diff --git a/.drone.yml b/.drone.yml index 45cbab5880..07ccb34f27 100644 --- a/.drone.yml +++ b/.drone.yml @@ -4,45 +4,67 @@ name: unit-tests steps: - name: bootstrap - image: signalwire/freeswitch-public-base - pull: true + image: signalwire/freeswitch-public-base:bullseye + pull: always commands: - cat /proc/sys/kernel/core_pattern - ./bootstrap.sh -j - name: configure - image: signalwire/freeswitch-public-base - pull: true + image: signalwire/freeswitch-public-base:bullseye + pull: always + environment: + REPOTOKEN: + from_secret: repotoken commands: - - apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -yq remove libspandsp-dev - - DEBIAN_FRONTEND=noninteractive apt-get -yq install libsofia-sip-ua-dev libspandsp3-dev - - echo "applications/mod_test" >> modules.conf + - echo "machine freeswitch.signalwire.com password $REPOTOKEN" > /etc/apt/auth.conf + - apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -yq remove libsofia-sip-ua0 libspandsp-dev + - DEBIAN_FRONTEND=noninteractive apt-get -yq install libspandsp3-dev + - export REPOTOKEN='' + - rm -rf /etc/apt/auth.conf + - git clone https://github.com/freeswitch/sofia-sip.git + - cd sofia-sip && ./autogen.sh && ./configure.gnu && make -j`nproc` && make install && cd .. - echo 'codecs/mod_openh264' >> modules.conf - sed -i '/applications\\/mod_http_cache/s/^#//g' modules.conf - sed -i '/event_handlers\\/mod_rayo/s/^#//g' modules.conf - sed -i '/formats\\/mod_opusfile/s/^#//g' modules.conf - sed -i '/languages\\/mod_lua/s/^#//g' modules.conf - - export ASAN_OPTIONS=log_path=stdout:disable_coredump=0:unmap_shadow_on_exit=1; - - ./configure --enable-address-sanitizer + - export ASAN_OPTIONS=log_path=stdout:disable_coredump=0:unmap_shadow_on_exit=1:fast_unwind_on_malloc=0 + - ./configure --enable-address-sanitizer --enable-fake-dlclose - name: build - image: signalwire/freeswitch-public-base - pull: true + image: signalwire/freeswitch-public-base:bullseye + pull: always + environment: + REPOTOKEN: + from_secret: repotoken commands: - - apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -yq remove libspandsp-dev - - DEBIAN_FRONTEND=noninteractive apt-get -yq install libsofia-sip-ua-dev libspandsp3-dev + - echo "machine freeswitch.signalwire.com password $REPOTOKEN" > /etc/apt/auth.conf + - apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -yq remove libsofia-sip-ua0 libspandsp-dev + - DEBIAN_FRONTEND=noninteractive apt-get -yq install libspandsp3-dev + - export REPOTOKEN='' + - rm -rf /etc/apt/auth.conf + - cd sofia-sip && make install && cd .. - echo '#!/bin/bash\nmake -j`nproc --all` |& tee ./unit-tests-build-result.txt\nexitstatus=$${PIPESTATUS[0]}\necho $$exitstatus > ./build-status.txt\n' > build.sh - chmod +x build.sh - ./build.sh - name: run-tests - image: signalwire/freeswitch-public-base - pull: true + image: signalwire/freeswitch-public-base:bullseye + pull: always + environment: + REPOTOKEN: + from_secret: repotoken commands: - - apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -yq remove libspandsp-dev - - DEBIAN_FRONTEND=noninteractive apt-get -yq install libsofia-sip-ua-dev libspandsp3-dev + - echo "machine freeswitch.signalwire.com password $REPOTOKEN" > /etc/apt/auth.conf + - apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -yq remove libsofia-sip-ua0 libspandsp-dev + - DEBIAN_FRONTEND=noninteractive apt-get -yq install libspandsp3-dev + - export REPOTOKEN='' + - rm -rf /etc/apt/auth.conf + - cd sofia-sip && make install && cd .. - make install || true - cd tests/unit + - export ASAN_OPTIONS=log_path=stdout:disable_coredump=0:unmap_shadow_on_exit=1:fast_unwind_on_malloc=0 - ./run-tests.sh - ls -la /cores - mkdir logs && (mv log_run-tests_*.html logs || true) && (mv backtrace_*.txt logs || true) @@ -53,7 +75,7 @@ steps: - name: notify image: signalwire/drone-notify - pull: true + pull: always environment: SLACK_WEBHOOK_URL: from_secret: slack_webhook_url @@ -61,7 +83,7 @@ steps: from_secret: notify_env commands: - /root/unit-tests-notify.sh - + trigger: branch: - master @@ -75,17 +97,23 @@ name: scan-build steps: - name: bootstrap - image: signalwire/freeswitch-public-base:stretch - pull: true + image: signalwire/freeswitch-public-base:bullseye + pull: always commands: - ./bootstrap.sh -j - name: configure - image: signalwire/freeswitch-public-base:stretch - pull: true + image: signalwire/freeswitch-public-base:bullseye + pull: always + environment: + REPOTOKEN: + from_secret: repotoken commands: + - echo "machine freeswitch.signalwire.com password $REPOTOKEN" > /etc/apt/auth.conf - apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -yq remove libspandsp-dev - DEBIAN_FRONTEND=noninteractive apt-get -yq install libsofia-sip-ua-dev libspandsp3-dev + - export REPOTOKEN='' + - rm -rf /etc/apt/auth.conf - cp build/modules.conf.most modules.conf #Enable/Uncomment mods - echo 'codecs/mod_openh264' >> modules.conf @@ -112,13 +140,19 @@ steps: - ./configure - name: scan-build - image: signalwire/freeswitch-public-base:stretch - pull: true + image: signalwire/freeswitch-public-base:bullseye + pull: always + environment: + REPOTOKEN: + from_secret: repotoken commands: + - echo "machine freeswitch.signalwire.com password $REPOTOKEN" > /etc/apt/auth.conf - apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -yq remove libspandsp-dev - DEBIAN_FRONTEND=noninteractive apt-get -yq install libsofia-sip-ua-dev libspandsp3-dev + - export REPOTOKEN='' + - rm -rf /etc/apt/auth.conf - mkdir -p scan-build - - echo '#!/bin/bash\nscan-build-4.0 -o ./scan-build/ make -j`nproc --all` |& tee ./scan-build-result.txt\nexitstatus=$${PIPESTATUS[0]}\necho $$exitstatus > ./scan-build-status.txt\n' > scan.sh + - echo '#!/bin/bash\nscan-build-11 -o ./scan-build/ make -j`nproc --all` |& tee ./scan-build-result.txt\nexitstatus=$${PIPESTATUS[0]}\necho $$exitstatus > ./scan-build-status.txt\n' > scan.sh - chmod +x scan.sh - ./scan.sh - exitstatus=`cat ./scan-build-status.txt` @@ -126,7 +160,7 @@ steps: - name: notify image: signalwire/drone-notify - pull: true + pull: always environment: SLACK_WEBHOOK_URL: from_secret: slack_webhook_url @@ -135,7 +169,6 @@ steps: commands: - /root/scan-build-notify.sh - trigger: branch: - master @@ -145,6 +178,6 @@ trigger: --- kind: signature -hmac: af77439b382612b49140cb95f04d6d695e0a188c411ae227abcba205bf96bab9 +hmac: 780e4aaee61e3683ea4a8d6fe5131f7c9e62ebad727546013f18df0fca80d705 ... diff --git a/.gitignore b/.gitignore index a4fb5ca6f6..0461c273de 100644 --- a/.gitignore +++ b/.gitignore @@ -102,6 +102,7 @@ Release/ /build/config/ltmain.sh /build/config/missing /build/freeswitch.pc +/build/standalone_module/freeswitch.pc /build/getlib.sh /build/getg729.sh /build/getsounds.sh @@ -115,15 +116,6 @@ Release/ /libs/esl/fs_ivrd /libs/esl/testclient /libs/esl/testserver -/libs/freetdm/detect_dtmf -/libs/freetdm/detect_tones -/libs/freetdm/testanalog -/libs/freetdm/testapp -/libs/freetdm/testcid -/libs/freetdm/testpri -/libs/freetdm/testr2 -/libs/freetdm/testsangomaboost -/libs/freetdm/testtones /libs/fsg729-*-installer /libs/g729/ /libs/libcodec2/compile @@ -165,6 +157,7 @@ Release/ /src/mod/languages/mod_lua/mod_lua_wrap.cpp.orig /src/mod/languages/mod_perl/mod_perl_wrap.cpp.orig /src/mod/languages/mod_python/mod_python_wrap.cpp.orig +/src/mod/languages/mod_python3/mod_python_wrap.cpp.orig /src/mod/say/mod_say_de/Makefile /src/mod/say/mod_say_es/Makefile /src/mod/say/mod_say_fr/Makefile @@ -273,9 +266,18 @@ src/mod/applications/mod_http_cache/test/test_aws.log src/mod/applications/mod_http_cache/test/test_aws.trs src/mod/formats/mod_sndfile/test/test_sndfile src/mod/formats/mod_sndfile/test/test_sndfile_conf +src/mod/formats/mod_ssml/test/test_tts_format src/mod/*/*/test/*.log src/mod/*/*/test/*.trs src/mod/*/*/test/[0-9]*/* test-suite.log src/mod/applications/mod_av/test/test_BT7.mp4 src/mod/applications/mod_av/test/test_RGB.mp4 +images/test-argb.png +images/test-rgb.png +images/test.png +images/test_patched.png +images/test_text.png + +src/mod/codecs/mod_amrwb/test/test_amrwb +src/mod/endpoints/mod_sofia/test/sipp-based-tests diff --git a/Freeswitch.2017.sln b/Freeswitch.2017.sln index b708f4e9ca..5f3259a6e0 100644 --- a/Freeswitch.2017.sln +++ b/Freeswitch.2017.sln @@ -69,7 +69,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "autoload_configs", "autoloa conf\vanilla\autoload_configs\conference.conf.xml = conf\vanilla\autoload_configs\conference.conf.xml conf\vanilla\autoload_configs\console.conf.xml = conf\vanilla\autoload_configs\console.conf.xml conf\vanilla\autoload_configs\dialplan_directory.conf.xml = conf\vanilla\autoload_configs\dialplan_directory.conf.xml - conf\vanilla\autoload_configs\dingaling.conf.xml = conf\vanilla\autoload_configs\dingaling.conf.xml conf\vanilla\autoload_configs\enum.conf.xml = conf\vanilla\autoload_configs\enum.conf.xml conf\vanilla\autoload_configs\event_multicast.conf.xml = conf\vanilla\autoload_configs\event_multicast.conf.xml conf\vanilla\autoload_configs\event_socket.conf.xml = conf\vanilla\autoload_configs\event_socket.conf.xml @@ -166,8 +165,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "vm", "vm", "{3DAF028C-AB5B- EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Sound Files", "Sound Files", "{4F227C26-768F-46A3-8684-1D08A46FB374}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "unimrcp", "unimrcp", "{62F27B1A-C919-4A70-8478-51F178F3B18F}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeSwitchConsole", "w32\Console\FreeSwitchConsole.2017.vcxproj", "{1AF3A893-F7BE-43DD-B697-8AB2397C0D67}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeSwitchCoreLib", "w32\Library\FreeSwitchCore.2017.vcxproj", "{202D7A4E-760D-4D0E-AFA1-D7459CED30FF}" @@ -198,8 +195,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_cepstral", "src\mod\asr EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_ilbc", "src\mod\codecs\mod_ilbc\mod_ilbc.2017.vcxproj", "{D3EC0AFF-76FC-4210-A825-9A17410660A3}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_dingaling", "src\mod\endpoints\mod_dingaling\mod_dingaling.2017.vcxproj", "{FFAA4C52-3A53-4F99-90C1-D59D1F0427F3}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_commands", "src\mod\applications\mod_commands\mod_commands.2017.vcxproj", "{30A5B29C-983E-4580-9FD0-D647CCDCC7EB}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_console", "src\mod\loggers\mod_console\mod_console.2017.vcxproj", "{1C453396-D912-4213-89FD-9B489162B7B5}" @@ -217,20 +212,14 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_dptools", "src\mod\appl EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_event_socket", "src\mod\event_handlers\mod_event_socket\mod_event_socket.2017.vcxproj", "{05515420-16DE-4E63-BE73-85BE85BA5142}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libdingaling", "libs\libdingaling\libdingaling.2017.vcxproj", "{1906D736-08BD-4EE1-924F-B536249B9A54}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libsrtp", "libs\srtp\libsrtp.2017.vcxproj", "{EEF031CB-FED8-451E-A471-91EC8D4F6750}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libsqlite", "libs\win32\sqlite\sqlite.2017.vcxproj", "{6EDFEFD5-3596-4FA9-8EBA-B331547B35A3}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libapr", "libs\win32\apr\libapr.2017.vcxproj", "{F6C55D93-B927-4483-BB69-15AEF3DD2DFF}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libaprutil", "libs\win32\apr-util\libaprutil.2017.vcxproj", "{F057DA7F-79E5-4B00-845C-EF446EF055E3}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "iksemel", "libs\win32\iksemel\iksemel.2017.vcxproj", "{E727E8F6-935D-46FE-8B0E-37834748A0E3}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xml", "libs\win32\apr-util\xml.2017.vcxproj", "{155844C3-EC5F-407F-97A4-A2DDADED9B2F}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_sofia", "src\mod\endpoints\mod_sofia\mod_sofia.2017.vcxproj", "{0DF3ABD0-DDC0-4265-B778-07C66780979B}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pthread", "libs\win32\pthread\pthread.2017.vcxproj", "{DF018947-0FFF-4EB3-BDEE-441DC81DA7A4}" @@ -380,29 +369,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libbroadvoice", "libs\win32 EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_bv", "src\mod\codecs\mod_bv\mod_bv.2017.vcxproj", "{D5C87B19-150D-4EF3-A671-96589BD2D14A}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aprtoolkit", "libs\unimrcp\libs\apr-toolkit\aprtoolkit.2017.vcxproj", "{13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2}" - ProjectSection(ProjectDependencies) = postProject - {155844C3-EC5F-407F-97A4-A2DDADED9B2F} = {155844C3-EC5F-407F-97A4-A2DDADED9B2F} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpf", "libs\unimrcp\libs\mpf\mpf.2017.vcxproj", "{B5A00BFA-6083-4FAE-A097-71642D6473B5}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mrcp", "libs\unimrcp\libs\mrcp\mrcp.2017.vcxproj", "{1C320193-46A6-4B34-9C56-8AB584FC1B56}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mrcpclient", "libs\unimrcp\libs\mrcp-client\mrcpclient.2017.vcxproj", "{72782932-37CC-46AE-8C7F-9A7B1A6EE108}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mrcpsignaling", "libs\unimrcp\libs\mrcp-signaling\mrcpsignaling.2017.vcxproj", "{12A49562-BAB9-43A3-A21D-15B60BBB4C31}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mrcpv2transport", "libs\unimrcp\libs\mrcpv2-transport\mrcpv2transport.2017.vcxproj", "{A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unirtsp", "libs\unimrcp\libs\uni-rtsp\unirtsp.2017.vcxproj", "{504B3154-7A4F-459D-9877-B951021C3F1F}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mrcpsofiasip", "libs\unimrcp\modules\mrcp-sofiasip\mrcpsofiasip.2017.vcxproj", "{746F3632-5BB2-4570-9453-31D6D58A7D8E}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mrcpunirtsp", "libs\unimrcp\modules\mrcp-unirtsp\mrcpunirtsp.2017.vcxproj", "{DEB01ACB-D65F-4A62-AED9-58C1054499E9}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_unimrcp", "src\mod\asr_tts\mod_unimrcp\mod_unimrcp.2017.vcxproj", "{D07C378A-F5F7-438F-ADF3-4AC4FB1883CD}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcelt", "libs\win32\celt\libcelt.2017.vcxproj", "{ABB71A76-42B0-47A4-973A-42E3D920C6FD}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FSComm", "fscomm\FSComm.2017.vcxproj", "{7D3122C7-C9D0-3748-81F8-F0DDCB40BF5E}" @@ -451,8 +417,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gsmlib", "src\mod\endpoints EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_gsmopen", "src\mod\endpoints\mod_gsmopen\mod_gsmopen.2017.vcxproj", "{74B120FF-6935-4DFE-A142-CDB6BEA99C90}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libzrtp", "libs\libzrtp\projects\win\libzrtp.2017.vcxproj", "{C13CC324-0032-4492-9A30-310A6BD64FF5}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_redis", "src\mod\applications\mod_redis\mod_redis.2017.vcxproj", "{886B5E9D-F2C2-4AF2-98C8-EF98C4C770E6}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libjpeg", "libs\win32\libjpeg\libjpeg.2017.vcxproj", "{019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1}" @@ -752,17 +716,6 @@ Global {D3EC0AFF-76FC-4210-A825-9A17410660A3}.Release|Win32.Build.0 = Release|Win32 {D3EC0AFF-76FC-4210-A825-9A17410660A3}.Release|x64.ActiveCfg = Release|x64 {D3EC0AFF-76FC-4210-A825-9A17410660A3}.Release|x64.Build.0 = Release|x64 - {FFAA4C52-3A53-4F99-90C1-D59D1F0427F3}.All|Win32.ActiveCfg = Release|x64 - {FFAA4C52-3A53-4F99-90C1-D59D1F0427F3}.All|x64.ActiveCfg = Release|x64 - {FFAA4C52-3A53-4F99-90C1-D59D1F0427F3}.All|x64.Build.0 = Release|x64 - {FFAA4C52-3A53-4F99-90C1-D59D1F0427F3}.Debug|Win32.ActiveCfg = Debug|Win32 - {FFAA4C52-3A53-4F99-90C1-D59D1F0427F3}.Debug|Win32.Build.0 = Debug|Win32 - {FFAA4C52-3A53-4F99-90C1-D59D1F0427F3}.Debug|x64.ActiveCfg = Debug|x64 - {FFAA4C52-3A53-4F99-90C1-D59D1F0427F3}.Debug|x64.Build.0 = Debug|x64 - {FFAA4C52-3A53-4F99-90C1-D59D1F0427F3}.Release|Win32.ActiveCfg = Release|Win32 - {FFAA4C52-3A53-4F99-90C1-D59D1F0427F3}.Release|Win32.Build.0 = Release|Win32 - {FFAA4C52-3A53-4F99-90C1-D59D1F0427F3}.Release|x64.ActiveCfg = Release|x64 - {FFAA4C52-3A53-4F99-90C1-D59D1F0427F3}.Release|x64.Build.0 = Release|x64 {30A5B29C-983E-4580-9FD0-D647CCDCC7EB}.All|Win32.ActiveCfg = Release|x64 {30A5B29C-983E-4580-9FD0-D647CCDCC7EB}.All|x64.ActiveCfg = Release|x64 {30A5B29C-983E-4580-9FD0-D647CCDCC7EB}.All|x64.Build.0 = Release|x64 @@ -840,17 +793,6 @@ Global {05515420-16DE-4E63-BE73-85BE85BA5142}.Release|Win32.Build.0 = Release|Win32 {05515420-16DE-4E63-BE73-85BE85BA5142}.Release|x64.ActiveCfg = Release|x64 {05515420-16DE-4E63-BE73-85BE85BA5142}.Release|x64.Build.0 = Release|x64 - {1906D736-08BD-4EE1-924F-B536249B9A54}.All|Win32.ActiveCfg = Release DLL|x64 - {1906D736-08BD-4EE1-924F-B536249B9A54}.All|x64.ActiveCfg = Release DLL|x64 - {1906D736-08BD-4EE1-924F-B536249B9A54}.All|x64.Build.0 = Release DLL|x64 - {1906D736-08BD-4EE1-924F-B536249B9A54}.Debug|Win32.ActiveCfg = Debug|Win32 - {1906D736-08BD-4EE1-924F-B536249B9A54}.Debug|Win32.Build.0 = Debug|Win32 - {1906D736-08BD-4EE1-924F-B536249B9A54}.Debug|x64.ActiveCfg = Debug|x64 - {1906D736-08BD-4EE1-924F-B536249B9A54}.Debug|x64.Build.0 = Debug|x64 - {1906D736-08BD-4EE1-924F-B536249B9A54}.Release|Win32.ActiveCfg = Release|Win32 - {1906D736-08BD-4EE1-924F-B536249B9A54}.Release|Win32.Build.0 = Release|Win32 - {1906D736-08BD-4EE1-924F-B536249B9A54}.Release|x64.ActiveCfg = Release|x64 - {1906D736-08BD-4EE1-924F-B536249B9A54}.Release|x64.Build.0 = Release|x64 {EEF031CB-FED8-451E-A471-91EC8D4F6750}.All|Win32.ActiveCfg = Release Dll|x64 {EEF031CB-FED8-451E-A471-91EC8D4F6750}.All|x64.ActiveCfg = Release Dll|x64 {EEF031CB-FED8-451E-A471-91EC8D4F6750}.All|x64.Build.0 = Release Dll|x64 @@ -884,17 +826,6 @@ Global {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}.Release|Win32.Build.0 = Release|Win32 {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}.Release|x64.ActiveCfg = Release|x64 {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}.Release|x64.Build.0 = Release|x64 - {F057DA7F-79E5-4B00-845C-EF446EF055E3}.All|Win32.ActiveCfg = Release|x64 - {F057DA7F-79E5-4B00-845C-EF446EF055E3}.All|x64.ActiveCfg = Release|x64 - {F057DA7F-79E5-4B00-845C-EF446EF055E3}.All|x64.Build.0 = Release|x64 - {F057DA7F-79E5-4B00-845C-EF446EF055E3}.Debug|Win32.ActiveCfg = Debug|Win32 - {F057DA7F-79E5-4B00-845C-EF446EF055E3}.Debug|Win32.Build.0 = Debug|Win32 - {F057DA7F-79E5-4B00-845C-EF446EF055E3}.Debug|x64.ActiveCfg = Debug|x64 - {F057DA7F-79E5-4B00-845C-EF446EF055E3}.Debug|x64.Build.0 = Debug|x64 - {F057DA7F-79E5-4B00-845C-EF446EF055E3}.Release|Win32.ActiveCfg = Release|Win32 - {F057DA7F-79E5-4B00-845C-EF446EF055E3}.Release|Win32.Build.0 = Release|Win32 - {F057DA7F-79E5-4B00-845C-EF446EF055E3}.Release|x64.ActiveCfg = Release|x64 - {F057DA7F-79E5-4B00-845C-EF446EF055E3}.Release|x64.Build.0 = Release|x64 {E727E8F6-935D-46FE-8B0E-37834748A0E3}.All|Win32.ActiveCfg = Release|x64 {E727E8F6-935D-46FE-8B0E-37834748A0E3}.All|x64.ActiveCfg = Release|x64 {E727E8F6-935D-46FE-8B0E-37834748A0E3}.All|x64.Build.0 = Release|x64 @@ -906,17 +837,6 @@ Global {E727E8F6-935D-46FE-8B0E-37834748A0E3}.Release|Win32.Build.0 = Release|Win32 {E727E8F6-935D-46FE-8B0E-37834748A0E3}.Release|x64.ActiveCfg = Release|x64 {E727E8F6-935D-46FE-8B0E-37834748A0E3}.Release|x64.Build.0 = Release|x64 - {155844C3-EC5F-407F-97A4-A2DDADED9B2F}.All|Win32.ActiveCfg = Debug|x64 - {155844C3-EC5F-407F-97A4-A2DDADED9B2F}.All|x64.ActiveCfg = Debug|x64 - {155844C3-EC5F-407F-97A4-A2DDADED9B2F}.All|x64.Build.0 = Debug|x64 - {155844C3-EC5F-407F-97A4-A2DDADED9B2F}.Debug|Win32.ActiveCfg = Debug|Win32 - {155844C3-EC5F-407F-97A4-A2DDADED9B2F}.Debug|Win32.Build.0 = Debug|Win32 - {155844C3-EC5F-407F-97A4-A2DDADED9B2F}.Debug|x64.ActiveCfg = Debug|x64 - {155844C3-EC5F-407F-97A4-A2DDADED9B2F}.Debug|x64.Build.0 = Debug|x64 - {155844C3-EC5F-407F-97A4-A2DDADED9B2F}.Release|Win32.ActiveCfg = Release|Win32 - {155844C3-EC5F-407F-97A4-A2DDADED9B2F}.Release|Win32.Build.0 = Release|Win32 - {155844C3-EC5F-407F-97A4-A2DDADED9B2F}.Release|x64.ActiveCfg = Release|x64 - {155844C3-EC5F-407F-97A4-A2DDADED9B2F}.Release|x64.Build.0 = Release|x64 {0DF3ABD0-DDC0-4265-B778-07C66780979B}.All|Win32.ActiveCfg = Release|x64 {0DF3ABD0-DDC0-4265-B778-07C66780979B}.All|x64.ActiveCfg = Release|x64 {0DF3ABD0-DDC0-4265-B778-07C66780979B}.All|x64.Build.0 = Release|x64 @@ -1697,116 +1617,6 @@ Global {D5C87B19-150D-4EF3-A671-96589BD2D14A}.Release|Win32.Build.0 = Release|Win32 {D5C87B19-150D-4EF3-A671-96589BD2D14A}.Release|x64.ActiveCfg = Release|x64 {D5C87B19-150D-4EF3-A671-96589BD2D14A}.Release|x64.Build.0 = Release|x64 - {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2}.All|Win32.ActiveCfg = Release|Win32 - {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2}.All|Win32.Build.0 = Release|Win32 - {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2}.All|x64.ActiveCfg = Release|Win32 - {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2}.Debug|Win32.ActiveCfg = Debug|Win32 - {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2}.Debug|Win32.Build.0 = Debug|Win32 - {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2}.Debug|x64.ActiveCfg = Debug|x64 - {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2}.Debug|x64.Build.0 = Debug|x64 - {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2}.Release|Win32.ActiveCfg = Release|Win32 - {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2}.Release|Win32.Build.0 = Release|Win32 - {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2}.Release|x64.ActiveCfg = Release|x64 - {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2}.Release|x64.Build.0 = Release|x64 - {B5A00BFA-6083-4FAE-A097-71642D6473B5}.All|Win32.ActiveCfg = Release|Win32 - {B5A00BFA-6083-4FAE-A097-71642D6473B5}.All|Win32.Build.0 = Release|Win32 - {B5A00BFA-6083-4FAE-A097-71642D6473B5}.All|x64.ActiveCfg = Release|Win32 - {B5A00BFA-6083-4FAE-A097-71642D6473B5}.Debug|Win32.ActiveCfg = Debug|Win32 - {B5A00BFA-6083-4FAE-A097-71642D6473B5}.Debug|Win32.Build.0 = Debug|Win32 - {B5A00BFA-6083-4FAE-A097-71642D6473B5}.Debug|x64.ActiveCfg = Debug|x64 - {B5A00BFA-6083-4FAE-A097-71642D6473B5}.Debug|x64.Build.0 = Debug|x64 - {B5A00BFA-6083-4FAE-A097-71642D6473B5}.Release|Win32.ActiveCfg = Release|Win32 - {B5A00BFA-6083-4FAE-A097-71642D6473B5}.Release|Win32.Build.0 = Release|Win32 - {B5A00BFA-6083-4FAE-A097-71642D6473B5}.Release|x64.ActiveCfg = Release|x64 - {B5A00BFA-6083-4FAE-A097-71642D6473B5}.Release|x64.Build.0 = Release|x64 - {1C320193-46A6-4B34-9C56-8AB584FC1B56}.All|Win32.ActiveCfg = Release|Win32 - {1C320193-46A6-4B34-9C56-8AB584FC1B56}.All|Win32.Build.0 = Release|Win32 - {1C320193-46A6-4B34-9C56-8AB584FC1B56}.All|x64.ActiveCfg = Release|Win32 - {1C320193-46A6-4B34-9C56-8AB584FC1B56}.Debug|Win32.ActiveCfg = Debug|Win32 - {1C320193-46A6-4B34-9C56-8AB584FC1B56}.Debug|Win32.Build.0 = Debug|Win32 - {1C320193-46A6-4B34-9C56-8AB584FC1B56}.Debug|x64.ActiveCfg = Debug|x64 - {1C320193-46A6-4B34-9C56-8AB584FC1B56}.Debug|x64.Build.0 = Debug|x64 - {1C320193-46A6-4B34-9C56-8AB584FC1B56}.Release|Win32.ActiveCfg = Release|Win32 - {1C320193-46A6-4B34-9C56-8AB584FC1B56}.Release|Win32.Build.0 = Release|Win32 - {1C320193-46A6-4B34-9C56-8AB584FC1B56}.Release|x64.ActiveCfg = Release|x64 - {1C320193-46A6-4B34-9C56-8AB584FC1B56}.Release|x64.Build.0 = Release|x64 - {72782932-37CC-46AE-8C7F-9A7B1A6EE108}.All|Win32.ActiveCfg = Release|Win32 - {72782932-37CC-46AE-8C7F-9A7B1A6EE108}.All|Win32.Build.0 = Release|Win32 - {72782932-37CC-46AE-8C7F-9A7B1A6EE108}.All|x64.ActiveCfg = Release|Win32 - {72782932-37CC-46AE-8C7F-9A7B1A6EE108}.Debug|Win32.ActiveCfg = Debug|Win32 - {72782932-37CC-46AE-8C7F-9A7B1A6EE108}.Debug|Win32.Build.0 = Debug|Win32 - {72782932-37CC-46AE-8C7F-9A7B1A6EE108}.Debug|x64.ActiveCfg = Debug|x64 - {72782932-37CC-46AE-8C7F-9A7B1A6EE108}.Debug|x64.Build.0 = Debug|x64 - {72782932-37CC-46AE-8C7F-9A7B1A6EE108}.Release|Win32.ActiveCfg = Release|Win32 - {72782932-37CC-46AE-8C7F-9A7B1A6EE108}.Release|Win32.Build.0 = Release|Win32 - {72782932-37CC-46AE-8C7F-9A7B1A6EE108}.Release|x64.ActiveCfg = Release|x64 - {72782932-37CC-46AE-8C7F-9A7B1A6EE108}.Release|x64.Build.0 = Release|x64 - {12A49562-BAB9-43A3-A21D-15B60BBB4C31}.All|Win32.ActiveCfg = Release|Win32 - {12A49562-BAB9-43A3-A21D-15B60BBB4C31}.All|Win32.Build.0 = Release|Win32 - {12A49562-BAB9-43A3-A21D-15B60BBB4C31}.All|x64.ActiveCfg = Release|Win32 - {12A49562-BAB9-43A3-A21D-15B60BBB4C31}.Debug|Win32.ActiveCfg = Debug|Win32 - {12A49562-BAB9-43A3-A21D-15B60BBB4C31}.Debug|Win32.Build.0 = Debug|Win32 - {12A49562-BAB9-43A3-A21D-15B60BBB4C31}.Debug|x64.ActiveCfg = Debug|x64 - {12A49562-BAB9-43A3-A21D-15B60BBB4C31}.Debug|x64.Build.0 = Debug|x64 - {12A49562-BAB9-43A3-A21D-15B60BBB4C31}.Release|Win32.ActiveCfg = Release|Win32 - {12A49562-BAB9-43A3-A21D-15B60BBB4C31}.Release|Win32.Build.0 = Release|Win32 - {12A49562-BAB9-43A3-A21D-15B60BBB4C31}.Release|x64.ActiveCfg = Release|x64 - {12A49562-BAB9-43A3-A21D-15B60BBB4C31}.Release|x64.Build.0 = Release|x64 - {A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA}.All|Win32.ActiveCfg = Release|Win32 - {A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA}.All|Win32.Build.0 = Release|Win32 - {A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA}.All|x64.ActiveCfg = Release|Win32 - {A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA}.Debug|Win32.ActiveCfg = Debug|Win32 - {A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA}.Debug|Win32.Build.0 = Debug|Win32 - {A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA}.Debug|x64.ActiveCfg = Debug|x64 - {A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA}.Debug|x64.Build.0 = Debug|x64 - {A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA}.Release|Win32.ActiveCfg = Release|Win32 - {A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA}.Release|Win32.Build.0 = Release|Win32 - {A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA}.Release|x64.ActiveCfg = Release|x64 - {A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA}.Release|x64.Build.0 = Release|x64 - {504B3154-7A4F-459D-9877-B951021C3F1F}.All|Win32.ActiveCfg = Release|Win32 - {504B3154-7A4F-459D-9877-B951021C3F1F}.All|Win32.Build.0 = Release|Win32 - {504B3154-7A4F-459D-9877-B951021C3F1F}.All|x64.ActiveCfg = Release|Win32 - {504B3154-7A4F-459D-9877-B951021C3F1F}.Debug|Win32.ActiveCfg = Debug|Win32 - {504B3154-7A4F-459D-9877-B951021C3F1F}.Debug|Win32.Build.0 = Debug|Win32 - {504B3154-7A4F-459D-9877-B951021C3F1F}.Debug|x64.ActiveCfg = Debug|x64 - {504B3154-7A4F-459D-9877-B951021C3F1F}.Debug|x64.Build.0 = Debug|x64 - {504B3154-7A4F-459D-9877-B951021C3F1F}.Release|Win32.ActiveCfg = Release|Win32 - {504B3154-7A4F-459D-9877-B951021C3F1F}.Release|Win32.Build.0 = Release|Win32 - {504B3154-7A4F-459D-9877-B951021C3F1F}.Release|x64.ActiveCfg = Release|x64 - {504B3154-7A4F-459D-9877-B951021C3F1F}.Release|x64.Build.0 = Release|x64 - {746F3632-5BB2-4570-9453-31D6D58A7D8E}.All|Win32.ActiveCfg = Release|Win32 - {746F3632-5BB2-4570-9453-31D6D58A7D8E}.All|Win32.Build.0 = Release|Win32 - {746F3632-5BB2-4570-9453-31D6D58A7D8E}.All|x64.ActiveCfg = Release|Win32 - {746F3632-5BB2-4570-9453-31D6D58A7D8E}.Debug|Win32.ActiveCfg = Debug|Win32 - {746F3632-5BB2-4570-9453-31D6D58A7D8E}.Debug|Win32.Build.0 = Debug|Win32 - {746F3632-5BB2-4570-9453-31D6D58A7D8E}.Debug|x64.ActiveCfg = Debug|x64 - {746F3632-5BB2-4570-9453-31D6D58A7D8E}.Debug|x64.Build.0 = Debug|x64 - {746F3632-5BB2-4570-9453-31D6D58A7D8E}.Release|Win32.ActiveCfg = Release|Win32 - {746F3632-5BB2-4570-9453-31D6D58A7D8E}.Release|Win32.Build.0 = Release|Win32 - {746F3632-5BB2-4570-9453-31D6D58A7D8E}.Release|x64.ActiveCfg = Release|x64 - {746F3632-5BB2-4570-9453-31D6D58A7D8E}.Release|x64.Build.0 = Release|x64 - {DEB01ACB-D65F-4A62-AED9-58C1054499E9}.All|Win32.ActiveCfg = Release|Win32 - {DEB01ACB-D65F-4A62-AED9-58C1054499E9}.All|Win32.Build.0 = Release|Win32 - {DEB01ACB-D65F-4A62-AED9-58C1054499E9}.All|x64.ActiveCfg = Release|Win32 - {DEB01ACB-D65F-4A62-AED9-58C1054499E9}.Debug|Win32.ActiveCfg = Debug|Win32 - {DEB01ACB-D65F-4A62-AED9-58C1054499E9}.Debug|Win32.Build.0 = Debug|Win32 - {DEB01ACB-D65F-4A62-AED9-58C1054499E9}.Debug|x64.ActiveCfg = Debug|x64 - {DEB01ACB-D65F-4A62-AED9-58C1054499E9}.Debug|x64.Build.0 = Debug|x64 - {DEB01ACB-D65F-4A62-AED9-58C1054499E9}.Release|Win32.ActiveCfg = Release|Win32 - {DEB01ACB-D65F-4A62-AED9-58C1054499E9}.Release|Win32.Build.0 = Release|Win32 - {DEB01ACB-D65F-4A62-AED9-58C1054499E9}.Release|x64.ActiveCfg = Release|x64 - {DEB01ACB-D65F-4A62-AED9-58C1054499E9}.Release|x64.Build.0 = Release|x64 - {D07C378A-F5F7-438F-ADF3-4AC4FB1883CD}.All|Win32.ActiveCfg = Release|x64 - {D07C378A-F5F7-438F-ADF3-4AC4FB1883CD}.All|x64.ActiveCfg = Release|x64 - {D07C378A-F5F7-438F-ADF3-4AC4FB1883CD}.All|x64.Build.0 = Release|x64 - {D07C378A-F5F7-438F-ADF3-4AC4FB1883CD}.Debug|Win32.ActiveCfg = Debug|Win32 - {D07C378A-F5F7-438F-ADF3-4AC4FB1883CD}.Debug|Win32.Build.0 = Debug|Win32 - {D07C378A-F5F7-438F-ADF3-4AC4FB1883CD}.Debug|x64.ActiveCfg = Debug|x64 - {D07C378A-F5F7-438F-ADF3-4AC4FB1883CD}.Debug|x64.Build.0 = Debug|x64 - {D07C378A-F5F7-438F-ADF3-4AC4FB1883CD}.Release|Win32.ActiveCfg = Release|Win32 - {D07C378A-F5F7-438F-ADF3-4AC4FB1883CD}.Release|Win32.Build.0 = Release|Win32 - {D07C378A-F5F7-438F-ADF3-4AC4FB1883CD}.Release|x64.ActiveCfg = Release|x64 - {D07C378A-F5F7-438F-ADF3-4AC4FB1883CD}.Release|x64.Build.0 = Release|x64 {ABB71A76-42B0-47A4-973A-42E3D920C6FD}.All|Win32.ActiveCfg = Release|x64 {ABB71A76-42B0-47A4-973A-42E3D920C6FD}.All|x64.ActiveCfg = Release|x64 {ABB71A76-42B0-47A4-973A-42E3D920C6FD}.All|x64.Build.0 = Release|x64 @@ -2053,17 +1863,6 @@ Global {74B120FF-6935-4DFE-A142-CDB6BEA99C90}.Release|Win32.Build.0 = Release|Win32 {74B120FF-6935-4DFE-A142-CDB6BEA99C90}.Release|x64.ActiveCfg = Release|x64 {74B120FF-6935-4DFE-A142-CDB6BEA99C90}.Release|x64.Build.0 = Release|x64 - {C13CC324-0032-4492-9A30-310A6BD64FF5}.All|Win32.ActiveCfg = Release|Win32 - {C13CC324-0032-4492-9A30-310A6BD64FF5}.All|Win32.Build.0 = Release|Win32 - {C13CC324-0032-4492-9A30-310A6BD64FF5}.All|x64.ActiveCfg = Release|Win32 - {C13CC324-0032-4492-9A30-310A6BD64FF5}.Debug|Win32.ActiveCfg = Debug|Win32 - {C13CC324-0032-4492-9A30-310A6BD64FF5}.Debug|Win32.Build.0 = Debug|Win32 - {C13CC324-0032-4492-9A30-310A6BD64FF5}.Debug|x64.ActiveCfg = Debug|x64 - {C13CC324-0032-4492-9A30-310A6BD64FF5}.Debug|x64.Build.0 = Debug|x64 - {C13CC324-0032-4492-9A30-310A6BD64FF5}.Release|Win32.ActiveCfg = Release|Win32 - {C13CC324-0032-4492-9A30-310A6BD64FF5}.Release|Win32.Build.0 = Release|Win32 - {C13CC324-0032-4492-9A30-310A6BD64FF5}.Release|x64.ActiveCfg = Release|x64 - {C13CC324-0032-4492-9A30-310A6BD64FF5}.Release|x64.Build.0 = Release|x64 {886B5E9D-F2C2-4AF2-98C8-EF98C4C770E6}.All|Win32.ActiveCfg = Release|x64 {886B5E9D-F2C2-4AF2-98C8-EF98C4C770E6}.All|x64.ActiveCfg = Release|x64 {886B5E9D-F2C2-4AF2-98C8-EF98C4C770E6}.All|x64.Build.0 = Release|x64 @@ -2739,7 +2538,6 @@ Global {713E4747-1126-40B1-BD84-58F9A7745423} = {57199684-EC63-4A60-9DC6-11815AF6B413} {F1B71990-EB04-4EB5-B28A-BC3EB6F7E843} = {D4A12E4C-DBDA-4614-BA26-3425AE9F60F5} {3DAF028C-AB5B-4183-A01B-DCC43F5A87F0} = {D4A12E4C-DBDA-4614-BA26-3425AE9F60F5} - {62F27B1A-C919-4A70-8478-51F178F3B18F} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} {1D95CD95-0DE2-48C3-AC23-D5C7D1C9C0F0} = {F881ADA2-2F1A-4046-9FEB-191D9422D781} {AFAC0568-7548-42D5-9F6A-8D3400A1E4F6} = {A5A27244-AD24-46E5-B01B-840CD296C91D} {5FD31A25-5D83-4794-8BEE-904DAD84CE71} = {9460B5F1-0A95-41C4-BEB7-9C2C96459A7C} @@ -2753,7 +2551,6 @@ Global {8B754330-A434-4791-97E5-1EE67060BAC0} = {0C808854-54D1-4230-BFF5-77B5FD905000} {692F6330-4D87-4C82-81DF-40DB5892636E} = {4CF6A6AC-07DE-4B9E-ABE1-7F98B64E0BB0} {D3EC0AFF-76FC-4210-A825-9A17410660A3} = {F881ADA2-2F1A-4046-9FEB-191D9422D781} - {FFAA4C52-3A53-4F99-90C1-D59D1F0427F3} = {9460B5F1-0A95-41C4-BEB7-9C2C96459A7C} {30A5B29C-983E-4580-9FD0-D647CCDCC7EB} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78} {1C453396-D912-4213-89FD-9B489162B7B5} = {A7AB4405-FDB7-4853-9FBB-1516B1C3D80A} {CBEC7225-0C21-4DA8-978E-1F158F8AD950} = {F69A4A6B-9360-4EBB-A280-22AA3C455AC5} @@ -2761,13 +2558,10 @@ Global {C24FB505-05D7-4319-8485-7540B44C8603} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78} {B5881A85-FE70-4F64-8607-2CAAE52669C6} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78} {05515420-16DE-4E63-BE73-85BE85BA5142} = {9ADF1E48-2F5C-4ED7-A893-596259FABFE0} - {1906D736-08BD-4EE1-924F-B536249B9A54} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} {EEF031CB-FED8-451E-A471-91EC8D4F6750} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} {6EDFEFD5-3596-4FA9-8EBA-B331547B35A3} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} - {F057DA7F-79E5-4B00-845C-EF446EF055E3} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} {E727E8F6-935D-46FE-8B0E-37834748A0E3} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} - {155844C3-EC5F-407F-97A4-A2DDADED9B2F} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} {0DF3ABD0-DDC0-4265-B778-07C66780979B} = {9460B5F1-0A95-41C4-BEB7-9C2C96459A7C} {DF018947-0FFF-4EB3-BDEE-441DC81DA7A4} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} {FEA1EEF7-876F-48DE-88BF-C0E3E606D758} = {F881ADA2-2F1A-4046-9FEB-191D9422D781} @@ -2840,16 +2634,6 @@ Global {432DB165-1EB2-4781-A9C0-71E62610B20A} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78} {CF70F278-3364-4395-A2E1-23501C9B8AD2} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} {D5C87B19-150D-4EF3-A671-96589BD2D14A} = {F881ADA2-2F1A-4046-9FEB-191D9422D781} - {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2} = {62F27B1A-C919-4A70-8478-51F178F3B18F} - {B5A00BFA-6083-4FAE-A097-71642D6473B5} = {62F27B1A-C919-4A70-8478-51F178F3B18F} - {1C320193-46A6-4B34-9C56-8AB584FC1B56} = {62F27B1A-C919-4A70-8478-51F178F3B18F} - {72782932-37CC-46AE-8C7F-9A7B1A6EE108} = {62F27B1A-C919-4A70-8478-51F178F3B18F} - {12A49562-BAB9-43A3-A21D-15B60BBB4C31} = {62F27B1A-C919-4A70-8478-51F178F3B18F} - {A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA} = {62F27B1A-C919-4A70-8478-51F178F3B18F} - {504B3154-7A4F-459D-9877-B951021C3F1F} = {62F27B1A-C919-4A70-8478-51F178F3B18F} - {746F3632-5BB2-4570-9453-31D6D58A7D8E} = {62F27B1A-C919-4A70-8478-51F178F3B18F} - {DEB01ACB-D65F-4A62-AED9-58C1054499E9} = {62F27B1A-C919-4A70-8478-51F178F3B18F} - {D07C378A-F5F7-438F-ADF3-4AC4FB1883CD} = {4CF6A6AC-07DE-4B9E-ABE1-7F98B64E0BB0} {ABB71A76-42B0-47A4-973A-42E3D920C6FD} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} {EF300386-A8DF-4372-B6D8-FB9BFFCA9AED} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78} {AFA983D6-4569-4F88-BA94-555ED00FD9A8} = {F881ADA2-2F1A-4046-9FEB-191D9422D781} @@ -2873,7 +2657,6 @@ Global {9DE35039-A8F6-4FBF-B1B6-EB527F802411} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} {26C82FCE-E0CF-4D10-A00C-D8E582FFEB53} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} {74B120FF-6935-4DFE-A142-CDB6BEA99C90} = {9460B5F1-0A95-41C4-BEB7-9C2C96459A7C} - {C13CC324-0032-4492-9A30-310A6BD64FF5} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} {886B5E9D-F2C2-4AF2-98C8-EF98C4C770E6} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78} {019DBD2A-273D-4BA4-BF86-B5EFE2ED76B1} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B} {D2396DD7-7D38-473A-ABB7-6F96D65AE1B9} = {9DE35039-A8F6-4FBF-B1B6-EB527F802411} diff --git a/LICENSE b/LICENSE index 6745df1f35..e36ad2a73c 100644 --- a/LICENSE +++ b/LICENSE @@ -3,8 +3,8 @@ Upstream-Name: freeswitch Source: https://freeswitch.org/ Files: * -Copyright: 2005-2014 Anthony Minessale II - 2005-2014 Anthony Minessale II +Copyright: 2005-2022 Anthony Minessale II + 2005-2022 Anthony Minessale II License: MPL-1.1 MOZILLA PUBLIC LICENSE Version 1.1 @@ -1011,12 +1011,6 @@ License: MPL-1.1 or GPL-2+ use the text of this Exhibit A rather than the text found in the Original Code Source Code for Your Modifications.] -Files: libs/unimrcp/* -Copyright: 2008-2010 Arsen Chaloyan - 2009-2010 Tomas Valenta, Arsen Chaloyan - 2001-2006 Steve Underwood -License: Apache-2.0 - Files: */inet_pton.c libs/curl/lib/inet_ntop.c libs/curl/lib/mprintf.c @@ -1595,15 +1589,6 @@ Files: libs/silk/* Copyright: 2006-2011, Skype Limited. License: BSD-2-clause -Files: libs/libdingaling/* -Copyright: 2005-2014, Anthony Minessale II - 2001-2003 Allan Saddi -License: MPL-1.1 - -Files: libs/libdingaling/src/sha1.[ch] -Copyright: 2001-2003 Allan Saddi -License: BSD-2-clause - Files: libs/libcodec2/* Copyright: 1990-2010 David Rowe 1990-2010 David Rowe 2009 @@ -1724,27 +1709,6 @@ License: LGPL-2.1 Files: libs/broadvoice/autogen.sh License: GPL-2 -Files: libs/libzrtp/* -Copyright: 2006-2012 Philip R. Zimmermann. - 1993-2005 Colin Plumb - 1998-2006, Dr Brian Gladman, Worcester, UK. - 2002, Bryce "Zooko" Wilcox-O'Hearn - 2010 Soft Industry -License: AGPL-3 or MPL-1.1 - -Files: libs/libzrtp/test/cmockery/cmockery.c -Copyright: 2008 Google Inc -License: Apache-2.0 - -Files: libs/libzrtp/third_party/bnlib/legal.c - libs/libzrtp/third_party/bnlib/* -Copyright: 1993-2005 Colin Plumb -License: GPL-2 or GPL-3 or MPL-1.1 - -Files: libs/libzrtp/third_party/bnlib/test/md5.c -Copyright: 1995 Abandoned Colin Plumb -License: public-domain - Files: libs/win32/sqlite/sqlite3.[ch] libs/win32/sqlite/parse.c Copyright: 2006 Abandoned D. Richard Hipp diff --git a/Makefile.am b/Makefile.am index fa0bb9abd7..fdd339a68b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -15,16 +15,6 @@ AM_LIBAPR_CPPFLAGS := $(shell ./libs/apr/apr-1-config --cppflags --includes) AM_LIBAPR_LDFLAGS := $(shell ./libs/apr/apr-1-config --ldflags) AM_LIBAPR_LIBS := $(subst $(switch_builddir)/,,$(shell ./libs/apr/apr-1-config \--libs)) endif -if SYSTEM_APRUTIL -AM_LIBAPU_CPPFLAGS := $(shell apu-1-config --includes) -AM_LIBAPU_LDFLAGS := $(shell apu-1-config --ldflags) -AM_LIBAPU_LIBS := $(shell apu-1-config \--libs) -AM_LIBAPU_LINKLIBTOOL := $(shell apu-1-config \--link-libtool) -else -AM_LIBAPU_CPPFLAGS := $(shell ./libs/apr-util/apu-1-config --includes) -AM_LIBAPU_LDFLAGS := $(shell ./libs/apr-util/apu-1-config --ldflags) -AM_LIBAPU_LIBS := $(subst $(switch_builddir)/,,$(shell ./libs/apr-util/apu-1-config \--libs)) -endif AM_CFLAGS = $(SWITCH_AM_CFLAGS) $(SWITCH_ANSI_CFLAGS) @@ -141,11 +131,6 @@ CORE_LIBS= if ENABLE_LIBVPX CORE_LIBS += libs/libvpx/libvpx.a endif -if SYSTEM_APRUTIL -CORE_LIBS += $(AM_LIBAPU_LINKLIBTOOL) -else -CORE_LIBS += libs/apr-util/libaprutil-1.la -endif if SYSTEM_APR CORE_LIBS += $(AM_LIBAPR_LINKLIBTOOL) else @@ -248,7 +233,7 @@ endif lib_LTLIBRARIES = libfreeswitch.la libfreeswitch_la_CFLAGS = $(CORE_CFLAGS) $(SQLITE_CFLAGS) $(GUMBO_CFLAGS) $(FVAD_CFLAGS) $(FREETYPE_CFLAGS) $(CURL_CFLAGS) $(PCRE_CFLAGS) $(SPEEX_CFLAGS) $(LIBEDIT_CFLAGS) $(openssl_CFLAGS) $(SOFIA_SIP_CFLAGS) $(AM_CFLAGS) $(TPL_CFLAGS) libfreeswitch_la_LDFLAGS = -version-info 1:0:0 $(AM_LDFLAGS) $(PLATFORM_CORE_LDFLAGS) -no-undefined -libfreeswitch_la_LIBADD = $(CORE_LIBS) $(APR_LIBS) $(SQLITE_LIBS) $(GUMBO_LIBS) $(FVAD_LIBS) $(FREETYPE_LIBS) $(CURL_LIBS) $(PCRE_LIBS) $(SPEEX_LIBS) $(LIBEDIT_LIBS) $(openssl_LIBS) $(PLATFORM_CORE_LIBS) $(TPL_LIBS) $(SPANDSP_LIBS) $(SOFIA_SIP_LIBS) +libfreeswitch_la_LIBADD = $(CORE_LIBS) $(APR_LIBS) $(SQLITE_LIBS) $(GUMBO_LIBS) $(FVAD_LIBS) $(FREETYPE_LIBS) $(CURL_LIBS) $(PCRE_LIBS) $(SPEEX_LIBS) $(LIBEDIT_LIBS) $(SYSTEMD_LIBS) $(openssl_LIBS) $(PLATFORM_CORE_LIBS) $(TPL_LIBS) $(SPANDSP_LIBS) $(SOFIA_SIP_LIBS) libfreeswitch_la_DEPENDENCIES = $(BUILT_SOURCES) if HAVE_PNG @@ -259,19 +244,6 @@ if HAVE_ODBC libfreeswitch_la_LDFLAGS += $(ODBC_LIB_FLAGS) endif -if ENABLE_ZRTP -CORE_CFLAGS += -I$(switch_srcdir)/libs/libzrtp/third_party/bgaes -CORE_CFLAGS += -I$(switch_srcdir)/libs/libzrtp/third_party/bnlib -CORE_CFLAGS += -isystem $(switch_srcdir)/libs/libzrtp/include -ZRTP_LDFLAGS = -L$(switch_srcdir)/libs/libzrtp/third_party/bnlib -ZRTP_LDFLAGS += -L$(switch_srcdir)/libs/libzrtp -ZRTP_LIBS = -lbn -lzrtp -libfreeswitch_la_LDFLAGS += $(ZRTP_LDFLAGS) -libfreeswitch_la_LIBADD += $(ZRTP_LIBS) -CORE_LIBS += libs/libzrtp/libzrtp.a -LIBS += libs/libzrtp/third_party/bnlib/libbn.a -endif - library_includetestdir = $(includedir)/test library_includetest_HEADERS = \ src/include/test/switch_fct.h \ @@ -300,6 +272,7 @@ library_include_HEADERS = \ src/include/switch_dso.h \ src/include/switch_loadable_module.h \ src/include/switch_module_interfaces.h \ + src/include/switch_packetizer.h \ src/include/switch_platform.h \ src/include/switch_resample.h \ src/include/switch_regex.h \ @@ -309,6 +282,7 @@ library_include_HEADERS = \ src/include/switch_jitterbuffer.h \ src/include/switch_estimators.h \ src/include/switch_rtcp_frame.h \ + src/include/switch_spandsp.h \ src/include/switch_stun.h \ src/include/switch_nat.h \ src/include/switch_log.h \ @@ -338,6 +312,7 @@ nodist_libfreeswitch_la_SOURCES = \ libfreeswitch_la_SOURCES = \ src/switch_apr.c \ + src/switch_apr_queue.c \ src/switch_buffer.c \ src/switch_caller.c \ src/switch_channel.c \ @@ -364,6 +339,7 @@ libfreeswitch_la_SOURCES = \ src/switch_version.c \ src/switch_core_media.c \ src/switch_core_video.c \ + src/switch_packetizer.c \ src/switch_sdp.c \ src/switch_scheduler.c \ src/switch_core_db.c \ @@ -383,6 +359,7 @@ libfreeswitch_la_SOURCES = \ src/switch_ivr_say.c \ src/switch_ivr_menu.c \ src/switch_ivr.c \ + src/switch_spandsp.c \ src/switch_stun.c \ src/switch_nat.c \ src/switch_log.c \ @@ -580,9 +557,6 @@ src/include/switch_version.h: src/include/switch_version.h.in Makefile $(switch_ libs/libedit/src/.libs/libedit.a: cd libs/libedit && $(MAKE) -libs/libzrtp/libzrtp.a: - cd libs/libzrtp && $(MAKE) - libs/libvpx/Makefile: libs/libvpx/.update cd libs/libvpx && CC="$(CC)" CXX="$(CXX)" CFLAGS="$(CFLAGS) $(VISIBILITY_FLAG)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" ./configure --enable-pic --disable-docs --disable-examples --disable-install-bins --disable-install-srcs --disable-unit-tests --size-limit=16384x16384 @@ -596,17 +570,15 @@ libs/apr/Makefile: libs/apr/Makefile.in libs/apr/config.status libs/apr libs/apr libs/apr/libapr-1.la: libs/apr/Makefile libs/apr/.update @if [ $(MAKELEVEL) = 0 -o -z "`echo "$(MAKEARGS)" | grep "j"`" ] ; then touch $(switch_srcdir)/src/include/switch.h; cd libs/apr && $(MAKE) $(MFLAGS) && touch libapr-1.la; fi -libs/apr-util/libaprutil-1.la: libs/apr/libapr-1.la libs/apr-util libs/apr-util/.update - @if [ $(MAKELEVEL) = 0 -o -z "`echo "$(MAKEARGS)" | grep "j"`" ] ; then touch $(switch_srcdir)/src/include/switch.h; cd libs/apr-util && $(MAKE) $(MFLAGS) && touch libaprutil-1.la; fi - -SRTP_SRC = libs/srtp/srtp/srtp.c libs/srtp/srtp/ekt.c libs/srtp/crypto/cipher/cipher.c libs/srtp/crypto/cipher/null_cipher.c \ +SRTP_SRC = libs/srtp/srtp/srtp.c libs/srtp/crypto/cipher/cipher.c libs/srtp/crypto/cipher/null_cipher.c \ libs/srtp/crypto/cipher/aes.c libs/srtp/crypto/cipher/aes_icm.c \ libs/srtp/crypto/hash/null_auth.c libs/srtp/crypto/hash/sha1.c \ libs/srtp/crypto/hash/hmac.c libs/srtp/crypto/hash/auth.c \ - libs/srtp/crypto/math/datatypes.c libs/srtp/crypto/math/stat.c \ + libs/srtp/crypto/math/datatypes.c \ libs/srtp/crypto/kernel/crypto_kernel.c libs/srtp/crypto/kernel/alloc.c \ libs/srtp/crypto/kernel/key.c libs/srtp/crypto/kernel/err.c \ - libs/srtp/crypto/replay/rdb.c libs/srtp/crypto/replay/rdbx.c libs/srtp/crypto/replay/ut_sim.c + libs/srtp/crypto/replay/rdb.c libs/srtp/crypto/replay/rdbx.c \ + libs/srtp/crypto/cipher/cipher_test_cases.c libs/srtp/crypto/hash/auth_test_cases.c libs/srtp/libsrtp.la: libs/srtp libs/srtp/.update $(SRTP_SRC) touch $(switch_srcdir)/src/include/switch.h @@ -697,7 +669,7 @@ yesdepends: rm .nodepends iksemel-dep: - make -C src/mod/endpoints/mod_dingaling deps + make -C src/mod/formats/mod_ssml deps core: $(switch_builddir)/modules.conf src/include/switch_version.h $(CORE_LIBS) $(MAKE) $(AM_MAKEFLAGS) libfreeswitch.la @@ -741,11 +713,11 @@ pristine: git clean -fdx git reset --hard -update-clean: clean python-reconf +update-clean: clean python-reconf python3-reconf cd libs/esl && $(MAKE) clean cd libs/srtp && $(MAKE) clean -swigall: +swigall: src/include/switch_swigable_cpp.h @echo reswigging all sh $(switch_srcdir)/build/swigall.sh @@ -758,6 +730,10 @@ python-reconf: rm -f src/mod/languages/mod_python/Makefile ./config.status +python3-reconf: + rm -f src/mod/languages/mod_python3/Makefile + ./config.status + reconf: rm config.cache sh ./config.status --recheck @@ -773,7 +749,7 @@ iks-reconf: cd libs/iksemel && $(MAKE) clean cd libs/iksemel && autoreconf -fi cd libs/iksemel && sh ./configure.gnu $(MY_DEFAULT_ARGS) - $(MAKE) mod_dingaling-clean + $(MAKE) mod_ssml-clean cluecon: @clear diff --git a/README.md b/README.md index 77de167e3e..15cda2e22f 100644 --- a/README.md +++ b/README.md @@ -1,63 +1,74 @@ -# FreeSWITCH - -FreeSWITCH is a Software Defined Telecom Stack enabling the digital transformation from proprietary telecom switches to a versatile software implementation that runs on any commodity hardware. From a Raspberry PI to a multi-core server, FreeSWITCH can unlock the telecommunications potential of any device. Combined with our hosted cloud platform, SignalWire, FreeSWITCH can interconnect with the outside world and scale to any size. - -Visit [https://signalwire.com](https://signalwire.com/) or https://github.com/signalwire for more info. - -## Getting Started - -FreeSWITCH is available on [Github](https://github.com/signalwire/freeswitch) in source code format. You can checkout the development branch and build for many poplular platforms including Linux, Windows, MacOSX and BSD. There is an issue tracker and pull request system available as part of the repo online. - -See [https://freeswitch.com/#getting-started](https://freeswitch.com/#getting-started) for more detailed instructions. - -## Additional Help - -If you need assistance or have an interest in using a commercially supported build, you can contact coreteam@freeswitch.com to learn about professional services to support your project. - -## Voice-over-IP services - SIP / SMS - App Integrations - -[SignalWire](https://signalwire.com) is the primary sponsor of the FreeSWITCH project and was founded by the original developers of FreeSWITCH. SignalWire provides scalable services to enhance and scale your project such as SMS, SIP, Serverless Application hosting as well as programmable telecom. mod_signalwire which is distributed in this code base allows you to instantly pair with SignalWire and extend your FreeSWITCH. - -## Documentation - -The main index for documentation is available at: - - * https://freeswitch.org/confluence/ - -### Release notes: - - * https://freeswitch.org/confluence/display/FREESWITCH/Release+Notes - -### Installation - -Step by step tutorials to install FreeSWITCH from packages or source code are available at: - - * [Debian 10 Buster](https://freeswitch.org/confluence/display/FREESWITCH/Debian+10+Buster) [Recommended] - * [Raspberry Pi](https://freeswitch.org/confluence/display/FREESWITCH/Raspberry+Pi) - * [CentOS 7](https://freeswitch.org/confluence/display/FREESWITCH/CentOS+7+and+RHEL+7) - -## Downloads - - * [Tarballs](https://files.freeswitch.org/releases/freeswitch/) - * [Windows Installer](http://files.freeswitch.org/windows/installer/x64/) - * [Windows Sound Packages](http://files.freeswitch.org/windows/installer/x64/sounds/) - -## Contributions - -GitHub pull requests are the recommended way to contribute to the FreeSWITCH source code: - - * https://github.com/signalwire/freeswitch/pulls - -## Community - -Slack is our chat system where the developers, the FreeSWITCH team, and the most active users are present. -This is the place to get answers faster and chat with other users in real time. All you need to do is enter your email and verify it on the Slack signup page and you are ready to join in the discussion! - -Slack Community: - * https://signalwire.community/ - -Mailing list: - - * http://lists.freeswitch.org/mailman/listinfo/freeswitch-users - -**Thank you for using FreeSWITCH!** \ No newline at end of file +# FreeSWITCH + +FreeSWITCH is a Software Defined Telecom Stack enabling the digital transformation from proprietary telecom switches to a versatile software implementation that runs on any commodity hardware. From a Raspberry PI to a multi-core server, FreeSWITCH can unlock the telecommunications potential of any device. Combined with our hosted cloud platform, SignalWire, FreeSWITCH can interconnect with the outside world and scale to any size. + +Visit [https://signalwire.com](https://signalwire.com/) or https://github.com/signalwire for more info. + +## Getting Started + +FreeSWITCH is available on [Github](https://github.com/signalwire/freeswitch) in source code format. You can checkout the development branch and build for many popular platforms including Linux, Windows, MacOSX and BSD. There is an issue tracker and pull request system available as part of the repo online. + +See https://developer.signalwire.com/freeswitch/FreeSWITCH-Explained/ for more detailed instructions. + +## Additional Help + +If you need assistance or have an interest in using a commercially supported build, you can contact coreteam@freeswitch.com to learn about professional services to support your project. + +## Voice-over-IP services - SIP / SMS - App Integrations + +[SignalWire](https://signalwire.com) is the primary sponsor of the FreeSWITCH project and was founded by the original developers of FreeSWITCH. SignalWire provides scalable services to enhance and scale your project such as SMS, SIP, Serverless Application hosting as well as programmable telecom. mod_signalwire which is distributed in this code base allows you to instantly pair with SignalWire and extend your FreeSWITCH. + +## Documentation + +The main index for documentation is available at: + + * https://freeswitch.org/confluence/ + + +### Release notes: + + * https://freeswitch.org/confluence/display/FREESWITCH/Release+Notes + +### Install from packages + +Step by step tutorials to install FreeSWITCH from packages: + + * [Debian](https://freeswitch.org/confluence/display/FREESWITCH/Debian) [Recommended] + * [Raspberry Pi](https://freeswitch.org/confluence/display/FREESWITCH/Raspberry+Pi) + * [CentOS 7](https://freeswitch.org/confluence/display/FREESWITCH/CentOS+7+and+RHEL+7) + +### Build from source + +Example Dockerfiles to build FreeSWITCH and dependencies from source: + * https://github.com/signalwire/freeswitch/tree/master/docker/examples + +Step by step tutorials to build FreeSWITCH with provided dependency packages: + * [Debian](https://freeswitch.org/confluence/display/FREESWITCH/Debian#Debian-buildfromsource) [Recommended] + * [Raspberry Pi](https://freeswitch.org/confluence/display/FREESWITCH/Raspberry+Pi) + * [CentOS 7](https://freeswitch.org/confluence/display/FREESWITCH/CentOS+7+and+RHEL+7) + +## Downloads + + * [Tarballs](https://files.freeswitch.org/releases/freeswitch/) + * [Windows Installer](http://files.freeswitch.org/windows/installer/x64/) + * [Windows Sound Packages](http://files.freeswitch.org/windows/installer/x64/sounds/) + +## Contributions + +GitHub pull requests are the recommended way to contribute to the FreeSWITCH source code: + + * https://github.com/signalwire/freeswitch/pulls + +## Community + +Slack is our chat system where the developers, the FreeSWITCH team, and the most active users are present. +This is the place to get answers faster and chat with other users in real time. All you need to do is enter your email and verify it on the Slack signup page and you are ready to join in the discussion! + +Slack Community: + * https://signalwire.community/ + +Mailing list: + + * http://lists.freeswitch.org/mailman/listinfo/freeswitch-users + +**Thank you for using FreeSWITCH!** diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000000..9efb6b711a --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,5 @@ +# Security Policy + +## Reporting a Vulnerability + +Send an e-mail to security@signalwire.com to report a vulnerability. If accepted, we'll create a security advisory and add you and your team as collaborators. Please allow our team sufficient time to resolve the vulnerability before disclosing it; we'll remain in contact about the fix and may ask for your assistance to verify it is resolved. diff --git a/bootstrap.sh b/bootstrap.sh index fa7e10ad88..afa73687f5 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -10,7 +10,7 @@ BGJOB=false VERBOSE=false BASEDIR=`pwd`; LIBDIR=${BASEDIR}/libs; -SUBDIRS="apr libzrtp iksemel libdingaling srtp freetdm unimrcp fs"; +SUBDIRS="apr iksemel srtp fs"; while getopts 'jhd:v' o; do case "$o" in @@ -170,13 +170,6 @@ bootstrap_apr() { # Remove autoconf 2.5x's cache directory rm -rf autom4te*.cache - echo "Entering directory ${LIBDIR}/apr-util" - cd ${LIBDIR}/apr-util - ./buildconf -} - -bootstrap_libzrtp() { - (cd ${LIBDIR}/libzrtp && ./bootstrap.sh) } # Libs automake automation function @@ -263,7 +256,7 @@ bootstrap_libs_post() { bootstrap_libs() { for i in ${SUBDIRS}; do case "$i" in - apr|fs|libzrtp) + apr|fs) ${BGJOB} && wait bootstrap_$i continue diff --git a/build/buildmrcpserver.sh b/build/buildmrcpserver.sh deleted file mode 100755 index a6468b06d2..0000000000 --- a/build/buildmrcpserver.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -base=`pwd` -cd libs/unimrcp -./configure --with-pocketsphinx=$base/libs/pocketsphinx-0.5.99 --with-sphinxbase=$base/libs/sphinxbase-0.4.99 --with-flite=$base/libs/flite-1.3.99 --with-apr=$base/libs/apr --with-apr-util=$base/libs/apr-util --with-sofia-sip=$base/libs/sofia-sip --prefix=/usr/local/unimrcpserver --enable-pocketsphinx-plugin --enable-flite-plugin --disable-demosynth-plugin --disable-demorecog-plugin --disable-recorder-plugin --disable-cepstral-plugin -make -make install diff --git a/build/buildzrtp.sh b/build/buildzrtp.sh deleted file mode 100755 index 9df8fff6f6..0000000000 --- a/build/buildzrtp.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -tar zxf libzrtp-0.81.514.tar.gz -cd libzrtp-0.81.514 -patch -p1 < ../patches/zrtp_bnlib_pic.diff -cd projects/gnu/ -./configure CFLAGS="-fPIC" -make -make install diff --git a/build/freeswitch.service b/build/freeswitch.service index ae6921b4df..2b0a035723 100644 --- a/build/freeswitch.service +++ b/build/freeswitch.service @@ -4,6 +4,10 @@ After=syslog.target network.target After=postgresql.service postgresql-9.3.service postgresql-9.4.service mysqld.service httpd.service [Service] +# You can use Type=notify only if you compile FreeSWITCH with --enable-systemd configure option +# In this case you have to run FreeSWITCH in foreground mode (-nf option)! +#Type=notify +#NotifyAccess=main User=freeswitch EnvironmentFile=-/etc/sysconfig/freeswitch # RuntimeDirectory is not yet supported in CentOS 7. A workaround is to use /etc/tmpfiles.d/freeswitch.conf diff --git a/build/modcheck.sh b/build/modcheck.sh index 5df91f7e97..e8a82abf29 100644 --- a/build/modcheck.sh +++ b/build/modcheck.sh @@ -21,8 +21,8 @@ cd $here for i in $files ; do mod=${i%%.*} - infile=`grep ^.*$mod\$ ../modules.conf | grep -v ftmod_` - commented=`grep ^\#.*$mod\$ ../modules.conf | grep -v ftmod_` + infile=`grep -E "^.*$mod(\|.*)?$" ../modules.conf | grep -v ftmod_` + commented=`grep -E "^\#.*$mod(\|.*)?$" ../modules.conf | grep -v ftmod_` if [ -z "$infile" ] ; then echo "${on}WARNING: installed module: $i was not installed by this build. It is not present in modules.conf.${off}" diff --git a/build/modmake.rules.in b/build/modmake.rules.in index dbce9bd48e..7f880b86f9 100644 --- a/build/modmake.rules.in +++ b/build/modmake.rules.in @@ -188,7 +188,7 @@ $(MODNAME).o: $(MODDIR)/$(SOURCEFILE) \ $(switch_srcdir)/src/include/switch_event.h $(switch_srcdir)/src/include/switch_resample.h \ $(switch_srcdir)/src/include/switch_ivr.h $(switch_srcdir)/src/include/switch_rtp.h \ $(switch_srcdir)/src/include/switch_stun.h $(switch_srcdir)/src/include/switch_log.h \ - $(switch_srcdir)/src/include/switch_xml.h + $(switch_srcdir)/src/include/switch_xml.h $(switch_srcdir)/src/include/switch_spandsp.h @echo Compiling $<... if test -f "$(CSOURCEFILE)" -o -f "$(MODDIR)/$(CSOURCEFILE)"; then \ if test ! -z $(VERBOSE) ; then echo $(COMPILE) -c -o $@ `test -f '$<' || echo '$(MODDIR)/'`$< ; fi ;\ @@ -211,7 +211,7 @@ $(MODNAME).lo: $(MODDIR)/$(SOURCEFILE) \ $(switch_srcdir)/src/include/switch_event.h $(switch_srcdir)/src/include/switch_resample.h \ $(switch_srcdir)/src/include/switch_ivr.h $(switch_srcdir)/src/include/switch_rtp.h \ $(switch_srcdir)/src/include/switch_stun.h $(switch_srcdir)/src/include/switch_log.h \ - $(switch_srcdir)/src/include/switch_xml.h + $(switch_srcdir)/src/include/switch_xml.h $(switch_srcdir)/src/include/switch_spandsp.h @echo Compiling $<... if test -f "$(CSOURCEFILE)" -o -f "$(MODDIR)/$(CSOURCEFILE)"; then \ if test ! -z $(VERBOSE) ; then echo $(LTCOMPILE) -c -o $@ `test -f '$<' || echo '$(MODDIR)/'`$< ; fi ;\ @@ -261,6 +261,8 @@ $(switch_srcdir)/src/include/switch_ivr.h: $(switch_srcdir)/src/include/switch_rtp.h: +$(switch_srcdir)/src/include/switch_spandsp.h: + $(switch_srcdir)/src/include/switch_stun.h: $(switch_srcdir)/src/include/switch_log.h: diff --git a/build/modules.conf.in b/build/modules.conf.in index 14ad5dd080..7bf59e2acc 100644 --- a/build/modules.conf.in +++ b/build/modules.conf.in @@ -49,6 +49,7 @@ applications/mod_sms applications/mod_spandsp #applications/mod_spy #applications/mod_stress +applications/mod_test #applications/mod_translate applications/mod_valet_parking #applications/mod_video_filter @@ -59,7 +60,6 @@ applications/mod_voicemail #asr_tts/mod_flite #asr_tts/mod_pocketsphinx #asr_tts/mod_tts_commandline -#asr_tts/mod_unimrcp codecs/mod_amr #codecs/mod_amrwb codecs/mod_b64 @@ -86,7 +86,6 @@ dialplans/mod_dialplan_asterisk dialplans/mod_dialplan_xml #directories/mod_ldap #endpoints/mod_alsa -#endpoints/mod_dingaling #endpoints/mod_gsmopen #endpoints/mod_h323 #endpoints/mod_khomp @@ -134,6 +133,7 @@ languages/mod_lua #languages/mod_managed #languages/mod_perl #languages/mod_python +#languages/mod_python3 #languages/mod_v8 #languages/mod_yaml loggers/mod_console @@ -168,7 +168,7 @@ xml_int/mod_xml_cdr xml_int/mod_xml_rpc xml_int/mod_xml_scgi -#../../libs/freetdm/mod_freetdm +#mod_freetdm|https://github.com/freeswitch/freetdm.git -b master ## Experimental Modules (don't cry if they're broken) #../../contrib/mod/xml_int/mod_xml_odbc diff --git a/build/modules.conf.most b/build/modules.conf.most index 6f976dca38..fbf8100a90 100644 --- a/build/modules.conf.most +++ b/build/modules.conf.most @@ -47,6 +47,7 @@ applications/mod_soundtouch applications/mod_spandsp applications/mod_spy applications/mod_stress +applications/mod_test applications/mod_translate applications/mod_valet_parking applications/mod_video_filter @@ -57,7 +58,6 @@ applications/mod_voicemail_ivr asr_tts/mod_flite asr_tts/mod_pocketsphinx asr_tts/mod_tts_commandline -asr_tts/mod_unimrcp codecs/mod_amr codecs/mod_amrwb codecs/mod_b64 @@ -83,7 +83,6 @@ dialplans/mod_dialplan_directory dialplans/mod_dialplan_xml directories/mod_ldap #endpoints/mod_alsa -endpoints/mod_dingaling #endpoints/mod_gsmopen #endpoints/mod_h323 #endpoints/mod_khomp @@ -127,7 +126,7 @@ languages/mod_java languages/mod_lua languages/mod_managed languages/mod_perl -languages/mod_python +languages/mod_python3 #languages/mod_v8 languages/mod_yaml loggers/mod_console diff --git a/build/next-release.txt b/build/next-release.txt index defa9f0e12..b61c58c7d4 100644 --- a/build/next-release.txt +++ b/build/next-release.txt @@ -1 +1 @@ -1.10.6-dev +1.10.10-dev diff --git a/build/sounds_version.txt b/build/sounds_version.txt index b0b46ff4e2..12d0f30d10 100644 --- a/build/sounds_version.txt +++ b/build/sounds_version.txt @@ -1,5 +1,5 @@ -en-us-callie 1.0.52 -en-us-allison 1.0.1 +en-us-callie 1.0.53 +en-us-allison 1.0.2 ru-RU-elena 1.0.51 ru-RU-kirill 1.0.0 ru-RU-vika 1.0.0 diff --git a/build/swigall.sh b/build/swigall.sh index ee7abf19cd..44b05b633b 100755 --- a/build/swigall.sh +++ b/build/swigall.sh @@ -13,6 +13,11 @@ make swigclean make mod_python_wrap.cpp cd ../../../.. +cd src/mod/languages/mod_python3 +make swigclean +make mod_python_wrap.cpp +cd ../../../.. + cd src/mod/languages/mod_java make reswig cd ../../../.. diff --git a/clients/flex/com/adobe/air/filesystem/FileUtil.as b/clients/flex/com/adobe/air/filesystem/FileUtil.as index 33bf04df79..9a6bbc3dde 100644 --- a/clients/flex/com/adobe/air/filesystem/FileUtil.as +++ b/clients/flex/com/adobe/air/filesystem/FileUtil.as @@ -53,7 +53,7 @@ package com.adobe.air.filesystem } else if(os.indexOf("Linux") > -1) { - //todo: need to impliment Linux + //todo: need to implement Linux } return v; diff --git a/clients/flex/com/adobe/air/filesystem/VolumeMonitor.as b/clients/flex/com/adobe/air/filesystem/VolumeMonitor.as index cbb5ad5ba2..67901a264b 100644 --- a/clients/flex/com/adobe/air/filesystem/VolumeMonitor.as +++ b/clients/flex/com/adobe/air/filesystem/VolumeMonitor.as @@ -110,7 +110,7 @@ package com.adobe.air.filesystem timer.addEventListener(TimerEvent.TIMER, onTimerEvent,false,0, true); } - //we reinitialize the hash everytime we start watching + //we reinitialize the hash every time we start watching volumes = new Dictionary(); var v:Array = FileUtil.getRootDirectories(); diff --git a/clients/flex/com/adobe/net/DynamicURLLoader.as b/clients/flex/com/adobe/net/DynamicURLLoader.as index 2a9eea1c36..a365b2479d 100644 --- a/clients/flex/com/adobe/net/DynamicURLLoader.as +++ b/clients/flex/com/adobe/net/DynamicURLLoader.as @@ -35,9 +35,9 @@ package com.adobe.net import flash.net.URLLoader; /** - * Class that provides a dynamic implimentation of the URLLoader class. + * Class that provides a dynamic implementation of the URLLoader class. * - * This class provides no API implimentations. However, since the class is + * This class provides no API implementations. However, since the class is * declared as dynamic, it can be used in place of URLLoader, and allow * you to dynamically attach properties to it (which URLLoader does not allow). * diff --git a/clients/flex/com/adobe/net/MimeTypeMap.as b/clients/flex/com/adobe/net/MimeTypeMap.as index 63353cab8c..cd9224722f 100644 --- a/clients/flex/com/adobe/net/MimeTypeMap.as +++ b/clients/flex/com/adobe/net/MimeTypeMap.as @@ -169,7 +169,7 @@ package com.adobe.net } /** - * Returns the prefered extension for the given mimetype. + * Returns the preferred extension for the given mimetype. */ public function getExtension(mimetype:String):String { diff --git a/clients/flex/com/adobe/net/URI.as b/clients/flex/com/adobe/net/URI.as index a212cdd7b8..b77896b250 100644 --- a/clients/flex/com/adobe/net/URI.as +++ b/clients/flex/com/adobe/net/URI.as @@ -64,7 +64,7 @@ package com.adobe.net * URI syntax (e.g. custom query syntax or special handling of * non-hierarchical URI's), this class can be fully subclassed. If you * intended to subclass URI, please see the source code for complete - * documation on protected members and protected fuctions.

+ * documentation on protected members and protected functions.

* * @langversion ActionScript 3.0 * @playerversion Flash 9.0 @@ -203,7 +203,7 @@ package com.adobe.net /** - * @private Private initializiation. + * @private Private initialization. */ protected function initialize() : void { @@ -332,7 +332,7 @@ package com.adobe.net * well formed. Sometimes characters that should have been escaped * are not, and those situations would break a regexp pattern. This * function attempts to be smart about what it is parsing based on - * location of characters relative to eachother. This function has + * location of characters relative to each other. This function has * been proven through real-world use to parse the vast majority * of URI's correctly. * @@ -835,7 +835,7 @@ package com.adobe.net * to be properly escaped and unescaped, it must be split into its * component parts. This accessor escapes/unescapes the entire query * part without regard for it's component parts. This has the - * possibliity of leaving the query string in an ambiguious state in + * possibliity of leaving the query string in an ambiguous state in * regards to its syntax. If the contents of the query part are * important, it is recommended that get/setQueryValue() or * get/setQueryByMap() are used instead.

@@ -2340,7 +2340,7 @@ package com.adobe.net *

This function is intended to be a helper function. * It is not all-knowning and will probably make mistakes * when attempting to parse a string of unknown origin. If - * your applicaiton is receiving input from the user, your + * your application is receiving input from the user, your * application should already have a good idea what the user * should be entering, and your application should be * pre-processing the user's input to make sure it is well formed @@ -2354,7 +2354,7 @@ package com.adobe.net * on a URI that was created from unknownToURI() may not match * the input string due to the difference in escaping.

* - * @param unknown a potental URI string that should be parsed + * @param unknown a potential URI string that should be parsed * and loaded into this object. * @param defaultScheme if it is determined that the passed string * looks like a URI, but it is missing the scheme part, this diff --git a/clients/flex/com/adobe/serialization/json/JSONEncoder.as b/clients/flex/com/adobe/serialization/json/JSONEncoder.as index 639df02c2c..1b5311e970 100644 --- a/clients/flex/com/adobe/serialization/json/JSONEncoder.as +++ b/clients/flex/com/adobe/serialization/json/JSONEncoder.as @@ -104,7 +104,7 @@ package com.adobe.serialization.json } /** - * Escapes a string accoding to the JSON specification. + * Escapes a string according to the JSON specification. * * @param str The string to be escaped * @return The string with escaped special characters diff --git a/clients/flex/com/adobe/serialization/json/JSONParseError.as b/clients/flex/com/adobe/serialization/json/JSONParseError.as index 5aec1e3b02..1c25b71da4 100644 --- a/clients/flex/com/adobe/serialization/json/JSONParseError.as +++ b/clients/flex/com/adobe/serialization/json/JSONParseError.as @@ -47,7 +47,7 @@ package com.adobe.serialization.json { /** * Constructs a new JSONParseError. * - * @param message The error message that occured during parsing + * @param message The error message that occurred during parsing * @langversion ActionScript 3.0 * @playerversion Flash 9.0 * @tiptext diff --git a/clients/flex/com/adobe/utils/DateUtil.as b/clients/flex/com/adobe/utils/DateUtil.as index a741df0d76..13d4ee647c 100644 --- a/clients/flex/com/adobe/utils/DateUtil.as +++ b/clients/flex/com/adobe/utils/DateUtil.as @@ -74,7 +74,7 @@ package com.adobe.utils * @param Optional parameter indicating whether the search should be case * sensitive * - * @return A int that represents that month represented by the specifed + * @return A int that represents that month represented by the specified * short name. * * @langversion ActionScript 3.0 @@ -114,7 +114,7 @@ package com.adobe.utils * * @param m A full month name. * - * @return A int that represents that month represented by the specifed + * @return A int that represents that month represented by the specified * full month name. * * @langversion ActionScript 3.0 @@ -154,7 +154,7 @@ package com.adobe.utils * * @param m A short day name. * - * @return A int that represents that short day represented by the specifed + * @return A int that represents that short day represented by the specified * full month name. * * @langversion ActionScript 3.0 @@ -194,7 +194,7 @@ package com.adobe.utils * * @param m A full day name. * - * @return A int that represents that full day represented by the specifed + * @return A int that represents that full day represented by the specified * full month name. * * @langversion ActionScript 3.0 @@ -675,7 +675,7 @@ package com.adobe.utils } /** - * Converts a date into just befor midnight. + * Converts a date into just before midnight. */ public static function makeNight(d:Date):Date { diff --git a/clients/flex/com/adobe/utils/StringUtil.as b/clients/flex/com/adobe/utils/StringUtil.as index d7e98ed08b..af236d210e 100644 --- a/clients/flex/com/adobe/utils/StringUtil.as +++ b/clients/flex/com/adobe/utils/StringUtil.as @@ -79,7 +79,7 @@ package com.adobe.utils * @param input The String whose beginning and ending whitespace will * will be removed. * - * @returns A String with whitespace removed from the begining and end + * @returns A String with whitespace removed from the beginning and end * * @langversion ActionScript 3.0 * @playerversion Flash 9.0 @@ -95,7 +95,7 @@ package com.adobe.utils * * @param input The String whose beginning whitespace will will be removed. * - * @returns A String with whitespace removed from the begining + * @returns A String with whitespace removed from the beginning * * @langversion ActionScript 3.0 * @playerversion Flash 9.0 @@ -236,4 +236,4 @@ package com.adobe.utils return (s != null && s.length > 0); } } -} \ No newline at end of file +} diff --git a/clients/flex/jquery-1.4.2.js b/clients/flex/jquery-1.4.2.js index fff6776433..cc6e7dd4ea 100644 --- a/clients/flex/jquery-1.4.2.js +++ b/clients/flex/jquery-1.4.2.js @@ -519,7 +519,7 @@ jQuery.extend({ noop: function() {}, - // Evalulates a script in a global context + // Evaluates a script in a global context globalEval: function( data ) { if ( data && rnotwhite.test(data) ) { // Inspired by code by Andrea Giammarchi @@ -855,7 +855,7 @@ function now() { htmlSerialize: !!div.getElementsByTagName("link").length, // Get the style information from getAttribute - // (IE uses .cssText insted) + // (IE uses .cssText instead) style: /red/.test( a.getAttribute("style") ), // Make sure that URLs aren't manipulated @@ -1310,7 +1310,7 @@ jQuery.fn.extend({ classNames = value.split( rspace ); while ( (className = classNames[ i++ ]) ) { - // check each className given, space seperated list + // check each className given, space separated list state = isBool ? state : !self.hasClass( className ); self[ state ? "addClass" : "removeClass" ]( className ); } @@ -1364,7 +1364,7 @@ jQuery.fn.extend({ var option = options[ i ]; if ( option.selected ) { - // Get the specifc value for the option + // Get the specific value for the option value = jQuery(option).val(); // We don't need an array for one selects @@ -2636,7 +2636,7 @@ var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^ baseHasDuplicate = true; // Here we check if the JavaScript engine is using some sort of -// optimization where it does not always call our comparision +// optimization where it does not always call our comparison // function. If that is the case, discard the hasDuplicate value. // Thus far that includes Google Chrome. [0, 0].sort(function(){ @@ -3415,7 +3415,7 @@ if ( document.documentElement.compareDocumentPosition ) { }; } -// Utility function for retreiving the text value of an array of DOM nodes +// Utility function for retrieving the text value of an array of DOM nodes function getText( elems ) { var ret = "", elem; @@ -4149,7 +4149,7 @@ jQuery.fn.extend({ if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) { // IE copies events bound via attachEvent when // using cloneNode. Calling detachEvent on the - // clone will also remove the events from the orignal + // clone will also remove the events from the original // In order to get around this, we use innerHTML. // Unfortunately, this means some modifications to // attributes in IE that are actually only stored @@ -4886,7 +4886,7 @@ jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".sp jQuery.extend({ get: function( url, data, callback, type ) { - // shift arguments if data argument was omited + // shift arguments if data argument was omitted if ( jQuery.isFunction( data ) ) { type = type || callback; callback = data; @@ -4911,7 +4911,7 @@ jQuery.extend({ }, post: function( url, data, callback, type ) { - // shift arguments if data argument was omited + // shift arguments if data argument was omitted if ( jQuery.isFunction( data ) ) { type = type || callback; callback = data; @@ -4948,7 +4948,7 @@ jQuery.extend({ // Create the request object; Microsoft failed to properly // implement the XMLHttpRequest in IE7 (can't request local files), // so we use the ActiveXObject when it is available - // This function can be overriden by calling jQuery.ajaxSetup + // This function can be overridden by calling jQuery.ajaxSetup xhr: window.XMLHttpRequest && (window.location.protocol !== "file:" || !window.ActiveXObject) ? function() { return new window.XMLHttpRequest(); diff --git a/clients/flex/jquery.tmpl.js b/clients/flex/jquery.tmpl.js index 7e850f9d06..24188733b6 100644 --- a/clients/flex/jquery.tmpl.js +++ b/clients/flex/jquery.tmpl.js @@ -362,7 +362,7 @@ function updateWrapped( options, wrapped ) { // Build the wrapped content. options._wrap = build( options, true, - // Suport imperative scenario in which options.wrapped can be set to a selector or an HTML string. + // Support imperative scenario in which options.wrapped can be set to a selector or an HTML string. jQuery.isArray( wrapped ) ? wrapped : [htmlExpr.test( wrapped ) ? wrapped : jQuery( wrapped ).html()] ).join(""); } diff --git a/cmake_modules/FindAPRUtil.cmake b/cmake_modules/FindAPRUtil.cmake deleted file mode 100644 index 4de5d6050e..0000000000 --- a/cmake_modules/FindAPRUtil.cmake +++ /dev/null @@ -1,49 +0,0 @@ -# Locate APR-Util include paths and libraries - -# This module defines -# APRUTIL_INCLUDES, where to find apr.h, etc. -# APRUTIL_LIBS, the libraries to link against to use APR. -# APRUTIL_FOUND, set to yes if found - -find_program(APRUTIL_CONFIG_EXECUTABLE - apu-1-config - /usr/local/apr-util/1.2.12/bin - /usr/local/bin - /usr/bin - C:/Progra~1/apr/bin - ) - -mark_as_advanced(APRUTIL_CONFIG_EXECUTABLE) - -macro(_apu_invoke _varname _regexp) - execute_process( - COMMAND ${APRUTIL_CONFIG_EXECUTABLE} ${ARGN} - OUTPUT_VARIABLE _apr_output - RESULT_VARIABLE _apr_failed - ) - - if(_apr_failed) - message(FATAL_ERROR "apu-1-config ${ARGN} failed") - else(_apr_failed) - string(REGEX REPLACE "[\r\n]" "" _apr_output "${_apr_output}") - string(REGEX REPLACE " +$" "" _apr_output "${_apr_output}") - - if(NOT ${_regexp} STREQUAL "") - string(REGEX REPLACE "${_regexp}" " " _apr_output "${_apr_output}") - endif(NOT ${_regexp} STREQUAL "") - - separate_arguments(_apr_output) - - set(${_varname} "${_apr_output}") - endif(_apr_failed) -endmacro(_apu_invoke) - -_apu_invoke(APRUTIL_INCLUDES "(^| )-I" --includes) -_apu_invoke(APRUTIL_LIBS "" --link-ld) - -if(APRUTIL_LIBS AND APRUTIL_INCLUDES) - set(APRUTIL_FOUND "YES") - set(APRUTIL_DEFINITIONS "") - message (STATUS "apr-util found: YES ${APRUTIL_LIBS}") -endif(APRUTIL_LIBS AND APRUTIL_INCLUDES) - diff --git a/conf/FreeMono.ttf b/conf/FreeMono.ttf new file mode 100644 index 0000000000..c4200565a7 Binary files /dev/null and b/conf/FreeMono.ttf differ diff --git a/conf/curl/autoload_configs/conference.conf.xml b/conf/curl/autoload_configs/conference.conf.xml index dad34b2cce..75a12c78fd 100644 --- a/conf/curl/autoload_configs/conference.conf.xml +++ b/conf/curl/autoload_configs/conference.conf.xml @@ -53,7 +53,7 @@ - + diff --git a/conf/curl/autoload_configs/dingaling.conf.xml b/conf/curl/autoload_configs/dingaling.conf.xml deleted file mode 100644 index e68c8b4b44..0000000000 --- a/conf/curl/autoload_configs/dingaling.conf.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/conf/curl/autoload_configs/timezones.conf.xml b/conf/curl/autoload_configs/timezones.conf.xml index 397e9a979f..14f87f8c67 100644 --- a/conf/curl/autoload_configs/timezones.conf.xml +++ b/conf/curl/autoload_configs/timezones.conf.xml @@ -184,7 +184,7 @@ - + diff --git a/conf/curl/autoload_configs/xml_cdr.conf.xml b/conf/curl/autoload_configs/xml_cdr.conf.xml index 7f635d64aa..6aed35ac91 100644 --- a/conf/curl/autoload_configs/xml_cdr.conf.xml +++ b/conf/curl/autoload_configs/xml_cdr.conf.xml @@ -6,7 +6,7 @@ - + diff --git a/conf/insideout/autoload_configs/conference.conf.xml b/conf/insideout/autoload_configs/conference.conf.xml index dad34b2cce..75a12c78fd 100644 --- a/conf/insideout/autoload_configs/conference.conf.xml +++ b/conf/insideout/autoload_configs/conference.conf.xml @@ -53,7 +53,7 @@ - + diff --git a/conf/insideout/autoload_configs/modules.conf.xml b/conf/insideout/autoload_configs/modules.conf.xml index 5078503489..9408bcd29f 100644 --- a/conf/insideout/autoload_configs/modules.conf.xml +++ b/conf/insideout/autoload_configs/modules.conf.xml @@ -81,6 +81,7 @@ + diff --git a/conf/insideout/autoload_configs/timezones.conf.xml b/conf/insideout/autoload_configs/timezones.conf.xml index 397e9a979f..14f87f8c67 100644 --- a/conf/insideout/autoload_configs/timezones.conf.xml +++ b/conf/insideout/autoload_configs/timezones.conf.xml @@ -184,7 +184,7 @@ - + diff --git a/conf/insideout/autoload_configs/xml_cdr.conf.xml b/conf/insideout/autoload_configs/xml_cdr.conf.xml index 7f635d64aa..6aed35ac91 100644 --- a/conf/insideout/autoload_configs/xml_cdr.conf.xml +++ b/conf/insideout/autoload_configs/xml_cdr.conf.xml @@ -6,7 +6,7 @@ - + diff --git a/conf/insideout/dialplan/default.xml b/conf/insideout/dialplan/default.xml index 560b3023bb..6290dd53b0 100644 --- a/conf/insideout/dialplan/default.xml +++ b/conf/insideout/dialplan/default.xml @@ -2,7 +2,7 @@ NOTICE: This context is usually accessed via authenticated callers on the sip profile on port 5060 - or transfered callers from the public context which arrived via the sip profile on port 5080. + or transferred callers from the public context which arrived via the sip profile on port 5080. Authenticated users will use the user_context variable on the user to determine what context they can access. You can also add a user in the directory with the cidr= attribute acl.conf.xml @@ -330,7 +330,7 @@ - + diff --git a/conf/insideout/sip_profiles/external.xml b/conf/insideout/sip_profiles/external.xml index 22fd155434..be38318432 100644 --- a/conf/insideout/sip_profiles/external.xml +++ b/conf/insideout/sip_profiles/external.xml @@ -48,7 +48,6 @@ - diff --git a/conf/insideout/sip_profiles/internal-ipv6.xml b/conf/insideout/sip_profiles/internal-ipv6.xml index 0ae93cfc82..64dac272c3 100644 --- a/conf/insideout/sip_profiles/internal-ipv6.xml +++ b/conf/insideout/sip_profiles/internal-ipv6.xml @@ -70,9 +70,6 @@ - - - diff --git a/conf/insideout/sip_profiles/internal.xml b/conf/insideout/sip_profiles/internal.xml index b64b5cea86..63ea350449 100644 --- a/conf/insideout/sip_profiles/internal.xml +++ b/conf/insideout/sip_profiles/internal.xml @@ -106,9 +106,6 @@ - - - diff --git a/conf/minimal/autoload_configs/timezones.conf.xml b/conf/minimal/autoload_configs/timezones.conf.xml index 757d16c19d..0af4c77d7f 100644 --- a/conf/minimal/autoload_configs/timezones.conf.xml +++ b/conf/minimal/autoload_configs/timezones.conf.xml @@ -196,7 +196,7 @@ - + diff --git a/conf/rayo/autoload_configs/conference.conf.xml b/conf/rayo/autoload_configs/conference.conf.xml index 1ccd675d75..0641df764e 100644 --- a/conf/rayo/autoload_configs/conference.conf.xml +++ b/conf/rayo/autoload_configs/conference.conf.xml @@ -64,7 +64,7 @@ - + diff --git a/conf/rayo/autoload_configs/rayo.conf.xml b/conf/rayo/autoload_configs/rayo.conf.xml index e5191909cb..9f525c597c 100644 --- a/conf/rayo/autoload_configs/rayo.conf.xml +++ b/conf/rayo/autoload_configs/rayo.conf.xml @@ -277,36 +277,6 @@ ]]> - - - - yesno - ]]]]> - - - ]]> - - - - - yesno - ]]]]> - - - ]]> - diff --git a/conf/rayo/autoload_configs/switch.conf.xml b/conf/rayo/autoload_configs/switch.conf.xml index d23d832224..02aa434f9b 100644 --- a/conf/rayo/autoload_configs/switch.conf.xml +++ b/conf/rayo/autoload_configs/switch.conf.xml @@ -145,8 +145,6 @@ - - diff --git a/conf/rayo/vars.xml b/conf/rayo/vars.xml index a91c963465..af602cad34 100644 --- a/conf/rayo/vars.xml +++ b/conf/rayo/vars.xml @@ -14,13 +14,6 @@ - - - diff --git a/conf/sbc/autoload_configs/timezones.conf.xml b/conf/sbc/autoload_configs/timezones.conf.xml index 397e9a979f..14f87f8c67 100644 --- a/conf/sbc/autoload_configs/timezones.conf.xml +++ b/conf/sbc/autoload_configs/timezones.conf.xml @@ -184,7 +184,7 @@ - + diff --git a/conf/sbc/sbc_profiles/external.xml b/conf/sbc/sbc_profiles/external.xml index 7bf024658b..1cb91e8dab 100644 --- a/conf/sbc/sbc_profiles/external.xml +++ b/conf/sbc/sbc_profiles/external.xml @@ -49,7 +49,6 @@ - diff --git a/conf/sbc/sbc_profiles/internal-ipv6.xml b/conf/sbc/sbc_profiles/internal-ipv6.xml index 525554f4b8..e433da1425 100644 --- a/conf/sbc/sbc_profiles/internal-ipv6.xml +++ b/conf/sbc/sbc_profiles/internal-ipv6.xml @@ -69,9 +69,6 @@ - - - diff --git a/conf/sbc/sbc_profiles/internal.xml b/conf/sbc/sbc_profiles/internal.xml index d4b2efd37b..8263a82668 100644 --- a/conf/sbc/sbc_profiles/internal.xml +++ b/conf/sbc/sbc_profiles/internal.xml @@ -110,9 +110,6 @@ - - - diff --git a/conf/testing/autoload_configs/amrwb.conf.xml b/conf/testing/autoload_configs/amrwb.conf.xml new file mode 100644 index 0000000000..1163ffd1a6 --- /dev/null +++ b/conf/testing/autoload_configs/amrwb.conf.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + diff --git a/conf/testing/autoload_configs/opus.conf.xml b/conf/testing/autoload_configs/opus.conf.xml index e187a0a6c5..1154797dce 100644 --- a/conf/testing/autoload_configs/opus.conf.xml +++ b/conf/testing/autoload_configs/opus.conf.xml @@ -6,6 +6,7 @@ - + + diff --git a/conf/testing/autoload_configs/switch.conf.xml b/conf/testing/autoload_configs/switch.conf.xml index d07c1b2d6e..2633165f68 100644 --- a/conf/testing/autoload_configs/switch.conf.xml +++ b/conf/testing/autoload_configs/switch.conf.xml @@ -150,8 +150,6 @@ - - diff --git a/conf/testing/sip_profiles/external.xml b/conf/testing/sip_profiles/external.xml index 6edc878c06..4d12b0f5b3 100644 --- a/conf/testing/sip_profiles/external.xml +++ b/conf/testing/sip_profiles/external.xml @@ -57,7 +57,6 @@ - diff --git a/conf/testing/sip_profiles/internal-ipv6.xml b/conf/testing/sip_profiles/internal-ipv6.xml index 98efa2ffbb..46e60d4ad9 100644 --- a/conf/testing/sip_profiles/internal-ipv6.xml +++ b/conf/testing/sip_profiles/internal-ipv6.xml @@ -71,9 +71,6 @@ - - - diff --git a/conf/testing/sip_profiles/internal.xml b/conf/testing/sip_profiles/internal.xml index 2a3564ebb4..62f52af63f 100644 --- a/conf/testing/sip_profiles/internal.xml +++ b/conf/testing/sip_profiles/internal.xml @@ -216,6 +216,14 @@ + + + @@ -238,9 +246,6 @@ - - - diff --git a/conf/testing/vars.xml b/conf/testing/vars.xml index 814f709be3..68d5e1083e 100644 --- a/conf/testing/vars.xml +++ b/conf/testing/vars.xml @@ -7,7 +7,6 @@ - diff --git a/conf/vanilla/autoload_configs/amr.conf.xml b/conf/vanilla/autoload_configs/amr.conf.xml index e1c3e3cc1b..19b8cb8891 100644 --- a/conf/vanilla/autoload_configs/amr.conf.xml +++ b/conf/vanilla/autoload_configs/amr.conf.xml @@ -15,5 +15,7 @@ + + diff --git a/conf/vanilla/autoload_configs/amrwb.conf.xml b/conf/vanilla/autoload_configs/amrwb.conf.xml index 9dac3505a4..1163ffd1a6 100644 --- a/conf/vanilla/autoload_configs/amrwb.conf.xml +++ b/conf/vanilla/autoload_configs/amrwb.conf.xml @@ -1,7 +1,24 @@ - - - - + + + + + + + + + + + diff --git a/conf/vanilla/autoload_configs/dingaling.conf.xml b/conf/vanilla/autoload_configs/dingaling.conf.xml deleted file mode 100644 index dd6c9a5da1..0000000000 --- a/conf/vanilla/autoload_configs/dingaling.conf.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/conf/vanilla/autoload_configs/modules.conf.xml b/conf/vanilla/autoload_configs/modules.conf.xml index 8eff5fe263..b5a58d1580 100644 --- a/conf/vanilla/autoload_configs/modules.conf.xml +++ b/conf/vanilla/autoload_configs/modules.conf.xml @@ -122,6 +122,7 @@ + diff --git a/conf/vanilla/autoload_configs/opus.conf.xml b/conf/vanilla/autoload_configs/opus.conf.xml index 94aaede471..8494c2d3c7 100644 --- a/conf/vanilla/autoload_configs/opus.conf.xml +++ b/conf/vanilla/autoload_configs/opus.conf.xml @@ -28,6 +28,8 @@ - + + + diff --git a/conf/vanilla/autoload_configs/signalwire.conf.xml b/conf/vanilla/autoload_configs/signalwire.conf.xml new file mode 100644 index 0000000000..86e7056c7b --- /dev/null +++ b/conf/vanilla/autoload_configs/signalwire.conf.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/conf/vanilla/autoload_configs/spandsp.conf.xml b/conf/vanilla/autoload_configs/spandsp.conf.xml index 2471ca52ce..6345512908 100644 --- a/conf/vanilla/autoload_configs/spandsp.conf.xml +++ b/conf/vanilla/autoload_configs/spandsp.conf.xml @@ -28,6 +28,7 @@ + diff --git a/conf/vanilla/autoload_configs/switch.conf.xml b/conf/vanilla/autoload_configs/switch.conf.xml index 714b62c54c..8117d8ed9c 100644 --- a/conf/vanilla/autoload_configs/switch.conf.xml +++ b/conf/vanilla/autoload_configs/switch.conf.xml @@ -153,8 +153,6 @@ - - + + + - - - - - - - - - - - - - - - - - - - diff --git a/conf/vanilla/autoload_configs/verto.conf.xml b/conf/vanilla/autoload_configs/verto.conf.xml index 899aaeb6c2..91f75f11e9 100644 --- a/conf/vanilla/autoload_configs/verto.conf.xml +++ b/conf/vanilla/autoload_configs/verto.conf.xml @@ -2,6 +2,7 @@ + diff --git a/conf/vanilla/dialplan/default.xml b/conf/vanilla/dialplan/default.xml index 7f7ff6fa35..c3edafc1c8 100644 --- a/conf/vanilla/dialplan/default.xml +++ b/conf/vanilla/dialplan/default.xml @@ -443,10 +443,6 @@ This will take the SAS from the b-leg and send it to the display on the a-leg phone. Known working with Polycom and Snom maybe others. --> - @@ -768,13 +764,6 @@ - - - - - - - diff --git a/conf/vanilla/jingle_profiles/client.xml b/conf/vanilla/jingle_profiles/client.xml deleted file mode 100644 index 20a8dd809d..0000000000 --- a/conf/vanilla/jingle_profiles/client.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/conf/vanilla/jingle_profiles/server.xml b/conf/vanilla/jingle_profiles/server.xml deleted file mode 100644 index b60dc27ea6..0000000000 --- a/conf/vanilla/jingle_profiles/server.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/conf/vanilla/mrcp_profiles/loquendo-7-mrcp-v2.xml b/conf/vanilla/mrcp_profiles/loquendo-7-mrcp-v2.xml deleted file mode 100644 index dcf42821f5..0000000000 --- a/conf/vanilla/mrcp_profiles/loquendo-7-mrcp-v2.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/conf/vanilla/mrcp_profiles/nuance-1.0.0-mrcp-v1.xml b/conf/vanilla/mrcp_profiles/nuance-1.0.0-mrcp-v1.xml deleted file mode 100644 index 0700dec629..0000000000 --- a/conf/vanilla/mrcp_profiles/nuance-1.0.0-mrcp-v1.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/conf/vanilla/mrcp_profiles/nuance-5.0-mrcp-v1.xml b/conf/vanilla/mrcp_profiles/nuance-5.0-mrcp-v1.xml deleted file mode 100644 index 3c4938a66d..0000000000 --- a/conf/vanilla/mrcp_profiles/nuance-5.0-mrcp-v1.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/conf/vanilla/mrcp_profiles/nuance-5.0-mrcp-v2.xml b/conf/vanilla/mrcp_profiles/nuance-5.0-mrcp-v2.xml deleted file mode 100644 index b53cba0984..0000000000 --- a/conf/vanilla/mrcp_profiles/nuance-5.0-mrcp-v2.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/conf/vanilla/mrcp_profiles/unimrcpserver-mrcp-v1.xml b/conf/vanilla/mrcp_profiles/unimrcpserver-mrcp-v1.xml deleted file mode 100644 index fe02b1582f..0000000000 --- a/conf/vanilla/mrcp_profiles/unimrcpserver-mrcp-v1.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/conf/vanilla/mrcp_profiles/vestec-mrcp-v1.xml b/conf/vanilla/mrcp_profiles/vestec-mrcp-v1.xml deleted file mode 100644 index cbde87ca5a..0000000000 --- a/conf/vanilla/mrcp_profiles/vestec-mrcp-v1.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/conf/vanilla/mrcp_profiles/voxeo-prophecy-8.0-mrcp-v1.xml b/conf/vanilla/mrcp_profiles/voxeo-prophecy-8.0-mrcp-v1.xml deleted file mode 100644 index fb1d0ee287..0000000000 --- a/conf/vanilla/mrcp_profiles/voxeo-prophecy-8.0-mrcp-v1.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/conf/vanilla/sip_profiles/external-ipv6.xml b/conf/vanilla/sip_profiles/external-ipv6.xml index 99e8feb246..1b9d0c857d 100644 --- a/conf/vanilla/sip_profiles/external-ipv6.xml +++ b/conf/vanilla/sip_profiles/external-ipv6.xml @@ -57,7 +57,6 @@ - diff --git a/conf/vanilla/sip_profiles/external.xml b/conf/vanilla/sip_profiles/external.xml index d9e312d78f..57ec4a6e74 100644 --- a/conf/vanilla/sip_profiles/external.xml +++ b/conf/vanilla/sip_profiles/external.xml @@ -57,7 +57,6 @@ - diff --git a/conf/vanilla/sip_profiles/internal-ipv6.xml b/conf/vanilla/sip_profiles/internal-ipv6.xml index 21bb1f1e77..26c891ba98 100644 --- a/conf/vanilla/sip_profiles/internal-ipv6.xml +++ b/conf/vanilla/sip_profiles/internal-ipv6.xml @@ -36,6 +36,8 @@ + + @@ -71,9 +73,6 @@ - - - diff --git a/conf/vanilla/sip_profiles/internal.xml b/conf/vanilla/sip_profiles/internal.xml index 58350e827b..eb07779f43 100644 --- a/conf/vanilla/sip_profiles/internal.xml +++ b/conf/vanilla/sip_profiles/internal.xml @@ -172,6 +172,8 @@ + + @@ -216,6 +218,14 @@ + + + @@ -229,6 +239,9 @@ + + + @@ -238,9 +251,6 @@ - - - diff --git a/conf/vanilla/vars.xml b/conf/vanilla/vars.xml index 387592c978..8948d179cc 100644 --- a/conf/vanilla/vars.xml +++ b/conf/vanilla/vars.xml @@ -41,7 +41,6 @@ storage_dir cache_dir core_uuid - zrtp_enabled nat_public_addr nat_private_addr nat_type @@ -64,12 +63,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/docs/phrase/phrase_es_MX.xml b/docs/phrase/phrase_es_MX.xml index 7860d01e81..c7882ff7e0 100644 --- a/docs/phrase/phrase_es_MX.xml +++ b/docs/phrase/phrase_es_MX.xml @@ -991,23 +991,5 @@ - - - - - - - - - - - - - - - - - - diff --git a/docs/phrase/phrase_pt_BR.xml b/docs/phrase/phrase_pt_BR.xml index af58683a09..d618767b8f 100644 --- a/docs/phrase/phrase_pt_BR.xml +++ b/docs/phrase/phrase_pt_BR.xml @@ -985,23 +985,5 @@ - - - - - - - - - - - - - - - - - - diff --git a/docs/phrase/phrase_pt_PT.xml b/docs/phrase/phrase_pt_PT.xml index 66775ef839..4a04b5751d 100644 --- a/docs/phrase/phrase_pt_PT.xml +++ b/docs/phrase/phrase_pt_PT.xml @@ -984,23 +984,5 @@ - - - - - - - - - - - - - - - - - - diff --git a/docs/phrase/phrase_ru.xml b/docs/phrase/phrase_ru.xml index fb873dd9da..714afa440f 100644 --- a/docs/phrase/phrase_ru.xml +++ b/docs/phrase/phrase_ru.xml @@ -1157,39 +1157,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/erlang.spec b/erlang.spec deleted file mode 100644 index 6cdd7245b9..0000000000 --- a/erlang.spec +++ /dev/null @@ -1,297 +0,0 @@ -%define ver %{VERSION_NUMBER} -%define rel %{RELEASE_NUMBER} - -Name: erlang -Version: %{ver} -Release: %{rel}.1%{?dist} -Summary: General-purpose programming language and runtime environment - -Group: Development/Languages -License: ERPL -URL: http://www.erlang.org -Source: http://www.erlang.org/download/otp_src_R14B03.tar.gz -Source1: http://www.erlang.org/download/otp_doc_html_R14B03.tar.gz -Source2: http://www.erlang.org/download/otp_doc_man_R14B03.tar.gz -Patch1: otp-R14B-00-0001-Do-not-format-man-pages.patch -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) - -BuildRequires: ncurses-devel -BuildRequires: openssl-devel -BuildRequires: unixODBC-devel -BuildRequires: tcl-devel -BuildRequires: tk-devel -BuildRequires: gd-devel -# BuildRequires: jdk -BuildRequires: flex -BuildRequires: m4 - -Requires: tk - -# Added virtual Provides for each erlang module -Provides: erlang-appmon = %{version}-%{release} -Provides: erlang-asn1 = %{version}-%{release} -Provides: erlang-common_test = %{version}-%{release} -Provides: erlang-compiler = %{version}-%{release} -Provides: erlang-cosEvent = %{version}-%{release} -Provides: erlang-cosEventDomain = %{version}-%{release} -Provides: erlang-cosFileTransfer = %{version}-%{release} -Provides: erlang-cosNotification = %{version}-%{release} -Provides: erlang-cosProperty = %{version}-%{release} -Provides: erlang-cosTime = %{version}-%{release} -Provides: erlang-cosTransactions = %{version}-%{release} -Provides: erlang-crypto = %{version}-%{release} -Provides: erlang-debugger = %{version}-%{release} -Provides: erlang-dialyzer = %{version}-%{release} -Provides: erlang-docbuilder = %{version}-%{release} -Provides: erlang-edoc = %{version}-%{release} -Provides: erlang-erts = %{version}-%{release} -Provides: erlang-et = %{version}-%{release} -Provides: erlang-eunit = %{version}-%{release} -Provides: erlang-gs = %{version}-%{release} -Provides: erlang-hipe = %{version}-%{release} -Provides: erlang-ic = %{version}-%{release} -Provides: erlang-inets = %{version}-%{release} -Provides: erlang-inviso = %{version}-%{release} -Provides: erlang-kernel = %{version}-%{release} -Provides: erlang-megaco = %{version}-%{release} -Provides: erlang-mnesia = %{version}-%{release} -Provides: erlang-observer = %{version}-%{release} -Provides: erlang-odbc = %{version}-%{release} -Provides: erlang-orber = %{version}-%{release} -Provides: erlang-os_mon = %{version}-%{release} -Provides: erlang-otp_mibs = %{version}-%{release} -Provides: erlang-parsetools = %{version}-%{release} -Provides: erlang-percept = %{version}-%{release} -Provides: erlang-pman = %{version}-%{release} -Provides: erlang-public_key = %{version}-%{release} -Provides: erlang-runtime_tools = %{version}-%{release} -Provides: erlang-sasl = %{version}-%{release} -Provides: erlang-snmp = %{version}-%{release} -Provides: erlang-ssh = %{version}-%{release} -Provides: erlang-ssl = %{version}-%{release} -Provides: erlang-stdlib = %{version}-%{release} -Provides: erlang-syntax_tools = %{version}-%{release} -Provides: erlang-test_server = %{version}-%{release} -Provides: erlang-toolbar = %{version}-%{release} -Provides: erlang-tools = %{version}-%{release} -Provides: erlang-tv = %{version}-%{release} -Provides: erlang-typer = %{version}-%{release} -Provides: erlang-webtool = %{version}-%{release} -Provides: erlang-xmerl = %{version}-%{release} - -%description -Erlang is a general-purpose programming language and runtime -environment. Erlang has built-in support for concurrency, distribution -and fault tolerance. Erlang is used in several large telecommunication -systems from Ericsson. - - -%package doc -Summary: Erlang documentation -Group: Development/Languages - -%description doc -Documentation for Erlang. - - -%prep -%setup -q -n otp_src_%{ver}%{rel} -#%setup -q -n otp_src_%{ver} - -%build -# WARN: --enable-dynamic-ssl-lib needed for preventing strange messages about missing dependencies on EPEL -# see https://bugzilla.redhat.com/458646 and https://bugzilla.redhat.com/499525 -%ifarch sparcv9 sparc64 -CFLAGS="$RPM_OPT_FLAGS -mcpu=ultrasparc -fno-strict-aliasing" %configure --enable-dynamic-ssl-lib -%else -CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing" %configure --enable-dynamic-ssl-lib -%endif -chmod -R u+w . -make - - -%install -rm -rf $RPM_BUILD_ROOT -make INSTALL_PREFIX=$RPM_BUILD_ROOT install - -# clean up -find $RPM_BUILD_ROOT%{_libdir}/erlang -perm 0775 | xargs chmod 755 -find $RPM_BUILD_ROOT%{_libdir}/erlang -name Makefile | xargs chmod 644 -find $RPM_BUILD_ROOT%{_libdir}/erlang -name \*.o | xargs chmod 644 -find $RPM_BUILD_ROOT%{_libdir}/erlang -name \*.bat | xargs rm -f -find $RPM_BUILD_ROOT%{_libdir}/erlang -name index.txt.old | xargs rm -f - -# doc -mkdir -p erlang_doc -tar -C erlang_doc -zxf %{SOURCE1} -tar -C $RPM_BUILD_ROOT/%{_libdir}/erlang -zxf %{SOURCE2} - -# make links to binaries -#mkdir -p $RPM_BUILD_ROOT/%{_bindir} -#cd $RPM_BUILD_ROOT/%{_bindir} -#for file in erl erlc escript dialyzer -#do -# ln -sf ../%{_lib}/erlang/bin/$file . -#done - -# remove buildroot from installed files -cd $RPM_BUILD_ROOT/%{_libdir}/erlang -sed -i "s|$RPM_BUILD_ROOT||" erts*/bin/{erl,start} releases/RELEASES bin/{erl,start} - - -%clean -rm -rf $RPM_BUILD_ROOT - - -%files -%defattr(-,root,root) -%doc AUTHORS EPLICENCE README.md -%{_bindir}/* -%{_libdir}/erlang - - -%files doc -%defattr(-,root,root) -%doc erlang_doc/* - - -%post -%{_libdir}/erlang/Install -minimal %{_libdir}/erlang >/dev/null 2>/dev/null - - -%changelog -* Wed Sep 29 2010 Anthony Molinaro - R14B-00.1 -- modified R13B04 spec to work with R14B - -* Wed Jul 7 2010 Anthony Molinaro - R13B-04.1 -- modified the R12B spec to work with R13B04 - -* Mon Jun 7 2010 Peter Lemenkov - R12B-5.10 -- Added missing virtual provides erlang-erts - -* Tue May 25 2010 Peter Lemenkov - R12B-5.9 -- Use java-1.4.2 only for EL-[45] -- Added virtual provides for each erlang module -- Small typo fix - -* Mon Apr 19 2010 Peter Lemenkov - R12B-5.8 -- Patches rebased -- Added patches 6,7 from trunk -- Use %%configure - -* Tue Apr 21 2009 Debarshi Ray R12B-5.7 -- Updated rpath patch. -- Fixed configure to respect $RPM_OPT_FLAGS. - -* Sun Mar 1 2009 Gerard Milmeister - R12B-5.6 -- new release R12B-5 -- link escript and dialyzer to %{_bindir} - -* Tue Feb 24 2009 Fedora Release Engineering - R12B-5.5 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild - -* Sat Feb 14 2009 Dennis Gilmore - R12B-4.5 -- fix sparc arches to compile - -* Fri Jan 16 2009 Tomas Mraz - R12B-4.4 -- rebuild with new openssl - -* Sat Oct 25 2008 Gerard Milmeister - R12B-4.1 -- new release R12B-4 - -* Fri Sep 5 2008 Gerard Milmeister - R12B-3.3 -- fixed sslrpath patch - -* Thu Jul 17 2008 Tom "spot" Callaway - R12B-3.2 -- fix license tag - -* Sun Jul 6 2008 Gerard Milmeister - R12B-3.1 -- new release R12B-3 - -* Thu Mar 27 2008 Gerard Milmeister - R12B-1.1 -- new release R12B-1 - -* Sat Feb 23 2008 Gerard Milmeister - R12B-0.3 -- disable strict aliasing optimization - -* Mon Feb 18 2008 Fedora Release Engineering - R12B-0.2 -- Autorebuild for GCC 4.3 - -* Sat Dec 8 2007 Gerard Milmeister - R12B-0.1 -- new release R12B-0 - -* Wed Dec 05 2007 Release Engineering - R11B-6 - - Rebuild for deps - -* Sun Aug 19 2007 Gerard Milmeister - R11B-5.3 -- fix some permissions - -* Sat Aug 18 2007 Gerard Milmeister - R11B-5.2 -- enable dynamic linking for ssl - -* Sat Aug 18 2007 Gerard Milmeister - R11B-5.1 -- new release R11B-5 - -* Sat Mar 24 2007 Thomas Fitzsimmons - R11B-2.4 -- Require java-1.5.0-gcj-devel for build. - -* Sun Dec 31 2006 Gerard Milmeister - R11B-2.3 -- remove buildroot from installed files - -* Sat Dec 30 2006 Gerard Milmeister - R11B-2.2 -- added patch for compiling with glibc 2.5 - -* Sat Dec 30 2006 Gerard Milmeister - R11B-2.1 -- new version R11B-2 - -* Mon Aug 28 2006 Gerard Milmeister - R11B-0.3 -- Rebuild for FE6 - -* Wed Jul 5 2006 Gerard Milmeister - R11B-0.2 -- add BR m4 - -* Thu May 18 2006 Gerard Milmeister - R11B-0.1 -- new version R11B-0 - -* Wed May 3 2006 Gerard Milmeister - R10B-10.3 -- added patch for run_erl by Knut-Håvard Aksnes - -* Mon Mar 13 2006 Gerard Milmeister - R10B-10.1 -- new version R10B-10 - -* Thu Dec 29 2005 Gerard Milmeister - R10B-9.1 -- New Version R10B-9 - -* Sat Oct 29 2005 Gerard Milmeister - R10B-8.2 -- updated rpath patch - -* Sat Oct 29 2005 Gerard Milmeister - R10B-8.1 -- New Version R10B-8 - -* Sat Oct 1 2005 Gerard Milmeister - R10B-6.4 -- Added tk-devel and tcl-devel to buildreq -- Added tk to req - -* Tue Sep 6 2005 Gerard Milmeister - R10B-6.3 -- Remove perl BuildRequires - -* Tue Aug 30 2005 Gerard Milmeister - R10B-6.2 -- change /usr/lib to %%{_libdir} -- redirect output in %%post to /dev/null -- add unixODBC-devel to BuildRequires -- split doc off to erlang-doc package - -* Sat Jun 25 2005 Gerard Milmeister - R10B-6.1 -- New Version R10B-6 - -* Sun Feb 13 2005 Gerard Milmeister - R10B-3.1 -- New Version R10B-3 - -* Mon Dec 27 2004 Gerard Milmeister - 0:R10B-2-0.fdr.1 -- New Version R10B-2 - -* Wed Oct 6 2004 Gerard Milmeister - 0:R10B-0.fdr.1 -- New Version R10B - -* Thu Oct 16 2003 Gerard Milmeister - 0:R9B-1.fdr.1 -- First Fedora release diff --git a/freeswitch.spec b/freeswitch.spec index dfd71f5429..f3904afa2c 100644 --- a/freeswitch.spec +++ b/freeswitch.spec @@ -37,8 +37,6 @@ %define build_mod_esl 0 %define build_mod_rayo 1 %define build_mod_ssml 1 -%define build_mod_shout 1 -%define build_mod_opusfile 0 %define build_mod_v8 0 %{?with_sang_tc:%define build_sng_tc 1 } @@ -47,8 +45,6 @@ %{?with_py26_esl:%define build_py26_esl 1 } %{?with_timerfd:%define build_timerfd 1 } %{?with_mod_esl:%define build_mod_esl 1 } -%{?with_mod_shout:%define build_mod_shout 1 } -%{?with_mod_opusfile:%define build_mod_opusfile 1 } %{?with_mod_v8:%define build_mod_v8 1 } %define nonparsedversion 1.7.0 @@ -144,7 +140,7 @@ BuildRequires: curl-devel >= 7.19 BuildRequires: gcc-c++ BuildRequires: libtool >= 1.5.17 BuildRequires: openssl-devel >= 1.0.1e -BuildRequires: sofia-sip-devel >= 1.12.12 +BuildRequires: sofia-sip-devel >= 1.13.14 BuildRequires: spandsp3-devel >= 3.0 BuildRequires: pcre-devel BuildRequires: speex-devel @@ -172,10 +168,26 @@ Requires: zlib Requires: libxml2 Requires: libsndfile +%if 0%{?rhel} == 7 +# to build mariadb module required gcc >= 4.9 (more details GH #1046) +# On CentOS 7 dist you can install fresh gcc using command +# yum install centos-release-scl && yum install devtoolset-9 +BuildRequires: devtoolset-9 +%endif +%if 0%{?rhel} == 8 +# we want use fresh gcc on RHEL 8 based dists +# On CentOS 8 dist you can install fresh gcc using command +# dnf install gcc-toolset-9 +BuildRequires: gcc-toolset-9 +%endif + %if 0%{?suse_version} > 800 PreReq: %insserv_prereq %fillup_prereq %endif +%if 0%{?fedora} +BuildRequires: gumbo-parser-devel +%endif ###################################################################################################################### # @@ -296,7 +308,7 @@ Group: System/Libraries Requires: %{name} = %{version}-%{release} %description application-directory -Provides FreeSWITCH mod_directory, a dial by name directory application. +Provides FreeSWITCH mod_directory, a dial by name directory application. %package application-distributor Summary: FreeSWITCH mod_distributor @@ -304,7 +316,7 @@ Group: System/Libraries Requires: %{name} = %{version}-%{release} %description application-distributor -Provides FreeSWITCH mod_distributor, a simple round-robbin style distribution +Provides FreeSWITCH mod_distributor, a simple round-robin style distribution to call gateways. %package application-easyroute @@ -461,7 +473,7 @@ Group: System/Libraries Requires: %{name} = %{version}-%{release} %description application-rad_auth -Provides FreeSWITCH mod_rad_auth, authetication via RADIUS protocol from FreeSWITCH dialplan +Provides FreeSWITCH mod_rad_auth, authentication via RADIUS protocol from FreeSWITCH dialplan %package application-redis Summary: FreeSWITCH mod_redis @@ -624,15 +636,6 @@ Requires: %{name} = %{version}-%{release} Provides FreeSWITCH mod_tts_commandline, Run a command line and play the output file. -%package asrtts-unimrcp -Summary: FreeSWITCH mod_unimrcp -Group: System/Libraries -Requires: %{name} = %{version}-%{release} - -%description asrtts-unimrcp -Provides FreeSWITCH mod_unimrcp, allows communication with Media Resource -Control Protocol (MRCP) servers - ###################################################################################################################### # FreeSWITCH Codec Modules ###################################################################################################################### @@ -829,17 +832,8 @@ PostgreSQL native support for FreeSWITCH. # FreeSWITCH Endpoint Modules ###################################################################################################################### -%package endpoint-dingaling -Summary: Generic XMPP support for FreeSWITCH open source telephony platform -Group: System/Libraries -Requires: %{name} = %{version}-%{release} - -%description endpoint-dingaling -XMPP support for FreeSWITCH open source telephony platform. Allows FreeSWITCH -to be used as a client for GoogleTalk or other XMPP Servers. - #%package endpoint-gsmopen -#Summary: Generic GSM enpoint support for FreeSWITCH open source telephony platform +#Summary: Generic GSM endpoint support for FreeSWITCH open source telephony platform #Group: System/Libraries #Requires: %{name} = %{version}-%{release} # @@ -849,12 +843,12 @@ to be used as a client for GoogleTalk or other XMPP Servers. #SMS is handled via the standard CHAT API in FreeSWITCH. #%package endpoint-h323 -#Summary: H.323 enpoint support for FreeSWITCH open source telephony platform +#Summary: H.323 endpoint support for FreeSWITCH open source telephony platform #Group: System/Libraries #Requires: %{name} = %{version}-%{release} # #%description endpoint-h323 -#H.323 enpoint support for FreeSWITCH open source telephony platform +#H.323 endpoint support for FreeSWITCH open source telephony platform #%package endpoint-khomp #Summary: khomp endpoint support for FreeSWITCH open source telephony platform @@ -1078,7 +1072,6 @@ Mod shell stream is a FreeSWITCH module to allow you to stream audio from an arbitrary shell command. You could use it to read audio from a database, from a soundcard, etc. -%if %{build_mod_shout} %package format-mod-shout Summary: Implements Media Steaming from arbitrary shell commands for the FreeSWITCH open source telephony platform Group: System/Libraries @@ -1093,19 +1086,16 @@ BuildRequires: lame-devel %description format-mod-shout Mod Shout is a FreeSWITCH module to allow you to stream audio from MP3s or a i shoutcast stream. -%endif -%if %{build_mod_opusfile} -%package format-mod-opusfile +%package format-opusfile Summary: Plays Opus encoded files Group: System/Libraries Requires: %{name} = %{version}-%{release} Requires: opusfile >= 0.5 BuildRequires: opusfile-devel >= 0.5 -%description format-mod-opusfile +%description format-opusfile Mod Opusfile is a FreeSWITCH module to allow you to play Opus encoded files -%endif %if %{build_mod_ssml} %package format-ssml @@ -1170,7 +1160,7 @@ Requires: %{name} = %{version}-%{release} ###################################################################################################################### %package lang-en -Summary: Provides english language dependand modules and speech config for the FreeSWITCH Open Source telephone platform. +Summary: Provides english language dependent modules and speech config for the FreeSWITCH Open Source telephone platform. Group: System/Libraries Requires: %{name} = %{version}-%{release} @@ -1178,7 +1168,7 @@ Requires: %{name} = %{version}-%{release} English language phrases module and directory structure for say module and voicemail %package lang-ru -Summary: Provides russian language dependand modules and speech config for the FreeSWITCH Open Source telephone platform. +Summary: Provides russian language dependent modules and speech config for the FreeSWITCH Open Source telephone platform. Group: System/Libraries Requires: %{name} = %{version}-%{release} @@ -1218,12 +1208,12 @@ Requires: %{name} = %{version}-%{release} Spanish language phrases module and directory structure for say module and voicemail %package lang-pt -Summary: Provides Portugese language dependend modules and speech config for the FreeSWITCH Open Source telephone platform. +Summary: Provides Portuguese language dependend modules and speech config for the FreeSWITCH Open Source telephone platform. Group: System/Libraries Requires: %{name} = %{version}-%{release} %description lang-pt -Portugese language phrases module and directory structure for say module and voicemail +Portuguese language phrases module and directory structure for say module and voicemail %package lang-sv Summary: Provides Swedish language dependend modules and speech config for the FreeSWITCH Open Source telephone platform. @@ -1436,7 +1426,7 @@ APPLICATIONS_MODULES="$APPLICATION_MODULES_AC $APPLICATION_MODULES_DE $APPLICATI # Automatic Speech Recognition and Text To Speech Modules # ###################################################################################################################### -ASR_TTS_MODULES="asr_tts/mod_flite asr_tts/mod_pocketsphinx asr_tts/mod_tts_commandline asr_tts/mod_unimrcp" +ASR_TTS_MODULES="asr_tts/mod_flite asr_tts/mod_pocketsphinx asr_tts/mod_tts_commandline" ###################################################################################################################### # @@ -1477,7 +1467,7 @@ DIRECTORIES_MODULES="" # Endpoints # ###################################################################################################################### -ENDPOINTS_MODULES="endpoints/mod_dingaling \ +ENDPOINTS_MODULES=" \ endpoints/mod_loopback endpoints/mod_portaudio endpoints/mod_rtmp \ endpoints/mod_skinny endpoints/mod_verto endpoints/mod_rtc endpoints/mod_sofia" @@ -1502,17 +1492,11 @@ EVENT_HANDLERS_MODULES+=" event_handlers/mod_rayo" # File and Audio Format Handlers # ###################################################################################################################### -FORMATS_MODULES="formats/mod_local_stream formats/mod_native_file formats/mod_portaudio_stream \ - formats/mod_shell_stream formats/mod_sndfile formats/mod_tone_stream" -%if %{build_mod_shout} -FORMATS_MODULES+=" formats/mod_shout " -%endif +FORMATS_MODULES="formats/mod_local_stream formats/mod_native_file formats/mod_opusfile formats/mod_portaudio_stream \ + formats/mod_shell_stream formats/mod_shout formats/mod_sndfile formats/mod_tone_stream" %if %{build_mod_ssml} FORMATS_MODULES+=" formats/mod_ssml" %endif -%if %{build_mod_opusfile} -FORMATS_MODULES+=" formats/mod_opusfile" -%endif ###################################################################################################################### # @@ -1579,6 +1563,16 @@ export DESTDIR=%{buildroot}/ export PKG_CONFIG_PATH=/usr/bin/pkg-config:$PKG_CONFIG_PATH export ACLOCAL_FLAGS="-I /usr/share/aclocal" +%if 0%{?rhel} == 7 +# to build mod_mariadb we need gcc >= 4.9 (more details GH #1046) +export CFLAGS="$CFLAGS -Wno-error=expansion-to-defined" +. /opt/rh/devtoolset-9/enable +%endif +%if 0%{?rhel} == 8 +# we want use fresh gcc on RHEL 8 based dists +. /opt/rh/gcc-toolset-9/enable +%endif + ###################################################################################################################### # # Bootstrap, Configure and Build the whole enchilada @@ -1638,6 +1632,15 @@ cd libs/esl # ###################################################################################################################### %install +%if 0%{?rhel} == 7 +# to build mod_mariadb we need gcc >= 4.9 +. /opt/rh/devtoolset-9/enable +%endif +%if 0%{?rhel} == 8 +# we want use fresh gcc on RHEL 8 based dists +. /opt/rh/gcc-toolset-9/enable +%endif + %{__make} DESTDIR=%{buildroot} install @@ -1645,6 +1648,7 @@ cd libs/esl %{__mkdir} -p %{buildroot}%{prefix}/log %{__mkdir} -p %{buildroot}%{logfiledir} %{__mkdir} -p %{buildroot}%{runtimedir} +%{__mkdir} -p %{buildroot}%{_localstatedir}/cache/freeswitch #install the esl stuff cd libs/esl @@ -1704,6 +1708,8 @@ cd ../.. %{__rm} -f %{buildroot}/%{MODINSTDIR}/ftmod_sangoma_isdn* %endif +%{__rm} -f %{buildroot}/%{LIBDIR}/*.la +%{__rm} -f %{buildroot}/%{MODINSTDIR}/*.la ###################################################################################################################### @@ -1787,9 +1793,7 @@ fi %dir %attr(0750, freeswitch, daemon) %{sysconfdir}/dialplan/skinny-patterns %dir %attr(0750, freeswitch, daemon) %{sysconfdir}/directory %dir %attr(0750, freeswitch, daemon) %{sysconfdir}/directory/default -%dir %attr(0750, freeswitch, daemon) %{sysconfdir}/jingle_profiles %dir %attr(0750, freeswitch, daemon) %{sysconfdir}/lang -%dir %attr(0750, freeswitch, daemon) %{sysconfdir}/mrcp_profiles %dir %attr(0750, freeswitch, daemon) %{sysconfdir}/sip_profiles %dir %attr(0750, freeswitch, daemon) %{sysconfdir}/sip_profiles/external %dir %attr(0750, freeswitch, daemon) %{sysconfdir}/sip_profiles/external-ipv6 @@ -1858,10 +1862,8 @@ fi # ###################################################################################################################### %files devel -%{LIBDIR}/*.a -%{LIBDIR}/*.la +%{LIBDIR}/*.so* %{PKGCONFIGDIR}/* -%{MODINSTDIR}/*.*a %{INCLUDEDIR}/*.h %{INCLUDEDIR}/test/*.h @@ -1897,7 +1899,6 @@ fi %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/curl.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/db.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/dialplan_directory.conf.xml -%config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/dingaling.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/directory.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/distributor.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/easyroute.conf.xml @@ -1937,6 +1938,7 @@ fi %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/rtmp.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/sangoma_codec.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/shout.conf.xml +%config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/signalwire.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/skinny.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/smpp.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/sms_flowroute.conf.xml @@ -1949,7 +1951,6 @@ fi %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/translate.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/tts_commandline.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/unicall.conf.xml -%config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/unimrcp.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/verto.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/voicemail.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/voicemail_ivr.conf.xml @@ -1982,7 +1983,7 @@ fi %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/directory/*.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/directory/default/* ###################################################################################################################### -# IVR Menues +# IVR Menus ###################################################################################################################### %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/ivr_menus/*.xml ###################################################################################################################### @@ -1992,11 +1993,9 @@ fi %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/sip_profiles/external/*.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/sip_profiles/external-ipv6/*.xml ###################################################################################################################### -# Other Protocol Profiles (skinny, jingle, mrcp) +# Other Protocol Profiles (skinny) ###################################################################################################################### %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/skinny_profiles/*.xml -%config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/jingle_profiles/*.xml -%config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/mrcp_profiles/*.xml ###################################################################################################################### # Grammar Files ###################################################################################################################### @@ -2073,6 +2072,7 @@ fi %{MODINSTDIR}/mod_httapi.so* %files application-http-cache +%dir %attr(0750, freeswitch, daemon) %{_localstatedir}/cache/freeswitch %{MODINSTDIR}/mod_http_cache.so* %files application-lcr @@ -2149,9 +2149,6 @@ fi %files asrtts-tts-commandline %{MODINSTDIR}/mod_tts_commandline.so* -%files asrtts-unimrcp -%{MODINSTDIR}/mod_unimrcp.so* - ###################################################################################################################### # # CODEC Packages @@ -2234,9 +2231,6 @@ fi # ###################################################################################################################### -%files endpoint-dingaling -%{MODINSTDIR}/mod_dingaling.so* - #%files endpoint-gsmopen #%{MODINSTDIR}/mod_gsmopen.so* @@ -2318,16 +2312,17 @@ fi %files format-native-file %{MODINSTDIR}/mod_native_file.so* +%files format-opusfile +%{MODINSTDIR}/mod_opusfile.so* + %files format-portaudio-stream %{MODINSTDIR}/mod_portaudio_stream.so* %files format-shell-stream %{MODINSTDIR}/mod_shell_stream.so* -%if %{build_mod_shout} %files format-mod-shout %{MODINSTDIR}/mod_shout.so* -%endif %if %{build_mod_ssml} %files format-ssml @@ -2344,18 +2339,15 @@ fi ###################################################################################################################### %files lua %{MODINSTDIR}/mod_lua*.so* -%dir %attr(0750, freeswitch, daemon) %{sysconfdir}/autoload_configs %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/lua.conf.xml %files perl %{MODINSTDIR}/mod_perl*.so* %{prefix}/perl/* -%dir %attr(0750, freeswitch, daemon) %{sysconfdir}/autoload_configs %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/perl.conf.xml %files python %{MODINSTDIR}/mod_python*.so* -%dir %attr(0750, freeswitch, daemon) %{sysconfdir}/autoload_configs %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/python.conf.xml %if %{build_mod_v8} @@ -2365,7 +2357,6 @@ fi %{LIBDIR}/libicui18n.so %{LIBDIR}/libicuuc.so %endif -%dir %attr(0750, freeswitch, daemon) %{sysconfdir}/autoload_configs %config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/v8.conf.xml ###################################################################################################################### @@ -2557,7 +2548,7 @@ fi * Wed Jun 19 2013 - krice@freeswitch.org - tweak files included for vanilla configs * Wed Sep 19 2012 - krice@freeswitch.org -- Add support for Spanish and Portugese say language modules +- Add support for Spanish and Portuguese say language modules * Thu Jan 26 2012 - krice@freeswitch.org - complete rework of spec file * Tue Jun 14 2011 - michal.bielicki@seventhsignal.de @@ -2576,7 +2567,7 @@ fi - fixes for ss7 freetdm modules - added mod_opus - added selector for sangoma modules -- addded python esl module to rpm +- added python esl module to rpm - some minor cleanups - cut sangoma modules into separate rpms as addons for freetdm * Tue Jan 18 2011 - michal.bielicki@seventhsignal.de @@ -2594,7 +2585,7 @@ fi - added mod_nibblebill to standard modules * Sun Sep 26 2010 - michal.bielicki@seventhsignal.de - added portaudio_stream module -- some more formating work +- some more formatting work * Mon Jul 19 2010 - michal.bielicki@seventhsignal.de - new hash module config file added to freeswitch.spec * Mon Jul 19 2010 - michal.bielicki@seventhsignal.de @@ -2607,7 +2598,7 @@ fi - Added Contributors - Added Anthony's copyright for the whole package into the header * Tue Jun 22 2010 - michal.bielicki@seventhsignal.de -- Reorganized the modules alphabeticaly +- Reorganized the modules alphabetically - synced SFEopensolaris and centos spec - started to fix Run Dependencies - added mod_say_ru which seemd to have gone missing @@ -2619,7 +2610,7 @@ fi - replaced mod_limit with mod_db - added mod_spy - added mod_valet_parking -- addded mod_memcache +- added mod_memcache - added mod_distributor - added mod_avmd * Thu Apr 29 2010 - michal.bielicki@seventhsignal.de @@ -2639,7 +2630,7 @@ fi * Sat Nov 21 2009 - michal.bielicki@seventhsignal.de - added patch by Igor Neves : Added some checkup in %post and %postun to prevent upgrades from removing freeswitch user * Wed Nov 18 2009 - michal.bielicki@seventhsignal.de -- added new config files for diretory and distributor +- added new config files for directory and distributor - removed sangoma boost from openzap for builds that do not inherit wanpipe while building. * Fri Jul 24 2009 - mike@jerris.com - removed mod_http @@ -2704,7 +2695,7 @@ fi - fixed odbc requirements - added all buildable modules - added redhat style init file -- splitted off language dependant stuff into separate language files +- split off language dependent stuff into separate language files - disable non complete language modules * Tue Apr 24 2007 - peter+rpmspam@suntel.com.tr - Added a debug package diff --git a/fscomm/preferences/prefdialog.ui b/fscomm/preferences/prefdialog.ui index aca5eff198..66742f2c78 100644 --- a/fscomm/preferences/prefdialog.ui +++ b/fscomm/preferences/prefdialog.ui @@ -1092,7 +1092,7 @@ - Noise Supressor + Noise Suppressor diff --git a/images/cluecon.jpg b/images/cluecon.jpg new file mode 100644 index 0000000000..a6e89751ea Binary files /dev/null and b/images/cluecon.jpg differ diff --git a/images/cluecon.png b/images/cluecon.png new file mode 100644 index 0000000000..7b0c4ced2b Binary files /dev/null and b/images/cluecon.png differ diff --git a/libs/.gitignore b/libs/.gitignore index 392aaffdbd..87da2671c6 100644 --- a/libs/.gitignore +++ b/libs/.gitignore @@ -34,40 +34,13 @@ opal /apr/build/pkg/pkginfo /apr/exports.c /apr/export_vars.c -/apr/include/apr.h -/apr/include/arch/unix/apr_private.h -/apr/include/arch/unix/apr_private.h.in +/apr/include/fspr.h +/apr/include/arch/unix/fspr_private.h +/apr/include/arch/unix/fspr_private.h.in /apr/.make.dirs /apr/Makefile /apr/test/internal/Makefile /apr/test/Makefile -/apr-util/aprutil.exp -/apr-util/apu-1-config -/apr-util/build/apr_common.m4 -/apr-util/build/find_apr.m4 -/apr-util/build/get-version.sh -/apr-util/build/install.sh -/apr-util/build/pkg/pkginfo -/apr-util/build/rules.mk -/apr-util/exports.c -/apr-util/export_vars.c -/apr-util/export_vars.sh -/apr-util/include/apr_ldap.h -/apr-util/include/apu_config.h -/apr-util/include/apu.h -/apr-util/include/apu_select_dbm.h -/apr-util/include/apu_want.h -/apr-util/include/private/apu_config.h -/apr-util/include/private/apu_config.h.in -/apr-util/include/private/apu_select_dbm.h -/apr-util/.make.dirs -/apr-util/Makefile -/apr-util/test/Makefile -/apr-util/xml/expat/config.h -/apr-util/xml/expat/lib/config.h -/apr-util/xml/expat/lib/expat.h -/apr-util/xml/expat/lib/Makefile -/apr-util/xml/expat/Makefile /broadvoice/config-h.in /broadvoice/doc/Makefile /broadvoice/doc/Makefile.in @@ -85,12 +58,6 @@ opal /esl/Release/ /flite-*/ /freeradius-client-*/ -/freetdm/build/compile -/freetdm/COPYING -/freetdm/INSTALL -/freetdm/Makefile.in -/freetdm/msvc/Debug/ -/freetdm/msvc/Release/ /iksemel/build/compile /iksemel/doc/Makefile /iksemel/doc/Makefile.in @@ -232,11 +199,6 @@ opal /libcodec2/unittest/vqtrainjnd /libcodec2/unittest/vqtrainph /libcodec2/unittest/vqtrainsp -/libdingaling/build/compile -/libdingaling/Makefile -/libdingaling/Makefile.in -/libdingaling/src/config.h -/libdingaling/src/stamp-h1 /libg722_1/config-h.in /libg722_1/doc/Makefile /libg722_1/doc/Makefile.in @@ -589,102 +551,6 @@ opal /tiff-*/tools/tiffmedian /tiff-*/tools/tiffset /tiff-*/tools/tiffsplit -/unimrcp/build/acmacros/libtool.m4 -/unimrcp/build/acmacros/lt~obsolete.m4 -/unimrcp/build/acmacros/ltoptions.m4 -/unimrcp/build/acmacros/ltsugar.m4 -/unimrcp/build/acmacros/ltversion.m4 -/unimrcp/build/Makefile -/unimrcp/build/Makefile.in -/unimrcp/build/pkgconfig/Makefile -/unimrcp/build/pkgconfig/Makefile.in -/unimrcp/build/svnrev/Makefile -/unimrcp/build/svnrev/Makefile.in -/unimrcp/build/svnrev/svnrev -!/unimrcp/build/tools/unimrcpservice.exe.manifest -!/unimrcp/build/uni_revision.h -!/unimrcp/configure.gnu -/unimrcp/conf/Makefile -/unimrcp/conf/Makefile.in -/unimrcp/data/Makefile -/unimrcp/data/Makefile.in -/unimrcp/docs/doxygen.conf -/unimrcp/libs/apr-toolkit/Makefile -/unimrcp/libs/apr-toolkit/Makefile.in -/unimrcp/libs/Makefile -/unimrcp/libs/Makefile.in -/unimrcp/libs/mpf/Makefile -/unimrcp/libs/mpf/Makefile.in -/unimrcp/libs/mrcp-client/Makefile -/unimrcp/libs/mrcp-client/Makefile.in -/unimrcp/libs/mrcp-engine/Makefile -/unimrcp/libs/mrcp-engine/Makefile.in -/unimrcp/libs/mrcp/Makefile -/unimrcp/libs/mrcp/Makefile.in -/unimrcp/libs/mrcp-server/Makefile -/unimrcp/libs/mrcp-server/Makefile.in -/unimrcp/libs/mrcp-signaling/Makefile -/unimrcp/libs/mrcp-signaling/Makefile.in -/unimrcp/libs/mrcpv2-transport/Makefile -/unimrcp/libs/mrcpv2-transport/Makefile.in -/unimrcp/libs/uni-rtsp/Makefile -/unimrcp/libs/uni-rtsp/Makefile.in -/unimrcp/Makefile -/unimrcp/Makefile.in -/unimrcp/modules/Makefile -/unimrcp/modules/Makefile.in -/unimrcp/modules/mrcp-sofiasip/Makefile -/unimrcp/modules/mrcp-sofiasip/Makefile.in -/unimrcp/modules/mrcp-unirtsp/Makefile -/unimrcp/modules/mrcp-unirtsp/Makefile.in -/unimrcp/platforms/asr-client/asrclient -/unimrcp/platforms/asr-client/Makefile -/unimrcp/platforms/asr-client/Makefile.in -/unimrcp/platforms/libasr-client/Makefile -/unimrcp/platforms/libasr-client/Makefile.in -/unimrcp/platforms/libunimrcp-client/Makefile -/unimrcp/platforms/libunimrcp-client/Makefile.in -/unimrcp/platforms/libunimrcp-server/Makefile -/unimrcp/platforms/libunimrcp-server/Makefile.in -/unimrcp/platforms/Makefile -/unimrcp/platforms/Makefile.in -/unimrcp/platforms/umc/Makefile -/unimrcp/platforms/umc/Makefile.in -/unimrcp/platforms/umc/umc -/unimrcp/platforms/unimrcp-client/Makefile -/unimrcp/platforms/unimrcp-client/Makefile.in -/unimrcp/platforms/unimrcp-client/unimrcpclient -/unimrcp/platforms/unimrcp-server/Makefile -/unimrcp/platforms/unimrcp-server/Makefile.in -/unimrcp/platforms/unimrcp-server/unimrcpserver -/unimrcp/plugins/demo-recog/Makefile -/unimrcp/plugins/demo-recog/Makefile.in -/unimrcp/plugins/demo-synth/Makefile -/unimrcp/plugins/demo-synth/Makefile.in -/unimrcp/plugins/demo-verifier/Makefile -/unimrcp/plugins/demo-verifier/Makefile.in -/unimrcp/plugins/Makefile -/unimrcp/plugins/Makefile.in -/unimrcp/plugins/mrcp-cepstral/Makefile -/unimrcp/plugins/mrcp-cepstral/Makefile.in -/unimrcp/plugins/mrcp-flite/Makefile -/unimrcp/plugins/mrcp-flite/Makefile.in -/unimrcp/plugins/mrcp-pocketsphinx/Makefile -/unimrcp/plugins/mrcp-pocketsphinx/Makefile.in -/unimrcp/plugins/mrcp-recorder/Makefile -/unimrcp/plugins/mrcp-recorder/Makefile.in -/unimrcp/tests/apttest/Makefile -/unimrcp/tests/apttest/Makefile.in -/unimrcp/tests/Makefile -/unimrcp/tests/Makefile.in -/unimrcp/tests/mpftest/Makefile -/unimrcp/tests/mpftest/Makefile.in -/unimrcp/tests/mrcptest/Makefile -/unimrcp/tests/mrcptest/Makefile.in -/unimrcp/tests/rtsptest/Makefile -/unimrcp/tests/rtsptest/Makefile.in -/unimrcp/tests/strtablegen/Makefile -/unimrcp/tests/strtablegen/Makefile.in /win32/celt/*/*/libcelt.log /win32/libg722_1/*/*/libg722_1.log /win32/libshout/*/*/libshout.log @@ -734,17 +600,7 @@ opal /v8-*.zip # build products we should remove -!/apr-util/xml/expat/conftools/config.guess -!/apr-util/xml/expat/conftools/config.sub -!/apr-util/xml/expat/conftools/install-sh -!/apr-util/xml/expat/conftools/missing !/iksemel/ltmain.sh -!/libdingaling/config.guess -!/libdingaling/config.sub -!/libdingaling/depcomp -!/libdingaling/install-sh -!/libdingaling/ltmain.sh -!/libdingaling/missing !/libg722_1/config/depcomp !/libg722_1/config/missing !/tiff-*/config/depcomp @@ -756,25 +612,21 @@ ilbc/config/compile libg722_1/config/compile pcre/compile srtp/build/compile -unimrcp/build/compile /pcre-*/ /speex-*/ /curl-*/ /sqlite-*.zip /sqlite-*/ +/sqlite/ /ldns/ /portaudio/ portaudio.*.log -apr-util/configure -apr-util/xml/expat/configure apr/configure iksemel/configure -libdingaling/configure libyuv/Makefile libyuv/convert srtp/configure tiff-4.0.2/configure -unimrcp/configure zlib-*/ zlib-* libpq-*/ @@ -799,4 +651,5 @@ mariadb-connector-c-*/ mariadb-connector-c-* /spandsp*/ /spandsp* -win32/spandsp/spandsp.h \ No newline at end of file +win32/spandsp/spandsp.h +win32/spandsp/win32 diff --git a/libs/apr-util/.update b/libs/apr-util/.update deleted file mode 100644 index a573c80504..0000000000 --- a/libs/apr-util/.update +++ /dev/null @@ -1 +0,0 @@ -Thu 18 Nov 2010 20:56:38 EST diff --git a/libs/apr-util/CHANGES b/libs/apr-util/CHANGES deleted file mode 100644 index dbbe4ae567..0000000000 --- a/libs/apr-util/CHANGES +++ /dev/null @@ -1,619 +0,0 @@ -Changes with APR-util 1.2.8 - - *) Add support for Berkeley DB 4.5 to the configure scripts. - [Garrett Rooney] - - *) Allow apr_queue.h to be included before other APR headers. - PR 40891 [Henry Jen ] - - *) Provide folding in autogenerated .manifest files for Win32 builders - using VisualStudio 2005 [William Rowe] - - *) Implement prepared statement support in SQLite3 DBD driver - [Bojan Smojver] - - *) Fix to ensure that "deprecated" LDAP interfaces are still - exposed if using OpenLDAP 2.3. [Joe Orton] - - *) Fix incorrect byte order and incorrect timestamp type - in the fallback UUID generator used when no external UUID - generator is detected by APR. PR 37342. [Max Bowsher] - -Changes with APR-util 1.2.7 - - *) Fix apr_dbd_init to be safe to call multiple times - [Bojan Smojver , Nick Kew] - - *) Win32 / Netware - add missing apu_version.c for apu_version_string() - to the Windows and Netware specific builds. Unix platforms supported - this API since 0.9.1. [William Rowe, Brad Nicholes]. - -Changes with APR-util 1.2.6 - - *) Stop trying to link against Berkeley DB by default. To enable use - of Berkeley DB users must now explicitly pass --with-berkeley-db to - configure, since Berkeley DB is released under a viral license that - requires distribution of source code for any program that uses it. - [Garrett Rooney] - - *) Stop trying to link against GDBM by default. To enable use of GDBM - users must now explicitly pass --with-gdbm to configure, since GDBM - is licensed under the GPL. - [Garrett Rooney] - - *) Fix VPATH builds, and symlink builds where apr and apr-util - reside in parallel as symlinks to directories with more explicit - names, e.g. apr-1.x and apr-util-1.x. This solves various breakage - on Solaris in particular with ./buildconf and ./configure. Also - eliminated the nested ../apr-iconv/buildconf, given that apr-util - didn't bother with ../apr/buildconf, and this was inconsistant. - [William Rowe] - - *) Fix the escape implementations for the sqlite2 and sqlite3 dbd - back ends. - [Ronen Mizrahi , Garrett Rooney] - - *) Add support for Berkeley DB 4.4 to the configure scripts. - [Garrett Rooney] - - *) Fix bug in test suite that cause testbuckets to write 8GB file - on Mac OS X. [Justin Erenkrantz] - -Changes with APR-util 1.2.2 - - *) Teach configure how to find the Novell LDAP SDK. [Graham Leggett] - - *) Fix usage of ldapssl_init/ldap_sslinit on platforms that support - these API's including Win32. Support APR_HAS_LDAP_START_TLS_S - flag in the Win32 LDAP API, to drop usage of ldap_start_ssl_s - and ldap_stop_ssl_s on Win32 by default (change the flag in apr_ldap.hw - to enable if supported on a given OS level). [William Rowe] - -Changes with APR-util 1.2.1 - - *) Fix apr_rmm_realloc() offset calculation bug. [Keith Kelleman - ] - - *) Add sqlite3 support to APR DBD. [Rick Keiner ] - - *) Fix build failure with non-threaded APR on AIX. PR 34655. - [Ryan Murray ] - - *) Add sqlite2 support to APR DBD. [Ryan Phillips ] - - *) Introduction of APR DBD layer. [Nick Kew] - -Changes with APR-util 1.1.2 - - *) Fix libaprutil.rc for Win32 builds [William Rowe, Justin Erenkrantz] - -Changes with APR-util 1.1.1 - - *) Fix memory leak in buckets when using APR_POOL_DEBUG mode. [Joe Schaefer] - - *) find_apu.m4: Try installed APR-util before bundled copy if --with-apr-util - not passed to configure. [Justin Erenkrantz] - -Changes with APR-util 1.1.0 - - *) LDAP: Move all certificate initialisation, and the creation of SSL - and TLS connections into the apr_ldap_set_option() API. Add support - for client certificates. [Graham Leggett] - - *) Emit the run-time link path option in apu-config after installation - if the user is linking with libtool. [Justin Erenkrantz] - - *) Port testmd4 and testmd5 to the new test suite. [Thom May] - - *) Allow passing NULL inbuf/inbytes_left parameters to - apr_xlate_conv_buffer(), required to correctly terminate the - output buffer for some stateful character set encodings. - [Joe Orton] - - *) Link libaprutil against the libraries on which it depends. - PR 11122. [Joe Orton] - - *) Add apr_brigade_insert_file() function, to safely insert a file - into a brigade, regardless of size. [Joe Orton] - -Changes with APR-util 1.0.2 - - *) Teach apr_ldap_init() how to handle STARTTLS in addition to the existing - SSL support. Add apr_ldap_option API. [Graham Leggett] - - *) Rework the LDAP toolkit detection to be more accurate than "OpenLDAP - detected regardless", while remaining backwards compatible with v1.0. - [Graham Leggett] - - *) Added the apr_ldap_ssl_add_cert() API to allow multiple certificates - to be stored and used when establishing an SSL connection to different - LDAP servers. [Brad Nicholes] - - *) Fix the detection of ldap.h on Solaris - it needs lber.h to be - defined first. [Graham Leggett] - - *) Add a build script to create a solaris package. [Graham Leggett] - -Changes with APR-util 1.0.1 - - *) Add support for Berkeley DB 4.3. [Jani Averbach ] - - *) SECURITY: CAN-2004-0786 (cve.mitre.org) - Fix input validation in apr_uri_parse() to avoid passing negative - length to memcpy for malformed IPv6 literal addresses. - [Joe Orton] - -Changes with APR-util 1.0 - - *) Only install apu-$MAJOR-config and add appropriate detection code to - find_apu.m4 (APU_FIND_APU). [Max Bowsher ] - - *) Overhaul support for LDAP URL parsing. Instead of using incompatible - URL parsers and memory that needs freeing, apr-util provides a parser - which parses the URL and allocates memory from a pool. [Graham Leggett] - - *) Remove support for LDAP v2.0 SDK toolkits. This will be added - back properly later assuming there is demand for it. In the mean - time, please use an LDAP v3.0 SDK toolkit. [Graham Leggett] - - *) Add an apr_ldap_err_t structure to handle the return of LDAP - specific error codes. [Graham Leggett, Brad Nicholes] - - *) Add APR functions to do the job of ldap_init(), hiding toolkit - specific SSL/TLS handling. Code derived from httpd util_ldap. - [Graham Leggett] - - *) Add an RPM spec file derived from Fedora Core. - [Graham Leggett, Joe Orton] - - *) The whole codebase was relicensed and is now available under - the Apache License, Version 2.0 (http://www.apache.org/licenses). - [Apache Software Foundation] - - *) A new function, apr_reslist_invalidate, was added so that invalid - resources can be removed from a reslist instead of being returned - to the reslist in a broken state. [Nick Kew ] - - *) Switch to a single, top-level make. [Greg Stein] - - *) Add timeout feature to apr_reslist_acquire(). - [Mladen Turk ] - - *) Pass error codes returned from constructors all the way back to - the reslist consumer. Also fix a minor reslist memory leak that could - happen when a constructor returns an error code. PR 23492. - [Snke Tesch , Aaron Bannert] - - *) The following header files have been removed: - - apu_compat.h - -Changes with APR-util 0.9.5 - - *) Fix corrupt output from the apr_xlate_* interfaces on AIX 4.x. - [Joe Orton] - - *) Change the order in which ldap.h and lber.h are defined, to fix - a compile bug in Solaris v2.8 which requires lber.h then ldap.h. - PR 27379. [Andrew Connors ] - - *) Restore support for SHA1 passwords in apr_validate_password. - PR 17343. [Paul Querna ] - - *) Fix DESTDIR install for bundled expat library. PR 14076 - [David S. Madole ] - - *) Fix occasional crash in apr_rmm_realloc(). PR 22915. - [Jay Shrauner ] - - *) Fix apr_dbm_exists() for sdbm when sizeof(int) != sizeof(size_t). - [Joe Orton] - - *) The whole codebase was relicensed and is now available under - the Apache License, Version 2.0 (http://www.apache.org/licenses). - [Apache Software Foundation] - - *) Fix xlate.c compile failure on AIX 5.2. PR 25701. [Jeff Trawick] - - *) Fixed a bug in apr_rmm that would cause it to mishandle blocks of - a size close to the one requested from the allocator. - [Kevin Wang ] - -Changes with APR-util 0.9.4 - - *) Changed apr_bucket_alloc_create() so that it uses the allocator - from the pool that was passed in rather than creating its own. - Also, the bucket_allocator is now allocated from the apr_allocator_t - rather than using apr_palloc(). Added apr_bucket_alloc_create_ex() - which takes an apr_allocator_t* directly rather than an apr_pool_t*. - [Cliff Woolley, Jean-Jacques Clar] - - *) Added debugging consistency checks to the buckets code. Add - -DAPR_BUCKET_DEBUG to the build flags to enable. - [Cliff Woolley] - - *) Make the version of the db library APU built against visible. - [Thom May] - - *) Fix a problem with VPATH builds copying the APR rules.mk into the - source directory rather than the build directory. [Justin Erenkrantz] - - *) SECURITY [httpd incident CAN-2003-0189] Address a thread safety - issue with apr_password_validate() on AIX, Linux, Mac OS X, and - possibly other platforms. [Jeff Trawick, Justin Erenkrantz] - - *) Fix a problem with LDAP configuration which caused subsequent - configure tests to fail since LIBS contained LDAP libraries for - subsequent tests but LDFLAGS no longer included the path to such - LDAP libraries. [Jeff Trawick] - - *) Fix a problem preventing the use of the bundled Expat when APR-util - is built stand-alone. [Jeff Trawick] - - *) Use the same compiler and preprocessor for the APR-util config tests - which were used by APR. The user can override this via CC and CPP. - This was done all along for the actual build, but not necessarily - for the config tests. [Jeff Trawick] - - *) Fix apr_uuid_parse() on EBCDIC machines. [Jeff Trawick] - - *) Fix alignment problem when allocating memory using apr_rmm. The problem - showed up while trying to write a double in the memory allocated. - [Madhusudan Mathihalli] - -Changes with APR-util 0.9.3 - - *) Allow apr_date_parse_rfc to parse 'Sun, 06-Nov-1994 08:49:37 GMT' as a - valid date. [Dmitri Tikhonov ] - - *) Fix error in apu-config when symlinks are involved. - [Garrett Rooney ] - -Changes with APR-util 0.9.2 - - *) Fix the APR_BUCKET_IS_foo() macros so they parenthesize their parameter. - This fixes compile problems with some types of parameters. - [Jim Carlson ] - - *) Queue overwrite, we now return the item pushed, not a reference to it. - [Paul Marquis ] - - *) Remove include/apr_ldap.h on distclean. PR 15592. [Justin Erenkrantz] - - *) Fix race conditions in apr_queue. - [Jacob Lewallen ] - - *) Stop buildconf copying rules.mk, copy it at configure time. - [Thom May] - - *) Make buildconf copy rules.mk as well. - [Garrett Rooney ] - - *) Add --includedir flag to apu-config. [Justin Erenkrantz] - - *) Fix brokenness in sdbm when sizeof(int) != sizeof(size_t) - (e.g., 64-bit AIX, 64-bit Solaris). PR 14861. [Jeff Trawick] - - *) Have buildconf copy required files from apr so that apr-util can build - on its own. [Craig Rodrigues ] - - *) Detect OpenLDAP when used with Solaris 9. PR 13427. - [Gary Algier ] - - *) Detect Berkeley DB 4.1 when compiled with --with-uniquenames - [Thom May] - - *) Allow apu-config to work in symlinked install directories when - 'realpath' is available. [Justin Erenkrantz] - - *) Fix bug in apr_strmatch when used with case-insensitive patterns. - [Justin Erenkrantz] - - *) Allow apr_queue to have greater than int number of elements. - [Justin Erenkrantz] - - *) Detect Berkeley DB 4.0 compiled with --with-uniquenames. - [Philip Martin ] - - *) Allocate brigades from a bucket allocator rather than a pool. [Brian Pane] - - *) Update with the latest APR renames [Thom May] - - *) Update doxygen tags. [Justin Erenkrantz] - - *) Add apr_ldap.hw for Windows build. - [Andre Schild ] - - *) Add IPv6 literal address support to apr_uri_parse(), apr_uri_unparse(), - and apr_uri_parse_hostinfo(). PR 11887 [Jeff Trawick] - - *) Add apr_brigade_writev() [Brian Pane] - - *) Add support for Berkeley DB 4.1. [Justin Erenkrantz] - - *) Add --bindir option to apu-config. [Justin Erenkrantz] - -Changes with APR-util 0.9.1 - - *) Add versioning infrastructure. - [Justin Erenkrantz] - - *) Running "make check" in the toplevel directory or the test/ directory - will build and run all test programs. [Aaron Bannert] - - *) Bug #9789 : NDBM support - [Toomas Soome , Ian Holsman] - - *) Added a Thread safe FIFO bounded buffer (apr_queue) [Ian Holsman] - - *) Changed file_bucket_setaside() to use apr_file_setaside() instead - of turning the file bucket into an mmap bucket. [Brian Pane] - - *) Install libaprutil support libraries before installing libaprutil - itself, since on some platforms libaprutil is relinked during - make install and the support libraries need to exist already. - [Jeff Trawick] - - *) Added a Resource List API for threadsafe access to persistent - and dynamically created user-defined resources. [Aaron Bannert] - - *) Adopted apr-util/xlate from apr/i18n for inclusion of apr-iconv - as required by missing libiconv. [William Rowe] - - *) Adopted apr-util/crypto/ uuid and md5 from apr. [William Rowe] - - *) Look for expat in lib64 directories. [Peter Poeml ] - - *) Faster implementation of apr_brigade_puts() [Brian Pane] - - *) Fixed a segfault in apr_date_parse_rfc() for some date formats - where it was trying to overlay a potentially static input - string even though it didn't really need to. - [Cliff Woolley, Doug MacEachern] - - *) Ensure that apu-config does not print libtool libraries when - using --libs. [Justin Erenkrantz] - - *) Added apr_bucket_file_enable_mmap() function to the bucket - API to let an application control whether a file bucket may - be turned into an mmap bucket upon read. (The default remains - to do the mmap, but this function lets the app prevent the - mmap in contexts where mmap would be a bad idea. Examples - include multiprocessors where mmap doesn't scale well and - NFS-mounted filesystems where a bus error can result if - a memory-mapped file is removed or truncated.) [Brian Pane] - - *) Added string-matching API (apr_strmatch.h) [Brian Pane] - - *) Rearrange INCLUDES so that APRUTIL_PRIV_INCLUDES is always - first. [Garrett Rooney ] - - *) Add --old-expat option to apu-config to allow users of apr-util to - determine what expat it should expect to be installed. If the - flag is set to yes, it should include xmlparse.h. If it is set to - no, it should include expat.h. [Justin Erenkrantz] - - *) Fix exporting of includes in apu-config. [Justin Erenkrantz] - - *) Change bucket brigades API to allow a "bucket allocator" to be - passed in at certain points. This allows us to implement freelists - so that we can stop using malloc/free so frequently. - [Cliff Woolley, Brian Pane] - - *) add apr_rmm_realloc() function - [Madhusudan Mathihalli ] - - *) renames: apr_ansi_time_to_apr_time becomes apr_time_ansi_put - ap_exploded_time_t becomes apr_time_exp_t - [Thom May ] - - *) Add detection support for FreeBSD's expat and expat2 ports. - [Justin Erenkrantz] - - *) Deprecate check_brigade_flush(), which had several nasty bugs, and - which was causing apr_brigade_write()'s logic to be less than obvious. - Everything is now done in a slightly rearranged apr_brigade_write(). - [Cliff Woolley] - - *) Don't add /usr/include to the INCLUDES variable on expat's account. - [Joe Orton ] - - *) Remove the autoconf 2.5x cache directory in buildconf. - [Joe Orton ] - - *) BerkleyDB should NULL out the key if it is @EOF in vt_db_nextkey - [Ian Holsman] - - *) Add ability to natively fetch and split brigades based on LF lines. - [Justin Erenkrantz] - - *) add --with-berkeley-db=DIR & --with-gdbm configure flags - [Ian Holsman/Justin Erenkrantz] - - *) Fix expat detection to recognize installed versions. - [Eric Gillespie, Jr. ] - - *) Add find_apu.m4 to allow third-party programs that use APR-util - to have a standard m4 macro for detection. [Justin Erenkrantz] - - *) Add apu-config - a shell script to allow third-party programs - easy access to APR configuration parameters. [Justin Erenkrantz] - - *) Add GMT offset calculation to apr_date_parse_rfc(). - [Justin Erenkrantz] - - *) Introduce the apr_rmm api, to allow relocatable memory management - of address-independent data stores, such as shared memory. - [William Rowe] - - *) Rework and fix VPATH-build support. [Justin Erenkrantz] - - *) Add support for Berkeley DB4. [Justin Erenkrantz] - - *) Improve testdbm help. [Justin Erenkrantz] - - *) Improve autoconf detection of DBMs. [Justin Erenkrantz] - - *) BerkeleyDBM v2 now checks minor level for cursor ops [Ian Holsman] - - *) Reading a file bucket bigger than APR_MMAP_LIMIT (4MB) now yields - a string of 4MB mmap buckets, rather than a string of 8KB heap buckets - plus a 4MB mmap bucket. To accomodate this, the mmap bucket destroy - function explicitly deletes the apr_mmap_t after last reference - to avoid having too much of a large file mapped at once if possible. - [Cliff Woolley] - - *) Multi-DBM support (via apr_dbm_open_ex). [Ian Holsman] - - *) Use apr_mmap_dup in mmap_setaside(). [Brian Pane ] - - *) Dropped the "w" parameter from apr_bucket_heap_create() and - apr_bucket_heap_make(). That parameter was originally intended - to return the amount of data copied into the bucket, but it - ended up being unnecessary because that amount is invariant from - the size of the data and is available as b->length in the - resulting bucket anyway. [Cliff Woolley] - - *) Fix Makefile conversion for BSD/OS. [Cliff Woolley] - - *) Use APR_XtOffsetOf instead of offsetof() in the ring macros for - portability. [Cliff Woolley] - - *) We now create exports.c and export_vars.h, which in turn create - exports.c. From this we generate two more files with different - purposes: aprutil.exp - list of exported symbols; and exports.lo - (exports.o) - an object file that can be linked with an executable - to force resolution of all apr-util symbols. [Aaron Bannert] - - *) Fix Berkley DBM support [Ian Holsman ] - - *) Fix apr_brigade_vprintf so that it can handle more than - 4k of data at one time. [Cody Sherr ] - - *) prefix UNP_* flags with APR_URI_ - - rename: - apr_uri_components -> apr_uri_t - apr_uri_unparse_components -> apr_uri_unparse - apr_uri_parse_components -> apr_uri_parse - apr_uri_parse_hostinfo_components -> apr_uri_parse_hostinfo - - s/APU_URI_/APR_URI_/g - [Perl] - - *) Landed the link-to-LDAP to the build process, and the LDAP v2/v3 - compatibility functions. - [Dave Carrigan , Graham Leggett] - - *) Fix URI unparse function to handle the case where it would place a @ - when both the username and password were present but omitted. - [Jon Travis ] - - *) Extend apr_bucket struct to add a pointer to a function used - to free the bucket. This change enables custom buckets to - completely specify how they are to be allocated and freed. - Before this change, custom buckets were required to use the - same memory allocation scheme as the standard APR buckets. - [Saeid Sakhitab, Bill Stoddard, Cliff Woolley, Roy Fielding] - - *) Install Expat when installing APR-util. [Justin Erenkrantz] - - *) Make APR-util configure script rely on APR. This removes the locally - generated copy of libtool and uses the one in APR. Fix up how we - call the expat configure script. Generate config.nice file. - [Justin Erenkrantz] - - *) The apr_bucket lengths are now consistently apr_size_t, while any - apr_brigade lengths (short of a read) are consistently apr_off_t. - This is required for APR_HAS_LARGE_FILES handling. [William Rowe] - - *) apr_bucket_file_create() and apr_bucket_file_make() now take a pool - parameter which is the pool into which any needed data structures - should be created during file_read(). This is used for MMAPing the - file and reopening the file if the original apr_file_t is in XTHREAD - mode. [Cliff Woolley] - - *) apr_brigade_partition() now returns an apr_status_t. [Cliff Woolley] - - *) Add MD4 implementation in crypto. [Sander Striker, Justin Erenkrantz] - - *) Moved httpd 2.0.18's util_date to apr_date and enhanced its parsing - capabilities. [Justin Erenkrantz] - - *) Moved httpd 2.0.18's util_uri to apr_uri and name-protected its - symbols and functions. [Justin Erenkrantz, Roy Fielding] - - *) Rename field "private" in struct apr_xml_elem to "priv" for C++ - compatibility. PR #7727 [Joshua MacDonald ] - - *) Make APR_IMPLEMENT_EXTERNAL_HOOK_BASE generate a - ${namespace}_hook_get_${hookname} function to fetch the - list of registered hooks [Doug MacEachern] - - *) Allow LTFLAGS to be overridden by the configure command-line - (default="--silent") and introduce LT_LDFLAGS. [Roy Fielding] - - *) Add APR_SHARELOCK support to apr_sdbm_open(), locking read operations - with a shared lock and all write ops with an excl lock. [Will Rowe] - - *) Namespace protect apr_sdbm, and normalize the return values (including - the apr_sdbm_fetch, apr_sdbm_firstkey and apr_sdbm_nextkey functions). - Normalized the get/clear error function names, and stores the actual - apr error for apr_sdbm_error_get. [Will Rowe] - - *) Introduce an apr_fileperms_t argument to apr_dbm_open(). [Will Rowe] - - *) Removed apr_bucket_do_create() macro, which was causing warnings - about unreachable code in some compilers (notably MSVC). What - used to be done by this macro is now done inline in the various - apr_bucket_foo_create() functions. [Cliff Woolley] - - *) Make clean, distclean, and extraclean consistently according to the - Gnu makefile guidelines. [Justin Erenkrantz ] - - *) Migrate the --disable-libtool changes from APR to APR-util. - This cleans things up, and allows more flexibility when building - programs. [Ryan Bloom] - - *) Allow APR-util to be compiled without libtool. The default is - to use libtool, but it can turned off with --disable-libtool - on the configure command. [Ryan Bloom] - - *) Repair calling convention for apr_register_optional_fn to - eliminate GP fault on Win32. [William Rowe] - - *) Substantial changes to correct linkage and declarations for - generic hooks on dso architectures. [Ben Laurie, Will Rowe] - - *) apr_bucket_shared_destroy() now returns a boolean value. - [Cliff Woolley] - - *) We have to initialize the heap buckets to the correct length. - we were seeing heap buckets with 17 chars in them reporting - a length of 9017, because they were initialized to the amount - of memory allocated, instead of the amount of memory used. - This was only an issue for heap buckets created by the - apr_brigade_* functions. [Ryan Bloom] - - *) apr_bucket_init_types() and apr_bucket_insert_type() have been - removed... they're not needed anymore. [Cliff Woolley] - - *) The apr_bucket_shared and apr_bucket_simple structures have been - removed as an API simplification/optimization. This should be - transparent outside APR-util except to callers who attempt to - directly manipulate the buckets' internal structure (which is - not recommended anyway) and to callers who create their own - bucket types. [Cliff Woolley] - - *) apr_bucket_simple_split() and apr_bucket_simple_copy() are now - exported functions, which could be helpful in implementing - external bucket types. [Cliff Woolley] - - *) The third parameter to apr_bucket_shared_make() is now - 'apr_off_t length' rather than 'apr_off_t end', since the - end usually had to be computed by the caller and all we - really want is the length anyway. [Cliff Woolley] - diff --git a/libs/apr-util/CMakeLists.txt b/libs/apr-util/CMakeLists.txt deleted file mode 100644 index 796f5e4b05..0000000000 --- a/libs/apr-util/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -cmake_minimum_required(VERSION 2.6) - -INCLUDE_DIRECTORIES(include/) - -add_definitions(-DHAVE_CONFIG_H -DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK) -INCLUDE_DIRECTORIES(BEFORE ${CMAKE_SOURCE_DIR}/libs/apr-util/include ${CMAKE_SOURCE_DIR}/libs/apr-util/include/private ${CMAKE_SOURCE_DIR}/libs/apr/include) - - -SET (apr-util_SRCS -crypto/apr_md5.c -crypto/uuid.c -crypto/apr_sha1.c -crypto/getuuid.c -crypto/apr_md4.c -encoding/apr_base64.c -hooks/apr_hooks.c -misc/apr_reslist.c -misc/apr_rmm.c -misc/apr_date.c -misc/apu_version.c -misc/apr_queue.c -uri/apr_uri.c -strmatch/apr_strmatch.c -xlate/xlate.c -) - -LINK_LIBRARIES ("-liconv -ldl -lpthread") - -ADD_LIBRARY(apr-util STATIC ${apr-util_SRCS}) - - - - - - - diff --git a/libs/apr-util/INSTALL.MySQL b/libs/apr-util/INSTALL.MySQL deleted file mode 100644 index 67718bf9d8..0000000000 --- a/libs/apr-util/INSTALL.MySQL +++ /dev/null @@ -1,14 +0,0 @@ -The MySQL driver is not distributed from apache.org due to licensing issues. - -If you wish to build the driver, download apr_dbd_mysql.c from -http://apache.webthing.com/database/ -and copy it into the dbd directory. -Now run buildconf, followed by configure. - -It is distributed under the GPL to conform with MySQL License terms -This means it cannot be distributed from apache.org, as that would -violate ASF policy. - -Using the driver with APR and Apache is of course allowed, -and there is no problem with a third party bundling the driver, -provided you respect both the ASF and GPL licenses. diff --git a/libs/apr-util/LICENSE b/libs/apr-util/LICENSE deleted file mode 100644 index 2813d26052..0000000000 --- a/libs/apr-util/LICENSE +++ /dev/null @@ -1,404 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - -APACHE PORTABLE RUNTIME SUBCOMPONENTS: - -The Apache Portable Runtime includes a number of subcomponents with -separate copyright notices and license terms. Your use of the source -code for the these subcomponents is subject to the terms and -conditions of the following licenses. - -For the include\apr_md5.h component: -/* - * This is work is derived from material Copyright RSA Data Security, Inc. - * - * The RSA copyright statement and Licence for that original material is - * included below. This is followed by the Apache copyright statement and - * licence for the modifications made to that material. - */ - -/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All - rights reserved. - - License to copy and use this software is granted provided that it - is identified as the "RSA Data Security, Inc. MD5 Message-Digest - Algorithm" in all material mentioning or referencing this software - or this function. - - License is also granted to make and use derivative works provided - that such works are identified as "derived from the RSA Data - Security, Inc. MD5 Message-Digest Algorithm" in all material - mentioning or referencing the derived work. - - RSA Data Security, Inc. makes no representations concerning either - the merchantability of this software or the suitability of this - software for any particular purpose. It is provided "as is" - without express or implied warranty of any kind. - - These notices must be retained in any copies of any part of this - documentation and/or software. - */ - -For the passwd\apr_md5.c component: - -/* - * This is work is derived from material Copyright RSA Data Security, Inc. - * - * The RSA copyright statement and Licence for that original material is - * included below. This is followed by the Apache copyright statement and - * licence for the modifications made to that material. - */ - -/* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm - */ - -/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All - rights reserved. - - License to copy and use this software is granted provided that it - is identified as the "RSA Data Security, Inc. MD5 Message-Digest - Algorithm" in all material mentioning or referencing this software - or this function. - - License is also granted to make and use derivative works provided - that such works are identified as "derived from the RSA Data - Security, Inc. MD5 Message-Digest Algorithm" in all material - mentioning or referencing the derived work. - - RSA Data Security, Inc. makes no representations concerning either - the merchantability of this software or the suitability of this - software for any particular purpose. It is provided "as is" - without express or implied warranty of any kind. - - These notices must be retained in any copies of any part of this - documentation and/or software. - */ -/* - * The apr_md5_encode() routine uses much code obtained from the FreeBSD 3.0 - * MD5 crypt() function, which is licenced as follows: - * ---------------------------------------------------------------------------- - * "THE BEER-WARE LICENSE" (Revision 42): - * wrote this file. As long as you retain this notice you - * can do whatever you want with this stuff. If we meet some day, and you think - * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp - * ---------------------------------------------------------------------------- - */ - -For the crypto\apr_md4.c component: - - * This is derived from material copyright RSA Data Security, Inc. - * Their notice is reproduced below in its entirety. - * - * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All - * rights reserved. - * - * License to copy and use this software is granted provided that it - * is identified as the "RSA Data Security, Inc. MD4 Message-Digest - * Algorithm" in all material mentioning or referencing this software - * or this function. - * - * License is also granted to make and use derivative works provided - * that such works are identified as "derived from the RSA Data - * Security, Inc. MD4 Message-Digest Algorithm" in all material - * mentioning or referencing the derived work. - * - * RSA Data Security, Inc. makes no representations concerning either - * the merchantability of this software or the suitability of this - * software for any particular purpose. It is provided "as is" - * without express or implied warranty of any kind. - * - * These notices must be retained in any copies of any part of this - * documentation and/or software. - */ - -For the include\apr_md4.h component: - - * - * This is derived from material copyright RSA Data Security, Inc. - * Their notice is reproduced below in its entirety. - * - * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All - * rights reserved. - * - * License to copy and use this software is granted provided that it - * is identified as the "RSA Data Security, Inc. MD4 Message-Digest - * Algorithm" in all material mentioning or referencing this software - * or this function. - * - * License is also granted to make and use derivative works provided - * that such works are identified as "derived from the RSA Data - * Security, Inc. MD4 Message-Digest Algorithm" in all material - * mentioning or referencing the derived work. - * - * RSA Data Security, Inc. makes no representations concerning either - * the merchantability of this software or the suitability of this - * software for any particular purpose. It is provided "as is" - * without express or implied warranty of any kind. - * - * These notices must be retained in any copies of any part of this - * documentation and/or software. - */ - -For the test\testmd4.c component: - - * - * This is derived from material copyright RSA Data Security, Inc. - * Their notice is reproduced below in its entirety. - * - * Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All - * rights reserved. - * - * RSA Data Security, Inc. makes no representations concerning either - * the merchantability of this software or the suitability of this - * software for any particular purpose. It is provided "as is" - * without express or implied warranty of any kind. - * - * These notices must be retained in any copies of any part of this - * documentation and/or software. - */ - -For the xml\expat\conftools\install-sh component: - -# -# install - install a program, script, or datafile -# This comes from X11R5 (mit/util/scripts/install.sh). -# -# Copyright 1991 by the Massachusetts Institute of Technology -# -# Permission to use, copy, modify, distribute, and sell this software and its -# documentation for any purpose is hereby granted without fee, provided that -# the above copyright notice appear in all copies and that both that -# copyright notice and this permission notice appear in supporting -# documentation, and that the name of M.I.T. not be used in advertising or -# publicity pertaining to distribution of the software without specific, -# written prior permission. M.I.T. makes no representations about the -# suitability of this software for any purpose. It is provided "as is" -# without express or implied warranty. -# - -For the expat xml parser component: - -Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd - and Clark Cooper - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -==================================================================== diff --git a/libs/apr-util/Makefile.in b/libs/apr-util/Makefile.in deleted file mode 100644 index c33574ed20..0000000000 --- a/libs/apr-util/Makefile.in +++ /dev/null @@ -1,91 +0,0 @@ -# -# Top-level Makefile for APRUTIL -# -CPP = @CPP@ - -# gets substituted into some targets -APRUTIL_MAJOR_VERSION=@APRUTIL_MAJOR_VERSION@ -APRUTIL_DOTTED_VERSION=@APRUTIL_DOTTED_VERSION@ - -srcdir = @srcdir@ -VPATH = @srcdir@ - -INCLUDES = @APRUTIL_PRIV_INCLUDES@ @APR_INCLUDES@ @APRUTIL_INCLUDES@ -APRUTIL_LDFLAGS = @APRUTIL_LDFLAGS@ -APRUTIL_LIBS = @APRUTIL_LIBS@ - -TARGET_LIB = lib@APRUTIL_LIBNAME@.la -INSTALL_SUBDIRS = @APR_ICONV_DIR@ @APR_XML_DIR@ -EXTRA_SOURCE_DIRS = @APR_ICONV_DIR@ @APR_XML_DIR@ -APRUTIL_PCFILE = apr-util-$(APRUTIL_MAJOR_VERSION).pc -APU_CONFIG = apu-$(APRUTIL_MAJOR_VERSION)-config -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ - -TARGETS = $(TARGET_LIB) aprutil.exp - -# bring in rules.mk for standard functionality -@INCLUDE_RULES@ -@INCLUDE_OUTPUTS@ - -CLEAN_SUBDIRS = test @APR_ICONV_DIR@ - -CLEAN_TARGETS = exports.c export_vars.c aprutil.exp .make.dirs apu-config.out -DISTCLEAN_TARGETS = config.cache config.log config.status libtool \ - include/private/apu_config.h include/private/apu_private.h \ - include/private/apu_select_dbm.h include/apr_ldap.h include/apu.h \ - export_vars.sh $(APU_CONFIG) build/rules.mk include/apu_want.h \ - apr-util.pc build/pkg/pkginfo -EXTRACLEAN_TARGETS = configure aclocal.m4 include/private/apu_config.h.in \ - exports.c build-outputs.mk \ - build/apr_common.m4 build/find_apr.m4 build/install.sh \ - build/config.guess build/config.sub - -prefix=@prefix@ -exec_prefix=@exec_prefix@ -bindir=@bindir@ -libdir=@libdir@ -includedir=@includedir@ -top_srcdir=@abs_srcdir@ -top_blddir=@abs_builddir@ - -# Create apu-config script suitable for the install tree -apu-config.out: $(APU_CONFIG) - sed 's,^\(location=\).*$$,\1installed,' < $(APU_CONFIG) > $@ - -install: $(TARGET_LIB) apu-config.out - $(APR_MKDIR) $(DESTDIR)$(includedir) $(DESTDIR)$(libdir)/pkgconfig \ - $(DESTDIR)$(libdir) $(DESTDIR)$(bindir) - for f in $(top_srcdir)/include/*.h $(top_blddir)/include/*.h; do \ - $(INSTALL_DATA) $${f} $(DESTDIR)$(includedir); \ - done - $(INSTALL_DATA) apr-util.pc $(DESTDIR)$(libdir)/pkgconfig/$(APRUTIL_PCFILE) - list='$(INSTALL_SUBDIRS)'; for i in $$list; do \ - ( cd $$i ; $(MAKE) DESTDIR=$(DESTDIR) install ); \ - done - $(LIBTOOL) --mode=install $(INSTALL) -m 755 $(TARGET_LIB) $(DESTDIR)$(libdir) - $(INSTALL_DATA) aprutil.exp $(DESTDIR)$(libdir) - $(INSTALL) -m 755 apu-config.out $(DESTDIR)$(bindir)/$(APU_CONFIG) - -$(TARGET_LIB): $(OBJECTS) - $(LINK) @lib_target@ $(ALL_LIBS) $(APRUTIL_LDFLAGS) $(APRUTIL_LIBS) - -exports.c: $(HEADERS) - $(APR_MKEXPORT) $(HEADERS) > $@ - -export_vars.c: $(HEADERS) - $(APR_MKVAREXPORT) $(HEADERS) > $@ - -aprutil.exp: exports.c export_vars.c - @echo "#! lib@APRUTIL_LIBNAME@.so" > $@ - @echo "* This file was AUTOGENERATED at build time." >> $@ - @echo "* Please do not edit by hand." >> $@ - $(CPP) $(ALL_CPPFLAGS) $(ALL_INCLUDES) exports.c | grep "ap_hack_" | sed -e 's/^.*[)]\(.*\);$$/\1/' >> $@ - $(CPP) $(ALL_CPPFLAGS) $(ALL_INCLUDES) export_vars.c | sed -e 's/^\#[^!]*//' | sed -e '/^$$/d' >> $@ - -dox: - doxygen $(top_srcdir)/docs/doxygen.conf - -test: check -check: $(TARGET_LIB) - cd test && $(MAKE) check diff --git a/libs/apr-util/NOTICE b/libs/apr-util/NOTICE deleted file mode 100644 index 9ccc9d7974..0000000000 --- a/libs/apr-util/NOTICE +++ /dev/null @@ -1,11 +0,0 @@ -This product includes software developed by -The Apache Software Foundation (http://www.apache.org/). - -Portions of this software were developed at the National Center -for Supercomputing Applications (NCSA) at the University of -Illinois at Urbana-Champaign. - -This software contains code derived from the RSA Data Security -Inc. MD5 Message-Digest Algorithm, including various -modifications by Spyglass Inc., Carnegie Mellon University, and -Bell Communications Research, Inc (Bellcore). diff --git a/libs/apr-util/NWGNUmakefile b/libs/apr-util/NWGNUmakefile deleted file mode 100644 index db72b27603..0000000000 --- a/libs/apr-util/NWGNUmakefile +++ /dev/null @@ -1,292 +0,0 @@ -# -# Declare the sub-directories to be built here -# - -SUBDIRS = \ - ldap \ - xml \ - $(EOLIST) - -# -# Get the 'head' of the build environment. This includes default targets and -# paths to tools -# - -include $(APR_WORK)\build\NWGNUhead.inc - -# -# Make sure all needed macro's are defined -# - -# -# These directories will be at the beginning of the include list, followed by -# INCDIRS -# -XINCDIRS += \ - $(APR)/include \ - $(APR)/include/arch/NetWare \ - $(APRUTIL)/include \ - $(APRUTIL)/uri \ - $(APRUTIL)/dbm/sdbm \ - $(APRUTIL)/include/private \ - $(APRUTIL)/xml/expat/lib \ - $(LDAPSDK)/inc \ - $(EOLIST) - -# -# These flags will come after CFLAGS -# -XCFLAGS += \ - $(EOLIST) - -# -# These defines will come after DEFINES -# -XDEFINES += \ - $(EOLIST) - -# -# These flags will be added to the link.opt file -# -XLFLAGS += \ - $(EOLIST) - -# -# These values will be appended to the correct variables based on the value of -# RELEASE -# -ifeq "$(RELEASE)" "debug" -XINCDIRS += \ - $(EOLIST) - -XCFLAGS += \ - $(EOLIST) - -XDEFINES += \ - $(EOLIST) - -XLFLAGS += \ - $(EOLIST) -endif - -ifeq "$(RELEASE)" "noopt" -XINCDIRS += \ - $(EOLIST) - -XCFLAGS += \ - $(EOLIST) - -XDEFINES += \ - $(EOLIST) - -XLFLAGS += \ - $(EOLIST) -endif - -ifeq "$(RELEASE)" "release" -XINCDIRS += \ - $(EOLIST) - -XCFLAGS += \ - $(EOLIST) - -XDEFINES += \ - $(EOLIST) - -XLFLAGS += \ - $(EOLIST) -endif - -# -# These are used by the link target if an NLM is being generated -# This is used by the link 'name' directive to name the nlm. If left blank -# TARGET_nlm (see below) will be used. -# -NLM_NAME = - -# -# This is used by the link '-desc ' directive. -# If left blank, NLM_NAME will be used. -# -NLM_DESCRIPTION = - -# -# This is used by the '-threadname' directive. If left blank, -# NLM_NAME Thread will be used. -# -NLM_THREAD_NAME = -# -# If this is specified, it will override VERSION value in -# $(APR_WORK)\build\NWGNUenvironment.inc -# -NLM_VERSION = - -# -# If this is specified, it will override the default of 64K -# -NLM_STACK_SIZE = - -# -# If this is specified it will be used by the link '-entry' directive -# -NLM_ENTRY_SYM = - -# -# If this is specified it will be used by the link '-exit' directive -# -NLM_EXIT_SYM = - -# -# If this is specified it will be used by the link '-check' directive -# -NLM_CHECK_SYM = - -# -# If this is specified it will be used by the link '-flags' directive -# -NLM_FLAGS = - -# -# If this is specified it will be linked in with the XDCData option in the def -# file instead of the default of $(APR)/misc/netware/apache.xdc. XDCData can -# be disabled by setting APACHE_UNIPROC in the environment -# -XDCDATA = - -# -# Declare all target files (you must add your files here) -# - -# -# If there is an NLM target, put it here -# -TARGET_nlm = \ - $(EOLIST) - -# -# If there is an LIB target, put it here -# -TARGET_lib = \ - $(OBJDIR)/aprutil.lib \ - $(EOLIST) - -# -# These are the OBJ files needed to create the NLM target above. -# Paths must all use the '/' character -# -FILES_nlm_objs = \ - $(EOLIST) - -# -# These are the LIB files needed to create the NLM target above. -# These will be added as a library command in the link.opt file. -# -FILES_nlm_libs = \ - $(EOLIST) - -# -# These are the modules that the above NLM target depends on to load. -# These will be added as a module command in the link.opt file. -# -FILES_nlm_modules = \ - $(EOLIST) - -# -# If the nlm has a msg file, put it's path here -# -FILE_nlm_msg = - -# -# If the nlm has a hlp file put it's path here -# -FILE_nlm_hlp = - -# -# If this is specified, it will override $(NWOS)\copyright.txt. -# -FILE_nlm_copyright = - -# -# Any additional imports go here -# -FILES_nlm_Ximports = \ - $(EOLIST) - -# -# Any symbols exported to here -# -FILES_nlm_exports = \ - $(EOLIST) - -# -# These are the OBJ files needed to create the LIB target above. -# Paths must all use the '/' character -# -FILES_lib_objs = \ - $(OBJDIR)/apr_base64.o \ - $(OBJDIR)/apr_brigade.o \ - $(OBJDIR)/apr_buckets.o \ - $(OBJDIR)/apr_buckets_alloc.o \ - $(OBJDIR)/apr_buckets_eos.o \ - $(OBJDIR)/apr_buckets_file.o \ - $(OBJDIR)/apr_buckets_flush.o \ - $(OBJDIR)/apr_buckets_heap.o \ - $(OBJDIR)/apr_buckets_mmap.o \ - $(OBJDIR)/apr_buckets_pipe.o \ - $(OBJDIR)/apr_buckets_pool.o \ - $(OBJDIR)/apr_buckets_refcount.o \ - $(OBJDIR)/apr_buckets_simple.o \ - $(OBJDIR)/apr_buckets_socket.o \ - $(OBJDIR)/apr_date.o \ - $(OBJDIR)/apr_dbm.o \ - $(OBJDIR)/apr_dbd.o \ - $(OBJDIR)/apr_dbd_pgsql.o \ - $(OBJDIR)/apr_dbm_berkeleydb.o \ - $(OBJDIR)/apr_dbm_sdbm.o \ - $(OBJDIR)/apr_hooks.o \ - $(OBJDIR)/apr_md4.o \ - $(OBJDIR)/apr_md5.o \ - $(OBJDIR)/apr_queue.o \ - $(OBJDIR)/apr_reslist.o \ - $(OBJDIR)/apr_rmm.o \ - $(OBJDIR)/apr_sha1.o \ - $(OBJDIR)/apu_version.o \ - $(OBJDIR)/getuuid.o \ - $(OBJDIR)/uuid.o \ - $(OBJDIR)/apr_strmatch.o \ - $(OBJDIR)/apr_uri.o \ - $(OBJDIR)/sdbm.o \ - $(OBJDIR)/sdbm_hash.o \ - $(OBJDIR)/sdbm_lock.o \ - $(OBJDIR)/sdbm_pair.o \ - $(OBJDIR)/xlate.o \ - $(EOLIST) - -# -# implement targets and dependancies (leave this section alone) -# - -libs :: $(OBJDIR) $(TARGET_lib) - -nlms :: libs $(TARGET_nlm) - -# -# Updated this target to create necessary directories and copy files to the -# correct place. (See $(APR_WORK)\build\NWGNUhead.inc for examples) -# -install :: nlms FORCE - -# -# Any specialized rules here -# - -vpath %.c buckets:crypto:dbd:dbm:dbm/sdbm:encoding:hooks:ldap:misc:strmatch:uri:xlate:xml - -# -# Include the 'tail' makefile that has targets that depend on variables defined -# in this makefile -# - -include $(APR_WORK)\build\NWGNUtail.inc - - diff --git a/libs/apr-util/apr-util.pc.in b/libs/apr-util/apr-util.pc.in deleted file mode 100644 index 9e3cda6a3c..0000000000 --- a/libs/apr-util/apr-util.pc.in +++ /dev/null @@ -1,13 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -APRUTIL_MAJOR_VERSION=@APRUTIL_MAJOR_VERSION@ -includedir=@includedir@ - -Name: APR Utils -Description: Companion library for APR -Version: @APRUTIL_DOTTED_VERSION@ -# assume that apr-util requires libapr of same major version -Requires: apr-@APRUTIL_MAJOR_VERSION@ -Libs: -L${libdir} -l@APRUTIL_LIBNAME@ @APRUTIL_EXPORT_LIBS@ -Cflags: -I${includedir} diff --git a/libs/apr-util/apr-util.spec b/libs/apr-util/apr-util.spec deleted file mode 100644 index f7f387f3bb..0000000000 --- a/libs/apr-util/apr-util.spec +++ /dev/null @@ -1,89 +0,0 @@ - -%define apuver 1 - -Summary: Apache Portable Runtime Utility library -Name: apr-util -Version: 1.2.8 -Release: 1 -License: Apache Software License -Group: System Environment/Libraries -URL: http://apr.apache.org/ -Source0: %{name}-%{version}.tar.gz -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot -BuildPrereq: autoconf, libtool, doxygen, apr-devel >= 0:{version}-{release} -BuildPrereq: openldap-devel, db4-devel, expat-devel -Conflicts: subversion < 0.20.1-2 - -%description -The mission of the Apache Portable Runtime (APR) is to provide a -free library of C data structures and routines. This library -contains additional utility interfaces for APR; including support -for XML, LDAP, database interfaces, URI parsing and more. - -%package devel -Group: Development/Libraries -Summary: APR utility library development kit -Requires: apr-util = %{version}-%{release}, apr-devel -Requires: openldap-devel, db4-devel, expat-devel -Conflicts: subversion-devel < 0.20.1-2 - -%description devel -This package provides the support files which can be used to -build applications using the APR utility library. The mission -of the Apache Portable Runtime (APR) is to provide a free -library of C data structures and routines. - -%prep -%setup -q - -%build -%configure --with-apr=%{_prefix} \ - --includedir=%{_includedir}/apr-%{apuver} \ - --with-ldap --without-gdbm -make %{?_smp_mflags} && make dox - -%check -# Run non-interactive tests -pushd test -make %{?_smp_mflags} testall CFLAGS=-fno-strict-aliasing -./testall -v || exit 1 -popd - -%install -rm -rf $RPM_BUILD_ROOT -make install DESTDIR=$RPM_BUILD_ROOT - -# Documentation -mv docs/dox/html html - -# Unpackaged files -rm -f $RPM_BUILD_ROOT%{_libdir}/aprutil.exp - -%clean -rm -rf $RPM_BUILD_ROOT - -%post -p /sbin/ldconfig - -%postun -p /sbin/ldconfig - -%files -%defattr(-,root,root,-) -%doc CHANGES LICENSE NOTICE -%{_libdir}/libaprutil-%{apuver}.so.* - -%files devel -%defattr(-,root,root,-) -%{_bindir}/apu-%{apuver}-config -%{_libdir}/libaprutil-%{apuver}.*a -%{_libdir}/libaprutil-%{apuver}.so -%{_libdir}/pkgconfig/apr-util-%{apuver}.pc -%{_includedir}/apr-%{apuver}/*.h -%doc --parents html - -%changelog -* Tue Jun 22 2004 Graham Leggett 1.0.0-1 -- update to support v1.0.0 of APR - -* Tue Jun 22 2004 Graham Leggett 1.0.0-1 -- derived from Fedora Core apr.spec - diff --git a/libs/apr-util/aprutil.dsp b/libs/apr-util/aprutil.dsp deleted file mode 100644 index efa1f8239d..0000000000 --- a/libs/apr-util/aprutil.dsp +++ /dev/null @@ -1,587 +0,0 @@ -# Microsoft Developer Studio Project File - Name="aprutil" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -CFG=aprutil - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "aprutil.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "aprutil.mak" CFG="aprutil - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "aprutil - Win32 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "aprutil - Win32 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "aprutil - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "LibR" -# PROP BASE Intermediate_Dir "LibR" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "LibR" -# PROP Intermediate_Dir "LibR" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c -# ADD CPP /nologo /MD /W3 /O2 /Oy- /Zi /I "./include" /I "../apr/include" /I "./include/private" /I "../apr-iconv/include" /I "./dbm/sdbm" /I "./xml/expat/lib" /D "NDEBUG" /D "APR_DECLARE_STATIC" /D "APU_DECLARE_STATIC" /D "API_DECLARE_STATIC" /D "APU_USE_SDBM" /D "XML_STATIC" /D "WIN32" /D "_WINDOWS" /Fd"LibR\aprutil_src" /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"LibR\aprutil-1.lib" - -!ELSEIF "$(CFG)" == "aprutil - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "LibD" -# PROP BASE Intermediate_Dir "LibD" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "LibD" -# PROP Intermediate_Dir "LibD" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MDd /W3 /EHsc /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /c -# ADD CPP /nologo /MDd /W3 /EHsc /Zi /Od /I "./include" /I "../apr/include" /I "./include/private" /I "../apr-iconv/include" /I "./dbm/sdbm" /I "./xml/expat/lib" /D "_DEBUG" /D "APR_DECLARE_STATIC" /D "APU_DECLARE_STATIC" /D "API_DECLARE_STATIC" /D "APU_USE_SDBM" /D "XML_STATIC" /D "WIN32" /D "_WINDOWS" /Fd"LibD\aprutil_src" /FD /c -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"LibD\aprutil-1.lib" - -!ENDIF - -# Begin Target - -# Name "aprutil - Win32 Release" -# Name "aprutil - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "" -# Begin Group "buckets" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\buckets\apr_brigade.c -# End Source File -# Begin Source File - -SOURCE=.\buckets\apr_buckets.c -# End Source File -# Begin Source File - -SOURCE=.\buckets\apr_buckets_alloc.c -# End Source File -# Begin Source File - -SOURCE=.\buckets\apr_buckets_eos.c -# End Source File -# Begin Source File - -SOURCE=.\buckets\apr_buckets_file.c -# End Source File -# Begin Source File - -SOURCE=.\buckets\apr_buckets_flush.c -# End Source File -# Begin Source File - -SOURCE=.\buckets\apr_buckets_heap.c -# End Source File -# Begin Source File - -SOURCE=.\buckets\apr_buckets_mmap.c -# End Source File -# Begin Source File - -SOURCE=.\buckets\apr_buckets_pipe.c -# End Source File -# Begin Source File - -SOURCE=.\buckets\apr_buckets_pool.c -# End Source File -# Begin Source File - -SOURCE=.\buckets\apr_buckets_refcount.c -# End Source File -# Begin Source File - -SOURCE=.\buckets\apr_buckets_simple.c -# End Source File -# Begin Source File - -SOURCE=.\buckets\apr_buckets_socket.c -# End Source File -# End Group -# Begin Group "crypto" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\crypto\apr_md4.c -# End Source File -# Begin Source File - -SOURCE=.\crypto\apr_md5.c -# End Source File -# Begin Source File - -SOURCE=.\crypto\apr_sha1.c -# End Source File -# Begin Source File - -SOURCE=.\crypto\getuuid.c -# End Source File -# Begin Source File - -SOURCE=.\crypto\uuid.c -# End Source File -# End Group -# Begin Group "dbd" -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\dbd\apr_dbd.c -# End Source File -# Begin Source File - -SOURCE=.\dbd\apr_dbd_pgsql.c -# End Source File -# Begin Source File - -SOURCE=.\dbd\apr_dbd_sqlite2.c -# End Source File -# Begin Source File - -SOURCE=.\dbd\apr_dbd_sqlite3.c -# End Source File -# End Group -# Begin Group "dbm" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\dbm\apr_dbm.c -# End Source File -# Begin Source File - -SOURCE=.\dbm\apr_dbm_berkeleydb.c -# End Source File -# Begin Source File - -SOURCE=.\dbm\apr_dbm_gdbm.c -# End Source File -# Begin Source File - -SOURCE=.\dbm\apr_dbm_sdbm.c -# End Source File -# End Group -# Begin Group "encoding" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\encoding\apr_base64.c -# End Source File -# End Group -# Begin Group "hooks" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\hooks\apr_hooks.c -# End Source File -# End Group -# Begin Group "ldap" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\ldap\apr_ldap_init.c -# End Source File -# Begin Source File - -SOURCE=.\ldap\apr_ldap_url.c -# End Source File -# Begin Source File - -SOURCE=.\ldap\apr_ldap_option.c -# End Source File -# End Group -# Begin Group "misc" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\misc\apr_date.c -# End Source File -# Begin Source File - -SOURCE=.\misc\apr_queue.c -# End Source File -# Begin Source File - -SOURCE=.\misc\apr_reslist.c -# End Source File -# Begin Source File - -SOURCE=.\misc\apr_rmm.c -# End Source File -# Begin Source File - -SOURCE=.\misc\apu_version.c -# End Source File -# End Group -# Begin Group "sdbm" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\dbm\sdbm\sdbm.c -# End Source File -# Begin Source File - -SOURCE=.\dbm\sdbm\sdbm_hash.c -# End Source File -# Begin Source File - -SOURCE=.\dbm\sdbm\sdbm_lock.c -# End Source File -# Begin Source File - -SOURCE=.\dbm\sdbm\sdbm_pair.c -# End Source File -# Begin Source File - -SOURCE=.\dbm\sdbm\sdbm_pair.h -# End Source File -# Begin Source File - -SOURCE=.\dbm\sdbm\sdbm_private.h -# End Source File -# Begin Source File - -SOURCE=.\dbm\sdbm\sdbm_tune.h -# End Source File -# End Group -# Begin Group "strmatch" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\strmatch\apr_strmatch.c -# End Source File -# End Group -# Begin Group "uri" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\uri\apr_uri.c -# End Source File -# End Group -# Begin Group "xlate" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\xlate\xlate.c -# End Source File -# End Group -# Begin Group "xml" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\xml\apr_xml.c -# End Source File -# End Group -# End Group -# Begin Group "Generated Files" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\include\apr_ldap.h.in -# End Source File -# Begin Source File - -SOURCE=.\include\apr_ldap.hnw -# End Source File -# Begin Source File - -SOURCE=.\include\apr_ldap.hw - -!IF "$(CFG)" == "aprutil - Win32 Release" - -# Begin Custom Build - Creating apr_ldap.h from apr_ldap.hw -InputPath=.\include\apr_ldap.hw - -".\include\apr_ldap.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\include\apr_ldap.hw > .\include\apr_ldap.h - -# End Custom Build - -!ELSEIF "$(CFG)" == "aprutil - Win32 Debug" - -# Begin Custom Build - Creating apr_ldap.h from apr_ldap.hw -InputPath=.\include\apr_ldap.hw - -".\include\apr_ldap.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\include\apr_ldap.hw > .\include\apr_ldap.h - -# End Custom Build - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\include\apu.h.in -# End Source File -# Begin Source File - -SOURCE=.\include\apu.hnw -# End Source File -# Begin Source File - -SOURCE=.\include\apu.hw - -!IF "$(CFG)" == "aprutil - Win32 Release" - -# Begin Custom Build - Creating apu.h from apu.hw -InputPath=.\include\apu.hw - -".\include\apu.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\include\apu.hw > .\include\apu.h - -# End Custom Build - -!ELSEIF "$(CFG)" == "aprutil - Win32 Debug" - -# Begin Custom Build - Creating apu.h from apu.hw -InputPath=.\include\apu.hw - -".\include\apu.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\include\apu.hw > .\include\apu.h - -# End Custom Build - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\include\private\apu_config.h.in -# End Source File -# Begin Source File - -SOURCE=.\include\private\apu_config.hw - -!IF "$(CFG)" == "aprutil - Win32 Release" - -# Begin Custom Build - Creating apu_config.h from apu_config.hw -InputPath=.\include\private\apu_config.hw - -".\include\private\apu_config.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\include\private\apu_config.hw > .\include\private\apu_config.h - -# End Custom Build - -!ELSEIF "$(CFG)" == "aprutil - Win32 Debug" - -# Begin Custom Build - Creating apu_config.h from apu_config.hw -InputPath=.\include\private\apu_config.hw - -".\include\private\apu_config.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\include\private\apu_config.hw > .\include\private\apu_config.h - -# End Custom Build - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\include\private\apu_select_dbm.h.in -# End Source File -# Begin Source File - -SOURCE=.\include\private\apu_select_dbm.hw - -!IF "$(CFG)" == "aprutil - Win32 Release" - -# Begin Custom Build - Creating apu_select_dbm.h from apu_select_dbm.hw -InputPath=.\include\private\apu_select_dbm.hw - -".\include\private\apu_select_dbm.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\include\private\apu_select_dbm.hw > .\include\private\apu_select_dbm.h - -# End Custom Build - -!ELSEIF "$(CFG)" == "aprutil - Win32 Debug" - -# Begin Custom Build - Creating apu_select_dbm.h from apu_select_dbm.hw -InputPath=.\include\private\apu_select_dbm.hw - -".\include\private\apu_select_dbm.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\include\private\apu_select_dbm.hw > .\include\private\apu_select_dbm.h - -# End Custom Build - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\include\apu_want.h.in -# End Source File -# Begin Source File - -SOURCE=.\include\apu_want.hnw -# End Source File -# Begin Source File - -SOURCE=.\include\apu_want.hw - -!IF "$(CFG)" == "aprutil - Win32 Release" - -# Begin Custom Build - Creating apu_want.h from apu_want.hw -InputPath=.\include\apu_want.hw - -".\include\apu_want.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\include\apu_want.hw > .\include\apu_want.h - -# End Custom Build - -!ELSEIF "$(CFG)" == "aprutil - Win32 Debug" - -# Begin Custom Build - Creating apu_want.h from apu_want.hw -InputPath=.\include\apu_want.hw - -".\include\apu_want.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\include\apu_want.hw > .\include\apu_want.h - -# End Custom Build - -!ENDIF - -# End Source File -# End Group -# Begin Group "Public Header Files" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\include\apr_anylock.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_base64.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_buckets.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_date.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_dbm.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_hooks.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_ldap_url.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_md4.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_md5.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_optional.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_optional_hooks.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_queue.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_reslist.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_rmm.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_sdbm.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_sha1.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_strmatch.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_uri.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_uuid.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_xlate.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_xml.h -# End Source File -# End Group -# End Target -# End Project diff --git a/libs/apr-util/aprutil.dsw b/libs/apr-util/aprutil.dsw deleted file mode 100644 index 75352c2974..0000000000 --- a/libs/apr-util/aprutil.dsw +++ /dev/null @@ -1,161 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "apr"="..\apr\apr.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "apriconv"="..\apr-iconv\apriconv.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name apr - End Project Dependency -}}} - -############################################################################### - -Project: "aprutil"=".\aprutil.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name apr - End Project Dependency - Begin Project Dependency - Project_Dep_Name xml - End Project Dependency - Begin Project Dependency - Project_Dep_Name apriconv - End Project Dependency -}}} - -############################################################################### - -Project: "libapr"="..\apr\libapr.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "libapriconv"="..\apr-iconv\libapriconv.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name libapr - End Project Dependency -}}} - -############################################################################### - -Project: "libapriconv_ccs_modules"="..\apr-iconv\ccs\libapriconv_ccs_modules.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name libapr - End Project Dependency - Begin Project Dependency - Project_Dep_Name libapriconv - End Project Dependency -}}} - -############################################################################### - -Project: "libapriconv_ces_modules"="..\apr-iconv\ces\libapriconv_ces_modules.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name libapr - End Project Dependency - Begin Project Dependency - Project_Dep_Name libapriconv - End Project Dependency -}}} - -############################################################################### - -Project: "libaprutil"=".\libaprutil.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name libapr - End Project Dependency - Begin Project Dependency - Project_Dep_Name xml - End Project Dependency - Begin Project Dependency - Project_Dep_Name libapriconv - End Project Dependency -}}} - -############################################################################### - -Project: "xml"=".\xml\expat\lib\xml.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/libs/apr-util/apu-config.in b/libs/apr-util/apu-config.in deleted file mode 100644 index b4d896e008..0000000000 --- a/libs/apr-util/apu-config.in +++ /dev/null @@ -1,207 +0,0 @@ -#!/bin/sh -# Copyright 2001-2005 The Apache Software Foundation or its licensors, as -# applicable. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# APR-util script designed to allow easy command line access to APR-util -# configuration parameters. - -APRUTIL_MAJOR_VERSION="@APRUTIL_MAJOR_VERSION@" -APRUTIL_DOTTED_VERSION="@APRUTIL_DOTTED_VERSION@" - -prefix="@prefix@" -exec_prefix="@exec_prefix@" -bindir="@bindir@" -libdir="@libdir@" -includedir="@includedir@" - -LIBS="@APRUTIL_EXPORT_LIBS@" -INCLUDES="@APRUTIL_INCLUDES@" -LDFLAGS="@APRUTIL_LDFLAGS@" - -APRUTIL_LIBNAME="@APRUTIL_LIBNAME@" - -APU_SOURCE_DIR="@abs_srcdir@" -APU_BUILD_DIR="@abs_builddir@" -APR_XML_EXPAT_OLD="@APR_XML_EXPAT_OLD@" -APU_DB_VERSION="@apu_db_version@" - -# NOTE: the following line is modified during 'make install': alter with care! -location=@APU_CONFIG_LOCATION@ - -show_usage() -{ - cat << EOF -Usage: apu-$APRUTIL_MAJOR_VERSION-config [OPTION] - -Known values for OPTION are: - --prefix[=DIR] change prefix to DIR - --bindir print location where binaries are installed - --includes print include information - --includedir print location where headers are installed - --ldflags print linker flags - --libs print library information - --srcdir print APR-util source directory - --link-ld print link switch(es) for linking to APR-util - --link-libtool print the libtool inputs for linking to APR-util - --apu-la-file print the path to the .la file, if available - --old-expat indicate if APR-util was built against an old expat - --db-version print the DB version - --version print APR-util's version as a dotted triple - --help print this help - -When linking with libtool, an application should do something like: - APU_LIBS="\`apu-$APRUTIL_MAJOR_VERSION-config --link-libtool --libs\`" -or when linking directly: - APU_LIBS="\`apu-$APRUTIL_MAJOR_VERSION-config --link-ld --libs\`" - -An application should use the results of --includes, and --ldflags in -their build process. -EOF -} - -if test $# -eq 0; then - show_usage - exit 1 -fi - -if test "$location" = "installed"; then - LA_FILE="$libdir/lib${APRUTIL_LIBNAME}.la" - - LIBS=`echo "$LIBS" | sed -e "s $APU_BUILD_DIR/xml/expat $prefix g" -e "s $prefix/lib/libexpat.la -lexpat g"` - LDFLAGS=`echo "$LDFLAGS" | sed -e "s $APU_BUILD_DIR/xml/expat $prefix g"` - INCLUDES=`echo "$INCLUDES" | sed -e "s $APU_BUILD_DIR/xml/expat $prefix g" -e "s -I$prefix/lib g"` -else - LA_FILE="$APU_BUILD_DIR/lib${APRUTIL_LIBNAME}.la" -fi - -flags="" - -while test $# -gt 0; do - # Normalize the prefix. - case "$1" in - -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; - *) optarg= ;; - esac - - case "$1" in - # It is possible for the user to override our prefix. - --prefix=*) - prefix=$optarg - ;; - --prefix) - echo $prefix - exit 0 - ;; - --bindir) - echo $bindir - exit 0 - ;; - --libs) - flags="$flags $LIBS" - ;; - --includedir) - if test "$location" = "installed"; then - flags="$includedir" - elif test "$location" = "source"; then - flags="$APU_SOURCE_DIR/include" - else - # this is for VPATH builds - flags="$APU_BUILD_DIR/include $APU_SOURCE_DIR/include" - fi - echo $flags - exit 0 - ;; - --includes) - if test "$location" = "installed"; then - flags="$flags -I$includedir $INCLUDES" - elif test "$location" = "source"; then - flags="$flags -I$APU_SOURCE_DIR/include $INCLUDES" - else - # this is for VPATH builds - flags="$flags -I$APU_BUILD_DIR/include -I$APU_SOURCE_DIR/include $INCLUDES" - fi - ;; - --ldflags) - flags="$flags $LDFLAGS" - ;; - --srcdir) - echo $APU_SOURCE_DIR - exit 0 - ;; - --version) - echo $APRUTIL_DOTTED_VERSION - exit 0 - ;; - --link-ld) - if test "$location" = "installed"; then - ### avoid using -L if libdir is a "standard" location like /usr/lib - flags="$flags -L$libdir -l$APRUTIL_LIBNAME" - else - flags="$flags -L$APU_BUILD_DIR -l$APRUTIL_LIBNAME" - fi - ;; - --link-libtool) - # If the LA_FILE exists where we think it should be, use it. If we're - # installed and the LA_FILE does not exist, assume to use -L/-l - # (the LA_FILE may not have been installed). If we're building ourselves, - # we'll assume that at some point the .la file be created. - if test -f "$LA_FILE"; then - flags="$flags $LA_FILE" - elif test "$location" = "installed"; then - ### avoid using -L if libdir is a "standard" location like /usr/lib - # Since the user is specifying they are linking with libtool, we - # *know* that -R will be recognized by libtool. - flags="$flags -L$libdir -R$libdir -l$APRUTIL_LIBNAME" - else - flags="$flags $LA_FILE" - fi - ;; - --apu-la-file) - if test -f "$LA_FILE"; then - flags="$flags $LA_FILE" - fi - ;; - --old-expat) - if test ! -n "$APR_XML_EXPAT_OLD"; then - echo "no" - else - echo "$APR_XML_EXPAT_OLD" - fi - exit 0 - ;; - --db-version) - echo $APU_DB_VERSION - exit 0 - ;; - --help) - show_usage - exit 0 - ;; - *) - show_usage - exit 1 - ;; - esac - - # Next please. - shift -done - -if test -n "$flags"; then - echo "$flags" -fi - -exit 0 diff --git a/libs/apr-util/buckets/apr_brigade.c b/libs/apr-util/buckets/apr_brigade.c deleted file mode 100644 index 69813f2963..0000000000 --- a/libs/apr-util/buckets/apr_brigade.c +++ /dev/null @@ -1,702 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_lib.h" -#include "apr_strings.h" -#include "apr_pools.h" -#include "apr_tables.h" -#include "apr_buckets.h" -#include "apr_errno.h" -#define APR_WANT_MEMFUNC -#define APR_WANT_STRFUNC -#include "apr_want.h" - -#if APR_HAVE_SYS_UIO_H -#include -#endif - -static apr_status_t brigade_cleanup(void *data) -{ - return apr_brigade_cleanup(data); -} - -APU_DECLARE(apr_status_t) apr_brigade_cleanup(void *data) -{ - apr_bucket_brigade *b = data; - apr_bucket *e; - - while (!APR_BRIGADE_EMPTY(b)) { - e = APR_BRIGADE_FIRST(b); - apr_bucket_delete(e); - } - /* We don't need to free(bb) because it's allocated from a pool. */ - return APR_SUCCESS; -} - -APU_DECLARE(apr_status_t) apr_brigade_destroy(apr_bucket_brigade *b) -{ - apr_pool_cleanup_kill(b->p, b, brigade_cleanup); - return apr_brigade_cleanup(b); -} - -APU_DECLARE(apr_bucket_brigade *) apr_brigade_create(apr_pool_t *p, - apr_bucket_alloc_t *list) -{ - apr_bucket_brigade *b; - - b = apr_palloc(p, sizeof(*b)); - b->p = p; - b->bucket_alloc = list; - - APR_RING_INIT(&b->list, apr_bucket, link); - - apr_pool_cleanup_register(b->p, b, brigade_cleanup, apr_pool_cleanup_null); - return b; -} - -APU_DECLARE(apr_bucket_brigade *) apr_brigade_split(apr_bucket_brigade *b, - apr_bucket *e) -{ - apr_bucket_brigade *a; - apr_bucket *f; - - a = apr_brigade_create(b->p, b->bucket_alloc); - /* Return an empty brigade if there is nothing left in - * the first brigade to split off - */ - if (e != APR_BRIGADE_SENTINEL(b)) { - f = APR_RING_LAST(&b->list); - APR_RING_UNSPLICE(e, f, link); - APR_RING_SPLICE_HEAD(&a->list, e, f, apr_bucket, link); - } - - APR_BRIGADE_CHECK_CONSISTENCY(a); - APR_BRIGADE_CHECK_CONSISTENCY(b); - - return a; -} - -APU_DECLARE(apr_status_t) apr_brigade_partition(apr_bucket_brigade *b, - apr_off_t point, - apr_bucket **after_point) -{ - apr_bucket *e; - const char *s; - apr_size_t len; - apr_status_t rv; - - if (point < 0) { - /* this could cause weird (not necessarily SEGV) things to happen */ - return APR_EINVAL; - } - if (point == 0) { - *after_point = APR_BRIGADE_FIRST(b); - return APR_SUCCESS; - } - - APR_BRIGADE_CHECK_CONSISTENCY(b); - - for (e = APR_BRIGADE_FIRST(b); - e != APR_BRIGADE_SENTINEL(b); - e = APR_BUCKET_NEXT(e)) - { - if ((e->length == (apr_size_t)(-1)) && (point > (apr_size_t)(-1))) { - /* point is too far out to simply split this bucket, - * we must fix this bucket's size and keep going... */ - rv = apr_bucket_read(e, &s, &len, APR_BLOCK_READ); - if (rv != APR_SUCCESS) { - *after_point = e; - return rv; - } - } - if ((point < e->length) || (e->length == (apr_size_t)(-1))) { - /* We already checked e->length -1 above, so we now - * trust e->length < MAX_APR_SIZE_T. - * First try to split the bucket natively... */ - if ((rv = apr_bucket_split(e, (apr_size_t)point)) - != APR_ENOTIMPL) { - *after_point = APR_BUCKET_NEXT(e); - return rv; - } - - /* if the bucket cannot be split, we must read from it, - * changing its type to one that can be split */ - rv = apr_bucket_read(e, &s, &len, APR_BLOCK_READ); - if (rv != APR_SUCCESS) { - *after_point = e; - return rv; - } - - /* this assumes that len == e->length, which is okay because e - * might have been morphed by the apr_bucket_read() above, but - * if it was, the length would have been adjusted appropriately */ - if (point < e->length) { - rv = apr_bucket_split(e, (apr_size_t)point); - *after_point = APR_BUCKET_NEXT(e); - return rv; - } - } - if (point == e->length) { - *after_point = APR_BUCKET_NEXT(e); - return APR_SUCCESS; - } - point -= e->length; - } - *after_point = APR_BRIGADE_SENTINEL(b); - return APR_INCOMPLETE; -} - -APU_DECLARE(apr_status_t) apr_brigade_length(apr_bucket_brigade *bb, - int read_all, apr_off_t *length) -{ - apr_off_t total = 0; - apr_bucket *bkt; - - for (bkt = APR_BRIGADE_FIRST(bb); - bkt != APR_BRIGADE_SENTINEL(bb); - bkt = APR_BUCKET_NEXT(bkt)) - { - if (bkt->length == (apr_size_t)(-1)) { - const char *ignore; - apr_size_t len; - apr_status_t status; - - if (!read_all) { - *length = -1; - return APR_SUCCESS; - } - - if ((status = apr_bucket_read(bkt, &ignore, &len, - APR_BLOCK_READ)) != APR_SUCCESS) { - return status; - } - } - - total += bkt->length; - } - - *length = total; - return APR_SUCCESS; -} - -APU_DECLARE(apr_status_t) apr_brigade_flatten(apr_bucket_brigade *bb, - char *c, apr_size_t *len) -{ - apr_size_t actual = 0; - apr_bucket *b; - - for (b = APR_BRIGADE_FIRST(bb); - b != APR_BRIGADE_SENTINEL(bb); - b = APR_BUCKET_NEXT(b)) - { - const char *str; - apr_size_t str_len; - apr_status_t status; - - status = apr_bucket_read(b, &str, &str_len, APR_BLOCK_READ); - if (status != APR_SUCCESS) { - return status; - } - - /* If we would overflow. */ - if (str_len + actual > *len) { - str_len = *len - actual; - } - - /* XXX: It appears that overflow of the final bucket - * is DISCARDED without any warning to the caller. - * - * No, we only copy the data up to their requested size. -- jre - */ - memcpy(c, str, str_len); - - c += str_len; - actual += str_len; - - /* This could probably be actual == *len, but be safe from stray - * photons. */ - if (actual >= *len) { - break; - } - } - - *len = actual; - return APR_SUCCESS; -} - -APU_DECLARE(apr_status_t) apr_brigade_pflatten(apr_bucket_brigade *bb, - char **c, - apr_size_t *len, - apr_pool_t *pool) -{ - apr_off_t actual; - apr_size_t total; - apr_status_t rv; - - apr_brigade_length(bb, 1, &actual); - - /* XXX: This is dangerous beyond belief. At least in the - * apr_brigade_flatten case, the user explicitly stated their - * buffer length - so we don't up and palloc 4GB for a single - * file bucket. This API must grow a useful max boundry, - * either compiled-in or preset via the *len value. - * - * Shouldn't both fn's grow an additional return value for - * the case that the brigade couldn't be flattened into the - * provided or allocated buffer (such as APR_EMOREDATA?) - * Not a failure, simply an advisory result. - */ - total = (apr_size_t)actual; - - *c = apr_palloc(pool, total); - - rv = apr_brigade_flatten(bb, *c, &total); - - if (rv != APR_SUCCESS) { - return rv; - } - - *len = total; - return APR_SUCCESS; -} - -APU_DECLARE(apr_status_t) apr_brigade_split_line(apr_bucket_brigade *bbOut, - apr_bucket_brigade *bbIn, - apr_read_type_e block, - apr_off_t maxbytes) -{ - apr_off_t readbytes = 0; - - while (!APR_BRIGADE_EMPTY(bbIn)) { - const char *pos; - const char *str; - apr_size_t len; - apr_status_t rv; - apr_bucket *e; - - e = APR_BRIGADE_FIRST(bbIn); - rv = apr_bucket_read(e, &str, &len, block); - - if (rv != APR_SUCCESS) { - return rv; - } - - pos = memchr(str, APR_ASCII_LF, len); - /* We found a match. */ - if (pos != NULL) { - apr_bucket_split(e, pos - str + 1); - APR_BUCKET_REMOVE(e); - APR_BRIGADE_INSERT_TAIL(bbOut, e); - return APR_SUCCESS; - } - APR_BUCKET_REMOVE(e); - APR_BRIGADE_INSERT_TAIL(bbOut, e); - readbytes += len; - /* We didn't find an APR_ASCII_LF within the maximum line length. */ - if (readbytes >= maxbytes) { - break; - } - } - - return APR_SUCCESS; -} - - -APU_DECLARE(apr_status_t) apr_brigade_to_iovec(apr_bucket_brigade *b, - struct iovec *vec, int *nvec) -{ - int left = *nvec; - apr_bucket *e; - struct iovec *orig; - apr_size_t iov_len; - apr_status_t rv; - - orig = vec; - - for (e = APR_BRIGADE_FIRST(b); - e != APR_BRIGADE_SENTINEL(b); - e = APR_BUCKET_NEXT(e)) - { - if (left-- == 0) - break; - - rv = apr_bucket_read(e, (const char **)&vec->iov_base, &iov_len, - APR_NONBLOCK_READ); - if (rv != APR_SUCCESS) - return rv; - vec->iov_len = iov_len; /* set indirectly in case size differs */ - ++vec; - } - - *nvec = vec - orig; - return APR_SUCCESS; -} - -APU_DECLARE(apr_status_t) apr_brigade_vputstrs(apr_bucket_brigade *b, - apr_brigade_flush flush, - void *ctx, - va_list va) -{ - for (;;) { - const char *str = va_arg(va, const char *); - apr_status_t rv; - - if (str == NULL) - break; - - rv = apr_brigade_write(b, flush, ctx, str, strlen(str)); - if (rv != APR_SUCCESS) - return rv; - } - - return APR_SUCCESS; -} - -APU_DECLARE(apr_status_t) apr_brigade_putc(apr_bucket_brigade *b, - apr_brigade_flush flush, void *ctx, - const char c) -{ - return apr_brigade_write(b, flush, ctx, &c, 1); -} - -APU_DECLARE(apr_status_t) apr_brigade_write(apr_bucket_brigade *b, - apr_brigade_flush flush, - void *ctx, - const char *str, apr_size_t nbyte) -{ - apr_bucket *e = APR_BRIGADE_LAST(b); - apr_size_t remaining = APR_BUCKET_BUFF_SIZE; - char *buf = NULL; - - if (!APR_BRIGADE_EMPTY(b) && APR_BUCKET_IS_HEAP(e)) { - apr_bucket_heap *h = e->data; - - /* HEAP bucket start offsets are always in-memory, safe to cast */ - remaining = h->alloc_len - (e->length + (apr_size_t)e->start); - buf = h->base + e->start + e->length; - } - - if (nbyte > remaining) { - /* either a buffer bucket exists but is full, - * or no buffer bucket exists and the data is too big - * to buffer. In either case, we should flush. */ - if (flush) { - e = apr_bucket_transient_create(str, nbyte, b->bucket_alloc); - APR_BRIGADE_INSERT_TAIL(b, e); - return flush(b, ctx); - } - else { - e = apr_bucket_heap_create(str, nbyte, NULL, b->bucket_alloc); - APR_BRIGADE_INSERT_TAIL(b, e); - return APR_SUCCESS; - } - } - else if (!buf) { - /* we don't have a buffer, but the data is small enough - * that we don't mind making a new buffer */ - buf = apr_bucket_alloc(APR_BUCKET_BUFF_SIZE, b->bucket_alloc); - e = apr_bucket_heap_create(buf, APR_BUCKET_BUFF_SIZE, - apr_bucket_free, b->bucket_alloc); - APR_BRIGADE_INSERT_TAIL(b, e); - e->length = 0; /* We are writing into the brigade, and - * allocating more memory than we need. This - * ensures that the bucket thinks it is empty just - * after we create it. We'll fix the length - * once we put data in it below. - */ - } - - /* there is a sufficiently big buffer bucket available now */ - memcpy(buf, str, nbyte); - e->length += nbyte; - - return APR_SUCCESS; -} - -APU_DECLARE(apr_status_t) apr_brigade_writev(apr_bucket_brigade *b, - apr_brigade_flush flush, - void *ctx, - const struct iovec *vec, - apr_size_t nvec) -{ - apr_bucket *e; - apr_size_t total_len; - apr_size_t i; - char *buf; - - /* Compute the total length of the data to be written. - */ - total_len = 0; - for (i = 0; i < nvec; i++) { - total_len += vec[i].iov_len; - } - - /* If the data to be written is very large, try to convert - * the iovec to transient buckets rather than copying. - */ - if (total_len > APR_BUCKET_BUFF_SIZE) { - if (flush) { - for (i = 0; i < nvec; i++) { - e = apr_bucket_transient_create(vec[i].iov_base, - vec[i].iov_len, - b->bucket_alloc); - APR_BRIGADE_INSERT_TAIL(b, e); - } - return flush(b, ctx); - } - else { - for (i = 0; i < nvec; i++) { - e = apr_bucket_heap_create((const char *) vec[i].iov_base, - vec[i].iov_len, NULL, - b->bucket_alloc); - APR_BRIGADE_INSERT_TAIL(b, e); - } - return APR_SUCCESS; - } - } - - i = 0; - - /* If there is a heap bucket at the end of the brigade - * already, copy into the existing bucket. - */ - e = APR_BRIGADE_LAST(b); - if (!APR_BRIGADE_EMPTY(b) && APR_BUCKET_IS_HEAP(e)) { - apr_bucket_heap *h = e->data; - apr_size_t remaining = h->alloc_len - - (e->length + (apr_size_t)e->start); - buf = h->base + e->start + e->length; - - if (remaining >= total_len) { - /* Simple case: all the data will fit in the - * existing heap bucket - */ - for (; i < nvec; i++) { - apr_size_t len = vec[i].iov_len; - memcpy(buf, (const void *) vec[i].iov_base, len); - buf += len; - } - e->length += total_len; - return APR_SUCCESS; - } - else { - /* More complicated case: not all of the data - * will fit in the existing heap bucket. The - * total data size is <= APR_BUCKET_BUFF_SIZE, - * so we'll need only one additional bucket. - */ - const char *start_buf = buf; - for (; i < nvec; i++) { - apr_size_t len = vec[i].iov_len; - if (len > remaining) { - break; - } - memcpy(buf, (const void *) vec[i].iov_base, len); - buf += len; - remaining -= len; - } - e->length += (buf - start_buf); - total_len -= (buf - start_buf); - - if (flush) { - apr_status_t rv = flush(b, ctx); - if (rv != APR_SUCCESS) { - return rv; - } - } - - /* Now fall through into the case below to - * allocate another heap bucket and copy the - * rest of the array. (Note that i is not - * reset to zero here; it holds the index - * of the first vector element to be - * written to the new bucket.) - */ - } - } - - /* Allocate a new heap bucket, and copy the data into it. - * The checks above ensure that the amount of data to be - * written here is no larger than APR_BUCKET_BUFF_SIZE. - */ - buf = apr_bucket_alloc(APR_BUCKET_BUFF_SIZE, b->bucket_alloc); - e = apr_bucket_heap_create(buf, APR_BUCKET_BUFF_SIZE, - apr_bucket_free, b->bucket_alloc); - for (; i < nvec; i++) { - apr_size_t len = vec[i].iov_len; - memcpy(buf, (const void *) vec[i].iov_base, len); - buf += len; - } - e->length = total_len; - APR_BRIGADE_INSERT_TAIL(b, e); - - return APR_SUCCESS; -} - -APU_DECLARE(apr_status_t) apr_brigade_puts(apr_bucket_brigade *bb, - apr_brigade_flush flush, void *ctx, - const char *str) -{ - apr_size_t len = strlen(str); - apr_bucket *bkt = APR_BRIGADE_LAST(bb); - if (!APR_BRIGADE_EMPTY(bb) && APR_BUCKET_IS_HEAP(bkt)) { - /* If there is enough space available in a heap bucket - * at the end of the brigade, copy the string directly - * into the heap bucket - */ - apr_bucket_heap *h = bkt->data; - apr_size_t bytes_avail = h->alloc_len - bkt->length; - - if (bytes_avail >= len) { - char *buf = h->base + bkt->start + bkt->length; - memcpy(buf, str, len); - bkt->length += len; - return APR_SUCCESS; - } - } - - /* If the string could not be copied into an existing heap - * bucket, delegate the work to apr_brigade_write(), which - * knows how to grow the brigade - */ - return apr_brigade_write(bb, flush, ctx, str, len); -} - -APU_DECLARE_NONSTD(apr_status_t) apr_brigade_putstrs(apr_bucket_brigade *b, - apr_brigade_flush flush, - void *ctx, ...) -{ - va_list va; - apr_status_t rv; - - va_start(va, ctx); - rv = apr_brigade_vputstrs(b, flush, ctx, va); - va_end(va); - return rv; -} - -APU_DECLARE_NONSTD(apr_status_t) apr_brigade_printf(apr_bucket_brigade *b, - apr_brigade_flush flush, - void *ctx, - const char *fmt, ...) -{ - va_list ap; - apr_status_t rv; - - va_start(ap, fmt); - rv = apr_brigade_vprintf(b, flush, ctx, fmt, ap); - va_end(ap); - return rv; -} - -struct brigade_vprintf_data_t { - apr_vformatter_buff_t vbuff; - - apr_bucket_brigade *b; /* associated brigade */ - apr_brigade_flush *flusher; /* flushing function */ - void *ctx; - - char *cbuff; /* buffer to flush from */ -}; - -static apr_status_t brigade_flush(apr_vformatter_buff_t *buff) -{ - /* callback function passed to ap_vformatter to be - * called when vformatter needs to buff and - * buff.curpos > buff.endpos - */ - - /* "downcast," have really passed a brigade_vprintf_data_t* */ - struct brigade_vprintf_data_t *vd = (struct brigade_vprintf_data_t*)buff; - apr_status_t res = APR_SUCCESS; - - res = apr_brigade_write(vd->b, *vd->flusher, vd->ctx, vd->cbuff, - APR_BUCKET_BUFF_SIZE); - - if(res != APR_SUCCESS) { - return -1; - } - - vd->vbuff.curpos = vd->cbuff; - vd->vbuff.endpos = vd->cbuff + APR_BUCKET_BUFF_SIZE; - - return res; -} - -APU_DECLARE(apr_status_t) apr_brigade_vprintf(apr_bucket_brigade *b, - apr_brigade_flush flush, - void *ctx, - const char *fmt, va_list va) -{ - /* the cast, in order of appearance */ - struct brigade_vprintf_data_t vd; - char buf[APR_BUCKET_BUFF_SIZE]; - apr_size_t written; - - vd.vbuff.curpos = buf; - vd.vbuff.endpos = buf + APR_BUCKET_BUFF_SIZE; - vd.b = b; - vd.flusher = &flush; - vd.ctx = ctx; - vd.cbuff = buf; - - written = apr_vformatter(brigade_flush, &vd.vbuff, fmt, va); - - if (written == -1) { - return -1; - } - - /* tack on null terminator to remaining string */ - *(vd.vbuff.curpos) = '\0'; - - /* write out what remains in the buffer */ - return apr_brigade_write(b, flush, ctx, buf, vd.vbuff.curpos - buf); -} - -/* A "safe" maximum bucket size, 1Gb */ -#define MAX_BUCKET_SIZE (0x40000000) - -APU_DECLARE(apr_bucket *) apr_brigade_insert_file(apr_bucket_brigade *bb, - apr_file_t *f, - apr_off_t start, - apr_off_t length, - apr_pool_t *p) -{ - apr_bucket *e; - - if (sizeof(apr_off_t) == sizeof(apr_size_t) || length < MAX_BUCKET_SIZE) { - e = apr_bucket_file_create(f, start, (apr_size_t)length, p, - bb->bucket_alloc); - } - else { - /* Several buckets are needed. */ - e = apr_bucket_file_create(f, start, MAX_BUCKET_SIZE, p, - bb->bucket_alloc); - - while (length > MAX_BUCKET_SIZE) { - apr_bucket *ce; - apr_bucket_copy(e, &ce); - APR_BRIGADE_INSERT_TAIL(bb, ce); - e->start += MAX_BUCKET_SIZE; - length -= MAX_BUCKET_SIZE; - } - e->length = (apr_size_t)length; /* Resize just the last bucket */ - } - - APR_BRIGADE_INSERT_TAIL(bb, e); - return e; -} diff --git a/libs/apr-util/buckets/apr_buckets.c b/libs/apr-util/buckets/apr_buckets.c deleted file mode 100644 index 69b7f6cf75..0000000000 --- a/libs/apr-util/buckets/apr_buckets.c +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_buckets.h" - -APU_DECLARE_NONSTD(apr_status_t) apr_bucket_setaside_noop(apr_bucket *data, - apr_pool_t *pool) -{ - return APR_SUCCESS; -} - -APU_DECLARE_NONSTD(apr_status_t) apr_bucket_setaside_notimpl(apr_bucket *data, - apr_pool_t *pool) -{ - return APR_ENOTIMPL; -} - -APU_DECLARE_NONSTD(apr_status_t) apr_bucket_split_notimpl(apr_bucket *data, - apr_size_t point) -{ - return APR_ENOTIMPL; -} - -APU_DECLARE_NONSTD(apr_status_t) apr_bucket_copy_notimpl(apr_bucket *e, - apr_bucket **c) -{ - return APR_ENOTIMPL; -} - -APU_DECLARE_NONSTD(void) apr_bucket_destroy_noop(void *data) -{ - return; -} diff --git a/libs/apr-util/buckets/apr_buckets_alloc.c b/libs/apr-util/buckets/apr_buckets_alloc.c deleted file mode 100644 index 81a8271484..0000000000 --- a/libs/apr-util/buckets/apr_buckets_alloc.c +++ /dev/null @@ -1,184 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "apr_buckets.h" -#include "apr_allocator.h" - -#define ALLOC_AMT (8192 - APR_MEMNODE_T_SIZE) - -typedef struct node_header_t { - apr_size_t size; - apr_bucket_alloc_t *alloc; - apr_memnode_t *memnode; - struct node_header_t *next; -} node_header_t; - -#define SIZEOF_NODE_HEADER_T APR_ALIGN_DEFAULT(sizeof(node_header_t)) -#define SMALL_NODE_SIZE (APR_BUCKET_ALLOC_SIZE + SIZEOF_NODE_HEADER_T) - -/** A list of free memory from which new buckets or private bucket - * structures can be allocated. - */ -struct apr_bucket_alloc_t { - apr_pool_t *pool; - apr_allocator_t *allocator; - node_header_t *freelist; - apr_memnode_t *blocks; -}; - -static apr_status_t alloc_cleanup(void *data) -{ - apr_bucket_alloc_t *list = data; - - apr_allocator_free(list->allocator, list->blocks); - -#if APR_POOL_DEBUG - if (list->pool && list->allocator != apr_pool_allocator_get(list->pool)) { - apr_allocator_destroy(list->allocator); - } -#endif - - return APR_SUCCESS; -} - -APU_DECLARE_NONSTD(apr_bucket_alloc_t *) apr_bucket_alloc_create(apr_pool_t *p) -{ - apr_allocator_t *allocator = apr_pool_allocator_get(p); - apr_bucket_alloc_t *list; - -#if APR_POOL_DEBUG - /* may be NULL for debug mode. */ - if (allocator == NULL) { - if (apr_allocator_create(&allocator) != APR_SUCCESS) { - abort(); - } - } -#endif - - list = apr_bucket_alloc_create_ex(allocator); - list->pool = p; - apr_pool_cleanup_register(list->pool, list, alloc_cleanup, - apr_pool_cleanup_null); - - return list; -} - -APU_DECLARE_NONSTD(apr_bucket_alloc_t *) apr_bucket_alloc_create_ex( - apr_allocator_t *allocator) -{ - apr_bucket_alloc_t *list; - apr_memnode_t *block; - - block = apr_allocator_alloc(allocator, ALLOC_AMT); - list = (apr_bucket_alloc_t *)block->first_avail; - list->pool = NULL; - list->allocator = allocator; - list->freelist = NULL; - list->blocks = block; - block->first_avail += APR_ALIGN_DEFAULT(sizeof(*list)); - - return list; -} - -APU_DECLARE_NONSTD(void) apr_bucket_alloc_destroy(apr_bucket_alloc_t *list) -{ - if (list->pool) { - apr_pool_cleanup_kill(list->pool, list, alloc_cleanup); - } - - apr_allocator_free(list->allocator, list->blocks); - -#if APR_POOL_DEBUG - if (list->pool && list->allocator != apr_pool_allocator_get(list->pool)) { - apr_allocator_destroy(list->allocator); - } -#endif -} - -APU_DECLARE_NONSTD(void *) apr_bucket_alloc(apr_size_t size, - apr_bucket_alloc_t *list) -{ - node_header_t *node; - apr_memnode_t *active = list->blocks; - char *endp; - - size += SIZEOF_NODE_HEADER_T; - if (size <= SMALL_NODE_SIZE) { - if (list->freelist) { - node = list->freelist; - list->freelist = node->next; - } - else { - endp = active->first_avail + SMALL_NODE_SIZE; - if (endp >= active->endp) { - list->blocks = apr_allocator_alloc(list->allocator, ALLOC_AMT); - list->blocks->next = active; - active = list->blocks; - endp = active->first_avail + SMALL_NODE_SIZE; - } - node = (node_header_t *)active->first_avail; - node->alloc = list; - node->memnode = active; - node->size = SMALL_NODE_SIZE; - active->first_avail = endp; - } - } - else { - apr_memnode_t *memnode = apr_allocator_alloc(list->allocator, size); - node = (node_header_t *)memnode->first_avail; - node->alloc = list; - node->memnode = memnode; - node->size = size; - } - return ((char *)node) + SIZEOF_NODE_HEADER_T; -} - -#ifdef APR_BUCKET_DEBUG -#if APR_HAVE_STDLIB_H -#include -#endif -static void check_not_already_free(node_header_t *node) -{ - apr_bucket_alloc_t *list = node->alloc; - node_header_t *curr = list->freelist; - - while (curr) { - if (node == curr) { - abort(); - } - curr = curr->next; - } -} -#else -#define check_not_already_free(node) -#endif - -APU_DECLARE_NONSTD(void) apr_bucket_free(void *mem) -{ - node_header_t *node = (node_header_t *)((char *)mem - SIZEOF_NODE_HEADER_T); - apr_bucket_alloc_t *list = node->alloc; - - if (node->size == SMALL_NODE_SIZE) { - check_not_already_free(node); - node->next = list->freelist; - list->freelist = node; - } - else { - apr_allocator_free(list->allocator, node->memnode); - } -} diff --git a/libs/apr-util/buckets/apr_buckets_eos.c b/libs/apr-util/buckets/apr_buckets_eos.c deleted file mode 100644 index 5783857dfa..0000000000 --- a/libs/apr-util/buckets/apr_buckets_eos.c +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_buckets.h" - -static apr_status_t eos_bucket_read(apr_bucket *b, const char **str, - apr_size_t *len, apr_read_type_e block) -{ - *str = NULL; - *len = 0; - return APR_SUCCESS; -} - -APU_DECLARE(apr_bucket *) apr_bucket_eos_make(apr_bucket *b) -{ - b->length = 0; - b->start = 0; - b->data = NULL; - b->type = &apr_bucket_type_eos; - - return b; -} - -APU_DECLARE(apr_bucket *) apr_bucket_eos_create(apr_bucket_alloc_t *list) -{ - apr_bucket *b = apr_bucket_alloc(sizeof(*b), list); - - APR_BUCKET_INIT(b); - b->free = apr_bucket_free; - b->list = list; - return apr_bucket_eos_make(b); -} - -APU_DECLARE_DATA const apr_bucket_type_t apr_bucket_type_eos = { - "EOS", 5, APR_BUCKET_METADATA, - apr_bucket_destroy_noop, - eos_bucket_read, - apr_bucket_setaside_noop, - apr_bucket_split_notimpl, - apr_bucket_simple_copy -}; diff --git a/libs/apr-util/buckets/apr_buckets_file.c b/libs/apr-util/buckets/apr_buckets_file.c deleted file mode 100644 index 7462bb7032..0000000000 --- a/libs/apr-util/buckets/apr_buckets_file.c +++ /dev/null @@ -1,228 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_general.h" -#include "apr_file_io.h" -#include "apr_buckets.h" - -#if APR_HAS_MMAP -#include "apr_mmap.h" - -/* mmap support for static files based on ideas from John Heidemann's - * patch against 1.0.5. See - * . - */ - -#endif /* APR_HAS_MMAP */ - -static void file_bucket_destroy(void *data) -{ - apr_bucket_file *f = data; - - if (apr_bucket_shared_destroy(f)) { - /* no need to close the file here; it will get - * done automatically when the pool gets cleaned up */ - apr_bucket_free(f); - } -} - -#if APR_HAS_MMAP -static int file_make_mmap(apr_bucket *e, apr_size_t filelength, - apr_off_t fileoffset, apr_pool_t *p) -{ - apr_bucket_file *a = e->data; - apr_mmap_t *mm; - - if (!a->can_mmap) { - return 0; - } - - if (filelength > APR_MMAP_LIMIT) { - if (apr_mmap_create(&mm, a->fd, fileoffset, APR_MMAP_LIMIT, - APR_MMAP_READ, p) != APR_SUCCESS) - { - return 0; - } - apr_bucket_split(e, APR_MMAP_LIMIT); - filelength = APR_MMAP_LIMIT; - } - else if ((filelength < APR_MMAP_THRESHOLD) || - (apr_mmap_create(&mm, a->fd, fileoffset, filelength, - APR_MMAP_READ, p) != APR_SUCCESS)) - { - return 0; - } - apr_bucket_mmap_make(e, mm, 0, filelength); - file_bucket_destroy(a); - return 1; -} -#endif - -static apr_status_t file_bucket_read(apr_bucket *e, const char **str, - apr_size_t *len, apr_read_type_e block) -{ - apr_bucket_file *a = e->data; - apr_file_t *f = a->fd; - apr_bucket *b = NULL; - char *buf; - apr_status_t rv; - apr_size_t filelength = e->length; /* bytes remaining in file past offset */ - apr_off_t fileoffset = e->start; -#if APR_HAS_THREADS && !APR_HAS_XTHREAD_FILES - apr_int32_t flags; -#endif - -#if APR_HAS_MMAP - if (file_make_mmap(e, filelength, fileoffset, a->readpool)) { - return apr_bucket_read(e, str, len, block); - } -#endif - -#if APR_HAS_THREADS && !APR_HAS_XTHREAD_FILES - if ((flags = apr_file_flags_get(f)) & APR_XTHREAD) { - /* this file descriptor is shared across multiple threads and - * this OS doesn't support that natively, so as a workaround - * we must reopen the file into a->readpool */ - const char *fname; - apr_file_name_get(&fname, f); - - rv = apr_file_open(&f, fname, (flags & ~APR_XTHREAD), 0, a->readpool); - if (rv != APR_SUCCESS) - return rv; - - a->fd = f; - } -#endif - - *len = (filelength > APR_BUCKET_BUFF_SIZE) - ? APR_BUCKET_BUFF_SIZE - : filelength; - *str = NULL; /* in case we die prematurely */ - buf = apr_bucket_alloc(*len, e->list); - - /* Handle offset ... */ - rv = apr_file_seek(f, APR_SET, &fileoffset); - if (rv != APR_SUCCESS) { - apr_bucket_free(buf); - return rv; - } - rv = apr_file_read(f, buf, len); - if (rv != APR_SUCCESS && rv != APR_EOF) { - apr_bucket_free(buf); - return rv; - } - filelength -= *len; - /* - * Change the current bucket to refer to what we read, - * even if we read nothing because we hit EOF. - */ - apr_bucket_heap_make(e, buf, *len, apr_bucket_free); - - /* If we have more to read from the file, then create another bucket */ - if (filelength > 0 && rv != APR_EOF) { - /* for efficiency, we can just build a new apr_bucket struct - * to wrap around the existing file bucket */ - b = apr_bucket_alloc(sizeof(*b), e->list); - b->start = fileoffset + (*len); - b->length = filelength; - b->data = a; - b->type = &apr_bucket_type_file; - b->free = apr_bucket_free; - b->list = e->list; - APR_BUCKET_INSERT_AFTER(e, b); - } - else { - file_bucket_destroy(a); - } - - *str = buf; - return rv; -} - -APU_DECLARE(apr_bucket *) apr_bucket_file_make(apr_bucket *b, apr_file_t *fd, - apr_off_t offset, - apr_size_t len, apr_pool_t *p) -{ - apr_bucket_file *f; - - f = apr_bucket_alloc(sizeof(*f), b->list); - f->fd = fd; - f->readpool = p; -#if APR_HAS_MMAP - f->can_mmap = 1; -#endif - - b = apr_bucket_shared_make(b, f, offset, len); - b->type = &apr_bucket_type_file; - - return b; -} - -APU_DECLARE(apr_bucket *) apr_bucket_file_create(apr_file_t *fd, - apr_off_t offset, - apr_size_t len, apr_pool_t *p, - apr_bucket_alloc_t *list) -{ - apr_bucket *b = apr_bucket_alloc(sizeof(*b), list); - - APR_BUCKET_INIT(b); - b->free = apr_bucket_free; - b->list = list; - return apr_bucket_file_make(b, fd, offset, len, p); -} - -APU_DECLARE(apr_status_t) apr_bucket_file_enable_mmap(apr_bucket *e, - int enabled) -{ -#if APR_HAS_MMAP - apr_bucket_file *a = e->data; - a->can_mmap = enabled; - return APR_SUCCESS; -#else - return APR_ENOTIMPL; -#endif /* APR_HAS_MMAP */ -} - - -static apr_status_t file_bucket_setaside(apr_bucket *data, apr_pool_t *reqpool) -{ - apr_bucket_file *a = data->data; - apr_file_t *fd = NULL; - apr_file_t *f = a->fd; - apr_pool_t *curpool = apr_file_pool_get(f); - - if (apr_pool_is_ancestor(curpool, reqpool)) { - return APR_SUCCESS; - } - - if (!apr_pool_is_ancestor(a->readpool, reqpool)) { - a->readpool = reqpool; - } - - apr_file_setaside(&fd, f, reqpool); - a->fd = fd; - return APR_SUCCESS; -} - -APU_DECLARE_DATA const apr_bucket_type_t apr_bucket_type_file = { - "FILE", 5, APR_BUCKET_DATA, - file_bucket_destroy, - file_bucket_read, - file_bucket_setaside, - apr_bucket_shared_split, - apr_bucket_shared_copy -}; diff --git a/libs/apr-util/buckets/apr_buckets_flush.c b/libs/apr-util/buckets/apr_buckets_flush.c deleted file mode 100644 index 68b6bfa214..0000000000 --- a/libs/apr-util/buckets/apr_buckets_flush.c +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_buckets.h" - -static apr_status_t flush_bucket_read(apr_bucket *b, const char **str, - apr_size_t *len, apr_read_type_e block) -{ - *str = NULL; - *len = 0; - return APR_SUCCESS; -} - -APU_DECLARE(apr_bucket *) apr_bucket_flush_make(apr_bucket *b) -{ - b->length = 0; - b->start = 0; - b->data = NULL; - b->type = &apr_bucket_type_flush; - - return b; -} - -APU_DECLARE(apr_bucket *) apr_bucket_flush_create(apr_bucket_alloc_t *list) -{ - apr_bucket *b = apr_bucket_alloc(sizeof(*b), list); - - APR_BUCKET_INIT(b); - b->free = apr_bucket_free; - b->list = list; - return apr_bucket_flush_make(b); -} - -APU_DECLARE_DATA const apr_bucket_type_t apr_bucket_type_flush = { - "FLUSH", 5, APR_BUCKET_METADATA, - apr_bucket_destroy_noop, - flush_bucket_read, - apr_bucket_setaside_noop, - apr_bucket_split_notimpl, - apr_bucket_simple_copy -}; diff --git a/libs/apr-util/buckets/apr_buckets_heap.c b/libs/apr-util/buckets/apr_buckets_heap.c deleted file mode 100644 index d1ebd2947a..0000000000 --- a/libs/apr-util/buckets/apr_buckets_heap.c +++ /dev/null @@ -1,96 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_buckets.h" -#define APR_WANT_MEMFUNC -#include "apr_want.h" - -static apr_status_t heap_bucket_read(apr_bucket *b, const char **str, - apr_size_t *len, apr_read_type_e block) -{ - apr_bucket_heap *h = b->data; - - *str = h->base + b->start; - *len = b->length; - return APR_SUCCESS; -} - -static void heap_bucket_destroy(void *data) -{ - apr_bucket_heap *h = data; - - if (apr_bucket_shared_destroy(h)) { - (*h->free_func)(h->base); - apr_bucket_free(h); - } -} - -/* Warning: if you change this function, be sure to - * change apr_bucket_pool_make() too! */ -APU_DECLARE(apr_bucket *) apr_bucket_heap_make(apr_bucket *b, const char *buf, - apr_size_t length, - void (*free_func)(void *data)) -{ - apr_bucket_heap *h; - - h = apr_bucket_alloc(sizeof(*h), b->list); - - if (!free_func) { - h->alloc_len = length; - h->base = apr_bucket_alloc(h->alloc_len, b->list); - if (h->base == NULL) { - apr_bucket_free(h); - return NULL; - } - h->free_func = apr_bucket_free; - memcpy(h->base, buf, length); - } - else { - /* XXX: we lose the const qualifier here which indicates - * there's something screwy with the API... - */ - h->base = (char *) buf; - h->alloc_len = length; - h->free_func = free_func; - } - - b = apr_bucket_shared_make(b, h, 0, length); - b->type = &apr_bucket_type_heap; - - return b; -} - -APU_DECLARE(apr_bucket *) apr_bucket_heap_create(const char *buf, - apr_size_t length, - void (*free_func)(void *data), - apr_bucket_alloc_t *list) -{ - apr_bucket *b = apr_bucket_alloc(sizeof(*b), list); - - APR_BUCKET_INIT(b); - b->free = apr_bucket_free; - b->list = list; - return apr_bucket_heap_make(b, buf, length, free_func); -} - -APU_DECLARE_DATA const apr_bucket_type_t apr_bucket_type_heap = { - "HEAP", 5, APR_BUCKET_DATA, - heap_bucket_destroy, - heap_bucket_read, - apr_bucket_setaside_noop, - apr_bucket_shared_split, - apr_bucket_shared_copy -}; diff --git a/libs/apr-util/buckets/apr_buckets_mmap.c b/libs/apr-util/buckets/apr_buckets_mmap.c deleted file mode 100644 index 3e7a9d73c2..0000000000 --- a/libs/apr-util/buckets/apr_buckets_mmap.c +++ /dev/null @@ -1,144 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_buckets.h" - -#if APR_HAS_MMAP - -static apr_status_t mmap_bucket_read(apr_bucket *b, const char **str, - apr_size_t *length, apr_read_type_e block) -{ - apr_bucket_mmap *m = b->data; - apr_status_t ok; - void *addr; - - if (!m->mmap) { - /* the apr_mmap_t was already cleaned up out from under us */ - return APR_EINVAL; - } - - ok = apr_mmap_offset(&addr, m->mmap, b->start); - if (ok != APR_SUCCESS) { - return ok; - } - *str = addr; - *length = b->length; - return APR_SUCCESS; -} - -static apr_status_t mmap_bucket_cleanup(void *data) -{ - /* the apr_mmap_t is about to disappear out from under us, so we - * have no choice but to pretend it doesn't exist anymore. the - * refcount is now useless because there's nothing to refer to - * anymore. so the only valid action on any remaining referrer - * is to delete it. no more reads, no more anything. */ - apr_bucket_mmap *m = data; - - m->mmap = NULL; - return APR_SUCCESS; -} - -static void mmap_bucket_destroy(void *data) -{ - apr_bucket_mmap *m = data; - - if (apr_bucket_shared_destroy(m)) { - if (m->mmap) { - apr_pool_cleanup_kill(m->mmap->cntxt, m, mmap_bucket_cleanup); - apr_mmap_delete(m->mmap); - } - apr_bucket_free(m); - } -} - -/* - * XXX: are the start and length arguments useful? - */ -APU_DECLARE(apr_bucket *) apr_bucket_mmap_make(apr_bucket *b, apr_mmap_t *mm, - apr_off_t start, - apr_size_t length) -{ - apr_bucket_mmap *m; - - m = apr_bucket_alloc(sizeof(*m), b->list); - m->mmap = mm; - - apr_pool_cleanup_register(mm->cntxt, m, mmap_bucket_cleanup, - apr_pool_cleanup_null); - - b = apr_bucket_shared_make(b, m, start, length); - b->type = &apr_bucket_type_mmap; - - return b; -} - - -APU_DECLARE(apr_bucket *) apr_bucket_mmap_create(apr_mmap_t *mm, - apr_off_t start, - apr_size_t length, - apr_bucket_alloc_t *list) -{ - apr_bucket *b = apr_bucket_alloc(sizeof(*b), list); - - APR_BUCKET_INIT(b); - b->free = apr_bucket_free; - b->list = list; - return apr_bucket_mmap_make(b, mm, start, length); -} - -static apr_status_t mmap_bucket_setaside(apr_bucket *b, apr_pool_t *p) -{ - apr_bucket_mmap *m = b->data; - apr_mmap_t *mm = m->mmap; - apr_mmap_t *new_mm; - apr_status_t ok; - - if (!mm) { - /* the apr_mmap_t was already cleaned up out from under us */ - return APR_EINVAL; - } - - /* shortcut if possible */ - if (apr_pool_is_ancestor(mm->cntxt, p)) { - return APR_SUCCESS; - } - - /* duplicate apr_mmap_t into new pool */ - ok = apr_mmap_dup(&new_mm, mm, p); - if (ok != APR_SUCCESS) { - return ok; - } - - /* decrement refcount on old apr_bucket_mmap */ - mmap_bucket_destroy(m); - - /* create new apr_bucket_mmap pointing to new apr_mmap_t */ - apr_bucket_mmap_make(b, new_mm, b->start, b->length); - - return APR_SUCCESS; -} - -APU_DECLARE_DATA const apr_bucket_type_t apr_bucket_type_mmap = { - "MMAP", 5, APR_BUCKET_DATA, - mmap_bucket_destroy, - mmap_bucket_read, - mmap_bucket_setaside, - apr_bucket_shared_split, - apr_bucket_shared_copy -}; - -#endif diff --git a/libs/apr-util/buckets/apr_buckets_pipe.c b/libs/apr-util/buckets/apr_buckets_pipe.c deleted file mode 100644 index 36c0cd55eb..0000000000 --- a/libs/apr-util/buckets/apr_buckets_pipe.c +++ /dev/null @@ -1,119 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_buckets.h" - -static apr_status_t pipe_bucket_read(apr_bucket *a, const char **str, - apr_size_t *len, apr_read_type_e block) -{ - apr_file_t *p = a->data; - char *buf; - apr_status_t rv; - apr_interval_time_t timeout; - - if (block == APR_NONBLOCK_READ) { - apr_file_pipe_timeout_get(p, &timeout); - apr_file_pipe_timeout_set(p, 0); - } - - *str = NULL; - *len = APR_BUCKET_BUFF_SIZE; - buf = apr_bucket_alloc(*len, a->list); /* XXX: check for failure? */ - - rv = apr_file_read(p, buf, len); - - if (block == APR_NONBLOCK_READ) { - apr_file_pipe_timeout_set(p, timeout); - } - - if (rv != APR_SUCCESS && rv != APR_EOF) { - apr_bucket_free(buf); - return rv; - } - /* - * If there's more to read we have to keep the rest of the pipe - * for later. Otherwise, we'll close the pipe. - * XXX: Note that more complicated bucket types that - * refer to data not in memory and must therefore have a read() - * function similar to this one should be wary of copying this - * code because if they have a destroy function they probably - * want to migrate the bucket's subordinate structure from the - * old bucket to a raw new one and adjust it as appropriate, - * rather than destroying the old one and creating a completely - * new bucket. - */ - if (*len > 0) { - apr_bucket_heap *h; - /* Change the current bucket to refer to what we read */ - a = apr_bucket_heap_make(a, buf, *len, apr_bucket_free); - h = a->data; - h->alloc_len = APR_BUCKET_BUFF_SIZE; /* note the real buffer size */ - *str = buf; - APR_BUCKET_INSERT_AFTER(a, apr_bucket_pipe_create(p, a->list)); - } - else { - apr_bucket_free(buf); - a = apr_bucket_immortal_make(a, "", 0); - *str = a->data; - if (rv == APR_EOF) { - apr_file_close(p); - } - } - return APR_SUCCESS; -} - -APU_DECLARE(apr_bucket *) apr_bucket_pipe_make(apr_bucket *b, apr_file_t *p) -{ - /* - * A pipe is closed when the end is reached in pipe_bucket_read(). If - * the pipe isn't read to the end (e.g., error path), the pipe will be - * closed when its pool goes away. - * - * Note that typically the pipe is allocated from the request pool - * so it will disappear when the request is finished. However the - * core filter may decide to set aside the tail end of a CGI - * response if the connection is pipelined. This turns out not to - * be a problem because the core will have read to the end of the - * stream so the bucket(s) that it sets aside will be the heap - * buckets created by pipe_bucket_read() above. - */ - b->type = &apr_bucket_type_pipe; - b->length = (apr_size_t)(-1); - b->start = -1; - b->data = p; - - return b; -} - -APU_DECLARE(apr_bucket *) apr_bucket_pipe_create(apr_file_t *p, - apr_bucket_alloc_t *list) -{ - apr_bucket *b = apr_bucket_alloc(sizeof(*b), list); - - APR_BUCKET_INIT(b); - b->free = apr_bucket_free; - b->list = list; - return apr_bucket_pipe_make(b, p); -} - -APU_DECLARE_DATA const apr_bucket_type_t apr_bucket_type_pipe = { - "PIPE", 5, APR_BUCKET_DATA, - apr_bucket_destroy_noop, - pipe_bucket_read, - apr_bucket_setaside_notimpl, - apr_bucket_split_notimpl, - apr_bucket_copy_notimpl -}; diff --git a/libs/apr-util/buckets/apr_buckets_pool.c b/libs/apr-util/buckets/apr_buckets_pool.c deleted file mode 100644 index 2226a75196..0000000000 --- a/libs/apr-util/buckets/apr_buckets_pool.c +++ /dev/null @@ -1,142 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_buckets.h" -#define APR_WANT_MEMFUNC -#include "apr_want.h" - -static apr_status_t pool_bucket_cleanup(void *data) -{ - apr_bucket_pool *p = data; - - /* - * If the pool gets cleaned up, we have to copy the data out - * of the pool and onto the heap. But the apr_buckets out there - * that point to this pool bucket need to be notified such that - * they can morph themselves into a regular heap bucket the next - * time they try to read. To avoid having to manipulate - * reference counts and b->data pointers, the apr_bucket_pool - * actually _contains_ an apr_bucket_heap as its first element, - * so the two share their apr_bucket_refcount member, and you - * can typecast a pool bucket struct to make it look like a - * regular old heap bucket struct. - */ - p->heap.base = apr_bucket_alloc(p->heap.alloc_len, p->list); - memcpy(p->heap.base, p->base, p->heap.alloc_len); - p->base = NULL; - p->pool = NULL; - - return APR_SUCCESS; -} - -static apr_status_t pool_bucket_read(apr_bucket *b, const char **str, - apr_size_t *len, apr_read_type_e block) -{ - apr_bucket_pool *p = b->data; - const char *base = p->base; - - if (p->pool == NULL) { - /* - * pool has been cleaned up... masquerade as a heap bucket from now - * on. subsequent bucket operations will use the heap bucket code. - */ - b->type = &apr_bucket_type_heap; - base = p->heap.base; - } - *str = base + b->start; - *len = b->length; - return APR_SUCCESS; -} - -static void pool_bucket_destroy(void *data) -{ - apr_bucket_pool *p = data; - - /* If the pool is cleaned up before the last reference goes - * away, the data is really now on the heap; heap_destroy() takes - * over. free() in heap_destroy() thinks it's freeing - * an apr_bucket_heap, when in reality it's freeing the whole - * apr_bucket_pool for us. - */ - if (p->pool) { - /* the shared resource is still in the pool - * because the pool has not been cleaned up yet - */ - if (apr_bucket_shared_destroy(p)) { - apr_pool_cleanup_kill(p->pool, p, pool_bucket_cleanup); - apr_bucket_free(p); - } - } - else { - /* the shared resource is no longer in the pool, it's - * on the heap, but this reference still thinks it's a pool - * bucket. we should just go ahead and pass control to - * heap_destroy() for it since it doesn't know any better. - */ - apr_bucket_type_heap.destroy(p); - } -} - -APU_DECLARE(apr_bucket *) apr_bucket_pool_make(apr_bucket *b, - const char *buf, apr_size_t length, apr_pool_t *pool) -{ - apr_bucket_pool *p; - - p = apr_bucket_alloc(sizeof(*p), b->list); - - /* XXX: we lose the const qualifier here which indicates - * there's something screwy with the API... - */ - /* XXX: why is this? buf is const, p->base is const... what's - * the problem? --jcw */ - p->base = (char *) buf; - p->pool = pool; - p->list = b->list; - - b = apr_bucket_shared_make(b, p, 0, length); - b->type = &apr_bucket_type_pool; - - /* pre-initialize heap bucket member */ - p->heap.alloc_len = length; - p->heap.base = NULL; - p->heap.free_func = apr_bucket_free; - - apr_pool_cleanup_register(p->pool, p, pool_bucket_cleanup, - apr_pool_cleanup_null); - return b; -} - -APU_DECLARE(apr_bucket *) apr_bucket_pool_create(const char *buf, - apr_size_t length, - apr_pool_t *pool, - apr_bucket_alloc_t *list) -{ - apr_bucket *b = apr_bucket_alloc(sizeof(*b), list); - - APR_BUCKET_INIT(b); - b->free = apr_bucket_free; - b->list = list; - return apr_bucket_pool_make(b, buf, length, pool); -} - -APU_DECLARE_DATA const apr_bucket_type_t apr_bucket_type_pool = { - "POOL", 5, APR_BUCKET_DATA, - pool_bucket_destroy, - pool_bucket_read, - apr_bucket_setaside_noop, /* don't need to setaside thanks to the cleanup*/ - apr_bucket_shared_split, - apr_bucket_shared_copy -}; diff --git a/libs/apr-util/buckets/apr_buckets_refcount.c b/libs/apr-util/buckets/apr_buckets_refcount.c deleted file mode 100644 index 72747878d7..0000000000 --- a/libs/apr-util/buckets/apr_buckets_refcount.c +++ /dev/null @@ -1,64 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_buckets.h" - -APU_DECLARE_NONSTD(apr_status_t) apr_bucket_shared_split(apr_bucket *a, - apr_size_t point) -{ - apr_bucket_refcount *r = a->data; - apr_status_t rv; - - if ((rv = apr_bucket_simple_split(a, point)) != APR_SUCCESS) { - return rv; - } - r->refcount++; - - return APR_SUCCESS; -} - -APU_DECLARE_NONSTD(apr_status_t) apr_bucket_shared_copy(apr_bucket *a, - apr_bucket **b) -{ - apr_bucket_refcount *r = a->data; - - apr_bucket_simple_copy(a, b); - r->refcount++; - - return APR_SUCCESS; -} - -APU_DECLARE(int) apr_bucket_shared_destroy(void *data) -{ - apr_bucket_refcount *r = data; - r->refcount--; - return (r->refcount == 0); -} - -APU_DECLARE(apr_bucket *) apr_bucket_shared_make(apr_bucket *b, void *data, - apr_off_t start, - apr_size_t length) -{ - apr_bucket_refcount *r = data; - - b->data = r; - b->start = start; - b->length = length; - /* caller initializes the type field */ - r->refcount = 1; - - return b; -} diff --git a/libs/apr-util/buckets/apr_buckets_simple.c b/libs/apr-util/buckets/apr_buckets_simple.c deleted file mode 100644 index aabe086479..0000000000 --- a/libs/apr-util/buckets/apr_buckets_simple.c +++ /dev/null @@ -1,137 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_buckets.h" - -APU_DECLARE_NONSTD(apr_status_t) apr_bucket_simple_copy(apr_bucket *a, - apr_bucket **b) -{ - *b = apr_bucket_alloc(sizeof(**b), a->list); /* XXX: check for failure? */ - **b = *a; - - return APR_SUCCESS; -} - -APU_DECLARE_NONSTD(apr_status_t) apr_bucket_simple_split(apr_bucket *a, - apr_size_t point) -{ - apr_bucket *b; - - if (point > a->length) { - return APR_EINVAL; - } - - apr_bucket_simple_copy(a, &b); - - a->length = point; - b->length -= point; - b->start += point; - - APR_BUCKET_INSERT_AFTER(a, b); - - return APR_SUCCESS; -} - -static apr_status_t simple_bucket_read(apr_bucket *b, const char **str, - apr_size_t *len, apr_read_type_e block) -{ - *str = (char *)b->data + b->start; - *len = b->length; - return APR_SUCCESS; -} - -APU_DECLARE(apr_bucket *) apr_bucket_immortal_make(apr_bucket *b, - const char *buf, - apr_size_t length) -{ - b->data = (char *)buf; - b->length = length; - b->start = 0; - b->type = &apr_bucket_type_immortal; - - return b; -} - -APU_DECLARE(apr_bucket *) apr_bucket_immortal_create(const char *buf, - apr_size_t length, - apr_bucket_alloc_t *list) -{ - apr_bucket *b = apr_bucket_alloc(sizeof(*b), list); - - APR_BUCKET_INIT(b); - b->free = apr_bucket_free; - b->list = list; - return apr_bucket_immortal_make(b, buf, length); -} - -/* - * XXX: This function could do with some tweaking to reduce memory - * usage in various cases, e.g. share buffers in the heap between all - * the buckets that are set aside, or even spool set-aside data to - * disk if it gets too voluminous (but if it does then that's probably - * a bug elsewhere). There should probably be a apr_brigade_setaside() - * function that co-ordinates the action of all the bucket setaside - * functions to improve memory efficiency. - */ -static apr_status_t transient_bucket_setaside(apr_bucket *b, apr_pool_t *pool) -{ - b = apr_bucket_heap_make(b, (char *)b->data + b->start, b->length, NULL); - if (b == NULL) { - return APR_ENOMEM; - } - return APR_SUCCESS; -} - -APU_DECLARE(apr_bucket *) apr_bucket_transient_make(apr_bucket *b, - const char *buf, - apr_size_t length) -{ - b->data = (char *)buf; - b->length = length; - b->start = 0; - b->type = &apr_bucket_type_transient; - return b; -} - -APU_DECLARE(apr_bucket *) apr_bucket_transient_create(const char *buf, - apr_size_t length, - apr_bucket_alloc_t *list) -{ - apr_bucket *b = apr_bucket_alloc(sizeof(*b), list); - - APR_BUCKET_INIT(b); - b->free = apr_bucket_free; - b->list = list; - return apr_bucket_transient_make(b, buf, length); -} - -const apr_bucket_type_t apr_bucket_type_immortal = { - "IMMORTAL", 5, APR_BUCKET_DATA, - apr_bucket_destroy_noop, - simple_bucket_read, - apr_bucket_setaside_noop, - apr_bucket_simple_split, - apr_bucket_simple_copy -}; - -APU_DECLARE_DATA const apr_bucket_type_t apr_bucket_type_transient = { - "TRANSIENT", 5, APR_BUCKET_DATA, - apr_bucket_destroy_noop, - simple_bucket_read, - transient_bucket_setaside, - apr_bucket_simple_split, - apr_bucket_simple_copy -}; diff --git a/libs/apr-util/buckets/apr_buckets_socket.c b/libs/apr-util/buckets/apr_buckets_socket.c deleted file mode 100644 index 7885d08efb..0000000000 --- a/libs/apr-util/buckets/apr_buckets_socket.c +++ /dev/null @@ -1,114 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_buckets.h" - -static apr_status_t socket_bucket_read(apr_bucket *a, const char **str, - apr_size_t *len, apr_read_type_e block) -{ - apr_socket_t *p = a->data; - char *buf; - apr_status_t rv; - apr_interval_time_t timeout; - - if (block == APR_NONBLOCK_READ) { - apr_socket_timeout_get(p, &timeout); - apr_socket_timeout_set(p, 0); - } - - *str = NULL; - *len = APR_BUCKET_BUFF_SIZE; - buf = apr_bucket_alloc(*len, a->list); /* XXX: check for failure? */ - - rv = apr_socket_recv(p, buf, len); - - if (block == APR_NONBLOCK_READ) { - apr_socket_timeout_set(p, timeout); - } - - if (rv != APR_SUCCESS && rv != APR_EOF) { - apr_bucket_free(buf); - return rv; - } - /* - * If there's more to read we have to keep the rest of the socket - * for later. XXX: Note that more complicated bucket types that - * refer to data not in memory and must therefore have a read() - * function similar to this one should be wary of copying this - * code because if they have a destroy function they probably - * want to migrate the bucket's subordinate structure from the - * old bucket to a raw new one and adjust it as appropriate, - * rather than destroying the old one and creating a completely - * new bucket. - * - * Even if there is nothing more to read, don't close the socket here - * as we have to use it to send any response :) We could shut it - * down for reading, but there is no benefit to doing so. - */ - if (*len > 0) { - apr_bucket_heap *h; - /* Change the current bucket to refer to what we read */ - a = apr_bucket_heap_make(a, buf, *len, apr_bucket_free); - h = a->data; - h->alloc_len = APR_BUCKET_BUFF_SIZE; /* note the real buffer size */ - *str = buf; - APR_BUCKET_INSERT_AFTER(a, apr_bucket_socket_create(p, a->list)); - } - else { - apr_bucket_free(buf); - a = apr_bucket_immortal_make(a, "", 0); - *str = a->data; - } - return APR_SUCCESS; -} - -APU_DECLARE(apr_bucket *) apr_bucket_socket_make(apr_bucket *b, apr_socket_t *p) -{ - /* - * XXX: We rely on a cleanup on some pool or other to actually - * destroy the socket. We should probably explicitly call apr to - * destroy it instead. - * - * Note that typically the socket is allocated from the connection pool - * so it will disappear when the connection is finished. - */ - b->type = &apr_bucket_type_socket; - b->length = (apr_size_t)(-1); - b->start = -1; - b->data = p; - - return b; -} - -APU_DECLARE(apr_bucket *) apr_bucket_socket_create(apr_socket_t *p, - apr_bucket_alloc_t *list) -{ - apr_bucket *b = apr_bucket_alloc(sizeof(*b), list); - - APR_BUCKET_INIT(b); - b->free = apr_bucket_free; - b->list = list; - return apr_bucket_socket_make(b, p); -} - -APU_DECLARE_DATA const apr_bucket_type_t apr_bucket_type_socket = { - "SOCKET", 5, APR_BUCKET_DATA, - apr_bucket_destroy_noop, - socket_bucket_read, - apr_bucket_setaside_notimpl, - apr_bucket_split_notimpl, - apr_bucket_copy_notimpl -}; diff --git a/libs/apr-util/build-outputs.mk b/libs/apr-util/build-outputs.mk deleted file mode 100644 index d42cda80ff..0000000000 --- a/libs/apr-util/build-outputs.mk +++ /dev/null @@ -1,40 +0,0 @@ -# DO NOT EDIT. AUTOMATICALLY GENERATED. - -crypto/apr_md5.lo: crypto/apr_md5.c .make.dirs include/apr_xlate.h include/apr_md5.h include/apr_sha1.h -crypto/uuid.lo: crypto/uuid.c .make.dirs include/apr_uuid.h -crypto/apr_sha1.lo: crypto/apr_sha1.c .make.dirs include/apr_xlate.h include/apr_sha1.h include/apr_base64.h -crypto/getuuid.lo: crypto/getuuid.c .make.dirs include/apr_uuid.h include/apr_md5.h include/apr_xlate.h -crypto/apr_md4.lo: crypto/apr_md4.c .make.dirs include/apr_md4.h include/apr_xlate.h -encoding/apr_base64.lo: encoding/apr_base64.c .make.dirs include/apr_base64.h include/apr_xlate.h -hooks/apr_hooks.lo: hooks/apr_hooks.c .make.dirs include/apr_optional_hooks.h include/apr_optional.h include/apr_hooks.h -misc/apr_reslist.lo: misc/apr_reslist.c .make.dirs include/apr_reslist.h -misc/apr_rmm.lo: misc/apr_rmm.c .make.dirs include/apr_rmm.h include/apr_anylock.h -misc/apr_date.lo: misc/apr_date.c .make.dirs include/apr_date.h -misc/apu_version.lo: misc/apu_version.c .make.dirs include/apu_version.h -misc/apr_queue.lo: misc/apr_queue.c .make.dirs include/apr_queue.h -uri/apr_uri.lo: uri/apr_uri.c .make.dirs include/apr_uri.h -xml/apr_xml.lo: xml/apr_xml.c .make.dirs include/apr_xml.h include/apr_xlate.h -strmatch/apr_strmatch.lo: strmatch/apr_strmatch.c .make.dirs include/apr_strmatch.h -xlate/xlate.lo: xlate/xlate.c .make.dirs include/apr_xlate.h - -OBJECTS_all = crypto/apr_md5.lo crypto/uuid.lo crypto/apr_sha1.lo crypto/getuuid.lo crypto/apr_md4.lo encoding/apr_base64.lo hooks/apr_hooks.lo misc/apr_reslist.lo misc/apr_rmm.lo misc/apr_date.lo misc/apu_version.lo misc/apr_queue.lo uri/apr_uri.lo xml/apr_xml.lo strmatch/apr_strmatch.lo xlate/xlate.lo - -OBJECTS_unix = $(OBJECTS_all) - -OBJECTS_aix = $(OBJECTS_all) - -OBJECTS_beos = $(OBJECTS_all) - -OBJECTS_os2 = $(OBJECTS_all) - -OBJECTS_os390 = $(OBJECTS_all) - -HEADERS = $(top_srcdir)/include/apr_optional.h $(top_srcdir)/include/apu_version.h $(top_srcdir)/include/apr_strmatch.h $(top_srcdir)/include/apr_optional_hooks.h $(top_srcdir)/include/apr_sdbm.h $(top_srcdir)/include/apr_md4.h $(top_srcdir)/include/apr_reslist.h $(top_srcdir)/include/apr_base64.h $(top_srcdir)/include/apr_xml.h $(top_srcdir)/include/apr_anylock.h $(top_srcdir)/include/apr_rmm.h $(top_srcdir)/include/apr_md5.h $(top_srcdir)/include/apr_date.h $(top_srcdir)/include/apr_hooks.h $(top_srcdir)/include/apr_xlate.h $(top_srcdir)/include/apr_queue.h $(top_srcdir)/include/apr_uri.h $(top_srcdir)/include/apr_uuid.h $(top_srcdir)/include/apr_sha1.h - -SOURCE_DIRS = xml encoding hooks misc crypto uri strmatch xlate $(EXTRA_SOURCE_DIRS) - -BUILD_DIRS = crypto encoding hooks misc strmatch uri xlate xml - -.make.dirs: $(srcdir)/build-outputs.mk - @for d in $(BUILD_DIRS); do test -d $$d || mkdir $$d; done - @echo timestamp > $@ diff --git a/libs/apr-util/build.conf b/libs/apr-util/build.conf deleted file mode 100644 index 066009fdaa..0000000000 --- a/libs/apr-util/build.conf +++ /dev/null @@ -1,32 +0,0 @@ -# -# Configuration file for APRUTIL. Used by APR/build/gen-build.py -# - -[options] - -# the platform-independent .c files -paths = - buckets/*.c - crypto/*.c - dbm/*.c - dbm/sdbm/*.c - encoding/*.c - hooks/*.c - ldap/*.c - misc/*.c - uri/apr_uri.c - xml/*.c - strmatch/*.c - xlate/*.c - dbd/*.c - -# we have no platform-specific subdirs -platform_dirs = - -# the public headers -headers = include/*.h - -# gen_uri_delim.c - -# we have a recursive makefile for the test files (for now) -# test/*.c diff --git a/libs/apr-util/build/apu-conf.m4 b/libs/apr-util/build/apu-conf.m4 deleted file mode 100644 index b78b038e7b..0000000000 --- a/libs/apr-util/build/apu-conf.m4 +++ /dev/null @@ -1,435 +0,0 @@ -dnl -------------------------------------------------------- -*- autoconf -*- -dnl Copyright 2000-2005 The Apache Software Foundation or its licensors, as -dnl applicable. -dnl -dnl Licensed under the Apache License, Version 2.0 (the "License"); -dnl you may not use this file except in compliance with the License. -dnl You may obtain a copy of the License at -dnl -dnl http://www.apache.org/licenses/LICENSE-2.0 -dnl -dnl Unless required by applicable law or agreed to in writing, software -dnl distributed under the License is distributed on an "AS IS" BASIS, -dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -dnl See the License for the specific language governing permissions and -dnl limitations under the License. - - -dnl -dnl custom autoconf rules for APRUTIL -dnl - -dnl -dnl APU_FIND_APR: figure out where APR is located -dnl -AC_DEFUN([APU_FIND_APR], [ - - dnl use the find_apr.m4 script to locate APR. sets apr_found and apr_config - APR_FIND_APR(,,,[1]) - if test "$apr_found" = "no"; then - AC_MSG_ERROR(APR could not be located. Please use the --with-apr option.) - fi - - APR_BUILD_DIR="`$apr_config --installbuilddir`" - - dnl make APR_BUILD_DIR an absolute directory (we'll need it in the - dnl sub-projects in some cases) - APR_BUILD_DIR="`cd $APR_BUILD_DIR && pwd`" - - APR_INCLUDES="`$apr_config --includes`" - APR_LIBS="`$apr_config --link-libtool --libs`" - APR_SO_EXT="`$apr_config --apr-so-ext`" - APR_LIB_TARGET="`$apr_config --apr-lib-target`" - - AC_SUBST(APR_INCLUDES) - AC_SUBST(APR_LIBS) - AC_SUBST(APR_BUILD_DIR) -]) - - -dnl -dnl APU_TEST_EXPAT(directory): test if Expat is located in the specified dir -dnl -dnl if present: sets expat_include_dir, expat_libs, possibly expat_old -dnl -AC_DEFUN([APU_TEST_EXPAT], [ - AC_MSG_CHECKING(for Expat in ifelse($2,,$1,$2)) - - expat_libtool="" - - if test -r "$1/lib/expat.h.in"; then - dnl Expat 1.95.* distribution - expat_include_dir="$1/lib" - expat_ldflags="-L$1/lib" - expat_libs="-lexpat" - expat_libtool="$1/lib/libexpat.la" - elif test -r "$1/include/expat.h" -a \ - -r "$1/lib/libexpat.la"; then - dnl Expat 1.95.* installation (with libtool) - expat_include_dir="$1/include" - expat_ldflags="-L$1/lib" - expat_libs="-lexpat" - expat_libtool="$1/lib/libexpat.la" - elif test -r "$1/include/expat.h" -a \ - -r "$1/lib64/libexpat.la"; then - dnl Expat 1.95.* installation on certain 64-bit platforms (with libtool) - expat_include_dir="$1/include" - expat_ldflags="-L$1/lib64" - expat_libs="-lexpat" - expat_libtool="$1/lib64/libexpat.la" - elif test -r "$1/include/expat.h" -a \ - -r "$1/lib/libexpat.a"; then - dnl Expat 1.95.* installation (without libtool) - dnl FreeBSD textproc/expat2 - expat_include_dir="$1/include" - expat_ldflags="-L$1/lib" - expat_libs="-lexpat" - elif test -r "$1/xmlparse.h"; then - dnl maybe an expat-lite. use this dir for both includes and libs - expat_include_dir="$1" - expat_ldflags="-L$1" - expat_libs="-lexpat" - expat_libtool="$1/libexpat.la" - expat_old=yes - elif test -r "$1/include/xmlparse.h" -a \ - -r "$1/lib/libexpat.a"; then - dnl previously installed expat - expat_include_dir="$1/include" - expat_ldflags="-L$1/lib" - expat_libs="-lexpat" - expat_old=yes - elif test -r "$1/include/xml/xmlparse.h" -a \ - -r "$1/lib/xml/libexpat.a"; then - dnl previously installed expat - expat_include_dir="$1/include/xml" - expat_ldflags="-L$1/lib" - expat_libs="-lexpat" - expat_old=yes - elif test -r "$1/include/xmltok/xmlparse.h"; then - dnl Debian distribution - expat_include_dir="$1/include/xmltok" - expat_ldflags="-L$1/lib" - expat_libs="-lxmlparse -lxmltok" - expat_old=yes - elif test -r "$1/include/xml/xmlparse.h" -a \ - -r "$1/lib/libexpat.a"; then - dnl FreeBSD textproc/expat package - expat_include_dir="$1/include/xml" - expat_ldflags="-L$1/lib" - expat_libs="-lexpat" - expat_old=yes - elif test -r "$1/xmlparse/xmlparse.h"; then - dnl Expat 1.0 or 1.1 source directory - expat_include_dir="$1/xmlparse" - expat_ldflags="-L$1" - expat_libs="-lexpat" - expat_old=yes - fi - dnl ### test for installed Expat 1.95.* distros - - if test -n "$expat_include_dir"; then - dnl ### more info about what we found there? version? using .la? - AC_MSG_RESULT(yes) - else - AC_MSG_RESULT(no) - fi -]) - - -dnl -dnl APU_FIND_EXPAT: figure out where EXPAT is located (or use bundled) -dnl -AC_DEFUN([APU_FIND_EXPAT], [ - -AC_ARG_WITH([expat], -[ --with-expat=DIR specify Expat location or 'builtin'], [ - if test "$withval" = "yes"; then - AC_MSG_ERROR([a directory must be specified for --with-expat]) - elif test "$withval" = "no"; then - AC_MSG_ERROR([Expat cannot be disabled (at this time)]) - elif test "$withval" = "builtin"; then - abs_expatdir="`cd $srcdir/xml/expat && pwd`" - if test -d $abs_expatdir/. -a ! -d xml/expat/.; then - $mkdir_p xml/expat - fi - APU_TEST_EXPAT($abs_expatdir, xml/expat) - else - abs_expatdir="`cd $withval && pwd`" - APU_TEST_EXPAT($abs_expatdir, $withval) - if test -z "$expat_include_dir"; then - AC_MSG_ERROR([Expat was not found (or recognized) in \"$withval\"]) - fi - fi -]) - -if test -z "$expat_include_dir"; then - for d in /usr /usr/local xml/expat-cvs xml/expat $srcdir/xml/expat ; do - APU_TEST_EXPAT($d) - if test -n "$expat_include_dir"; then - dnl For /usr installs of expat, we can't specify -L/usr/lib - if test "$d" = "/usr"; then - expat_ldflags="" - fi - break - fi - done -fi -if test -z "$expat_include_dir"; then - AC_MSG_ERROR([could not locate Expat. use --with-expat]) -fi - -dnl If this expat doesn't use libtool natively, we'll mimic it for our -dnl dependency library generation. -if test -z "$expat_libtool"; then - expat_libtool="$expat_ldflags $expat_libs" -fi - -if test -n "$expat_old"; then - AC_DEFINE(APR_HAVE_OLD_EXPAT, 1, [define if Expat 1.0 or 1.1 was found]) -fi - -dnl special-case the bundled distribution (use absolute dirs) -if test "$expat_include_dir" = "xml/expat/lib" -o "$expat_include_dir" = "xml/expat-cvs/lib"; then - bundled_subdir="`echo $expat_include_dir | sed -e 's%/lib%%'`" - APR_SUBDIR_CONFIG($bundled_subdir, [--prefix=$prefix --exec-prefix=$exec_prefix --libdir=$libdir --includedir=$includedir --bindir=$bindir]) - expat_include_dir=$top_builddir/$bundled_subdir/lib - expat_ldflags="-L$top_builddir/$bundled_subdir/lib" - expat_libs="-lexpat" - expat_libtool=$top_builddir/$bundled_subdir/lib/libexpat.la - APR_XML_SUBDIRS="`echo $bundled_subdir | sed -e 's%xml/%%'`" - APR_ADDTO(APRUTIL_EXPORT_LIBS, [$expat_libtool]) -else -if test "$expat_include_dir" = "$abs_srcdir/xml/expat/include" -o "$expat_include_dir" = "$abs_srcdir/xml/expat/lib"; then - dnl This is a bit of a hack. This only works because we know that - dnl we are working with the bundled version of the software. - bundled_subdir="xml/expat" - APR_SUBDIR_CONFIG($bundled_subdir, [--prefix=$prefix --exec-prefix=$exec_prefix --libdir=$libdir --includedir=$includedir --bindir=$bindir]) - expat_include_dir=$top_builddir/$bundled_subdir/lib - expat_ldflags="-L$top_builddir/$bundled_subdir/lib" - expat_libs="-lexpat" - expat_libtool=$top_builddir/$bundled_subdir/lib/libexpat.la - APR_XML_SUBDIRS="`echo $bundled_subdir | sed -e 's%xml/%%'`" - APR_ADDTO(APRUTIL_EXPORT_LIBS, [$expat_libtool]) -else - APR_ADDTO(APRUTIL_EXPORT_LIBS, [$expat_libs]) -fi -fi -APR_XML_DIR=$bundled_subdir -APR_XML_EXPAT_OLD=$expat_old -AC_SUBST(APR_XML_SUBDIRS) -AC_SUBST(APR_XML_DIR) -AC_SUBST(APR_XML_EXPAT_OLD) - -if test "$expat_include_dir" != "/usr/include"; then - APR_ADDTO(APRUTIL_INCLUDES, [-I$expat_include_dir]) -fi -APR_ADDTO(APRUTIL_LDFLAGS, [$expat_ldflags]) -APR_ADDTO(APRUTIL_LIBS, [$expat_libtool]) -]) - - -dnl -dnl Find a particular LDAP library -dnl -AC_DEFUN([APU_FIND_LDAPLIB], [ - if test ${apu_has_ldap} != "1"; then - ldaplib=$1 - extralib=$2 - unset ac_cv_lib_${ldaplib}_ldap_init - unset ac_cv_lib_${ldaplib}___ldap_init - AC_CHECK_LIB(${ldaplib}, ldap_init, - [ - APR_ADDTO(APRUTIL_EXPORT_LIBS,[-l${ldaplib} ${extralib}]) - APR_ADDTO(APRUTIL_LIBS,[-l${ldaplib} ${extralib}]) - AC_CHECK_LIB(${ldaplib}, ldapssl_client_init, apu_has_ldapssl_client_init="1", , ${extralib}) - AC_CHECK_LIB(${ldaplib}, ldapssl_client_deinit, apu_has_ldapssl_client_deinit="1", , ${extralib}) - AC_CHECK_LIB(${ldaplib}, ldapssl_add_trusted_cert, apu_has_ldapssl_add_trusted_cert="1", , ${extralib}) - AC_CHECK_LIB(${ldaplib}, ldap_start_tls_s, apu_has_ldap_start_tls_s="1", , ${extralib}) - AC_CHECK_LIB(${ldaplib}, ldap_sslinit, apu_has_ldap_sslinit="1", , ${extralib}) - AC_CHECK_LIB(${ldaplib}, ldapssl_init, apu_has_ldapssl_init="1", , ${extralib}) - AC_CHECK_LIB(${ldaplib}, ldapssl_install_routines, apu_has_ldapssl_install_routines="1", , ${extralib}) - apu_has_ldap="1"; - ], , ${extralib}) - fi -]) - - -dnl -dnl APU_FIND_LDAP: figure out where LDAP is located -dnl -AC_DEFUN([APU_FIND_LDAP], [ - -echo $ac_n "${nl}checking for ldap support..." - -apu_has_ldap="0"; -apu_has_ldapssl_client_init="0" -apu_has_ldapssl_client_deinit="0" -apu_has_ldapssl_add_trusted_cert="0" -apu_has_ldap_start_tls_s="0" -apu_has_ldapssl_init="0" -apu_has_ldap_sslinit="0" -apu_has_ldapssl_install_routines="0" -apu_has_ldap_openldap="0" -apu_has_ldap_solaris="0" -apu_has_ldap_novell="0" -apu_has_ldap_microsoft="0" -apu_has_ldap_netscape="0" -apu_has_ldap_mozilla="0" -apu_has_ldap_other="0" - -AC_ARG_WITH(ldap-include,[ --with-ldap-include=path path to ldap include files with trailing slash]) -AC_ARG_WITH(ldap-lib,[ --with-ldap-lib=path path to ldap lib file]) -AC_ARG_WITH(ldap,[ --with-ldap=library ldap library to use], - [ - save_cppflags="$CPPFLAGS" - save_ldflags="$LDFLAGS" - save_libs="$LIBS" - if test -n "$with_ldap_include"; then - CPPFLAGS="$CPPFLAGS -I$with_ldap_include" - APR_ADDTO(APRUTIL_INCLUDES, [-I$with_ldap_include]) - fi - if test -n "$with_ldap_lib"; then - LDFLAGS="$LDFLAGS -L$with_ldap_lib" - APR_ADDTO(APRUTIL_LDFLAGS, [-L$with_ldap_lib]) - fi - - LIBLDAP="$withval" - if test "$LIBLDAP" = "yes"; then -dnl The iPlanet C SDK 5.0 is as yet untested... - APU_FIND_LDAPLIB("ldap50", "-lnspr4 -lplc4 -lplds4 -liutil50 -llber50 -lldif50 -lnss3 -lprldap50 -lssl3 -lssldap50") - APU_FIND_LDAPLIB("ldapssl41", "-lnspr3 -lplc3 -lplds3") - APU_FIND_LDAPLIB("ldapssl40") - APU_FIND_LDAPLIB("ldapssl30") - APU_FIND_LDAPLIB("ldapssl20") - APU_FIND_LDAPLIB("ldapsdk", "-lldapx -lldapssl -lldapgss -lgssapi_krb5") - APU_FIND_LDAPLIB("ldapsdk", "-lldapx -lldapssl -lldapgss -lgss -lresolv -lsocket") - APU_FIND_LDAPLIB("ldap", "-llber") - APU_FIND_LDAPLIB("ldap", "-llber -lresolv") - APU_FIND_LDAPLIB("ldap", "-llber -lresolv -lsocket -lnsl") - APU_FIND_LDAPLIB("ldap", "-ldl -lpthread") - else - APU_FIND_LDAPLIB($LIBLDAP) - APU_FIND_LDAPLIB($LIBLDAP, "-lresolv") - APU_FIND_LDAPLIB($LIBLDAP, "-lresolv -lsocket -lnsl") - APU_FIND_LDAPLIB($LIBLDAP, "-ldl -lpthread") - fi - - test ${apu_has_ldap} != "1" && AC_MSG_ERROR(could not find an LDAP library) - AC_CHECK_LIB(lber, ber_init) - - AC_CHECK_HEADERS(lber.h, lber_h=["#include "]) - - # Solaris has a problem in which prevents it from - # being included by itself. Check for manually, - # including lber.h first. - AC_CACHE_CHECK([for ldap.h], [apr_cv_hdr_ldap_h], - [AC_TRY_CPP( - [#ifdef HAVE_LBER_H - #include - #endif - #include - ], [apr_cv_hdr_ldap_h=yes], [apr_cv_hdr_ldap_h=no])]) - if test "$apr_cv_hdr_ldap_h" = "yes"; then - ldap_h=["#include "] - AC_DEFINE([HAVE_LDAP_H], 1, [Defined if ldap.h is present]) - fi - - AC_CHECK_HEADERS(ldap_ssl.h, ldap_ssl_h=["#include "]) - - if test "$apr_cv_hdr_ldap_h" = "yes"; then - AC_CACHE_CHECK([for LDAP toolkit], - [apr_cv_ldap_toolkit], [ - if test "x$apr_cv_ldap_toolkit" = "x"; then - AC_EGREP_CPP([OpenLDAP], [$lber_h - $ldap_h - LDAP_VENDOR_NAME], [apu_has_ldap_openldap="1" - apr_cv_ldap_toolkit="OpenLDAP"]) - fi - if test "x$apr_cv_ldap_toolkit" = "x"; then - AC_EGREP_CPP([Sun Microsystems Inc.], [$lber_h - $ldap_h - LDAP_VENDOR_NAME], [apu_has_ldap_solaris="1" - apr_cv_ldap_toolkit="Solaris"]) - fi - if test "x$apr_cv_ldap_toolkit" = "x"; then - AC_EGREP_CPP([Novell], [$lber_h - $ldap_h - LDAP_VENDOR_NAME], [apu_has_ldap_novell="1" - apr_cv_ldap_toolkit="Novell"]) - fi - if test "x$apr_cv_ldap_toolkit" = "x"; then - AC_EGREP_CPP([Microsoft Corporation.], [$lber_h - $ldap_h - LDAP_VENDOR_NAME], [apu_has_ldap_microsoft="1" - apr_cv_ldap_toolkit="Microsoft"]) - fi - if test "x$apr_cv_ldap_toolkit" = "x"; then - AC_EGREP_CPP([Netscape Communications Corp.], [$lber_h - $ldap_h - LDAP_VENDOR_NAME], [apu_has_ldap_netscape="1" - apr_cv_ldap_toolkit="Netscape"]) - fi - if test "x$apr_cv_ldap_toolkit" = "x"; then - AC_EGREP_CPP([mozilla.org], [$lber_h - $ldap_h - LDAP_VENDOR_NAME], [apu_has_ldap_mozilla="1" - apr_cv_ldap_toolkit="Mozilla"]) - fi - if test "x$apr_cv_ldap_toolkit" = "x"; then - apu_has_ldap_other="1" - apr_cv_ldap_toolkit="unknown" - fi - ]) - fi - - CPPFLAGS=$save_cppflags - LDFLAGS=$save_ldflags - LIBS=$save_libs - ]) - -AC_SUBST(ldap_h) -AC_SUBST(lber_h) -AC_SUBST(ldap_ssl_h) -AC_SUBST(apu_has_ldapssl_client_init) -AC_SUBST(apu_has_ldapssl_client_deinit) -AC_SUBST(apu_has_ldapssl_add_trusted_cert) -AC_SUBST(apu_has_ldap_start_tls_s) -AC_SUBST(apu_has_ldapssl_init) -AC_SUBST(apu_has_ldap_sslinit) -AC_SUBST(apu_has_ldapssl_install_routines) -AC_SUBST(apu_has_ldap) -AC_SUBST(apu_has_ldap_openldap) -AC_SUBST(apu_has_ldap_solaris) -AC_SUBST(apu_has_ldap_novell) -AC_SUBST(apu_has_ldap_microsoft) -AC_SUBST(apu_has_ldap_netscape) -AC_SUBST(apu_has_ldap_mozilla) -AC_SUBST(apu_has_ldap_other) - -]) - -dnl -dnl APU_CHECK_CRYPT_R_STYLE -dnl -dnl Decide which of a couple of flavors of crypt_r() is necessary for -dnl this platform. -dnl -AC_DEFUN([APU_CHECK_CRYPT_R_STYLE], [ - -AC_CACHE_CHECK([style of crypt_r], apr_cv_crypt_r_style, -[AC_TRY_COMPILE([#include ], - [CRYPTD buffer; - crypt_r("passwd", "hash", &buffer);], - [apr_cv_crypt_r_style=cryptd], - [AC_TRY_COMPILE([#include ], - [struct crypt_data buffer; - crypt_r("passwd", "hash", &buffer);], - [apr_cv_crypt_r_style=struct_crypt_data], - [apr_cv_crypt_r_style=none])])]) - -if test "$apr_cv_crypt_r_style" = "cryptd"; then - AC_DEFINE(CRYPT_R_CRYPTD, 1, [Define if crypt_r has uses CRYPTD]) -elif test "$apr_cv_crypt_r_style" = "struct_crypt_data"; then - AC_DEFINE(CRYPT_R_STRUCT_CRYPT_DATA, 1, [Define if crypt_r uses struct crypt_data]) -fi -]) diff --git a/libs/apr-util/build/apu-hints.m4 b/libs/apr-util/build/apu-hints.m4 deleted file mode 100644 index 20878d3275..0000000000 --- a/libs/apr-util/build/apu-hints.m4 +++ /dev/null @@ -1,61 +0,0 @@ -dnl -------------------------------------------------------- -*- autoconf -*- -dnl Copyright 2003-2005 The Apache Software Foundation or its licensors, as -dnl applicable. -dnl -dnl Licensed under the Apache License, Version 2.0 (the "License"); -dnl you may not use this file except in compliance with the License. -dnl You may obtain a copy of the License at -dnl -dnl http://www.apache.org/licenses/LICENSE-2.0 -dnl -dnl Unless required by applicable law or agreed to in writing, software -dnl distributed under the License is distributed on an "AS IS" BASIS, -dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -dnl See the License for the specific language governing permissions and -dnl limitations under the License. - -dnl ----------------------------------------------------------------- -dnl apu-hints.m4: apr-util's autoconf macros for platform-specific hints -dnl -dnl We preload various configure settings depending -dnl on previously obtained platform knowledge. -dnl We allow all settings to be overridden from -dnl the command-line. - -dnl -dnl APU_PRELOAD -dnl -dnl Preload various build parameters based on outside knowledge. -dnl -AC_DEFUN([APU_PRELOAD], [ -if test "x$apu_preload_done" != "xyes" ; then - apu_preload_done="yes" - - echo "Applying apr-util hints file rules for $host" - - case "$host" in - *-dec-osf*) - APR_SETIFNULL(apu_crypt_threadsafe, [1]) - ;; - *-hp-hpux11.*) - APR_SETIFNULL(apu_crypt_threadsafe, [1]) - ;; - *-ibm-aix4*|*-ibm-aix5.1*) - APR_SETIFNULL(apu_iconv_inbuf_const, [1]) - ;; - *-ibm-os390) - APR_SETIFNULL(apu_crypt_threadsafe, [1]) - ;; - *-solaris2*) - APR_SETIFNULL(apu_iconv_inbuf_const, [1]) - APR_SETIFNULL(apu_crypt_threadsafe, [1]) - ;; - *-sco3.2v5*) - APR_SETIFNULL(apu_db_xtra_libs, [-lsocket]) - ;; - esac - -fi -]) - - diff --git a/libs/apr-util/build/apu-iconv.m4 b/libs/apr-util/build/apu-iconv.m4 deleted file mode 100644 index b27b75cec7..0000000000 --- a/libs/apr-util/build/apu-iconv.m4 +++ /dev/null @@ -1,123 +0,0 @@ -dnl -------------------------------------------------------- -*- autoconf -*- -dnl Copyright 2002-2005 The Apache Software Foundation, or its licensors, as -dnl applicable. -dnl -dnl Licensed under the Apache License, Version 2.0 (the "License"); -dnl you may not use this file except in compliance with the License. -dnl You may obtain a copy of the License at -dnl -dnl http://www.apache.org/licenses/LICENSE-2.0 -dnl -dnl Unless required by applicable law or agreed to in writing, software -dnl distributed under the License is distributed on an "AS IS" BASIS, -dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -dnl See the License for the specific language governing permissions and -dnl limitations under the License. - -dnl -dnl APU_TRY_ICONV[ IF-SUCCESS, IF-FAILURE ]: try to compile for iconv. -dnl -AC_DEFUN([APU_TRY_ICONV], [ - AC_TRY_LINK([ -#include -#include -], -[ - iconv_t cd = iconv_open("", ""); - iconv(cd, NULL, NULL, NULL, NULL); -], [$1], [$2]) -]) - -dnl -dnl APU_FIND_ICONV: find an iconv library -dnl -AC_DEFUN([APU_FIND_ICONV], [ - -apu_iconv_dir="unknown" -have_apr_iconv="0" -AC_ARG_WITH(iconv,[ --with-iconv[=DIR] path to iconv installation], - [ apu_iconv_dir="$withval" - if test "$apu_iconv_dir" != "yes"; then - APR_ADDTO(CPPFLAGS,[-I$apu_iconv_dir/include]) - APR_ADDTO(LDFLAGS,[-L$apu_iconv_dir/lib]) - fi - if test -f "$apu_iconv_dir/include/api_version.h"; then - have_apr_iconv="1" - have_iconv="0" - APR_REMOVEFROM(LIBS,[-lapriconv]) - AC_MSG_RESULT("Using apr-iconv") - fi - ]) - -if test "$have_apr_iconv" != "1"; then - AC_CHECK_HEADER(iconv.h, [ - APU_TRY_ICONV([ have_iconv="1" ], [ - - APR_ADDTO(LIBS,[-liconv]) - - APU_TRY_ICONV([ - APR_ADDTO(APRUTIL_LIBS,[-liconv]) - APR_ADDTO(APRUTIL_EXPORT_LIBS,[-liconv]) - have_iconv="1" ], - [ have_iconv="0" ]) - - APR_REMOVEFROM(LIBS,[-liconv]) - - ]) - ], [ have_iconv="0" ]) -fi - -if test "$apu_iconv_dir" != "unknown"; then - if test "$have_iconv" != "1"; then - if test "$have_apr_iconv" != "1"; then - AC_MSG_ERROR([iconv support requested, but not found]) - fi - fi - APR_REMOVEFROM(CPPFLAGS,[-I$apu_iconv_dir/include]) - APR_REMOVEFROM(LDFLAGS,[-L$apu_iconv_dir/lib]) - APR_ADDTO(APRUTIL_INCLUDES,[-I$apu_iconv_dir/include]) - APR_ADDTO(APRUTIL_LDFLAGS,[-L$apu_iconv_dir/lib]) -fi - -if test "$have_iconv" = "1"; then - APU_CHECK_ICONV_INBUF -fi - -APR_FLAG_HEADERS(iconv.h langinfo.h) -APR_FLAG_FUNCS(nl_langinfo) -APR_CHECK_DEFINE(CODESET, langinfo.h, [CODESET defined in langinfo.h]) - -AC_SUBST(have_iconv) -AC_SUBST(have_apr_iconv) -])dnl - -dnl -dnl APU_CHECK_ICONV_INBUF -dnl -dnl Decide whether or not the inbuf parameter to iconv() is const. -dnl -dnl We try to compile something without const. If it fails to -dnl compile, we assume that the system's iconv() has const. -dnl Unfortunately, we won't realize when there was a compile -dnl warning, so we allow a variable -- apu_iconv_inbuf_const -- to -dnl be set in hints.m4 to specify whether or not iconv() has const -dnl on this parameter. -dnl -AC_DEFUN([APU_CHECK_ICONV_INBUF], [ -AC_MSG_CHECKING(for type of inbuf parameter to iconv) -if test "x$apu_iconv_inbuf_const" = "x"; then - APR_TRY_COMPILE_NO_WARNING([ - #include - #include - ],[ - iconv(0,(char **)0,(size_t *)0,(char **)0,(size_t *)0); - ], apu_iconv_inbuf_const="0", apu_iconv_inbuf_const="1") -fi -if test "$apu_iconv_inbuf_const" = "1"; then - AC_DEFINE(APU_ICONV_INBUF_CONST, 1, [Define if the inbuf parm to iconv() is const char **]) - msg="const char **" -else - msg="char **" -fi -AC_MSG_RESULT([$msg]) -])dnl diff --git a/libs/apr-util/build/dbd.m4 b/libs/apr-util/build/dbd.m4 deleted file mode 100644 index 076efb51e6..0000000000 --- a/libs/apr-util/build/dbd.m4 +++ /dev/null @@ -1,278 +0,0 @@ -dnl -------------------------------------------------------- -*- autoconf -*- -dnl Copyright 2005 The Apache Software Foundation or its licensors, as -dnl applicable. -dnl -dnl Licensed under the Apache License, Version 2.0 (the "License"); -dnl you may not use this file except in compliance with the License. -dnl You may obtain a copy of the License at -dnl -dnl http://www.apache.org/licenses/LICENSE-2.0 -dnl -dnl Unless required by applicable law or agreed to in writing, software -dnl distributed under the License is distributed on an "AS IS" BASIS, -dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -dnl See the License for the specific language governing permissions and -dnl limitations under the License. - -dnl -dnl DBD module -dnl - -dnl -dnl APU_CHECK_DBD: compile backends for apr_dbd. -dnl -AC_DEFUN([APU_CHECK_DBD], [ - apu_have_pgsql=0 - - AC_ARG_WITH([pgsql], [ - --with-pgsql=DIR specify PostgreSQL location - ], [ - apu_have_pgsql=0 - if test "$withval" = "yes"; then - AC_CHECK_HEADERS(libpq-fe.h, AC_CHECK_LIB(pq, PQsendQueryPrepared, [apu_have_pgsql=1])) - if test "$apu_have_pgsql" = "0"; then - AC_CHECK_HEADERS(postgresql/libpq-fe.h, AC_CHECK_LIB(pq, PQsendQueryPrepared, [apu_have_pgsql=1])) - fi - elif test "$withval" = "no"; then - apu_have_pgsql=0 - else - old_cppflags="$CPPFLAGS" - old_ldflags="$LDFLAGS" - - pgsql_CPPFLAGS="-I$withval/include" - pgsql_LDFLAGS="-L$withval/lib " - - APR_ADDTO(CPPFLAGS, [$pgsql_CPPFLAGS]) - APR_ADDTO(LDFLAGS, [$pgsql_LDFLAGS]) - - AC_MSG_NOTICE(checking for pgsql in $withval) - AC_CHECK_HEADERS(libpq-fe.h, AC_CHECK_LIB(pq, PQsendQueryPrepared, [apu_have_pgsql=1])) - if test "$apu_have_pgsql" != "0"; then - APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib]) - APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include]) - fi - if test "$apu_have_pgsql" != "1"; then - AC_CHECK_HEADERS(postgresql/libpq-fe.h, AC_CHECK_LIB(pq, PQsendQueryPrepared, [apu_have_pgsql=1])) - if test "$apu_have_pgsql" != "0"; then - APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include/postgresql]) - APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib]) - fi - fi - - CPPFLAGS="$old_cppflags" - LDFLAGS="$old_ldflags" - fi - ], [ - apu_have_pgsql=0 - AC_CHECK_HEADERS(libpq-fe.h, AC_CHECK_LIB(pq, PQsendQueryPrepared, [apu_have_pgsql=1])) - ]) - AC_SUBST(apu_have_pgsql) - dnl Since we have already done the AC_CHECK_LIB tests, if we have it, - dnl we know the library is there. - if test "$apu_have_pgsql" = "1"; then - APR_ADDTO(APRUTIL_EXPORT_LIBS,[-lpq]) - APR_ADDTO(APRUTIL_LIBS,[-lpq]) - fi -]) -dnl -AC_DEFUN([APU_CHECK_DBD_MYSQL], [ - apu_have_mysql=0 - - AC_CHECK_FILES([dbd/apr_dbd_mysql.c],[ - AC_ARG_WITH([mysql], [ - --with-mysql=DIR **** SEE INSTALL.MySQL **** - ], [ - apu_have_mysql=0 - if test "$withval" = "yes"; then - old_cppflags="$CPPFLAGS" - old_ldflags="$LDFLAGS" - - AC_PATH_PROG([MYSQL_CONFIG],[mysql_config]) - if test "x$MYSQL_CONFIG" != 'x'; then - mysql_CPPFLAGS="`$MYSQL_CONFIG --include`" - mysql_LDFLAGS="`$MYSQL_CONFIG --libs_r`" - - APR_ADDTO(CPPFLAGS, [$mysql_CPPFLAGS]) - APR_ADDTO(LDFLAGS, [$mysql_LDFLAGS]) - fi - - AC_CHECK_HEADERS(mysql.h, AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1])) - if test "$apu_have_mysql" = "0"; then - AC_CHECK_HEADERS(mysql/mysql.h, AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1])) - else - if test "x$MYSQL_CONFIG" != 'x'; then - APR_ADDTO(APRUTIL_INCLUDES, [$mysql_CPPFLAGS]) - APR_ADDTO(APRUTIL_LDFLAGS, [$mysql_LDFLAGS]) - fi - fi - - CPPFLAGS="$old_cppflags" - LDFLAGS="$old_ldflags" - elif test "$withval" = "no"; then - apu_have_mysql=0 - else - old_cppflags="$CPPFLAGS" - old_ldflags="$LDFLAGS" - - AC_PATH_PROG([MYSQL_CONFIG],[mysql_config],,[$withval/bin]) - if test "x$MYSQL_CONFIG" != 'x'; then - mysql_CPPFLAGS="`$MYSQL_CONFIG --include`" - mysql_LDFLAGS="`$MYSQL_CONFIG --libs_r`" - else - mysql_CPPFLAGS="-I$withval/include" - mysql_LDFLAGS="-L$withval/lib " - fi - - APR_ADDTO(CPPFLAGS, [$mysql_CPPFLAGS]) - APR_ADDTO(LDFLAGS, [$mysql_LDFLAGS]) - - AC_MSG_NOTICE(checking for mysql in $withval) - AC_CHECK_HEADERS(mysql.h, AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1])) - if test "$apu_have_mysql" != "0"; then - APR_ADDTO(APRUTIL_INCLUDES, [$mysql_CPPFLAGS]) - APR_ADDTO(APRUTIL_LDFLAGS, [$mysql_LDFLAGS]) - fi - - if test "$apu_have_mysql" != "1"; then - AC_CHECK_HEADERS(mysql/mysql.h, AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1])) - if test "$apu_have_mysql" != "0"; then - APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include/mysql]) - APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib]) - fi - fi - - CPPFLAGS="$old_cppflags" - LDFLAGS="$old_ldflags" - fi - ], [ - apu_have_mysql=0 - - old_cppflags="$CPPFLAGS" - old_ldflags="$LDFLAGS" - - AC_PATH_PROG([MYSQL_CONFIG],[mysql_config]) - if test "x$MYSQL_CONFIG" != 'x'; then - mysql_CPPFLAGS="`$MYSQL_CONFIG --include`" - mysql_LDFLAGS="`$MYSQL_CONFIG --libs_r`" - - APR_ADDTO(CPPFLAGS, [$mysql_CPPFLAGS]) - APR_ADDTO(LDFLAGS, [$mysql_LDFLAGS]) - fi - - AC_CHECK_HEADERS(mysql.h, AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1])) - - if test "$apu_have_mysql" != "0"; then - if test "x$MYSQL_CONFIG" != 'x'; then - APR_ADDTO(APRUTIL_INCLUDES, [$mysql_CPPFLAGS]) - APR_ADDTO(APRUTIL_LDFLAGS, [$mysql_LDFLAGS]) - fi - fi - - CPPFLAGS="$old_cppflags" - LDFLAGS="$old_ldflags" - ]) - ]) - - AC_SUBST(apu_have_mysql) - - dnl Since we have already done the AC_CHECK_LIB tests, if we have it, - dnl we know the library is there. - if test "$apu_have_mysql" = "1"; then - APR_ADDTO(APRUTIL_EXPORT_LIBS,[-lmysqlclient_r]) - APR_ADDTO(APRUTIL_LIBS,[-lmysqlclient_r]) - fi -]) -dnl -AC_DEFUN([APU_CHECK_DBD_SQLITE3], [ - apu_have_sqlite3=0 - - AC_ARG_WITH([sqlite3], [ - --with-sqlite3=DIR - ], [ - apu_have_sqlite3=0 - if test "$withval" = "yes"; then - AC_CHECK_HEADERS(sqlite3.h, AC_CHECK_LIB(sqlite3, sqlite3_open, [apu_have_sqlite3=1])) - elif test "$withval" = "no"; then - apu_have_sqlite3=0 - else - old_cppflags="$CPPFLAGS" - old_ldflags="$LDFLAGS" - - sqlite3_CPPFLAGS="-I$withval/include" - sqlite3_LDFLAGS="-L$withval/lib " - - APR_ADDTO(CPPFLAGS, [$sqlite3_CPPFLAGS]) - APR_ADDTO(LDFLAGS, [$sqlite3_LDFLAGS]) - - AC_MSG_NOTICE(checking for sqlite3 in $withval) - AC_CHECK_HEADERS(sqlite3.h, AC_CHECK_LIB(sqlite3, sqlite3_open, [apu_have_sqlite3=1])) - if test "$apu_have_sqlite3" != "0"; then - APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib]) - APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include]) - fi - - CPPFLAGS="$old_cppflags" - LDFLAGS="$old_ldflags" - fi - ], [ - apu_have_sqlite3=0 - AC_CHECK_HEADERS(sqlite3.h, AC_CHECK_LIB(sqlite3, sqlite3_open, [apu_have_sqlite3=1])) - ]) - - AC_SUBST(apu_have_sqlite3) - - dnl Since we have already done the AC_CHECK_LIB tests, if we have it, - dnl we know the library is there. - if test "$apu_have_sqlite3" = "1"; then - APR_ADDTO(APRUTIL_EXPORT_LIBS,[-lsqlite3]) - APR_ADDTO(APRUTIL_LIBS,[-lsqlite3]) - fi -]) -dnl -AC_DEFUN([APU_CHECK_DBD_SQLITE2], [ - apu_have_sqlite2=0 - - AC_ARG_WITH([sqlite2], [ - --with-sqlite2=DIR - ], [ - apu_have_sqlite2=0 - if test "$withval" = "yes"; then - AC_CHECK_HEADERS(sqlite.h, AC_CHECK_LIB(sqlite, sqlite_open, [apu_have_sqlite2=1])) - elif test "$withval" = "no"; then - apu_have_sqlite2=0 - else - old_cppflags="$CPPFLAGS" - old_ldflags="$LDFLAGS" - - sqlite2_CPPFLAGS="-I$withval/include" - sqlite2_LDFLAGS="-L$withval/lib " - - APR_ADDTO(CPPFLAGS, [$sqlite2_CPPFLAGS]) - APR_ADDTO(LDFLAGS, [$sqlite2_LDFLAGS]) - - AC_MSG_NOTICE(checking for sqlite2 in $withval) - AC_CHECK_HEADERS(sqlite.h, AC_CHECK_LIB(sqlite, sqlite_open, [apu_have_sqlite2=1])) - if test "$apu_have_sqlite2" != "0"; then - APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib]) - APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include]) - fi - - CPPFLAGS="$old_cppflags" - LDFLAGS="$old_ldflags" - fi - ], [ - apu_have_sqlite2=0 - AC_CHECK_HEADERS(sqlite.h, AC_CHECK_LIB(sqlite, sqlite_open, [apu_have_sqlite2=1])) - ]) - - AC_SUBST(apu_have_sqlite2) - - dnl Since we have already done the AC_CHECK_LIB tests, if we have it, - dnl we know the library is there. - if test "$apu_have_sqlite2" = "1"; then - APR_ADDTO(APRUTIL_EXPORT_LIBS,[-lsqlite]) - APR_ADDTO(APRUTIL_LIBS,[-lsqlite]) - fi -]) -dnl - diff --git a/libs/apr-util/build/dbm.m4 b/libs/apr-util/build/dbm.m4 deleted file mode 100644 index 39a6252d71..0000000000 --- a/libs/apr-util/build/dbm.m4 +++ /dev/null @@ -1,870 +0,0 @@ -dnl -------------------------------------------------------- -*- autoconf -*- -dnl Copyright 2002-2005 The Apache Software Foundation or its licensors, as -dnl applicable. -dnl -dnl Licensed under the Apache License, Version 2.0 (the "License"); -dnl you may not use this file except in compliance with the License. -dnl You may obtain a copy of the License at -dnl -dnl http://www.apache.org/licenses/LICENSE-2.0 -dnl -dnl Unless required by applicable law or agreed to in writing, software -dnl distributed under the License is distributed on an "AS IS" BASIS, -dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -dnl See the License for the specific language governing permissions and -dnl limitations under the License. - - -dnl -dnl DBM module -dnl - -dnl APU_LIB_BERKELEY_DB(major, minor, patch, places, headers, libnames) -dnl -dnl Search for a useable version of Berkeley DB in a number of -dnl common places. The installed DB must be no older than the -dnl version given by MAJOR, MINOR, and PATCH. All of these -dnl arguments are allowed to be '-1', indicating we don't care. -dnl PLACES is a list of places to search for a Berkeley DB -dnl installation. HEADERS is a list of headers to try. LIBNAMES -dnl is a list of names of the library to attempt to link against, -dnl typically 'db' and 'db4'. -dnl -dnl If we find a useable version, set CPPFLAGS and LIBS as -dnl appropriate, and set the shell variable `apu_have_db' to -dnl `1', and apu_db_lib to the matching lib name, and apu_db_header -dnl to the header to use. Otherwise, set `apu_have_db' to `0'. -dnl -dnl This macro also checks for the `--with-berkeley-db=PATH' flag; -dnl if given, the macro will use the PATH specified, and the -dnl configuration script will die if it can't find the library. If -dnl the user gives the `--without-berkeley-db' flag, the entire -dnl search is skipped. -dnl -dnl We cache the results of individual searches under particular -dnl prefixes, not the overall result of whether we found Berkeley -dnl DB. That way, the user can re-run the configure script with -dnl different --with-berkeley-db switch values, without interference -dnl from the cache. - - -AC_DEFUN([APU_CHECK_BERKELEY_DB], [ - bdb_version=$1 - if test "$2" != "-1"; then - bdb_version="$bdb_version.$2" - if test "$3" != "-1"; then - bdb_version="$bdb_version.$3" - fi - fi - bdb_places=$4 - bdb_default_search_headers=$5 - bdb_default_search_lib_names=$6 - - apu_have_db=0 - - # Save the original values of the flags we tweak. - apu_check_lib_save_libs="$LIBS" - apu_check_lib_save_ldflags="$LDFLAGS" - apu_check_lib_save_cppflags="$CPPFLAGS" - - # The variable `found' is the prefix under which we've found - # Berkeley DB, or `not' if we haven't found it anywhere yet. - found=not - for bdb_place in $bdb_places; do - - LDFLAGS="$apu_check_lib_save_ldflags" - CPPFLAGS="$apu_check_lib_save_cppflags" - case "$bdb_place" in - "std" ) - description="the standard places" - ;; - *":"* ) - header="`echo $bdb_place | sed -e 's/:.*$//'`" - lib="`echo $bdb_place | sed -e 's/^.*://'`" - CPPFLAGS="$CPPFLAGS -I$header" - LDFLAGS="$LDFLAGS -L$lib" - description="$header and $lib" - ;; - * ) - if test -d $bdb_place; then - LDFLAGS="$LDFLAGS -L$bdb_place/lib" - CPPFLAGS="$CPPFLAGS -I$bdb_place/include" - else - AC_MSG_CHECKING([for Berkeley DB $bdb_version in $bdb_place]) - AC_MSG_RESULT([directory not found]) - continue - fi - description="$bdb_place" - ;; - esac - - # Since there is no AC_MSG_NOTICE in autoconf 2.13, we use this - # trick to display a message instead. - AC_MSG_CHECKING([for Berkeley DB $bdb_version in $description]) - AC_MSG_RESULT() - - for bdb_libname in $bdb_default_search_lib_names; do - for bdb_header in $bdb_default_search_headers; do - # Clear the header cache variable for each location - changequote(,) - cache_id="`echo ac_cv_header_${bdb_header} \ - | sed -e 's/[^a-zA-Z0-9_]/_/g'`" - changequote([,]) - unset $cache_id - AC_CHECK_HEADER([$bdb_header], [ - if test "$1" = "3" -o "$1" = "4"; then - # We generate a separate cache variable for each prefix and libname - # we search under. That way, we avoid caching information that - # changes if the user runs `configure' with a different set of - # switches. - changequote(,) - cache_id="`echo apu_cv_check_berkeley_db_$1_$2_$3_${bdb_header}_${bdb_libname}_in_${bdb_place} \ - | sed -e 's/[^a-zA-Z0-9_]/_/g'`" - changequote([,]) - - AC_MSG_CHECKING([for -l$bdb_libname]) - dnl We can't use AC_CACHE_CHECK here, because that won't print out - dnl the value of the computed cache variable properly. - AC_CACHE_VAL($cache_id, - [ - APU_TRY_BERKELEY_DB($1, $2, $3, $bdb_header, $bdb_libname) - eval "$cache_id=$apu_try_berkeley_db" - ]) - result="`eval echo '$'$cache_id`" - AC_MSG_RESULT($result) - elif test "$1" = "1"; then - AC_CHECK_LIB($bdb_libname, - dbopen, - [result=yes], - [result=no] - ) - elif test "$1" = "2"; then - AC_CHECK_LIB($bdb_libname, - db_open, - [result=yes], - [result=no] - ) - fi - ], [result="no"]) - - # If we found it, no need to search any more. - if test "$result" = "yes"; then - found="$bdb_place" - break - fi - done - test "$found" != "not" && break - done - test "$found" != "not" && break - done - - # Restore the original values of the flags we tweak. - LDFLAGS="$apu_check_lib_save_ldflags" - CPPFLAGS="$apu_check_lib_save_cppflags" - - case "$found" in - "not") - apu_have_db=0 - ;; - "std") - apu_db_header=$bdb_header - apu_db_lib=$bdb_libname - apu_have_db=1 - ;; - *":"*) - header="`echo $found | sed -e 's/:.*$//'`" - lib="`echo $found | sed -e 's/^.*://'`" - - APR_ADDTO(APRUTIL_INCLUDES, [-I$header]) - APR_ADDTO(APRUTIL_LDFLAGS, [-L$lib]) - apu_db_header=$bdb_header - apu_db_lib=$bdb_libname - apu_have_db=1 - ;; - *) - APR_ADDTO(APRUTIL_INCLUDES, [-I$found/include]) - APR_ADDTO(APRUTIL_LDFLAGS, [-L$found/lib]) - apu_db_header=$bdb_header - apu_db_lib=$bdb_libname - apu_have_db=1 - ;; - esac -]) - - -dnl APU_TRY_BERKELEY_DB(major, minor, patch, header, libname) -dnl -dnl A subroutine of APU_CHECK_BERKELEY_DB. -dnl -dnl Check that a new-enough version of Berkeley DB is installed. -dnl "New enough" means no older than the version given by MAJOR, -dnl MINOR, and PATCH. The result of the test is not cached; no -dnl messages are printed. Use HEADER as the header file to include. -dnl Use LIBNAME as the library to link against. -dnl (e.g. LIBNAME should usually be "db" or "db4".) -dnl -dnl Set the shell variable `apu_try_berkeley_db' to `yes' if we found -dnl an appropriate version installed, or `no' otherwise. -dnl -dnl This macro uses the Berkeley DB library function `db_version' to -dnl find the version. If the library installed doesn't have this -dnl function, then this macro assumes it is too old. - -dnl NOTE: This is pretty messed up. It seems that the FreeBSD port of -dnl Berkeley DB 4 puts the header file in /usr/local/include/db4, but the -dnl database library in /usr/local/lib, as libdb4.[a|so]. There is no -dnl /usr/local/include/db.h. So if you check for /usr/local first, you'll -dnl get the old header file from /usr/include, and the new library from -dnl /usr/local/lib. Disaster. Thus this test compares the version constants -dnl in the db.h header with the ones returned by db_version(). - - -AC_DEFUN([APU_TRY_BERKELEY_DB], - [ - apu_try_berkeley_db_save_libs="$LIBS" - - apu_check_berkeley_db_major=$1 - apu_check_berkeley_db_minor=$2 - apu_check_berkeley_db_patch=$3 - apu_try_berkeley_db_header=$4 - apu_try_berkeley_db_libname=$5 - - LIBS="$LIBS -l$apu_try_berkeley_db_libname" - AC_TRY_RUN( - [ -#include -#include <$apu_try_berkeley_db_header> -main () -{ - int major, minor, patch; - - db_version(&major, &minor, &patch); - - /* Sanity check: ensure that db.h constants actually match the db library */ - if (major != DB_VERSION_MAJOR - || minor != DB_VERSION_MINOR - || patch != DB_VERSION_PATCH) - exit (1); - - /* Run-time check: ensure the library claims to be the correct version. */ - - if ($apu_check_berkeley_db_major != -1) { - if (major < $apu_check_berkeley_db_major) - exit (1); - if (major > $apu_check_berkeley_db_major) - exit (0); - } - - if ($apu_check_berkeley_db_minor != -1) { - if (minor < $apu_check_berkeley_db_minor) - exit (1); - if (minor > $apu_check_berkeley_db_minor) - exit (0); - } - - if ($apu_check_berkeley_db_patch == -1 - || patch >= $apu_check_berkeley_db_patch) - exit (0); - else - exit (1); -} - ], - [apu_try_berkeley_db=yes], - [apu_try_berkeley_db=no], - [apu_try_berkeley_db=yes] - ) - - LIBS="$apu_try_berkeley_db_save_libs" - ] -) - - -dnl -dnl APU_CHECK_DB1: is DB1 present? -dnl -dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version -dnl -AC_DEFUN([APU_CHECK_DB1], [ - places=$1 - if test -z "$places"; then - places="std" - fi - APU_CHECK_BERKELEY_DB(1, 0, 0, - "$places", - "db1/db.h db.h", - "db1" - ) - if test "$apu_have_db" = "1"; then - apu_db_version=1 - fi -]) - - -dnl -dnl APU_CHECK_DB185: is DB1.85 present? -dnl -dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version -dnl -dnl NB: BerkelyDB v2 and above can be compiled in 1.85 mode -dnl which has a libdb not libdb1 or libdb185 -AC_DEFUN([APU_CHECK_DB185], [ - places=$1 - if test -z "$places"; then - places="std" - fi - APU_CHECK_BERKELEY_DB(1, -1, -1, - "$places", - "db_185.h", - "db" - ) - if test "$apu_have_db" = "1"; then - apu_db_version=185 - fi -]) - - -dnl -dnl APU_CHECK_DB2: is DB2 present? -dnl -dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version -dnl -AC_DEFUN([APU_CHECK_DB2], [ - places=$1 - if test -z "$places"; then - places="std" - fi - APU_CHECK_BERKELEY_DB(2, -1, -1, - "$places", - "db2/db.h db.h", - "db2 db" - ) - if test "$apu_have_db" = "1"; then - apu_db_version=2 - fi -]) - - -dnl -dnl APU_CHECK_DB3: is DB3 present? -dnl -dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version -dnl -AC_DEFUN([APU_CHECK_DB3], [ - places=$1 - if test -z "$places"; then - places="std" - fi - APU_CHECK_BERKELEY_DB(3, -1, -1, - "$places", - "db3/db.h db.h", - "db3 db" - ) - if test "$apu_have_db" = "1"; then - apu_db_version=3 - fi -]) - - -dnl -dnl APU_CHECK_DB4: is DB4 present? -dnl -dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version -dnl -AC_DEFUN([APU_CHECK_DB4], [ - places=$1 - if test -z "$places"; then - places="std /usr/local /usr/local/BerkeleyDB.4.0 /boot/home/config" - fi - APU_CHECK_BERKELEY_DB("4", "0", "-1", - "$places", - "db4/db.h db.h", - "db-4.0 db4 db" - ) - if test "$apu_have_db" = "1"; then - apu_db_version=4 - fi -]) - - -dnl -dnl APU_CHECK_DB41: is DB4.1 present? -dnl -dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version -dnl -AC_DEFUN([APU_CHECK_DB41], [ - places=$1 - if test -z "$places"; then - places="std /usr/local /usr/local/BerkeleyDB.4.1 /boot/home/config" - fi - APU_CHECK_BERKELEY_DB("4", "1", "-1", - "$places", - "db41/db.h db4/db.h db.h", - "db-4.1 db41 db4 db" - ) - if test "$apu_have_db" = "1"; then - apu_db_version=4 - fi -]) - - -dnl -dnl APU_CHECK_DB42: is DB4.2 present? -dnl -dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version -dnl -AC_DEFUN([APU_CHECK_DB42], [ - places=$1 - if test -z "$places"; then - places="std /usr/local /usr/local/BerkeleyDB.4.2 /boot/home/config" - fi - APU_CHECK_BERKELEY_DB("4", "2", "-1", - "$places", - "db42/db.h db4/db.h db.h", - "db-4.2 db42 db4 db" - ) - if test "$apu_have_db" = "1"; then - apu_db_version=4 - fi -]) -dnl -dnl APU_CHECK_DB43: is DB4.3 present? -dnl -dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version -dnl -AC_DEFUN([APU_CHECK_DB43], [ - places=$1 - if test -z "$places"; then - places="std /usr/local/BerkeleyDB.4.3 /boot/home/config" - fi - APU_CHECK_BERKELEY_DB("4", "3", "-1", - "$places", - "db43/db.h db4/db.h db.h", - "db-4.3 db4-4.3 db43 db4 db" - ) - if test "$apu_have_db" = "1"; then - apu_db_version=4 - fi -]) -dnl -dnl APU_CHECK_DB44: is DB4.4 present? -dnl -dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version -dnl -AC_DEFUN([APU_CHECK_DB44], [ - places=$1 - if test -z "$places"; then - places="std /usr/local/BerkeleyDB.4.4 /boot/home/config" - fi - APU_CHECK_BERKELEY_DB("4", "4", "-1", - "$places", - "db44/db.h db4/db.h db.h", - "db-4.4 db4-4.4 db44 db4 db" - ) - if test "$apu_have_db" = "1"; then - apu_db_version=4 - fi -]) -dnl -dnl APU_CHECK_DB45: is DB4.5 present? -dnl -dnl if present: sets apu_db_header, apu_db_lib, and apu_db_version -dnl -AC_DEFUN([APU_CHECK_DB45], [ - places=$1 - if test -z "$places"; then - places="std /usr/local/BerkeleyDB.4.5 /boot/home/config" - fi - APU_CHECK_BERKELEY_DB("4", "5", "-1", - "$places", - "db45/db.h db4/db.h db.h", - "db-4.5 db4-4.5 db45 db4 db" - ) - if test "$apu_have_db" = "1"; then - apu_db_version=4 - fi -]) - -AC_DEFUN([APU_CHECK_DB], [ - requested=$1 - check_places=$2 - - case "$requested" in - db) - APU_CHECK_DB_ALL("$check_places") - if test "$apu_have_db" = "0"; then - AC_MSG_ERROR(Berkeley db requested, but not found) - fi - ;; - db1) - APU_CHECK_DB1("$check_places") - if test "$apu_db_version" != "1"; then - AC_MSG_ERROR(Berkeley db1 not found) - fi - ;; - db185) - APU_CHECK_DB185("$check_places") - if test "$apu_db_version" != "185"; then - AC_MSG_ERROR(Berkeley db185 not found) - fi - ;; - db2) - APU_CHECK_DB2("$check_places") - if test "$apu_db_version" != "2"; then - AC_MSG_ERROR(Berkeley db2 not found) - fi - ;; - db3) - APU_CHECK_DB3("$check_places") - if test "$apu_db_version" != "3"; then - AC_MSG_ERROR(Berkeley db3 not found) - fi - ;; - db4) - APU_CHECK_DB4("$check_places") - if test "$apu_db_version" != "4"; then - AC_MSG_ERROR(Berkeley db4 not found) - fi - ;; - db41) - APU_CHECK_DB41("$check_places") - if test "$apu_db_version" != "4"; then - AC_MSG_ERROR(Berkeley db4 not found) - fi - ;; - db42) - APU_CHECK_DB42("$check_places") - if test "$apu_db_version" != "4"; then - AC_MSG_ERROR(Berkeley db4 not found) - fi - ;; - db43) - APU_CHECK_DB43("$check_places") - if test "$apu_db_version" != "4"; then - AC_MSG_ERROR(Berkeley db4 not found) - fi - ;; - db44) - APU_CHECK_DB44("$check_places") - if test "$apu_db_version" != "4"; then - AC_MSG_ERROR(Berkeley db4 not found) - fi - ;; - db45) - APU_CHECK_DB44("$check_places") - if test "$apu_db_version" != "4"; then - AC_MSG_ERROR(Berkeley db4 not found) - fi - ;; - default) - APU_CHECK_DB_ALL("$check_places") - ;; - esac -]) - -dnl -dnl APU_CHECK_DB_ALL: Try all Berkeley DB versions, from 4.3 to 1. -dnl -AC_DEFUN([APU_CHECK_DB_ALL], [ - all_places=$1 - - APU_CHECK_DB45("$all_places") - if test "$apu_db_version" != "4"; then - APU_CHECK_DB44("$all_places") - if test "$apu_db_version" != "4"; then - APU_CHECK_DB43("$all_places") - if test "$apu_db_version" != "4"; then - APU_CHECK_DB42("$all_places") - if test "$apu_db_version" != "4"; then - APU_CHECK_DB41("$all_places") - if test "$apu_db_version" != "4"; then - APU_CHECK_DB4("$all_places") - if test "$apu_db_version" != "4"; then - APU_CHECK_DB3("$all_places") - if test "$apu_db_version" != "3"; then - APU_CHECK_DB2("$all_places") - if test "$apu_db_version" != "2"; then - APU_CHECK_DB1("$all_places") - if test "$apu_db_version" != "1"; then - APU_CHECK_DB185("$all_places") - fi - fi - fi - fi - fi - fi - fi - fi - fi - AC_MSG_CHECKING(for Berkeley DB) - if test "$apu_have_db" = "1"; then - AC_MSG_RESULT(found db$apu_db_version) - else - AC_MSG_RESULT(not found) - fi -]) - - -dnl -dnl APU_CHECK_DBM: see what kind of DBM backend to use for apr_dbm. -dnl -AC_DEFUN([APU_CHECK_DBM], [ - apu_use_sdbm=0 - apu_use_ndbm=0 - apu_use_gdbm=0 - apu_use_db=0 - dnl it's in our codebase - apu_have_sdbm=1 - apu_have_gdbm=0 - apu_have_ndbm=0 - apu_have_db=0 - - apu_db_header=db.h # default so apu_select_dbm.h is syntactically correct - apu_db_version=0 - - AC_ARG_WITH(dbm, [ - --with-dbm=DBM choose the DBM type to use. - DBM={sdbm,gdbm,ndbm,db,db1,db185,db2,db3,db4,db41,db42,db43,db44,db45} - ], [ - if test "$withval" = "yes"; then - AC_MSG_ERROR([--with-dbm needs to specify a DBM type to use. - One of: sdbm, gdbm, ndbm, db, db1, db185, db2, db3, db4, db41, db42, db43, db44, db45]) - fi - requested="$withval" - ], [ - requested=default - ]) - - dnl We don't pull in GDBM unless the user asks for it, since it's GPL - AC_ARG_WITH([gdbm], [ - --with-gdbm=DIR specify GDBM location - ], [ - apu_have_gdbm=0 - if test "$withval" = "yes"; then - AC_CHECK_HEADER(gdbm.h, AC_CHECK_LIB(gdbm, gdbm_open, [apu_have_gdbm=1])) - elif test "$withval" = "no"; then - apu_have_gdbm=0 - else - CPPFLAGS="-I$withval/include" - LIBS="-L$withval/lib " - - AC_MSG_CHECKING(checking for gdbm in $withval) - AC_CHECK_HEADER(gdbm.h, AC_CHECK_LIB(gdbm, gdbm_open, [apu_have_gdbm=1])) - if test "$apu_have_gdbm" != "0"; then - APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib]) - APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include]) - fi - fi - ]) - - AC_ARG_WITH([ndbm], [ - --with-ndbm=PATH - Find the NDBM header and library in \`PATH/include' and - \`PATH/lib'. If PATH is of the form \`HEADER:LIB', then search - for header files in HEADER, and the library in LIB. If you omit - the \`=PATH' part completely, the configure script will search - for NDBM in a number of standard places. - ], [ - apu_have_ndbm=0 - if test "$withval" = "yes"; then - AC_MSG_CHECKING(checking for ndbm in the usual places) - apu_want_ndbm=1 - NDBM_INC="" - NDBM_LDFLAGS="" - elif test "$withval" = "no"; then - apu_want_ndbm=0 - else - apu_want_ndbm=1 - case "$withval" in - *":"*) - NDBM_INC="-I`echo $withval |sed -e 's/:.*$//'`" - NDBM_LDFLAGS="-L`echo $withval |sed -e 's/^.*://'`" - AC_MSG_CHECKING(checking for ndbm includes with $NDBM_INC libs with $NDBM_LDFLAGS ) - ;; - *) - NDBM_INC="-I$withval/include" - NDBM_LDFLAGS="-L$withval/lib" - AC_MSG_CHECKING(checking for ndbm includes in $withval) - ;; - esac - fi - - save_cppflags="$CPPFLAGS" - save_ldflags="$LDFLAGS" - CPPFLAGS="$CPPFLAGS $NDBM_INC" - LDFLAGS="$LDFLAGS $NDBM_LDFLAGS" - dnl db_ndbm_open is what sleepcat's compatibility library actually has in it's lib - if test "$apu_want_ndbm" != "0"; then - AC_CHECK_HEADER(ndbm.h, - AC_CHECK_LIB(c, dbm_open, [apu_have_ndbm=1;apu_ndbm_lib=c], - AC_CHECK_LIB(dbm, dbm_open, [apu_have_ndbm=1;apu_ndbm_lib=dbm], - AC_CHECK_LIB(db, dbm_open, [apu_have_ndbm=1;apu_ndbm_lib=db], - AC_CHECK_LIB(db, __db_ndbm_open, [apu_have_ndbm=1;apu_ndbm_lib=db]) - ) - ) - ) - ) - if test "$apu_have_ndbm" != "0"; then - if test "$withval" != "yes"; then - APR_ADDTO(APRUTIL_INCLUDES, [$NDBM_INC]) - APR_ADDTO(APRUTIL_LDFLAGS, [$NDBM_LDFLAGS]) - fi - elif test "$withval" != "yes"; then - AC_ERROR( NDBM not found in the specified directory) - fi - fi - CPPFLAGS="$save_cppflags" - LDFLAGS="$save_ldflags" - ], [ - dnl don't check it no one has asked us for it - apu_have_ndbm=0 - ]) - - - if test -n "$apu_db_xtra_libs"; then - saveddbxtralibs="$LIBS" - LIBS="$apu_db_xtra_libs $LIBS" - fi - - dnl We're going to try to find the highest version of Berkeley DB supported. - dnl - dnl Note that we only do this if the user requested it, since the Sleepycat - dnl license is viral and requires distribution of source along with programs - dnl that use it. - AC_ARG_WITH([berkeley-db], [ - --with-berkeley-db=PATH - Find the Berkeley DB header and library in \`PATH/include' and - \`PATH/lib'. If PATH is of the form \`HEADER:LIB', then search - for header files in HEADER, and the library in LIB. If you omit - the \`=PATH' part completely, the configure script will search - for Berkeley DB in a number of standard places. - ], [ - if test "$withval" = "yes"; then - apu_want_db=1 - user_places="" - elif test "$withval" = "no"; then - apu_want_db=0 - else - apu_want_db=1 - user_places="$withval" - fi - - if test "$apu_want_db" != "0"; then - APU_CHECK_DB($requested, $user_places) - if test "$apu_have_db" = "0"; then - AC_ERROR(Berkeley DB not found.) - fi - fi - ]) - - if test -n "$apu_db_xtra_libs"; then - LIBS="$saveddbxtralibs" - fi - - case "$requested" in - sdbm) - apu_use_sdbm=1 - apu_default_dbm=sdbm - ;; - gdbm) - apu_use_gdbm=1 - apu_default_dbm=gdbm - ;; - ndbm) - apu_use_ndbm=1 - apu_default_dbm=ndbm - ;; - db) - apu_use_db=1 - apu_default_dbm=db - ;; - db1) - apu_use_db=1 - apu_default_dbm=db1 - ;; - db185) - apu_use_db=1 - apu_default_dbm=db185 - ;; - db2) - apu_use_db=1 - apu_default_dbm=db2 - ;; - db3) - apu_use_db=1 - apu_default_dbm=db3 - ;; - db4) - apu_use_db=1 - apu_default_dbm=db4 - ;; - db41) - apu_use_db=1 - apu_default_dbm=db4 - ;; - db42) - apu_use_db=1 - apu_default_dbm=db4 - ;; - db43) - apu_use_db=1 - apu_default_dbm=db4 - ;; - db44) - apu_use_db=1 - apu_default_dbm=db4 - ;; - db45) - apu_use_db=1 - apu_default_dbm=db4 - ;; - default) - dnl ### use more sophisticated DBMs for the default? - apu_default_dbm="sdbm (default)" - apu_use_sdbm=1 - ;; - *) - AC_MSG_ERROR([--with-dbm=$look_for is an unknown DBM type. - Use one of: sdbm, gdbm, ndbm, db, db1, db185, db2, db3, db4, db41, db42, db43, db44 db45]) - ;; - esac - - dnl Yes, it'd be nice if we could collate the output in an order - dnl so that the AC_MSG_CHECKING would be output before the actual - dnl checks, but it isn't happening now. - AC_MSG_CHECKING(for default DBM) - AC_MSG_RESULT($apu_default_dbm) - - AC_SUBST(apu_use_sdbm) - AC_SUBST(apu_use_gdbm) - AC_SUBST(apu_use_ndbm) - AC_SUBST(apu_use_db) - - AC_SUBST(apu_have_sdbm) - AC_SUBST(apu_have_gdbm) - AC_SUBST(apu_have_ndbm) - AC_SUBST(apu_have_db) - AC_SUBST(apu_db_header) - AC_SUBST(apu_db_version) - - dnl Since we have already done the AC_CHECK_LIB tests, if we have it, - dnl we know the library is there. - if test "$apu_have_gdbm" = "1"; then - APR_ADDTO(APRUTIL_EXPORT_LIBS,[-lgdbm]) - APR_ADDTO(APRUTIL_LIBS,[-lgdbm]) - fi - - if test "$apu_have_ndbm" = "1"; then - APR_ADDTO(APRUTIL_EXPORT_LIBS,[-l$apu_ndbm_lib]) - APR_ADDTO(APRUTIL_LIBS,[-l$apu_ndbm_lib]) - fi - - if test "$apu_have_db" = "1"; then - APR_ADDTO(APRUTIL_EXPORT_LIBS,[-l$apu_db_lib]) - APR_ADDTO(APRUTIL_LIBS,[-l$apu_db_lib]) - if test -n "apu_db_xtra_libs"; then - APR_ADDTO(APRUTIL_EXPORT_LIBS,[$apu_db_xtra_libs]) - APR_ADDTO(APRUTIL_LIBS,[$apu_db_xtra_libs]) - fi - fi -]) - diff --git a/libs/apr-util/build/find_apu.m4 b/libs/apr-util/build/find_apu.m4 deleted file mode 100644 index e29bc60923..0000000000 --- a/libs/apr-util/build/find_apu.m4 +++ /dev/null @@ -1,176 +0,0 @@ -dnl -------------------------------------------------------- -*- autoconf -*- -dnl Copyright 2002-2005 The Apache Software Foundation or its licensors, as -dnl applicable. -dnl -dnl Licensed under the Apache License, Version 2.0 (the "License"); -dnl you may not use this file except in compliance with the License. -dnl You may obtain a copy of the License at -dnl -dnl http://www.apache.org/licenses/LICENSE-2.0 -dnl -dnl Unless required by applicable law or agreed to in writing, software -dnl distributed under the License is distributed on an "AS IS" BASIS, -dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -dnl See the License for the specific language governing permissions and -dnl limitations under the License. - -dnl -dnl find_apu.m4 : locate the APR-util (APU) include files and libraries -dnl -dnl This macro file can be used by applications to find and use the APU -dnl library. It provides a standardized mechanism for using APU. It supports -dnl embedding APU into the application source, or locating an installed -dnl copy of APU. -dnl -dnl APR_FIND_APU(srcdir, builddir, implicit-install-check, acceptable-majors) -dnl -dnl where srcdir is the location of the bundled APU source directory, or -dnl empty if source is not bundled. -dnl -dnl where builddir is the location where the bundled APU will be built, -dnl or empty if the build will occur in the srcdir. -dnl -dnl where implicit-install-check set to 1 indicates if there is no -dnl --with-apr-util option specified, we will look for installed copies. -dnl -dnl where acceptable-majors is a space separated list of acceptable major -dnl version numbers. Often only a single major version will be acceptable. -dnl If multiple versions are specified, and --with-apr-util=PREFIX or the -dnl implicit installed search are used, then the first (leftmost) version -dnl in the list that is found will be used. Currently defaults to [0 1]. -dnl -dnl Sets the following variables on exit: -dnl -dnl apu_found : "yes", "no", "reconfig" -dnl -dnl apu_config : If the apu-config tool exists, this refers to it. If -dnl apu_found is "reconfig", then the bundled directory -dnl should be reconfigured *before* using apu_config. -dnl -dnl Note: this macro file assumes that apr-config has been installed; it -dnl is normally considered a required part of an APR installation. -dnl -dnl Note: At this time, we cannot find *both* a source dir and a build dir. -dnl If both are available, the build directory should be passed to -dnl the --with-apr-util switch. -dnl -dnl Note: the installation layout is presumed to follow the standard -dnl PREFIX/lib and PREFIX/include pattern. If the APU config file -dnl is available (and can be found), then non-standard layouts are -dnl possible, since it will be described in the config file. -dnl -dnl If a bundled source directory is available and needs to be (re)configured, -dnl then apu_found is set to "reconfig". The caller should reconfigure the -dnl (passed-in) source directory, placing the result in the build directory, -dnl as appropriate. -dnl -dnl If apu_found is "yes" or "reconfig", then the caller should use the -dnl value of apu_config to fetch any necessary build/link information. -dnl - -AC_DEFUN([APR_FIND_APU], [ - apu_found="no" - - if test "$target_os" = "os2-emx"; then - # Scripts don't pass test -x on OS/2 - TEST_X="test -f" - else - TEST_X="test -x" - fi - - ifelse([$4], [], - [ - ifdef(AC_WARNING,([$0: missing argument 4 (acceptable-majors): Defaulting to APU 0.x then APU 1.x])) - acceptable_majors="0 1" - ], [acceptable_majors="$4"]) - - apu_temp_acceptable_apu_config="" - for apu_temp_major in $acceptable_majors - do - case $apu_temp_major in - 0) - apu_temp_acceptable_apu_config="$apu_temp_acceptable_apu_config apu-config" - ;; - *) - apu_temp_acceptable_apu_config="$apu_temp_acceptable_apu_config apu-$apu_temp_major-config" - ;; - esac - done - - AC_MSG_CHECKING(for APR-util) - AC_ARG_WITH(apr-util, - [ --with-apr-util=PATH prefix for installed APU, path to APU build tree, - or the full path to apu-config], - [ - if test "$withval" = "no" || test "$withval" = "yes"; then - AC_MSG_ERROR([--with-apr-util requires a directory or file to be provided]) - fi - - for apu_temp_apu_config_file in $apu_temp_acceptable_apu_config - do - for lookdir in "$withval/bin" "$withval" - do - if $TEST_X "$lookdir/$apu_temp_apu_config_file"; then - apu_found="yes" - apu_config="$lookdir/$apu_temp_apu_config_file" - break 2 - fi - done - done - - if test "$apu_found" != "yes" && $TEST_X "$withval" && $withval --help > /dev/null 2>&1 ; then - apu_found="yes" - apu_config="$withval" - fi - - dnl if --with-apr-util is used, it is a fatal error for its argument - dnl to be invalid - if test "$apu_found" != "yes"; then - AC_MSG_ERROR([the --with-apr-util parameter is incorrect. It must specify an install prefix, a build directory, or an apu-config file.]) - fi - ],[ - if test -n "$3" && test "$3" = "1"; then - for apu_temp_apu_config_file in $apu_temp_acceptable_apu_config - do - if $apu_temp_apu_config_file --help > /dev/null 2>&1 ; then - apu_found="yes" - apu_config="$apu_temp_apu_config_file" - break - else - dnl look in some standard places (apparently not in builtin/default) - for lookdir in /usr /usr/local /usr/local/apr /opt/apr /usr/local/apache2 ; do - if $TEST_X "$lookdir/bin/$apu_temp_apu_config_file"; then - apu_found="yes" - apu_config="$lookdir/bin/$apu_temp_apu_config_file" - break 2 - fi - done - fi - done - fi - dnl if we have not found anything yet and have bundled source, use that - if test "$apu_found" = "no" && test -d "$1"; then - apu_temp_abs_srcdir="`cd $1 && pwd`" - apu_found="reconfig" - apu_bundled_major="`sed -n '/#define.*APU_MAJOR_VERSION/s/^[^0-9]*\([0-9]*\).*$/\1/p' \"$1/include/apu_version.h\"`" - case $apu_bundled_major in - "") - AC_MSG_ERROR([failed to find major version of bundled APU]) - ;; - 0) - apu_temp_apu_config_file="apu-config" - ;; - *) - apu_temp_apu_config_file="apu-$apu_bundled_major-config" - ;; - esac - if test -n "$2"; then - apu_config="$2/$apu_temp_apu_config_file" - else - apu_config="$1/$apu_temp_apu_config_file" - fi - fi - ]) - - AC_MSG_RESULT($apu_found) -]) diff --git a/libs/apr-util/build/mkdir.sh b/libs/apr-util/build/mkdir.sh deleted file mode 100755 index b947c92606..0000000000 --- a/libs/apr-util/build/mkdir.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh -## -## mkdir.sh -- make directory hierarchy -## -## Based on `mkinstalldirs' from Noah Friedman -## as of 1994-03-25, which was placed in the Public Domain. -## Cleaned up for Apache's Autoconf-style Interface (APACI) -## by Ralf S. Engelschall -## -# -# This script falls under the Apache License. -# See http://www.apache.org/docs/LICENSE - - -umask 022 -errstatus=0 -for file in ${1+"$@"} ; do - set fnord `echo ":$file" |\ - sed -e 's/^:\//%/' -e 's/^://' -e 's/\// /g' -e 's/^%/\//'` - shift - pathcomp= - for d in ${1+"$@"}; do - pathcomp="$pathcomp$d" - case "$pathcomp" in - -* ) pathcomp=./$pathcomp ;; - ?: ) pathcomp="$pathcomp/" - continue ;; - esac - if test ! -d "$pathcomp"; then - echo "mkdir $pathcomp" 1>&2 - mkdir "$pathcomp" || errstatus=$? - fi - pathcomp="$pathcomp/" - done -done -exit $errstatus - diff --git a/libs/apr-util/build/pkg/README b/libs/apr-util/build/pkg/README deleted file mode 100644 index d7e61a762c..0000000000 --- a/libs/apr-util/build/pkg/README +++ /dev/null @@ -1,20 +0,0 @@ -The script in this directory will attempt to build a Solaris package -out of a source tree for APR-util. - -To build a package, make sure you are in the root of the source tree, -and run: - -build/pkg/buildpkg.sh - -A Solaris package called apr-util---local.gz will be -created in the root of the source tree. - -By default, if you attempt to build packages for apr-util, it will -search for the sources for apr in: - -../apr - -You may override the location of apr like so: - -build/pkg/buildpkg.sh --with-apr=some/other/path - diff --git a/libs/apr-util/build/pkg/buildpkg.sh b/libs/apr-util/build/pkg/buildpkg.sh deleted file mode 100755 index ae9d00b321..0000000000 --- a/libs/apr-util/build/pkg/buildpkg.sh +++ /dev/null @@ -1,99 +0,0 @@ -#!/bin/sh -# Copyright 2000-2005 The Apache Software Foundation or its licensors, as -# applicable. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# - -# buildpkg.sh: This script builds a Solaris PKG from the source tree -# provided. - -PREFIX=/usr/local -TEMPDIR=/var/tmp/$USER/apr-util-root -rm -rf $TEMPDIR - -apr_util_src_dir=. -apr_src_dir=../apr -expat_dir=/usr - -while test $# -gt 0 -do - # Normalize - case "$1" in - -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; - *) optarg= ;; - esac - - case "$1" in - --with-apr=*) - apr_src_dir=$optarg - ;; - esac - - case "$1" in - --with-apr-util=*) - apr_util_src_dir=$optarg - ;; - esac - - case "$1" in - --with-expat=*) - expat_dir=$optarg - ;; - esac - - shift -done - -if [ -f "$apr_util_src_dir/configure.ac" ]; then - cd $apr_util_src_dir -else - echo "The apr-util source could not be found within $apr_util_src_dir" - echo "Usage: buildpkg [--with-apr=dir] [--with-apr-util=dir] [--with-expat=dir]" - exit 1 -fi - -if [ ! -f "$apr_src_dir/configure.ac" ]; then - echo "The apr source could not be found within $apr_src_dir" - echo "Usage: buildpkg [--with-apr=dir] [--with-apr-util=dir] [--with-expat=dir]" - exit 1 -fi - -if [ ! -d "$expat_dir" ]; then - echo "The expat directory could not be found within $expat_dir" - echo "Usage: buildpkg [--with-apr=dir] [--with-apr-util=dir] [--with-expat=dir]" - exit 1 -fi - -./configure --prefix=$PREFIX --with-apr=$apr_src_dir \ - --with-ldap --with-expat=$expat_dir -make -make install DESTDIR=$TEMPDIR -rm $TEMPDIR$PREFIX/lib/aprutil.exp -. build/pkg/pkginfo -cp build/pkg/pkginfo $TEMPDIR$PREFIX - -current=`pwd` -cd $TEMPDIR$PREFIX -echo "i pkginfo=./pkginfo" > prototype -find . -print | grep -v ./prototype | grep -v ./pkginfo | pkgproto | awk '{print $1" "$2" "$3" "$4" root bin"}' >> prototype -mkdir $TEMPDIR/pkg -pkgmk -r $TEMPDIR$PREFIX -d $TEMPDIR/pkg - -cd $current -pkgtrans -s $TEMPDIR/pkg $current/$NAME-$VERSION-$ARCH-local -gzip $current/$NAME-$VERSION-$ARCH-local - -rm -rf $TEMPDIR - diff --git a/libs/apr-util/build/pkg/pkginfo.in b/libs/apr-util/build/pkg/pkginfo.in deleted file mode 100644 index 1b6359a059..0000000000 --- a/libs/apr-util/build/pkg/pkginfo.in +++ /dev/null @@ -1,11 +0,0 @@ -PKG="ASFapu-1" -NAME="apr-util" -ARCH="@target_cpu@" -VERSION="@APRUTIL_DOTTED_VERSION@" -CATEGORY="application" -VENDOR="Apache Software Foundation" -EMAIL="dev@apr.apache.org" -PSTAMP="dev@apr.apache.org" -BASEDIR="@prefix@" -CLASSES="none" - diff --git a/libs/apr-util/build/rpm/apr-util.spec.in b/libs/apr-util/build/rpm/apr-util.spec.in deleted file mode 100644 index b7157682ca..0000000000 --- a/libs/apr-util/build/rpm/apr-util.spec.in +++ /dev/null @@ -1,89 +0,0 @@ - -%define apuver 1 - -Summary: Apache Portable Runtime Utility library -Name: apr-util -Version: APU_VERSION -Release: APU_RELEASE -License: Apache Software License -Group: System Environment/Libraries -URL: http://apr.apache.org/ -Source0: %{name}-%{version}.tar.gz -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot -BuildPrereq: autoconf, libtool, doxygen, apr-devel >= 0:{version}-{release} -BuildPrereq: openldap-devel, db4-devel, expat-devel -Conflicts: subversion < 0.20.1-2 - -%description -The mission of the Apache Portable Runtime (APR) is to provide a -free library of C data structures and routines. This library -contains additional utility interfaces for APR; including support -for XML, LDAP, database interfaces, URI parsing and more. - -%package devel -Group: Development/Libraries -Summary: APR utility library development kit -Requires: apr-util = %{version}-%{release}, apr-devel -Requires: openldap-devel, db4-devel, expat-devel -Conflicts: subversion-devel < 0.20.1-2 - -%description devel -This package provides the support files which can be used to -build applications using the APR utility library. The mission -of the Apache Portable Runtime (APR) is to provide a free -library of C data structures and routines. - -%prep -%setup -q - -%build -%configure --with-apr=%{_prefix} \ - --includedir=%{_includedir}/apr-%{apuver} \ - --with-ldap --without-gdbm -make %{?_smp_mflags} && make dox - -%check -# Run non-interactive tests -pushd test -make %{?_smp_mflags} testall CFLAGS=-fno-strict-aliasing -./testall -v || exit 1 -popd - -%install -rm -rf $RPM_BUILD_ROOT -make install DESTDIR=$RPM_BUILD_ROOT - -# Documentation -mv docs/dox/html html - -# Unpackaged files -rm -f $RPM_BUILD_ROOT%{_libdir}/aprutil.exp - -%clean -rm -rf $RPM_BUILD_ROOT - -%post -p /sbin/ldconfig - -%postun -p /sbin/ldconfig - -%files -%defattr(-,root,root,-) -%doc CHANGES LICENSE NOTICE -%{_libdir}/libaprutil-%{apuver}.so.* - -%files devel -%defattr(-,root,root,-) -%{_bindir}/apu-%{apuver}-config -%{_libdir}/libaprutil-%{apuver}.*a -%{_libdir}/libaprutil-%{apuver}.so -%{_libdir}/pkgconfig/apr-util-%{apuver}.pc -%{_includedir}/apr-%{apuver}/*.h -%doc --parents html - -%changelog -* Tue Jun 22 2004 Graham Leggett 1.0.0-1 -- update to support v1.0.0 of APR - -* Tue Jun 22 2004 Graham Leggett 1.0.0-1 -- derived from Fedora Core apr.spec - diff --git a/libs/apr-util/build/w32locatedb.pl b/libs/apr-util/build/w32locatedb.pl deleted file mode 100644 index 121dbf857f..0000000000 --- a/libs/apr-util/build/w32locatedb.pl +++ /dev/null @@ -1,217 +0,0 @@ -#! perl -w -# -# w32locatedb.pl -- Build apr-util with Berkeley DB on Win32 -# -# Usage: perl w32locatedb.pl -# type: Library type to link with ('lib' or 'dll') -# incdir: BDB includes directory (for db.h) -# libdir: Library directory (for libdbXY[s][d].lib) -# -# This script falls under the Apache License. -# See http://www.apache.org/docs/LICENSE - -require 5.008; -use strict; -use File::Spec::Functions qw(canonpath rel2abs - splitpath catpath splitdir catdir); - -######## -# Subroutine prototypes -sub usage(); -sub find_srcdir(); -sub get_lib_name($$); -sub edit_header($$); -sub edit_project($$); - -######## -# Parse program arguments and set globals -die usage() unless scalar @ARGV >= 3; - -my $type = lc($ARGV[0]); -die "Invalid library type '$type'\n" - unless $type eq 'lib' or $type eq 'dll'; - -my $incdir = $ARGV[1]; -die "No 'db.h' in $incdir\n" unless -f "$incdir/db.h"; - -my $libdir = $ARGV[2]; -die "$libdir: $!" unless -d $libdir; - -my $libname = get_lib_name($type, $incdir); -die "No '$libname.lib' in $libdir" unless -f "$libdir/$libname.lib"; -die "No '${libname}d.lib' in $libdir" unless -f "$libdir/${libname}d.lib"; - -my $srcdir = find_srcdir(); -my $apu_hw = canonpath("$srcdir/include/apu.hw"); -my $apu_want_hw = canonpath("$srcdir/include/apu_want.hw"); -my $apu_select_dbm_hw = canonpath("$srcdir/include/private/apu_select_dbm.hw"); -my $aprutil_dsp = canonpath("$srcdir/aprutil.dsp"); -my $libaprutil_dsp = canonpath("$srcdir/libaprutil.dsp"); -die "Can't find $apu_hw" unless -f $apu_hw; -die "Can't find $apu_want_hw" unless -f $apu_want_hw; -die "Can't find $apu_select_dbm_hw" unless -f $apu_select_dbm_hw; -die "Can't find $aprutil_dsp" unless -f $aprutil_dsp; -die "Can't find $libaprutil_dsp" unless -f $libaprutil_dsp; - - -######## -# Edit the header file templates -my $db_h = rel2abs(canonpath("$incdir/db.h")); -$db_h =~ s/\\/\//g; -edit_header($apu_hw, - [['^\s*\#\s*define\s+APU_HAVE_DB\s+0\s*$', - '#define APU_HAVE_DB 1']]); -edit_header($apu_want_hw, - [['^\s*\#\s*include\s+\\s*$', - "#include \"$db_h\""]]); -edit_header($apu_select_dbm_hw, - [['^\s*\#\s*define\s+APU_USE_DB\s+0\s*$', - '#define APU_USE_DB 1'], - ['^\s*\#\s*include\s+\\s*$', - "#include \"$db_h\""]]); - -######## -# Edit the .dsp files -my $libpath = rel2abs(canonpath("$libdir/$libname")); -edit_project($aprutil_dsp, $libpath); -edit_project($libaprutil_dsp, $libpath); - - -######## -# Print usage -sub usage() -{ - return ("Usage: perl w32locatedb.pl \n" - . " type: Library type to link with ('lib' or 'dll')\n" - . " incdir: BDB includes directory (for db.h)\n" - . " libdir: Library directory (for libdbXY[s][d].lib)\n"); -} - -######## -# Calculate the (possibly relative) path to the top of the apr-util -# source dir. -sub find_srcdir() -{ - my $srcdir = rel2abs(canonpath($0)); - my ($vol, $dir, $file) = splitpath($srcdir); - my @dirs = splitdir($dir); - die if scalar @dirs < 1; - do { $_ = pop @dirs } while ($_ eq ''); - return catpath($vol, catdir(@dirs), ''); -} - -######## -# Construct the name of the BDB library, based on the type and -# version information in db.h -sub get_lib_name($$) -{ - my ($type, $incdir) = @_; - my $major = undef; - my $minor = undef; - my $patch = undef; - - open(DBH, "< $incdir/db.h") - or die "Can't open $incdir/db.h: $!"; - while () { - chomp; - m/^\s*\#\s*define\s+DB_VERSION_(MAJOR|MINOR|PATCH)\s+(\d+)\s*$/; - next unless defined $1 and defined $2; - if ($1 eq 'MAJOR') { $major = $2; } - elsif ($1 eq 'MINOR') { $minor = $2; } - elsif ($1 eq 'PATCH') { $patch = $2; } - last if defined $major and defined $minor and defined $patch; - } - close(DBH); - die "Can't determine BDB version\n" - unless defined $major and defined $minor and defined $patch; - - print "Using BDB version $major.$minor.$patch\n"; - - my $libname = "libdb$major$minor"; - $libname .= 's' if $type eq 'lib'; - return $libname; -} - -######## -# Replace a file, keeping a backup copy -sub maybe_rename_with_backup($$$) -{ - my ($tmpfile, $file, $maybe) = @_; - if ($maybe) { - # Make the file writable by the owner. On Windows, this removes - # any read-only bits. - chmod((stat($file))[2] | 0600, $file); - rename($file, "${file}~"); - rename($tmpfile, $file); - } else { - print "No changes in $file\n"; - unlink($tmpfile); - } -} - -######## -# Edit a header template in-place. -sub edit_header($$) -{ - my ($file, $pairs) = @_; - my $tmpfile = "$file.tmp"; - my $substs = 0; - - open(IN, "< $file") or die "Can't open $file: $!"; - open(TMP, "> $tmpfile") or die "Can't open $tmpfile: $!"; - while () { - chomp; - foreach my $pair (@$pairs) { - $substs += s/${$pair}[0]/${$pair}[1]/; - } - print TMP $_, "\n"; - } - close(IN); - close(TMP); - - maybe_rename_with_backup($tmpfile, $file, $substs > 0); -} - -######## -# Edit a project file in-place -sub edit_project($$) -{ - my ($file, $libpath) = @_; - my $tmpfile = "$file.tmp"; - my $substs = 0; - my ($prog, $debug) = (undef, undef); - - my $libsearch = $libpath; - $libsearch =~ s/\\/\\\\/g; - - open(IN, "< $file") or die "Can't open $file: $!"; - open(TMP, "> $tmpfile") or die "Can't open $tmpfile: $!"; - while () { - chomp; - - if (m/^\# TARGTYPE \"[^\"]+\" 0x([0-9A-Za-z]+)/ - and defined $1) { - $prog = 'LINK32' if $1 eq '0102'; - $prog = 'LIB32' if $1 eq '0104'; - die "Unknown project type 0x$1" unless defined $prog; - } elsif (defined $prog - and m/^\# PROP Use_Debug_Libraries ([01])/ - and defined $1) { - $debug = $1; - } elsif (defined $prog and defined $debug - and m/^\# ADD $prog (\"$libsearch)?/ - and not defined $1) { - my $fullpath = - ($debug eq '1' ? "${libpath}d.lib" : "$libpath.lib"); - $substs += s/^\# ADD $prog /\# ADD $prog \"$fullpath\" /; - } elsif (m/^\# ADD CPP/) { - $substs += s/APU_USE_SDBM/APU_USE_DB/g; - } - - print TMP $_, "\n"; - } - close(IN); - close(TMP); - - maybe_rename_with_backup($tmpfile, $file, $substs > 0); -} diff --git a/libs/apr-util/buildconf b/libs/apr-util/buildconf deleted file mode 100755 index 718cb0ac2d..0000000000 --- a/libs/apr-util/buildconf +++ /dev/null @@ -1,111 +0,0 @@ -#!/bin/sh -# -# Copyright 1999-2005 The Apache Software Foundation or its licensors, as -# applicable. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# - -# Default place to look for apr source. Can be overridden with -# --with-apr=[directory] -apr_src_dir=../apr - -while test $# -gt 0 -do - # Normalize - case "$1" in - -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; - *) optarg= ;; - esac - - case "$1" in - --with-apr=*) - apr_src_dir=$optarg - ;; - esac - - shift -done - -if [ -f "$apr_src_dir/build/apr_common.m4" ]; then - apr_src_dir=`cd $apr_src_dir; pwd` - echo "" - echo "Looking for apr source in $apr_src_dir" -else - echo "" - echo "Problem finding apr source in $apr_src_dir." - echo "Use:" - echo " --with-apr=[directory]" - exit 1 -fi - -set -e - -# Remove some files, then copy them from apr source tree -rm -f build/apr_common.m4 build/find_apr.m4 build/install.sh \ - build/config.guess build/config.sub build/get-version.sh -cp -p $apr_src_dir/build/apr_common.m4 $apr_src_dir/build/find_apr.m4 \ - $apr_src_dir/build/install.sh $apr_src_dir/build/config.guess \ - $apr_src_dir/build/config.sub $apr_src_dir/build/get-version.sh \ - build/ - -# Remove aclocal.m4 as it'll break some builds... -rm -rf aclocal.m4 autom4te*.cache - -# -# Generate the autoconf header (include/apu_config.h) and ./configure -# -echo "Creating include/private/apu_config.h ..." -${AUTOHEADER:-autoheader} - -echo "Creating configure ..." -### do some work to toss config.cache? -if ${AUTOCONF:-autoconf}; then - : -else - echo "autoconf failed" - exit 1 -fi - -# -# Generate build-outputs.mk for the build systme -# -echo "Generating 'make' outputs ..." -#$apr_src_dir/build/gen-build.py make - -# -# If Expat has been bundled, then go and configure the thing -# -if [ -f xml/expat/buildconf.sh ]; then - echo "Invoking xml/expat/buildconf.sh ..." - (cd xml/expat; ./buildconf.sh) -fi - -# Remove autoconf cache again -rm -rf autom4te*.cache - -# Create RPM Spec file -if [ -f `which cut` ]; then - echo rebuilding rpm spec file - REVISION=`build/get-version.sh all include/apu_version.h APU` - VERSION=`echo $REVISION | cut -d- -s -f1` - RELEASE=`echo $REVISION | cut -d- -s -f2` - if [ "x$VERSION" = "x" ]; then - VERSION=$REVISION - RELEASE=1 - fi - sed -e "s/APU_VERSION/$VERSION/" -e "s/APU_RELEASE/$RELEASE/" \ - ./build/rpm/apr-util.spec.in > apr-util.spec -fi - diff --git a/libs/apr-util/config.layout b/libs/apr-util/config.layout deleted file mode 100644 index 907d0bb116..0000000000 --- a/libs/apr-util/config.layout +++ /dev/null @@ -1,232 +0,0 @@ -## -## config.layout -- Pre-defined Installation Path Layouts -## -## Hints: -## - layouts can be loaded with configure's --enable-layout=ID option -## - when no --enable-layout option is given, the default layout is `apr' -## - a trailing plus character (`+') on paths is replaced with a -## `/' suffix where is currently hardcoded to 'apr'. -## (This may become a configurable parameter at some point.) -## - -# Classical APR-util path layout designed for parallel installs. - - prefix: /usr/local/apr - exec_prefix: ${prefix} - bindir: ${exec_prefix}/bin - sbindir: ${exec_prefix}/bin - libdir: ${exec_prefix}/lib - libexecdir: ${exec_prefix}/modules - mandir: ${prefix}/man - sysconfdir: ${prefix}/conf - datadir: ${prefix} - installbuilddir: ${datadir}/build - includedir: ${prefix}/include/apr-${APRUTIL_MAJOR_VERSION} - localstatedir: ${prefix} - libsuffix: -${APRUTIL_MAJOR_VERSION} - - -# Classical single-installation APR path layout. - - prefix: /usr/local/apr - exec_prefix: ${prefix} - bindir: ${exec_prefix}/bin - sbindir: ${exec_prefix}/bin - libdir: ${exec_prefix}/lib - libexecdir: ${exec_prefix}/modules - mandir: ${prefix}/man - sysconfdir: ${prefix}/conf - datadir: ${prefix} - installbuilddir: ${datadir}/build - includedir: ${prefix}/include - localstatedir: ${prefix} - - -# GNU standards conforming path layout. -# See FSF's GNU project `make-stds' document for details. - - prefix: /usr/local - exec_prefix: ${prefix} - bindir: ${exec_prefix}/bin - sbindir: ${exec_prefix}/sbin - libdir: ${exec_prefix}/lib - libexecdir: ${exec_prefix}/libexec - mandir: ${prefix}/man - sysconfdir: ${prefix}/etc+ - datadir: ${prefix}/share+ - installbuilddir: ${datadir}/build - includedir: ${prefix}/include+ - localstatedir: ${prefix}/var+ - runtimedir: ${localstatedir}/run - - -# Mac OS X Server (Rhapsody) - - prefix: /Local/Library/WebServer - exec_prefix: /usr - bindir: ${exec_prefix}/bin - sbindir: ${exec_prefix}/sbin - libdir: ${exec_prefix}/lib - libexecdir: /System/Library/apr/Modules - mandir: ${exec_prefix}/share/man - sysconfdir: ${prefix}/Configuration - datadir: ${prefix} - installbuilddir: /System/Library/apr/Build - includedir: /System/Library/Frameworks/apr.framework/Versions/2.0/Headers - localstatedir: /var - runtimedir: ${prefix}/Logs - - -# Darwin/Mac OS Layout - - prefix: /usr - exec_prefix: ${prefix} - bindir: ${exec_prefix}/bin - sbindir: ${exec_prefix}/sbin - libdir: ${exec_prefix}/lib - libexecdir: ${exec_prefix}/libexec+ - mandir: ${prefix}/share/man - datadir: /Library/WebServer - sysconfdir: /etc+ - installbuilddir: ${prefix}/share/httpd/build - includedir: ${prefix}/include+ - localstatedir: /var - runtimedir: ${localstatedir}/run - - -# Red Hat Linux 7.x layout - - prefix: /usr - exec_prefix: ${prefix} - bindir: ${prefix}/bin - sbindir: ${prefix}/sbin - libdir: ${prefix}/lib - libexecdir: ${prefix}/lib/apr - mandir: ${prefix}/man - sysconfdir: /etc/httpd/conf - datadir: /var/www - installbuilddir: ${datadir}/build - includedir: ${prefix}/include/apr - localstatedir: /var - runtimedir: ${localstatedir}/run - - -# According to the /opt filesystem conventions - - prefix: /opt/apr - exec_prefix: ${prefix} - bindir: ${exec_prefix}/bin - sbindir: ${exec_prefix}/sbin - libdir: ${exec_prefix}/lib - libexecdir: ${exec_prefix}/libexec - mandir: ${prefix}/man - sysconfdir: /etc${prefix} - datadir: ${prefix}/share - installbuilddir: ${datadir}/build - includedir: ${prefix}/include - localstatedir: /var${prefix} - runtimedir: ${localstatedir}/run - - -# BeOS layout... - - prefix: /boot/home/apr - exec_prefix: ${prefix} - bindir: ${exec_prefix}/bin - sbindir: ${exec_prefix}/bin - libdir: ${exec_prefix}/lib - libexecdir: ${exec_prefix}/libexec - mandir: ${prefix}/man - sysconfdir: ${prefix}/conf - datadir: ${prefix} - installbuilddir: ${datadir}/build - includedir: ${prefix}/include - localstatedir: ${prefix} - runtimedir: ${localstatedir}/logs - - -# SuSE 6.x layout - - prefix: /usr - exec_prefix: ${prefix} - bindir: ${prefix}/bin - sbindir: ${prefix}/sbin - libdir: ${prefix}/lib - libexecdir: ${prefix}/lib/apr - mandir: ${prefix}/share/man - sysconfdir: /etc/httpd - datadir: /usr/local/httpd - installbuilddir: ${datadir}/build - includedir: ${prefix}/include/apr - localstatedir: /var/lib/httpd - runtimedir: /var/run - - -# BSD/OS layout - - prefix: /var/www - exec_prefix: /usr/contrib - bindir: ${exec_prefix}/bin - sbindir: ${exec_prefix}/bin - libdir: ${exec_prefix}/lib - libexecdir: ${exec_prefix}/libexec/apr - mandir: ${exec_prefix}/man - sysconfdir: ${prefix}/conf - datadir: ${prefix} - installbuilddir: ${datadir}/build - includedir: ${exec_prefix}/include/apr - localstatedir: /var - runtimedir: ${localstatedir}/run - - -# Solaris 8 Layout - - prefix: /usr/apr - exec_prefix: ${prefix} - bindir: ${exec_prefix}/bin - sbindir: ${exec_prefix}/bin - libdir: ${exec_prefix}/lib - libexecdir: ${exec_prefix}/libexec - mandir: ${exec_prefix}/man - sysconfdir: /etc/apr - datadir: /var/apr - installbuilddir: ${datadir}/build - includedir: ${exec_prefix}/include - localstatedir: ${prefix} - runtimedir: /var/run - - -# OpenBSD Layout - - prefix: /var/www - exec_prefix: /usr - bindir: ${exec_prefix}/bin - sbindir: ${exec_prefix}/sbin - libdir: ${exec_prefix}/lib - libexecdir: ${exec_prefix}/lib/apr/modules - mandir: ${exec_prefix}/share/man - sysconfdir: ${prefix}/conf - datadir: ${prefix} - installbuilddir: ${prefix}/build - includedir: ${exec_prefix}/lib/apr/include - localstatedir: ${prefix} - runtimedir: ${prefix}/logs - - -# Debian layout - - prefix: - exec_prefix: ${prefix}/usr - bindir: ${exec_prefix}/bin - sbindir: ${exec_prefix}/sbin - libdir: ${exec_prefix}/lib - libexecdir: ${exec_prefix}/lib/apr/modules - mandir: ${exec_prefix}/share/man - datadir: ${exec_prefix}/share/apr - includedir: ${exec_prefix}/include/apr-${APRUTIL_MAJOR_VERSION} - localstatedir: ${prefix}/var/run - runtimedir: ${prefix}/var/run - infodir: ${exec_prefix}/share/info - libsuffix: -${APRUTIL_MAJOR_VERSION} - installbuilddir: ${prefix}/usr/share/apache2/build - diff --git a/libs/apr-util/configure.ac b/libs/apr-util/configure.ac deleted file mode 100644 index c0b4a3bfad..0000000000 --- a/libs/apr-util/configure.ac +++ /dev/null @@ -1,216 +0,0 @@ -dnl -dnl Process this file with autoconf to produce a configure script -dnl - -AC_PREREQ(2.50) -AC_INIT(export_vars.sh.in) - -AC_CONFIG_HEADERS(include/private/apu_config.h) -AC_CONFIG_AUX_DIR(build) - -sinclude(build/apu-conf.m4) -sinclude(build/apu-iconv.m4) -sinclude(build/apu-hints.m4) -sinclude(build/apr_common.m4) -sinclude(build/find_apr.m4) -sinclude(build/dbm.m4) -sinclude(build/dbd.m4) - -dnl Generate ./config.nice for reproducing runs of configure -dnl -APR_CONFIG_NICE(config.nice) - -CFLAGS="$CFLAGS $CONFIGURE_CFLAGS" -CXXFLAGS="$CXXFLAGS $CONFIGURE_CXXFLAGS" -LDFLAGS="$LDFLAGS $CONFIGURE_LDFLAGS" - -dnl # Some initial steps for configuration. We setup the default directory -dnl # and which files are to be configured. - -dnl Absolute source/build directory -abs_srcdir=`(cd $srcdir && pwd)` -abs_builddir=`pwd` - -if test "$abs_builddir" != "$abs_srcdir"; then - USE_VPATH=1 - APU_CONFIG_LOCATION=build -else - APU_CONFIG_LOCATION=source -fi - -AC_SUBST(APU_CONFIG_LOCATION) - -AC_CANONICAL_SYSTEM - -AC_PROG_INSTALL - -dnl -dnl compute the top directory of the build -dnl note: this is needed for LIBTOOL and exporting the bundled Expat -dnl -top_builddir="$abs_builddir" -AC_SUBST(top_builddir) -AC_SUBST(abs_srcdir) -AC_SUBST(abs_builddir) - -dnl Initialize mkdir -p functionality. -APR_MKDIR_P_CHECK($abs_srcdir/build/mkdir.sh) - -dnl get our version information -get_version="$abs_srcdir/build/get-version.sh" -version_hdr="$abs_srcdir/include/apu_version.h" -APRUTIL_MAJOR_VERSION="`$get_version major $version_hdr APU`" -APRUTIL_DOTTED_VERSION="`$get_version all $version_hdr APU`" - -AC_SUBST(APRUTIL_DOTTED_VERSION) -AC_SUBST(APRUTIL_MAJOR_VERSION) - -echo "APR-util Version: ${APRUTIL_DOTTED_VERSION}" - -dnl Enable the layout handling code, then reparse the prefix-style -dnl arguments due to autoconf being a PITA. -APR_ENABLE_LAYOUT(apr-util) -APR_PARSE_ARGUMENTS - -dnl load os-specific hints for apr-util -APU_PRELOAD - -dnl -dnl set up the compilation flags and stuff -dnl - -APRUTIL_INCLUDES="" -APRUTIL_PRIV_INCLUDES="-I$top_builddir/include -I$top_builddir/include/private" -if test -n "$USE_VPATH"; then - APRUTIL_PRIV_INCLUDES="$APRUTIL_PRIV_INCLUDES -I$abs_srcdir/include/private -I$abs_srcdir/include" -fi - -dnl -dnl Find the APR includes directory and (possibly) the source (base) dir. -dnl -APU_FIND_APR - -dnl -dnl even though we use apr_rules.mk for building apr-util, we need -dnl to grab CC and CPP ahead of time so that apr-util config tests -dnl use the same compiler as APR; we need the same compiler options -dnl and feature test macros as well -dnl -APR_SETIFNULL(CC, `$apr_config --cc`) -APR_SETIFNULL(CPP, `$apr_config --cpp`) -APR_ADDTO(CFLAGS, `$apr_config --cflags`) -APR_ADDTO(CPPFLAGS, `$apr_config --cppflags`) - -dnl -dnl Find the APR-ICONV directory. -dnl -if test -d ../apr-iconv; then - APR_SUBDIR_CONFIG(../apr-iconv, - [$apache_apr_flags --prefix=$prefix --exec-prefix=$exec_prefix --libdir=$libdir --includedir=$includedir --bindir=$bindir --datadir=$datadir --with-installbuilddir=$installbuilddir], - [--enable-layout=*|\'--enable-layout=*]) - APRUTIL_EXPORT_LIBS="$abs_srcdir/../apr-iconv/lib/libapriconv.la $APRUTIL_EXPORT_LIBS" - APRUTIL_INCLUDES="-I$abs_srcdir/../apr-iconv/include $APRUTIL_INCLUDES" - APR_ICONV_DIR=../apr-iconv -else - APR_ICONV_DIR="" -fi -AC_SUBST(APR_ICONV_DIR) - -dnl Find LDAP library -dnl Determine what DBM backend type to use. -dnl Find Expat -dnl Find an iconv library -APU_FIND_LDAP -APU_CHECK_DBM -APU_CHECK_DBD -APU_CHECK_DBD_MYSQL -APU_CHECK_DBD_SQLITE3 -APU_CHECK_DBD_SQLITE2 -APU_FIND_EXPAT -APU_FIND_ICONV - -AC_SEARCH_LIBS(crypt, crypt ufc) -AC_MSG_CHECKING(if system crypt() function is threadsafe) -if test "x$apu_crypt_threadsafe" = "x1"; then - AC_DEFINE(APU_CRYPT_THREADSAFE, 1, [Define if the system crypt() function is threadsafe]) - msg="yes" -else - msg="no" -fi -AC_MSG_RESULT([$msg]) - -AC_CHECK_FUNCS(crypt_r, [ crypt_r="1" ], [ crypt_r="0" ]) -if test "$crypt_r" = "1"; then - APU_CHECK_CRYPT_R_STYLE -fi - -so_ext=$APR_SO_EXT -lib_target=$APR_LIB_TARGET -AC_SUBST(so_ext) -AC_SUBST(lib_target) - -APRUTIL_LIBNAME="aprutil${libsuffix}" -AC_SUBST(APRUTIL_LIBNAME) - -dnl -dnl Prep all the flags and stuff for compilation and export to other builds -dnl -APR_ADDTO(APRUTIL_LIBS, [$APR_LIBS]) - -AC_SUBST(APRUTIL_EXPORT_LIBS) -AC_SUBST(APRUTIL_PRIV_INCLUDES) -AC_SUBST(APRUTIL_INCLUDES) -AC_SUBST(APRUTIL_LDFLAGS) -AC_SUBST(APRUTIL_LIBS) -AC_SUBST(LDFLAGS) - -dnl copy apr's rules.mk into our build directory. -if test ! -d ./build; then - $mkdir_p build -fi -cp $APR_BUILD_DIR/apr_rules.mk $abs_builddir/build/rules.mk - -dnl -dnl BSD/OS (BSDi) needs to use a different include syntax in the Makefiles -dnl -case "$host_alias" in -*bsdi* | BSD/OS) - # Check whether they've installed GNU make - if make --version > /dev/null 2>&1; then - INCLUDE_RULES="include $abs_builddir/build/rules.mk" - INCLUDE_OUTPUTS="include $abs_srcdir/build-outputs.mk" - else - INCLUDE_RULES=".include \"$abs_builddir/build/rules.mk\"" - INCLUDE_OUTPUTS=".include \"$abs_srcdir/build-outputs.mk\"" - fi - ;; -*) - INCLUDE_RULES="include $abs_builddir/build/rules.mk" - INCLUDE_OUTPUTS="include $abs_srcdir/build-outputs.mk" - ;; -esac -AC_SUBST(INCLUDE_RULES) -AC_SUBST(INCLUDE_OUTPUTS) - -for d in include include/private; do - test -d $top_builddir/$d || mkdir $top_builddir/$d -done - -AC_CONFIG_FILES([Makefile export_vars.sh - build/pkg/pkginfo apr-util.pc - apu-$APRUTIL_MAJOR_VERSION-config:apu-config.in - include/private/apu_select_dbm.h - include/apr_ldap.h - include/apu.h include/apu_want.h]) - -AC_CONFIG_COMMANDS([default], [ -chmod +x apu-$APRUTIL_MAJOR_VERSION-config -],[ -APRUTIL_MAJOR_VERSION=$APRUTIL_MAJOR_VERSION -]) - -if test -d $srcdir/test; then - AC_CONFIG_FILES([test/Makefile]) -fi - -AC_OUTPUT diff --git a/libs/apr-util/configure.gnu b/libs/apr-util/configure.gnu deleted file mode 100644 index 72f3dccb09..0000000000 --- a/libs/apr-util/configure.gnu +++ /dev/null @@ -1,4 +0,0 @@ -#! /bin/sh -srcpath=$(dirname $0 2>/dev/null ) || srcpath="." -$srcpath/configure "$@" --with-apr=../apr --disable-shared --with-pic --without-sqlite2 --without-sqlite3 --with-expat=builtin - diff --git a/libs/apr-util/crypto/apr_md4.c b/libs/apr-util/crypto/apr_md4.c deleted file mode 100644 index 6b9d9f4b39..0000000000 --- a/libs/apr-util/crypto/apr_md4.c +++ /dev/null @@ -1,404 +0,0 @@ -/* Copyright 2001-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * This is derived from material copyright RSA Data Security, Inc. - * Their notice is reproduced below in its entirety. - * - * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All - * rights reserved. - * - * License to copy and use this software is granted provided that it - * is identified as the "RSA Data Security, Inc. MD4 Message-Digest - * Algorithm" in all material mentioning or referencing this software - * or this function. - * - * License is also granted to make and use derivative works provided - * that such works are identified as "derived from the RSA Data - * Security, Inc. MD4 Message-Digest Algorithm" in all material - * mentioning or referencing the derived work. - * - * RSA Data Security, Inc. makes no representations concerning either - * the merchantability of this software or the suitability of this - * software for any particular purpose. It is provided "as is" - * without express or implied warranty of any kind. - * - * These notices must be retained in any copies of any part of this - * documentation and/or software. - */ - -#include "apr_strings.h" -#include "apr_md4.h" -#include "apr_lib.h" - -#if APR_HAVE_STRING_H -#include -#endif -#if APR_HAVE_UNISTD_H -#include -#endif - -/* Constants for MD4Transform routine. - */ - -#define S11 3 -#define S12 7 -#define S13 11 -#define S14 19 -#define S21 3 -#define S22 5 -#define S23 9 -#define S24 13 -#define S31 3 -#define S32 9 -#define S33 11 -#define S34 15 - -static void MD4Transform(apr_uint32_t state[4], const unsigned char block[64]); -static void Encode(unsigned char *output, const apr_uint32_t *input, - unsigned int len); -static void Decode(apr_uint32_t *output, const unsigned char *input, - unsigned int len); - -static unsigned char PADDING[64] = -{ - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; - -#if APR_CHARSET_EBCDIC -static apr_xlate_t *xlate_ebcdic_to_ascii; /* used in apr_md4_encode() */ -#endif - -/* F, G and I are basic MD4 functions. - */ -#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) -#define G(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z))) -#define H(x, y, z) ((x) ^ (y) ^ (z)) - -/* ROTATE_LEFT rotates x left n bits. - */ -#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) - -/* FF, GG and HH are transformations for rounds 1, 2 and 3 */ -/* Rotation is separate from addition to prevent recomputation */ - -#define FF(a, b, c, d, x, s) { \ - (a) += F ((b), (c), (d)) + (x); \ - (a) = ROTATE_LEFT ((a), (s)); \ - } -#define GG(a, b, c, d, x, s) { \ - (a) += G ((b), (c), (d)) + (x) + (apr_uint32_t)0x5a827999; \ - (a) = ROTATE_LEFT ((a), (s)); \ - } -#define HH(a, b, c, d, x, s) { \ - (a) += H ((b), (c), (d)) + (x) + (apr_uint32_t)0x6ed9eba1; \ - (a) = ROTATE_LEFT ((a), (s)); \ - } - -/* MD4 initialization. Begins an MD4 operation, writing a new context. - */ -APU_DECLARE(apr_status_t) apr_md4_init(apr_md4_ctx_t *context) -{ - context->count[0] = context->count[1] = 0; - - /* Load magic initialization constants. */ - context->state[0] = 0x67452301; - context->state[1] = 0xefcdab89; - context->state[2] = 0x98badcfe; - context->state[3] = 0x10325476; - -#if APR_HAS_XLATE - context->xlate = NULL; -#endif - - return APR_SUCCESS; -} - -#if APR_HAS_XLATE -/* MD4 translation setup. Provides the APR translation handle - * to be used for translating the content before calculating the - * digest. - */ -APU_DECLARE(apr_status_t) apr_md4_set_xlate(apr_md4_ctx_t *context, - apr_xlate_t *xlate) -{ - apr_status_t rv; - int is_sb; - - /* TODO: remove the single-byte-only restriction from this code - */ - rv = apr_xlate_sb_get(xlate, &is_sb); - if (rv != APR_SUCCESS) { - return rv; - } - if (!is_sb) { - return APR_EINVAL; - } - context->xlate = xlate; - return APR_SUCCESS; -} -#endif /* APR_HAS_XLATE */ - -/* MD4 block update operation. Continues an MD4 message-digest - * operation, processing another message block, and updating the - * context. - */ -APU_DECLARE(apr_status_t) apr_md4_update(apr_md4_ctx_t *context, - const unsigned char *input, - apr_size_t inputLen) -{ - unsigned int i, idx, partLen; -#if APR_HAS_XLATE - apr_size_t inbytes_left, outbytes_left; -#endif - - /* Compute number of bytes mod 64 */ - idx = (unsigned int)((context->count[0] >> 3) & 0x3F); - - /* Update number of bits */ - if ((context->count[0] += ((apr_uint32_t)inputLen << 3)) - < ((apr_uint32_t)inputLen << 3)) - context->count[1]++; - context->count[1] += (apr_uint32_t)inputLen >> 29; - - partLen = 64 - idx; - - /* Transform as many times as possible. */ -#if !APR_HAS_XLATE - if (inputLen >= partLen) { - memcpy(&context->buffer[idx], input, partLen); - MD4Transform(context->state, context->buffer); - - for (i = partLen; i + 63 < inputLen; i += 64) - MD4Transform(context->state, &input[i]); - - idx = 0; - } - else - i = 0; - - /* Buffer remaining input */ - memcpy(&context->buffer[idx], &input[i], inputLen - i); -#else /*APR_HAS_XLATE*/ - if (inputLen >= partLen) { - if (context->xlate) { - inbytes_left = outbytes_left = partLen; - apr_xlate_conv_buffer(context->xlate, (const char *)input, - &inbytes_left, - (char *)&context->buffer[idx], - &outbytes_left); - } - else { - memcpy(&context->buffer[idx], input, partLen); - } - MD4Transform(context->state, context->buffer); - - for (i = partLen; i + 63 < inputLen; i += 64) { - if (context->xlate) { - unsigned char inp_tmp[64]; - inbytes_left = outbytes_left = 64; - apr_xlate_conv_buffer(context->xlate, (const char *)&input[i], - &inbytes_left, - (char *)inp_tmp, &outbytes_left); - MD4Transform(context->state, inp_tmp); - } - else { - MD4Transform(context->state, &input[i]); - } - } - - idx = 0; - } - else - i = 0; - - /* Buffer remaining input */ - if (context->xlate) { - inbytes_left = outbytes_left = inputLen - i; - apr_xlate_conv_buffer(context->xlate, (const char *)&input[i], - &inbytes_left, (char *)&context->buffer[idx], - &outbytes_left); - } - else { - memcpy(&context->buffer[idx], &input[i], inputLen - i); - } -#endif /*APR_HAS_XLATE*/ - return APR_SUCCESS; -} - -/* MD4 finalization. Ends an MD4 message-digest operation, writing the - * the message digest and zeroizing the context. - */ -APU_DECLARE(apr_status_t) apr_md4_final( - unsigned char digest[APR_MD4_DIGESTSIZE], - apr_md4_ctx_t *context) -{ - unsigned char bits[8]; - unsigned int idx, padLen; - - /* Save number of bits */ - Encode(bits, context->count, 8); - -#if APR_HAS_XLATE - /* apr_md4_update() should not translate for this final round. */ - context->xlate = NULL; -#endif /*APR_HAS_XLATE*/ - - /* Pad out to 56 mod 64. */ - idx = (unsigned int) ((context->count[0] >> 3) & 0x3f); - padLen = (idx < 56) ? (56 - idx) : (120 - idx); - apr_md4_update(context, PADDING, padLen); - - /* Append length (before padding) */ - apr_md4_update(context, bits, 8); - - /* Store state in digest */ - Encode(digest, context->state, APR_MD4_DIGESTSIZE); - - /* Zeroize sensitive information. */ - memset(context, 0, sizeof(*context)); - - return APR_SUCCESS; -} - -/* MD4 computation in one step (init, update, final) - */ -APU_DECLARE(apr_status_t) apr_md4(unsigned char digest[APR_MD4_DIGESTSIZE], - const unsigned char *input, - apr_size_t inputLen) -{ - apr_md4_ctx_t ctx; - apr_status_t rv; - - apr_md4_init(&ctx); - - if ((rv = apr_md4_update(&ctx, input, inputLen)) != APR_SUCCESS) - return rv; - - return apr_md4_final(digest, &ctx); -} - -/* MD4 basic transformation. Transforms state based on block. */ -static void MD4Transform(apr_uint32_t state[4], const unsigned char block[64]) -{ - apr_uint32_t a = state[0], b = state[1], c = state[2], d = state[3], - x[APR_MD4_DIGESTSIZE]; - - Decode(x, block, 64); - - /* Round 1 */ - FF (a, b, c, d, x[ 0], S11); /* 1 */ - FF (d, a, b, c, x[ 1], S12); /* 2 */ - FF (c, d, a, b, x[ 2], S13); /* 3 */ - FF (b, c, d, a, x[ 3], S14); /* 4 */ - FF (a, b, c, d, x[ 4], S11); /* 5 */ - FF (d, a, b, c, x[ 5], S12); /* 6 */ - FF (c, d, a, b, x[ 6], S13); /* 7 */ - FF (b, c, d, a, x[ 7], S14); /* 8 */ - FF (a, b, c, d, x[ 8], S11); /* 9 */ - FF (d, a, b, c, x[ 9], S12); /* 10 */ - FF (c, d, a, b, x[10], S13); /* 11 */ - FF (b, c, d, a, x[11], S14); /* 12 */ - FF (a, b, c, d, x[12], S11); /* 13 */ - FF (d, a, b, c, x[13], S12); /* 14 */ - FF (c, d, a, b, x[14], S13); /* 15 */ - FF (b, c, d, a, x[15], S14); /* 16 */ - - /* Round 2 */ - GG (a, b, c, d, x[ 0], S21); /* 17 */ - GG (d, a, b, c, x[ 4], S22); /* 18 */ - GG (c, d, a, b, x[ 8], S23); /* 19 */ - GG (b, c, d, a, x[12], S24); /* 20 */ - GG (a, b, c, d, x[ 1], S21); /* 21 */ - GG (d, a, b, c, x[ 5], S22); /* 22 */ - GG (c, d, a, b, x[ 9], S23); /* 23 */ - GG (b, c, d, a, x[13], S24); /* 24 */ - GG (a, b, c, d, x[ 2], S21); /* 25 */ - GG (d, a, b, c, x[ 6], S22); /* 26 */ - GG (c, d, a, b, x[10], S23); /* 27 */ - GG (b, c, d, a, x[14], S24); /* 28 */ - GG (a, b, c, d, x[ 3], S21); /* 29 */ - GG (d, a, b, c, x[ 7], S22); /* 30 */ - GG (c, d, a, b, x[11], S23); /* 31 */ - GG (b, c, d, a, x[15], S24); /* 32 */ - - /* Round 3 */ - HH (a, b, c, d, x[ 0], S31); /* 33 */ - HH (d, a, b, c, x[ 8], S32); /* 34 */ - HH (c, d, a, b, x[ 4], S33); /* 35 */ - HH (b, c, d, a, x[12], S34); /* 36 */ - HH (a, b, c, d, x[ 2], S31); /* 37 */ - HH (d, a, b, c, x[10], S32); /* 38 */ - HH (c, d, a, b, x[ 6], S33); /* 39 */ - HH (b, c, d, a, x[14], S34); /* 40 */ - HH (a, b, c, d, x[ 1], S31); /* 41 */ - HH (d, a, b, c, x[ 9], S32); /* 42 */ - HH (c, d, a, b, x[ 5], S33); /* 43 */ - HH (b, c, d, a, x[13], S34); /* 44 */ - HH (a, b, c, d, x[ 3], S31); /* 45 */ - HH (d, a, b, c, x[11], S32); /* 46 */ - HH (c, d, a, b, x[ 7], S33); /* 47 */ - HH (b, c, d, a, x[15], S34); /* 48 */ - - state[0] += a; - state[1] += b; - state[2] += c; - state[3] += d; - - /* Zeroize sensitive information. */ - memset(x, 0, sizeof(x)); -} - -/* Encodes input (apr_uint32_t) into output (unsigned char). Assumes len is - * a multiple of 4. - */ -static void Encode(unsigned char *output, const apr_uint32_t *input, - unsigned int len) -{ - unsigned int i, j; - apr_uint32_t k; - - for (i = 0, j = 0; j < len; i++, j += 4) { - k = input[i]; - output[j] = (unsigned char)(k & 0xff); - output[j + 1] = (unsigned char)((k >> 8) & 0xff); - output[j + 2] = (unsigned char)((k >> 16) & 0xff); - output[j + 3] = (unsigned char)((k >> 24) & 0xff); - } -} - -/* Decodes input (unsigned char) into output (apr_uint32_t). Assumes len is - * a multiple of 4. - */ -static void Decode(apr_uint32_t *output, const unsigned char *input, - unsigned int len) -{ - unsigned int i, j; - - for (i = 0, j = 0; j < len; i++, j += 4) - output[i] = ((apr_uint32_t)input[j]) | - (((apr_uint32_t)input[j + 1]) << 8) | - (((apr_uint32_t)input[j + 2]) << 16) | - (((apr_uint32_t)input[j + 3]) << 24); -} - -#if APR_CHARSET_EBCDIC -APU_DECLARE(apr_status_t) apr_MD4InitEBCDIC(apr_xlate_t *xlate) -{ - xlate_ebcdic_to_ascii = xlate; - return APR_SUCCESS; -} -#endif diff --git a/libs/apr-util/crypto/apr_md5.c b/libs/apr-util/crypto/apr_md5.c deleted file mode 100644 index 40942e30db..0000000000 --- a/libs/apr-util/crypto/apr_md5.c +++ /dev/null @@ -1,733 +0,0 @@ -/* - * This is work is derived from material Copyright RSA Data Security, Inc. - * - * The RSA copyright statement and Licence for that original material is - * included below. This is followed by the Apache copyright statement and - * licence for the modifications made to that material. - */ - -/* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm - */ - -/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All - rights reserved. - - License to copy and use this software is granted provided that it - is identified as the "RSA Data Security, Inc. MD5 Message-Digest - Algorithm" in all material mentioning or referencing this software - or this function. - - License is also granted to make and use derivative works provided - that such works are identified as "derived from the RSA Data - Security, Inc. MD5 Message-Digest Algorithm" in all material - mentioning or referencing the derived work. - - RSA Data Security, Inc. makes no representations concerning either - the merchantability of this software or the suitability of this - software for any particular purpose. It is provided "as is" - without express or implied warranty of any kind. - - These notices must be retained in any copies of any part of this - documentation and/or software. - */ - -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * The apr_md5_encode() routine uses much code obtained from the FreeBSD 3.0 - * MD5 crypt() function, which is licenced as follows: - * ---------------------------------------------------------------------------- - * "THE BEER-WARE LICENSE" (Revision 42): - * wrote this file. As long as you retain this notice you - * can do whatever you want with this stuff. If we meet some day, and you think - * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp - * ---------------------------------------------------------------------------- - */ -#include "apr_strings.h" -#include "apr_md5.h" -#include "apr_lib.h" -#include "apu_config.h" -#include "apr_sha1.h" - -#if APR_HAVE_STRING_H -#include -#endif -#if APR_HAVE_CRYPT_H -#include -#endif -#if APR_HAVE_UNISTD_H -#include -#endif -#if APR_HAVE_PTHREAD_H -#include -#endif - -/* Constants for MD5Transform routine. - */ - -#define S11 7 -#define S12 12 -#define S13 17 -#define S14 22 -#define S21 5 -#define S22 9 -#define S23 14 -#define S24 20 -#define S31 4 -#define S32 11 -#define S33 16 -#define S34 23 -#define S41 6 -#define S42 10 -#define S43 15 -#define S44 21 - -static void MD5Transform(apr_uint32_t state[4], const unsigned char block[64]); -static void Encode(unsigned char *output, const apr_uint32_t *input, - unsigned int len); -static void Decode(apr_uint32_t *output, const unsigned char *input, - unsigned int len); - -static unsigned char PADDING[64] = -{ - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; - -#if APR_CHARSET_EBCDIC -static apr_xlate_t *xlate_ebcdic_to_ascii; /* used in apr_md5_encode() */ -#endif - -/* F, G, H and I are basic MD5 functions. - */ -#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) -#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) -#define H(x, y, z) ((x) ^ (y) ^ (z)) -#define I(x, y, z) ((y) ^ ((x) | (~z))) - -/* ROTATE_LEFT rotates x left n bits. - */ -#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) - -/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. - * Rotation is separate from addition to prevent recomputation. - */ -#define FF(a, b, c, d, x, s, ac) { \ - (a) += F ((b), (c), (d)) + (x) + (apr_uint32_t)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define GG(a, b, c, d, x, s, ac) { \ - (a) += G ((b), (c), (d)) + (x) + (apr_uint32_t)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define HH(a, b, c, d, x, s, ac) { \ - (a) += H ((b), (c), (d)) + (x) + (apr_uint32_t)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define II(a, b, c, d, x, s, ac) { \ - (a) += I ((b), (c), (d)) + (x) + (apr_uint32_t)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } - -/* MD5 initialization. Begins an MD5 operation, writing a new context. - */ -APU_DECLARE(apr_status_t) apr_md5_init(apr_md5_ctx_t *context) -{ - context->count[0] = context->count[1] = 0; - - /* Load magic initialization constants. */ - context->state[0] = 0x67452301; - context->state[1] = 0xefcdab89; - context->state[2] = 0x98badcfe; - context->state[3] = 0x10325476; - context->xlate = NULL; - - return APR_SUCCESS; -} - -/* MD5 translation setup. Provides the APR translation handle - * to be used for translating the content before calculating the - * digest. - */ -APU_DECLARE(apr_status_t) apr_md5_set_xlate(apr_md5_ctx_t *context, - apr_xlate_t *xlate) -{ -#if APR_HAS_XLATE - apr_status_t rv; - int is_sb; - - /* TODO: remove the single-byte-only restriction from this code - */ - rv = apr_xlate_sb_get(xlate, &is_sb); - if (rv != APR_SUCCESS) { - return rv; - } - if (!is_sb) { - return APR_EINVAL; - } - context->xlate = xlate; - return APR_SUCCESS; -#else - return APR_ENOTIMPL; -#endif /* APR_HAS_XLATE */ -} - -/* MD5 block update operation. Continues an MD5 message-digest - * operation, processing another message block, and updating the - * context. - */ -APU_DECLARE(apr_status_t) apr_md5_update(apr_md5_ctx_t *context, - const void *_input, - apr_size_t inputLen) -{ - const unsigned char *input = _input; - unsigned int i, idx, partLen; -#if APR_HAS_XLATE - apr_size_t inbytes_left, outbytes_left; -#endif - - /* Compute number of bytes mod 64 */ - idx = (unsigned int)((context->count[0] >> 3) & 0x3F); - - /* Update number of bits */ - if ((context->count[0] += ((apr_uint32_t)inputLen << 3)) - < ((apr_uint32_t)inputLen << 3)) - context->count[1]++; - context->count[1] += (apr_uint32_t)inputLen >> 29; - - partLen = 64 - idx; - - /* Transform as many times as possible. */ -#if !APR_HAS_XLATE - if (inputLen >= partLen) { - memcpy(&context->buffer[idx], input, partLen); - MD5Transform(context->state, context->buffer); - - for (i = partLen; i + 63 < inputLen; i += 64) - MD5Transform(context->state, &input[i]); - - idx = 0; - } - else - i = 0; - - /* Buffer remaining input */ - memcpy(&context->buffer[idx], &input[i], inputLen - i); -#else /*APR_HAS_XLATE*/ - if (inputLen >= partLen) { - if (context->xlate) { - inbytes_left = outbytes_left = partLen; - apr_xlate_conv_buffer(context->xlate, (const char *)input, - &inbytes_left, - (char *)&context->buffer[idx], - &outbytes_left); - } - else { - memcpy(&context->buffer[idx], input, partLen); - } - MD5Transform(context->state, context->buffer); - - for (i = partLen; i + 63 < inputLen; i += 64) { - if (context->xlate) { - unsigned char inp_tmp[64]; - inbytes_left = outbytes_left = 64; - apr_xlate_conv_buffer(context->xlate, (const char *)&input[i], - &inbytes_left, (char *)inp_tmp, - &outbytes_left); - MD5Transform(context->state, inp_tmp); - } - else { - MD5Transform(context->state, &input[i]); - } - } - - idx = 0; - } - else - i = 0; - - /* Buffer remaining input */ - if (context->xlate) { - inbytes_left = outbytes_left = inputLen - i; - apr_xlate_conv_buffer(context->xlate, (const char *)&input[i], - &inbytes_left, (char *)&context->buffer[idx], - &outbytes_left); - } - else { - memcpy(&context->buffer[idx], &input[i], inputLen - i); - } -#endif /*APR_HAS_XLATE*/ - return APR_SUCCESS; -} - -/* MD5 finalization. Ends an MD5 message-digest operation, writing the - * the message digest and zeroizing the context. - */ -APU_DECLARE(apr_status_t) apr_md5_final(unsigned char digest[APR_MD5_DIGESTSIZE], - apr_md5_ctx_t *context) -{ - unsigned char bits[8]; - unsigned int idx, padLen; - - /* Save number of bits */ - Encode(bits, context->count, 8); - -#if APR_HAS_XLATE - /* apr_md5_update() should not translate for this final round. */ - context->xlate = NULL; -#endif /*APR_HAS_XLATE*/ - - /* Pad out to 56 mod 64. */ - idx = (unsigned int)((context->count[0] >> 3) & 0x3f); - padLen = (idx < 56) ? (56 - idx) : (120 - idx); - apr_md5_update(context, PADDING, padLen); - - /* Append length (before padding) */ - apr_md5_update(context, bits, 8); - - /* Store state in digest */ - Encode(digest, context->state, APR_MD5_DIGESTSIZE); - - /* Zeroize sensitive information. */ - memset(context, 0, sizeof(*context)); - - return APR_SUCCESS; -} - -/* MD5 in one step (init, update, final) - */ -APU_DECLARE(apr_status_t) apr_md5(unsigned char digest[APR_MD5_DIGESTSIZE], - const void *_input, - apr_size_t inputLen) -{ - const unsigned char *input = _input; - apr_md5_ctx_t ctx; - apr_status_t rv; - - apr_md5_init(&ctx); - - if ((rv = apr_md5_update(&ctx, input, inputLen)) != APR_SUCCESS) - return rv; - - return apr_md5_final(digest, &ctx); -} - -/* MD5 basic transformation. Transforms state based on block. */ -static void MD5Transform(apr_uint32_t state[4], const unsigned char block[64]) -{ - apr_uint32_t a = state[0], b = state[1], c = state[2], d = state[3], - x[APR_MD5_DIGESTSIZE]; - - Decode(x, block, 64); - - /* Round 1 */ - FF(a, b, c, d, x[0], S11, 0xd76aa478); /* 1 */ - FF(d, a, b, c, x[1], S12, 0xe8c7b756); /* 2 */ - FF(c, d, a, b, x[2], S13, 0x242070db); /* 3 */ - FF(b, c, d, a, x[3], S14, 0xc1bdceee); /* 4 */ - FF(a, b, c, d, x[4], S11, 0xf57c0faf); /* 5 */ - FF(d, a, b, c, x[5], S12, 0x4787c62a); /* 6 */ - FF(c, d, a, b, x[6], S13, 0xa8304613); /* 7 */ - FF(b, c, d, a, x[7], S14, 0xfd469501); /* 8 */ - FF(a, b, c, d, x[8], S11, 0x698098d8); /* 9 */ - FF(d, a, b, c, x[9], S12, 0x8b44f7af); /* 10 */ - FF(c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */ - FF(b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */ - FF(a, b, c, d, x[12], S11, 0x6b901122); /* 13 */ - FF(d, a, b, c, x[13], S12, 0xfd987193); /* 14 */ - FF(c, d, a, b, x[14], S13, 0xa679438e); /* 15 */ - FF(b, c, d, a, x[15], S14, 0x49b40821); /* 16 */ - - /* Round 2 */ - GG(a, b, c, d, x[1], S21, 0xf61e2562); /* 17 */ - GG(d, a, b, c, x[6], S22, 0xc040b340); /* 18 */ - GG(c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */ - GG(b, c, d, a, x[0], S24, 0xe9b6c7aa); /* 20 */ - GG(a, b, c, d, x[5], S21, 0xd62f105d); /* 21 */ - GG(d, a, b, c, x[10], S22, 0x2441453); /* 22 */ - GG(c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */ - GG(b, c, d, a, x[4], S24, 0xe7d3fbc8); /* 24 */ - GG(a, b, c, d, x[9], S21, 0x21e1cde6); /* 25 */ - GG(d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */ - GG(c, d, a, b, x[3], S23, 0xf4d50d87); /* 27 */ - GG(b, c, d, a, x[8], S24, 0x455a14ed); /* 28 */ - GG(a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */ - GG(d, a, b, c, x[2], S22, 0xfcefa3f8); /* 30 */ - GG(c, d, a, b, x[7], S23, 0x676f02d9); /* 31 */ - GG(b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */ - - /* Round 3 */ - HH(a, b, c, d, x[5], S31, 0xfffa3942); /* 33 */ - HH(d, a, b, c, x[8], S32, 0x8771f681); /* 34 */ - HH(c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */ - HH(b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */ - HH(a, b, c, d, x[1], S31, 0xa4beea44); /* 37 */ - HH(d, a, b, c, x[4], S32, 0x4bdecfa9); /* 38 */ - HH(c, d, a, b, x[7], S33, 0xf6bb4b60); /* 39 */ - HH(b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */ - HH(a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */ - HH(d, a, b, c, x[0], S32, 0xeaa127fa); /* 42 */ - HH(c, d, a, b, x[3], S33, 0xd4ef3085); /* 43 */ - HH(b, c, d, a, x[6], S34, 0x4881d05); /* 44 */ - HH(a, b, c, d, x[9], S31, 0xd9d4d039); /* 45 */ - HH(d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */ - HH(c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */ - HH(b, c, d, a, x[2], S34, 0xc4ac5665); /* 48 */ - - /* Round 4 */ - II(a, b, c, d, x[0], S41, 0xf4292244); /* 49 */ - II(d, a, b, c, x[7], S42, 0x432aff97); /* 50 */ - II(c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */ - II(b, c, d, a, x[5], S44, 0xfc93a039); /* 52 */ - II(a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */ - II(d, a, b, c, x[3], S42, 0x8f0ccc92); /* 54 */ - II(c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */ - II(b, c, d, a, x[1], S44, 0x85845dd1); /* 56 */ - II(a, b, c, d, x[8], S41, 0x6fa87e4f); /* 57 */ - II(d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */ - II(c, d, a, b, x[6], S43, 0xa3014314); /* 59 */ - II(b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */ - II(a, b, c, d, x[4], S41, 0xf7537e82); /* 61 */ - II(d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */ - II(c, d, a, b, x[2], S43, 0x2ad7d2bb); /* 63 */ - II(b, c, d, a, x[9], S44, 0xeb86d391); /* 64 */ - - state[0] += a; - state[1] += b; - state[2] += c; - state[3] += d; - - /* Zeroize sensitive information. */ - memset(x, 0, sizeof(x)); -} - -/* Encodes input (apr_uint32_t) into output (unsigned char). Assumes len is - * a multiple of 4. - */ -static void Encode(unsigned char *output, const apr_uint32_t *input, - unsigned int len) -{ - unsigned int i, j; - apr_uint32_t k; - - for (i = 0, j = 0; j < len; i++, j += 4) { - k = input[i]; - output[j] = (unsigned char)(k & 0xff); - output[j + 1] = (unsigned char)((k >> 8) & 0xff); - output[j + 2] = (unsigned char)((k >> 16) & 0xff); - output[j + 3] = (unsigned char)((k >> 24) & 0xff); - } -} - -/* Decodes input (unsigned char) into output (apr_uint32_t). Assumes len is - * a multiple of 4. - */ -static void Decode(apr_uint32_t *output, const unsigned char *input, - unsigned int len) -{ - unsigned int i, j; - - for (i = 0, j = 0; j < len; i++, j += 4) - output[i] = ((apr_uint32_t)input[j]) | - (((apr_uint32_t)input[j + 1]) << 8) | - (((apr_uint32_t)input[j + 2]) << 16) | - (((apr_uint32_t)input[j + 3]) << 24); -} - -#if APR_CHARSET_EBCDIC -APU_DECLARE(apr_status_t) apr_MD5InitEBCDIC(apr_xlate_t *xlate) -{ - xlate_ebcdic_to_ascii = xlate; - return APR_SUCCESS; -} -#endif - -/* - * Define the Magic String prefix that identifies a password as being - * hashed using our algorithm. - */ -static const char *apr1_id = "$apr1$"; - -/* - * The following MD5 password encryption code was largely borrowed from - * the FreeBSD 3.0 /usr/src/lib/libcrypt/crypt.c file, which is - * licenced as stated at the top of this file. - */ - -static void to64(char *s, unsigned long v, int n) -{ - static unsigned char itoa64[] = /* 0 ... 63 => ASCII - 64 */ - "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; - - while (--n >= 0) { - *s++ = itoa64[v&0x3f]; - v >>= 6; - } -} - -APU_DECLARE(apr_status_t) apr_md5_encode(const char *pw, const char *salt, - char *result, apr_size_t nbytes) -{ - /* - * Minimum size is 8 bytes for salt, plus 1 for the trailing NUL, - * plus 4 for the '$' separators, plus the password hash itself. - * Let's leave a goodly amount of leeway. - */ - - char passwd[120], *p; - const char *sp, *ep; - unsigned char final[APR_MD5_DIGESTSIZE]; - apr_ssize_t sl, pl, i; - apr_md5_ctx_t ctx, ctx1; - unsigned long l; - - /* - * Refine the salt first. It's possible we were given an already-hashed - * string as the salt argument, so extract the actual salt value from it - * if so. Otherwise just use the string up to the first '$' as the salt. - */ - sp = salt; - - /* - * If it starts with the magic string, then skip that. - */ - if (!strncmp(sp, apr1_id, strlen(apr1_id))) { - sp += strlen(apr1_id); - } - - /* - * It stops at the first '$' or 8 chars, whichever comes first - */ - for (ep = sp; (*ep != '\0') && (*ep != '$') && (ep < (sp + 8)); ep++) { - continue; - } - - /* - * Get the length of the true salt - */ - sl = ep - sp; - - /* - * 'Time to make the doughnuts..' - */ - apr_md5_init(&ctx); -#if APR_CHARSET_EBCDIC - apr_md5_set_xlate(&ctx, xlate_ebcdic_to_ascii); -#endif - - /* - * The password first, since that is what is most unknown - */ - apr_md5_update(&ctx, pw, strlen(pw)); - - /* - * Then our magic string - */ - apr_md5_update(&ctx, apr1_id, strlen(apr1_id)); - - /* - * Then the raw salt - */ - apr_md5_update(&ctx, sp, sl); - - /* - * Then just as many characters of the MD5(pw, salt, pw) - */ - apr_md5_init(&ctx1); - apr_md5_update(&ctx1, pw, strlen(pw)); - apr_md5_update(&ctx1, sp, sl); - apr_md5_update(&ctx1, pw, strlen(pw)); - apr_md5_final(final, &ctx1); - for (pl = strlen(pw); pl > 0; pl -= APR_MD5_DIGESTSIZE) { - apr_md5_update(&ctx, final, - (pl > APR_MD5_DIGESTSIZE) ? APR_MD5_DIGESTSIZE : pl); - } - - /* - * Don't leave anything around in vm they could use. - */ - memset(final, 0, sizeof(final)); - - /* - * Then something really weird... - */ - for (i = strlen(pw); i != 0; i >>= 1) { - if (i & 1) { - apr_md5_update(&ctx, final, 1); - } - else { - apr_md5_update(&ctx, pw, 1); - } - } - - /* - * Now make the output string. We know our limitations, so we - * can use the string routines without bounds checking. - */ - strcpy(passwd, apr1_id); - strncat(passwd, sp, sl); - strcat(passwd, "$"); - - apr_md5_final(final, &ctx); - - /* - * And now, just to make sure things don't run too fast.. - * On a 60 Mhz Pentium this takes 34 msec, so you would - * need 30 seconds to build a 1000 entry dictionary... - */ - for (i = 0; i < 1000; i++) { - apr_md5_init(&ctx1); - if (i & 1) { - apr_md5_update(&ctx1, pw, strlen(pw)); - } - else { - apr_md5_update(&ctx1, final, APR_MD5_DIGESTSIZE); - } - if (i % 3) { - apr_md5_update(&ctx1, sp, sl); - } - - if (i % 7) { - apr_md5_update(&ctx1, pw, strlen(pw)); - } - - if (i & 1) { - apr_md5_update(&ctx1, final, APR_MD5_DIGESTSIZE); - } - else { - apr_md5_update(&ctx1, pw, strlen(pw)); - } - apr_md5_final(final,&ctx1); - } - - p = passwd + strlen(passwd); - - l = (final[ 0]<<16) | (final[ 6]<<8) | final[12]; to64(p, l, 4); p += 4; - l = (final[ 1]<<16) | (final[ 7]<<8) | final[13]; to64(p, l, 4); p += 4; - l = (final[ 2]<<16) | (final[ 8]<<8) | final[14]; to64(p, l, 4); p += 4; - l = (final[ 3]<<16) | (final[ 9]<<8) | final[15]; to64(p, l, 4); p += 4; - l = (final[ 4]<<16) | (final[10]<<8) | final[ 5]; to64(p, l, 4); p += 4; - l = final[11] ; to64(p, l, 2); p += 2; - *p = '\0'; - - /* - * Don't leave anything around in vm they could use. - */ - memset(final, 0, sizeof(final)); - - apr_cpystrn(result, passwd, nbytes - 1); - return APR_SUCCESS; -} - -#if !defined(WIN32) && !defined(BEOS) && !defined(NETWARE) -#if defined(APU_CRYPT_THREADSAFE) || !APR_HAS_THREADS || \ - defined(CRYPT_R_CRYPTD) || defined(CRYPT_R_STRUCT_CRYPT_DATA) - -#define crypt_mutex_lock() -#define crypt_mutex_unlock() - -#elif APR_HAVE_PTHREAD_H && defined(PTHREAD_MUTEX_INITIALIZER) - -static pthread_mutex_t crypt_mutex = PTHREAD_MUTEX_INITIALIZER; -static void crypt_mutex_lock(void) -{ - pthread_mutex_lock(&crypt_mutex); -} - -static void crypt_mutex_unlock(void) -{ - pthread_mutex_unlock(&crypt_mutex); -} - -#else - -#error apr_password_validate() is not threadsafe. rebuild APR without thread support. - -#endif -#endif - -/* - * Validate a plaintext password against a smashed one. Uses either - * crypt() (if available) or apr_md5_encode() or apr_sha1_base64(), depending - * upon the format of the smashed input password. Returns APR_SUCCESS if - * they match, or APR_EMISMATCH if they don't. If the platform doesn't - * support crypt, then the default check is against a clear text string. - */ -APU_DECLARE(apr_status_t) apr_password_validate(const char *passwd, - const char *hash) -{ - char sample[120]; -#if !defined(WIN32) && !defined(BEOS) && !defined(NETWARE) - char *crypt_pw; -#endif - if (!strncmp(hash, apr1_id, strlen(apr1_id))) { - /* - * The hash was created using our custom algorithm. - */ - apr_md5_encode(passwd, hash, sample, sizeof(sample)); - } - else if (!strncmp(hash, APR_SHA1PW_ID, APR_SHA1PW_IDLEN)) { - apr_sha1_base64(passwd, strlen(passwd), sample); - } - else { - /* - * It's not our algorithm, so feed it to crypt() if possible. - */ -#if defined(WIN32) || defined(BEOS) || defined(NETWARE) - apr_cpystrn(sample, passwd, sizeof(sample) - 1); -#elif defined(CRYPT_R_CRYPTD) - CRYPTD buffer; - - crypt_pw = crypt_r(passwd, hash, &buffer); - apr_cpystrn(sample, crypt_pw, sizeof(sample) - 1); -#elif defined(CRYPT_R_STRUCT_CRYPT_DATA) - struct crypt_data buffer; - - /* having to clear this seems bogus... GNU doc is - * confusing... user report found from google says - * the crypt_data struct had to be cleared to get - * the same result as plain crypt() - */ - memset(&buffer, 0, sizeof(buffer)); - crypt_pw = crypt_r(passwd, hash, &buffer); - apr_cpystrn(sample, crypt_pw, sizeof(sample) - 1); -#else - /* Do a bit of sanity checking since we know that crypt_r() - * should always be used for threaded builds on AIX, and - * problems in configure logic can result in the wrong - * choice being made. - */ -#if defined(_AIX) && APR_HAS_THREADS -#error Configuration error! crypt_r() should have been selected! -#endif - - /* Handle thread safety issues by holding a mutex around the - * call to crypt(). - */ - crypt_mutex_lock(); - crypt_pw = crypt(passwd, hash); - apr_cpystrn(sample, crypt_pw, sizeof(sample) - 1); - crypt_mutex_unlock(); -#endif - } - return (strcmp(sample, hash) == 0) ? APR_SUCCESS : APR_EMISMATCH; -} diff --git a/libs/apr-util/crypto/apr_sha1.c b/libs/apr-util/crypto/apr_sha1.c deleted file mode 100644 index 0b139127e6..0000000000 --- a/libs/apr-util/crypto/apr_sha1.c +++ /dev/null @@ -1,372 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * The exported function: - * - * apr_sha1_base64(const char *clear, int len, char *out); - * - * provides a means to SHA1 crypt/encode a plaintext password in - * a way which makes password files compatible with those commonly - * used in netscape web and ldap installations. It was put together - * by Clinton Wong , who also notes that: - * - * Note: SHA1 support is useful for migration purposes, but is less - * secure than Apache's password format, since Apache's (MD5) - * password format uses a random eight character salt to generate - * one of many possible hashes for the same password. Netscape - * uses plain SHA1 without a salt, so the same password - * will always generate the same hash, making it easier - * to break since the search space is smaller. - * - * See also the documentation in support/SHA1 as to hints on how to - * migrate an existing netscape installation and other supplied utitlites. - * - * This software also makes use of the following component: - * - * NIST Secure Hash Algorithm - * heavily modified by Uwe Hollerbach uh@alumni.caltech edu - * from Peter C. Gutmann's implementation as found in - * Applied Cryptography by Bruce Schneier - * This code is hereby placed in the public domain - */ - -#include "apr_sha1.h" -#include "apr_base64.h" -#include "apr_strings.h" -#include "apr_lib.h" -#if APR_CHARSET_EBCDIC -#include "apr_xlate.h" -#endif /*APR_CHARSET_EBCDIC*/ -#include - -/* a bit faster & bigger, if defined */ -#define UNROLL_LOOPS - -/* NIST's proposed modification to SHA, 7/11/94 */ -#define USE_MODIFIED_SHA - -/* SHA f()-functions */ -#define f1(x,y,z) ((x & y) | (~x & z)) -#define f2(x,y,z) (x ^ y ^ z) -#define f3(x,y,z) ((x & y) | (x & z) | (y & z)) -#define f4(x,y,z) (x ^ y ^ z) - -/* SHA constants */ -#define CONST1 0x5a827999L -#define CONST2 0x6ed9eba1L -#define CONST3 0x8f1bbcdcL -#define CONST4 0xca62c1d6L - -/* 32-bit rotate */ - -#define ROT32(x,n) ((x << n) | (x >> (32 - n))) - -#define FUNC(n,i) \ - temp = ROT32(A,5) + f##n(B,C,D) + E + W[i] + CONST##n; \ - E = D; D = C; C = ROT32(B,30); B = A; A = temp - -#define SHA_BLOCKSIZE 64 - -#if APR_CHARSET_EBCDIC -static apr_xlate_t *ebcdic2ascii_xlate; - -APU_DECLARE(apr_status_t) apr_SHA1InitEBCDIC(apr_xlate_t *x) -{ - apr_status_t rv; - int onoff; - - /* Only single-byte conversion is supported. - */ - rv = apr_xlate_sb_get(x, &onoff); - if (rv) { - return rv; - } - if (!onoff) { /* If conversion is not single-byte-only */ - return APR_EINVAL; - } - ebcdic2ascii_xlate = x; - return APR_SUCCESS; -} -#endif - -/* do SHA transformation */ -static void sha_transform(apr_sha1_ctx_t *sha_info) -{ - int i; - apr_uint32_t temp, A, B, C, D, E, W[80]; - - for (i = 0; i < 16; ++i) { - W[i] = sha_info->data[i]; - } - for (i = 16; i < 80; ++i) { - W[i] = W[i-3] ^ W[i-8] ^ W[i-14] ^ W[i-16]; -#ifdef USE_MODIFIED_SHA - W[i] = ROT32(W[i], 1); -#endif /* USE_MODIFIED_SHA */ - } - A = sha_info->digest[0]; - B = sha_info->digest[1]; - C = sha_info->digest[2]; - D = sha_info->digest[3]; - E = sha_info->digest[4]; -#ifdef UNROLL_LOOPS - FUNC(1, 0); FUNC(1, 1); FUNC(1, 2); FUNC(1, 3); FUNC(1, 4); - FUNC(1, 5); FUNC(1, 6); FUNC(1, 7); FUNC(1, 8); FUNC(1, 9); - FUNC(1,10); FUNC(1,11); FUNC(1,12); FUNC(1,13); FUNC(1,14); - FUNC(1,15); FUNC(1,16); FUNC(1,17); FUNC(1,18); FUNC(1,19); - - FUNC(2,20); FUNC(2,21); FUNC(2,22); FUNC(2,23); FUNC(2,24); - FUNC(2,25); FUNC(2,26); FUNC(2,27); FUNC(2,28); FUNC(2,29); - FUNC(2,30); FUNC(2,31); FUNC(2,32); FUNC(2,33); FUNC(2,34); - FUNC(2,35); FUNC(2,36); FUNC(2,37); FUNC(2,38); FUNC(2,39); - - FUNC(3,40); FUNC(3,41); FUNC(3,42); FUNC(3,43); FUNC(3,44); - FUNC(3,45); FUNC(3,46); FUNC(3,47); FUNC(3,48); FUNC(3,49); - FUNC(3,50); FUNC(3,51); FUNC(3,52); FUNC(3,53); FUNC(3,54); - FUNC(3,55); FUNC(3,56); FUNC(3,57); FUNC(3,58); FUNC(3,59); - - FUNC(4,60); FUNC(4,61); FUNC(4,62); FUNC(4,63); FUNC(4,64); - FUNC(4,65); FUNC(4,66); FUNC(4,67); FUNC(4,68); FUNC(4,69); - FUNC(4,70); FUNC(4,71); FUNC(4,72); FUNC(4,73); FUNC(4,74); - FUNC(4,75); FUNC(4,76); FUNC(4,77); FUNC(4,78); FUNC(4,79); -#else /* !UNROLL_LOOPS */ - for (i = 0; i < 20; ++i) { - FUNC(1,i); - } - for (i = 20; i < 40; ++i) { - FUNC(2,i); - } - for (i = 40; i < 60; ++i) { - FUNC(3,i); - } - for (i = 60; i < 80; ++i) { - FUNC(4,i); - } -#endif /* !UNROLL_LOOPS */ - sha_info->digest[0] += A; - sha_info->digest[1] += B; - sha_info->digest[2] += C; - sha_info->digest[3] += D; - sha_info->digest[4] += E; -} - -union endianTest { - long Long; - char Char[sizeof(long)]; -}; - -static char isLittleEndian(void) -{ - static union endianTest u; - u.Long = 1; - return (u.Char[0] == 1); -} - -/* change endianness of data */ - -/* count is the number of bytes to do an endian flip */ -static void maybe_byte_reverse(apr_uint32_t *buffer, int count) -{ - int i; - apr_byte_t ct[4], *cp; - - if (isLittleEndian()) { /* do the swap only if it is little endian */ - count /= sizeof(apr_uint32_t); - cp = (apr_byte_t *) buffer; - for (i = 0; i < count; ++i) { - ct[0] = cp[0]; - ct[1] = cp[1]; - ct[2] = cp[2]; - ct[3] = cp[3]; - cp[0] = ct[3]; - cp[1] = ct[2]; - cp[2] = ct[1]; - cp[3] = ct[0]; - cp += sizeof(apr_uint32_t); - } - } -} - -/* initialize the SHA digest */ - -APU_DECLARE(void) apr_sha1_init(apr_sha1_ctx_t *sha_info) -{ - sha_info->digest[0] = 0x67452301L; - sha_info->digest[1] = 0xefcdab89L; - sha_info->digest[2] = 0x98badcfeL; - sha_info->digest[3] = 0x10325476L; - sha_info->digest[4] = 0xc3d2e1f0L; - sha_info->count_lo = 0L; - sha_info->count_hi = 0L; - sha_info->local = 0; -} - -/* update the SHA digest */ - -APU_DECLARE(void) apr_sha1_update_binary(apr_sha1_ctx_t *sha_info, - const unsigned char *buffer, - unsigned int count) -{ - unsigned int i; - - if ((sha_info->count_lo + ((apr_uint32_t) count << 3)) < sha_info->count_lo) { - ++sha_info->count_hi; - } - sha_info->count_lo += (apr_uint32_t) count << 3; - sha_info->count_hi += (apr_uint32_t) count >> 29; - if (sha_info->local) { - i = SHA_BLOCKSIZE - sha_info->local; - if (i > count) { - i = count; - } - memcpy(((apr_byte_t *) sha_info->data) + sha_info->local, buffer, i); - count -= i; - buffer += i; - sha_info->local += i; - if (sha_info->local == SHA_BLOCKSIZE) { - maybe_byte_reverse(sha_info->data, SHA_BLOCKSIZE); - sha_transform(sha_info); - } - else { - return; - } - } - while (count >= SHA_BLOCKSIZE) { - memcpy(sha_info->data, buffer, SHA_BLOCKSIZE); - buffer += SHA_BLOCKSIZE; - count -= SHA_BLOCKSIZE; - maybe_byte_reverse(sha_info->data, SHA_BLOCKSIZE); - sha_transform(sha_info); - } - memcpy(sha_info->data, buffer, count); - sha_info->local = count; -} - -APU_DECLARE(void) apr_sha1_update(apr_sha1_ctx_t *sha_info, const char *buf, - unsigned int count) -{ -#if APR_CHARSET_EBCDIC - int i; - const apr_byte_t *buffer = (const apr_byte_t *) buf; - apr_size_t inbytes_left, outbytes_left; - - if ((sha_info->count_lo + ((apr_uint32_t) count << 3)) < sha_info->count_lo) { - ++sha_info->count_hi; - } - sha_info->count_lo += (apr_uint32_t) count << 3; - sha_info->count_hi += (apr_uint32_t) count >> 29; - /* Is there a remainder of the previous Update operation? */ - if (sha_info->local) { - i = SHA_BLOCKSIZE - sha_info->local; - if (i > count) { - i = count; - } - inbytes_left = outbytes_left = i; - apr_xlate_conv_buffer(ebcdic2ascii_xlate, buffer, &inbytes_left, - ((apr_byte_t *) sha_info->data) + sha_info->local, - &outbytes_left); - count -= i; - buffer += i; - sha_info->local += i; - if (sha_info->local == SHA_BLOCKSIZE) { - maybe_byte_reverse(sha_info->data, SHA_BLOCKSIZE); - sha_transform(sha_info); - } - else { - return; - } - } - while (count >= SHA_BLOCKSIZE) { - inbytes_left = outbytes_left = SHA_BLOCKSIZE; - apr_xlate_conv_buffer(ebcdic2ascii_xlate, buffer, &inbytes_left, - (apr_byte_t *) sha_info->data, &outbytes_left); - buffer += SHA_BLOCKSIZE; - count -= SHA_BLOCKSIZE; - maybe_byte_reverse(sha_info->data, SHA_BLOCKSIZE); - sha_transform(sha_info); - } - inbytes_left = outbytes_left = count; - apr_xlate_conv_buffer(ebcdic2ascii_xlate, buffer, &inbytes_left, - (apr_byte_t *) sha_info->data, &outbytes_left); - sha_info->local = count; -#else - apr_sha1_update_binary(sha_info, (const unsigned char *) buf, count); -#endif -} - -/* finish computing the SHA digest */ - -APU_DECLARE(void) apr_sha1_final(unsigned char digest[APR_SHA1_DIGESTSIZE], - apr_sha1_ctx_t *sha_info) -{ - int count, i, j; - apr_uint32_t lo_bit_count, hi_bit_count, k; - - lo_bit_count = sha_info->count_lo; - hi_bit_count = sha_info->count_hi; - count = (int) ((lo_bit_count >> 3) & 0x3f); - ((apr_byte_t *) sha_info->data)[count++] = 0x80; - if (count > SHA_BLOCKSIZE - 8) { - memset(((apr_byte_t *) sha_info->data) + count, 0, SHA_BLOCKSIZE - count); - maybe_byte_reverse(sha_info->data, SHA_BLOCKSIZE); - sha_transform(sha_info); - memset((apr_byte_t *) sha_info->data, 0, SHA_BLOCKSIZE - 8); - } - else { - memset(((apr_byte_t *) sha_info->data) + count, 0, - SHA_BLOCKSIZE - 8 - count); - } - maybe_byte_reverse(sha_info->data, SHA_BLOCKSIZE); - sha_info->data[14] = hi_bit_count; - sha_info->data[15] = lo_bit_count; - sha_transform(sha_info); - - for (i = 0, j = 0; j < APR_SHA1_DIGESTSIZE; i++) { - k = sha_info->digest[i]; - digest[j++] = (unsigned char) ((k >> 24) & 0xff); - digest[j++] = (unsigned char) ((k >> 16) & 0xff); - digest[j++] = (unsigned char) ((k >> 8) & 0xff); - digest[j++] = (unsigned char) (k & 0xff); - } -} - - -APU_DECLARE(void) apr_sha1_base64(const char *clear, int len, char *out) -{ - int l; - apr_sha1_ctx_t context; - apr_byte_t digest[APR_SHA1_DIGESTSIZE]; - - if (strncmp(clear, APR_SHA1PW_ID, APR_SHA1PW_IDLEN) == 0) { - clear += APR_SHA1PW_IDLEN; - } - - apr_sha1_init(&context); - apr_sha1_update(&context, clear, len); - apr_sha1_final(digest, &context); - - /* private marker. */ - apr_cpystrn(out, APR_SHA1PW_ID, APR_SHA1PW_IDLEN + 1); - - /* SHA1 hash is always 20 chars */ - l = apr_base64_encode_binary(out + APR_SHA1PW_IDLEN, digest, sizeof(digest)); - out[l + APR_SHA1PW_IDLEN] = '\0'; - - /* - * output of base64 encoded SHA1 is always 28 chars + APR_SHA1PW_IDLEN - */ -} diff --git a/libs/apr-util/crypto/getuuid.c b/libs/apr-util/crypto/getuuid.c deleted file mode 100644 index 293b24eeb2..0000000000 --- a/libs/apr-util/crypto/getuuid.c +++ /dev/null @@ -1,209 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * This attempts to generate V1 UUIDs according to the Internet Draft - * located at http://www.webdav.org/specs/draft-leach-uuids-guids-01.txt - */ -#include "apr.h" -#include "apr_uuid.h" -#include "apr_general.h" -#include "apr_portable.h" -#if !APR_HAS_RANDOM -#include "apr_md5.h" -#endif - -#if APR_HAVE_UNISTD_H -#include /* for getpid, gethostname */ -#endif -#if APR_HAVE_STDLIB_H -#include /* for rand, srand */ -#endif - - -#if APR_HAVE_STRING_H -#include -#endif -#if APR_HAVE_STRINGS_H -#include -#endif -#if APR_HAVE_NETDB_H -#include -#endif -#if APR_HAVE_SYS_TIME_H -#include /* for gettimeofday */ -#endif - -#define NODE_LENGTH 6 - -static int uuid_state_seqnum; -static unsigned char uuid_state_node[NODE_LENGTH] = { 0 }; - - -static void get_random_info(unsigned char node[NODE_LENGTH]) -{ -#if APR_HAS_RANDOM - - (void) apr_generate_random_bytes(node, NODE_LENGTH); - -#else - - unsigned char seed[APR_MD5_DIGESTSIZE]; - apr_md5_ctx_t c; - - /* ### probably should revise some of this to be a bit more portable */ - - /* Leach & Salz use Linux-specific struct sysinfo; - * replace with pid/tid for portability (in the spirit of mod_unique_id) */ - struct { - /* Add thread id here, if applicable, when we get to pthread or apr */ - pid_t pid; -#ifdef NETWARE - apr_uint64_t t; -#else - struct timeval t; -#endif - char hostname[257]; - - } r; - - apr_md5_init(&c); -#ifdef NETWARE - r.pid = NXThreadGetId(); - NXGetTime(NX_SINCE_BOOT, NX_USECONDS, &(r.t)); -#else - r.pid = getpid(); - gettimeofday(&r.t, (struct timezone *)0); -#endif - gethostname(r.hostname, 256); - apr_md5_update(&c, (const unsigned char *)&r, sizeof(r)); - apr_md5_final(seed, &c); - - memcpy(node, seed, NODE_LENGTH); /* use a subset of the seed bytes */ -#endif -} - -/* This implementation generates a random node ID instead of a - system-dependent call to get IEEE node ID. This is also more secure: - we aren't passing out our MAC address. -*/ -static void get_pseudo_node_identifier(unsigned char *node) -{ - get_random_info(node); - node[0] |= 0x01; /* this designates a random node ID */ -} - -static void get_system_time(apr_uint64_t *uuid_time) -{ - /* ### fix this call to be more portable? */ - *uuid_time = apr_time_now(); - - /* Offset between UUID formatted times and Unix formatted times. - UUID UTC base time is October 15, 1582. - Unix base time is January 1, 1970. */ - *uuid_time = (*uuid_time * 10) + APR_TIME_C(0x01B21DD213814000); -} - -/* true_random -- generate a crypto-quality random number. */ -static int true_random(void) -{ - apr_uint64_t time_now; - -#if APR_HAS_RANDOM - unsigned char buf[2]; - - if (apr_generate_random_bytes(buf, 2) == APR_SUCCESS) { - return (buf[0] << 8) | buf[1]; - } -#endif - - /* crap. this isn't crypto quality, but it will be Good Enough */ - - get_system_time(&time_now); - srand((unsigned int)(((time_now >> 32) ^ time_now) & 0xffffffff)); - - return rand() & 0x0FFFF; -} - -static void init_state(void) -{ - uuid_state_seqnum = true_random(); - get_pseudo_node_identifier(uuid_state_node); -} - -static void get_current_time(apr_uint64_t *timestamp) -{ - /* ### this needs to be made thread-safe! */ - - apr_uint64_t time_now; - static apr_uint64_t time_last = 0; - static apr_uint64_t fudge = 0; - - get_system_time(&time_now); - - /* if clock reading changed since last UUID generated... */ - if (time_last != time_now) { - /* The clock reading has changed since the last UUID was generated. - Reset the fudge factor. if we are generating them too fast, then - the fudge may need to be reset to something greater than zero. */ - if (time_last + fudge > time_now) - fudge = time_last + fudge - time_now + 1; - else - fudge = 0; - time_last = time_now; - } - else { - /* We generated two really fast. Bump the fudge factor. */ - ++fudge; - } - - *timestamp = time_now + fudge; -} - -APU_DECLARE(void) apr_uuid_get(apr_uuid_t *uuid) -{ - apr_uint64_t timestamp; - unsigned char *d = uuid->data; - -#if APR_HAS_OS_UUID - if (apr_os_uuid_get(d) == APR_SUCCESS) { - return; - } -#endif /* !APR_HAS_OS_UUID */ - - if (!uuid_state_node[0]) - init_state(); - - get_current_time(×tamp); - - /* time_low, uint32 */ - d[3] = (unsigned char)timestamp; - d[2] = (unsigned char)(timestamp >> 8); - d[1] = (unsigned char)(timestamp >> 16); - d[0] = (unsigned char)(timestamp >> 24); - /* time_mid, uint16 */ - d[5] = (unsigned char)(timestamp >> 32); - d[4] = (unsigned char)(timestamp >> 40); - /* time_hi_and_version, uint16 */ - d[7] = (unsigned char)(timestamp >> 48); - d[6] = (unsigned char)(((timestamp >> 56) & 0x0F) | 0x10); - /* clock_seq_hi_and_reserved, uint8 */ - d[8] = (unsigned char)(((++uuid_state_seqnum >> 8) & 0x3F) | 0x80); - /* clock_seq_low, uint8 */ - d[9] = (unsigned char)uuid_state_seqnum; - /* node, byte[6] */ - memcpy(&d[10], uuid_state_node, NODE_LENGTH); -} diff --git a/libs/apr-util/crypto/uuid.c b/libs/apr-util/crypto/uuid.c deleted file mode 100644 index 451481b5a5..0000000000 --- a/libs/apr-util/crypto/uuid.c +++ /dev/null @@ -1,130 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include /* for sprintf */ - -#include "apr.h" -#include "apr_uuid.h" -#include "apr_errno.h" -#include "apr_lib.h" - - -APU_DECLARE(void) apr_uuid_format(char *buffer, const apr_uuid_t *uuid) -{ - const unsigned char *d = uuid->data; - - sprintf(buffer, - "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", - d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], - d[8], d[9], d[10], d[11], d[12], d[13], d[14], d[15]); -} - -/* convert a pair of hex digits to an integer value [0,255] */ -#if 'A' == 65 -static unsigned char parse_hexpair(const char *s) -{ - int result; - int temp; - - result = s[0] - '0'; - if (result > 48) - result = (result - 39) << 4; - else if (result > 16) - result = (result - 7) << 4; - else - result = result << 4; - - temp = s[1] - '0'; - if (temp > 48) - result |= temp - 39; - else if (temp > 16) - result |= temp - 7; - else - result |= temp; - - return (unsigned char)result; -} -#else -static unsigned char parse_hexpair(const char *s) -{ - int result; - - if (isdigit(*s)) { - result = (*s - '0') << 4; - } - else { - if (isupper(*s)) { - result = (*s - 'A' + 10) << 4; - } - else { - result = (*s - 'a' + 10) << 4; - } - } - - ++s; - if (isdigit(*s)) { - result |= (*s - '0'); - } - else { - if (isupper(*s)) { - result |= (*s - 'A' + 10); - } - else { - result |= (*s - 'a' + 10); - } - } - - return (unsigned char)result; -} -#endif - -APU_DECLARE(apr_status_t) apr_uuid_parse(apr_uuid_t *uuid, - const char *uuid_str) -{ - int i; - unsigned char *d = uuid->data; - - for (i = 0; i < 36; ++i) { - char c = uuid_str[i]; - if (!apr_isxdigit(c) && - !(c == '-' && (i == 8 || i == 13 || i == 18 || i == 23))) - /* ### need a better value */ - return APR_BADARG; - } - if (uuid_str[36] != '\0') { - /* ### need a better value */ - return APR_BADARG; - } - - d[0] = parse_hexpair(&uuid_str[0]); - d[1] = parse_hexpair(&uuid_str[2]); - d[2] = parse_hexpair(&uuid_str[4]); - d[3] = parse_hexpair(&uuid_str[6]); - - d[4] = parse_hexpair(&uuid_str[9]); - d[5] = parse_hexpair(&uuid_str[11]); - - d[6] = parse_hexpair(&uuid_str[14]); - d[7] = parse_hexpair(&uuid_str[16]); - - d[8] = parse_hexpair(&uuid_str[19]); - d[9] = parse_hexpair(&uuid_str[21]); - - for (i = 6; i--;) - d[10 + i] = parse_hexpair(&uuid_str[i*2+24]); - - return APR_SUCCESS; -} diff --git a/libs/apr-util/dbd/apr_dbd.c b/libs/apr-util/dbd/apr_dbd.c deleted file mode 100644 index d9ec11e04c..0000000000 --- a/libs/apr-util/dbd/apr_dbd.c +++ /dev/null @@ -1,303 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "apu.h" -#include "apr_pools.h" -#include "apr_dbd_internal.h" -#include "apr_dbd.h" -#include "apr_hash.h" -#include "apr_thread_mutex.h" -#include "apr_dso.h" -#include "apr_strings.h" - -static apr_hash_t *drivers = NULL; - -#define CLEANUP_CAST (apr_status_t (*)(void*)) - -/* Once the autofoo supports building it for dynamic load, we can use - * #define APR_DSO_BUILD APR_HAS_DSO - */ - -#if APR_DSO_BUILD -#if APR_HAS_THREADS -static apr_thread_mutex_t* mutex = NULL; -#endif -#else -#define DRIVER_LOAD(name,driver,pool) \ - { \ - extern const apr_dbd_driver_t driver; \ - apr_hash_set(drivers,name,APR_HASH_KEY_STRING,&driver); \ - if (driver.init) { \ - driver.init(pool); \ - } \ - } -#endif - -static apr_status_t apr_dbd_term(void *ptr) -{ - /* set drivers to NULL so init can work again */ - drivers = NULL; - - /* Everything else we need is handled by cleanups registered - * when we created mutexes and loaded DSOs - */ - return APR_SUCCESS; -} - -APU_DECLARE(apr_status_t) apr_dbd_init(apr_pool_t *pool) -{ - apr_status_t ret = APR_SUCCESS; - - if (drivers != NULL) { - return APR_SUCCESS; - } - drivers = apr_hash_make(pool); - apr_pool_cleanup_register(pool, NULL, apr_dbd_term, - apr_pool_cleanup_null); - -#if APR_DSO_BUILD - -#if APR_HAS_THREADS - ret = apr_thread_mutex_create(&mutex, APR_THREAD_MUTEX_DEFAULT, pool); - /* This already registers a pool cleanup */ -#endif - -#else - -#if APU_HAVE_MYSQL - DRIVER_LOAD("mysql", apr_dbd_mysql_driver, pool); -#endif -#if APU_HAVE_PGSQL - DRIVER_LOAD("pgsql", apr_dbd_pgsql_driver, pool); -#endif -#if APU_HAVE_SQLITE3 - DRIVER_LOAD("sqlite3", apr_dbd_sqlite3_driver, pool); -#endif -#if APU_HAVE_SQLITE2 - DRIVER_LOAD("sqlite2", apr_dbd_sqlite2_driver, pool); -#endif -#if APU_HAVE_SOME_OTHER_BACKEND - DRIVER_LOAD("firebird", apr_dbd_other_driver, pool); -#endif -#endif - return ret; -} -APU_DECLARE(apr_status_t) apr_dbd_get_driver(apr_pool_t *pool, const char *name, - const apr_dbd_driver_t **driver) -{ -#if APR_DSO_BUILD - char path[80]; - apr_dso_handle_t *dlhandle = NULL; -#endif - apr_status_t rv; - - *driver = apr_hash_get(drivers, name, APR_HASH_KEY_STRING); - if (*driver) { - return APR_SUCCESS; - } - -#if APR_DSO_BUILD - -#if APR_HAS_THREADS - rv = apr_thread_mutex_lock(mutex); - if (rv != APR_SUCCESS) { - goto unlock; - } - *driver = apr_hash_get(drivers, name, APR_HASH_KEY_STRING); - if (*driver) { - goto unlock; - } -#endif - -#ifdef WIN32 - sprintf(path, "apr_dbd_%s.dll", name); -#else - sprintf(path, "apr_dbd_%s.so", name); -#endif - rv = apr_dso_load(&dlhandle, path, pool); - if (rv != APR_SUCCESS) { /* APR_EDSOOPEN */ - goto unlock; - } - sprintf(path, "apr_dbd_%s_driver", name); - rv = apr_dso_sym((void*)driver, dlhandle, path); - if (rv != APR_SUCCESS) { /* APR_ESYMNOTFOUND */ - apr_dso_unload(dlhandle); - goto unlock; - } - if ((*driver)->init) { - (*driver)->init(pool); - } - apr_hash_set(drivers, name, APR_HASH_KEY_STRING, *driver); - -unlock: -#if APR_HAS_THREADS - apr_thread_mutex_unlock(mutex); -#endif - -#else /* APR_DSO_BUILD - so if it wasn't already loaded, it's NOTIMPL */ - rv = APR_ENOTIMPL; -#endif - - return rv; -} -APU_DECLARE(apr_status_t) apr_dbd_open(const apr_dbd_driver_t *driver, - apr_pool_t *pool, const char *params, - apr_dbd_t **handle) -{ - apr_status_t rv; - *handle = driver->open(pool, params); - if (*handle == NULL) { - return APR_EGENERAL; - } - rv = apr_dbd_check_conn(driver, pool, *handle); - if ((rv != APR_SUCCESS) && (rv != APR_ENOTIMPL)) { - apr_dbd_close(driver, *handle); - return APR_EGENERAL; - } - return APR_SUCCESS; -} -APU_DECLARE(int) apr_dbd_transaction_start(const apr_dbd_driver_t *driver, - apr_pool_t *pool, apr_dbd_t *handle, - apr_dbd_transaction_t **trans) -{ - int ret = driver->start_transaction(pool, handle, trans); - if (*trans) { - apr_pool_cleanup_register(pool, *trans, - CLEANUP_CAST driver->end_transaction, - apr_pool_cleanup_null); - } - return ret; -} -APU_DECLARE(int) apr_dbd_transaction_end(const apr_dbd_driver_t *driver, - apr_pool_t *pool, - apr_dbd_transaction_t *trans) -{ - apr_pool_cleanup_kill(pool, trans, CLEANUP_CAST driver->end_transaction); - return driver->end_transaction(trans); -} - -APU_DECLARE(apr_status_t) apr_dbd_close(const apr_dbd_driver_t *driver, - apr_dbd_t *handle) -{ - return driver->close(handle); -} -APU_DECLARE(const char*) apr_dbd_name(const apr_dbd_driver_t *driver) -{ - return driver->name; -} -APU_DECLARE(void*) apr_dbd_native_handle(const apr_dbd_driver_t *driver, - apr_dbd_t *handle) -{ - return driver->native_handle(handle); -} -APU_DECLARE(int) apr_dbd_check_conn(const apr_dbd_driver_t *driver, apr_pool_t *pool, - apr_dbd_t *handle) -{ - return driver->check_conn(pool, handle); -} -APU_DECLARE(int) apr_dbd_set_dbname(const apr_dbd_driver_t *driver, apr_pool_t *pool, - apr_dbd_t *handle, const char *name) -{ - return driver->set_dbname(pool,handle,name); -} -APU_DECLARE(int) apr_dbd_query(const apr_dbd_driver_t *driver, apr_dbd_t *handle, - int *nrows, const char *statement) -{ - return driver->query(handle,nrows,statement); -} -APU_DECLARE(int) apr_dbd_select(const apr_dbd_driver_t *driver, apr_pool_t *pool, - apr_dbd_t *handle, apr_dbd_results_t **res, - const char *statement, int random) -{ - return driver->select(pool,handle,res,statement,random); -} -APU_DECLARE(int) apr_dbd_num_cols(const apr_dbd_driver_t *driver, - apr_dbd_results_t *res) -{ - return driver->num_cols(res); -} -APU_DECLARE(int) apr_dbd_num_tuples(const apr_dbd_driver_t *driver, - apr_dbd_results_t *res) -{ - return driver->num_tuples(res); -} -APU_DECLARE(int) apr_dbd_get_row(const apr_dbd_driver_t *driver, apr_pool_t *pool, - apr_dbd_results_t *res, apr_dbd_row_t **row, - int rownum) -{ - return driver->get_row(pool,res,row,rownum); -} -APU_DECLARE(const char*) apr_dbd_get_entry(const apr_dbd_driver_t *driver, - apr_dbd_row_t *row, int col) -{ - return driver->get_entry(row,col); -} -APU_DECLARE(const char*) apr_dbd_error(const apr_dbd_driver_t *driver, - apr_dbd_t *handle, int errnum) -{ - return driver->error(handle,errnum); -} -APU_DECLARE(const char*) apr_dbd_escape(const apr_dbd_driver_t *driver, - apr_pool_t *pool, const char *string, - apr_dbd_t *handle) -{ - return driver->escape(pool,string,handle); -} -APU_DECLARE(int) apr_dbd_prepare(const apr_dbd_driver_t *driver, apr_pool_t *pool, - apr_dbd_t *handle, const char *query, - const char *label, - apr_dbd_prepared_t **statement) -{ - return driver->prepare(pool,handle,query,label,statement); -} -APU_DECLARE(int) apr_dbd_pquery(const apr_dbd_driver_t *driver, apr_pool_t *pool, - apr_dbd_t *handle, int *nrows, - apr_dbd_prepared_t *statement, int nargs, - const char **args) -{ - return driver->pquery(pool,handle,nrows,statement,nargs,args); -} -APU_DECLARE(int) apr_dbd_pselect(const apr_dbd_driver_t *driver, apr_pool_t *pool, - apr_dbd_t *handle, apr_dbd_results_t **res, - apr_dbd_prepared_t *statement, int random, - int nargs, const char **args) -{ - return driver->pselect(pool,handle,res,statement,random,nargs,args); -} -APU_DECLARE(int) apr_dbd_pvquery(const apr_dbd_driver_t *driver, apr_pool_t *pool, - apr_dbd_t *handle, int *nrows, - apr_dbd_prepared_t *statement,...) -{ - int ret; - va_list args; - va_start(args, statement); - ret = driver->pvquery(pool,handle,nrows,statement,args); - va_end(args); - return ret; -} -APU_DECLARE(int) apr_dbd_pvselect(const apr_dbd_driver_t *driver, apr_pool_t *pool, - apr_dbd_t *handle, apr_dbd_results_t **res, - apr_dbd_prepared_t *statement, int random,...) -{ - int ret; - va_list args; - va_start(args, random); - ret = driver->pvselect(pool,handle,res,statement,random,args); - va_end(args); - return ret; -} diff --git a/libs/apr-util/dbd/apr_dbd_pgsql.c b/libs/apr-util/dbd/apr_dbd_pgsql.c deleted file mode 100644 index 76bfa0c11f..0000000000 --- a/libs/apr-util/dbd/apr_dbd_pgsql.c +++ /dev/null @@ -1,664 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apu.h" - -#if APU_HAVE_PGSQL - -#include "apu_config.h" - -#include -#include - -#ifdef HAVE_LIBPQ_FE_H -#include -#elif defined(HAVE_POSTGRESQL_LIBPQ_FE_H) -#include -#endif - -#include "apr_strings.h" -#include "apr_time.h" - -#include "apr_dbd_internal.h" - -#define QUERY_MAX_ARGS 40 - -struct apr_dbd_transaction_t { - int errnum; - apr_dbd_t *handle; -}; - -struct apr_dbd_t { - PGconn *conn; - apr_dbd_transaction_t *trans; -}; - -struct apr_dbd_results_t { - int random; - PGconn *handle; - PGresult *res; - size_t ntuples; - size_t sz; - size_t index; -}; - -struct apr_dbd_row_t { - int n; - apr_dbd_results_t *res; -}; - -struct apr_dbd_prepared_t { - const char *name; - int prepared; - int nargs; -}; - -#define dbd_pgsql_is_success(x) (((x) == PGRES_EMPTY_QUERY) \ - || ((x) == PGRES_COMMAND_OK) \ - || ((x) == PGRES_TUPLES_OK)) - -static apr_status_t clear_result(void *data) -{ - PQclear(data); - return APR_SUCCESS; -} - -static int dbd_pgsql_select(apr_pool_t *pool, apr_dbd_t *sql, - apr_dbd_results_t **results, - const char *query, int seek) -{ - PGresult *res; - int ret; - if ( sql->trans && sql->trans->errnum ) { - return sql->trans->errnum; - } - if (seek) { /* synchronous query */ - res = PQexec(sql->conn, query); - if (res) { - ret = PQresultStatus(res); - if (dbd_pgsql_is_success(ret)) { - ret = 0; - } else { - PQclear(res); - } - } else { - ret = PGRES_FATAL_ERROR; - } - if (ret != 0) { - if (sql->trans) { - sql->trans->errnum = ret; - } - return ret; - } - if (!*results) { - *results = apr_pcalloc(pool, sizeof(apr_dbd_results_t)); - } - (*results)->res = res; - (*results)->ntuples = PQntuples(res); - (*results)->sz = PQnfields(res); - (*results)->random = seek; - apr_pool_cleanup_register(pool, res, clear_result, - apr_pool_cleanup_null); - } - else { - if (PQsendQuery(sql->conn, query) == 0) { - if (sql->trans) { - sql->trans->errnum = 1; - } - return 1; - } - if (*results == NULL) { - *results = apr_pcalloc(pool, sizeof(apr_dbd_results_t)); - } - (*results)->random = seek; - (*results)->handle = sql->conn; - } - return 0; -} - -static int dbd_pgsql_get_row(apr_pool_t *pool, apr_dbd_results_t *res, - apr_dbd_row_t **rowp, int rownum) -{ - apr_dbd_row_t *row = *rowp; - int sequential = ((rownum >= 0) && res->random) ? 0 : 1; - - if (row == NULL) { - row = apr_palloc(pool, sizeof(apr_dbd_row_t)); - *rowp = row; - row->res = res; - row->n = sequential ? 0 : rownum; - } - else { - if ( sequential ) { - ++row->n; - } - else { - row->n = rownum; - } - } - - if (res->random) { - if (row->n >= res->ntuples) { - *rowp = NULL; - apr_pool_cleanup_run(pool, res->res, clear_result); - res->res = NULL; - return -1; - } - } - else { - if (row->n >= res->ntuples) { - /* no data; we have to fetch some */ - row->n -= res->ntuples; - if (res->res != NULL) { - PQclear(res->res); - } - res->res = PQgetResult(res->handle); - if (res->res) { - res->ntuples = PQntuples(res->res); - while (res->ntuples == 0) { - /* if we got an empty result, clear it, wait a mo, try - * again */ - PQclear(res->res); - apr_sleep(100000); /* 0.1 secs */ - res->res = PQgetResult(res->handle); - if (res->res) { - res->ntuples = PQntuples(res->res); - } - else { - return -1; - } - } - if (res->sz == 0) { - res->sz = PQnfields(res->res); - } - } - else { - return -1; - } - } - } - return 0; -} - -static const char *dbd_pgsql_get_entry(const apr_dbd_row_t *row, int n) -{ - return PQgetvalue(row->res->res, row->n, n); -} - -static const char *dbd_pgsql_error(apr_dbd_t *sql, int n) -{ - return PQerrorMessage(sql->conn); -} - -static int dbd_pgsql_query(apr_dbd_t *sql, int *nrows, const char *query) -{ - PGresult *res; - int ret; - if (sql->trans && sql->trans->errnum) { - return sql->trans->errnum; - } - res = PQexec(sql->conn, query); - if (res) { - ret = PQresultStatus(res); - if (dbd_pgsql_is_success(ret)) { - /* ugh, making 0 return-success doesn't fit */ - ret = 0; - } - *nrows = atoi(PQcmdTuples(res)); - PQclear(res); - } - else { - ret = PGRES_FATAL_ERROR; - } - if (sql->trans) { - sql->trans->errnum = ret; - } - return ret; -} - -static const char *dbd_pgsql_escape(apr_pool_t *pool, const char *arg, - apr_dbd_t *sql) -{ - size_t len = strlen(arg); - char *ret = apr_palloc(pool, 2*(len + 1)); - PQescapeString(ret, arg, len); - return ret; -} - -static int dbd_pgsql_prepare(apr_pool_t *pool, apr_dbd_t *sql, - const char *query, const char *label, - apr_dbd_prepared_t **statement) -{ - char *sqlcmd; - char *sqlptr; - size_t length; - size_t i = 0; - const char *args[QUERY_MAX_ARGS]; - size_t alen; - int ret; - PGresult *res; - char *pgquery; - char *pgptr; - - if (!*statement) { - *statement = apr_palloc(pool, sizeof(apr_dbd_prepared_t)); - } - (*statement)->nargs = 0; - /* Translate from apr_dbd to native query format */ - for (sqlptr = (char*)query; *sqlptr; ++sqlptr) { - if (sqlptr[0] == '%') { - if (isalpha(sqlptr[1])) { - ++(*statement)->nargs; - } - else if (sqlptr[1] == '%') { - ++sqlptr; - } - } - } - length = strlen(query) + 1; - if ((*statement)->nargs > 8) { - length += (*statement)->nargs - 8; - } - pgptr = pgquery = apr_palloc(pool, length) ; - - for (sqlptr = (char*)query; *sqlptr; ++sqlptr) { - if ((sqlptr[0] == '%') && isalpha(sqlptr[1])) { - *pgptr++ = '$'; - if (i < 9) { - *pgptr++ = '1' + i; - } - else { - *pgptr++ = '0' + ((i+1)/10); - *pgptr++ = '0' + ((i+1)%10); - } - switch (*++sqlptr) { - case 'd': - args[i] = "integer"; - break; - case 's': - args[i] = "varchar"; - break; - default: - args[i] = "varchar"; - break; - } - length += 1 + strlen(args[i]); - ++i; - } - else if ((sqlptr[0] == '%') && (sqlptr[1] == '%')) { - /* reduce %% to % */ - *pgptr++ = *sqlptr++; - } - else { - *pgptr++ = *sqlptr; - } - } - *pgptr = 0; - - if (!label) { - /* don't really prepare; use in execParams instead */ - (*statement)->prepared = 0; - (*statement)->name = apr_pstrdup(pool, pgquery); - return 0; - } - (*statement)->name = apr_pstrdup(pool, label); - - /* length of SQL query that prepares this statement */ - length = 8 + strlen(label) + 2 + 4 + length + 1; - sqlcmd = apr_palloc(pool, length); - sqlptr = sqlcmd; - memcpy(sqlptr, "PREPARE ", 8); - sqlptr += 8; - length = strlen(label); - memcpy(sqlptr, label, length); - sqlptr += length; - if ((*statement)->nargs > 0) { - memcpy(sqlptr, " (",2); - sqlptr += 2; - for (i=0; i < (*statement)->nargs; ++i) { - alen = strlen(args[i]); - memcpy(sqlptr, args[i], alen); - sqlptr += alen; - *sqlptr++ = ','; - } - sqlptr[-1] = ')'; - } - memcpy(sqlptr, " AS ", 4); - sqlptr += 4; - memcpy(sqlptr, pgquery, strlen(pgquery)); - sqlptr += strlen(pgquery); - *sqlptr = 0; - - res = PQexec(sql->conn, sqlcmd); - if ( res ) { - ret = PQresultStatus(res); - if (dbd_pgsql_is_success(ret)) { - ret = 0; - } - /* Hmmm, do we do this here or register it on the pool? */ - PQclear(res); - } - else { - ret = PGRES_FATAL_ERROR; - } - (*statement)->prepared = 1; - - return ret; -} - -static int dbd_pgsql_pquery(apr_pool_t *pool, apr_dbd_t *sql, - int *nrows, apr_dbd_prepared_t *statement, - int nargs, const char **values) -{ - int ret; - PGresult *res; - - if (sql->trans && sql->trans->errnum) { - return sql->trans->errnum; - } - - if (statement->prepared) { - res = PQexecPrepared(sql->conn, statement->name, nargs, values, 0, 0, - 0); - } - else { - res = PQexecParams(sql->conn, statement->name, nargs, 0, values, 0, 0, - 0); - } - if (res) { - ret = PQresultStatus(res); - if (dbd_pgsql_is_success(ret)) { - ret = 0; - } - *nrows = atoi(PQcmdTuples(res)); - PQclear(res); - } - else { - ret = PGRES_FATAL_ERROR; - } - - if (sql->trans) { - sql->trans->errnum = ret; - } - return ret; -} - -static int dbd_pgsql_pvquery(apr_pool_t *pool, apr_dbd_t *sql, - int *nrows, apr_dbd_prepared_t *statement, - va_list args) -{ - const char **values; - int i; - - if (sql->trans && sql->trans->errnum) { - return sql->trans->errnum; - } - - values = apr_palloc(pool, sizeof(*values) * statement->nargs); - - for (i = 0; i < statement->nargs; i++) { - values[i] = apr_pstrdup(pool, va_arg(args, const char*)); - } - - return dbd_pgsql_pquery(pool, sql, nrows, statement, - statement->nargs, values); -} - -static int dbd_pgsql_pselect(apr_pool_t *pool, apr_dbd_t *sql, - apr_dbd_results_t **results, - apr_dbd_prepared_t *statement, - int seek, int nargs, const char **values) -{ - PGresult *res; - int rv; - int ret = 0; - - if (sql->trans && sql->trans->errnum) { - return sql->trans->errnum; - } - - if (seek) { /* synchronous query */ - if (statement->prepared) { - res = PQexecPrepared(sql->conn, statement->name, nargs, values, 0, - 0, 0); - } - else { - res = PQexecParams(sql->conn, statement->name, nargs, 0, values, 0, - 0, 0); - } - if (res) { - ret = PQresultStatus(res); - if (dbd_pgsql_is_success(ret)) { - ret = 0; - } - else { - PQclear(res); - } - } - else { - ret = PGRES_FATAL_ERROR; - } - if (ret != 0) { - if (sql->trans) { - sql->trans->errnum = ret; - } - return ret; - } - if (!*results) { - *results = apr_pcalloc(pool, sizeof(apr_dbd_results_t)); - } - (*results)->res = res; - (*results)->ntuples = PQntuples(res); - (*results)->sz = PQnfields(res); - (*results)->random = seek; - apr_pool_cleanup_register(pool, res, clear_result, - apr_pool_cleanup_null); - } - else { - if (statement->prepared) { - rv = PQsendQueryPrepared(sql->conn, statement->name, nargs, values, - 0, 0, 0); - } - else { - rv = PQsendQueryParams(sql->conn, statement->name, nargs, 0, - values, 0, 0, 0); - } - if (rv == 0) { - if (sql->trans) { - sql->trans->errnum = 1; - } - return 1; - } - if (!*results) { - *results = apr_pcalloc(pool, sizeof(apr_dbd_results_t)); - } - (*results)->random = seek; - (*results)->handle = sql->conn; - } - - if (sql->trans) { - sql->trans->errnum = ret; - } - return ret; -} - -static int dbd_pgsql_pvselect(apr_pool_t *pool, apr_dbd_t *sql, - apr_dbd_results_t **results, - apr_dbd_prepared_t *statement, - int seek, va_list args) -{ - const char **values; - int i; - - if (sql->trans && sql->trans->errnum) { - return sql->trans->errnum; - } - - values = apr_palloc(pool, sizeof(*values) * statement->nargs); - - for (i = 0; i < statement->nargs; i++) { - values[i] = apr_pstrdup(pool, va_arg(args, const char*)); - } - - return dbd_pgsql_pselect(pool, sql, results, statement, - seek, statement->nargs, values) ; -} - -static int dbd_pgsql_start_transaction(apr_pool_t *pool, apr_dbd_t *handle, - apr_dbd_transaction_t **trans) -{ - int ret = 0; - PGresult *res; - - /* XXX handle recursive transactions here */ - - res = PQexec(handle->conn, "BEGIN TRANSACTION"); - if (res) { - ret = PQresultStatus(res); - if (dbd_pgsql_is_success(ret)) { - ret = 0; - if (!*trans) { - *trans = apr_pcalloc(pool, sizeof(apr_dbd_transaction_t)); - } - } - PQclear(res); - (*trans)->handle = handle; - handle->trans = *trans; - } - else { - ret = PGRES_FATAL_ERROR; - } - return ret; -} - -static int dbd_pgsql_end_transaction(apr_dbd_transaction_t *trans) -{ - PGresult *res; - int ret = -1; /* no transaction is an error cond */ - if (trans) { - if (trans->errnum) { - trans->errnum = 0; - res = PQexec(trans->handle->conn, "ROLLBACK"); - } - else { - res = PQexec(trans->handle->conn, "COMMIT"); - } - if (res) { - ret = PQresultStatus(res); - if (dbd_pgsql_is_success(ret)) { - ret = 0; - } - PQclear(res); - } - else { - ret = PGRES_FATAL_ERROR; - } - trans->handle->trans = NULL; - } - return ret; -} - -static apr_dbd_t *dbd_pgsql_open(apr_pool_t *pool, const char *params) -{ - apr_dbd_t *sql; - - PGconn *conn = PQconnectdb(params); - - /* if there's an error in the connect string or something we get - * back a * bogus connection object, and things like PQreset are - * liable to segfault, so just close it out now. it would be nice - * if we could give an indication of why we failed to connect... */ - if (PQstatus(conn) != CONNECTION_OK) { - PQfinish(conn); - return NULL; - } - - sql = apr_pcalloc (pool, sizeof (*sql)); - - sql->conn = conn; - - return sql; -} - -static apr_status_t dbd_pgsql_close(apr_dbd_t *handle) -{ - PQfinish(handle->conn); - return APR_SUCCESS; -} - -static apr_status_t dbd_pgsql_check_conn(apr_pool_t *pool, - apr_dbd_t *handle) -{ - if (PQstatus(handle->conn) != CONNECTION_OK) { - PQreset(handle->conn); - if (PQstatus(handle->conn) != CONNECTION_OK) { - return APR_EGENERAL; - } - } - return APR_SUCCESS; -} - -static int dbd_pgsql_select_db(apr_pool_t *pool, apr_dbd_t *handle, - const char *name) -{ - return APR_ENOTIMPL; -} - -static void *dbd_pgsql_native(apr_dbd_t *handle) -{ - return handle->conn; -} - -static int dbd_pgsql_num_cols(apr_dbd_results_t* res) -{ - return res->sz; -} - -static int dbd_pgsql_num_tuples(apr_dbd_results_t* res) -{ - if (res->random) { - return res->ntuples; - } - else { - return -1; - } -} - -APU_DECLARE_DATA const apr_dbd_driver_t apr_dbd_pgsql_driver = { - "pgsql", - NULL, - dbd_pgsql_native, - dbd_pgsql_open, - dbd_pgsql_check_conn, - dbd_pgsql_close, - dbd_pgsql_select_db, - dbd_pgsql_start_transaction, - dbd_pgsql_end_transaction, - dbd_pgsql_query, - dbd_pgsql_select, - dbd_pgsql_num_cols, - dbd_pgsql_num_tuples, - dbd_pgsql_get_row, - dbd_pgsql_get_entry, - dbd_pgsql_error, - dbd_pgsql_escape, - dbd_pgsql_prepare, - dbd_pgsql_pvquery, - dbd_pgsql_pvselect, - dbd_pgsql_pquery, - dbd_pgsql_pselect, -}; -#endif diff --git a/libs/apr-util/dbd/apr_dbd_sqlite2.c b/libs/apr-util/dbd/apr_dbd_sqlite2.c deleted file mode 100644 index d93bf11100..0000000000 --- a/libs/apr-util/dbd/apr_dbd_sqlite2.c +++ /dev/null @@ -1,396 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apu.h" - -#if APU_HAVE_SQLITE2 - -#include -#include - -#include - -#include "apr_strings.h" -#include "apr_time.h" - -#include "apr_dbd_internal.h" - -struct apr_dbd_transaction_t { - int errnum; - apr_dbd_t *handle; -}; - -struct apr_dbd_t { - sqlite *conn; - char *errmsg; - apr_dbd_transaction_t *trans; -}; - -struct apr_dbd_results_t { - int random; - sqlite *handle; - char **res; - size_t ntuples; - size_t sz; - size_t index; -}; - -struct apr_dbd_row_t { - int n; - char **data; - apr_dbd_results_t *res; -}; - -struct apr_dbd_prepared_t { - const char *name; - int prepared; -}; - -#define FREE_ERROR_MSG(dbd) \ - do { \ - if(dbd && dbd->errmsg) { \ - free(dbd->errmsg); \ - dbd->errmsg = NULL; \ - } \ - } while(0); - -static apr_status_t free_table(void *data) -{ - sqlite_free_table(data); - return APR_SUCCESS; -} - -static int dbd_sqlite_select(apr_pool_t * pool, apr_dbd_t * sql, - apr_dbd_results_t ** results, const char *query, - int seek) -{ - char **result; - int ret = 0; - int tuples = 0; - int fields = 0; - - if (sql->trans && sql->trans->errnum) { - return sql->trans->errnum; - } - - FREE_ERROR_MSG(sql); - - ret = sqlite_get_table(sql->conn, query, &result, &tuples, &fields, - &sql->errmsg); - - if (ret == SQLITE_OK) { - if (!*results) { - *results = apr_pcalloc(pool, sizeof(apr_dbd_results_t)); - } - - (*results)->res = result; - (*results)->ntuples = tuples; - (*results)->sz = fields; - (*results)->random = seek; - - if (tuples > 0) - apr_pool_cleanup_register(pool, result, free_table, - apr_pool_cleanup_null); - - ret = 0; - } - else { - sql->trans->errnum = ret; - } - - return ret; -} - -static int dbd_sqlite_get_row(apr_pool_t * pool, apr_dbd_results_t * res, - apr_dbd_row_t ** rowp, int rownum) -{ - apr_dbd_row_t *row = *rowp; - int sequential = ((rownum >= 0) && res->random) ? 0 : 1; - - if (row == NULL) { - row = apr_palloc(pool, sizeof(apr_dbd_row_t)); - *rowp = row; - row->res = res; - row->n = sequential ? 0 : rownum - 1; - } - else { - if (sequential) { - ++row->n; - } - else { - row->n = rownum - 1; - } - } - - if (row->n >= res->ntuples) { - *rowp = NULL; - apr_pool_cleanup_run(pool, res->res, free_table); - res->res = NULL; - return -1; - } - - /* Pointer magic explanation: - * The sqlite result is an array such that the first res->sz elements are - * the column names and each tuple follows afterwards - * ex: (from the sqlite2 documentation) - SELECT employee_name, login, host FROM users WHERE login LIKE * 'd%'; - - nrow = 2 - ncolumn = 3 - result[0] = "employee_name" - result[1] = "login" - result[2] = "host" - result[3] = "dummy" - result[4] = "No such user" - result[5] = 0 - result[6] = "D. Richard Hipp" - result[7] = "drh" - result[8] = "zadok" - */ - - row->data = res->res + res->sz + (res->sz * row->n); - - return 0; -} - -static const char *dbd_sqlite_get_entry(const apr_dbd_row_t * row, int n) -{ - if ((n < 0) || (n >= row->res->sz)) { - return NULL; - } - - return row->data[n]; -} - -static const char *dbd_sqlite_error(apr_dbd_t * sql, int n) -{ - return sql->errmsg; -} - -static int dbd_sqlite_query(apr_dbd_t * sql, int *nrows, const char *query) -{ - char **result; - int ret; - int tuples = 0; - int fields = 0; - - if (sql->trans && sql->trans->errnum) { - return sql->trans->errnum; - } - - FREE_ERROR_MSG(sql); - - ret = - sqlite_get_table(sql->conn, query, &result, &tuples, &fields, - &sql->errmsg); - if (ret == SQLITE_OK) { - *nrows = sqlite_changes(sql->conn); - - if (tuples > 0) - free(result); - - ret = 0; - } - - if (sql->trans) { - sql->trans->errnum = ret; - } - - return ret; -} - -static apr_status_t free_mem(void *data) -{ - sqlite_freemem(data); - return APR_SUCCESS; -} - -static const char *dbd_sqlite_escape(apr_pool_t * pool, const char *arg, - apr_dbd_t * sql) -{ - char *ret = sqlite_mprintf("%q", arg); - apr_pool_cleanup_register(pool, ret, free_mem, apr_pool_cleanup_null); - return ret; -} - -static int dbd_sqlite_prepare(apr_pool_t * pool, apr_dbd_t * sql, - const char *query, const char *label, - apr_dbd_prepared_t ** statement) -{ - return APR_ENOTIMPL; -} - -static int dbd_sqlite_pquery(apr_pool_t * pool, apr_dbd_t * sql, - int *nrows, apr_dbd_prepared_t * statement, - int nargs, const char **values) -{ - return APR_ENOTIMPL; -} - -static int dbd_sqlite_pvquery(apr_pool_t * pool, apr_dbd_t * sql, - int *nrows, apr_dbd_prepared_t * statement, - va_list args) -{ - return APR_ENOTIMPL; -} - -static int dbd_sqlite_pselect(apr_pool_t * pool, apr_dbd_t * sql, - apr_dbd_results_t ** results, - apr_dbd_prepared_t * statement, - int seek, int nargs, const char **values) -{ - return APR_ENOTIMPL; -} - -static int dbd_sqlite_pvselect(apr_pool_t * pool, apr_dbd_t * sql, - apr_dbd_results_t ** results, - apr_dbd_prepared_t * statement, int seek, - va_list args) -{ - return APR_ENOTIMPL; -} - -static int dbd_sqlite_start_transaction(apr_pool_t * pool, apr_dbd_t * handle, - apr_dbd_transaction_t ** trans) -{ - int ret, rows; - - ret = dbd_sqlite_query(handle, &rows, "BEGIN TRANSACTION"); - if (ret == 0) { - if (!*trans) { - *trans = apr_pcalloc(pool, sizeof(apr_dbd_transaction_t)); - } - (*trans)->handle = handle; - handle->trans = *trans; - } - else { - ret = -1; - } - return ret; -} - -static int dbd_sqlite_end_transaction(apr_dbd_transaction_t * trans) -{ - int rows; - int ret = -1; /* no transaction is an error cond */ - - if (trans) { - if (trans->errnum) { - trans->errnum = 0; - ret = - dbd_sqlite_query(trans->handle, &rows, - "ROLLBACK TRANSACTION"); - } - else { - ret = - dbd_sqlite_query(trans->handle, &rows, "COMMIT TRANSACTION"); - } - trans->handle->trans = NULL; - } - - return ret; -} - -static apr_dbd_t *dbd_sqlite_open(apr_pool_t * pool, const char *params_) -{ - apr_dbd_t *sql; - sqlite *conn = NULL; - char *perm; - int iperms = 600; - char* params = apr_pstrdup(pool, params_); - /* params = "[filename]:[permissions]" - * example: "shopping.db:600" - */ - - perm = strstr(params, ":"); - if (perm) { - *(perm++) = '\x00'; /* split the filename and permissions */ - - if (strlen(perm) > 0) - iperms = atoi(perm); - } - - conn = sqlite_open(params, iperms, NULL); - - sql = apr_pcalloc(pool, sizeof(*sql)); - sql->conn = conn; - - return sql; -} - -static apr_status_t dbd_sqlite_close(apr_dbd_t * handle) -{ - if (handle->conn) { - sqlite_close(handle->conn); - handle->conn = NULL; - } - return APR_SUCCESS; -} - -static apr_status_t dbd_sqlite_check_conn(apr_pool_t * pool, - apr_dbd_t * handle) -{ - if (handle->conn == NULL) - return -1; - return APR_SUCCESS; -} - -static int dbd_sqlite_select_db(apr_pool_t * pool, apr_dbd_t * handle, - const char *name) -{ - return APR_ENOTIMPL; -} - -static void *dbd_sqlite_native(apr_dbd_t * handle) -{ - return handle->conn; -} - -static int dbd_sqlite_num_cols(apr_dbd_results_t * res) -{ - return res->sz; -} - -static int dbd_sqlite_num_tuples(apr_dbd_results_t * res) -{ - return res->ntuples; -} - -APU_DECLARE_DATA const apr_dbd_driver_t apr_dbd_sqlite2_driver = { - "sqlite2", - NULL, - dbd_sqlite_native, - dbd_sqlite_open, - dbd_sqlite_check_conn, - dbd_sqlite_close, - dbd_sqlite_select_db, - dbd_sqlite_start_transaction, - dbd_sqlite_end_transaction, - dbd_sqlite_query, - dbd_sqlite_select, - dbd_sqlite_num_cols, - dbd_sqlite_num_tuples, - dbd_sqlite_get_row, - dbd_sqlite_get_entry, - dbd_sqlite_error, - dbd_sqlite_escape, - dbd_sqlite_prepare, - dbd_sqlite_pvquery, - dbd_sqlite_pvselect, - dbd_sqlite_pquery, - dbd_sqlite_pselect, -}; -#endif diff --git a/libs/apr-util/dbd/apr_dbd_sqlite3.c b/libs/apr-util/dbd/apr_dbd_sqlite3.c deleted file mode 100644 index d82e3d31d2..0000000000 --- a/libs/apr-util/dbd/apr_dbd_sqlite3.c +++ /dev/null @@ -1,723 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apu.h" - -#if APU_HAVE_SQLITE3 - -#include -#include - -#include - -#include "apr_strings.h" -#include "apr_time.h" - -#include "apr_dbd_internal.h" - -#define MAX_RETRY_COUNT 15 -#define MAX_RETRY_SLEEP 100000 - -struct apr_dbd_transaction_t { - int errnum; - apr_dbd_t *handle; -}; - -struct apr_dbd_t { - sqlite3 *conn; - apr_dbd_transaction_t *trans; -#if APR_HAS_THREADS - apr_thread_mutex_t *mutex; -#endif - apr_pool_t *pool; - apr_dbd_prepared_t *prep; -}; - -typedef struct { - char *name; - char *value; - int size; - int type; -} apr_dbd_column_t; - -struct apr_dbd_row_t { - apr_dbd_results_t *res; - apr_dbd_column_t **columns; - apr_dbd_row_t *next_row; - int columnCount; - int rownum; -}; - -struct apr_dbd_results_t { - int random; - sqlite3 *handle; - sqlite3_stmt *stmt; - apr_dbd_row_t *next_row; - size_t sz; - int tuples; - char **col_names; -}; - -struct apr_dbd_prepared_t { - sqlite3_stmt *stmt; - apr_dbd_prepared_t *next; -}; - -#define dbd_sqlite3_is_success(x) (((x) == SQLITE_DONE ) \ - || ((x) == SQLITE_OK )) - -static int dbd_sqlite3_select(apr_pool_t * pool, apr_dbd_t * sql, apr_dbd_results_t ** results, const char *query, int seek) -{ - sqlite3_stmt *stmt = NULL; - const char *tail = NULL; - int i, ret, retry_count = 0; - size_t num_tuples = 0; - int increment = 0; - apr_dbd_row_t *row = NULL; - apr_dbd_row_t *lastrow = NULL; - apr_dbd_column_t *column; - char *hold = NULL; - - if (sql->trans && sql->trans->errnum) { - return sql->trans->errnum; - } - -#if APR_HAS_THREADS - apr_thread_mutex_lock(sql->mutex); -#endif - - ret = sqlite3_prepare(sql->conn, query, strlen(query), &stmt, &tail); - if (!dbd_sqlite3_is_success(ret)) { -#if APR_HAS_THREADS - apr_thread_mutex_unlock(sql->mutex); -#endif - return ret; - } else { - int column_count; - column_count = sqlite3_column_count(stmt); - if (!*results) { - *results = apr_pcalloc(pool, sizeof(apr_dbd_results_t)); - } - (*results)->stmt = stmt; - (*results)->sz = column_count; - (*results)->random = seek; - (*results)->next_row = 0; - (*results)->tuples = 0; - (*results)->col_names = apr_pcalloc(pool, - column_count * sizeof(char *)); - do { - ret = sqlite3_step(stmt); - if (ret == SQLITE_BUSY) { - if (retry_count++ > MAX_RETRY_COUNT) { - ret = SQLITE_ERROR; - } else { -#if APR_HAS_THREADS - apr_thread_mutex_unlock(sql->mutex); -#endif - apr_sleep(MAX_RETRY_SLEEP); -#if APR_HAS_THREADS - apr_thread_mutex_lock(sql->mutex); -#endif - } - } else if (ret == SQLITE_ROW) { - int length; - apr_dbd_column_t *col; - row = apr_palloc(pool, sizeof(apr_dbd_row_t)); - row->res = *results; - increment = sizeof(apr_dbd_column_t *); - length = increment * (*results)->sz; - row->columns = apr_palloc(pool, length); - row->columnCount = column_count; - for (i = 0; i < (*results)->sz; i++) { - column = apr_palloc(pool, sizeof(apr_dbd_column_t)); - row->columns[i] = column; - /* copy column name once only */ - if ((*results)->col_names[i] == NULL) { - (*results)->col_names[i] = - apr_pstrdup(pool, sqlite3_column_name(stmt, i)); - } - column->name = (*results)->col_names[i]; - column->size = sqlite3_column_bytes(stmt, i); - column->type = sqlite3_column_type(stmt, i); - column->value = NULL; - switch (column->type) { - case SQLITE_FLOAT: - case SQLITE_INTEGER: - case SQLITE_TEXT: - hold = NULL; - hold = (char *) sqlite3_column_text(stmt, i); - if (hold) { - column->value = apr_palloc(pool, column->size + 1); - strncpy(column->value, hold, column->size + 1); - } - break; - case SQLITE_BLOB: - break; - case SQLITE_NULL: - break; - } - col = row->columns[i]; - } - row->rownum = num_tuples++; - row->next_row = 0; - (*results)->tuples = num_tuples; - if ((*results)->next_row == 0) { - (*results)->next_row = row; - } - if (lastrow != 0) { - lastrow->next_row = row; - } - lastrow = row; - } else if (ret == SQLITE_DONE) { - ret = SQLITE_OK; - } - } while (ret == SQLITE_ROW || ret == SQLITE_BUSY); - } - ret = sqlite3_finalize(stmt); -#if APR_HAS_THREADS - apr_thread_mutex_unlock(sql->mutex); -#endif - - if (sql->trans) { - sql->trans->errnum = ret; - } - return ret; -} - -static int dbd_sqlite3_get_row(apr_pool_t *pool, apr_dbd_results_t *res, - apr_dbd_row_t **rowp, int rownum) -{ - int i = 0; - - if (rownum == -1) { - *rowp = res->next_row; - if (*rowp == 0) - return -1; - res->next_row = (*rowp)->next_row; - return 0; - } - if (rownum > res->tuples) { - return -1; - } - rownum--; - *rowp = res->next_row; - for (; *rowp != 0; i++, *rowp = (*rowp)->next_row) { - if (i == rownum) { - return 0; - } - } - - return -1; - -} - -static const char *dbd_sqlite3_get_entry(const apr_dbd_row_t *row, int n) -{ - apr_dbd_column_t *column; - const char *value; - if ((n < 0) || (n >= row->columnCount)) { - return NULL; - } - column = row->columns[n]; - value = column->value; - return value; -} - -static const char *dbd_sqlite3_error(apr_dbd_t *sql, int n) -{ - return sqlite3_errmsg(sql->conn); -} - -static int dbd_sqlite3_query(apr_dbd_t *sql, int *nrows, const char *query) -{ - sqlite3_stmt *stmt = NULL; - const char *tail = NULL; - int ret = -1, length = 0; - - if (sql->trans && sql->trans->errnum) { - return sql->trans->errnum; - } - - length = strlen(query); -#if APR_HAS_THREADS - apr_thread_mutex_lock(sql->mutex); -#endif - - do { - int retry_count = 0; - - ret = sqlite3_prepare(sql->conn, query, length, &stmt, &tail); - if (ret != SQLITE_OK) { - sqlite3_finalize(stmt); - break; - } - - while(retry_count++ <= MAX_RETRY_COUNT) { - ret = sqlite3_step(stmt); - if (ret != SQLITE_BUSY) - break; - -#if APR_HAS_THREADS - apr_thread_mutex_unlock(sql->mutex); -#endif - apr_sleep(MAX_RETRY_SLEEP); -#if APR_HAS_THREADS - apr_thread_mutex_lock(sql->mutex); -#endif - } - - *nrows = sqlite3_changes(sql->conn); - sqlite3_finalize(stmt); - length -= (tail - query); - query = tail; - } while (length > 0); - - if (dbd_sqlite3_is_success(ret)) { - ret = 0; - } -#if APR_HAS_THREADS - apr_thread_mutex_unlock(sql->mutex); -#endif - if (sql->trans) { - sql->trans->errnum = ret; - } - return ret; -} - -static apr_status_t free_mem(void *data) -{ - sqlite3_free(data); - return APR_SUCCESS; -} - -static const char *dbd_sqlite3_escape(apr_pool_t *pool, const char *arg, - apr_dbd_t *sql) -{ - char *ret = sqlite3_mprintf("%q", arg); - apr_pool_cleanup_register(pool, ret, free_mem, - apr_pool_cleanup_null); - return ret; -} - -static int dbd_sqlite3_prepare(apr_pool_t *pool, apr_dbd_t *sql, - const char *query, const char *label, - apr_dbd_prepared_t **statement) -{ - sqlite3_stmt *stmt; - char *p, *slquery = apr_pstrdup(pool, query); - const char *tail = NULL, *q; - int ret; - - for (p = slquery, q = query; *q; ++q) { - if (q[0] == '%') { - if (isalpha(q[1])) { - *p++ = '?'; - ++q; - } - else if (q[1] == '%') { - /* reduce %% to % */ - *p++ = *q++; - } - else { - *p++ = *q; - } - } - else { - *p++ = *q; - } - } - *p = 0; - -#if APR_HAS_THREADS - apr_thread_mutex_lock(sql->mutex); -#endif - - ret = sqlite3_prepare(sql->conn, slquery, strlen(query), &stmt, &tail); - if (ret == SQLITE_OK) { - apr_dbd_prepared_t *prep; - - prep = apr_pcalloc(sql->pool, sizeof(*prep)); - prep->stmt = stmt; - prep->next = sql->prep; - - /* link new statement to the handle */ - sql->prep = prep; - - *statement = prep; - } else { - sqlite3_finalize(stmt); - } - -#if APR_HAS_THREADS - apr_thread_mutex_unlock(sql->mutex); -#endif - - return ret; -} - -static int dbd_sqlite3_pquery(apr_pool_t *pool, apr_dbd_t *sql, - int *nrows, apr_dbd_prepared_t *statement, - int nargs, const char **values) -{ - sqlite3_stmt *stmt = statement->stmt; - int ret = -1, retry_count = 0, i; - - if (sql->trans && sql->trans->errnum) { - return sql->trans->errnum; - } - -#if APR_HAS_THREADS - apr_thread_mutex_lock(sql->mutex); -#endif - - ret = sqlite3_reset(stmt); - if (ret == SQLITE_OK) { - for (i=0; i < nargs; i++) { - sqlite3_bind_text(stmt, i + 1, values[i], strlen(values[i]), - SQLITE_STATIC); - } - - while(retry_count++ <= MAX_RETRY_COUNT) { - ret = sqlite3_step(stmt); - if (ret != SQLITE_BUSY) - break; - -#if APR_HAS_THREADS - apr_thread_mutex_unlock(sql->mutex); -#endif - apr_sleep(MAX_RETRY_SLEEP); -#if APR_HAS_THREADS - apr_thread_mutex_lock(sql->mutex); -#endif - } - - *nrows = sqlite3_changes(sql->conn); - - sqlite3_reset(stmt); - } - - if (dbd_sqlite3_is_success(ret)) { - ret = 0; - } -#if APR_HAS_THREADS - apr_thread_mutex_unlock(sql->mutex); -#endif - if (sql->trans) { - sql->trans->errnum = ret; - } - - return ret; -} - -static int dbd_sqlite3_pvquery(apr_pool_t *pool, apr_dbd_t *sql, int *nrows, - apr_dbd_prepared_t *statement, va_list args) -{ - const char **values; - int i, nargs; - - if (sql->trans && sql->trans->errnum) { - return sql->trans->errnum; - } - - nargs = sqlite3_bind_parameter_count(statement->stmt); - values = apr_palloc(pool, sizeof(*values) * nargs); - - for (i = 0; i < nargs; i++) { - values[i] = apr_pstrdup(pool, va_arg(args, const char*)); - } - - return dbd_sqlite3_pquery(pool, sql, nrows, statement, nargs, values); -} - -static int dbd_sqlite3_pselect(apr_pool_t *pool, apr_dbd_t *sql, - apr_dbd_results_t **results, - apr_dbd_prepared_t *statement, int seek, - int nargs, const char **values) -{ - sqlite3_stmt *stmt = statement->stmt; - int i, ret, retry_count = 0; - size_t num_tuples = 0; - int increment = 0; - apr_dbd_row_t *row = NULL; - apr_dbd_row_t *lastrow = NULL; - apr_dbd_column_t *column; - char *hold = NULL; - - if (sql->trans && sql->trans->errnum) { - return sql->trans->errnum; - } - -#if APR_HAS_THREADS - apr_thread_mutex_lock(sql->mutex); -#endif - - ret = sqlite3_reset(stmt); - if (ret == SQLITE_OK) { - int column_count; - - for (i=0; i < nargs; i++) { - sqlite3_bind_text(stmt, i + 1, values[i], strlen(values[i]), - SQLITE_STATIC); - } - - column_count = sqlite3_column_count(stmt); - if (!*results) { - *results = apr_pcalloc(pool, sizeof(apr_dbd_results_t)); - } - (*results)->stmt = stmt; - (*results)->sz = column_count; - (*results)->random = seek; - (*results)->next_row = 0; - (*results)->tuples = 0; - (*results)->col_names = apr_pcalloc(pool, - column_count * sizeof(char *)); - do { - ret = sqlite3_step(stmt); - if (ret == SQLITE_BUSY) { - if (retry_count++ > MAX_RETRY_COUNT) { - ret = SQLITE_ERROR; - } else { -#if APR_HAS_THREADS - apr_thread_mutex_unlock(sql->mutex); -#endif - apr_sleep(MAX_RETRY_SLEEP); -#if APR_HAS_THREADS - apr_thread_mutex_lock(sql->mutex); -#endif - } - } else if (ret == SQLITE_ROW) { - int length; - apr_dbd_column_t *col; - row = apr_palloc(pool, sizeof(apr_dbd_row_t)); - row->res = *results; - increment = sizeof(apr_dbd_column_t *); - length = increment * (*results)->sz; - row->columns = apr_palloc(pool, length); - row->columnCount = column_count; - for (i = 0; i < (*results)->sz; i++) { - column = apr_palloc(pool, sizeof(apr_dbd_column_t)); - row->columns[i] = column; - /* copy column name once only */ - if ((*results)->col_names[i] == NULL) { - (*results)->col_names[i] = - apr_pstrdup(pool, sqlite3_column_name(stmt, i)); - } - column->name = (*results)->col_names[i]; - column->size = sqlite3_column_bytes(stmt, i); - column->type = sqlite3_column_type(stmt, i); - column->value = NULL; - switch (column->type) { - case SQLITE_FLOAT: - case SQLITE_INTEGER: - case SQLITE_TEXT: - hold = NULL; - hold = (char *) sqlite3_column_text(stmt, i); - if (hold) { - column->value = apr_palloc(pool, column->size + 1); - strncpy(column->value, hold, column->size + 1); - } - break; - case SQLITE_BLOB: - break; - case SQLITE_NULL: - break; - } - col = row->columns[i]; - } - row->rownum = num_tuples++; - row->next_row = 0; - (*results)->tuples = num_tuples; - if ((*results)->next_row == 0) { - (*results)->next_row = row; - } - if (lastrow != 0) { - lastrow->next_row = row; - } - lastrow = row; - } else if (ret == SQLITE_DONE) { - ret = SQLITE_OK; - } - } while (ret == SQLITE_ROW || ret == SQLITE_BUSY); - - sqlite3_reset(stmt); - } -#if APR_HAS_THREADS - apr_thread_mutex_unlock(sql->mutex); -#endif - - if (sql->trans) { - sql->trans->errnum = ret; - } - return ret; -} - -static int dbd_sqlite3_pvselect(apr_pool_t *pool, apr_dbd_t *sql, - apr_dbd_results_t **results, - apr_dbd_prepared_t *statement, int seek, - va_list args) -{ - const char **values; - int i, nargs; - - if (sql->trans && sql->trans->errnum) { - return sql->trans->errnum; - } - - nargs = sqlite3_bind_parameter_count(statement->stmt); - values = apr_palloc(pool, sizeof(*values) * nargs); - - for (i = 0; i < nargs; i++) { - values[i] = apr_pstrdup(pool, va_arg(args, const char*)); - } - - return dbd_sqlite3_pselect(pool, sql, results, statement, - seek, nargs, values); -} - -static int dbd_sqlite3_start_transaction(apr_pool_t *pool, - apr_dbd_t *handle, - apr_dbd_transaction_t **trans) -{ - int ret = 0; - int nrows = 0; - - ret = dbd_sqlite3_query(handle, &nrows, "BEGIN"); - if (!*trans) { - *trans = apr_pcalloc(pool, sizeof(apr_dbd_transaction_t)); - (*trans)->handle = handle; - handle->trans = *trans; - } - - return ret; -} - -static int dbd_sqlite3_end_transaction(apr_dbd_transaction_t *trans) -{ - int ret = -1; /* ending transaction that was never started is an error */ - int nrows = 0; - - if (trans) { - if (trans->errnum) { - trans->errnum = 0; - ret = dbd_sqlite3_query(trans->handle, &nrows, "ROLLBACK"); - } else { - ret = dbd_sqlite3_query(trans->handle, &nrows, "COMMIT"); - } - trans->handle->trans = NULL; - } - - return ret; -} - -static apr_dbd_t *dbd_sqlite3_open(apr_pool_t *pool, const char *params) -{ - apr_dbd_t *sql = NULL; - sqlite3 *conn = NULL; - apr_status_t res; - int sqlres; - if (!params) - return NULL; - sqlres = sqlite3_open(params, &conn); - if (sqlres != SQLITE_OK) { - sqlite3_close(conn); - return NULL; - } - /* should we register rand or power functions to the sqlite VM? */ - sql = apr_pcalloc(pool, sizeof(*sql)); - sql->conn = conn; - sql->pool = pool; - sql->trans = NULL; -#if APR_HAS_THREADS - /* Create a mutex */ - res = apr_thread_mutex_create(&sql->mutex, APR_THREAD_MUTEX_DEFAULT, - pool); - if (res != APR_SUCCESS) { - return NULL; - } -#endif - - return sql; -} - -static apr_status_t dbd_sqlite3_close(apr_dbd_t *handle) -{ - apr_dbd_prepared_t *prep = handle->prep; - - /* finalize all prepared statements, or we'll get SQLITE_BUSY on close */ - while (prep) { - sqlite3_finalize(prep->stmt); - prep = prep->next; - } - - sqlite3_close(handle->conn); -#if APR_HAS_THREADS - apr_thread_mutex_destroy(handle->mutex); -#endif - return APR_SUCCESS; -} - -static apr_status_t dbd_sqlite3_check_conn(apr_pool_t *pool, - apr_dbd_t *handle) -{ - return (handle->conn != NULL) ? APR_SUCCESS : APR_EGENERAL; -} - -static int dbd_sqlite3_select_db(apr_pool_t *pool, apr_dbd_t *handle, - const char *name) -{ - return APR_ENOTIMPL; -} - -static void *dbd_sqlite3_native(apr_dbd_t *handle) -{ - return handle->conn; -} - -static int dbd_sqlite3_num_cols(apr_dbd_results_t *res) -{ - return res->sz; -} - -static int dbd_sqlite3_num_tuples(apr_dbd_results_t *res) -{ - return res->tuples; -} - -APU_DECLARE_DATA const apr_dbd_driver_t apr_dbd_sqlite3_driver = { - "sqlite3", - NULL, - dbd_sqlite3_native, - dbd_sqlite3_open, - dbd_sqlite3_check_conn, - dbd_sqlite3_close, - dbd_sqlite3_select_db, - dbd_sqlite3_start_transaction, - dbd_sqlite3_end_transaction, - dbd_sqlite3_query, - dbd_sqlite3_select, - dbd_sqlite3_num_cols, - dbd_sqlite3_num_tuples, - dbd_sqlite3_get_row, - dbd_sqlite3_get_entry, - dbd_sqlite3_error, - dbd_sqlite3_escape, - dbd_sqlite3_prepare, - dbd_sqlite3_pvquery, - dbd_sqlite3_pvselect, - dbd_sqlite3_pquery, - dbd_sqlite3_pselect, -}; -#endif diff --git a/libs/apr-util/dbm/apr_dbm.c b/libs/apr-util/dbm/apr_dbm.c deleted file mode 100644 index 88cf08e675..0000000000 --- a/libs/apr-util/dbm/apr_dbm.c +++ /dev/null @@ -1,207 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_errno.h" -#include "apr_pools.h" -#include "apr_strings.h" -#define APR_WANT_MEMFUNC -#define APR_WANT_STRFUNC -#include "apr_want.h" -#include "apr_general.h" - -#include "apu.h" -#include "apu_select_dbm.h" -#include "apr_dbm.h" -#include "apr_dbm_private.h" - -/* ### note: the setting of DBM_VTABLE will go away once we have multiple - ### DBMs in here. - ### Well, that day is here. So, do we remove DBM_VTABLE and the old - ### API entirely? Oh, what to do. We need an APU_DEFAULT_DBM #define. - ### Sounds like a job for autoconf. */ - -#if APU_USE_SDBM -#define DBM_VTABLE apr_dbm_type_sdbm -#elif APU_USE_GDBM -#define DBM_VTABLE apr_dbm_type_gdbm -#elif APU_USE_DB -#define DBM_VTABLE apr_dbm_type_db -#elif APU_USE_NDBM -#define DBM_VTABLE apr_dbm_type_ndbm -#else /* Not in the USE_xDBM list above */ -#error a DBM implementation was not specified -#endif - -APU_DECLARE(apr_status_t) apr_dbm_open_ex(apr_dbm_t **pdb, const char*type, - const char *pathname, - apr_int32_t mode, apr_fileperms_t perm, - apr_pool_t *pool) -{ -#if APU_HAVE_GDBM - if (!strcasecmp(type, "GDBM")) { - return (*apr_dbm_type_gdbm.open)(pdb, pathname, mode, perm, pool); - } -#endif -#if APU_HAVE_SDBM - if (!strcasecmp(type, "SDBM")) { - return (*apr_dbm_type_sdbm.open)(pdb, pathname, mode, perm, pool); - } -#endif -#if APU_HAVE_DB - if (!strcasecmp(type, "DB")) { - return (*apr_dbm_type_db.open)(pdb, pathname, mode, perm, pool); - } -#endif -#if APU_HAVE_NDBM - if (!strcasecmp(type, "NDBM")) { - return (*apr_dbm_type_ndbm.open)(pdb, pathname, mode, perm, pool); - } -#endif - - if (!strcasecmp(type, "default")) { - return (*DBM_VTABLE.open)(pdb, pathname, mode, perm, pool); - } - - return APR_ENOTIMPL; -} - -APU_DECLARE(apr_status_t) apr_dbm_open(apr_dbm_t **pdb, const char *pathname, - apr_int32_t mode, apr_fileperms_t perm, - apr_pool_t *pool) -{ - return (*DBM_VTABLE.open)(pdb, pathname, mode, perm, pool); -} - -APU_DECLARE(void) apr_dbm_close(apr_dbm_t *dbm) -{ - (*dbm->type->close)(dbm); -} - -APU_DECLARE(apr_status_t) apr_dbm_fetch(apr_dbm_t *dbm, apr_datum_t key, - apr_datum_t *pvalue) -{ - return (*dbm->type->fetch)(dbm, key, pvalue); -} - -APU_DECLARE(apr_status_t) apr_dbm_store(apr_dbm_t *dbm, apr_datum_t key, - apr_datum_t value) -{ - return (*dbm->type->store)(dbm, key, value); -} - -APU_DECLARE(apr_status_t) apr_dbm_delete(apr_dbm_t *dbm, apr_datum_t key) -{ - return (*dbm->type->del)(dbm, key); -} - -APU_DECLARE(int) apr_dbm_exists(apr_dbm_t *dbm, apr_datum_t key) -{ - return (*dbm->type->exists)(dbm, key); -} - -APU_DECLARE(apr_status_t) apr_dbm_firstkey(apr_dbm_t *dbm, apr_datum_t *pkey) -{ - return (*dbm->type->firstkey)(dbm, pkey); -} - -APU_DECLARE(apr_status_t) apr_dbm_nextkey(apr_dbm_t *dbm, apr_datum_t *pkey) -{ - return (*dbm->type->nextkey)(dbm, pkey); -} - -APU_DECLARE(void) apr_dbm_freedatum(apr_dbm_t *dbm, apr_datum_t data) -{ - (*dbm->type->freedatum)(dbm, data); -} - -APU_DECLARE(char *) apr_dbm_geterror(apr_dbm_t *dbm, int *errcode, - char *errbuf, apr_size_t errbufsize) -{ - if (errcode != NULL) - *errcode = dbm->errcode; - - /* assert: errbufsize > 0 */ - - if (dbm->errmsg == NULL) - *errbuf = '\0'; - else - (void) apr_cpystrn(errbuf, dbm->errmsg, errbufsize); - return errbuf; -} - -APU_DECLARE(apr_status_t) apr_dbm_get_usednames_ex(apr_pool_t *p, - const char *type, - const char *pathname, - const char **used1, - const char **used2) -{ -#if APU_HAVE_GDBM - if (!strcasecmp(type, "GDBM")) { - (*apr_dbm_type_gdbm.getusednames)(p,pathname,used1,used2); - return APR_SUCCESS; - } -#endif -#if APU_HAVE_SDBM - if (!strcasecmp(type, "SDBM")) { - (*apr_dbm_type_sdbm.getusednames)(p,pathname,used1,used2); - return APR_SUCCESS; - } -#endif -#if APU_HAVE_DB - if (!strcasecmp(type, "DB")) { - (*apr_dbm_type_db.getusednames)(p,pathname,used1,used2); - return APR_SUCCESS; - } -#endif -#if APU_HAVE_NDBM - if (!strcasecmp(type, "NDBM")) { - (*apr_dbm_type_ndbm.getusednames)(p,pathname,used1,used2); - return APR_SUCCESS; - } -#endif - - if (!strcasecmp(type, "default")) { - (*DBM_VTABLE.getusednames)(p, pathname, used1, used2); - return APR_SUCCESS; - } - - return APR_ENOTIMPL; -} - -APU_DECLARE(void) apr_dbm_get_usednames(apr_pool_t *p, - const char *pathname, - const char **used1, - const char **used2) -{ - /* ### one day, a DBM type name will be passed and we'll need to look it - ### up. for now, it is constant. */ - - (*DBM_VTABLE.getusednames)(p, pathname, used1, used2); -} - -/* Most DBM libraries take a POSIX mode for creating files. Don't trust - * the mode_t type, some platforms may not support it, int is safe. - */ -APU_DECLARE(int) apr_posix_perms2mode(apr_fileperms_t perm) -{ - int mode = 0; - - mode |= 0700 & (perm >> 2); /* User is off-by-2 bits */ - mode |= 0070 & (perm >> 1); /* Group is off-by-1 bit */ - mode |= 0007 & (perm); /* World maps 1 for 1 */ - return mode; -} diff --git a/libs/apr-util/dbm/apr_dbm_berkeleydb.c b/libs/apr-util/dbm/apr_dbm_berkeleydb.c deleted file mode 100644 index 46ededcc0c..0000000000 --- a/libs/apr-util/dbm/apr_dbm_berkeleydb.c +++ /dev/null @@ -1,403 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_strings.h" -#define APR_WANT_MEMFUNC -#include "apr_want.h" - -#define APU_WANT_DB -#include "apu_want.h" - -#if APR_HAVE_STDLIB_H -#include /* for abort() */ -#endif - -#include "apu.h" - -#if APU_HAVE_DB -#include "apr_dbm_private.h" - -/* - * We pick up all varieties of Berkeley DB through db.h (included through - * apu_select_dbm.h). This code has been compiled/tested against DB1, - * DB_185, DB2, DB3, and DB4. - */ - -#if defined(DB_VERSION_MAJOR) && (DB_VERSION_MAJOR == 4) -/* We will treat anything greater than 4.1 as DB4. - * We can treat 4.0 as DB3. - */ -#if defined(DB_VERSION_MINOR) && (DB_VERSION_MINOR >= 1) -#define DB_VER 4 -#else -#define DB_VER 3 -#endif -#elif defined(DB_VERSION_MAJOR) && (DB_VERSION_MAJOR == 3) -#define DB_VER 3 -#elif defined(DB_VERSION_MAJOR) && (DB_VERSION_MAJOR == 2) -#define DB_VER 2 -#else -#define DB_VER 1 -#endif - -typedef struct { - DB *bdb; -#if DB_VER != 1 - DBC *curs; -#endif -} real_file_t; - - -#if DB_VER == 1 -#define TXN_ARG -#else -#define TXN_ARG NULL, -#endif - -#define GET_BDB(f) (((real_file_t *)(f))->bdb) - -#define do_fetch(bdb, k, v) ((*(bdb)->get)(bdb, TXN_ARG &(k), &(v), 0)) - -#if DB_VER == 1 -#include -#define APR_DBM_DBMODE_RO O_RDONLY -#define APR_DBM_DBMODE_RW O_RDWR -#define APR_DBM_DBMODE_RWCREATE (O_CREAT | O_RDWR) -#define APR_DBM_DBMODE_RWTRUNC (O_CREAT | O_RDWR | O_TRUNC) -#else -#define APR_DBM_DBMODE_RO DB_RDONLY -#define APR_DBM_DBMODE_RW 0 -#define APR_DBM_DBMODE_RWCREATE DB_CREATE -#define APR_DBM_DBMODE_RWTRUNC DB_TRUNCATE -#endif /* DBVER == 1 */ - -/* -------------------------------------------------------------------------- -** -** UTILITY FUNCTIONS -*/ - -/* map a DB error to an apr_status_t */ -static apr_status_t db2s(int dberr) -{ - if (dberr != 0) { - /* ### need to fix this */ - return APR_OS_START_USEERR + dberr; - } - - return APR_SUCCESS; -} - - -static apr_status_t set_error(apr_dbm_t *dbm, apr_status_t dbm_said) -{ - apr_status_t rv = APR_SUCCESS; - - /* ### ignore whatever the DBM said (dbm_said); ask it explicitly */ - - if (dbm_said == APR_SUCCESS) { - dbm->errcode = 0; - dbm->errmsg = NULL; - } - else { - /* ### need to fix. dberr was tossed in db2s(). */ - /* ### use db_strerror() */ - dbm->errcode = dbm_said; -#if DB_VER == 1 || DB_VER == 2 - dbm->errmsg = NULL; -#else - dbm->errmsg = db_strerror(dbm_said - APR_OS_START_USEERR); -#endif - rv = dbm_said; - } - - return rv; -} - -/* -------------------------------------------------------------------------- -** -** DEFINE THE VTABLE FUNCTIONS FOR BERKELEY DB -** -** ### we may need three sets of these: db1, db2, db3 -*/ - -static apr_status_t vt_db_open(apr_dbm_t **pdb, const char *pathname, - apr_int32_t mode, apr_fileperms_t perm, - apr_pool_t *pool) -{ - real_file_t file; - int dbmode; - - *pdb = NULL; - - switch (mode) { - case APR_DBM_READONLY: - dbmode = APR_DBM_DBMODE_RO; - break; - case APR_DBM_READWRITE: - dbmode = APR_DBM_DBMODE_RW; - break; - case APR_DBM_RWCREATE: - dbmode = APR_DBM_DBMODE_RWCREATE; - break; - case APR_DBM_RWTRUNC: - dbmode = APR_DBM_DBMODE_RWTRUNC; - break; - default: - return APR_EINVAL; - } - - { - int dberr; - -#if DB_VER >= 3 - if ((dberr = db_create(&file.bdb, NULL, 0)) == 0) { - if ((dberr = (*file.bdb->open)(file.bdb, -#if DB_VER == 4 - NULL, -#endif - pathname, NULL, - DB_HASH, dbmode, - apr_posix_perms2mode(perm))) != 0) { - /* close the DB handler */ - (void) (*file.bdb->close)(file.bdb, 0); - } - } - file.curs = NULL; -#elif DB_VER == 2 - dberr = db_open(pathname, DB_HASH, dbmode, apr_posix_perms2mode(perm), - NULL, NULL, &file.bdb); - file.curs = NULL; -#else - file.bdb = dbopen(pathname, dbmode, apr_posix_perms2mode(perm), - DB_HASH, NULL); - if (file.bdb == NULL) - return APR_EGENERAL; /* ### need a better error */ - dberr = 0; -#endif - if (dberr != 0) - return db2s(dberr); - } - - /* we have an open database... return it */ - *pdb = apr_pcalloc(pool, sizeof(**pdb)); - (*pdb)->pool = pool; - (*pdb)->type = &apr_dbm_type_db; - (*pdb)->file = apr_pmemdup(pool, &file, sizeof(file)); - - /* ### register a cleanup to close the DBM? */ - - return APR_SUCCESS; -} - -static void vt_db_close(apr_dbm_t *dbm) -{ - (*GET_BDB(dbm->file)->close)(GET_BDB(dbm->file) -#if DB_VER != 1 - , 0 -#endif - ); -} - -static apr_status_t vt_db_fetch(apr_dbm_t *dbm, apr_datum_t key, - apr_datum_t * pvalue) -{ - DBT ckey = { 0 }; - DBT rd = { 0 }; - int dberr; - - ckey.data = key.dptr; - ckey.size = key.dsize; - - dberr = do_fetch(GET_BDB(dbm->file), ckey, rd); - - /* "not found" is not an error. return zero'd value. */ - if (dberr == -#if DB_VER == 1 - RET_SPECIAL -#else - DB_NOTFOUND -#endif - ) { - memset(&rd, 0, sizeof(rd)); - dberr = 0; - } - - pvalue->dptr = rd.data; - pvalue->dsize = rd.size; - - /* store the error info into DBM, and return a status code. Also, note - that *pvalue should have been cleared on error. */ - return set_error(dbm, db2s(dberr)); -} - -static apr_status_t vt_db_store(apr_dbm_t *dbm, apr_datum_t key, - apr_datum_t value) -{ - apr_status_t rv; - DBT ckey = { 0 }; - DBT cvalue = { 0 }; - - ckey.data = key.dptr; - ckey.size = key.dsize; - - cvalue.data = value.dptr; - cvalue.size = value.dsize; - - rv = db2s((*GET_BDB(dbm->file)->put)(GET_BDB(dbm->file), - TXN_ARG - &ckey, - &cvalue, - 0)); - - /* store any error info into DBM, and return a status code. */ - return set_error(dbm, rv); -} - -static apr_status_t vt_db_del(apr_dbm_t *dbm, apr_datum_t key) -{ - apr_status_t rv; - DBT ckey = { 0 }; - - ckey.data = key.dptr; - ckey.size = key.dsize; - - rv = db2s((*GET_BDB(dbm->file)->del)(GET_BDB(dbm->file), - TXN_ARG - &ckey, - 0)); - - /* store any error info into DBM, and return a status code. */ - return set_error(dbm, rv); -} - -static int vt_db_exists(apr_dbm_t *dbm, apr_datum_t key) -{ - DBT ckey = { 0 }; /* converted key */ - DBT data = { 0 }; - int dberr; - - ckey.data = key.dptr; - ckey.size = key.dsize; - - dberr = do_fetch(GET_BDB(dbm->file), ckey, data); - - /* note: the result data is "loaned" to us; we don't need to free it */ - - /* DB returns DB_NOTFOUND if it doesn't exist. but we want to say - that *any* error means it doesn't exist. */ - return dberr == 0; -} - -static apr_status_t vt_db_firstkey(apr_dbm_t *dbm, apr_datum_t * pkey) -{ - real_file_t *f = dbm->file; - DBT first = { 0 }; - DBT data = { 0 }; - int dberr; - -#if DB_VER == 1 - dberr = (*f->bdb->seq)(f->bdb, &first, &data, R_FIRST); -#else - if ((dberr = (*f->bdb->cursor)(f->bdb, NULL, &f->curs -#if DB_VER >= 3 || ((DB_VERSION_MAJOR == 2) && (DB_VERSION_MINOR > 5)) - , 0 -#endif - )) == 0) { - dberr = (*f->curs->c_get)(f->curs, &first, &data, DB_FIRST); - if (dberr == DB_NOTFOUND) { - memset(&first, 0, sizeof(first)); - (*f->curs->c_close)(f->curs); - f->curs = NULL; - dberr = 0; - } - } -#endif - - pkey->dptr = first.data; - pkey->dsize = first.size; - - /* store any error info into DBM, and return a status code. */ - return set_error(dbm, db2s(dberr)); -} - -static apr_status_t vt_db_nextkey(apr_dbm_t *dbm, apr_datum_t * pkey) -{ - real_file_t *f = dbm->file; - DBT ckey = { 0 }; - DBT data = { 0 }; - int dberr; - - ckey.data = pkey->dptr; - ckey.size = pkey->dsize; - -#if DB_VER == 1 - dberr = (*f->bdb->seq)(f->bdb, &ckey, &data, R_NEXT); - if (dberr == RET_SPECIAL) { - dberr = 0; - ckey.data = NULL; - ckey.size = 0; - } -#else - if (f->curs == NULL) - return APR_EINVAL; - - dberr = (*f->curs->c_get)(f->curs, &ckey, &data, DB_NEXT); - if (dberr == DB_NOTFOUND) { - (*f->curs->c_close)(f->curs); - f->curs = NULL; - dberr = 0; - ckey.data = NULL; - ckey.size = 0; - } -#endif - - pkey->dptr = ckey.data; - pkey->dsize = ckey.size; - - /* store any error info into DBM, and return a status code. */ - /* ### or use db2s(dberr) instead of APR_SUCCESS? */ - return set_error(dbm, APR_SUCCESS); -} - -static void vt_db_freedatum(apr_dbm_t *dbm, apr_datum_t data) -{ - /* nothing to do */ -} - -static void vt_db_usednames(apr_pool_t *pool, const char *pathname, - const char **used1, const char **used2) -{ - *used1 = apr_pstrdup(pool, pathname); - *used2 = NULL; -} - - -APU_DECLARE_DATA const apr_dbm_type_t apr_dbm_type_db = { - "db", - - vt_db_open, - vt_db_close, - vt_db_fetch, - vt_db_store, - vt_db_del, - vt_db_exists, - vt_db_firstkey, - vt_db_nextkey, - vt_db_freedatum, - vt_db_usednames -}; - -#endif /* APU_HAVE_DB */ diff --git a/libs/apr-util/dbm/apr_dbm_gdbm.c b/libs/apr-util/dbm/apr_dbm_gdbm.c deleted file mode 100644 index 93fb942a6c..0000000000 --- a/libs/apr-util/dbm/apr_dbm_gdbm.c +++ /dev/null @@ -1,270 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_strings.h" - -#if APR_HAVE_STDLIB_H -#include /* for free() */ -#endif - -#include "apu.h" - -#if APU_HAVE_GDBM -#include "apr_dbm_private.h" - -#include - -/* this is used in a few places to define a noop "function". it is needed - to stop "no effect" warnings from GCC. */ -#define NOOP_FUNCTION if (0) ; else - -/* ### define defaults for now; these will go away in a while */ -#define REGISTER_CLEANUP(dbm, pdatum) NOOP_FUNCTION -#define SET_FILE(pdb, f) ((pdb)->file = (f)) - -typedef GDBM_FILE real_file_t; - -typedef datum *cvt_datum_t; -#define CONVERT_DATUM(cvt, pinput) ((cvt) = (datum *)(pinput)) - -typedef datum result_datum_t; -#define RETURN_DATUM(poutput, rd) (*(poutput) = *(apr_datum_t *)&(rd)) - -#define APR_DBM_CLOSE(f) gdbm_close(f) -#define APR_DBM_FETCH(f, k, v) ((v) = gdbm_fetch(f, *(k)), APR_SUCCESS) -#define APR_DBM_STORE(f, k, v) g2s(gdbm_store(f, *(k), *(v), GDBM_REPLACE)) -#define APR_DBM_DELETE(f, k) g2s(gdbm_delete(f, *(k))) -#define APR_DBM_FIRSTKEY(f, k) ((k) = gdbm_firstkey(f), APR_SUCCESS) -#define APR_DBM_NEXTKEY(f, k, nk) ((nk) = gdbm_nextkey(f, *(k)), APR_SUCCESS) -#define APR_DBM_FREEDPTR(dptr) ((dptr) ? free(dptr) : 0) - -#undef REGISTER_CLEANUP -#define REGISTER_CLEANUP(dbm, pdatum) \ - if ((pdatum)->dptr) \ - apr_pool_cleanup_register((dbm)->pool, (pdatum)->dptr, \ - datum_cleanup, apr_pool_cleanup_null); \ - else - -#define APR_DBM_DBMODE_RO GDBM_READER -#define APR_DBM_DBMODE_RW GDBM_WRITER -#define APR_DBM_DBMODE_RWCREATE GDBM_WRCREAT -#define APR_DBM_DBMODE_RWTRUNC GDBM_NEWDB - -/* map a GDBM error to an apr_status_t */ -static apr_status_t g2s(int gerr) -{ - if (gerr == -1) { - /* ### need to fix this */ - return APR_EGENERAL; - } - - return APR_SUCCESS; -} - -static apr_status_t datum_cleanup(void *dptr) -{ - if (dptr) - free(dptr); - - return APR_SUCCESS; -} - -static apr_status_t set_error(apr_dbm_t *dbm, apr_status_t dbm_said) -{ - apr_status_t rv = APR_SUCCESS; - - /* ### ignore whatever the DBM said (dbm_said); ask it explicitly */ - - if ((dbm->errcode = gdbm_errno) == GDBM_NO_ERROR) { - dbm->errmsg = NULL; - } - else { - dbm->errmsg = gdbm_strerror(gdbm_errno); - rv = APR_EGENERAL; /* ### need something better */ - } - - /* captured it. clear it now. */ - gdbm_errno = GDBM_NO_ERROR; - - return rv; -} - -/* -------------------------------------------------------------------------- -** -** DEFINE THE VTABLE FUNCTIONS FOR GDBM -*/ - -static apr_status_t vt_gdbm_open(apr_dbm_t **pdb, const char *pathname, - apr_int32_t mode, apr_fileperms_t perm, - apr_pool_t *pool) -{ - real_file_t file; - int dbmode; - - *pdb = NULL; - - switch (mode) { - case APR_DBM_READONLY: - dbmode = APR_DBM_DBMODE_RO; - break; - case APR_DBM_READWRITE: - dbmode = APR_DBM_DBMODE_RW; - break; - case APR_DBM_RWCREATE: - dbmode = APR_DBM_DBMODE_RWCREATE; - break; - case APR_DBM_RWTRUNC: - dbmode = APR_DBM_DBMODE_RWTRUNC; - break; - default: - return APR_EINVAL; - } - - { - /* Note: stupid cast to get rid of "const" on the pathname */ - file = gdbm_open((char *) pathname, 0, dbmode, - apr_posix_perms2mode(perm), NULL); - if (file == NULL) - return APR_EGENERAL; /* ### need a better error */ - } - - /* we have an open database... return it */ - *pdb = apr_pcalloc(pool, sizeof(**pdb)); - (*pdb)->pool = pool; - (*pdb)->type = &apr_dbm_type_gdbm; - SET_FILE(*pdb, file); - - /* ### register a cleanup to close the DBM? */ - - return APR_SUCCESS; -} - -static void vt_gdbm_close(apr_dbm_t *dbm) -{ - APR_DBM_CLOSE(dbm->file); -} - -static apr_status_t vt_gdbm_fetch(apr_dbm_t *dbm, apr_datum_t key, - apr_datum_t * pvalue) -{ - apr_status_t rv; - cvt_datum_t ckey; - result_datum_t rd; - - CONVERT_DATUM(ckey, &key); - rv = APR_DBM_FETCH(dbm->file, ckey, rd); - RETURN_DATUM(pvalue, rd); - - REGISTER_CLEANUP(dbm, pvalue); - - /* store the error info into DBM, and return a status code. Also, note - that *pvalue should have been cleared on error. */ - return set_error(dbm, rv); -} - -static apr_status_t vt_gdbm_store(apr_dbm_t *dbm, apr_datum_t key, - apr_datum_t value) -{ - apr_status_t rv; - cvt_datum_t ckey; - cvt_datum_t cvalue; - - CONVERT_DATUM(ckey, &key); - CONVERT_DATUM(cvalue, &value); - rv = APR_DBM_STORE(dbm->file, ckey, cvalue); - - /* store any error info into DBM, and return a status code. */ - return set_error(dbm, rv); -} - -static apr_status_t vt_gdbm_del(apr_dbm_t *dbm, apr_datum_t key) -{ - apr_status_t rv; - cvt_datum_t ckey; - - CONVERT_DATUM(ckey, &key); - rv = APR_DBM_DELETE(dbm->file, ckey); - - /* store any error info into DBM, and return a status code. */ - return set_error(dbm, rv); -} - -static int vt_gdbm_exists(apr_dbm_t *dbm, apr_datum_t key) -{ - datum *ckey = (datum *)&key; - - return gdbm_exists(dbm->file, *ckey) != 0; -} - -static apr_status_t vt_gdbm_firstkey(apr_dbm_t *dbm, apr_datum_t * pkey) -{ - apr_status_t rv; - result_datum_t rd; - - rv = APR_DBM_FIRSTKEY(dbm->file, rd); - RETURN_DATUM(pkey, rd); - - REGISTER_CLEANUP(dbm, pkey); - - /* store any error info into DBM, and return a status code. */ - return set_error(dbm, rv); -} - -static apr_status_t vt_gdbm_nextkey(apr_dbm_t *dbm, apr_datum_t * pkey) -{ - apr_status_t rv; - cvt_datum_t ckey; - result_datum_t rd; - - CONVERT_DATUM(ckey, pkey); - rv = APR_DBM_NEXTKEY(dbm->file, ckey, rd); - RETURN_DATUM(pkey, rd); - - REGISTER_CLEANUP(dbm, pkey); - - /* store any error info into DBM, and return a status code. */ - return set_error(dbm, APR_SUCCESS); -} - -static void vt_gdbm_freedatum(apr_dbm_t *dbm, apr_datum_t data) -{ - (void) apr_pool_cleanup_run(dbm->pool, data.dptr, datum_cleanup); -} - -static void vt_gdbm_usednames(apr_pool_t *pool, const char *pathname, - const char **used1, const char **used2) -{ - *used1 = apr_pstrdup(pool, pathname); - *used2 = NULL; -} - - -APU_DECLARE_DATA const apr_dbm_type_t apr_dbm_type_gdbm = { - "gdbm", - - vt_gdbm_open, - vt_gdbm_close, - vt_gdbm_fetch, - vt_gdbm_store, - vt_gdbm_del, - vt_gdbm_exists, - vt_gdbm_firstkey, - vt_gdbm_nextkey, - vt_gdbm_freedatum, - vt_gdbm_usednames -}; - -#endif /* APU_HAVE_GDBM */ diff --git a/libs/apr-util/dbm/apr_dbm_ndbm.c b/libs/apr-util/dbm/apr_dbm_ndbm.c deleted file mode 100644 index d770ed4403..0000000000 --- a/libs/apr-util/dbm/apr_dbm_ndbm.c +++ /dev/null @@ -1,227 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_strings.h" - -#if APR_HAVE_STDLIB_H -#include /* for free() */ -#endif - -#include "apu.h" - -#if APU_HAVE_NDBM -#include "apr_dbm_private.h" - -#include -#include -#include -#include - -/* this is used in a few places to define a noop "function". it is needed - to stop "no effect" warnings from GCC. */ -#define NOOP_FUNCTION if (0) ; else - -#define APR_DBM_DBMODE_RO O_RDONLY -#define APR_DBM_DBMODE_RW O_RDWR -#define APR_DBM_DBMODE_RWCREATE (O_RDWR|O_CREAT) -#define APR_DBM_DBMODE_RWTRUNC (O_RDWR|O_CREAT|O_TRUNC) - -/* map a NDBM error to an apr_status_t */ -static apr_status_t ndbm2s(int ndbmerr) -{ - if (ndbmerr == -1) { - /* ### need to fix this */ - return APR_EGENERAL; - } - - return APR_SUCCESS; -} - -static apr_status_t set_error(apr_dbm_t *dbm, apr_status_t dbm_said) -{ - apr_status_t rv = APR_SUCCESS; - - /* ### ignore whatever the DBM said (dbm_said); ask it explicitly */ - - dbm->errmsg = NULL; - if (dbm_error((DBM*)dbm->file)) { - dbm->errmsg = NULL; - rv = APR_EGENERAL; /* ### need something better */ - } - - /* captured it. clear it now. */ - dbm_clearerr((DBM*)dbm->file); - - return rv; -} - -/* -------------------------------------------------------------------------- -** -** DEFINE THE VTABLE FUNCTIONS FOR NDBM -*/ - -static apr_status_t vt_ndbm_open(apr_dbm_t **pdb, const char *pathname, - apr_int32_t mode, apr_fileperms_t perm, - apr_pool_t *pool) -{ - DBM *file; - int dbmode; - - *pdb = NULL; - - switch (mode) { - case APR_DBM_READONLY: - dbmode = APR_DBM_DBMODE_RO; - break; - case APR_DBM_READWRITE: - dbmode = APR_DBM_DBMODE_RW; - break; - case APR_DBM_RWCREATE: - dbmode = APR_DBM_DBMODE_RWCREATE; - break; - case APR_DBM_RWTRUNC: - dbmode = APR_DBM_DBMODE_RWTRUNC; - break; - default: - return APR_EINVAL; - } - - { - file = dbm_open(pathname, dbmode, apr_posix_perms2mode(perm)); - if (file == NULL) - return APR_EGENERAL; /* ### need a better error */ - } - - /* we have an open database... return it */ - *pdb = apr_pcalloc(pool, sizeof(**pdb)); - (*pdb)->pool = pool; - (*pdb)->type = &apr_dbm_type_ndbm; - (*pdb)->file = file; - - /* ### register a cleanup to close the DBM? */ - - return APR_SUCCESS; -} - -static void vt_ndbm_close(apr_dbm_t *dbm) -{ - dbm_close(dbm->file); -} - -static apr_status_t vt_ndbm_fetch(apr_dbm_t *dbm, apr_datum_t key, - apr_datum_t * pvalue) -{ - datum *ckey; - datum rd; - - ckey = (datum*)&key; - rd = dbm_fetch(dbm->file, *ckey); - *pvalue = *(apr_datum_t*)&rd; - - /* store the error info into DBM, and return a status code. Also, note - that *pvalue should have been cleared on error. */ - return set_error(dbm, APR_SUCCESS); -} - -static apr_status_t vt_ndbm_store(apr_dbm_t *dbm, apr_datum_t key, - apr_datum_t value) -{ - apr_status_t rv; - datum *ckey; - datum *cvalue; - - ckey = (datum*)&key; - cvalue = (datum*)&value; - rv = ndbm2s( dbm_store( dbm->file, *ckey, *cvalue, DBM_REPLACE)); - - /* store any error info into DBM, and return a status code. */ - return set_error(dbm, rv); -} - -static apr_status_t vt_ndbm_del(apr_dbm_t *dbm, apr_datum_t key) -{ - apr_status_t rv; - datum *ckey; - - ckey = (datum*)&key; - rv = ndbm2s( dbm_delete(dbm->file, *ckey)); - - /* store any error info into DBM, and return a status code. */ - return set_error(dbm, rv); -} - -static int vt_ndbm_exists(apr_dbm_t *dbm, apr_datum_t key) -{ - datum *ckey = (datum *)&key; - datum value; - - value = dbm_fetch( dbm->file, *ckey); - - return value.dptr != NULL; -} - -static apr_status_t vt_ndbm_firstkey(apr_dbm_t *dbm, apr_datum_t * pkey) -{ - datum rd; - - rd = dbm_firstkey(dbm->file); - *pkey = *(apr_datum_t*)&rd; - - /* store any error info into DBM, and return a status code. */ - return set_error(dbm, APR_SUCCESS); -} - -static apr_status_t vt_ndbm_nextkey(apr_dbm_t *dbm, apr_datum_t * pkey) -{ - datum *ckey; - datum rd; - - ckey = (datum*)pkey; - rd = dbm_nextkey(dbm->file); - *pkey = *(apr_datum_t*)&rd; - - /* store any error info into DBM, and return a status code. */ - return set_error(dbm, APR_SUCCESS); -} - -static void vt_ndbm_freedatum(apr_dbm_t *dbm, apr_datum_t data) -{ - /* nothing to do */ -} - -static void vt_ndbm_usednames(apr_pool_t *pool, const char *pathname, - const char **used1, const char **used2) -{ - *used1 = apr_pstrdup(pool, pathname); - *used2 = NULL; -} - - -APU_DECLARE_DATA const apr_dbm_type_t apr_dbm_type_ndbm = { - "ndbm", - - vt_ndbm_open, - vt_ndbm_close, - vt_ndbm_fetch, - vt_ndbm_store, - vt_ndbm_del, - vt_ndbm_exists, - vt_ndbm_firstkey, - vt_ndbm_nextkey, - vt_ndbm_freedatum, - vt_ndbm_usednames -}; -#endif /* APU_HAVE_NDBM */ diff --git a/libs/apr-util/dbm/apr_dbm_sdbm.c b/libs/apr-util/dbm/apr_dbm_sdbm.c deleted file mode 100644 index dadb1e2670..0000000000 --- a/libs/apr-util/dbm/apr_dbm_sdbm.c +++ /dev/null @@ -1,265 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_strings.h" -#define APR_WANT_MEMFUNC -#define APR_WANT_STRFUNC -#include "apr_want.h" - -#include "apu.h" - -#if APU_HAVE_SDBM - -#include "apr_dbm_private.h" - -#include "apr_sdbm.h" -#if APR_HAVE_STDLIB_H -#include /* For abort() */ -#endif - -/* this is used in a few places to define a noop "function". it is needed - to stop "no effect" warnings from GCC. */ -#define NOOP_FUNCTION if (0) ; else - -/* ### define defaults for now; these will go away in a while */ -#define REGISTER_CLEANUP(dbm, pdatum) NOOP_FUNCTION -#define SET_FILE(pdb, f) ((pdb)->file = (f)) - -typedef apr_sdbm_t *real_file_t; - -typedef apr_sdbm_datum_t cvt_datum_t; -#define CONVERT_DATUM(cvt, pinput) ((cvt).dptr = (pinput)->dptr, (cvt).dsize = (pinput)->dsize) - -typedef apr_sdbm_datum_t result_datum_t; -#define RETURN_DATUM(poutput, rd) ((poutput)->dptr = (rd).dptr, (poutput)->dsize = (rd).dsize) - -#define APR_DBM_CLOSE(f) apr_sdbm_close(f) -#define APR_DBM_FETCH(f, k, v) apr_sdbm_fetch(f, &(v), (k)) -#define APR_DBM_STORE(f, k, v) apr_sdbm_store(f, (k), (v), APR_SDBM_REPLACE) -#define APR_DBM_DELETE(f, k) apr_sdbm_delete(f, (k)) -#define APR_DBM_FIRSTKEY(f, k) apr_sdbm_firstkey(f, &(k)) -#define APR_DBM_NEXTKEY(f, k, nk) apr_sdbm_nextkey(f, &(nk)) -#define APR_DBM_FREEDPTR(dptr) NOOP_FUNCTION - -#define APR_DBM_DBMODE_RO APR_READ -#define APR_DBM_DBMODE_RW (APR_READ | APR_WRITE) -#define APR_DBM_DBMODE_RWCREATE (APR_READ | APR_WRITE | APR_CREATE) -#define APR_DBM_DBMODE_RWTRUNC (APR_READ | APR_WRITE | APR_CREATE | \ - APR_TRUNCATE) - -static apr_status_t set_error(apr_dbm_t *dbm, apr_status_t dbm_said) -{ - apr_status_t rv = APR_SUCCESS; - - /* ### ignore whatever the DBM said (dbm_said); ask it explicitly */ - - if ((dbm->errcode = dbm_said) == APR_SUCCESS) { - dbm->errmsg = NULL; - } - else { - dbm->errmsg = "I/O error occurred."; - rv = APR_EGENERAL; /* ### need something better */ - } - - return rv; -} - -/* -------------------------------------------------------------------------- -** -** DEFINE THE VTABLE FUNCTIONS FOR SDBM -*/ - -static apr_status_t vt_sdbm_open(apr_dbm_t **pdb, const char *pathname, - apr_int32_t mode, apr_fileperms_t perm, - apr_pool_t *pool) -{ - real_file_t file; - int dbmode; - - *pdb = NULL; - - switch (mode) { - case APR_DBM_READONLY: - dbmode = APR_DBM_DBMODE_RO; - break; - case APR_DBM_READWRITE: - dbmode = APR_DBM_DBMODE_RW; - break; - case APR_DBM_RWCREATE: - dbmode = APR_DBM_DBMODE_RWCREATE; - break; - case APR_DBM_RWTRUNC: - dbmode = APR_DBM_DBMODE_RWTRUNC; - break; - default: - return APR_EINVAL; - } - - { - apr_status_t rv; - - rv = apr_sdbm_open(&file, pathname, dbmode, perm, pool); - if (rv != APR_SUCCESS) - return rv; - } - - /* we have an open database... return it */ - *pdb = apr_pcalloc(pool, sizeof(**pdb)); - (*pdb)->pool = pool; - (*pdb)->type = &apr_dbm_type_sdbm; - SET_FILE(*pdb, file); - - /* ### register a cleanup to close the DBM? */ - - return APR_SUCCESS; -} - -static void vt_sdbm_close(apr_dbm_t *dbm) -{ - APR_DBM_CLOSE(dbm->file); -} - -static apr_status_t vt_sdbm_fetch(apr_dbm_t *dbm, apr_datum_t key, - apr_datum_t * pvalue) -{ - apr_status_t rv; - cvt_datum_t ckey; - result_datum_t rd; - - CONVERT_DATUM(ckey, &key); - rv = APR_DBM_FETCH(dbm->file, ckey, rd); - RETURN_DATUM(pvalue, rd); - - REGISTER_CLEANUP(dbm, pvalue); - - /* store the error info into DBM, and return a status code. Also, note - that *pvalue should have been cleared on error. */ - return set_error(dbm, rv); -} - -static apr_status_t vt_sdbm_store(apr_dbm_t *dbm, apr_datum_t key, - apr_datum_t value) -{ - apr_status_t rv; - cvt_datum_t ckey; - cvt_datum_t cvalue; - - CONVERT_DATUM(ckey, &key); - CONVERT_DATUM(cvalue, &value); - rv = APR_DBM_STORE(dbm->file, ckey, cvalue); - - /* store any error info into DBM, and return a status code. */ - return set_error(dbm, rv); -} - -static apr_status_t vt_sdbm_del(apr_dbm_t *dbm, apr_datum_t key) -{ - apr_status_t rv; - cvt_datum_t ckey; - - CONVERT_DATUM(ckey, &key); - rv = APR_DBM_DELETE(dbm->file, ckey); - - /* store any error info into DBM, and return a status code. */ - return set_error(dbm, rv); -} - -static int vt_sdbm_exists(apr_dbm_t *dbm, apr_datum_t key) -{ - int exists; - apr_sdbm_datum_t ckey; - - CONVERT_DATUM(ckey, &key); - - { - apr_sdbm_datum_t value; - if (apr_sdbm_fetch(dbm->file, &value, ckey) != APR_SUCCESS) { - exists = 0; - } - else - exists = value.dptr != NULL; - } - - return exists; -} - -static apr_status_t vt_sdbm_firstkey(apr_dbm_t *dbm, apr_datum_t * pkey) -{ - apr_status_t rv; - result_datum_t rd; - - rv = APR_DBM_FIRSTKEY(dbm->file, rd); - RETURN_DATUM(pkey, rd); - - REGISTER_CLEANUP(dbm, pkey); - - /* store any error info into DBM, and return a status code. */ - return set_error(dbm, rv); -} - -static apr_status_t vt_sdbm_nextkey(apr_dbm_t *dbm, apr_datum_t * pkey) -{ - apr_status_t rv; - cvt_datum_t ckey; - result_datum_t rd; - - CONVERT_DATUM(ckey, pkey); - rv = APR_DBM_NEXTKEY(dbm->file, ckey, rd); - RETURN_DATUM(pkey, rd); - - REGISTER_CLEANUP(dbm, pkey); - - /* store any error info into DBM, and return a status code. */ - return set_error(dbm, APR_SUCCESS); -} - -static void vt_sdbm_freedatum(apr_dbm_t *dbm, apr_datum_t data) -{ - APR_DBM_FREEDPTR(data.dptr); -} - -static void vt_sdbm_usednames(apr_pool_t *pool, const char *pathname, - const char **used1, const char **used2) -{ - char *work; - - /* ### this could be optimized by computing strlen() once and using - ### memcpy and pmemdup instead. but why bother? */ - - *used1 = apr_pstrcat(pool, pathname, APR_SDBM_DIRFEXT, NULL); - *used2 = work = apr_pstrdup(pool, *used1); - - /* we know the extension is 4 characters */ - memcpy(&work[strlen(work) - 4], APR_SDBM_PAGFEXT, 4); -} - - -APU_DECLARE_DATA const apr_dbm_type_t apr_dbm_type_sdbm = { - "sdbm", - - vt_sdbm_open, - vt_sdbm_close, - vt_sdbm_fetch, - vt_sdbm_store, - vt_sdbm_del, - vt_sdbm_exists, - vt_sdbm_firstkey, - vt_sdbm_nextkey, - vt_sdbm_freedatum, - vt_sdbm_usednames -}; - -#endif /* APU_HAVE_SDBM */ diff --git a/libs/apr-util/dbm/sdbm/sdbm.c b/libs/apr-util/dbm/sdbm/sdbm.c deleted file mode 100644 index 537a5b7254..0000000000 --- a/libs/apr-util/dbm/sdbm/sdbm.c +++ /dev/null @@ -1,588 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * sdbm - ndbm work-alike hashed database library - * based on Per-Aake Larson's Dynamic Hashing algorithms. BIT 18 (1978). - * author: oz@nexus.yorku.ca - * ex-public domain, ported to APR for Apache 2 - * core routines - */ - -#include "apr.h" -#include "apr_file_io.h" -#include "apr_strings.h" -#include "apr_errno.h" -#include "apr_sdbm.h" - -#include "sdbm_tune.h" -#include "sdbm_pair.h" -#include "sdbm_private.h" - -#include /* for memset() */ -#include /* for malloc() and free() */ - -/* - * forward - */ -static int getdbit (apr_sdbm_t *, long); -static apr_status_t setdbit(apr_sdbm_t *, long); -static apr_status_t getpage(apr_sdbm_t *db, long); -static apr_status_t getnext(apr_sdbm_datum_t *key, apr_sdbm_t *db); -static apr_status_t makroom(apr_sdbm_t *, long, int); - -/* - * useful macros - */ -#define bad(x) ((x).dptr == NULL || (x).dsize <= 0) -#define exhash(item) sdbm_hash((item).dptr, (item).dsize) - -/* ### Does anything need these externally? */ -#define sdbm_dirfno(db) ((db)->dirf) -#define sdbm_pagfno(db) ((db)->pagf) - -#define OFF_PAG(off) (apr_off_t) (off) * PBLKSIZ -#define OFF_DIR(off) (apr_off_t) (off) * DBLKSIZ - -static long masks[] = { - 000000000000, 000000000001, 000000000003, 000000000007, - 000000000017, 000000000037, 000000000077, 000000000177, - 000000000377, 000000000777, 000000001777, 000000003777, - 000000007777, 000000017777, 000000037777, 000000077777, - 000000177777, 000000377777, 000000777777, 000001777777, - 000003777777, 000007777777, 000017777777, 000037777777, - 000077777777, 000177777777, 000377777777, 000777777777, - 001777777777, 003777777777, 007777777777, 017777777777 -}; - -const apr_sdbm_datum_t sdbm_nullitem = { NULL, 0 }; - -static apr_status_t database_cleanup(void *data) -{ - apr_sdbm_t *db = data; - - /* - * Can't rely on apr_sdbm_unlock, since it will merely - * decrement the refcnt if several locks are held. - */ - if (db->flags & (SDBM_SHARED_LOCK | SDBM_EXCLUSIVE_LOCK)) - (void) apr_file_unlock(db->dirf); - (void) apr_file_close(db->dirf); - (void) apr_file_close(db->pagf); - free(db); - - return APR_SUCCESS; -} - -static apr_status_t prep(apr_sdbm_t **pdb, const char *dirname, const char *pagname, - apr_int32_t flags, apr_fileperms_t perms, apr_pool_t *p) -{ - apr_sdbm_t *db; - apr_status_t status; - - *pdb = NULL; - - db = malloc(sizeof(*db)); - memset(db, 0, sizeof(*db)); - - db->pool = p; - - /* - * adjust user flags so that WRONLY becomes RDWR, - * as required by this package. Also set our internal - * flag for RDONLY if needed. - */ - if (!(flags & APR_WRITE)) { - db->flags |= SDBM_RDONLY; - } - - /* - * adjust the file open flags so that we handle locking - * on our own (don't rely on any locking behavior within - * an apr_file_t, in case it's ever introduced, and set - * our own flag. - */ - if (flags & APR_SHARELOCK) { - db->flags |= SDBM_SHARED; - flags &= ~APR_SHARELOCK; - } - - flags |= APR_BINARY | APR_READ; - - /* - * open the files in sequence, and stat the dirfile. - * If we fail anywhere, undo everything, return NULL. - */ - - if ((status = apr_file_open(&db->dirf, dirname, flags, perms, p)) - != APR_SUCCESS) - goto error; - - if ((status = apr_file_open(&db->pagf, pagname, flags, perms, p)) - != APR_SUCCESS) - goto error; - - if ((status = apr_sdbm_lock(db, (db->flags & SDBM_RDONLY) - ? APR_FLOCK_SHARED - : APR_FLOCK_EXCLUSIVE)) - != APR_SUCCESS) - goto error; - - /* apr_pcalloc zeroed the buffers - * apr_sdbm_lock stated the dirf->size and invalidated the cache - */ - - /* - * if we are opened in SHARED mode, unlock ourself - */ - if (db->flags & SDBM_SHARED) - if ((status = apr_sdbm_unlock(db)) != APR_SUCCESS) - goto error; - - /* make sure that we close the database at some point */ - apr_pool_cleanup_register(p, db, database_cleanup, apr_pool_cleanup_null); - - /* Done! */ - *pdb = db; - return APR_SUCCESS; - -error: - if (db->dirf && db->pagf) - (void) apr_sdbm_unlock(db); - if (db->dirf != NULL) - (void) apr_file_close(db->dirf); - if (db->pagf != NULL) { - (void) apr_file_close(db->pagf); - } - free(db); - return status; -} - -APU_DECLARE(apr_status_t) apr_sdbm_open(apr_sdbm_t **db, const char *file, - apr_int32_t flags, - apr_fileperms_t perms, apr_pool_t *p) -{ - char *dirname = apr_pstrcat(p, file, APR_SDBM_DIRFEXT, NULL); - char *pagname = apr_pstrcat(p, file, APR_SDBM_PAGFEXT, NULL); - - return prep(db, dirname, pagname, flags, perms, p); -} - -APU_DECLARE(apr_status_t) apr_sdbm_close(apr_sdbm_t *db) -{ - return apr_pool_cleanup_run(db->pool, db, database_cleanup); -} - -APU_DECLARE(apr_status_t) apr_sdbm_fetch(apr_sdbm_t *db, apr_sdbm_datum_t *val, - apr_sdbm_datum_t key) -{ - apr_status_t status; - - if (db == NULL || bad(key)) - return APR_EINVAL; - - if ((status = apr_sdbm_lock(db, APR_FLOCK_SHARED)) != APR_SUCCESS) - return status; - - if ((status = getpage(db, exhash(key))) == APR_SUCCESS) { - *val = getpair(db->pagbuf, key); - /* ### do we want a not-found result? */ - } - - (void) apr_sdbm_unlock(db); - - return status; -} - -static apr_status_t write_page(apr_sdbm_t *db, const char *buf, long pagno) -{ - apr_status_t status; - apr_off_t off = OFF_PAG(pagno); - - if ((status = apr_file_seek(db->pagf, APR_SET, &off)) == APR_SUCCESS) - status = apr_file_write_full(db->pagf, buf, PBLKSIZ, NULL); - - return status; -} - -APU_DECLARE(apr_status_t) apr_sdbm_delete(apr_sdbm_t *db, - const apr_sdbm_datum_t key) -{ - apr_status_t status; - - if (db == NULL || bad(key)) - return APR_EINVAL; - if (apr_sdbm_rdonly(db)) - return APR_EINVAL; - - if ((status = apr_sdbm_lock(db, APR_FLOCK_EXCLUSIVE)) != APR_SUCCESS) - return status; - - if ((status = getpage(db, exhash(key))) == APR_SUCCESS) { - if (!delpair(db->pagbuf, key)) - /* ### should we define some APRUTIL codes? */ - status = APR_EGENERAL; - else - status = write_page(db, db->pagbuf, db->pagbno); - } - - (void) apr_sdbm_unlock(db); - - return status; -} - -APU_DECLARE(apr_status_t) apr_sdbm_store(apr_sdbm_t *db, apr_sdbm_datum_t key, - apr_sdbm_datum_t val, int flags) -{ - int need; - register long hash; - apr_status_t status; - - if (db == NULL || bad(key)) - return APR_EINVAL; - if (apr_sdbm_rdonly(db)) - return APR_EINVAL; - need = key.dsize + val.dsize; - /* - * is the pair too big (or too small) for this database ?? - */ - if (need < 0 || need > PAIRMAX) - return APR_EINVAL; - - if ((status = apr_sdbm_lock(db, APR_FLOCK_EXCLUSIVE)) != APR_SUCCESS) - return status; - - if ((status = getpage(db, (hash = exhash(key)))) == APR_SUCCESS) { - - /* - * if we need to replace, delete the key/data pair - * first. If it is not there, ignore. - */ - if (flags == APR_SDBM_REPLACE) - (void) delpair(db->pagbuf, key); - else if (!(flags & APR_SDBM_INSERTDUP) && duppair(db->pagbuf, key)) { - status = APR_EEXIST; - goto error; - } - /* - * if we do not have enough room, we have to split. - */ - if (!fitpair(db->pagbuf, need)) - if ((status = makroom(db, hash, need)) != APR_SUCCESS) - goto error; - /* - * we have enough room or split is successful. insert the key, - * and update the page file. - */ - (void) putpair(db->pagbuf, key, val); - - status = write_page(db, db->pagbuf, db->pagbno); - } - -error: - (void) apr_sdbm_unlock(db); - - return status; -} - -/* - * makroom - make room by splitting the overfull page - * this routine will attempt to make room for SPLTMAX times before - * giving up. - */ -static apr_status_t makroom(apr_sdbm_t *db, long hash, int need) -{ - long newp; - char twin[PBLKSIZ]; - char *pag = db->pagbuf; - char *new = twin; - register int smax = SPLTMAX; - apr_status_t status; - - do { - /* - * split the current page - */ - (void) splpage(pag, new, db->hmask + 1); - /* - * address of the new page - */ - newp = (hash & db->hmask) | (db->hmask + 1); - - /* - * write delay, read avoidence/cache shuffle: - * select the page for incoming pair: if key is to go to the new page, - * write out the previous one, and copy the new one over, thus making - * it the current page. If not, simply write the new page, and we are - * still looking at the page of interest. current page is not updated - * here, as sdbm_store will do so, after it inserts the incoming pair. - */ - if (hash & (db->hmask + 1)) { - if ((status = write_page(db, db->pagbuf, db->pagbno)) - != APR_SUCCESS) - return status; - - db->pagbno = newp; - (void) memcpy(pag, new, PBLKSIZ); - } - else { - if ((status = write_page(db, new, newp)) != APR_SUCCESS) - return status; - } - - if ((status = setdbit(db, db->curbit)) != APR_SUCCESS) - return status; - /* - * see if we have enough room now - */ - if (fitpair(pag, need)) - return APR_SUCCESS; - /* - * try again... update curbit and hmask as getpage would have - * done. because of our update of the current page, we do not - * need to read in anything. BUT we have to write the current - * [deferred] page out, as the window of failure is too great. - */ - db->curbit = 2 * db->curbit - + ((hash & (db->hmask + 1)) ? 2 : 1); - db->hmask |= db->hmask + 1; - - if ((status = write_page(db, db->pagbuf, db->pagbno)) - != APR_SUCCESS) - return status; - - } while (--smax); - - /* - * if we are here, this is real bad news. After SPLTMAX splits, - * we still cannot fit the key. say goodnight. - */ -#if 0 - (void) write(2, "sdbm: cannot insert after SPLTMAX attempts.\n", 44); -#endif - /* ### ENOSPC not really appropriate but better than nothing */ - return APR_ENOSPC; - -} - -/* Reads 'len' bytes from file 'f' at offset 'off' into buf. - * 'off' is given relative to the start of the file. - * If EOF is returned while reading, this is taken as success. - */ -static apr_status_t read_from(apr_file_t *f, void *buf, - apr_off_t off, apr_size_t len) -{ - apr_status_t status; - - if ((status = apr_file_seek(f, APR_SET, &off)) != APR_SUCCESS || - ((status = apr_file_read_full(f, buf, len, NULL)) != APR_SUCCESS)) { - /* if EOF is reached, pretend we read all zero's */ - if (status == APR_EOF) { - memset(buf, 0, len); - status = APR_SUCCESS; - } - } - - return status; -} - -/* - * the following two routines will break if - * deletions aren't taken into account. (ndbm bug) - */ -APU_DECLARE(apr_status_t) apr_sdbm_firstkey(apr_sdbm_t *db, - apr_sdbm_datum_t *key) -{ - apr_status_t status; - - if ((status = apr_sdbm_lock(db, APR_FLOCK_SHARED)) != APR_SUCCESS) - return status; - - /* - * start at page 0 - */ - if ((status = read_from(db->pagf, db->pagbuf, OFF_PAG(0), PBLKSIZ)) - == APR_SUCCESS) { - db->pagbno = 0; - db->blkptr = 0; - db->keyptr = 0; - status = getnext(key, db); - } - - (void) apr_sdbm_unlock(db); - - return status; -} - -APU_DECLARE(apr_status_t) apr_sdbm_nextkey(apr_sdbm_t *db, - apr_sdbm_datum_t *key) -{ - apr_status_t status; - - if ((status = apr_sdbm_lock(db, APR_FLOCK_SHARED)) != APR_SUCCESS) - return status; - - status = getnext(key, db); - - (void) apr_sdbm_unlock(db); - - return status; -} - -/* - * all important binary tree traversal - */ -static apr_status_t getpage(apr_sdbm_t *db, long hash) -{ - register int hbit; - register long dbit; - register long pagb; - apr_status_t status; - - dbit = 0; - hbit = 0; - while (dbit < db->maxbno && getdbit(db, dbit)) - dbit = 2 * dbit + ((hash & (1 << hbit++)) ? 2 : 1); - - debug(("dbit: %d...", dbit)); - - db->curbit = dbit; - db->hmask = masks[hbit]; - - pagb = hash & db->hmask; - /* - * see if the block we need is already in memory. - * note: this lookaside cache has about 10% hit rate. - */ - if (pagb != db->pagbno) { - /* - * note: here, we assume a "hole" is read as 0s. - * if not, must zero pagbuf first. - * ### joe: this assumption was surely never correct? but - * ### we make it so in read_from anyway. - */ - if ((status = read_from(db->pagf, db->pagbuf, OFF_PAG(pagb), PBLKSIZ)) - != APR_SUCCESS) - return status; - - if (!chkpage(db->pagbuf)) - return APR_ENOSPC; /* ### better error? */ - db->pagbno = pagb; - - debug(("pag read: %d\n", pagb)); - } - return APR_SUCCESS; -} - -static int getdbit(apr_sdbm_t *db, long dbit) -{ - register long c; - register long dirb; - - c = dbit / BYTESIZ; - dirb = c / DBLKSIZ; - - if (dirb != db->dirbno) { - if (read_from(db->dirf, db->dirbuf, OFF_DIR(dirb), DBLKSIZ) - != APR_SUCCESS) - return 0; - - db->dirbno = dirb; - - debug(("dir read: %d\n", dirb)); - } - - return db->dirbuf[c % DBLKSIZ] & (1 << dbit % BYTESIZ); -} - -static apr_status_t setdbit(apr_sdbm_t *db, long dbit) -{ - register long c; - register long dirb; - apr_status_t status; - apr_off_t off; - - c = dbit / BYTESIZ; - dirb = c / DBLKSIZ; - - if (dirb != db->dirbno) { - if ((status = read_from(db->dirf, db->dirbuf, OFF_DIR(dirb), DBLKSIZ)) - != APR_SUCCESS) - return status; - - db->dirbno = dirb; - - debug(("dir read: %d\n", dirb)); - } - - db->dirbuf[c % DBLKSIZ] |= (1 << dbit % BYTESIZ); - - if (dbit >= db->maxbno) - db->maxbno += DBLKSIZ * BYTESIZ; - - off = OFF_DIR(dirb); - if ((status = apr_file_seek(db->dirf, APR_SET, &off)) == APR_SUCCESS) - status = apr_file_write_full(db->dirf, db->dirbuf, DBLKSIZ, NULL); - - return status; -} - -/* -* getnext - get the next key in the page, and if done with -* the page, try the next page in sequence -*/ -static apr_status_t getnext(apr_sdbm_datum_t *key, apr_sdbm_t *db) -{ - apr_status_t status; - for (;;) { - db->keyptr++; - *key = getnkey(db->pagbuf, db->keyptr); - if (key->dptr != NULL) - return APR_SUCCESS; - /* - * we either run out, or there is nothing on this page.. - * try the next one... If we lost our position on the - * file, we will have to seek. - */ - db->keyptr = 0; - if (db->pagbno != db->blkptr++) { - apr_off_t off = OFF_PAG(db->blkptr); - if ((status = apr_file_seek(db->pagf, APR_SET, &off) - != APR_SUCCESS)) - return status; - } - - db->pagbno = db->blkptr; - /* ### EOF acceptable here too? */ - if ((status = apr_file_read_full(db->pagf, db->pagbuf, PBLKSIZ, NULL)) - != APR_SUCCESS) - return status; - if (!chkpage(db->pagbuf)) - return APR_EGENERAL; /* ### need better error */ - } - - /* NOTREACHED */ -} - - -APU_DECLARE(int) apr_sdbm_rdonly(apr_sdbm_t *db) -{ - /* ### Should we return true if the first lock is a share lock, - * to reflect that apr_sdbm_store and apr_sdbm_delete will fail? - */ - return (db->flags & SDBM_RDONLY) != 0; -} - diff --git a/libs/apr-util/dbm/sdbm/sdbm_hash.c b/libs/apr-util/dbm/sdbm/sdbm_hash.c deleted file mode 100644 index 012e3d0750..0000000000 --- a/libs/apr-util/dbm/sdbm/sdbm_hash.c +++ /dev/null @@ -1,63 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * sdbm - ndbm work-alike hashed database library - * based on Per-Aake Larson's Dynamic Hashing algorithms. BIT 18 (1978). - * author: oz@nexus.yorku.ca - * status: ex-public domain. keep it that way. - * - * hashing routine - */ - -#include "apr_sdbm.h" -#include "sdbm_private.h" - -/* - * polynomial conversion ignoring overflows - * [this seems to work remarkably well, in fact better - * then the ndbm hash function. Replace at your own risk] - * use: 65599 nice. - * 65587 even better. - */ -long sdbm_hash(const char *str, int len) -{ - register unsigned long n = 0; - -#define DUFF /* go ahead and use the loop-unrolled version */ -#ifdef DUFF - -#define HASHC n = *str++ + 65599 * n - - if (len > 0) { - register int loop = (len + 8 - 1) >> 3; - - switch(len & (8 - 1)) { - case 0: do { - HASHC; case 7: HASHC; - case 6: HASHC; case 5: HASHC; - case 4: HASHC; case 3: HASHC; - case 2: HASHC; case 1: HASHC; - } while (--loop); - } - - } -#else - while (len--) - n = *str++ + 65599 * n; -#endif - return n; -} diff --git a/libs/apr-util/dbm/sdbm/sdbm_lock.c b/libs/apr-util/dbm/sdbm/sdbm_lock.c deleted file mode 100644 index a001ed413b..0000000000 --- a/libs/apr-util/dbm/sdbm/sdbm_lock.c +++ /dev/null @@ -1,78 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_file_info.h" -#include "apr_file_io.h" -#include "apr_sdbm.h" - -#include "sdbm_private.h" -#include "sdbm_tune.h" - -/* NOTE: this function blocks until it acquires the lock */ -APU_DECLARE(apr_status_t) apr_sdbm_lock(apr_sdbm_t *db, int type) -{ - apr_status_t status; - - if (!(type == APR_FLOCK_SHARED || type == APR_FLOCK_EXCLUSIVE)) - return APR_EINVAL; - - if (db->flags & SDBM_EXCLUSIVE_LOCK) { - ++db->lckcnt; - return APR_SUCCESS; - } - else if (db->flags & SDBM_SHARED_LOCK) { - /* - * Cannot promote a shared lock to an exlusive lock - * in a cross-platform compatibile manner. - */ - if (type == APR_FLOCK_EXCLUSIVE) - return APR_EINVAL; - ++db->lckcnt; - return APR_SUCCESS; - } - /* - * zero size: either a fresh database, or one with a single, - * unsplit data page: dirpage is all zeros. - */ - if ((status = apr_file_lock(db->dirf, type)) == APR_SUCCESS) - { - apr_finfo_t finfo; - if ((status = apr_file_info_get(&finfo, APR_FINFO_SIZE, db->dirf)) - != APR_SUCCESS) { - (void) apr_file_unlock(db->dirf); - return status; - } - - SDBM_INVALIDATE_CACHE(db, finfo); - - ++db->lckcnt; - if (type == APR_FLOCK_SHARED) - db->flags |= SDBM_SHARED_LOCK; - else if (type == APR_FLOCK_EXCLUSIVE) - db->flags |= SDBM_EXCLUSIVE_LOCK; - } - return status; -} - -APU_DECLARE(apr_status_t) apr_sdbm_unlock(apr_sdbm_t *db) -{ - if (!(db->flags & (SDBM_SHARED_LOCK | SDBM_EXCLUSIVE_LOCK))) - return APR_EINVAL; - if (--db->lckcnt > 0) - return APR_SUCCESS; - db->flags &= ~(SDBM_SHARED_LOCK | SDBM_EXCLUSIVE_LOCK); - return apr_file_unlock(db->dirf); -} diff --git a/libs/apr-util/dbm/sdbm/sdbm_pair.c b/libs/apr-util/dbm/sdbm/sdbm_pair.c deleted file mode 100644 index 3fe82b6664..0000000000 --- a/libs/apr-util/dbm/sdbm/sdbm_pair.c +++ /dev/null @@ -1,319 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * sdbm - ndbm work-alike hashed database library - * based on Per-Aake Larson's Dynamic Hashing algorithms. BIT 18 (1978). - * author: oz@nexus.yorku.ca - * status: ex-public domain. - * - * page-level routines - */ - -#include "apr_sdbm.h" - -#include "sdbm_tune.h" -#include "sdbm_pair.h" -#include "sdbm_private.h" - -#include /* for memset() */ - - -#define exhash(item) sdbm_hash((item).dptr, (item).dsize) - -/* - * forward - */ -static int seepair(char *, int, char *, int); - -/* - * page format: - * +------------------------------+ - * ino | n | keyoff | datoff | keyoff | - * +------------+--------+--------+ - * | datoff | - - - ----> | - * +--------+---------------------+ - * | F R E E A R E A | - * +--------------+---------------+ - * | <---- - - - | data | - * +--------+-----+----+----------+ - * | key | data | key | - * +--------+----------+----------+ - * - * calculating the offsets for free area: if the number - * of entries (ino[0]) is zero, the offset to the END of - * the free area is the block size. Otherwise, it is the - * nth (ino[ino[0]]) entry's offset. - */ - -int -fitpair(pag, need) -char *pag; -int need; -{ - register int n; - register int off; - register int avail; - register short *ino = (short *) pag; - - off = ((n = ino[0]) > 0) ? ino[n] : PBLKSIZ; - avail = off - (n + 1) * sizeof(short); - need += 2 * sizeof(short); - - debug(("avail %d need %d\n", avail, need)); - - return need <= avail; -} - -void -putpair(pag, key, val) -char *pag; -apr_sdbm_datum_t key; -apr_sdbm_datum_t val; -{ - register int n; - register int off; - register short *ino = (short *) pag; - - off = ((n = ino[0]) > 0) ? ino[n] : PBLKSIZ; -/* - * enter the key first - */ - off -= key.dsize; - (void) memcpy(pag + off, key.dptr, key.dsize); - ino[n + 1] = off; -/* - * now the data - */ - off -= val.dsize; - (void) memcpy(pag + off, val.dptr, val.dsize); - ino[n + 2] = off; -/* - * adjust item count - */ - ino[0] += 2; -} - -apr_sdbm_datum_t -getpair(pag, key) -char *pag; -apr_sdbm_datum_t key; -{ - register int i; - register int n; - apr_sdbm_datum_t val; - register short *ino = (short *) pag; - - if ((n = ino[0]) == 0) - return sdbm_nullitem; - - if ((i = seepair(pag, n, key.dptr, key.dsize)) == 0) - return sdbm_nullitem; - - val.dptr = pag + ino[i + 1]; - val.dsize = ino[i] - ino[i + 1]; - return val; -} - -int -duppair(pag, key) -char *pag; -apr_sdbm_datum_t key; -{ - register short *ino = (short *) pag; - return ino[0] > 0 && seepair(pag, ino[0], key.dptr, key.dsize) > 0; -} - -apr_sdbm_datum_t -getnkey(pag, num) -char *pag; -int num; -{ - apr_sdbm_datum_t key; - register int off; - register short *ino = (short *) pag; - - num = num * 2 - 1; - if (ino[0] == 0 || num > ino[0]) - return sdbm_nullitem; - - off = (num > 1) ? ino[num - 1] : PBLKSIZ; - - key.dptr = pag + ino[num]; - key.dsize = off - ino[num]; - - return key; -} - -int -delpair(pag, key) -char *pag; -apr_sdbm_datum_t key; -{ - register int n; - register int i; - register short *ino = (short *) pag; - - if ((n = ino[0]) == 0) - return 0; - - if ((i = seepair(pag, n, key.dptr, key.dsize)) == 0) - return 0; -/* - * found the key. if it is the last entry - * [i.e. i == n - 1] we just adjust the entry count. - * hard case: move all data down onto the deleted pair, - * shift offsets onto deleted offsets, and adjust them. - * [note: 0 < i < n] - */ - if (i < n - 1) { - register int m; - register char *dst = pag + (i == 1 ? PBLKSIZ : ino[i - 1]); - register char *src = pag + ino[i + 1]; - register int zoo = dst - src; - - debug(("free-up %d ", zoo)); -/* - * shift data/keys down - */ - m = ino[i + 1] - ino[n]; - -#undef DUFF /* just use memmove. it should be plenty fast. */ -#ifdef DUFF -#define MOVB *--dst = *--src - - if (m > 0) { - register int loop = (m + 8 - 1) >> 3; - - switch (m & (8 - 1)) { - case 0: do { - MOVB; case 7: MOVB; - case 6: MOVB; case 5: MOVB; - case 4: MOVB; case 3: MOVB; - case 2: MOVB; case 1: MOVB; - } while (--loop); - } - } -#else - dst -= m; - src -= m; - memmove(dst, src, m); -#endif - -/* - * adjust offset index up - */ - while (i < n - 1) { - ino[i] = ino[i + 2] + zoo; - i++; - } - } - ino[0] -= 2; - return 1; -} - -/* - * search for the key in the page. - * return offset index in the range 0 < i < n. - * return 0 if not found. - */ -static int -seepair(pag, n, key, siz) -char *pag; -register int n; -register char *key; -register int siz; -{ - register int i; - register int off = PBLKSIZ; - register short *ino = (short *) pag; - - for (i = 1; i < n; i += 2) { - if (siz == off - ino[i] && - memcmp(key, pag + ino[i], siz) == 0) - return i; - off = ino[i + 1]; - } - return 0; -} - -void -splpage(pag, new, sbit) -char *pag; -char *new; -long sbit; -{ - apr_sdbm_datum_t key; - apr_sdbm_datum_t val; - - register int n; - register int off = PBLKSIZ; - char cur[PBLKSIZ]; - register short *ino = (short *) cur; - - (void) memcpy(cur, pag, PBLKSIZ); - (void) memset(pag, 0, PBLKSIZ); - (void) memset(new, 0, PBLKSIZ); - - n = ino[0]; - for (ino++; n > 0; ino += 2) { - key.dptr = cur + ino[0]; - key.dsize = off - ino[0]; - val.dptr = cur + ino[1]; - val.dsize = ino[0] - ino[1]; -/* - * select the page pointer (by looking at sbit) and insert - */ - (void) putpair((exhash(key) & sbit) ? new : pag, key, val); - - off = ino[1]; - n -= 2; - } - - debug(("%d split %d/%d\n", ((short *) cur)[0] / 2, - ((short *) new)[0] / 2, - ((short *) pag)[0] / 2)); -} - -/* - * check page sanity: - * number of entries should be something - * reasonable, and all offsets in the index should be in order. - * this could be made more rigorous. - */ -int -chkpage(pag) -char *pag; -{ - register int n; - register int off; - register short *ino = (short *) pag; - - if ((n = ino[0]) < 0 || n > PBLKSIZ / sizeof(short)) - return 0; - - if (n > 0) { - off = PBLKSIZ; - for (ino++; n > 0; ino += 2) { - if (ino[0] > off || ino[1] > off || - ino[1] > ino[0]) - return 0; - off = ino[1]; - n -= 2; - } - } - return 1; -} diff --git a/libs/apr-util/dbm/sdbm/sdbm_pair.h b/libs/apr-util/dbm/sdbm/sdbm_pair.h deleted file mode 100644 index 51d1065871..0000000000 --- a/libs/apr-util/dbm/sdbm/sdbm_pair.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef SDBM_PAIR_H -#define SDBM_PAIR_H - -/* Mini EMBED (pair.c) */ -#define chkpage apu__sdbm_chkpage -#define delpair apu__sdbm_delpair -#define duppair apu__sdbm_duppair -#define fitpair apu__sdbm_fitpair -#define getnkey apu__sdbm_getnkey -#define getpair apu__sdbm_getpair -#define putpair apu__sdbm_putpair -#define splpage apu__sdbm_splpage - -int fitpair(char *, int); -void putpair(char *, apr_sdbm_datum_t, apr_sdbm_datum_t); -apr_sdbm_datum_t getpair(char *, apr_sdbm_datum_t); -int delpair(char *, apr_sdbm_datum_t); -int chkpage (char *); -apr_sdbm_datum_t getnkey(char *, int); -void splpage(char *, char *, long); -int duppair(char *, apr_sdbm_datum_t); - -#endif /* SDBM_PAIR_H */ - diff --git a/libs/apr-util/dbm/sdbm/sdbm_private.h b/libs/apr-util/dbm/sdbm/sdbm_private.h deleted file mode 100644 index a1ad29d471..0000000000 --- a/libs/apr-util/dbm/sdbm/sdbm_private.h +++ /dev/null @@ -1,84 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * sdbm - ndbm work-alike hashed database library - * based on Per-Ake Larson's Dynamic Hashing algorithms. BIT 18 (1978). - * author: oz@nexus.yorku.ca - */ - -#ifndef SDBM_PRIVATE_H -#define SDBM_PRIVATE_H - -#include "apr.h" -#include "apr_pools.h" -#include "apr_file_io.h" -#include "apr_errno.h" /* for apr_status_t */ - -#if 0 -/* if the block/page size is increased, it breaks perl apr_sdbm_t compatibility */ -#define DBLKSIZ 16384 -#define PBLKSIZ 8192 -#define PAIRMAX 8008 /* arbitrary on PBLKSIZ-N */ -#else -#define DBLKSIZ 4096 -#define PBLKSIZ 1024 -#define PAIRMAX 1008 /* arbitrary on PBLKSIZ-N */ -#endif -#define SPLTMAX 10 /* maximum allowed splits */ - -/* for apr_sdbm_t.flags */ -#define SDBM_RDONLY 0x1 /* data base open read-only */ -#define SDBM_SHARED 0x2 /* data base open for sharing */ -#define SDBM_SHARED_LOCK 0x4 /* data base locked for shared read */ -#define SDBM_EXCLUSIVE_LOCK 0x8 /* data base locked for write */ - -struct apr_sdbm_t { - apr_pool_t *pool; - apr_file_t *dirf; /* directory file descriptor */ - apr_file_t *pagf; /* page file descriptor */ - apr_int32_t flags; /* status/error flags, see below */ - long maxbno; /* size of dirfile in bits */ - long curbit; /* current bit number */ - long hmask; /* current hash mask */ - long blkptr; /* current block for nextkey */ - int keyptr; /* current key for nextkey */ - long blkno; /* current page to read/write */ - long pagbno; /* current page in pagbuf */ - char pagbuf[PBLKSIZ]; /* page file block buffer */ - long dirbno; /* current block in dirbuf */ - char dirbuf[DBLKSIZ]; /* directory file block buffer */ - int lckcnt; /* number of calls to sdbm_lock */ -}; - - -#define sdbm_hash apu__sdbm_hash -#define sdbm_nullitem apu__sdbm_nullitem - -extern const apr_sdbm_datum_t sdbm_nullitem; - -long sdbm_hash(const char *str, int len); - -/* - * zero the cache - */ -#define SDBM_INVALIDATE_CACHE(db, finfo) \ - do { db->dirbno = (!finfo.size) ? 0 : -1; \ - db->pagbno = -1; \ - db->maxbno = (long)(finfo.size * BYTESIZ); \ - } while (0); - -#endif /* SDBM_PRIVATE_H */ diff --git a/libs/apr-util/dbm/sdbm/sdbm_tune.h b/libs/apr-util/dbm/sdbm/sdbm_tune.h deleted file mode 100644 index 92ed6a253c..0000000000 --- a/libs/apr-util/dbm/sdbm/sdbm_tune.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * sdbm - ndbm work-alike hashed database library - * tuning and portability constructs [not nearly enough] - * author: oz@nexus.yorku.ca - */ - -#ifndef SDBM_TUNE_H -#define SDBM_TUNE_H - -#include "apr_errno.h" - -/* ### this might be better off as sizeof(char *) */ -#define BYTESIZ 8 - -/* - * misc - */ -#ifdef DEBUG -#define debug(x) printf x -#else -#define debug(x) -#endif - -#endif /* SDBM_TUNE_H */ diff --git a/libs/apr-util/docs/doxygen.conf b/libs/apr-util/docs/doxygen.conf deleted file mode 100644 index dc49609dad..0000000000 --- a/libs/apr-util/docs/doxygen.conf +++ /dev/null @@ -1,30 +0,0 @@ -PROJECT_NAME="Apache Portable Runtime Utility Library" - -INPUT=. -QUIET=YES -RECURSIVE=YES -FILE_PATTERNS=*.h - -OUTPUT_DIRECTORY=docs/dox - -MACRO_EXPANSION=YES -EXPAND_ONLY_PREDEF=YES -#EXPAND_AS_DEFINED= -# not sure why this doesn't work as EXPAND_AS_DEFINED, it should! -PREDEFINED="APU_DECLARE(x)=x" \ - "APU_DECLARE_NONSTD(x)=x" \ - "APU_DECLARE_DATA" \ - "APR_HAS_MMAP" \ - "APR_HAS_THREADS" \ - "APR_HAS_XLATE" \ - "__attribute__(x)=" \ - DOXYGEN= - -OPTIMIZE_OUTPUT_FOR_C=YES - -FULL_PATH_NAMES=YES -CASE_SENSE_NAMES=NO -# some autoconf guru needs to make configure set this correctly... -#STRIP_FROM_PATH=/root/apache/httpd-2.0-8/srclib/apr-util - -GENERATE_TAGFILE=docs/dox/apu.tag diff --git a/libs/apr-util/encoding/apr_base64.c b/libs/apr-util/encoding/apr_base64.c deleted file mode 100644 index 4a1f49c568..0000000000 --- a/libs/apr-util/encoding/apr_base64.c +++ /dev/null @@ -1,268 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* base64 encoder/decoder. Originally part of main/util.c - * but moved here so that support/ab and apr_sha1.c could - * use it. This meant removing the apr_palloc()s and adding - * ugly 'len' functions, which is quite a nasty cost. - */ - -#include "apr_base64.h" -#if APR_CHARSET_EBCDIC -#include "apr_xlate.h" -#endif /* APR_CHARSET_EBCDIC */ - -/* aaaack but it's fast and const should make it shared text page. */ -static const unsigned char pr2six[256] = -{ -#if !APR_CHARSET_EBCDIC - /* ASCII table */ - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 64, 64, 64, 63, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 64, 64, 64, 64, 64, - 64, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 64, 64, 64, 64, 64, - 64, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 -#else /*APR_CHARSET_EBCDIC*/ - /* EBCDIC table */ - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 26, 27, 28, 29, 30, 31, 32, 33, 34, 64, 64, 64, 64, 64, 64, - 64, 35, 36, 37, 38, 39, 40, 41, 42, 43, 64, 64, 64, 64, 64, 64, - 64, 64, 44, 45, 46, 47, 48, 49, 50, 51, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 0, 1, 2, 3, 4, 5, 6, 7, 8, 64, 64, 64, 64, 64, 64, - 64, 9, 10, 11, 12, 13, 14, 15, 16, 17, 64, 64, 64, 64, 64, 64, - 64, 64, 18, 19, 20, 21, 22, 23, 24, 25, 64, 64, 64, 64, 64, 64, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 64, 64, 64, 64, 64 -#endif /*APR_CHARSET_EBCDIC*/ -}; - -#if APR_CHARSET_EBCDIC -static apr_xlate_t *xlate_to_ebcdic; -static unsigned char os_toascii[256]; - -APU_DECLARE(apr_status_t) apr_base64init_ebcdic(apr_xlate_t *to_ascii, - apr_xlate_t *to_ebcdic) -{ - int i; - apr_size_t inbytes_left, outbytes_left; - apr_status_t rv; - int onoff; - - /* Only single-byte conversion is supported. - */ - rv = apr_xlate_sb_get(to_ascii, &onoff); - if (rv) { - return rv; - } - if (!onoff) { /* If conversion is not single-byte-only */ - return APR_EINVAL; - } - rv = apr_xlate_sb_get(to_ebcdic, &onoff); - if (rv) { - return rv; - } - if (!onoff) { /* If conversion is not single-byte-only */ - return APR_EINVAL; - } - xlate_to_ebcdic = to_ebcdic; - for (i = 0; i < sizeof(os_toascii); i++) { - os_toascii[i] = i; - } - inbytes_left = outbytes_left = sizeof(os_toascii); - apr_xlate_conv_buffer(to_ascii, os_toascii, &inbytes_left, - os_toascii, &outbytes_left); - - return APR_SUCCESS; -} -#endif /*APR_CHARSET_EBCDIC*/ - -APU_DECLARE(int) apr_base64_decode_len(const char *bufcoded) -{ - int nbytesdecoded; - register const unsigned char *bufin; - register int nprbytes; - - bufin = (const unsigned char *) bufcoded; - while (pr2six[*(bufin++)] <= 63); - - nprbytes = (bufin - (const unsigned char *) bufcoded) - 1; - nbytesdecoded = ((nprbytes + 3) / 4) * 3; - - return nbytesdecoded + 1; -} - -APU_DECLARE(int) apr_base64_decode(char *bufplain, const char *bufcoded) -{ -#if APR_CHARSET_EBCDIC - apr_size_t inbytes_left, outbytes_left; -#endif /* APR_CHARSET_EBCDIC */ - int len; - - len = apr_base64_decode_binary((unsigned char *) bufplain, bufcoded); -#if APR_CHARSET_EBCDIC - inbytes_left = outbytes_left = len; - apr_xlate_conv_buffer(xlate_to_ebcdic, bufplain, &inbytes_left, - bufplain, &outbytes_left); -#endif /* APR_CHARSET_EBCDIC */ - bufplain[len] = '\0'; - return len; -} - -/* This is the same as apr_base64_decode() except on EBCDIC machines, where - * the conversion of the output to ebcdic is left out. - */ -APU_DECLARE(int) apr_base64_decode_binary(unsigned char *bufplain, - const char *bufcoded) -{ - int nbytesdecoded; - register const unsigned char *bufin; - register unsigned char *bufout; - register int nprbytes; - - bufin = (const unsigned char *) bufcoded; - while (pr2six[*(bufin++)] <= 63); - nprbytes = (bufin - (const unsigned char *) bufcoded) - 1; - nbytesdecoded = ((nprbytes + 3) / 4) * 3; - - bufout = (unsigned char *) bufplain; - bufin = (const unsigned char *) bufcoded; - - while (nprbytes > 4) { - *(bufout++) = - (unsigned char) (pr2six[*bufin] << 2 | pr2six[bufin[1]] >> 4); - *(bufout++) = - (unsigned char) (pr2six[bufin[1]] << 4 | pr2six[bufin[2]] >> 2); - *(bufout++) = - (unsigned char) (pr2six[bufin[2]] << 6 | pr2six[bufin[3]]); - bufin += 4; - nprbytes -= 4; - } - - /* Note: (nprbytes == 1) would be an error, so just ingore that case */ - if (nprbytes > 1) { - *(bufout++) = - (unsigned char) (pr2six[*bufin] << 2 | pr2six[bufin[1]] >> 4); - } - if (nprbytes > 2) { - *(bufout++) = - (unsigned char) (pr2six[bufin[1]] << 4 | pr2six[bufin[2]] >> 2); - } - if (nprbytes > 3) { - *(bufout++) = - (unsigned char) (pr2six[bufin[2]] << 6 | pr2six[bufin[3]]); - } - - nbytesdecoded -= (4 - nprbytes) & 3; - return nbytesdecoded; -} - -static const char basis_64[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - -APU_DECLARE(int) apr_base64_encode_len(int len) -{ - return ((len + 2) / 3 * 4) + 1; -} - -APU_DECLARE(int) apr_base64_encode(char *encoded, const char *string, int len) -{ -#if !APR_CHARSET_EBCDIC - return apr_base64_encode_binary(encoded, (const unsigned char *) string, len); -#else /* APR_CHARSET_EBCDIC */ - int i; - char *p; - - p = encoded; - for (i = 0; i < len - 2; i += 3) { - *p++ = basis_64[(os_toascii[string[i]] >> 2) & 0x3F]; - *p++ = basis_64[((os_toascii[string[i]] & 0x3) << 4) | - ((int) (os_toascii[string[i + 1]] & 0xF0) >> 4)]; - *p++ = basis_64[((os_toascii[string[i + 1]] & 0xF) << 2) | - ((int) (os_toascii[string[i + 2]] & 0xC0) >> 6)]; - *p++ = basis_64[os_toascii[string[i + 2]] & 0x3F]; - } - if (i < len) { - *p++ = basis_64[(os_toascii[string[i]] >> 2) & 0x3F]; - if (i == (len - 1)) { - *p++ = basis_64[((os_toascii[string[i]] & 0x3) << 4)]; - *p++ = '='; - } - else { - *p++ = basis_64[((os_toascii[string[i]] & 0x3) << 4) | - ((int) (os_toascii[string[i + 1]] & 0xF0) >> 4)]; - *p++ = basis_64[((os_toascii[string[i + 1]] & 0xF) << 2)]; - } - *p++ = '='; - } - - *p++ = '\0'; - return p - encoded; -#endif /* APR_CHARSET_EBCDIC */ -} - -/* This is the same as apr_base64_encode() except on EBCDIC machines, where - * the conversion of the input to ascii is left out. - */ -APU_DECLARE(int) apr_base64_encode_binary(char *encoded, - const unsigned char *string, int len) -{ - int i; - char *p; - - p = encoded; - for (i = 0; i < len - 2; i += 3) { - *p++ = basis_64[(string[i] >> 2) & 0x3F]; - *p++ = basis_64[((string[i] & 0x3) << 4) | - ((int) (string[i + 1] & 0xF0) >> 4)]; - *p++ = basis_64[((string[i + 1] & 0xF) << 2) | - ((int) (string[i + 2] & 0xC0) >> 6)]; - *p++ = basis_64[string[i + 2] & 0x3F]; - } - if (i < len) { - *p++ = basis_64[(string[i] >> 2) & 0x3F]; - if (i == (len - 1)) { - *p++ = basis_64[((string[i] & 0x3) << 4)]; - *p++ = '='; - } - else { - *p++ = basis_64[((string[i] & 0x3) << 4) | - ((int) (string[i + 1] & 0xF0) >> 4)]; - *p++ = basis_64[((string[i + 1] & 0xF) << 2)]; - } - *p++ = '='; - } - - *p++ = '\0'; - return p - encoded; -} diff --git a/libs/apr-util/export_vars.sh.in b/libs/apr-util/export_vars.sh.in deleted file mode 100644 index 96a9352631..0000000000 --- a/libs/apr-util/export_vars.sh.in +++ /dev/null @@ -1,13 +0,0 @@ -# -# export_vars.sh -# -# This shell script is used to export vars to the application using the -# APRUTIL library. This script should be "sourced" to ensure the variable -# values are set within the calling script's context. For example: -# -# $ . path/to/apr-util/export_vars.sh -# - -APRUTIL_EXPORT_INCLUDES="@APRUTIL_INCLUDES@" -APRUTIL_EXPORT_LIBS="@APRUTIL_EXPORT_LIBS@" -APRUTIL_LDFLAGS="@APRUTIL_LDFLAGS@" diff --git a/libs/apr-util/hooks/apr_hooks.c b/libs/apr-util/hooks/apr_hooks.c deleted file mode 100644 index 776bc884e7..0000000000 --- a/libs/apr-util/hooks/apr_hooks.c +++ /dev/null @@ -1,404 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include - -#include "apr_pools.h" -#include "apr_tables.h" -#include "apr.h" -#include "apr_hooks.h" -#include "apr_hash.h" -#include "apr_optional_hooks.h" -#include "apr_optional.h" -#define APR_WANT_MEMFUNC -#define APR_WANT_STRFUNC -#include "apr_want.h" - -#if 0 -#define apr_palloc(pool,size) malloc(size) -#endif - -APU_DECLARE_DATA apr_pool_t *apr_hook_global_pool = NULL; -APU_DECLARE_DATA int apr_hook_debug_enabled = 0; -APU_DECLARE_DATA const char *apr_hook_debug_current = NULL; - -/** @deprecated @see apr_hook_global_pool */ -APU_DECLARE_DATA apr_pool_t *apr_global_hook_pool = NULL; - -/** @deprecated @see apr_hook_debug_enabled */ -APU_DECLARE_DATA int apr_debug_module_hooks = 0; - -/** @deprecated @see apr_hook_debug_current */ -APU_DECLARE_DATA const char *apr_current_hooking_module = NULL; - -/* NB: This must echo the LINK_##name structure */ -typedef struct -{ - void (*dummy)(void *); - const char *szName; - const char * const *aszPredecessors; - const char * const *aszSuccessors; - int nOrder; -} TSortData; - -typedef struct tsort_ -{ - void *pData; - int nPredecessors; - struct tsort_ **ppPredecessors; - struct tsort_ *pNext; -} TSort; - -#ifdef NETWARE -#include "apr_private.h" -#define get_apd APP_DATA* apd = (APP_DATA*)get_app_data(gLibId); -#define s_aHooksToSort ((apr_array_header_t *)(apd->gs_aHooksToSort)) -#define s_phOptionalHooks ((apr_hash_t *)(apd->gs_phOptionalHooks)) -#define s_phOptionalFunctions ((apr_hash_t *)(apd->gs_phOptionalFunctions)) -#endif - -static int crude_order(const void *a_,const void *b_) -{ - const TSortData *a=a_; - const TSortData *b=b_; - - return a->nOrder-b->nOrder; -} - -static TSort *prepare(apr_pool_t *p,TSortData *pItems,int nItems) -{ - TSort *pData=apr_palloc(p,nItems*sizeof *pData); - int n; - - qsort(pItems,nItems,sizeof *pItems,crude_order); - for(n=0 ; n < nItems ; ++n) { - pData[n].nPredecessors=0; - pData[n].ppPredecessors=apr_pcalloc(p,nItems*sizeof *pData[n].ppPredecessors); - pData[n].pNext=NULL; - pData[n].pData=&pItems[n]; - } - - for(n=0 ; n < nItems ; ++n) { - int i,k; - - for(i=0 ; pItems[n].aszPredecessors && pItems[n].aszPredecessors[i] ; ++i) - for(k=0 ; k < nItems ; ++k) - if(!strcmp(pItems[k].szName,pItems[n].aszPredecessors[i])) { - int l; - - for(l=0 ; l < pData[n].nPredecessors ; ++l) - if(pData[n].ppPredecessors[l] == &pData[k]) - goto got_it; - pData[n].ppPredecessors[pData[n].nPredecessors]=&pData[k]; - ++pData[n].nPredecessors; - got_it: - break; - } - for(i=0 ; pItems[n].aszSuccessors && pItems[n].aszSuccessors[i] ; ++i) - for(k=0 ; k < nItems ; ++k) - if(!strcmp(pItems[k].szName,pItems[n].aszSuccessors[i])) { - int l; - - for(l=0 ; l < pData[k].nPredecessors ; ++l) - if(pData[k].ppPredecessors[l] == &pData[n]) - goto got_it2; - pData[k].ppPredecessors[pData[k].nPredecessors]=&pData[n]; - ++pData[k].nPredecessors; - got_it2: - break; - } - } - - return pData; -} - -/* Topologically sort, dragging out-of-order items to the front. Note that - this tends to preserve things that want to be near the front better, and - changing that behaviour might compromise some of Apache's behaviour (in - particular, mod_log_forensic might otherwise get pushed to the end, and - core.c's log open function used to end up at the end when pushing items - to the back was the methedology). Also note that the algorithm could - go back to its original simplicity by sorting from the back instead of - the front. -*/ -static TSort *tsort(TSort *pData,int nItems) -{ - int nTotal; - TSort *pHead=NULL; - TSort *pTail=NULL; - - for(nTotal=0 ; nTotal < nItems ; ++nTotal) { - int n,i,k; - - for(n=0 ; ; ++n) { - if(n == nItems) - assert(0); /* we have a loop... */ - if(!pData[n].pNext) { - if(pData[n].nPredecessors) { - for(k=0 ; ; ++k) { - assert(k < nItems); - if(pData[n].ppPredecessors[k]) - break; - } - for(i=0 ; ; ++i) { - assert(i < nItems); - if(&pData[i] == pData[n].ppPredecessors[k]) { - n=i-1; - break; - } - } - } else - break; - } - } - if(pTail) - pTail->pNext=&pData[n]; - else - pHead=&pData[n]; - pTail=&pData[n]; - pTail->pNext=pTail; /* fudge it so it looks linked */ - for(i=0 ; i < nItems ; ++i) - for(k=0 ; k < nItems ; ++k) - if(pData[i].ppPredecessors[k] == &pData[n]) { - --pData[i].nPredecessors; - pData[i].ppPredecessors[k]=NULL; - break; - } - } - if (pTail) { - pTail->pNext = NULL; /* unfudge the tail */ - } - return pHead; -} - -static apr_array_header_t *sort_hook(apr_array_header_t *pHooks, - const char *szName) -{ - apr_pool_t *p; - TSort *pSort; - apr_array_header_t *pNew; - int n; - - apr_pool_create(&p, apr_hook_global_pool); - pSort=prepare(p,(TSortData *)pHooks->elts,pHooks->nelts); - pSort=tsort(pSort,pHooks->nelts); - pNew=apr_array_make(apr_hook_global_pool,pHooks->nelts,sizeof(TSortData)); - if(apr_hook_debug_enabled) - printf("Sorting %s:",szName); - for(n=0 ; pSort ; pSort=pSort->pNext,++n) { - TSortData *pHook; - assert(n < pHooks->nelts); - pHook=apr_array_push(pNew); - memcpy(pHook,pSort->pData,sizeof *pHook); - if(apr_hook_debug_enabled) - printf(" %s",pHook->szName); - } - if(apr_hook_debug_enabled) - fputc('\n',stdout); - return pNew; -} - -#ifndef NETWARE -static apr_array_header_t *s_aHooksToSort; -#endif - -typedef struct -{ - const char *szHookName; - apr_array_header_t **paHooks; -} HookSortEntry; - -APU_DECLARE(void) apr_hook_sort_register(const char *szHookName, - apr_array_header_t **paHooks) -{ -#ifdef NETWARE - get_apd -#endif - HookSortEntry *pEntry; - - if(!s_aHooksToSort) - s_aHooksToSort=apr_array_make(apr_hook_global_pool,1,sizeof(HookSortEntry)); - pEntry=apr_array_push(s_aHooksToSort); - pEntry->szHookName=szHookName; - pEntry->paHooks=paHooks; -} - -APU_DECLARE(void) apr_hook_sort_all(void) -{ -#ifdef NETWARE - get_apd -#endif - int n; - - for(n=0 ; n < s_aHooksToSort->nelts ; ++n) { - HookSortEntry *pEntry=&((HookSortEntry *)s_aHooksToSort->elts)[n]; - *pEntry->paHooks=sort_hook(*pEntry->paHooks,pEntry->szHookName); - } -} - -#ifndef NETWARE -static apr_hash_t *s_phOptionalHooks; -static apr_hash_t *s_phOptionalFunctions; -#endif - -APU_DECLARE(void) apr_hook_deregister_all(void) -{ -#ifdef NETWARE - get_apd -#endif - int n; - - for(n=0 ; n < s_aHooksToSort->nelts ; ++n) { - HookSortEntry *pEntry=&((HookSortEntry *)s_aHooksToSort->elts)[n]; - *pEntry->paHooks=NULL; - } - s_aHooksToSort=NULL; - s_phOptionalHooks=NULL; - s_phOptionalFunctions=NULL; -} - -APU_DECLARE(void) apr_hook_debug_show(const char *szName, - const char * const *aszPre, - const char * const *aszSucc) -{ - int nFirst; - - printf(" Hooked %s",szName); - if(aszPre) { - fputs(" pre(",stdout); - nFirst=1; - while(*aszPre) { - if(!nFirst) - fputc(',',stdout); - nFirst=0; - fputs(*aszPre,stdout); - ++aszPre; - } - fputc(')',stdout); - } - if(aszSucc) { - fputs(" succ(",stdout); - nFirst=1; - while(*aszSucc) { - if(!nFirst) - fputc(',',stdout); - nFirst=0; - fputs(*aszSucc,stdout); - ++aszSucc; - } - fputc(')',stdout); - } - fputc('\n',stdout); -} - -/* Optional hook support */ - -APR_DECLARE_EXTERNAL_HOOK(apr,APU,void,_optional,(void)) - -APU_DECLARE(apr_array_header_t *) apr_optional_hook_get(const char *szName) -{ -#ifdef NETWARE - get_apd -#endif - apr_array_header_t **ppArray; - - if(!s_phOptionalHooks) - return NULL; - ppArray=apr_hash_get(s_phOptionalHooks,szName,strlen(szName)); - if(!ppArray) - return NULL; - return *ppArray; -} - -APU_DECLARE(void) apr_optional_hook_add(const char *szName,void (*pfn)(void), - const char * const *aszPre, - const char * const *aszSucc,int nOrder) -{ -#ifdef NETWARE - get_apd -#endif - apr_array_header_t *pArray=apr_optional_hook_get(szName); - apr_LINK__optional_t *pHook; - - if(!pArray) { - apr_array_header_t **ppArray; - - pArray=apr_array_make(apr_hook_global_pool,1, - sizeof(apr_LINK__optional_t)); - if(!s_phOptionalHooks) - s_phOptionalHooks=apr_hash_make(apr_hook_global_pool); - ppArray=apr_palloc(apr_hook_global_pool,sizeof *ppArray); - *ppArray=pArray; - apr_hash_set(s_phOptionalHooks,szName,strlen(szName),ppArray); - apr_hook_sort_register(szName,ppArray); - } - pHook=apr_array_push(pArray); - pHook->pFunc=pfn; - pHook->aszPredecessors=aszPre; - pHook->aszSuccessors=aszSucc; - pHook->nOrder=nOrder; - pHook->szName=apr_hook_debug_current; - if(apr_hook_debug_enabled) - apr_hook_debug_show(szName,aszPre,aszSucc); -} - -/* optional function support */ - -APU_DECLARE(apr_opt_fn_t *) apr_dynamic_fn_retrieve(const char *szName) -{ -#ifdef NETWARE - get_apd -#endif - if(!s_phOptionalFunctions) - return NULL; - return (void(*)(void))apr_hash_get(s_phOptionalFunctions,szName,strlen(szName)); -} - -/* Deprecated */ -APU_DECLARE_NONSTD(void) apr_dynamic_fn_register(const char *szName, - apr_opt_fn_t *pfn) -{ -#ifdef NETWARE - get_apd -#endif - if(!s_phOptionalFunctions) - s_phOptionalFunctions=apr_hash_make(apr_hook_global_pool); - apr_hash_set(s_phOptionalFunctions,szName,strlen(szName),(void *)pfn); -} - -#if 0 -void main() -{ - const char *aszAPre[]={"b","c",NULL}; - const char *aszBPost[]={"a",NULL}; - const char *aszCPost[]={"b",NULL}; - TSortData t1[]= - { - { "a",aszAPre,NULL }, - { "b",NULL,aszBPost }, - { "c",NULL,aszCPost } - }; - TSort *pResult; - - pResult=prepare(t1,3); - pResult=tsort(pResult,3); - - for( ; pResult ; pResult=pResult->pNext) - printf("%s\n",pResult->pData->szName); -} -#endif diff --git a/libs/apr-util/include/apr_anylock.h b/libs/apr-util/include/apr_anylock.h deleted file mode 100644 index 6b724de2c3..0000000000 --- a/libs/apr-util/include/apr_anylock.h +++ /dev/null @@ -1,128 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file apr_anylock.h - * @brief APR-Util transparent any lock flavor wrapper - */ -#ifndef APR_ANYLOCK_H -#define APR_ANYLOCK_H - -#include "apr_proc_mutex.h" -#include "apr_thread_mutex.h" -#include "apr_thread_rwlock.h" - -/** Structure that may contain any APR lock type */ -typedef struct apr_anylock_t { - /** Indicates what type of lock is in lock */ - enum tm_lock { - apr_anylock_none, /**< None */ - apr_anylock_procmutex, /**< Process-based */ - apr_anylock_threadmutex, /**< Thread-based */ - apr_anylock_readlock, /**< Read lock */ - apr_anylock_writelock /**< Write lock */ - } type; - /** Union of all possible APR locks */ - union apr_anylock_u_t { - apr_proc_mutex_t *pm; /**< Process mutex */ -#if APR_HAS_THREADS - apr_thread_mutex_t *tm; /**< Thread mutex */ - apr_thread_rwlock_t *rw; /**< Read-write lock */ -#endif - } lock; -} apr_anylock_t; - -#if APR_HAS_THREADS - -/** Lock an apr_anylock_t structure */ -#define APR_ANYLOCK_LOCK(lck) \ - (((lck)->type == apr_anylock_none) \ - ? APR_SUCCESS \ - : (((lck)->type == apr_anylock_threadmutex) \ - ? apr_thread_mutex_lock((lck)->lock.tm) \ - : (((lck)->type == apr_anylock_procmutex) \ - ? apr_proc_mutex_lock((lck)->lock.pm) \ - : (((lck)->type == apr_anylock_readlock) \ - ? apr_thread_rwlock_rdlock((lck)->lock.rw) \ - : (((lck)->type == apr_anylock_writelock) \ - ? apr_thread_rwlock_wrlock((lck)->lock.rw) \ - : APR_EINVAL))))) - -#else /* APR_HAS_THREADS */ - -#define APR_ANYLOCK_LOCK(lck) \ - (((lck)->type == apr_anylock_none) \ - ? APR_SUCCESS \ - : (((lck)->type == apr_anylock_procmutex) \ - ? apr_proc_mutex_lock((lck)->lock.pm) \ - : APR_EINVAL)) - -#endif /* APR_HAS_THREADS */ - -#if APR_HAS_THREADS - -/** Try to lock an apr_anylock_t structure */ -#define APR_ANYLOCK_TRYLOCK(lck) \ - (((lck)->type == apr_anylock_none) \ - ? APR_SUCCESS \ - : (((lck)->type == apr_anylock_threadmutex) \ - ? apr_thread_mutex_trylock((lck)->lock.tm) \ - : (((lck)->type == apr_anylock_procmutex) \ - ? apr_proc_mutex_trylock((lck)->lock.pm) \ - : (((lck)->type == apr_anylock_readlock) \ - ? apr_thread_rwlock_tryrdlock((lck)->lock.rw) \ - : (((lck)->type == apr_anylock_writelock) \ - ? apr_thread_rwlock_trywrlock((lck)->lock.rw) \ - : APR_EINVAL))))) - -#else /* APR_HAS_THREADS */ - -#define APR_ANYLOCK_TRYLOCK(lck) \ - (((lck)->type == apr_anylock_none) \ - ? APR_SUCCESS \ - : (((lck)->type == apr_anylock_procmutex) \ - ? apr_proc_mutex_trylock((lck)->lock.pm) \ - : APR_EINVAL)) - -#endif /* APR_HAS_THREADS */ - -#if APR_HAS_THREADS - -/** Unlock an apr_anylock_t structure */ -#define APR_ANYLOCK_UNLOCK(lck) \ - (((lck)->type == apr_anylock_none) \ - ? APR_SUCCESS \ - : (((lck)->type == apr_anylock_threadmutex) \ - ? apr_thread_mutex_unlock((lck)->lock.tm) \ - : (((lck)->type == apr_anylock_procmutex) \ - ? apr_proc_mutex_unlock((lck)->lock.pm) \ - : ((((lck)->type == apr_anylock_readlock) || \ - ((lck)->type == apr_anylock_writelock)) \ - ? apr_thread_rwlock_unlock((lck)->lock.rw) \ - : APR_EINVAL)))) - -#else /* APR_HAS_THREADS */ - -#define APR_ANYLOCK_UNLOCK(lck) \ - (((lck)->type == apr_anylock_none) \ - ? APR_SUCCESS \ - : (((lck)->type == apr_anylock_procmutex) \ - ? apr_proc_mutex_unlock((lck)->lock.pm) \ - : APR_EINVAL)) - -#endif /* APR_HAS_THREADS */ - -#endif /* !APR_ANYLOCK_H */ diff --git a/libs/apr-util/include/apr_base64.h b/libs/apr-util/include/apr_base64.h deleted file mode 100644 index d26aeb2d22..0000000000 --- a/libs/apr-util/include/apr_base64.h +++ /dev/null @@ -1,111 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * The apr_vsnprintf/apr_snprintf functions are based on, and used with the - * permission of, the SIO stdio-replacement strx_* functions by Panos - * Tsirigotis for xinetd. - */ - -/** - * @file apr_base64.h - * @brief APR-UTIL Base64 Encoding - */ -#ifndef APR_BASE64_H -#define APR_BASE64_H - -#include "apu.h" -#include "apr_general.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup APR_Util_Base64 Base64 Encoding - * @ingroup APR_Util - * @{ - */ - -/* Simple BASE64 encode/decode functions. - * - * As we might encode binary strings, hence we require the length of - * the incoming plain source. And return the length of what we decoded. - * - * The decoding function takes any non valid char (i.e. whitespace, \0 - * or anything non A-Z,0-9 etc as terminal. - * - * plain strings/binary sequences are not assumed '\0' terminated. Encoded - * strings are neither. But probably should. - * - */ - -/** - * Given the length of an un-encrypted string, get the length of the - * encrypted string. - * @param len the length of an unencrypted string. - * @return the length of the string after it is encrypted - */ -APU_DECLARE(int) apr_base64_encode_len(int len); - -/** - * Encode a text string using base64encoding. - * @param coded_dst The destination string for the encoded string. - * @param plain_src The original string in plain text - * @param len_plain_src The length of the plain text string - * @return the length of the encoded string - */ -APU_DECLARE(int) apr_base64_encode(char * coded_dst, const char *plain_src, - int len_plain_src); - -/** - * Encode an EBCDIC string using base64encoding. - * @param coded_dst The destination string for the encoded string. - * @param plain_src The original string in plain text - * @param len_plain_src The length of the plain text string - * @return the length of the encoded string - */ -APU_DECLARE(int) apr_base64_encode_binary(char * coded_dst, - const unsigned char *plain_src, - int len_plain_src); - -/** - * Determine the length of a plain text string given the encoded version - * @param coded_src The encoded string - * @return the length of the plain text string - */ -APU_DECLARE(int) apr_base64_decode_len(const char * coded_src); - -/** - * Decode a string to plain text - * @param plain_dst The destination string for the plain text - * @param coded_src The encoded string - * @return the length of the plain text string - */ -APU_DECLARE(int) apr_base64_decode(char * plain_dst, const char *coded_src); - -/** - * Decode an EBCDIC string to plain text - * @param plain_dst The destination string for the plain text - * @param coded_src The encoded string - * @return the length of the plain text string - */ -APU_DECLARE(int) apr_base64_decode_binary(unsigned char * plain_dst, - const char *coded_src); - -/** @} */ -#ifdef __cplusplus -} -#endif - -#endif /* !APR_BASE64_H */ diff --git a/libs/apr-util/include/apr_buckets.h b/libs/apr-util/include/apr_buckets.h deleted file mode 100644 index 01f6743d97..0000000000 --- a/libs/apr-util/include/apr_buckets.h +++ /dev/null @@ -1,1464 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @file apr_buckets.h - * @brief APR-UTIL Buckets/Bucket Brigades - */ - -#ifndef APR_BUCKETS_H -#define APR_BUCKETS_H - -#if defined(APR_BUCKET_DEBUG) && !defined(APR_RING_DEBUG) -#define APR_RING_DEBUG -#endif - -#include "apu.h" -#include "apr_network_io.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_mmap.h" -#include "apr_errno.h" -#include "apr_ring.h" -#include "apr.h" -#if APR_HAVE_SYS_UIO_H -#include /* for struct iovec */ -#endif -#if APR_HAVE_STDARG_H -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup APR_Util_Bucket_Brigades Bucket Brigades - * @ingroup APR_Util - * @{ - */ - -/** default bucket buffer size - 8KB minus room for memory allocator headers */ -#define APR_BUCKET_BUFF_SIZE 8000 - -/** Determines how a bucket or brigade should be read */ -typedef enum { - APR_BLOCK_READ, /**< block until data becomes available */ - APR_NONBLOCK_READ /**< return immediately if no data is available */ -} apr_read_type_e; - -/** - * The one-sentence buzzword-laden overview: Bucket brigades represent - * a complex data stream that can be passed through a layered IO - * system without unnecessary copying. A longer overview follows... - * - * A bucket brigade is a doubly linked list (ring) of buckets, so we - * aren't limited to inserting at the front and removing at the end. - * Buckets are only passed around as members of a brigade, although - * singleton buckets can occur for short periods of time. - * - * Buckets are data stores of various types. They can refer to data in - * memory, or part of a file or mmap area, or the output of a process, - * etc. Buckets also have some type-dependent accessor functions: - * read, split, copy, setaside, and destroy. - * - * read returns the address and size of the data in the bucket. If the - * data isn't in memory then it is read in and the bucket changes type - * so that it can refer to the new location of the data. If all the - * data doesn't fit in the bucket then a new bucket is inserted into - * the brigade to hold the rest of it. - * - * split divides the data in a bucket into two regions. After a split - * the original bucket refers to the first part of the data and a new - * bucket inserted into the brigade after the original bucket refers - * to the second part of the data. Reference counts are maintained as - * necessary. - * - * setaside ensures that the data in the bucket has a long enough - * lifetime. Sometimes it is convenient to create a bucket referring - * to data on the stack in the expectation that it will be consumed - * (output to the network) before the stack is unwound. If that - * expectation turns out not to be valid, the setaside function is - * called to move the data somewhere safer. - * - * copy makes a duplicate of the bucket structure as long as it's - * possible to have multiple references to a single copy of the - * data itself. Not all bucket types can be copied. - * - * destroy maintains the reference counts on the resources used by a - * bucket and frees them if necessary. - * - * Note: all of the above functions have wrapper macros (apr_bucket_read(), - * apr_bucket_destroy(), etc), and those macros should be used rather - * than using the function pointers directly. - * - * To write a bucket brigade, they are first made into an iovec, so that we - * don't write too little data at one time. Currently we ignore compacting the - * buckets into as few buckets as possible, but if we really want good - * performance, then we need to compact the buckets before we convert to an - * iovec, or possibly while we are converting to an iovec. - */ - -/* - * Forward declaration of the main types. - */ - -/** @see apr_bucket_brigade */ -typedef struct apr_bucket_brigade apr_bucket_brigade; -/** @see apr_bucket */ -typedef struct apr_bucket apr_bucket; -/** @see apr_bucket_alloc_t */ -typedef struct apr_bucket_alloc_t apr_bucket_alloc_t; - -/** @see apr_bucket_type_t */ -typedef struct apr_bucket_type_t apr_bucket_type_t; - -/** - * Basic bucket type - */ -struct apr_bucket_type_t { - /** - * The name of the bucket type - */ - const char *name; - /** - * The number of functions this bucket understands. Can not be less than - * five. - */ - int num_func; - /** - * Whether the bucket contains metadata (ie, information that - * describes the regular contents of the brigade). The metadata - * is not returned by apr_bucket_read() and is not indicated by - * the ->length of the apr_bucket itself. In other words, an - * empty bucket is safe to arbitrarily remove if and only if it - * contains no metadata. In this sense, "data" is just raw bytes - * that are the "content" of the brigade and "metadata" describes - * that data but is not a proper part of it. - */ - enum { - /** This bucket type represents actual data to send to the client. */ - APR_BUCKET_DATA = 0, - /** This bucket type represents metadata. */ - APR_BUCKET_METADATA = 1 - } is_metadata; - /** - * Free the private data and any resources used by the bucket (if they - * aren't shared with another bucket). This function is required to be - * implemented for all bucket types, though it might be a no-op on some - * of them (namely ones that never allocate any private data structures). - * @param data The private data pointer from the bucket to be destroyed - */ - void (*destroy)(void *data); - - /** - * Read the data from the bucket. This is required to be implemented - * for all bucket types. - * @param b The bucket to read from - * @param str A place to store the data read. Allocation should only be - * done if absolutely necessary. - * @param len The amount of data read. - * @param block Should this read function block if there is more data that - * cannot be read immediately. - */ - apr_status_t (*read)(apr_bucket *b, const char **str, apr_size_t *len, - apr_read_type_e block); - - /** - * Make it possible to set aside the data for at least as long as the - * given pool. Buckets containing data that could potentially die before - * this pool (e.g. the data resides on the stack, in a child pool of - * the given pool, or in a disjoint pool) must somehow copy, shift, or - * transform the data to have the proper lifetime. - * @param e The bucket to convert - * @remark Some bucket types contain data that will always outlive the - * bucket itself. For example no data (EOS and FLUSH), or the data - * resides in global, constant memory (IMMORTAL), or the data is on - * the heap (HEAP). For these buckets, apr_bucket_setaside_noop can - * be used. - */ - apr_status_t (*setaside)(apr_bucket *e, apr_pool_t *pool); - - /** - * Split one bucket in two at the specified position by duplicating - * the bucket structure (not the data) and modifying any necessary - * start/end/offset information. If it's not possible to do this - * for the bucket type (perhaps the length of the data is indeterminate, - * as with pipe and socket buckets), then APR_ENOTIMPL is returned. - * @param e The bucket to split - * @param point The offset of the first byte in the new bucket - */ - apr_status_t (*split)(apr_bucket *e, apr_size_t point); - - /** - * Copy the bucket structure (not the data), assuming that this is - * possible for the bucket type. If it's not, APR_ENOTIMPL is returned. - * @param e The bucket to copy - * @param c Returns a pointer to the new bucket - */ - apr_status_t (*copy)(apr_bucket *e, apr_bucket **c); - -}; - -/** - * apr_bucket structures are allocated on the malloc() heap and - * their lifetime is controlled by the parent apr_bucket_brigade - * structure. Buckets can move from one brigade to another e.g. by - * calling APR_BRIGADE_CONCAT(). In general the data in a bucket has - * the same lifetime as the bucket and is freed when the bucket is - * destroyed; if the data is shared by more than one bucket (e.g. - * after a split) the data is freed when the last bucket goes away. - */ -struct apr_bucket { - /** Links to the rest of the brigade */ - APR_RING_ENTRY(apr_bucket) link; - /** The type of bucket. */ - const apr_bucket_type_t *type; - /** The length of the data in the bucket. This could have been implemented - * with a function, but this is an optimization, because the most - * common thing to do will be to get the length. If the length is unknown, - * the value of this field will be (apr_size_t)(-1). - */ - apr_size_t length; - /** The start of the data in the bucket relative to the private base - * pointer. The vast majority of bucket types allow a fixed block of - * data to be referenced by multiple buckets, each bucket pointing to - * a different segment of the data. That segment starts at base+start - * and ends at base+start+length. - * If the length == (apr_size_t)(-1), then start == -1. - */ - apr_off_t start; - /** type-dependent data hangs off this pointer */ - void *data; - /** - * Pointer to function used to free the bucket. This function should - * always be defined and it should be consistent with the memory - * function used to allocate the bucket. For example, if malloc() is - * used to allocate the bucket, this pointer should point to free(). - * @param e Pointer to the bucket being freed - */ - void (*free)(void *e); - /** The freelist from which this bucket was allocated */ - apr_bucket_alloc_t *list; -}; - -/** A list of buckets */ -struct apr_bucket_brigade { - /** The pool to associate the brigade with. The data is not allocated out - * of the pool, but a cleanup is registered with this pool. If the - * brigade is destroyed by some mechanism other than pool destruction, - * the destroying function is responsible for killing the cleanup. - */ - apr_pool_t *p; - /** The buckets in the brigade are on this list. */ - /* - * The apr_bucket_list structure doesn't actually need a name tag - * because it has no existence independent of struct apr_bucket_brigade; - * the ring macros are designed so that you can leave the name tag - * argument empty in this situation but apparently the Windows compiler - * doesn't like that. - */ - APR_RING_HEAD(apr_bucket_list, apr_bucket) list; - /** The freelist from which this bucket was allocated */ - apr_bucket_alloc_t *bucket_alloc; -}; - - -/** - * Function called when a brigade should be flushed - */ -typedef apr_status_t (*apr_brigade_flush)(apr_bucket_brigade *bb, void *ctx); - -/* - * define APR_BUCKET_DEBUG if you want your brigades to be checked for - * validity at every possible instant. this will slow your code down - * substantially but is a very useful debugging tool. - */ -#ifdef APR_BUCKET_DEBUG - -#define APR_BRIGADE_CHECK_CONSISTENCY(b) \ - APR_RING_CHECK_CONSISTENCY(&(b)->list, apr_bucket, link) - -#define APR_BUCKET_CHECK_CONSISTENCY(e) \ - APR_RING_CHECK_ELEM_CONSISTENCY((e), apr_bucket, link) - -#else -/** - * checks the ring pointers in a bucket brigade for consistency. an - * abort() will be triggered if any inconsistencies are found. - * note: this is a no-op unless APR_BUCKET_DEBUG is defined. - * @param b The brigade - */ -#define APR_BRIGADE_CHECK_CONSISTENCY(b) -/** - * checks the brigade a bucket is in for ring consistency. an - * abort() will be triggered if any inconsistencies are found. - * note: this is a no-op unless APR_BUCKET_DEBUG is defined. - * @param e The bucket - */ -#define APR_BUCKET_CHECK_CONSISTENCY(e) -#endif - - -/** - * Wrappers around the RING macros to reduce the verbosity of the code - * that handles bucket brigades. - */ -/** - * The magic pointer value that indicates the head of the brigade - * @remark This is used to find the beginning and end of the brigade, eg: - *
- *      while (e != APR_BRIGADE_SENTINEL(b)) {
- *          ...
- *          e = APR_BUCKET_NEXT(e);
- *      }
- * 
- * @param b The brigade - * @return The magic pointer value - */ -#define APR_BRIGADE_SENTINEL(b) APR_RING_SENTINEL(&(b)->list, apr_bucket, link) - -/** - * Determine if the bucket brigade is empty - * @param b The brigade to check - * @return true or false - */ -#define APR_BRIGADE_EMPTY(b) APR_RING_EMPTY(&(b)->list, apr_bucket, link) - -/** - * Return the first bucket in a brigade - * @param b The brigade to query - * @return The first bucket in the brigade - */ -#define APR_BRIGADE_FIRST(b) APR_RING_FIRST(&(b)->list) -/** - * Return the last bucket in a brigade - * @param b The brigade to query - * @return The last bucket in the brigade - */ -#define APR_BRIGADE_LAST(b) APR_RING_LAST(&(b)->list) - -/** - * Insert a list of buckets at the front of a brigade - * @param b The brigade to add to - * @param e The first bucket in a list of buckets to insert - */ -#define APR_BRIGADE_INSERT_HEAD(b, e) do { \ - apr_bucket *ap__b = (e); \ - APR_RING_INSERT_HEAD(&(b)->list, ap__b, apr_bucket, link); \ - APR_BRIGADE_CHECK_CONSISTENCY((b)); \ - } while (0) - -/** - * Insert a list of buckets at the end of a brigade - * @param b The brigade to add to - * @param e The first bucket in a list of buckets to insert - */ -#define APR_BRIGADE_INSERT_TAIL(b, e) do { \ - apr_bucket *ap__b = (e); \ - APR_RING_INSERT_TAIL(&(b)->list, ap__b, apr_bucket, link); \ - APR_BRIGADE_CHECK_CONSISTENCY((b)); \ - } while (0) - -/** - * Concatenate brigade b onto the end of brigade a, leaving brigade b empty - * @param a The first brigade - * @param b The second brigade - */ -#define APR_BRIGADE_CONCAT(a, b) do { \ - APR_RING_CONCAT(&(a)->list, &(b)->list, apr_bucket, link); \ - APR_BRIGADE_CHECK_CONSISTENCY((a)); \ - } while (0) - -/** - * Prepend brigade b onto the beginning of brigade a, leaving brigade b empty - * @param a The first brigade - * @param b The second brigade - */ -#define APR_BRIGADE_PREPEND(a, b) do { \ - APR_RING_PREPEND(&(a)->list, &(b)->list, apr_bucket, link); \ - APR_BRIGADE_CHECK_CONSISTENCY((a)); \ - } while (0) - -/** - * Insert a list of buckets before a specified bucket - * @param a The bucket to insert before - * @param b The buckets to insert - */ -#define APR_BUCKET_INSERT_BEFORE(a, b) do { \ - apr_bucket *ap__a = (a), *ap__b = (b); \ - APR_RING_INSERT_BEFORE(ap__a, ap__b, link); \ - APR_BUCKET_CHECK_CONSISTENCY(ap__a); \ - } while (0) - -/** - * Insert a list of buckets after a specified bucket - * @param a The bucket to insert after - * @param b The buckets to insert - */ -#define APR_BUCKET_INSERT_AFTER(a, b) do { \ - apr_bucket *ap__a = (a), *ap__b = (b); \ - APR_RING_INSERT_AFTER(ap__a, ap__b, link); \ - APR_BUCKET_CHECK_CONSISTENCY(ap__a); \ - } while (0) - -/** - * Get the next bucket in the list - * @param e The current bucket - * @return The next bucket - */ -#define APR_BUCKET_NEXT(e) APR_RING_NEXT((e), link) -/** - * Get the previous bucket in the list - * @param e The current bucket - * @return The previous bucket - */ -#define APR_BUCKET_PREV(e) APR_RING_PREV((e), link) - -/** - * Remove a bucket from its bucket brigade - * @param e The bucket to remove - */ -#define APR_BUCKET_REMOVE(e) APR_RING_REMOVE((e), link) - -/** - * Initialize a new bucket's prev/next pointers - * @param e The bucket to initialize - */ -#define APR_BUCKET_INIT(e) APR_RING_ELEM_INIT((e), link) - -/** - * Determine if a bucket contains metadata. An empty bucket is - * safe to arbitrarily remove if and only if this is false. - * @param e The bucket to inspect - * @return true or false - */ -#define APR_BUCKET_IS_METADATA(e) ((e)->type->is_metadata) - -/** - * Determine if a bucket is a FLUSH bucket - * @param e The bucket to inspect - * @return true or false - */ -#define APR_BUCKET_IS_FLUSH(e) ((e)->type == &apr_bucket_type_flush) -/** - * Determine if a bucket is an EOS bucket - * @param e The bucket to inspect - * @return true or false - */ -#define APR_BUCKET_IS_EOS(e) ((e)->type == &apr_bucket_type_eos) -/** - * Determine if a bucket is a FILE bucket - * @param e The bucket to inspect - * @return true or false - */ -#define APR_BUCKET_IS_FILE(e) ((e)->type == &apr_bucket_type_file) -/** - * Determine if a bucket is a PIPE bucket - * @param e The bucket to inspect - * @return true or false - */ -#define APR_BUCKET_IS_PIPE(e) ((e)->type == &apr_bucket_type_pipe) -/** - * Determine if a bucket is a SOCKET bucket - * @param e The bucket to inspect - * @return true or false - */ -#define APR_BUCKET_IS_SOCKET(e) ((e)->type == &apr_bucket_type_socket) -/** - * Determine if a bucket is a HEAP bucket - * @param e The bucket to inspect - * @return true or false - */ -#define APR_BUCKET_IS_HEAP(e) ((e)->type == &apr_bucket_type_heap) -/** - * Determine if a bucket is a TRANSIENT bucket - * @param e The bucket to inspect - * @return true or false - */ -#define APR_BUCKET_IS_TRANSIENT(e) ((e)->type == &apr_bucket_type_transient) -/** - * Determine if a bucket is a IMMORTAL bucket - * @param e The bucket to inspect - * @return true or false - */ -#define APR_BUCKET_IS_IMMORTAL(e) ((e)->type == &apr_bucket_type_immortal) -#if APR_HAS_MMAP -/** - * Determine if a bucket is a MMAP bucket - * @param e The bucket to inspect - * @return true or false - */ -#define APR_BUCKET_IS_MMAP(e) ((e)->type == &apr_bucket_type_mmap) -#endif -/** - * Determine if a bucket is a POOL bucket - * @param e The bucket to inspect - * @return true or false - */ -#define APR_BUCKET_IS_POOL(e) ((e)->type == &apr_bucket_type_pool) - -/* - * General-purpose reference counting for the various bucket types. - * - * Any bucket type that keeps track of the resources it uses (i.e. - * most of them except for IMMORTAL, TRANSIENT, and EOS) needs to - * attach a reference count to the resource so that it can be freed - * when the last bucket that uses it goes away. Resource-sharing may - * occur because of bucket splits or buckets that refer to globally - * cached data. */ - -/** @see apr_bucket_refcount */ -typedef struct apr_bucket_refcount apr_bucket_refcount; -/** - * The structure used to manage the shared resource must start with an - * apr_bucket_refcount which is updated by the general-purpose refcount - * code. A pointer to the bucket-type-dependent private data structure - * can be cast to a pointer to an apr_bucket_refcount and vice versa. - */ -struct apr_bucket_refcount { - /** The number of references to this bucket */ - int refcount; -}; - -/* ***** Reference-counted bucket types ***** */ - -/** @see apr_bucket_heap */ -typedef struct apr_bucket_heap apr_bucket_heap; -/** - * A bucket referring to data allocated off the heap. - */ -struct apr_bucket_heap { - /** Number of buckets using this memory */ - apr_bucket_refcount refcount; - /** The start of the data actually allocated. This should never be - * modified, it is only used to free the bucket. - */ - char *base; - /** how much memory was allocated */ - apr_size_t alloc_len; - /** function to use to delete the data */ - void (*free_func)(void *data); -}; - -/** @see apr_bucket_pool */ -typedef struct apr_bucket_pool apr_bucket_pool; -/** - * A bucket referring to data allocated from a pool - */ -struct apr_bucket_pool { - /** The pool bucket must be able to be easily morphed to a heap - * bucket if the pool gets cleaned up before all references are - * destroyed. This apr_bucket_heap structure is populated automatically - * when the pool gets cleaned up, and subsequent calls to pool_read() - * will result in the apr_bucket in question being morphed into a - * regular heap bucket. (To avoid having to do many extra refcount - * manipulations and b->data manipulations, the apr_bucket_pool - * struct actually *contains* the apr_bucket_heap struct that it - * will become as its first element; the two share their - * apr_bucket_refcount members.) - */ - apr_bucket_heap heap; - /** The block of data actually allocated from the pool. - * Segments of this block are referenced by adjusting - * the start and length of the apr_bucket accordingly. - * This will be NULL after the pool gets cleaned up. - */ - const char *base; - /** The pool the data was allocated from. When the pool - * is cleaned up, this gets set to NULL as an indicator - * to pool_read() that the data is now on the heap and - * so it should morph the bucket into a regular heap - * bucket before continuing. - */ - apr_pool_t *pool; - /** The freelist this structure was allocated from, which is - * needed in the cleanup phase in order to allocate space on the heap - */ - apr_bucket_alloc_t *list; -}; - -#if APR_HAS_MMAP -/** @see apr_bucket_mmap */ -typedef struct apr_bucket_mmap apr_bucket_mmap; -/** - * A bucket referring to an mmap()ed file - */ -struct apr_bucket_mmap { - /** Number of buckets using this memory */ - apr_bucket_refcount refcount; - /** The mmap this sub_bucket refers to */ - apr_mmap_t *mmap; -}; -#endif - -/** @see apr_bucket_file */ -typedef struct apr_bucket_file apr_bucket_file; -/** - * A bucket referring to an file - */ -struct apr_bucket_file { - /** Number of buckets using this memory */ - apr_bucket_refcount refcount; - /** The file this bucket refers to */ - apr_file_t *fd; - /** The pool into which any needed structures should - * be created while reading from this file bucket */ - apr_pool_t *readpool; -#if APR_HAS_MMAP - /** Whether this bucket should be memory-mapped if - * a caller tries to read from it */ - int can_mmap; -#endif /* APR_HAS_MMAP */ -}; - -/** @see apr_bucket_structs */ -typedef union apr_bucket_structs apr_bucket_structs; -/** - * A union of all bucket structures so we know what - * the max size is. - */ -union apr_bucket_structs { - apr_bucket b; /**< Bucket */ - apr_bucket_heap heap; /**< Heap */ - apr_bucket_pool pool; /**< Pool */ -#if APR_HAS_MMAP - apr_bucket_mmap mmap; /**< MMap */ -#endif - apr_bucket_file file; /**< File */ -}; - -/** - * The amount that apr_bucket_alloc() should allocate in the common case. - * Note: this is twice as big as apr_bucket_structs to allow breathing - * room for third-party bucket types. - */ -#define APR_BUCKET_ALLOC_SIZE APR_ALIGN_DEFAULT(2*sizeof(apr_bucket_structs)) - -/* ***** Bucket Brigade Functions ***** */ -/** - * Create a new bucket brigade. The bucket brigade is originally empty. - * @param p The pool to associate with the brigade. Data is not allocated out - * of the pool, but a cleanup is registered. - * @param list The bucket allocator to use - * @return The empty bucket brigade - */ -APU_DECLARE(apr_bucket_brigade *) apr_brigade_create(apr_pool_t *p, - apr_bucket_alloc_t *list); - -/** - * destroy an entire bucket brigade. This includes destroying all of the - * buckets within the bucket brigade's bucket list. - * @param b The bucket brigade to destroy - */ -APU_DECLARE(apr_status_t) apr_brigade_destroy(apr_bucket_brigade *b); - -/** - * empty out an entire bucket brigade. This includes destroying all of the - * buckets within the bucket brigade's bucket list. This is similar to - * apr_brigade_destroy(), except that it does not deregister the brigade's - * pool cleanup function. - * @param data The bucket brigade to clean up - * @remark Generally, you should use apr_brigade_destroy(). This function - * can be useful in situations where you have a single brigade that - * you wish to reuse many times by destroying all of the buckets in - * the brigade and putting new buckets into it later. - */ -APU_DECLARE(apr_status_t) apr_brigade_cleanup(void *data); - -/** - * Split a bucket brigade into two, such that the given bucket is the - * first in the new bucket brigade. This function is useful when a - * filter wants to pass only the initial part of a brigade to the next - * filter. - * @param b The brigade to split - * @param e The first element of the new brigade - * @return The new brigade - */ -APU_DECLARE(apr_bucket_brigade *) apr_brigade_split(apr_bucket_brigade *b, - apr_bucket *e); - -/** - * Partition a bucket brigade at a given offset (in bytes from the start of - * the brigade). This is useful whenever a filter wants to use known ranges - * of bytes from the brigade; the ranges can even overlap. - * @param b The brigade to partition - * @param point The offset at which to partition the brigade - * @param after_point Returns a pointer to the first bucket after the partition - * @return APR_SUCCESS on success, APR_INCOMPLETE if the contents of the - * brigade were shorter than @a point, or an error code. - * @remark if APR_INCOMPLETE is returned, @a after_point will be set to - * the brigade sentinel. - */ -APU_DECLARE(apr_status_t) apr_brigade_partition(apr_bucket_brigade *b, - apr_off_t point, - apr_bucket **after_point); - -/** - * Return the total length of the brigade. - * @param bb The brigade to compute the length of - * @param read_all Read unknown-length buckets to force a size - * @param length Returns the length of the brigade, or -1 if the brigade has - * buckets of indeterminate length and read_all is 0. - */ -APU_DECLARE(apr_status_t) apr_brigade_length(apr_bucket_brigade *bb, - int read_all, - apr_off_t *length); - -/** - * Take a bucket brigade and store the data in a flat char* - * @param bb The bucket brigade to create the char* from - * @param c The char* to write into - * @param len The maximum length of the char array. On return, it is the - * actual length of the char array. - */ -APU_DECLARE(apr_status_t) apr_brigade_flatten(apr_bucket_brigade *bb, - char *c, - apr_size_t *len); - -/** - * Creates a pool-allocated string representing a flat bucket brigade - * @param bb The bucket brigade to create the char array from - * @param c On return, the allocated char array - * @param len On return, the length of the char array. - * @param pool The pool to allocate the string from. - */ -APU_DECLARE(apr_status_t) apr_brigade_pflatten(apr_bucket_brigade *bb, - char **c, - apr_size_t *len, - apr_pool_t *pool); - -/** - * Split a brigade to represent one LF line. - * @param bbOut The bucket brigade that will have the LF line appended to. - * @param bbIn The input bucket brigade to search for a LF-line. - * @param block The blocking mode to be used to split the line. - * @param maxbytes The maximum bytes to read. If this many bytes are seen - * without a LF, the brigade will contain a partial line. - */ -APU_DECLARE(apr_status_t) apr_brigade_split_line(apr_bucket_brigade *bbOut, - apr_bucket_brigade *bbIn, - apr_read_type_e block, - apr_off_t maxbytes); - -/** - * create an iovec of the elements in a bucket_brigade... return number - * of elements used. This is useful for writing to a file or to the - * network efficiently. - * @param b The bucket brigade to create the iovec from - * @param vec The iovec to create - * @param nvec The number of elements in the iovec. On return, it is the - * number of iovec elements actually filled out. - */ -APU_DECLARE(apr_status_t) apr_brigade_to_iovec(apr_bucket_brigade *b, - struct iovec *vec, int *nvec); - -/** - * This function writes a list of strings into a bucket brigade. - * @param b The bucket brigade to add to - * @param flush The flush function to use if the brigade is full - * @param ctx The structure to pass to the flush function - * @param va A list of strings to add - * @return APR_SUCCESS or error code. - */ -APU_DECLARE(apr_status_t) apr_brigade_vputstrs(apr_bucket_brigade *b, - apr_brigade_flush flush, - void *ctx, - va_list va); - -/** - * This function writes a string into a bucket brigade. - * @param b The bucket brigade to add to - * @param flush The flush function to use if the brigade is full - * @param ctx The structure to pass to the flush function - * @param str The string to add - * @param nbyte The number of bytes to write - * @return APR_SUCCESS or error code - */ -APU_DECLARE(apr_status_t) apr_brigade_write(apr_bucket_brigade *b, - apr_brigade_flush flush, void *ctx, - const char *str, apr_size_t nbyte); - -/** - * This function writes multiple strings into a bucket brigade. - * @param b The bucket brigade to add to - * @param flush The flush function to use if the brigade is full - * @param ctx The structure to pass to the flush function - * @param vec The strings to add (address plus length for each) - * @param nvec The number of entries in iovec - * @return APR_SUCCESS or error code - */ -APU_DECLARE(apr_status_t) apr_brigade_writev(apr_bucket_brigade *b, - apr_brigade_flush flush, - void *ctx, - const struct iovec *vec, - apr_size_t nvec); - -/** - * This function writes a string into a bucket brigade. - * @param bb The bucket brigade to add to - * @param flush The flush function to use if the brigade is full - * @param ctx The structure to pass to the flush function - * @param str The string to add - * @return APR_SUCCESS or error code - */ -APU_DECLARE(apr_status_t) apr_brigade_puts(apr_bucket_brigade *bb, - apr_brigade_flush flush, void *ctx, - const char *str); - -/** - * This function writes a character into a bucket brigade. - * @param b The bucket brigade to add to - * @param flush The flush function to use if the brigade is full - * @param ctx The structure to pass to the flush function - * @param c The character to add - * @return APR_SUCCESS or error code - */ -APU_DECLARE(apr_status_t) apr_brigade_putc(apr_bucket_brigade *b, - apr_brigade_flush flush, void *ctx, - const char c); - -/** - * This function writes an unspecified number of strings into a bucket brigade. - * @param b The bucket brigade to add to - * @param flush The flush function to use if the brigade is full - * @param ctx The structure to pass to the flush function - * @param ... The strings to add - * @return APR_SUCCESS or error code - */ -APU_DECLARE_NONSTD(apr_status_t) apr_brigade_putstrs(apr_bucket_brigade *b, - apr_brigade_flush flush, - void *ctx, ...); - -/** - * Evaluate a printf and put the resulting string at the end - * of the bucket brigade. - * @param b The brigade to write to - * @param flush The flush function to use if the brigade is full - * @param ctx The structure to pass to the flush function - * @param fmt The format of the string to write - * @param ... The arguments to fill out the format - * @return APR_SUCCESS or error code - */ -APU_DECLARE_NONSTD(apr_status_t) apr_brigade_printf(apr_bucket_brigade *b, - apr_brigade_flush flush, - void *ctx, - const char *fmt, ...) - __attribute__((format(printf,4,5))); - -/** - * Evaluate a printf and put the resulting string at the end - * of the bucket brigade. - * @param b The brigade to write to - * @param flush The flush function to use if the brigade is full - * @param ctx The structure to pass to the flush function - * @param fmt The format of the string to write - * @param va The arguments to fill out the format - * @return APR_SUCCESS or error code - */ -APU_DECLARE(apr_status_t) apr_brigade_vprintf(apr_bucket_brigade *b, - apr_brigade_flush flush, - void *ctx, - const char *fmt, va_list va); - -/** - * Utility function to insert a file (or a segment of a file) onto the - * end of the brigade. The file is split into multiple buckets if it - * is larger than the maximum size which can be represented by a - * single bucket. - * @param bb the brigade to insert into - * @param f the file to insert - * @param start the offset of the start of the segment - * @param len the length of the segment of the file to insert - * @param p pool from which file buckets are allocated - * @return the last bucket inserted - */ -APU_DECLARE(apr_bucket *) apr_brigade_insert_file(apr_bucket_brigade *bb, - apr_file_t *f, - apr_off_t start, - apr_off_t len, - apr_pool_t *p); - - - -/* ***** Bucket freelist functions ***** */ -/** - * Create a bucket allocator. - * @param p This pool's underlying apr_allocator_t is used to allocate memory - * for the bucket allocator. When the pool is destroyed, the bucket - * allocator's cleanup routine will free all memory that has been - * allocated from it. - * @remark The reason the allocator gets its memory from the pool's - * apr_allocator_t rather than from the pool itself is because - * the bucket allocator will free large memory blocks back to the - * allocator when it's done with them, thereby preventing memory - * footprint growth that would occur if we allocated from the pool. - * @warning The allocator must never be used by more than one thread at a time. - */ -APU_DECLARE_NONSTD(apr_bucket_alloc_t *) apr_bucket_alloc_create(apr_pool_t *p); - -/** - * Create a bucket allocator. - * @param allocator This apr_allocator_t is used to allocate both the bucket - * allocator and all memory handed out by the bucket allocator. The - * caller is responsible for destroying the bucket allocator and the - * apr_allocator_t -- no automatic cleanups will happen. - * @warning The allocator must never be used by more than one thread at a time. - */ -APU_DECLARE_NONSTD(apr_bucket_alloc_t *) apr_bucket_alloc_create_ex(apr_allocator_t *allocator); - -/** - * Destroy a bucket allocator. - * @param list The allocator to be destroyed - */ -APU_DECLARE_NONSTD(void) apr_bucket_alloc_destroy(apr_bucket_alloc_t *list); - -/** - * Allocate memory for use by the buckets. - * @param size The amount to allocate. - * @param list The allocator from which to allocate the memory. - */ -APU_DECLARE_NONSTD(void *) apr_bucket_alloc(apr_size_t size, apr_bucket_alloc_t *list); - -/** - * Free memory previously allocated with apr_bucket_alloc(). - * @param block The block of memory to be freed. - */ -APU_DECLARE_NONSTD(void) apr_bucket_free(void *block); - - -/* ***** Bucket Functions ***** */ -/** - * Free the resources used by a bucket. If multiple buckets refer to - * the same resource it is freed when the last one goes away. - * @see apr_bucket_delete() - * @param e The bucket to destroy - */ -#define apr_bucket_destroy(e) do { \ - (e)->type->destroy((e)->data); \ - (e)->free(e); \ - } while (0) - -/** - * Delete a bucket by removing it from its brigade (if any) and then - * destroying it. - * @remark This mainly acts as an aid in avoiding code verbosity. It is - * the preferred exact equivalent to: - *
- *      APR_BUCKET_REMOVE(e);
- *      apr_bucket_destroy(e);
- * 
- * @param e The bucket to delete - */ -#define apr_bucket_delete(e) do { \ - APR_BUCKET_REMOVE(e); \ - apr_bucket_destroy(e); \ - } while (0) - -/** - * read the data from the bucket - * @param e The bucket to read from - * @param str The location to store the data in - * @param len The amount of data read - * @param block Whether the read function blocks - */ -#define apr_bucket_read(e,str,len,block) (e)->type->read(e, str, len, block) - -/** - * Setaside data so that stack data is not destroyed on returning from - * the function - * @param e The bucket to setaside - * @param p The pool to setaside into - */ -#define apr_bucket_setaside(e,p) (e)->type->setaside(e,p) - -/** - * Split one bucket in two. - * @param e The bucket to split - * @param point The offset to split the bucket at - */ -#define apr_bucket_split(e,point) (e)->type->split(e, point) - -/** - * Copy a bucket. - * @param e The bucket to copy - * @param c Returns a pointer to the new bucket - */ -#define apr_bucket_copy(e,c) (e)->type->copy(e, c) - -/* Bucket type handling */ - -/** - * This function simply returns APR_SUCCESS to denote that the bucket does - * not require anything to happen for its setaside() function. This is - * appropriate for buckets that have "immortal" data -- the data will live - * at least as long as the bucket. - * @param data The bucket to setaside - * @param pool The pool defining the desired lifetime of the bucket data - * @return APR_SUCCESS - */ -APU_DECLARE_NONSTD(apr_status_t) apr_bucket_setaside_noop(apr_bucket *data, - apr_pool_t *pool); - -/** - * A place holder function that signifies that the setaside function was not - * implemented for this bucket - * @param data The bucket to setaside - * @param pool The pool defining the desired lifetime of the bucket data - * @return APR_ENOTIMPL - */ -APU_DECLARE_NONSTD(apr_status_t) apr_bucket_setaside_notimpl(apr_bucket *data, - apr_pool_t *pool); - -/** - * A place holder function that signifies that the split function was not - * implemented for this bucket - * @param data The bucket to split - * @param point The location to split the bucket - * @return APR_ENOTIMPL - */ -APU_DECLARE_NONSTD(apr_status_t) apr_bucket_split_notimpl(apr_bucket *data, - apr_size_t point); - -/** - * A place holder function that signifies that the copy function was not - * implemented for this bucket - * @param e The bucket to copy - * @param c Returns a pointer to the new bucket - * @return APR_ENOTIMPL - */ -APU_DECLARE_NONSTD(apr_status_t) apr_bucket_copy_notimpl(apr_bucket *e, - apr_bucket **c); - -/** - * A place holder function that signifies that this bucket does not need - * to do anything special to be destroyed. That's only the case for buckets - * that either have no data (metadata buckets) or buckets whose data pointer - * points to something that's not a bucket-type-specific structure, as with - * simple buckets where data points to a string and pipe buckets where data - * points directly to the apr_file_t. - * @param data The bucket data to destroy - */ -APU_DECLARE_NONSTD(void) apr_bucket_destroy_noop(void *data); - -/** - * There is no apr_bucket_destroy_notimpl, because destruction is required - * to be implemented (it could be a noop, but only if that makes sense for - * the bucket type) - */ - -/* There is no apr_bucket_read_notimpl, because it is a required function - */ - - -/* All of the bucket types implemented by the core */ -/** - * The flush bucket type. This signifies that all data should be flushed to - * the next filter. The flush bucket should be sent with the other buckets. - */ -APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_flush; -/** - * The EOS bucket type. This signifies that there will be no more data, ever. - * All filters MUST send all data to the next filter when they receive a - * bucket of this type - */ -APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_eos; -/** - * The FILE bucket type. This bucket represents a file on disk - */ -APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_file; -/** - * The HEAP bucket type. This bucket represents a data allocated from the - * heap. - */ -APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_heap; -#if APR_HAS_MMAP -/** - * The MMAP bucket type. This bucket represents an MMAP'ed file - */ -APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_mmap; -#endif -/** - * The POOL bucket type. This bucket represents a data that was allocated - * from a pool. IF this bucket is still available when the pool is cleared, - * the data is copied on to the heap. - */ -APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_pool; -/** - * The PIPE bucket type. This bucket represents a pipe to another program. - */ -APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_pipe; -/** - * The IMMORTAL bucket type. This bucket represents a segment of data that - * the creator is willing to take responsibility for. The core will do - * nothing with the data in an immortal bucket - */ -APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_immortal; -/** - * The TRANSIENT bucket type. This bucket represents a data allocated off - * the stack. When the setaside function is called, this data is copied on - * to the heap - */ -APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_transient; -/** - * The SOCKET bucket type. This bucket represents a socket to another machine - */ -APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_socket; - - -/* ***** Simple buckets ***** */ - -/** - * Split a simple bucket into two at the given point. Most non-reference - * counting buckets that allow multiple references to the same block of - * data (eg transient and immortal) will use this as their split function - * without any additional type-specific handling. - * @param b The bucket to be split - * @param point The offset of the first byte in the new bucket - * @return APR_EINVAL if the point is not within the bucket; - * APR_ENOMEM if allocation failed; - * or APR_SUCCESS - */ -APU_DECLARE_NONSTD(apr_status_t) apr_bucket_simple_split(apr_bucket *b, - apr_size_t point); - -/** - * Copy a simple bucket. Most non-reference-counting buckets that allow - * multiple references to the same block of data (eg transient and immortal) - * will use this as their copy function without any additional type-specific - * handling. - * @param a The bucket to copy - * @param b Returns a pointer to the new bucket - * @return APR_ENOMEM if allocation failed; - * or APR_SUCCESS - */ -APU_DECLARE_NONSTD(apr_status_t) apr_bucket_simple_copy(apr_bucket *a, - apr_bucket **b); - - -/* ***** Shared, reference-counted buckets ***** */ - -/** - * Initialize a bucket containing reference-counted data that may be - * shared. The caller must allocate the bucket if necessary and - * initialize its type-dependent fields, and allocate and initialize - * its own private data structure. This function should only be called - * by type-specific bucket creation functions. - * @param b The bucket to initialize - * @param data A pointer to the private data structure - * with the reference count at the start - * @param start The start of the data in the bucket - * relative to the private base pointer - * @param length The length of the data in the bucket - * @return The new bucket, or NULL if allocation failed - */ -APU_DECLARE(apr_bucket *) apr_bucket_shared_make(apr_bucket *b, void *data, - apr_off_t start, - apr_size_t length); - -/** - * Decrement the refcount of the data in the bucket. This function - * should only be called by type-specific bucket destruction functions. - * @param data The private data pointer from the bucket to be destroyed - * @return TRUE or FALSE; TRUE if the reference count is now - * zero, indicating that the shared resource itself can - * be destroyed by the caller. - */ -APU_DECLARE(int) apr_bucket_shared_destroy(void *data); - -/** - * Split a bucket into two at the given point, and adjust the refcount - * to the underlying data. Most reference-counting bucket types will - * be able to use this function as their split function without any - * additional type-specific handling. - * @param b The bucket to be split - * @param point The offset of the first byte in the new bucket - * @return APR_EINVAL if the point is not within the bucket; - * APR_ENOMEM if allocation failed; - * or APR_SUCCESS - */ -APU_DECLARE_NONSTD(apr_status_t) apr_bucket_shared_split(apr_bucket *b, - apr_size_t point); - -/** - * Copy a refcounted bucket, incrementing the reference count. Most - * reference-counting bucket types will be able to use this function - * as their copy function without any additional type-specific handling. - * @param a The bucket to copy - * @param b Returns a pointer to the new bucket - * @return APR_ENOMEM if allocation failed; - or APR_SUCCESS - */ -APU_DECLARE_NONSTD(apr_status_t) apr_bucket_shared_copy(apr_bucket *a, - apr_bucket **b); - - -/* ***** Functions to Create Buckets of varying types ***** */ -/* - * Each bucket type foo has two initialization functions: - * apr_bucket_foo_make which sets up some already-allocated memory as a - * bucket of type foo; and apr_bucket_foo_create which allocates memory - * for the bucket, calls apr_bucket_make_foo, and initializes the - * bucket's list pointers. The apr_bucket_foo_make functions are used - * inside the bucket code to change the type of buckets in place; - * other code should call apr_bucket_foo_create. All the initialization - * functions change nothing if they fail. - */ - -/** - * Create an End of Stream bucket. This indicates that there is no more data - * coming from down the filter stack. All filters should flush at this point. - * @param list The freelist from which this bucket should be allocated - * @return The new bucket, or NULL if allocation failed - */ -APU_DECLARE(apr_bucket *) apr_bucket_eos_create(apr_bucket_alloc_t *list); - -/** - * Make the bucket passed in an EOS bucket. This indicates that there is no - * more data coming from down the filter stack. All filters should flush at - * this point. - * @param b The bucket to make into an EOS bucket - * @return The new bucket, or NULL if allocation failed - */ -APU_DECLARE(apr_bucket *) apr_bucket_eos_make(apr_bucket *b); - -/** - * Create a flush bucket. This indicates that filters should flush their - * data. There is no guarantee that they will flush it, but this is the - * best we can do. - * @param list The freelist from which this bucket should be allocated - * @return The new bucket, or NULL if allocation failed - */ -APU_DECLARE(apr_bucket *) apr_bucket_flush_create(apr_bucket_alloc_t *list); - -/** - * Make the bucket passed in a FLUSH bucket. This indicates that filters - * should flush their data. There is no guarantee that they will flush it, - * but this is the best we can do. - * @param b The bucket to make into a FLUSH bucket - * @return The new bucket, or NULL if allocation failed - */ -APU_DECLARE(apr_bucket *) apr_bucket_flush_make(apr_bucket *b); - -/** - * Create a bucket referring to long-lived data. - * @param buf The data to insert into the bucket - * @param nbyte The size of the data to insert. - * @param list The freelist from which this bucket should be allocated - * @return The new bucket, or NULL if allocation failed - */ -APU_DECLARE(apr_bucket *) apr_bucket_immortal_create(const char *buf, - apr_size_t nbyte, - apr_bucket_alloc_t *list); - -/** - * Make the bucket passed in a bucket refer to long-lived data - * @param b The bucket to make into a IMMORTAL bucket - * @param buf The data to insert into the bucket - * @param nbyte The size of the data to insert. - * @return The new bucket, or NULL if allocation failed - */ -APU_DECLARE(apr_bucket *) apr_bucket_immortal_make(apr_bucket *b, - const char *buf, - apr_size_t nbyte); - -/** - * Create a bucket referring to data on the stack. - * @param buf The data to insert into the bucket - * @param nbyte The size of the data to insert. - * @param list The freelist from which this bucket should be allocated - * @return The new bucket, or NULL if allocation failed - */ -APU_DECLARE(apr_bucket *) apr_bucket_transient_create(const char *buf, - apr_size_t nbyte, - apr_bucket_alloc_t *list); - -/** - * Make the bucket passed in a bucket refer to stack data - * @param b The bucket to make into a TRANSIENT bucket - * @param buf The data to insert into the bucket - * @param nbyte The size of the data to insert. - * @return The new bucket, or NULL if allocation failed - */ -APU_DECLARE(apr_bucket *) apr_bucket_transient_make(apr_bucket *b, - const char *buf, - apr_size_t nbyte); - -/** - * Create a bucket referring to memory on the heap. If the caller asks - * for the data to be copied, this function always allocates 4K of - * memory so that more data can be added to the bucket without - * requiring another allocation. Therefore not all the data may be put - * into the bucket. If copying is not requested then the bucket takes - * over responsibility for free()ing the memory. - * @param buf The buffer to insert into the bucket - * @param nbyte The size of the buffer to insert. - * @param free_func Function to use to free the data; NULL indicates that the - * bucket should make a copy of the data - * @param list The freelist from which this bucket should be allocated - * @return The new bucket, or NULL if allocation failed - */ -APU_DECLARE(apr_bucket *) apr_bucket_heap_create(const char *buf, - apr_size_t nbyte, - void (*free_func)(void *data), - apr_bucket_alloc_t *list); -/** - * Make the bucket passed in a bucket refer to heap data - * @param b The bucket to make into a HEAP bucket - * @param buf The buffer to insert into the bucket - * @param nbyte The size of the buffer to insert. - * @param free_func Function to use to free the data; NULL indicates that the - * bucket should make a copy of the data - * @return The new bucket, or NULL if allocation failed - */ -APU_DECLARE(apr_bucket *) apr_bucket_heap_make(apr_bucket *b, const char *buf, - apr_size_t nbyte, - void (*free_func)(void *data)); - -/** - * Create a bucket referring to memory allocated from a pool. - * - * @param buf The buffer to insert into the bucket - * @param length The number of bytes referred to by this bucket - * @param pool The pool the memory was allocated from - * @param list The freelist from which this bucket should be allocated - * @return The new bucket, or NULL if allocation failed - */ -APU_DECLARE(apr_bucket *) apr_bucket_pool_create(const char *buf, - apr_size_t length, - apr_pool_t *pool, - apr_bucket_alloc_t *list); - -/** - * Make the bucket passed in a bucket refer to pool data - * @param b The bucket to make into a pool bucket - * @param buf The buffer to insert into the bucket - * @param length The number of bytes referred to by this bucket - * @param pool The pool the memory was allocated from - * @return The new bucket, or NULL if allocation failed - */ -APU_DECLARE(apr_bucket *) apr_bucket_pool_make(apr_bucket *b, const char *buf, - apr_size_t length, - apr_pool_t *pool); - -#if APR_HAS_MMAP -/** - * Create a bucket referring to mmap()ed memory. - * @param mm The mmap to insert into the bucket - * @param start The offset of the first byte in the mmap - * that this bucket refers to - * @param length The number of bytes referred to by this bucket - * @param list The freelist from which this bucket should be allocated - * @return The new bucket, or NULL if allocation failed - */ -APU_DECLARE(apr_bucket *) apr_bucket_mmap_create(apr_mmap_t *mm, - apr_off_t start, - apr_size_t length, - apr_bucket_alloc_t *list); - -/** - * Make the bucket passed in a bucket refer to an MMAP'ed file - * @param b The bucket to make into a MMAP bucket - * @param mm The mmap to insert into the bucket - * @param start The offset of the first byte in the mmap - * that this bucket refers to - * @param length The number of bytes referred to by this bucket - * @return The new bucket, or NULL if allocation failed - */ -APU_DECLARE(apr_bucket *) apr_bucket_mmap_make(apr_bucket *b, apr_mmap_t *mm, - apr_off_t start, - apr_size_t length); -#endif - -/** - * Create a bucket referring to a socket. - * @param thissock The socket to put in the bucket - * @param list The freelist from which this bucket should be allocated - * @return The new bucket, or NULL if allocation failed - */ -APU_DECLARE(apr_bucket *) apr_bucket_socket_create(apr_socket_t *thissock, - apr_bucket_alloc_t *list); -/** - * Make the bucket passed in a bucket refer to a socket - * @param b The bucket to make into a SOCKET bucket - * @param thissock The socket to put in the bucket - * @return The new bucket, or NULL if allocation failed - */ -APU_DECLARE(apr_bucket *) apr_bucket_socket_make(apr_bucket *b, - apr_socket_t *thissock); - -/** - * Create a bucket referring to a pipe. - * @param thispipe The pipe to put in the bucket - * @param list The freelist from which this bucket should be allocated - * @return The new bucket, or NULL if allocation failed - */ -APU_DECLARE(apr_bucket *) apr_bucket_pipe_create(apr_file_t *thispipe, - apr_bucket_alloc_t *list); - -/** - * Make the bucket passed in a bucket refer to a pipe - * @param b The bucket to make into a PIPE bucket - * @param thispipe The pipe to put in the bucket - * @return The new bucket, or NULL if allocation failed - */ -APU_DECLARE(apr_bucket *) apr_bucket_pipe_make(apr_bucket *b, - apr_file_t *thispipe); - -/** - * Create a bucket referring to a file. - * @param fd The file to put in the bucket - * @param offset The offset where the data of interest begins in the file - * @param len The amount of data in the file we are interested in - * @param p The pool into which any needed structures should be created - * while reading from this file bucket - * @param list The freelist from which this bucket should be allocated - * @return The new bucket, or NULL if allocation failed - */ -APU_DECLARE(apr_bucket *) apr_bucket_file_create(apr_file_t *fd, - apr_off_t offset, - apr_size_t len, - apr_pool_t *p, - apr_bucket_alloc_t *list); - -/** - * Make the bucket passed in a bucket refer to a file - * @param b The bucket to make into a FILE bucket - * @param fd The file to put in the bucket - * @param offset The offset where the data of interest begins in the file - * @param len The amount of data in the file we are interested in - * @param p The pool into which any needed structures should be created - * while reading from this file bucket - * @return The new bucket, or NULL if allocation failed - */ -APU_DECLARE(apr_bucket *) apr_bucket_file_make(apr_bucket *b, apr_file_t *fd, - apr_off_t offset, - apr_size_t len, apr_pool_t *p); - -/** - * Enable or disable memory-mapping for a FILE bucket (default is enabled) - * @param b The bucket - * @param enabled Whether memory-mapping should be enabled - * @return APR_SUCCESS normally, or an error code if the operation fails - */ -APU_DECLARE(apr_status_t) apr_bucket_file_enable_mmap(apr_bucket *b, - int enabled); - -/** @} */ -#ifdef __cplusplus -} -#endif - -#endif /* !APR_BUCKETS_H */ diff --git a/libs/apr-util/include/apr_date.h b/libs/apr-util/include/apr_date.h deleted file mode 100644 index 87500a3394..0000000000 --- a/libs/apr-util/include/apr_date.h +++ /dev/null @@ -1,106 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_DATE_H -#define APR_DATE_H - -/** - * @file apr_date.h - * @brief APR-UTIL date routines - */ - -/** - * @defgroup APR_Util_Date Date routines - * @ingroup APR_Util - * @{ - */ - -/* - * apr_date.h: prototypes for date parsing utility routines - */ - -#include "apu.h" -#include "apr_time.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** A bad date. */ -#define APR_DATE_BAD ((apr_time_t)0) - -/** - * Compare a string to a mask - * @param data The string to compare - * @param mask Mask characters (arbitrary maximum is 256 characters): - *
- *   '\@' - uppercase letter
- *   '\$' - lowercase letter
- *   '\&' - hex digit
- *   '#' - digit
- *   '~' - digit or space
- *   '*' - swallow remaining characters
- * 
- * @remark The mask tests for an exact match for any other character - * @return 1 if the string matches, 0 otherwise - */ -APU_DECLARE(int) apr_date_checkmask(const char *data, const char *mask); - -/** - * Parses an HTTP date in one of three standard forms: - *
- *     Sun, 06 Nov 1994 08:49:37 GMT  ; RFC 822, updated by RFC 1123
- *     Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036
- *     Sun Nov  6 08:49:37 1994       ; ANSI C's asctime() format
- * 
- * @param date The date in one of the three formats above - * @return the apr_time_t number of microseconds since 1 Jan 1970 GMT, or - * 0 if this would be out of range or if the date is invalid. - */ -APU_DECLARE(apr_time_t) apr_date_parse_http(const char *date); - -/** - * Parses a string resembling an RFC 822 date. This is meant to be - * leinent in its parsing of dates. Hence, this will parse a wider - * range of dates than apr_date_parse_http. - * - * The prominent mailer (or poster, if mailer is unknown) that has - * been seen in the wild is included for the unknown formats. - *
- *     Sun, 06 Nov 1994 08:49:37 GMT  ; RFC 822, updated by RFC 1123
- *     Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036
- *     Sun Nov  6 08:49:37 1994       ; ANSI C's asctime() format
- *     Sun, 6 Nov 1994 08:49:37 GMT   ; RFC 822, updated by RFC 1123
- *     Sun, 06 Nov 94 08:49:37 GMT    ; RFC 822
- *     Sun, 6 Nov 94 08:49:37 GMT     ; RFC 822
- *     Sun, 06 Nov 94 08:49 GMT       ; Unknown [drtr\@ast.cam.ac.uk] 
- *     Sun, 6 Nov 94 08:49 GMT        ; Unknown [drtr\@ast.cam.ac.uk]
- *     Sun, 06 Nov 94 8:49:37 GMT     ; Unknown [Elm 70.85]
- *     Sun, 6 Nov 94 8:49:37 GMT      ; Unknown [Elm 70.85] 
- * 
- * - * @param date The date in one of the formats above - * @return the apr_time_t number of microseconds since 1 Jan 1970 GMT, or - * 0 if this would be out of range or if the date is invalid. - */ -APU_DECLARE(apr_time_t) apr_date_parse_rfc(const char *date); - -/** @} */ -#ifdef __cplusplus -} -#endif - -#endif /* !APR_DATE_H */ diff --git a/libs/apr-util/include/apr_dbd.h b/libs/apr-util/include/apr_dbd.h deleted file mode 100644 index 103ff9cb5e..0000000000 --- a/libs/apr-util/include/apr_dbd.h +++ /dev/null @@ -1,357 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* Overview of what this is and does: - * http://www.apache.org/~niq/dbd.html - */ - -#ifndef APR_DBD_H -#define APR_DBD_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @file apr_dbd.h - * @brief APR-UTIL DBD library - */ -/** - * @defgroup APR_Util_DBD DBD routines - * @ingroup APR_Util - * @{ - */ - -/* These are opaque structs. Instantiation is up to each backend */ -typedef struct apr_dbd_driver_t apr_dbd_driver_t; -typedef struct apr_dbd_t apr_dbd_t; -typedef struct apr_dbd_transaction_t apr_dbd_transaction_t; -typedef struct apr_dbd_results_t apr_dbd_results_t; -typedef struct apr_dbd_row_t apr_dbd_row_t; -typedef struct apr_dbd_prepared_t apr_dbd_prepared_t; - -/** apr_dbd_init: perform once-only initialisation. Call once only. - * - * @param pool - pool to register any shutdown cleanups, etc - */ -APU_DECLARE(apr_status_t) apr_dbd_init(apr_pool_t *pool); - -/** apr_dbd_get_driver: get the driver struct for a name - * - * @param pool - (process) pool to register cleanup - * @param name - driver name - * @param driver - pointer to driver struct. - * @return APR_SUCCESS for success - * @return APR_ENOTIMPL for no driver (when DSO not enabled) - * @return APR_EDSOOPEN if DSO driver file can't be opened - * @return APR_ESYMNOTFOUND if the driver file doesn't contain a driver - */ -APU_DECLARE(apr_status_t) apr_dbd_get_driver(apr_pool_t *pool, const char *name, - const apr_dbd_driver_t **driver); - -/** apr_dbd_open: open a connection to a backend - * - * @param pool - working pool - * @param params - arguments to driver (implementation-dependent) - * @param handle - pointer to handle to return - * @param driver - driver struct. - * @return APR_SUCCESS for success - * @return APR_EGENERAL if driver exists but connection failed - * @remarks PostgreSQL: the params is passed directly to the PQconnectdb() - * function (check PostgreSQL documentation for more details on the syntax). - * @remarks SQLite2: the params is split on a colon, with the first part used - * as the filename and second part converted to an integer and used as file - * mode. - * @remarks SQLite3: the params is passed directly to the sqlite3_open() - * function as a filename to be opened (check SQLite3 documentation for more - * details). - * @remarks MySQL: the params can have "host", "port", "user", "pass", - * "dbname", "sock", "flags" and "fldsz" keys, each followed by an equal sign - * and a value. Such key/value pairs can be delimited by space, CR, LF, tab, - * semicolon, vertical bar or comma. For now, "flags" can only recognise - * CLIENT_FOUND_ROWS (check MySQL manual for details). The value associated - * with "fldsz" determines maximum amount of memory (in bytes) for each of - * the fields in the result set of prepared statements. By default, this - * value is 1 MB. - */ -APU_DECLARE(apr_status_t) apr_dbd_open(const apr_dbd_driver_t *driver, - apr_pool_t *pool, const char *params, - apr_dbd_t **handle); - -/** apr_dbd_close: close a connection to a backend - * - * @param handle - handle to close - * @param driver - driver struct. - * @return APR_SUCCESS for success or error status - */ -APU_DECLARE(apr_status_t) apr_dbd_close(const apr_dbd_driver_t *driver, - apr_dbd_t *handle); - -/* apr-function-shaped versions of things */ - -/** apr_dbd_name: get the name of the driver - * - * @param driver - the driver - * @return - name - */ -APU_DECLARE(const char*) apr_dbd_name(const apr_dbd_driver_t *driver); - -/** apr_dbd_native_handle: get native database handle of the underlying db - * - * @param driver - the driver - * @param handle - apr_dbd handle - * @return - native handle - */ -APU_DECLARE(void*) apr_dbd_native_handle(const apr_dbd_driver_t *driver, - apr_dbd_t *handle); - -/** check_conn: check status of a database connection - * - * @param driver - the driver - * @param pool - working pool - * @param handle - the connection to check - * @return APR_SUCCESS or error - */ -APU_DECLARE(int) apr_dbd_check_conn(const apr_dbd_driver_t *driver, apr_pool_t *pool, - apr_dbd_t *handle); - -/** apr_dbd_set_dbname: select database name. May be a no-op if not supported. - * - * @param driver - the driver - * @param pool - working pool - * @param handle - the connection - * @param name - the database to select - * @return 0 for success or error code - */ -APU_DECLARE(int) apr_dbd_set_dbname(const apr_dbd_driver_t *driver, apr_pool_t *pool, - apr_dbd_t *handle, const char *name); - -/** apr_dbd_transaction_start: start a transaction. May be a no-op. - * - * @param driver - the driver - * @param pool - a pool to use for error messages (if any). - * @param handle - the db connection - * @param trans - ptr to a transaction. May be null on entry - * @return 0 for success or error code - * @remarks If any of the query/select calls during a transaction return - * non-zero status code, the transaction will inherit this code and any - * further query/select calls will fail immediately. - */ -APU_DECLARE(int) apr_dbd_transaction_start(const apr_dbd_driver_t *driver, - apr_pool_t *pool, - apr_dbd_t *handle, - apr_dbd_transaction_t **trans); - -/** apr_dbd_transaction_end: end a transaction - * (commit on success, rollback on error). - * May be a no-op. - * - * @param driver - the driver - * @param handle - the db connection - * @param trans - the transaction. - * @return 0 for success or error code - */ -APU_DECLARE(int) apr_dbd_transaction_end(const apr_dbd_driver_t *driver, - apr_pool_t *pool, - apr_dbd_transaction_t *trans); - -/** apr_dbd_query: execute an SQL query that doesn't return a result set - * - * @param driver - the driver - * @param handle - the connection - * @param nrows - number of rows affected. - * @param statement - the SQL statement to execute - * @return 0 for success or error code - */ -APU_DECLARE(int) apr_dbd_query(const apr_dbd_driver_t *driver, apr_dbd_t *handle, - int *nrows, const char *statement); - -/** apr_dbd_select: execute an SQL query that returns a result set - * - * @param driver - the driver - * @param pool - pool to allocate the result set - * @param handle - the connection - * @param res - pointer to result set pointer. May point to NULL on entry - * @param statement - the SQL statement to execute - * @param random - 1 to support random access to results (seek any row); - * 0 to support only looping through results in order - * (async access - faster) - * @return 0 for success or error code - */ -APU_DECLARE(int) apr_dbd_select(const apr_dbd_driver_t *driver, apr_pool_t *pool, - apr_dbd_t *handle, apr_dbd_results_t **res, - const char *statement, int random); - -/** apr_dbd_num_cols: get the number of columns in a results set - * - * @param driver - the driver - * @param res - result set. - * @return number of columns - */ -APU_DECLARE(int) apr_dbd_num_cols(const apr_dbd_driver_t *driver, - apr_dbd_results_t *res); - -/** apr_dbd_num_tuples: get the number of rows in a results set - * of a synchronous select - * - * @param driver - the driver - * @param res - result set. - * @return number of rows, or -1 if the results are asynchronous - */ -APU_DECLARE(int) apr_dbd_num_tuples(const apr_dbd_driver_t *driver, - apr_dbd_results_t *res); - -/** apr_dbd_get_row: get a row from a result set - * - * @param driver - the driver - * @param pool - pool to allocate the row - * @param res - result set pointer - * @param row - pointer to row pointer. May point to NULL on entry - * @param rownum - row number, or -1 for "next row". Ignored if random - * access is not supported. - * @return 0 for success, -1 for rownum out of range or data finished - */ -APU_DECLARE(int) apr_dbd_get_row(const apr_dbd_driver_t *driver, apr_pool_t *pool, - apr_dbd_results_t *res, apr_dbd_row_t **row, - int rownum); - -/** apr_dbd_get_entry: get an entry from a row - * - * @param driver - the driver - * @param row - row pointer - * @param col - entry number - * @return value from the row, or NULL if col is out of bounds. - */ -APU_DECLARE(const char*) apr_dbd_get_entry(const apr_dbd_driver_t *driver, - apr_dbd_row_t *row, int col); - -/** apr_dbd_error: get current error message (if any) - * - * @param driver - the driver - * @param handle - the connection - * @param errnum - error code from operation that returned an error - * @return the database current error message, or message for errnum - * (implementation-dependent whether errnum is ignored) - */ -APU_DECLARE(const char*) apr_dbd_error(const apr_dbd_driver_t *driver, - apr_dbd_t *handle, int errnum); - -/** apr_dbd_escape: escape a string so it is safe for use in query/select - * - * @param driver - the driver - * @param pool - pool to alloc the result from - * @param string - the string to escape - * @param handle - the connection - * @return the escaped, safe string - */ -APU_DECLARE(const char*) apr_dbd_escape(const apr_dbd_driver_t *driver, - apr_pool_t *pool, const char *string, - apr_dbd_t *handle); - -/** apr_dbd_prepare: prepare a statement - * - * @param driver - the driver - * @param pool - pool to alloc the result from - * @param handle - the connection - * @param query - the SQL query - * @param label - A label for the prepared statement. - * use NULL for temporary prepared statements - * (eg within a Request in httpd) - * @param statement - statement to prepare. May point to null on entry. - * @return 0 for success or error code - * @remarks To specify parameters of the prepared query, use %s in place of - * database specific parameter syntax (e.g. for PostgreSQL, this would be $1, - * $2, for SQLite3 this would be ? etc.). For instance: "SELECT name FROM - * customers WHERE name=%s" would be a query that this function understands. - * Some drivers may support different data types using printf-like format: - * for example %d (e.g. PostgreSQL) or %f for numeric data. - */ -APU_DECLARE(int) apr_dbd_prepare(const apr_dbd_driver_t *driver, apr_pool_t *pool, - apr_dbd_t *handle, const char *query, - const char *label, - apr_dbd_prepared_t **statement); - - -/** apr_dbd_pquery: query using a prepared statement + args - * - * @param driver - the driver - * @param pool - working pool - * @param handle - the connection - * @param nrows - number of rows affected. - * @param statement - the prepared statement to execute - * @param nargs - number of args to prepared statement - * @param args - args to prepared statement - * @return 0 for success or error code - */ -APU_DECLARE(int) apr_dbd_pquery(const apr_dbd_driver_t *driver, apr_pool_t *pool, - apr_dbd_t *handle, int *nrows, - apr_dbd_prepared_t *statement, int nargs, - const char **args); - -/** apr_dbd_pselect: select using a prepared statement + args - * - * @param driver - the driver - * @param pool - working pool - * @param handle - the connection - * @param res - pointer to query results. May point to NULL on entry - * @param statement - the prepared statement to execute - * @param random - Whether to support random-access to results - * @param nargs - number of args to prepared statement - * @param args - args to prepared statement - * @return 0 for success or error code - */ -APU_DECLARE(int) apr_dbd_pselect(const apr_dbd_driver_t *driver, apr_pool_t *pool, - apr_dbd_t *handle, apr_dbd_results_t **res, - apr_dbd_prepared_t *statement, int random, - int nargs, const char **args); - -/** apr_dbd_pvquery: query using a prepared statement + args - * - * @param driver - the driver - * @param pool - working pool - * @param handle - the connection - * @param nrows - number of rows affected. - * @param statement - the prepared statement to execute - * @param ... - varargs list - * @return 0 for success or error code - */ -APU_DECLARE(int) apr_dbd_pvquery(const apr_dbd_driver_t *driver, apr_pool_t *pool, - apr_dbd_t *handle, int *nrows, - apr_dbd_prepared_t *statement, ...); - -/** apr_dbd_pvselect: select using a prepared statement + args - * - * @param driver - the driver - * @param pool - working pool - * @param handle - the connection - * @param res - pointer to query results. May point to NULL on entry - * @param statement - the prepared statement to execute - * @param random - Whether to support random-access to results - * @param ... - varargs list - * @return 0 for success or error code - */ -APU_DECLARE(int) apr_dbd_pvselect(const apr_dbd_driver_t *driver, apr_pool_t *pool, - apr_dbd_t *handle, apr_dbd_results_t **res, - apr_dbd_prepared_t *statement, int random, - ...); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/libs/apr-util/include/apr_dbm.h b/libs/apr-util/include/apr_dbm.h deleted file mode 100644 index d34f9ad3f3..0000000000 --- a/libs/apr-util/include/apr_dbm.h +++ /dev/null @@ -1,224 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_DBM_H -#define APR_DBM_H - -#include "apu.h" -#include "apr.h" -#include "apr_errno.h" -#include "apr_pools.h" -#include "apr_file_info.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @file apr_dbm.h - * @brief APR-UTIL DBM library - */ -/** - * @defgroup APR_Util_DBM DBM routines - * @ingroup APR_Util - * @{ - */ -/** - * Structure for referencing a dbm - */ -typedef struct apr_dbm_t apr_dbm_t; - -/** - * Structure for referencing the datum record within a dbm - */ -typedef struct -{ - /** pointer to the 'data' to retrieve/store in the DBM */ - char *dptr; - /** size of the 'data' to retrieve/store in the DBM */ - apr_size_t dsize; -} apr_datum_t; - -/* modes to open the DB */ -#define APR_DBM_READONLY 1 /**< open for read-only access */ -#define APR_DBM_READWRITE 2 /**< open for read-write access */ -#define APR_DBM_RWCREATE 3 /**< open for r/w, create if needed */ -#define APR_DBM_RWTRUNC 4 /**< open for r/w, truncating an existing - DB if present */ -/** - * Open a dbm file by file name and type of DBM - * @param dbm The newly opened database - * @param type The type of the DBM (not all may be available at run time) - *
- *  GDBM for GDBM files
- *  SDBM for SDBM files
- *  DB   for berkeley DB files
- *  NDBM for NDBM files
- *  default for the default DBM type
- *  
- * @param name The dbm file name to open - * @param mode The flag value - *
- *           APR_DBM_READONLY   open for read-only access
- *           APR_DBM_READWRITE  open for read-write access
- *           APR_DBM_RWCREATE   open for r/w, create if needed
- *           APR_DBM_RWTRUNC    open for r/w, truncate if already there
- * 
- * @param perm Permissions to apply to if created - * @param cntxt The pool to use when creating the dbm - * @remark The dbm name may not be a true file name, as many dbm packages - * append suffixes for seperate data and index files. - */ - -APU_DECLARE(apr_status_t) apr_dbm_open_ex(apr_dbm_t **dbm, const char* type, - const char *name, - apr_int32_t mode, apr_fileperms_t perm, - apr_pool_t *cntxt); - - -/** - * Open a dbm file by file name - * @param dbm The newly opened database - * @param name The dbm file name to open - * @param mode The flag value - *
- *           APR_DBM_READONLY   open for read-only access
- *           APR_DBM_READWRITE  open for read-write access
- *           APR_DBM_RWCREATE   open for r/w, create if needed
- *           APR_DBM_RWTRUNC    open for r/w, truncate if already there
- * 
- * @param perm Permissions to apply to if created - * @param cntxt The pool to use when creating the dbm - * @remark The dbm name may not be a true file name, as many dbm packages - * append suffixes for seperate data and index files. - */ -APU_DECLARE(apr_status_t) apr_dbm_open(apr_dbm_t **dbm, const char *name, - apr_int32_t mode, apr_fileperms_t perm, - apr_pool_t *cntxt); - -/** - * Close a dbm file previously opened by apr_dbm_open - * @param dbm The database to close - */ -APU_DECLARE(void) apr_dbm_close(apr_dbm_t *dbm); - -/** - * Fetch a dbm record value by key - * @param dbm The database - * @param key The key datum to find this record - * @param pvalue The value datum retrieved for this record - */ -APU_DECLARE(apr_status_t) apr_dbm_fetch(apr_dbm_t *dbm, apr_datum_t key, - apr_datum_t *pvalue); -/** - * Store a dbm record value by key - * @param dbm The database - * @param key The key datum to store this record by - * @param value The value datum to store in this record - */ -APU_DECLARE(apr_status_t) apr_dbm_store(apr_dbm_t *dbm, apr_datum_t key, - apr_datum_t value); - -/** - * Delete a dbm record value by key - * @param dbm The database - * @param key The key datum of the record to delete - * @remark It is not an error to delete a non-existent record. - */ -APU_DECLARE(apr_status_t) apr_dbm_delete(apr_dbm_t *dbm, apr_datum_t key); - -/** - * Search for a key within the dbm - * @param dbm The database - * @param key The datum describing a key to test - */ -APU_DECLARE(int) apr_dbm_exists(apr_dbm_t *dbm, apr_datum_t key); - -/** - * Retrieve the first record key from a dbm - * @param dbm The database - * @param pkey The key datum of the first record - */ -APU_DECLARE(apr_status_t) apr_dbm_firstkey(apr_dbm_t *dbm, apr_datum_t *pkey); - -/** - * Retrieve the next record key from a dbm - * @param dbm The database - * @param pkey The key datum of the next record - */ -APU_DECLARE(apr_status_t) apr_dbm_nextkey(apr_dbm_t *dbm, apr_datum_t *pkey); - -/** - * Proactively toss any memory associated with the apr_datum_t. - * @param dbm The database - * @param data The datum to free. - */ -APU_DECLARE(void) apr_dbm_freedatum(apr_dbm_t *dbm, apr_datum_t data); - -/** - * Report more information when an apr_dbm function fails. - * @param dbm The database - * @param errcode A DBM-specific value for the error (for logging). If this - * isn't needed, it may be NULL. - * @param errbuf Location to store the error text - * @param errbufsize The size of the provided buffer - * @return The errbuf parameter, for convenience. - */ -APU_DECLARE(char *) apr_dbm_geterror(apr_dbm_t *dbm, int *errcode, - char *errbuf, apr_size_t errbufsize); -/** - * If the specified file/path were passed to apr_dbm_open(), return the - * actual file/path names which would be (created and) used. At most, two - * files may be used; used2 may be NULL if only one file is used. - * @param pool The pool for allocating used1 and used2. - * @param type The type of DBM you require info on - * @param pathname The path name to generate used-names from. - * @param used1 The first pathname used by the apr_dbm implementation. - * @param used2 The second pathname used by apr_dbm. If only one file is - * used by the specific implementation, this will be set to NULL. - * @return An error if the specified type is invalid. - * @remark The dbm file(s) don't need to exist. This function only manipulates - * the pathnames. - */ -APU_DECLARE(apr_status_t) apr_dbm_get_usednames_ex(apr_pool_t *pool, - const char *type, - const char *pathname, - const char **used1, - const char **used2); - -/** - * If the specified file/path were passed to apr_dbm_open(), return the - * actual file/path names which would be (created and) used. At most, two - * files may be used; used2 may be NULL if only one file is used. - * @param pool The pool for allocating used1 and used2. - * @param pathname The path name to generate used-names from. - * @param used1 The first pathname used by the apr_dbm implementation. - * @param used2 The second pathname used by apr_dbm. If only one file is - * used by the specific implementation, this will be set to NULL. - * @remark The dbm file(s) don't need to exist. This function only manipulates - * the pathnames. - */ -APU_DECLARE(void) apr_dbm_get_usednames(apr_pool_t *pool, - const char *pathname, - const char **used1, - const char **used2); - -/** @} */ -#ifdef __cplusplus -} -#endif - -#endif /* !APR_DBM_H */ diff --git a/libs/apr-util/include/apr_hooks.h b/libs/apr-util/include/apr_hooks.h deleted file mode 100644 index 287fb8cb0e..0000000000 --- a/libs/apr-util/include/apr_hooks.h +++ /dev/null @@ -1,256 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_HOOKS_H -#define APR_HOOKS_H - -#include "apu.h" -/* For apr_array_header_t */ -#include "apr_tables.h" - -/** - * @file apr_hooks.h - * @brief Apache hook functions - */ - -#ifdef __cplusplus -extern "C" { -#endif -/** - * @defgroup APR_Util_Hook Hook Functions - * @ingroup APR_Util - * @{ - */ -/** macro to return the prototype of the hook function */ -#define APR_IMPLEMENT_HOOK_GET_PROTO(ns,link,name) \ -link##_DECLARE(apr_array_header_t *) ns##_hook_get_##name(void) - -/** macro to declare the hook correctly */ -#define APR_DECLARE_EXTERNAL_HOOK(ns,link,ret,name,args) \ -typedef ret ns##_HOOK_##name##_t args; \ -link##_DECLARE(void) ns##_hook_##name(ns##_HOOK_##name##_t *pf, \ - const char * const *aszPre, \ - const char * const *aszSucc, int nOrder); \ -link##_DECLARE(ret) ns##_run_##name args; \ -APR_IMPLEMENT_HOOK_GET_PROTO(ns,link,name); \ -typedef struct ns##_LINK_##name##_t \ - { \ - ns##_HOOK_##name##_t *pFunc; \ - const char *szName; \ - const char * const *aszPredecessors; \ - const char * const *aszSuccessors; \ - int nOrder; \ - } ns##_LINK_##name##_t; - -/** macro to declare the hook structure */ -#define APR_HOOK_STRUCT(members) \ -static struct { members } _hooks; - -/** macro to link the hook structure */ -#define APR_HOOK_LINK(name) \ - apr_array_header_t *link_##name; - -/** macro to implement the hook */ -#define APR_IMPLEMENT_EXTERNAL_HOOK_BASE(ns,link,name) \ -link##_DECLARE(void) ns##_hook_##name(ns##_HOOK_##name##_t *pf,const char * const *aszPre, \ - const char * const *aszSucc,int nOrder) \ - { \ - ns##_LINK_##name##_t *pHook; \ - if(!_hooks.link_##name) \ - { \ - _hooks.link_##name=apr_array_make(apr_hook_global_pool,1,sizeof(ns##_LINK_##name##_t)); \ - apr_hook_sort_register(#name,&_hooks.link_##name); \ - } \ - pHook=apr_array_push(_hooks.link_##name); \ - pHook->pFunc=pf; \ - pHook->aszPredecessors=aszPre; \ - pHook->aszSuccessors=aszSucc; \ - pHook->nOrder=nOrder; \ - pHook->szName=apr_hook_debug_current; \ - if(apr_hook_debug_enabled) \ - apr_hook_debug_show(#name,aszPre,aszSucc); \ - } \ - APR_IMPLEMENT_HOOK_GET_PROTO(ns,link,name) \ - { \ - return _hooks.link_##name; \ - } - -/** - * Implement a hook that has no return code, and therefore runs all of the - * registered functions - * @param ns The namespace prefix of the hook functions - * @param link The linkage declaration prefix of the hook - * @param name The name of the hook - * @param args_decl The declaration of the arguments for the hook - * @param args_use The names for the arguments for the hook - * @note The link prefix FOO corresponds to FOO_DECLARE() macros, which - * provide export linkage from the module that IMPLEMENTs the hook, and - * import linkage from external modules that link to the hook's module. - */ -#define APR_IMPLEMENT_EXTERNAL_HOOK_VOID(ns,link,name,args_decl,args_use) \ -APR_IMPLEMENT_EXTERNAL_HOOK_BASE(ns,link,name) \ -link##_DECLARE(void) ns##_run_##name args_decl \ - { \ - ns##_LINK_##name##_t *pHook; \ - int n; \ -\ - if(!_hooks.link_##name) \ - return; \ -\ - pHook=(ns##_LINK_##name##_t *)_hooks.link_##name->elts; \ - for(n=0 ; n < _hooks.link_##name->nelts ; ++n) \ - pHook[n].pFunc args_use; \ - } - -/* FIXME: note that this returns ok when nothing is run. I suspect it should - really return decline, but that breaks Apache currently - Ben -*/ -/** - * Implement a hook that runs until one of the functions returns something - * other than OK or DECLINE - * @param ns The namespace prefix of the hook functions - * @param link The linkage declaration prefix of the hook - * @param ret Type to return - * @param name The name of the hook - * @param args_decl The declaration of the arguments for the hook - * @param args_use The names for the arguments for the hook - * @param ok Success value - * @param decline Decline value - * @note The link prefix FOO corresponds to FOO_DECLARE() macros, which - * provide export linkage from the module that IMPLEMENTs the hook, and - * import linkage from external modules that link to the hook's module. - */ -#define APR_IMPLEMENT_EXTERNAL_HOOK_RUN_ALL(ns,link,ret,name,args_decl,args_use,ok,decline) \ -APR_IMPLEMENT_EXTERNAL_HOOK_BASE(ns,link,name) \ -link##_DECLARE(ret) ns##_run_##name args_decl \ - { \ - ns##_LINK_##name##_t *pHook; \ - int n; \ - ret rv; \ -\ - if(!_hooks.link_##name) \ - return ok; \ -\ - pHook=(ns##_LINK_##name##_t *)_hooks.link_##name->elts; \ - for(n=0 ; n < _hooks.link_##name->nelts ; ++n) \ - { \ - rv=pHook[n].pFunc args_use; \ -\ - if(rv != ok && rv != decline) \ - return rv; \ - } \ - return ok; \ - } - - -/** - * Implement a hook that runs until the first function returns something - * other than the value of decline - * @param ns The namespace prefix of the hook functions - * @param link The linkage declaration prefix of the hook - * @param name The name of the hook - * @param ret Type to return - * @param args_decl The declaration of the arguments for the hook - * @param args_use The names for the arguments for the hook - * @param decline Decline value - * @note The link prefix FOO corresponds to FOO_DECLARE() macros, which - * provide export linkage from the module that IMPLEMENTs the hook, and - * import linkage from external modules that link to the hook's module. - */ -#define APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(ns,link,ret,name,args_decl,args_use,decline) \ -APR_IMPLEMENT_EXTERNAL_HOOK_BASE(ns,link,name) \ -link##_DECLARE(ret) ns##_run_##name args_decl \ - { \ - ns##_LINK_##name##_t *pHook; \ - int n; \ - ret rv; \ -\ - if(!_hooks.link_##name) \ - return decline; \ -\ - pHook=(ns##_LINK_##name##_t *)_hooks.link_##name->elts; \ - for(n=0 ; n < _hooks.link_##name->nelts ; ++n) \ - { \ - rv=pHook[n].pFunc args_use; \ -\ - if(rv != decline) \ - return rv; \ - } \ - return decline; \ - } - - /* Hook orderings */ -/** run this hook first, before ANYTHING */ -#define APR_HOOK_REALLY_FIRST (-10) -/** run this hook first */ -#define APR_HOOK_FIRST 0 -/** run this hook somewhere */ -#define APR_HOOK_MIDDLE 10 -/** run this hook after every other hook which is defined*/ -#define APR_HOOK_LAST 20 -/** run this hook last, after EVERYTHING */ -#define APR_HOOK_REALLY_LAST 30 - -/** - * The global pool used to allocate any memory needed by the hooks. - */ -APU_DECLARE_DATA extern apr_pool_t *apr_hook_global_pool; - -/** - * A global variable to determine if debugging information about the - * hooks functions should be printed - */ -APU_DECLARE_DATA extern int apr_hook_debug_enabled; - -/** - * The name of the module that is currently registering a function - */ -APU_DECLARE_DATA extern const char *apr_hook_debug_current; - -/** - * Register a hook function to be sorted - * @param szHookName The name of the Hook the function is registered for - * @param aHooks The array which stores all of the functions for this hook - */ -APU_DECLARE(void) apr_hook_sort_register(const char *szHookName, - apr_array_header_t **aHooks); -/** - * Sort all of the registerd functions for a given hook - */ -APU_DECLARE(void) apr_hook_sort_all(void); - -/** - * Print all of the information about the current hook. This is used for - * debugging purposes. - * @param szName The name of the hook - * @param aszPre All of the functions in the predecessor array - * @param aszSucc All of the functions in the successor array - */ -APU_DECLARE(void) apr_hook_debug_show(const char *szName, - const char * const *aszPre, - const char * const *aszSucc); - -/** - * Remove all currently registered functions. - */ -APU_DECLARE(void) apr_hook_deregister_all(void); - -/** @} */ -#ifdef __cplusplus -} -#endif - -#endif /* APR_HOOKS_H */ diff --git a/libs/apr-util/include/apr_ldap.h.in b/libs/apr-util/include/apr_ldap.h.in deleted file mode 100644 index e44729d63b..0000000000 --- a/libs/apr-util/include/apr_ldap.h.in +++ /dev/null @@ -1,131 +0,0 @@ -/* Copyright 2002-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * apr_ldap.h is generated from apr_ldap.h.in by configure -- do not edit apr_ldap.h - */ -/** - * @file apr_ldap.h - * @brief APR-UTIL LDAP - */ -#ifndef APU_LDAP_H -#define APU_LDAP_H - -/** - * @defgroup APR_Util_LDAP LDAP - * @ingroup APR_Util - * @{ - */ - -/* this will be defined if LDAP support was compiled into apr-util */ -#define APR_HAS_LDAP @apu_has_ldap@ - -/* identify the LDAP toolkit used */ -#define APR_HAS_NETSCAPE_LDAPSDK @apu_has_ldap_netscape@ -#define APR_HAS_SOLARIS_LDAPSDK @apu_has_ldap_solaris@ -#define APR_HAS_NOVELL_LDAPSDK @apu_has_ldap_novell@ -#define APR_HAS_MOZILLA_LDAPSDK @apu_has_ldap_mozilla@ -#define APR_HAS_OPENLDAP_LDAPSDK @apu_has_ldap_openldap@ -#define APR_HAS_MICROSOFT_LDAPSDK @apu_has_ldap_microsoft@ -#define APR_HAS_OTHER_LDAPSDK @apu_has_ldap_other@ - - -/* - * Handle the case when LDAP is enabled - */ -#if APR_HAS_LDAP - -/* - * The following #defines are DEPRECATED and should not be used for - * anything. They remain to maintain binary compatibility. - * The original code defined the OPENLDAP SDK as present regardless - * of what really was there, which was way bogus. In addition, the - * apr_ldap_url_parse*() functions have been rewritten specifically for - * APR, so the APR_HAS_LDAP_URL_PARSE macro is forced to zero. - */ -#define APR_HAS_LDAP_SSL 1 -#define APR_HAS_LDAP_URL_PARSE 0 - -#if APR_HAS_OPENLDAP_LDAPSDK && !defined(LDAP_DEPRECATED) -/* Ensure that the "deprecated" interfaces are still exposed - * with OpenLDAP >= 2.3; these were exposed by default in earlier - * releases. */ -#define LDAP_DEPRECATED 1 -#endif - -/* - * Include the standard LDAP header files. - */ - -@lber_h@ -@ldap_h@ -@ldap_ssl_h@ - - -/* - * Detected standard functions - */ -#define APR_HAS_LDAPSSL_CLIENT_INIT @apu_has_ldapssl_client_init@ -#define APR_HAS_LDAPSSL_CLIENT_DEINIT @apu_has_ldapssl_client_deinit@ -#define APR_HAS_LDAPSSL_ADD_TRUSTED_CERT @apu_has_ldapssl_add_trusted_cert@ -#define APR_HAS_LDAP_START_TLS_S @apu_has_ldap_start_tls_s@ -#define APR_HAS_LDAP_SSLINIT @apu_has_ldap_sslinit@ -#define APR_HAS_LDAPSSL_INIT @apu_has_ldapssl_init@ -#define APR_HAS_LDAPSSL_INSTALL_ROUTINES @apu_has_ldapssl_install_routines@ - -/* - * Make sure the secure LDAP port is defined - */ -#ifndef LDAPS_PORT -#define LDAPS_PORT 636 /* ldaps:/// default LDAP over TLS port */ -#endif - - -/* Note: Macros defining const casting has been removed in APR v1.0, - * pending real support for LDAP v2.0 toolkits. - * - * In the mean time, please use an LDAP v3.0 toolkit. - */ -#if LDAP_VERSION_MAX <= 2 -#error Support for LDAP v2.0 toolkits has been removed from apr-util. Please use an LDAP v3.0 toolkit. -#endif - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * This structure allows the C LDAP API error codes to be returned - * along with plain text error messages that explain to us mere mortals - * what really happened. - */ -typedef struct apr_ldap_err_t { - const char *reason; - const char *msg; - int rc; -} apr_ldap_err_t; - -#ifdef __cplusplus -} -#endif - -#include "apr_ldap_url.h" -#include "apr_ldap_init.h" -#include "apr_ldap_option.h" - -/** @} */ -#endif /* APR_HAS_LDAP */ -#endif /* APU_LDAP_H */ diff --git a/libs/apr-util/include/apr_ldap.hnw b/libs/apr-util/include/apr_ldap.hnw deleted file mode 100644 index 947eaac2d7..0000000000 --- a/libs/apr-util/include/apr_ldap.hnw +++ /dev/null @@ -1,133 +0,0 @@ -/* Copyright 2002-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * apr_ldap.h is generated from apr_ldap.h.in by configure -- do not edit apr_ldap.h - */ -/** - * @file apr_ldap.h - * @brief APR-UTIL LDAP - */ -#ifndef APU_LDAP_H -#define APU_LDAP_H - -/** - * @defgroup APR_Util_LDAP LDAP - * @ingroup APR_Util - * @{ - */ - -/* this will be defined if LDAP support was compiled into apr-util */ -#define APR_HAS_LDAP 1 - -/* identify the LDAP toolkit used */ -#define APR_HAS_NETSCAPE_LDAPSDK 0 -#define APR_HAS_SOLARIS_LDAPSDK 0 -#define APR_HAS_NOVELL_LDAPSDK 1 -#define APR_HAS_MOZILLA_LDAPSDK 0 -#define APR_HAS_OPENLDAP_LDAPSDK 0 -#define APR_HAS_MICROSOFT_LDAPSDK 0 -#define APR_HAS_OTHER_LDAPSDK 0 - - -/* - * Handle the case when LDAP is enabled - */ -#if APR_HAS_LDAP - -/* - * The following #defines are DEPRECATED and should not be used for - * anything. They remain to maintain binary compatibility. - * The original code defined the OPENLDAP SDK as present regardless - * of what really was there, which was way bogus. In addition, the - * apr_ldap_url_parse*() functions have been rewritten specifically for - * APR, so the APR_HAS_LDAP_URL_PARSE macro is forced to zero. - */ -#define APR_HAS_LDAP_SSL 1 -#define APR_HAS_LDAP_URL_PARSE 0 - - -/* - * Include the standard LDAP header files. - */ - -#ifdef GENEXPORTS -#define LDAP_VERSION_MAX 3 -#else -#include -#include -#if APR_HAS_LDAP_SSL -#include -#endif -#endif - - -/* - * Detected standard functions - */ -#define APR_HAS_LDAPSSL_CLIENT_INIT 1 -#define APR_HAS_LDAPSSL_CLIENT_DEINIT 1 -#define APR_HAS_LDAPSSL_ADD_TRUSTED_CERT 1 -#define APR_HAS_LDAP_START_TLS_S 0 -#define APR_HAS_LDAP_SSLINIT 0 -#define APR_HAS_LDAPSSL_INIT 1 -#define APR_HAS_LDAPSSL_INSTALL_ROUTINES 0 - - -/* - * Make sure the secure LDAP port is defined - */ -#ifndef LDAPS_PORT -#define LDAPS_PORT 636 /* ldaps:/// default LDAP over TLS port */ -#endif - - -/* Note: Macros defining const casting has been removed in APR v1.0, - * pending real support for LDAP v2.0 toolkits. - * - * In the mean time, please use an LDAP v3.0 toolkit. - */ -#if LDAP_VERSION_MAX <= 2 -#error Support for LDAP v2.0 toolkits has been removed from apr-util. Please use an LDAP v3.0 toolkit. -#endif - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * This structure allows the C LDAP API error codes to be returned - * along with plain text error messages that explain to us mere mortals - * what really happened. - */ -typedef struct apr_ldap_err_t { - const char *reason; - const char *msg; - int rc; -} apr_ldap_err_t; - -#ifdef __cplusplus -} -#endif - -#include "apr_ldap_url.h" -#include "apr_ldap_init.h" -#include "apr_ldap_option.h" - -/** @} */ -#endif /* APR_HAS_LDAP */ -#endif /* APU_LDAP_H */ - diff --git a/libs/apr-util/include/apr_ldap.hw b/libs/apr-util/include/apr_ldap.hw deleted file mode 100644 index 7a4d67f8f5..0000000000 --- a/libs/apr-util/include/apr_ldap.hw +++ /dev/null @@ -1,124 +0,0 @@ -/* Copyright 2002-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * apr_ldap.h is generated from apr_ldap.h.in by configure -- do not edit apr_ldap.h - */ -/** - * @file apr_ldap.h - * @brief APR-UTIL LDAP - */ -#ifndef APU_LDAP_H -#define APU_LDAP_H - -/** - * @defgroup APR_Util_LDAP LDAP - * @ingroup APR_Util - * @{ - */ - -/* this will be defined if LDAP support was compiled into apr-util */ -#define APR_HAS_LDAP 1 - -/* identify the LDAP toolkit used */ -#define APR_HAS_NETSCAPE_LDAPSDK 0 -#define APR_HAS_SOLARIS_LDAPSDK 0 -#define APR_HAS_NOVELL_LDAPSDK 0 -#define APR_HAS_MOZILLA_LDAPSDK 0 -#define APR_HAS_OPENLDAP_LDAPSDK 0 -#define APR_HAS_MICROSOFT_LDAPSDK 1 -#define APR_HAS_OTHER_LDAPSDK 0 - - -/* - * Handle the case when LDAP is enabled - */ -#if APR_HAS_LDAP - -/* - * The following #defines are DEPRECATED and should not be used for - * anything. They remain to maintain binary compatibility. - * The original code defined the OPENLDAP SDK as present regardless - * of what really was there, which was way bogus. In addition, the - * apr_ldap_url_parse*() functions have been rewritten specifically for - * APR, so the APR_HAS_LDAP_URL_PARSE macro is forced to zero. - */ -#define APR_HAS_LDAP_SSL 1 -#define APR_HAS_LDAP_URL_PARSE 0 - - -/* - * Include the standard LDAP header files. - */ - -#include - - -/* - * Detected standard functions - */ -#define APR_HAS_LDAPSSL_CLIENT_INIT 0 -#define APR_HAS_LDAPSSL_CLIENT_DEINIT 0 -#define APR_HAS_LDAPSSL_ADD_TRUSTED_CERT 0 -#define APR_HAS_LDAP_START_TLS_S 0 -#define APR_HAS_LDAP_SSLINIT 1 -#define APR_HAS_LDAPSSL_INIT 0 -#define APR_HAS_LDAPSSL_INSTALL_ROUTINES 0 - - -/* - * Make sure the secure LDAP port is defined - */ -#ifndef LDAPS_PORT -#define LDAPS_PORT 636 /* ldaps:/// default LDAP over TLS port */ -#endif - - -/* Note: Macros defining const casting has been removed in APR v1.0, - * pending real support for LDAP v2.0 toolkits. - * - * In the mean time, please use an LDAP v3.0 toolkit. - */ -#if LDAP_VERSION_MAX <= 2 -#error Support for LDAP v2.0 toolkits has been removed from apr-util. Please use an LDAP v3.0 toolkit. -#endif - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * This structure allows the C LDAP API error codes to be returned - * along with plain text error messages that explain to us mere mortals - * what really happened. - */ -typedef struct apr_ldap_err_t { - const char *reason; - const char *msg; - int rc; -} apr_ldap_err_t; - -#ifdef __cplusplus -} -#endif - -#include "apr_ldap_url.h" -#include "apr_ldap_init.h" -#include "apr_ldap_option.h" - -/** @} */ -#endif /* APR_HAS_LDAP */ -#endif /* APU_LDAP_H */ diff --git a/libs/apr-util/include/apr_ldap_init.h b/libs/apr-util/include/apr_ldap_init.h deleted file mode 100644 index bd13d070bc..0000000000 --- a/libs/apr-util/include/apr_ldap_init.h +++ /dev/null @@ -1,137 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file apr_ldap_init.h - * @brief APR-UTIL LDAP ldap_init() functions - */ -#ifndef APR_LDAP_INIT_H -#define APR_LDAP_INIT_H - -/** - * @defgroup APR_Util_LDAP LDAP - * @ingroup APR_Util - * @{ - */ - -#include "apr_ldap.h" - -#if APR_HAS_LDAP - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * APR LDAP SSL Initialise function - * - * This function initialises SSL on the underlying LDAP toolkit - * if this is necessary. - * - * If a CA certificate is provided, this is set, however the setting - * of certificates via this method has been deprecated and will be removed in - * APR v2.0. - * - * The apr_ldap_set_option() function with the APR_LDAP_OPT_TLS_CERT option - * should be used instead to set certificates. - * - * If SSL support is not available on this platform, or a problem - * was encountered while trying to set the certificate, the function - * will return APR_EGENERAL. Further LDAP specific error information - * can be found in result_err. - * @param pool The pool to use - * @param cert_auth_file The name of the certificate to use, can be NULL - * @param cert_file_type The type of certificate specified. See the - * apr_ldap_set_option() APR_LDAP_OPT_TLS_CERT option for details. - * @param result_err The returned result - */ -APU_DECLARE(int) apr_ldap_ssl_init(apr_pool_t *pool, - const char *cert_auth_file, - int cert_file_type, - apr_ldap_err_t **result_err); - -/** - * APR LDAP SSL De-Initialise function - * - * This function tears down any SSL certificate setup previously - * set using apr_ldap_ssl_init(). It should be called to clean - * up if a graceful restart of a service is attempted. - * @todo currently we do not check whether apr_ldap_ssl_init() - * has been called first - we probably should. - */ -APU_DECLARE(int) apr_ldap_ssl_deinit(void); - -/** - * APR LDAP initialise function - * - * This function is responsible for initialising an LDAP - * connection in a toolkit independant way. It does the - * job of ldap_init() from the C api. - * - * It handles both the SSL and non-SSL case, and attempts - * to hide the complexity setup from the user. This function - * assumes that any certificate setup necessary has already - * been done. - * - * If SSL or STARTTLS needs to be enabled, and the underlying - * toolkit supports it, the following values are accepted for - * secure: - * - * APR_LDAP_NONE: No encryption - * APR_LDAP_SSL: SSL encryption (ldaps://) - * APR_LDAP_STARTTLS: Force STARTTLS on ldap:// - * @remark The Novell toolkit is only able to set the SSL mode via this - * function. To work around this limitation, set the SSL mode here if no - * per connection client certificates are present, otherwise set secure - * APR_LDAP_NONE here, then set the per connection client certificates, - * followed by setting the SSL mode via apr_ldap_set_option(). As Novell - * does not support per connection client certificates, this problem is - * worked around while still being compatible with other LDAP toolkits. - * @param pool The pool to use - * @param ldap The LDAP handle - * @param hostname The name of the host to connect to. This can be either a - * DNS name, or an IP address. - * @param portno The port to connect to - * @param secure The security mode to set - * @param result_err The returned result - */ -APU_DECLARE(int) apr_ldap_init(apr_pool_t *pool, - LDAP **ldap, - const char *hostname, - int portno, - int secure, - apr_ldap_err_t **result_err); - -/** - * APR LDAP info function - * - * This function returns a string describing the LDAP toolkit - * currently in use. The string is placed inside result_err->reason. - * @param pool The pool to use - * @param result_err The returned result - */ -APU_DECLARE(int) apr_ldap_info(apr_pool_t *pool, - apr_ldap_err_t **result_err); - -#ifdef __cplusplus -} -#endif - -#endif /* APR_HAS_LDAP */ - -/** @} */ - -#endif /* APR_LDAP_URL_H */ diff --git a/libs/apr-util/include/apr_ldap_option.h b/libs/apr-util/include/apr_ldap_option.h deleted file mode 100644 index 489dc0c8b5..0000000000 --- a/libs/apr-util/include/apr_ldap_option.h +++ /dev/null @@ -1,240 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file apr_ldap_option.h - * @brief APR-UTIL LDAP ldap_*_option() functions - */ -#ifndef APR_LDAP_OPTION_H -#define APR_LDAP_OPTION_H - -/** - * @defgroup APR_Util_LDAP LDAP - * @ingroup APR_Util - * @{ - */ - -#include "apr_ldap.h" - -#if APR_HAS_LDAP - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* - * The following defines handle the different TLS certificate - * options available. If these options are missing, APR will try and - * emulate support for this using the deprecated ldap_start_tls_s() - * function. - */ -/** - * Set SSL mode to one of APR_LDAP_NONE, APR_LDAP_SSL, APR_LDAP_STARTTLS - * or APR_LDAP_STOPTLS. - */ -#define APR_LDAP_OPT_TLS 0x6fff -/** - * Set zero or more CA certificates, client certificates or private - * keys globally, or per connection (where supported). - */ -#define APR_LDAP_OPT_TLS_CERT 0x6ffe -/** - * Set the LDAP library to no verify the server certificate. This means - * all servers are considered trusted. - */ -#define APR_LDAP_OPT_VERIFY_CERT 0x6ffd - -/** - * Structures for the apr_set_option() cases - */ - -/** - * APR_LDAP_OPT_TLS_CERT - * - * This structure includes possible options to set certificates on - * system initialisation. Different SDKs have different certificate - * requirements, and to achieve this multiple certificates must be - * specified at once passed as an (apr_array_header_t *). - * - * Netscape: - * Needs the CA cert database (cert7.db), the client cert database (key3.db) - * and the security module file (secmod.db) set at the system initialisation - * time. Three types are supported: APR_LDAP_CERT7_DB, APR_LDAP_KEY3_DB and - * APR_LDAP_SECMOD. - * - * To specify a client cert connection, a certificate nickname needs to be - * provided with a type of APR_LDAP_CERT. - * int ldapssl_enable_clientauth( LDAP *ld, char *keynickname, - * char *keypasswd, char *certnickname ); - * keynickname is currently not used, and should be set to "" - * - * Novell: - * Needs CA certificates and client certificates set at system initialisation - * time. Three types are supported: APR_LDAP_CA*, APR_LDAP_CERT* and - * APR_LDAP_KEY*. - * - * Certificates cannot be specified per connection. - * - * The functions used are: - * ldapssl_add_trusted_cert(serverTrustedRoot, serverTrustedRootEncoding); - * Clients certs and keys are set at system initialisation time with - * int ldapssl_set_client_cert ( - * void *cert, - * int type - * void *password); - * type can be LDAPSSL_CERT_FILETYPE_B64 or LDAPSSL_CERT_FILETYPE_DER - * ldapssl_set_client_private_key(clientPrivateKey, - * clientPrivateKeyEncoding, - * clientPrivateKeyPassword); - * - * OpenSSL: - * Needs one or more CA certificates to be set at system initialisation time - * with a type of APR_LDAP_CA*. - * - * May have one or more client certificates set per connection with a type of - * APR_LDAP_CERT*, and keys with APR_LDAP_KEY*. - */ -/** CA certificate type unknown */ -#define APR_LDAP_CA_TYPE_UNKNOWN 0 -/** binary DER encoded CA certificate */ -#define APR_LDAP_CA_TYPE_DER 1 -/** PEM encoded CA certificate */ -#define APR_LDAP_CA_TYPE_BASE64 2 -/** Netscape/Mozilla cert7.db CA certificate database */ -#define APR_LDAP_CA_TYPE_CERT7_DB 3 -/** Netscape/Mozilla secmod file */ -#define APR_LDAP_CA_TYPE_SECMOD 4 -/** Client certificate type unknown */ -#define APR_LDAP_CERT_TYPE_UNKNOWN 5 -/** binary DER encoded client certificate */ -#define APR_LDAP_CERT_TYPE_DER 6 -/** PEM encoded client certificate */ -#define APR_LDAP_CERT_TYPE_BASE64 7 -/** Netscape/Mozilla key3.db client certificate database */ -#define APR_LDAP_CERT_TYPE_KEY3_DB 8 -/** Netscape/Mozilla client certificate nickname */ -#define APR_LDAP_CERT_TYPE_NICKNAME 9 -/** Private key type unknown */ -#define APR_LDAP_KEY_TYPE_UNKNOWN 10 -/** binary DER encoded private key */ -#define APR_LDAP_KEY_TYPE_DER 11 -/** PEM encoded private key */ -#define APR_LDAP_KEY_TYPE_BASE64 12 -/** PKCS#12 encoded client certificate */ -#define APR_LDAP_CERT_TYPE_PFX 13 -/** PKCS#12 encoded private key */ -#define APR_LDAP_KEY_TYPE_PFX 14 - -/** - * Certificate structure. - * - * This structure is used to store certificate details. An array of - * these structures is passed to apr_ldap_set_option() to set CA - * and client certificates. - * @param type Type of certificate APR_LDAP_*_TYPE_* - * @param path Path, file or nickname of the certificate - * @param password Optional password, can be NULL - */ -typedef struct apr_ldap_opt_tls_cert_t apr_ldap_opt_tls_cert_t; -struct apr_ldap_opt_tls_cert_t { - int type; - const char *path; - const char *password; -}; - -/** - * APR_LDAP_OPT_TLS - * - * This sets the SSL level on the LDAP handle. - * - * Netscape/Mozilla: - * Supports SSL, but not STARTTLS - * SSL is enabled by calling ldapssl_install_routines(). - * - * Novell: - * Supports SSL and STARTTLS. - * SSL is enabled by calling ldapssl_install_routines(). Note that calling - * other ldap functions before ldapssl_install_routines() may cause this - * function to fail. - * STARTTLS is enabled by calling ldapssl_start_tls_s() after calling - * ldapssl_install_routines() (check this). - * - * OpenLDAP: - * Supports SSL and supports STARTTLS, but none of this is documented: - * http://www.openldap.org/lists/openldap-software/200409/msg00618.html - * Documentation for both SSL support and STARTTLS has been deleted from - * the OpenLDAP documentation and website. - */ - -/** No encryption */ -#define APR_LDAP_NONE 0 -/** SSL encryption (ldaps://) */ -#define APR_LDAP_SSL 1 -/** TLS encryption (STARTTLS) */ -#define APR_LDAP_STARTTLS 2 -/** end TLS encryption (STOPTLS) */ -#define APR_LDAP_STOPTLS 3 - -/** - * APR LDAP get option function - * - * This function gets option values from a given LDAP session if - * one was specified. It maps to the native ldap_get_option() function. - * @param pool The pool to use - * @param ldap The LDAP handle - * @param option The LDAP_OPT_* option to return - * @param outvalue The value returned (if any) - * @param result_err The apr_ldap_err_t structure contained detailed results - * of the operation. - */ -APU_DECLARE(int) apr_ldap_get_option(apr_pool_t *pool, - LDAP *ldap, - int option, - void *outvalue, - apr_ldap_err_t **result_err); - -/** - * APR LDAP set option function - * - * This function sets option values to a given LDAP session if - * one was specified. It maps to the native ldap_set_option() function. - * - * Where an option is not supported by an LDAP toolkit, this function - * will try and apply legacy functions to achieve the same effect, - * depending on the platform. - * @param pool The pool to use - * @param ldap The LDAP handle - * @param option The LDAP_OPT_* option to set - * @param invalue The value to set - * @param result_err The apr_ldap_err_t structure contained detailed results - * of the operation. - */ -APU_DECLARE(int) apr_ldap_set_option(apr_pool_t *pool, - LDAP *ldap, - int option, - const void *invalue, - apr_ldap_err_t **result_err); - -#ifdef __cplusplus -} -#endif - -#endif /* APR_HAS_LDAP */ - -/** @} */ - -#endif /* APR_LDAP_OPTION_H */ - diff --git a/libs/apr-util/include/apr_ldap_url.h b/libs/apr-util/include/apr_ldap_url.h deleted file mode 100644 index de59161409..0000000000 --- a/libs/apr-util/include/apr_ldap_url.h +++ /dev/null @@ -1,117 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file apr_ldap_url.h - * @brief APR-UTIL LDAP ldap_init() functions - */ -#ifndef APR_LDAP_URL_H -#define APR_LDAP_URL_H - -/** - * @defgroup APR_Util_LDAP LDAP - * @ingroup APR_Util - * @{ - */ - -#if APR_HAS_LDAP - -#include "apu.h" -#include "apr_pools.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** Structure to access an exploded LDAP URL */ -typedef struct apr_ldap_url_desc_t { - struct apr_ldap_url_desc_t *lud_next; - char *lud_scheme; - char *lud_host; - int lud_port; - char *lud_dn; - char **lud_attrs; - int lud_scope; - char *lud_filter; - char **lud_exts; - int lud_crit_exts; -} apr_ldap_url_desc_t; - -#ifndef APR_LDAP_URL_SUCCESS -#define APR_LDAP_URL_SUCCESS 0x00 /* Success */ -#define APR_LDAP_URL_ERR_MEM 0x01 /* can't allocate memory space */ -#define APR_LDAP_URL_ERR_PARAM 0x02 /* parameter is bad */ -#define APR_LDAP_URL_ERR_BADSCHEME 0x03 /* URL doesn't begin with "ldap[si]://" */ -#define APR_LDAP_URL_ERR_BADENCLOSURE 0x04 /* URL is missing trailing ">" */ -#define APR_LDAP_URL_ERR_BADURL 0x05 /* URL is bad */ -#define APR_LDAP_URL_ERR_BADHOST 0x06 /* host port is bad */ -#define APR_LDAP_URL_ERR_BADATTRS 0x07 /* bad (or missing) attributes */ -#define APR_LDAP_URL_ERR_BADSCOPE 0x08 /* scope string is invalid (or missing) */ -#define APR_LDAP_URL_ERR_BADFILTER 0x09 /* bad or missing filter */ -#define APR_LDAP_URL_ERR_BADEXTS 0x0a /* bad or missing extensions */ -#endif - -/** - * Is this URL an ldap url? ldap:// - * @param url The url to test - */ -APU_DECLARE(int) apr_ldap_is_ldap_url(const char *url); - -/** - * Is this URL an SSL ldap url? ldaps:// - * @param url The url to test - */ -APU_DECLARE(int) apr_ldap_is_ldaps_url(const char *url); - -/** - * Is this URL an ldap socket url? ldapi:// - * @param url The url to test - */ -APU_DECLARE(int) apr_ldap_is_ldapi_url(const char *url); - -/** - * Parse an LDAP URL. - * @param pool The pool to use - * @param url_in The URL to parse - * @param ludpp The structure to return the exploded URL - * @param result_err The result structure of the operation - */ -APU_DECLARE(int) apr_ldap_url_parse_ext(apr_pool_t *pool, - const char *url_in, - apr_ldap_url_desc_t **ludpp, - apr_ldap_err_t **result_err); - -/** - * Parse an LDAP URL. - * @param pool The pool to use - * @param url_in The URL to parse - * @param ludpp The structure to return the exploded URL - * @param result_err The result structure of the operation - */ -APU_DECLARE(int) apr_ldap_url_parse(apr_pool_t *pool, - const char *url_in, - apr_ldap_url_desc_t **ludpp, - apr_ldap_err_t **result_err); - -#ifdef __cplusplus -} -#endif - -#endif /* APR_HAS_LDAP */ - -/** @} */ - -#endif /* APR_LDAP_URL_H */ diff --git a/libs/apr-util/include/apr_md4.h b/libs/apr-util/include/apr_md4.h deleted file mode 100644 index 42d108df9f..0000000000 --- a/libs/apr-util/include/apr_md4.h +++ /dev/null @@ -1,135 +0,0 @@ -/* Copyright 2001-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* This is derived from material copyright RSA Data Security, Inc. - * Their notice is reproduced below in its entirety. - * - * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All - * rights reserved. - * - * License to copy and use this software is granted provided that it - * is identified as the "RSA Data Security, Inc. MD4 Message-Digest - * Algorithm" in all material mentioning or referencing this software - * or this function. - * - * License is also granted to make and use derivative works provided - * that such works are identified as "derived from the RSA Data - * Security, Inc. MD4 Message-Digest Algorithm" in all material - * mentioning or referencing the derived work. - * - * RSA Data Security, Inc. makes no representations concerning either - * the merchantability of this software or the suitability of this - * software for any particular purpose. It is provided "as is" - * without express or implied warranty of any kind. - * - * These notices must be retained in any copies of any part of this - * documentation and/or software. - */ - -#ifndef APR_MD4_H -#define APR_MD4_H - -#include "apu.h" -#include "apr_xlate.h" -/** - * @file apr_md4.h - * @brief APR-UTIL MD4 Library - */ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup APR_Util_MD4 MD4 Library - * @ingroup APR_Util - * @{ - */ - -/** The digestsize for MD4 */ -#define APR_MD4_DIGESTSIZE 16 - -/** @see apr_md4_ctx_t */ -typedef struct apr_md4_ctx_t apr_md4_ctx_t; - -/** MD4 context. */ -struct apr_md4_ctx_t { - /** state (ABCD) */ - apr_uint32_t state[4]; - /** number of bits, modulo 2^64 (lsb first) */ - apr_uint32_t count[2]; - /** input buffer */ - unsigned char buffer[64]; -#if APR_HAS_XLATE - /** translation handle */ - apr_xlate_t *xlate; -#endif -}; - -/** - * MD4 Initialize. Begins an MD4 operation, writing a new context. - * @param context The MD4 context to initialize. - */ -APU_DECLARE(apr_status_t) apr_md4_init(apr_md4_ctx_t *context); - -#if APR_HAS_XLATE -/** - * MDr4 translation setup. Provides the APR translation handle to be used - * for translating the content before calculating the digest. - * @param context The MD4 content to set the translation for. - * @param xlate The translation handle to use for this MD4 context - */ -APU_DECLARE(apr_status_t) apr_md4_set_xlate(apr_md4_ctx_t *context, - apr_xlate_t *xlate); -#else -#define apr_md4_set_xlate(context, xlate) APR_ENOTIMPL -#endif - -/** - * MD4 block update operation. Continue an MD4 message-digest operation, - * processing another message block, and updating the context. - * @param context The MD4 content to update. - * @param input next message block to update - * @param inputLen The length of the next message block - */ -APU_DECLARE(apr_status_t) apr_md4_update(apr_md4_ctx_t *context, - const unsigned char *input, - apr_size_t inputLen); - -/** - * MD4 finalization. Ends an MD4 message-digest operation, writing the - * message digest and zeroing the context - * @param digest The final MD4 digest - * @param context The MD4 content we are finalizing. - */ -APU_DECLARE(apr_status_t) apr_md4_final( - unsigned char digest[APR_MD4_DIGESTSIZE], - apr_md4_ctx_t *context); - -/** - * MD4 digest computation - * @param digest The MD4 digest - * @param input message block to use - * @param inputLen The length of the message block - */ -APU_DECLARE(apr_status_t) apr_md4(unsigned char digest[APR_MD4_DIGESTSIZE], - const unsigned char *input, - apr_size_t inputLen); - -/** @} */ -#ifdef __cplusplus -} -#endif - -#endif /* !APR_MD4_H */ diff --git a/libs/apr-util/include/apr_md5.h b/libs/apr-util/include/apr_md5.h deleted file mode 100644 index c6a306e3c4..0000000000 --- a/libs/apr-util/include/apr_md5.h +++ /dev/null @@ -1,162 +0,0 @@ -/* - * This is work is derived from material Copyright RSA Data Security, Inc. - * - * The RSA copyright statement and Licence for that original material is - * included below. This is followed by the Apache copyright statement and - * licence for the modifications made to that material. - */ - -/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All - rights reserved. - - License to copy and use this software is granted provided that it - is identified as the "RSA Data Security, Inc. MD5 Message-Digest - Algorithm" in all material mentioning or referencing this software - or this function. - - License is also granted to make and use derivative works provided - that such works are identified as "derived from the RSA Data - Security, Inc. MD5 Message-Digest Algorithm" in all material - mentioning or referencing the derived work. - - RSA Data Security, Inc. makes no representations concerning either - the merchantability of this software or the suitability of this - software for any particular purpose. It is provided "as is" - without express or implied warranty of any kind. - - These notices must be retained in any copies of any part of this - documentation and/or software. - */ - -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_MD5_H -#define APR_MD5_H - -#include "apu.h" -#include "apr_xlate.h" - -#ifdef __cplusplus -extern "C" { -#endif -/** - * @file apr_md5.h - * @brief APR MD5 Routines - */ - -/** - * @defgroup APR_MD5 MD5 Routines - * @ingroup APR - * @{ - */ - -/** The MD5 digest size */ -#define APR_MD5_DIGESTSIZE 16 - -/** @see apr_md5_ctx_t */ -typedef struct apr_md5_ctx_t apr_md5_ctx_t; - -/** MD5 context. */ -struct apr_md5_ctx_t { - /** state (ABCD) */ - apr_uint32_t state[4]; - /** number of bits, modulo 2^64 (lsb first) */ - apr_uint32_t count[2]; - /** input buffer */ - unsigned char buffer[64]; - /** translation handle - * ignored if xlate is unsupported - */ - apr_xlate_t *xlate; -}; - -/** - * MD5 Initialize. Begins an MD5 operation, writing a new context. - * @param context The MD5 context to initialize. - */ -APU_DECLARE(apr_status_t) apr_md5_init(apr_md5_ctx_t *context); - -/** - * MD5 translation setup. Provides the APR translation handle to be used - * for translating the content before calculating the digest. - * @param context The MD5 content to set the translation for. - * @param xlate The translation handle to use for this MD5 context - */ -APU_DECLARE(apr_status_t) apr_md5_set_xlate(apr_md5_ctx_t *context, - apr_xlate_t *xlate); - -/** - * MD5 block update operation. Continue an MD5 message-digest operation, - * processing another message block, and updating the context. - * @param context The MD5 content to update. - * @param input next message block to update - * @param inputLen The length of the next message block - */ -APU_DECLARE(apr_status_t) apr_md5_update(apr_md5_ctx_t *context, - const void *input, - apr_size_t inputLen); - -/** - * MD5 finalization. Ends an MD5 message-digest operation, writing the - * message digest and zeroing the context - * @param digest The final MD5 digest - * @param context The MD5 content we are finalizing. - */ -APU_DECLARE(apr_status_t) apr_md5_final(unsigned char digest[APR_MD5_DIGESTSIZE], - apr_md5_ctx_t *context); - -/** - * MD5 in one step - * @param digest The final MD5 digest - * @param input The message block to use - * @param inputLen The length of the message block - */ -APU_DECLARE(apr_status_t) apr_md5(unsigned char digest[APR_MD5_DIGESTSIZE], - const void *input, - apr_size_t inputLen); - -/** - * Encode a password using an MD5 algorithm - * @param password The password to encode - * @param salt The salt to use for the encoding - * @param result The string to store the encoded password in - * @param nbytes The size of the result buffer - */ -APU_DECLARE(apr_status_t) apr_md5_encode(const char *password, const char *salt, - char *result, apr_size_t nbytes); - - -/** - * Validate hashes created by APR-supported algorithms: md5 and sha1. - * hashes created by crypt are supported only on platforms that provide - * crypt(3), so don't rely on that function unless you know that your - * application will be run only on platforms that support it. On platforms - * that don't support crypt(3), this falls back to a clear text string - * comparison. - * @param passwd The password to validate - * @param hash The password to validate against - */ -APU_DECLARE(apr_status_t) apr_password_validate(const char *passwd, - const char *hash); - - -/** @} */ -#ifdef __cplusplus -} -#endif - -#endif /* !APR_MD5_H */ diff --git a/libs/apr-util/include/apr_optional.h b/libs/apr-util/include/apr_optional.h deleted file mode 100644 index 8c9413f9a0..0000000000 --- a/libs/apr-util/include/apr_optional.h +++ /dev/null @@ -1,92 +0,0 @@ -/* Copyright 2001-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_OPTIONAL_H -#define APR_OPTIONAL_H - -#include "apu.h" -/** - * @file apr_optional.h - * @brief APR-UTIL registration of functions exported by modules - */ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup APR_Util_Opt Optional Functions - * @ingroup APR_Util - * - * Typesafe registration and retrieval of functions that may not be present - * (i.e. functions exported by optional modules) - * @{ - */ - -/** - * The type of an optional function. - * @param name The name of the function - */ -#define APR_OPTIONAL_FN_TYPE(name) apr_OFN_##name##_t - -/** - * Declare an optional function. - * @param ret The return type of the function - * @param name The name of the function - * @param args The function arguments (including brackets) - */ -#define APR_DECLARE_OPTIONAL_FN(ret,name,args) \ -typedef ret (APR_OPTIONAL_FN_TYPE(name)) args - -/** - * XXX: This doesn't belong here, then! - * Private function! DO NOT USE! - * @internal - */ - -typedef void (apr_opt_fn_t)(void); -/** @internal */ -APU_DECLARE_NONSTD(void) apr_dynamic_fn_register(const char *szName, - apr_opt_fn_t *pfn); - -/** - * Register an optional function. This can be later retrieved, type-safely, by - * name. Like all global functions, the name must be unique. Note that, - * confusingly but correctly, the function itself can be static! - * @param name The name of the function - */ -#define APR_REGISTER_OPTIONAL_FN(name) do { \ - APR_OPTIONAL_FN_TYPE(name) *apu__opt = name; \ - apr_dynamic_fn_register(#name,(apr_opt_fn_t *)apu__opt); \ -} while (0) - -/** @internal - * Private function! DO NOT USE! - */ -APU_DECLARE(apr_opt_fn_t *) apr_dynamic_fn_retrieve(const char *szName); - -/** - * Retrieve an optional function. Returns NULL if the function is not present. - * @param name The name of the function - */ -#define APR_RETRIEVE_OPTIONAL_FN(name) \ - (APR_OPTIONAL_FN_TYPE(name) *)apr_dynamic_fn_retrieve(#name) - -/** @} */ -#ifdef __cplusplus -} -#endif - -#endif /* APR_OPTIONAL_H */ diff --git a/libs/apr-util/include/apr_optional_hooks.h b/libs/apr-util/include/apr_optional_hooks.h deleted file mode 100644 index 7d01ab0068..0000000000 --- a/libs/apr-util/include/apr_optional_hooks.h +++ /dev/null @@ -1,117 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @file apr_optional_hooks.h - * @brief Apache optional hook functions - */ - - -#ifndef APR_OPTIONAL_HOOK_H -#define APR_OPTIONAL_HOOK_H - -#include "apr_tables.h" - -#ifdef __cplusplus -extern "C" { -#endif -/** - * @defgroup APR_Util_OPT_HOOK Optional Hook Functions - * @ingroup APR_Util_Hook - * @{ - */ -/** - * Function to implemnt the APR_OPTIONAL_HOOK Macro - * @internal - * @see APR_OPTIONAL_HOOK - * - * @param name The name of the hook - * @param pfn A pointer to a function that will be called - * @param aszPre a NULL-terminated array of strings that name modules whose hooks should precede this one - * @param aszSucc a NULL-terminated array of strings that name modules whose hooks should succeed this one - * @param nOrder an integer determining order before honouring aszPre and aszSucc (for example HOOK_MIDDLE) - */ - - -APU_DECLARE(void) apr_optional_hook_add(const char *szName,void (*pfn)(void), - const char * const *aszPre, - const char * const *aszSucc, - int nOrder); - -/** - * Hook to an optional hook. - * - * @param ns The namespace prefix of the hook functions - * @param name The name of the hook - * @param pfn A pointer to a function that will be called - * @param aszPre a NULL-terminated array of strings that name modules whose hooks should precede this one - * @param aszSucc a NULL-terminated array of strings that name modules whose hooks should succeed this one - * @param nOrder an integer determining order before honouring aszPre and aszSucc (for example HOOK_MIDDLE) - */ - -#define APR_OPTIONAL_HOOK(ns,name,pfn,aszPre,aszSucc,nOrder) do { \ - ns##_HOOK_##name##_t *apu__hook = pfn; \ - apr_optional_hook_add(#name,(void (*)(void))apu__hook,aszPre, aszSucc, nOrder); \ -} while (0) - -/** - * @internal - * @param szName - the name of the function - * @return the hook structure for a given hook - */ -APU_DECLARE(apr_array_header_t *) apr_optional_hook_get(const char *szName); - -/** - * Implement an optional hook that runs until one of the functions - * returns something other than OK or DECLINE. - * - * @param ns The namespace prefix of the hook functions - * @param link The linkage declaration prefix of the hook - * @param ret The type of the return value of the hook - * @param ret The type of the return value of the hook - * @param name The name of the hook - * @param args_decl The declaration of the arguments for the hook - * @param args_use The names for the arguments for the hook - * @param ok Success value - * @param decline Decline value - */ -#define APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ns,link,ret,name,args_decl,args_use,ok,decline) \ -link##_DECLARE(ret) ns##_run_##name args_decl \ - { \ - ns##_LINK_##name##_t *pHook; \ - int n; \ - ret rv; \ - apr_array_header_t *pHookArray=apr_optional_hook_get(#name); \ -\ - if(!pHookArray) \ - return ok; \ -\ - pHook=(ns##_LINK_##name##_t *)pHookArray->elts; \ - for(n=0 ; n < pHookArray->nelts ; ++n) \ - { \ - rv=(pHook[n].pFunc)args_use; \ -\ - if(rv != ok && rv != decline) \ - return rv; \ - } \ - return ok; \ - } - -/** @} */ -#ifdef __cplusplus -} -#endif - -#endif /* APR_OPTIONAL_HOOK_H */ diff --git a/libs/apr-util/include/apr_queue.h b/libs/apr-util/include/apr_queue.h deleted file mode 100644 index dcf0c137ed..0000000000 --- a/libs/apr-util/include/apr_queue.h +++ /dev/null @@ -1,154 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_QUEUE_H -#define APR_QUEUE_H - -/** - * @file apr_queue.h - * @brief Thread Safe FIFO bounded queue - * @note Since most implementations of the queue are backed by a condition - * variable implementation, it isn't available on systems without threads. - * Although condition variables are some times available without threads. - */ - -#include "apu.h" -#include "apr_errno.h" -#include "apr_pools.h" - -#if APR_HAS_THREADS - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup APR_Util_FIFO Thread Safe FIFO bounded queue - * @ingroup APR_Util - * @{ - */ - -/** - * opaque structure - */ -typedef struct apr_queue_t apr_queue_t; - -/** - * create a FIFO queue - * @param queue The new queue - * @param queue_capacity maximum size of the queue - * @param a pool to allocate queue from - */ -APU_DECLARE(apr_status_t) apr_queue_create(apr_queue_t **queue, - unsigned int queue_capacity, - apr_pool_t *a); - -/** - * push/add a object to the queue, blocking if the queue is already full - * - * @param queue the queue - * @param data the data - * @returns APR_EINTR the blocking was interrupted (try again) - * @returns APR_EOF the queue has been terminated - * @returns APR_SUCCESS on a successfull push - */ -APU_DECLARE(apr_status_t) apr_queue_push(apr_queue_t *queue, void *data); - -/** - * pop/get an object from the queue, blocking if the queue is already empty - * - * @param queue the queue - * @param data the data - * @returns APR_EINTR the blocking was interrupted (try again) - * @returns APR_EOF if the queue has been terminated - * @returns APR_SUCCESS on a successfull pop - */ -APU_DECLARE(apr_status_t) apr_queue_pop(apr_queue_t *queue, void **data); - -/** - * pop/get an object from the queue, blocking if the queue is already empty - * - * @param queue the queue - * @param data the data - * @param timeout The amount of time in microseconds to wait. This is - * a maximum, not a minimum. If the condition is signaled, we - * will wake up before this time, otherwise the error APR_TIMEUP - * is returned. - * @returns APR_TIMEUP the request timed out - * @returns APR_EINTR the blocking was interrupted (try again) - * @returns APR_EOF if the queue has been terminated - * @returns APR_SUCCESS on a successfull pop - */ -APU_DECLARE(apr_status_t) apr_queue_pop_timeout(apr_queue_t *queue, void **data, apr_interval_time_t timeout); - -/** - * push/add a object to the queue, returning immediatly if the queue is full - * - * @param queue the queue - * @param data the data - * @returns APR_EINTR the blocking operation was interrupted (try again) - * @returns APR_EAGAIN the queue is full - * @returns APR_EOF the queue has been terminated - * @returns APR_SUCCESS on a successfull push - */ -APU_DECLARE(apr_status_t) apr_queue_trypush(apr_queue_t *queue, void *data); - -/** - * pop/get an object to the queue, returning immediatly if the queue is empty - * - * @param queue the queue - * @param data the data - * @returns APR_EINTR the blocking operation was interrupted (try again) - * @returns APR_EAGAIN the queue is empty - * @returns APR_EOF the queue has been terminated - * @returns APR_SUCCESS on a successfull push - */ -APU_DECLARE(apr_status_t) apr_queue_trypop(apr_queue_t *queue, void **data); - -/** - * returns the size of the queue. - * - * @warning this is not threadsafe, and is intended for reporting/monitoring - * of the queue. - * @param queue the queue - * @returns the size of the queue - */ -APU_DECLARE(unsigned int) apr_queue_size(apr_queue_t *queue); - -/** - * interrupt all the threads blocking on this queue. - * - * @param queue the queue - */ -APU_DECLARE(apr_status_t) apr_queue_interrupt_all(apr_queue_t *queue); - -/** - * terminate all queue, sendinging a interupt to all the - * blocking threads - * - * @param queue the queue - */ -APU_DECLARE(apr_status_t) apr_queue_term(apr_queue_t *queue); - -#ifdef __cplusplus -} -#endif - -/** @} */ - -#endif /* APR_HAS_THREADS */ - -#endif /* APRQUEUE_H */ diff --git a/libs/apr-util/include/apr_reslist.h b/libs/apr-util/include/apr_reslist.h deleted file mode 100644 index e6b64846d2..0000000000 --- a/libs/apr-util/include/apr_reslist.h +++ /dev/null @@ -1,144 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_RESLIST_H -#define APR_RESLIST_H - -/** - * @file apr_reslist.h - * @brief APR-UTIL Resource List Routines - */ - -#include "apr.h" -#include "apu.h" -#include "apr_pools.h" -#include "apr_errno.h" -#include "apr_time.h" - -#if APR_HAS_THREADS - -/** - * @defgroup APR_Util_RL Resource List Routines - * @ingroup APR_Util - * @{ - */ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** Opaque resource list object */ -typedef struct apr_reslist_t apr_reslist_t; - -/* Generic constructor called by resource list when it needs to create a - * resource. - * @param resource opaque resource - * @param param flags - * @param pool Pool - */ -typedef apr_status_t (*apr_reslist_constructor)(void **resource, void *params, - apr_pool_t *pool); - -/* Generic destructor called by resource list when it needs to destroy a - * resource. - * @param resource opaque resource - * @param param flags - * @param pool Pool - */ -typedef apr_status_t (*apr_reslist_destructor)(void *resource, void *params, - apr_pool_t *pool); - -/** - * Create a new resource list with the following parameters: - * @param reslist An address where the pointer to the new resource - * list will be stored. - * @param pool The pool to use for local storage and management - * @param min Allowed minimum number of available resources. Zero - * creates new resources only when needed. - * @param smax Resources will be destroyed to meet this maximum - * restriction as they expire. - * @param hmax Absolute maximum limit on the number of total resources. - * @param ttl If non-zero, sets the maximum amount of time a resource - * may be available while exceeding the soft limit. - * @param con Constructor routine that is called to create a new resource. - * @param de Destructor routine that is called to destroy an expired resource. - * @param params Passed to constructor and deconstructor - * @param pool The pool from which to create this resoure list. Also the - * same pool that is passed to the constructor and destructor - * routines. - */ -APU_DECLARE(apr_status_t) apr_reslist_create(apr_reslist_t **reslist, - int min, int smax, int hmax, - apr_interval_time_t ttl, - apr_reslist_constructor con, - apr_reslist_destructor de, - void *params, - apr_pool_t *pool); - -/** - * Destroy the given resource list and all resources controlled by - * this list. - * FIXME: Should this block until all resources become available, - * or maybe just destroy all the free ones, or maybe destroy - * them even though they might be in use by something else? - * Currently it will abort if there are resources that haven't - * been released, so there is an assumption that all resources - * have been released to the list before calling this function. - * @param reslist The reslist to destroy - */ -APU_DECLARE(apr_status_t) apr_reslist_destroy(apr_reslist_t *reslist); - -/** - * Retrieve a resource from the list, creating a new one if necessary. - * If we have met our maximum number of resources, we will block - * until one becomes available. - */ -APU_DECLARE(apr_status_t) apr_reslist_acquire(apr_reslist_t *reslist, - void **resource); - -/** - * Return a resource back to the list of available resources. - */ -APU_DECLARE(apr_status_t) apr_reslist_release(apr_reslist_t *reslist, - void *resource); - -/** - * Set the timeout the acquire will wait for a free resource - * when the maximum number of resources is exceeded. - * @param reslist The resource list. - * @param timeout Timeout to wait. The zero waits forewer. - */ -APU_DECLARE(void) apr_reslist_timeout_set(apr_reslist_t *reslist, - apr_interval_time_t timeout); - -/** - * Invalidate a resource in the pool - e.g. a database connection - * that returns a "lost connection" error and can't be restored. - * Use this instead of apr_reslist_release if the resource is bad. - */ -APU_DECLARE(apr_status_t) apr_reslist_invalidate(apr_reslist_t *reslist, - void *resource); - - -#ifdef __cplusplus -} -#endif - -/** @} */ - -#endif /* APR_HAS_THREADS */ - -#endif /* ! APR_RESLIST_H */ diff --git a/libs/apr-util/include/apr_rmm.h b/libs/apr-util/include/apr_rmm.h deleted file mode 100644 index a1f0d67605..0000000000 --- a/libs/apr-util/include/apr_rmm.h +++ /dev/null @@ -1,137 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_RMM_H -#define APR_RMM_H -/** - * @file apr_rmm.h - * @brief APR-UTIL Relocatable Memory Management Routines - */ -/** - * @defgroup APR_Util_RMM Relocatable Memory Management Routines - * @ingroup APR_Util - * @{ - */ - -#include "apr.h" -#include "apr_pools.h" -#include "apr_errno.h" -#include "apu.h" -#include "apr_anylock.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** Structure to access Relocatable, Managed Memory */ -typedef struct apr_rmm_t apr_rmm_t; - -/** Fundamental allocation unit, within a specific apr_rmm_t */ -typedef apr_size_t apr_rmm_off_t; - -/** - * Initialize a relocatable memory block to be managed by the apr_rmm API. - * @param rmm The relocatable memory block - * @param lock An apr_anylock_t of the appropriate type of lock, or NULL - * if no locking is required. - * @param membuf The block of relocatable memory to be managed - * @param memsize The size of relocatable memory block to be managed - * @param cont The pool to use for local storage and management - * @remark Both @param membuf and @param memsize must be aligned - * (for instance using APR_ALIGN_DEFAULT). - */ -APU_DECLARE(apr_status_t) apr_rmm_init(apr_rmm_t **rmm, apr_anylock_t *lock, - void *membuf, apr_size_t memsize, - apr_pool_t *cont); - -/** - * Destroy a managed memory block. - * @param rmm The relocatable memory block to destroy - */ -APU_DECLARE(apr_status_t) apr_rmm_destroy(apr_rmm_t *rmm); - -/** - * Attach to a relocatable memory block already managed by the apr_rmm API. - * @param rmm The relocatable memory block - * @param lock An apr_anylock_t of the appropriate type of lock - * @param membuf The block of relocatable memory already under management - * @param cont The pool to use for local storage and management - */ -APU_DECLARE(apr_status_t) apr_rmm_attach(apr_rmm_t **rmm, apr_anylock_t *lock, - void *membuf, apr_pool_t *cont); - -/** - * Detach from the managed block of memory. - * @param rmm The relocatable memory block to detach from - */ -APU_DECLARE(apr_status_t) apr_rmm_detach(apr_rmm_t *rmm); - -/** - * Allocate memory from the block of relocatable memory. - * @param rmm The relocatable memory block - * @param reqsize How much memory to allocate - */ -APU_DECLARE(apr_rmm_off_t) apr_rmm_malloc(apr_rmm_t *rmm, apr_size_t reqsize); - -/** - * Realloc memory from the block of relocatable memory. - * @param rmm The relocatable memory block - * @param entity The memory allocation to realloc - * @param reqsize The new size - */ -APU_DECLARE(apr_rmm_off_t) apr_rmm_realloc(apr_rmm_t *rmm, void *entity, apr_size_t reqsize); - -/** - * Allocate memory from the block of relocatable memory and initialize it to zero. - * @param rmm The relocatable memory block - * @param reqsize How much memory to allocate - */ -APU_DECLARE(apr_rmm_off_t) apr_rmm_calloc(apr_rmm_t *rmm, apr_size_t reqsize); - -/** - * Free allocation returned by apr_rmm_malloc or apr_rmm_calloc. - * @param rmm The relocatable memory block - * @param entity The memory allocation to free - */ -APU_DECLARE(apr_status_t) apr_rmm_free(apr_rmm_t *rmm, apr_rmm_off_t entity); - -/** - * Retrieve the physical address of a relocatable allocation of memory - * @param rmm The relocatable memory block - * @param entity The memory allocation to free - * @return address The address, aligned with APR_ALIGN_DEFAULT. - */ -APU_DECLARE(void *) apr_rmm_addr_get(apr_rmm_t *rmm, apr_rmm_off_t entity); - -/** - * Compute the offset of a relocatable allocation of memory - * @param rmm The relocatable memory block - * @param entity The physical address to convert to an offset - */ -APU_DECLARE(apr_rmm_off_t) apr_rmm_offset_get(apr_rmm_t *rmm, void *entity); - -/** - * Compute the required overallocation of memory needed to fit n allocs - * @param n The number of alloc/calloc regions desired - */ -APU_DECLARE(apr_size_t) apr_rmm_overhead_get(int n); - -#ifdef __cplusplus -} -#endif -/** @} */ -#endif /* ! APR_RMM_H */ - diff --git a/libs/apr-util/include/apr_sdbm.h b/libs/apr-util/include/apr_sdbm.h deleted file mode 100644 index 7fcf7f6e53..0000000000 --- a/libs/apr-util/include/apr_sdbm.h +++ /dev/null @@ -1,175 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * sdbm - ndbm work-alike hashed database library - * based on Per-Ake Larson's Dynamic Hashing algorithms. BIT 18 (1978). - * author: oz@nexus.yorku.ca - * status: ex-public domain - */ - -#ifndef APR_SDBM_H -#define APR_SDBM_H - -#include "apu.h" -#include "apr_errno.h" -#include "apr_file_io.h" /* for apr_fileperms_t */ - -/** - * @file apr_sdbm.h - * @brief apr-util SDBM library - */ -/** - * @defgroup APR_Util_DBM_SDBM SDBM library - * @ingroup APR_Util_DBM - * @{ - */ - -/** - * Structure for referencing an sdbm - */ -typedef struct apr_sdbm_t apr_sdbm_t; - -/** - * Structure for referencing the datum record within an sdbm - */ -typedef struct { - /** pointer to the data stored/retrieved */ - char *dptr; - /** size of data */ - int dsize; -} apr_sdbm_datum_t; - -/* The extensions used for the database files */ -/** SDBM Directory file extension */ -#define APR_SDBM_DIRFEXT ".dir" -/** SDBM page file extension */ -#define APR_SDBM_PAGFEXT ".pag" - -/* flags to sdbm_store */ -#define APR_SDBM_INSERT 0 /**< Insert */ -#define APR_SDBM_REPLACE 1 /**< Replace */ -#define APR_SDBM_INSERTDUP 2 /**< Insert with duplicates */ - -/** - * Open an sdbm database by file name - * @param db The newly opened database - * @param name The sdbm file to open - * @param mode The flag values (APR_READ and APR_BINARY flags are implicit) - *
- *           APR_WRITE          open for read-write access
- *           APR_CREATE         create the sdbm if it does not exist
- *           APR_TRUNCATE       empty the contents of the sdbm
- *           APR_EXCL           fail for APR_CREATE if the file exists
- *           APR_DELONCLOSE     delete the sdbm when closed
- *           APR_SHARELOCK      support locking across process/machines
- * 
- * @param perms Permissions to apply to if created - * @param p The pool to use when creating the sdbm - * @remark The sdbm name is not a true file name, as sdbm appends suffixes - * for seperate data and index files. - */ -APU_DECLARE(apr_status_t) apr_sdbm_open(apr_sdbm_t **db, const char *name, - apr_int32_t mode, - apr_fileperms_t perms, apr_pool_t *p); - -/** - * Close an sdbm file previously opened by apr_sdbm_open - * @param db The database to close - */ -APU_DECLARE(apr_status_t) apr_sdbm_close(apr_sdbm_t *db); - -/** - * Lock an sdbm database for concurency of multiple operations - * @param db The database to lock - * @param type The lock type - *
- *           APR_FLOCK_SHARED
- *           APR_FLOCK_EXCLUSIVE
- * 
- * @remark Calls to apr_sdbm_lock may be nested. All apr_sdbm functions - * perform implicit locking. Since an APR_FLOCK_SHARED lock cannot be - * portably promoted to an APR_FLOCK_EXCLUSIVE lock, apr_sdbm_store and - * apr_sdbm_delete calls will fail if an APR_FLOCK_SHARED lock is held. - * The apr_sdbm_lock call requires the database to be opened with the - * APR_SHARELOCK mode value. - */ -APU_DECLARE(apr_status_t) apr_sdbm_lock(apr_sdbm_t *db, int type); - -/** - * Release an sdbm lock previously aquired by apr_sdbm_lock - * @param db The database to unlock - */ -APU_DECLARE(apr_status_t) apr_sdbm_unlock(apr_sdbm_t *db); - -/** - * Fetch an sdbm record value by key - * @param db The database - * @param value The value datum retrieved for this record - * @param key The key datum to find this record - */ -APU_DECLARE(apr_status_t) apr_sdbm_fetch(apr_sdbm_t *db, - apr_sdbm_datum_t *value, - apr_sdbm_datum_t key); - -/** - * Store an sdbm record value by key - * @param db The database - * @param key The key datum to store this record by - * @param value The value datum to store in this record - * @param opt The method used to store the record - *
- *           APR_SDBM_INSERT     return an error if the record exists
- *           APR_SDBM_REPLACE    overwrite any existing record for key
- * 
- */ -APU_DECLARE(apr_status_t) apr_sdbm_store(apr_sdbm_t *db, apr_sdbm_datum_t key, - apr_sdbm_datum_t value, int opt); - -/** - * Delete an sdbm record value by key - * @param db The database - * @param key The key datum of the record to delete - * @remark It is not an error to delete a non-existent record. - */ -APU_DECLARE(apr_status_t) apr_sdbm_delete(apr_sdbm_t *db, - const apr_sdbm_datum_t key); - -/** - * Retrieve the first record key from a dbm - * @param db The database - * @param key The key datum of the first record - * @remark The keys returned are not ordered. To traverse the list of keys - * for an sdbm opened with APR_SHARELOCK, the caller must use apr_sdbm_lock - * prior to retrieving the first record, and hold the lock until after the - * last call to apr_sdbm_nextkey. - */ -APU_DECLARE(apr_status_t) apr_sdbm_firstkey(apr_sdbm_t *db, apr_sdbm_datum_t *key); - -/** - * Retrieve the next record key from an sdbm - * @param db The database - * @param key The key datum of the next record - */ -APU_DECLARE(apr_status_t) apr_sdbm_nextkey(apr_sdbm_t *db, apr_sdbm_datum_t *key); - -/** - * Returns true if the sdbm database opened for read-only access - * @param db The database to test - */ -APU_DECLARE(int) apr_sdbm_rdonly(apr_sdbm_t *db); -/** @} */ -#endif /* APR_SDBM_H */ diff --git a/libs/apr-util/include/apr_sha1.h b/libs/apr-util/include/apr_sha1.h deleted file mode 100644 index 1ad506556d..0000000000 --- a/libs/apr-util/include/apr_sha1.h +++ /dev/null @@ -1,121 +0,0 @@ -/* Copyright 2001-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* NIST Secure Hash Algorithm - * heavily modified by Uwe Hollerbach uh@alumni.caltech edu - * from Peter C. Gutmann's implementation as found in - * Applied Cryptography by Bruce Schneier - * This code is hereby placed in the public domain - */ - -#ifndef APR_SHA1_H -#define APR_SHA1_H - -#include "apu.h" -#include "apr_general.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @file apr_sha1.h - * @brief APR-UTIL SHA1 library - */ - -/** size of the SHA1 DIGEST */ -#define APR_SHA1_DIGESTSIZE 20 - -/** - * Define the Magic String prefix that identifies a password as being - * hashed using our algorithm. - */ -#define APR_SHA1PW_ID "{SHA}" - -/** length of the SHA Password */ -#define APR_SHA1PW_IDLEN 5 - -/** @see apr_sha1_ctx_t */ -typedef struct apr_sha1_ctx_t apr_sha1_ctx_t; - -/** - * SHA1 context structure - */ -struct apr_sha1_ctx_t { - /** message digest */ - apr_uint32_t digest[5]; - /** 64-bit bit counts */ - apr_uint32_t count_lo, count_hi; - /** SHA data buffer */ - apr_uint32_t data[16]; - /** unprocessed amount in data */ - int local; -}; - -/** - * Provide a means to SHA1 crypt/encode a plaintext password in a way which - * makes password file compatible with those commonly use in netscape web - * and ldap installations. - * @param clear The plaintext password - * @param len The length of the plaintext password - * @param out The encrypted/encoded password - * @note SHA1 support is useful for migration purposes, but is less - * secure than Apache's password format, since Apache's (MD5) - * password format uses a random eight character salt to generate - * one of many possible hashes for the same password. Netscape - * uses plain SHA1 without a salt, so the same password - * will always generate the same hash, making it easier - * to break since the search space is smaller. - */ -APU_DECLARE(void) apr_sha1_base64(const char *clear, int len, char *out); - -/** - * Initialize the SHA digest - * @param context The SHA context to initialize - */ -APU_DECLARE(void) apr_sha1_init(apr_sha1_ctx_t *context); - -/** - * Update the SHA digest - * @param context The SHA1 context to update - * @param input The buffer to add to the SHA digest - * @param inputLen The length of the input buffer - */ -APU_DECLARE(void) apr_sha1_update(apr_sha1_ctx_t *context, const char *input, - unsigned int inputLen); - -/** - * Update the SHA digest with binary data - * @param context The SHA1 context to update - * @param input The buffer to add to the SHA digest - * @param inputLen The length of the input buffer - */ -APU_DECLARE(void) apr_sha1_update_binary(apr_sha1_ctx_t *context, - const unsigned char *input, - unsigned int inputLen); - -/** - * Finish computing the SHA digest - * @param digest the output buffer in which to store the digest - * @param context The context to finalize - */ -APU_DECLARE(void) apr_sha1_final(unsigned char digest[APR_SHA1_DIGESTSIZE], - apr_sha1_ctx_t *context); - -#ifdef __cplusplus -} -#endif - -#endif /* APR_SHA1_H */ diff --git a/libs/apr-util/include/apr_strmatch.h b/libs/apr-util/include/apr_strmatch.h deleted file mode 100644 index 4753318b75..0000000000 --- a/libs/apr-util/include/apr_strmatch.h +++ /dev/null @@ -1,81 +0,0 @@ -/* Copyright 2002-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_STRMATCH_H -#define APR_STRMATCH_H -/** - * @file apr_strmatch.h - * @brief APR-UTIL string matching routines - */ - -#include "apu.h" -#include "apr_pools.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup APR_Util_StrMatch String matching routines - * @ingroup APR_Util - * @{ - */ - -/** @see apr_strmatch_pattern */ -typedef struct apr_strmatch_pattern apr_strmatch_pattern; - -/** - * Precompiled search pattern - */ -struct apr_strmatch_pattern { - /** Function called to compare */ - const char *(*compare)(const apr_strmatch_pattern *this_pattern, - const char *s, apr_size_t slen); - const char *pattern; /**< Current pattern */ - apr_size_t length; /**< Current length */ - void *context; /**< hook to add precomputed metadata */ -}; - -#if defined(DOXYGEN) -/** - * Search for a precompiled pattern within a string - * @param pattern The pattern - * @param s The string in which to search for the pattern - * @param slen The length of s (excluding null terminator) - * @return A pointer to the first instance of the pattern in s, or - * NULL if not found - */ -APU_DECLARE(const char *) apr_strmatch(const apr_strmatch_pattern *pattern, - const char *s, apr_size_t slen); -#else -#define apr_strmatch(pattern, s, slen) (*((pattern)->compare))((pattern), (s), (slen)) -#endif - -/** - * Precompile a pattern for matching using the Boyer-Moore-Horspool algorithm - * @param p The pool from which to allocate the pattern - * @param s The pattern string - * @param case_sensitive Whether the matching should be case-sensitive - * @return a pointer to the compiled pattern, or NULL if compilation fails - */ -APU_DECLARE(const apr_strmatch_pattern *) apr_strmatch_precompile(apr_pool_t *p, const char *s, int case_sensitive); - -/** @} */ -#ifdef __cplusplus -} -#endif - -#endif /* !APR_STRMATCH_H */ diff --git a/libs/apr-util/include/apr_uri.h b/libs/apr-util/include/apr_uri.h deleted file mode 100644 index 82a86b24e5..0000000000 --- a/libs/apr-util/include/apr_uri.h +++ /dev/null @@ -1,178 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * apr_uri.h: External Interface of apr_uri.c - */ - -/** - * @file apr_uri.h - * @brief APR-UTIL URI Routines - */ - -#ifndef APR_URI_H -#define APR_URI_H - -#include "apu.h" - -#include "apr_network_io.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup APR_Util_URI URI - * @ingroup APR_Util - * @{ - */ - -#define APR_URI_FTP_DEFAULT_PORT 21 /**< default FTP port */ -#define APR_URI_SSH_DEFAULT_PORT 22 /**< default SSH port */ -#define APR_URI_TELNET_DEFAULT_PORT 23 /**< default telnet port */ -#define APR_URI_GOPHER_DEFAULT_PORT 70 /**< default Gopher port */ -#define APR_URI_HTTP_DEFAULT_PORT 80 /**< default HTTP port */ -#define APR_URI_POP_DEFAULT_PORT 110 /**< default POP port */ -#define APR_URI_NNTP_DEFAULT_PORT 119 /**< default NNTP port */ -#define APR_URI_IMAP_DEFAULT_PORT 143 /**< default IMAP port */ -#define APR_URI_PROSPERO_DEFAULT_PORT 191 /**< default Prospero port */ -#define APR_URI_WAIS_DEFAULT_PORT 210 /**< default WAIS port */ -#define APR_URI_LDAP_DEFAULT_PORT 389 /**< default LDAP port */ -#define APR_URI_HTTPS_DEFAULT_PORT 443 /**< default HTTPS port */ -#define APR_URI_RTSP_DEFAULT_PORT 554 /**< default RTSP port */ -#define APR_URI_SNEWS_DEFAULT_PORT 563 /**< default SNEWS port */ -#define APR_URI_ACAP_DEFAULT_PORT 674 /**< default ACAP port */ -#define APR_URI_NFS_DEFAULT_PORT 2049 /**< default NFS port */ -#define APR_URI_TIP_DEFAULT_PORT 3372 /**< default TIP port */ -#define APR_URI_SIP_DEFAULT_PORT 5060 /**< default SIP port */ - -/** Flags passed to unparse_uri_components(): */ -/** suppress "scheme://user\@site:port" */ -#define APR_URI_UNP_OMITSITEPART (1U<<0) -/** Just omit user */ -#define APR_URI_UNP_OMITUSER (1U<<1) -/** Just omit password */ -#define APR_URI_UNP_OMITPASSWORD (1U<<2) -/** omit "user:password\@" part */ -#define APR_URI_UNP_OMITUSERINFO (APR_URI_UNP_OMITUSER | \ - APR_URI_UNP_OMITPASSWORD) -/** Show plain text password (default: show XXXXXXXX) */ -#define APR_URI_UNP_REVEALPASSWORD (1U<<3) -/** Show "scheme://user\@site:port" only */ -#define APR_URI_UNP_OMITPATHINFO (1U<<4) -/** Omit the "?queryarg" from the path */ -#define APR_URI_UNP_OMITQUERY (1U<<5) - -/** @see apr_uri_t */ -typedef struct apr_uri_t apr_uri_t; - -/** - * A structure to encompass all of the fields in a uri - */ -struct apr_uri_t { - /** scheme ("http"/"ftp"/...) */ - char *scheme; - /** combined [user[:password]\@]host[:port] */ - char *hostinfo; - /** user name, as in http://user:passwd\@host:port/ */ - char *user; - /** password, as in http://user:passwd\@host:port/ */ - char *password; - /** hostname from URI (or from Host: header) */ - char *hostname; - /** port string (integer representation is in "port") */ - char *port_str; - /** the request path (or "/" if only scheme://host was given) */ - char *path; - /** Everything after a '?' in the path, if present */ - char *query; - /** Trailing "#fragment" string, if present */ - char *fragment; - - /** structure returned from gethostbyname() */ - struct hostent *hostent; - - /** The port number, numeric, valid only if port_str != NULL */ - apr_port_t port; - - /** has the structure been initialized */ - unsigned is_initialized:1; - - /** has the DNS been looked up yet */ - unsigned dns_looked_up:1; - /** has the dns been resolved yet */ - unsigned dns_resolved:1; -}; - -/* apr_uri.c */ -/** - * Return the default port for a given scheme. The schemes recognized are - * http, ftp, https, gopher, wais, nntp, snews, and prospero - * @param scheme_str The string that contains the current scheme - * @return The default port for this scheme - */ -APU_DECLARE(apr_port_t) apr_uri_port_of_scheme(const char *scheme_str); - -/** - * Unparse a apr_uri_t structure to an URI string. Optionally - * suppress the password for security reasons. - * @param p The pool to allocate out of - * @param uptr All of the parts of the uri - * @param flags How to unparse the uri. One of: - *
- *    APR_URI_UNP_OMITSITEPART        Suppress "scheme://user\@site:port" 
- *    APR_URI_UNP_OMITUSER            Just omit user 
- *    APR_URI_UNP_OMITPASSWORD        Just omit password 
- *    APR_URI_UNP_OMITUSERINFO        Omit "user:password\@" part
- *    APR_URI_UNP_REVEALPASSWORD      Show plain text password (default: show XXXXXXXX)
- *    APR_URI_UNP_OMITPATHINFO        Show "scheme://user\@site:port" only 
- *    APR_URI_UNP_OMITQUERY           Omit "?queryarg" or "#fragment" 
- * 
- * @return The uri as a string - */ -APU_DECLARE(char *) apr_uri_unparse(apr_pool_t *p, - const apr_uri_t *uptr, - unsigned flags); - -/** - * Parse a given URI, fill in all supplied fields of a apr_uri_t - * structure. This eliminates the necessity of extracting host, port, - * path, query info repeatedly in the modules. - * @param p The pool to allocate out of - * @param uri The uri to parse - * @param uptr The apr_uri_t to fill out - * @return APR_SUCCESS for success or error code - */ -APU_DECLARE(apr_status_t) apr_uri_parse(apr_pool_t *p, const char *uri, - apr_uri_t *uptr); - -/** - * Special case for CONNECT parsing: it comes with the hostinfo part only - * @param p The pool to allocate out of - * @param hostinfo The hostinfo string to parse - * @param uptr The apr_uri_t to fill out - * @return APR_SUCCESS for success or error code - */ -APU_DECLARE(apr_status_t) apr_uri_parse_hostinfo(apr_pool_t *p, - const char *hostinfo, - apr_uri_t *uptr); - -/** @} */ -#ifdef __cplusplus -} -#endif - -#endif /* APR_URI_H */ diff --git a/libs/apr-util/include/apr_uuid.h b/libs/apr-util/include/apr_uuid.h deleted file mode 100644 index 820d7409db..0000000000 --- a/libs/apr-util/include/apr_uuid.h +++ /dev/null @@ -1,76 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file apr_uuid.h - * @brief APR UUID library - */ -#ifndef APR_UUID_H -#define APR_UUID_H - -#include "apu.h" -#include "apr_errno.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup APR_UUID UUID Handling - * @ingroup APR - * @{ - */ - -/** - * we represent a UUID as a block of 16 bytes. - */ - -typedef struct { - unsigned char data[16]; /**< the actual UUID */ -} apr_uuid_t; - -/** UUIDs are formatted as: 00112233-4455-6677-8899-AABBCCDDEEFF */ -#define APR_UUID_FORMATTED_LENGTH 36 - - -/** - * Generate and return a (new) UUID - * @param uuid The resulting UUID - */ -APU_DECLARE(void) apr_uuid_get(apr_uuid_t *uuid); - -/** - * Format a UUID into a string, following the standard format - * @param buffer The buffer to place the formatted UUID string into. It must - * be at least APR_UUID_FORMATTED_LENGTH + 1 bytes long to hold - * the formatted UUID and a null terminator - * @param uuid The UUID to format - */ -APU_DECLARE(void) apr_uuid_format(char *buffer, const apr_uuid_t *uuid); - -/** - * Parse a standard-format string into a UUID - * @param uuid The resulting UUID - * @param uuid_str The formatted UUID - */ -APU_DECLARE(apr_status_t) apr_uuid_parse(apr_uuid_t *uuid, const char *uuid_str); - -/** @} */ -#ifdef __cplusplus -} -#endif - -#endif /* APR_UUID_H */ diff --git a/libs/apr-util/include/apr_xlate.h b/libs/apr-util/include/apr_xlate.h deleted file mode 100644 index 19402a76cd..0000000000 --- a/libs/apr-util/include/apr_xlate.h +++ /dev/null @@ -1,163 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_XLATE_H -#define APR_XLATE_H - -#include "apu.h" -#include "apr_pools.h" -#include "apr_errno.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @file apr_xlate.h - * @brief APR I18N translation library - */ - -/** - * @defgroup APR_XLATE I18N translation library - * @ingroup APR - * @{ - */ -/** Opaque translation buffer */ -typedef struct apr_xlate_t apr_xlate_t; - -/** - * Set up for converting text from one charset to another. - * @param convset The handle to be filled in by this function - * @param topage The name of the target charset - * @param frompage The name of the source charset - * @param pool The pool to use - * @remark - * Specify APR_DEFAULT_CHARSET for one of the charset - * names to indicate the charset of the source code at - * compile time. This is useful if there are literal - * strings in the source code which must be translated - * according to the charset of the source code. - * APR_DEFAULT_CHARSET is not useful if the source code - * of the caller was not encoded in the same charset as - * APR at compile time. - * - * @remark - * Specify APR_LOCALE_CHARSET for one of the charset - * names to indicate the charset of the current locale. - * - * @remark - * Return APR_EINVAL if unable to procure a convset, or APR_ENOTIMPL - * if charset transcoding is not available in this instance of - * apr-util at all (i.e., APR_HAS_XLATE is undefined). - */ -APU_DECLARE(apr_status_t) apr_xlate_open(apr_xlate_t **convset, - const char *topage, - const char *frompage, - apr_pool_t *pool); - -/** - * This is to indicate the charset of the sourcecode at compile time - * names to indicate the charset of the source code at - * compile time. This is useful if there are literal - * strings in the source code which must be translated - * according to the charset of the source code. - */ -#define APR_DEFAULT_CHARSET (const char *)0 -/** - * To indicate charset names of the current locale - */ -#define APR_LOCALE_CHARSET (const char *)1 - -/** - * Find out whether or not the specified conversion is single-byte-only. - * @param convset The handle allocated by apr_xlate_open, specifying the - * parameters of conversion - * @param onoff Output: whether or not the conversion is single-byte-only - * @remark - * Return APR_ENOTIMPL if charset transcoding is not available - * in this instance of apr-util (i.e., APR_HAS_XLATE is undefined). - */ -APU_DECLARE(apr_status_t) apr_xlate_sb_get(apr_xlate_t *convset, int *onoff); - -/** - * Convert a buffer of text from one codepage to another. - * @param convset The handle allocated by apr_xlate_open, specifying - * the parameters of conversion - * @param inbuf The address of the source buffer - * @param inbytes_left Input: the amount of input data to be translated - * Output: the amount of input data not yet translated - * @param outbuf The address of the destination buffer - * @param outbytes_left Input: the size of the output buffer - * Output: the amount of the output buffer not yet used - * @remark - * Returns APR_ENOTIMPL if charset transcoding is not available - * in this instance of apr-util (i.e., APR_HAS_XLATE is undefined). - * Returns APR_INCOMPLETE if the input buffer ends in an incomplete - * multi-byte character. - * - * To correctly terminate the output buffer for some multi-byte - * character set encodings, a final call must be made to this function - * after the complete input string has been converted, passing - * the inbuf and inbytes_left parameters as NULL. (Note that this - * mode only works from version 1.1.0 onwards) - */ -APU_DECLARE(apr_status_t) apr_xlate_conv_buffer(apr_xlate_t *convset, - const char *inbuf, - apr_size_t *inbytes_left, - char *outbuf, - apr_size_t *outbytes_left); - -/* @see apr_file_io.h the comment in apr_file_io.h about this hack */ -#ifdef APR_NOT_DONE_YET -/** - * The purpose of apr_xlate_conv_char is to translate one character - * at a time. This needs to be written carefully so that it works - * with double-byte character sets. - * @param convset The handle allocated by apr_xlate_open, specifying the - * parameters of conversion - * @param inchar The character to convert - * @param outchar The converted character - */ -APU_DECLARE(apr_status_t) apr_xlate_conv_char(apr_xlate_t *convset, - char inchar, char outchar); -#endif - -/** - * Convert a single-byte character from one charset to another. - * @param convset The handle allocated by apr_xlate_open, specifying the - * parameters of conversion - * @param inchar The single-byte character to convert. - * @warning This only works when converting between single-byte character sets. - * -1 will be returned if the conversion can't be performed. - */ -APU_DECLARE(apr_int32_t) apr_xlate_conv_byte(apr_xlate_t *convset, - unsigned char inchar); - -/** - * Close a codepage translation handle. - * @param convset The codepage translation handle to close - * @remark - * Return APR_ENOTIMPL if charset transcoding is not available - * in this instance of apr-util (i.e., APR_HAS_XLATE is undefined). - */ -APU_DECLARE(apr_status_t) apr_xlate_close(apr_xlate_t *convset); - -/** @} */ -#ifdef __cplusplus -} -#endif - -#endif /* ! APR_XLATE_H */ diff --git a/libs/apr-util/include/apr_xml.h b/libs/apr-util/include/apr_xml.h deleted file mode 100644 index ab184e7a7e..0000000000 --- a/libs/apr-util/include/apr_xml.h +++ /dev/null @@ -1,356 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @file apr_xml.h - * @brief APR-UTIL XML Library - */ -#ifndef APR_XML_H -#define APR_XML_H - -/** - * @defgroup APR_Util_XML XML - * @ingroup APR_Util - * @{ - */ -#include "apr_pools.h" -#include "apr_tables.h" -#include "apr_file_io.h" - -#include "apu.h" -#if APR_CHARSET_EBCDIC -#include "apr_xlate.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @package Apache XML library - */ - -/* -------------------------------------------------------------------- */ - -/* ### these will need to move at some point to a more logical spot */ - -/** @see apr_text */ -typedef struct apr_text apr_text; - -/** Structure to keep a linked list of pieces of text */ -struct apr_text { - /** The current piece of text */ - const char *text; - /** a pointer to the next piece of text */ - struct apr_text *next; -}; - -/** @see apr_text_header */ -typedef struct apr_text_header apr_text_header; - -/** A list of pieces of text */ -struct apr_text_header { - /** The first piece of text in the list */ - apr_text *first; - /** The last piece of text in the list */ - apr_text *last; -}; - -/** - * Append a piece of text to the end of a list - * @param p The pool to allocate out of - * @param hdr The text header to append to - * @param text The new text to append - */ -APU_DECLARE(void) apr_text_append(apr_pool_t *p, apr_text_header *hdr, - const char *text); - - -/* -------------------------------------------------------------------- -** -** XML PARSING -*/ - -/* -** Qualified namespace values -** -** APR_XML_NS_DAV_ID -** We always insert the "DAV:" namespace URI at the head of the -** namespace array. This means that it will always be at ID==0, -** making it much easier to test for. -** -** APR_XML_NS_NONE -** This special ID is used for two situations: -** -** 1) The namespace prefix begins with "xml" (and we do not know -** what it means). Namespace prefixes with "xml" (any case) as -** their first three characters are reserved by the XML Namespaces -** specification for future use. mod_dav will pass these through -** unchanged. When this identifier is used, the prefix is LEFT in -** the element/attribute name. Downstream processing should not -** prepend another prefix. -** -** 2) The element/attribute does not have a namespace. -** -** a) No prefix was used, and a default namespace has not been -** defined. -** b) No prefix was used, and the default namespace was specified -** to mean "no namespace". This is done with a namespace -** declaration of: xmlns="" -** (this declaration is typically used to override a previous -** specification for the default namespace) -** -** In these cases, we need to record that the elem/attr has no -** namespace so that we will not attempt to prepend a prefix. -** All namespaces that are used will have a prefix assigned to -** them -- mod_dav will never set or use the default namespace -** when generating XML. This means that "no prefix" will always -** mean "no namespace". -** -** In both cases, the XML generation will avoid prepending a prefix. -** For the first case, this means the original prefix/name will be -** inserted into the output stream. For the latter case, it means -** the name will have no prefix, and since we never define a default -** namespace, this means it will have no namespace. -** -** Note: currently, mod_dav understands the "xmlns" prefix and the -** "xml:lang" attribute. These are handled specially (they aren't -** left within the XML tree), so the APR_XML_NS_NONE value won't ever -** really apply to these values. -*/ -#define APR_XML_NS_DAV_ID 0 /**< namespace ID for "DAV:" */ -#define APR_XML_NS_NONE -10 /**< no namespace for this elem/attr */ - -#define APR_XML_NS_ERROR_BASE -100 /**< used only during processing */ -/** Is this namespace an error? */ -#define APR_XML_NS_IS_ERROR(e) ((e) <= APR_XML_NS_ERROR_BASE) - -/** @see apr_xml_attr */ -typedef struct apr_xml_attr apr_xml_attr; -/** @see apr_xml_elem */ -typedef struct apr_xml_elem apr_xml_elem; -/** @see apr_xml_doc */ -typedef struct apr_xml_doc apr_xml_doc; - -/** apr_xml_attr: holds a parsed XML attribute */ -struct apr_xml_attr { - /** attribute name */ - const char *name; - /** index into namespace array */ - int ns; - - /** attribute value */ - const char *value; - - /** next attribute */ - struct apr_xml_attr *next; -}; - -/** apr_xml_elem: holds a parsed XML element */ -struct apr_xml_elem { - /** element name */ - const char *name; - /** index into namespace array */ - int ns; - /** xml:lang for attrs/contents */ - const char *lang; - - /** cdata right after start tag */ - apr_text_header first_cdata; - /** cdata after MY end tag */ - apr_text_header following_cdata; - - /** parent element */ - struct apr_xml_elem *parent; - /** next (sibling) element */ - struct apr_xml_elem *next; - /** first child element */ - struct apr_xml_elem *first_child; - /** first attribute */ - struct apr_xml_attr *attr; - - /* used only during parsing */ - /** last child element */ - struct apr_xml_elem *last_child; - /** namespaces scoped by this elem */ - struct apr_xml_ns_scope *ns_scope; - - /* used by modules during request processing */ - /** Place for modules to store private data */ - void *priv; -}; - -/** Is this XML element empty? */ -#define APR_XML_ELEM_IS_EMPTY(e) ((e)->first_child == NULL && \ - (e)->first_cdata.first == NULL) - -/** apr_xml_doc: holds a parsed XML document */ -struct apr_xml_doc { - /** root element */ - apr_xml_elem *root; - /** array of namespaces used */ - apr_array_header_t *namespaces; -}; - -/** Opaque XML parser structure */ -typedef struct apr_xml_parser apr_xml_parser; - -/** - * Create an XML parser - * @param pool The pool for allocating the parser and the parse results. - * @return The new parser. - */ -APU_DECLARE(apr_xml_parser *) apr_xml_parser_create(apr_pool_t *pool); - -/** - * Parse a File, producing a xml_doc - * @param p The pool for allocating the parse results. - * @param parser A pointer to *parser (needed so calling function can get - * errors), will be set to NULL on successfull completion. - * @param ppdoc A pointer to *apr_xml_doc (which has the parsed results in it) - * @param xmlfd A file to read from. - * @param buffer_length Buffer length which would be suitable - * @return Any errors found during parsing. - */ -APU_DECLARE(apr_status_t) apr_xml_parse_file(apr_pool_t *p, - apr_xml_parser **parser, - apr_xml_doc **ppdoc, - apr_file_t *xmlfd, - apr_size_t buffer_length); - - -/** - * Feed input into the parser - * @param parser The XML parser for parsing this data. - * @param data The data to parse. - * @param len The length of the data. - * @return Any errors found during parsing. - * @remark Use apr_xml_parser_geterror() to get more error information. - */ -APU_DECLARE(apr_status_t) apr_xml_parser_feed(apr_xml_parser *parser, - const char *data, - apr_size_t len); - -/** - * Terminate the parsing and return the result - * @param parser The XML parser for parsing this data. - * @param pdoc The resulting parse information. May be NULL to simply - * terminate the parsing without fetching the info. - * @return Any errors found during the final stage of parsing. - * @remark Use apr_xml_parser_geterror() to get more error information. - */ -APU_DECLARE(apr_status_t) apr_xml_parser_done(apr_xml_parser *parser, - apr_xml_doc **pdoc); - -/** - * Fetch additional error information from the parser. - * @param parser The XML parser to query for errors. - * @param errbuf A buffer for storing error text. - * @param errbufsize The length of the error text buffer. - * @return The error buffer - */ -APU_DECLARE(char *) apr_xml_parser_geterror(apr_xml_parser *parser, - char *errbuf, - apr_size_t errbufsize); - - -/** - * Converts an XML element tree to flat text - * @param p The pool to allocate out of - * @param elem The XML element to convert - * @param style How to covert the XML. One of: - *
- *     APR_XML_X2T_FULL                start tag, contents, end tag 
- *     APR_XML_X2T_INNER               contents only 
- *     APR_XML_X2T_LANG_INNER          xml:lang + inner contents 
- *     APR_XML_X2T_FULL_NS_LANG        FULL + ns defns + xml:lang 
- * 
- * @param namespaces The namespace of the current XML element - * @param ns_map Namespace mapping - * @param pbuf Buffer to put the converted text into - * @param psize Size of the converted text - */ -APU_DECLARE(void) apr_xml_to_text(apr_pool_t *p, const apr_xml_elem *elem, - int style, apr_array_header_t *namespaces, - int *ns_map, const char **pbuf, - apr_size_t *psize); - -/* style argument values: */ -#define APR_XML_X2T_FULL 0 /**< start tag, contents, end tag */ -#define APR_XML_X2T_INNER 1 /**< contents only */ -#define APR_XML_X2T_LANG_INNER 2 /**< xml:lang + inner contents */ -#define APR_XML_X2T_FULL_NS_LANG 3 /**< FULL + ns defns + xml:lang */ - -/** - * empty XML element - * @param p The pool to allocate out of - * @param elem The XML element to empty - * @return the string that was stored in the XML element - */ -APU_DECLARE(const char *) apr_xml_empty_elem(apr_pool_t *p, - const apr_xml_elem *elem); - -/** - * quote an XML string - * Replace '<', '>', and '&' with '<', '>', and '&'. - * @param p The pool to allocate out of - * @param s The string to quote - * @param quotes If quotes is true, then replace '"' with '"'. - * @return The quoted string - * @note If the string does not contain special characters, it is not - * duplicated into the pool and the original string is returned. - */ -APU_DECLARE(const char *) apr_xml_quote_string(apr_pool_t *p, const char *s, - int quotes); - -/** - * Quote an XML element - * @param p The pool to allocate out of - * @param elem The element to quote - */ -APU_DECLARE(void) apr_xml_quote_elem(apr_pool_t *p, apr_xml_elem *elem); - -/* manage an array of unique URIs: apr_xml_insert_uri() and APR_XML_URI_ITEM() */ - -/** - * return the URI's (existing) index, or insert it and return a new index - * @param uri_array array to insert into - * @param uri The uri to insert - * @return int The uri's index - */ -APU_DECLARE(int) apr_xml_insert_uri(apr_array_header_t *uri_array, - const char *uri); - -/** Get the URI item for this XML element */ -#define APR_XML_GET_URI_ITEM(ary, i) (((const char * const *)(ary)->elts)[i]) - -#if APR_CHARSET_EBCDIC -/** - * Convert parsed tree in EBCDIC - * @param p The pool to allocate out of - * @param pdoc The apr_xml_doc to convert. - * @param xlate The translation handle to use. - * @return Any errors found during conversion. - */ -APU_DECLARE(apr_status_t) apr_xml_parser_convert_doc(apr_pool_t *p, - apr_xml_doc *pdoc, - apr_xlate_t *convset); -#endif - -#ifdef __cplusplus -} -#endif -/** @} */ -#endif /* APR_XML_H */ diff --git a/libs/apr-util/include/apu.h.in b/libs/apr-util/include/apu.h.in deleted file mode 100644 index 5bd7d00f56..0000000000 --- a/libs/apr-util/include/apu.h.in +++ /dev/null @@ -1,91 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * apu.h is generated from apu.h.in by configure -- do not edit apu.h - */ -/* @file apu.h - * @brief APR-Utility main file - */ -/** - * @defgroup APR_Util APR Utility Functions - * @{ - */ - - -#ifndef APU_H -#define APU_H - -/** - * APU_DECLARE_EXPORT is defined when building the APR-UTIL dynamic library, - * so that all public symbols are exported. - * - * APU_DECLARE_STATIC is defined when including the APR-UTIL public headers, - * to provide static linkage when the dynamic library may be unavailable. - * - * APU_DECLARE_STATIC and APU_DECLARE_EXPORT are left undefined when - * including the APR-UTIL public headers, to import and link the symbols from - * the dynamic APR-UTIL library and assure appropriate indirection and calling - * conventions at compile time. - */ - -/** - * The public APR-UTIL functions are declared with APU_DECLARE(), so they may - * use the most appropriate calling convention. Public APR functions with - * variable arguments must use APU_DECLARE_NONSTD(). - * - * @deffunc APU_DECLARE(rettype) apr_func(args); - */ -#define APU_DECLARE(type) type -/** - * The public APR-UTIL functions using variable arguments are declared with - * APU_DECLARE_NONSTD(), as they must use the C language calling convention. - * - * @deffunc APU_DECLARE_NONSTD(rettype) apr_func(args, ...); - */ -#define APU_DECLARE_NONSTD(type) type -/** - * The public APR-UTIL variables are declared with APU_DECLARE_DATA. - * This assures the appropriate indirection is invoked at compile time. - * - * @deffunc APU_DECLARE_DATA type apr_variable; - * @tip APU_DECLARE_DATA extern type apr_variable; syntax is required for - * declarations within headers to properly import the variable. - */ -#define APU_DECLARE_DATA -/* - * we always have SDBM (it's in our codebase) - */ -#define APU_HAVE_SDBM @apu_have_sdbm@ -#define APU_HAVE_GDBM @apu_have_gdbm@ -#define APU_HAVE_NDBM @apu_have_ndbm@ -#define APU_HAVE_DB @apu_have_db@ - -#if APU_HAVE_DB -#define APU_HAVE_DB_VERSION @apu_db_version@ -#endif /* APU_HAVE_DB */ - -#define APU_HAVE_PGSQL @apu_have_pgsql@ -#define APU_HAVE_MYSQL @apu_have_mysql@ -#define APU_HAVE_SQLITE3 @apu_have_sqlite3@ -#define APU_HAVE_SQLITE2 @apu_have_sqlite2@ - -#define APU_HAVE_APR_ICONV @have_apr_iconv@ -#define APU_HAVE_ICONV @have_iconv@ -#define APR_HAS_XLATE (APU_HAVE_APR_ICONV || APU_HAVE_ICONV) - -#endif /* APU_H */ -/** @} */ diff --git a/libs/apr-util/include/apu.hnw b/libs/apr-util/include/apu.hnw deleted file mode 100644 index 8c3cee7832..0000000000 --- a/libs/apr-util/include/apu.hnw +++ /dev/null @@ -1,84 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Note: This is a NetWare specific version of apu.h. It is renamed to - * apu.h at the start of a NetWare build. - */ -/* @file apu.h - * @brief APR-Utility main file - */ -/** - * @defgroup APR_Util APR Utility Functions - * @{ - */ - - -#ifndef APU_H -#define APU_H - -/** - * APU_DECLARE_EXPORT is defined when building the APR-UTIL dynamic library, - * so that all public symbols are exported. - * - * APU_DECLARE_STATIC is defined when including the APR-UTIL public headers, - * to provide static linkage when the dynamic library may be unavailable. - * - * APU_DECLARE_STATIC and APU_DECLARE_EXPORT are left undefined when - * including the APR-UTIL public headers, to import and link the symbols from - * the dynamic APR-UTIL library and assure appropriate indirection and calling - * conventions at compile time. - */ - -/** - * The public APR-UTIL functions are declared with APU_DECLARE(), so they may - * use the most appropriate calling convention. Public APR functions with - * variable arguments must use APU_DECLARE_NONSTD(). - * - * @deffunc APU_DECLARE(rettype) apr_func(args); - */ -#define APU_DECLARE(type) type -/** - * The public APR-UTIL functions using variable arguments are declared with - * APU_DECLARE_NONSTD(), as they must use the C language calling convention. - * - * @deffunc APU_DECLARE_NONSTD(rettype) apr_func(args, ...); - */ -#define APU_DECLARE_NONSTD(type) type -/** - * The public APR-UTIL variables are declared with APU_DECLARE_DATA. - * This assures the appropriate indirection is invoked at compile time. - * - * @deffunc APU_DECLARE_DATA type apr_variable; - * @tip APU_DECLARE_DATA extern type apr_variable; syntax is required for - * declarations within headers to properly import the variable. - */ -#define APU_DECLARE_DATA -/* - * we always have SDBM (it's in our codebase) - */ -#define APU_HAVE_SDBM 1 -#define APU_HAVE_GDBM 0 -#define APU_HAVE_DB 0 - - -#define HAVE_ICONV_H 1 -#define APU_HAVE_APR_ICONV 0 -#define APU_HAVE_ICONV 1 -#define APR_HAS_XLATE (APU_HAVE_APR_ICONV || APU_HAVE_ICONV) - -#endif /* APU_H */ -/** @} */ diff --git a/libs/apr-util/include/apu.hw b/libs/apr-util/include/apu.hw deleted file mode 100644 index c710ee2b13..0000000000 --- a/libs/apr-util/include/apu.hw +++ /dev/null @@ -1,113 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Note: This is a Windows specific version of apu.h. It is renamed to - * apu.h at the start of a Windows build. - */ -/* @file apu.h - * @brief APR-Utility main file - */ - -#ifdef WIN32 -#ifndef APU_H -#define APU_H -/** - * @defgroup APR_Util APR Utility Functions - * @{ - */ - - -/** - * APU_DECLARE_EXPORT is defined when building the APR-UTIL dynamic library, - * so that all public symbols are exported. - * - * APU_DECLARE_STATIC is defined when including the APR-UTIL public headers, - * to provide static linkage when the dynamic library may be unavailable. - * - * APU_DECLARE_STATIC and APU_DECLARE_EXPORT are left undefined when - * including the APR-UTIL public headers, to import and link the symbols from - * the dynamic APR-UTIL library and assure appropriate indirection and calling - * conventions at compile time. - */ - -#if defined(DOXYGEN) || !defined(WIN32) -/** - * The public APR-UTIL functions are declared with APU_DECLARE(), so they may - * use the most appropriate calling convention. Public APR functions with - * variable arguments must use APU_DECLARE_NONSTD(). - * - * @deffunc APU_DECLARE(rettype) apr_func(args); - */ -#define APU_DECLARE(type) type -/** - * The public APR-UTIL functions using variable arguments are declared with - * APU_DECLARE_NONSTD(), as they must use the C language calling convention. - * - * @deffunc APU_DECLARE_NONSTD(rettype) apr_func(args, ...); - */ -#define APU_DECLARE_NONSTD(type) type -/** - * The public APR-UTIL variables are declared with APU_DECLARE_DATA. - * This assures the appropriate indirection is invoked at compile time. - * - * @deffunc APU_DECLARE_DATA type apr_variable; - * @tip extern APU_DECLARE_DATA type apr_variable; syntax is required for - * declarations within headers to properly import the variable. - */ -#define APU_DECLARE_DATA -#elif defined(APU_DECLARE_STATIC) -#define APU_DECLARE(type) type __stdcall -#define APU_DECLARE_NONSTD(type) type __cdecl -#define APU_DECLARE_DATA -#elif defined(APU_DECLARE_EXPORT) -#define APU_DECLARE(type) __declspec(dllexport) type __stdcall -#define APU_DECLARE_NONSTD(type) __declspec(dllexport) type __cdecl -#define APU_DECLARE_DATA __declspec(dllexport) -#else -#define APU_DECLARE(type) __declspec(dllimport) type __stdcall -#define APU_DECLARE_NONSTD(type) __declspec(dllimport) type __cdecl -#define APU_DECLARE_DATA __declspec(dllimport) -#endif -/** @} */ -/* - * we always have SDBM (it's in our codebase) - */ -#define APU_HAVE_SDBM 1 -#define APU_HAVE_GDBM 0 - -/* Allow external override */ -#if !defined(APU_HAVE_DB) -#define APU_HAVE_DB 0 -#endif - - -#define APU_HAVE_APR_ICONV 0 -#define APU_HAVE_ICONV 0 -#define APR_HAS_XLATE (APU_HAVE_APR_ICONV || APU_HAVE_ICONV) - -#if !defined(APU_HAVE_PGSQL) -#define APU_HAVE_PGSQL 0 -#endif -#if !defined(APU_HAVE_SQLITE2) -#define APU_HAVE_SQLITE2 0 -#endif -#if !defined(APU_HAVE_SQLITE3) -#define APU_HAVE_SQLITE3 0 -#endif - -#endif /* APU_H */ -#endif /* WIN32 */ diff --git a/libs/apr-util/include/apu_version.h b/libs/apr-util/include/apu_version.h deleted file mode 100644 index 578106ec4b..0000000000 --- a/libs/apr-util/include/apu_version.h +++ /dev/null @@ -1,134 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APU_VERSION_H -#define APU_VERSION_H - -/** - * @file apu_version.h - * @brief APR-util Versioning Interface - * - * APR-util's Version - * - * There are several different mechanisms for accessing the version. There - * is a string form, and a set of numbers; in addition, there are constants - * which can be compiled into your application, and you can query the library - * being used for its actual version. - * - * Note that it is possible for an application to detect that it has been - * compiled against a different version of APU by use of the compile-time - * constants and the use of the run-time query function. - * - * APU version numbering follows the guidelines specified in: - * - * http://apr.apache.org/versioning.html - */ - - -/* The numeric compile-time version constants. These constants are the - * authoritative version numbers for APU. - */ - -/** major version - * Major API changes that could cause compatibility problems for older - * programs such as structure size changes. No binary compatibility is - * possible across a change in the major version. - */ -#define APU_MAJOR_VERSION 1 - -/** minor version - * Minor API changes that do not cause binary compatibility problems. - * Reset to 0 when upgrading APU_MAJOR_VERSION - */ -#define APU_MINOR_VERSION 2 - -/** patch level - * The Patch Level never includes API changes, simply bug fixes. - * Reset to 0 when upgrading APR_MINOR_VERSION - */ -#define APU_PATCH_VERSION 8 - -/** - * The symbol APU_IS_DEV_VERSION is only defined for internal, - * "development" copies of APU. It is undefined for released versions - * of APU. - */ -/* #define APU_IS_DEV_VERSION */ - - -#if defined(APU_IS_DEV_VERSION) || defined(DOXYGEN) -/** Internal: string form of the "is dev" flag */ -#define APU_IS_DEV_STRING "-dev" -#else -#define APU_IS_DEV_STRING "" -#endif - - -#ifndef APU_STRINGIFY -/** Properly quote a value as a string in the C preprocessor */ -#define APU_STRINGIFY(n) APU_STRINGIFY_HELPER(n) -/** Helper macro for APU_STRINGIFY */ -#define APU_STRINGIFY_HELPER(n) #n -#endif - -/** The formatted string of APU's version */ -#define APU_VERSION_STRING \ - APU_STRINGIFY(APU_MAJOR_VERSION) "." \ - APU_STRINGIFY(APU_MINOR_VERSION) "." \ - APU_STRINGIFY(APU_PATCH_VERSION) \ - APU_IS_DEV_STRING - -/** An alternative formatted string of APR's version */ -/* macro for Win32 .rc files using numeric csv representation */ -#define APU_VERSION_STRING_CSV APU_MAJOR_VERSION ##, \ - ##APU_MINOR_VERSION ##, \ - ##APU_PATCH_VERSION - - -#ifndef APU_VERSION_ONLY - -/* The C language API to access the version at run time, - * as opposed to compile time. APU_VERSION_ONLY may be defined - * externally when preprocessing apr_version.h to obtain strictly - * the C Preprocessor macro declarations. - */ - -#include "apr_version.h" - -#include "apu.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Return APR-util's version information information in a numeric form. - * - * @param pvsn Pointer to a version structure for returning the version - * information. - */ -APU_DECLARE(void) apu_version(apr_version_t *pvsn); - -/** Return APU's version information as a string. */ -APU_DECLARE(const char *) apu_version_string(void); - -#ifdef __cplusplus -} -#endif - -#endif /* ndef APU_VERSION_ONLY */ - -#endif /* ndef APU_VERSION_H */ diff --git a/libs/apr-util/include/apu_want.h.in b/libs/apr-util/include/apu_want.h.in deleted file mode 100644 index ac297292ba..0000000000 --- a/libs/apr-util/include/apu_want.h.in +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apu.h" /* configuration data */ - -/** - * @file apu_want.h - * @brief APR Standard Headers Support - * - *
- * Features:
- *
- *   APU_WANT_DB:       <@apu_db_header@>
- *
- * Typical usage:
- *
- *   #define APU_WANT_DB
- *   #include "apu_want.h"
- *
- * The appropriate headers will be included.
- *
- * Note: it is safe to use this in a header (it won't interfere with other
- *       headers' or source files' use of apu_want.h)
- * 
- */ - -/* --------------------------------------------------------------------- */ - -#ifdef APU_WANT_DB - -#if APU_HAVE_DB -#include <@apu_db_header@> -#endif - -#undef APU_WANT_DB -#endif - -/* --------------------------------------------------------------------- */ diff --git a/libs/apr-util/include/apu_want.hnw b/libs/apr-util/include/apu_want.hnw deleted file mode 100644 index 4927da8b9d..0000000000 --- a/libs/apr-util/include/apu_want.hnw +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apu.h" /* configuration data */ - -/** - * @file apu_want.h - * @brief APR Standard Headers Support - * - *
- * Features:
- *
- *   APU_WANT_DB:       <@apu_db_header>
- *
- * Typical usage:
- *
- *   #define APU_WANT_DB
- *   #include "apu_want.h"
- *
- * The appropriate headers will be included.
- *
- * Note: it is safe to use this in a header (it won't interfere with other
- *       headers' or source files' use of apu_want.h)
- * 
- */ - -/* --------------------------------------------------------------------- */ - -#ifdef APU_WANT_DB - -#if APU_HAVE_DB -/* win32 note.. you will need to change this for db1 */ -#include -#endif - -#undef APU_WANT_DB -#endif - -/* --------------------------------------------------------------------- */ diff --git a/libs/apr-util/include/apu_want.hw b/libs/apr-util/include/apu_want.hw deleted file mode 100644 index 4927da8b9d..0000000000 --- a/libs/apr-util/include/apu_want.hw +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apu.h" /* configuration data */ - -/** - * @file apu_want.h - * @brief APR Standard Headers Support - * - *
- * Features:
- *
- *   APU_WANT_DB:       <@apu_db_header>
- *
- * Typical usage:
- *
- *   #define APU_WANT_DB
- *   #include "apu_want.h"
- *
- * The appropriate headers will be included.
- *
- * Note: it is safe to use this in a header (it won't interfere with other
- *       headers' or source files' use of apu_want.h)
- * 
- */ - -/* --------------------------------------------------------------------- */ - -#ifdef APU_WANT_DB - -#if APU_HAVE_DB -/* win32 note.. you will need to change this for db1 */ -#include -#endif - -#undef APU_WANT_DB -#endif - -/* --------------------------------------------------------------------- */ diff --git a/libs/apr-util/include/private/apr_dbd_internal.h b/libs/apr-util/include/private/apr_dbd_internal.h deleted file mode 100644 index fcefc2345f..0000000000 --- a/libs/apr-util/include/private/apr_dbd_internal.h +++ /dev/null @@ -1,257 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* Overview of what this is and does: - * http://www.apache.org/~niq/dbd.html - */ - -#ifndef APR_DBD_INTERNAL_H -#define APR_DBD_INTERNAL_H - -#include - -#include "apr_dbd.h" - -#ifdef __cplusplus -extern "C" { -#endif - -struct apr_dbd_driver_t { - /** name */ - const char *name; - - /** init: allow driver to perform once-only initialisation. - * Called once only. May be NULL - */ - void (*init)(apr_pool_t *pool); - - /** native_handle: return the native database handle of the underlying db - * - * @param handle - apr_dbd handle - * @return - native handle - */ - void *(*native_handle)(apr_dbd_t *handle); - - /** open: obtain a database connection from the server rec. - * Must be explicitly closed when you're finished with it. - * WARNING: only use this when you need a connection with - * a lifetime other than a request - * - * @param pool - a pool to use for error messages (if any). - * @param s - server rec managing the underlying connection/pool. - * @return database handle, or NULL on error. - */ - apr_dbd_t *(*open)(apr_pool_t *pool, const char *params); - - /** check_conn: check status of a database connection - * - * @param pool - a pool to use for error messages (if any). - * @param handle - the connection to check - * @return APR_SUCCESS or error - */ - apr_status_t (*check_conn)(apr_pool_t *pool, apr_dbd_t *handle); - - /** close: close/release a connection obtained from open() - * - * @param handle - the connection to release - * @return APR_SUCCESS or error - */ - apr_status_t (*close)(apr_dbd_t *handle); - - /** set_dbname: select database name. May be a no-op if not supported. - * - * @param pool - working pool - * @param handle - the connection - * @param name - the database to select - * @return 0 for success or error code - */ - int (*set_dbname)(apr_pool_t* pool, apr_dbd_t *handle, const char *name); - - /** transaction: start a transaction. May be a no-op. - * - * @param pool - a pool to use for error messages (if any). - * @param handle - the connection - * @param transaction - ptr to a transaction. May be null on entry - * @return 0 for success or error code - */ - int (*start_transaction)(apr_pool_t *pool, apr_dbd_t *handle, - apr_dbd_transaction_t **trans); - - /** end_transaction: end a transaction - * (commit on success, rollback on error). - * May be a no-op. - * - * @param transaction - the transaction. - * @return 0 for success or error code - */ - int (*end_transaction)(apr_dbd_transaction_t *trans); - - /** query: execute an SQL query that doesn't return a result set - * - * @param handle - the connection - * @param nrows - number of rows affected. - * @param statement - the SQL statement to execute - * @return 0 for success or error code - */ - int (*query)(apr_dbd_t *handle, int *nrows, const char *statement); - - /** select: execute an SQL query that returns a result set - * - * @param pool - pool to allocate the result set - * @param handle - the connection - * @param res - pointer to result set pointer. May point to NULL on entry - * @param statement - the SQL statement to execute - * @param random - 1 to support random access to results (seek any row); - * 0 to support only looping through results in order - * (async access - faster) - * @return 0 for success or error code - */ - int (*select)(apr_pool_t *pool, apr_dbd_t *handle, apr_dbd_results_t **res, - const char *statement, int random); - - /** num_cols: get the number of columns in a results set - * - * @param res - result set. - * @return number of columns - */ - int (*num_cols)(apr_dbd_results_t *res); - - /** num_tuples: get the number of rows in a results set - * of a synchronous select - * - * @param res - result set. - * @return number of rows, or -1 if the results are asynchronous - */ - int (*num_tuples)(apr_dbd_results_t *res); - - /** get_row: get a row from a result set - * - * @param pool - pool to allocate the row - * @param res - result set pointer - * @param row - pointer to row pointer. May point to NULL on entry - * @param rownum - row number, or -1 for "next row". Ignored if random - * access is not supported. - * @return 0 for success, -1 for rownum out of range or data finished - */ - int (*get_row)(apr_pool_t *pool, apr_dbd_results_t *res, - apr_dbd_row_t **row, int rownum); - - /** get_entry: get an entry from a row - * - * @param row - row pointer - * @param col - entry number - * @param val - entry to fill - * @return 0 for success, -1 for no data, +1 for general error - */ - const char* (*get_entry)(const apr_dbd_row_t *row, int col); - - /** error: get current error message (if any) - * - * @param handle - the connection - * @param errnum - error code from operation that returned an error - * @return the database current error message, or message for errnum - * (implementation-dependent whether errnum is ignored) - */ - const char *(*error)(apr_dbd_t *handle, int errnum); - - /** escape: escape a string so it is safe for use in query/select - * - * @param pool - pool to alloc the result from - * @param string - the string to escape - * @param handle - the connection - * @return the escaped, safe string - */ - const char *(*escape)(apr_pool_t *pool, const char *string, - apr_dbd_t *handle); - - /** prepare: prepare a statement - * - * @param pool - pool to alloc the result from - * @param handle - the connection - * @param query - the SQL query - * @param label - A label for the prepared statement. - * use NULL for temporary prepared statements - * (eg within a Request in httpd) - * @param statement - statement to prepare. May point to null on entry. - * @return 0 for success or error code - */ - int (*prepare)(apr_pool_t *pool, apr_dbd_t *handle, const char *query, - const char *label, apr_dbd_prepared_t **statement); - - /** pvquery: query using a prepared statement + args - * - * @param pool - working pool - * @param handle - the connection - * @param nrows - number of rows affected. - * @param statement - the prepared statement to execute - * @param args - args to prepared statement - * @return 0 for success or error code - */ - int (*pvquery)(apr_pool_t *pool, apr_dbd_t *handle, int *nrows, - apr_dbd_prepared_t *statement, va_list args); - - /** pvselect: select using a prepared statement + args - * - * @param pool - working pool - * @param handle - the connection - * @param res - pointer to query results. May point to NULL on entry - * @param statement - the prepared statement to execute - * @param random - Whether to support random-access to results - * @param args - args to prepared statement - * @return 0 for success or error code - */ - int (*pvselect)(apr_pool_t *pool, apr_dbd_t *handle, - apr_dbd_results_t **res, - apr_dbd_prepared_t *statement, int random, va_list args); - - /** pquery: query using a prepared statement + args - * - * @param pool - working pool - * @param handle - the connection - * @param nrows - number of rows affected. - * @param statement - the prepared statement to execute - * @param nargs - number of args to prepared statement - * @param args - args to prepared statement - * @return 0 for success or error code - */ - int (*pquery)(apr_pool_t *pool, apr_dbd_t *handle, int *nrows, - apr_dbd_prepared_t *statement, int nargs, - const char **args); - - /** pselect: select using a prepared statement + args - * - * @param pool - working pool - * @param handle - the connection - * @param res - pointer to query results. May point to NULL on entry - * @param statement - the prepared statement to execute - * @param random - Whether to support random-access to results - * @param nargs - number of args to prepared statement - * @param args - args to prepared statement - * @return 0 for success or error code - */ - int (*pselect)(apr_pool_t *pool, apr_dbd_t *handle, - apr_dbd_results_t **res, apr_dbd_prepared_t *statement, - int random, int nargs, const char **args); - - -}; - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/libs/apr-util/include/private/apr_dbm_private.h b/libs/apr-util/include/private/apr_dbm_private.h deleted file mode 100644 index 7faae8bf3b..0000000000 --- a/libs/apr-util/include/private/apr_dbm_private.h +++ /dev/null @@ -1,125 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_DBM_PRIVATE_H -#define APR_DBM_PRIVATE_H - -#include "apr.h" -#include "apr_errno.h" -#include "apr_pools.h" -#include "apr_dbm.h" -#include "apr_file_io.h" - -#include "apu.h" - -/* ### for now, include the DBM selection; this will go away once we start - ### building and linking all of the DBMs at once. */ -#include "apu_select_dbm.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** @internal */ - -/** - * Most DBM libraries take a POSIX mode for creating files. Don't trust - * the mode_t type, some platforms may not support it, int is safe. - */ -APU_DECLARE(int) apr_posix_perms2mode(apr_fileperms_t perm); - -/** - * Structure to describe the operations of the DBM - */ -typedef struct { - /** The name of the DBM Type */ - const char *name; - - /** Open the DBM */ - apr_status_t (*open)(apr_dbm_t **pdb, const char *pathname, - apr_int32_t mode, apr_fileperms_t perm, - apr_pool_t *pool); - - /** Close the DBM */ - void (*close)(apr_dbm_t *dbm); - - /** Fetch a dbm record value by key */ - apr_status_t (*fetch)(apr_dbm_t *dbm, apr_datum_t key, - apr_datum_t * pvalue); - - /** Store a dbm record value by key */ - apr_status_t (*store)(apr_dbm_t *dbm, apr_datum_t key, apr_datum_t value); - - /** Delete a dbm record value by key */ - apr_status_t (*del)(apr_dbm_t *dbm, apr_datum_t key); - - /** Search for a key within the dbm */ - int (*exists)(apr_dbm_t *dbm, apr_datum_t key); - - /** Retrieve the first record key from a dbm */ - apr_status_t (*firstkey)(apr_dbm_t *dbm, apr_datum_t * pkey); - - /** Retrieve the next record key from a dbm */ - apr_status_t (*nextkey)(apr_dbm_t *dbm, apr_datum_t * pkey); - - /** Proactively toss any memory associated with the apr_datum_t. */ - void (*freedatum)(apr_dbm_t *dbm, apr_datum_t data); - - /** Get the names that the DBM will use for a given pathname. */ - void (*getusednames)(apr_pool_t *pool, - const char *pathname, - const char **used1, - const char **used2); - -} apr_dbm_type_t; - - -/** - * The actual DBM - */ -struct apr_dbm_t -{ - /** Associated pool */ - apr_pool_t *pool; - - /** pointer to DB Implementation Specific data */ - void *file; - - /** Current integer error code */ - int errcode; - /** Current string error code */ - const char *errmsg; - - /** the type of DBM */ - const apr_dbm_type_t *type; -}; - - -/* Declare all of the builtin DBM providers */ -APU_DECLARE_DATA extern const apr_dbm_type_t apr_dbm_type_sdbm; -APU_DECLARE_DATA extern const apr_dbm_type_t apr_dbm_type_gdbm; -APU_DECLARE_DATA extern const apr_dbm_type_t apr_dbm_type_ndbm; -APU_DECLARE_DATA extern const apr_dbm_type_t apr_dbm_type_db1; -APU_DECLARE_DATA extern const apr_dbm_type_t apr_dbm_type_db2; -APU_DECLARE_DATA extern const apr_dbm_type_t apr_dbm_type_db3; -APU_DECLARE_DATA extern const apr_dbm_type_t apr_dbm_type_db4; -APU_DECLARE_DATA extern const apr_dbm_type_t apr_dbm_type_db; - -#ifdef __cplusplus -} -#endif - -#endif /* APR_DBM_PRIVATE_H */ diff --git a/libs/apr-util/include/private/apu_config.hw b/libs/apr-util/include/private/apu_config.hw deleted file mode 100644 index c4d7d093fb..0000000000 --- a/libs/apr-util/include/private/apu_config.hw +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Note: This is a Windows specific version of apu_config.hw. It is copied - * as apu_config.h at the start of a Windows build. - */ - -#ifdef WIN32 - -#ifndef APU_CONFIG_H -#define APU_CONFIG_H - -/* - * Windows does not have GDBM, and we always use the bundled (new) Expat - */ - -/* Define if you have the gdbm library (-lgdbm). */ -/* #undef HAVE_LIBGDBM */ - -/* define if Expat 1.0 or 1.1 was found */ -/* #undef APR_HAVE_OLD_EXPAT */ - - -#endif /* APU_CONFIG_H */ -#endif /* WIN32 */ diff --git a/libs/apr-util/include/private/apu_select_dbm.h.in b/libs/apr-util/include/private/apu_select_dbm.h.in deleted file mode 100644 index c24ebe52a9..0000000000 --- a/libs/apr-util/include/private/apu_select_dbm.h.in +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APU_SELECT_DBM_H -#define APU_SELECT_DBM_H - -/* -** The following macros control what features APRUTIL will use -*/ -#define APU_USE_SDBM @apu_use_sdbm@ -#define APU_USE_NDBM @apu_use_ndbm@ -#define APU_USE_GDBM @apu_use_gdbm@ -#define APU_USE_DB @apu_use_db@ - -#endif /* !APU_SELECT_DBM_H */ diff --git a/libs/apr-util/include/private/apu_select_dbm.hw b/libs/apr-util/include/private/apu_select_dbm.hw deleted file mode 100644 index 0561cb8f84..0000000000 --- a/libs/apr-util/include/private/apu_select_dbm.hw +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APU_SELECT_DBM_H -#define APU_SELECT_DBM_H - -/* -** The following macros control what features APRUTIL will use -*/ -#define APU_USE_SDBM 1 -#define APU_USE_GDBM 0 -#define APU_USE_NDBM 0 -#define APU_USE_DB 0 - -#if APU_USE_DB -#include -#endif - -#endif /* !APU_SELECT_DBM_H */ diff --git a/libs/apr-util/ldap/NWGNUmakefile b/libs/apr-util/ldap/NWGNUmakefile deleted file mode 100644 index a0ecc3bac6..0000000000 --- a/libs/apr-util/ldap/NWGNUmakefile +++ /dev/null @@ -1,260 +0,0 @@ -# -# Declare the sub-directories to be built here -# - -SUBDIRS = \ - $(EOLIST) - -# -# Get the 'head' of the build environment. This includes default targets and -# paths to tools -# - -include $(APR_WORK)\build\NWGNUhead.inc - -# -# build this level's files - -# -# Make sure all needed macro's are defined -# - -# -# These directories will be at the beginning of the include list, followed by -# INCDIRS -# -XINCDIRS += \ - $(APR)/include \ - $(APR)/include/arch/NetWare \ - $(APRUTIL)/include \ - $(LDAPSDK)/inc \ - $(EOLIST) - -# -# These flags will come after CFLAGS -# -XCFLAGS += \ - $(EOLIST) - -# -# These defines will come after DEFINES -# -XDEFINES += \ - $(EOLIST) - -# -#LDAP client requires the use of Winsock -# -ifdef USE_STDSOCKETS -XDEFINES += -DUSE_WINSOCK \ - $(EOLIST) -endif - -# -# These flags will be added to the link.opt file -# -XLFLAGS += \ - $(EOLIST) - -# -# These values will be appended to the correct variables based on the value of -# RELEASE -# -ifeq "$(RELEASE)" "debug" -XINCDIRS += \ - $(EOLIST) - -XCFLAGS += \ - $(EOLIST) - -XDEFINES += \ - $(EOLIST) - -XLFLAGS += \ - $(EOLIST) -endif - -ifeq "$(RELEASE)" "noopt" -XINCDIRS += \ - $(EOLIST) - -XCFLAGS += \ - $(EOLIST) - -XDEFINES += \ - $(EOLIST) - -XLFLAGS += \ - $(EOLIST) -endif - -ifeq "$(RELEASE)" "release" -XINCDIRS += \ - $(EOLIST) - -XCFLAGS += \ - $(EOLIST) - -XDEFINES += \ - $(EOLIST) - -XLFLAGS += \ - $(EOLIST) -endif - -# -# These are used by the link target if an NLM is being generated -# This is used by the link 'name' directive to name the nlm. If left blank -# TARGET_nlm (see below) will be used. -# -NLM_NAME = - -# -# This is used by the link '-desc ' directive. -# If left blank, NLM_NAME will be used. -# -NLM_DESCRIPTION = - -# -# This is used by the '-threadname' directive. If left blank, -# NLM_NAME Thread will be used. -# -NLM_THREAD_NAME = -# -# If this is specified, it will override VERSION value in -# $(APR_WORK)\build\NWGNUenvironment.inc -# -NLM_VERSION = - -# -# If this is specified, it will override the default of 64K -# -NLM_STACK_SIZE = - -# -# If this is specified it will be used by the link '-entry' directive -# -NLM_ENTRY_SYM = - -# -# If this is specified it will be used by the link '-exit' directive -# -NLM_EXIT_SYM = - -# -# If this is specified it will be used by the link '-check' directive -# -NLM_CHECK_SYM = - -# -# If this is specified it will be used by the link '-flags' directive -# -NLM_FLAGS = - -# -# If this is specified it will be linked in with the XDCData option in the def -# file instead of the default of $(APR)/misc/netware/apache.xdc. XDCData can -# be disabled by setting APACHE_UNIPROC in the environment -# -XDCDATA = - -# -# Declare all target files (you must add your files here) -# - -# -# If there is an NLM target, put it here -# -TARGET_nlm = \ - $(EOLIST) - -# -# If there is an LIB target, put it here -# -TARGET_lib = \ - $(OBJDIR)/apuldap.lib \ - $(EOLIST) - -# -# These are the OBJ files needed to create the NLM target above. -# Paths must all use the '/' character -# -FILES_nlm_objs = \ - $(EOLIST) - -# -# These are the LIB files needed to create the NLM target above. -# These will be added as a library command in the link.opt file. -# -FILES_nlm_libs = \ - $(EOLIST) - -# -# These are the modules that the above NLM target depends on to load. -# These will be added as a module command in the link.opt file. -# -FILES_nlm_modules = \ - $(EOLIST) - -# -# If the nlm has a msg file, put it's path here -# -FILE_nlm_msg = - -# -# If the nlm has a hlp file put it's path here -# -FILE_nlm_hlp = - -# -# If this is specified, it will override the default copyright. -# -FILE_nlm_copyright = - -# -# Any additional imports go here -# -FILES_nlm_Ximports = \ - $(EOLIST) - -# -# Any symbols exported to here -# -FILES_nlm_exports = \ - $(EOLIST) - -# -# These are the OBJ files needed to create the LIB target above. -# Paths must all use the '/' character -# -FILES_lib_objs = \ - $(OBJDIR)/apr_ldap_init.o \ - $(OBJDIR)/apr_ldap_option.o \ - $(OBJDIR)/apr_ldap_url.o \ - $(EOLIST) - -# -# implement targets and dependancies (leave this section alone) -# - -libs :: $(OBJDIR) $(TARGET_lib) - -nlms :: libs $(TARGET_nlm) - -# -# Updated this target to create necessary directories and copy files to the -# correct place. (See $(APR_WORK)\build\NWGNUhead.inc for examples) -# -install :: nlms FORCE - -# -# Any specialized rules here -# - -# -# Include the 'tail' makefile that has targets that depend on variables defined -# in this makefile -# - -include $(APR_WORK)\build\NWGNUtail.inc - diff --git a/libs/apr-util/ldap/apr_ldap_init.c b/libs/apr-util/ldap/apr_ldap_init.c deleted file mode 100644 index 6aec5d16a0..0000000000 --- a/libs/apr-util/ldap/apr_ldap_init.c +++ /dev/null @@ -1,189 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * apr_ldap_init.c: LDAP v2/v3 common initialise - * - * Original code from auth_ldap module for Apache v1.3: - * Copyright 1998, 1999 Enbridge Pipelines Inc. - * Copyright 1999-2001 Dave Carrigan - */ - -#include "apr.h" -#include "apu.h" -#include "apr_ldap.h" -#include "apr_errno.h" -#include "apr_pools.h" -#include "apr_strings.h" - -#if APR_HAS_LDAP - -/** - * APR LDAP SSL Initialise function - * - * This function initialises SSL on the underlying LDAP toolkit - * if this is necessary. - * - * If a CA certificate is provided, this is set, however the setting - * of certificates via this method has been deprecated and will be removed in - * APR v2.0. - * - * The apr_ldap_set_option() function with the APR_LDAP_OPT_TLS_CERT option - * should be used instead to set certificates. - * - * If SSL support is not available on this platform, or a problem - * was encountered while trying to set the certificate, the function - * will return APR_EGENERAL. Further LDAP specific error information - * can be found in result_err. - */ -APU_DECLARE(int) apr_ldap_ssl_init(apr_pool_t *pool, - const char *cert_auth_file, - int cert_file_type, - apr_ldap_err_t **result_err) { - - apr_ldap_err_t *result = (apr_ldap_err_t *)apr_pcalloc(pool, sizeof(apr_ldap_err_t)); - *result_err = result; - -#if APR_HAS_LDAP_SSL /* compiled with ssl support */ - - /* Novell */ -#if APR_HAS_NOVELL_LDAPSDK - ldapssl_client_init(NULL, NULL); -#endif - - /* if a certificate was specified, set it */ - if (cert_auth_file) { - apr_ldap_opt_tls_cert_t *cert = (apr_ldap_opt_tls_cert_t *)apr_pcalloc(pool, sizeof(apr_ldap_opt_tls_cert_t)); - cert->type = cert_file_type; - cert->path = cert_auth_file; - return apr_ldap_set_option(pool, NULL, APR_LDAP_OPT_TLS_CERT, (void *)cert, result_err); - } - -#else /* not compiled with SSL Support */ - if (cert_auth_file) { - result->reason = "LDAP: Attempt to set certificate store failed. " - "Not built with SSL support"; - result->rc = -1; - } -#endif /* APR_HAS_LDAP_SSL */ - - if (result->rc != -1) { - result->msg = ldap_err2string(result->rc); - } - - if (LDAP_SUCCESS != result->rc) { - return APR_EGENERAL; - } - - return APR_SUCCESS; - -} - - -/** - * APR LDAP SSL De-Initialise function - * - * This function tears down any SSL certificate setup previously - * set using apr_ldap_ssl_init(). It should be called to clean - * up if a graceful restart of a service is attempted. - * - * This function only does anything on Netware. - * - * @todo currently we do not check whether apr_ldap_ssl_init() - * has been called first - should we? - */ -APU_DECLARE(int) apr_ldap_ssl_deinit(void) { - -#if APR_HAS_LDAP_SSL && APR_HAS_LDAPSSL_CLIENT_DEINIT - ldapssl_client_deinit(); -#endif - return APR_SUCCESS; - -} - - -/** - * APR LDAP initialise function - * - * This function is responsible for initialising an LDAP - * connection in a toolkit independant way. It does the - * job of ldap_init() from the C api. - * - * It handles both the SSL and non-SSL case, and attempts - * to hide the complexity setup from the user. This function - * assumes that any certificate setup necessary has already - * been done. - * - * If SSL or STARTTLS needs to be enabled, and the underlying - * toolkit supports it, the following values are accepted for - * secure: - * - * APR_LDAP_NONE: No encryption - * APR_LDAP_SSL: SSL encryption (ldaps://) - * APR_LDAP_STARTTLS: Force STARTTLS on ldap:// - */ -APU_DECLARE(int) apr_ldap_init(apr_pool_t *pool, - LDAP **ldap, - const char *hostname, - int portno, - int secure, - apr_ldap_err_t **result_err) { - - apr_ldap_err_t *result = (apr_ldap_err_t *)apr_pcalloc(pool, sizeof(apr_ldap_err_t)); - *result_err = result; - -#if APR_HAS_LDAPSSL_INIT - *ldap = ldapssl_init(hostname, portno, 0); -#elif APR_HAS_LDAP_SSLINIT - *ldap = ldap_sslinit((char *)hostname, portno, 0); -#else - *ldap = ldap_init((char *)hostname, portno); -#endif - if (*ldap != NULL) { - return apr_ldap_set_option(pool, *ldap, APR_LDAP_OPT_TLS, &secure, result_err); - } - else { - /* handle the error case */ - apr_ldap_err_t *result = (apr_ldap_err_t *)apr_pcalloc(pool, sizeof(apr_ldap_err_t)); - *result_err = result; - - result->reason = "APR LDAP: Unable to initialize the LDAP connection"; - result->rc = -1; - return APR_EGENERAL; - } - -} - - -/** - * APR LDAP info function - * - * This function returns a string describing the LDAP toolkit - * currently in use. The string is placed inside result_err->reason. - */ -APU_DECLARE(int) apr_ldap_info(apr_pool_t *pool, apr_ldap_err_t **result_err) -{ - apr_ldap_err_t *result = (apr_ldap_err_t *)apr_pcalloc(pool, sizeof(apr_ldap_err_t)); - *result_err = result; - - result->reason = "APR LDAP: Built with " - LDAP_VENDOR_NAME - " LDAP SDK"; - return APR_SUCCESS; - -} - -#endif /* APR_HAS_LDAP */ diff --git a/libs/apr-util/ldap/apr_ldap_option.c b/libs/apr-util/ldap/apr_ldap_option.c deleted file mode 100644 index 43eb8d090e..0000000000 --- a/libs/apr-util/ldap/apr_ldap_option.c +++ /dev/null @@ -1,598 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* apr_ldap_option.c -- LDAP options - * - * The LDAP SDK allows the getting and setting of options on an LDAP - * connection. - * - */ - -#include "apr.h" -#include "apu.h" -#include "apr_ldap.h" -#include "apr_errno.h" -#include "apr_pools.h" -#include "apr_strings.h" -#include "apr_tables.h" - -#if APR_HAS_LDAP - -static void option_set_cert(apr_pool_t *pool, LDAP *ldap, const void *invalue, - apr_ldap_err_t *result); -static void option_set_tls(apr_pool_t *pool, LDAP *ldap, const void *invalue, - apr_ldap_err_t *result); - -/** - * APR LDAP get option function - * - * This function gets option values from a given LDAP session if - * one was specified. - */ -APU_DECLARE(int) apr_ldap_get_option(apr_pool_t *pool, - LDAP *ldap, - int option, - void *outvalue, - apr_ldap_err_t **result_err) -{ - apr_ldap_err_t *result; - - result = apr_pcalloc(pool, sizeof(apr_ldap_err_t)); - *result_err = result; - if (!result) { - return APR_ENOMEM; - } - - /* get the option specified using the native LDAP function */ - result->rc = ldap_get_option(ldap, option, outvalue); - - /* handle the error case */ - if (result->rc != LDAP_SUCCESS) { - result->msg = ldap_err2string(result-> rc); - result->reason = apr_pstrdup(pool, "LDAP: Could not get an option"); - return APR_EGENERAL; - } - - return APR_SUCCESS; - -} - -/** - * APR LDAP set option function - * - * This function sets option values to a given LDAP session if - * one was specified. - * - * Where an option is not supported by an LDAP toolkit, this function - * will try and apply legacy functions to achieve the same effect, - * depending on the platform. - */ -APU_DECLARE(int) apr_ldap_set_option(apr_pool_t *pool, - LDAP *ldap, - int option, - const void *invalue, - apr_ldap_err_t **result_err) -{ - apr_ldap_err_t *result; - - result = apr_pcalloc(pool, sizeof(apr_ldap_err_t)); - *result_err = result; - if (!result) { - return APR_ENOMEM; - } - - switch (option) { - case APR_LDAP_OPT_TLS_CERT: - option_set_cert(pool, ldap, invalue, result); - break; - - case APR_LDAP_OPT_TLS: - option_set_tls(pool, ldap, invalue, result); - break; - - case APR_LDAP_OPT_VERIFY_CERT: -#if APR_HAS_NETSCAPE_LDAPSDK || APR_HAS_SOLARIS_LDAPSDK || APR_HAS_MOZILLA_LDAPSK - result->reason = "LDAP: Verify certificate not yet supported by APR on the " - "Netscape, Solaris or Mozilla LDAP SDKs"; - result->rc = -1; - return APR_EGENERAL; -#endif -#if APR_HAS_NOVELL_LDAPSDK - if (*((int*)invalue)) { - result->rc = ldapssl_set_verify_mode(LDAPSSL_VERIFY_SERVER); - } - else { - result->rc = ldapssl_set_verify_mode(LDAPSSL_VERIFY_NONE); - } -#endif -#if APR_HAS_OPENLDAP_LDAPSDK -#ifdef LDAP_OPT_X_TLS - /* This is not a per-connection setting so just pass NULL for the - Ldap connection handle */ - if (*((int*)invalue)) { - int i = LDAP_OPT_X_TLS_DEMAND; - result->rc = ldap_set_option(NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, &i); - } - else { - int i = LDAP_OPT_X_TLS_NEVER; - result->rc = ldap_set_option(NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, &i); - } -#else - result->reason = "LDAP: SSL/TLS not yet supported by APR on this " - "version of the OpenLDAP toolkit"; - result->rc = -1; - return APR_EGENERAL; -#endif -#endif - - /* handle the error case */ - if (result->rc != LDAP_SUCCESS) { - result->msg = ldap_err2string(result->rc); - result->reason = "LDAP: Could not set verify mode"; - } - break; - - default: - /* set the option specified using the native LDAP function */ - result->rc = ldap_set_option(ldap, option, (void *)invalue); - - /* handle the error case */ - if (result->rc != LDAP_SUCCESS) { - result->msg = ldap_err2string(result->rc); - result->reason = "LDAP: Could not set an option"; - } - break; - } - - /* handle the error case */ - if (result->rc != LDAP_SUCCESS) { - return APR_EGENERAL; - } - - return APR_SUCCESS; - -} - -/** - * Handle APR_LDAP_OPT_TLS - * - * This function sets the type of TLS to be applied to this connection. - * The options are: - * APR_LDAP_NONE: no encryption - * APR_LDAP_SSL: SSL encryption (ldaps://) - * APR_LDAP_STARTTLS: STARTTLS encryption - * APR_LDAP_STOPTLS: Stop existing TLS connecttion - */ -static void option_set_tls(apr_pool_t *pool, LDAP *ldap, const void *invalue, - apr_ldap_err_t *result) -{ - int tls = * (const int *)invalue; - -#if APR_HAS_LDAP_SSL /* compiled with ssl support */ - - /* Netscape/Mozilla/Solaris SDK */ -#if APR_HAS_NETSCAPE_LDAPSDK || APR_HAS_SOLARIS_LDAPSDK || APR_HAS_MOZILLA_LDAPSK -#if APR_HAS_LDAPSSL_INSTALL_ROUTINES - if (tls == APR_LDAP_SSL) { - result->rc = ldapssl_install_routines(ldap); -#ifdef LDAP_OPT_SSL - /* apparently Netscape and Mozilla need this too, Solaris doesn't */ - if (result->rc == LDAP_SUCCESS) { - result->rc = ldap_set_option(ldap, LDAP_OPT_SSL, LDAP_OPT_ON); - } -#endif - if (result->rc != LDAP_SUCCESS) { - result->msg = ldap_err2string(result->rc); - result->reason = "LDAP: Could not switch SSL on for this " - "connection."; - } - } - else if (tls == APR_LDAP_STARTTLS) { - result->reason = "LDAP: STARTTLS is not supported by the " - "Netscape/Mozilla/Solaris SDK"; - result->rc = -1; - } - else if (tls == APR_LDAP_STOPTLS) { - result->reason = "LDAP: STOPTLS is not supported by the " - "Netscape/Mozilla/Solaris SDK"; - result->rc = -1; - } -#else - if (tls != APR_LDAP_NONE) { - result->reason = "LDAP: SSL/TLS is not supported by this version " - "of the Netscape/Mozilla/Solaris SDK"; - result->rc = -1; - } -#endif -#endif - - /* Novell SDK */ -#if APR_HAS_NOVELL_LDAPSDK - /* ldapssl_install_routines(ldap) - * Behavior is unpredictable when other LDAP functions are called - * between the ldap_init function and the ldapssl_install_routines - * function. - * - * STARTTLS is supported by the ldap_start_tls_s() method - */ - if (tls == APR_LDAP_SSL) { - result->rc = ldapssl_install_routines(ldap); - if (result->rc != LDAP_SUCCESS) { - result->msg = ldap_err2string(result->rc); - result->reason = "LDAP: Could not switch SSL on for this " - "connection."; - } - } - if (tls == APR_LDAP_STARTTLS) { - result->rc = ldapssl_start_tls(ldap); - if (result->rc != LDAP_SUCCESS) { - result->msg = ldap_err2string(result->rc); - result->reason = "LDAP: Could not start TLS on this connection"; - } - } - else if (tls == APR_LDAP_STOPTLS) { - result->rc = ldapssl_stop_tls(ldap); - if (result->rc != LDAP_SUCCESS) { - result->msg = ldap_err2string(result->rc); - result->reason = "LDAP: Could not stop TLS on this connection"; - } - } -#endif - - /* OpenLDAP SDK */ -#if APR_HAS_OPENLDAP_LDAPSDK -#ifdef LDAP_OPT_X_TLS - if (tls == APR_LDAP_SSL) { - int SSLmode = LDAP_OPT_X_TLS_HARD; - result->rc = ldap_set_option(ldap, LDAP_OPT_X_TLS, &SSLmode); - if (result->rc != LDAP_SUCCESS) { - result->reason = "LDAP: ldap_set_option failed. " - "Could not set LDAP_OPT_X_TLS to " - "LDAP_OPT_X_TLS_HARD"; - result->msg = ldap_err2string(result->rc); - } - } - else if (tls == APR_LDAP_STARTTLS) { - result->rc = ldap_start_tls_s(ldap, NULL, NULL); - if (result->rc != LDAP_SUCCESS) { - result->reason = "LDAP: ldap_start_tls_s() failed"; - result->msg = ldap_err2string(result->rc); - } - } - else if (tls == APR_LDAP_STOPTLS) { - result->reason = "LDAP: STOPTLS is not supported by the " - "OpenLDAP SDK"; - result->rc = -1; - } -#else - if (tls != APR_LDAP_NONE) { - result->reason = "LDAP: SSL/TLS not yet supported by APR on this " - "version of the OpenLDAP toolkit"; - result->rc = -1; - } -#endif -#endif - - /* Microsoft SDK */ -#if APR_HAS_MICROSOFT_LDAPSDK - if (tls == APR_LDAP_NONE) { - result->rc = ldap_set_option(ldap, LDAP_OPT_SSL, LDAP_OPT_OFF); - if (result->rc != LDAP_SUCCESS) { - result->reason = "LDAP: an attempt to set LDAP_OPT_SSL off " - "failed."; - result->msg = ldap_err2string(result->rc); - } - } - else if (tls == APR_LDAP_SSL) { - result->rc = ldap_set_option(ldap, LDAP_OPT_SSL, LDAP_OPT_ON); - if (result->rc != LDAP_SUCCESS) { - result->reason = "LDAP: an attempt to set LDAP_OPT_SSL on " - "failed."; - result->msg = ldap_err2string(result->rc); - } - } -#if APR_HAS_LDAP_START_TLS_S - else if (tls == APR_LDAP_STARTTLS) { - result->rc = ldap_start_tls_s(ldap, NULL, NULL, NULL, NULL); - if (result->rc != LDAP_SUCCESS) { - result->reason = "LDAP: ldap_start_tls_s() failed"; - result->msg = ldap_err2string(result->rc); - } - } - else if (tls == APR_LDAP_STOPTLS) { - result->rc = ldap_stop_tls_s(ldap); - if (result->rc != LDAP_SUCCESS) { - result->reason = "LDAP: ldap_stop_tls_s() failed"; - result->msg = ldap_err2string(result->rc); - } - } -#endif -#endif - -#if APR_HAS_OTHER_LDAPSDK - if (tls != APR_LDAP_NONE) { - result->reason = "LDAP: SSL/TLS is currently not supported by " - "APR on this LDAP SDK"; - result->rc = -1; - } -#endif - -#endif /* APR_HAS_LDAP_SSL */ - -} - -/** - * Handle APR_LDAP_OPT_TLS_CACERTFILE - * - * This function sets the CA certificate for further SSL/TLS connections. - * - * The file provided are in different formats depending on the toolkit used: - * - * Netscape: cert7.db file - * Novell: PEM or DER - * OpenLDAP: PEM (others supported?) - * Microsoft: unknown - * Solaris: unknown - */ -static void option_set_cert(apr_pool_t *pool, LDAP *ldap, - const void *invalue, apr_ldap_err_t *result) -{ - apr_array_header_t *certs = (apr_array_header_t *)invalue; - struct apr_ldap_opt_tls_cert_t *ents = (struct apr_ldap_opt_tls_cert_t *)certs->elts; - int i = 0; - -#if APR_HAS_LDAP_SSL - - /* Netscape/Mozilla/Solaris SDK */ -#if APR_HAS_NETSCAPE_LDAPSDK || APR_HAS_SOLARIS_LDAPSDK || APR_HAS_MOZILLA_LDAPSDK -#if APR_HAS_LDAPSSL_CLIENT_INIT - const char *nickname = NULL; - const char *secmod = NULL; - const char *key3db = NULL; - const char *cert7db = NULL; - const char *password = NULL; - - /* set up cert7.db, key3.db and secmod parameters */ - for (i = 0; i < certs->nelts; i++) { - switch (ents[i].type) { - case APR_LDAP_CA_TYPE_CERT7_DB: - cert7db = ents[i].path; - break; - case APR_LDAP_CA_TYPE_SECMOD: - secmod = ents[i].path; - break; - case APR_LDAP_CERT_TYPE_KEY3_DB: - key3db = ents[i].path; - break; - case APR_LDAP_CERT_TYPE_NICKNAME: - nickname = ents[i].path; - password = ents[i].password; - break; - default: - result->rc = -1; - result->reason = "LDAP: The Netscape/Mozilla LDAP SDK only " - "understands the CERT7, KEY3 and SECMOD " - "file types."; - break; - } - if (result->rc != LDAP_SUCCESS) { - break; - } - } - - /* actually set the certificate parameters */ - if (result->rc == LDAP_SUCCESS) { - if (nickname) { - result->rc = ldapssl_enable_clientauth(ldap, "", - (char *)password, - (char *)nickname); - if (result->rc != LDAP_SUCCESS) { - result->reason = "LDAP: could not set client certificate: " - "ldapssl_enable_clientauth() failed."; - result->msg = ldap_err2string(result->rc); - } - } - else if (secmod) { - result->rc = ldapssl_advclientauth_init(cert7db, NULL, - key3db ? 1 : 0, key3db, NULL, - 1, secmod, LDAPSSL_AUTH_CNCHECK); - if (result->rc != LDAP_SUCCESS) { - result->reason = "LDAP: ldapssl_advclientauth_init() failed."; - result->msg = ldap_err2string(result->rc); - } - } - else if (key3db) { - result->rc = ldapssl_clientauth_init(cert7db, NULL, - 1, key3db, NULL); - if (result->rc != LDAP_SUCCESS) { - result->reason = "LDAP: ldapssl_clientauth_init() failed."; - result->msg = ldap_err2string(result->rc); - } - } - else { - result->rc = ldapssl_client_init(cert7db, NULL); - if (result->rc != LDAP_SUCCESS) { - result->reason = "LDAP: ldapssl_client_init() failed."; - result->msg = ldap_err2string(result->rc); - } - } - } -#else - result->reason = "LDAP: SSL/TLS ldapssl_client_init() function not " - "supported by this Netscape/Mozilla/Solaris SDK. " - "Certificate authority file not set"; - result->rc = -1; -#endif -#endif - - /* Novell SDK */ -#if APR_HAS_NOVELL_LDAPSDK -#if APR_HAS_LDAPSSL_CLIENT_INIT && APR_HAS_LDAPSSL_ADD_TRUSTED_CERT && APR_HAS_LDAPSSL_CLIENT_DEINIT - /* The Novell library cannot support per connection certificates. Error - * out if the ldap handle is provided. - */ - if (ldap) { - result->rc = -1; - result->reason = "LDAP: The Novell LDAP SDK cannot support the setting " - "of certificates or keys on a per connection basis."; - } - /* Novell's library needs to be initialised first */ - else { - result->rc = ldapssl_client_init(NULL, NULL); - if (result->rc != LDAP_SUCCESS) { - result->msg = ldap_err2string(result-> rc); - result->reason = apr_pstrdup(pool, "LDAP: Could not " - "initialize SSL"); - } - } - /* set one or more certificates */ - for (i = 0; LDAP_SUCCESS == result->rc && i < certs->nelts; i++) { - /* Novell SDK supports DER or BASE64 files. */ - switch (ents[i].type) { - case APR_LDAP_CA_TYPE_DER: - result->rc = ldapssl_add_trusted_cert((void *)ents[i].path, - LDAPSSL_CERT_FILETYPE_DER); - result->msg = ldap_err2string(result->rc); - break; - case APR_LDAP_CA_TYPE_BASE64: - result->rc = ldapssl_add_trusted_cert((void *)ents[i].path, - LDAPSSL_CERT_FILETYPE_B64); - result->msg = ldap_err2string(result->rc); - break; - case APR_LDAP_CERT_TYPE_DER: - result->rc = ldapssl_set_client_cert((void *)ents[i].path, - LDAPSSL_CERT_FILETYPE_DER, - (void*)ents[i].password); - result->msg = ldap_err2string(result->rc); - break; - case APR_LDAP_CERT_TYPE_BASE64: - result->rc = ldapssl_set_client_cert((void *)ents[i].path, - LDAPSSL_CERT_FILETYPE_B64, - (void*)ents[i].password); - result->msg = ldap_err2string(result->rc); - break; - case APR_LDAP_CERT_TYPE_PFX: - result->rc = ldapssl_set_client_cert((void *)ents[i].path, - LDAPSSL_FILETYPE_P12, - (void*)ents[i].password); - result->msg = ldap_err2string(result->rc); - break; - case APR_LDAP_KEY_TYPE_DER: - result->rc = ldapssl_set_client_private_key((void *)ents[i].path, - LDAPSSL_CERT_FILETYPE_DER, - (void*)ents[i].password); - result->msg = ldap_err2string(result->rc); - break; - case APR_LDAP_KEY_TYPE_BASE64: - result->rc = ldapssl_set_client_private_key((void *)ents[i].path, - LDAPSSL_CERT_FILETYPE_B64, - (void*)ents[i].password); - result->msg = ldap_err2string(result->rc); - break; - case APR_LDAP_KEY_TYPE_PFX: - result->rc = ldapssl_set_client_private_key((void *)ents[i].path, - LDAPSSL_FILETYPE_P12, - (void*)ents[i].password); - result->msg = ldap_err2string(result->rc); - break; - default: - result->rc = -1; - result->reason = "LDAP: The Novell LDAP SDK only understands the " - "DER and PEM (BASE64) file types."; - break; - } - if (result->rc != LDAP_SUCCESS) { - break; - } - } -#else - result->reason = "LDAP: ldapssl_client_init(), " - "ldapssl_add_trusted_cert() or " - "ldapssl_client_deinit() functions not supported " - "by this Novell SDK. Certificate authority file " - "not set"; - result->rc = -1; -#endif -#endif - - /* OpenLDAP SDK */ -#if APR_HAS_OPENLDAP_LDAPSDK -#ifdef LDAP_OPT_X_TLS_CACERTFILE - /* set one or more certificates */ - /* FIXME: make it support setting directories as well as files */ - for (i = 0; i < certs->nelts; i++) { - /* OpenLDAP SDK supports BASE64 files. */ - switch (ents[i].type) { - case APR_LDAP_CA_TYPE_BASE64: - result->rc = ldap_set_option(ldap, LDAP_OPT_X_TLS_CACERTFILE, - (void *)ents[i].path); - result->msg = ldap_err2string(result->rc); - break; - case APR_LDAP_CERT_TYPE_BASE64: - result->rc = ldap_set_option(ldap, LDAP_OPT_X_TLS_CERTFILE, - (void *)ents[i].path); - result->msg = ldap_err2string(result->rc); - break; - case APR_LDAP_KEY_TYPE_BASE64: - result->rc = ldap_set_option(ldap, LDAP_OPT_X_TLS_KEYFILE, - (void *)ents[i].path); - result->msg = ldap_err2string(result->rc); - break; - default: - result->rc = -1; - result->reason = "LDAP: The OpenLDAP SDK only understands the " - "PEM (BASE64) file type."; - break; - } - if (result->rc != LDAP_SUCCESS) { - break; - } - } -#else - result->reason = "LDAP: LDAP_OPT_X_TLS_CACERTFILE not " - "defined by this OpenLDAP SDK. Certificate " - "authority file not set"; - result->rc = -1; -#endif -#endif - - /* Microsoft SDK */ -#if APR_HAS_MICROSOFT_LDAPSDK - /* Microsoft SDK use the registry certificate store - error out - * here with a message explaining this. */ - result->reason = "LDAP: CA certificates cannot be set using this method, " - "as they are stored in the registry instead."; - result->rc = -1; -#endif - - /* SDK not recognised */ -#if APR_HAS_OTHER_LDAPSDK - result->reason = "LDAP: LDAP_OPT_X_TLS_CACERTFILE not " - "defined by this LDAP SDK. Certificate " - "authority file not set"; - result->rc = -1; -#endif - -#else /* not compiled with SSL Support */ - result->reason = "LDAP: Attempt to set certificate(s) failed. " - "Not built with SSL support"; - result->rc = -1; -#endif /* APR_HAS_LDAP_SSL */ - -} - -#endif /* APR_HAS_LDAP */ - diff --git a/libs/apr-util/ldap/apr_ldap_url.c b/libs/apr-util/ldap/apr_ldap_url.c deleted file mode 100644 index 29684b7756..0000000000 --- a/libs/apr-util/ldap/apr_ldap_url.c +++ /dev/null @@ -1,694 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* Portions Copyright 1998-2002 The OpenLDAP Foundation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted only as authorized by the OpenLDAP - * Public License. A copy of this license is available at - * http://www.OpenLDAP.org/license.html or in file LICENSE in the - * top-level directory of the distribution. - * - * OpenLDAP is a registered trademark of the OpenLDAP Foundation. - * - * Individual files and/or contributed packages may be copyright by - * other parties and subject to additional restrictions. - * - * This work is derived from the University of Michigan LDAP v3.3 - * distribution. Information concerning this software is available - * at: http://www.umich.edu/~dirsvcs/ldap/ - * - * This work also contains materials derived from public sources. - * - * Additional information about OpenLDAP can be obtained at: - * http://www.openldap.org/ - */ - -/* - * Portions Copyright (c) 1992-1996 Regents of the University of Michigan. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that this notice is preserved and that due credit is given - * to the University of Michigan at Ann Arbor. The name of the University - * may not be used to endorse or promote products derived from this - * software without specific prior written permission. This software - * is provided ``as is'' without express or implied warranty. - */ - -/* apr_ldap_url.c -- LDAP URL (RFC 2255) related routines - * - * Win32 and perhaps other non-OpenLDAP based ldap libraries may be - * missing ldap_url_* APIs. We focus here on the one significant - * aspect, which is parsing. We have [for the time being] omitted - * the ldap_url_search APIs. - * - * LDAP URLs look like this: - * ldap[is]://host:port[/[dn[?[attributes][?[scope][?[filter][?exts]]]]]] - * - * where: - * attributes is a comma separated list - * scope is one of these three strings: base one sub (default=base) - * filter is an string-represented filter as in RFC 2254 - * - * e.g., ldap://host:port/dc=com?o,cn?base?o=openldap?extension - * - * Tolerates URLs that look like: and - */ - -#include "apu.h" -#include "apr_pools.h" -#include "apr_general.h" -#include "apr_strings.h" -#include "apr_ldap.h" - -#if APR_HAS_LDAP - -#if APR_HAVE_STDLIB_H -#include -#endif - -#ifndef LDAPS_PORT -#define LDAPS_PORT 636 /* ldaps:/// default LDAP over TLS port */ -#endif - -#define APR_LDAP_URL_PREFIX "ldap://" -#define APR_LDAP_URL_PREFIX_LEN (sizeof(APR_LDAP_URL_PREFIX)-1) -#define APR_LDAPS_URL_PREFIX "ldaps://" -#define APR_LDAPS_URL_PREFIX_LEN (sizeof(APR_LDAPS_URL_PREFIX)-1) -#define APR_LDAPI_URL_PREFIX "ldapi://" -#define APR_LDAPI_URL_PREFIX_LEN (sizeof(APR_LDAPI_URL_PREFIX)-1) -#define APR_LDAP_URL_URLCOLON "URL:" -#define APR_LDAP_URL_URLCOLON_LEN (sizeof(APR_LDAP_URL_URLCOLON)-1) - - -/* local functions */ -static const char* skip_url_prefix(const char *url, - int *enclosedp, - const char **scheme); - -static void apr_ldap_pvt_hex_unescape(char *s); - -static int apr_ldap_pvt_unhex(int c); - -static char **apr_ldap_str2charray(apr_pool_t *pool, - const char *str, - const char *brkstr); - - -/** - * Is this URL an ldap url? - * - */ -APU_DECLARE(int) apr_ldap_is_ldap_url(const char *url) -{ - int enclosed; - const char * scheme; - - if( url == NULL ) { - return 0; - } - - if( skip_url_prefix( url, &enclosed, &scheme ) == NULL ) { - return 0; - } - - return 1; -} - -/** - * Is this URL a secure ldap url? - * - */ -APU_DECLARE(int) apr_ldap_is_ldaps_url(const char *url) -{ - int enclosed; - const char * scheme; - - if( url == NULL ) { - return 0; - } - - if( skip_url_prefix( url, &enclosed, &scheme ) == NULL ) { - return 0; - } - - return strcmp(scheme, "ldaps") == 0; -} - -/** - * Is this URL an ldap socket url? - * - */ -APU_DECLARE(int) apr_ldap_is_ldapi_url(const char *url) -{ - int enclosed; - const char * scheme; - - if( url == NULL ) { - return 0; - } - - if( skip_url_prefix( url, &enclosed, &scheme ) == NULL ) { - return 0; - } - - return strcmp(scheme, "ldapi") == 0; -} - - -static const char *skip_url_prefix(const char *url, int *enclosedp, - const char **scheme) -{ - /* - * return non-zero if this looks like a LDAP URL; zero if not - * if non-zero returned, *urlp will be moved past "ldap://" part of URL - */ - const char *p; - - if ( url == NULL ) { - return( NULL ); - } - - p = url; - - /* skip leading '<' (if any) */ - if ( *p == '<' ) { - *enclosedp = 1; - ++p; - } else { - *enclosedp = 0; - } - - /* skip leading "URL:" (if any) */ - if ( strncasecmp( p, APR_LDAP_URL_URLCOLON, APR_LDAP_URL_URLCOLON_LEN ) == 0 ) { - p += APR_LDAP_URL_URLCOLON_LEN; - } - - /* check for "ldap://" prefix */ - if ( strncasecmp( p, APR_LDAP_URL_PREFIX, APR_LDAP_URL_PREFIX_LEN ) == 0 ) { - /* skip over "ldap://" prefix and return success */ - p += APR_LDAP_URL_PREFIX_LEN; - *scheme = "ldap"; - return( p ); - } - - /* check for "ldaps://" prefix */ - if ( strncasecmp( p, APR_LDAPS_URL_PREFIX, APR_LDAPS_URL_PREFIX_LEN ) == 0 ) { - /* skip over "ldaps://" prefix and return success */ - p += APR_LDAPS_URL_PREFIX_LEN; - *scheme = "ldaps"; - return( p ); - } - - /* check for "ldapi://" prefix */ - if ( strncasecmp( p, APR_LDAPI_URL_PREFIX, APR_LDAPI_URL_PREFIX_LEN ) == 0 ) { - /* skip over "ldapi://" prefix and return success */ - p += APR_LDAPI_URL_PREFIX_LEN; - *scheme = "ldapi"; - return( p ); - } - - return( NULL ); -} - - -static int str2scope(const char *p) -{ - if ( strcasecmp( p, "one" ) == 0 ) { - return LDAP_SCOPE_ONELEVEL; - - } else if ( strcasecmp( p, "onetree" ) == 0 ) { - return LDAP_SCOPE_ONELEVEL; - - } else if ( strcasecmp( p, "base" ) == 0 ) { - return LDAP_SCOPE_BASE; - - } else if ( strcasecmp( p, "sub" ) == 0 ) { - return LDAP_SCOPE_SUBTREE; - - } else if ( strcasecmp( p, "subtree" ) == 0 ) { - return LDAP_SCOPE_SUBTREE; - } - - return( -1 ); -} - - -/** - * Parse the URL provided into an apr_ldap_url_desc_t object. - * - * APR_SUCCESS is returned on success, APR_EGENERAL on failure. - * The LDAP result code and reason string is returned in the - * apr_ldap_err_t structure. - */ -APU_DECLARE(int) apr_ldap_url_parse_ext(apr_pool_t *pool, - const char *url_in, - apr_ldap_url_desc_t **ludpp, - apr_ldap_err_t **result_err) -{ - apr_ldap_url_desc_t *ludp; - char *p, *q, *r; - int i, enclosed; - const char *scheme = NULL; - const char *url_tmp; - char *url; - - apr_ldap_err_t *result = (apr_ldap_err_t *)apr_pcalloc(pool, sizeof(apr_ldap_err_t)); - *result_err = result; - - /* sanity check our parameters */ - if( url_in == NULL || ludpp == NULL ) { - result->reason = "Either the LDAP URL, or the URL structure was NULL. Oops."; - result->rc = APR_LDAP_URL_ERR_PARAM; - return APR_EGENERAL; - } - - *ludpp = NULL; /* pessimistic */ - - url_tmp = skip_url_prefix( url_in, &enclosed, &scheme ); - if ( url_tmp == NULL ) { - result->reason = "The scheme was not recognised as a valid LDAP URL scheme."; - result->rc = APR_LDAP_URL_ERR_BADSCHEME; - return APR_EGENERAL; - } - - /* make working copy of the remainder of the URL */ - url = (char *)apr_pstrdup(pool, url_tmp); - if ( url == NULL ) { - result->reason = "Out of memory parsing LDAP URL."; - result->rc = APR_LDAP_URL_ERR_MEM; - return APR_EGENERAL; - } - - if ( enclosed ) { - p = &url[strlen(url)-1]; - - if( *p != '>' ) { - result->reason = "Bad enclosure error while parsing LDAP URL."; - result->rc = APR_LDAP_URL_ERR_BADENCLOSURE; - return APR_EGENERAL; - } - - *p = '\0'; - } - - /* allocate return struct */ - ludp = (apr_ldap_url_desc_t *)apr_pcalloc(pool, sizeof(apr_ldap_url_desc_t)); - if ( ludp == NULL ) { - result->reason = "Out of memory parsing LDAP URL."; - result->rc = APR_LDAP_URL_ERR_MEM; - return APR_EGENERAL; - } - - ludp->lud_next = NULL; - ludp->lud_host = NULL; - ludp->lud_port = LDAP_PORT; - ludp->lud_dn = NULL; - ludp->lud_attrs = NULL; - ludp->lud_filter = NULL; - ludp->lud_scope = -1; - ludp->lud_filter = NULL; - ludp->lud_exts = NULL; - - ludp->lud_scheme = (char *)apr_pstrdup(pool, scheme); - if ( ludp->lud_scheme == NULL ) { - result->reason = "Out of memory parsing LDAP URL."; - result->rc = APR_LDAP_URL_ERR_MEM; - return APR_EGENERAL; - } - - if( strcasecmp( ludp->lud_scheme, "ldaps" ) == 0 ) { - ludp->lud_port = LDAPS_PORT; - } - - /* scan forward for '/' that marks end of hostport and begin. of dn */ - p = strchr( url, '/' ); - - if( p != NULL ) { - /* terminate hostport; point to start of dn */ - *p++ = '\0'; - } - - /* IPv6 syntax with [ip address]:port */ - if ( *url == '[' ) { - r = strchr( url, ']' ); - if ( r == NULL ) { - result->reason = "Bad LDAP URL while parsing IPV6 syntax."; - result->rc = APR_LDAP_URL_ERR_BADURL; - return APR_EGENERAL; - } - *r++ = '\0'; - q = strrchr( r, ':' ); - } else { - q = strrchr( url, ':' ); - } - - if ( q != NULL ) { - apr_ldap_pvt_hex_unescape( ++q ); - - if( *q == '\0' ) { - result->reason = "Bad LDAP URL while parsing."; - result->rc = APR_LDAP_URL_ERR_BADURL; - return APR_EGENERAL; - } - - ludp->lud_port = atoi( q ); - } - - apr_ldap_pvt_hex_unescape( url ); - - /* If [ip address]:port syntax, url is [ip and we skip the [ */ - ludp->lud_host = (char *)apr_pstrdup(pool, url + ( *url == '[' )); - if( ludp->lud_host == NULL ) { - result->reason = "Out of memory parsing LDAP URL."; - result->rc = APR_LDAP_URL_ERR_MEM; - return APR_EGENERAL; - } - - /* - * Kludge. ldap://111.222.333.444:389??cn=abc,o=company - * - * On early Novell releases, search references/referrals were returned - * in this format, i.e., the dn was kind of in the scope position, - * but the required slash is missing. The whole thing is illegal syntax, - * but we need to account for it. Fortunately it can't be confused with - * anything real. - */ - if( (p == NULL) && (q != NULL) && ((q = strchr( q, '?')) != NULL)) { - q++; - /* ? immediately followed by question */ - if( *q == '?') { - q++; - if( *q != '\0' ) { - /* parse dn part */ - apr_ldap_pvt_hex_unescape( q ); - ludp->lud_dn = (char *)apr_pstrdup(pool, q); - } else { - ludp->lud_dn = (char *)apr_pstrdup(pool, ""); - } - - if( ludp->lud_dn == NULL ) { - result->reason = "Out of memory parsing LDAP URL."; - result->rc = APR_LDAP_URL_ERR_MEM; - return APR_EGENERAL; - } - } - } - - if( p == NULL ) { - *ludpp = ludp; - return APR_SUCCESS; - } - - /* scan forward for '?' that may marks end of dn */ - q = strchr( p, '?' ); - - if( q != NULL ) { - /* terminate dn part */ - *q++ = '\0'; - } - - if( *p != '\0' ) { - /* parse dn part */ - apr_ldap_pvt_hex_unescape( p ); - ludp->lud_dn = (char *)apr_pstrdup(pool, p); - } else { - ludp->lud_dn = (char *)apr_pstrdup(pool, ""); - } - - if( ludp->lud_dn == NULL ) { - result->reason = "Out of memory parsing LDAP URL."; - result->rc = APR_LDAP_URL_ERR_MEM; - return APR_EGENERAL; - } - - if( q == NULL ) { - /* no more */ - *ludpp = ludp; - return APR_SUCCESS; - } - - /* scan forward for '?' that may marks end of attributes */ - p = q; - q = strchr( p, '?' ); - - if( q != NULL ) { - /* terminate attributes part */ - *q++ = '\0'; - } - - if( *p != '\0' ) { - /* parse attributes */ - apr_ldap_pvt_hex_unescape( p ); - ludp->lud_attrs = apr_ldap_str2charray(pool, p, ","); - - if( ludp->lud_attrs == NULL ) { - result->reason = "Bad attributes encountered while parsing LDAP URL."; - result->rc = APR_LDAP_URL_ERR_BADATTRS; - return APR_EGENERAL; - } - } - - if ( q == NULL ) { - /* no more */ - *ludpp = ludp; - return APR_SUCCESS; - } - - /* scan forward for '?' that may marks end of scope */ - p = q; - q = strchr( p, '?' ); - - if( q != NULL ) { - /* terminate the scope part */ - *q++ = '\0'; - } - - if( *p != '\0' ) { - /* parse the scope */ - apr_ldap_pvt_hex_unescape( p ); - ludp->lud_scope = str2scope( p ); - - if( ludp->lud_scope == -1 ) { - result->reason = "Bad scope encountered while parsing LDAP URL."; - result->rc = APR_LDAP_URL_ERR_BADSCOPE; - return APR_EGENERAL; - } - } - - if ( q == NULL ) { - /* no more */ - *ludpp = ludp; - return APR_SUCCESS; - } - - /* scan forward for '?' that may marks end of filter */ - p = q; - q = strchr( p, '?' ); - - if( q != NULL ) { - /* terminate the filter part */ - *q++ = '\0'; - } - - if( *p != '\0' ) { - /* parse the filter */ - apr_ldap_pvt_hex_unescape( p ); - - if( ! *p ) { - /* missing filter */ - result->reason = "Bad filter encountered while parsing LDAP URL."; - result->rc = APR_LDAP_URL_ERR_BADFILTER; - return APR_EGENERAL; - } - - ludp->lud_filter = (char *)apr_pstrdup(pool, p); - if( ludp->lud_filter == NULL ) { - result->reason = "Out of memory parsing LDAP URL."; - result->rc = APR_LDAP_URL_ERR_MEM; - return APR_EGENERAL; - } - } - - if ( q == NULL ) { - /* no more */ - *ludpp = ludp; - return APR_SUCCESS; - } - - /* scan forward for '?' that may marks end of extensions */ - p = q; - q = strchr( p, '?' ); - - if( q != NULL ) { - /* extra '?' */ - result->reason = "Bad URL encountered while parsing LDAP URL."; - result->rc = APR_LDAP_URL_ERR_BADURL; - return APR_EGENERAL; - } - - /* parse the extensions */ - ludp->lud_exts = apr_ldap_str2charray(pool, p, ","); - if( ludp->lud_exts == NULL ) { - result->reason = "Bad extensions encountered while parsing LDAP URL."; - result->rc = APR_LDAP_URL_ERR_BADEXTS; - return APR_EGENERAL; - } - - for( i=0; ludp->lud_exts[i] != NULL; i++ ) { - apr_ldap_pvt_hex_unescape( ludp->lud_exts[i] ); - - if( *ludp->lud_exts[i] == '!' ) { - /* count the number of critical extensions */ - ludp->lud_crit_exts++; - } - } - - if( i == 0 ) { - /* must have 1 or more */ - result->reason = "Bad extensions encountered while parsing LDAP URL."; - result->rc = APR_LDAP_URL_ERR_BADEXTS; - return APR_EGENERAL; - } - - /* no more */ - *ludpp = ludp; - return APR_SUCCESS; -} - - -/** - * Parse the URL provided into an apr_ldap_url_desc_t object. - * - * APR_SUCCESS is returned on success, APR_EGENERAL on failure. - * The LDAP result code and reason string is returned in the - * apr_ldap_err_t structure. - */ -APU_DECLARE(int) apr_ldap_url_parse(apr_pool_t *pool, - const char *url_in, - apr_ldap_url_desc_t **ludpp, - apr_ldap_err_t **result_err) -{ - - int rc = apr_ldap_url_parse_ext(pool, url_in, ludpp, result_err); - if( rc != APR_SUCCESS ) { - return rc; - } - - if ((*ludpp)->lud_scope == -1) { - (*ludpp)->lud_scope = LDAP_SCOPE_BASE; - } - - if ((*ludpp)->lud_host != NULL && *(*ludpp)->lud_host == '\0') { - (*ludpp)->lud_host = NULL; - } - - return rc; - -} - - -static void apr_ldap_pvt_hex_unescape(char *s) -{ - /* - * Remove URL hex escapes from s... done in place. The basic concept for - * this routine is borrowed from the WWW library HTUnEscape() routine. - */ - char *p; - - for ( p = s; *s != '\0'; ++s ) { - if ( *s == '%' ) { - if ( *++s == '\0' ) { - break; - } - *p = apr_ldap_pvt_unhex( *s ) << 4; - if ( *++s == '\0' ) { - break; - } - *p++ += apr_ldap_pvt_unhex( *s ); - } else { - *p++ = *s; - } - } - - *p = '\0'; -} - - -static int apr_ldap_pvt_unhex(int c) -{ - return( c >= '0' && c <= '9' ? c - '0' - : c >= 'A' && c <= 'F' ? c - 'A' + 10 - : c - 'a' + 10 ); -} - - -/** - * Convert a string to a character array - */ -static char **apr_ldap_str2charray(apr_pool_t *pool, - const char *str_in, - const char *brkstr) -{ - char **res; - char *str, *s; - char *lasts; - int i; - - /* protect the input string from strtok */ - str = (char *)apr_pstrdup(pool, str_in); - if( str == NULL ) { - return NULL; - } - - i = 1; - for ( s = str; *s; s++ ) { - /* Warning: this strchr was previously ldap_utf8_strchr(), check - * whether this particular code has any charset issues. - */ - if ( strchr( brkstr, *s ) != NULL ) { - i++; - } - } - - res = (char **) apr_pcalloc(pool, (i + 1) * sizeof(char *)); - if( res == NULL ) { - return NULL; - } - - i = 0; - - for ( s = (char *)apr_strtok( str, brkstr, &lasts ); - s != NULL; - s = (char *)apr_strtok( NULL, brkstr, &lasts ) ) { - - res[i] = (char *)apr_pstrdup(pool, s); - if(res[i] == NULL) { - return NULL; - } - - i++; - } - - res[i] = NULL; - - return( res ); - -} - -#endif /* APR_HAS_LDAP */ diff --git a/libs/apr-util/libaprutil.dsp b/libs/apr-util/libaprutil.dsp deleted file mode 100644 index 4eb1c49351..0000000000 --- a/libs/apr-util/libaprutil.dsp +++ /dev/null @@ -1,614 +0,0 @@ -# Microsoft Developer Studio Project File - Name="libaprutil" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=libaprutil - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "libaprutil.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "libaprutil.mak" CFG="libaprutil - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "libaprutil - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "libaprutil - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "libaprutil - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c -# ADD CPP /nologo /MD /W3 /O2 /Oy- /Zi /I "./include" /I "../apr/include" /I "./include/private" /I "../apr-iconv/include" /I "./dbm/sdbm" /I "./xml/expat/lib" /D "NDEBUG" /D "APU_DECLARE_EXPORT" /D "APU_USE_SDBM" /D "WIN32" /D "_WINDOWS" /Fd"Release\libaprutil_src" /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL" -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL" -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" /d "APU_VERSION_ONLY" /I "./include" /I "../apr/include" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib advapi32.lib ws2_32.lib mswsock.lib wldap32.lib ole32.lib /nologo /base:"0x6EE60000" /subsystem:windows /dll /incremental:no /debug /machine:I386 /opt:ref -# ADD LINK32 kernel32.lib advapi32.lib ws2_32.lib mswsock.lib wldap32.lib ole32.lib /nologo /base:"0x6EE60000" /subsystem:windows /dll /incremental:no /debug /machine:I386 /out:"Release/libaprutil-1.dll" /opt:ref -# Begin Special Build Tool -OutDir=.\Release -SOURCE="$(InputPath)" -PostBuild_Desc=Embed .manifest -PostBuild_Cmds=if exist $(OUTDIR)\libaprutil-1.dll.manifest mt.exe -manifest $(OUTDIR)\libaprutil-1.dll.manifest -outputresource:$(OUTDIR)\libaprutil-1.dll;2 -# End Special Build Tool - -!ELSEIF "$(CFG)" == "libaprutil - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MDd /W3 /EHsc /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /c -# ADD CPP /nologo /MDd /W3 /EHsc /Zi /Od /I "./include" /I "../apr/include" /I "./include/private" /I "../apr-iconv/include" /I "./dbm/sdbm" /I "./xml/expat/lib" /D "_DEBUG" /D "APU_DECLARE_EXPORT" /D "APU_USE_SDBM" /D "WIN32" /D "_WINDOWS" /Fd"Debug\libaprutil_src" /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL" -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL" -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" /d "APU_VERSION_ONLY" /I "./include" /I "../apr/include" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib advapi32.lib ws2_32.lib mswsock.lib wldap32.lib ole32.lib /nologo /base:"0x6EE60000" /subsystem:windows /dll /incremental:no /debug /machine:I386 -# ADD LINK32 kernel32.lib advapi32.lib ws2_32.lib mswsock.lib wldap32.lib ole32.lib /nologo /base:"0x6EE60000" /subsystem:windows /dll /incremental:no /debug /machine:I386 /out:"Debug/libaprutil-1.dll" -# Begin Special Build Tool -OutDir=.\Debug -SOURCE="$(InputPath)" -PostBuild_Desc=Embed .manifest -PostBuild_Cmds=if exist $(OUTDIR)\libaprutil-1.dll.manifest mt.exe -manifest $(OUTDIR)\libaprutil-1.dll.manifest -outputresource:$(OUTDIR)\libaprutil-1.dll;2 -# End Special Build Tool - -!ENDIF - -# Begin Target - -# Name "libaprutil - Win32 Release" -# Name "libaprutil - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "" -# Begin Group "buckets" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\buckets\apr_brigade.c -# End Source File -# Begin Source File - -SOURCE=.\buckets\apr_buckets.c -# End Source File -# Begin Source File - -SOURCE=.\buckets\apr_buckets_alloc.c -# End Source File -# Begin Source File - -SOURCE=.\buckets\apr_buckets_eos.c -# End Source File -# Begin Source File - -SOURCE=.\buckets\apr_buckets_file.c -# End Source File -# Begin Source File - -SOURCE=.\buckets\apr_buckets_flush.c -# End Source File -# Begin Source File - -SOURCE=.\buckets\apr_buckets_heap.c -# End Source File -# Begin Source File - -SOURCE=.\buckets\apr_buckets_mmap.c -# End Source File -# Begin Source File - -SOURCE=.\buckets\apr_buckets_pipe.c -# End Source File -# Begin Source File - -SOURCE=.\buckets\apr_buckets_pool.c -# End Source File -# Begin Source File - -SOURCE=.\buckets\apr_buckets_refcount.c -# End Source File -# Begin Source File - -SOURCE=.\buckets\apr_buckets_simple.c -# End Source File -# Begin Source File - -SOURCE=.\buckets\apr_buckets_socket.c -# End Source File -# End Group -# Begin Group "crypto" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\crypto\apr_md4.c -# End Source File -# Begin Source File - -SOURCE=.\crypto\apr_md5.c -# End Source File -# Begin Source File - -SOURCE=.\crypto\apr_sha1.c -# End Source File -# Begin Source File - -SOURCE=.\crypto\getuuid.c -# End Source File -# Begin Source File - -SOURCE=.\crypto\uuid.c -# End Source File -# End Group -# Begin Group "dbd" -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\dbd\apr_dbd.c -# End Source File -# Begin Source File - -SOURCE=.\dbd\apr_dbd_pgsql.c -# End Source File -# Begin Source File - -SOURCE=.\dbd\apr_dbd_sqlite2.c -# End Source File -# Begin Source File - -SOURCE=.\dbd\apr_dbd_sqlite3.c -# End Source File -# End Group -# Begin Group "dbm" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\dbm\apr_dbm.c -# End Source File -# Begin Source File - -SOURCE=.\dbm\apr_dbm_berkeleydb.c -# End Source File -# Begin Source File - -SOURCE=.\dbm\apr_dbm_gdbm.c -# End Source File -# Begin Source File - -SOURCE=.\dbm\apr_dbm_sdbm.c -# End Source File -# End Group -# Begin Group "encoding" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\encoding\apr_base64.c -# End Source File -# End Group -# Begin Group "hooks" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\hooks\apr_hooks.c -# End Source File -# End Group -# Begin Group "ldap" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\ldap\apr_ldap_init.c -# End Source File -# Begin Source File - -SOURCE=.\ldap\apr_ldap_url.c -# End Source File -# Begin Source File - -SOURCE=.\ldap\apr_ldap_option.c -# End Source File -# End Group -# Begin Group "misc" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\misc\apr_date.c -# End Source File -# Begin Source File - -SOURCE=.\misc\apr_queue.c -# End Source File -# Begin Source File - -SOURCE=.\misc\apr_reslist.c -# End Source File -# Begin Source File - -SOURCE=.\misc\apr_rmm.c -# End Source File -# Begin Source File - -SOURCE=.\misc\apu_version.c -# End Source File -# End Group -# Begin Group "sdbm" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\dbm\sdbm\sdbm.c -# End Source File -# Begin Source File - -SOURCE=.\dbm\sdbm\sdbm_hash.c -# End Source File -# Begin Source File - -SOURCE=.\dbm\sdbm\sdbm_lock.c -# End Source File -# Begin Source File - -SOURCE=.\dbm\sdbm\sdbm_pair.c -# End Source File -# Begin Source File - -SOURCE=.\dbm\sdbm\sdbm_pair.h -# End Source File -# Begin Source File - -SOURCE=.\dbm\sdbm\sdbm_private.h -# End Source File -# Begin Source File - -SOURCE=.\dbm\sdbm\sdbm_tune.h -# End Source File -# End Group -# Begin Group "strmatch" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\strmatch\apr_strmatch.c -# End Source File -# End Group -# Begin Group "uri" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\uri\apr_uri.c -# End Source File -# End Group -# Begin Group "xlate" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\xlate\xlate.c -# End Source File -# End Group -# Begin Group "xml" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\xml\apr_xml.c -# End Source File -# End Group -# End Group -# Begin Group "Generated Files" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\include\apr_ldap.h.in -# End Source File -# Begin Source File - -SOURCE=.\include\apr_ldap.hnw -# End Source File -# Begin Source File - -SOURCE=.\include\apr_ldap.hw - -!IF "$(CFG)" == "libaprutil - Win32 Release" - -# Begin Custom Build - Creating apr_ldap.h from apr_ldap.hw -InputPath=.\include\apr_ldap.hw - -".\include\apr_ldap.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\include\apr_ldap.hw > .\include\apr_ldap.h - -# End Custom Build - -!ELSEIF "$(CFG)" == "libaprutil - Win32 Debug" - -# Begin Custom Build - Creating apr_ldap.h from apr_ldap.hw -InputPath=.\include\apr_ldap.hw - -".\include\apr_ldap.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\include\apr_ldap.hw > .\include\apr_ldap.h - -# End Custom Build - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\include\apu.h.in -# End Source File -# Begin Source File - -SOURCE=.\include\apu.hnw -# End Source File -# Begin Source File - -SOURCE=.\include\apu.hw - -!IF "$(CFG)" == "libaprutil - Win32 Release" - -# Begin Custom Build - Creating apu.h from apu.hw -InputPath=.\include\apu.hw - -".\include\apu.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\include\apu.hw > .\include\apu.h - -# End Custom Build - -!ELSEIF "$(CFG)" == "libaprutil - Win32 Debug" - -# Begin Custom Build - Creating apu.h from apu.hw -InputPath=.\include\apu.hw - -".\include\apu.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\include\apu.hw > .\include\apu.h - -# End Custom Build - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\include\private\apu_config.h.in -# End Source File -# Begin Source File - -SOURCE=.\include\private\apu_config.hw - -!IF "$(CFG)" == "libaprutil - Win32 Release" - -# Begin Custom Build - Creating apu_config.h from apu_config.hw -InputPath=.\include\private\apu_config.hw - -".\include\private\apu_config.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\include\private\apu_config.hw > .\include\private\apu_config.h - -# End Custom Build - -!ELSEIF "$(CFG)" == "libaprutil - Win32 Debug" - -# Begin Custom Build - Creating apu_config.h from apu_config.hw -InputPath=.\include\private\apu_config.hw - -".\include\private\apu_config.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\include\private\apu_config.hw > .\include\private\apu_config.h - -# End Custom Build - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\include\private\apu_select_dbm.h.in -# End Source File -# Begin Source File - -SOURCE=.\include\private\apu_select_dbm.hw - -!IF "$(CFG)" == "libaprutil - Win32 Release" - -# Begin Custom Build - Creating apu_select_dbm.h from apu_select_dbm.hw -InputPath=.\include\private\apu_select_dbm.hw - -".\include\private\apu_select_dbm.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\include\private\apu_select_dbm.hw > .\include\private\apu_select_dbm.h - -# End Custom Build - -!ELSEIF "$(CFG)" == "libaprutil - Win32 Debug" - -# Begin Custom Build - Creating apu_select_dbm.h from apu_select_dbm.hw -InputPath=.\include\private\apu_select_dbm.hw - -".\include\private\apu_select_dbm.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\include\private\apu_select_dbm.hw > .\include\private\apu_select_dbm.h - -# End Custom Build - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\include\apu_want.h.in -# End Source File -# Begin Source File - -SOURCE=.\include\apu_want.hnw -# End Source File -# Begin Source File - -SOURCE=.\include\apu_want.hw - -!IF "$(CFG)" == "libaprutil - Win32 Release" - -# Begin Custom Build - Creating apu_want.h from apu_want.hw -InputPath=.\include\apu_want.hw - -".\include\apu_want.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\include\apu_want.hw > .\include\apu_want.h - -# End Custom Build - -!ELSEIF "$(CFG)" == "libaprutil - Win32 Debug" - -# Begin Custom Build - Creating apu_want.h from apu_want.hw -InputPath=.\include\apu_want.hw - -".\include\apu_want.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\include\apu_want.hw > .\include\apu_want.h - -# End Custom Build - -!ENDIF - -# End Source File -# End Group -# Begin Group "Public Header Files" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\include\apr_anylock.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_base64.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_buckets.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_date.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_dbm.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_hooks.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_ldap_url.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_md4.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_md5.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_optional.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_optional_hooks.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_queue.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_reslist.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_rmm.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_sdbm.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_sha1.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_strmatch.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_uri.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_uuid.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_xlate.h -# End Source File -# Begin Source File - -SOURCE=.\include\apr_xml.h -# End Source File -# Begin Source File - -SOURCE=.\include\apu_version.h -# End Source File -# End Group -# Begin Source File - -SOURCE=.\libaprutil.rc -# End Source File - -# End Target -# End Project diff --git a/libs/apr-util/libaprutil.rc b/libs/apr-util/libaprutil.rc deleted file mode 100644 index 06a527f6bc..0000000000 --- a/libs/apr-util/libaprutil.rc +++ /dev/null @@ -1,66 +0,0 @@ -#include "apu_version.h" - -#define APU_COPYRIGHT "Copyright 2000-2005 The Apache Software " \ - "Foundation or its licensors, as applicable." - -#define APU_LICENSE "Licensed under the Apache License, Version 2.0 " \ - "(the ""License""); you may not use this file except " \ - "in compliance with the License. You may obtain a " \ - "copy of the License at\r\n\r\n" \ - "http://www.apache.org/licenses/LICENSE-2.0\r\n\r\n" \ - "Unless required by applicable law or agreed to in " \ - "writing, software distributed under the License is " \ - "distributed on an ""AS IS"" BASIS, WITHOUT " \ - "WARRANTIES OR CONDITIONS OF ANY KIND, either " \ - "express or implied. See the License for the " \ - "specific language governing permissions and " \ - "limitations under the License." - -#define APU_DLL_BASENAME "libaprutil-" APU_STRINGIFY(APU_MAJOR_VERSION) - - -1 VERSIONINFO - FILEVERSION APU_VERSION_STRING_CSV,0 - PRODUCTVERSION APU_VERSION_STRING_CSV,0 - FILEFLAGSMASK 0x3fL -#if defined(APU_IS_DEV_VERSION) -#if defined(_DEBUG) - FILEFLAGS 0x03L -#else - FILEFLAGS 0x02L -#endif -#else -#if defined(_DEBUG) - FILEFLAGS 0x01L -#else - FILEFLAGS 0x00L -#endif -#endif -#if defined(WINNT) || defined(WIN64) - FILEOS 0x40004L -#else - FILEOS 0x4L -#endif - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "Comments", APU_LICENSE "\0" - VALUE "CompanyName", "Apache Software Foundation\0" - VALUE "FileDescription", "Apache Portable Runtime Library\0" - VALUE "FileVersion", APU_VERSION_STRING "\0" - VALUE "InternalName", APU_DLL_BASENAME "\0" - VALUE "LegalCopyright", APU_COPYRIGHT "\0" - VALUE "OriginalFilename", APU_DLL_BASENAME ".dll\0" - VALUE "ProductName", "Apache Portable Runtime Project\0" - VALUE "ProductVersion", APU_VERSION_STRING "\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END diff --git a/libs/apr-util/misc/apr_date.c b/libs/apr-util/misc/apr_date.c deleted file mode 100644 index f584e09314..0000000000 --- a/libs/apr-util/misc/apr_date.c +++ /dev/null @@ -1,616 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * apr_date.c: date parsing utility routines - * These routines are (hopefully) platform independent. - * - * 27 Oct 1996 Roy Fielding - * Extracted (with many modifications) from mod_proxy.c and - * tested with over 50,000 randomly chosen valid date strings - * and several hundred variations of invalid date strings. - * - */ - -#include "apr.h" -#include "apr_lib.h" - -#define APR_WANT_STRFUNC -#include "apr_want.h" - -#if APR_HAVE_STDLIB_H -#include -#endif - -#if APR_HAVE_CTYPE_H -#include -#endif - -#include "apr_date.h" - -/* - * Compare a string to a mask - * Mask characters (arbitrary maximum is 256 characters, just in case): - * @ - uppercase letter - * $ - lowercase letter - * & - hex digit - * # - digit - * ~ - digit or space - * * - swallow remaining characters - * - exact match for any other character - */ -APU_DECLARE(int) apr_date_checkmask(const char *data, const char *mask) -{ - int i; - char d; - - for (i = 0; i < 256; i++) { - d = data[i]; - switch (mask[i]) { - case '\0': - return (d == '\0'); - - case '*': - return 1; - - case '@': - if (!apr_isupper(d)) - return 0; - break; - case '$': - if (!apr_islower(d)) - return 0; - break; - case '#': - if (!apr_isdigit(d)) - return 0; - break; - case '&': - if (!apr_isxdigit(d)) - return 0; - break; - case '~': - if ((d != ' ') && !apr_isdigit(d)) - return 0; - break; - default: - if (mask[i] != d) - return 0; - break; - } - } - return 0; /* We only get here if mask is corrupted (exceeds 256) */ -} - -/* - * Parses an HTTP date in one of three standard forms: - * - * Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123 - * Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036 - * Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format - * - * and returns the apr_time_t number of microseconds since 1 Jan 1970 GMT, - * or APR_DATE_BAD if this would be out of range or if the date is invalid. - * - * The restricted HTTP syntax is - * - * HTTP-date = rfc1123-date | rfc850-date | asctime-date - * - * rfc1123-date = wkday "," SP date1 SP time SP "GMT" - * rfc850-date = weekday "," SP date2 SP time SP "GMT" - * asctime-date = wkday SP date3 SP time SP 4DIGIT - * - * date1 = 2DIGIT SP month SP 4DIGIT - * ; day month year (e.g., 02 Jun 1982) - * date2 = 2DIGIT "-" month "-" 2DIGIT - * ; day-month-year (e.g., 02-Jun-82) - * date3 = month SP ( 2DIGIT | ( SP 1DIGIT )) - * ; month day (e.g., Jun 2) - * - * time = 2DIGIT ":" 2DIGIT ":" 2DIGIT - * ; 00:00:00 - 23:59:59 - * - * wkday = "Mon" | "Tue" | "Wed" - * | "Thu" | "Fri" | "Sat" | "Sun" - * - * weekday = "Monday" | "Tuesday" | "Wednesday" - * | "Thursday" | "Friday" | "Saturday" | "Sunday" - * - * month = "Jan" | "Feb" | "Mar" | "Apr" - * | "May" | "Jun" | "Jul" | "Aug" - * | "Sep" | "Oct" | "Nov" | "Dec" - * - * However, for the sake of robustness (and Netscapeness), we ignore the - * weekday and anything after the time field (including the timezone). - * - * This routine is intended to be very fast; 10x faster than using sscanf. - * - * Originally from Andrew Daviel , 29 Jul 96 - * but many changes since then. - * - */ -APU_DECLARE(apr_time_t) apr_date_parse_http(const char *date) -{ - apr_time_exp_t ds; - apr_time_t result; - int mint, mon; - const char *monstr, *timstr; - static const int months[12] = - { - ('J' << 16) | ('a' << 8) | 'n', ('F' << 16) | ('e' << 8) | 'b', - ('M' << 16) | ('a' << 8) | 'r', ('A' << 16) | ('p' << 8) | 'r', - ('M' << 16) | ('a' << 8) | 'y', ('J' << 16) | ('u' << 8) | 'n', - ('J' << 16) | ('u' << 8) | 'l', ('A' << 16) | ('u' << 8) | 'g', - ('S' << 16) | ('e' << 8) | 'p', ('O' << 16) | ('c' << 8) | 't', - ('N' << 16) | ('o' << 8) | 'v', ('D' << 16) | ('e' << 8) | 'c'}; - - if (!date) - return APR_DATE_BAD; - - while (*date && apr_isspace(*date)) /* Find first non-whitespace char */ - ++date; - - if (*date == '\0') - return APR_DATE_BAD; - - if ((date = strchr(date, ' ')) == NULL) /* Find space after weekday */ - return APR_DATE_BAD; - - ++date; /* Now pointing to first char after space, which should be */ - - /* start of the actual date information for all 4 formats. */ - - if (apr_date_checkmask(date, "## @$$ #### ##:##:## *")) { - /* RFC 1123 format with two days */ - ds.tm_year = ((date[7] - '0') * 10 + (date[8] - '0') - 19) * 100; - if (ds.tm_year < 0) - return APR_DATE_BAD; - - ds.tm_year += ((date[9] - '0') * 10) + (date[10] - '0'); - - ds.tm_mday = ((date[0] - '0') * 10) + (date[1] - '0'); - - monstr = date + 3; - timstr = date + 12; - } - else if (apr_date_checkmask(date, "##-@$$-## ##:##:## *")) { - /* RFC 850 format */ - ds.tm_year = ((date[7] - '0') * 10) + (date[8] - '0'); - if (ds.tm_year < 70) - ds.tm_year += 100; - - ds.tm_mday = ((date[0] - '0') * 10) + (date[1] - '0'); - - monstr = date + 3; - timstr = date + 10; - } - else if (apr_date_checkmask(date, "@$$ ~# ##:##:## ####*")) { - /* asctime format */ - ds.tm_year = ((date[16] - '0') * 10 + (date[17] - '0') - 19) * 100; - if (ds.tm_year < 0) - return APR_DATE_BAD; - - ds.tm_year += ((date[18] - '0') * 10) + (date[19] - '0'); - - if (date[4] == ' ') - ds.tm_mday = 0; - else - ds.tm_mday = (date[4] - '0') * 10; - - ds.tm_mday += (date[5] - '0'); - - monstr = date; - timstr = date + 7; - } - else if (apr_date_checkmask(date, "# @$$ #### ##:##:## *")) { - /* RFC 1123 format with one day */ - ds.tm_year = ((date[6] - '0') * 10 + (date[7] - '0') - 19) * 100; - if (ds.tm_year < 0) - return APR_DATE_BAD; - - ds.tm_year += ((date[8] - '0') * 10) + (date[9] - '0'); - - ds.tm_mday = (date[0] - '0'); - - monstr = date + 2; - timstr = date + 11; - } - else - return APR_DATE_BAD; - - if (ds.tm_mday <= 0 || ds.tm_mday > 31) - return APR_DATE_BAD; - - ds.tm_hour = ((timstr[0] - '0') * 10) + (timstr[1] - '0'); - ds.tm_min = ((timstr[3] - '0') * 10) + (timstr[4] - '0'); - ds.tm_sec = ((timstr[6] - '0') * 10) + (timstr[7] - '0'); - - if ((ds.tm_hour > 23) || (ds.tm_min > 59) || (ds.tm_sec > 61)) - return APR_DATE_BAD; - - mint = (monstr[0] << 16) | (monstr[1] << 8) | monstr[2]; - for (mon = 0; mon < 12; mon++) - if (mint == months[mon]) - break; - - if (mon == 12) - return APR_DATE_BAD; - - if ((ds.tm_mday == 31) && (mon == 3 || mon == 5 || mon == 8 || mon == 10)) - return APR_DATE_BAD; - - /* February gets special check for leapyear */ - if ((mon == 1) && - ((ds.tm_mday > 29) || - ((ds.tm_mday == 29) - && ((ds.tm_year & 3) - || (((ds.tm_year % 100) == 0) - && (((ds.tm_year % 400) != 100))))))) - return APR_DATE_BAD; - - ds.tm_mon = mon; - - /* ap_mplode_time uses tm_usec and tm_gmtoff fields, but they haven't - * been set yet. - * It should be safe to just zero out these values. - * tm_usec is the number of microseconds into the second. HTTP only - * cares about second granularity. - * tm_gmtoff is the number of seconds off of GMT the time is. By - * definition all times going through this function are in GMT, so this - * is zero. - */ - ds.tm_usec = 0; - ds.tm_gmtoff = 0; - if (apr_time_exp_get(&result, &ds) != APR_SUCCESS) - return APR_DATE_BAD; - - return result; -} - -/* - * Parses a string resembling an RFC 822 date. This is meant to be - * leinent in its parsing of dates. Hence, this will parse a wider - * range of dates than apr_date_parse_http. - * - * The prominent mailer (or poster, if mailer is unknown) that has - * been seen in the wild is included for the unknown formats. - * - * Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123 - * Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036 - * Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format - * Sun, 6 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123 - * Sun, 06 Nov 94 08:49:37 GMT ; RFC 822 - * Sun, 6 Nov 94 08:49:37 GMT ; RFC 822 - * Sun, 06 Nov 94 08:49 GMT ; Unknown [drtr@ast.cam.ac.uk] - * Sun, 6 Nov 94 08:49 GMT ; Unknown [drtr@ast.cam.ac.uk] - * Sun, 06 Nov 94 8:49:37 GMT ; Unknown [Elm 70.85] - * Sun, 6 Nov 94 8:49:37 GMT ; Unknown [Elm 70.85] - * Mon, 7 Jan 2002 07:21:22 GMT ; Unknown [Postfix] - * Sun, 06-Nov-1994 08:49:37 GMT ; RFC 850 with four digit years - * - */ - -#define TIMEPARSE(ds,hr10,hr1,min10,min1,sec10,sec1) \ - { \ - ds.tm_hour = ((hr10 - '0') * 10) + (hr1 - '0'); \ - ds.tm_min = ((min10 - '0') * 10) + (min1 - '0'); \ - ds.tm_sec = ((sec10 - '0') * 10) + (sec1 - '0'); \ - } -#define TIMEPARSE_STD(ds,timstr) \ - { \ - TIMEPARSE(ds, timstr[0],timstr[1], \ - timstr[3],timstr[4], \ - timstr[6],timstr[7]); \ - } - -APU_DECLARE(apr_time_t) apr_date_parse_rfc(const char *date) -{ - apr_time_exp_t ds; - apr_time_t result; - int mint, mon; - const char *monstr, *timstr, *gmtstr; - static const int months[12] = - { - ('J' << 16) | ('a' << 8) | 'n', ('F' << 16) | ('e' << 8) | 'b', - ('M' << 16) | ('a' << 8) | 'r', ('A' << 16) | ('p' << 8) | 'r', - ('M' << 16) | ('a' << 8) | 'y', ('J' << 16) | ('u' << 8) | 'n', - ('J' << 16) | ('u' << 8) | 'l', ('A' << 16) | ('u' << 8) | 'g', - ('S' << 16) | ('e' << 8) | 'p', ('O' << 16) | ('c' << 8) | 't', - ('N' << 16) | ('o' << 8) | 'v', ('D' << 16) | ('e' << 8) | 'c' }; - - if (!date) - return APR_DATE_BAD; - - /* Not all dates have text months at the beginning. */ - if (!apr_isdigit(date[0])) - { - while (*date && apr_isspace(*date)) /* Find first non-whitespace char */ - ++date; - - if (*date == '\0') - return APR_DATE_BAD; - - if ((date = strchr(date, ' ')) == NULL) /* Find space after weekday */ - return APR_DATE_BAD; - - ++date; /* Now pointing to first char after space, which should be */ } - - /* start of the actual date information for all 11 formats. */ - if (apr_date_checkmask(date, "## @$$ #### ##:##:## *")) { /* RFC 1123 format */ - ds.tm_year = ((date[7] - '0') * 10 + (date[8] - '0') - 19) * 100; - - if (ds.tm_year < 0) - return APR_DATE_BAD; - - ds.tm_year += ((date[9] - '0') * 10) + (date[10] - '0'); - - ds.tm_mday = ((date[0] - '0') * 10) + (date[1] - '0'); - - monstr = date + 3; - timstr = date + 12; - gmtstr = date + 20; - - TIMEPARSE_STD(ds, timstr); - } - else if (apr_date_checkmask(date, "##-@$$-## ##:##:## *")) {/* RFC 850 format */ - ds.tm_year = ((date[7] - '0') * 10) + (date[8] - '0'); - - if (ds.tm_year < 70) - ds.tm_year += 100; - - ds.tm_mday = ((date[0] - '0') * 10) + (date[1] - '0'); - - monstr = date + 3; - timstr = date + 10; - gmtstr = date + 19; - - TIMEPARSE_STD(ds, timstr); - } - else if (apr_date_checkmask(date, "@$$ ~# ##:##:## ####*")) { - /* asctime format */ - ds.tm_year = ((date[16] - '0') * 10 + (date[17] - '0') - 19) * 100; - if (ds.tm_year < 0) - return APR_DATE_BAD; - - ds.tm_year += ((date[18] - '0') * 10) + (date[19] - '0'); - - if (date[4] == ' ') - ds.tm_mday = 0; - else - ds.tm_mday = (date[4] - '0') * 10; - - ds.tm_mday += (date[5] - '0'); - - monstr = date; - timstr = date + 7; - gmtstr = NULL; - - TIMEPARSE_STD(ds, timstr); - } - else if (apr_date_checkmask(date, "# @$$ #### ##:##:## *")) { - /* RFC 1123 format*/ - ds.tm_year = ((date[6] - '0') * 10 + (date[7] - '0') - 19) * 100; - - if (ds.tm_year < 0) - return APR_DATE_BAD; - - ds.tm_year += ((date[8] - '0') * 10) + (date[9] - '0'); - ds.tm_mday = (date[0] - '0'); - - monstr = date + 2; - timstr = date + 11; - gmtstr = date + 20; - - TIMEPARSE_STD(ds, timstr); - } - else if (apr_date_checkmask(date, "## @$$ ## ##:##:## *")) { - /* This is the old RFC 1123 date format - many many years ago, people - * used two-digit years. Oh, how foolish. */ - ds.tm_year = ((date[7] - '0') * 10) + (date[8] - '0'); - - if (ds.tm_year < 70) - ds.tm_year += 100; - - ds.tm_mday = ((date[0] - '0') * 10) + (date[1] - '0'); - - monstr = date + 3; - timstr = date + 10; - gmtstr = date + 19; - - TIMEPARSE_STD(ds, timstr); - } - else if (apr_date_checkmask(date, "# @$$ ## ##:##:## *")) { - /* This is the old RFC 1123 date format - many many years ago, people - * used two-digit years. Oh, how foolish. */ - ds.tm_year = ((date[6] - '0') * 10) + (date[7] - '0'); - - if (ds.tm_year < 70) - ds.tm_year += 100; - - ds.tm_mday = (date[0] - '0'); - - monstr = date + 2; - timstr = date + 9; - gmtstr = date + 18; - - TIMEPARSE_STD(ds, timstr); - } - else if (apr_date_checkmask(date, "## @$$ ## ##:## *")) { - /* Loser format. This is quite bogus. */ - ds.tm_year = ((date[7] - '0') * 10) + (date[8] - '0'); - - if (ds.tm_year < 70) - ds.tm_year += 100; - - ds.tm_mday = ((date[0] - '0') * 10) + (date[1] - '0'); - - monstr = date + 3; - timstr = date + 10; - gmtstr = NULL; - - TIMEPARSE(ds, timstr[0],timstr[1], timstr[3],timstr[4], '0','0'); - } - else if (apr_date_checkmask(date, "# @$$ ## ##:## *")) { - /* Loser format. This is quite bogus. */ - ds.tm_year = ((date[6] - '0') * 10) + (date[7] - '0'); - - if (ds.tm_year < 70) - ds.tm_year += 100; - - ds.tm_mday = (date[0] - '0'); - - monstr = date + 2; - timstr = date + 9; - gmtstr = NULL; - - TIMEPARSE(ds, timstr[0],timstr[1], timstr[3],timstr[4], '0','0'); - } - else if (apr_date_checkmask(date, "## @$$ ## #:##:## *")) { - /* Loser format. This is quite bogus. */ - ds.tm_year = ((date[7] - '0') * 10) + (date[8] - '0'); - - if (ds.tm_year < 70) - ds.tm_year += 100; - - ds.tm_mday = ((date[0] - '0') * 10) + (date[1] - '0'); - - monstr = date + 3; - timstr = date + 9; - gmtstr = date + 18; - - TIMEPARSE(ds, '0',timstr[1], timstr[3],timstr[4], timstr[6],timstr[7]); - } - else if (apr_date_checkmask(date, "# @$$ ## #:##:## *")) { - /* Loser format. This is quite bogus. */ - ds.tm_year = ((date[6] - '0') * 10) + (date[7] - '0'); - - if (ds.tm_year < 70) - ds.tm_year += 100; - - ds.tm_mday = (date[0] - '0'); - - monstr = date + 2; - timstr = date + 8; - gmtstr = date + 17; - - TIMEPARSE(ds, '0',timstr[1], timstr[3],timstr[4], timstr[6],timstr[7]); - } - else if (apr_date_checkmask(date, " # @$$ #### ##:##:## *")) { - /* RFC 1123 format with a space instead of a leading zero. */ - ds.tm_year = ((date[7] - '0') * 10 + (date[8] - '0') - 19) * 100; - - if (ds.tm_year < 0) - return APR_DATE_BAD; - - ds.tm_year += ((date[9] - '0') * 10) + (date[10] - '0'); - - ds.tm_mday = (date[1] - '0'); - - monstr = date + 3; - timstr = date + 12; - gmtstr = date + 20; - - TIMEPARSE_STD(ds, timstr); - } - else if (apr_date_checkmask(date, "##-@$$-#### ##:##:## *")) { - /* RFC 1123 with dashes instead of spaces between date/month/year - * This also looks like RFC 850 with four digit years. - */ - ds.tm_year = ((date[7] - '0') * 10 + (date[8] - '0') - 19) * 100; - if (ds.tm_year < 0) - return APR_DATE_BAD; - - ds.tm_year += ((date[9] - '0') * 10) + (date[10] - '0'); - - ds.tm_mday = ((date[0] - '0') * 10) + (date[1] - '0'); - - monstr = date + 3; - timstr = date + 12; - gmtstr = date + 21; - - TIMEPARSE_STD(ds, timstr); - } - else - return APR_DATE_BAD; - - if (ds.tm_mday <= 0 || ds.tm_mday > 31) - return APR_DATE_BAD; - - if ((ds.tm_hour > 23) || (ds.tm_min > 59) || (ds.tm_sec > 61)) - return APR_DATE_BAD; - - mint = (monstr[0] << 16) | (monstr[1] << 8) | monstr[2]; - for (mon = 0; mon < 12; mon++) - if (mint == months[mon]) - break; - - if (mon == 12) - return APR_DATE_BAD; - - if ((ds.tm_mday == 31) && (mon == 3 || mon == 5 || mon == 8 || mon == 10)) - return APR_DATE_BAD; - - /* February gets special check for leapyear */ - - if ((mon == 1) && - ((ds.tm_mday > 29) - || ((ds.tm_mday == 29) - && ((ds.tm_year & 3) - || (((ds.tm_year % 100) == 0) - && (((ds.tm_year % 400) != 100))))))) - return APR_DATE_BAD; - - ds.tm_mon = mon; - - /* tm_gmtoff is the number of seconds off of GMT the time is. - * - * We only currently support: [+-]ZZZZ where Z is the offset in - * hours from GMT. - * - * If there is any confusion, tm_gmtoff will remain 0. - */ - ds.tm_gmtoff = 0; - if (gmtstr && *gmtstr != '\0') { - /* Do we have a GMT? */ - if (*(++gmtstr) != '\0') { - int offset; - switch (*(gmtstr++)) { - case '-': - offset = atoi(gmtstr); - ds.tm_gmtoff -= (offset / 100) * 60 * 60; - ds.tm_gmtoff -= (offset % 100) * 60; - break; - case '+': - offset = atoi(gmtstr); - ds.tm_gmtoff += (offset / 100) * 60 * 60; - ds.tm_gmtoff += (offset % 100) * 60; - break; - } - } - } - - /* apr_time_exp_get uses tm_usec field, but it hasn't been set yet. - * It should be safe to just zero out this value. - * tm_usec is the number of microseconds into the second. HTTP only - * cares about second granularity. - */ - ds.tm_usec = 0; - - if (apr_time_exp_gmt_get(&result, &ds) != APR_SUCCESS) - return APR_DATE_BAD; - - return result; -} diff --git a/libs/apr-util/misc/apr_reslist.c b/libs/apr-util/misc/apr_reslist.c deleted file mode 100644 index c8ed5062dc..0000000000 --- a/libs/apr-util/misc/apr_reslist.c +++ /dev/null @@ -1,376 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "apu.h" -#include "apr_reslist.h" -#include "apr_errno.h" -#include "apr_strings.h" -#include "apr_thread_mutex.h" -#include "apr_thread_cond.h" -#include "apr_ring.h" - -#if APR_HAS_THREADS - -/** - * A single resource element. - */ -struct apr_res_t { - apr_time_t freed; - void *opaque; - APR_RING_ENTRY(apr_res_t) link; -}; -typedef struct apr_res_t apr_res_t; - -/** - * A ring of resources representing the list of available resources. - */ -APR_RING_HEAD(apr_resring_t, apr_res_t); -typedef struct apr_resring_t apr_resring_t; - -struct apr_reslist_t { - apr_pool_t *pool; /* the pool used in constructor and destructor calls */ - int ntotal; /* total number of resources managed by this list */ - int nidle; /* number of available resources */ - int min; /* desired minimum number of available resources */ - int smax; /* soft maximum on the total number of resources */ - int hmax; /* hard maximum on the total number of resources */ - apr_interval_time_t ttl; /* TTL when we have too many resources */ - apr_interval_time_t timeout; /* Timeout for waiting on resource */ - apr_reslist_constructor constructor; - apr_reslist_destructor destructor; - void *params; /* opaque data passed to constructor and destructor calls */ - apr_resring_t avail_list; - apr_resring_t free_list; - apr_thread_mutex_t *listlock; - apr_thread_cond_t *avail; -}; - -/** - * Grab a resource from the front of the resource list. - * Assumes: that the reslist is locked. - */ -static apr_res_t *pop_resource(apr_reslist_t *reslist) -{ - apr_res_t *res; - res = APR_RING_FIRST(&reslist->avail_list); - APR_RING_REMOVE(res, link); - reslist->nidle--; - return res; -} - -/** - * Add a resource to the end of the list, set the time at which - * it was added to the list. - * Assumes: that the reslist is locked. - */ -static void push_resource(apr_reslist_t *reslist, apr_res_t *resource) -{ - APR_RING_INSERT_TAIL(&reslist->avail_list, resource, apr_res_t, link); - resource->freed = apr_time_now(); - reslist->nidle++; -} - -/** - * Get an resource container from the free list or create a new one. - */ -static apr_res_t *get_container(apr_reslist_t *reslist) -{ - apr_res_t *res; - - if (!APR_RING_EMPTY(&reslist->free_list, apr_res_t, link)) { - res = APR_RING_FIRST(&reslist->free_list); - APR_RING_REMOVE(res, link); - } - else - res = apr_pcalloc(reslist->pool, sizeof(*res)); - return res; -} - -/** - * Free up a resource container by placing it on the free list. - */ -static void free_container(apr_reslist_t *reslist, apr_res_t *container) -{ - APR_RING_INSERT_TAIL(&reslist->free_list, container, apr_res_t, link); -} - -/** - * Create a new resource and return it. - * Assumes: that the reslist is locked. - */ -static apr_status_t create_resource(apr_reslist_t *reslist, apr_res_t **ret_res) -{ - apr_status_t rv; - apr_res_t *res; - - res = get_container(reslist); - - rv = reslist->constructor(&res->opaque, reslist->params, reslist->pool); - - *ret_res = res; - return rv; -} - -/** - * Destroy a single idle resource. - * Assumes: that the reslist is locked. - */ -static apr_status_t destroy_resource(apr_reslist_t *reslist, apr_res_t *res) -{ - return reslist->destructor(res->opaque, reslist->params, reslist->pool); -} - -static apr_status_t reslist_cleanup(void *data_) -{ - apr_status_t rv; - apr_reslist_t *rl = data_; - apr_res_t *res; - - apr_thread_mutex_lock(rl->listlock); - - while (rl->nidle > 0) { - res = pop_resource(rl); - rl->ntotal--; - rv = destroy_resource(rl, res); - if (rv != APR_SUCCESS) { - return rv; - } - free_container(rl, res); - } - - assert(rl->nidle == 0); - assert(rl->ntotal == 0); - - apr_thread_mutex_destroy(rl->listlock); - apr_thread_cond_destroy(rl->avail); - - return APR_SUCCESS; -} - -/** - * Perform routine maintenance on the resource list. This call - * may instantiate new resources or expire old resources. - */ -static apr_status_t reslist_maint(apr_reslist_t *reslist) -{ - apr_time_t now; - apr_status_t rv; - apr_res_t *res; - int created_one = 0; - - apr_thread_mutex_lock(reslist->listlock); - - /* Check if we need to create more resources, and if we are allowed to. */ - while (reslist->nidle < reslist->min && reslist->ntotal <= reslist->hmax) { - /* Create the resource */ - rv = create_resource(reslist, &res); - if (rv != APR_SUCCESS) { - free_container(reslist, res); - apr_thread_mutex_unlock(reslist->listlock); - return rv; - } - /* Add it to the list */ - push_resource(reslist, res); - /* Update our counters */ - reslist->ntotal++; - /* If someone is waiting on that guy, wake them up. */ - rv = apr_thread_cond_signal(reslist->avail); - if (rv != APR_SUCCESS) { - apr_thread_mutex_unlock(reslist->listlock); - return rv; - } - created_one++; - } - - /* We don't need to see if we're over the max if we were under it before */ - if (created_one) { - apr_thread_mutex_unlock(reslist->listlock); - return APR_SUCCESS; - } - - /* Check if we need to expire old resources */ - now = apr_time_now(); - while (reslist->nidle > reslist->smax && reslist->nidle > 0) { - /* Peak at the first resource in the list */ - res = APR_RING_FIRST(&reslist->avail_list); - /* See if the oldest entry should be expired */ - if (now - res->freed < reslist->ttl) { - /* If this entry is too young, none of the others - * will be ready to be expired either, so we are done. */ - break; - } - res = pop_resource(reslist); - reslist->ntotal--; - rv = destroy_resource(reslist, res); - free_container(reslist, res); - if (rv != APR_SUCCESS) { - apr_thread_mutex_unlock(reslist->listlock); - return rv; - } - } - - apr_thread_mutex_unlock(reslist->listlock); - return APR_SUCCESS; -} - -APU_DECLARE(apr_status_t) apr_reslist_create(apr_reslist_t **reslist, - int min, int smax, int hmax, - apr_interval_time_t ttl, - apr_reslist_constructor con, - apr_reslist_destructor de, - void *params, - apr_pool_t *pool) -{ - apr_status_t rv; - apr_reslist_t *rl; - - /* Do some sanity checks so we don't thrash around in the - * maintenance routine later. */ - if (min > smax || min > hmax || smax > hmax || ttl < 0) { - return APR_EINVAL; - } - - rl = apr_pcalloc(pool, sizeof(*rl)); - rl->pool = pool; - rl->min = min; - rl->smax = smax; - rl->hmax = hmax; - rl->ttl = ttl; - rl->constructor = con; - rl->destructor = de; - rl->params = params; - - APR_RING_INIT(&rl->avail_list, apr_res_t, link); - APR_RING_INIT(&rl->free_list, apr_res_t, link); - - rv = apr_thread_mutex_create(&rl->listlock, APR_THREAD_MUTEX_DEFAULT, - pool); - if (rv != APR_SUCCESS) { - return rv; - } - rv = apr_thread_cond_create(&rl->avail, pool); - if (rv != APR_SUCCESS) { - return rv; - } - - rv = reslist_maint(rl); - if (rv != APR_SUCCESS) { - return rv; - } - - apr_pool_cleanup_register(rl->pool, rl, reslist_cleanup, - apr_pool_cleanup_null); - - *reslist = rl; - - return APR_SUCCESS; -} - -APU_DECLARE(apr_status_t) apr_reslist_destroy(apr_reslist_t *reslist) -{ - return apr_pool_cleanup_run(reslist->pool, reslist, reslist_cleanup); -} - -APU_DECLARE(apr_status_t) apr_reslist_acquire(apr_reslist_t *reslist, - void **resource) -{ - apr_status_t rv; - apr_res_t *res; - - apr_thread_mutex_lock(reslist->listlock); - /* If there are idle resources on the available list, use - * them right away. */ - if (reslist->nidle > 0) { - /* Pop off the first resource */ - res = pop_resource(reslist); - *resource = res->opaque; - free_container(reslist, res); - apr_thread_mutex_unlock(reslist->listlock); - return APR_SUCCESS; - } - /* If we've hit our max, block until we're allowed to create - * a new one, or something becomes free. */ - else while (reslist->ntotal >= reslist->hmax - && reslist->nidle <= 0) { - if (reslist->timeout) { - if ((rv = apr_thread_cond_timedwait(reslist->avail, - reslist->listlock, reslist->timeout)) != APR_SUCCESS) { - apr_thread_mutex_unlock(reslist->listlock); - return rv; - } - } - else - apr_thread_cond_wait(reslist->avail, reslist->listlock); - } - /* If we popped out of the loop, first try to see if there - * are new resources available for immediate use. */ - if (reslist->nidle > 0) { - res = pop_resource(reslist); - *resource = res->opaque; - free_container(reslist, res); - apr_thread_mutex_unlock(reslist->listlock); - return APR_SUCCESS; - } - /* Otherwise the reason we dropped out of the loop - * was because there is a new slot available, so create - * a resource to fill the slot and use it. */ - else { - rv = create_resource(reslist, &res); - if (rv == APR_SUCCESS) { - reslist->ntotal++; - *resource = res->opaque; - } - free_container(reslist, res); - apr_thread_mutex_unlock(reslist->listlock); - return rv; - } -} - -APU_DECLARE(apr_status_t) apr_reslist_release(apr_reslist_t *reslist, - void *resource) -{ - apr_res_t *res; - - apr_thread_mutex_lock(reslist->listlock); - res = get_container(reslist); - res->opaque = resource; - push_resource(reslist, res); - apr_thread_cond_signal(reslist->avail); - apr_thread_mutex_unlock(reslist->listlock); - - return reslist_maint(reslist); -} - -APU_DECLARE(void) apr_reslist_timeout_set(apr_reslist_t *reslist, - apr_interval_time_t timeout) -{ - reslist->timeout = timeout; -} - -APU_DECLARE(apr_status_t) apr_reslist_invalidate(apr_reslist_t *reslist, - void *resource) -{ - apr_status_t ret; - apr_thread_mutex_lock(reslist->listlock); - ret = reslist->destructor(resource, reslist->params, reslist->pool); - reslist->ntotal--; - apr_thread_mutex_unlock(reslist->listlock); - return ret; -} - -#endif /* APR_HAS_THREADS */ diff --git a/libs/apr-util/misc/apr_rmm.c b/libs/apr-util/misc/apr_rmm.c deleted file mode 100644 index 87d0513213..0000000000 --- a/libs/apr-util/misc/apr_rmm.c +++ /dev/null @@ -1,446 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_general.h" -#include "apr_rmm.h" -#include "apr_errno.h" -#include "apr_lib.h" -#include "apr_strings.h" - -/* The RMM region is made up of two doubly-linked-list of blocks; the - * list of used blocks, and the list of free blocks (either list may - * be empty). The base pointer, rmm->base, points at the beginning of - * the shmem region in use. Each block is addressable by an - * apr_rmm_off_t value, which represents the offset from the base - * pointer. The term "address" is used here to mean such a value; an - * "offset from rmm->base". - * - * The RMM region contains exactly one "rmm_hdr_block_t" structure, - * the "header block", which is always stored at the base pointer. - * The firstused field in this structure is the address of the first - * block in the "used blocks" list; the firstfree field is the address - * of the first block in the "free blocks" list. - * - * Each block is prefixed by an "rmm_block_t" structure, followed by - * the caller-usable region represented by the block. The next and - * prev fields of the structure are zero if the block is at the end or - * beginning of the linked-list respectively, or otherwise hold the - * address of the next and previous blocks in the list. ("address 0", - * i.e. rmm->base is *not* a valid address for a block, since the - * header block is always stored at that address). - * - * At creation, the RMM region is initialized to hold a single block - * on the free list representing the entire available shm segment - * (minus header block); subsequent allocation and deallocation of - * blocks involves splitting blocks and coalescing adjacent blocks, - * and switching them between the free and used lists as - * appropriate. */ - -typedef struct rmm_block_t { - apr_size_t size; - apr_rmm_off_t prev; - apr_rmm_off_t next; -} rmm_block_t; - -/* Always at our apr_rmm_off(0): - */ -typedef struct rmm_hdr_block_t { - apr_size_t abssize; - apr_rmm_off_t /* rmm_block_t */ firstused; - apr_rmm_off_t /* rmm_block_t */ firstfree; -} rmm_hdr_block_t; - -#define RMM_HDR_BLOCK_SIZE (APR_ALIGN_DEFAULT(sizeof(rmm_hdr_block_t))) -#define RMM_BLOCK_SIZE (APR_ALIGN_DEFAULT(sizeof(rmm_block_t))) - -struct apr_rmm_t { - apr_pool_t *p; - rmm_hdr_block_t *base; - apr_size_t size; - apr_anylock_t lock; -}; - -static apr_rmm_off_t find_block_by_offset(apr_rmm_t *rmm, apr_rmm_off_t next, - apr_rmm_off_t find, int includes) -{ - apr_rmm_off_t prev = 0; - - while (next) { - struct rmm_block_t *blk = (rmm_block_t*)((char*)rmm->base + next); - - if (find == next) - return next; - - /* Overshot? */ - if (find < next) - return includes ? prev : 0; - - prev = next; - next = blk->next; - } - return includes ? prev : 0; -} - -static apr_rmm_off_t find_block_of_size(apr_rmm_t *rmm, apr_size_t size) -{ - apr_rmm_off_t next = rmm->base->firstfree; - apr_rmm_off_t best = 0; - apr_rmm_off_t bestsize = 0; - - while (next) { - struct rmm_block_t *blk = (rmm_block_t*)((char*)rmm->base + next); - - if (blk->size == size) - return next; - - if (blk->size >= size) { - /* XXX: sub optimal algorithm - * We need the most thorough best-fit logic, since we can - * never grow our rmm, we are SOL when we hit the wall. - */ - if (!bestsize || (blk->size < bestsize)) { - bestsize = blk->size; - best = next; - } - } - - next = blk->next; - } - - if (bestsize > RMM_BLOCK_SIZE + size) { - struct rmm_block_t *blk = (rmm_block_t*)((char*)rmm->base + best); - struct rmm_block_t *new = (rmm_block_t*)((char*)rmm->base + best + size); - - new->size = blk->size - size; - new->next = blk->next; - new->prev = best; - - blk->size = size; - blk->next = best + size; - - if (new->next) { - blk = (rmm_block_t*)((char*)rmm->base + new->next); - blk->prev = best + size; - } - } - - return best; -} - -static void move_block(apr_rmm_t *rmm, apr_rmm_off_t this, int free) -{ - struct rmm_block_t *blk = (rmm_block_t*)((char*)rmm->base + this); - - /* close the gap */ - if (blk->prev) { - struct rmm_block_t *prev = (rmm_block_t*)((char*)rmm->base + blk->prev); - prev->next = blk->next; - } - else { - if (free) { - rmm->base->firstused = blk->next; - } - else { - rmm->base->firstfree = blk->next; - } - } - if (blk->next) { - struct rmm_block_t *next = (rmm_block_t*)((char*)rmm->base + blk->next); - next->prev = blk->prev; - } - - /* now find it in the other list, pushing it to the head if required */ - if (free) { - blk->prev = find_block_by_offset(rmm, rmm->base->firstfree, this, 1); - if (!blk->prev) { - blk->next = rmm->base->firstfree; - rmm->base->firstfree = this; - } - } - else { - blk->prev = find_block_by_offset(rmm, rmm->base->firstused, this, 1); - if (!blk->prev) { - blk->next = rmm->base->firstused; - rmm->base->firstused = this; - } - } - - /* and open it up */ - if (blk->prev) { - struct rmm_block_t *prev = (rmm_block_t*)((char*)rmm->base + blk->prev); - if (free && (blk->prev + prev->size == this)) { - /* Collapse us into our predecessor */ - prev->size += blk->size; - this = blk->prev; - blk = prev; - } - else { - blk->next = prev->next; - prev->next = this; - } - } - - if (blk->next) { - struct rmm_block_t *next = (rmm_block_t*)((char*)rmm->base + blk->next); - if (free && (this + blk->size == blk->next)) { - /* Collapse us into our successor */ - blk->size += next->size; - blk->next = next->next; - if (blk->next) { - next = (rmm_block_t*)((char*)rmm->base + blk->next); - next->prev = this; - } - } - else { - next->prev = this; - } - } -} - -APU_DECLARE(apr_status_t) apr_rmm_init(apr_rmm_t **rmm, apr_anylock_t *lock, - void *base, apr_size_t size, - apr_pool_t *p) -{ - apr_status_t rv; - rmm_block_t *blk; - apr_anylock_t nulllock; - - if (!lock) { - nulllock.type = apr_anylock_none; - nulllock.lock.pm = NULL; - lock = &nulllock; - } - if ((rv = APR_ANYLOCK_LOCK(lock)) != APR_SUCCESS) - return rv; - - (*rmm) = (apr_rmm_t *)apr_pcalloc(p, sizeof(apr_rmm_t)); - (*rmm)->p = p; - (*rmm)->base = base; - (*rmm)->size = size; - (*rmm)->lock = *lock; - - (*rmm)->base->abssize = size; - (*rmm)->base->firstused = 0; - (*rmm)->base->firstfree = RMM_HDR_BLOCK_SIZE; - - blk = (rmm_block_t *)((char*)base + (*rmm)->base->firstfree); - - blk->size = size - (*rmm)->base->firstfree; - blk->prev = 0; - blk->next = 0; - - return APR_ANYLOCK_UNLOCK(lock); -} - -APU_DECLARE(apr_status_t) apr_rmm_destroy(apr_rmm_t *rmm) -{ - apr_status_t rv; - rmm_block_t *blk; - - if ((rv = APR_ANYLOCK_LOCK(&rmm->lock)) != APR_SUCCESS) { - return rv; - } - /* Blast it all --- no going back :) */ - if (rmm->base->firstused) { - apr_rmm_off_t this = rmm->base->firstused; - do { - blk = (rmm_block_t *)((char*)rmm->base + this); - this = blk->next; - blk->next = blk->prev = 0; - } while (this); - rmm->base->firstused = 0; - } - if (rmm->base->firstfree) { - apr_rmm_off_t this = rmm->base->firstfree; - do { - blk = (rmm_block_t *)((char*)rmm->base + this); - this = blk->next; - blk->next = blk->prev = 0; - } while (this); - rmm->base->firstfree = 0; - } - rmm->base->abssize = 0; - rmm->size = 0; - - return APR_ANYLOCK_UNLOCK(&rmm->lock); -} - -APU_DECLARE(apr_status_t) apr_rmm_attach(apr_rmm_t **rmm, apr_anylock_t *lock, - void *base, apr_pool_t *p) -{ - apr_anylock_t nulllock; - - if (!lock) { - nulllock.type = apr_anylock_none; - nulllock.lock.pm = NULL; - lock = &nulllock; - } - - /* sanity would be good here */ - (*rmm) = (apr_rmm_t *)apr_pcalloc(p, sizeof(apr_rmm_t)); - (*rmm)->p = p; - (*rmm)->base = base; - (*rmm)->size = (*rmm)->base->abssize; - (*rmm)->lock = *lock; - return APR_SUCCESS; -} - -APU_DECLARE(apr_status_t) apr_rmm_detach(apr_rmm_t *rmm) -{ - /* A noop until we introduce locked/refcounts */ - return APR_SUCCESS; -} - -APU_DECLARE(apr_rmm_off_t) apr_rmm_malloc(apr_rmm_t *rmm, apr_size_t reqsize) -{ - apr_rmm_off_t this; - - reqsize = APR_ALIGN_DEFAULT(reqsize) + RMM_BLOCK_SIZE; - - APR_ANYLOCK_LOCK(&rmm->lock); - - this = find_block_of_size(rmm, reqsize); - - if (this) { - move_block(rmm, this, 0); - this += RMM_BLOCK_SIZE; - } - - APR_ANYLOCK_UNLOCK(&rmm->lock); - return this; -} - -APU_DECLARE(apr_rmm_off_t) apr_rmm_calloc(apr_rmm_t *rmm, apr_size_t reqsize) -{ - apr_rmm_off_t this; - - reqsize = APR_ALIGN_DEFAULT(reqsize) + RMM_BLOCK_SIZE; - - APR_ANYLOCK_LOCK(&rmm->lock); - - this = find_block_of_size(rmm, reqsize); - - if (this) { - move_block(rmm, this, 0); - this += RMM_BLOCK_SIZE; - memset((char*)rmm->base + this, 0, reqsize - RMM_BLOCK_SIZE); - } - - APR_ANYLOCK_UNLOCK(&rmm->lock); - return this; -} - -APU_DECLARE(apr_rmm_off_t) apr_rmm_realloc(apr_rmm_t *rmm, void *entity, - apr_size_t reqsize) -{ - apr_rmm_off_t this; - apr_rmm_off_t old; - struct rmm_block_t *blk; - apr_size_t oldsize; - - if (!entity) { - return apr_rmm_malloc(rmm, reqsize); - } - - reqsize = APR_ALIGN_DEFAULT(reqsize); - old = apr_rmm_offset_get(rmm, entity); - - if ((this = apr_rmm_malloc(rmm, reqsize)) == 0) { - return 0; - } - - blk = (rmm_block_t*)((char*)rmm->base + old - RMM_BLOCK_SIZE); - oldsize = blk->size; - - memcpy(apr_rmm_addr_get(rmm, this), - apr_rmm_addr_get(rmm, old), oldsize < reqsize ? oldsize : reqsize); - apr_rmm_free(rmm, old); - - return this; -} - -APU_DECLARE(apr_status_t) apr_rmm_free(apr_rmm_t *rmm, apr_rmm_off_t this) -{ - apr_status_t rv; - struct rmm_block_t *blk; - - /* A little sanity check is always healthy, especially here. - * If we really cared, we could make this compile-time - */ - if (this < RMM_HDR_BLOCK_SIZE + RMM_BLOCK_SIZE) { - return APR_EINVAL; - } - - this -= RMM_BLOCK_SIZE; - - blk = (rmm_block_t*)((char*)rmm->base + this); - - if ((rv = APR_ANYLOCK_LOCK(&rmm->lock)) != APR_SUCCESS) { - return rv; - } - if (blk->prev) { - struct rmm_block_t *prev = (rmm_block_t*)((char*)rmm->base + blk->prev); - if (prev->next != this) { - APR_ANYLOCK_UNLOCK(&rmm->lock); - return APR_EINVAL; - } - } - else { - if (rmm->base->firstused != this) { - APR_ANYLOCK_UNLOCK(&rmm->lock); - return APR_EINVAL; - } - } - - if (blk->next) { - struct rmm_block_t *next = (rmm_block_t*)((char*)rmm->base + blk->next); - if (next->prev != this) { - APR_ANYLOCK_UNLOCK(&rmm->lock); - return APR_EINVAL; - } - } - - /* Ok, it remained [apparently] sane, so unlink it - */ - move_block(rmm, this, 1); - - return APR_ANYLOCK_UNLOCK(&rmm->lock); -} - -APU_DECLARE(void *) apr_rmm_addr_get(apr_rmm_t *rmm, apr_rmm_off_t entity) -{ - /* debug-sanity checking here would be good - */ - return (void*)((char*)rmm->base + entity); -} - -APU_DECLARE(apr_rmm_off_t) apr_rmm_offset_get(apr_rmm_t *rmm, void* entity) -{ - /* debug, or always, sanity checking here would be good - * since the primitive is apr_rmm_off_t, I don't mind penalizing - * inverse conversions for safety, unless someone can prove that - * there is no choice in some cases. - */ - return ((char*)entity - (char*)rmm->base); -} - -APU_DECLARE(apr_size_t) apr_rmm_overhead_get(int n) -{ - /* overhead per block is at most APR_ALIGN_DEFAULT(1) wasted bytes - * for alignment overhead, plus the size of the rmm_block_t - * structure. */ - return RMM_HDR_BLOCK_SIZE + n * (RMM_BLOCK_SIZE + APR_ALIGN_DEFAULT(1)); -} diff --git a/libs/apr-util/misc/apu_version.c b/libs/apr-util/misc/apu_version.c deleted file mode 100644 index dab34b71ad..0000000000 --- a/libs/apr-util/misc/apu_version.c +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_general.h" /* for APR_STRINGIFY */ - -#include "apu.h" -#include "apu_version.h" - -APU_DECLARE(void) apu_version(apr_version_t *pvsn) -{ - pvsn->major = APU_MAJOR_VERSION; - pvsn->minor = APU_MINOR_VERSION; - pvsn->patch = APU_PATCH_VERSION; -#ifdef APU_IS_DEV_VERSION - pvsn->is_dev = 1; -#else - pvsn->is_dev = 0; -#endif -} - -APU_DECLARE(const char *) apu_version_string(void) -{ - return APU_VERSION_STRING; -} diff --git a/libs/apr-util/renames_pending b/libs/apr-util/renames_pending deleted file mode 100644 index 0ebcfe2eb3..0000000000 --- a/libs/apr-util/renames_pending +++ /dev/null @@ -1,2 +0,0 @@ -Symbol renames pending for apr-util (keep ordered and complete, please!) - diff --git a/libs/apr-util/strmatch/apr_strmatch.c b/libs/apr-util/strmatch/apr_strmatch.c deleted file mode 100644 index 86f874f358..0000000000 --- a/libs/apr-util/strmatch/apr_strmatch.c +++ /dev/null @@ -1,118 +0,0 @@ -/* Copyright 2002-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_strmatch.h" -#include "apr_lib.h" -#define APR_WANT_STRFUNC -#include "apr_want.h" - - -#define NUM_CHARS 256 - -/* - * String searching functions - */ -static const char *match_no_op(const apr_strmatch_pattern *this_pattern, - const char *s, apr_size_t slen) -{ - return s; -} - -static const char *match_boyer_moore_horspool( - const apr_strmatch_pattern *this_pattern, - const char *s, apr_size_t slen) -{ - const char *s_end = s + slen; - int *shift = (int *)(this_pattern->context); - const char *s_next = s + this_pattern->length - 1; - const char *p_start = this_pattern->pattern; - const char *p_end = p_start + this_pattern->length - 1; - while (s_next < s_end) { - const char *s_tmp = s_next; - const char *p_tmp = p_end; - while (*s_tmp == *p_tmp) { - p_tmp--; - if (p_tmp < p_start) { - return s_tmp; - } - s_tmp--; - } - s_next += shift[(int)*((const unsigned char *)s_next)]; - } - return NULL; -} - -static const char *match_boyer_moore_horspool_nocase( - const apr_strmatch_pattern *this_pattern, - const char *s, apr_size_t slen) -{ - const char *s_end = s + slen; - int *shift = (int *)(this_pattern->context); - const char *s_next = s + this_pattern->length - 1; - const char *p_start = this_pattern->pattern; - const char *p_end = p_start + this_pattern->length - 1; - while (s_next < s_end) { - const char *s_tmp = s_next; - const char *p_tmp = p_end; - while (apr_tolower(*s_tmp) == apr_tolower(*p_tmp)) { - p_tmp--; - if (p_tmp < p_start) { - return s_tmp; - } - s_tmp--; - } - s_next += shift[apr_tolower(*s_next)]; - } - return NULL; -} - -APU_DECLARE(const apr_strmatch_pattern *) apr_strmatch_precompile( - apr_pool_t *p, const char *s, - int case_sensitive) -{ - apr_strmatch_pattern *pattern; - apr_size_t i; - int *shift; - - pattern = apr_palloc(p, sizeof(*pattern)); - pattern->pattern = s; - pattern->length = strlen(s); - if (pattern->length == 0) { - pattern->compare = match_no_op; - pattern->context = NULL; - return pattern; - } - - shift = (int *)apr_palloc(p, sizeof(int) * NUM_CHARS); - for (i = 0; i < NUM_CHARS; i++) { - shift[i] = pattern->length; - } - if (case_sensitive) { - pattern->compare = match_boyer_moore_horspool; - for (i = 0; i < pattern->length - 1; i++) { - shift[(int)s[i]] = pattern->length - i - 1; - } - } - else { - pattern->compare = match_boyer_moore_horspool_nocase; - for (i = 0; i < pattern->length - 1; i++) { - shift[apr_tolower(s[i])] = pattern->length - i - 1; - } - } - pattern->context = shift; - - return pattern; -} diff --git a/libs/apr-util/test/Makefile.in b/libs/apr-util/test/Makefile.in deleted file mode 100644 index eb101720d8..0000000000 --- a/libs/apr-util/test/Makefile.in +++ /dev/null @@ -1,81 +0,0 @@ -VPATH = @srcdir@ - -INCLUDES = @APRUTIL_PRIV_INCLUDES@ @APR_INCLUDES@ @APRUTIL_INCLUDES@ - -PROGRAMS = testall testdbm testdate testxml testrmm \ - testreslist testqueue testxlate dbd -TARGETS = $(PROGRAMS) - -APRUTIL_DOTTED_VERSION=@APRUTIL_DOTTED_VERSION@ -APRUTIL_MAJOR_VERSION=@APRUTIL_MAJOR_VERSION@ -TARGET_LIB_PATH = ../lib@APRUTIL_LIBNAME@.la - -CLEAN_TARGETS = manyfile.bin testfile.txt data/sqlite*.db - -# bring in rules.mk for standard functionality -@INCLUDE_RULES@ -PROGRAM_DEPENDENCIES = @APRUTIL_LIBS@ -APRUTIL_LDFLAGS = -no-install @APRUTIL_LDFLAGS@ - -all: $(PROGRAMS) - -check: $(PROGRAMS) - for prog in $(PROGRAMS); do \ - ./$$prog ;\ - if test $$? = 255; then \ - echo "$$prog failed"; \ - break; \ - fi; \ - done - -testdbm_OBJECTS = testdbm.lo -testdbm_LDADD = $(TARGET_LIB_PATH) -testdbm: $(testdbm_OBJECTS) $(testdbm_LDADD) - $(LINK) $(APRUTIL_LDFLAGS) $(testdbm_OBJECTS) $(testdbm_LDADD) $(PROGRAM_DEPENDENCIES) - -dbd_OBJECTS = dbd.lo -dbd_LDADD = $(TARGET_LIB_PATH) -dbd: $(dbd_OBJECTS) $(dbd_LDADD) - $(LINK) $(APRUTIL_LDFLAGS) $(dbd_OBJECTS) $(dbd_LDADD) $(PROGRAM_DEPENDENCIES) - -testdbd_OBJECTS = testdbd.lo -testdbd_LDADD = $(TARGET_LIB_PATH) -testdbd: $(testdbd_OBJECTS) $(testdbd_LDADD) - $(LINK) $(APRUTIL_LDFLAGS) $(testdbd_OBJECTS) $(testdbd_LDADD) $(PROGRAM_DEPENDENCIES) - -testdate_OBJECTS = testdate.lo -testdate_LDADD = $(TARGET_LIB_PATH) -testdate: $(testdate_OBJECTS) $(testdate_LDADD) - $(LINK) $(APRUTIL_LDFLAGS) $(testdate_OBJECTS) $(testdate_LDADD) $(PROGRAM_DEPENDENCIES) - -testxml_OBJECTS = testxml.lo -testxml_LDADD = $(TARGET_LIB_PATH) -testxml: $(testxml_OBJECTS) $(testxml_LDADD) - $(LINK) $(APRUTIL_LDFLAGS) $(testxml_OBJECTS) $(testxml_LDADD) $(PROGRAM_DEPENDENCIES) - -testrmm_OBJECTS = testrmm.lo -testrmm_LDADD = $(TARGET_LIB_PATH) -testrmm: $(testrmm_OBJECTS) $(testrmm_LDADD) - $(LINK) $(APRUTIL_LDFLAGS) $(testrmm_OBJECTS) $(testrmm_LDADD) $(PROGRAM_DEPENDENCIES) - -testreslist_OBJECTS = testreslist.lo -testreslist_LDADD = $(TARGET_LIB_PATH) -testreslist: $(testreslist_OBJECTS) $(testreslist_LDADD) - $(LINK) $(APRUTIL_LDFLAGS) $(testreslist_OBJECTS) $(testreslist_LDADD) $(PROGRAM_DEPENDENCIES) - -testqueue_OBJECTS = testqueue.lo -testqueue_LDADD = $(TARGET_LIB_PATH) -testqueue: $(testqueue_OBJECTS) $(testqueue_LDADD) - $(LINK) $(APRUTIL_LDFLAGS) $(testqueue_OBJECTS) $(testqueue_LDADD) $(PROGRAM_DEPENDENCIES) - -testxlate_OBJECTS = testxlate.lo -testxlate_LDADD = $(TARGET_LIB_PATH) -testxlate: $(testxlate_OBJECTS) $(testxlate_LDADD) - $(LINK) $(APRUTIL_LDFLAGS) $(testxlate_OBJECTS) $(testxlate_LDADD) $(PROGRAM_DEPENDENCIES) - -testall_OBJECTS = teststrmatch.lo testuri.lo testuuid.lo abts.lo testutil.lo \ - testbuckets.lo testpass.lo testmd4.lo testmd5.lo testldap.lo testdbd.lo -testall_LDADD = $(TARGET_LIB_PATH) -testall: $(testall_OBJECTS) $(testall_LDADD) - $(LINK) $(APRUTIL_LDFLAGS) $(testall_OBJECTS) $(testall_LDADD) $(PROGRAM_DEPENDENCIES) - diff --git a/libs/apr-util/test/Makefile.win b/libs/apr-util/test/Makefile.win deleted file mode 100644 index 374f0ebb83..0000000000 --- a/libs/apr-util/test/Makefile.win +++ /dev/null @@ -1,131 +0,0 @@ -# -*- Makefile -*- -!IF "$(OS)" == "Windows_NT" -NULL= -rmdir=rd /s /q -!ELSE -NULL=nul -rmdir=deltree /y -!ENDIF - -SILENT=@ - -# Default build and bind modes -BUILD_MODE = release -BIND_MODE = shared - -!IF "$(BUILD_MODE)" == "release" || "$(BUILD_MODE)" == "Release" -!IF "$(BIND_MODE)" == "shared" -# release shared -APR_LIB_PFX = $(APR_SOURCE)\Release\lib -APU_LIB_PFX = $(APU_SOURCE)\Release\lib -API_LIB_PFX = $(API_SOURCE)\Release\lib -CFG_CFLAGS = /MD /O2 -CFG_DEFINES = /D "NDEBUG" -CFG_OUTPUT = Release - -!ELSE -!IF "$(BIND_MODE)" == "static" -# release static -APR_LIB_PFX = $(APR_SOURCE)\LibR\ # no line continuation -APU_LIB_PFX = $(APU_SOURCE)\LibR\ # no line continuation -API_LIB_PFX = $(API_SOURCE)\LibR\ # no line continuation -CFG_CFLAGS = /MD /O2 -CFG_DEFINES = /D "NDEBUG" /D "APR_DECLARE_STATIC" \ - /D "APU_DECLARE_STATIC" /D "API_DECLARE_STATIC" -CFG_API_LIB = $(API_LIB_PFX)apriconv-1.lib -CFG_OUTPUT = LibR - -!ELSE -!ERROR Unknown bind mode "$(BIND_MODE)" -!ENDIF -!ENDIF - -!ELSE -!IF "$(BUILD_MODE)" == "debug" || "$(BUILD_MODE)" == "Debug" -!IF "$(BIND_MODE)" == "shared" -# debug shared -APR_LIB_PFX = $(APR_SOURCE)\Debug\lib -APU_LIB_PFX = $(APU_SOURCE)\Debug\lib -API_LIB_PFX = $(API_SOURCE)\Debug\lib -CFG_CFLAGS = /MDd /Zi /Od -CFG_DEFINES = /D "_DEBUG" -CFG_LDFLAGS = /DEBUG -CFG_OUTPUT = Debug - -!ELSE -!IF "$(BIND_MODE)" == "static" -# debug static -APR_LIB_PFX = $(APR_SOURCE)\LibD\ # no line continuation -APU_LIB_PFX = $(APU_SOURCE)\LibD\ # no line continuation -API_LIB_PFX = $(API_SOURCE)\LibD\ # no line continuation -CFG_CFLAGS = /MDd /Zi /Od -CFG_DEFINES = /D "_DEBUG" /D "APR_DECLARE_STATIC" \ - /D "APU_DECLARE_STATIC" /D "API_DECLARE_STATIC" -CFG_LDFLAGS = /DEBUG -CFG_API_LIB = $(API_LIB_PFX)apriconv-1.lib -CFG_OUTPUT = LibD - -!ELSE -!ERROR Unknown bind mode "$(BIND_MODE)" -!ENDIF -!ENDIF - -!ELSE -!ERROR Unknown build mode "$(BUILD_MODE)" -!ENDIF -!ENDIF - - -APR_SOURCE = ..\..\apr -APU_SOURCE = .. -API_SOURCE = ..\..\apr-iconv -OUTPUT_DIR = .\$(CFG_OUTPUT) - -INT_CFLAGS = /nologo $(CFG_CFLAGS) /Fp"$(OUTPUT_DIR)\iconv.pch" /YX"iconv.h" -INT_INCLUDES = /I "$(APU_SOURCE)\include" /I "$(APR_SOURCE)\include" -# /I "$(API_SOURCE)\include" -INT_DEFINES = /D "WIN32" /D "_CONSOLE" /D "_MBCS" $(CFG_DEFINES) -INT_LDFLAGS = /nologo /incremental:no /subsystem:console $(CFG_LDFLAGS) - -CFLAGS = /W3 -ALL_CFLAGS = $(INT_CFLAGS) $(INT_INCLUDES) $(INT_DEFINES) $(CFLAGS) - -LDFLAGS = /WARN:0 -ALL_LDFLAGS = $(INT_LDFLAGS) $(LDFLAGS) - -.c{$(OUTPUT_DIR)}.exe: - -$(SILENT)if not exist "$(OUTPUT_DIR)\$(NULL)" mkdir "$(OUTPUT_DIR)" - $(SILENT)echo Compiling and linking $@... - $(SILENT)cl $(ALL_CFLAGS) /Fo"$*.obj" /Fd"$*" $< \ - /link $(ALL_LDFLAGS) /out:$@ \ - "$(APU_LIB_PFX)aprutil-1.lib" \ - "$(APR_LIB_PFX)apr-1.lib" \ - "$(CFG_API)" \ - kernel32.lib advapi32.lib ws2_32.lib mswsock.lib - - -##!ALL_TARGETS = $(OUTPUT_DIR)\testdate.exe \ -##! $(OUTPUT_DIR)\testdbm.exe \ -##! $(OUTPUT_DIR)\testmd4.exe \ -##! $(OUTPUT_DIR)\testmd5.exe \ -##! $(OUTPUT_DIR)\testqueue.exe \ -##! $(OUTPUT_DIR)\testreslist.exe \ -##! $(OUTPUT_DIR)\testrmm.exe \ -##! $(OUTPUT_DIR)\teststrmatch.exe \ -##! $(OUTPUT_DIR)\testuri.exe \ -##! $(OUTPUT_DIR)\testuuid.exe \ -##! $(OUTPUT_DIR)\testxlate.exe \ -##! $(OUTPUT_DIR)\testxml.exe - -ALL_TARGETS = $(OUTPUT_DIR)\testxlate.exe \ - $(OUTPUT_DIR)\testdbm.exe \ - $(OUTPUT_DIR)\testqueue.exe \ - $(OUTPUT_DIR)\testrmm.exe \ - $(OUTPUT_DIR)\testmd4.exe \ - $(OUTPUT_DIR)\testmd5.exe \ - $(OUTPUT_DIR)\testxml.exe - -all: $(ALL_TARGETS) - -clean: - -$(SILENT)if exist "$(OUTPUT_DIR)/$(NULL)" $(rmdir) $(OUTPUT_DIR) diff --git a/libs/apr-util/test/NWGNUmakefile b/libs/apr-util/test/NWGNUmakefile deleted file mode 100644 index e0bb2d5b0b..0000000000 --- a/libs/apr-util/test/NWGNUmakefile +++ /dev/null @@ -1,258 +0,0 @@ -# -# Declare the sub-directories to be built here -# - -SUBDIRS = \ - $(EOLIST) - -# -# Get the 'head' of the build environment. This includes default targets and -# paths to tools -# - -include $(APR_WORK)\build\NWGNUhead.inc - -# -# build this level's files - -# -# Make sure all needed macro's are defined -# - - -# -# These directories will be at the beginning of the include list, followed by -# INCDIRS -# -XINCDIRS += \ - $(APR)/include \ - $(APR)/include/arch/NetWare \ - $(EOLIST) - -# -# These flags will come after CFLAGS -# -XCFLAGS += \ - $(EOLIST) - -# -# These defines will come after DEFINES -# -XDEFINES += \ - $(EOLIST) - -# -# These flags will be added to the link.opt file -# -XLFLAGS += \ - $(EOLIST) - -# -# These values will be appended to the correct variables based on the value of -# RELEASE -# -ifeq "$(RELEASE)" "debug" -XINCDIRS += \ - $(EOLIST) - -XCFLAGS += \ - $(EOLIST) - -XDEFINES += \ - $(EOLIST) - -XLFLAGS += \ - $(EOLIST) - -endif - -ifeq "$(RELEASE)" "noopt" -XINCDIRS += \ - $(EOLIST) - -XCFLAGS += \ - $(EOLIST) - -XDEFINES += \ - $(EOLIST) - -XLFLAGS += \ - $(EOLIST) -endif - -ifeq "$(RELEASE)" "release" -XINCDIRS += \ - $(EOLIST) - -XCFLAGS += \ - $(EOLIST) - -XDEFINES += \ - $(EOLIST) - -XLFLAGS += \ - $(EOLIST) -endif - -# -# These are used by the link target if an NLM is being generated -# This is used by the link 'name' directive to name the nlm. If left blank -# TARGET_nlm (see below) will be used. -# -NLM_NAME = - -# -# This is used by the link '-desc ' directive. -# If left blank, NLM_NAME will be used. -# -NLM_DESCRIPTION = NLM is to test the apu layer - -# -# This is used by the '-threadname' directive. If left blank, -# NLM_NAME Thread will be used. -# -NLM_THREAD_NAME = - -# -# This is used by the '-screenname' directive. If left blank, -# 'Apache for NetWare' Thread will be used. -# -NLM_SCREEN_NAME = - -# -# If this is specified, it will override VERSION value in -# $(APR_WORK)\build\NWGNUenvironment.inc -# -NLM_VERSION = - -# -# If this is specified, it will override the default of 64K -# -NLM_STACK_SIZE = - -# -# If this is specified it will be used by the link '-entry' directive -# -NLM_ENTRY_SYM = - -# -# If this is specified it will be used by the link '-exit' directive -# -NLM_EXIT_SYM = - -# -# If this is specified it will be used by the link '-check' directive -# -NLM_CHECK_SYM = - -# -# If this is specified it will be used by the link '-flags' directive -# -NLM_FLAGS = - -# -# If this is specified it will be linked in with the XDCData option in the def -# file instead of the default of $(APR)/misc/netware/apache.xdc. XDCData can -# be disabled by setting APACHE_UNIPROC in the environment -# -XDCDATA = - -# -# Declare all target files (you must add your files here) -# - -# -# If there is an NLM target, put it here -# -TARGET_nlm = \ - $(OBJDIR)/aputest.nlm \ - $(OBJDIR)/testdate.nlm \ - $(EOLIST) -# -# If there is an LIB target, put it here -# -TARGET_lib = \ - $(EOLIST) - -# -# These are the OBJ files needed to create the NLM target above. -# Paths must all use the '/' character -# -FILES_nlm_objs = \ - $(EOLIST) - -# -# These are the LIB files needed to create the NLM target above. -# These will be added as a library command in the link.opt file. -# -FILES_nlm_libs = \ - $(EOLIST) - -# -# These are the modules that the above NLM target depends on to load. -# These will be added as a module command in the link.opt file. -# -FILES_nlm_modules = \ - aprlib \ - $(EOLIST) - -# -# If the nlm has a msg file, put it's path here -# -FILE_nlm_msg = - -# -# If the nlm has a hlp file put it's path here -# -FILE_nlm_hlp = - -# -# If this is specified, it will override the default copyright. -# -FILE_nlm_copyright = - -# -# Any additional imports go here -# -FILES_nlm_Ximports = \ - $(EOLIST) - -# -# Any symbols exported to here -# -FILES_nlm_exports = \ - $(EOLIST) - -# -# These are the OBJ files needed to create the LIB target above. -# Paths must all use the '/' character -# -FILES_lib_objs = \ - $(EOLIST) - -# -# implement targets and dependancies (leave this section alone) -# - -libs :: $(OBJDIR) $(TARGET_lib) - -nlms :: libs $(TARGET_nlm) - -# -# Updated this target to create necessary directories and copy files to the -# correct place. (See $(APR_WORK)\build\NWGNUhead.inc for examples) -# -install :: nlms FORCE - copy $(OBJDIR)\*.nlm $(INSTALL)\Apache2 - -# -# Any specialized rules here -# - -# -# Include the 'tail' makefile that has targets that depend on variables defined -# in this makefile -# - -include $(APR_WORK)\build\NWGNUtail.inc - diff --git a/libs/apr-util/test/abts.c b/libs/apr-util/test/abts.c deleted file mode 100644 index 03ae16d1b3..0000000000 --- a/libs/apr-util/test/abts.c +++ /dev/null @@ -1,416 +0,0 @@ -/* Copyright 2000-2004 Ryan Bloom - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Portions of this file were taken from testall.c in the APR test suite, - * written by members of the Apache Software Foundation. - */ - -#include "abts.h" -#include "abts_tests.h" -#include "testutil.h" - -#define ABTS_STAT_SIZE 6 -static char status[ABTS_STAT_SIZE] = {'|', '/', '-', '|', '\\', '-'}; -static int curr_char; -static int verbose = 0; -static int exclude = 0; -static int quiet = 0; -static int list_tests = 0; - -const char **testlist = NULL; - -static int find_test_name(const char *testname) { - int i; - for (i = 0; testlist[i] != NULL; i++) { - if (!strcmp(testlist[i], testname)) { - return 1; - } - } - return 0; -} - -/* Determine if the test should be run at all */ -static int should_test_run(const char *testname) { - int found = 0; - if (list_tests == 1) { - return 0; - } - if (testlist == NULL) { - return 1; - } - found = find_test_name(testname); - if ((found && !exclude) || (!found && exclude)) { - return 1; - } - return 0; -} - -static void reset_status(void) -{ - curr_char = 0; -} - -static void update_status(void) -{ - if (!quiet) { - curr_char = (curr_char + 1) % ABTS_STAT_SIZE; - fprintf(stdout, "\b%c", status[curr_char]); - fflush(stdout); - } -} - -static void end_suite(abts_suite *suite) -{ - if (suite != NULL) { - sub_suite *last = suite->tail; - if (!quiet) { - fprintf(stdout, "\b"); - fflush(stdout); - } - if (last->failed == 0) { - fprintf(stdout, "SUCCESS\n"); - fflush(stdout); - } - else { - fprintf(stdout, "FAILED %d of %d\n", last->failed, last->num_test); - fflush(stdout); - } - } -} - -abts_suite *abts_add_suite(abts_suite *suite, const char *suite_name_full) -{ - sub_suite *subsuite; - char *p; - const char *suite_name; - curr_char = 0; - - /* Only end the suite if we actually ran it */ - if (suite && suite->tail &&!suite->tail->not_run) { - end_suite(suite); - } - - subsuite = malloc(sizeof(*subsuite)); - subsuite->num_test = 0; - subsuite->failed = 0; - subsuite->next = NULL; - /* suite_name_full may be an absolute path depending on __FILE__ - * expansion */ - suite_name = strrchr(suite_name_full, '/'); - if (suite_name) { - suite_name++; - } else { - suite_name = suite_name_full; - } - p = strrchr(suite_name, '.'); - if (p) { - subsuite->name = memcpy(calloc(p - suite_name + 1, 1), - suite_name, p - suite_name); - } - else { - subsuite->name = suite_name; - } - - if (list_tests) { - fprintf(stdout, "%s\n", subsuite->name); - } - - subsuite->not_run = 0; - - if (suite == NULL) { - suite = malloc(sizeof(*suite)); - suite->head = subsuite; - suite->tail = subsuite; - } - else { - suite->tail->next = subsuite; - suite->tail = subsuite; - } - - if (!should_test_run(subsuite->name)) { - subsuite->not_run = 1; - return suite; - } - - reset_status(); - fprintf(stdout, "%-20s: ", subsuite->name); - update_status(); - fflush(stdout); - - return suite; -} - -void abts_run_test(abts_suite *ts, test_func f, void *value) -{ - abts_case *tc; - sub_suite *ss; - - if (!should_test_run(ts->tail->name)) { - return; - } - ss = ts->tail; - - tc = malloc(sizeof(*tc)); - tc->failed = 0; - tc->suite = ss; - - ss->num_test++; - update_status(); - - f(tc, value); - - if (tc->failed) { - ss->failed++; - } - free(tc); -} - -static int report(abts_suite *suite) -{ - int count = 0; - sub_suite *dptr; - - if (suite && suite->tail &&!suite->tail->not_run) { - end_suite(suite); - } - - for (dptr = suite->head; dptr; dptr = dptr->next) { - count += dptr->failed; - } - - if (list_tests) { - return 0; - } - - if (count == 0) { - printf("All tests passed.\n"); - return 0; - } - - dptr = suite->head; - fprintf(stdout, "%-15s\t\tTotal\tFail\tFailed %%\n", "Failed Tests"); - fprintf(stdout, "===================================================\n"); - while (dptr != NULL) { - if (dptr->failed != 0) { - float percent = ((float)dptr->failed / (float)dptr->num_test); - fprintf(stdout, "%-15s\t\t%5d\t%4d\t%6.2f%%\n", dptr->name, - dptr->num_test, dptr->failed, percent * 100); - } - dptr = dptr->next; - } - return 1; -} - -void abts_log_message(const char *fmt, ...) -{ - va_list args; - update_status(); - - if (verbose) { - va_start(args, fmt); - vfprintf(stderr, fmt, args); - va_end(args); - fprintf(stderr, "\n"); - fflush(stderr); - } -} - -void abts_int_equal(abts_case *tc, const int expected, const int actual, int lineno) -{ - update_status(); - if (tc->failed) return; - - if (expected == actual) return; - - tc->failed = TRUE; - if (verbose) { - fprintf(stderr, "Line %d: expected <%d>, but saw <%d>\n", lineno, expected, actual); - fflush(stderr); - } -} - -void abts_int_nequal(abts_case *tc, const int expected, const int actual, int lineno) -{ - update_status(); - if (tc->failed) return; - - if (expected != actual) return; - - tc->failed = TRUE; - if (verbose) { - fprintf(stderr, "Line %d: expected <%d>, but saw <%d>\n", lineno, expected, actual); - fflush(stderr); - } -} - -void abts_str_equal(abts_case *tc, const char *expected, const char *actual, int lineno) -{ - update_status(); - if (tc->failed) return; - - /* If both are NULL, match is good */ - if (!expected && !actual) return; - if (expected && actual) - if (!strcmp(expected, actual)) return; - - tc->failed = TRUE; - if (verbose) { - fprintf(stderr, "Line %d: expected <%s>, but saw <%s>\n", lineno, expected, actual); - fflush(stderr); - } -} - -void abts_str_nequal(abts_case *tc, const char *expected, const char *actual, - size_t n, int lineno) -{ - update_status(); - if (tc->failed) return; - - if (!strncmp(expected, actual, n)) return; - - tc->failed = TRUE; - if (verbose) { - fprintf(stderr, "Line %d: expected <%s>, but saw <%s>\n", lineno, expected, actual); - fflush(stderr); - } -} - -void abts_ptr_notnull(abts_case *tc, const void *ptr, int lineno) -{ - update_status(); - if (tc->failed) return; - - if (ptr != NULL) return; - - tc->failed = TRUE; - if (verbose) { - fprintf(stderr, "Line %d: Expected NULL, but saw <%p>\n", lineno, ptr); - fflush(stderr); - } -} - -void abts_ptr_equal(abts_case *tc, const void *expected, const void *actual, int lineno) -{ - update_status(); - if (tc->failed) return; - - if (expected == actual) return; - - tc->failed = TRUE; - if (verbose) { - fprintf(stderr, "Line %d: expected <%p>, but saw <%p>\n", lineno, expected, actual); - fflush(stderr); - } -} - -void abts_fail(abts_case *tc, const char *message, int lineno) -{ - update_status(); - if (tc->failed) return; - - tc->failed = TRUE; - if (verbose) { - fprintf(stderr, "Line %d: %s\n", lineno, message); - fflush(stderr); - } -} - -void abts_assert(abts_case *tc, const char *message, int condition, int lineno) -{ - update_status(); - if (tc->failed) return; - - if (condition) return; - - tc->failed = TRUE; - if (verbose) { - fprintf(stderr, "Line %d: %s\n", lineno, message); - fflush(stderr); - } -} - -void abts_true(abts_case *tc, int condition, int lineno) -{ - update_status(); - if (tc->failed) return; - - if (condition) return; - - tc->failed = TRUE; - if (verbose) { - fprintf(stderr, "Line %d: Condition is false, but expected true\n", lineno); - fflush(stderr); - } -} - -void abts_not_impl(abts_case *tc, const char *message, int lineno) -{ - update_status(); - - tc->suite->not_impl++; - if (verbose) { - fprintf(stderr, "Line %d: %s\n", lineno, message); - fflush(stderr); - } -} - -int main(int argc, const char *const argv[]) { - int i; - int rv; - int list_provided = 0; - abts_suite *suite = NULL; - - initialize(); - for (i = 1; i < argc; i++) { - if (!strcmp(argv[i], "-v")) { - verbose = 1; - continue; - } - if (!strcmp(argv[i], "-x")) { - exclude = 1; - continue; - } - if (!strcmp(argv[i], "-l")) { - list_tests = 1; - continue; - } - if (!strcmp(argv[i], "-q")) { - quiet = 1; - continue; - } - if (argv[i][0] == '-') { - fprintf(stderr, "Invalid option: `%s'\n", argv[i]); - exit(1); - } - list_provided = 1; - } - - if (list_provided) { - /* Waste a little space here, because it is easier than counting the - * number of tests listed. Besides it is at most three char *. - */ - testlist = calloc(argc + 1, sizeof(char *)); - for (i = 1; i < argc; i++) { - testlist[i - 1] = argv[i]; - } - } - - for (i = 0; i < (sizeof(alltests) / sizeof(struct testlist *)); i++) { - suite = alltests[i].func(suite); - } - - rv = report(suite); - return rv; -} - diff --git a/libs/apr-util/test/abts.h b/libs/apr-util/test/abts.h deleted file mode 100644 index 51123ff079..0000000000 --- a/libs/apr-util/test/abts.h +++ /dev/null @@ -1,98 +0,0 @@ -/* Copyright 2000-2004 Ryan Bloom - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include - -#ifndef ABTS_H -#define ABTS_H - -#ifndef FALSE -#define FALSE 0 -#endif -#ifndef TRUE -#define TRUE 1 -#endif - -struct sub_suite { - const char *name; - int num_test; - int failed; - int not_run; - int not_impl; - struct sub_suite *next; -}; -typedef struct sub_suite sub_suite; - -struct abts_suite { - sub_suite *head; - sub_suite *tail; -}; -typedef struct abts_suite abts_suite; - -struct abts_case { - int failed; - sub_suite *suite; -}; -typedef struct abts_case abts_case; - -typedef void (*test_func)(abts_case *tc, void *data); - -#define ADD_SUITE(suite) abts_add_suite(suite, __FILE__); - -abts_suite *abts_add_suite(abts_suite *suite, const char *suite_name); -void abts_run_test(abts_suite *ts, test_func f, void *value); -void abts_log_message(const char *fmt, ...); - -void abts_int_equal(abts_case *tc, const int expected, const int actual, int lineno); -void abts_int_nequal(abts_case *tc, const int expected, const int actual, int lineno); -void abts_str_equal(abts_case *tc, const char *expected, const char *actual, int lineno); -void abts_str_nequal(abts_case *tc, const char *expected, const char *actual, - size_t n, int lineno); -void abts_ptr_notnull(abts_case *tc, const void *ptr, int lineno); -void abts_ptr_equal(abts_case *tc, const void *expected, const void *actual, int lineno); -void abts_true(abts_case *tc, int condition, int lineno); -void abts_fail(abts_case *tc, const char *message, int lineno); -void abts_not_impl(abts_case *tc, const char *message, int lineno); -void abts_assert(abts_case *tc, const char *message, int condition, int lineno); - -/* Convenience macros. Ryan hates these! */ -#define ABTS_INT_EQUAL(a, b, c) abts_int_equal(a, b, c, __LINE__) -#define ABTS_INT_NEQUAL(a, b, c) abts_int_nequal(a, b, c, __LINE__) -#define ABTS_STR_EQUAL(a, b, c) abts_str_equal(a, b, c, __LINE__) -#define ABTS_STR_NEQUAL(a, b, c, d) abts_str_nequal(a, b, c, d, __LINE__) -#define ABTS_PTR_NOTNULL(a, b) abts_ptr_notnull(a, b, __LINE__) -#define ABTS_PTR_EQUAL(a, b, c) abts_ptr_equal(a, b, c, __LINE__) -#define ABTS_TRUE(a, b) abts_true(a, b, __LINE__); -#define ABTS_FAIL(a, b) abts_fail(a, b, __LINE__); -#define ABTS_NOT_IMPL(a, b) abts_not_impl(a, b, __LINE__); -#define ABTS_ASSERT(a, b, c) abts_assert(a, b, c, __LINE__); - -abts_suite *run_tests(abts_suite *suite); -abts_suite *run_tests1(abts_suite *suite); - - -#endif - -#ifdef __cplusplus -} -#endif - diff --git a/libs/apr-util/test/abts_tests.h b/libs/apr-util/test/abts_tests.h deleted file mode 100644 index b137ce58dc..0000000000 --- a/libs/apr-util/test/abts_tests.h +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_TEST_INCLUDES -#define APR_TEST_INCLUDES - -#include "abts.h" -#include "testutil.h" - -const struct testlist { - abts_suite *(*func)(abts_suite *suite); -} alltests[] = { - {teststrmatch}, - {testuri}, - {testuuid}, - {testbuckets}, - {testpass}, - {testmd4}, - {testmd5}, - {testldap}, - {testdbd} -}; - -#endif /* APR_TEST_INCLUDES */ diff --git a/libs/apr-util/test/data/.empty b/libs/apr-util/test/data/.empty deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/libs/apr-util/test/dbd.c b/libs/apr-util/test/dbd.c deleted file mode 100644 index f8832539c1..0000000000 --- a/libs/apr-util/test/dbd.c +++ /dev/null @@ -1,407 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apu.h" -#include "apr_pools.h" -#include "apr_dbd.h" - -#include - -#define TEST(msg,func) \ - printf("======== %s ========\n", msg); \ - rv = func(pool, sql, driver); \ - if (rv != 0) { \ - printf("Error in %s: rc=%d\n\n", msg, rv); \ - } \ - else { \ - printf("%s test successful\n\n", msg); \ - } \ - fflush(stdout); - -static int create_table(apr_pool_t* pool, apr_dbd_t* handle, - const apr_dbd_driver_t* driver) -{ - int rv = 0; - int nrows; - const char *statement = "CREATE TABLE apr_dbd_test (" - "col1 varchar(40) not null," - "col2 varchar(40)," - "col3 integer)" ; - rv = apr_dbd_query(driver, handle, &nrows, statement); - return rv; -} -static int drop_table(apr_pool_t* pool, apr_dbd_t* handle, - const apr_dbd_driver_t* driver) -{ - int rv = 0; - int nrows; - const char *statement = "DROP TABLE apr_dbd_test" ; - rv = apr_dbd_query(driver, handle, &nrows, statement); - return rv; -} -static int insert_rows(apr_pool_t* pool, apr_dbd_t* handle, - const apr_dbd_driver_t* driver) -{ - int i; - int rv = 0; - int nrows; - int nerrors = 0; - const char *statement = - "INSERT into apr_dbd_test (col1) values ('foo');" - "INSERT into apr_dbd_test values ('wibble', 'other', 5);" - "INSERT into apr_dbd_test values ('wibble', 'nothing', 5);" - "INSERT into apr_dbd_test values ('qwerty', 'foo', 0);" - "INSERT into apr_dbd_test values ('asdfgh', 'bar', 1);" - ; - rv = apr_dbd_query(driver, handle, &nrows, statement); - if (rv) { - const char* stmt[] = { - "INSERT into apr_dbd_test (col1) values ('foo');", - "INSERT into apr_dbd_test values ('wibble', 'other', 5);", - "INSERT into apr_dbd_test values ('wibble', 'nothing', 5);", - "INSERT into apr_dbd_test values ('qwerty', 'foo', 0);", - "INSERT into apr_dbd_test values ('asdfgh', 'bar', 1);", - NULL - }; - printf("Compound insert failed; trying statements one-by-one\n") ; - for (i=0; stmt[i] != NULL; ++i) { - statement = stmt[i]; - rv = apr_dbd_query(driver, handle, &nrows, statement); - if (rv) { - nerrors++; - } - } - if (nerrors) { - printf("%d single inserts failed too.\n", nerrors) ; - } - } - return rv; -} -static int invalid_op(apr_pool_t* pool, apr_dbd_t* handle, - const apr_dbd_driver_t* driver) -{ - int rv = 0; - int nrows; - const char *statement = "INSERT into apr_dbd_test1 (col2) values ('foo')" ; - rv = apr_dbd_query(driver, handle, &nrows, statement); - printf("invalid op returned %d (should be nonzero). Error msg follows\n", rv); - printf("'%s'\n", apr_dbd_error(driver, handle, rv)); - statement = "INSERT into apr_dbd_test (col1, col2) values ('bar', 'foo')" ; - rv = apr_dbd_query(driver, handle, &nrows, statement); - printf("valid op returned %d (should be zero; error shouldn't affect subsequent ops)\n", rv); - return rv; -} -static int select_sequential(apr_pool_t* pool, apr_dbd_t* handle, - const apr_dbd_driver_t* driver) -{ - int rv = 0; - int i = 0; - int n; - const char* entry; - const char* statement = "SELECT * FROM apr_dbd_test ORDER BY col1, col2"; - apr_dbd_results_t *res = NULL; - apr_dbd_row_t *row = NULL; - rv = apr_dbd_select(driver,pool,handle,&res,statement,0); - if (rv) { - printf("Select failed: %s", apr_dbd_error(driver, handle, rv)); - return rv; - } - for (rv = apr_dbd_get_row(driver, pool, res, &row, -1); - rv == 0; - rv = apr_dbd_get_row(driver, pool, res, &row, -1)) { - printf("ROW %d: ", i++) ; - for (n = 0; n < apr_dbd_num_cols(driver, res); ++n) { - entry = apr_dbd_get_entry(driver, row, n); - if (entry == NULL) { - printf("(null) ") ; - } - else { - printf("%s ", entry); - } - } - fputs("\n", stdout); - } - return (rv == -1) ? 0 : 1; -} -static int select_random(apr_pool_t* pool, apr_dbd_t* handle, - const apr_dbd_driver_t* driver) -{ - int rv = 0; - int n; - const char* entry; - const char* statement = "SELECT * FROM apr_dbd_test ORDER BY col1, col2"; - apr_dbd_results_t *res = NULL; - apr_dbd_row_t *row = NULL; - rv = apr_dbd_select(driver,pool,handle,&res,statement,1); - if (rv) { - printf("Select failed: %s", apr_dbd_error(driver, handle, rv)); - return rv; - } - rv = apr_dbd_get_row(driver, pool, res, &row, 5) ; - if (rv) { - printf("get_row failed: %s", apr_dbd_error(driver, handle, rv)); - return rv; - } - printf("ROW 5: "); - for (n = 0; n < apr_dbd_num_cols(driver, res); ++n) { - entry = apr_dbd_get_entry(driver, row, n); - if (entry == NULL) { - printf("(null) ") ; - } - else { - printf("%s ", entry); - } - } - fputs("\n", stdout); - rv = apr_dbd_get_row(driver, pool, res, &row, 1) ; - if (rv) { - printf("get_row failed: %s", apr_dbd_error(driver, handle, rv)); - return rv; - } - printf("ROW 1: "); - for (n = 0; n < apr_dbd_num_cols(driver, res); ++n) { - entry = apr_dbd_get_entry(driver, row, n); - if (entry == NULL) { - printf("(null) ") ; - } - else { - printf("%s ", entry); - } - } - fputs("\n", stdout); - rv = apr_dbd_get_row(driver, pool, res, &row, 11) ; - if (rv != -1) { - printf("Oops! get_row out of range but thinks it succeeded!\n%s\n", - apr_dbd_error(driver, handle, rv)); - return -1; - } - rv = 0; - - return rv; -} -static int test_transactions(apr_pool_t* pool, apr_dbd_t* handle, - const apr_dbd_driver_t* driver) -{ - int rv = 0; - int nrows; - apr_dbd_transaction_t *trans = NULL; - const char* statement; - - /* trans 1 - error out early */ - printf("Transaction 1\n"); - rv = apr_dbd_transaction_start(driver, pool, handle, &trans); - if (rv) { - printf("Start transaction failed!\n%s\n", - apr_dbd_error(driver, handle, rv)); - return rv; - } - statement = "UPDATE apr_dbd_test SET col2 = 'failed'"; - rv = apr_dbd_query(driver, handle, &nrows, statement); - if (rv) { - printf("Update failed: '%s'\n", apr_dbd_error(driver, handle, rv)); - apr_dbd_transaction_end(driver, pool, trans); - return rv; - } - printf("%d rows updated\n", nrows); - - statement = "INSERT INTO apr_dbd_test1 (col3) values (3)"; - rv = apr_dbd_query(driver, handle, &nrows, statement); - if (!rv) { - printf("Oops, invalid op succeeded but shouldn't!\n"); - } - statement = "INSERT INTO apr_dbd_test values ('zzz', 'aaa', 3)"; - rv = apr_dbd_query(driver, handle, &nrows, statement); - printf("Valid insert returned %d. Should be nonzero (fail) because transaction is bad\n", rv) ; - - rv = apr_dbd_transaction_end(driver, pool, trans); - if (rv) { - printf("End transaction failed!\n%s\n", - apr_dbd_error(driver, handle, rv)); - return rv; - } - printf("Transaction ended (should be rollback) - viewing table\n" - "A column of \"failed\" indicates transaction failed (no rollback)\n"); - select_sequential(pool, handle, driver); - - /* trans 2 - complete successfully */ - printf("Transaction 2\n"); - rv = apr_dbd_transaction_start(driver, pool, handle, &trans); - if (rv) { - printf("Start transaction failed!\n%s\n", - apr_dbd_error(driver, handle, rv)); - return rv; - } - statement = "UPDATE apr_dbd_test SET col2 = 'success'"; - rv = apr_dbd_query(driver, handle, &nrows, statement); - if (rv) { - printf("Update failed: '%s'\n", apr_dbd_error(driver, handle, rv)); - apr_dbd_transaction_end(driver, pool, trans); - return rv; - } - printf("%d rows updated\n", nrows); - statement = "INSERT INTO apr_dbd_test values ('aaa', 'zzz', 3)"; - rv = apr_dbd_query(driver, handle, &nrows, statement); - printf("Valid insert returned %d. Should be zero (OK)\n", rv) ; - rv = apr_dbd_transaction_end(driver, pool, trans); - if (rv) { - printf("End transaction failed!\n%s\n", - apr_dbd_error(driver, handle, rv)); - return rv; - } - printf("Transaction ended (should be commit) - viewing table\n"); - select_sequential(pool, handle, driver); - return rv; -} -static int test_pselect(apr_pool_t* pool, apr_dbd_t* handle, - const apr_dbd_driver_t* driver) -{ - int rv = 0; - int i, n; - const char *query = - "SELECT * FROM apr_dbd_test WHERE col3 <= %s or col1 = 'bar'" ; - const char *label = "lowvalues"; - apr_dbd_prepared_t *statement = NULL; - apr_dbd_results_t *res = NULL; - apr_dbd_row_t *row = NULL; - const char *entry = NULL; - - rv = apr_dbd_prepare(driver, pool, handle, query, label, &statement); - if (rv) { - printf("Prepare statement failed!\n%s\n", - apr_dbd_error(driver, handle, rv)); - return rv; - } - rv = apr_dbd_pvselect(driver, pool, handle, &res, statement, 0, "3", NULL); - if (rv) { - printf("Exec of prepared statement failed!\n%s\n", - apr_dbd_error(driver, handle, rv)); - return rv; - } - i = 0; - printf("Selecting rows where col3 <= 3 and bar row where it's unset.\nShould show four rows.\n"); - for (rv = apr_dbd_get_row(driver, pool, res, &row, -1); - rv == 0; - rv = apr_dbd_get_row(driver, pool, res, &row, -1)) { - printf("ROW %d: ", i++) ; - for (n = 0; n < apr_dbd_num_cols(driver, res); ++n) { - entry = apr_dbd_get_entry(driver, row, n); - if (entry == NULL) { - printf("(null) ") ; - } - else { - printf("%s ", entry); - } - } - fputs("\n", stdout); - } - return (rv == -1) ? 0 : 1; -} -static int test_pquery(apr_pool_t* pool, apr_dbd_t* handle, - const apr_dbd_driver_t* driver) -{ - int rv = 0; - const char *query = "INSERT INTO apr_dbd_test VALUES (%s, %s, %d)"; - apr_dbd_prepared_t *statement = NULL; - const char *label = "testpquery"; - int nrows; - apr_dbd_transaction_t *trans =0; - - rv = apr_dbd_prepare(driver, pool, handle, query, label, &statement); - /* rv = apr_dbd_prepare(driver, pool, handle, query, NULL, &statement); */ - if (rv) { - printf("Prepare statement failed!\n%s\n", - apr_dbd_error(driver, handle, rv)); - return rv; - } - apr_dbd_transaction_start(driver, pool, handle, &trans); - rv = apr_dbd_pvquery(driver, pool, handle, &nrows, statement, - "prepared", "insert", "2", NULL); - apr_dbd_transaction_end(driver, pool, trans); - if (rv) { - printf("Exec of prepared statement failed!\n%s\n", - apr_dbd_error(driver, handle, rv)); - return rv; - } - printf("Showing table (should now contain row \"prepared insert 2\")\n"); - select_sequential(pool, handle, driver); - return rv; -} -int main(int argc, char** argv) -{ - const char *name; - const char *params; - apr_pool_t *pool = NULL; - apr_dbd_t *sql = NULL; - const apr_dbd_driver_t *driver = NULL; - int rv; - - apr_initialize(); - apr_pool_create(&pool, NULL); - - if (argc >= 2 && argc <= 3) { - name = argv[1]; - params = ( argc == 3 ) ? argv[2] : ""; - apr_dbd_init(pool); - setbuf(stdout,NULL); - rv = apr_dbd_get_driver(pool, name, &driver); - switch (rv) { - case APR_SUCCESS: - printf("Loaded %s driver OK.\n", name); - break; - case APR_EDSOOPEN: - printf("Failed to load driver file apr_dbd_%s.so\n", name); - goto finish; - case APR_ESYMNOTFOUND: - printf("Failed to load driver apr_dbd_%s_driver.\n", name); - goto finish; - case APR_ENOTIMPL: - printf("No driver available for %s.\n", name); - goto finish; - default: /* it's a bug if none of the above happen */ - printf("Internal error loading %s.\n", name); - goto finish; - } - rv = apr_dbd_open(driver, pool, params, &sql); - switch (rv) { - case APR_SUCCESS: - printf("Opened %s[%s] OK\n", name, params); - break; - case APR_EGENERAL: - printf("Failed to open %s[%s]\n", name, params); - goto finish; - default: /* it's a bug if none of the above happen */ - printf("Internal error opening %s[%s]\n", name, params); - goto finish; - } - TEST("create table", create_table); - TEST("insert rows", insert_rows); - TEST("invalid op", invalid_op); - TEST("select random", select_random); - TEST("select sequential", select_sequential); - TEST("transactions", test_transactions); - TEST("prepared select", test_pselect); - TEST("prepared query", test_pquery); - TEST("drop table", drop_table); - apr_dbd_close(driver, sql); - } - else { - fprintf(stderr, "Usage: %s driver-name [params]\n", argv[0]); - } -finish: - apr_pool_destroy(pool); - apr_terminate(); - return 0; -} diff --git a/libs/apr-util/test/nw_misc.c b/libs/apr-util/test/nw_misc.c deleted file mode 100644 index cf68692bde..0000000000 --- a/libs/apr-util/test/nw_misc.c +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include -#include "testutil.h" - -void _NonAppStop( void ) -{ - pressanykey(); -} - -/* -static void test_not_impl(CuTest *tc) -{ - CuNotImpl(tc, "Test not implemented on this platform yet"); -} -*/ - diff --git a/libs/apr-util/test/nwgnuaputest b/libs/apr-util/test/nwgnuaputest deleted file mode 100644 index 1611a58273..0000000000 --- a/libs/apr-util/test/nwgnuaputest +++ /dev/null @@ -1,272 +0,0 @@ -# -# Make sure all needed macro's are defined -# - -# -# Get the 'head' of the build environment if necessary. This includes default -# targets and paths to tools -# - -ifndef EnvironmentDefined -include $(APR_WORK)\build\NWGNUhead.inc -endif - -# -# These directories will be at the beginning of the include list, followed by -# INCDIRS -# -XINCDIRS += \ - $(APR)/include \ - $(APR)/include/arch/NetWare \ - $(APRUTIL)/include \ - $(LDAPSDK)/inc \ - $(EOLIST) - -# -# These flags will come after CFLAGS -# -XCFLAGS += \ - $(EOLIST) - -# -# These defines will come after DEFINES -# -XDEFINES += \ - $(EOLIST) - -# -# These flags will be added to the link.opt file -# -XLFLAGS += \ - $(EOLIST) - -# -# These values will be appended to the correct variables based on the value of -# RELEASE -# -ifeq "$(RELEASE)" "debug" -XINCDIRS += \ - $(EOLIST) - -XCFLAGS += \ - $(EOLIST) - -XDEFINES += \ - $(EOLIST) - -XLFLAGS += \ - $(EOLIST) -endif - -ifeq "$(RELEASE)" "noopt" -XINCDIRS += \ - $(EOLIST) - -XCFLAGS += \ - $(EOLIST) - -XDEFINES += \ - $(EOLIST) - -XLFLAGS += \ - $(EOLIST) -endif - -ifeq "$(RELEASE)" "release" -XINCDIRS += \ - $(EOLIST) - -XCFLAGS += \ - $(EOLIST) - -XDEFINES += \ - $(EOLIST) - -XLFLAGS += \ - $(EOLIST) -endif - -# -# These are used by the link target if an NLM is being generated -# This is used by the link 'name' directive to name the nlm. If left blank -# TARGET_nlm (see below) will be used. -# -NLM_NAME =aputest -# -# This is used by the link '-desc ' directive. -# If left blank, NLM_NAME will be used. -# -NLM_DESCRIPTION = NLM is to test the apu layer - -# -# This is used by the '-threadname' directive. If left blank, -# NLM_NAME Thread will be used. -# -NLM_THREAD_NAME = aputest - -# -# This is used by the '-screenname' directive. If left blank, -# 'Apache for NetWare' Thread will be used. -# -NLM_SCREEN_NAME = aputest - -# -# If this is specified, it will override VERSION value in -# $(APR_WORK)\build\NWGNUenvironment.inc -# -NLM_VERSION = 1,0,0 - -# -# If this is specified, it will override the default of 64K -# -NLM_STACK_SIZE = 524288 - -# -# If this is specified it will be used by the link '-entry' directive -# -NLM_ENTRY_SYM = _LibCPrelude - -# -# If this is specified it will be used by the link '-exit' directive -# -NLM_EXIT_SYM = _LibCPostlude - -# -# If this is specified it will be used by the link '-check' directive -# -NLM_CHECK_SYM = - -# -# If this is specified it will be used by the link '-flags' directive -# -NLM_FLAGS = AUTOUNLOAD, PSEUDOPREEMPTION - -# -# If this is specified it will be linked in with the XDCData option in the def -# file instead of the default of $(APR)/misc/netware/apache.xdc. XDCData can -# be disabled by setting APACHE_UNIPROC in the environment -# -XDCDATA = - -# -# Declare all target files (you must add your files here) -# - -# -# If there is an NLM target, put it here -# -TARGET_nlm = \ - $(OBJDIR)/aputest.nlm \ - $(EOLIST) - -# -# If there is an LIB target, put it here -# -TARGET_lib = \ - $(EOLIST) - -# -# These are the OBJ files needed to create the NLM target above. -# Paths must all use the '/' character -# - -FILES_nlm_objs = \ - $(OBJDIR)/abts.o \ - $(OBJDIR)/teststrmatch.o \ - $(OBJDIR)/testuri.o \ - $(OBJDIR)/testuuid.o \ - $(OBJDIR)/testbuckets.o \ - $(OBJDIR)/testpass.o \ - $(OBJDIR)/testmd4.o \ - $(OBJDIR)/testmd5.o \ - $(OBJDIR)/testldap.o \ - $(OBJDIR)/testutil.o \ - $(OBJDIR)/nw_misc.o \ - $(EOLIST) - -# Pending tests - -# -# These are the LIB files needed to create the NLM target above. -# These will be added as a library command in the link.opt file. -# -FILES_nlm_libs = \ - libcpre.o \ - $(EOLIST) - -# -# These are the modules that the above NLM target depends on to load. -# These will be added as a module command in the link.opt file. -# -FILES_nlm_modules = \ - Libc \ - APRLIB \ - lldapsdk \ - lldapssl \ - lldapx \ - $(EOLIST) - -# -# If the nlm has a msg file, put it's path here -# -FILE_nlm_msg = - -# -# If the nlm has a hlp file put it's path here -# -FILE_nlm_hlp = - -# -# If this is specified, it will override the default copyright. -# -FILE_nlm_copyright = - -# -# Any additional imports go here -# -FILES_nlm_Ximports = \ - @libc.imp \ - @$(APR)/aprlib.imp \ - @$(LDAPSDK)/imports/lldapsdk.imp \ - @$(LDAPSDK)/imports/lldapssl.imp \ - $(EOLIST) - -# -# Any symbols exported to here -# -FILES_nlm_exports = \ - $(EOLIST) - -# -# These are the OBJ files needed to create the LIB target above. -# Paths must all use the '/' character -# -FILES_lib_objs = \ - $(EOLIST) - -# -# implement targets and dependancies (leave this section alone) -# - -libs :: $(OBJDIR) $(TARGET_lib) - -nlms :: libs $(TARGET_nlm) - -# -# Updated this target to create necessary directories and copy files to the -# correct place. (See $(APR_WORK)\build\NWGNUhead.inc for examples) -# -install :: nlms FORCE - -# -# Any specialized rules here -# - - -# -# Include the 'tail' makefile that has targets that depend on variables defined -# in this makefile -# - -include $(APR_WORK)\build\NWGNUtail.inc - diff --git a/libs/apr-util/test/test_apu.h b/libs/apr-util/test/test_apu.h deleted file mode 100644 index 8d5f6ddee2..0000000000 --- a/libs/apr-util/test/test_apu.h +++ /dev/null @@ -1,100 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* Some simple functions to make the test apps easier to write and - * a bit more consistent... - * this is a >copy< of apr_test.h - */ - -/* Things to bear in mind when using these... - * - * If you include '\t' within the string passed in it won't be included - * in the spacing, so use spaces instead :) - * - */ - -#ifndef APU_TEST_INCLUDES -#define APU_TEST_INCLUDES - -#include "apr_strings.h" -#include "apr_time.h" - -#define TEST_EQ(str, func, value, good, bad) \ - printf("%-60s", str); \ - { \ - apr_status_t rv; \ - if ((rv = func) == value){ \ - char errmsg[200]; \ - printf("%s\n", bad); \ - fprintf(stderr, "Error was %d : %s\n", rv, \ - apr_strerror(rv, (char*)&errmsg, 200)); \ - exit(-1); \ - } \ - printf("%s\n", good); \ - } - -#define TEST_NEQ(str, func, value, good, bad) \ - printf("%-60s", str); \ - { \ - apr_status_t rv; \ - if ((rv = func) != value){ \ - char errmsg[200]; \ - printf("%s\n", bad); \ - fprintf(stderr, "Error was %d : %s\n", rv, \ - apr_strerror(rv, (char*)&errmsg, 200)); \ - exit(-1); \ - } \ - printf("%s\n", good); \ - } - -#define TEST_STATUS(str, func, testmacro, good, bad) \ - printf("%-60s", str); \ - { \ - apr_status_t rv = func; \ - if (!testmacro(rv)) { \ - char errmsg[200]; \ - printf("%s\n", bad); \ - fprintf(stderr, "Error was %d : %s\n", rv, \ - apr_strerror(rv, (char*)&errmsg, 200)); \ - exit(-1); \ - } \ - printf("%s\n", good); \ - } - -#define STD_TEST_NEQ(str, func) \ - TEST_NEQ(str, func, APR_SUCCESS, "OK", "Failed"); - -#define PRINT_ERROR(rv) \ - { \ - char errmsg[200]; \ - fprintf(stderr, "Error was %d : %s\n", rv, \ - apr_strerror(rv, (char*)&errmsg, 200)); \ - exit(-1); \ - } - -#define MSG_AND_EXIT(msg) \ - printf("%s\n", msg); \ - exit (-1); - -#define TIME_FUNCTION(time, function) \ - { \ - apr_time_t tt = apr_time_now(); \ - function; \ - time = apr_time_now() - tt; \ - } - - -#endif /* APU_TEST_INCLUDES */ diff --git a/libs/apr-util/test/testbuckets.c b/libs/apr-util/test/testbuckets.c deleted file mode 100644 index 52b4840039..0000000000 --- a/libs/apr-util/test/testbuckets.c +++ /dev/null @@ -1,490 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "abts.h" -#include "testutil.h" -#include "apr_buckets.h" -#include "apr_strings.h" - -static void test_create(abts_case *tc, void *data) -{ - apr_bucket_alloc_t *ba; - apr_bucket_brigade *bb; - - ba = apr_bucket_alloc_create(p); - bb = apr_brigade_create(p, ba); - - ABTS_ASSERT(tc, "new brigade not NULL", bb != NULL); - ABTS_ASSERT(tc, "new brigade is empty", APR_BRIGADE_EMPTY(bb)); - - apr_brigade_destroy(bb); - apr_bucket_alloc_destroy(ba); -} - -static void test_simple(abts_case *tc, void *data) -{ - apr_bucket_alloc_t *ba; - apr_bucket_brigade *bb; - apr_bucket *fb, *tb; - - ba = apr_bucket_alloc_create(p); - bb = apr_brigade_create(p, ba); - - fb = APR_BRIGADE_FIRST(bb); - ABTS_ASSERT(tc, "first bucket of empty brigade is sentinel", - fb == APR_BRIGADE_SENTINEL(bb)); - - fb = apr_bucket_flush_create(ba); - APR_BRIGADE_INSERT_HEAD(bb, fb); - - ABTS_ASSERT(tc, "first bucket of brigade is flush", - APR_BRIGADE_FIRST(bb) == fb); - - ABTS_ASSERT(tc, "bucket after flush is sentinel", - APR_BUCKET_NEXT(fb) == APR_BRIGADE_SENTINEL(bb)); - - tb = apr_bucket_transient_create("aaa", 3, ba); - APR_BUCKET_INSERT_BEFORE(fb, tb); - - ABTS_ASSERT(tc, "bucket before flush now transient", - APR_BUCKET_PREV(fb) == tb); - ABTS_ASSERT(tc, "bucket after transient is flush", - APR_BUCKET_NEXT(tb) == fb); - ABTS_ASSERT(tc, "bucket before transient is sentinel", - APR_BUCKET_PREV(tb) == APR_BRIGADE_SENTINEL(bb)); - - apr_brigade_cleanup(bb); - - ABTS_ASSERT(tc, "cleaned up brigade was empty", APR_BRIGADE_EMPTY(bb)); - - apr_brigade_destroy(bb); - apr_bucket_alloc_destroy(ba); -} - -static apr_bucket_brigade *make_simple_brigade(apr_bucket_alloc_t *ba, - const char *first, - const char *second) -{ - apr_bucket_brigade *bb = apr_brigade_create(p, ba); - apr_bucket *e; - - e = apr_bucket_transient_create(first, strlen(first), ba); - APR_BRIGADE_INSERT_TAIL(bb, e); - - e = apr_bucket_transient_create(second, strlen(second), ba); - APR_BRIGADE_INSERT_TAIL(bb, e); - - return bb; -} - -/* tests that 'bb' flattens to string 'expect'. */ -static void flatten_match(abts_case *tc, const char *ctx, - apr_bucket_brigade *bb, - const char *expect) -{ - apr_size_t elen = strlen(expect); - char *buf = malloc(elen); - apr_size_t len = elen; - char msg[200]; - - sprintf(msg, "%s: flatten brigade", ctx); - apr_assert_success(tc, msg, apr_brigade_flatten(bb, buf, &len)); - sprintf(msg, "%s: length match (%ld not %ld)", ctx, - (long)len, (long)elen); - ABTS_ASSERT(tc, msg, len == elen); - sprintf(msg, "%s: result match", msg); - ABTS_STR_NEQUAL(tc, expect, buf, len); - free(buf); -} - -static void test_flatten(abts_case *tc, void *data) -{ - apr_bucket_alloc_t *ba = apr_bucket_alloc_create(p); - apr_bucket_brigade *bb; - - bb = make_simple_brigade(ba, "hello, ", "world"); - - flatten_match(tc, "flatten brigade", bb, "hello, world"); - - apr_brigade_destroy(bb); - apr_bucket_alloc_destroy(ba); -} - -static int count_buckets(apr_bucket_brigade *bb) -{ - apr_bucket *e; - int count = 0; - - for (e = APR_BRIGADE_FIRST(bb); - e != APR_BRIGADE_SENTINEL(bb); - e = APR_BUCKET_NEXT(e)) { - count++; - } - - return count; -} - -static void test_split(abts_case *tc, void *data) -{ - apr_bucket_alloc_t *ba = apr_bucket_alloc_create(p); - apr_bucket_brigade *bb, *bb2; - apr_bucket *e; - - bb = make_simple_brigade(ba, "hello, ", "world"); - - /* split at the "world" bucket */ - e = APR_BRIGADE_LAST(bb); - bb2 = apr_brigade_split(bb, e); - - ABTS_ASSERT(tc, "split brigade contains one bucket", - count_buckets(bb2) == 1); - ABTS_ASSERT(tc, "original brigade contains one bucket", - count_buckets(bb) == 1); - - flatten_match(tc, "match original brigade", bb, "hello, "); - flatten_match(tc, "match split brigade", bb2, "world"); - - apr_brigade_destroy(bb2); - apr_brigade_destroy(bb); - apr_bucket_alloc_destroy(ba); -} - -#define COUNT 3000 -#define THESTR "hello" - -static void test_bwrite(abts_case *tc, void *data) -{ - apr_bucket_alloc_t *ba = apr_bucket_alloc_create(p); - apr_bucket_brigade *bb = apr_brigade_create(p, ba); - apr_off_t length; - int n; - - for (n = 0; n < COUNT; n++) { - apr_assert_success(tc, "brigade_write", - apr_brigade_write(bb, NULL, NULL, - THESTR, sizeof THESTR)); - } - - apr_assert_success(tc, "determine brigade length", - apr_brigade_length(bb, 1, &length)); - - ABTS_ASSERT(tc, "brigade has correct length", - length == (COUNT * sizeof THESTR)); - - apr_brigade_destroy(bb); - apr_bucket_alloc_destroy(ba); -} - -static void test_splitline(abts_case *tc, void *data) -{ - apr_bucket_alloc_t *ba = apr_bucket_alloc_create(p); - apr_bucket_brigade *bin, *bout; - - bin = make_simple_brigade(ba, "blah blah blah-", - "end of line.\nfoo foo foo"); - bout = apr_brigade_create(p, ba); - - apr_assert_success(tc, "split line", - apr_brigade_split_line(bout, bin, - APR_BLOCK_READ, 100)); - - flatten_match(tc, "split line", bout, "blah blah blah-end of line.\n"); - flatten_match(tc, "remainder", bin, "foo foo foo"); - - apr_brigade_destroy(bout); - apr_brigade_destroy(bin); - apr_bucket_alloc_destroy(ba); -} - -/* Test that bucket E has content EDATA of length ELEN. */ -static void test_bucket_content(abts_case *tc, - apr_bucket *e, - const char *edata, - apr_size_t elen) -{ - const char *adata; - apr_size_t alen; - - apr_assert_success(tc, "read from bucket", - apr_bucket_read(e, &adata, &alen, - APR_BLOCK_READ)); - - ABTS_ASSERT(tc, "read expected length", alen == elen); - ABTS_STR_NEQUAL(tc, edata, adata, elen); -} - -static void test_splits(abts_case *tc, void *ctx) -{ - apr_bucket_alloc_t *ba = apr_bucket_alloc_create(p); - apr_bucket_brigade *bb; - apr_bucket *e; - char *str = "alphabeta"; - int n; - - bb = apr_brigade_create(p, ba); - - APR_BRIGADE_INSERT_TAIL(bb, - apr_bucket_immortal_create(str, 9, ba)); - APR_BRIGADE_INSERT_TAIL(bb, - apr_bucket_transient_create(str, 9, ba)); - APR_BRIGADE_INSERT_TAIL(bb, - apr_bucket_heap_create(strdup(str), 9, free, ba)); - APR_BRIGADE_INSERT_TAIL(bb, - apr_bucket_pool_create(apr_pstrdup(p, str), 9, p, - ba)); - - ABTS_ASSERT(tc, "four buckets inserted", count_buckets(bb) == 4); - - /* now split each of the buckets after byte 5 */ - for (n = 0, e = APR_BRIGADE_FIRST(bb); n < 4; n++) { - ABTS_ASSERT(tc, "reached end of brigade", - e != APR_BRIGADE_SENTINEL(bb)); - ABTS_ASSERT(tc, "split bucket OK", - apr_bucket_split(e, 5) == APR_SUCCESS); - e = APR_BUCKET_NEXT(e); - ABTS_ASSERT(tc, "split OK", e != APR_BRIGADE_SENTINEL(bb)); - e = APR_BUCKET_NEXT(e); - } - - ABTS_ASSERT(tc, "four buckets split into eight", - count_buckets(bb) == 8); - - for (n = 0, e = APR_BRIGADE_FIRST(bb); n < 4; n++) { - const char *data; - apr_size_t len; - - apr_assert_success(tc, "read alpha from bucket", - apr_bucket_read(e, &data, &len, APR_BLOCK_READ)); - ABTS_ASSERT(tc, "read 5 bytes", len == 5); - ABTS_STR_NEQUAL(tc, "alpha", data, 5); - - e = APR_BUCKET_NEXT(e); - - apr_assert_success(tc, "read beta from bucket", - apr_bucket_read(e, &data, &len, APR_BLOCK_READ)); - ABTS_ASSERT(tc, "read 4 bytes", len == 4); - ABTS_STR_NEQUAL(tc, "beta", data, 5); - - e = APR_BUCKET_NEXT(e); - } - - /* now delete the "alpha" buckets */ - for (n = 0, e = APR_BRIGADE_FIRST(bb); n < 4; n++) { - apr_bucket *f; - - ABTS_ASSERT(tc, "reached end of brigade", - e != APR_BRIGADE_SENTINEL(bb)); - f = APR_BUCKET_NEXT(e); - apr_bucket_delete(e); - e = APR_BUCKET_NEXT(f); - } - - ABTS_ASSERT(tc, "eight buckets reduced to four", - count_buckets(bb) == 4); - - flatten_match(tc, "flatten beta brigade", bb, - "beta" "beta" "beta" "beta"); - - apr_brigade_destroy(bb); - apr_bucket_alloc_destroy(ba); -} - -#define TIF_FNAME "testfile.txt" - -static void test_insertfile(abts_case *tc, void *ctx) -{ - apr_bucket_alloc_t *ba = apr_bucket_alloc_create(p); - apr_bucket_brigade *bb; - const apr_off_t bignum = (APR_INT64_C(2) << 32) + 424242; - apr_off_t count; - apr_file_t *f; - apr_bucket *e; - - ABTS_ASSERT(tc, "open test file", - apr_file_open(&f, TIF_FNAME, - APR_WRITE|APR_TRUNCATE|APR_CREATE, - APR_OS_DEFAULT, p) == APR_SUCCESS); - - if (apr_file_trunc(f, bignum)) { - apr_file_close(f); - apr_file_remove(TIF_FNAME, p); - ABTS_NOT_IMPL(tc, "Skipped: could not create large file"); - return; - } - - bb = apr_brigade_create(p, ba); - - e = apr_brigade_insert_file(bb, f, 0, bignum, p); - - ABTS_ASSERT(tc, "inserted file was not at end of brigade", - e == APR_BRIGADE_LAST(bb)); - - /* check that the total size of inserted buckets is equal to the - * total size of the file. */ - count = 0; - - for (e = APR_BRIGADE_FIRST(bb); - e != APR_BRIGADE_SENTINEL(bb); - e = APR_BUCKET_NEXT(e)) { - ABTS_ASSERT(tc, "bucket size sane", e->length != (apr_size_t)-1); - count += e->length; - } - - ABTS_ASSERT(tc, "total size of buckets incorrect", count == bignum); - - apr_brigade_destroy(bb); - - /* Truncate the file to zero size before close() so that we don't - * actually write out the large file if we are on a non-sparse file - * system - like Mac OS X's HFS. Otherwise, pity the poor user who - * has to wait for the 8GB file to be written to disk. - */ - apr_file_trunc(f, 0); - - apr_file_close(f); - apr_bucket_alloc_destroy(ba); - apr_file_remove(TIF_FNAME, p); -} - -/* Make a test file named FNAME, and write CONTENTS to it. */ -static apr_file_t *make_test_file(abts_case *tc, const char *fname, - const char *contents) -{ - apr_file_t *f; - - ABTS_ASSERT(tc, "create test file", - apr_file_open(&f, fname, - APR_READ|APR_WRITE|APR_TRUNCATE|APR_CREATE, - APR_OS_DEFAULT, p) == APR_SUCCESS); - - ABTS_ASSERT(tc, "write test file contents", - apr_file_puts(contents, f) == APR_SUCCESS); - - return f; -} - -static void test_manyfile(abts_case *tc, void *data) -{ - apr_bucket_alloc_t *ba = apr_bucket_alloc_create(p); - apr_bucket_brigade *bb = apr_brigade_create(p, ba); - apr_file_t *f; - - f = make_test_file(tc, "manyfile.bin", - "world" "hello" "brave" " ,\n"); - - apr_brigade_insert_file(bb, f, 5, 5, p); - apr_brigade_insert_file(bb, f, 16, 1, p); - apr_brigade_insert_file(bb, f, 15, 1, p); - apr_brigade_insert_file(bb, f, 10, 5, p); - apr_brigade_insert_file(bb, f, 15, 1, p); - apr_brigade_insert_file(bb, f, 0, 5, p); - apr_brigade_insert_file(bb, f, 17, 1, p); - - /* can you tell what it is yet? */ - flatten_match(tc, "file seek test", bb, - "hello, brave world\n"); - - apr_file_close(f); - apr_brigade_destroy(bb); - apr_bucket_alloc_destroy(ba); -} - -/* Regression test for PR 34708, where a file bucket will keep - * duplicating itself on being read() when EOF is reached - * prematurely. */ -static void test_truncfile(abts_case *tc, void *data) -{ - apr_bucket_alloc_t *ba = apr_bucket_alloc_create(p); - apr_bucket_brigade *bb = apr_brigade_create(p, ba); - apr_file_t *f = make_test_file(tc, "testfile.txt", "hello"); - apr_bucket *e; - const char *buf; - apr_size_t len; - - apr_brigade_insert_file(bb, f, 0, 5, p); - - apr_file_trunc(f, 0); - - e = APR_BRIGADE_FIRST(bb); - - ABTS_ASSERT(tc, "single bucket in brigade", - APR_BUCKET_NEXT(e) == APR_BRIGADE_SENTINEL(bb)); - - apr_bucket_file_enable_mmap(e, 0); - - ABTS_ASSERT(tc, "read gave APR_EOF", - apr_bucket_read(e, &buf, &len, APR_BLOCK_READ) == APR_EOF); - - ABTS_ASSERT(tc, "read length 0", len == 0); - - ABTS_ASSERT(tc, "still a single bucket in brigade", - APR_BUCKET_NEXT(e) == APR_BRIGADE_SENTINEL(bb)); - - apr_file_close(f); - apr_brigade_destroy(bb); - apr_bucket_alloc_destroy(ba); -} - -static const char hello[] = "hello, world"; - -static void test_partition(abts_case *tc, void *data) -{ - apr_bucket_alloc_t *ba = apr_bucket_alloc_create(p); - apr_bucket_brigade *bb = apr_brigade_create(p, ba); - apr_bucket *e; - - e = apr_bucket_immortal_create(hello, strlen(hello), ba); - APR_BRIGADE_INSERT_HEAD(bb, e); - - apr_assert_success(tc, "partition brigade", - apr_brigade_partition(bb, 5, &e)); - - test_bucket_content(tc, APR_BRIGADE_FIRST(bb), - "hello", 5); - - test_bucket_content(tc, APR_BRIGADE_LAST(bb), - ", world", 7); - - ABTS_ASSERT(tc, "partition returns APR_INCOMPLETE", - apr_brigade_partition(bb, 8192, &e)); - - ABTS_ASSERT(tc, "APR_INCOMPLETE partition returned sentinel", - e == APR_BRIGADE_SENTINEL(bb)); - - apr_brigade_destroy(bb); - apr_bucket_alloc_destroy(ba); -} - -abts_suite *testbuckets(abts_suite *suite) -{ - suite = ADD_SUITE(suite); - - abts_run_test(suite, test_create, NULL); - abts_run_test(suite, test_simple, NULL); - abts_run_test(suite, test_flatten, NULL); - abts_run_test(suite, test_split, NULL); - abts_run_test(suite, test_bwrite, NULL); - abts_run_test(suite, test_splitline, NULL); - abts_run_test(suite, test_splits, NULL); - abts_run_test(suite, test_insertfile, NULL); - abts_run_test(suite, test_manyfile, NULL); - abts_run_test(suite, test_truncfile, NULL); - abts_run_test(suite, test_partition, NULL); - - return suite; -} - - diff --git a/libs/apr-util/test/testdate.c b/libs/apr-util/test/testdate.c deleted file mode 100644 index b13bc4d1f4..0000000000 --- a/libs/apr-util/test/testdate.c +++ /dev/null @@ -1,198 +0,0 @@ -/* This program tests the date_parse_http routine in ../main/util_date.c. - * - * It is only semiautomated in that I would run it, modify the code to - * use a different algorithm or seed, recompile and run again, etc. - * Obviously it should use an argument for that, but I never got around - * to changing the implementation. - * - * gcc -g -O2 -I../main -o test_date ../main/util_date.o test_date.c - * test_date | egrep '^No ' - * - * Roy Fielding, 1996 - */ - -#include -#include -#include -#include "apr_date.h" - -#ifndef srand48 -#define srand48 srandom -#endif - -#ifndef mrand48 -#define mrand48 random -#endif - -void gm_timestr_822(char *ts, apr_time_t sec); -void gm_timestr_850(char *ts, apr_time_t sec); -void gm_timestr_ccc(char *ts, apr_time_t sec); - -static const apr_time_t year2secs[] = { - 0LL, /* 1970 */ - 31536000LL, /* 1971 */ - 63072000LL, /* 1972 */ - 94694400LL, /* 1973 */ - 126230400LL, /* 1974 */ - 157766400LL, /* 1975 */ - 189302400LL, /* 1976 */ - 220924800LL, /* 1977 */ - 252460800LL, /* 1978 */ - 283996800LL, /* 1979 */ - 315532800LL, /* 1980 */ - 347155200LL, /* 1981 */ - 378691200LL, /* 1982 */ - 410227200LL, /* 1983 */ - 441763200LL, /* 1984 */ - 473385600LL, /* 1985 */ - 504921600LL, /* 1986 */ - 536457600LL, /* 1987 */ - 567993600LL, /* 1988 */ - 599616000LL, /* 1989 */ - 631152000LL, /* 1990 */ - 662688000LL, /* 1991 */ - 694224000LL, /* 1992 */ - 725846400LL, /* 1993 */ - 757382400LL, /* 1994 */ - 788918400LL, /* 1995 */ - 820454400LL, /* 1996 */ - 852076800LL, /* 1997 */ - 883612800LL, /* 1998 */ - 915148800LL, /* 1999 */ - 946684800LL, /* 2000 */ - 978307200LL, /* 2001 */ - 1009843200LL, /* 2002 */ - 1041379200LL, /* 2003 */ - 1072915200LL, /* 2004 */ - 1104537600LL, /* 2005 */ - 1136073600LL, /* 2006 */ - 1167609600LL, /* 2007 */ - 1199145600LL, /* 2008 */ - 1230768000LL, /* 2009 */ - 1262304000LL, /* 2010 */ - 1293840000LL, /* 2011 */ - 1325376000LL, /* 2012 */ - 1356998400LL, /* 2013 */ - 1388534400LL, /* 2014 */ - 1420070400LL, /* 2015 */ - 1451606400LL, /* 2016 */ - 1483228800LL, /* 2017 */ - 1514764800LL, /* 2018 */ - 1546300800LL, /* 2019 */ - 1577836800LL, /* 2020 */ - 1609459200LL, /* 2021 */ - 1640995200LL, /* 2022 */ - 1672531200LL, /* 2023 */ - 1704067200LL, /* 2024 */ - 1735689600LL, /* 2025 */ - 1767225600LL, /* 2026 */ - 1798761600LL, /* 2027 */ - 1830297600LL, /* 2028 */ - 1861920000LL, /* 2029 */ - 1893456000LL, /* 2030 */ - 1924992000LL, /* 2031 */ - 1956528000LL, /* 2032 */ - 1988150400LL, /* 2033 */ - 2019686400LL, /* 2034 */ - 2051222400LL, /* 2035 */ - 2082758400LL, /* 2036 */ - 2114380800LL, /* 2037 */ - 2145916800LL /* 2038 */ -}; - -const char month_snames[12][4] = { - "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec" -}; - -void gm_timestr_822(char *ts, apr_time_t sec) -{ - static const char *const days[7]= - {"Sun","Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; - struct tm *tms; - time_t ls = (time_t)sec; - - tms = gmtime(&ls); - - sprintf(ts, "%s, %.2d %s %d %.2d:%.2d:%.2d GMT", days[tms->tm_wday], - tms->tm_mday, month_snames[tms->tm_mon], tms->tm_year + 1900, - tms->tm_hour, tms->tm_min, tms->tm_sec); -} - -void gm_timestr_850(char *ts, apr_time_t sec) -{ - static const char *const days[7]= - {"Sunday","Monday", "Tuesday", "Wednesday", "Thursday", "Friday", - "Saturday"}; - struct tm *tms; - int year; - time_t ls = (time_t)sec; - - tms = gmtime(&ls); - - year = tms->tm_year; - if (year >= 100) year -= 100; - - sprintf(ts, "%s, %.2d-%s-%.2d %.2d:%.2d:%.2d GMT", days[tms->tm_wday], - tms->tm_mday, month_snames[tms->tm_mon], year, - tms->tm_hour, tms->tm_min, tms->tm_sec); -} - -void gm_timestr_ccc(char *ts, apr_time_t sec) -{ - static const char *const days[7]= - {"Sun","Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; - struct tm *tms; - time_t ls = (time_t)sec; - - tms = gmtime(&ls); - - sprintf(ts, "%s %s %2d %.2d:%.2d:%.2d %d", days[tms->tm_wday], - month_snames[tms->tm_mon], tms->tm_mday, - tms->tm_hour, tms->tm_min, tms->tm_sec, tms->tm_year + 1900); -} - -int main (void) -{ - int year, i; - apr_time_t guess; - apr_time_t offset = 0; - /* apr_time_t offset = 0; */ - /* apr_time_t offset = ((31 + 28) * 24 * 3600) - 1; */ - apr_time_t secstodate, newsecs; - char datestr[50]; - - for (year = 1970; year < 2038; ++year) { - secstodate = year2secs[year - 1970] + offset; - gm_timestr_822(datestr, secstodate); - secstodate *= APR_USEC_PER_SEC; - newsecs = apr_date_parse_http(datestr); - if (secstodate == newsecs) - printf("Yes %4d %19" APR_TIME_T_FMT " %s\n", year, secstodate, datestr); - else if (newsecs == APR_DATE_BAD) - printf("No %4d %19" APR_TIME_T_FMT " %19" APR_TIME_T_FMT " %s\n", - year, secstodate, newsecs, datestr); - else - printf("No* %4d %19" APR_TIME_T_FMT " %19" APR_TIME_T_FMT " %s\n", - year, secstodate, newsecs, datestr); - } - - srand48(978245L); - - for (i = 0; i < 10000; ++i) { - guess = (time_t)mrand48(); - if (guess < 0) guess *= -1; - secstodate = guess + offset; - gm_timestr_822(datestr, secstodate); - secstodate *= APR_USEC_PER_SEC; - newsecs = apr_date_parse_http(datestr); - if (secstodate == newsecs) - printf("Yes %" APR_TIME_T_FMT " %s\n", secstodate, datestr); - else if (newsecs == APR_DATE_BAD) - printf("No %" APR_TIME_T_FMT " %" APR_TIME_T_FMT " %s\n", - secstodate, newsecs, datestr); - else - printf("No* %" APR_TIME_T_FMT " %" APR_TIME_T_FMT " %s\n", - secstodate, newsecs, datestr); - } - exit(0); -} diff --git a/libs/apr-util/test/testdbd.c b/libs/apr-util/test/testdbd.c deleted file mode 100644 index 9f2dcbc8a5..0000000000 --- a/libs/apr-util/test/testdbd.c +++ /dev/null @@ -1,233 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "testutil.h" -#include "apr.h" -#include "apu.h" -#include "apr_pools.h" -#include "apr_dbd.h" -#include "apr_strings.h" - -static void test_dbd_init(abts_case *tc, void *data) -{ - apr_pool_t *pool = p; - apr_status_t rv; - - rv = apr_dbd_init(pool); - ABTS_ASSERT(tc, "failed to init apr_dbd", rv == APR_SUCCESS); -} - -#if APU_HAVE_SQLITE2 || APU_HAVE_SQLITE3 -static void test_statement(abts_case *tc, apr_dbd_t* handle, - const apr_dbd_driver_t* driver, const char* sql) -{ - int nrows; - apr_status_t rv; - - rv = apr_dbd_query(driver, handle, &nrows, sql); - - ABTS_ASSERT(tc, sql, rv == APR_SUCCESS); -} - -static void create_table(abts_case *tc, apr_dbd_t* handle, - const apr_dbd_driver_t* driver) -{ - const char *sql = "CREATE TABLE apr_dbd_test (" - "col1 varchar(40) not null," - "col2 varchar(40)," - "col3 integer)"; - - test_statement(tc, handle, driver, sql); -} - -static void drop_table(abts_case *tc, apr_dbd_t* handle, - const apr_dbd_driver_t* driver) -{ - const char *sql = "DROP TABLE apr_dbd_test"; - test_statement(tc, handle, driver, sql); -} - -static void delete_rows(abts_case *tc, apr_dbd_t* handle, - const apr_dbd_driver_t* driver) -{ - const char *sql = "DELETE FROM apr_dbd_test"; - test_statement(tc, handle, driver, sql); -} - - -static void insert_data(abts_case *tc, apr_dbd_t* handle, - const apr_dbd_driver_t* driver, int count) -{ - apr_pool_t* pool = p; - const char* sql = "INSERT INTO apr_dbd_test VALUES('%d', '%d', %d)"; - char* sqf = NULL; - int i; - int nrows; - apr_status_t rv; - - for (i=0; i 0) { - row = NULL; - rv = apr_dbd_get_row(driver, pool, res, &row, -1); - ABTS_ASSERT(tc, sql, rv == APR_SUCCESS); - ABTS_PTR_NOTNULL(tc, row); - apr_pool_clear(tpool); - i--; - } - ABTS_ASSERT(tc, "Missing Rows!", i == 0); - - res = NULL; - i = count; - - rv = apr_dbd_select(driver, pool, handle, &res, sql, 1); - ABTS_ASSERT(tc, sql, rv == APR_SUCCESS); - ABTS_PTR_NOTNULL(tc, res); - - rv = apr_dbd_num_tuples(driver, res); - ABTS_ASSERT(tc, "invalid row count", rv == count); - - while (i > 0) { - row = NULL; - rv = apr_dbd_get_row(driver, pool, res, &row, i); - ABTS_ASSERT(tc, sql, rv == APR_SUCCESS); - ABTS_PTR_NOTNULL(tc, row); - apr_pool_clear(tpool); - i--; - } - ABTS_ASSERT(tc, "Missing Rows!", i == 0); - rv = apr_dbd_get_row(driver, pool, res, &row, count+100); - ABTS_ASSERT(tc, "If we overseek, get_row should return -1", rv == -1); -} - -static void test_escape(abts_case *tc, apr_dbd_t *handle, - const apr_dbd_driver_t *driver) -{ - const char *escaped = apr_dbd_escape(driver, p, "foo'bar", handle); - - ABTS_STR_EQUAL(tc, "foo''bar", escaped); -} - -static void test_dbd_generic(abts_case *tc, apr_dbd_t* handle, - const apr_dbd_driver_t* driver) -{ - void* native; - apr_pool_t *pool = p; - apr_status_t rv; - - native = apr_dbd_native_handle(driver, handle); - ABTS_PTR_NOTNULL(tc, native); - - rv = apr_dbd_check_conn(driver, pool, handle); - - create_table(tc, handle, driver); - select_rows(tc, handle, driver, 0); - insert_data(tc, handle, driver, 5); - select_rows(tc, handle, driver, 5); - delete_rows(tc, handle, driver); - select_rows(tc, handle, driver, 0); - drop_table(tc, handle, driver); - - test_escape(tc, handle, driver); - - rv = apr_dbd_close(driver, handle); - ABTS_ASSERT(tc, "failed to close database", rv == APR_SUCCESS); -} -#endif - -#if APU_HAVE_SQLITE2 -static void test_dbd_sqlite2(abts_case *tc, void *data) -{ - apr_pool_t *pool = p; - apr_status_t rv; - const apr_dbd_driver_t* driver = NULL; - apr_dbd_t* handle = NULL; - - rv = apr_dbd_get_driver(pool, "sqlite2", &driver); - ABTS_ASSERT(tc, "failed to fetch driver", rv == APR_SUCCESS); - ABTS_PTR_NOTNULL(tc, driver); - - ABTS_STR_EQUAL(tc, apr_dbd_name(driver), "sqlite2"); - - rv = apr_dbd_open(driver, pool, "data/sqlite2.db:600", &handle); - ABTS_ASSERT(tc, "failed to open database", rv == APR_SUCCESS); - ABTS_PTR_NOTNULL(tc, handle); - - test_dbd_generic(tc, handle, driver); -} -#endif - -#if APU_HAVE_SQLITE3 -static void test_dbd_sqlite3(abts_case *tc, void *data) -{ - apr_pool_t *pool = p; - apr_status_t rv; - const apr_dbd_driver_t* driver = NULL; - apr_dbd_t* handle = NULL; - - rv = apr_dbd_get_driver(pool, "sqlite3", &driver); - ABTS_ASSERT(tc, "failed to fetch driver", rv == APR_SUCCESS); - ABTS_PTR_NOTNULL(tc, driver); - - ABTS_STR_EQUAL(tc, apr_dbd_name(driver), "sqlite3"); - - rv = apr_dbd_open(driver, pool, "data/sqlite3.db", &handle); - ABTS_ASSERT(tc, "failed to open database", rv == APR_SUCCESS); - ABTS_PTR_NOTNULL(tc, handle); - - test_dbd_generic(tc, handle, driver); -} -#endif - -abts_suite *testdbd(abts_suite *suite) -{ - suite = ADD_SUITE(suite); - - - abts_run_test(suite, test_dbd_init, NULL); - -#if APU_HAVE_SQLITE2 - abts_run_test(suite, test_dbd_sqlite2, NULL); -#endif - -#if APU_HAVE_SQLITE3 - abts_run_test(suite, test_dbd_sqlite3, NULL); -#endif - return suite; -} diff --git a/libs/apr-util/test/testdbm.c b/libs/apr-util/test/testdbm.c deleted file mode 100644 index da787125f0..0000000000 --- a/libs/apr-util/test/testdbm.c +++ /dev/null @@ -1,425 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* This file came from the SDBM package (written by oz@nexus.yorku.ca). - * That package was under public domain. This file has been ported to - * APR, updated to ANSI C and other, newer idioms, and added to the Apache - * codebase under the above copyright and license. - */ - -/* - * testdbm: Simple APR dbm tester. - * Automatic test case: ./testdbm auto foo - * - Attempts to store and fetch values from the DBM. - * - * Run the program for more help. - */ - -#include "apr.h" -#include "apr_general.h" -#include "apr_pools.h" -#include "apr_errno.h" -#include "apr_getopt.h" -#include "apr_time.h" -#define APR_WANT_STRFUNC -#include "apr_want.h" - -#if APR_HAVE_STDIO_H -#include -#endif -#if APR_HAVE_UNISTD_H -#include -#endif -#include /* for atexit(), malloc() */ -#include - -#include "apr_dbm.h" - -static const char *progname; -static int rflag; - -#define DERROR 0 -#define DLOOK 1 - -#define DDELETE 3 -#define DCAT 4 -#define DBUILD 5 -#define DPRESS 6 -#define DCREAT 7 -#define DNAME 8 -#define DTRUNC 9 -#define DAUTO 10 - -#define LINEMAX 8192 - -typedef struct { - const char *sname; - int scode; - int flags; -} cmd; - -static const cmd cmds[] = { - - { "fetch", DLOOK, APR_DBM_READONLY }, - { "get", DLOOK, APR_DBM_READONLY }, - { "look", DLOOK, APR_DBM_READONLY }, - { "add", DBUILD, APR_DBM_READWRITE }, - { "insert", DBUILD, APR_DBM_READWRITE }, - { "store", DBUILD, APR_DBM_READWRITE }, - { "delete", DDELETE, APR_DBM_READWRITE }, - { "remove", DDELETE, APR_DBM_READWRITE }, - { "dump", DCAT, APR_DBM_READONLY }, - { "list", DCAT, APR_DBM_READONLY }, - { "cat", DCAT, APR_DBM_READONLY }, - { "build", DBUILD, APR_DBM_RWCREATE }, /** this one creates the DB */ - { "creat", DCREAT, APR_DBM_RWCREATE }, - { "trunc", DTRUNC, APR_DBM_RWTRUNC }, - { "new", DCREAT, APR_DBM_RWCREATE }, - { "names", DNAME, APR_DBM_READONLY }, -#if 0 - {"squash", DPRESS, APR_DBM_READWRITE, }, - {"compact", DPRESS, APR_DBM_READWRITE, }, - {"compress", DPRESS, APR_DBM_READWRITE, }, -#endif - { "auto", DAUTO, APR_DBM_RWCREATE }, -}; - -#define CMD_SIZE (sizeof(cmds)/sizeof(cmd)) - -static void doit(const cmd *act, const char*type, const char *file, apr_pool_t *pool); -static const cmd *parse_command(const char *str); -static void prdatum(FILE *stream, apr_datum_t d); -static void oops(apr_dbm_t *dbm, apr_status_t rv, const char *s1, - const char *s2); -static void show_usage(void); - -int main(int argc, const char * const * argv) -{ - apr_pool_t *pool; - const cmd *act; - apr_getopt_t *os; - char optch; - const char *optarg; - const char*dbtype; - - (void) apr_initialize(); - apr_pool_create(&pool, NULL); - atexit(apr_terminate); - - (void) apr_getopt_init(&os, pool, argc, argv); - - progname = argv[0]; - dbtype = "default"; - - while (apr_getopt(os, "Rt:", &optch, &optarg) == APR_SUCCESS) { - switch (optch) { - case 'R': /* raw processing */ - rflag++; - break; - case 't': - dbtype = optarg; - break; - default: - show_usage(); - fputs("unknown option.",stderr); - exit(-1); - break; - } - } - - if (argc <= os->ind) { - show_usage(); - fputs("Note: If you have no clue what this program is, start with:\n", stderr); - fputs(" ./testdbm auto foo\n", stderr); - fputs(" where foo is the DBM prefix.\n", stderr); - exit(-2); - } - - if ((act = parse_command(argv[os->ind])) == NULL) { - show_usage(); - fprintf(stderr, "unrecognized command: %s\n", argv[os->ind]); - exit(-3); - } - - if (++os->ind >= argc) { - show_usage(); - fputs("please supply a DB file to use (may be created)\n", stderr); - exit(-4); - } - - doit(act, dbtype, argv[os->ind], pool); - - apr_pool_destroy(pool); - - return 0; -} - -static void doit(const cmd *act, const char*type, const char *file, - apr_pool_t *pool) -{ - apr_status_t rv; - apr_datum_t key; - apr_datum_t val; - apr_dbm_t *db; - char *op; - int n; - char *line; - const char *use1; - const char *use2; -#ifdef TIME - long start; - extern long time(); -#endif - - rv = apr_dbm_open_ex(&db, type, file, act->flags, APR_OS_DEFAULT, pool); - if (rv != APR_SUCCESS) - oops(db, rv, "cannot open: %s", file); - - line = (char *) apr_palloc(pool,LINEMAX); - - switch (act->scode) { - - case DLOOK: - while (fgets(line, LINEMAX, stdin) != NULL) { - n = strlen(line) - 1; - line[n] = 0; - if (n == 0) - break; - - key.dptr = line; - key.dsize = n; - rv = apr_dbm_fetch(db, key, &val); - if (rv == APR_SUCCESS) { - prdatum(stdout, val); - putchar('\n'); - continue; - } - prdatum(stderr, key); - fprintf(stderr, ": not found.\n"); - } - break; - - case DDELETE: - while (fgets(line, LINEMAX, stdin) != NULL) { - n = strlen(line) - 1; - line[n] = 0; - if (n == 0) - break; - - key.dptr = line; - key.dsize = n; - if (apr_dbm_delete(db, key) != APR_SUCCESS) { - prdatum(stderr, key); - fprintf(stderr, ": not found.\n"); - } - } - break; - case DCAT: - rv = apr_dbm_firstkey(db, &key); - if (rv != APR_SUCCESS) - oops(db, rv, "could not fetch first key: %s", file); - - while (key.dptr != NULL) { - prdatum(stdout, key); - putchar('\t'); - rv = apr_dbm_fetch(db, key, &val); - if (rv != APR_SUCCESS) - oops(db, rv, "apr_dbm_fetch", "failure"); - prdatum(stdout, val); - putchar('\n'); - rv = apr_dbm_nextkey(db, &key); - if (rv != APR_SUCCESS) - oops(db, rv, "NextKey", "failure"); - } - break; - case DBUILD: -#ifdef TIME - start = time(0); -#endif - while (fgets(line, LINEMAX, stdin) != NULL) { - n = strlen(line) - 1; - line[n] = 0; - if (n == 0) - break; - - key.dptr = line; - if ((op = strchr(line, '\t')) != 0) { - key.dsize = op - line; - *op++ = 0; - val.dptr = op; - val.dsize = line + n - op; - } - else - oops(NULL, APR_EGENERAL, "bad input: %s", line); - - rv = apr_dbm_store(db, key, val); - if (rv != APR_SUCCESS) { - prdatum(stderr, key); - fprintf(stderr, ": "); - oops(db, rv, "store: %s", "failed"); - } - } -#ifdef TIME - printf("done: %d seconds.\n", time(0) - start); -#endif - break; - case DPRESS: - break; - case DCREAT: - break; - case DTRUNC: - break; - case DNAME: - apr_dbm_get_usednames(pool, file, &use1, &use2); - fprintf(stderr, "%s %s\n", use1, use2); - break; - case DAUTO: - { - int i; - char *valdata = "0123456789"; - fprintf(stderr, "Generating data: "); - for (i = 0; i < 10; i++) { - int j; - char c, keydata[10]; - for (j = 0, c = 'A' + (i % 16); j < 10; j++, c++) { - keydata[j] = c; - } - key.dptr = keydata; - key.dsize = 10; - val.dptr = valdata; - val.dsize = 10; - rv = apr_dbm_store(db, key, val); - if (rv != APR_SUCCESS) { - prdatum(stderr, key); - fprintf(stderr, ": "); - oops(db, rv, "store: %s", "failed"); - } - } - fputs("OK\n", stderr); - fputs("Testing existence/retrieval: ", stderr); - for (i = 0; i < 10; i++) { - int j; - char c, keydata[10]; - for (j = 0, c = 'A' + (i % 16); j < 10; j++, c++) { - keydata[j] = c; - } - key.dptr = keydata; - key.dsize = 10; - if (!apr_dbm_exists(db, key)) { - prdatum(stderr, key); - oops(db, 0, "exists: %s", "failed"); - } - rv = apr_dbm_fetch(db, key, &val); - if (rv != APR_SUCCESS || val.dsize != 10 || - (strncmp(val.dptr, valdata, 10) != 0) ) { - prdatum(stderr, key); - fprintf(stderr, ": "); - oops(db, rv, "fetch: %s", "failed"); - } - } - fputs("OK\n", stderr); - } - break; - } - - apr_dbm_close(db); -} - -static const cmd *parse_command(const char *str) -{ - int i; - - for (i = 0; i < CMD_SIZE; i++) - if (strcasecmp(cmds[i].sname, str) == 0) - return &cmds[i]; - - return NULL; -} - -static void prdatum(FILE *stream, apr_datum_t d) -{ - int c; - const char *p = d.dptr; - int n = d.dsize; - - while (n--) { - c = *p++ & 0377; - if (c & 0200) { - fprintf(stream, "M-"); - c &= 0177; - } - if (c == 0177 || c < ' ') - fprintf(stream, "^%c", (c == 0177) ? '?' : c + '@'); - else - putc(c, stream); - } -} - -static void oops(apr_dbm_t * dbm, apr_status_t rv, const char *s1, - const char *s2) -{ - char errbuf[200]; - - if (progname) { - fprintf(stderr, "%s: ", progname); - } - fprintf(stderr, s1, s2); - fprintf(stderr, "\n"); - - if (rv != APR_SUCCESS) { - apr_strerror(rv, errbuf, sizeof(errbuf)); - fprintf(stderr, "APR Error %d - %s\n", rv, errbuf); - - if (dbm) { - apr_dbm_geterror(dbm, &rv, errbuf, sizeof(errbuf)); - fprintf(stderr, "APR_DB Error %d - %s\n", rv, errbuf); - } - } - exit(1); -} - -static void show_usage(void) -{ - int i; - - if (!progname) { - progname = "testdbm"; - } - - fprintf(stderr, "%s [-t DBM-type] [-R] [commands] dbm-file-path\n", - progname); - - fputs("Available DBM-types:", stderr); -#if APU_HAVE_GDBM - fputs(" GDBM", stderr); -#endif -#if APU_HAVE_NDBM - fputs(" NDBM", stderr); -#endif -#if APU_HAVE_SDBM - fputs(" SDBM", stderr); -#endif -#if APU_HAVE_DB - fputs(" DB", stderr); -#endif - fputs(" default\n", stderr); - - fputs("Available commands:\n", stderr); - for (i = 0; i < CMD_SIZE; i++) { - fprintf(stderr, "%-8s%c", cmds[i].sname, - ((i + 1) % 6 == 0) ? '\n' : ' '); - } - fputs("\n", stderr); -} diff --git a/libs/apr-util/test/testldap.c b/libs/apr-util/test/testldap.c deleted file mode 100644 index b0a6369242..0000000000 --- a/libs/apr-util/test/testldap.c +++ /dev/null @@ -1,250 +0,0 @@ -/* Copyright 2002-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - /* Setup: - * - Create or edit the file data/host.data and add an - * ldap server DN. Multiple DNs may be listed on - * a single line. - * - Copy the server certificates to the data/ directory. - * All DER type certificates must have the .der extention. - * All BASE64 or PEM certificates must have the .b64 - * extension. All certificate files copied to the /data - * directory will be added to the ldap certificate store. - */ - - /* This test covers the following three types of connections: - * - Unsecure ldap:// - * - Secure ldaps:// - * - Secure ldap://+Start_TLS - * - * - (TBD) Mutual authentication - * - * There are other variations that should be tested: - * - All of the above with multiple redundant LDAP servers - * This can be done by listing more than one server DN - * in the host.data file. The DNs should all be listed - * on one line separated by a space. - * - All of the above with multiple certificates - * If more than one certificate is found in the data/ - * directory, each certificate found will be added - * to the certificate store. - * - All of the above on alternate ports - * An alternate port can be specified as part of the - * host in the host.data file. The ":port" should - * follow each DN listed. Default is 389 and 636. - * - Secure connections with mutual authentication - */ - -#include "testutil.h" - -#include "apr.h" -#include "apr_general.h" -#include "apr_ldap.h" -#include "apr_file_io.h" -#include "apr_file_info.h" -#include "apr_strings.h" -#if APR_HAVE_STDLIB_H -#include -#endif -#define APR_WANT_STDIO -#define APR_WANT_STRFUNC -#include "apr_want.h" - -#define DIRNAME "data" -#define FILENAME DIRNAME "/host.data" -#define CERTFILEDER DIRNAME "/*.der" -#define CERTFILEB64 DIRNAME "/*.b64" - -#if APR_HAS_LDAP - -static char ldap_host[256]; - -static int get_ldap_host(void) -{ - apr_status_t rv; - apr_file_t *thefile = NULL; - char *ptr; - - ldap_host[0] = '\0'; - rv = apr_file_open(&thefile, FILENAME, - APR_READ, - APR_UREAD | APR_UWRITE | APR_GREAD, p); - if (rv != APR_SUCCESS) { - return 0; - } - - rv = apr_file_gets(ldap_host, sizeof(ldap_host), thefile); - if (rv != APR_SUCCESS) { - return 0; - } - - ptr = strstr (ldap_host, "\r\n"); - if (ptr) { - *ptr = '\0'; - } - apr_file_close(thefile); - - return 1; - -} - -static int add_ldap_certs(abts_case *tc) -{ - apr_status_t status; - apr_dir_t *thedir; - apr_finfo_t dirent; - apr_ldap_err_t *result = NULL; - - if ((status = apr_dir_open(&thedir, DIRNAME, p)) == APR_SUCCESS) { - apr_ldap_opt_tls_cert_t *cert = (apr_ldap_opt_tls_cert_t *)apr_pcalloc(p, sizeof(apr_ldap_opt_tls_cert_t)); - - do { - status = apr_dir_read(&dirent, APR_FINFO_MIN | APR_FINFO_NAME, thedir); - if (APR_STATUS_IS_INCOMPLETE(status)) { - continue; /* ignore un-stat()able files */ - } - else if (status != APR_SUCCESS) { - break; - } - - if (strstr(dirent.name, ".der")) { - cert->type = APR_LDAP_CA_TYPE_DER; - cert->path = apr_pstrcat (p, DIRNAME, "/", dirent.name, NULL); - apr_ldap_set_option(p, NULL, APR_LDAP_OPT_TLS_CERT, (void *)cert, &result); - ABTS_TRUE(tc, result->rc == LDAP_SUCCESS); - } - if (strstr(dirent.name, ".b64")) { - cert->type = APR_LDAP_CA_TYPE_BASE64; - cert->path = apr_pstrcat (p, DIRNAME, "/", dirent.name, NULL); - apr_ldap_set_option(p, NULL, APR_LDAP_OPT_TLS_CERT, (void *)cert, &result); - ABTS_TRUE(tc, result->rc == LDAP_SUCCESS); - } - - } while (1); - - apr_dir_close(thedir); - } - return 0; -} - -static void test_ldap_connection(abts_case *tc, LDAP *ldap) -{ - int version = LDAP_VERSION3; - int failures, result; - - /* always default to LDAP V3 */ - ldap_set_option(ldap, LDAP_OPT_PROTOCOL_VERSION, &version); - - for (failures=0; failures<10; failures++) - { - result = ldap_simple_bind_s(ldap, - (char *)NULL, - (char *)NULL); - if (LDAP_SERVER_DOWN != result) - break; - } - - ABTS_TRUE(tc, result == LDAP_SUCCESS); - if (result != LDAP_SUCCESS) { - abts_log_message("%s\n", ldap_err2string(result)); - } - - ldap_unbind_s(ldap); - - return; -} - -static void test_ldap(abts_case *tc, void *data) -{ - apr_pool_t *pool = p; - LDAP *ldap; - apr_ldap_err_t *result = NULL; - - - ABTS_ASSERT(tc, "failed to get host", ldap_host[0] != '\0'); - - apr_ldap_init(pool, &ldap, - ldap_host, LDAP_PORT, - APR_LDAP_NONE, &(result)); - - ABTS_TRUE(tc, ldap != NULL); - ABTS_PTR_NOTNULL(tc, result); - - if (result->rc == LDAP_SUCCESS) { - test_ldap_connection(tc, ldap); - } -} - -static void test_ldaps(abts_case *tc, void *data) -{ - apr_pool_t *pool = p; - LDAP *ldap; - apr_ldap_err_t *result = NULL; - - apr_ldap_init(pool, &ldap, - ldap_host, LDAPS_PORT, - APR_LDAP_SSL, &(result)); - - ABTS_TRUE(tc, ldap != NULL); - ABTS_PTR_NOTNULL(tc, result); - - if (result->rc == LDAP_SUCCESS) { - add_ldap_certs(tc); - - test_ldap_connection(tc, ldap); - } -} - -static void test_ldap_tls(abts_case *tc, void *data) -{ - apr_pool_t *pool = p; - LDAP *ldap; - apr_ldap_err_t *result = NULL; - - apr_ldap_init(pool, &ldap, - ldap_host, LDAP_PORT, - APR_LDAP_STARTTLS, &(result)); - - ABTS_TRUE(tc, ldap != NULL); - ABTS_PTR_NOTNULL(tc, result); - - if (result->rc == LDAP_SUCCESS) { - add_ldap_certs(tc); - - test_ldap_connection(tc, ldap); - } -} - -#endif /* APR_HAS_LDAP */ - -abts_suite *testldap(abts_suite *suite) -{ -#if APR_HAS_LDAP - apr_ldap_err_t *result = NULL; - suite = ADD_SUITE(suite); - - apr_ldap_ssl_init(p, NULL, 0, &result); - - if (get_ldap_host()) { - abts_run_test(suite, test_ldap, NULL); - abts_run_test(suite, test_ldaps, NULL); - abts_run_test(suite, test_ldap_tls, NULL); - } -#endif /* APR_HAS_LDAP */ - - return suite; -} - diff --git a/libs/apr-util/test/testmd4.c b/libs/apr-util/test/testmd4.c deleted file mode 100644 index 494529d3cf..0000000000 --- a/libs/apr-util/test/testmd4.c +++ /dev/null @@ -1,119 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* This is derived from material copyright RSA Data Security, Inc. - * Their notice is reproduced below in its entirety. - * - * Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All - * rights reserved. - * - * RSA Data Security, Inc. makes no representations concerning either - * the merchantability of this software or the suitability of this - * software for any particular purpose. It is provided "as is" - * without express or implied warranty of any kind. - * - * These notices must be retained in any copies of any part of this - * documentation and/or software. - */ - -#include -#include -#include - -#include "apr_errno.h" -#include "apr_md4.h" -#include "apr_file_io.h" - -#include "abts.h" -#include "testutil.h" - -static struct { - const char *string; - const char *md4sum; -} md4sums[] = -{ -/* -* Taken from the old md4 test suite. -* MD4 ("") = 31d6cfe0d16ae931b73c59d7e0c089c0 -* MD4 ("a") = bde52cb31de33e46245e05fbdbd6fb24 -* MD4 ("abc") = a448017aaf21d8525fc10ae87aa6729d -* MD4 ("message digest") = d9130a8164549fe818874806e1c7014b -* MD4 ("abcdefghijklmnopqrstuvwxyz") = d79e1c308aa5bbcdeea8ed63df412da9 -* MD4 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") -* MD4 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") = e33b4ddc9c38f2199c3e7b164fcc0536 -* -*/ - {"", - "\x31\xd6\xcf\xe0\xd1\x6a\xe9\x31\xb7\x3c\x59\xd7\xe0\xc0\x89\xc0"}, - {"a", - "\xbd\xe5\x2c\xb3\x1d\xe3\x3e\x46\x24\x5e\x05\xfb\xdb\xd6\xfb\x24"}, - {"abc", - "\xa4\x48\x01\x7a\xaf\x21\xd8\x52\x5f\xc1\x0a\xe8\x7a\xa6\x72\x9d"}, - {"message digest", - "\xd9\x13\x0a\x81\x64\x54\x9f\xe8\x18\x87\x48\x06\xe1\xc7\x01\x4b"}, - {"abcdefghijklmnopqrstuvwxyz", - "\xd7\x9e\x1c\x30\x8a\xa5\xbb\xcd\xee\xa8\xed\x63\xdf\x41\x2d\xa9"}, - {"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", - "\x04\x3f\x85\x82\xf2\x41\xdb\x35\x1c\xe6\x27\xe1\x53\xe7\xf0\xe4"}, - {"12345678901234567890123456789012345678901234567890123456789012345678901234567890", - "\xe3\x3b\x4d\xdc\x9c\x38\xf2\x19\x9c\x3e\x7b\x16\x4f\xcc\x05\x36"} -}; - -static int num_sums = sizeof(md4sums) / sizeof(md4sums[0]); -static int count; - -#if 0 -static int MDStringComp(const void *string, const void *sum) -{ - apr_md4_ctx_t context; - unsigned char digest[APR_MD4_DIGESTSIZE]; - unsigned int len = strlen(string); - - apr_md4_init(&context); - apr_md4_update(&context, (unsigned char *)string, len); - apr_md4_final(digest, &context); - return (memcmp(digest, sum, APR_MD4_DIGESTSIZE)); - -} -#endif - -static void test_md4sum(abts_case *tc, void *data) -{ - apr_md4_ctx_t context; - unsigned char digest[APR_MD4_DIGESTSIZE]; - const void *string = md4sums[count].string; - const void *sum = md4sums[count].md4sum; - unsigned int len = strlen(string); - - ABTS_ASSERT(tc, "apr_md4_init", (apr_md4_init(&context) == 0)); - ABTS_ASSERT(tc, "apr_md4_update", - (apr_md4_update(&context, - (unsigned char *)string, len) == 0)); - - ABTS_ASSERT(tc, "apr_md4_final", (apr_md4_final(digest, &context) ==0)); - ABTS_ASSERT(tc, "check for correct md4 digest", - (memcmp(digest, sum, APR_MD4_DIGESTSIZE) == 0)); -} - -abts_suite *testmd4(abts_suite *suite) -{ - suite = ADD_SUITE(suite); - - for (count=0; count < num_sums; count++) { - abts_run_test(suite, test_md4sum, NULL); - } - - return suite; -} diff --git a/libs/apr-util/test/testmd5.c b/libs/apr-util/test/testmd5.c deleted file mode 100644 index 4f06f0d7d3..0000000000 --- a/libs/apr-util/test/testmd5.c +++ /dev/null @@ -1,78 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include - -#include "apr_md5.h" -#include "apr_xlate.h" -#include "apr_general.h" - -#include "abts.h" -#include "testutil.h" - -static struct { - const char *string; - const char *digest; -} md5sums[] = -{ - {"Jeff was here!", - "\xa5\x25\x8a\x89\x11\xb2\x9d\x1f\x81\x75\x96\x3b\x60\x94\x49\xc0"}, - {"01234567890aBcDeFASDFGHJKLPOIUYTR" - "POIUYTREWQZXCVBN LLLLLLLLLLLLLLL", - "\xd4\x1a\x06\x2c\xc5\xfd\x6f\x24\x67\x68\x56\x7c\x40\x8a\xd5\x69"}, - {"111111118888888888888888*******%%%%%%%%%%#####" - "142134u8097289720432098409289nkjlfkjlmn,m.. ", - "\xb6\xea\x5b\xe8\xca\x45\x8a\x33\xf0\xf1\x84\x6f\xf9\x65\xa8\xe1"}, - {"01234567890aBcDeFASDFGHJKLPOIUYTR" - "POIUYTREWQZXCVBN LLLLLLLLLLLLLLL" - "01234567890aBcDeFASDFGHJKLPOIUYTR" - "POIUYTREWQZXCVBN LLLLLLLLLLLLLLL" - "1", - "\xd1\xa1\xc0\x97\x8a\x60\xbb\xfb\x2a\x25\x46\x9d\xa5\xae\xd0\xb0"} -}; - -static int num_sums = sizeof(md5sums) / sizeof(md5sums[0]); -static int count; - -static void test_md5sum(abts_case *tc, void *data) -{ - apr_md5_ctx_t context; - unsigned char digest[APR_MD5_DIGESTSIZE]; - const void *string = md5sums[count].string; - const void *sum = md5sums[count].digest; - unsigned int len = strlen(string); - - ABTS_ASSERT(tc, "apr_md5_init", (apr_md5_init(&context) == 0)); - ABTS_ASSERT(tc, "apr_md5_update", - (apr_md5_update(&context, string, len) == 0)); - ABTS_ASSERT(tc, "apr_md5_final", (apr_md5_final(digest, &context) - == 0)); - ABTS_ASSERT(tc, "check for correct md5 digest", - (memcmp(digest, sum, APR_MD5_DIGESTSIZE) == 0)); -} - -abts_suite *testmd5(abts_suite *suite) -{ - suite = ADD_SUITE(suite); - - for (count=0; count < num_sums; count++) { - abts_run_test(suite, test_md5sum, NULL); - } - - return suite; -} diff --git a/libs/apr-util/test/testpass.c b/libs/apr-util/test/testpass.c deleted file mode 100644 index 67bbdbeaf8..0000000000 --- a/libs/apr-util/test/testpass.c +++ /dev/null @@ -1,140 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include - -#include "apr_errno.h" -#include "apr_strings.h" -#include "apr_file_io.h" -#include "apr_thread_proc.h" -#include "apr_md5.h" -#include "apr_sha1.h" - -#include "abts.h" -#include "testutil.h" - -static struct { - const char *password; - const char *hash; -} passwords[] = -{ -/* - passwords and hashes created with Apache's htpasswd utility like this: - - htpasswd -c -b passwords pass1 pass1 - htpasswd -b passwords pass2 pass2 - htpasswd -b passwords pass3 pass3 - htpasswd -b passwords pass4 pass4 - htpasswd -b passwords pass5 pass5 - htpasswd -b passwords pass6 pass6 - htpasswd -b passwords pass7 pass7 - htpasswd -b passwords pass8 pass8 - (insert Perl one-liner to convert to initializer :) ) - */ - {"pass1", "1fWDc9QWYCWrQ"}, - {"pass2", "1fiGx3u7QoXaM"}, - {"pass3", "1fzijMylTiwCs"}, - {"pass4", "nHUYc8U2UOP7s"}, - {"pass5", "nHpETGLGPwAmA"}, - {"pass6", "nHbsbWmJ3uyhc"}, - {"pass7", "nHQ3BbF0Y9vpI"}, - {"pass8", "nHZA1rViSldQk"} -}; -static int num_passwords = sizeof(passwords) / sizeof(passwords[0]); - -static void test_crypt(abts_case *tc, void *data) -{ - int i; - - for (i = 0; i < num_passwords; i++) { - apr_assert_success(tc, "check for valid password", - apr_password_validate(passwords[i].password, - passwords[i].hash)); - } -} - -#if APR_HAS_THREADS - -static void * APR_THREAD_FUNC testing_thread(apr_thread_t *thd, - void *data) -{ - abts_case *tc = data; - int i; - - for (i = 0; i < 100; i++) { - test_crypt(tc, NULL); - } - - return APR_SUCCESS; -} - -/* test for threadsafe crypt() */ -static void test_threadsafe(abts_case *tc, void *data) -{ -#define NUM_THR 20 - apr_thread_t *my_threads[NUM_THR]; - int i; - apr_status_t rv; - - for (i = 0; i < NUM_THR; i++) { - apr_assert_success(tc, "create test thread", - apr_thread_create(&my_threads[i], NULL, - testing_thread, tc, p)); - } - - for (i = 0; i < NUM_THR; i++) { - apr_thread_join(&rv, my_threads[i]); - } -} -#endif - -static void test_shapass(abts_case *tc, void *data) -{ - const char *pass = "hellojed"; - char hash[100]; - - apr_sha1_base64(pass, strlen(pass), hash); - - apr_assert_success(tc, "SHA1 password validated", - apr_password_validate(pass, hash)); -} - -static void test_md5pass(abts_case *tc, void *data) -{ - const char *pass = "hellojed", *salt = "sardine"; - char hash[100]; - - apr_md5_encode(pass, salt, hash, sizeof hash); - - apr_assert_success(tc, "MD5 password validated", - apr_password_validate(pass, hash)); -} - -abts_suite *testpass(abts_suite *suite) -{ - suite = ADD_SUITE(suite); - - abts_run_test(suite, test_crypt, NULL); -#if APR_HAS_THREADS - abts_run_test(suite, test_threadsafe, NULL); -#endif - abts_run_test(suite, test_shapass, NULL); - abts_run_test(suite, test_md5pass, NULL); - - return suite; -} diff --git a/libs/apr-util/test/testqueue.c b/libs/apr-util/test/testqueue.c deleted file mode 100644 index 9a971f4b11..0000000000 --- a/libs/apr-util/test/testqueue.c +++ /dev/null @@ -1,282 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include "errno.h" -#include -#include -#include -#if APR_HAVE_UNISTD_H -#include -#endif -#include -#include "apr_queue.h" - -#if !APR_HAS_THREADS -int main(void) -{ - fprintf(stderr, - "This program won't work on this platform because there is no " - "support for threads.\n"); - return 0; -} -#else /* !APR_HAS_THREADS */ - -apr_pool_t *context; -int consumer_activity=400; -int producer_activity=300; -int verbose=0; -static void * APR_THREAD_FUNC consumer(apr_thread_t *thd, void *data); -static void * APR_THREAD_FUNC producer(apr_thread_t *thd, void *data); -static void usage(void); - -static void * APR_THREAD_FUNC consumer(apr_thread_t *thd, void *data) -{ - long sleeprate; - apr_queue_t *q = (apr_queue_t*)data; - apr_status_t rv; - int val; - void *v; - char current_thread_str[30]; - apr_os_thread_t current_thread = apr_os_thread_current(); - - apr_snprintf(current_thread_str, sizeof current_thread_str, - "%pT", ¤t_thread); - - sleeprate = 1000000/consumer_activity; - apr_sleep( (rand() % 4 ) * 1000000 ); /* sleep random seconds */ - while (1) { - do { - rv = apr_queue_pop(q, &v); - if (rv == APR_EINTR) { - fprintf(stderr, "%s\tconsumer intr\n", current_thread_str); - } - - } while (rv == APR_EINTR) ; - if (rv != APR_SUCCESS) { - if (rv == APR_EOF) { - fprintf(stderr, "%s\tconsumer:queue terminated APR_EOF\n", current_thread_str); - rv=APR_SUCCESS; - } - else - fprintf(stderr, "%s\tconsumer thread exit rv %d\n", current_thread_str, rv); - apr_thread_exit(thd, rv); - return NULL; - } - val = *(int*)v; - if (verbose) - fprintf(stderr, "%s\tpop %d\n", current_thread_str, val); - apr_sleep( sleeprate ); /* sleep this long to acheive our rate */ - } - /* not reached */ - return NULL; -} - -static void * APR_THREAD_FUNC producer(apr_thread_t *thd, void *data) -{ - int i=0; - long sleeprate; - apr_queue_t *q = (apr_queue_t*)data; - apr_status_t rv; - int *val; - char current_thread_str[30]; - apr_os_thread_t current_thread = apr_os_thread_current(); - - apr_snprintf(current_thread_str, sizeof current_thread_str, - "%pT", ¤t_thread); - - sleeprate = 1000000/producer_activity; - apr_sleep( (rand() % 4 ) * 1000000 ); /* sleep random seconds */ - - while(1) { - val = apr_palloc(context, sizeof(int)); - *val=i; - if (verbose) - fprintf(stderr, "%s\tpush %d\n", current_thread_str, *val); - do { - rv = apr_queue_push(q, val); - if (rv == APR_EINTR) - fprintf(stderr, "%s\tproducer intr\n", current_thread_str); - } while (rv == APR_EINTR); - - if (rv != APR_SUCCESS) { - if (rv == APR_EOF) { - fprintf(stderr, "%s\tproducer: queue terminated APR_EOF\n", current_thread_str); - rv = APR_SUCCESS; - } - else - fprintf(stderr, "%s\tproducer thread exit rv %d\n", current_thread_str, rv); - apr_thread_exit(thd, rv); - return NULL; - } - i++; - apr_sleep( sleeprate ); /* sleep this long to acheive our rate */ - } - /* not reached */ - return NULL; -} - -static void usage(void) -{ - fprintf(stderr,"usage: testqueue -p n -P n -c n -C n -q n -s n\n"); - fprintf(stderr,"-c # of consumer\n"); - fprintf(stderr,"-C amount they consumer before dying\n"); - fprintf(stderr,"-p # of producers\n"); - fprintf(stderr,"-P amount they produce before dying\n"); - fprintf(stderr,"-q queue size\n"); - fprintf(stderr,"-s amount of time to sleep before killing it\n"); - fprintf(stderr,"-v verbose\n"); -} - -int main(int argc, const char* const argv[]) -{ - apr_thread_t **t; - apr_queue_t *queue; - int i; - apr_status_t rv; - apr_getopt_t *opt; - const char *optarg; - char c; - int numconsumers=3; - int numproducers=4; - int queuesize=100; - int sleeptime=30; - char errorbuf[200]; - - apr_initialize(); - srand((unsigned int)apr_time_now()); - printf("APR Queue Test\n======================\n\n"); - - printf("%-60s", "Initializing the context"); - if (apr_pool_create(&context, NULL) != APR_SUCCESS) { - fflush(stdout); - fprintf(stderr, "Failed.\nCould not initialize\n"); - exit(-1); - } - printf("OK\n"); - - apr_getopt_init(&opt, context, argc, argv); - while ((rv = apr_getopt(opt, "p:c:P:C:q:s:v", &c, &optarg)) - == APR_SUCCESS) { - switch (c) { - case 'c': - numconsumers = atoi( optarg); - break; - case 'p': - numproducers = atoi( optarg); - break; - case 'C': - consumer_activity = atoi( optarg); - break; - case 'P': - producer_activity = atoi( optarg); - break; - case 's': - sleeptime= atoi(optarg); - break; - case 'q': - queuesize = atoi(optarg); - break; - case 'v': - verbose= 1; - break; - default: - usage(); - exit(-1); - } - } - /* bad cmdline option? then we die */ - if (rv != APR_EOF || opt->ind < opt->argc) { - usage(); - exit(-1); - } - - - - printf("test stats %d consumers (rate %d/sec) %d producers (rate %d/sec) queue size %d sleep %d\n", - numconsumers,consumer_activity, numproducers, producer_activity, queuesize,sleeptime); - printf("%-60s", "Initializing the queue"); - rv = apr_queue_create(&queue, queuesize, context); - - if (rv != APR_SUCCESS) { - fflush(stdout); - fprintf(stderr, "Failed\nCould not create queue %d\n",rv); - apr_strerror(rv, errorbuf,200); - fprintf(stderr,"%s\n",errorbuf); - exit(-1); - } - printf("OK\n"); - - t = apr_palloc( context, sizeof(apr_thread_t*) * (numconsumers+numproducers)); - printf("%-60s", "Starting consumers"); - for (i=0;i -#include -#include "apr_reslist.h" -#include "apr_thread_proc.h" - -#if APR_HAVE_TIME_H -#include -#endif /* APR_HAVE_TIME_H */ - -#if !APR_HAS_THREADS - -int main(void) -{ - fprintf(stderr, "this program requires APR thread support\n"); - return 0; -} - -#else - -#define RESLIST_MIN 3 -#define RESLIST_SMAX 10 -#define RESLIST_HMAX 20 -#define RESLIST_TTL APR_TIME_C(350000) /* 35 ms */ -#define CONSUMER_THREADS 25 -#define CONSUMER_ITERATIONS 250 -#define CONSTRUCT_SLEEP_TIME APR_TIME_C(250000) /* 25 ms */ -#define DESTRUCT_SLEEP_TIME APR_TIME_C(100000) /* 10 ms */ -#define WORK_DELAY_SLEEP_TIME APR_TIME_C(150000) /* 15 ms */ - -typedef struct { - apr_interval_time_t sleep_upon_construct; - apr_interval_time_t sleep_upon_destruct; - int c_count; - int d_count; -} my_parameters_t; - -typedef struct { - int id; -} my_resource_t; - -static apr_status_t my_constructor(void **resource, void *params, - apr_pool_t *pool) -{ - my_resource_t *res; - my_parameters_t *my_params = params; - - /* Create some resource */ - res = apr_palloc(pool, sizeof(*res)); - res->id = my_params->c_count++; - - printf("++ constructing new resource [id:%d, #%d/%d]\n", res->id, - my_params->c_count, my_params->d_count); - - /* Sleep for awhile, to simulate construction overhead. */ - apr_sleep(my_params->sleep_upon_construct); - - /* Set the resource so it can be managed by the reslist */ - *resource = res; - return APR_SUCCESS; -} - -static apr_status_t my_destructor(void *resource, void *params, - apr_pool_t *pool) -{ - my_resource_t *res = resource; - my_parameters_t *my_params = params; - - printf("-- destructing old resource [id:%d, #%d/%d]\n", res->id, - my_params->c_count, ++my_params->d_count); - - apr_sleep(my_params->sleep_upon_destruct); - - return APR_SUCCESS; -} - -typedef struct { - int tid; - apr_reslist_t *reslist; - apr_interval_time_t work_delay_sleep; -} my_thread_info_t; - -static void * APR_THREAD_FUNC resource_consuming_thread(apr_thread_t *thd, - void *data) -{ - apr_status_t rv; - my_thread_info_t *thread_info = data; - apr_reslist_t *rl = thread_info->reslist; - int i; - - for (i = 0; i < CONSUMER_ITERATIONS; i++) { - my_resource_t *res; - void *vp; - rv = apr_reslist_acquire(rl, &vp); - if (rv != APR_SUCCESS) { - fprintf(stderr, "Failed to retrieve resource from reslist\n"); - apr_thread_exit(thd, rv); - return NULL; - } - res = vp; - printf(" [tid:%d,iter:%d] using resource id:%d\n", thread_info->tid, - i, res->id); - apr_sleep(thread_info->work_delay_sleep); -/* simulate a 5% chance of the resource being bad */ - if ( drand48() < 0.95 ) { - rv = apr_reslist_release(rl, res); - if (rv != APR_SUCCESS) { - fprintf(stderr, "Failed to return resource to reslist\n"); - apr_thread_exit(thd, rv); - return NULL; - } - } else { - printf("invalidating resource id:%d\n", res->id) ; - rv = apr_reslist_invalidate(rl, res); - if (rv != APR_SUCCESS) { - fprintf(stderr, "Failed to invalidate resource\n"); - apr_thread_exit(thd, rv); - return NULL; - } - } - } - - return APR_SUCCESS; -} - -static void test_timeout(apr_reslist_t *rl) -{ - apr_status_t rv; - my_resource_t *resources[RESLIST_HMAX]; - my_resource_t *res; - void *vp; - int i; - - printf("Setting timeout to 1000us: "); - apr_reslist_timeout_set(rl, 1000); - fprintf(stdout, "OK\n"); - - /* deplete all possible resources from the resource list - * so that the next call will block until timeout is reached - * (since there are no other threads to make a resource - * available) - */ - - for (i = 0; i < RESLIST_HMAX; i++) { - rv = apr_reslist_acquire(rl, (void**)&resources[i]); - if (rv != APR_SUCCESS) { - fprintf(stderr, "couldn't acquire resource: %d\n", rv); - exit(1); - } - } - - /* next call will block until timeout is reached */ - rv = apr_reslist_acquire(rl, &vp); - if (!APR_STATUS_IS_TIMEUP(rv)) { - fprintf(stderr, "apr_reslist_acquire()->%d instead of TIMEUP\n", - rv); - exit(1); - } - res = vp; - - /* release the resources; otherwise the destroy operation - * will blow - */ - for (i = 0; i < RESLIST_HMAX; i++) { - rv = apr_reslist_release(rl, &resources[i]); - if (rv != APR_SUCCESS) { - fprintf(stderr, "couldn't release resource: %d\n", rv); - exit(1); - } - } -} - -static apr_status_t test_reslist(apr_pool_t *parpool) -{ - apr_status_t rv; - apr_pool_t *pool; - apr_reslist_t *rl; - my_parameters_t *params; - int i; - apr_thread_t *my_threads[CONSUMER_THREADS]; - my_thread_info_t my_thread_info[CONSUMER_THREADS]; - srand48(time(0)) ; - - printf("Creating child pool......................."); - rv = apr_pool_create(&pool, parpool); - if (rv != APR_SUCCESS) { - fprintf(stderr, "Error creating child pool\n"); - return rv; - } - printf("OK\n"); - - /* Create some parameters that will be passed into each - * constructor and destructor call. */ - params = apr_pcalloc(pool, sizeof(*params)); - params->sleep_upon_construct = CONSTRUCT_SLEEP_TIME; - params->sleep_upon_destruct = DESTRUCT_SLEEP_TIME; - - /* We're going to want 10 blocks of data from our target rmm. */ - printf("Creating resource list:\n" - " min/smax/hmax: %d/%d/%d\n" - " ttl: %" APR_TIME_T_FMT "\n", RESLIST_MIN, RESLIST_SMAX, - RESLIST_HMAX, RESLIST_TTL); - rv = apr_reslist_create(&rl, RESLIST_MIN, RESLIST_SMAX, RESLIST_HMAX, - RESLIST_TTL, my_constructor, my_destructor, - params, pool); - if (rv != APR_SUCCESS) { - fprintf(stderr, "Error allocating shared memory block\n"); - return rv; - } - fprintf(stdout, "OK\n"); - - printf("Creating %d threads", CONSUMER_THREADS); - for (i = 0; i < CONSUMER_THREADS; i++) { - putchar('.'); - my_thread_info[i].tid = i; - my_thread_info[i].reslist = rl; - my_thread_info[i].work_delay_sleep = WORK_DELAY_SLEEP_TIME; - rv = apr_thread_create(&my_threads[i], NULL, - resource_consuming_thread, &my_thread_info[i], - pool); - if (rv != APR_SUCCESS) { - fprintf(stderr, "Failed to create thread %d\n", i); - return rv; - } - } - printf("\nDone!\n"); - - printf("Waiting for threads to finish"); - for (i = 0; i < CONSUMER_THREADS; i++) { - apr_status_t thread_rv; - putchar('.'); - apr_thread_join(&thread_rv, my_threads[i]); - if (rv != APR_SUCCESS) { - fprintf(stderr, "Failed to join thread %d\n", i); - return rv; - } - } - printf("\nDone!\n"); - - test_timeout(rl); - - printf("Destroying resource list................."); - rv = apr_reslist_destroy(rl); - if (rv != APR_SUCCESS) { - printf("FAILED\n"); - return rv; - } - printf("OK\n"); - - apr_pool_destroy(pool); - - return APR_SUCCESS; -} - - -int main(void) -{ - apr_status_t rv; - apr_pool_t *pool; - char errmsg[200]; - - apr_initialize(); - - printf("APR Resource List Test\n"); - printf("======================\n\n"); - - printf("Initializing the pool............................"); - if (apr_pool_create(&pool, NULL) != APR_SUCCESS) { - printf("could not initialize pool\n"); - exit(-1); - } - printf("OK\n"); - - rv = test_reslist(pool); - if (rv != APR_SUCCESS) { - printf("Resource list test FAILED: [%d] %s\n", - rv, apr_strerror(rv, errmsg, sizeof(errmsg))); - exit(-2); - } - printf("Resource list test passed!\n"); - - return 0; -} - -#endif /* APR_HAS_THREADS */ diff --git a/libs/apr-util/test/testrmm.c b/libs/apr-util/test/testrmm.c deleted file mode 100644 index 3c3ac604d0..0000000000 --- a/libs/apr-util/test/testrmm.c +++ /dev/null @@ -1,281 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_shm.h" -#include "apr_rmm.h" -#include "apr_errno.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_strings.h" -#include "apr_time.h" -#include -#include -#include -#if APR_HAVE_UNISTD_H -#include -#endif - -#if APR_HAS_SHARED_MEMORY - -#define FRAG_SIZE 80 -#define FRAG_COUNT 10 -#define SHARED_SIZE (apr_size_t)(FRAG_SIZE * FRAG_COUNT * sizeof(char*)) - -static apr_status_t test_rmm(apr_pool_t *parpool) -{ - apr_status_t rv; - apr_pool_t *pool; - apr_shm_t *shm; - apr_rmm_t *rmm; - apr_size_t size, fragsize; - apr_rmm_off_t *off; - int i; - void *entity; - - rv = apr_pool_create(&pool, parpool); - if (rv != APR_SUCCESS) { - fprintf(stderr, "Error creating child pool\n"); - return rv; - } - - /* We're going to want 10 blocks of data from our target rmm. */ - size = SHARED_SIZE + apr_rmm_overhead_get(FRAG_COUNT + 1); - printf("Creating anonymous shared memory (%" - APR_SIZE_T_FMT " bytes).....", size); - rv = apr_shm_create(&shm, size, NULL, pool); - if (rv != APR_SUCCESS) { - fprintf(stderr, "Error allocating shared memory block\n"); - return rv; - } - fprintf(stdout, "OK\n"); - - printf("Creating rmm segment............................."); - rv = apr_rmm_init(&rmm, NULL, apr_shm_baseaddr_get(shm), size, - pool); - - if (rv != APR_SUCCESS) { - fprintf(stderr, "Error allocating rmm..............\n"); - return rv; - } - fprintf(stdout, "OK\n"); - - fragsize = SHARED_SIZE / FRAG_COUNT; - printf("Creating each fragment of size %" APR_SIZE_T_FMT "................", - fragsize); - off = apr_palloc(pool, FRAG_COUNT * sizeof(apr_rmm_off_t)); - for (i = 0; i < FRAG_COUNT; i++) { - off[i] = apr_rmm_malloc(rmm, fragsize); - } - fprintf(stdout, "OK\n"); - - printf("Checking for out of memory allocation............"); - if (apr_rmm_malloc(rmm, FRAG_SIZE * FRAG_COUNT) == 0) { - fprintf(stdout, "OK\n"); - } - else { - return APR_EGENERAL; - } - - printf("Checking each fragment for address alignment....."); - for (i = 0; i < FRAG_COUNT; i++) { - char *c = apr_rmm_addr_get(rmm, off[i]); - apr_size_t sc = (apr_size_t)c; - - if (off[i] == 0) { - printf("allocation failed for offset %d\n", i); - return APR_ENOMEM; - } - - if (sc & 7) { - printf("Bad alignment for fragment %d; %p not %p!\n", - i, c, (void *)APR_ALIGN_DEFAULT((apr_size_t)c)); - return APR_EGENERAL; - } - } - fprintf(stdout, "OK\n"); - - printf("Setting each fragment to a unique value.........."); - for (i = 0; i < FRAG_COUNT; i++) { - int j; - char **c = apr_rmm_addr_get(rmm, off[i]); - for (j = 0; j < FRAG_SIZE; j++, c++) { - *c = apr_itoa(pool, i + j); - } - } - fprintf(stdout, "OK\n"); - - printf("Checking each fragment for its unique value......"); - for (i = 0; i < FRAG_COUNT; i++) { - int j; - char **c = apr_rmm_addr_get(rmm, off[i]); - for (j = 0; j < FRAG_SIZE; j++, c++) { - char *d = apr_itoa(pool, i + j); - if (strcmp(*c, d) != 0) { - return APR_EGENERAL; - } - } - } - fprintf(stdout, "OK\n"); - - printf("Freeing each fragment............................"); - for (i = 0; i < FRAG_COUNT; i++) { - rv = apr_rmm_free(rmm, off[i]); - if (rv != APR_SUCCESS) { - return rv; - } - } - fprintf(stdout, "OK\n"); - - printf("Creating one large segment......................."); - off[0] = apr_rmm_calloc(rmm, SHARED_SIZE); - fprintf(stdout, "OK\n"); - - printf("Setting large segment............................"); - for (i = 0; i < FRAG_COUNT * FRAG_SIZE; i++) { - char **c = apr_rmm_addr_get(rmm, off[0]); - c[i] = apr_itoa(pool, i); - } - fprintf(stdout, "OK\n"); - - printf("Freeing large segment............................"); - apr_rmm_free(rmm, off[0]); - fprintf(stdout, "OK\n"); - - printf("Creating each fragment of size %" APR_SIZE_T_FMT " (again)........", - fragsize); - for (i = 0; i < FRAG_COUNT; i++) { - off[i] = apr_rmm_malloc(rmm, fragsize); - } - fprintf(stdout, "OK\n"); - - printf("Freeing each fragment backwards.................."); - for (i = FRAG_COUNT - 1; i >= 0; i--) { - rv = apr_rmm_free(rmm, off[i]); - if (rv != APR_SUCCESS) { - return rv; - } - } - fprintf(stdout, "OK\n"); - - printf("Creating one large segment (again)..............."); - off[0] = apr_rmm_calloc(rmm, SHARED_SIZE); - fprintf(stdout, "OK\n"); - - printf("Freeing large segment............................"); - apr_rmm_free(rmm, off[0]); - fprintf(stdout, "OK\n"); - - printf("Checking realloc................................."); - off[0] = apr_rmm_calloc(rmm, SHARED_SIZE - 100); - off[1] = apr_rmm_calloc(rmm, 100); - if (off[0] == 0 || off[1] == 0) { - printf("FAILED\n"); - return APR_EINVAL; - } - entity = apr_rmm_addr_get(rmm, off[1]); - rv = apr_rmm_free(rmm, off[0]); - if (rv != APR_SUCCESS) { - printf("FAILED\n"); - return rv; - } - - { - unsigned char *c = entity; - - /* Fill in the region; the first half with zereos, which will - * likely catch the apr_rmm_realloc offset calculation bug by - * making it think the old region was zero length. */ - for (i = 0; i < 100; i++) { - c[i] = (i < 50) ? 0 : i; - } - } - - /* now we can realloc off[1] and get many more bytes */ - off[0] = apr_rmm_realloc(rmm, entity, SHARED_SIZE - 100); - if (off[0] == 0) { - printf("FAILED\n"); - return APR_EINVAL; - } - - { - unsigned char *c = apr_rmm_addr_get(rmm, off[0]); - - /* fill in the region */ - for (i = 0; i < 100; i++) { - if (c[i] != (i < 50 ? 0 : i)) { - printf("FAILED at offset %d: %hx\n", i, c[i]); - return APR_EGENERAL; - } - } - } - - fprintf(stdout, "OK\n"); - - printf("Destroying rmm segment..........................."); - rv = apr_rmm_destroy(rmm); - if (rv != APR_SUCCESS) { - printf("FAILED\n"); - return rv; - } - printf("OK\n"); - - printf("Destroying shared memory segment................."); - rv = apr_shm_destroy(shm); - if (rv != APR_SUCCESS) { - printf("FAILED\n"); - return rv; - } - printf("OK\n"); - - apr_pool_destroy(pool); - - return APR_SUCCESS; -} - - -int main(void) -{ - apr_status_t rv; - apr_pool_t *pool; - char errmsg[200]; - - apr_initialize(); - - printf("APR RMM Memory Test\n"); - printf("======================\n\n"); - - printf("Initializing the pool............................"); - if (apr_pool_create(&pool, NULL) != APR_SUCCESS) { - printf("could not initialize pool\n"); - exit(-1); - } - printf("OK\n"); - - rv = test_rmm(pool); - if (rv != APR_SUCCESS) { - printf("Anonymous shared memory test FAILED: [%d] %s\n", - rv, apr_strerror(rv, errmsg, sizeof(errmsg))); - exit(-2); - } - printf("RMM test passed!\n"); - - return 0; -} - -#else /* APR_HAS_SHARED_MEMORY */ -#error shmem is not supported on this platform -#endif /* APR_HAS_SHARED_MEMORY */ - diff --git a/libs/apr-util/test/teststrmatch.c b/libs/apr-util/test/teststrmatch.c deleted file mode 100644 index e86b4c13c9..0000000000 --- a/libs/apr-util/test/teststrmatch.c +++ /dev/null @@ -1,92 +0,0 @@ -/* Copyright 2002-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "testutil.h" - -#include "apr.h" -#include "apr_general.h" -#include "apr_strmatch.h" -#if APR_HAVE_STDLIB_H -#include -#endif -#define APR_WANT_STDIO -#define APR_WANT_STRFUNC -#include "apr_want.h" - -static void test_str(abts_case *tc, void *data) -{ - apr_pool_t *pool = p; - const apr_strmatch_pattern *pattern; - const apr_strmatch_pattern *pattern_nocase; - const apr_strmatch_pattern *pattern_onechar; - const apr_strmatch_pattern *pattern_zero; - const char *match = NULL; - const char *input1 = "string that contains a patterN..."; - const char *input2 = "string that contains a pattern..."; - const char *input3 = "pattern at the start of a string"; - const char *input4 = "string that ends with a pattern"; - const char *input5 = "patter\200n not found, negative chars in input"; - const char *input6 = "patter\200n, negative chars, contains pattern..."; - - pattern = apr_strmatch_precompile(pool, "pattern", 1); - ABTS_PTR_NOTNULL(tc, pattern); - - pattern_nocase = apr_strmatch_precompile(pool, "pattern", 0); - ABTS_PTR_NOTNULL(tc, pattern_nocase); - - pattern_onechar = apr_strmatch_precompile(pool, "g", 0); - ABTS_PTR_NOTNULL(tc, pattern_onechar); - - pattern_zero = apr_strmatch_precompile(pool, "", 0); - ABTS_PTR_NOTNULL(tc, pattern_zero); - - match = apr_strmatch(pattern, input1, strlen(input1)); - ABTS_PTR_EQUAL(tc, match, NULL); - - match = apr_strmatch(pattern, input2, strlen(input2)); - ABTS_PTR_EQUAL(tc, match, input2 + 23); - - match = apr_strmatch(pattern_onechar, input1, strlen(input1)); - ABTS_PTR_EQUAL(tc, match, input1 + 5); - - match = apr_strmatch(pattern_zero, input1, strlen(input1)); - ABTS_PTR_EQUAL(tc, match, input1); - - match = apr_strmatch(pattern_nocase, input1, strlen(input1)); - ABTS_PTR_EQUAL(tc, match, input1 + 23); - - match = apr_strmatch(pattern, input3, strlen(input3)); - ABTS_PTR_EQUAL(tc, match, input3); - - match = apr_strmatch(pattern, input4, strlen(input4)); - ABTS_PTR_EQUAL(tc, match, input4 + 24); - - match = apr_strmatch(pattern, input5, strlen(input5)); - ABTS_PTR_EQUAL(tc, match, NULL); - - match = apr_strmatch(pattern, input6, strlen(input6)); - ABTS_PTR_EQUAL(tc, match, input6 + 35); -} - -abts_suite *teststrmatch(abts_suite *suite) -{ - suite = ADD_SUITE(suite); - - abts_run_test(suite, test_str, NULL); - - return suite; -} - diff --git a/libs/apr-util/test/testuri.c b/libs/apr-util/test/testuri.c deleted file mode 100644 index c4d385d3c9..0000000000 --- a/libs/apr-util/test/testuri.c +++ /dev/null @@ -1,230 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include - -#include "testutil.h" -#include "apr_general.h" -#include "apr_strings.h" -#include "apr_uri.h" - -struct aup_test { - const char *uri; - apr_status_t rv; - const char *scheme; - const char *hostinfo; - const char *user; - const char *password; - const char *hostname; - const char *port_str; - const char *path; - const char *query; - const char *fragment; - apr_port_t port; -}; - -struct aup_test aup_tests[] = -{ - { "http://[/::1]/index.html", APR_EGENERAL }, - { "http://[", APR_EGENERAL }, - { "http://[?::1]/index.html", APR_EGENERAL }, - - { - "http://127.0.0.1:9999/asdf.html", - 0, "http", "127.0.0.1:9999", NULL, NULL, "127.0.0.1", "9999", "/asdf.html", NULL, NULL, 9999 - }, - { - "http://127.0.0.1:9999a/asdf.html", - APR_EGENERAL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0 - }, - { - "http://[::127.0.0.1]:9999/asdf.html", - 0, "http", "[::127.0.0.1]:9999", NULL, NULL, "::127.0.0.1", "9999", "/asdf.html", NULL, NULL, 9999 - }, - { - "http://[::127.0.0.1]:9999a/asdf.html", - APR_EGENERAL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0 - }, - { - "/error/include/top.html", - 0, NULL, NULL, NULL, NULL, NULL, NULL, "/error/include/top.html", NULL, NULL, 0 - }, - { - "/error/include/../contact.html.var", - 0, NULL, NULL, NULL, NULL, NULL, NULL, "/error/include/../contact.html.var", NULL, NULL, 0 - }, - { - "/", - 0, NULL, NULL, NULL, NULL, NULL, NULL, "/", NULL, NULL, 0 - }, - { - "/manual/", - 0, NULL, NULL, NULL, NULL, NULL, NULL, "/manual/", NULL, NULL, 0 - }, - { - "/cocoon/developing/graphics/Using%20Databases-label_over.jpg", - 0, NULL, NULL, NULL, NULL, NULL, NULL, "/cocoon/developing/graphics/Using%20Databases-label_over.jpg", NULL, NULL, 0 - }, - { - "http://sonyamt:garbage@127.0.0.1/filespace/", - 0, "http", "sonyamt:garbage@127.0.0.1", "sonyamt", "garbage", "127.0.0.1", NULL, "/filespace/", NULL, NULL, 0 - }, - { - "http://sonyamt:garbage@[fe80::1]/filespace/", - 0, "http", "sonyamt:garbage@[fe80::1]", "sonyamt", "garbage", "fe80::1", NULL, "/filespace/", NULL, NULL, 0 - }, - { - "http://sonyamt@[fe80::1]/filespace/?arg1=store", - 0, "http", "sonyamt@[fe80::1]", "sonyamt", NULL, "fe80::1", NULL, "/filespace/", "arg1=store", NULL, 0 - }, - { - "//www.apache.org/", - 0, NULL, "www.apache.org", NULL, NULL, "www.apache.org", NULL, "/", NULL, NULL, 0 - }, -}; - -struct uph_test { - const char *hostinfo; - apr_status_t rv; - const char *hostname; - const char *port_str; - apr_port_t port; -}; - -struct uph_test uph_tests[] = -{ - { - "www.ibm.com:443", - 0, "www.ibm.com", "443", 443 - }, - { - "[fe80::1]:443", - 0, "fe80::1", "443", 443 - }, - { - "127.0.0.1:443", - 0, "127.0.0.1", "443", 443 - }, - { - "127.0.0.1", - APR_EGENERAL, NULL, NULL, 0 - }, - { - "[fe80:80", - APR_EGENERAL, NULL, NULL, 0 - }, - { - "fe80::80]:443", - APR_EGENERAL, NULL, NULL, 0 - } -}; - -#if 0 -static void show_info(apr_status_t rv, apr_status_t expected, const apr_uri_t *info) -{ - if (rv != expected) { - fprintf(stderr, " actual rv: %d expected rv: %d\n", rv, expected); - } - else { - fprintf(stderr, - " scheme: %s\n" - " hostinfo: %s\n" - " user: %s\n" - " password: %s\n" - " hostname: %s\n" - " port_str: %s\n" - " path: %s\n" - " query: %s\n" - " fragment: %s\n" - " hostent: %p\n" - " port: %u\n" - " is_initialized: %u\n" - " dns_looked_up: %u\n" - " dns_resolved: %u\n", - info->scheme, info->hostinfo, info->user, info->password, - info->hostname, info->port_str, info->path, info->query, - info->fragment, info->hostent, info->port, info->is_initialized, - info->dns_looked_up, info->dns_resolved); - } -} -#endif - -static void test_aup(abts_case *tc, void *data) -{ - int i; - apr_status_t rv; - apr_uri_t info; - struct aup_test *t; - const char *s = NULL; - - for (i = 0; i < sizeof(aup_tests) / sizeof(aup_tests[0]); i++) { - char msg[256]; - - memset(&info, 0, sizeof(info)); - t = &aup_tests[i]; - rv = apr_uri_parse(p, t->uri, &info); - apr_snprintf(msg, sizeof msg, "uri '%s': rv=%d not %d", t->uri, - rv, t->rv); - ABTS_ASSERT(tc, msg, rv == t->rv); - if (t->rv == APR_SUCCESS) { - ABTS_STR_EQUAL(tc, info.scheme, t->scheme); - ABTS_STR_EQUAL(tc, info.hostinfo, t->hostinfo); - ABTS_STR_EQUAL(tc, info.user, t->user); - ABTS_STR_EQUAL(tc, info.password, t->password); - ABTS_STR_EQUAL(tc, info.hostname, t->hostname); - ABTS_STR_EQUAL(tc, info.port_str, t->port_str); - ABTS_STR_EQUAL(tc, info.path, t->path); - ABTS_STR_EQUAL(tc, info.query, t->query); - ABTS_STR_EQUAL(tc, info.user, t->user); - ABTS_INT_EQUAL(tc, info.port, t->port); - - s = apr_uri_unparse(p, &info, APR_URI_UNP_REVEALPASSWORD); - ABTS_STR_EQUAL(tc, s, t->uri); - } - } -} - -static void test_uph(abts_case *tc, void *data) -{ - int i; - apr_status_t rv; - apr_uri_t info; - struct uph_test *t; - - for (i = 0; i < sizeof(uph_tests) / sizeof(uph_tests[0]); i++) { - memset(&info, 0, sizeof(info)); - t = &uph_tests[i]; - rv = apr_uri_parse_hostinfo(p, t->hostinfo, &info); - ABTS_INT_EQUAL(tc, rv, t->rv); - if (t->rv == APR_SUCCESS) { - ABTS_STR_EQUAL(tc, info.hostname, t->hostname); - ABTS_STR_EQUAL(tc, info.port_str, t->port_str); - ABTS_INT_EQUAL(tc, info.port, t->port); - } - } -} - -abts_suite *testuri(abts_suite *suite) -{ - suite = ADD_SUITE(suite); - - abts_run_test(suite, test_aup, NULL); - abts_run_test(suite, test_uph, NULL); - - return suite; -} - diff --git a/libs/apr-util/test/testutil.c b/libs/apr-util/test/testutil.c deleted file mode 100644 index f60ef21af2..0000000000 --- a/libs/apr-util/test/testutil.c +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include - -#include "abts.h" -#include "testutil.h" -#include "apr_pools.h" - -apr_pool_t *p; - -void apr_assert_success(abts_case* tc, const char* context, apr_status_t rv) -{ - if (rv == APR_ENOTIMPL) { - ABTS_NOT_IMPL(tc, context); - } - - if (rv != APR_SUCCESS) { - char buf[STRING_MAX], ebuf[128]; - sprintf(buf, "%s (%d): %s\n", context, rv, - apr_strerror(rv, ebuf, sizeof ebuf)); - ABTS_FAIL(tc, buf); - } -} - -void initialize(void) { - if (apr_initialize() != APR_SUCCESS) { - abort(); - } - atexit(apr_terminate); - - apr_pool_create(&p, NULL); - apr_pool_tag(p, "apr-util global test pool"); -} diff --git a/libs/apr-util/test/testutil.h b/libs/apr-util/test/testutil.h deleted file mode 100644 index 95318e17c4..0000000000 --- a/libs/apr-util/test/testutil.h +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_pools.h" -#include "abts.h" - -#ifndef APR_TEST_UTIL -#define APR_TEST_UTIL - -/* XXX FIXME */ -#ifdef WIN32 -#define EXTENSION ".exe" -#elif NETWARE -#define EXTENSION ".nlm" -#else -#define EXTENSION -#endif - -#define STRING_MAX 8096 - -/* Some simple functions to make the test apps easier to write and - * a bit more consistent... - */ - -extern apr_pool_t *p; - -/* Assert that RV is an APR_SUCCESS value; else fail giving strerror - * for RV and CONTEXT message. */ -void apr_assert_success(abts_case* tc, const char *context, apr_status_t rv); - -void initialize(void); - -abts_suite *teststrmatch(abts_suite *suite); -abts_suite *testuri(abts_suite *suite); -abts_suite *testuuid(abts_suite *suite); -abts_suite *testbuckets(abts_suite *suite); -abts_suite *testpass(abts_suite *suite); -abts_suite *testmd4(abts_suite *suite); -abts_suite *testmd5(abts_suite *suite); -abts_suite *testldap(abts_suite *suite); -abts_suite *testdbd(abts_suite *suite); - -#endif /* APR_TEST_INCLUDES */ diff --git a/libs/apr-util/test/testuuid.c b/libs/apr-util/test/testuuid.c deleted file mode 100644 index 2bd6ef37fb..0000000000 --- a/libs/apr-util/test/testuuid.c +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "testutil.h" -#include "apr_general.h" -#include "apr_uuid.h" - -static void test_uuid_parse(abts_case *tc, void *data) -{ - apr_uuid_t uuid; - apr_uuid_t uuid2; - char buf[APR_UUID_FORMATTED_LENGTH + 1]; - - apr_uuid_get(&uuid); - apr_uuid_format(buf, &uuid); - - apr_uuid_parse(&uuid2, buf); - ABTS_ASSERT(tc, "parse produced a different UUID", - memcmp(&uuid, &uuid2, sizeof(uuid)) == 0); -} - -static void test_gen2(abts_case *tc, void *data) -{ - apr_uuid_t uuid; - apr_uuid_t uuid2; - - /* generate two of them quickly */ - apr_uuid_get(&uuid); - apr_uuid_get(&uuid2); - - ABTS_ASSERT(tc, "generated the same UUID twice", - memcmp(&uuid, &uuid2, sizeof(uuid)) != 0); -} - -abts_suite *testuuid(abts_suite *suite) -{ - suite = ADD_SUITE(suite); - - abts_run_test(suite, test_uuid_parse, NULL); - abts_run_test(suite, test_gen2, NULL); - - return suite; -} diff --git a/libs/apr-util/test/testxlate.c b/libs/apr-util/test/testxlate.c deleted file mode 100644 index f6819914f0..0000000000 --- a/libs/apr-util/test/testxlate.c +++ /dev/null @@ -1,124 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include - -#include "apr.h" -#include "apr_errno.h" -#include "apr_general.h" -#include "apr_strings.h" -#include "apr_xlate.h" - -static const char test_utf8[] = "Edelwei\xc3\x9f"; -static const char test_utf7[] = "Edelwei+AN8-"; -static const char test_latin1[] = "Edelwei\xdf"; -static const char test_latin2[] = "Edelwei\xdf"; - - -static int check_status (apr_status_t status, const char *msg) -{ - if (status) - { - static char buf[1024]; - printf("ERROR: %s\n %s\n", msg, - apr_strerror(status, buf, sizeof(buf))); - return 1; - } - return 0; -} - -static int test_conversion (apr_xlate_t *convset, - const char *inbuf, - const char *expected) -{ - static char buf[1024]; - int retcode = 0; - apr_size_t inbytes_left = strlen(inbuf); - apr_size_t outbytes_left = sizeof(buf) - 1; - apr_status_t status = apr_xlate_conv_buffer(convset, - inbuf, - &inbytes_left, - buf, - &outbytes_left); - if (status == APR_SUCCESS) { - status = apr_xlate_conv_buffer(convset, NULL, NULL, - buf + sizeof(buf) - outbytes_left - 1, - &outbytes_left); - } - buf[sizeof(buf) - outbytes_left - 1] = '\0'; - retcode |= check_status(status, "apr_xlate_conv_buffer"); - if ((!status || APR_STATUS_IS_INCOMPLETE(status)) - && strcmp(buf, expected)) - { - printf("ERROR: expected: '%s'\n actual: '%s'" - "\n inbytes_left: %"APR_SIZE_T_FMT"\n", - expected, buf, inbytes_left); - retcode |= 1; - } - return retcode; -} - -static int one_test (const char *cs1, const char *cs2, - const char *str1, const char *str2, - apr_pool_t *pool) -{ - apr_xlate_t *convset; - const char *msg = apr_psprintf(pool, "apr_xlate_open(%s, %s)", cs2, cs1); - int retcode = check_status(apr_xlate_open(&convset, cs2, cs1, pool), msg); - if (!retcode) - { - retcode |= test_conversion(convset, str1, str2); - retcode |= check_status(apr_xlate_close(convset), "apr_xlate_close"); - } - printf("%s: %s -> %s\n", (retcode ? "FAIL" : "PASS"), cs1, cs2); - return retcode; -} - - -int main (int argc, char **argv) -{ - apr_pool_t *pool; - int retcode = 0; - -#ifndef APR_HAS_XLATE - puts("SKIP: apr_xlate not implemented"); - return 0; -#endif - - apr_initialize(); - atexit(apr_terminate); - apr_pool_create(&pool, NULL); - - /* 1. Identity transformation: UTF-8 -> UTF-8 */ - retcode |= one_test("UTF-8", "UTF-8", test_utf8, test_utf8, pool); - - /* 2. UTF-8 <-> ISO-8859-1 */ - retcode |= one_test("UTF-8", "ISO-8859-1", test_utf8, test_latin1, pool); - retcode |= one_test("ISO-8859-1", "UTF-8", test_latin1, test_utf8, pool); - - /* 3. ISO-8859-1 <-> ISO-8859-2, identity */ - retcode |= one_test("ISO-8859-1", "ISO-8859-2", - test_latin1, test_latin2, pool); - retcode |= one_test("ISO-8859-2", "ISO-8859-1", - test_latin2, test_latin1, pool); - - /* 4. Transformation using charset aliases */ - retcode |= one_test("UTF-8", "UTF-7", test_utf8, test_utf7, pool); - retcode |= one_test("UTF-7", "UTF-8", test_utf7, test_utf8, pool); - - return retcode; -} diff --git a/libs/apr-util/test/testxml.c b/libs/apr-util/test/testxml.c deleted file mode 100644 index 9808f21065..0000000000 --- a/libs/apr-util/test/testxml.c +++ /dev/null @@ -1,219 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_general.h" -#include "apr_xml.h" - -#if APR_HAVE_STDLIB_H -#include /* for exit() */ -#endif - -static const char *progname; -static const char *usage = "%s [xmlfile]\nIt will create " - "a dummy XML file if none is supplied"; -/* - * If our platform knows about the tmpnam() external buffer size, create - * a buffer to pass in. This is needed in a threaded environment, or - * one that thinks it is (like HP-UX). - */ - -#ifdef L_tmpnam -static char tname_buf[L_tmpnam]; -#else -static char *tname_buf = NULL; -#endif - -static apr_status_t create_dummy_file_error(apr_pool_t *p, apr_file_t **fd) -{ - apr_status_t rv; - char *tmpfile; - int i; - apr_off_t off = 0L; - tmpfile = tmpnam(tname_buf); - - if ((tmpfile == NULL) || (*tmpfile == '\0')) { - fprintf(stderr, "unable to generate temporary filename\n"); - if (errno == 0) { - errno = ENOENT; - } - perror("tmpnam"); - return APR_ENOENT; - } - rv = apr_file_open(fd, tmpfile, APR_CREATE|APR_TRUNCATE|APR_DELONCLOSE| - APR_READ|APR_WRITE|APR_EXCL, APR_OS_DEFAULT, p); - - if (rv != APR_SUCCESS) - return rv; - rv = apr_file_puts("\n" - "\n", *fd); - if (rv != APR_SUCCESS) - return rv; - - for (i = 0; i < 5000; i++) { - rv = apr_file_puts("yummy\n", *fd); - if (rv != APR_SUCCESS) - return rv; - } - rv = apr_file_puts("\n", *fd); - if (rv != APR_SUCCESS) - return rv; - - return apr_file_seek(*fd, APR_SET, &off); -} - -static apr_status_t create_dummy_file(apr_pool_t *p, apr_file_t **fd) -{ - apr_status_t rv; - char *tmpfile; - int i; - apr_off_t off = 0L; - tmpfile = tmpnam(tname_buf); - - if ((tmpfile == NULL) || (*tmpfile == '\0')) { - fprintf(stderr, "unable to generate temporary filename\n"); - if (errno == 0) { - errno = ENOENT; - } - perror("tmpnam"); - return APR_ENOENT; - } - rv = apr_file_open(fd, tmpfile, APR_CREATE|APR_TRUNCATE|APR_DELONCLOSE| - APR_READ|APR_WRITE|APR_EXCL, APR_OS_DEFAULT, p); - - if (rv != APR_SUCCESS) - return rv; - rv = apr_file_puts("\n" - "\n", *fd); - if (rv != APR_SUCCESS) - return rv; - - for (i = 0; i < 5000; i++) { - rv = apr_file_puts("yummy\n", *fd); - if (rv != APR_SUCCESS) - return rv; - } - rv = apr_file_puts("\n", *fd); - if (rv != APR_SUCCESS) - return rv; - - rv = apr_file_seek(*fd, APR_SET, &off); - return rv; -} - -static void dump_xml(apr_xml_elem *e, int level) -{ - apr_xml_attr *a; - apr_xml_elem *ec; - - printf("%d: element %s\n", level, e->name); - if (e->attr) { - a = e->attr; - printf("%d:\tattrs\t", level); - while (a) { - printf("%s=%s\t", a->name, a->value); - a = a->next; - } - printf("\n"); - } - if (e->first_child) { - ec = e->first_child; - while (ec) { - dump_xml(ec, level + 1); - ec = ec->next; - } - } -} - -static void oops(const char *s1, const char *s2, apr_status_t rv) -{ - if (progname) - fprintf(stderr, "%s: ", progname); - fprintf(stderr, s1, s2); - if (rv != APR_SUCCESS) { - char buf[120]; - - fprintf(stderr, " (%s)", apr_strerror(rv, buf, sizeof buf)); - } - fprintf(stderr, "\n"); - exit(1); -} - -int main(int argc, const char *const * argv) -{ - apr_pool_t *pool; - apr_file_t *fd; - apr_xml_parser *parser; - apr_xml_doc *doc; - apr_status_t rv; - char errbuf[2000]; - char errbufXML[2000]; - - (void) apr_initialize(); - apr_pool_create(&pool, NULL); - progname = argv[0]; - if (argc == 1) { - rv = create_dummy_file(pool, &fd); - if (rv != APR_SUCCESS) { - oops("cannot create dummy file", "oops", rv); - } - } - else { - if (argc == 2) { - rv = apr_file_open(&fd, argv[1], APR_READ, APR_OS_DEFAULT, pool); - if (rv != APR_SUCCESS) { - oops("cannot open: %s", argv[1], rv); - } - } - else { - oops("usage: %s", usage, 0); - } - } - rv = apr_xml_parse_file(pool, &parser, &doc, fd, 2000); - if (rv != APR_SUCCESS) { - fprintf(stderr, "APR Error %s\nXML Error: %s\n", - apr_strerror(rv, errbuf, sizeof(errbuf)), - apr_xml_parser_geterror(parser, errbufXML, sizeof(errbufXML))); - return rv; - } - dump_xml(doc->root, 0); - apr_file_close(fd); - if (argc == 1) { - rv = create_dummy_file_error(pool, &fd); - if (rv != APR_SUCCESS) { - oops("cannot create error dummy file", "oops", rv); - } - rv = apr_xml_parse_file(pool, &parser, &doc, fd, 2000); - if (rv != APR_SUCCESS) { - fprintf(stdout, "APR Error %s\nXML Error: %s " - "(EXPECTED) This is good.\n", - apr_strerror(rv, errbuf, sizeof(errbuf)), - apr_xml_parser_geterror(parser, errbufXML, sizeof(errbufXML))); - rv = APR_SUCCESS; /* reset the return code, as the test is supposed to get this error */ - } - else { - fprintf(stderr, "Expected an error, but didn't get one ;( "); - return APR_EGENERAL; - } - } - apr_pool_destroy(pool); - apr_terminate(); - return rv; -} diff --git a/libs/apr-util/uri/NWGNUmakefile b/libs/apr-util/uri/NWGNUmakefile deleted file mode 100644 index bf97c96f6e..0000000000 --- a/libs/apr-util/uri/NWGNUmakefile +++ /dev/null @@ -1,257 +0,0 @@ -# -# NWGNUmakefile for GenUri.nlm (Apache2) -# Declare the sub-directories to be built here -# - -SUBDIRS = \ - $(EOLIST) - -# -# Get the 'head' of the build environment. This includes default targets and -# paths to tools -# - -include $(APR_WORK)\build\NWGNUhead.inc - -# -# build this level's files - -# -# Make sure all needed macro's are defined -# - -# -# These directories will be at the beginning of the include list, followed by -# INCDIRS -# -XINCDIRS += \ - $(APR)/include/arch/NetWare \ - $(APR)/include \ - $(APRUTIL)/include \ - $(APRUTIL)/include/private \ - $(APRUTIL)/xml/expat/lib \ - $(EOLIST) - -# -# These flags will come after CFLAGS -# -XCFLAGS += \ - $(EOLIST) - -# -# These defines will come after DEFINES -# -XDEFINES += \ - $(EOLIST) - -# -# These flags will be added to the link.opt file -# -XLFLAGS += \ - $(EOLIST) - -# -# These values will be appended to the correct variables based on the value of -# RELEASE -# -ifeq "$(RELEASE)" "debug" -XINCDIRS += \ - $(EOLIST) - -XCFLAGS += \ - $(EOLIST) - -XDEFINES += \ - $(EOLIST) - -XLFLAGS += \ - $(EOLIST) -endif - -ifeq "$(RELEASE)" "noopt" -XINCDIRS += \ - $(EOLIST) - -XCFLAGS += \ - $(EOLIST) - -XDEFINES += \ - $(EOLIST) - -XLFLAGS += \ - $(EOLIST) -endif - -ifeq "$(RELEASE)" "release" -XINCDIRS += \ - $(EOLIST) - -XCFLAGS += \ - $(EOLIST) - -XDEFINES += \ - $(EOLIST) - -XLFLAGS += \ - $(EOLIST) -endif - -# -# These are used by the link target if an NLM is being generated -# This is used by the link 'name' directive to name the nlm. If left blank -# TARGET_nlm (see below) will be used. -# -NLM_NAME = Genuri - -# -# This is used by the link '-desc ' directive. -# If left blank, NLM_NAME will be used. -# -NLM_DESCRIPTION = Generate URI Delimiters - -# -# This is used by the '-threadname' directive. If left blank, -# NLM_NAME Thread will be used. -# -NLM_THREAD_NAME = genuri - -# -# If this is specified, it will override VERSION value in -# $(APR_WORK)\build\NWGNUenvironment.inc -# -NLM_VERSION = 1,0,0 - -# -# If this is specified, it will override the default of 64K -# -NLM_STACK_SIZE = 8192 - -# -# If this is specified it will be used by the link '-entry' directive -# -NLM_ENTRY_SYM =_LibCPrelude - -# -# If this is specified it will be used by the link '-exit' directive -# -NLM_EXIT_SYM =_LibCPostlude - -# -# If this is specified it will be used by the link '-check' directive -# -NLM_CHECK_SYM = - -# -# If this is specified it will be used by the link '-flags' directive -# -NLM_FLAGS = PSEUDOPREEMPTION - -# -# If this is specified it will be linked in with the XDCData option in the def -# file instead of the default of $(APR)/misc/netware/apr.xdc. XDCData can -# be disabled by setting APACHE_UNIPROC in the environment -# -XDCDATA = - -# -# Declare all target files (you must add your files here) -# - -# -# If there is an NLM target, put it here -# -TARGET_nlm = \ -$(OBJDIR)/Genuri.nlm \ - $(EOLIST) - -# -# If there is an LIB target, put it here -# -TARGET_lib = \ - $(EOLIST) - -# -# These are the OBJ files needed to create the NLM target above. -# Paths must all use the '/' character -# -FILES_nlm_objs = \ - $(OBJDIR)/gen_uri_delims.o \ - $(EOLIST) - -# -# These are the LIB files needed to create the NLM target above. -# These will be added as a library command in the link.opt file. -# -FILES_nlm_libs = \ - libcpre.o \ - $(EOLIST) - -# -# These are the modules that the above NLM target depends on to load. -# These will be added as a module command in the link.opt file. -# -FILES_nlm_modules = \ - Libc \ - $(EOLIST) - -# -# If the nlm has a msg file, put it's path here -# -FILE_nlm_msg = - -# -# If the nlm has a hlp file put it's path here -# -FILE_nlm_hlp = - -# -# If this is specified, it will override $(NWOS)\copyright.txt. -# -FILE_nlm_copyright = - -# -# Any additional imports go here -# -FILES_nlm_Ximports = \ - @libc.imp \ - $(EOLIST) - -# -# Any symbols exported to here -# -FILES_nlm_exports = \ - $(EOLIST) - -# -# These are the OBJ files needed to create the LIB target above. -# Paths must all use the '/' character -# -FILES_lib_objs = \ - $(EOLIST) - -# -# implement targets and dependancies (leave this section alone) -# - -libs :: $(OBJDIR) $(TARGET_lib) - -nlms :: libs $(TARGET_nlm) - -# -# Updated this target to create necessary directories and copy files to the -# correct place. (See $(APR_WORK)\build\NWGNUhead.inc for examples) -# -install :: nlms FORCE - -# -# Any specialized rules here -# - - -# -# Include the 'tail' makefile that has targets that depend on variables defined -# in this makefile -# - -include $(APR_WORK)\build\NWGNUtail.inc - diff --git a/libs/apr-util/uri/apr_uri.c b/libs/apr-util/uri/apr_uri.c deleted file mode 100644 index 3245c19a41..0000000000 --- a/libs/apr-util/uri/apr_uri.c +++ /dev/null @@ -1,462 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * apr_uri.c: URI related utility things - * - */ - -#include - -#include "apu.h" -#include "apr.h" -#include "apr_general.h" -#include "apr_strings.h" - -#define APR_WANT_STRFUNC -#include "apr_want.h" - -#include "apr_uri.h" - -typedef struct schemes_t schemes_t; - -/** Structure to store various schemes and their default ports */ -struct schemes_t { - /** The name of the scheme */ - const char *name; - /** The default port for the scheme */ - apr_port_t default_port; -}; - -/* Some WWW schemes and their default ports; this is basically /etc/services */ -/* This will become global when the protocol abstraction comes */ -/* As the schemes are searched by a linear search, */ -/* they are sorted by their expected frequency */ -static schemes_t schemes[] = -{ - {"http", APR_URI_HTTP_DEFAULT_PORT}, - {"ftp", APR_URI_FTP_DEFAULT_PORT}, - {"https", APR_URI_HTTPS_DEFAULT_PORT}, - {"gopher", APR_URI_GOPHER_DEFAULT_PORT}, - {"ldap", APR_URI_LDAP_DEFAULT_PORT}, - {"nntp", APR_URI_NNTP_DEFAULT_PORT}, - {"snews", APR_URI_SNEWS_DEFAULT_PORT}, - {"imap", APR_URI_IMAP_DEFAULT_PORT}, - {"pop", APR_URI_POP_DEFAULT_PORT}, - {"sip", APR_URI_SIP_DEFAULT_PORT}, - {"rtsp", APR_URI_RTSP_DEFAULT_PORT}, - {"wais", APR_URI_WAIS_DEFAULT_PORT}, - {"z39.50r", APR_URI_WAIS_DEFAULT_PORT}, - {"z39.50s", APR_URI_WAIS_DEFAULT_PORT}, - {"prospero", APR_URI_PROSPERO_DEFAULT_PORT}, - {"nfs", APR_URI_NFS_DEFAULT_PORT}, - {"tip", APR_URI_TIP_DEFAULT_PORT}, - {"acap", APR_URI_ACAP_DEFAULT_PORT}, - {"telnet", APR_URI_TELNET_DEFAULT_PORT}, - {"ssh", APR_URI_SSH_DEFAULT_PORT}, - { NULL, 0xFFFF } /* unknown port */ -}; - -APU_DECLARE(apr_port_t) apr_uri_port_of_scheme(const char *scheme_str) -{ - schemes_t *scheme; - - if (scheme_str) { - for (scheme = schemes; scheme->name != NULL; ++scheme) { - if (strcasecmp(scheme_str, scheme->name) == 0) { - return scheme->default_port; - } - } - } - return 0; -} - -/* Unparse a apr_uri_t structure to an URI string. - * Optionally suppress the password for security reasons. - */ -APU_DECLARE(char *) apr_uri_unparse(apr_pool_t *p, - const apr_uri_t *uptr, - unsigned flags) -{ - char *ret = ""; - - /* If suppressing the site part, omit both user name & scheme://hostname */ - if (!(flags & APR_URI_UNP_OMITSITEPART)) { - - /* Construct a "user:password@" string, honoring the passed - * APR_URI_UNP_ flags: */ - if (uptr->user || uptr->password) { - ret = apr_pstrcat(p, - (uptr->user && !(flags & APR_URI_UNP_OMITUSER)) - ? uptr->user : "", - (uptr->password && !(flags & APR_URI_UNP_OMITPASSWORD)) - ? ":" : "", - (uptr->password && !(flags & APR_URI_UNP_OMITPASSWORD)) - ? ((flags & APR_URI_UNP_REVEALPASSWORD) - ? uptr->password : "XXXXXXXX") - : "", - ((uptr->user && !(flags & APR_URI_UNP_OMITUSER)) || - (uptr->password && !(flags & APR_URI_UNP_OMITPASSWORD))) - ? "@" : "", - NULL); - } - - /* Construct scheme://site string */ - if (uptr->hostname) { - int is_default_port; - const char *lbrk = "", *rbrk = ""; - - if (strchr(uptr->hostname, ':')) { /* v6 literal */ - lbrk = "["; - rbrk = "]"; - } - - is_default_port = - (uptr->port_str == NULL || - uptr->port == 0 || - uptr->port == apr_uri_port_of_scheme(uptr->scheme)); - - if (uptr->scheme) { - ret = apr_pstrcat(p, - uptr->scheme, "://", ret, - lbrk, uptr->hostname, rbrk, - is_default_port ? "" : ":", - is_default_port ? "" : uptr->port_str, - NULL); - } - else { - /* A violation of RFC2396, but it is clear from section 3.2 - * that the : belongs above to the scheme, while // belongs - * to the authority, so include the authority prefix while - * omitting the "scheme:" that the user neglected to pass us. - */ - ret = apr_pstrcat(p, - "//", ret, lbrk, uptr->hostname, rbrk, - is_default_port ? "" : ":", - is_default_port ? "" : uptr->port_str, - NULL); - } - } - } - - /* Should we suppress all path info? */ - if (!(flags & APR_URI_UNP_OMITPATHINFO)) { - /* Append path, query and fragment strings: */ - ret = apr_pstrcat(p, - ret, - (uptr->path) - ? uptr->path : "", - (uptr->query && !(flags & APR_URI_UNP_OMITQUERY)) - ? "?" : "", - (uptr->query && !(flags & APR_URI_UNP_OMITQUERY)) - ? uptr->query : "", - (uptr->fragment && !(flags & APR_URI_UNP_OMITQUERY)) - ? "#" : NULL, - (uptr->fragment && !(flags & APR_URI_UNP_OMITQUERY)) - ? uptr->fragment : NULL, - NULL); - } - return ret; -} - -/* Here is the hand-optimized parse_uri_components(). There are some wild - * tricks we could pull in assembly language that we don't pull here... like we - * can do word-at-time scans for delimiter characters using the same technique - * that fast memchr()s use. But that would be way non-portable. -djg - */ - -/* We have a apr_table_t that we can index by character and it tells us if the - * character is one of the interesting delimiters. Note that we even get - * compares for NUL for free -- it's just another delimiter. - */ - -#define T_COLON 0x01 /* ':' */ -#define T_SLASH 0x02 /* '/' */ -#define T_QUESTION 0x04 /* '?' */ -#define T_HASH 0x08 /* '#' */ -#define T_NUL 0x80 /* '\0' */ - -#if APR_CHARSET_EBCDIC -/* Delimiter table for the EBCDIC character set */ -static const unsigned char uri_delims[256] = { - T_NUL,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,T_SLASH,0,0,0,0,0,0,0,0,0,0,0,0,0,T_QUESTION, - 0,0,0,0,0,0,0,0,0,0,T_COLON,T_HASH,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -}; -#else -/* Delimiter table for the ASCII character set */ -static const unsigned char uri_delims[256] = { - T_NUL,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,T_HASH,0,0,0,0,0,0,0,0,0,0,0,T_SLASH, - 0,0,0,0,0,0,0,0,0,0,T_COLON,0,0,0,0,T_QUESTION, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -}; -#endif - - -/* it works like this: - if (uri_delims[ch] & NOTEND_foobar) { - then we're not at a delimiter for foobar - } -*/ - -/* Note that we optimize the scheme scanning here, we cheat and let the - * compiler know that it doesn't have to do the & masking. - */ -#define NOTEND_SCHEME (0xff) -#define NOTEND_HOSTINFO (T_SLASH | T_QUESTION | T_HASH | T_NUL) -#define NOTEND_PATH (T_QUESTION | T_HASH | T_NUL) - -/* parse_uri_components(): - * Parse a given URI, fill in all supplied fields of a uri_components - * structure. This eliminates the necessity of extracting host, port, - * path, query info repeatedly in the modules. - * Side effects: - * - fills in fields of uri_components *uptr - * - none on any of the r->* fields - */ -APU_DECLARE(apr_status_t) apr_uri_parse(apr_pool_t *p, const char *uri, - apr_uri_t *uptr) -{ - const char *s; - const char *s1; - const char *hostinfo; - char *endstr; - int port; - int v6_offset1 = 0, v6_offset2 = 0; - - /* Initialize the structure. parse_uri() and parse_uri_components() - * can be called more than once per request. - */ - memset (uptr, '\0', sizeof(*uptr)); - uptr->is_initialized = 1; - - /* We assume the processor has a branch predictor like most -- - * it assumes forward branches are untaken and backwards are taken. That's - * the reason for the gotos. -djg - */ - if (uri[0] == '/') { - /* RFC2396 #4.3 says that two leading slashes mean we have an - * authority component, not a path! Fixing this looks scary - * with the gotos here. But if the existing logic is valid, - * then presumably a goto pointing to deal_with_authority works. - * - * RFC2396 describes this as resolving an ambiguity. In the - * case of three or more slashes there would seem to be no - * ambiguity, so it is a path after all. - */ - if (uri[1] == '/' && uri[2] != '/') { - s = uri + 2 ; - goto deal_with_authority ; - } - -deal_with_path: - /* we expect uri to point to first character of path ... remember - * that the path could be empty -- http://foobar?query for example - */ - s = uri; - while ((uri_delims[*(unsigned char *)s] & NOTEND_PATH) == 0) { - ++s; - } - if (s != uri) { - uptr->path = apr_pstrmemdup(p, uri, s - uri); - } - if (*s == 0) { - return APR_SUCCESS; - } - if (*s == '?') { - ++s; - s1 = strchr(s, '#'); - if (s1) { - uptr->fragment = apr_pstrdup(p, s1 + 1); - uptr->query = apr_pstrmemdup(p, s, s1 - s); - } - else { - uptr->query = apr_pstrdup(p, s); - } - return APR_SUCCESS; - } - /* otherwise it's a fragment */ - uptr->fragment = apr_pstrdup(p, s + 1); - return APR_SUCCESS; - } - - /* find the scheme: */ - s = uri; - while ((uri_delims[*(unsigned char *)s] & NOTEND_SCHEME) == 0) { - ++s; - } - /* scheme must be non-empty and followed by :// */ - if (s == uri || s[0] != ':' || s[1] != '/' || s[2] != '/') { - goto deal_with_path; /* backwards predicted taken! */ - } - - uptr->scheme = apr_pstrmemdup(p, uri, s - uri); - s += 3; - -deal_with_authority: - hostinfo = s; - while ((uri_delims[*(unsigned char *)s] & NOTEND_HOSTINFO) == 0) { - ++s; - } - uri = s; /* whatever follows hostinfo is start of uri */ - uptr->hostinfo = apr_pstrmemdup(p, hostinfo, uri - hostinfo); - - /* If there's a username:password@host:port, the @ we want is the last @... - * too bad there's no memrchr()... For the C purists, note that hostinfo - * is definately not the first character of the original uri so therefore - * &hostinfo[-1] < &hostinfo[0] ... and this loop is valid C. - */ - do { - --s; - } while (s >= hostinfo && *s != '@'); - if (s < hostinfo) { - /* again we want the common case to be fall through */ -deal_with_host: - /* We expect hostinfo to point to the first character of - * the hostname. If there's a port it is the first colon, - * except with IPv6. - */ - if (*hostinfo == '[') { - v6_offset1 = 1; - v6_offset2 = 2; - s = memchr(hostinfo, ']', uri - hostinfo); - if (s == NULL) { - return APR_EGENERAL; - } - if (*++s != ':') { - s = NULL; /* no port */ - } - } - else { - s = memchr(hostinfo, ':', uri - hostinfo); - } - if (s == NULL) { - /* we expect the common case to have no port */ - uptr->hostname = apr_pstrmemdup(p, - hostinfo + v6_offset1, - uri - hostinfo - v6_offset2); - goto deal_with_path; - } - uptr->hostname = apr_pstrmemdup(p, - hostinfo + v6_offset1, - s - hostinfo - v6_offset2); - ++s; - uptr->port_str = apr_pstrmemdup(p, s, uri - s); - if (uri != s) { - port = strtol(uptr->port_str, &endstr, 10); - uptr->port = port; - if (*endstr == '\0') { - goto deal_with_path; - } - /* Invalid characters after ':' found */ - return APR_EGENERAL; - } - uptr->port = apr_uri_port_of_scheme(uptr->scheme); - goto deal_with_path; - } - - /* first colon delimits username:password */ - s1 = memchr(hostinfo, ':', s - hostinfo); - if (s1) { - uptr->user = apr_pstrmemdup(p, hostinfo, s1 - hostinfo); - ++s1; - uptr->password = apr_pstrmemdup(p, s1, s - s1); - } - else { - uptr->user = apr_pstrmemdup(p, hostinfo, s - hostinfo); - } - hostinfo = s + 1; - goto deal_with_host; -} - -/* Special case for CONNECT parsing: it comes with the hostinfo part only */ -/* See the INTERNET-DRAFT document "Tunneling SSL Through a WWW Proxy" - * currently at http://www.mcom.com/newsref/std/tunneling_ssl.html - * for the format of the "CONNECT host:port HTTP/1.0" request - */ -APU_DECLARE(apr_status_t) apr_uri_parse_hostinfo(apr_pool_t *p, - const char *hostinfo, - apr_uri_t *uptr) -{ - const char *s; - char *endstr; - const char *rsb; - int v6_offset1 = 0; - - /* Initialize the structure. parse_uri() and parse_uri_components() - * can be called more than once per request. - */ - memset(uptr, '\0', sizeof(*uptr)); - uptr->is_initialized = 1; - uptr->hostinfo = apr_pstrdup(p, hostinfo); - - /* We expect hostinfo to point to the first character of - * the hostname. There must be a port, separated by a colon - */ - if (*hostinfo == '[') { - if ((rsb = strchr(hostinfo, ']')) == NULL || - *(rsb + 1) != ':') { - return APR_EGENERAL; - } - /* literal IPv6 address */ - s = rsb + 1; - ++hostinfo; - v6_offset1 = 1; - } - else { - s = strchr(hostinfo, ':'); - } - if (s == NULL) { - return APR_EGENERAL; - } - uptr->hostname = apr_pstrndup(p, hostinfo, s - hostinfo - v6_offset1); - ++s; - uptr->port_str = apr_pstrdup(p, s); - if (*s != '\0') { - uptr->port = (unsigned short) strtol(uptr->port_str, &endstr, 10); - if (*endstr == '\0') { - return APR_SUCCESS; - } - /* Invalid characters after ':' found */ - } - return APR_EGENERAL; -} diff --git a/libs/apr-util/xlate/xlate.c b/libs/apr-util/xlate/xlate.c deleted file mode 100644 index 5e955ef258..0000000000 --- a/libs/apr-util/xlate/xlate.c +++ /dev/null @@ -1,458 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apu.h" -#include "apu_config.h" -#include "apr_lib.h" -#include "apr_strings.h" -#include "apr_portable.h" -#include "apr_xlate.h" - -/* If no implementation is available, don't generate code here since - * apr_xlate.h emitted macros which return APR_ENOTIMPL. - */ - -#if APR_HAS_XLATE - -#ifdef HAVE_STDDEF_H -#include /* for NULL */ -#endif -#if APR_HAVE_STRING_H -#include -#endif -#if APR_HAVE_STRINGS_H -#include -#endif -#ifdef HAVE_ICONV_H -#include -#endif -#if APU_HAVE_APR_ICONV -#include -#endif - -#if defined(APU_ICONV_INBUF_CONST) || APU_HAVE_APR_ICONV -#define ICONV_INBUF_TYPE const char ** -#else -#define ICONV_INBUF_TYPE char ** -#endif - -#ifndef min -#define min(x,y) ((x) <= (y) ? (x) : (y)) -#endif - -struct apr_xlate_t { - apr_pool_t *pool; - char *frompage; - char *topage; - char *sbcs_table; -#if APU_HAVE_ICONV - iconv_t ich; -#elif APU_HAVE_APR_ICONV - apr_iconv_t ich; -#endif -}; - - -static const char *handle_special_names(const char *page, apr_pool_t *pool) -{ - if (page == APR_DEFAULT_CHARSET) { - return apr_os_default_encoding(pool); - } - else if (page == APR_LOCALE_CHARSET) { - return apr_os_locale_encoding(pool); - } - else { - return page; - } -} - -static apr_status_t apr_xlate_cleanup(void *convset) -{ - apr_xlate_t *old = convset; - -#if APU_HAVE_APR_ICONV - if (old->ich != (apr_iconv_t)-1) { - return apr_iconv_close(old->ich, old->pool); - } - -#elif APU_HAVE_ICONV - if (old->ich != (iconv_t)-1) { - if (iconv_close(old->ich)) { - int rv = errno; - - /* Sometimes, iconv is not good about setting errno. */ - return rv ? rv : APR_EINVAL; - } - } -#endif - - return APR_SUCCESS; -} - -#if APU_HAVE_ICONV -static void check_sbcs(apr_xlate_t *convset) -{ - char inbuf[256], outbuf[256]; - char *inbufptr = inbuf; - char *outbufptr = outbuf; - apr_size_t inbytes_left, outbytes_left; - int i; - apr_size_t translated; - - for (i = 0; i < sizeof(inbuf); i++) { - inbuf[i] = i; - } - - inbytes_left = outbytes_left = sizeof(inbuf); - translated = iconv(convset->ich, (ICONV_INBUF_TYPE)&inbufptr, - &inbytes_left, &outbufptr, &outbytes_left); - - if (translated != (apr_size_t)-1 - && inbytes_left == 0 - && outbytes_left == 0) { - /* hurray... this is simple translation; save the table, - * close the iconv descriptor - */ - - convset->sbcs_table = apr_palloc(convset->pool, sizeof(outbuf)); - memcpy(convset->sbcs_table, outbuf, sizeof(outbuf)); - iconv_close(convset->ich); - convset->ich = (iconv_t)-1; - - /* TODO: add the table to the cache */ - } - else { - /* reset the iconv descriptor, since it's now in an undefined - * state. */ - iconv_close(convset->ich); - convset->ich = iconv_open(convset->topage, convset->frompage); - } -} -#elif APU_HAVE_APR_ICONV -static void check_sbcs(apr_xlate_t *convset) -{ - char inbuf[256], outbuf[256]; - char *inbufptr = inbuf; - char *outbufptr = outbuf; - apr_size_t inbytes_left, outbytes_left; - int i; - apr_size_t translated; - apr_status_t rv; - - for (i = 0; i < sizeof(inbuf); i++) { - inbuf[i] = i; - } - - inbytes_left = outbytes_left = sizeof(inbuf); - rv = apr_iconv(convset->ich, (ICONV_INBUF_TYPE)&inbufptr, - &inbytes_left, &outbufptr, &outbytes_left, - &translated); - - if ((rv == APR_SUCCESS) - && (translated != (apr_size_t)-1) - && inbytes_left == 0 - && outbytes_left == 0) { - /* hurray... this is simple translation; save the table, - * close the iconv descriptor - */ - - convset->sbcs_table = apr_palloc(convset->pool, sizeof(outbuf)); - memcpy(convset->sbcs_table, outbuf, sizeof(outbuf)); - apr_iconv_close(convset->ich, convset->pool); - convset->ich = (apr_iconv_t)-1; - - /* TODO: add the table to the cache */ - } - else { - /* reset the iconv descriptor, since it's now in an undefined - * state. */ - apr_iconv_close(convset->ich, convset->pool); - rv = apr_iconv_open(convset->topage, convset->frompage, - convset->pool, &convset->ich); - } -} -#endif /* APU_HAVE_APR_ICONV */ - -static void make_identity_table(apr_xlate_t *convset) -{ - int i; - - convset->sbcs_table = apr_palloc(convset->pool, 256); - for (i = 0; i < 256; i++) - convset->sbcs_table[i] = i; -} - -APU_DECLARE(apr_status_t) apr_xlate_open(apr_xlate_t **convset, - const char *topage, - const char *frompage, - apr_pool_t *pool) -{ - apr_status_t rv; - apr_xlate_t *new; - int found = 0; - - *convset = NULL; - - topage = handle_special_names(topage, pool); - frompage = handle_special_names(frompage, pool); - - new = (apr_xlate_t *)apr_pcalloc(pool, sizeof(apr_xlate_t)); - if (!new) { - return APR_ENOMEM; - } - - new->pool = pool; - new->topage = apr_pstrdup(pool, topage); - new->frompage = apr_pstrdup(pool, frompage); - if (!new->topage || !new->frompage) { - return APR_ENOMEM; - } - -#ifdef TODO - /* search cache of codepage pairs; we may be able to avoid the - * expensive iconv_open() - */ - - set found to non-zero if found in the cache -#endif - - if ((! found) && (strcmp(topage, frompage) == 0)) { - /* to and from are the same */ - found = 1; - make_identity_table(new); - } - -#if APU_HAVE_APR_ICONV - if (!found) { - rv = apr_iconv_open(topage, frompage, pool, &new->ich); - if (rv != APR_SUCCESS) { - return rv; - } - found = 1; - check_sbcs(new); - } else - new->ich = (apr_iconv_t)-1; - -#elif APU_HAVE_ICONV - if (!found) { - new->ich = iconv_open(topage, frompage); - if (new->ich == (iconv_t)-1) { - int rv = errno; - /* Sometimes, iconv is not good about setting errno. */ - return rv ? rv : APR_EINVAL; - } - found = 1; - check_sbcs(new); - } else - new->ich = (iconv_t)-1; -#endif /* APU_HAVE_ICONV */ - - if (found) { - *convset = new; - apr_pool_cleanup_register(pool, (void *)new, apr_xlate_cleanup, - apr_pool_cleanup_null); - rv = APR_SUCCESS; - } - else { - rv = APR_EINVAL; /* iconv() would return EINVAL if it - couldn't handle the pair */ - } - - return rv; -} - -APU_DECLARE(apr_status_t) apr_xlate_sb_get(apr_xlate_t *convset, int *onoff) -{ - *onoff = convset->sbcs_table != NULL; - return APR_SUCCESS; -} - -APU_DECLARE(apr_status_t) apr_xlate_conv_buffer(apr_xlate_t *convset, - const char *inbuf, - apr_size_t *inbytes_left, - char *outbuf, - apr_size_t *outbytes_left) -{ - apr_status_t status = APR_SUCCESS; - -#if APU_HAVE_APR_ICONV - if (convset->ich != (apr_iconv_t)-1) { - const char *inbufptr = inbuf; - apr_size_t translated; - char *outbufptr = outbuf; - status = apr_iconv(convset->ich, &inbufptr, inbytes_left, - &outbufptr, outbytes_left, &translated); - - /* If everything went fine but we ran out of buffer, don't - * report it as an error. Caller needs to look at the two - * bytes-left values anyway. - * - * There are three expected cases where rc is -1. In each of - * these cases, *inbytes_left != 0. - * a) the non-error condition where we ran out of output - * buffer - * b) the non-error condition where we ran out of input (i.e., - * the last input character is incomplete) - * c) the error condition where the input is invalid - */ - switch (status) { - - case E2BIG: /* out of space on output */ - status = 0; /* change table lookup code below if you - make this an error */ - break; - - case EINVAL: /* input character not complete (yet) */ - status = APR_INCOMPLETE; - break; - - case EILSEQ: /* bad input byte */ - status = APR_EINVAL; - break; - - /* Sometimes, iconv is not good about setting errno. */ - case 0: - if (*inbytes_left) - status = APR_INCOMPLETE; - break; - - default: - break; - } - } - else - -#elif APU_HAVE_ICONV - if (convset->ich != (iconv_t)-1) { - const char *inbufptr = inbuf; - char *outbufptr = outbuf; - apr_size_t translated; - translated = iconv(convset->ich, (ICONV_INBUF_TYPE)&inbufptr, - inbytes_left, &outbufptr, outbytes_left); - - /* If everything went fine but we ran out of buffer, don't - * report it as an error. Caller needs to look at the two - * bytes-left values anyway. - * - * There are three expected cases where rc is -1. In each of - * these cases, *inbytes_left != 0. - * a) the non-error condition where we ran out of output - * buffer - * b) the non-error condition where we ran out of input (i.e., - * the last input character is incomplete) - * c) the error condition where the input is invalid - */ - if (translated == (apr_size_t)-1) { - int rv = errno; - switch (rv) { - - case E2BIG: /* out of space on output */ - status = 0; /* change table lookup code below if you - make this an error */ - break; - - case EINVAL: /* input character not complete (yet) */ - status = APR_INCOMPLETE; - break; - - case EILSEQ: /* bad input byte */ - status = APR_EINVAL; - break; - - /* Sometimes, iconv is not good about setting errno. */ - case 0: - status = APR_INCOMPLETE; - break; - - default: - status = rv; - break; - } - } - } - else -#endif - - if (inbuf) { - int to_convert = min(*inbytes_left, *outbytes_left); - int converted = to_convert; - char *table = convset->sbcs_table; - - while (to_convert) { - *outbuf = table[(unsigned char)*inbuf]; - ++outbuf; - ++inbuf; - --to_convert; - } - *inbytes_left -= converted; - *outbytes_left -= converted; - } - - return status; -} - -APU_DECLARE(apr_int32_t) apr_xlate_conv_byte(apr_xlate_t *convset, - unsigned char inchar) -{ - if (convset->sbcs_table) { - return convset->sbcs_table[inchar]; - } - else { - return -1; - } -} - -APU_DECLARE(apr_status_t) apr_xlate_close(apr_xlate_t *convset) -{ - return apr_pool_cleanup_run(convset->pool, convset, apr_xlate_cleanup); -} - -#else /* !APR_HAS_XLATE */ - -APU_DECLARE(apr_status_t) apr_xlate_open(apr_xlate_t **convset, - const char *topage, - const char *frompage, - apr_pool_t *pool) -{ - return APR_ENOTIMPL; -} - -APU_DECLARE(apr_status_t) apr_xlate_sb_get(apr_xlate_t *convset, int *onoff) -{ - return APR_ENOTIMPL; -} - -APU_DECLARE(apr_int32_t) apr_xlate_conv_byte(apr_xlate_t *convset, - unsigned char inchar) -{ - return (-1); -} - -APU_DECLARE(apr_status_t) apr_xlate_conv_buffer(apr_xlate_t *convset, - const char *inbuf, - apr_size_t *inbytes_left, - char *outbuf, - apr_size_t *outbytes_left) -{ - return APR_ENOTIMPL; -} - -APU_DECLARE(apr_status_t) apr_xlate_close(apr_xlate_t *convset) -{ - return APR_ENOTIMPL; -} - -#endif /* APR_HAS_XLATE */ diff --git a/libs/apr-util/xml/NWGNUmakefile b/libs/apr-util/xml/NWGNUmakefile deleted file mode 100644 index 5f85964f6c..0000000000 --- a/libs/apr-util/xml/NWGNUmakefile +++ /dev/null @@ -1,258 +0,0 @@ -# -# Declare the sub-directories to be built here -# - -SUBDIRS = \ - $(EOLIST) - -# -# Get the 'head' of the build environment. This includes default targets and -# paths to tools -# - -include $(APR_WORK)\build\NWGNUhead.inc - -# -# build this level's files - -# -# Make sure all needed macro's are defined -# - -# -# These directories will be at the beginning of the include list, followed by -# INCDIRS -# -XINCDIRS += \ - $(APR)/include \ - $(APR)/include/arch/NetWare \ - $(APRUTIL)/include \ - $(APRUTIL)/uri \ - $(APRUTIL)/dbm/sdbm \ - $(APRUTIL)/include/private \ - $(APRUTIL)/xml/expat/lib \ - $(EOLIST) - -# -# These flags will come after CFLAGS -# -XCFLAGS += \ - $(EOLIST) - -# -# These defines will come after DEFINES -# -XDEFINES += \ - $(EOLIST) - -# -# These flags will be added to the link.opt file -# -XLFLAGS += \ - $(EOLIST) - -# -# These values will be appended to the correct variables based on the value of -# RELEASE -# -ifeq "$(RELEASE)" "debug" -XINCDIRS += \ - $(EOLIST) - -XCFLAGS += \ - $(EOLIST) - -XDEFINES += \ - $(EOLIST) - -XLFLAGS += \ - $(EOLIST) -endif - -ifeq "$(RELEASE)" "noopt" -XINCDIRS += \ - $(EOLIST) - -XCFLAGS += \ - $(EOLIST) - -XDEFINES += \ - $(EOLIST) - -XLFLAGS += \ - $(EOLIST) -endif - -ifeq "$(RELEASE)" "release" -XINCDIRS += \ - $(EOLIST) - -XCFLAGS += \ - $(EOLIST) - -XDEFINES += \ - $(EOLIST) - -XLFLAGS += \ - $(EOLIST) -endif - -# -# These are used by the link target if an NLM is being generated -# This is used by the link 'name' directive to name the nlm. If left blank -# TARGET_nlm (see below) will be used. -# -NLM_NAME = - -# -# This is used by the link '-desc ' directive. -# If left blank, NLM_NAME will be used. -# -NLM_DESCRIPTION = - -# -# This is used by the '-threadname' directive. If left blank, -# NLM_NAME Thread will be used. -# -NLM_THREAD_NAME = -# -# If this is specified, it will override VERSION value in -# $(APR_WORK)\build\NWGNUenvironment.inc -# -NLM_VERSION = - -# -# If this is specified, it will override the default of 64K -# -NLM_STACK_SIZE = - -# -# If this is specified it will be used by the link '-entry' directive -# -NLM_ENTRY_SYM = - -# -# If this is specified it will be used by the link '-exit' directive -# -NLM_EXIT_SYM = - -# -# If this is specified it will be used by the link '-check' directive -# -NLM_CHECK_SYM = - -# -# If this is specified it will be used by the link '-flags' directive -# -NLM_FLAGS = - -# -# If this is specified it will be linked in with the XDCData option in the def -# file instead of the default of $(APR)/misc/netware/apache.xdc. XDCData can -# be disabled by setting APACHE_UNIPROC in the environment -# -XDCDATA = - -# -# Declare all target files (you must add your files here) -# - -# -# If there is an NLM target, put it here -# -TARGET_nlm = \ - $(EOLIST) - -# -# If there is an LIB target, put it here -# -TARGET_lib = \ - $(OBJDIR)/xmllib.lib \ - $(EOLIST) - -# -# These are the OBJ files needed to create the NLM target above. -# Paths must all use the '/' character -# -FILES_nlm_objs = \ - $(EOLIST) - -# -# These are the LIB files needed to create the NLM target above. -# These will be added as a library command in the link.opt file. -# -FILES_nlm_libs = \ - $(EOLIST) - -# -# These are the modules that the above NLM target depends on to load. -# These will be added as a module command in the link.opt file. -# -FILES_nlm_modules = \ - $(EOLIST) - -# -# If the nlm has a msg file, put it's path here -# -FILE_nlm_msg = - -# -# If the nlm has a hlp file put it's path here -# -FILE_nlm_hlp = - -# -# If this is specified, it will override the default copyright. -# -FILE_nlm_copyright = - -# -# Any additional imports go here -# -FILES_nlm_Ximports = \ - $(EOLIST) - -# -# Any symbols exported to here -# -FILES_nlm_exports = \ - $(EOLIST) - -# -# These are the OBJ files needed to create the LIB target above. -# Paths must all use the '/' character -# -FILES_lib_objs = \ - $(OBJDIR)/apr_xml.o \ - $(OBJDIR)/xmlparse.o \ - $(OBJDIR)/xmlrole.o \ - $(OBJDIR)/xmltok.o \ - $(EOLIST) - -# -# implement targets and dependancies (leave this section alone) -# - -libs :: $(OBJDIR) $(TARGET_lib) - -nlms :: libs $(TARGET_nlm) - -# -# Updated this target to create necessary directories and copy files to the -# correct place. (See $(APR_WORK)\build\NWGNUhead.inc for examples) -# -install :: nlms FORCE - -# -# Any specialized rules here -# - -vpath %.c expat/lib - -# -# Include the 'tail' makefile that has targets that depend on variables defined -# in this makefile -# - -include $(APR_WORK)\build\NWGNUtail.inc - diff --git a/libs/apr-util/xml/apr_xml.c b/libs/apr-util/xml/apr_xml.c deleted file mode 100644 index a05348d60f..0000000000 --- a/libs/apr-util/xml/apr_xml.c +++ /dev/null @@ -1,976 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr.h" -#include "apr_strings.h" - -#define APR_WANT_STDIO /* for sprintf() */ -#define APR_WANT_STRFUNC -#include "apr_want.h" - -#include "apr_xml.h" - -#include "apu_config.h" - -#ifdef APR_HAVE_OLD_EXPAT -#include "xmlparse.h" -#else -#include "expat.h" -#endif - -#define DEBUG_CR "\r\n" - -static const char APR_KW_xmlns[] = { 0x78, 0x6D, 0x6C, 0x6E, 0x73, '\0' }; -static const char APR_KW_xmlns_lang[] = { 0x78, 0x6D, 0x6C, 0x3A, 0x6C, 0x61, 0x6E, 0x67, '\0' }; -static const char APR_KW_DAV[] = { 0x44, 0x41, 0x56, 0x3A, '\0' }; - -/* errors related to namespace processing */ -#define APR_XML_NS_ERROR_UNKNOWN_PREFIX (-1000) -#define APR_XML_NS_ERROR_INVALID_DECL (-1001) - -/* test for a namespace prefix that begins with [Xx][Mm][Ll] */ -#define APR_XML_NS_IS_RESERVED(name) \ - ( (name[0] == 0x58 || name[0] == 0x78) && \ - (name[1] == 0x4D || name[1] == 0x6D) && \ - (name[2] == 0x4C || name[2] == 0x6C) ) - - -/* the real (internal) definition of the parser context */ -struct apr_xml_parser { - apr_xml_doc *doc; /* the doc we're parsing */ - apr_pool_t *p; /* the pool we allocate from */ - apr_xml_elem *cur_elem; /* current element */ - - int error; /* an error has occurred */ -#define APR_XML_ERROR_EXPAT 1 -#define APR_XML_ERROR_PARSE_DONE 2 -/* also: public APR_XML_NS_ERROR_* values (if any) */ - - XML_Parser xp; /* the actual (Expat) XML parser */ - enum XML_Error xp_err; /* stored Expat error code */ -}; - -/* struct for scoping namespace declarations */ -typedef struct apr_xml_ns_scope { - const char *prefix; /* prefix used for this ns */ - int ns; /* index into namespace table */ - int emptyURI; /* the namespace URI is the empty string */ - struct apr_xml_ns_scope *next; /* next scoped namespace */ -} apr_xml_ns_scope; - - -/* return namespace table index for a given prefix */ -static int find_prefix(apr_xml_parser *parser, const char *prefix) -{ - apr_xml_elem *elem = parser->cur_elem; - - /* - ** Walk up the tree, looking for a namespace scope that defines this - ** prefix. - */ - for (; elem; elem = elem->parent) { - apr_xml_ns_scope *ns_scope; - - for (ns_scope = elem->ns_scope; ns_scope; ns_scope = ns_scope->next) { - if (strcmp(prefix, ns_scope->prefix) == 0) { - if (ns_scope->emptyURI) { - /* - ** It is possible to set the default namespace to an - ** empty URI string; this resets the default namespace - ** to mean "no namespace." We just found the prefix - ** refers to an empty URI, so return "no namespace." - */ - return APR_XML_NS_NONE; - } - - return ns_scope->ns; - } - } - } - - /* - * If the prefix is empty (""), this means that a prefix was not - * specified in the element/attribute. The search that was performed - * just above did not locate a default namespace URI (which is stored - * into ns_scope with an empty prefix). This means the element/attribute - * has "no namespace". We have a reserved value for this. - */ - if (*prefix == '\0') { - return APR_XML_NS_NONE; - } - - /* not found */ - return APR_XML_NS_ERROR_UNKNOWN_PREFIX; -} - -static void start_handler(void *userdata, const char *name, const char **attrs) -{ - apr_xml_parser *parser = userdata; - apr_xml_elem *elem; - apr_xml_attr *attr; - apr_xml_attr *prev; - char *colon; - const char *quoted; - char *elem_name; - - /* punt once we find an error */ - if (parser->error) - return; - - elem = apr_pcalloc(parser->p, sizeof(*elem)); - - /* prep the element */ - elem->name = elem_name = apr_pstrdup(parser->p, name); - - /* fill in the attributes (note: ends up in reverse order) */ - while (*attrs) { - attr = apr_palloc(parser->p, sizeof(*attr)); - attr->name = apr_pstrdup(parser->p, *attrs++); - attr->value = apr_pstrdup(parser->p, *attrs++); - attr->next = elem->attr; - elem->attr = attr; - } - - /* hook the element into the tree */ - if (parser->cur_elem == NULL) { - /* no current element; this also becomes the root */ - parser->cur_elem = parser->doc->root = elem; - } - else { - /* this element appeared within the current elem */ - elem->parent = parser->cur_elem; - - /* set up the child/sibling links */ - if (elem->parent->last_child == NULL) { - /* no first child either */ - elem->parent->first_child = elem->parent->last_child = elem; - } - else { - /* hook onto the end of the parent's children */ - elem->parent->last_child->next = elem; - elem->parent->last_child = elem; - } - - /* this element is now the current element */ - parser->cur_elem = elem; - } - - /* scan the attributes for namespace declarations */ - for (prev = NULL, attr = elem->attr; - attr; - attr = attr->next) { - if (strncmp(attr->name, APR_KW_xmlns, 5) == 0) { - const char *prefix = &attr->name[5]; - apr_xml_ns_scope *ns_scope; - - /* test for xmlns:foo= form and xmlns= form */ - if (*prefix == 0x3A) { - /* a namespace prefix declaration must have a - non-empty value. */ - if (attr->value[0] == '\0') { - parser->error = APR_XML_NS_ERROR_INVALID_DECL; - return; - } - ++prefix; - } - else if (*prefix != '\0') { - /* advance "prev" since "attr" is still present */ - prev = attr; - continue; - } - - /* quote the URI before we ever start working with it */ - quoted = apr_xml_quote_string(parser->p, attr->value, 1); - - /* build and insert the new scope */ - ns_scope = apr_pcalloc(parser->p, sizeof(*ns_scope)); - ns_scope->prefix = prefix; - ns_scope->ns = apr_xml_insert_uri(parser->doc->namespaces, quoted); - ns_scope->emptyURI = *quoted == '\0'; - ns_scope->next = elem->ns_scope; - elem->ns_scope = ns_scope; - - /* remove this attribute from the element */ - if (prev == NULL) - elem->attr = attr->next; - else - prev->next = attr->next; - - /* Note: prev will not be advanced since we just removed "attr" */ - } - else if (strcmp(attr->name, APR_KW_xmlns_lang) == 0) { - /* save away the language (in quoted form) */ - elem->lang = apr_xml_quote_string(parser->p, attr->value, 1); - - /* remove this attribute from the element */ - if (prev == NULL) - elem->attr = attr->next; - else - prev->next = attr->next; - - /* Note: prev will not be advanced since we just removed "attr" */ - } - else { - /* advance "prev" since "attr" is still present */ - prev = attr; - } - } - - /* - ** If an xml:lang attribute didn't exist (lang==NULL), then copy the - ** language from the parent element (if present). - ** - ** NOTE: elem_size() *depends* upon this pointer equality. - */ - if (elem->lang == NULL && elem->parent != NULL) - elem->lang = elem->parent->lang; - - /* adjust the element's namespace */ - colon = strchr(elem_name, 0x3A); - if (colon == NULL) { - /* - * The element is using the default namespace, which will always - * be found. Either it will be "no namespace", or a default - * namespace URI has been specified at some point. - */ - elem->ns = find_prefix(parser, ""); - } - else if (APR_XML_NS_IS_RESERVED(elem->name)) { - elem->ns = APR_XML_NS_NONE; - } - else { - *colon = '\0'; - elem->ns = find_prefix(parser, elem->name); - elem->name = colon + 1; - - if (APR_XML_NS_IS_ERROR(elem->ns)) { - parser->error = elem->ns; - return; - } - } - - /* adjust all remaining attributes' namespaces */ - for (attr = elem->attr; attr; attr = attr->next) { - /* - * apr_xml_attr defines this as "const" but we dup'd it, so we - * know that we can change it. a bit hacky, but the existing - * structure def is best. - */ - char *attr_name = (char *)attr->name; - - colon = strchr(attr_name, 0x3A); - if (colon == NULL) { - /* - * Attributes do NOT use the default namespace. Therefore, - * we place them into the "no namespace" category. - */ - attr->ns = APR_XML_NS_NONE; - } - else if (APR_XML_NS_IS_RESERVED(attr->name)) { - attr->ns = APR_XML_NS_NONE; - } - else { - *colon = '\0'; - attr->ns = find_prefix(parser, attr->name); - attr->name = colon + 1; - - if (APR_XML_NS_IS_ERROR(attr->ns)) { - parser->error = attr->ns; - return; - } - } - } -} - -static void end_handler(void *userdata, const char *name) -{ - apr_xml_parser *parser = userdata; - - /* punt once we find an error */ - if (parser->error) - return; - - /* pop up one level */ - parser->cur_elem = parser->cur_elem->parent; -} - -static void cdata_handler(void *userdata, const char *data, int len) -{ - apr_xml_parser *parser = userdata; - apr_xml_elem *elem; - apr_text_header *hdr; - const char *s; - - /* punt once we find an error */ - if (parser->error) - return; - - elem = parser->cur_elem; - s = apr_pstrndup(parser->p, data, len); - - if (elem->last_child == NULL) { - /* no children yet. this cdata follows the start tag */ - hdr = &elem->first_cdata; - } - else { - /* child elements exist. this cdata follows the last child. */ - hdr = &elem->last_child->following_cdata; - } - - apr_text_append(parser->p, hdr, s); -} - -static apr_status_t cleanup_parser(void *ctx) -{ - apr_xml_parser *parser = ctx; - - XML_ParserFree(parser->xp); - parser->xp = NULL; - - return APR_SUCCESS; -} - -APU_DECLARE(apr_xml_parser *) apr_xml_parser_create(apr_pool_t *pool) -{ - apr_xml_parser *parser = apr_pcalloc(pool, sizeof(*parser)); - - parser->p = pool; - parser->doc = apr_pcalloc(pool, sizeof(*parser->doc)); - - parser->doc->namespaces = apr_array_make(pool, 5, sizeof(const char *)); - - /* ### is there a way to avoid hard-coding this? */ - apr_xml_insert_uri(parser->doc->namespaces, APR_KW_DAV); - - parser->xp = XML_ParserCreate(NULL); - if (parser->xp == NULL) { - (*apr_pool_abort_get(pool))(APR_ENOMEM); - return NULL; - } - - apr_pool_cleanup_register(pool, parser, cleanup_parser, - apr_pool_cleanup_null); - - XML_SetUserData(parser->xp, parser); - XML_SetElementHandler(parser->xp, start_handler, end_handler); - XML_SetCharacterDataHandler(parser->xp, cdata_handler); - - return parser; -} - -static apr_status_t do_parse(apr_xml_parser *parser, - const char *data, apr_size_t len, - int is_final) -{ - if (parser->xp == NULL) { - parser->error = APR_XML_ERROR_PARSE_DONE; - } - else { - int rv = XML_Parse(parser->xp, data, len, is_final); - - if (rv == 0) { - parser->error = APR_XML_ERROR_EXPAT; - parser->xp_err = XML_GetErrorCode(parser->xp); - } - } - - /* ### better error code? */ - return parser->error ? APR_EGENERAL : APR_SUCCESS; -} - -APU_DECLARE(apr_status_t) apr_xml_parser_feed(apr_xml_parser *parser, - const char *data, - apr_size_t len) -{ - return do_parse(parser, data, len, 0 /* is_final */); -} - -APU_DECLARE(apr_status_t) apr_xml_parser_done(apr_xml_parser *parser, - apr_xml_doc **pdoc) -{ - char end; - apr_status_t status = do_parse(parser, &end, 0, 1 /* is_final */); - - /* get rid of the parser */ - (void) apr_pool_cleanup_run(parser->p, parser, cleanup_parser); - - if (status) - return status; - - if (pdoc != NULL) - *pdoc = parser->doc; - return APR_SUCCESS; -} - -APU_DECLARE(char *) apr_xml_parser_geterror(apr_xml_parser *parser, - char *errbuf, - apr_size_t errbufsize) -{ - int error = parser->error; - const char *msg; - - /* clear our record of an error */ - parser->error = 0; - - switch (error) { - case 0: - msg = "No error."; - break; - - case APR_XML_NS_ERROR_UNKNOWN_PREFIX: - msg = "An undefined namespace prefix was used."; - break; - - case APR_XML_NS_ERROR_INVALID_DECL: - msg = "A namespace prefix was defined with an empty URI."; - break; - - case APR_XML_ERROR_EXPAT: - (void) apr_snprintf(errbuf, errbufsize, - "XML parser error code: %s (%d)", - XML_ErrorString(parser->xp_err), parser->xp_err); - return errbuf; - - case APR_XML_ERROR_PARSE_DONE: - msg = "The parser is not active."; - break; - - default: - msg = "There was an unknown error within the XML body."; - break; - } - - (void) apr_cpystrn(errbuf, msg, errbufsize); - return errbuf; -} - -APU_DECLARE(apr_status_t) apr_xml_parse_file(apr_pool_t *p, - apr_xml_parser **parser, - apr_xml_doc **ppdoc, - apr_file_t *xmlfd, - apr_size_t buffer_length) -{ - apr_status_t rv; - char *buffer; - apr_size_t length; - - *parser = apr_xml_parser_create(p); - if (*parser == NULL) { - /* FIXME: returning an error code would be nice, - * but we dont get one ;( */ - return APR_EGENERAL; - } - buffer = apr_palloc(p, buffer_length); - length = buffer_length; - - rv = apr_file_read(xmlfd, buffer, &length); - - while (rv == APR_SUCCESS) { - rv = apr_xml_parser_feed(*parser, buffer, length); - if (rv != APR_SUCCESS) { - return rv; - } - - length = buffer_length; - rv = apr_file_read(xmlfd, buffer, &length); - } - if (rv != APR_EOF) { - return rv; - } - rv = apr_xml_parser_done(*parser, ppdoc); - *parser = NULL; - return rv; -} - -APU_DECLARE(void) apr_text_append(apr_pool_t * p, apr_text_header *hdr, - const char *text) -{ - apr_text *t = apr_palloc(p, sizeof(*t)); - - t->text = text; - t->next = NULL; - - if (hdr->first == NULL) { - /* no text elements yet */ - hdr->first = hdr->last = t; - } - else { - /* append to the last text element */ - hdr->last->next = t; - hdr->last = t; - } -} - - -/* --------------------------------------------------------------- -** -** XML UTILITY FUNCTIONS -*/ - -/* -** apr_xml_quote_string: quote an XML string -** -** Replace '<', '>', and '&' with '<', '>', and '&'. -** If quotes is true, then replace '"' with '"'. -** -** quotes is typically set to true for XML strings that will occur within -** double quotes -- attribute values. -*/ -APU_DECLARE(const char *) apr_xml_quote_string(apr_pool_t *p, const char *s, - int quotes) -{ - const char *scan; - apr_size_t len = 0; - apr_size_t extra = 0; - char *qstr; - char *qscan; - char c; - - for (scan = s; (c = *scan) != '\0'; ++scan, ++len) { - if (c == '<' || c == '>') - extra += 3; /* < or > */ - else if (c == '&') - extra += 4; /* & */ - else if (quotes && c == '"') - extra += 5; /* " */ - } - - /* nothing to do? */ - if (extra == 0) - return s; - - qstr = apr_palloc(p, len + extra + 1); - for (scan = s, qscan = qstr; (c = *scan) != '\0'; ++scan) { - if (c == '<') { - *qscan++ = '&'; - *qscan++ = 'l'; - *qscan++ = 't'; - *qscan++ = ';'; - } - else if (c == '>') { - *qscan++ = '&'; - *qscan++ = 'g'; - *qscan++ = 't'; - *qscan++ = ';'; - } - else if (c == '&') { - *qscan++ = '&'; - *qscan++ = 'a'; - *qscan++ = 'm'; - *qscan++ = 'p'; - *qscan++ = ';'; - } - else if (quotes && c == '"') { - *qscan++ = '&'; - *qscan++ = 'q'; - *qscan++ = 'u'; - *qscan++ = 'o'; - *qscan++ = 't'; - *qscan++ = ';'; - } - else { - *qscan++ = c; - } - } - - *qscan = '\0'; - return qstr; -} - -/* how many characters for the given integer? */ -#define APR_XML_NS_LEN(ns) ((ns) < 10 ? 1 : (ns) < 100 ? 2 : (ns) < 1000 ? 3 : \ - (ns) < 10000 ? 4 : (ns) < 100000 ? 5 : \ - (ns) < 1000000 ? 6 : (ns) < 10000000 ? 7 : \ - (ns) < 100000000 ? 8 : (ns) < 1000000000 ? 9 : 10) - -static apr_size_t text_size(const apr_text *t) -{ - apr_size_t size = 0; - - for (; t; t = t->next) - size += strlen(t->text); - return size; -} - -static apr_size_t elem_size(const apr_xml_elem *elem, int style, - apr_array_header_t *namespaces, int *ns_map) -{ - apr_size_t size; - - if (style == APR_XML_X2T_FULL || style == APR_XML_X2T_FULL_NS_LANG) { - const apr_xml_attr *attr; - - size = 0; - - if (style == APR_XML_X2T_FULL_NS_LANG) { - int i; - - /* - ** The outer element will contain xmlns:ns%d="%s" attributes - ** and an xml:lang attribute, if applicable. - */ - - for (i = namespaces->nelts; i--;) { - /* compute size of: ' xmlns:ns%d="%s"' */ - size += (9 + APR_XML_NS_LEN(i) + 2 + - strlen(APR_XML_GET_URI_ITEM(namespaces, i)) + 1); - } - - if (elem->lang != NULL) { - /* compute size of: ' xml:lang="%s"' */ - size += 11 + strlen(elem->lang) + 1; - } - } - - if (elem->ns == APR_XML_NS_NONE) { - /* compute size of: <%s> */ - size += 1 + strlen(elem->name) + 1; - } - else { - int ns = ns_map ? ns_map[elem->ns] : elem->ns; - - /* compute size of: */ - size += 3 + APR_XML_NS_LEN(ns) + 1 + strlen(elem->name) + 1; - } - - if (APR_XML_ELEM_IS_EMPTY(elem)) { - /* insert a closing "/" */ - size += 1; - } - else { - /* - * two of above plus "/": - * ... - * OR <%s> ... - */ - size = 2 * size + 1; - } - - for (attr = elem->attr; attr; attr = attr->next) { - if (attr->ns == APR_XML_NS_NONE) { - /* compute size of: ' %s="%s"' */ - size += 1 + strlen(attr->name) + 2 + strlen(attr->value) + 1; - } - else { - /* compute size of: ' ns%d:%s="%s"' */ - size += 3 + APR_XML_NS_LEN(attr->ns) + 1 + strlen(attr->name) + 2 + strlen(attr->value) + 1; - } - } - - /* - ** If the element has an xml:lang value that is *different* from - ** its parent, then add the thing in: ' xml:lang="%s"'. - ** - ** NOTE: we take advantage of the pointer equality established by - ** the parsing for "inheriting" the xml:lang values from parents. - */ - if (elem->lang != NULL && - (elem->parent == NULL || elem->lang != elem->parent->lang)) { - size += 11 + strlen(elem->lang) + 1; - } - } - else if (style == APR_XML_X2T_LANG_INNER) { - /* - * This style prepends the xml:lang value plus a null terminator. - * If a lang value is not present, then we insert a null term. - */ - size = elem->lang ? strlen(elem->lang) + 1 : 1; - } - else - size = 0; - - size += text_size(elem->first_cdata.first); - - for (elem = elem->first_child; elem; elem = elem->next) { - /* the size of the child element plus the CDATA that follows it */ - size += (elem_size(elem, APR_XML_X2T_FULL, NULL, ns_map) + - text_size(elem->following_cdata.first)); - } - - return size; -} - -static char *write_text(char *s, const apr_text *t) -{ - for (; t; t = t->next) { - apr_size_t len = strlen(t->text); - memcpy(s, t->text, len); - s += len; - } - return s; -} - -static char *write_elem(char *s, const apr_xml_elem *elem, int style, - apr_array_header_t *namespaces, int *ns_map) -{ - const apr_xml_elem *child; - apr_size_t len; - int ns; - - if (style == APR_XML_X2T_FULL || style == APR_XML_X2T_FULL_NS_LANG) { - int empty = APR_XML_ELEM_IS_EMPTY(elem); - const apr_xml_attr *attr; - - if (elem->ns == APR_XML_NS_NONE) { - len = sprintf(s, "<%s", elem->name); - } - else { - ns = ns_map ? ns_map[elem->ns] : elem->ns; - len = sprintf(s, "name); - } - s += len; - - for (attr = elem->attr; attr; attr = attr->next) { - if (attr->ns == APR_XML_NS_NONE) - len = sprintf(s, " %s=\"%s\"", attr->name, attr->value); - else - len = sprintf(s, " ns%d:%s=\"%s\"", attr->ns, attr->name, attr->value); - s += len; - } - - /* add the xml:lang value if necessary */ - if (elem->lang != NULL && - (style == APR_XML_X2T_FULL_NS_LANG || - elem->parent == NULL || - elem->lang != elem->parent->lang)) { - len = sprintf(s, " xml:lang=\"%s\"", elem->lang); - s += len; - } - - /* add namespace definitions, if required */ - if (style == APR_XML_X2T_FULL_NS_LANG) { - int i; - - for (i = namespaces->nelts; i--;) { - len = sprintf(s, " xmlns:ns%d=\"%s\"", i, - APR_XML_GET_URI_ITEM(namespaces, i)); - s += len; - } - } - - /* no more to do. close it up and go. */ - if (empty) { - *s++ = '/'; - *s++ = '>'; - return s; - } - - /* just close it */ - *s++ = '>'; - } - else if (style == APR_XML_X2T_LANG_INNER) { - /* prepend the xml:lang value */ - if (elem->lang != NULL) { - len = strlen(elem->lang); - memcpy(s, elem->lang, len); - s += len; - } - *s++ = '\0'; - } - - s = write_text(s, elem->first_cdata.first); - - for (child = elem->first_child; child; child = child->next) { - s = write_elem(s, child, APR_XML_X2T_FULL, NULL, ns_map); - s = write_text(s, child->following_cdata.first); - } - - if (style == APR_XML_X2T_FULL || style == APR_XML_X2T_FULL_NS_LANG) { - if (elem->ns == APR_XML_NS_NONE) { - len = sprintf(s, "", elem->name); - } - else { - ns = ns_map ? ns_map[elem->ns] : elem->ns; - len = sprintf(s, "", ns, elem->name); - } - s += len; - } - - return s; -} - -APU_DECLARE(void) apr_xml_quote_elem(apr_pool_t *p, apr_xml_elem *elem) -{ - apr_text *scan_txt; - apr_xml_attr *scan_attr; - apr_xml_elem *scan_elem; - - /* convert the element's text */ - for (scan_txt = elem->first_cdata.first; - scan_txt != NULL; - scan_txt = scan_txt->next) { - scan_txt->text = apr_xml_quote_string(p, scan_txt->text, 0); - } - for (scan_txt = elem->following_cdata.first; - scan_txt != NULL; - scan_txt = scan_txt->next) { - scan_txt->text = apr_xml_quote_string(p, scan_txt->text, 0); - } - - /* convert the attribute values */ - for (scan_attr = elem->attr; - scan_attr != NULL; - scan_attr = scan_attr->next) { - scan_attr->value = apr_xml_quote_string(p, scan_attr->value, 1); - } - - /* convert the child elements */ - for (scan_elem = elem->first_child; - scan_elem != NULL; - scan_elem = scan_elem->next) { - apr_xml_quote_elem(p, scan_elem); - } -} - -/* convert an element to a text string */ -APU_DECLARE(void) apr_xml_to_text(apr_pool_t * p, const apr_xml_elem *elem, - int style, apr_array_header_t *namespaces, - int *ns_map, const char **pbuf, - apr_size_t *psize) -{ - /* get the exact size, plus a null terminator */ - apr_size_t size = elem_size(elem, style, namespaces, ns_map) + 1; - char *s = apr_palloc(p, size); - - (void) write_elem(s, elem, style, namespaces, ns_map); - s[size - 1] = '\0'; - - *pbuf = s; - if (psize) - *psize = size; -} - -APU_DECLARE(const char *) apr_xml_empty_elem(apr_pool_t * p, - const apr_xml_elem *elem) -{ - if (elem->ns == APR_XML_NS_NONE) { - /* - * The prefix (xml...) is already within the prop name, or - * the element simply has no prefix. - */ - return apr_psprintf(p, "<%s/>" DEBUG_CR, elem->name); - } - - return apr_psprintf(p, "" DEBUG_CR, elem->ns, elem->name); -} - -/* return the URI's (existing) index, or insert it and return a new index */ -APU_DECLARE(int) apr_xml_insert_uri(apr_array_header_t *uri_array, - const char *uri) -{ - int i; - const char **pelt; - - /* never insert an empty URI; this index is always APR_XML_NS_NONE */ - if (*uri == '\0') - return APR_XML_NS_NONE; - - for (i = uri_array->nelts; i--;) { - if (strcmp(uri, APR_XML_GET_URI_ITEM(uri_array, i)) == 0) - return i; - } - - pelt = apr_array_push(uri_array); - *pelt = uri; /* assume uri is const or in a pool */ - return uri_array->nelts - 1; -} - -/* convert the element to EBCDIC */ -#if APR_CHARSET_EBCDIC -static apr_status_t apr_xml_parser_convert_elem(apr_xml_elem *e, - apr_xlate_t *convset) -{ - apr_xml_attr *a; - apr_xml_elem *ec; - apr_text *t; - apr_size_t inbytes_left, outbytes_left; - apr_status_t status; - - inbytes_left = outbytes_left = strlen(e->name); - status = apr_xlate_conv_buffer(convset, e->name, &inbytes_left, (char *) e->name, &outbytes_left); - if (status) { - return status; - } - - for (t = e->first_cdata.first; t != NULL; t = t->next) { - inbytes_left = outbytes_left = strlen(t->text); - status = apr_xlate_conv_buffer(convset, t->text, &inbytes_left, (char *) t->text, &outbytes_left); - if (status) { - return status; - } - } - - for (t = e->following_cdata.first; t != NULL; t = t->next) { - inbytes_left = outbytes_left = strlen(t->text); - status = apr_xlate_conv_buffer(convset, t->text, &inbytes_left, (char *) t->text, &outbytes_left); - if (status) { - return status; - } - } - - for (a = e->attr; a != NULL; a = a->next) { - inbytes_left = outbytes_left = strlen(a->name); - status = apr_xlate_conv_buffer(convset, a->name, &inbytes_left, (char *) a->name, &outbytes_left); - if (status) { - return status; - } - inbytes_left = outbytes_left = strlen(a->value); - status = apr_xlate_conv_buffer(convset, a->value, &inbytes_left, (char *) a->value, &outbytes_left); - if (status) { - return status; - } - } - - for (ec = e->first_child; ec != NULL; ec = ec->next) { - status = apr_xml_parser_convert_elem(ec, convset); - if (status) { - return status; - } - } - return APR_SUCCESS; -} - -/* convert the whole document to EBCDIC */ -APU_DECLARE(apr_status_t) apr_xml_parser_convert_doc(apr_pool_t *pool, - apr_xml_doc *pdoc, - apr_xlate_t *convset) -{ - apr_status_t status; - /* Don't convert the namespaces: they are constant! */ - if (pdoc->namespaces != NULL) { - int i; - apr_array_header_t *namespaces; - namespaces = apr_array_make(pool, pdoc->namespaces->nelts, sizeof(const char *)); - if (namespaces == NULL) - return APR_ENOMEM; - for (i = 0; i < pdoc->namespaces->nelts; i++) { - apr_size_t inbytes_left, outbytes_left; - char *ptr = (char *) APR_XML_GET_URI_ITEM(pdoc->namespaces, i); - ptr = apr_pstrdup(pool, ptr); - if ( ptr == NULL) - return APR_ENOMEM; - inbytes_left = outbytes_left = strlen(ptr); - status = apr_xlate_conv_buffer(convset, ptr, &inbytes_left, ptr, &outbytes_left); - if (status) { - return status; - } - apr_xml_insert_uri(namespaces, ptr); - } - pdoc->namespaces = namespaces; - } - return apr_xml_parser_convert_elem(pdoc->root, convset); -} -#endif diff --git a/libs/apr-util/xml/expat/COPYING b/libs/apr-util/xml/expat/COPYING deleted file mode 100644 index fc97b02d90..0000000000 --- a/libs/apr-util/xml/expat/COPYING +++ /dev/null @@ -1,21 +0,0 @@ -Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd - and Clark Cooper - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/libs/apr-util/xml/expat/Makefile.in b/libs/apr-util/xml/expat/Makefile.in deleted file mode 100644 index aee7a354cc..0000000000 --- a/libs/apr-util/xml/expat/Makefile.in +++ /dev/null @@ -1,156 +0,0 @@ -################################################################ -# Process this file with top-level configure script to produce Makefile -# -# Copyright 2000 Clark Cooper -# -# This file is part of EXPAT. -# -# EXPAT is free software; you can redistribute it and/or modify it -# under the terms of the License (based on the MIT/X license) contained -# in the file COPYING that comes with this distribution. -# -# EXPAT IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -# SOFTWARE OR THE USE OR OTHER DEALINGS IN EXPAT. -# -# --- -# I started using automake, but -# 1) it seemed like overkill -# 2) I don't want all the GNU policies -# 3) I wanted more explicit control over what gets built -# -# So I'm doing my Makefile.in files manually. But a fair part is based -# on what I learned from perusing the Makefile.in's generated by automake, -# and the automake authors still get my kudos. -# - -SHELL = @SHELL@ - -srcdir = @srcdir@ -top_srcdir = @top_srcdir@ -VPATH = @srcdir@ -prefix = @prefix@ -exec_prefix = @exec_prefix@ - -bindir = @bindir@ -sbindir = @sbindir@ -libexecdir = @libexecdir@ -datadir = @datadir@ -sysconfdir = @sysconfdir@ -sharedstatedir = @sharedstatedir@ -localstatedir = @localstatedir@ -libdir = @libdir@ -infodir = @infodir@ -mandir = @mandir@ -includedir = @includedir@ -oldincludedir = /usr/include - -top_builddir = . - - -AUTOCONF = autoconf - -INSTALL = @INSTALL@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ - -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -host_alias = @host_alias@ -host_triplet = @host@ - -CC = @CC@ - -LIBTOOL = @LIBTOOL@ -LN_S = @LN_S@ -PACKAGE = @PACKAGE@ -RANLIB = @RANLIB@ -VERSION = @VERSION@ - -SUBDIRS = lib -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -CONFIG_HEADERS = config.h - -DISTDIR = $(PACKAGE)-$(VERSION) -DISTRIBUTION = $(DISTDIR).tar.gz - -all: build-subdirs - -.PHONY: all build-subdirs clean distclean extraclean maintainer-clean dist install \ - uninstall distdir - -Makefile: Makefile.in config.status - CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) config.status - -config.status: configure - @if test -f $@; then \ - $(SHELL) config.status --recheck ; \ - else \ - $(SHELL) configure ; \ - fi - -configure: configure.ac - $(AUTOCONF) - -config.h: config.h.in config.status - CONFIG_FILES= CONFIG_HEADERS=$(CONFIG_HEADERS) \ - $(SHELL) ./config.status - -build-subdirs: - @list='$(SUBDIRS)'; \ - for dir in $$list; do \ - cd $$dir; $(MAKE); cd ..; \ - done - -clean: - @list='$(SUBDIRS)'; for dir in $$list; do \ - cd $$dir; $(MAKE) clean; cd ..; \ - done - rm -f core *~ - -distclean: - @list='$(SUBDIRS)'; for dir in $$list; do \ - cd $$dir; $(MAKE) distclean; cd ..; \ - done - rm -f config.h config.status config.log libtool examples/Makefile xmlwf/Makefile Makefile - -extraclean: distclean - rm -f configure aclocal.m4 - -maintainer-clean: distclean - rm -f $(DISTRIBUTION) - rm -rf $(DISTDIR) - -distdir: MANIFEST - test -d $(DISTDIR) && rm -rf $(DISTDIR); \ - mkdir $(DISTDIR); \ - flist=`sed -e "s/[ ]:.*$$//" MANIFEST`; for file in $$flist; do \ - cp -P $$file $(DISTDIR); \ - done - -$(DISTRIBUTION): distdir - tar cfz $(DISTRIBUTION) $(DISTDIR) - -dist: $(DISTRIBUTION) - -install: - @list='$(SUBDIRS)'; for dir in $$list; do \ - cd $$dir; $(MAKE) install; cd ..; \ - done - -uninstall: - @list='$(SUBDIRS)'; for dir in $$list; do \ - cd $$dir; $(MAKE) uninstall; cd ..; \ - done - -depend: - echo SOMEONE SHOULD MAKE THIS DO SOMETHING!!! diff --git a/libs/apr-util/xml/expat/README b/libs/apr-util/xml/expat/README deleted file mode 100644 index 15bcdccb50..0000000000 --- a/libs/apr-util/xml/expat/README +++ /dev/null @@ -1,72 +0,0 @@ - - Expat, Release 1.95.2 - -This is expat, a C library for parsing XML, written by James Clark. -Expat is a stream-oriented XML parser. This means that you register -handlers with the parser before starting the parse. These handlers -are called when the parser discovers the associated structures in the -document being parsed. A start tag is an example of the kind of -structures for which you may register handlers. - -Windows users should use the expat_win32bin package, which includes -both precompiled libraries and executalbes, and source code for -developers. - -Expat is free software. You may copy, distribute, and modify it under -the terms of the License contained in the file COPYING distributed -with this package. This license is the same as the MIT/X Consortium -license. - -Versions of expat that have an odd minor version (the middle number in -the release above), are development releases and should be considered -as beta software. Releases with even minor version numbers are -intended to be production grade software. - -To build expat, you first run the configuration shell script in the -top level distribution directory: - - ./configure - -There are many options which you may provide to configure (which you -can discover by running configure with the --help option). But the -one of most interest is the one that sets the installation directory. -By default, the configure script will set things up to install -libexpat into /usr/local/lib, expat.h into /usr/local/include, and -xmlwf into /usr/local/bin. If, for example, you'd prefer to install -into /home/me/mystuff/lib, /home/me/mystuff/include, and -/home/me/mystuff/bin, you can tell configure about that with: - - ./configure --prefix=/home/me/mystuff - -After running the configure script, the "make" command will build -things and "make install" will install things into their proper -location. Note that you need to have write permission into the -directories into which things will be installed. - -When building for use with C++, you may need to add additional -compiler flags to support proper interaction with exceptions. This -can be done by setting the CFLAGS environment variable. For example, -when using GCC, you can use: - - CFLAGS=-fexceptions ./configure - -Note for Solaris users: The "ar" command is usually located in -"/usr/ccs/bin", which is not in the default PATH. You will need to -add this to your path for the "make" command, and probably also switch -to GNU make (the "make" found in /usr/ccs/bin does not seem to work -properly -- appearantly it does not understand .PHONY directives). If -you're using ksh or bash, use this command to build: - - PATH=/usr/ccs/bin:$PATH make - -A reference manual is available in the file doc/reference.html in this -distribution. - -The homepage for this project is http://expat.sourceforge.net/. There -are links there to connect you to the bug reports page. If you need -to report a bug when you don't have access to a browser, you may also -send a bug report by email to expat-bugs@lists.sourceforge.net. - -Discussion related to the direction of future expat development takes -place on expat-discuss@lists.sourceforge.net. Archives of this list -may be found at http://www.geocrawler.com/redir-sf.php3?list=expat-discuss. diff --git a/libs/apr-util/xml/expat/buildconf.sh b/libs/apr-util/xml/expat/buildconf.sh deleted file mode 100755 index 9050a0282a..0000000000 --- a/libs/apr-util/xml/expat/buildconf.sh +++ /dev/null @@ -1,77 +0,0 @@ -#! /bin/sh - -# -# Find libtoolize -# -libtoolize=`conftools/PrintPath glibtoolize libtoolize libtoolize15 libtoolize14` -if [ "x$libtoolize" = "x" ]; then - echo "libtoolize not found in path" - exit 1 -fi - -# -# Create the libtool helper files -# -# Note: we copy (rather than link) the files. -# -# Note: This bundled version of expat will not always replace the -# files since we have a special config.guess/config.sub that we -# want to ensure is used. -echo "Copying libtool helper files ..." - -# Remove any m4 cache and libtool files so one can switch between -# autoconf and libtool versions by simply rerunning the buildconf script. -# -(cd conftools ; rm -f ltconfig ltmain.sh) -rm -rf aclocal.m4 libtool.m4 ltsugar.m4 autom4te*.cache - -$libtoolize --copy --automake - -# -# find libtool.m4 -# -if [ ! -f libtool.m4 ]; then - ltpath=`dirname $libtoolize` - ltfile=${LIBTOOL_M4-`cd $ltpath/../share/aclocal ; pwd`/libtool.m4} - if [ -f $ltfile ]; then - echo "libtool.m4 found at $ltfile" - cp $ltfile libtool.m4 - else - echo "libtool.m4 not found - aborting!" - exit 1 - fi -fi - -# -# Build aclocal.m4 from libtool's m4 files -# -echo "dnl THIS FILE IS AUTOMATICALLY GENERATED BY buildconf.sh" > aclocal.m4 -echo "dnl edits here will be lost" >> aclocal.m4 - -for m4file in libtool.m4 ltsugar.m4 ltoptions.m4 ltversion.m4 lt~obsolete.m4 -do - if [ -f $m4file ]; then - echo "Incorporating $m4file into aclocal.m4 ..." - cat $m4file >> aclocal.m4 - rm -f $m4file - fi -done - -cross_compile_warning="warning: AC_TRY_RUN called without default to allow cross compiling" - -# -# Generate the autoconf header template (config.h.in) and ./configure -# -echo "Creating config.h.in ..." -${AUTOHEADER:-autoheader} 2>&1 | grep -v "$cross_compile_warning" - -echo "Creating configure ..." -${ACLOCAL:-aclocal} - -### do some work to toss config.cache? -${AUTOCONF:-autoconf} 2>&1 | grep -v "$cross_compile_warning" - -# Remove autoconf caches -rm -rf autom4te*.cache - -exit 0 diff --git a/libs/apr-util/xml/expat/configure.ac b/libs/apr-util/xml/expat/configure.ac deleted file mode 100644 index f808df4cce..0000000000 --- a/libs/apr-util/xml/expat/configure.ac +++ /dev/null @@ -1,120 +0,0 @@ -dnl configuration script for expat -dnl Process this file with autoconf to produce a configure script. -dnl -dnl Copyright 2000 Clark Cooper -dnl -dnl This file is part of EXPAT. -dnl -dnl EXPAT is free software; you can redistribute it and/or modify it -dnl under the terms of the License (based on the MIT/X license) contained -dnl in the file COPYING that comes with this distribution. -dnl - -AC_INIT(Makefile.in) -AC_CONFIG_AUX_DIR(conftools) -AC_CONFIG_MACRO_DIR(.) - -dnl -dnl Follow the GNU/Linux convention of odd number minor version for -dnl beta/development releases and even number minor version for stable -dnl releases. Edit is bumped with each release and set to 0 with -dnl change to major or minor version. -dnl - -EXPAT_MAJOR_VERSION=1 -EXPAT_MINOR_VERSION=95 -EXPAT_EDIT=2 - -EXPAT_VERSION=$EXPAT_MAJOR_VERSION.$EXPAT_MINOR_VERSION.$EXPAT_EDIT -VERSION=$EXPAT_VERSION -PACKAGE=expat - -dnl -dnl Increment LIBREVISION if source code has changed at all -dnl -dnl If the API has changed, increment LIBCURRENT and set LIBREVISION to 0 -dnl -dnl If the API changes compatibly (i.e. simply adding a new function -dnl without changing or removing earlier interfaces), then increment LIBAGE. -dnl -dnl If the API changes incompatibly set LIBAGE back to 0 -dnl - -LIBCURRENT=1 -LIBREVISION=0 -LIBAGE=1 - -AC_CONFIG_HEADER(config.h) - -AC_CANONICAL_SYSTEM -case "$host_os" in -*os2*) - # Use a custom made libtool replacement - echo Using aplibtool - LIBTOOL="$srcdir/../../../apr/build/aplibtool" - ;; -*) - AC_LIBTOOL_WIN32_DLL -AC_PROG_LIBTOOL - ;; -esac - -blddir=`pwd` -AC_SUBST(blddir) - -AC_SUBST(PACKAGE) -AC_SUBST(VERSION) -AC_SUBST(EXPAT_MAJOR_VERSION) -AC_SUBST(EXPAT_MINOR_VERSION) -AC_SUBST(EXPAT_EDIT) - -AC_SUBST(LIBCURRENT) -AC_SUBST(LIBREVISION) -AC_SUBST(LIBAGE) - -dnl Checks for programs. -AC_PROG_CC -AC_PROG_INSTALL - -dnl Checks for libraries. - -dnl Checks for header files. -AC_HEADER_STDC -AC_CHECK_HEADERS(fcntl.h unistd.h string.h) - -dnl Checks for typedefs, structures, and compiler characteristics. -dnl check for endianness -if test "$cross_compiling" = "no"; then - AC_C_BIGENDIAN -else - AC_DEFINE(AP_UNKNOWN_BYTE_ORDER,1,[byte order is unknown due to cross-compilation]) -fi - -if test "$ac_cv_c_bigendian" = "yes"; then - AC_DEFINE(XML_BYTE_ORDER,21,[21 for big endian or 12 for little]) -else - AC_DEFINE(XML_BYTE_ORDER,12,[z]) -fi - -AC_DEFINE(XML_NS,,[Define me]) -AC_DEFINE(XML_DTD,,[Define me]) -AC_DEFINE(XML_CONTEXT_BYTES,1024,[1024]) - -AC_C_CONST -AC_TYPE_OFF_T -AC_TYPE_SIZE_T - -dnl Checks for library functions. - -AC_FUNC_MEMCMP -AC_FUNC_MMAP -AC_SUBST(FILEMAP_OBJ) -if test -z "$HAVE_MMAP"; then -FILEMAP_OBJ=unixfilemap.o -else -FILEMAP_OBJ=readfilemap.o -fi - -AC_CHECK_FUNCS(memmove bcopy) - -AC_OUTPUT(Makefile lib/Makefile lib/expat.h) diff --git a/libs/apr-util/xml/expat/conftools/PrintPath b/libs/apr-util/xml/expat/conftools/PrintPath deleted file mode 100755 index 68435f3744..0000000000 --- a/libs/apr-util/xml/expat/conftools/PrintPath +++ /dev/null @@ -1,116 +0,0 @@ -#!/bin/sh -# Look for program[s] somewhere in $PATH. -# -# Options: -# -s -# Do not print out full pathname. (silent) -# -pPATHNAME -# Look in PATHNAME instead of $PATH -# -# Usage: -# PrintPath [-s] [-pPATHNAME] program [program ...] -# -# Initially written by Jim Jagielski for the Apache configuration mechanism -# (with kudos to Kernighan/Pike) -# -# This script falls under the Apache License. -# See http://www.apache.org/docs/LICENSE - -## -# Some "constants" -## -pathname=$PATH -echo="yes" - -## -# Find out what OS we are running for later on -## -os=`(uname) 2>/dev/null` - -## -# Parse command line -## -for args in $* -do - case $args in - -s ) echo="no" ;; - -p* ) pathname="`echo $args | sed 's/^..//'`" ;; - * ) programs="$programs $args" ;; - esac -done - -## -# Now we make the adjustments required for OS/2 and everyone -# else :) -# -# First of all, all OS/2 programs have the '.exe' extension. -# Next, we adjust PATH (or what was given to us as PATH) to -# be whitespace seperated directories. -# Finally, we try to determine the best flag to use for -# test/[] to look for an executable file. OS/2 just has '-r' -# but with other OSs, we do some funny stuff to check to see -# if test/[] knows about -x, which is the prefered flag. -## - -if [ "x$os" = "xOS/2" ] -then - ext=".exe" - pathname=`echo -E $pathname | - sed 's/^;/.;/ - s/;;/;.;/g - s/;$/;./ - s/;/ /g - s/\\\\/\\//g' ` - test_exec_flag="-r" -else - ext="" # No default extensions - pathname=`echo $pathname | - sed 's/^:/.:/ - s/::/:.:/g - s/:$/:./ - s/:/ /g' ` - # Here is how we test to see if test/[] can handle -x - testfile="pp.t.$$" - - cat > $testfile </dev/null`; then - test_exec_flag="-x" - else - test_exec_flag="-r" - fi - rm -f $testfile -fi - -for program in $programs -do - for path in $pathname - do - if [ $test_exec_flag $path/${program}${ext} ] && \ - [ ! -d $path/${program}${ext} ]; then - if [ "x$echo" = "xyes" ]; then - echo $path/${program}${ext} - fi - exit 0 - fi - -# Next try without extension (if one was used above) - if [ "x$ext" != "x" ]; then - if [ $test_exec_flag $path/${program} ] && \ - [ ! -d $path/${program} ]; then - if [ "x$echo" = "xyes" ]; then - echo $path/${program} - fi - exit 0 - fi - fi - done -done -exit 1 - diff --git a/libs/apr-util/xml/expat/conftools/config.guess b/libs/apr-util/xml/expat/conftools/config.guess deleted file mode 100755 index 1f5c50c0d1..0000000000 --- a/libs/apr-util/xml/expat/conftools/config.guess +++ /dev/null @@ -1,1420 +0,0 @@ -#! /bin/sh -# Attempt to guess a canonical system name. -# Copyright 1992-2014 Free Software Foundation, Inc. - -timestamp='2014-03-23' - -# This file 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 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, see . -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that -# program. This Exception is an additional permission under section 7 -# of the GNU General Public License, version 3 ("GPLv3"). -# -# Originally written by Per Bothner. -# -# You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD -# -# Please send patches with a ChangeLog entry to config-patches@gnu.org. - - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] - -Output the configuration name of the system \`$me' is run on. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.guess ($timestamp) - -Originally written by Per Bothner. -Copyright 1992-2014 Free Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit ;; - --version | -v ) - echo "$version" ; exit ;; - --help | --h* | -h ) - echo "$usage"; exit ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" >&2 - exit 1 ;; - * ) - break ;; - esac -done - -if test $# != 0; then - echo "$me: too many arguments$help" >&2 - exit 1 -fi - -trap 'exit 1' 1 2 15 - -# CC_FOR_BUILD -- compiler used by this script. Note that the use of a -# compiler to aid in system detection is discouraged as it requires -# temporary files to be created and, as you can see below, it is a -# headache to deal with in a portable fashion. - -# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still -# use `HOST_CC' if defined, but it is deprecated. - -# Portable tmp directory creation inspired by the Autoconf team. - -set_cc_for_build=' -trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; -trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; -: ${TMPDIR=/tmp} ; - { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || - { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || - { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || - { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; -dummy=$tmp/dummy ; -tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; -case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int x;" > $dummy.c ; - for c in cc gcc c89 c99 ; do - if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then - CC_FOR_BUILD="$c"; break ; - fi ; - done ; - if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found ; - fi - ;; - ,,*) CC_FOR_BUILD=$CC ;; - ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac ; set_cc_for_build= ;' - -# This is needed to find uname on a Pyramid OSx when run in the BSD universe. -# (ghazi@noc.rutgers.edu 1994-08-24) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then - PATH=$PATH:/.attbin ; export PATH -fi - -UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown -UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown -UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown -UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown - -case "${UNAME_SYSTEM}" in -Linux|GNU|GNU/*) - # If the system lacks a compiler, then just pick glibc. - # We could probably try harder. - LIBC=gnu - - eval $set_cc_for_build - cat <<-EOF > $dummy.c - #include - #if defined(__UCLIBC__) - LIBC=uclibc - #elif defined(__dietlibc__) - LIBC=dietlibc - #else - LIBC=gnu - #endif - EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` - ;; -esac - -# Note: order is significant - the case branches are not exclusive. - -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in - *:NetBSD:*:*) - # NetBSD (nbsd) targets should (where applicable) match one or - # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, - # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently - # switched to ELF, *-*-netbsd* would select the old - # object file format. This provides both forward - # compatibility and a consistent mechanism for selecting the - # object file format. - # - # Note: NetBSD doesn't particularly care about the vendor - # portion of the name. We always set it to "unknown". - sysctl="sysctl -n hw.machine_arch" - UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || echo unknown)` - case "${UNAME_MACHINE_ARCH}" in - armeb) machine=armeb-unknown ;; - arm*) machine=arm-unknown ;; - sh3el) machine=shl-unknown ;; - sh3eb) machine=sh-unknown ;; - sh5el) machine=sh5le-unknown ;; - *) machine=${UNAME_MACHINE_ARCH}-unknown ;; - esac - # The Operating System including object format, if it has switched - # to ELF recently, or will in the future. - case "${UNAME_MACHINE_ARCH}" in - arm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build - if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep -q __ELF__ - then - # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). - # Return netbsd for either. FIX? - os=netbsd - else - os=netbsdelf - fi - ;; - *) - os=netbsd - ;; - esac - # The OS release - # Debian GNU/NetBSD machines have a different userland, and - # thus, need a distinct triplet. However, they do not need - # kernel version information, so it can be replaced with a - # suitable tag, in the style of linux-gnu. - case "${UNAME_VERSION}" in - Debian*) - release='-gnu' - ;; - *) - release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` - ;; - esac - # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: - # contains redundant information, the shorter form: - # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}" - exit ;; - *:Bitrig:*:*) - UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} - exit ;; - *:OpenBSD:*:*) - UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} - exit ;; - *:ekkoBSD:*:*) - echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} - exit ;; - *:SolidBSD:*:*) - echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} - exit ;; - macppc:MirBSD:*:*) - echo powerpc-unknown-mirbsd${UNAME_RELEASE} - exit ;; - *:MirBSD:*:*) - echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} - exit ;; - alpha:OSF1:*:*) - case $UNAME_RELEASE in - *4.0) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` - ;; - *5.*) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` - ;; - esac - # According to Compaq, /usr/sbin/psrinfo has been available on - # OSF/1 and Tru64 systems produced since 1995. I hope that - # covers most systems running today. This code pipes the CPU - # types through head -n 1, so we only detect the type of CPU 0. - ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` - case "$ALPHA_CPU_TYPE" in - "EV4 (21064)") - UNAME_MACHINE="alpha" ;; - "EV4.5 (21064)") - UNAME_MACHINE="alpha" ;; - "LCA4 (21066/21068)") - UNAME_MACHINE="alpha" ;; - "EV5 (21164)") - UNAME_MACHINE="alphaev5" ;; - "EV5.6 (21164A)") - UNAME_MACHINE="alphaev56" ;; - "EV5.6 (21164PC)") - UNAME_MACHINE="alphapca56" ;; - "EV5.7 (21164PC)") - UNAME_MACHINE="alphapca57" ;; - "EV6 (21264)") - UNAME_MACHINE="alphaev6" ;; - "EV6.7 (21264A)") - UNAME_MACHINE="alphaev67" ;; - "EV6.8CB (21264C)") - UNAME_MACHINE="alphaev68" ;; - "EV6.8AL (21264B)") - UNAME_MACHINE="alphaev68" ;; - "EV6.8CX (21264D)") - UNAME_MACHINE="alphaev68" ;; - "EV6.9A (21264/EV69A)") - UNAME_MACHINE="alphaev69" ;; - "EV7 (21364)") - UNAME_MACHINE="alphaev7" ;; - "EV7.9 (21364A)") - UNAME_MACHINE="alphaev79" ;; - esac - # A Pn.n version is a patched version. - # A Vn.n version is a released version. - # A Tn.n version is a released field test version. - # A Xn.n version is an unreleased experimental baselevel. - # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - # Reset EXIT trap before exiting to avoid spurious non-zero exit code. - exitcode=$? - trap '' 0 - exit $exitcode ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit ;; - Amiga*:UNIX_System_V:4.0:*) - echo m68k-unknown-sysv4 - exit ;; - *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos - exit ;; - *:[Mm]orph[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-morphos - exit ;; - *:OS/390:*:*) - echo i370-ibm-openedition - exit ;; - *:z/VM:*:*) - echo s390-ibm-zvmoe - exit ;; - *:OS400:*:*) - echo powerpc-ibm-os400 - exit ;; - arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} - exit ;; - arm*:riscos:*:*|arm*:RISCOS:*:*) - echo arm-unknown-riscos - exit ;; - SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) - echo hppa1.1-hitachi-hiuxmpp - exit ;; - Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) - # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. - if test "`(/bin/universe) 2>/dev/null`" = att ; then - echo pyramid-pyramid-sysv3 - else - echo pyramid-pyramid-bsd - fi - exit ;; - NILE*:*:*:dcosx) - echo pyramid-pyramid-svr4 - exit ;; - DRS?6000:unix:4.0:6*) - echo sparc-icl-nx6 - exit ;; - DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) - case `/usr/bin/uname -p` in - sparc) echo sparc-icl-nx7; exit ;; - esac ;; - s390x:SunOS:*:*) - echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) - echo i386-pc-auroraux${UNAME_RELEASE} - exit ;; - i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) - eval $set_cc_for_build - SUN_ARCH="i386" - # If there is a compiler, see if it is configured for 64-bit objects. - # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. - # This test works for both compilers. - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then - if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null - then - SUN_ARCH="x86_64" - fi - fi - echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:6*:*) - # According to config.sub, this is the proper way to canonicalize - # SunOS6. Hard to guess exactly what SunOS6 will be like, but - # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:*:*) - case "`/usr/bin/arch -k`" in - Series*|S4*) - UNAME_RELEASE=`uname -v` - ;; - esac - # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` - exit ;; - sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} - exit ;; - sun*:*:4.2BSD:*) - UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 - case "`/bin/arch`" in - sun3) - echo m68k-sun-sunos${UNAME_RELEASE} - ;; - sun4) - echo sparc-sun-sunos${UNAME_RELEASE} - ;; - esac - exit ;; - aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} - exit ;; - # The situation for MiNT is a little confusing. The machine name - # can be virtually everything (everything which is not - # "atarist" or "atariste" at least should have a processor - # > m68000). The system name ranges from "MiNT" over "FreeMiNT" - # to the lowercase version "mint" (or "freemint"). Finally - # the system name "TOS" denotes a system which is actually not - # MiNT. But MiNT is downward compatible to TOS, so this should - # be no problem. - atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit ;; - hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit ;; - *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit ;; - m68k:machten:*:*) - echo m68k-apple-machten${UNAME_RELEASE} - exit ;; - powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} - exit ;; - RISC*:Mach:*:*) - echo mips-dec-mach_bsd4.3 - exit ;; - RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} - exit ;; - VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} - exit ;; - 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} - exit ;; - mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c -#ifdef __cplusplus -#include /* for printf() prototype */ - int main (int argc, char *argv[]) { -#else - int main (argc, argv) int argc; char *argv[]; { -#endif - #if defined (host_mips) && defined (MIPSEB) - #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); - #endif - #endif - exit (-1); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c && - dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && - SYSTEM_NAME=`$dummy $dummyarg` && - { echo "$SYSTEM_NAME"; exit; } - echo mips-mips-riscos${UNAME_RELEASE} - exit ;; - Motorola:PowerMAX_OS:*:*) - echo powerpc-motorola-powermax - exit ;; - Motorola:*:4.3:PL8-*) - echo powerpc-harris-powermax - exit ;; - Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) - echo powerpc-harris-powermax - exit ;; - Night_Hawk:Power_UNIX:*:*) - echo powerpc-harris-powerunix - exit ;; - m88k:CX/UX:7*:*) - echo m88k-harris-cxux7 - exit ;; - m88k:*:4*:R4*) - echo m88k-motorola-sysv4 - exit ;; - m88k:*:3*:R3*) - echo m88k-motorola-sysv3 - exit ;; - AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] - then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] - then - echo m88k-dg-dgux${UNAME_RELEASE} - else - echo m88k-dg-dguxbcs${UNAME_RELEASE} - fi - else - echo i586-dg-dgux${UNAME_RELEASE} - fi - exit ;; - M88*:DolphinOS:*:*) # DolphinOS (SVR3) - echo m88k-dolphin-sysv3 - exit ;; - M88*:*:R3*:*) - # Delta 88k system running SVR3 - echo m88k-motorola-sysv3 - exit ;; - XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) - echo m88k-tektronix-sysv3 - exit ;; - Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) - echo m68k-tektronix-bsd - exit ;; - *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` - exit ;; - ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' - i*86:AIX:*:*) - echo i386-ibm-aix - exit ;; - ia64:AIX:*:*) - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} - exit ;; - *:AIX:2:3) - if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - - main() - { - if (!__power_pc()) - exit(1); - puts("powerpc-ibm-aix3.2.5"); - exit(0); - } -EOF - if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` - then - echo "$SYSTEM_NAME" - else - echo rs6000-ibm-aix3.2.5 - fi - elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then - echo rs6000-ibm-aix3.2.4 - else - echo rs6000-ibm-aix3.2 - fi - exit ;; - *:AIX:*:[4567]) - IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` - if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then - IBM_ARCH=rs6000 - else - IBM_ARCH=powerpc - fi - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} - exit ;; - *:AIX:*:*) - echo rs6000-ibm-aix - exit ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) - echo romp-ibm-bsd4.4 - exit ;; - ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to - exit ;; # report: romp-ibm BSD 4.3 - *:BOSX:*:*) - echo rs6000-bull-bosx - exit ;; - DPX/2?00:B.O.S.:*:*) - echo m68k-bull-sysv3 - exit ;; - 9000/[34]??:4.3bsd:1.*:*) - echo m68k-hp-bsd - exit ;; - hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) - echo m68k-hp-bsd4.4 - exit ;; - 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; - 9000/[678][0-9][0-9]) - if [ -x /usr/bin/getconf ]; then - sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` - sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 - 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; - '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 - esac ;; - esac - fi - if [ "${HP_ARCH}" = "" ]; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - - #define _HPUX_SOURCE - #include - #include - - int main () - { - #if defined(_SC_KERNEL_BITS) - long bits = sysconf(_SC_KERNEL_BITS); - #endif - long cpu = sysconf (_SC_CPU_VERSION); - - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1"); break; - case CPU_PA_RISC2_0: - #if defined(_SC_KERNEL_BITS) - switch (bits) - { - case 64: puts ("hppa2.0w"); break; - case 32: puts ("hppa2.0n"); break; - default: puts ("hppa2.0"); break; - } break; - #else /* !defined(_SC_KERNEL_BITS) */ - puts ("hppa2.0"); break; - #endif - default: puts ("hppa1.0"); break; - } - exit (0); - } -EOF - (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` - test -z "$HP_ARCH" && HP_ARCH=hppa - fi ;; - esac - if [ ${HP_ARCH} = "hppa2.0w" ] - then - eval $set_cc_for_build - - # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating - # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler - # generating 64-bit code. GNU and HP use different nomenclature: - # - # $ CC_FOR_BUILD=cc ./config.guess - # => hppa2.0w-hp-hpux11.23 - # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess - # => hppa64-hp-hpux11.23 - - if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | - grep -q __LP64__ - then - HP_ARCH="hppa2.0w" - else - HP_ARCH="hppa64" - fi - fi - echo ${HP_ARCH}-hp-hpux${HPUX_REV} - exit ;; - ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} - exit ;; - 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - int - main () - { - long cpu = sysconf (_SC_CPU_VERSION); - /* The order matters, because CPU_IS_HP_MC68K erroneously returns - true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct - results, however. */ - if (CPU_IS_PA_RISC (cpu)) - { - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; - case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; - default: puts ("hppa-hitachi-hiuxwe2"); break; - } - } - else if (CPU_IS_HP_MC68K (cpu)) - puts ("m68k-hitachi-hiuxwe2"); - else puts ("unknown-hitachi-hiuxwe2"); - exit (0); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && - { echo "$SYSTEM_NAME"; exit; } - echo unknown-hitachi-hiuxwe2 - exit ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) - echo hppa1.1-hp-bsd - exit ;; - 9000/8??:4.3bsd:*:*) - echo hppa1.0-hp-bsd - exit ;; - *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) - echo hppa1.0-hp-mpeix - exit ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) - echo hppa1.1-hp-osf - exit ;; - hp8??:OSF1:*:*) - echo hppa1.0-hp-osf - exit ;; - i*86:OSF1:*:*) - if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk - else - echo ${UNAME_MACHINE}-unknown-osf1 - fi - exit ;; - parisc*:Lites*:*:*) - echo hppa1.1-hp-lites - exit ;; - C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) - echo c1-convex-bsd - exit ;; - C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit ;; - C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) - echo c34-convex-bsd - exit ;; - C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) - echo c38-convex-bsd - exit ;; - C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) - echo c4-convex-bsd - exit ;; - CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ - | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ - -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ - -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - *:UNICOS/mp:*:*) - echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) - FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; - 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` - echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; - i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} - exit ;; - sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} - exit ;; - *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} - exit ;; - *:FreeBSD:*:*) - UNAME_PROCESSOR=`/usr/bin/uname -p` - case ${UNAME_PROCESSOR} in - amd64) - echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - *) - echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - esac - exit ;; - i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin - exit ;; - *:MINGW64*:*) - echo ${UNAME_MACHINE}-pc-mingw64 - exit ;; - *:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 - exit ;; - *:MSYS*:*) - echo ${UNAME_MACHINE}-pc-msys - exit ;; - i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 - exit ;; - i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 - exit ;; - *:Interix*:*) - case ${UNAME_MACHINE} in - x86) - echo i586-pc-interix${UNAME_RELEASE} - exit ;; - authenticamd | genuineintel | EM64T) - echo x86_64-unknown-interix${UNAME_RELEASE} - exit ;; - IA64) - echo ia64-unknown-interix${UNAME_RELEASE} - exit ;; - esac ;; - [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) - echo i${UNAME_MACHINE}-pc-mks - exit ;; - 8664:Windows_NT:*) - echo x86_64-pc-mks - exit ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i586-pc-interix - exit ;; - i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin - exit ;; - amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) - echo x86_64-unknown-cygwin - exit ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin - exit ;; - prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - *:GNU:*:*) - # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` - exit ;; - *:GNU/*:*:*) - # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} - exit ;; - i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix - exit ;; - aarch64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - aarch64_be:Linux:*:*) - UNAME_MACHINE=aarch64_be - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in - EV5) UNAME_MACHINE=alphaev5 ;; - EV56) UNAME_MACHINE=alphaev56 ;; - PCA56) UNAME_MACHINE=alphapca56 ;; - PCA57) UNAME_MACHINE=alphapca56 ;; - EV6) UNAME_MACHINE=alphaev6 ;; - EV67) UNAME_MACHINE=alphaev67 ;; - EV68*) UNAME_MACHINE=alphaev68 ;; - esac - objdump --private-headers /bin/sh | grep -q ld.so.1 - if test "$?" = 0 ; then LIBC="gnulibc1" ; fi - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - arc:Linux:*:* | arceb:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - arm*:Linux:*:*) - eval $set_cc_for_build - if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep -q __ARM_EABI__ - then - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - else - if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep -q __ARM_PCS_VFP - then - echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi - else - echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf - fi - fi - exit ;; - avr32*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - cris:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} - exit ;; - crisv32:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} - exit ;; - frv:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - hexagon:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - i*86:Linux:*:*) - echo ${UNAME_MACHINE}-pc-linux-${LIBC} - exit ;; - ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - mips:Linux:*:* | mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #undef CPU - #undef ${UNAME_MACHINE} - #undef ${UNAME_MACHINE}el - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=${UNAME_MACHINE}el - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=${UNAME_MACHINE} - #else - CPU= - #endif - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } - ;; - openrisc*:Linux:*:*) - echo or1k-unknown-linux-${LIBC} - exit ;; - or32:Linux:*:* | or1k*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - padre:Linux:*:*) - echo sparc-unknown-linux-${LIBC} - exit ;; - parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-${LIBC} - exit ;; - parisc:Linux:*:* | hppa:Linux:*:*) - # Look for CPU level - case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; - PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; - *) echo hppa-unknown-linux-${LIBC} ;; - esac - exit ;; - ppc64:Linux:*:*) - echo powerpc64-unknown-linux-${LIBC} - exit ;; - ppc:Linux:*:*) - echo powerpc-unknown-linux-${LIBC} - exit ;; - ppc64le:Linux:*:*) - echo powerpc64le-unknown-linux-${LIBC} - exit ;; - ppcle:Linux:*:*) - echo powerpcle-unknown-linux-${LIBC} - exit ;; - s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux-${LIBC} - exit ;; - sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - tile*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - vax:Linux:*:*) - echo ${UNAME_MACHINE}-dec-linux-${LIBC} - exit ;; - x86_64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - i*86:DYNIX/ptx:4*:*) - # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. - # earlier versions are messed up and put the nodename in both - # sysname and nodename. - echo i386-sequent-sysv4 - exit ;; - i*86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... - # I am not positive that other SVR4 systems won't match this, - # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} - exit ;; - i*86:OS/2:*:*) - # If we were able to find `uname', then EMX Unix compatibility - # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx - exit ;; - i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop - exit ;; - i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos - exit ;; - i*86:syllable:*:*) - echo ${UNAME_MACHINE}-pc-syllable - exit ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} - exit ;; - i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp - exit ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` - if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} - else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} - fi - exit ;; - i*86:*:5:[678]*) - # UnixWare 7.x, OpenUNIX and OpenServer 6. - case `/bin/uname -X | grep "^Machine"` in - *486*) UNAME_MACHINE=i486 ;; - *Pentium) UNAME_MACHINE=i586 ;; - *Pent*|*Celeron) UNAME_MACHINE=i686 ;; - esac - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} - exit ;; - i*86:*:3.2:*) - if test -f /usr/options/cb.name; then - UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then - UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` - (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 - (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ - && UNAME_MACHINE=i586 - (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ - && UNAME_MACHINE=i686 - (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ - && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL - else - echo ${UNAME_MACHINE}-pc-sysv32 - fi - exit ;; - pc:*:*:*) - # Left here for compatibility: - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i586. - # Note: whatever this is, it MUST be the same as what config.sub - # prints for the "djgpp" host, or else GDB configury will decide that - # this is a cross-build. - echo i586-pc-msdosdjgpp - exit ;; - Intel:Mach:3*:*) - echo i386-pc-mach3 - exit ;; - paragon:*:*:*) - echo i860-intel-osf1 - exit ;; - i860:*:4.*:*) # i860-SVR4 - if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 - else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 - fi - exit ;; - mini*:CTIX:SYS*5:*) - # "miniframe" - echo m68010-convergent-sysv - exit ;; - mc68k:UNIX:SYSTEM5:3.51m) - echo m68k-convergent-sysv - exit ;; - M680?0:D-NIX:5.3:*) - echo m68k-diab-dnix - exit ;; - M68*:*:R3V[5678]*:*) - test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; - 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) - OS_REL='' - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; - 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4; exit; } ;; - NCR*:*:4.2:* | MPRAS*:*:4.2:*) - OS_REL='.3' - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } - /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; - m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} - exit ;; - mc68030:UNIX_System_V:4.*:*) - echo m68k-atari-sysv4 - exit ;; - TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} - exit ;; - rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} - exit ;; - PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} - exit ;; - SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} - exit ;; - RM*:ReliantUNIX-*:*:*) - echo mips-sni-sysv4 - exit ;; - RM*:SINIX-*:*:*) - echo mips-sni-sysv4 - exit ;; - *:SINIX-*:*:*) - if uname -p 2>/dev/null >/dev/null ; then - UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 - else - echo ns32k-sni-sysv - fi - exit ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says - echo i586-unisys-sysv4 - exit ;; - *:UNIX_System_V:4*:FTX*) - # From Gerald Hewes . - # How about differentiating between stratus architectures? -djm - echo hppa1.1-stratus-sysv4 - exit ;; - *:*:*:FTX*) - # From seanf@swdc.stratus.com. - echo i860-stratus-sysv4 - exit ;; - i*86:VOS:*:*) - # From Paul.Green@stratus.com. - echo ${UNAME_MACHINE}-stratus-vos - exit ;; - *:VOS:*:*) - # From Paul.Green@stratus.com. - echo hppa1.1-stratus-vos - exit ;; - mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} - exit ;; - news*:NEWS-OS:6*:*) - echo mips-sony-newsos6 - exit ;; - R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) - if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} - else - echo mips-unknown-sysv${UNAME_RELEASE} - fi - exit ;; - BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. - echo powerpc-be-beos - exit ;; - BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. - echo powerpc-apple-beos - exit ;; - BePC:BeOS:*:*) # BeOS running on Intel PC compatible. - echo i586-pc-beos - exit ;; - BePC:Haiku:*:*) # Haiku running on Intel PC compatible. - echo i586-pc-haiku - exit ;; - x86_64:Haiku:*:*) - echo x86_64-unknown-haiku - exit ;; - SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} - exit ;; - SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} - exit ;; - SX-6:SUPER-UX:*:*) - echo sx6-nec-superux${UNAME_RELEASE} - exit ;; - SX-7:SUPER-UX:*:*) - echo sx7-nec-superux${UNAME_RELEASE} - exit ;; - SX-8:SUPER-UX:*:*) - echo sx8-nec-superux${UNAME_RELEASE} - exit ;; - SX-8R:SUPER-UX:*:*) - echo sx8r-nec-superux${UNAME_RELEASE} - exit ;; - Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} - exit ;; - *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} - exit ;; - *:Darwin:*:*) - UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - eval $set_cc_for_build - if test "$UNAME_PROCESSOR" = unknown ; then - UNAME_PROCESSOR=powerpc - fi - if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then - if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null - then - case $UNAME_PROCESSOR in - i386) UNAME_PROCESSOR=x86_64 ;; - powerpc) UNAME_PROCESSOR=powerpc64 ;; - esac - fi - fi - elif test "$UNAME_PROCESSOR" = i386 ; then - # Avoid executing cc on OS X 10.9, as it ships with a stub - # that puts up a graphical alert prompting to install - # developer tools. Any system running Mac OS X 10.7 or - # later (Darwin 11 and later) is required to have a 64-bit - # processor. This is not true of the ARM version of Darwin - # that Apple uses in portable devices. - UNAME_PROCESSOR=x86_64 - fi - echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} - exit ;; - *:procnto*:*:* | *:QNX:[0123456789]*:*) - UNAME_PROCESSOR=`uname -p` - if test "$UNAME_PROCESSOR" = "x86"; then - UNAME_PROCESSOR=i386 - UNAME_MACHINE=pc - fi - echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} - exit ;; - *:QNX:*:4*) - echo i386-pc-qnx - exit ;; - NEO-?:NONSTOP_KERNEL:*:*) - echo neo-tandem-nsk${UNAME_RELEASE} - exit ;; - NSE-*:NONSTOP_KERNEL:*:*) - echo nse-tandem-nsk${UNAME_RELEASE} - exit ;; - NSR-?:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} - exit ;; - *:NonStop-UX:*:*) - echo mips-compaq-nonstopux - exit ;; - BS2000:POSIX*:*:*) - echo bs2000-siemens-sysv - exit ;; - DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} - exit ;; - *:Plan9:*:*) - # "uname -m" is not consistent, so use $cputype instead. 386 - # is converted to i386 for consistency with other x86 - # operating systems. - if test "$cputype" = "386"; then - UNAME_MACHINE=i386 - else - UNAME_MACHINE="$cputype" - fi - echo ${UNAME_MACHINE}-unknown-plan9 - exit ;; - *:TOPS-10:*:*) - echo pdp10-unknown-tops10 - exit ;; - *:TENEX:*:*) - echo pdp10-unknown-tenex - exit ;; - KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) - echo pdp10-dec-tops20 - exit ;; - XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) - echo pdp10-xkl-tops20 - exit ;; - *:TOPS-20:*:*) - echo pdp10-unknown-tops20 - exit ;; - *:ITS:*:*) - echo pdp10-unknown-its - exit ;; - SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} - exit ;; - *:DragonFly:*:*) - echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit ;; - *:*VMS:*:*) - UNAME_MACHINE=`(uname -p) 2>/dev/null` - case "${UNAME_MACHINE}" in - A*) echo alpha-dec-vms ; exit ;; - I*) echo ia64-dec-vms ; exit ;; - V*) echo vax-dec-vms ; exit ;; - esac ;; - *:XENIX:*:SysV) - echo i386-pc-xenix - exit ;; - i*86:skyos:*:*) - echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' - exit ;; - i*86:rdos:*:*) - echo ${UNAME_MACHINE}-pc-rdos - exit ;; - i*86:AROS:*:*) - echo ${UNAME_MACHINE}-pc-aros - exit ;; - x86_64:VMkernel:*:*) - echo ${UNAME_MACHINE}-unknown-esx - exit ;; -esac - -cat >&2 < in order to provide the needed -information to handle your system. - -config.guess timestamp = $timestamp - -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null` - -hostinfo = `(hostinfo) 2>/dev/null` -/bin/universe = `(/bin/universe) 2>/dev/null` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` -/bin/arch = `(/bin/arch) 2>/dev/null` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` - -UNAME_MACHINE = ${UNAME_MACHINE} -UNAME_RELEASE = ${UNAME_RELEASE} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} -EOF - -exit 1 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/libs/apr-util/xml/expat/conftools/config.sub b/libs/apr-util/xml/expat/conftools/config.sub deleted file mode 100755 index bba4efb805..0000000000 --- a/libs/apr-util/xml/expat/conftools/config.sub +++ /dev/null @@ -1,1799 +0,0 @@ -#! /bin/sh -# Configuration validation subroutine script. -# Copyright 1992-2014 Free Software Foundation, Inc. - -timestamp='2014-09-11' - -# This file 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 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, see . -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that -# program. This Exception is an additional permission under section 7 -# of the GNU General Public License, version 3 ("GPLv3"). - - -# Please send patches with a ChangeLog entry to config-patches@gnu.org. -# -# Configuration subroutine to validate and canonicalize a configuration type. -# Supply the specified configuration type as an argument. -# If it is invalid, we print an error message on stderr and exit with code 1. -# Otherwise, we print the canonical config type on stdout and succeed. - -# You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD - -# This file is supposed to be the same for all GNU packages -# and recognize all the CPU types, system types and aliases -# that are meaningful with *any* GNU software. -# Each package is responsible for reporting which valid configurations -# it does not support. The user should be able to distinguish -# a failure to support a valid configuration from a meaningless -# configuration. - -# The goal of this file is to map all the various variations of a given -# machine specification into a single specification in the form: -# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM -# or in some cases, the newer four-part form: -# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM -# It is wrong to echo any other type of specification. - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] CPU-MFR-OPSYS - $0 [OPTION] ALIAS - -Canonicalize a configuration name. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.sub ($timestamp) - -Copyright 1992-2014 Free Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit ;; - --version | -v ) - echo "$version" ; exit ;; - --help | --h* | -h ) - echo "$usage"; exit ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" - exit 1 ;; - - *local*) - # First pass through any local machine types. - echo $1 - exit ;; - - * ) - break ;; - esac -done - -case $# in - 0) echo "$me: missing argument$help" >&2 - exit 1;; - 1) ;; - *) echo "$me: too many arguments$help" >&2 - exit 1;; -esac - -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ - linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ - knetbsd*-gnu* | netbsd*-gnu* | \ - kopensolaris*-gnu* | \ - storm-chaos* | os2-emx* | rtmk-nova*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - android-linux) - os=-linux-android - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac - -### Let's recognize common machines as not being operating systems so -### that things like config.sub decstation-3100 work. We also -### recognize some manufacturers as not being operating systems, so we -### can provide default operating systems below. -case $os in - -sun*os*) - # Prevent following clause from handling this invalid input. - ;; - -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ - -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ - -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ - -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ - -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis | -knuth | -cray | -microblaze*) - os= - basic_machine=$1 - ;; - -bluegene*) - os=-cnk - ;; - -sim | -cisco | -oki | -wec | -winbond) - os= - basic_machine=$1 - ;; - -scout) - ;; - -wrs) - os=-vxworks - basic_machine=$1 - ;; - -chorusos*) - os=-chorusos - basic_machine=$1 - ;; - -chorusrdb) - os=-chorusrdb - basic_machine=$1 - ;; - -hiux*) - os=-hiuxwe2 - ;; - -sco6) - os=-sco5v6 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5) - os=-sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco4) - os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2.[4-9]*) - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2v[4-9]*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5v6*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco*) - os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -udk*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -isc) - os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -clix*) - basic_machine=clipper-intergraph - ;; - -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -lynx*178) - os=-lynxos178 - ;; - -lynx*5) - os=-lynxos5 - ;; - -lynx*) - os=-lynxos - ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` - ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` - ;; - -psos*) - os=-psos - ;; - -mint | -mint[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; -esac - -# Decode aliases for certain CPU-COMPANY combinations. -case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - 1750a | 580 \ - | a29k \ - | aarch64 | aarch64_be \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ - | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ - | am33_2.0 \ - | arc | arceb \ - | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ - | avr | avr32 \ - | be32 | be64 \ - | bfin \ - | c4x | c8051 | clipper \ - | d10v | d30v | dlx | dsp16xx \ - | epiphany \ - | fido | fr30 | frv \ - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | hexagon \ - | i370 | i860 | i960 | ia64 \ - | ip2k | iq2000 \ - | k1om \ - | le32 | le64 \ - | lm32 \ - | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ - | mips | mipsbe | mipseb | mipsel | mipsle \ - | mips16 \ - | mips64 | mips64el \ - | mips64octeon | mips64octeonel \ - | mips64orion | mips64orionel \ - | mips64r5900 | mips64r5900el \ - | mips64vr | mips64vrel \ - | mips64vr4100 | mips64vr4100el \ - | mips64vr4300 | mips64vr4300el \ - | mips64vr5000 | mips64vr5000el \ - | mips64vr5900 | mips64vr5900el \ - | mipsisa32 | mipsisa32el \ - | mipsisa32r2 | mipsisa32r2el \ - | mipsisa32r6 | mipsisa32r6el \ - | mipsisa64 | mipsisa64el \ - | mipsisa64r2 | mipsisa64r2el \ - | mipsisa64r6 | mipsisa64r6el \ - | mipsisa64sb1 | mipsisa64sb1el \ - | mipsisa64sr71k | mipsisa64sr71kel \ - | mipsr5900 | mipsr5900el \ - | mipstx39 | mipstx39el \ - | mn10200 | mn10300 \ - | moxie \ - | mt \ - | msp430 \ - | nds32 | nds32le | nds32be \ - | nios | nios2 | nios2eb | nios2el \ - | ns16k | ns32k \ - | open8 | or1k | or1knd | or32 \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle \ - | pyramid \ - | riscv32 | riscv64 \ - | rl78 | rx \ - | score \ - | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ - | sh64 | sh64le \ - | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ - | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ - | spu \ - | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ - | ubicom32 \ - | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ - | we32k \ - | x86 | xc16x | xstormy16 | xtensa \ - | z8k | z80) - basic_machine=$basic_machine-unknown - ;; - c54x) - basic_machine=tic54x-unknown - ;; - c55x) - basic_machine=tic55x-unknown - ;; - c6x) - basic_machine=tic6x-unknown - ;; - m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) - basic_machine=$basic_machine-unknown - os=-none - ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) - ;; - ms1) - basic_machine=mt-unknown - ;; - - strongarm | thumb | xscale) - basic_machine=arm-unknown - ;; - xgate) - basic_machine=$basic_machine-unknown - os=-none - ;; - xscaleeb) - basic_machine=armeb-unknown - ;; - - xscaleel) - basic_machine=armel-unknown - ;; - - # We use `pc' rather than `unknown' - # because (1) that's what they normally are, and - # (2) the word "unknown" tends to confuse beginning users. - i*86 | x86_64) - basic_machine=$basic_machine-pc - ;; - # Object if more than one company name word. - *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; - # Recognize the basic CPU types with company name. - 580-* \ - | a29k-* \ - | aarch64-* | aarch64_be-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ - | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ - | avr-* | avr32-* \ - | be32-* | be64-* \ - | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* \ - | c8051-* | clipper-* | craynv-* | cydra-* \ - | d10v-* | d30v-* | dlx-* \ - | elxsi-* \ - | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ - | h8300-* | h8500-* \ - | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | hexagon-* \ - | i*86-* | i860-* | i960-* | ia64-* \ - | ip2k-* | iq2000-* \ - | k1om-* \ - | le32-* | le64-* \ - | lm32-* \ - | m32c-* | m32r-* | m32rle-* \ - | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ - | microblaze-* | microblazeel-* \ - | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ - | mips16-* \ - | mips64-* | mips64el-* \ - | mips64octeon-* | mips64octeonel-* \ - | mips64orion-* | mips64orionel-* \ - | mips64r5900-* | mips64r5900el-* \ - | mips64vr-* | mips64vrel-* \ - | mips64vr4100-* | mips64vr4100el-* \ - | mips64vr4300-* | mips64vr4300el-* \ - | mips64vr5000-* | mips64vr5000el-* \ - | mips64vr5900-* | mips64vr5900el-* \ - | mipsisa32-* | mipsisa32el-* \ - | mipsisa32r2-* | mipsisa32r2el-* \ - | mipsisa32r6-* | mipsisa32r6el-* \ - | mipsisa64-* | mipsisa64el-* \ - | mipsisa64r2-* | mipsisa64r2el-* \ - | mipsisa64r6-* | mipsisa64r6el-* \ - | mipsisa64sb1-* | mipsisa64sb1el-* \ - | mipsisa64sr71k-* | mipsisa64sr71kel-* \ - | mipsr5900-* | mipsr5900el-* \ - | mipstx39-* | mipstx39el-* \ - | mmix-* \ - | mt-* \ - | msp430-* \ - | nds32-* | nds32le-* | nds32be-* \ - | nios-* | nios2-* | nios2eb-* | nios2el-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ - | open8-* \ - | or1k*-* \ - | orion-* \ - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ - | pyramid-* \ - | rl78-* | romp-* | rs6000-* | rx-* \ - | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ - | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ - | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ - | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ - | tahoe-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ - | tile*-* \ - | tron-* \ - | ubicom32-* \ - | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ - | vax-* \ - | we32k-* \ - | x86-* | x86_64-* | xc16x-* | xps100-* \ - | xstormy16-* | xtensa*-* \ - | ymp-* \ - | z8k-* | z80-*) - ;; - # Recognize the basic CPU types without company name, with glob match. - xtensa*) - basic_machine=$basic_machine-unknown - ;; - # Recognize the various machine names and aliases which stand - # for a CPU type and a company and sometimes even an OS. - 386bsd) - basic_machine=i386-unknown - os=-bsd - ;; - 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att - ;; - 3b*) - basic_machine=we32k-att - ;; - a29khif) - basic_machine=a29k-amd - os=-udi - ;; - abacus) - basic_machine=abacus-unknown - ;; - adobe68k) - basic_machine=m68010-adobe - os=-scout - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; - amd64) - basic_machine=x86_64-pc - ;; - amd64-*) - basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; - amiga | amiga-*) - basic_machine=m68k-unknown - ;; - amigaos | amigados) - basic_machine=m68k-unknown - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-unknown - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - apollo68bsd) - basic_machine=m68k-apollo - os=-bsd - ;; - aros) - basic_machine=i386-pc - os=-aros - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - blackfin) - basic_machine=bfin-unknown - os=-linux - ;; - blackfin-*) - basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - bluegene*) - basic_machine=powerpc-ibm - os=-cnk - ;; - c54x-*) - basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c55x-*) - basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c6x-*) - basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c90) - basic_machine=c90-cray - os=-unicos - ;; - cegcc) - basic_machine=arm-unknown - os=-cegcc - ;; - convex-c1) - basic_machine=c1-convex - os=-bsd - ;; - convex-c2) - basic_machine=c2-convex - os=-bsd - ;; - convex-c32) - basic_machine=c32-convex - os=-bsd - ;; - convex-c34) - basic_machine=c34-convex - os=-bsd - ;; - convex-c38) - basic_machine=c38-convex - os=-bsd - ;; - cray | j90) - basic_machine=j90-cray - os=-unicos - ;; - craynv) - basic_machine=craynv-cray - os=-unicosmp - ;; - cr16 | cr16-*) - basic_machine=cr16-unknown - os=-elf - ;; - crds | unos) - basic_machine=m68k-crds - ;; - crisv32 | crisv32-* | etraxfs*) - basic_machine=crisv32-axis - ;; - cris | cris-* | etrax*) - basic_machine=cris-axis - ;; - crx) - basic_machine=crx-unknown - os=-elf - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec - ;; - decsystem10* | dec10*) - basic_machine=pdp10-dec - os=-tops10 - ;; - decsystem20* | dec20*) - basic_machine=pdp10-dec - os=-tops20 - ;; - delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - dicos) - basic_machine=i686-pc - os=-dicos - ;; - djgpp) - basic_machine=i586-pc - os=-msdosdjgpp - ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx - ;; - dpx2* | dpx2*-bull) - basic_machine=m68k-bull - os=-sysv3 - ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon - ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd - ;; - encore | umax | mmax) - basic_machine=ns32k-encore - ;; - es1800 | OSE68k | ose68k | ose | OSE) - basic_machine=m68k-ericsson - os=-ose - ;; - fx2800) - basic_machine=i860-alliant - ;; - genix) - basic_machine=ns32k-ns - ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - go32) - basic_machine=i386-pc - os=-go32 - ;; - h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - h8300xray) - basic_machine=h8300-hitachi - os=-xray - ;; - h8500hms) - basic_machine=h8500-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; - hp300-*) - basic_machine=m68k-hp - ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux - ;; - hp3k9[0-9][0-9] | hp9[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp - ;; - hp9k3[2-9][0-9]) - basic_machine=m68k-hp - ;; - hp9k6[0-9][0-9] | hp6[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k7[0-79][0-9] | hp7[0-79][0-9]) - basic_machine=hppa1.1-hp - ;; - hp9k78[0-9] | hp78[0-9]) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][13679] | hp8[0-9][13679]) - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hppa-next) - os=-nextstep3 - ;; - hppaosf) - basic_machine=hppa1.1-hp - os=-osf - ;; - hppro) - basic_machine=hppa1.1-hp - os=-proelf - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm - ;; - i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 - ;; - i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 - ;; - i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv - ;; - i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 - ;; - i386mach) - basic_machine=i386-mach - os=-mach - ;; - i386-vsta | vsta) - basic_machine=i386-unknown - os=-vsta - ;; - iris | iris4d) - basic_machine=mips-sgi - case $os in - -irix*) - ;; - *) - os=-irix4 - ;; - esac - ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - m68knommu) - basic_machine=m68k-unknown - os=-linux - ;; - m68knommu-*) - basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - microblaze*) - basic_machine=microblaze-xilinx - ;; - mingw64) - basic_machine=x86_64-pc - os=-mingw64 - ;; - mingw32) - basic_machine=i686-pc - os=-mingw32 - ;; - mingw32ce) - basic_machine=arm-unknown - os=-mingw32ce - ;; - miniframe) - basic_machine=m68000-convergent - ;; - *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; - mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; - monitor) - basic_machine=m68k-rom68k - os=-coff - ;; - morphos) - basic_machine=powerpc-unknown - os=-morphos - ;; - moxiebox) - basic_machine=moxie-unknown - os=-moxiebox - ;; - msdos) - basic_machine=i386-pc - os=-msdos - ;; - ms1-*) - basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` - ;; - msys) - basic_machine=i686-pc - os=-msys - ;; - mvs) - basic_machine=i370-ibm - os=-mvs - ;; - nacl) - basic_machine=le32-unknown - os=-nacl - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - netbsd386) - basic_machine=i386-unknown - os=-netbsd - ;; - netwinder) - basic_machine=armv4l-rebel - os=-linux - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos - ;; - news-3600 | risc-news) - basic_machine=mips-sony - os=-newsos - ;; - necv70) - basic_machine=v70-nec - os=-sysv - ;; - next | m*-next ) - basic_machine=m68k-next - case $os in - -nextstep* ) - ;; - -ns2*) - os=-nextstep2 - ;; - *) - os=-nextstep3 - ;; - esac - ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - mon960) - basic_machine=i960-intel - os=-mon960 - ;; - nonstopux) - basic_machine=mips-compaq - os=-nonstopux - ;; - np1) - basic_machine=np1-gould - ;; - neo-tandem) - basic_machine=neo-tandem - ;; - nse-tandem) - basic_machine=nse-tandem - ;; - nsr-tandem) - basic_machine=nsr-tandem - ;; - op50n-* | op60c-*) - basic_machine=hppa1.1-oki - os=-proelf - ;; - openrisc | openrisc-*) - basic_machine=or32-unknown - ;; - os400) - basic_machine=powerpc-ibm - os=-os400 - ;; - OSE68000 | ose68000) - basic_machine=m68000-ericsson - os=-ose - ;; - os68k) - basic_machine=m68k-none - os=-os68k - ;; - pa-hitachi) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - parisc) - basic_machine=hppa-unknown - os=-linux - ;; - parisc-*) - basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - pbd) - basic_machine=sparc-tti - ;; - pbb) - basic_machine=m68k-tti - ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 - ;; - pc98) - basic_machine=i386-pc - ;; - pc98-*) - basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium | p5 | k5 | k6 | nexgen | viac3) - basic_machine=i586-pc - ;; - pentiumpro | p6 | 6x86 | athlon | athlon_*) - basic_machine=i686-pc - ;; - pentiumii | pentium2 | pentiumiii | pentium3) - basic_machine=i686-pc - ;; - pentium4) - basic_machine=i786-pc - ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium4-*) - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pn) - basic_machine=pn-gould - ;; - power) basic_machine=power-ibm - ;; - ppc | ppcbe) basic_machine=powerpc-unknown - ;; - ppc-* | ppcbe-*) - basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppcle | powerpclittle | ppc-le | powerpc-little) - basic_machine=powerpcle-unknown - ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64) basic_machine=powerpc64-unknown - ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) - basic_machine=powerpc64le-unknown - ;; - ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ps2) - basic_machine=i386-ibm - ;; - pw32) - basic_machine=i586-unknown - os=-pw32 - ;; - rdos | rdos64) - basic_machine=x86_64-pc - os=-rdos - ;; - rdos32) - basic_machine=i386-pc - os=-rdos - ;; - rom68k) - basic_machine=m68k-rom68k - os=-coff - ;; - rm[46]00) - basic_machine=mips-siemens - ;; - rtpc | rtpc-*) - basic_machine=romp-ibm - ;; - s390 | s390-*) - basic_machine=s390-ibm - ;; - s390x | s390x-*) - basic_machine=s390x-ibm - ;; - sa29200) - basic_machine=a29k-amd - os=-udi - ;; - sb1) - basic_machine=mipsisa64sb1-unknown - ;; - sb1el) - basic_machine=mipsisa64sb1el-unknown - ;; - sde) - basic_machine=mipsisa32-sde - os=-elf - ;; - sei) - basic_machine=mips-sei - os=-seiux - ;; - sequent) - basic_machine=i386-sequent - ;; - sh) - basic_machine=sh-hitachi - os=-hms - ;; - sh5el) - basic_machine=sh5le-unknown - ;; - sh64) - basic_machine=sh64-unknown - ;; - sparclite-wrs | simso-wrs) - basic_machine=sparclite-wrs - os=-vxworks - ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 - ;; - spur) - basic_machine=spur-unknown - ;; - st2000) - basic_machine=m68k-tandem - ;; - stratus) - basic_machine=i860-stratus - os=-sysv4 - ;; - strongarm-* | thumb-*) - basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - sun2) - basic_machine=m68000-sun - ;; - sun2os3) - basic_machine=m68000-sun - os=-sunos3 - ;; - sun2os4) - basic_machine=m68000-sun - os=-sunos4 - ;; - sun3os3) - basic_machine=m68k-sun - os=-sunos3 - ;; - sun3os4) - basic_machine=m68k-sun - os=-sunos4 - ;; - sun4os3) - basic_machine=sparc-sun - os=-sunos3 - ;; - sun4os4) - basic_machine=sparc-sun - os=-sunos4 - ;; - sun4sol2) - basic_machine=sparc-sun - os=-solaris2 - ;; - sun3 | sun3-*) - basic_machine=m68k-sun - ;; - sun4) - basic_machine=sparc-sun - ;; - sun386 | sun386i | roadrunner) - basic_machine=i386-sun - ;; - sv1) - basic_machine=sv1-cray - os=-unicos - ;; - symmetry) - basic_machine=i386-sequent - os=-dynix - ;; - t3e) - basic_machine=alphaev5-cray - os=-unicos - ;; - t90) - basic_machine=t90-cray - os=-unicos - ;; - tile*) - basic_machine=$basic_machine-unknown - os=-linux-gnu - ;; - tx39) - basic_machine=mipstx39-unknown - ;; - tx39el) - basic_machine=mipstx39el-unknown - ;; - toad1) - basic_machine=pdp10-xkl - os=-tops20 - ;; - tower | tower-32) - basic_machine=m68k-ncr - ;; - tpf) - basic_machine=s390x-ibm - os=-tpf - ;; - udi29k) - basic_machine=a29k-amd - os=-udi - ;; - ultra3) - basic_machine=a29k-nyu - os=-sym1 - ;; - v810 | necv810) - basic_machine=v810-nec - os=-none - ;; - vaxv) - basic_machine=vax-dec - os=-sysv - ;; - vms) - basic_machine=vax-dec - os=-vms - ;; - vpp*|vx|vx-*) - basic_machine=f301-fujitsu - ;; - vxworks960) - basic_machine=i960-wrs - os=-vxworks - ;; - vxworks68) - basic_machine=m68k-wrs - os=-vxworks - ;; - vxworks29k) - basic_machine=a29k-wrs - os=-vxworks - ;; - w65*) - basic_machine=w65-wdc - os=-none - ;; - w89k-*) - basic_machine=hppa1.1-winbond - os=-proelf - ;; - xbox) - basic_machine=i686-pc - os=-mingw32 - ;; - xps | xps100) - basic_machine=xps100-honeywell - ;; - xscale-* | xscalee[bl]-*) - basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` - ;; - ymp) - basic_machine=ymp-cray - os=-unicos - ;; - z8k-*-coff) - basic_machine=z8k-unknown - os=-sim - ;; - z80-*-coff) - basic_machine=z80-unknown - os=-sim - ;; - none) - basic_machine=none-none - os=-none - ;; - -# Here we handle the default manufacturer of certain CPU types. It is in -# some cases the only manufacturer, in others, it is the most popular. - w89k) - basic_machine=hppa1.1-winbond - ;; - op50n) - basic_machine=hppa1.1-oki - ;; - op60c) - basic_machine=hppa1.1-oki - ;; - romp) - basic_machine=romp-ibm - ;; - mmix) - basic_machine=mmix-knuth - ;; - rs6000) - basic_machine=rs6000-ibm - ;; - vax) - basic_machine=vax-dec - ;; - pdp10) - # there are many clones, so DEC is not a safe bet - basic_machine=pdp10-unknown - ;; - pdp11) - basic_machine=pdp11-dec - ;; - we32k) - basic_machine=we32k-att - ;; - sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) - basic_machine=sh-unknown - ;; - sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) - basic_machine=sparc-sun - ;; - cydra) - basic_machine=cydra-cydrome - ;; - orion) - basic_machine=orion-highlevel - ;; - orion105) - basic_machine=clipper-highlevel - ;; - mac | mpw | mac-mpw) - basic_machine=m68k-apple - ;; - pmac | pmac-mpw) - basic_machine=powerpc-apple - ;; - *-unknown) - # Make sure to match an already-canonicalized machine name. - ;; - *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; -esac - -# Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` - ;; - *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` - ;; - *) - ;; -esac - -# Decode manufacturer-specific aliases for certain operating systems. - -if [ x"$os" != x"" ] -then -case $os in - # First match some system type aliases - # that might get confused with valid system types. - # -solaris* is a basic system type, with this one exception. - -auroraux) - os=-auroraux - ;; - -solaris1 | -solaris1.*) - os=`echo $os | sed -e 's|solaris1|sunos4|'` - ;; - -solaris) - os=-solaris2 - ;; - -svr4*) - os=-sysv4 - ;; - -unixware*) - os=-sysv4.2uw - ;; - -gnu/linux*) - os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` - ;; - # First accept the basic system types. - # The portable systems comes first. - # Each alternative MUST END IN A *, to match a version number. - # -sysv* is not here because it comes later, after sysvr4. - -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ - | -sym* | -kopensolaris* | -plan9* \ - | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* | -aros* \ - | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ - | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ - | -bitrig* | -openbsd* | -solidbsd* \ - | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ - | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ - | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* | -cegcc* \ - | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ - | -linux-newlib* | -linux-musl* | -linux-uclibc* \ - | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ - | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ - | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ - | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ - | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ - | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ - | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; - -qnx*) - case $basic_machine in - x86-* | i*86-*) - ;; - *) - os=-nto$os - ;; - esac - ;; - -nto-qnx*) - ;; - -nto*) - os=`echo $os | sed -e 's|nto|nto-qnx|'` - ;; - -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ - | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) - ;; - -mac*) - os=`echo $os | sed -e 's|mac|macos|'` - ;; - -linux-dietlibc) - os=-linux-dietlibc - ;; - -linux*) - os=`echo $os | sed -e 's|linux|linux-gnu|'` - ;; - -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` - ;; - -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` - ;; - -opened*) - os=-openedition - ;; - -os400*) - os=-os400 - ;; - -wince*) - os=-wince - ;; - -osfrose*) - os=-osfrose - ;; - -osf*) - os=-osf - ;; - -utek*) - os=-bsd - ;; - -dynix*) - os=-bsd - ;; - -acis*) - os=-aos - ;; - -atheos*) - os=-atheos - ;; - -syllable*) - os=-syllable - ;; - -386bsd) - os=-bsd - ;; - -ctix* | -uts*) - os=-sysv - ;; - -nova*) - os=-rtmk-nova - ;; - -ns2 ) - os=-nextstep2 - ;; - -nsk*) - os=-nsk - ;; - # Preserve the version number of sinix5. - -sinix5.*) - os=`echo $os | sed -e 's|sinix|sysv|'` - ;; - -sinix*) - os=-sysv4 - ;; - -tpf*) - os=-tpf - ;; - -triton*) - os=-sysv3 - ;; - -oss*) - os=-sysv3 - ;; - -svr4) - os=-sysv4 - ;; - -svr3) - os=-sysv3 - ;; - -sysvr4) - os=-sysv4 - ;; - # This must come after -sysvr4. - -sysv*) - ;; - -ose*) - os=-ose - ;; - -es1800*) - os=-ose - ;; - -xenix) - os=-xenix - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - os=-mint - ;; - -aros*) - os=-aros - ;; - -zvmoe) - os=-zvmoe - ;; - -dicos*) - os=-dicos - ;; - -nacl*) - ;; - -none) - ;; - *) - # Get rid of the `-' at the beginning of $os. - os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 - exit 1 - ;; -esac -else - -# Here we handle the default operating systems that come with various machines. -# The value should be what the vendor currently ships out the door with their -# machine or put another way, the most popular os provided with the machine. - -# Note that if you're going to try to match "-MANUFACTURER" here (say, -# "-sun"), then you have to tell the case statement up towards the top -# that MANUFACTURER isn't an operating system. Otherwise, code above -# will signal an error saying that MANUFACTURER isn't an operating -# system, and we'll never get to this point. - -case $basic_machine in - score-*) - os=-elf - ;; - spu-*) - os=-elf - ;; - *-acorn) - os=-riscix1.2 - ;; - arm*-rebel) - os=-linux - ;; - arm*-semi) - os=-aout - ;; - c4x-* | tic4x-*) - os=-coff - ;; - c8051-*) - os=-elf - ;; - hexagon-*) - os=-elf - ;; - tic54x-*) - os=-coff - ;; - tic55x-*) - os=-coff - ;; - tic6x-*) - os=-coff - ;; - # This must come before the *-dec entry. - pdp10-*) - os=-tops20 - ;; - pdp11-*) - os=-none - ;; - *-dec | vax-*) - os=-ultrix4.2 - ;; - m68*-apollo) - os=-domain - ;; - i386-sun) - os=-sunos4.0.2 - ;; - m68000-sun) - os=-sunos3 - ;; - m68*-cisco) - os=-aout - ;; - mep-*) - os=-elf - ;; - mips*-cisco) - os=-elf - ;; - mips*-*) - os=-elf - ;; - or32-*) - os=-coff - ;; - *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 - ;; - sparc-* | *-sun) - os=-sunos4.1.1 - ;; - *-be) - os=-beos - ;; - *-haiku) - os=-haiku - ;; - *-ibm) - os=-aix - ;; - *-knuth) - os=-mmixware - ;; - *-wec) - os=-proelf - ;; - *-winbond) - os=-proelf - ;; - *-oki) - os=-proelf - ;; - *-hp) - os=-hpux - ;; - *-hitachi) - os=-hiux - ;; - i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv - ;; - *-cbm) - os=-amigaos - ;; - *-dg) - os=-dgux - ;; - *-dolphin) - os=-sysv3 - ;; - m68k-ccur) - os=-rtu - ;; - m88k-omron*) - os=-luna - ;; - *-next ) - os=-nextstep - ;; - *-sequent) - os=-ptx - ;; - *-crds) - os=-unos - ;; - *-ns) - os=-genix - ;; - i370-*) - os=-mvs - ;; - *-next) - os=-nextstep3 - ;; - *-gould) - os=-sysv - ;; - *-highlevel) - os=-bsd - ;; - *-encore) - os=-bsd - ;; - *-sgi) - os=-irix - ;; - *-siemens) - os=-sysv4 - ;; - *-masscomp) - os=-rtu - ;; - f30[01]-fujitsu | f700-fujitsu) - os=-uxpv - ;; - *-rom68k) - os=-coff - ;; - *-*bug) - os=-coff - ;; - *-apple) - os=-macos - ;; - *-atari*) - os=-mint - ;; - *) - os=-none - ;; -esac -fi - -# Here we handle the case where we know the os, and the CPU type, but not the -# manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) - case $os in - -riscix*) - vendor=acorn - ;; - -sunos*) - vendor=sun - ;; - -cnk*|-aix*) - vendor=ibm - ;; - -beos*) - vendor=be - ;; - -hpux*) - vendor=hp - ;; - -mpeix*) - vendor=hp - ;; - -hiux*) - vendor=hitachi - ;; - -unos*) - vendor=crds - ;; - -dgux*) - vendor=dg - ;; - -luna*) - vendor=omron - ;; - -genix*) - vendor=ns - ;; - -mvs* | -opened*) - vendor=ibm - ;; - -os400*) - vendor=ibm - ;; - -ptx*) - vendor=sequent - ;; - -tpf*) - vendor=ibm - ;; - -vxsim* | -vxworks* | -windiss*) - vendor=wrs - ;; - -aux*) - vendor=apple - ;; - -hms*) - vendor=hitachi - ;; - -mpw* | -macos*) - vendor=apple - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - vendor=atari - ;; - -vos*) - vendor=stratus - ;; - esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` - ;; -esac - -echo $basic_machine$os -exit - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/libs/apr-util/xml/expat/conftools/install-sh b/libs/apr-util/xml/expat/conftools/install-sh deleted file mode 100755 index e9de23842d..0000000000 --- a/libs/apr-util/xml/expat/conftools/install-sh +++ /dev/null @@ -1,251 +0,0 @@ -#!/bin/sh -# -# install - install a program, script, or datafile -# This comes from X11R5 (mit/util/scripts/install.sh). -# -# Copyright 1991 by the Massachusetts Institute of Technology -# -# Permission to use, copy, modify, distribute, and sell this software and its -# documentation for any purpose is hereby granted without fee, provided that -# the above copyright notice appear in all copies and that both that -# copyright notice and this permission notice appear in supporting -# documentation, and that the name of M.I.T. not be used in advertising or -# publicity pertaining to distribution of the software without specific, -# written prior permission. M.I.T. makes no representations about the -# suitability of this software for any purpose. It is provided "as is" -# without express or implied warranty. -# -# Calling this script install-sh is preferred over install.sh, to prevent -# `make' implicit rules from creating a file called install from it -# when there is no Makefile. -# -# This script is compatible with the BSD install script, but was written -# from scratch. It can only install one file at a time, a restriction -# shared with many OS's install programs. - - -# set DOITPROG to echo to test this script - -# Don't use :- since 4.3BSD and earlier shells don't like it. -doit="${DOITPROG-}" - - -# put in absolute paths if you don't have them in your path; or use env. vars. - -mvprog="${MVPROG-mv}" -cpprog="${CPPROG-cp}" -chmodprog="${CHMODPROG-chmod}" -chownprog="${CHOWNPROG-chown}" -chgrpprog="${CHGRPPROG-chgrp}" -stripprog="${STRIPPROG-strip}" -rmprog="${RMPROG-rm}" -mkdirprog="${MKDIRPROG-mkdir}" - -transformbasename="" -transform_arg="" -instcmd="$mvprog" -chmodcmd="$chmodprog 0755" -chowncmd="" -chgrpcmd="" -stripcmd="" -rmcmd="$rmprog -f" -mvcmd="$mvprog" -src="" -dst="" -dir_arg="" - -while [ x"$1" != x ]; do - case $1 in - -c) instcmd="$cpprog" - shift - continue;; - - -d) dir_arg=true - shift - continue;; - - -m) chmodcmd="$chmodprog $2" - shift - shift - continue;; - - -o) chowncmd="$chownprog $2" - shift - shift - continue;; - - -g) chgrpcmd="$chgrpprog $2" - shift - shift - continue;; - - -s) stripcmd="$stripprog" - shift - continue;; - - -t=*) transformarg=`echo $1 | sed 's/-t=//'` - shift - continue;; - - -b=*) transformbasename=`echo $1 | sed 's/-b=//'` - shift - continue;; - - *) if [ x"$src" = x ] - then - src=$1 - else - # this colon is to work around a 386BSD /bin/sh bug - : - dst=$1 - fi - shift - continue;; - esac -done - -if [ x"$src" = x ] -then - echo "install: no input file specified" - exit 1 -else - true -fi - -if [ x"$dir_arg" != x ]; then - dst=$src - src="" - - if [ -d $dst ]; then - instcmd=: - chmodcmd="" - else - instcmd=mkdir - fi -else - -# Waiting for this to be detected by the "$instcmd $src $dsttmp" command -# might cause directories to be created, which would be especially bad -# if $src (and thus $dsttmp) contains '*'. - - if [ -f $src -o -d $src ] - then - true - else - echo "install: $src does not exist" - exit 1 - fi - - if [ x"$dst" = x ] - then - echo "install: no destination specified" - exit 1 - else - true - fi - -# If destination is a directory, append the input filename; if your system -# does not like double slashes in filenames, you may need to add some logic - - if [ -d $dst ] - then - dst="$dst"/`basename $src` - else - true - fi -fi - -## this sed command emulates the dirname command -dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` - -# Make sure that the destination directory exists. -# this part is taken from Noah Friedman's mkinstalldirs script - -# Skip lots of stat calls in the usual case. -if [ ! -d "$dstdir" ]; then -defaultIFS=' -' -IFS="${IFS-${defaultIFS}}" - -oIFS="${IFS}" -# Some sh's can't handle IFS=/ for some reason. -IFS='%' -set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` -IFS="${oIFS}" - -pathcomp='' - -while [ $# -ne 0 ] ; do - pathcomp="${pathcomp}${1}" - shift - - if [ ! -d "${pathcomp}" ] ; - then - $mkdirprog "${pathcomp}" - else - true - fi - - pathcomp="${pathcomp}/" -done -fi - -if [ x"$dir_arg" != x ] -then - $doit $instcmd $dst && - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi -else - -# If we're going to rename the final executable, determine the name now. - - if [ x"$transformarg" = x ] - then - dstfile=`basename $dst` - else - dstfile=`basename $dst $transformbasename | - sed $transformarg`$transformbasename - fi - -# don't allow the sed command to completely eliminate the filename - - if [ x"$dstfile" = x ] - then - dstfile=`basename $dst` - else - true - fi - -# Make a temp file name in the proper directory. - - dsttmp=$dstdir/#inst.$$# - -# Move or copy the file name to the temp name - - $doit $instcmd $src $dsttmp && - - trap "rm -f ${dsttmp}" 0 && - -# and set any options; do chmod last to preserve setuid bits - -# If any of these fail, we abort the whole thing. If we want to -# ignore errors from any of these, just make sure not to ignore -# errors from the above "$doit $instcmd $src $dsttmp" command. - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && - -# Now rename the file to the real destination. - - $doit $rmcmd -f $dstdir/$dstfile && - $doit $mvcmd $dsttmp $dstdir/$dstfile - -fi && - - -exit 0 diff --git a/libs/apr-util/xml/expat/conftools/missing b/libs/apr-util/xml/expat/conftools/missing deleted file mode 100755 index 8c9d99736f..0000000000 --- a/libs/apr-util/xml/expat/conftools/missing +++ /dev/null @@ -1,190 +0,0 @@ -#! /bin/sh -# Common stub for a few missing GNU programs while installing. -# Copyright (C) 1996, 1997 Free Software Foundation, Inc. -# Franc,ois Pinard , 1996. - -# 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, or (at your option) -# any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA. - -if test $# -eq 0; then - echo 1>&2 "Try \`$0 --help' for more information" - exit 1 -fi - -case "$1" in - - -h|--h|--he|--hel|--help) - echo "\ -$0 [OPTION]... PROGRAM [ARGUMENT]... - -Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an -error status if there is no known handling for PROGRAM. - -Options: - -h, --help display this help and exit - -v, --version output version information and exit - -Supported PROGRAM values: - aclocal touch file \`aclocal.m4' - autoconf touch file \`configure' - autoheader touch file \`config.h.in' - automake touch all \`Makefile.in' files - bison create \`y.tab.[ch]', if possible, from existing .[ch] - flex create \`lex.yy.c', if possible, from existing .c - lex create \`lex.yy.c', if possible, from existing .c - makeinfo touch the output file - yacc create \`y.tab.[ch]', if possible, from existing .[ch]" - ;; - - -v|--v|--ve|--ver|--vers|--versi|--versio|--version) - echo "missing - GNU libit 0.0" - ;; - - -*) - echo 1>&2 "$0: Unknown \`$1' option" - echo 1>&2 "Try \`$0 --help' for more information" - exit 1 - ;; - - aclocal) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified \`acinclude.m4' or \`configure.ac'. You might want - to install the \`Automake' and \`Perl' packages. Grab them from - any GNU archive site." - touch aclocal.m4 - ;; - - autoconf) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified \`configure.ac'. You might want to install the - \`Autoconf' and \`GNU m4' packages. Grab them from any GNU - archive site." - touch configure - ;; - - autoheader) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified \`acconfig.h' or \`configure.ac'. You might want - to install the \`Autoconf' and \`GNU m4' packages. Grab them - from any GNU archive site." - files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' configure.ac` - test -z "$files" && files="config.h" - touch_files= - for f in $files; do - case "$f" in - *:*) touch_files="$touch_files "`echo "$f" | - sed -e 's/^[^:]*://' -e 's/:.*//'`;; - *) touch_files="$touch_files $f.in";; - esac - done - touch $touch_files - ;; - - automake) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified \`Makefile.am', \`acinclude.m4' or \`configure.ac'. - You might want to install the \`Automake' and \`Perl' packages. - Grab them from any GNU archive site." - find . -type f -name Makefile.am -print | - sed 's/\.am$/.in/' | - while read f; do touch "$f"; done - ;; - - bison|yacc) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified a \`.y' file. You may need the \`Bison' package - in order for those modifications to take effect. You can get - \`Bison' from any GNU archive site." - rm -f y.tab.c y.tab.h - if [ $# -ne 1 ]; then - eval LASTARG="\${$#}" - case "$LASTARG" in - *.y) - SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` - if [ -f "$SRCFILE" ]; then - cp "$SRCFILE" y.tab.c - fi - SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` - if [ -f "$SRCFILE" ]; then - cp "$SRCFILE" y.tab.h - fi - ;; - esac - fi - if [ ! -f y.tab.h ]; then - echo >y.tab.h - fi - if [ ! -f y.tab.c ]; then - echo 'main() { return 0; }' >y.tab.c - fi - ;; - - lex|flex) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified a \`.l' file. You may need the \`Flex' package - in order for those modifications to take effect. You can get - \`Flex' from any GNU archive site." - rm -f lex.yy.c - if [ $# -ne 1 ]; then - eval LASTARG="\${$#}" - case "$LASTARG" in - *.l) - SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` - if [ -f "$SRCFILE" ]; then - cp "$SRCFILE" lex.yy.c - fi - ;; - esac - fi - if [ ! -f lex.yy.c ]; then - echo 'main() { return 0; }' >lex.yy.c - fi - ;; - - makeinfo) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified a \`.texi' or \`.texinfo' file, or any other file - indirectly affecting the aspect of the manual. The spurious - call might also be the consequence of using a buggy \`make' (AIX, - DU, IRIX). You might want to install the \`Texinfo' package or - the \`GNU make' package. Grab either from any GNU archive site." - file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` - if test -z "$file"; then - file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` - file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` - fi - touch $file - ;; - - *) - echo 1>&2 "\ -WARNING: \`$1' is needed, and you do not seem to have it handy on your - system. You might have modified some files without having the - proper tools for further handling them. Check the \`README' file, - it often tells you about the needed prerequirements for installing - this package. You may also peek at any GNU archive site, in case - some other package would contain this missing \`$1' program." - exit 1 - ;; -esac - -exit 0 diff --git a/libs/apr-util/xml/expat/conftools/mkinstalldirs b/libs/apr-util/xml/expat/conftools/mkinstalldirs deleted file mode 100755 index 25b7bd1a0f..0000000000 --- a/libs/apr-util/xml/expat/conftools/mkinstalldirs +++ /dev/null @@ -1,40 +0,0 @@ -#! /bin/sh -# mkinstalldirs --- make directory hierarchy -# Author: Noah Friedman -# Created: 1993-05-16 -# Public domain - -# $Id: mkinstalldirs 106501 2004-11-24 23:41:24Z nd $ - -errstatus=0 - -for file -do - set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` - shift - - pathcomp= - for d - do - pathcomp="$pathcomp$d" - case "$pathcomp" in - -* ) pathcomp=./$pathcomp ;; - esac - - if test ! -d "$pathcomp"; then - echo "mkdir $pathcomp" - - mkdir "$pathcomp" || lasterr=$? - - if test ! -d "$pathcomp"; then - errstatus=$lasterr - fi - fi - - pathcomp="$pathcomp/" - done -done - -exit $errstatus - -# mkinstalldirs ends here diff --git a/libs/apr-util/xml/expat/lib/Makefile.in b/libs/apr-util/xml/expat/lib/Makefile.in deleted file mode 100644 index b5e4b3def5..0000000000 --- a/libs/apr-util/xml/expat/lib/Makefile.in +++ /dev/null @@ -1,154 +0,0 @@ -################################################################ -# Process this file with top-level configure script to produce Makefile -# -# Copyright 2000 Clark Cooper -# -# This file is part of EXPAT. -# -# EXPAT is free software; you can redistribute it and/or modify it -# under the terms of the License (based on the MIT/X license) contained -# in the file COPYING that comes with this distribution. -# -# EXPAT IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -# SOFTWARE OR THE USE OR OTHER DEALINGS IN EXPAT. -# - - -SHELL = @SHELL@ - -srcdir = @srcdir@ -top_srcdir = @top_srcdir@ -VPATH = @srcdir@ -prefix = @prefix@ -exec_prefix = @exec_prefix@ - -blddir = @blddir@/lib -bindir = @bindir@ -sbindir = @sbindir@ -libexecdir = @libexecdir@ -datadir = @datadir@ -sysconfdir = @sysconfdir@ -sharedstatedir = @sharedstatedir@ -localstatedir = @localstatedir@ -libdir = @libdir@ -infodir = @infodir@ -mandir = @mandir@ -includedir = @includedir@ -oldincludedir = /usr/include - -subdir = lib - -top_builddir = .. - -INSTALL = @INSTALL@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_DATA = @INSTALL_DATA@ - -host_alias = @host_alias@ -host_triplet = @host@ -AS = @AS@ -CC = @CC@ -DLLTOOL = @DLLTOOL@ -LIBTOOL = @LIBTOOL@ -LN_S = @LN_S@ -OBJDUMP = @OBJDUMP@ -PACKAGE = @PACKAGE@ -RANLIB = @RANLIB@ -VERSION = @VERSION@ - -LIBRARY = libexpat.la -SOURCES = xmlparse.c xmltok.c xmlrole.c -OBJECTS = $(SOURCES:.c=.o) -LTOBJECTS = $(SOURCES:.c=.lo) - -TEMPLATES = xmltok_impl.c xmltok_ns.c -APIHEADER = expat.h -HEADERS = ascii.h iasciitab.h utf8tab.h xmltok.h asciitab.h latin1tab.h \ - nametab.h xmldef.h xmlrole.h xmltok_impl.h - -mkinstalldirs = $(SHELL) $(top_srcdir)/conftools/mkinstalldirs -CONFIG_HEADER = ../config.h -CONFIG_CLEAN_FILES = - -INCLUDES = -I$(srcdir) -I.. -I$(blddir) -DEFS = @DEFS@ -DPACKAGE='"$(PACKAGE)"' -DVERSION='"$(PACKAGE)_$(VERSION)"' - -CPPFLAGS = @CPPFLAGS@ -LDFLAGS = @LDFLAGS@ -LIBS = @LIBS@ -CFLAGS = @CFLAGS@ - -LIBREVISION = @LIBREVISION@ -LIBCURRENT = @LIBCURRENT@ -LIBAGE = @LIBAGE@ - -COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -CCLD = $(CC) -LINK = $(LIBTOOL) --mode=link $(CCLD) -version-info $(LIBCURRENT):$(LIBREVISION):$(LIBAGE) $(CFLAGS) $(LDFLAGS) -o $@ -DIST_COMMON = Makefile.in - - -DISTFILES = $(DIST_COMMON) $(SOURCES) $(TEMPLATES) $(APIHEADER) $(HEADERS) - -TAR = gtar -GZIP_ENV = --best - -all: $(LIBRARY) - -.SUFFIXES: .c .lo .o -.PHONY: all clean distclean maintainer-clean - -.c.o: - $(COMPILE) -c $< - -.c.lo: - $(LTCOMPILE) -c $< - -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - cd $(top_builddir) \ - && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status - -$(top_builddir)/config.status: $(top_builddir)/configure - cd $(top_builddir) && $(MAKE) config.status - -$(top_builddir)/config.h: $(top_builddir)/config.h.in - cd $(top_builddir) && $(MAKE) config.h - -clean: - rm -f $(LIBRARY) *.o *.lo *~ - rm -rf .libs _libs - -distclean: clean - rm -f Makefile expat.h - -maintainer-clean: distclean - -install: $(LIBRARY) $(APIHEADER) - $(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir) - $(LIBTOOL) --mode=install $(INSTALL) $(LIBRARY) $(DESTDIR)$(libdir)/$(LIBRARY) - $(INSTALL_DATA) $(APIHEADER) $(DESTDIR)$(includedir) - -uninstall: - $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$(LIBRARY); - rm -f $(DESTDIR)$(libdir)/$(APIHEADER) - -$(LIBRARY): $(LTOBJECTS) - $(LINK) -rpath $(libdir) $(LDFLAGS) $(LTOBJECTS) - -xmlparse.o \ -xmlparse.lo: xmlparse.c expat.h xmlrole.h xmltok.h $(top_builddir)/config.h - -xmlrole.o \ -xmlrole.lo: xmlrole.c ascii.h xmlrole.h $(top_builddir)/config.h - -xmltok.o \ -xmltok.lo: xmltok.c xmltok_impl.c xmltok_ns.c \ - ascii.h asciitab.h iasciitab.h latin1tab.h nametab.h utf8tab.h \ - xmltok.h xmltok_impl.h $(top_builddir)/config.h diff --git a/libs/apr-util/xml/expat/lib/ascii.h b/libs/apr-util/xml/expat/lib/ascii.h deleted file mode 100644 index 6376b1f311..0000000000 --- a/libs/apr-util/xml/expat/lib/ascii.h +++ /dev/null @@ -1,86 +0,0 @@ -/* -Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd -See the file COPYING for copying permission. -*/ - -#define ASCII_A 0x41 -#define ASCII_B 0x42 -#define ASCII_C 0x43 -#define ASCII_D 0x44 -#define ASCII_E 0x45 -#define ASCII_F 0x46 -#define ASCII_G 0x47 -#define ASCII_H 0x48 -#define ASCII_I 0x49 -#define ASCII_J 0x4A -#define ASCII_K 0x4B -#define ASCII_L 0x4C -#define ASCII_M 0x4D -#define ASCII_N 0x4E -#define ASCII_O 0x4F -#define ASCII_P 0x50 -#define ASCII_Q 0x51 -#define ASCII_R 0x52 -#define ASCII_S 0x53 -#define ASCII_T 0x54 -#define ASCII_U 0x55 -#define ASCII_V 0x56 -#define ASCII_W 0x57 -#define ASCII_X 0x58 -#define ASCII_Y 0x59 -#define ASCII_Z 0x5A - -#define ASCII_a 0x61 -#define ASCII_b 0x62 -#define ASCII_c 0x63 -#define ASCII_d 0x64 -#define ASCII_e 0x65 -#define ASCII_f 0x66 -#define ASCII_g 0x67 -#define ASCII_h 0x68 -#define ASCII_i 0x69 -#define ASCII_j 0x6A -#define ASCII_k 0x6B -#define ASCII_l 0x6C -#define ASCII_m 0x6D -#define ASCII_n 0x6E -#define ASCII_o 0x6F -#define ASCII_p 0x70 -#define ASCII_q 0x71 -#define ASCII_r 0x72 -#define ASCII_s 0x73 -#define ASCII_t 0x74 -#define ASCII_u 0x75 -#define ASCII_v 0x76 -#define ASCII_w 0x77 -#define ASCII_x 0x78 -#define ASCII_y 0x79 -#define ASCII_z 0x7A - -#define ASCII_0 0x30 -#define ASCII_1 0x31 -#define ASCII_2 0x32 -#define ASCII_3 0x33 -#define ASCII_4 0x34 -#define ASCII_5 0x35 -#define ASCII_6 0x36 -#define ASCII_7 0x37 -#define ASCII_8 0x38 -#define ASCII_9 0x39 - -#define ASCII_TAB 0x09 -#define ASCII_SPACE 0x20 -#define ASCII_EXCL 0x21 -#define ASCII_QUOT 0x22 -#define ASCII_AMP 0x26 -#define ASCII_APOS 0x27 -#define ASCII_MINUS 0x2D -#define ASCII_PERIOD 0x2E -#define ASCII_COLON 0x3A -#define ASCII_SEMI 0x3B -#define ASCII_LT 0x3C -#define ASCII_EQUALS 0x3D -#define ASCII_GT 0x3E -#define ASCII_LSQB 0x5B -#define ASCII_RSQB 0x5D -#define ASCII_UNDERSCORE 0x5F diff --git a/libs/apr-util/xml/expat/lib/asciitab.h b/libs/apr-util/xml/expat/lib/asciitab.h deleted file mode 100644 index eb445cc52c..0000000000 --- a/libs/apr-util/xml/expat/lib/asciitab.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd -See the file COPYING for copying permission. -*/ - -/* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML, -/* 0x0C */ BT_NONXML, BT_CR, BT_NONXML, BT_NONXML, -/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM, -/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS, -/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS, -/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL, -/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT, -/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT, -/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI, -/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST, -/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX, -/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT, -/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB, -/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT, -/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX, -/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT, -/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER, -/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER, diff --git a/libs/apr-util/xml/expat/lib/config.hnw b/libs/apr-util/xml/expat/lib/config.hnw deleted file mode 100644 index de129d343c..0000000000 --- a/libs/apr-util/xml/expat/lib/config.hnw +++ /dev/null @@ -1,23 +0,0 @@ -/*================================================================ -** Copyright 2000, Clark Cooper -** All rights reserved. -** -** This is free software. You are permitted to copy, distribute, or modify -** it under the terms of the MIT/X license (contained in the COPYING file -** with this distribution.) -** -** -*/ - -#ifndef CONFIG_HNW -#define CONFIG_HNW - -#include -#include - -#define XML_NS 1 -#define XML_DTD 1 -#define XML_BYTE_ORDER 12 -#define XML_CONTEXT_BYTES 1024 - -#endif /* ndef CONFIG_HNW */ diff --git a/libs/apr-util/xml/expat/lib/expat.dsp b/libs/apr-util/xml/expat/lib/expat.dsp deleted file mode 100644 index 3de22e9eb3..0000000000 --- a/libs/apr-util/xml/expat/lib/expat.dsp +++ /dev/null @@ -1,227 +0,0 @@ -# Microsoft Developer Studio Project File - Name="expat" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=expat - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "expat.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "expat.mak" CFG="expat - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "expat - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "expat - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "expat - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /W3 /EHsc /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXPAT_EXPORTS" /Yu"stdafx.h" /FD /c -# ADD CPP /nologo /MT /W3 /EHsc /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXPAT_EXPORTS" /D "COMPILED_FROM_DSP" /Yu"stdafx.h" /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 - -!ELSEIF "$(CFG)" == "expat - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /W3 /Gm /EHsc /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXPAT_EXPORTS" /Yu"stdafx.h" /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /EHsc /Zi /Od /D "_DEBUG" /D "COMPILED_FROM_DSP" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXPAT_EXPORTS" /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "expat - Win32 Release" -# Name "expat - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\xmlparse.c - -!IF "$(CFG)" == "expat - Win32 Release" - -# ADD CPP /D VERSION=\"expat_1.95.2\" - -!ELSEIF "$(CFG)" == "expat - Win32 Debug" - -# ADD CPP /GX- /Od /D VERSION=\"expat_1.95.2\" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\xmlrole.c - -!IF "$(CFG)" == "expat - Win32 Release" - -# ADD CPP /D VERSION=\"expat_1.95.2\" - -!ELSEIF "$(CFG)" == "expat - Win32 Debug" - -# ADD CPP /D VERSION=\"expat_1.95.2\" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\xmltok.c - -!IF "$(CFG)" == "expat - Win32 Release" - -# ADD CPP /D VERSION=\"expat_1.95.2\" - -!ELSEIF "$(CFG)" == "expat - Win32 Debug" - -# ADD CPP /D VERSION=\"expat_1.95.2\" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=xmltok_impl.c - -!IF "$(CFG)" == "expat - Win32 Release" - -# ADD CPP /D VERSION=\"expat_1.95.2\" - -!ELSEIF "$(CFG)" == "expat - Win32 Debug" - -# PROP Exclude_From_Build 1 -# ADD CPP /D VERSION=\"expat_1.95.2\" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=xmltok_ns.c - -!IF "$(CFG)" == "expat - Win32 Release" - -# ADD CPP /D VERSION=\"expat_1.95.2\" - -!ELSEIF "$(CFG)" == "expat - Win32 Debug" - -# PROP Exclude_From_Build 1 -# ADD CPP /D VERSION=\"expat_1.95.2\" - -!ENDIF - -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=.\ascii.h -# End Source File -# Begin Source File - -SOURCE=.\asciitab.h -# End Source File -# Begin Source File - -SOURCE=.\config.h -# End Source File -# Begin Source File - -SOURCE=.\expat.h -# End Source File -# Begin Source File - -SOURCE=.\iasciitab.h -# End Source File -# Begin Source File - -SOURCE=.\latin1tab.h -# End Source File -# Begin Source File - -SOURCE=.\nametab.h -# End Source File -# Begin Source File - -SOURCE=.\utf8tab.h -# End Source File -# Begin Source File - -SOURCE=.\xmlrole.h -# End Source File -# Begin Source File - -SOURCE=.\xmltok.h -# End Source File -# Begin Source File - -SOURCE=.\xmltok_impl.h -# End Source File -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" -# End Group -# Begin Source File - -SOURCE=.\ReadMe.txt -# End Source File -# End Target -# End Project diff --git a/libs/apr-util/xml/expat/lib/expat.h.in b/libs/apr-util/xml/expat/lib/expat.h.in deleted file mode 100644 index 9e440e2009..0000000000 --- a/libs/apr-util/xml/expat/lib/expat.h.in +++ /dev/null @@ -1,742 +0,0 @@ -/* -Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd -See the file COPYING for copying permission. -*/ - -#ifndef XmlParse_INCLUDED -#define XmlParse_INCLUDED 1 - -#include - -#ifndef XMLPARSEAPI -# if defined(__declspec) && !defined(__CYGWIN__) -# define XMLPARSEAPI __declspec(dllimport) -# else -# define XMLPARSEAPI /* nothing */ -# endif -#endif /* not defined XMLPARSEAPI */ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void *XML_Parser; - -/* Information is UTF-8 encoded. */ -typedef char XML_Char; -typedef char XML_LChar; - -enum XML_Content_Type { - XML_CTYPE_EMPTY = 1, - XML_CTYPE_ANY, - XML_CTYPE_MIXED, - XML_CTYPE_NAME, - XML_CTYPE_CHOICE, - XML_CTYPE_SEQ -}; - -enum XML_Content_Quant { - XML_CQUANT_NONE, - XML_CQUANT_OPT, - XML_CQUANT_REP, - XML_CQUANT_PLUS -}; - -/* If type == XML_CTYPE_EMPTY or XML_CTYPE_ANY, then quant will be - XML_CQUANT_NONE, and the other fields will be zero or NULL. - If type == XML_CTYPE_MIXED, then quant will be NONE or REP and - numchildren will contain number of elements that may be mixed in - and children point to an array of XML_Content cells that will be - all of XML_CTYPE_NAME type with no quantification. - - If type == XML_CTYPE_NAME, then the name points to the name, and - the numchildren field will be zero and children will be NULL. The - quant fields indicates any quantifiers placed on the name. - - CHOICE and SEQ will have name NULL, the number of children in - numchildren and children will point, recursively, to an array - of XML_Content cells. - - The EMPTY, ANY, and MIXED types will only occur at top level. -*/ - -typedef struct XML_cp XML_Content; - -struct XML_cp { - enum XML_Content_Type type; - enum XML_Content_Quant quant; - const XML_Char * name; - unsigned int numchildren; - XML_Content * children; -}; - - -/* This is called for an element declaration. See above for - description of the model argument. It's the caller's responsibility - to free model when finished with it. -*/ - -typedef void (*XML_ElementDeclHandler) (void *userData, - const XML_Char *name, - XML_Content *model); - -void XMLPARSEAPI -XML_SetElementDeclHandler(XML_Parser parser, - XML_ElementDeclHandler eldecl); - -/* - The Attlist declaration handler is called for *each* attribute. So - a single Attlist declaration with multiple attributes declared will - generate multiple calls to this handler. The "default" parameter - may be NULL in the case of the "#IMPLIED" or "#REQUIRED" keyword. - The "isrequired" parameter will be true and the default value will - be NULL in the case of "#REQUIRED". If "isrequired" is true and - default is non-NULL, then this is a "#FIXED" default. - */ - -typedef void (*XML_AttlistDeclHandler) (void *userData, - const XML_Char *elname, - const XML_Char *attname, - const XML_Char *att_type, - const XML_Char *dflt, - int isrequired); - -void XMLPARSEAPI -XML_SetAttlistDeclHandler(XML_Parser parser, - XML_AttlistDeclHandler attdecl); - - - /* The XML declaration handler is called for *both* XML declarations and - text declarations. The way to distinguish is that the version parameter - will be null for text declarations. The encoding parameter may be null - for XML declarations. The standalone parameter will be -1, 0, or 1 - indicating respectively that there was no standalone parameter in - the declaration, that it was given as no, or that it was given as yes. - */ - -typedef void (*XML_XmlDeclHandler) (void *userData, - const XML_Char *version, - const XML_Char *encoding, - int standalone); - -void XMLPARSEAPI -XML_SetXmlDeclHandler(XML_Parser parser, - XML_XmlDeclHandler xmldecl); - - -typedef struct { - void *(*malloc_fcn)(size_t size); - void *(*realloc_fcn)(void *ptr, size_t size); - void (*free_fcn)(void *ptr); -} XML_Memory_Handling_Suite; - -/* Constructs a new parser; encoding is the encoding specified by the -external protocol or null if there is none specified. */ - -XML_Parser XMLPARSEAPI -XML_ParserCreate(const XML_Char *encoding); - -/* Constructs a new parser and namespace processor. Element type -names and attribute names that belong to a namespace will be expanded; -unprefixed attribute names are never expanded; unprefixed element type -names are expanded only if there is a default namespace. The expanded -name is the concatenation of the namespace URI, the namespace -separator character, and the local part of the name. If the namespace -separator is '\0' then the namespace URI and the local part will be -concatenated without any separator. When a namespace is not declared, -the name and prefix will be passed through without expansion. */ - -XML_Parser XMLPARSEAPI -XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator); - - -/* Constructs a new parser using the memory management suit referred to - by memsuite. If memsuite is NULL, then use the standard library memory - suite. If namespaceSeparator is non-NULL it creates a parser with - namespace processing as described above. The character pointed at - will serve as the namespace separator. - - All further memory operations used for the created parser will come from - the given suite. -*/ - -XML_Parser XMLPARSEAPI -XML_ParserCreate_MM(const XML_Char *encoding, - const XML_Memory_Handling_Suite *memsuite, - const XML_Char *namespaceSeparator); - -/* atts is array of name/value pairs, terminated by 0; - names and values are 0 terminated. */ - -typedef void (*XML_StartElementHandler)(void *userData, - const XML_Char *name, - const XML_Char **atts); - -typedef void (*XML_EndElementHandler)(void *userData, - const XML_Char *name); - - -/* s is not 0 terminated. */ -typedef void (*XML_CharacterDataHandler)(void *userData, - const XML_Char *s, - int len); - -/* target and data are 0 terminated */ -typedef void (*XML_ProcessingInstructionHandler)(void *userData, - const XML_Char *target, - const XML_Char *data); - -/* data is 0 terminated */ -typedef void (*XML_CommentHandler)(void *userData, const XML_Char *data); - -typedef void (*XML_StartCdataSectionHandler)(void *userData); -typedef void (*XML_EndCdataSectionHandler)(void *userData); - -/* This is called for any characters in the XML document for -which there is no applicable handler. This includes both -characters that are part of markup which is of a kind that is -not reported (comments, markup declarations), or characters -that are part of a construct which could be reported but -for which no handler has been supplied. The characters are passed -exactly as they were in the XML document except that -they will be encoded in UTF-8. Line boundaries are not normalized. -Note that a byte order mark character is not passed to the default handler. -There are no guarantees about how characters are divided between calls -to the default handler: for example, a comment might be split between -multiple calls. */ - -typedef void (*XML_DefaultHandler)(void *userData, - const XML_Char *s, - int len); - -/* This is called for the start of the DOCTYPE declaration, before - any DTD or internal subset is parsed. */ - -typedef void (*XML_StartDoctypeDeclHandler)(void *userData, - const XML_Char *doctypeName, - const XML_Char *sysid, - const XML_Char *pubid, - int has_internal_subset - ); - -/* This is called for the start of the DOCTYPE declaration when the -closing > is encountered, but after processing any external subset. */ -typedef void (*XML_EndDoctypeDeclHandler)(void *userData); - -/* This is called for entity declarations. The is_parameter_entity - argument will be non-zero if the entity is a parameter entity, zero - otherwise. - - For internal entities (), value will - be non-null and systemId, publicID, and notationName will be null. - The value string is NOT null terminated; the length is provided in - the value_length argument. Since it is legal to have zero-length - values, do not use this argument to test for internal entities. - - For external entities, value will be null and systemId will be non-null. - The publicId argument will be null unless a public identifier was - provided. The notationName argument will have a non-null value only - for unparsed entity declarations. -*/ - -typedef void (*XML_EntityDeclHandler) (void *userData, - const XML_Char *entityName, - int is_parameter_entity, - const XML_Char *value, - int value_length, - const XML_Char *base, - const XML_Char *systemId, - const XML_Char *publicId, - const XML_Char *notationName); - -void XMLPARSEAPI -XML_SetEntityDeclHandler(XML_Parser parser, - XML_EntityDeclHandler handler); - -/* OBSOLETE -- OBSOLETE -- OBSOLETE - This handler has been superceded by the EntityDeclHandler above. - It is provided here for backward compatibility. -This is called for a declaration of an unparsed (NDATA) -entity. The base argument is whatever was set by XML_SetBase. -The entityName, systemId and notationName arguments will never be null. -The other arguments may be. */ - -typedef void (*XML_UnparsedEntityDeclHandler)(void *userData, - const XML_Char *entityName, - const XML_Char *base, - const XML_Char *systemId, - const XML_Char *publicId, - const XML_Char *notationName); - -/* This is called for a declaration of notation. -The base argument is whatever was set by XML_SetBase. -The notationName will never be null. The other arguments can be. */ - -typedef void (*XML_NotationDeclHandler)(void *userData, - const XML_Char *notationName, - const XML_Char *base, - const XML_Char *systemId, - const XML_Char *publicId); - -/* When namespace processing is enabled, these are called once for -each namespace declaration. The call to the start and end element -handlers occur between the calls to the start and end namespace -declaration handlers. For an xmlns attribute, prefix will be null. -For an xmlns="" attribute, uri will be null. */ - -typedef void (*XML_StartNamespaceDeclHandler)(void *userData, - const XML_Char *prefix, - const XML_Char *uri); - -typedef void (*XML_EndNamespaceDeclHandler)(void *userData, - const XML_Char *prefix); - -/* This is called if the document is not standalone (it has an -external subset or a reference to a parameter entity, but does not -have standalone="yes"). If this handler returns 0, then processing -will not continue, and the parser will return a -XML_ERROR_NOT_STANDALONE error. */ - -typedef int (*XML_NotStandaloneHandler)(void *userData); - -/* This is called for a reference to an external parsed general entity. -The referenced entity is not automatically parsed. -The application can parse it immediately or later using -XML_ExternalEntityParserCreate. -The parser argument is the parser parsing the entity containing the reference; -it can be passed as the parser argument to XML_ExternalEntityParserCreate. -The systemId argument is the system identifier as specified in the entity -declaration; it will not be null. -The base argument is the system identifier that should be used as the base for -resolving systemId if systemId was relative; this is set by XML_SetBase; -it may be null. -The publicId argument is the public identifier as specified in the entity -declaration, or null if none was specified; the whitespace in the public -identifier will have been normalized as required by the XML spec. -The context argument specifies the parsing context in the format -expected by the context argument to -XML_ExternalEntityParserCreate; context is valid only until the handler -returns, so if the referenced entity is to be parsed later, it must be copied. -The handler should return 0 if processing should not continue because of -a fatal error in the handling of the external entity. -In this case the calling parser will return an -XML_ERROR_EXTERNAL_ENTITY_HANDLING error. -Note that unlike other handlers the first argument is the parser, not -userData. */ - -typedef int (*XML_ExternalEntityRefHandler)(XML_Parser parser, - const XML_Char *context, - const XML_Char *base, - const XML_Char *systemId, - const XML_Char *publicId); - -/* This structure is filled in by the XML_UnknownEncodingHandler -to provide information to the parser about encodings that are unknown -to the parser. -The map[b] member gives information about byte sequences -whose first byte is b. -If map[b] is c where c is >= 0, then b by itself encodes the Unicode scalar -value c. -If map[b] is -1, then the byte sequence is malformed. -If map[b] is -n, where n >= 2, then b is the first byte of an n-byte -sequence that encodes a single Unicode scalar value. -The data member will be passed as the first argument to the convert function. -The convert function is used to convert multibyte sequences; -s will point to a n-byte sequence where map[(unsigned char)*s] == -n. -The convert function must return the Unicode scalar value -represented by this byte sequence or -1 if the byte sequence is malformed. -The convert function may be null if the encoding is a single-byte encoding, -that is if map[b] >= -1 for all bytes b. -When the parser is finished with the encoding, then if release is not null, -it will call release passing it the data member; -once release has been called, the convert function will not be called again. - -Expat places certain restrictions on the encodings that are supported -using this mechanism. - -1. Every ASCII character that can appear in a well-formed XML document, -other than the characters - - $@\^`{}~ - -must be represented by a single byte, and that byte must be the -same byte that represents that character in ASCII. - -2. No character may require more than 4 bytes to encode. - -3. All characters encoded must have Unicode scalar values <= 0xFFFF, -(ie characters that would be encoded by surrogates in UTF-16 -are not allowed). Note that this restriction doesn't apply to -the built-in support for UTF-8 and UTF-16. - -4. No Unicode character may be encoded by more than one distinct sequence -of bytes. */ - -typedef struct { - int map[256]; - void *data; - int (*convert)(void *data, const char *s); - void (*release)(void *data); -} XML_Encoding; - -/* This is called for an encoding that is unknown to the parser. -The encodingHandlerData argument is that which was passed as the -second argument to XML_SetUnknownEncodingHandler. -The name argument gives the name of the encoding as specified in -the encoding declaration. -If the callback can provide information about the encoding, -it must fill in the XML_Encoding structure, and return 1. -Otherwise it must return 0. -If info does not describe a suitable encoding, -then the parser will return an XML_UNKNOWN_ENCODING error. */ - -typedef int (*XML_UnknownEncodingHandler)(void *encodingHandlerData, - const XML_Char *name, - XML_Encoding *info); - -void XMLPARSEAPI -XML_SetElementHandler(XML_Parser parser, - XML_StartElementHandler start, - XML_EndElementHandler end); - -void XMLPARSEAPI -XML_SetStartElementHandler(XML_Parser, XML_StartElementHandler); - -void XMLPARSEAPI -XML_SetEndElementHandler(XML_Parser, XML_EndElementHandler); - -void XMLPARSEAPI -XML_SetCharacterDataHandler(XML_Parser parser, - XML_CharacterDataHandler handler); - -void XMLPARSEAPI -XML_SetProcessingInstructionHandler(XML_Parser parser, - XML_ProcessingInstructionHandler handler); -void XMLPARSEAPI -XML_SetCommentHandler(XML_Parser parser, - XML_CommentHandler handler); - -void XMLPARSEAPI -XML_SetCdataSectionHandler(XML_Parser parser, - XML_StartCdataSectionHandler start, - XML_EndCdataSectionHandler end); - -void XMLPARSEAPI -XML_SetStartCdataSectionHandler(XML_Parser parser, - XML_StartCdataSectionHandler start); - -void XMLPARSEAPI -XML_SetEndCdataSectionHandler(XML_Parser parser, - XML_EndCdataSectionHandler end); - -/* This sets the default handler and also inhibits expansion of -internal entities. The entity reference will be passed to the default -handler. */ - -void XMLPARSEAPI -XML_SetDefaultHandler(XML_Parser parser, - XML_DefaultHandler handler); - -/* This sets the default handler but does not inhibit expansion of -internal entities. The entity reference will not be passed to the -default handler. */ - -void XMLPARSEAPI -XML_SetDefaultHandlerExpand(XML_Parser parser, - XML_DefaultHandler handler); - -void XMLPARSEAPI -XML_SetDoctypeDeclHandler(XML_Parser parser, - XML_StartDoctypeDeclHandler start, - XML_EndDoctypeDeclHandler end); - -void XMLPARSEAPI -XML_SetStartDoctypeDeclHandler(XML_Parser parser, - XML_StartDoctypeDeclHandler start); - -void XMLPARSEAPI -XML_SetEndDoctypeDeclHandler(XML_Parser parser, - XML_EndDoctypeDeclHandler end); - -void XMLPARSEAPI -XML_SetUnparsedEntityDeclHandler(XML_Parser parser, - XML_UnparsedEntityDeclHandler handler); - -void XMLPARSEAPI -XML_SetNotationDeclHandler(XML_Parser parser, - XML_NotationDeclHandler handler); - -void XMLPARSEAPI -XML_SetNamespaceDeclHandler(XML_Parser parser, - XML_StartNamespaceDeclHandler start, - XML_EndNamespaceDeclHandler end); - -void XMLPARSEAPI -XML_SetStartNamespaceDeclHandler(XML_Parser parser, - XML_StartNamespaceDeclHandler start); - -void XMLPARSEAPI -XML_SetEndNamespaceDeclHandler(XML_Parser parser, - XML_EndNamespaceDeclHandler end); - -void XMLPARSEAPI -XML_SetNotStandaloneHandler(XML_Parser parser, - XML_NotStandaloneHandler handler); - -void XMLPARSEAPI -XML_SetExternalEntityRefHandler(XML_Parser parser, - XML_ExternalEntityRefHandler handler); - -/* If a non-null value for arg is specified here, then it will be passed -as the first argument to the external entity ref handler instead -of the parser object. */ -void XMLPARSEAPI -XML_SetExternalEntityRefHandlerArg(XML_Parser, void *arg); - -void XMLPARSEAPI -XML_SetUnknownEncodingHandler(XML_Parser parser, - XML_UnknownEncodingHandler handler, - void *encodingHandlerData); - -/* This can be called within a handler for a start element, end element, -processing instruction or character data. It causes the corresponding -markup to be passed to the default handler. */ -void XMLPARSEAPI -XML_DefaultCurrent(XML_Parser parser); - -/* If do_nst is non-zero, and namespace processing is in effect, and - a name has a prefix (i.e. an explicit namespace qualifier) then - that name is returned as a triplet in a single - string separated by the separator character specified when the parser - was created: URI + sep + local_name + sep + prefix. - - If do_nst is zero, then namespace information is returned in the - default manner (URI + sep + local_name) whether or not the names - has a prefix. -*/ - -void XMLPARSEAPI -XML_SetReturnNSTriplet(XML_Parser parser, int do_nst); - -/* This value is passed as the userData argument to callbacks. */ -void XMLPARSEAPI -XML_SetUserData(XML_Parser parser, void *userData); - -/* Returns the last value set by XML_SetUserData or null. */ -#define XML_GetUserData(parser) (*(void **)(parser)) - -/* This is equivalent to supplying an encoding argument -to XML_ParserCreate. It must not be called after XML_Parse -or XML_ParseBuffer. */ - -int XMLPARSEAPI -XML_SetEncoding(XML_Parser parser, const XML_Char *encoding); - -/* If this function is called, then the parser will be passed -as the first argument to callbacks instead of userData. -The userData will still be accessible using XML_GetUserData. */ - -void XMLPARSEAPI -XML_UseParserAsHandlerArg(XML_Parser parser); - -/* Sets the base to be used for resolving relative URIs in system -identifiers in declarations. Resolving relative identifiers is left -to the application: this value will be passed through as the base -argument to the XML_ExternalEntityRefHandler, XML_NotationDeclHandler -and XML_UnparsedEntityDeclHandler. The base argument will be copied. -Returns zero if out of memory, non-zero otherwise. */ - -int XMLPARSEAPI -XML_SetBase(XML_Parser parser, const XML_Char *base); - -const XML_Char XMLPARSEAPI * -XML_GetBase(XML_Parser parser); - -/* Returns the number of the attribute/value pairs passed in last call -to the XML_StartElementHandler that were specified in the start-tag -rather than defaulted. Each attribute/value pair counts as 2; thus -this correspondds to an index into the atts array passed to the -XML_StartElementHandler. */ - -int XMLPARSEAPI -XML_GetSpecifiedAttributeCount(XML_Parser parser); - -/* Returns the index of the ID attribute passed in the last call to -XML_StartElementHandler, or -1 if there is no ID attribute. Each -attribute/value pair counts as 2; thus this correspondds to an index -into the atts array passed to the XML_StartElementHandler. */ - -int XMLPARSEAPI -XML_GetIdAttributeIndex(XML_Parser parser); - -/* Parses some input. Returns 0 if a fatal error is detected. -The last call to XML_Parse must have isFinal true; -len may be zero for this call (or any other). */ -int XMLPARSEAPI -XML_Parse(XML_Parser parser, const char *s, int len, int isFinal); - -void XMLPARSEAPI * -XML_GetBuffer(XML_Parser parser, int len); - -int XMLPARSEAPI -XML_ParseBuffer(XML_Parser parser, int len, int isFinal); - -/* Creates an XML_Parser object that can parse an external general -entity; context is a '\0'-terminated string specifying the parse -context; encoding is a '\0'-terminated string giving the name of the -externally specified encoding, or null if there is no externally -specified encoding. The context string consists of a sequence of -tokens separated by formfeeds (\f); a token consisting of a name -specifies that the general entity of the name is open; a token of the -form prefix=uri specifies the namespace for a particular prefix; a -token of the form =uri specifies the default namespace. This can be -called at any point after the first call to an -ExternalEntityRefHandler so longer as the parser has not yet been -freed. The new parser is completely independent and may safely be -used in a separate thread. The handlers and userData are initialized -from the parser argument. Returns 0 if out of memory. Otherwise -returns a new XML_Parser object. */ -XML_Parser XMLPARSEAPI -XML_ExternalEntityParserCreate(XML_Parser parser, - const XML_Char *context, - const XML_Char *encoding); - -enum XML_ParamEntityParsing { - XML_PARAM_ENTITY_PARSING_NEVER, - XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE, - XML_PARAM_ENTITY_PARSING_ALWAYS -}; - -/* Controls parsing of parameter entities (including the external DTD -subset). If parsing of parameter entities is enabled, then references -to external parameter entities (including the external DTD subset) -will be passed to the handler set with -XML_SetExternalEntityRefHandler. The context passed will be 0. -Unlike external general entities, external parameter entities can only -be parsed synchronously. If the external parameter entity is to be -parsed, it must be parsed during the call to the external entity ref -handler: the complete sequence of XML_ExternalEntityParserCreate, -XML_Parse/XML_ParseBuffer and XML_ParserFree calls must be made during -this call. After XML_ExternalEntityParserCreate has been called to -create the parser for the external parameter entity (context must be 0 -for this call), it is illegal to make any calls on the old parser -until XML_ParserFree has been called on the newly created parser. If -the library has been compiled without support for parameter entity -parsing (ie without XML_DTD being defined), then -XML_SetParamEntityParsing will return 0 if parsing of parameter -entities is requested; otherwise it will return non-zero. */ - -int XMLPARSEAPI -XML_SetParamEntityParsing(XML_Parser parser, - enum XML_ParamEntityParsing parsing); - -enum XML_Error { - XML_ERROR_NONE, - XML_ERROR_NO_MEMORY, - XML_ERROR_SYNTAX, - XML_ERROR_NO_ELEMENTS, - XML_ERROR_INVALID_TOKEN, - XML_ERROR_UNCLOSED_TOKEN, - XML_ERROR_PARTIAL_CHAR, - XML_ERROR_TAG_MISMATCH, - XML_ERROR_DUPLICATE_ATTRIBUTE, - XML_ERROR_JUNK_AFTER_DOC_ELEMENT, - XML_ERROR_PARAM_ENTITY_REF, - XML_ERROR_UNDEFINED_ENTITY, - XML_ERROR_RECURSIVE_ENTITY_REF, - XML_ERROR_ASYNC_ENTITY, - XML_ERROR_BAD_CHAR_REF, - XML_ERROR_BINARY_ENTITY_REF, - XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF, - XML_ERROR_MISPLACED_XML_PI, - XML_ERROR_UNKNOWN_ENCODING, - XML_ERROR_INCORRECT_ENCODING, - XML_ERROR_UNCLOSED_CDATA_SECTION, - XML_ERROR_EXTERNAL_ENTITY_HANDLING, - XML_ERROR_NOT_STANDALONE, - XML_ERROR_UNEXPECTED_STATE -}; - -/* If XML_Parse or XML_ParseBuffer have returned 0, then XML_GetErrorCode -returns information about the error. */ - -enum XML_Error XMLPARSEAPI -XML_GetErrorCode(XML_Parser parser); - -/* These functions return information about the current parse location. -They may be called when XML_Parse or XML_ParseBuffer return 0; -in this case the location is the location of the character at which -the error was detected. -They may also be called from any other callback called to report -some parse event; in this the location is the location of the first -of the sequence of characters that generated the event. */ - -int XMLPARSEAPI XML_GetCurrentLineNumber(XML_Parser parser); -int XMLPARSEAPI XML_GetCurrentColumnNumber(XML_Parser parser); -long XMLPARSEAPI XML_GetCurrentByteIndex(XML_Parser parser); - -/* Return the number of bytes in the current event. -Returns 0 if the event is in an internal entity. */ - -int XMLPARSEAPI -XML_GetCurrentByteCount(XML_Parser parser); - -/* If XML_CONTEXT_BYTES is defined, returns the input buffer, sets - the integer pointed to by offset to the offset within this buffer - of the current parse position, and sets the integer pointed to by size - to the size of this buffer (the number of input bytes). Otherwise - returns a null pointer. Also returns a null pointer if a parse isn't - active. - - NOTE: The character pointer returned should not be used outside - the handler that makes the call. */ - -const char XMLPARSEAPI * -XML_GetInputContext(XML_Parser parser, - int *offset, - int *size); - -/* For backwards compatibility with previous versions. */ -#define XML_GetErrorLineNumber XML_GetCurrentLineNumber -#define XML_GetErrorColumnNumber XML_GetCurrentColumnNumber -#define XML_GetErrorByteIndex XML_GetCurrentByteIndex - -/* Frees memory used by the parser. */ -void XMLPARSEAPI -XML_ParserFree(XML_Parser parser); - -/* Returns a string describing the error. */ -const XML_LChar XMLPARSEAPI * -XML_ErrorString(int code); - -/* Return a string containing the version number of this expat */ -const XML_LChar XMLPARSEAPI * -XML_ExpatVersion(void); - -typedef struct { - int major; - int minor; - int micro; -} XML_Expat_Version; - -/* Return an XML_Expat_Version structure containing numeric version - number information for this version of expat */ - -XML_Expat_Version XMLPARSEAPI -XML_ExpatVersionInfo(void); - -#ifndef XML_MAJOR_VERSION -#define XML_MAJOR_VERSION 1 -#endif -#ifndef XML_MINOR_VERSION -#define XML_MINOR_VERSION 95 -#endif -#ifndef XML_MICRO_VERSION -#define XML_MICRO_VERSION 2 -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* not XmlParse_INCLUDED */ diff --git a/libs/apr-util/xml/expat/lib/iasciitab.h b/libs/apr-util/xml/expat/lib/iasciitab.h deleted file mode 100644 index 55dbc398b8..0000000000 --- a/libs/apr-util/xml/expat/lib/iasciitab.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd -See the file COPYING for copying permission. -*/ - -/* Like asciitab.h, except that 0xD has code BT_S rather than BT_CR */ -/* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML, -/* 0x0C */ BT_NONXML, BT_S, BT_NONXML, BT_NONXML, -/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM, -/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS, -/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS, -/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL, -/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT, -/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT, -/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI, -/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST, -/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX, -/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT, -/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB, -/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT, -/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX, -/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT, -/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER, -/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER, diff --git a/libs/apr-util/xml/expat/lib/latin1tab.h b/libs/apr-util/xml/expat/lib/latin1tab.h deleted file mode 100644 index 178b1d186d..0000000000 --- a/libs/apr-util/xml/expat/lib/latin1tab.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd -See the file COPYING for copying permission. -*/ - -/* 0x80 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 0x84 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 0x88 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 0x8C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 0x90 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 0x94 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 0x98 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 0x9C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 0xA0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 0xA4 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 0xA8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER, -/* 0xAC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 0xB0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 0xB4 */ BT_OTHER, BT_NMSTRT, BT_OTHER, BT_NAME, -/* 0xB8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER, -/* 0xBC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 0xC0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0xC4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0xC8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0xCC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0xD0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0xD4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER, -/* 0xD8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0xDC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0xE0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0xE4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0xE8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0xEC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0xF0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0xF4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER, -/* 0xF8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0xFC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, diff --git a/libs/apr-util/xml/expat/lib/map_osd_ebcdic_df04_1.h b/libs/apr-util/xml/expat/lib/map_osd_ebcdic_df04_1.h deleted file mode 100644 index 93ece0c887..0000000000 --- a/libs/apr-util/xml/expat/lib/map_osd_ebcdic_df04_1.h +++ /dev/null @@ -1,18 +0,0 @@ -static unsigned char ebcdic[] = { -/* 00 */ 0x00 ,0x01 ,0x02 ,0x03 ,0x85 ,0x09 ,0x86 ,0x7f ,0x87 ,0x8d ,0x8e ,0x0b ,0x0c ,0x0d ,0x0e ,0x0f , -/* 10 */ 0x10 ,0x11 ,0x12 ,0x13 ,0x8f ,0x0a ,0x08 ,0x97 ,0x18 ,0x19 ,0x9c ,0x9d ,0x1c ,0x1d ,0x1e ,0x1f , -/* 20 */ 0x80 ,0x81 ,0x82 ,0x83 ,0x84 ,0x92 ,0x17 ,0x1b ,0x88 ,0x89 ,0x8a ,0x8b ,0x8c ,0x05 ,0x06 ,0x07 , -/* 30 */ 0x90 ,0x91 ,0x16 ,0x93 ,0x94 ,0x95 ,0x96 ,0x04 ,0x98 ,0x99 ,0x9a ,0x9b ,0x14 ,0x15 ,0x9e ,0x1a , -/* 40 */ 0x20 ,0xa0 ,0xe2 ,0xe4 ,0xe0 ,0xe1 ,0xe3 ,0xe5 ,0xe7 ,0xf1 ,0x60 ,0x2e ,0x3c ,0x28 ,0x2b ,0x7c , -/* 50 */ 0x26 ,0xe9 ,0xea ,0xeb ,0xe8 ,0xed ,0xee ,0xef ,0xec ,0xdf ,0x21 ,0x24 ,0x2a ,0x29 ,0x3b ,0x9f , -/* 60 */ 0x2d ,0x2f ,0xc2 ,0xc4 ,0xc0 ,0xc1 ,0xc3 ,0xc5 ,0xc7 ,0xd1 ,0x5e ,0x2c ,0x25 ,0x5f ,0x3e ,0x3f , -/* 70 */ 0xf8 ,0xc9 ,0xca ,0xcb ,0xc8 ,0xcd ,0xce ,0xcf ,0xcc ,0xa8 ,0x3a ,0x23 ,0x40 ,0x27 ,0x3d ,0x22 , -/* 80 */ 0xd8 ,0x61 ,0x62 ,0x63 ,0x64 ,0x65 ,0x66 ,0x67 ,0x68 ,0x69 ,0xab ,0xbb ,0xf0 ,0xfd ,0xfe ,0xb1 , -/* 90 */ 0xb0 ,0x6a ,0x6b ,0x6c ,0x6d ,0x6e ,0x6f ,0x70 ,0x71 ,0x72 ,0xaa ,0xba ,0xe6 ,0xb8 ,0xc6 ,0xa4 , -/* a0 */ 0xb5 ,0xaf ,0x73 ,0x74 ,0x75 ,0x76 ,0x77 ,0x78 ,0x79 ,0x7a ,0xa1 ,0xbf ,0xd0 ,0xdd ,0xde ,0xae , -/* b0 */ 0xa2 ,0xa3 ,0xa5 ,0xb7 ,0xa9 ,0xa7 ,0xb6 ,0xbc ,0xbd ,0xbe ,0xac ,0x5b ,0x5c ,0x5d ,0xb4 ,0xd7 , -/* c0 */ 0xf9 ,0x41 ,0x42 ,0x43 ,0x44 ,0x45 ,0x46 ,0x47 ,0x48 ,0x49 ,0xad ,0xf4 ,0xf6 ,0xf2 ,0xf3 ,0xf5 , -/* d0 */ 0xa6 ,0x4a ,0x4b ,0x4c ,0x4d ,0x4e ,0x4f ,0x50 ,0x51 ,0x52 ,0xb9 ,0xfb ,0xfc ,0xdb ,0xfa ,0xff , -/* e0 */ 0xd9 ,0xf7 ,0x53 ,0x54 ,0x55 ,0x56 ,0x57 ,0x58 ,0x59 ,0x5a ,0xb2 ,0xd4 ,0xd6 ,0xd2 ,0xd3 ,0xd5 , -/* f0 */ 0x30 ,0x31 ,0x32 ,0x33 ,0x34 ,0x35 ,0x36 ,0x37 ,0x38 ,0x39 ,0xb3 ,0x7b ,0xdc ,0x7d ,0xda ,0x7e -}; diff --git a/libs/apr-util/xml/expat/lib/nametab.h b/libs/apr-util/xml/expat/lib/nametab.h deleted file mode 100644 index b05e62c77a..0000000000 --- a/libs/apr-util/xml/expat/lib/nametab.h +++ /dev/null @@ -1,150 +0,0 @@ -static const unsigned namingBitmap[] = { -0x00000000, 0x00000000, 0x00000000, 0x00000000, -0x00000000, 0x00000000, 0x00000000, 0x00000000, -0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, -0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, -0x00000000, 0x04000000, 0x87FFFFFE, 0x07FFFFFE, -0x00000000, 0x00000000, 0xFF7FFFFF, 0xFF7FFFFF, -0xFFFFFFFF, 0x7FF3FFFF, 0xFFFFFDFE, 0x7FFFFFFF, -0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFE00F, 0xFC31FFFF, -0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF, -0xFFFFFFFF, 0xF80001FF, 0x00000003, 0x00000000, -0x00000000, 0x00000000, 0x00000000, 0x00000000, -0xFFFFD740, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD, -0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF, -0xFFFF0003, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF, -0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE, -0x0000007F, 0x00000000, 0xFFFF0000, 0x000707FF, -0x00000000, 0x07FFFFFE, 0x000007FE, 0xFFFE0000, -0xFFFFFFFF, 0x7CFFFFFF, 0x002F7FFF, 0x00000060, -0xFFFFFFE0, 0x23FFFFFF, 0xFF000000, 0x00000003, -0xFFF99FE0, 0x03C5FDFF, 0xB0000000, 0x00030003, -0xFFF987E0, 0x036DFDFF, 0x5E000000, 0x001C0000, -0xFFFBAFE0, 0x23EDFDFF, 0x00000000, 0x00000001, -0xFFF99FE0, 0x23CDFDFF, 0xB0000000, 0x00000003, -0xD63DC7E0, 0x03BFC718, 0x00000000, 0x00000000, -0xFFFDDFE0, 0x03EFFDFF, 0x00000000, 0x00000003, -0xFFFDDFE0, 0x03EFFDFF, 0x40000000, 0x00000003, -0xFFFDDFE0, 0x03FFFDFF, 0x00000000, 0x00000003, -0x00000000, 0x00000000, 0x00000000, 0x00000000, -0xFFFFFFFE, 0x000D7FFF, 0x0000003F, 0x00000000, -0xFEF02596, 0x200D6CAE, 0x0000001F, 0x00000000, -0x00000000, 0x00000000, 0xFFFFFEFF, 0x000003FF, -0x00000000, 0x00000000, 0x00000000, 0x00000000, -0x00000000, 0x00000000, 0x00000000, 0x00000000, -0x00000000, 0xFFFFFFFF, 0xFFFF003F, 0x007FFFFF, -0x0007DAED, 0x50000000, 0x82315001, 0x002C62AB, -0x40000000, 0xF580C900, 0x00000007, 0x02010800, -0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, -0x0FFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x03FFFFFF, -0x3F3FFFFF, 0xFFFFFFFF, 0xAAFF3F3F, 0x3FFFFFFF, -0xFFFFFFFF, 0x5FDFFFFF, 0x0FCF1FDC, 0x1FDC1FFF, -0x00000000, 0x00004C40, 0x00000000, 0x00000000, -0x00000007, 0x00000000, 0x00000000, 0x00000000, -0x00000080, 0x000003FE, 0xFFFFFFFE, 0xFFFFFFFF, -0x001FFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0x07FFFFFF, -0xFFFFFFE0, 0x00001FFF, 0x00000000, 0x00000000, -0x00000000, 0x00000000, 0x00000000, 0x00000000, -0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, -0xFFFFFFFF, 0x0000003F, 0x00000000, 0x00000000, -0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, -0xFFFFFFFF, 0x0000000F, 0x00000000, 0x00000000, -0x00000000, 0x07FF6000, 0x87FFFFFE, 0x07FFFFFE, -0x00000000, 0x00800000, 0xFF7FFFFF, 0xFF7FFFFF, -0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF, -0xFFFFFFFF, 0xF80001FF, 0x00030003, 0x00000000, -0xFFFFFFFF, 0xFFFFFFFF, 0x0000003F, 0x00000003, -0xFFFFD7C0, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD, -0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF, -0xFFFF007B, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF, -0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE, -0xFFFE007F, 0xBBFFFFFB, 0xFFFF0016, 0x000707FF, -0x00000000, 0x07FFFFFE, 0x0007FFFF, 0xFFFF03FF, -0xFFFFFFFF, 0x7CFFFFFF, 0xFFEF7FFF, 0x03FF3DFF, -0xFFFFFFEE, 0xF3FFFFFF, 0xFF1E3FFF, 0x0000FFCF, -0xFFF99FEE, 0xD3C5FDFF, 0xB080399F, 0x0003FFCF, -0xFFF987E4, 0xD36DFDFF, 0x5E003987, 0x001FFFC0, -0xFFFBAFEE, 0xF3EDFDFF, 0x00003BBF, 0x0000FFC1, -0xFFF99FEE, 0xF3CDFDFF, 0xB0C0398F, 0x0000FFC3, -0xD63DC7EC, 0xC3BFC718, 0x00803DC7, 0x0000FF80, -0xFFFDDFEE, 0xC3EFFDFF, 0x00603DDF, 0x0000FFC3, -0xFFFDDFEC, 0xC3EFFDFF, 0x40603DDF, 0x0000FFC3, -0xFFFDDFEC, 0xC3FFFDFF, 0x00803DCF, 0x0000FFC3, -0x00000000, 0x00000000, 0x00000000, 0x00000000, -0xFFFFFFFE, 0x07FF7FFF, 0x03FF7FFF, 0x00000000, -0xFEF02596, 0x3BFF6CAE, 0x03FF3F5F, 0x00000000, -0x03000000, 0xC2A003FF, 0xFFFFFEFF, 0xFFFE03FF, -0xFEBF0FDF, 0x02FE3FFF, 0x00000000, 0x00000000, -0x00000000, 0x00000000, 0x00000000, 0x00000000, -0x00000000, 0x00000000, 0x1FFF0000, 0x00000002, -0x000000A0, 0x003EFFFE, 0xFFFFFFFE, 0xFFFFFFFF, -0x661FFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0x77FFFFFF, -}; -static const unsigned char nmstrtPages[] = { -0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x00, -0x00, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, -0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13, -0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x15, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; -static const unsigned char namePages[] = { -0x19, 0x03, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x00, -0x00, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, -0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13, -0x26, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x27, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; diff --git a/libs/apr-util/xml/expat/lib/osd_ebcdic_df04_1.h b/libs/apr-util/xml/expat/lib/osd_ebcdic_df04_1.h deleted file mode 100644 index 968256ba2b..0000000000 --- a/libs/apr-util/xml/expat/lib/osd_ebcdic_df04_1.h +++ /dev/null @@ -1,81 +0,0 @@ -/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* Table for the OSD_EBCDIC_DF04_1 encoding */ - -/* 00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 04 */ BT_OTHER, BT_S, BT_OTHER, BT_OTHER, -/* 08 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_NONXML, -/* 0c */ BT_NONXML, BT_CR, BT_NONXML, BT_NONXML, -/* 10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 14 */ BT_OTHER, BT_LF, BT_NONXML, BT_OTHER, -/* 18 */ BT_NONXML, BT_NONXML, BT_OTHER, BT_OTHER, -/* 1c */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 20 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 24 */ BT_OTHER, BT_OTHER, BT_NONXML, BT_NONXML, -/* 28 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 2c */ BT_OTHER, BT_NONXML, BT_NONXML, BT_NONXML, -/* 30 */ BT_OTHER, BT_OTHER, BT_NONXML, BT_OTHER, -/* 34 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_NONXML, -/* 38 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 3c */ BT_NONXML, BT_NONXML, BT_OTHER, BT_NONXML, -/* 40 */ BT_S, BT_OTHER, BT_NMSTRT, BT_NMSTRT, -/* 44 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 48 */ BT_NMSTRT, BT_NMSTRT, BT_OTHER, BT_NAME, -/* 4c */ BT_LT, BT_LPAR, BT_PLUS, BT_VERBAR, -/* 50 */ BT_AMP, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 58 */ BT_NMSTRT, BT_NMSTRT, BT_EXCL, BT_OTHER, -/* 5c */ BT_AST, BT_RPAR, BT_SEMI, BT_OTHER, -/* 60 */ BT_MINUS, BT_SOL, BT_NMSTRT, BT_NMSTRT, -/* 64 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 68 */ BT_NMSTRT, BT_NMSTRT, BT_OTHER, BT_COMMA, -/* 6c */ BT_PERCNT, BT_NMSTRT, BT_GT, BT_QUEST, -/* 70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 78 */ BT_NMSTRT, BT_OTHER, BT_COLON, BT_NUM, -/* 7c */ BT_OTHER, BT_APOS, BT_EQUALS, BT_QUOT, -/* 80 */ BT_NMSTRT, BT_HEX, BT_HEX, BT_HEX, -/* 84 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT, -/* 88 */ BT_NMSTRT, BT_NMSTRT, BT_OTHER, BT_OTHER, -/* 8c */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER, -/* 90 */ BT_OTHER, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 94 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 98 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 9c */ BT_NMSTRT, BT_OTHER, BT_NMSTRT, BT_OTHER, -/* a0 */ BT_NMSTRT, BT_OTHER, BT_NMSTRT, BT_NMSTRT, -/* a4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* a8 */ BT_NMSTRT, BT_NMSTRT, BT_OTHER, BT_OTHER, -/* ac */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER, -/* b0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_NAME, -/* b4 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* b8 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_LSQB, -/* bc */ BT_OTHER, BT_RSQB, BT_OTHER, BT_OTHER, -/* c0 */ BT_NMSTRT, BT_HEX, BT_HEX, BT_HEX, -/* c4 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT, -/* c8 */ BT_NMSTRT, BT_NMSTRT, BT_OTHER, BT_NMSTRT, -/* cc */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* d0 */ BT_OTHER, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* d4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* d8 */ BT_NMSTRT, BT_NMSTRT, BT_OTHER, BT_NMSTRT, -/* dc */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* e0 */ BT_NMSTRT, BT_OTHER, BT_NMSTRT, BT_NMSTRT, -/* e4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* e8 */ BT_NMSTRT, BT_NMSTRT, BT_OTHER, BT_NMSTRT, -/* ec */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* f0 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT, -/* f4 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT, -/* f8 */ BT_DIGIT, BT_DIGIT, BT_OTHER, BT_OTHER, -/* fc */ BT_NMSTRT, BT_OTHER, BT_NMSTRT, BT_OTHER, diff --git a/libs/apr-util/xml/expat/lib/utf8tab.h b/libs/apr-util/xml/expat/lib/utf8tab.h deleted file mode 100644 index 9e3b6b83eb..0000000000 --- a/libs/apr-util/xml/expat/lib/utf8tab.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd -See the file COPYING for copying permission. -*/ - - -/* 0x80 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0x84 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0x88 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0x8C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0x90 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0x94 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0x98 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0x9C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0xA0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0xA4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0xA8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0xAC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0xB0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0xB4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0xB8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0xBC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0xC0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, -/* 0xC4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, -/* 0xC8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, -/* 0xCC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, -/* 0xD0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, -/* 0xD4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, -/* 0xD8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, -/* 0xDC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, -/* 0xE0 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3, -/* 0xE4 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3, -/* 0xE8 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3, -/* 0xEC */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3, -/* 0xF0 */ BT_LEAD4, BT_LEAD4, BT_LEAD4, BT_LEAD4, -/* 0xF4 */ BT_LEAD4, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0xF8 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0xFC */ BT_NONXML, BT_NONXML, BT_MALFORM, BT_MALFORM, diff --git a/libs/apr-util/xml/expat/lib/winconfig.h b/libs/apr-util/xml/expat/lib/winconfig.h deleted file mode 100644 index 602ea94111..0000000000 --- a/libs/apr-util/xml/expat/lib/winconfig.h +++ /dev/null @@ -1,28 +0,0 @@ -/*================================================================ -** Copyright 2000, Clark Cooper -** All rights reserved. -** -** This is free software. You are permitted to copy, distribute, or modify -** it under the terms of the MIT/X license (contained in the COPYING file -** with this distribution.) -** -** -*/ - -#ifndef WINCONFIG_H -#define WINCONFIG_H - -#define WIN32_LEAN_AND_MEAN -#include -#undef WIN32_LEAN_AND_MEAN - -#include -#include - -#define XML_NS 1 -#define XML_DTD 1 -#define XML_BYTE_ORDER 12 -#define XML_CONTEXT_BYTES 1024 -#define HAVE_MEMMOVE - -#endif /* ndef WINCONFIG_H */ diff --git a/libs/apr-util/xml/expat/lib/xml.dsp b/libs/apr-util/xml/expat/lib/xml.dsp deleted file mode 100644 index 55baa4865d..0000000000 --- a/libs/apr-util/xml/expat/lib/xml.dsp +++ /dev/null @@ -1,221 +0,0 @@ -# Microsoft Developer Studio Project File - Name="xml" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -CFG=xml - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "xml.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "xml.mak" CFG="xml - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "xml - Win32 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "xml - Win32 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "xml - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "LibR" -# PROP BASE Intermediate_Dir "LibR" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "LibR" -# PROP Intermediate_Dir "LibR" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FD /c -# ADD CPP /nologo /MD /W3 /O2 /Oy- /Zi /I "." /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D VERSION=\"expat_1.95.2\" /Fd"LibR\xml_src" /FD /c -# ADD BASE RSC /l 0x409 -# ADD RSC /l 0x409 -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ELSEIF "$(CFG)" == "xml - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "LibD" -# PROP BASE Intermediate_Dir "LibD" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "LibD" -# PROP Intermediate_Dir "LibD" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MDd /W3 /EHsc /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FD /c -# ADD CPP /nologo /MDd /W3 /EHsc /Zi /Od /I "." /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D VERSION=\"expat_1.95.2\" /Fd"LibD\xml_src" /FD /c -# ADD BASE RSC /l 0x409 -# ADD RSC /l 0x409 -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ENDIF - -# Begin Target - -# Name "xml - Win32 Release" -# Name "xml - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\xmlparse.c -# End Source File -# Begin Source File - -SOURCE=.\xmlrole.c -# End Source File -# Begin Source File - -SOURCE=.\xmltok.c -# End Source File -# Begin Source File - -SOURCE=xmltok_impl.c -# PROP Exclude_From_Build 1 -# End Source File -# Begin Source File - -SOURCE=xmltok_ns.c -# PROP Exclude_From_Build 1 -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=.\ascii.h -# End Source File -# Begin Source File - -SOURCE=.\asciitab.h -# End Source File -# Begin Source File - -SOURCE=.\config.h -# End Source File -# Begin Source File - -SOURCE=.\expat.h -# End Source File -# Begin Source File - -SOURCE=.\iasciitab.h -# End Source File -# Begin Source File - -SOURCE=.\latin1tab.h -# End Source File -# Begin Source File - -SOURCE=.\nametab.h -# End Source File -# Begin Source File - -SOURCE=.\utf8tab.h -# End Source File -# Begin Source File - -SOURCE=.\xmlrole.h -# End Source File -# Begin Source File - -SOURCE=.\xmltok.h -# End Source File -# Begin Source File - -SOURCE=.\xmltok_impl.h -# End Source File -# End Group -# Begin Group "Generated Header Files" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\expat.h.in - -!IF "$(CFG)" == "xml - Win32 Release" - -# Begin Custom Build - Creating expat.h from expat.h.in -InputPath=.\expat.h.in - -".\expat.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\expat.h.in > .\expat.h - -# End Custom Build - -!ELSEIF "$(CFG)" == "xml - Win32 Debug" - -# Begin Custom Build - Creating expat.h from expat.h.in -InputPath=.\expat.h.in - -".\expat.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\expat.h.in > .\expat.h - -# End Custom Build - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\winconfig.h - -!IF "$(CFG)" == "xml - Win32 Release" - -# Begin Custom Build - Creating config.h from winconfig.h -InputPath=.\winconfig.h - -".\config.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\winconfig.h > .\config.h - -# End Custom Build - -!ELSEIF "$(CFG)" == "xml - Win32 Debug" - -# Begin Custom Build - Creating config.h from winconfig.h -InputPath=.\winconfig.h - -".\config.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\winconfig.h > .\config.h - -# End Custom Build - -!ENDIF - -# End Source File -# End Group -# Begin Source File - -SOURCE=.\ReadMe.txt -# End Source File -# End Target -# End Project diff --git a/libs/apr-util/xml/expat/lib/xmlparse.c b/libs/apr-util/xml/expat/lib/xmlparse.c deleted file mode 100644 index 822fabdd86..0000000000 --- a/libs/apr-util/xml/expat/lib/xmlparse.c +++ /dev/null @@ -1,4650 +0,0 @@ -/* -Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd -See the file COPYING for copying permission. -*/ - -static char RCSId[] - = "$Header: /home/cvs/apr-util/xml/expat/lib/xmlparse.c,v 1.4 2001/08/30 05:44:18 wrowe Exp $"; - -#ifdef COMPILED_FROM_DSP -# include "winconfig.h" -# define XMLPARSEAPI __declspec(dllexport) -# include "expat.h" -# undef XMLPARSEAPI -#else -#include - -#ifndef HAVE_MEMMOVE -#ifdef HAVE_BCOPY -#define memmove(d,s,l) bcopy((s),(d),(l)) -#else -#define memmove(d,s,l) ;punting on memmove; -#endif -#endif - -#ifdef HAVE_STRING_H -# include -#endif - -#ifndef __CYGWIN__ -#ifdef __declspec -# define XMLPARSEAPI __declspec(dllexport) -#endif -#endif - -#include "expat.h" - -#ifdef __declspec -# undef XMLPARSEAPI -#endif -#endif /* ndef COMPILED_FROM_DSP */ - -#include - -#ifdef XML_UNICODE -#define XML_ENCODE_MAX XML_UTF16_ENCODE_MAX -#define XmlConvert XmlUtf16Convert -#define XmlGetInternalEncoding XmlGetUtf16InternalEncoding -#define XmlGetInternalEncodingNS XmlGetUtf16InternalEncodingNS -#define XmlEncode XmlUtf16Encode -#define MUST_CONVERT(enc, s) (!(enc)->isUtf16 || (((unsigned long)s) & 1)) -typedef unsigned short ICHAR; -#else -#define XML_ENCODE_MAX XML_UTF8_ENCODE_MAX -#define XmlConvert XmlUtf8Convert -#define XmlGetInternalEncoding XmlGetUtf8InternalEncoding -#define XmlGetInternalEncodingNS XmlGetUtf8InternalEncodingNS -#define XmlEncode XmlUtf8Encode -#define MUST_CONVERT(enc, s) (!(enc)->isUtf8) -typedef char ICHAR; -#endif - - -#ifndef XML_NS - -#define XmlInitEncodingNS XmlInitEncoding -#define XmlInitUnknownEncodingNS XmlInitUnknownEncoding -#undef XmlGetInternalEncodingNS -#define XmlGetInternalEncodingNS XmlGetInternalEncoding -#define XmlParseXmlDeclNS XmlParseXmlDecl - -#endif - -#ifdef XML_UNICODE_WCHAR_T -#define XML_T(x) L ## x -#else -#define XML_T(x) x -#endif - -/* Round up n to be a multiple of sz, where sz is a power of 2. */ -#define ROUND_UP(n, sz) (((n) + ((sz) - 1)) & ~((sz) - 1)) - -#include "xmltok.h" -#include "xmlrole.h" - -typedef const XML_Char *KEY; - -typedef struct { - KEY name; -} NAMED; - -typedef struct { - NAMED **v; - size_t size; - size_t used; - size_t usedLim; - XML_Memory_Handling_Suite *mem; -} HASH_TABLE; - -typedef struct { - NAMED **p; - NAMED **end; -} HASH_TABLE_ITER; - -#define INIT_TAG_BUF_SIZE 32 /* must be a multiple of sizeof(XML_Char) */ -#define INIT_DATA_BUF_SIZE 1024 -#define INIT_ATTS_SIZE 16 -#define INIT_BLOCK_SIZE 1024 -#define INIT_BUFFER_SIZE 1024 - -#define EXPAND_SPARE 24 - -typedef struct binding { - struct prefix *prefix; - struct binding *nextTagBinding; - struct binding *prevPrefixBinding; - const struct attribute_id *attId; - XML_Char *uri; - int uriLen; - int uriAlloc; -} BINDING; - -typedef struct prefix { - const XML_Char *name; - BINDING *binding; -} PREFIX; - -typedef struct { - const XML_Char *str; - const XML_Char *localPart; - int uriLen; -} TAG_NAME; - -typedef struct tag { - struct tag *parent; - const char *rawName; - int rawNameLength; - TAG_NAME name; - char *buf; - char *bufEnd; - BINDING *bindings; -} TAG; - -typedef struct { - const XML_Char *name; - const XML_Char *textPtr; - int textLen; - const XML_Char *systemId; - const XML_Char *base; - const XML_Char *publicId; - const XML_Char *notation; - char open; - char is_param; -} ENTITY; - -typedef struct { - enum XML_Content_Type type; - enum XML_Content_Quant quant; - const XML_Char * name; - int firstchild; - int lastchild; - int childcnt; - int nextsib; -} CONTENT_SCAFFOLD; - -typedef struct block { - struct block *next; - int size; - XML_Char s[1]; -} BLOCK; - -typedef struct { - BLOCK *blocks; - BLOCK *freeBlocks; - const XML_Char *end; - XML_Char *ptr; - XML_Char *start; - XML_Memory_Handling_Suite *mem; -} STRING_POOL; - -/* The XML_Char before the name is used to determine whether -an attribute has been specified. */ -typedef struct attribute_id { - XML_Char *name; - PREFIX *prefix; - char maybeTokenized; - char xmlns; -} ATTRIBUTE_ID; - -typedef struct { - const ATTRIBUTE_ID *id; - char isCdata; - const XML_Char *value; -} DEFAULT_ATTRIBUTE; - -typedef struct { - const XML_Char *name; - PREFIX *prefix; - const ATTRIBUTE_ID *idAtt; - int nDefaultAtts; - int allocDefaultAtts; - DEFAULT_ATTRIBUTE *defaultAtts; -} ELEMENT_TYPE; - -typedef struct { - HASH_TABLE generalEntities; - HASH_TABLE elementTypes; - HASH_TABLE attributeIds; - HASH_TABLE prefixes; - STRING_POOL pool; - int complete; - int standalone; -#ifdef XML_DTD - HASH_TABLE paramEntities; -#endif /* XML_DTD */ - PREFIX defaultPrefix; - /* === scaffolding for building content model === */ - int in_eldecl; - CONTENT_SCAFFOLD *scaffold; - unsigned contentStringLen; - unsigned scaffSize; - unsigned scaffCount; - int scaffLevel; - int *scaffIndex; -} DTD; - -typedef struct open_internal_entity { - const char *internalEventPtr; - const char *internalEventEndPtr; - struct open_internal_entity *next; - ENTITY *entity; -} OPEN_INTERNAL_ENTITY; - -typedef enum XML_Error Processor(XML_Parser parser, - const char *start, - const char *end, - const char **endPtr); - -static Processor prologProcessor; -static Processor prologInitProcessor; -static Processor contentProcessor; -static Processor cdataSectionProcessor; -#ifdef XML_DTD -static Processor ignoreSectionProcessor; -#endif /* XML_DTD */ -static Processor epilogProcessor; -static Processor errorProcessor; -static Processor externalEntityInitProcessor; -static Processor externalEntityInitProcessor2; -static Processor externalEntityInitProcessor3; -static Processor externalEntityContentProcessor; - -static enum XML_Error -handleUnknownEncoding(XML_Parser parser, const XML_Char *encodingName); -static enum XML_Error -processXmlDecl(XML_Parser parser, int isGeneralTextEntity, const char *, const char *); -static enum XML_Error -initializeEncoding(XML_Parser parser); -static enum XML_Error -doProlog(XML_Parser parser, const ENCODING *enc, const char *s, - const char *end, int tok, const char *next, const char **nextPtr); -static enum XML_Error -processInternalParamEntity(XML_Parser parser, ENTITY *entity); -static enum XML_Error -doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc, - const char *start, const char *end, const char **endPtr); -static enum XML_Error -doCdataSection(XML_Parser parser, const ENCODING *, const char **startPtr, const char *end, const char **nextPtr); -#ifdef XML_DTD -static enum XML_Error -doIgnoreSection(XML_Parser parser, const ENCODING *, const char **startPtr, const char *end, const char **nextPtr); -#endif /* XML_DTD */ -static enum XML_Error storeAtts(XML_Parser parser, const ENCODING *, const char *s, - TAG_NAME *tagNamePtr, BINDING **bindingsPtr); -static -int addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId, const XML_Char *uri, BINDING **bindingsPtr); - -static int -defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *, - int isCdata, int isId, const XML_Char *dfltValue, - XML_Parser parser); - -static enum XML_Error -storeAttributeValue(XML_Parser parser, const ENCODING *, int isCdata, const char *, const char *, - STRING_POOL *); -static enum XML_Error -appendAttributeValue(XML_Parser parser, const ENCODING *, int isCdata, const char *, const char *, - STRING_POOL *); -static ATTRIBUTE_ID * -getAttributeId(XML_Parser parser, const ENCODING *enc, const char *start, const char *end); -static int setElementTypePrefix(XML_Parser parser, ELEMENT_TYPE *); -static enum XML_Error -storeEntityValue(XML_Parser parser, const ENCODING *enc, const char *start, const char *end); -static int -reportProcessingInstruction(XML_Parser parser, const ENCODING *enc, const char *start, const char *end); -static int -reportComment(XML_Parser parser, const ENCODING *enc, const char *start, const char *end); -static void -reportDefault(XML_Parser parser, const ENCODING *enc, const char *start, const char *end); - -static const XML_Char *getContext(XML_Parser parser); -static int setContext(XML_Parser parser, const XML_Char *context); -static void normalizePublicId(XML_Char *s); -static int dtdInit(DTD *, XML_Parser parser); - -static void dtdDestroy(DTD *, XML_Parser parser); - -static int dtdCopy(DTD *newDtd, const DTD *oldDtd, XML_Parser parser); - -static int copyEntityTable(HASH_TABLE *, STRING_POOL *, const HASH_TABLE *, - XML_Parser parser); - -#ifdef XML_DTD -static void dtdSwap(DTD *, DTD *); -#endif /* XML_DTD */ - -static NAMED *lookup(HASH_TABLE *table, KEY name, size_t createSize); - -static void hashTableInit(HASH_TABLE *, XML_Memory_Handling_Suite *ms); - -static void hashTableDestroy(HASH_TABLE *); -static void hashTableIterInit(HASH_TABLE_ITER *, const HASH_TABLE *); -static NAMED *hashTableIterNext(HASH_TABLE_ITER *); -static void poolInit(STRING_POOL *, XML_Memory_Handling_Suite *ms); -static void poolClear(STRING_POOL *); -static void poolDestroy(STRING_POOL *); -static XML_Char *poolAppend(STRING_POOL *pool, const ENCODING *enc, - const char *ptr, const char *end); -static XML_Char *poolStoreString(STRING_POOL *pool, const ENCODING *enc, - const char *ptr, const char *end); - -static int poolGrow(STRING_POOL *pool); - -static int nextScaffoldPart(XML_Parser parser); -static XML_Content *build_model(XML_Parser parser); - -static const XML_Char *poolCopyString(STRING_POOL *pool, const XML_Char *s); -static const XML_Char *poolCopyStringN(STRING_POOL *pool, const XML_Char *s, int n); -static const XML_Char *poolAppendString(STRING_POOL *pool, const XML_Char *s); -static ELEMENT_TYPE * getElementType(XML_Parser Paraser, - const ENCODING *enc, - const char *ptr, - const char *end); - -#define poolStart(pool) ((pool)->start) -#define poolEnd(pool) ((pool)->ptr) -#define poolLength(pool) ((pool)->ptr - (pool)->start) -#define poolChop(pool) ((void)--(pool->ptr)) -#define poolLastChar(pool) (((pool)->ptr)[-1]) -#define poolDiscard(pool) ((pool)->ptr = (pool)->start) -#define poolFinish(pool) ((pool)->start = (pool)->ptr) -#define poolAppendChar(pool, c) \ - (((pool)->ptr == (pool)->end && !poolGrow(pool)) \ - ? 0 \ - : ((*((pool)->ptr)++ = c), 1)) - -typedef struct { - /* The first member must be userData so that the XML_GetUserData macro works. */ - void *m_userData; - void *m_handlerArg; - char *m_buffer; - XML_Memory_Handling_Suite m_mem; - /* first character to be parsed */ - const char *m_bufferPtr; - /* past last character to be parsed */ - char *m_bufferEnd; - /* allocated end of buffer */ - const char *m_bufferLim; - long m_parseEndByteIndex; - const char *m_parseEndPtr; - XML_Char *m_dataBuf; - XML_Char *m_dataBufEnd; - XML_StartElementHandler m_startElementHandler; - XML_EndElementHandler m_endElementHandler; - XML_CharacterDataHandler m_characterDataHandler; - XML_ProcessingInstructionHandler m_processingInstructionHandler; - XML_CommentHandler m_commentHandler; - XML_StartCdataSectionHandler m_startCdataSectionHandler; - XML_EndCdataSectionHandler m_endCdataSectionHandler; - XML_DefaultHandler m_defaultHandler; - XML_StartDoctypeDeclHandler m_startDoctypeDeclHandler; - XML_EndDoctypeDeclHandler m_endDoctypeDeclHandler; - XML_UnparsedEntityDeclHandler m_unparsedEntityDeclHandler; - XML_NotationDeclHandler m_notationDeclHandler; - XML_StartNamespaceDeclHandler m_startNamespaceDeclHandler; - XML_EndNamespaceDeclHandler m_endNamespaceDeclHandler; - XML_NotStandaloneHandler m_notStandaloneHandler; - XML_ExternalEntityRefHandler m_externalEntityRefHandler; - void *m_externalEntityRefHandlerArg; - XML_UnknownEncodingHandler m_unknownEncodingHandler; - XML_ElementDeclHandler m_elementDeclHandler; - XML_AttlistDeclHandler m_attlistDeclHandler; - XML_EntityDeclHandler m_entityDeclHandler; - XML_XmlDeclHandler m_xmlDeclHandler; - const ENCODING *m_encoding; - INIT_ENCODING m_initEncoding; - const ENCODING *m_internalEncoding; - const XML_Char *m_protocolEncodingName; - int m_ns; - int m_ns_triplets; - void *m_unknownEncodingMem; - void *m_unknownEncodingData; - void *m_unknownEncodingHandlerData; - void (*m_unknownEncodingRelease)(void *); - PROLOG_STATE m_prologState; - Processor *m_processor; - enum XML_Error m_errorCode; - const char *m_eventPtr; - const char *m_eventEndPtr; - const char *m_positionPtr; - OPEN_INTERNAL_ENTITY *m_openInternalEntities; - int m_defaultExpandInternalEntities; - int m_tagLevel; - ENTITY *m_declEntity; - const XML_Char *m_doctypeName; - const XML_Char *m_doctypeSysid; - const XML_Char *m_doctypePubid; - const XML_Char *m_declAttributeType; - const XML_Char *m_declNotationName; - const XML_Char *m_declNotationPublicId; - ELEMENT_TYPE *m_declElementType; - ATTRIBUTE_ID *m_declAttributeId; - char m_declAttributeIsCdata; - char m_declAttributeIsId; - DTD m_dtd; - const XML_Char *m_curBase; - TAG *m_tagStack; - TAG *m_freeTagList; - BINDING *m_inheritedBindings; - BINDING *m_freeBindingList; - int m_attsSize; - int m_nSpecifiedAtts; - int m_idAttIndex; - ATTRIBUTE *m_atts; - POSITION m_position; - STRING_POOL m_tempPool; - STRING_POOL m_temp2Pool; - char *m_groupConnector; - unsigned m_groupSize; - int m_hadExternalDoctype; - XML_Char m_namespaceSeparator; -#ifdef XML_DTD - enum XML_ParamEntityParsing m_paramEntityParsing; - XML_Parser m_parentParser; -#endif -} Parser; - -#define MALLOC(s) (((Parser *)parser)->m_mem.malloc_fcn((s))) -#define REALLOC(p,s) (((Parser *)parser)->m_mem.realloc_fcn((p),(s))) -#define FREE(p) (((Parser *)parser)->m_mem.free_fcn((p))) - -#define userData (((Parser *)parser)->m_userData) -#define handlerArg (((Parser *)parser)->m_handlerArg) -#define startElementHandler (((Parser *)parser)->m_startElementHandler) -#define endElementHandler (((Parser *)parser)->m_endElementHandler) -#define characterDataHandler (((Parser *)parser)->m_characterDataHandler) -#define processingInstructionHandler (((Parser *)parser)->m_processingInstructionHandler) -#define commentHandler (((Parser *)parser)->m_commentHandler) -#define startCdataSectionHandler (((Parser *)parser)->m_startCdataSectionHandler) -#define endCdataSectionHandler (((Parser *)parser)->m_endCdataSectionHandler) -#define defaultHandler (((Parser *)parser)->m_defaultHandler) -#define startDoctypeDeclHandler (((Parser *)parser)->m_startDoctypeDeclHandler) -#define endDoctypeDeclHandler (((Parser *)parser)->m_endDoctypeDeclHandler) -#define unparsedEntityDeclHandler (((Parser *)parser)->m_unparsedEntityDeclHandler) -#define notationDeclHandler (((Parser *)parser)->m_notationDeclHandler) -#define startNamespaceDeclHandler (((Parser *)parser)->m_startNamespaceDeclHandler) -#define endNamespaceDeclHandler (((Parser *)parser)->m_endNamespaceDeclHandler) -#define notStandaloneHandler (((Parser *)parser)->m_notStandaloneHandler) -#define externalEntityRefHandler (((Parser *)parser)->m_externalEntityRefHandler) -#define externalEntityRefHandlerArg (((Parser *)parser)->m_externalEntityRefHandlerArg) -#define unknownEncodingHandler (((Parser *)parser)->m_unknownEncodingHandler) -#define elementDeclHandler (((Parser *)parser)->m_elementDeclHandler) -#define attlistDeclHandler (((Parser *)parser)->m_attlistDeclHandler) -#define entityDeclHandler (((Parser *)parser)->m_entityDeclHandler) -#define xmlDeclHandler (((Parser *)parser)->m_xmlDeclHandler) -#define encoding (((Parser *)parser)->m_encoding) -#define initEncoding (((Parser *)parser)->m_initEncoding) -#define internalEncoding (((Parser *)parser)->m_internalEncoding) -#define unknownEncodingMem (((Parser *)parser)->m_unknownEncodingMem) -#define unknownEncodingData (((Parser *)parser)->m_unknownEncodingData) -#define unknownEncodingHandlerData \ - (((Parser *)parser)->m_unknownEncodingHandlerData) -#define unknownEncodingRelease (((Parser *)parser)->m_unknownEncodingRelease) -#define protocolEncodingName (((Parser *)parser)->m_protocolEncodingName) -#define ns (((Parser *)parser)->m_ns) -#define ns_triplets (((Parser *)parser)->m_ns_triplets) -#define prologState (((Parser *)parser)->m_prologState) -#define processor (((Parser *)parser)->m_processor) -#define errorCode (((Parser *)parser)->m_errorCode) -#define eventPtr (((Parser *)parser)->m_eventPtr) -#define eventEndPtr (((Parser *)parser)->m_eventEndPtr) -#define positionPtr (((Parser *)parser)->m_positionPtr) -#define position (((Parser *)parser)->m_position) -#define openInternalEntities (((Parser *)parser)->m_openInternalEntities) -#define defaultExpandInternalEntities (((Parser *)parser)->m_defaultExpandInternalEntities) -#define tagLevel (((Parser *)parser)->m_tagLevel) -#define buffer (((Parser *)parser)->m_buffer) -#define bufferPtr (((Parser *)parser)->m_bufferPtr) -#define bufferEnd (((Parser *)parser)->m_bufferEnd) -#define parseEndByteIndex (((Parser *)parser)->m_parseEndByteIndex) -#define parseEndPtr (((Parser *)parser)->m_parseEndPtr) -#define bufferLim (((Parser *)parser)->m_bufferLim) -#define dataBuf (((Parser *)parser)->m_dataBuf) -#define dataBufEnd (((Parser *)parser)->m_dataBufEnd) -#define dtd (((Parser *)parser)->m_dtd) -#define curBase (((Parser *)parser)->m_curBase) -#define declEntity (((Parser *)parser)->m_declEntity) -#define doctypeName (((Parser *)parser)->m_doctypeName) -#define doctypeSysid (((Parser *)parser)->m_doctypeSysid) -#define doctypePubid (((Parser *)parser)->m_doctypePubid) -#define declAttributeType (((Parser *)parser)->m_declAttributeType) -#define declNotationName (((Parser *)parser)->m_declNotationName) -#define declNotationPublicId (((Parser *)parser)->m_declNotationPublicId) -#define declElementType (((Parser *)parser)->m_declElementType) -#define declAttributeId (((Parser *)parser)->m_declAttributeId) -#define declAttributeIsCdata (((Parser *)parser)->m_declAttributeIsCdata) -#define declAttributeIsId (((Parser *)parser)->m_declAttributeIsId) -#define freeTagList (((Parser *)parser)->m_freeTagList) -#define freeBindingList (((Parser *)parser)->m_freeBindingList) -#define inheritedBindings (((Parser *)parser)->m_inheritedBindings) -#define tagStack (((Parser *)parser)->m_tagStack) -#define atts (((Parser *)parser)->m_atts) -#define attsSize (((Parser *)parser)->m_attsSize) -#define nSpecifiedAtts (((Parser *)parser)->m_nSpecifiedAtts) -#define idAttIndex (((Parser *)parser)->m_idAttIndex) -#define tempPool (((Parser *)parser)->m_tempPool) -#define temp2Pool (((Parser *)parser)->m_temp2Pool) -#define groupConnector (((Parser *)parser)->m_groupConnector) -#define groupSize (((Parser *)parser)->m_groupSize) -#define hadExternalDoctype (((Parser *)parser)->m_hadExternalDoctype) -#define namespaceSeparator (((Parser *)parser)->m_namespaceSeparator) -#ifdef XML_DTD -#define parentParser (((Parser *)parser)->m_parentParser) -#define paramEntityParsing (((Parser *)parser)->m_paramEntityParsing) -#endif /* XML_DTD */ - -#ifdef COMPILED_FROM_DSP -BOOL WINAPI DllMain(HINSTANCE h, DWORD r, LPVOID p) { - return TRUE; -} -#endif /* def COMPILED_FROM_DSP */ - -#ifdef _MSC_VER -#ifdef _DEBUG -Parser *asParser(XML_Parser parser) -{ - return parser; -} -#endif -#endif - -XML_Parser XML_ParserCreate(const XML_Char *encodingName) -{ - return XML_ParserCreate_MM(encodingName, NULL, NULL); -} - -XML_Parser XML_ParserCreateNS(const XML_Char *encodingName, XML_Char nsSep) -{ - XML_Char tmp[2]; - *tmp = nsSep; - return XML_ParserCreate_MM(encodingName, NULL, tmp); -} - -XML_Parser -XML_ParserCreate_MM(const XML_Char *encodingName, - const XML_Memory_Handling_Suite *memsuite, - const XML_Char *nameSep) { - - XML_Parser parser; - static - const XML_Char implicitContext[] = { - XML_T('x'), XML_T('m'), XML_T('l'), XML_T('='), - XML_T('h'), XML_T('t'), XML_T('t'), XML_T('p'), XML_T(':'), - XML_T('/'), XML_T('/'), XML_T('w'), XML_T('w'), XML_T('w'), - XML_T('.'), XML_T('w'), XML_T('3'), - XML_T('.'), XML_T('o'), XML_T('r'), XML_T('g'), - XML_T('/'), XML_T('X'), XML_T('M'), XML_T('L'), - XML_T('/'), XML_T('1'), XML_T('9'), XML_T('9'), XML_T('8'), - XML_T('/'), XML_T('n'), XML_T('a'), XML_T('m'), XML_T('e'), - XML_T('s'), XML_T('p'), XML_T('a'), XML_T('c'), XML_T('e'), - XML_T('\0') - }; - - - if (memsuite) { - XML_Memory_Handling_Suite *mtemp; - parser = memsuite->malloc_fcn(sizeof(Parser)); - mtemp = &(((Parser *) parser)->m_mem); - mtemp->malloc_fcn = memsuite->malloc_fcn; - mtemp->realloc_fcn = memsuite->realloc_fcn; - mtemp->free_fcn = memsuite->free_fcn; - } - else { - XML_Memory_Handling_Suite *mtemp; - parser = malloc(sizeof(Parser)); - mtemp = &(((Parser *) parser)->m_mem); - mtemp->malloc_fcn = malloc; - mtemp->realloc_fcn = realloc; - mtemp->free_fcn = free; - } - - if (!parser) - return parser; - processor = prologInitProcessor; - XmlPrologStateInit(&prologState); - userData = 0; - handlerArg = 0; - startElementHandler = 0; - endElementHandler = 0; - characterDataHandler = 0; - processingInstructionHandler = 0; - commentHandler = 0; - startCdataSectionHandler = 0; - endCdataSectionHandler = 0; - defaultHandler = 0; - startDoctypeDeclHandler = 0; - endDoctypeDeclHandler = 0; - unparsedEntityDeclHandler = 0; - notationDeclHandler = 0; - startNamespaceDeclHandler = 0; - endNamespaceDeclHandler = 0; - notStandaloneHandler = 0; - externalEntityRefHandler = 0; - externalEntityRefHandlerArg = parser; - unknownEncodingHandler = 0; - elementDeclHandler = 0; - attlistDeclHandler = 0; - entityDeclHandler = 0; - xmlDeclHandler = 0; - buffer = 0; - bufferPtr = 0; - bufferEnd = 0; - parseEndByteIndex = 0; - parseEndPtr = 0; - bufferLim = 0; - declElementType = 0; - declAttributeId = 0; - declEntity = 0; - doctypeName = 0; - doctypeSysid = 0; - doctypePubid = 0; - declAttributeType = 0; - declNotationName = 0; - declNotationPublicId = 0; - memset(&position, 0, sizeof(POSITION)); - errorCode = XML_ERROR_NONE; - eventPtr = 0; - eventEndPtr = 0; - positionPtr = 0; - openInternalEntities = 0; - tagLevel = 0; - tagStack = 0; - freeTagList = 0; - freeBindingList = 0; - inheritedBindings = 0; - attsSize = INIT_ATTS_SIZE; - atts = MALLOC(attsSize * sizeof(ATTRIBUTE)); - nSpecifiedAtts = 0; - dataBuf = MALLOC(INIT_DATA_BUF_SIZE * sizeof(XML_Char)); - groupSize = 0; - groupConnector = 0; - hadExternalDoctype = 0; - unknownEncodingMem = 0; - unknownEncodingRelease = 0; - unknownEncodingData = 0; - unknownEncodingHandlerData = 0; - namespaceSeparator = '!'; -#ifdef XML_DTD - parentParser = 0; - paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER; -#endif - ns = 0; - ns_triplets = 0; - poolInit(&tempPool, &(((Parser *) parser)->m_mem)); - poolInit(&temp2Pool, &(((Parser *) parser)->m_mem)); - protocolEncodingName = encodingName ? poolCopyString(&tempPool, encodingName) : 0; - curBase = 0; - if (!dtdInit(&dtd, parser) || !atts || !dataBuf - || (encodingName && !protocolEncodingName)) { - XML_ParserFree(parser); - return 0; - } - dataBufEnd = dataBuf + INIT_DATA_BUF_SIZE; - - if (nameSep) { - XmlInitEncodingNS(&initEncoding, &encoding, 0); - ns = 1; - internalEncoding = XmlGetInternalEncodingNS(); - namespaceSeparator = *nameSep; - - if (! setContext(parser, implicitContext)) { - XML_ParserFree(parser); - return 0; - } - } - else { - XmlInitEncoding(&initEncoding, &encoding, 0); - internalEncoding = XmlGetInternalEncoding(); - } - - return parser; -} /* End XML_ParserCreate_MM */ - -int XML_SetEncoding(XML_Parser parser, const XML_Char *encodingName) -{ - if (!encodingName) - protocolEncodingName = 0; - else { - protocolEncodingName = poolCopyString(&tempPool, encodingName); - if (!protocolEncodingName) - return 0; - } - return 1; -} - -XML_Parser XML_ExternalEntityParserCreate(XML_Parser oldParser, - const XML_Char *context, - const XML_Char *encodingName) -{ - XML_Parser parser = oldParser; - DTD *oldDtd = &dtd; - XML_StartElementHandler oldStartElementHandler = startElementHandler; - XML_EndElementHandler oldEndElementHandler = endElementHandler; - XML_CharacterDataHandler oldCharacterDataHandler = characterDataHandler; - XML_ProcessingInstructionHandler oldProcessingInstructionHandler = processingInstructionHandler; - XML_CommentHandler oldCommentHandler = commentHandler; - XML_StartCdataSectionHandler oldStartCdataSectionHandler = startCdataSectionHandler; - XML_EndCdataSectionHandler oldEndCdataSectionHandler = endCdataSectionHandler; - XML_DefaultHandler oldDefaultHandler = defaultHandler; - XML_UnparsedEntityDeclHandler oldUnparsedEntityDeclHandler = unparsedEntityDeclHandler; - XML_NotationDeclHandler oldNotationDeclHandler = notationDeclHandler; - XML_StartNamespaceDeclHandler oldStartNamespaceDeclHandler = startNamespaceDeclHandler; - XML_EndNamespaceDeclHandler oldEndNamespaceDeclHandler = endNamespaceDeclHandler; - XML_NotStandaloneHandler oldNotStandaloneHandler = notStandaloneHandler; - XML_ExternalEntityRefHandler oldExternalEntityRefHandler = externalEntityRefHandler; - XML_UnknownEncodingHandler oldUnknownEncodingHandler = unknownEncodingHandler; - XML_ElementDeclHandler oldElementDeclHandler = elementDeclHandler; - XML_AttlistDeclHandler oldAttlistDeclHandler = attlistDeclHandler; - XML_EntityDeclHandler oldEntityDeclHandler = entityDeclHandler; - XML_XmlDeclHandler oldXmlDeclHandler = xmlDeclHandler; - ELEMENT_TYPE * oldDeclElementType = declElementType; - - void *oldUserData = userData; - void *oldHandlerArg = handlerArg; - int oldDefaultExpandInternalEntities = defaultExpandInternalEntities; - void *oldExternalEntityRefHandlerArg = externalEntityRefHandlerArg; -#ifdef XML_DTD - int oldParamEntityParsing = paramEntityParsing; -#endif - int oldns_triplets = ns_triplets; - - if (ns) { - XML_Char tmp[2]; - - *tmp = namespaceSeparator; - parser = XML_ParserCreate_MM(encodingName, &((Parser *)parser)->m_mem, - tmp); - } - else { - parser = XML_ParserCreate_MM(encodingName, &((Parser *)parser)->m_mem, - NULL); - } - - if (!parser) - return 0; - - startElementHandler = oldStartElementHandler; - endElementHandler = oldEndElementHandler; - characterDataHandler = oldCharacterDataHandler; - processingInstructionHandler = oldProcessingInstructionHandler; - commentHandler = oldCommentHandler; - startCdataSectionHandler = oldStartCdataSectionHandler; - endCdataSectionHandler = oldEndCdataSectionHandler; - defaultHandler = oldDefaultHandler; - unparsedEntityDeclHandler = oldUnparsedEntityDeclHandler; - notationDeclHandler = oldNotationDeclHandler; - startNamespaceDeclHandler = oldStartNamespaceDeclHandler; - endNamespaceDeclHandler = oldEndNamespaceDeclHandler; - notStandaloneHandler = oldNotStandaloneHandler; - externalEntityRefHandler = oldExternalEntityRefHandler; - unknownEncodingHandler = oldUnknownEncodingHandler; - elementDeclHandler = oldElementDeclHandler; - attlistDeclHandler = oldAttlistDeclHandler; - entityDeclHandler = oldEntityDeclHandler; - xmlDeclHandler = oldXmlDeclHandler; - declElementType = oldDeclElementType; - userData = oldUserData; - if (oldUserData == oldHandlerArg) - handlerArg = userData; - else - handlerArg = parser; - if (oldExternalEntityRefHandlerArg != oldParser) - externalEntityRefHandlerArg = oldExternalEntityRefHandlerArg; - defaultExpandInternalEntities = oldDefaultExpandInternalEntities; - ns_triplets = oldns_triplets; -#ifdef XML_DTD - paramEntityParsing = oldParamEntityParsing; - if (context) { -#endif /* XML_DTD */ - if (!dtdCopy(&dtd, oldDtd, parser) || !setContext(parser, context)) { - XML_ParserFree(parser); - return 0; - } - processor = externalEntityInitProcessor; -#ifdef XML_DTD - } - else { - dtdSwap(&dtd, oldDtd); - parentParser = oldParser; - XmlPrologStateInitExternalEntity(&prologState); - dtd.complete = 1; - hadExternalDoctype = 1; - } -#endif /* XML_DTD */ - return parser; -} - -static -void destroyBindings(BINDING *bindings, XML_Parser parser) -{ - for (;;) { - BINDING *b = bindings; - if (!b) - break; - bindings = b->nextTagBinding; - FREE(b->uri); - FREE(b); - } -} - -void XML_ParserFree(XML_Parser parser) -{ - for (;;) { - TAG *p; - if (tagStack == 0) { - if (freeTagList == 0) - break; - tagStack = freeTagList; - freeTagList = 0; - } - p = tagStack; - tagStack = tagStack->parent; - FREE(p->buf); - destroyBindings(p->bindings, parser); - FREE(p); - } - destroyBindings(freeBindingList, parser); - destroyBindings(inheritedBindings, parser); - poolDestroy(&tempPool); - poolDestroy(&temp2Pool); -#ifdef XML_DTD - if (parentParser) { - if (hadExternalDoctype) - dtd.complete = 0; - dtdSwap(&dtd, &((Parser *)parentParser)->m_dtd); - } -#endif /* XML_DTD */ - dtdDestroy(&dtd, parser); - FREE((void *)atts); - if (groupConnector) - FREE(groupConnector); - if (buffer) - FREE(buffer); - FREE(dataBuf); - if (unknownEncodingMem) - FREE(unknownEncodingMem); - if (unknownEncodingRelease) - unknownEncodingRelease(unknownEncodingData); - FREE(parser); -} - -void XML_UseParserAsHandlerArg(XML_Parser parser) -{ - handlerArg = parser; -} - -void -XML_SetReturnNSTriplet(XML_Parser parser, int do_nst) { - ns_triplets = do_nst; -} - -void XML_SetUserData(XML_Parser parser, void *p) -{ - if (handlerArg == userData) - handlerArg = userData = p; - else - userData = p; -} - -int XML_SetBase(XML_Parser parser, const XML_Char *p) -{ - if (p) { - p = poolCopyString(&dtd.pool, p); - if (!p) - return 0; - curBase = p; - } - else - curBase = 0; - return 1; -} - -const XML_Char *XML_GetBase(XML_Parser parser) -{ - return curBase; -} - -int XML_GetSpecifiedAttributeCount(XML_Parser parser) -{ - return nSpecifiedAtts; -} - -int XML_GetIdAttributeIndex(XML_Parser parser) -{ - return idAttIndex; -} - -void XML_SetElementHandler(XML_Parser parser, - XML_StartElementHandler start, - XML_EndElementHandler end) -{ - startElementHandler = start; - endElementHandler = end; -} - -void XML_SetStartElementHandler(XML_Parser parser, - XML_StartElementHandler start) { - startElementHandler = start; -} - -void XML_SetEndElementHandler(XML_Parser parser, - XML_EndElementHandler end) { - endElementHandler = end; -} - -void XML_SetCharacterDataHandler(XML_Parser parser, - XML_CharacterDataHandler handler) -{ - characterDataHandler = handler; -} - -void XML_SetProcessingInstructionHandler(XML_Parser parser, - XML_ProcessingInstructionHandler handler) -{ - processingInstructionHandler = handler; -} - -void XML_SetCommentHandler(XML_Parser parser, - XML_CommentHandler handler) -{ - commentHandler = handler; -} - -void XML_SetCdataSectionHandler(XML_Parser parser, - XML_StartCdataSectionHandler start, - XML_EndCdataSectionHandler end) -{ - startCdataSectionHandler = start; - endCdataSectionHandler = end; -} - -void XML_SetStartCdataSectionHandler(XML_Parser parser, - XML_StartCdataSectionHandler start) { - startCdataSectionHandler = start; -} - -void XML_SetEndCdataSectionHandler(XML_Parser parser, - XML_EndCdataSectionHandler end) { - endCdataSectionHandler = end; -} - -void XML_SetDefaultHandler(XML_Parser parser, - XML_DefaultHandler handler) -{ - defaultHandler = handler; - defaultExpandInternalEntities = 0; -} - -void XML_SetDefaultHandlerExpand(XML_Parser parser, - XML_DefaultHandler handler) -{ - defaultHandler = handler; - defaultExpandInternalEntities = 1; -} - -void XML_SetDoctypeDeclHandler(XML_Parser parser, - XML_StartDoctypeDeclHandler start, - XML_EndDoctypeDeclHandler end) -{ - startDoctypeDeclHandler = start; - endDoctypeDeclHandler = end; -} - -void XML_SetStartDoctypeDeclHandler(XML_Parser parser, - XML_StartDoctypeDeclHandler start) { - startDoctypeDeclHandler = start; -} - -void XML_SetEndDoctypeDeclHandler(XML_Parser parser, - XML_EndDoctypeDeclHandler end) { - endDoctypeDeclHandler = end; -} - -void XML_SetUnparsedEntityDeclHandler(XML_Parser parser, - XML_UnparsedEntityDeclHandler handler) -{ - unparsedEntityDeclHandler = handler; -} - -void XML_SetNotationDeclHandler(XML_Parser parser, - XML_NotationDeclHandler handler) -{ - notationDeclHandler = handler; -} - -void XML_SetNamespaceDeclHandler(XML_Parser parser, - XML_StartNamespaceDeclHandler start, - XML_EndNamespaceDeclHandler end) -{ - startNamespaceDeclHandler = start; - endNamespaceDeclHandler = end; -} - -void XML_SetStartNamespaceDeclHandler(XML_Parser parser, - XML_StartNamespaceDeclHandler start) { - startNamespaceDeclHandler = start; -} - -void XML_SetEndNamespaceDeclHandler(XML_Parser parser, - XML_EndNamespaceDeclHandler end) { - endNamespaceDeclHandler = end; -} - - -void XML_SetNotStandaloneHandler(XML_Parser parser, - XML_NotStandaloneHandler handler) -{ - notStandaloneHandler = handler; -} - -void XML_SetExternalEntityRefHandler(XML_Parser parser, - XML_ExternalEntityRefHandler handler) -{ - externalEntityRefHandler = handler; -} - -void XML_SetExternalEntityRefHandlerArg(XML_Parser parser, void *arg) -{ - if (arg) - externalEntityRefHandlerArg = arg; - else - externalEntityRefHandlerArg = parser; -} - -void XML_SetUnknownEncodingHandler(XML_Parser parser, - XML_UnknownEncodingHandler handler, - void *data) -{ - unknownEncodingHandler = handler; - unknownEncodingHandlerData = data; -} - -void XML_SetElementDeclHandler(XML_Parser parser, - XML_ElementDeclHandler eldecl) -{ - elementDeclHandler = eldecl; -} - -void XML_SetAttlistDeclHandler(XML_Parser parser, - XML_AttlistDeclHandler attdecl) -{ - attlistDeclHandler = attdecl; -} - -void XML_SetEntityDeclHandler(XML_Parser parser, - XML_EntityDeclHandler handler) -{ - entityDeclHandler = handler; -} - -void XML_SetXmlDeclHandler(XML_Parser parser, - XML_XmlDeclHandler handler) { - xmlDeclHandler = handler; -} - -int XML_SetParamEntityParsing(XML_Parser parser, - enum XML_ParamEntityParsing parsing) -{ -#ifdef XML_DTD - paramEntityParsing = parsing; - return 1; -#else - return parsing == XML_PARAM_ENTITY_PARSING_NEVER; -#endif -} - -int XML_Parse(XML_Parser parser, const char *s, int len, int isFinal) -{ - if (len == 0) { - if (!isFinal) - return 1; - positionPtr = bufferPtr; - errorCode = processor(parser, bufferPtr, parseEndPtr = bufferEnd, 0); - if (errorCode == XML_ERROR_NONE) - return 1; - eventEndPtr = eventPtr; - processor = errorProcessor; - return 0; - } -#ifndef XML_CONTEXT_BYTES - else if (bufferPtr == bufferEnd) { - const char *end; - int nLeftOver; - parseEndByteIndex += len; - positionPtr = s; - if (isFinal) { - errorCode = processor(parser, s, parseEndPtr = s + len, 0); - if (errorCode == XML_ERROR_NONE) - return 1; - eventEndPtr = eventPtr; - processor = errorProcessor; - return 0; - } - errorCode = processor(parser, s, parseEndPtr = s + len, &end); - if (errorCode != XML_ERROR_NONE) { - eventEndPtr = eventPtr; - processor = errorProcessor; - return 0; - } - XmlUpdatePosition(encoding, positionPtr, end, &position); - nLeftOver = s + len - end; - if (nLeftOver) { - if (buffer == 0 || nLeftOver > bufferLim - buffer) { - /* FIXME avoid integer overflow */ - buffer = buffer == 0 ? MALLOC(len * 2) : REALLOC(buffer, len * 2); - /* FIXME storage leak if realloc fails */ - if (!buffer) { - errorCode = XML_ERROR_NO_MEMORY; - eventPtr = eventEndPtr = 0; - processor = errorProcessor; - return 0; - } - bufferLim = buffer + len * 2; - } - memcpy(buffer, end, nLeftOver); - bufferPtr = buffer; - bufferEnd = buffer + nLeftOver; - } - return 1; - } -#endif /* not defined XML_CONTEXT_BYTES */ - else { - memcpy(XML_GetBuffer(parser, len), s, len); - return XML_ParseBuffer(parser, len, isFinal); - } -} - -int XML_ParseBuffer(XML_Parser parser, int len, int isFinal) -{ - const char *start = bufferPtr; - positionPtr = start; - bufferEnd += len; - parseEndByteIndex += len; - errorCode = processor(parser, start, parseEndPtr = bufferEnd, - isFinal ? (const char **)0 : &bufferPtr); - if (errorCode == XML_ERROR_NONE) { - if (!isFinal) - XmlUpdatePosition(encoding, positionPtr, bufferPtr, &position); - return 1; - } - else { - eventEndPtr = eventPtr; - processor = errorProcessor; - return 0; - } -} - -void *XML_GetBuffer(XML_Parser parser, int len) -{ - if (len > bufferLim - bufferEnd) { - /* FIXME avoid integer overflow */ - int neededSize = len + (bufferEnd - bufferPtr); -#ifdef XML_CONTEXT_BYTES - int keep = bufferPtr - buffer; - - if (keep > XML_CONTEXT_BYTES) - keep = XML_CONTEXT_BYTES; - neededSize += keep; -#endif /* defined XML_CONTEXT_BYTES */ - if (neededSize <= bufferLim - buffer) { -#ifdef XML_CONTEXT_BYTES - if (keep < bufferPtr - buffer) { - int offset = (bufferPtr - buffer) - keep; - memmove(buffer, &buffer[offset], bufferEnd - bufferPtr + keep); - bufferEnd -= offset; - bufferPtr -= offset; - } -#else - memmove(buffer, bufferPtr, bufferEnd - bufferPtr); - bufferEnd = buffer + (bufferEnd - bufferPtr); - bufferPtr = buffer; -#endif /* not defined XML_CONTEXT_BYTES */ - } - else { - char *newBuf; - int bufferSize = bufferLim - bufferPtr; - if (bufferSize == 0) - bufferSize = INIT_BUFFER_SIZE; - do { - bufferSize *= 2; - } while (bufferSize < neededSize); - newBuf = MALLOC(bufferSize); - if (newBuf == 0) { - errorCode = XML_ERROR_NO_MEMORY; - return 0; - } - bufferLim = newBuf + bufferSize; -#ifdef XML_CONTEXT_BYTES - if (bufferPtr) { - int keep = bufferPtr - buffer; - if (keep > XML_CONTEXT_BYTES) - keep = XML_CONTEXT_BYTES; - memcpy(newBuf, &bufferPtr[-keep], bufferEnd - bufferPtr + keep); - FREE(buffer); - buffer = newBuf; - bufferEnd = buffer + (bufferEnd - bufferPtr) + keep; - bufferPtr = buffer + keep; - } - else { - bufferEnd = newBuf + (bufferEnd - bufferPtr); - bufferPtr = buffer = newBuf; - } -#else - if (bufferPtr) { - memcpy(newBuf, bufferPtr, bufferEnd - bufferPtr); - FREE(buffer); - } - bufferEnd = newBuf + (bufferEnd - bufferPtr); - bufferPtr = buffer = newBuf; -#endif /* not defined XML_CONTEXT_BYTES */ - } - } - return bufferEnd; -} - -enum XML_Error XML_GetErrorCode(XML_Parser parser) -{ - return errorCode; -} - -long XML_GetCurrentByteIndex(XML_Parser parser) -{ - if (eventPtr) - return parseEndByteIndex - (parseEndPtr - eventPtr); - return -1; -} - -int XML_GetCurrentByteCount(XML_Parser parser) -{ - if (eventEndPtr && eventPtr) - return eventEndPtr - eventPtr; - return 0; -} - -const char * XML_GetInputContext(XML_Parser parser, int *offset, int *size) -{ -#ifdef XML_CONTEXT_BYTES - if (eventPtr && buffer) { - *offset = eventPtr - buffer; - *size = bufferEnd - buffer; - return buffer; - } -#endif /* defined XML_CONTEXT_BYTES */ - return (char *) 0; -} - -int XML_GetCurrentLineNumber(XML_Parser parser) -{ - if (eventPtr) { - XmlUpdatePosition(encoding, positionPtr, eventPtr, &position); - positionPtr = eventPtr; - } - return position.lineNumber + 1; -} - -int XML_GetCurrentColumnNumber(XML_Parser parser) -{ - if (eventPtr) { - XmlUpdatePosition(encoding, positionPtr, eventPtr, &position); - positionPtr = eventPtr; - } - return position.columnNumber; -} - -void XML_DefaultCurrent(XML_Parser parser) -{ - if (defaultHandler) { - if (openInternalEntities) - reportDefault(parser, - internalEncoding, - openInternalEntities->internalEventPtr, - openInternalEntities->internalEventEndPtr); - else - reportDefault(parser, encoding, eventPtr, eventEndPtr); - } -} - -const XML_LChar *XML_ErrorString(int code) -{ - static const XML_LChar *message[] = { - 0, - XML_T("out of memory"), - XML_T("syntax error"), - XML_T("no element found"), - XML_T("not well-formed (invalid token)"), - XML_T("unclosed token"), - XML_T("unclosed token"), - XML_T("mismatched tag"), - XML_T("duplicate attribute"), - XML_T("junk after document element"), - XML_T("illegal parameter entity reference"), - XML_T("undefined entity"), - XML_T("recursive entity reference"), - XML_T("asynchronous entity"), - XML_T("reference to invalid character number"), - XML_T("reference to binary entity"), - XML_T("reference to external entity in attribute"), - XML_T("xml processing instruction not at start of external entity"), - XML_T("unknown encoding"), - XML_T("encoding specified in XML declaration is incorrect"), - XML_T("unclosed CDATA section"), - XML_T("error in processing external entity reference"), - XML_T("document is not standalone"), - XML_T("unexpected parser state - please send a bug report") - }; - if (code > 0 && code < sizeof(message)/sizeof(message[0])) - return message[code]; - return 0; -} - -const XML_LChar * -XML_ExpatVersion(void) { - return VERSION; -} - -XML_Expat_Version -XML_ExpatVersionInfo(void) { - XML_Expat_Version version; - - version.major = XML_MAJOR_VERSION; - version.minor = XML_MINOR_VERSION; - version.micro = XML_MICRO_VERSION; - - return version; -} - -static -enum XML_Error contentProcessor(XML_Parser parser, - const char *start, - const char *end, - const char **endPtr) -{ - return doContent(parser, 0, encoding, start, end, endPtr); -} - -static -enum XML_Error externalEntityInitProcessor(XML_Parser parser, - const char *start, - const char *end, - const char **endPtr) -{ - enum XML_Error result = initializeEncoding(parser); - if (result != XML_ERROR_NONE) - return result; - processor = externalEntityInitProcessor2; - return externalEntityInitProcessor2(parser, start, end, endPtr); -} - -static -enum XML_Error externalEntityInitProcessor2(XML_Parser parser, - const char *start, - const char *end, - const char **endPtr) -{ - const char *next; - int tok = XmlContentTok(encoding, start, end, &next); - switch (tok) { - case XML_TOK_BOM: - start = next; - break; - case XML_TOK_PARTIAL: - if (endPtr) { - *endPtr = start; - return XML_ERROR_NONE; - } - eventPtr = start; - return XML_ERROR_UNCLOSED_TOKEN; - case XML_TOK_PARTIAL_CHAR: - if (endPtr) { - *endPtr = start; - return XML_ERROR_NONE; - } - eventPtr = start; - return XML_ERROR_PARTIAL_CHAR; - } - processor = externalEntityInitProcessor3; - return externalEntityInitProcessor3(parser, start, end, endPtr); -} - -static -enum XML_Error externalEntityInitProcessor3(XML_Parser parser, - const char *start, - const char *end, - const char **endPtr) -{ - const char *next; - int tok = XmlContentTok(encoding, start, end, &next); - switch (tok) { - case XML_TOK_XML_DECL: - { - enum XML_Error result = processXmlDecl(parser, 1, start, next); - if (result != XML_ERROR_NONE) - return result; - start = next; - } - break; - case XML_TOK_PARTIAL: - if (endPtr) { - *endPtr = start; - return XML_ERROR_NONE; - } - eventPtr = start; - return XML_ERROR_UNCLOSED_TOKEN; - case XML_TOK_PARTIAL_CHAR: - if (endPtr) { - *endPtr = start; - return XML_ERROR_NONE; - } - eventPtr = start; - return XML_ERROR_PARTIAL_CHAR; - } - processor = externalEntityContentProcessor; - tagLevel = 1; - return doContent(parser, 1, encoding, start, end, endPtr); -} - -static -enum XML_Error externalEntityContentProcessor(XML_Parser parser, - const char *start, - const char *end, - const char **endPtr) -{ - return doContent(parser, 1, encoding, start, end, endPtr); -} - -static enum XML_Error -doContent(XML_Parser parser, - int startTagLevel, - const ENCODING *enc, - const char *s, - const char *end, - const char **nextPtr) -{ - const char **eventPP; - const char **eventEndPP; - if (enc == encoding) { - eventPP = &eventPtr; - eventEndPP = &eventEndPtr; - } - else { - eventPP = &(openInternalEntities->internalEventPtr); - eventEndPP = &(openInternalEntities->internalEventEndPtr); - } - *eventPP = s; - for (;;) { - const char *next = s; /* XmlContentTok doesn't always set the last arg */ - int tok = XmlContentTok(enc, s, end, &next); - *eventEndPP = next; - switch (tok) { - case XML_TOK_TRAILING_CR: - if (nextPtr) { - *nextPtr = s; - return XML_ERROR_NONE; - } - *eventEndPP = end; - if (characterDataHandler) { - XML_Char c = 0xA; - characterDataHandler(handlerArg, &c, 1); - } - else if (defaultHandler) - reportDefault(parser, enc, s, end); - if (startTagLevel == 0) - return XML_ERROR_NO_ELEMENTS; - if (tagLevel != startTagLevel) - return XML_ERROR_ASYNC_ENTITY; - return XML_ERROR_NONE; - case XML_TOK_NONE: - if (nextPtr) { - *nextPtr = s; - return XML_ERROR_NONE; - } - if (startTagLevel > 0) { - if (tagLevel != startTagLevel) - return XML_ERROR_ASYNC_ENTITY; - return XML_ERROR_NONE; - } - return XML_ERROR_NO_ELEMENTS; - case XML_TOK_INVALID: - *eventPP = next; - return XML_ERROR_INVALID_TOKEN; - case XML_TOK_PARTIAL: - if (nextPtr) { - *nextPtr = s; - return XML_ERROR_NONE; - } - return XML_ERROR_UNCLOSED_TOKEN; - case XML_TOK_PARTIAL_CHAR: - if (nextPtr) { - *nextPtr = s; - return XML_ERROR_NONE; - } - return XML_ERROR_PARTIAL_CHAR; - case XML_TOK_ENTITY_REF: - { - const XML_Char *name; - ENTITY *entity; - XML_Char ch = XmlPredefinedEntityName(enc, - s + enc->minBytesPerChar, - next - enc->minBytesPerChar); - if (ch) { - if (characterDataHandler) - characterDataHandler(handlerArg, &ch, 1); - else if (defaultHandler) - reportDefault(parser, enc, s, next); - break; - } - name = poolStoreString(&dtd.pool, enc, - s + enc->minBytesPerChar, - next - enc->minBytesPerChar); - if (!name) - return XML_ERROR_NO_MEMORY; - entity = (ENTITY *)lookup(&dtd.generalEntities, name, 0); - poolDiscard(&dtd.pool); - if (!entity) { - if (dtd.complete || dtd.standalone) - return XML_ERROR_UNDEFINED_ENTITY; - if (defaultHandler) - reportDefault(parser, enc, s, next); - break; - } - if (entity->open) - return XML_ERROR_RECURSIVE_ENTITY_REF; - if (entity->notation) - return XML_ERROR_BINARY_ENTITY_REF; - if (entity) { - if (entity->textPtr) { - enum XML_Error result; - OPEN_INTERNAL_ENTITY openEntity; - if (defaultHandler && !defaultExpandInternalEntities) { - reportDefault(parser, enc, s, next); - break; - } - entity->open = 1; - openEntity.next = openInternalEntities; - openInternalEntities = &openEntity; - openEntity.entity = entity; - openEntity.internalEventPtr = 0; - openEntity.internalEventEndPtr = 0; - result = doContent(parser, - tagLevel, - internalEncoding, - (char *)entity->textPtr, - (char *)(entity->textPtr + entity->textLen), - 0); - entity->open = 0; - openInternalEntities = openEntity.next; - if (result) - return result; - } - else if (externalEntityRefHandler) { - const XML_Char *context; - entity->open = 1; - context = getContext(parser); - entity->open = 0; - if (!context) - return XML_ERROR_NO_MEMORY; - if (!externalEntityRefHandler(externalEntityRefHandlerArg, - context, - entity->base, - entity->systemId, - entity->publicId)) - return XML_ERROR_EXTERNAL_ENTITY_HANDLING; - poolDiscard(&tempPool); - } - else if (defaultHandler) - reportDefault(parser, enc, s, next); - } - break; - } - case XML_TOK_START_TAG_WITH_ATTS: - if (!startElementHandler) { - enum XML_Error result = storeAtts(parser, enc, s, 0, 0); - if (result) - return result; - } - /* fall through */ - case XML_TOK_START_TAG_NO_ATTS: - { - TAG *tag; - if (freeTagList) { - tag = freeTagList; - freeTagList = freeTagList->parent; - } - else { - tag = MALLOC(sizeof(TAG)); - if (!tag) - return XML_ERROR_NO_MEMORY; - tag->buf = MALLOC(INIT_TAG_BUF_SIZE); - if (!tag->buf) - return XML_ERROR_NO_MEMORY; - tag->bufEnd = tag->buf + INIT_TAG_BUF_SIZE; - } - tag->bindings = 0; - tag->parent = tagStack; - tagStack = tag; - tag->name.localPart = 0; - tag->rawName = s + enc->minBytesPerChar; - tag->rawNameLength = XmlNameLength(enc, tag->rawName); - if (nextPtr) { - /* Need to guarantee that: - tag->buf + ROUND_UP(tag->rawNameLength, sizeof(XML_Char)) <= tag->bufEnd - sizeof(XML_Char) */ - if (tag->rawNameLength + (int)(sizeof(XML_Char) - 1) + (int)sizeof(XML_Char) > tag->bufEnd - tag->buf) { - int bufSize = tag->rawNameLength * 4; - bufSize = ROUND_UP(bufSize, sizeof(XML_Char)); - tag->buf = REALLOC(tag->buf, bufSize); - if (!tag->buf) - return XML_ERROR_NO_MEMORY; - tag->bufEnd = tag->buf + bufSize; - } - memcpy(tag->buf, tag->rawName, tag->rawNameLength); - tag->rawName = tag->buf; - } - ++tagLevel; - if (startElementHandler) { - enum XML_Error result; - XML_Char *toPtr; - for (;;) { - const char *rawNameEnd = tag->rawName + tag->rawNameLength; - const char *fromPtr = tag->rawName; - int bufSize; - if (nextPtr) - toPtr = (XML_Char *)(tag->buf + ROUND_UP(tag->rawNameLength, sizeof(XML_Char))); - else - toPtr = (XML_Char *)tag->buf; - tag->name.str = toPtr; - XmlConvert(enc, - &fromPtr, rawNameEnd, - (ICHAR **)&toPtr, (ICHAR *)tag->bufEnd - 1); - if (fromPtr == rawNameEnd) - break; - bufSize = (tag->bufEnd - tag->buf) << 1; - tag->buf = REALLOC(tag->buf, bufSize); - if (!tag->buf) - return XML_ERROR_NO_MEMORY; - tag->bufEnd = tag->buf + bufSize; - if (nextPtr) - tag->rawName = tag->buf; - } - *toPtr = XML_T('\0'); - result = storeAtts(parser, enc, s, &(tag->name), &(tag->bindings)); - if (result) - return result; - startElementHandler(handlerArg, tag->name.str, (const XML_Char **)atts); - poolClear(&tempPool); - } - else { - tag->name.str = 0; - if (defaultHandler) - reportDefault(parser, enc, s, next); - } - break; - } - case XML_TOK_EMPTY_ELEMENT_WITH_ATTS: - if (!startElementHandler) { - enum XML_Error result = storeAtts(parser, enc, s, 0, 0); - if (result) - return result; - } - /* fall through */ - case XML_TOK_EMPTY_ELEMENT_NO_ATTS: - if (startElementHandler || endElementHandler) { - const char *rawName = s + enc->minBytesPerChar; - enum XML_Error result; - BINDING *bindings = 0; - TAG_NAME name; - name.str = poolStoreString(&tempPool, enc, rawName, - rawName + XmlNameLength(enc, rawName)); - if (!name.str) - return XML_ERROR_NO_MEMORY; - poolFinish(&tempPool); - result = storeAtts(parser, enc, s, &name, &bindings); - if (result) - return result; - poolFinish(&tempPool); - if (startElementHandler) - startElementHandler(handlerArg, name.str, (const XML_Char **)atts); - if (endElementHandler) { - if (startElementHandler) - *eventPP = *eventEndPP; - endElementHandler(handlerArg, name.str); - } - poolClear(&tempPool); - while (bindings) { - BINDING *b = bindings; - if (endNamespaceDeclHandler) - endNamespaceDeclHandler(handlerArg, b->prefix->name); - bindings = bindings->nextTagBinding; - b->nextTagBinding = freeBindingList; - freeBindingList = b; - b->prefix->binding = b->prevPrefixBinding; - } - } - else if (defaultHandler) - reportDefault(parser, enc, s, next); - if (tagLevel == 0) - return epilogProcessor(parser, next, end, nextPtr); - break; - case XML_TOK_END_TAG: - if (tagLevel == startTagLevel) - return XML_ERROR_ASYNC_ENTITY; - else { - int len; - const char *rawName; - TAG *tag = tagStack; - tagStack = tag->parent; - tag->parent = freeTagList; - freeTagList = tag; - rawName = s + enc->minBytesPerChar*2; - len = XmlNameLength(enc, rawName); - if (len != tag->rawNameLength - || memcmp(tag->rawName, rawName, len) != 0) { - *eventPP = rawName; - return XML_ERROR_TAG_MISMATCH; - } - --tagLevel; - if (endElementHandler && tag->name.str) { - if (tag->name.localPart) { - XML_Char *to = (XML_Char *)tag->name.str + tag->name.uriLen; - const XML_Char *from = tag->name.localPart; - while ((*to++ = *from++) != 0) - ; - } - endElementHandler(handlerArg, tag->name.str); - } - else if (defaultHandler) - reportDefault(parser, enc, s, next); - while (tag->bindings) { - BINDING *b = tag->bindings; - if (endNamespaceDeclHandler) - endNamespaceDeclHandler(handlerArg, b->prefix->name); - tag->bindings = tag->bindings->nextTagBinding; - b->nextTagBinding = freeBindingList; - freeBindingList = b; - b->prefix->binding = b->prevPrefixBinding; - } - if (tagLevel == 0) - return epilogProcessor(parser, next, end, nextPtr); - } - break; - case XML_TOK_CHAR_REF: - { - int n = XmlCharRefNumber(enc, s); - if (n < 0) - return XML_ERROR_BAD_CHAR_REF; - if (characterDataHandler) { - XML_Char buf[XML_ENCODE_MAX]; - characterDataHandler(handlerArg, buf, XmlEncode(n, (ICHAR *)buf)); - } - else if (defaultHandler) - reportDefault(parser, enc, s, next); - } - break; - case XML_TOK_XML_DECL: - return XML_ERROR_MISPLACED_XML_PI; - case XML_TOK_DATA_NEWLINE: - if (characterDataHandler) { - XML_Char c = 0xA; - characterDataHandler(handlerArg, &c, 1); - } - else if (defaultHandler) - reportDefault(parser, enc, s, next); - break; - case XML_TOK_CDATA_SECT_OPEN: - { - enum XML_Error result; - if (startCdataSectionHandler) - startCdataSectionHandler(handlerArg); -#if 0 - /* Suppose you doing a transformation on a document that involves - changing only the character data. You set up a defaultHandler - and a characterDataHandler. The defaultHandler simply copies - characters through. The characterDataHandler does the transformation - and writes the characters out escaping them as necessary. This case - will fail to work if we leave out the following two lines (because & - and < inside CDATA sections will be incorrectly escaped). - - However, now we have a start/endCdataSectionHandler, so it seems - easier to let the user deal with this. */ - - else if (characterDataHandler) - characterDataHandler(handlerArg, dataBuf, 0); -#endif - else if (defaultHandler) - reportDefault(parser, enc, s, next); - result = doCdataSection(parser, enc, &next, end, nextPtr); - if (!next) { - processor = cdataSectionProcessor; - return result; - } - } - break; - case XML_TOK_TRAILING_RSQB: - if (nextPtr) { - *nextPtr = s; - return XML_ERROR_NONE; - } - if (characterDataHandler) { - if (MUST_CONVERT(enc, s)) { - ICHAR *dataPtr = (ICHAR *)dataBuf; - XmlConvert(enc, &s, end, &dataPtr, (ICHAR *)dataBufEnd); - characterDataHandler(handlerArg, dataBuf, dataPtr - (ICHAR *)dataBuf); - } - else - characterDataHandler(handlerArg, - (XML_Char *)s, - (XML_Char *)end - (XML_Char *)s); - } - else if (defaultHandler) - reportDefault(parser, enc, s, end); - if (startTagLevel == 0) { - *eventPP = end; - return XML_ERROR_NO_ELEMENTS; - } - if (tagLevel != startTagLevel) { - *eventPP = end; - return XML_ERROR_ASYNC_ENTITY; - } - return XML_ERROR_NONE; - case XML_TOK_DATA_CHARS: - if (characterDataHandler) { - if (MUST_CONVERT(enc, s)) { - for (;;) { - ICHAR *dataPtr = (ICHAR *)dataBuf; - XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd); - *eventEndPP = s; - characterDataHandler(handlerArg, dataBuf, dataPtr - (ICHAR *)dataBuf); - if (s == next) - break; - *eventPP = s; - } - } - else - characterDataHandler(handlerArg, - (XML_Char *)s, - (XML_Char *)next - (XML_Char *)s); - } - else if (defaultHandler) - reportDefault(parser, enc, s, next); - break; - case XML_TOK_PI: - if (!reportProcessingInstruction(parser, enc, s, next)) - return XML_ERROR_NO_MEMORY; - break; - case XML_TOK_COMMENT: - if (!reportComment(parser, enc, s, next)) - return XML_ERROR_NO_MEMORY; - break; - default: - if (defaultHandler) - reportDefault(parser, enc, s, next); - break; - } - *eventPP = s = next; - } - /* not reached */ -} - -/* If tagNamePtr is non-null, build a real list of attributes, -otherwise just check the attributes for well-formedness. */ - -static enum XML_Error storeAtts(XML_Parser parser, const ENCODING *enc, - const char *attStr, TAG_NAME *tagNamePtr, - BINDING **bindingsPtr) -{ - ELEMENT_TYPE *elementType = 0; - int nDefaultAtts = 0; - const XML_Char **appAtts; /* the attribute list to pass to the application */ - int attIndex = 0; - int i; - int n; - int nPrefixes = 0; - BINDING *binding; - const XML_Char *localPart; - - /* lookup the element type name */ - if (tagNamePtr) { - elementType = (ELEMENT_TYPE *)lookup(&dtd.elementTypes, tagNamePtr->str,0); - if (!elementType) { - tagNamePtr->str = poolCopyString(&dtd.pool, tagNamePtr->str); - if (!tagNamePtr->str) - return XML_ERROR_NO_MEMORY; - elementType = (ELEMENT_TYPE *)lookup(&dtd.elementTypes, tagNamePtr->str, sizeof(ELEMENT_TYPE)); - if (!elementType) - return XML_ERROR_NO_MEMORY; - if (ns && !setElementTypePrefix(parser, elementType)) - return XML_ERROR_NO_MEMORY; - } - nDefaultAtts = elementType->nDefaultAtts; - } - /* get the attributes from the tokenizer */ - n = XmlGetAttributes(enc, attStr, attsSize, atts); - if (n + nDefaultAtts > attsSize) { - int oldAttsSize = attsSize; - attsSize = n + nDefaultAtts + INIT_ATTS_SIZE; - atts = REALLOC((void *)atts, attsSize * sizeof(ATTRIBUTE)); - if (!atts) - return XML_ERROR_NO_MEMORY; - if (n > oldAttsSize) - XmlGetAttributes(enc, attStr, n, atts); - } - appAtts = (const XML_Char **)atts; - for (i = 0; i < n; i++) { - /* add the name and value to the attribute list */ - ATTRIBUTE_ID *attId = getAttributeId(parser, enc, atts[i].name, - atts[i].name - + XmlNameLength(enc, atts[i].name)); - if (!attId) - return XML_ERROR_NO_MEMORY; - /* detect duplicate attributes */ - if ((attId->name)[-1]) { - if (enc == encoding) - eventPtr = atts[i].name; - return XML_ERROR_DUPLICATE_ATTRIBUTE; - } - (attId->name)[-1] = 1; - appAtts[attIndex++] = attId->name; - if (!atts[i].normalized) { - enum XML_Error result; - int isCdata = 1; - - /* figure out whether declared as other than CDATA */ - if (attId->maybeTokenized) { - int j; - for (j = 0; j < nDefaultAtts; j++) { - if (attId == elementType->defaultAtts[j].id) { - isCdata = elementType->defaultAtts[j].isCdata; - break; - } - } - } - - /* normalize the attribute value */ - result = storeAttributeValue(parser, enc, isCdata, - atts[i].valuePtr, atts[i].valueEnd, - &tempPool); - if (result) - return result; - if (tagNamePtr) { - appAtts[attIndex] = poolStart(&tempPool); - poolFinish(&tempPool); - } - else - poolDiscard(&tempPool); - } - else if (tagNamePtr) { - /* the value did not need normalizing */ - appAtts[attIndex] = poolStoreString(&tempPool, enc, atts[i].valuePtr, atts[i].valueEnd); - if (appAtts[attIndex] == 0) - return XML_ERROR_NO_MEMORY; - poolFinish(&tempPool); - } - /* handle prefixed attribute names */ - if (attId->prefix && tagNamePtr) { - if (attId->xmlns) { - /* deal with namespace declarations here */ - if (!addBinding(parser, attId->prefix, attId, appAtts[attIndex], bindingsPtr)) - return XML_ERROR_NO_MEMORY; - --attIndex; - } - else { - /* deal with other prefixed names later */ - attIndex++; - nPrefixes++; - (attId->name)[-1] = 2; - } - } - else - attIndex++; - } - if (tagNamePtr) { - int j; - nSpecifiedAtts = attIndex; - if (elementType->idAtt && (elementType->idAtt->name)[-1]) { - for (i = 0; i < attIndex; i += 2) - if (appAtts[i] == elementType->idAtt->name) { - idAttIndex = i; - break; - } - } - else - idAttIndex = -1; - /* do attribute defaulting */ - for (j = 0; j < nDefaultAtts; j++) { - const DEFAULT_ATTRIBUTE *da = elementType->defaultAtts + j; - if (!(da->id->name)[-1] && da->value) { - if (da->id->prefix) { - if (da->id->xmlns) { - if (!addBinding(parser, da->id->prefix, da->id, da->value, bindingsPtr)) - return XML_ERROR_NO_MEMORY; - } - else { - (da->id->name)[-1] = 2; - nPrefixes++; - appAtts[attIndex++] = da->id->name; - appAtts[attIndex++] = da->value; - } - } - else { - (da->id->name)[-1] = 1; - appAtts[attIndex++] = da->id->name; - appAtts[attIndex++] = da->value; - } - } - } - appAtts[attIndex] = 0; - } - i = 0; - if (nPrefixes) { - /* expand prefixed attribute names */ - for (; i < attIndex; i += 2) { - if (appAtts[i][-1] == 2) { - ATTRIBUTE_ID *id; - ((XML_Char *)(appAtts[i]))[-1] = 0; - id = (ATTRIBUTE_ID *)lookup(&dtd.attributeIds, appAtts[i], 0); - if (id->prefix->binding) { - int j; - const BINDING *b = id->prefix->binding; - const XML_Char *s = appAtts[i]; - for (j = 0; j < b->uriLen; j++) { - if (!poolAppendChar(&tempPool, b->uri[j])) - return XML_ERROR_NO_MEMORY; - } - while (*s++ != ':') - ; - do { - if (!poolAppendChar(&tempPool, *s)) - return XML_ERROR_NO_MEMORY; - } while (*s++); - if (ns_triplets) { - tempPool.ptr[-1] = namespaceSeparator; - s = b->prefix->name; - do { - if (!poolAppendChar(&tempPool, *s)) - return XML_ERROR_NO_MEMORY; - } while (*s++); - } - - appAtts[i] = poolStart(&tempPool); - poolFinish(&tempPool); - } - if (!--nPrefixes) - break; - } - else - ((XML_Char *)(appAtts[i]))[-1] = 0; - } - } - /* clear the flags that say whether attributes were specified */ - for (; i < attIndex; i += 2) - ((XML_Char *)(appAtts[i]))[-1] = 0; - if (!tagNamePtr) - return XML_ERROR_NONE; - for (binding = *bindingsPtr; binding; binding = binding->nextTagBinding) - binding->attId->name[-1] = 0; - /* expand the element type name */ - if (elementType->prefix) { - binding = elementType->prefix->binding; - if (!binding) - return XML_ERROR_NONE; - localPart = tagNamePtr->str; - while (*localPart++ != XML_T(':')) - ; - } - else if (dtd.defaultPrefix.binding) { - binding = dtd.defaultPrefix.binding; - localPart = tagNamePtr->str; - } - else - return XML_ERROR_NONE; - tagNamePtr->localPart = localPart; - tagNamePtr->uriLen = binding->uriLen; - for (i = 0; localPart[i++];) - ; - n = i + binding->uriLen; - if (n > binding->uriAlloc) { - TAG *p; - XML_Char *uri = MALLOC((n + EXPAND_SPARE) * sizeof(XML_Char)); - if (!uri) - return XML_ERROR_NO_MEMORY; - binding->uriAlloc = n + EXPAND_SPARE; - memcpy(uri, binding->uri, binding->uriLen * sizeof(XML_Char)); - for (p = tagStack; p; p = p->parent) - if (p->name.str == binding->uri) - p->name.str = uri; - FREE(binding->uri); - binding->uri = uri; - } - memcpy(binding->uri + binding->uriLen, localPart, i * sizeof(XML_Char)); - tagNamePtr->str = binding->uri; - return XML_ERROR_NONE; -} - -static -int addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId, const XML_Char *uri, BINDING **bindingsPtr) -{ - BINDING *b; - int len; - for (len = 0; uri[len]; len++) - ; - if (namespaceSeparator) - len++; - if (freeBindingList) { - b = freeBindingList; - if (len > b->uriAlloc) { - b->uri = REALLOC(b->uri, sizeof(XML_Char) * (len + EXPAND_SPARE)); - if (!b->uri) - return 0; - b->uriAlloc = len + EXPAND_SPARE; - } - freeBindingList = b->nextTagBinding; - } - else { - b = MALLOC(sizeof(BINDING)); - if (!b) - return 0; - b->uri = MALLOC(sizeof(XML_Char) * (len + EXPAND_SPARE)); - if (!b->uri) { - FREE(b); - return 0; - } - b->uriAlloc = len + EXPAND_SPARE; - } - b->uriLen = len; - memcpy(b->uri, uri, len * sizeof(XML_Char)); - if (namespaceSeparator) - b->uri[len - 1] = namespaceSeparator; - b->prefix = prefix; - b->attId = attId; - b->prevPrefixBinding = prefix->binding; - if (*uri == XML_T('\0') && prefix == &dtd.defaultPrefix) - prefix->binding = 0; - else - prefix->binding = b; - b->nextTagBinding = *bindingsPtr; - *bindingsPtr = b; - if (startNamespaceDeclHandler) - startNamespaceDeclHandler(handlerArg, prefix->name, - prefix->binding ? uri : 0); - return 1; -} - -/* The idea here is to avoid using stack for each CDATA section when -the whole file is parsed with one call. */ - -static -enum XML_Error cdataSectionProcessor(XML_Parser parser, - const char *start, - const char *end, - const char **endPtr) -{ - enum XML_Error result = doCdataSection(parser, encoding, &start, end, endPtr); - if (start) { - processor = contentProcessor; - return contentProcessor(parser, start, end, endPtr); - } - return result; -} - -/* startPtr gets set to non-null is the section is closed, and to null if -the section is not yet closed. */ - -static -enum XML_Error doCdataSection(XML_Parser parser, - const ENCODING *enc, - const char **startPtr, - const char *end, - const char **nextPtr) -{ - const char *s = *startPtr; - const char **eventPP; - const char **eventEndPP; - if (enc == encoding) { - eventPP = &eventPtr; - *eventPP = s; - eventEndPP = &eventEndPtr; - } - else { - eventPP = &(openInternalEntities->internalEventPtr); - eventEndPP = &(openInternalEntities->internalEventEndPtr); - } - *eventPP = s; - *startPtr = 0; - for (;;) { - const char *next; - int tok = XmlCdataSectionTok(enc, s, end, &next); - *eventEndPP = next; - switch (tok) { - case XML_TOK_CDATA_SECT_CLOSE: - if (endCdataSectionHandler) - endCdataSectionHandler(handlerArg); -#if 0 - /* see comment under XML_TOK_CDATA_SECT_OPEN */ - else if (characterDataHandler) - characterDataHandler(handlerArg, dataBuf, 0); -#endif - else if (defaultHandler) - reportDefault(parser, enc, s, next); - *startPtr = next; - return XML_ERROR_NONE; - case XML_TOK_DATA_NEWLINE: - if (characterDataHandler) { - XML_Char c = 0xA; - characterDataHandler(handlerArg, &c, 1); - } - else if (defaultHandler) - reportDefault(parser, enc, s, next); - break; - case XML_TOK_DATA_CHARS: - if (characterDataHandler) { - if (MUST_CONVERT(enc, s)) { - for (;;) { - ICHAR *dataPtr = (ICHAR *)dataBuf; - XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd); - *eventEndPP = next; - characterDataHandler(handlerArg, dataBuf, dataPtr - (ICHAR *)dataBuf); - if (s == next) - break; - *eventPP = s; - } - } - else - characterDataHandler(handlerArg, - (XML_Char *)s, - (XML_Char *)next - (XML_Char *)s); - } - else if (defaultHandler) - reportDefault(parser, enc, s, next); - break; - case XML_TOK_INVALID: - *eventPP = next; - return XML_ERROR_INVALID_TOKEN; - case XML_TOK_PARTIAL_CHAR: - if (nextPtr) { - *nextPtr = s; - return XML_ERROR_NONE; - } - return XML_ERROR_PARTIAL_CHAR; - case XML_TOK_PARTIAL: - case XML_TOK_NONE: - if (nextPtr) { - *nextPtr = s; - return XML_ERROR_NONE; - } - return XML_ERROR_UNCLOSED_CDATA_SECTION; - default: - *eventPP = next; - return XML_ERROR_UNEXPECTED_STATE; - } - *eventPP = s = next; - } - /* not reached */ -} - -#ifdef XML_DTD - -/* The idea here is to avoid using stack for each IGNORE section when -the whole file is parsed with one call. */ - -static -enum XML_Error ignoreSectionProcessor(XML_Parser parser, - const char *start, - const char *end, - const char **endPtr) -{ - enum XML_Error result = doIgnoreSection(parser, encoding, &start, end, endPtr); - if (start) { - processor = prologProcessor; - return prologProcessor(parser, start, end, endPtr); - } - return result; -} - -/* startPtr gets set to non-null is the section is closed, and to null if -the section is not yet closed. */ - -static -enum XML_Error doIgnoreSection(XML_Parser parser, - const ENCODING *enc, - const char **startPtr, - const char *end, - const char **nextPtr) -{ - const char *next; - int tok; - const char *s = *startPtr; - const char **eventPP; - const char **eventEndPP; - if (enc == encoding) { - eventPP = &eventPtr; - *eventPP = s; - eventEndPP = &eventEndPtr; - } - else { - eventPP = &(openInternalEntities->internalEventPtr); - eventEndPP = &(openInternalEntities->internalEventEndPtr); - } - *eventPP = s; - *startPtr = 0; - tok = XmlIgnoreSectionTok(enc, s, end, &next); - *eventEndPP = next; - switch (tok) { - case XML_TOK_IGNORE_SECT: - if (defaultHandler) - reportDefault(parser, enc, s, next); - *startPtr = next; - return XML_ERROR_NONE; - case XML_TOK_INVALID: - *eventPP = next; - return XML_ERROR_INVALID_TOKEN; - case XML_TOK_PARTIAL_CHAR: - if (nextPtr) { - *nextPtr = s; - return XML_ERROR_NONE; - } - return XML_ERROR_PARTIAL_CHAR; - case XML_TOK_PARTIAL: - case XML_TOK_NONE: - if (nextPtr) { - *nextPtr = s; - return XML_ERROR_NONE; - } - return XML_ERROR_SYNTAX; /* XML_ERROR_UNCLOSED_IGNORE_SECTION */ - default: - *eventPP = next; - return XML_ERROR_UNEXPECTED_STATE; - } - /* not reached */ -} - -#endif /* XML_DTD */ - -static enum XML_Error -initializeEncoding(XML_Parser parser) -{ - const char *s; -#ifdef XML_UNICODE - char encodingBuf[128]; - if (!protocolEncodingName) - s = 0; - else { - int i; - for (i = 0; protocolEncodingName[i]; i++) { - if (i == sizeof(encodingBuf) - 1 - || (protocolEncodingName[i] & ~0x7f) != 0) { - encodingBuf[0] = '\0'; - break; - } - encodingBuf[i] = (char)protocolEncodingName[i]; - } - encodingBuf[i] = '\0'; - s = encodingBuf; - } -#else - s = protocolEncodingName; -#endif - if ((ns ? XmlInitEncodingNS : XmlInitEncoding)(&initEncoding, &encoding, s)) - return XML_ERROR_NONE; - return handleUnknownEncoding(parser, protocolEncodingName); -} - -static enum XML_Error -processXmlDecl(XML_Parser parser, int isGeneralTextEntity, - const char *s, const char *next) -{ - const char *encodingName = 0; - const char *storedEncName = 0; - const ENCODING *newEncoding = 0; - const char *version = 0; - const char *versionend; - const char *storedversion = 0; - int standalone = -1; - if (!(ns - ? XmlParseXmlDeclNS - : XmlParseXmlDecl)(isGeneralTextEntity, - encoding, - s, - next, - &eventPtr, - &version, - &versionend, - &encodingName, - &newEncoding, - &standalone)) - return XML_ERROR_SYNTAX; - if (!isGeneralTextEntity && standalone == 1) { - dtd.standalone = 1; -#ifdef XML_DTD - if (paramEntityParsing == XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE) - paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER; -#endif /* XML_DTD */ - } - if (xmlDeclHandler) { - if (encodingName) { - storedEncName = poolStoreString(&temp2Pool, - encoding, - encodingName, - encodingName - + XmlNameLength(encoding, encodingName)); - if (! storedEncName) - return XML_ERROR_NO_MEMORY; - poolFinish(&temp2Pool); - } - if (version) { - storedversion = poolStoreString(&temp2Pool, - encoding, - version, - versionend - encoding->minBytesPerChar); - if (! storedversion) - return XML_ERROR_NO_MEMORY; - } - xmlDeclHandler(handlerArg, storedversion, storedEncName, standalone); - } - else if (defaultHandler) - reportDefault(parser, encoding, s, next); - if (!protocolEncodingName) { - if (newEncoding) { - if (newEncoding->minBytesPerChar != encoding->minBytesPerChar) { - eventPtr = encodingName; - return XML_ERROR_INCORRECT_ENCODING; - } - encoding = newEncoding; - } - else if (encodingName) { - enum XML_Error result; - if (! storedEncName) { - storedEncName = poolStoreString(&temp2Pool, - encoding, - encodingName, - encodingName - + XmlNameLength(encoding, encodingName)); - if (! storedEncName) - return XML_ERROR_NO_MEMORY; - } - result = handleUnknownEncoding(parser, storedEncName); - poolClear(&tempPool); - if (result == XML_ERROR_UNKNOWN_ENCODING) - eventPtr = encodingName; - return result; - } - } - - if (storedEncName || storedversion) - poolClear(&temp2Pool); - - return XML_ERROR_NONE; -} - -static enum XML_Error -handleUnknownEncoding(XML_Parser parser, const XML_Char *encodingName) -{ - if (unknownEncodingHandler) { - XML_Encoding info; - int i; - for (i = 0; i < 256; i++) - info.map[i] = -1; - info.convert = 0; - info.data = 0; - info.release = 0; - if (unknownEncodingHandler(unknownEncodingHandlerData, encodingName, &info)) { - ENCODING *enc; - unknownEncodingMem = MALLOC(XmlSizeOfUnknownEncoding()); - if (!unknownEncodingMem) { - if (info.release) - info.release(info.data); - return XML_ERROR_NO_MEMORY; - } - enc = (ns - ? XmlInitUnknownEncodingNS - : XmlInitUnknownEncoding)(unknownEncodingMem, - info.map, - info.convert, - info.data); - if (enc) { - unknownEncodingData = info.data; - unknownEncodingRelease = info.release; - encoding = enc; - return XML_ERROR_NONE; - } - } - if (info.release) - info.release(info.data); - } - return XML_ERROR_UNKNOWN_ENCODING; -} - -static enum XML_Error -prologInitProcessor(XML_Parser parser, - const char *s, - const char *end, - const char **nextPtr) -{ - enum XML_Error result = initializeEncoding(parser); - if (result != XML_ERROR_NONE) - return result; - processor = prologProcessor; - return prologProcessor(parser, s, end, nextPtr); -} - -static enum XML_Error -prologProcessor(XML_Parser parser, - const char *s, - const char *end, - const char **nextPtr) -{ - const char *next; - int tok = XmlPrologTok(encoding, s, end, &next); - return doProlog(parser, encoding, s, end, tok, next, nextPtr); -} - -static enum XML_Error -doProlog(XML_Parser parser, - const ENCODING *enc, - const char *s, - const char *end, - int tok, - const char *next, - const char **nextPtr) -{ -#ifdef XML_DTD - static const XML_Char externalSubsetName[] = { '#' , '\0' }; -#endif /* XML_DTD */ - - const char **eventPP; - const char **eventEndPP; - enum XML_Content_Quant quant; - - if (enc == encoding) { - eventPP = &eventPtr; - eventEndPP = &eventEndPtr; - } - else { - eventPP = &(openInternalEntities->internalEventPtr); - eventEndPP = &(openInternalEntities->internalEventEndPtr); - } - for (;;) { - int role; - *eventPP = s; - *eventEndPP = next; - if (tok <= 0) { - if (nextPtr != 0 && tok != XML_TOK_INVALID) { - *nextPtr = s; - return XML_ERROR_NONE; - } - switch (tok) { - case XML_TOK_INVALID: - *eventPP = next; - return XML_ERROR_INVALID_TOKEN; - case XML_TOK_PARTIAL: - return XML_ERROR_UNCLOSED_TOKEN; - case XML_TOK_PARTIAL_CHAR: - return XML_ERROR_PARTIAL_CHAR; - case XML_TOK_NONE: -#ifdef XML_DTD - if (enc != encoding) - return XML_ERROR_NONE; - if (parentParser) { - if (XmlTokenRole(&prologState, XML_TOK_NONE, end, end, enc) - == XML_ROLE_ERROR) - return XML_ERROR_SYNTAX; - hadExternalDoctype = 0; - return XML_ERROR_NONE; - } -#endif /* XML_DTD */ - return XML_ERROR_NO_ELEMENTS; - default: - tok = -tok; - next = end; - break; - } - } - role = XmlTokenRole(&prologState, tok, s, next, enc); - switch (role) { - case XML_ROLE_XML_DECL: - { - enum XML_Error result = processXmlDecl(parser, 0, s, next); - if (result != XML_ERROR_NONE) - return result; - enc = encoding; - } - break; - case XML_ROLE_DOCTYPE_NAME: - if (startDoctypeDeclHandler) { - doctypeName = poolStoreString(&tempPool, enc, s, next); - if (! doctypeName) - return XML_ERROR_NO_MEMORY; - poolFinish(&tempPool); - doctypeSysid = 0; - doctypePubid = 0; - } - break; - case XML_ROLE_DOCTYPE_INTERNAL_SUBSET: - if (startDoctypeDeclHandler) { - startDoctypeDeclHandler(handlerArg, doctypeName, doctypeSysid, - doctypePubid, 1); - doctypeName = 0; - poolClear(&tempPool); - } - break; -#ifdef XML_DTD - case XML_ROLE_TEXT_DECL: - { - enum XML_Error result = processXmlDecl(parser, 1, s, next); - if (result != XML_ERROR_NONE) - return result; - enc = encoding; - } - break; -#endif /* XML_DTD */ - case XML_ROLE_DOCTYPE_PUBLIC_ID: - if (startDoctypeDeclHandler) { - doctypePubid = poolStoreString(&tempPool, enc, s + 1, next - 1); - if (! doctypePubid) - return XML_ERROR_NO_MEMORY; - poolFinish(&tempPool); - } -#ifdef XML_DTD - declEntity = (ENTITY *)lookup(&dtd.paramEntities, - externalSubsetName, - sizeof(ENTITY)); - if (!declEntity) - return XML_ERROR_NO_MEMORY; -#endif /* XML_DTD */ - /* fall through */ - case XML_ROLE_ENTITY_PUBLIC_ID: - if (!XmlIsPublicId(enc, s, next, eventPP)) - return XML_ERROR_SYNTAX; - if (declEntity) { - XML_Char *tem = poolStoreString(&dtd.pool, - enc, - s + enc->minBytesPerChar, - next - enc->minBytesPerChar); - if (!tem) - return XML_ERROR_NO_MEMORY; - normalizePublicId(tem); - declEntity->publicId = tem; - poolFinish(&dtd.pool); - } - break; - case XML_ROLE_DOCTYPE_CLOSE: - if (doctypeName) { - startDoctypeDeclHandler(handlerArg, doctypeName, - doctypeSysid, doctypePubid, 0); - poolClear(&tempPool); - } - if (dtd.complete && hadExternalDoctype) { - dtd.complete = 0; -#ifdef XML_DTD - if (paramEntityParsing && externalEntityRefHandler) { - ENTITY *entity = (ENTITY *)lookup(&dtd.paramEntities, - externalSubsetName, - 0); - if (!externalEntityRefHandler(externalEntityRefHandlerArg, - 0, - entity->base, - entity->systemId, - entity->publicId)) - return XML_ERROR_EXTERNAL_ENTITY_HANDLING; - } -#endif /* XML_DTD */ - if (!dtd.complete - && !dtd.standalone - && notStandaloneHandler - && !notStandaloneHandler(handlerArg)) - return XML_ERROR_NOT_STANDALONE; - } - if (endDoctypeDeclHandler) - endDoctypeDeclHandler(handlerArg); - break; - case XML_ROLE_INSTANCE_START: - processor = contentProcessor; - return contentProcessor(parser, s, end, nextPtr); - case XML_ROLE_ATTLIST_ELEMENT_NAME: - declElementType = getElementType(parser, enc, s, next); - if (!declElementType) - return XML_ERROR_NO_MEMORY; - break; - case XML_ROLE_ATTRIBUTE_NAME: - declAttributeId = getAttributeId(parser, enc, s, next); - if (!declAttributeId) - return XML_ERROR_NO_MEMORY; - declAttributeIsCdata = 0; - declAttributeType = 0; - declAttributeIsId = 0; - break; - case XML_ROLE_ATTRIBUTE_TYPE_CDATA: - declAttributeIsCdata = 1; - declAttributeType = "CDATA"; - break; - case XML_ROLE_ATTRIBUTE_TYPE_ID: - declAttributeIsId = 1; - declAttributeType = "ID"; - break; - case XML_ROLE_ATTRIBUTE_TYPE_IDREF: - declAttributeType = "IDREF"; - break; - case XML_ROLE_ATTRIBUTE_TYPE_IDREFS: - declAttributeType = "IDREFS"; - break; - case XML_ROLE_ATTRIBUTE_TYPE_ENTITY: - declAttributeType = "ENTITY"; - break; - case XML_ROLE_ATTRIBUTE_TYPE_ENTITIES: - declAttributeType = "ENTITIES"; - break; - case XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN: - declAttributeType = "NMTOKEN"; - break; - case XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS: - declAttributeType = "NMTOKENS"; - break; - - case XML_ROLE_ATTRIBUTE_ENUM_VALUE: - case XML_ROLE_ATTRIBUTE_NOTATION_VALUE: - if (attlistDeclHandler) - { - char *prefix; - if (declAttributeType) { - prefix = "|"; - } - else { - prefix = (role == XML_ROLE_ATTRIBUTE_NOTATION_VALUE - ? "NOTATION(" - : "("); - } - if (! poolAppendString(&tempPool, prefix)) - return XML_ERROR_NO_MEMORY; - if (! poolAppend(&tempPool, enc, s, next)) - return XML_ERROR_NO_MEMORY; - declAttributeType = tempPool.start; - } - break; - case XML_ROLE_IMPLIED_ATTRIBUTE_VALUE: - case XML_ROLE_REQUIRED_ATTRIBUTE_VALUE: - if (dtd.complete - && !defineAttribute(declElementType, declAttributeId, - declAttributeIsCdata, declAttributeIsId, 0, - parser)) - return XML_ERROR_NO_MEMORY; - if (attlistDeclHandler && declAttributeType) { - if (*declAttributeType == '(' - || (*declAttributeType == 'N' && declAttributeType[1] == 'O')) { - /* Enumerated or Notation type */ - if (! poolAppendChar(&tempPool, ')') - || ! poolAppendChar(&tempPool, '\0')) - return XML_ERROR_NO_MEMORY; - declAttributeType = tempPool.start; - poolFinish(&tempPool); - } - *eventEndPP = s; - attlistDeclHandler(handlerArg, declElementType->name, - declAttributeId->name, declAttributeType, - 0, role == XML_ROLE_REQUIRED_ATTRIBUTE_VALUE); - poolClear(&tempPool); - } - break; - case XML_ROLE_DEFAULT_ATTRIBUTE_VALUE: - case XML_ROLE_FIXED_ATTRIBUTE_VALUE: - { - const XML_Char *attVal; - enum XML_Error result - = storeAttributeValue(parser, enc, declAttributeIsCdata, - s + enc->minBytesPerChar, - next - enc->minBytesPerChar, - &dtd.pool); - if (result) - return result; - attVal = poolStart(&dtd.pool); - poolFinish(&dtd.pool); - if (dtd.complete - /* ID attributes aren't allowed to have a default */ - && !defineAttribute(declElementType, declAttributeId, declAttributeIsCdata, 0, attVal, parser)) - return XML_ERROR_NO_MEMORY; - if (attlistDeclHandler && declAttributeType) { - if (*declAttributeType == '(' - || (*declAttributeType == 'N' && declAttributeType[1] == 'O')) { - /* Enumerated or Notation type */ - if (! poolAppendChar(&tempPool, ')') - || ! poolAppendChar(&tempPool, '\0')) - return XML_ERROR_NO_MEMORY; - declAttributeType = tempPool.start; - poolFinish(&tempPool); - } - *eventEndPP = s; - attlistDeclHandler(handlerArg, declElementType->name, - declAttributeId->name, declAttributeType, - attVal, - role == XML_ROLE_FIXED_ATTRIBUTE_VALUE); - poolClear(&tempPool); - } - break; - } - case XML_ROLE_ENTITY_VALUE: - { - enum XML_Error result = storeEntityValue(parser, enc, - s + enc->minBytesPerChar, - next - enc->minBytesPerChar); - if (declEntity) { - declEntity->textPtr = poolStart(&dtd.pool); - declEntity->textLen = poolLength(&dtd.pool); - poolFinish(&dtd.pool); - if (entityDeclHandler) { - *eventEndPP = s; - entityDeclHandler(handlerArg, - declEntity->name, - declEntity->is_param, - declEntity->textPtr, - declEntity->textLen, - curBase, 0, 0, 0); - } - } - else - poolDiscard(&dtd.pool); - if (result != XML_ERROR_NONE) - return result; - } - break; - case XML_ROLE_DOCTYPE_SYSTEM_ID: - if (startDoctypeDeclHandler) { - doctypeSysid = poolStoreString(&tempPool, enc, s + 1, next - 1); - if (! doctypeSysid) - return XML_ERROR_NO_MEMORY; - poolFinish(&tempPool); - } - if (!dtd.standalone -#ifdef XML_DTD - && !paramEntityParsing -#endif /* XML_DTD */ - && notStandaloneHandler - && !notStandaloneHandler(handlerArg)) - return XML_ERROR_NOT_STANDALONE; - hadExternalDoctype = 1; -#ifndef XML_DTD - break; -#else /* XML_DTD */ - if (!declEntity) { - declEntity = (ENTITY *)lookup(&dtd.paramEntities, - externalSubsetName, - sizeof(ENTITY)); - declEntity->publicId = 0; - if (!declEntity) - return XML_ERROR_NO_MEMORY; - } - /* fall through */ -#endif /* XML_DTD */ - case XML_ROLE_ENTITY_SYSTEM_ID: - if (declEntity) { - declEntity->systemId = poolStoreString(&dtd.pool, enc, - s + enc->minBytesPerChar, - next - enc->minBytesPerChar); - if (!declEntity->systemId) - return XML_ERROR_NO_MEMORY; - declEntity->base = curBase; - poolFinish(&dtd.pool); - } - break; - case XML_ROLE_ENTITY_COMPLETE: - if (declEntity && entityDeclHandler) { - *eventEndPP = s; - entityDeclHandler(handlerArg, - declEntity->name, - 0,0,0, - declEntity->base, - declEntity->systemId, - declEntity->publicId, - 0); - } - break; - case XML_ROLE_ENTITY_NOTATION_NAME: - if (declEntity) { - declEntity->notation = poolStoreString(&dtd.pool, enc, s, next); - if (!declEntity->notation) - return XML_ERROR_NO_MEMORY; - poolFinish(&dtd.pool); - if (unparsedEntityDeclHandler) { - *eventEndPP = s; - unparsedEntityDeclHandler(handlerArg, - declEntity->name, - declEntity->base, - declEntity->systemId, - declEntity->publicId, - declEntity->notation); - } - else if (entityDeclHandler) { - *eventEndPP = s; - entityDeclHandler(handlerArg, - declEntity->name, - 0,0,0, - declEntity->base, - declEntity->systemId, - declEntity->publicId, - declEntity->notation); - } - } - break; - case XML_ROLE_GENERAL_ENTITY_NAME: - { - const XML_Char *name; - if (XmlPredefinedEntityName(enc, s, next)) { - declEntity = 0; - break; - } - name = poolStoreString(&dtd.pool, enc, s, next); - if (!name) - return XML_ERROR_NO_MEMORY; - if (dtd.complete) { - declEntity = (ENTITY *)lookup(&dtd.generalEntities, name, sizeof(ENTITY)); - if (!declEntity) - return XML_ERROR_NO_MEMORY; - if (declEntity->name != name) { - poolDiscard(&dtd.pool); - declEntity = 0; - } - else { - poolFinish(&dtd.pool); - declEntity->publicId = 0; - declEntity->is_param = 0; - } - } - else { - poolDiscard(&dtd.pool); - declEntity = 0; - } - } - break; - case XML_ROLE_PARAM_ENTITY_NAME: -#ifdef XML_DTD - if (dtd.complete) { - const XML_Char *name = poolStoreString(&dtd.pool, enc, s, next); - if (!name) - return XML_ERROR_NO_MEMORY; - declEntity = (ENTITY *)lookup(&dtd.paramEntities, - name, sizeof(ENTITY)); - if (!declEntity) - return XML_ERROR_NO_MEMORY; - if (declEntity->name != name) { - poolDiscard(&dtd.pool); - declEntity = 0; - } - else { - poolFinish(&dtd.pool); - declEntity->publicId = 0; - declEntity->is_param = 1; - } - } -#else /* not XML_DTD */ - declEntity = 0; -#endif /* not XML_DTD */ - break; - case XML_ROLE_NOTATION_NAME: - declNotationPublicId = 0; - declNotationName = 0; - if (notationDeclHandler) { - declNotationName = poolStoreString(&tempPool, enc, s, next); - if (!declNotationName) - return XML_ERROR_NO_MEMORY; - poolFinish(&tempPool); - } - break; - case XML_ROLE_NOTATION_PUBLIC_ID: - if (!XmlIsPublicId(enc, s, next, eventPP)) - return XML_ERROR_SYNTAX; - if (declNotationName) { - XML_Char *tem = poolStoreString(&tempPool, - enc, - s + enc->minBytesPerChar, - next - enc->minBytesPerChar); - if (!tem) - return XML_ERROR_NO_MEMORY; - normalizePublicId(tem); - declNotationPublicId = tem; - poolFinish(&tempPool); - } - break; - case XML_ROLE_NOTATION_SYSTEM_ID: - if (declNotationName && notationDeclHandler) { - const XML_Char *systemId - = poolStoreString(&tempPool, enc, - s + enc->minBytesPerChar, - next - enc->minBytesPerChar); - if (!systemId) - return XML_ERROR_NO_MEMORY; - *eventEndPP = s; - notationDeclHandler(handlerArg, - declNotationName, - curBase, - systemId, - declNotationPublicId); - } - poolClear(&tempPool); - break; - case XML_ROLE_NOTATION_NO_SYSTEM_ID: - if (declNotationPublicId && notationDeclHandler) { - *eventEndPP = s; - notationDeclHandler(handlerArg, - declNotationName, - curBase, - 0, - declNotationPublicId); - } - poolClear(&tempPool); - break; - case XML_ROLE_ERROR: - switch (tok) { - case XML_TOK_PARAM_ENTITY_REF: - return XML_ERROR_PARAM_ENTITY_REF; - case XML_TOK_XML_DECL: - return XML_ERROR_MISPLACED_XML_PI; - default: - return XML_ERROR_SYNTAX; - } -#ifdef XML_DTD - case XML_ROLE_IGNORE_SECT: - { - enum XML_Error result; - if (defaultHandler) - reportDefault(parser, enc, s, next); - result = doIgnoreSection(parser, enc, &next, end, nextPtr); - if (!next) { - processor = ignoreSectionProcessor; - return result; - } - } - break; -#endif /* XML_DTD */ - case XML_ROLE_GROUP_OPEN: - if (prologState.level >= groupSize) { - if (groupSize) { - groupConnector = REALLOC(groupConnector, groupSize *= 2); - if (dtd.scaffIndex) - dtd.scaffIndex = REALLOC(dtd.scaffIndex, groupSize * sizeof(int)); - } - else - groupConnector = MALLOC(groupSize = 32); - if (!groupConnector) - return XML_ERROR_NO_MEMORY; - } - groupConnector[prologState.level] = 0; - if (dtd.in_eldecl) { - int myindex = nextScaffoldPart(parser); - if (myindex < 0) - return XML_ERROR_NO_MEMORY; - dtd.scaffIndex[dtd.scaffLevel] = myindex; - dtd.scaffLevel++; - dtd.scaffold[myindex].type = XML_CTYPE_SEQ; - } - break; - case XML_ROLE_GROUP_SEQUENCE: - if (groupConnector[prologState.level] == '|') - return XML_ERROR_SYNTAX; - groupConnector[prologState.level] = ','; - break; - case XML_ROLE_GROUP_CHOICE: - if (groupConnector[prologState.level] == ',') - return XML_ERROR_SYNTAX; - if (dtd.in_eldecl - && ! groupConnector[prologState.level] - && dtd.scaffold[dtd.scaffIndex[dtd.scaffLevel - 1]].type != XML_CTYPE_MIXED - ) { - dtd.scaffold[dtd.scaffIndex[dtd.scaffLevel - 1]].type = XML_CTYPE_CHOICE; - } - groupConnector[prologState.level] = '|'; - break; - case XML_ROLE_PARAM_ENTITY_REF: -#ifdef XML_DTD - case XML_ROLE_INNER_PARAM_ENTITY_REF: - if (paramEntityParsing - && (dtd.complete || role == XML_ROLE_INNER_PARAM_ENTITY_REF)) { - const XML_Char *name; - ENTITY *entity; - name = poolStoreString(&dtd.pool, enc, - s + enc->minBytesPerChar, - next - enc->minBytesPerChar); - if (!name) - return XML_ERROR_NO_MEMORY; - entity = (ENTITY *)lookup(&dtd.paramEntities, name, 0); - poolDiscard(&dtd.pool); - if (!entity) { - /* FIXME what to do if !dtd.complete? */ - return XML_ERROR_UNDEFINED_ENTITY; - } - if (entity->open) - return XML_ERROR_RECURSIVE_ENTITY_REF; - if (entity->textPtr) { - enum XML_Error result; - result = processInternalParamEntity(parser, entity); - if (result != XML_ERROR_NONE) - return result; - break; - } - if (role == XML_ROLE_INNER_PARAM_ENTITY_REF) - return XML_ERROR_PARAM_ENTITY_REF; - if (externalEntityRefHandler) { - dtd.complete = 0; - entity->open = 1; - if (!externalEntityRefHandler(externalEntityRefHandlerArg, - 0, - entity->base, - entity->systemId, - entity->publicId)) { - entity->open = 0; - return XML_ERROR_EXTERNAL_ENTITY_HANDLING; - } - entity->open = 0; - if (dtd.complete) - break; - } - } -#endif /* XML_DTD */ - if (!dtd.standalone - && notStandaloneHandler - && !notStandaloneHandler(handlerArg)) - return XML_ERROR_NOT_STANDALONE; - dtd.complete = 0; - if (defaultHandler) - reportDefault(parser, enc, s, next); - break; - - /* Element declaration stuff */ - - case XML_ROLE_ELEMENT_NAME: - if (elementDeclHandler) { - declElementType = getElementType(parser, enc, s, next); - if (! declElementType) - return XML_ERROR_NO_MEMORY; - dtd.scaffLevel = 0; - dtd.scaffCount = 0; - dtd.in_eldecl = 1; - } - break; - - case XML_ROLE_CONTENT_ANY: - case XML_ROLE_CONTENT_EMPTY: - if (dtd.in_eldecl) { - if (elementDeclHandler) { - XML_Content * content = (XML_Content *) MALLOC(sizeof(XML_Content)); - if (! content) - return XML_ERROR_NO_MEMORY; - content->quant = XML_CQUANT_NONE; - content->name = 0; - content->numchildren = 0; - content->children = 0; - content->type = ((role == XML_ROLE_CONTENT_ANY) ? - XML_CTYPE_ANY : - XML_CTYPE_EMPTY); - *eventEndPP = s; - elementDeclHandler(handlerArg, declElementType->name, content); - } - dtd.in_eldecl = 0; - } - break; - - case XML_ROLE_CONTENT_PCDATA: - if (dtd.in_eldecl) { - dtd.scaffold[dtd.scaffIndex[dtd.scaffLevel - 1]].type = XML_CTYPE_MIXED; - } - break; - - case XML_ROLE_CONTENT_ELEMENT: - quant = XML_CQUANT_NONE; - goto elementContent; - case XML_ROLE_CONTENT_ELEMENT_OPT: - quant = XML_CQUANT_OPT; - goto elementContent; - case XML_ROLE_CONTENT_ELEMENT_REP: - quant = XML_CQUANT_REP; - goto elementContent; - case XML_ROLE_CONTENT_ELEMENT_PLUS: - quant = XML_CQUANT_PLUS; - elementContent: - if (dtd.in_eldecl) - { - ELEMENT_TYPE *el; - const char *nxt = quant == XML_CQUANT_NONE ? next : next - 1; - int myindex = nextScaffoldPart(parser); - if (myindex < 0) - return XML_ERROR_NO_MEMORY; - dtd.scaffold[myindex].type = XML_CTYPE_NAME; - dtd.scaffold[myindex].quant = quant; - el = getElementType(parser, enc, s, nxt); - if (! el) - return XML_ERROR_NO_MEMORY; - dtd.scaffold[myindex].name = el->name; - dtd.contentStringLen += nxt - s + 1; - } - break; - - case XML_ROLE_GROUP_CLOSE: - quant = XML_CQUANT_NONE; - goto closeGroup; - case XML_ROLE_GROUP_CLOSE_OPT: - quant = XML_CQUANT_OPT; - goto closeGroup; - case XML_ROLE_GROUP_CLOSE_REP: - quant = XML_CQUANT_REP; - goto closeGroup; - case XML_ROLE_GROUP_CLOSE_PLUS: - quant = XML_CQUANT_PLUS; - closeGroup: - if (dtd.in_eldecl) { - dtd.scaffLevel--; - dtd.scaffold[dtd.scaffIndex[dtd.scaffLevel]].quant = quant; - if (dtd.scaffLevel == 0) { - if (elementDeclHandler) { - XML_Content *model = build_model(parser); - if (! model) - return XML_ERROR_NO_MEMORY; - *eventEndPP = s; - elementDeclHandler(handlerArg, declElementType->name, model); - } - dtd.in_eldecl = 0; - dtd.contentStringLen = 0; - } - } - break; - /* End element declaration stuff */ - - case XML_ROLE_NONE: - switch (tok) { - case XML_TOK_PI: - if (!reportProcessingInstruction(parser, enc, s, next)) - return XML_ERROR_NO_MEMORY; - break; - case XML_TOK_COMMENT: - if (!reportComment(parser, enc, s, next)) - return XML_ERROR_NO_MEMORY; - break; - } - break; - } - if (defaultHandler) { - switch (tok) { - case XML_TOK_PI: - case XML_TOK_COMMENT: - case XML_TOK_BOM: - case XML_TOK_XML_DECL: -#ifdef XML_DTD - case XML_TOK_IGNORE_SECT: -#endif /* XML_DTD */ - case XML_TOK_PARAM_ENTITY_REF: - break; - default: -#ifdef XML_DTD - if (role != XML_ROLE_IGNORE_SECT) -#endif /* XML_DTD */ - reportDefault(parser, enc, s, next); - } - } - s = next; - tok = XmlPrologTok(enc, s, end, &next); - } - /* not reached */ -} - -static -enum XML_Error epilogProcessor(XML_Parser parser, - const char *s, - const char *end, - const char **nextPtr) -{ - processor = epilogProcessor; - eventPtr = s; - for (;;) { - const char *next; - int tok = XmlPrologTok(encoding, s, end, &next); - eventEndPtr = next; - switch (tok) { - case -XML_TOK_PROLOG_S: - if (defaultHandler) { - eventEndPtr = end; - reportDefault(parser, encoding, s, end); - } - /* fall through */ - case XML_TOK_NONE: - if (nextPtr) - *nextPtr = end; - return XML_ERROR_NONE; - case XML_TOK_PROLOG_S: - if (defaultHandler) - reportDefault(parser, encoding, s, next); - break; - case XML_TOK_PI: - if (!reportProcessingInstruction(parser, encoding, s, next)) - return XML_ERROR_NO_MEMORY; - break; - case XML_TOK_COMMENT: - if (!reportComment(parser, encoding, s, next)) - return XML_ERROR_NO_MEMORY; - break; - case XML_TOK_INVALID: - eventPtr = next; - return XML_ERROR_INVALID_TOKEN; - case XML_TOK_PARTIAL: - if (nextPtr) { - *nextPtr = s; - return XML_ERROR_NONE; - } - return XML_ERROR_UNCLOSED_TOKEN; - case XML_TOK_PARTIAL_CHAR: - if (nextPtr) { - *nextPtr = s; - return XML_ERROR_NONE; - } - return XML_ERROR_PARTIAL_CHAR; - default: - return XML_ERROR_JUNK_AFTER_DOC_ELEMENT; - } - eventPtr = s = next; - } -} - -#ifdef XML_DTD - -static enum XML_Error -processInternalParamEntity(XML_Parser parser, ENTITY *entity) -{ - const char *s, *end, *next; - int tok; - enum XML_Error result; - OPEN_INTERNAL_ENTITY openEntity; - entity->open = 1; - openEntity.next = openInternalEntities; - openInternalEntities = &openEntity; - openEntity.entity = entity; - openEntity.internalEventPtr = 0; - openEntity.internalEventEndPtr = 0; - s = (char *)entity->textPtr; - end = (char *)(entity->textPtr + entity->textLen); - tok = XmlPrologTok(internalEncoding, s, end, &next); - result = doProlog(parser, internalEncoding, s, end, tok, next, 0); - entity->open = 0; - openInternalEntities = openEntity.next; - return result; -} - -#endif /* XML_DTD */ - -static -enum XML_Error errorProcessor(XML_Parser parser, - const char *s, - const char *end, - const char **nextPtr) -{ - return errorCode; -} - -static enum XML_Error -storeAttributeValue(XML_Parser parser, const ENCODING *enc, int isCdata, - const char *ptr, const char *end, - STRING_POOL *pool) -{ - enum XML_Error result = appendAttributeValue(parser, enc, isCdata, ptr, end, pool); - if (result) - return result; - if (!isCdata && poolLength(pool) && poolLastChar(pool) == 0x20) - poolChop(pool); - if (!poolAppendChar(pool, XML_T('\0'))) - return XML_ERROR_NO_MEMORY; - return XML_ERROR_NONE; -} - -static enum XML_Error -appendAttributeValue(XML_Parser parser, const ENCODING *enc, int isCdata, - const char *ptr, const char *end, - STRING_POOL *pool) -{ - for (;;) { - const char *next; - int tok = XmlAttributeValueTok(enc, ptr, end, &next); - switch (tok) { - case XML_TOK_NONE: - return XML_ERROR_NONE; - case XML_TOK_INVALID: - if (enc == encoding) - eventPtr = next; - return XML_ERROR_INVALID_TOKEN; - case XML_TOK_PARTIAL: - if (enc == encoding) - eventPtr = ptr; - return XML_ERROR_INVALID_TOKEN; - case XML_TOK_CHAR_REF: - { - XML_Char buf[XML_ENCODE_MAX]; - int i; - int n = XmlCharRefNumber(enc, ptr); - if (n < 0) { - if (enc == encoding) - eventPtr = ptr; - return XML_ERROR_BAD_CHAR_REF; - } - if (!isCdata - && n == 0x20 /* space */ - && (poolLength(pool) == 0 || poolLastChar(pool) == 0x20)) - break; - n = XmlEncode(n, (ICHAR *)buf); - if (!n) { - if (enc == encoding) - eventPtr = ptr; - return XML_ERROR_BAD_CHAR_REF; - } - for (i = 0; i < n; i++) { - if (!poolAppendChar(pool, buf[i])) - return XML_ERROR_NO_MEMORY; - } - } - break; - case XML_TOK_DATA_CHARS: - if (!poolAppend(pool, enc, ptr, next)) - return XML_ERROR_NO_MEMORY; - break; - break; - case XML_TOK_TRAILING_CR: - next = ptr + enc->minBytesPerChar; - /* fall through */ - case XML_TOK_ATTRIBUTE_VALUE_S: - case XML_TOK_DATA_NEWLINE: - if (!isCdata && (poolLength(pool) == 0 || poolLastChar(pool) == 0x20)) - break; - if (!poolAppendChar(pool, 0x20)) - return XML_ERROR_NO_MEMORY; - break; - case XML_TOK_ENTITY_REF: - { - const XML_Char *name; - ENTITY *entity; - XML_Char ch = XmlPredefinedEntityName(enc, - ptr + enc->minBytesPerChar, - next - enc->minBytesPerChar); - if (ch) { - if (!poolAppendChar(pool, ch)) - return XML_ERROR_NO_MEMORY; - break; - } - name = poolStoreString(&temp2Pool, enc, - ptr + enc->minBytesPerChar, - next - enc->minBytesPerChar); - if (!name) - return XML_ERROR_NO_MEMORY; - entity = (ENTITY *)lookup(&dtd.generalEntities, name, 0); - poolDiscard(&temp2Pool); - if (!entity) { - if (dtd.complete) { - if (enc == encoding) - eventPtr = ptr; - return XML_ERROR_UNDEFINED_ENTITY; - } - } - else if (entity->open) { - if (enc == encoding) - eventPtr = ptr; - return XML_ERROR_RECURSIVE_ENTITY_REF; - } - else if (entity->notation) { - if (enc == encoding) - eventPtr = ptr; - return XML_ERROR_BINARY_ENTITY_REF; - } - else if (!entity->textPtr) { - if (enc == encoding) - eventPtr = ptr; - return XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF; - } - else { - enum XML_Error result; - const XML_Char *textEnd = entity->textPtr + entity->textLen; - entity->open = 1; - result = appendAttributeValue(parser, internalEncoding, isCdata, (char *)entity->textPtr, (char *)textEnd, pool); - entity->open = 0; - if (result) - return result; - } - } - break; - default: - if (enc == encoding) - eventPtr = ptr; - return XML_ERROR_UNEXPECTED_STATE; - } - ptr = next; - } - /* not reached */ -} - -static -enum XML_Error storeEntityValue(XML_Parser parser, - const ENCODING *enc, - const char *entityTextPtr, - const char *entityTextEnd) -{ - STRING_POOL *pool = &(dtd.pool); - for (;;) { - const char *next; - int tok = XmlEntityValueTok(enc, entityTextPtr, entityTextEnd, &next); - switch (tok) { - case XML_TOK_PARAM_ENTITY_REF: -#ifdef XML_DTD - if (parentParser || enc != encoding) { - enum XML_Error result; - const XML_Char *name; - ENTITY *entity; - name = poolStoreString(&tempPool, enc, - entityTextPtr + enc->minBytesPerChar, - next - enc->minBytesPerChar); - if (!name) - return XML_ERROR_NO_MEMORY; - entity = (ENTITY *)lookup(&dtd.paramEntities, name, 0); - poolDiscard(&tempPool); - if (!entity) { - if (enc == encoding) - eventPtr = entityTextPtr; - return XML_ERROR_UNDEFINED_ENTITY; - } - if (entity->open) { - if (enc == encoding) - eventPtr = entityTextPtr; - return XML_ERROR_RECURSIVE_ENTITY_REF; - } - if (entity->systemId) { - if (enc == encoding) - eventPtr = entityTextPtr; - return XML_ERROR_PARAM_ENTITY_REF; - } - entity->open = 1; - result = storeEntityValue(parser, - internalEncoding, - (char *)entity->textPtr, - (char *)(entity->textPtr + entity->textLen)); - entity->open = 0; - if (result) - return result; - break; - } -#endif /* XML_DTD */ - eventPtr = entityTextPtr; - return XML_ERROR_SYNTAX; - case XML_TOK_NONE: - return XML_ERROR_NONE; - case XML_TOK_ENTITY_REF: - case XML_TOK_DATA_CHARS: - if (!poolAppend(pool, enc, entityTextPtr, next)) - return XML_ERROR_NO_MEMORY; - break; - case XML_TOK_TRAILING_CR: - next = entityTextPtr + enc->minBytesPerChar; - /* fall through */ - case XML_TOK_DATA_NEWLINE: - if (pool->end == pool->ptr && !poolGrow(pool)) - return XML_ERROR_NO_MEMORY; - *(pool->ptr)++ = 0xA; - break; - case XML_TOK_CHAR_REF: - { - XML_Char buf[XML_ENCODE_MAX]; - int i; - int n = XmlCharRefNumber(enc, entityTextPtr); - if (n < 0) { - if (enc == encoding) - eventPtr = entityTextPtr; - return XML_ERROR_BAD_CHAR_REF; - } - n = XmlEncode(n, (ICHAR *)buf); - if (!n) { - if (enc == encoding) - eventPtr = entityTextPtr; - return XML_ERROR_BAD_CHAR_REF; - } - for (i = 0; i < n; i++) { - if (pool->end == pool->ptr && !poolGrow(pool)) - return XML_ERROR_NO_MEMORY; - *(pool->ptr)++ = buf[i]; - } - } - break; - case XML_TOK_PARTIAL: - if (enc == encoding) - eventPtr = entityTextPtr; - return XML_ERROR_INVALID_TOKEN; - case XML_TOK_INVALID: - if (enc == encoding) - eventPtr = next; - return XML_ERROR_INVALID_TOKEN; - default: - if (enc == encoding) - eventPtr = entityTextPtr; - return XML_ERROR_UNEXPECTED_STATE; - } - entityTextPtr = next; - } - /* not reached */ -} - -static void -normalizeLines(XML_Char *s) -{ - XML_Char *p; - for (;; s++) { - if (*s == XML_T('\0')) - return; - if (*s == 0xD) - break; - } - p = s; - do { - if (*s == 0xD) { - *p++ = 0xA; - if (*++s == 0xA) - s++; - } - else - *p++ = *s++; - } while (*s); - *p = XML_T('\0'); -} - -static int -reportProcessingInstruction(XML_Parser parser, const ENCODING *enc, const char *start, const char *end) -{ - const XML_Char *target; - XML_Char *data; - const char *tem; - if (!processingInstructionHandler) { - if (defaultHandler) - reportDefault(parser, enc, start, end); - return 1; - } - start += enc->minBytesPerChar * 2; - tem = start + XmlNameLength(enc, start); - target = poolStoreString(&tempPool, enc, start, tem); - if (!target) - return 0; - poolFinish(&tempPool); - data = poolStoreString(&tempPool, enc, - XmlSkipS(enc, tem), - end - enc->minBytesPerChar*2); - if (!data) - return 0; - normalizeLines(data); - processingInstructionHandler(handlerArg, target, data); - poolClear(&tempPool); - return 1; -} - -static int -reportComment(XML_Parser parser, const ENCODING *enc, const char *start, const char *end) -{ - XML_Char *data; - if (!commentHandler) { - if (defaultHandler) - reportDefault(parser, enc, start, end); - return 1; - } - data = poolStoreString(&tempPool, - enc, - start + enc->minBytesPerChar * 4, - end - enc->minBytesPerChar * 3); - if (!data) - return 0; - normalizeLines(data); - commentHandler(handlerArg, data); - poolClear(&tempPool); - return 1; -} - -static void -reportDefault(XML_Parser parser, const ENCODING *enc, const char *s, const char *end) -{ - if (MUST_CONVERT(enc, s)) { - const char **eventPP; - const char **eventEndPP; - if (enc == encoding) { - eventPP = &eventPtr; - eventEndPP = &eventEndPtr; - } - else { - eventPP = &(openInternalEntities->internalEventPtr); - eventEndPP = &(openInternalEntities->internalEventEndPtr); - } - do { - ICHAR *dataPtr = (ICHAR *)dataBuf; - XmlConvert(enc, &s, end, &dataPtr, (ICHAR *)dataBufEnd); - *eventEndPP = s; - defaultHandler(handlerArg, dataBuf, dataPtr - (ICHAR *)dataBuf); - *eventPP = s; - } while (s != end); - } - else - defaultHandler(handlerArg, (XML_Char *)s, (XML_Char *)end - (XML_Char *)s); -} - - -static int -defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *attId, int isCdata, - int isId, const XML_Char *value, XML_Parser parser) -{ - DEFAULT_ATTRIBUTE *att; - if (value || isId) { - /* The handling of default attributes gets messed up if we have - a default which duplicates a non-default. */ - int i; - for (i = 0; i < type->nDefaultAtts; i++) - if (attId == type->defaultAtts[i].id) - return 1; - if (isId && !type->idAtt && !attId->xmlns) - type->idAtt = attId; - } - if (type->nDefaultAtts == type->allocDefaultAtts) { - if (type->allocDefaultAtts == 0) { - type->allocDefaultAtts = 8; - type->defaultAtts = MALLOC(type->allocDefaultAtts*sizeof(DEFAULT_ATTRIBUTE)); - } - else { - type->allocDefaultAtts *= 2; - type->defaultAtts = REALLOC(type->defaultAtts, - type->allocDefaultAtts*sizeof(DEFAULT_ATTRIBUTE)); - } - if (!type->defaultAtts) - return 0; - } - att = type->defaultAtts + type->nDefaultAtts; - att->id = attId; - att->value = value; - att->isCdata = isCdata; - if (!isCdata) - attId->maybeTokenized = 1; - type->nDefaultAtts += 1; - return 1; -} - -static int setElementTypePrefix(XML_Parser parser, ELEMENT_TYPE *elementType) -{ - const XML_Char *name; - for (name = elementType->name; *name; name++) { - if (*name == XML_T(':')) { - PREFIX *prefix; - const XML_Char *s; - for (s = elementType->name; s != name; s++) { - if (!poolAppendChar(&dtd.pool, *s)) - return 0; - } - if (!poolAppendChar(&dtd.pool, XML_T('\0'))) - return 0; - prefix = (PREFIX *)lookup(&dtd.prefixes, poolStart(&dtd.pool), sizeof(PREFIX)); - if (!prefix) - return 0; - if (prefix->name == poolStart(&dtd.pool)) - poolFinish(&dtd.pool); - else - poolDiscard(&dtd.pool); - elementType->prefix = prefix; - - } - } - return 1; -} - -static ATTRIBUTE_ID * -getAttributeId(XML_Parser parser, const ENCODING *enc, const char *start, const char *end) -{ - ATTRIBUTE_ID *id; - const XML_Char *name; - if (!poolAppendChar(&dtd.pool, XML_T('\0'))) - return 0; - name = poolStoreString(&dtd.pool, enc, start, end); - if (!name) - return 0; - ++name; - id = (ATTRIBUTE_ID *)lookup(&dtd.attributeIds, name, sizeof(ATTRIBUTE_ID)); - if (!id) - return 0; - if (id->name != name) - poolDiscard(&dtd.pool); - else { - poolFinish(&dtd.pool); - if (!ns) - ; - else if (name[0] == 'x' - && name[1] == 'm' - && name[2] == 'l' - && name[3] == 'n' - && name[4] == 's' - && (name[5] == XML_T('\0') || name[5] == XML_T(':'))) { - if (name[5] == '\0') - id->prefix = &dtd.defaultPrefix; - else - id->prefix = (PREFIX *)lookup(&dtd.prefixes, name + 6, sizeof(PREFIX)); - id->xmlns = 1; - } - else { - int i; - for (i = 0; name[i]; i++) { - if (name[i] == XML_T(':')) { - int j; - for (j = 0; j < i; j++) { - if (!poolAppendChar(&dtd.pool, name[j])) - return 0; - } - if (!poolAppendChar(&dtd.pool, XML_T('\0'))) - return 0; - id->prefix = (PREFIX *)lookup(&dtd.prefixes, poolStart(&dtd.pool), sizeof(PREFIX)); - if (id->prefix->name == poolStart(&dtd.pool)) - poolFinish(&dtd.pool); - else - poolDiscard(&dtd.pool); - break; - } - } - } - } - return id; -} - -#define CONTEXT_SEP XML_T('\f') - -static -const XML_Char *getContext(XML_Parser parser) -{ - HASH_TABLE_ITER iter; - int needSep = 0; - - if (dtd.defaultPrefix.binding) { - int i; - int len; - if (!poolAppendChar(&tempPool, XML_T('='))) - return 0; - len = dtd.defaultPrefix.binding->uriLen; - if (namespaceSeparator != XML_T('\0')) - len--; - for (i = 0; i < len; i++) - if (!poolAppendChar(&tempPool, dtd.defaultPrefix.binding->uri[i])) - return 0; - needSep = 1; - } - - hashTableIterInit(&iter, &(dtd.prefixes)); - for (;;) { - int i; - int len; - const XML_Char *s; - PREFIX *prefix = (PREFIX *)hashTableIterNext(&iter); - if (!prefix) - break; - if (!prefix->binding) - continue; - if (needSep && !poolAppendChar(&tempPool, CONTEXT_SEP)) - return 0; - for (s = prefix->name; *s; s++) - if (!poolAppendChar(&tempPool, *s)) - return 0; - if (!poolAppendChar(&tempPool, XML_T('='))) - return 0; - len = prefix->binding->uriLen; - if (namespaceSeparator != XML_T('\0')) - len--; - for (i = 0; i < len; i++) - if (!poolAppendChar(&tempPool, prefix->binding->uri[i])) - return 0; - needSep = 1; - } - - - hashTableIterInit(&iter, &(dtd.generalEntities)); - for (;;) { - const XML_Char *s; - ENTITY *e = (ENTITY *)hashTableIterNext(&iter); - if (!e) - break; - if (!e->open) - continue; - if (needSep && !poolAppendChar(&tempPool, CONTEXT_SEP)) - return 0; - for (s = e->name; *s; s++) - if (!poolAppendChar(&tempPool, *s)) - return 0; - needSep = 1; - } - - if (!poolAppendChar(&tempPool, XML_T('\0'))) - return 0; - return tempPool.start; -} - -static -int setContext(XML_Parser parser, const XML_Char *context) -{ - const XML_Char *s = context; - - while (*context != XML_T('\0')) { - if (*s == CONTEXT_SEP || *s == XML_T('\0')) { - ENTITY *e; - if (!poolAppendChar(&tempPool, XML_T('\0'))) - return 0; - e = (ENTITY *)lookup(&dtd.generalEntities, poolStart(&tempPool), 0); - if (e) - e->open = 1; - if (*s != XML_T('\0')) - s++; - context = s; - poolDiscard(&tempPool); - } - else if (*s == '=') { - PREFIX *prefix; - if (poolLength(&tempPool) == 0) - prefix = &dtd.defaultPrefix; - else { - if (!poolAppendChar(&tempPool, XML_T('\0'))) - return 0; - prefix = (PREFIX *)lookup(&dtd.prefixes, poolStart(&tempPool), sizeof(PREFIX)); - if (!prefix) - return 0; - if (prefix->name == poolStart(&tempPool)) { - prefix->name = poolCopyString(&dtd.pool, prefix->name); - if (!prefix->name) - return 0; - } - poolDiscard(&tempPool); - } - for (context = s + 1; *context != CONTEXT_SEP && *context != XML_T('\0'); context++) - if (!poolAppendChar(&tempPool, *context)) - return 0; - if (!poolAppendChar(&tempPool, XML_T('\0'))) - return 0; - if (!addBinding(parser, prefix, 0, poolStart(&tempPool), &inheritedBindings)) - return 0; - poolDiscard(&tempPool); - if (*context != XML_T('\0')) - ++context; - s = context; - } - else { - if (!poolAppendChar(&tempPool, *s)) - return 0; - s++; - } - } - return 1; -} - - -static -void normalizePublicId(XML_Char *publicId) -{ - XML_Char *p = publicId; - XML_Char *s; - for (s = publicId; *s; s++) { - switch (*s) { - case 0x20: - case 0xD: - case 0xA: - if (p != publicId && p[-1] != 0x20) - *p++ = 0x20; - break; - default: - *p++ = *s; - } - } - if (p != publicId && p[-1] == 0x20) - --p; - *p = XML_T('\0'); -} - -static int dtdInit(DTD *p, XML_Parser parser) -{ - XML_Memory_Handling_Suite *ms = &((Parser *) parser)->m_mem; - poolInit(&(p->pool), ms); - hashTableInit(&(p->generalEntities), ms); - hashTableInit(&(p->elementTypes), ms); - hashTableInit(&(p->attributeIds), ms); - hashTableInit(&(p->prefixes), ms); - p->complete = 1; - p->standalone = 0; -#ifdef XML_DTD - hashTableInit(&(p->paramEntities), ms); -#endif /* XML_DTD */ - p->defaultPrefix.name = 0; - p->defaultPrefix.binding = 0; - - p->in_eldecl = 0; - p->scaffIndex = 0; - p->scaffLevel = 0; - p->scaffold = 0; - p->contentStringLen = 0; - p->scaffSize = 0; - p->scaffCount = 0; - - return 1; -} - -#ifdef XML_DTD - -static void dtdSwap(DTD *p1, DTD *p2) -{ - DTD tem; - memcpy(&tem, p1, sizeof(DTD)); - memcpy(p1, p2, sizeof(DTD)); - memcpy(p2, &tem, sizeof(DTD)); -} - -#endif /* XML_DTD */ - -static void dtdDestroy(DTD *p, XML_Parser parser) -{ - HASH_TABLE_ITER iter; - hashTableIterInit(&iter, &(p->elementTypes)); - for (;;) { - ELEMENT_TYPE *e = (ELEMENT_TYPE *)hashTableIterNext(&iter); - if (!e) - break; - if (e->allocDefaultAtts != 0) - FREE(e->defaultAtts); - } - hashTableDestroy(&(p->generalEntities)); -#ifdef XML_DTD - hashTableDestroy(&(p->paramEntities)); -#endif /* XML_DTD */ - hashTableDestroy(&(p->elementTypes)); - hashTableDestroy(&(p->attributeIds)); - hashTableDestroy(&(p->prefixes)); - poolDestroy(&(p->pool)); - if (p->scaffIndex) - FREE(p->scaffIndex); - if (p->scaffold) - FREE(p->scaffold); -} - -/* Do a deep copy of the DTD. Return 0 for out of memory; non-zero otherwise. -The new DTD has already been initialized. */ - -static int dtdCopy(DTD *newDtd, const DTD *oldDtd, XML_Parser parser) -{ - HASH_TABLE_ITER iter; - - /* Copy the prefix table. */ - - hashTableIterInit(&iter, &(oldDtd->prefixes)); - for (;;) { - const XML_Char *name; - const PREFIX *oldP = (PREFIX *)hashTableIterNext(&iter); - if (!oldP) - break; - name = poolCopyString(&(newDtd->pool), oldP->name); - if (!name) - return 0; - if (!lookup(&(newDtd->prefixes), name, sizeof(PREFIX))) - return 0; - } - - hashTableIterInit(&iter, &(oldDtd->attributeIds)); - - /* Copy the attribute id table. */ - - for (;;) { - ATTRIBUTE_ID *newA; - const XML_Char *name; - const ATTRIBUTE_ID *oldA = (ATTRIBUTE_ID *)hashTableIterNext(&iter); - - if (!oldA) - break; - /* Remember to allocate the scratch byte before the name. */ - if (!poolAppendChar(&(newDtd->pool), XML_T('\0'))) - return 0; - name = poolCopyString(&(newDtd->pool), oldA->name); - if (!name) - return 0; - ++name; - newA = (ATTRIBUTE_ID *)lookup(&(newDtd->attributeIds), name, sizeof(ATTRIBUTE_ID)); - if (!newA) - return 0; - newA->maybeTokenized = oldA->maybeTokenized; - if (oldA->prefix) { - newA->xmlns = oldA->xmlns; - if (oldA->prefix == &oldDtd->defaultPrefix) - newA->prefix = &newDtd->defaultPrefix; - else - newA->prefix = (PREFIX *)lookup(&(newDtd->prefixes), oldA->prefix->name, 0); - } - } - - /* Copy the element type table. */ - - hashTableIterInit(&iter, &(oldDtd->elementTypes)); - - for (;;) { - int i; - ELEMENT_TYPE *newE; - const XML_Char *name; - const ELEMENT_TYPE *oldE = (ELEMENT_TYPE *)hashTableIterNext(&iter); - if (!oldE) - break; - name = poolCopyString(&(newDtd->pool), oldE->name); - if (!name) - return 0; - newE = (ELEMENT_TYPE *)lookup(&(newDtd->elementTypes), name, sizeof(ELEMENT_TYPE)); - if (!newE) - return 0; - if (oldE->nDefaultAtts) { - newE->defaultAtts = (DEFAULT_ATTRIBUTE *)MALLOC(oldE->nDefaultAtts * sizeof(DEFAULT_ATTRIBUTE)); - if (!newE->defaultAtts) - return 0; - } - if (oldE->idAtt) - newE->idAtt = (ATTRIBUTE_ID *)lookup(&(newDtd->attributeIds), oldE->idAtt->name, 0); - newE->allocDefaultAtts = newE->nDefaultAtts = oldE->nDefaultAtts; - if (oldE->prefix) - newE->prefix = (PREFIX *)lookup(&(newDtd->prefixes), oldE->prefix->name, 0); - for (i = 0; i < newE->nDefaultAtts; i++) { - newE->defaultAtts[i].id = (ATTRIBUTE_ID *)lookup(&(newDtd->attributeIds), oldE->defaultAtts[i].id->name, 0); - newE->defaultAtts[i].isCdata = oldE->defaultAtts[i].isCdata; - if (oldE->defaultAtts[i].value) { - newE->defaultAtts[i].value = poolCopyString(&(newDtd->pool), oldE->defaultAtts[i].value); - if (!newE->defaultAtts[i].value) - return 0; - } - else - newE->defaultAtts[i].value = 0; - } - } - - /* Copy the entity tables. */ - if (!copyEntityTable(&(newDtd->generalEntities), - &(newDtd->pool), - &(oldDtd->generalEntities), parser)) - return 0; - -#ifdef XML_DTD - if (!copyEntityTable(&(newDtd->paramEntities), - &(newDtd->pool), - &(oldDtd->paramEntities), parser)) - return 0; -#endif /* XML_DTD */ - - newDtd->complete = oldDtd->complete; - newDtd->standalone = oldDtd->standalone; - - /* Don't want deep copying for scaffolding */ - newDtd->in_eldecl = oldDtd->in_eldecl; - newDtd->scaffold = oldDtd->scaffold; - newDtd->contentStringLen = oldDtd->contentStringLen; - newDtd->scaffSize = oldDtd->scaffSize; - newDtd->scaffLevel = oldDtd->scaffLevel; - newDtd->scaffIndex = oldDtd->scaffIndex; - - return 1; -} /* End dtdCopy */ - -static int copyEntityTable(HASH_TABLE *newTable, - STRING_POOL *newPool, - const HASH_TABLE *oldTable, - XML_Parser parser) -{ - HASH_TABLE_ITER iter; - const XML_Char *cachedOldBase = 0; - const XML_Char *cachedNewBase = 0; - - hashTableIterInit(&iter, oldTable); - - for (;;) { - ENTITY *newE; - const XML_Char *name; - const ENTITY *oldE = (ENTITY *)hashTableIterNext(&iter); - if (!oldE) - break; - name = poolCopyString(newPool, oldE->name); - if (!name) - return 0; - newE = (ENTITY *)lookup(newTable, name, sizeof(ENTITY)); - if (!newE) - return 0; - if (oldE->systemId) { - const XML_Char *tem = poolCopyString(newPool, oldE->systemId); - if (!tem) - return 0; - newE->systemId = tem; - if (oldE->base) { - if (oldE->base == cachedOldBase) - newE->base = cachedNewBase; - else { - cachedOldBase = oldE->base; - tem = poolCopyString(newPool, cachedOldBase); - if (!tem) - return 0; - cachedNewBase = newE->base = tem; - } - } - } - else { - const XML_Char *tem = poolCopyStringN(newPool, oldE->textPtr, oldE->textLen); - if (!tem) - return 0; - newE->textPtr = tem; - newE->textLen = oldE->textLen; - } - if (oldE->notation) { - const XML_Char *tem = poolCopyString(newPool, oldE->notation); - if (!tem) - return 0; - newE->notation = tem; - } - } - return 1; -} - -#define INIT_SIZE 64 - -static -int keyeq(KEY s1, KEY s2) -{ - for (; *s1 == *s2; s1++, s2++) - if (*s1 == 0) - return 1; - return 0; -} - -static -unsigned long hash(KEY s) -{ - unsigned long h = 0; - while (*s) - h = (h << 5) + h + (unsigned char)*s++; - return h; -} - -static -NAMED *lookup(HASH_TABLE *table, KEY name, size_t createSize) -{ - size_t i; - if (table->size == 0) { - size_t tsize; - - if (!createSize) - return 0; - tsize = INIT_SIZE * sizeof(NAMED *); - table->v = table->mem->malloc_fcn(tsize); - if (!table->v) - return 0; - memset(table->v, 0, tsize); - table->size = INIT_SIZE; - table->usedLim = INIT_SIZE / 2; - i = hash(name) & (table->size - 1); - } - else { - unsigned long h = hash(name); - for (i = h & (table->size - 1); - table->v[i]; - i == 0 ? i = table->size - 1 : --i) { - if (keyeq(name, table->v[i]->name)) - return table->v[i]; - } - if (!createSize) - return 0; - if (table->used == table->usedLim) { - /* check for overflow */ - size_t newSize = table->size * 2; - size_t tsize = newSize * sizeof(NAMED *); - NAMED **newV = table->mem->malloc_fcn(tsize); - if (!newV) - return 0; - memset(newV, 0, tsize); - for (i = 0; i < table->size; i++) - if (table->v[i]) { - size_t j; - for (j = hash(table->v[i]->name) & (newSize - 1); - newV[j]; - j == 0 ? j = newSize - 1 : --j) - ; - newV[j] = table->v[i]; - } - table->mem->free_fcn(table->v); - table->v = newV; - table->size = newSize; - table->usedLim = newSize/2; - for (i = h & (table->size - 1); - table->v[i]; - i == 0 ? i = table->size - 1 : --i) - ; - } - } - table->v[i] = table->mem->malloc_fcn(createSize); - if (!table->v[i]) - return 0; - memset(table->v[i], 0, createSize); - table->v[i]->name = name; - (table->used)++; - return table->v[i]; -} - -static -void hashTableDestroy(HASH_TABLE *table) -{ - size_t i; - for (i = 0; i < table->size; i++) { - NAMED *p = table->v[i]; - if (p) - table->mem->free_fcn(p); - } - if (table->v) - table->mem->free_fcn(table->v); -} - -static -void hashTableInit(HASH_TABLE *p, XML_Memory_Handling_Suite *ms) -{ - p->size = 0; - p->usedLim = 0; - p->used = 0; - p->v = 0; - p->mem = ms; -} - -static -void hashTableIterInit(HASH_TABLE_ITER *iter, const HASH_TABLE *table) -{ - iter->p = table->v; - iter->end = iter->p + table->size; -} - -static -NAMED *hashTableIterNext(HASH_TABLE_ITER *iter) -{ - while (iter->p != iter->end) { - NAMED *tem = *(iter->p)++; - if (tem) - return tem; - } - return 0; -} - - -static -void poolInit(STRING_POOL *pool, XML_Memory_Handling_Suite *ms) -{ - pool->blocks = 0; - pool->freeBlocks = 0; - pool->start = 0; - pool->ptr = 0; - pool->end = 0; - pool->mem = ms; -} - -static -void poolClear(STRING_POOL *pool) -{ - if (!pool->freeBlocks) - pool->freeBlocks = pool->blocks; - else { - BLOCK *p = pool->blocks; - while (p) { - BLOCK *tem = p->next; - p->next = pool->freeBlocks; - pool->freeBlocks = p; - p = tem; - } - } - pool->blocks = 0; - pool->start = 0; - pool->ptr = 0; - pool->end = 0; -} - -static -void poolDestroy(STRING_POOL *pool) -{ - BLOCK *p = pool->blocks; - while (p) { - BLOCK *tem = p->next; - pool->mem->free_fcn(p); - p = tem; - } - pool->blocks = 0; - p = pool->freeBlocks; - while (p) { - BLOCK *tem = p->next; - pool->mem->free_fcn(p); - p = tem; - } - pool->freeBlocks = 0; - pool->ptr = 0; - pool->start = 0; - pool->end = 0; -} - -static -XML_Char *poolAppend(STRING_POOL *pool, const ENCODING *enc, - const char *ptr, const char *end) -{ - if (!pool->ptr && !poolGrow(pool)) - return 0; - for (;;) { - XmlConvert(enc, &ptr, end, (ICHAR **)&(pool->ptr), (ICHAR *)pool->end); - if (ptr == end) - break; - if (!poolGrow(pool)) - return 0; - } - return pool->start; -} - -static const XML_Char *poolCopyString(STRING_POOL *pool, const XML_Char *s) -{ - do { - if (!poolAppendChar(pool, *s)) - return 0; - } while (*s++); - s = pool->start; - poolFinish(pool); - return s; -} - -static const XML_Char *poolCopyStringN(STRING_POOL *pool, const XML_Char *s, int n) -{ - if (!pool->ptr && !poolGrow(pool)) - return 0; - for (; n > 0; --n, s++) { - if (!poolAppendChar(pool, *s)) - return 0; - - } - s = pool->start; - poolFinish(pool); - return s; -} - -static -const XML_Char *poolAppendString(STRING_POOL *pool, const XML_Char *s) -{ - while (*s) { - if (!poolAppendChar(pool, *s)) - return 0; - s++; - } - return pool->start; -} /* End poolAppendString */ - -static -XML_Char *poolStoreString(STRING_POOL *pool, const ENCODING *enc, - const char *ptr, const char *end) -{ - if (!poolAppend(pool, enc, ptr, end)) - return 0; - if (pool->ptr == pool->end && !poolGrow(pool)) - return 0; - *(pool->ptr)++ = 0; - return pool->start; -} - -static -int poolGrow(STRING_POOL *pool) -{ - if (pool->freeBlocks) { - if (pool->start == 0) { - pool->blocks = pool->freeBlocks; - pool->freeBlocks = pool->freeBlocks->next; - pool->blocks->next = 0; - pool->start = pool->blocks->s; - pool->end = pool->start + pool->blocks->size; - pool->ptr = pool->start; - return 1; - } - if (pool->end - pool->start < pool->freeBlocks->size) { - BLOCK *tem = pool->freeBlocks->next; - pool->freeBlocks->next = pool->blocks; - pool->blocks = pool->freeBlocks; - pool->freeBlocks = tem; - memcpy(pool->blocks->s, pool->start, (pool->end - pool->start) * sizeof(XML_Char)); - pool->ptr = pool->blocks->s + (pool->ptr - pool->start); - pool->start = pool->blocks->s; - pool->end = pool->start + pool->blocks->size; - return 1; - } - } - if (pool->blocks && pool->start == pool->blocks->s) { - int blockSize = (pool->end - pool->start)*2; - pool->blocks = pool->mem->realloc_fcn(pool->blocks, offsetof(BLOCK, s) + blockSize * sizeof(XML_Char)); - if (!pool->blocks) - return 0; - pool->blocks->size = blockSize; - pool->ptr = pool->blocks->s + (pool->ptr - pool->start); - pool->start = pool->blocks->s; - pool->end = pool->start + blockSize; - } - else { - BLOCK *tem; - int blockSize = pool->end - pool->start; - if (blockSize < INIT_BLOCK_SIZE) - blockSize = INIT_BLOCK_SIZE; - else - blockSize *= 2; - tem = pool->mem->malloc_fcn(offsetof(BLOCK, s) + blockSize * sizeof(XML_Char)); - if (!tem) - return 0; - tem->size = blockSize; - tem->next = pool->blocks; - pool->blocks = tem; - if (pool->ptr != pool->start) - memcpy(tem->s, pool->start, (pool->ptr - pool->start) * sizeof(XML_Char)); - pool->ptr = tem->s + (pool->ptr - pool->start); - pool->start = tem->s; - pool->end = tem->s + blockSize; - } - return 1; -} - -static int -nextScaffoldPart(XML_Parser parser) -{ - CONTENT_SCAFFOLD * me; - int next; - - if (! dtd.scaffIndex) { - dtd.scaffIndex = MALLOC(groupSize * sizeof(int)); - if (! dtd.scaffIndex) - return -1; - dtd.scaffIndex[0] = 0; - } - - if (dtd.scaffCount >= dtd.scaffSize) { - if (dtd.scaffold) { - dtd.scaffSize *= 2; - dtd.scaffold = (CONTENT_SCAFFOLD *) REALLOC(dtd.scaffold, - dtd.scaffSize * sizeof(CONTENT_SCAFFOLD)); - } - else { - dtd.scaffSize = 32; - dtd.scaffold = (CONTENT_SCAFFOLD *) MALLOC(dtd.scaffSize * sizeof(CONTENT_SCAFFOLD)); - } - if (! dtd.scaffold) - return -1; - } - next = dtd.scaffCount++; - me = &dtd.scaffold[next]; - if (dtd.scaffLevel) { - CONTENT_SCAFFOLD *parent = &dtd.scaffold[dtd.scaffIndex[dtd.scaffLevel - 1]]; - if (parent->lastchild) { - dtd.scaffold[parent->lastchild].nextsib = next; - } - if (! parent->childcnt) - parent->firstchild = next; - parent->lastchild = next; - parent->childcnt++; - } - me->firstchild = me->lastchild = me->childcnt = me->nextsib = 0; - return next; -} /* End nextScaffoldPart */ - -static void -build_node (XML_Parser parser, - int src_node, - XML_Content *dest, - XML_Content **contpos, - char **strpos) -{ - dest->type = dtd.scaffold[src_node].type; - dest->quant = dtd.scaffold[src_node].quant; - if (dest->type == XML_CTYPE_NAME) { - const char *src; - dest->name = *strpos; - src = dtd.scaffold[src_node].name; - for (;;) { - *(*strpos)++ = *src; - if (! *src) - break; - src++; - } - dest->numchildren = 0; - dest->children = 0; - } - else { - unsigned int i; - int cn; - dest->numchildren = dtd.scaffold[src_node].childcnt; - dest->children = *contpos; - *contpos += dest->numchildren; - for (i = 0, cn = dtd.scaffold[src_node].firstchild; - i < dest->numchildren; - i++, cn = dtd.scaffold[cn].nextsib) { - build_node(parser, cn, &(dest->children[i]), contpos, strpos); - } - dest->name = 0; - } -} /* End build_node */ - -static XML_Content * -build_model (XML_Parser parser) -{ - XML_Content *ret; - XML_Content *cpos; - char * str; - int allocsize = dtd.scaffCount * sizeof(XML_Content) + dtd.contentStringLen; - - ret = MALLOC(allocsize); - if (! ret) - return 0; - - str = (char *) (&ret[dtd.scaffCount]); - cpos = &ret[1]; - - build_node(parser, 0, ret, &cpos, &str); - return ret; -} /* End build_model */ - -static ELEMENT_TYPE * -getElementType(XML_Parser parser, - const ENCODING *enc, - const char *ptr, - const char *end) -{ - const XML_Char *name = poolStoreString(&dtd.pool, enc, ptr, end); - ELEMENT_TYPE *ret; - - if (! name) - return 0; - ret = (ELEMENT_TYPE *) lookup(&dtd.elementTypes, name, sizeof(ELEMENT_TYPE)); - if (! ret) - return 0; - if (ret->name != name) - poolDiscard(&dtd.pool); - else { - poolFinish(&dtd.pool); - if (!setElementTypePrefix(parser, ret)) - return 0; - } - return ret; -} /* End getElementType */ diff --git a/libs/apr-util/xml/expat/lib/xmlrole.c b/libs/apr-util/xml/expat/lib/xmlrole.c deleted file mode 100644 index ac130392ef..0000000000 --- a/libs/apr-util/xml/expat/lib/xmlrole.c +++ /dev/null @@ -1,1275 +0,0 @@ -/* -Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd -See the file COPYING for copying permission. -*/ - -static char RCSId[] - = "$Header: /home/cvs/apr-util/xml/expat/lib/xmlrole.c,v 1.1 2001/02/28 14:41:26 gstein Exp $"; - -#ifdef COMPILED_FROM_DSP -# include "winconfig.h" -#else -# include -#endif /* ndef COMPILED_FROM_DSP */ - -#include "xmlrole.h" -#include "ascii.h" - -/* Doesn't check: - - that ,| are not mixed in a model group - content of literals - -*/ - -static const char KW_ANY[] = { ASCII_A, ASCII_N, ASCII_Y, '\0' }; -static const char KW_ATTLIST[] = { ASCII_A, ASCII_T, ASCII_T, ASCII_L, ASCII_I, ASCII_S, ASCII_T, '\0' }; -static const char KW_CDATA[] = { ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' }; -static const char KW_DOCTYPE[] = { ASCII_D, ASCII_O, ASCII_C, ASCII_T, ASCII_Y, ASCII_P, ASCII_E, '\0' }; -static const char KW_ELEMENT[] = { ASCII_E, ASCII_L, ASCII_E, ASCII_M, ASCII_E, ASCII_N, ASCII_T, '\0' }; -static const char KW_EMPTY[] = { ASCII_E, ASCII_M, ASCII_P, ASCII_T, ASCII_Y, '\0' }; -static const char KW_ENTITIES[] = { ASCII_E, ASCII_N, ASCII_T, ASCII_I, ASCII_T, ASCII_I, ASCII_E, ASCII_S, '\0' }; -static const char KW_ENTITY[] = { ASCII_E, ASCII_N, ASCII_T, ASCII_I, ASCII_T, ASCII_Y, '\0' }; -static const char KW_FIXED[] = { ASCII_F, ASCII_I, ASCII_X, ASCII_E, ASCII_D, '\0' }; -static const char KW_ID[] = { ASCII_I, ASCII_D, '\0' }; -static const char KW_IDREF[] = { ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, '\0' }; -static const char KW_IDREFS[] = { ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, ASCII_S, '\0' }; -static const char KW_IGNORE[] = { ASCII_I, ASCII_G, ASCII_N, ASCII_O, ASCII_R, ASCII_E, '\0' }; -static const char KW_IMPLIED[] = { ASCII_I, ASCII_M, ASCII_P, ASCII_L, ASCII_I, ASCII_E, ASCII_D, '\0' }; -static const char KW_INCLUDE[] = { ASCII_I, ASCII_N, ASCII_C, ASCII_L, ASCII_U, ASCII_D, ASCII_E, '\0' }; -static const char KW_NDATA[] = { ASCII_N, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' }; -static const char KW_NMTOKEN[] = { ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, ASCII_E, ASCII_N, '\0' }; -static const char KW_NMTOKENS[] = { ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, ASCII_E, ASCII_N, ASCII_S, '\0' }; -static const char KW_NOTATION[] = { ASCII_N, ASCII_O, ASCII_T, ASCII_A, ASCII_T, ASCII_I, ASCII_O, ASCII_N, '\0' }; -static const char KW_PCDATA[] = { ASCII_P, ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' }; -static const char KW_PUBLIC[] = { ASCII_P, ASCII_U, ASCII_B, ASCII_L, ASCII_I, ASCII_C, '\0' }; -static const char KW_REQUIRED[] = { ASCII_R, ASCII_E, ASCII_Q, ASCII_U, ASCII_I, ASCII_R, ASCII_E, ASCII_D, '\0' }; -static const char KW_SYSTEM[] = { ASCII_S, ASCII_Y, ASCII_S, ASCII_T, ASCII_E, ASCII_M, '\0' }; - -#ifndef MIN_BYTES_PER_CHAR -#define MIN_BYTES_PER_CHAR(enc) ((enc)->minBytesPerChar) -#endif - -#ifdef XML_DTD -#define setTopLevel(state) \ - ((state)->handler = ((state)->documentEntity \ - ? internalSubset \ - : externalSubset1)) -#else /* not XML_DTD */ -#define setTopLevel(state) ((state)->handler = internalSubset) -#endif /* not XML_DTD */ - -typedef int PROLOG_HANDLER(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc); - -static PROLOG_HANDLER - prolog0, prolog1, prolog2, - doctype0, doctype1, doctype2, doctype3, doctype4, doctype5, - internalSubset, - entity0, entity1, entity2, entity3, entity4, entity5, entity6, - entity7, entity8, entity9, - notation0, notation1, notation2, notation3, notation4, - attlist0, attlist1, attlist2, attlist3, attlist4, attlist5, attlist6, - attlist7, attlist8, attlist9, - element0, element1, element2, element3, element4, element5, element6, - element7, -#ifdef XML_DTD - externalSubset0, externalSubset1, - condSect0, condSect1, condSect2, -#endif /* XML_DTD */ - declClose, - error; - -static -int common(PROLOG_STATE *state, int tok); - -static -int prolog0(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - state->handler = prolog1; - return XML_ROLE_NONE; - case XML_TOK_XML_DECL: - state->handler = prolog1; - return XML_ROLE_XML_DECL; - case XML_TOK_PI: - state->handler = prolog1; - return XML_ROLE_NONE; - case XML_TOK_COMMENT: - state->handler = prolog1; - case XML_TOK_BOM: - return XML_ROLE_NONE; - case XML_TOK_DECL_OPEN: - if (!XmlNameMatchesAscii(enc, - ptr + 2 * MIN_BYTES_PER_CHAR(enc), - end, - KW_DOCTYPE)) - break; - state->handler = doctype0; - return XML_ROLE_NONE; - case XML_TOK_INSTANCE_START: - state->handler = error; - return XML_ROLE_INSTANCE_START; - } - return common(state, tok); -} - -static -int prolog1(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_PI: - case XML_TOK_COMMENT: - case XML_TOK_BOM: - return XML_ROLE_NONE; - case XML_TOK_DECL_OPEN: - if (!XmlNameMatchesAscii(enc, - ptr + 2 * MIN_BYTES_PER_CHAR(enc), - end, - KW_DOCTYPE)) - break; - state->handler = doctype0; - return XML_ROLE_NONE; - case XML_TOK_INSTANCE_START: - state->handler = error; - return XML_ROLE_INSTANCE_START; - } - return common(state, tok); -} - -static -int prolog2(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_PI: - case XML_TOK_COMMENT: - return XML_ROLE_NONE; - case XML_TOK_INSTANCE_START: - state->handler = error; - return XML_ROLE_INSTANCE_START; - } - return common(state, tok); -} - -static -int doctype0(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_NAME: - case XML_TOK_PREFIXED_NAME: - state->handler = doctype1; - return XML_ROLE_DOCTYPE_NAME; - } - return common(state, tok); -} - -static -int doctype1(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_OPEN_BRACKET: - state->handler = internalSubset; - return XML_ROLE_DOCTYPE_INTERNAL_SUBSET; - case XML_TOK_DECL_CLOSE: - state->handler = prolog2; - return XML_ROLE_DOCTYPE_CLOSE; - case XML_TOK_NAME: - if (XmlNameMatchesAscii(enc, ptr, end, KW_SYSTEM)) { - state->handler = doctype3; - return XML_ROLE_NONE; - } - if (XmlNameMatchesAscii(enc, ptr, end, KW_PUBLIC)) { - state->handler = doctype2; - return XML_ROLE_NONE; - } - break; - } - return common(state, tok); -} - -static -int doctype2(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_LITERAL: - state->handler = doctype3; - return XML_ROLE_DOCTYPE_PUBLIC_ID; - } - return common(state, tok); -} - -static -int doctype3(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_LITERAL: - state->handler = doctype4; - return XML_ROLE_DOCTYPE_SYSTEM_ID; - } - return common(state, tok); -} - -static -int doctype4(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_OPEN_BRACKET: - state->handler = internalSubset; - return XML_ROLE_DOCTYPE_INTERNAL_SUBSET; - case XML_TOK_DECL_CLOSE: - state->handler = prolog2; - return XML_ROLE_DOCTYPE_CLOSE; - } - return common(state, tok); -} - -static -int doctype5(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_DECL_CLOSE: - state->handler = prolog2; - return XML_ROLE_DOCTYPE_CLOSE; - } - return common(state, tok); -} - -static -int internalSubset(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_DECL_OPEN: - if (XmlNameMatchesAscii(enc, - ptr + 2 * MIN_BYTES_PER_CHAR(enc), - end, - KW_ENTITY)) { - state->handler = entity0; - return XML_ROLE_NONE; - } - if (XmlNameMatchesAscii(enc, - ptr + 2 * MIN_BYTES_PER_CHAR(enc), - end, - KW_ATTLIST)) { - state->handler = attlist0; - return XML_ROLE_NONE; - } - if (XmlNameMatchesAscii(enc, - ptr + 2 * MIN_BYTES_PER_CHAR(enc), - end, - KW_ELEMENT)) { - state->handler = element0; - return XML_ROLE_NONE; - } - if (XmlNameMatchesAscii(enc, - ptr + 2 * MIN_BYTES_PER_CHAR(enc), - end, - KW_NOTATION)) { - state->handler = notation0; - return XML_ROLE_NONE; - } - break; - case XML_TOK_PI: - case XML_TOK_COMMENT: - return XML_ROLE_NONE; - case XML_TOK_PARAM_ENTITY_REF: - return XML_ROLE_PARAM_ENTITY_REF; - case XML_TOK_CLOSE_BRACKET: - state->handler = doctype5; - return XML_ROLE_NONE; - } - return common(state, tok); -} - -#ifdef XML_DTD - -static -int externalSubset0(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - state->handler = externalSubset1; - if (tok == XML_TOK_XML_DECL) - return XML_ROLE_TEXT_DECL; - return externalSubset1(state, tok, ptr, end, enc); -} - -static -int externalSubset1(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_COND_SECT_OPEN: - state->handler = condSect0; - return XML_ROLE_NONE; - case XML_TOK_COND_SECT_CLOSE: - if (state->includeLevel == 0) - break; - state->includeLevel -= 1; - return XML_ROLE_NONE; - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_CLOSE_BRACKET: - break; - case XML_TOK_NONE: - if (state->includeLevel) - break; - return XML_ROLE_NONE; - default: - return internalSubset(state, tok, ptr, end, enc); - } - return common(state, tok); -} - -#endif /* XML_DTD */ - -static -int entity0(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_PERCENT: - state->handler = entity1; - return XML_ROLE_NONE; - case XML_TOK_NAME: - state->handler = entity2; - return XML_ROLE_GENERAL_ENTITY_NAME; - } - return common(state, tok); -} - -static -int entity1(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_NAME: - state->handler = entity7; - return XML_ROLE_PARAM_ENTITY_NAME; - } - return common(state, tok); -} - -static -int entity2(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_NAME: - if (XmlNameMatchesAscii(enc, ptr, end, KW_SYSTEM)) { - state->handler = entity4; - return XML_ROLE_NONE; - } - if (XmlNameMatchesAscii(enc, ptr, end, KW_PUBLIC)) { - state->handler = entity3; - return XML_ROLE_NONE; - } - break; - case XML_TOK_LITERAL: - state->handler = declClose; - return XML_ROLE_ENTITY_VALUE; - } - return common(state, tok); -} - -static -int entity3(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_LITERAL: - state->handler = entity4; - return XML_ROLE_ENTITY_PUBLIC_ID; - } - return common(state, tok); -} - - -static -int entity4(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_LITERAL: - state->handler = entity5; - return XML_ROLE_ENTITY_SYSTEM_ID; - } - return common(state, tok); -} - -static -int entity5(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_DECL_CLOSE: - setTopLevel(state); - return XML_ROLE_ENTITY_COMPLETE; - case XML_TOK_NAME: - if (XmlNameMatchesAscii(enc, ptr, end, KW_NDATA)) { - state->handler = entity6; - return XML_ROLE_NONE; - } - break; - } - return common(state, tok); -} - -static -int entity6(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_NAME: - state->handler = declClose; - return XML_ROLE_ENTITY_NOTATION_NAME; - } - return common(state, tok); -} - -static -int entity7(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_NAME: - if (XmlNameMatchesAscii(enc, ptr, end, KW_SYSTEM)) { - state->handler = entity9; - return XML_ROLE_NONE; - } - if (XmlNameMatchesAscii(enc, ptr, end, KW_PUBLIC)) { - state->handler = entity8; - return XML_ROLE_NONE; - } - break; - case XML_TOK_LITERAL: - state->handler = declClose; - return XML_ROLE_ENTITY_VALUE; - } - return common(state, tok); -} - -static -int entity8(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_LITERAL: - state->handler = entity9; - return XML_ROLE_ENTITY_PUBLIC_ID; - } - return common(state, tok); -} - -static -int entity9(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_LITERAL: - state->handler = declClose; - return XML_ROLE_ENTITY_SYSTEM_ID; - } - return common(state, tok); -} - -static -int notation0(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_NAME: - state->handler = notation1; - return XML_ROLE_NOTATION_NAME; - } - return common(state, tok); -} - -static -int notation1(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_NAME: - if (XmlNameMatchesAscii(enc, ptr, end, KW_SYSTEM)) { - state->handler = notation3; - return XML_ROLE_NONE; - } - if (XmlNameMatchesAscii(enc, ptr, end, KW_PUBLIC)) { - state->handler = notation2; - return XML_ROLE_NONE; - } - break; - } - return common(state, tok); -} - -static -int notation2(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_LITERAL: - state->handler = notation4; - return XML_ROLE_NOTATION_PUBLIC_ID; - } - return common(state, tok); -} - -static -int notation3(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_LITERAL: - state->handler = declClose; - return XML_ROLE_NOTATION_SYSTEM_ID; - } - return common(state, tok); -} - -static -int notation4(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_LITERAL: - state->handler = declClose; - return XML_ROLE_NOTATION_SYSTEM_ID; - case XML_TOK_DECL_CLOSE: - setTopLevel(state); - return XML_ROLE_NOTATION_NO_SYSTEM_ID; - } - return common(state, tok); -} - -static -int attlist0(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_NAME: - case XML_TOK_PREFIXED_NAME: - state->handler = attlist1; - return XML_ROLE_ATTLIST_ELEMENT_NAME; - } - return common(state, tok); -} - -static -int attlist1(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_DECL_CLOSE: - setTopLevel(state); - return XML_ROLE_NONE; - case XML_TOK_NAME: - case XML_TOK_PREFIXED_NAME: - state->handler = attlist2; - return XML_ROLE_ATTRIBUTE_NAME; - } - return common(state, tok); -} - -static -int attlist2(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_NAME: - { - static const char *types[] = { - KW_CDATA, - KW_ID, - KW_IDREF, - KW_IDREFS, - KW_ENTITY, - KW_ENTITIES, - KW_NMTOKEN, - KW_NMTOKENS, - }; - int i; - for (i = 0; i < (int)(sizeof(types)/sizeof(types[0])); i++) - if (XmlNameMatchesAscii(enc, ptr, end, types[i])) { - state->handler = attlist8; - return XML_ROLE_ATTRIBUTE_TYPE_CDATA + i; - } - } - if (XmlNameMatchesAscii(enc, ptr, end, KW_NOTATION)) { - state->handler = attlist5; - return XML_ROLE_NONE; - } - break; - case XML_TOK_OPEN_PAREN: - state->handler = attlist3; - return XML_ROLE_NONE; - } - return common(state, tok); -} - -static -int attlist3(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_NMTOKEN: - case XML_TOK_NAME: - case XML_TOK_PREFIXED_NAME: - state->handler = attlist4; - return XML_ROLE_ATTRIBUTE_ENUM_VALUE; - } - return common(state, tok); -} - -static -int attlist4(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_CLOSE_PAREN: - state->handler = attlist8; - return XML_ROLE_NONE; - case XML_TOK_OR: - state->handler = attlist3; - return XML_ROLE_NONE; - } - return common(state, tok); -} - -static -int attlist5(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_OPEN_PAREN: - state->handler = attlist6; - return XML_ROLE_NONE; - } - return common(state, tok); -} - - -static -int attlist6(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_NAME: - state->handler = attlist7; - return XML_ROLE_ATTRIBUTE_NOTATION_VALUE; - } - return common(state, tok); -} - -static -int attlist7(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_CLOSE_PAREN: - state->handler = attlist8; - return XML_ROLE_NONE; - case XML_TOK_OR: - state->handler = attlist6; - return XML_ROLE_NONE; - } - return common(state, tok); -} - -/* default value */ -static -int attlist8(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_POUND_NAME: - if (XmlNameMatchesAscii(enc, - ptr + MIN_BYTES_PER_CHAR(enc), - end, - KW_IMPLIED)) { - state->handler = attlist1; - return XML_ROLE_IMPLIED_ATTRIBUTE_VALUE; - } - if (XmlNameMatchesAscii(enc, - ptr + MIN_BYTES_PER_CHAR(enc), - end, - KW_REQUIRED)) { - state->handler = attlist1; - return XML_ROLE_REQUIRED_ATTRIBUTE_VALUE; - } - if (XmlNameMatchesAscii(enc, - ptr + MIN_BYTES_PER_CHAR(enc), - end, - KW_FIXED)) { - state->handler = attlist9; - return XML_ROLE_NONE; - } - break; - case XML_TOK_LITERAL: - state->handler = attlist1; - return XML_ROLE_DEFAULT_ATTRIBUTE_VALUE; - } - return common(state, tok); -} - -static -int attlist9(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_LITERAL: - state->handler = attlist1; - return XML_ROLE_FIXED_ATTRIBUTE_VALUE; - } - return common(state, tok); -} - -static -int element0(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_NAME: - case XML_TOK_PREFIXED_NAME: - state->handler = element1; - return XML_ROLE_ELEMENT_NAME; - } - return common(state, tok); -} - -static -int element1(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_NAME: - if (XmlNameMatchesAscii(enc, ptr, end, KW_EMPTY)) { - state->handler = declClose; - return XML_ROLE_CONTENT_EMPTY; - } - if (XmlNameMatchesAscii(enc, ptr, end, KW_ANY)) { - state->handler = declClose; - return XML_ROLE_CONTENT_ANY; - } - break; - case XML_TOK_OPEN_PAREN: - state->handler = element2; - state->level = 1; - return XML_ROLE_GROUP_OPEN; - } - return common(state, tok); -} - -static -int element2(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_POUND_NAME: - if (XmlNameMatchesAscii(enc, - ptr + MIN_BYTES_PER_CHAR(enc), - end, - KW_PCDATA)) { - state->handler = element3; - return XML_ROLE_CONTENT_PCDATA; - } - break; - case XML_TOK_OPEN_PAREN: - state->level = 2; - state->handler = element6; - return XML_ROLE_GROUP_OPEN; - case XML_TOK_NAME: - case XML_TOK_PREFIXED_NAME: - state->handler = element7; - return XML_ROLE_CONTENT_ELEMENT; - case XML_TOK_NAME_QUESTION: - state->handler = element7; - return XML_ROLE_CONTENT_ELEMENT_OPT; - case XML_TOK_NAME_ASTERISK: - state->handler = element7; - return XML_ROLE_CONTENT_ELEMENT_REP; - case XML_TOK_NAME_PLUS: - state->handler = element7; - return XML_ROLE_CONTENT_ELEMENT_PLUS; - } - return common(state, tok); -} - -static -int element3(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_CLOSE_PAREN: - state->handler = declClose; - return XML_ROLE_GROUP_CLOSE; - case XML_TOK_CLOSE_PAREN_ASTERISK: - state->handler = declClose; - return XML_ROLE_GROUP_CLOSE_REP; - case XML_TOK_OR: - state->handler = element4; - return XML_ROLE_NONE; - } - return common(state, tok); -} - -static -int element4(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_NAME: - case XML_TOK_PREFIXED_NAME: - state->handler = element5; - return XML_ROLE_CONTENT_ELEMENT; - } - return common(state, tok); -} - -static -int element5(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_CLOSE_PAREN_ASTERISK: - state->handler = declClose; - return XML_ROLE_GROUP_CLOSE_REP; - case XML_TOK_OR: - state->handler = element4; - return XML_ROLE_NONE; - } - return common(state, tok); -} - -static -int element6(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_OPEN_PAREN: - state->level += 1; - return XML_ROLE_GROUP_OPEN; - case XML_TOK_NAME: - case XML_TOK_PREFIXED_NAME: - state->handler = element7; - return XML_ROLE_CONTENT_ELEMENT; - case XML_TOK_NAME_QUESTION: - state->handler = element7; - return XML_ROLE_CONTENT_ELEMENT_OPT; - case XML_TOK_NAME_ASTERISK: - state->handler = element7; - return XML_ROLE_CONTENT_ELEMENT_REP; - case XML_TOK_NAME_PLUS: - state->handler = element7; - return XML_ROLE_CONTENT_ELEMENT_PLUS; - } - return common(state, tok); -} - -static -int element7(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_CLOSE_PAREN: - state->level -= 1; - if (state->level == 0) - state->handler = declClose; - return XML_ROLE_GROUP_CLOSE; - case XML_TOK_CLOSE_PAREN_ASTERISK: - state->level -= 1; - if (state->level == 0) - state->handler = declClose; - return XML_ROLE_GROUP_CLOSE_REP; - case XML_TOK_CLOSE_PAREN_QUESTION: - state->level -= 1; - if (state->level == 0) - state->handler = declClose; - return XML_ROLE_GROUP_CLOSE_OPT; - case XML_TOK_CLOSE_PAREN_PLUS: - state->level -= 1; - if (state->level == 0) - state->handler = declClose; - return XML_ROLE_GROUP_CLOSE_PLUS; - case XML_TOK_COMMA: - state->handler = element6; - return XML_ROLE_GROUP_SEQUENCE; - case XML_TOK_OR: - state->handler = element6; - return XML_ROLE_GROUP_CHOICE; - } - return common(state, tok); -} - -#ifdef XML_DTD - -static -int condSect0(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_NAME: - if (XmlNameMatchesAscii(enc, ptr, end, KW_INCLUDE)) { - state->handler = condSect1; - return XML_ROLE_NONE; - } - if (XmlNameMatchesAscii(enc, ptr, end, KW_IGNORE)) { - state->handler = condSect2; - return XML_ROLE_NONE; - } - break; - } - return common(state, tok); -} - -static -int condSect1(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_OPEN_BRACKET: - state->handler = externalSubset1; - state->includeLevel += 1; - return XML_ROLE_NONE; - } - return common(state, tok); -} - -static -int condSect2(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_OPEN_BRACKET: - state->handler = externalSubset1; - return XML_ROLE_IGNORE_SECT; - } - return common(state, tok); -} - -#endif /* XML_DTD */ - -static -int declClose(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_DECL_CLOSE: - setTopLevel(state); - return XML_ROLE_NONE; - } - return common(state, tok); -} - -#if 0 - -static -int ignore(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_DECL_CLOSE: - state->handler = internalSubset; - return 0; - default: - return XML_ROLE_NONE; - } - return common(state, tok); -} -#endif - -static -int error(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - return XML_ROLE_NONE; -} - -static -int common(PROLOG_STATE *state, int tok) -{ -#ifdef XML_DTD - if (!state->documentEntity && tok == XML_TOK_PARAM_ENTITY_REF) - return XML_ROLE_INNER_PARAM_ENTITY_REF; -#endif - state->handler = error; - return XML_ROLE_ERROR; -} - -void XmlPrologStateInit(PROLOG_STATE *state) -{ - state->handler = prolog0; -#ifdef XML_DTD - state->documentEntity = 1; - state->includeLevel = 0; -#endif /* XML_DTD */ -} - -#ifdef XML_DTD - -void XmlPrologStateInitExternalEntity(PROLOG_STATE *state) -{ - state->handler = externalSubset0; - state->documentEntity = 0; - state->includeLevel = 0; -} - -#endif /* XML_DTD */ diff --git a/libs/apr-util/xml/expat/lib/xmlrole.h b/libs/apr-util/xml/expat/lib/xmlrole.h deleted file mode 100644 index db3ebc8484..0000000000 --- a/libs/apr-util/xml/expat/lib/xmlrole.h +++ /dev/null @@ -1,100 +0,0 @@ -/* -Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd -See the file COPYING for copying permission. -*/ - -#ifndef XmlRole_INCLUDED -#define XmlRole_INCLUDED 1 - -#include "xmltok.h" - -#ifdef __cplusplus -extern "C" { -#endif - -enum { - XML_ROLE_ERROR = -1, - XML_ROLE_NONE = 0, - XML_ROLE_XML_DECL, - XML_ROLE_INSTANCE_START, - XML_ROLE_DOCTYPE_NAME, - XML_ROLE_DOCTYPE_SYSTEM_ID, - XML_ROLE_DOCTYPE_PUBLIC_ID, - XML_ROLE_DOCTYPE_INTERNAL_SUBSET, - XML_ROLE_DOCTYPE_CLOSE, - XML_ROLE_GENERAL_ENTITY_NAME, - XML_ROLE_PARAM_ENTITY_NAME, - XML_ROLE_ENTITY_VALUE, - XML_ROLE_ENTITY_SYSTEM_ID, - XML_ROLE_ENTITY_PUBLIC_ID, - XML_ROLE_ENTITY_COMPLETE, - XML_ROLE_ENTITY_NOTATION_NAME, - XML_ROLE_NOTATION_NAME, - XML_ROLE_NOTATION_SYSTEM_ID, - XML_ROLE_NOTATION_NO_SYSTEM_ID, - XML_ROLE_NOTATION_PUBLIC_ID, - XML_ROLE_ATTRIBUTE_NAME, - XML_ROLE_ATTRIBUTE_TYPE_CDATA, - XML_ROLE_ATTRIBUTE_TYPE_ID, - XML_ROLE_ATTRIBUTE_TYPE_IDREF, - XML_ROLE_ATTRIBUTE_TYPE_IDREFS, - XML_ROLE_ATTRIBUTE_TYPE_ENTITY, - XML_ROLE_ATTRIBUTE_TYPE_ENTITIES, - XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN, - XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS, - XML_ROLE_ATTRIBUTE_ENUM_VALUE, - XML_ROLE_ATTRIBUTE_NOTATION_VALUE, - XML_ROLE_ATTLIST_ELEMENT_NAME, - XML_ROLE_IMPLIED_ATTRIBUTE_VALUE, - XML_ROLE_REQUIRED_ATTRIBUTE_VALUE, - XML_ROLE_DEFAULT_ATTRIBUTE_VALUE, - XML_ROLE_FIXED_ATTRIBUTE_VALUE, - XML_ROLE_ELEMENT_NAME, - XML_ROLE_CONTENT_ANY, - XML_ROLE_CONTENT_EMPTY, - XML_ROLE_CONTENT_PCDATA, - XML_ROLE_GROUP_OPEN, - XML_ROLE_GROUP_CLOSE, - XML_ROLE_GROUP_CLOSE_REP, - XML_ROLE_GROUP_CLOSE_OPT, - XML_ROLE_GROUP_CLOSE_PLUS, - XML_ROLE_GROUP_CHOICE, - XML_ROLE_GROUP_SEQUENCE, - XML_ROLE_CONTENT_ELEMENT, - XML_ROLE_CONTENT_ELEMENT_REP, - XML_ROLE_CONTENT_ELEMENT_OPT, - XML_ROLE_CONTENT_ELEMENT_PLUS, -#ifdef XML_DTD - XML_ROLE_TEXT_DECL, - XML_ROLE_IGNORE_SECT, - XML_ROLE_INNER_PARAM_ENTITY_REF, -#endif /* XML_DTD */ - XML_ROLE_PARAM_ENTITY_REF -}; - -typedef struct prolog_state { - int (*handler)(struct prolog_state *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc); - unsigned level; -#ifdef XML_DTD - unsigned includeLevel; - int documentEntity; -#endif /* XML_DTD */ -} PROLOG_STATE; - -void XmlPrologStateInit(PROLOG_STATE *); -#ifdef XML_DTD -void XmlPrologStateInitExternalEntity(PROLOG_STATE *); -#endif /* XML_DTD */ - -#define XmlTokenRole(state, tok, ptr, end, enc) \ - (((state)->handler)(state, tok, ptr, end, enc)) - -#ifdef __cplusplus -} -#endif - -#endif /* not XmlRole_INCLUDED */ diff --git a/libs/apr-util/xml/expat/lib/xmltok.c b/libs/apr-util/xml/expat/lib/xmltok.c deleted file mode 100644 index 74c681f1e6..0000000000 --- a/libs/apr-util/xml/expat/lib/xmltok.c +++ /dev/null @@ -1,1569 +0,0 @@ -/* -Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd -See the file COPYING for copying permission. -*/ - -static char RCSId[] - = "$Header: /home/cvs/apr-util/xml/expat/lib/xmltok.c,v 1.1 2001/02/28 14:41:26 gstein Exp $"; - -#ifdef COMPILED_FROM_DSP -# include "winconfig.h" -#else -# include -#endif /* ndef COMPILED_FROM_DSP */ - -#include "xmltok.h" -#include "nametab.h" - -#ifdef XML_DTD -#define IGNORE_SECTION_TOK_VTABLE , PREFIX(ignoreSectionTok) -#else -#define IGNORE_SECTION_TOK_VTABLE /* as nothing */ -#endif - -#define VTABLE1 \ - { PREFIX(prologTok), PREFIX(contentTok), \ - PREFIX(cdataSectionTok) IGNORE_SECTION_TOK_VTABLE }, \ - { PREFIX(attributeValueTok), PREFIX(entityValueTok) }, \ - PREFIX(sameName), \ - PREFIX(nameMatchesAscii), \ - PREFIX(nameLength), \ - PREFIX(skipS), \ - PREFIX(getAtts), \ - PREFIX(charRefNumber), \ - PREFIX(predefinedEntityName), \ - PREFIX(updatePosition), \ - PREFIX(isPublicId) - -#define VTABLE VTABLE1, PREFIX(toUtf8), PREFIX(toUtf16) - -#define UCS2_GET_NAMING(pages, hi, lo) \ - (namingBitmap[(pages[hi] << 3) + ((lo) >> 5)] & (1 << ((lo) & 0x1F))) - -/* A 2 byte UTF-8 representation splits the characters 11 bits -between the bottom 5 and 6 bits of the bytes. -We need 8 bits to index into pages, 3 bits to add to that index and -5 bits to generate the mask. */ -#define UTF8_GET_NAMING2(pages, byte) \ - (namingBitmap[((pages)[(((byte)[0]) >> 2) & 7] << 3) \ - + ((((byte)[0]) & 3) << 1) \ - + ((((byte)[1]) >> 5) & 1)] \ - & (1 << (((byte)[1]) & 0x1F))) - -/* A 3 byte UTF-8 representation splits the characters 16 bits -between the bottom 4, 6 and 6 bits of the bytes. -We need 8 bits to index into pages, 3 bits to add to that index and -5 bits to generate the mask. */ -#define UTF8_GET_NAMING3(pages, byte) \ - (namingBitmap[((pages)[((((byte)[0]) & 0xF) << 4) \ - + ((((byte)[1]) >> 2) & 0xF)] \ - << 3) \ - + ((((byte)[1]) & 3) << 1) \ - + ((((byte)[2]) >> 5) & 1)] \ - & (1 << (((byte)[2]) & 0x1F))) - -#define UTF8_GET_NAMING(pages, p, n) \ - ((n) == 2 \ - ? UTF8_GET_NAMING2(pages, (const unsigned char *)(p)) \ - : ((n) == 3 \ - ? UTF8_GET_NAMING3(pages, (const unsigned char *)(p)) \ - : 0)) - -#define UTF8_INVALID3(p) \ - ((*p) == 0xED \ - ? (((p)[1] & 0x20) != 0) \ - : ((*p) == 0xEF \ - ? ((p)[1] == 0xBF && ((p)[2] == 0xBF || (p)[2] == 0xBE)) \ - : 0)) - -#define UTF8_INVALID4(p) ((*p) == 0xF4 && ((p)[1] & 0x30) != 0) - -static -int isNever(const ENCODING *enc, const char *p) -{ - return 0; -} - -static -int utf8_isName2(const ENCODING *enc, const char *p) -{ - return UTF8_GET_NAMING2(namePages, (const unsigned char *)p); -} - -static -int utf8_isName3(const ENCODING *enc, const char *p) -{ - return UTF8_GET_NAMING3(namePages, (const unsigned char *)p); -} - -#define utf8_isName4 isNever - -static -int utf8_isNmstrt2(const ENCODING *enc, const char *p) -{ - return UTF8_GET_NAMING2(nmstrtPages, (const unsigned char *)p); -} - -static -int utf8_isNmstrt3(const ENCODING *enc, const char *p) -{ - return UTF8_GET_NAMING3(nmstrtPages, (const unsigned char *)p); -} - -#define utf8_isNmstrt4 isNever - -#define utf8_isInvalid2 isNever - -static -int utf8_isInvalid3(const ENCODING *enc, const char *p) -{ - return UTF8_INVALID3((const unsigned char *)p); -} - -static -int utf8_isInvalid4(const ENCODING *enc, const char *p) -{ - return UTF8_INVALID4((const unsigned char *)p); -} - -struct normal_encoding { - ENCODING enc; - unsigned char type[256]; -#ifdef XML_MIN_SIZE - int (*byteType)(const ENCODING *, const char *); - int (*isNameMin)(const ENCODING *, const char *); - int (*isNmstrtMin)(const ENCODING *, const char *); - int (*byteToAscii)(const ENCODING *, const char *); - int (*charMatches)(const ENCODING *, const char *, int); -#endif /* XML_MIN_SIZE */ - int (*isName2)(const ENCODING *, const char *); - int (*isName3)(const ENCODING *, const char *); - int (*isName4)(const ENCODING *, const char *); - int (*isNmstrt2)(const ENCODING *, const char *); - int (*isNmstrt3)(const ENCODING *, const char *); - int (*isNmstrt4)(const ENCODING *, const char *); - int (*isInvalid2)(const ENCODING *, const char *); - int (*isInvalid3)(const ENCODING *, const char *); - int (*isInvalid4)(const ENCODING *, const char *); -}; - -#ifdef XML_MIN_SIZE - -#define STANDARD_VTABLE(E) \ - E ## byteType, \ - E ## isNameMin, \ - E ## isNmstrtMin, \ - E ## byteToAscii, \ - E ## charMatches, - -#else - -#define STANDARD_VTABLE(E) /* as nothing */ - -#endif - -#define NORMAL_VTABLE(E) \ - E ## isName2, \ - E ## isName3, \ - E ## isName4, \ - E ## isNmstrt2, \ - E ## isNmstrt3, \ - E ## isNmstrt4, \ - E ## isInvalid2, \ - E ## isInvalid3, \ - E ## isInvalid4 - -static int checkCharRefNumber(int); - -#include "xmltok_impl.h" -#include "ascii.h" - -#ifdef XML_MIN_SIZE -#define sb_isNameMin isNever -#define sb_isNmstrtMin isNever -#endif - -#ifdef XML_MIN_SIZE -#define MINBPC(enc) ((enc)->minBytesPerChar) -#else -/* minimum bytes per character */ -#define MINBPC(enc) 1 -#endif - -#define SB_BYTE_TYPE(enc, p) \ - (((struct normal_encoding *)(enc))->type[(unsigned char)*(p)]) - -#ifdef XML_MIN_SIZE -static -int sb_byteType(const ENCODING *enc, const char *p) -{ - return SB_BYTE_TYPE(enc, p); -} -#define BYTE_TYPE(enc, p) \ - (((const struct normal_encoding *)(enc))->byteType(enc, p)) -#else -#define BYTE_TYPE(enc, p) SB_BYTE_TYPE(enc, p) -#endif - -#ifdef XML_MIN_SIZE -#define BYTE_TO_ASCII(enc, p) \ - (((const struct normal_encoding *)(enc))->byteToAscii(enc, p)) -static -int sb_byteToAscii(const ENCODING *enc, const char *p) -{ - return *p; -} -#else -#define BYTE_TO_ASCII(enc, p) (*(p)) -#endif - -#define IS_NAME_CHAR(enc, p, n) \ - (((const struct normal_encoding *)(enc))->isName ## n(enc, p)) -#define IS_NMSTRT_CHAR(enc, p, n) \ - (((const struct normal_encoding *)(enc))->isNmstrt ## n(enc, p)) -#define IS_INVALID_CHAR(enc, p, n) \ - (((const struct normal_encoding *)(enc))->isInvalid ## n(enc, p)) - -#ifdef XML_MIN_SIZE -#define IS_NAME_CHAR_MINBPC(enc, p) \ - (((const struct normal_encoding *)(enc))->isNameMin(enc, p)) -#define IS_NMSTRT_CHAR_MINBPC(enc, p) \ - (((const struct normal_encoding *)(enc))->isNmstrtMin(enc, p)) -#else -#define IS_NAME_CHAR_MINBPC(enc, p) (0) -#define IS_NMSTRT_CHAR_MINBPC(enc, p) (0) -#endif - -#ifdef XML_MIN_SIZE -#define CHAR_MATCHES(enc, p, c) \ - (((const struct normal_encoding *)(enc))->charMatches(enc, p, c)) -static -int sb_charMatches(const ENCODING *enc, const char *p, int c) -{ - return *p == c; -} -#else -/* c is an ASCII character */ -#define CHAR_MATCHES(enc, p, c) (*(p) == c) -#endif - -#define PREFIX(ident) normal_ ## ident -#include "xmltok_impl.c" - -#undef MINBPC -#undef BYTE_TYPE -#undef BYTE_TO_ASCII -#undef CHAR_MATCHES -#undef IS_NAME_CHAR -#undef IS_NAME_CHAR_MINBPC -#undef IS_NMSTRT_CHAR -#undef IS_NMSTRT_CHAR_MINBPC -#undef IS_INVALID_CHAR - -enum { /* UTF8_cvalN is value of masked first byte of N byte sequence */ - UTF8_cval1 = 0x00, - UTF8_cval2 = 0xc0, - UTF8_cval3 = 0xe0, - UTF8_cval4 = 0xf0 -}; - -static -void utf8_toUtf8(const ENCODING *enc, - const char **fromP, const char *fromLim, - char **toP, const char *toLim) -{ - char *to; - const char *from; - if (fromLim - *fromP > toLim - *toP) { - /* Avoid copying partial characters. */ - for (fromLim = *fromP + (toLim - *toP); fromLim > *fromP; fromLim--) - if (((unsigned char)fromLim[-1] & 0xc0) != 0x80) - break; - } - for (to = *toP, from = *fromP; from != fromLim; from++, to++) - *to = *from; - *fromP = from; - *toP = to; -} - -static -void utf8_toUtf16(const ENCODING *enc, - const char **fromP, const char *fromLim, - unsigned short **toP, const unsigned short *toLim) -{ - unsigned short *to = *toP; - const char *from = *fromP; - while (from != fromLim && to != toLim) { - switch (((struct normal_encoding *)enc)->type[(unsigned char)*from]) { - case BT_LEAD2: - *to++ = ((from[0] & 0x1f) << 6) | (from[1] & 0x3f); - from += 2; - break; - case BT_LEAD3: - *to++ = ((from[0] & 0xf) << 12) | ((from[1] & 0x3f) << 6) | (from[2] & 0x3f); - from += 3; - break; - case BT_LEAD4: - { - unsigned long n; - if (to + 1 == toLim) - break; - n = ((from[0] & 0x7) << 18) | ((from[1] & 0x3f) << 12) | ((from[2] & 0x3f) << 6) | (from[3] & 0x3f); - n -= 0x10000; - to[0] = (unsigned short)((n >> 10) | 0xD800); - to[1] = (unsigned short)((n & 0x3FF) | 0xDC00); - to += 2; - from += 4; - } - break; - default: - *to++ = *from++; - break; - } - } - *fromP = from; - *toP = to; -} - -#ifdef XML_NS -static const struct normal_encoding utf8_encoding_ns = { - { VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0 }, - { -#include "asciitab.h" -#include "utf8tab.h" - }, - STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_) -}; -#endif - -static const struct normal_encoding utf8_encoding = { - { VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0 }, - { -#define BT_COLON BT_NMSTRT -#include "asciitab.h" -#undef BT_COLON -#include "utf8tab.h" - }, - STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_) -}; - -#ifdef XML_NS - -static const struct normal_encoding internal_utf8_encoding_ns = { - { VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0 }, - { -#include "iasciitab.h" -#include "utf8tab.h" - }, - STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_) -}; - -#endif - -static const struct normal_encoding internal_utf8_encoding = { - { VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0 }, - { -#define BT_COLON BT_NMSTRT -#include "iasciitab.h" -#undef BT_COLON -#include "utf8tab.h" - }, - STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_) -}; - -static -void latin1_toUtf8(const ENCODING *enc, - const char **fromP, const char *fromLim, - char **toP, const char *toLim) -{ - for (;;) { - unsigned char c; - if (*fromP == fromLim) - break; - c = (unsigned char)**fromP; - if (c & 0x80) { - if (toLim - *toP < 2) - break; - *(*toP)++ = ((c >> 6) | UTF8_cval2); - *(*toP)++ = ((c & 0x3f) | 0x80); - (*fromP)++; - } - else { - if (*toP == toLim) - break; - *(*toP)++ = *(*fromP)++; - } - } -} - -static -void latin1_toUtf16(const ENCODING *enc, - const char **fromP, const char *fromLim, - unsigned short **toP, const unsigned short *toLim) -{ - while (*fromP != fromLim && *toP != toLim) - *(*toP)++ = (unsigned char)*(*fromP)++; -} - -#ifdef XML_NS - -static const struct normal_encoding latin1_encoding_ns = { - { VTABLE1, latin1_toUtf8, latin1_toUtf16, 1, 0, 0 }, - { -#include "asciitab.h" -#include "latin1tab.h" - }, - STANDARD_VTABLE(sb_) -}; - -#endif - -static const struct normal_encoding latin1_encoding = { - { VTABLE1, latin1_toUtf8, latin1_toUtf16, 1, 0, 0 }, - { -#define BT_COLON BT_NMSTRT -#include "asciitab.h" -#undef BT_COLON -#include "latin1tab.h" - }, - STANDARD_VTABLE(sb_) -}; - -static -void ascii_toUtf8(const ENCODING *enc, - const char **fromP, const char *fromLim, - char **toP, const char *toLim) -{ - while (*fromP != fromLim && *toP != toLim) - *(*toP)++ = *(*fromP)++; -} - -#ifdef XML_NS - -static const struct normal_encoding ascii_encoding_ns = { - { VTABLE1, ascii_toUtf8, latin1_toUtf16, 1, 1, 0 }, - { -#include "asciitab.h" -/* BT_NONXML == 0 */ - }, - STANDARD_VTABLE(sb_) -}; - -#endif - -static const struct normal_encoding ascii_encoding = { - { VTABLE1, ascii_toUtf8, latin1_toUtf16, 1, 1, 0 }, - { -#define BT_COLON BT_NMSTRT -#include "asciitab.h" -#undef BT_COLON -/* BT_NONXML == 0 */ - }, - STANDARD_VTABLE(sb_) -}; - -static int unicode_byte_type(char hi, char lo) -{ - switch ((unsigned char)hi) { - case 0xD8: case 0xD9: case 0xDA: case 0xDB: - return BT_LEAD4; - case 0xDC: case 0xDD: case 0xDE: case 0xDF: - return BT_TRAIL; - case 0xFF: - switch ((unsigned char)lo) { - case 0xFF: - case 0xFE: - return BT_NONXML; - } - break; - } - return BT_NONASCII; -} - -#define DEFINE_UTF16_TO_UTF8(E) \ -static \ -void E ## toUtf8(const ENCODING *enc, \ - const char **fromP, const char *fromLim, \ - char **toP, const char *toLim) \ -{ \ - const char *from; \ - for (from = *fromP; from != fromLim; from += 2) { \ - int plane; \ - unsigned char lo2; \ - unsigned char lo = GET_LO(from); \ - unsigned char hi = GET_HI(from); \ - switch (hi) { \ - case 0: \ - if (lo < 0x80) { \ - if (*toP == toLim) { \ - *fromP = from; \ - return; \ - } \ - *(*toP)++ = lo; \ - break; \ - } \ - /* fall through */ \ - case 0x1: case 0x2: case 0x3: \ - case 0x4: case 0x5: case 0x6: case 0x7: \ - if (toLim - *toP < 2) { \ - *fromP = from; \ - return; \ - } \ - *(*toP)++ = ((lo >> 6) | (hi << 2) | UTF8_cval2); \ - *(*toP)++ = ((lo & 0x3f) | 0x80); \ - break; \ - default: \ - if (toLim - *toP < 3) { \ - *fromP = from; \ - return; \ - } \ - /* 16 bits divided 4, 6, 6 amongst 3 bytes */ \ - *(*toP)++ = ((hi >> 4) | UTF8_cval3); \ - *(*toP)++ = (((hi & 0xf) << 2) | (lo >> 6) | 0x80); \ - *(*toP)++ = ((lo & 0x3f) | 0x80); \ - break; \ - case 0xD8: case 0xD9: case 0xDA: case 0xDB: \ - if (toLim - *toP < 4) { \ - *fromP = from; \ - return; \ - } \ - plane = (((hi & 0x3) << 2) | ((lo >> 6) & 0x3)) + 1; \ - *(*toP)++ = ((plane >> 2) | UTF8_cval4); \ - *(*toP)++ = (((lo >> 2) & 0xF) | ((plane & 0x3) << 4) | 0x80); \ - from += 2; \ - lo2 = GET_LO(from); \ - *(*toP)++ = (((lo & 0x3) << 4) \ - | ((GET_HI(from) & 0x3) << 2) \ - | (lo2 >> 6) \ - | 0x80); \ - *(*toP)++ = ((lo2 & 0x3f) | 0x80); \ - break; \ - } \ - } \ - *fromP = from; \ -} - -#define DEFINE_UTF16_TO_UTF16(E) \ -static \ -void E ## toUtf16(const ENCODING *enc, \ - const char **fromP, const char *fromLim, \ - unsigned short **toP, const unsigned short *toLim) \ -{ \ - /* Avoid copying first half only of surrogate */ \ - if (fromLim - *fromP > ((toLim - *toP) << 1) \ - && (GET_HI(fromLim - 2) & 0xF8) == 0xD8) \ - fromLim -= 2; \ - for (; *fromP != fromLim && *toP != toLim; *fromP += 2) \ - *(*toP)++ = (GET_HI(*fromP) << 8) | GET_LO(*fromP); \ -} - -#define SET2(ptr, ch) \ - (((ptr)[0] = ((ch) & 0xff)), ((ptr)[1] = ((ch) >> 8))) -#define GET_LO(ptr) ((unsigned char)(ptr)[0]) -#define GET_HI(ptr) ((unsigned char)(ptr)[1]) - -DEFINE_UTF16_TO_UTF8(little2_) -DEFINE_UTF16_TO_UTF16(little2_) - -#undef SET2 -#undef GET_LO -#undef GET_HI - -#define SET2(ptr, ch) \ - (((ptr)[0] = ((ch) >> 8)), ((ptr)[1] = ((ch) & 0xFF))) -#define GET_LO(ptr) ((unsigned char)(ptr)[1]) -#define GET_HI(ptr) ((unsigned char)(ptr)[0]) - -DEFINE_UTF16_TO_UTF8(big2_) -DEFINE_UTF16_TO_UTF16(big2_) - -#undef SET2 -#undef GET_LO -#undef GET_HI - -#define LITTLE2_BYTE_TYPE(enc, p) \ - ((p)[1] == 0 \ - ? ((struct normal_encoding *)(enc))->type[(unsigned char)*(p)] \ - : unicode_byte_type((p)[1], (p)[0])) -#define LITTLE2_BYTE_TO_ASCII(enc, p) ((p)[1] == 0 ? (p)[0] : -1) -#define LITTLE2_CHAR_MATCHES(enc, p, c) ((p)[1] == 0 && (p)[0] == c) -#define LITTLE2_IS_NAME_CHAR_MINBPC(enc, p) \ - UCS2_GET_NAMING(namePages, (unsigned char)p[1], (unsigned char)p[0]) -#define LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p) \ - UCS2_GET_NAMING(nmstrtPages, (unsigned char)p[1], (unsigned char)p[0]) - -#ifdef XML_MIN_SIZE - -static -int little2_byteType(const ENCODING *enc, const char *p) -{ - return LITTLE2_BYTE_TYPE(enc, p); -} - -static -int little2_byteToAscii(const ENCODING *enc, const char *p) -{ - return LITTLE2_BYTE_TO_ASCII(enc, p); -} - -static -int little2_charMatches(const ENCODING *enc, const char *p, int c) -{ - return LITTLE2_CHAR_MATCHES(enc, p, c); -} - -static -int little2_isNameMin(const ENCODING *enc, const char *p) -{ - return LITTLE2_IS_NAME_CHAR_MINBPC(enc, p); -} - -static -int little2_isNmstrtMin(const ENCODING *enc, const char *p) -{ - return LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p); -} - -#undef VTABLE -#define VTABLE VTABLE1, little2_toUtf8, little2_toUtf16 - -#else /* not XML_MIN_SIZE */ - -#undef PREFIX -#define PREFIX(ident) little2_ ## ident -#define MINBPC(enc) 2 -/* CHAR_MATCHES is guaranteed to have MINBPC bytes available. */ -#define BYTE_TYPE(enc, p) LITTLE2_BYTE_TYPE(enc, p) -#define BYTE_TO_ASCII(enc, p) LITTLE2_BYTE_TO_ASCII(enc, p) -#define CHAR_MATCHES(enc, p, c) LITTLE2_CHAR_MATCHES(enc, p, c) -#define IS_NAME_CHAR(enc, p, n) 0 -#define IS_NAME_CHAR_MINBPC(enc, p) LITTLE2_IS_NAME_CHAR_MINBPC(enc, p) -#define IS_NMSTRT_CHAR(enc, p, n) (0) -#define IS_NMSTRT_CHAR_MINBPC(enc, p) LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p) - -#include "xmltok_impl.c" - -#undef MINBPC -#undef BYTE_TYPE -#undef BYTE_TO_ASCII -#undef CHAR_MATCHES -#undef IS_NAME_CHAR -#undef IS_NAME_CHAR_MINBPC -#undef IS_NMSTRT_CHAR -#undef IS_NMSTRT_CHAR_MINBPC -#undef IS_INVALID_CHAR - -#endif /* not XML_MIN_SIZE */ - -#ifdef XML_NS - -static const struct normal_encoding little2_encoding_ns = { - { VTABLE, 2, 0, -#if XML_BYTE_ORDER == 12 - 1 -#else - 0 -#endif - }, - { -#include "asciitab.h" -#include "latin1tab.h" - }, - STANDARD_VTABLE(little2_) -}; - -#endif - -static const struct normal_encoding little2_encoding = { - { VTABLE, 2, 0, -#if XML_BYTE_ORDER == 12 - 1 -#else - 0 -#endif - }, - { -#define BT_COLON BT_NMSTRT -#include "asciitab.h" -#undef BT_COLON -#include "latin1tab.h" - }, - STANDARD_VTABLE(little2_) -}; - -#if XML_BYTE_ORDER != 21 - -#ifdef XML_NS - -static const struct normal_encoding internal_little2_encoding_ns = { - { VTABLE, 2, 0, 1 }, - { -#include "iasciitab.h" -#include "latin1tab.h" - }, - STANDARD_VTABLE(little2_) -}; - -#endif - -static const struct normal_encoding internal_little2_encoding = { - { VTABLE, 2, 0, 1 }, - { -#define BT_COLON BT_NMSTRT -#include "iasciitab.h" -#undef BT_COLON -#include "latin1tab.h" - }, - STANDARD_VTABLE(little2_) -}; - -#endif - - -#define BIG2_BYTE_TYPE(enc, p) \ - ((p)[0] == 0 \ - ? ((struct normal_encoding *)(enc))->type[(unsigned char)(p)[1]] \ - : unicode_byte_type((p)[0], (p)[1])) -#define BIG2_BYTE_TO_ASCII(enc, p) ((p)[0] == 0 ? (p)[1] : -1) -#define BIG2_CHAR_MATCHES(enc, p, c) ((p)[0] == 0 && (p)[1] == c) -#define BIG2_IS_NAME_CHAR_MINBPC(enc, p) \ - UCS2_GET_NAMING(namePages, (unsigned char)p[0], (unsigned char)p[1]) -#define BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p) \ - UCS2_GET_NAMING(nmstrtPages, (unsigned char)p[0], (unsigned char)p[1]) - -#ifdef XML_MIN_SIZE - -static -int big2_byteType(const ENCODING *enc, const char *p) -{ - return BIG2_BYTE_TYPE(enc, p); -} - -static -int big2_byteToAscii(const ENCODING *enc, const char *p) -{ - return BIG2_BYTE_TO_ASCII(enc, p); -} - -static -int big2_charMatches(const ENCODING *enc, const char *p, int c) -{ - return BIG2_CHAR_MATCHES(enc, p, c); -} - -static -int big2_isNameMin(const ENCODING *enc, const char *p) -{ - return BIG2_IS_NAME_CHAR_MINBPC(enc, p); -} - -static -int big2_isNmstrtMin(const ENCODING *enc, const char *p) -{ - return BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p); -} - -#undef VTABLE -#define VTABLE VTABLE1, big2_toUtf8, big2_toUtf16 - -#else /* not XML_MIN_SIZE */ - -#undef PREFIX -#define PREFIX(ident) big2_ ## ident -#define MINBPC(enc) 2 -/* CHAR_MATCHES is guaranteed to have MINBPC bytes available. */ -#define BYTE_TYPE(enc, p) BIG2_BYTE_TYPE(enc, p) -#define BYTE_TO_ASCII(enc, p) BIG2_BYTE_TO_ASCII(enc, p) -#define CHAR_MATCHES(enc, p, c) BIG2_CHAR_MATCHES(enc, p, c) -#define IS_NAME_CHAR(enc, p, n) 0 -#define IS_NAME_CHAR_MINBPC(enc, p) BIG2_IS_NAME_CHAR_MINBPC(enc, p) -#define IS_NMSTRT_CHAR(enc, p, n) (0) -#define IS_NMSTRT_CHAR_MINBPC(enc, p) BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p) - -#include "xmltok_impl.c" - -#undef MINBPC -#undef BYTE_TYPE -#undef BYTE_TO_ASCII -#undef CHAR_MATCHES -#undef IS_NAME_CHAR -#undef IS_NAME_CHAR_MINBPC -#undef IS_NMSTRT_CHAR -#undef IS_NMSTRT_CHAR_MINBPC -#undef IS_INVALID_CHAR - -#endif /* not XML_MIN_SIZE */ - -#ifdef XML_NS - -static const struct normal_encoding big2_encoding_ns = { - { VTABLE, 2, 0, -#if XML_BYTE_ORDER == 21 - 1 -#else - 0 -#endif - }, - { -#include "asciitab.h" -#include "latin1tab.h" - }, - STANDARD_VTABLE(big2_) -}; - -#endif - -static const struct normal_encoding big2_encoding = { - { VTABLE, 2, 0, -#if XML_BYTE_ORDER == 21 - 1 -#else - 0 -#endif - }, - { -#define BT_COLON BT_NMSTRT -#include "asciitab.h" -#undef BT_COLON -#include "latin1tab.h" - }, - STANDARD_VTABLE(big2_) -}; - -#if XML_BYTE_ORDER != 12 - -#ifdef XML_NS - -static const struct normal_encoding internal_big2_encoding_ns = { - { VTABLE, 2, 0, 1 }, - { -#include "iasciitab.h" -#include "latin1tab.h" - }, - STANDARD_VTABLE(big2_) -}; - -#endif - -static const struct normal_encoding internal_big2_encoding = { - { VTABLE, 2, 0, 1 }, - { -#define BT_COLON BT_NMSTRT -#include "iasciitab.h" -#undef BT_COLON -#include "latin1tab.h" - }, - STANDARD_VTABLE(big2_) -}; - -#endif - -#undef PREFIX - -static -int streqci(const char *s1, const char *s2) -{ - for (;;) { - char c1 = *s1++; - char c2 = *s2++; - if (ASCII_a <= c1 && c1 <= ASCII_z) - c1 += ASCII_A - ASCII_a; - if (ASCII_a <= c2 && c2 <= ASCII_z) - c2 += ASCII_A - ASCII_a; - if (c1 != c2) - return 0; - if (!c1) - break; - } - return 1; -} - -static -void initUpdatePosition(const ENCODING *enc, const char *ptr, - const char *end, POSITION *pos) -{ - normal_updatePosition(&utf8_encoding.enc, ptr, end, pos); -} - -static -int toAscii(const ENCODING *enc, const char *ptr, const char *end) -{ - char buf[1]; - char *p = buf; - XmlUtf8Convert(enc, &ptr, end, &p, p + 1); - if (p == buf) - return -1; - else - return buf[0]; -} - -static -int isSpace(int c) -{ - switch (c) { - case 0x20: - case 0xD: - case 0xA: - case 0x9: - return 1; - } - return 0; -} - -/* Return 1 if there's just optional white space -or there's an S followed by name=val. */ -static -int parsePseudoAttribute(const ENCODING *enc, - const char *ptr, - const char *end, - const char **namePtr, - const char **nameEndPtr, - const char **valPtr, - const char **nextTokPtr) -{ - int c; - char open; - if (ptr == end) { - *namePtr = 0; - return 1; - } - if (!isSpace(toAscii(enc, ptr, end))) { - *nextTokPtr = ptr; - return 0; - } - do { - ptr += enc->minBytesPerChar; - } while (isSpace(toAscii(enc, ptr, end))); - if (ptr == end) { - *namePtr = 0; - return 1; - } - *namePtr = ptr; - for (;;) { - c = toAscii(enc, ptr, end); - if (c == -1) { - *nextTokPtr = ptr; - return 0; - } - if (c == ASCII_EQUALS) { - *nameEndPtr = ptr; - break; - } - if (isSpace(c)) { - *nameEndPtr = ptr; - do { - ptr += enc->minBytesPerChar; - } while (isSpace(c = toAscii(enc, ptr, end))); - if (c != ASCII_EQUALS) { - *nextTokPtr = ptr; - return 0; - } - break; - } - ptr += enc->minBytesPerChar; - } - if (ptr == *namePtr) { - *nextTokPtr = ptr; - return 0; - } - ptr += enc->minBytesPerChar; - c = toAscii(enc, ptr, end); - while (isSpace(c)) { - ptr += enc->minBytesPerChar; - c = toAscii(enc, ptr, end); - } - if (c != ASCII_QUOT && c != ASCII_APOS) { - *nextTokPtr = ptr; - return 0; - } - open = c; - ptr += enc->minBytesPerChar; - *valPtr = ptr; - for (;; ptr += enc->minBytesPerChar) { - c = toAscii(enc, ptr, end); - if (c == open) - break; - if (!(ASCII_a <= c && c <= ASCII_z) - && !(ASCII_A <= c && c <= ASCII_Z) - && !(ASCII_0 <= c && c <= ASCII_9) - && c != ASCII_PERIOD - && c != ASCII_MINUS - && c != ASCII_UNDERSCORE) { - *nextTokPtr = ptr; - return 0; - } - } - *nextTokPtr = ptr + enc->minBytesPerChar; - return 1; -} - -static const char KW_version[] = { - ASCII_v, ASCII_e, ASCII_r, ASCII_s, ASCII_i, ASCII_o, ASCII_n, '\0' -}; - -static const char KW_encoding[] = { - ASCII_e, ASCII_n, ASCII_c, ASCII_o, ASCII_d, ASCII_i, ASCII_n, ASCII_g, '\0' -}; - -static const char KW_standalone[] = { - ASCII_s, ASCII_t, ASCII_a, ASCII_n, ASCII_d, ASCII_a, ASCII_l, ASCII_o, ASCII_n, ASCII_e, '\0' -}; - -static const char KW_yes[] = { - ASCII_y, ASCII_e, ASCII_s, '\0' -}; - -static const char KW_no[] = { - ASCII_n, ASCII_o, '\0' -}; - -static -int doParseXmlDecl(const ENCODING *(*encodingFinder)(const ENCODING *, - const char *, - const char *), - int isGeneralTextEntity, - const ENCODING *enc, - const char *ptr, - const char *end, - const char **badPtr, - const char **versionPtr, - const char **versionEndPtr, - const char **encodingName, - const ENCODING **encoding, - int *standalone) -{ - const char *val = 0; - const char *name = 0; - const char *nameEnd = 0; - ptr += 5 * enc->minBytesPerChar; - end -= 2 * enc->minBytesPerChar; - if (!parsePseudoAttribute(enc, ptr, end, &name, &nameEnd, &val, &ptr) || !name) { - *badPtr = ptr; - return 0; - } - if (!XmlNameMatchesAscii(enc, name, nameEnd, KW_version)) { - if (!isGeneralTextEntity) { - *badPtr = name; - return 0; - } - } - else { - if (versionPtr) - *versionPtr = val; - if (versionEndPtr) - *versionEndPtr = ptr; - if (!parsePseudoAttribute(enc, ptr, end, &name, &nameEnd, &val, &ptr)) { - *badPtr = ptr; - return 0; - } - if (!name) { - if (isGeneralTextEntity) { - /* a TextDecl must have an EncodingDecl */ - *badPtr = ptr; - return 0; - } - return 1; - } - } - if (XmlNameMatchesAscii(enc, name, nameEnd, KW_encoding)) { - int c = toAscii(enc, val, end); - if (!(ASCII_a <= c && c <= ASCII_z) && !(ASCII_A <= c && c <= ASCII_Z)) { - *badPtr = val; - return 0; - } - if (encodingName) - *encodingName = val; - if (encoding) - *encoding = encodingFinder(enc, val, ptr - enc->minBytesPerChar); - if (!parsePseudoAttribute(enc, ptr, end, &name, &nameEnd, &val, &ptr)) { - *badPtr = ptr; - return 0; - } - if (!name) - return 1; - } - if (!XmlNameMatchesAscii(enc, name, nameEnd, KW_standalone) || isGeneralTextEntity) { - *badPtr = name; - return 0; - } - if (XmlNameMatchesAscii(enc, val, ptr - enc->minBytesPerChar, KW_yes)) { - if (standalone) - *standalone = 1; - } - else if (XmlNameMatchesAscii(enc, val, ptr - enc->minBytesPerChar, KW_no)) { - if (standalone) - *standalone = 0; - } - else { - *badPtr = val; - return 0; - } - while (isSpace(toAscii(enc, ptr, end))) - ptr += enc->minBytesPerChar; - if (ptr != end) { - *badPtr = ptr; - return 0; - } - return 1; -} - -static -int checkCharRefNumber(int result) -{ - switch (result >> 8) { - case 0xD8: case 0xD9: case 0xDA: case 0xDB: - case 0xDC: case 0xDD: case 0xDE: case 0xDF: - return -1; - case 0: - if (latin1_encoding.type[result] == BT_NONXML) - return -1; - break; - case 0xFF: - if (result == 0xFFFE || result == 0xFFFF) - return -1; - break; - } - return result; -} - -int XmlUtf8Encode(int c, char *buf) -{ - enum { - /* minN is minimum legal resulting value for N byte sequence */ - min2 = 0x80, - min3 = 0x800, - min4 = 0x10000 - }; - - if (c < 0) - return 0; - if (c < min2) { - buf[0] = (c | UTF8_cval1); - return 1; - } - if (c < min3) { - buf[0] = ((c >> 6) | UTF8_cval2); - buf[1] = ((c & 0x3f) | 0x80); - return 2; - } - if (c < min4) { - buf[0] = ((c >> 12) | UTF8_cval3); - buf[1] = (((c >> 6) & 0x3f) | 0x80); - buf[2] = ((c & 0x3f) | 0x80); - return 3; - } - if (c < 0x110000) { - buf[0] = ((c >> 18) | UTF8_cval4); - buf[1] = (((c >> 12) & 0x3f) | 0x80); - buf[2] = (((c >> 6) & 0x3f) | 0x80); - buf[3] = ((c & 0x3f) | 0x80); - return 4; - } - return 0; -} - -int XmlUtf16Encode(int charNum, unsigned short *buf) -{ - if (charNum < 0) - return 0; - if (charNum < 0x10000) { - buf[0] = charNum; - return 1; - } - if (charNum < 0x110000) { - charNum -= 0x10000; - buf[0] = (charNum >> 10) + 0xD800; - buf[1] = (charNum & 0x3FF) + 0xDC00; - return 2; - } - return 0; -} - -struct unknown_encoding { - struct normal_encoding normal; - int (*convert)(void *userData, const char *p); - void *userData; - unsigned short utf16[256]; - char utf8[256][4]; -}; - -int XmlSizeOfUnknownEncoding(void) -{ - return sizeof(struct unknown_encoding); -} - -static -int unknown_isName(const ENCODING *enc, const char *p) -{ - int c = ((const struct unknown_encoding *)enc) - ->convert(((const struct unknown_encoding *)enc)->userData, p); - if (c & ~0xFFFF) - return 0; - return UCS2_GET_NAMING(namePages, c >> 8, c & 0xFF); -} - -static -int unknown_isNmstrt(const ENCODING *enc, const char *p) -{ - int c = ((const struct unknown_encoding *)enc) - ->convert(((const struct unknown_encoding *)enc)->userData, p); - if (c & ~0xFFFF) - return 0; - return UCS2_GET_NAMING(nmstrtPages, c >> 8, c & 0xFF); -} - -static -int unknown_isInvalid(const ENCODING *enc, const char *p) -{ - int c = ((const struct unknown_encoding *)enc) - ->convert(((const struct unknown_encoding *)enc)->userData, p); - return (c & ~0xFFFF) || checkCharRefNumber(c) < 0; -} - -static -void unknown_toUtf8(const ENCODING *enc, - const char **fromP, const char *fromLim, - char **toP, const char *toLim) -{ - char buf[XML_UTF8_ENCODE_MAX] = {0}; - for (;;) { - const char *utf8; - int n; - if (*fromP == fromLim) - break; - utf8 = ((const struct unknown_encoding *)enc)->utf8[(unsigned char)**fromP]; - n = *utf8++; - if (n == 0) { - int c = ((const struct unknown_encoding *)enc) - ->convert(((const struct unknown_encoding *)enc)->userData, *fromP); - n = XmlUtf8Encode(c, buf); - if (n > toLim - *toP) - break; - utf8 = buf; - *fromP += ((const struct normal_encoding *)enc)->type[(unsigned char)**fromP] - - (BT_LEAD2 - 2); - } - else { - if (n > toLim - *toP) - break; - (*fromP)++; - } - do { - *(*toP)++ = *utf8++; - } while (--n != 0); - } -} - -static -void unknown_toUtf16(const ENCODING *enc, - const char **fromP, const char *fromLim, - unsigned short **toP, const unsigned short *toLim) -{ - while (*fromP != fromLim && *toP != toLim) { - unsigned short c - = ((const struct unknown_encoding *)enc)->utf16[(unsigned char)**fromP]; - if (c == 0) { - c = (unsigned short)((const struct unknown_encoding *)enc) - ->convert(((const struct unknown_encoding *)enc)->userData, *fromP); - *fromP += ((const struct normal_encoding *)enc)->type[(unsigned char)**fromP] - - (BT_LEAD2 - 2); - } - else - (*fromP)++; - *(*toP)++ = c; - } -} - -ENCODING * -XmlInitUnknownEncoding(void *mem, - int *table, - int (*convert)(void *userData, const char *p), - void *userData) -{ - int i; - struct unknown_encoding *e = mem; - for (i = 0; i < (int)sizeof(struct normal_encoding); i++) - ((char *)mem)[i] = ((char *)&latin1_encoding)[i]; - for (i = 0; i < 128; i++) - if (latin1_encoding.type[i] != BT_OTHER - && latin1_encoding.type[i] != BT_NONXML - && table[i] != i) - return 0; - for (i = 0; i < 256; i++) { - int c = table[i]; - if (c == -1) { - e->normal.type[i] = BT_MALFORM; - /* This shouldn't really get used. */ - e->utf16[i] = 0xFFFF; - e->utf8[i][0] = 1; - e->utf8[i][1] = 0; - } - else if (c < 0) { - if (c < -4) - return 0; - e->normal.type[i] = BT_LEAD2 - (c + 2); - e->utf8[i][0] = 0; - e->utf16[i] = 0; - } - else if (c < 0x80) { - if (latin1_encoding.type[c] != BT_OTHER - && latin1_encoding.type[c] != BT_NONXML - && c != i) - return 0; - e->normal.type[i] = latin1_encoding.type[c]; - e->utf8[i][0] = 1; - e->utf8[i][1] = (char)c; - e->utf16[i] = c == 0 ? 0xFFFF : c; - } - else if (checkCharRefNumber(c) < 0) { - e->normal.type[i] = BT_NONXML; - /* This shouldn't really get used. */ - e->utf16[i] = 0xFFFF; - e->utf8[i][0] = 1; - e->utf8[i][1] = 0; - } - else { - if (c > 0xFFFF) - return 0; - if (UCS2_GET_NAMING(nmstrtPages, c >> 8, c & 0xff)) - e->normal.type[i] = BT_NMSTRT; - else if (UCS2_GET_NAMING(namePages, c >> 8, c & 0xff)) - e->normal.type[i] = BT_NAME; - else - e->normal.type[i] = BT_OTHER; - e->utf8[i][0] = (char)XmlUtf8Encode(c, e->utf8[i] + 1); - e->utf16[i] = c; - } - } - e->userData = userData; - e->convert = convert; - if (convert) { - e->normal.isName2 = unknown_isName; - e->normal.isName3 = unknown_isName; - e->normal.isName4 = unknown_isName; - e->normal.isNmstrt2 = unknown_isNmstrt; - e->normal.isNmstrt3 = unknown_isNmstrt; - e->normal.isNmstrt4 = unknown_isNmstrt; - e->normal.isInvalid2 = unknown_isInvalid; - e->normal.isInvalid3 = unknown_isInvalid; - e->normal.isInvalid4 = unknown_isInvalid; - } - e->normal.enc.utf8Convert = unknown_toUtf8; - e->normal.enc.utf16Convert = unknown_toUtf16; - return &(e->normal.enc); -} - -/* If this enumeration is changed, getEncodingIndex and encodings -must also be changed. */ -enum { - UNKNOWN_ENC = -1, - ISO_8859_1_ENC = 0, - US_ASCII_ENC, - UTF_8_ENC, - UTF_16_ENC, - UTF_16BE_ENC, - UTF_16LE_ENC, - /* must match encodingNames up to here */ - NO_ENC -}; - -static const char KW_ISO_8859_1[] = { - ASCII_I, ASCII_S, ASCII_O, ASCII_MINUS, ASCII_8, ASCII_8, ASCII_5, ASCII_9, ASCII_MINUS, ASCII_1, '\0' -}; -static const char KW_US_ASCII[] = { - ASCII_U, ASCII_S, ASCII_MINUS, ASCII_A, ASCII_S, ASCII_C, ASCII_I, ASCII_I, '\0' -}; -static const char KW_UTF_8[] = { - ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_8, '\0' -}; -static const char KW_UTF_16[] = { - ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_1, ASCII_6, '\0' -}; -static const char KW_UTF_16BE[] = { - ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_1, ASCII_6, ASCII_B, ASCII_E, '\0' -}; -static const char KW_UTF_16LE[] = { - ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_1, ASCII_6, ASCII_L, ASCII_E, '\0' -}; - -static -int getEncodingIndex(const char *name) -{ - static const char *encodingNames[] = { - KW_ISO_8859_1, - KW_US_ASCII, - KW_UTF_8, - KW_UTF_16, - KW_UTF_16BE, - KW_UTF_16LE, - }; - int i; - if (name == 0) - return NO_ENC; - for (i = 0; i < (int)(sizeof(encodingNames)/sizeof(encodingNames[0])); i++) - if (streqci(name, encodingNames[i])) - return i; - return UNKNOWN_ENC; -} - -/* For binary compatibility, we store the index of the encoding specified -at initialization in the isUtf16 member. */ - -#define INIT_ENC_INDEX(enc) ((int)(enc)->initEnc.isUtf16) -#define SET_INIT_ENC_INDEX(enc, i) ((enc)->initEnc.isUtf16 = (char)i) - -/* This is what detects the encoding. -encodingTable maps from encoding indices to encodings; -INIT_ENC_INDEX(enc) is the index of the external (protocol) specified encoding; -state is XML_CONTENT_STATE if we're parsing an external text entity, -and XML_PROLOG_STATE otherwise. -*/ - - -static -int initScan(const ENCODING **encodingTable, - const INIT_ENCODING *enc, - int state, - const char *ptr, - const char *end, - const char **nextTokPtr) -{ - const ENCODING **encPtr; - - if (ptr == end) - return XML_TOK_NONE; - encPtr = enc->encPtr; - if (ptr + 1 == end) { - /* only a single byte available for auto-detection */ -#ifndef XML_DTD /* FIXME */ - /* a well-formed document entity must have more than one byte */ - if (state != XML_CONTENT_STATE) - return XML_TOK_PARTIAL; -#endif - /* so we're parsing an external text entity... */ - /* if UTF-16 was externally specified, then we need at least 2 bytes */ - switch (INIT_ENC_INDEX(enc)) { - case UTF_16_ENC: - case UTF_16LE_ENC: - case UTF_16BE_ENC: - return XML_TOK_PARTIAL; - } - switch ((unsigned char)*ptr) { - case 0xFE: - case 0xFF: - case 0xEF: /* possibly first byte of UTF-8 BOM */ - if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC - && state == XML_CONTENT_STATE) - break; - /* fall through */ - case 0x00: - case 0x3C: - return XML_TOK_PARTIAL; - } - } - else { - switch (((unsigned char)ptr[0] << 8) | (unsigned char)ptr[1]) { - case 0xFEFF: - if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC - && state == XML_CONTENT_STATE) - break; - *nextTokPtr = ptr + 2; - *encPtr = encodingTable[UTF_16BE_ENC]; - return XML_TOK_BOM; - /* 00 3C is handled in the default case */ - case 0x3C00: - if ((INIT_ENC_INDEX(enc) == UTF_16BE_ENC - || INIT_ENC_INDEX(enc) == UTF_16_ENC) - && state == XML_CONTENT_STATE) - break; - *encPtr = encodingTable[UTF_16LE_ENC]; - return XmlTok(*encPtr, state, ptr, end, nextTokPtr); - case 0xFFFE: - if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC - && state == XML_CONTENT_STATE) - break; - *nextTokPtr = ptr + 2; - *encPtr = encodingTable[UTF_16LE_ENC]; - return XML_TOK_BOM; - case 0xEFBB: - /* Maybe a UTF-8 BOM (EF BB BF) */ - /* If there's an explicitly specified (external) encoding - of ISO-8859-1 or some flavour of UTF-16 - and this is an external text entity, - don't look for the BOM, - because it might be a legal data. */ - if (state == XML_CONTENT_STATE) { - int e = INIT_ENC_INDEX(enc); - if (e == ISO_8859_1_ENC || e == UTF_16BE_ENC || e == UTF_16LE_ENC || e == UTF_16_ENC) - break; - } - if (ptr + 2 == end) - return XML_TOK_PARTIAL; - if ((unsigned char)ptr[2] == 0xBF) { - *nextTokPtr = ptr + 3; - *encPtr = encodingTable[UTF_8_ENC]; - return XML_TOK_BOM; - } - break; - default: - if (ptr[0] == '\0') { - /* 0 isn't a legal data character. Furthermore a document entity can only - start with ASCII characters. So the only way this can fail to be big-endian - UTF-16 if it it's an external parsed general entity that's labelled as - UTF-16LE. */ - if (state == XML_CONTENT_STATE && INIT_ENC_INDEX(enc) == UTF_16LE_ENC) - break; - *encPtr = encodingTable[UTF_16BE_ENC]; - return XmlTok(*encPtr, state, ptr, end, nextTokPtr); - } - else if (ptr[1] == '\0') { - /* We could recover here in the case: - - parsing an external entity - - second byte is 0 - - no externally specified encoding - - no encoding declaration - by assuming UTF-16LE. But we don't, because this would mean when - presented just with a single byte, we couldn't reliably determine - whether we needed further bytes. */ - if (state == XML_CONTENT_STATE) - break; - *encPtr = encodingTable[UTF_16LE_ENC]; - return XmlTok(*encPtr, state, ptr, end, nextTokPtr); - } - break; - } - } - *encPtr = encodingTable[INIT_ENC_INDEX(enc)]; - return XmlTok(*encPtr, state, ptr, end, nextTokPtr); -} - - -#define NS(x) x -#define ns(x) x -#include "xmltok_ns.c" -#undef NS -#undef ns - -#ifdef XML_NS - -#define NS(x) x ## NS -#define ns(x) x ## _ns - -#include "xmltok_ns.c" - -#undef NS -#undef ns - -ENCODING * -XmlInitUnknownEncodingNS(void *mem, - int *table, - int (*convert)(void *userData, const char *p), - void *userData) -{ - ENCODING *enc = XmlInitUnknownEncoding(mem, table, convert, userData); - if (enc) - ((struct normal_encoding *)enc)->type[ASCII_COLON] = BT_COLON; - return enc; -} - -#endif /* XML_NS */ diff --git a/libs/apr-util/xml/expat/lib/xmltok.h b/libs/apr-util/xml/expat/lib/xmltok.h deleted file mode 100644 index 8b02324c38..0000000000 --- a/libs/apr-util/xml/expat/lib/xmltok.h +++ /dev/null @@ -1,299 +0,0 @@ -/* -Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd -See the file COPYING for copying permission. -*/ - -#ifndef XmlTok_INCLUDED -#define XmlTok_INCLUDED 1 - -#ifdef __cplusplus -extern "C" { -#endif - -/* The following token may be returned by XmlContentTok */ -#define XML_TOK_TRAILING_RSQB -5 /* ] or ]] at the end of the scan; might be start of - illegal ]]> sequence */ -/* The following tokens may be returned by both XmlPrologTok and XmlContentTok */ -#define XML_TOK_NONE -4 /* The string to be scanned is empty */ -#define XML_TOK_TRAILING_CR -3 /* A CR at the end of the scan; - might be part of CRLF sequence */ -#define XML_TOK_PARTIAL_CHAR -2 /* only part of a multibyte sequence */ -#define XML_TOK_PARTIAL -1 /* only part of a token */ -#define XML_TOK_INVALID 0 - -/* The following tokens are returned by XmlContentTok; some are also - returned by XmlAttributeValueTok, XmlEntityTok, XmlCdataSectionTok */ - -#define XML_TOK_START_TAG_WITH_ATTS 1 -#define XML_TOK_START_TAG_NO_ATTS 2 -#define XML_TOK_EMPTY_ELEMENT_WITH_ATTS 3 /* empty element tag */ -#define XML_TOK_EMPTY_ELEMENT_NO_ATTS 4 -#define XML_TOK_END_TAG 5 -#define XML_TOK_DATA_CHARS 6 -#define XML_TOK_DATA_NEWLINE 7 -#define XML_TOK_CDATA_SECT_OPEN 8 -#define XML_TOK_ENTITY_REF 9 -#define XML_TOK_CHAR_REF 10 /* numeric character reference */ - -/* The following tokens may be returned by both XmlPrologTok and XmlContentTok */ -#define XML_TOK_PI 11 /* processing instruction */ -#define XML_TOK_XML_DECL 12 /* XML decl or text decl */ -#define XML_TOK_COMMENT 13 -#define XML_TOK_BOM 14 /* Byte order mark */ - -/* The following tokens are returned only by XmlPrologTok */ -#define XML_TOK_PROLOG_S 15 -#define XML_TOK_DECL_OPEN 16 /* */ -#define XML_TOK_NAME 18 -#define XML_TOK_NMTOKEN 19 -#define XML_TOK_POUND_NAME 20 /* #name */ -#define XML_TOK_OR 21 /* | */ -#define XML_TOK_PERCENT 22 -#define XML_TOK_OPEN_PAREN 23 -#define XML_TOK_CLOSE_PAREN 24 -#define XML_TOK_OPEN_BRACKET 25 -#define XML_TOK_CLOSE_BRACKET 26 -#define XML_TOK_LITERAL 27 -#define XML_TOK_PARAM_ENTITY_REF 28 -#define XML_TOK_INSTANCE_START 29 - -/* The following occur only in element type declarations */ -#define XML_TOK_NAME_QUESTION 30 /* name? */ -#define XML_TOK_NAME_ASTERISK 31 /* name* */ -#define XML_TOK_NAME_PLUS 32 /* name+ */ -#define XML_TOK_COND_SECT_OPEN 33 /* */ -#define XML_TOK_CLOSE_PAREN_QUESTION 35 /* )? */ -#define XML_TOK_CLOSE_PAREN_ASTERISK 36 /* )* */ -#define XML_TOK_CLOSE_PAREN_PLUS 37 /* )+ */ -#define XML_TOK_COMMA 38 - -/* The following token is returned only by XmlAttributeValueTok */ -#define XML_TOK_ATTRIBUTE_VALUE_S 39 - -/* The following token is returned only by XmlCdataSectionTok */ -#define XML_TOK_CDATA_SECT_CLOSE 40 - -/* With namespace processing this is returned by XmlPrologTok - for a name with a colon. */ -#define XML_TOK_PREFIXED_NAME 41 - -#ifdef XML_DTD -#define XML_TOK_IGNORE_SECT 42 -#endif /* XML_DTD */ - -#ifdef XML_DTD -#define XML_N_STATES 4 -#else /* not XML_DTD */ -#define XML_N_STATES 3 -#endif /* not XML_DTD */ - -#define XML_PROLOG_STATE 0 -#define XML_CONTENT_STATE 1 -#define XML_CDATA_SECTION_STATE 2 -#ifdef XML_DTD -#define XML_IGNORE_SECTION_STATE 3 -#endif /* XML_DTD */ - -#define XML_N_LITERAL_TYPES 2 -#define XML_ATTRIBUTE_VALUE_LITERAL 0 -#define XML_ENTITY_VALUE_LITERAL 1 - -/* The size of the buffer passed to XmlUtf8Encode must be at least this. */ -#define XML_UTF8_ENCODE_MAX 4 -/* The size of the buffer passed to XmlUtf16Encode must be at least this. */ -#define XML_UTF16_ENCODE_MAX 2 - -typedef struct position { - /* first line and first column are 0 not 1 */ - unsigned long lineNumber; - unsigned long columnNumber; -} POSITION; - -typedef struct { - const char *name; - const char *valuePtr; - const char *valueEnd; - char normalized; -} ATTRIBUTE; - -struct encoding; -typedef struct encoding ENCODING; - -struct encoding { - int (*scanners[XML_N_STATES])(const ENCODING *, - const char *, - const char *, - const char **); - int (*literalScanners[XML_N_LITERAL_TYPES])(const ENCODING *, - const char *, - const char *, - const char **); - int (*sameName)(const ENCODING *, - const char *, const char *); - int (*nameMatchesAscii)(const ENCODING *, - const char *, const char *, const char *); - int (*nameLength)(const ENCODING *, const char *); - const char *(*skipS)(const ENCODING *, const char *); - int (*getAtts)(const ENCODING *enc, const char *ptr, - int attsMax, ATTRIBUTE *atts); - int (*charRefNumber)(const ENCODING *enc, const char *ptr); - int (*predefinedEntityName)(const ENCODING *, const char *, const char *); - void (*updatePosition)(const ENCODING *, - const char *ptr, - const char *end, - POSITION *); - int (*isPublicId)(const ENCODING *enc, const char *ptr, const char *end, - const char **badPtr); - void (*utf8Convert)(const ENCODING *enc, - const char **fromP, - const char *fromLim, - char **toP, - const char *toLim); - void (*utf16Convert)(const ENCODING *enc, - const char **fromP, - const char *fromLim, - unsigned short **toP, - const unsigned short *toLim); - int minBytesPerChar; - char isUtf8; - char isUtf16; -}; - -/* -Scan the string starting at ptr until the end of the next complete token, -but do not scan past eptr. Return an integer giving the type of token. - -Return XML_TOK_NONE when ptr == eptr; nextTokPtr will not be set. - -Return XML_TOK_PARTIAL when the string does not contain a complete token; -nextTokPtr will not be set. - -Return XML_TOK_INVALID when the string does not start a valid token; nextTokPtr -will be set to point to the character which made the token invalid. - -Otherwise the string starts with a valid token; nextTokPtr will be set to point -to the character following the end of that token. - -Each data character counts as a single token, but adjacent data characters -may be returned together. Similarly for characters in the prolog outside -literals, comments and processing instructions. -*/ - - -#define XmlTok(enc, state, ptr, end, nextTokPtr) \ - (((enc)->scanners[state])(enc, ptr, end, nextTokPtr)) - -#define XmlPrologTok(enc, ptr, end, nextTokPtr) \ - XmlTok(enc, XML_PROLOG_STATE, ptr, end, nextTokPtr) - -#define XmlContentTok(enc, ptr, end, nextTokPtr) \ - XmlTok(enc, XML_CONTENT_STATE, ptr, end, nextTokPtr) - -#define XmlCdataSectionTok(enc, ptr, end, nextTokPtr) \ - XmlTok(enc, XML_CDATA_SECTION_STATE, ptr, end, nextTokPtr) - -#ifdef XML_DTD - -#define XmlIgnoreSectionTok(enc, ptr, end, nextTokPtr) \ - XmlTok(enc, XML_IGNORE_SECTION_STATE, ptr, end, nextTokPtr) - -#endif /* XML_DTD */ - -/* This is used for performing a 2nd-level tokenization on -the content of a literal that has already been returned by XmlTok. */ - -#define XmlLiteralTok(enc, literalType, ptr, end, nextTokPtr) \ - (((enc)->literalScanners[literalType])(enc, ptr, end, nextTokPtr)) - -#define XmlAttributeValueTok(enc, ptr, end, nextTokPtr) \ - XmlLiteralTok(enc, XML_ATTRIBUTE_VALUE_LITERAL, ptr, end, nextTokPtr) - -#define XmlEntityValueTok(enc, ptr, end, nextTokPtr) \ - XmlLiteralTok(enc, XML_ENTITY_VALUE_LITERAL, ptr, end, nextTokPtr) - -#define XmlSameName(enc, ptr1, ptr2) (((enc)->sameName)(enc, ptr1, ptr2)) - -#define XmlNameMatchesAscii(enc, ptr1, end1, ptr2) \ - (((enc)->nameMatchesAscii)(enc, ptr1, end1, ptr2)) - -#define XmlNameLength(enc, ptr) \ - (((enc)->nameLength)(enc, ptr)) - -#define XmlSkipS(enc, ptr) \ - (((enc)->skipS)(enc, ptr)) - -#define XmlGetAttributes(enc, ptr, attsMax, atts) \ - (((enc)->getAtts)(enc, ptr, attsMax, atts)) - -#define XmlCharRefNumber(enc, ptr) \ - (((enc)->charRefNumber)(enc, ptr)) - -#define XmlPredefinedEntityName(enc, ptr, end) \ - (((enc)->predefinedEntityName)(enc, ptr, end)) - -#define XmlUpdatePosition(enc, ptr, end, pos) \ - (((enc)->updatePosition)(enc, ptr, end, pos)) - -#define XmlIsPublicId(enc, ptr, end, badPtr) \ - (((enc)->isPublicId)(enc, ptr, end, badPtr)) - -#define XmlUtf8Convert(enc, fromP, fromLim, toP, toLim) \ - (((enc)->utf8Convert)(enc, fromP, fromLim, toP, toLim)) - -#define XmlUtf16Convert(enc, fromP, fromLim, toP, toLim) \ - (((enc)->utf16Convert)(enc, fromP, fromLim, toP, toLim)) - -typedef struct { - ENCODING initEnc; - const ENCODING **encPtr; -} INIT_ENCODING; - -int XmlParseXmlDecl(int isGeneralTextEntity, - const ENCODING *enc, - const char *ptr, - const char *end, - const char **badPtr, - const char **versionPtr, - const char **versionEndPtr, - const char **encodingNamePtr, - const ENCODING **namedEncodingPtr, - int *standalonePtr); - -int XmlInitEncoding(INIT_ENCODING *, const ENCODING **, const char *name); -const ENCODING *XmlGetUtf8InternalEncoding(void); -const ENCODING *XmlGetUtf16InternalEncoding(void); -int XmlUtf8Encode(int charNumber, char *buf); -int XmlUtf16Encode(int charNumber, unsigned short *buf); - -int XmlSizeOfUnknownEncoding(void); -ENCODING * -XmlInitUnknownEncoding(void *mem, - int *table, - int (*conv)(void *userData, const char *p), - void *userData); - -int XmlParseXmlDeclNS(int isGeneralTextEntity, - const ENCODING *enc, - const char *ptr, - const char *end, - const char **badPtr, - const char **versionPtr, - const char **versionEndPtr, - const char **encodingNamePtr, - const ENCODING **namedEncodingPtr, - int *standalonePtr); -int XmlInitEncodingNS(INIT_ENCODING *, const ENCODING **, const char *name); -const ENCODING *XmlGetUtf8InternalEncodingNS(void); -const ENCODING *XmlGetUtf16InternalEncodingNS(void); -ENCODING * -XmlInitUnknownEncodingNS(void *mem, - int *table, - int (*conv)(void *userData, const char *p), - void *userData); -#ifdef __cplusplus -} -#endif - -#endif /* not XmlTok_INCLUDED */ diff --git a/libs/apr-util/xml/expat/lib/xmltok_impl.c b/libs/apr-util/xml/expat/lib/xmltok_impl.c deleted file mode 100644 index 36d2065ce3..0000000000 --- a/libs/apr-util/xml/expat/lib/xmltok_impl.c +++ /dev/null @@ -1,1768 +0,0 @@ -/* -Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd -See the file COPYING for copying permission. -*/ - -#ifndef IS_INVALID_CHAR -#define IS_INVALID_CHAR(enc, ptr, n) (0) -#endif - -#define INVALID_LEAD_CASE(n, ptr, nextTokPtr) \ - case BT_LEAD ## n: \ - if (end - ptr < n) \ - return XML_TOK_PARTIAL_CHAR; \ - if (IS_INVALID_CHAR(enc, ptr, n)) { \ - *(nextTokPtr) = (ptr); \ - return XML_TOK_INVALID; \ - } \ - ptr += n; \ - break; - -#define INVALID_CASES(ptr, nextTokPtr) \ - INVALID_LEAD_CASE(2, ptr, nextTokPtr) \ - INVALID_LEAD_CASE(3, ptr, nextTokPtr) \ - INVALID_LEAD_CASE(4, ptr, nextTokPtr) \ - case BT_NONXML: \ - case BT_MALFORM: \ - case BT_TRAIL: \ - *(nextTokPtr) = (ptr); \ - return XML_TOK_INVALID; - -#define CHECK_NAME_CASE(n, enc, ptr, end, nextTokPtr) \ - case BT_LEAD ## n: \ - if (end - ptr < n) \ - return XML_TOK_PARTIAL_CHAR; \ - if (!IS_NAME_CHAR(enc, ptr, n)) { \ - *nextTokPtr = ptr; \ - return XML_TOK_INVALID; \ - } \ - ptr += n; \ - break; - -#define CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) \ - case BT_NONASCII: \ - if (!IS_NAME_CHAR_MINBPC(enc, ptr)) { \ - *nextTokPtr = ptr; \ - return XML_TOK_INVALID; \ - } \ - case BT_NMSTRT: \ - case BT_HEX: \ - case BT_DIGIT: \ - case BT_NAME: \ - case BT_MINUS: \ - ptr += MINBPC(enc); \ - break; \ - CHECK_NAME_CASE(2, enc, ptr, end, nextTokPtr) \ - CHECK_NAME_CASE(3, enc, ptr, end, nextTokPtr) \ - CHECK_NAME_CASE(4, enc, ptr, end, nextTokPtr) - -#define CHECK_NMSTRT_CASE(n, enc, ptr, end, nextTokPtr) \ - case BT_LEAD ## n: \ - if (end - ptr < n) \ - return XML_TOK_PARTIAL_CHAR; \ - if (!IS_NMSTRT_CHAR(enc, ptr, n)) { \ - *nextTokPtr = ptr; \ - return XML_TOK_INVALID; \ - } \ - ptr += n; \ - break; - -#define CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) \ - case BT_NONASCII: \ - if (!IS_NMSTRT_CHAR_MINBPC(enc, ptr)) { \ - *nextTokPtr = ptr; \ - return XML_TOK_INVALID; \ - } \ - case BT_NMSTRT: \ - case BT_HEX: \ - ptr += MINBPC(enc); \ - break; \ - CHECK_NMSTRT_CASE(2, enc, ptr, end, nextTokPtr) \ - CHECK_NMSTRT_CASE(3, enc, ptr, end, nextTokPtr) \ - CHECK_NMSTRT_CASE(4, enc, ptr, end, nextTokPtr) - -#ifndef PREFIX -#define PREFIX(ident) ident -#endif - -/* ptr points to character following " */ - switch (BYTE_TYPE(enc, ptr + MINBPC(enc))) { - case BT_S: case BT_CR: case BT_LF: case BT_PERCNT: - *nextTokPtr = ptr; - return XML_TOK_INVALID; - } - /* fall through */ - case BT_S: case BT_CR: case BT_LF: - *nextTokPtr = ptr; - return XML_TOK_DECL_OPEN; - case BT_NMSTRT: - case BT_HEX: - ptr += MINBPC(enc); - break; - default: - *nextTokPtr = ptr; - return XML_TOK_INVALID; - } - } - return XML_TOK_PARTIAL; -} - -static -int PREFIX(checkPiTarget)(const ENCODING *enc, const char *ptr, const char *end, int *tokPtr) -{ - int upper = 0; - *tokPtr = XML_TOK_PI; - if (end - ptr != MINBPC(enc)*3) - return 1; - switch (BYTE_TO_ASCII(enc, ptr)) { - case ASCII_x: - break; - case ASCII_X: - upper = 1; - break; - default: - return 1; - } - ptr += MINBPC(enc); - switch (BYTE_TO_ASCII(enc, ptr)) { - case ASCII_m: - break; - case ASCII_M: - upper = 1; - break; - default: - return 1; - } - ptr += MINBPC(enc); - switch (BYTE_TO_ASCII(enc, ptr)) { - case ASCII_l: - break; - case ASCII_L: - upper = 1; - break; - default: - return 1; - } - if (upper) - return 0; - *tokPtr = XML_TOK_XML_DECL; - return 1; -} - -/* ptr points to character following " 1) { - size_t n = end - ptr; - if (n & (MINBPC(enc) - 1)) { - n &= ~(MINBPC(enc) - 1); - if (n == 0) - return XML_TOK_PARTIAL; - end = ptr + n; - } - } - switch (BYTE_TYPE(enc, ptr)) { - case BT_RSQB: - ptr += MINBPC(enc); - if (ptr == end) - return XML_TOK_PARTIAL; - if (!CHAR_MATCHES(enc, ptr, ASCII_RSQB)) - break; - ptr += MINBPC(enc); - if (ptr == end) - return XML_TOK_PARTIAL; - if (!CHAR_MATCHES(enc, ptr, ASCII_GT)) { - ptr -= MINBPC(enc); - break; - } - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_CDATA_SECT_CLOSE; - case BT_CR: - ptr += MINBPC(enc); - if (ptr == end) - return XML_TOK_PARTIAL; - if (BYTE_TYPE(enc, ptr) == BT_LF) - ptr += MINBPC(enc); - *nextTokPtr = ptr; - return XML_TOK_DATA_NEWLINE; - case BT_LF: - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_DATA_NEWLINE; - INVALID_CASES(ptr, nextTokPtr) - default: - ptr += MINBPC(enc); - break; - } - while (ptr != end) { - switch (BYTE_TYPE(enc, ptr)) { -#define LEAD_CASE(n) \ - case BT_LEAD ## n: \ - if (end - ptr < n || IS_INVALID_CHAR(enc, ptr, n)) { \ - *nextTokPtr = ptr; \ - return XML_TOK_DATA_CHARS; \ - } \ - ptr += n; \ - break; - LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) -#undef LEAD_CASE - case BT_NONXML: - case BT_MALFORM: - case BT_TRAIL: - case BT_CR: - case BT_LF: - case BT_RSQB: - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; - default: - ptr += MINBPC(enc); - break; - } - } - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; -} - -/* ptr points to character following " 1) { - size_t n = end - ptr; - if (n & (MINBPC(enc) - 1)) { - n &= ~(MINBPC(enc) - 1); - if (n == 0) - return XML_TOK_PARTIAL; - end = ptr + n; - } - } - switch (BYTE_TYPE(enc, ptr)) { - case BT_LT: - return PREFIX(scanLt)(enc, ptr + MINBPC(enc), end, nextTokPtr); - case BT_AMP: - return PREFIX(scanRef)(enc, ptr + MINBPC(enc), end, nextTokPtr); - case BT_CR: - ptr += MINBPC(enc); - if (ptr == end) - return XML_TOK_TRAILING_CR; - if (BYTE_TYPE(enc, ptr) == BT_LF) - ptr += MINBPC(enc); - *nextTokPtr = ptr; - return XML_TOK_DATA_NEWLINE; - case BT_LF: - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_DATA_NEWLINE; - case BT_RSQB: - ptr += MINBPC(enc); - if (ptr == end) - return XML_TOK_TRAILING_RSQB; - if (!CHAR_MATCHES(enc, ptr, ASCII_RSQB)) - break; - ptr += MINBPC(enc); - if (ptr == end) - return XML_TOK_TRAILING_RSQB; - if (!CHAR_MATCHES(enc, ptr, ASCII_GT)) { - ptr -= MINBPC(enc); - break; - } - *nextTokPtr = ptr; - return XML_TOK_INVALID; - INVALID_CASES(ptr, nextTokPtr) - default: - ptr += MINBPC(enc); - break; - } - while (ptr != end) { - switch (BYTE_TYPE(enc, ptr)) { -#define LEAD_CASE(n) \ - case BT_LEAD ## n: \ - if (end - ptr < n || IS_INVALID_CHAR(enc, ptr, n)) { \ - *nextTokPtr = ptr; \ - return XML_TOK_DATA_CHARS; \ - } \ - ptr += n; \ - break; - LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) -#undef LEAD_CASE - case BT_RSQB: - if (ptr + MINBPC(enc) != end) { - if (!CHAR_MATCHES(enc, ptr + MINBPC(enc), ASCII_RSQB)) { - ptr += MINBPC(enc); - break; - } - if (ptr + 2*MINBPC(enc) != end) { - if (!CHAR_MATCHES(enc, ptr + 2*MINBPC(enc), ASCII_GT)) { - ptr += MINBPC(enc); - break; - } - *nextTokPtr = ptr + 2*MINBPC(enc); - return XML_TOK_INVALID; - } - } - /* fall through */ - case BT_AMP: - case BT_LT: - case BT_NONXML: - case BT_MALFORM: - case BT_TRAIL: - case BT_CR: - case BT_LF: - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; - default: - ptr += MINBPC(enc); - break; - } - } - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; -} - -/* ptr points to character following "%" */ - -static -int PREFIX(scanPercent)(const ENCODING *enc, const char *ptr, const char *end, - const char **nextTokPtr) -{ - if (ptr == end) - return XML_TOK_PARTIAL; - switch (BYTE_TYPE(enc, ptr)) { - CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) - case BT_S: case BT_LF: case BT_CR: case BT_PERCNT: - *nextTokPtr = ptr; - return XML_TOK_PERCENT; - default: - *nextTokPtr = ptr; - return XML_TOK_INVALID; - } - while (ptr != end) { - switch (BYTE_TYPE(enc, ptr)) { - CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) - case BT_SEMI: - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_PARAM_ENTITY_REF; - default: - *nextTokPtr = ptr; - return XML_TOK_INVALID; - } - } - return XML_TOK_PARTIAL; -} - -static -int PREFIX(scanPoundName)(const ENCODING *enc, const char *ptr, const char *end, - const char **nextTokPtr) -{ - if (ptr == end) - return XML_TOK_PARTIAL; - switch (BYTE_TYPE(enc, ptr)) { - CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) - default: - *nextTokPtr = ptr; - return XML_TOK_INVALID; - } - while (ptr != end) { - switch (BYTE_TYPE(enc, ptr)) { - CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) - case BT_CR: case BT_LF: case BT_S: - case BT_RPAR: case BT_GT: case BT_PERCNT: case BT_VERBAR: - *nextTokPtr = ptr; - return XML_TOK_POUND_NAME; - default: - *nextTokPtr = ptr; - return XML_TOK_INVALID; - } - } - return -XML_TOK_POUND_NAME; -} - -static -int PREFIX(scanLit)(int open, const ENCODING *enc, - const char *ptr, const char *end, - const char **nextTokPtr) -{ - while (ptr != end) { - int t = BYTE_TYPE(enc, ptr); - switch (t) { - INVALID_CASES(ptr, nextTokPtr) - case BT_QUOT: - case BT_APOS: - ptr += MINBPC(enc); - if (t != open) - break; - if (ptr == end) - return -XML_TOK_LITERAL; - *nextTokPtr = ptr; - switch (BYTE_TYPE(enc, ptr)) { - case BT_S: case BT_CR: case BT_LF: - case BT_GT: case BT_PERCNT: case BT_LSQB: - return XML_TOK_LITERAL; - default: - return XML_TOK_INVALID; - } - default: - ptr += MINBPC(enc); - break; - } - } - return XML_TOK_PARTIAL; -} - -static -int PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end, - const char **nextTokPtr) -{ - int tok; - if (ptr == end) - return XML_TOK_NONE; - if (MINBPC(enc) > 1) { - size_t n = end - ptr; - if (n & (MINBPC(enc) - 1)) { - n &= ~(MINBPC(enc) - 1); - if (n == 0) - return XML_TOK_PARTIAL; - end = ptr + n; - } - } - switch (BYTE_TYPE(enc, ptr)) { - case BT_QUOT: - return PREFIX(scanLit)(BT_QUOT, enc, ptr + MINBPC(enc), end, nextTokPtr); - case BT_APOS: - return PREFIX(scanLit)(BT_APOS, enc, ptr + MINBPC(enc), end, nextTokPtr); - case BT_LT: - { - ptr += MINBPC(enc); - if (ptr == end) - return XML_TOK_PARTIAL; - switch (BYTE_TYPE(enc, ptr)) { - case BT_EXCL: - return PREFIX(scanDecl)(enc, ptr + MINBPC(enc), end, nextTokPtr); - case BT_QUEST: - return PREFIX(scanPi)(enc, ptr + MINBPC(enc), end, nextTokPtr); - case BT_NMSTRT: - case BT_HEX: - case BT_NONASCII: - case BT_LEAD2: - case BT_LEAD3: - case BT_LEAD4: - *nextTokPtr = ptr - MINBPC(enc); - return XML_TOK_INSTANCE_START; - } - *nextTokPtr = ptr; - return XML_TOK_INVALID; - } - case BT_CR: - if (ptr + MINBPC(enc) == end) - return -XML_TOK_PROLOG_S; - /* fall through */ - case BT_S: case BT_LF: - for (;;) { - ptr += MINBPC(enc); - if (ptr == end) - break; - switch (BYTE_TYPE(enc, ptr)) { - case BT_S: case BT_LF: - break; - case BT_CR: - /* don't split CR/LF pair */ - if (ptr + MINBPC(enc) != end) - break; - /* fall through */ - default: - *nextTokPtr = ptr; - return XML_TOK_PROLOG_S; - } - } - *nextTokPtr = ptr; - return XML_TOK_PROLOG_S; - case BT_PERCNT: - return PREFIX(scanPercent)(enc, ptr + MINBPC(enc), end, nextTokPtr); - case BT_COMMA: - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_COMMA; - case BT_LSQB: - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_OPEN_BRACKET; - case BT_RSQB: - ptr += MINBPC(enc); - if (ptr == end) - return -XML_TOK_CLOSE_BRACKET; - if (CHAR_MATCHES(enc, ptr, ASCII_RSQB)) { - if (ptr + MINBPC(enc) == end) - return XML_TOK_PARTIAL; - if (CHAR_MATCHES(enc, ptr + MINBPC(enc), ASCII_GT)) { - *nextTokPtr = ptr + 2*MINBPC(enc); - return XML_TOK_COND_SECT_CLOSE; - } - } - *nextTokPtr = ptr; - return XML_TOK_CLOSE_BRACKET; - case BT_LPAR: - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_OPEN_PAREN; - case BT_RPAR: - ptr += MINBPC(enc); - if (ptr == end) - return -XML_TOK_CLOSE_PAREN; - switch (BYTE_TYPE(enc, ptr)) { - case BT_AST: - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_CLOSE_PAREN_ASTERISK; - case BT_QUEST: - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_CLOSE_PAREN_QUESTION; - case BT_PLUS: - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_CLOSE_PAREN_PLUS; - case BT_CR: case BT_LF: case BT_S: - case BT_GT: case BT_COMMA: case BT_VERBAR: - case BT_RPAR: - *nextTokPtr = ptr; - return XML_TOK_CLOSE_PAREN; - } - *nextTokPtr = ptr; - return XML_TOK_INVALID; - case BT_VERBAR: - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_OR; - case BT_GT: - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_DECL_CLOSE; - case BT_NUM: - return PREFIX(scanPoundName)(enc, ptr + MINBPC(enc), end, nextTokPtr); -#define LEAD_CASE(n) \ - case BT_LEAD ## n: \ - if (end - ptr < n) \ - return XML_TOK_PARTIAL_CHAR; \ - if (IS_NMSTRT_CHAR(enc, ptr, n)) { \ - ptr += n; \ - tok = XML_TOK_NAME; \ - break; \ - } \ - if (IS_NAME_CHAR(enc, ptr, n)) { \ - ptr += n; \ - tok = XML_TOK_NMTOKEN; \ - break; \ - } \ - *nextTokPtr = ptr; \ - return XML_TOK_INVALID; - LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) -#undef LEAD_CASE - case BT_NMSTRT: - case BT_HEX: - tok = XML_TOK_NAME; - ptr += MINBPC(enc); - break; - case BT_DIGIT: - case BT_NAME: - case BT_MINUS: -#ifdef XML_NS - case BT_COLON: -#endif - tok = XML_TOK_NMTOKEN; - ptr += MINBPC(enc); - break; - case BT_NONASCII: - if (IS_NMSTRT_CHAR_MINBPC(enc, ptr)) { - ptr += MINBPC(enc); - tok = XML_TOK_NAME; - break; - } - if (IS_NAME_CHAR_MINBPC(enc, ptr)) { - ptr += MINBPC(enc); - tok = XML_TOK_NMTOKEN; - break; - } - /* fall through */ - default: - *nextTokPtr = ptr; - return XML_TOK_INVALID; - } - while (ptr != end) { - switch (BYTE_TYPE(enc, ptr)) { - CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) - case BT_GT: case BT_RPAR: case BT_COMMA: - case BT_VERBAR: case BT_LSQB: case BT_PERCNT: - case BT_S: case BT_CR: case BT_LF: - *nextTokPtr = ptr; - return tok; -#ifdef XML_NS - case BT_COLON: - ptr += MINBPC(enc); - switch (tok) { - case XML_TOK_NAME: - if (ptr == end) - return XML_TOK_PARTIAL; - tok = XML_TOK_PREFIXED_NAME; - switch (BYTE_TYPE(enc, ptr)) { - CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) - default: - tok = XML_TOK_NMTOKEN; - break; - } - break; - case XML_TOK_PREFIXED_NAME: - tok = XML_TOK_NMTOKEN; - break; - } - break; -#endif - case BT_PLUS: - if (tok == XML_TOK_NMTOKEN) { - *nextTokPtr = ptr; - return XML_TOK_INVALID; - } - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_NAME_PLUS; - case BT_AST: - if (tok == XML_TOK_NMTOKEN) { - *nextTokPtr = ptr; - return XML_TOK_INVALID; - } - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_NAME_ASTERISK; - case BT_QUEST: - if (tok == XML_TOK_NMTOKEN) { - *nextTokPtr = ptr; - return XML_TOK_INVALID; - } - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_NAME_QUESTION; - default: - *nextTokPtr = ptr; - return XML_TOK_INVALID; - } - } - return -tok; -} - -static -int PREFIX(attributeValueTok)(const ENCODING *enc, const char *ptr, const char *end, - const char **nextTokPtr) -{ - const char *start; - if (ptr == end) - return XML_TOK_NONE; - start = ptr; - while (ptr != end) { - switch (BYTE_TYPE(enc, ptr)) { -#define LEAD_CASE(n) \ - case BT_LEAD ## n: ptr += n; break; - LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) -#undef LEAD_CASE - case BT_AMP: - if (ptr == start) - return PREFIX(scanRef)(enc, ptr + MINBPC(enc), end, nextTokPtr); - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; - case BT_LT: - /* this is for inside entity references */ - *nextTokPtr = ptr; - return XML_TOK_INVALID; - case BT_LF: - if (ptr == start) { - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_DATA_NEWLINE; - } - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; - case BT_CR: - if (ptr == start) { - ptr += MINBPC(enc); - if (ptr == end) - return XML_TOK_TRAILING_CR; - if (BYTE_TYPE(enc, ptr) == BT_LF) - ptr += MINBPC(enc); - *nextTokPtr = ptr; - return XML_TOK_DATA_NEWLINE; - } - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; - case BT_S: - if (ptr == start) { - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_ATTRIBUTE_VALUE_S; - } - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; - default: - ptr += MINBPC(enc); - break; - } - } - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; -} - -static -int PREFIX(entityValueTok)(const ENCODING *enc, const char *ptr, const char *end, - const char **nextTokPtr) -{ - const char *start; - if (ptr == end) - return XML_TOK_NONE; - start = ptr; - while (ptr != end) { - switch (BYTE_TYPE(enc, ptr)) { -#define LEAD_CASE(n) \ - case BT_LEAD ## n: ptr += n; break; - LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) -#undef LEAD_CASE - case BT_AMP: - if (ptr == start) - return PREFIX(scanRef)(enc, ptr + MINBPC(enc), end, nextTokPtr); - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; - case BT_PERCNT: - if (ptr == start) { - int tok = PREFIX(scanPercent)(enc, ptr + MINBPC(enc), - end, nextTokPtr); - return (tok == XML_TOK_PERCENT) ? XML_TOK_INVALID : tok; - } - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; - case BT_LF: - if (ptr == start) { - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_DATA_NEWLINE; - } - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; - case BT_CR: - if (ptr == start) { - ptr += MINBPC(enc); - if (ptr == end) - return XML_TOK_TRAILING_CR; - if (BYTE_TYPE(enc, ptr) == BT_LF) - ptr += MINBPC(enc); - *nextTokPtr = ptr; - return XML_TOK_DATA_NEWLINE; - } - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; - default: - ptr += MINBPC(enc); - break; - } - } - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; -} - -#ifdef XML_DTD - -static -int PREFIX(ignoreSectionTok)(const ENCODING *enc, const char *ptr, const char *end, - const char **nextTokPtr) -{ - int level = 0; - if (MINBPC(enc) > 1) { - size_t n = end - ptr; - if (n & (MINBPC(enc) - 1)) { - n &= ~(MINBPC(enc) - 1); - end = ptr + n; - } - } - while (ptr != end) { - switch (BYTE_TYPE(enc, ptr)) { - INVALID_CASES(ptr, nextTokPtr) - case BT_LT: - if ((ptr += MINBPC(enc)) == end) - return XML_TOK_PARTIAL; - if (CHAR_MATCHES(enc, ptr, ASCII_EXCL)) { - if ((ptr += MINBPC(enc)) == end) - return XML_TOK_PARTIAL; - if (CHAR_MATCHES(enc, ptr, ASCII_LSQB)) { - ++level; - ptr += MINBPC(enc); - } - } - break; - case BT_RSQB: - if ((ptr += MINBPC(enc)) == end) - return XML_TOK_PARTIAL; - if (CHAR_MATCHES(enc, ptr, ASCII_RSQB)) { - if ((ptr += MINBPC(enc)) == end) - return XML_TOK_PARTIAL; - if (CHAR_MATCHES(enc, ptr, ASCII_GT)) { - ptr += MINBPC(enc); - if (level == 0) { - *nextTokPtr = ptr; - return XML_TOK_IGNORE_SECT; - } - --level; - } - } - break; - default: - ptr += MINBPC(enc); - break; - } - } - return XML_TOK_PARTIAL; -} - -#endif /* XML_DTD */ - -static -int PREFIX(isPublicId)(const ENCODING *enc, const char *ptr, const char *end, - const char **badPtr) -{ - ptr += MINBPC(enc); - end -= MINBPC(enc); - for (; ptr != end; ptr += MINBPC(enc)) { - switch (BYTE_TYPE(enc, ptr)) { - case BT_DIGIT: - case BT_HEX: - case BT_MINUS: - case BT_APOS: - case BT_LPAR: - case BT_RPAR: - case BT_PLUS: - case BT_COMMA: - case BT_SOL: - case BT_EQUALS: - case BT_QUEST: - case BT_CR: - case BT_LF: - case BT_SEMI: - case BT_EXCL: - case BT_AST: - case BT_PERCNT: - case BT_NUM: -#ifdef XML_NS - case BT_COLON: -#endif - break; - case BT_S: - if (CHAR_MATCHES(enc, ptr, ASCII_TAB)) { - *badPtr = ptr; - return 0; - } - break; - case BT_NAME: - case BT_NMSTRT: - if (!(BYTE_TO_ASCII(enc, ptr) & ~0x7f)) - break; - default: - switch (BYTE_TO_ASCII(enc, ptr)) { - case 0x24: /* $ */ - case 0x40: /* @ */ - break; - default: - *badPtr = ptr; - return 0; - } - break; - } - } - return 1; -} - -/* This must only be called for a well-formed start-tag or empty element tag. -Returns the number of attributes. Pointers to the first attsMax attributes -are stored in atts. */ - -static -int PREFIX(getAtts)(const ENCODING *enc, const char *ptr, - int attsMax, ATTRIBUTE *atts) -{ - enum { other, inName, inValue } state = inName; - int nAtts = 0; - int open = 0; /* defined when state == inValue; - initialization just to shut up compilers */ - - for (ptr += MINBPC(enc);; ptr += MINBPC(enc)) { - switch (BYTE_TYPE(enc, ptr)) { -#define START_NAME \ - if (state == other) { \ - if (nAtts < attsMax) { \ - atts[nAtts].name = ptr; \ - atts[nAtts].normalized = 1; \ - } \ - state = inName; \ - } -#define LEAD_CASE(n) \ - case BT_LEAD ## n: START_NAME ptr += (n - MINBPC(enc)); break; - LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) -#undef LEAD_CASE - case BT_NONASCII: - case BT_NMSTRT: - case BT_HEX: - START_NAME - break; -#undef START_NAME - case BT_QUOT: - if (state != inValue) { - if (nAtts < attsMax) - atts[nAtts].valuePtr = ptr + MINBPC(enc); - state = inValue; - open = BT_QUOT; - } - else if (open == BT_QUOT) { - state = other; - if (nAtts < attsMax) - atts[nAtts].valueEnd = ptr; - nAtts++; - } - break; - case BT_APOS: - if (state != inValue) { - if (nAtts < attsMax) - atts[nAtts].valuePtr = ptr + MINBPC(enc); - state = inValue; - open = BT_APOS; - } - else if (open == BT_APOS) { - state = other; - if (nAtts < attsMax) - atts[nAtts].valueEnd = ptr; - nAtts++; - } - break; - case BT_AMP: - if (nAtts < attsMax) - atts[nAtts].normalized = 0; - break; - case BT_S: - if (state == inName) - state = other; - else if (state == inValue - && nAtts < attsMax - && atts[nAtts].normalized - && (ptr == atts[nAtts].valuePtr - || BYTE_TO_ASCII(enc, ptr) != ASCII_SPACE - || BYTE_TO_ASCII(enc, ptr + MINBPC(enc)) == ASCII_SPACE - || BYTE_TYPE(enc, ptr + MINBPC(enc)) == open)) - atts[nAtts].normalized = 0; - break; - case BT_CR: case BT_LF: - /* This case ensures that the first attribute name is counted - Apart from that we could just change state on the quote. */ - if (state == inName) - state = other; - else if (state == inValue && nAtts < attsMax) - atts[nAtts].normalized = 0; - break; - case BT_GT: - case BT_SOL: - if (state != inValue) - return nAtts; - break; - default: - break; - } - } - /* not reached */ -} - -static -int PREFIX(charRefNumber)(const ENCODING *enc, const char *ptr) -{ - int result = 0; - /* skip &# */ - ptr += 2*MINBPC(enc); - if (CHAR_MATCHES(enc, ptr, ASCII_x)) { - for (ptr += MINBPC(enc); !CHAR_MATCHES(enc, ptr, ASCII_SEMI); ptr += MINBPC(enc)) { - int c = BYTE_TO_ASCII(enc, ptr); - switch (c) { - case ASCII_0: case ASCII_1: case ASCII_2: case ASCII_3: case ASCII_4: - case ASCII_5: case ASCII_6: case ASCII_7: case ASCII_8: case ASCII_9: - result <<= 4; - result |= (c - ASCII_0); - break; - case ASCII_A: case ASCII_B: case ASCII_C: case ASCII_D: case ASCII_E: case ASCII_F: - result <<= 4; - result += 10 + (c - ASCII_A); - break; - case ASCII_a: case ASCII_b: case ASCII_c: case ASCII_d: case ASCII_e: case ASCII_f: - result <<= 4; - result += 10 + (c - ASCII_a); - break; - } - if (result >= 0x110000) - return -1; - } - } - else { - for (; !CHAR_MATCHES(enc, ptr, ASCII_SEMI); ptr += MINBPC(enc)) { - int c = BYTE_TO_ASCII(enc, ptr); - result *= 10; - result += (c - ASCII_0); - if (result >= 0x110000) - return -1; - } - } - return checkCharRefNumber(result); -} - -static -int PREFIX(predefinedEntityName)(const ENCODING *enc, const char *ptr, const char *end) -{ - switch ((end - ptr)/MINBPC(enc)) { - case 2: - if (CHAR_MATCHES(enc, ptr + MINBPC(enc), ASCII_t)) { - switch (BYTE_TO_ASCII(enc, ptr)) { - case ASCII_l: - return ASCII_LT; - case ASCII_g: - return ASCII_GT; - } - } - break; - case 3: - if (CHAR_MATCHES(enc, ptr, ASCII_a)) { - ptr += MINBPC(enc); - if (CHAR_MATCHES(enc, ptr, ASCII_m)) { - ptr += MINBPC(enc); - if (CHAR_MATCHES(enc, ptr, ASCII_p)) - return ASCII_AMP; - } - } - break; - case 4: - switch (BYTE_TO_ASCII(enc, ptr)) { - case ASCII_q: - ptr += MINBPC(enc); - if (CHAR_MATCHES(enc, ptr, ASCII_u)) { - ptr += MINBPC(enc); - if (CHAR_MATCHES(enc, ptr, ASCII_o)) { - ptr += MINBPC(enc); - if (CHAR_MATCHES(enc, ptr, ASCII_t)) - return ASCII_QUOT; - } - } - break; - case ASCII_a: - ptr += MINBPC(enc); - if (CHAR_MATCHES(enc, ptr, ASCII_p)) { - ptr += MINBPC(enc); - if (CHAR_MATCHES(enc, ptr, ASCII_o)) { - ptr += MINBPC(enc); - if (CHAR_MATCHES(enc, ptr, ASCII_s)) - return ASCII_APOS; - } - } - break; - } - } - return 0; -} - -static -int PREFIX(sameName)(const ENCODING *enc, const char *ptr1, const char *ptr2) -{ - for (;;) { - switch (BYTE_TYPE(enc, ptr1)) { -#define LEAD_CASE(n) \ - case BT_LEAD ## n: \ - if (*ptr1++ != *ptr2++) \ - return 0; - LEAD_CASE(4) LEAD_CASE(3) LEAD_CASE(2) -#undef LEAD_CASE - /* fall through */ - if (*ptr1++ != *ptr2++) - return 0; - break; - case BT_NONASCII: - case BT_NMSTRT: -#ifdef XML_NS - case BT_COLON: -#endif - case BT_HEX: - case BT_DIGIT: - case BT_NAME: - case BT_MINUS: - if (*ptr2++ != *ptr1++) - return 0; - if (MINBPC(enc) > 1) { - if (*ptr2++ != *ptr1++) - return 0; - if (MINBPC(enc) > 2) { - if (*ptr2++ != *ptr1++) - return 0; - if (MINBPC(enc) > 3) { - if (*ptr2++ != *ptr1++) - return 0; - } - } - } - break; - default: - if (MINBPC(enc) == 1 && *ptr1 == *ptr2) - return 1; - switch (BYTE_TYPE(enc, ptr2)) { - case BT_LEAD2: - case BT_LEAD3: - case BT_LEAD4: - case BT_NONASCII: - case BT_NMSTRT: -#ifdef XML_NS - case BT_COLON: -#endif - case BT_HEX: - case BT_DIGIT: - case BT_NAME: - case BT_MINUS: - return 0; - default: - return 1; - } - } - } - /* not reached */ -} - -static -int PREFIX(nameMatchesAscii)(const ENCODING *enc, const char *ptr1, - const char *end1, const char *ptr2) -{ - for (; *ptr2; ptr1 += MINBPC(enc), ptr2++) { - if (ptr1 == end1) - return 0; - if (!CHAR_MATCHES(enc, ptr1, *ptr2)) - return 0; - } - return ptr1 == end1; -} - -static -int PREFIX(nameLength)(const ENCODING *enc, const char *ptr) -{ - const char *start = ptr; - for (;;) { - switch (BYTE_TYPE(enc, ptr)) { -#define LEAD_CASE(n) \ - case BT_LEAD ## n: ptr += n; break; - LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) -#undef LEAD_CASE - case BT_NONASCII: - case BT_NMSTRT: -#ifdef XML_NS - case BT_COLON: -#endif - case BT_HEX: - case BT_DIGIT: - case BT_NAME: - case BT_MINUS: - ptr += MINBPC(enc); - break; - default: - return ptr - start; - } - } -} - -static -const char *PREFIX(skipS)(const ENCODING *enc, const char *ptr) -{ - for (;;) { - switch (BYTE_TYPE(enc, ptr)) { - case BT_LF: - case BT_CR: - case BT_S: - ptr += MINBPC(enc); - break; - default: - return ptr; - } - } -} - -static -void PREFIX(updatePosition)(const ENCODING *enc, - const char *ptr, - const char *end, - POSITION *pos) -{ - while (ptr != end) { - switch (BYTE_TYPE(enc, ptr)) { -#define LEAD_CASE(n) \ - case BT_LEAD ## n: \ - ptr += n; \ - break; - LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) -#undef LEAD_CASE - case BT_LF: - pos->columnNumber = (unsigned)-1; - pos->lineNumber++; - ptr += MINBPC(enc); - break; - case BT_CR: - pos->lineNumber++; - ptr += MINBPC(enc); - if (ptr != end && BYTE_TYPE(enc, ptr) == BT_LF) - ptr += MINBPC(enc); - pos->columnNumber = (unsigned)-1; - break; - default: - ptr += MINBPC(enc); - break; - } - pos->columnNumber++; - } -} - -#undef DO_LEAD_CASE -#undef MULTIBYTE_CASES -#undef INVALID_CASES -#undef CHECK_NAME_CASE -#undef CHECK_NAME_CASES -#undef CHECK_NMSTRT_CASE -#undef CHECK_NMSTRT_CASES diff --git a/libs/apr-util/xml/expat/lib/xmltok_impl.h b/libs/apr-util/xml/expat/lib/xmltok_impl.h deleted file mode 100644 index da0ea60a65..0000000000 --- a/libs/apr-util/xml/expat/lib/xmltok_impl.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd -See the file COPYING for copying permission. -*/ - -enum { - BT_NONXML, - BT_MALFORM, - BT_LT, - BT_AMP, - BT_RSQB, - BT_LEAD2, - BT_LEAD3, - BT_LEAD4, - BT_TRAIL, - BT_CR, - BT_LF, - BT_GT, - BT_QUOT, - BT_APOS, - BT_EQUALS, - BT_QUEST, - BT_EXCL, - BT_SOL, - BT_SEMI, - BT_NUM, - BT_LSQB, - BT_S, - BT_NMSTRT, - BT_COLON, - BT_HEX, - BT_DIGIT, - BT_NAME, - BT_MINUS, - BT_OTHER, /* known not to be a name or name start character */ - BT_NONASCII, /* might be a name or name start character */ - BT_PERCNT, - BT_LPAR, - BT_RPAR, - BT_AST, - BT_PLUS, - BT_COMMA, - BT_VERBAR -}; - -#include diff --git a/libs/apr-util/xml/expat/lib/xmltok_ns.c b/libs/apr-util/xml/expat/lib/xmltok_ns.c deleted file mode 100644 index 21859738ac..0000000000 --- a/libs/apr-util/xml/expat/lib/xmltok_ns.c +++ /dev/null @@ -1,98 +0,0 @@ -const ENCODING *NS(XmlGetUtf8InternalEncoding)(void) -{ - return &ns(internal_utf8_encoding).enc; -} - -const ENCODING *NS(XmlGetUtf16InternalEncoding)(void) -{ -#if XML_BYTE_ORDER == 12 - return &ns(internal_little2_encoding).enc; -#elif XML_BYTE_ORDER == 21 - return &ns(internal_big2_encoding).enc; -#else - const short n = 1; - return *(const char *)&n ? &ns(internal_little2_encoding).enc : &ns(internal_big2_encoding).enc; -#endif -} - -static -const ENCODING *NS(encodings)[] = { - &ns(latin1_encoding).enc, - &ns(ascii_encoding).enc, - &ns(utf8_encoding).enc, - &ns(big2_encoding).enc, - &ns(big2_encoding).enc, - &ns(little2_encoding).enc, - &ns(utf8_encoding).enc /* NO_ENC */ -}; - -static -int NS(initScanProlog)(const ENCODING *enc, const char *ptr, const char *end, - const char **nextTokPtr) -{ - return initScan(NS(encodings), (const INIT_ENCODING *)enc, XML_PROLOG_STATE, ptr, end, nextTokPtr); -} - -static -int NS(initScanContent)(const ENCODING *enc, const char *ptr, const char *end, - const char **nextTokPtr) -{ - return initScan(NS(encodings), (const INIT_ENCODING *)enc, XML_CONTENT_STATE, ptr, end, nextTokPtr); -} - -int NS(XmlInitEncoding)(INIT_ENCODING *p, const ENCODING **encPtr, const char *name) -{ - int i = getEncodingIndex(name); - if (i == UNKNOWN_ENC) - return 0; - SET_INIT_ENC_INDEX(p, i); - p->initEnc.scanners[XML_PROLOG_STATE] = NS(initScanProlog); - p->initEnc.scanners[XML_CONTENT_STATE] = NS(initScanContent); - p->initEnc.updatePosition = initUpdatePosition; - p->encPtr = encPtr; - *encPtr = &(p->initEnc); - return 1; -} - -static -const ENCODING *NS(findEncoding)(const ENCODING *enc, const char *ptr, const char *end) -{ -#define ENCODING_MAX 128 - char buf[ENCODING_MAX]; - char *p = buf; - int i; - XmlUtf8Convert(enc, &ptr, end, &p, p + ENCODING_MAX - 1); - if (ptr != end) - return 0; - *p = 0; - if (streqci(buf, KW_UTF_16) && enc->minBytesPerChar == 2) - return enc; - i = getEncodingIndex(buf); - if (i == UNKNOWN_ENC) - return 0; - return NS(encodings)[i]; -} - -int NS(XmlParseXmlDecl)(int isGeneralTextEntity, - const ENCODING *enc, - const char *ptr, - const char *end, - const char **badPtr, - const char **versionPtr, - const char **versionEndPtr, - const char **encodingName, - const ENCODING **encoding, - int *standalone) -{ - return doParseXmlDecl(NS(findEncoding), - isGeneralTextEntity, - enc, - ptr, - end, - badPtr, - versionPtr, - versionEndPtr, - encodingName, - encoding, - standalone); -} diff --git a/libs/apr/Makefile.in b/libs/apr/Makefile.in index ee7969f9fc..2c347b7322 100644 --- a/libs/apr/Makefile.in +++ b/libs/apr/Makefile.in @@ -45,7 +45,7 @@ TARGETS = $(TARGET_LIB) export_vars.c apr.exp CLEAN_TARGETS = apr-config.out apr.exp exports.c export_vars.c .make.dirs \ build/apr_rules.out DISTCLEAN_TARGETS = config.cache config.log config.status \ - include/apr.h include/arch/unix/apr_private.h \ + include/fspr.h include/arch/unix/apr_private.h \ libtool $(APR_CONFIG) build/apr_rules.mk apr.pc \ build/pkg/pkginfo EXTRACLEAN_TARGETS = configure aclocal.m4 include/arch/unix/apr_private.h.in \ @@ -81,7 +81,7 @@ $(top_srcdir)/configure: $(top_srcdir)/configure.ac install: $(TARGET_LIB) apr-config.out build/apr_rules.out $(APR_MKDIR) $(DESTDIR)$(libdir) $(DESTDIR)$(bindir) $(DESTDIR)$(installbuilddir) \ $(DESTDIR)$(libdir)/pkgconfig $(DESTDIR)$(includedir) - $(INSTALL_DATA) $(top_blddir)/include/apr.h $(DESTDIR)$(includedir) + $(INSTALL_DATA) $(top_blddir)/include/fspr.h $(DESTDIR)$(includedir) for f in $(top_srcdir)/include/apr_*.h; do \ $(INSTALL_DATA) $${f} $(DESTDIR)$(includedir); \ done diff --git a/libs/apr/apr.dsp b/libs/apr/apr.dsp index d1c1b29cfd..7c3d0160da 100644 --- a/libs/apr/apr.dsp +++ b/libs/apr/apr.dsp @@ -41,7 +41,7 @@ RSC=rc.exe # PROP Intermediate_Dir "LibR" # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c -# ADD CPP /nologo /MD /W3 /O2 /Oy- /Zi /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "NDEBUG" /D "APR_DECLARE_STATIC" /D "WIN32" /D "_WINDOWS" /Fd"LibR\apr_src" /FD /c +# ADD CPP /nologo /MD /W3 /O2 /Oy- /Zi /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "NDEBUG" /D "APR_DECLARE_STATIC" /D "WIN32" /D "_WINDOWS" /Fd"LibR\fspr_src" /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe @@ -65,7 +65,7 @@ LIB32=link.exe -lib # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /EHsc /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /c -# ADD CPP /nologo /MDd /W3 /EHsc /Zi /Od /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "_DEBUG" /D "APR_DECLARE_STATIC" /D "WIN32" /D "_WINDOWS" /Fd"LibD\apr_src" /FD /c +# ADD CPP /nologo /MDd /W3 /EHsc /Zi /Od /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "_DEBUG" /D "APR_DECLARE_STATIC" /D "WIN32" /D "_WINDOWS" /Fd"LibD\fspr_src" /FD /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe @@ -89,7 +89,7 @@ LIB32=link.exe -lib # PROP Default_Filter "" # Begin Source File -SOURCE=.\atomic\win32\apr_atomic.c +SOURCE=.\atomic\win32\fspr_atomic.c # End Source File # End Group # Begin Group "dso" @@ -193,7 +193,7 @@ SOURCE=.\locks\win32\thread_rwlock.c # PROP Default_Filter "" # Begin Source File -SOURCE=.\memory\unix\apr_pools.c +SOURCE=.\memory\unix\fspr_pools.c # End Source File # End Group # Begin Group "misc" @@ -201,7 +201,7 @@ SOURCE=.\memory\unix\apr_pools.c # PROP Default_Filter "" # Begin Source File -SOURCE=.\misc\win32\apr_app.c +SOURCE=.\misc\win32\fspr_app.c # PROP Exclude_From_Build 1 # End Source File # Begin Source File @@ -302,7 +302,7 @@ SOURCE=.\network_io\win32\sockopt.c # PROP Default_Filter "" # Begin Source File -SOURCE=.\passwd\apr_getpass.c +SOURCE=.\passwd\fspr_getpass.c # End Source File # End Group # Begin Group "random" @@ -310,7 +310,7 @@ SOURCE=.\passwd\apr_getpass.c # PROP Default_Filter "" # Begin Source File -SOURCE=.\random\unix\apr_random.c +SOURCE=.\random\unix\fspr_random.c # End Source File # Begin Source File @@ -334,27 +334,27 @@ SOURCE=.\shmem\win32\shm.c # PROP Default_Filter "" # Begin Source File -SOURCE=.\strings\apr_cpystrn.c +SOURCE=.\strings\fspr_cpystrn.c # End Source File # Begin Source File -SOURCE=.\strings\apr_fnmatch.c +SOURCE=.\strings\fspr_fnmatch.c # End Source File # Begin Source File -SOURCE=.\strings\apr_snprintf.c +SOURCE=.\strings\fspr_snprintf.c # End Source File # Begin Source File -SOURCE=.\strings\apr_strings.c +SOURCE=.\strings\fspr_strings.c # End Source File # Begin Source File -SOURCE=.\strings\apr_strnatcmp.c +SOURCE=.\strings\fspr_strnatcmp.c # End Source File # Begin Source File -SOURCE=.\strings\apr_strtok.c +SOURCE=.\strings\fspr_strtok.c # End Source File # End Group # Begin Group "tables" @@ -362,11 +362,11 @@ SOURCE=.\strings\apr_strtok.c # PROP Default_Filter "" # Begin Source File -SOURCE=.\tables\apr_hash.c +SOURCE=.\tables\fspr_hash.c # End Source File # Begin Source File -SOURCE=.\tables\apr_tables.c +SOURCE=.\tables\fspr_tables.c # End Source File # End Group # Begin Group "threadproc" @@ -423,51 +423,51 @@ SOURCE=.\user\win32\userinfo.c # PROP Default_Filter "" # Begin Source File -SOURCE=.\include\arch\win32\apr_arch_atime.h +SOURCE=.\include\arch\win32\fspr_arch_atime.h # End Source File # Begin Source File -SOURCE=.\include\arch\win32\apr_arch_dso.h +SOURCE=.\include\arch\win32\fspr_arch_dso.h # End Source File # Begin Source File -SOURCE=.\include\arch\win32\apr_arch_file_io.h +SOURCE=.\include\arch\win32\fspr_arch_file_io.h # End Source File # Begin Source File -SOURCE=.\include\arch\win32\apr_arch_inherit.h +SOURCE=.\include\arch\win32\fspr_arch_inherit.h # End Source File # Begin Source File -SOURCE=.\include\arch\win32\apr_arch_misc.h +SOURCE=.\include\arch\win32\fspr_arch_misc.h # End Source File # Begin Source File -SOURCE=.\include\arch\win32\apr_arch_networkio.h +SOURCE=.\include\arch\win32\fspr_arch_networkio.h # End Source File # Begin Source File -SOURCE=.\include\arch\win32\apr_arch_thread_mutex.h +SOURCE=.\include\arch\win32\fspr_arch_thread_mutex.h # End Source File # Begin Source File -SOURCE=.\include\arch\win32\apr_arch_thread_rwlock.h +SOURCE=.\include\arch\win32\fspr_arch_thread_rwlock.h # End Source File # Begin Source File -SOURCE=.\include\arch\win32\apr_arch_threadproc.h +SOURCE=.\include\arch\win32\fspr_arch_threadproc.h # End Source File # Begin Source File -SOURCE=.\include\arch\win32\apr_arch_utf8.h +SOURCE=.\include\arch\win32\fspr_arch_utf8.h # End Source File # Begin Source File -SOURCE=.\include\arch\win32\apr_private.h +SOURCE=.\include\arch\win32\fspr_private.h # End Source File # Begin Source File -SOURCE=.\include\arch\apr_private_common.h +SOURCE=.\include\arch\fspr_private_common.h # End Source File # End Group # Begin Group "Public Header Files" @@ -475,35 +475,35 @@ SOURCE=.\include\arch\apr_private_common.h # PROP Default_Filter "" # Begin Source File -SOURCE=.\include\apr.h.in +SOURCE=.\include\fspr.h.in # PROP Exclude_From_Build 1 # End Source File # Begin Source File -SOURCE=.\include\apr.hnw +SOURCE=.\include\fspr.hnw # PROP Exclude_From_Build 1 # End Source File # Begin Source File -SOURCE=.\include\apr.hw +SOURCE=.\include\fspr.hw !IF "$(CFG)" == "apr - Win32 Release" # Begin Custom Build - Creating apr.h from apr.hw -InputPath=.\include\apr.hw +InputPath=.\include\fspr.hw -".\include\apr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\include\apr.hw > .\include\apr.h +".\include\fspr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + type .\include\fspr.hw > .\include\fspr.h # End Custom Build !ELSEIF "$(CFG)" == "apr - Win32 Debug" # Begin Custom Build - Creating apr.h from apr.hw -InputPath=.\include\apr.hw +InputPath=.\include\fspr.hw -".\include\apr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\include\apr.hw > .\include\apr.h +".\include\fspr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + type .\include\fspr.hw > .\include\fspr.h # End Custom Build @@ -512,139 +512,139 @@ InputPath=.\include\apr.hw # End Source File # Begin Source File -SOURCE=.\include\apr_allocator.h +SOURCE=.\include\fspr_allocator.h # End Source File # Begin Source File -SOURCE=.\include\apr_atomic.h +SOURCE=.\include\fspr_atomic.h # End Source File # Begin Source File -SOURCE=.\include\apr_dso.h +SOURCE=.\include\fspr_dso.h # End Source File # Begin Source File -SOURCE=.\include\apr_env.h +SOURCE=.\include\fspr_env.h # End Source File # Begin Source File -SOURCE=.\include\apr_errno.h +SOURCE=.\include\fspr_errno.h # End Source File # Begin Source File -SOURCE=.\include\apr_file_info.h +SOURCE=.\include\fspr_file_info.h # End Source File # Begin Source File -SOURCE=.\include\apr_file_io.h +SOURCE=.\include\fspr_file_io.h # End Source File # Begin Source File -SOURCE=.\include\apr_fnmatch.h +SOURCE=.\include\fspr_fnmatch.h # End Source File # Begin Source File -SOURCE=.\include\apr_general.h +SOURCE=.\include\fspr_general.h # End Source File # Begin Source File -SOURCE=.\include\apr_getopt.h +SOURCE=.\include\fspr_getopt.h # End Source File # Begin Source File -SOURCE=.\include\apr_global_mutex.h +SOURCE=.\include\fspr_global_mutex.h # End Source File # Begin Source File -SOURCE=.\include\apr_hash.h +SOURCE=.\include\fspr_hash.h # End Source File # Begin Source File -SOURCE=.\include\apr_inherit.h +SOURCE=.\include\fspr_inherit.h # End Source File # Begin Source File -SOURCE=.\include\apr_lib.h +SOURCE=.\include\fspr_lib.h # End Source File # Begin Source File -SOURCE=.\include\apr_mmap.h +SOURCE=.\include\fspr_mmap.h # End Source File # Begin Source File -SOURCE=.\include\apr_network_io.h +SOURCE=.\include\fspr_network_io.h # End Source File # Begin Source File -SOURCE=.\include\apr_poll.h +SOURCE=.\include\fspr_poll.h # End Source File # Begin Source File -SOURCE=.\include\apr_pools.h +SOURCE=.\include\fspr_pools.h # End Source File # Begin Source File -SOURCE=.\include\apr_portable.h +SOURCE=.\include\fspr_portable.h # End Source File # Begin Source File -SOURCE=.\include\apr_proc_mutex.h +SOURCE=.\include\fspr_proc_mutex.h # End Source File # Begin Source File -SOURCE=.\include\apr_ring.h +SOURCE=.\include\fspr_ring.h # End Source File # Begin Source File -SOURCE=.\include\apr_shm.h +SOURCE=.\include\fspr_shm.h # End Source File # Begin Source File -SOURCE=.\include\apr_signal.h +SOURCE=.\include\fspr_signal.h # End Source File # Begin Source File -SOURCE=.\include\apr_strings.h +SOURCE=.\include\fspr_strings.h # End Source File # Begin Source File -SOURCE=.\include\apr_support.h +SOURCE=.\include\fspr_support.h # End Source File # Begin Source File -SOURCE=.\include\apr_tables.h +SOURCE=.\include\fspr_tables.h # End Source File # Begin Source File -SOURCE=.\include\apr_thread_cond.h +SOURCE=.\include\fspr_thread_cond.h # End Source File # Begin Source File -SOURCE=.\include\apr_thread_mutex.h +SOURCE=.\include\fspr_thread_mutex.h # End Source File # Begin Source File -SOURCE=.\include\apr_thread_proc.h +SOURCE=.\include\fspr_thread_proc.h # End Source File # Begin Source File -SOURCE=.\include\apr_thread_rwlock.h +SOURCE=.\include\fspr_thread_rwlock.h # End Source File # Begin Source File -SOURCE=.\include\apr_time.h +SOURCE=.\include\fspr_time.h # End Source File # Begin Source File -SOURCE=.\include\apr_user.h +SOURCE=.\include\fspr_user.h # End Source File # Begin Source File -SOURCE=.\include\apr_version.h +SOURCE=.\include\fspr_version.h # End Source File # Begin Source File -SOURCE=.\include\apr_want.h +SOURCE=.\include\fspr_want.h # End Source File # End Group # End Target diff --git a/libs/apr/apr.dsw b/libs/apr/apr.dsw index dc0871bbc8..73db5d052e 100644 --- a/libs/apr/apr.dsw +++ b/libs/apr/apr.dsw @@ -15,7 +15,7 @@ Package=<4> ############################################################################### -Project: "apr_app"=".\build\apr_app.dsp" - Package Owner=<4> +Project: "fspr_app"=".\build\fspr_app.dsp" - Package Owner=<4> Package=<5> {{{ @@ -42,7 +42,7 @@ Package=<4> ############################################################################### -Project: "libapr_app"=".\build\libapr_app.dsp" - Package Owner=<4> +Project: "libfspr_app"=".\build\libfspr_app.dsp" - Package Owner=<4> Package=<5> {{{ diff --git a/libs/apr/atomic/netware/apr_atomic.c b/libs/apr/atomic/netware/fspr_atomic.c similarity index 61% rename from libs/apr/atomic/netware/apr_atomic.c rename to libs/apr/atomic/netware/fspr_atomic.c index 94a3549775..e54704064c 100644 --- a/libs/apr/atomic/netware/apr_atomic.c +++ b/libs/apr/atomic/netware/fspr_atomic.c @@ -14,57 +14,57 @@ * limitations under the License. */ -#include "apr.h" -#include "apr_atomic.h" +#include "fspr.h" +#include "fspr_atomic.h" #include -APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_atomic_init(fspr_pool_t *pool) { return APR_SUCCESS; } -APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val) +APR_DECLARE(fspr_uint32_t) fspr_atomic_add32(volatile fspr_uint32_t *mem, fspr_uint32_t val) { return atomic_xchgadd((unsigned long *)mem,(unsigned long)val); } -APR_DECLARE(void) apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val) +APR_DECLARE(void) fspr_atomic_sub32(volatile fspr_uint32_t *mem, fspr_uint32_t val) { atomic_sub((unsigned long *)mem,(unsigned long)val); } -APR_DECLARE(apr_uint32_t) apr_atomic_inc32(volatile apr_uint32_t *mem) +APR_DECLARE(fspr_uint32_t) fspr_atomic_inc32(volatile fspr_uint32_t *mem) { return atomic_xchgadd((unsigned long *)mem, 1); } -APR_DECLARE(void) apr_atomic_set32(volatile apr_uint32_t *mem, apr_uint32_t val) +APR_DECLARE(void) fspr_atomic_set32(volatile fspr_uint32_t *mem, fspr_uint32_t val) { *mem = val; } -APR_DECLARE(apr_uint32_t) apr_atomic_read32(volatile apr_uint32_t *mem) +APR_DECLARE(fspr_uint32_t) fspr_atomic_read32(volatile fspr_uint32_t *mem) { return *mem; } -APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem, apr_uint32_t with,apr_uint32_t cmp) +APR_DECLARE(fspr_uint32_t) fspr_atomic_cas32(volatile fspr_uint32_t *mem, fspr_uint32_t with,fspr_uint32_t cmp) { return atomic_cmpxchg((unsigned long *)mem,(unsigned long)cmp,(unsigned long)with); } -APR_DECLARE(apr_uint32_t) apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint32_t val) +APR_DECLARE(fspr_uint32_t) fspr_atomic_xchg32(volatile fspr_uint32_t *mem, fspr_uint32_t val) { return atomic_xchg((unsigned long *)mem,(unsigned long)val); } -APR_DECLARE(int) apr_atomic_dec32(volatile apr_uint32_t *mem) +APR_DECLARE(int) fspr_atomic_dec32(volatile fspr_uint32_t *mem) { return (atomic_xchgadd((unsigned long *)mem, 0xFFFFFFFF) - 1); } -APR_DECLARE(void *) apr_atomic_casptr(volatile void **mem, void *with, const void *cmp) +APR_DECLARE(void *) fspr_atomic_casptr(volatile void **mem, void *with, const void *cmp) { return (void*)atomic_cmpxchg((unsigned long *)mem,(unsigned long)cmp,(unsigned long)with); } diff --git a/libs/apr/atomic/os390/atomic.c b/libs/apr/atomic/os390/atomic.c index 35ddf1c226..b85b5bfa64 100644 --- a/libs/apr/atomic/os390/atomic.c +++ b/libs/apr/atomic/os390/atomic.c @@ -15,19 +15,19 @@ */ -#include "apr.h" -#include "apr_atomic.h" +#include "fspr.h" +#include "fspr_atomic.h" #include -apr_status_t apr_atomic_init(apr_pool_t *p) +fspr_status_t fspr_atomic_init(fspr_pool_t *p) { return APR_SUCCESS; } -apr_uint32_t apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val) +fspr_uint32_t fspr_atomic_add32(volatile fspr_uint32_t *mem, fspr_uint32_t val) { - apr_uint32_t old, new_val; + fspr_uint32_t old, new_val; old = *mem; /* old is automatically updated on cs failure */ do { @@ -36,9 +36,9 @@ apr_uint32_t apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val) return old; } -void apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val) +void fspr_atomic_sub32(volatile fspr_uint32_t *mem, fspr_uint32_t val) { - apr_uint32_t old, new_val; + fspr_uint32_t old, new_val; old = *mem; /* old is automatically updated on cs failure */ do { @@ -46,14 +46,14 @@ void apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val) } while (__cs(&old, (cs_t *)mem, new_val)); } -apr_uint32_t apr_atomic_inc32(volatile apr_uint32_t *mem) +fspr_uint32_t fspr_atomic_inc32(volatile fspr_uint32_t *mem) { - return apr_atomic_add32(mem, 1); + return fspr_atomic_add32(mem, 1); } -int apr_atomic_dec32(volatile apr_uint32_t *mem) +int fspr_atomic_dec32(volatile fspr_uint32_t *mem) { - apr_uint32_t old, new_val; + fspr_uint32_t old, new_val; old = *mem; /* old is automatically updated on cs failure */ do { @@ -63,28 +63,28 @@ int apr_atomic_dec32(volatile apr_uint32_t *mem) return new_val != 0; } -apr_uint32_t apr_atomic_read32(volatile apr_uint32_t *mem) +fspr_uint32_t fspr_atomic_read32(volatile fspr_uint32_t *mem) { return *mem; } -void apr_atomic_set32(volatile apr_uint32_t *mem, apr_uint32_t val) +void fspr_atomic_set32(volatile fspr_uint32_t *mem, fspr_uint32_t val) { *mem = val; } -apr_uint32_t apr_atomic_cas32(volatile apr_uint32_t *mem, apr_uint32_t swap, - apr_uint32_t cmp) +fspr_uint32_t fspr_atomic_cas32(volatile fspr_uint32_t *mem, fspr_uint32_t swap, + fspr_uint32_t cmp) { - apr_uint32_t old = cmp; + fspr_uint32_t old = cmp; __cs(&old, (cs_t *)mem, swap); return old; /* old is automatically updated from mem on cs failure */ } -apr_uint32_t apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint32_t val) +fspr_uint32_t fspr_atomic_xchg32(volatile fspr_uint32_t *mem, fspr_uint32_t val) { - apr_uint32_t old, new_val; + fspr_uint32_t old, new_val; old = *mem; /* old is automatically updated on cs failure */ do { diff --git a/libs/apr/atomic/unix/apr_atomic.c b/libs/apr/atomic/unix/fspr_atomic.c similarity index 65% rename from libs/apr/atomic/unix/apr_atomic.c rename to libs/apr/atomic/unix/fspr_atomic.c index 3110d96d7c..6a366a1a73 100644 --- a/libs/apr/atomic/unix/apr_atomic.c +++ b/libs/apr/atomic/unix/fspr_atomic.c @@ -14,11 +14,11 @@ * limitations under the License. */ -#include "apr.h" -#include "apr_atomic.h" -#include "apr_thread_mutex.h" +#include "fspr.h" +#include "fspr_atomic.h" +#include "fspr_thread_mutex.h" -#include "apr_private.h" +#include "fspr_private.h" #include @@ -31,11 +31,11 @@ #if (defined(__i386__) || defined(__x86_64__)) \ && defined(__GNUC__) && !defined(USE_GENERIC_ATOMICS) -APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem, - apr_uint32_t with, - apr_uint32_t cmp) +APR_DECLARE(fspr_uint32_t) fspr_atomic_cas32(volatile fspr_uint32_t *mem, + fspr_uint32_t with, + fspr_uint32_t cmp) { - apr_uint32_t prev; + fspr_uint32_t prev; asm volatile ("lock; cmpxchgl %1, %2" : "=a" (prev) @@ -45,8 +45,8 @@ APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem, } #define APR_OVERRIDE_ATOMIC_CAS32 -static apr_uint32_t inline intel_atomic_add32(volatile apr_uint32_t *mem, - apr_uint32_t val) +static fspr_uint32_t inline intel_atomic_add32(volatile fspr_uint32_t *mem, + fspr_uint32_t val) { asm volatile ("lock; xaddl %0,%1" : "=r"(val), "=m"(*mem) /* outputs */ @@ -55,14 +55,14 @@ static apr_uint32_t inline intel_atomic_add32(volatile apr_uint32_t *mem, return val; } -APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem, - apr_uint32_t val) +APR_DECLARE(fspr_uint32_t) fspr_atomic_add32(volatile fspr_uint32_t *mem, + fspr_uint32_t val) { return intel_atomic_add32(mem, val); } #define APR_OVERRIDE_ATOMIC_ADD32 -APR_DECLARE(void) apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val) +APR_DECLARE(void) fspr_atomic_sub32(volatile fspr_uint32_t *mem, fspr_uint32_t val) { asm volatile ("lock; subl %1, %0" : @@ -71,7 +71,7 @@ APR_DECLARE(void) apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val) } #define APR_OVERRIDE_ATOMIC_SUB32 -APR_DECLARE(int) apr_atomic_dec32(volatile apr_uint32_t *mem) +APR_DECLARE(int) fspr_atomic_dec32(volatile fspr_uint32_t *mem) { unsigned char prev; @@ -84,21 +84,21 @@ APR_DECLARE(int) apr_atomic_dec32(volatile apr_uint32_t *mem) } #define APR_OVERRIDE_ATOMIC_DEC32 -APR_DECLARE(apr_uint32_t) apr_atomic_inc32(volatile apr_uint32_t *mem) +APR_DECLARE(fspr_uint32_t) fspr_atomic_inc32(volatile fspr_uint32_t *mem) { return intel_atomic_add32(mem, 1); } #define APR_OVERRIDE_ATOMIC_INC32 -APR_DECLARE(void) apr_atomic_set32(volatile apr_uint32_t *mem, apr_uint32_t val) +APR_DECLARE(void) fspr_atomic_set32(volatile fspr_uint32_t *mem, fspr_uint32_t val) { *mem = val; } #define APR_OVERRIDE_ATOMIC_SET32 -APR_DECLARE(apr_uint32_t) apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint32_t val) +APR_DECLARE(fspr_uint32_t) fspr_atomic_xchg32(volatile fspr_uint32_t *mem, fspr_uint32_t val) { - apr_uint32_t prev = val; + fspr_uint32_t prev = val; asm volatile ("lock; xchgl %0, %1" : "=r" (prev) @@ -108,18 +108,18 @@ APR_DECLARE(apr_uint32_t) apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint } #define APR_OVERRIDE_ATOMIC_XCHG32 -/*#define apr_atomic_init(pool) APR_SUCCESS*/ +/*#define fspr_atomic_init(pool) APR_SUCCESS*/ #endif /* (__linux__ || __EMX__ || __FreeBSD__) && __i386__ */ #if (defined(__PPC__) || defined(__ppc__)) && defined(__GNUC__) \ && !defined(USE_GENERIC_ATOMICS) -APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem, - apr_uint32_t swap, - apr_uint32_t cmp) +APR_DECLARE(fspr_uint32_t) fspr_atomic_cas32(volatile fspr_uint32_t *mem, + fspr_uint32_t swap, + fspr_uint32_t cmp) { - apr_uint32_t prev; + fspr_uint32_t prev; asm volatile ("0:\n\t" /* retry local label */ "lwarx %0,0,%1\n\t" /* load prev and reserve */ @@ -138,10 +138,10 @@ APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem, } #define APR_OVERRIDE_ATOMIC_CAS32 -APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem, - apr_uint32_t delta) +APR_DECLARE(fspr_uint32_t) fspr_atomic_add32(volatile fspr_uint32_t *mem, + fspr_uint32_t delta) { - apr_uint32_t prev, temp; + fspr_uint32_t prev, temp; asm volatile ("0:\n\t" /* retry local label */ "lwarx %0,0,%2\n\t" /* load prev and reserve */ @@ -168,18 +168,18 @@ APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem, #define NUM_ATOMIC_HASH 7 /* shift by 2 to get rid of alignment issues */ #define ATOMIC_HASH(x) (unsigned int)(((unsigned long)(x)>>2)%(unsigned int)NUM_ATOMIC_HASH) -static apr_thread_mutex_t **hash_mutex; +static fspr_thread_mutex_t **hash_mutex; #endif /* APR_HAS_THREADS */ -apr_status_t apr_atomic_init(apr_pool_t *p) +fspr_status_t fspr_atomic_init(fspr_pool_t *p) { #if APR_HAS_THREADS int i; - apr_status_t rv; - hash_mutex = apr_palloc(p, sizeof(apr_thread_mutex_t*) * NUM_ATOMIC_HASH); + fspr_status_t rv; + hash_mutex = fspr_palloc(p, sizeof(fspr_thread_mutex_t*) * NUM_ATOMIC_HASH); for (i = 0; i < NUM_ATOMIC_HASH; i++) { - rv = apr_thread_mutex_create(&(hash_mutex[i]), + rv = fspr_thread_mutex_create(&(hash_mutex[i]), APR_THREAD_MUTEX_DEFAULT, p); if (rv != APR_SUCCESS) { return rv; @@ -195,28 +195,28 @@ apr_status_t apr_atomic_init(apr_pool_t *p) #if !defined(APR_OVERRIDE_ATOMIC_ADD32) #if defined(APR_OVERRIDE_ATOMIC_CAS32) -apr_uint32_t apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val) +fspr_uint32_t fspr_atomic_add32(volatile fspr_uint32_t *mem, fspr_uint32_t val) { - apr_uint32_t old_value, new_value; + fspr_uint32_t old_value, new_value; do { old_value = *mem; new_value = old_value + val; - } while (apr_atomic_cas32(mem, new_value, old_value) != old_value); + } while (fspr_atomic_cas32(mem, new_value, old_value) != old_value); return old_value; } #else -apr_uint32_t apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val) +fspr_uint32_t fspr_atomic_add32(volatile fspr_uint32_t *mem, fspr_uint32_t val) { - apr_uint32_t old_value; + fspr_uint32_t old_value; #if APR_HAS_THREADS - apr_thread_mutex_t *lock = hash_mutex[ATOMIC_HASH(mem)]; + fspr_thread_mutex_t *lock = hash_mutex[ATOMIC_HASH(mem)]; - CHECK(apr_thread_mutex_lock(lock)); + CHECK(fspr_thread_mutex_lock(lock)); old_value = *mem; *mem += val; - CHECK(apr_thread_mutex_unlock(lock)); + CHECK(fspr_thread_mutex_unlock(lock)); #else old_value = *mem; *mem += val; @@ -228,24 +228,24 @@ apr_uint32_t apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val) #if !defined(APR_OVERRIDE_ATOMIC_SUB32) #if defined(APR_OVERRIDE_ATOMIC_CAS32) -void apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val) +void fspr_atomic_sub32(volatile fspr_uint32_t *mem, fspr_uint32_t val) { - apr_uint32_t old_value, new_value; + fspr_uint32_t old_value, new_value; do { old_value = *mem; new_value = old_value - val; - } while (apr_atomic_cas32(mem, new_value, old_value) != old_value); + } while (fspr_atomic_cas32(mem, new_value, old_value) != old_value); } #else -void apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val) +void fspr_atomic_sub32(volatile fspr_uint32_t *mem, fspr_uint32_t val) { #if APR_HAS_THREADS - apr_thread_mutex_t *lock = hash_mutex[ATOMIC_HASH(mem)]; + fspr_thread_mutex_t *lock = hash_mutex[ATOMIC_HASH(mem)]; - CHECK(apr_thread_mutex_lock(lock)); + CHECK(fspr_thread_mutex_lock(lock)); *mem -= val; - CHECK(apr_thread_mutex_unlock(lock)); + CHECK(fspr_thread_mutex_unlock(lock)); #else *mem -= val; #endif /* APR_HAS_THREADS */ @@ -254,14 +254,14 @@ void apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val) #endif /* !defined(APR_OVERRIDE_ATOMIC_SUB32) */ #if !defined(APR_OVERRIDE_ATOMIC_SET32) -void apr_atomic_set32(volatile apr_uint32_t *mem, apr_uint32_t val) +void fspr_atomic_set32(volatile fspr_uint32_t *mem, fspr_uint32_t val) { #if APR_HAS_THREADS - apr_thread_mutex_t *lock = hash_mutex[ATOMIC_HASH(mem)]; + fspr_thread_mutex_t *lock = hash_mutex[ATOMIC_HASH(mem)]; - CHECK(apr_thread_mutex_lock(lock)); + CHECK(fspr_thread_mutex_lock(lock)); *mem = val; - CHECK(apr_thread_mutex_unlock(lock)); + CHECK(fspr_thread_mutex_unlock(lock)); #else *mem = val; #endif /* APR_HAS_THREADS */ @@ -269,35 +269,35 @@ void apr_atomic_set32(volatile apr_uint32_t *mem, apr_uint32_t val) #endif /* !defined(APR_OVERRIDE_ATOMIC_SET32) */ #if !defined(APR_OVERRIDE_ATOMIC_INC32) -apr_uint32_t apr_atomic_inc32(volatile apr_uint32_t *mem) +fspr_uint32_t fspr_atomic_inc32(volatile fspr_uint32_t *mem) { - return apr_atomic_add32(mem, 1); + return fspr_atomic_add32(mem, 1); } #endif /* !defined(APR_OVERRIDE_ATOMIC_INC32) */ #if !defined(APR_OVERRIDE_ATOMIC_DEC32) #if defined(APR_OVERRIDE_ATOMIC_CAS32) -int apr_atomic_dec32(volatile apr_uint32_t *mem) +int fspr_atomic_dec32(volatile fspr_uint32_t *mem) { - apr_uint32_t old_value, new_value; + fspr_uint32_t old_value, new_value; do { old_value = *mem; new_value = old_value - 1; - } while (apr_atomic_cas32(mem, new_value, old_value) != old_value); + } while (fspr_atomic_cas32(mem, new_value, old_value) != old_value); return old_value != 1; } #else -int apr_atomic_dec32(volatile apr_uint32_t *mem) +int fspr_atomic_dec32(volatile fspr_uint32_t *mem) { #if APR_HAS_THREADS - apr_thread_mutex_t *lock = hash_mutex[ATOMIC_HASH(mem)]; - apr_uint32_t new; + fspr_thread_mutex_t *lock = hash_mutex[ATOMIC_HASH(mem)]; + fspr_uint32_t new; - CHECK(apr_thread_mutex_lock(lock)); + CHECK(fspr_thread_mutex_lock(lock)); (*mem)--; new = *mem; - CHECK(apr_thread_mutex_unlock(lock)); + CHECK(fspr_thread_mutex_unlock(lock)); return new; #else (*mem)--; @@ -308,19 +308,19 @@ int apr_atomic_dec32(volatile apr_uint32_t *mem) #endif /* !defined(APR_OVERRIDE_ATOMIC_DEC32) */ #if !defined(APR_OVERRIDE_ATOMIC_CAS32) -apr_uint32_t apr_atomic_cas32(volatile apr_uint32_t *mem, apr_uint32_t with, - apr_uint32_t cmp) +fspr_uint32_t fspr_atomic_cas32(volatile fspr_uint32_t *mem, fspr_uint32_t with, + fspr_uint32_t cmp) { - apr_uint32_t prev; + fspr_uint32_t prev; #if APR_HAS_THREADS - apr_thread_mutex_t *lock = hash_mutex[ATOMIC_HASH(mem)]; + fspr_thread_mutex_t *lock = hash_mutex[ATOMIC_HASH(mem)]; - CHECK(apr_thread_mutex_lock(lock)); + CHECK(fspr_thread_mutex_lock(lock)); prev = *mem; if (prev == cmp) { *mem = with; } - CHECK(apr_thread_mutex_unlock(lock)); + CHECK(fspr_thread_mutex_unlock(lock)); #else prev = *mem; if (prev == cmp) { @@ -333,25 +333,25 @@ apr_uint32_t apr_atomic_cas32(volatile apr_uint32_t *mem, apr_uint32_t with, #if !defined(APR_OVERRIDE_ATOMIC_XCHG32) #if defined(APR_OVERRIDE_ATOMIC_CAS32) -apr_uint32_t apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint32_t val) +fspr_uint32_t fspr_atomic_xchg32(volatile fspr_uint32_t *mem, fspr_uint32_t val) { - apr_uint32_t prev; + fspr_uint32_t prev; do { prev = *mem; - } while (apr_atomic_cas32(mem, val, prev) != prev); + } while (fspr_atomic_cas32(mem, val, prev) != prev); return prev; } #else -apr_uint32_t apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint32_t val) +fspr_uint32_t fspr_atomic_xchg32(volatile fspr_uint32_t *mem, fspr_uint32_t val) { - apr_uint32_t prev; + fspr_uint32_t prev; #if APR_HAS_THREADS - apr_thread_mutex_t *lock = hash_mutex[ATOMIC_HASH(mem)]; + fspr_thread_mutex_t *lock = hash_mutex[ATOMIC_HASH(mem)]; - CHECK(apr_thread_mutex_lock(lock)); + CHECK(fspr_thread_mutex_lock(lock)); prev = *mem; *mem = val; - CHECK(apr_thread_mutex_unlock(lock)); + CHECK(fspr_thread_mutex_unlock(lock)); #else prev = *mem; *mem = val; @@ -362,18 +362,18 @@ apr_uint32_t apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint32_t val) #endif /* !defined(APR_OVERRIDE_ATOMIC_XCHG32) */ #if !defined(APR_OVERRIDE_ATOMIC_CASPTR) -void *apr_atomic_casptr(volatile void **mem, void *with, const void *cmp) +void *fspr_atomic_casptr(volatile void **mem, void *with, const void *cmp) { void *prev; #if APR_HAS_THREADS - apr_thread_mutex_t *lock = hash_mutex[ATOMIC_HASH(mem)]; + fspr_thread_mutex_t *lock = hash_mutex[ATOMIC_HASH(mem)]; - CHECK(apr_thread_mutex_lock(lock)); + CHECK(fspr_thread_mutex_lock(lock)); prev = *(void **)mem; if (prev == cmp) { *mem = with; } - CHECK(apr_thread_mutex_unlock(lock)); + CHECK(fspr_thread_mutex_unlock(lock)); #else prev = *(void **)mem; if (prev == cmp) { @@ -385,7 +385,7 @@ void *apr_atomic_casptr(volatile void **mem, void *with, const void *cmp) #endif /* !defined(APR_OVERRIDE_ATOMIC_CASPTR) */ #if !defined(APR_OVERRIDE_ATOMIC_READ32) -APR_DECLARE(apr_uint32_t) apr_atomic_read32(volatile apr_uint32_t *mem) +APR_DECLARE(fspr_uint32_t) fspr_atomic_read32(volatile fspr_uint32_t *mem) { return *mem; } diff --git a/libs/apr/atomic/win32/apr_atomic.c b/libs/apr/atomic/win32/fspr_atomic.c similarity index 56% rename from libs/apr/atomic/win32/apr_atomic.c rename to libs/apr/atomic/win32/fspr_atomic.c index 18a7bcd0ba..e9cfc0558a 100644 --- a/libs/apr/atomic/win32/apr_atomic.c +++ b/libs/apr/atomic/win32/fspr_atomic.c @@ -14,59 +14,59 @@ * limitations under the License. */ -#include "apr.h" -#include "apr_atomic.h" -#include "apr_thread_mutex.h" +#include "fspr.h" +#include "fspr_atomic.h" +#include "fspr_thread_mutex.h" -APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_atomic_init(fspr_pool_t *p) { return APR_SUCCESS; } /* - * Remapping function pointer type to accept apr_uint32_t's type-safely - * as the arguments for as our apr_atomic_foo32 Functions + * Remapping function pointer type to accept fspr_uint32_t's type-safely + * as the arguments for as our fspr_atomic_foo32 Functions */ #if (_MSC_VER < 1800) -typedef WINBASEAPI apr_uint32_t (WINAPI * apr_atomic_win32_ptr_fn) - (apr_uint32_t volatile *); -typedef WINBASEAPI apr_uint32_t (WINAPI * apr_atomic_win32_ptr_val_fn) - (apr_uint32_t volatile *, - apr_uint32_t); -typedef WINBASEAPI apr_uint32_t (WINAPI * apr_atomic_win32_ptr_val_val_fn) - (apr_uint32_t volatile *, - apr_uint32_t, apr_uint32_t); -typedef WINBASEAPI void * (WINAPI * apr_atomic_win32_ptr_ptr_ptr_fn) +typedef WINBASEAPI fspr_uint32_t (WINAPI * fspr_atomic_win32_ptr_fn) + (fspr_uint32_t volatile *); +typedef WINBASEAPI fspr_uint32_t (WINAPI * fspr_atomic_win32_ptr_val_fn) + (fspr_uint32_t volatile *, + fspr_uint32_t); +typedef WINBASEAPI fspr_uint32_t (WINAPI * fspr_atomic_win32_ptr_val_val_fn) + (fspr_uint32_t volatile *, + fspr_uint32_t, fspr_uint32_t); +typedef WINBASEAPI void * (WINAPI * fspr_atomic_win32_ptr_ptr_ptr_fn) (volatile void **, void *, const void *); #endif -APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val) +APR_DECLARE(fspr_uint32_t) fspr_atomic_add32(volatile fspr_uint32_t *mem, fspr_uint32_t val) { #if (defined(_M_IA64) || defined(_M_AMD64)) return InterlockedExchangeAdd(mem, val); #elif (_MSC_VER >= 1800) return InterlockedExchangeAdd(mem, val); #else - return ((apr_atomic_win32_ptr_val_fn)InterlockedExchangeAdd)(mem, val); + return ((fspr_atomic_win32_ptr_val_fn)InterlockedExchangeAdd)(mem, val); #endif } /* Of course we want the 2's compliment of the unsigned value, val */ #pragma warning(disable: 4146) -APR_DECLARE(void) apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val) +APR_DECLARE(void) fspr_atomic_sub32(volatile fspr_uint32_t *mem, fspr_uint32_t val) { #if (defined(_M_IA64) || defined(_M_AMD64)) InterlockedExchangeAdd(mem, -val); #elif (_MSC_VER >= 1800) InterlockedExchangeAdd(mem, -val); #else - ((apr_atomic_win32_ptr_val_fn)InterlockedExchangeAdd)(mem, -val); + ((fspr_atomic_win32_ptr_val_fn)InterlockedExchangeAdd)(mem, -val); #endif } -APR_DECLARE(apr_uint32_t) apr_atomic_inc32(volatile apr_uint32_t *mem) +APR_DECLARE(fspr_uint32_t) fspr_atomic_inc32(volatile fspr_uint32_t *mem) { /* we return old value, win32 returns new value :( */ #if (defined(_M_IA64) || defined(_M_AMD64)) && !defined(RC_INVOKED) @@ -74,50 +74,50 @@ APR_DECLARE(apr_uint32_t) apr_atomic_inc32(volatile apr_uint32_t *mem) #elif (_MSC_VER >= 1800) return InterlockedIncrement(mem) - 1; #else - return ((apr_atomic_win32_ptr_fn)InterlockedIncrement)(mem) - 1; + return ((fspr_atomic_win32_ptr_fn)InterlockedIncrement)(mem) - 1; #endif } -APR_DECLARE(int) apr_atomic_dec32(volatile apr_uint32_t *mem) +APR_DECLARE(int) fspr_atomic_dec32(volatile fspr_uint32_t *mem) { #if (defined(_M_IA64) || defined(_M_AMD64)) && !defined(RC_INVOKED) return InterlockedDecrement(mem); #elif (_MSC_VER >= 1800) return InterlockedDecrement(mem); #else - return ((apr_atomic_win32_ptr_fn)InterlockedDecrement)(mem); + return ((fspr_atomic_win32_ptr_fn)InterlockedDecrement)(mem); #endif } -APR_DECLARE(void) apr_atomic_set32(volatile apr_uint32_t *mem, apr_uint32_t val) +APR_DECLARE(void) fspr_atomic_set32(volatile fspr_uint32_t *mem, fspr_uint32_t val) { #if (defined(_M_IA64) || defined(_M_AMD64)) && !defined(RC_INVOKED) InterlockedExchange(mem, val); #elif (_MSC_VER >= 1800) InterlockedExchange(mem, val); #else - ((apr_atomic_win32_ptr_val_fn)InterlockedExchange)(mem, val); + ((fspr_atomic_win32_ptr_val_fn)InterlockedExchange)(mem, val); #endif } -APR_DECLARE(apr_uint32_t) apr_atomic_read32(volatile apr_uint32_t *mem) +APR_DECLARE(fspr_uint32_t) fspr_atomic_read32(volatile fspr_uint32_t *mem) { return *mem; } -APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem, apr_uint32_t with, - apr_uint32_t cmp) +APR_DECLARE(fspr_uint32_t) fspr_atomic_cas32(volatile fspr_uint32_t *mem, fspr_uint32_t with, + fspr_uint32_t cmp) { #if (defined(_M_IA64) || defined(_M_AMD64)) && !defined(RC_INVOKED) return InterlockedCompareExchange(mem, with, cmp); #elif (_MSC_VER >= 1800) return InterlockedCompareExchange(mem, with, cmp); #else - return ((apr_atomic_win32_ptr_val_val_fn)InterlockedCompareExchange)(mem, with, cmp); + return ((fspr_atomic_win32_ptr_val_val_fn)InterlockedCompareExchange)(mem, with, cmp); #endif } -APR_DECLARE(void *) apr_atomic_casptr(volatile void **mem, void *with, const void *cmp) +APR_DECLARE(void *) fspr_atomic_casptr(volatile void **mem, void *with, const void *cmp) { #if (defined(_M_IA64) || defined(_M_AMD64)) && !defined(RC_INVOKED) return InterlockedCompareExchangePointer(mem, with, cmp); @@ -125,17 +125,17 @@ APR_DECLARE(void *) apr_atomic_casptr(volatile void **mem, void *with, const voi return InterlockedCompareExchangePointer(mem, with, cmp); #else /* Too many VC6 users have stale win32 API files, stub this */ - return ((apr_atomic_win32_ptr_ptr_ptr_fn)InterlockedCompareExchange)(mem, with, cmp); + return ((fspr_atomic_win32_ptr_ptr_ptr_fn)InterlockedCompareExchange)(mem, with, cmp); #endif } -APR_DECLARE(apr_uint32_t) apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint32_t val) +APR_DECLARE(fspr_uint32_t) fspr_atomic_xchg32(volatile fspr_uint32_t *mem, fspr_uint32_t val) { #if (defined(_M_IA64) || defined(_M_AMD64)) && !defined(RC_INVOKED) return InterlockedExchange(mem, val); #elif (_MSC_VER >= 1800) return InterlockedExchange(mem, val); #else - return ((apr_atomic_win32_ptr_val_fn)InterlockedExchange)(mem, val); + return ((fspr_atomic_win32_ptr_val_fn)InterlockedExchange)(mem, val); #endif } diff --git a/libs/apr/build-outputs.mk b/libs/apr/build-outputs.mk index 2c127688d1..d3e68a8bea 100644 --- a/libs/apr/build-outputs.mk +++ b/libs/apr/build-outputs.mk @@ -1,83 +1,83 @@ # DO NOT EDIT. AUTOMATICALLY GENERATED. -passwd/apr_getpass.lo: passwd/apr_getpass.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_errno.h include/apr_want.h include/apr_strings.h include/apr_thread_mutex.h include/apr_lib.h include/apr_pools.h -strings/apr_cpystrn.lo: strings/apr_cpystrn.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_errno.h include/apr_want.h include/apr_strings.h include/apr_thread_mutex.h include/apr_lib.h include/apr_pools.h -strings/apr_strnatcmp.lo: strings/apr_strnatcmp.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_errno.h include/apr_want.h include/apr_strings.h include/apr_thread_mutex.h include/apr_lib.h include/apr_pools.h -strings/apr_strings.lo: strings/apr_strings.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_errno.h include/apr_want.h include/apr_strings.h include/apr_thread_mutex.h include/apr_lib.h include/apr_pools.h -strings/apr_strtok.lo: strings/apr_strtok.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_errno.h include/apr_want.h include/apr_strings.h include/apr_thread_mutex.h include/apr_pools.h -strings/apr_fnmatch.lo: strings/apr_fnmatch.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_errno.h include/apr_want.h include/apr_file_info.h include/apr_user.h include/apr_fnmatch.h include/apr_strings.h include/apr_thread_mutex.h include/apr_lib.h include/apr_time.h include/apr_pools.h include/apr_tables.h -strings/apr_snprintf.lo: strings/apr_snprintf.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_tables.h include/apr_errno.h include/apr_proc_mutex.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_want.h include/apr_lib.h include/apr_shm.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h -tables/apr_tables.lo: tables/apr_tables.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_errno.h include/apr_want.h include/apr_strings.h include/apr_thread_mutex.h include/apr_lib.h include/apr_pools.h include/apr_tables.h -tables/apr_hash.lo: tables/apr_hash.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_errno.h include/apr_want.h include/apr_thread_mutex.h include/apr_hash.h include/apr_pools.h +passwd/fspr_getpass.lo: passwd/fspr_getpass.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_errno.h include/fspr_want.h include/fspr_strings.h include/fspr_thread_mutex.h include/fspr_lib.h include/fspr_pools.h +strings/fspr_cpystrn.lo: strings/fspr_cpystrn.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_errno.h include/fspr_want.h include/fspr_strings.h include/fspr_thread_mutex.h include/fspr_lib.h include/fspr_pools.h +strings/fspr_strnatcmp.lo: strings/fspr_strnatcmp.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_errno.h include/fspr_want.h include/fspr_strings.h include/fspr_thread_mutex.h include/fspr_lib.h include/fspr_pools.h +strings/fspr_strings.lo: strings/fspr_strings.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_errno.h include/fspr_want.h include/fspr_strings.h include/fspr_thread_mutex.h include/fspr_lib.h include/fspr_pools.h +strings/fspr_strtok.lo: strings/fspr_strtok.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_errno.h include/fspr_want.h include/fspr_strings.h include/fspr_thread_mutex.h include/fspr_pools.h +strings/fspr_fnmatch.lo: strings/fspr_fnmatch.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_errno.h include/fspr_want.h include/fspr_file_info.h include/fspr_user.h include/fspr_fnmatch.h include/fspr_strings.h include/fspr_thread_mutex.h include/fspr_lib.h include/fspr_time.h include/fspr_pools.h include/fspr_tables.h +strings/fspr_snprintf.lo: strings/fspr_snprintf.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_tables.h include/fspr_errno.h include/fspr_proc_mutex.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_want.h include/fspr_lib.h include/fspr_shm.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h +tables/fspr_tables.lo: tables/fspr_tables.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_errno.h include/fspr_want.h include/fspr_strings.h include/fspr_thread_mutex.h include/fspr_lib.h include/fspr_pools.h include/fspr_tables.h +tables/fspr_hash.lo: tables/fspr_hash.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_errno.h include/fspr_want.h include/fspr_thread_mutex.h include/fspr_hash.h include/fspr_pools.h -OBJECTS_all = passwd/apr_getpass.lo strings/apr_cpystrn.lo strings/apr_strnatcmp.lo strings/apr_strings.lo strings/apr_strtok.lo strings/apr_fnmatch.lo strings/apr_snprintf.lo tables/apr_tables.lo tables/apr_hash.lo +OBJECTS_all = passwd/fspr_getpass.lo strings/fspr_cpystrn.lo strings/fspr_strnatcmp.lo strings/fspr_strings.lo strings/fspr_strtok.lo strings/fspr_fnmatch.lo strings/fspr_snprintf.lo tables/fspr_tables.lo tables/fspr_hash.lo -atomic/unix/apr_atomic.lo: atomic/unix/apr_atomic.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_errno.h include/apr_want.h include/apr_thread_mutex.h include/apr_atomic.h include/apr_pools.h +atomic/unix/fspr_atomic.lo: atomic/unix/fspr_atomic.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_errno.h include/fspr_want.h include/fspr_thread_mutex.h include/fspr_atomic.h include/fspr_pools.h -OBJECTS_atomic_unix = atomic/unix/apr_atomic.lo +OBJECTS_atomic_unix = atomic/unix/fspr_atomic.lo -dso/unix/dso.lo: dso/unix/dso.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_tables.h include/apr_errno.h include/apr_proc_mutex.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_want.h include/apr_shm.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h +dso/unix/dso.lo: dso/unix/dso.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_tables.h include/fspr_errno.h include/fspr_proc_mutex.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_want.h include/fspr_shm.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h OBJECTS_dso_unix = dso/unix/dso.lo file_io/unix/flock.lo: file_io/unix/flock.c .make.dirs -file_io/unix/readwrite.lo: file_io/unix/readwrite.c .make.dirs include/apr_support.h include/apr_allocator.h include/apr_network_io.h include/apr_general.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_tables.h include/apr_errno.h include/apr_want.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_time.h include/apr_pools.h -file_io/unix/filepath_util.lo: file_io/unix/filepath_util.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_errno.h include/apr_want.h include/apr_strings.h include/apr_thread_mutex.h include/apr_pools.h include/apr_tables.h +file_io/unix/readwrite.lo: file_io/unix/readwrite.c .make.dirs include/fspr_support.h include/fspr_allocator.h include/fspr_network_io.h include/fspr_general.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_tables.h include/fspr_errno.h include/fspr_want.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_time.h include/fspr_pools.h +file_io/unix/filepath_util.lo: file_io/unix/filepath_util.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_errno.h include/fspr_want.h include/fspr_strings.h include/fspr_thread_mutex.h include/fspr_pools.h include/fspr_tables.h file_io/unix/seek.lo: file_io/unix/seek.c .make.dirs -file_io/unix/dir.lo: file_io/unix/dir.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_tables.h include/apr_errno.h include/apr_proc_mutex.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_want.h include/apr_shm.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h -file_io/unix/mktemp.lo: file_io/unix/mktemp.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_tables.h include/apr_errno.h include/apr_proc_mutex.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_want.h include/apr_shm.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h -file_io/unix/filedup.lo: file_io/unix/filedup.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_tables.h include/apr_errno.h include/apr_want.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_proc_mutex.h include/apr_shm.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h -file_io/unix/tempdir.lo: file_io/unix/tempdir.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_errno.h include/apr_env.h include/apr_file_info.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_want.h include/apr_thread_mutex.h include/apr_inherit.h include/apr_time.h include/apr_pools.h include/apr_tables.h -file_io/unix/filepath.lo: file_io/unix/filepath.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_errno.h include/apr_want.h include/apr_file_info.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_inherit.h include/apr_thread_mutex.h include/apr_time.h include/apr_pools.h include/apr_tables.h -file_io/unix/pipe.lo: file_io/unix/pipe.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_tables.h include/apr_errno.h include/apr_proc_mutex.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_want.h include/apr_shm.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h -file_io/unix/open.lo: file_io/unix/open.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_tables.h include/apr_errno.h include/apr_want.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_proc_mutex.h include/apr_hash.h include/apr_shm.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h -file_io/unix/filestat.lo: file_io/unix/filestat.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_errno.h include/apr_want.h include/apr_file_info.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_inherit.h include/apr_thread_mutex.h include/apr_time.h include/apr_pools.h include/apr_tables.h -file_io/unix/copy.lo: file_io/unix/copy.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_errno.h include/apr_inherit.h include/apr_file_info.h include/apr_user.h include/apr_file_io.h include/apr_want.h include/apr_thread_mutex.h include/apr_time.h include/apr_pools.h include/apr_tables.h -file_io/unix/fileacc.lo: file_io/unix/fileacc.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_thread_mutex.h include/apr_errno.h include/apr_want.h include/apr_pools.h include/apr_strings.h -file_io/unix/fullrw.lo: file_io/unix/fullrw.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_errno.h include/apr_inherit.h include/apr_file_info.h include/apr_user.h include/apr_file_io.h include/apr_want.h include/apr_thread_mutex.h include/apr_time.h include/apr_pools.h include/apr_tables.h +file_io/unix/dir.lo: file_io/unix/dir.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_tables.h include/fspr_errno.h include/fspr_proc_mutex.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_want.h include/fspr_shm.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h +file_io/unix/mktemp.lo: file_io/unix/mktemp.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_tables.h include/fspr_errno.h include/fspr_proc_mutex.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_want.h include/fspr_shm.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h +file_io/unix/filedup.lo: file_io/unix/filedup.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_tables.h include/fspr_errno.h include/fspr_want.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_proc_mutex.h include/fspr_shm.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h +file_io/unix/tempdir.lo: file_io/unix/tempdir.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_errno.h include/fspr_env.h include/fspr_file_info.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_want.h include/fspr_thread_mutex.h include/fspr_inherit.h include/fspr_time.h include/fspr_pools.h include/fspr_tables.h +file_io/unix/filepath.lo: file_io/unix/filepath.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_errno.h include/fspr_want.h include/fspr_file_info.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_inherit.h include/fspr_thread_mutex.h include/fspr_time.h include/fspr_pools.h include/fspr_tables.h +file_io/unix/pipe.lo: file_io/unix/pipe.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_tables.h include/fspr_errno.h include/fspr_proc_mutex.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_want.h include/fspr_shm.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h +file_io/unix/open.lo: file_io/unix/open.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_tables.h include/fspr_errno.h include/fspr_want.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_proc_mutex.h include/fspr_hash.h include/fspr_shm.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h +file_io/unix/filestat.lo: file_io/unix/filestat.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_errno.h include/fspr_want.h include/fspr_file_info.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_inherit.h include/fspr_thread_mutex.h include/fspr_time.h include/fspr_pools.h include/fspr_tables.h +file_io/unix/copy.lo: file_io/unix/copy.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_errno.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_user.h include/fspr_file_io.h include/fspr_want.h include/fspr_thread_mutex.h include/fspr_time.h include/fspr_pools.h include/fspr_tables.h +file_io/unix/fileacc.lo: file_io/unix/fileacc.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_thread_mutex.h include/fspr_errno.h include/fspr_want.h include/fspr_pools.h include/fspr_strings.h +file_io/unix/fullrw.lo: file_io/unix/fullrw.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_errno.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_user.h include/fspr_file_io.h include/fspr_want.h include/fspr_thread_mutex.h include/fspr_time.h include/fspr_pools.h include/fspr_tables.h OBJECTS_file_io_unix = file_io/unix/flock.lo file_io/unix/readwrite.lo file_io/unix/filepath_util.lo file_io/unix/seek.lo file_io/unix/dir.lo file_io/unix/mktemp.lo file_io/unix/filedup.lo file_io/unix/tempdir.lo file_io/unix/filepath.lo file_io/unix/pipe.lo file_io/unix/open.lo file_io/unix/filestat.lo file_io/unix/copy.lo file_io/unix/fileacc.lo file_io/unix/fullrw.lo locks/unix/thread_rwlock.lo: locks/unix/thread_rwlock.c .make.dirs -locks/unix/thread_mutex.lo: locks/unix/thread_mutex.c .make.dirs include/apr_want.h +locks/unix/thread_mutex.lo: locks/unix/thread_mutex.c .make.dirs include/fspr_want.h locks/unix/thread_cond.lo: locks/unix/thread_cond.c .make.dirs -locks/unix/proc_mutex.lo: locks/unix/proc_mutex.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_thread_mutex.h include/apr_errno.h include/apr_want.h include/apr_pools.h include/apr_strings.h -locks/unix/global_mutex.lo: locks/unix/global_mutex.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_tables.h include/apr_errno.h include/apr_proc_mutex.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_want.h include/apr_shm.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h +locks/unix/proc_mutex.lo: locks/unix/proc_mutex.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_thread_mutex.h include/fspr_errno.h include/fspr_want.h include/fspr_pools.h include/fspr_strings.h +locks/unix/global_mutex.lo: locks/unix/global_mutex.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_tables.h include/fspr_errno.h include/fspr_proc_mutex.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_want.h include/fspr_shm.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h OBJECTS_locks_unix = locks/unix/thread_rwlock.lo locks/unix/thread_mutex.lo locks/unix/thread_cond.lo locks/unix/proc_mutex.lo locks/unix/global_mutex.lo -memory/unix/apr_pools.lo: memory/unix/apr_pools.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_env.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_atomic.h include/apr_tables.h include/apr_errno.h include/apr_want.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_inherit.h include/apr_hash.h include/apr_lib.h include/apr_proc_mutex.h include/apr_shm.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h +memory/unix/fspr_pools.lo: memory/unix/fspr_pools.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_env.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_atomic.h include/fspr_tables.h include/fspr_errno.h include/fspr_want.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_inherit.h include/fspr_hash.h include/fspr_lib.h include/fspr_proc_mutex.h include/fspr_shm.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h -OBJECTS_memory_unix = memory/unix/apr_pools.lo +OBJECTS_memory_unix = memory/unix/fspr_pools.lo -misc/unix/charset.lo: misc/unix/charset.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_tables.h include/apr_errno.h include/apr_proc_mutex.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_want.h include/apr_shm.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h -misc/unix/env.lo: misc/unix/env.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_errno.h include/apr_want.h include/apr_env.h include/apr_thread_mutex.h include/apr_pools.h -misc/unix/version.lo: misc/unix/version.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_errno.h include/apr_want.h include/apr_version.h include/apr_thread_mutex.h include/apr_pools.h -misc/unix/rand.lo: misc/unix/rand.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_errno.h include/apr_want.h include/apr_thread_mutex.h include/apr_pools.h -misc/unix/start.lo: misc/unix/start.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_errno.h include/apr_signal.h include/apr_want.h include/apr_thread_mutex.h include/apr_atomic.h include/apr_pools.h -misc/unix/errorcodes.lo: misc/unix/errorcodes.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_errno.h include/apr_want.h include/apr_strings.h include/apr_thread_mutex.h include/apr_lib.h include/apr_dso.h include/apr_pools.h -misc/unix/getopt.lo: misc/unix/getopt.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_errno.h include/apr_want.h include/apr_strings.h include/apr_thread_mutex.h include/apr_lib.h include/apr_pools.h +misc/unix/charset.lo: misc/unix/charset.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_tables.h include/fspr_errno.h include/fspr_proc_mutex.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_want.h include/fspr_shm.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h +misc/unix/env.lo: misc/unix/env.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_errno.h include/fspr_want.h include/fspr_env.h include/fspr_thread_mutex.h include/fspr_pools.h +misc/unix/version.lo: misc/unix/version.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_errno.h include/fspr_want.h include/fspr_version.h include/fspr_thread_mutex.h include/fspr_pools.h +misc/unix/rand.lo: misc/unix/rand.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_errno.h include/fspr_want.h include/fspr_thread_mutex.h include/fspr_pools.h +misc/unix/start.lo: misc/unix/start.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_errno.h include/fspr_signal.h include/fspr_want.h include/fspr_thread_mutex.h include/fspr_atomic.h include/fspr_pools.h +misc/unix/errorcodes.lo: misc/unix/errorcodes.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_errno.h include/fspr_want.h include/fspr_strings.h include/fspr_thread_mutex.h include/fspr_lib.h include/fspr_dso.h include/fspr_pools.h +misc/unix/getopt.lo: misc/unix/getopt.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_errno.h include/fspr_want.h include/fspr_strings.h include/fspr_thread_mutex.h include/fspr_lib.h include/fspr_pools.h misc/unix/otherchild.lo: misc/unix/otherchild.c .make.dirs OBJECTS_misc_unix = misc/unix/charset.lo misc/unix/env.lo misc/unix/version.lo misc/unix/rand.lo misc/unix/start.lo misc/unix/errorcodes.lo misc/unix/getopt.lo misc/unix/otherchild.lo -mmap/unix/mmap.lo: mmap/unix/mmap.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_tables.h include/apr_errno.h include/apr_want.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_proc_mutex.h include/apr_shm.h include/apr_ring.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h include/apr_mmap.h -mmap/unix/common.lo: mmap/unix/common.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_errno.h include/apr_inherit.h include/apr_file_info.h include/apr_user.h include/apr_file_io.h include/apr_want.h include/apr_thread_mutex.h include/apr_ring.h include/apr_tables.h include/apr_time.h include/apr_pools.h include/apr_mmap.h +mmap/unix/mmap.lo: mmap/unix/mmap.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_tables.h include/fspr_errno.h include/fspr_want.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_proc_mutex.h include/fspr_shm.h include/fspr_ring.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h include/fspr_mmap.h +mmap/unix/common.lo: mmap/unix/common.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_errno.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_user.h include/fspr_file_io.h include/fspr_want.h include/fspr_thread_mutex.h include/fspr_ring.h include/fspr_tables.h include/fspr_time.h include/fspr_pools.h include/fspr_mmap.h OBJECTS_mmap_unix = mmap/unix/mmap.lo mmap/unix/common.lo -network_io/unix/sockaddr.lo: network_io/unix/sockaddr.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_errno.h include/apr_want.h include/apr_strings.h include/apr_thread_mutex.h include/apr_lib.h include/apr_pools.h -network_io/unix/sockopt.lo: network_io/unix/sockopt.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_thread_mutex.h include/apr_errno.h include/apr_want.h include/apr_pools.h include/apr_strings.h -network_io/unix/sendrecv.lo: network_io/unix/sendrecv.c .make.dirs include/apr_support.h include/apr_allocator.h include/apr_user.h include/apr_network_io.h include/apr_general.h include/apr_inherit.h include/apr_file_info.h include/apr_errno.h include/apr_file_io.h include/apr_want.h include/apr_thread_mutex.h include/apr_time.h include/apr_pools.h include/apr_tables.h -network_io/unix/multicast.lo: network_io/unix/multicast.c .make.dirs include/apr_support.h include/apr_allocator.h include/apr_network_io.h include/apr_portable.h include/apr_inherit.h include/apr_file_info.h include/apr_general.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_tables.h include/apr_errno.h include/apr_want.h include/apr_user.h include/apr_file_io.h include/apr_proc_mutex.h include/apr_shm.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h -network_io/unix/sockets.lo: network_io/unix/sockets.c .make.dirs include/apr_support.h include/apr_allocator.h include/apr_network_io.h include/apr_portable.h include/apr_inherit.h include/apr_file_info.h include/apr_general.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_tables.h include/apr_errno.h include/apr_want.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_proc_mutex.h include/apr_shm.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h -network_io/unix/inet_ntop.lo: network_io/unix/inet_ntop.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_thread_mutex.h include/apr_errno.h include/apr_want.h include/apr_pools.h include/apr_strings.h +network_io/unix/sockaddr.lo: network_io/unix/sockaddr.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_errno.h include/fspr_want.h include/fspr_strings.h include/fspr_thread_mutex.h include/fspr_lib.h include/fspr_pools.h +network_io/unix/sockopt.lo: network_io/unix/sockopt.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_thread_mutex.h include/fspr_errno.h include/fspr_want.h include/fspr_pools.h include/fspr_strings.h +network_io/unix/sendrecv.lo: network_io/unix/sendrecv.c .make.dirs include/fspr_support.h include/fspr_allocator.h include/fspr_user.h include/fspr_network_io.h include/fspr_general.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_errno.h include/fspr_file_io.h include/fspr_want.h include/fspr_thread_mutex.h include/fspr_time.h include/fspr_pools.h include/fspr_tables.h +network_io/unix/multicast.lo: network_io/unix/multicast.c .make.dirs include/fspr_support.h include/fspr_allocator.h include/fspr_network_io.h include/fspr_portable.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_general.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_tables.h include/fspr_errno.h include/fspr_want.h include/fspr_user.h include/fspr_file_io.h include/fspr_proc_mutex.h include/fspr_shm.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h +network_io/unix/sockets.lo: network_io/unix/sockets.c .make.dirs include/fspr_support.h include/fspr_allocator.h include/fspr_network_io.h include/fspr_portable.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_general.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_tables.h include/fspr_errno.h include/fspr_want.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_proc_mutex.h include/fspr_shm.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h +network_io/unix/inet_ntop.lo: network_io/unix/inet_ntop.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_thread_mutex.h include/fspr_errno.h include/fspr_want.h include/fspr_pools.h include/fspr_strings.h network_io/unix/inet_pton.lo: network_io/unix/inet_pton.c .make.dirs OBJECTS_network_io_unix = network_io/unix/sockaddr.lo network_io/unix/sockopt.lo network_io/unix/sendrecv.lo network_io/unix/multicast.lo network_io/unix/sockets.lo network_io/unix/inet_ntop.lo network_io/unix/inet_pton.lo poll/unix/epoll.lo: poll/unix/epoll.c .make.dirs -poll/unix/select.lo: poll/unix/select.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_tables.h include/apr_errno.h include/apr_proc_mutex.h include/apr_user.h include/apr_file_io.h include/apr_want.h include/apr_poll.h include/apr_shm.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h +poll/unix/select.lo: poll/unix/select.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_tables.h include/fspr_errno.h include/fspr_proc_mutex.h include/fspr_user.h include/fspr_file_io.h include/fspr_want.h include/fspr_poll.h include/fspr_shm.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h poll/unix/poll.lo: poll/unix/poll.c .make.dirs poll/unix/port.lo: poll/unix/port.c .make.dirs poll/unix/kqueue.lo: poll/unix/kqueue.c .make.dirs @@ -85,147 +85,147 @@ poll/unix/kqueue.lo: poll/unix/kqueue.c .make.dirs OBJECTS_poll_unix = poll/unix/epoll.lo poll/unix/select.lo poll/unix/poll.lo poll/unix/port.lo poll/unix/kqueue.lo random/unix/sha2.lo: random/unix/sha2.c .make.dirs -random/unix/apr_random.lo: random/unix/apr_random.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_errno.h include/apr_inherit.h include/apr_file_info.h include/apr_user.h include/apr_file_io.h include/apr_want.h include/apr_thread_mutex.h include/apr_random.h include/apr_thread_proc.h include/apr_time.h include/apr_pools.h include/apr_tables.h -random/unix/sha2_glue.lo: random/unix/sha2_glue.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_errno.h include/apr_want.h include/apr_thread_mutex.h include/apr_random.h include/apr_pools.h +random/unix/fspr_random.lo: random/unix/fspr_random.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_errno.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_user.h include/fspr_file_io.h include/fspr_want.h include/fspr_thread_mutex.h include/fspr_random.h include/fspr_thread_proc.h include/fspr_time.h include/fspr_pools.h include/fspr_tables.h +random/unix/sha2_glue.lo: random/unix/sha2_glue.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_errno.h include/fspr_want.h include/fspr_thread_mutex.h include/fspr_random.h include/fspr_pools.h -OBJECTS_random_unix = random/unix/sha2.lo random/unix/apr_random.lo random/unix/sha2_glue.lo +OBJECTS_random_unix = random/unix/sha2.lo random/unix/fspr_random.lo random/unix/sha2_glue.lo -shmem/unix/shm.lo: shmem/unix/shm.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_errno.h include/apr_want.h include/apr_user.h include/apr_strings.h include/apr_thread_mutex.h include/apr_pools.h +shmem/unix/shm.lo: shmem/unix/shm.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_errno.h include/fspr_want.h include/fspr_user.h include/fspr_strings.h include/fspr_thread_mutex.h include/fspr_pools.h OBJECTS_shmem_unix = shmem/unix/shm.lo -support/unix/waitio.lo: support/unix/waitio.c .make.dirs include/apr_support.h include/apr_allocator.h include/apr_network_io.h include/apr_general.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_tables.h include/apr_errno.h include/apr_want.h include/apr_user.h include/apr_file_io.h include/apr_poll.h include/apr_time.h include/apr_pools.h +support/unix/waitio.lo: support/unix/waitio.c .make.dirs include/fspr_support.h include/fspr_allocator.h include/fspr_network_io.h include/fspr_general.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_tables.h include/fspr_errno.h include/fspr_want.h include/fspr_user.h include/fspr_file_io.h include/fspr_poll.h include/fspr_time.h include/fspr_pools.h OBJECTS_support_unix = support/unix/waitio.lo threadproc/unix/procsup.lo: threadproc/unix/procsup.c .make.dirs -threadproc/unix/thread.lo: threadproc/unix/thread.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_tables.h include/apr_errno.h include/apr_proc_mutex.h include/apr_user.h include/apr_file_io.h include/apr_want.h include/apr_shm.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h -threadproc/unix/signals.lo: threadproc/unix/signals.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_errno.h include/apr_signal.h include/apr_strings.h include/apr_want.h include/apr_thread_mutex.h include/apr_pools.h -threadproc/unix/proc.lo: threadproc/unix/proc.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_signal.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_proc_mutex.h include/apr_tables.h include/apr_errno.h include/apr_want.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_inherit.h include/apr_random.h include/apr_shm.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h -threadproc/unix/threadpriv.lo: threadproc/unix/threadpriv.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_tables.h include/apr_errno.h include/apr_proc_mutex.h include/apr_user.h include/apr_file_io.h include/apr_want.h include/apr_shm.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h +threadproc/unix/thread.lo: threadproc/unix/thread.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_tables.h include/fspr_errno.h include/fspr_proc_mutex.h include/fspr_user.h include/fspr_file_io.h include/fspr_want.h include/fspr_shm.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h +threadproc/unix/signals.lo: threadproc/unix/signals.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_errno.h include/fspr_signal.h include/fspr_strings.h include/fspr_want.h include/fspr_thread_mutex.h include/fspr_pools.h +threadproc/unix/proc.lo: threadproc/unix/proc.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_signal.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_proc_mutex.h include/fspr_tables.h include/fspr_errno.h include/fspr_want.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_inherit.h include/fspr_random.h include/fspr_shm.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h +threadproc/unix/threadpriv.lo: threadproc/unix/threadpriv.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_tables.h include/fspr_errno.h include/fspr_proc_mutex.h include/fspr_user.h include/fspr_file_io.h include/fspr_want.h include/fspr_shm.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h OBJECTS_threadproc_unix = threadproc/unix/procsup.lo threadproc/unix/thread.lo threadproc/unix/signals.lo threadproc/unix/proc.lo threadproc/unix/threadpriv.lo -time/unix/time.lo: time/unix/time.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_tables.h include/apr_errno.h include/apr_want.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_proc_mutex.h include/apr_lib.h include/apr_shm.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h -time/unix/timestr.lo: time/unix/timestr.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_tables.h include/apr_errno.h include/apr_want.h include/apr_user.h include/apr_file_io.h include/apr_proc_mutex.h include/apr_lib.h include/apr_shm.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h +time/unix/time.lo: time/unix/time.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_tables.h include/fspr_errno.h include/fspr_want.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_proc_mutex.h include/fspr_lib.h include/fspr_shm.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h +time/unix/timestr.lo: time/unix/timestr.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_tables.h include/fspr_errno.h include/fspr_want.h include/fspr_user.h include/fspr_file_io.h include/fspr_proc_mutex.h include/fspr_lib.h include/fspr_shm.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h OBJECTS_time_unix = time/unix/time.lo time/unix/timestr.lo -user/unix/userinfo.lo: user/unix/userinfo.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_tables.h include/apr_errno.h include/apr_want.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_proc_mutex.h include/apr_shm.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h -user/unix/groupinfo.lo: user/unix/groupinfo.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_tables.h include/apr_errno.h include/apr_proc_mutex.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_want.h include/apr_shm.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h +user/unix/userinfo.lo: user/unix/userinfo.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_tables.h include/fspr_errno.h include/fspr_want.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_proc_mutex.h include/fspr_shm.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h +user/unix/groupinfo.lo: user/unix/groupinfo.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_tables.h include/fspr_errno.h include/fspr_proc_mutex.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_want.h include/fspr_shm.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h OBJECTS_user_unix = user/unix/userinfo.lo user/unix/groupinfo.lo OBJECTS_unix = $(OBJECTS_all) $(OBJECTS_atomic_unix) $(OBJECTS_dso_unix) $(OBJECTS_file_io_unix) $(OBJECTS_locks_unix) $(OBJECTS_memory_unix) $(OBJECTS_misc_unix) $(OBJECTS_mmap_unix) $(OBJECTS_network_io_unix) $(OBJECTS_poll_unix) $(OBJECTS_random_unix) $(OBJECTS_shmem_unix) $(OBJECTS_support_unix) $(OBJECTS_threadproc_unix) $(OBJECTS_time_unix) $(OBJECTS_user_unix) -dso/aix/dso.lo: dso/aix/dso.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_tables.h include/apr_errno.h include/apr_proc_mutex.h include/apr_user.h include/apr_file_io.h include/apr_want.h include/apr_shm.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h +dso/aix/dso.lo: dso/aix/dso.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_tables.h include/fspr_errno.h include/fspr_proc_mutex.h include/fspr_user.h include/fspr_file_io.h include/fspr_want.h include/fspr_shm.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h OBJECTS_dso_aix = dso/aix/dso.lo OBJECTS_aix = $(OBJECTS_all) $(OBJECTS_atomic_unix) $(OBJECTS_dso_aix) $(OBJECTS_file_io_unix) $(OBJECTS_locks_unix) $(OBJECTS_memory_unix) $(OBJECTS_misc_unix) $(OBJECTS_mmap_unix) $(OBJECTS_network_io_unix) $(OBJECTS_poll_unix) $(OBJECTS_random_unix) $(OBJECTS_shmem_unix) $(OBJECTS_support_unix) $(OBJECTS_threadproc_unix) $(OBJECTS_time_unix) $(OBJECTS_user_unix) -dso/beos/dso.lo: dso/beos/dso.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_tables.h include/apr_errno.h include/apr_proc_mutex.h include/apr_user.h include/apr_file_io.h include/apr_want.h include/apr_shm.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h +dso/beos/dso.lo: dso/beos/dso.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_tables.h include/fspr_errno.h include/fspr_proc_mutex.h include/fspr_user.h include/fspr_file_io.h include/fspr_want.h include/fspr_shm.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h OBJECTS_dso_beos = dso/beos/dso.lo -locks/beos/thread_rwlock.lo: locks/beos/thread_rwlock.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_tables.h include/apr_errno.h include/apr_proc_mutex.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_want.h include/apr_shm.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h -locks/beos/thread_mutex.lo: locks/beos/thread_mutex.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_tables.h include/apr_errno.h include/apr_proc_mutex.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_want.h include/apr_shm.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h -locks/beos/thread_cond.lo: locks/beos/thread_cond.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_tables.h include/apr_errno.h include/apr_proc_mutex.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_want.h include/apr_shm.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h -locks/beos/proc_mutex.lo: locks/beos/proc_mutex.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_tables.h include/apr_errno.h include/apr_proc_mutex.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_want.h include/apr_shm.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h +locks/beos/thread_rwlock.lo: locks/beos/thread_rwlock.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_tables.h include/fspr_errno.h include/fspr_proc_mutex.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_want.h include/fspr_shm.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h +locks/beos/thread_mutex.lo: locks/beos/thread_mutex.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_tables.h include/fspr_errno.h include/fspr_proc_mutex.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_want.h include/fspr_shm.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h +locks/beos/thread_cond.lo: locks/beos/thread_cond.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_tables.h include/fspr_errno.h include/fspr_proc_mutex.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_want.h include/fspr_shm.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h +locks/beos/proc_mutex.lo: locks/beos/proc_mutex.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_tables.h include/fspr_errno.h include/fspr_proc_mutex.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_want.h include/fspr_shm.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h OBJECTS_locks_beos = locks/beos/thread_rwlock.lo locks/beos/thread_mutex.lo locks/beos/thread_cond.lo locks/beos/proc_mutex.lo network_io/beos/socketcommon.lo: network_io/beos/socketcommon.c .make.dirs -network_io/beos/sendrecv.lo: network_io/beos/sendrecv.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_thread_mutex.h include/apr_errno.h include/apr_want.h include/apr_time.h include/apr_pools.h +network_io/beos/sendrecv.lo: network_io/beos/sendrecv.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_thread_mutex.h include/fspr_errno.h include/fspr_want.h include/fspr_time.h include/fspr_pools.h OBJECTS_network_io_beos = network_io/beos/socketcommon.lo network_io/beos/sendrecv.lo -shmem/beos/shm.lo: shmem/beos/shm.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_tables.h include/apr_errno.h include/apr_want.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_proc_mutex.h include/apr_lib.h include/apr_shm.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h +shmem/beos/shm.lo: shmem/beos/shm.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_tables.h include/fspr_errno.h include/fspr_want.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_proc_mutex.h include/fspr_lib.h include/fspr_shm.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h OBJECTS_shmem_beos = shmem/beos/shm.lo -threadproc/beos/apr_proc_stub.lo: threadproc/beos/apr_proc_stub.c .make.dirs -threadproc/beos/thread.lo: threadproc/beos/thread.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_tables.h include/apr_errno.h include/apr_proc_mutex.h include/apr_user.h include/apr_file_io.h include/apr_want.h include/apr_shm.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h -threadproc/beos/proc.lo: threadproc/beos/proc.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_thread_mutex.h include/apr_errno.h include/apr_want.h include/apr_pools.h include/apr_strings.h +threadproc/beos/fspr_proc_stub.lo: threadproc/beos/fspr_proc_stub.c .make.dirs +threadproc/beos/thread.lo: threadproc/beos/thread.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_tables.h include/fspr_errno.h include/fspr_proc_mutex.h include/fspr_user.h include/fspr_file_io.h include/fspr_want.h include/fspr_shm.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h +threadproc/beos/proc.lo: threadproc/beos/proc.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_thread_mutex.h include/fspr_errno.h include/fspr_want.h include/fspr_pools.h include/fspr_strings.h threadproc/beos/threadpriv.lo: threadproc/beos/threadpriv.c .make.dirs threadproc/beos/threadproc_common.lo: threadproc/beos/threadproc_common.c .make.dirs -OBJECTS_threadproc_beos = threadproc/beos/apr_proc_stub.lo threadproc/beos/thread.lo threadproc/beos/proc.lo threadproc/beos/threadpriv.lo threadproc/beos/threadproc_common.lo +OBJECTS_threadproc_beos = threadproc/beos/fspr_proc_stub.lo threadproc/beos/thread.lo threadproc/beos/proc.lo threadproc/beos/threadpriv.lo threadproc/beos/threadproc_common.lo OBJECTS_beos = $(OBJECTS_all) $(OBJECTS_atomic_unix) $(OBJECTS_dso_beos) $(OBJECTS_file_io_unix) $(OBJECTS_locks_beos) $(OBJECTS_memory_unix) $(OBJECTS_misc_unix) $(OBJECTS_mmap_unix) $(OBJECTS_network_io_beos) $(OBJECTS_poll_unix) $(OBJECTS_random_unix) $(OBJECTS_shmem_beos) $(OBJECTS_support_unix) $(OBJECTS_threadproc_beos) $(OBJECTS_time_unix) $(OBJECTS_user_unix) -dso/os2/dso.lo: dso/os2/dso.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_tables.h include/apr_errno.h include/apr_proc_mutex.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_want.h include/apr_shm.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h +dso/os2/dso.lo: dso/os2/dso.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_tables.h include/fspr_errno.h include/fspr_proc_mutex.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_want.h include/fspr_shm.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h OBJECTS_dso_os2 = dso/os2/dso.lo -file_io/os2/dir_make_recurse.lo: file_io/os2/dir_make_recurse.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_errno.h include/apr_inherit.h include/apr_file_info.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_want.h include/apr_thread_mutex.h include/apr_lib.h include/apr_time.h include/apr_pools.h include/apr_tables.h -file_io/os2/filesys.lo: file_io/os2/filesys.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_errno.h include/apr_want.h include/apr_strings.h include/apr_thread_mutex.h include/apr_lib.h include/apr_pools.h +file_io/os2/dir_make_recurse.lo: file_io/os2/dir_make_recurse.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_errno.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_want.h include/fspr_thread_mutex.h include/fspr_lib.h include/fspr_time.h include/fspr_pools.h include/fspr_tables.h +file_io/os2/filesys.lo: file_io/os2/filesys.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_errno.h include/fspr_want.h include/fspr_strings.h include/fspr_thread_mutex.h include/fspr_lib.h include/fspr_pools.h file_io/os2/flock.lo: file_io/os2/flock.c .make.dirs -file_io/os2/readwrite.lo: file_io/os2/readwrite.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_errno.h include/apr_inherit.h include/apr_file_info.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_want.h include/apr_thread_mutex.h include/apr_lib.h include/apr_time.h include/apr_pools.h include/apr_tables.h +file_io/os2/readwrite.lo: file_io/os2/readwrite.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_errno.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_want.h include/fspr_thread_mutex.h include/fspr_lib.h include/fspr_time.h include/fspr_pools.h include/fspr_tables.h file_io/os2/filepath_util.lo: file_io/os2/filepath_util.c .make.dirs -file_io/os2/seek.lo: file_io/os2/seek.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_errno.h include/apr_inherit.h include/apr_file_info.h include/apr_user.h include/apr_file_io.h include/apr_want.h include/apr_thread_mutex.h include/apr_lib.h include/apr_time.h include/apr_pools.h include/apr_tables.h -file_io/os2/dir.lo: file_io/os2/dir.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_tables.h include/apr_errno.h include/apr_proc_mutex.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_want.h include/apr_lib.h include/apr_shm.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h +file_io/os2/seek.lo: file_io/os2/seek.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_errno.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_user.h include/fspr_file_io.h include/fspr_want.h include/fspr_thread_mutex.h include/fspr_lib.h include/fspr_time.h include/fspr_pools.h include/fspr_tables.h +file_io/os2/dir.lo: file_io/os2/dir.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_tables.h include/fspr_errno.h include/fspr_proc_mutex.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_want.h include/fspr_lib.h include/fspr_shm.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h file_io/os2/mktemp.lo: file_io/os2/mktemp.c .make.dirs -file_io/os2/filedup.lo: file_io/os2/filedup.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_errno.h include/apr_inherit.h include/apr_file_info.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_want.h include/apr_thread_mutex.h include/apr_lib.h include/apr_time.h include/apr_pools.h include/apr_tables.h +file_io/os2/filedup.lo: file_io/os2/filedup.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_errno.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_want.h include/fspr_thread_mutex.h include/fspr_lib.h include/fspr_time.h include/fspr_pools.h include/fspr_tables.h file_io/os2/tempdir.lo: file_io/os2/tempdir.c .make.dirs -file_io/os2/maperrorcode.lo: file_io/os2/maperrorcode.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_errno.h include/apr_inherit.h include/apr_file_info.h include/apr_user.h include/apr_file_io.h include/apr_want.h include/apr_thread_mutex.h include/apr_time.h include/apr_pools.h include/apr_tables.h +file_io/os2/maperrorcode.lo: file_io/os2/maperrorcode.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_errno.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_user.h include/fspr_file_io.h include/fspr_want.h include/fspr_thread_mutex.h include/fspr_time.h include/fspr_pools.h include/fspr_tables.h file_io/os2/filepath.lo: file_io/os2/filepath.c .make.dirs -file_io/os2/pipe.lo: file_io/os2/pipe.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_tables.h include/apr_errno.h include/apr_want.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_proc_mutex.h include/apr_lib.h include/apr_shm.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h -file_io/os2/open.lo: file_io/os2/open.c .make.dirs include/apr_allocator.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_tables.h include/apr_errno.h include/apr_want.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_shm.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_dso.h include/apr_proc_mutex.h include/apr_lib.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h -file_io/os2/filestat.lo: file_io/os2/filestat.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_errno.h include/apr_inherit.h include/apr_file_info.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_want.h include/apr_thread_mutex.h include/apr_lib.h include/apr_time.h include/apr_pools.h include/apr_tables.h +file_io/os2/pipe.lo: file_io/os2/pipe.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_tables.h include/fspr_errno.h include/fspr_want.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_proc_mutex.h include/fspr_lib.h include/fspr_shm.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h +file_io/os2/open.lo: file_io/os2/open.c .make.dirs include/fspr_allocator.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_tables.h include/fspr_errno.h include/fspr_want.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_shm.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_dso.h include/fspr_proc_mutex.h include/fspr_lib.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h +file_io/os2/filestat.lo: file_io/os2/filestat.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_errno.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_want.h include/fspr_thread_mutex.h include/fspr_lib.h include/fspr_time.h include/fspr_pools.h include/fspr_tables.h file_io/os2/copy.lo: file_io/os2/copy.c .make.dirs file_io/os2/fileacc.lo: file_io/os2/fileacc.c .make.dirs file_io/os2/fullrw.lo: file_io/os2/fullrw.c .make.dirs OBJECTS_file_io_os2 = file_io/os2/dir_make_recurse.lo file_io/os2/filesys.lo file_io/os2/flock.lo file_io/os2/readwrite.lo file_io/os2/filepath_util.lo file_io/os2/seek.lo file_io/os2/dir.lo file_io/os2/mktemp.lo file_io/os2/filedup.lo file_io/os2/tempdir.lo file_io/os2/maperrorcode.lo file_io/os2/filepath.lo file_io/os2/pipe.lo file_io/os2/open.lo file_io/os2/filestat.lo file_io/os2/copy.lo file_io/os2/fileacc.lo file_io/os2/fullrw.lo -locks/os2/thread_rwlock.lo: locks/os2/thread_rwlock.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_tables.h include/apr_errno.h include/apr_want.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_proc_mutex.h include/apr_lib.h include/apr_shm.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h -locks/os2/thread_mutex.lo: locks/os2/thread_mutex.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_tables.h include/apr_errno.h include/apr_want.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_proc_mutex.h include/apr_lib.h include/apr_shm.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h -locks/os2/thread_cond.lo: locks/os2/thread_cond.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_tables.h include/apr_errno.h include/apr_want.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_proc_mutex.h include/apr_lib.h include/apr_shm.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h -locks/os2/proc_mutex.lo: locks/os2/proc_mutex.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_tables.h include/apr_errno.h include/apr_want.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_proc_mutex.h include/apr_lib.h include/apr_shm.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h +locks/os2/thread_rwlock.lo: locks/os2/thread_rwlock.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_tables.h include/fspr_errno.h include/fspr_want.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_proc_mutex.h include/fspr_lib.h include/fspr_shm.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h +locks/os2/thread_mutex.lo: locks/os2/thread_mutex.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_tables.h include/fspr_errno.h include/fspr_want.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_proc_mutex.h include/fspr_lib.h include/fspr_shm.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h +locks/os2/thread_cond.lo: locks/os2/thread_cond.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_tables.h include/fspr_errno.h include/fspr_want.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_proc_mutex.h include/fspr_lib.h include/fspr_shm.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h +locks/os2/proc_mutex.lo: locks/os2/proc_mutex.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_tables.h include/fspr_errno.h include/fspr_want.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_proc_mutex.h include/fspr_lib.h include/fspr_shm.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h OBJECTS_locks_os2 = locks/os2/thread_rwlock.lo locks/os2/thread_mutex.lo locks/os2/thread_cond.lo locks/os2/proc_mutex.lo network_io/os2/sockaddr.lo: network_io/os2/sockaddr.c .make.dirs -network_io/os2/sockopt.lo: network_io/os2/sockopt.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_errno.h include/apr_want.h include/apr_file_info.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_inherit.h include/apr_thread_mutex.h include/apr_lib.h include/apr_time.h include/apr_pools.h include/apr_tables.h -network_io/os2/sendrecv_udp.lo: network_io/os2/sendrecv_udp.c .make.dirs include/apr_support.h include/apr_general.h include/apr_network_io.h include/apr_inherit.h include/apr_file_info.h include/apr_allocator.h include/apr_thread_mutex.h include/apr_tables.h include/apr_errno.h include/apr_want.h include/apr_user.h include/apr_file_io.h include/apr_lib.h include/apr_time.h include/apr_pools.h -network_io/os2/sendrecv.lo: network_io/os2/sendrecv.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_errno.h include/apr_want.h include/apr_file_info.h include/apr_user.h include/apr_file_io.h include/apr_inherit.h include/apr_thread_mutex.h include/apr_lib.h include/apr_time.h include/apr_pools.h include/apr_tables.h -network_io/os2/os2calls.lo: network_io/os2/os2calls.c .make.dirs include/apr_allocator.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_tables.h include/apr_errno.h include/apr_want.h include/apr_user.h include/apr_file_io.h include/apr_shm.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_dso.h include/apr_proc_mutex.h include/apr_lib.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h -network_io/os2/sockets.lo: network_io/os2/sockets.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_tables.h include/apr_errno.h include/apr_want.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_proc_mutex.h include/apr_lib.h include/apr_shm.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h +network_io/os2/sockopt.lo: network_io/os2/sockopt.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_errno.h include/fspr_want.h include/fspr_file_info.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_inherit.h include/fspr_thread_mutex.h include/fspr_lib.h include/fspr_time.h include/fspr_pools.h include/fspr_tables.h +network_io/os2/sendrecv_udp.lo: network_io/os2/sendrecv_udp.c .make.dirs include/fspr_support.h include/fspr_general.h include/fspr_network_io.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_allocator.h include/fspr_thread_mutex.h include/fspr_tables.h include/fspr_errno.h include/fspr_want.h include/fspr_user.h include/fspr_file_io.h include/fspr_lib.h include/fspr_time.h include/fspr_pools.h +network_io/os2/sendrecv.lo: network_io/os2/sendrecv.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_errno.h include/fspr_want.h include/fspr_file_info.h include/fspr_user.h include/fspr_file_io.h include/fspr_inherit.h include/fspr_thread_mutex.h include/fspr_lib.h include/fspr_time.h include/fspr_pools.h include/fspr_tables.h +network_io/os2/os2calls.lo: network_io/os2/os2calls.c .make.dirs include/fspr_allocator.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_tables.h include/fspr_errno.h include/fspr_want.h include/fspr_user.h include/fspr_file_io.h include/fspr_shm.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_dso.h include/fspr_proc_mutex.h include/fspr_lib.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h +network_io/os2/sockets.lo: network_io/os2/sockets.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_tables.h include/fspr_errno.h include/fspr_want.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_proc_mutex.h include/fspr_lib.h include/fspr_shm.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h network_io/os2/inet_ntop.lo: network_io/os2/inet_ntop.c .make.dirs network_io/os2/inet_pton.lo: network_io/os2/inet_pton.c .make.dirs OBJECTS_network_io_os2 = network_io/os2/sockaddr.lo network_io/os2/sockopt.lo network_io/os2/sendrecv_udp.lo network_io/os2/sendrecv.lo network_io/os2/os2calls.lo network_io/os2/sockets.lo network_io/os2/inet_ntop.lo network_io/os2/inet_pton.lo -poll/os2/pollset.lo: poll/os2/pollset.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_errno.h include/apr_inherit.h include/apr_file_info.h include/apr_user.h include/apr_file_io.h include/apr_want.h include/apr_thread_mutex.h include/apr_poll.h include/apr_time.h include/apr_pools.h include/apr_tables.h -poll/os2/poll.lo: poll/os2/poll.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_errno.h include/apr_inherit.h include/apr_file_info.h include/apr_user.h include/apr_file_io.h include/apr_want.h include/apr_thread_mutex.h include/apr_poll.h include/apr_time.h include/apr_pools.h include/apr_tables.h +poll/os2/pollset.lo: poll/os2/pollset.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_errno.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_user.h include/fspr_file_io.h include/fspr_want.h include/fspr_thread_mutex.h include/fspr_poll.h include/fspr_time.h include/fspr_pools.h include/fspr_tables.h +poll/os2/poll.lo: poll/os2/poll.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_errno.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_user.h include/fspr_file_io.h include/fspr_want.h include/fspr_thread_mutex.h include/fspr_poll.h include/fspr_time.h include/fspr_pools.h include/fspr_tables.h OBJECTS_poll_os2 = poll/os2/pollset.lo poll/os2/poll.lo -shmem/os2/shm.lo: shmem/os2/shm.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_tables.h include/apr_errno.h include/apr_want.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_proc_mutex.h include/apr_lib.h include/apr_shm.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h +shmem/os2/shm.lo: shmem/os2/shm.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_tables.h include/fspr_errno.h include/fspr_want.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_proc_mutex.h include/fspr_lib.h include/fspr_shm.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h OBJECTS_shmem_os2 = shmem/os2/shm.lo -threadproc/os2/thread.lo: threadproc/os2/thread.c .make.dirs include/apr_allocator.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_tables.h include/apr_errno.h include/apr_want.h include/apr_user.h include/apr_file_io.h include/apr_shm.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_dso.h include/apr_proc_mutex.h include/apr_lib.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h +threadproc/os2/thread.lo: threadproc/os2/thread.c .make.dirs include/fspr_allocator.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_tables.h include/fspr_errno.h include/fspr_want.h include/fspr_user.h include/fspr_file_io.h include/fspr_shm.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_dso.h include/fspr_proc_mutex.h include/fspr_lib.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h threadproc/os2/signals.lo: threadproc/os2/signals.c .make.dirs -threadproc/os2/proc.lo: threadproc/os2/proc.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_signal.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_proc_mutex.h include/apr_tables.h include/apr_errno.h include/apr_want.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_inherit.h include/apr_lib.h include/apr_shm.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h -threadproc/os2/threadpriv.lo: threadproc/os2/threadpriv.c .make.dirs include/apr_allocator.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_tables.h include/apr_errno.h include/apr_want.h include/apr_user.h include/apr_file_io.h include/apr_shm.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_dso.h include/apr_proc_mutex.h include/apr_lib.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h +threadproc/os2/proc.lo: threadproc/os2/proc.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_signal.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_proc_mutex.h include/fspr_tables.h include/fspr_errno.h include/fspr_want.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_inherit.h include/fspr_lib.h include/fspr_shm.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h +threadproc/os2/threadpriv.lo: threadproc/os2/threadpriv.c .make.dirs include/fspr_allocator.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_tables.h include/fspr_errno.h include/fspr_want.h include/fspr_user.h include/fspr_file_io.h include/fspr_shm.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_dso.h include/fspr_proc_mutex.h include/fspr_lib.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h OBJECTS_threadproc_os2 = threadproc/os2/thread.lo threadproc/os2/signals.lo threadproc/os2/proc.lo threadproc/os2/threadpriv.lo OBJECTS_os2 = $(OBJECTS_all) $(OBJECTS_atomic_unix) $(OBJECTS_dso_os2) $(OBJECTS_file_io_os2) $(OBJECTS_locks_os2) $(OBJECTS_memory_unix) $(OBJECTS_misc_unix) $(OBJECTS_mmap_unix) $(OBJECTS_network_io_os2) $(OBJECTS_poll_os2) $(OBJECTS_random_unix) $(OBJECTS_shmem_os2) $(OBJECTS_support_unix) $(OBJECTS_threadproc_os2) $(OBJECTS_time_unix) $(OBJECTS_user_unix) -atomic/os390/atomic.lo: atomic/os390/atomic.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_thread_mutex.h include/apr_errno.h include/apr_want.h include/apr_atomic.h include/apr_pools.h +atomic/os390/atomic.lo: atomic/os390/atomic.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_thread_mutex.h include/fspr_errno.h include/fspr_want.h include/fspr_atomic.h include/fspr_pools.h OBJECTS_atomic_os390 = atomic/os390/atomic.lo -dso/os390/dso.lo: dso/os390/dso.c .make.dirs include/apr_allocator.h include/apr_general.h include/apr_network_io.h include/apr_portable.h include/apr_inherit.h include/apr_file_info.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_dso.h include/apr_tables.h include/apr_errno.h include/apr_want.h include/apr_user.h include/apr_file_io.h include/apr_strings.h include/apr_proc_mutex.h include/apr_shm.h include/apr_global_mutex.h include/apr_time.h include/apr_pools.h +dso/os390/dso.lo: dso/os390/dso.c .make.dirs include/fspr_allocator.h include/fspr_general.h include/fspr_network_io.h include/fspr_portable.h include/fspr_inherit.h include/fspr_file_info.h include/fspr_thread_mutex.h include/fspr_thread_proc.h include/fspr_dso.h include/fspr_tables.h include/fspr_errno.h include/fspr_want.h include/fspr_user.h include/fspr_file_io.h include/fspr_strings.h include/fspr_proc_mutex.h include/fspr_shm.h include/fspr_global_mutex.h include/fspr_time.h include/fspr_pools.h OBJECTS_dso_os390 = dso/os390/dso.lo OBJECTS_os390 = $(OBJECTS_all) $(OBJECTS_atomic_os390) $(OBJECTS_dso_os390) $(OBJECTS_file_io_unix) $(OBJECTS_locks_unix) $(OBJECTS_memory_unix) $(OBJECTS_misc_unix) $(OBJECTS_mmap_unix) $(OBJECTS_network_io_unix) $(OBJECTS_poll_unix) $(OBJECTS_random_unix) $(OBJECTS_shmem_unix) $(OBJECTS_support_unix) $(OBJECTS_threadproc_unix) $(OBJECTS_time_unix) $(OBJECTS_user_unix) -HEADERS = $(top_srcdir)/include/apr_thread_mutex.h $(top_srcdir)/include/apr_env.h $(top_srcdir)/include/apr_poll.h $(top_srcdir)/include/apr_fnmatch.h $(top_srcdir)/include/apr_global_mutex.h $(top_srcdir)/include/apr_pools.h $(top_srcdir)/include/apr_want.h $(top_srcdir)/include/apr_file_io.h $(top_srcdir)/include/apr_version.h $(top_srcdir)/include/apr_mmap.h $(top_srcdir)/include/apr_dso.h $(top_srcdir)/include/apr_thread_proc.h $(top_srcdir)/include/apr_errno.h $(top_srcdir)/include/apr_shm.h $(top_srcdir)/include/apr_network_io.h $(top_srcdir)/include/apr_signal.h $(top_srcdir)/include/apr_user.h $(top_srcdir)/include/apr_support.h $(top_srcdir)/include/apr_atomic.h $(top_srcdir)/include/apr_random.h $(top_srcdir)/include/apr_thread_cond.h $(top_srcdir)/include/apr_thread_rwlock.h $(top_srcdir)/include/apr_getopt.h $(top_srcdir)/include/apr_inherit.h $(top_srcdir)/include/apr_strings.h $(top_srcdir)/include/apr_general.h $(top_srcdir)/include/apr_proc_mutex.h $(top_srcdir)/include/apr_tables.h $(top_srcdir)/include/apr_ring.h $(top_srcdir)/include/apr_file_info.h $(top_srcdir)/include/apr_allocator.h $(top_srcdir)/include/apr_portable.h $(top_srcdir)/include/apr_hash.h $(top_srcdir)/include/apr_time.h $(top_srcdir)/include/apr_lib.h +HEADERS = $(top_srcdir)/include/fspr_thread_mutex.h $(top_srcdir)/include/fspr_env.h $(top_srcdir)/include/fspr_poll.h $(top_srcdir)/include/fspr_fnmatch.h $(top_srcdir)/include/fspr_global_mutex.h $(top_srcdir)/include/fspr_pools.h $(top_srcdir)/include/fspr_want.h $(top_srcdir)/include/fspr_file_io.h $(top_srcdir)/include/fspr_version.h $(top_srcdir)/include/fspr_mmap.h $(top_srcdir)/include/fspr_dso.h $(top_srcdir)/include/fspr_thread_proc.h $(top_srcdir)/include/fspr_errno.h $(top_srcdir)/include/fspr_shm.h $(top_srcdir)/include/fspr_network_io.h $(top_srcdir)/include/fspr_signal.h $(top_srcdir)/include/fspr_user.h $(top_srcdir)/include/fspr_support.h $(top_srcdir)/include/fspr_atomic.h $(top_srcdir)/include/fspr_random.h $(top_srcdir)/include/fspr_thread_cond.h $(top_srcdir)/include/fspr_thread_rwlock.h $(top_srcdir)/include/fspr_getopt.h $(top_srcdir)/include/fspr_inherit.h $(top_srcdir)/include/fspr_strings.h $(top_srcdir)/include/fspr_general.h $(top_srcdir)/include/fspr_proc_mutex.h $(top_srcdir)/include/fspr_tables.h $(top_srcdir)/include/fspr_ring.h $(top_srcdir)/include/fspr_file_info.h $(top_srcdir)/include/fspr_allocator.h $(top_srcdir)/include/fspr_portable.h $(top_srcdir)/include/fspr_hash.h $(top_srcdir)/include/fspr_time.h $(top_srcdir)/include/fspr_lib.h SOURCE_DIRS = random/unix dso/os2 time/unix locks/unix user/unix locks/beos tables support/unix file_io/unix mmap/unix atomic/unix poll/os2 dso/os390 atomic/os390 dso/beos poll/unix passwd network_io/beos threadproc/os2 network_io/os2 threadproc/beos shmem/unix network_io/unix file_io/os2 dso/aix threadproc/unix misc/unix shmem/beos dso/unix locks/os2 shmem/os2 memory/unix strings $(EXTRA_SOURCE_DIRS) diff --git a/libs/apr/build/NWGNUenvironment.inc b/libs/apr/build/NWGNUenvironment.inc index fd54b487c9..53039ba962 100644 --- a/libs/apr/build/NWGNUenvironment.inc +++ b/libs/apr/build/NWGNUenvironment.inc @@ -164,9 +164,9 @@ ifeq "$(RELEASE)" "optimized" CFLAGS += -O4,p endif -# -prefix apr_arch_pre_nw.h #include pre_nw.h for all files +# -prefix fspr_arch_pre_nw.h #include pre_nw.h for all files -CFLAGS += -prefix apr_arch_pre_nw.h +CFLAGS += -prefix fspr_arch_pre_nw.h PATH:=$(PATH);$(METROWERKS)\bin;$(METROWERKS)\Other Metrowerks Tools\Command Line Tools diff --git a/libs/apr/build/NWGNUmakefile b/libs/apr/build/NWGNUmakefile index 6f9b32dd04..a9aac49fcd 100644 --- a/libs/apr/build/NWGNUmakefile +++ b/libs/apr/build/NWGNUmakefile @@ -16,10 +16,10 @@ include $(APR_WORK)\build\NWGNUhead.inc # build this level's files FILES_prebuild_headers = \ - $(APR)/include/apr.h \ + $(APR)/include/fspr.h \ $(APRUTIL)/include/apu.h \ $(APRUTIL)/include/apu_want.h \ - $(APRUTIL)/include/apr_ldap.h \ + $(APRUTIL)/include/fspr_ldap.h \ $(APRUTIL)/include/private/apu_config.h \ $(APRUTIL)/include/private/apu_select_dbm.h \ $(APRUTIL)/xml/expat/lib/expat.h \ @@ -83,9 +83,9 @@ clean :: $(CHK) nw_export.i $(DEL) nw_export.i $(CHK) $(NLM_NAME)_cc.opt $(DEL) $(NLM_NAME)_cc.opt $(CHK) NWGNUversion.inc $(DEL) NWGNUversion.inc - $(CHK) $(subst /,\,$(APR))\include\apr.h $(DEL) $(subst /,\,$(APR))\include\apr.h + $(CHK) $(subst /,\,$(APR))\include\fspr.h $(DEL) $(subst /,\,$(APR))\include\fspr.h $(CHK) $(subst /,\,$(APRUTIL))\include\apu.h $(DEL) $(subst /,\,$(APRUTIL))\include\apu.h - $(CHK) $(subst /,\,$(APRUTIL))\include\apr_ldap.h $(DEL) $(subst /,\,$(APRUTIL))\include\apr_ldap.h + $(CHK) $(subst /,\,$(APRUTIL))\include\fspr_ldap.h $(DEL) $(subst /,\,$(APRUTIL))\include\fspr_ldap.h $(CHK) $(subst /,\,$(APRUTIL))\include\private\apu_config.h $(DEL) $(subst /,\,$(APRUTIL))\include\private\apu_config.h $(CHK) $(subst /,\,$(APRUTIL))\include\private\apu_select_dbm.h $(DEL) $(subst /,\,$(APRUTIL))\include\private\apu_select_dbm.h $(CHK) $(subst /,\,$(APRUTIL))\xml\expat\lib\expat.h $(DEL) $(subst /,\,$(APRUTIL))\xml\expat\lib\expat.h diff --git a/libs/apr/build/NWGNUtail.inc b/libs/apr/build/NWGNUtail.inc index 641c091b24..2c3ccf36f9 100644 --- a/libs/apr/build/NWGNUtail.inc +++ b/libs/apr/build/NWGNUtail.inc @@ -88,9 +88,9 @@ endif # Generic compiler rules # -$(APR_WORK)\build\NWGNUversion.inc : $(APR_WORK)\include\apr_version.h $(APR_WORK)\build\nw_ver.awk +$(APR_WORK)\build\NWGNUversion.inc : $(APR_WORK)\include\fspr_version.h $(APR_WORK)\build\nw_ver.awk @echo Generating $(subst /,\,$@) - awk -f $(APR_WORK)\build\nw_ver.awk $(APR_WORK)\include\apr_version.h > $(APR_WORK)\build\NWGNUversion.inc + awk -f $(APR_WORK)\build\nw_ver.awk $(APR_WORK)\include\fspr_version.h > $(APR_WORK)\build\NWGNUversion.inc -include $(APR_WORK)\build\NWGNUversion.inc diff --git a/libs/apr/build/apr_app.dsp b/libs/apr/build/apr_app.dsp index ac060a503f..55c84e3c48 100644 --- a/libs/apr/build/apr_app.dsp +++ b/libs/apr/build/apr_app.dsp @@ -83,7 +83,7 @@ LIB32=link.exe -lib # Name "apr_app - Win32 Debug" # Begin Source File -SOURCE=..\misc\win32\apr_app.c +SOURCE=..\misc\win32\fspr_app.c # End Source File # End Target # End Project diff --git a/libs/apr/build/apr_common.m4 b/libs/apr/build/apr_common.m4 index 1f79f7acd0..13d6be60dd 100644 --- a/libs/apr/build/apr_common.m4 +++ b/libs/apr/build/apr_common.m4 @@ -338,7 +338,7 @@ AC_DEFUN([APR_CHECK_APR_DEFINE],[ apr_old_cppflags=$CPPFLAGS CPPFLAGS="$CPPFLAGS $INCLUDES" AC_EGREP_CPP(YES_IS_DEFINED, [ -#include +#include #if $1 YES_IS_DEFINED #endif @@ -403,7 +403,7 @@ ac_decision='' AC_DEFUN([APR_DECIDE],[dnl -dnl Define the flag (or not) in apr_private.h via autoheader +dnl Define the flag (or not) in fspr_private.h via autoheader AH_TEMPLATE($1, [Define if $2 will be used]) ac_decision='$1' ac_decision_msg='$2' @@ -519,6 +519,9 @@ AC_TRY_RUN([ #include #include #include +#ifdef HAVE_STDLIB_H +#include +#endif int main(void) { char buf[1024]; diff --git a/libs/apr/build/apr_network.m4 b/libs/apr/build/apr_network.m4 index d8b1bcad27..df582960ac 100644 --- a/libs/apr/build/apr_network.m4 +++ b/libs/apr/build/apr_network.m4 @@ -40,6 +40,9 @@ AC_DEFUN([APR_CHECK_WORKING_GETADDRINFO],[ #ifdef HAVE_SYS_SOCKET_H #include #endif +#ifdef HAVE_STDLIB_H +#include +#endif int main(void) { struct addrinfo hints, *ai; @@ -134,6 +137,12 @@ AC_DEFUN([APR_CHECK_WORKING_GETNAMEINFO],[ #ifdef HAVE_NETINET_IN_H #include #endif +#ifdef HAVE_ARPA_INET_H +#include +#endif +#ifdef HAVE_STDLIB_H +#include +#endif int main(void) { struct sockaddr_in sa; @@ -177,6 +186,9 @@ AC_DEFUN([APR_CHECK_NEGATIVE_EAI],[ #ifdef HAVE_NETDB_H #include #endif +#ifdef HAVE_STDLIB_H +#include +#endif int main(void) { if (EAI_ADDRFAMILY < 0) { @@ -282,6 +294,9 @@ AC_DEFUN([APR_CHECK_TCP_NODELAY_INHERITED],[ #ifndef HAVE_SOCKLEN_T typedef int socklen_t; #endif +#ifdef HAVE_STDLIB_H +#include +#endif int main(void) { int listen_s, connected_s, client_s; int listen_port, rc; @@ -453,6 +468,9 @@ typedef int socklen_t; #ifdef HAVE_FCNTL_H #include #endif +#ifdef HAVE_STDLIB_H +#include +#endif int main(void) { int listen_s, connected_s, client_s; int listen_port, rc; diff --git a/libs/apr/build/find_apr.m4 b/libs/apr/build/find_apr.m4 index 048cb7bfc8..1060965d8d 100644 --- a/libs/apr/build/find_apr.m4 +++ b/libs/apr/build/find_apr.m4 @@ -143,7 +143,7 @@ AC_DEFUN([APR_FIND_APR], [ if test "$apr_found" = "no" && test -d "$1"; then apr_temp_abs_srcdir="`cd $1 && pwd`" apr_found="reconfig" - apr_bundled_major="`sed -n '/#define.*APR_MAJOR_VERSION/s/^[^0-9]*\([0-9]*\).*$/\1/p' \"$1/include/apr_version.h\"`" + apr_bundled_major="`sed -n '/#define.*APR_MAJOR_VERSION/s/^[^0-9]*\([0-9]*\).*$/\1/p' \"$1/include/fspr_version.h\"`" case $apr_bundled_major in "") AC_MSG_ERROR([failed to find major version of bundled APR]) diff --git a/libs/apr/build/libapr_app.dsp b/libs/apr/build/libapr_app.dsp index 0cd962e5cd..875dade39f 100644 --- a/libs/apr/build/libapr_app.dsp +++ b/libs/apr/build/libapr_app.dsp @@ -83,7 +83,7 @@ LIB32=link.exe -lib # Name "libapr_app - Win32 Debug" # Begin Source File -SOURCE=..\misc\win32\apr_app.c +SOURCE=..\misc\win32\fspr_app.c # End Source File # Begin Source File diff --git a/libs/apr/build/make_exports.awk b/libs/apr/build/make_exports.awk index 1d12fc65ab..bd417e2a44 100644 --- a/libs/apr/build/make_exports.awk +++ b/libs/apr/build/make_exports.awk @@ -100,21 +100,21 @@ function add_symbol(symbol) { /^[ \t]*APR_POOL_DECLARE_ACCESSOR[^(]*[(][^)]*[)]/ { sub("[ \t]*APR_POOL_DECLARE_ACCESSOR[^(]*[(]", "", $0) sub("[)].*$", "", $0) - add_symbol("apr_" $0 "_pool_get") + add_symbol("fspr_" $0 "_pool_get") next } /^[ \t]*APR_DECLARE_INHERIT_SET[^(]*[(][^)]*[)]/ { sub("[ \t]*APR_DECLARE_INHERIT_SET[^(]*[(]", "", $0) sub("[)].*$", "", $0) - add_symbol("apr_" $0 "_inherit_set") + add_symbol("fspr_" $0 "_inherit_set") next } /^[ \t]*APR_DECLARE_INHERIT_UNSET[^(]*[(][^)]*[)]/ { sub("[ \t]*APR_DECLARE_INHERIT_UNSET[^(]*[(]", "", $0) sub("[)].*$", "", $0) - add_symbol("apr_" $0 "_inherit_unset") + add_symbol("fspr_" $0 "_inherit_unset") next } diff --git a/libs/apr/build/make_nw_export.awk b/libs/apr/build/make_nw_export.awk index 291ecc0b2c..21cc683157 100644 --- a/libs/apr/build/make_nw_export.awk +++ b/libs/apr/build/make_nw_export.awk @@ -6,8 +6,8 @@ BEGIN { } # List of functions that we don't support, yet?? -#/apr_##name##_set_inherit/{next} -#/apr_##name##_unset_inherit/{next} +#/fspr_##name##_set_inherit/{next} +#/fspr_##name##_unset_inherit/{next} function add_symbol (sym_name) { @@ -47,21 +47,21 @@ function add_symbol (sym_name) { /^[ \t]*APR_POOL_DECLARE_ACCESSOR[^(]*[(][^)]*[)]/ { sub("[ \t]*APR_POOL_DECLARE_ACCESSOR[^(]*[(]", "", $0) sub("[)].*$", "", $0) - add_symbol("apr_" $0 "_pool_get") + add_symbol("fspr_" $0 "_pool_get") next } /^[ \t]*APR_DECLARE_INHERIT_SET[^(]*[(][^)]*[)]/ { sub("[ \t]*APR_DECLARE_INHERIT_SET[^(]*[(]", "", $0) sub("[)].*$", "", $0) - add_symbol("apr_" $0 "_inherit_set") + add_symbol("fspr_" $0 "_inherit_set") next } /^[ \t]*APR_DECLARE_INHERIT_UNSET[^(]*[(][^)]*[)]/ { sub("[ \t]*APR_DECLARE_INHERIT_UNSET[^(]*[(]", "", $0) sub("[)].*$", "", $0) - add_symbol("apr_" $0 "_inherit_unset") + add_symbol("fspr_" $0 "_inherit_unset") next } diff --git a/libs/apr/build/nw_export.inc b/libs/apr/build/nw_export.inc index 58495cd075..d9f3208d6a 100644 --- a/libs/apr/build/nw_export.inc +++ b/libs/apr/build/nw_export.inc @@ -1,7 +1,7 @@ /* Must include apr.h first so that we can undefine the standard prototypes macros after it messes with them. */ -#include "apr.h" +#include "fspr.h" #undef APR_DECLARE #undef APR_DECLARE_NONSTD @@ -10,41 +10,41 @@ #undef APR_DECLARE_DATA /* Preprocess all of the standard APR headers. */ -#include "apr_allocator.h" -#include "apr_atomic.h" -#include "apr_dso.h" -#include "apr_env.h" -#include "apr_errno.h" -#include "apr_file_info.h" -#include "apr_file_io.h" -#include "apr_fnmatch.h" -#include "apr_general.h" -#include "apr_getopt.h" -#include "apr_global_mutex.h" -#include "apr_hash.h" -#include "apr_inherit.h" -#include "apr_lib.h" -#include "apr_mmap.h" -#include "apr_network_io.h" -#include "apr_poll.h" -#include "apr_pools.h" -#include "apr_portable.h" -#include "apr_proc_mutex.h" -#include "apr_ring.h" -#include "apr_random.h" -#include "apr_shm.h" -#include "apr_signal.h" -#include "apr_strings.h" -#include "apr_support.h" -#include "apr_tables.h" -#include "apr_thread_cond.h" -#include "apr_thread_mutex.h" -#include "apr_thread_proc.h" -#include "apr_thread_rwlock.h" -#include "apr_time.h" -#include "apr_user.h" -#include "apr_version.h" -#include "apr_want.h" +#include "fspr_allocator.h" +#include "fspr_atomic.h" +#include "fspr_dso.h" +#include "fspr_env.h" +#include "fspr_errno.h" +#include "fspr_file_info.h" +#include "fspr_file_io.h" +#include "fspr_fnmatch.h" +#include "fspr_general.h" +#include "fspr_getopt.h" +#include "fspr_global_mutex.h" +#include "fspr_hash.h" +#include "fspr_inherit.h" +#include "fspr_lib.h" +#include "fspr_mmap.h" +#include "fspr_network_io.h" +#include "fspr_poll.h" +#include "fspr_pools.h" +#include "fspr_portable.h" +#include "fspr_proc_mutex.h" +#include "fspr_ring.h" +#include "fspr_random.h" +#include "fspr_shm.h" +#include "fspr_signal.h" +#include "fspr_strings.h" +#include "fspr_support.h" +#include "fspr_tables.h" +#include "fspr_thread_cond.h" +#include "fspr_thread_mutex.h" +#include "fspr_thread_proc.h" +#include "fspr_thread_rwlock.h" +#include "fspr_time.h" +#include "fspr_user.h" +#include "fspr_version.h" +#include "fspr_want.h" /* Must include apu.h first so that we can undefine @@ -57,29 +57,29 @@ #undef APU_DECLARE_DATA /* Preprocess all of the standard APR headers. */ -#include "apr_anylock.h" -#include "apr_base64.h" -#include "apr_buckets.h" -#include "apr_date.h" -#include "apr_dbd.h" -#include "apr_dbm.h" -#include "apr_hooks.h" -#include "apr_ldap.h" -#include "apr_ldap_url.h" -#include "apr_md4.h" -#include "apr_md5.h" -#include "apr_optional.h" -#include "apr_optional_hooks.h" -#include "apr_queue.h" -#include "apr_reslist.h" -#include "apr_rmm.h" -#include "apr_sdbm.h" -#include "apr_sha1.h" -#include "apr_strmatch.h" -#include "apr_uri.h" -#include "apr_uuid.h" -#include "apr_xlate.h" -#include "apr_xml.h" +#include "fspr_anylock.h" +#include "fspr_base64.h" +#include "fspr_buckets.h" +#include "fspr_date.h" +#include "fspr_dbd.h" +#include "fspr_dbm.h" +#include "fspr_hooks.h" +#include "fspr_ldap.h" +#include "fspr_ldap_url.h" +#include "fspr_md4.h" +#include "fspr_md5.h" +#include "fspr_optional.h" +#include "fspr_optional_hooks.h" +#include "fspr_queue.h" +#include "fspr_reslist.h" +#include "fspr_rmm.h" +#include "fspr_sdbm.h" +#include "fspr_sha1.h" +#include "fspr_strmatch.h" +#include "fspr_uri.h" +#include "fspr_uuid.h" +#include "fspr_xlate.h" +#include "fspr_xml.h" #include "apu_version.h" #include "apu_want.h" diff --git a/libs/apr/build/prebuildNW.bat b/libs/apr/build/prebuildNW.bat index 941d920c9b..7b3f3a7b08 100755 --- a/libs/apr/build/prebuildNW.bat +++ b/libs/apr/build/prebuildNW.bat @@ -24,7 +24,7 @@ goto Done @echo # "apr-util\uri\uri_delims.h" on the build machine. @echo Fixing up the APR headers -copy ..\include\apr.hnw ..\include\apr.h +copy ..\include\fspr.hnw ..\include\fspr.h @echo Fixing up the APR-Util headers copy ..\..\apr-util\include\apu.hnw ..\..\apr-util\include\apu.h diff --git a/libs/apr/configure.ac b/libs/apr/configure.ac index fa5796ecca..b267825e09 100644 --- a/libs/apr/configure.ac +++ b/libs/apr/configure.ac @@ -7,7 +7,7 @@ dnl Use ./buildconf to prepare build files and run autoconf for APR. AC_PREREQ(2.50) AC_INIT(build/apr_common.m4) -AC_CONFIG_HEADER(include/arch/unix/apr_private.h) +AC_CONFIG_HEADER(include/arch/unix/fspr_private.h) AC_CONFIG_AUX_DIR(build) dnl @@ -24,7 +24,7 @@ CFLAGS="$CFLAGS $CONFIGURE_CFLAGS" CXXFLAGS="$CXXFLAGS $CONFIGURE_CXXFLAGS" LDFLAGS="$LDFLAGS $CONFIGURE_LDFLAGS" -dnl Hard-coded inclusion at the tail end of apr_private.h: +dnl Hard-coded inclusion at the tail end of fspr_private.h: AH_BOTTOM([ /* switch this on if we have a BeOS version below BONE */ #if BEOS && !HAVE_BONE_VERSION @@ -36,7 +36,7 @@ AH_BOTTOM([ /* * Include common private declarations. */ -#include "../apr_private_common.h" +#include "../fspr_private_common.h" ]) dnl Save user-defined environment settings for later restoration @@ -95,7 +95,7 @@ APR_MKDIR_P_CHECK($apr_builders/mkdir.sh) # get our version information get_version="$apr_builders/get-version.sh" -version_hdr="$apr_srcdir/include/apr_version.h" +version_hdr="$apr_srcdir/include/fspr_version.h" APR_MAJOR_VERSION="`$get_version major $version_hdr APR`" APR_DOTTED_VERSION="`$get_version all $version_hdr APR`" @@ -1169,7 +1169,7 @@ fi if test "$ac_cv_sizeof_int" = "4"; then int_value=int fi -# Now we need to find what apr_int64_t (sizeof == 8) will be. +# Now we need to find what fspr_int64_t (sizeof == 8) will be. # The first match is our preference. if test "$ac_cv_sizeof_int" = "8"; then int64_literal='#define APR_INT64_C(val) (val)' @@ -1243,12 +1243,12 @@ fi if test "$ac_cv_type_size_t" = "yes"; then size_t_value="size_t" else - size_t_value="apr_int32_t" + size_t_value="fspr_int32_t" fi if test "$ac_cv_type_ssize_t" = "yes"; then ssize_t_value="ssize_t" else - ssize_t_value="apr_int32_t" + ssize_t_value="fspr_int32_t" fi if test "$ac_cv_socklen_t" = "yes"; then socklen_t_value="socklen_t" @@ -1298,17 +1298,17 @@ else aprlfs=0 fi -AC_MSG_CHECKING([which type to use for apr_off_t]) +AC_MSG_CHECKING([which type to use for fspr_off_t]) if test "${ac_cv_sizeof_off_t}${apr_cv_use_lfs64}" = "4yes"; then # LFS is go! off_t_fmt='#define APR_OFF_T_FMT APR_INT64_T_FMT' off_t_value='off64_t' - off_t_strfn='apr_strtoi64' + off_t_strfn='fspr_strtoi64' elif test "${ac_cv_sizeof_off_t}x${ac_cv_sizeof_long}" = "4x4"; then # Special case: off_t may change size with _FILE_OFFSET_BITS # on 32-bit systems with LFS support. To avoid compatibility # issues when other packages do define _FILE_OFFSET_BITS, - # hard-code apr_off_t to long. + # hard-code fspr_off_t to long. off_t_value=long off_t_fmt='#define APR_OFF_T_FMT "ld"' off_t_strfn='strtol' @@ -1324,13 +1324,13 @@ elif test "$ac_cv_type_off_t" = "yes"; then off_t_strfn='strtoi' elif test "$ac_cv_sizeof_off_t" = "$ac_cv_sizeof_long_long"; then off_t_fmt='#define APR_OFF_T_FMT APR_INT64_T_FMT' - off_t_strfn='apr_strtoi64' + off_t_strfn='fspr_strtoi64' else AC_ERROR([could not determine the size of off_t]) fi else # Fallback on int - off_t_value=apr_int32_t + off_t_value=fspr_int32_t off_t_fmt=d off_t_strfn='strtoi' fi @@ -1440,7 +1440,7 @@ fi if test "$have_int64_strfn" = "1"; then AC_DEFINE_UNQUOTED(APR_INT64_STRFN, [$int64_strfn], - [Define as function which can be used for conversion of strings to apr_int64_t]) + [Define as function which can be used for conversion of strings to fspr_int64_t]) fi AC_SUBST(have_strnicmp) @@ -1451,11 +1451,11 @@ AC_SUBST(have_strdup) AC_SUBST(have_strstr) AC_SUBST(have_memchr) -if test "$off_t_strfn" = "apr_strtoi64" && test "$have_int64_strfn" = "1"; then +if test "$off_t_strfn" = "fspr_strtoi64" && test "$have_int64_strfn" = "1"; then off_t_strfn=$int64_strfn fi AC_DEFINE_UNQUOTED(APR_OFF_T_STRFN, [$off_t_strfn], - [Define as function used for conversion of strings to apr_off_t]) + [Define as function used for conversion of strings to fspr_off_t]) dnl ----------------------------- Checking for DSO support echo "${nl}Checking for DSO..." @@ -1552,6 +1552,7 @@ AC_TRY_RUN([ #include #include #include +#include main() { struct rlimit limit; @@ -1580,6 +1581,7 @@ AC_TRY_RUN([ #include #include #include +#include main() { sem_t *psem; @@ -1634,6 +1636,7 @@ if test "$threads" = "1"; then AC_TRY_RUN([ #include #include +#include int main() { pthread_mutex_t mutex; @@ -1946,7 +1949,7 @@ AC_SUBST(file_as_socket) if test "$ac_cv_func_poll $file_as_socket" = "yes 1"; then AC_DEFINE(WAITIO_USES_POLL, 1, - [Define if apr_wait_for_io_or_timeout() uses poll(2)]) + [Define if fspr_wait_for_io_or_timeout() uses poll(2)]) fi # Check the types only if we have gethostbyname_r @@ -2132,7 +2135,7 @@ AC_SUBST(INCLUDE_RULES) AC_SUBST(INCLUDE_OUTPUTS) AC_CONFIG_FILES([Makefile - include/apr.h + include/fspr.h build/apr_rules.mk build/pkg/pkginfo apr-$APR_MAJOR_VERSION-config:apr-config.in @@ -2160,7 +2163,7 @@ dnl This section is expanded by configure UNQUOTED so variable dnl references must be backslash-escaped as necessary. # Commands run at the beginning of config.status: -APR_SAVE_HEADERS="include/apr.h include/arch/unix/apr_private.h" +APR_SAVE_HEADERS="include/fspr.h include/arch/unix/fspr_private.h" APR_MAJOR_VERSION=$APR_MAJOR_VERSION for apri in \${APR_SAVE_HEADERS}; do diff --git a/libs/apr/docs/APRDesign.html b/libs/apr/docs/APRDesign.html index 7d1caeb8d4..d4f6de2d3b 100644 --- a/libs/apr/docs/APRDesign.html +++ b/libs/apr/docs/APRDesign.html @@ -22,10 +22,10 @@ code to the effort.

APR On Windows and Netware

APR on Windows and Netware is different from APR on all other systems, -because those platforms don't use autoconf. On Unix, apr_private.h (private to +because those platforms don't use autoconf. On Unix, fspr_private.h (private to APR) and apr.h (public, used by applications that use APR) are generated by autoconf from acconfig.h and apr.h.in respectively. On Windows (and Netware), -apr_private.h and apr.h are created from apr_private.hw (apr_private.hwn) +fspr_private.h and apr.h are created from fspr_private.hw (fspr_private.hwn) and apr.hw (apr.hwn) respectively.

@@ -34,7 +34,7 @@ and apr.hw (apr.hwn) respectively.

these additions as well. A general rule of thumb, is that if it is a feature macro, such as APR_HAS_THREADS, Windows and Netware need it. In other words, if the definition is going to be used in a public APR - header file, such as apr_general.h, Windows needs it. + header file, such as fspr_general.h, Windows needs it. The only time it is safe to add a macro or test without also adding the macro to apr*.h[n]w, is if the macro tells APR how to build. For @@ -161,7 +161,7 @@ implemented one way. For example, time is a complete type because there is only one reasonable time implementation.
  • The second exception to the incomplete type rule can be found in -apr_portable.h. This file defines the native types for each platform. +fspr_portable.h. This file defines the native types for each platform. Using these types, it is possible to extract native types for any APR type.

    @@ -171,14 +171,14 @@ in file_io/unix/fileio.h:

         struct ap_file_t {
    -        apr_pool_t *cntxt;
    +        fspr_pool_t *cntxt;
             int filedes;
             FILE *filehand;
             ...
         }
     
    -

    In include/apr_file_io.h:

    +

    In include/fspr_file_io.h:

    typedef struct ap_file_t ap_file_t; @@ -187,7 +187,7 @@ in file_io/unix/fileio.h:

    field in this structure. Windows does not have a filedes field, so obviously, it is important that programs not be able to access these.

    -

    You may notice the apr_pool_t field. Most APR types have this field. This +

    You may notice the fspr_pool_t field. Most APR types have this field. This type is used to allocate memory within APR. Because every APR type has a pool, any APR function can allocate memory if it needs to. This is very important and it is one of the reasons that APR works. If you create a new type, you @@ -281,15 +281,15 @@ the error code indicates an error condition or a status codition.

    If your function has multiple return codes that all indicate success, but with different results, or if your function can only return PASS/FAIL, you -should still return an apr_status_t. In the first case, define one +should still return an fspr_status_t. In the first case, define one APR status code for each return value, an example of this is -apr_proc_wait, which can only return APR_CHILDDONE, +fspr_proc_wait, which can only return APR_CHILDDONE, APR_CHILDNOTDONE, or an error code. In the second case, please return APR_SUCCESS for PASS, and define a new APR status code for failure, an -example of this is apr_compare_users, which can only return +example of this is fspr_compare_users, which can only return APR_SUCCESS, APR_EMISMATCH, or an error code.

    -

    All of these definitions can be found in apr_errno.h for all platforms. When +

    All of these definitions can be found in fspr_errno.h for all platforms. When an error occurs in an APR function, the function must return an error code. If the error occurred in a system call and that system call uses errno to report an error, then the code is returned unchanged. For example:

    @@ -320,7 +320,7 @@ case. We'll get to how this problem is solved in a little while.

    If the error occurs in an APR function but it is not due to a system call, but it is actually an APR error or just a status code from APR, then the -appropriate code should be returned. These codes are defined in apr_errno.h +appropriate code should be returned. These codes are defined in fspr_errno.h and should be self explanatory.

    No APR code should ever return a code between APR_OS_START_USEERR and diff --git a/libs/apr/docs/canonical_filenames.html b/libs/apr/docs/canonical_filenames.html index 10867d3796..f1abad5bd8 100644 --- a/libs/apr/docs/canonical_filenames.html +++ b/libs/apr/docs/canonical_filenames.html @@ -88,7 +88,7 @@ system objects.

    Canonical API

    -Functions to manipulate the apr_canon_file_t (an opaque type) include: +Functions to manipulate the fspr_canon_file_t (an opaque type) include:
    • Create canon_file_t (from char* path and canon_file_t parent path) @@ -99,7 +99,7 @@ Functions to manipulate the apr_canon_file_t (an opaque type) include:

    The path is corrected to the file system case only if is in absolute -form. The apr_canon_file_t should be preserved as long as possible and +form. The fspr_canon_file_t should be preserved as long as possible and used as the parent to create child entries to reduce the number of expensive stat and case canonicalization calls to the OS.

    diff --git a/libs/apr/docs/doxygen.conf b/libs/apr/docs/doxygen.conf index 29c2cbf694..76adb8646a 100644 --- a/libs/apr/docs/doxygen.conf +++ b/libs/apr/docs/doxygen.conf @@ -14,9 +14,9 @@ EXPAND_ONLY_PREDEF=YES PREDEFINED="APR_DECLARE(x)=x" \ "APR_DECLARE_NONSTD(x)=x" \ "APR_DECLARE_DATA" \ - "APR_POOL_DECLARE_ACCESSOR(x)=apr_pool_t* apr_##x##_pool_get (const apr_##x##_t *the##x)" \ - "APR_DECLARE_INHERIT_SET(x)=apr_status_t apr_##x##_inherit_set(apr_##x##_t *the##x)" \ - "APR_DECLARE_INHERIT_UNSET(x)=apr_status_t apr_##x##_inherit_unset(apr_##x##_t *the##x)" \ + "APR_POOL_DECLARE_ACCESSOR(x)=fspr_pool_t* fspr_##x##_pool_get (const fspr_##x##_t *the##x)" \ + "APR_DECLARE_INHERIT_SET(x)=fspr_status_t fspr_##x##_inherit_set(fspr_##x##_t *the##x)" \ + "APR_DECLARE_INHERIT_UNSET(x)=fspr_status_t fspr_##x##_inherit_unset(fspr_##x##_t *the##x)" \ "APR_HAS_THREADS" \ "__attribute__(x)=" \ DOXYGEN= diff --git a/libs/apr/docs/non_apr_programs b/libs/apr/docs/non_apr_programs index 5003a8bd55..4595f0e83a 100644 --- a/libs/apr/docs/non_apr_programs +++ b/libs/apr/docs/non_apr_programs @@ -6,7 +6,7 @@ we don't expect them to migrate to using APR just because APR has been released. So, we have provided a way for non-APR'ized programs to interact very cleanly with APR. -There are a set of functions, all documented in apr_portable.h, which allow +There are a set of functions, all documented in fspr_portable.h, which allow a programmer to either get a native type from an APR type, or to setup an APR type from a native type. @@ -15,11 +15,11 @@ APR for file I/O, but you (in your infinite wisdom) want to use APR to make sure your section is portable. Assume the program provides a type foo_t with a file descriptor in it (fd). -void function_using_apr(foo_t non_apr_struct, ap_pool_t *p) +void function_using_apr(foo_t non_fspr_struct, ap_pool_t *p) { - ap_file_t *apr_file = NULL; + ap_file_t *fspr_file = NULL; - ap_put_os_file(&apr_file, &non_apr_struct->fd, p); + ap_put_os_file(&fspr_file, &non_fspr_struct->fd, p); ... } @@ -28,20 +28,20 @@ There are portable functions for each APR incomplete type. They are all called ap_put_os_foobar(), and they each take the same basic arguments, a pointer to a pointer to the incomplete type (the last pointer in that list should be NULL), a pointer to the native type, and a pool. Each of these can -be found in apr_portable.h. +be found in fspr_portable.h. If you have to do the exact opposite (take an APR type and convert it to a native type, there are functions for that too. For example: -void function_not_using_apr(apr_file_t *apr_file) +void function_not_using_apr(fspr_file_t *fspr_file) { int unix_file_desc; - ap_get_os_file(&unix_file_desc, apr_file); + ap_get_os_file(&unix_file_desc, fspr_file); ... } For each ap_put_os_foobar, there is a corresponding ap_get_os_file. These are -also documented in apr_portable.h. +also documented in fspr_portable.h. diff --git a/libs/apr/docs/pool-design.html b/libs/apr/docs/pool-design.html index 6ce6d81e6a..462afaa9c1 100644 --- a/libs/apr/docs/pool-design.html +++ b/libs/apr/docs/pool-design.html @@ -60,13 +60,13 @@

    -subpool = apr_create_subpool(pool);
    +subpool = fspr_create_subpool(pool);
     for (i = 0; i < n; ++i) {
    -  apr_pool_clear(subpool);
    +  fspr_pool_clear(subpool);
     
       do_operation(..., subpool);
     }
    -apr_pool_destroy(subpool);
    +fspr_pool_destroy(subpool);

    This pattern prevents the 'pool' from growing unbounded and diff --git a/libs/apr/docs/win32_builds.html b/libs/apr/docs/win32_builds.html index ad57d8e138..664769fbaf 100644 --- a/libs/apr/docs/win32_builds.html +++ b/libs/apr/docs/win32_builds.html @@ -43,7 +43,7 @@ link with the /pdbtype:sept flag! At the time your application links to an APR library, the corresponding _src.pdb file should exist in the original path the library was built, or it may be sufficient to keep the _src.pdb file - in the same path as the library file. (E.g. apr.lib and apr_src.pdb should + in the same path as the library file. (E.g. apr.lib and fspr_src.pdb should reside together in your lib directory.) The later option is unconfirmed.

    In order to keep the symbols compiled into the static library, your application diff --git a/libs/apr/dso/aix/dso.c b/libs/apr/dso/aix/dso.c index 25f6262af8..f3449d38da 100644 --- a/libs/apr/dso/aix/dso.c +++ b/libs/apr/dso/aix/dso.c @@ -49,8 +49,8 @@ #include #include #include -#include "apr_arch_dso.h" -#include "apr_portable.h" +#include "fspr_arch_dso.h" +#include "fspr_portable.h" #if APR_HAS_DSO @@ -97,26 +97,26 @@ struct dl_info { * add the basic "wrappers" here. */ -APR_DECLARE(apr_status_t) apr_os_dso_handle_put(apr_dso_handle_t **aprdso, - apr_os_dso_handle_t osdso, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_os_dso_handle_put(fspr_dso_handle_t **aprdso, + fspr_os_dso_handle_t osdso, + fspr_pool_t *pool) { - *aprdso = apr_pcalloc(pool, sizeof **aprdso); + *aprdso = fspr_pcalloc(pool, sizeof **aprdso); (*aprdso)->handle = osdso; (*aprdso)->pool = pool; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_os_dso_handle_get(apr_os_dso_handle_t *osdso, - apr_dso_handle_t *aprdso) +APR_DECLARE(fspr_status_t) fspr_os_dso_handle_get(fspr_os_dso_handle_t *osdso, + fspr_dso_handle_t *aprdso) { *osdso = aprdso->handle; return APR_SUCCESS; } -static apr_status_t dso_cleanup(void *thedso) +static fspr_status_t dso_cleanup(void *thedso) { - apr_dso_handle_t *dso = thedso; + fspr_dso_handle_t *dso = thedso; if (dso->handle != NULL && dlclose(dso->handle) != 0) return APR_EINIT; @@ -125,12 +125,12 @@ static apr_status_t dso_cleanup(void *thedso) return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_dso_load(apr_dso_handle_t **res_handle, - const char *path, apr_pool_t *ctx) +APR_DECLARE(fspr_status_t) fspr_dso_load(fspr_dso_handle_t **res_handle, + const char *path, fspr_pool_t *ctx) { void *os_handle = dlopen((char *)path, RTLD_NOW | RTLD_GLOBAL); - *res_handle = apr_pcalloc(ctx, sizeof(*res_handle)); + *res_handle = fspr_pcalloc(ctx, sizeof(*res_handle)); if(os_handle == NULL) { (*res_handle)->errormsg = dlerror(); @@ -141,18 +141,18 @@ APR_DECLARE(apr_status_t) apr_dso_load(apr_dso_handle_t **res_handle, (*res_handle)->pool = ctx; (*res_handle)->errormsg = NULL; - apr_pool_cleanup_register(ctx, *res_handle, dso_cleanup, apr_pool_cleanup_null); + fspr_pool_cleanup_register(ctx, *res_handle, dso_cleanup, fspr_pool_cleanup_null); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_dso_unload(apr_dso_handle_t *handle) +APR_DECLARE(fspr_status_t) fspr_dso_unload(fspr_dso_handle_t *handle) { - return apr_pool_cleanup_run(handle->pool, handle, dso_cleanup); + return fspr_pool_cleanup_run(handle->pool, handle, dso_cleanup); } -APR_DECLARE(apr_status_t) apr_dso_sym(apr_dso_handle_sym_t *ressym, - apr_dso_handle_t *handle, +APR_DECLARE(fspr_status_t) fspr_dso_sym(fspr_dso_handle_sym_t *ressym, + fspr_dso_handle_t *handle, const char *symname) { void *retval = dlsym(handle->handle, symname); @@ -166,10 +166,10 @@ APR_DECLARE(apr_status_t) apr_dso_sym(apr_dso_handle_sym_t *ressym, return APR_SUCCESS; } -APR_DECLARE(const char *) apr_dso_error(apr_dso_handle_t *dso, char *buffer, apr_size_t buflen) +APR_DECLARE(const char *) fspr_dso_error(fspr_dso_handle_t *dso, char *buffer, fspr_size_t buflen) { if (dso->errormsg) { - apr_cpystrn(buffer, dso->errormsg, buflen); + fspr_cpystrn(buffer, dso->errormsg, buflen); return dso->errormsg; } return "No Error"; diff --git a/libs/apr/dso/beos/dso.c b/libs/apr/dso/beos/dso.c index 91dd1b4e81..6ca214e865 100644 --- a/libs/apr/dso/beos/dso.c +++ b/libs/apr/dso/beos/dso.c @@ -14,14 +14,14 @@ * limitations under the License. */ -#include "apr_arch_dso.h" -#include "apr_portable.h" +#include "fspr_arch_dso.h" +#include "fspr_portable.h" #if APR_HAS_DSO -static apr_status_t dso_cleanup(void *thedso) +static fspr_status_t dso_cleanup(void *thedso) { - apr_dso_handle_t *dso = thedso; + fspr_dso_handle_t *dso = thedso; if (dso->handle > 0 && unload_add_on(dso->handle) < B_NO_ERROR) return APR_EINIT; @@ -30,12 +30,12 @@ static apr_status_t dso_cleanup(void *thedso) return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_dso_load(apr_dso_handle_t **res_handle, - const char *path, apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_dso_load(fspr_dso_handle_t **res_handle, + const char *path, fspr_pool_t *pool) { image_id newid = -1; - *res_handle = apr_pcalloc(pool, sizeof(*res_handle)); + *res_handle = fspr_pcalloc(pool, sizeof(*res_handle)); if((newid = load_add_on(path)) < B_NO_ERROR) { (*res_handle)->errormsg = strerror(newid); @@ -45,17 +45,17 @@ APR_DECLARE(apr_status_t) apr_dso_load(apr_dso_handle_t **res_handle, (*res_handle)->pool = pool; (*res_handle)->handle = newid; - apr_pool_cleanup_register(pool, *res_handle, dso_cleanup, apr_pool_cleanup_null); + fspr_pool_cleanup_register(pool, *res_handle, dso_cleanup, fspr_pool_cleanup_null); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_dso_unload(apr_dso_handle_t *handle) +APR_DECLARE(fspr_status_t) fspr_dso_unload(fspr_dso_handle_t *handle) { - return apr_pool_cleanup_run(handle->pool, handle, dso_cleanup); + return fspr_pool_cleanup_run(handle->pool, handle, dso_cleanup); } -APR_DECLARE(apr_status_t) apr_dso_sym(apr_dso_handle_sym_t *ressym, apr_dso_handle_t *handle, +APR_DECLARE(fspr_status_t) fspr_dso_sym(fspr_dso_handle_sym_t *ressym, fspr_dso_handle_t *handle, const char *symname) { int err; @@ -72,24 +72,24 @@ APR_DECLARE(apr_status_t) apr_dso_sym(apr_dso_handle_sym_t *ressym, apr_dso_hand return APR_SUCCESS; } -APR_DECLARE(const char *) apr_dso_error(apr_dso_handle_t *dso, char *buffer, apr_size_t buflen) +APR_DECLARE(const char *) fspr_dso_error(fspr_dso_handle_t *dso, char *buffer, fspr_size_t buflen) { strncpy(buffer, strerror(errno), buflen); return buffer; } -APR_DECLARE(apr_status_t) apr_os_dso_handle_put(apr_dso_handle_t **aprdso, - apr_os_dso_handle_t osdso, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_os_dso_handle_put(fspr_dso_handle_t **aprdso, + fspr_os_dso_handle_t osdso, + fspr_pool_t *pool) { - *aprdso = apr_pcalloc(pool, sizeof **aprdso); + *aprdso = fspr_pcalloc(pool, sizeof **aprdso); (*aprdso)->handle = osdso; (*aprdso)->pool = pool; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_os_dso_handle_get(apr_os_dso_handle_t *osdso, - apr_dso_handle_t *aprdso) +APR_DECLARE(fspr_status_t) fspr_os_dso_handle_get(fspr_os_dso_handle_t *osdso, + fspr_dso_handle_t *aprdso) { *osdso = aprdso->handle; return APR_SUCCESS; diff --git a/libs/apr/dso/netware/dso.c b/libs/apr/dso/netware/dso.c index 4cd2ad611e..effe03eeea 100644 --- a/libs/apr/dso/netware/dso.c +++ b/libs/apr/dso/netware/dso.c @@ -14,33 +14,33 @@ * limitations under the License. */ -#include "apr_arch_dso.h" -#include "apr_strings.h" -#include "apr_portable.h" +#include "fspr_arch_dso.h" +#include "fspr_strings.h" +#include "fspr_portable.h" #include #include -APR_DECLARE(apr_status_t) apr_os_dso_handle_put(apr_dso_handle_t **aprdso, - apr_os_dso_handle_t osdso, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_os_dso_handle_put(fspr_dso_handle_t **aprdso, + fspr_os_dso_handle_t osdso, + fspr_pool_t *pool) { - *aprdso = apr_pcalloc(pool, sizeof **aprdso); + *aprdso = fspr_pcalloc(pool, sizeof **aprdso); (*aprdso)->handle = osdso; (*aprdso)->pool = pool; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_os_dso_handle_get(apr_os_dso_handle_t *osdso, - apr_dso_handle_t *aprdso) +APR_DECLARE(fspr_status_t) fspr_os_dso_handle_get(fspr_os_dso_handle_t *osdso, + fspr_dso_handle_t *aprdso) { *osdso = aprdso->handle; return APR_SUCCESS; } -static apr_status_t dso_cleanup(void *thedso) +static fspr_status_t dso_cleanup(void *thedso) { - apr_dso_handle_t *dso = thedso; + fspr_dso_handle_t *dso = thedso; sym_list *symbol = NULL; void *NLMHandle = getnlmhandle(); @@ -65,22 +65,22 @@ static apr_status_t dso_cleanup(void *thedso) return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_dso_load(apr_dso_handle_t **res_handle, - const char *path, apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_dso_load(fspr_dso_handle_t **res_handle, + const char *path, fspr_pool_t *pool) { void *os_handle = NULL; char *fullpath = NULL; - apr_status_t rv; + fspr_status_t rv; - if ((rv = apr_filepath_merge(&fullpath, NULL, path, + if ((rv = fspr_filepath_merge(&fullpath, NULL, path, APR_FILEPATH_NATIVE, pool)) != APR_SUCCESS) { return rv; } os_handle = dlopen(fullpath, RTLD_NOW | RTLD_LOCAL); - *res_handle = apr_pcalloc(pool, sizeof(**res_handle)); + *res_handle = fspr_pcalloc(pool, sizeof(**res_handle)); if(os_handle == NULL) { (*res_handle)->errormsg = dlerror(); @@ -91,20 +91,20 @@ APR_DECLARE(apr_status_t) apr_dso_load(apr_dso_handle_t **res_handle, (*res_handle)->pool = pool; (*res_handle)->errormsg = NULL; (*res_handle)->symbols = NULL; - (*res_handle)->path = apr_pstrdup(pool, fullpath); + (*res_handle)->path = fspr_pstrdup(pool, fullpath); - apr_pool_cleanup_register(pool, *res_handle, dso_cleanup, apr_pool_cleanup_null); + fspr_pool_cleanup_register(pool, *res_handle, dso_cleanup, fspr_pool_cleanup_null); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_dso_unload(apr_dso_handle_t *handle) +APR_DECLARE(fspr_status_t) fspr_dso_unload(fspr_dso_handle_t *handle) { - return apr_pool_cleanup_run(handle->pool, handle, dso_cleanup); + return fspr_pool_cleanup_run(handle->pool, handle, dso_cleanup); } -APR_DECLARE(apr_status_t) apr_dso_sym(apr_dso_handle_sym_t *ressym, - apr_dso_handle_t *handle, +APR_DECLARE(fspr_status_t) fspr_dso_sym(fspr_dso_handle_sym_t *ressym, + fspr_dso_handle_t *handle, const char *symname) { sym_list *symbol = NULL; @@ -115,21 +115,21 @@ APR_DECLARE(apr_status_t) apr_dso_sym(apr_dso_handle_sym_t *ressym, return APR_ESYMNOTFOUND; } - symbol = apr_pcalloc(handle->pool, sizeof(sym_list)); + symbol = fspr_pcalloc(handle->pool, sizeof(sym_list)); symbol->next = handle->symbols; handle->symbols = symbol; - symbol->symbol = apr_pstrdup(handle->pool, symname); + symbol->symbol = fspr_pstrdup(handle->pool, symname); *ressym = retval; return APR_SUCCESS; } -APR_DECLARE(const char *) apr_dso_error(apr_dso_handle_t *dso, char *buffer, - apr_size_t buflen) +APR_DECLARE(const char *) fspr_dso_error(fspr_dso_handle_t *dso, char *buffer, + fspr_size_t buflen) { if (dso->errormsg) { - apr_cpystrn(buffer, dso->errormsg, buflen); + fspr_cpystrn(buffer, dso->errormsg, buflen); return dso->errormsg; } return "No Error"; diff --git a/libs/apr/dso/os2/dso.c b/libs/apr/dso/os2/dso.c index 1a7f7de838..0cc71842fb 100644 --- a/libs/apr/dso/os2/dso.c +++ b/libs/apr/dso/os2/dso.c @@ -14,17 +14,17 @@ * limitations under the License. */ -#include "apr_arch_dso.h" -#include "apr_strings.h" -#include "apr_portable.h" +#include "fspr_arch_dso.h" +#include "fspr_strings.h" +#include "fspr_portable.h" #include #include #if APR_HAS_DSO -static apr_status_t dso_cleanup(void *thedso) +static fspr_status_t dso_cleanup(void *thedso) { - apr_dso_handle_t *dso = thedso; + fspr_dso_handle_t *dso = thedso; int rc; if (dso->handle == 0) @@ -39,39 +39,39 @@ static apr_status_t dso_cleanup(void *thedso) } -APR_DECLARE(apr_status_t) apr_dso_load(apr_dso_handle_t **res_handle, const char *path, apr_pool_t *ctx) +APR_DECLARE(fspr_status_t) fspr_dso_load(fspr_dso_handle_t **res_handle, const char *path, fspr_pool_t *ctx) { char failed_module[200]; HMODULE handle; int rc; - *res_handle = apr_pcalloc(ctx, sizeof(**res_handle)); + *res_handle = fspr_pcalloc(ctx, sizeof(**res_handle)); (*res_handle)->cont = ctx; (*res_handle)->load_error = APR_SUCCESS; (*res_handle)->failed_module = NULL; if ((rc = DosLoadModule(failed_module, sizeof(failed_module), path, &handle)) != 0) { (*res_handle)->load_error = APR_FROM_OS_ERROR(rc); - (*res_handle)->failed_module = apr_pstrdup(ctx, failed_module); + (*res_handle)->failed_module = fspr_pstrdup(ctx, failed_module); return APR_FROM_OS_ERROR(rc); } (*res_handle)->handle = handle; - apr_pool_cleanup_register(ctx, *res_handle, dso_cleanup, apr_pool_cleanup_null); + fspr_pool_cleanup_register(ctx, *res_handle, dso_cleanup, fspr_pool_cleanup_null); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_dso_unload(apr_dso_handle_t *handle) +APR_DECLARE(fspr_status_t) fspr_dso_unload(fspr_dso_handle_t *handle) { - return apr_pool_cleanup_run(handle->cont, handle, dso_cleanup); + return fspr_pool_cleanup_run(handle->cont, handle, dso_cleanup); } -APR_DECLARE(apr_status_t) apr_dso_sym(apr_dso_handle_sym_t *ressym, - apr_dso_handle_t *handle, +APR_DECLARE(fspr_status_t) fspr_dso_sym(fspr_dso_handle_sym_t *ressym, + fspr_dso_handle_t *handle, const char *symname) { PFN func; @@ -91,10 +91,10 @@ APR_DECLARE(apr_status_t) apr_dso_sym(apr_dso_handle_sym_t *ressym, -APR_DECLARE(const char *) apr_dso_error(apr_dso_handle_t *dso, char *buffer, apr_size_t buflen) +APR_DECLARE(const char *) fspr_dso_error(fspr_dso_handle_t *dso, char *buffer, fspr_size_t buflen) { char message[200]; - apr_strerror(dso->load_error, message, sizeof(message)); + fspr_strerror(dso->load_error, message, sizeof(message)); if (dso->failed_module != NULL) { strcat(message, " ("); @@ -102,17 +102,17 @@ APR_DECLARE(const char *) apr_dso_error(apr_dso_handle_t *dso, char *buffer, apr strcat(message, ")"); } - apr_cpystrn(buffer, message, buflen); + fspr_cpystrn(buffer, message, buflen); return buffer; } -APR_DECLARE(apr_status_t) apr_os_dso_handle_put(apr_dso_handle_t **aprdso, - apr_os_dso_handle_t osdso, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_os_dso_handle_put(fspr_dso_handle_t **aprdso, + fspr_os_dso_handle_t osdso, + fspr_pool_t *pool) { - *aprdso = apr_pcalloc(pool, sizeof **aprdso); + *aprdso = fspr_pcalloc(pool, sizeof **aprdso); (*aprdso)->handle = osdso; (*aprdso)->cont = pool; (*aprdso)->load_error = APR_SUCCESS; @@ -122,8 +122,8 @@ APR_DECLARE(apr_status_t) apr_os_dso_handle_put(apr_dso_handle_t **aprdso, -APR_DECLARE(apr_status_t) apr_os_dso_handle_get(apr_os_dso_handle_t *osdso, - apr_dso_handle_t *aprdso) +APR_DECLARE(fspr_status_t) fspr_os_dso_handle_get(fspr_os_dso_handle_t *osdso, + fspr_dso_handle_t *aprdso) { *osdso = aprdso->handle; return APR_SUCCESS; diff --git a/libs/apr/dso/os390/dso.c b/libs/apr/dso/os390/dso.c index 293d0653e7..7c7f9fb832 100644 --- a/libs/apr/dso/os390/dso.c +++ b/libs/apr/dso/os390/dso.c @@ -14,34 +14,34 @@ * limitations under the License. */ -#include "apr_portable.h" -#include "apr_strings.h" -#include "apr_arch_dso.h" +#include "fspr_portable.h" +#include "fspr_strings.h" +#include "fspr_arch_dso.h" #include #include #if APR_HAS_DSO -APR_DECLARE(apr_status_t) apr_os_dso_handle_put(apr_dso_handle_t **aprdso, - apr_os_dso_handle_t osdso, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_os_dso_handle_put(fspr_dso_handle_t **aprdso, + fspr_os_dso_handle_t osdso, + fspr_pool_t *pool) { - *aprdso = apr_pcalloc(pool, sizeof **aprdso); + *aprdso = fspr_pcalloc(pool, sizeof **aprdso); (*aprdso)->handle = osdso; (*aprdso)->pool = pool; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_os_dso_handle_get(apr_os_dso_handle_t *osdso, - apr_dso_handle_t *aprdso) +APR_DECLARE(fspr_status_t) fspr_os_dso_handle_get(fspr_os_dso_handle_t *osdso, + fspr_dso_handle_t *aprdso) { *osdso = aprdso->handle; return APR_SUCCESS; } -static apr_status_t dso_cleanup(void *thedso) +static fspr_status_t dso_cleanup(void *thedso) { - apr_dso_handle_t *dso = thedso; + fspr_dso_handle_t *dso = thedso; int rc; if (dso->handle == 0) @@ -57,17 +57,17 @@ static apr_status_t dso_cleanup(void *thedso) return errno; } -APR_DECLARE(apr_status_t) apr_dso_load(apr_dso_handle_t **res_handle, - const char *path, apr_pool_t *ctx) +APR_DECLARE(fspr_status_t) fspr_dso_load(fspr_dso_handle_t **res_handle, + const char *path, fspr_pool_t *ctx) { dllhandle *handle; int rc; - *res_handle = apr_pcalloc(ctx, sizeof(*res_handle)); + *res_handle = fspr_pcalloc(ctx, sizeof(*res_handle)); (*res_handle)->pool = ctx; if ((handle = dllload(path)) != NULL) { (*res_handle)->handle = handle; - apr_pool_cleanup_register(ctx, *res_handle, dso_cleanup, apr_pool_cleanup_null); + fspr_pool_cleanup_register(ctx, *res_handle, dso_cleanup, fspr_pool_cleanup_null); return APR_SUCCESS; } @@ -75,13 +75,13 @@ APR_DECLARE(apr_status_t) apr_dso_load(apr_dso_handle_t **res_handle, return errno; } -APR_DECLARE(apr_status_t) apr_dso_unload(apr_dso_handle_t *handle) +APR_DECLARE(fspr_status_t) fspr_dso_unload(fspr_dso_handle_t *handle) { - return apr_pool_cleanup_run(handle->pool, handle, dso_cleanup); + return fspr_pool_cleanup_run(handle->pool, handle, dso_cleanup); } -APR_DECLARE(apr_status_t) apr_dso_sym(apr_dso_handle_sym_t *ressym, - apr_dso_handle_t *handle, +APR_DECLARE(fspr_status_t) fspr_dso_sym(fspr_dso_handle_sym_t *ressym, + fspr_dso_handle_t *handle, const char *symname) { void *func_ptr; @@ -99,10 +99,10 @@ APR_DECLARE(apr_status_t) apr_dso_sym(apr_dso_handle_sym_t *ressym, return errno; } -APR_DECLARE(const char *) apr_dso_error(apr_dso_handle_t *handle, char *buffer, - apr_size_t buflen) +APR_DECLARE(const char *) fspr_dso_error(fspr_dso_handle_t *handle, char *buffer, + fspr_size_t buflen) { - apr_cpystrn(buffer, strerror(handle->failing_errno), buflen); + fspr_cpystrn(buffer, strerror(handle->failing_errno), buflen); return buffer; } diff --git a/libs/apr/dso/unix/dso.c b/libs/apr/dso/unix/dso.c index 15d39d7d19..2e77a19bf5 100644 --- a/libs/apr/dso/unix/dso.c +++ b/libs/apr/dso/unix/dso.c @@ -14,9 +14,9 @@ * limitations under the License. */ -#include "apr_arch_dso.h" -#include "apr_strings.h" -#include "apr_portable.h" +#include "fspr_arch_dso.h" +#include "fspr_strings.h" +#include "fspr_portable.h" #if APR_HAS_DSO @@ -38,26 +38,26 @@ #define DYLD_LIBRARY_HANDLE (void *)-1 #endif -APR_DECLARE(apr_status_t) apr_os_dso_handle_put(apr_dso_handle_t **aprdso, - apr_os_dso_handle_t osdso, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_os_dso_handle_put(fspr_dso_handle_t **aprdso, + fspr_os_dso_handle_t osdso, + fspr_pool_t *pool) { - *aprdso = apr_pcalloc(pool, sizeof **aprdso); + *aprdso = fspr_pcalloc(pool, sizeof **aprdso); (*aprdso)->handle = osdso; (*aprdso)->pool = pool; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_os_dso_handle_get(apr_os_dso_handle_t *osdso, - apr_dso_handle_t *aprdso) +APR_DECLARE(fspr_status_t) fspr_os_dso_handle_get(fspr_os_dso_handle_t *osdso, + fspr_dso_handle_t *aprdso) { *osdso = aprdso->handle; return APR_SUCCESS; } -static apr_status_t dso_cleanup(void *thedso) +static fspr_status_t dso_cleanup(void *thedso) { - apr_dso_handle_t *dso = thedso; + fspr_dso_handle_t *dso = thedso; if (dso->handle == NULL) return APR_SUCCESS; @@ -77,8 +77,8 @@ static apr_status_t dso_cleanup(void *thedso) return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_dso_load(apr_dso_handle_t **res_handle, - const char *path, apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_dso_load(fspr_dso_handle_t **res_handle, + const char *path, fspr_pool_t *pool) { #if defined(DSO_USE_SHL) shl_t os_handle = shl_load(path, BIND_IMMEDIATE, 0L); @@ -140,7 +140,7 @@ APR_DECLARE(apr_status_t) apr_dso_load(apr_dso_handle_t **res_handle, #endif #endif /* DSO_USE_x */ - *res_handle = apr_pcalloc(pool, sizeof(**res_handle)); + *res_handle = fspr_pcalloc(pool, sizeof(**res_handle)); if(os_handle == NULL) { #if defined(DSO_USE_SHL) @@ -159,18 +159,18 @@ APR_DECLARE(apr_status_t) apr_dso_load(apr_dso_handle_t **res_handle, (*res_handle)->pool = pool; (*res_handle)->errormsg = NULL; - apr_pool_cleanup_register(pool, *res_handle, dso_cleanup, apr_pool_cleanup_null); + fspr_pool_cleanup_register(pool, *res_handle, dso_cleanup, fspr_pool_cleanup_null); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_dso_unload(apr_dso_handle_t *handle) +APR_DECLARE(fspr_status_t) fspr_dso_unload(fspr_dso_handle_t *handle) { - return apr_pool_cleanup_run(handle->pool, handle, dso_cleanup); + return fspr_pool_cleanup_run(handle->pool, handle, dso_cleanup); } -APR_DECLARE(apr_status_t) apr_dso_sym(apr_dso_handle_sym_t *ressym, - apr_dso_handle_t *handle, +APR_DECLARE(fspr_status_t) fspr_dso_sym(fspr_dso_handle_sym_t *ressym, + fspr_dso_handle_t *handle, const char *symname) { #if defined(DSO_USE_SHL) @@ -238,11 +238,11 @@ APR_DECLARE(apr_status_t) apr_dso_sym(apr_dso_handle_sym_t *ressym, #endif /* DSO_USE_x */ } -APR_DECLARE(const char *) apr_dso_error(apr_dso_handle_t *dso, char *buffer, - apr_size_t buflen) +APR_DECLARE(const char *) fspr_dso_error(fspr_dso_handle_t *dso, char *buffer, + fspr_size_t buflen) { if (dso->errormsg) { - apr_cpystrn(buffer, dso->errormsg, buflen); + fspr_cpystrn(buffer, dso->errormsg, buflen); return dso->errormsg; } return "No Error"; diff --git a/libs/apr/dso/win32/dso.c b/libs/apr/dso/win32/dso.c index d4a689387b..928b88344b 100644 --- a/libs/apr/dso/win32/dso.c +++ b/libs/apr/dso/win32/dso.c @@ -14,48 +14,48 @@ * limitations under the License. */ -#include "apr_arch_dso.h" -#include "apr_strings.h" -#include "apr_private.h" -#include "apr_arch_file_io.h" -#include "apr_arch_utf8.h" +#include "fspr_arch_dso.h" +#include "fspr_strings.h" +#include "fspr_private.h" +#include "fspr_arch_file_io.h" +#include "fspr_arch_utf8.h" #if APR_HAS_DSO -APR_DECLARE(apr_status_t) apr_os_dso_handle_put(apr_dso_handle_t **aprdso, - apr_os_dso_handle_t osdso, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_os_dso_handle_put(fspr_dso_handle_t **aprdso, + fspr_os_dso_handle_t osdso, + fspr_pool_t *pool) { - *aprdso = apr_pcalloc(pool, sizeof **aprdso); + *aprdso = fspr_pcalloc(pool, sizeof **aprdso); (*aprdso)->handle = osdso; (*aprdso)->cont = pool; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_os_dso_handle_get(apr_os_dso_handle_t *osdso, - apr_dso_handle_t *aprdso) +APR_DECLARE(fspr_status_t) fspr_os_dso_handle_get(fspr_os_dso_handle_t *osdso, + fspr_dso_handle_t *aprdso) { *osdso = aprdso->handle; return APR_SUCCESS; } -static apr_status_t dso_cleanup(void *thedso) +static fspr_status_t dso_cleanup(void *thedso) { - apr_dso_handle_t *dso = thedso; + fspr_dso_handle_t *dso = thedso; if (dso->handle != NULL && !FreeLibrary(dso->handle)) { - return apr_get_os_error(); + return fspr_get_os_error(); } dso->handle = NULL; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_dso_load(struct apr_dso_handle_t **res_handle, - const char *path, apr_pool_t *ctx) +APR_DECLARE(fspr_status_t) fspr_dso_load(struct fspr_dso_handle_t **res_handle, + const char *path, fspr_pool_t *ctx) { HINSTANCE os_handle; - apr_status_t rv; + fspr_status_t rv; #ifndef _WIN32_WCE UINT em; #endif @@ -63,11 +63,11 @@ APR_DECLARE(apr_status_t) apr_dso_load(struct apr_dso_handle_t **res_handle, #if APR_HAS_UNICODE_FS IF_WIN_OS_IS_UNICODE { - apr_wchar_t wpath[APR_PATH_MAX]; + fspr_wchar_t wpath[APR_PATH_MAX]; if ((rv = utf8_to_unicode_path(wpath, sizeof(wpath) - / sizeof(apr_wchar_t), path)) + / sizeof(fspr_wchar_t), path)) != APR_SUCCESS) { - *res_handle = apr_pcalloc(ctx, sizeof(**res_handle)); + *res_handle = fspr_pcalloc(ctx, sizeof(**res_handle)); return ((*res_handle)->load_error = rv); } /* Prevent ugly popups from killing our app */ @@ -78,7 +78,7 @@ APR_DECLARE(apr_status_t) apr_dso_load(struct apr_dso_handle_t **res_handle, if (!os_handle) os_handle = LoadLibraryExW(wpath, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); if (!os_handle) - rv = apr_get_os_error(); + rv = fspr_get_os_error(); #ifndef _WIN32_WCE SetErrorMode(em); #endif @@ -94,7 +94,7 @@ APR_DECLARE(apr_status_t) apr_dso_load(struct apr_dso_handle_t **res_handle, * LoadLibrary in the MS PSDK also reveals that it -explicitly- states * that backslashes must be used for the LoadLibrary family of calls. */ - apr_cpystrn(fspec, path, sizeof(fspec)); + fspr_cpystrn(fspec, path, sizeof(fspec)); while ((p = strchr(p, '/')) != NULL) *p = '\\'; @@ -104,14 +104,14 @@ APR_DECLARE(apr_status_t) apr_dso_load(struct apr_dso_handle_t **res_handle, if (!os_handle) os_handle = LoadLibraryEx(path, NULL, 0); if (!os_handle) - rv = apr_get_os_error(); + rv = fspr_get_os_error(); else rv = APR_SUCCESS; SetErrorMode(em); } #endif - *res_handle = apr_pcalloc(ctx, sizeof(**res_handle)); + *res_handle = fspr_pcalloc(ctx, sizeof(**res_handle)); (*res_handle)->cont = ctx; if (rv) { @@ -121,27 +121,27 @@ APR_DECLARE(apr_status_t) apr_dso_load(struct apr_dso_handle_t **res_handle, (*res_handle)->handle = (void*)os_handle; (*res_handle)->load_error = APR_SUCCESS; - apr_pool_cleanup_register(ctx, *res_handle, dso_cleanup, apr_pool_cleanup_null); + fspr_pool_cleanup_register(ctx, *res_handle, dso_cleanup, fspr_pool_cleanup_null); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_dso_unload(struct apr_dso_handle_t *handle) +APR_DECLARE(fspr_status_t) fspr_dso_unload(struct fspr_dso_handle_t *handle) { - return apr_pool_cleanup_run(handle->cont, handle, dso_cleanup); + return fspr_pool_cleanup_run(handle->cont, handle, dso_cleanup); } -APR_DECLARE(apr_status_t) apr_dso_sym(apr_dso_handle_sym_t *ressym, - struct apr_dso_handle_t *handle, +APR_DECLARE(fspr_status_t) fspr_dso_sym(fspr_dso_handle_sym_t *ressym, + struct fspr_dso_handle_t *handle, const char *symname) { #ifdef _WIN32_WCE - apr_size_t symlen = strlen(symname) + 1; - apr_size_t wsymlen = 256; - apr_wchar_t wsymname[256]; - apr_status_t rv; + fspr_size_t symlen = strlen(symname) + 1; + fspr_size_t wsymlen = 256; + fspr_wchar_t wsymname[256]; + fspr_status_t rv; - rv = apr_conv_utf8_to_ucs2(wsymname, &wsymlen, symname, &symlen); + rv = fspr_conv_utf8_to_ucs2(wsymname, &wsymlen, symname, &symlen); if (rv != APR_SUCCESS) { return rv; } @@ -149,19 +149,19 @@ APR_DECLARE(apr_status_t) apr_dso_sym(apr_dso_handle_sym_t *ressym, return APR_ENAMETOOLONG; } - *ressym = (apr_dso_handle_sym_t)GetProcAddressW(handle->handle, wsymname); + *ressym = (fspr_dso_handle_sym_t)GetProcAddressW(handle->handle, wsymname); #else - *ressym = (apr_dso_handle_sym_t)GetProcAddress(handle->handle, symname); + *ressym = (fspr_dso_handle_sym_t)GetProcAddress(handle->handle, symname); #endif if (!*ressym) { - return apr_get_os_error(); + return fspr_get_os_error(); } return APR_SUCCESS; } -APR_DECLARE(const char *) apr_dso_error(apr_dso_handle_t *dso, char *buf, apr_size_t bufsize) +APR_DECLARE(const char *) fspr_dso_error(fspr_dso_handle_t *dso, char *buf, fspr_size_t bufsize) { - return apr_strerror(dso->load_error, buf, bufsize); + return fspr_strerror(dso->load_error, buf, bufsize); } #endif diff --git a/libs/apr/file_io/netware/filestat.c b/libs/apr/file_io/netware/filestat.c index a3f60e57df..5b58ef5b50 100644 --- a/libs/apr/file_io/netware/filestat.c +++ b/libs/apr/file_io/netware/filestat.c @@ -14,15 +14,15 @@ * limitations under the License. */ -#include "apr_arch_file_io.h" +#include "fspr_arch_file_io.h" #include "fsio.h" #include "nks/dirio.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_strings.h" -#include "apr_errno.h" -#include "apr_hash.h" -#include "apr_thread_rwlock.h" +#include "fspr_file_io.h" +#include "fspr_general.h" +#include "fspr_strings.h" +#include "fspr_errno.h" +#include "fspr_hash.h" +#include "fspr_thread_rwlock.h" #ifdef HAVE_UTIME_H #include @@ -30,9 +30,9 @@ #define APR_HAS_PSA -static apr_filetype_e filetype_from_mode(mode_t mode) +static fspr_filetype_e filetype_from_mode(mode_t mode) { - apr_filetype_e type = APR_NOFILE; + fspr_filetype_e type = APR_NOFILE; if (S_ISREG(mode)) type = APR_REG; @@ -53,12 +53,12 @@ static apr_filetype_e filetype_from_mode(mode_t mode) return type; } -static void fill_out_finfo(apr_finfo_t *finfo, struct stat *info, - apr_int32_t wanted) +static void fill_out_finfo(fspr_finfo_t *finfo, struct stat *info, + fspr_int32_t wanted) { finfo->valid = APR_FINFO_MIN | APR_FINFO_IDENT | APR_FINFO_NLINK | APR_FINFO_OWNER | APR_FINFO_PROT; - finfo->protection = apr_unix_mode2perms(info->st_mode); + finfo->protection = fspr_unix_mode2perms(info->st_mode); finfo->filetype = filetype_from_mode(info->st_mode); finfo->user = info->st_uid; finfo->group = info->st_gid; @@ -66,9 +66,9 @@ static void fill_out_finfo(apr_finfo_t *finfo, struct stat *info, finfo->inode = info->st_ino; finfo->device = info->st_dev; finfo->nlink = info->st_nlink; - apr_time_ansi_put(&finfo->atime, info->st_atime.tv_sec); - apr_time_ansi_put(&finfo->mtime, info->st_mtime.tv_sec); - apr_time_ansi_put(&finfo->ctime, info->st_ctime.tv_sec); + fspr_time_ansi_put(&finfo->atime, info->st_atime.tv_sec); + fspr_time_ansi_put(&finfo->mtime, info->st_mtime.tv_sec); + fspr_time_ansi_put(&finfo->ctime, info->st_ctime.tv_sec); /* ### needs to be revisited * if (wanted & APR_FINFO_CSIZE) { * finfo->csize = info->st_blocks * 512; @@ -77,14 +77,14 @@ static void fill_out_finfo(apr_finfo_t *finfo, struct stat *info, */ } -APR_DECLARE(apr_status_t) apr_file_info_get(apr_finfo_t *finfo, - apr_int32_t wanted, - apr_file_t *thefile) +APR_DECLARE(fspr_status_t) fspr_file_info_get(fspr_finfo_t *finfo, + fspr_int32_t wanted, + fspr_file_t *thefile) { struct stat info; if (thefile->buffered) { - apr_status_t rv = apr_file_flush(thefile); + fspr_status_t rv = fspr_file_flush(thefile); if (rv != APR_SUCCESS) return rv; } @@ -100,30 +100,30 @@ APR_DECLARE(apr_status_t) apr_file_info_get(apr_finfo_t *finfo, } } -APR_DECLARE(apr_status_t) apr_file_perms_set(const char *fname, - apr_fileperms_t perms) +APR_DECLARE(fspr_status_t) fspr_file_perms_set(const char *fname, + fspr_fileperms_t perms) { - mode_t mode = apr_unix_perms2mode(perms); + mode_t mode = fspr_unix_perms2mode(perms); if (chmod(fname, mode) == -1) return errno; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_file_attrs_set(const char *fname, - apr_fileattrs_t attributes, - apr_fileattrs_t attr_mask, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_file_attrs_set(const char *fname, + fspr_fileattrs_t attributes, + fspr_fileattrs_t attr_mask, + fspr_pool_t *pool) { - apr_status_t status; - apr_finfo_t finfo; + fspr_status_t status; + fspr_finfo_t finfo; /* Don't do anything if we can't handle the requested attributes */ if (!(attr_mask & (APR_FILE_ATTR_READONLY | APR_FILE_ATTR_EXECUTABLE))) return APR_SUCCESS; - status = apr_stat(&finfo, fname, APR_FINFO_PROT, pool); + status = fspr_stat(&finfo, fname, APR_FINFO_PROT, pool); if (status) return status; @@ -162,21 +162,21 @@ APR_DECLARE(apr_status_t) apr_file_attrs_set(const char *fname, } } - return apr_file_perms_set(fname, finfo.protection); + return fspr_file_perms_set(fname, finfo.protection); } #ifndef APR_HAS_PSA -static apr_status_t stat_cache_cleanup(void *data) +static fspr_status_t stat_cache_cleanup(void *data) { - apr_pool_t *p = (apr_pool_t *)getGlobalPool(); - apr_hash_index_t *hi; - apr_hash_t *statCache = (apr_hash_t*)data; + fspr_pool_t *p = (fspr_pool_t *)getGlobalPool(); + fspr_hash_index_t *hi; + fspr_hash_t *statCache = (fspr_hash_t*)data; char *key; - apr_ssize_t keylen; + fspr_ssize_t keylen; NXPathCtx_t pathctx; - for (hi = apr_hash_first(p, statCache); hi; hi = apr_hash_next(hi)) { - apr_hash_this(hi, (const void**)&key, &keylen, (void**)&pathctx); + for (hi = fspr_hash_first(p, statCache); hi; hi = fspr_hash_next(hi)) { + fspr_hash_this(hi, (const void**)&key, &keylen, (void**)&pathctx); if (pathctx) { NXFreePathContext(pathctx); @@ -186,11 +186,11 @@ static apr_status_t stat_cache_cleanup(void *data) return APR_SUCCESS; } -int cstat (NXPathCtx_t ctx, char *path, struct stat *buf, unsigned long requestmap, apr_pool_t *p) +int cstat (NXPathCtx_t ctx, char *path, struct stat *buf, unsigned long requestmap, fspr_pool_t *p) { - apr_pool_t *gPool = (apr_pool_t *)getGlobalPool(); - apr_hash_t *statCache = NULL; - apr_thread_rwlock_t *rwlock = NULL; + fspr_pool_t *gPool = (fspr_pool_t *)getGlobalPool(); + fspr_hash_t *statCache = NULL; + fspr_thread_rwlock_t *rwlock = NULL; NXPathCtx_t pathctx = 0; char *ptr = NULL, *tr; @@ -205,22 +205,22 @@ int cstat (NXPathCtx_t ctx, char *path, struct stat *buf, unsigned long requestm if (!gPool) { char poolname[50]; - if (apr_pool_create(&gPool, NULL) != APR_SUCCESS) { + if (fspr_pool_create(&gPool, NULL) != APR_SUCCESS) { return getstat(ctx, path, buf, requestmap); } setGlobalPool(gPool); - apr_pool_tag(gPool, apr_pstrdup(gPool, "cstat_mem_pool")); + fspr_pool_tag(gPool, fspr_pstrdup(gPool, "cstat_mem_pool")); - statCache = apr_hash_make(gPool); - apr_pool_userdata_set ((void*)statCache, "STAT_CACHE", stat_cache_cleanup, gPool); + statCache = fspr_hash_make(gPool); + fspr_pool_userdata_set ((void*)statCache, "STAT_CACHE", stat_cache_cleanup, gPool); - apr_thread_rwlock_create(&rwlock, gPool); - apr_pool_userdata_set ((void*)rwlock, "STAT_CACHE_LOCK", apr_pool_cleanup_null, gPool); + fspr_thread_rwlock_create(&rwlock, gPool); + fspr_pool_userdata_set ((void*)rwlock, "STAT_CACHE_LOCK", fspr_pool_cleanup_null, gPool); } else { - apr_pool_userdata_get((void**)&statCache, "STAT_CACHE", gPool); - apr_pool_userdata_get((void**)&rwlock, "STAT_CACHE_LOCK", gPool); + fspr_pool_userdata_get((void**)&statCache, "STAT_CACHE", gPool); + fspr_pool_userdata_get((void**)&rwlock, "STAT_CACHE_LOCK", gPool); } if (!gPool || !statCache || !rwlock) { @@ -239,7 +239,7 @@ int cstat (NXPathCtx_t ctx, char *path, struct stat *buf, unsigned long requestm } if (ptr) { - ppath = apr_pstrndup (p, path, len); + ppath = fspr_pstrndup (p, path, len); strlwr(ppath); if (ptr[1] != '\0') { ptr++; @@ -249,19 +249,19 @@ int cstat (NXPathCtx_t ctx, char *path, struct stat *buf, unsigned long requestm slash, we need to make sure we stat the current directory with a dot */ if (((*ptr == '/') || (*ptr == '\\')) && (*(ptr+1) == '\0')) { - pinfo = apr_pstrdup (p, "."); + pinfo = fspr_pstrdup (p, "."); } else { - pinfo = apr_pstrdup (p, ptr); + pinfo = fspr_pstrdup (p, ptr); } } /* If we have a statCache then try to pull the information from the cache. Otherwise just stat the file and return.*/ if (statCache) { - apr_thread_rwlock_rdlock(rwlock); - pathctx = (NXPathCtx_t) apr_hash_get(statCache, ppath, APR_HASH_KEY_STRING); - apr_thread_rwlock_unlock(rwlock); + fspr_thread_rwlock_rdlock(rwlock); + pathctx = (NXPathCtx_t) fspr_hash_get(statCache, ppath, APR_HASH_KEY_STRING); + fspr_thread_rwlock_unlock(rwlock); if (pathctx) { return getstat(pathctx, pinfo, buf, requestmap); } @@ -270,9 +270,9 @@ int cstat (NXPathCtx_t ctx, char *path, struct stat *buf, unsigned long requestm err = NXCreatePathContext(0, ppath, 0, NULL, &pathctx); if (!err) { - apr_thread_rwlock_wrlock(rwlock); - apr_hash_set(statCache, apr_pstrdup(gPool,ppath) , APR_HASH_KEY_STRING, (void*)pathctx); - apr_thread_rwlock_unlock(rwlock); + fspr_thread_rwlock_wrlock(rwlock); + fspr_hash_set(statCache, fspr_pstrdup(gPool,ppath) , APR_HASH_KEY_STRING, (void*)pathctx); + fspr_thread_rwlock_unlock(rwlock); return getstat(pathctx, pinfo, buf, requestmap); } } @@ -282,9 +282,9 @@ int cstat (NXPathCtx_t ctx, char *path, struct stat *buf, unsigned long requestm } #endif -APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, +APR_DECLARE(fspr_status_t) fspr_stat(fspr_finfo_t *finfo, const char *fname, - apr_int32_t wanted, apr_pool_t *pool) + fspr_int32_t wanted, fspr_pool_t *pool) { struct stat info; int srv; @@ -305,7 +305,7 @@ APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, if (wanted & APR_FINFO_LINK) wanted &= ~APR_FINFO_LINK; if (wanted & APR_FINFO_NAME) { - finfo->name = apr_pstrdup(pool, info.st_name); + finfo->name = fspr_pstrdup(pool, info.st_name); finfo->valid |= APR_FINFO_NAME; } return (wanted & ~finfo->valid) ? APR_INCOMPLETE : APR_SUCCESS; @@ -345,14 +345,14 @@ APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, } } -APR_DECLARE(apr_status_t) apr_file_mtime_set(const char *fname, - apr_time_t mtime, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_file_mtime_set(const char *fname, + fspr_time_t mtime, + fspr_pool_t *pool) { - apr_status_t status; - apr_finfo_t finfo; + fspr_status_t status; + fspr_finfo_t finfo; - status = apr_stat(&finfo, fname, APR_FINFO_ATIME, pool); + status = fspr_stat(&finfo, fname, APR_FINFO_ATIME, pool); if (status) { return status; } @@ -361,10 +361,10 @@ APR_DECLARE(apr_status_t) apr_file_mtime_set(const char *fname, { struct timeval tvp[2]; - tvp[0].tv_sec = apr_time_sec(finfo.atime); - tvp[0].tv_usec = apr_time_usec(finfo.atime); - tvp[1].tv_sec = apr_time_sec(mtime); - tvp[1].tv_usec = apr_time_usec(mtime); + tvp[0].tv_sec = fspr_time_sec(finfo.atime); + tvp[0].tv_usec = fspr_time_usec(finfo.atime); + tvp[1].tv_sec = fspr_time_sec(mtime); + tvp[1].tv_usec = fspr_time_usec(mtime); if (utimes(fname, tvp) == -1) { return errno; diff --git a/libs/apr/file_io/netware/filesys.c b/libs/apr/file_io/netware/filesys.c index 05c44cecd5..f366f4644b 100644 --- a/libs/apr/file_io/netware/filesys.c +++ b/libs/apr/file_io/netware/filesys.c @@ -14,21 +14,21 @@ * limitations under the License. */ -#include "apr.h" -#include "apr_arch_file_io.h" -#include "apr_strings.h" +#include "fspr.h" +#include "fspr_arch_file_io.h" +#include "fspr_strings.h" -apr_status_t filepath_root_case(char **rootpath, char *root, apr_pool_t *p) +fspr_status_t filepath_root_case(char **rootpath, char *root, fspr_pool_t *p) { /* See the Windows code to figure out what to do here. It probably checks to make sure that the root exists and case it correctly according to the file system. */ - *rootpath = apr_pstrdup(p, root); + *rootpath = fspr_pstrdup(p, root); return APR_SUCCESS; } -apr_status_t filepath_has_drive(const char *rootpath, int only, apr_pool_t *p) +fspr_status_t filepath_has_drive(const char *rootpath, int only, fspr_pool_t *p) { char *s; @@ -46,7 +46,7 @@ apr_status_t filepath_has_drive(const char *rootpath, int only, apr_pool_t *p) return 0; } -apr_status_t filepath_compare_drive(const char *path1, const char *path2, apr_pool_t *p) +fspr_status_t filepath_compare_drive(const char *path1, const char *path2, fspr_pool_t *p) { char *s1, *s2; @@ -64,8 +64,8 @@ apr_status_t filepath_compare_drive(const char *path1, const char *path2, apr_po return -1; } -APR_DECLARE(apr_status_t) apr_filepath_get(char **rootpath, apr_int32_t flags, - apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_filepath_get(char **rootpath, fspr_int32_t flags, + fspr_pool_t *p) { char path[APR_PATH_MAX]; char *ptr; @@ -85,7 +85,7 @@ APR_DECLARE(apr_status_t) apr_filepath_get(char **rootpath, apr_int32_t flags, if (*ptr == ':') { ptr = path; } - *rootpath = apr_pstrdup(p, ptr); + *rootpath = fspr_pstrdup(p, ptr); if (!(flags & APR_FILEPATH_NATIVE)) { for (ptr = *rootpath; *ptr; ++ptr) { if (*ptr == '\\') @@ -95,8 +95,8 @@ APR_DECLARE(apr_status_t) apr_filepath_get(char **rootpath, apr_int32_t flags, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_filepath_set(const char *rootpath, - apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_filepath_set(const char *rootpath, + fspr_pool_t *p) { if (chdir2(rootpath) != 0) return errno; diff --git a/libs/apr/file_io/netware/flock.c b/libs/apr/file_io/netware/flock.c index c083a0ed40..084d4d9bb7 100644 --- a/libs/apr/file_io/netware/flock.c +++ b/libs/apr/file_io/netware/flock.c @@ -15,10 +15,10 @@ */ #include -#include "apr_arch_file_io.h" +#include "fspr_arch_file_io.h" -apr_status_t apr_file_lock(apr_file_t *thefile, int type) +fspr_status_t fspr_file_lock(fspr_file_t *thefile, int type) { int fc; @@ -30,7 +30,7 @@ apr_status_t apr_file_lock(apr_file_t *thefile, int type) return APR_SUCCESS; } -apr_status_t apr_file_unlock(apr_file_t *thefile) +fspr_status_t fspr_file_unlock(fspr_file_t *thefile) { if(NXFileRangeUnlock(thefile->filedes,NX_RANGE_LOCK_CANCEL,0 , 0) == -1) return errno; diff --git a/libs/apr/file_io/netware/mktemp.c b/libs/apr/file_io/netware/mktemp.c index c5ffebd20d..8ffa947404 100644 --- a/libs/apr/file_io/netware/mktemp.c +++ b/libs/apr/file_io/netware/mktemp.c @@ -14,18 +14,18 @@ * limitations under the License. */ -#include "apr_private.h" -#include "apr_file_io.h" /* prototype of apr_mkstemp() */ -#include "apr_strings.h" /* prototype of apr_mkstemp() */ -#include "apr_arch_file_io.h" /* prototype of apr_mkstemp() */ -#include "apr_portable.h" /* for apr_os_file_put() */ +#include "fspr_private.h" +#include "fspr_file_io.h" /* prototype of fspr_mkstemp() */ +#include "fspr_strings.h" /* prototype of fspr_mkstemp() */ +#include "fspr_arch_file_io.h" /* prototype of fspr_mkstemp() */ +#include "fspr_portable.h" /* for fspr_os_file_put() */ #include /* for mkstemp() - Single Unix */ -APR_DECLARE(apr_status_t) apr_file_mktemp(apr_file_t **fp, char *template, apr_int32_t flags, apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_file_mktemp(fspr_file_t **fp, char *template, fspr_int32_t flags, fspr_pool_t *p) { int fd; - apr_status_t rv; + fspr_status_t rv; flags = (!flags) ? APR_CREATE | APR_READ | APR_WRITE | APR_DELONCLOSE : flags & ~APR_EXCL; @@ -38,11 +38,11 @@ APR_DECLARE(apr_status_t) apr_file_mktemp(apr_file_t **fp, char *template, apr_i * Otherwise file locking will not allow the file to be shared. */ close(fd); - if ((rv = apr_file_open(fp, template, flags|APR_FILE_NOCLEANUP, + if ((rv = fspr_file_open(fp, template, flags|APR_FILE_NOCLEANUP, APR_UREAD | APR_UWRITE, p)) == APR_SUCCESS) { - apr_pool_cleanup_register((*fp)->pool, (void *)(*fp), - apr_unix_file_cleanup, apr_unix_file_cleanup); + fspr_pool_cleanup_register((*fp)->pool, (void *)(*fp), + fspr_unix_file_cleanup, fspr_unix_file_cleanup); } return rv; diff --git a/libs/apr/file_io/netware/pipe.c b/libs/apr/file_io/netware/pipe.c index 4b6b826887..70ed4b8e12 100644 --- a/libs/apr/file_io/netware/pipe.c +++ b/libs/apr/file_io/netware/pipe.c @@ -18,12 +18,12 @@ #include #include -#include "apr_arch_file_io.h" -#include "apr_strings.h" -#include "apr_portable.h" -#include "apr_arch_inherit.h" +#include "fspr_arch_file_io.h" +#include "fspr_strings.h" +#include "fspr_portable.h" +#include "fspr_arch_inherit.h" -static apr_status_t pipeblock(apr_file_t *thepipe) +static fspr_status_t pipeblock(fspr_file_t *thepipe) { #ifdef USE_FLAGS int err; @@ -46,7 +46,7 @@ static apr_status_t pipeblock(apr_file_t *thepipe) return APR_SUCCESS; } -static apr_status_t pipenonblock(apr_file_t *thepipe) +static fspr_status_t pipenonblock(fspr_file_t *thepipe) { #ifdef USE_FLAGS int err; @@ -70,7 +70,7 @@ static apr_status_t pipenonblock(apr_file_t *thepipe) return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_file_pipe_timeout_set(apr_file_t *thepipe, apr_interval_time_t timeout) +APR_DECLARE(fspr_status_t) fspr_file_pipe_timeout_set(fspr_file_t *thepipe, fspr_interval_time_t timeout) { if (thepipe->is_pipe == 1) { thepipe->timeout = timeout; @@ -89,7 +89,7 @@ APR_DECLARE(apr_status_t) apr_file_pipe_timeout_set(apr_file_t *thepipe, apr_int return APR_EINVAL; } -APR_DECLARE(apr_status_t) apr_file_pipe_timeout_get(apr_file_t *thepipe, apr_interval_time_t *timeout) +APR_DECLARE(fspr_status_t) fspr_file_pipe_timeout_get(fspr_file_t *thepipe, fspr_interval_time_t *timeout) { if (thepipe->is_pipe == 1) { *timeout = thepipe->timeout; @@ -98,14 +98,14 @@ APR_DECLARE(apr_status_t) apr_file_pipe_timeout_get(apr_file_t *thepipe, apr_int return APR_EINVAL; } -APR_DECLARE(apr_status_t) apr_os_pipe_put_ex(apr_file_t **file, - apr_os_file_t *thefile, +APR_DECLARE(fspr_status_t) fspr_os_pipe_put_ex(fspr_file_t **file, + fspr_os_file_t *thefile, int register_cleanup, - apr_pool_t *pool) + fspr_pool_t *pool) { int *dafile = thefile; - (*file) = apr_pcalloc(pool, sizeof(apr_file_t)); + (*file) = fspr_pcalloc(pool, sizeof(fspr_file_t)); (*file)->pool = pool; (*file)->eof_hit = 0; (*file)->is_pipe = 1; @@ -121,21 +121,21 @@ APR_DECLARE(apr_status_t) apr_os_pipe_put_ex(apr_file_t **file, (*file)->thlock = NULL; #endif if (register_cleanup) { - apr_pool_cleanup_register((*file)->pool, (void *)(*file), - apr_unix_file_cleanup, - apr_pool_cleanup_null); + fspr_pool_cleanup_register((*file)->pool, (void *)(*file), + fspr_unix_file_cleanup, + fspr_pool_cleanup_null); } return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_os_pipe_put(apr_file_t **file, - apr_os_file_t *thefile, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_os_pipe_put(fspr_file_t **file, + fspr_os_file_t *thefile, + fspr_pool_t *pool) { - return apr_os_pipe_put_ex(file, thefile, 0, pool); + return fspr_os_pipe_put_ex(file, thefile, 0, pool); } -APR_DECLARE(apr_status_t) apr_file_pipe_create(apr_file_t **in, apr_file_t **out, apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_file_pipe_create(fspr_file_t **in, fspr_file_t **out, fspr_pool_t *pool) { int filedes[2]; int err; @@ -144,8 +144,8 @@ APR_DECLARE(apr_status_t) apr_file_pipe_create(apr_file_t **in, apr_file_t **out return errno; } - (*in) = (apr_file_t *)apr_pcalloc(pool, sizeof(apr_file_t)); - (*out) = (apr_file_t *)apr_pcalloc(pool, sizeof(apr_file_t)); + (*in) = (fspr_file_t *)fspr_pcalloc(pool, sizeof(fspr_file_t)); + (*out) = (fspr_file_t *)fspr_pcalloc(pool, sizeof(fspr_file_t)); (*in)->pool = (*out)->pool = pool; @@ -166,19 +166,19 @@ APR_DECLARE(apr_status_t) apr_file_pipe_create(apr_file_t **in, apr_file_t **out (*in)->ungetchar = -1; (*in)->thlock = (*out)->thlock = NULL; - (void) apr_pollset_create(&(*in)->pollset, 1, pool, 0); - (void) apr_pollset_create(&(*out)->pollset, 1, pool, 0); + (void) fspr_pollset_create(&(*in)->pollset, 1, pool, 0); + (void) fspr_pollset_create(&(*out)->pollset, 1, pool, 0); - apr_pool_cleanup_register((*in)->pool, (void *)(*in), apr_unix_file_cleanup, - apr_pool_cleanup_null); - apr_pool_cleanup_register((*out)->pool, (void *)(*out), apr_unix_file_cleanup, - apr_pool_cleanup_null); + fspr_pool_cleanup_register((*in)->pool, (void *)(*in), fspr_unix_file_cleanup, + fspr_pool_cleanup_null); + fspr_pool_cleanup_register((*out)->pool, (void *)(*out), fspr_unix_file_cleanup, + fspr_pool_cleanup_null); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_file_namedpipe_create(const char *filename, - apr_fileperms_t perm, apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_file_namedpipe_create(const char *filename, + fspr_fileperms_t perm, fspr_pool_t *pool) { return APR_ENOTIMPL; } diff --git a/libs/apr/file_io/os2/dir.c b/libs/apr/file_io/os2/dir.c index 3b08355f56..f237d21514 100644 --- a/libs/apr/file_io/os2/dir.c +++ b/libs/apr/file_io/os2/dir.c @@ -14,30 +14,30 @@ * limitations under the License. */ -#include "apr_arch_file_io.h" -#include "apr_file_io.h" -#include "apr_lib.h" -#include "apr_strings.h" -#include "apr_portable.h" +#include "fspr_arch_file_io.h" +#include "fspr_file_io.h" +#include "fspr_lib.h" +#include "fspr_strings.h" +#include "fspr_portable.h" #include -static apr_status_t dir_cleanup(void *thedir) +static fspr_status_t dir_cleanup(void *thedir) { - apr_dir_t *dir = thedir; - return apr_dir_close(dir); + fspr_dir_t *dir = thedir; + return fspr_dir_close(dir); } -APR_DECLARE(apr_status_t) apr_dir_open(apr_dir_t **new, const char *dirname, apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_dir_open(fspr_dir_t **new, const char *dirname, fspr_pool_t *pool) { - apr_dir_t *thedir = (apr_dir_t *)apr_palloc(pool, sizeof(apr_dir_t)); + fspr_dir_t *thedir = (fspr_dir_t *)fspr_palloc(pool, sizeof(fspr_dir_t)); if (thedir == NULL) return APR_ENOMEM; thedir->pool = pool; - thedir->dirname = apr_pstrdup(pool, dirname); + thedir->dirname = fspr_pstrdup(pool, dirname); if (thedir->dirname == NULL) return APR_ENOMEM; @@ -45,13 +45,13 @@ APR_DECLARE(apr_status_t) apr_dir_open(apr_dir_t **new, const char *dirname, apr thedir->handle = 0; thedir->validentry = FALSE; *new = thedir; - apr_pool_cleanup_register(pool, thedir, dir_cleanup, apr_pool_cleanup_null); + fspr_pool_cleanup_register(pool, thedir, dir_cleanup, fspr_pool_cleanup_null); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_dir_close(apr_dir_t *thedir) +APR_DECLARE(fspr_status_t) fspr_dir_close(fspr_dir_t *thedir) { int rv = 0; @@ -68,15 +68,15 @@ APR_DECLARE(apr_status_t) apr_dir_close(apr_dir_t *thedir) -APR_DECLARE(apr_status_t) apr_dir_read(apr_finfo_t *finfo, apr_int32_t wanted, - apr_dir_t *thedir) +APR_DECLARE(fspr_status_t) fspr_dir_read(fspr_finfo_t *finfo, fspr_int32_t wanted, + fspr_dir_t *thedir) { int rv; ULONG entries = 1; if (thedir->handle == 0) { thedir->handle = HDIR_CREATE; - rv = DosFindFirst(apr_pstrcat(thedir->pool, thedir->dirname, "/*", NULL), &thedir->handle, + rv = DosFindFirst(fspr_pstrcat(thedir->pool, thedir->dirname, "/*", NULL), &thedir->handle, FILE_ARCHIVED|FILE_DIRECTORY|FILE_SYSTEM|FILE_HIDDEN|FILE_READONLY, &thedir->entry, sizeof(thedir->entry), &entries, FIL_STANDARD); } else { @@ -98,11 +98,11 @@ APR_DECLARE(apr_status_t) apr_dir_read(apr_finfo_t *finfo, apr_int32_t wanted, /* Only directories & regular files show up in directory listings */ finfo->filetype = (thedir->entry.attrFile & FILE_DIRECTORY) ? APR_DIR : APR_REG; - apr_os2_time_to_apr_time(&finfo->mtime, thedir->entry.fdateLastWrite, + fspr_os2_time_to_fspr_time(&finfo->mtime, thedir->entry.fdateLastWrite, thedir->entry.ftimeLastWrite); - apr_os2_time_to_apr_time(&finfo->atime, thedir->entry.fdateLastAccess, + fspr_os2_time_to_fspr_time(&finfo->atime, thedir->entry.fdateLastAccess, thedir->entry.ftimeLastAccess); - apr_os2_time_to_apr_time(&finfo->ctime, thedir->entry.fdateCreation, + fspr_os2_time_to_fspr_time(&finfo->ctime, thedir->entry.fdateCreation, thedir->entry.ftimeCreation); finfo->name = thedir->entry.achName; @@ -123,28 +123,28 @@ APR_DECLARE(apr_status_t) apr_dir_read(apr_finfo_t *finfo, apr_int32_t wanted, -APR_DECLARE(apr_status_t) apr_dir_rewind(apr_dir_t *thedir) +APR_DECLARE(fspr_status_t) fspr_dir_rewind(fspr_dir_t *thedir) { - return apr_dir_close(thedir); + return fspr_dir_close(thedir); } -APR_DECLARE(apr_status_t) apr_dir_make(const char *path, apr_fileperms_t perm, apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_dir_make(const char *path, fspr_fileperms_t perm, fspr_pool_t *pool) { return APR_FROM_OS_ERROR(DosCreateDir(path, NULL)); } -APR_DECLARE(apr_status_t) apr_dir_remove(const char *path, apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_dir_remove(const char *path, fspr_pool_t *pool) { return APR_FROM_OS_ERROR(DosDeleteDir(path)); } -APR_DECLARE(apr_status_t) apr_os_dir_get(apr_os_dir_t **thedir, apr_dir_t *dir) +APR_DECLARE(fspr_status_t) fspr_os_dir_get(fspr_os_dir_t **thedir, fspr_dir_t *dir) { if (dir == NULL) { return APR_ENODIR; @@ -155,11 +155,11 @@ APR_DECLARE(apr_status_t) apr_os_dir_get(apr_os_dir_t **thedir, apr_dir_t *dir) -APR_DECLARE(apr_status_t) apr_os_dir_put(apr_dir_t **dir, apr_os_dir_t *thedir, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_os_dir_put(fspr_dir_t **dir, fspr_os_dir_t *thedir, + fspr_pool_t *pool) { if ((*dir) == NULL) { - (*dir) = (apr_dir_t *)apr_pcalloc(pool, sizeof(apr_dir_t)); + (*dir) = (fspr_dir_t *)fspr_pcalloc(pool, sizeof(fspr_dir_t)); (*dir)->pool = pool; } (*dir)->handle = *thedir; diff --git a/libs/apr/file_io/os2/dir_make_recurse.c b/libs/apr/file_io/os2/dir_make_recurse.c index 1f645b7dda..fde99ace7a 100644 --- a/libs/apr/file_io/os2/dir_make_recurse.c +++ b/libs/apr/file_io/os2/dir_make_recurse.c @@ -14,27 +14,27 @@ * limitations under the License. */ -#include "apr_file_io.h" -#include "apr_lib.h" -#include "apr_strings.h" +#include "fspr_file_io.h" +#include "fspr_lib.h" +#include "fspr_strings.h" #include #define IS_SEP(c) (c == '/' || c == '\\') /* Remove trailing separators that don't affect the meaning of PATH. */ -static const char *path_canonicalize(const char *path, apr_pool_t *pool) +static const char *path_canonicalize(const char *path, fspr_pool_t *pool) { /* At some point this could eliminate redundant components. For * now, it just makes sure there is no trailing slash. */ - apr_size_t len = strlen(path); - apr_size_t orig_len = len; + fspr_size_t len = strlen(path); + fspr_size_t orig_len = len; while ((len > 0) && IS_SEP(path[len - 1])) { len--; } if (len != orig_len) { - return apr_pstrndup(pool, path, len); + return fspr_pstrndup(pool, path, len); } else { return path; @@ -44,7 +44,7 @@ static const char *path_canonicalize(const char *path, apr_pool_t *pool) /* Remove one component off the end of PATH. */ -static char *path_remove_last_component(const char *path, apr_pool_t *pool) +static char *path_remove_last_component(const char *path, fspr_pool_t *pool) { const char *newpath = path_canonicalize(path, pool); int i; @@ -55,32 +55,32 @@ static char *path_remove_last_component(const char *path, apr_pool_t *pool) } } - return apr_pstrndup(pool, path, (i < 0) ? 0 : i); + return fspr_pstrndup(pool, path, (i < 0) ? 0 : i); } -apr_status_t apr_dir_make_recursive(const char *path, apr_fileperms_t perm, - apr_pool_t *pool) +fspr_status_t fspr_dir_make_recursive(const char *path, fspr_fileperms_t perm, + fspr_pool_t *pool) { - apr_status_t apr_err = APR_SUCCESS; + fspr_status_t fspr_err = APR_SUCCESS; - apr_err = apr_dir_make(path, perm, pool); /* Try to make PATH right out */ + fspr_err = fspr_dir_make(path, perm, pool); /* Try to make PATH right out */ - if (APR_STATUS_IS_EEXIST(apr_err)) { /* It's OK if PATH exists */ + if (APR_STATUS_IS_EEXIST(fspr_err)) { /* It's OK if PATH exists */ return APR_SUCCESS; } - if (APR_STATUS_IS_ENOENT(apr_err)) { /* Missing an intermediate dir */ + if (APR_STATUS_IS_ENOENT(fspr_err)) { /* Missing an intermediate dir */ char *dir; dir = path_remove_last_component(path, pool); - apr_err = apr_dir_make_recursive(dir, perm, pool); + fspr_err = fspr_dir_make_recursive(dir, perm, pool); - if (!apr_err) { - apr_err = apr_dir_make(path, perm, pool); + if (!fspr_err) { + fspr_err = fspr_dir_make(path, perm, pool); } } - return apr_err; + return fspr_err; } diff --git a/libs/apr/file_io/os2/filedup.c b/libs/apr/file_io/os2/filedup.c index 72b86e2faa..c19ade0e6e 100644 --- a/libs/apr/file_io/os2/filedup.c +++ b/libs/apr/file_io/os2/filedup.c @@ -14,20 +14,20 @@ * limitations under the License. */ -#include "apr_arch_file_io.h" -#include "apr_file_io.h" -#include "apr_lib.h" -#include "apr_strings.h" +#include "fspr_arch_file_io.h" +#include "fspr_file_io.h" +#include "fspr_lib.h" +#include "fspr_strings.h" #include -#include "apr_arch_inherit.h" +#include "fspr_arch_inherit.h" -static apr_status_t file_dup(apr_file_t **new_file, apr_file_t *old_file, apr_pool_t *p) +static fspr_status_t file_dup(fspr_file_t **new_file, fspr_file_t *old_file, fspr_pool_t *p) { int rv; - apr_file_t *dup_file; + fspr_file_t *dup_file; if (*new_file == NULL) { - dup_file = (apr_file_t *)apr_palloc(p, sizeof(apr_file_t)); + dup_file = (fspr_file_t *)fspr_palloc(p, sizeof(fspr_file_t)); if (dup_file == NULL) { return APR_ENOMEM; @@ -45,7 +45,7 @@ static apr_status_t file_dup(apr_file_t **new_file, apr_file_t *old_file, apr_po return APR_FROM_OS_ERROR(rv); } - dup_file->fname = apr_pstrdup(dup_file->pool, old_file->fname); + dup_file->fname = fspr_pstrdup(dup_file->pool, old_file->fname); dup_file->buffered = old_file->buffered; dup_file->isopen = old_file->isopen; dup_file->flags = old_file->flags & ~APR_INHERIT; @@ -53,8 +53,8 @@ static apr_status_t file_dup(apr_file_t **new_file, apr_file_t *old_file, apr_po dup_file->pipe = old_file->pipe; if (*new_file == NULL) { - apr_pool_cleanup_register(dup_file->pool, dup_file, apr_file_cleanup, - apr_pool_cleanup_null); + fspr_pool_cleanup_register(dup_file->pool, dup_file, fspr_file_cleanup, + fspr_pool_cleanup_null); *new_file = dup_file; } @@ -63,10 +63,10 @@ static apr_status_t file_dup(apr_file_t **new_file, apr_file_t *old_file, apr_po -APR_DECLARE(apr_status_t) apr_file_dup(apr_file_t **new_file, apr_file_t *old_file, apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_file_dup(fspr_file_t **new_file, fspr_file_t *old_file, fspr_pool_t *p) { if (*new_file) { - apr_file_close(*new_file); + fspr_file_close(*new_file); (*new_file)->filedes = -1; } @@ -75,23 +75,23 @@ APR_DECLARE(apr_status_t) apr_file_dup(apr_file_t **new_file, apr_file_t *old_fi -APR_DECLARE(apr_status_t) apr_file_dup2(apr_file_t *new_file, apr_file_t *old_file, apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_file_dup2(fspr_file_t *new_file, fspr_file_t *old_file, fspr_pool_t *p) { return file_dup(&new_file, old_file, p); } -APR_DECLARE(apr_status_t) apr_file_setaside(apr_file_t **new_file, - apr_file_t *old_file, - apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_file_setaside(fspr_file_t **new_file, + fspr_file_t *old_file, + fspr_pool_t *p) { - *new_file = (apr_file_t *)apr_palloc(p, sizeof(apr_file_t)); - memcpy(*new_file, old_file, sizeof(apr_file_t)); + *new_file = (fspr_file_t *)fspr_palloc(p, sizeof(fspr_file_t)); + memcpy(*new_file, old_file, sizeof(fspr_file_t)); (*new_file)->pool = p; if (old_file->buffered) { - (*new_file)->buffer = apr_palloc(p, APR_FILE_BUFSIZE); + (*new_file)->buffer = fspr_palloc(p, APR_FILE_BUFSIZE); if (old_file->direction == 1) { memcpy((*new_file)->buffer, old_file->buffer, old_file->bufpos); @@ -101,25 +101,25 @@ APR_DECLARE(apr_status_t) apr_file_setaside(apr_file_t **new_file, } if (old_file->mutex) { - apr_thread_mutex_create(&((*new_file)->mutex), + fspr_thread_mutex_create(&((*new_file)->mutex), APR_THREAD_MUTEX_DEFAULT, p); - apr_thread_mutex_destroy(old_file->mutex); + fspr_thread_mutex_destroy(old_file->mutex); } } if (old_file->fname) { - (*new_file)->fname = apr_pstrdup(p, old_file->fname); + (*new_file)->fname = fspr_pstrdup(p, old_file->fname); } if (!(old_file->flags & APR_FILE_NOCLEANUP)) { - apr_pool_cleanup_register(p, (void *)(*new_file), - apr_file_cleanup, - apr_file_cleanup); + fspr_pool_cleanup_register(p, (void *)(*new_file), + fspr_file_cleanup, + fspr_file_cleanup); } old_file->filedes = -1; - apr_pool_cleanup_kill(old_file->pool, (void *)old_file, - apr_file_cleanup); + fspr_pool_cleanup_kill(old_file->pool, (void *)old_file, + fspr_file_cleanup); return APR_SUCCESS; } diff --git a/libs/apr/file_io/os2/filestat.c b/libs/apr/file_io/os2/filestat.c index f31c7c1b50..dd9b0f8e78 100644 --- a/libs/apr/file_io/os2/filestat.c +++ b/libs/apr/file_io/os2/filestat.c @@ -16,14 +16,14 @@ #define INCL_DOS #define INCL_DOSERRORS -#include "apr_arch_file_io.h" -#include "apr_file_io.h" -#include "apr_lib.h" +#include "fspr_arch_file_io.h" +#include "fspr_file_io.h" +#include "fspr_lib.h" #include -#include "apr_strings.h" +#include "fspr_strings.h" -static void FS3_to_finfo(apr_finfo_t *finfo, FILESTATUS3 *fstatus) +static void FS3_to_finfo(fspr_finfo_t *finfo, FILESTATUS3 *fstatus) { finfo->protection = (fstatus->attrFile & FILE_READONLY) ? 0x555 : 0x777; @@ -39,11 +39,11 @@ static void FS3_to_finfo(apr_finfo_t *finfo, FILESTATUS3 *fstatus) finfo->device = 0; finfo->size = fstatus->cbFile; finfo->csize = fstatus->cbFileAlloc; - apr_os2_time_to_apr_time(&finfo->atime, fstatus->fdateLastAccess, + fspr_os2_time_to_fspr_time(&finfo->atime, fstatus->fdateLastAccess, fstatus->ftimeLastAccess ); - apr_os2_time_to_apr_time(&finfo->mtime, fstatus->fdateLastWrite, + fspr_os2_time_to_fspr_time(&finfo->mtime, fstatus->fdateLastWrite, fstatus->ftimeLastWrite ); - apr_os2_time_to_apr_time(&finfo->ctime, fstatus->fdateCreation, + fspr_os2_time_to_fspr_time(&finfo->ctime, fstatus->fdateCreation, fstatus->ftimeCreation ); finfo->valid = APR_FINFO_TYPE | APR_FINFO_PROT | APR_FINFO_SIZE | APR_FINFO_CSIZE | APR_FINFO_MTIME @@ -52,7 +52,7 @@ static void FS3_to_finfo(apr_finfo_t *finfo, FILESTATUS3 *fstatus) -static apr_status_t handle_type(apr_filetype_e *ftype, HFILE file) +static fspr_status_t handle_type(fspr_filetype_e *ftype, HFILE file) { ULONG filetype, fileattr, rc; @@ -86,15 +86,15 @@ static apr_status_t handle_type(apr_filetype_e *ftype, HFILE file) -APR_DECLARE(apr_status_t) apr_file_info_get(apr_finfo_t *finfo, apr_int32_t wanted, - apr_file_t *thefile) +APR_DECLARE(fspr_status_t) fspr_file_info_get(fspr_finfo_t *finfo, fspr_int32_t wanted, + fspr_file_t *thefile) { ULONG rc; FILESTATUS3 fstatus; if (thefile->isopen) { if (thefile->buffered) { - apr_status_t rv = apr_file_flush(thefile); + fspr_status_t rv = fspr_file_flush(thefile); if (rv != APR_SUCCESS) { return rv; @@ -124,14 +124,14 @@ APR_DECLARE(apr_status_t) apr_file_info_get(apr_finfo_t *finfo, apr_int32_t want return APR_FROM_OS_ERROR(rc); } -APR_DECLARE(apr_status_t) apr_file_perms_set(const char *fname, apr_fileperms_t perms) +APR_DECLARE(fspr_status_t) fspr_file_perms_set(const char *fname, fspr_fileperms_t perms) { return APR_ENOTIMPL; } -APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, const char *fname, - apr_int32_t wanted, apr_pool_t *cont) +APR_DECLARE(fspr_status_t) fspr_stat(fspr_finfo_t *finfo, const char *fname, + fspr_int32_t wanted, fspr_pool_t *cont) { ULONG rc; FILESTATUS3 fstatus; @@ -153,18 +153,18 @@ APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, const char *fname, FILE_DIRECTORY|FILE_HIDDEN|FILE_SYSTEM|FILE_ARCHIVED, &ffb, sizeof(ffb), &count, FIL_STANDARD); if (rc == 0 && count == 1) { - finfo->name = apr_pstrdup(cont, ffb.achName); + finfo->name = fspr_pstrdup(cont, ffb.achName); finfo->valid |= APR_FINFO_NAME; } } } else if (rc == ERROR_INVALID_ACCESS) { - memset(finfo, 0, sizeof(apr_finfo_t)); + memset(finfo, 0, sizeof(fspr_finfo_t)); finfo->valid = APR_FINFO_TYPE | APR_FINFO_PROT; finfo->protection = 0666; finfo->filetype = APR_CHR; if (wanted & APR_FINFO_NAME) { - finfo->name = apr_pstrdup(cont, fname); + finfo->name = fspr_pstrdup(cont, fname); finfo->valid |= APR_FINFO_NAME; } } else { @@ -176,10 +176,10 @@ APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, const char *fname, -APR_DECLARE(apr_status_t) apr_file_attrs_set(const char *fname, - apr_fileattrs_t attributes, - apr_fileattrs_t attr_mask, - apr_pool_t *cont) +APR_DECLARE(fspr_status_t) fspr_file_attrs_set(const char *fname, + fspr_fileattrs_t attributes, + fspr_fileattrs_t attr_mask, + fspr_pool_t *cont) { FILESTATUS3 fs3; ULONG rc; @@ -221,9 +221,9 @@ APR_DECLARE(apr_status_t) apr_file_attrs_set(const char *fname, /* ### Somebody please write this! */ -APR_DECLARE(apr_status_t) apr_file_mtime_set(const char *fname, - apr_time_t mtime, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_file_mtime_set(const char *fname, + fspr_time_t mtime, + fspr_pool_t *pool) { FILESTATUS3 fs3; ULONG rc; @@ -233,7 +233,7 @@ APR_DECLARE(apr_status_t) apr_file_mtime_set(const char *fname, return APR_FROM_OS_ERROR(rc); } - apr_apr_time_to_os2_time(&fs3.fdateLastWrite, &fs3.ftimeLastWrite, mtime); + fspr_fspr_time_to_os2_time(&fs3.fdateLastWrite, &fs3.ftimeLastWrite, mtime); rc = DosSetPathInfo(fname, FIL_STANDARD, &fs3, sizeof(fs3), 0); return APR_FROM_OS_ERROR(rc); diff --git a/libs/apr/file_io/os2/filesys.c b/libs/apr/file_io/os2/filesys.c index ae43bc0a0f..c2fbb9d219 100644 --- a/libs/apr/file_io/os2/filesys.c +++ b/libs/apr/file_io/os2/filesys.c @@ -14,10 +14,10 @@ * limitations under the License. */ -#include "apr.h" -#include "apr_arch_file_io.h" -#include "apr_strings.h" -#include "apr_lib.h" +#include "fspr.h" +#include "fspr_arch_file_io.h" +#include "fspr_strings.h" +#include "fspr_lib.h" #include /* OS/2 Exceptions: @@ -52,9 +52,9 @@ const char c_is_fnchar[256] = #define IS_SLASH(c) (c == '/' || c == '\\') -apr_status_t filepath_root_test(char *path, apr_pool_t *p) +fspr_status_t filepath_root_test(char *path, fspr_pool_t *p) { - char drive = apr_toupper(path[0]); + char drive = fspr_toupper(path[0]); if (drive >= 'A' && drive <= 'Z' && path[1] == ':' && IS_SLASH(path[2])) return APR_SUCCESS; @@ -63,8 +63,8 @@ apr_status_t filepath_root_test(char *path, apr_pool_t *p) } -apr_status_t filepath_drive_get(char **rootpath, char drive, - apr_int32_t flags, apr_pool_t *p) +fspr_status_t filepath_drive_get(char **rootpath, char drive, + fspr_int32_t flags, fspr_pool_t *p) { char path[APR_PATH_MAX]; char *pos; @@ -75,7 +75,7 @@ apr_status_t filepath_drive_get(char **rootpath, char drive, path[1] = ':'; path[2] = '/'; - rc = DosQueryCurrentDir(apr_toupper(drive) - 'A', path+3, &bufsize); + rc = DosQueryCurrentDir(fspr_toupper(drive) - 'A', path+3, &bufsize); if (rc) { return APR_FROM_OS_ERROR(rc); @@ -88,16 +88,16 @@ apr_status_t filepath_drive_get(char **rootpath, char drive, } } - *rootpath = apr_pstrdup(p, path); + *rootpath = fspr_pstrdup(p, path); return APR_SUCCESS; } -apr_status_t filepath_root_case(char **rootpath, char *root, apr_pool_t *p) +fspr_status_t filepath_root_case(char **rootpath, char *root, fspr_pool_t *p) { - if (root[0] && apr_islower(root[0]) && root[1] == ':') { - *rootpath = apr_pstrdup(p, root); - (*rootpath)[0] = apr_toupper((*rootpath)[0]); + if (root[0] && fspr_islower(root[0]) && root[1] == ':') { + *rootpath = fspr_pstrdup(p, root); + (*rootpath)[0] = fspr_toupper((*rootpath)[0]); } else { *rootpath = root; @@ -106,8 +106,8 @@ apr_status_t filepath_root_case(char **rootpath, char *root, apr_pool_t *p) } -APR_DECLARE(apr_status_t) apr_filepath_get(char **defpath, apr_int32_t flags, - apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_filepath_get(char **defpath, fspr_int32_t flags, + fspr_pool_t *p) { char path[APR_PATH_MAX]; ULONG drive; @@ -120,7 +120,7 @@ APR_DECLARE(apr_status_t) apr_filepath_get(char **defpath, apr_int32_t flags, strcpy(path+1, ":\\"); rv = DosQueryCurrentDir(drive, path+3, &pathlen); - *defpath = apr_pstrdup(p, path); + *defpath = fspr_pstrdup(p, path); if (!(flags & APR_FILEPATH_NATIVE)) { for (pos=*defpath; *pos; pos++) { @@ -134,12 +134,12 @@ APR_DECLARE(apr_status_t) apr_filepath_get(char **defpath, apr_int32_t flags, -APR_DECLARE(apr_status_t) apr_filepath_set(const char *path, apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_filepath_set(const char *path, fspr_pool_t *p) { ULONG rv = 0; if (path[1] == ':') - rv = DosSetDefaultDisk(apr_toupper(path[0]) - '@'); + rv = DosSetDefaultDisk(fspr_toupper(path[0]) - '@'); if (rv == 0) rv = DosSetCurrentDir(path); diff --git a/libs/apr/file_io/os2/flock.c b/libs/apr/file_io/os2/flock.c index ec94022081..6499589825 100644 --- a/libs/apr/file_io/os2/flock.c +++ b/libs/apr/file_io/os2/flock.c @@ -14,9 +14,9 @@ * limitations under the License. */ -#include "apr_arch_file_io.h" +#include "fspr_arch_file_io.h" -APR_DECLARE(apr_status_t) apr_file_lock(apr_file_t *thefile, int type) +APR_DECLARE(fspr_status_t) fspr_file_lock(fspr_file_t *thefile, int type) { FILELOCK lockrange = { 0, 0x7fffffff }; ULONG rc; @@ -27,7 +27,7 @@ APR_DECLARE(apr_status_t) apr_file_lock(apr_file_t *thefile, int type) return APR_FROM_OS_ERROR(rc); } -APR_DECLARE(apr_status_t) apr_file_unlock(apr_file_t *thefile) +APR_DECLARE(fspr_status_t) fspr_file_unlock(fspr_file_t *thefile) { FILELOCK unlockrange = { 0, 0x7fffffff }; ULONG rc; diff --git a/libs/apr/file_io/os2/maperrorcode.c b/libs/apr/file_io/os2/maperrorcode.c index 282338bba0..2982eea0a6 100644 --- a/libs/apr/file_io/os2/maperrorcode.c +++ b/libs/apr/file_io/os2/maperrorcode.c @@ -15,11 +15,11 @@ */ #define INCL_DOSERRORS -#include "apr_arch_file_io.h" -#include "apr_file_io.h" +#include "fspr_arch_file_io.h" +#include "fspr_file_io.h" #include #include -#include "apr_errno.h" +#include "fspr_errno.h" static int errormap[][2] = { { NO_ERROR, APR_SUCCESS }, @@ -75,7 +75,7 @@ static int errormap[][2] = { #define MAPSIZE (sizeof(errormap)/sizeof(errormap[0])) -int apr_canonical_error(apr_status_t err) +int fspr_canonical_error(fspr_status_t err) { int rv = -1, index; @@ -89,7 +89,7 @@ int apr_canonical_error(apr_status_t err) if (index -apr_status_t apr_file_cleanup(void *thefile) +fspr_status_t fspr_file_cleanup(void *thefile) { - apr_file_t *file = thefile; - return apr_file_close(file); + fspr_file_t *file = thefile; + return fspr_file_close(file); } -APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new, const char *fname, apr_int32_t flag, apr_fileperms_t perm, apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_file_open(fspr_file_t **new, const char *fname, fspr_int32_t flag, fspr_fileperms_t perm, fspr_pool_t *pool) { int oflags = 0; int mflags = OPEN_FLAGS_FAIL_ON_ERROR|OPEN_SHARE_DENYNONE; int rv; ULONG action; - apr_file_t *dafile = (apr_file_t *)apr_palloc(pool, sizeof(apr_file_t)); + fspr_file_t *dafile = (fspr_file_t *)fspr_palloc(pool, sizeof(fspr_file_t)); dafile->pool = pool; dafile->isopen = FALSE; @@ -59,8 +59,8 @@ APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new, const char *fname, apr dafile->buffered = (flag & APR_BUFFERED) > 0; if (dafile->buffered) { - dafile->buffer = apr_palloc(pool, APR_FILE_BUFSIZE); - rv = apr_thread_mutex_create(&dafile->mutex, 0, pool); + dafile->buffer = fspr_palloc(pool, APR_FILE_BUFSIZE); + rv = fspr_thread_mutex_create(&dafile->mutex, 0, pool); if (rv) return rv; @@ -97,7 +97,7 @@ APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new, const char *fname, apr return APR_FROM_OS_ERROR(rv); dafile->isopen = TRUE; - dafile->fname = apr_pstrdup(pool, fname); + dafile->fname = fspr_pstrdup(pool, fname); dafile->filePtr = 0; dafile->bufpos = 0; dafile->dataRead = 0; @@ -105,7 +105,7 @@ APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new, const char *fname, apr dafile->pipe = FALSE; if (!(flag & APR_FILE_NOCLEANUP)) { - apr_pool_cleanup_register(dafile->pool, dafile, apr_file_cleanup, apr_file_cleanup); + fspr_pool_cleanup_register(dafile->pool, dafile, fspr_file_cleanup, fspr_file_cleanup); } *new = dafile; @@ -114,13 +114,13 @@ APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new, const char *fname, apr -APR_DECLARE(apr_status_t) apr_file_close(apr_file_t *file) +APR_DECLARE(fspr_status_t) fspr_file_close(fspr_file_t *file) { ULONG rc; - apr_status_t status; + fspr_status_t status; if (file && file->isopen) { - apr_file_flush(file); + fspr_file_flush(file); rc = DosClose(file->filedes); if (rc == 0) { @@ -136,14 +136,14 @@ APR_DECLARE(apr_status_t) apr_file_close(apr_file_t *file) } if (file->buffered) - apr_thread_mutex_destroy(file->mutex); + fspr_thread_mutex_destroy(file->mutex); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_file_remove(const char *path, apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_file_remove(const char *path, fspr_pool_t *pool) { ULONG rc = DosDelete(path); return APR_FROM_OS_ERROR(rc); @@ -151,8 +151,8 @@ APR_DECLARE(apr_status_t) apr_file_remove(const char *path, apr_pool_t *pool) -APR_DECLARE(apr_status_t) apr_file_rename(const char *from_path, const char *to_path, - apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_file_rename(const char *from_path, const char *to_path, + fspr_pool_t *p) { ULONG rc = DosMove(from_path, to_path); @@ -169,7 +169,7 @@ APR_DECLARE(apr_status_t) apr_file_rename(const char *from_path, const char *to_ -APR_DECLARE(apr_status_t) apr_os_file_get(apr_os_file_t *thefile, apr_file_t *file) +APR_DECLARE(fspr_status_t) fspr_os_file_get(fspr_os_file_t *thefile, fspr_file_t *file) { *thefile = file->filedes; return APR_SUCCESS; @@ -177,11 +177,11 @@ APR_DECLARE(apr_status_t) apr_os_file_get(apr_os_file_t *thefile, apr_file_t *fi -APR_DECLARE(apr_status_t) apr_os_file_put(apr_file_t **file, apr_os_file_t *thefile, apr_int32_t flags, apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_os_file_put(fspr_file_t **file, fspr_os_file_t *thefile, fspr_int32_t flags, fspr_pool_t *pool) { - apr_os_file_t *dafile = thefile; + fspr_os_file_t *dafile = thefile; - (*file) = apr_palloc(pool, sizeof(apr_file_t)); + (*file) = fspr_palloc(pool, sizeof(fspr_file_t)); (*file)->pool = pool; (*file)->filedes = *dafile; (*file)->isopen = TRUE; @@ -191,10 +191,10 @@ APR_DECLARE(apr_status_t) apr_os_file_put(apr_file_t **file, apr_os_file_t *thef (*file)->buffered = (flags & APR_BUFFERED) > 0; if ((*file)->buffered) { - apr_status_t rv; + fspr_status_t rv; - (*file)->buffer = apr_palloc(pool, APR_FILE_BUFSIZE); - rv = apr_thread_mutex_create(&(*file)->mutex, 0, pool); + (*file)->buffer = fspr_palloc(pool, APR_FILE_BUFSIZE); + rv = fspr_thread_mutex_create(&(*file)->mutex, 0, pool); if (rv) return rv; @@ -204,7 +204,7 @@ APR_DECLARE(apr_status_t) apr_os_file_put(apr_file_t **file, apr_os_file_t *thef } -APR_DECLARE(apr_status_t) apr_file_eof(apr_file_t *fptr) +APR_DECLARE(fspr_status_t) fspr_file_eof(fspr_file_t *fptr) { if (!fptr->isopen || fptr->eof_hit == 1) { return APR_EOF; @@ -213,33 +213,33 @@ APR_DECLARE(apr_status_t) apr_file_eof(apr_file_t *fptr) } -APR_DECLARE(apr_status_t) apr_file_open_stderr(apr_file_t **thefile, apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_file_open_stderr(fspr_file_t **thefile, fspr_pool_t *pool) { - apr_os_file_t fd = 2; + fspr_os_file_t fd = 2; - return apr_os_file_put(thefile, &fd, 0, pool); + return fspr_os_file_put(thefile, &fd, 0, pool); } -APR_DECLARE(apr_status_t) apr_file_open_stdout(apr_file_t **thefile, apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_file_open_stdout(fspr_file_t **thefile, fspr_pool_t *pool) { - apr_os_file_t fd = 1; + fspr_os_file_t fd = 1; - return apr_os_file_put(thefile, &fd, 0, pool); + return fspr_os_file_put(thefile, &fd, 0, pool); } -APR_DECLARE(apr_status_t) apr_file_open_stdin(apr_file_t **thefile, apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_file_open_stdin(fspr_file_t **thefile, fspr_pool_t *pool) { - apr_os_file_t fd = 0; + fspr_os_file_t fd = 0; - return apr_os_file_put(thefile, &fd, 0, pool); + return fspr_os_file_put(thefile, &fd, 0, pool); } APR_POOL_IMPLEMENT_ACCESSOR(file); -APR_IMPLEMENT_INHERIT_SET(file, flags, pool, apr_file_cleanup) +APR_IMPLEMENT_INHERIT_SET(file, flags, pool, fspr_file_cleanup) -APR_IMPLEMENT_INHERIT_UNSET(file, flags, pool, apr_file_cleanup) +APR_IMPLEMENT_INHERIT_UNSET(file, flags, pool, fspr_file_cleanup) diff --git a/libs/apr/file_io/os2/pipe.c b/libs/apr/file_io/os2/pipe.c index ee2b2b004e..007977aafc 100644 --- a/libs/apr/file_io/os2/pipe.c +++ b/libs/apr/file_io/os2/pipe.c @@ -15,16 +15,16 @@ */ #define INCL_DOSERRORS -#include "apr_arch_file_io.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_strings.h" -#include "apr_portable.h" +#include "fspr_arch_file_io.h" +#include "fspr_file_io.h" +#include "fspr_general.h" +#include "fspr_lib.h" +#include "fspr_strings.h" +#include "fspr_portable.h" #include #include -APR_DECLARE(apr_status_t) apr_file_pipe_create(apr_file_t **in, apr_file_t **out, apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_file_pipe_create(fspr_file_t **in, fspr_file_t **out, fspr_pool_t *pool) { ULONG filedes[2]; ULONG rc, action; @@ -54,7 +54,7 @@ APR_DECLARE(apr_status_t) apr_file_pipe_create(apr_file_t **in, apr_file_t **out return APR_FROM_OS_ERROR(rc); } - (*in) = (apr_file_t *)apr_palloc(pool, sizeof(apr_file_t)); + (*in) = (fspr_file_t *)fspr_palloc(pool, sizeof(fspr_file_t)); rc = DosCreateEventSem(NULL, &(*in)->pipeSem, DC_SEM_SHARED, FALSE); if (rc) { @@ -78,33 +78,33 @@ APR_DECLARE(apr_status_t) apr_file_pipe_create(apr_file_t **in, apr_file_t **out (*in)->pool = pool; (*in)->filedes = filedes[0]; - (*in)->fname = apr_pstrdup(pool, pipename); + (*in)->fname = fspr_pstrdup(pool, pipename); (*in)->isopen = TRUE; (*in)->buffered = FALSE; (*in)->flags = 0; (*in)->pipe = 1; (*in)->timeout = -1; (*in)->blocking = BLK_ON; - apr_pool_cleanup_register(pool, *in, apr_file_cleanup, apr_pool_cleanup_null); + fspr_pool_cleanup_register(pool, *in, fspr_file_cleanup, fspr_pool_cleanup_null); - (*out) = (apr_file_t *)apr_palloc(pool, sizeof(apr_file_t)); + (*out) = (fspr_file_t *)fspr_palloc(pool, sizeof(fspr_file_t)); (*out)->pool = pool; (*out)->filedes = filedes[1]; - (*out)->fname = apr_pstrdup(pool, pipename); + (*out)->fname = fspr_pstrdup(pool, pipename); (*out)->isopen = TRUE; (*out)->buffered = FALSE; (*out)->flags = 0; (*out)->pipe = 1; (*out)->timeout = -1; (*out)->blocking = BLK_ON; - apr_pool_cleanup_register(pool, *out, apr_file_cleanup, apr_pool_cleanup_null); + fspr_pool_cleanup_register(pool, *out, fspr_file_cleanup, fspr_pool_cleanup_null); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_file_namedpipe_create(const char *filename, apr_fileperms_t perm, apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_file_namedpipe_create(const char *filename, fspr_fileperms_t perm, fspr_pool_t *pool) { /* Not yet implemented, interface not suitable */ return APR_ENOTIMPL; @@ -112,7 +112,7 @@ APR_DECLARE(apr_status_t) apr_file_namedpipe_create(const char *filename, apr_fi -APR_DECLARE(apr_status_t) apr_file_pipe_timeout_set(apr_file_t *thepipe, apr_interval_time_t timeout) +APR_DECLARE(fspr_status_t) fspr_file_pipe_timeout_set(fspr_file_t *thepipe, fspr_interval_time_t timeout) { if (thepipe->pipe == 1) { thepipe->timeout = timeout; @@ -135,7 +135,7 @@ APR_DECLARE(apr_status_t) apr_file_pipe_timeout_set(apr_file_t *thepipe, apr_int -APR_DECLARE(apr_status_t) apr_file_pipe_timeout_get(apr_file_t *thepipe, apr_interval_time_t *timeout) +APR_DECLARE(fspr_status_t) fspr_file_pipe_timeout_get(fspr_file_t *thepipe, fspr_interval_time_t *timeout) { if (thepipe->pipe == 1) { *timeout = thepipe->timeout; @@ -146,12 +146,12 @@ APR_DECLARE(apr_status_t) apr_file_pipe_timeout_get(apr_file_t *thepipe, apr_int -APR_DECLARE(apr_status_t) apr_os_pipe_put_ex(apr_file_t **file, - apr_os_file_t *thefile, +APR_DECLARE(fspr_status_t) fspr_os_pipe_put_ex(fspr_file_t **file, + fspr_os_file_t *thefile, int register_cleanup, - apr_pool_t *pool) + fspr_pool_t *pool) { - (*file) = apr_pcalloc(pool, sizeof(apr_file_t)); + (*file) = fspr_pcalloc(pool, sizeof(fspr_file_t)); (*file)->pool = pool; (*file)->isopen = TRUE; (*file)->pipe = 1; @@ -160,8 +160,8 @@ APR_DECLARE(apr_status_t) apr_os_pipe_put_ex(apr_file_t **file, (*file)->filedes = *thefile; if (register_cleanup) { - apr_pool_cleanup_register(pool, *file, apr_file_cleanup, - apr_pool_cleanup_null); + fspr_pool_cleanup_register(pool, *file, fspr_file_cleanup, + fspr_pool_cleanup_null); } return APR_SUCCESS; @@ -169,9 +169,9 @@ APR_DECLARE(apr_status_t) apr_os_pipe_put_ex(apr_file_t **file, -APR_DECLARE(apr_status_t) apr_os_pipe_put(apr_file_t **file, - apr_os_file_t *thefile, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_os_pipe_put(fspr_file_t **file, + fspr_os_file_t *thefile, + fspr_pool_t *pool) { - return apr_os_pipe_put_ex(file, thefile, 0, pool); + return fspr_os_pipe_put_ex(file, thefile, 0, pool); } diff --git a/libs/apr/file_io/os2/readwrite.c b/libs/apr/file_io/os2/readwrite.c index f25a4210d6..90d786755e 100644 --- a/libs/apr/file_io/os2/readwrite.c +++ b/libs/apr/file_io/os2/readwrite.c @@ -17,14 +17,14 @@ #define INCL_DOS #define INCL_DOSERRORS -#include "apr_arch_file_io.h" -#include "apr_file_io.h" -#include "apr_lib.h" -#include "apr_strings.h" +#include "fspr_arch_file_io.h" +#include "fspr_file_io.h" +#include "fspr_lib.h" +#include "fspr_strings.h" #include -APR_DECLARE(apr_status_t) apr_file_read(apr_file_t *thefile, void *buf, apr_size_t *nbytes) +APR_DECLARE(fspr_status_t) fspr_file_read(fspr_file_t *thefile, void *buf, fspr_size_t *nbytes) { ULONG rc = 0; ULONG bytesread; @@ -39,13 +39,13 @@ APR_DECLARE(apr_status_t) apr_file_read(apr_file_t *thefile, void *buf, apr_size ULONG blocksize; ULONG size = *nbytes; - apr_thread_mutex_lock(thefile->mutex); + fspr_thread_mutex_lock(thefile->mutex); if (thefile->direction == 1) { - int rv = apr_file_flush(thefile); + int rv = fspr_file_flush(thefile); if (rv != APR_SUCCESS) { - apr_thread_mutex_unlock(thefile->mutex); + fspr_thread_mutex_unlock(thefile->mutex); return rv; } @@ -79,7 +79,7 @@ APR_DECLARE(apr_status_t) apr_file_read(apr_file_t *thefile, void *buf, apr_size } *nbytes = rc == 0 ? pos - (char *)buf : 0; - apr_thread_mutex_unlock(thefile->mutex); + fspr_thread_mutex_unlock(thefile->mutex); if (*nbytes == 0 && rc == 0 && thefile->eof_hit) { return APR_EOF; @@ -122,7 +122,7 @@ APR_DECLARE(apr_status_t) apr_file_read(apr_file_t *thefile, void *buf, apr_size -APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, apr_size_t *nbytes) +APR_DECLARE(fspr_status_t) fspr_file_write(fspr_file_t *thefile, const void *buf, fspr_size_t *nbytes) { ULONG rc = 0; ULONG byteswritten; @@ -137,7 +137,7 @@ APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, a int blocksize; int size = *nbytes; - apr_thread_mutex_lock(thefile->mutex); + fspr_thread_mutex_lock(thefile->mutex); if ( thefile->direction == 0 ) { // Position file pointer for writing at the offset we are logically reading from @@ -150,7 +150,7 @@ APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, a while (rc == 0 && size > 0) { if (thefile->bufpos == APR_FILE_BUFSIZE) // write buffer is full - rc = apr_file_flush(thefile); + rc = fspr_file_flush(thefile); blocksize = size > APR_FILE_BUFSIZE - thefile->bufpos ? APR_FILE_BUFSIZE - thefile->bufpos : size; memcpy(thefile->buffer + thefile->bufpos, pos, blocksize); @@ -159,7 +159,7 @@ APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, a size -= blocksize; } - apr_thread_mutex_unlock(thefile->mutex); + fspr_thread_mutex_unlock(thefile->mutex); return APR_FROM_OS_ERROR(rc); } else { if (thefile->flags & APR_APPEND) { @@ -194,7 +194,7 @@ APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, a #ifdef HAVE_WRITEV -APR_DECLARE(apr_status_t) apr_file_writev(apr_file_t *thefile, const struct iovec *vec, apr_size_t nvec, apr_size_t *nbytes) +APR_DECLARE(fspr_status_t) fspr_file_writev(fspr_file_t *thefile, const struct iovec *vec, fspr_size_t nvec, fspr_size_t *nbytes) { int bytes; if ((bytes = writev(thefile->filedes, vec, nvec)) < 0) { @@ -210,7 +210,7 @@ APR_DECLARE(apr_status_t) apr_file_writev(apr_file_t *thefile, const struct iove -APR_DECLARE(apr_status_t) apr_file_putc(char ch, apr_file_t *thefile) +APR_DECLARE(fspr_status_t) fspr_file_putc(char ch, fspr_file_t *thefile) { ULONG rc; ULONG byteswritten; @@ -230,24 +230,24 @@ APR_DECLARE(apr_status_t) apr_file_putc(char ch, apr_file_t *thefile) -APR_DECLARE(apr_status_t) apr_file_ungetc(char ch, apr_file_t *thefile) +APR_DECLARE(fspr_status_t) fspr_file_ungetc(char ch, fspr_file_t *thefile) { - apr_off_t offset = -1; - return apr_file_seek(thefile, APR_CUR, &offset); + fspr_off_t offset = -1; + return fspr_file_seek(thefile, APR_CUR, &offset); } -APR_DECLARE(apr_status_t) apr_file_getc(char *ch, apr_file_t *thefile) +APR_DECLARE(fspr_status_t) fspr_file_getc(char *ch, fspr_file_t *thefile) { ULONG rc; - apr_size_t bytesread; + fspr_size_t bytesread; if (!thefile->isopen) { return APR_EBADF; } bytesread = 1; - rc = apr_file_read(thefile, ch, &bytesread); + rc = fspr_file_read(thefile, ch, &bytesread); if (rc) { return rc; @@ -263,16 +263,16 @@ APR_DECLARE(apr_status_t) apr_file_getc(char *ch, apr_file_t *thefile) -APR_DECLARE(apr_status_t) apr_file_puts(const char *str, apr_file_t *thefile) +APR_DECLARE(fspr_status_t) fspr_file_puts(const char *str, fspr_file_t *thefile) { - apr_size_t len; + fspr_size_t len; len = strlen(str); - return apr_file_write(thefile, str, &len); + return fspr_file_write(thefile, str, &len); } -APR_DECLARE(apr_status_t) apr_file_flush(apr_file_t *thefile) +APR_DECLARE(fspr_status_t) fspr_file_flush(fspr_file_t *thefile) { if (thefile->buffered) { ULONG written = 0; @@ -296,15 +296,15 @@ APR_DECLARE(apr_status_t) apr_file_flush(apr_file_t *thefile) } -APR_DECLARE(apr_status_t) apr_file_gets(char *str, int len, apr_file_t *thefile) +APR_DECLARE(fspr_status_t) fspr_file_gets(char *str, int len, fspr_file_t *thefile) { - apr_size_t readlen; - apr_status_t rv = APR_SUCCESS; + fspr_size_t readlen; + fspr_status_t rv = APR_SUCCESS; int i; for (i = 0; i < len-1; i++) { readlen = 1; - rv = apr_file_read(thefile, str+i, &readlen); + rv = fspr_file_read(thefile, str+i, &readlen); if (rv != APR_SUCCESS) { break; @@ -332,7 +332,7 @@ APR_DECLARE(apr_status_t) apr_file_gets(char *str, int len, apr_file_t *thefile) -APR_DECLARE_NONSTD(int) apr_file_printf(apr_file_t *fptr, +APR_DECLARE_NONSTD(int) fspr_file_printf(fspr_file_t *fptr, const char *format, ...) { int cc; @@ -345,8 +345,8 @@ APR_DECLARE_NONSTD(int) apr_file_printf(apr_file_t *fptr, return 0; } va_start(ap, format); - len = apr_vsnprintf(buf, HUGE_STRING_LEN, format, ap); - cc = apr_file_puts(buf, fptr); + len = fspr_vsnprintf(buf, HUGE_STRING_LEN, format, ap); + cc = fspr_file_puts(buf, fptr); va_end(ap); free(buf); return (cc == APR_SUCCESS) ? len : -1; @@ -354,7 +354,7 @@ APR_DECLARE_NONSTD(int) apr_file_printf(apr_file_t *fptr, -apr_status_t apr_file_check_read(apr_file_t *fd) +fspr_status_t fspr_file_check_read(fspr_file_t *fd) { int rc; diff --git a/libs/apr/file_io/os2/seek.c b/libs/apr/file_io/os2/seek.c index 6fdfe8e826..61420de7cc 100644 --- a/libs/apr/file_io/os2/seek.c +++ b/libs/apr/file_io/os2/seek.c @@ -14,20 +14,20 @@ * limitations under the License. */ -#include "apr_arch_file_io.h" -#include "apr_file_io.h" -#include "apr_lib.h" +#include "fspr_arch_file_io.h" +#include "fspr_file_io.h" +#include "fspr_lib.h" #include #include -static apr_status_t setptr(apr_file_t *thefile, unsigned long pos ) +static fspr_status_t setptr(fspr_file_t *thefile, unsigned long pos ) { long newbufpos; ULONG rc; if (thefile->direction == 1) { - apr_status_t rv = apr_file_flush(thefile); + fspr_status_t rv = fspr_file_flush(thefile); if (rv != APR_SUCCESS) { return rv; @@ -52,7 +52,7 @@ static apr_status_t setptr(apr_file_t *thefile, unsigned long pos ) -APR_DECLARE(apr_status_t) apr_file_seek(apr_file_t *thefile, apr_seek_where_t where, apr_off_t *offset) +APR_DECLARE(fspr_status_t) fspr_file_seek(fspr_file_t *thefile, fspr_seek_where_t where, fspr_off_t *offset) { if (!thefile->isopen) { return APR_EBADF; @@ -62,7 +62,7 @@ APR_DECLARE(apr_status_t) apr_file_seek(apr_file_t *thefile, apr_seek_where_t wh if (thefile->buffered) { int rc = EINVAL; - apr_finfo_t finfo; + fspr_finfo_t finfo; switch (where) { case APR_SET: @@ -74,7 +74,7 @@ APR_DECLARE(apr_status_t) apr_file_seek(apr_file_t *thefile, apr_seek_where_t wh break; case APR_END: - rc = apr_file_info_get(&finfo, APR_FINFO_NORM, thefile); + rc = fspr_file_info_get(&finfo, APR_FINFO_NORM, thefile); if (rc == APR_SUCCESS) rc = setptr(thefile, finfo.size + *offset); break; @@ -103,7 +103,7 @@ APR_DECLARE(apr_status_t) apr_file_seek(apr_file_t *thefile, apr_seek_where_t wh -APR_DECLARE(apr_status_t) apr_file_trunc(apr_file_t *fp, apr_off_t offset) +APR_DECLARE(fspr_status_t) fspr_file_trunc(fspr_file_t *fp, fspr_off_t offset) { int rc = DosSetFileSize(fp->filedes, offset); diff --git a/libs/apr/file_io/unix/copy.c b/libs/apr/file_io/unix/copy.c index 113a1081bd..df5b1fec7f 100644 --- a/libs/apr/file_io/unix/copy.c +++ b/libs/apr/file_io/unix/copy.c @@ -14,30 +14,30 @@ * limitations under the License. */ -#include "apr_arch_file_io.h" -#include "apr_file_io.h" +#include "fspr_arch_file_io.h" +#include "fspr_file_io.h" -static apr_status_t apr_file_transfer_contents(const char *from_path, +static fspr_status_t fspr_file_transfer_contents(const char *from_path, const char *to_path, - apr_int32_t flags, - apr_fileperms_t to_perms, - apr_pool_t *pool) + fspr_int32_t flags, + fspr_fileperms_t to_perms, + fspr_pool_t *pool) { - apr_file_t *s, *d; - apr_status_t status; - apr_finfo_t finfo; - apr_fileperms_t perms; + fspr_file_t *s, *d; + fspr_status_t status; + fspr_finfo_t finfo; + fspr_fileperms_t perms; /* Open source file. */ - status = apr_file_open(&s, from_path, APR_READ, APR_OS_DEFAULT, pool); + status = fspr_file_open(&s, from_path, APR_READ, APR_OS_DEFAULT, pool); if (status) return status; /* Maybe get its permissions. */ if (to_perms == APR_FILE_SOURCE_PERMS) { - status = apr_file_info_get(&finfo, APR_FINFO_PROT, s); + status = fspr_file_info_get(&finfo, APR_FINFO_PROT, s); if (status != APR_SUCCESS && status != APR_INCOMPLETE) { - apr_file_close(s); /* toss any error */ + fspr_file_close(s); /* toss any error */ return status; } perms = finfo.protection; @@ -46,66 +46,66 @@ static apr_status_t apr_file_transfer_contents(const char *from_path, perms = to_perms; /* Open dest file. */ - status = apr_file_open(&d, to_path, flags, perms, pool); + status = fspr_file_open(&d, to_path, flags, perms, pool); if (status) { - apr_file_close(s); /* toss any error */ + fspr_file_close(s); /* toss any error */ return status; } /* Copy bytes till the cows come home. */ while (1) { char buf[BUFSIZ]; - apr_size_t bytes_this_time = sizeof(buf); - apr_status_t read_err; - apr_status_t write_err; + fspr_size_t bytes_this_time = sizeof(buf); + fspr_status_t read_err; + fspr_status_t write_err; /* Read 'em. */ - read_err = apr_file_read(s, buf, &bytes_this_time); + read_err = fspr_file_read(s, buf, &bytes_this_time); if (read_err && !APR_STATUS_IS_EOF(read_err)) { - apr_file_close(s); /* toss any error */ - apr_file_close(d); /* toss any error */ + fspr_file_close(s); /* toss any error */ + fspr_file_close(d); /* toss any error */ return read_err; } /* Write 'em. */ - write_err = apr_file_write_full(d, buf, bytes_this_time, NULL); + write_err = fspr_file_write_full(d, buf, bytes_this_time, NULL); if (write_err) { - apr_file_close(s); /* toss any error */ - apr_file_close(d); /* toss any error */ + fspr_file_close(s); /* toss any error */ + fspr_file_close(d); /* toss any error */ return write_err; } if (read_err && APR_STATUS_IS_EOF(read_err)) { - status = apr_file_close(s); + status = fspr_file_close(s); if (status) { - apr_file_close(d); /* toss any error */ + fspr_file_close(d); /* toss any error */ return status; } /* return the results of this close: an error, or success */ - return apr_file_close(d); + return fspr_file_close(d); } } /* NOTREACHED */ } -APR_DECLARE(apr_status_t) apr_file_copy(const char *from_path, +APR_DECLARE(fspr_status_t) fspr_file_copy(const char *from_path, const char *to_path, - apr_fileperms_t perms, - apr_pool_t *pool) + fspr_fileperms_t perms, + fspr_pool_t *pool) { - return apr_file_transfer_contents(from_path, to_path, + return fspr_file_transfer_contents(from_path, to_path, (APR_WRITE | APR_CREATE | APR_TRUNCATE), perms, pool); } -APR_DECLARE(apr_status_t) apr_file_append(const char *from_path, +APR_DECLARE(fspr_status_t) fspr_file_append(const char *from_path, const char *to_path, - apr_fileperms_t perms, - apr_pool_t *pool) + fspr_fileperms_t perms, + fspr_pool_t *pool) { - return apr_file_transfer_contents(from_path, to_path, + return fspr_file_transfer_contents(from_path, to_path, (APR_WRITE | APR_CREATE | APR_APPEND), perms, pool); diff --git a/libs/apr/file_io/unix/dir.c b/libs/apr/file_io/unix/dir.c index e05dc993c5..faba53d71d 100644 --- a/libs/apr/file_io/unix/dir.c +++ b/libs/apr/file_io/unix/dir.c @@ -14,9 +14,9 @@ * limitations under the License. */ -#include "apr_arch_file_io.h" -#include "apr_strings.h" -#include "apr_portable.h" +#include "fspr_arch_file_io.h" +#include "fspr_strings.h" +#include "fspr_portable.h" #if APR_HAVE_SYS_SYSLIMITS_H #include #endif @@ -24,9 +24,9 @@ #include #endif -static apr_status_t dir_cleanup(void *thedir) +static fspr_status_t dir_cleanup(void *thedir) { - apr_dir_t *dir = thedir; + fspr_dir_t *dir = thedir; if (closedir(dir->dirstruct) == 0) { return APR_SUCCESS; } @@ -38,24 +38,24 @@ static apr_status_t dir_cleanup(void *thedir) #define PATH_SEPARATOR '/' /* Remove trailing separators that don't affect the meaning of PATH. */ -static const char *path_canonicalize (const char *path, apr_pool_t *pool) +static const char *path_canonicalize (const char *path, fspr_pool_t *pool) { /* At some point this could eliminate redundant components. For * now, it just makes sure there is no trailing slash. */ - apr_size_t len = strlen (path); - apr_size_t orig_len = len; + fspr_size_t len = strlen (path); + fspr_size_t orig_len = len; while ((len > 0) && (path[len - 1] == PATH_SEPARATOR)) len--; if (len != orig_len) - return apr_pstrndup (pool, path, len); + return fspr_pstrndup (pool, path, len); else return path; } /* Remove one component off the end of PATH. */ -static char *path_remove_last_component (const char *path, apr_pool_t *pool) +static char *path_remove_last_component (const char *path, fspr_pool_t *pool) { const char *newpath = path_canonicalize (path, pool); int i; @@ -65,18 +65,18 @@ static char *path_remove_last_component (const char *path, apr_pool_t *pool) break; } - return apr_pstrndup (pool, path, (i < 0) ? 0 : i); + return fspr_pstrndup (pool, path, (i < 0) ? 0 : i); } -apr_status_t apr_dir_open(apr_dir_t **new, const char *dirname, - apr_pool_t *pool) +fspr_status_t fspr_dir_open(fspr_dir_t **new, const char *dirname, + fspr_pool_t *pool) { /* On some platforms (e.g., Linux+GNU libc), d_name[] in struct * dirent is declared with enough storage for the name. On other * platforms (e.g., Solaris 8 for Intel), d_name is declared as a * one-byte array. Note: gcc evaluates this at compile time. */ - apr_size_t dirent_size = + fspr_size_t dirent_size = (sizeof((*new)->entry->d_name) > 1 ? sizeof(struct dirent) : sizeof (struct dirent) + 255); DIR *dir = opendir(dirname); @@ -85,25 +85,25 @@ apr_status_t apr_dir_open(apr_dir_t **new, const char *dirname, return errno; } - (*new) = (apr_dir_t *)apr_palloc(pool, sizeof(apr_dir_t)); + (*new) = (fspr_dir_t *)fspr_palloc(pool, sizeof(fspr_dir_t)); (*new)->pool = pool; - (*new)->dirname = apr_pstrdup(pool, dirname); + (*new)->dirname = fspr_pstrdup(pool, dirname); (*new)->dirstruct = dir; - (*new)->entry = apr_pcalloc(pool, dirent_size); + (*new)->entry = fspr_pcalloc(pool, dirent_size); - apr_pool_cleanup_register((*new)->pool, *new, dir_cleanup, - apr_pool_cleanup_null); + fspr_pool_cleanup_register((*new)->pool, *new, dir_cleanup, + fspr_pool_cleanup_null); return APR_SUCCESS; } -apr_status_t apr_dir_close(apr_dir_t *thedir) +fspr_status_t fspr_dir_close(fspr_dir_t *thedir) { - return apr_pool_cleanup_run(thedir->pool, thedir, dir_cleanup); + return fspr_pool_cleanup_run(thedir->pool, thedir, dir_cleanup); } #ifdef DIRENT_TYPE -static apr_filetype_e filetype_from_dirent_type(int type) +static fspr_filetype_e filetype_from_dirent_type(int type) { switch (type) { case DT_REG: @@ -130,12 +130,12 @@ static apr_filetype_e filetype_from_dirent_type(int type) } #endif -apr_status_t apr_dir_read(apr_finfo_t *finfo, apr_int32_t wanted, - apr_dir_t *thedir) +fspr_status_t fspr_dir_read(fspr_finfo_t *finfo, fspr_int32_t wanted, + fspr_dir_t *thedir) { - apr_status_t ret = 0; + fspr_status_t ret = 0; #ifdef DIRENT_TYPE - apr_filetype_e type; + fspr_filetype_e type; #endif #if APR_HAS_THREADS && defined(_POSIX_THREAD_SAFE_FUNCTIONS) \ && !defined(READDIR_IS_THREAD_SAFE) @@ -201,12 +201,12 @@ apr_status_t apr_dir_read(apr_finfo_t *finfo, apr_int32_t wanted, { char fspec[APR_PATH_MAX]; int off; - apr_cpystrn(fspec, thedir->dirname, sizeof(fspec)); + fspr_cpystrn(fspec, thedir->dirname, sizeof(fspec)); off = strlen(fspec); if ((fspec[off - 1] != '/') && (off + 1 < sizeof(fspec))) fspec[off++] = '/'; - apr_cpystrn(fspec + off, thedir->entry->d_name, sizeof(fspec) - off); - ret = apr_stat(finfo, fspec, APR_FINFO_LINK | wanted, thedir->pool); + fspr_cpystrn(fspec + off, thedir->entry->d_name, sizeof(fspec) - off); + ret = fspr_stat(finfo, fspec, APR_FINFO_LINK | wanted, thedir->pool); /* We passed a stack name that will disappear */ finfo->fname = NULL; } @@ -234,7 +234,7 @@ apr_status_t apr_dir_read(apr_finfo_t *finfo, apr_int32_t wanted, #endif } - finfo->name = apr_pstrdup(thedir->pool, thedir->entry->d_name); + finfo->name = fspr_pstrdup(thedir->pool, thedir->entry->d_name); finfo->valid |= APR_FINFO_NAME; if (wanted) @@ -243,16 +243,16 @@ apr_status_t apr_dir_read(apr_finfo_t *finfo, apr_int32_t wanted, return APR_SUCCESS; } -apr_status_t apr_dir_rewind(apr_dir_t *thedir) +fspr_status_t fspr_dir_rewind(fspr_dir_t *thedir) { rewinddir(thedir->dirstruct); return APR_SUCCESS; } -apr_status_t apr_dir_make(const char *path, apr_fileperms_t perm, - apr_pool_t *pool) +fspr_status_t fspr_dir_make(const char *path, fspr_fileperms_t perm, + fspr_pool_t *pool) { - mode_t mode = apr_unix_perms2mode(perm); + mode_t mode = fspr_unix_perms2mode(perm); if (mkdir(path, mode) == 0) { return APR_SUCCESS; @@ -262,35 +262,35 @@ apr_status_t apr_dir_make(const char *path, apr_fileperms_t perm, } } -apr_status_t apr_dir_make_recursive(const char *path, apr_fileperms_t perm, - apr_pool_t *pool) +fspr_status_t fspr_dir_make_recursive(const char *path, fspr_fileperms_t perm, + fspr_pool_t *pool) { - apr_status_t apr_err = 0; + fspr_status_t fspr_err = 0; - apr_err = apr_dir_make (path, perm, pool); /* Try to make PATH right out */ + fspr_err = fspr_dir_make (path, perm, pool); /* Try to make PATH right out */ - if (apr_err == EEXIST) /* It's OK if PATH exists */ + if (fspr_err == EEXIST) /* It's OK if PATH exists */ return APR_SUCCESS; - if (apr_err == ENOENT) { /* Missing an intermediate dir */ + if (fspr_err == ENOENT) { /* Missing an intermediate dir */ char *dir; dir = path_remove_last_component(path, pool); /* If there is no path left, give up. */ if (dir[0] == '\0') { - return apr_err; + return fspr_err; } - apr_err = apr_dir_make_recursive(dir, perm, pool); + fspr_err = fspr_dir_make_recursive(dir, perm, pool); - if (!apr_err) - apr_err = apr_dir_make (path, perm, pool); + if (!fspr_err) + fspr_err = fspr_dir_make (path, perm, pool); } - return apr_err; + return fspr_err; } -apr_status_t apr_dir_remove(const char *path, apr_pool_t *pool) +fspr_status_t fspr_dir_remove(const char *path, fspr_pool_t *pool) { if (rmdir(path) == 0) { return APR_SUCCESS; @@ -300,7 +300,7 @@ apr_status_t apr_dir_remove(const char *path, apr_pool_t *pool) } } -apr_status_t apr_os_dir_get(apr_os_dir_t **thedir, apr_dir_t *dir) +fspr_status_t fspr_os_dir_get(fspr_os_dir_t **thedir, fspr_dir_t *dir) { if (dir == NULL) { return APR_ENODIR; @@ -309,11 +309,11 @@ apr_status_t apr_os_dir_get(apr_os_dir_t **thedir, apr_dir_t *dir) return APR_SUCCESS; } -apr_status_t apr_os_dir_put(apr_dir_t **dir, apr_os_dir_t *thedir, - apr_pool_t *pool) +fspr_status_t fspr_os_dir_put(fspr_dir_t **dir, fspr_os_dir_t *thedir, + fspr_pool_t *pool) { if ((*dir) == NULL) { - (*dir) = (apr_dir_t *)apr_pcalloc(pool, sizeof(apr_dir_t)); + (*dir) = (fspr_dir_t *)fspr_pcalloc(pool, sizeof(fspr_dir_t)); (*dir)->pool = pool; } (*dir)->dirstruct = thedir; diff --git a/libs/apr/file_io/unix/fileacc.c b/libs/apr/file_io/unix/fileacc.c index 437f3589f5..b1efa0e822 100644 --- a/libs/apr/file_io/unix/fileacc.c +++ b/libs/apr/file_io/unix/fileacc.c @@ -14,25 +14,25 @@ * limitations under the License. */ -#include "apr_strings.h" -#include "apr_arch_file_io.h" +#include "fspr_strings.h" +#include "fspr_arch_file_io.h" -/* A file to put ALL of the accessor functions for apr_file_t types. */ +/* A file to put ALL of the accessor functions for fspr_file_t types. */ -APR_DECLARE(apr_status_t) apr_file_name_get(const char **fname, - apr_file_t *thefile) +APR_DECLARE(fspr_status_t) fspr_file_name_get(const char **fname, + fspr_file_t *thefile) { *fname = thefile->fname; return APR_SUCCESS; } -APR_DECLARE(apr_int32_t) apr_file_flags_get(apr_file_t *f) +APR_DECLARE(fspr_int32_t) fspr_file_flags_get(fspr_file_t *f) { return f->flags; } #if !defined(OS2) && !defined(WIN32) -mode_t apr_unix_perms2mode(apr_fileperms_t perms) +mode_t fspr_unix_perms2mode(fspr_fileperms_t perms) { mode_t mode = 0; @@ -68,9 +68,9 @@ mode_t apr_unix_perms2mode(apr_fileperms_t perms) return mode; } -apr_fileperms_t apr_unix_mode2perms(mode_t mode) +fspr_fileperms_t fspr_unix_mode2perms(mode_t mode) { - apr_fileperms_t perms = 0; + fspr_fileperms_t perms = 0; if (mode & S_ISUID) perms |= APR_USETID; @@ -105,15 +105,15 @@ apr_fileperms_t apr_unix_mode2perms(mode_t mode) } #endif -APR_DECLARE(apr_status_t) apr_file_data_get(void **data, const char *key, - apr_file_t *file) +APR_DECLARE(fspr_status_t) fspr_file_data_get(void **data, const char *key, + fspr_file_t *file) { - return apr_pool_userdata_get(data, key, file->pool); + return fspr_pool_userdata_get(data, key, file->pool); } -APR_DECLARE(apr_status_t) apr_file_data_set(apr_file_t *file, void *data, +APR_DECLARE(fspr_status_t) fspr_file_data_set(fspr_file_t *file, void *data, const char *key, - apr_status_t (*cleanup)(void *)) + fspr_status_t (*cleanup)(void *)) { - return apr_pool_userdata_set(data, key, cleanup, file->pool); + return fspr_pool_userdata_set(data, key, cleanup, file->pool); } diff --git a/libs/apr/file_io/unix/filedup.c b/libs/apr/file_io/unix/filedup.c index f2b61efe03..007421f91b 100644 --- a/libs/apr/file_io/unix/filedup.c +++ b/libs/apr/file_io/unix/filedup.c @@ -14,14 +14,14 @@ * limitations under the License. */ -#include "apr_arch_file_io.h" -#include "apr_strings.h" -#include "apr_portable.h" -#include "apr_thread_mutex.h" -#include "apr_arch_inherit.h" +#include "fspr_arch_file_io.h" +#include "fspr_strings.h" +#include "fspr_portable.h" +#include "fspr_thread_mutex.h" +#include "fspr_arch_inherit.h" -static apr_status_t file_dup(apr_file_t **new_file, - apr_file_t *old_file, apr_pool_t *p, +static fspr_status_t file_dup(fspr_file_t **new_file, + fspr_file_t *old_file, fspr_pool_t *p, int which_dup) { int rv; @@ -40,12 +40,12 @@ static apr_status_t file_dup(apr_file_t **new_file, return errno; if (which_dup == 1) { - (*new_file) = (apr_file_t *)apr_pcalloc(p, sizeof(apr_file_t)); + (*new_file) = (fspr_file_t *)fspr_pcalloc(p, sizeof(fspr_file_t)); (*new_file)->pool = p; (*new_file)->filedes = rv; } - (*new_file)->fname = apr_pstrdup(p, old_file->fname); + (*new_file)->fname = fspr_pstrdup(p, old_file->fname); (*new_file)->buffered = old_file->buffered; /* If the existing socket in a dup2 is already buffered, we @@ -54,7 +54,7 @@ static apr_status_t file_dup(apr_file_t **new_file, */ #if APR_HAS_THREADS if ((*new_file)->buffered && !(*new_file)->thlock && old_file->thlock) { - apr_thread_mutex_create(&((*new_file)->thlock), + fspr_thread_mutex_create(&((*new_file)->thlock), APR_THREAD_MUTEX_DEFAULT, p); } #endif @@ -62,7 +62,7 @@ static apr_status_t file_dup(apr_file_t **new_file, * got one. */ if ((*new_file)->buffered && !(*new_file)->buffer) { - (*new_file)->buffer = apr_palloc(p, APR_FILE_BUFSIZE); + (*new_file)->buffer = fspr_palloc(p, APR_FILE_BUFSIZE); } /* this is the way dup() works */ @@ -71,29 +71,29 @@ static apr_status_t file_dup(apr_file_t **new_file, /* make sure unget behavior is consistent */ (*new_file)->ungetchar = old_file->ungetchar; - /* apr_file_dup2() retains the original cleanup, reflecting + /* fspr_file_dup2() retains the original cleanup, reflecting * the existing inherit and nocleanup flags. This means, - * that apr_file_dup2() cannot be called against an apr_file_t - * already closed with apr_file_close, because the expected + * that fspr_file_dup2() cannot be called against an fspr_file_t + * already closed with fspr_file_close, because the expected * cleanup was already killed. */ if (which_dup == 2) { return APR_SUCCESS; } - /* apr_file_dup() retains all old_file flags with the exceptions + /* fspr_file_dup() retains all old_file flags with the exceptions * of APR_INHERIT and APR_FILE_NOCLEANUP. - * The user must call apr_file_inherit_set() on the dupped - * apr_file_t when desired. + * The user must call fspr_file_inherit_set() on the dupped + * fspr_file_t when desired. */ (*new_file)->flags = old_file->flags & ~(APR_INHERIT | APR_FILE_NOCLEANUP); - apr_pool_cleanup_register((*new_file)->pool, (void *)(*new_file), - apr_unix_file_cleanup, - apr_unix_file_cleanup); + fspr_pool_cleanup_register((*new_file)->pool, (void *)(*new_file), + fspr_unix_file_cleanup, + fspr_unix_file_cleanup); #ifndef WAITIO_USES_POLL - /* Start out with no pollset. apr_wait_for_io_or_timeout() will + /* Start out with no pollset. fspr_wait_for_io_or_timeout() will * initialize the pollset if needed. */ (*new_file)->pollset = NULL; @@ -101,27 +101,27 @@ static apr_status_t file_dup(apr_file_t **new_file, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_file_dup(apr_file_t **new_file, - apr_file_t *old_file, apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_file_dup(fspr_file_t **new_file, + fspr_file_t *old_file, fspr_pool_t *p) { return file_dup(new_file, old_file, p, 1); } -APR_DECLARE(apr_status_t) apr_file_dup2(apr_file_t *new_file, - apr_file_t *old_file, apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_file_dup2(fspr_file_t *new_file, + fspr_file_t *old_file, fspr_pool_t *p) { return file_dup(&new_file, old_file, p, 2); } -APR_DECLARE(apr_status_t) apr_file_setaside(apr_file_t **new_file, - apr_file_t *old_file, - apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_file_setaside(fspr_file_t **new_file, + fspr_file_t *old_file, + fspr_pool_t *p) { - *new_file = (apr_file_t *)apr_palloc(p, sizeof(apr_file_t)); - memcpy(*new_file, old_file, sizeof(apr_file_t)); + *new_file = (fspr_file_t *)fspr_palloc(p, sizeof(fspr_file_t)); + memcpy(*new_file, old_file, sizeof(fspr_file_t)); (*new_file)->pool = p; if (old_file->buffered) { - (*new_file)->buffer = apr_palloc(p, APR_FILE_BUFSIZE); + (*new_file)->buffer = fspr_palloc(p, APR_FILE_BUFSIZE); if (old_file->direction == 1) { memcpy((*new_file)->buffer, old_file->buffer, old_file->bufpos); } @@ -130,26 +130,26 @@ APR_DECLARE(apr_status_t) apr_file_setaside(apr_file_t **new_file, } #if APR_HAS_THREADS if (old_file->thlock) { - apr_thread_mutex_create(&((*new_file)->thlock), + fspr_thread_mutex_create(&((*new_file)->thlock), APR_THREAD_MUTEX_DEFAULT, p); - apr_thread_mutex_destroy(old_file->thlock); + fspr_thread_mutex_destroy(old_file->thlock); } #endif /* APR_HAS_THREADS */ } if (old_file->fname) { - (*new_file)->fname = apr_pstrdup(p, old_file->fname); + (*new_file)->fname = fspr_pstrdup(p, old_file->fname); } if (!(old_file->flags & APR_FILE_NOCLEANUP)) { - apr_pool_cleanup_register(p, (void *)(*new_file), - apr_unix_file_cleanup, + fspr_pool_cleanup_register(p, (void *)(*new_file), + fspr_unix_file_cleanup, ((*new_file)->flags & APR_INHERIT) - ? apr_pool_cleanup_null - : apr_unix_file_cleanup); + ? fspr_pool_cleanup_null + : fspr_unix_file_cleanup); } old_file->filedes = -1; - apr_pool_cleanup_kill(old_file->pool, (void *)old_file, - apr_unix_file_cleanup); + fspr_pool_cleanup_kill(old_file->pool, (void *)old_file, + fspr_unix_file_cleanup); #ifndef WAITIO_USES_POLL (*new_file)->pollset = NULL; #endif diff --git a/libs/apr/file_io/unix/filepath.c b/libs/apr/file_io/unix/filepath.c index 64f1b2fbd4..1e87b9f267 100644 --- a/libs/apr/file_io/unix/filepath.c +++ b/libs/apr/file_io/unix/filepath.c @@ -14,13 +14,13 @@ * limitations under the License. */ -#include "apr.h" -#include "apr_private.h" -#include "apr_arch_file_io.h" -#include "apr_file_io.h" -#include "apr_strings.h" +#include "fspr.h" +#include "fspr_private.h" +#include "fspr_arch_file_io.h" +#include "fspr_file_io.h" +#include "fspr_strings.h" #define APR_WANT_STRFUNC -#include "apr_want.h" +#include "fspr_want.h" #if APR_HAVE_UNISTD_H #include #endif @@ -34,8 +34,8 @@ /* Any OS that requires/refuses trailing slashes should be dealt with here. */ -APR_DECLARE(apr_status_t) apr_filepath_get(char **defpath, apr_int32_t flags, - apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_filepath_get(char **defpath, fspr_int32_t flags, + fspr_pool_t *p) { char path[APR_PATH_MAX]; @@ -45,7 +45,7 @@ APR_DECLARE(apr_status_t) apr_filepath_get(char **defpath, apr_int32_t flags, else return errno; } - *defpath = apr_pstrdup(p, path); + *defpath = fspr_pstrdup(p, path); return APR_SUCCESS; } @@ -53,7 +53,7 @@ APR_DECLARE(apr_status_t) apr_filepath_get(char **defpath, apr_int32_t flags, /* Any OS that requires/refuses trailing slashes should be dealt with here */ -APR_DECLARE(apr_status_t) apr_filepath_set(const char *path, apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_filepath_set(const char *path, fspr_pool_t *p) { if (chdir(path) != 0) return errno; @@ -61,13 +61,13 @@ APR_DECLARE(apr_status_t) apr_filepath_set(const char *path, apr_pool_t *p) return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_filepath_root(const char **rootpath, +APR_DECLARE(fspr_status_t) fspr_filepath_root(const char **rootpath, const char **inpath, - apr_int32_t flags, - apr_pool_t *p) + fspr_int32_t flags, + fspr_pool_t *p) { if (**inpath == '/') { - *rootpath = apr_pstrdup(p, "/"); + *rootpath = fspr_pstrdup(p, "/"); do { ++(*inpath); } while (**inpath == '/'); @@ -78,19 +78,19 @@ APR_DECLARE(apr_status_t) apr_filepath_root(const char **rootpath, return APR_ERELATIVE; } -APR_DECLARE(apr_status_t) apr_filepath_merge(char **newpath, +APR_DECLARE(fspr_status_t) fspr_filepath_merge(char **newpath, const char *rootpath, const char *addpath, - apr_int32_t flags, - apr_pool_t *p) + fspr_int32_t flags, + fspr_pool_t *p) { char *path; - apr_size_t rootlen; /* is the length of the src rootpath */ - apr_size_t maxlen; /* maximum total path length */ - apr_size_t keptlen; /* is the length of the retained rootpath */ - apr_size_t pathlen; /* is the length of the result path */ - apr_size_t seglen; /* is the end of the current segment */ - apr_status_t rv; + fspr_size_t rootlen; /* is the length of the src rootpath */ + fspr_size_t maxlen; /* maximum total path length */ + fspr_size_t keptlen; /* is the length of the retained rootpath */ + fspr_size_t pathlen; /* is the length of the result path */ + fspr_size_t seglen; /* is the end of the current segment */ + fspr_status_t rv; /* Treat null as an empty path. */ @@ -134,7 +134,7 @@ APR_DECLARE(apr_status_t) apr_filepath_merge(char **newpath, * passing the address of a char const* for a char** arg. */ char *getpath = NULL; - rv = apr_filepath_get(&getpath, flags, p); + rv = fspr_filepath_get(&getpath, flags, p); rootpath = getpath; if (rv != APR_SUCCESS) return errno; @@ -144,7 +144,7 @@ APR_DECLARE(apr_status_t) apr_filepath_merge(char **newpath, /* XXX: Any kernel subject to goofy, uncanonical results * must run the rootpath against the user's given flags. - * Simplest would be a recursive call to apr_filepath_merge + * Simplest would be a recursive call to fspr_filepath_merge * with an empty (not null) rootpath and addpath of the cwd. */ } @@ -156,7 +156,7 @@ APR_DECLARE(apr_status_t) apr_filepath_merge(char **newpath, if (maxlen > APR_PATH_MAX) { return APR_ENAMETOOLONG; } - path = (char *)apr_palloc(p, maxlen); + path = (char *)fspr_palloc(p, maxlen); if (addpath[0] == '/') { /* Ignore the given root path, strip off leading @@ -292,21 +292,21 @@ APR_DECLARE(apr_status_t) apr_filepath_merge(char **newpath, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_filepath_list_split(apr_array_header_t **pathelts, +APR_DECLARE(fspr_status_t) fspr_filepath_list_split(fspr_array_header_t **pathelts, const char *liststr, - apr_pool_t *p) + fspr_pool_t *p) { - return apr_filepath_list_split_impl(pathelts, liststr, ':', p); + return fspr_filepath_list_split_impl(pathelts, liststr, ':', p); } -APR_DECLARE(apr_status_t) apr_filepath_list_merge(char **liststr, - apr_array_header_t *pathelts, - apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_filepath_list_merge(char **liststr, + fspr_array_header_t *pathelts, + fspr_pool_t *p) { - return apr_filepath_list_merge_impl(liststr, pathelts, ':', p); + return fspr_filepath_list_merge_impl(liststr, pathelts, ':', p); } -APR_DECLARE(apr_status_t) apr_filepath_encoding(int *style, apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_filepath_encoding(int *style, fspr_pool_t *p) { *style = APR_FILEPATH_ENCODING_LOCALE; return APR_SUCCESS; diff --git a/libs/apr/file_io/unix/filepath_util.c b/libs/apr/file_io/unix/filepath_util.c index d8ccc56714..d81dc91ce3 100644 --- a/libs/apr/file_io/unix/filepath_util.c +++ b/libs/apr/file_io/unix/filepath_util.c @@ -17,29 +17,29 @@ #define APR_WANT_STRFUNC #define APR_WANT_MEMFUNC -#include "apr_want.h" +#include "fspr_want.h" -#include "apr_errno.h" -#include "apr_pools.h" -#include "apr_strings.h" -#include "apr_tables.h" +#include "fspr_errno.h" +#include "fspr_pools.h" +#include "fspr_strings.h" +#include "fspr_tables.h" -#include "apr_private.h" +#include "fspr_private.h" -apr_status_t apr_filepath_list_split_impl(apr_array_header_t **pathelts, +fspr_status_t fspr_filepath_list_split_impl(fspr_array_header_t **pathelts, const char *liststr, char separator, - apr_pool_t *p) + fspr_pool_t *p) { char *path, *part, *ptr; char separator_string[2] = { '\0', '\0' }; - apr_array_header_t *elts; + fspr_array_header_t *elts; int nelts; separator_string[0] = separator; /* Count the number of path elements. We know there'll be at least one even if path is an empty string. */ - path = apr_pstrdup(p, liststr); + path = fspr_pstrdup(p, liststr); for (nelts = 0, ptr = path; ptr != NULL; ++nelts) { ptr = strchr(ptr, separator); @@ -48,14 +48,14 @@ apr_status_t apr_filepath_list_split_impl(apr_array_header_t **pathelts, } /* Split the path into the array. */ - elts = apr_array_make(p, nelts, sizeof(char*)); - while ((part = apr_strtok(path, separator_string, &ptr)) != NULL) + elts = fspr_array_make(p, nelts, sizeof(char*)); + while ((part = fspr_strtok(path, separator_string, &ptr)) != NULL) { if (*part == '\0') /* Ignore empty path components. */ continue; - *(char**)apr_array_push(elts) = part; - path = NULL; /* For the next call to apr_strtok */ + *(char**)fspr_array_push(elts) = part; + path = NULL; /* For the next call to fspr_strtok */ } *pathelts = elts; @@ -63,12 +63,12 @@ apr_status_t apr_filepath_list_split_impl(apr_array_header_t **pathelts, } -apr_status_t apr_filepath_list_merge_impl(char **liststr, - apr_array_header_t *pathelts, +fspr_status_t fspr_filepath_list_merge_impl(char **liststr, + fspr_array_header_t *pathelts, char separator, - apr_pool_t *p) + fspr_pool_t *p) { - apr_size_t path_size = 0; + fspr_size_t path_size = 0; char *path; int i; @@ -91,13 +91,13 @@ apr_status_t apr_filepath_list_merge_impl(char **liststr, path_size += (i - 1); /* Merge the path components */ - path = *liststr = apr_palloc(p, path_size + 1); + path = *liststr = fspr_palloc(p, path_size + 1); for (i = 0; i < pathelts->nelts; ++i) { /* ### Hmmmm. Calling strlen twice on the same string. Yuck. - But is is better than reallocation in apr_pstrcat? */ + But is is better than reallocation in fspr_pstrcat? */ const char *part = ((char**)pathelts->elts)[i]; - apr_size_t part_size = strlen(part); + fspr_size_t part_size = strlen(part); if (part_size == 0) /* Ignore empty path components. */ continue; diff --git a/libs/apr/file_io/unix/filestat.c b/libs/apr/file_io/unix/filestat.c index a34b22c370..d5e92724d5 100644 --- a/libs/apr/file_io/unix/filestat.c +++ b/libs/apr/file_io/unix/filestat.c @@ -14,19 +14,19 @@ * limitations under the License. */ -#include "apr_arch_file_io.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_strings.h" -#include "apr_errno.h" +#include "fspr_arch_file_io.h" +#include "fspr_file_io.h" +#include "fspr_general.h" +#include "fspr_strings.h" +#include "fspr_errno.h" #ifdef HAVE_UTIME #include #endif -static apr_filetype_e filetype_from_mode(mode_t mode) +static fspr_filetype_e filetype_from_mode(mode_t mode) { - apr_filetype_e type; + fspr_filetype_e type; switch (mode & S_IFMT) { case S_IFREG: @@ -67,12 +67,12 @@ static apr_filetype_e filetype_from_mode(mode_t mode) return type; } -static void fill_out_finfo(apr_finfo_t *finfo, struct_stat *info, - apr_int32_t wanted) +static void fill_out_finfo(fspr_finfo_t *finfo, struct_stat *info, + fspr_int32_t wanted) { finfo->valid = APR_FINFO_MIN | APR_FINFO_IDENT | APR_FINFO_NLINK | APR_FINFO_OWNER | APR_FINFO_PROT; - finfo->protection = apr_unix_mode2perms(info->st_mode); + finfo->protection = fspr_unix_mode2perms(info->st_mode); finfo->filetype = filetype_from_mode(info->st_mode); finfo->user = info->st_uid; finfo->group = info->st_gid; @@ -80,9 +80,9 @@ static void fill_out_finfo(apr_finfo_t *finfo, struct_stat *info, finfo->inode = info->st_ino; finfo->device = info->st_dev; finfo->nlink = info->st_nlink; - apr_time_ansi_put(&finfo->atime, info->st_atime); - apr_time_ansi_put(&finfo->mtime, info->st_mtime); - apr_time_ansi_put(&finfo->ctime, info->st_ctime); + fspr_time_ansi_put(&finfo->atime, info->st_atime); + fspr_time_ansi_put(&finfo->mtime, info->st_mtime); + fspr_time_ansi_put(&finfo->ctime, info->st_ctime); /* ### needs to be revisited * if (wanted & APR_FINFO_CSIZE) { * finfo->csize = info->st_blocks * 512; @@ -91,14 +91,14 @@ static void fill_out_finfo(apr_finfo_t *finfo, struct_stat *info, */ } -APR_DECLARE(apr_status_t) apr_file_info_get(apr_finfo_t *finfo, - apr_int32_t wanted, - apr_file_t *thefile) +APR_DECLARE(fspr_status_t) fspr_file_info_get(fspr_finfo_t *finfo, + fspr_int32_t wanted, + fspr_file_t *thefile) { struct_stat info; if (thefile->buffered) { - apr_status_t rv = apr_file_flush(thefile); + fspr_status_t rv = fspr_file_flush(thefile); if (rv != APR_SUCCESS) return rv; } @@ -114,30 +114,30 @@ APR_DECLARE(apr_status_t) apr_file_info_get(apr_finfo_t *finfo, } } -APR_DECLARE(apr_status_t) apr_file_perms_set(const char *fname, - apr_fileperms_t perms) +APR_DECLARE(fspr_status_t) fspr_file_perms_set(const char *fname, + fspr_fileperms_t perms) { - mode_t mode = apr_unix_perms2mode(perms); + mode_t mode = fspr_unix_perms2mode(perms); if (chmod(fname, mode) == -1) return errno; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_file_attrs_set(const char *fname, - apr_fileattrs_t attributes, - apr_fileattrs_t attr_mask, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_file_attrs_set(const char *fname, + fspr_fileattrs_t attributes, + fspr_fileattrs_t attr_mask, + fspr_pool_t *pool) { - apr_status_t status; - apr_finfo_t finfo = {0}; + fspr_status_t status; + fspr_finfo_t finfo = {0}; /* Don't do anything if we can't handle the requested attributes */ if (!(attr_mask & (APR_FILE_ATTR_READONLY | APR_FILE_ATTR_EXECUTABLE))) return APR_SUCCESS; - status = apr_stat(&finfo, fname, APR_FINFO_PROT, pool); + status = fspr_stat(&finfo, fname, APR_FINFO_PROT, pool); if (status) return status; @@ -176,18 +176,18 @@ APR_DECLARE(apr_status_t) apr_file_attrs_set(const char *fname, } } - return apr_file_perms_set(fname, finfo.protection); + return fspr_file_perms_set(fname, finfo.protection); } -APR_DECLARE(apr_status_t) apr_file_mtime_set(const char *fname, - apr_time_t mtime, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_file_mtime_set(const char *fname, + fspr_time_t mtime, + fspr_pool_t *pool) { - apr_status_t status; - apr_finfo_t finfo = {0}; + fspr_status_t status; + fspr_finfo_t finfo = {0}; - status = apr_stat(&finfo, fname, APR_FINFO_ATIME, pool); + status = fspr_stat(&finfo, fname, APR_FINFO_ATIME, pool); if (status) { return status; } @@ -196,10 +196,10 @@ APR_DECLARE(apr_status_t) apr_file_mtime_set(const char *fname, { struct timeval tvp[2]; - tvp[0].tv_sec = apr_time_sec(finfo.atime); - tvp[0].tv_usec = apr_time_usec(finfo.atime); - tvp[1].tv_sec = apr_time_sec(mtime); - tvp[1].tv_usec = apr_time_usec(mtime); + tvp[0].tv_sec = fspr_time_sec(finfo.atime); + tvp[0].tv_usec = fspr_time_usec(finfo.atime); + tvp[1].tv_sec = fspr_time_sec(mtime); + tvp[1].tv_usec = fspr_time_usec(mtime); if (utimes(fname, tvp) == -1) { return errno; @@ -224,9 +224,9 @@ APR_DECLARE(apr_status_t) apr_file_mtime_set(const char *fname, } -APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, +APR_DECLARE(fspr_status_t) fspr_stat(fspr_finfo_t *finfo, const char *fname, - apr_int32_t wanted, apr_pool_t *pool) + fspr_int32_t wanted, fspr_pool_t *pool) { struct_stat info; int srv; diff --git a/libs/apr/file_io/unix/flock.c b/libs/apr/file_io/unix/flock.c index f400a96701..9081b5faf4 100644 --- a/libs/apr/file_io/unix/flock.c +++ b/libs/apr/file_io/unix/flock.c @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "apr_arch_file_io.h" +#include "fspr_arch_file_io.h" #if APR_HAVE_FCNTL_H #include @@ -23,7 +23,7 @@ #include #endif -APR_DECLARE(apr_status_t) apr_file_lock(apr_file_t *thefile, int type) +APR_DECLARE(fspr_status_t) fspr_file_lock(fspr_file_t *thefile, int type) { int rc; @@ -82,7 +82,7 @@ APR_DECLARE(apr_status_t) apr_file_lock(apr_file_t *thefile, int type) return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_file_unlock(apr_file_t *thefile) +APR_DECLARE(fspr_status_t) fspr_file_unlock(fspr_file_t *thefile) { int rc; diff --git a/libs/apr/file_io/unix/fullrw.c b/libs/apr/file_io/unix/fullrw.c index 9ad27ec99b..9503e983ad 100644 --- a/libs/apr/file_io/unix/fullrw.c +++ b/libs/apr/file_io/unix/fullrw.c @@ -14,20 +14,20 @@ * limitations under the License. */ -#include "apr_file_io.h" +#include "fspr_file_io.h" -APR_DECLARE(apr_status_t) apr_file_read_full(apr_file_t *thefile, void *buf, - apr_size_t nbytes, - apr_size_t *bytes_read) +APR_DECLARE(fspr_status_t) fspr_file_read_full(fspr_file_t *thefile, void *buf, + fspr_size_t nbytes, + fspr_size_t *bytes_read) { - apr_status_t status; - apr_size_t total_read = 0; + fspr_status_t status; + fspr_size_t total_read = 0; do { - apr_size_t amt = nbytes; + fspr_size_t amt = nbytes; - status = apr_file_read(thefile, buf, &amt); + status = fspr_file_read(thefile, buf, &amt); buf = (char *)buf + amt; nbytes -= amt; total_read += amt; @@ -39,18 +39,18 @@ APR_DECLARE(apr_status_t) apr_file_read_full(apr_file_t *thefile, void *buf, return status; } -APR_DECLARE(apr_status_t) apr_file_write_full(apr_file_t *thefile, +APR_DECLARE(fspr_status_t) fspr_file_write_full(fspr_file_t *thefile, const void *buf, - apr_size_t nbytes, - apr_size_t *bytes_written) + fspr_size_t nbytes, + fspr_size_t *bytes_written) { - apr_status_t status; - apr_size_t total_written = 0; + fspr_status_t status; + fspr_size_t total_written = 0; do { - apr_size_t amt = nbytes; + fspr_size_t amt = nbytes; - status = apr_file_write(thefile, buf, &amt); + status = fspr_file_write(thefile, buf, &amt); buf = (char *)buf + amt; nbytes -= amt; total_written += amt; @@ -62,18 +62,18 @@ APR_DECLARE(apr_status_t) apr_file_write_full(apr_file_t *thefile, return status; } -APR_DECLARE(apr_status_t) apr_file_writev_full(apr_file_t *thefile, +APR_DECLARE(fspr_status_t) fspr_file_writev_full(fspr_file_t *thefile, const struct iovec *vec, - apr_size_t nvec, - apr_size_t *bytes_written) + fspr_size_t nvec, + fspr_size_t *bytes_written) { - apr_status_t rv = APR_SUCCESS; - apr_size_t i; - apr_size_t amt = 0; - apr_size_t total = 0; + fspr_status_t rv = APR_SUCCESS; + fspr_size_t i; + fspr_size_t amt = 0; + fspr_size_t total = 0; for (i = 0; i < nvec && rv == APR_SUCCESS; i++) { - rv = apr_file_write_full(thefile, vec[i].iov_base, + rv = fspr_file_write_full(thefile, vec[i].iov_base, vec[i].iov_len, &amt); total += amt; } diff --git a/libs/apr/file_io/unix/mktemp.c b/libs/apr/file_io/unix/mktemp.c index 73c61dcfce..2ea22e01b9 100644 --- a/libs/apr/file_io/unix/mktemp.c +++ b/libs/apr/file_io/unix/mktemp.c @@ -46,11 +46,11 @@ * SUCH DAMAGE. */ -#include "apr_private.h" -#include "apr_file_io.h" /* prototype of apr_mkstemp() */ -#include "apr_strings.h" /* prototype of apr_mkstemp() */ -#include "apr_arch_file_io.h" /* prototype of apr_mkstemp() */ -#include "apr_portable.h" /* for apr_os_file_put() */ +#include "fspr_private.h" +#include "fspr_file_io.h" /* prototype of fspr_mkstemp() */ +#include "fspr_strings.h" /* prototype of fspr_mkstemp() */ +#include "fspr_arch_file_io.h" /* prototype of fspr_mkstemp() */ +#include "fspr_portable.h" /* for fspr_os_file_put() */ #ifndef HAVE_MKSTEMP @@ -89,18 +89,18 @@ static const unsigned char padchar[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; -static apr_uint32_t randseed=0; +static fspr_uint32_t randseed=0; -static int gettemp(char *path, apr_file_t **doopen, apr_int32_t flags, apr_pool_t *p) +static int gettemp(char *path, fspr_file_t **doopen, fspr_int32_t flags, fspr_pool_t *p) { register char *start, *trv, *suffp; char *pad; - apr_finfo_t sbuf; - apr_status_t rv; - apr_uint32_t randnum; + fspr_finfo_t sbuf; + fspr_status_t rv; + fspr_uint32_t randnum; if (randseed==0) { - randseed = (int)apr_time_now(); + randseed = (int)fspr_time_now(); seedrandom(randseed); } @@ -127,7 +127,7 @@ static int gettemp(char *path, apr_file_t **doopen, apr_int32_t flags, apr_pool_ break; if (*trv == '/') { *trv = '\0'; - rv = apr_stat(&sbuf, path, APR_FINFO_TYPE, p); + rv = fspr_stat(&sbuf, path, APR_FINFO_TYPE, p); *trv = '/'; if (rv != APR_SUCCESS) return rv; @@ -139,7 +139,7 @@ static int gettemp(char *path, apr_file_t **doopen, apr_int32_t flags, apr_pool_ } for (;;) { - if ((rv = apr_file_open(doopen, path, flags, + if ((rv = fspr_file_open(doopen, path, flags, APR_UREAD | APR_UWRITE, p)) == APR_SUCCESS) return APR_SUCCESS; if (!APR_STATUS_IS_EEXIST(rv)) @@ -172,7 +172,7 @@ static int gettemp(char *path, apr_file_t **doopen, apr_int32_t flags, apr_pool_ #endif #endif /* !defined(HAVE_MKSTEMP) */ -APR_DECLARE(apr_status_t) apr_file_mktemp(apr_file_t **fp, char *template, apr_int32_t flags, apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_file_mktemp(fspr_file_t **fp, char *template, fspr_int32_t flags, fspr_pool_t *p) { #ifdef HAVE_MKSTEMP int fd; @@ -197,13 +197,13 @@ APR_DECLARE(apr_status_t) apr_file_mktemp(apr_file_t **fp, char *template, apr_i * * We either have to unset the flags, or fix up the fd and other * xthread and inherit bits appropriately. Since gettemp() above - * calls apr_file_open, our flags are respected in that code path. + * calls fspr_file_open, our flags are respected in that code path. */ - apr_os_file_put(fp, &fd, flags, p); - (*fp)->fname = apr_pstrdup(p, template); + fspr_os_file_put(fp, &fd, flags, p); + (*fp)->fname = fspr_pstrdup(p, template); - apr_pool_cleanup_register((*fp)->pool, (void *)(*fp), - apr_unix_file_cleanup, apr_unix_file_cleanup); + fspr_pool_cleanup_register((*fp)->pool, (void *)(*fp), + fspr_unix_file_cleanup, fspr_unix_file_cleanup); #endif return APR_SUCCESS; } diff --git a/libs/apr/file_io/unix/open.c b/libs/apr/file_io/unix/open.c index ef3b9670ef..c2b9cd1c54 100644 --- a/libs/apr/file_io/unix/open.c +++ b/libs/apr/file_io/unix/open.c @@ -14,25 +14,25 @@ * limitations under the License. */ -#include "apr_arch_file_io.h" -#include "apr_strings.h" -#include "apr_portable.h" -#include "apr_thread_mutex.h" -#include "apr_arch_inherit.h" +#include "fspr_arch_file_io.h" +#include "fspr_strings.h" +#include "fspr_portable.h" +#include "fspr_thread_mutex.h" +#include "fspr_arch_inherit.h" #ifdef NETWARE #include "nks/dirio.h" -#include "apr_hash.h" +#include "fspr_hash.h" #include "fsio.h" #endif -apr_status_t apr_unix_file_cleanup(void *thefile) +fspr_status_t fspr_unix_file_cleanup(void *thefile) { - apr_file_t *file = thefile; - apr_status_t flush_rv = APR_SUCCESS, rv = APR_SUCCESS; + fspr_file_t *file = thefile; + fspr_status_t flush_rv = APR_SUCCESS, rv = APR_SUCCESS; if (file->buffered) { - flush_rv = apr_file_flush(file); + flush_rv = fspr_file_flush(file); } if (close(file->filedes) == 0) { file->filedes = -1; @@ -41,7 +41,7 @@ apr_status_t apr_unix_file_cleanup(void *thefile) } #if APR_HAS_THREADS if (file->thlock) { - rv = apr_thread_mutex_destroy(file->thlock); + rv = fspr_thread_mutex_destroy(file->thlock); } #endif } @@ -51,9 +51,9 @@ apr_status_t apr_unix_file_cleanup(void *thefile) } #ifndef WAITIO_USES_POLL if (file->pollset != NULL) { - int pollset_rv = apr_pollset_destroy(file->pollset); + int pollset_rv = fspr_pollset_destroy(file->pollset); /* If the file close failed, return its error value, - * not apr_pollset_destroy()'s. + * not fspr_pollset_destroy()'s. */ if (rv == APR_SUCCESS) { rv = pollset_rv; @@ -63,17 +63,17 @@ apr_status_t apr_unix_file_cleanup(void *thefile) return rv != APR_SUCCESS ? rv : flush_rv; } -APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new, +APR_DECLARE(fspr_status_t) fspr_file_open(fspr_file_t **new, const char *fname, - apr_int32_t flag, - apr_fileperms_t perm, - apr_pool_t *pool) + fspr_int32_t flag, + fspr_fileperms_t perm, + fspr_pool_t *pool) { - apr_os_file_t fd; + fspr_os_file_t fd; int oflags = 0; #if APR_HAS_THREADS - apr_thread_mutex_t *thlock; - apr_status_t rv; + fspr_thread_mutex_t *thlock; + fspr_status_t rv; #endif if ((flag & APR_READ) && (flag & APR_WRITE)) { @@ -121,7 +121,7 @@ APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new, #if APR_HAS_THREADS if ((flag & APR_BUFFERED) && (flag & APR_XTHREAD)) { - rv = apr_thread_mutex_create(&thlock, + rv = fspr_thread_mutex_create(&thlock, APR_THREAD_MUTEX_DEFAULT, pool); if (rv) { return rv; @@ -133,24 +133,24 @@ APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new, fd = open(fname, oflags, 0666); } else { - fd = open(fname, oflags, apr_unix_perms2mode(perm)); + fd = open(fname, oflags, fspr_unix_perms2mode(perm)); } if (fd < 0) { return errno; } - (*new) = (apr_file_t *)apr_pcalloc(pool, sizeof(apr_file_t)); + (*new) = (fspr_file_t *)fspr_pcalloc(pool, sizeof(fspr_file_t)); (*new)->pool = pool; (*new)->flags = flag; (*new)->filedes = fd; - (*new)->fname = apr_pstrdup(pool, fname); + (*new)->fname = fspr_pstrdup(pool, fname); (*new)->blocking = BLK_ON; (*new)->buffered = (flag & APR_BUFFERED) > 0; if ((*new)->buffered) { - (*new)->buffer = apr_palloc(pool, APR_FILE_BUFSIZE); + (*new)->buffer = fspr_palloc(pool, APR_FILE_BUFSIZE); #if APR_HAS_THREADS if ((*new)->flags & APR_XTHREAD) { (*new)->thlock = thlock; @@ -170,25 +170,25 @@ APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new, (*new)->dataRead = 0; (*new)->direction = 0; #ifndef WAITIO_USES_POLL - /* Start out with no pollset. apr_wait_for_io_or_timeout() will + /* Start out with no pollset. fspr_wait_for_io_or_timeout() will * initialize the pollset if needed. */ (*new)->pollset = NULL; #endif if (!(flag & APR_FILE_NOCLEANUP)) { - apr_pool_cleanup_register((*new)->pool, (void *)(*new), - apr_unix_file_cleanup, - apr_unix_file_cleanup); + fspr_pool_cleanup_register((*new)->pool, (void *)(*new), + fspr_unix_file_cleanup, + fspr_unix_file_cleanup); } return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_file_close(apr_file_t *file) +APR_DECLARE(fspr_status_t) fspr_file_close(fspr_file_t *file) { - return apr_pool_cleanup_run(file->pool, file, apr_unix_file_cleanup); + return fspr_pool_cleanup_run(file->pool, file, fspr_unix_file_cleanup); } -APR_DECLARE(apr_status_t) apr_file_remove(const char *path, apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_file_remove(const char *path, fspr_pool_t *pool) { if (unlink(path) == 0) { return APR_SUCCESS; @@ -198,9 +198,9 @@ APR_DECLARE(apr_status_t) apr_file_remove(const char *path, apr_pool_t *pool) } } -APR_DECLARE(apr_status_t) apr_file_rename(const char *from_path, +APR_DECLARE(fspr_status_t) fspr_file_rename(const char *from_path, const char *to_path, - apr_pool_t *p) + fspr_pool_t *p) { if (rename(from_path, to_path) != 0) { return errno; @@ -208,20 +208,20 @@ APR_DECLARE(apr_status_t) apr_file_rename(const char *from_path, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_os_file_get(apr_os_file_t *thefile, - apr_file_t *file) +APR_DECLARE(fspr_status_t) fspr_os_file_get(fspr_os_file_t *thefile, + fspr_file_t *file) { *thefile = file->filedes; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_os_file_put(apr_file_t **file, - apr_os_file_t *thefile, - apr_int32_t flags, apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_os_file_put(fspr_file_t **file, + fspr_os_file_t *thefile, + fspr_int32_t flags, fspr_pool_t *pool) { int *dafile = thefile; - (*file) = apr_pcalloc(pool, sizeof(apr_file_t)); + (*file) = fspr_pcalloc(pool, sizeof(fspr_file_t)); (*file)->pool = pool; (*file)->eof_hit = 0; (*file)->blocking = BLK_UNKNOWN; /* in case it is a pipe */ @@ -232,18 +232,18 @@ APR_DECLARE(apr_status_t) apr_os_file_put(apr_file_t **file, (*file)->buffered = (flags & APR_BUFFERED) > 0; #ifndef WAITIO_USES_POLL - /* Start out with no pollset. apr_wait_for_io_or_timeout() will + /* Start out with no pollset. fspr_wait_for_io_or_timeout() will * initialize the pollset if needed. */ (*file)->pollset = NULL; #endif if ((*file)->buffered) { - (*file)->buffer = apr_palloc(pool, APR_FILE_BUFSIZE); + (*file)->buffer = fspr_palloc(pool, APR_FILE_BUFSIZE); #if APR_HAS_THREADS if ((*file)->flags & APR_XTHREAD) { - apr_status_t rv; - rv = apr_thread_mutex_create(&((*file)->thlock), + fspr_status_t rv; + rv = fspr_thread_mutex_create(&((*file)->thlock), APR_THREAD_MUTEX_DEFAULT, pool); if (rv) { return rv; @@ -254,7 +254,7 @@ APR_DECLARE(apr_status_t) apr_os_file_put(apr_file_t **file, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_file_eof(apr_file_t *fptr) +APR_DECLARE(fspr_status_t) fspr_file_eof(fspr_file_t *fptr) { if (fptr->eof_hit == 1) { return APR_EOF; @@ -262,32 +262,32 @@ APR_DECLARE(apr_status_t) apr_file_eof(apr_file_t *fptr) return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_file_open_stderr(apr_file_t **thefile, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_file_open_stderr(fspr_file_t **thefile, + fspr_pool_t *pool) { int fd = STDERR_FILENO; - return apr_os_file_put(thefile, &fd, 0, pool); + return fspr_os_file_put(thefile, &fd, 0, pool); } -APR_DECLARE(apr_status_t) apr_file_open_stdout(apr_file_t **thefile, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_file_open_stdout(fspr_file_t **thefile, + fspr_pool_t *pool) { int fd = STDOUT_FILENO; - return apr_os_file_put(thefile, &fd, 0, pool); + return fspr_os_file_put(thefile, &fd, 0, pool); } -APR_DECLARE(apr_status_t) apr_file_open_stdin(apr_file_t **thefile, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_file_open_stdin(fspr_file_t **thefile, + fspr_pool_t *pool) { int fd = STDIN_FILENO; - return apr_os_file_put(thefile, &fd, 0, pool); + return fspr_os_file_put(thefile, &fd, 0, pool); } -APR_IMPLEMENT_INHERIT_SET(file, flags, pool, apr_unix_file_cleanup) +APR_IMPLEMENT_INHERIT_SET(file, flags, pool, fspr_unix_file_cleanup) -APR_IMPLEMENT_INHERIT_UNSET(file, flags, pool, apr_unix_file_cleanup) +APR_IMPLEMENT_INHERIT_UNSET(file, flags, pool, fspr_unix_file_cleanup) APR_POOL_IMPLEMENT_ACCESSOR(file) diff --git a/libs/apr/file_io/unix/pipe.c b/libs/apr/file_io/unix/pipe.c index 5411f5d407..66086fbbf0 100644 --- a/libs/apr/file_io/unix/pipe.c +++ b/libs/apr/file_io/unix/pipe.c @@ -14,11 +14,11 @@ * limitations under the License. */ -#include "apr_arch_file_io.h" -#include "apr_strings.h" -#include "apr_portable.h" +#include "fspr_arch_file_io.h" +#include "fspr_strings.h" +#include "fspr_portable.h" -#include "apr_arch_inherit.h" +#include "fspr_arch_inherit.h" /* Figure out how to get pipe block/nonblock on BeOS... * Basically, BONE7 changed things again so that ioctl didn't work, @@ -33,7 +33,7 @@ #endif #endif -static apr_status_t pipeblock(apr_file_t *thepipe) +static fspr_status_t pipeblock(fspr_file_t *thepipe) { #if !BEOS_BLOCKING int fd_flags; @@ -69,7 +69,7 @@ static apr_status_t pipeblock(apr_file_t *thepipe) return APR_SUCCESS; } -static apr_status_t pipenonblock(apr_file_t *thepipe) +static fspr_status_t pipenonblock(fspr_file_t *thepipe) { #if !BEOS_BLOCKING int fd_flags = fcntl(thepipe->filedes, F_GETFL, 0); @@ -105,7 +105,7 @@ static apr_status_t pipenonblock(apr_file_t *thepipe) return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_file_pipe_timeout_set(apr_file_t *thepipe, apr_interval_time_t timeout) +APR_DECLARE(fspr_status_t) fspr_file_pipe_timeout_set(fspr_file_t *thepipe, fspr_interval_time_t timeout) { if (thepipe->is_pipe == 1) { thepipe->timeout = timeout; @@ -124,7 +124,7 @@ APR_DECLARE(apr_status_t) apr_file_pipe_timeout_set(apr_file_t *thepipe, apr_int return APR_EINVAL; } -APR_DECLARE(apr_status_t) apr_file_pipe_timeout_get(apr_file_t *thepipe, apr_interval_time_t *timeout) +APR_DECLARE(fspr_status_t) fspr_file_pipe_timeout_get(fspr_file_t *thepipe, fspr_interval_time_t *timeout) { if (thepipe->is_pipe == 1) { *timeout = thepipe->timeout; @@ -133,14 +133,14 @@ APR_DECLARE(apr_status_t) apr_file_pipe_timeout_get(apr_file_t *thepipe, apr_int return APR_EINVAL; } -APR_DECLARE(apr_status_t) apr_os_pipe_put_ex(apr_file_t **file, - apr_os_file_t *thefile, +APR_DECLARE(fspr_status_t) fspr_os_pipe_put_ex(fspr_file_t **file, + fspr_os_file_t *thefile, int register_cleanup, - apr_pool_t *pool) + fspr_pool_t *pool) { int *dafile = thefile; - (*file) = apr_pcalloc(pool, sizeof(apr_file_t)); + (*file) = fspr_pcalloc(pool, sizeof(fspr_file_t)); (*file)->pool = pool; (*file)->eof_hit = 0; (*file)->is_pipe = 1; @@ -156,12 +156,12 @@ APR_DECLARE(apr_status_t) apr_os_pipe_put_ex(apr_file_t **file, (*file)->thlock = NULL; #endif if (register_cleanup) { - apr_pool_cleanup_register((*file)->pool, (void *)(*file), - apr_unix_file_cleanup, - apr_pool_cleanup_null); + fspr_pool_cleanup_register((*file)->pool, (void *)(*file), + fspr_unix_file_cleanup, + fspr_pool_cleanup_null); } #ifndef WAITIO_USES_POLL - /* Start out with no pollset. apr_wait_for_io_or_timeout() will + /* Start out with no pollset. fspr_wait_for_io_or_timeout() will * initialize the pollset if needed. */ (*file)->pollset = NULL; @@ -169,14 +169,14 @@ APR_DECLARE(apr_status_t) apr_os_pipe_put_ex(apr_file_t **file, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_os_pipe_put(apr_file_t **file, - apr_os_file_t *thefile, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_os_pipe_put(fspr_file_t **file, + fspr_os_file_t *thefile, + fspr_pool_t *pool) { - return apr_os_pipe_put_ex(file, thefile, 0, pool); + return fspr_os_pipe_put_ex(file, thefile, 0, pool); } -APR_DECLARE(apr_status_t) apr_file_pipe_create(apr_file_t **in, apr_file_t **out, apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_file_pipe_create(fspr_file_t **in, fspr_file_t **out, fspr_pool_t *pool) { int filedes[2]; @@ -184,7 +184,7 @@ APR_DECLARE(apr_status_t) apr_file_pipe_create(apr_file_t **in, apr_file_t **out return errno; } - (*in) = (apr_file_t *)apr_pcalloc(pool, sizeof(apr_file_t)); + (*in) = (fspr_file_t *)fspr_pcalloc(pool, sizeof(fspr_file_t)); (*in)->pool = pool; (*in)->filedes = filedes[0]; (*in)->is_pipe = 1; @@ -200,7 +200,7 @@ APR_DECLARE(apr_status_t) apr_file_pipe_create(apr_file_t **in, apr_file_t **out #ifndef WAITIO_USES_POLL (*in)->pollset = NULL; #endif - (*out) = (apr_file_t *)apr_pcalloc(pool, sizeof(apr_file_t)); + (*out) = (fspr_file_t *)fspr_pcalloc(pool, sizeof(fspr_file_t)); (*out)->pool = pool; (*out)->filedes = filedes[1]; (*out)->is_pipe = 1; @@ -215,17 +215,17 @@ APR_DECLARE(apr_status_t) apr_file_pipe_create(apr_file_t **in, apr_file_t **out #ifndef WAITIO_USES_POLL (*out)->pollset = NULL; #endif - apr_pool_cleanup_register((*in)->pool, (void *)(*in), apr_unix_file_cleanup, - apr_pool_cleanup_null); - apr_pool_cleanup_register((*out)->pool, (void *)(*out), apr_unix_file_cleanup, - apr_pool_cleanup_null); + fspr_pool_cleanup_register((*in)->pool, (void *)(*in), fspr_unix_file_cleanup, + fspr_pool_cleanup_null); + fspr_pool_cleanup_register((*out)->pool, (void *)(*out), fspr_unix_file_cleanup, + fspr_pool_cleanup_null); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_file_namedpipe_create(const char *filename, - apr_fileperms_t perm, apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_file_namedpipe_create(const char *filename, + fspr_fileperms_t perm, fspr_pool_t *pool) { - mode_t mode = apr_unix_perms2mode(perm); + mode_t mode = fspr_unix_perms2mode(perm); if (mkfifo(filename, mode) == -1) { return errno; diff --git a/libs/apr/file_io/unix/readwrite.c b/libs/apr/file_io/unix/readwrite.c index 1721582ba8..2006b6f274 100644 --- a/libs/apr/file_io/unix/readwrite.c +++ b/libs/apr/file_io/unix/readwrite.c @@ -14,10 +14,10 @@ * limitations under the License. */ -#include "apr_arch_file_io.h" -#include "apr_strings.h" -#include "apr_thread_mutex.h" -#include "apr_support.h" +#include "fspr_arch_file_io.h" +#include "fspr_strings.h" +#include "fspr_thread_mutex.h" +#include "fspr_support.h" /* The only case where we don't use wait_for_io_or_timeout is on * pre-BONE BeOS, so this check should be sufficient and simpler */ @@ -25,10 +25,10 @@ #define USE_WAIT_FOR_IO #endif -APR_DECLARE(apr_status_t) apr_file_read(apr_file_t *thefile, void *buf, apr_size_t *nbytes) +APR_DECLARE(fspr_status_t) fspr_file_read(fspr_file_t *thefile, void *buf, fspr_size_t *nbytes) { - apr_ssize_t rv; - apr_size_t bytes_read; + fspr_ssize_t rv; + fspr_size_t bytes_read; if (*nbytes <= 0) { *nbytes = 0; @@ -37,21 +37,21 @@ APR_DECLARE(apr_status_t) apr_file_read(apr_file_t *thefile, void *buf, apr_size if (thefile->buffered) { char *pos = (char *)buf; - apr_uint64_t blocksize; - apr_uint64_t size = *nbytes; + fspr_uint64_t blocksize; + fspr_uint64_t size = *nbytes; #if APR_HAS_THREADS if (thefile->thlock) { - apr_thread_mutex_lock(thefile->thlock); + fspr_thread_mutex_lock(thefile->thlock); } #endif if (thefile->direction == 1) { - rv = apr_file_flush(thefile); + rv = fspr_file_flush(thefile); if (rv) { #if APR_HAS_THREADS if (thefile->thlock) { - apr_thread_mutex_unlock(thefile->thlock); + fspr_thread_mutex_unlock(thefile->thlock); } #endif return rv; @@ -98,7 +98,7 @@ APR_DECLARE(apr_status_t) apr_file_read(apr_file_t *thefile, void *buf, apr_size } #if APR_HAS_THREADS if (thefile->thlock) { - apr_thread_mutex_unlock(thefile->thlock); + fspr_thread_mutex_unlock(thefile->thlock); } #endif return rv; @@ -124,7 +124,7 @@ APR_DECLARE(apr_status_t) apr_file_read(apr_file_t *thefile, void *buf, apr_size if (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK) && thefile->timeout != 0) { - apr_status_t arv = apr_wait_for_io_or_timeout(thefile, NULL, 1); + fspr_status_t arv = fspr_wait_for_io_or_timeout(thefile, NULL, 1); if (arv != APR_SUCCESS) { *nbytes = bytes_read; return arv; @@ -149,9 +149,9 @@ APR_DECLARE(apr_status_t) apr_file_read(apr_file_t *thefile, void *buf, apr_size } } -APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, apr_size_t *nbytes) +APR_DECLARE(fspr_status_t) fspr_file_write(fspr_file_t *thefile, const void *buf, fspr_size_t *nbytes) { - apr_size_t rv; + fspr_size_t rv; if (thefile->buffered) { char *pos = (char *)buf; @@ -160,7 +160,7 @@ APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, a #if APR_HAS_THREADS if (thefile->thlock) { - apr_thread_mutex_lock(thefile->thlock); + fspr_thread_mutex_lock(thefile->thlock); } #endif @@ -168,7 +168,7 @@ APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, a /* Position file pointer for writing at the offset we are * logically reading from */ - apr_int64_t offset = thefile->filePtr - thefile->dataRead + thefile->bufpos; + fspr_int64_t offset = thefile->filePtr - thefile->dataRead + thefile->bufpos; if (offset != thefile->filePtr) lseek(thefile->filedes, offset, SEEK_SET); thefile->bufpos = thefile->dataRead = 0; @@ -178,7 +178,7 @@ APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, a rv = 0; while (rv == 0 && size > 0) { if (thefile->bufpos == APR_FILE_BUFSIZE) /* write buffer is full*/ - rv = apr_file_flush(thefile); + rv = fspr_file_flush(thefile); blocksize = size > APR_FILE_BUFSIZE - thefile->bufpos ? APR_FILE_BUFSIZE - thefile->bufpos : size; @@ -190,7 +190,7 @@ APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, a #if APR_HAS_THREADS if (thefile->thlock) { - apr_thread_mutex_unlock(thefile->thlock); + fspr_thread_mutex_unlock(thefile->thlock); } #endif return rv; @@ -198,12 +198,12 @@ APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, a else { do { rv = write(thefile->filedes, buf, *nbytes); - } while (rv == (apr_size_t)-1 && errno == EINTR); + } while (rv == (fspr_size_t)-1 && errno == EINTR); #ifdef USE_WAIT_FOR_IO - if (rv == (apr_size_t)-1 && + if (rv == (fspr_size_t)-1 && (errno == EAGAIN || errno == EWOULDBLOCK) && thefile->timeout != 0) { - apr_status_t arv = apr_wait_for_io_or_timeout(thefile, NULL, 0); + fspr_status_t arv = fspr_wait_for_io_or_timeout(thefile, NULL, 0); if (arv != APR_SUCCESS) { *nbytes = 0; return arv; @@ -212,8 +212,8 @@ APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, a do { do { rv = write(thefile->filedes, buf, *nbytes); - } while (rv == (apr_size_t)-1 && errno == EINTR); - if (rv == (apr_size_t)-1 && + } while (rv == (fspr_size_t)-1 && errno == EINTR); + if (rv == (fspr_size_t)-1 && (errno == EAGAIN || errno == EWOULDBLOCK)) { *nbytes /= 2; /* yes, we'll loop if kernel lied * and we can't even write 1 byte @@ -226,7 +226,7 @@ APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, a } } #endif - if (rv == (apr_size_t)-1) { + if (rv == (fspr_size_t)-1) { (*nbytes) = 0; return errno; } @@ -235,8 +235,8 @@ APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, a } } -APR_DECLARE(apr_status_t) apr_file_writev(apr_file_t *thefile, const struct iovec *vec, - apr_size_t nvec, apr_size_t *nbytes) +APR_DECLARE(fspr_status_t) fspr_file_writev(fspr_file_t *thefile, const struct iovec *vec, + fspr_size_t nvec, fspr_size_t *nbytes) { #ifdef HAVE_WRITEV int bytes; @@ -261,49 +261,49 @@ APR_DECLARE(apr_status_t) apr_file_writev(apr_file_t *thefile, const struct iove * The only reasonable option, that maintains the semantics of a real * writev(), is to only write the first iovec. Callers of file_writev() * must deal with partial writes as they normally would. If you want to - * ensure an entire iovec is written, use apr_file_writev_full(). + * ensure an entire iovec is written, use fspr_file_writev_full(). */ *nbytes = vec[0].iov_len; - return apr_file_write(thefile, vec[0].iov_base, nbytes); + return fspr_file_write(thefile, vec[0].iov_base, nbytes); #endif } -APR_DECLARE(apr_status_t) apr_file_putc(char ch, apr_file_t *thefile) +APR_DECLARE(fspr_status_t) fspr_file_putc(char ch, fspr_file_t *thefile) { - apr_size_t nbytes = 1; + fspr_size_t nbytes = 1; - return apr_file_write(thefile, &ch, &nbytes); + return fspr_file_write(thefile, &ch, &nbytes); } -APR_DECLARE(apr_status_t) apr_file_ungetc(char ch, apr_file_t *thefile) +APR_DECLARE(fspr_status_t) fspr_file_ungetc(char ch, fspr_file_t *thefile) { thefile->ungetchar = (unsigned char)ch; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_file_getc(char *ch, apr_file_t *thefile) +APR_DECLARE(fspr_status_t) fspr_file_getc(char *ch, fspr_file_t *thefile) { - apr_size_t nbytes = 1; + fspr_size_t nbytes = 1; - return apr_file_read(thefile, ch, &nbytes); + return fspr_file_read(thefile, ch, &nbytes); } -APR_DECLARE(apr_status_t) apr_file_puts(const char *str, apr_file_t *thefile) +APR_DECLARE(fspr_status_t) fspr_file_puts(const char *str, fspr_file_t *thefile) { - return apr_file_write_full(thefile, str, strlen(str), NULL); + return fspr_file_write_full(thefile, str, strlen(str), NULL); } -APR_DECLARE(apr_status_t) apr_file_flush(apr_file_t *thefile) +APR_DECLARE(fspr_status_t) fspr_file_flush(fspr_file_t *thefile) { if (thefile->buffered) { - apr_int64_t written = 0; + fspr_int64_t written = 0; if (thefile->direction == 1 && thefile->bufpos) { do { written = write(thefile->filedes, thefile->buffer, thefile->bufpos); - } while (written == (apr_int64_t)-1 && errno == EINTR); - if (written == (apr_int64_t)-1) { + } while (written == (fspr_int64_t)-1 && errno == EINTR); + if (written == (fspr_int64_t)-1) { return errno; } thefile->filePtr += written; @@ -316,10 +316,10 @@ APR_DECLARE(apr_status_t) apr_file_flush(apr_file_t *thefile) return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_file_gets(char *str, int len, apr_file_t *thefile) +APR_DECLARE(fspr_status_t) fspr_file_gets(char *str, int len, fspr_file_t *thefile) { - apr_status_t rv = APR_SUCCESS; /* get rid of gcc warning */ - apr_size_t nbytes; + fspr_status_t rv = APR_SUCCESS; /* get rid of gcc warning */ + fspr_size_t nbytes; const char *str_start = str; char *final = str + len - 1; @@ -330,22 +330,22 @@ APR_DECLARE(apr_status_t) apr_file_gets(char *str, int len, apr_file_t *thefile) } /* If we have an underlying buffer, we can be *much* more efficient - * and skip over the apr_file_read calls. + * and skip over the fspr_file_read calls. */ if (thefile->buffered) { #if APR_HAS_THREADS if (thefile->thlock) { - apr_thread_mutex_lock(thefile->thlock); + fspr_thread_mutex_lock(thefile->thlock); } #endif if (thefile->direction == 1) { - rv = apr_file_flush(thefile); + rv = fspr_file_flush(thefile); if (rv) { #if APR_HAS_THREADS if (thefile->thlock) { - apr_thread_mutex_unlock(thefile->thlock); + fspr_thread_mutex_unlock(thefile->thlock); } #endif return rv; @@ -357,14 +357,14 @@ APR_DECLARE(apr_status_t) apr_file_gets(char *str, int len, apr_file_t *thefile) } while (str < final) { /* leave room for trailing '\0' */ - /* Force ungetc leftover to call apr_file_read. */ + /* Force ungetc leftover to call fspr_file_read. */ if (thefile->bufpos < thefile->dataRead && thefile->ungetchar == -1) { *str = thefile->buffer[thefile->bufpos++]; } else { nbytes = 1; - rv = apr_file_read(thefile, str, &nbytes); + rv = fspr_file_read(thefile, str, &nbytes); if (rv != APR_SUCCESS) { break; } @@ -378,14 +378,14 @@ APR_DECLARE(apr_status_t) apr_file_gets(char *str, int len, apr_file_t *thefile) #if APR_HAS_THREADS if (thefile->thlock) { - apr_thread_mutex_unlock(thefile->thlock); + fspr_thread_mutex_unlock(thefile->thlock); } #endif } else { while (str < final) { /* leave room for trailing '\0' */ nbytes = 1; - rv = apr_file_read(thefile, str, &nbytes); + rv = fspr_file_read(thefile, str, &nbytes); if (rv != APR_SUCCESS) { break; } @@ -410,17 +410,17 @@ APR_DECLARE(apr_status_t) apr_file_gets(char *str, int len, apr_file_t *thefile) return rv; } -struct apr_file_printf_data { - apr_vformatter_buff_t vbuff; - apr_file_t *fptr; +struct fspr_file_printf_data { + fspr_vformatter_buff_t vbuff; + fspr_file_t *fptr; char *buf; }; -static int file_printf_flush(apr_vformatter_buff_t *buff) +static int file_printf_flush(fspr_vformatter_buff_t *buff) { - struct apr_file_printf_data *data = (struct apr_file_printf_data *)buff; + struct fspr_file_printf_data *data = (struct fspr_file_printf_data *)buff; - if (apr_file_write_full(data->fptr, data->buf, + if (fspr_file_write_full(data->fptr, data->buf, data->vbuff.curpos - data->buf, NULL)) { return -1; } @@ -429,10 +429,10 @@ static int file_printf_flush(apr_vformatter_buff_t *buff) return 0; } -APR_DECLARE_NONSTD(int) apr_file_printf(apr_file_t *fptr, +APR_DECLARE_NONSTD(int) fspr_file_printf(fspr_file_t *fptr, const char *format, ...) { - struct apr_file_printf_data data; + struct fspr_file_printf_data data; va_list ap; int count; @@ -445,10 +445,10 @@ APR_DECLARE_NONSTD(int) apr_file_printf(apr_file_t *fptr, data.vbuff.endpos = data.buf + HUGE_STRING_LEN; data.fptr = fptr; va_start(ap, format); - count = apr_vformatter(file_printf_flush, - (apr_vformatter_buff_t *)&data, format, ap); - /* apr_vformatter does not call flush for the last bits */ - if (count >= 0) file_printf_flush((apr_vformatter_buff_t *)&data); + count = fspr_vformatter(file_printf_flush, + (fspr_vformatter_buff_t *)&data, format, ap); + /* fspr_vformatter does not call flush for the last bits */ + if (count >= 0) file_printf_flush((fspr_vformatter_buff_t *)&data); va_end(ap); diff --git a/libs/apr/file_io/unix/seek.c b/libs/apr/file_io/unix/seek.c index d1fe484627..c477d86e93 100644 --- a/libs/apr/file_io/unix/seek.c +++ b/libs/apr/file_io/unix/seek.c @@ -14,15 +14,15 @@ * limitations under the License. */ -#include "apr_arch_file_io.h" +#include "fspr_arch_file_io.h" -static apr_status_t setptr(apr_file_t *thefile, apr_off_t pos ) +static fspr_status_t setptr(fspr_file_t *thefile, fspr_off_t pos ) { - apr_off_t newbufpos; - apr_status_t rv; + fspr_off_t newbufpos; + fspr_status_t rv; if (thefile->direction == 1) { - rv = apr_file_flush(thefile); + rv = fspr_file_flush(thefile); if (rv) { return rv; } @@ -49,15 +49,15 @@ static apr_status_t setptr(apr_file_t *thefile, apr_off_t pos ) } -APR_DECLARE(apr_status_t) apr_file_seek(apr_file_t *thefile, apr_seek_where_t where, apr_off_t *offset) +APR_DECLARE(fspr_status_t) fspr_file_seek(fspr_file_t *thefile, fspr_seek_where_t where, fspr_off_t *offset) { - apr_off_t rv; + fspr_off_t rv; thefile->eof_hit = 0; if (thefile->buffered) { int rc = EINVAL; - apr_finfo_t finfo; + fspr_finfo_t finfo; switch (where) { case APR_SET: @@ -69,7 +69,7 @@ APR_DECLARE(apr_status_t) apr_file_seek(apr_file_t *thefile, apr_seek_where_t wh break; case APR_END: - rc = apr_file_info_get(&finfo, APR_FINFO_SIZE, thefile); + rc = fspr_file_info_get(&finfo, APR_FINFO_SIZE, thefile); if (rc == APR_SUCCESS) rc = setptr(thefile, finfo.size + *offset); break; @@ -91,7 +91,7 @@ APR_DECLARE(apr_status_t) apr_file_seek(apr_file_t *thefile, apr_seek_where_t wh } } -apr_status_t apr_file_trunc(apr_file_t *fp, apr_off_t offset) +fspr_status_t fspr_file_trunc(fspr_file_t *fp, fspr_off_t offset) { if (ftruncate(fp->filedes, offset) == -1) { return errno; diff --git a/libs/apr/file_io/unix/tempdir.c b/libs/apr/file_io/unix/tempdir.c index 1138e2c900..6a0091d5dc 100644 --- a/libs/apr/file_io/unix/tempdir.c +++ b/libs/apr/file_io/unix/tempdir.c @@ -13,22 +13,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "apr_private.h" -#include "apr_file_io.h" -#include "apr_strings.h" -#include "apr_env.h" +#include "fspr_private.h" +#include "fspr_file_io.h" +#include "fspr_strings.h" +#include "fspr_env.h" /* Try to open a temporary file in the temporary dir, write to it, and then close it. */ -static int test_tempdir(const char *temp_dir, apr_pool_t *p) +static int test_tempdir(const char *temp_dir, fspr_pool_t *p) { - apr_file_t *dummy_file; - char *path = apr_pstrcat(p, temp_dir, "/apr-tmp.XXXXXX", NULL); + fspr_file_t *dummy_file; + char *path = fspr_pstrcat(p, temp_dir, "/apr-tmp.XXXXXX", NULL); - if (apr_file_mktemp(&dummy_file, path, 0, p) == APR_SUCCESS) { - if (apr_file_putc('!', dummy_file) == APR_SUCCESS) { - if (apr_file_close(dummy_file) == APR_SUCCESS) { + if (fspr_file_mktemp(&dummy_file, path, 0, p) == APR_SUCCESS) { + if (fspr_file_putc('!', dummy_file) == APR_SUCCESS) { + if (fspr_file_close(dummy_file) == APR_SUCCESS) { return 1; } } @@ -37,10 +37,10 @@ static int test_tempdir(const char *temp_dir, apr_pool_t *p) } -APR_DECLARE(apr_status_t) apr_temp_dir_get(const char **temp_dir, - apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_temp_dir_get(const char **temp_dir, + fspr_pool_t *p) { - apr_status_t apr_err; + fspr_status_t fspr_err; const char *try_dirs[] = { "/tmp", "/usr/tmp", "/var/tmp" }; const char *try_envs[] = { "TMP", "TEMP", "TMPDIR" }; const char *dir; @@ -69,9 +69,9 @@ APR_DECLARE(apr_status_t) apr_temp_dir_get(const char **temp_dir, /* Try the environment first. */ for (i = 0; i < (sizeof(try_envs) / sizeof(const char *)); i++) { char *value; - apr_err = apr_env_get(&value, try_envs[i], p); - if ((apr_err == APR_SUCCESS) && value) { - apr_size_t len = strlen(value); + fspr_err = fspr_env_get(&value, try_envs[i], p); + if ((fspr_err == APR_SUCCESS) && value) { + fspr_size_t len = strlen(value); if (len && (len < APR_PATH_MAX) && test_tempdir(value, p)) { dir = value; goto end; @@ -114,7 +114,7 @@ APR_DECLARE(apr_status_t) apr_temp_dir_get(const char **temp_dir, #endif /* Finally, try the current working directory. */ - if (APR_SUCCESS == apr_filepath_get(&cwd, APR_FILEPATH_NATIVE, p)) { + if (APR_SUCCESS == fspr_filepath_get(&cwd, APR_FILEPATH_NATIVE, p)) { if (test_tempdir(cwd, p)) { dir = cwd; goto end; @@ -125,6 +125,6 @@ APR_DECLARE(apr_status_t) apr_temp_dir_get(const char **temp_dir, return APR_EGENERAL; end: - *temp_dir = apr_pstrdup(p, dir); + *temp_dir = fspr_pstrdup(p, dir); return APR_SUCCESS; } diff --git a/libs/apr/file_io/win32/dir.c b/libs/apr/file_io/win32/dir.c index 76fe42bca8..809f9e08fd 100644 --- a/libs/apr/file_io/win32/dir.c +++ b/libs/apr/file_io/win32/dir.c @@ -14,12 +14,12 @@ * limitations under the License. */ -#include "apr.h" -#include "apr_arch_file_io.h" -#include "apr_file_io.h" -#include "apr_strings.h" -#include "apr_portable.h" -#include "apr_arch_atime.h" +#include "fspr.h" +#include "fspr_arch_file_io.h" +#include "fspr_file_io.h" +#include "fspr_strings.h" +#include "fspr_portable.h" +#include "fspr_arch_atime.h" #if APR_HAVE_ERRNO_H #include @@ -35,27 +35,27 @@ #endif -static apr_status_t dir_cleanup(void *thedir) +static fspr_status_t dir_cleanup(void *thedir) { - apr_dir_t *dir = thedir; + fspr_dir_t *dir = thedir; if (dir->dirhand != INVALID_HANDLE_VALUE && !FindClose(dir->dirhand)) { - return apr_get_os_error(); + return fspr_get_os_error(); } dir->dirhand = INVALID_HANDLE_VALUE; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_dir_open(apr_dir_t **new, const char *dirname, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_dir_open(fspr_dir_t **new, const char *dirname, + fspr_pool_t *pool) { - apr_status_t rv; + fspr_status_t rv; - apr_size_t len = strlen(dirname); - (*new) = apr_pcalloc(pool, sizeof(apr_dir_t)); + fspr_size_t len = strlen(dirname); + (*new) = fspr_pcalloc(pool, sizeof(fspr_dir_t)); /* Leave room here to add and pop the '*' wildcard for FindFirstFile * and double-null terminate so we have one character to change. */ - (*new)->dirname = apr_palloc(pool, len + 3); + (*new)->dirname = fspr_palloc(pool, len + 3); memcpy((*new)->dirname, dirname, len); if (len && (*new)->dirname[len - 1] != '/') { (*new)->dirname[len++] = '/'; @@ -68,8 +68,8 @@ APR_DECLARE(apr_status_t) apr_dir_open(apr_dir_t **new, const char *dirname, { /* Create a buffer for the longest file name we will ever see */ - (*new)->w.entry = apr_pcalloc(pool, sizeof(WIN32_FIND_DATAW)); - (*new)->name = apr_pcalloc(pool, APR_FILE_MAX * 3 + 1); + (*new)->w.entry = fspr_pcalloc(pool, sizeof(WIN32_FIND_DATAW)); + (*new)->name = fspr_pcalloc(pool, APR_FILE_MAX * 3 + 1); } #endif #if APR_HAS_ANSI_FS @@ -85,16 +85,16 @@ APR_DECLARE(apr_status_t) apr_dir_open(apr_dir_t **new, const char *dirname, (*new) = NULL; return APR_ENAMETOOLONG; } - (*new)->n.entry = apr_pcalloc(pool, sizeof(WIN32_FIND_DATAW)); + (*new)->n.entry = fspr_pcalloc(pool, sizeof(WIN32_FIND_DATAW)); } #endif (*new)->rootlen = len - 1; (*new)->pool = pool; (*new)->dirhand = INVALID_HANDLE_VALUE; - apr_pool_cleanup_register((*new)->pool, (void *)(*new), dir_cleanup, - apr_pool_cleanup_null); + fspr_pool_cleanup_register((*new)->pool, (void *)(*new), dir_cleanup, + fspr_pool_cleanup_null); - rv = apr_dir_read(NULL, 0, *new); + rv = fspr_dir_read(NULL, 0, *new); if (rv != APR_SUCCESS) { dir_cleanup(*new); *new = NULL; @@ -103,33 +103,33 @@ APR_DECLARE(apr_status_t) apr_dir_open(apr_dir_t **new, const char *dirname, return rv; } -APR_DECLARE(apr_status_t) apr_dir_close(apr_dir_t *dir) +APR_DECLARE(fspr_status_t) fspr_dir_close(fspr_dir_t *dir) { - apr_pool_cleanup_kill(dir->pool, dir, dir_cleanup); + fspr_pool_cleanup_kill(dir->pool, dir, dir_cleanup); return dir_cleanup(dir); } -APR_DECLARE(apr_status_t) apr_dir_read(apr_finfo_t *finfo, apr_int32_t wanted, - apr_dir_t *thedir) +APR_DECLARE(fspr_status_t) fspr_dir_read(fspr_finfo_t *finfo, fspr_int32_t wanted, + fspr_dir_t *thedir) { - apr_status_t rv; + fspr_status_t rv; char *fname; /* The while loops below allow us to skip all invalid file names, so that * we aren't reporting any files where their absolute paths are too long. */ #if APR_HAS_UNICODE_FS - apr_wchar_t wdirname[APR_PATH_MAX]; - apr_wchar_t *eos = NULL; + fspr_wchar_t wdirname[APR_PATH_MAX]; + fspr_wchar_t *eos = NULL; IF_WIN_OS_IS_UNICODE { - /* This code path is always be invoked by apr_dir_open or - * apr_dir_rewind, so return without filling out the finfo. + /* This code path is always be invoked by fspr_dir_open or + * fspr_dir_rewind, so return without filling out the finfo. */ if (thedir->dirhand == INVALID_HANDLE_VALUE) { - apr_status_t rv; + fspr_status_t rv; if (rv = utf8_to_unicode_path(wdirname, sizeof(wdirname) - / sizeof(apr_wchar_t), + / sizeof(fspr_wchar_t), thedir->dirname)) { return rv; } @@ -139,27 +139,27 @@ APR_DECLARE(apr_status_t) apr_dir_read(apr_finfo_t *finfo, apr_int32_t wanted, thedir->dirhand = FindFirstFileW(wdirname, thedir->w.entry); eos[0] = '\0'; if (thedir->dirhand == INVALID_HANDLE_VALUE) { - return apr_get_os_error(); + return fspr_get_os_error(); } thedir->bof = 1; return APR_SUCCESS; } else if (thedir->bof) { /* Noop - we already called FindFirstFileW from - * either apr_dir_open or apr_dir_rewind ... use + * either fspr_dir_open or fspr_dir_rewind ... use * that first record. */ thedir->bof = 0; } else if (!FindNextFileW(thedir->dirhand, thedir->w.entry)) { - return apr_get_os_error(); + return fspr_get_os_error(); } while (thedir->rootlen && thedir->rootlen + wcslen(thedir->w.entry->cFileName) >= APR_PATH_MAX) { if (!FindNextFileW(thedir->dirhand, thedir->w.entry)) { - return apr_get_os_error(); + return fspr_get_os_error(); } } if (rv = unicode_to_utf8_path(thedir->name, APR_FILE_MAX * 3 + 1, @@ -171,8 +171,8 @@ APR_DECLARE(apr_status_t) apr_dir_read(apr_finfo_t *finfo, apr_int32_t wanted, #if APR_HAS_ANSI_FS ELSE_WIN_OS_IS_ANSI { - /* This code path is always be invoked by apr_dir_open or - * apr_dir_rewind, so return without filling out the finfo. + /* This code path is always be invoked by fspr_dir_open or + * fspr_dir_rewind, so return without filling out the finfo. */ if (thedir->dirhand == INVALID_HANDLE_VALUE) { /* '/' terminated, so add the '*' and pop it when we finish */ @@ -183,26 +183,26 @@ APR_DECLARE(apr_status_t) apr_dir_read(apr_finfo_t *finfo, apr_int32_t wanted, thedir->n.entry); eop[0] = '\0'; if (thedir->dirhand == INVALID_HANDLE_VALUE) { - return apr_get_os_error(); + return fspr_get_os_error(); } thedir->bof = 1; return APR_SUCCESS; } else if (thedir->bof) { /* Noop - we already called FindFirstFileW from - * either apr_dir_open or apr_dir_rewind ... use + * either fspr_dir_open or fspr_dir_rewind ... use * that first record. */ thedir->bof = 0; } else if (!FindNextFile(thedir->dirhand, thedir->n.entry)) { - return apr_get_os_error(); + return fspr_get_os_error(); } while (thedir->rootlen && thedir->rootlen + strlen(thedir->n.entry->cFileName) >= MAX_PATH) { if (!FindNextFileW(thedir->dirhand, thedir->w.entry)) { - return apr_get_os_error(); + return fspr_get_os_error(); } } fname = thedir->n.entry->cFileName; @@ -244,11 +244,11 @@ APR_DECLARE(apr_status_t) apr_dir_read(apr_finfo_t *finfo, apr_int32_t wanted, #else char fspec[APR_PATH_MAX]; #endif - apr_size_t dirlen = strlen(thedir->dirname); + fspr_size_t dirlen = strlen(thedir->dirname); if (dirlen >= sizeof(fspec)) dirlen = sizeof(fspec) - 1; - apr_cpystrn(fspec, thedir->dirname, sizeof(fspec)); - apr_cpystrn(fspec + dirlen, fname, sizeof(fspec) - dirlen); + fspr_cpystrn(fspec, thedir->dirname, sizeof(fspec)); + fspr_cpystrn(fspec + dirlen, fname, sizeof(fspec) - dirlen); return more_finfo(finfo, fspec, wanted, MORE_OF_FSPEC); } #endif @@ -257,66 +257,66 @@ APR_DECLARE(apr_status_t) apr_dir_read(apr_finfo_t *finfo, apr_int32_t wanted, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_dir_rewind(apr_dir_t *dir) +APR_DECLARE(fspr_status_t) fspr_dir_rewind(fspr_dir_t *dir) { - apr_status_t rv; + fspr_status_t rv; /* this will mark the handle as invalid and we'll open it - * again if apr_dir_read() is subsequently called + * again if fspr_dir_read() is subsequently called */ rv = dir_cleanup(dir); if (rv == APR_SUCCESS) - rv = apr_dir_read(NULL, 0, dir); + rv = fspr_dir_read(NULL, 0, dir); return rv; } -APR_DECLARE(apr_status_t) apr_dir_make(const char *path, apr_fileperms_t perm, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_dir_make(const char *path, fspr_fileperms_t perm, + fspr_pool_t *pool) { #if APR_HAS_UNICODE_FS IF_WIN_OS_IS_UNICODE { - apr_wchar_t wpath[APR_PATH_MAX]; - apr_status_t rv; + fspr_wchar_t wpath[APR_PATH_MAX]; + fspr_status_t rv; if (rv = utf8_to_unicode_path(wpath, sizeof(wpath) - / sizeof(apr_wchar_t), path)) { + / sizeof(fspr_wchar_t), path)) { return rv; } if (!CreateDirectoryW(wpath, NULL)) { - return apr_get_os_error(); + return fspr_get_os_error(); } } #endif #if APR_HAS_ANSI_FS ELSE_WIN_OS_IS_ANSI if (!CreateDirectory(path, NULL)) { - return apr_get_os_error(); + return fspr_get_os_error(); } #endif return APR_SUCCESS; } -static apr_status_t dir_make_parent(char *path, - apr_fileperms_t perm, - apr_pool_t *pool) +static fspr_status_t dir_make_parent(char *path, + fspr_fileperms_t perm, + fspr_pool_t *pool) { - apr_status_t rv; + fspr_status_t rv; char *ch = strrchr(path, '\\'); if (!ch) { return APR_ENOENT; } *ch = '\0'; - rv = apr_dir_make (path, perm, pool); /* Try to make straight off */ + rv = fspr_dir_make (path, perm, pool); /* Try to make straight off */ if (APR_STATUS_IS_ENOENT(rv)) { /* Missing an intermediate dir */ rv = dir_make_parent(path, perm, pool); if (rv == APR_SUCCESS) { - rv = apr_dir_make (path, perm, pool); /* And complete the path */ + rv = fspr_dir_make (path, perm, pool); /* And complete the path */ } } @@ -324,13 +324,13 @@ static apr_status_t dir_make_parent(char *path, return rv; } -APR_DECLARE(apr_status_t) apr_dir_make_recursive(const char *path, - apr_fileperms_t perm, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_dir_make_recursive(const char *path, + fspr_fileperms_t perm, + fspr_pool_t *pool) { - apr_status_t rv = 0; + fspr_status_t rv = 0; - rv = apr_dir_make (path, perm, pool); /* Try to make PATH right out */ + rv = fspr_dir_make (path, perm, pool); /* Try to make PATH right out */ if (APR_STATUS_IS_EEXIST(rv)) /* It's OK if PATH exists */ return APR_SUCCESS; @@ -338,45 +338,45 @@ APR_DECLARE(apr_status_t) apr_dir_make_recursive(const char *path, if (APR_STATUS_IS_ENOENT(rv)) { /* Missing an intermediate dir */ char *dir; - rv = apr_filepath_merge(&dir, "", path, APR_FILEPATH_NATIVE, pool); + rv = fspr_filepath_merge(&dir, "", path, APR_FILEPATH_NATIVE, pool); if (rv == APR_SUCCESS) rv = dir_make_parent(dir, perm, pool); /* Make intermediate dirs */ if (rv == APR_SUCCESS) - rv = apr_dir_make (dir, perm, pool); /* And complete the path */ + rv = fspr_dir_make (dir, perm, pool); /* And complete the path */ } return rv; } -APR_DECLARE(apr_status_t) apr_dir_remove(const char *path, apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_dir_remove(const char *path, fspr_pool_t *pool) { #if APR_HAS_UNICODE_FS IF_WIN_OS_IS_UNICODE { - apr_wchar_t wpath[APR_PATH_MAX]; - apr_status_t rv; + fspr_wchar_t wpath[APR_PATH_MAX]; + fspr_status_t rv; if (rv = utf8_to_unicode_path(wpath, sizeof(wpath) - / sizeof(apr_wchar_t), path)) { + / sizeof(fspr_wchar_t), path)) { return rv; } if (!RemoveDirectoryW(wpath)) { - return apr_get_os_error(); + return fspr_get_os_error(); } } #endif #if APR_HAS_ANSI_FS ELSE_WIN_OS_IS_ANSI if (!RemoveDirectory(path)) { - return apr_get_os_error(); + return fspr_get_os_error(); } #endif return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_os_dir_get(apr_os_dir_t **thedir, - apr_dir_t *dir) +APR_DECLARE(fspr_status_t) fspr_os_dir_get(fspr_os_dir_t **thedir, + fspr_dir_t *dir) { if (dir == NULL) { return APR_ENODIR; @@ -385,9 +385,9 @@ APR_DECLARE(apr_status_t) apr_os_dir_get(apr_os_dir_t **thedir, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_os_dir_put(apr_dir_t **dir, - apr_os_dir_t *thedir, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_os_dir_put(fspr_dir_t **dir, + fspr_os_dir_t *thedir, + fspr_pool_t *pool) { return APR_ENOTIMPL; } diff --git a/libs/apr/file_io/win32/filedup.c b/libs/apr/file_io/win32/filedup.c index 69e4d91347..f1d5cb08ea 100644 --- a/libs/apr/file_io/win32/filedup.c +++ b/libs/apr/file_io/win32/filedup.c @@ -14,15 +14,15 @@ * limitations under the License. */ -#include "win32/apr_arch_file_io.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_strings.h" +#include "win32/fspr_arch_file_io.h" +#include "fspr_file_io.h" +#include "fspr_general.h" +#include "fspr_strings.h" #include -#include "apr_arch_inherit.h" +#include "fspr_arch_inherit.h" -APR_DECLARE(apr_status_t) apr_file_dup(apr_file_t **new_file, - apr_file_t *old_file, apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_file_dup(fspr_file_t **new_file, + fspr_file_t *old_file, fspr_pool_t *p) { #ifdef _WIN32_WCE return APR_ENOTIMPL; @@ -33,31 +33,31 @@ APR_DECLARE(apr_status_t) apr_file_dup(apr_file_t **new_file, if (!DuplicateHandle(hproc, old_file->filehand, hproc, &newhand, 0, FALSE, DUPLICATE_SAME_ACCESS)) { - return apr_get_os_error(); + return fspr_get_os_error(); } - (*new_file) = (apr_file_t *) apr_pcalloc(p, sizeof(apr_file_t)); + (*new_file) = (fspr_file_t *) fspr_pcalloc(p, sizeof(fspr_file_t)); (*new_file)->filehand = newhand; (*new_file)->flags = old_file->flags & ~APR_INHERIT; (*new_file)->pool = p; - (*new_file)->fname = apr_pstrdup(p, old_file->fname); + (*new_file)->fname = fspr_pstrdup(p, old_file->fname); (*new_file)->append = old_file->append; (*new_file)->buffered = FALSE; (*new_file)->ungetchar = old_file->ungetchar; #if APR_HAS_THREADS if (old_file->mutex) { - apr_thread_mutex_create(&((*new_file)->mutex), + fspr_thread_mutex_create(&((*new_file)->mutex), APR_THREAD_MUTEX_DEFAULT, p); } #endif - apr_pool_cleanup_register((*new_file)->pool, (void *)(*new_file), file_cleanup, - apr_pool_cleanup_null); + fspr_pool_cleanup_register((*new_file)->pool, (void *)(*new_file), file_cleanup, + fspr_pool_cleanup_null); /* Create a pollset with room for one descriptor. */ /* ### check return codes */ - (void) apr_pollset_create(&(*new_file)->pollset, 1, p, 0); + (void) fspr_pollset_create(&(*new_file)->pollset, 1, p, 0); return APR_SUCCESS; #endif /* !defined(_WIN32_WCE) */ @@ -67,8 +67,8 @@ APR_DECLARE(apr_status_t) apr_file_dup(apr_file_t **new_file, #define stdout_handle 0x02 #define stderr_handle 0x04 -APR_DECLARE(apr_status_t) apr_file_dup2(apr_file_t *new_file, - apr_file_t *old_file, apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_file_dup2(fspr_file_t *new_file, + fspr_file_t *old_file, fspr_pool_t *p) { #ifdef _WIN32_WCE return APR_ENOTIMPL; @@ -76,7 +76,7 @@ APR_DECLARE(apr_status_t) apr_file_dup2(apr_file_t *new_file, DWORD stdhandle = 0; HANDLE hproc = GetCurrentProcess(); HANDLE newhand = NULL; - apr_int32_t newflags; + fspr_int32_t newflags; /* dup2 is not supported literaly with native Windows handles. * We can, however, emulate dup2 for the standard i/o handles, @@ -97,12 +97,12 @@ APR_DECLARE(apr_status_t) apr_file_dup2(apr_file_t *new_file, if (!DuplicateHandle(hproc, old_file->filehand, hproc, &newhand, 0, TRUE, DUPLICATE_SAME_ACCESS)) { - return apr_get_os_error(); + return fspr_get_os_error(); } if (((stdhandle & stderr_handle) && !SetStdHandle(STD_ERROR_HANDLE, newhand)) || ((stdhandle & stdout_handle) && !SetStdHandle(STD_OUTPUT_HANDLE, newhand)) || ((stdhandle & stdin_handle) && !SetStdHandle(STD_INPUT_HANDLE, newhand))) { - return apr_get_os_error(); + return fspr_get_os_error(); } newflags = old_file->flags | APR_INHERIT; } @@ -110,7 +110,7 @@ APR_DECLARE(apr_status_t) apr_file_dup2(apr_file_t *new_file, if (!DuplicateHandle(hproc, old_file->filehand, hproc, &newhand, 0, FALSE, DUPLICATE_SAME_ACCESS)) { - return apr_get_os_error(); + return fspr_get_os_error(); } newflags = old_file->flags & ~APR_INHERIT; } @@ -121,14 +121,14 @@ APR_DECLARE(apr_status_t) apr_file_dup2(apr_file_t *new_file, new_file->flags = newflags; new_file->filehand = newhand; - new_file->fname = apr_pstrdup(new_file->pool, old_file->fname); + new_file->fname = fspr_pstrdup(new_file->pool, old_file->fname); new_file->append = old_file->append; new_file->buffered = FALSE; new_file->ungetchar = old_file->ungetchar; #if APR_HAS_THREADS if (old_file->mutex) { - apr_thread_mutex_create(&(new_file->mutex), + fspr_thread_mutex_create(&(new_file->mutex), APR_THREAD_MUTEX_DEFAULT, p); } #endif @@ -137,15 +137,15 @@ APR_DECLARE(apr_status_t) apr_file_dup2(apr_file_t *new_file, #endif /* !defined(_WIN32_WCE) */ } -APR_DECLARE(apr_status_t) apr_file_setaside(apr_file_t **new_file, - apr_file_t *old_file, - apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_file_setaside(fspr_file_t **new_file, + fspr_file_t *old_file, + fspr_pool_t *p) { - *new_file = (apr_file_t *)apr_palloc(p, sizeof(apr_file_t)); - memcpy(*new_file, old_file, sizeof(apr_file_t)); + *new_file = (fspr_file_t *)fspr_palloc(p, sizeof(fspr_file_t)); + memcpy(*new_file, old_file, sizeof(fspr_file_t)); (*new_file)->pool = p; if (old_file->buffered) { - (*new_file)->buffer = apr_palloc(p, APR_FILE_BUFSIZE); + (*new_file)->buffer = fspr_palloc(p, APR_FILE_BUFSIZE); if (old_file->direction == 1) { memcpy((*new_file)->buffer, old_file->buffer, old_file->bufpos); } @@ -154,26 +154,26 @@ APR_DECLARE(apr_status_t) apr_file_setaside(apr_file_t **new_file, } } if (old_file->mutex) { - apr_thread_mutex_create(&((*new_file)->mutex), + fspr_thread_mutex_create(&((*new_file)->mutex), APR_THREAD_MUTEX_DEFAULT, p); - apr_thread_mutex_destroy(old_file->mutex); + fspr_thread_mutex_destroy(old_file->mutex); } if (old_file->fname) { - (*new_file)->fname = apr_pstrdup(p, old_file->fname); + (*new_file)->fname = fspr_pstrdup(p, old_file->fname); } if (!(old_file->flags & APR_FILE_NOCLEANUP)) { - apr_pool_cleanup_register(p, (void *)(*new_file), + fspr_pool_cleanup_register(p, (void *)(*new_file), file_cleanup, file_cleanup); } old_file->filehand = INVALID_HANDLE_VALUE; - apr_pool_cleanup_kill(old_file->pool, (void *)old_file, + fspr_pool_cleanup_kill(old_file->pool, (void *)old_file, file_cleanup); /* Create a pollset with room for one descriptor. */ /* ### check return codes */ - (void) apr_pollset_create(&(*new_file)->pollset, 1, p, 0); + (void) fspr_pollset_create(&(*new_file)->pollset, 1, p, 0); return APR_SUCCESS; } diff --git a/libs/apr/file_io/win32/filepath.c b/libs/apr/file_io/win32/filepath.c index 766e35f8d8..353cb2649e 100644 --- a/libs/apr/file_io/win32/filepath.c +++ b/libs/apr/file_io/win32/filepath.c @@ -14,11 +14,11 @@ * limitations under the License. */ -#include "apr.h" -#include "apr_private.h" -#include "apr_arch_file_io.h" -#include "apr_strings.h" -#include "apr_lib.h" +#include "fspr.h" +#include "fspr_private.h" +#include "fspr_arch_file_io.h" +#include "fspr_strings.h" +#include "fspr_lib.h" #include #include @@ -37,10 +37,10 @@ * OS2 appears immune from the nonsense :) */ -APR_DECLARE(apr_status_t) apr_filepath_root(const char **rootpath, +APR_DECLARE(fspr_status_t) fspr_filepath_root(const char **rootpath, const char **inpath, - apr_int32_t flags, - apr_pool_t *p) + fspr_int32_t flags, + fspr_pool_t *p) { const char *testpath = *inpath; char *newpath; @@ -78,7 +78,7 @@ APR_DECLARE(apr_status_t) apr_filepath_root(const char **rootpath, Otherwise we either have an incomplete or relative path */ if (volume && strlen(volume) > 0) { - newpath = apr_pcalloc(p, strlen(server)+strlen(volume)+5); + newpath = fspr_pcalloc(p, strlen(server)+strlen(volume)+5); construct(newpath, server, volume, NULL, NULL, NULL, PATH_NETWARE); /* NetWare doesn't add the root slash so we need to add it manually. @@ -106,7 +106,7 @@ APR_DECLARE(apr_status_t) apr_filepath_root(const char **rootpath, in same manner as unix although this path will be incomplete. */ - *rootpath = apr_pstrdup(p, seperator); + *rootpath = fspr_pstrdup(p, seperator); do { ++(*inpath); } while ((**inpath == '/') || (**inpath == '\\')); @@ -133,12 +133,12 @@ APR_DECLARE(apr_status_t) apr_filepath_root(const char **rootpath, && (testpath[3] == '/' || testpath[3] == '\\')) { if (IS_FNCHAR(testpath[4]) && testpath[5] == ':') { - apr_status_t rv; + fspr_status_t rv; testpath += 4; /* given '//?/C: or //./C: let us try this * all over again from the drive designator */ - rv = apr_filepath_root(rootpath, &testpath, flags, p); + rv = fspr_filepath_root(rootpath, &testpath, flags, p); if (!rv || rv == APR_EINCOMPLETE) *inpath = testpath; return rv; @@ -170,7 +170,7 @@ APR_DECLARE(apr_status_t) apr_filepath_root(const char **rootpath, } while (*delim1 && *delim1 != '/' && *delim1 != '\\'); if (*delim1) { - apr_status_t rv; + fspr_status_t rv; delim2 = delim1 + 1; while (*delim2 && *delim2 != '/' && *delim2 != '\\') { /* Protect against //machine/X/ where X is illegal */ @@ -181,7 +181,7 @@ APR_DECLARE(apr_status_t) apr_filepath_root(const char **rootpath, /* Copy the '//machine/[share[/]]' path, always providing * an extra byte for the trailing slash. */ - newpath = apr_pstrmemdup(p, testpath, delim2 - testpath + 1); + newpath = fspr_pstrmemdup(p, testpath, delim2 - testpath + 1); if (delim2 == delim1 + 1) { /* We found simply \\machine\, so give up already @@ -196,7 +196,7 @@ APR_DECLARE(apr_status_t) apr_filepath_root(const char **rootpath, * Win32 will argue about slashed in UNC paths, * so use backslashes till we finish testing, * and add the trailing backslash [required]. - * apr_pstrmemdup above guarentees us the new + * fspr_pstrmemdup above guarentees us the new * trailing null character. */ newpath[0] = '\\'; @@ -246,7 +246,7 @@ APR_DECLARE(apr_status_t) apr_filepath_root(const char **rootpath, */ delim1 = strchr(testpath, '\0'); if (delim1 > testpath + 2) { - newpath = apr_pstrndup(p, testpath, delim1 - testpath + 1); + newpath = fspr_pstrndup(p, testpath, delim1 - testpath + 1); if (flags & APR_FILEPATH_TRUENAME) newpath[delim1 - testpath] = seperator[0]; else @@ -254,7 +254,7 @@ APR_DECLARE(apr_status_t) apr_filepath_root(const char **rootpath, newpath[delim1 - testpath + 1] = '\0'; } else { - newpath = apr_pstrndup(p, testpath, delim1 - testpath); + newpath = fspr_pstrndup(p, testpath, delim1 - testpath); } if (flags & APR_FILEPATH_TRUENAME) { newpath[0] = seperator[0]; @@ -268,7 +268,7 @@ APR_DECLARE(apr_status_t) apr_filepath_root(const char **rootpath, /* Left with a path of '/', what drive are we asking about? */ *inpath = testpath + 1; - newpath = apr_palloc(p, 2); + newpath = fspr_palloc(p, 2); if (flags & APR_FILEPATH_TRUENAME) newpath[0] = seperator[0]; else @@ -281,20 +281,20 @@ APR_DECLARE(apr_status_t) apr_filepath_root(const char **rootpath, /* Evaluate path of 'd:[/]' */ if (IS_FNCHAR(*testpath) && testpath[1] == ':') { - apr_status_t rv; + fspr_status_t rv; /* Validate that D:\ drive exists, test must be rooted * Note that posix/win32 insists a drive letter is upper case, * so who are we to argue with a 'feature'. * It is a safe fold, since only A-Z is legal, and has no * side effects of legal mis-mapped non-us-ascii codes. */ - newpath = apr_palloc(p, 4); + newpath = fspr_palloc(p, 4); newpath[0] = testpath[0]; newpath[1] = testpath[1]; newpath[2] = seperator[0]; newpath[3] = '\0'; if (flags & APR_FILEPATH_TRUENAME) { - newpath[0] = apr_toupper(newpath[0]); + newpath[0] = fspr_toupper(newpath[0]); rv = filepath_root_test(newpath, p); if (rv) return rv; @@ -328,24 +328,24 @@ APR_DECLARE(apr_status_t) apr_filepath_root(const char **rootpath, } -APR_DECLARE(apr_status_t) apr_filepath_merge(char **newpath, +APR_DECLARE(fspr_status_t) fspr_filepath_merge(char **newpath, const char *basepath, const char *addpath, - apr_int32_t flags, - apr_pool_t *p) + fspr_int32_t flags, + fspr_pool_t *p) { char path[APR_PATH_MAX]; /* isn't null term */ const char *baseroot = NULL; const char *addroot; - apr_size_t rootlen; /* the length of the root portion of path, d:/ is 3 */ - apr_size_t baselen; /* the length of basepath (excluding baseroot) */ - apr_size_t keptlen; /* the length of the retained basepath (incl root) */ - apr_size_t pathlen; /* the length of the result path */ - apr_size_t segend; /* the end of the current segment */ - apr_size_t seglen; /* the length of the segment (excl trailing chars) */ - apr_status_t basetype = 0; /* from parsing the basepath's baseroot */ - apr_status_t addtype; /* from parsing the addpath's addroot */ - apr_status_t rv; + fspr_size_t rootlen; /* the length of the root portion of path, d:/ is 3 */ + fspr_size_t baselen; /* the length of basepath (excluding baseroot) */ + fspr_size_t keptlen; /* the length of the retained basepath (incl root) */ + fspr_size_t pathlen; /* the length of the result path */ + fspr_size_t segend; /* the end of the current segment */ + fspr_size_t seglen; /* the length of the segment (excl trailing chars) */ + fspr_status_t basetype = 0; /* from parsing the basepath's baseroot */ + fspr_status_t addtype; /* from parsing the addpath's addroot */ + fspr_status_t rv; #ifndef NETWARE int fixunc = 0; /* flag to complete an incomplete UNC basepath */ #endif @@ -359,7 +359,7 @@ APR_DECLARE(apr_status_t) apr_filepath_merge(char **newpath, else { /* This call _should_ test the path */ - addtype = apr_filepath_root(&addroot, &addpath, + addtype = fspr_filepath_root(&addroot, &addpath, APR_FILEPATH_TRUENAME | (flags & APR_FILEPATH_NATIVE), p); @@ -370,7 +370,7 @@ APR_DECLARE(apr_status_t) apr_filepath_merge(char **newpath, addroot = ""; } else if (addtype != APR_EINCOMPLETE) { - /* apr_filepath_root was incomprehensible so fail already + /* fspr_filepath_root was incomprehensible so fail already */ return addtype; } @@ -425,7 +425,7 @@ APR_DECLARE(apr_status_t) apr_filepath_merge(char **newpath, rv = filepath_drive_get(&getpath, addroot[0], flags, p); else #endif - rv = apr_filepath_get(&getpath, flags, p); + rv = fspr_filepath_get(&getpath, flags, p); if (rv != APR_SUCCESS) return rv; basepath = getpath; @@ -434,7 +434,7 @@ APR_DECLARE(apr_status_t) apr_filepath_merge(char **newpath, if (!baseroot) { /* This call should _not_ test the path */ - basetype = apr_filepath_root(&baseroot, &basepath, + basetype = fspr_filepath_root(&baseroot, &basepath, (flags & APR_FILEPATH_NATIVE), p); if (basetype == APR_SUCCESS) { basetype = APR_EABSOLUTE; @@ -443,7 +443,7 @@ APR_DECLARE(apr_status_t) apr_filepath_merge(char **newpath, baseroot = ""; } else if (basetype != APR_EINCOMPLETE) { - /* apr_filepath_root was incomprehensible so fail already + /* fspr_filepath_root was incomprehensible so fail already */ return basetype; } @@ -740,8 +740,8 @@ APR_DECLARE(apr_status_t) apr_filepath_merge(char **newpath, if (fixunc) { const char *testpath = path; const char *testroot; - apr_status_t testtype; - apr_size_t i = (addpath[segend] != '\0'); + fspr_status_t testtype; + fspr_size_t i = (addpath[segend] != '\0'); /* This isn't legal unless the unc path is complete! */ @@ -764,7 +764,7 @@ APR_DECLARE(apr_status_t) apr_filepath_merge(char **newpath, path[pathlen] = '\0'; /* This call _should_ test the path */ - testtype = apr_filepath_root(&testroot, &testpath, + testtype = fspr_filepath_root(&testroot, &testpath, APR_FILEPATH_TRUENAME | (flags & APR_FILEPATH_NATIVE), p); @@ -774,7 +774,7 @@ APR_DECLARE(apr_status_t) apr_filepath_merge(char **newpath, fixunc = 0; } else if (testtype != APR_EINCOMPLETE) { - /* apr_filepath_root was very unexpected so fail already + /* fspr_filepath_root was very unexpected so fail already */ return testtype; } @@ -784,7 +784,7 @@ APR_DECLARE(apr_status_t) apr_filepath_merge(char **newpath, { /* An actual segment, append it to the destination path */ - apr_size_t i = (addpath[segend] != '\0'); + fspr_size_t i = (addpath[segend] != '\0'); if (pathlen + seglen + i >= sizeof(path)) return APR_ENAMETOOLONG; memcpy(path + pathlen, addpath, seglen + i); @@ -835,7 +835,7 @@ APR_DECLARE(apr_status_t) apr_filepath_merge(char **newpath, } /* Go through all the new segments */ while (keptlen < pathlen) { - apr_finfo_t finfo; + fspr_finfo_t finfo; char saveslash = 0; seglen = 0; /* find any slash and set it aside for a minute. */ @@ -848,10 +848,10 @@ APR_DECLARE(apr_status_t) apr_filepath_merge(char **newpath, } /* Null term for stat! */ path[keptlen + seglen] = '\0'; - if ((rv = apr_stat(&finfo, path, + if ((rv = fspr_stat(&finfo, path, APR_FINFO_LINK | APR_FINFO_TYPE | APR_FINFO_NAME, p)) == APR_SUCCESS) { - apr_size_t namelen = strlen(finfo.name); + fspr_size_t namelen = strlen(finfo.name); #if defined(OS2) /* only has case folding, never aliases that change the length */ @@ -949,28 +949,28 @@ APR_DECLARE(apr_status_t) apr_filepath_merge(char **newpath, } } - *newpath = apr_pmemdup(p, path, pathlen + 1); + *newpath = fspr_pmemdup(p, path, pathlen + 1); (*newpath)[pathlen] = '\0'; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_filepath_list_split(apr_array_header_t **pathelts, +APR_DECLARE(fspr_status_t) fspr_filepath_list_split(fspr_array_header_t **pathelts, const char *liststr, - apr_pool_t *p) + fspr_pool_t *p) { - return apr_filepath_list_split_impl(pathelts, liststr, ';', p); + return fspr_filepath_list_split_impl(pathelts, liststr, ';', p); } -APR_DECLARE(apr_status_t) apr_filepath_list_merge(char **liststr, - apr_array_header_t *pathelts, - apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_filepath_list_merge(char **liststr, + fspr_array_header_t *pathelts, + fspr_pool_t *p) { - return apr_filepath_list_merge_impl(liststr, pathelts, ';', p); + return fspr_filepath_list_merge_impl(liststr, pathelts, ';', p); } -APR_DECLARE(apr_status_t) apr_filepath_encoding(int *style, apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_filepath_encoding(int *style, fspr_pool_t *p) { #if APR_HAS_UNICODE_FS IF_WIN_OS_IS_UNICODE diff --git a/libs/apr/file_io/win32/filestat.c b/libs/apr/file_io/win32/filestat.c index af93bb933b..1972ccf3b3 100644 --- a/libs/apr/file_io/win32/filestat.c +++ b/libs/apr/file_io/win32/filestat.c @@ -14,28 +14,28 @@ * limitations under the License. */ -#include "apr.h" +#include "fspr.h" #include -#include "apr_private.h" -#include "apr_arch_file_io.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_strings.h" -#include "apr_errno.h" -#include "apr_time.h" +#include "fspr_private.h" +#include "fspr_arch_file_io.h" +#include "fspr_file_io.h" +#include "fspr_general.h" +#include "fspr_strings.h" +#include "fspr_errno.h" +#include "fspr_time.h" #include -#include "apr_arch_atime.h" -#include "apr_arch_misc.h" +#include "fspr_arch_atime.h" +#include "fspr_arch_misc.h" /* We have to assure that the file name contains no '*'s, or other * wildcards when using FindFirstFile to recover the true file name. */ -static apr_status_t test_safe_name(const char *name) +static fspr_status_t test_safe_name(const char *name) { /* Only accept ':' in the second position of the filename, * as the drive letter delimiter: */ - if (apr_isalpha(*name) && (name[1] == ':')) { + if (fspr_isalpha(*name) && (name[1] == ':')) { name += 2; } while (*name) { @@ -50,12 +50,12 @@ static apr_status_t test_safe_name(const char *name) return APR_SUCCESS; } -static apr_status_t free_localheap(void *heap) { +static fspr_status_t free_localheap(void *heap) { LocalFree(heap); return APR_SUCCESS; } -static apr_gid_t worldid = NULL; +static fspr_gid_t worldid = NULL; static void free_world(void) { @@ -72,13 +72,13 @@ typedef enum prot_scope_e { prot_scope_user = 8 } prot_scope_e; -static apr_fileperms_t convert_prot(ACCESS_MASK acc, prot_scope_e scope) +static fspr_fileperms_t convert_prot(ACCESS_MASK acc, prot_scope_e scope) { /* These choices are based on the single filesystem bit that controls * the given behavior. They are -not- recommended for any set protection * function, such a function should -set- use GENERIC_READ/WRITE/EXECUTE */ - apr_fileperms_t prot = 0; + fspr_fileperms_t prot = 0; if (acc & FILE_EXECUTE) prot |= APR_WEXECUTE; if (acc & FILE_WRITE_DATA) @@ -88,7 +88,7 @@ static apr_fileperms_t convert_prot(ACCESS_MASK acc, prot_scope_e scope) return (prot << scope); } -static void resolve_prot(apr_finfo_t *finfo, apr_int32_t wanted, PACL dacl) +static void resolve_prot(fspr_finfo_t *finfo, fspr_int32_t wanted, PACL dacl) { TRUSTEE_W ident = {NULL, NO_MULTIPLE_TRUSTEE, TRUSTEE_IS_SID}; ACCESS_MASK acc; @@ -139,11 +139,11 @@ static void resolve_prot(apr_finfo_t *finfo, apr_int32_t wanted, PACL dacl) } } -static apr_status_t resolve_ident(apr_finfo_t *finfo, const char *fname, - apr_int32_t wanted, apr_pool_t *pool) +static fspr_status_t resolve_ident(fspr_finfo_t *finfo, const char *fname, + fspr_int32_t wanted, fspr_pool_t *pool) { - apr_file_t *thefile = NULL; - apr_status_t rv; + fspr_file_t *thefile = NULL; + fspr_status_t rv; /* * NT5 (W2K) only supports symlinks in the same manner as mount points. * This code should eventually take that into account, for now treat @@ -153,28 +153,28 @@ static apr_status_t resolve_ident(apr_finfo_t *finfo, const char *fname, * user, group or permissions. */ - if ((rv = apr_file_open(&thefile, fname, APR_OPENINFO + if ((rv = fspr_file_open(&thefile, fname, APR_OPENINFO | ((wanted & APR_FINFO_LINK) ? APR_OPENLINK : 0) | ((wanted & (APR_FINFO_PROT | APR_FINFO_OWNER)) ? APR_READCONTROL : 0), APR_OS_DEFAULT, pool)) == APR_SUCCESS) { - rv = apr_file_info_get(finfo, wanted, thefile); + rv = fspr_file_info_get(finfo, wanted, thefile); finfo->filehand = NULL; - apr_file_close(thefile); + fspr_file_close(thefile); } else if (APR_STATUS_IS_EACCES(rv) && (wanted & (APR_FINFO_PROT | APR_FINFO_OWNER))) { /* We have a backup plan. Perhaps we couldn't grab READ_CONTROL? * proceed without asking for that permission... */ - if ((rv = apr_file_open(&thefile, fname, APR_OPENINFO + if ((rv = fspr_file_open(&thefile, fname, APR_OPENINFO | ((wanted & APR_FINFO_LINK) ? APR_OPENLINK : 0), APR_OS_DEFAULT, pool)) == APR_SUCCESS) { - rv = apr_file_info_get(finfo, wanted & ~(APR_FINFO_PROT + rv = fspr_file_info_get(finfo, wanted & ~(APR_FINFO_PROT | APR_FINFO_OWNER), thefile); finfo->filehand = NULL; - apr_file_close(thefile); + fspr_file_close(thefile); } } @@ -188,7 +188,7 @@ static apr_status_t resolve_ident(apr_finfo_t *finfo, const char *fname, return rv; } -static void guess_protection_bits(apr_finfo_t *finfo) +static void guess_protection_bits(fspr_finfo_t *finfo) { /* Read, write execute for owner. In the Win9x environment, any * readable file is executable (well, not entirely 100% true, but @@ -207,20 +207,20 @@ static void guess_protection_bits(apr_finfo_t *finfo) finfo->valid |= APR_FINFO_UPROT | APR_FINFO_GPROT | APR_FINFO_WPROT; } -apr_status_t more_finfo(apr_finfo_t *finfo, const void *ufile, - apr_int32_t wanted, int whatfile) +fspr_status_t more_finfo(fspr_finfo_t *finfo, const void *ufile, + fspr_int32_t wanted, int whatfile) { PSID user = NULL, grp = NULL; PACL dacl = NULL; - apr_status_t rv; + fspr_status_t rv; - if (apr_os_level < APR_WIN_NT) + if (fspr_os_level < APR_WIN_NT) guess_protection_bits(finfo); else if (wanted & (APR_FINFO_PROT | APR_FINFO_OWNER)) { /* On NT this request is incredibly expensive, but accurate. * Since the WinNT-only functions below are protected by the - * (apr_os_level < APR_WIN_NT) case above, we need no extra + * (fspr_os_level < APR_WIN_NT) case above, we need no extra * tests, but remember GetNamedSecurityInfo & GetSecurityInfo * are not supported on 9x. */ @@ -233,7 +233,7 @@ apr_status_t more_finfo(apr_finfo_t *finfo, const void *ufile, if (wanted & APR_FINFO_PROT) sinf |= DACL_SECURITY_INFORMATION; if (whatfile == MORE_OF_WFSPEC) { - apr_wchar_t *wfile = (apr_wchar_t*) ufile; + fspr_wchar_t *wfile = (fspr_wchar_t*) ufile; int fix = 0; if (wcsncmp(wfile, L"\\\\?\\", 4) == 0) { fix = 4; @@ -266,8 +266,8 @@ apr_status_t more_finfo(apr_finfo_t *finfo, const void *ufile, else return APR_INCOMPLETE; if (rv == ERROR_SUCCESS) - apr_pool_cleanup_register(finfo->pool, pdesc, free_localheap, - apr_pool_cleanup_null); + fspr_pool_cleanup_register(finfo->pool, pdesc, free_localheap, + fspr_pool_cleanup_null); else user = grp = dacl = NULL; @@ -303,9 +303,9 @@ apr_status_t more_finfo(apr_finfo_t *finfo, const void *ufile, * if this is a CHR filetype. If it's reasonably certain it can't be, * then the function returns 0. */ -int fillin_fileinfo(apr_finfo_t *finfo, +int fillin_fileinfo(fspr_finfo_t *finfo, WIN32_FILE_ATTRIBUTE_DATA *wininfo, - int byhandle, apr_int32_t wanted) + int byhandle, fspr_int32_t wanted) { DWORD *sizes = &wininfo->nFileSizeHigh + byhandle; int warn = 0; @@ -317,10 +317,10 @@ int fillin_fileinfo(apr_finfo_t *finfo, FileTimeToAprTime(&finfo->mtime, &wininfo->ftLastWriteTime); #if APR_HAS_LARGE_FILES - finfo->size = (apr_off_t)sizes[1] - | ((apr_off_t)sizes[0] << 32); + finfo->size = (fspr_off_t)sizes[1] + | ((fspr_off_t)sizes[0] << 32); #else - finfo->size = (apr_off_t)sizes[1]; + finfo->size = (fspr_off_t)sizes[1]; if (finfo->size < 0 || sizes[0]) finfo->size = 0x7fffffff; #endif @@ -369,20 +369,20 @@ int fillin_fileinfo(apr_finfo_t *finfo, } -APR_DECLARE(apr_status_t) apr_file_info_get(apr_finfo_t *finfo, apr_int32_t wanted, - apr_file_t *thefile) +APR_DECLARE(fspr_status_t) fspr_file_info_get(fspr_finfo_t *finfo, fspr_int32_t wanted, + fspr_file_t *thefile) { BY_HANDLE_FILE_INFORMATION FileInfo; if (thefile->buffered) { /* XXX: flush here is not mutex protected */ - apr_status_t rv = apr_file_flush(thefile); + fspr_status_t rv = fspr_file_flush(thefile); if (rv != APR_SUCCESS) return rv; } if (!GetFileInformationByHandle(thefile->filehand, &FileInfo)) { - return apr_get_os_error(); + return fspr_get_os_error(); } fillin_fileinfo(finfo, (WIN32_FILE_ATTRIBUTE_DATA *) &FileInfo, 1, wanted); @@ -416,8 +416,8 @@ APR_DECLARE(apr_status_t) apr_file_info_get(apr_finfo_t *finfo, apr_int32_t want finfo->fname = thefile->fname; /* Extra goodies known only by GetFileInformationByHandle() */ - finfo->inode = (apr_ino_t)FileInfo.nFileIndexLow - | ((apr_ino_t)FileInfo.nFileIndexHigh << 32); + finfo->inode = (fspr_ino_t)FileInfo.nFileIndexLow + | ((fspr_ino_t)FileInfo.nFileIndexHigh << 32); finfo->device = FileInfo.dwVolumeSerialNumber; finfo->nlink = FileInfo.nNumberOfLinks; @@ -432,21 +432,21 @@ APR_DECLARE(apr_status_t) apr_file_info_get(apr_finfo_t *finfo, apr_int32_t want return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_file_perms_set(const char *fname, - apr_fileperms_t perms) +APR_DECLARE(fspr_status_t) fspr_file_perms_set(const char *fname, + fspr_fileperms_t perms) { return APR_ENOTIMPL; } -APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, const char *fname, - apr_int32_t wanted, apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_stat(fspr_finfo_t *finfo, const char *fname, + fspr_int32_t wanted, fspr_pool_t *pool) { /* XXX: is constant - needs testing - which requires a lighter-weight root test fn */ int isroot = 0; - apr_status_t ident_rv = 0; - apr_status_t rv; + fspr_status_t ident_rv = 0; + fspr_status_t rv; #if APR_HAS_UNICODE_FS - apr_wchar_t wfname[APR_PATH_MAX]; + fspr_wchar_t wfname[APR_PATH_MAX]; #endif char *filename = NULL; @@ -489,12 +489,12 @@ APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, const char *fname, } if (rv = utf8_to_unicode_path(wfname, sizeof(wfname) - / sizeof(apr_wchar_t), fname)) + / sizeof(fspr_wchar_t), fname)) return rv; if (!(wanted & APR_FINFO_NAME)) { if (!GetFileAttributesExW(wfname, GetFileExInfoStandard, &FileInfo.i)) - return apr_get_os_error(); + return fspr_get_os_error(); } else { /* Guard against bogus wildcards and retrieve by name @@ -508,13 +508,13 @@ APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, const char *fname, } hFind = FindFirstFileW(wfname, &FileInfo.w); if (hFind == INVALID_HANDLE_VALUE) - return apr_get_os_error(); + return fspr_get_os_error(); FindClose(hFind); if (unicode_to_utf8_path(tmpname, sizeof(tmpname), FileInfo.w.cFileName)) { return APR_ENAMETOOLONG; } - filename = apr_pstrdup(pool, tmpname); + filename = fspr_pstrdup(pool, tmpname); } } #endif @@ -523,17 +523,17 @@ APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, const char *fname, { char *root = NULL; const char *test = fname; - rv = apr_filepath_root(&root, &test, APR_FILEPATH_NATIVE, pool); + rv = fspr_filepath_root(&root, &test, APR_FILEPATH_NATIVE, pool); isroot = (root && *root && !(*test)); - if ((apr_os_level >= APR_WIN_98) && (!(wanted & APR_FINFO_NAME) || isroot)) + if ((fspr_os_level >= APR_WIN_98) && (!(wanted & APR_FINFO_NAME) || isroot)) { /* cannot use FindFile on a Win98 root, it returns \* * GetFileAttributesExA is not available on Win95 */ if (!GetFileAttributesExA(fname, GetFileExInfoStandard, &FileInfo.i)) { - return apr_get_os_error(); + return fspr_get_os_error(); } } else if (isroot) { @@ -543,7 +543,7 @@ APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, const char *fname, { finfo->pool = pool; finfo->filetype = 0; - finfo->mtime = apr_time_now(); + finfo->mtime = fspr_time_now(); finfo->protection |= APR_WREAD | APR_WEXECUTE | APR_WWRITE; finfo->protection |= (finfo->protection << prot_scope_group) | (finfo->protection << prot_scope_user); @@ -567,10 +567,10 @@ APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, const char *fname, } hFind = FindFirstFileA(fname, &FileInfo.n); if (hFind == INVALID_HANDLE_VALUE) { - return apr_get_os_error(); + return fspr_get_os_error(); } FindClose(hFind); - filename = apr_pstrdup(pool, FileInfo.n.cFileName); + filename = fspr_pstrdup(pool, FileInfo.n.cFileName); } } #endif @@ -583,12 +583,12 @@ APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, const char *fname, * to reliably translate char devices to the path '\\.\device' * so go ask for the full path. */ - if (apr_os_level >= APR_WIN_NT) + if (fspr_os_level >= APR_WIN_NT) { #if APR_HAS_UNICODE_FS - apr_wchar_t tmpname[APR_FILE_MAX]; - apr_wchar_t *tmpoff = NULL; - if (GetFullPathNameW(wfname, sizeof(tmpname) / sizeof(apr_wchar_t), + fspr_wchar_t tmpname[APR_FILE_MAX]; + fspr_wchar_t *tmpoff = NULL; + if (GetFullPathNameW(wfname, sizeof(tmpname) / sizeof(fspr_wchar_t), tmpname, &tmpoff)) { if (!wcsncmp(tmpname, L"\\\\.\\", 4)) { @@ -646,7 +646,7 @@ APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, const char *fname, if (wanted &= ~finfo->valid) { /* Caller wants more than APR_FINFO_MIN | APR_FINFO_NAME */ #if APR_HAS_UNICODE_FS - if (apr_os_level >= APR_WIN_NT) + if (fspr_os_level >= APR_WIN_NT) return more_finfo(finfo, wfname, wanted, MORE_OF_WFSPEC); #endif return more_finfo(finfo, fname, wanted, MORE_OF_FSPEC); @@ -655,15 +655,15 @@ APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, const char *fname, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_file_attrs_set(const char *fname, - apr_fileattrs_t attributes, - apr_fileattrs_t attr_mask, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_file_attrs_set(const char *fname, + fspr_fileattrs_t attributes, + fspr_fileattrs_t attr_mask, + fspr_pool_t *pool) { DWORD flags; - apr_status_t rv; + fspr_status_t rv; #if APR_HAS_UNICODE_FS - apr_wchar_t wfname[APR_PATH_MAX]; + fspr_wchar_t wfname[APR_PATH_MAX]; #endif /* Don't do anything if we can't handle the requested attributes */ @@ -689,7 +689,7 @@ APR_DECLARE(apr_status_t) apr_file_attrs_set(const char *fname, #endif if (flags == 0xFFFFFFFF) - return apr_get_os_error(); + return fspr_get_os_error(); if (attr_mask & APR_FILE_ATTR_READONLY) { @@ -721,20 +721,20 @@ APR_DECLARE(apr_status_t) apr_file_attrs_set(const char *fname, #endif if (rv == 0) - return apr_get_os_error(); + return fspr_get_os_error(); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_file_mtime_set(const char *fname, - apr_time_t mtime, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_file_mtime_set(const char *fname, + fspr_time_t mtime, + fspr_pool_t *pool) { - apr_file_t *thefile; - apr_status_t rv; + fspr_file_t *thefile; + fspr_status_t rv; - rv = apr_file_open(&thefile, fname, + rv = fspr_file_open(&thefile, fname, APR_READ | APR_WRITEATTRS, APR_OS_DEFAULT, pool); if (!rv) @@ -745,16 +745,16 @@ APR_DECLARE(apr_status_t) apr_file_mtime_set(const char *fname, if (!GetFileTime(thefile->filehand, &file_ctime, &file_atime, &file_mtime)) - rv = apr_get_os_error(); + rv = fspr_get_os_error(); else { AprTimeToFileTime(&file_mtime, mtime); if (!SetFileTime(thefile->filehand, &file_ctime, &file_atime, &file_mtime)) - rv = apr_get_os_error(); + rv = fspr_get_os_error(); } - apr_file_close(thefile); + fspr_file_close(thefile); } return rv; diff --git a/libs/apr/file_io/win32/filesys.c b/libs/apr/file_io/win32/filesys.c index ad31e3387a..0694cefac9 100644 --- a/libs/apr/file_io/win32/filesys.c +++ b/libs/apr/file_io/win32/filesys.c @@ -14,9 +14,9 @@ * limitations under the License. */ -#include "apr.h" -#include "apr_arch_file_io.h" -#include "apr_strings.h" +#include "fspr.h" +#include "fspr_arch_file_io.h" +#include "fspr_strings.h" /* Win32 Exceptions: * @@ -38,7 +38,7 @@ * Oddly, \x7f _is_ acceptable ;) */ -/* apr_c_is_fnchar[] maps Win32's file name and shell escape symbols +/* fspr_c_is_fnchar[] maps Win32's file name and shell escape symbols * * element & 1 == valid file name character [excluding delimiters] * element & 2 == character should be shell (caret) escaped from cmd.exe @@ -46,7 +46,7 @@ * this must be in-sync with Apache httpd's gen_test_char.c for cgi escaping. */ -const char apr_c_is_fnchar[256] = +const char fspr_c_is_fnchar[256] = {/* Reject all ctrl codes... Escape \n and \r (ascii 10 and 13) */ 0,0,0,0,0,0,0,0,0,0,2,0,0,2,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? */ @@ -63,15 +63,15 @@ const char apr_c_is_fnchar[256] = }; -apr_status_t filepath_root_test(char *path, apr_pool_t *p) +fspr_status_t filepath_root_test(char *path, fspr_pool_t *p) { - apr_status_t rv; + fspr_status_t rv; #if APR_HAS_UNICODE_FS - if (apr_os_level >= APR_WIN_NT) + if (fspr_os_level >= APR_WIN_NT) { - apr_wchar_t wpath[APR_PATH_MAX]; + fspr_wchar_t wpath[APR_PATH_MAX]; if (rv = utf8_to_unicode_path(wpath, sizeof(wpath) - / sizeof(apr_wchar_t), path)) + / sizeof(fspr_wchar_t), path)) return rv; rv = GetDriveTypeW(wpath); } @@ -85,24 +85,24 @@ apr_status_t filepath_root_test(char *path, apr_pool_t *p) } -apr_status_t filepath_drive_get(char **rootpath, char drive, - apr_int32_t flags, apr_pool_t *p) +fspr_status_t filepath_drive_get(char **rootpath, char drive, + fspr_int32_t flags, fspr_pool_t *p) { char path[APR_PATH_MAX]; #if APR_HAS_UNICODE_FS IF_WIN_OS_IS_UNICODE { - apr_wchar_t *ignored; - apr_wchar_t wdrive[8]; - apr_wchar_t wpath[APR_PATH_MAX]; - apr_status_t rv; + fspr_wchar_t *ignored; + fspr_wchar_t wdrive[8]; + fspr_wchar_t wpath[APR_PATH_MAX]; + fspr_status_t rv; /* ???: This needs review, apparently "\\?\d:." returns "\\?\d:" * as if that is useful for anything. */ wcscpy(wdrive, L"D:."); - wdrive[0] = (apr_wchar_t)(unsigned char)drive; - if (!GetFullPathNameW(wdrive, sizeof(wpath) / sizeof(apr_wchar_t), wpath, &ignored)) - return apr_get_os_error(); + wdrive[0] = (fspr_wchar_t)(unsigned char)drive; + if (!GetFullPathNameW(wdrive, sizeof(wpath) / sizeof(fspr_wchar_t), wpath, &ignored)) + return fspr_get_os_error(); if ((rv = unicode_to_utf8_path(path, sizeof(path), wpath))) return rv; } @@ -117,7 +117,7 @@ apr_status_t filepath_drive_get(char **rootpath, char drive, drivestr[2] = '.';; drivestr[3] = '\0'; if (!GetFullPathName(drivestr, sizeof(path), path, &ignored)) - return apr_get_os_error(); + return fspr_get_os_error(); } #endif if (!(flags & APR_FILEPATH_NATIVE)) { @@ -126,34 +126,34 @@ apr_status_t filepath_drive_get(char **rootpath, char drive, **rootpath = '/'; } } - *rootpath = apr_pstrdup(p, path); + *rootpath = fspr_pstrdup(p, path); return APR_SUCCESS; } -apr_status_t filepath_root_case(char **rootpath, char *root, apr_pool_t *p) +fspr_status_t filepath_root_case(char **rootpath, char *root, fspr_pool_t *p) { #if APR_HAS_UNICODE_FS IF_WIN_OS_IS_UNICODE { - apr_wchar_t *ignored; - apr_wchar_t wpath[APR_PATH_MAX]; - apr_status_t rv; - apr_wchar_t wroot[APR_PATH_MAX]; + fspr_wchar_t *ignored; + fspr_wchar_t wpath[APR_PATH_MAX]; + fspr_status_t rv; + fspr_wchar_t wroot[APR_PATH_MAX]; /* ???: This needs review, apparently "\\?\d:." returns "\\?\d:" * as if that is useful for anything. */ if (rv = utf8_to_unicode_path(wroot, sizeof(wroot) - / sizeof(apr_wchar_t), root)) + / sizeof(fspr_wchar_t), root)) return rv; - if (!GetFullPathNameW(wroot, sizeof(wpath) / sizeof(apr_wchar_t), wpath, &ignored)) - return apr_get_os_error(); + if (!GetFullPathNameW(wroot, sizeof(wpath) / sizeof(fspr_wchar_t), wpath, &ignored)) + return fspr_get_os_error(); /* Borrow wroot as a char buffer (twice as big as necessary) */ if ((rv = unicode_to_utf8_path((char*)wroot, sizeof(wroot), wpath))) return rv; - *rootpath = apr_pstrdup(p, (char*)wroot); + *rootpath = fspr_pstrdup(p, (char*)wroot); } #endif #if APR_HAS_ANSI_FS @@ -162,25 +162,25 @@ apr_status_t filepath_root_case(char **rootpath, char *root, apr_pool_t *p) char path[APR_PATH_MAX]; char *ignored; if (!GetFullPathName(root, sizeof(path), path, &ignored)) - return apr_get_os_error(); - *rootpath = apr_pstrdup(p, path); + return fspr_get_os_error(); + *rootpath = fspr_pstrdup(p, path); } #endif return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_filepath_get(char **rootpath, apr_int32_t flags, - apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_filepath_get(char **rootpath, fspr_int32_t flags, + fspr_pool_t *p) { char path[APR_PATH_MAX]; #if APR_HAS_UNICODE_FS IF_WIN_OS_IS_UNICODE { - apr_wchar_t wpath[APR_PATH_MAX]; - apr_status_t rv; - if (!GetCurrentDirectoryW(sizeof(wpath) / sizeof(apr_wchar_t), wpath)) - return apr_get_os_error(); + fspr_wchar_t wpath[APR_PATH_MAX]; + fspr_status_t rv; + if (!GetCurrentDirectoryW(sizeof(wpath) / sizeof(fspr_wchar_t), wpath)) + return fspr_get_os_error(); if ((rv = unicode_to_utf8_path(path, sizeof(path), wpath))) return rv; } @@ -189,7 +189,7 @@ APR_DECLARE(apr_status_t) apr_filepath_get(char **rootpath, apr_int32_t flags, ELSE_WIN_OS_IS_ANSI { if (!GetCurrentDirectory(sizeof(path), path)) - return apr_get_os_error(); + return fspr_get_os_error(); } #endif if (!(flags & APR_FILEPATH_NATIVE)) { @@ -198,31 +198,31 @@ APR_DECLARE(apr_status_t) apr_filepath_get(char **rootpath, apr_int32_t flags, **rootpath = '/'; } } - *rootpath = apr_pstrdup(p, path); + *rootpath = fspr_pstrdup(p, path); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_filepath_set(const char *rootpath, - apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_filepath_set(const char *rootpath, + fspr_pool_t *p) { #if APR_HAS_UNICODE_FS IF_WIN_OS_IS_UNICODE { - apr_wchar_t wpath[APR_PATH_MAX]; - apr_status_t rv; + fspr_wchar_t wpath[APR_PATH_MAX]; + fspr_status_t rv; if (rv = utf8_to_unicode_path(wpath, sizeof(wpath) - / sizeof(apr_wchar_t), rootpath)) + / sizeof(fspr_wchar_t), rootpath)) return rv; if (!SetCurrentDirectoryW(wpath)) - return apr_get_os_error(); + return fspr_get_os_error(); } #endif #if APR_HAS_ANSI_FS ELSE_WIN_OS_IS_ANSI { if (!SetCurrentDirectory(rootpath)) - return apr_get_os_error(); + return fspr_get_os_error(); } #endif return APR_SUCCESS; diff --git a/libs/apr/file_io/win32/flock.c b/libs/apr/file_io/win32/flock.c index e08e08a7a4..17b8459642 100644 --- a/libs/apr/file_io/win32/flock.c +++ b/libs/apr/file_io/win32/flock.c @@ -14,9 +14,9 @@ * limitations under the License. */ -#include "apr_arch_file_io.h" +#include "fspr_arch_file_io.h" -APR_DECLARE(apr_status_t) apr_file_lock(apr_file_t *thefile, int type) +APR_DECLARE(fspr_status_t) fspr_file_lock(fspr_file_t *thefile, int type) { #ifdef _WIN32_WCE /* The File locking is unsuported on WCE */ @@ -28,12 +28,12 @@ APR_DECLARE(apr_status_t) apr_file_lock(apr_file_t *thefile, int type) flags = ((type & APR_FLOCK_NONBLOCK) ? LOCKFILE_FAIL_IMMEDIATELY : 0) + (((type & APR_FLOCK_TYPEMASK) == APR_FLOCK_SHARED) ? 0 : LOCKFILE_EXCLUSIVE_LOCK); - if (apr_os_level >= APR_WIN_NT) { + if (fspr_os_level >= APR_WIN_NT) { /* Syntax is correct, len is passed for LengthLow and LengthHigh*/ OVERLAPPED offset; memset (&offset, 0, sizeof(offset)); if (!LockFileEx(thefile->filehand, flags, 0, len, len, &offset)) - return apr_get_os_error(); + return fspr_get_os_error(); } else { /* On Win9x, LockFile() never blocks. Hack in a crufty poll. @@ -62,23 +62,23 @@ APR_DECLARE(apr_status_t) apr_file_lock(apr_file_t *thefile, int type) #endif /* !defined(_WIN32_WCE) */ } -APR_DECLARE(apr_status_t) apr_file_unlock(apr_file_t *thefile) +APR_DECLARE(fspr_status_t) fspr_file_unlock(fspr_file_t *thefile) { #ifdef _WIN32_WCE return APR_ENOTIMPL; #else DWORD len = 0xffffffff; - if (apr_os_level >= APR_WIN_NT) { + if (fspr_os_level >= APR_WIN_NT) { /* Syntax is correct, len is passed for LengthLow and LengthHigh*/ OVERLAPPED offset; memset (&offset, 0, sizeof(offset)); if (!UnlockFileEx(thefile->filehand, 0, len, len, &offset)) - return apr_get_os_error(); + return fspr_get_os_error(); } else { if (!UnlockFile(thefile->filehand, 0, 0, len, 0)) - return apr_get_os_error(); + return fspr_get_os_error(); } return APR_SUCCESS; diff --git a/libs/apr/file_io/win32/open.c b/libs/apr/file_io/win32/open.c index b3a5176729..2ed23c1d33 100644 --- a/libs/apr/file_io/win32/open.c +++ b/libs/apr/file_io/win32/open.c @@ -14,13 +14,13 @@ * limitations under the License. */ -#include "apr_private.h" -#include "apr_arch_file_io.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_strings.h" -#include "apr_portable.h" -#include "apr_thread_mutex.h" +#include "fspr_private.h" +#include "fspr_arch_file_io.h" +#include "fspr_file_io.h" +#include "fspr_general.h" +#include "fspr_strings.h" +#include "fspr_portable.h" +#include "fspr_thread_mutex.h" #if APR_HAVE_ERRNO_H #include #endif @@ -29,11 +29,11 @@ #if APR_HAVE_SYS_STAT_H #include #endif -#include "apr_arch_misc.h" -#include "apr_arch_inherit.h" +#include "fspr_arch_misc.h" +#include "fspr_arch_inherit.h" #if APR_HAS_UNICODE_FS -apr_status_t utf8_to_unicode_path(apr_wchar_t* retstr, apr_size_t retlen, +fspr_status_t utf8_to_unicode_path(fspr_wchar_t* retstr, fspr_size_t retlen, const char* srcstr) { /* TODO: The computations could preconvert the string to determine @@ -48,9 +48,9 @@ apr_status_t utf8_to_unicode_path(apr_wchar_t* retstr, apr_size_t retlen, * Note that the \\?\ form only works for local drive paths, and * \\?\UNC\ is needed UNC paths. */ - apr_size_t srcremains = strlen(srcstr) + 1; - apr_wchar_t *t = retstr; - apr_status_t rv; + fspr_size_t srcremains = strlen(srcstr) + 1; + fspr_wchar_t *t = retstr; + fspr_status_t rv; /* This is correct, we don't twist the filename if it is will * definately be shorter than MAX_PATH. It merits some @@ -81,7 +81,7 @@ apr_status_t utf8_to_unicode_path(apr_wchar_t* retstr, apr_size_t retlen, } } - if (rv = apr_conv_utf8_to_ucs2(srcstr, &srcremains, t, &retlen)) { + if (rv = fspr_conv_utf8_to_ucs2(srcstr, &srcremains, t, &retlen)) { return (rv == APR_INCOMPLETE) ? APR_EINVAL : rv; } if (srcremains) { @@ -93,8 +93,8 @@ apr_status_t utf8_to_unicode_path(apr_wchar_t* retstr, apr_size_t retlen, return APR_SUCCESS; } -apr_status_t unicode_to_utf8_path(char* retstr, apr_size_t retlen, - const apr_wchar_t* srcstr) +fspr_status_t unicode_to_utf8_path(char* retstr, fspr_size_t retlen, + const fspr_wchar_t* srcstr) { /* Skip the leading 4 characters if the path begins \\?\, or substitute * // for the \\?\UNC\ path prefix, allocating the maximum string @@ -102,8 +102,8 @@ apr_status_t unicode_to_utf8_path(char* retstr, apr_size_t retlen, * then transform \\'s back into /'s since the \\?\ form never * allows '/' path seperators, and APR always uses '/'s. */ - apr_size_t srcremains = wcslen(srcstr) + 1; - apr_status_t rv; + fspr_size_t srcremains = wcslen(srcstr) + 1; + fspr_status_t rv; char *t = retstr; if (srcstr[0] == L'\\' && srcstr[1] == L'\\' && srcstr[2] == L'?' && srcstr[3] == L'\\') { @@ -122,7 +122,7 @@ apr_status_t unicode_to_utf8_path(char* retstr, apr_size_t retlen, } } - if (rv = apr_conv_ucs2_to_utf8(srcstr, &srcremains, t, &retlen)) { + if (rv = fspr_conv_ucs2_to_utf8(srcstr, &srcremains, t, &retlen)) { return rv; } if (srcremains) { @@ -132,17 +132,17 @@ apr_status_t unicode_to_utf8_path(char* retstr, apr_size_t retlen, } #endif -void *res_name_from_filename(const char *file, int global, apr_pool_t *pool) +void *res_name_from_filename(const char *file, int global, fspr_pool_t *pool) { #if APR_HAS_UNICODE_FS IF_WIN_OS_IS_UNICODE { - apr_wchar_t *wpre, *wfile, *ch; - apr_size_t n = strlen(file) + 1; - apr_size_t r, d; - apr_status_t rv; + fspr_wchar_t *wpre, *wfile, *ch; + fspr_size_t n = strlen(file) + 1; + fspr_size_t r, d; + fspr_status_t rv; - if (apr_os_level >= APR_WIN_2000) { + if (fspr_os_level >= APR_WIN_2000) { if (global) wpre = L"Global\\"; else @@ -161,10 +161,10 @@ void *res_name_from_filename(const char *file, int global, apr_pool_t *pool) --n; } } - wfile = apr_palloc(pool, (r + n) * sizeof(apr_wchar_t)); + wfile = fspr_palloc(pool, (r + n) * sizeof(fspr_wchar_t)); wcscpy(wfile, wpre); d = n; - if (rv = apr_conv_utf8_to_ucs2(file, &n, wfile + r, &d)) { + if (rv = fspr_conv_utf8_to_ucs2(file, &n, wfile + r, &d)) { return NULL; } for (ch = wfile + r; *ch; ++ch) { @@ -178,14 +178,14 @@ void *res_name_from_filename(const char *file, int global, apr_pool_t *pool) ELSE_WIN_OS_IS_ANSI { char *nfile, *ch; - apr_size_t n = strlen(file) + 1; + fspr_size_t n = strlen(file) + 1; #if !APR_HAS_UNICODE_FS - apr_status_t rv; - apr_size_t r, d; + fspr_status_t rv; + fspr_size_t r, d; char *pre; - if (apr_os_level >= APR_WIN_2000) { + if (fspr_os_level >= APR_WIN_2000) { if (global) pre = "Global\\"; else @@ -199,16 +199,16 @@ void *res_name_from_filename(const char *file, int global, apr_pool_t *pool) file += n - 256 - r; n = 256; } - nfile = apr_palloc(pool, (r + n) * sizeof(apr_wchar_t)); + nfile = fspr_palloc(pool, (r + n) * sizeof(fspr_wchar_t)); memcpy(nfile, pre, r); memcpy(nfile + r, file, n); #else - const apr_size_t r = 0; + const fspr_size_t r = 0; if (n > 256) { file += n - 256; n = 256; } - nfile = apr_pmemdup(pool, file, n); + nfile = fspr_pmemdup(pool, file, n); #endif for (ch = nfile + r; *ch; ++ch) { if (*ch == ':' || *ch == '/' || *ch == '\\') @@ -220,10 +220,10 @@ void *res_name_from_filename(const char *file, int global, apr_pool_t *pool) } -apr_status_t file_cleanup(void *thefile) +fspr_status_t file_cleanup(void *thefile) { - apr_file_t *file = thefile; - apr_status_t flush_rv = APR_SUCCESS; + fspr_file_t *file = thefile; + fspr_status_t flush_rv = APR_SUCCESS; if (file->filehand != INVALID_HANDLE_VALUE) { @@ -243,7 +243,7 @@ apr_status_t file_cleanup(void *thefile) if (file->buffered) { /* XXX: flush here is not mutex protected */ - flush_rv = apr_file_flush((apr_file_t *)thefile); + flush_rv = fspr_file_flush((fspr_file_t *)thefile); } CloseHandle(file->filehand); file->filehand = INVALID_HANDLE_VALUE; @@ -255,16 +255,16 @@ apr_status_t file_cleanup(void *thefile) return flush_rv; } -APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new, const char *fname, - apr_int32_t flag, apr_fileperms_t perm, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_file_open(fspr_file_t **new, const char *fname, + fspr_int32_t flag, fspr_fileperms_t perm, + fspr_pool_t *pool) { HANDLE handle = INVALID_HANDLE_VALUE; DWORD oflags = 0; DWORD createflags = 0; DWORD attributes = 0; DWORD sharemode = FILE_SHARE_READ | FILE_SHARE_WRITE; - apr_status_t rv; + fspr_status_t rv; if (flag & APR_READ) { oflags |= GENERIC_READ; @@ -276,7 +276,7 @@ APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new, const char *fname, oflags |= FILE_WRITE_ATTRIBUTES; } - if (apr_os_level >= APR_WIN_NT) + if (fspr_os_level >= APR_WIN_NT) sharemode |= FILE_SHARE_DELETE; if (flag & APR_CREATE) { @@ -310,7 +310,7 @@ APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new, const char *fname, attributes |= FILE_FLAG_OPEN_REPARSE_POINT; } - /* Without READ or WRITE, we fail unless apr called apr_file_open + /* Without READ or WRITE, we fail unless apr called fspr_file_open * internally with the private APR_OPENINFO flag. * * With the APR_OPENINFO flag on NT, use the option flag @@ -319,7 +319,7 @@ APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new, const char *fname, */ if (!(flag & (APR_READ | APR_WRITE))) { if (flag & APR_OPENINFO) { - if (apr_os_level >= APR_WIN_NT) { + if (fspr_os_level >= APR_WIN_NT) { attributes |= FILE_FLAG_BACKUP_SEMANTICS; } } @@ -340,7 +340,7 @@ APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new, const char *fname, #if APR_HAS_UNICODE_FS IF_WIN_OS_IS_UNICODE { - apr_wchar_t wfname[APR_PATH_MAX]; + fspr_wchar_t wfname[APR_PATH_MAX]; if (flag & APR_SENDFILE_ENABLED) { /* This feature is required to enable sendfile operations @@ -351,7 +351,7 @@ APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new, const char *fname, } if (rv = utf8_to_unicode_path(wfname, sizeof(wfname) - / sizeof(apr_wchar_t), fname)) + / sizeof(fspr_wchar_t), fname)) return rv; handle = CreateFileW(wfname, oflags, sharemode, NULL, createflags, attributes, 0); @@ -370,13 +370,13 @@ APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new, const char *fname, } #endif if (handle == INVALID_HANDLE_VALUE) { - return apr_get_os_error(); + return fspr_get_os_error(); } - (*new) = (apr_file_t *)apr_pcalloc(pool, sizeof(apr_file_t)); + (*new) = (fspr_file_t *)fspr_pcalloc(pool, sizeof(fspr_file_t)); (*new)->pool = pool; (*new)->filehand = handle; - (*new)->fname = apr_pstrdup(pool, fname); + (*new)->fname = fspr_pstrdup(pool, fname); (*new)->flags = flag; (*new)->timeout = -1; (*new)->ungetchar = -1; @@ -387,15 +387,15 @@ APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new, const char *fname, } if (flag & APR_BUFFERED) { (*new)->buffered = 1; - (*new)->buffer = apr_palloc(pool, APR_FILE_BUFSIZE); + (*new)->buffer = fspr_palloc(pool, APR_FILE_BUFSIZE); } /* Need the mutex to handled buffered and O_APPEND style file i/o */ if ((*new)->buffered || (*new)->append) { - rv = apr_thread_mutex_create(&(*new)->mutex, + rv = fspr_thread_mutex_create(&(*new)->mutex, APR_THREAD_MUTEX_DEFAULT, pool); if (rv) { if (file_cleanup(*new) == APR_SUCCESS) { - apr_pool_cleanup_kill(pool, *new, file_cleanup); + fspr_pool_cleanup_kill(pool, *new, file_cleanup); } return rv; } @@ -403,23 +403,23 @@ APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new, const char *fname, /* Create a pollset with room for one descriptor. */ /* ### check return codes */ - (void) apr_pollset_create(&(*new)->pollset, 1, pool, 0); + (void) fspr_pollset_create(&(*new)->pollset, 1, pool, 0); if (!(flag & APR_FILE_NOCLEANUP)) { - apr_pool_cleanup_register((*new)->pool, (void *)(*new), file_cleanup, - apr_pool_cleanup_null); + fspr_pool_cleanup_register((*new)->pool, (void *)(*new), file_cleanup, + fspr_pool_cleanup_null); } return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_file_close(apr_file_t *file) +APR_DECLARE(fspr_status_t) fspr_file_close(fspr_file_t *file) { - apr_status_t stat; + fspr_status_t stat; if ((stat = file_cleanup(file)) == APR_SUCCESS) { - apr_pool_cleanup_kill(file->pool, file, file_cleanup); + fspr_pool_cleanup_kill(file->pool, file, file_cleanup); if (file->mutex) { - apr_thread_mutex_destroy(file->mutex); + fspr_thread_mutex_destroy(file->mutex); } return APR_SUCCESS; @@ -427,15 +427,15 @@ APR_DECLARE(apr_status_t) apr_file_close(apr_file_t *file) return stat; } -APR_DECLARE(apr_status_t) apr_file_remove(const char *path, apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_file_remove(const char *path, fspr_pool_t *pool) { #if APR_HAS_UNICODE_FS IF_WIN_OS_IS_UNICODE { - apr_wchar_t wpath[APR_PATH_MAX]; - apr_status_t rv; + fspr_wchar_t wpath[APR_PATH_MAX]; + fspr_status_t rv; if (rv = utf8_to_unicode_path(wpath, sizeof(wpath) - / sizeof(apr_wchar_t), path)) { + / sizeof(fspr_wchar_t), path)) { return rv; } if (DeleteFileW(wpath)) @@ -447,24 +447,24 @@ APR_DECLARE(apr_status_t) apr_file_remove(const char *path, apr_pool_t *pool) if (DeleteFile(path)) return APR_SUCCESS; #endif - return apr_get_os_error(); + return fspr_get_os_error(); } -APR_DECLARE(apr_status_t) apr_file_rename(const char *frompath, +APR_DECLARE(fspr_status_t) fspr_file_rename(const char *frompath, const char *topath, - apr_pool_t *pool) + fspr_pool_t *pool) { IF_WIN_OS_IS_UNICODE { #if APR_HAS_UNICODE_FS - apr_wchar_t wfrompath[APR_PATH_MAX], wtopath[APR_PATH_MAX]; - apr_status_t rv; + fspr_wchar_t wfrompath[APR_PATH_MAX], wtopath[APR_PATH_MAX]; + fspr_status_t rv; if (rv = utf8_to_unicode_path(wfrompath, sizeof(wfrompath) - / sizeof(apr_wchar_t), frompath)) { + / sizeof(fspr_wchar_t), frompath)) { return rv; } if (rv = utf8_to_unicode_path(wtopath, sizeof(wtopath) - / sizeof(apr_wchar_t), topath)) { + / sizeof(fspr_wchar_t), topath)) { return rv; } #ifndef _WIN32_WCE @@ -496,28 +496,28 @@ APR_DECLARE(apr_status_t) apr_file_rename(const char *frompath, { CloseHandle(handle); if (!DeleteFile(topath)) - return apr_get_os_error(); + return fspr_get_os_error(); } if (MoveFile(frompath, topath)) return APR_SUCCESS; } #endif - return apr_get_os_error(); + return fspr_get_os_error(); } -APR_DECLARE(apr_status_t) apr_os_file_get(apr_os_file_t *thefile, - apr_file_t *file) +APR_DECLARE(fspr_status_t) fspr_os_file_get(fspr_os_file_t *thefile, + fspr_file_t *file) { *thefile = file->filehand; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_os_file_put(apr_file_t **file, - apr_os_file_t *thefile, - apr_int32_t flags, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_os_file_put(fspr_file_t **file, + fspr_os_file_t *thefile, + fspr_int32_t flags, + fspr_pool_t *pool) { - (*file) = apr_pcalloc(pool, sizeof(apr_file_t)); + (*file) = fspr_pcalloc(pool, sizeof(fspr_file_t)); (*file)->pool = pool; (*file)->filehand = *thefile; (*file)->ungetchar = -1; /* no char avail */ @@ -529,16 +529,16 @@ APR_DECLARE(apr_status_t) apr_os_file_put(apr_file_t **file, } if (flags & APR_BUFFERED) { (*file)->buffered = 1; - (*file)->buffer = apr_palloc(pool, APR_FILE_BUFSIZE); + (*file)->buffer = fspr_palloc(pool, APR_FILE_BUFSIZE); } if ((*file)->append || (*file)->buffered) { - apr_status_t rv; - rv = apr_thread_mutex_create(&(*file)->mutex, + fspr_status_t rv; + rv = fspr_thread_mutex_create(&(*file)->mutex, APR_THREAD_MUTEX_DEFAULT, pool); if (rv) { if (file_cleanup(*file) == APR_SUCCESS) { - apr_pool_cleanup_kill(pool, *file, file_cleanup); + fspr_pool_cleanup_kill(pool, *file, file_cleanup); } return rv; } @@ -546,7 +546,7 @@ APR_DECLARE(apr_status_t) apr_os_file_put(apr_file_t **file, /* Create a pollset with room for one descriptor. */ /* ### check return codes */ - (void) apr_pollset_create(&(*file)->pollset, 1, pool, 0); + (void) fspr_pollset_create(&(*file)->pollset, 1, pool, 0); /* XXX... we pcalloc above so all others are zeroed. * Should we be testing if thefile is a handle to @@ -557,7 +557,7 @@ APR_DECLARE(apr_status_t) apr_os_file_put(apr_file_t **file, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_file_eof(apr_file_t *fptr) +APR_DECLARE(fspr_status_t) fspr_file_eof(fspr_file_t *fptr) { if (fptr->eof_hit == 1) { return APR_EOF; @@ -565,66 +565,66 @@ APR_DECLARE(apr_status_t) apr_file_eof(apr_file_t *fptr) return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_file_open_stderr(apr_file_t **thefile, apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_file_open_stderr(fspr_file_t **thefile, fspr_pool_t *pool) { #ifdef _WIN32_WCE return APR_ENOTIMPL; #else - apr_os_file_t file_handle; + fspr_os_file_t file_handle; - apr_set_os_error(APR_SUCCESS); + fspr_set_os_error(APR_SUCCESS); file_handle = GetStdHandle(STD_ERROR_HANDLE); if (!file_handle || (file_handle == INVALID_HANDLE_VALUE)) { - apr_status_t rv = apr_get_os_error(); + fspr_status_t rv = fspr_get_os_error(); if (rv == APR_SUCCESS) { return APR_EINVAL; } return rv; } - return apr_os_file_put(thefile, &file_handle, 0, pool); + return fspr_os_file_put(thefile, &file_handle, 0, pool); #endif } -APR_DECLARE(apr_status_t) apr_file_open_stdout(apr_file_t **thefile, apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_file_open_stdout(fspr_file_t **thefile, fspr_pool_t *pool) { #ifdef _WIN32_WCE return APR_ENOTIMPL; #else - apr_os_file_t file_handle; + fspr_os_file_t file_handle; - apr_set_os_error(APR_SUCCESS); + fspr_set_os_error(APR_SUCCESS); file_handle = GetStdHandle(STD_OUTPUT_HANDLE); if (!file_handle || (file_handle == INVALID_HANDLE_VALUE)) { - apr_status_t rv = apr_get_os_error(); + fspr_status_t rv = fspr_get_os_error(); if (rv == APR_SUCCESS) { return APR_EINVAL; } return rv; } - return apr_os_file_put(thefile, &file_handle, 0, pool); + return fspr_os_file_put(thefile, &file_handle, 0, pool); #endif } -APR_DECLARE(apr_status_t) apr_file_open_stdin(apr_file_t **thefile, apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_file_open_stdin(fspr_file_t **thefile, fspr_pool_t *pool) { #ifdef _WIN32_WCE return APR_ENOTIMPL; #else - apr_os_file_t file_handle; + fspr_os_file_t file_handle; - apr_set_os_error(APR_SUCCESS); + fspr_set_os_error(APR_SUCCESS); file_handle = GetStdHandle(STD_INPUT_HANDLE); if (!file_handle || (file_handle == INVALID_HANDLE_VALUE)) { - apr_status_t rv = apr_get_os_error(); + fspr_status_t rv = fspr_get_os_error(); if (rv == APR_SUCCESS) { return APR_EINVAL; } return rv; } - return apr_os_file_put(thefile, &file_handle, 0, pool); + return fspr_os_file_put(thefile, &file_handle, 0, pool); #endif } diff --git a/libs/apr/file_io/win32/pipe.c b/libs/apr/file_io/win32/pipe.c index cda79e3af3..a9da026a37 100644 --- a/libs/apr/file_io/win32/pipe.c +++ b/libs/apr/file_io/win32/pipe.c @@ -14,10 +14,10 @@ * limitations under the License. */ -#include "win32/apr_arch_file_io.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_strings.h" +#include "win32/fspr_arch_file_io.h" +#include "fspr_file_io.h" +#include "fspr_general.h" +#include "fspr_strings.h" #if APR_HAVE_ERRNO_H #include #endif @@ -29,9 +29,9 @@ #if APR_HAVE_SYS_STAT_H #include #endif -#include "apr_arch_misc.h" +#include "fspr_arch_misc.h" -APR_DECLARE(apr_status_t) apr_file_pipe_timeout_set(apr_file_t *thepipe, apr_interval_time_t timeout) +APR_DECLARE(fspr_status_t) fspr_file_pipe_timeout_set(fspr_file_t *thepipe, fspr_interval_time_t timeout) { /* Always OK to unset timeouts */ if (timeout == -1) { @@ -50,30 +50,30 @@ APR_DECLARE(apr_status_t) apr_file_pipe_timeout_set(apr_file_t *thepipe, apr_int return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_file_pipe_timeout_get(apr_file_t *thepipe, apr_interval_time_t *timeout) +APR_DECLARE(fspr_status_t) fspr_file_pipe_timeout_get(fspr_file_t *thepipe, fspr_interval_time_t *timeout) { /* Always OK to get the timeout (even if it's unset ... -1) */ *timeout = thepipe->timeout; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_file_pipe_create(apr_file_t **in, apr_file_t **out, apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_file_pipe_create(fspr_file_t **in, fspr_file_t **out, fspr_pool_t *p) { /* Unix creates full blocking pipes. */ - return apr_create_nt_pipe(in, out, APR_FULL_BLOCK, p); + return fspr_create_nt_pipe(in, out, APR_FULL_BLOCK, p); } -/* apr_create_nt_pipe() - * An internal (for now) APR function used by apr_proc_create() +/* fspr_create_nt_pipe() + * An internal (for now) APR function used by fspr_proc_create() * when setting up pipes to communicate with the child process. - * apr_create_nt_pipe() allows setting the blocking mode of each end of + * fspr_create_nt_pipe() allows setting the blocking mode of each end of * the pipe when the pipe is created (rather than after the pipe is created). * A pipe handle must be opened in full async i/o mode in order to * emulate Unix non-blocking pipes with timeouts. * * In general, we don't want to enable child side pipe handles for async i/o. * This prevents us from enabling both ends of the pipe for async i/o in - * apr_file_pipe_create. + * fspr_file_pipe_create. * * Why not use NamedPipes on NT which support setting pipe state to * non-blocking? On NT, even though you can set a pipe non-blocking, @@ -81,9 +81,9 @@ APR_DECLARE(apr_status_t) apr_file_pipe_create(apr_file_t **in, apr_file_t **out * WaitForSinglelObject, et. al. will not detect pipe i/o). On NT, you * have to poll the pipe to detect i/o on a non-blocking pipe. */ -apr_status_t apr_create_nt_pipe(apr_file_t **in, apr_file_t **out, - apr_int32_t blocking_mode, - apr_pool_t *p) +fspr_status_t fspr_create_nt_pipe(fspr_file_t **in, fspr_file_t **out, + fspr_int32_t blocking_mode, + fspr_pool_t *p) { #ifdef _WIN32_WCE return APR_ENOTIMPL; @@ -98,7 +98,7 @@ apr_status_t apr_create_nt_pipe(apr_file_t **in, apr_file_t **out, sa.bInheritHandle = TRUE; sa.lpSecurityDescriptor = NULL; - (*in) = (apr_file_t *)apr_pcalloc(p, sizeof(apr_file_t)); + (*in) = (fspr_file_t *)fspr_pcalloc(p, sizeof(fspr_file_t)); (*in)->pool = p; (*in)->fname = NULL; (*in)->pipe = 1; @@ -110,9 +110,9 @@ apr_status_t apr_create_nt_pipe(apr_file_t **in, apr_file_t **out, (*in)->dataRead = 0; (*in)->direction = 0; (*in)->pOverlapped = NULL; - (void) apr_pollset_create(&(*in)->pollset, 1, p, 0); + (void) fspr_pollset_create(&(*in)->pollset, 1, p, 0); - (*out) = (apr_file_t *)apr_pcalloc(p, sizeof(apr_file_t)); + (*out) = (fspr_file_t *)fspr_pcalloc(p, sizeof(fspr_file_t)); (*out)->pool = p; (*out)->fname = NULL; (*out)->pipe = 1; @@ -124,15 +124,15 @@ apr_status_t apr_create_nt_pipe(apr_file_t **in, apr_file_t **out, (*out)->dataRead = 0; (*out)->direction = 0; (*out)->pOverlapped = NULL; - (void) apr_pollset_create(&(*out)->pollset, 1, p, 0); + (void) fspr_pollset_create(&(*out)->pollset, 1, p, 0); - if (apr_os_level >= APR_WIN_NT) { + if (fspr_os_level >= APR_WIN_NT) { /* Create the read end of the pipe */ dwOpenMode = PIPE_ACCESS_INBOUND; if (blocking_mode == APR_WRITE_BLOCK /* READ_NONBLOCK */ || blocking_mode == APR_FULL_NONBLOCK) { dwOpenMode |= FILE_FLAG_OVERLAPPED; - (*in)->pOverlapped = (OVERLAPPED*) apr_pcalloc(p, sizeof(OVERLAPPED)); + (*in)->pOverlapped = (OVERLAPPED*) fspr_pcalloc(p, sizeof(OVERLAPPED)); (*in)->pOverlapped->hEvent = CreateEvent(NULL, FALSE, FALSE, NULL); } @@ -154,7 +154,7 @@ apr_status_t apr_create_nt_pipe(apr_file_t **in, apr_file_t **out, if (blocking_mode == APR_READ_BLOCK /* WRITE_NONBLOCK */ || blocking_mode == APR_FULL_NONBLOCK) { dwOpenMode |= FILE_FLAG_OVERLAPPED; - (*out)->pOverlapped = (OVERLAPPED*) apr_pcalloc(p, sizeof(OVERLAPPED)); + (*out)->pOverlapped = (OVERLAPPED*) fspr_pcalloc(p, sizeof(OVERLAPPED)); (*out)->pOverlapped->hEvent = CreateEvent(NULL, FALSE, FALSE, NULL); } @@ -169,22 +169,22 @@ apr_status_t apr_create_nt_pipe(apr_file_t **in, apr_file_t **out, else { /* Pipes on Win9* are blocking. Live with it. */ if (!CreatePipe(&(*in)->filehand, &(*out)->filehand, &sa, 65536)) { - return apr_get_os_error(); + return fspr_get_os_error(); } } - apr_pool_cleanup_register((*in)->pool, (void *)(*in), file_cleanup, - apr_pool_cleanup_null); - apr_pool_cleanup_register((*out)->pool, (void *)(*out), file_cleanup, - apr_pool_cleanup_null); + fspr_pool_cleanup_register((*in)->pool, (void *)(*in), file_cleanup, + fspr_pool_cleanup_null); + fspr_pool_cleanup_register((*out)->pool, (void *)(*out), file_cleanup, + fspr_pool_cleanup_null); return APR_SUCCESS; #endif /* _WIN32_WCE */ } -APR_DECLARE(apr_status_t) apr_file_namedpipe_create(const char *filename, - apr_fileperms_t perm, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_file_namedpipe_create(const char *filename, + fspr_fileperms_t perm, + fspr_pool_t *pool) { /* Not yet implemented, interface not suitable. * Win32 requires the named pipe to be *opened* at the time it's @@ -200,31 +200,31 @@ APR_DECLARE(apr_status_t) apr_file_namedpipe_create(const char *filename, * would be to handle stdio-style or blocking pipes. Win32 doesn't have * select() blocking for pipes anyways :( */ -APR_DECLARE(apr_status_t) apr_os_pipe_put_ex(apr_file_t **file, - apr_os_file_t *thefile, +APR_DECLARE(fspr_status_t) fspr_os_pipe_put_ex(fspr_file_t **file, + fspr_os_file_t *thefile, int register_cleanup, - apr_pool_t *pool) + fspr_pool_t *pool) { - (*file) = apr_pcalloc(pool, sizeof(apr_file_t)); + (*file) = fspr_pcalloc(pool, sizeof(fspr_file_t)); (*file)->pool = pool; (*file)->pipe = 1; (*file)->timeout = -1; (*file)->ungetchar = -1; (*file)->filehand = *thefile; - (void) apr_pollset_create(&(*file)->pollset, 1, pool, 0); + (void) fspr_pollset_create(&(*file)->pollset, 1, pool, 0); if (register_cleanup) { - apr_pool_cleanup_register(pool, *file, file_cleanup, - apr_pool_cleanup_null); + fspr_pool_cleanup_register(pool, *file, file_cleanup, + fspr_pool_cleanup_null); } return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_os_pipe_put(apr_file_t **file, - apr_os_file_t *thefile, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_os_pipe_put(fspr_file_t **file, + fspr_os_file_t *thefile, + fspr_pool_t *pool) { - return apr_os_pipe_put_ex(file, thefile, 0, pool); + return fspr_os_pipe_put_ex(file, thefile, 0, pool); } diff --git a/libs/apr/file_io/win32/readwrite.c b/libs/apr/file_io/win32/readwrite.c index d15ac7c1ac..a0acc26943 100644 --- a/libs/apr/file_io/win32/readwrite.c +++ b/libs/apr/file_io/win32/readwrite.c @@ -14,23 +14,23 @@ * limitations under the License. */ -#include "win32/apr_arch_file_io.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_strings.h" -#include "apr_lib.h" -#include "apr_errno.h" +#include "win32/fspr_arch_file_io.h" +#include "fspr_file_io.h" +#include "fspr_general.h" +#include "fspr_strings.h" +#include "fspr_lib.h" +#include "fspr_errno.h" #include -#include "apr_arch_atime.h" -#include "apr_arch_misc.h" +#include "fspr_arch_atime.h" +#include "fspr_arch_misc.h" /* * read_with_timeout() * Uses async i/o to emulate unix non-blocking i/o with timeouts. */ -static apr_status_t read_with_timeout(apr_file_t *file, void *buf, apr_size_t len_in, apr_size_t *nbytes) +static fspr_status_t read_with_timeout(fspr_file_t *file, void *buf, fspr_size_t len_in, fspr_size_t *nbytes) { - apr_status_t rv; + fspr_status_t rv; DWORD len = (DWORD)len_in; DWORD bytesread = 0; @@ -42,7 +42,7 @@ static apr_status_t read_with_timeout(apr_file_t *file, void *buf, apr_size_t le if (file->pipe) { DWORD bytes; if (!PeekNamedPipe(file->filehand, NULL, 0, NULL, &bytes, NULL)) { - rv = apr_get_os_error(); + rv = fspr_get_os_error(); if (rv == APR_FROM_OS_ERROR(ERROR_BROKEN_PIPE)) { rv = APR_EOF; } @@ -77,7 +77,7 @@ static apr_status_t read_with_timeout(apr_file_t *file, void *buf, apr_size_t le *nbytes = bytesread; if (!rv) { - rv = apr_get_os_error(); + rv = fspr_get_os_error(); if (rv == APR_FROM_OS_ERROR(ERROR_IO_PENDING)) { /* Wait for the pending i/o */ if (file->timeout > 0) { @@ -101,7 +101,7 @@ static apr_status_t read_with_timeout(apr_file_t *file, void *buf, apr_size_t le break; case WAIT_FAILED: - rv = apr_get_os_error(); + rv = fspr_get_os_error(); break; default: @@ -109,7 +109,7 @@ static apr_status_t read_with_timeout(apr_file_t *file, void *buf, apr_size_t le } if (rv != APR_SUCCESS) { - if (apr_os_level >= APR_WIN_98) { + if (fspr_os_level >= APR_WIN_98) { CancelIo(file->filehand); } } @@ -131,9 +131,9 @@ static apr_status_t read_with_timeout(apr_file_t *file, void *buf, apr_size_t le return rv; } -APR_DECLARE(apr_status_t) apr_file_read(apr_file_t *thefile, void *buf, apr_size_t *len) +APR_DECLARE(fspr_status_t) fspr_file_read(fspr_file_t *thefile, void *buf, fspr_size_t *len) { - apr_status_t rv; + fspr_status_t rv; DWORD bytes_read = 0; if (*len <= 0) { @@ -143,14 +143,14 @@ APR_DECLARE(apr_status_t) apr_file_read(apr_file_t *thefile, void *buf, apr_size /* If the file is open for xthread support, allocate and * initialize the overlapped and io completion event (hEvent). - * Threads should NOT share an apr_file_t or its hEvent. + * Threads should NOT share an fspr_file_t or its hEvent. */ if ((thefile->flags & APR_XTHREAD) && !thefile->pOverlapped ) { - thefile->pOverlapped = (OVERLAPPED*) apr_pcalloc(thefile->pool, + thefile->pOverlapped = (OVERLAPPED*) fspr_pcalloc(thefile->pool, sizeof(OVERLAPPED)); thefile->pOverlapped->hEvent = CreateEvent(NULL, FALSE, FALSE, NULL); if (!thefile->pOverlapped->hEvent) { - rv = apr_get_os_error(); + rv = fspr_get_os_error(); return rv; } } @@ -169,15 +169,15 @@ APR_DECLARE(apr_status_t) apr_file_read(apr_file_t *thefile, void *buf, apr_size } if (thefile->buffered) { char *pos = (char *)buf; - apr_size_t blocksize; - apr_size_t size = *len; + fspr_size_t blocksize; + fspr_size_t size = *len; - apr_thread_mutex_lock(thefile->mutex); + fspr_thread_mutex_lock(thefile->mutex); if (thefile->direction == 1) { - rv = apr_file_flush(thefile); + rv = fspr_file_flush(thefile); if (rv != APR_SUCCESS) { - apr_thread_mutex_unlock(thefile->mutex); + fspr_thread_mutex_unlock(thefile->mutex); return rv; } thefile->bufpos = 0; @@ -188,7 +188,7 @@ APR_DECLARE(apr_status_t) apr_file_read(apr_file_t *thefile, void *buf, apr_size rv = 0; while (rv == 0 && size > 0) { if (thefile->bufpos >= thefile->dataRead) { - apr_size_t read; + fspr_size_t read; rv = read_with_timeout(thefile, thefile->buffer, APR_FILE_BUFSIZE, &read); if (read == 0) { @@ -214,10 +214,10 @@ APR_DECLARE(apr_status_t) apr_file_read(apr_file_t *thefile, void *buf, apr_size if (*len) { rv = APR_SUCCESS; } - apr_thread_mutex_unlock(thefile->mutex); + fspr_thread_mutex_unlock(thefile->mutex); } else { /* Unbuffered i/o */ - apr_size_t nbytes; + fspr_size_t nbytes; rv = read_with_timeout(thefile, buf, *len, &nbytes); if (rv == APR_EOF) thefile->eof_hit = TRUE; @@ -227,35 +227,35 @@ APR_DECLARE(apr_status_t) apr_file_read(apr_file_t *thefile, void *buf, apr_size return rv; } -APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, apr_size_t *nbytes) +APR_DECLARE(fspr_status_t) fspr_file_write(fspr_file_t *thefile, const void *buf, fspr_size_t *nbytes) { - apr_status_t rv; + fspr_status_t rv; DWORD bwrote; /* If the file is open for xthread support, allocate and * initialize the overlapped and io completion event (hEvent). - * Threads should NOT share an apr_file_t or its hEvent. + * Threads should NOT share an fspr_file_t or its hEvent. */ if ((thefile->flags & APR_XTHREAD) && !thefile->pOverlapped ) { - thefile->pOverlapped = (OVERLAPPED*) apr_pcalloc(thefile->pool, + thefile->pOverlapped = (OVERLAPPED*) fspr_pcalloc(thefile->pool, sizeof(OVERLAPPED)); thefile->pOverlapped->hEvent = CreateEvent(NULL, FALSE, FALSE, NULL); if (!thefile->pOverlapped->hEvent) { - rv = apr_get_os_error(); + rv = fspr_get_os_error(); return rv; } } if (thefile->buffered) { char *pos = (char *)buf; - apr_size_t blocksize; - apr_size_t size = *nbytes; + fspr_size_t blocksize; + fspr_size_t size = *nbytes; - apr_thread_mutex_lock(thefile->mutex); + fspr_thread_mutex_lock(thefile->mutex); if (thefile->direction == 0) { // Position file pointer for writing at the offset we are logically reading from - apr_off_t offset = thefile->filePtr - thefile->dataRead + thefile->bufpos; + fspr_off_t offset = thefile->filePtr - thefile->dataRead + thefile->bufpos; DWORD offlo = (DWORD)offset; DWORD offhi = (DWORD)(offset >> 32); if (offset != thefile->filePtr) @@ -267,7 +267,7 @@ APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, a rv = 0; while (rv == 0 && size > 0) { if (thefile->bufpos == APR_FILE_BUFSIZE) // write buffer is full - rv = apr_file_flush(thefile); + rv = fspr_file_flush(thefile); blocksize = size > APR_FILE_BUFSIZE - thefile->bufpos ? APR_FILE_BUFSIZE - thefile->bufpos : size; memcpy(thefile->buffer + thefile->bufpos, pos, blocksize); @@ -276,27 +276,27 @@ APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, a size -= blocksize; } - apr_thread_mutex_unlock(thefile->mutex); + fspr_thread_mutex_unlock(thefile->mutex); return rv; } else { if (!thefile->pipe) { - apr_off_t offset = 0; - apr_status_t rc; + fspr_off_t offset = 0; + fspr_status_t rc; if (thefile->append) { - /* apr_file_lock will mutex the file across processes. - * The call to apr_thread_mutex_lock is added to avoid + /* fspr_file_lock will mutex the file across processes. + * The call to fspr_thread_mutex_lock is added to avoid * a race condition between LockFile and WriteFile * that occasionally leads to deadlocked threads. */ - apr_thread_mutex_lock(thefile->mutex); - rc = apr_file_lock(thefile, APR_FLOCK_EXCLUSIVE); + fspr_thread_mutex_lock(thefile->mutex); + rc = fspr_file_lock(thefile, APR_FLOCK_EXCLUSIVE); if (rc != APR_SUCCESS) { - apr_thread_mutex_unlock(thefile->mutex); + fspr_thread_mutex_unlock(thefile->mutex); return rc; } - rc = apr_file_seek(thefile, APR_END, &offset); + rc = fspr_file_seek(thefile, APR_END, &offset); if (rc != APR_SUCCESS) { - apr_thread_mutex_unlock(thefile->mutex); + fspr_thread_mutex_unlock(thefile->mutex); return rc; } } @@ -307,8 +307,8 @@ APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, a rv = WriteFile(thefile->filehand, buf, (DWORD)*nbytes, &bwrote, thefile->pOverlapped); if (thefile->append) { - apr_file_unlock(thefile); - apr_thread_mutex_unlock(thefile->mutex); + fspr_file_unlock(thefile); + fspr_thread_mutex_unlock(thefile->mutex); } } else { @@ -321,7 +321,7 @@ APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, a } else { (*nbytes) = 0; - rv = apr_get_os_error(); + rv = fspr_get_os_error(); if (rv == APR_FROM_OS_ERROR(ERROR_IO_PENDING)) { DWORD timeout_ms; @@ -348,13 +348,13 @@ APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, a rv = APR_TIMEUP; break; case WAIT_FAILED: - rv = apr_get_os_error(); + rv = fspr_get_os_error(); break; default: break; } if (rv != APR_SUCCESS) { - if (apr_os_level >= APR_WIN_98) + if (fspr_os_level >= APR_WIN_98) CancelIo(thefile->filehand); } } @@ -368,21 +368,21 @@ APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, a /* ToDo: Write for it anyway and test the oslevel! * Too bad WriteFileGather() is not supported on 95&98 (or NT prior to SP2) */ -APR_DECLARE(apr_status_t) apr_file_writev(apr_file_t *thefile, +APR_DECLARE(fspr_status_t) fspr_file_writev(fspr_file_t *thefile, const struct iovec *vec, - apr_size_t nvec, - apr_size_t *nbytes) + fspr_size_t nvec, + fspr_size_t *nbytes) { - apr_status_t rv = APR_SUCCESS; - apr_size_t i; - apr_size_t bwrote = 0; + fspr_status_t rv = APR_SUCCESS; + fspr_size_t i; + fspr_size_t bwrote = 0; char *buf; *nbytes = 0; for (i = 0; i < nvec; i++) { buf = vec[i].iov_base; bwrote = vec[i].iov_len; - rv = apr_file_write(thefile, buf, &bwrote); + rv = fspr_file_write(thefile, buf, &bwrote); *nbytes += bwrote; if (rv != APR_SUCCESS) { break; @@ -391,26 +391,26 @@ APR_DECLARE(apr_status_t) apr_file_writev(apr_file_t *thefile, return rv; } -APR_DECLARE(apr_status_t) apr_file_putc(char ch, apr_file_t *thefile) +APR_DECLARE(fspr_status_t) fspr_file_putc(char ch, fspr_file_t *thefile) { - apr_size_t len = 1; + fspr_size_t len = 1; - return apr_file_write(thefile, &ch, &len); + return fspr_file_write(thefile, &ch, &len); } -APR_DECLARE(apr_status_t) apr_file_ungetc(char ch, apr_file_t *thefile) +APR_DECLARE(fspr_status_t) fspr_file_ungetc(char ch, fspr_file_t *thefile) { thefile->ungetchar = (unsigned char) ch; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_file_getc(char *ch, apr_file_t *thefile) +APR_DECLARE(fspr_status_t) fspr_file_getc(char *ch, fspr_file_t *thefile) { - apr_status_t rc; - apr_size_t bread; + fspr_status_t rc; + fspr_size_t bread; bread = 1; - rc = apr_file_read(thefile, ch, &bread); + rc = fspr_file_read(thefile, ch, &bread); if (rc) { return rc; @@ -423,22 +423,22 @@ APR_DECLARE(apr_status_t) apr_file_getc(char *ch, apr_file_t *thefile) return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_file_puts(const char *str, apr_file_t *thefile) +APR_DECLARE(fspr_status_t) fspr_file_puts(const char *str, fspr_file_t *thefile) { - apr_size_t len = strlen(str); + fspr_size_t len = strlen(str); - return apr_file_write(thefile, str, &len); + return fspr_file_write(thefile, str, &len); } -APR_DECLARE(apr_status_t) apr_file_gets(char *str, int len, apr_file_t *thefile) +APR_DECLARE(fspr_status_t) fspr_file_gets(char *str, int len, fspr_file_t *thefile) { - apr_size_t readlen; - apr_status_t rv = APR_SUCCESS; + fspr_size_t readlen; + fspr_status_t rv = APR_SUCCESS; int i; for (i = 0; i < len-1; i++) { readlen = 1; - rv = apr_file_read(thefile, str+i, &readlen); + rv = fspr_file_read(thefile, str+i, &readlen); if (rv != APR_SUCCESS && rv != APR_EOF) return rv; @@ -459,13 +459,13 @@ APR_DECLARE(apr_status_t) apr_file_gets(char *str, int len, apr_file_t *thefile) return rv; } -APR_DECLARE(apr_status_t) apr_file_flush(apr_file_t *thefile) +APR_DECLARE(fspr_status_t) fspr_file_flush(fspr_file_t *thefile) { if (thefile->buffered) { DWORD numbytes, written = 0; - apr_status_t rc = 0; + fspr_status_t rc = 0; char *buffer; - apr_size_t bytesleft; + fspr_size_t bytesleft; if (thefile->direction == 1 && thefile->bufpos) { buffer = thefile->buffer; @@ -480,7 +480,7 @@ APR_DECLARE(apr_status_t) apr_file_flush(apr_file_t *thefile) } if (!WriteFile(thefile->filehand, buffer, numbytes, &written, NULL)) { - rc = apr_get_os_error(); + rc = fspr_get_os_error(); thefile->filePtr += written; break; } @@ -504,17 +504,17 @@ APR_DECLARE(apr_status_t) apr_file_flush(apr_file_t *thefile) return APR_SUCCESS; } -struct apr_file_printf_data { - apr_vformatter_buff_t vbuff; - apr_file_t *fptr; +struct fspr_file_printf_data { + fspr_vformatter_buff_t vbuff; + fspr_file_t *fptr; char *buf; }; -static int file_printf_flush(apr_vformatter_buff_t *buff) +static int file_printf_flush(fspr_vformatter_buff_t *buff) { - struct apr_file_printf_data *data = (struct apr_file_printf_data *)buff; + struct fspr_file_printf_data *data = (struct fspr_file_printf_data *)buff; - if (apr_file_write_full(data->fptr, data->buf, + if (fspr_file_write_full(data->fptr, data->buf, data->vbuff.curpos - data->buf, NULL)) { return -1; } @@ -523,10 +523,10 @@ static int file_printf_flush(apr_vformatter_buff_t *buff) return 0; } -APR_DECLARE_NONSTD(int) apr_file_printf(apr_file_t *fptr, +APR_DECLARE_NONSTD(int) fspr_file_printf(fspr_file_t *fptr, const char *format, ...) { - struct apr_file_printf_data data; + struct fspr_file_printf_data data; va_list ap; int count; @@ -538,10 +538,10 @@ APR_DECLARE_NONSTD(int) apr_file_printf(apr_file_t *fptr, data.vbuff.endpos = data.buf + HUGE_STRING_LEN; data.fptr = fptr; va_start(ap, format); - count = apr_vformatter(file_printf_flush, - (apr_vformatter_buff_t *)&data, format, ap); - /* apr_vformatter does not call flush for the last bits */ - if (count >= 0) file_printf_flush((apr_vformatter_buff_t *)&data); + count = fspr_vformatter(file_printf_flush, + (fspr_vformatter_buff_t *)&data, format, ap); + /* fspr_vformatter does not call flush for the last bits */ + if (count >= 0) file_printf_flush((fspr_vformatter_buff_t *)&data); va_end(ap); diff --git a/libs/apr/file_io/win32/seek.c b/libs/apr/file_io/win32/seek.c index 2566d061cf..1bd59de25e 100644 --- a/libs/apr/file_io/win32/seek.c +++ b/libs/apr/file_io/win32/seek.c @@ -14,20 +14,20 @@ * limitations under the License. */ -#include "win32/apr_arch_file_io.h" -#include "apr_file_io.h" +#include "win32/fspr_arch_file_io.h" +#include "fspr_file_io.h" #include #include -static apr_status_t setptr(apr_file_t *thefile, apr_off_t pos ) +static fspr_status_t setptr(fspr_file_t *thefile, fspr_off_t pos ) { - apr_size_t newbufpos; - apr_status_t rv; + fspr_size_t newbufpos; + fspr_status_t rv; DWORD rc; if (thefile->direction == 1) { /* XXX: flush here is not mutex protected */ - rv = apr_file_flush(thefile); + rv = fspr_file_flush(thefile); if (rv != APR_SUCCESS) return rv; thefile->bufpos = thefile->dataRead = 0; @@ -37,11 +37,11 @@ static apr_status_t setptr(apr_file_t *thefile, apr_off_t pos ) /* We may be truncating to size here. * XXX: testing an 'unsigned' as >= 0 below indicates a bug */ - newbufpos = (apr_size_t)(pos - (thefile->filePtr + newbufpos = (fspr_size_t)(pos - (thefile->filePtr - thefile->dataRead)); if (newbufpos >= 0 && newbufpos <= thefile->dataRead) { - thefile->bufpos = (apr_size_t)newbufpos; + thefile->bufpos = (fspr_size_t)newbufpos; rv = APR_SUCCESS; } else { DWORD offlo = (DWORD)pos; @@ -54,7 +54,7 @@ static apr_status_t setptr(apr_file_t *thefile, apr_off_t pos ) * to confirm this. INVALID_SET_FILE_POINTER is too recently * added for us to rely on it as a constant. */ - rv = apr_get_os_error(); + rv = fspr_get_os_error(); else rv = APR_SUCCESS; @@ -70,10 +70,10 @@ static apr_status_t setptr(apr_file_t *thefile, apr_off_t pos ) } -APR_DECLARE(apr_status_t) apr_file_seek(apr_file_t *thefile, apr_seek_where_t where, apr_off_t *offset) +APR_DECLARE(fspr_status_t) fspr_file_seek(fspr_file_t *thefile, fspr_seek_where_t where, fspr_off_t *offset) { - apr_finfo_t finfo; - apr_status_t rc = APR_SUCCESS; + fspr_finfo_t finfo; + fspr_status_t rc = APR_SUCCESS; thefile->eof_hit = 0; @@ -89,7 +89,7 @@ APR_DECLARE(apr_status_t) apr_file_seek(apr_file_t *thefile, apr_seek_where_t wh break; case APR_END: - rc = apr_file_info_get(&finfo, APR_FINFO_SIZE, thefile); + rc = fspr_file_info_get(&finfo, APR_FINFO_SIZE, thefile); if (rc == APR_SUCCESS) rc = setptr(thefile, finfo.size + *offset); break; @@ -115,7 +115,7 @@ APR_DECLARE(apr_status_t) apr_file_seek(apr_file_t *thefile, apr_seek_where_t wh break; case APR_END: - rc = apr_file_info_get(&finfo, APR_FINFO_SIZE, thefile); + rc = fspr_file_info_get(&finfo, APR_FINFO_SIZE, thefile); if (rc == APR_SUCCESS && finfo.size + *offset >= 0) thefile->filePtr = finfo.size + *offset; break; @@ -144,31 +144,31 @@ APR_DECLARE(apr_status_t) apr_file_seek(apr_file_t *thefile, apr_seek_where_t wh offlo = SetFilePointer(thefile->filehand, (LONG)offlo, (LONG*)&offhi, howmove); if (offlo == 0xFFFFFFFF) - rc = apr_get_os_error(); + rc = fspr_get_os_error(); else rc = APR_SUCCESS; /* Since we can land at 0xffffffff we will measure our APR_SUCCESS */ if (rc == APR_SUCCESS) - *offset = ((apr_off_t)offhi << 32) | offlo; + *offset = ((fspr_off_t)offhi << 32) | offlo; return rc; } } -APR_DECLARE(apr_status_t) apr_file_trunc(apr_file_t *thefile, apr_off_t offset) +APR_DECLARE(fspr_status_t) fspr_file_trunc(fspr_file_t *thefile, fspr_off_t offset) { - apr_status_t rv; + fspr_status_t rv; DWORD offlo = (DWORD)offset; DWORD offhi = (DWORD)(offset >> 32); DWORD rc; rc = SetFilePointer(thefile->filehand, offlo, &offhi, FILE_BEGIN); if (rc == 0xFFFFFFFF) - if ((rv = apr_get_os_error()) != APR_SUCCESS) + if ((rv = fspr_get_os_error()) != APR_SUCCESS) return rv; if (!SetEndOfFile(thefile->filehand)) - return apr_get_os_error(); + return fspr_get_os_error(); if (thefile->buffered) { return setptr(thefile, offset); diff --git a/libs/apr/helpers/apr_rename.pl b/libs/apr/helpers/apr_rename.pl index 25b9d52d4c..5254978574 100755 --- a/libs/apr/helpers/apr_rename.pl +++ b/libs/apr/helpers/apr_rename.pl @@ -8,7 +8,7 @@ shift if $just_check; my $dir = shift || '.'; my %names; -my $prefix = 'apr_'; +my $prefix = 'fspr_'; while () { chomp; @@ -41,7 +41,7 @@ sub replace { while () { for (m/[^_\"]*$prefix($pattern)\b/og) { $found++; - print " $file:$. apr_$_ -> apr_$names{$_}\n"; + print " $file:$. fspr_$_ -> fspr_$names{$_}\n"; } push @lines, $_ if $replace; } @@ -66,41 +66,41 @@ sub replace { } __DATA__ -apr_time_t: -apr_implode_gmt apr_time_exp_gmt_get +fspr_time_t: +fspr_implode_gmt fspr_time_exp_gmt_get -apr_socket_t: -apr_close_socket apr_socket_close -apr_create_socket apr_socket_create -apr_get_sockaddr apr_socket_addr_get -apr_get_socketdata apr_socket_data_get -apr_set_socketdata apr_socket_data_set -apr_shutdown apr_socket_shutdown -apr_bind apr_socket_bind -apr_listen apr_socket_listen -apr_accept apr_socket_accept -apr_connect apr_socket_connect -apr_send apr_socket_send -apr_sendv apr_socket_sendv -apr_sendto apr_socket_sendto -apr_recvfrom apr_socket_recvfrom -apr_sendfile apr_socket_sendfile -apr_recv apr_socket_recv +fspr_socket_t: +fspr_close_socket fspr_socket_close +fspr_create_socket fspr_socket_create +fspr_get_sockaddr fspr_socket_addr_get +fspr_get_socketdata fspr_socket_data_get +fspr_set_socketdata fspr_socket_data_set +fspr_shutdown fspr_socket_shutdown +fspr_bind fspr_socket_bind +fspr_listen fspr_socket_listen +fspr_accept fspr_socket_accept +fspr_connect fspr_socket_connect +fspr_send fspr_socket_send +fspr_sendv fspr_socket_sendv +fspr_sendto fspr_socket_sendto +fspr_recvfrom fspr_socket_recvfrom +fspr_sendfile fspr_socket_sendfile +fspr_recv fspr_socket_recv -apr_filepath_*: -apr_filename_of_pathname apr_filepath_name_get +fspr_filepath_*: +fspr_filename_of_pathname fspr_filepath_name_get -apr_gid_t: -apr_get_groupid apr_gid_get -apr_get_groupname apr_gid_name_get -apr_group_name_get apr_gid_name_get -apr_compare_groups apr_gid_compare +fspr_gid_t: +fspr_get_groupid fspr_gid_get +fspr_get_groupname fspr_gid_name_get +fspr_group_name_get fspr_gid_name_get +fspr_compare_groups fspr_gid_compare -apr_uid_t: -apr_get_home_directory apr_uid_homepath_get -apr_get_userid apr_uid_get -apr_current_userid apr_uid_current -apr_compare_users apr_uid_compare -apr_get_username apr_uid_name_get -apr_compare_users apr_uid_compare +fspr_uid_t: +fspr_get_home_directory fspr_uid_homepath_get +fspr_get_userid fspr_uid_get +fspr_current_userid fspr_uid_current +fspr_compare_users fspr_uid_compare +fspr_get_username fspr_uid_name_get +fspr_compare_users fspr_uid_compare diff --git a/libs/apr/include/apr_random.h b/libs/apr/include/apr_random.h deleted file mode 100644 index 9c0eac23ad..0000000000 --- a/libs/apr/include/apr_random.h +++ /dev/null @@ -1,74 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef APR_RANDOM_H -#define APR_RANDOM_H - -#include - -typedef struct apr_crypto_hash_t apr_crypto_hash_t; - -typedef void apr_crypto_hash_init_t(apr_crypto_hash_t *hash); -typedef void apr_crypto_hash_add_t(apr_crypto_hash_t *hash,const void *data, - apr_size_t bytes); -typedef void apr_crypto_hash_finish_t(apr_crypto_hash_t *hash, - unsigned char *result); - -/* FIXME: make this opaque */ -struct apr_crypto_hash_t { - apr_crypto_hash_init_t *init; - apr_crypto_hash_add_t *add; - apr_crypto_hash_finish_t *finish; - apr_size_t size; - void *data; -}; - -APR_DECLARE(apr_crypto_hash_t *) apr_crypto_sha256_new(apr_pool_t *p); - -typedef struct apr_random_t apr_random_t; - -APR_DECLARE(void) apr_random_init(apr_random_t *g,apr_pool_t *p, - apr_crypto_hash_t *pool_hash, - apr_crypto_hash_t *key_hash, - apr_crypto_hash_t *prng_hash); -APR_DECLARE(apr_random_t *) apr_random_standard_new(apr_pool_t *p); -APR_DECLARE(void) apr_random_add_entropy(apr_random_t *g, - const void *entropy_, - apr_size_t bytes); -APR_DECLARE(apr_status_t) apr_random_insecure_bytes(apr_random_t *g, - void *random, - apr_size_t bytes); -APR_DECLARE(apr_status_t) apr_random_secure_bytes(apr_random_t *g, - void *random, - apr_size_t bytes); -APR_DECLARE(void) apr_random_barrier(apr_random_t *g); -APR_DECLARE(apr_status_t) apr_random_secure_ready(apr_random_t *r); -APR_DECLARE(apr_status_t) apr_random_insecure_ready(apr_random_t *r); - -/* Call this in the child after forking to mix the randomness - pools. Note that its generally a bad idea to fork a process with a - real PRNG in it - better to have the PRNG externally and get the - randomness from there. However, if you really must do it, then you - should supply all your entropy to all the PRNGs - don't worry, they - won't produce the same output. - - Note that apr_proc_fork() calls this for you, so only weird - applications need ever call it themselves. -*/ -struct apr_proc_t; -APR_DECLARE(void) apr_random_after_fork(struct apr_proc_t *proc); - -#endif /* ndef APR_RANDOM_H */ diff --git a/libs/apr/include/arch/aix/apr_arch_dso.h b/libs/apr/include/arch/aix/fspr_arch_dso.h similarity index 86% rename from libs/apr/include/arch/aix/apr_arch_dso.h rename to libs/apr/include/arch/aix/fspr_arch_dso.h index d1cac684f6..04a2700285 100644 --- a/libs/apr/include/arch/aix/apr_arch_dso.h +++ b/libs/apr/include/arch/aix/fspr_arch_dso.h @@ -17,11 +17,11 @@ #ifndef DSO_H #define DSO_H -#include "apr_private.h" -#include "apr_general.h" -#include "apr_pools.h" -#include "apr_dso.h" -#include "apr.h" +#include "fspr_private.h" +#include "fspr_general.h" +#include "fspr_pools.h" +#include "fspr_dso.h" +#include "fspr.h" #if APR_HAS_DSO @@ -30,8 +30,8 @@ void *dlsym(void *handle, const char *symbol); const char *dlerror(void); int dlclose(void *handle); -struct apr_dso_handle_t { - apr_pool_t *pool; +struct fspr_dso_handle_t { + fspr_pool_t *pool; void *handle; const char *errormsg; }; diff --git a/libs/apr/include/arch/beos/apr_arch_dso.h b/libs/apr/include/arch/beos/fspr_arch_dso.h similarity index 85% rename from libs/apr/include/arch/beos/apr_arch_dso.h rename to libs/apr/include/arch/beos/fspr_arch_dso.h index fbc5c2ff01..0be76ade03 100644 --- a/libs/apr/include/arch/beos/apr_arch_dso.h +++ b/libs/apr/include/arch/beos/fspr_arch_dso.h @@ -17,20 +17,20 @@ #ifndef DSO_H #define DSO_H -#include "apr_private.h" -#include "apr_general.h" -#include "apr_pools.h" -#include "apr_errno.h" -#include "apr_dso.h" -#include "apr.h" +#include "fspr_private.h" +#include "fspr_general.h" +#include "fspr_pools.h" +#include "fspr_errno.h" +#include "fspr_dso.h" +#include "fspr.h" #include #include #if APR_HAS_DSO -struct apr_dso_handle_t { +struct fspr_dso_handle_t { image_id handle; /* Handle to the DSO loaded */ - apr_pool_t *pool; + fspr_pool_t *pool; const char *errormsg; /* if the load fails, we have an error * message here :) */ diff --git a/libs/apr/include/arch/beos/apr_arch_proc_mutex.h b/libs/apr/include/arch/beos/fspr_arch_proc_mutex.h similarity index 82% rename from libs/apr/include/arch/beos/apr_arch_proc_mutex.h rename to libs/apr/include/arch/beos/fspr_arch_proc_mutex.h index c60d8c6228..c0a08b465a 100644 --- a/libs/apr/include/arch/beos/apr_arch_proc_mutex.h +++ b/libs/apr/include/arch/beos/fspr_arch_proc_mutex.h @@ -17,15 +17,15 @@ #ifndef PROC_MUTEX_H #define PROC_MUTEX_H -#include "apr_pools.h" -#include "apr_proc_mutex.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_portable.h" +#include "fspr_pools.h" +#include "fspr_proc_mutex.h" +#include "fspr_file_io.h" +#include "fspr_general.h" +#include "fspr_lib.h" +#include "fspr_portable.h" -struct apr_proc_mutex_t { - apr_pool_t *pool; +struct fspr_proc_mutex_t { + fspr_pool_t *pool; /* Our lock :) */ sem_id Lock; diff --git a/libs/apr/include/arch/beos/apr_arch_thread_cond.h b/libs/apr/include/arch/beos/fspr_arch_thread_cond.h similarity index 81% rename from libs/apr/include/arch/beos/apr_arch_thread_cond.h rename to libs/apr/include/arch/beos/fspr_arch_thread_cond.h index c9420b53cb..f18aba7d6c 100644 --- a/libs/apr/include/arch/beos/apr_arch_thread_cond.h +++ b/libs/apr/include/arch/beos/fspr_arch_thread_cond.h @@ -18,23 +18,23 @@ #define THREAD_COND_H #include -#include "apr_pools.h" -#include "apr_thread_cond.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_portable.h" -#include "apr_ring.h" +#include "fspr_pools.h" +#include "fspr_thread_cond.h" +#include "fspr_file_io.h" +#include "fspr_general.h" +#include "fspr_lib.h" +#include "fspr_portable.h" +#include "fspr_ring.h" struct waiter_t { APR_RING_ENTRY(waiter_t) link; sem_id sem; }; -struct apr_thread_cond_t { - apr_pool_t *pool; +struct fspr_thread_cond_t { + fspr_pool_t *pool; sem_id lock; - apr_thread_mutex_t *condlock; + fspr_thread_mutex_t *condlock; thread_id owner; /* active list */ APR_RING_HEAD(active_list, waiter_t) alist; diff --git a/libs/apr/include/arch/beos/apr_arch_thread_mutex.h b/libs/apr/include/arch/beos/fspr_arch_thread_mutex.h similarity index 81% rename from libs/apr/include/arch/beos/apr_arch_thread_mutex.h rename to libs/apr/include/arch/beos/fspr_arch_thread_mutex.h index bb7d4ae80b..f2fbb22388 100644 --- a/libs/apr/include/arch/beos/apr_arch_thread_mutex.h +++ b/libs/apr/include/arch/beos/fspr_arch_thread_mutex.h @@ -18,15 +18,15 @@ #define THREAD_MUTEX_H #include -#include "apr_pools.h" -#include "apr_thread_mutex.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_portable.h" +#include "fspr_pools.h" +#include "fspr_thread_mutex.h" +#include "fspr_file_io.h" +#include "fspr_general.h" +#include "fspr_lib.h" +#include "fspr_portable.h" -struct apr_thread_mutex_t { - apr_pool_t *pool; +struct fspr_thread_mutex_t { + fspr_pool_t *pool; /* Our lock :) */ sem_id Lock; @@ -34,7 +34,7 @@ struct apr_thread_mutex_t { /* If we nest locks we need these... */ int nested; - apr_os_thread_t owner; + fspr_os_thread_t owner; int owner_ref; }; diff --git a/libs/apr/include/arch/beos/apr_arch_thread_rwlock.h b/libs/apr/include/arch/beos/fspr_arch_thread_rwlock.h similarity index 84% rename from libs/apr/include/arch/beos/apr_arch_thread_rwlock.h rename to libs/apr/include/arch/beos/fspr_arch_thread_rwlock.h index 694b0d5046..9a7849fbd5 100644 --- a/libs/apr/include/arch/beos/apr_arch_thread_rwlock.h +++ b/libs/apr/include/arch/beos/fspr_arch_thread_rwlock.h @@ -18,15 +18,15 @@ #define THREAD_RWLOCK_H #include -#include "apr_pools.h" -#include "apr_thread_rwlock.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_portable.h" +#include "fspr_pools.h" +#include "fspr_thread_rwlock.h" +#include "fspr_file_io.h" +#include "fspr_general.h" +#include "fspr_lib.h" +#include "fspr_portable.h" -struct apr_thread_rwlock_t { - apr_pool_t *pool; +struct fspr_thread_rwlock_t { + fspr_pool_t *pool; /* Our lock :) */ sem_id Lock; diff --git a/libs/apr/include/arch/beos/apr_arch_threadproc.h b/libs/apr/include/arch/beos/fspr_arch_threadproc.h similarity index 71% rename from libs/apr/include/arch/beos/apr_arch_threadproc.h rename to libs/apr/include/arch/beos/fspr_arch_threadproc.h index 13de053634..aa55461a4a 100644 --- a/libs/apr/include/arch/beos/apr_arch_threadproc.h +++ b/libs/apr/include/arch/beos/fspr_arch_threadproc.h @@ -14,12 +14,12 @@ * limitations under the License. */ -#include "apr_thread_proc.h" -#include "apr_arch_file_io.h" -#include "apr_file_io.h" -#include "apr_thread_proc.h" -#include "apr_general.h" -#include "apr_portable.h" +#include "fspr_thread_proc.h" +#include "fspr_arch_file_io.h" +#include "fspr_file_io.h" +#include "fspr_thread_proc.h" +#include "fspr_general.h" +#include "fspr_portable.h" #include #include #include @@ -39,23 +39,23 @@ #define BEOS_MAX_DATAKEYS 128 -struct apr_thread_t { - apr_pool_t *pool; +struct fspr_thread_t { + fspr_pool_t *pool; thread_id td; void *data; - apr_thread_start_t func; - apr_status_t exitval; + fspr_thread_start_t func; + fspr_status_t exitval; }; -struct apr_threadattr_t { - apr_pool_t *pool; +struct fspr_threadattr_t { + fspr_pool_t *pool; int32 attr; int detached; int joinable; }; -struct apr_threadkey_t { - apr_pool_t *pool; +struct fspr_threadkey_t { + fspr_pool_t *pool; int32 key; }; @@ -73,20 +73,20 @@ struct beos_key { void (* destructor) (void *); }; -struct apr_procattr_t { - apr_pool_t *pool; - apr_file_t *parent_in; - apr_file_t *child_in; - apr_file_t *parent_out; - apr_file_t *child_out; - apr_file_t *parent_err; - apr_file_t *child_err; +struct fspr_procattr_t { + fspr_pool_t *pool; + fspr_file_t *parent_in; + fspr_file_t *child_in; + fspr_file_t *parent_out; + fspr_file_t *child_out; + fspr_file_t *parent_err; + fspr_file_t *child_err; char *currdir; - apr_int32_t cmdtype; - apr_int32_t detached; + fspr_int32_t cmdtype; + fspr_int32_t detached; }; -struct apr_thread_once_t { +struct fspr_thread_once_t { sem_id sem; int hit; }; diff --git a/libs/apr/include/arch/apr_private_common.h b/libs/apr/include/arch/fspr_private_common.h similarity index 75% rename from libs/apr/include/arch/apr_private_common.h rename to libs/apr/include/arch/fspr_private_common.h index 9cd52ecf22..2213744b1c 100644 --- a/libs/apr/include/arch/apr_private_common.h +++ b/libs/apr/include/arch/fspr_private_common.h @@ -21,22 +21,22 @@ #ifndef APR_PRIVATE_COMMON_H #define APR_PRIVATE_COMMON_H -#include "apr_pools.h" -#include "apr_tables.h" +#include "fspr_pools.h" +#include "fspr_tables.h" -apr_status_t apr_filepath_list_split_impl(apr_array_header_t **pathelts, +fspr_status_t fspr_filepath_list_split_impl(fspr_array_header_t **pathelts, const char *liststr, char separator, - apr_pool_t *p); + fspr_pool_t *p); -apr_status_t apr_filepath_list_merge_impl(char **liststr, - apr_array_header_t *pathelts, +fspr_status_t fspr_filepath_list_merge_impl(char **liststr, + fspr_array_header_t *pathelts, char separator, - apr_pool_t *p); + fspr_pool_t *p); /* temporary defines to handle 64bit compile mismatches */ #define APR_INT_TRUNC_CAST int -#define APR_UINT32_TRUNC_CAST apr_uint32_t +#define APR_UINT32_TRUNC_CAST fspr_uint32_t #define APR_UINT32_MAX 0xFFFFFFFFUL #endif /*APR_PRIVATE_COMMON_H*/ diff --git a/libs/apr/include/arch/netware/apr_arch_dso.h b/libs/apr/include/arch/netware/fspr_arch_dso.h similarity index 86% rename from libs/apr/include/arch/netware/apr_arch_dso.h rename to libs/apr/include/arch/netware/fspr_arch_dso.h index ea0fe8c254..54bf22f72f 100644 --- a/libs/apr/include/arch/netware/apr_arch_dso.h +++ b/libs/apr/include/arch/netware/fspr_arch_dso.h @@ -17,11 +17,11 @@ #ifndef DSO_H #define DSO_H -#include "apr_private.h" -#include "apr_general.h" -#include "apr_pools.h" -#include "apr_dso.h" -#include "apr.h" +#include "fspr_private.h" +#include "fspr_general.h" +#include "fspr_pools.h" +#include "fspr_dso.h" +#include "fspr.h" #include @@ -32,8 +32,8 @@ struct sym_list { char *symbol; }; -struct apr_dso_handle_t { - apr_pool_t *pool; +struct fspr_dso_handle_t { + fspr_pool_t *pool; void *handle; const char *errormsg; sym_list *symbols; diff --git a/libs/apr/include/arch/netware/apr_arch_file_io.h b/libs/apr/include/arch/netware/fspr_arch_file_io.h similarity index 76% rename from libs/apr/include/arch/netware/apr_arch_file_io.h rename to libs/apr/include/arch/netware/fspr_arch_file_io.h index 6b2bfeca44..d1172e2153 100644 --- a/libs/apr/include/arch/netware/apr_arch_file_io.h +++ b/libs/apr/include/arch/netware/fspr_arch_file_io.h @@ -17,15 +17,15 @@ #ifndef FILE_IO_H #define FILE_IO_H -#include "apr.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_tables.h" -#include "apr_file_io.h" -#include "apr_file_info.h" -#include "apr_errno.h" -#include "apr_lib.h" -#include "apr_poll.h" +#include "fspr.h" +#include "fspr_private.h" +#include "fspr_general.h" +#include "fspr_tables.h" +#include "fspr_file_io.h" +#include "fspr_file_info.h" +#include "fspr_errno.h" +#include "fspr_lib.h" +#include "fspr_poll.h" /* System headers the file I/O library needs */ #if APR_HAVE_FCNTL_H @@ -78,45 +78,45 @@ typedef struct stat struct_stat; -struct apr_file_t { - apr_pool_t *pool; +struct fspr_file_t { + fspr_pool_t *pool; int filedes; char *fname; - apr_int32_t flags; + fspr_int32_t flags; int eof_hit; int is_pipe; - apr_interval_time_t timeout; + fspr_interval_time_t timeout; int buffered; enum {BLK_UNKNOWN, BLK_OFF, BLK_ON } blocking; int ungetchar; /* Last char provided by an unget op. (-1 = no char)*/ /* if there is a timeout set, then this pollset is used */ - apr_pollset_t *pollset; + fspr_pollset_t *pollset; /* Stuff for buffered mode */ char *buffer; int bufpos; /* Read/Write position in buffer */ - apr_off_t dataRead; /* amount of valid data read into buffer */ + fspr_off_t dataRead; /* amount of valid data read into buffer */ int direction; /* buffer being used for 0 = read, 1 = write */ - apr_off_t filePtr; /* position in file of handle */ + fspr_off_t filePtr; /* position in file of handle */ #if APR_HAS_THREADS - struct apr_thread_mutex_t *thlock; + struct fspr_thread_mutex_t *thlock; #endif }; -struct apr_dir_t { - apr_pool_t *pool; +struct fspr_dir_t { + fspr_pool_t *pool; char *dirname; DIR *dirstruct; struct dirent *entry; }; -typedef struct apr_stat_entry_t apr_stat_entry_t; +typedef struct fspr_stat_entry_t fspr_stat_entry_t; -struct apr_stat_entry_t { +struct fspr_stat_entry_t { struct stat info; char *casedName; - apr_time_t expire; + fspr_time_t expire; NXPathCtx_t pathCtx; }; @@ -131,21 +131,21 @@ struct apr_stat_entry_t { * we need to fold the case to canonical form. This function is * supposed to do so. */ -apr_status_t filepath_root_case(char **rootpath, char *root, apr_pool_t *p); +fspr_status_t filepath_root_case(char **rootpath, char *root, fspr_pool_t *p); /* This function check to see of the given path includes a drive/volume * specifier. If the _only_ parameter is set to DRIVE_ONLY then it * check to see of the path only contains a drive/volume specifier and * nothing else. */ -apr_status_t filepath_has_drive(const char *rootpath, int only, apr_pool_t *p); +fspr_status_t filepath_has_drive(const char *rootpath, int only, fspr_pool_t *p); /* This function compares the drive/volume specifiers for each given path. * It returns zero if they match or non-zero if not. */ -apr_status_t filepath_compare_drive(const char *path1, const char *path2, apr_pool_t *p); +fspr_status_t filepath_compare_drive(const char *path1, const char *path2, fspr_pool_t *p); -apr_status_t apr_unix_file_cleanup(void *); +fspr_status_t fspr_unix_file_cleanup(void *); #endif /* ! FILE_IO_H */ diff --git a/libs/apr/include/arch/netware/apr_arch_global_mutex.h b/libs/apr/include/arch/netware/fspr_arch_global_mutex.h similarity index 85% rename from libs/apr/include/arch/netware/apr_arch_global_mutex.h rename to libs/apr/include/arch/netware/fspr_arch_global_mutex.h index 4167d37821..bceaddb5b6 100644 --- a/libs/apr/include/arch/netware/apr_arch_global_mutex.h +++ b/libs/apr/include/arch/netware/fspr_arch_global_mutex.h @@ -17,12 +17,12 @@ #ifndef GLOBAL_MUTEX_H #define GLOBAL_MUTEX_H -#include "apr_global_mutex.h" -#include "apr_thread_mutex.h" +#include "fspr_global_mutex.h" +#include "fspr_thread_mutex.h" -struct apr_global_mutex_t { - apr_pool_t *pool; - apr_thread_mutex_t *mutex; +struct fspr_global_mutex_t { + fspr_pool_t *pool; + fspr_thread_mutex_t *mutex; }; #endif /* GLOBAL_MUTEX_H */ diff --git a/libs/apr/include/arch/netware/apr_arch_internal_time.h b/libs/apr/include/arch/netware/fspr_arch_internal_time.h similarity index 94% rename from libs/apr/include/arch/netware/apr_arch_internal_time.h rename to libs/apr/include/arch/netware/fspr_arch_internal_time.h index 59f1067208..8f43fb1cce 100644 --- a/libs/apr/include/arch/netware/apr_arch_internal_time.h +++ b/libs/apr/include/arch/netware/fspr_arch_internal_time.h @@ -17,10 +17,10 @@ #ifndef TIME_INTERNAL_H #define TIME_INTERNAL_H -#include "apr.h" +#include "fspr.h" #define TZONE (*___timezone()) -void apr_netware_setup_time(void); +void fspr_netware_setup_time(void); #endif /* TIME_INTERNAL_H */ diff --git a/libs/apr/include/arch/netware/apr_arch_networkio.h b/libs/apr/include/arch/netware/fspr_arch_networkio.h similarity index 93% rename from libs/apr/include/arch/netware/apr_arch_networkio.h rename to libs/apr/include/arch/netware/fspr_arch_networkio.h index 63f17abe59..0779530996 100644 --- a/libs/apr/include/arch/netware/apr_arch_networkio.h +++ b/libs/apr/include/arch/netware/fspr_arch_networkio.h @@ -22,9 +22,9 @@ arch/netware and then arch/unix. But in this specific case we want arch/win32. */ -#include <../win32/apr_arch_networkio.h> +#include <../win32/fspr_arch_networkio.h> #else -#include <../unix/apr_arch_networkio.h> +#include <../unix/fspr_arch_networkio.h> #endif #endif /* ! NETWORK_IO_H */ diff --git a/libs/apr/include/arch/netware/apr_arch_pre_nw.h b/libs/apr/include/arch/netware/fspr_arch_pre_nw.h similarity index 100% rename from libs/apr/include/arch/netware/apr_arch_pre_nw.h rename to libs/apr/include/arch/netware/fspr_arch_pre_nw.h diff --git a/libs/apr/include/arch/netware/apr_arch_proc_mutex.h b/libs/apr/include/arch/netware/fspr_arch_proc_mutex.h similarity index 86% rename from libs/apr/include/arch/netware/apr_arch_proc_mutex.h rename to libs/apr/include/arch/netware/fspr_arch_proc_mutex.h index 7a634c2e50..169a6c292e 100644 --- a/libs/apr/include/arch/netware/apr_arch_proc_mutex.h +++ b/libs/apr/include/arch/netware/fspr_arch_proc_mutex.h @@ -17,12 +17,12 @@ #ifndef PROC_MUTEX_H #define PROC_MUTEX_H -#include "apr_proc_mutex.h" -#include "apr_thread_mutex.h" +#include "fspr_proc_mutex.h" +#include "fspr_thread_mutex.h" -struct apr_proc_mutex_t { - apr_pool_t *pool; - apr_thread_mutex_t *mutex; +struct fspr_proc_mutex_t { + fspr_pool_t *pool; + fspr_thread_mutex_t *mutex; }; #endif /* PROC_MUTEX_H */ diff --git a/libs/apr/include/arch/netware/apr_arch_thread_cond.h b/libs/apr/include/arch/netware/fspr_arch_thread_cond.h similarity index 91% rename from libs/apr/include/arch/netware/apr_arch_thread_cond.h rename to libs/apr/include/arch/netware/fspr_arch_thread_cond.h index b11a5f86a7..ec0e69018f 100644 --- a/libs/apr/include/arch/netware/apr_arch_thread_cond.h +++ b/libs/apr/include/arch/netware/fspr_arch_thread_cond.h @@ -17,11 +17,11 @@ #ifndef THREAD_COND_H #define THREAD_COND_H -#include "apr_thread_cond.h" +#include "fspr_thread_cond.h" #include -struct apr_thread_cond_t { - apr_pool_t *pool; +struct fspr_thread_cond_t { + fspr_pool_t *pool; NXCond_t *cond; }; diff --git a/libs/apr/include/arch/netware/apr_arch_thread_mutex.h b/libs/apr/include/arch/netware/fspr_arch_thread_mutex.h similarity index 91% rename from libs/apr/include/arch/netware/apr_arch_thread_mutex.h rename to libs/apr/include/arch/netware/fspr_arch_thread_mutex.h index 0453799c2d..7691795a3d 100644 --- a/libs/apr/include/arch/netware/apr_arch_thread_mutex.h +++ b/libs/apr/include/arch/netware/fspr_arch_thread_mutex.h @@ -17,11 +17,11 @@ #ifndef THREAD_MUTEX_H #define THREAD_MUTEX_H -#include "apr_thread_mutex.h" +#include "fspr_thread_mutex.h" #include -struct apr_thread_mutex_t { - apr_pool_t *pool; +struct fspr_thread_mutex_t { + fspr_pool_t *pool; NXMutex_t *mutex; }; diff --git a/libs/apr/include/arch/netware/apr_arch_thread_rwlock.h b/libs/apr/include/arch/netware/fspr_arch_thread_rwlock.h similarity index 91% rename from libs/apr/include/arch/netware/apr_arch_thread_rwlock.h rename to libs/apr/include/arch/netware/fspr_arch_thread_rwlock.h index d2dbd42f79..56df129656 100644 --- a/libs/apr/include/arch/netware/apr_arch_thread_rwlock.h +++ b/libs/apr/include/arch/netware/fspr_arch_thread_rwlock.h @@ -17,11 +17,11 @@ #ifndef THREAD_RWLOCK_H #define THREAD_RWLOCK_H -#include "apr_thread_rwlock.h" +#include "fspr_thread_rwlock.h" #include -struct apr_thread_rwlock_t { - apr_pool_t *pool; +struct fspr_thread_rwlock_t { + fspr_pool_t *pool; NXRwLock_t *rwlock; }; diff --git a/libs/apr/include/arch/netware/apr_arch_threadproc.h b/libs/apr/include/arch/netware/fspr_arch_threadproc.h similarity index 59% rename from libs/apr/include/arch/netware/apr_arch_threadproc.h rename to libs/apr/include/arch/netware/fspr_arch_threadproc.h index 713ed295af..5dd85058f7 100644 --- a/libs/apr/include/arch/netware/apr_arch_threadproc.h +++ b/libs/apr/include/arch/netware/fspr_arch_threadproc.h @@ -14,9 +14,9 @@ * limitations under the License. */ -#include "apr.h" -#include "apr_thread_proc.h" -#include "apr_file_io.h" +#include "fspr.h" +#include "fspr_thread_proc.h" +#include "fspr_file_io.h" #include @@ -26,52 +26,52 @@ #define SHELL_PATH "" #define APR_DEFAULT_STACK_SIZE 65536 -struct apr_thread_t { - apr_pool_t *pool; +struct fspr_thread_t { + fspr_pool_t *pool; NXContext_t ctx; NXThreadId_t td; char *thread_name; - apr_int32_t cancel; - apr_int32_t cancel_how; + fspr_int32_t cancel; + fspr_int32_t cancel_how; void *data; - apr_thread_start_t func; - apr_status_t exitval; + fspr_thread_start_t func; + fspr_status_t exitval; }; -struct apr_threadattr_t { - apr_pool_t *pool; - apr_size_t stack_size; - apr_int32_t detach; +struct fspr_threadattr_t { + fspr_pool_t *pool; + fspr_size_t stack_size; + fspr_int32_t detach; char *thread_name; }; -struct apr_threadkey_t { - apr_pool_t *pool; +struct fspr_threadkey_t { + fspr_pool_t *pool; NXKey_t key; }; -struct apr_procattr_t { - apr_pool_t *pool; - apr_file_t *parent_in; - apr_file_t *child_in; - apr_file_t *parent_out; - apr_file_t *child_out; - apr_file_t *parent_err; - apr_file_t *child_err; +struct fspr_procattr_t { + fspr_pool_t *pool; + fspr_file_t *parent_in; + fspr_file_t *child_in; + fspr_file_t *parent_out; + fspr_file_t *child_out; + fspr_file_t *parent_err; + fspr_file_t *child_err; char *currdir; - apr_int32_t cmdtype; - apr_int32_t detached; - apr_int32_t addrspace; + fspr_int32_t cmdtype; + fspr_int32_t detached; + fspr_int32_t addrspace; }; -struct apr_thread_once_t { +struct fspr_thread_once_t { unsigned long value; }; -//struct apr_proc_t { -// apr_pool_t *pool; +//struct fspr_proc_t { +// fspr_pool_t *pool; // pid_t pid; -// apr_procattr_t *attr; +// fspr_procattr_t *attr; //}; #endif /* ! THREAD_PROC_H */ diff --git a/libs/apr/include/arch/netware/apr_private.h b/libs/apr/include/arch/netware/fspr_private.h similarity index 98% rename from libs/apr/include/arch/netware/apr_private.h rename to libs/apr/include/arch/netware/fspr_private.h index ad659b5988..a200fcc6a1 100644 --- a/libs/apr/include/arch/netware/apr_private.h +++ b/libs/apr/include/arch/netware/fspr_private.h @@ -28,7 +28,7 @@ /* Include the public APR symbols, include our idea of the 'right' * subset of the Windows.h header. This saves us repetition. */ -#include "apr.h" +#include "fspr.h" #include #include @@ -185,7 +185,7 @@ void* getStatCache(); /* * Include common private declarations. */ -#include "../apr_private_common.h" +#include "../fspr_private_common.h" #endif /*APR_PRIVATE_H*/ #endif /*NETWARE*/ diff --git a/libs/apr/include/arch/os2/apr_arch_os2calls.h b/libs/apr/include/arch/os2/apr_arch_os2calls.h deleted file mode 100644 index 3c739bfd19..0000000000 --- a/libs/apr/include/arch/os2/apr_arch_os2calls.h +++ /dev/null @@ -1,59 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "apr_errno.h" -#include -#include - -extern int (*apr_os2_socket)(int, int, int); -extern int (*apr_os2_select)(int *, int, int, int, long); -extern int (*apr_os2_sock_errno)(); -extern int (*apr_os2_accept)(int, struct sockaddr *, int *); -extern int (*apr_os2_bind)(int, struct sockaddr *, int); -extern int (*apr_os2_connect)(int, struct sockaddr *, int); -extern int (*apr_os2_getpeername)(int, struct sockaddr *, int *); -extern int (*apr_os2_getsockname)(int, struct sockaddr *, int *); -extern int (*apr_os2_getsockopt)(int, int, int, char *, int *); -extern int (*apr_os2_ioctl)(int, int, caddr_t, int); -extern int (*apr_os2_listen)(int, int); -extern int (*apr_os2_recv)(int, char *, int, int); -extern int (*apr_os2_send)(int, const char *, int, int); -extern int (*apr_os2_setsockopt)(int, int, int, char *, int); -extern int (*apr_os2_shutdown)(int, int); -extern int (*apr_os2_soclose)(int); -extern int (*apr_os2_writev)(int, struct iovec *, int); -extern int (*apr_os2_sendto)(int, const char *, int, int, const struct sockaddr *, int); -extern int (*apr_os2_recvfrom)(int, char *, int, int, struct sockaddr *, int *); - -#define socket apr_os2_socket -#define select apr_os2_select -#define sock_errno apr_os2_sock_errno -#define accept apr_os2_accept -#define bind apr_os2_bind -#define connect apr_os2_connect -#define getpeername apr_os2_getpeername -#define getsockname apr_os2_getsockname -#define getsockopt apr_os2_getsockopt -#define ioctl apr_os2_ioctl -#define listen apr_os2_listen -#define recv apr_os2_recv -#define send apr_os2_send -#define setsockopt apr_os2_setsockopt -#define shutdown apr_os2_shutdown -#define soclose apr_os2_soclose -#define writev apr_os2_writev -#define sendto apr_os2_sendto -#define recvfrom apr_os2_recvfrom diff --git a/libs/apr/include/arch/os2/apr_arch_dso.h b/libs/apr/include/arch/os2/fspr_arch_dso.h similarity index 79% rename from libs/apr/include/arch/os2/apr_arch_dso.h rename to libs/apr/include/arch/os2/fspr_arch_dso.h index 2bda6b7c66..ee6eb45ae7 100644 --- a/libs/apr/include/arch/os2/apr_arch_dso.h +++ b/libs/apr/include/arch/os2/fspr_arch_dso.h @@ -17,18 +17,18 @@ #ifndef DSO_H #define DSO_H -#include "apr_private.h" -#include "apr_general.h" -#include "apr_pools.h" -#include "apr_dso.h" -#include "apr.h" +#include "fspr_private.h" +#include "fspr_general.h" +#include "fspr_pools.h" +#include "fspr_dso.h" +#include "fspr.h" #if APR_HAS_DSO -struct apr_dso_handle_t { - apr_pool_t *cont; /* Context for returning error strings */ +struct fspr_dso_handle_t { + fspr_pool_t *cont; /* Context for returning error strings */ HMODULE handle; /* Handle to the DSO loaded */ - apr_status_t load_error; + fspr_status_t load_error; char *failed_module; }; diff --git a/libs/apr/include/arch/os2/apr_arch_file_io.h b/libs/apr/include/arch/os2/fspr_arch_file_io.h similarity index 67% rename from libs/apr/include/arch/os2/apr_arch_file_io.h rename to libs/apr/include/arch/os2/fspr_arch_file_io.h index a8884c34dc..8f2c2da0f6 100644 --- a/libs/apr/include/arch/os2/apr_arch_file_io.h +++ b/libs/apr/include/arch/os2/fspr_arch_file_io.h @@ -17,13 +17,13 @@ #ifndef FILE_IO_H #define FILE_IO_H -#include "apr_private.h" -#include "apr_general.h" -#include "apr_thread_mutex.h" -#include "apr_file_io.h" -#include "apr_file_info.h" -#include "apr_errno.h" -#include "apr_poll.h" +#include "fspr_private.h" +#include "fspr_general.h" +#include "fspr_thread_mutex.h" +#include "fspr_file_io.h" +#include "fspr_file_info.h" +#include "fspr_errno.h" +#include "fspr_poll.h" /* We have an implementation of mkstemp but it's not very multi-threading * friendly & is part of the POSIX emulation rather than native so don't @@ -33,14 +33,14 @@ #define APR_FILE_BUFSIZE 4096 -struct apr_file_t { - apr_pool_t *pool; +struct fspr_file_t { + fspr_pool_t *pool; HFILE filedes; char * fname; int isopen; int buffered; int eof_hit; - apr_int32_t flags; + fspr_int32_t flags; int timeout; int pipe; HEV pipeSem; @@ -52,32 +52,32 @@ struct apr_file_t { unsigned long dataRead; // amount of valid data read into buffer int direction; // buffer being used for 0 = read, 1 = write unsigned long filePtr; // position in file of handle - apr_thread_mutex_t *mutex;// mutex semaphore, must be owned to access the above fields + fspr_thread_mutex_t *mutex;// mutex semaphore, must be owned to access the above fields }; -struct apr_dir_t { - apr_pool_t *pool; +struct fspr_dir_t { + fspr_pool_t *pool; char *dirname; ULONG handle; FILEFINDBUF3 entry; int validentry; }; -apr_status_t apr_file_cleanup(void *); -apr_status_t apr_os2_time_to_apr_time(apr_time_t *result, FDATE os2date, +fspr_status_t fspr_file_cleanup(void *); +fspr_status_t fspr_os2_time_to_fspr_time(fspr_time_t *result, FDATE os2date, FTIME os2time); -apr_status_t apr_apr_time_to_os2_time(FDATE *os2date, FTIME *os2time, - apr_time_t aprtime); +fspr_status_t fspr_fspr_time_to_os2_time(FDATE *os2date, FTIME *os2time, + fspr_time_t aprtime); /* see win32/fileio.h for description of these */ extern const char c_is_fnchar[256]; #define IS_FNCHAR(c) c_is_fnchar[(unsigned char)c] -apr_status_t filepath_root_test(char *path, apr_pool_t *p); -apr_status_t filepath_drive_get(char **rootpath, char drive, - apr_int32_t flags, apr_pool_t *p); -apr_status_t filepath_root_case(char **rootpath, char *root, apr_pool_t *p); +fspr_status_t filepath_root_test(char *path, fspr_pool_t *p); +fspr_status_t filepath_drive_get(char **rootpath, char drive, + fspr_int32_t flags, fspr_pool_t *p); +fspr_status_t filepath_root_case(char **rootpath, char *root, fspr_pool_t *p); #endif /* ! FILE_IO_H */ diff --git a/libs/apr/include/arch/os2/apr_arch_networkio.h b/libs/apr/include/arch/os2/fspr_arch_networkio.h similarity index 80% rename from libs/apr/include/arch/os2/apr_arch_networkio.h rename to libs/apr/include/arch/os2/fspr_arch_networkio.h index 10c6de81fb..9fd277ab8d 100644 --- a/libs/apr/include/arch/os2/apr_arch_networkio.h +++ b/libs/apr/include/arch/os2/fspr_arch_networkio.h @@ -17,11 +17,11 @@ #ifndef NETWORK_IO_H #define NETWORK_IO_H -#include "apr_private.h" -#include "apr_network_io.h" -#include "apr_general.h" -#include "apr_arch_os2calls.h" -#include "apr_poll.h" +#include "fspr_private.h" +#include "fspr_network_io.h" +#include "fspr_general.h" +#include "fspr_arch_os2calls.h" +#include "fspr_poll.h" #if APR_HAVE_NETDB_H #include @@ -34,24 +34,24 @@ struct sock_userdata_t { void *data; }; -struct apr_socket_t { - apr_pool_t *pool; +struct fspr_socket_t { + fspr_pool_t *pool; int socketdes; int type; int protocol; - apr_sockaddr_t *local_addr; - apr_sockaddr_t *remote_addr; - apr_interval_time_t timeout; + fspr_sockaddr_t *local_addr; + fspr_sockaddr_t *remote_addr; + fspr_interval_time_t timeout; int nonblock; int local_port_unknown; int local_interface_unknown; int remote_addr_unknown; - apr_int32_t options; - apr_int32_t inherit; + fspr_int32_t options; + fspr_int32_t inherit; sock_userdata_t *userdata; /* if there is a timeout set, then this pollset is used */ - apr_pollset_t *pollset; + fspr_pollset_t *pollset; }; /* Error codes returned from sock_errno() */ @@ -68,9 +68,9 @@ struct apr_socket_t { #define SOCEPIPE (SOCBASEERR+32) /* Broken pipe */ #define SOCEOS2ERR (SOCBASEERR+100) /* OS/2 Error */ -const char *apr_inet_ntop(int af, const void *src, char *dst, apr_size_t size); -int apr_inet_pton(int af, const char *src, void *dst); -void apr_sockaddr_vars_set(apr_sockaddr_t *, int, apr_port_t); +const char *fspr_inet_ntop(int af, const void *src, char *dst, fspr_size_t size); +int fspr_inet_pton(int af, const char *src, void *dst); +void fspr_sockaddr_vars_set(fspr_sockaddr_t *, int, fspr_port_t); #endif /* ! NETWORK_IO_H */ diff --git a/libs/apr/include/arch/os2/fspr_arch_os2calls.h b/libs/apr/include/arch/os2/fspr_arch_os2calls.h new file mode 100644 index 0000000000..335662ffce --- /dev/null +++ b/libs/apr/include/arch/os2/fspr_arch_os2calls.h @@ -0,0 +1,59 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "fspr_errno.h" +#include +#include + +extern int (*fspr_os2_socket)(int, int, int); +extern int (*fspr_os2_select)(int *, int, int, int, long); +extern int (*fspr_os2_sock_errno)(); +extern int (*fspr_os2_accept)(int, struct sockaddr *, int *); +extern int (*fspr_os2_bind)(int, struct sockaddr *, int); +extern int (*fspr_os2_connect)(int, struct sockaddr *, int); +extern int (*fspr_os2_getpeername)(int, struct sockaddr *, int *); +extern int (*fspr_os2_getsockname)(int, struct sockaddr *, int *); +extern int (*fspr_os2_getsockopt)(int, int, int, char *, int *); +extern int (*fspr_os2_ioctl)(int, int, caddr_t, int); +extern int (*fspr_os2_listen)(int, int); +extern int (*fspr_os2_recv)(int, char *, int, int); +extern int (*fspr_os2_send)(int, const char *, int, int); +extern int (*fspr_os2_setsockopt)(int, int, int, char *, int); +extern int (*fspr_os2_shutdown)(int, int); +extern int (*fspr_os2_soclose)(int); +extern int (*fspr_os2_writev)(int, struct iovec *, int); +extern int (*fspr_os2_sendto)(int, const char *, int, int, const struct sockaddr *, int); +extern int (*fspr_os2_recvfrom)(int, char *, int, int, struct sockaddr *, int *); + +#define socket fspr_os2_socket +#define select fspr_os2_select +#define sock_errno fspr_os2_sock_errno +#define accept fspr_os2_accept +#define bind fspr_os2_bind +#define connect fspr_os2_connect +#define getpeername fspr_os2_getpeername +#define getsockname fspr_os2_getsockname +#define getsockopt fspr_os2_getsockopt +#define ioctl fspr_os2_ioctl +#define listen fspr_os2_listen +#define recv fspr_os2_recv +#define send fspr_os2_send +#define setsockopt fspr_os2_setsockopt +#define shutdown fspr_os2_shutdown +#define soclose fspr_os2_soclose +#define writev fspr_os2_writev +#define sendto fspr_os2_sendto +#define recvfrom fspr_os2_recvfrom diff --git a/libs/apr/include/arch/os2/apr_arch_proc_mutex.h b/libs/apr/include/arch/os2/fspr_arch_proc_mutex.h similarity index 89% rename from libs/apr/include/arch/os2/apr_arch_proc_mutex.h rename to libs/apr/include/arch/os2/fspr_arch_proc_mutex.h index 8caf3369dc..5270fbf277 100644 --- a/libs/apr/include/arch/os2/apr_arch_proc_mutex.h +++ b/libs/apr/include/arch/os2/fspr_arch_proc_mutex.h @@ -17,11 +17,11 @@ #ifndef PROC_MUTEX_H #define PROC_MUTEX_H -#include "apr_proc_mutex.h" -#include "apr_file_io.h" +#include "fspr_proc_mutex.h" +#include "fspr_file_io.h" -struct apr_proc_mutex_t { - apr_pool_t *pool; +struct fspr_proc_mutex_t { + fspr_pool_t *pool; HMTX hMutex; TID owner; int lock_count; diff --git a/libs/apr/include/arch/os2/apr_arch_thread_cond.h b/libs/apr/include/arch/os2/fspr_arch_thread_cond.h similarity index 89% rename from libs/apr/include/arch/os2/apr_arch_thread_cond.h rename to libs/apr/include/arch/os2/fspr_arch_thread_cond.h index 648b85d148..6a2ecd8e01 100644 --- a/libs/apr/include/arch/os2/apr_arch_thread_cond.h +++ b/libs/apr/include/arch/os2/fspr_arch_thread_cond.h @@ -17,11 +17,11 @@ #ifndef THREAD_COND_H #define THREAD_COND_H -#include "apr_thread_cond.h" -#include "apr_file_io.h" +#include "fspr_thread_cond.h" +#include "fspr_file_io.h" -struct apr_thread_cond_t { - apr_pool_t *pool; +struct fspr_thread_cond_t { + fspr_pool_t *pool; }; #endif /* THREAD_COND_H */ diff --git a/libs/apr/include/arch/os2/apr_arch_thread_mutex.h b/libs/apr/include/arch/os2/fspr_arch_thread_mutex.h similarity index 89% rename from libs/apr/include/arch/os2/apr_arch_thread_mutex.h rename to libs/apr/include/arch/os2/fspr_arch_thread_mutex.h index 3ae2a41db7..fc6aeed45a 100644 --- a/libs/apr/include/arch/os2/apr_arch_thread_mutex.h +++ b/libs/apr/include/arch/os2/fspr_arch_thread_mutex.h @@ -17,11 +17,11 @@ #ifndef THREAD_MUTEX_H #define THREAD_MUTEX_H -#include "apr_thread_mutex.h" -#include "apr_file_io.h" +#include "fspr_thread_mutex.h" +#include "fspr_file_io.h" -struct apr_thread_mutex_t { - apr_pool_t *pool; +struct fspr_thread_mutex_t { + fspr_pool_t *pool; HMTX hMutex; }; diff --git a/libs/apr/include/arch/os2/apr_arch_thread_rwlock.h b/libs/apr/include/arch/os2/fspr_arch_thread_rwlock.h similarity index 89% rename from libs/apr/include/arch/os2/apr_arch_thread_rwlock.h rename to libs/apr/include/arch/os2/fspr_arch_thread_rwlock.h index 7187d5cb2e..fa721bf5a2 100644 --- a/libs/apr/include/arch/os2/apr_arch_thread_rwlock.h +++ b/libs/apr/include/arch/os2/fspr_arch_thread_rwlock.h @@ -17,11 +17,11 @@ #ifndef THREAD_RWLOCK_H #define THREAD_RWLOCK_H -#include "apr_thread_rwlock.h" -#include "apr_file_io.h" +#include "fspr_thread_rwlock.h" +#include "fspr_file_io.h" -struct apr_thread_rwlock_t { - apr_pool_t *pool; +struct fspr_thread_rwlock_t { + fspr_pool_t *pool; int readers; HMTX write_lock; HEV read_done; diff --git a/libs/apr/include/arch/os2/apr_arch_threadproc.h b/libs/apr/include/arch/os2/fspr_arch_threadproc.h similarity index 64% rename from libs/apr/include/arch/os2/apr_arch_threadproc.h rename to libs/apr/include/arch/os2/fspr_arch_threadproc.h index c8017adbff..ac1aa39c10 100644 --- a/libs/apr/include/arch/os2/apr_arch_threadproc.h +++ b/libs/apr/include/arch/os2/fspr_arch_threadproc.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#include "apr_thread_proc.h" -#include "apr_file_io.h" +#include "fspr_thread_proc.h" +#include "fspr_file_io.h" #ifndef THREAD_PROC_H #define THREAD_PROC_H @@ -25,40 +25,40 @@ #define SHELL_PATH "cmd.exe" #define APR_THREAD_STACKSIZE 65536 -struct apr_threadattr_t { - apr_pool_t *pool; +struct fspr_threadattr_t { + fspr_pool_t *pool; unsigned long attr; - apr_size_t stacksize; + fspr_size_t stacksize; }; -struct apr_thread_t { - apr_pool_t *pool; - struct apr_threadattr_t *attr; +struct fspr_thread_t { + fspr_pool_t *pool; + struct fspr_threadattr_t *attr; unsigned long tid; - apr_thread_start_t func; + fspr_thread_start_t func; void *data; - apr_status_t exitval; + fspr_status_t exitval; }; -struct apr_threadkey_t { - apr_pool_t *pool; +struct fspr_threadkey_t { + fspr_pool_t *pool; unsigned long *key; }; -struct apr_procattr_t { - apr_pool_t *pool; - apr_file_t *parent_in; - apr_file_t *child_in; - apr_file_t *parent_out; - apr_file_t *child_out; - apr_file_t *parent_err; - apr_file_t *child_err; +struct fspr_procattr_t { + fspr_pool_t *pool; + fspr_file_t *parent_in; + fspr_file_t *child_in; + fspr_file_t *parent_out; + fspr_file_t *child_out; + fspr_file_t *parent_err; + fspr_file_t *child_err; char *currdir; - apr_int32_t cmdtype; - apr_int32_t detached; + fspr_int32_t cmdtype; + fspr_int32_t detached; }; -struct apr_thread_once_t { +struct fspr_thread_once_t { unsigned long sem; char hit; }; diff --git a/libs/apr/include/arch/os390/apr_arch_dso.h b/libs/apr/include/arch/os390/fspr_arch_dso.h similarity index 86% rename from libs/apr/include/arch/os390/apr_arch_dso.h rename to libs/apr/include/arch/os390/fspr_arch_dso.h index 4263297b40..5fb8845ff6 100644 --- a/libs/apr/include/arch/os390/apr_arch_dso.h +++ b/libs/apr/include/arch/os390/fspr_arch_dso.h @@ -17,21 +17,21 @@ #ifndef DSO_H #define DSO_H -#include "apr_private.h" -#include "apr_general.h" -#include "apr_pools.h" -#include "apr_dso.h" -#include "apr.h" +#include "fspr_private.h" +#include "fspr_general.h" +#include "fspr_pools.h" +#include "fspr_dso.h" +#include "fspr.h" #if APR_HAS_DSO #include -struct apr_dso_handle_t { +struct fspr_dso_handle_t { dllhandle *handle; /* Handle to the DSO loaded */ int failing_errno; /* Don't save the buffer returned by strerror(); it gets reused */ - apr_pool_t *pool; + fspr_pool_t *pool; }; #endif diff --git a/libs/apr/include/arch/unix/apr_arch_dso.h b/libs/apr/include/arch/unix/fspr_arch_dso.h similarity index 88% rename from libs/apr/include/arch/unix/apr_arch_dso.h rename to libs/apr/include/arch/unix/fspr_arch_dso.h index d82182d48b..c65ccfccca 100644 --- a/libs/apr/include/arch/unix/apr_arch_dso.h +++ b/libs/apr/include/arch/unix/fspr_arch_dso.h @@ -17,11 +17,11 @@ #ifndef DSO_H #define DSO_H -#include "apr_private.h" -#include "apr_general.h" -#include "apr_pools.h" -#include "apr_dso.h" -#include "apr.h" +#include "fspr_private.h" +#include "fspr_general.h" +#include "fspr_pools.h" +#include "fspr_dso.h" +#include "fspr.h" #if APR_HAS_DSO @@ -52,8 +52,8 @@ #define DLSYM_NEEDS_UNDERSCORE #endif -struct apr_dso_handle_t { - apr_pool_t *pool; +struct fspr_dso_handle_t { + fspr_pool_t *pool; void *handle; const char *errormsg; }; diff --git a/libs/apr/include/arch/unix/apr_arch_file_io.h b/libs/apr/include/arch/unix/fspr_arch_file_io.h similarity index 80% rename from libs/apr/include/arch/unix/apr_arch_file_io.h rename to libs/apr/include/arch/unix/fspr_arch_file_io.h index 05ef8ed741..70a1cf9984 100644 --- a/libs/apr/include/arch/unix/apr_arch_file_io.h +++ b/libs/apr/include/arch/unix/fspr_arch_file_io.h @@ -17,17 +17,17 @@ #ifndef FILE_IO_H #define FILE_IO_H -#include "apr.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_tables.h" -#include "apr_file_io.h" -#include "apr_file_info.h" -#include "apr_errno.h" -#include "apr_lib.h" -#include "apr_thread_mutex.h" +#include "fspr.h" +#include "fspr_private.h" +#include "fspr_general.h" +#include "fspr_tables.h" +#include "fspr_file_io.h" +#include "fspr_file_info.h" +#include "fspr_errno.h" +#include "fspr_lib.h" +#include "fspr_thread_mutex.h" #ifndef WAITIO_USES_POLL -#include "apr_poll.h" +#include "fspr_poll.h" #endif /* System headers the file I/O library needs */ @@ -84,29 +84,29 @@ #define APR_FILE_BUFSIZE 4096 -struct apr_file_t { - apr_pool_t *pool; +struct fspr_file_t { + fspr_pool_t *pool; int filedes; char *fname; - apr_int32_t flags; + fspr_int32_t flags; int eof_hit; int is_pipe; - apr_interval_time_t timeout; + fspr_interval_time_t timeout; int buffered; enum {BLK_UNKNOWN, BLK_OFF, BLK_ON } blocking; int ungetchar; /* Last char provided by an unget op. (-1 = no char)*/ #ifndef WAITIO_USES_POLL /* if there is a timeout set, then this pollset is used */ - apr_pollset_t *pollset; + fspr_pollset_t *pollset; #endif /* Stuff for buffered mode */ char *buffer; int bufpos; /* Read/Write position in buffer */ unsigned long dataRead; /* amount of valid data read into buffer */ int direction; /* buffer being used for 0 = read, 1 = write */ - apr_off_t filePtr; /* position in file of handle */ + fspr_off_t filePtr; /* position in file of handle */ #if APR_HAS_THREADS - struct apr_thread_mutex_t *thlock; + struct fspr_thread_mutex_t *thlock; #endif }; @@ -121,17 +121,17 @@ typedef struct stat64 struct_stat; typedef struct stat struct_stat; #endif -struct apr_dir_t { - apr_pool_t *pool; +struct fspr_dir_t { + fspr_pool_t *pool; char *dirname; DIR *dirstruct; struct dirent *entry; }; -apr_status_t apr_unix_file_cleanup(void *); +fspr_status_t fspr_unix_file_cleanup(void *); -mode_t apr_unix_perms2mode(apr_fileperms_t perms); -apr_fileperms_t apr_unix_mode2perms(mode_t mode); +mode_t fspr_unix_perms2mode(fspr_fileperms_t perms); +fspr_fileperms_t fspr_unix_mode2perms(mode_t mode); #endif /* ! FILE_IO_H */ diff --git a/libs/apr/include/arch/unix/apr_arch_global_mutex.h b/libs/apr/include/arch/unix/fspr_arch_global_mutex.h similarity index 74% rename from libs/apr/include/arch/unix/apr_arch_global_mutex.h rename to libs/apr/include/arch/unix/fspr_arch_global_mutex.h index 3add9ecfa7..85c8c68745 100644 --- a/libs/apr/include/arch/unix/apr_arch_global_mutex.h +++ b/libs/apr/include/arch/unix/fspr_arch_global_mutex.h @@ -17,19 +17,19 @@ #ifndef GLOBAL_MUTEX_H #define GLOBAL_MUTEX_H -#include "apr.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_global_mutex.h" -#include "apr_arch_proc_mutex.h" -#include "apr_arch_thread_mutex.h" +#include "fspr.h" +#include "fspr_private.h" +#include "fspr_general.h" +#include "fspr_lib.h" +#include "fspr_global_mutex.h" +#include "fspr_arch_proc_mutex.h" +#include "fspr_arch_thread_mutex.h" -struct apr_global_mutex_t { - apr_pool_t *pool; - apr_proc_mutex_t *proc_mutex; +struct fspr_global_mutex_t { + fspr_pool_t *pool; + fspr_proc_mutex_t *proc_mutex; #if APR_HAS_THREADS - apr_thread_mutex_t *thread_mutex; + fspr_thread_mutex_t *thread_mutex; #endif /* APR_HAS_THREADS */ }; diff --git a/libs/apr/include/arch/unix/apr_arch_inherit.h b/libs/apr/include/arch/unix/fspr_arch_inherit.h similarity index 85% rename from libs/apr/include/arch/unix/apr_arch_inherit.h rename to libs/apr/include/arch/unix/fspr_arch_inherit.h index 9a6bdbca58..50c9ca9c19 100644 --- a/libs/apr/include/arch/unix/apr_arch_inherit.h +++ b/libs/apr/include/arch/unix/fspr_arch_inherit.h @@ -17,32 +17,32 @@ #ifndef INHERIT_H #define INHERIT_H -#include "apr_inherit.h" +#include "fspr_inherit.h" #define APR_INHERIT (1 << 24) /* Must not conflict with other bits */ #define APR_IMPLEMENT_INHERIT_SET(name, flag, pool, cleanup) \ -apr_status_t apr_##name##_inherit_set(apr_##name##_t *the##name) \ +fspr_status_t fspr_##name##_inherit_set(fspr_##name##_t *the##name) \ { \ if (the##name->flag & APR_FILE_NOCLEANUP) \ return APR_EINVAL; \ if (!(the##name->flag & APR_INHERIT)) { \ the##name->flag |= APR_INHERIT; \ - apr_pool_child_cleanup_set(the##name->pool, \ + fspr_pool_child_cleanup_set(the##name->pool, \ (void *)the##name, \ - cleanup, apr_pool_cleanup_null); \ + cleanup, fspr_pool_cleanup_null); \ } \ return APR_SUCCESS; \ } #define APR_IMPLEMENT_INHERIT_UNSET(name, flag, pool, cleanup) \ -apr_status_t apr_##name##_inherit_unset(apr_##name##_t *the##name) \ +fspr_status_t fspr_##name##_inherit_unset(fspr_##name##_t *the##name) \ { \ if (the##name->flag & APR_FILE_NOCLEANUP) \ return APR_EINVAL; \ if (the##name->flag & APR_INHERIT) { \ the##name->flag &= ~APR_INHERIT; \ - apr_pool_child_cleanup_set(the##name->pool, \ + fspr_pool_child_cleanup_set(the##name->pool, \ (void *)the##name, \ cleanup, cleanup); \ } \ diff --git a/libs/apr/include/arch/unix/apr_arch_internal_time.h b/libs/apr/include/arch/unix/fspr_arch_internal_time.h similarity index 94% rename from libs/apr/include/arch/unix/apr_arch_internal_time.h rename to libs/apr/include/arch/unix/fspr_arch_internal_time.h index 6e12c67439..4ea5d3e95d 100644 --- a/libs/apr/include/arch/unix/apr_arch_internal_time.h +++ b/libs/apr/include/arch/unix/fspr_arch_internal_time.h @@ -17,8 +17,8 @@ #ifndef TIME_INTERNAL_H #define TIME_INTERNAL_H -#include "apr.h" +#include "fspr.h" -void apr_unix_setup_time(void); +void fspr_unix_setup_time(void); #endif /* TIME_INTERNAL_H */ diff --git a/libs/apr/include/arch/unix/apr_arch_misc.h b/libs/apr/include/arch/unix/fspr_arch_misc.h similarity index 76% rename from libs/apr/include/arch/unix/apr_arch_misc.h rename to libs/apr/include/arch/unix/fspr_arch_misc.h index 823512506c..70b3b5531d 100644 --- a/libs/apr/include/arch/unix/apr_arch_misc.h +++ b/libs/apr/include/arch/unix/fspr_arch_misc.h @@ -17,16 +17,16 @@ #ifndef MISC_H #define MISC_H -#include "apr.h" -#include "apr_portable.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_pools.h" -#include "apr_getopt.h" -#include "apr_thread_proc.h" -#include "apr_file_io.h" -#include "apr_errno.h" -#include "apr_getopt.h" +#include "fspr.h" +#include "fspr_portable.h" +#include "fspr_private.h" +#include "fspr_general.h" +#include "fspr_pools.h" +#include "fspr_getopt.h" +#include "fspr_thread_proc.h" +#include "fspr_file_io.h" +#include "fspr_errno.h" +#include "fspr_getopt.h" #if APR_HAVE_STDIO_H #include @@ -49,13 +49,13 @@ #include #endif -struct apr_other_child_rec_t { - apr_pool_t *p; - struct apr_other_child_rec_t *next; - apr_proc_t *proc; +struct fspr_other_child_rec_t { + fspr_pool_t *p; + struct fspr_other_child_rec_t *next; + fspr_proc_t *proc; void (*maintenance) (int, void *, int); void *data; - apr_os_file_t write_fd; + fspr_os_file_t write_fd; }; #if defined(WIN32) || defined(NETWARE) diff --git a/libs/apr/include/arch/unix/apr_arch_networkio.h b/libs/apr/include/arch/unix/fspr_arch_networkio.h similarity index 80% rename from libs/apr/include/arch/unix/apr_arch_networkio.h rename to libs/apr/include/arch/unix/fspr_arch_networkio.h index 91018f7c6b..facbfe4382 100644 --- a/libs/apr/include/arch/unix/apr_arch_networkio.h +++ b/libs/apr/include/arch/unix/fspr_arch_networkio.h @@ -17,14 +17,14 @@ #ifndef NETWORK_IO_H #define NETWORK_IO_H -#include "apr.h" -#include "apr_private.h" -#include "apr_network_io.h" -#include "apr_errno.h" -#include "apr_general.h" -#include "apr_lib.h" +#include "fspr.h" +#include "fspr_private.h" +#include "fspr_network_io.h" +#include "fspr_errno.h" +#include "fspr_general.h" +#include "fspr_lib.h" #ifndef WAITIO_USES_POLL -#include "apr_poll.h" +#include "fspr_poll.h" #endif /* System headers the network I/O library needs */ @@ -100,37 +100,37 @@ struct sock_userdata_t { void *data; }; -struct apr_socket_t { - apr_pool_t *pool; +struct fspr_socket_t { + fspr_pool_t *pool; int socketdes; int type; int protocol; - apr_sockaddr_t *local_addr; - apr_sockaddr_t *remote_addr; - apr_interval_time_t timeout; + fspr_sockaddr_t *local_addr; + fspr_sockaddr_t *remote_addr; + fspr_interval_time_t timeout; #ifndef HAVE_POLL int connected; #endif int local_port_unknown; int local_interface_unknown; int remote_addr_unknown; - apr_int32_t options; - apr_int32_t inherit; + fspr_int32_t options; + fspr_int32_t inherit; sock_userdata_t *userdata; #ifndef WAITIO_USES_POLL /* if there is a timeout set, then this pollset is used */ - apr_pollset_t *pollset; + fspr_pollset_t *pollset; #endif }; -const char *apr_inet_ntop(int af, const void *src, char *dst, apr_size_t size); -int apr_inet_pton(int af, const char *src, void *dst); -void apr_sockaddr_vars_set(apr_sockaddr_t *, int, apr_port_t); +const char *fspr_inet_ntop(int af, const void *src, char *dst, fspr_size_t size); +int fspr_inet_pton(int af, const char *src, void *dst); +void fspr_sockaddr_vars_set(fspr_sockaddr_t *, int, fspr_port_t); -#define apr_is_option_set(skt, option) \ +#define fspr_is_option_set(skt, option) \ (((skt)->options & (option)) == (option)) -#define apr_set_option(skt, option, on) \ +#define fspr_set_option(skt, option, on) \ do { \ if (on) \ (skt)->options |= (option); \ diff --git a/libs/apr/include/arch/unix/apr_arch_poll_private.h b/libs/apr/include/arch/unix/fspr_arch_poll_private.h similarity index 83% rename from libs/apr/include/arch/unix/apr_arch_poll_private.h rename to libs/apr/include/arch/unix/fspr_arch_poll_private.h index f176eac0e5..93ad7b891c 100644 --- a/libs/apr/include/arch/unix/apr_arch_poll_private.h +++ b/libs/apr/include/arch/unix/fspr_arch_poll_private.h @@ -17,12 +17,12 @@ #ifndef APR_ARCH_POLL_PRIVATE_H #define APR_ARCH_POLL_PRIVATE_H -#include "apr.h" -#include "apr_poll.h" -#include "apr_time.h" -#include "apr_portable.h" -#include "apr_arch_networkio.h" -#include "apr_arch_file_io.h" +#include "fspr.h" +#include "fspr_poll.h" +#include "fspr_time.h" +#include "fspr_portable.h" +#include "fspr_arch_networkio.h" +#include "fspr_arch_file_io.h" #if HAVE_POLL_H #include @@ -52,7 +52,7 @@ #define HAS_PIPES(dt) (dt == APR_POLL_FILE) ? 1 : 0 #endif -/* Choose the best method platform specific to use in apr_pollset */ +/* Choose the best method platform specific to use in fspr_pollset */ #ifdef HAVE_KQUEUE #define POLLSET_USES_KQUEUE #elif defined(HAVE_PORT_CREATE) @@ -73,16 +73,16 @@ #if defined(POLLSET_USES_KQUEUE) || defined(POLLSET_USES_EPOLL) || defined(POLLSET_USES_PORT) -#include "apr_ring.h" +#include "fspr_ring.h" #if APR_HAS_THREADS -#include "apr_thread_mutex.h" +#include "fspr_thread_mutex.h" #define pollset_lock_rings() \ if (pollset->flags & APR_POLLSET_THREADSAFE) \ - apr_thread_mutex_lock(pollset->ring_lock); + fspr_thread_mutex_lock(pollset->ring_lock); #define pollset_unlock_rings() \ if (pollset->flags & APR_POLLSET_THREADSAFE) \ - apr_thread_mutex_unlock(pollset->ring_lock); + fspr_thread_mutex_unlock(pollset->ring_lock); #else #define pollset_lock_rings() #define pollset_unlock_rings() @@ -92,7 +92,7 @@ typedef struct pfd_elem_t pfd_elem_t; struct pfd_elem_t { APR_RING_ENTRY(pfd_elem_t) link; - apr_pollfd_t pfd; + fspr_pollfd_t pfd; }; #endif diff --git a/libs/apr/include/arch/unix/apr_arch_proc_mutex.h b/libs/apr/include/arch/unix/fspr_arch_proc_mutex.h similarity index 68% rename from libs/apr/include/arch/unix/apr_arch_proc_mutex.h rename to libs/apr/include/arch/unix/fspr_arch_proc_mutex.h index a307d94657..8f21801c7a 100644 --- a/libs/apr/include/arch/unix/apr_arch_proc_mutex.h +++ b/libs/apr/include/arch/unix/fspr_arch_proc_mutex.h @@ -23,15 +23,15 @@ #endif #endif -#include "apr.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_proc_mutex.h" -#include "apr_pools.h" -#include "apr_portable.h" -#include "apr_file_io.h" -#include "apr_arch_file_io.h" +#include "fspr.h" +#include "fspr_private.h" +#include "fspr_general.h" +#include "fspr_lib.h" +#include "fspr_proc_mutex.h" +#include "fspr_pools.h" +#include "fspr_portable.h" +#include "fspr_file_io.h" +#include "fspr_arch_file_io.h" /* System headers required by Locks library */ #if APR_HAVE_SYS_TYPES_H @@ -73,19 +73,19 @@ #endif /* End System Headers */ -struct apr_proc_mutex_unix_lock_methods_t { +struct fspr_proc_mutex_unix_lock_methods_t { unsigned int flags; - apr_status_t (*create)(apr_proc_mutex_t *, const char *); - apr_status_t (*acquire)(apr_proc_mutex_t *); - apr_status_t (*tryacquire)(apr_proc_mutex_t *); - apr_status_t (*release)(apr_proc_mutex_t *); - apr_status_t (*cleanup)(void *); - apr_status_t (*child_init)(apr_proc_mutex_t **, apr_pool_t *, const char *); + fspr_status_t (*create)(fspr_proc_mutex_t *, const char *); + fspr_status_t (*acquire)(fspr_proc_mutex_t *); + fspr_status_t (*tryacquire)(fspr_proc_mutex_t *); + fspr_status_t (*release)(fspr_proc_mutex_t *); + fspr_status_t (*cleanup)(void *); + fspr_status_t (*child_init)(fspr_proc_mutex_t **, fspr_pool_t *, const char *); const char *name; }; -typedef struct apr_proc_mutex_unix_lock_methods_t apr_proc_mutex_unix_lock_methods_t; +typedef struct fspr_proc_mutex_unix_lock_methods_t fspr_proc_mutex_unix_lock_methods_t; -/* bit values for flags field in apr_unix_lock_methods_t */ +/* bit values for flags field in fspr_unix_lock_methods_t */ #define APR_PROCESS_LOCK_MECH_IS_GLOBAL 1 #if !APR_HAVE_UNION_SEMUN && defined(APR_HAS_SYSVSEM_SERIALIZE) @@ -96,14 +96,14 @@ union semun { }; #endif -struct apr_proc_mutex_t { - apr_pool_t *pool; - const apr_proc_mutex_unix_lock_methods_t *meth; - const apr_proc_mutex_unix_lock_methods_t *inter_meth; +struct fspr_proc_mutex_t { + fspr_pool_t *pool; + const fspr_proc_mutex_unix_lock_methods_t *meth; + const fspr_proc_mutex_unix_lock_methods_t *inter_meth; int curr_locked; char *fname; #if APR_HAS_SYSVSEM_SERIALIZE || APR_HAS_FCNTL_SERIALIZE || APR_HAS_FLOCK_SERIALIZE - apr_file_t *interproc; + fspr_file_t *interproc; #endif #if APR_HAS_POSIXSEM_SERIALIZE sem_t *psem_interproc; @@ -113,7 +113,7 @@ struct apr_proc_mutex_t { #endif }; -void apr_proc_mutex_unix_setup_lock(void); +void fspr_proc_mutex_unix_setup_lock(void); #endif /* PROC_MUTEX_H */ diff --git a/libs/apr/include/arch/unix/apr_arch_shm.h b/libs/apr/include/arch/unix/fspr_arch_shm.h similarity index 81% rename from libs/apr/include/arch/unix/apr_arch_shm.h rename to libs/apr/include/arch/unix/fspr_arch_shm.h index dbd9b9bc5c..39b344ccdf 100644 --- a/libs/apr/include/arch/unix/apr_arch_shm.h +++ b/libs/apr/include/arch/unix/fspr_arch_shm.h @@ -17,15 +17,15 @@ #ifndef SHM_H #define SHM_H -#include "apr.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_shm.h" -#include "apr_pools.h" -#include "apr_file_io.h" -#include "apr_network_io.h" -#include "apr_portable.h" +#include "fspr.h" +#include "fspr_private.h" +#include "fspr_general.h" +#include "fspr_lib.h" +#include "fspr_shm.h" +#include "fspr_pools.h" +#include "fspr_file_io.h" +#include "fspr_network_io.h" +#include "fspr_portable.h" #ifdef HAVE_SYS_MMAN_H #include @@ -55,12 +55,12 @@ #define MAP_FAILED ((void *)-1) #endif -struct apr_shm_t { - apr_pool_t *pool; +struct fspr_shm_t { + fspr_pool_t *pool; void *base; /* base real address */ void *usable; /* base usable address */ - apr_size_t reqsize; /* requested segment size */ - apr_size_t realsize; /* actual segment size */ + fspr_size_t reqsize; /* requested segment size */ + fspr_size_t realsize; /* actual segment size */ const char *filename; /* NULL if anonymous */ #if APR_USE_SHMEM_SHMGET || APR_USE_SHMEM_SHMGET_ANON int shmid; /* shmem ID returned from shmget() */ diff --git a/libs/apr/include/arch/unix/apr_arch_thread_cond.h b/libs/apr/include/arch/unix/fspr_arch_thread_cond.h similarity index 82% rename from libs/apr/include/arch/unix/apr_arch_thread_cond.h rename to libs/apr/include/arch/unix/fspr_arch_thread_cond.h index 5c2b51d1f4..369bc23b17 100644 --- a/libs/apr/include/arch/unix/apr_arch_thread_cond.h +++ b/libs/apr/include/arch/unix/fspr_arch_thread_cond.h @@ -17,13 +17,13 @@ #ifndef THREAD_COND_H #define THREAD_COND_H -#include "apr.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_thread_mutex.h" -#include "apr_thread_cond.h" -#include "apr_pools.h" +#include "fspr.h" +#include "fspr_private.h" +#include "fspr_general.h" +#include "fspr_lib.h" +#include "fspr_thread_mutex.h" +#include "fspr_thread_cond.h" +#include "fspr_pools.h" #if APR_HAVE_PTHREAD_H #include @@ -32,8 +32,8 @@ /* XXX: Should we have a better autoconf search, something like * APR_HAS_PTHREAD_COND? -aaron */ #if APR_HAS_THREADS -struct apr_thread_cond_t { - apr_pool_t *pool; +struct fspr_thread_cond_t { + fspr_pool_t *pool; pthread_cond_t cond; }; #endif diff --git a/libs/apr/include/arch/unix/apr_arch_thread_mutex.h b/libs/apr/include/arch/unix/fspr_arch_thread_mutex.h similarity index 83% rename from libs/apr/include/arch/unix/apr_arch_thread_mutex.h rename to libs/apr/include/arch/unix/fspr_arch_thread_mutex.h index 0f9798701e..b11bd4ae1b 100644 --- a/libs/apr/include/arch/unix/apr_arch_thread_mutex.h +++ b/libs/apr/include/arch/unix/fspr_arch_thread_mutex.h @@ -23,20 +23,20 @@ #endif #endif -#include "apr.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_thread_mutex.h" -#include "apr_portable.h" -#include "apr_atomic.h" +#include "fspr.h" +#include "fspr_private.h" +#include "fspr_general.h" +#include "fspr_thread_mutex.h" +#include "fspr_portable.h" +#include "fspr_atomic.h" #if APR_HAVE_PTHREAD_H #include #endif #if APR_HAS_THREADS -struct apr_thread_mutex_t { - apr_pool_t *pool; +struct fspr_thread_mutex_t { + fspr_pool_t *pool; pthread_mutex_t mutex; }; #endif diff --git a/libs/apr/include/arch/unix/apr_arch_thread_rwlock.h b/libs/apr/include/arch/unix/fspr_arch_thread_rwlock.h similarity index 82% rename from libs/apr/include/arch/unix/apr_arch_thread_rwlock.h rename to libs/apr/include/arch/unix/fspr_arch_thread_rwlock.h index 2cb43af6a3..06a7e2a232 100644 --- a/libs/apr/include/arch/unix/apr_arch_thread_rwlock.h +++ b/libs/apr/include/arch/unix/fspr_arch_thread_rwlock.h @@ -17,11 +17,11 @@ #ifndef THREAD_RWLOCK_H #define THREAD_RWLOCK_H -#include "apr.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_thread_rwlock.h" -#include "apr_pools.h" +#include "fspr.h" +#include "fspr_private.h" +#include "fspr_general.h" +#include "fspr_thread_rwlock.h" +#include "fspr_pools.h" #if APR_HAVE_PTHREAD_H /* this gives us pthread_rwlock_t */ @@ -31,15 +31,15 @@ #if APR_HAS_THREADS #ifdef HAVE_PTHREAD_RWLOCKS -struct apr_thread_rwlock_t { - apr_pool_t *pool; +struct fspr_thread_rwlock_t { + fspr_pool_t *pool; pthread_rwlock_t rwlock; }; #else -struct apr_thread_rwlock_t { - apr_pool_t *pool; +struct fspr_thread_rwlock_t { + fspr_pool_t *pool; }; #endif diff --git a/libs/apr/include/arch/unix/apr_arch_threadproc.h b/libs/apr/include/arch/unix/fspr_arch_threadproc.h similarity index 71% rename from libs/apr/include/arch/unix/apr_arch_threadproc.h rename to libs/apr/include/arch/unix/fspr_arch_threadproc.h index 348c6c55d3..2573421b50 100644 --- a/libs/apr/include/arch/unix/apr_arch_threadproc.h +++ b/libs/apr/include/arch/unix/fspr_arch_threadproc.h @@ -14,11 +14,11 @@ * limitations under the License. */ -#include "apr.h" -#include "apr_private.h" -#include "apr_thread_proc.h" -#include "apr_file_io.h" -#include "apr_arch_file_io.h" +#include "fspr.h" +#include "fspr_private.h" +#include "fspr_thread_proc.h" +#include "fspr_file_io.h" +#include "fspr_arch_file_io.h" /* System headers required for thread/process library */ #if APR_HAVE_PTHREAD_H @@ -49,43 +49,43 @@ #if APR_HAS_THREADS -struct apr_thread_t { - apr_pool_t *pool; +struct fspr_thread_t { + fspr_pool_t *pool; pthread_t *td; void *data; - apr_thread_start_t func; - apr_status_t exitval; + fspr_thread_start_t func; + fspr_status_t exitval; int priority; }; -struct apr_threadattr_t { - apr_pool_t *pool; +struct fspr_threadattr_t { + fspr_pool_t *pool; pthread_attr_t attr; int priority; }; -struct apr_threadkey_t { - apr_pool_t *pool; +struct fspr_threadkey_t { + fspr_pool_t *pool; pthread_key_t key; }; -struct apr_thread_once_t { +struct fspr_thread_once_t { pthread_once_t once; }; #endif -struct apr_procattr_t { - apr_pool_t *pool; - apr_file_t *parent_in; - apr_file_t *child_in; - apr_file_t *parent_out; - apr_file_t *child_out; - apr_file_t *parent_err; - apr_file_t *child_err; +struct fspr_procattr_t { + fspr_pool_t *pool; + fspr_file_t *parent_in; + fspr_file_t *child_in; + fspr_file_t *parent_out; + fspr_file_t *child_out; + fspr_file_t *parent_err; + fspr_file_t *child_err; char *currdir; - apr_int32_t cmdtype; - apr_int32_t detached; + fspr_int32_t cmdtype; + fspr_int32_t detached; #ifdef RLIMIT_CPU struct rlimit *limit_cpu; #endif @@ -98,10 +98,10 @@ struct apr_procattr_t { #ifdef RLIMIT_NOFILE struct rlimit *limit_nofile; #endif - apr_child_errfn_t *errfn; - apr_int32_t errchk; - apr_uid_t uid; - apr_gid_t gid; + fspr_child_errfn_t *errfn; + fspr_int32_t errchk; + fspr_uid_t uid; + fspr_gid_t gid; }; #endif /* ! THREAD_PROC_H */ diff --git a/libs/apr/include/arch/win32/apr_arch_atime.h b/libs/apr/include/arch/win32/fspr_arch_atime.h similarity index 87% rename from libs/apr/include/arch/win32/apr_arch_atime.h rename to libs/apr/include/arch/win32/fspr_arch_atime.h index 47b75a9565..c1a47d12a9 100644 --- a/libs/apr/include/arch/win32/apr_arch_atime.h +++ b/libs/apr/include/arch/win32/fspr_arch_atime.h @@ -17,15 +17,15 @@ #ifndef ATIME_H #define ATIME_H -#include "apr_private.h" -#include "apr_time.h" +#include "fspr_private.h" +#include "fspr_time.h" #if APR_HAVE_TIME_H #include #endif struct atime_t { - apr_pool_t *cntxt; - apr_time_t currtime; + fspr_pool_t *cntxt; + fspr_time_t currtime; SYSTEMTIME *explodedtime; }; @@ -36,7 +36,7 @@ struct atime_t { #define APR_DELTA_EPOCH_IN_USEC APR_TIME_C(11644473600000000); -__inline void FileTimeToAprTime(apr_time_t *result, FILETIME *input) +__inline void FileTimeToAprTime(fspr_time_t *result, FILETIME *input) { /* Convert FILETIME one 64 bit number so we can work with it. */ *result = input->dwHighDateTime; @@ -48,7 +48,7 @@ __inline void FileTimeToAprTime(apr_time_t *result, FILETIME *input) } -__inline void AprTimeToFileTime(LPFILETIME pft, apr_time_t t) +__inline void AprTimeToFileTime(LPFILETIME pft, fspr_time_t t) { LONGLONG ll; t += APR_DELTA_EPOCH_IN_USEC; diff --git a/libs/apr/include/arch/win32/apr_arch_dso.h b/libs/apr/include/arch/win32/fspr_arch_dso.h similarity index 81% rename from libs/apr/include/arch/win32/apr_arch_dso.h rename to libs/apr/include/arch/win32/fspr_arch_dso.h index e2e4e40f2e..983b42eca7 100644 --- a/libs/apr/include/arch/win32/apr_arch_dso.h +++ b/libs/apr/include/arch/win32/fspr_arch_dso.h @@ -17,18 +17,18 @@ #ifndef DSO_H #define DSO_H -#include "apr_private.h" -#include "apr_general.h" -#include "apr_pools.h" -#include "apr_dso.h" -#include "apr.h" +#include "fspr_private.h" +#include "fspr_general.h" +#include "fspr_pools.h" +#include "fspr_dso.h" +#include "fspr.h" #if APR_HAS_DSO -struct apr_dso_handle_t { - apr_pool_t *cont; +struct fspr_dso_handle_t { + fspr_pool_t *cont; void *handle; - apr_status_t load_error; + fspr_status_t load_error; }; #endif diff --git a/libs/apr/include/arch/win32/apr_arch_file_io.h b/libs/apr/include/arch/win32/fspr_arch_file_io.h similarity index 72% rename from libs/apr/include/arch/win32/apr_arch_file_io.h rename to libs/apr/include/arch/win32/fspr_arch_file_io.h index 35c3c072ec..852d89dd65 100644 --- a/libs/apr/include/arch/win32/apr_arch_file_io.h +++ b/libs/apr/include/arch/win32/fspr_arch_file_io.h @@ -17,17 +17,17 @@ #ifndef FILE_IO_H #define FILE_IO_H -#include "apr.h" -#include "apr_private.h" -#include "apr_pools.h" -#include "apr_general.h" -#include "apr_tables.h" -#include "apr_thread_mutex.h" -#include "apr_file_io.h" -#include "apr_file_info.h" -#include "apr_errno.h" -#include "apr_arch_misc.h" -#include "apr_poll.h" +#include "fspr.h" +#include "fspr_private.h" +#include "fspr_pools.h" +#include "fspr_general.h" +#include "fspr_tables.h" +#include "fspr_thread_mutex.h" +#include "fspr_file_io.h" +#include "fspr_file_info.h" +#include "fspr_errno.h" +#include "fspr_arch_misc.h" +#include "fspr_poll.h" #ifdef HAVE_SYS_STAT_H #include @@ -49,10 +49,10 @@ #endif #if APR_HAS_UNICODE_FS -#include "arch/win32/apr_arch_utf8.h" +#include "arch/win32/fspr_arch_utf8.h" #include -typedef apr_uint16_t apr_wchar_t; +typedef fspr_uint16_t fspr_wchar_t; /* Helper functions for the WinNT ApiW() functions. APR treats all * resource identifiers (files, etc) by their UTF-8 name, to provide @@ -66,10 +66,10 @@ typedef apr_uint16_t apr_wchar_t; * Ascii API calls. So we tack them on in utf8_to_unicode_path, and * strip them right back off in unicode_to_utf8_path. */ -apr_status_t utf8_to_unicode_path(apr_wchar_t* dststr, apr_size_t dstchars, +fspr_status_t utf8_to_unicode_path(fspr_wchar_t* dststr, fspr_size_t dstchars, const char* srcstr); -apr_status_t unicode_to_utf8_path(char* dststr, apr_size_t dstchars, - const apr_wchar_t* srcstr); +fspr_status_t unicode_to_utf8_path(char* dststr, fspr_size_t dstchars, + const fspr_wchar_t* srcstr); #endif /* APR_HAS_UNICODE_FS */ @@ -80,7 +80,7 @@ apr_status_t unicode_to_utf8_path(char* dststr, apr_size_t dstchars, * and return the appropriate char* or wchar* for ApiA or ApiW calls. */ -void *res_name_from_filename(const char *file, int global, apr_pool_t *pool); +void *res_name_from_filename(const char *file, int global, fspr_pool_t *pool); #define APR_FILE_MAX MAX_PATH @@ -95,7 +95,7 @@ void *res_name_from_filename(const char *file, int global, apr_pool_t *pool); #define S_IFWHT 0160000 /* Whiteout */ #endif -/* Internal Flags for apr_file_open */ +/* Internal Flags for fspr_file_open */ #define APR_OPENINFO 0x00100000 /* Open without READ or WRITE access */ #define APR_OPENLINK 0x00200000 /* Open a link itself, if supported */ #define APR_READCONTROL 0x00400000 /* Read the file's owner/perms */ @@ -128,20 +128,20 @@ void *res_name_from_filename(const char *file, int global, apr_pool_t *pool); /* Sneak the Readonly bit through finfo->protection for internal use _only_ */ #define APR_FREADONLY 0x10000000 -/* Private function for apr_stat/lstat/getfileinfo/dir_read */ -int fillin_fileinfo(apr_finfo_t *finfo, WIN32_FILE_ATTRIBUTE_DATA *wininfo, - int byhandle, apr_int32_t wanted); +/* Private function for fspr_stat/lstat/getfileinfo/dir_read */ +int fillin_fileinfo(fspr_finfo_t *finfo, WIN32_FILE_ATTRIBUTE_DATA *wininfo, + int byhandle, fspr_int32_t wanted); -/* Private function that extends apr_stat/lstat/getfileinfo/dir_read */ -apr_status_t more_finfo(apr_finfo_t *finfo, const void *ufile, - apr_int32_t wanted, int whatfile); +/* Private function that extends fspr_stat/lstat/getfileinfo/dir_read */ +fspr_status_t more_finfo(fspr_finfo_t *finfo, const void *ufile, + fspr_int32_t wanted, int whatfile); /* whatfile types for the ufile arg */ #define MORE_OF_HANDLE 0 #define MORE_OF_FSPEC 1 #define MORE_OF_WFSPEC 2 -/* quick run-down of fields in windows' apr_file_t structure that may have +/* quick run-down of fields in windows' fspr_file_t structure that may have * obvious uses. * fname -- the filename as passed to the open call. * dwFileAttricutes -- Attributes used to open the file. @@ -150,19 +150,19 @@ apr_status_t more_finfo(apr_finfo_t *finfo, const void *ufile, * correctly when writing to a file with this flag set TRUE. */ -// for apr_poll.c; +// for fspr_poll.c; #define filedes filehand -struct apr_file_t { - apr_pool_t *pool; +struct fspr_file_t { + fspr_pool_t *pool; HANDLE filehand; BOOLEAN pipe; // Is this a pipe of a file? OVERLAPPED *pOverlapped; - apr_interval_time_t timeout; - apr_int32_t flags; + fspr_interval_time_t timeout; + fspr_int32_t flags; /* File specific info */ - apr_finfo_t *finfo; + fspr_finfo_t *finfo; char *fname; DWORD dwFileAttributes; int eof_hit; @@ -172,22 +172,22 @@ struct apr_file_t { /* Stuff for buffered mode */ char *buffer; - apr_size_t bufpos; // Read/Write position in buffer - apr_size_t dataRead; // amount of valid data read into buffer + fspr_size_t bufpos; // Read/Write position in buffer + fspr_size_t dataRead; // amount of valid data read into buffer int direction; // buffer being used for 0 = read, 1 = write - apr_off_t filePtr; // position in file of handle - apr_thread_mutex_t *mutex; // mutex semaphore, must be owned to access the above fields + fspr_off_t filePtr; // position in file of handle + fspr_thread_mutex_t *mutex; // mutex semaphore, must be owned to access the above fields /* if there is a timeout set, then this pollset is used */ - apr_pollset_t *pollset; + fspr_pollset_t *pollset; /* Pipe specific info */ }; -struct apr_dir_t { - apr_pool_t *pool; +struct fspr_dir_t { + fspr_pool_t *pool; HANDLE dirhand; - apr_size_t rootlen; + fspr_size_t rootlen; char *dirname; char *name; union { @@ -209,21 +209,21 @@ struct apr_dir_t { * or can confound the cmd.exe shell. Here's the list * [declared in filesys.c] */ -extern const char apr_c_is_fnchar[256]; +extern const char fspr_c_is_fnchar[256]; -#define IS_FNCHAR(c) (apr_c_is_fnchar[(unsigned char)(c)] & 1) -#define IS_SHCHAR(c) ((apr_c_is_fnchar[(unsigned char)(c)] & 2) == 2) +#define IS_FNCHAR(c) (fspr_c_is_fnchar[(unsigned char)(c)] & 1) +#define IS_SHCHAR(c) ((fspr_c_is_fnchar[(unsigned char)(c)] & 2) == 2) /* If the user passes APR_FILEPATH_TRUENAME to either - * apr_filepath_root or apr_filepath_merge, this fn determines + * fspr_filepath_root or fspr_filepath_merge, this fn determines * that the root really exists. It's expensive, wouldn't want * to do this too frequenly. */ -apr_status_t filepath_root_test(char *path, apr_pool_t *p); +fspr_status_t filepath_root_test(char *path, fspr_pool_t *p); -/* The apr_filepath_merge wants to canonicalize the cwd to the +/* The fspr_filepath_merge wants to canonicalize the cwd to the * addpath if the user passes NULL as the old root path (this * isn't true of an empty string "", which won't be concatenated. * @@ -233,18 +233,18 @@ apr_status_t filepath_root_test(char *path, apr_pool_t *p); * If flags includes the bit APR_FILEPATH_NATIVE, the path returned * is in the os-native format. */ -apr_status_t filepath_drive_get(char **rootpath, char drive, - apr_int32_t flags, apr_pool_t *p); +fspr_status_t filepath_drive_get(char **rootpath, char drive, + fspr_int32_t flags, fspr_pool_t *p); /* If the user passes d: vs. D: (or //mach/share vs. //MACH/SHARE), * we need to fold the case to canonical form. This function is * supposed to do so. */ -apr_status_t filepath_root_case(char **rootpath, char *root, apr_pool_t *p); +fspr_status_t filepath_root_case(char **rootpath, char *root, fspr_pool_t *p); -apr_status_t file_cleanup(void *); +fspr_status_t file_cleanup(void *); /** * Internal function to create a Win32/NT pipe that respects some async @@ -259,20 +259,20 @@ apr_status_t file_cleanup(void *); * APR_FULL_NONBLOCK * * @remark It so happens that APR_FULL_BLOCK and APR_FULL_NONBLOCK - * are common to apr_procattr_io_set() in, out and err modes. + * are common to fspr_procattr_io_set() in, out and err modes. * Because APR_CHILD_BLOCK and APR_WRITE_BLOCK share the same value, * as do APR_PARENT_BLOCK and APR_READ_BLOCK, it's possible to use * that value directly for creating the stdout/stderr pipes. When * creating the stdin pipe, the values must be transposed. - * @see apr_procattr_io_set + * @see fspr_procattr_io_set */ -apr_status_t apr_create_nt_pipe(apr_file_t **in, apr_file_t **out, - apr_int32_t blocking_mode, - apr_pool_t *p); +fspr_status_t fspr_create_nt_pipe(fspr_file_t **in, fspr_file_t **out, + fspr_int32_t blocking_mode, + fspr_pool_t *p); -/** @see apr_create_nt_pipe */ +/** @see fspr_create_nt_pipe */ #define APR_READ_BLOCK 3 -/** @see apr_create_nt_pipe */ +/** @see fspr_create_nt_pipe */ #define APR_WRITE_BLOCK 4 #endif /* ! FILE_IO_H */ diff --git a/libs/apr/include/arch/win32/apr_arch_inherit.h b/libs/apr/include/arch/win32/fspr_arch_inherit.h similarity index 87% rename from libs/apr/include/arch/win32/apr_arch_inherit.h rename to libs/apr/include/arch/win32/fspr_arch_inherit.h index 97c7d05d0a..02d9e05506 100644 --- a/libs/apr/include/arch/win32/apr_arch_inherit.h +++ b/libs/apr/include/arch/win32/fspr_arch_inherit.h @@ -17,19 +17,19 @@ #ifndef INHERIT_H #define INHERIT_H -#include "apr_inherit.h" +#include "fspr_inherit.h" #define APR_INHERIT (1 << 24) /* Must not conflict with other bits */ #define APR_IMPLEMENT_INHERIT_SET(name, flag, pool, cleanup) \ -APR_DECLARE(apr_status_t) apr_##name##_inherit_set(apr_##name##_t *the##name) \ +APR_DECLARE(fspr_status_t) fspr_##name##_inherit_set(fspr_##name##_t *the##name) \ { \ IF_WIN_OS_IS_UNICODE \ { \ if (!SetHandleInformation(the##name->filehand, \ HANDLE_FLAG_INHERIT, \ HANDLE_FLAG_INHERIT)) \ - return apr_get_os_error(); \ + return fspr_get_os_error(); \ } \ ELSE_WIN_OS_IS_ANSI \ { \ @@ -37,7 +37,7 @@ APR_DECLARE(apr_status_t) apr_##name##_inherit_set(apr_##name##_t *the##name) \ if (!DuplicateHandle(hproc, the##name->filehand, \ hproc, &temp, 0, TRUE, \ DUPLICATE_SAME_ACCESS)) \ - return apr_get_os_error(); \ + return fspr_get_os_error(); \ CloseHandle(the##name->filehand); \ the##name->filehand = temp; \ } \ @@ -45,13 +45,13 @@ APR_DECLARE(apr_status_t) apr_##name##_inherit_set(apr_##name##_t *the##name) \ } #define APR_IMPLEMENT_INHERIT_UNSET(name, flag, pool, cleanup) \ -APR_DECLARE(apr_status_t) apr_##name##_inherit_unset(apr_##name##_t *the##name)\ +APR_DECLARE(fspr_status_t) fspr_##name##_inherit_unset(fspr_##name##_t *the##name)\ { \ IF_WIN_OS_IS_UNICODE \ { \ if (!SetHandleInformation(the##name->filehand, \ HANDLE_FLAG_INHERIT, 0)) \ - return apr_get_os_error(); \ + return fspr_get_os_error(); \ } \ ELSE_WIN_OS_IS_ANSI \ { \ @@ -59,7 +59,7 @@ APR_DECLARE(apr_status_t) apr_##name##_inherit_unset(apr_##name##_t *the##name)\ if (!DuplicateHandle(hproc, the##name->filehand, \ hproc, &temp, 0, FALSE, \ DUPLICATE_SAME_ACCESS)) \ - return apr_get_os_error(); \ + return fspr_get_os_error(); \ CloseHandle(the##name->filehand); \ the##name->filehand = temp; \ } \ diff --git a/libs/apr/include/arch/win32/apr_arch_misc.h b/libs/apr/include/arch/win32/fspr_arch_misc.h similarity index 78% rename from libs/apr/include/arch/win32/apr_arch_misc.h rename to libs/apr/include/arch/win32/fspr_arch_misc.h index 6db6a1b9d2..89f01d1f6d 100644 --- a/libs/apr/include/arch/win32/apr_arch_misc.h +++ b/libs/apr/include/arch/win32/fspr_arch_misc.h @@ -17,16 +17,16 @@ #ifndef MISC_H #define MISC_H -#include "apr.h" -#include "apr_portable.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_pools.h" -#include "apr_getopt.h" -#include "apr_thread_proc.h" -#include "apr_file_io.h" -#include "apr_errno.h" -#include "apr_getopt.h" +#include "fspr.h" +#include "fspr_portable.h" +#include "fspr_private.h" +#include "fspr_general.h" +#include "fspr_pools.h" +#include "fspr_getopt.h" +#include "fspr_thread_proc.h" +#include "fspr_file_io.h" +#include "fspr_errno.h" +#include "fspr_getopt.h" #if APR_HAVE_STDIO_H #include @@ -46,26 +46,26 @@ #include #endif -struct apr_other_child_rec_t { - apr_pool_t *p; - struct apr_other_child_rec_t *next; - apr_proc_t *proc; +struct fspr_other_child_rec_t { + fspr_pool_t *p; + struct fspr_other_child_rec_t *next; + fspr_proc_t *proc; void (*maintenance) (int, void *, int); void *data; - apr_os_file_t write_fd; + fspr_os_file_t write_fd; }; #define WSAHighByte 2 #define WSALowByte 0 -/* start.c and apr_app.c helpers and communication within misc.c +/* start.c and fspr_app.c helpers and communication within misc.c * - * They are not for public consumption, although apr_app_init_complete + * They are not for public consumption, although fspr_app_init_complete * must be an exported symbol to avoid reinitialization. */ -extern int APR_DECLARE_DATA apr_app_init_complete; +extern int APR_DECLARE_DATA fspr_app_init_complete; -int apr_wastrtoastr(char const * const * *retarr, +int fspr_wastrtoastr(char const * const * *retarr, wchar_t const * const *arr, int args); /* Platform specific designation of run time os version. @@ -104,11 +104,11 @@ typedef enum { APR_WIN_XP_SP1 = 61, APR_WIN_XP_SP2 = 62, APR_WIN_2003 = 70 -} apr_oslevel_e; +} fspr_oslevel_e; -extern APR_DECLARE_DATA apr_oslevel_e apr_os_level; +extern APR_DECLARE_DATA fspr_oslevel_e fspr_os_level; -apr_status_t apr_get_oslevel(apr_oslevel_e *); +fspr_status_t fspr_get_oslevel(fspr_oslevel_e *); /* The APR_HAS_ANSI_FS symbol is PRIVATE, and internal to APR. * APR only supports char data for filenames. Like most applications, @@ -131,7 +131,7 @@ apr_status_t apr_get_oslevel(apr_oslevel_e *); * build which supports only WINNT or WCE. */ #if APR_HAS_ANSI_FS && APR_HAS_UNICODE_FS -#define IF_WIN_OS_IS_UNICODE if (apr_os_level >= APR_WIN_UNICODE) +#define IF_WIN_OS_IS_UNICODE if (fspr_os_level >= APR_WIN_UNICODE) #define ELSE_WIN_OS_IS_ANSI else #else /* APR_HAS_UNICODE_FS */ #define IF_WIN_OS_IS_UNICODE @@ -146,26 +146,26 @@ typedef enum { DLL_SHSTDAPI = 4, // shell32 From ShellAPI.h DLL_NTDLL = 5, // shell32 From our real kernel DLL_defined = 6 // must define as last idx_ + 1 -} apr_dlltoken_e; +} fspr_dlltoken_e; -FARPROC apr_load_dll_func(apr_dlltoken_e fnLib, char *fnName, int ordinal); +FARPROC fspr_load_dll_func(fspr_dlltoken_e fnLib, char *fnName, int ordinal); -/* The apr_load_dll_func call WILL fault if the function cannot be loaded */ +/* The fspr_load_dll_func call WILL fault if the function cannot be loaded */ #define APR_DECLARE_LATE_DLL_FUNC(lib, rettype, calltype, fn, ord, args, names) \ - typedef rettype (calltype *apr_winapi_fpt_##fn) args; \ - static apr_winapi_fpt_##fn apr_winapi_pfn_##fn = NULL; \ - __inline rettype apr_winapi_##fn args \ - { if (!apr_winapi_pfn_##fn) \ - apr_winapi_pfn_##fn = (apr_winapi_fpt_##fn) \ - apr_load_dll_func(lib, #fn, ord); \ - return (*(apr_winapi_pfn_##fn)) names; }; \ + typedef rettype (calltype *fspr_winapi_fpt_##fn) args; \ + static fspr_winapi_fpt_##fn fspr_winapi_pfn_##fn = NULL; \ + __inline rettype fspr_winapi_##fn args \ + { if (!fspr_winapi_pfn_##fn) \ + fspr_winapi_pfn_##fn = (fspr_winapi_fpt_##fn) \ + fspr_load_dll_func(lib, #fn, ord); \ + return (*(fspr_winapi_pfn_##fn)) names; }; \ /* Provide late bound declarations of every API function missing from * one or more supported releases of the Win32 API * - * lib is the enumerated token from apr_dlltoken_e, and must correspond - * to the string table entry in start.c used by the apr_load_dll_func(). + * lib is the enumerated token from fspr_dlltoken_e, and must correspond + * to the string table entry in start.c used by the fspr_load_dll_func(). * Token names (attempt to) follow Windows.h declarations prefixed by DLL_ * in order to facilitate comparison. Use the exact declaration syntax * and names from Windows.h to prevent ambigutity and bugs. @@ -190,9 +190,9 @@ APR_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, BOOL, WINAPI, GetFileAttributesExA, 0, IN GET_FILEEX_INFO_LEVELS fInfoLevelId, OUT LPVOID lpFileInformation), (lpFileName, fInfoLevelId, lpFileInformation)); -#define GetFileAttributesExA apr_winapi_GetFileAttributesExA +#define GetFileAttributesExA fspr_winapi_GetFileAttributesExA #undef GetFileAttributesEx -#define GetFileAttributesEx apr_winapi_GetFileAttributesExA +#define GetFileAttributesEx fspr_winapi_GetFileAttributesExA #ifdef GetFileAttributesExW #undef GetFileAttributesExW @@ -202,29 +202,29 @@ APR_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, BOOL, WINAPI, GetFileAttributesExW, 0, IN GET_FILEEX_INFO_LEVELS fInfoLevelId, OUT LPVOID lpFileInformation), (lpFileName, fInfoLevelId, lpFileInformation)); -#define GetFileAttributesExW apr_winapi_GetFileAttributesExW +#define GetFileAttributesExW fspr_winapi_GetFileAttributesExW APR_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, BOOL, WINAPI, CancelIo, 0, ( IN HANDLE hFile), (hFile)); -#define CancelIo apr_winapi_CancelIo +#define CancelIo fspr_winapi_CancelIo APR_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, BOOL, WINAPI, TryEnterCriticalSection, 0, ( LPCRITICAL_SECTION lpCriticalSection), (lpCriticalSection)); -#define TryEnterCriticalSection apr_winapi_TryEnterCriticalSection +#define TryEnterCriticalSection fspr_winapi_TryEnterCriticalSection APR_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, BOOL, WINAPI, SwitchToThread, 0, ( void), ()); -#define SwitchToThread apr_winapi_SwitchToThread +#define SwitchToThread fspr_winapi_SwitchToThread APR_DECLARE_LATE_DLL_FUNC(DLL_WINADVAPI, BOOL, WINAPI, GetEffectiveRightsFromAclW, 0, ( IN PACL pacl, IN PTRUSTEE_W pTrustee, OUT PACCESS_MASK pAccessRights), (pacl, pTrustee, pAccessRights)); -#define GetEffectiveRightsFromAclW apr_winapi_GetEffectiveRightsFromAclW +#define GetEffectiveRightsFromAclW fspr_winapi_GetEffectiveRightsFromAclW APR_DECLARE_LATE_DLL_FUNC(DLL_WINADVAPI, BOOL, WINAPI, GetNamedSecurityInfoW, 0, ( IN LPWSTR pObjectName, @@ -237,7 +237,7 @@ APR_DECLARE_LATE_DLL_FUNC(DLL_WINADVAPI, BOOL, WINAPI, GetNamedSecurityInfoW, 0, OUT PSECURITY_DESCRIPTOR *ppSecurityDescriptor), (pObjectName, ObjectType, SecurityInfo, ppsidOwner, ppsidGroup, ppDacl, ppSacl, ppSecurityDescriptor)); -#define GetNamedSecurityInfoW apr_winapi_GetNamedSecurityInfoW +#define GetNamedSecurityInfoW fspr_winapi_GetNamedSecurityInfoW APR_DECLARE_LATE_DLL_FUNC(DLL_WINADVAPI, BOOL, WINAPI, GetNamedSecurityInfoA, 0, ( IN LPSTR pObjectName, @@ -250,9 +250,9 @@ APR_DECLARE_LATE_DLL_FUNC(DLL_WINADVAPI, BOOL, WINAPI, GetNamedSecurityInfoA, 0, OUT PSECURITY_DESCRIPTOR *ppSecurityDescriptor), (pObjectName, ObjectType, SecurityInfo, ppsidOwner, ppsidGroup, ppDacl, ppSacl, ppSecurityDescriptor)); -#define GetNamedSecurityInfoA apr_winapi_GetNamedSecurityInfoA +#define GetNamedSecurityInfoA fspr_winapi_GetNamedSecurityInfoA #undef GetNamedSecurityInfo -#define GetNamedSecurityInfo apr_winapi_GetNamedSecurityInfoA +#define GetNamedSecurityInfo fspr_winapi_GetNamedSecurityInfoA APR_DECLARE_LATE_DLL_FUNC(DLL_WINADVAPI, BOOL, WINAPI, GetSecurityInfo, 0, ( IN HANDLE handle, @@ -265,13 +265,13 @@ APR_DECLARE_LATE_DLL_FUNC(DLL_WINADVAPI, BOOL, WINAPI, GetSecurityInfo, 0, ( OUT PSECURITY_DESCRIPTOR *ppSecurityDescriptor), (handle, ObjectType, SecurityInfo, ppsidOwner, ppsidGroup, ppDacl, ppSacl, ppSecurityDescriptor)); -#define GetSecurityInfo apr_winapi_GetSecurityInfo +#define GetSecurityInfo fspr_winapi_GetSecurityInfo APR_DECLARE_LATE_DLL_FUNC(DLL_SHSTDAPI, LPWSTR *, WINAPI, CommandLineToArgvW, 0, ( LPCWSTR lpCmdLine, int *pNumArgs), (lpCmdLine, pNumArgs)); -#define CommandLineToArgvW apr_winapi_CommandLineToArgvW +#define CommandLineToArgvW fspr_winapi_CommandLineToArgvW #endif /* !defined(_WIN32_WCE) && !defined(WINNT) */ @@ -282,14 +282,14 @@ APR_DECLARE_LATE_DLL_FUNC(DLL_NTDLL, DWORD, WINAPI, NtQueryTimerResolution, 0, ( ULONG *pMinRes, /* Maximum NS Resolution */ ULONG *pCurRes), /* Current NS Resolution */ (pMaxRes, pMinRes, pCurRes)); -#define QueryTimerResolution apr_winapi_NtQueryTimerResolution +#define QueryTimerResolution fspr_winapi_NtQueryTimerResolution APR_DECLARE_LATE_DLL_FUNC(DLL_NTDLL, DWORD, WINAPI, NtSetTimerResolution, 0, ( ULONG ReqRes, /* Requested NS Clock Resolution */ BOOL Acquire, /* Aquire (1) or Release (0) our interest */ ULONG *pNewRes), /* The NS Clock Resolution granted */ (ReqRes, Acquire, pNewRes)); -#define SetTimerResolution apr_winapi_NtSetTimerResolution +#define SetTimerResolution fspr_winapi_NtSetTimerResolution /* ### These are ULONG_PTR values, but that's int32 for all we care * until the Win64 port is prepared. @@ -310,7 +310,7 @@ APR_DECLARE_LATE_DLL_FUNC(DLL_NTDLL, DWORD, WINAPI, NtQueryInformationProcess, 0 ULONG LenPI, /* Use sizeof(PBI) */ ULONG *pSizePI), /* returns pPI buffer used (may pass NULL) */ (hProcess, info, pPI, LenPI, pSizePI)); -#define QueryInformationProcess apr_winapi_NtQueryInformationProcess +#define QueryInformationProcess fspr_winapi_NtQueryInformationProcess APR_DECLARE_LATE_DLL_FUNC(DLL_NTDLL, DWORD, WINAPI, NtQueryObject, 0, ( HANDLE hObject, /* Obvious */ @@ -319,7 +319,7 @@ APR_DECLARE_LATE_DLL_FUNC(DLL_NTDLL, DWORD, WINAPI, NtQueryObject, 0, ( ULONG LenOI, /* Use sizeof(PBI) */ ULONG *pSizeOI), /* returns pPI buffer used (may pass NULL) */ (hObject, info, pOI, LenOI, pSizeOI)); -#define QueryObject apr_winapi_NtQueryObject +#define QueryObject fspr_winapi_NtQueryObject #endif /* !defined(_WIN32_WCE) */ diff --git a/libs/apr/include/arch/win32/apr_arch_networkio.h b/libs/apr/include/arch/win32/fspr_arch_networkio.h similarity index 74% rename from libs/apr/include/arch/win32/apr_arch_networkio.h rename to libs/apr/include/arch/win32/fspr_arch_networkio.h index bb58dde224..d125adc067 100644 --- a/libs/apr/include/arch/win32/apr_arch_networkio.h +++ b/libs/apr/include/arch/win32/fspr_arch_networkio.h @@ -17,9 +17,9 @@ #ifndef NETWORK_IO_H #define NETWORK_IO_H -#include "apr_network_io.h" -#include "apr_general.h" -#include "apr_poll.h" +#include "fspr_network_io.h" +#include "fspr_general.h" +#include "fspr_poll.h" #ifdef _MSC_VER #undef MCAST_JOIN_SOURCE_GROUP #endif @@ -31,24 +31,24 @@ struct sock_userdata_t { void *data; }; -struct apr_socket_t { - apr_pool_t *pool; +struct fspr_socket_t { + fspr_pool_t *pool; SOCKET socketdes; int type; /* SOCK_STREAM, SOCK_DGRAM */ int protocol; - apr_sockaddr_t *local_addr; - apr_sockaddr_t *remote_addr; + fspr_sockaddr_t *local_addr; + fspr_sockaddr_t *remote_addr; int timeout_ms; /* MUST MATCH if timeout > 0 */ - apr_interval_time_t timeout; - apr_int32_t disconnected; + fspr_interval_time_t timeout; + fspr_int32_t disconnected; int local_port_unknown; int local_interface_unknown; int remote_addr_unknown; - apr_int32_t options; - apr_int32_t inherit; + fspr_int32_t options; + fspr_int32_t inherit; #if APR_HAS_SENDFILE /* As of 07.20.04, the overlapped structure is only used by - * apr_socket_sendfile and that's where it will be allocated + * fspr_socket_sendfile and that's where it will be allocated * and initialized. */ OVERLAPPED *overlapped; @@ -56,7 +56,7 @@ struct apr_socket_t { sock_userdata_t *userdata; /* if there is a timeout set, then this pollset is used */ - apr_pollset_t *pollset; + fspr_pollset_t *pollset; }; #ifdef _WIN32_WCE @@ -71,16 +71,16 @@ typedef struct _WSABUF { #define HAVE_STRUCT_IPMREQ #endif -apr_status_t status_from_res_error(int); +fspr_status_t status_from_res_error(int); -const char *apr_inet_ntop(int af, const void *src, char *dst, apr_size_t size); -int apr_inet_pton(int af, const char *src, void *dst); -void apr_sockaddr_vars_set(apr_sockaddr_t *, int, apr_port_t); +const char *fspr_inet_ntop(int af, const void *src, char *dst, fspr_size_t size); +int fspr_inet_pton(int af, const char *src, void *dst); +void fspr_sockaddr_vars_set(fspr_sockaddr_t *, int, fspr_port_t); -#define apr_is_option_set(skt, option) \ +#define fspr_is_option_set(skt, option) \ (((skt)->options & (option)) == (option)) -#define apr_set_option(skt, option, on) \ +#define fspr_set_option(skt, option, on) \ do { \ if (on) \ (skt)->options |= (option); \ diff --git a/libs/apr/include/arch/win32/apr_arch_proc_mutex.h b/libs/apr/include/arch/win32/fspr_arch_proc_mutex.h similarity index 92% rename from libs/apr/include/arch/win32/apr_arch_proc_mutex.h rename to libs/apr/include/arch/win32/fspr_arch_proc_mutex.h index 4e3e399399..cde7698a09 100644 --- a/libs/apr/include/arch/win32/apr_arch_proc_mutex.h +++ b/libs/apr/include/arch/win32/fspr_arch_proc_mutex.h @@ -17,10 +17,10 @@ #ifndef PROC_MUTEX_H #define PROC_MUTEX_H -#include "apr_proc_mutex.h" +#include "fspr_proc_mutex.h" -struct apr_proc_mutex_t { - apr_pool_t *pool; +struct fspr_proc_mutex_t { + fspr_pool_t *pool; HANDLE handle; const char *fname; }; diff --git a/libs/apr/include/arch/win32/apr_arch_thread_cond.h b/libs/apr/include/arch/win32/fspr_arch_thread_cond.h similarity index 92% rename from libs/apr/include/arch/win32/apr_arch_thread_cond.h rename to libs/apr/include/arch/win32/fspr_arch_thread_cond.h index c7f69f8064..482ddf4021 100644 --- a/libs/apr/include/arch/win32/apr_arch_thread_cond.h +++ b/libs/apr/include/arch/win32/fspr_arch_thread_cond.h @@ -17,10 +17,10 @@ #ifndef THREAD_COND_H #define THREAD_COND_H -#include "apr_thread_cond.h" +#include "fspr_thread_cond.h" -struct apr_thread_cond_t { - apr_pool_t *pool; +struct fspr_thread_cond_t { + fspr_pool_t *pool; HANDLE semaphore; CRITICAL_SECTION csection; unsigned long num_waiting; diff --git a/libs/apr/include/arch/win32/apr_arch_thread_mutex.h b/libs/apr/include/arch/win32/fspr_arch_thread_mutex.h similarity index 94% rename from libs/apr/include/arch/win32/apr_arch_thread_mutex.h rename to libs/apr/include/arch/win32/fspr_arch_thread_mutex.h index 13d3c1cbd5..c74255b86f 100644 --- a/libs/apr/include/arch/win32/apr_arch_thread_mutex.h +++ b/libs/apr/include/arch/win32/fspr_arch_thread_mutex.h @@ -17,7 +17,7 @@ #ifndef THREAD_MUTEX_H #define THREAD_MUTEX_H -#include "apr_pools.h" +#include "fspr_pools.h" typedef enum thread_mutex_type { thread_mutex_critical_section, @@ -29,8 +29,8 @@ typedef enum thread_mutex_type { * and nested_mutex on Win9x only. Otherwise critical_section * is used for NT nexted mutexes providing optimal performance. */ -struct apr_thread_mutex_t { - apr_pool_t *pool; +struct fspr_thread_mutex_t { + fspr_pool_t *pool; thread_mutex_type type; HANDLE handle; CRITICAL_SECTION section; diff --git a/libs/apr/include/arch/win32/apr_arch_thread_rwlock.h b/libs/apr/include/arch/win32/fspr_arch_thread_rwlock.h similarity index 92% rename from libs/apr/include/arch/win32/apr_arch_thread_rwlock.h rename to libs/apr/include/arch/win32/fspr_arch_thread_rwlock.h index 0a6889df83..28e8f953fe 100644 --- a/libs/apr/include/arch/win32/apr_arch_thread_rwlock.h +++ b/libs/apr/include/arch/win32/fspr_arch_thread_rwlock.h @@ -17,10 +17,10 @@ #ifndef THREAD_RWLOCK_H #define THREAD_RWLOCK_H -#include "apr_thread_rwlock.h" +#include "fspr_thread_rwlock.h" -struct apr_thread_rwlock_t { - apr_pool_t *pool; +struct fspr_thread_rwlock_t { + fspr_pool_t *pool; HANDLE write_mutex; HANDLE read_event; LONG readers; diff --git a/libs/apr/include/arch/win32/apr_arch_threadproc.h b/libs/apr/include/arch/win32/fspr_arch_threadproc.h similarity index 60% rename from libs/apr/include/arch/win32/apr_arch_threadproc.h rename to libs/apr/include/arch/win32/fspr_arch_threadproc.h index 056090bf11..47d9cff910 100644 --- a/libs/apr/include/arch/win32/apr_arch_threadproc.h +++ b/libs/apr/include/arch/win32/fspr_arch_threadproc.h @@ -14,50 +14,50 @@ * limitations under the License. */ -#include "apr_private.h" -#include "apr_thread_proc.h" -#include "apr_file_io.h" +#include "fspr_private.h" +#include "fspr_thread_proc.h" +#include "fspr_file_io.h" #ifndef THREAD_PROC_H #define THREAD_PROC_H #define SHELL_PATH "cmd.exe" -struct apr_thread_t { - apr_pool_t *pool; +struct fspr_thread_t { + fspr_pool_t *pool; HANDLE td; - apr_int32_t cancel; - apr_int32_t cancel_how; + fspr_int32_t cancel; + fspr_int32_t cancel_how; void *data; - apr_thread_start_t func; - apr_status_t exitval; + fspr_thread_start_t func; + fspr_status_t exitval; }; -struct apr_threadattr_t { - apr_pool_t *pool; - apr_int32_t detach; - apr_size_t stacksize; +struct fspr_threadattr_t { + fspr_pool_t *pool; + fspr_int32_t detach; + fspr_size_t stacksize; int priority; }; -struct apr_threadkey_t { - apr_pool_t *pool; +struct fspr_threadkey_t { + fspr_pool_t *pool; DWORD key; }; -struct apr_procattr_t { - apr_pool_t *pool; - apr_file_t *parent_in; - apr_file_t *child_in; - apr_file_t *parent_out; - apr_file_t *child_out; - apr_file_t *parent_err; - apr_file_t *child_err; +struct fspr_procattr_t { + fspr_pool_t *pool; + fspr_file_t *parent_in; + fspr_file_t *child_in; + fspr_file_t *parent_out; + fspr_file_t *child_out; + fspr_file_t *parent_err; + fspr_file_t *child_err; char *currdir; - apr_int32_t cmdtype; - apr_int32_t detached; - apr_child_errfn_t *errfn; - apr_int32_t errchk; + fspr_int32_t cmdtype; + fspr_int32_t detached; + fspr_child_errfn_t *errfn; + fspr_int32_t errchk; #ifndef _WIN32_WCE HANDLE user_token; LPSECURITY_ATTRIBUTES sa; @@ -65,7 +65,7 @@ struct apr_procattr_t { #endif }; -struct apr_thread_once_t { +struct fspr_thread_once_t { long value; }; diff --git a/libs/apr/include/arch/win32/apr_arch_utf8.h b/libs/apr/include/arch/win32/fspr_arch_utf8.h similarity index 76% rename from libs/apr/include/arch/win32/apr_arch_utf8.h rename to libs/apr/include/arch/win32/fspr_arch_utf8.h index 84f8bf775e..435ee03006 100644 --- a/libs/apr/include/arch/win32/apr_arch_utf8.h +++ b/libs/apr/include/arch/win32/fspr_arch_utf8.h @@ -17,13 +17,13 @@ #ifndef UTF8_H #define UTF8_H -#include "apr.h" -#include "apr_lib.h" -#include "apr_errno.h" +#include "fspr.h" +#include "fspr_lib.h" +#include "fspr_errno.h" /* If we ever support anything more exciting than char... this could move. */ -typedef apr_uint16_t apr_wchar_t; +typedef fspr_uint16_t fspr_wchar_t; /** * An APR internal function for fast utf-8 octet-encoded Unicode conversion @@ -34,10 +34,10 @@ typedef apr_uint16_t apr_wchar_t; * when the character code is invalid (in or out of context) and the later * when more characters were expected, but insufficient characters remain. */ -APR_DECLARE(apr_status_t) apr_conv_utf8_to_ucs2(const char *in, - apr_size_t *inbytes, - apr_wchar_t *out, - apr_size_t *outwords); +APR_DECLARE(fspr_status_t) fspr_conv_utf8_to_ucs2(const char *in, + fspr_size_t *inbytes, + fspr_wchar_t *out, + fspr_size_t *outwords); /** * An APR internal function for fast ucs-2 wide Unicode format conversion to @@ -48,9 +48,9 @@ APR_DECLARE(apr_status_t) apr_conv_utf8_to_ucs2(const char *in, * when the character code is invalid (in or out of context) and the later * when more words were expected, but insufficient words remain. */ -APR_DECLARE(apr_status_t) apr_conv_ucs2_to_utf8(const apr_wchar_t *in, - apr_size_t *inwords, +APR_DECLARE(fspr_status_t) fspr_conv_ucs2_to_utf8(const fspr_wchar_t *in, + fspr_size_t *inwords, char *out, - apr_size_t *outbytes); + fspr_size_t *outbytes); #endif /* def UTF8_H */ diff --git a/libs/apr/include/arch/win32/apr_dbg_win32_handles.h b/libs/apr/include/arch/win32/fspr_dbg_win32_handles.h similarity index 62% rename from libs/apr/include/arch/win32/apr_dbg_win32_handles.h rename to libs/apr/include/arch/win32/fspr_dbg_win32_handles.h index 471cd66dbf..ba576016a8 100644 --- a/libs/apr/include/arch/win32/apr_dbg_win32_handles.h +++ b/libs/apr/include/arch/win32/fspr_dbg_win32_handles.h @@ -23,18 +23,18 @@ extern "C" { /* USAGE: * - * Add the following include to apr_private.h for internal debugging, + * Add the following include to fspr_private.h for internal debugging, * or copy this header into apr/include add the include below to apr.h * for really global debugging; * - * #include "apr_dbg_win32_handles.h" + * #include "fspr_dbg_win32_handles.h" * - * apr_dbg_log is the crux of this function ... it uses Win32 API and + * fspr_dbg_log is the crux of this function ... it uses Win32 API and * no apr calls itself to log all activity to a file named for the * executing application with a .pid suffix. Ergo several instances * may be executing and logged at once. * - * HANDLE apr_dbg_log(char* fn, HANDLE ha, char* fl, int ln, int nh + * HANDLE fspr_dbg_log(char* fn, HANDLE ha, char* fl, int ln, int nh * [, HANDLE *hv, char *dsc...]) * * returns: the handle passed in ha, which is cast back to the real return type. @@ -42,7 +42,7 @@ extern "C" { * formats one line into the debug log file if nh is zero; * ha (hex) seq(hex) tid(hex) fn fl ln * xxxxxxxx xxxxxxxx xxxxxxxx func() sourcefile:lineno - * The macro apr_dbg_rv makes this simple to implement for many APIs + * The macro fspr_dbg_rv makes this simple to implement for many APIs * that simply take args that don't interest us, and return a handle. * * formats multiple lines (nh) into the debug log file for each hv/dsc pair @@ -53,67 +53,67 @@ extern "C" { * treated as a handle. */ -APR_DECLARE_NONSTD(HANDLE) apr_dbg_log(char* fn, HANDLE ha, char* fl, int ln, +APR_DECLARE_NONSTD(HANDLE) fspr_dbg_log(char* fn, HANDLE ha, char* fl, int ln, int nh,/* HANDLE *hv, char *dsc */...); -#define apr_dbg_rv(fn, args) (apr_dbg_log(#fn,(fn) args,__FILE__,__LINE__,0)) +#define fspr_dbg_rv(fn, args) (fspr_dbg_log(#fn,(fn) args,__FILE__,__LINE__,0)) #define CloseHandle(h) \ - ((BOOL)apr_dbg_log("CloseHandle", \ + ((BOOL)fspr_dbg_log("CloseHandle", \ (HANDLE)(CloseHandle)(h), \ __FILE__,__LINE__,1, \ &(h),"")) -#define CreateEventA(sd,b1,b2,nm) apr_dbg_rv(CreateEventA,(sd,b1,b2,nm)) -#define CreateEventW(sd,b1,b2,nm) apr_dbg_rv(CreateEventW,(sd,b1,b2,nm)) +#define CreateEventA(sd,b1,b2,nm) fspr_dbg_rv(CreateEventA,(sd,b1,b2,nm)) +#define CreateEventW(sd,b1,b2,nm) fspr_dbg_rv(CreateEventW,(sd,b1,b2,nm)) -#define CreateFileA(nm,d1,d2,sd,d3,d4,h) apr_dbg_rv(CreateFileA,(nm,d1,d2,sd,d3,d4,h)) -#define CreateFileW(nm,d1,d2,sd,d3,d4,h) apr_dbg_rv(CreateFileW,(nm,d1,d2,sd,d3,d4,h)) +#define CreateFileA(nm,d1,d2,sd,d3,d4,h) fspr_dbg_rv(CreateFileA,(nm,d1,d2,sd,d3,d4,h)) +#define CreateFileW(nm,d1,d2,sd,d3,d4,h) fspr_dbg_rv(CreateFileW,(nm,d1,d2,sd,d3,d4,h)) -#define CreateFileMappingA(fh,sd,d1,d2,d3,nm) apr_dbg_rv(CreateFileMappingA,(fh,sd,d1,d2,d3,nm)) -#define CreateFileMappingW(fh,sd,d1,d2,d3,nm) apr_dbg_rv(CreateFileMappingW,(fh,sd,d1,d2,d3,nm)) +#define CreateFileMappingA(fh,sd,d1,d2,d3,nm) fspr_dbg_rv(CreateFileMappingA,(fh,sd,d1,d2,d3,nm)) +#define CreateFileMappingW(fh,sd,d1,d2,d3,nm) fspr_dbg_rv(CreateFileMappingW,(fh,sd,d1,d2,d3,nm)) -#define CreateMutexA(sd,b,nm) apr_dbg_rv(CreateMutexA,(sd,b,nm)) -#define CreateMutexW(sd,b,nm) apr_dbg_rv(CreateMutexW,(sd,b,nm)) +#define CreateMutexA(sd,b,nm) fspr_dbg_rv(CreateMutexA,(sd,b,nm)) +#define CreateMutexW(sd,b,nm) fspr_dbg_rv(CreateMutexW,(sd,b,nm)) -#define CreateIoCompletionPort(h1,h2,pd1,d2) apr_dbg_rv(CreateIoCompletionPort,(h1,h2,pd1,d2)) +#define CreateIoCompletionPort(h1,h2,pd1,d2) fspr_dbg_rv(CreateIoCompletionPort,(h1,h2,pd1,d2)) -#define CreateNamedPipeA(nm,d1,d2,d3,d4,d5,d6,sd) apr_dbg_rv(CreateNamedPipeA,(nm,d1,d2,d3,d4,d5,d6,sd)) -#define CreateNamedPipeW(nm,d1,d2,d3,d4,d5,d6,sd) apr_dbg_rv(CreateNamedPipeW,(nm,d1,d2,d3,d4,d5,d6,sd)) +#define CreateNamedPipeA(nm,d1,d2,d3,d4,d5,d6,sd) fspr_dbg_rv(CreateNamedPipeA,(nm,d1,d2,d3,d4,d5,d6,sd)) +#define CreateNamedPipeW(nm,d1,d2,d3,d4,d5,d6,sd) fspr_dbg_rv(CreateNamedPipeW,(nm,d1,d2,d3,d4,d5,d6,sd)) #define CreatePipe(ph1,ph2,sd,d) \ - ((BOOL)apr_dbg_log("CreatePipe", \ + ((BOOL)fspr_dbg_log("CreatePipe", \ (HANDLE)(CreatePipe)(ph1,ph2,sd,d), \ __FILE__,__LINE__,2, \ (ph1),"hRead", \ (ph2),"hWrite")) #define CreateProcessA(s1,s2,sd1,sd2,b,d1,s3,s4,pd2,hr) \ - ((BOOL)apr_dbg_log("CreateProcessA", \ + ((BOOL)fspr_dbg_log("CreateProcessA", \ (HANDLE)(CreateProcessA)(s1,s2,sd1,sd2,b,d1,s3,s4,pd2,hr), \ __FILE__,__LINE__,2, \ &((hr)->hProcess),"hProcess", \ &((hr)->hThread),"hThread")) #define CreateProcessW(s1,s2,sd1,sd2,b,d1,s3,s4,pd2,hr) \ - ((BOOL)apr_dbg_log("CreateProcessW", \ + ((BOOL)fspr_dbg_log("CreateProcessW", \ (HANDLE)(CreateProcessW)(s1,s2,sd1,sd2,b,d1,s3,s4,pd2,hr), \ __FILE__,__LINE__,2, \ &((hr)->hProcess),"hProcess", \ &((hr)->hThread),"hThread")) -#define CreateSemaphoreA(sd,d1,d2,nm) apr_dbg_rv(CreateSemaphoreA,(sd,d1,d2,nm)) -#define CreateSemaphoreW(sd,d1,d2,nm) apr_dbg_rv(CreateSemaphoreW,(sd,d1,d2,nm)) +#define CreateSemaphoreA(sd,d1,d2,nm) fspr_dbg_rv(CreateSemaphoreA,(sd,d1,d2,nm)) +#define CreateSemaphoreW(sd,d1,d2,nm) fspr_dbg_rv(CreateSemaphoreW,(sd,d1,d2,nm)) -#define CreateThread(sd,d1,fn,pv,d2,pd3) apr_dbg_rv(CreateThread,(sd,d1,fn,pv,d2,pd3)) +#define CreateThread(sd,d1,fn,pv,d2,pd3) fspr_dbg_rv(CreateThread,(sd,d1,fn,pv,d2,pd3)) #define DeregisterEventSource(h) \ - ((BOOL)apr_dbg_log("DeregisterEventSource", \ + ((BOOL)fspr_dbg_log("DeregisterEventSource", \ (HANDLE)(DeregisterEventSource)(h), \ __FILE__,__LINE__,1, \ &(h),"")) #define DuplicateHandle(h1,h2,h3,ph4,d1,b,d2) \ - ((BOOL)apr_dbg_log("DuplicateHandle", \ + ((BOOL)fspr_dbg_log("DuplicateHandle", \ (HANDLE)(DuplicateHandle)(h1,h2,h3,ph4,d1,b,d2), \ __FILE__,__LINE__,2, \ (ph4),((h3)==GetCurrentProcess()) \ @@ -122,91 +122,91 @@ APR_DECLARE_NONSTD(HANDLE) apr_dbg_log(char* fn, HANDLE ha, char* fl, int ln, ? "Source" : "EXTERN Source")) #define GetCurrentProcess() \ - (apr_dbg_log("GetCurrentProcess", \ + (fspr_dbg_log("GetCurrentProcess", \ (GetCurrentProcess)(),__FILE__,__LINE__,0)) #define GetCurrentThread() \ - (apr_dbg_log("GetCurrentThread", \ + (fspr_dbg_log("GetCurrentThread", \ (GetCurrentThread)(),__FILE__,__LINE__,0)) -#define GetModuleHandleA(nm) apr_dbg_rv(GetModuleHandleA,(nm)) -#define GetModuleHandleW(nm) apr_dbg_rv(GetModuleHandleW,(nm)) +#define GetModuleHandleA(nm) fspr_dbg_rv(GetModuleHandleA,(nm)) +#define GetModuleHandleW(nm) fspr_dbg_rv(GetModuleHandleW,(nm)) -#define GetStdHandle(d) apr_dbg_rv(GetStdHandle,(d)) +#define GetStdHandle(d) fspr_dbg_rv(GetStdHandle,(d)) -#define LoadLibraryA(nm) apr_dbg_rv(LoadLibraryA,(nm)) -#define LoadLibraryW(nm) apr_dbg_rv(LoadLibraryW,(nm)) +#define LoadLibraryA(nm) fspr_dbg_rv(LoadLibraryA,(nm)) +#define LoadLibraryW(nm) fspr_dbg_rv(LoadLibraryW,(nm)) -#define LoadLibraryExA(nm,h,d) apr_dbg_rv(LoadLibraryExA,(nm,h,d)) -#define LoadLibraryExW(nm,h,d) apr_dbg_rv(LoadLibraryExW,(nm,h,d)) +#define LoadLibraryExA(nm,h,d) fspr_dbg_rv(LoadLibraryExA,(nm,h,d)) +#define LoadLibraryExW(nm,h,d) fspr_dbg_rv(LoadLibraryExW,(nm,h,d)) -#define OpenEventA(d,b,nm) apr_dbg_rv(OpenEventA,(d,b,nm)) -#define OpenEventW(d,b,nm) apr_dbg_rv(OpenEventW,(d,b,nm)) +#define OpenEventA(d,b,nm) fspr_dbg_rv(OpenEventA,(d,b,nm)) +#define OpenEventW(d,b,nm) fspr_dbg_rv(OpenEventW,(d,b,nm)) -#define OpenFileMappingA(d,b,nm) apr_dbg_rv(OpenFileMappingA,(d,b,nm)) -#define OpenFileMappingW(d,b,nm) apr_dbg_rv(OpenFileMappingW,(d,b,nm)) +#define OpenFileMappingA(d,b,nm) fspr_dbg_rv(OpenFileMappingA,(d,b,nm)) +#define OpenFileMappingW(d,b,nm) fspr_dbg_rv(OpenFileMappingW,(d,b,nm)) -#define RegisterEventSourceA(s1,s2) apr_dbg_rv(RegisterEventSourceA,(s1,s2)) -#define RegisterEventSourceW(s1,s2) apr_dbg_rv(RegisterEventSourceW,(s1,s2)) +#define RegisterEventSourceA(s1,s2) fspr_dbg_rv(RegisterEventSourceA,(s1,s2)) +#define RegisterEventSourceW(s1,s2) fspr_dbg_rv(RegisterEventSourceW,(s1,s2)) #define SetEvent(h) \ - ((BOOL)apr_dbg_log("SetEvent", \ + ((BOOL)fspr_dbg_log("SetEvent", \ (HANDLE)(SetEvent)(h), \ __FILE__,__LINE__,1, \ &(h),"")) #define SetStdHandle(d,h) \ - ((BOOL)apr_dbg_log("SetStdHandle", \ + ((BOOL)fspr_dbg_log("SetStdHandle", \ (HANDLE)(SetStdHandle)(d,h), \ __FILE__,__LINE__,1,&(h),"")) #define socket(i1,i2,i3) \ - ((SOCKET)apr_dbg_log("socket", \ + ((SOCKET)fspr_dbg_log("socket", \ (HANDLE)(socket)(i1,i2,i3), \ __FILE__,__LINE__,0)) #define WaitForSingleObject(h,d) \ - ((DWORD)apr_dbg_log("WaitForSingleObject", \ + ((DWORD)fspr_dbg_log("WaitForSingleObject", \ (HANDLE)(WaitForSingleObject)(h,d), \ __FILE__,__LINE__,1,&(h),"Signaled")) #define WaitForSingleObjectEx(h,d,b) \ - ((DWORD)apr_dbg_log("WaitForSingleObjectEx", \ + ((DWORD)fspr_dbg_log("WaitForSingleObjectEx", \ (HANDLE)(WaitForSingleObjectEx)(h,d,b), \ __FILE__,__LINE__,1,&(h),"Signaled")) #define WaitForMultipleObjects(d1,ah,b,d2) \ - ((DWORD)apr_dbg_log("WaitForMultipleObjects", \ + ((DWORD)fspr_dbg_log("WaitForMultipleObjects", \ (HANDLE)(WaitForMultipleObjects)(d1,ah,b,d2), \ __FILE__,__LINE__,1,ah,"Signaled")) #define WaitForMultipleObjectsEx(d1,ah,b1,d2,b2) \ - ((DWORD)apr_dbg_log("WaitForMultipleObjectsEx", \ + ((DWORD)fspr_dbg_log("WaitForMultipleObjectsEx", \ (HANDLE)(WaitForMultipleObjectsEx)(d1,ah,b1,d2,b2), \ __FILE__,__LINE__,1,ah,"Signaled")) #define WSASocketA(i1,i2,i3,pi,g,dw) \ - ((SOCKET)apr_dbg_log("WSASocketA", \ + ((SOCKET)fspr_dbg_log("WSASocketA", \ (HANDLE)(WSASocketA)(i1,i2,i3,pi,g,dw), \ __FILE__,__LINE__,0)) #define WSASocketW(i1,i2,i3,pi,g,dw) \ - ((SOCKET)apr_dbg_log("WSASocketW", \ + ((SOCKET)fspr_dbg_log("WSASocketW", \ (HANDLE)(WSASocketW)(i1,i2,i3,pi,g,dw), \ __FILE__,__LINE__,0)) #define closesocket(sh) \ - ((int)apr_dbg_log("closesocket", \ + ((int)fspr_dbg_log("closesocket", \ (HANDLE)(closesocket)(sh), \ __FILE__,__LINE__,1,&(sh),"")) #define _beginthread(fn,d,pv) \ - ((unsigned long)apr_dbg_log("_beginthread", \ + ((unsigned long)fspr_dbg_log("_beginthread", \ (HANDLE)(_beginthread)(fn,d,pv), \ __FILE__,__LINE__,0)) #define _beginthreadex(sd,d1,fn,pv,d2,pd3) \ - ((unsigned long)apr_dbg_log("_beginthreadex", \ + ((unsigned long)fspr_dbg_log("_beginthreadex", \ (HANDLE)(_beginthreadex)(sd,d1,fn,pv,d2,pd3), \ __FILE__,__LINE__,0)) diff --git a/libs/apr/include/arch/win32/apr_private.h b/libs/apr/include/arch/win32/fspr_private.h similarity index 97% rename from libs/apr/include/arch/win32/apr_private.h rename to libs/apr/include/arch/win32/fspr_private.h index 0dc5f98963..53af7067ef 100644 --- a/libs/apr/include/arch/win32/apr_private.h +++ b/libs/apr/include/arch/win32/fspr_private.h @@ -28,7 +28,7 @@ /* Include the public APR symbols, include our idea of the 'right' * subset of the Windows.h header. This saves us repetition. */ -#include "apr.h" +#include "fspr.h" /* * Add a _very_few_ declarations missing from the restricted set of headers @@ -153,7 +153,7 @@ APR_DECLARE_DATA int errno; #ifdef APR_INT64_STRFN #define APR_OFF_T_STRFN APR_INT64_STRFN #else -#define APR_OFF_T_STRFN apr_strtoi64 +#define APR_OFF_T_STRFN fspr_strtoi64 #endif #else #define APR_OFF_T_STRFN strtoi @@ -165,7 +165,7 @@ APR_DECLARE_DATA int errno; /* * Include common private declarations. */ -#include "../apr_private_common.h" +#include "../fspr_private_common.h" #endif /*APR_PRIVATE_H*/ #endif /*WIN32*/ diff --git a/libs/apr/include/apr.h.in b/libs/apr/include/fspr.h.in similarity index 92% rename from libs/apr/include/apr.h.in rename to libs/apr/include/fspr.h.in index 2a916184b7..4c0e80b400 100644 --- a/libs/apr/include/apr.h.in +++ b/libs/apr/include/fspr.h.in @@ -38,7 +38,7 @@ * @{ */ /** - * @defgroup apr_platform Platform Definitions + * @defgroup fspr_platform Platform Definitions * @{ */ @@ -152,7 +152,7 @@ extern "C" { #endif /** - * @addtogroup apr_platform + * @addtogroup fspr_platform * @ingroup APR * @{ */ @@ -254,21 +254,21 @@ extern "C" { /* Typedefs that APR needs. */ -typedef unsigned char apr_byte_t; +typedef unsigned char fspr_byte_t; -typedef @short_value@ apr_int16_t; -typedef unsigned @short_value@ apr_uint16_t; +typedef @short_value@ fspr_int16_t; +typedef unsigned @short_value@ fspr_uint16_t; -typedef @int_value@ apr_int32_t; -typedef unsigned @int_value@ apr_uint32_t; +typedef @int_value@ fspr_int32_t; +typedef unsigned @int_value@ fspr_uint32_t; -typedef @long_value@ apr_int64_t; -typedef unsigned @long_value@ apr_uint64_t; +typedef @long_value@ fspr_int64_t; +typedef unsigned @long_value@ fspr_uint64_t; -typedef @size_t_value@ apr_size_t; -typedef @ssize_t_value@ apr_ssize_t; -typedef @off_t_value@ apr_off_t; -typedef @socklen_t_value@ apr_socklen_t; +typedef @size_t_value@ fspr_size_t; +typedef @ssize_t_value@ fspr_ssize_t; +typedef @off_t_value@ fspr_off_t; +typedef @socklen_t_value@ fspr_socklen_t; #define APR_SIZEOF_VOIDP @voidp_size@ @@ -286,7 +286,7 @@ typedef @socklen_t_value@ apr_socklen_t; * so that they follow the platform's calling convention. * @example */ -/** void* APR_THREAD_FUNC my_thread_entry_fn(apr_thread_t *thd, void *data); +/** void* APR_THREAD_FUNC my_thread_entry_fn(fspr_thread_t *thd, void *data); */ #define APR_THREAD_FUNC @@ -298,7 +298,7 @@ typedef @socklen_t_value@ apr_socklen_t; * @remark Both the declaration and implementations must use the same macro. * @example */ -/** APR_DECLARE(rettype) apr_func(args) +/** APR_DECLARE(rettype) fspr_func(args) * @see APR_DECLARE_NONSTD @see APR_DECLARE_DATA * @remark Note that when APR compiles the library itself, it passes the * symbol -DAPR_DECLARE_EXPORT to the compiler on some platforms (e.g. Win32) @@ -319,7 +319,7 @@ typedef @socklen_t_value@ apr_socklen_t; * @remark Both the declaration and implementations must use the same macro. * @example */ -/** APR_DECLARE_NONSTD(rettype) apr_func(args, ...); +/** APR_DECLARE_NONSTD(rettype) fspr_func(args, ...); */ #define APR_DECLARE_NONSTD(type) type @@ -331,8 +331,8 @@ typedef @socklen_t_value@ apr_socklen_t; * but both must include the macro. * @example */ -/** extern APR_DECLARE_DATA type apr_variable;\n - * APR_DECLARE_DATA type apr_variable = value; +/** extern APR_DECLARE_DATA type fspr_variable;\n + * APR_DECLARE_DATA type fspr_variable = value; */ #define APR_DECLARE_DATA @@ -373,9 +373,9 @@ typedef @socklen_t_value@ apr_socklen_t; #if APR_HAVE_SYS_WAIT_H #ifdef WEXITSTATUS -#define apr_wait_t int +#define fspr_wait_t int #else -#define apr_wait_t union wait +#define fspr_wait_t union wait #define WEXITSTATUS(status) (int)((status).w_retcode) #define WTERMSIG(status) (int)((status).w_termsig) #endif /* !WEXITSTATUS */ diff --git a/libs/apr/include/apr.hnw b/libs/apr/include/fspr.hnw similarity index 91% rename from libs/apr/include/apr.hnw rename to libs/apr/include/fspr.hnw index 6f1e1559e5..774103f835 100644 --- a/libs/apr/include/apr.hnw +++ b/libs/apr/include/fspr.hnw @@ -73,7 +73,7 @@ extern "C" { #endif /** - * @defgroup apr_platform Platform Definitions + * @defgroup fspr_platform Platform Definitions * @ingroup APR * @{ */ @@ -232,28 +232,28 @@ extern "C" { /* Typedefs that APR needs. */ -typedef unsigned char apr_byte_t; +typedef unsigned char fspr_byte_t; -typedef short apr_int16_t; -typedef unsigned short apr_uint16_t; +typedef short fspr_int16_t; +typedef unsigned short fspr_uint16_t; -typedef int apr_int32_t; -typedef unsigned int apr_uint32_t; +typedef int fspr_int32_t; +typedef unsigned int fspr_uint32_t; -typedef long long apr_int64_t; -typedef unsigned long long apr_uint64_t; +typedef long long fspr_int64_t; +typedef unsigned long long fspr_uint64_t; -typedef size_t apr_size_t; -typedef ssize_t apr_ssize_t; +typedef size_t fspr_size_t; +typedef ssize_t fspr_ssize_t; #if APR_HAS_LARGE_FILES -typedef off64_t apr_off_t; +typedef off64_t fspr_off_t; #else -typedef off_t apr_off_t; +typedef off_t fspr_off_t; #endif #ifdef USE_WINSOCK -typedef int apr_socklen_t; +typedef int fspr_socklen_t; #else -typedef size_t apr_socklen_t; +typedef size_t fspr_socklen_t; #endif /* Are we big endian? */ @@ -280,7 +280,7 @@ typedef size_t apr_socklen_t; * so that they follow the platform's calling convention. * @example */ -/** void* APR_THREAD_FUNC my_thread_entry_fn(apr_thread_t *thd, void *data); +/** void* APR_THREAD_FUNC my_thread_entry_fn(fspr_thread_t *thd, void *data); */ #define APR_THREAD_FUNC @@ -292,7 +292,7 @@ typedef size_t apr_socklen_t; * @remark Both the declaration and implementations must use the same macro. * @example */ -/** APR_DECLARE(rettype) apr_func(args) +/** APR_DECLARE(rettype) fspr_func(args) * @see APR_DECLARE_NONSTD @see APR_DECLARE_DATA * @remark Note that when APR compiles the library itself, it passes the * symbol -DAPR_DECLARE_EXPORT to the compiler on some platforms (e.g. Win32) @@ -313,7 +313,7 @@ typedef size_t apr_socklen_t; * @remark Both the declaration and implementations must use the same macro. * @example */ -/** APR_DECLARE_NONSTD(rettype) apr_func(args, ...); +/** APR_DECLARE_NONSTD(rettype) fspr_func(args, ...); */ #define APR_DECLARE_NONSTD(type) type @@ -325,8 +325,8 @@ typedef size_t apr_socklen_t; * but both must include the macro. * @example */ -/** extern APR_DECLARE_DATA type apr_variable;\n - * APR_DECLARE_DATA type apr_variable = value; +/** extern APR_DECLARE_DATA type fspr_variable;\n + * APR_DECLARE_DATA type fspr_variable = value; */ #define APR_DECLARE_DATA @@ -345,7 +345,7 @@ typedef size_t apr_socklen_t; /* Local machine definition for console and log output. */ #define APR_EOL_STR "\r\n" -typedef int apr_wait_t; +typedef int fspr_wait_t; #define APR_PATH_MAX PATH_MAX diff --git a/libs/apr/include/apr.hw b/libs/apr/include/fspr.hw similarity index 92% rename from libs/apr/include/apr.hw rename to libs/apr/include/fspr.hw index aa47ec0374..e061ae49bf 100644 --- a/libs/apr/include/apr.hw +++ b/libs/apr/include/fspr.hw @@ -106,7 +106,7 @@ #endif /* !_WINDOWS_ */ /** - * @defgroup apr_platform Platform Definitions + * @defgroup fspr_platform Platform Definitions * @ingroup APR * @{ */ @@ -275,7 +275,7 @@ extern "C" { #endif /** - * @addtogroup apr_platform + * @addtogroup fspr_platform * @ingroup APR * @{ */ @@ -322,29 +322,29 @@ extern "C" { /* Typedefs that APR needs. */ -typedef unsigned char apr_byte_t; +typedef unsigned char fspr_byte_t; -typedef short apr_int16_t; -typedef unsigned short apr_uint16_t; +typedef short fspr_int16_t; +typedef unsigned short fspr_uint16_t; -typedef int apr_int32_t; -typedef unsigned int apr_uint32_t; +typedef int fspr_int32_t; +typedef unsigned int fspr_uint32_t; -typedef __int64 apr_int64_t; -typedef unsigned __int64 apr_uint64_t; +typedef __int64 fspr_int64_t; +typedef unsigned __int64 fspr_uint64_t; -typedef size_t apr_size_t; +typedef size_t fspr_size_t; #if APR_HAVE_STDDEF_H -typedef ptrdiff_t apr_ssize_t; +typedef ptrdiff_t fspr_ssize_t; #else -typedef int apr_ssize_t; +typedef int fspr_ssize_t; #endif #if APR_HAS_LARGE_FILES -typedef __int64 apr_off_t; +typedef __int64 fspr_off_t; #else -typedef int apr_off_t; +typedef int fspr_off_t; #endif -typedef int apr_socklen_t; +typedef int fspr_socklen_t; /* Are we big endian? */ /* XXX: Fatal assumption on Alpha platforms */ @@ -356,7 +356,7 @@ typedef int apr_socklen_t; #define APR_SIZEOF_VOIDP 4 #endif -/* XXX These simply don't belong here, perhaps in apr_portable.h +/* XXX These simply don't belong here, perhaps in fspr_portable.h * based on some APR_HAVE_PID/GID/UID? */ typedef int pid_t; @@ -378,8 +378,8 @@ typedef int gid_t; #ifndef WS2TCPIP_INLINE #define IN6_IS_ADDR_V4MAPPED(a) \ - ( (*(const apr_uint64_t *)(const void *)(&(a)->s6_addr[0]) == 0) \ - && (*(const apr_uint32_t *)(const void *)(&(a)->s6_addr[8]) == ntohl(0x0000ffff))) + ( (*(const fspr_uint64_t *)(const void *)(&(a)->s6_addr[0]) == 0) \ + && (*(const fspr_uint32_t *)(const void *)(&(a)->s6_addr[8]) == ntohl(0x0000ffff))) #endif #endif /* APR_HAS_IPV6 */ @@ -391,7 +391,7 @@ typedef int gid_t; * so that they follow the platform's calling convention. * @example */ -/** void* APR_THREAD_FUNC my_thread_entry_fn(apr_thread_t *thd, void *data); +/** void* APR_THREAD_FUNC my_thread_entry_fn(fspr_thread_t *thd, void *data); */ #define APR_THREAD_FUNC __stdcall @@ -406,7 +406,7 @@ typedef int gid_t; * @remark Both the declaration and implementations must use the same macro. * @example */ -/** APR_DECLARE(rettype) apr_func(args) +/** APR_DECLARE(rettype) fspr_func(args) * @see APR_DECLARE_NONSTD @see APR_DECLARE_DATA * @remark Note that when APR compiles the library itself, it passes the * symbol -DAPR_DECLARE_EXPORT to the compiler on some platforms (e.g. Win32) @@ -427,7 +427,7 @@ typedef int gid_t; * @remark Both the declaration and implementations must use the same macro. * @example */ -/** APR_DECLARE_NONSTD(rettype) apr_func(args, ...); +/** APR_DECLARE_NONSTD(rettype) fspr_func(args, ...); */ #define APR_DECLARE_NONSTD(type) type @@ -439,8 +439,8 @@ typedef int gid_t; * but both must include the macro. * @example */ -/** extern APR_DECLARE_DATA type apr_variable;\n - * APR_DECLARE_DATA type apr_variable = value; +/** extern APR_DECLARE_DATA type fspr_variable;\n + * APR_DECLARE_DATA type fspr_variable = value; */ #define APR_DECLARE_DATA @@ -484,12 +484,12 @@ typedef int gid_t; /* No difference between PROC and GLOBAL mutex */ #define APR_PROC_MUTEX_IS_GLOBAL 1 -typedef int apr_wait_t; +typedef int fspr_wait_t; /* struct iovec is needed to emulate Unix writev */ struct iovec { char* iov_base; - apr_size_t iov_len; + fspr_size_t iov_len; }; /* Nasty Win32 .h ommissions we really need */ diff --git a/libs/apr/include/apr_allocator.h b/libs/apr/include/fspr_allocator.h similarity index 65% rename from libs/apr/include/apr_allocator.h rename to libs/apr/include/fspr_allocator.h index 5aaeb1b2fa..17de2cb285 100644 --- a/libs/apr/include/apr_allocator.h +++ b/libs/apr/include/fspr_allocator.h @@ -18,50 +18,50 @@ #define APR_ALLOCATOR_H /** - * @file apr_allocator.h + * @file fspr_allocator.h * @brief APR Internal Memory Allocation */ -#include "apr.h" -#include "apr_errno.h" +#include "fspr.h" +#include "fspr_errno.h" #define APR_WANT_MEMFUNC /**< For no good reason? */ -#include "apr_want.h" +#include "fspr_want.h" #ifdef __cplusplus extern "C" { #endif /** - * @defgroup apr_allocator Internal Memory Allocation + * @defgroup fspr_allocator Internal Memory Allocation * @ingroup APR * @{ */ /** the allocator structure */ -typedef struct apr_allocator_t apr_allocator_t; +typedef struct fspr_allocator_t fspr_allocator_t; /** the structure which holds information about the allocation */ -typedef struct apr_memnode_t apr_memnode_t; +typedef struct fspr_memnode_t fspr_memnode_t; /** basic memory node structure * @note The next, ref and first_avail fields are available for use by the - * caller of apr_allocator_alloc(), the remaining fields are read-only. + * caller of fspr_allocator_alloc(), the remaining fields are read-only. * The next field has to be used with caution and sensibly set when the - * memnode is passed back to apr_allocator_free(). See apr_allocator_free() + * memnode is passed back to fspr_allocator_free(). See fspr_allocator_free() * for details. * The ref and first_avail fields will be properly restored by - * apr_allocator_free(). + * fspr_allocator_free(). */ -struct apr_memnode_t { - apr_memnode_t *next; /**< next memnode */ - apr_memnode_t **ref; /**< reference to self */ - apr_uint32_t index; /**< size */ - apr_uint32_t free_index; /**< how much free */ +struct fspr_memnode_t { + fspr_memnode_t *next; /**< next memnode */ + fspr_memnode_t **ref; /**< reference to self */ + fspr_uint32_t index; /**< size */ + fspr_uint32_t free_index; /**< how much free */ char *first_avail; /**< pointer to first free memory */ char *endp; /**< pointer to end of free memory */ }; /** The base size of a memory node - aligned. */ -#define APR_MEMNODE_T_SIZE APR_ALIGN_DEFAULT(sizeof(apr_memnode_t)) +#define APR_MEMNODE_T_SIZE APR_ALIGN_DEFAULT(sizeof(fspr_memnode_t)) /** Symbolic constants */ #define APR_ALLOCATOR_MAX_FREE_UNLIMITED 0 @@ -71,7 +71,7 @@ struct apr_memnode_t { * @param allocator The allocator we have just created. * */ -APR_DECLARE(apr_status_t) apr_allocator_create(apr_allocator_t **allocator); +APR_DECLARE(fspr_status_t) fspr_allocator_create(fspr_allocator_t **allocator); /** * Destroy an allocator @@ -79,7 +79,7 @@ APR_DECLARE(apr_status_t) apr_allocator_create(apr_allocator_t **allocator); * @remark Any memnodes not given back to the allocator prior to destroying * will _not_ be free()d. */ -APR_DECLARE(void) apr_allocator_destroy(apr_allocator_t *allocator); +APR_DECLARE(void) fspr_allocator_destroy(fspr_allocator_t *allocator); /** * Allocate a block of mem from the allocator @@ -87,8 +87,8 @@ APR_DECLARE(void) apr_allocator_destroy(apr_allocator_t *allocator); * @param size The size of the mem to allocate (excluding the * memnode structure) */ -APR_DECLARE(apr_memnode_t *) apr_allocator_alloc(apr_allocator_t *allocator, - apr_size_t size); +APR_DECLARE(fspr_memnode_t *) fspr_allocator_alloc(fspr_allocator_t *allocator, + fspr_size_t size); /** * Free a list of blocks of mem, giving them back to the allocator. @@ -97,10 +97,10 @@ APR_DECLARE(apr_memnode_t *) apr_allocator_alloc(apr_allocator_t *allocator, * @param allocator The allocator to give the mem back to * @param memnode The memory node to return */ -APR_DECLARE(void) apr_allocator_free(apr_allocator_t *allocator, - apr_memnode_t *memnode); +APR_DECLARE(void) fspr_allocator_free(fspr_allocator_t *allocator, + fspr_memnode_t *memnode); -#include "apr_pools.h" +#include "fspr_pools.h" /** * Set the owner of the allocator @@ -113,14 +113,14 @@ APR_DECLARE(void) apr_allocator_free(apr_allocator_t *allocator, * you can make a pool an owner, but if the pool doesn't use the allocator * the allocator will never be destroyed. */ -APR_DECLARE(void) apr_allocator_owner_set(apr_allocator_t *allocator, - apr_pool_t *pool); +APR_DECLARE(void) fspr_allocator_owner_set(fspr_allocator_t *allocator, + fspr_pool_t *pool); /** * Get the current owner of the allocator * @param allocator The allocator to get the owner from */ -APR_DECLARE(apr_pool_t *) apr_allocator_owner_get(apr_allocator_t *allocator); +APR_DECLARE(fspr_pool_t *) fspr_allocator_owner_get(fspr_allocator_t *allocator); /** * Set the current threshold at which the allocator should start @@ -128,10 +128,10 @@ APR_DECLARE(apr_pool_t *) apr_allocator_owner_get(apr_allocator_t *allocator); * @param allocator The allocator the set the threshold on * @param size The threshold. 0 == unlimited. */ -APR_DECLARE(void) apr_allocator_max_free_set(apr_allocator_t *allocator, - apr_size_t size); +APR_DECLARE(void) fspr_allocator_max_free_set(fspr_allocator_t *allocator, + fspr_size_t size); -#include "apr_thread_mutex.h" +#include "fspr_thread_mutex.h" #if APR_HAS_THREADS /** @@ -139,15 +139,15 @@ APR_DECLARE(void) apr_allocator_max_free_set(apr_allocator_t *allocator, * @param allocator The allocator to set the mutex for * @param mutex The mutex */ -APR_DECLARE(void) apr_allocator_mutex_set(apr_allocator_t *allocator, - apr_thread_mutex_t *mutex); +APR_DECLARE(void) fspr_allocator_mutex_set(fspr_allocator_t *allocator, + fspr_thread_mutex_t *mutex); /** * Get the mutex currently set for the allocator * @param allocator The allocator */ -APR_DECLARE(apr_thread_mutex_t *) apr_allocator_mutex_get( - apr_allocator_t *allocator); +APR_DECLARE(fspr_thread_mutex_t *) fspr_allocator_mutex_get( + fspr_allocator_t *allocator); #endif /* APR_HAS_THREADS */ diff --git a/libs/apr/include/apr_atomic.h b/libs/apr/include/fspr_atomic.h similarity index 64% rename from libs/apr/include/apr_atomic.h rename to libs/apr/include/fspr_atomic.h index b169ff3dc1..c06069ccc9 100644 --- a/libs/apr/include/apr_atomic.h +++ b/libs/apr/include/fspr_atomic.h @@ -18,19 +18,19 @@ #define APR_ATOMIC_H /** - * @file apr_atomic.h + * @file fspr_atomic.h * @brief APR Atomic Operations */ -#include "apr.h" -#include "apr_pools.h" +#include "fspr.h" +#include "fspr_pools.h" #ifdef __cplusplus extern "C" { #endif /** - * @defgroup apr_atomic Atomic Operations + * @defgroup fspr_atomic Atomic Operations * @ingroup APR * @{ */ @@ -41,7 +41,7 @@ extern "C" { * @param p pool * @return APR_SUCCESS on successful completion */ -APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *p); +APR_DECLARE(fspr_status_t) fspr_atomic_init(fspr_pool_t *p); /* * Atomic operations on 32-bit values @@ -50,65 +50,65 @@ APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *p); */ /** - * atomically read an apr_uint32_t from memory + * atomically read an fspr_uint32_t from memory * @param mem the pointer */ -APR_DECLARE(apr_uint32_t) apr_atomic_read32(volatile apr_uint32_t *mem); +APR_DECLARE(fspr_uint32_t) fspr_atomic_read32(volatile fspr_uint32_t *mem); /** - * atomically set an apr_uint32_t in memory + * atomically set an fspr_uint32_t in memory * @param mem pointer to the object * @param val value that the object will assume */ -APR_DECLARE(void) apr_atomic_set32(volatile apr_uint32_t *mem, apr_uint32_t val); +APR_DECLARE(void) fspr_atomic_set32(volatile fspr_uint32_t *mem, fspr_uint32_t val); /** - * atomically add 'val' to an apr_uint32_t + * atomically add 'val' to an fspr_uint32_t * @param mem pointer to the object * @param val amount to add * @return old value pointed to by mem */ -APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val); +APR_DECLARE(fspr_uint32_t) fspr_atomic_add32(volatile fspr_uint32_t *mem, fspr_uint32_t val); /** - * atomically subtract 'val' from an apr_uint32_t + * atomically subtract 'val' from an fspr_uint32_t * @param mem pointer to the object * @param val amount to subtract */ -APR_DECLARE(void) apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val); +APR_DECLARE(void) fspr_atomic_sub32(volatile fspr_uint32_t *mem, fspr_uint32_t val); /** - * atomically increment an apr_uint32_t by 1 + * atomically increment an fspr_uint32_t by 1 * @param mem pointer to the object * @return old value pointed to by mem */ -APR_DECLARE(apr_uint32_t) apr_atomic_inc32(volatile apr_uint32_t *mem); +APR_DECLARE(fspr_uint32_t) fspr_atomic_inc32(volatile fspr_uint32_t *mem); /** - * atomically decrement an apr_uint32_t by 1 + * atomically decrement an fspr_uint32_t by 1 * @param mem pointer to the atomic value * @return zero if the value becomes zero on decrement, otherwise non-zero */ -APR_DECLARE(int) apr_atomic_dec32(volatile apr_uint32_t *mem); +APR_DECLARE(int) fspr_atomic_dec32(volatile fspr_uint32_t *mem); /** - * compare an apr_uint32_t's value with 'cmp'. + * compare an fspr_uint32_t's value with 'cmp'. * If they are the same swap the value with 'with' * @param mem pointer to the value * @param with what to swap it with * @param cmp the value to compare it to * @return the old value of *mem */ -APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem, apr_uint32_t with, - apr_uint32_t cmp); +APR_DECLARE(fspr_uint32_t) fspr_atomic_cas32(volatile fspr_uint32_t *mem, fspr_uint32_t with, + fspr_uint32_t cmp); /** - * exchange an apr_uint32_t's value with 'val'. + * exchange an fspr_uint32_t's value with 'val'. * @param mem pointer to the value * @param val what to swap it with * @return the old value of *mem */ -APR_DECLARE(apr_uint32_t) apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint32_t val); +APR_DECLARE(fspr_uint32_t) fspr_atomic_xchg32(volatile fspr_uint32_t *mem, fspr_uint32_t val); /** * compare the pointer's value with cmp. @@ -118,7 +118,7 @@ APR_DECLARE(apr_uint32_t) apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint * @param cmp the value to compare it to * @return the old value of the pointer */ -APR_DECLARE(void*) apr_atomic_casptr(volatile void **mem, void *with, const void *cmp); +APR_DECLARE(void*) fspr_atomic_casptr(volatile void **mem, void *with, const void *cmp); /** @} */ diff --git a/libs/apr/include/apr_dso.h b/libs/apr/include/fspr_dso.h similarity index 74% rename from libs/apr/include/apr_dso.h rename to libs/apr/include/fspr_dso.h index ac701cfdf5..b43ad24040 100644 --- a/libs/apr/include/apr_dso.h +++ b/libs/apr/include/fspr_dso.h @@ -18,20 +18,20 @@ #define APR_DSO_DOT_H /** - * @file apr_dso.h + * @file fspr_dso.h * @brief APR Dynamic Object Handling Routines */ -#include "apr.h" -#include "apr_pools.h" -#include "apr_errno.h" +#include "fspr.h" +#include "fspr_pools.h" +#include "fspr_errno.h" #ifdef __cplusplus extern "C" { #endif /** - * @defgroup apr_dso Dynamic Object Handling + * @defgroup fspr_dso Dynamic Object Handling * @ingroup APR * @{ */ @@ -41,12 +41,12 @@ extern "C" { /** * Structure for referencing dynamic objects */ -typedef struct apr_dso_handle_t apr_dso_handle_t; +typedef struct fspr_dso_handle_t fspr_dso_handle_t; /** * Structure for referencing symbols from dynamic objects */ -typedef void * apr_dso_handle_sym_t; +typedef void * fspr_dso_handle_sym_t; /** * Load a DSO library. @@ -56,14 +56,14 @@ typedef void * apr_dso_handle_sym_t; * @bug We aught to provide an alternative to RTLD_GLOBAL, which * is the only supported method of loading DSOs today. */ -APR_DECLARE(apr_status_t) apr_dso_load(apr_dso_handle_t **res_handle, - const char *path, apr_pool_t *ctx); +APR_DECLARE(fspr_status_t) fspr_dso_load(fspr_dso_handle_t **res_handle, + const char *path, fspr_pool_t *ctx); /** * Close a DSO library. * @param handle handle to close. */ -APR_DECLARE(apr_status_t) apr_dso_unload(apr_dso_handle_t *handle); +APR_DECLARE(fspr_status_t) fspr_dso_unload(fspr_dso_handle_t *handle); /** * Load a symbol from a DSO handle. @@ -71,8 +71,8 @@ APR_DECLARE(apr_status_t) apr_dso_unload(apr_dso_handle_t *handle); * @param handle handle to load the symbol from. * @param symname Name of the symbol to load. */ -APR_DECLARE(apr_status_t) apr_dso_sym(apr_dso_handle_sym_t *ressym, - apr_dso_handle_t *handle, +APR_DECLARE(fspr_status_t) fspr_dso_sym(fspr_dso_handle_sym_t *ressym, + fspr_dso_handle_t *handle, const char *symname); /** @@ -81,7 +81,7 @@ APR_DECLARE(apr_status_t) apr_dso_sym(apr_dso_handle_sym_t *ressym, * @param buf Location to store the dso error * @param bufsize The size of the provided buffer */ -APR_DECLARE(const char *) apr_dso_error(apr_dso_handle_t *dso, char *buf, apr_size_t bufsize); +APR_DECLARE(const char *) fspr_dso_error(fspr_dso_handle_t *dso, char *buf, fspr_size_t bufsize); #endif /* APR_HAS_DSO */ diff --git a/libs/apr/include/apr_env.h b/libs/apr/include/fspr_env.h similarity index 77% rename from libs/apr/include/apr_env.h rename to libs/apr/include/fspr_env.h index 05419c37c1..d6f7ad6750 100644 --- a/libs/apr/include/apr_env.h +++ b/libs/apr/include/fspr_env.h @@ -17,18 +17,18 @@ #ifndef APR_ENV_H #define APR_ENV_H /** - * @file apr_env.h + * @file fspr_env.h * @brief APR Environment functions */ -#include "apr_errno.h" -#include "apr_pools.h" +#include "fspr_errno.h" +#include "fspr_pools.h" #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** - * @defgroup apr_env Functions for manupulating the environment + * @defgroup fspr_env Functions for manupulating the environment * @ingroup APR * @{ */ @@ -39,8 +39,8 @@ extern "C" { * @param envvar the name of the environment variable * @param pool where to allocate @a value and any temporary storage from */ -APR_DECLARE(apr_status_t) apr_env_get(char **value, const char *envvar, - apr_pool_t *pool); +APR_DECLARE(fspr_status_t) fspr_env_get(char **value, const char *envvar, + fspr_pool_t *pool); /** * Set the value of an environment variable @@ -48,15 +48,15 @@ APR_DECLARE(apr_status_t) apr_env_get(char **value, const char *envvar, * @param value the value to set * @param pool where to allocate temporary storage from */ -APR_DECLARE(apr_status_t) apr_env_set(const char *envvar, const char *value, - apr_pool_t *pool); +APR_DECLARE(fspr_status_t) fspr_env_set(const char *envvar, const char *value, + fspr_pool_t *pool); /** * Delete a variable from the environment * @param envvar the name of the environment variable * @param pool where to allocate temporary storage from */ -APR_DECLARE(apr_status_t) apr_env_delete(const char *envvar, apr_pool_t *pool); +APR_DECLARE(fspr_status_t) fspr_env_delete(const char *envvar, fspr_pool_t *pool); /** @} */ diff --git a/libs/apr/include/apr_errno.h b/libs/apr/include/fspr_errno.h similarity index 95% rename from libs/apr/include/apr_errno.h rename to libs/apr/include/fspr_errno.h index c74e44df95..13441ae324 100644 --- a/libs/apr/include/apr_errno.h +++ b/libs/apr/include/fspr_errno.h @@ -18,11 +18,11 @@ #define APR_ERRNO_H /** - * @file apr_errno.h + * @file fspr_errno.h * @brief APR Error Codes */ -#include "apr.h" +#include "fspr.h" #if APR_HAVE_ERRNO_H #include @@ -33,7 +33,7 @@ extern "C" { #endif /* __cplusplus */ /** - * @defgroup apr_errno Error Codes + * @defgroup fspr_errno Error Codes * @ingroup APR * @{ */ @@ -41,7 +41,7 @@ extern "C" { /** * Type for specifying an error or status code. */ -typedef int apr_status_t; +typedef int fspr_status_t; /** * Return a human readable string describing the specified error. @@ -49,14 +49,14 @@ typedef int apr_status_t; * @param buf A buffer to hold the error string. * @param bufsize Size of the buffer to hold the string. */ -APR_DECLARE(char *) apr_strerror(apr_status_t statcode, char *buf, - apr_size_t bufsize); +APR_DECLARE(char *) fspr_strerror(fspr_status_t statcode, char *buf, + fspr_size_t bufsize); #if defined(DOXYGEN) /** * @def APR_FROM_OS_ERROR(os_err_type syserr) - * Fold a platform specific error into an apr_status_t code. - * @return apr_status_t + * Fold a platform specific error into an fspr_status_t code. + * @return fspr_status_t * @param e The platform os error code. * @warning macro implementation; the syserr argument may be evaluated * multiple times. @@ -64,46 +64,46 @@ APR_DECLARE(char *) apr_strerror(apr_status_t statcode, char *buf, #define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR) /** - * @def APR_TO_OS_ERROR(apr_status_t statcode) + * @def APR_TO_OS_ERROR(fspr_status_t statcode) * @return os_err_type - * Fold an apr_status_t code back to the native platform defined error. - * @param e The apr_status_t folded platform os error code. + * Fold an fspr_status_t code back to the native platform defined error. + * @param e The fspr_status_t folded platform os error code. * @warning macro implementation; the statcode argument may be evaluated - * multiple times. If the statcode was not created by apr_get_os_error + * multiple times. If the statcode was not created by fspr_get_os_error * or APR_FROM_OS_ERROR, the results are undefined. */ #define APR_TO_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR) -/** @def apr_get_os_error() - * @return apr_status_t the last platform error, folded into apr_status_t, on most platforms +/** @def fspr_get_os_error() + * @return fspr_status_t the last platform error, folded into fspr_status_t, on most platforms * @remark This retrieves errno, or calls a GetLastError() style function, and * folds it with APR_FROM_OS_ERROR. Some platforms (such as OS2) have no * such mechanism, so this call may be unsupported. Do NOT use this * call for socket errors from socket, send, recv etc! */ -/** @def apr_set_os_error(e) - * Reset the last platform error, unfolded from an apr_status_t, on some platforms +/** @def fspr_set_os_error(e) + * Reset the last platform error, unfolded from an fspr_status_t, on some platforms * @param e The OS error folded in a prior call to APR_FROM_OS_ERROR() * @warning This is a macro implementation; the statcode argument may be evaluated - * multiple times. If the statcode was not created by apr_get_os_error + * multiple times. If the statcode was not created by fspr_get_os_error * or APR_FROM_OS_ERROR, the results are undefined. This macro sets * errno, or calls a SetLastError() style function, unfolding statcode * with APR_TO_OS_ERROR. Some platforms (such as OS2) have no such * mechanism, so this call may be unsupported. */ -/** @def apr_get_netos_error() - * Return the last socket error, folded into apr_status_t, on all platforms +/** @def fspr_get_netos_error() + * Return the last socket error, folded into fspr_status_t, on all platforms * @remark This retrieves errno or calls a GetLastSocketError() style function, * and folds it with APR_FROM_OS_ERROR. */ -/** @def apr_set_netos_error(e) - * Reset the last socket error, unfolded from an apr_status_t +/** @def fspr_set_netos_error(e) + * Reset the last socket error, unfolded from an fspr_status_t * @param e The socket error folded in a prior call to APR_FROM_OS_ERROR() * @warning This is a macro implementation; the statcode argument may be evaluated - * multiple times. If the statcode was not created by apr_get_os_error + * multiple times. If the statcode was not created by fspr_get_os_error * or APR_FROM_OS_ERROR, the results are undefined. This macro sets * errno, or calls a WSASetLastError() style function, unfolding * socketcode with APR_TO_OS_ERROR. @@ -146,12 +146,12 @@ APR_DECLARE(char *) apr_strerror(apr_status_t statcode, char *buf, + (APR_OS_ERRSPACE_SIZE * 10)) /** * APR_OS_START_EAIERR folds EAI_ error codes from getaddrinfo() into - * apr_status_t values. + * fspr_status_t values. */ #define APR_OS_START_EAIERR (APR_OS_START_CANONERR + APR_OS_ERRSPACE_SIZE) /** * APR_OS_START_SYSERR folds platform-specific system error values into - * apr_status_t values. + * fspr_status_t values. */ #define APR_OS_START_SYSERR (APR_OS_START_EAIERR + APR_OS_ERRSPACE_SIZE) @@ -176,7 +176,7 @@ APR_DECLARE(char *) apr_strerror(apr_status_t statcode, char *buf, * APR_ENOTHDKEY APR was not given a thread key structure * APR_ENOSHMAVAIL There is no more shared memory available * APR_EDSOOPEN APR was unable to open the dso object. For more - * information call apr_dso_error(). + * information call fspr_dso_error(). * APR_EGENERAL General failure (specific information not available) * APR_EBADIP The specified IP address is invalid * APR_EBADMASK The specified netmask is invalid @@ -327,7 +327,7 @@ APR_DECLARE(char *) apr_strerror(apr_status_t statcode, char *buf, /* empty slot: +18 */ /** * APR was unable to open the dso object. - * For more information call apr_dso_error(). + * For more information call fspr_dso_error(). */ #if defined(WIN32) #define APR_STATUS_IS_EDSOOPEN(s) ((s) == APR_EDSOOPEN \ @@ -348,7 +348,7 @@ APR_DECLARE(char *) apr_strerror(apr_status_t statcode, char *buf, /** The given path contained wildcards. */ #define APR_STATUS_IS_EPATHWILD(s) ((s) == APR_EPATHWILD) /** Could not find the requested symbol. - * For more information call apr_dso_error(). + * For more information call fspr_dso_error(). */ #if defined(WIN32) #define APR_STATUS_IS_ESYMNOTFOUND(s) ((s) == APR_ESYMNOTFOUND \ @@ -775,14 +775,14 @@ APR_DECLARE(char *) apr_strerror(apr_status_t statcode, char *buf, * The API calls always return a result codes which * should be filtered through APR_FROM_OS_ERROR(). * - * #define apr_get_os_error() (APR_FROM_OS_ERROR(GetLastError())) - * #define apr_set_os_error(e) (SetLastError(APR_TO_OS_ERROR(e))) + * #define fspr_get_os_error() (APR_FROM_OS_ERROR(GetLastError())) + * #define fspr_set_os_error(e) (SetLastError(APR_TO_OS_ERROR(e))) */ /* A special case, only socket calls require this; */ -#define apr_get_netos_error() (APR_FROM_OS_ERROR(errno)) -#define apr_set_netos_error(e) (errno = APR_TO_OS_ERROR(e)) +#define fspr_get_netos_error() (APR_FROM_OS_ERROR(errno)) +#define fspr_set_netos_error(e) (errno = APR_TO_OS_ERROR(e)) /* And this needs to be greped away for good: */ @@ -938,13 +938,13 @@ APR_DECLARE(char *) apr_strerror(apr_status_t statcode, char *buf, #define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR) #define APR_TO_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR) -#define apr_get_os_error() (APR_FROM_OS_ERROR(GetLastError())) -#define apr_set_os_error(e) (SetLastError(APR_TO_OS_ERROR(e))) +#define fspr_get_os_error() (APR_FROM_OS_ERROR(GetLastError())) +#define fspr_set_os_error(e) (SetLastError(APR_TO_OS_ERROR(e))) /* A special case, only socket calls require this: */ -#define apr_get_netos_error() (APR_FROM_OS_ERROR(WSAGetLastError())) -#define apr_set_netos_error(e) (WSASetLastError(APR_TO_OS_ERROR(e))) +#define fspr_get_netos_error() (APR_FROM_OS_ERROR(WSAGetLastError())) +#define fspr_set_netos_error(e) (WSASetLastError(APR_TO_OS_ERROR(e))) /* APR CANONICAL ERROR TESTS */ #define APR_STATUS_IS_EACCES(s) ((s) == APR_EACCES \ @@ -1051,12 +1051,12 @@ APR_DECLARE(char *) apr_strerror(apr_status_t statcode, char *buf, #define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR) #define APR_TO_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR) -#define apr_get_os_error() (errno) -#define apr_set_os_error(e) (errno = (e)) +#define fspr_get_os_error() (errno) +#define fspr_set_os_error(e) (errno = (e)) /* A special case, only socket calls require this: */ -#define apr_get_netos_error() (APR_FROM_OS_ERROR(WSAGetLastError())) -#define apr_set_netos_error(e) (WSASetLastError(APR_TO_OS_ERROR(e))) +#define fspr_get_netos_error() (APR_FROM_OS_ERROR(WSAGetLastError())) +#define fspr_set_netos_error(e) (WSASetLastError(APR_TO_OS_ERROR(e))) /* APR CANONICAL ERROR TESTS */ #define APR_STATUS_IS_EACCES(s) ((s) == APR_EACCES) @@ -1113,13 +1113,13 @@ APR_DECLARE(char *) apr_strerror(apr_status_t statcode, char *buf, #define APR_FROM_OS_ERROR(e) (e) #define APR_TO_OS_ERROR(e) (e) -#define apr_get_os_error() (errno) -#define apr_set_os_error(e) (errno = (e)) +#define fspr_get_os_error() (errno) +#define fspr_set_os_error(e) (errno = (e)) /* A special case, only socket calls require this: */ -#define apr_get_netos_error() (errno) -#define apr_set_netos_error(e) (errno = (e)) +#define fspr_get_netos_error() (errno) +#define fspr_set_netos_error(e) (errno = (e)) /** * @addtogroup APR_STATUS_IS diff --git a/libs/apr/include/apr_file_info.h b/libs/apr/include/fspr_file_info.h similarity index 78% rename from libs/apr/include/apr_file_info.h rename to libs/apr/include/fspr_file_info.h index 94146f0ae3..44a75ee348 100644 --- a/libs/apr/include/apr_file_info.h +++ b/libs/apr/include/fspr_file_info.h @@ -18,16 +18,16 @@ #define APR_FILE_INFO_H /** - * @file apr_file_info.h + * @file fspr_file_info.h * @brief APR File Information */ -#include "apr.h" -#include "apr_user.h" -#include "apr_pools.h" -#include "apr_tables.h" -#include "apr_time.h" -#include "apr_errno.h" +#include "fspr.h" +#include "fspr_user.h" +#include "fspr_pools.h" +#include "fspr_tables.h" +#include "fspr_time.h" +#include "fspr_errno.h" #if APR_HAVE_SYS_UIO_H #include @@ -38,7 +38,7 @@ extern "C" { #endif /* __cplusplus */ /** - * @defgroup apr_file_info File Information + * @defgroup fspr_file_info File Information * @ingroup APR * @{ */ @@ -48,8 +48,8 @@ extern "C" { * so the APR_NOFILE value must be distinct from APR_UNKFILE. */ -/** apr_filetype_e values for the filetype member of the - * apr_file_info_t structure +/** fspr_filetype_e values for the filetype member of the + * fspr_file_info_t structure * @warning: Not all of the filetypes below can be determined. * For example, a given platform might not correctly report * a socket descriptor as APR_SOCK if that type isn't @@ -69,10 +69,10 @@ typedef enum { APR_LNK, /**< a symbolic link */ APR_SOCK, /**< a [unix domain] socket */ APR_UNKFILE = 127 /**< a file of some other unknown type */ -} apr_filetype_e; +} fspr_filetype_e; /** - * @defgroup apr_file_permissions File Permissions flags + * @defgroup fspr_file_permissions File Permissions flags * @{ */ @@ -93,7 +93,7 @@ typedef enum { #define APR_FPROT_OS_DEFAULT 0x0FFF /**< use OS's default permissions */ -/* additional permission flags for apr_file_copy and apr_file_append */ +/* additional permission flags for fspr_file_copy and fspr_file_append */ #define APR_FPROT_FILE_SOURCE_PERMS 0x1000 /**< Copy source file's permissions */ /* backcompat */ @@ -118,35 +118,35 @@ typedef enum { /** * Structure for referencing directories. */ -typedef struct apr_dir_t apr_dir_t; +typedef struct fspr_dir_t fspr_dir_t; /** * Structure for determining file permissions. */ -typedef apr_int32_t apr_fileperms_t; +typedef fspr_int32_t fspr_fileperms_t; #if (defined WIN32) || (defined NETWARE) /** * Structure for determining the inode of the file. */ -typedef apr_uint64_t apr_ino_t; +typedef fspr_uint64_t fspr_ino_t; /** * Structure for determining the device the file is on. */ -typedef apr_uint32_t apr_dev_t; +typedef fspr_uint32_t fspr_dev_t; #else /** The inode of the file. */ -typedef ino_t apr_ino_t; +typedef ino_t fspr_ino_t; /** * Structure for determining the device the file is on. */ -typedef dev_t apr_dev_t; +typedef dev_t fspr_dev_t; #endif /** - * @defgroup apr_file_stat Stat Functions + * @defgroup fspr_file_stat Stat Functions * @{ */ /** file info structure */ -typedef struct apr_finfo_t apr_finfo_t; +typedef struct fspr_finfo_t fspr_finfo_t; #define APR_FINFO_LINK 0x00000001 /**< Stat the link not the file itself if it is a link */ #define APR_FINFO_MTIME 0x00000010 /**< Modification Time */ @@ -170,52 +170,52 @@ typedef struct apr_finfo_t apr_finfo_t; #define APR_FINFO_IDENT 0x00003000 /**< dev and inode */ #define APR_FINFO_OWNER 0x00030000 /**< user and group */ #define APR_FINFO_PROT 0x00700000 /**< all protections */ -#define APR_FINFO_NORM 0x0073b170 /**< an atomic unix apr_stat() */ -#define APR_FINFO_DIRENT 0x02000000 /**< an atomic unix apr_dir_read() */ +#define APR_FINFO_NORM 0x0073b170 /**< an atomic unix fspr_stat() */ +#define APR_FINFO_DIRENT 0x02000000 /**< an atomic unix fspr_dir_read() */ /** * The file information structure. This is analogous to the POSIX * stat structure. */ -struct apr_finfo_t { +struct fspr_finfo_t { /** Allocates memory and closes lingering handles in the specified pool */ - apr_pool_t *pool; - /** The bitmask describing valid fields of this apr_finfo_t structure + fspr_pool_t *pool; + /** The bitmask describing valid fields of this fspr_finfo_t structure * including all available 'wanted' fields and potentially more */ - apr_int32_t valid; + fspr_int32_t valid; /** The access permissions of the file. Mimics Unix access rights. */ - apr_fileperms_t protection; + fspr_fileperms_t protection; /** The type of file. One of APR_REG, APR_DIR, APR_CHR, APR_BLK, APR_PIPE, * APR_LNK or APR_SOCK. If the type is undetermined, the value is APR_NOFILE. * If the type cannot be determined, the value is APR_UNKFILE. */ - apr_filetype_e filetype; + fspr_filetype_e filetype; /** The user id that owns the file */ - apr_uid_t user; + fspr_uid_t user; /** The group id that owns the file */ - apr_gid_t group; + fspr_gid_t group; /** The inode of the file. */ - apr_ino_t inode; + fspr_ino_t inode; /** The id of the device the file is on. */ - apr_dev_t device; + fspr_dev_t device; /** The number of hard links to the file. */ - apr_int32_t nlink; + fspr_int32_t nlink; /** The size of the file */ - apr_off_t size; + fspr_off_t size; /** The storage size consumed by the file */ - apr_off_t csize; + fspr_off_t csize; /** The time the file was last accessed */ - apr_time_t atime; + fspr_time_t atime; /** The time the file was last modified */ - apr_time_t mtime; + fspr_time_t mtime; /** The time the file was created, or the inode was last changed */ - apr_time_t ctime; + fspr_time_t ctime; /** The pathname of the file (possibly unrooted) */ const char *fname; /** The file's name (no path) in filesystem case */ const char *name; - /** The file's handle, if accessed (can be submitted to apr_duphandle) */ - struct apr_file_t *filehand; + /** The file's handle, if accessed (can be submitted to fspr_duphandle) */ + struct fspr_file_t *filehand; }; /** @@ -224,7 +224,7 @@ struct apr_finfo_t { * @param finfo Where to store the information about the file, which is * never touched if the call fails. * @param fname The name of the file to stat. - * @param wanted The desired apr_finfo_t fields, as a bit flag of APR_FINFO_ + * @param wanted The desired fspr_finfo_t fields, as a bit flag of APR_FINFO_ values * @param pool the pool to use to allocate the new file. * @@ -232,12 +232,12 @@ struct apr_finfo_t { * not be filled in, and you need to check the @c finfo->valid bitmask * to verify that what you're looking for is there. */ -APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, const char *fname, - apr_int32_t wanted, apr_pool_t *pool); +APR_DECLARE(fspr_status_t) fspr_stat(fspr_finfo_t *finfo, const char *fname, + fspr_int32_t wanted, fspr_pool_t *pool); /** @} */ /** - * @defgroup apr_dir Directory Manipulation Functions + * @defgroup fspr_dir Directory Manipulation Functions * @{ */ @@ -247,58 +247,58 @@ APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, const char *fname, * @param dirname The full path to the directory (use / on all systems) * @param pool The pool to use. */ -APR_DECLARE(apr_status_t) apr_dir_open(apr_dir_t **new_dir, +APR_DECLARE(fspr_status_t) fspr_dir_open(fspr_dir_t **new_dir, const char *dirname, - apr_pool_t *pool); + fspr_pool_t *pool); /** * close the specified directory. * @param thedir the directory descriptor to close. */ -APR_DECLARE(apr_status_t) apr_dir_close(apr_dir_t *thedir); +APR_DECLARE(fspr_status_t) fspr_dir_close(fspr_dir_t *thedir); /** * Read the next entry from the specified directory. - * @param finfo the file info structure and filled in by apr_dir_read - * @param wanted The desired apr_finfo_t fields, as a bit flag of APR_FINFO_ + * @param finfo the file info structure and filled in by fspr_dir_read + * @param wanted The desired fspr_finfo_t fields, as a bit flag of APR_FINFO_ values - * @param thedir the directory descriptor returned from apr_dir_open + * @param thedir the directory descriptor returned from fspr_dir_open * @remark No ordering is guaranteed for the entries read. * * @note If @c APR_INCOMPLETE is returned all the fields in @a finfo may * not be filled in, and you need to check the @c finfo->valid bitmask * to verify that what you're looking for is there. */ -APR_DECLARE(apr_status_t) apr_dir_read(apr_finfo_t *finfo, apr_int32_t wanted, - apr_dir_t *thedir); +APR_DECLARE(fspr_status_t) fspr_dir_read(fspr_finfo_t *finfo, fspr_int32_t wanted, + fspr_dir_t *thedir); /** * Rewind the directory to the first entry. * @param thedir the directory descriptor to rewind. */ -APR_DECLARE(apr_status_t) apr_dir_rewind(apr_dir_t *thedir); +APR_DECLARE(fspr_status_t) fspr_dir_rewind(fspr_dir_t *thedir); /** @} */ /** - * @defgroup apr_filepath Filepath Manipulation Functions + * @defgroup fspr_filepath Filepath Manipulation Functions * @{ */ -/** Cause apr_filepath_merge to fail if addpath is above rootpath */ +/** Cause fspr_filepath_merge to fail if addpath is above rootpath */ #define APR_FILEPATH_NOTABOVEROOT 0x01 /** internal: Only meaningful with APR_FILEPATH_NOTABOVEROOT */ #define APR_FILEPATH_SECUREROOTTEST 0x02 -/** Cause apr_filepath_merge to fail if addpath is above rootpath, +/** Cause fspr_filepath_merge to fail if addpath is above rootpath, * even given a rootpath /foo/bar and an addpath ../bar/bash */ #define APR_FILEPATH_SECUREROOT 0x03 -/** Fail apr_filepath_merge if the merged path is relative */ +/** Fail fspr_filepath_merge if the merged path is relative */ #define APR_FILEPATH_NOTRELATIVE 0x04 -/** Fail apr_filepath_merge if the merged path is absolute */ +/** Fail fspr_filepath_merge if the merged path is absolute */ #define APR_FILEPATH_NOTABSOLUTE 0x08 /** Return the file system's native path format (e.g. path delimiters @@ -334,10 +334,10 @@ APR_DECLARE(apr_status_t) apr_dir_rewind(apr_dir_t *thedir); * the drive letter), or APR_EBADPATH if the root is simply invalid. * APR_SUCCESS is returned if filepath is an absolute path. */ -APR_DECLARE(apr_status_t) apr_filepath_root(const char **rootpath, +APR_DECLARE(fspr_status_t) fspr_filepath_root(const char **rootpath, const char **filepath, - apr_int32_t flags, - apr_pool_t *p); + fspr_int32_t flags, + fspr_pool_t *p); /** * Merge additional file path onto the previously processed rootpath @@ -352,11 +352,11 @@ APR_DECLARE(apr_status_t) apr_filepath_root(const char **rootpath, * result code will be APR_EPATHWILD, and all further segments will not * reflect the true filenames including the wildcard and following segments. */ -APR_DECLARE(apr_status_t) apr_filepath_merge(char **newpath, +APR_DECLARE(fspr_status_t) fspr_filepath_merge(char **newpath, const char *rootpath, const char *addpath, - apr_int32_t flags, - apr_pool_t *p); + fspr_int32_t flags, + fspr_pool_t *p); /** * Split a search path into separate components @@ -367,9 +367,9 @@ APR_DECLARE(apr_status_t) apr_filepath_merge(char **newpath, * @remark the path separator in @a liststr is system specific; * e.g., ':' on Unix, ';' on Windows, etc. */ -APR_DECLARE(apr_status_t) apr_filepath_list_split(apr_array_header_t **pathelts, +APR_DECLARE(fspr_status_t) fspr_filepath_list_split(fspr_array_header_t **pathelts, const char *liststr, - apr_pool_t *p); + fspr_pool_t *p); /** * Merge a list of search path components into a single search path @@ -380,9 +380,9 @@ APR_DECLARE(apr_status_t) apr_filepath_list_split(apr_array_header_t **pathelts, * @remark the path separator in @a liststr is system specific; * e.g., ':' on Unix, ';' on Windows, etc. */ -APR_DECLARE(apr_status_t) apr_filepath_list_merge(char **liststr, - apr_array_header_t *pathelts, - apr_pool_t *p); +APR_DECLARE(fspr_status_t) fspr_filepath_list_merge(char **liststr, + fspr_array_header_t *pathelts, + fspr_pool_t *p); /** * Return the default file path (for relative file names) @@ -391,15 +391,15 @@ APR_DECLARE(apr_status_t) apr_filepath_list_merge(char **liststr, * default file path in os-native format. * @param p the pool to allocate the default path string from */ -APR_DECLARE(apr_status_t) apr_filepath_get(char **path, apr_int32_t flags, - apr_pool_t *p); +APR_DECLARE(fspr_status_t) fspr_filepath_get(char **path, fspr_int32_t flags, + fspr_pool_t *p); /** * Set the default file path (for relative file names) * @param path the default path returned * @param p the pool to allocate any working storage */ -APR_DECLARE(apr_status_t) apr_filepath_set(const char *path, apr_pool_t *p); +APR_DECLARE(fspr_status_t) fspr_filepath_set(const char *path, fspr_pool_t *p); /** The FilePath character encoding is unknown */ #define APR_FILEPATH_ENCODING_UNKNOWN 0 @@ -414,10 +414,10 @@ APR_DECLARE(apr_status_t) apr_filepath_set(const char *path, apr_pool_t *p); * Determine the encoding used internally by the FilePath functions * @param style points to a variable which receives the encoding style flag * @param p the pool to allocate any working storage - * @remark Use @c apr_os_locale_encoding and/or @c apr_os_default_encoding + * @remark Use @c fspr_os_locale_encoding and/or @c fspr_os_default_encoding * to get the name of the path encoding if it's not UTF-8. */ -APR_DECLARE(apr_status_t) apr_filepath_encoding(int *style, apr_pool_t *p); +APR_DECLARE(fspr_status_t) fspr_filepath_encoding(int *style, fspr_pool_t *p); /** @} */ /** @} */ diff --git a/libs/apr/include/apr_file_io.h b/libs/apr/include/fspr_file_io.h similarity index 72% rename from libs/apr/include/apr_file_io.h rename to libs/apr/include/fspr_file_io.h index b8146eea65..d19901e2b8 100644 --- a/libs/apr/include/apr_file_io.h +++ b/libs/apr/include/fspr_file_io.h @@ -18,33 +18,33 @@ #define APR_FILE_IO_H /** - * @file apr_file_io.h + * @file fspr_file_io.h * @brief APR File I/O Handling */ -#include "apr.h" -#include "apr_pools.h" -#include "apr_time.h" -#include "apr_errno.h" -#include "apr_file_info.h" -#include "apr_inherit.h" +#include "fspr.h" +#include "fspr_pools.h" +#include "fspr_time.h" +#include "fspr_errno.h" +#include "fspr_file_info.h" +#include "fspr_inherit.h" #define APR_WANT_STDIO /**< for SEEK_* */ -#define APR_WANT_IOVEC /**< for apr_file_writev */ -#include "apr_want.h" +#define APR_WANT_IOVEC /**< for fspr_file_writev */ +#include "fspr_want.h" #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** - * @defgroup apr_file_io File I/O Handling Functions + * @defgroup fspr_file_io File I/O Handling Functions * @ingroup APR * @{ */ /** - * @defgroup apr_file_open_flags File Open Flags/Routines + * @defgroup fspr_file_open_flags File Open Flags/Routines * @{ */ @@ -73,7 +73,7 @@ extern "C" { when the file is opened */ #define APR_FOPEN_SENDFILE_ENABLED 0x01000 /**< Advisory flag that this file should support - apr_socket_sendfile operation */ + fspr_socket_sendfile operation */ #define APR_FOPEN_LARGEFILE 0x04000 /**< Platform dependent flag to enable large file support; WARNING see below. */ @@ -94,12 +94,12 @@ extern "C" { #define APR_LARGEFILE APR_FOPEN_LARGEFILE /**< @deprecated @see APR_FOPEN_LARGEFILE */ /** @warning The APR_LARGEFILE flag only has effect on some platforms - * where sizeof(apr_off_t) == 4. Where implemented, it allows opening + * where sizeof(fspr_off_t) == 4. Where implemented, it allows opening * and writing to a file which exceeds the size which can be - * represented by apr_off_t (2 gigabytes). When a file's size does - * exceed 2Gb, apr_file_info_get() will fail with an error on the - * descriptor, likewise apr_stat()/apr_lstat() will fail on the - * filename. apr_dir_read() will fail with APR_INCOMPLETE on a + * represented by fspr_off_t (2 gigabytes). When a file's size does + * exceed 2Gb, fspr_file_info_get() will fail with an error on the + * descriptor, likewise fspr_stat()/fspr_lstat() will fail on the + * filename. fspr_dir_read() will fail with APR_INCOMPLETE on a * directory entry for a large file depending on the particular * APR_FINFO_* flags. Generally, it is not recommended to use this * flag. */ @@ -107,11 +107,11 @@ extern "C" { /** @} */ /** - * @defgroup apr_file_seek_flags File Seek Flags + * @defgroup fspr_file_seek_flags File Seek Flags * @{ */ -/* flags for apr_file_seek */ +/* flags for fspr_file_seek */ /** Set the file position */ #define APR_SET SEEK_SET /** Current */ @@ -121,18 +121,18 @@ extern "C" { /** @} */ /** - * @defgroup apr_file_attrs_set_flags File Attribute Flags + * @defgroup fspr_file_attrs_set_flags File Attribute Flags * @{ */ -/* flags for apr_file_attrs_set */ +/* flags for fspr_file_attrs_set */ #define APR_FILE_ATTR_READONLY 0x01 /**< File is read-only */ #define APR_FILE_ATTR_EXECUTABLE 0x02 /**< File is executable */ #define APR_FILE_ATTR_HIDDEN 0x04 /**< File is hidden */ /** @} */ /** - * @defgroup apr_file_writev{_full} max iovec size + * @defgroup fspr_file_writev{_full} max iovec size * @{ */ #if defined(DOXYGEN) @@ -148,19 +148,19 @@ extern "C" { /** @} */ /** File attributes */ -typedef apr_uint32_t apr_fileattrs_t; +typedef fspr_uint32_t fspr_fileattrs_t; -/** Type to pass as whence argument to apr_file_seek. */ -typedef int apr_seek_where_t; +/** Type to pass as whence argument to fspr_file_seek. */ +typedef int fspr_seek_where_t; /** * Structure for referencing files. */ -typedef struct apr_file_t apr_file_t; +typedef struct fspr_file_t fspr_file_t; /* File lock types/flags */ /** - * @defgroup apr_file_lock_types File Lock Types + * @defgroup fspr_file_lock_types File Lock Types * @{ */ @@ -203,29 +203,29 @@ typedef struct apr_file_t apr_file_t; * writes across process/machines * APR_FILE_NOCLEANUP Do not register a cleanup with the pool * passed in on the pool argument (see below). - * The apr_os_file_t handle in apr_file_t will not + * The fspr_os_file_t handle in fspr_file_t will not * be closed when the pool is destroyed. * APR_SENDFILE_ENABLED Open with appropriate platform semantics * for sendfile operations. Advisory only, - * apr_socket_sendfile does not check this flag. + * fspr_socket_sendfile does not check this flag. * * @param perm Access permissions for file. * @param pool The pool to use. * @remark If perm is APR_OS_DEFAULT and the file is being created, * appropriate default permissions will be used. * @remark By default, the returned file descriptor will not be - * inherited by child processes created by apr_proc_create(). This - * can be changed using apr_file_inherit_set(). + * inherited by child processes created by fspr_proc_create(). This + * can be changed using fspr_file_inherit_set(). */ -APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **newf, const char *fname, - apr_int32_t flag, apr_fileperms_t perm, - apr_pool_t *pool); +APR_DECLARE(fspr_status_t) fspr_file_open(fspr_file_t **newf, const char *fname, + fspr_int32_t flag, fspr_fileperms_t perm, + fspr_pool_t *pool); /** * Close the specified file. * @param file The file descriptor to close. */ -APR_DECLARE(apr_status_t) apr_file_close(apr_file_t *file); +APR_DECLARE(fspr_status_t) fspr_file_close(fspr_file_t *file); /** * Delete the specified file. @@ -234,7 +234,7 @@ APR_DECLARE(apr_status_t) apr_file_close(apr_file_t *file); * @remark If the file is open, it won't be removed until all * instances are closed. */ -APR_DECLARE(apr_status_t) apr_file_remove(const char *path, apr_pool_t *pool); +APR_DECLARE(fspr_status_t) fspr_file_remove(const char *path, fspr_pool_t *pool); /** * Rename the specified file. @@ -245,9 +245,9 @@ APR_DECLARE(apr_status_t) apr_file_remove(const char *path, apr_pool_t *pool); * overwritten. Moving files or directories across devices may not be * possible. */ -APR_DECLARE(apr_status_t) apr_file_rename(const char *from_path, +APR_DECLARE(fspr_status_t) fspr_file_rename(const char *from_path, const char *to_path, - apr_pool_t *pool); + fspr_pool_t *pool); /** * Copy the specified file to another file. @@ -261,10 +261,10 @@ APR_DECLARE(apr_status_t) apr_file_rename(const char *from_path, * @remark The new file does not need to exist, it will be created if required. * @warning If the new file already exists, its contents will be overwritten. */ -APR_DECLARE(apr_status_t) apr_file_copy(const char *from_path, +APR_DECLARE(fspr_status_t) fspr_file_copy(const char *from_path, const char *to_path, - apr_fileperms_t perms, - apr_pool_t *pool); + fspr_fileperms_t perms, + fspr_pool_t *pool); /** * Append the specified file to another file. @@ -277,55 +277,55 @@ APR_DECLARE(apr_status_t) apr_file_copy(const char *from_path, * @param pool The pool to use. * @remark The new file does not need to exist, it will be created if required. */ -APR_DECLARE(apr_status_t) apr_file_append(const char *from_path, +APR_DECLARE(fspr_status_t) fspr_file_append(const char *from_path, const char *to_path, - apr_fileperms_t perms, - apr_pool_t *pool); + fspr_fileperms_t perms, + fspr_pool_t *pool); /** * Are we at the end of the file * @param fptr The apr file we are testing. * @remark Returns APR_EOF if we are at the end of file, APR_SUCCESS otherwise. */ -APR_DECLARE(apr_status_t) apr_file_eof(apr_file_t *fptr); +APR_DECLARE(fspr_status_t) fspr_file_eof(fspr_file_t *fptr); /** * Open standard error as an apr file pointer. * @param thefile The apr file to use as stderr. * @param pool The pool to allocate the file out of. * - * @remark The only reason that the apr_file_open_std* functions exist + * @remark The only reason that the fspr_file_open_std* functions exist * is that you may not always have a stderr/out/in on Windows. This * is generally a problem with newer versions of Windows and services. * * @remark The other problem is that the C library functions generally work - * differently on Windows and Unix. So, by using apr_file_open_std* + * differently on Windows and Unix. So, by using fspr_file_open_std* * functions, you can get a handle to an APR struct that works with * the APR functions which are supposed to work identically on all * platforms. */ -APR_DECLARE(apr_status_t) apr_file_open_stderr(apr_file_t **thefile, - apr_pool_t *pool); +APR_DECLARE(fspr_status_t) fspr_file_open_stderr(fspr_file_t **thefile, + fspr_pool_t *pool); /** * open standard output as an apr file pointer. * @param thefile The apr file to use as stdout. * @param pool The pool to allocate the file out of. * - * @remark See remarks for apr_file_open_stdout. + * @remark See remarks for fspr_file_open_stdout. */ -APR_DECLARE(apr_status_t) apr_file_open_stdout(apr_file_t **thefile, - apr_pool_t *pool); +APR_DECLARE(fspr_status_t) fspr_file_open_stdout(fspr_file_t **thefile, + fspr_pool_t *pool); /** * open standard input as an apr file pointer. * @param thefile The apr file to use as stdin. * @param pool The pool to allocate the file out of. * - * @remark See remarks for apr_file_open_stdout. + * @remark See remarks for fspr_file_open_stdout. */ -APR_DECLARE(apr_status_t) apr_file_open_stdin(apr_file_t **thefile, - apr_pool_t *pool); +APR_DECLARE(fspr_status_t) fspr_file_open_stdin(fspr_file_t **thefile, + fspr_pool_t *pool); /** * Read data from the specified file. @@ -334,7 +334,7 @@ APR_DECLARE(apr_status_t) apr_file_open_stdin(apr_file_t **thefile, * @param nbytes On entry, the number of bytes to read; on exit, the number * of bytes read. * - * @remark apr_file_read will read up to the specified number of + * @remark fspr_file_read will read up to the specified number of * bytes, but never more. If there isn't enough data to fill that * number of bytes, all of the available data is read. The third * argument is modified to reflect the number of bytes read. If a @@ -344,8 +344,8 @@ APR_DECLARE(apr_status_t) apr_file_open_stdin(apr_file_t **thefile, * @remark It is not possible for both bytes to be read and an APR_EOF * or other error to be returned. APR_EINTR is never returned. */ -APR_DECLARE(apr_status_t) apr_file_read(apr_file_t *thefile, void *buf, - apr_size_t *nbytes); +APR_DECLARE(fspr_status_t) fspr_file_read(fspr_file_t *thefile, void *buf, + fspr_size_t *nbytes); /** * Write data to the specified file. @@ -354,7 +354,7 @@ APR_DECLARE(apr_status_t) apr_file_read(apr_file_t *thefile, void *buf, * @param nbytes On entry, the number of bytes to write; on exit, the number * of bytes written. * - * @remark apr_file_write will write up to the specified number of + * @remark fspr_file_write will write up to the specified number of * bytes, but never more. If the OS cannot write that many bytes, it * will write as many as it can. The third argument is modified to * reflect the * number of bytes written. @@ -362,8 +362,8 @@ APR_DECLARE(apr_status_t) apr_file_read(apr_file_t *thefile, void *buf, * @remark It is possible for both bytes to be written and an error to * be returned. APR_EINTR is never returned. */ -APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, - apr_size_t *nbytes); +APR_DECLARE(fspr_status_t) fspr_file_write(fspr_file_t *thefile, const void *buf, + fspr_size_t *nbytes); /** * Write data from iovec array to the specified file. @@ -377,12 +377,12 @@ APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, * @remark It is possible for both bytes to be written and an error to * be returned. APR_EINTR is never returned. * - * @remark apr_file_writev is available even if the underlying + * @remark fspr_file_writev is available even if the underlying * operating system doesn't provide writev(). */ -APR_DECLARE(apr_status_t) apr_file_writev(apr_file_t *thefile, +APR_DECLARE(fspr_status_t) fspr_file_writev(fspr_file_t *thefile, const struct iovec *vec, - apr_size_t nvec, apr_size_t *nbytes); + fspr_size_t nvec, fspr_size_t *nbytes); /** * Read data from the specified file, ensuring that the buffer is filled @@ -392,7 +392,7 @@ APR_DECLARE(apr_status_t) apr_file_writev(apr_file_t *thefile, * @param nbytes The number of bytes to read. * @param bytes_read If non-NULL, this will contain the number of bytes read. * - * @remark apr_file_read will read up to the specified number of + * @remark fspr_file_read will read up to the specified number of * bytes, but never more. If there isn't enough data to fill that * number of bytes, then the process/thread will block until it is * available or EOF is reached. If a char was put back into the @@ -404,9 +404,9 @@ APR_DECLARE(apr_status_t) apr_file_writev(apr_file_t *thefile, * * @remark APR_EINTR is never returned. */ -APR_DECLARE(apr_status_t) apr_file_read_full(apr_file_t *thefile, void *buf, - apr_size_t nbytes, - apr_size_t *bytes_read); +APR_DECLARE(fspr_status_t) fspr_file_read_full(fspr_file_t *thefile, void *buf, + fspr_size_t nbytes, + fspr_size_t *bytes_read); /** * Write data to the specified file, ensuring that all of the data is @@ -416,7 +416,7 @@ APR_DECLARE(apr_status_t) apr_file_read_full(apr_file_t *thefile, void *buf, * @param nbytes The number of bytes to write. * @param bytes_written If non-NULL, set to the number of bytes written. * - * @remark apr_file_write will write up to the specified number of + * @remark fspr_file_write will write up to the specified number of * bytes, but never more. If the OS cannot write that many bytes, the * process/thread will block until they can be written. Exceptional * error such as "out of space" or "pipe closed" will terminate with @@ -428,10 +428,10 @@ APR_DECLARE(apr_status_t) apr_file_read_full(apr_file_t *thefile, void *buf, * * @remark APR_EINTR is never returned. */ -APR_DECLARE(apr_status_t) apr_file_write_full(apr_file_t *thefile, +APR_DECLARE(fspr_status_t) fspr_file_write_full(fspr_file_t *thefile, const void *buf, - apr_size_t nbytes, - apr_size_t *bytes_written); + fspr_size_t nbytes, + fspr_size_t *bytes_written); /** @@ -444,33 +444,33 @@ APR_DECLARE(apr_status_t) apr_file_write_full(apr_file_t *thefile, * will fail with APR_EINVAL. * @param nbytes The number of bytes written. * - * @remark apr_file_writev_full is available even if the underlying + * @remark fspr_file_writev_full is available even if the underlying * operating system doesn't provide writev(). */ -APR_DECLARE(apr_status_t) apr_file_writev_full(apr_file_t *thefile, +APR_DECLARE(fspr_status_t) fspr_file_writev_full(fspr_file_t *thefile, const struct iovec *vec, - apr_size_t nvec, - apr_size_t *nbytes); + fspr_size_t nvec, + fspr_size_t *nbytes); /** * Write a character into the specified file. * @param ch The character to write. * @param thefile The file descriptor to write to */ -APR_DECLARE(apr_status_t) apr_file_putc(char ch, apr_file_t *thefile); +APR_DECLARE(fspr_status_t) fspr_file_putc(char ch, fspr_file_t *thefile); /** * Read a character from the specified file. * @param ch The character to read into * @param thefile The file descriptor to read from */ -APR_DECLARE(apr_status_t) apr_file_getc(char *ch, apr_file_t *thefile); +APR_DECLARE(fspr_status_t) fspr_file_getc(char *ch, fspr_file_t *thefile); /** * Put a character back onto a specified stream. * @param ch The character to write. * @param thefile The file descriptor to write to */ -APR_DECLARE(apr_status_t) apr_file_ungetc(char ch, apr_file_t *thefile); +APR_DECLARE(fspr_status_t) fspr_file_ungetc(char ch, fspr_file_t *thefile); /** * Read a string from the specified file. @@ -479,32 +479,32 @@ APR_DECLARE(apr_status_t) apr_file_ungetc(char ch, apr_file_t *thefile); * @param thefile The file descriptor to read from * @remark The buffer will be NUL-terminated if any characters are stored. */ -APR_DECLARE(apr_status_t) apr_file_gets(char *str, int len, - apr_file_t *thefile); +APR_DECLARE(fspr_status_t) fspr_file_gets(char *str, int len, + fspr_file_t *thefile); /** * Write the string into the specified file. * @param str The string to write. * @param thefile The file descriptor to write to */ -APR_DECLARE(apr_status_t) apr_file_puts(const char *str, apr_file_t *thefile); +APR_DECLARE(fspr_status_t) fspr_file_puts(const char *str, fspr_file_t *thefile); /** * Flush the file's buffer. * @param thefile The file descriptor to flush */ -APR_DECLARE(apr_status_t) apr_file_flush(apr_file_t *thefile); +APR_DECLARE(fspr_status_t) fspr_file_flush(fspr_file_t *thefile); /** * Duplicate the specified file descriptor. * @param new_file The structure to duplicate into. * @param old_file The file to duplicate. * @param p The pool to use for the new file. - * @remark *new_file must point to a valid apr_file_t, or point to NULL. + * @remark *new_file must point to a valid fspr_file_t, or point to NULL. */ -APR_DECLARE(apr_status_t) apr_file_dup(apr_file_t **new_file, - apr_file_t *old_file, - apr_pool_t *p); +APR_DECLARE(fspr_status_t) fspr_file_dup(fspr_file_t **new_file, + fspr_file_t *old_file, + fspr_pool_t *p); /** * Duplicate the specified file descriptor and close the original @@ -512,26 +512,26 @@ APR_DECLARE(apr_status_t) apr_file_dup(apr_file_t **new_file, * @param old_file The file to duplicate * @param p The pool to use for the new file * - * @remark new_file MUST point at a valid apr_file_t. It cannot be NULL. + * @remark new_file MUST point at a valid fspr_file_t. It cannot be NULL. */ -APR_DECLARE(apr_status_t) apr_file_dup2(apr_file_t *new_file, - apr_file_t *old_file, - apr_pool_t *p); +APR_DECLARE(fspr_status_t) fspr_file_dup2(fspr_file_t *new_file, + fspr_file_t *old_file, + fspr_pool_t *p); /** * Move the specified file descriptor to a new pool - * @param new_file Pointer in which to return the new apr_file_t + * @param new_file Pointer in which to return the new fspr_file_t * @param old_file The file to move * @param p The pool to which the descriptor is to be moved - * @remark Unlike apr_file_dup2(), this function doesn't do an + * @remark Unlike fspr_file_dup2(), this function doesn't do an * OS dup() operation on the underlying descriptor; it just - * moves the descriptor's apr_file_t wrapper to a new pool. + * moves the descriptor's fspr_file_t wrapper to a new pool. * @remark The new pool need not be an ancestor of old_file's pool. * @remark After calling this function, old_file may not be used */ -APR_DECLARE(apr_status_t) apr_file_setaside(apr_file_t **new_file, - apr_file_t *old_file, - apr_pool_t *p); +APR_DECLARE(fspr_status_t) fspr_file_setaside(fspr_file_t **new_file, + fspr_file_t *old_file, + fspr_pool_t *p); /** * Move the read/write file offset to a specified byte within a file. @@ -546,9 +546,9 @@ APR_DECLARE(apr_status_t) apr_file_setaside(apr_file_t **new_file, * @remark The third argument is modified to be the offset the pointer was actually moved to. */ -APR_DECLARE(apr_status_t) apr_file_seek(apr_file_t *thefile, - apr_seek_where_t where, - apr_off_t *offset); +APR_DECLARE(fspr_status_t) fspr_file_seek(fspr_file_t *thefile, + fspr_seek_where_t where, + fspr_off_t *offset); /** * Create an anonymous pipe. @@ -556,12 +556,12 @@ APR_DECLARE(apr_status_t) apr_file_seek(apr_file_t *thefile, * @param out The file descriptor to use as output from the pipe. * @param pool The pool to operate on. * @remark By default, the returned file descriptors will be inherited - * by child processes created using apr_proc_create(). This can be - * changed using apr_file_inherit_unset(). + * by child processes created using fspr_proc_create(). This can be + * changed using fspr_file_inherit_unset(). */ -APR_DECLARE(apr_status_t) apr_file_pipe_create(apr_file_t **in, - apr_file_t **out, - apr_pool_t *pool); +APR_DECLARE(fspr_status_t) fspr_file_pipe_create(fspr_file_t **in, + fspr_file_t **out, + fspr_pool_t *pool); /** * Create a named pipe. @@ -569,17 +569,17 @@ APR_DECLARE(apr_status_t) apr_file_pipe_create(apr_file_t **in, * @param perm The permissions for the newly created pipe. * @param pool The pool to operate on. */ -APR_DECLARE(apr_status_t) apr_file_namedpipe_create(const char *filename, - apr_fileperms_t perm, - apr_pool_t *pool); +APR_DECLARE(fspr_status_t) fspr_file_namedpipe_create(const char *filename, + fspr_fileperms_t perm, + fspr_pool_t *pool); /** * Get the timeout value for a pipe or manipulate the blocking state. * @param thepipe The pipe we are getting a timeout for. * @param timeout The current timeout value in microseconds. */ -APR_DECLARE(apr_status_t) apr_file_pipe_timeout_get(apr_file_t *thepipe, - apr_interval_time_t *timeout); +APR_DECLARE(fspr_status_t) fspr_file_pipe_timeout_get(fspr_file_t *thepipe, + fspr_interval_time_t *timeout); /** * Set the timeout value for a pipe or manipulate the blocking state. @@ -587,8 +587,8 @@ APR_DECLARE(apr_status_t) apr_file_pipe_timeout_get(apr_file_t *thepipe, * @param timeout The timeout value in microseconds. Values < 0 mean wait * forever, 0 means do not wait at all. */ -APR_DECLARE(apr_status_t) apr_file_pipe_timeout_set(apr_file_t *thepipe, - apr_interval_time_t timeout); +APR_DECLARE(fspr_status_t) fspr_file_pipe_timeout_set(fspr_file_t *thepipe, + fspr_interval_time_t timeout); /** file (un)locking functions. */ @@ -601,13 +601,13 @@ APR_DECLARE(apr_status_t) apr_file_pipe_timeout_set(apr_file_t *thepipe, * @param thefile The file to lock. * @param type The type of lock to establish on the file. */ -APR_DECLARE(apr_status_t) apr_file_lock(apr_file_t *thefile, int type); +APR_DECLARE(fspr_status_t) fspr_file_lock(fspr_file_t *thefile, int type); /** * Remove any outstanding locks on the file. * @param thefile The file to unlock. */ -APR_DECLARE(apr_status_t) apr_file_unlock(apr_file_t *thefile); +APR_DECLARE(fspr_status_t) fspr_file_unlock(fspr_file_t *thefile); /**accessor and general file_io functions. */ @@ -616,8 +616,8 @@ APR_DECLARE(apr_status_t) apr_file_unlock(apr_file_t *thefile); * @param new_path The path of the file. * @param thefile The currently open file. */ -APR_DECLARE(apr_status_t) apr_file_name_get(const char **new_path, - apr_file_t *thefile); +APR_DECLARE(fspr_status_t) fspr_file_name_get(const char **new_path, + fspr_file_t *thefile); /** * Return the data associated with the current file. @@ -625,8 +625,8 @@ APR_DECLARE(apr_status_t) apr_file_name_get(const char **new_path, * @param key The key to use for retreiving data associated with this file. * @param file The currently open file. */ -APR_DECLARE(apr_status_t) apr_file_data_get(void **data, const char *key, - apr_file_t *file); +APR_DECLARE(fspr_status_t) fspr_file_data_get(void **data, const char *key, + fspr_file_t *file); /** * Set the data associated with the current file. @@ -635,9 +635,9 @@ APR_DECLARE(apr_status_t) apr_file_data_get(void **data, const char *key, * @param key The key to use for assocaiteing data with the file. * @param cleanup The cleanup routine to use when the file is destroyed. */ -APR_DECLARE(apr_status_t) apr_file_data_set(apr_file_t *file, void *data, +APR_DECLARE(fspr_status_t) fspr_file_data_set(fspr_file_t *file, void *data, const char *key, - apr_status_t (*cleanup)(void *)); + fspr_status_t (*cleanup)(void *)); /** * Write a string to a file using a printf format. @@ -646,7 +646,7 @@ APR_DECLARE(apr_status_t) apr_file_data_set(apr_file_t *file, void *data, * @param ... The values to substitute in the format string * @return The number of bytes written */ -APR_DECLARE_NONSTD(int) apr_file_printf(apr_file_t *fptr, +APR_DECLARE_NONSTD(int) fspr_file_printf(fspr_file_t *fptr, const char *format, ...) __attribute__((format(printf,2,3))); @@ -662,8 +662,8 @@ APR_DECLARE_NONSTD(int) apr_file_printf(apr_file_t *fptr, * @warning Platforms which do not implement this feature will return * APR_ENOTIMPL. */ -APR_DECLARE(apr_status_t) apr_file_perms_set(const char *fname, - apr_fileperms_t perms); +APR_DECLARE(fspr_status_t) fspr_file_perms_set(const char *fname, + fspr_fileperms_t perms); /** * Set attributes of the specified file. @@ -683,10 +683,10 @@ APR_DECLARE(apr_status_t) apr_file_perms_set(const char *fname, * @warning Platforms which do not implement this feature will return * APR_ENOTIMPL. */ -APR_DECLARE(apr_status_t) apr_file_attrs_set(const char *fname, - apr_fileattrs_t attributes, - apr_fileattrs_t attr_mask, - apr_pool_t *pool); +APR_DECLARE(fspr_status_t) fspr_file_attrs_set(const char *fname, + fspr_fileattrs_t attributes, + fspr_fileattrs_t attr_mask, + fspr_pool_t *pool); /** * Set the mtime of the specified file. @@ -696,9 +696,9 @@ APR_DECLARE(apr_status_t) apr_file_attrs_set(const char *fname, * @warning Platforms which do not implement this feature will return * APR_ENOTIMPL. */ -APR_DECLARE(apr_status_t) apr_file_mtime_set(const char *fname, - apr_time_t mtime, - apr_pool_t *pool); +APR_DECLARE(fspr_status_t) fspr_file_mtime_set(const char *fname, + fspr_time_t mtime, + fspr_pool_t *pool); /** * Create a new directory on the file system. @@ -706,8 +706,8 @@ APR_DECLARE(apr_status_t) apr_file_mtime_set(const char *fname, * @param perm Permissions for the new direcoty. * @param pool the pool to use. */ -APR_DECLARE(apr_status_t) apr_dir_make(const char *path, apr_fileperms_t perm, - apr_pool_t *pool); +APR_DECLARE(fspr_status_t) fspr_dir_make(const char *path, fspr_fileperms_t perm, + fspr_pool_t *pool); /** Creates a new directory on the file system, but behaves like * 'mkdir -p'. Creates intermediate directories as required. No error @@ -716,26 +716,26 @@ APR_DECLARE(apr_status_t) apr_dir_make(const char *path, apr_fileperms_t perm, * @param perm Permissions for the new direcoty. * @param pool the pool to use. */ -APR_DECLARE(apr_status_t) apr_dir_make_recursive(const char *path, - apr_fileperms_t perm, - apr_pool_t *pool); +APR_DECLARE(fspr_status_t) fspr_dir_make_recursive(const char *path, + fspr_fileperms_t perm, + fspr_pool_t *pool); /** * Remove directory from the file system. * @param path the path for the directory to be removed. (use / on all systems) * @param pool the pool to use. */ -APR_DECLARE(apr_status_t) apr_dir_remove(const char *path, apr_pool_t *pool); +APR_DECLARE(fspr_status_t) fspr_dir_remove(const char *path, fspr_pool_t *pool); /** * get the specified file's stats. * @param finfo Where to store the information about the file. - * @param wanted The desired apr_finfo_t fields, as a bit flag of APR_FINFO_ values + * @param wanted The desired fspr_finfo_t fields, as a bit flag of APR_FINFO_ values * @param thefile The file to get information about. */ -APR_DECLARE(apr_status_t) apr_file_info_get(apr_finfo_t *finfo, - apr_int32_t wanted, - apr_file_t *thefile); +APR_DECLARE(fspr_status_t) fspr_file_info_get(fspr_finfo_t *finfo, + fspr_int32_t wanted, + fspr_file_t *thefile); /** @@ -743,14 +743,14 @@ APR_DECLARE(apr_status_t) apr_file_info_get(apr_finfo_t *finfo, * @param fp The file to truncate * @param offset The offset to truncate to. */ -APR_DECLARE(apr_status_t) apr_file_trunc(apr_file_t *fp, apr_off_t offset); +APR_DECLARE(fspr_status_t) fspr_file_trunc(fspr_file_t *fp, fspr_off_t offset); /** - * Retrieve the flags that were passed into apr_file_open() + * Retrieve the flags that were passed into fspr_file_open() * when the file was opened. - * @return apr_int32_t the flags + * @return fspr_int32_t the flags */ -APR_DECLARE(apr_int32_t) apr_file_flags_get(apr_file_t *f); +APR_DECLARE(fspr_int32_t) fspr_file_flags_get(fspr_file_t *f); /** * Get the pool used by the file. @@ -784,8 +784,8 @@ APR_DECLARE_INHERIT_UNSET(file); * array. * */ -APR_DECLARE(apr_status_t) apr_file_mktemp(apr_file_t **fp, char *templ, - apr_int32_t flags, apr_pool_t *p); +APR_DECLARE(fspr_status_t) fspr_file_mktemp(fspr_file_t **fp, char *templ, + fspr_int32_t flags, fspr_pool_t *p); /** @@ -800,8 +800,8 @@ APR_DECLARE(apr_status_t) apr_file_mktemp(apr_file_t **fp, char *templ, * is successful. * */ -APR_DECLARE(apr_status_t) apr_temp_dir_get(const char **temp_dir, - apr_pool_t *p); +APR_DECLARE(fspr_status_t) fspr_temp_dir_get(const char **temp_dir, + fspr_pool_t *p); /** @} */ diff --git a/libs/apr/include/apr_fnmatch.h b/libs/apr/include/fspr_fnmatch.h similarity index 89% rename from libs/apr/include/apr_fnmatch.h rename to libs/apr/include/fspr_fnmatch.h index 7a2811aac8..18c0f138d7 100644 --- a/libs/apr/include/apr_fnmatch.h +++ b/libs/apr/include/fspr_fnmatch.h @@ -38,19 +38,19 @@ #define _APR_FNMATCH_H_ /** - * @file apr_fnmatch.h + * @file fspr_fnmatch.h * @brief APR FNMatch Functions */ -#include "apr_errno.h" -#include "apr_tables.h" +#include "fspr_errno.h" +#include "fspr_tables.h" #ifdef __cplusplus extern "C" { #endif /** - * @defgroup apr_fnmatch Filename Matching Functions + * @defgroup fspr_fnmatch Filename Matching Functions * @ingroup APR * @{ */ @@ -78,7 +78,7 @@ extern "C" { * */ -APR_DECLARE(apr_status_t) apr_fnmatch(const char *pattern, +APR_DECLARE(fspr_status_t) fspr_fnmatch(const char *pattern, const char *strings, int flags); /** @@ -86,7 +86,7 @@ APR_DECLARE(apr_status_t) apr_fnmatch(const char *pattern, * @param pattern The pattern to search for glob characters. * @return non-zero if pattern has any glob characters in it */ -APR_DECLARE(int) apr_fnmatch_test(const char *pattern); +APR_DECLARE(int) fspr_fnmatch_test(const char *pattern); /** * Find all files that match a specified pattern. @@ -95,9 +95,9 @@ APR_DECLARE(int) apr_fnmatch_test(const char *pattern); * @param p The pool to use. * @return non-zero if pattern has any glob characters in it */ -APR_DECLARE(apr_status_t) apr_match_glob(const char *pattern, - apr_array_header_t **result, - apr_pool_t *p); +APR_DECLARE(fspr_status_t) fspr_match_glob(const char *pattern, + fspr_array_header_t **result, + fspr_pool_t *p); /** @} */ diff --git a/libs/apr/include/apr_general.h b/libs/apr/include/fspr_general.h similarity index 78% rename from libs/apr/include/apr_general.h rename to libs/apr/include/fspr_general.h index 42eec83ce4..e2261228c0 100644 --- a/libs/apr/include/apr_general.h +++ b/libs/apr/include/fspr_general.h @@ -18,16 +18,20 @@ #define APR_GENERAL_H /** - * @file apr_general.h + * @file fspr_general.h * This is collection of oddballs that didn't fit anywhere else, * and might move to more appropriate headers with the release * of APR 1.0. * @brief APR Miscellaneous library routines */ -#include "apr.h" -#include "apr_pools.h" -#include "apr_errno.h" +#include "fspr.h" +#include "fspr_pools.h" +#include "fspr_errno.h" + +#if !defined(NSIG) && !defined(_ANSI_SOURCE) && defined(_DARWIN_C_SOURCE) +#define NSIG __DARWIN_NSIG +#endif #if APR_HAVE_SIGNAL_H #include @@ -38,7 +42,7 @@ extern "C" { #endif /* __cplusplus */ /** - * @defgroup apr_general Miscellaneous library routines + * @defgroup fspr_general Miscellaneous library routines * @ingroup APR * This is collection of oddballs that didn't fit anywhere else, * and might move to more appropriate headers with the release @@ -65,7 +69,7 @@ extern "C" { #define APR_ASCII_TAB '\011' /** signal numbers typedef */ -typedef int apr_signum_t; +typedef int fspr_signum_t; /** * Finding offsets of elements within structures. @@ -144,7 +148,7 @@ int strncasecmp(const char *a, const char *b, size_t n); * String and memory functions */ -/* APR_STRINGIFY is defined here, and also in apr_release.h, so wrap it */ +/* APR_STRINGIFY is defined here, and also in fspr_release.h, so wrap it */ #ifndef APR_STRINGIFY /** Properly quote a value as a string in the C preprocessor */ #define APR_STRINGIFY(n) APR_STRINGIFY_HELPER(n) @@ -163,17 +167,17 @@ void *memchr(const void *s, int c, size_t n); /** @} */ /** - * @defgroup apr_library Library initialization and termination + * @defgroup fspr_library Library initialization and termination * @{ */ /** * Setup any APR internal data structures. This MUST be the first function * called for any APR library. - * @remark See apr_app_initialize if this is an application, rather than + * @remark See fspr_app_initialize if this is an application, rather than * a library consumer of apr. */ -APR_DECLARE(apr_status_t) apr_initialize(void); +APR_DECLARE(fspr_status_t) fspr_initialize(void); /** * Set up an application with normalized argc, argv (and optionally env) in @@ -183,11 +187,11 @@ APR_DECLARE(apr_status_t) apr_initialize(void); * @param argc Pointer to the argc that may be corrected * @param argv Pointer to the argv that may be corrected * @param env Pointer to the env that may be corrected, may be NULL - * @remark See apr_initialize if this is a library consumer of apr. - * Otherwise, this call is identical to apr_initialize, and must be closed - * with a call to apr_terminate at the end of program execution. + * @remark See fspr_initialize if this is a library consumer of apr. + * Otherwise, this call is identical to fspr_initialize, and must be closed + * with a call to fspr_terminate at the end of program execution. */ -APR_DECLARE(apr_status_t) apr_app_initialize(int *argc, +APR_DECLARE(fspr_status_t) fspr_app_initialize(int *argc, char const * const * *argv, char const * const * *env); @@ -198,25 +202,25 @@ APR_DECLARE(apr_status_t) apr_app_initialize(int *argc, * has stopped using APR services. The APR developers suggest using * atexit to ensure this is called. When using APR from a language * other than C that has problems with the calling convention, use - * apr_terminate2() instead. + * fspr_terminate2() instead. */ -APR_DECLARE_NONSTD(void) apr_terminate(void); +APR_DECLARE_NONSTD(void) fspr_terminate(void); /** * Tear down any APR internal data structures which aren't torn down - * automatically, same as apr_terminate - * @remark An APR program must call either the apr_terminate or apr_terminate2 + * automatically, same as fspr_terminate + * @remark An APR program must call either the fspr_terminate or fspr_terminate2 * function once it it has finished using APR services. The APR - * developers suggest using atexit(apr_terminate) to ensure this is done. - * apr_terminate2 exists to allow non-c language apps to tear down apr, - * while apr_terminate is recommended from c language applications. + * developers suggest using atexit(fspr_terminate) to ensure this is done. + * fspr_terminate2 exists to allow non-c language apps to tear down apr, + * while fspr_terminate is recommended from c language applications. */ -APR_DECLARE(void) apr_terminate2(void); +APR_DECLARE(void) fspr_terminate2(void); /** @} */ /** - * @defgroup apr_random Random Functions + * @defgroup fspr_random Random Functions * @{ */ @@ -228,8 +232,8 @@ APR_DECLARE(void) apr_terminate2(void); * @param buf Buffer to fill with random bytes * @param length Length of buffer in bytes */ -APR_DECLARE(apr_status_t) apr_generate_random_bytes(unsigned char * buf, - apr_size_t length); +APR_DECLARE(fspr_status_t) fspr_generate_random_bytes(unsigned char * buf, + fspr_size_t length); #endif /** @} */ diff --git a/libs/apr/include/apr_getopt.h b/libs/apr/include/fspr_getopt.h similarity index 78% rename from libs/apr/include/apr_getopt.h rename to libs/apr/include/fspr_getopt.h index 131aa4b38d..5299fa7ae3 100644 --- a/libs/apr/include/apr_getopt.h +++ b/libs/apr/include/fspr_getopt.h @@ -18,18 +18,18 @@ #define APR_GETOPT_H /** - * @file apr_getopt.h + * @file fspr_getopt.h * @brief APR Command Arguments (getopt) */ -#include "apr_pools.h" +#include "fspr_pools.h" #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** - * @defgroup apr_getopt Command Argument Parsing + * @defgroup fspr_getopt Command Argument Parsing * @ingroup APR * @{ */ @@ -37,19 +37,19 @@ extern "C" { /** * defintion of a error function */ -typedef void (apr_getopt_err_fn_t)(void *arg, const char *err, ...); +typedef void (fspr_getopt_err_fn_t)(void *arg, const char *err, ...); -/** @see apr_getopt_t */ -typedef struct apr_getopt_t apr_getopt_t; +/** @see fspr_getopt_t */ +typedef struct fspr_getopt_t fspr_getopt_t; /** * Structure to store command line argument information. */ -struct apr_getopt_t { +struct fspr_getopt_t { /** context for processing */ - apr_pool_t *cont; + fspr_pool_t *cont; /** function to print error message (NULL == no messages) */ - apr_getopt_err_fn_t *errfn; + fspr_getopt_err_fn_t *errfn; /** user defined first arg to pass to error message */ void *errarg; /** index into parent argv vector */ @@ -72,13 +72,13 @@ struct apr_getopt_t { int skip_end; }; -/** @see apr_getopt_option_t */ -typedef struct apr_getopt_option_t apr_getopt_option_t; +/** @see fspr_getopt_option_t */ +typedef struct fspr_getopt_option_t fspr_getopt_option_t; /** * Structure used to describe options that getopt should search for. */ -struct apr_getopt_option_t { +struct fspr_getopt_option_t { /** long option name, or NULL if option has no long name */ const char *name; /** option letter, or a value greater than 255 if option has no letter */ @@ -90,20 +90,20 @@ struct apr_getopt_option_t { }; /** - * Initialize the arguments for parsing by apr_getopt(). - * @param os The options structure created for apr_getopt() + * Initialize the arguments for parsing by fspr_getopt(). + * @param os The options structure created for fspr_getopt() * @param cont The pool to operate on * @param argc The number of arguments to parse * @param argv The array of arguments to parse * @remark Arguments 2 and 3 are most commonly argc and argv from main(argc, argv) * The errfn is initialized to fprintf(stderr... but may be overridden. */ -APR_DECLARE(apr_status_t) apr_getopt_init(apr_getopt_t **os, apr_pool_t *cont, +APR_DECLARE(fspr_status_t) fspr_getopt_init(fspr_getopt_t **os, fspr_pool_t *cont, int argc, const char * const *argv); /** - * Parse the options initialized by apr_getopt_init(). - * @param os The apr_opt_t structure returned by apr_getopt_init() + * Parse the options initialized by fspr_getopt_init(). + * @param os The fspr_opt_t structure returned by fspr_getopt_init() * @param opts A string of characters that are acceptable options to the * program. Characters followed by ":" are required to have an * option associated @@ -117,19 +117,19 @@ APR_DECLARE(apr_status_t) apr_getopt_init(apr_getopt_t **os, apr_pool_t *cont, * APR_SUCCESS -- The next option was found. * */ -APR_DECLARE(apr_status_t) apr_getopt(apr_getopt_t *os, const char *opts, +APR_DECLARE(fspr_status_t) fspr_getopt(fspr_getopt_t *os, const char *opts, char *option_ch, const char **option_arg); /** - * Parse the options initialized by apr_getopt_init(), accepting long + * Parse the options initialized by fspr_getopt_init(), accepting long * options beginning with "--" in addition to single-character * options beginning with "-". - * @param os The apr_getopt_t structure created by apr_getopt_init() - * @param opts A pointer to a list of apr_getopt_option_t structures, which + * @param os The fspr_getopt_t structure created by fspr_getopt_init() + * @param opts A pointer to a list of fspr_getopt_option_t structures, which * can be initialized with { "name", optch, has_args }. has_args * is nonzero if the option requires an argument. A structure * with an optch value of 0 terminates the list. - * @param option_ch Receives the value of "optch" from the apr_getopt_option_t + * @param option_ch Receives the value of "optch" from the fspr_getopt_option_t * structure corresponding to the next option matched. * @param option_arg Receives the argument following the option, if any. * @return There are four potential status values on exit. They are: @@ -145,8 +145,8 @@ APR_DECLARE(apr_status_t) apr_getopt(apr_getopt_t *os, const char *opts, * after arguments, and os->argv will be permuted to leave non-option arguments * at the end (the original argv is unaffected). */ -APR_DECLARE(apr_status_t) apr_getopt_long(apr_getopt_t *os, - const apr_getopt_option_t *opts, +APR_DECLARE(fspr_status_t) fspr_getopt_long(fspr_getopt_t *os, + const fspr_getopt_option_t *opts, int *option_ch, const char **option_arg); /** @} */ diff --git a/libs/apr/include/apr_global_mutex.h b/libs/apr/include/fspr_global_mutex.h similarity index 71% rename from libs/apr/include/apr_global_mutex.h rename to libs/apr/include/fspr_global_mutex.h index 9316001ce6..3e82a3e7dd 100644 --- a/libs/apr/include/apr_global_mutex.h +++ b/libs/apr/include/fspr_global_mutex.h @@ -18,16 +18,16 @@ #define APR_GLOBAL_MUTEX_H /** - * @file apr_global_mutex.h + * @file fspr_global_mutex.h * @brief APR Global Locking Routines */ -#include "apr.h" -#include "apr_proc_mutex.h" /* only for apr_lockmech_e */ -#include "apr_pools.h" -#include "apr_errno.h" +#include "fspr.h" +#include "fspr_proc_mutex.h" /* only for fspr_lockmech_e */ +#include "fspr_pools.h" +#include "fspr_errno.h" #if APR_PROC_MUTEX_IS_GLOBAL -#include "apr_proc_mutex.h" +#include "fspr_proc_mutex.h" #endif #ifdef __cplusplus @@ -43,7 +43,7 @@ extern "C" { #if !APR_PROC_MUTEX_IS_GLOBAL || defined(DOXYGEN) /** Opaque global mutex structure. */ -typedef struct apr_global_mutex_t apr_global_mutex_t; +typedef struct fspr_global_mutex_t fspr_global_mutex_t; /* Function definitions */ @@ -51,7 +51,7 @@ typedef struct apr_global_mutex_t apr_global_mutex_t; * Create and initialize a mutex that can be used to synchronize both * processes and threads. Note: There is considerable overhead in using * this API if only cross-process or cross-thread mutual exclusion is - * required. See apr_proc_mutex.h and apr_thread_mutex.h for more + * required. See fspr_proc_mutex.h and fspr_thread_mutex.h for more * specialized lock routines. * @param mutex the memory address where the newly created mutex will be * stored. @@ -71,10 +71,10 @@ typedef struct apr_global_mutex_t apr_global_mutex_t; * @warning Check APR_HAS_foo_SERIALIZE defines to see if the platform supports * APR_LOCK_foo. Only APR_LOCK_DEFAULT is portable. */ -APR_DECLARE(apr_status_t) apr_global_mutex_create(apr_global_mutex_t **mutex, +APR_DECLARE(fspr_status_t) fspr_global_mutex_create(fspr_global_mutex_t **mutex, const char *fname, - apr_lockmech_e mech, - apr_pool_t *pool); + fspr_lockmech_e mech, + fspr_pool_t *pool); /** * Re-open a mutex in a child process. @@ -82,22 +82,22 @@ APR_DECLARE(apr_status_t) apr_global_mutex_create(apr_global_mutex_t **mutex, * @param fname A file name to use if the mutex mechanism requires one. This * argument should always be provided. The mutex code itself will * determine if it should be used. This filename should be the - * same one that was passed to apr_global_mutex_create(). + * same one that was passed to fspr_global_mutex_create(). * @param pool The pool to operate on. * @remark This function must be called to maintain portability, even * if the underlying lock mechanism does not require it. */ -APR_DECLARE(apr_status_t) apr_global_mutex_child_init( - apr_global_mutex_t **mutex, +APR_DECLARE(fspr_status_t) fspr_global_mutex_child_init( + fspr_global_mutex_t **mutex, const char *fname, - apr_pool_t *pool); + fspr_pool_t *pool); /** * Acquire the lock for the given mutex. If the mutex is already locked, * the current thread will be put to sleep until the lock becomes available. * @param mutex the mutex on which to acquire the lock. */ -APR_DECLARE(apr_status_t) apr_global_mutex_lock(apr_global_mutex_t *mutex); +APR_DECLARE(fspr_status_t) fspr_global_mutex_lock(fspr_global_mutex_t *mutex); /** * Attempt to acquire the lock for the given mutex. If the mutex has already @@ -106,23 +106,23 @@ APR_DECLARE(apr_status_t) apr_global_mutex_lock(apr_global_mutex_t *mutex); * if the return value was APR_EBUSY, for portability reasons. * @param mutex the mutex on which to attempt the lock acquiring. */ -APR_DECLARE(apr_status_t) apr_global_mutex_trylock(apr_global_mutex_t *mutex); +APR_DECLARE(fspr_status_t) fspr_global_mutex_trylock(fspr_global_mutex_t *mutex); /** * Release the lock for the given mutex. * @param mutex the mutex from which to release the lock. */ -APR_DECLARE(apr_status_t) apr_global_mutex_unlock(apr_global_mutex_t *mutex); +APR_DECLARE(fspr_status_t) fspr_global_mutex_unlock(fspr_global_mutex_t *mutex); /** * Destroy the mutex and free the memory associated with the lock. * @param mutex the mutex to destroy. */ -APR_DECLARE(apr_status_t) apr_global_mutex_destroy(apr_global_mutex_t *mutex); +APR_DECLARE(fspr_status_t) fspr_global_mutex_destroy(fspr_global_mutex_t *mutex); /** * Get the pool used by this global_mutex. - * @return apr_pool_t the pool + * @return fspr_pool_t the pool */ APR_POOL_DECLARE_ACCESSOR(global_mutex); @@ -130,17 +130,17 @@ APR_POOL_DECLARE_ACCESSOR(global_mutex); /* Some platforms [e.g. Win32] have cross process locks that are truly * global locks, since there isn't the concept of cross-process locks. - * Define these platforms in terms of an apr_proc_mutex_t. + * Define these platforms in terms of an fspr_proc_mutex_t. */ -#define apr_global_mutex_t apr_proc_mutex_t -#define apr_global_mutex_create apr_proc_mutex_create -#define apr_global_mutex_child_init apr_proc_mutex_child_init -#define apr_global_mutex_lock apr_proc_mutex_lock -#define apr_global_mutex_trylock apr_proc_mutex_trylock -#define apr_global_mutex_unlock apr_proc_mutex_unlock -#define apr_global_mutex_destroy apr_proc_mutex_destroy -#define apr_global_mutex_pool_get apr_proc_mutex_pool_get +#define fspr_global_mutex_t fspr_proc_mutex_t +#define fspr_global_mutex_create fspr_proc_mutex_create +#define fspr_global_mutex_child_init fspr_proc_mutex_child_init +#define fspr_global_mutex_lock fspr_proc_mutex_lock +#define fspr_global_mutex_trylock fspr_proc_mutex_trylock +#define fspr_global_mutex_unlock fspr_proc_mutex_unlock +#define fspr_global_mutex_destroy fspr_proc_mutex_destroy +#define fspr_global_mutex_pool_get fspr_proc_mutex_pool_get #endif diff --git a/libs/apr/include/apr_hash.h b/libs/apr/include/fspr_hash.h similarity index 69% rename from libs/apr/include/apr_hash.h rename to libs/apr/include/fspr_hash.h index 353709b145..fca4458cb3 100644 --- a/libs/apr/include/apr_hash.h +++ b/libs/apr/include/fspr_hash.h @@ -18,43 +18,43 @@ #define APR_HASH_H /** - * @file apr_hash.h + * @file fspr_hash.h * @brief APR Hash Tables */ -#include "apr_pools.h" +#include "fspr_pools.h" #ifdef __cplusplus extern "C" { #endif /** - * @defgroup apr_hash Hash Tables + * @defgroup fspr_hash Hash Tables * @ingroup APR * @{ */ /** - * When passing a key to apr_hash_set or apr_hash_get, this value can be - * passed to indicate a string-valued key, and have apr_hash compute the + * When passing a key to fspr_hash_set or fspr_hash_get, this value can be + * passed to indicate a string-valued key, and have fspr_hash compute the * length automatically. * - * @remark apr_hash will use strlen(key) for the length. The NUL terminator + * @remark fspr_hash will use strlen(key) for the length. The NUL terminator * is not included in the hash value (why throw a constant in?). * Since the hash table merely references the provided key (rather - * than copying it), apr_hash_this() will return the NUL-term'd key. + * than copying it), fspr_hash_this() will return the NUL-term'd key. */ #define APR_HASH_KEY_STRING (-1) /** * Abstract type for hash tables. */ -typedef struct apr_hash_t apr_hash_t; +typedef struct fspr_hash_t fspr_hash_t; /** * Abstract type for scanning hash tables. */ -typedef struct apr_hash_index_t apr_hash_index_t; +typedef struct fspr_hash_index_t fspr_hash_index_t; /** * Callback functions for calculating hash values. @@ -62,20 +62,20 @@ typedef struct apr_hash_index_t apr_hash_index_t; * @param klen The length of the key, or APR_HASH_KEY_STRING to use the string * length. If APR_HASH_KEY_STRING then returns the actual key length. */ -typedef unsigned int (*apr_hashfunc_t)(const char *key, apr_ssize_t *klen); +typedef unsigned int (*fspr_hashfunc_t)(const char *key, fspr_ssize_t *klen); /** * The default hash function. */ -APR_DECLARE_NONSTD(unsigned int) apr_hashfunc_default(const char *key, - apr_ssize_t *klen); +APR_DECLARE_NONSTD(unsigned int) fspr_hashfunc_default(const char *key, + fspr_ssize_t *klen); /** * Create a hash table. * @param pool The pool to allocate the hash table out of * @return The hash table just created */ -APR_DECLARE(apr_hash_t *) apr_hash_make(apr_pool_t *pool); +APR_DECLARE(fspr_hash_t *) fspr_hash_make(fspr_pool_t *pool); /** * Create a hash table with a custom hash function @@ -83,8 +83,8 @@ APR_DECLARE(apr_hash_t *) apr_hash_make(apr_pool_t *pool); * @param hash_func A custom hash function. * @return The hash table just created */ -APR_DECLARE(apr_hash_t *) apr_hash_make_custom(apr_pool_t *pool, - apr_hashfunc_t hash_func); +APR_DECLARE(fspr_hash_t *) fspr_hash_make_custom(fspr_pool_t *pool, + fspr_hashfunc_t hash_func); /** * Make a copy of a hash table @@ -93,8 +93,8 @@ APR_DECLARE(apr_hash_t *) apr_hash_make_custom(apr_pool_t *pool, * @return The hash table just created * @remark Makes a shallow copy */ -APR_DECLARE(apr_hash_t *) apr_hash_copy(apr_pool_t *pool, - const apr_hash_t *h); +APR_DECLARE(fspr_hash_t *) fspr_hash_copy(fspr_pool_t *pool, + const fspr_hash_t *h); /** * Associate a value with a key in a hash table. @@ -104,8 +104,8 @@ APR_DECLARE(apr_hash_t *) apr_hash_copy(apr_pool_t *pool, * @param val Value to associate with the key * @remark If the value is NULL the hash entry is deleted. */ -APR_DECLARE(void) apr_hash_set(apr_hash_t *ht, const void *key, - apr_ssize_t klen, const void *val); +APR_DECLARE(void) fspr_hash_set(fspr_hash_t *ht, const void *key, + fspr_ssize_t klen, const void *val); /** * Look up the value associated with a key in a hash table. @@ -114,12 +114,12 @@ APR_DECLARE(void) apr_hash_set(apr_hash_t *ht, const void *key, * @param klen Length of the key. Can be APR_HASH_KEY_STRING to use the string length. * @return Returns NULL if the key is not present. */ -APR_DECLARE(void *) apr_hash_get(apr_hash_t *ht, const void *key, - apr_ssize_t klen); +APR_DECLARE(void *) fspr_hash_get(fspr_hash_t *ht, const void *key, + fspr_ssize_t klen); /** * Start iterating over the entries in a hash table. - * @param p The pool to allocate the apr_hash_index_t iterator. If this + * @param p The pool to allocate the fspr_hash_index_t iterator. If this * pool is NULL, then an internal, non-thread-safe iterator is used. * @param ht The hash table * @remark There is no restriction on adding or deleting hash entries during @@ -132,20 +132,20 @@ APR_DECLARE(void *) apr_hash_get(apr_hash_t *ht, const void *key, /** *

      * 
    - * int sum_values(apr_pool_t *p, apr_hash_t *ht)
    + * int sum_values(fspr_pool_t *p, fspr_hash_t *ht)
      * {
    - *     apr_hash_index_t *hi;
    + *     fspr_hash_index_t *hi;
      *     void *val;
      *     int sum = 0;
    - *     for (hi = apr_hash_first(p, ht); hi; hi = apr_hash_next(hi)) {
    - *         apr_hash_this(hi, NULL, NULL, &val);
    + *     for (hi = fspr_hash_first(p, ht); hi; hi = fspr_hash_next(hi)) {
    + *         fspr_hash_this(hi, NULL, NULL, &val);
      *         sum += *(int *)val;
      *     }
      *     return sum;
      * }
      * 
    */ -APR_DECLARE(apr_hash_index_t *) apr_hash_first(apr_pool_t *p, apr_hash_t *ht); +APR_DECLARE(fspr_hash_index_t *) fspr_hash_first(fspr_pool_t *p, fspr_hash_t *ht); /** * Continue iterating over the entries in a hash table. @@ -153,7 +153,7 @@ APR_DECLARE(apr_hash_index_t *) apr_hash_first(apr_pool_t *p, apr_hash_t *ht); * @return a pointer to the updated iteration state. NULL if there are no more * entries. */ -APR_DECLARE(apr_hash_index_t *) apr_hash_next(apr_hash_index_t *hi); +APR_DECLARE(fspr_hash_index_t *) fspr_hash_next(fspr_hash_index_t *hi); /** * Get the current entry's details from the iteration state. @@ -164,21 +164,21 @@ APR_DECLARE(apr_hash_index_t *) apr_hash_next(apr_hash_index_t *hi); * @remark The return pointers should point to a variable that will be set to the * corresponding data, or they may be NULL if the data isn't interesting. */ -APR_DECLARE(void) apr_hash_this(apr_hash_index_t *hi, const void **key, - apr_ssize_t *klen, void **val); +APR_DECLARE(void) fspr_hash_this(fspr_hash_index_t *hi, const void **key, + fspr_ssize_t *klen, void **val); /** * Get the number of key/value pairs in the hash table. * @param ht The hash table * @return The number of key/value pairs in the hash table. */ -APR_DECLARE(unsigned int) apr_hash_count(apr_hash_t *ht); +APR_DECLARE(unsigned int) fspr_hash_count(fspr_hash_t *ht); /** * Clear any key/value pairs in the hash table. * @param ht The hash table */ -APR_DECLARE(void) apr_hash_clear(apr_hash_t *ht); +APR_DECLARE(void) fspr_hash_clear(fspr_hash_t *ht); /** * Merge two hash tables into one new hash table. The values of the overlay @@ -189,9 +189,9 @@ APR_DECLARE(void) apr_hash_clear(apr_hash_t *ht); * @param base The table that represents the initial values of the new table * @return A new hash table containing all of the data from the two passed in */ -APR_DECLARE(apr_hash_t *) apr_hash_overlay(apr_pool_t *p, - const apr_hash_t *overlay, - const apr_hash_t *base); +APR_DECLARE(fspr_hash_t *) fspr_hash_overlay(fspr_pool_t *p, + const fspr_hash_t *overlay, + const fspr_hash_t *base); /** * Merge two hash tables into one new hash table. If the same key @@ -203,16 +203,16 @@ APR_DECLARE(apr_hash_t *) apr_hash_overlay(apr_pool_t *p, * @param h2 The second of the tables to merge * @param merger A callback function to merge values, or NULL to * make values from h1 override values from h2 (same semantics as - * apr_hash_overlay()) + * fspr_hash_overlay()) * @param data Client data to pass to the merger function * @return A new hash table containing all of the data from the two passed in */ -APR_DECLARE(apr_hash_t *) apr_hash_merge(apr_pool_t *p, - const apr_hash_t *h1, - const apr_hash_t *h2, - void * (*merger)(apr_pool_t *p, +APR_DECLARE(fspr_hash_t *) fspr_hash_merge(fspr_pool_t *p, + const fspr_hash_t *h1, + const fspr_hash_t *h2, + void * (*merger)(fspr_pool_t *p, const void *key, - apr_ssize_t klen, + fspr_ssize_t klen, const void *h1_val, const void *h2_val, const void *data), diff --git a/libs/apr/include/apr_inherit.h b/libs/apr/include/fspr_inherit.h similarity index 70% rename from libs/apr/include/apr_inherit.h rename to libs/apr/include/fspr_inherit.h index b7f7480f1f..c73cd8aa60 100644 --- a/libs/apr/include/apr_inherit.h +++ b/libs/apr/include/fspr_inherit.h @@ -18,34 +18,34 @@ #define APR_INHERIT_H /** - * @file apr_inherit.h + * @file fspr_inherit.h * @brief APR File Handle Inheritance Helpers * @remark This internal header includes internal declaration helpers - * for other headers to declare apr_foo_inherit_[un]set functions. + * for other headers to declare fspr_foo_inherit_[un]set functions. */ /** - * Prototype for type-specific declarations of apr_foo_inherit_set + * Prototype for type-specific declarations of fspr_foo_inherit_set * functions. * @remark Doxygen unwraps this macro (via doxygen.conf) to provide - * actual help for each specific occurance of apr_foo_inherit_set. + * actual help for each specific occurance of fspr_foo_inherit_set. * @remark the linkage is specified for APR. It would be possible to expand * the macros to support other linkages. */ #define APR_DECLARE_INHERIT_SET(type) \ - APR_DECLARE(apr_status_t) apr_##type##_inherit_set( \ - apr_##type##_t *the##type) + APR_DECLARE(fspr_status_t) fspr_##type##_inherit_set( \ + fspr_##type##_t *the##type) /** - * Prototype for type-specific declarations of apr_foo_inherit_unset + * Prototype for type-specific declarations of fspr_foo_inherit_unset * functions. * @remark Doxygen unwraps this macro (via doxygen.conf) to provide - * actual help for each specific occurance of apr_foo_inherit_unset. + * actual help for each specific occurance of fspr_foo_inherit_unset. * @remark the linkage is specified for APR. It would be possible to expand * the macros to support other linkages. */ #define APR_DECLARE_INHERIT_UNSET(type) \ - APR_DECLARE(apr_status_t) apr_##type##_inherit_unset( \ - apr_##type##_t *the##type) + APR_DECLARE(fspr_status_t) fspr_##type##_inherit_unset( \ + fspr_##type##_t *the##type) #endif /* ! APR_INHERIT_H */ diff --git a/libs/apr/include/apr_lib.h b/libs/apr/include/fspr_lib.h similarity index 65% rename from libs/apr/include/apr_lib.h rename to libs/apr/include/fspr_lib.h index ed25d869f5..6642950ecf 100644 --- a/libs/apr/include/apr_lib.h +++ b/libs/apr/include/fspr_lib.h @@ -18,15 +18,15 @@ #define APR_LIB_H /** - * @file apr_lib.h + * @file fspr_lib.h * This is collection of oddballs that didn't fit anywhere else, * and might move to more appropriate headers with the release * of APR 1.0. * @brief APR general purpose library routines */ -#include "apr.h" -#include "apr_errno.h" +#include "fspr.h" +#include "fspr_errno.h" #if APR_HAVE_CTYPE_H #include @@ -40,7 +40,7 @@ extern "C" { #endif /* __cplusplus */ /** - * @defgroup apr_lib General Purpose Library Routines + * @defgroup fspr_lib General Purpose Library Routines * @ingroup APR * This is collection of oddballs that didn't fit anywhere else, * and might move to more appropriate headers with the release @@ -55,13 +55,13 @@ extern "C" { * Define the structures used by the APR general-purpose library. */ -/** @see apr_vformatter_buff_t */ -typedef struct apr_vformatter_buff_t apr_vformatter_buff_t; +/** @see fspr_vformatter_buff_t */ +typedef struct fspr_vformatter_buff_t fspr_vformatter_buff_t; /** * Structure used by the variable-formatter routines. */ -struct apr_vformatter_buff_t { +struct fspr_vformatter_buff_t { /** The current position */ char *curpos; /** The end position of the format string */ @@ -81,26 +81,26 @@ struct apr_vformatter_buff_t { * "bs\\path\\stuff" -> "stuff" * */ -APR_DECLARE(const char *) apr_filepath_name_get(const char *pathname); +APR_DECLARE(const char *) fspr_filepath_name_get(const char *pathname); /** - * apr_killpg + * fspr_killpg * Small utility macros to make things easier to read. Not usually a * goal, to be sure.. */ #ifdef WIN32 -#define apr_killpg(x, y) +#define fspr_killpg(x, y) #else /* WIN32 */ #ifdef NO_KILLPG -#define apr_killpg(x, y) (kill (-(x), (y))) +#define fspr_killpg(x, y) (kill (-(x), (y))) #else /* NO_KILLPG */ -#define apr_killpg(x, y) (killpg ((x), (y))) +#define fspr_killpg(x, y) (killpg ((x), (y))) #endif /* NO_KILLPG */ #endif /* WIN32 */ /** - * apr_vformatter() is a generic printf-style formatting routine + * fspr_vformatter() is a generic printf-style formatting routine * with some extensions. * @param flush_func The function to call when the buffer is full * @param c The buffer to write to @@ -112,11 +112,11 @@ APR_DECLARE(const char *) apr_filepath_name_get(const char *pathname); * The extensions are: * * %%pA takes a struct in_addr *, and prints it as a.b.c.d - * %%pI takes an apr_sockaddr_t * and prints it as a.b.c.d:port or + * %%pI takes an fspr_sockaddr_t * and prints it as a.b.c.d:port or * [ipv6-address]:port - * %%pT takes an apr_os_thread_t * and prints it in decimal + * %%pT takes an fspr_os_thread_t * and prints it in decimal * ('0' is printed if !APR_HAS_THREADS) - * %%pt takes an apr_os_thread_t * and prints it in hexadecimal + * %%pt takes an fspr_os_thread_t * and prints it in hexadecimal * ('0' is printed if !APR_HAS_THREADS) * %%pp takes a void * and outputs it in hex * @@ -126,44 +126,44 @@ APR_DECLARE(const char *) apr_filepath_name_get(const char *pathname); * work as expected at all, but that seems to be a fair trade-off * for the increased robustness of having printf-warnings work. * - * Additionally, apr_vformatter allows for arbitrary output methods - * using the apr_vformatter_buff and flush_func. + * Additionally, fspr_vformatter allows for arbitrary output methods + * using the fspr_vformatter_buff and flush_func. * - * The apr_vformatter_buff has two elements curpos and endpos. - * curpos is where apr_vformatter will write the next byte of output. + * The fspr_vformatter_buff has two elements curpos and endpos. + * curpos is where fspr_vformatter will write the next byte of output. * It proceeds writing output to curpos, and updating curpos, until * either the end of output is reached, or curpos == endpos (i.e. the * buffer is full). * - * If the end of output is reached, apr_vformatter returns the + * If the end of output is reached, fspr_vformatter returns the * number of bytes written. * * When the buffer is full, the flush_func is called. The flush_func * can return -1 to indicate that no further output should be attempted, - * and apr_vformatter will return immediately with -1. Otherwise + * and fspr_vformatter will return immediately with -1. Otherwise * the flush_func should flush the buffer in whatever manner is - * appropriate, re apr_pool_t nitialize curpos and endpos, and return 0. + * appropriate, re fspr_pool_t nitialize curpos and endpos, and return 0. * * Note that flush_func is only invoked as a result of attempting to * write another byte at curpos when curpos >= endpos. So for * example, it's possible when the output exactly matches the buffer * space available that curpos == endpos will be true when - * apr_vformatter returns. + * fspr_vformatter returns. * - * apr_vformatter does not call out to any other code, it is entirely + * fspr_vformatter does not call out to any other code, it is entirely * self-contained. This allows the callers to do things which are - * otherwise "unsafe". For example, apr_psprintf uses the "scratch" + * otherwise "unsafe". For example, fspr_psprintf uses the "scratch" * space at the unallocated end of a block, and doesn't actually - * complete the allocation until apr_vformatter returns. apr_psprintf - * would be completely broken if apr_vformatter were to call anything + * complete the allocation until fspr_vformatter returns. fspr_psprintf + * would be completely broken if fspr_vformatter were to call anything * that used this same pool. Similarly http_bprintf() uses the "scratch" * space at the end of its output buffer, and doesn't actually note * that the space is in use until it either has to flush the buffer - * or until apr_vformatter returns. + * or until fspr_vformatter returns. * */ -APR_DECLARE(int) apr_vformatter(int (*flush_func)(apr_vformatter_buff_t *b), - apr_vformatter_buff_t *c, const char *fmt, +APR_DECLARE(int) fspr_vformatter(int (*flush_func)(fspr_vformatter_buff_t *b), + fspr_vformatter_buff_t *c, const char *fmt, va_list ap); /** @@ -174,16 +174,16 @@ APR_DECLARE(int) apr_vformatter(int (*flush_func)(apr_vformatter_buff_t *b), * @remark If the password entered must be truncated to fit in * the provided buffer, APR_ENAMETOOLONG will be returned. * Note that the bufsize paramater is passed by reference for no - * reason; its value will never be modified by the apr_password_get() + * reason; its value will never be modified by the fspr_password_get() * function. */ -APR_DECLARE(apr_status_t) apr_password_get(const char *prompt, char *pwbuf, - apr_size_t *bufsize); +APR_DECLARE(fspr_status_t) fspr_password_get(const char *prompt, char *pwbuf, + fspr_size_t *bufsize); /** @} */ /** - * @defgroup apr_ctype ctype functions + * @defgroup fspr_ctype ctype functions * These macros allow correct support of 8-bit characters on systems which * support 8-bit characters. Pretty dumb how the cast is required, but * that's legacy libc for ya. These new macros do not support EOF like @@ -191,37 +191,37 @@ APR_DECLARE(apr_status_t) apr_password_get(const char *prompt, char *pwbuf, * @{ */ /** @see isalnum */ -#define apr_isalnum(c) (isalnum(((unsigned char)(c)))) +#define fspr_isalnum(c) (isalnum(((unsigned char)(c)))) /** @see isalpha */ -#define apr_isalpha(c) (isalpha(((unsigned char)(c)))) +#define fspr_isalpha(c) (isalpha(((unsigned char)(c)))) /** @see iscntrl */ -#define apr_iscntrl(c) (iscntrl(((unsigned char)(c)))) +#define fspr_iscntrl(c) (iscntrl(((unsigned char)(c)))) /** @see isdigit */ -#define apr_isdigit(c) (isdigit(((unsigned char)(c)))) +#define fspr_isdigit(c) (isdigit(((unsigned char)(c)))) /** @see isgraph */ -#define apr_isgraph(c) (isgraph(((unsigned char)(c)))) +#define fspr_isgraph(c) (isgraph(((unsigned char)(c)))) /** @see islower*/ -#define apr_islower(c) (islower(((unsigned char)(c)))) +#define fspr_islower(c) (islower(((unsigned char)(c)))) /** @see isascii */ #ifdef isascii -#define apr_isascii(c) (isascii(((unsigned char)(c)))) +#define fspr_isascii(c) (isascii(((unsigned char)(c)))) #else -#define apr_isascii(c) (((c) & ~0x7f)==0) +#define fspr_isascii(c) (((c) & ~0x7f)==0) #endif /** @see isprint */ -#define apr_isprint(c) (isprint(((unsigned char)(c)))) +#define fspr_isprint(c) (isprint(((unsigned char)(c)))) /** @see ispunct */ -#define apr_ispunct(c) (ispunct(((unsigned char)(c)))) +#define fspr_ispunct(c) (ispunct(((unsigned char)(c)))) /** @see isspace */ -#define apr_isspace(c) (isspace(((unsigned char)(c)))) +#define fspr_isspace(c) (isspace(((unsigned char)(c)))) /** @see isupper */ -#define apr_isupper(c) (isupper(((unsigned char)(c)))) +#define fspr_isupper(c) (isupper(((unsigned char)(c)))) /** @see isxdigit */ -#define apr_isxdigit(c) (isxdigit(((unsigned char)(c)))) +#define fspr_isxdigit(c) (isxdigit(((unsigned char)(c)))) /** @see tolower */ -#define apr_tolower(c) (tolower(((unsigned char)(c)))) +#define fspr_tolower(c) (tolower(((unsigned char)(c)))) /** @see toupper */ -#define apr_toupper(c) (toupper(((unsigned char)(c)))) +#define fspr_toupper(c) (toupper(((unsigned char)(c)))) /** @} */ diff --git a/libs/apr/include/apr_mmap.h b/libs/apr/include/fspr_mmap.h similarity index 76% rename from libs/apr/include/apr_mmap.h rename to libs/apr/include/fspr_mmap.h index 77d697f5b5..88b99b8fe1 100644 --- a/libs/apr/include/apr_mmap.h +++ b/libs/apr/include/fspr_mmap.h @@ -18,15 +18,15 @@ #define APR_MMAP_H /** - * @file apr_mmap.h + * @file fspr_mmap.h * @brief APR MMAP routines */ -#include "apr.h" -#include "apr_pools.h" -#include "apr_errno.h" -#include "apr_ring.h" -#include "apr_file_io.h" /* for apr_file_t */ +#include "fspr.h" +#include "fspr_pools.h" +#include "fspr_errno.h" +#include "fspr_ring.h" +#include "fspr_file_io.h" /* for fspr_file_t */ #ifdef BEOS #include @@ -37,7 +37,7 @@ extern "C" { #endif /* __cplusplus */ /** - * @defgroup apr_mmap MMAP (Memory Map) Routines + * @defgroup fspr_mmap MMAP (Memory Map) Routines * @ingroup APR * @{ */ @@ -47,8 +47,8 @@ extern "C" { /** MMap opened for writing */ #define APR_MMAP_WRITE 2 -/** @see apr_mmap_t */ -typedef struct apr_mmap_t apr_mmap_t; +/** @see fspr_mmap_t */ +typedef struct fspr_mmap_t fspr_mmap_t; /** * @remark @@ -59,9 +59,9 @@ typedef struct apr_mmap_t apr_mmap_t; * Apache. */ /** The MMAP structure */ -struct apr_mmap_t { +struct fspr_mmap_t { /** The pool the mmap structure was allocated out of. */ - apr_pool_t *cntxt; + fspr_pool_t *cntxt; #ifdef BEOS /** An area ID. Only valid on BeOS */ area_id area; @@ -72,17 +72,17 @@ struct apr_mmap_t { /** The start of the real memory page area (mapped view) */ void *mv; /** The physical start, size and offset */ - apr_off_t pstart; - apr_size_t psize; - apr_off_t poffset; + fspr_off_t pstart; + fspr_size_t psize; + fspr_off_t poffset; #endif /** The start of the memory mapped area */ void *mm; /** The amount of data in the mmap */ - apr_size_t size; - /** ring of apr_mmap_t's that reference the same + fspr_size_t size; + /** ring of fspr_mmap_t's that reference the same * mmap'ed region; acts in place of a reference count */ - APR_RING_ENTRY(apr_mmap_t) link; + APR_RING_ENTRY(fspr_mmap_t) link; }; #if APR_HAS_MMAP || defined(DOXYGEN) @@ -130,10 +130,10 @@ struct apr_mmap_t { * * @param cntxt The pool to use when creating the mmap. */ -APR_DECLARE(apr_status_t) apr_mmap_create(apr_mmap_t **newmmap, - apr_file_t *file, apr_off_t offset, - apr_size_t size, apr_int32_t flag, - apr_pool_t *cntxt); +APR_DECLARE(fspr_status_t) fspr_mmap_create(fspr_mmap_t **newmmap, + fspr_file_t *file, fspr_off_t offset, + fspr_size_t size, fspr_int32_t flag, + fspr_pool_t *cntxt); /** * Duplicate the specified MMAP. @@ -141,15 +141,15 @@ APR_DECLARE(apr_status_t) apr_mmap_create(apr_mmap_t **newmmap, * @param old_mmap The mmap to duplicate. * @param p The pool to use for new_mmap. */ -APR_DECLARE(apr_status_t) apr_mmap_dup(apr_mmap_t **new_mmap, - apr_mmap_t *old_mmap, - apr_pool_t *p); +APR_DECLARE(fspr_status_t) fspr_mmap_dup(fspr_mmap_t **new_mmap, + fspr_mmap_t *old_mmap, + fspr_pool_t *p); /** * Remove a mmap'ed. * @param mm The mmap'ed file. */ -APR_DECLARE(apr_status_t) apr_mmap_delete(apr_mmap_t *mm); +APR_DECLARE(fspr_status_t) fspr_mmap_delete(fspr_mmap_t *mm); /** * Move the pointer into the mmap'ed file to the specified offset. @@ -157,8 +157,8 @@ APR_DECLARE(apr_status_t) apr_mmap_delete(apr_mmap_t *mm); * @param mm The mmap'ed file. * @param offset The offset to move to. */ -APR_DECLARE(apr_status_t) apr_mmap_offset(void **addr, apr_mmap_t *mm, - apr_off_t offset); +APR_DECLARE(fspr_status_t) fspr_mmap_offset(void **addr, fspr_mmap_t *mm, + fspr_off_t offset); #endif /* APR_HAS_MMAP */ diff --git a/libs/apr/include/apr_network_io.h b/libs/apr/include/fspr_network_io.h similarity index 72% rename from libs/apr/include/apr_network_io.h rename to libs/apr/include/fspr_network_io.h index 1d65f1cb09..384b329143 100644 --- a/libs/apr/include/apr_network_io.h +++ b/libs/apr/include/fspr_network_io.h @@ -17,15 +17,15 @@ #ifndef APR_NETWORK_IO_H #define APR_NETWORK_IO_H /** - * @file apr_network_io.h + * @file fspr_network_io.h * @brief APR Network library */ -#include "apr.h" -#include "apr_pools.h" -#include "apr_file_io.h" -#include "apr_errno.h" -#include "apr_inherit.h" +#include "fspr.h" +#include "fspr_pools.h" +#include "fspr_file_io.h" +#include "fspr_errno.h" +#include "fspr_inherit.h" #if APR_HAVE_NETINET_IN_H #include @@ -36,7 +36,7 @@ extern "C" { #endif /* __cplusplus */ /** - * @defgroup apr_network_io Network Routines + * @defgroup fspr_network_io Network Routines * @ingroup APR * @{ */ @@ -57,7 +57,7 @@ extern "C" { #endif /** - * @defgroup apr_sockopt Socket option definitions + * @defgroup fspr_sockopt Socket option definitions * @{ */ #define APR_SO_LINGER 1 /**< Linger */ @@ -81,7 +81,7 @@ extern "C" { #define APR_INCOMPLETE_READ 4096 /**< Set on non-blocking sockets * (timeout != 0) on which the * previous read() did not fill a buffer - * completely. the next apr_socket_recv() + * completely. the next fspr_socket_recv() * will first call select()/poll() rather than * going straight into read(). (Can also * be set by an application to force a @@ -97,7 +97,7 @@ extern "C" { */ #define APR_TCP_DEFER_ACCEPT 32768 /**< Delay accepting of new connections * until data is available. - * @see apr_socket_accept_filter + * @see fspr_socket_accept_filter */ /** @} */ @@ -107,10 +107,10 @@ typedef enum { APR_SHUTDOWN_READ, /**< no longer allow read request */ APR_SHUTDOWN_WRITE, /**< no longer allow write requests */ APR_SHUTDOWN_READWRITE /**< no longer allow read or write requests */ -} apr_shutdown_how_e; +} fspr_shutdown_how_e; -#define APR_IPV4_ADDR_OK 0x01 /**< @see apr_sockaddr_info_get() */ -#define APR_IPV6_ADDR_OK 0x02 /**< @see apr_sockaddr_info_get() */ +#define APR_IPV4_ADDR_OK 0x01 /**< @see fspr_sockaddr_info_get() */ +#define APR_IPV6_ADDR_OK 0x02 /**< @see fspr_sockaddr_info_get() */ #if (!APR_HAVE_IN_ADDR) /** @@ -118,7 +118,7 @@ typedef enum { * define it ourselves, if the platform doesn't provide it. */ struct in_addr { - apr_uint32_t s_addr; /**< storage to hold the IP# */ + fspr_uint32_t s_addr; /**< storage to hold the IP# */ }; #endif @@ -169,7 +169,7 @@ struct in_addr { typedef enum { APR_LOCAL, APR_REMOTE -} apr_interface_e; +} fspr_interface_e; /** * The specific declaration of inet_addr's ... some platforms fall back @@ -177,49 +177,49 @@ typedef enum { */ #if APR_HAVE_INET_ADDR -#define apr_inet_addr inet_addr +#define fspr_inet_addr inet_addr #elif APR_HAVE_INET_NETWORK /* only DGUX, as far as I know */ /** * @warning * not generally safe... inet_network() and inet_addr() perform * different functions */ -#define apr_inet_addr inet_network +#define fspr_inet_addr inet_network #endif /** A structure to represent sockets */ -typedef struct apr_socket_t apr_socket_t; +typedef struct fspr_socket_t fspr_socket_t; /** - * A structure to encapsulate headers and trailers for apr_socket_sendfile + * A structure to encapsulate headers and trailers for fspr_socket_sendfile */ -typedef struct apr_hdtr_t apr_hdtr_t; +typedef struct fspr_hdtr_t fspr_hdtr_t; /** A structure to represent in_addr */ -typedef struct in_addr apr_in_addr_t; +typedef struct in_addr fspr_in_addr_t; /** A structure to represent an IP subnet */ -typedef struct apr_ipsubnet_t apr_ipsubnet_t; +typedef struct fspr_ipsubnet_t fspr_ipsubnet_t; -/** @remark use apr_uint16_t just in case some system has a short that isn't 16 bits... */ -typedef apr_uint16_t apr_port_t; +/** @remark use fspr_uint16_t just in case some system has a short that isn't 16 bits... */ +typedef fspr_uint16_t fspr_port_t; /** @remark It's defined here as I think it should all be platform safe... - * @see apr_sockaddr_t + * @see fspr_sockaddr_t */ -typedef struct apr_sockaddr_t apr_sockaddr_t; +typedef struct fspr_sockaddr_t fspr_sockaddr_t; /** * APRs socket address type, used to ensure protocol independence */ -struct apr_sockaddr_t { +struct fspr_sockaddr_t { /** The pool to use... */ - apr_pool_t *pool; + fspr_pool_t *pool; /** The hostname */ char *hostname; /** Either a string of the port number or the service name for the port */ char *servname; /** The numeric port */ - apr_port_t port; + fspr_port_t port; /** The family */ - apr_int32_t family; + fspr_int32_t family; /** How big is the sockaddr we're using? */ - apr_socklen_t salen; + fspr_socklen_t salen; /** How big is the ip address structure we're using? */ int ipaddr_len; /** How big should the address buffer be? 16 for v4 or 46 for v6 @@ -228,9 +228,9 @@ struct apr_sockaddr_t { /** This points to the IP address structure within the appropriate * sockaddr structure. */ void *ipaddr_ptr; - /** If multiple addresses were found by apr_sockaddr_info_get(), this + /** If multiple addresses were found by fspr_sockaddr_info_get(), this * points to a representation of the next address. */ - apr_sockaddr_t *next; + fspr_sockaddr_t *next; /** Union of either IPv4 or IPv6 sockaddr. */ union { /** IPv4 sockaddr structure */ @@ -251,13 +251,13 @@ struct apr_sockaddr_t { /** * Support reusing the socket on platforms which support it (from disconnect, * specifically Win32. - * @remark Optional flag passed into apr_socket_sendfile() + * @remark Optional flag passed into fspr_socket_sendfile() */ #define APR_SENDFILE_DISCONNECT_SOCKET 1 #endif -/** A structure to encapsulate headers and trailers for apr_socket_sendfile */ -struct apr_hdtr_t { +/** A structure to encapsulate headers and trailers for fspr_socket_sendfile */ +struct fspr_hdtr_t { /** An iovec to store the headers sent before the file. */ struct iovec* headers; /** number of headers in the iovec */ @@ -278,10 +278,10 @@ struct apr_hdtr_t { * @param protocol The protocol of the socket (e.g., APR_PROTO_TCP). * @param cont The pool to use */ -APR_DECLARE(apr_status_t) apr_socket_create(apr_socket_t **new_sock, +APR_DECLARE(fspr_status_t) fspr_socket_create(fspr_socket_t **new_sock, int family, int type, int protocol, - apr_pool_t *cont); + fspr_pool_t *cont); /** * Shutdown either reading, writing, or both sides of a socket. @@ -292,18 +292,18 @@ APR_DECLARE(apr_status_t) apr_socket_create(apr_socket_t **new_sock, * APR_SHUTDOWN_WRITE no longer allow write requests * APR_SHUTDOWN_READWRITE no longer allow read or write requests * - * @see apr_shutdown_how_e + * @see fspr_shutdown_how_e * @remark This does not actually close the socket descriptor, it just * controls which calls are still valid on the socket. */ -APR_DECLARE(apr_status_t) apr_socket_shutdown(apr_socket_t *thesocket, - apr_shutdown_how_e how); +APR_DECLARE(fspr_status_t) fspr_socket_shutdown(fspr_socket_t *thesocket, + fspr_shutdown_how_e how); /** * Close a socket. * @param thesocket The socket to close */ -APR_DECLARE(apr_status_t) apr_socket_close(apr_socket_t *thesocket); +APR_DECLARE(fspr_status_t) fspr_socket_close(fspr_socket_t *thesocket); /** * Bind the socket to its associated port @@ -312,8 +312,8 @@ APR_DECLARE(apr_status_t) apr_socket_close(apr_socket_t *thesocket); * @remark This may be where we will find out if there is any other process * using the selected port. */ -APR_DECLARE(apr_status_t) apr_socket_bind(apr_socket_t *sock, - apr_sockaddr_t *sa); +APR_DECLARE(fspr_status_t) fspr_socket_bind(fspr_socket_t *sock, + fspr_sockaddr_t *sa); /** * Listen to a bound socket for connections. @@ -322,8 +322,8 @@ APR_DECLARE(apr_status_t) apr_socket_bind(apr_socket_t *sock, * listen queue. If this value is less than zero, the listen * queue size is set to zero. */ -APR_DECLARE(apr_status_t) apr_socket_listen(apr_socket_t *sock, - apr_int32_t backlog); +APR_DECLARE(fspr_status_t) fspr_socket_listen(fspr_socket_t *sock, + fspr_int32_t backlog); /** * Accept a new connection request @@ -333,9 +333,9 @@ APR_DECLARE(apr_status_t) apr_socket_listen(apr_socket_t *sock, * @param sock The socket we are listening on. * @param connection_pool The pool for the new socket. */ -APR_DECLARE(apr_status_t) apr_socket_accept(apr_socket_t **new_sock, - apr_socket_t *sock, - apr_pool_t *connection_pool); +APR_DECLARE(fspr_status_t) fspr_socket_accept(fspr_socket_t **new_sock, + fspr_socket_t *sock, + fspr_pool_t *connection_pool); /** * Issue a connection request to a socket either on the same machine @@ -343,12 +343,12 @@ APR_DECLARE(apr_status_t) apr_socket_accept(apr_socket_t **new_sock, * @param sock The socket we wish to use for our side of the connection * @param sa The address of the machine we wish to connect to. */ -APR_DECLARE(apr_status_t) apr_socket_connect(apr_socket_t *sock, - apr_sockaddr_t *sa); +APR_DECLARE(fspr_status_t) fspr_socket_connect(fspr_socket_t *sock, + fspr_sockaddr_t *sa); /** - * Create apr_sockaddr_t from hostname, address family, and port. - * @param sa The new apr_sockaddr_t. + * Create fspr_sockaddr_t from hostname, address family, and port. + * @param sa The new fspr_sockaddr_t. * @param hostname The hostname or numeric address string to resolve/parse, or * NULL to build an address that corresponds to 0.0.0.0 or :: * @param family The address family to use, or APR_UNSPEC if the system should @@ -367,24 +367,24 @@ APR_DECLARE(apr_status_t) apr_socket_connect(apr_socket_t *sock, * isn't NULL and APR_HAVE_IPV6; mutually exclusive * with APR_IPV4_ADDR_OK * - * @param p The pool for the apr_sockaddr_t and associated storage. + * @param p The pool for the fspr_sockaddr_t and associated storage. */ -APR_DECLARE(apr_status_t) apr_sockaddr_info_get(apr_sockaddr_t **sa, +APR_DECLARE(fspr_status_t) fspr_sockaddr_info_get(fspr_sockaddr_t **sa, const char *hostname, - apr_int32_t family, - apr_port_t port, - apr_int32_t flags, - apr_pool_t *p); + fspr_int32_t family, + fspr_port_t port, + fspr_int32_t flags, + fspr_pool_t *p); /** - * Look up the host name from an apr_sockaddr_t. + * Look up the host name from an fspr_sockaddr_t. * @param hostname The hostname. - * @param sa The apr_sockaddr_t. + * @param sa The fspr_sockaddr_t. * @param flags Special processing flags. */ -APR_DECLARE(apr_status_t) apr_getnameinfo(char **hostname, - apr_sockaddr_t *sa, - apr_int32_t flags); +APR_DECLARE(fspr_status_t) fspr_getnameinfo(char **hostname, + fspr_sockaddr_t *sa, + fspr_int32_t flags); /** * Parse hostname/IP address with scope id and port. @@ -416,11 +416,11 @@ APR_DECLARE(apr_status_t) apr_getnameinfo(char **hostname, * required, check for addr == NULL in addition to checking the * return code. */ -APR_DECLARE(apr_status_t) apr_parse_addr_port(char **addr, +APR_DECLARE(fspr_status_t) fspr_parse_addr_port(char **addr, char **scope_id, - apr_port_t *port, + fspr_port_t *port, const char *str, - apr_pool_t *p); + fspr_pool_t *p); /** * Get name of the current machine @@ -430,7 +430,7 @@ APR_DECLARE(apr_status_t) apr_parse_addr_port(char **addr, * @param cont The pool to use. * @remark If the buffer was not large enough, an error will be returned. */ -APR_DECLARE(apr_status_t) apr_gethostname(char *buf, int len, apr_pool_t *cont); +APR_DECLARE(fspr_status_t) fspr_gethostname(char *buf, int len, fspr_pool_t *cont); /** * Return the data associated with the current socket @@ -438,8 +438,8 @@ APR_DECLARE(apr_status_t) apr_gethostname(char *buf, int len, apr_pool_t *cont); * @param key The key to associate with the user data. * @param sock The currently open socket. */ -APR_DECLARE(apr_status_t) apr_socket_data_get(void **data, const char *key, - apr_socket_t *sock); +APR_DECLARE(fspr_status_t) fspr_socket_data_get(void **data, const char *key, + fspr_socket_t *sock); /** * Set the data associated with the current socket. @@ -448,9 +448,9 @@ APR_DECLARE(apr_status_t) apr_socket_data_get(void **data, const char *key, * @param key The key to associate with the data. * @param cleanup The cleanup to call when the socket is destroyed. */ -APR_DECLARE(apr_status_t) apr_socket_data_set(apr_socket_t *sock, void *data, +APR_DECLARE(fspr_status_t) fspr_socket_data_set(fspr_socket_t *sock, void *data, const char *key, - apr_status_t (*cleanup)(void*)); + fspr_status_t (*cleanup)(void*)); /** * Send data over a network. @@ -461,7 +461,7 @@ APR_DECLARE(apr_status_t) apr_socket_data_set(apr_socket_t *sock, void *data, * @remark *
      * This functions acts like a blocking write by default.  To change 
    - * this behavior, use apr_socket_timeout_set() or the APR_SO_NONBLOCK
    + * this behavior, use fspr_socket_timeout_set() or the APR_SO_NONBLOCK
      * socket option.
      *
      * It is possible for both bytes to be sent and an error to be returned.
    @@ -469,8 +469,8 @@ APR_DECLARE(apr_status_t) apr_socket_data_set(apr_socket_t *sock, void *data,
      * APR_EINTR is never returned.
      * 
    */ -APR_DECLARE(apr_status_t) apr_socket_send(apr_socket_t *sock, const char *buf, - apr_size_t *len); +APR_DECLARE(fspr_status_t) fspr_socket_send(fspr_socket_t *sock, const char *buf, + fspr_size_t *len); /** * Send multiple packets of data over a network. @@ -481,7 +481,7 @@ APR_DECLARE(apr_status_t) apr_socket_send(apr_socket_t *sock, const char *buf, * @remark *
      * This functions acts like a blocking write by default.  To change 
    - * this behavior, use apr_socket_timeout_set() or the APR_SO_NONBLOCK
    + * this behavior, use fspr_socket_timeout_set() or the APR_SO_NONBLOCK
      * socket option.
      * The number of bytes actually sent is stored in argument 3.
      *
    @@ -490,34 +490,34 @@ APR_DECLARE(apr_status_t) apr_socket_send(apr_socket_t *sock, const char *buf,
      * APR_EINTR is never returned.
      * 
    */ -APR_DECLARE(apr_status_t) apr_socket_sendv(apr_socket_t *sock, +APR_DECLARE(fspr_status_t) fspr_socket_sendv(fspr_socket_t *sock, const struct iovec *vec, - apr_int32_t nvec, apr_size_t *len); + fspr_int32_t nvec, fspr_size_t *len); /** * @param sock The socket to send from - * @param where The apr_sockaddr_t describing where to send the data + * @param where The fspr_sockaddr_t describing where to send the data * @param flags The flags to use * @param buf The data to send * @param len The length of the data to send */ -APR_DECLARE(apr_status_t) apr_socket_sendto(apr_socket_t *sock, - apr_sockaddr_t *where, - apr_int32_t flags, const char *buf, - apr_size_t *len); +APR_DECLARE(fspr_status_t) fspr_socket_sendto(fspr_socket_t *sock, + fspr_sockaddr_t *where, + fspr_int32_t flags, const char *buf, + fspr_size_t *len); /** - * @param from The apr_sockaddr_t to fill in the recipient info + * @param from The fspr_sockaddr_t to fill in the recipient info * @param sock The socket to use * @param flags The flags to use * @param buf The buffer to use * @param len The length of the available buffer */ -APR_DECLARE(apr_status_t) apr_socket_recvfrom(apr_sockaddr_t *from, - apr_socket_t *sock, - apr_int32_t flags, char *buf, - apr_size_t *len); +APR_DECLARE(fspr_status_t) fspr_socket_recvfrom(fspr_sockaddr_t *from, + fspr_socket_t *sock, + fspr_int32_t flags, char *buf, + fspr_size_t *len); #if APR_HAS_SENDFILE || defined(DOXYGEN) @@ -533,18 +533,18 @@ APR_DECLARE(apr_status_t) apr_socket_recvfrom(apr_sockaddr_t *from, * including headers, file, and trailers * @param flags APR flags that are mapped to OS specific flags * @remark This functions acts like a blocking write by default. To change - * this behavior, use apr_socket_timeout_set() or the + * this behavior, use fspr_socket_timeout_set() or the * APR_SO_NONBLOCK socket option. * The number of bytes actually sent is stored in the len parameter. * The offset parameter is passed by reference for no reason; its - * value will never be modified by the apr_socket_sendfile() function. + * value will never be modified by the fspr_socket_sendfile() function. */ -APR_DECLARE(apr_status_t) apr_socket_sendfile(apr_socket_t *sock, - apr_file_t *file, - apr_hdtr_t *hdtr, - apr_off_t *offset, - apr_size_t *len, - apr_int32_t flags); +APR_DECLARE(fspr_status_t) fspr_socket_sendfile(fspr_socket_t *sock, + fspr_file_t *file, + fspr_hdtr_t *hdtr, + fspr_off_t *offset, + fspr_size_t *len, + fspr_int32_t flags); #endif /* APR_HAS_SENDFILE */ @@ -557,7 +557,7 @@ APR_DECLARE(apr_status_t) apr_socket_sendfile(apr_socket_t *sock, * @remark *
      * This functions acts like a blocking read by default.  To change 
    - * this behavior, use apr_socket_timeout_set() or the APR_SO_NONBLOCK
    + * this behavior, use fspr_socket_timeout_set() or the APR_SO_NONBLOCK
      * socket option.
      * The number of bytes actually received is stored in argument 3.
      *
    @@ -567,8 +567,8 @@ APR_DECLARE(apr_status_t) apr_socket_sendfile(apr_socket_t *sock,
      * APR_EINTR is never returned.
      * 
    */ -APR_DECLARE(apr_status_t) apr_socket_recv(apr_socket_t *sock, - char *buf, apr_size_t *len); +APR_DECLARE(fspr_status_t) fspr_socket_recv(fspr_socket_t *sock, + char *buf, fspr_size_t *len); /** * Setup socket options for the specified socket @@ -592,8 +592,8 @@ APR_DECLARE(apr_status_t) apr_socket_recv(apr_socket_t *sock, * * @param on Value for the option. */ -APR_DECLARE(apr_status_t) apr_socket_opt_set(apr_socket_t *sock, - apr_int32_t opt, apr_int32_t on); +APR_DECLARE(fspr_status_t) fspr_socket_opt_set(fspr_socket_t *sock, + fspr_int32_t opt, fspr_int32_t on); /** * Setup socket timeout for the specified socket @@ -606,8 +606,8 @@ APR_DECLARE(apr_status_t) apr_socket_opt_set(apr_socket_t *sock, * t < 0 -- read and write calls block * */ -APR_DECLARE(apr_status_t) apr_socket_timeout_set(apr_socket_t *sock, - apr_interval_time_t t); +APR_DECLARE(fspr_status_t) fspr_socket_timeout_set(fspr_socket_t *sock, + fspr_interval_time_t t); /** * Query socket options for the specified socket @@ -628,14 +628,14 @@ APR_DECLARE(apr_status_t) apr_socket_timeout_set(apr_socket_t *sock, * * @param on Socket option returned on the call. */ -APR_DECLARE(apr_status_t) apr_socket_opt_get(apr_socket_t *sock, - apr_int32_t opt, apr_int32_t *on); +APR_DECLARE(fspr_status_t) fspr_socket_opt_get(fspr_socket_t *sock, + fspr_int32_t opt, fspr_int32_t *on); /** * Get Socket fd for the socket passed * @param sock The socket to quesry for the socket fd */ -APR_DECLARE(int) apr_socket_fd_get(apr_socket_t *sock); +APR_DECLARE(int) fspr_socket_fd_get(fspr_socket_t *sock); /** @@ -643,8 +643,8 @@ APR_DECLARE(int) apr_socket_fd_get(apr_socket_t *sock); * @param sock The socket to query * @param t Socket timeout returned from the query. */ -APR_DECLARE(apr_status_t) apr_socket_timeout_get(apr_socket_t *sock, - apr_interval_time_t *t); +APR_DECLARE(fspr_status_t) fspr_socket_timeout_get(fspr_socket_t *sock, + fspr_interval_time_t *t); /** * Query the specified socket if at the OOB/Urgent data mark @@ -652,28 +652,28 @@ APR_DECLARE(apr_status_t) apr_socket_timeout_get(apr_socket_t *sock, * @param atmark Is set to true if socket is at the OOB/urgent mark, * otherwise is set to false. */ -APR_DECLARE(apr_status_t) apr_socket_atmark(apr_socket_t *sock, +APR_DECLARE(fspr_status_t) fspr_socket_atmark(fspr_socket_t *sock, int *atmark); /** - * Return an apr_sockaddr_t from an apr_socket_t - * @param sa The returned apr_sockaddr_t. - * @param which Which interface do we want the apr_sockaddr_t for? + * Return an fspr_sockaddr_t from an fspr_socket_t + * @param sa The returned fspr_sockaddr_t. + * @param which Which interface do we want the fspr_sockaddr_t for? * @param sock The socket to use */ -APR_DECLARE(apr_status_t) apr_socket_addr_get(apr_sockaddr_t **sa, - apr_interface_e which, - apr_socket_t *sock); +APR_DECLARE(fspr_status_t) fspr_socket_addr_get(fspr_sockaddr_t **sa, + fspr_interface_e which, + fspr_socket_t *sock); /** * Return the IP address (in numeric address string format) in * an APR socket address. APR will allocate storage for the IP address - * string from the pool of the apr_sockaddr_t. + * string from the pool of the fspr_sockaddr_t. * @param addr The IP address. * @param sockaddr The socket address to reference. */ -APR_DECLARE(apr_status_t) apr_sockaddr_ip_get(char **addr, - apr_sockaddr_t *sockaddr); +APR_DECLARE(fspr_status_t) fspr_sockaddr_ip_get(char **addr, + fspr_sockaddr_t *sockaddr); /** * See if the IP addresses in two APR socket addresses are @@ -685,23 +685,23 @@ APR_DECLARE(apr_status_t) apr_sockaddr_ip_get(char **addr, * @remark The return value will be non-zero if the addresses * are equivalent. */ -APR_DECLARE(int) apr_sockaddr_equal(const apr_sockaddr_t *addr1, - const apr_sockaddr_t *addr2); +APR_DECLARE(int) fspr_sockaddr_equal(const fspr_sockaddr_t *addr1, + const fspr_sockaddr_t *addr2); /** * Return the type of the socket. * @param sock The socket to query. * @param type The returned type (e.g., SOCK_STREAM). */ -APR_DECLARE(apr_status_t) apr_socket_type_get(apr_socket_t *sock, +APR_DECLARE(fspr_status_t) fspr_socket_type_get(fspr_socket_t *sock, int *type); /** - * Given an apr_sockaddr_t and a service name, set the port for the service - * @param sockaddr The apr_sockaddr_t that will have its port set + * Given an fspr_sockaddr_t and a service name, set the port for the service + * @param sockaddr The fspr_sockaddr_t that will have its port set * @param servname The name of the service you wish to use */ -APR_DECLARE(apr_status_t) apr_getservbyname(apr_sockaddr_t *sockaddr, +APR_DECLARE(fspr_status_t) fspr_getservbyname(fspr_sockaddr_t *sockaddr, const char *servname); /** * Build an ip-subnet representation from an IP address and optional netmask or @@ -711,19 +711,19 @@ APR_DECLARE(apr_status_t) apr_getservbyname(apr_sockaddr_t *sockaddr, * @param mask_or_numbits The input netmask or number-of-bits string, or NULL * @param p The pool to allocate from */ -APR_DECLARE(apr_status_t) apr_ipsubnet_create(apr_ipsubnet_t **ipsub, +APR_DECLARE(fspr_status_t) fspr_ipsubnet_create(fspr_ipsubnet_t **ipsub, const char *ipstr, const char *mask_or_numbits, - apr_pool_t *p); + fspr_pool_t *p); /** - * Test the IP address in an apr_sockaddr_t against a pre-built ip-subnet + * Test the IP address in an fspr_sockaddr_t against a pre-built ip-subnet * representation. * @param ipsub The ip-subnet representation * @param sa The socket address to test * @return non-zero if the socket address is within the subnet, 0 otherwise */ -APR_DECLARE(int) apr_ipsubnet_test(apr_ipsubnet_t *ipsub, apr_sockaddr_t *sa); +APR_DECLARE(int) fspr_ipsubnet_test(fspr_ipsubnet_t *ipsub, fspr_sockaddr_t *sa); #if APR_HAS_SO_ACCEPTFILTER || defined(DOXYGEN) /** @@ -733,7 +733,7 @@ APR_DECLARE(int) apr_ipsubnet_test(apr_ipsubnet_t *ipsub, apr_sockaddr_t *sa); * @param args Any extra args to the accept filter. Passing NULL here removes * the accept filter. */ -apr_status_t apr_socket_accept_filter(apr_socket_t *sock, char *name, +fspr_status_t fspr_socket_accept_filter(fspr_socket_t *sock, char *name, char *args); #endif @@ -742,7 +742,7 @@ apr_status_t apr_socket_accept_filter(apr_socket_t *sock, char *name, * @param sock The socket to query. * @param protocol The returned protocol (e.g., APR_PROTO_TCP). */ -APR_DECLARE(apr_status_t) apr_socket_protocol_get(apr_socket_t *sock, +APR_DECLARE(fspr_status_t) fspr_socket_protocol_get(fspr_socket_t *sock, int *protocol); /** @@ -761,7 +761,7 @@ APR_DECLARE_INHERIT_SET(socket); APR_DECLARE_INHERIT_UNSET(socket); /** - * @defgroup apr_mcast IP Multicast + * @defgroup fspr_mcast IP Multicast * @{ */ @@ -774,14 +774,14 @@ APR_DECLARE_INHERIT_UNSET(socket); * @param source Source Address to accept transmissions from (non-NULL * implies Source-Specific Multicast) */ -APR_DECLARE(apr_status_t) apr_mcast_join(apr_socket_t *sock, - apr_sockaddr_t *join, - apr_sockaddr_t *iface, - apr_sockaddr_t *source); +APR_DECLARE(fspr_status_t) fspr_mcast_join(fspr_socket_t *sock, + fspr_sockaddr_t *join, + fspr_sockaddr_t *iface, + fspr_sockaddr_t *source); /** * Leave a Multicast Group. All arguments must be the same as - * apr_mcast_join. + * fspr_mcast_join. * @param sock The socket to leave a multicast group * @param addr The address of the multicast group to leave * @param iface Address of the interface to use. If NULL is passed, the @@ -789,10 +789,10 @@ APR_DECLARE(apr_status_t) apr_mcast_join(apr_socket_t *sock, * @param source Source Address to accept transmissions from (non-NULL * implies Source-Specific Multicast) */ -APR_DECLARE(apr_status_t) apr_mcast_leave(apr_socket_t *sock, - apr_sockaddr_t *addr, - apr_sockaddr_t *iface, - apr_sockaddr_t *source); +APR_DECLARE(fspr_status_t) fspr_mcast_leave(fspr_socket_t *sock, + fspr_sockaddr_t *addr, + fspr_sockaddr_t *iface, + fspr_sockaddr_t *source); /** * Set the Multicast Time to Live (ttl) for a multicast transmission. @@ -801,16 +801,16 @@ APR_DECLARE(apr_status_t) apr_mcast_leave(apr_socket_t *sock, * @remark If the TTL is 0, packets will only be seen by sockets on * the local machine, and only when multicast loopback is enabled. */ -APR_DECLARE(apr_status_t) apr_mcast_hops(apr_socket_t *sock, - apr_byte_t ttl); +APR_DECLARE(fspr_status_t) fspr_mcast_hops(fspr_socket_t *sock, + fspr_byte_t ttl); /** * Toggle IP Multicast Loopback * @param sock The socket to set multicast loopback * @param opt 0=disable, 1=enable */ -APR_DECLARE(apr_status_t) apr_mcast_loopback(apr_socket_t *sock, - apr_byte_t opt); +APR_DECLARE(fspr_status_t) fspr_mcast_loopback(fspr_socket_t *sock, + fspr_byte_t opt); /** @@ -818,8 +818,8 @@ APR_DECLARE(apr_status_t) apr_mcast_loopback(apr_socket_t *sock, * @param sock The socket to set the multicast interface on * @param iface Address of the interface to use for Multicast */ -APR_DECLARE(apr_status_t) apr_mcast_interface(apr_socket_t *sock, - apr_sockaddr_t *iface); +APR_DECLARE(fspr_status_t) fspr_mcast_interface(fspr_socket_t *sock, + fspr_sockaddr_t *iface); /** @} */ diff --git a/libs/apr/include/apr_poll.h b/libs/apr/include/fspr_poll.h similarity index 65% rename from libs/apr/include/apr_poll.h rename to libs/apr/include/fspr_poll.h index c5266495f9..a3fa5c42f2 100644 --- a/libs/apr/include/apr_poll.h +++ b/libs/apr/include/fspr_poll.h @@ -17,15 +17,15 @@ #ifndef APR_POLL_H #define APR_POLL_H /** - * @file apr_poll.h + * @file fspr_poll.h * @brief APR Poll interface */ -#include "apr.h" -#include "apr_pools.h" -#include "apr_errno.h" -#include "apr_inherit.h" -#include "apr_file_io.h" -#include "apr_network_io.h" +#include "fspr.h" +#include "fspr_pools.h" +#include "fspr_errno.h" +#include "fspr_inherit.h" +#include "fspr_file_io.h" +#include "fspr_network_io.h" #if APR_HAVE_NETINET_IN_H #include @@ -36,7 +36,7 @@ extern "C" { #endif /* __cplusplus */ /** - * @defgroup apr_poll Poll Routines + * @defgroup fspr_poll Poll Routines * @ingroup APR * @{ */ @@ -56,30 +56,30 @@ extern "C" { */ #define APR_POLLSET_THREADSAFE 0x001 /**< Adding or Removing a Descriptor is thread safe */ -/** Used in apr_pollfd_t to determine what the apr_descriptor is */ +/** Used in fspr_pollfd_t to determine what the fspr_descriptor is */ typedef enum { APR_NO_DESC, /**< nothing here */ APR_POLL_SOCKET, /**< descriptor refers to a socket */ APR_POLL_FILE, /**< descriptor refers to a file */ APR_POLL_LASTDESC /**< descriptor is the last one in the list */ -} apr_datatype_e ; +} fspr_datatype_e ; /** Union of either an APR file or socket. */ typedef union { - apr_file_t *f; /**< file */ - apr_socket_t *s; /**< socket */ -} apr_descriptor; + fspr_file_t *f; /**< file */ + fspr_socket_t *s; /**< socket */ +} fspr_descriptor; -/** @see apr_pollfd_t */ -typedef struct apr_pollfd_t apr_pollfd_t; +/** @see fspr_pollfd_t */ +typedef struct fspr_pollfd_t fspr_pollfd_t; /** Poll descriptor set. */ -struct apr_pollfd_t { - apr_pool_t *p; /**< associated pool */ - apr_datatype_e desc_type; /**< descriptor type */ - apr_int16_t reqevents; /**< requested events */ - apr_int16_t rtnevents; /**< returned events */ - apr_descriptor desc; /**< @see apr_descriptor */ +struct fspr_pollfd_t { + fspr_pool_t *p; /**< associated pool */ + fspr_datatype_e desc_type; /**< descriptor type */ + fspr_int16_t reqevents; /**< requested events */ + fspr_int16_t rtnevents; /**< returned events */ + fspr_descriptor desc; /**< @see fspr_descriptor */ void *client_data; /**< allows app to associate context */ }; @@ -89,7 +89,7 @@ struct apr_pollfd_t { */ /** Opaque structure used for pollset API */ -typedef struct apr_pollset_t apr_pollset_t; +typedef struct fspr_pollset_t fspr_pollset_t; /** * Setup a pollset object @@ -100,21 +100,21 @@ typedef struct apr_pollset_t apr_pollset_t; * * @remark If flags equals APR_POLLSET_THREADSAFE, then a pollset is * created on which it is safe to make concurrent calls to - * apr_pollset_add(), apr_pollset_remove() and apr_pollset_poll() from + * fspr_pollset_add(), fspr_pollset_remove() and fspr_pollset_poll() from * separate threads. This feature is only supported on some - * platforms; the apr_pollset_create() call will fail with + * platforms; the fspr_pollset_create() call will fail with * APR_ENOTIMPL on platforms where it is not supported. */ -APR_DECLARE(apr_status_t) apr_pollset_create(apr_pollset_t **pollset, - apr_uint32_t size, - apr_pool_t *p, - apr_uint32_t flags); +APR_DECLARE(fspr_status_t) fspr_pollset_create(fspr_pollset_t **pollset, + fspr_uint32_t size, + fspr_pool_t *p, + fspr_uint32_t flags); /** * Destroy a pollset object * @param pollset The pollset to destroy */ -APR_DECLARE(apr_status_t) apr_pollset_destroy(apr_pollset_t *pollset); +APR_DECLARE(fspr_status_t) fspr_pollset_destroy(fspr_pollset_t *pollset); /** * Add a socket or file descriptor to a pollset @@ -122,36 +122,36 @@ APR_DECLARE(apr_status_t) apr_pollset_destroy(apr_pollset_t *pollset); * @param descriptor The descriptor to add * @remark If you set client_data in the descriptor, that value * will be returned in the client_data field whenever this - * descriptor is signalled in apr_pollset_poll(). + * descriptor is signalled in fspr_pollset_poll(). * @remark If the pollset has been created with APR_POLLSET_THREADSAFE - * and thread T1 is blocked in a call to apr_pollset_poll() for - * this same pollset that is being modified via apr_pollset_add() - * in thread T2, the currently executing apr_pollset_poll() call in + * and thread T1 is blocked in a call to fspr_pollset_poll() for + * this same pollset that is being modified via fspr_pollset_add() + * in thread T2, the currently executing fspr_pollset_poll() call in * T1 will either: (1) automatically include the newly added descriptor * in the set of descriptors it is watching or (2) return immediately * with APR_EINTR. Option (1) is recommended, but option (2) is * allowed for implementations where option (1) is impossible * or impractical. */ -APR_DECLARE(apr_status_t) apr_pollset_add(apr_pollset_t *pollset, - const apr_pollfd_t *descriptor); +APR_DECLARE(fspr_status_t) fspr_pollset_add(fspr_pollset_t *pollset, + const fspr_pollfd_t *descriptor); /** * Remove a descriptor from a pollset * @param pollset The pollset from which to remove the descriptor * @param descriptor The descriptor to remove * @remark If the pollset has been created with APR_POLLSET_THREADSAFE - * and thread T1 is blocked in a call to apr_pollset_poll() for - * this same pollset that is being modified via apr_pollset_remove() - * in thread T2, the currently executing apr_pollset_poll() call in + * and thread T1 is blocked in a call to fspr_pollset_poll() for + * this same pollset that is being modified via fspr_pollset_remove() + * in thread T2, the currently executing fspr_pollset_poll() call in * T1 will either: (1) automatically exclude the newly added descriptor * in the set of descriptors it is watching or (2) return immediately * with APR_EINTR. Option (1) is recommended, but option (2) is * allowed for implementations where option (1) is impossible * or impractical. */ -APR_DECLARE(apr_status_t) apr_pollset_remove(apr_pollset_t *pollset, - const apr_pollfd_t *descriptor); +APR_DECLARE(fspr_status_t) fspr_pollset_remove(fspr_pollset_t *pollset, + const fspr_pollfd_t *descriptor); /** * Block for activity on the descriptor(s) in a pollset @@ -160,10 +160,10 @@ APR_DECLARE(apr_status_t) apr_pollset_remove(apr_pollset_t *pollset, * @param num Number of signalled descriptors (output parameter) * @param descriptors Array of signalled descriptors (output parameter) */ -APR_DECLARE(apr_status_t) apr_pollset_poll(apr_pollset_t *pollset, - apr_interval_time_t timeout, - apr_int32_t *num, - const apr_pollfd_t **descriptors); +APR_DECLARE(fspr_status_t) fspr_pollset_poll(fspr_pollset_t *pollset, + fspr_interval_time_t timeout, + fspr_int32_t *num, + const fspr_pollfd_t **descriptors); /** @@ -178,12 +178,12 @@ APR_DECLARE(apr_status_t) apr_pollset_poll(apr_pollset_t *pollset, * @remark The number of descriptors signalled is returned in the third argument. * This is a blocking call, and it will not return until either a * descriptor has been signalled, or the timeout has expired. - * @remark The rtnevents field in the apr_pollfd_t array will only be filled- + * @remark The rtnevents field in the fspr_pollfd_t array will only be filled- * in if the return value is APR_SUCCESS. */ -APR_DECLARE(apr_status_t) apr_poll(apr_pollfd_t *aprset, apr_int32_t numsock, - apr_int32_t *nsds, - apr_interval_time_t timeout); +APR_DECLARE(fspr_status_t) fspr_poll(fspr_pollfd_t *aprset, fspr_int32_t numsock, + fspr_int32_t *nsds, + fspr_interval_time_t timeout); /** @} */ diff --git a/libs/apr/include/apr_pools.h b/libs/apr/include/fspr_pools.h similarity index 70% rename from libs/apr/include/apr_pools.h rename to libs/apr/include/fspr_pools.h index 9b7f15685a..5764b96d16 100644 --- a/libs/apr/include/apr_pools.h +++ b/libs/apr/include/fspr_pools.h @@ -18,7 +18,7 @@ #define APR_POOLS_H /** - * @file apr_pools.h + * @file fspr_pools.h * @brief APR memory allocation * * Resource allocation routines... @@ -30,61 +30,61 @@ * Instead, we maintain pools, and allocate items (both memory and I/O * handlers) from the pools --- currently there are two, one for per * transaction info, and one for config info. When a transaction is over, - * we can delete everything in the per-transaction apr_pool_t without fear, + * we can delete everything in the per-transaction fspr_pool_t without fear, * and without thinking too hard about it either. */ -#include "apr.h" -#include "apr_errno.h" -#include "apr_general.h" /* for APR_STRINGIFY */ +#include "fspr.h" +#include "fspr_errno.h" +#include "fspr_general.h" /* for APR_STRINGIFY */ #define APR_WANT_MEMFUNC /**< for no good reason? */ -#include "apr_want.h" +#include "fspr_want.h" #ifdef __cplusplus extern "C" { #endif /** - * @defgroup apr_pools Memory Pool Functions + * @defgroup fspr_pools Memory Pool Functions * @ingroup APR * @{ */ /** The fundamental pool type */ -typedef struct apr_pool_t apr_pool_t; +typedef struct fspr_pool_t fspr_pool_t; /** - * Declaration helper macro to construct apr_foo_pool_get()s. + * Declaration helper macro to construct fspr_foo_pool_get()s. * * This standardized macro is used by opaque (APR) data types to return - * the apr_pool_t that is associated with the data type. + * the fspr_pool_t that is associated with the data type. * * APR_POOL_DECLARE_ACCESSOR() is used in a header file to declare the * accessor function. A typical usage and result would be: *
      *    APR_POOL_DECLARE_ACCESSOR(file);
      * becomes:
    - *    APR_DECLARE(apr_pool_t *) apr_file_pool_get(apr_file_t *ob);
    + *    APR_DECLARE(fspr_pool_t *) fspr_file_pool_get(fspr_file_t *ob);
      * 
    * @remark Doxygen unwraps this macro (via doxygen.conf) to provide - * actual help for each specific occurance of apr_foo_pool_get. + * actual help for each specific occurance of fspr_foo_pool_get. * @remark the linkage is specified for APR. It would be possible to expand * the macros to support other linkages. */ #define APR_POOL_DECLARE_ACCESSOR(type) \ - APR_DECLARE(apr_pool_t *) apr_##type##_pool_get \ - (const apr_##type##_t *the##type) + APR_DECLARE(fspr_pool_t *) fspr_##type##_pool_get \ + (const fspr_##type##_t *the##type) /** - * Implementation helper macro to provide apr_foo_pool_get()s. + * Implementation helper macro to provide fspr_foo_pool_get()s. * * In the implementation, the APR_POOL_IMPLEMENT_ACCESSOR() is used to * actually define the function. It assumes the field is named "pool". */ #define APR_POOL_IMPLEMENT_ACCESSOR(type) \ - APR_DECLARE(apr_pool_t *) apr_##type##_pool_get \ - (const apr_##type##_t *the##type) \ + APR_DECLARE(fspr_pool_t *) fspr_##type##_pool_get \ + (const fspr_##type##_t *the##type) \ { return the##type->pool; } @@ -116,7 +116,7 @@ typedef struct apr_pool_t apr_pool_t; * combination with the verbose flag above, * it will output OWNER in such an event * prior to aborting. Use the debug - * function apr_pool_owner_set() to switch + * function fspr_pool_owner_set() to switch * a pools ownership. * * When no debug level was specified, assume general debug mode. @@ -139,7 +139,7 @@ typedef struct apr_pool_t apr_pool_t; /** A function that is called when allocation fails. */ -typedef int (*apr_abortfunc_t)(int retcode); +typedef int (*fspr_abortfunc_t)(int retcode); /* * APR memory structure manipulators (pools, tables, and arrays). @@ -152,74 +152,74 @@ typedef int (*apr_abortfunc_t)(int retcode); /** * Setup all of the internal structures required to use pools * @remark Programs do NOT need to call this directly. APR will call this - * automatically from apr_initialize. + * automatically from fspr_initialize. * @internal */ -APR_DECLARE(apr_status_t) apr_pool_initialize(void); +APR_DECLARE(fspr_status_t) fspr_pool_initialize(void); /** * Tear down all of the internal structures required to use pools * @remark Programs do NOT need to call this directly. APR will call this - * automatically from apr_terminate. + * automatically from fspr_terminate. * @internal */ -APR_DECLARE(void) apr_pool_terminate(void); +APR_DECLARE(void) fspr_pool_terminate(void); /* * Pool creation/destruction */ -#include "apr_allocator.h" +#include "fspr_allocator.h" /** * Create a new pool. * @param newpool The pool we have just created. * @param parent The parent pool. If this is NULL, the new pool is a root * pool. If it is non-NULL, the new pool will inherit all - * of its parent pool's attributes, except the apr_pool_t will + * of its parent pool's attributes, except the fspr_pool_t will * be a sub-pool. * @param abort_fn A function to use if the pool cannot allocate more memory. * @param allocator The allocator to use with the new pool. If NULL the * allocator of the parent pool will be used. */ -APR_DECLARE(apr_status_t) apr_pool_create_ex(apr_pool_t **newpool, - apr_pool_t *parent, - apr_abortfunc_t abort_fn, - apr_allocator_t *allocator); +APR_DECLARE(fspr_status_t) fspr_pool_create_ex(fspr_pool_t **newpool, + fspr_pool_t *parent, + fspr_abortfunc_t abort_fn, + fspr_allocator_t *allocator); /** - * Debug version of apr_pool_create_ex. - * @param newpool @see apr_pool_create. - * @param parent @see apr_pool_create. - * @param abort_fn @see apr_pool_create. - * @param allocator @see apr_pool_create. + * Debug version of fspr_pool_create_ex. + * @param newpool @see fspr_pool_create. + * @param parent @see fspr_pool_create. + * @param abort_fn @see fspr_pool_create. + * @param allocator @see fspr_pool_create. * @param file_line Where the function is called from. * This is usually APR_POOL__FILE_LINE__. * @remark Only available when APR_POOL_DEBUG is defined. - * Call this directly if you have you apr_pool_create_ex + * Call this directly if you have you fspr_pool_create_ex * calls in a wrapper function and wish to override * the file_line argument to reflect the caller of * your wrapper function. If you do not have - * apr_pool_create_ex in a wrapper, trust the macro - * and don't call apr_pool_create_ex_debug directly. + * fspr_pool_create_ex in a wrapper, trust the macro + * and don't call fspr_pool_create_ex_debug directly. */ -APR_DECLARE(apr_status_t) apr_pool_create_ex_debug(apr_pool_t **newpool, - apr_pool_t *parent, - apr_abortfunc_t abort_fn, - apr_allocator_t *allocator, +APR_DECLARE(fspr_status_t) fspr_pool_create_ex_debug(fspr_pool_t **newpool, + fspr_pool_t *parent, + fspr_abortfunc_t abort_fn, + fspr_allocator_t *allocator, const char *file_line); #if APR_POOL_DEBUG -#define apr_pool_create_ex(newpool, parent, abort_fn, allocator) \ - apr_pool_create_ex_debug(newpool, parent, abort_fn, allocator, \ +#define fspr_pool_create_ex(newpool, parent, abort_fn, allocator) \ + fspr_pool_create_ex_debug(newpool, parent, abort_fn, allocator, \ APR_POOL__FILE_LINE__) -APR_DECLARE(int) apr_pool_walk_tree_debug(apr_pool_t *pool, - int(*fn)(apr_pool_t *pool, void *data), +APR_DECLARE(int) fspr_pool_walk_tree_debug(fspr_pool_t *pool, + int(*fn)(fspr_pool_t *pool, void *data), void *data); -APR_DECLARE(void) apr_pool_get_stats(apr_pool_t *pool, unsigned int *alloc, unsigned int *total_alloc, unsigned int *clear); +APR_DECLARE(void) fspr_pool_get_stats(fspr_pool_t *pool, unsigned int *alloc, unsigned int *total_alloc, unsigned int *clear); #endif /** @@ -227,20 +227,20 @@ APR_DECLARE(void) apr_pool_get_stats(apr_pool_t *pool, unsigned int *alloc, unsi * @param newpool The pool we have just created. * @param parent The parent pool. If this is NULL, the new pool is a root * pool. If it is non-NULL, the new pool will inherit all - * of its parent pool's attributes, except the apr_pool_t will + * of its parent pool's attributes, except the fspr_pool_t will * be a sub-pool. */ #if defined(DOXYGEN) -APR_DECLARE(apr_status_t) apr_pool_create(apr_pool_t **newpool, - apr_pool_t *parent); +APR_DECLARE(fspr_status_t) fspr_pool_create(fspr_pool_t **newpool, + fspr_pool_t *parent); #else #if APR_POOL_DEBUG -#define apr_pool_create(newpool, parent) \ - apr_pool_create_ex_debug(newpool, parent, NULL, NULL, \ +#define fspr_pool_create(newpool, parent) \ + fspr_pool_create_ex_debug(newpool, parent, NULL, NULL, \ APR_POOL__FILE_LINE__) #else -#define apr_pool_create(newpool, parent) \ - apr_pool_create_ex(newpool, parent, NULL, NULL) +#define fspr_pool_create(newpool, parent) \ + fspr_pool_create_ex(newpool, parent, NULL, NULL) #endif #endif @@ -248,7 +248,7 @@ APR_DECLARE(apr_status_t) apr_pool_create(apr_pool_t **newpool, * Find the pools allocator * @param pool The pool to get the allocator from. */ -APR_DECLARE(apr_allocator_t *) apr_pool_allocator_get(apr_pool_t *pool); +APR_DECLARE(fspr_allocator_t *) fspr_pool_allocator_get(fspr_pool_t *pool); /** * Clear all memory in the pool and run all the cleanups. This also destroys all @@ -256,58 +256,58 @@ APR_DECLARE(apr_allocator_t *) apr_pool_allocator_get(apr_pool_t *pool); * @param p The pool to clear * @remark This does not actually free the memory, it just allows the pool * to re-use this memory for the next allocation. - * @see apr_pool_destroy() + * @see fspr_pool_destroy() */ -APR_DECLARE(void) apr_pool_clear(apr_pool_t *p); +APR_DECLARE(void) fspr_pool_clear(fspr_pool_t *p); /** - * Debug version of apr_pool_clear. - * @param p See: apr_pool_clear. + * Debug version of fspr_pool_clear. + * @param p See: fspr_pool_clear. * @param file_line Where the function is called from. * This is usually APR_POOL__FILE_LINE__. * @remark Only available when APR_POOL_DEBUG is defined. - * Call this directly if you have you apr_pool_clear + * Call this directly if you have you fspr_pool_clear * calls in a wrapper function and wish to override * the file_line argument to reflect the caller of * your wrapper function. If you do not have - * apr_pool_clear in a wrapper, trust the macro - * and don't call apr_pool_destroy_clear directly. + * fspr_pool_clear in a wrapper, trust the macro + * and don't call fspr_pool_destroy_clear directly. */ -APR_DECLARE(void) apr_pool_clear_debug(apr_pool_t *p, +APR_DECLARE(void) fspr_pool_clear_debug(fspr_pool_t *p, const char *file_line); #if APR_POOL_DEBUG -#define apr_pool_clear(p) \ - apr_pool_clear_debug(p, APR_POOL__FILE_LINE__) +#define fspr_pool_clear(p) \ + fspr_pool_clear_debug(p, APR_POOL__FILE_LINE__) #endif /** - * Destroy the pool. This takes similar action as apr_pool_clear() and then + * Destroy the pool. This takes similar action as fspr_pool_clear() and then * frees all the memory. * @param p The pool to destroy * @remark This will actually free the memory */ -APR_DECLARE(void) apr_pool_destroy(apr_pool_t *p); +APR_DECLARE(void) fspr_pool_destroy(fspr_pool_t *p); /** - * Debug version of apr_pool_destroy. - * @param p See: apr_pool_destroy. + * Debug version of fspr_pool_destroy. + * @param p See: fspr_pool_destroy. * @param file_line Where the function is called from. * This is usually APR_POOL__FILE_LINE__. * @remark Only available when APR_POOL_DEBUG is defined. - * Call this directly if you have you apr_pool_destroy + * Call this directly if you have you fspr_pool_destroy * calls in a wrapper function and wish to override * the file_line argument to reflect the caller of * your wrapper function. If you do not have - * apr_pool_destroy in a wrapper, trust the macro - * and don't call apr_pool_destroy_debug directly. + * fspr_pool_destroy in a wrapper, trust the macro + * and don't call fspr_pool_destroy_debug directly. */ -APR_DECLARE(void) apr_pool_destroy_debug(apr_pool_t *p, +APR_DECLARE(void) fspr_pool_destroy_debug(fspr_pool_t *p, const char *file_line); #if APR_POOL_DEBUG -#define apr_pool_destroy(p) \ - apr_pool_destroy_debug(p, APR_POOL__FILE_LINE__) +#define fspr_pool_destroy(p) \ + fspr_pool_destroy_debug(p, APR_POOL__FILE_LINE__) #endif @@ -321,22 +321,22 @@ APR_DECLARE(void) apr_pool_destroy_debug(apr_pool_t *p, * @param size The amount of memory to allocate * @return The allocated memory */ -APR_DECLARE(void *) apr_palloc(apr_pool_t *p, apr_size_t size); +APR_DECLARE(void *) fspr_palloc(fspr_pool_t *p, fspr_size_t size); /** - * Debug version of apr_palloc - * @param p See: apr_palloc - * @param size See: apr_palloc + * Debug version of fspr_palloc + * @param p See: fspr_palloc + * @param size See: fspr_palloc * @param file_line Where the function is called from. * This is usually APR_POOL__FILE_LINE__. - * @return See: apr_palloc + * @return See: fspr_palloc */ -APR_DECLARE(void *) apr_palloc_debug(apr_pool_t *p, apr_size_t size, +APR_DECLARE(void *) fspr_palloc_debug(fspr_pool_t *p, fspr_size_t size, const char *file_line); #if APR_POOL_DEBUG -#define apr_palloc(p, size) \ - apr_palloc_debug(p, size, APR_POOL__FILE_LINE__) +#define fspr_palloc(p, size) \ + fspr_palloc_debug(p, size, APR_POOL__FILE_LINE__) #endif /** @@ -346,25 +346,25 @@ APR_DECLARE(void *) apr_palloc_debug(apr_pool_t *p, apr_size_t size, * @return The allocated memory */ #if defined(DOXYGEN) -APR_DECLARE(void *) apr_pcalloc(apr_pool_t *p, apr_size_t size); +APR_DECLARE(void *) fspr_pcalloc(fspr_pool_t *p, fspr_size_t size); #elif !APR_POOL_DEBUG -#define apr_pcalloc(p, size) memset(apr_palloc(p, size), 0, size) +#define fspr_pcalloc(p, size) memset(fspr_palloc(p, size), 0, size) #endif /** - * Debug version of apr_pcalloc - * @param p See: apr_pcalloc - * @param size See: apr_pcalloc + * Debug version of fspr_pcalloc + * @param p See: fspr_pcalloc + * @param size See: fspr_pcalloc * @param file_line Where the function is called from. * This is usually APR_POOL__FILE_LINE__. - * @return See: apr_pcalloc + * @return See: fspr_pcalloc */ -APR_DECLARE(void *) apr_pcalloc_debug(apr_pool_t *p, apr_size_t size, +APR_DECLARE(void *) fspr_pcalloc_debug(fspr_pool_t *p, fspr_size_t size, const char *file_line); #if APR_POOL_DEBUG -#define apr_pcalloc(p, size) \ - apr_pcalloc_debug(p, size, APR_POOL__FILE_LINE__) +#define fspr_pcalloc(p, size) \ + fspr_pcalloc_debug(p, size, APR_POOL__FILE_LINE__) #endif @@ -380,22 +380,22 @@ APR_DECLARE(void *) apr_pcalloc_debug(apr_pool_t *p, apr_size_t size, * then APR will return an error and expect the calling program to * deal with the error accordingly. */ -APR_DECLARE(void) apr_pool_abort_set(apr_abortfunc_t abortfunc, - apr_pool_t *pool); +APR_DECLARE(void) fspr_pool_abort_set(fspr_abortfunc_t abortfunc, + fspr_pool_t *pool); /** * Get the abort function associated with the specified pool. * @param pool The pool for retrieving the abort function. * @return The abort function for the given pool. */ -APR_DECLARE(apr_abortfunc_t) apr_pool_abort_get(apr_pool_t *pool); +APR_DECLARE(fspr_abortfunc_t) fspr_pool_abort_get(fspr_pool_t *pool); /** * Get the parent pool of the specified pool. * @param pool The pool for retrieving the parent pool. * @return The parent of the given pool. */ -APR_DECLARE(apr_pool_t *) apr_pool_parent_get(apr_pool_t *pool); +APR_DECLARE(fspr_pool_t *) fspr_pool_parent_get(fspr_pool_t *pool); /** * Determine if pool a is an ancestor of pool b. @@ -405,17 +405,17 @@ APR_DECLARE(apr_pool_t *) apr_pool_parent_get(apr_pool_t *pool); * of all pools. * @remark if compiled with APR_POOL_DEBUG, this function will also * return true if A is a pool which has been guaranteed by the caller - * (using apr_pool_join) to have a lifetime at least as long as some + * (using fspr_pool_join) to have a lifetime at least as long as some * ancestor of pool B. */ -APR_DECLARE(int) apr_pool_is_ancestor(apr_pool_t *a, apr_pool_t *b); +APR_DECLARE(int) fspr_pool_is_ancestor(fspr_pool_t *a, fspr_pool_t *b); /** * Tag a pool (give it a name) * @param pool The pool to tag * @param tag The tag */ -APR_DECLARE(const char *) apr_pool_tag(apr_pool_t *pool, const char *tag); +APR_DECLARE(const char *) fspr_pool_tag(fspr_pool_t *pool, const char *tag); #if APR_HAS_THREADS /** @@ -424,8 +424,8 @@ APR_DECLARE(const char *) apr_pool_tag(apr_pool_t *pool, const char *tag); * @param mutex The mutex * @remark The mutex does not protect the destroy operation just the low level allocs. */ -APR_DECLARE(void) apr_pool_mutex_set(apr_pool_t *pool, - apr_thread_mutex_t *mutex); +APR_DECLARE(void) fspr_pool_mutex_set(fspr_pool_t *pool, + fspr_thread_mutex_t *mutex); #endif @@ -453,11 +453,11 @@ APR_DECLARE(void) apr_pool_mutex_set(apr_pool_t *pool, * */ -APR_DECLARE(apr_status_t) apr_pool_userdata_set( +APR_DECLARE(fspr_status_t) fspr_pool_userdata_set( const void *data, const char *key, - apr_status_t (*cleanup)(void *), - apr_pool_t *pool); + fspr_status_t (*cleanup)(void *), + fspr_pool_t *pool); /** * Set the data associated with the current pool @@ -465,24 +465,24 @@ APR_DECLARE(apr_status_t) apr_pool_userdata_set( * @param key The key to use for association * @param cleanup The cleanup program to use to cleanup the data (NULL if none) * @param pool The current pool - * @note same as apr_pool_userdata_set(), except that this version doesn't + * @note same as fspr_pool_userdata_set(), except that this version doesn't * make a copy of the key (this function is useful, for example, when * the key is a string literal) * @warning This should NOT be used if the key could change addresses by - * any means between the apr_pool_userdata_setn() call and a - * subsequent apr_pool_userdata_get() on that key, such as if a + * any means between the fspr_pool_userdata_setn() call and a + * subsequent fspr_pool_userdata_get() on that key, such as if a * static string is used as a userdata key in a DSO and the DSO could * be unloaded and reloaded between the _setn() and the _get(). You - * MUST use apr_pool_userdata_set() in such cases. + * MUST use fspr_pool_userdata_set() in such cases. * @warning More generally, the key and the data to be attached to the * pool should have a life span at least as long as the pool itself. * */ -APR_DECLARE(apr_status_t) apr_pool_userdata_setn( +APR_DECLARE(fspr_status_t) fspr_pool_userdata_setn( const void *data, const char *key, - apr_status_t (*cleanup)(void *), - apr_pool_t *pool); + fspr_status_t (*cleanup)(void *), + fspr_pool_t *pool); /** * Return the data associated with the current pool. @@ -490,8 +490,8 @@ APR_DECLARE(apr_status_t) apr_pool_userdata_setn( * @param key The key for the data to retrieve * @param pool The current pool. */ -APR_DECLARE(apr_status_t) apr_pool_userdata_get(void **data, const char *key, - apr_pool_t *pool); +APR_DECLARE(fspr_status_t) fspr_pool_userdata_get(void **data, const char *key, + fspr_pool_t *pool); /** @@ -517,11 +517,11 @@ APR_DECLARE(apr_status_t) apr_pool_userdata_get(void **data, const char *key, * @param child_cleanup The function to call when a child process is about * to exec - this function is called in the child, obviously! */ -APR_DECLARE(void) apr_pool_cleanup_register( - apr_pool_t *p, +APR_DECLARE(void) fspr_pool_cleanup_register( + fspr_pool_t *p, const void *data, - apr_status_t (*plain_cleanup)(void *), - apr_status_t (*child_cleanup)(void *)); + fspr_status_t (*plain_cleanup)(void *), + fspr_status_t (*child_cleanup)(void *)); /** * Remove a previously registered cleanup function. @@ -535,8 +535,8 @@ APR_DECLARE(void) apr_pool_cleanup_register( * @remarks For some strange reason only the plain_cleanup is handled by this * function */ -APR_DECLARE(void) apr_pool_cleanup_kill(apr_pool_t *p, const void *data, - apr_status_t (*cleanup)(void *)); +APR_DECLARE(void) fspr_pool_cleanup_kill(fspr_pool_t *p, const void *data, + fspr_status_t (*cleanup)(void *)); /** * Replace the child cleanup function of a previously registered cleanup. @@ -550,11 +550,11 @@ APR_DECLARE(void) apr_pool_cleanup_kill(apr_pool_t *p, const void *data, * @param plain_cleanup The plain cleanup function of the registered cleanup * @param child_cleanup The function to register as the child cleanup */ -APR_DECLARE(void) apr_pool_child_cleanup_set( - apr_pool_t *p, +APR_DECLARE(void) fspr_pool_child_cleanup_set( + fspr_pool_t *p, const void *data, - apr_status_t (*plain_cleanup)(void *), - apr_status_t (*child_cleanup)(void *)); + fspr_status_t (*plain_cleanup)(void *), + fspr_status_t (*child_cleanup)(void *)); /** * Run the specified cleanup function immediately and unregister it. @@ -567,19 +567,19 @@ APR_DECLARE(void) apr_pool_child_cleanup_set( * @param data The data to remove from cleanup * @param cleanup The function to remove from cleanup */ -APR_DECLARE(apr_status_t) apr_pool_cleanup_run( - apr_pool_t *p, +APR_DECLARE(fspr_status_t) fspr_pool_cleanup_run( + fspr_pool_t *p, void *data, - apr_status_t (*cleanup)(void *)); + fspr_status_t (*cleanup)(void *)); /** * An empty cleanup function. * - * Passed to apr_pool_cleanup_register() when no cleanup is required. + * Passed to fspr_pool_cleanup_register() when no cleanup is required. * * @param data The data to cleanup, will not be used by this function. */ -APR_DECLARE_NONSTD(apr_status_t) apr_pool_cleanup_null(void *data); +APR_DECLARE_NONSTD(fspr_status_t) fspr_pool_cleanup_null(void *data); /** * Run all registered child cleanups, in preparation for an exec() @@ -587,7 +587,7 @@ APR_DECLARE_NONSTD(apr_status_t) apr_pool_cleanup_null(void *data); * buffers, *don't* wait for subprocesses, and *don't* free any * memory. */ -APR_DECLARE(void) apr_pool_cleanup_for_exec(void); +APR_DECLARE(void) fspr_pool_cleanup_for_exec(void); /** @} */ @@ -615,7 +615,7 @@ APR_DECLARE(void) apr_pool_cleanup_for_exec(void); * if the data is allocated in any ancestor of T's pool. This is the * basis on which the APR_POOL_DEBUG code works -- it tests these ancestor * relationships for all data inserted into tables. APR_POOL_DEBUG also - * provides tools (apr_pool_find, and apr_pool_is_ancestor) for other + * provides tools (fspr_pool_find, and fspr_pool_is_ancestor) for other * folks to implement similar restrictions for their own data * structures. * @@ -626,7 +626,7 @@ APR_DECLARE(void) apr_pool_cleanup_for_exec(void); * is, the caller guarantees they won't destroy the sub pool * individually prior to destroying the parent pool. * - * In this case the caller must call apr_pool_join() to indicate this + * In this case the caller must call fspr_pool_join() to indicate this * guarantee to the APR_POOL_DEBUG code. * * These functions are only implemented when #APR_POOL_DEBUG is set. @@ -639,14 +639,14 @@ APR_DECLARE(void) apr_pool_cleanup_for_exec(void); * @param p The parent pool * @param sub The subpool */ -APR_DECLARE(void) apr_pool_join(apr_pool_t *p, apr_pool_t *sub); +APR_DECLARE(void) fspr_pool_join(fspr_pool_t *p, fspr_pool_t *sub); /** * Find a pool from something allocated in it. * @param mem The thing allocated in the pool * @return The pool it is allocated in */ -APR_DECLARE(apr_pool_t *) apr_pool_find(const void *mem); +APR_DECLARE(fspr_pool_t *) fspr_pool_find(const void *mem); /** * Report the number of bytes currently in the pool @@ -654,28 +654,28 @@ APR_DECLARE(apr_pool_t *) apr_pool_find(const void *mem); * @param recurse Recurse/include the subpools' sizes * @return The number of bytes */ -APR_DECLARE(apr_size_t) apr_pool_num_bytes(apr_pool_t *p, int recurse); +APR_DECLARE(fspr_size_t) fspr_pool_num_bytes(fspr_pool_t *p, int recurse); /** * Lock a pool * @param pool The pool to lock * @param flag The flag */ -APR_DECLARE(void) apr_pool_lock(apr_pool_t *pool, int flag); +APR_DECLARE(void) fspr_pool_lock(fspr_pool_t *pool, int flag); /* @} */ #else /* APR_POOL_DEBUG or DOXYGEN */ -#ifdef apr_pool_join -#undef apr_pool_join +#ifdef fspr_pool_join +#undef fspr_pool_join #endif -#define apr_pool_join(a,b) +#define fspr_pool_join(a,b) -#ifdef apr_pool_lock -#undef apr_pool_lock +#ifdef fspr_pool_lock +#undef fspr_pool_lock #endif -#define apr_pool_lock(pool, lock) +#define fspr_pool_lock(pool, lock) #endif /* APR_POOL_DEBUG or DOXYGEN */ diff --git a/libs/apr/include/apr_portable.h b/libs/apr/include/fspr_portable.h similarity index 51% rename from libs/apr/include/apr_portable.h rename to libs/apr/include/fspr_portable.h index b1b21e37b7..d4118d0cfe 100644 --- a/libs/apr/include/apr_portable.h +++ b/libs/apr/include/fspr_portable.h @@ -21,21 +21,21 @@ #ifndef APR_PORTABLE_H #define APR_PORTABLE_H /** - * @file apr_portable.h + * @file fspr_portable.h * @brief APR Portability Routines */ -#include "apr.h" -#include "apr_pools.h" -#include "apr_thread_proc.h" -#include "apr_file_io.h" -#include "apr_network_io.h" -#include "apr_errno.h" -#include "apr_global_mutex.h" -#include "apr_proc_mutex.h" -#include "apr_time.h" -#include "apr_dso.h" -#include "apr_shm.h" +#include "fspr.h" +#include "fspr_pools.h" +#include "fspr_thread_proc.h" +#include "fspr_file_io.h" +#include "fspr_network_io.h" +#include "fspr_errno.h" +#include "fspr_global_mutex.h" +#include "fspr_proc_mutex.h" +#include "fspr_time.h" +#include "fspr_dso.h" +#include "fspr_shm.h" #if APR_HAVE_DIRENT_H #include @@ -52,71 +52,71 @@ extern "C" { #endif /* __cplusplus */ /** - * @defgroup apr_portabile Portability Routines + * @defgroup fspr_portabile Portability Routines * @ingroup APR * @{ */ #ifdef WIN32 /* The primitives for Windows types */ -typedef HANDLE apr_os_file_t; -typedef HANDLE apr_os_dir_t; -typedef SOCKET apr_os_sock_t; -typedef HANDLE apr_os_proc_mutex_t; -typedef HANDLE apr_os_thread_t; -typedef HANDLE apr_os_proc_t; -typedef DWORD apr_os_threadkey_t; -typedef FILETIME apr_os_imp_time_t; -typedef SYSTEMTIME apr_os_exp_time_t; -typedef HANDLE apr_os_dso_handle_t; -typedef HANDLE apr_os_shm_t; +typedef HANDLE fspr_os_file_t; +typedef HANDLE fspr_os_dir_t; +typedef SOCKET fspr_os_sock_t; +typedef HANDLE fspr_os_proc_mutex_t; +typedef HANDLE fspr_os_thread_t; +typedef HANDLE fspr_os_proc_t; +typedef DWORD fspr_os_threadkey_t; +typedef FILETIME fspr_os_imp_time_t; +typedef SYSTEMTIME fspr_os_exp_time_t; +typedef HANDLE fspr_os_dso_handle_t; +typedef HANDLE fspr_os_shm_t; #elif defined(OS2) -typedef HFILE apr_os_file_t; -typedef HDIR apr_os_dir_t; -typedef int apr_os_sock_t; -typedef HMTX apr_os_proc_mutex_t; -typedef TID apr_os_thread_t; -typedef PID apr_os_proc_t; -typedef PULONG apr_os_threadkey_t; -typedef struct timeval apr_os_imp_time_t; -typedef struct tm apr_os_exp_time_t; -typedef HMODULE apr_os_dso_handle_t; -typedef void* apr_os_shm_t; +typedef HFILE fspr_os_file_t; +typedef HDIR fspr_os_dir_t; +typedef int fspr_os_sock_t; +typedef HMTX fspr_os_proc_mutex_t; +typedef TID fspr_os_thread_t; +typedef PID fspr_os_proc_t; +typedef PULONG fspr_os_threadkey_t; +typedef struct timeval fspr_os_imp_time_t; +typedef struct tm fspr_os_exp_time_t; +typedef HMODULE fspr_os_dso_handle_t; +typedef void* fspr_os_shm_t; #elif defined(__BEOS__) #include #include -struct apr_os_proc_mutex_t { +struct fspr_os_proc_mutex_t { sem_id sem; int32 ben; }; -typedef int apr_os_file_t; -typedef DIR apr_os_dir_t; -typedef int apr_os_sock_t; -typedef struct apr_os_proc_mutex_t apr_os_proc_mutex_t; -typedef thread_id apr_os_thread_t; -typedef thread_id apr_os_proc_t; -typedef int apr_os_threadkey_t; -typedef struct timeval apr_os_imp_time_t; -typedef struct tm apr_os_exp_time_t; -typedef image_id apr_os_dso_handle_t; -typedef void* apr_os_shm_t; +typedef int fspr_os_file_t; +typedef DIR fspr_os_dir_t; +typedef int fspr_os_sock_t; +typedef struct fspr_os_proc_mutex_t fspr_os_proc_mutex_t; +typedef thread_id fspr_os_thread_t; +typedef thread_id fspr_os_proc_t; +typedef int fspr_os_threadkey_t; +typedef struct timeval fspr_os_imp_time_t; +typedef struct tm fspr_os_exp_time_t; +typedef image_id fspr_os_dso_handle_t; +typedef void* fspr_os_shm_t; #elif defined(NETWARE) -typedef int apr_os_file_t; -typedef DIR apr_os_dir_t; -typedef int apr_os_sock_t; -typedef NXMutex_t apr_os_proc_mutex_t; -typedef NXThreadId_t apr_os_thread_t; -typedef long apr_os_proc_t; -typedef NXKey_t apr_os_threadkey_t; -typedef struct timeval apr_os_imp_time_t; -typedef struct tm apr_os_exp_time_t; -typedef void * apr_os_dso_handle_t; -typedef void* apr_os_shm_t; +typedef int fspr_os_file_t; +typedef DIR fspr_os_dir_t; +typedef int fspr_os_sock_t; +typedef NXMutex_t fspr_os_proc_mutex_t; +typedef NXThreadId_t fspr_os_thread_t; +typedef long fspr_os_proc_t; +typedef NXKey_t fspr_os_threadkey_t; +typedef struct timeval fspr_os_imp_time_t; +typedef struct tm fspr_os_exp_time_t; +typedef void * fspr_os_dso_handle_t; +typedef void* fspr_os_shm_t; #else /* Any other OS should go above this one. This is the lowest common @@ -124,7 +124,7 @@ typedef void* apr_os_shm_t; */ /** Basic OS process mutex structure. */ -struct apr_os_proc_mutex_t { +struct fspr_os_proc_mutex_t { #if APR_HAS_SYSVSEM_SERIALIZE || APR_HAS_FCNTL_SERIALIZE || APR_HAS_FLOCK_SERIALIZE /** Value used for SYS V Semaphore, FCNTL and FLOCK serialization */ int crossproc; @@ -142,46 +142,46 @@ struct apr_os_proc_mutex_t { #endif }; -typedef int apr_os_file_t; /**< native file */ -typedef DIR apr_os_dir_t; /**< native dir */ -typedef int apr_os_sock_t; /**< native dir */ -typedef struct apr_os_proc_mutex_t apr_os_proc_mutex_t; /**< native proces +typedef int fspr_os_file_t; /**< native file */ +typedef DIR fspr_os_dir_t; /**< native dir */ +typedef int fspr_os_sock_t; /**< native dir */ +typedef struct fspr_os_proc_mutex_t fspr_os_proc_mutex_t; /**< native proces * mutex */ #if APR_HAS_THREADS && APR_HAVE_PTHREAD_H -typedef pthread_t apr_os_thread_t; /**< native thread */ -typedef pthread_key_t apr_os_threadkey_t; /**< native thread address +typedef pthread_t fspr_os_thread_t; /**< native thread */ +typedef pthread_key_t fspr_os_threadkey_t; /**< native thread address * space */ #endif -typedef pid_t apr_os_proc_t; /**< native pid */ -typedef struct timeval apr_os_imp_time_t; /**< native timeval */ -typedef struct tm apr_os_exp_time_t; /**< native tm */ -/** @var apr_os_dso_handle_t +typedef pid_t fspr_os_proc_t; /**< native pid */ +typedef struct timeval fspr_os_imp_time_t; /**< native timeval */ +typedef struct tm fspr_os_exp_time_t; /**< native tm */ +/** @var fspr_os_dso_handle_t * native dso types */ #if defined(HPUX) || defined(HPUX10) || defined(HPUX11) #include -typedef shl_t apr_os_dso_handle_t; +typedef shl_t fspr_os_dso_handle_t; #elif defined(DARWIN) #include -typedef NSModule apr_os_dso_handle_t; +typedef NSModule fspr_os_dso_handle_t; #else -typedef void * apr_os_dso_handle_t; +typedef void * fspr_os_dso_handle_t; #endif -typedef void* apr_os_shm_t; /**< native SHM */ +typedef void* fspr_os_shm_t; /**< native SHM */ #endif /** - * @typedef apr_os_sock_info_t + * @typedef fspr_os_sock_info_t * @brief alias for local OS socket */ /** * everything APR needs to know about an active socket to construct * an APR socket from it; currently, this is platform-independent */ -struct apr_os_sock_info_t { - apr_os_sock_t *os_sock; /**< always required */ +struct fspr_os_sock_info_t { + fspr_os_sock_t *os_sock; /**< always required */ struct sockaddr *local; /**< NULL if not yet bound */ struct sockaddr *remote; /**< NULL if not connected */ int family; /**< always required (APR_INET, APR_INET6, etc.) */ @@ -189,28 +189,28 @@ struct apr_os_sock_info_t { int protocol; /**< 0 or actual protocol (APR_PROTO_SCTP, APR_PROTO_TCP, etc.) */ }; -typedef struct apr_os_sock_info_t apr_os_sock_info_t; +typedef struct fspr_os_sock_info_t fspr_os_sock_info_t; #if APR_PROC_MUTEX_IS_GLOBAL || defined(DOXYGEN) /** Opaque global mutex type */ -#define apr_os_global_mutex_t apr_os_proc_mutex_t -/** @return apr_os_global_mutex */ -#define apr_os_global_mutex_get apr_os_proc_mutex_get +#define fspr_os_global_mutex_t fspr_os_proc_mutex_t +/** @return fspr_os_global_mutex */ +#define fspr_os_global_mutex_get fspr_os_proc_mutex_get #else /** Thread and process mutex for those platforms where process mutexes * are not held in threads. */ - struct apr_os_global_mutex_t { - apr_pool_t *pool; - apr_proc_mutex_t *proc_mutex; + struct fspr_os_global_mutex_t { + fspr_pool_t *pool; + fspr_proc_mutex_t *proc_mutex; #if APR_HAS_THREADS - apr_thread_mutex_t *thread_mutex; + fspr_thread_mutex_t *thread_mutex; #endif /* APR_HAS_THREADS */ }; - typedef struct apr_os_global_mutex_t apr_os_global_mutex_t; + typedef struct fspr_os_global_mutex_t fspr_os_global_mutex_t; -APR_DECLARE(apr_status_t) apr_os_global_mutex_get(apr_os_global_mutex_t *ospmutex, - apr_global_mutex_t *pmutex); +APR_DECLARE(fspr_status_t) fspr_os_global_mutex_get(fspr_os_global_mutex_t *ospmutex, + fspr_global_mutex_t *pmutex); #endif @@ -221,60 +221,60 @@ APR_DECLARE(apr_status_t) apr_os_global_mutex_get(apr_os_global_mutex_t *ospmute * @remark On Unix, it is only possible to get a file descriptor from * an apr file type. */ -APR_DECLARE(apr_status_t) apr_os_file_get(apr_os_file_t *thefile, - apr_file_t *file); +APR_DECLARE(fspr_status_t) fspr_os_file_get(fspr_os_file_t *thefile, + fspr_file_t *file); /** * convert the dir from apr type to os specific type. * @param thedir The os specific dir we are converting to * @param dir The apr dir to convert. */ -APR_DECLARE(apr_status_t) apr_os_dir_get(apr_os_dir_t **thedir, - apr_dir_t *dir); +APR_DECLARE(fspr_status_t) fspr_os_dir_get(fspr_os_dir_t **thedir, + fspr_dir_t *dir); /** * Convert the socket from an apr type to an OS specific socket * @param thesock The socket to convert. * @param sock The os specifc equivelant of the apr socket.. */ -APR_DECLARE(apr_status_t) apr_os_sock_get(apr_os_sock_t *thesock, - apr_socket_t *sock); +APR_DECLARE(fspr_status_t) fspr_os_sock_get(fspr_os_sock_t *thesock, + fspr_socket_t *sock); /** * Convert the proc mutex from os specific type to apr type * @param ospmutex The os specific proc mutex we are converting to. * @param pmutex The apr proc mutex to convert. */ -APR_DECLARE(apr_status_t) apr_os_proc_mutex_get(apr_os_proc_mutex_t *ospmutex, - apr_proc_mutex_t *pmutex); +APR_DECLARE(fspr_status_t) fspr_os_proc_mutex_get(fspr_os_proc_mutex_t *ospmutex, + fspr_proc_mutex_t *pmutex); /** * Get the exploded time in the platforms native format. * @param ostime the native time format * @param aprtime the time to convert */ -APR_DECLARE(apr_status_t) apr_os_exp_time_get(apr_os_exp_time_t **ostime, - apr_time_exp_t *aprtime); +APR_DECLARE(fspr_status_t) fspr_os_exp_time_get(fspr_os_exp_time_t **ostime, + fspr_time_exp_t *aprtime); /** * Get the imploded time in the platforms native format. * @param ostime the native time format * @param aprtime the time to convert */ -APR_DECLARE(apr_status_t) apr_os_imp_time_get(apr_os_imp_time_t **ostime, - apr_time_t *aprtime); +APR_DECLARE(fspr_status_t) fspr_os_imp_time_get(fspr_os_imp_time_t **ostime, + fspr_time_t *aprtime); /** * convert the shm from apr type to os specific type. * @param osshm The os specific shm representation * @param shm The apr shm to convert. */ -APR_DECLARE(apr_status_t) apr_os_shm_get(apr_os_shm_t *osshm, - apr_shm_t *shm); +APR_DECLARE(fspr_status_t) fspr_os_shm_get(fspr_os_shm_t *osshm, + fspr_shm_t *shm); #if APR_HAS_THREADS || defined(DOXYGEN) /** - * @defgroup apr_os_thread Thread portability Routines + * @defgroup fspr_os_thread Thread portability Routines * @{ */ /** @@ -282,16 +282,16 @@ APR_DECLARE(apr_status_t) apr_os_shm_get(apr_os_shm_t *osshm, * @param thethd The apr thread to convert * @param thd The os specific thread we are converting to */ -APR_DECLARE(apr_status_t) apr_os_thread_get(apr_os_thread_t **thethd, - apr_thread_t *thd); +APR_DECLARE(fspr_status_t) fspr_os_thread_get(fspr_os_thread_t **thethd, + fspr_thread_t *thd); /** * convert the thread private memory key to os specific type from an apr type. * @param thekey The apr handle we are converting from. * @param key The os specific handle we are converting to. */ -APR_DECLARE(apr_status_t) apr_os_threadkey_get(apr_os_threadkey_t *thekey, - apr_threadkey_t *key); +APR_DECLARE(fspr_status_t) fspr_os_threadkey_get(fspr_os_threadkey_t *thekey, + fspr_threadkey_t *key); /** * convert the thread from os specific type to apr type. @@ -299,9 +299,9 @@ APR_DECLARE(apr_status_t) apr_os_threadkey_get(apr_os_threadkey_t *thekey, * @param thethd The os specific thread to convert * @param cont The pool to use if it is needed. */ -APR_DECLARE(apr_status_t) apr_os_thread_put(apr_thread_t **thd, - apr_os_thread_t *thethd, - apr_pool_t *cont); +APR_DECLARE(fspr_status_t) fspr_os_thread_put(fspr_thread_t **thd, + fspr_os_thread_t *thethd, + fspr_pool_t *cont); /** * convert the thread private memory key from os specific type to apr type. @@ -309,21 +309,21 @@ APR_DECLARE(apr_status_t) apr_os_thread_put(apr_thread_t **thd, * @param thekey The os specific handle to convert * @param cont The pool to use if it is needed. */ -APR_DECLARE(apr_status_t) apr_os_threadkey_put(apr_threadkey_t **key, - apr_os_threadkey_t *thekey, - apr_pool_t *cont); +APR_DECLARE(fspr_status_t) fspr_os_threadkey_put(fspr_threadkey_t **key, + fspr_os_threadkey_t *thekey, + fspr_pool_t *cont); /** * Get the thread ID */ -APR_DECLARE(apr_os_thread_t) apr_os_thread_current(void); +APR_DECLARE(fspr_os_thread_t) fspr_os_thread_current(void); /** * Compare two thread id's * @param tid1 1st Thread ID to compare * @param tid2 2nd Thread ID to compare */ -APR_DECLARE(int) apr_os_thread_equal(apr_os_thread_t tid1, - apr_os_thread_t tid2); +APR_DECLARE(int) fspr_os_thread_equal(fspr_os_thread_t tid1, + fspr_os_thread_t tid2); /** @} */ #endif /* APR_HAS_THREADS */ @@ -337,9 +337,9 @@ APR_DECLARE(int) apr_os_thread_equal(apr_os_thread_t tid1, * @remark On Unix, it is only possible to put a file descriptor into * an apr file type. */ -APR_DECLARE(apr_status_t) apr_os_file_put(apr_file_t **file, - apr_os_file_t *thefile, - apr_int32_t flags, apr_pool_t *cont); +APR_DECLARE(fspr_status_t) fspr_os_file_put(fspr_file_t **file, + fspr_os_file_t *thefile, + fspr_int32_t flags, fspr_pool_t *cont); /** * convert the file from os specific type to apr type. @@ -349,24 +349,24 @@ APR_DECLARE(apr_status_t) apr_os_file_put(apr_file_t **file, * @remark On Unix, it is only possible to put a file descriptor into * an apr file type. */ -APR_DECLARE(apr_status_t) apr_os_pipe_put(apr_file_t **file, - apr_os_file_t *thefile, - apr_pool_t *cont); +APR_DECLARE(fspr_status_t) fspr_os_pipe_put(fspr_file_t **file, + fspr_os_file_t *thefile, + fspr_pool_t *cont); /** * convert the file from os specific type to apr type. * @param file The apr file we are converting to. * @param thefile The os specific pipe to convert - * @param register_cleanup A cleanup will be registered on the apr_file_t - * to issue apr_file_close(). + * @param register_cleanup A cleanup will be registered on the fspr_file_t + * to issue fspr_file_close(). * @param cont The pool to use if it is needed. * @remark On Unix, it is only possible to put a file descriptor into * an apr file type. */ -APR_DECLARE(apr_status_t) apr_os_pipe_put_ex(apr_file_t **file, - apr_os_file_t *thefile, +APR_DECLARE(fspr_status_t) fspr_os_pipe_put_ex(fspr_file_t **file, + fspr_os_file_t *thefile, int register_cleanup, - apr_pool_t *cont); + fspr_pool_t *cont); /** * convert the dir from os specific type to apr type. @@ -374,35 +374,35 @@ APR_DECLARE(apr_status_t) apr_os_pipe_put_ex(apr_file_t **file, * @param thedir The os specific dir to convert * @param cont The pool to use when creating to apr directory. */ -APR_DECLARE(apr_status_t) apr_os_dir_put(apr_dir_t **dir, - apr_os_dir_t *thedir, - apr_pool_t *cont); +APR_DECLARE(fspr_status_t) fspr_os_dir_put(fspr_dir_t **dir, + fspr_os_dir_t *thedir, + fspr_pool_t *cont); /** * Convert a socket from the os specific type to the apr type * @param sock The pool to use. * @param thesock The socket to convert to. * @param cont The socket we are converting to an apr type. - * @remark If it is a true socket, it is best to call apr_os_sock_make() + * @remark If it is a true socket, it is best to call fspr_os_sock_make() * and provide APR with more information about the socket. */ -APR_DECLARE(apr_status_t) apr_os_sock_put(apr_socket_t **sock, - apr_os_sock_t *thesock, - apr_pool_t *cont); +APR_DECLARE(fspr_status_t) fspr_os_sock_put(fspr_socket_t **sock, + fspr_os_sock_t *thesock, + fspr_pool_t *cont); /** * Create a socket from an existing descriptor and local and remote * socket addresses. - * @param apr_sock The new socket that has been set up + * @param fspr_sock The new socket that has been set up * @param os_sock_info The os representation of the socket handle and * other characteristics of the socket * @param cont The pool to use * @remark If you only know the descriptor/handle or if it isn't really - * a true socket, use apr_os_sock_put() instead. + * a true socket, use fspr_os_sock_put() instead. */ -APR_DECLARE(apr_status_t) apr_os_sock_make(apr_socket_t **apr_sock, - apr_os_sock_info_t *os_sock_info, - apr_pool_t *cont); +APR_DECLARE(fspr_status_t) fspr_os_sock_make(fspr_socket_t **fspr_sock, + fspr_os_sock_info_t *os_sock_info, + fspr_pool_t *cont); /** * Convert the proc mutex from os specific type to apr type @@ -410,9 +410,9 @@ APR_DECLARE(apr_status_t) apr_os_sock_make(apr_socket_t **apr_sock, * @param ospmutex The os specific proc mutex to convert. * @param cont The pool to use if it is needed. */ -APR_DECLARE(apr_status_t) apr_os_proc_mutex_put(apr_proc_mutex_t **pmutex, - apr_os_proc_mutex_t *ospmutex, - apr_pool_t *cont); +APR_DECLARE(fspr_status_t) fspr_os_proc_mutex_put(fspr_proc_mutex_t **pmutex, + fspr_os_proc_mutex_t *ospmutex, + fspr_pool_t *cont); /** * Put the imploded time in the APR format. @@ -420,9 +420,9 @@ APR_DECLARE(apr_status_t) apr_os_proc_mutex_put(apr_proc_mutex_t **pmutex, * @param ostime the time to convert * @param cont the pool to use if necessary */ -APR_DECLARE(apr_status_t) apr_os_imp_time_put(apr_time_t *aprtime, - apr_os_imp_time_t **ostime, - apr_pool_t *cont); +APR_DECLARE(fspr_status_t) fspr_os_imp_time_put(fspr_time_t *aprtime, + fspr_os_imp_time_t **ostime, + fspr_pool_t *cont); /** * Put the exploded time in the APR format. @@ -430,9 +430,9 @@ APR_DECLARE(apr_status_t) apr_os_imp_time_put(apr_time_t *aprtime, * @param ostime the time to convert * @param cont the pool to use if necessary */ -APR_DECLARE(apr_status_t) apr_os_exp_time_put(apr_time_exp_t *aprtime, - apr_os_exp_time_t **ostime, - apr_pool_t *cont); +APR_DECLARE(fspr_status_t) fspr_os_exp_time_put(fspr_time_exp_t *aprtime, + fspr_os_exp_time_t **ostime, + fspr_pool_t *cont); /** * convert the shared memory from os specific type to apr type. @@ -443,14 +443,14 @@ APR_DECLARE(apr_status_t) apr_os_exp_time_put(apr_time_exp_t *aprtime, * the memory block mapped. On non-fork architectures, this is typically * some internal handle to pass the mapping from process to process. */ -APR_DECLARE(apr_status_t) apr_os_shm_put(apr_shm_t **shm, - apr_os_shm_t *osshm, - apr_pool_t *cont); +APR_DECLARE(fspr_status_t) fspr_os_shm_put(fspr_shm_t **shm, + fspr_os_shm_t *osshm, + fspr_pool_t *cont); #if APR_HAS_DSO || defined(DOXYGEN) /** - * @defgroup apr_os_dso DSO (Dynamic Loading) Portabiliity Routines + * @defgroup fspr_os_dso DSO (Dynamic Loading) Portabiliity Routines * @{ */ /** @@ -459,23 +459,23 @@ APR_DECLARE(apr_status_t) apr_os_shm_put(apr_shm_t **shm, * @param thedso the os specific handle to convert * @param pool the pool to use if it is needed */ -APR_DECLARE(apr_status_t) apr_os_dso_handle_put(apr_dso_handle_t **dso, - apr_os_dso_handle_t thedso, - apr_pool_t *pool); +APR_DECLARE(fspr_status_t) fspr_os_dso_handle_put(fspr_dso_handle_t **dso, + fspr_os_dso_handle_t thedso, + fspr_pool_t *pool); /** * convert the apr dso handle into an os specific one * @param aprdso The apr dso handle to convert * @param dso The os specific dso to return */ -APR_DECLARE(apr_status_t) apr_os_dso_handle_get(apr_os_dso_handle_t *dso, - apr_dso_handle_t *aprdso); +APR_DECLARE(fspr_status_t) fspr_os_dso_handle_get(fspr_os_dso_handle_t *dso, + fspr_dso_handle_t *aprdso); #if APR_HAS_OS_UUID /** - * Private: apr-util's apr_uuid module when supported by the platform + * Private: apr-util's fspr_uuid module when supported by the platform */ -APR_DECLARE(apr_status_t) apr_os_uuid_get(unsigned char *uuid_data); +APR_DECLARE(fspr_status_t) fspr_os_uuid_get(unsigned char *uuid_data); #endif /** @} */ @@ -486,16 +486,16 @@ APR_DECLARE(apr_status_t) apr_os_uuid_get(unsigned char *uuid_data); * Get the name of the system default characer set. * @param pool the pool to allocate the name from, if needed */ -APR_DECLARE(const char*) apr_os_default_encoding(apr_pool_t *pool); +APR_DECLARE(const char*) fspr_os_default_encoding(fspr_pool_t *pool); /** * Get the name of the current locale character set. * @param pool the pool to allocate the name from, if needed - * @remark Defers to apr_os_default_encoding if the current locale's + * @remark Defers to fspr_os_default_encoding if the current locale's * data can't be retreved on this system. */ -APR_DECLARE(const char*) apr_os_locale_encoding(apr_pool_t *pool); +APR_DECLARE(const char*) fspr_os_locale_encoding(fspr_pool_t *pool); /** @} */ diff --git a/libs/apr/include/apr_proc_mutex.h b/libs/apr/include/fspr_proc_mutex.h similarity index 78% rename from libs/apr/include/apr_proc_mutex.h rename to libs/apr/include/fspr_proc_mutex.h index ceb9c82a8d..9e1b6d6b48 100644 --- a/libs/apr/include/apr_proc_mutex.h +++ b/libs/apr/include/fspr_proc_mutex.h @@ -18,20 +18,20 @@ #define APR_PROC_MUTEX_H /** - * @file apr_proc_mutex.h + * @file fspr_proc_mutex.h * @brief APR Process Locking Routines */ -#include "apr.h" -#include "apr_pools.h" -#include "apr_errno.h" +#include "fspr.h" +#include "fspr_pools.h" +#include "fspr_errno.h" #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** - * @defgroup apr_proc_mutex Process Locking Routines + * @defgroup fspr_proc_mutex Process Locking Routines * @ingroup APR * @{ */ @@ -48,10 +48,10 @@ typedef enum { APR_LOCK_PROC_PTHREAD, /**< POSIX pthread process-based locking */ APR_LOCK_POSIXSEM, /**< POSIX semaphore process-based locking */ APR_LOCK_DEFAULT /**< Use the default process lock */ -} apr_lockmech_e; +} fspr_lockmech_e; /** Opaque structure representing a process mutex. */ -typedef struct apr_proc_mutex_t apr_proc_mutex_t; +typedef struct fspr_proc_mutex_t fspr_proc_mutex_t; /* Function definitions */ @@ -72,14 +72,14 @@ typedef struct apr_proc_mutex_t apr_proc_mutex_t; * APR_LOCK_DEFAULT pick the default mechanism for the platform * * @param pool the pool from which to allocate the mutex. - * @see apr_lockmech_e + * @see fspr_lockmech_e * @warning Check APR_HAS_foo_SERIALIZE defines to see if the platform supports * APR_LOCK_foo. Only APR_LOCK_DEFAULT is portable. */ -APR_DECLARE(apr_status_t) apr_proc_mutex_create(apr_proc_mutex_t **mutex, +APR_DECLARE(fspr_status_t) fspr_proc_mutex_create(fspr_proc_mutex_t **mutex, const char *fname, - apr_lockmech_e mech, - apr_pool_t *pool); + fspr_lockmech_e mech, + fspr_pool_t *pool); /** * Re-open a mutex in a child process. @@ -87,21 +87,21 @@ APR_DECLARE(apr_status_t) apr_proc_mutex_create(apr_proc_mutex_t **mutex, * @param fname A file name to use if the mutex mechanism requires one. This * argument should always be provided. The mutex code itself will * determine if it should be used. This filename should be the - * same one that was passed to apr_proc_mutex_create(). + * same one that was passed to fspr_proc_mutex_create(). * @param pool The pool to operate on. * @remark This function must be called to maintain portability, even * if the underlying lock mechanism does not require it. */ -APR_DECLARE(apr_status_t) apr_proc_mutex_child_init(apr_proc_mutex_t **mutex, +APR_DECLARE(fspr_status_t) fspr_proc_mutex_child_init(fspr_proc_mutex_t **mutex, const char *fname, - apr_pool_t *pool); + fspr_pool_t *pool); /** * Acquire the lock for the given mutex. If the mutex is already locked, * the current thread will be put to sleep until the lock becomes available. * @param mutex the mutex on which to acquire the lock. */ -APR_DECLARE(apr_status_t) apr_proc_mutex_lock(apr_proc_mutex_t *mutex); +APR_DECLARE(fspr_status_t) fspr_proc_mutex_lock(fspr_proc_mutex_t *mutex); /** * Attempt to acquire the lock for the given mutex. If the mutex has already @@ -110,19 +110,19 @@ APR_DECLARE(apr_status_t) apr_proc_mutex_lock(apr_proc_mutex_t *mutex); * if the return value was APR_EBUSY, for portability reasons. * @param mutex the mutex on which to attempt the lock acquiring. */ -APR_DECLARE(apr_status_t) apr_proc_mutex_trylock(apr_proc_mutex_t *mutex); +APR_DECLARE(fspr_status_t) fspr_proc_mutex_trylock(fspr_proc_mutex_t *mutex); /** * Release the lock for the given mutex. * @param mutex the mutex from which to release the lock. */ -APR_DECLARE(apr_status_t) apr_proc_mutex_unlock(apr_proc_mutex_t *mutex); +APR_DECLARE(fspr_status_t) fspr_proc_mutex_unlock(fspr_proc_mutex_t *mutex); /** * Destroy the mutex and free the memory associated with the lock. * @param mutex the mutex to destroy. */ -APR_DECLARE(apr_status_t) apr_proc_mutex_destroy(apr_proc_mutex_t *mutex); +APR_DECLARE(fspr_status_t) fspr_proc_mutex_destroy(fspr_proc_mutex_t *mutex); /** * Destroy the mutex and free the memory associated with the lock. @@ -130,30 +130,30 @@ APR_DECLARE(apr_status_t) apr_proc_mutex_destroy(apr_proc_mutex_t *mutex); * @note This function is generally used to kill a cleanup on an already * created mutex */ -APR_DECLARE(apr_status_t) apr_proc_mutex_cleanup(void *mutex); +APR_DECLARE(fspr_status_t) fspr_proc_mutex_cleanup(void *mutex); /** * Return the name of the lockfile for the mutex, or NULL * if the mutex doesn't use a lock file */ -APR_DECLARE(const char *) apr_proc_mutex_lockfile(apr_proc_mutex_t *mutex); +APR_DECLARE(const char *) fspr_proc_mutex_lockfile(fspr_proc_mutex_t *mutex); /** * Display the name of the mutex, as it relates to the actual method used. * This matches the valid options for Apache's AcceptMutex directive * @param mutex the name of the mutex */ -APR_DECLARE(const char *) apr_proc_mutex_name(apr_proc_mutex_t *mutex); +APR_DECLARE(const char *) fspr_proc_mutex_name(fspr_proc_mutex_t *mutex); /** * Display the name of the default mutex: APR_LOCK_DEFAULT */ -APR_DECLARE(const char *) apr_proc_mutex_defname(void); +APR_DECLARE(const char *) fspr_proc_mutex_defname(void); /** * Get the pool used by this proc_mutex. - * @return apr_pool_t the pool + * @return fspr_pool_t the pool */ APR_POOL_DECLARE_ACCESSOR(proc_mutex); diff --git a/libs/apr/include/fspr_random.h b/libs/apr/include/fspr_random.h new file mode 100644 index 0000000000..7ba2c78dbf --- /dev/null +++ b/libs/apr/include/fspr_random.h @@ -0,0 +1,74 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APR_RANDOM_H +#define APR_RANDOM_H + +#include + +typedef struct fspr_crypto_hash_t fspr_crypto_hash_t; + +typedef void fspr_crypto_hash_init_t(fspr_crypto_hash_t *hash); +typedef void fspr_crypto_hash_add_t(fspr_crypto_hash_t *hash,const void *data, + fspr_size_t bytes); +typedef void fspr_crypto_hash_finish_t(fspr_crypto_hash_t *hash, + unsigned char *result); + +/* FIXME: make this opaque */ +struct fspr_crypto_hash_t { + fspr_crypto_hash_init_t *init; + fspr_crypto_hash_add_t *add; + fspr_crypto_hash_finish_t *finish; + fspr_size_t size; + void *data; +}; + +APR_DECLARE(fspr_crypto_hash_t *) fspr_crypto_sha256_new(fspr_pool_t *p); + +typedef struct fspr_random_t fspr_random_t; + +APR_DECLARE(void) fspr_random_init(fspr_random_t *g,fspr_pool_t *p, + fspr_crypto_hash_t *pool_hash, + fspr_crypto_hash_t *key_hash, + fspr_crypto_hash_t *prng_hash); +APR_DECLARE(fspr_random_t *) fspr_random_standard_new(fspr_pool_t *p); +APR_DECLARE(void) fspr_random_add_entropy(fspr_random_t *g, + const void *entropy_, + fspr_size_t bytes); +APR_DECLARE(fspr_status_t) fspr_random_insecure_bytes(fspr_random_t *g, + void *random, + fspr_size_t bytes); +APR_DECLARE(fspr_status_t) fspr_random_secure_bytes(fspr_random_t *g, + void *random, + fspr_size_t bytes); +APR_DECLARE(void) fspr_random_barrier(fspr_random_t *g); +APR_DECLARE(fspr_status_t) fspr_random_secure_ready(fspr_random_t *r); +APR_DECLARE(fspr_status_t) fspr_random_insecure_ready(fspr_random_t *r); + +/* Call this in the child after forking to mix the randomness + pools. Note that its generally a bad idea to fork a process with a + real PRNG in it - better to have the PRNG externally and get the + randomness from there. However, if you really must do it, then you + should supply all your entropy to all the PRNGs - don't worry, they + won't produce the same output. + + Note that fspr_proc_fork() calls this for you, so only weird + applications need ever call it themselves. +*/ +struct fspr_proc_t; +APR_DECLARE(void) fspr_random_after_fork(struct fspr_proc_t *proc); + +#endif /* ndef APR_RANDOM_H */ diff --git a/libs/apr/include/apr_ring.h b/libs/apr/include/fspr_ring.h similarity index 99% rename from libs/apr/include/apr_ring.h rename to libs/apr/include/fspr_ring.h index a360254a38..4af513b41e 100644 --- a/libs/apr/include/apr_ring.h +++ b/libs/apr/include/fspr_ring.h @@ -28,17 +28,17 @@ #define APR_RING_H /** - * @file apr_ring.h + * @file fspr_ring.h * @brief APR Rings */ /* * for offsetof() */ -#include "apr_general.h" +#include "fspr_general.h" /** - * @defgroup apr_ring Ring Macro Implementations + * @defgroup fspr_ring Ring Macro Implementations * @ingroup APR * A ring is a kind of doubly-linked list that can be manipulated * without knowing where its head is. diff --git a/libs/apr/include/apr_shm.h b/libs/apr/include/fspr_shm.h similarity index 81% rename from libs/apr/include/apr_shm.h rename to libs/apr/include/fspr_shm.h index 4875ee1ff8..81bfd994ab 100644 --- a/libs/apr/include/apr_shm.h +++ b/libs/apr/include/fspr_shm.h @@ -18,20 +18,20 @@ #define APR_SHM_H /** - * @file apr_shm.h + * @file fspr_shm.h * @brief APR Shared Memory Routines */ -#include "apr.h" -#include "apr_pools.h" -#include "apr_errno.h" +#include "fspr.h" +#include "fspr_pools.h" +#include "fspr_errno.h" #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** - * @defgroup apr_shm Shared Memory Routines + * @defgroup fspr_shm Shared Memory Routines * @ingroup APR * @{ */ @@ -40,7 +40,7 @@ extern "C" { * Private, platform-specific data struture representing a shared memory * segment. */ -typedef struct apr_shm_t apr_shm_t; +typedef struct fspr_shm_t fspr_shm_t; /** * Create and make accessable a shared memory segment. @@ -61,14 +61,14 @@ typedef struct apr_shm_t apr_shm_t; * about the segment within the actual segment. In order to supply * the caller with the requested size it may be necessary for the * implementation to request a slightly greater segment length - * from the subsystem. In all cases, the apr_shm_baseaddr_get() + * from the subsystem. In all cases, the fspr_shm_baseaddr_get() * function will return the first usable byte of memory. * */ -APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, - apr_size_t reqsize, +APR_DECLARE(fspr_status_t) fspr_shm_create(fspr_shm_t **m, + fspr_size_t reqsize, const char *filename, - apr_pool_t *pool); + fspr_pool_t *pool); /** * Remove shared memory segment associated with a filename. @@ -79,14 +79,14 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, * name-based shared memory segments, and will return APR_ENOTIMPL on * platforms without such support. */ -APR_DECLARE(apr_status_t) apr_shm_remove(const char *filename, - apr_pool_t *pool); +APR_DECLARE(fspr_status_t) fspr_shm_remove(const char *filename, + fspr_pool_t *pool); /** * Destroy a shared memory segment and associated memory. * @param m The shared memory segment structure to destroy. */ -APR_DECLARE(apr_status_t) apr_shm_destroy(apr_shm_t *m); +APR_DECLARE(fspr_status_t) fspr_shm_destroy(fspr_shm_t *m); /** * Attach to a shared memory segment that was created @@ -97,16 +97,16 @@ APR_DECLARE(apr_status_t) apr_shm_destroy(apr_shm_t *m); * @param pool the pool from which to allocate the shared memory * structure for this process. */ -APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m, +APR_DECLARE(fspr_status_t) fspr_shm_attach(fspr_shm_t **m, const char *filename, - apr_pool_t *pool); + fspr_pool_t *pool); /** * Detach from a shared memory segment without destroying it. * @param m The shared memory structure representing the segment * to detach from. */ -APR_DECLARE(apr_status_t) apr_shm_detach(apr_shm_t *m); +APR_DECLARE(fspr_status_t) fspr_shm_detach(fspr_shm_t *m); /** * Retrieve the base address of the shared memory segment. @@ -117,14 +117,14 @@ APR_DECLARE(apr_status_t) apr_shm_detach(apr_shm_t *m); * the base address. * @return address, aligned by APR_ALIGN_DEFAULT. */ -APR_DECLARE(void *) apr_shm_baseaddr_get(const apr_shm_t *m); +APR_DECLARE(void *) fspr_shm_baseaddr_get(const fspr_shm_t *m); /** * Retrieve the length of a shared memory segment in bytes. * @param m The shared memory segment from which to retrieve * the segment length. */ -APR_DECLARE(apr_size_t) apr_shm_size_get(const apr_shm_t *m); +APR_DECLARE(fspr_size_t) fspr_shm_size_get(const fspr_shm_t *m); /** * Get the pool used by this shared memory segment. diff --git a/libs/apr/include/apr_signal.h b/libs/apr/include/fspr_signal.h similarity index 81% rename from libs/apr/include/apr_signal.h rename to libs/apr/include/fspr_signal.h index 991cbadbae..6a53efa24d 100644 --- a/libs/apr/include/apr_signal.h +++ b/libs/apr/include/fspr_signal.h @@ -18,12 +18,12 @@ #define APR_SIGNAL_H /** - * @file apr_signal.h + * @file fspr_signal.h * @brief APR Signal Handling */ -#include "apr.h" -#include "apr_pools.h" +#include "fspr.h" +#include "fspr_pools.h" #if APR_HAVE_SIGNAL_H #include @@ -34,7 +34,7 @@ extern "C" { #endif /* __cplusplus */ /** - * @defgroup apr_signal Handling + * @defgroup fspr_signal Handling * @ingroup APR * @{ */ @@ -54,21 +54,21 @@ extern "C" { #endif /** Function prototype for signal handlers */ -typedef void apr_sigfunc_t(int); +typedef void fspr_sigfunc_t(int); /** * Set the signal handler function for a given signal * @param signo The signal (eg... SIGWINCH) * @param func the function to get called */ -APR_DECLARE(apr_sigfunc_t *) apr_signal(int signo, apr_sigfunc_t * func); +APR_DECLARE(fspr_sigfunc_t *) fspr_signal(int signo, fspr_sigfunc_t * func); #if defined(SIG_IGN) && !defined(SIG_ERR) -#define SIG_ERR ((apr_sigfunc_t *) -1) +#define SIG_ERR ((fspr_sigfunc_t *) -1) #endif #else /* !APR_HAVE_SIGACTION */ -#define apr_signal(a, b) signal(a, b) +#define fspr_signal(a, b) signal(a, b) #endif @@ -77,28 +77,28 @@ APR_DECLARE(apr_sigfunc_t *) apr_signal(int signo, apr_sigfunc_t * func); * @param signum The signal number * @return The description of the signal */ -APR_DECLARE(const char *) apr_signal_description_get(int signum); +APR_DECLARE(const char *) fspr_signal_description_get(int signum); /** * APR-private function for initializing the signal package * @internal * @param pglobal The internal, global pool */ -void apr_signal_init(apr_pool_t *pglobal); +void fspr_signal_init(fspr_pool_t *pglobal); /** * Block the delivery of a particular signal * @param signum The signal number * @return status */ -APR_DECLARE(apr_status_t) apr_signal_block(int signum); +APR_DECLARE(fspr_status_t) fspr_signal_block(int signum); /** * Enable the delivery of a particular signal * @param signum The signal number * @return status */ -APR_DECLARE(apr_status_t) apr_signal_unblock(int signum); +APR_DECLARE(fspr_status_t) fspr_signal_unblock(int signum); /** @} */ diff --git a/libs/apr/include/apr_strings.h b/libs/apr/include/fspr_strings.h similarity index 77% rename from libs/apr/include/apr_strings.h rename to libs/apr/include/fspr_strings.h index fcfb7777a2..27a15bdb79 100644 --- a/libs/apr/include/apr_strings.h +++ b/libs/apr/include/fspr_strings.h @@ -41,15 +41,15 @@ #define APR_STRINGS_H /** - * @file apr_strings.h + * @file fspr_strings.h * @brief APR Strings library */ -#include "apr.h" -#include "apr_errno.h" -#include "apr_pools.h" +#include "fspr.h" +#include "fspr_errno.h" +#include "fspr_pools.h" #define APR_WANT_IOVEC -#include "apr_want.h" +#include "fspr_want.h" #if APR_HAVE_STDARG_H #include @@ -60,7 +60,7 @@ extern "C" { #endif /* __cplusplus */ /** - * @defgroup apr_strings String routines + * @defgroup fspr_strings String routines * @ingroup APR * @{ */ @@ -73,7 +73,7 @@ extern "C" { * this returns <0, if they are equivalent it returns 0, and if the * first string is greater than second string it retuns >0. */ -APR_DECLARE(int) apr_strnatcmp(char const *a, char const *b); +APR_DECLARE(int) fspr_strnatcmp(char const *a, char const *b); /** * Do a natural order comparison of two strings ignoring the case of the @@ -84,7 +84,7 @@ APR_DECLARE(int) apr_strnatcmp(char const *a, char const *b); * this returns <0, if they are equivalent it returns 0, and if the * first string is greater than second string it retuns >0. */ -APR_DECLARE(int) apr_strnatcasecmp(char const *a, char const *b); +APR_DECLARE(int) fspr_strnatcasecmp(char const *a, char const *b); /** * duplicate a string into memory allocated out of a pool @@ -92,7 +92,7 @@ APR_DECLARE(int) apr_strnatcasecmp(char const *a, char const *b); * @param s The string to duplicate * @return The new string */ -APR_DECLARE(char *) apr_pstrdup(apr_pool_t *p, const char *s); +APR_DECLARE(char *) fspr_pstrdup(fspr_pool_t *p, const char *s); /** * Create a null-terminated string by making a copy of a sequence @@ -101,12 +101,12 @@ APR_DECLARE(char *) apr_pstrdup(apr_pool_t *p, const char *s); * @param s The block of characters to duplicate * @param n The number of characters to duplicate * @return The new string - * @remark This is a faster alternative to apr_pstrndup, for use + * @remark This is a faster alternative to fspr_pstrndup, for use * when you know that the string being duplicated really * has 'n' or more characters. If the string might contain - * fewer characters, use apr_pstrndup. + * fewer characters, use fspr_pstrndup. */ -APR_DECLARE(char *) apr_pstrmemdup(apr_pool_t *p, const char *s, apr_size_t n); +APR_DECLARE(char *) fspr_pstrmemdup(fspr_pool_t *p, const char *s, fspr_size_t n); /** * Duplicate at most n characters of a string into memory allocated @@ -118,7 +118,7 @@ APR_DECLARE(char *) apr_pstrmemdup(apr_pool_t *p, const char *s, apr_size_t n); * @remark The amount of memory allocated from the pool is the length * of the returned string including the NUL terminator */ -APR_DECLARE(char *) apr_pstrndup(apr_pool_t *p, const char *s, apr_size_t n); +APR_DECLARE(char *) fspr_pstrndup(fspr_pool_t *p, const char *s, fspr_size_t n); /** * Duplicate a block of memory. @@ -128,7 +128,7 @@ APR_DECLARE(char *) apr_pstrndup(apr_pool_t *p, const char *s, apr_size_t n); * @param n The number of bytes to duplicate * @return The new block of memory */ -APR_DECLARE(void *) apr_pmemdup(apr_pool_t *p, const void *m, apr_size_t n); +APR_DECLARE(void *) fspr_pmemdup(fspr_pool_t *p, const void *m, fspr_size_t n); /** * Concatenate multiple strings, allocating memory out a pool @@ -136,7 +136,7 @@ APR_DECLARE(void *) apr_pmemdup(apr_pool_t *p, const void *m, apr_size_t n); * @param ... The strings to concatenate. The final string must be NULL * @return The new string */ -APR_DECLARE_NONSTD(char *) apr_pstrcat(apr_pool_t *p, ...); +APR_DECLARE_NONSTD(char *) fspr_pstrcat(fspr_pool_t *p, ...); /** * Concatenate multiple strings specified in a writev-style vector @@ -146,8 +146,8 @@ APR_DECLARE_NONSTD(char *) apr_pstrcat(apr_pool_t *p, ...); * @param nbytes (output) strlen of new string (pass in NULL to omit) * @return The new string */ -APR_DECLARE(char *) apr_pstrcatv(apr_pool_t *p, const struct iovec *vec, - apr_size_t nvec, apr_size_t *nbytes); +APR_DECLARE(char *) fspr_pstrcatv(fspr_pool_t *p, const struct iovec *vec, + fspr_size_t nvec, fspr_size_t *nbytes); /** * printf-style style printing routine. The data is output to a string @@ -157,7 +157,7 @@ APR_DECLARE(char *) apr_pstrcatv(apr_pool_t *p, const struct iovec *vec, * @param ap The arguments to use while printing the data * @return The new string */ -APR_DECLARE(char *) apr_pvsprintf(apr_pool_t *p, const char *fmt, va_list ap); +APR_DECLARE(char *) fspr_pvsprintf(fspr_pool_t *p, const char *fmt, va_list ap); /** * printf-style style printing routine. The data is output to a string @@ -167,7 +167,7 @@ APR_DECLARE(char *) apr_pvsprintf(apr_pool_t *p, const char *fmt, va_list ap); * @param ... The arguments to use while printing the data * @return The new string */ -APR_DECLARE_NONSTD(char *) apr_psprintf(apr_pool_t *p, const char *fmt, ...) +APR_DECLARE_NONSTD(char *) fspr_psprintf(fspr_pool_t *p, const char *fmt, ...) __attribute__((format(printf,2,3))); /** @@ -184,16 +184,16 @@ APR_DECLARE_NONSTD(char *) apr_psprintf(apr_pool_t *p, const char *fmt, ...) * @remark *
      * Note the differences between this function and strncpy():
    - *  1) strncpy() doesn't always NUL terminate; apr_cpystrn() does.
    + *  1) strncpy() doesn't always NUL terminate; fspr_cpystrn() does.
      *  2) strncpy() pads the destination string with NULs, which is often 
    - *     unnecessary; apr_cpystrn() does not.
    + *     unnecessary; fspr_cpystrn() does not.
      *  3) strncpy() returns a pointer to the beginning of the dst string;
    - *     apr_cpystrn() returns a pointer to the NUL terminator of dst, 
    + *     fspr_cpystrn() returns a pointer to the NUL terminator of dst, 
      *     to allow a check for truncation.
      * 
    */ -APR_DECLARE(char *) apr_cpystrn(char *dst, const char *src, - apr_size_t dst_size); +APR_DECLARE(char *) fspr_cpystrn(char *dst, const char *src, + fspr_size_t dst_size); /** * Strip spaces from a string @@ -202,7 +202,7 @@ APR_DECLARE(char *) apr_cpystrn(char *dst, const char *src, * @param src The string to rid the spaces from. * @return The destination string, dest. */ -APR_DECLARE(char *) apr_collapse_spaces(char *dest, const char *src); +APR_DECLARE(char *) fspr_collapse_spaces(char *dest, const char *src); /** * Convert the arguments to a program from one string to an array of @@ -211,66 +211,66 @@ APR_DECLARE(char *) apr_collapse_spaces(char *dest, const char *src); * @param argv_out Output location. This is a pointer to an array of strings. * @param token_context Pool to use. */ -APR_DECLARE(apr_status_t) apr_tokenize_to_argv(const char *arg_str, +APR_DECLARE(fspr_status_t) fspr_tokenize_to_argv(const char *arg_str, char ***argv_out, - apr_pool_t *token_context); + fspr_pool_t *token_context); /** * Split a string into separate null-terminated tokens. The tokens are * delimited in the string by one or more characters from the sep * argument. * @param str The string to separate; this should be specified on the - * first call to apr_strtok() for a given string, and NULL + * first call to fspr_strtok() for a given string, and NULL * on subsequent calls. * @param sep The set of delimiters - * @param last Internal state saved by apr_strtok() between calls. + * @param last Internal state saved by fspr_strtok() between calls. * @return The next token from the string */ -APR_DECLARE(char *) apr_strtok(char *str, const char *sep, char **last); +APR_DECLARE(char *) fspr_strtok(char *str, const char *sep, char **last); /** * @defgroup APR_Strings_Snprintf snprintf implementations * @warning - * These are snprintf implementations based on apr_vformatter(). + * These are snprintf implementations based on fspr_vformatter(). * * Note that various standards and implementations disagree on the return * value of snprintf, and side-effects due to %n in the formatting string. - * apr_snprintf (and apr_vsnprintf) behaves as follows: + * fspr_snprintf (and fspr_vsnprintf) behaves as follows: * * Process the format string until the entire string is exhausted, or * the buffer fills. If the buffer fills then stop processing immediately * (so no further %n arguments are processed), and return the buffer * length. In all cases the buffer is NUL terminated. It will return the * number of characters inserted into the buffer, not including the - * terminating NUL. As a special case, if len is 0, apr_snprintf will + * terminating NUL. As a special case, if len is 0, fspr_snprintf will * return the number of characters that would have been inserted if * the buffer had been infinite (in this case, *buffer can be NULL) * - * In no event does apr_snprintf return a negative number. + * In no event does fspr_snprintf return a negative number. * @{ */ /** - * snprintf routine based on apr_vformatter. This means it understands the + * snprintf routine based on fspr_vformatter. This means it understands the * same extensions. * @param buf The buffer to write to * @param len The size of the buffer * @param format The format string * @param ... The arguments to use to fill out the format string. */ -APR_DECLARE_NONSTD(int) apr_snprintf(char *buf, apr_size_t len, +APR_DECLARE_NONSTD(int) fspr_snprintf(char *buf, fspr_size_t len, const char *format, ...) __attribute__((format(printf,3,4))); /** - * vsnprintf routine based on apr_vformatter. This means it understands the + * vsnprintf routine based on fspr_vformatter. This means it understands the * same extensions. * @param buf The buffer to write to * @param len The size of the buffer * @param format The format string * @param ap The arguments to use to fill out the format string. */ -APR_DECLARE(int) apr_vsnprintf(char *buf, apr_size_t len, const char *format, +APR_DECLARE(int) fspr_vsnprintf(char *buf, fspr_size_t len, const char *format, va_list ap); /** @} */ @@ -280,7 +280,7 @@ APR_DECLARE(int) apr_vsnprintf(char *buf, apr_size_t len, const char *format, * @param n The number to format * @return The string representation of the number */ -APR_DECLARE(char *) apr_itoa(apr_pool_t *p, int n); +APR_DECLARE(char *) fspr_itoa(fspr_pool_t *p, int n); /** * create a string representation of a long, allocated from a pool @@ -288,18 +288,18 @@ APR_DECLARE(char *) apr_itoa(apr_pool_t *p, int n); * @param n The number to format * @return The string representation of the number */ -APR_DECLARE(char *) apr_ltoa(apr_pool_t *p, long n); +APR_DECLARE(char *) fspr_ltoa(fspr_pool_t *p, long n); /** - * create a string representation of an apr_off_t, allocated from a pool + * create a string representation of an fspr_off_t, allocated from a pool * @param p The pool from which to allocate * @param n The number to format * @return The string representation of the number */ -APR_DECLARE(char *) apr_off_t_toa(apr_pool_t *p, apr_off_t n); +APR_DECLARE(char *) fspr_off_t_toa(fspr_pool_t *p, fspr_off_t n); /** - * Convert a numeric string into an apr_off_t numeric value. + * Convert a numeric string into an fspr_off_t numeric value. * @param offset The value of the parsed string. * @param buf The string to parse. It may contain optional whitespace, * followed by an optional '+' (positive, default) or '-' (negative) @@ -312,7 +312,7 @@ APR_DECLARE(char *) apr_off_t_toa(apr_pool_t *p, apr_off_t n); * digits are prefixed with '0x', in which case it will be treated as * base 16. */ -APR_DECLARE(apr_status_t) apr_strtoff(apr_off_t *offset, const char *buf, +APR_DECLARE(fspr_status_t) fspr_strtoff(fspr_off_t *offset, const char *buf, char **end, int base); /** @@ -330,25 +330,25 @@ APR_DECLARE(apr_status_t) apr_strtoff(apr_off_t *offset, const char *buf, * @return The numeric value of the string. On overflow, errno is set * to ERANGE. */ -APR_DECLARE(apr_int64_t) apr_strtoi64(const char *buf, char **end, int base); +APR_DECLARE(fspr_int64_t) fspr_strtoi64(const char *buf, char **end, int base); /** * parse a base-10 numeric string into a 64-bit numeric value. - * Equivalent to apr_strtoi64(buf, (char**)NULL, 10). + * Equivalent to fspr_strtoi64(buf, (char**)NULL, 10). * @param buf The string to parse * @return The numeric value of the string */ -APR_DECLARE(apr_int64_t) apr_atoi64(const char *buf); +APR_DECLARE(fspr_int64_t) fspr_atoi64(const char *buf); /** - * Format a binary size (magnitiudes are 2^10 rather than 10^3) from an apr_off_t, + * Format a binary size (magnitiudes are 2^10 rather than 10^3) from an fspr_off_t, * as bytes, K, M, T, etc, to a four character compacted human readable string. * @param size The size to format * @param buf The 5 byte text buffer (counting the trailing null) - * @return The buf passed to apr_strfsize() - * @remark All negative sizes report ' - ', apr_strfsize only formats positive values. + * @return The buf passed to fspr_strfsize() + * @remark All negative sizes report ' - ', fspr_strfsize only formats positive values. */ -APR_DECLARE(char *) apr_strfsize(apr_off_t size, char *buf); +APR_DECLARE(char *) fspr_strfsize(fspr_off_t size, char *buf); /** @} */ diff --git a/libs/apr/include/apr_support.h b/libs/apr/include/fspr_support.h similarity index 83% rename from libs/apr/include/apr_support.h rename to libs/apr/include/fspr_support.h index a6115172d1..3fa0611d28 100644 --- a/libs/apr/include/apr_support.h +++ b/libs/apr/include/fspr_support.h @@ -18,20 +18,20 @@ #define APR_SUPPORT_H /** - * @file apr_support.h + * @file fspr_support.h * @brief APR Support functions */ -#include "apr.h" -#include "apr_network_io.h" -#include "apr_file_io.h" +#include "fspr.h" +#include "fspr_network_io.h" +#include "fspr_file_io.h" #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** - * @defgroup apr_support Internal APR support functions + * @defgroup fspr_support Internal APR support functions * @ingroup APR * @{ */ @@ -41,7 +41,7 @@ extern "C" { * * Uses POOL for temporary allocations. */ -apr_status_t apr_wait_for_io_or_timeout(apr_file_t *f, apr_socket_t *s, +fspr_status_t fspr_wait_for_io_or_timeout(fspr_file_t *f, fspr_socket_t *s, int for_read); /** @} */ diff --git a/libs/apr/include/apr_tables.h b/libs/apr/include/fspr_tables.h similarity index 74% rename from libs/apr/include/apr_tables.h rename to libs/apr/include/fspr_tables.h index 632f5b71b4..93d7f3bf87 100644 --- a/libs/apr/include/apr_tables.h +++ b/libs/apr/include/fspr_tables.h @@ -18,12 +18,12 @@ #define APR_TABLES_H /** - * @file apr_tables.h + * @file fspr_tables.h * @brief APR Table library */ -#include "apr.h" -#include "apr_pools.h" +#include "fspr.h" +#include "fspr_pools.h" #if APR_HAVE_STDARG_H #include /* for va_list */ @@ -34,7 +34,7 @@ extern "C" { #endif /* __cplusplus */ /** - * @defgroup apr_tables Table and Array Functions + * @defgroup fspr_tables Table and Array Functions * @ingroup APR * Tables are used to store entirely opaque structures * for applications, while Arrays are usually used to @@ -43,15 +43,15 @@ extern "C" { */ /** the table abstract data type */ -typedef struct apr_table_t apr_table_t; +typedef struct fspr_table_t fspr_table_t; -/** @see apr_array_header_t */ -typedef struct apr_array_header_t apr_array_header_t; +/** @see fspr_array_header_t */ +typedef struct fspr_array_header_t fspr_array_header_t; /** An opaque array type */ -struct apr_array_header_t { +struct fspr_array_header_t { /** The pool the array is allocated out of */ - apr_pool_t *pool; + fspr_pool_t *pool; /** The amount of memory allocated for each element of the array */ int elt_size; /** The number of active elements in the array */ @@ -65,10 +65,10 @@ struct apr_array_header_t { /** * The (opaque) structure for string-content tables. */ -typedef struct apr_table_entry_t apr_table_entry_t; +typedef struct fspr_table_entry_t fspr_table_entry_t; /** The type for each entry in a string-content table */ -struct apr_table_entry_t { +struct fspr_table_entry_t { /** The key for the current table entry */ char *key; /* maybe NULL in future; * check when iterating thru table_elts @@ -76,8 +76,8 @@ struct apr_table_entry_t { /** The value for the current table entry */ char *val; - /** A checksum for the key, for use by the apr_table internals */ - apr_uint32_t key_checksum; + /** A checksum for the key, for use by the fspr_table internals */ + fspr_uint32_t key_checksum; }; /** @@ -85,21 +85,21 @@ struct apr_table_entry_t { * @param t The table * @return An array containing the contents of the table */ -APR_DECLARE(const apr_array_header_t *) apr_table_elts(const apr_table_t *t); +APR_DECLARE(const fspr_array_header_t *) fspr_table_elts(const fspr_table_t *t); /** * Determine if the table is empty * @param t The table to check * @return True if empty, False otherwise */ -APR_DECLARE(int) apr_is_empty_table(const apr_table_t *t); +APR_DECLARE(int) fspr_is_empty_table(const fspr_table_t *t); /** * Determine if the array is empty * @param a The array to check * @return True if empty, False otherwise */ -APR_DECLARE(int) apr_is_empty_array(const apr_array_header_t *a); +APR_DECLARE(int) fspr_is_empty_array(const fspr_array_header_t *a); /** * Create an array @@ -108,7 +108,7 @@ APR_DECLARE(int) apr_is_empty_array(const apr_array_header_t *a); * @param elt_size The size of each element in the array. * @return The new array */ -APR_DECLARE(apr_array_header_t *) apr_array_make(apr_pool_t *p, +APR_DECLARE(fspr_array_header_t *) fspr_array_make(fspr_pool_t *p, int nelts, int elt_size); /** @@ -118,7 +118,7 @@ APR_DECLARE(apr_array_header_t *) apr_array_make(apr_pool_t *p, * @remark If there are no free spots in the array, then this function will * allocate new space for the new element. */ -APR_DECLARE(void *) apr_array_push(apr_array_header_t *arr); +APR_DECLARE(void *) fspr_array_push(fspr_array_header_t *arr); /** A helper macro for accessing a member of an APR array. * @@ -137,7 +137,7 @@ APR_DECLARE(void *) apr_array_push(apr_array_header_t *arr); * * @return the location where the new object should be placed */ -#define APR_ARRAY_PUSH(ary,type) (*((type *)apr_array_push(ary))) +#define APR_ARRAY_PUSH(ary,type) (*((type *)fspr_array_push(ary))) /** * Remove an element from an array (as a first-in, last-out stack) @@ -145,7 +145,7 @@ APR_DECLARE(void *) apr_array_push(apr_array_header_t *arr); * @return Location of the element in the array. * @remark If there are no elements in the array, NULL is returned. */ -APR_DECLARE(void *) apr_array_pop(apr_array_header_t *arr); +APR_DECLARE(void *) fspr_array_pop(fspr_array_header_t *arr); /** * Remove all elements from an array. @@ -153,7 +153,7 @@ APR_DECLARE(void *) apr_array_pop(apr_array_header_t *arr); * @remark As the underlying storage is allocated from a pool, no * memory is freed by this operation, but is available for reuse. */ -APR_DECLARE(void) apr_array_clear(apr_array_header_t *arr); +APR_DECLARE(void) fspr_array_clear(fspr_array_header_t *arr); /** * Concatenate two arrays together @@ -161,30 +161,30 @@ APR_DECLARE(void) apr_array_clear(apr_array_header_t *arr); * array * @param src The source array to add to the destination array */ -APR_DECLARE(void) apr_array_cat(apr_array_header_t *dst, - const apr_array_header_t *src); +APR_DECLARE(void) fspr_array_cat(fspr_array_header_t *dst, + const fspr_array_header_t *src); /** * Copy the entire array * @param p The pool to allocate the copy of the array out of * @param arr The array to copy * @return An exact copy of the array passed in - * @remark The alternate apr_array_copy_hdr copies only the header, and arranges + * @remark The alternate fspr_array_copy_hdr copies only the header, and arranges * for the elements to be copied if (and only if) the code subsequently * does a push or arraycat. */ -APR_DECLARE(apr_array_header_t *) apr_array_copy(apr_pool_t *p, - const apr_array_header_t *arr); +APR_DECLARE(fspr_array_header_t *) fspr_array_copy(fspr_pool_t *p, + const fspr_array_header_t *arr); /** * Copy the headers of the array, and arrange for the elements to be copied if * and only if the code subsequently does a push or arraycat. * @param p The pool to allocate the copy of the array out of * @param arr The array to copy * @return An exact copy of the array passed in - * @remark The alternate apr_array_copy copies the *entire* array. + * @remark The alternate fspr_array_copy copies the *entire* array. */ -APR_DECLARE(apr_array_header_t *) apr_array_copy_hdr(apr_pool_t *p, - const apr_array_header_t *arr); +APR_DECLARE(fspr_array_header_t *) fspr_array_copy_hdr(fspr_pool_t *p, + const fspr_array_header_t *arr); /** * Append one array to the end of another, creating a new array in the process. @@ -193,12 +193,12 @@ APR_DECLARE(apr_array_header_t *) apr_array_copy_hdr(apr_pool_t *p, * @param second The array to put second in the new array. * @return A new array containing the data from the two arrays passed in. */ -APR_DECLARE(apr_array_header_t *) apr_array_append(apr_pool_t *p, - const apr_array_header_t *first, - const apr_array_header_t *second); +APR_DECLARE(fspr_array_header_t *) fspr_array_append(fspr_pool_t *p, + const fspr_array_header_t *first, + const fspr_array_header_t *second); /** - * Generates a new string from the apr_pool_t containing the concatenated + * Generates a new string from the fspr_pool_t containing the concatenated * sequence of substrings referenced as elements within the array. The string * will be empty if all substrings are empty or null, or if there are no * elements in the array. If sep is non-NUL, it will be inserted between @@ -208,8 +208,8 @@ APR_DECLARE(apr_array_header_t *) apr_array_append(apr_pool_t *p, * @param sep The separator to use * @return A string containing all of the data in the array. */ -APR_DECLARE(char *) apr_array_pstrcat(apr_pool_t *p, - const apr_array_header_t *arr, +APR_DECLARE(char *) fspr_array_pstrcat(fspr_pool_t *p, + const fspr_array_header_t *arr, const char sep); /** @@ -219,7 +219,7 @@ APR_DECLARE(char *) apr_array_pstrcat(apr_pool_t *p, * @return The new table. * @warning This table can only store text data */ -APR_DECLARE(apr_table_t *) apr_table_make(apr_pool_t *p, int nelts); +APR_DECLARE(fspr_table_t *) fspr_table_make(fspr_pool_t *p, int nelts); /** * Create a new table and copy another table into it @@ -227,14 +227,14 @@ APR_DECLARE(apr_table_t *) apr_table_make(apr_pool_t *p, int nelts); * @param t The table to copy * @return A copy of the table passed in */ -APR_DECLARE(apr_table_t *) apr_table_copy(apr_pool_t *p, - const apr_table_t *t); +APR_DECLARE(fspr_table_t *) fspr_table_copy(fspr_pool_t *p, + const fspr_table_t *t); /** * Delete all of the elements from a table * @param t The table to clear */ -APR_DECLARE(void) apr_table_clear(apr_table_t *t); +APR_DECLARE(void) fspr_table_clear(fspr_table_t *t); /** * Get the value associated with a given key from the table. After this call, @@ -243,7 +243,7 @@ APR_DECLARE(void) apr_table_clear(apr_table_t *t); * @param key The key to search for * @return The value associated with the key, or NULL if the key does not exist. */ -APR_DECLARE(const char *) apr_table_get(const apr_table_t *t, const char *key); +APR_DECLARE(const char *) fspr_table_get(const fspr_table_t *t, const char *key); /** * Add a key/value pair to a table, if another element already exists with the @@ -254,7 +254,7 @@ APR_DECLARE(const char *) apr_table_get(const apr_table_t *t, const char *key); * @remark When adding data, this function makes a copy of both the key and the * value. */ -APR_DECLARE(void) apr_table_set(apr_table_t *t, const char *key, +APR_DECLARE(void) fspr_table_set(fspr_table_t *t, const char *key, const char *val); /** @@ -267,7 +267,7 @@ APR_DECLARE(void) apr_table_set(apr_table_t *t, const char *key, * the value, so care should be taken to ensure that the values will * not change after they have been added.. */ -APR_DECLARE(void) apr_table_setn(apr_table_t *t, const char *key, +APR_DECLARE(void) fspr_table_setn(fspr_table_t *t, const char *key, const char *val); /** @@ -275,7 +275,7 @@ APR_DECLARE(void) apr_table_setn(apr_table_t *t, const char *key, * @param t The table to remove data from * @param key The key of the data being removed */ -APR_DECLARE(void) apr_table_unset(apr_table_t *t, const char *key); +APR_DECLARE(void) fspr_table_unset(fspr_table_t *t, const char *key); /** * Add data to a table by merging the value with data that has already been @@ -283,9 +283,9 @@ APR_DECLARE(void) apr_table_unset(apr_table_t *t, const char *key); * @param t The table to search for the data * @param key The key to merge data for * @param val The data to add - * @remark If the key is not found, then this function acts like apr_table_add + * @remark If the key is not found, then this function acts like fspr_table_add */ -APR_DECLARE(void) apr_table_merge(apr_table_t *t, const char *key, +APR_DECLARE(void) fspr_table_merge(fspr_table_t *t, const char *key, const char *val); /** @@ -294,9 +294,9 @@ APR_DECLARE(void) apr_table_merge(apr_table_t *t, const char *key, * @param t The table to search for the data * @param key The key to merge data for * @param val The data to add - * @remark If the key is not found, then this function acts like apr_table_addn + * @remark If the key is not found, then this function acts like fspr_table_addn */ -APR_DECLARE(void) apr_table_mergen(apr_table_t *t, const char *key, +APR_DECLARE(void) fspr_table_mergen(fspr_table_t *t, const char *key, const char *val); /** @@ -308,7 +308,7 @@ APR_DECLARE(void) apr_table_mergen(apr_table_t *t, const char *key, * @remark When adding data, this function makes a copy of both the key and the * value. */ -APR_DECLARE(void) apr_table_add(apr_table_t *t, const char *key, +APR_DECLARE(void) fspr_table_add(fspr_table_t *t, const char *key, const char *val); /** @@ -321,7 +321,7 @@ APR_DECLARE(void) apr_table_add(apr_table_t *t, const char *key, * value, so care should be taken to ensure that the values will not * change after they have been added.. */ -APR_DECLARE(void) apr_table_addn(apr_table_t *t, const char *key, +APR_DECLARE(void) fspr_table_addn(fspr_table_t *t, const char *key, const char *val); /** @@ -331,21 +331,21 @@ APR_DECLARE(void) apr_table_addn(apr_table_t *t, const char *key, * @param base The table to add at the end of the new table * @return A new table containing all of the data from the two passed in */ -APR_DECLARE(apr_table_t *) apr_table_overlay(apr_pool_t *p, - const apr_table_t *overlay, - const apr_table_t *base); +APR_DECLARE(fspr_table_t *) fspr_table_overlay(fspr_pool_t *p, + const fspr_table_t *overlay, + const fspr_table_t *base); /** - * Declaration prototype for the iterator callback function of apr_table_do() - * and apr_table_vdo(). - * @param rec The data passed as the first argument to apr_table_[v]do() + * Declaration prototype for the iterator callback function of fspr_table_do() + * and fspr_table_vdo(). + * @param rec The data passed as the first argument to fspr_table_[v]do() * @param key The key from this iteration of the table * @param value The value from this iteration of the table * @remark Iteration continues while this callback function returns non-zero. - * To export the callback function for apr_table_[v]do() it must be declared + * To export the callback function for fspr_table_[v]do() it must be declared * in the _NONSTD convention. */ -typedef int (apr_table_do_callback_fn_t)(void *rec, const char *key, +typedef int (fspr_table_do_callback_fn_t)(void *rec, const char *key, const char *value); /** @@ -362,10 +362,10 @@ typedef int (apr_table_do_callback_fn_t)(void *rec, const char *key, * are run. * @return FALSE if one of the comp() iterations returned zero; TRUE if all * iterations returned non-zero - * @see apr_table_do_callback_fn_t + * @see fspr_table_do_callback_fn_t */ -APR_DECLARE_NONSTD(int) apr_table_do(apr_table_do_callback_fn_t *comp, - void *rec, const apr_table_t *t, ...); +APR_DECLARE_NONSTD(int) fspr_table_do(fspr_table_do_callback_fn_t *comp, + void *rec, const fspr_table_t *t, ...); /** * Iterate over a table running the provided function once for every @@ -381,14 +381,14 @@ APR_DECLARE_NONSTD(int) apr_table_do(apr_table_do_callback_fn_t *comp, * whose key matches are run. * @return FALSE if one of the comp() iterations returned zero; TRUE if all * iterations returned non-zero - * @see apr_table_do_callback_fn_t + * @see fspr_table_do_callback_fn_t */ -APR_DECLARE(int) apr_table_vdo(apr_table_do_callback_fn_t *comp, - void *rec, const apr_table_t *t, va_list vp); +APR_DECLARE(int) fspr_table_vdo(fspr_table_do_callback_fn_t *comp, + void *rec, const fspr_table_t *t, va_list vp); -/** flag for overlap to use apr_table_setn */ +/** flag for overlap to use fspr_table_setn */ #define APR_OVERLAP_TABLES_SET (0) -/** flag for overlap to use apr_table_mergen */ +/** flag for overlap to use fspr_table_mergen */ #define APR_OVERLAP_TABLES_MERGE (1) /** * For each element in table b, either use setn or mergen to add the data @@ -396,25 +396,25 @@ APR_DECLARE(int) apr_table_vdo(apr_table_do_callback_fn_t *comp, * @param a The table to add the data to. * @param b The table to iterate over, adding its data to table a * @param flags How to add the table to table a. One of: - * APR_OVERLAP_TABLES_SET Use apr_table_setn - * APR_OVERLAP_TABLES_MERGE Use apr_table_mergen + * APR_OVERLAP_TABLES_SET Use fspr_table_setn + * APR_OVERLAP_TABLES_MERGE Use fspr_table_mergen * @remark This function is highly optimized, and uses less memory and CPU cycles * than a function that just loops through table b calling other functions. */ /** *
    - * Conceptually, apr_table_overlap does this:
    + * Conceptually, fspr_table_overlap does this:
      *
    - *  apr_array_header_t *barr = apr_table_elts(b);
    - *  apr_table_entry_t *belt = (apr_table_entry_t *)barr->elts;
    + *  fspr_array_header_t *barr = fspr_table_elts(b);
    + *  fspr_table_entry_t *belt = (fspr_table_entry_t *)barr->elts;
      *  int i;
      *
      *  for (i = 0; i < barr->nelts; ++i) {
      *      if (flags & APR_OVERLAP_TABLES_MERGE) {
    - *          apr_table_mergen(a, belt[i].key, belt[i].val);
    + *          fspr_table_mergen(a, belt[i].key, belt[i].val);
      *      }
      *      else {
    - *          apr_table_setn(a, belt[i].key, belt[i].val);
    + *          fspr_table_setn(a, belt[i].key, belt[i].val);
      *      }
      *  }
      *
    @@ -427,7 +427,7 @@ APR_DECLARE(int) apr_table_vdo(apr_table_do_callback_fn_t *comp,
      * 
    */ -APR_DECLARE(void) apr_table_overlap(apr_table_t *a, const apr_table_t *b, +APR_DECLARE(void) fspr_table_overlap(fspr_table_t *a, const fspr_table_t *b, unsigned flags); /** @@ -438,7 +438,7 @@ APR_DECLARE(void) apr_table_overlap(apr_table_t *a, const apr_table_t *b, * @param flags APR_OVERLAP_TABLES_MERGE to merge, or * APR_OVERLAP_TABLES_SET to overwrite */ -APR_DECLARE(void) apr_table_compress(apr_table_t *t, unsigned flags); +APR_DECLARE(void) fspr_table_compress(fspr_table_t *t, unsigned flags); /** @} */ diff --git a/libs/apr/include/apr_thread_cond.h b/libs/apr/include/fspr_thread_cond.h similarity index 79% rename from libs/apr/include/apr_thread_cond.h rename to libs/apr/include/fspr_thread_cond.h index 3744b09042..7ece46e281 100644 --- a/libs/apr/include/apr_thread_cond.h +++ b/libs/apr/include/fspr_thread_cond.h @@ -18,15 +18,15 @@ #define APR_THREAD_COND_H /** - * @file apr_thread_cond.h + * @file fspr_thread_cond.h * @brief APR Condition Variable Routines */ -#include "apr.h" -#include "apr_pools.h" -#include "apr_errno.h" -#include "apr_time.h" -#include "apr_thread_mutex.h" +#include "fspr.h" +#include "fspr_pools.h" +#include "fspr_errno.h" +#include "fspr_time.h" +#include "fspr_thread_mutex.h" #ifdef __cplusplus extern "C" { @@ -35,13 +35,13 @@ extern "C" { #if APR_HAS_THREADS || defined(DOXYGEN) /** - * @defgroup apr_thread_cond Condition Variable Routines + * @defgroup fspr_thread_cond Condition Variable Routines * @ingroup APR * @{ */ /** Opaque structure for thread condition variables */ -typedef struct apr_thread_cond_t apr_thread_cond_t; +typedef struct fspr_thread_cond_t fspr_thread_cond_t; /** * Note: destroying a condition variable (or likewise, destroying or @@ -56,8 +56,8 @@ typedef struct apr_thread_cond_t apr_thread_cond_t; * will be stored. * @param pool the pool from which to allocate the mutex. */ -APR_DECLARE(apr_status_t) apr_thread_cond_create(apr_thread_cond_t **cond, - apr_pool_t *pool); +APR_DECLARE(fspr_status_t) fspr_thread_cond_create(fspr_thread_cond_t **cond, + fspr_pool_t *pool); /** * Put the active calling thread to sleep until signaled to wake up. Each @@ -71,8 +71,8 @@ APR_DECLARE(apr_status_t) apr_thread_cond_create(apr_thread_cond_t **cond, * is released while the thread is asleep, and is again acquired before * returning from this function. */ -APR_DECLARE(apr_status_t) apr_thread_cond_wait(apr_thread_cond_t *cond, - apr_thread_mutex_t *mutex); +APR_DECLARE(fspr_status_t) fspr_thread_cond_wait(fspr_thread_cond_t *cond, + fspr_thread_mutex_t *mutex); /** * Put the active calling thread to sleep until signaled to wake up or @@ -90,9 +90,9 @@ APR_DECLARE(apr_status_t) apr_thread_cond_wait(apr_thread_cond_t *cond, * will wake up before this time, otherwise the error APR_TIMEUP * is returned. */ -APR_DECLARE(apr_status_t) apr_thread_cond_timedwait(apr_thread_cond_t *cond, - apr_thread_mutex_t *mutex, - apr_interval_time_t timeout); +APR_DECLARE(fspr_status_t) fspr_thread_cond_timedwait(fspr_thread_cond_t *cond, + fspr_thread_mutex_t *mutex, + fspr_interval_time_t timeout); /** * Signals a single thread, if one exists, that is blocking on the given @@ -101,7 +101,7 @@ APR_DECLARE(apr_status_t) apr_thread_cond_timedwait(apr_thread_cond_t *cond, * is desired, that mutex must be locked while calling this function. * @param cond the condition variable on which to produce the signal. */ -APR_DECLARE(apr_status_t) apr_thread_cond_signal(apr_thread_cond_t *cond); +APR_DECLARE(fspr_status_t) fspr_thread_cond_signal(fspr_thread_cond_t *cond); /** * Signals all threads blocking on the given condition variable. @@ -109,17 +109,17 @@ APR_DECLARE(apr_status_t) apr_thread_cond_signal(apr_thread_cond_t *cond); * the associated mutex. This will happen in a serialized manner. * @param cond the condition variable on which to produce the broadcast. */ -APR_DECLARE(apr_status_t) apr_thread_cond_broadcast(apr_thread_cond_t *cond); +APR_DECLARE(fspr_status_t) fspr_thread_cond_broadcast(fspr_thread_cond_t *cond); /** * Destroy the condition variable and free the associated memory. * @param cond the condition variable to destroy. */ -APR_DECLARE(apr_status_t) apr_thread_cond_destroy(apr_thread_cond_t *cond); +APR_DECLARE(fspr_status_t) fspr_thread_cond_destroy(fspr_thread_cond_t *cond); /** * Get the pool used by this thread_cond. - * @return apr_pool_t the pool + * @return fspr_pool_t the pool */ APR_POOL_DECLARE_ACCESSOR(thread_cond); diff --git a/libs/apr/include/apr_thread_mutex.h b/libs/apr/include/fspr_thread_mutex.h similarity index 81% rename from libs/apr/include/apr_thread_mutex.h rename to libs/apr/include/fspr_thread_mutex.h index 4596dce5d2..0edf7942d6 100644 --- a/libs/apr/include/apr_thread_mutex.h +++ b/libs/apr/include/fspr_thread_mutex.h @@ -18,12 +18,12 @@ #define APR_THREAD_MUTEX_H /** - * @file apr_thread_mutex.h + * @file fspr_thread_mutex.h * @brief APR Thread Mutex Routines */ -#include "apr.h" -#include "apr_errno.h" +#include "fspr.h" +#include "fspr_errno.h" #ifdef __cplusplus extern "C" { @@ -32,20 +32,20 @@ extern "C" { #if APR_HAS_THREADS || defined(DOXYGEN) /** - * @defgroup apr_thread_mutex Thread Mutex Routines + * @defgroup fspr_thread_mutex Thread Mutex Routines * @ingroup APR * @{ */ /** Opaque thread-local mutex structure */ -typedef struct apr_thread_mutex_t apr_thread_mutex_t; +typedef struct fspr_thread_mutex_t fspr_thread_mutex_t; #define APR_THREAD_MUTEX_DEFAULT 0x0 /**< platform-optimal lock behavior */ #define APR_THREAD_MUTEX_NESTED 0x1 /**< enable nested (recursive) locks */ #define APR_THREAD_MUTEX_UNNESTED 0x2 /**< disable nested locks */ /* Delayed the include to avoid a circular reference */ -#include "apr_pools.h" +#include "fspr_pools.h" /** * Create and initialize a mutex that can be used to synchronize threads. @@ -62,15 +62,15 @@ typedef struct apr_thread_mutex_t apr_thread_mutex_t; * most optimial mutex based on a given platform's performance charateristics, * it will behave as either a nested or an unnested lock. */ -APR_DECLARE(apr_status_t) apr_thread_mutex_create(apr_thread_mutex_t **mutex, +APR_DECLARE(fspr_status_t) fspr_thread_mutex_create(fspr_thread_mutex_t **mutex, unsigned int flags, - apr_pool_t *pool); + fspr_pool_t *pool); /** * Acquire the lock for the given mutex. If the mutex is already locked, * the current thread will be put to sleep until the lock becomes available. * @param mutex the mutex on which to acquire the lock. */ -APR_DECLARE(apr_status_t) apr_thread_mutex_lock(apr_thread_mutex_t *mutex); +APR_DECLARE(fspr_status_t) fspr_thread_mutex_lock(fspr_thread_mutex_t *mutex); /** * Attempt to acquire the lock for the given mutex. If the mutex has already @@ -79,23 +79,23 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_lock(apr_thread_mutex_t *mutex); * if the return value was APR_EBUSY, for portability reasons. * @param mutex the mutex on which to attempt the lock acquiring. */ -APR_DECLARE(apr_status_t) apr_thread_mutex_trylock(apr_thread_mutex_t *mutex); +APR_DECLARE(fspr_status_t) fspr_thread_mutex_trylock(fspr_thread_mutex_t *mutex); /** * Release the lock for the given mutex. * @param mutex the mutex from which to release the lock. */ -APR_DECLARE(apr_status_t) apr_thread_mutex_unlock(apr_thread_mutex_t *mutex); +APR_DECLARE(fspr_status_t) fspr_thread_mutex_unlock(fspr_thread_mutex_t *mutex); /** * Destroy the mutex and free the memory associated with the lock. * @param mutex the mutex to destroy. */ -APR_DECLARE(apr_status_t) apr_thread_mutex_destroy(apr_thread_mutex_t *mutex); +APR_DECLARE(fspr_status_t) fspr_thread_mutex_destroy(fspr_thread_mutex_t *mutex); /** * Get the pool used by this thread_mutex. - * @return apr_pool_t the pool + * @return fspr_pool_t the pool */ APR_POOL_DECLARE_ACCESSOR(thread_mutex); diff --git a/libs/apr/include/apr_thread_proc.h b/libs/apr/include/fspr_thread_proc.h similarity index 71% rename from libs/apr/include/apr_thread_proc.h rename to libs/apr/include/fspr_thread_proc.h index c7930901b2..842f045092 100644 --- a/libs/apr/include/apr_thread_proc.h +++ b/libs/apr/include/fspr_thread_proc.h @@ -18,14 +18,14 @@ #define APR_THREAD_PROC_H /** - * @file apr_thread_proc.h + * @file fspr_thread_proc.h * @brief APR Thread and Process Library */ -#include "apr.h" -#include "apr_file_io.h" -#include "apr_pools.h" -#include "apr_errno.h" +#include "fspr.h" +#include "fspr_file_io.h" +#include "fspr_pools.h" +#include "fspr_errno.h" #if APR_HAVE_STRUCT_RLIMIT #include @@ -37,7 +37,7 @@ extern "C" { #endif /* __cplusplus */ /** - * @defgroup apr_thread_proc Threads and Process Functions + * @defgroup fspr_thread_proc Threads and Process Functions * @ingroup APR * @{ */ @@ -50,12 +50,12 @@ typedef enum { APR_SHELLCMD_ENV /**< use the shell to invoke the program, * replicating our environment */ -} apr_cmdtype_e; +} fspr_cmdtype_e; typedef enum { APR_WAIT, /**< wait for the specified process to finish */ APR_NOWAIT /**< do not wait -- just see if it has finished */ -} apr_wait_how_e; +} fspr_wait_how_e; /* I am specifically calling out the values so that the macros below make * more sense. Yes, I know I don't need to, but I am hoping this makes what @@ -66,7 +66,7 @@ typedef enum { APR_PROC_EXIT = 1, /**< process exited normally */ APR_PROC_SIGNAL = 2, /**< process exited due to a signal */ APR_PROC_SIGNAL_CORE = 4 /**< process exited and dumped a core file */ -} apr_exit_why_e; +} fspr_exit_why_e; /** did we exit the process */ #define APR_PROC_CHECK_EXIT(x) (x & APR_PROC_EXIT) @@ -75,25 +75,25 @@ typedef enum { /** did we get core */ #define APR_PROC_CHECK_CORE_DUMP(x) (x & APR_PROC_SIGNAL_CORE) -/** @see apr_procattr_io_set */ +/** @see fspr_procattr_io_set */ #define APR_NO_PIPE 0 -/** @see apr_procattr_io_set */ +/** @see fspr_procattr_io_set */ #define APR_FULL_BLOCK 1 -/** @see apr_procattr_io_set */ +/** @see fspr_procattr_io_set */ #define APR_FULL_NONBLOCK 2 -/** @see apr_procattr_io_set */ +/** @see fspr_procattr_io_set */ #define APR_PARENT_BLOCK 3 -/** @see apr_procattr_io_set */ +/** @see fspr_procattr_io_set */ #define APR_CHILD_BLOCK 4 -/** @see apr_procattr_limit_set */ +/** @see fspr_procattr_limit_set */ #define APR_LIMIT_CPU 0 -/** @see apr_procattr_limit_set */ +/** @see fspr_procattr_limit_set */ #define APR_LIMIT_MEM 1 -/** @see apr_procattr_limit_set */ +/** @see fspr_procattr_limit_set */ #define APR_LIMIT_NPROC 2 -/** @see apr_procattr_limit_set */ +/** @see fspr_procattr_limit_set */ #define APR_LIMIT_NOFILE 3 /** @@ -119,15 +119,15 @@ typedef enum { /** @} */ /** The APR process type */ -typedef struct apr_proc_t { +typedef struct fspr_proc_t { /** The process ID */ pid_t pid; /** Parent's side of pipe to child's stdin */ - apr_file_t *in; + fspr_file_t *in; /** Parent's side of pipe to child's stdout */ - apr_file_t *out; + fspr_file_t *out; /** Parent's side of pipe to child's stdouterr */ - apr_file_t *err; + fspr_file_t *err; #if APR_HAS_PROC_INVOKED || defined(DOXYGEN) /** Diagnositics/debugging string of the command invoked for * this process [only present if APR_HAS_PROC_INVOKED is true] @@ -147,51 +147,51 @@ typedef struct apr_proc_t { */ HANDLE hproc; #endif -} apr_proc_t; +} fspr_proc_t; /** * The prototype for APR child errfn functions. (See the description - * of apr_procattr_child_errfn_set() for more information.) + * of fspr_procattr_child_errfn_set() for more information.) * It is passed the following parameters: - * @param pool Pool associated with the apr_proc_t. If your child + * @param pool Pool associated with the fspr_proc_t. If your child * error function needs user data, associate it with this * pool. * @param err APR error code describing the error * @param description Text description of type of processing which failed */ -typedef void (apr_child_errfn_t)(apr_pool_t *proc, apr_status_t err, +typedef void (fspr_child_errfn_t)(fspr_pool_t *proc, fspr_status_t err, const char *description); /** Opaque Thread structure. */ -typedef struct apr_thread_t apr_thread_t; +typedef struct fspr_thread_t fspr_thread_t; /** Opaque Thread attributes structure. */ -typedef struct apr_threadattr_t apr_threadattr_t; +typedef struct fspr_threadattr_t fspr_threadattr_t; /** Opaque Process attributes structure. */ -typedef struct apr_procattr_t apr_procattr_t; +typedef struct fspr_procattr_t fspr_procattr_t; /** Opaque control variable for one-time atomic variables. */ -typedef struct apr_thread_once_t apr_thread_once_t; +typedef struct fspr_thread_once_t fspr_thread_once_t; /** Opaque thread private address space. */ -typedef struct apr_threadkey_t apr_threadkey_t; +typedef struct fspr_threadkey_t fspr_threadkey_t; /** Opaque record of child process. */ -typedef struct apr_other_child_rec_t apr_other_child_rec_t; +typedef struct fspr_other_child_rec_t fspr_other_child_rec_t; /** * The prototype for any APR thread worker functions. */ -typedef void *(APR_THREAD_FUNC *apr_thread_start_t)(apr_thread_t*, void*); +typedef void *(APR_THREAD_FUNC *fspr_thread_start_t)(fspr_thread_t*, void*); typedef enum { APR_KILL_NEVER, /**< process is never sent any signals */ - APR_KILL_ALWAYS, /**< process is sent SIGKILL on apr_pool_t cleanup */ + APR_KILL_ALWAYS, /**< process is sent SIGKILL on fspr_pool_t cleanup */ APR_KILL_AFTER_TIMEOUT, /**< SIGTERM, wait 3 seconds, SIGKILL */ APR_JUST_WAIT, /**< wait forever for the process to complete */ APR_KILL_ONLY_ONCE /**< send SIGTERM and then wait */ -} apr_kill_conditions_e; +} fspr_kill_conditions_e; /* Thread Function definitions */ @@ -202,16 +202,16 @@ typedef enum { * @param new_attr The newly created threadattr. * @param cont The pool to use */ -APR_DECLARE(apr_status_t) apr_threadattr_create(apr_threadattr_t **new_attr, - apr_pool_t *cont); +APR_DECLARE(fspr_status_t) fspr_threadattr_create(fspr_threadattr_t **new_attr, + fspr_pool_t *cont); /** * Set if newly created threads should be created in detached state. * @param attr The threadattr to affect * @param on Non-zero if detached threads should be created. */ -APR_DECLARE(apr_status_t) apr_threadattr_detach_set(apr_threadattr_t *attr, - apr_int32_t on); +APR_DECLARE(fspr_status_t) fspr_threadattr_detach_set(fspr_threadattr_t *attr, + fspr_int32_t on); /** * Get the detach state for this threadattr. @@ -219,15 +219,15 @@ APR_DECLARE(apr_status_t) apr_threadattr_detach_set(apr_threadattr_t *attr, * @return APR_DETACH if threads are to be detached, or APR_NOTDETACH * if threads are to be joinable. */ -APR_DECLARE(apr_status_t) apr_threadattr_detach_get(apr_threadattr_t *attr); +APR_DECLARE(fspr_status_t) fspr_threadattr_detach_get(fspr_threadattr_t *attr); /** * Set the stack size of newly created threads. * @param attr The threadattr to affect * @param stacksize The stack size in bytes */ -APR_DECLARE(apr_status_t) apr_threadattr_stacksize_set(apr_threadattr_t *attr, - apr_size_t stacksize); +APR_DECLARE(fspr_status_t) fspr_threadattr_stacksize_set(fspr_threadattr_t *attr, + fspr_size_t stacksize); /** * Set the stack guard area size of newly created threads. @@ -239,8 +239,8 @@ APR_DECLARE(apr_status_t) apr_threadattr_stacksize_set(apr_threadattr_t *attr, * and increases memory management overhead. Setting the guard area * size to zero hence trades off reliable behaviour on stack overflow * for performance. */ -APR_DECLARE(apr_status_t) apr_threadattr_guardsize_set(apr_threadattr_t *attr, - apr_size_t guardsize); +APR_DECLARE(fspr_status_t) fspr_threadattr_guardsize_set(fspr_threadattr_t *attr, + fspr_size_t guardsize); /** * Create a new thread of execution @@ -250,40 +250,40 @@ APR_DECLARE(apr_status_t) apr_threadattr_guardsize_set(apr_threadattr_t *attr, * @param data Any data to be passed to the starting function * @param cont The pool to use */ -APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new_thread, - apr_threadattr_t *attr, - apr_thread_start_t func, - void *data, apr_pool_t *cont); +APR_DECLARE(fspr_status_t) fspr_thread_create(fspr_thread_t **new_thread, + fspr_threadattr_t *attr, + fspr_thread_start_t func, + void *data, fspr_pool_t *cont); /** * stop the current thread * @param thd The thread to stop * @param retval The return value to pass back to any thread that cares */ -APR_DECLARE(apr_status_t) apr_thread_exit(apr_thread_t *thd, - apr_status_t retval); +APR_DECLARE(fspr_status_t) fspr_thread_exit(fspr_thread_t *thd, + fspr_status_t retval); /** * block until the desired thread stops executing. * @param retval The return value from the dead thread. * @param thd The thread to join */ -APR_DECLARE(apr_status_t) apr_thread_join(apr_status_t *retval, - apr_thread_t *thd); +APR_DECLARE(fspr_status_t) fspr_thread_join(fspr_status_t *retval, + fspr_thread_t *thd); /** * force the current thread to yield the processor */ -APR_DECLARE(void) apr_thread_yield(void); +APR_DECLARE(void) fspr_thread_yield(void); /** - * Initialize the control variable for apr_thread_once. If this isn't - * called, apr_initialize won't work. + * Initialize the control variable for fspr_thread_once. If this isn't + * called, fspr_initialize won't work. * @param control The control variable to initialize * @param p The pool to allocate data from. */ -APR_DECLARE(apr_status_t) apr_thread_once_init(apr_thread_once_t **control, - apr_pool_t *p); +APR_DECLARE(fspr_status_t) fspr_thread_once_init(fspr_thread_once_t **control, + fspr_pool_t *p); /** * Run the specified function one time, regardless of how many threads @@ -294,14 +294,14 @@ APR_DECLARE(apr_status_t) apr_thread_once_init(apr_thread_once_t **control, * if the function has ever been called before. * @param func The function to call. */ -APR_DECLARE(apr_status_t) apr_thread_once(apr_thread_once_t *control, +APR_DECLARE(fspr_status_t) fspr_thread_once(fspr_thread_once_t *control, void (*func)(void)); /** * detach a thread * @param thd The thread to detach */ -APR_DECLARE(apr_status_t) apr_thread_detach(apr_thread_t *thd); +APR_DECLARE(fspr_status_t) fspr_thread_detach(fspr_thread_t *thd); /** * Return the pool associated with the current thread. @@ -309,8 +309,8 @@ APR_DECLARE(apr_status_t) apr_thread_detach(apr_thread_t *thd); * @param key The key to associate with the data * @param thread The currently open thread. */ -APR_DECLARE(apr_status_t) apr_thread_data_get(void **data, const char *key, - apr_thread_t *thread); +APR_DECLARE(fspr_status_t) fspr_thread_data_get(void **data, const char *key, + fspr_thread_t *thread); /** * Return the pool associated with the current thread. @@ -319,9 +319,9 @@ APR_DECLARE(apr_status_t) apr_thread_data_get(void **data, const char *key, * @param cleanup The cleanup routine to use when the thread is destroyed. * @param thread The currently open thread. */ -APR_DECLARE(apr_status_t) apr_thread_data_set(void *data, const char *key, - apr_status_t (*cleanup) (void *), - apr_thread_t *thread); +APR_DECLARE(fspr_status_t) fspr_thread_data_set(void *data, const char *key, + fspr_status_t (*cleanup) (void *), + fspr_thread_t *thread); /** * Create and initialize a new thread private address space @@ -329,31 +329,31 @@ APR_DECLARE(apr_status_t) apr_thread_data_set(void *data, const char *key, * @param dest The destructor to use when freeing the private memory. * @param cont The pool to use */ -APR_DECLARE(apr_status_t) apr_threadkey_private_create(apr_threadkey_t **key, +APR_DECLARE(fspr_status_t) fspr_threadkey_private_create(fspr_threadkey_t **key, void (*dest)(void *), - apr_pool_t *cont); + fspr_pool_t *cont); /** * Get a pointer to the thread private memory * @param new_mem The data stored in private memory * @param key The handle for the desired thread private memory */ -APR_DECLARE(apr_status_t) apr_threadkey_private_get(void **new_mem, - apr_threadkey_t *key); +APR_DECLARE(fspr_status_t) fspr_threadkey_private_get(void **new_mem, + fspr_threadkey_t *key); /** * Set the data to be stored in thread private memory * @param priv The data to be stored in private memory * @param key The handle for the desired thread private memory */ -APR_DECLARE(apr_status_t) apr_threadkey_private_set(void *priv, - apr_threadkey_t *key); +APR_DECLARE(fspr_status_t) fspr_threadkey_private_set(void *priv, + fspr_threadkey_t *key); /** * Free the thread private memory * @param key The handle for the desired thread private memory */ -APR_DECLARE(apr_status_t) apr_threadkey_private_delete(apr_threadkey_t *key); +APR_DECLARE(fspr_status_t) fspr_threadkey_private_delete(fspr_threadkey_t *key); /** * Return the pool associated with the current threadkey. @@ -361,8 +361,8 @@ APR_DECLARE(apr_status_t) apr_threadkey_private_delete(apr_threadkey_t *key); * @param key The key associated with the data * @param threadkey The currently open threadkey. */ -APR_DECLARE(apr_status_t) apr_threadkey_data_get(void **data, const char *key, - apr_threadkey_t *threadkey); +APR_DECLARE(fspr_status_t) fspr_threadkey_data_get(void **data, const char *key, + fspr_threadkey_t *threadkey); /** * Return the pool associated with the current threadkey. @@ -371,9 +371,9 @@ APR_DECLARE(apr_status_t) apr_threadkey_data_get(void **data, const char *key, * @param cleanup The cleanup routine to use when the file is destroyed. * @param threadkey The currently open threadkey. */ -APR_DECLARE(apr_status_t) apr_threadkey_data_set(void *data, const char *key, - apr_status_t (*cleanup) (void *), - apr_threadkey_t *threadkey); +APR_DECLARE(fspr_status_t) fspr_threadkey_data_set(void *data, const char *key, + fspr_status_t (*cleanup) (void *), + fspr_threadkey_t *threadkey); #endif @@ -382,8 +382,8 @@ APR_DECLARE(apr_status_t) apr_threadkey_data_set(void *data, const char *key, * @param new_attr The newly created procattr. * @param cont The pool to use */ -APR_DECLARE(apr_status_t) apr_procattr_create(apr_procattr_t **new_attr, - apr_pool_t *cont); +APR_DECLARE(fspr_status_t) fspr_procattr_create(fspr_procattr_t **new_attr, + fspr_pool_t *cont); /** * Determine if any of stdin, stdout, or stderr should be linked to pipes @@ -393,15 +393,15 @@ APR_DECLARE(apr_status_t) apr_procattr_create(apr_procattr_t **new_attr, * @param out Should stdout be a pipe back to the parent? * @param err Should stderr be a pipe back to the parent? */ -APR_DECLARE(apr_status_t) apr_procattr_io_set(apr_procattr_t *attr, - apr_int32_t in, apr_int32_t out, - apr_int32_t err); +APR_DECLARE(fspr_status_t) fspr_procattr_io_set(fspr_procattr_t *attr, + fspr_int32_t in, fspr_int32_t out, + fspr_int32_t err); /** - * Set the child_in and/or parent_in values to existing apr_file_t values. + * Set the child_in and/or parent_in values to existing fspr_file_t values. * @param attr The procattr we care about. - * @param child_in apr_file_t value to use as child_in. Must be a valid file. - * @param parent_in apr_file_t value to use as parent_in. Must be a valid file. + * @param child_in fspr_file_t value to use as child_in. Must be a valid file. + * @param parent_in fspr_file_t value to use as parent_in. Must be a valid file. * @remark This is NOT a required initializer function. This is * useful if you have already opened a pipe (or multiple files) * that you wish to use, perhaps persistently across multiple @@ -409,37 +409,37 @@ APR_DECLARE(apr_status_t) apr_procattr_io_set(apr_procattr_t *attr, * extra function calls by not creating your own pipe since this * creates one in the process space for you. */ -APR_DECLARE(apr_status_t) apr_procattr_child_in_set(struct apr_procattr_t *attr, - apr_file_t *child_in, - apr_file_t *parent_in); +APR_DECLARE(fspr_status_t) fspr_procattr_child_in_set(struct fspr_procattr_t *attr, + fspr_file_t *child_in, + fspr_file_t *parent_in); /** - * Set the child_out and parent_out values to existing apr_file_t values. + * Set the child_out and parent_out values to existing fspr_file_t values. * @param attr The procattr we care about. - * @param child_out apr_file_t value to use as child_out. Must be a valid file. - * @param parent_out apr_file_t value to use as parent_out. Must be a valid file. + * @param child_out fspr_file_t value to use as child_out. Must be a valid file. + * @param parent_out fspr_file_t value to use as parent_out. Must be a valid file. * @remark This is NOT a required initializer function. This is * useful if you have already opened a pipe (or multiple files) * that you wish to use, perhaps persistently across multiple * process invocations - such as a log file. */ -APR_DECLARE(apr_status_t) apr_procattr_child_out_set(struct apr_procattr_t *attr, - apr_file_t *child_out, - apr_file_t *parent_out); +APR_DECLARE(fspr_status_t) fspr_procattr_child_out_set(struct fspr_procattr_t *attr, + fspr_file_t *child_out, + fspr_file_t *parent_out); /** - * Set the child_err and parent_err values to existing apr_file_t values. + * Set the child_err and parent_err values to existing fspr_file_t values. * @param attr The procattr we care about. - * @param child_err apr_file_t value to use as child_err. Must be a valid file. - * @param parent_err apr_file_t value to use as parent_err. Must be a valid file. + * @param child_err fspr_file_t value to use as child_err. Must be a valid file. + * @param parent_err fspr_file_t value to use as parent_err. Must be a valid file. * @remark This is NOT a required initializer function. This is * useful if you have already opened a pipe (or multiple files) * that you wish to use, perhaps persistently across multiple * process invocations - such as a log file. */ -APR_DECLARE(apr_status_t) apr_procattr_child_err_set(struct apr_procattr_t *attr, - apr_file_t *child_err, - apr_file_t *parent_err); +APR_DECLARE(fspr_status_t) fspr_procattr_child_err_set(struct fspr_procattr_t *attr, + fspr_file_t *child_err, + fspr_file_t *parent_err); /** * Set which directory the child process should start executing in. @@ -448,7 +448,7 @@ APR_DECLARE(apr_status_t) apr_procattr_child_err_set(struct apr_procattr_t *attr * the parent currently resides in, when the createprocess call * is made. */ -APR_DECLARE(apr_status_t) apr_procattr_dir_set(apr_procattr_t *attr, +APR_DECLARE(fspr_status_t) fspr_procattr_dir_set(fspr_procattr_t *attr, const char *dir); /** @@ -462,16 +462,16 @@ APR_DECLARE(apr_status_t) apr_procattr_dir_set(apr_procattr_t *attr, * APR_PROGRAM_PATH -- Executable program on PATH, copy env * */ -APR_DECLARE(apr_status_t) apr_procattr_cmdtype_set(apr_procattr_t *attr, - apr_cmdtype_e cmd); +APR_DECLARE(fspr_status_t) fspr_procattr_cmdtype_set(fspr_procattr_t *attr, + fspr_cmdtype_e cmd); /** * Determine if the child should start in detached state. * @param attr The procattr we care about. * @param detach Should the child start in detached state? Default is no. */ -APR_DECLARE(apr_status_t) apr_procattr_detach_set(apr_procattr_t *attr, - apr_int32_t detach); +APR_DECLARE(fspr_status_t) fspr_procattr_detach_set(fspr_procattr_t *attr, + fspr_int32_t detach); #if APR_HAVE_STRUCT_RLIMIT /** @@ -486,8 +486,8 @@ APR_DECLARE(apr_status_t) apr_procattr_detach_set(apr_procattr_t *attr, * * @param limit Value to set the limit to. */ -APR_DECLARE(apr_status_t) apr_procattr_limit_set(apr_procattr_t *attr, - apr_int32_t what, +APR_DECLARE(fspr_status_t) fspr_procattr_limit_set(fspr_procattr_t *attr, + fspr_int32_t what, struct rlimit *limit); #endif @@ -496,29 +496,29 @@ APR_DECLARE(apr_status_t) apr_procattr_limit_set(apr_procattr_t *attr, * encounters an error in the child prior to running the specified program. * @param attr The procattr describing the child process to be created. * @param errfn The function to call in the child process. - * @remark At the present time, it will only be called from apr_proc_create() + * @remark At the present time, it will only be called from fspr_proc_create() * on platforms where fork() is used. It will never be called on other - * platforms, on those platforms apr_proc_create() will return the error + * platforms, on those platforms fspr_proc_create() will return the error * in the parent process rather than invoke the callback in the now-forked * child process. */ -APR_DECLARE(apr_status_t) apr_procattr_child_errfn_set(apr_procattr_t *attr, - apr_child_errfn_t *errfn); +APR_DECLARE(fspr_status_t) fspr_procattr_child_errfn_set(fspr_procattr_t *attr, + fspr_child_errfn_t *errfn); /** - * Specify that apr_proc_create() should do whatever it can to report - * failures to the caller of apr_proc_create(), rather than find out in + * Specify that fspr_proc_create() should do whatever it can to report + * failures to the caller of fspr_proc_create(), rather than find out in * the child. * @param attr The procattr describing the child process to be created. * @param chk Flag to indicate whether or not extra work should be done * to try to report failures to the caller. - * @remark This flag only affects apr_proc_create() on platforms where + * @remark This flag only affects fspr_proc_create() on platforms where * fork() is used. This leads to extra overhead in the calling * process, but that may help the application handle such * errors more gracefully. */ -APR_DECLARE(apr_status_t) apr_procattr_error_check_set(apr_procattr_t *attr, - apr_int32_t chk); +APR_DECLARE(fspr_status_t) fspr_procattr_error_check_set(fspr_procattr_t *attr, + fspr_int32_t chk); /** * Determine if the child should start in its own address space or using the @@ -527,8 +527,8 @@ APR_DECLARE(apr_status_t) apr_procattr_error_check_set(apr_procattr_t *attr, * @param addrspace Should the child start in its own address space? Default * is no on NetWare and yes on other platforms. */ -APR_DECLARE(apr_status_t) apr_procattr_addrspace_set(apr_procattr_t *attr, - apr_int32_t addrspace); +APR_DECLARE(fspr_status_t) fspr_procattr_addrspace_set(fspr_procattr_t *attr, + fspr_int32_t addrspace); /** * Set the username used for running process @@ -538,7 +538,7 @@ APR_DECLARE(apr_status_t) apr_procattr_addrspace_set(apr_procattr_t *attr, * or any other platform having * APR_PROCATTR_USER_SET_REQUIRES_PASSWORD set. */ -APR_DECLARE(apr_status_t) apr_procattr_user_set(apr_procattr_t *attr, +APR_DECLARE(fspr_status_t) fspr_procattr_user_set(fspr_procattr_t *attr, const char *username, const char *password); @@ -547,7 +547,7 @@ APR_DECLARE(apr_status_t) apr_procattr_user_set(apr_procattr_t *attr, * @param attr The procattr we care about. * @param groupname The group name used */ -APR_DECLARE(apr_status_t) apr_procattr_group_set(apr_procattr_t *attr, +APR_DECLARE(fspr_status_t) fspr_procattr_group_set(fspr_procattr_t *attr, const char *groupname); @@ -560,7 +560,7 @@ APR_DECLARE(apr_status_t) apr_procattr_group_set(apr_procattr_t *attr, * @remark returns APR_INCHILD for the child, and APR_INPARENT for the parent * or an error. */ -APR_DECLARE(apr_status_t) apr_proc_fork(apr_proc_t *proc, apr_pool_t *cont); +APR_DECLARE(fspr_status_t) fspr_proc_fork(fspr_proc_t *proc, fspr_pool_t *cont); #endif /** @@ -577,14 +577,14 @@ APR_DECLARE(apr_status_t) apr_proc_fork(apr_proc_t *proc, apr_pool_t *cont); * process * @param pool The pool to use. * @note This function returns without waiting for the new process to terminate; - * use apr_proc_wait for that. + * use fspr_proc_wait for that. */ -APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new_proc, +APR_DECLARE(fspr_status_t) fspr_proc_create(fspr_proc_t *new_proc, const char *progname, const char * const *args, const char * const *env, - apr_procattr_t *attr, - apr_pool_t *pool); + fspr_procattr_t *attr, + fspr_pool_t *pool); /** * Wait for a child process to die @@ -612,9 +612,9 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new_proc, * APR_CHILD_NOTDONE -- child is still running. * */ -APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc, - int *exitcode, apr_exit_why_e *exitwhy, - apr_wait_how_e waithow); +APR_DECLARE(fspr_status_t) fspr_proc_wait(fspr_proc_t *proc, + int *exitcode, fspr_exit_why_e *exitwhy, + fspr_wait_how_e waithow); /** * Wait for any current child process to die and return information @@ -642,11 +642,11 @@ APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc, * @bug Passing proc as a *proc rather than **proc was an odd choice * for some platforms... this should be revisited in 1.0 */ -APR_DECLARE(apr_status_t) apr_proc_wait_all_procs(apr_proc_t *proc, +APR_DECLARE(fspr_status_t) fspr_proc_wait_all_procs(fspr_proc_t *proc, int *exitcode, - apr_exit_why_e *exitwhy, - apr_wait_how_e waithow, - apr_pool_t *p); + fspr_exit_why_e *exitwhy, + fspr_wait_how_e waithow, + fspr_pool_t *p); #define APR_PROC_DETACH_FOREGROUND 0 /**< Do not detach */ #define APR_PROC_DETACH_DAEMONIZE 1 /**< Detach */ @@ -657,7 +657,7 @@ APR_DECLARE(apr_status_t) apr_proc_wait_all_procs(apr_proc_t *proc, * and become a background process, else it will * stay in the foreground. */ -APR_DECLARE(apr_status_t) apr_proc_detach(int daemonize); +APR_DECLARE(fspr_status_t) fspr_proc_detach(int daemonize); /** * Register an other_child -- a child associated to its registered @@ -676,12 +676,12 @@ APR_DECLARE(apr_status_t) apr_proc_detach(int daemonize); * proc->in/out/err handles should be health checked. * @bug no platform currently tests the pipes health. */ -APR_DECLARE(void) apr_proc_other_child_register(apr_proc_t *proc, +APR_DECLARE(void) fspr_proc_other_child_register(fspr_proc_t *proc, void (*maintenance) (int reason, void *, int status), - void *data, apr_file_t *write_fd, - apr_pool_t *p); + void *data, fspr_file_t *write_fd, + fspr_pool_t *p); /** * Stop watching the specified other child. @@ -692,7 +692,7 @@ APR_DECLARE(void) apr_proc_other_child_register(apr_proc_t *proc, * themself by loading ocr->next before calling any maintenance * function. */ -APR_DECLARE(void) apr_proc_other_child_unregister(void *data); +APR_DECLARE(void) fspr_proc_other_child_unregister(void *data); /** * Notify the maintenance callback of a registered other child process @@ -702,10 +702,10 @@ APR_DECLARE(void) apr_proc_other_child_unregister(void *data); * @param status The status to pass to the maintenance function * @remark An example of code using this behavior; *
    - * rv = apr_proc_wait_all_procs(&proc, &exitcode, &status, APR_WAIT, p);
    + * rv = fspr_proc_wait_all_procs(&proc, &exitcode, &status, APR_WAIT, p);
      * if (APR_STATUS_IS_CHILD_DONE(rv)) {
      * #if APR_HAS_OTHER_CHILD
    - *     if (apr_proc_other_child_alert(&proc, APR_OC_REASON_DEATH, status)
    + *     if (fspr_proc_other_child_alert(&proc, APR_OC_REASON_DEATH, status)
      *             == APR_SUCCESS) {
      *         ;  (already handled)
      *     }
    @@ -714,7 +714,7 @@ APR_DECLARE(void) apr_proc_other_child_unregister(void *data);
      *         [... handling non-otherchild processes death ...]
      * 
    */ -APR_DECLARE(apr_status_t) apr_proc_other_child_alert(apr_proc_t *proc, +APR_DECLARE(fspr_status_t) fspr_proc_other_child_alert(fspr_proc_t *proc, int reason, int status); @@ -725,7 +725,7 @@ APR_DECLARE(apr_status_t) apr_proc_other_child_alert(apr_proc_t *proc, * @param ocr The registered other child * @param reason The reason code (e.g. APR_OC_REASON_RESTART) if still running */ -APR_DECLARE(void) apr_proc_other_child_refresh(apr_other_child_rec_t *ocr, +APR_DECLARE(void) fspr_proc_other_child_refresh(fspr_other_child_rec_t *ocr, int reason); /** @@ -734,14 +734,14 @@ APR_DECLARE(void) apr_proc_other_child_refresh(apr_other_child_rec_t *ocr, * code if the process is no longer healthy. * @param reason The reason code (e.g. APR_OC_REASON_RESTART) to running processes */ -APR_DECLARE(void) apr_proc_other_child_refresh_all(int reason); +APR_DECLARE(void) fspr_proc_other_child_refresh_all(int reason); /** * Terminate a process. * @param proc The process to terminate. * @param sig How to kill the process. */ -APR_DECLARE(apr_status_t) apr_proc_kill(apr_proc_t *proc, int sig); +APR_DECLARE(fspr_status_t) fspr_proc_kill(fspr_proc_t *proc, int sig); /** * Register a process to be killed when a pool dies. @@ -750,14 +750,14 @@ APR_DECLARE(apr_status_t) apr_proc_kill(apr_proc_t *proc, int sig); * @param how How to kill the process, one of: *
      *         APR_KILL_NEVER         -- process is never sent any signals
    - *         APR_KILL_ALWAYS        -- process is sent SIGKILL on apr_pool_t cleanup
    + *         APR_KILL_ALWAYS        -- process is sent SIGKILL on fspr_pool_t cleanup
      *         APR_KILL_AFTER_TIMEOUT -- SIGTERM, wait 3 seconds, SIGKILL
      *         APR_JUST_WAIT          -- wait forever for the process to complete
      *         APR_KILL_ONLY_ONCE     -- send SIGTERM and then wait
      * 
    */ -APR_DECLARE(void) apr_pool_note_subprocess(apr_pool_t *a, apr_proc_t *proc, - apr_kill_conditions_e how); +APR_DECLARE(void) fspr_pool_note_subprocess(fspr_pool_t *a, fspr_proc_t *proc, + fspr_kill_conditions_e how); #if APR_HAS_THREADS @@ -767,22 +767,22 @@ APR_DECLARE(void) apr_pool_note_subprocess(apr_pool_t *a, apr_proc_t *proc, * Setup the process for a single thread to be used for all signal handling. * @warning This must be called before any threads are created */ -APR_DECLARE(apr_status_t) apr_setup_signal_thread(void); +APR_DECLARE(fspr_status_t) fspr_setup_signal_thread(void); /** * Make the current thread listen for signals. This thread will loop * forever, calling a provided function whenever it receives a signal. That * functions should return 1 if the signal has been handled, 0 otherwise. * @param signal_handler The function to call when a signal is received - * apr_status_t apr_signal_thread((int)(*signal_handler)(int signum)) + * fspr_status_t fspr_signal_thread((int)(*signal_handler)(int signum)) */ -APR_DECLARE(apr_status_t) apr_signal_thread(int(*signal_handler)(int signum)); +APR_DECLARE(fspr_status_t) fspr_signal_thread(int(*signal_handler)(int signum)); #endif /* (APR_HAVE_SIGWAIT || APR_HAVE_SIGSUSPEND) && !defined(OS2) */ /** * Get the child-pool used by the thread from the thread info. - * @return apr_pool_t the pool + * @return fspr_pool_t the pool */ APR_POOL_DECLARE_ACCESSOR(thread); diff --git a/libs/apr/include/apr_thread_rwlock.h b/libs/apr/include/fspr_thread_rwlock.h similarity index 78% rename from libs/apr/include/apr_thread_rwlock.h rename to libs/apr/include/fspr_thread_rwlock.h index 0bd958fbfa..57f36fce31 100644 --- a/libs/apr/include/apr_thread_rwlock.h +++ b/libs/apr/include/fspr_thread_rwlock.h @@ -18,13 +18,13 @@ #define APR_THREAD_RWLOCK_H /** - * @file apr_thread_rwlock.h + * @file fspr_thread_rwlock.h * @brief APR Reader/Writer Lock Routines */ -#include "apr.h" -#include "apr_pools.h" -#include "apr_errno.h" +#include "fspr.h" +#include "fspr_pools.h" +#include "fspr_errno.h" #ifdef __cplusplus extern "C" { @@ -33,13 +33,13 @@ extern "C" { #if APR_HAS_THREADS /** - * @defgroup apr_thread_rwlock Reader/Writer Lock Routines + * @defgroup fspr_thread_rwlock Reader/Writer Lock Routines * @ingroup APR * @{ */ /** Opaque read-write thread-safe lock. */ -typedef struct apr_thread_rwlock_t apr_thread_rwlock_t; +typedef struct fspr_thread_rwlock_t fspr_thread_rwlock_t; /** * Note: The following operations have undefined results: unlocking a @@ -57,19 +57,19 @@ typedef struct apr_thread_rwlock_t apr_thread_rwlock_t; * will be stored. * @param pool the pool from which to allocate the mutex. */ -APR_DECLARE(apr_status_t) apr_thread_rwlock_create(apr_thread_rwlock_t **rwlock, - apr_pool_t *pool); +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_create(fspr_thread_rwlock_t **rwlock, + fspr_pool_t *pool); /** * Acquire a shared-read lock on the given read-write lock. This will allow * multiple threads to enter the same critical section while they have acquired * the read lock. * @param rwlock the read-write lock on which to acquire the shared read. */ -APR_DECLARE(apr_status_t) apr_thread_rwlock_rdlock(apr_thread_rwlock_t *rwlock); +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_rdlock(fspr_thread_rwlock_t *rwlock); /** * Attempt to acquire the shared-read lock on the given read-write lock. This - * is the same as apr_thread_rwlock_rdlock(), only that the function fails + * is the same as fspr_thread_rwlock_rdlock(), only that the function fails * if there is another thread holding the write lock, or if there are any * write threads blocking on the lock. If the function fails for this case, * APR_EBUSY will be returned. Note: it is important that the @@ -77,7 +77,7 @@ APR_DECLARE(apr_status_t) apr_thread_rwlock_rdlock(apr_thread_rwlock_t *rwlock); * APR_EBUSY, for portability reasons. * @param rwlock the rwlock on which to attempt the shared read. */ -APR_DECLARE(apr_status_t) apr_thread_rwlock_tryrdlock(apr_thread_rwlock_t *rwlock); +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_tryrdlock(fspr_thread_rwlock_t *rwlock); /** * Acquire an exclusive-write lock on the given read-write lock. This will @@ -86,35 +86,35 @@ APR_DECLARE(apr_status_t) apr_thread_rwlock_tryrdlock(apr_thread_rwlock_t *rwloc * sleep until it can have exclusive access to the lock. * @param rwlock the read-write lock on which to acquire the exclusive write. */ -APR_DECLARE(apr_status_t) apr_thread_rwlock_wrlock(apr_thread_rwlock_t *rwlock); +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_wrlock(fspr_thread_rwlock_t *rwlock); /** * Attempt to acquire the exclusive-write lock on the given read-write lock. - * This is the same as apr_thread_rwlock_wrlock(), only that the function fails + * This is the same as fspr_thread_rwlock_wrlock(), only that the function fails * if there is any other thread holding the lock (for reading or writing), * in which case the function will return APR_EBUSY. Note: it is important * that the APR_STATUS_IS_EBUSY(s) macro be used to determine if the return * value was APR_EBUSY, for portability reasons. * @param rwlock the rwlock on which to attempt the exclusive write. */ -APR_DECLARE(apr_status_t) apr_thread_rwlock_trywrlock(apr_thread_rwlock_t *rwlock); +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_trywrlock(fspr_thread_rwlock_t *rwlock); /** * Release either the read or write lock currently held by the calling thread * associated with the given read-write lock. * @param rwlock the read-write lock to be released (unlocked). */ -APR_DECLARE(apr_status_t) apr_thread_rwlock_unlock(apr_thread_rwlock_t *rwlock); +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_unlock(fspr_thread_rwlock_t *rwlock); /** * Destroy the read-write lock and free the associated memory. * @param rwlock the rwlock to destroy. */ -APR_DECLARE(apr_status_t) apr_thread_rwlock_destroy(apr_thread_rwlock_t *rwlock); +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_destroy(fspr_thread_rwlock_t *rwlock); /** * Get the pool used by this thread_rwlock. - * @return apr_pool_t the pool + * @return fspr_pool_t the pool */ APR_POOL_DECLARE_ACCESSOR(thread_rwlock); diff --git a/libs/apr/include/apr_time.h b/libs/apr/include/fspr_time.h similarity index 56% rename from libs/apr/include/apr_time.h rename to libs/apr/include/fspr_time.h index 253aa72b4a..acf6686469 100644 --- a/libs/apr/include/apr_time.h +++ b/libs/apr/include/fspr_time.h @@ -18,111 +18,111 @@ #define APR_TIME_H /** - * @file apr_time.h + * @file fspr_time.h * @brief APR Time Library */ -#include "apr.h" -#include "apr_pools.h" -#include "apr_errno.h" +#include "fspr.h" +#include "fspr_pools.h" +#include "fspr_errno.h" #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** - * @defgroup apr_time Time Routines + * @defgroup fspr_time Time Routines * @ingroup APR * @{ */ /** month names */ -APR_DECLARE_DATA extern const char apr_month_snames[12][4]; +APR_DECLARE_DATA extern const char fspr_month_snames[12][4]; /** day names */ -APR_DECLARE_DATA extern const char apr_day_snames[7][4]; +APR_DECLARE_DATA extern const char fspr_day_snames[7][4]; /** number of microseconds since 00:00:00 january 1, 1970 UTC */ -typedef apr_int64_t apr_time_t; +typedef fspr_int64_t fspr_time_t; -/** mechanism to properly type apr_time_t literals */ +/** mechanism to properly type fspr_time_t literals */ #define APR_TIME_C(val) APR_INT64_C(val) -/** mechanism to properly print apr_time_t values */ +/** mechanism to properly print fspr_time_t values */ #define APR_TIME_T_FMT APR_INT64_T_FMT /** intervals for I/O timeouts, in microseconds */ -typedef apr_int64_t apr_interval_time_t; +typedef fspr_int64_t fspr_interval_time_t; /** short interval for I/O timeouts, in microseconds */ -typedef apr_int32_t apr_short_interval_time_t; +typedef fspr_int32_t fspr_short_interval_time_t; /** number of microseconds per second */ #define APR_USEC_PER_SEC APR_TIME_C(1000000) -/** @return apr_time_t as a second */ -#define apr_time_sec(time) ((time) / APR_USEC_PER_SEC) +/** @return fspr_time_t as a second */ +#define fspr_time_sec(time) ((time) / APR_USEC_PER_SEC) -/** @return apr_time_t as a usec */ -#define apr_time_usec(time) ((time) % APR_USEC_PER_SEC) +/** @return fspr_time_t as a usec */ +#define fspr_time_usec(time) ((time) % APR_USEC_PER_SEC) -/** @return apr_time_t as a msec */ -#define apr_time_msec(time) (((time) / 1000) % 1000) +/** @return fspr_time_t as a msec */ +#define fspr_time_msec(time) (((time) / 1000) % 1000) -/** @return apr_time_t as a msec */ -#define apr_time_as_msec(time) ((time) / 1000) +/** @return fspr_time_t as a msec */ +#define fspr_time_as_msec(time) ((time) / 1000) -/** @return a second as an apr_time_t */ -#define apr_time_from_sec(sec) ((apr_time_t)(sec) * APR_USEC_PER_SEC) +/** @return a second as an fspr_time_t */ +#define fspr_time_from_sec(sec) ((fspr_time_t)(sec) * APR_USEC_PER_SEC) -/** @return a second and usec combination as an apr_time_t */ -#define apr_time_make(sec, usec) ((apr_time_t)(sec) * APR_USEC_PER_SEC \ - + (apr_time_t)(usec)) +/** @return a second and usec combination as an fspr_time_t */ +#define fspr_time_make(sec, usec) ((fspr_time_t)(sec) * APR_USEC_PER_SEC \ + + (fspr_time_t)(usec)) /** * @return the current time */ -APR_DECLARE(apr_time_t) apr_time_now(void); +APR_DECLARE(fspr_time_t) fspr_time_now(void); -/** @see apr_time_exp_t */ -typedef struct apr_time_exp_t apr_time_exp_t; +/** @see fspr_time_exp_t */ +typedef struct fspr_time_exp_t fspr_time_exp_t; /** * a structure similar to ANSI struct tm with the following differences: * - tm_usec isn't an ANSI field * - tm_gmtoff isn't an ANSI field (it's a bsdism) */ -struct apr_time_exp_t { +struct fspr_time_exp_t { /** microseconds past tm_sec */ - apr_int32_t tm_usec; + fspr_int32_t tm_usec; /** (0-61) seconds past tm_min */ - apr_int32_t tm_sec; + fspr_int32_t tm_sec; /** (0-59) minutes past tm_hour */ - apr_int32_t tm_min; + fspr_int32_t tm_min; /** (0-23) hours past midnight */ - apr_int32_t tm_hour; + fspr_int32_t tm_hour; /** (1-31) day of the month */ - apr_int32_t tm_mday; + fspr_int32_t tm_mday; /** (0-11) month of the year */ - apr_int32_t tm_mon; + fspr_int32_t tm_mon; /** year since 1900 */ - apr_int32_t tm_year; + fspr_int32_t tm_year; /** (0-6) days since sunday */ - apr_int32_t tm_wday; + fspr_int32_t tm_wday; /** (0-365) days since jan 1 */ - apr_int32_t tm_yday; + fspr_int32_t tm_yday; /** daylight saving time */ - apr_int32_t tm_isdst; + fspr_int32_t tm_isdst; /** seconds east of UTC */ - apr_int32_t tm_gmtoff; + fspr_int32_t tm_gmtoff; }; /** - * convert an ansi time_t to an apr_time_t - * @param result the resulting apr_time_t + * convert an ansi time_t to an fspr_time_t + * @param result the resulting fspr_time_t * @param input the time_t to convert */ -APR_DECLARE(apr_status_t) apr_time_ansi_put(apr_time_t *result, +APR_DECLARE(fspr_status_t) fspr_time_ansi_put(fspr_time_t *result, time_t input); /** @@ -132,76 +132,76 @@ APR_DECLARE(apr_status_t) apr_time_ansi_put(apr_time_t *result, * @param input the time to explode * @param offs the number of seconds offset to apply */ -APR_DECLARE(apr_status_t) apr_time_exp_tz(apr_time_exp_t *result, - apr_time_t input, - apr_int32_t offs); +APR_DECLARE(fspr_status_t) fspr_time_exp_tz(fspr_time_exp_t *result, + fspr_time_t input, + fspr_int32_t offs); /** * convert a time to its human readable components in GMT timezone * @param result the exploded time * @param input the time to explode */ -APR_DECLARE(apr_status_t) apr_time_exp_gmt(apr_time_exp_t *result, - apr_time_t input); +APR_DECLARE(fspr_status_t) fspr_time_exp_gmt(fspr_time_exp_t *result, + fspr_time_t input); /** * convert a time to its human readable components in local timezone * @param result the exploded time * @param input the time to explode */ -APR_DECLARE(apr_status_t) apr_time_exp_lt(apr_time_exp_t *result, - apr_time_t input); +APR_DECLARE(fspr_status_t) fspr_time_exp_lt(fspr_time_exp_t *result, + fspr_time_t input); /** - * Convert time value from human readable format to a numeric apr_time_t + * Convert time value from human readable format to a numeric fspr_time_t * e.g. elapsed usec since epoch * @param result the resulting imploded time * @param input the input exploded time */ -APR_DECLARE(apr_status_t) apr_time_exp_get(apr_time_t *result, - apr_time_exp_t *input); +APR_DECLARE(fspr_status_t) fspr_time_exp_get(fspr_time_t *result, + fspr_time_exp_t *input); /** - * Convert time value from human readable format to a numeric apr_time_t that + * Convert time value from human readable format to a numeric fspr_time_t that * always represents GMT * @param result the resulting imploded time * @param input the input exploded time */ -APR_DECLARE(apr_status_t) apr_time_exp_gmt_get(apr_time_t *result, - apr_time_exp_t *input); +APR_DECLARE(fspr_status_t) fspr_time_exp_gmt_get(fspr_time_t *result, + fspr_time_exp_t *input); /** * Sleep for the specified number of micro-seconds. * @param t desired amount of time to sleep. * @warning May sleep for longer than the specified time. */ -APR_DECLARE(void) apr_sleep(apr_interval_time_t t); +APR_DECLARE(void) fspr_sleep(fspr_interval_time_t t); /** length of a RFC822 Date */ #define APR_RFC822_DATE_LEN (30) /** - * apr_rfc822_date formats dates in the RFC822 + * fspr_rfc822_date formats dates in the RFC822 * format in an efficient manner. It is a fixed length * format which requires the indicated amount of storage, * including the trailing NUL terminator. * @param date_str String to write to. * @param t the time to convert */ -APR_DECLARE(apr_status_t) apr_rfc822_date(char *date_str, apr_time_t t); +APR_DECLARE(fspr_status_t) fspr_rfc822_date(char *date_str, fspr_time_t t); /** length of a CTIME date */ #define APR_CTIME_LEN (25) /** - * apr_ctime formats dates in the ctime() format + * fspr_ctime formats dates in the ctime() format * in an efficient manner. it is a fixed length format * and requires the indicated amount of storage including * the trailing NUL terminator. - * Unlike ANSI/ISO C ctime(), apr_ctime() does not include + * Unlike ANSI/ISO C ctime(), fspr_ctime() does not include * a \n at the end of the string. * @param date_str String to write to. * @param t the time to convert */ -APR_DECLARE(apr_status_t) apr_ctime(char *date_str, apr_time_t t); +APR_DECLARE(fspr_status_t) fspr_ctime(char *date_str, fspr_time_t t); /** * formats the exploded time according to the format specified @@ -211,9 +211,9 @@ APR_DECLARE(apr_status_t) apr_ctime(char *date_str, apr_time_t t); * @param format The format for the time string * @param tm The time to convert */ -APR_DECLARE(apr_status_t) apr_strftime(char *s, apr_size_t *retsize, - apr_size_t max, const char *format, - apr_time_exp_t *tm); +APR_DECLARE(fspr_status_t) fspr_strftime(char *s, fspr_size_t *retsize, + fspr_size_t max, const char *format, + fspr_time_exp_t *tm); /** * Improve the clock resolution for the lifetime of the given pool. @@ -221,7 +221,7 @@ APR_DECLARE(apr_status_t) apr_strftime(char *s, apr_size_t *retsize, * time-sensitive applications, and has no impact on most platforms. * @param p The pool to associate the finer clock resolution */ -APR_DECLARE(void) apr_time_clock_hires(apr_pool_t *p); +APR_DECLARE(void) fspr_time_clock_hires(fspr_pool_t *p); /** @} */ diff --git a/libs/apr/include/apr_user.h b/libs/apr/include/fspr_user.h similarity index 65% rename from libs/apr/include/apr_user.h rename to libs/apr/include/fspr_user.h index 0179e22644..68c7c753de 100644 --- a/libs/apr/include/apr_user.h +++ b/libs/apr/include/fspr_user.h @@ -18,20 +18,20 @@ #define APR_USER_H /** - * @file apr_user.h + * @file fspr_user.h * @brief APR User ID Services */ -#include "apr.h" -#include "apr_errno.h" -#include "apr_pools.h" +#include "fspr.h" +#include "fspr_errno.h" +#include "fspr_pools.h" #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** - * @defgroup apr_user User and Group ID Services + * @defgroup fspr_user User and Group ID Services * @ingroup APR * @{ */ @@ -40,18 +40,18 @@ extern "C" { * Structure for determining user ownership. */ #ifdef WIN32 -typedef PSID apr_uid_t; +typedef PSID fspr_uid_t; #else -typedef uid_t apr_uid_t; +typedef uid_t fspr_uid_t; #endif /** * Structure for determining group ownership. */ #ifdef WIN32 -typedef PSID apr_gid_t; +typedef PSID fspr_gid_t; #else -typedef gid_t apr_gid_t; +typedef gid_t fspr_gid_t; #endif #if APR_HAS_USER @@ -63,9 +63,9 @@ typedef gid_t apr_gid_t; * @param p The pool from which to allocate working space * @remark This function is available only if APR_HAS_USER is defined. */ -APR_DECLARE(apr_status_t) apr_uid_current(apr_uid_t *userid, - apr_gid_t *groupid, - apr_pool_t *p); +APR_DECLARE(fspr_status_t) fspr_uid_current(fspr_uid_t *userid, + fspr_gid_t *groupid, + fspr_pool_t *p); /** * Get the user name for a specified userid @@ -74,8 +74,8 @@ APR_DECLARE(apr_status_t) apr_uid_current(apr_uid_t *userid, * @param p The pool from which to allocate the string * @remark This function is available only if APR_HAS_USER is defined. */ -APR_DECLARE(apr_status_t) apr_uid_name_get(char **username, apr_uid_t userid, - apr_pool_t *p); +APR_DECLARE(fspr_status_t) fspr_uid_name_get(char **username, fspr_uid_t userid, + fspr_pool_t *p); /** * Get the userid (and groupid) for the specified username @@ -85,8 +85,8 @@ APR_DECLARE(apr_status_t) apr_uid_name_get(char **username, apr_uid_t userid, * @param p The pool from which to allocate working space * @remark This function is available only if APR_HAS_USER is defined. */ -APR_DECLARE(apr_status_t) apr_uid_get(apr_uid_t *userid, apr_gid_t *groupid, - const char *username, apr_pool_t *p); +APR_DECLARE(fspr_status_t) fspr_uid_get(fspr_uid_t *userid, fspr_gid_t *groupid, + const char *username, fspr_pool_t *p); /** * Get the home directory for the named user @@ -95,22 +95,22 @@ APR_DECLARE(apr_status_t) apr_uid_get(apr_uid_t *userid, apr_gid_t *groupid, * @param p The pool from which to allocate the string * @remark This function is available only if APR_HAS_USER is defined. */ -APR_DECLARE(apr_status_t) apr_uid_homepath_get(char **dirname, +APR_DECLARE(fspr_status_t) fspr_uid_homepath_get(char **dirname, const char *username, - apr_pool_t *p); + fspr_pool_t *p); /** * Compare two user identifiers for equality. * @param left One uid to test * @param right Another uid to test - * @return APR_SUCCESS if the apr_uid_t strutures identify the same user, - * APR_EMISMATCH if not, APR_BADARG if an apr_uid_t is invalid. + * @return APR_SUCCESS if the fspr_uid_t strutures identify the same user, + * APR_EMISMATCH if not, APR_BADARG if an fspr_uid_t is invalid. * @remark This function is available only if APR_HAS_USER is defined. */ #if defined(WIN32) -APR_DECLARE(apr_status_t) apr_uid_compare(apr_uid_t left, apr_uid_t right); +APR_DECLARE(fspr_status_t) fspr_uid_compare(fspr_uid_t left, fspr_uid_t right); #else -#define apr_uid_compare(left,right) (((left) == (right)) ? APR_SUCCESS : APR_EMISMATCH) +#define fspr_uid_compare(left,right) (((left) == (right)) ? APR_SUCCESS : APR_EMISMATCH) #endif /** @@ -120,8 +120,8 @@ APR_DECLARE(apr_status_t) apr_uid_compare(apr_uid_t left, apr_uid_t right); * @param p The pool from which to allocate the string * @remark This function is available only if APR_HAS_USER is defined. */ -APR_DECLARE(apr_status_t) apr_gid_name_get(char **groupname, - apr_gid_t groupid, apr_pool_t *p); +APR_DECLARE(fspr_status_t) fspr_gid_name_get(char **groupname, + fspr_gid_t groupid, fspr_pool_t *p); /** * Get the groupid for a specified group name @@ -130,21 +130,21 @@ APR_DECLARE(apr_status_t) apr_gid_name_get(char **groupname, * @param p The pool from which to allocate the string * @remark This function is available only if APR_HAS_USER is defined. */ -APR_DECLARE(apr_status_t) apr_gid_get(apr_gid_t *groupid, - const char *groupname, apr_pool_t *p); +APR_DECLARE(fspr_status_t) fspr_gid_get(fspr_gid_t *groupid, + const char *groupname, fspr_pool_t *p); /** * Compare two group identifiers for equality. * @param left One gid to test * @param right Another gid to test - * @return APR_SUCCESS if the apr_gid_t strutures identify the same group, - * APR_EMISMATCH if not, APR_BADARG if an apr_gid_t is invalid. + * @return APR_SUCCESS if the fspr_gid_t strutures identify the same group, + * APR_EMISMATCH if not, APR_BADARG if an fspr_gid_t is invalid. * @remark This function is available only if APR_HAS_USER is defined. */ #if defined(WIN32) -APR_DECLARE(apr_status_t) apr_gid_compare(apr_gid_t left, apr_gid_t right); +APR_DECLARE(fspr_status_t) fspr_gid_compare(fspr_gid_t left, fspr_gid_t right); #else -#define apr_gid_compare(left,right) (((left) == (right)) ? APR_SUCCESS : APR_EMISMATCH) +#define fspr_gid_compare(left,right) (((left) == (right)) ? APR_SUCCESS : APR_EMISMATCH) #endif #endif /* ! APR_HAS_USER */ diff --git a/libs/apr/include/apr_version.h b/libs/apr/include/fspr_version.h similarity index 93% rename from libs/apr/include/apr_version.h rename to libs/apr/include/fspr_version.h index a3bd6b893b..7d5b05f77c 100644 --- a/libs/apr/include/apr_version.h +++ b/libs/apr/include/fspr_version.h @@ -18,7 +18,7 @@ #define APR_VERSION_H /** - * @file apr_version.h + * @file fspr_version.h * @brief APR Versioning Interface * * APR's Version @@ -76,7 +76,7 @@ #define APR_IS_DEV_STRING "" #endif -/* APR_STRINGIFY is defined here, and also in apr_general.h, so wrap it */ +/* APR_STRINGIFY is defined here, and also in fspr_general.h, so wrap it */ #ifndef APR_STRINGIFY /** Properly quote a value as a string in the C preprocessor */ #define APR_STRINGIFY(n) APR_STRINGIFY_HELPER(n) @@ -102,11 +102,11 @@ /* The C language API to access the version at run time, * as opposed to compile time. APR_VERSION_ONLY may be defined - * externally when preprocessing apr_version.h to obtain strictly + * externally when preprocessing fspr_version.h to obtain strictly * the C Preprocessor macro declarations. */ -#include "apr.h" +#include "fspr.h" #ifdef __cplusplus extern "C" { @@ -121,7 +121,7 @@ typedef struct { int minor; /**< minor number */ int patch; /**< patch number */ int is_dev; /**< is development (1 or 0) */ -} apr_version_t; +} fspr_version_t; /** * Return APR's version information information in a numeric form. @@ -129,10 +129,10 @@ typedef struct { * @param pvsn Pointer to a version structure for returning the version * information. */ -APR_DECLARE(void) apr_version(apr_version_t *pvsn); +APR_DECLARE(void) fspr_version(fspr_version_t *pvsn); /** Return APR's version information as a string. */ -APR_DECLARE(const char *) apr_version_string(void); +APR_DECLARE(const char *) fspr_version_string(void); #ifdef __cplusplus } diff --git a/libs/apr/include/apr_want.h b/libs/apr/include/fspr_want.h similarity index 94% rename from libs/apr/include/apr_want.h rename to libs/apr/include/fspr_want.h index 39cc4fcb6b..238c2b1a2f 100644 --- a/libs/apr/include/apr_want.h +++ b/libs/apr/include/fspr_want.h @@ -14,9 +14,9 @@ * limitations under the License. */ -#include "apr.h" /* configuration data */ +#include "fspr.h" /* configuration data */ /** - * @file apr_want.h + * @file fspr_want.h * @brief APR Standard Headers Support * *
    @@ -32,12 +32,12 @@
      *
      *   #define APR_WANT_STRFUNC
      *   #define APR_WANT_MEMFUNC
    - *   #include "apr_want.h"
    + *   #include "fspr_want.h"
      *
      * The appropriate headers will be included.
      *
      * Note: it is safe to use this in a header (it won't interfere with other
    - *       headers' or source files' use of apr_want.h)
    + *       headers' or source files' use of fspr_want.h)
      * 
    */ diff --git a/libs/apr/libapr.dsp b/libs/apr/libapr.dsp index be347a7767..b4dbace5a9 100644 --- a/libs/apr/libapr.dsp +++ b/libs/apr/libapr.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c -# ADD CPP /nologo /MD /W3 /O2 /Oy- /Zi /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "NDEBUG" /D "APR_DECLARE_EXPORT" /D "WIN32" /D "_WINDOWS" /Fd"Release\libapr_src" /FD /c +# ADD CPP /nologo /MD /W3 /O2 /Oy- /Zi /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "NDEBUG" /D "APR_DECLARE_EXPORT" /D "WIN32" /D "_WINDOWS" /Fd"Release\libfspr_src" /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL" # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL" # ADD BASE RSC /l 0x409 /d "NDEBUG" @@ -75,7 +75,7 @@ PostBuild_Cmds=if exist $(OUTDIR)\libapr-1.dll.manifest mt.exe -manifest $(OUTDI # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /EHsc /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /c -# ADD CPP /nologo /MDd /W3 /EHsc /Zi /Od /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "_DEBUG" /D "APR_DECLARE_EXPORT" /D "WIN32" /D "_WINDOWS" /Fd"Debug\libapr_src" /FD /c +# ADD CPP /nologo /MDd /W3 /EHsc /Zi /Od /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "_DEBUG" /D "APR_DECLARE_EXPORT" /D "WIN32" /D "_WINDOWS" /Fd"Debug\libfspr_src" /FD /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL" # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL" # ADD BASE RSC /l 0x409 /d "_DEBUG" @@ -107,7 +107,7 @@ PostBuild_Cmds=if exist $(OUTDIR)\libapr-1.dll.manifest mt.exe -manifest $(OUTDI # PROP Default_Filter "" # Begin Source File -SOURCE=.\atomic\win32\apr_atomic.c +SOURCE=.\atomic\win32\fspr_atomic.c # End Source File # End Group # Begin Group "dso" @@ -211,7 +211,7 @@ SOURCE=.\locks\win32\thread_rwlock.c # PROP Default_Filter "" # Begin Source File -SOURCE=.\memory\unix\apr_pools.c +SOURCE=.\memory\unix\fspr_pools.c # End Source File # End Group # Begin Group "misc" @@ -219,7 +219,7 @@ SOURCE=.\memory\unix\apr_pools.c # PROP Default_Filter "" # Begin Source File -SOURCE=.\misc\win32\apr_app.c +SOURCE=.\misc\win32\fspr_app.c # PROP Exclude_From_Build 1 # End Source File # Begin Source File @@ -320,7 +320,7 @@ SOURCE=.\network_io\win32\sockopt.c # PROP Default_Filter "" # Begin Source File -SOURCE=.\passwd\apr_getpass.c +SOURCE=.\passwd\fspr_getpass.c # End Source File # End Group # Begin Group "random" @@ -328,7 +328,7 @@ SOURCE=.\passwd\apr_getpass.c # PROP Default_Filter "" # Begin Source File -SOURCE=.\random\unix\apr_random.c +SOURCE=.\random\unix\fspr_random.c # End Source File # Begin Source File @@ -352,27 +352,27 @@ SOURCE=.\shmem\win32\shm.c # PROP Default_Filter "" # Begin Source File -SOURCE=.\strings\apr_cpystrn.c +SOURCE=.\strings\fspr_cpystrn.c # End Source File # Begin Source File -SOURCE=.\strings\apr_fnmatch.c +SOURCE=.\strings\fspr_fnmatch.c # End Source File # Begin Source File -SOURCE=.\strings\apr_snprintf.c +SOURCE=.\strings\fspr_snprintf.c # End Source File # Begin Source File -SOURCE=.\strings\apr_strings.c +SOURCE=.\strings\fspr_strings.c # End Source File # Begin Source File -SOURCE=.\strings\apr_strnatcmp.c +SOURCE=.\strings\fspr_strnatcmp.c # End Source File # Begin Source File -SOURCE=.\strings\apr_strtok.c +SOURCE=.\strings\fspr_strtok.c # End Source File # End Group # Begin Group "tables" @@ -380,11 +380,11 @@ SOURCE=.\strings\apr_strtok.c # PROP Default_Filter "" # Begin Source File -SOURCE=.\tables\apr_hash.c +SOURCE=.\tables\fspr_hash.c # End Source File # Begin Source File -SOURCE=.\tables\apr_tables.c +SOURCE=.\tables\fspr_tables.c # End Source File # End Group # Begin Group "threadproc" @@ -441,51 +441,51 @@ SOURCE=.\user\win32\userinfo.c # PROP Default_Filter "" # Begin Source File -SOURCE=.\include\arch\win32\apr_arch_atime.h +SOURCE=.\include\arch\win32\fspr_arch_atime.h # End Source File # Begin Source File -SOURCE=.\include\arch\win32\apr_arch_dso.h +SOURCE=.\include\arch\win32\fspr_arch_dso.h # End Source File # Begin Source File -SOURCE=.\include\arch\win32\apr_arch_file_io.h +SOURCE=.\include\arch\win32\fspr_arch_file_io.h # End Source File # Begin Source File -SOURCE=.\include\arch\win32\apr_arch_inherit.h +SOURCE=.\include\arch\win32\fspr_arch_inherit.h # End Source File # Begin Source File -SOURCE=.\include\arch\win32\apr_arch_misc.h +SOURCE=.\include\arch\win32\fspr_arch_misc.h # End Source File # Begin Source File -SOURCE=.\include\arch\win32\apr_arch_networkio.h +SOURCE=.\include\arch\win32\fspr_arch_networkio.h # End Source File # Begin Source File -SOURCE=.\include\arch\win32\apr_arch_thread_mutex.h +SOURCE=.\include\arch\win32\fspr_arch_thread_mutex.h # End Source File # Begin Source File -SOURCE=.\include\arch\win32\apr_arch_thread_rwlock.h +SOURCE=.\include\arch\win32\fspr_arch_thread_rwlock.h # End Source File # Begin Source File -SOURCE=.\include\arch\win32\apr_arch_threadproc.h +SOURCE=.\include\arch\win32\fspr_arch_threadproc.h # End Source File # Begin Source File -SOURCE=.\include\arch\win32\apr_arch_utf8.h +SOURCE=.\include\arch\win32\fspr_arch_utf8.h # End Source File # Begin Source File -SOURCE=.\include\arch\win32\apr_private.h +SOURCE=.\include\arch\win32\fspr_private.h # End Source File # Begin Source File -SOURCE=.\include\arch\apr_private_common.h +SOURCE=.\include\arch\fspr_private_common.h # End Source File # End Group # Begin Group "Public Header Files" @@ -493,35 +493,35 @@ SOURCE=.\include\arch\apr_private_common.h # PROP Default_Filter "" # Begin Source File -SOURCE=.\include\apr.h.in +SOURCE=.\include\fspr.h.in # PROP Exclude_From_Build 1 # End Source File # Begin Source File -SOURCE=.\include\apr.hnw +SOURCE=.\include\fspr.hnw # PROP Exclude_From_Build 1 # End Source File # Begin Source File -SOURCE=.\include\apr.hw +SOURCE=.\include\fspr.hw !IF "$(CFG)" == "libapr - Win32 Release" # Begin Custom Build - Creating apr.h from apr.hw -InputPath=.\include\apr.hw +InputPath=.\include\fspr.hw -".\include\apr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\include\apr.hw > .\include\apr.h +".\include\fspr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + type .\include\fspr.hw > .\include\fspr.h # End Custom Build !ELSEIF "$(CFG)" == "libapr - Win32 Debug" # Begin Custom Build - Creating apr.h from apr.hw -InputPath=.\include\apr.hw +InputPath=.\include\fspr.hw -".\include\apr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - type .\include\apr.hw > .\include\apr.h +".\include\fspr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + type .\include\fspr.hw > .\include\fspr.h # End Custom Build @@ -530,139 +530,139 @@ InputPath=.\include\apr.hw # End Source File # Begin Source File -SOURCE=.\include\apr_allocator.h +SOURCE=.\include\fspr_allocator.h # End Source File # Begin Source File -SOURCE=.\include\apr_atomic.h +SOURCE=.\include\fspr_atomic.h # End Source File # Begin Source File -SOURCE=.\include\apr_dso.h +SOURCE=.\include\fspr_dso.h # End Source File # Begin Source File -SOURCE=.\include\apr_env.h +SOURCE=.\include\fspr_env.h # End Source File # Begin Source File -SOURCE=.\include\apr_errno.h +SOURCE=.\include\fspr_errno.h # End Source File # Begin Source File -SOURCE=.\include\apr_file_info.h +SOURCE=.\include\fspr_file_info.h # End Source File # Begin Source File -SOURCE=.\include\apr_file_io.h +SOURCE=.\include\fspr_file_io.h # End Source File # Begin Source File -SOURCE=.\include\apr_fnmatch.h +SOURCE=.\include\fspr_fnmatch.h # End Source File # Begin Source File -SOURCE=.\include\apr_general.h +SOURCE=.\include\fspr_general.h # End Source File # Begin Source File -SOURCE=.\include\apr_getopt.h +SOURCE=.\include\fspr_getopt.h # End Source File # Begin Source File -SOURCE=.\include\apr_global_mutex.h +SOURCE=.\include\fspr_global_mutex.h # End Source File # Begin Source File -SOURCE=.\include\apr_hash.h +SOURCE=.\include\fspr_hash.h # End Source File # Begin Source File -SOURCE=.\include\apr_inherit.h +SOURCE=.\include\fspr_inherit.h # End Source File # Begin Source File -SOURCE=.\include\apr_lib.h +SOURCE=.\include\fspr_lib.h # End Source File # Begin Source File -SOURCE=.\include\apr_mmap.h +SOURCE=.\include\fspr_mmap.h # End Source File # Begin Source File -SOURCE=.\include\apr_network_io.h +SOURCE=.\include\fspr_network_io.h # End Source File # Begin Source File -SOURCE=.\include\apr_poll.h +SOURCE=.\include\fspr_poll.h # End Source File # Begin Source File -SOURCE=.\include\apr_pools.h +SOURCE=.\include\fspr_pools.h # End Source File # Begin Source File -SOURCE=.\include\apr_portable.h +SOURCE=.\include\fspr_portable.h # End Source File # Begin Source File -SOURCE=.\include\apr_proc_mutex.h +SOURCE=.\include\fspr_proc_mutex.h # End Source File # Begin Source File -SOURCE=.\include\apr_ring.h +SOURCE=.\include\fspr_ring.h # End Source File # Begin Source File -SOURCE=.\include\apr_shm.h +SOURCE=.\include\fspr_shm.h # End Source File # Begin Source File -SOURCE=.\include\apr_signal.h +SOURCE=.\include\fspr_signal.h # End Source File # Begin Source File -SOURCE=.\include\apr_strings.h +SOURCE=.\include\fspr_strings.h # End Source File # Begin Source File -SOURCE=.\include\apr_support.h +SOURCE=.\include\fspr_support.h # End Source File # Begin Source File -SOURCE=.\include\apr_tables.h +SOURCE=.\include\fspr_tables.h # End Source File # Begin Source File -SOURCE=.\include\apr_thread_cond.h +SOURCE=.\include\fspr_thread_cond.h # End Source File # Begin Source File -SOURCE=.\include\apr_thread_mutex.h +SOURCE=.\include\fspr_thread_mutex.h # End Source File # Begin Source File -SOURCE=.\include\apr_thread_proc.h +SOURCE=.\include\fspr_thread_proc.h # End Source File # Begin Source File -SOURCE=.\include\apr_thread_rwlock.h +SOURCE=.\include\fspr_thread_rwlock.h # End Source File # Begin Source File -SOURCE=.\include\apr_time.h +SOURCE=.\include\fspr_time.h # End Source File # Begin Source File -SOURCE=.\include\apr_user.h +SOURCE=.\include\fspr_user.h # End Source File # Begin Source File -SOURCE=.\include\apr_version.h +SOURCE=.\include\fspr_version.h # End Source File # Begin Source File -SOURCE=.\include\apr_want.h +SOURCE=.\include\fspr_want.h # End Source File # End Group # Begin Source File diff --git a/libs/apr/libapr.rc b/libs/apr/libapr.rc index 925868d1e5..b06b68a105 100644 --- a/libs/apr/libapr.rc +++ b/libs/apr/libapr.rc @@ -1,4 +1,4 @@ -#include "apr_version.h" +#include "fspr_version.h" #define APR_COPYRIGHT "Copyright 2000-2005 The Apache Software " \ "Foundation or its licensors, as applicable." diff --git a/libs/apr/locks/beos/proc_mutex.c b/libs/apr/locks/beos/proc_mutex.c index ce2a580bac..b7227d2ff2 100644 --- a/libs/apr/locks/beos/proc_mutex.c +++ b/libs/apr/locks/beos/proc_mutex.c @@ -18,13 +18,13 @@ * Stephen Beaulieu */ -#include "apr_arch_proc_mutex.h" -#include "apr_strings.h" -#include "apr_portable.h" +#include "fspr_arch_proc_mutex.h" +#include "fspr_strings.h" +#include "fspr_portable.h" -static apr_status_t _proc_mutex_cleanup(void * data) +static fspr_status_t _proc_mutex_cleanup(void * data) { - apr_proc_mutex_t *lock = (apr_proc_mutex_t*)data; + fspr_proc_mutex_t *lock = (fspr_proc_mutex_t*)data; if (lock->LockCount != 0) { /* we're still locked... */ while (atomic_add(&lock->LockCount , -1) > 1){ @@ -39,19 +39,19 @@ static apr_status_t _proc_mutex_cleanup(void * data) return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_proc_mutex_create(apr_proc_mutex_t **mutex, +APR_DECLARE(fspr_status_t) fspr_proc_mutex_create(fspr_proc_mutex_t **mutex, const char *fname, - apr_lockmech_e mech, - apr_pool_t *pool) + fspr_lockmech_e mech, + fspr_pool_t *pool) { - apr_proc_mutex_t *new; - apr_status_t stat = APR_SUCCESS; + fspr_proc_mutex_t *new; + fspr_status_t stat = APR_SUCCESS; if (mech != APR_LOCK_DEFAULT) { return APR_ENOTIMPL; } - new = (apr_proc_mutex_t *)apr_pcalloc(pool, sizeof(apr_proc_mutex_t)); + new = (fspr_proc_mutex_t *)fspr_pcalloc(pool, sizeof(fspr_proc_mutex_t)); if (new == NULL){ return APR_ENOMEM; } @@ -64,21 +64,21 @@ APR_DECLARE(apr_status_t) apr_proc_mutex_create(apr_proc_mutex_t **mutex, new->Lock = stat; new->pool = pool; - apr_pool_cleanup_register(new->pool, (void *)new, _proc_mutex_cleanup, - apr_pool_cleanup_null); + fspr_pool_cleanup_register(new->pool, (void *)new, _proc_mutex_cleanup, + fspr_pool_cleanup_null); (*mutex) = new; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_proc_mutex_child_init(apr_proc_mutex_t **mutex, +APR_DECLARE(fspr_status_t) fspr_proc_mutex_child_init(fspr_proc_mutex_t **mutex, const char *fname, - apr_pool_t *pool) + fspr_pool_t *pool) { return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_proc_mutex_lock(apr_proc_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_proc_mutex_lock(fspr_proc_mutex_t *mutex) { int32 stat; @@ -91,12 +91,12 @@ APR_DECLARE(apr_status_t) apr_proc_mutex_lock(apr_proc_mutex_t *mutex) return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_proc_mutex_trylock(apr_proc_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_proc_mutex_trylock(fspr_proc_mutex_t *mutex) { return APR_ENOTIMPL; } -APR_DECLARE(apr_status_t) apr_proc_mutex_unlock(apr_proc_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_proc_mutex_unlock(fspr_proc_mutex_t *mutex) { int32 stat; @@ -109,58 +109,58 @@ APR_DECLARE(apr_status_t) apr_proc_mutex_unlock(apr_proc_mutex_t *mutex) return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_proc_mutex_destroy(apr_proc_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_proc_mutex_destroy(fspr_proc_mutex_t *mutex) { - apr_status_t stat; + fspr_status_t stat; if ((stat = _proc_mutex_cleanup(mutex)) == APR_SUCCESS) { - apr_pool_cleanup_kill(mutex->pool, mutex, _proc_mutex_cleanup); + fspr_pool_cleanup_kill(mutex->pool, mutex, _proc_mutex_cleanup); return APR_SUCCESS; } return stat; } -APR_DECLARE(apr_status_t) apr_proc_mutex_cleanup(void *mutex) +APR_DECLARE(fspr_status_t) fspr_proc_mutex_cleanup(void *mutex) { return _proc_mutex_cleanup(mutex); } -APR_DECLARE(const char *) apr_proc_mutex_lockfile(apr_proc_mutex_t *mutex) +APR_DECLARE(const char *) fspr_proc_mutex_lockfile(fspr_proc_mutex_t *mutex) { return NULL; } -APR_DECLARE(const char *) apr_proc_mutex_name(apr_proc_mutex_t *mutex) +APR_DECLARE(const char *) fspr_proc_mutex_name(fspr_proc_mutex_t *mutex) { return "beossem"; } -APR_DECLARE(const char *) apr_proc_mutex_defname(void) +APR_DECLARE(const char *) fspr_proc_mutex_defname(void) { return "beossem"; } APR_POOL_IMPLEMENT_ACCESSOR(proc_mutex) -/* Implement OS-specific accessors defined in apr_portable.h */ +/* Implement OS-specific accessors defined in fspr_portable.h */ -APR_DECLARE(apr_status_t) apr_os_proc_mutex_get(apr_os_proc_mutex_t *ospmutex, - apr_proc_mutex_t *pmutex) +APR_DECLARE(fspr_status_t) fspr_os_proc_mutex_get(fspr_os_proc_mutex_t *ospmutex, + fspr_proc_mutex_t *pmutex) { ospmutex->sem = pmutex->Lock; ospmutex->ben = pmutex->LockCount; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_os_proc_mutex_put(apr_proc_mutex_t **pmutex, - apr_os_proc_mutex_t *ospmutex, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_os_proc_mutex_put(fspr_proc_mutex_t **pmutex, + fspr_os_proc_mutex_t *ospmutex, + fspr_pool_t *pool) { if (pool == NULL) { return APR_ENOPOOL; } if ((*pmutex) == NULL) { - (*pmutex) = (apr_proc_mutex_t *)apr_pcalloc(pool, sizeof(apr_proc_mutex_t)); + (*pmutex) = (fspr_proc_mutex_t *)fspr_pcalloc(pool, sizeof(fspr_proc_mutex_t)); (*pmutex)->pool = pool; } (*pmutex)->Lock = ospmutex->sem; diff --git a/libs/apr/locks/beos/thread_cond.c b/libs/apr/locks/beos/thread_cond.c index e3ea460003..6585f61f12 100644 --- a/libs/apr/locks/beos/thread_cond.c +++ b/libs/apr/locks/beos/thread_cond.c @@ -14,15 +14,15 @@ * limitations under the License. */ -#include "apr_arch_thread_mutex.h" -#include "apr_arch_thread_cond.h" -#include "apr_strings.h" -#include "apr_portable.h" +#include "fspr_arch_thread_mutex.h" +#include "fspr_arch_thread_cond.h" +#include "fspr_strings.h" +#include "fspr_portable.h" -static apr_status_t thread_cond_cleanup(void *data) +static fspr_status_t thread_cond_cleanup(void *data) { struct waiter *w; - apr_thread_cond_t *cond = (apr_thread_cond_t *)data; + fspr_thread_cond_t *cond = (fspr_thread_cond_t *)data; acquire_sem(cond->lock); delete_sem(cond->lock); @@ -30,10 +30,10 @@ static apr_status_t thread_cond_cleanup(void *data) return APR_SUCCESS; } -static struct waiter_t *make_waiter(apr_pool_t *pool) +static struct waiter_t *make_waiter(fspr_pool_t *pool) { struct waiter_t *w = (struct waiter_t*) - apr_palloc(pool, sizeof(struct waiter_t)); + fspr_palloc(pool, sizeof(struct waiter_t)); if (w == NULL) return NULL; @@ -46,14 +46,14 @@ static struct waiter_t *make_waiter(apr_pool_t *pool) return w; } -APR_DECLARE(apr_status_t) apr_thread_cond_create(apr_thread_cond_t **cond, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_thread_cond_create(fspr_thread_cond_t **cond, + fspr_pool_t *pool) { - apr_thread_cond_t *new_cond; + fspr_thread_cond_t *new_cond; sem_id rv; int i; - new_cond = (apr_thread_cond_t *)apr_palloc(pool, sizeof(apr_thread_cond_t)); + new_cond = (fspr_thread_cond_t *)fspr_palloc(pool, sizeof(fspr_thread_cond_t)); if (new_cond == NULL) return APR_ENOMEM; @@ -71,21 +71,21 @@ APR_DECLARE(apr_status_t) apr_thread_cond_create(apr_thread_cond_t **cond, APR_RING_INSERT_TAIL(&new_cond->flist, nw, waiter_t, link); } - apr_pool_cleanup_register(new_cond->pool, + fspr_pool_cleanup_register(new_cond->pool, (void *)new_cond, thread_cond_cleanup, - apr_pool_cleanup_null); + fspr_pool_cleanup_null); *cond = new_cond; return APR_SUCCESS; } -static apr_status_t do_wait(apr_thread_cond_t *cond, apr_thread_mutex_t *mutex, +static fspr_status_t do_wait(fspr_thread_cond_t *cond, fspr_thread_mutex_t *mutex, int timeout) { struct waiter_t *wait; thread_id cth = find_thread(NULL); - apr_status_t rv; + fspr_status_t rv; int flags = B_RELATIVE_TIMEOUT; /* We must be the owner of the mutex or we can't do this... */ @@ -104,14 +104,14 @@ static apr_status_t do_wait(apr_thread_cond_t *cond, apr_thread_mutex_t *mutex, cond->condlock = mutex; release_sem(cond->lock); - apr_thread_mutex_unlock(cond->condlock); + fspr_thread_mutex_unlock(cond->condlock); if (timeout == 0) flags = 0; rv = acquire_sem_etc(wait->sem, 1, flags, timeout); - apr_thread_mutex_lock(cond->condlock); + fspr_thread_mutex_lock(cond->condlock); if (rv != B_OK) if (rv == B_TIMED_OUT) @@ -126,20 +126,20 @@ static apr_status_t do_wait(apr_thread_cond_t *cond, apr_thread_mutex_t *mutex, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_cond_wait(apr_thread_cond_t *cond, - apr_thread_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_thread_cond_wait(fspr_thread_cond_t *cond, + fspr_thread_mutex_t *mutex) { return do_wait(cond, mutex, 0); } -APR_DECLARE(apr_status_t) apr_thread_cond_timedwait(apr_thread_cond_t *cond, - apr_thread_mutex_t *mutex, - apr_interval_time_t timeout) +APR_DECLARE(fspr_status_t) fspr_thread_cond_timedwait(fspr_thread_cond_t *cond, + fspr_thread_mutex_t *mutex, + fspr_interval_time_t timeout) { return do_wait(cond, mutex, timeout); } -APR_DECLARE(apr_status_t) apr_thread_cond_signal(apr_thread_cond_t *cond) +APR_DECLARE(fspr_status_t) fspr_thread_cond_signal(fspr_thread_cond_t *cond) { struct waiter_t *wake; @@ -155,7 +155,7 @@ APR_DECLARE(apr_status_t) apr_thread_cond_signal(apr_thread_cond_t *cond) return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_cond_broadcast(apr_thread_cond_t *cond) +APR_DECLARE(fspr_status_t) fspr_thread_cond_broadcast(fspr_thread_cond_t *cond) { struct waiter_t *wake; @@ -171,11 +171,11 @@ APR_DECLARE(apr_status_t) apr_thread_cond_broadcast(apr_thread_cond_t *cond) return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_cond_destroy(apr_thread_cond_t *cond) +APR_DECLARE(fspr_status_t) fspr_thread_cond_destroy(fspr_thread_cond_t *cond) { - apr_status_t stat; + fspr_status_t stat; if ((stat = thread_cond_cleanup(cond)) == APR_SUCCESS) { - apr_pool_cleanup_kill(cond->pool, cond, thread_cond_cleanup); + fspr_pool_cleanup_kill(cond->pool, cond, thread_cond_cleanup); return APR_SUCCESS; } return stat; diff --git a/libs/apr/locks/beos/thread_mutex.c b/libs/apr/locks/beos/thread_mutex.c index b87f76606f..4604939802 100644 --- a/libs/apr/locks/beos/thread_mutex.c +++ b/libs/apr/locks/beos/thread_mutex.c @@ -18,13 +18,13 @@ * Stephen Beaulieu */ -#include "apr_arch_thread_mutex.h" -#include "apr_strings.h" -#include "apr_portable.h" +#include "fspr_arch_thread_mutex.h" +#include "fspr_strings.h" +#include "fspr_portable.h" -static apr_status_t _thread_mutex_cleanup(void * data) +static fspr_status_t _thread_mutex_cleanup(void * data) { - apr_thread_mutex_t *lock = (apr_thread_mutex_t*)data; + fspr_thread_mutex_t *lock = (fspr_thread_mutex_t*)data; if (lock->LockCount != 0) { /* we're still locked... */ while (atomic_add(&lock->LockCount , -1) > 1){ @@ -39,14 +39,14 @@ static apr_status_t _thread_mutex_cleanup(void * data) return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_mutex_create(apr_thread_mutex_t **mutex, +APR_DECLARE(fspr_status_t) fspr_thread_mutex_create(fspr_thread_mutex_t **mutex, unsigned int flags, - apr_pool_t *pool) + fspr_pool_t *pool) { - apr_thread_mutex_t *new_m; - apr_status_t stat = APR_SUCCESS; + fspr_thread_mutex_t *new_m; + fspr_status_t stat = APR_SUCCESS; - new_m = (apr_thread_mutex_t *)apr_pcalloc(pool, sizeof(apr_thread_mutex_t)); + new_m = (fspr_thread_mutex_t *)fspr_pcalloc(pool, sizeof(fspr_thread_mutex_t)); if (new_m == NULL){ return APR_ENOMEM; } @@ -64,24 +64,24 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_create(apr_thread_mutex_t **mutex, */ new_m->nested = flags & APR_THREAD_MUTEX_NESTED; - apr_pool_cleanup_register(new_m->pool, (void *)new_m, _thread_mutex_cleanup, - apr_pool_cleanup_null); + fspr_pool_cleanup_register(new_m->pool, (void *)new_m, _thread_mutex_cleanup, + fspr_pool_cleanup_null); (*mutex) = new_m; return APR_SUCCESS; } #if APR_HAS_CREATE_LOCKS_NP -APR_DECLARE(apr_status_t) apr_thread_mutex_create_np(apr_thread_mutex_t **mutex, +APR_DECLARE(fspr_status_t) fspr_thread_mutex_create_np(fspr_thread_mutex_t **mutex, const char *fname, - apr_lockmech_e_np mech, - apr_pool_t *pool) + fspr_lockmech_e_np mech, + fspr_pool_t *pool) { return APR_ENOTIMPL; } #endif -APR_DECLARE(apr_status_t) apr_thread_mutex_lock(apr_thread_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_thread_mutex_lock(fspr_thread_mutex_t *mutex) { int32 stat; thread_id me = find_thread(NULL); @@ -105,12 +105,12 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_lock(apr_thread_mutex_t *mutex) return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_mutex_trylock(apr_thread_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_thread_mutex_trylock(fspr_thread_mutex_t *mutex) { return APR_ENOTIMPL; } -APR_DECLARE(apr_status_t) apr_thread_mutex_unlock(apr_thread_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_thread_mutex_unlock(fspr_thread_mutex_t *mutex) { int32 stat; @@ -133,11 +133,11 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_unlock(apr_thread_mutex_t *mutex) return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_mutex_destroy(apr_thread_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_thread_mutex_destroy(fspr_thread_mutex_t *mutex) { - apr_status_t stat; + fspr_status_t stat; if ((stat = _thread_mutex_cleanup(mutex)) == APR_SUCCESS) { - apr_pool_cleanup_kill(mutex->pool, mutex, _thread_mutex_cleanup); + fspr_pool_cleanup_kill(mutex->pool, mutex, _thread_mutex_cleanup); return APR_SUCCESS; } return stat; diff --git a/libs/apr/locks/beos/thread_rwlock.c b/libs/apr/locks/beos/thread_rwlock.c index a540b44557..d006b3183a 100644 --- a/libs/apr/locks/beos/thread_rwlock.c +++ b/libs/apr/locks/beos/thread_rwlock.c @@ -18,15 +18,15 @@ * Stephen Beaulieu */ -#include "apr_arch_thread_rwlock.h" -#include "apr_strings.h" -#include "apr_portable.h" +#include "fspr_arch_thread_rwlock.h" +#include "fspr_strings.h" +#include "fspr_portable.h" #define BIG_NUM 100000 -static apr_status_t _thread_rw_cleanup(void * data) +static fspr_status_t _thread_rw_cleanup(void * data) { - apr_thread_rwlock_t *mutex = (apr_thread_rwlock_t*)data; + fspr_thread_rwlock_t *mutex = (fspr_thread_rwlock_t*)data; if (mutex->ReadCount != 0) { while (atomic_add(&mutex->ReadCount , -1) > 1){ @@ -50,12 +50,12 @@ static apr_status_t _thread_rw_cleanup(void * data) return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_rwlock_create(apr_thread_rwlock_t **rwlock, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_create(fspr_thread_rwlock_t **rwlock, + fspr_pool_t *pool) { - apr_thread_rwlock_t *new; + fspr_thread_rwlock_t *new; - new = (apr_thread_rwlock_t *)apr_pcalloc(pool, sizeof(apr_thread_rwlock_t)); + new = (fspr_thread_rwlock_t *)fspr_pcalloc(pool, sizeof(fspr_thread_rwlock_t)); if (new == NULL){ return APR_ENOMEM; } @@ -74,13 +74,13 @@ APR_DECLARE(apr_status_t) apr_thread_rwlock_create(apr_thread_rwlock_t **rwlock, return -1; } - apr_pool_cleanup_register(new->pool, (void *)new, _thread_rw_cleanup, - apr_pool_cleanup_null); + fspr_pool_cleanup_register(new->pool, (void *)new, _thread_rw_cleanup, + fspr_pool_cleanup_null); (*rwlock) = new; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_rwlock_rdlock(apr_thread_rwlock_t *rwlock) +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_rdlock(fspr_thread_rwlock_t *rwlock) { int32 rv = APR_SUCCESS; @@ -100,12 +100,12 @@ APR_DECLARE(apr_status_t) apr_thread_rwlock_rdlock(apr_thread_rwlock_t *rwlock) return rv; } -APR_DECLARE(apr_status_t) apr_thread_rwlock_tryrdlock(apr_thread_rwlock_t *rwlock) +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_tryrdlock(fspr_thread_rwlock_t *rwlock) { return APR_ENOTIMPL; } -APR_DECLARE(apr_status_t) apr_thread_rwlock_wrlock(apr_thread_rwlock_t *rwlock) +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_wrlock(fspr_thread_rwlock_t *rwlock) { int rv = APR_SUCCESS; @@ -136,14 +136,14 @@ APR_DECLARE(apr_status_t) apr_thread_rwlock_wrlock(apr_thread_rwlock_t *rwlock) return rv; } -APR_DECLARE(apr_status_t) apr_thread_rwlock_trywrlock(apr_thread_rwlock_t *rwlock) +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_trywrlock(fspr_thread_rwlock_t *rwlock) { return APR_ENOTIMPL; } -APR_DECLARE(apr_status_t) apr_thread_rwlock_unlock(apr_thread_rwlock_t *rwlock) +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_unlock(fspr_thread_rwlock_t *rwlock) { - apr_status_t rv = APR_SUCCESS; + fspr_status_t rv = APR_SUCCESS; int32 readers; /* we know we hold the lock, so don't check it :) */ @@ -176,11 +176,11 @@ APR_DECLARE(apr_status_t) apr_thread_rwlock_unlock(apr_thread_rwlock_t *rwlock) return rv; } -APR_DECLARE(apr_status_t) apr_thread_rwlock_destroy(apr_thread_rwlock_t *rwlock) +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_destroy(fspr_thread_rwlock_t *rwlock) { - apr_status_t stat; + fspr_status_t stat; if ((stat = _thread_rw_cleanup(rwlock)) == APR_SUCCESS) { - apr_pool_cleanup_kill(rwlock->pool, rwlock, _thread_rw_cleanup); + fspr_pool_cleanup_kill(rwlock->pool, rwlock, _thread_rw_cleanup); return APR_SUCCESS; } return stat; diff --git a/libs/apr/locks/netware/proc_mutex.c b/libs/apr/locks/netware/proc_mutex.c index 77411d0bf2..31bbd9ca05 100644 --- a/libs/apr/locks/netware/proc_mutex.c +++ b/libs/apr/locks/netware/proc_mutex.c @@ -14,27 +14,27 @@ * limitations under the License. */ -#include "apr.h" -#include "apr_private.h" -#include "apr_portable.h" -#include "apr_arch_proc_mutex.h" -#include "apr_arch_thread_mutex.h" +#include "fspr.h" +#include "fspr_private.h" +#include "fspr_portable.h" +#include "fspr_arch_proc_mutex.h" +#include "fspr_arch_thread_mutex.h" -APR_DECLARE(apr_status_t) apr_proc_mutex_create(apr_proc_mutex_t **mutex, +APR_DECLARE(fspr_status_t) fspr_proc_mutex_create(fspr_proc_mutex_t **mutex, const char *fname, - apr_lockmech_e mech, - apr_pool_t *pool) + fspr_lockmech_e mech, + fspr_pool_t *pool) { - apr_status_t ret; - apr_proc_mutex_t *new_mutex = NULL; - new_mutex = (apr_proc_mutex_t *)apr_pcalloc(pool, sizeof(apr_proc_mutex_t)); + fspr_status_t ret; + fspr_proc_mutex_t *new_mutex = NULL; + new_mutex = (fspr_proc_mutex_t *)fspr_pcalloc(pool, sizeof(fspr_proc_mutex_t)); if(new_mutex ==NULL) { return APR_ENOMEM; } new_mutex->pool = pool; - ret = apr_thread_mutex_create(&(new_mutex->mutex), APR_THREAD_MUTEX_DEFAULT, pool); + ret = fspr_thread_mutex_create(&(new_mutex->mutex), APR_THREAD_MUTEX_DEFAULT, pool); if (ret == APR_SUCCESS) *mutex = new_mutex; @@ -42,76 +42,76 @@ APR_DECLARE(apr_status_t) apr_proc_mutex_create(apr_proc_mutex_t **mutex, return ret; } -APR_DECLARE(apr_status_t) apr_proc_mutex_child_init(apr_proc_mutex_t **mutex, +APR_DECLARE(fspr_status_t) fspr_proc_mutex_child_init(fspr_proc_mutex_t **mutex, const char *fname, - apr_pool_t *pool) + fspr_pool_t *pool) { return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_proc_mutex_lock(apr_proc_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_proc_mutex_lock(fspr_proc_mutex_t *mutex) { if (mutex) - return apr_thread_mutex_lock(mutex->mutex); + return fspr_thread_mutex_lock(mutex->mutex); return APR_ENOLOCK; } -APR_DECLARE(apr_status_t) apr_proc_mutex_trylock(apr_proc_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_proc_mutex_trylock(fspr_proc_mutex_t *mutex) { if (mutex) - return apr_thread_mutex_trylock(mutex->mutex); + return fspr_thread_mutex_trylock(mutex->mutex); return APR_ENOLOCK; } -APR_DECLARE(apr_status_t) apr_proc_mutex_unlock(apr_proc_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_proc_mutex_unlock(fspr_proc_mutex_t *mutex) { if (mutex) - return apr_thread_mutex_unlock(mutex->mutex); + return fspr_thread_mutex_unlock(mutex->mutex); return APR_ENOLOCK; } -APR_DECLARE(apr_status_t) apr_proc_mutex_cleanup(void *mutex) +APR_DECLARE(fspr_status_t) fspr_proc_mutex_cleanup(void *mutex) { - return apr_proc_mutex_destroy(mutex); + return fspr_proc_mutex_destroy(mutex); } -APR_DECLARE(apr_status_t) apr_proc_mutex_destroy(apr_proc_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_proc_mutex_destroy(fspr_proc_mutex_t *mutex) { if (mutex) - return apr_thread_mutex_destroy(mutex->mutex); + return fspr_thread_mutex_destroy(mutex->mutex); return APR_ENOLOCK; } -APR_DECLARE(const char *) apr_proc_mutex_lockfile(apr_proc_mutex_t *mutex) +APR_DECLARE(const char *) fspr_proc_mutex_lockfile(fspr_proc_mutex_t *mutex) { return NULL; } -APR_DECLARE(const char *) apr_proc_mutex_name(apr_proc_mutex_t *mutex) +APR_DECLARE(const char *) fspr_proc_mutex_name(fspr_proc_mutex_t *mutex) { return "netwarethread"; } -APR_DECLARE(const char *) apr_proc_mutex_defname(void) +APR_DECLARE(const char *) fspr_proc_mutex_defname(void) { return "netwarethread"; } APR_POOL_IMPLEMENT_ACCESSOR(proc_mutex) -/* Implement OS-specific accessors defined in apr_portable.h */ +/* Implement OS-specific accessors defined in fspr_portable.h */ -apr_status_t apr_os_proc_mutex_get(apr_os_proc_mutex_t *ospmutex, - apr_proc_mutex_t *pmutex) +fspr_status_t fspr_os_proc_mutex_get(fspr_os_proc_mutex_t *ospmutex, + fspr_proc_mutex_t *pmutex) { if (pmutex) ospmutex = pmutex->mutex->mutex; return APR_ENOLOCK; } -apr_status_t apr_os_proc_mutex_put(apr_proc_mutex_t **pmutex, - apr_os_proc_mutex_t *ospmutex, - apr_pool_t *pool) +fspr_status_t fspr_os_proc_mutex_put(fspr_proc_mutex_t **pmutex, + fspr_os_proc_mutex_t *ospmutex, + fspr_pool_t *pool) { return APR_ENOTIMPL; } diff --git a/libs/apr/locks/netware/thread_cond.c b/libs/apr/locks/netware/thread_cond.c index dcb21edc9e..19f4649fe5 100644 --- a/libs/apr/locks/netware/thread_cond.c +++ b/libs/apr/locks/netware/thread_cond.c @@ -16,28 +16,28 @@ #include -#include "apr.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_strings.h" -#include "apr_arch_thread_mutex.h" -#include "apr_arch_thread_cond.h" -#include "apr_portable.h" +#include "fspr.h" +#include "fspr_private.h" +#include "fspr_general.h" +#include "fspr_strings.h" +#include "fspr_arch_thread_mutex.h" +#include "fspr_arch_thread_cond.h" +#include "fspr_portable.h" -static apr_status_t thread_cond_cleanup(void *data) +static fspr_status_t thread_cond_cleanup(void *data) { - apr_thread_cond_t *cond = (apr_thread_cond_t *)data; + fspr_thread_cond_t *cond = (fspr_thread_cond_t *)data; NXCondFree(cond->cond); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_cond_create(apr_thread_cond_t **cond, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_thread_cond_create(fspr_thread_cond_t **cond, + fspr_pool_t *pool) { - apr_thread_cond_t *new_cond = NULL; + fspr_thread_cond_t *new_cond = NULL; - new_cond = (apr_thread_cond_t *)apr_pcalloc(pool, sizeof(apr_thread_cond_t)); + new_cond = (fspr_thread_cond_t *)fspr_pcalloc(pool, sizeof(fspr_thread_cond_t)); if(new_cond ==NULL) { return APR_ENOMEM; @@ -49,24 +49,24 @@ APR_DECLARE(apr_status_t) apr_thread_cond_create(apr_thread_cond_t **cond, if(new_cond->cond == NULL) return APR_ENOMEM; - apr_pool_cleanup_register(new_cond->pool, new_cond, + fspr_pool_cleanup_register(new_cond->pool, new_cond, (void*)thread_cond_cleanup, - apr_pool_cleanup_null); + fspr_pool_cleanup_null); *cond = new_cond; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_cond_wait(apr_thread_cond_t *cond, - apr_thread_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_thread_cond_wait(fspr_thread_cond_t *cond, + fspr_thread_mutex_t *mutex) { if (NXCondWait(cond->cond, mutex->mutex) != 0) return APR_EINTR; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_cond_timedwait(apr_thread_cond_t *cond, - apr_thread_mutex_t *mutex, - apr_interval_time_t timeout){ +APR_DECLARE(fspr_status_t) fspr_thread_cond_timedwait(fspr_thread_cond_t *cond, + fspr_thread_mutex_t *mutex, + fspr_interval_time_t timeout){ if (NXCondTimedWait(cond->cond, mutex->mutex, (timeout*1000)/NXGetSystemTick()) == NX_ETIMEDOUT) { return APR_TIMEUP; @@ -74,23 +74,23 @@ APR_DECLARE(apr_status_t) apr_thread_cond_timedwait(apr_thread_cond_t *cond, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_cond_signal(apr_thread_cond_t *cond) +APR_DECLARE(fspr_status_t) fspr_thread_cond_signal(fspr_thread_cond_t *cond) { NXCondSignal(cond->cond); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_cond_broadcast(apr_thread_cond_t *cond) +APR_DECLARE(fspr_status_t) fspr_thread_cond_broadcast(fspr_thread_cond_t *cond) { NXCondBroadcast(cond->cond); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_cond_destroy(apr_thread_cond_t *cond) +APR_DECLARE(fspr_status_t) fspr_thread_cond_destroy(fspr_thread_cond_t *cond) { - apr_status_t stat; + fspr_status_t stat; if ((stat = thread_cond_cleanup(cond)) == APR_SUCCESS) { - apr_pool_cleanup_kill(cond->pool, cond, thread_cond_cleanup); + fspr_pool_cleanup_kill(cond->pool, cond, thread_cond_cleanup); return APR_SUCCESS; } return stat; diff --git a/libs/apr/locks/netware/thread_mutex.c b/libs/apr/locks/netware/thread_mutex.c index 98bf33bd22..8607211a4b 100644 --- a/libs/apr/locks/netware/thread_mutex.c +++ b/libs/apr/locks/netware/thread_mutex.c @@ -14,33 +14,33 @@ * limitations under the License. */ -#include "apr.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_strings.h" -#include "apr_arch_thread_mutex.h" -#include "apr_portable.h" +#include "fspr.h" +#include "fspr_private.h" +#include "fspr_general.h" +#include "fspr_strings.h" +#include "fspr_arch_thread_mutex.h" +#include "fspr_portable.h" -static apr_status_t thread_mutex_cleanup(void *data) +static fspr_status_t thread_mutex_cleanup(void *data) { - apr_thread_mutex_t *mutex = (apr_thread_mutex_t *)data; + fspr_thread_mutex_t *mutex = (fspr_thread_mutex_t *)data; NXMutexFree(mutex->mutex); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_mutex_create(apr_thread_mutex_t **mutex, +APR_DECLARE(fspr_status_t) fspr_thread_mutex_create(fspr_thread_mutex_t **mutex, unsigned int flags, - apr_pool_t *pool) + fspr_pool_t *pool) { - apr_thread_mutex_t *new_mutex = NULL; + fspr_thread_mutex_t *new_mutex = NULL; /* XXX: Implement _UNNESTED flavor and favor _DEFAULT for performance */ if (flags & APR_THREAD_MUTEX_UNNESTED) { return APR_ENOTIMPL; } - new_mutex = (apr_thread_mutex_t *)apr_pcalloc(pool, sizeof(apr_thread_mutex_t)); + new_mutex = (fspr_thread_mutex_t *)fspr_pcalloc(pool, sizeof(fspr_thread_mutex_t)); if(new_mutex ==NULL) { return APR_ENOMEM; @@ -52,37 +52,37 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_create(apr_thread_mutex_t **mutex, if(new_mutex->mutex == NULL) return APR_ENOMEM; - apr_pool_cleanup_register(new_mutex->pool, new_mutex, + fspr_pool_cleanup_register(new_mutex->pool, new_mutex, (void*)thread_mutex_cleanup, - apr_pool_cleanup_null); + fspr_pool_cleanup_null); *mutex = new_mutex; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_mutex_lock(apr_thread_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_thread_mutex_lock(fspr_thread_mutex_t *mutex) { NXLock(mutex->mutex); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_mutex_trylock(apr_thread_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_thread_mutex_trylock(fspr_thread_mutex_t *mutex) { if (!NXTryLock(mutex->mutex)) return APR_EBUSY; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_mutex_unlock(apr_thread_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_thread_mutex_unlock(fspr_thread_mutex_t *mutex) { NXUnlock(mutex->mutex); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_mutex_destroy(apr_thread_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_thread_mutex_destroy(fspr_thread_mutex_t *mutex) { - apr_status_t stat; + fspr_status_t stat; if ((stat = thread_mutex_cleanup(mutex)) == APR_SUCCESS) { - apr_pool_cleanup_kill(mutex->pool, mutex, thread_mutex_cleanup); + fspr_pool_cleanup_kill(mutex->pool, mutex, thread_mutex_cleanup); return APR_SUCCESS; } return stat; diff --git a/libs/apr/locks/netware/thread_rwlock.c b/libs/apr/locks/netware/thread_rwlock.c index d0bf3ddf34..d0f094d2df 100644 --- a/libs/apr/locks/netware/thread_rwlock.c +++ b/libs/apr/locks/netware/thread_rwlock.c @@ -14,85 +14,85 @@ * limitations under the License. */ -#include "apr.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_strings.h" -#include "apr_arch_thread_rwlock.h" -#include "apr_portable.h" +#include "fspr.h" +#include "fspr_private.h" +#include "fspr_general.h" +#include "fspr_strings.h" +#include "fspr_arch_thread_rwlock.h" +#include "fspr_portable.h" -static apr_status_t thread_rwlock_cleanup(void *data) +static fspr_status_t thread_rwlock_cleanup(void *data) { - apr_thread_rwlock_t *rwlock = (apr_thread_rwlock_t *)data; + fspr_thread_rwlock_t *rwlock = (fspr_thread_rwlock_t *)data; NXRwLockFree (rwlock->rwlock); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_rwlock_create(apr_thread_rwlock_t **rwlock, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_create(fspr_thread_rwlock_t **rwlock, + fspr_pool_t *pool) { - apr_thread_rwlock_t *new_rwlock = NULL; + fspr_thread_rwlock_t *new_rwlock = NULL; NXHierarchy_t hierarchy = 1; //for libc NKS NXRwLockAlloc NXLockInfo_t *info; //for libc NKS NXRwLockAlloc - new_rwlock = (apr_thread_rwlock_t *)apr_pcalloc(pool, sizeof(apr_thread_rwlock_t)); + new_rwlock = (fspr_thread_rwlock_t *)fspr_pcalloc(pool, sizeof(fspr_thread_rwlock_t)); if(new_rwlock ==NULL) { return APR_ENOMEM; } new_rwlock->pool = pool; - info = (NXLockInfo_t *)apr_pcalloc(pool, sizeof(NXLockInfo_t)); + info = (NXLockInfo_t *)fspr_pcalloc(pool, sizeof(NXLockInfo_t)); new_rwlock->rwlock = NXRwLockAlloc(hierarchy, info); if(new_rwlock->rwlock == NULL) return APR_ENOMEM; - apr_pool_cleanup_register(new_rwlock->pool, new_rwlock, thread_rwlock_cleanup, - apr_pool_cleanup_null); + fspr_pool_cleanup_register(new_rwlock->pool, new_rwlock, thread_rwlock_cleanup, + fspr_pool_cleanup_null); *rwlock = new_rwlock; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_rwlock_rdlock(apr_thread_rwlock_t *rwlock) +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_rdlock(fspr_thread_rwlock_t *rwlock) { NXRdLock(rwlock->rwlock); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_rwlock_tryrdlock(apr_thread_rwlock_t *rwlock) +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_tryrdlock(fspr_thread_rwlock_t *rwlock) { if (!NXTryRdLock(rwlock->rwlock)) return APR_EBUSY; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_rwlock_wrlock(apr_thread_rwlock_t *rwlock) +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_wrlock(fspr_thread_rwlock_t *rwlock) { NXWrLock(rwlock->rwlock); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_rwlock_trywrlock(apr_thread_rwlock_t *rwlock) +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_trywrlock(fspr_thread_rwlock_t *rwlock) { if (!NXTryWrLock(rwlock->rwlock)) return APR_EBUSY; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_rwlock_unlock(apr_thread_rwlock_t *rwlock) +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_unlock(fspr_thread_rwlock_t *rwlock) { NXRwUnlock(rwlock->rwlock); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_rwlock_destroy(apr_thread_rwlock_t *rwlock) +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_destroy(fspr_thread_rwlock_t *rwlock) { - apr_status_t stat; + fspr_status_t stat; if ((stat = thread_rwlock_cleanup(rwlock)) == APR_SUCCESS) { - apr_pool_cleanup_kill(rwlock->pool, rwlock, thread_rwlock_cleanup); + fspr_pool_cleanup_kill(rwlock->pool, rwlock, thread_rwlock_cleanup); return APR_SUCCESS; } return stat; diff --git a/libs/apr/locks/os2/proc_mutex.c b/libs/apr/locks/os2/proc_mutex.c index 5a49356355..695dc0931e 100644 --- a/libs/apr/locks/os2/proc_mutex.c +++ b/libs/apr/locks/os2/proc_mutex.c @@ -14,18 +14,18 @@ * limitations under the License. */ -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_strings.h" -#include "apr_portable.h" -#include "apr_arch_proc_mutex.h" -#include "apr_arch_file_io.h" +#include "fspr_general.h" +#include "fspr_lib.h" +#include "fspr_strings.h" +#include "fspr_portable.h" +#include "fspr_arch_proc_mutex.h" +#include "fspr_arch_file_io.h" #include #include #define CurrentTid (*_threadid) -static char *fixed_name(const char *fname, apr_pool_t *pool) +static char *fixed_name(const char *fname, fspr_pool_t *pool) { char *semname; @@ -37,7 +37,7 @@ static char *fixed_name(const char *fname, apr_pool_t *pool) fname++; } - semname = apr_pstrcat(pool, "/SEM32/", fname, NULL); + semname = fspr_pstrcat(pool, "/SEM32/", fname, NULL); if (semname[8] == ':') { semname[8] = '$'; @@ -49,34 +49,34 @@ static char *fixed_name(const char *fname, apr_pool_t *pool) -APR_DECLARE(apr_status_t) apr_proc_mutex_cleanup(void *vmutex) +APR_DECLARE(fspr_status_t) fspr_proc_mutex_cleanup(void *vmutex) { - apr_proc_mutex_t *mutex = vmutex; - return apr_proc_mutex_destroy(mutex); + fspr_proc_mutex_t *mutex = vmutex; + return fspr_proc_mutex_destroy(mutex); } -APR_DECLARE(const char *) apr_proc_mutex_lockfile(apr_proc_mutex_t *mutex) +APR_DECLARE(const char *) fspr_proc_mutex_lockfile(fspr_proc_mutex_t *mutex) { return NULL; } -APR_DECLARE(const char *) apr_proc_mutex_name(apr_proc_mutex_t *mutex) +APR_DECLARE(const char *) fspr_proc_mutex_name(fspr_proc_mutex_t *mutex) { return "os2sem"; } -APR_DECLARE(const char *) apr_proc_mutex_defname(void) +APR_DECLARE(const char *) fspr_proc_mutex_defname(void) { return "os2sem"; } -APR_DECLARE(apr_status_t) apr_proc_mutex_create(apr_proc_mutex_t **mutex, +APR_DECLARE(fspr_status_t) fspr_proc_mutex_create(fspr_proc_mutex_t **mutex, const char *fname, - apr_lockmech_e mech, - apr_pool_t *pool) + fspr_lockmech_e mech, + fspr_pool_t *pool) { - apr_proc_mutex_t *new; + fspr_proc_mutex_t *new; ULONG rc; char *semname; @@ -84,7 +84,7 @@ APR_DECLARE(apr_status_t) apr_proc_mutex_create(apr_proc_mutex_t **mutex, return APR_ENOTIMPL; } - new = (apr_proc_mutex_t *)apr_palloc(pool, sizeof(apr_proc_mutex_t)); + new = (fspr_proc_mutex_t *)fspr_palloc(pool, sizeof(fspr_proc_mutex_t)); new->pool = pool; new->owner = 0; new->lock_count = 0; @@ -94,7 +94,7 @@ APR_DECLARE(apr_status_t) apr_proc_mutex_create(apr_proc_mutex_t **mutex, rc = DosCreateMutexSem(semname, &(new->hMutex), DC_SEM_SHARED, FALSE); if (!rc) { - apr_pool_cleanup_register(pool, new, apr_proc_mutex_cleanup, apr_pool_cleanup_null); + fspr_pool_cleanup_register(pool, new, fspr_proc_mutex_cleanup, fspr_pool_cleanup_null); } return APR_FROM_OS_ERROR(rc); @@ -102,15 +102,15 @@ APR_DECLARE(apr_status_t) apr_proc_mutex_create(apr_proc_mutex_t **mutex, -APR_DECLARE(apr_status_t) apr_proc_mutex_child_init(apr_proc_mutex_t **mutex, +APR_DECLARE(fspr_status_t) fspr_proc_mutex_child_init(fspr_proc_mutex_t **mutex, const char *fname, - apr_pool_t *pool) + fspr_pool_t *pool) { - apr_proc_mutex_t *new; + fspr_proc_mutex_t *new; ULONG rc; char *semname; - new = (apr_proc_mutex_t *)apr_palloc(pool, sizeof(apr_proc_mutex_t)); + new = (fspr_proc_mutex_t *)fspr_palloc(pool, sizeof(fspr_proc_mutex_t)); new->pool = pool; new->owner = 0; new->lock_count = 0; @@ -120,7 +120,7 @@ APR_DECLARE(apr_status_t) apr_proc_mutex_child_init(apr_proc_mutex_t **mutex, *mutex = new; if (!rc) { - apr_pool_cleanup_register(pool, new, apr_proc_mutex_cleanup, apr_pool_cleanup_null); + fspr_pool_cleanup_register(pool, new, fspr_proc_mutex_cleanup, fspr_pool_cleanup_null); } return APR_FROM_OS_ERROR(rc); @@ -128,7 +128,7 @@ APR_DECLARE(apr_status_t) apr_proc_mutex_child_init(apr_proc_mutex_t **mutex, -APR_DECLARE(apr_status_t) apr_proc_mutex_lock(apr_proc_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_proc_mutex_lock(fspr_proc_mutex_t *mutex) { ULONG rc = DosRequestMutexSem(mutex->hMutex, SEM_INDEFINITE_WAIT); @@ -142,7 +142,7 @@ APR_DECLARE(apr_status_t) apr_proc_mutex_lock(apr_proc_mutex_t *mutex) -APR_DECLARE(apr_status_t) apr_proc_mutex_trylock(apr_proc_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_proc_mutex_trylock(fspr_proc_mutex_t *mutex) { ULONG rc = DosRequestMutexSem(mutex->hMutex, SEM_IMMEDIATE_RETURN); @@ -156,7 +156,7 @@ APR_DECLARE(apr_status_t) apr_proc_mutex_trylock(apr_proc_mutex_t *mutex) -APR_DECLARE(apr_status_t) apr_proc_mutex_unlock(apr_proc_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_proc_mutex_unlock(fspr_proc_mutex_t *mutex) { ULONG rc; @@ -171,14 +171,14 @@ APR_DECLARE(apr_status_t) apr_proc_mutex_unlock(apr_proc_mutex_t *mutex) -APR_DECLARE(apr_status_t) apr_proc_mutex_destroy(apr_proc_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_proc_mutex_destroy(fspr_proc_mutex_t *mutex) { ULONG rc; - apr_status_t status = APR_SUCCESS; + fspr_status_t status = APR_SUCCESS; if (mutex->owner == CurrentTid) { while (mutex->lock_count > 0 && status == APR_SUCCESS) { - status = apr_proc_mutex_unlock(mutex); + status = fspr_proc_mutex_unlock(mutex); } } @@ -205,10 +205,10 @@ APR_POOL_IMPLEMENT_ACCESSOR(proc_mutex) -/* Implement OS-specific accessors defined in apr_portable.h */ +/* Implement OS-specific accessors defined in fspr_portable.h */ -APR_DECLARE(apr_status_t) apr_os_proc_mutex_get(apr_os_proc_mutex_t *ospmutex, - apr_proc_mutex_t *pmutex) +APR_DECLARE(fspr_status_t) fspr_os_proc_mutex_get(fspr_os_proc_mutex_t *ospmutex, + fspr_proc_mutex_t *pmutex) { *ospmutex = pmutex->hMutex; return APR_ENOTIMPL; @@ -216,13 +216,13 @@ APR_DECLARE(apr_status_t) apr_os_proc_mutex_get(apr_os_proc_mutex_t *ospmutex, -APR_DECLARE(apr_status_t) apr_os_proc_mutex_put(apr_proc_mutex_t **pmutex, - apr_os_proc_mutex_t *ospmutex, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_os_proc_mutex_put(fspr_proc_mutex_t **pmutex, + fspr_os_proc_mutex_t *ospmutex, + fspr_pool_t *pool) { - apr_proc_mutex_t *new; + fspr_proc_mutex_t *new; - new = (apr_proc_mutex_t *)apr_palloc(pool, sizeof(apr_proc_mutex_t)); + new = (fspr_proc_mutex_t *)fspr_palloc(pool, sizeof(fspr_proc_mutex_t)); new->pool = pool; new->owner = 0; new->lock_count = 0; diff --git a/libs/apr/locks/os2/thread_cond.c b/libs/apr/locks/os2/thread_cond.c index ec6034f55d..509d159363 100644 --- a/libs/apr/locks/os2/thread_cond.c +++ b/libs/apr/locks/os2/thread_cond.c @@ -14,44 +14,44 @@ * limitations under the License. */ -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_strings.h" -#include "apr_portable.h" -#include "apr_arch_thread_mutex.h" -#include "apr_arch_thread_cond.h" -#include "apr_arch_file_io.h" +#include "fspr_general.h" +#include "fspr_lib.h" +#include "fspr_strings.h" +#include "fspr_portable.h" +#include "fspr_arch_thread_mutex.h" +#include "fspr_arch_thread_cond.h" +#include "fspr_arch_file_io.h" #include -APR_DECLARE(apr_status_t) apr_thread_cond_create(apr_thread_cond_t **cond, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_thread_cond_create(fspr_thread_cond_t **cond, + fspr_pool_t *pool) { return APR_ENOTIMPL; } -APR_DECLARE(apr_status_t) apr_thread_cond_wait(apr_thread_cond_t *cond, - apr_thread_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_thread_cond_wait(fspr_thread_cond_t *cond, + fspr_thread_mutex_t *mutex) { return APR_ENOTIMPL; } -APR_DECLARE(apr_status_t) apr_thread_cond_timedwait(apr_thread_cond_t *cond, - apr_thread_mutex_t *mutex, - apr_interval_time_t timeout){ +APR_DECLARE(fspr_status_t) fspr_thread_cond_timedwait(fspr_thread_cond_t *cond, + fspr_thread_mutex_t *mutex, + fspr_interval_time_t timeout){ return APR_ENOTIMPL; } -APR_DECLARE(apr_status_t) apr_thread_cond_signal(apr_thread_cond_t *cond) +APR_DECLARE(fspr_status_t) fspr_thread_cond_signal(fspr_thread_cond_t *cond) { return APR_ENOTIMPL; } -APR_DECLARE(apr_status_t) apr_thread_cond_broadcast(apr_thread_cond_t *cond) +APR_DECLARE(fspr_status_t) fspr_thread_cond_broadcast(fspr_thread_cond_t *cond) { return APR_ENOTIMPL; } -APR_DECLARE(apr_status_t) apr_thread_cond_destroy(apr_thread_cond_t *cond) +APR_DECLARE(fspr_status_t) fspr_thread_cond_destroy(fspr_thread_cond_t *cond) { return APR_ENOTIMPL; } diff --git a/libs/apr/locks/os2/thread_mutex.c b/libs/apr/locks/os2/thread_mutex.c index 5d8436be4f..873820ded2 100644 --- a/libs/apr/locks/os2/thread_mutex.c +++ b/libs/apr/locks/os2/thread_mutex.c @@ -14,19 +14,19 @@ * limitations under the License. */ -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_strings.h" -#include "apr_portable.h" -#include "apr_arch_thread_mutex.h" -#include "apr_arch_file_io.h" +#include "fspr_general.h" +#include "fspr_lib.h" +#include "fspr_strings.h" +#include "fspr_portable.h" +#include "fspr_arch_thread_mutex.h" +#include "fspr_arch_file_io.h" #include #include -static apr_status_t thread_mutex_cleanup(void *themutex) +static fspr_status_t thread_mutex_cleanup(void *themutex) { - apr_thread_mutex_t *mutex = themutex; - return apr_thread_mutex_destroy(mutex); + fspr_thread_mutex_t *mutex = themutex; + return fspr_thread_mutex_destroy(mutex); } @@ -34,28 +34,28 @@ static apr_status_t thread_mutex_cleanup(void *themutex) /* XXX: Need to respect APR_THREAD_MUTEX_[UN]NESTED flags argument * or return APR_ENOTIMPL!!! */ -APR_DECLARE(apr_status_t) apr_thread_mutex_create(apr_thread_mutex_t **mutex, +APR_DECLARE(fspr_status_t) fspr_thread_mutex_create(fspr_thread_mutex_t **mutex, unsigned int flags, - apr_pool_t *pool) + fspr_pool_t *pool) { - apr_thread_mutex_t *new_mutex; + fspr_thread_mutex_t *new_mutex; ULONG rc; - new_mutex = (apr_thread_mutex_t *)apr_palloc(pool, sizeof(apr_thread_mutex_t)); + new_mutex = (fspr_thread_mutex_t *)fspr_palloc(pool, sizeof(fspr_thread_mutex_t)); new_mutex->pool = pool; rc = DosCreateMutexSem(NULL, &(new_mutex->hMutex), 0, FALSE); *mutex = new_mutex; if (!rc) - apr_pool_cleanup_register(pool, new_mutex, thread_mutex_cleanup, apr_pool_cleanup_null); + fspr_pool_cleanup_register(pool, new_mutex, thread_mutex_cleanup, fspr_pool_cleanup_null); return APR_OS2_STATUS(rc); } -APR_DECLARE(apr_status_t) apr_thread_mutex_lock(apr_thread_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_thread_mutex_lock(fspr_thread_mutex_t *mutex) { ULONG rc = DosRequestMutexSem(mutex->hMutex, SEM_INDEFINITE_WAIT); return APR_OS2_STATUS(rc); @@ -63,7 +63,7 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_lock(apr_thread_mutex_t *mutex) -APR_DECLARE(apr_status_t) apr_thread_mutex_trylock(apr_thread_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_thread_mutex_trylock(fspr_thread_mutex_t *mutex) { ULONG rc = DosRequestMutexSem(mutex->hMutex, SEM_IMMEDIATE_RETURN); return APR_OS2_STATUS(rc); @@ -71,7 +71,7 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_trylock(apr_thread_mutex_t *mutex) -APR_DECLARE(apr_status_t) apr_thread_mutex_unlock(apr_thread_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_thread_mutex_unlock(fspr_thread_mutex_t *mutex) { ULONG rc = DosReleaseMutexSem(mutex->hMutex); return APR_OS2_STATUS(rc); @@ -79,7 +79,7 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_unlock(apr_thread_mutex_t *mutex) -APR_DECLARE(apr_status_t) apr_thread_mutex_destroy(apr_thread_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_thread_mutex_destroy(fspr_thread_mutex_t *mutex) { ULONG rc; diff --git a/libs/apr/locks/os2/thread_rwlock.c b/libs/apr/locks/os2/thread_rwlock.c index 195a56bda3..6d7ad2280f 100644 --- a/libs/apr/locks/os2/thread_rwlock.c +++ b/libs/apr/locks/os2/thread_rwlock.c @@ -14,29 +14,29 @@ * limitations under the License. */ -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_strings.h" -#include "apr_portable.h" -#include "apr_arch_thread_rwlock.h" -#include "apr_arch_file_io.h" +#include "fspr_general.h" +#include "fspr_lib.h" +#include "fspr_strings.h" +#include "fspr_portable.h" +#include "fspr_arch_thread_rwlock.h" +#include "fspr_arch_file_io.h" #include -static apr_status_t thread_rwlock_cleanup(void *therwlock) +static fspr_status_t thread_rwlock_cleanup(void *therwlock) { - apr_thread_rwlock_t *rwlock = therwlock; - return apr_thread_rwlock_destroy(rwlock); + fspr_thread_rwlock_t *rwlock = therwlock; + return fspr_thread_rwlock_destroy(rwlock); } -APR_DECLARE(apr_status_t) apr_thread_rwlock_create(apr_thread_rwlock_t **rwlock, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_create(fspr_thread_rwlock_t **rwlock, + fspr_pool_t *pool) { - apr_thread_rwlock_t *new_rwlock; + fspr_thread_rwlock_t *new_rwlock; ULONG rc; - new_rwlock = (apr_thread_rwlock_t *)apr_palloc(pool, sizeof(apr_thread_rwlock_t)); + new_rwlock = (fspr_thread_rwlock_t *)fspr_palloc(pool, sizeof(fspr_thread_rwlock_t)); new_rwlock->pool = pool; new_rwlock->readers = 0; @@ -53,15 +53,15 @@ APR_DECLARE(apr_status_t) apr_thread_rwlock_create(apr_thread_rwlock_t **rwlock, *rwlock = new_rwlock; if (!rc) - apr_pool_cleanup_register(pool, new_rwlock, thread_rwlock_cleanup, - apr_pool_cleanup_null); + fspr_pool_cleanup_register(pool, new_rwlock, thread_rwlock_cleanup, + fspr_pool_cleanup_null); return APR_FROM_OS_ERROR(rc); } -APR_DECLARE(apr_status_t) apr_thread_rwlock_rdlock(apr_thread_rwlock_t *rwlock) +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_rdlock(fspr_thread_rwlock_t *rwlock) { ULONG rc, posts; @@ -82,7 +82,7 @@ APR_DECLARE(apr_status_t) apr_thread_rwlock_rdlock(apr_thread_rwlock_t *rwlock) -APR_DECLARE(apr_status_t) apr_thread_rwlock_tryrdlock(apr_thread_rwlock_t *rwlock) +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_tryrdlock(fspr_thread_rwlock_t *rwlock) { /* As above but with different wait time */ ULONG rc, posts; @@ -100,7 +100,7 @@ APR_DECLARE(apr_status_t) apr_thread_rwlock_tryrdlock(apr_thread_rwlock_t *rwloc -APR_DECLARE(apr_status_t) apr_thread_rwlock_wrlock(apr_thread_rwlock_t *rwlock) +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_wrlock(fspr_thread_rwlock_t *rwlock) { ULONG rc; @@ -125,7 +125,7 @@ APR_DECLARE(apr_status_t) apr_thread_rwlock_wrlock(apr_thread_rwlock_t *rwlock) -APR_DECLARE(apr_status_t) apr_thread_rwlock_trywrlock(apr_thread_rwlock_t *rwlock) +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_trywrlock(fspr_thread_rwlock_t *rwlock) { ULONG rc; @@ -149,7 +149,7 @@ APR_DECLARE(apr_status_t) apr_thread_rwlock_trywrlock(apr_thread_rwlock_t *rwloc -APR_DECLARE(apr_status_t) apr_thread_rwlock_unlock(apr_thread_rwlock_t *rwlock) +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_unlock(fspr_thread_rwlock_t *rwlock) { ULONG rc; @@ -176,7 +176,7 @@ APR_DECLARE(apr_status_t) apr_thread_rwlock_unlock(apr_thread_rwlock_t *rwlock) -APR_DECLARE(apr_status_t) apr_thread_rwlock_destroy(apr_thread_rwlock_t *rwlock) +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_destroy(fspr_thread_rwlock_t *rwlock) { ULONG rc; diff --git a/libs/apr/locks/unix/global_mutex.c b/libs/apr/locks/unix/global_mutex.c index bfe360aa99..193482a62d 100644 --- a/libs/apr/locks/unix/global_mutex.c +++ b/libs/apr/locks/unix/global_mutex.c @@ -14,27 +14,27 @@ * limitations under the License. */ -#include "apr.h" -#include "apr_strings.h" -#include "apr_arch_global_mutex.h" -#include "apr_proc_mutex.h" -#include "apr_thread_mutex.h" -#include "apr_portable.h" +#include "fspr.h" +#include "fspr_strings.h" +#include "fspr_arch_global_mutex.h" +#include "fspr_proc_mutex.h" +#include "fspr_thread_mutex.h" +#include "fspr_portable.h" -static apr_status_t global_mutex_cleanup(void *data) +static fspr_status_t global_mutex_cleanup(void *data) { - apr_global_mutex_t *m = (apr_global_mutex_t *)data; - apr_status_t rv; + fspr_global_mutex_t *m = (fspr_global_mutex_t *)data; + fspr_status_t rv; - rv = apr_proc_mutex_destroy(m->proc_mutex); + rv = fspr_proc_mutex_destroy(m->proc_mutex); #if APR_HAS_THREADS if (m->thread_mutex) { if (rv != APR_SUCCESS) { - (void)apr_thread_mutex_destroy(m->thread_mutex); + (void)fspr_thread_mutex_destroy(m->thread_mutex); } else { - rv = apr_thread_mutex_destroy(m->thread_mutex); + rv = fspr_thread_mutex_destroy(m->thread_mutex); } } #endif /* APR_HAS_THREADS */ @@ -42,18 +42,18 @@ static apr_status_t global_mutex_cleanup(void *data) return rv; } -APR_DECLARE(apr_status_t) apr_global_mutex_create(apr_global_mutex_t **mutex, +APR_DECLARE(fspr_status_t) fspr_global_mutex_create(fspr_global_mutex_t **mutex, const char *fname, - apr_lockmech_e mech, - apr_pool_t *pool) + fspr_lockmech_e mech, + fspr_pool_t *pool) { - apr_status_t rv; - apr_global_mutex_t *m; + fspr_status_t rv; + fspr_global_mutex_t *m; - m = (apr_global_mutex_t *)apr_palloc(pool, sizeof(*m)); + m = (fspr_global_mutex_t *)fspr_palloc(pool, sizeof(*m)); m->pool = pool; - rv = apr_proc_mutex_create(&m->proc_mutex, fname, mech, m->pool); + rv = fspr_proc_mutex_create(&m->proc_mutex, fname, mech, m->pool); if (rv != APR_SUCCESS) { return rv; } @@ -63,51 +63,51 @@ APR_DECLARE(apr_status_t) apr_global_mutex_create(apr_global_mutex_t **mutex, m->thread_mutex = NULL; /* We don't need a thread lock. */ } else { - rv = apr_thread_mutex_create(&m->thread_mutex, + rv = fspr_thread_mutex_create(&m->thread_mutex, APR_THREAD_MUTEX_DEFAULT, m->pool); if (rv != APR_SUCCESS) { - rv = apr_proc_mutex_destroy(m->proc_mutex); + rv = fspr_proc_mutex_destroy(m->proc_mutex); return rv; } } #endif /* APR_HAS_THREADS */ - apr_pool_cleanup_register(m->pool, (void *)m, - global_mutex_cleanup, apr_pool_cleanup_null); + fspr_pool_cleanup_register(m->pool, (void *)m, + global_mutex_cleanup, fspr_pool_cleanup_null); *mutex = m; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_global_mutex_child_init( - apr_global_mutex_t **mutex, +APR_DECLARE(fspr_status_t) fspr_global_mutex_child_init( + fspr_global_mutex_t **mutex, const char *fname, - apr_pool_t *pool) + fspr_pool_t *pool) { - apr_status_t rv; + fspr_status_t rv; - rv = apr_proc_mutex_child_init(&((*mutex)->proc_mutex), fname, pool); + rv = fspr_proc_mutex_child_init(&((*mutex)->proc_mutex), fname, pool); return rv; } -APR_DECLARE(apr_status_t) apr_global_mutex_lock(apr_global_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_global_mutex_lock(fspr_global_mutex_t *mutex) { - apr_status_t rv; + fspr_status_t rv; #if APR_HAS_THREADS if (mutex->thread_mutex) { - rv = apr_thread_mutex_lock(mutex->thread_mutex); + rv = fspr_thread_mutex_lock(mutex->thread_mutex); if (rv != APR_SUCCESS) { return rv; } } #endif /* APR_HAS_THREADS */ - rv = apr_proc_mutex_lock(mutex->proc_mutex); + rv = fspr_proc_mutex_lock(mutex->proc_mutex); #if APR_HAS_THREADS if (rv != APR_SUCCESS) { if (mutex->thread_mutex) { - (void)apr_thread_mutex_unlock(mutex->thread_mutex); + (void)fspr_thread_mutex_unlock(mutex->thread_mutex); } } #endif /* APR_HAS_THREADS */ @@ -115,25 +115,25 @@ APR_DECLARE(apr_status_t) apr_global_mutex_lock(apr_global_mutex_t *mutex) return rv; } -APR_DECLARE(apr_status_t) apr_global_mutex_trylock(apr_global_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_global_mutex_trylock(fspr_global_mutex_t *mutex) { - apr_status_t rv; + fspr_status_t rv; #if APR_HAS_THREADS if (mutex->thread_mutex) { - rv = apr_thread_mutex_trylock(mutex->thread_mutex); + rv = fspr_thread_mutex_trylock(mutex->thread_mutex); if (rv != APR_SUCCESS) { return rv; } } #endif /* APR_HAS_THREADS */ - rv = apr_proc_mutex_trylock(mutex->proc_mutex); + rv = fspr_proc_mutex_trylock(mutex->proc_mutex); #if APR_HAS_THREADS if (rv != APR_SUCCESS) { if (mutex->thread_mutex) { - (void)apr_thread_mutex_unlock(mutex->thread_mutex); + (void)fspr_thread_mutex_unlock(mutex->thread_mutex); } } #endif /* APR_HAS_THREADS */ @@ -141,26 +141,26 @@ APR_DECLARE(apr_status_t) apr_global_mutex_trylock(apr_global_mutex_t *mutex) return rv; } -APR_DECLARE(apr_status_t) apr_global_mutex_unlock(apr_global_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_global_mutex_unlock(fspr_global_mutex_t *mutex) { - apr_status_t rv; + fspr_status_t rv; - rv = apr_proc_mutex_unlock(mutex->proc_mutex); + rv = fspr_proc_mutex_unlock(mutex->proc_mutex); #if APR_HAS_THREADS if (mutex->thread_mutex) { if (rv != APR_SUCCESS) { - (void)apr_thread_mutex_unlock(mutex->thread_mutex); + (void)fspr_thread_mutex_unlock(mutex->thread_mutex); } else { - rv = apr_thread_mutex_unlock(mutex->thread_mutex); + rv = fspr_thread_mutex_unlock(mutex->thread_mutex); } } #endif /* APR_HAS_THREADS */ return rv; } -APR_DECLARE(apr_status_t) apr_os_global_mutex_get(apr_os_global_mutex_t *ospmutex, - apr_global_mutex_t *pmutex) +APR_DECLARE(fspr_status_t) fspr_os_global_mutex_get(fspr_os_global_mutex_t *ospmutex, + fspr_global_mutex_t *pmutex) { ospmutex->pool = pmutex->pool; ospmutex->proc_mutex = pmutex->proc_mutex; @@ -170,9 +170,9 @@ APR_DECLARE(apr_status_t) apr_os_global_mutex_get(apr_os_global_mutex_t *ospmute return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_global_mutex_destroy(apr_global_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_global_mutex_destroy(fspr_global_mutex_t *mutex) { - return apr_pool_cleanup_run(mutex->pool, mutex, global_mutex_cleanup); + return fspr_pool_cleanup_run(mutex->pool, mutex, global_mutex_cleanup); } APR_POOL_IMPLEMENT_ACCESSOR(global_mutex) diff --git a/libs/apr/locks/unix/proc_mutex.c b/libs/apr/locks/unix/proc_mutex.c index 26b2f9029a..cebceadf7c 100644 --- a/libs/apr/locks/unix/proc_mutex.c +++ b/libs/apr/locks/unix/proc_mutex.c @@ -14,25 +14,25 @@ * limitations under the License. */ -#include "apr.h" -#include "apr_strings.h" -#include "apr_arch_proc_mutex.h" -#include "apr_arch_file_io.h" /* for apr_mkstemp() */ +#include "fspr.h" +#include "fspr_strings.h" +#include "fspr_arch_proc_mutex.h" +#include "fspr_arch_file_io.h" /* for fspr_mkstemp() */ -APR_DECLARE(apr_status_t) apr_proc_mutex_destroy(apr_proc_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_proc_mutex_destroy(fspr_proc_mutex_t *mutex) { - return apr_pool_cleanup_run(mutex->pool, mutex, apr_proc_mutex_cleanup); + return fspr_pool_cleanup_run(mutex->pool, mutex, fspr_proc_mutex_cleanup); } -static apr_status_t proc_mutex_no_tryacquire(apr_proc_mutex_t *new_mutex) +static fspr_status_t proc_mutex_no_tryacquire(fspr_proc_mutex_t *new_mutex) { return APR_ENOTIMPL; } #if APR_HAS_POSIXSEM_SERIALIZE || APR_HAS_FCNTL_SERIALIZE || \ APR_HAS_PROC_PTHREAD_SERIALIZE || APR_HAS_SYSVSEM_SERIALIZE -static apr_status_t proc_mutex_no_child_init(apr_proc_mutex_t **mutex, - apr_pool_t *cont, +static fspr_status_t proc_mutex_no_child_init(fspr_proc_mutex_t **mutex, + fspr_pool_t *cont, const char *fname) { return APR_SUCCESS; @@ -45,9 +45,9 @@ static apr_status_t proc_mutex_no_child_init(apr_proc_mutex_t **mutex, #define SEM_FAILED (-1) #endif -static apr_status_t proc_mutex_posix_cleanup(void *mutex_) +static fspr_status_t proc_mutex_posix_cleanup(void *mutex_) { - apr_proc_mutex_t *mutex = mutex_; + fspr_proc_mutex_t *mutex = mutex_; if (sem_close(mutex->psem_interproc) < 0) { return errno; @@ -56,16 +56,16 @@ static apr_status_t proc_mutex_posix_cleanup(void *mutex_) return APR_SUCCESS; } -static apr_status_t proc_mutex_posix_create(apr_proc_mutex_t *new_mutex, +static fspr_status_t proc_mutex_posix_create(fspr_proc_mutex_t *new_mutex, const char *fname) { sem_t *psem; char semname[31]; - apr_time_t now; + fspr_time_t now; unsigned long sec; unsigned long usec; - new_mutex->interproc = apr_palloc(new_mutex->pool, + new_mutex->interproc = fspr_palloc(new_mutex->pool, sizeof(*new_mutex->interproc)); /* * This bogusness is to follow what appears to be the @@ -92,10 +92,10 @@ static apr_status_t proc_mutex_posix_create(apr_proc_mutex_t *new_mutex, * help here however... * */ - now = apr_time_now(); - sec = apr_time_sec(now); - usec = apr_time_usec(now); - apr_snprintf(semname, sizeof(semname), "/ApR.%lxZ%lx", sec, usec); + now = fspr_time_now(); + sec = fspr_time_sec(now); + usec = fspr_time_usec(now); + fspr_snprintf(semname, sizeof(semname), "/ApR.%lxZ%lx", sec, usec); psem = sem_open(semname, O_CREAT, 0644, 1); if ((psem == (sem_t *)SEM_FAILED) && (errno == ENAMETOOLONG)) { /* Oh well, good try */ @@ -109,14 +109,14 @@ static apr_status_t proc_mutex_posix_create(apr_proc_mutex_t *new_mutex, /* Ahhh. The joys of Posix sems. Predelete it... */ sem_unlink(semname); new_mutex->psem_interproc = psem; - new_mutex->fname = apr_pstrdup(new_mutex->pool, semname); - apr_pool_cleanup_register(new_mutex->pool, (void *)new_mutex, - apr_proc_mutex_cleanup, - apr_pool_cleanup_null); + new_mutex->fname = fspr_pstrdup(new_mutex->pool, semname); + fspr_pool_cleanup_register(new_mutex->pool, (void *)new_mutex, + fspr_proc_mutex_cleanup, + fspr_pool_cleanup_null); return APR_SUCCESS; } -static apr_status_t proc_mutex_posix_acquire(apr_proc_mutex_t *mutex) +static fspr_status_t proc_mutex_posix_acquire(fspr_proc_mutex_t *mutex) { if (sem_wait(mutex->psem_interproc) < 0) { return errno; @@ -125,7 +125,7 @@ static apr_status_t proc_mutex_posix_acquire(apr_proc_mutex_t *mutex) return APR_SUCCESS; } -static apr_status_t proc_mutex_posix_release(apr_proc_mutex_t *mutex) +static fspr_status_t proc_mutex_posix_release(fspr_proc_mutex_t *mutex) { mutex->curr_locked = 0; if (sem_post(mutex->psem_interproc) < 0) { @@ -136,7 +136,7 @@ static apr_status_t proc_mutex_posix_release(apr_proc_mutex_t *mutex) return APR_SUCCESS; } -static const apr_proc_mutex_unix_lock_methods_t mutex_posixsem_methods = +static const fspr_proc_mutex_unix_lock_methods_t mutex_posixsem_methods = { #if APR_PROCESS_LOCK_IS_GLOBAL || !APR_HAS_THREADS || defined(POSIXSEM_IS_GLOBAL) APR_PROCESS_LOCK_MECH_IS_GLOBAL, @@ -169,9 +169,9 @@ static void proc_mutex_sysv_setup(void) proc_mutex_op_off.sem_flg = SEM_UNDO; } -static apr_status_t proc_mutex_sysv_cleanup(void *mutex_) +static fspr_status_t proc_mutex_sysv_cleanup(void *mutex_) { - apr_proc_mutex_t *mutex=mutex_; + fspr_proc_mutex_t *mutex=mutex_; union semun ick; if (mutex->interproc->filedes != -1) { @@ -181,13 +181,13 @@ static apr_status_t proc_mutex_sysv_cleanup(void *mutex_) return APR_SUCCESS; } -static apr_status_t proc_mutex_sysv_create(apr_proc_mutex_t *new_mutex, +static fspr_status_t proc_mutex_sysv_create(fspr_proc_mutex_t *new_mutex, const char *fname) { union semun ick; - apr_status_t rv; + fspr_status_t rv; - new_mutex->interproc = apr_palloc(new_mutex->pool, sizeof(*new_mutex->interproc)); + new_mutex->interproc = fspr_palloc(new_mutex->pool, sizeof(*new_mutex->interproc)); new_mutex->interproc->filedes = semget(IPC_PRIVATE, 1, IPC_CREAT | 0600); if (new_mutex->interproc->filedes < 0) { @@ -202,13 +202,13 @@ static apr_status_t proc_mutex_sysv_create(apr_proc_mutex_t *new_mutex, return rv; } new_mutex->curr_locked = 0; - apr_pool_cleanup_register(new_mutex->pool, - (void *)new_mutex, apr_proc_mutex_cleanup, - apr_pool_cleanup_null); + fspr_pool_cleanup_register(new_mutex->pool, + (void *)new_mutex, fspr_proc_mutex_cleanup, + fspr_pool_cleanup_null); return APR_SUCCESS; } -static apr_status_t proc_mutex_sysv_acquire(apr_proc_mutex_t *mutex) +static fspr_status_t proc_mutex_sysv_acquire(fspr_proc_mutex_t *mutex) { int rc; @@ -222,7 +222,7 @@ static apr_status_t proc_mutex_sysv_acquire(apr_proc_mutex_t *mutex) return APR_SUCCESS; } -static apr_status_t proc_mutex_sysv_release(apr_proc_mutex_t *mutex) +static fspr_status_t proc_mutex_sysv_release(fspr_proc_mutex_t *mutex) { int rc; @@ -236,7 +236,7 @@ static apr_status_t proc_mutex_sysv_release(apr_proc_mutex_t *mutex) return APR_SUCCESS; } -static const apr_proc_mutex_unix_lock_methods_t mutex_sysv_methods = +static const fspr_proc_mutex_unix_lock_methods_t mutex_sysv_methods = { #if APR_PROCESS_LOCK_IS_GLOBAL || !APR_HAS_THREADS || defined(SYSVSEM_IS_GLOBAL) APR_PROCESS_LOCK_MECH_IS_GLOBAL, @@ -256,10 +256,10 @@ static const apr_proc_mutex_unix_lock_methods_t mutex_sysv_methods = #if APR_HAS_PROC_PTHREAD_SERIALIZE -static apr_status_t proc_mutex_proc_pthread_cleanup(void *mutex_) +static fspr_status_t proc_mutex_proc_pthread_cleanup(void *mutex_) { - apr_proc_mutex_t *mutex=mutex_; - apr_status_t rv; + fspr_proc_mutex_t *mutex=mutex_; + fspr_status_t rv; if (mutex->curr_locked == 1) { if ((rv = pthread_mutex_unlock(mutex->pthread_interproc))) { @@ -284,10 +284,10 @@ static apr_status_t proc_mutex_proc_pthread_cleanup(void *mutex_) return APR_SUCCESS; } -static apr_status_t proc_mutex_proc_pthread_create(apr_proc_mutex_t *new_mutex, +static fspr_status_t proc_mutex_proc_pthread_create(fspr_proc_mutex_t *new_mutex, const char *fname) { - apr_status_t rv; + fspr_status_t rv; int fd; pthread_mutexattr_t mattr; @@ -364,16 +364,16 @@ static apr_status_t proc_mutex_proc_pthread_create(apr_proc_mutex_t *new_mutex, return rv; } - apr_pool_cleanup_register(new_mutex->pool, + fspr_pool_cleanup_register(new_mutex->pool, (void *)new_mutex, - apr_proc_mutex_cleanup, - apr_pool_cleanup_null); + fspr_proc_mutex_cleanup, + fspr_pool_cleanup_null); return APR_SUCCESS; } -static apr_status_t proc_mutex_proc_pthread_acquire(apr_proc_mutex_t *mutex) +static fspr_status_t proc_mutex_proc_pthread_acquire(fspr_proc_mutex_t *mutex) { - apr_status_t rv; + fspr_status_t rv; if ((rv = pthread_mutex_lock(mutex->pthread_interproc))) { #ifdef PTHREAD_SETS_ERRNO @@ -394,11 +394,11 @@ static apr_status_t proc_mutex_proc_pthread_acquire(apr_proc_mutex_t *mutex) return APR_SUCCESS; } -/* TODO: Add proc_mutex_proc_pthread_tryacquire(apr_proc_mutex_t *mutex) */ +/* TODO: Add proc_mutex_proc_pthread_tryacquire(fspr_proc_mutex_t *mutex) */ -static apr_status_t proc_mutex_proc_pthread_release(apr_proc_mutex_t *mutex) +static fspr_status_t proc_mutex_proc_pthread_release(fspr_proc_mutex_t *mutex) { - apr_status_t rv; + fspr_status_t rv; mutex->curr_locked = 0; if ((rv = pthread_mutex_unlock(mutex->pthread_interproc))) { @@ -410,7 +410,7 @@ static apr_status_t proc_mutex_proc_pthread_release(apr_proc_mutex_t *mutex) return APR_SUCCESS; } -static const apr_proc_mutex_unix_lock_methods_t mutex_proc_pthread_methods = +static const fspr_proc_mutex_unix_lock_methods_t mutex_proc_pthread_methods = { APR_PROCESS_LOCK_MECH_IS_GLOBAL, proc_mutex_proc_pthread_create, @@ -429,7 +429,7 @@ static const apr_proc_mutex_unix_lock_methods_t mutex_proc_pthread_methods = static struct flock proc_mutex_lock_it; static struct flock proc_mutex_unlock_it; -static apr_status_t proc_mutex_fcntl_release(apr_proc_mutex_t *); +static fspr_status_t proc_mutex_fcntl_release(fspr_proc_mutex_t *); static void proc_mutex_fcntl_setup(void) { @@ -445,10 +445,10 @@ static void proc_mutex_fcntl_setup(void) proc_mutex_unlock_it.l_pid = 0; /* pid not actually interesting */ } -static apr_status_t proc_mutex_fcntl_cleanup(void *mutex_) +static fspr_status_t proc_mutex_fcntl_cleanup(void *mutex_) { - apr_status_t status; - apr_proc_mutex_t *mutex=mutex_; + fspr_status_t status; + fspr_proc_mutex_t *mutex=mutex_; if (mutex->curr_locked == 1) { status = proc_mutex_fcntl_release(mutex); @@ -456,24 +456,24 @@ static apr_status_t proc_mutex_fcntl_cleanup(void *mutex_) return status; } - return apr_file_close(mutex->interproc); + return fspr_file_close(mutex->interproc); } -static apr_status_t proc_mutex_fcntl_create(apr_proc_mutex_t *new_mutex, +static fspr_status_t proc_mutex_fcntl_create(fspr_proc_mutex_t *new_mutex, const char *fname) { int rv; if (fname) { - new_mutex->fname = apr_pstrdup(new_mutex->pool, fname); - rv = apr_file_open(&new_mutex->interproc, new_mutex->fname, + new_mutex->fname = fspr_pstrdup(new_mutex->pool, fname); + rv = fspr_file_open(&new_mutex->interproc, new_mutex->fname, APR_CREATE | APR_WRITE | APR_EXCL, APR_UREAD | APR_UWRITE | APR_GREAD | APR_WREAD, new_mutex->pool); } else { - new_mutex->fname = apr_pstrdup(new_mutex->pool, "/tmp/aprXXXXXX"); - rv = apr_file_mktemp(&new_mutex->interproc, new_mutex->fname, + new_mutex->fname = fspr_pstrdup(new_mutex->pool, "/tmp/aprXXXXXX"); + rv = fspr_file_mktemp(&new_mutex->interproc, new_mutex->fname, APR_CREATE | APR_WRITE | APR_EXCL, new_mutex->pool); } @@ -484,14 +484,14 @@ static apr_status_t proc_mutex_fcntl_create(apr_proc_mutex_t *new_mutex, new_mutex->curr_locked = 0; unlink(new_mutex->fname); - apr_pool_cleanup_register(new_mutex->pool, + fspr_pool_cleanup_register(new_mutex->pool, (void*)new_mutex, - apr_proc_mutex_cleanup, - apr_pool_cleanup_null); + fspr_proc_mutex_cleanup, + fspr_pool_cleanup_null); return APR_SUCCESS; } -static apr_status_t proc_mutex_fcntl_acquire(apr_proc_mutex_t *mutex) +static fspr_status_t proc_mutex_fcntl_acquire(fspr_proc_mutex_t *mutex) { int rc; @@ -505,7 +505,7 @@ static apr_status_t proc_mutex_fcntl_acquire(apr_proc_mutex_t *mutex) return APR_SUCCESS; } -static apr_status_t proc_mutex_fcntl_release(apr_proc_mutex_t *mutex) +static fspr_status_t proc_mutex_fcntl_release(fspr_proc_mutex_t *mutex) { int rc; @@ -519,7 +519,7 @@ static apr_status_t proc_mutex_fcntl_release(apr_proc_mutex_t *mutex) return APR_SUCCESS; } -static const apr_proc_mutex_unix_lock_methods_t mutex_fcntl_methods = +static const fspr_proc_mutex_unix_lock_methods_t mutex_fcntl_methods = { #if APR_PROCESS_LOCK_IS_GLOBAL || !APR_HAS_THREADS || defined(FCNTL_IS_GLOBAL) APR_PROCESS_LOCK_MECH_IS_GLOBAL, @@ -539,12 +539,12 @@ static const apr_proc_mutex_unix_lock_methods_t mutex_fcntl_methods = #if APR_HAS_FLOCK_SERIALIZE -static apr_status_t proc_mutex_flock_release(apr_proc_mutex_t *); +static fspr_status_t proc_mutex_flock_release(fspr_proc_mutex_t *); -static apr_status_t proc_mutex_flock_cleanup(void *mutex_) +static fspr_status_t proc_mutex_flock_cleanup(void *mutex_) { - apr_status_t status; - apr_proc_mutex_t *mutex=mutex_; + fspr_status_t status; + fspr_proc_mutex_t *mutex=mutex_; if (mutex->curr_locked == 1) { status = proc_mutex_flock_release(mutex); @@ -552,27 +552,27 @@ static apr_status_t proc_mutex_flock_cleanup(void *mutex_) return status; } if (mutex->interproc) { /* if it was opened properly */ - apr_file_close(mutex->interproc); + fspr_file_close(mutex->interproc); } unlink(mutex->fname); return APR_SUCCESS; } -static apr_status_t proc_mutex_flock_create(apr_proc_mutex_t *new_mutex, +static fspr_status_t proc_mutex_flock_create(fspr_proc_mutex_t *new_mutex, const char *fname) { int rv; if (fname) { - new_mutex->fname = apr_pstrdup(new_mutex->pool, fname); - rv = apr_file_open(&new_mutex->interproc, new_mutex->fname, + new_mutex->fname = fspr_pstrdup(new_mutex->pool, fname); + rv = fspr_file_open(&new_mutex->interproc, new_mutex->fname, APR_CREATE | APR_WRITE | APR_EXCL, APR_UREAD | APR_UWRITE, new_mutex->pool); } else { - new_mutex->fname = apr_pstrdup(new_mutex->pool, "/tmp/aprXXXXXX"); - rv = apr_file_mktemp(&new_mutex->interproc, new_mutex->fname, + new_mutex->fname = fspr_pstrdup(new_mutex->pool, "/tmp/aprXXXXXX"); + rv = fspr_file_mktemp(&new_mutex->interproc, new_mutex->fname, APR_CREATE | APR_WRITE | APR_EXCL, new_mutex->pool); } @@ -582,13 +582,13 @@ static apr_status_t proc_mutex_flock_create(apr_proc_mutex_t *new_mutex, return errno; } new_mutex->curr_locked = 0; - apr_pool_cleanup_register(new_mutex->pool, (void *)new_mutex, - apr_proc_mutex_cleanup, - apr_pool_cleanup_null); + fspr_pool_cleanup_register(new_mutex->pool, (void *)new_mutex, + fspr_proc_mutex_cleanup, + fspr_pool_cleanup_null); return APR_SUCCESS; } -static apr_status_t proc_mutex_flock_acquire(apr_proc_mutex_t *mutex) +static fspr_status_t proc_mutex_flock_acquire(fspr_proc_mutex_t *mutex) { int rc; @@ -602,7 +602,7 @@ static apr_status_t proc_mutex_flock_acquire(apr_proc_mutex_t *mutex) return APR_SUCCESS; } -static apr_status_t proc_mutex_flock_release(apr_proc_mutex_t *mutex) +static fspr_status_t proc_mutex_flock_release(fspr_proc_mutex_t *mutex) { int rc; @@ -616,22 +616,22 @@ static apr_status_t proc_mutex_flock_release(apr_proc_mutex_t *mutex) return APR_SUCCESS; } -static apr_status_t proc_mutex_flock_child_init(apr_proc_mutex_t **mutex, - apr_pool_t *pool, +static fspr_status_t proc_mutex_flock_child_init(fspr_proc_mutex_t **mutex, + fspr_pool_t *pool, const char *fname) { - apr_proc_mutex_t *new_mutex; + fspr_proc_mutex_t *new_mutex; int rv; - new_mutex = (apr_proc_mutex_t *)apr_palloc(pool, sizeof(apr_proc_mutex_t)); + new_mutex = (fspr_proc_mutex_t *)fspr_palloc(pool, sizeof(fspr_proc_mutex_t)); memcpy(new_mutex, *mutex, sizeof *new_mutex); new_mutex->pool = pool; if (!fname) { fname = (*mutex)->fname; } - new_mutex->fname = apr_pstrdup(pool, fname); - rv = apr_file_open(&new_mutex->interproc, new_mutex->fname, + new_mutex->fname = fspr_pstrdup(pool, fname); + rv = fspr_file_open(&new_mutex->interproc, new_mutex->fname, APR_WRITE, 0, new_mutex->pool); if (rv != APR_SUCCESS) { return rv; @@ -640,7 +640,7 @@ static apr_status_t proc_mutex_flock_child_init(apr_proc_mutex_t **mutex, return APR_SUCCESS; } -static const apr_proc_mutex_unix_lock_methods_t mutex_flock_methods = +static const fspr_proc_mutex_unix_lock_methods_t mutex_flock_methods = { #if APR_PROCESS_LOCK_IS_GLOBAL || !APR_HAS_THREADS || defined(FLOCK_IS_GLOBAL) APR_PROCESS_LOCK_MECH_IS_GLOBAL, @@ -658,7 +658,7 @@ static const apr_proc_mutex_unix_lock_methods_t mutex_flock_methods = #endif /* flock implementation */ -void apr_proc_mutex_unix_setup_lock(void) +void fspr_proc_mutex_unix_setup_lock(void) { /* setup only needed for sysvsem and fnctl */ #if APR_HAS_SYSVSEM_SERIALIZE @@ -669,7 +669,7 @@ void apr_proc_mutex_unix_setup_lock(void) #endif } -static apr_status_t proc_mutex_choose_method(apr_proc_mutex_t *new_mutex, apr_lockmech_e mech) +static fspr_status_t proc_mutex_choose_method(fspr_proc_mutex_t *new_mutex, fspr_lockmech_e mech) { switch (mech) { case APR_LOCK_FCNTL: @@ -728,22 +728,21 @@ static apr_status_t proc_mutex_choose_method(apr_proc_mutex_t *new_mutex, apr_lo return APR_SUCCESS; } -APR_DECLARE(const char *) apr_proc_mutex_defname(void) +APR_DECLARE(const char *) fspr_proc_mutex_defname(void) { - apr_status_t rv; - apr_proc_mutex_t mutex; + fspr_proc_mutex_t mutex; - if ((rv = proc_mutex_choose_method(&mutex, APR_LOCK_DEFAULT)) != APR_SUCCESS) { + if (proc_mutex_choose_method(&mutex, APR_LOCK_DEFAULT) != APR_SUCCESS) { return "unknown"; } mutex.meth = mutex.inter_meth; - return apr_proc_mutex_name(&mutex); + return fspr_proc_mutex_name(&mutex); } -static apr_status_t proc_mutex_create(apr_proc_mutex_t *new_mutex, apr_lockmech_e mech, const char *fname) +static fspr_status_t proc_mutex_create(fspr_proc_mutex_t *new_mutex, fspr_lockmech_e mech, const char *fname) { - apr_status_t rv; + fspr_status_t rv; if ((rv = proc_mutex_choose_method(new_mutex, mech)) != APR_SUCCESS) { return rv; @@ -758,15 +757,15 @@ static apr_status_t proc_mutex_create(apr_proc_mutex_t *new_mutex, apr_lockmech_ return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_proc_mutex_create(apr_proc_mutex_t **mutex, +APR_DECLARE(fspr_status_t) fspr_proc_mutex_create(fspr_proc_mutex_t **mutex, const char *fname, - apr_lockmech_e mech, - apr_pool_t *pool) + fspr_lockmech_e mech, + fspr_pool_t *pool) { - apr_proc_mutex_t *new_mutex; - apr_status_t rv; + fspr_proc_mutex_t *new_mutex; + fspr_status_t rv; - new_mutex = apr_pcalloc(pool, sizeof(apr_proc_mutex_t)); + new_mutex = fspr_pcalloc(pool, sizeof(fspr_proc_mutex_t)); new_mutex->pool = pool; if ((rv = proc_mutex_create(new_mutex, mech, fname)) != APR_SUCCESS) @@ -776,39 +775,39 @@ APR_DECLARE(apr_status_t) apr_proc_mutex_create(apr_proc_mutex_t **mutex, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_proc_mutex_child_init(apr_proc_mutex_t **mutex, +APR_DECLARE(fspr_status_t) fspr_proc_mutex_child_init(fspr_proc_mutex_t **mutex, const char *fname, - apr_pool_t *pool) + fspr_pool_t *pool) { return (*mutex)->meth->child_init(mutex, pool, fname); } -APR_DECLARE(apr_status_t) apr_proc_mutex_lock(apr_proc_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_proc_mutex_lock(fspr_proc_mutex_t *mutex) { return mutex->meth->acquire(mutex); } -APR_DECLARE(apr_status_t) apr_proc_mutex_trylock(apr_proc_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_proc_mutex_trylock(fspr_proc_mutex_t *mutex) { return mutex->meth->tryacquire(mutex); } -APR_DECLARE(apr_status_t) apr_proc_mutex_unlock(apr_proc_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_proc_mutex_unlock(fspr_proc_mutex_t *mutex) { return mutex->meth->release(mutex); } -APR_DECLARE(apr_status_t) apr_proc_mutex_cleanup(void *mutex) +APR_DECLARE(fspr_status_t) fspr_proc_mutex_cleanup(void *mutex) { - return ((apr_proc_mutex_t *)mutex)->meth->cleanup(mutex); + return ((fspr_proc_mutex_t *)mutex)->meth->cleanup(mutex); } -APR_DECLARE(const char *) apr_proc_mutex_name(apr_proc_mutex_t *mutex) +APR_DECLARE(const char *) fspr_proc_mutex_name(fspr_proc_mutex_t *mutex) { return mutex->meth->name; } -APR_DECLARE(const char *) apr_proc_mutex_lockfile(apr_proc_mutex_t *mutex) +APR_DECLARE(const char *) fspr_proc_mutex_lockfile(fspr_proc_mutex_t *mutex) { /* POSIX sems use the fname field but don't use a file, * so be careful. */ @@ -827,10 +826,10 @@ APR_DECLARE(const char *) apr_proc_mutex_lockfile(apr_proc_mutex_t *mutex) APR_POOL_IMPLEMENT_ACCESSOR(proc_mutex) -/* Implement OS-specific accessors defined in apr_portable.h */ +/* Implement OS-specific accessors defined in fspr_portable.h */ -APR_DECLARE(apr_status_t) apr_os_proc_mutex_get(apr_os_proc_mutex_t *ospmutex, - apr_proc_mutex_t *pmutex) +APR_DECLARE(fspr_status_t) fspr_os_proc_mutex_get(fspr_os_proc_mutex_t *ospmutex, + fspr_proc_mutex_t *pmutex) { #if APR_HAS_SYSVSEM_SERIALIZE || APR_HAS_FCNTL_SERIALIZE || APR_HAS_FLOCK_SERIALIZE || APR_HAS_POSIXSEM_SERIALIZE ospmutex->crossproc = pmutex->interproc->filedes; @@ -841,20 +840,20 @@ APR_DECLARE(apr_status_t) apr_os_proc_mutex_get(apr_os_proc_mutex_t *ospmutex, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_os_proc_mutex_put(apr_proc_mutex_t **pmutex, - apr_os_proc_mutex_t *ospmutex, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_os_proc_mutex_put(fspr_proc_mutex_t **pmutex, + fspr_os_proc_mutex_t *ospmutex, + fspr_pool_t *pool) { if (pool == NULL) { return APR_ENOPOOL; } if ((*pmutex) == NULL) { - (*pmutex) = (apr_proc_mutex_t *)apr_pcalloc(pool, - sizeof(apr_proc_mutex_t)); + (*pmutex) = (fspr_proc_mutex_t *)fspr_pcalloc(pool, + sizeof(fspr_proc_mutex_t)); (*pmutex)->pool = pool; } #if APR_HAS_SYSVSEM_SERIALIZE || APR_HAS_FCNTL_SERIALIZE || APR_HAS_FLOCK_SERIALIZE || APR_HAS_POSIXSEM_SERIALIZE - apr_os_file_put(&(*pmutex)->interproc, &ospmutex->crossproc, 0, pool); + fspr_os_file_put(&(*pmutex)->interproc, &ospmutex->crossproc, 0, pool); #endif #if APR_HAS_PROC_PTHREAD_SERIALIZE (*pmutex)->pthread_interproc = ospmutex->pthread_interproc; diff --git a/libs/apr/locks/unix/thread_cond.c b/libs/apr/locks/unix/thread_cond.c index 227c1d7f64..46f5e88e89 100644 --- a/libs/apr/locks/unix/thread_cond.c +++ b/libs/apr/locks/unix/thread_cond.c @@ -14,17 +14,17 @@ * limitations under the License. */ -#include "apr.h" +#include "fspr.h" #if APR_HAS_THREADS -#include "apr_arch_thread_mutex.h" -#include "apr_arch_thread_cond.h" +#include "fspr_arch_thread_mutex.h" +#include "fspr_arch_thread_cond.h" -static apr_status_t thread_cond_cleanup(void *data) +static fspr_status_t thread_cond_cleanup(void *data) { - apr_thread_cond_t *cond = (apr_thread_cond_t *)data; - apr_status_t rv; + fspr_thread_cond_t *cond = (fspr_thread_cond_t *)data; + fspr_status_t rv; rv = pthread_cond_destroy(&cond->cond); #ifdef PTHREAD_SETS_ERRNO @@ -35,13 +35,13 @@ static apr_status_t thread_cond_cleanup(void *data) return rv; } -APR_DECLARE(apr_status_t) apr_thread_cond_create(apr_thread_cond_t **cond, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_thread_cond_create(fspr_thread_cond_t **cond, + fspr_pool_t *pool) { - apr_thread_cond_t *new_cond; - apr_status_t rv; + fspr_thread_cond_t *new_cond; + fspr_status_t rv; - new_cond = apr_palloc(pool, sizeof(apr_thread_cond_t)); + new_cond = fspr_palloc(pool, sizeof(fspr_thread_cond_t)); new_cond->pool = pool; @@ -52,18 +52,18 @@ APR_DECLARE(apr_status_t) apr_thread_cond_create(apr_thread_cond_t **cond, return rv; } - apr_pool_cleanup_register(new_cond->pool, + fspr_pool_cleanup_register(new_cond->pool, (void *)new_cond, thread_cond_cleanup, - apr_pool_cleanup_null); + fspr_pool_cleanup_null); *cond = new_cond; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_cond_wait(apr_thread_cond_t *cond, - apr_thread_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_thread_cond_wait(fspr_thread_cond_t *cond, + fspr_thread_mutex_t *mutex) { - apr_status_t rv; + fspr_status_t rv; rv = pthread_cond_wait(&cond->cond, &mutex->mutex); #ifdef PTHREAD_SETS_ERRNO @@ -74,17 +74,17 @@ APR_DECLARE(apr_status_t) apr_thread_cond_wait(apr_thread_cond_t *cond, return rv; } -APR_DECLARE(apr_status_t) apr_thread_cond_timedwait(apr_thread_cond_t *cond, - apr_thread_mutex_t *mutex, - apr_interval_time_t timeout) +APR_DECLARE(fspr_status_t) fspr_thread_cond_timedwait(fspr_thread_cond_t *cond, + fspr_thread_mutex_t *mutex, + fspr_interval_time_t timeout) { - apr_status_t rv; - apr_time_t then; + fspr_status_t rv; + fspr_time_t then; struct timespec abstime; - then = apr_time_now() + timeout; - abstime.tv_sec = apr_time_sec(then); - abstime.tv_nsec = apr_time_usec(then) * 1000; /* nanoseconds */ + then = fspr_time_now() + timeout; + abstime.tv_sec = fspr_time_sec(then); + abstime.tv_nsec = fspr_time_usec(then) * 1000; /* nanoseconds */ rv = pthread_cond_timedwait(&cond->cond, &mutex->mutex, &abstime); #ifdef PTHREAD_SETS_ERRNO @@ -99,9 +99,9 @@ APR_DECLARE(apr_status_t) apr_thread_cond_timedwait(apr_thread_cond_t *cond, } -APR_DECLARE(apr_status_t) apr_thread_cond_signal(apr_thread_cond_t *cond) +APR_DECLARE(fspr_status_t) fspr_thread_cond_signal(fspr_thread_cond_t *cond) { - apr_status_t rv; + fspr_status_t rv; rv = pthread_cond_signal(&cond->cond); #ifdef PTHREAD_SETS_ERRNO @@ -112,9 +112,9 @@ APR_DECLARE(apr_status_t) apr_thread_cond_signal(apr_thread_cond_t *cond) return rv; } -APR_DECLARE(apr_status_t) apr_thread_cond_broadcast(apr_thread_cond_t *cond) +APR_DECLARE(fspr_status_t) fspr_thread_cond_broadcast(fspr_thread_cond_t *cond) { - apr_status_t rv; + fspr_status_t rv; rv = pthread_cond_broadcast(&cond->cond); #ifdef PTHREAD_SETS_ERRNO @@ -125,9 +125,9 @@ APR_DECLARE(apr_status_t) apr_thread_cond_broadcast(apr_thread_cond_t *cond) return rv; } -APR_DECLARE(apr_status_t) apr_thread_cond_destroy(apr_thread_cond_t *cond) +APR_DECLARE(fspr_status_t) fspr_thread_cond_destroy(fspr_thread_cond_t *cond) { - return apr_pool_cleanup_run(cond->pool, cond, thread_cond_cleanup); + return fspr_pool_cleanup_run(cond->pool, cond, thread_cond_cleanup); } APR_POOL_IMPLEMENT_ACCESSOR(thread_cond) diff --git a/libs/apr/locks/unix/thread_mutex.c b/libs/apr/locks/unix/thread_mutex.c index e146a28f59..30786f883f 100644 --- a/libs/apr/locks/unix/thread_mutex.c +++ b/libs/apr/locks/unix/thread_mutex.c @@ -14,16 +14,16 @@ * limitations under the License. */ -#include "apr_arch_thread_mutex.h" +#include "fspr_arch_thread_mutex.h" #define APR_WANT_MEMFUNC -#include "apr_want.h" +#include "fspr_want.h" #if APR_HAS_THREADS -static apr_status_t thread_mutex_cleanup(void *data) +static fspr_status_t thread_mutex_cleanup(void *data) { - apr_thread_mutex_t *mutex = data; - apr_status_t rv; + fspr_thread_mutex_t *mutex = data; + fspr_status_t rv; rv = pthread_mutex_destroy(&mutex->mutex); #ifdef PTHREAD_SETS_ERRNO @@ -34,12 +34,12 @@ static apr_status_t thread_mutex_cleanup(void *data) return rv; } -APR_DECLARE(apr_status_t) apr_thread_mutex_create(apr_thread_mutex_t **mutex, +APR_DECLARE(fspr_status_t) fspr_thread_mutex_create(fspr_thread_mutex_t **mutex, unsigned int flags, - apr_pool_t *pool) + fspr_pool_t *pool) { - apr_thread_mutex_t *new_mutex; - apr_status_t rv; + fspr_thread_mutex_t *new_mutex; + fspr_status_t rv; #ifndef HAVE_PTHREAD_MUTEX_RECURSIVE if (flags & APR_THREAD_MUTEX_NESTED) { @@ -47,7 +47,7 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_create(apr_thread_mutex_t **mutex, } #endif - new_mutex = apr_pcalloc(pool, sizeof(apr_thread_mutex_t)); + new_mutex = fspr_pcalloc(pool, sizeof(fspr_thread_mutex_t)); new_mutex->pool = pool; #ifdef HAVE_PTHREAD_MUTEX_RECURSIVE @@ -77,17 +77,17 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_create(apr_thread_mutex_t **mutex, return rv; } - apr_pool_cleanup_register(new_mutex->pool, + fspr_pool_cleanup_register(new_mutex->pool, new_mutex, thread_mutex_cleanup, - apr_pool_cleanup_null); + fspr_pool_cleanup_null); *mutex = new_mutex; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_mutex_lock(apr_thread_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_thread_mutex_lock(fspr_thread_mutex_t *mutex) { - apr_status_t rv; + fspr_status_t rv; rv = pthread_mutex_lock(&mutex->mutex); #ifdef PTHREAD_SETS_ERRNO @@ -99,9 +99,9 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_lock(apr_thread_mutex_t *mutex) return rv; } -APR_DECLARE(apr_status_t) apr_thread_mutex_trylock(apr_thread_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_thread_mutex_trylock(fspr_thread_mutex_t *mutex) { - apr_status_t rv; + fspr_status_t rv; rv = pthread_mutex_trylock(&mutex->mutex); if (rv) { @@ -114,9 +114,9 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_trylock(apr_thread_mutex_t *mutex) return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_mutex_unlock(apr_thread_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_thread_mutex_unlock(fspr_thread_mutex_t *mutex) { - apr_status_t status; + fspr_status_t status; status = pthread_mutex_unlock(&mutex->mutex); #ifdef PTHREAD_SETS_ERRNO @@ -128,9 +128,9 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_unlock(apr_thread_mutex_t *mutex) return status; } -APR_DECLARE(apr_status_t) apr_thread_mutex_destroy(apr_thread_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_thread_mutex_destroy(fspr_thread_mutex_t *mutex) { - return apr_pool_cleanup_run(mutex->pool, mutex, thread_mutex_cleanup); + return fspr_pool_cleanup_run(mutex->pool, mutex, thread_mutex_cleanup); } APR_POOL_IMPLEMENT_ACCESSOR(thread_mutex) diff --git a/libs/apr/locks/unix/thread_rwlock.c b/libs/apr/locks/unix/thread_rwlock.c index 4b28bb618c..533174cff9 100644 --- a/libs/apr/locks/unix/thread_rwlock.c +++ b/libs/apr/locks/unix/thread_rwlock.c @@ -14,8 +14,8 @@ * limitations under the License. */ -#include "apr_arch_thread_rwlock.h" -#include "apr_private.h" +#include "fspr_arch_thread_rwlock.h" +#include "fspr_private.h" #if APR_HAS_THREADS @@ -23,10 +23,10 @@ /* The rwlock must be initialized but not locked by any thread when * cleanup is called. */ -static apr_status_t thread_rwlock_cleanup(void *data) +static fspr_status_t thread_rwlock_cleanup(void *data) { - apr_thread_rwlock_t *rwlock = (apr_thread_rwlock_t *)data; - apr_status_t stat; + fspr_thread_rwlock_t *rwlock = (fspr_thread_rwlock_t *)data; + fspr_status_t stat; stat = pthread_rwlock_destroy(&rwlock->rwlock); #ifdef PTHREAD_SETS_ERRNO @@ -37,13 +37,13 @@ static apr_status_t thread_rwlock_cleanup(void *data) return stat; } -APR_DECLARE(apr_status_t) apr_thread_rwlock_create(apr_thread_rwlock_t **rwlock, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_create(fspr_thread_rwlock_t **rwlock, + fspr_pool_t *pool) { - apr_thread_rwlock_t *new_rwlock; - apr_status_t stat; + fspr_thread_rwlock_t *new_rwlock; + fspr_status_t stat; - new_rwlock = apr_palloc(pool, sizeof(apr_thread_rwlock_t)); + new_rwlock = fspr_palloc(pool, sizeof(fspr_thread_rwlock_t)); new_rwlock->pool = pool; if ((stat = pthread_rwlock_init(&new_rwlock->rwlock, NULL))) { @@ -53,17 +53,17 @@ APR_DECLARE(apr_status_t) apr_thread_rwlock_create(apr_thread_rwlock_t **rwlock, return stat; } - apr_pool_cleanup_register(new_rwlock->pool, + fspr_pool_cleanup_register(new_rwlock->pool, (void *)new_rwlock, thread_rwlock_cleanup, - apr_pool_cleanup_null); + fspr_pool_cleanup_null); *rwlock = new_rwlock; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_rwlock_rdlock(apr_thread_rwlock_t *rwlock) +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_rdlock(fspr_thread_rwlock_t *rwlock) { - apr_status_t stat; + fspr_status_t stat; stat = pthread_rwlock_rdlock(&rwlock->rwlock); #ifdef PTHREAD_SETS_ERRNO @@ -74,9 +74,9 @@ APR_DECLARE(apr_status_t) apr_thread_rwlock_rdlock(apr_thread_rwlock_t *rwlock) return stat; } -APR_DECLARE(apr_status_t) apr_thread_rwlock_tryrdlock(apr_thread_rwlock_t *rwlock) +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_tryrdlock(fspr_thread_rwlock_t *rwlock) { - apr_status_t stat; + fspr_status_t stat; stat = pthread_rwlock_tryrdlock(&rwlock->rwlock); #ifdef PTHREAD_SETS_ERRNO @@ -90,9 +90,9 @@ APR_DECLARE(apr_status_t) apr_thread_rwlock_tryrdlock(apr_thread_rwlock_t *rwloc return stat; } -APR_DECLARE(apr_status_t) apr_thread_rwlock_wrlock(apr_thread_rwlock_t *rwlock) +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_wrlock(fspr_thread_rwlock_t *rwlock) { - apr_status_t stat; + fspr_status_t stat; stat = pthread_rwlock_wrlock(&rwlock->rwlock); #ifdef PTHREAD_SETS_ERRNO @@ -103,9 +103,9 @@ APR_DECLARE(apr_status_t) apr_thread_rwlock_wrlock(apr_thread_rwlock_t *rwlock) return stat; } -APR_DECLARE(apr_status_t) apr_thread_rwlock_trywrlock(apr_thread_rwlock_t *rwlock) +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_trywrlock(fspr_thread_rwlock_t *rwlock) { - apr_status_t stat; + fspr_status_t stat; stat = pthread_rwlock_trywrlock(&rwlock->rwlock); #ifdef PTHREAD_SETS_ERRNO @@ -119,9 +119,9 @@ APR_DECLARE(apr_status_t) apr_thread_rwlock_trywrlock(apr_thread_rwlock_t *rwloc return stat; } -APR_DECLARE(apr_status_t) apr_thread_rwlock_unlock(apr_thread_rwlock_t *rwlock) +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_unlock(fspr_thread_rwlock_t *rwlock) { - apr_status_t stat; + fspr_status_t stat; stat = pthread_rwlock_unlock(&rwlock->rwlock); #ifdef PTHREAD_SETS_ERRNO @@ -132,45 +132,45 @@ APR_DECLARE(apr_status_t) apr_thread_rwlock_unlock(apr_thread_rwlock_t *rwlock) return stat; } -APR_DECLARE(apr_status_t) apr_thread_rwlock_destroy(apr_thread_rwlock_t *rwlock) +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_destroy(fspr_thread_rwlock_t *rwlock) { - return apr_pool_cleanup_run(rwlock->pool, rwlock, thread_rwlock_cleanup); + return fspr_pool_cleanup_run(rwlock->pool, rwlock, thread_rwlock_cleanup); } #else /* HAVE_PTHREAD_RWLOCKS */ -APR_DECLARE(apr_status_t) apr_thread_rwlock_create(apr_thread_rwlock_t **rwlock, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_create(fspr_thread_rwlock_t **rwlock, + fspr_pool_t *pool) { return APR_ENOTIMPL; } -APR_DECLARE(apr_status_t) apr_thread_rwlock_rdlock(apr_thread_rwlock_t *rwlock) +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_rdlock(fspr_thread_rwlock_t *rwlock) { return APR_ENOTIMPL; } -APR_DECLARE(apr_status_t) apr_thread_rwlock_tryrdlock(apr_thread_rwlock_t *rwlock) +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_tryrdlock(fspr_thread_rwlock_t *rwlock) { return APR_ENOTIMPL; } -APR_DECLARE(apr_status_t) apr_thread_rwlock_wrlock(apr_thread_rwlock_t *rwlock) +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_wrlock(fspr_thread_rwlock_t *rwlock) { return APR_ENOTIMPL; } -APR_DECLARE(apr_status_t) apr_thread_rwlock_trywrlock(apr_thread_rwlock_t *rwlock) +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_trywrlock(fspr_thread_rwlock_t *rwlock) { return APR_ENOTIMPL; } -APR_DECLARE(apr_status_t) apr_thread_rwlock_unlock(apr_thread_rwlock_t *rwlock) +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_unlock(fspr_thread_rwlock_t *rwlock) { return APR_ENOTIMPL; } -APR_DECLARE(apr_status_t) apr_thread_rwlock_destroy(apr_thread_rwlock_t *rwlock) +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_destroy(fspr_thread_rwlock_t *rwlock) { return APR_ENOTIMPL; } diff --git a/libs/apr/locks/win32/proc_mutex.c b/libs/apr/locks/win32/proc_mutex.c index 9620a60d00..94e497e92a 100644 --- a/libs/apr/locks/win32/proc_mutex.c +++ b/libs/apr/locks/win32/proc_mutex.c @@ -14,31 +14,31 @@ * limitations under the License. */ -#include "apr.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_strings.h" -#include "apr_portable.h" -#include "apr_arch_file_io.h" -#include "apr_arch_proc_mutex.h" -#include "apr_arch_misc.h" +#include "fspr.h" +#include "fspr_private.h" +#include "fspr_general.h" +#include "fspr_strings.h" +#include "fspr_portable.h" +#include "fspr_arch_file_io.h" +#include "fspr_arch_proc_mutex.h" +#include "fspr_arch_misc.h" -static apr_status_t proc_mutex_cleanup(void *mutex_) +static fspr_status_t proc_mutex_cleanup(void *mutex_) { - apr_proc_mutex_t *mutex = mutex_; + fspr_proc_mutex_t *mutex = mutex_; if (mutex->handle) { if (CloseHandle(mutex->handle) == 0) { - return apr_get_os_error(); + return fspr_get_os_error(); } } return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_proc_mutex_create(apr_proc_mutex_t **mutex, +APR_DECLARE(fspr_status_t) fspr_proc_mutex_create(fspr_proc_mutex_t **mutex, const char *fname, - apr_lockmech_e mech, - apr_pool_t *pool) + fspr_lockmech_e mech, + fspr_pool_t *pool) { HANDLE hMutex; void *mutexkey; @@ -68,21 +68,21 @@ APR_DECLARE(apr_status_t) apr_proc_mutex_create(apr_proc_mutex_t **mutex, #endif if (!hMutex) { - return apr_get_os_error(); + return fspr_get_os_error(); } - *mutex = (apr_proc_mutex_t *)apr_palloc(pool, sizeof(apr_proc_mutex_t)); + *mutex = (fspr_proc_mutex_t *)fspr_palloc(pool, sizeof(fspr_proc_mutex_t)); (*mutex)->pool = pool; (*mutex)->handle = hMutex; (*mutex)->fname = fname; - apr_pool_cleanup_register((*mutex)->pool, *mutex, - proc_mutex_cleanup, apr_pool_cleanup_null); + fspr_pool_cleanup_register((*mutex)->pool, *mutex, + proc_mutex_cleanup, fspr_pool_cleanup_null); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_proc_mutex_child_init(apr_proc_mutex_t **mutex, +APR_DECLARE(fspr_status_t) fspr_proc_mutex_child_init(fspr_proc_mutex_t **mutex, const char *fname, - apr_pool_t *pool) + fspr_pool_t *pool) { HANDLE hMutex; void *mutexkey; @@ -112,19 +112,19 @@ APR_DECLARE(apr_status_t) apr_proc_mutex_child_init(apr_proc_mutex_t **mutex, #endif if (!hMutex) { - return apr_get_os_error(); + return fspr_get_os_error(); } - *mutex = (apr_proc_mutex_t *)apr_palloc(pool, sizeof(apr_proc_mutex_t)); + *mutex = (fspr_proc_mutex_t *)fspr_palloc(pool, sizeof(fspr_proc_mutex_t)); (*mutex)->pool = pool; (*mutex)->handle = hMutex; (*mutex)->fname = fname; - apr_pool_cleanup_register((*mutex)->pool, *mutex, - proc_mutex_cleanup, apr_pool_cleanup_null); + fspr_pool_cleanup_register((*mutex)->pool, *mutex, + proc_mutex_cleanup, fspr_pool_cleanup_null); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_proc_mutex_lock(apr_proc_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_proc_mutex_lock(fspr_proc_mutex_t *mutex) { DWORD rv; @@ -136,10 +136,10 @@ APR_DECLARE(apr_status_t) apr_proc_mutex_lock(apr_proc_mutex_t *mutex) else if (rv == WAIT_TIMEOUT) { return APR_EBUSY; } - return apr_get_os_error(); + return fspr_get_os_error(); } -APR_DECLARE(apr_status_t) apr_proc_mutex_trylock(apr_proc_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_proc_mutex_trylock(fspr_proc_mutex_t *mutex) { DWORD rv; @@ -151,69 +151,69 @@ APR_DECLARE(apr_status_t) apr_proc_mutex_trylock(apr_proc_mutex_t *mutex) else if (rv == WAIT_TIMEOUT) { return APR_EBUSY; } - return apr_get_os_error(); + return fspr_get_os_error(); } -APR_DECLARE(apr_status_t) apr_proc_mutex_unlock(apr_proc_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_proc_mutex_unlock(fspr_proc_mutex_t *mutex) { if (ReleaseMutex(mutex->handle) == 0) { - return apr_get_os_error(); + return fspr_get_os_error(); } return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_proc_mutex_destroy(apr_proc_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_proc_mutex_destroy(fspr_proc_mutex_t *mutex) { - apr_status_t stat; + fspr_status_t stat; stat = proc_mutex_cleanup(mutex); if (stat == APR_SUCCESS) { - apr_pool_cleanup_kill(mutex->pool, mutex, proc_mutex_cleanup); + fspr_pool_cleanup_kill(mutex->pool, mutex, proc_mutex_cleanup); } return stat; } -APR_DECLARE(apr_status_t) apr_proc_mutex_cleanup(void *mutex) +APR_DECLARE(fspr_status_t) fspr_proc_mutex_cleanup(void *mutex) { - return apr_proc_mutex_destroy((apr_proc_mutex_t *)mutex); + return fspr_proc_mutex_destroy((fspr_proc_mutex_t *)mutex); } -APR_DECLARE(const char *) apr_proc_mutex_lockfile(apr_proc_mutex_t *mutex) +APR_DECLARE(const char *) fspr_proc_mutex_lockfile(fspr_proc_mutex_t *mutex) { return NULL; } -APR_DECLARE(const char *) apr_proc_mutex_name(apr_proc_mutex_t *mutex) +APR_DECLARE(const char *) fspr_proc_mutex_name(fspr_proc_mutex_t *mutex) { return mutex->fname; } -APR_DECLARE(const char *) apr_proc_mutex_defname(void) +APR_DECLARE(const char *) fspr_proc_mutex_defname(void) { return "win32mutex"; } APR_POOL_IMPLEMENT_ACCESSOR(proc_mutex) -/* Implement OS-specific accessors defined in apr_portable.h */ +/* Implement OS-specific accessors defined in fspr_portable.h */ -APR_DECLARE(apr_status_t) apr_os_proc_mutex_get(apr_os_proc_mutex_t *ospmutex, - apr_proc_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_os_proc_mutex_get(fspr_os_proc_mutex_t *ospmutex, + fspr_proc_mutex_t *mutex) { *ospmutex = mutex->handle; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_os_proc_mutex_put(apr_proc_mutex_t **pmutex, - apr_os_proc_mutex_t *ospmutex, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_os_proc_mutex_put(fspr_proc_mutex_t **pmutex, + fspr_os_proc_mutex_t *ospmutex, + fspr_pool_t *pool) { if (pool == NULL) { return APR_ENOPOOL; } if ((*pmutex) == NULL) { - (*pmutex) = (apr_proc_mutex_t *)apr_palloc(pool, - sizeof(apr_proc_mutex_t)); + (*pmutex) = (fspr_proc_mutex_t *)fspr_palloc(pool, + sizeof(fspr_proc_mutex_t)); (*pmutex)->pool = pool; } (*pmutex)->handle = *ospmutex; diff --git a/libs/apr/locks/win32/thread_cond.c b/libs/apr/locks/win32/thread_cond.c index 60286e542d..dbcca776fa 100644 --- a/libs/apr/locks/win32/thread_cond.c +++ b/libs/apr/locks/win32/thread_cond.c @@ -14,59 +14,59 @@ * limitations under the License. */ -#include "apr.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_strings.h" -#include "apr_arch_thread_mutex.h" -#include "apr_arch_thread_cond.h" -#include "apr_portable.h" +#include "fspr.h" +#include "fspr_private.h" +#include "fspr_general.h" +#include "fspr_strings.h" +#include "fspr_arch_thread_mutex.h" +#include "fspr_arch_thread_cond.h" +#include "fspr_portable.h" #include -static apr_status_t thread_cond_cleanup(void *data) +static fspr_status_t thread_cond_cleanup(void *data) { - apr_thread_cond_t *cond = data; + fspr_thread_cond_t *cond = data; CloseHandle(cond->semaphore); DeleteCriticalSection(&cond->csection); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_cond_create(apr_thread_cond_t **cond, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_thread_cond_create(fspr_thread_cond_t **cond, + fspr_pool_t *pool) { - apr_thread_cond_t *cv; + fspr_thread_cond_t *cv; - cv = apr_pcalloc(pool, sizeof(**cond)); + cv = fspr_pcalloc(pool, sizeof(**cond)); if (cv == NULL) { return APR_ENOMEM; } cv->semaphore = CreateSemaphore(NULL, 0, LONG_MAX, NULL); if (cv->semaphore == NULL) { - return apr_get_os_error(); + return fspr_get_os_error(); } *cond = cv; cv->pool = pool; InitializeCriticalSection(&cv->csection); - apr_pool_cleanup_register(cv->pool, cv, thread_cond_cleanup, - apr_pool_cleanup_null); + fspr_pool_cleanup_register(cv->pool, cv, thread_cond_cleanup, + fspr_pool_cleanup_null); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_cond_destroy(apr_thread_cond_t *cond) +APR_DECLARE(fspr_status_t) fspr_thread_cond_destroy(fspr_thread_cond_t *cond) { - return apr_pool_cleanup_run(cond->pool, cond, thread_cond_cleanup); + return fspr_pool_cleanup_run(cond->pool, cond, thread_cond_cleanup); } -static APR_INLINE apr_status_t _thread_cond_timedwait(apr_thread_cond_t *cond, - apr_thread_mutex_t *mutex, +static APR_INLINE fspr_status_t _thread_cond_timedwait(fspr_thread_cond_t *cond, + fspr_thread_mutex_t *mutex, DWORD timeout_ms ) { DWORD res; - apr_status_t rv; + fspr_status_t rv; unsigned int wake = 0; unsigned long generation; @@ -75,7 +75,7 @@ static APR_INLINE apr_status_t _thread_cond_timedwait(apr_thread_cond_t *cond, generation = cond->generation; LeaveCriticalSection(&cond->csection); - apr_thread_mutex_unlock(mutex); + fspr_thread_mutex_unlock(mutex); do { res = WaitForSingleObject(cond->semaphore, timeout_ms); @@ -107,27 +107,27 @@ static APR_INLINE apr_status_t _thread_cond_timedwait(apr_thread_cond_t *cond, } while (1); LeaveCriticalSection(&cond->csection); - apr_thread_mutex_lock(mutex); + fspr_thread_mutex_lock(mutex); return rv; } -APR_DECLARE(apr_status_t) apr_thread_cond_wait(apr_thread_cond_t *cond, - apr_thread_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_thread_cond_wait(fspr_thread_cond_t *cond, + fspr_thread_mutex_t *mutex) { return _thread_cond_timedwait(cond, mutex, INFINITE); } -APR_DECLARE(apr_status_t) apr_thread_cond_timedwait(apr_thread_cond_t *cond, - apr_thread_mutex_t *mutex, - apr_interval_time_t timeout) +APR_DECLARE(fspr_status_t) fspr_thread_cond_timedwait(fspr_thread_cond_t *cond, + fspr_thread_mutex_t *mutex, + fspr_interval_time_t timeout) { - DWORD timeout_ms = (DWORD) apr_time_as_msec(timeout); + DWORD timeout_ms = (DWORD) fspr_time_as_msec(timeout); return _thread_cond_timedwait(cond, mutex, timeout_ms); } -APR_DECLARE(apr_status_t) apr_thread_cond_signal(apr_thread_cond_t *cond) +APR_DECLARE(fspr_status_t) fspr_thread_cond_signal(fspr_thread_cond_t *cond) { unsigned int wake = 0; @@ -146,7 +146,7 @@ APR_DECLARE(apr_status_t) apr_thread_cond_signal(apr_thread_cond_t *cond) return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_cond_broadcast(apr_thread_cond_t *cond) +APR_DECLARE(fspr_status_t) fspr_thread_cond_broadcast(fspr_thread_cond_t *cond) { unsigned long num_wake = 0; diff --git a/libs/apr/locks/win32/thread_mutex.c b/libs/apr/locks/win32/thread_mutex.c index 9b10d7278d..6f86edb782 100644 --- a/libs/apr/locks/win32/thread_mutex.c +++ b/libs/apr/locks/win32/thread_mutex.c @@ -14,18 +14,18 @@ * limitations under the License. */ -#include "apr.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_strings.h" -#include "apr_arch_thread_mutex.h" -#include "apr_thread_mutex.h" -#include "apr_portable.h" -#include "apr_arch_misc.h" +#include "fspr.h" +#include "fspr_private.h" +#include "fspr_general.h" +#include "fspr_strings.h" +#include "fspr_arch_thread_mutex.h" +#include "fspr_thread_mutex.h" +#include "fspr_portable.h" +#include "fspr_arch_misc.h" -static apr_status_t thread_mutex_cleanup(void *data) +static fspr_status_t thread_mutex_cleanup(void *data) { - apr_thread_mutex_t *lock = data; + fspr_thread_mutex_t *lock = data; if (lock->type == thread_mutex_critical_section) { lock->type = -1; @@ -33,17 +33,17 @@ static apr_status_t thread_mutex_cleanup(void *data) } else { if (!CloseHandle(lock->handle)) { - return apr_get_os_error(); + return fspr_get_os_error(); } } return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_mutex_create(apr_thread_mutex_t **mutex, +APR_DECLARE(fspr_status_t) fspr_thread_mutex_create(fspr_thread_mutex_t **mutex, unsigned int flags, - apr_pool_t *pool) + fspr_pool_t *pool) { - (*mutex) = (apr_thread_mutex_t *)apr_palloc(pool, sizeof(**mutex)); + (*mutex) = (fspr_thread_mutex_t *)fspr_palloc(pool, sizeof(**mutex)); (*mutex)->pool = pool; @@ -74,12 +74,12 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_create(apr_thread_mutex_t **mutex, #endif } - apr_pool_cleanup_register((*mutex)->pool, (*mutex), thread_mutex_cleanup, - apr_pool_cleanup_null); + fspr_pool_cleanup_register((*mutex)->pool, (*mutex), thread_mutex_cleanup, + fspr_pool_cleanup_null); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_mutex_lock(apr_thread_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_thread_mutex_lock(fspr_thread_mutex_t *mutex) { if (mutex->type == thread_mutex_critical_section) { EnterCriticalSection(&mutex->section); @@ -87,13 +87,13 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_lock(apr_thread_mutex_t *mutex) else { DWORD rv = WaitForSingleObject(mutex->handle, INFINITE); if ((rv != WAIT_OBJECT_0) && (rv != WAIT_ABANDONED)) { - return (rv == WAIT_TIMEOUT) ? APR_EBUSY : apr_get_os_error(); + return (rv == WAIT_TIMEOUT) ? APR_EBUSY : fspr_get_os_error(); } } return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_mutex_trylock(apr_thread_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_thread_mutex_trylock(fspr_thread_mutex_t *mutex) { if (mutex->type == thread_mutex_critical_section) { if (!TryEnterCriticalSection(&mutex->section)) { @@ -103,33 +103,33 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_trylock(apr_thread_mutex_t *mutex) else { DWORD rv = WaitForSingleObject(mutex->handle, 0); if ((rv != WAIT_OBJECT_0) && (rv != WAIT_ABANDONED)) { - return (rv == WAIT_TIMEOUT) ? APR_EBUSY : apr_get_os_error(); + return (rv == WAIT_TIMEOUT) ? APR_EBUSY : fspr_get_os_error(); } } return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_mutex_unlock(apr_thread_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_thread_mutex_unlock(fspr_thread_mutex_t *mutex) { if (mutex->type == thread_mutex_critical_section) { LeaveCriticalSection(&mutex->section); } else if (mutex->type == thread_mutex_unnested_event) { if (!SetEvent(mutex->handle)) { - return apr_get_os_error(); + return fspr_get_os_error(); } } else if (mutex->type == thread_mutex_nested_mutex) { if (!ReleaseMutex(mutex->handle)) { - return apr_get_os_error(); + return fspr_get_os_error(); } } return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_mutex_destroy(apr_thread_mutex_t *mutex) +APR_DECLARE(fspr_status_t) fspr_thread_mutex_destroy(fspr_thread_mutex_t *mutex) { - return apr_pool_cleanup_run(mutex->pool, mutex, thread_mutex_cleanup); + return fspr_pool_cleanup_run(mutex->pool, mutex, thread_mutex_cleanup); } APR_POOL_IMPLEMENT_ACCESSOR(thread_mutex) diff --git a/libs/apr/locks/win32/thread_rwlock.c b/libs/apr/locks/win32/thread_rwlock.c index 4995ca2dee..c8242adb85 100644 --- a/libs/apr/locks/win32/thread_rwlock.c +++ b/libs/apr/locks/win32/thread_rwlock.c @@ -14,56 +14,56 @@ * limitations under the License. */ -#include "apr.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_strings.h" -#include "win32/apr_arch_thread_rwlock.h" -#include "apr_portable.h" +#include "fspr.h" +#include "fspr_private.h" +#include "fspr_general.h" +#include "fspr_strings.h" +#include "win32/fspr_arch_thread_rwlock.h" +#include "fspr_portable.h" -static apr_status_t thread_rwlock_cleanup(void *data) +static fspr_status_t thread_rwlock_cleanup(void *data) { - apr_thread_rwlock_t *rwlock = data; + fspr_thread_rwlock_t *rwlock = data; if (! CloseHandle(rwlock->read_event)) - return apr_get_os_error(); + return fspr_get_os_error(); DeleteCriticalSection(&rwlock->read_section); if (! CloseHandle(rwlock->write_mutex)) - return apr_get_os_error(); + return fspr_get_os_error(); return APR_SUCCESS; } -APR_DECLARE(apr_status_t)apr_thread_rwlock_create(apr_thread_rwlock_t **rwlock, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t)fspr_thread_rwlock_create(fspr_thread_rwlock_t **rwlock, + fspr_pool_t *pool) { - *rwlock = apr_palloc(pool, sizeof(**rwlock)); + *rwlock = fspr_palloc(pool, sizeof(**rwlock)); (*rwlock)->pool = pool; (*rwlock)->readers = 0; if (! ((*rwlock)->read_event = CreateEvent(NULL, TRUE, FALSE, NULL))) { *rwlock = NULL; - return apr_get_os_error(); + return fspr_get_os_error(); } if (! ((*rwlock)->write_mutex = CreateMutex(NULL, FALSE, NULL))) { CloseHandle((*rwlock)->read_event); *rwlock = NULL; - return apr_get_os_error(); + return fspr_get_os_error(); } InitializeCriticalSection(&(*rwlock)->read_section); - apr_pool_cleanup_register(pool, *rwlock, thread_rwlock_cleanup, - apr_pool_cleanup_null); + fspr_pool_cleanup_register(pool, *rwlock, thread_rwlock_cleanup, + fspr_pool_cleanup_null); return APR_SUCCESS; } -static apr_status_t apr_thread_rwlock_rdlock_core(apr_thread_rwlock_t *rwlock, +static fspr_status_t fspr_thread_rwlock_rdlock_core(fspr_thread_rwlock_t *rwlock, DWORD milliseconds) { DWORD code; @@ -83,31 +83,31 @@ static apr_status_t apr_thread_rwlock_rdlock_core(apr_thread_rwlock_t *rwlock, if (! ResetEvent(rwlock->read_event)) { LeaveCriticalSection(&rwlock->read_section); - return apr_get_os_error(); + return fspr_get_os_error(); } if (! ReleaseMutex(rwlock->write_mutex)) { LeaveCriticalSection(&rwlock->read_section); - return apr_get_os_error(); + return fspr_get_os_error(); } LeaveCriticalSection(&rwlock->read_section); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_rwlock_rdlock(apr_thread_rwlock_t *rwlock) +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_rdlock(fspr_thread_rwlock_t *rwlock) { - return apr_thread_rwlock_rdlock_core(rwlock, INFINITE); + return fspr_thread_rwlock_rdlock_core(rwlock, INFINITE); } -APR_DECLARE(apr_status_t) -apr_thread_rwlock_tryrdlock(apr_thread_rwlock_t *rwlock) +APR_DECLARE(fspr_status_t) +fspr_thread_rwlock_tryrdlock(fspr_thread_rwlock_t *rwlock) { - return apr_thread_rwlock_rdlock_core(rwlock, 0); + return fspr_thread_rwlock_rdlock_core(rwlock, 0); } -static apr_status_t -apr_thread_rwlock_wrlock_core(apr_thread_rwlock_t *rwlock, DWORD milliseconds) +static fspr_status_t +fspr_thread_rwlock_wrlock_core(fspr_thread_rwlock_t *rwlock, DWORD milliseconds) { DWORD code = WaitForSingleObject(rwlock->write_mutex, milliseconds); @@ -128,7 +128,7 @@ apr_thread_rwlock_wrlock_core(apr_thread_rwlock_t *rwlock, DWORD milliseconds) if (code == WAIT_FAILED || code == WAIT_TIMEOUT) { /* Unable to wait for readers to finish, release write lock: */ if (! ReleaseMutex(rwlock->write_mutex)) - return apr_get_os_error(); + return fspr_get_os_error(); return APR_FROM_OS_ERROR(code); } @@ -137,30 +137,30 @@ apr_thread_rwlock_wrlock_core(apr_thread_rwlock_t *rwlock, DWORD milliseconds) return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_rwlock_wrlock(apr_thread_rwlock_t *rwlock) +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_wrlock(fspr_thread_rwlock_t *rwlock) { - return apr_thread_rwlock_wrlock_core(rwlock, INFINITE); + return fspr_thread_rwlock_wrlock_core(rwlock, INFINITE); } -APR_DECLARE(apr_status_t)apr_thread_rwlock_trywrlock(apr_thread_rwlock_t *rwlock) +APR_DECLARE(fspr_status_t)fspr_thread_rwlock_trywrlock(fspr_thread_rwlock_t *rwlock) { - return apr_thread_rwlock_wrlock_core(rwlock, 0); + return fspr_thread_rwlock_wrlock_core(rwlock, 0); } -APR_DECLARE(apr_status_t) apr_thread_rwlock_unlock(apr_thread_rwlock_t *rwlock) +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_unlock(fspr_thread_rwlock_t *rwlock) { - apr_status_t rv = 0; + fspr_status_t rv = 0; /* First, guess that we're unlocking a writer */ if (! ReleaseMutex(rwlock->write_mutex)) - rv = apr_get_os_error(); + rv = fspr_get_os_error(); if (rv == APR_FROM_OS_ERROR(ERROR_NOT_OWNER)) { /* Nope, we must have a read lock */ if (rwlock->readers && ! InterlockedDecrement(&rwlock->readers) && ! SetEvent(rwlock->read_event)) { - rv = apr_get_os_error(); + rv = fspr_get_os_error(); } else { rv = 0; @@ -170,9 +170,9 @@ APR_DECLARE(apr_status_t) apr_thread_rwlock_unlock(apr_thread_rwlock_t *rwlock) return rv; } -APR_DECLARE(apr_status_t) apr_thread_rwlock_destroy(apr_thread_rwlock_t *rwlock) +APR_DECLARE(fspr_status_t) fspr_thread_rwlock_destroy(fspr_thread_rwlock_t *rwlock) { - return apr_pool_cleanup_run(rwlock->pool, rwlock, thread_rwlock_cleanup); + return fspr_pool_cleanup_run(rwlock->pool, rwlock, thread_rwlock_cleanup); } APR_POOL_IMPLEMENT_ACCESSOR(thread_rwlock) diff --git a/libs/apr/memory/unix/apr_pools.c b/libs/apr/memory/unix/fspr_pools.c similarity index 67% rename from libs/apr/memory/unix/apr_pools.c rename to libs/apr/memory/unix/fspr_pools.c index 7e37a5d0a0..9f67b7ec53 100644 --- a/libs/apr/memory/unix/apr_pools.c +++ b/libs/apr/memory/unix/fspr_pools.c @@ -14,22 +14,22 @@ * limitations under the License. */ -#include "apr.h" -#include "apr_private.h" +#include "fspr.h" +#include "fspr_private.h" -#include "apr_atomic.h" -#include "apr_portable.h" /* for get_os_proc */ -#include "apr_strings.h" -#include "apr_general.h" -#include "apr_pools.h" -#include "apr_allocator.h" -#include "apr_lib.h" -#include "apr_thread_mutex.h" -#include "apr_hash.h" -#include "apr_time.h" +#include "fspr_atomic.h" +#include "fspr_portable.h" /* for get_os_proc */ +#include "fspr_strings.h" +#include "fspr_general.h" +#include "fspr_pools.h" +#include "fspr_allocator.h" +#include "fspr_lib.h" +#include "fspr_thread_mutex.h" +#include "fspr_hash.h" +#include "fspr_time.h" #define APR_WANT_MEMFUNC -#include "apr_want.h" -#include "apr_env.h" +#include "fspr_want.h" +#include "fspr_env.h" #if APR_HAVE_STDLIB_H #include /* for malloc, free and abort */ @@ -64,27 +64,27 @@ * Allocator */ -struct apr_allocator_t { - apr_uint32_t max_index; - apr_uint32_t max_free_index; - apr_uint32_t current_free_index; +struct fspr_allocator_t { + fspr_uint32_t max_index; + fspr_uint32_t max_free_index; + fspr_uint32_t current_free_index; #if APR_HAS_THREADS - apr_thread_mutex_t *mutex; + fspr_thread_mutex_t *mutex; #endif /* APR_HAS_THREADS */ - apr_pool_t *owner; - apr_memnode_t *free[MAX_INDEX]; + fspr_pool_t *owner; + fspr_memnode_t *free[MAX_INDEX]; }; -#define SIZEOF_ALLOCATOR_T APR_ALIGN_DEFAULT(sizeof(apr_allocator_t)) +#define SIZEOF_ALLOCATOR_T APR_ALIGN_DEFAULT(sizeof(fspr_allocator_t)) /* * Allocator */ -APR_DECLARE(apr_status_t) apr_allocator_create(apr_allocator_t **allocator) +APR_DECLARE(fspr_status_t) fspr_allocator_create(fspr_allocator_t **allocator) { - apr_allocator_t *new_allocator; + fspr_allocator_t *new_allocator; *allocator = NULL; @@ -99,10 +99,10 @@ APR_DECLARE(apr_status_t) apr_allocator_create(apr_allocator_t **allocator) return APR_SUCCESS; } -APR_DECLARE(void) apr_allocator_destroy(apr_allocator_t *allocator) +APR_DECLARE(void) fspr_allocator_destroy(fspr_allocator_t *allocator) { - apr_uint32_t index; - apr_memnode_t *node, **ref; + fspr_uint32_t index; + fspr_memnode_t *node, **ref; for (index = 0; index < MAX_INDEX; index++) { ref = &allocator->free[index]; @@ -116,42 +116,42 @@ APR_DECLARE(void) apr_allocator_destroy(apr_allocator_t *allocator) } #if APR_HAS_THREADS -APR_DECLARE(void) apr_allocator_mutex_set(apr_allocator_t *allocator, - apr_thread_mutex_t *mutex) +APR_DECLARE(void) fspr_allocator_mutex_set(fspr_allocator_t *allocator, + fspr_thread_mutex_t *mutex) { allocator->mutex = mutex; } -APR_DECLARE(apr_thread_mutex_t *) apr_allocator_mutex_get( - apr_allocator_t *allocator) +APR_DECLARE(fspr_thread_mutex_t *) fspr_allocator_mutex_get( + fspr_allocator_t *allocator) { return allocator->mutex; } #endif /* APR_HAS_THREADS */ -APR_DECLARE(void) apr_allocator_owner_set(apr_allocator_t *allocator, - apr_pool_t *pool) +APR_DECLARE(void) fspr_allocator_owner_set(fspr_allocator_t *allocator, + fspr_pool_t *pool) { allocator->owner = pool; } -APR_DECLARE(apr_pool_t *) apr_allocator_owner_get(apr_allocator_t *allocator) +APR_DECLARE(fspr_pool_t *) fspr_allocator_owner_get(fspr_allocator_t *allocator) { return allocator->owner; } -APR_DECLARE(void) apr_allocator_max_free_set(apr_allocator_t *allocator, - apr_size_t in_size) +APR_DECLARE(void) fspr_allocator_max_free_set(fspr_allocator_t *allocator, + fspr_size_t in_size) { - apr_uint32_t max_free_index; - apr_uint32_t size = (APR_UINT32_TRUNC_CAST)in_size; + fspr_uint32_t max_free_index; + fspr_uint32_t size = (APR_UINT32_TRUNC_CAST)in_size; #if APR_HAS_THREADS - apr_thread_mutex_t *mutex; + fspr_thread_mutex_t *mutex; - mutex = apr_allocator_mutex_get(allocator); + mutex = fspr_allocator_mutex_get(allocator); if (mutex != NULL) - apr_thread_mutex_lock(mutex); + fspr_thread_mutex_lock(mutex); #endif /* APR_HAS_THREADS */ max_free_index = APR_ALIGN(size, BOUNDARY_SIZE) >> BOUNDARY_INDEX; @@ -163,16 +163,16 @@ APR_DECLARE(void) apr_allocator_max_free_set(apr_allocator_t *allocator, #if APR_HAS_THREADS if (mutex != NULL) - apr_thread_mutex_unlock(mutex); + fspr_thread_mutex_unlock(mutex); #endif } static APR_INLINE -apr_memnode_t *allocator_alloc(apr_allocator_t *allocator, apr_size_t size) +fspr_memnode_t *allocator_alloc(fspr_allocator_t *allocator, fspr_size_t size) { - apr_memnode_t *node, **ref; - apr_uint32_t max_index; - apr_size_t i, index; + fspr_memnode_t *node, **ref; + fspr_uint32_t max_index; + fspr_size_t i, index; /* Round up the block size to the next boundary, but always * allocate at least a certain size (MIN_ALLOC). @@ -196,7 +196,7 @@ apr_memnode_t *allocator_alloc(apr_allocator_t *allocator, apr_size_t size) if (index <= allocator->max_index) { #if APR_HAS_THREADS if (allocator->mutex) - apr_thread_mutex_lock(allocator->mutex); + fspr_thread_mutex_lock(allocator->mutex); #endif /* APR_HAS_THREADS */ /* Walk the free list to see if there are @@ -239,7 +239,7 @@ apr_memnode_t *allocator_alloc(apr_allocator_t *allocator, apr_size_t size) #if APR_HAS_THREADS if (allocator->mutex) - apr_thread_mutex_unlock(allocator->mutex); + fspr_thread_mutex_unlock(allocator->mutex); #endif /* APR_HAS_THREADS */ node->next = NULL; @@ -250,7 +250,7 @@ apr_memnode_t *allocator_alloc(apr_allocator_t *allocator, apr_size_t size) #if APR_HAS_THREADS if (allocator->mutex) - apr_thread_mutex_unlock(allocator->mutex); + fspr_thread_mutex_unlock(allocator->mutex); #endif /* APR_HAS_THREADS */ } @@ -260,7 +260,7 @@ apr_memnode_t *allocator_alloc(apr_allocator_t *allocator, apr_size_t size) else if (allocator->free[0]) { #if APR_HAS_THREADS if (allocator->mutex) - apr_thread_mutex_lock(allocator->mutex); + fspr_thread_mutex_lock(allocator->mutex); #endif /* APR_HAS_THREADS */ /* Walk the free list to see if there are @@ -279,7 +279,7 @@ apr_memnode_t *allocator_alloc(apr_allocator_t *allocator, apr_size_t size) #if APR_HAS_THREADS if (allocator->mutex) - apr_thread_mutex_unlock(allocator->mutex); + fspr_thread_mutex_unlock(allocator->mutex); #endif /* APR_HAS_THREADS */ node->next = NULL; @@ -290,7 +290,7 @@ apr_memnode_t *allocator_alloc(apr_allocator_t *allocator, apr_size_t size) #if APR_HAS_THREADS if (allocator->mutex) - apr_thread_mutex_unlock(allocator->mutex); + fspr_thread_mutex_unlock(allocator->mutex); #endif /* APR_HAS_THREADS */ } @@ -309,15 +309,15 @@ apr_memnode_t *allocator_alloc(apr_allocator_t *allocator, apr_size_t size) } static APR_INLINE -void allocator_free(apr_allocator_t *allocator, apr_memnode_t *node) +void allocator_free(fspr_allocator_t *allocator, fspr_memnode_t *node) { - apr_memnode_t *next, *freelist = NULL; - apr_uint32_t index, max_index; - apr_uint32_t max_free_index, current_free_index; + fspr_memnode_t *next, *freelist = NULL; + fspr_uint32_t index, max_index; + fspr_uint32_t max_free_index, current_free_index; #if APR_HAS_THREADS if (allocator->mutex) - apr_thread_mutex_lock(allocator->mutex); + fspr_thread_mutex_lock(allocator->mutex); #endif /* APR_HAS_THREADS */ max_index = allocator->max_index; @@ -362,7 +362,7 @@ void allocator_free(apr_allocator_t *allocator, apr_memnode_t *node) #if APR_HAS_THREADS if (allocator->mutex) - apr_thread_mutex_unlock(allocator->mutex); + fspr_thread_mutex_unlock(allocator->mutex); #endif /* APR_HAS_THREADS */ while (freelist != NULL) { @@ -372,14 +372,14 @@ void allocator_free(apr_allocator_t *allocator, apr_memnode_t *node) } } -APR_DECLARE(apr_memnode_t *) apr_allocator_alloc(apr_allocator_t *allocator, - apr_size_t size) +APR_DECLARE(fspr_memnode_t *) fspr_allocator_alloc(fspr_allocator_t *allocator, + fspr_size_t size) { return allocator_alloc(allocator, size); } -APR_DECLARE(void) apr_allocator_free(apr_allocator_t *allocator, - apr_memnode_t *node) +APR_DECLARE(void) fspr_allocator_free(fspr_allocator_t *allocator, + fspr_memnode_t *node) { allocator_free(allocator, node); } @@ -409,8 +409,8 @@ typedef struct cleanup_t cleanup_t; /** A list of processes */ struct process_chain { /** The process ID */ - apr_proc_t *proc; - apr_kill_conditions_e kill_how; + fspr_proc_t *proc; + fspr_kill_conditions_e kill_how; /** The next process in the list */ struct process_chain *next; }; @@ -422,7 +422,7 @@ typedef struct debug_node_t debug_node_t; struct debug_node_t { debug_node_t *next; - apr_uint32_t index; + fspr_uint32_t index; void *beginp[64]; void *endp[64]; }; @@ -431,68 +431,68 @@ struct debug_node_t { #endif /* APR_POOL_DEBUG */ -/* The ref field in the apr_pool_t struct holds a +/* The ref field in the fspr_pool_t struct holds a * pointer to the pointer referencing this pool. * It is used for parent, child, sibling management. - * Look at apr_pool_create_ex() and apr_pool_destroy() + * Look at fspr_pool_create_ex() and fspr_pool_destroy() * to see how it is used. */ -struct apr_pool_t { - apr_pool_t *parent; - apr_pool_t *child; - apr_pool_t *sibling; - apr_pool_t **ref; +struct fspr_pool_t { + fspr_pool_t *parent; + fspr_pool_t *child; + fspr_pool_t *sibling; + fspr_pool_t **ref; cleanup_t *cleanups; cleanup_t *free_cleanups; - apr_allocator_t *allocator; + fspr_allocator_t *allocator; struct process_chain *subprocesses; - apr_abortfunc_t abort_fn; - apr_hash_t *user_data; + fspr_abortfunc_t abort_fn; + fspr_hash_t *user_data; const char *tag; #if APR_HAS_THREADS - apr_thread_mutex_t *user_mutex; + fspr_thread_mutex_t *user_mutex; #endif #if !APR_POOL_DEBUG - apr_memnode_t *active; - apr_memnode_t *self; /* The node containing the pool itself */ + fspr_memnode_t *active; + fspr_memnode_t *self; /* The node containing the pool itself */ char *self_first_avail; #else /* APR_POOL_DEBUG */ - apr_pool_t *joined; /* the caller has guaranteed that this pool + fspr_pool_t *joined; /* the caller has guaranteed that this pool * will survive as long as ->joined */ debug_node_t *nodes; const char *file_line; - apr_uint32_t creation_flags; + fspr_uint32_t creation_flags; unsigned int stat_alloc; unsigned int stat_total_alloc; unsigned int stat_clear; #if APR_HAS_THREADS - apr_os_thread_t owner; - apr_thread_mutex_t *mutex; + fspr_os_thread_t owner; + fspr_thread_mutex_t *mutex; #endif /* APR_HAS_THREADS */ #endif /* APR_POOL_DEBUG */ #ifdef NETWARE - apr_os_proc_t owner_proc; + fspr_os_proc_t owner_proc; #endif /* defined(NETWARE) */ }; -#define SIZEOF_POOL_T APR_ALIGN_DEFAULT(sizeof(apr_pool_t)) +#define SIZEOF_POOL_T APR_ALIGN_DEFAULT(sizeof(fspr_pool_t)) /* * Variables */ -static apr_byte_t apr_pools_initialized = 0; -static apr_pool_t *global_pool = NULL; +static fspr_byte_t fspr_pools_initialized = 0; +static fspr_pool_t *global_pool = NULL; #if !APR_POOL_DEBUG -static apr_allocator_t *global_allocator = NULL; +static fspr_allocator_t *global_allocator = NULL; #endif /* !APR_POOL_DEBUG */ #if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) -static apr_file_t *file_stderr = NULL; +static fspr_file_t *file_stderr = NULL; #endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) */ /* @@ -504,13 +504,13 @@ static void run_child_cleanups(cleanup_t **c); static void free_proc_chain(struct process_chain *procs); #if APR_POOL_DEBUG -static void pool_destroy_debug(apr_pool_t *pool, const char *file_line); +static void pool_destroy_debug(fspr_pool_t *pool, const char *file_line); #endif #if APR_HAS_THREADS -APR_DECLARE(void) apr_pool_mutex_set(apr_pool_t *pool, - apr_thread_mutex_t *mutex) +APR_DECLARE(void) fspr_pool_mutex_set(fspr_pool_t *pool, + fspr_thread_mutex_t *mutex) { pool->user_mutex = mutex; } @@ -522,63 +522,63 @@ APR_DECLARE(void) apr_pool_mutex_set(apr_pool_t *pool, * Initialization */ -APR_DECLARE(apr_status_t) apr_pool_initialize(void) +APR_DECLARE(fspr_status_t) fspr_pool_initialize(void) { - apr_status_t rv; + fspr_status_t rv; - if (apr_pools_initialized++) + if (fspr_pools_initialized++) return APR_SUCCESS; - if ((rv = apr_allocator_create(&global_allocator)) != APR_SUCCESS) { - apr_pools_initialized = 0; + if ((rv = fspr_allocator_create(&global_allocator)) != APR_SUCCESS) { + fspr_pools_initialized = 0; return rv; } - if ((rv = apr_pool_create_ex(&global_pool, NULL, NULL, + if ((rv = fspr_pool_create_ex(&global_pool, NULL, NULL, global_allocator)) != APR_SUCCESS) { - apr_allocator_destroy(global_allocator); + fspr_allocator_destroy(global_allocator); global_allocator = NULL; - apr_pools_initialized = 0; + fspr_pools_initialized = 0; return rv; } - apr_pool_tag(global_pool, "apr_global_pool"); + fspr_pool_tag(global_pool, "fspr_global_pool"); /* This has to happen here because mutexes might be backed by - * atomics. It used to be snug and safe in apr_initialize(). + * atomics. It used to be snug and safe in fspr_initialize(). */ - if ((rv = apr_atomic_init(global_pool)) != APR_SUCCESS) { + if ((rv = fspr_atomic_init(global_pool)) != APR_SUCCESS) { return rv; } #if APR_HAS_THREADS { - apr_thread_mutex_t *mutex; + fspr_thread_mutex_t *mutex; - if ((rv = apr_thread_mutex_create(&mutex, + if ((rv = fspr_thread_mutex_create(&mutex, APR_THREAD_MUTEX_DEFAULT, global_pool)) != APR_SUCCESS) { return rv; } - apr_allocator_mutex_set(global_allocator, mutex); + fspr_allocator_mutex_set(global_allocator, mutex); } #endif /* APR_HAS_THREADS */ - apr_allocator_owner_set(global_allocator, global_pool); + fspr_allocator_owner_set(global_allocator, global_pool); return APR_SUCCESS; } -APR_DECLARE(void) apr_pool_terminate(void) +APR_DECLARE(void) fspr_pool_terminate(void) { - if (!apr_pools_initialized) + if (!fspr_pools_initialized) return; - if (--apr_pools_initialized) + if (--fspr_pools_initialized) return; - apr_pool_destroy(global_pool); /* This will also destroy the mutex */ + fspr_pool_destroy(global_pool); /* This will also destroy the mutex */ global_pool = NULL; global_allocator = NULL; @@ -604,19 +604,19 @@ APR_DECLARE(void) apr_pool_terminate(void) * Memory allocation */ -APR_DECLARE(void *) apr_palloc(apr_pool_t *pool, apr_size_t size) +APR_DECLARE(void *) fspr_palloc(fspr_pool_t *pool, fspr_size_t size) { - apr_memnode_t *active, *node; + fspr_memnode_t *active, *node; void *mem = NULL; - apr_size_t free_index; + fspr_size_t free_index; #if APR_HAS_THREADS - if (pool->user_mutex) apr_thread_mutex_lock(pool->user_mutex); + if (pool->user_mutex) fspr_thread_mutex_lock(pool->user_mutex); #endif size = APR_ALIGN_DEFAULT(size); active = pool->active; /* If the active node has enough bytes left, use it. */ - if (size < (apr_size_t)(active->endp - active->first_avail)) { + if (size < (fspr_size_t)(active->endp - active->first_avail)) { mem = active->first_avail; active->first_avail += size; @@ -624,7 +624,7 @@ APR_DECLARE(void *) apr_palloc(apr_pool_t *pool, apr_size_t size) } node = active->next; - if (size < (apr_size_t)(node->endp - node->first_avail)) { + if (size < (fspr_size_t)(node->endp - node->first_avail)) { list_remove(node); } else { @@ -664,26 +664,26 @@ APR_DECLARE(void *) apr_palloc(apr_pool_t *pool, apr_size_t size) end: #if APR_HAS_THREADS - if (pool->user_mutex) apr_thread_mutex_unlock(pool->user_mutex); + if (pool->user_mutex) fspr_thread_mutex_unlock(pool->user_mutex); #endif return mem; } -/* Provide an implementation of apr_pcalloc for backward compatibility - * with code built before apr_pcalloc was a macro +/* Provide an implementation of fspr_pcalloc for backward compatibility + * with code built before fspr_pcalloc was a macro */ -#ifdef apr_pcalloc -#undef apr_pcalloc +#ifdef fspr_pcalloc +#undef fspr_pcalloc #endif -APR_DECLARE(void *) apr_pcalloc(apr_pool_t *pool, apr_size_t size); -APR_DECLARE(void *) apr_pcalloc(apr_pool_t *pool, apr_size_t size) +APR_DECLARE(void *) fspr_pcalloc(fspr_pool_t *pool, fspr_size_t size); +APR_DECLARE(void *) fspr_pcalloc(fspr_pool_t *pool, fspr_size_t size) { void *mem; size = APR_ALIGN_DEFAULT(size); - if ((mem = apr_palloc(pool, size)) != NULL) { + if ((mem = fspr_palloc(pool, size)) != NULL) { memset(mem, 0, size); } @@ -695,17 +695,17 @@ APR_DECLARE(void *) apr_pcalloc(apr_pool_t *pool, apr_size_t size) * Pool creation/destruction */ -APR_DECLARE(void) apr_pool_clear(apr_pool_t *pool) +APR_DECLARE(void) fspr_pool_clear(fspr_pool_t *pool) { - apr_memnode_t *active; + fspr_memnode_t *active; #if APR_HAS_THREADS - if (pool->user_mutex) apr_thread_mutex_lock(pool->user_mutex); + if (pool->user_mutex) fspr_thread_mutex_lock(pool->user_mutex); #endif /* Destroy the subpools. The subpools will detach themselves from * this pool thus this loop is safe and easy. */ while (pool->child) - apr_pool_destroy(pool->child); + fspr_pool_destroy(pool->child); /* Run cleanups */ run_cleanups(&pool->cleanups); @@ -735,20 +735,20 @@ APR_DECLARE(void) apr_pool_clear(apr_pool_t *pool) end: #if APR_HAS_THREADS - if (pool->user_mutex) apr_thread_mutex_unlock(pool->user_mutex); + if (pool->user_mutex) fspr_thread_mutex_unlock(pool->user_mutex); #endif } -APR_DECLARE(void) apr_pool_destroy(apr_pool_t *pool) +APR_DECLARE(void) fspr_pool_destroy(fspr_pool_t *pool) { - apr_memnode_t *active; - apr_allocator_t *allocator; + fspr_memnode_t *active; + fspr_allocator_t *allocator; /* Destroy the subpools. The subpools will detach themselve from * this pool thus this loop is safe and easy. */ while (pool->child) - apr_pool_destroy(pool->child); + fspr_pool_destroy(pool->child); /* Run cleanups */ run_cleanups(&pool->cleanups); @@ -759,10 +759,10 @@ APR_DECLARE(void) apr_pool_destroy(apr_pool_t *pool) /* Remove the pool from the parents child list */ if (pool->parent) { #if APR_HAS_THREADS - apr_thread_mutex_t *mutex; + fspr_thread_mutex_t *mutex; - if ((mutex = apr_allocator_mutex_get(pool->parent->allocator)) != NULL) - apr_thread_mutex_lock(mutex); + if ((mutex = fspr_allocator_mutex_get(pool->parent->allocator)) != NULL) + fspr_thread_mutex_lock(mutex); #endif /* APR_HAS_THREADS */ if ((*pool->ref = pool->sibling) != NULL) @@ -770,7 +770,7 @@ APR_DECLARE(void) apr_pool_destroy(apr_pool_t *pool) #if APR_HAS_THREADS if (mutex) - apr_thread_mutex_unlock(mutex); + fspr_thread_mutex_unlock(mutex); #endif /* APR_HAS_THREADS */ } @@ -782,11 +782,11 @@ APR_DECLARE(void) apr_pool_destroy(apr_pool_t *pool) *active->ref = NULL; #if APR_HAS_THREADS - if (apr_allocator_owner_get(allocator) == pool) { + if (fspr_allocator_owner_get(allocator) == pool) { /* Make sure to remove the lock, since it is highly likely to * be invalid now. */ - apr_allocator_mutex_set(allocator, NULL); + fspr_allocator_mutex_set(allocator, NULL); } #endif /* APR_HAS_THREADS */ @@ -800,18 +800,18 @@ APR_DECLARE(void) apr_pool_destroy(apr_pool_t *pool) * and the allocator). Don't worry about destroying the optional mutex * in the allocator, it will have been destroyed by the cleanup function. */ - if (apr_allocator_owner_get(allocator) == pool) { - apr_allocator_destroy(allocator); + if (fspr_allocator_owner_get(allocator) == pool) { + fspr_allocator_destroy(allocator); } } -APR_DECLARE(apr_status_t) apr_pool_create_ex(apr_pool_t **newpool, - apr_pool_t *parent, - apr_abortfunc_t abort_fn, - apr_allocator_t *allocator) +APR_DECLARE(fspr_status_t) fspr_pool_create_ex(fspr_pool_t **newpool, + fspr_pool_t *parent, + fspr_abortfunc_t abort_fn, + fspr_allocator_t *allocator) { - apr_pool_t *pool; - apr_memnode_t *node; + fspr_pool_t *pool; + fspr_memnode_t *node; *newpool = NULL; @@ -844,7 +844,7 @@ APR_DECLARE(apr_status_t) apr_pool_create_ex(apr_pool_t **newpool, node->next = node; node->ref = &node->next; - pool = (apr_pool_t *)node->first_avail; + pool = (fspr_pool_t *)node->first_avail; node->first_avail = pool->self_first_avail = (char *)pool + SIZEOF_POOL_T; pool->allocator = allocator; @@ -860,15 +860,15 @@ APR_DECLARE(apr_status_t) apr_pool_create_ex(apr_pool_t **newpool, pool->user_mutex = NULL; #endif #ifdef NETWARE - pool->owner_proc = (apr_os_proc_t)getnlmhandle(); + pool->owner_proc = (fspr_os_proc_t)getnlmhandle(); #endif /* defined(NETWARE) */ if ((pool->parent = parent) != NULL) { #if APR_HAS_THREADS - apr_thread_mutex_t *mutex; + fspr_thread_mutex_t *mutex; - if ((mutex = apr_allocator_mutex_get(parent->allocator)) != NULL) - apr_thread_mutex_lock(mutex); + if ((mutex = fspr_allocator_mutex_get(parent->allocator)) != NULL) + fspr_thread_mutex_lock(mutex); #endif /* APR_HAS_THREADS */ if ((pool->sibling = parent->child) != NULL) @@ -879,7 +879,7 @@ APR_DECLARE(apr_status_t) apr_pool_create_ex(apr_pool_t **newpool, #if APR_HAS_THREADS if (mutex) - apr_thread_mutex_unlock(mutex); + fspr_thread_mutex_unlock(mutex); #endif /* APR_HAS_THREADS */ } else { @@ -898,37 +898,37 @@ APR_DECLARE(apr_status_t) apr_pool_create_ex(apr_pool_t **newpool, */ /* - * apr_psprintf is implemented by writing directly into the current + * fspr_psprintf is implemented by writing directly into the current * block of the pool, starting right at first_avail. If there's * insufficient room, then a new block is allocated and the earlier * output is copied over. The new block isn't linked into the pool * until all the output is done. * * Note that this is completely safe because nothing else can - * allocate in this apr_pool_t while apr_psprintf is running. alarms are - * blocked, and the only thing outside of apr_pools.c that's invoked - * is apr_vformatter -- which was purposefully written to be + * allocate in this fspr_pool_t while fspr_psprintf is running. alarms are + * blocked, and the only thing outside of fspr_pools.c that's invoked + * is fspr_vformatter -- which was purposefully written to be * self-contained with no callouts. */ struct psprintf_data { - apr_vformatter_buff_t vbuff; - apr_memnode_t *node; - apr_pool_t *pool; - apr_byte_t got_a_new_node; - apr_memnode_t *free; + fspr_vformatter_buff_t vbuff; + fspr_memnode_t *node; + fspr_pool_t *pool; + fspr_byte_t got_a_new_node; + fspr_memnode_t *free; }; #define APR_PSPRINTF_MIN_STRINGSIZE 32 -static int psprintf_flush(apr_vformatter_buff_t *vbuff) +static int psprintf_flush(fspr_vformatter_buff_t *vbuff) { struct psprintf_data *ps = (struct psprintf_data *)vbuff; - apr_memnode_t *node, *active; - apr_size_t cur_len, size; + fspr_memnode_t *node, *active; + fspr_size_t cur_len, size; char *strp; - apr_pool_t *pool; - apr_size_t free_index; + fspr_pool_t *pool; + fspr_size_t free_index; pool = ps->pool; active = ps->node; @@ -946,7 +946,7 @@ static int psprintf_flush(apr_vformatter_buff_t *vbuff) node = active->next; if (!ps->got_a_new_node - && size < (apr_size_t)(node->endp - node->first_avail)) { + && size < (fspr_size_t)(node->endp - node->first_avail)) { list_remove(node); list_insert(node, active); @@ -993,19 +993,19 @@ static int psprintf_flush(apr_vformatter_buff_t *vbuff) return 0; } -APR_DECLARE(char *) apr_pvsprintf(apr_pool_t *pool, const char *fmt, va_list ap) +APR_DECLARE(char *) fspr_pvsprintf(fspr_pool_t *pool, const char *fmt, va_list ap) { struct psprintf_data ps; char *strp; - apr_size_t size; - apr_memnode_t *active, *node; - apr_size_t free_index; + fspr_size_t size; + fspr_memnode_t *active, *node; + fspr_size_t free_index; #if APR_HAS_THREADS - if (pool->user_mutex) apr_thread_mutex_lock(pool->user_mutex); + if (pool->user_mutex) fspr_thread_mutex_lock(pool->user_mutex); #endif - ps.node = active = pool->active; + ps.node = pool->active; ps.pool = pool; ps.vbuff.curpos = ps.node->first_avail; @@ -1014,7 +1014,7 @@ APR_DECLARE(char *) apr_pvsprintf(apr_pool_t *pool, const char *fmt, va_list ap) ps.got_a_new_node = 0; ps.free = NULL; - /* Make sure that the first node passed to apr_vformatter has at least + /* Make sure that the first node passed to fspr_vformatter has at least * room to hold the NUL terminator. */ if (ps.node->first_avail == ps.node->endp) { @@ -1028,7 +1028,7 @@ APR_DECLARE(char *) apr_pvsprintf(apr_pool_t *pool, const char *fmt, va_list ap) } } - if (apr_vformatter(psprintf_flush, &ps.vbuff, fmt, ap) == -1) { + if (fspr_vformatter(psprintf_flush, &ps.vbuff, fmt, ap) == -1) { if (pool->abort_fn) pool->abort_fn(APR_ENOMEM); @@ -1082,7 +1082,7 @@ APR_DECLARE(char *) apr_pvsprintf(apr_pool_t *pool, const char *fmt, va_list ap) end: #if APR_HAS_THREADS - if (pool->user_mutex) apr_thread_mutex_unlock(pool->user_mutex); + if (pool->user_mutex) fspr_thread_mutex_unlock(pool->user_mutex); #endif return strp; @@ -1100,12 +1100,12 @@ APR_DECLARE(char *) apr_pvsprintf(apr_pool_t *pool, const char *fmt, va_list ap) * anything other than 0, abort the traversal and return the value * returned by fn. */ -static int apr_pool_walk_tree(apr_pool_t *pool, - int (*fn)(apr_pool_t *pool, void *data), +static int fspr_pool_walk_tree(fspr_pool_t *pool, + int (*fn)(fspr_pool_t *pool, void *data), void *data) { int rv; - apr_pool_t *child; + fspr_pool_t *child; rv = fn(pool, data); if (rv) @@ -1113,13 +1113,13 @@ static int apr_pool_walk_tree(apr_pool_t *pool, #if APR_HAS_THREADS if (pool->mutex) { - apr_thread_mutex_lock(pool->mutex); + fspr_thread_mutex_lock(pool->mutex); } #endif /* APR_HAS_THREADS */ child = pool->child; while (child) { - rv = apr_pool_walk_tree(child, fn, data); + rv = fspr_pool_walk_tree(child, fn, data); if (rv) break; @@ -1128,21 +1128,21 @@ static int apr_pool_walk_tree(apr_pool_t *pool, #if APR_HAS_THREADS if (pool->mutex) { - apr_thread_mutex_unlock(pool->mutex); + fspr_thread_mutex_unlock(pool->mutex); } #endif /* APR_HAS_THREADS */ return rv; } -APR_DECLARE(int) apr_pool_walk_tree_debug(apr_pool_t *pool, - int(*fn)(apr_pool_t *pool, void *data), +APR_DECLARE(int) fspr_pool_walk_tree_debug(fspr_pool_t *pool, + int(*fn)(fspr_pool_t *pool, void *data), void *data) { - return apr_pool_walk_tree(pool, fn, data); + return fspr_pool_walk_tree(pool, fn, data); } -APR_DECLARE(void) apr_pool_get_stats(apr_pool_t *pool, unsigned int *alloc, unsigned int *total_alloc, unsigned int *clear) +APR_DECLARE(void) fspr_pool_get_stats(fspr_pool_t *pool, unsigned int *alloc, unsigned int *total_alloc, unsigned int *clear) { if (pool) { *alloc = pool->stat_alloc; @@ -1152,12 +1152,12 @@ APR_DECLARE(void) apr_pool_get_stats(apr_pool_t *pool, unsigned int *alloc, unsi } #if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) -static void apr_pool_log_event(apr_pool_t *pool, const char *event, +static void fspr_pool_log_event(fspr_pool_t *pool, const char *event, const char *file_line, int deref) { if (file_stderr) { if (deref) { - apr_file_printf(file_stderr, + fspr_file_printf(file_stderr, "POOL DEBUG: " "[%lu" #if APR_HAS_THREADS @@ -1172,18 +1172,18 @@ static void apr_pool_log_event(apr_pool_t *pool, const char *event, "\n", (unsigned long)getpid(), #if APR_HAS_THREADS - (unsigned long)apr_os_thread_current(), + (unsigned long)fspr_os_thread_current(), #endif /* APR_HAS_THREADS */ event, - (unsigned long)apr_pool_num_bytes(pool, 0), - (unsigned long)apr_pool_num_bytes(pool, 1), - (unsigned long)apr_pool_num_bytes(global_pool, 1), + (unsigned long)fspr_pool_num_bytes(pool, 0), + (unsigned long)fspr_pool_num_bytes(pool, 1), + (unsigned long)fspr_pool_num_bytes(global_pool, 1), (unsigned int)pool, pool->tag, file_line, pool->stat_alloc, pool->stat_total_alloc, pool->stat_clear); } else { - apr_file_printf(file_stderr, + fspr_file_printf(file_stderr, "POOL DEBUG: " "[%lu" #if APR_HAS_THREADS @@ -1197,7 +1197,7 @@ static void apr_pool_log_event(apr_pool_t *pool, const char *event, "\n", (unsigned long)getpid(), #if APR_HAS_THREADS - (unsigned long)apr_os_thread_current(), + (unsigned long)fspr_os_thread_current(), #endif /* APR_HAS_THREADS */ event, (unsigned int)pool, @@ -1208,26 +1208,26 @@ static void apr_pool_log_event(apr_pool_t *pool, const char *event, #endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) */ #if (APR_POOL_DEBUG & APR_POOL_DEBUG_LIFETIME) -static int pool_is_child_of(apr_pool_t *parent, void *data) +static int pool_is_child_of(fspr_pool_t *parent, void *data) { - apr_pool_t *pool = (apr_pool_t *)data; + fspr_pool_t *pool = (fspr_pool_t *)data; return (pool == parent); } -static int apr_pool_is_child_of(apr_pool_t *pool, apr_pool_t *parent) +static int fspr_pool_is_child_of(fspr_pool_t *pool, fspr_pool_t *parent) { if (parent == NULL) return 0; - return apr_pool_walk_tree(parent, pool_is_child_of, pool); + return fspr_pool_walk_tree(parent, pool_is_child_of, pool); } #endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_LIFETIME) */ -static void apr_pool_check_integrity(apr_pool_t *pool) +static void fspr_pool_check_integrity(fspr_pool_t *pool) { /* Rule of thumb: use of the global pool is always - * ok, since the only user is apr_pools.c. Unless + * ok, since the only user is fspr_pools.c. Unless * people have searched for the top level parent and * started to use that... */ @@ -1240,10 +1240,10 @@ static void apr_pool_check_integrity(apr_pool_t *pool) * destroyed, in which case we abort(). */ #if (APR_POOL_DEBUG & APR_POOL_DEBUG_LIFETIME) - if (!apr_pool_is_child_of(pool, global_pool)) { + if (!fspr_pool_is_child_of(pool, global_pool)) { #if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) - apr_pool_log_event(pool, "LIFE", - __FILE__ ":apr_pool_integrity check", 0); + fspr_pool_log_event(pool, "LIFE", + __FILE__ ":fspr_pool_integrity check", 0); #endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) */ abort(); } @@ -1251,10 +1251,10 @@ static void apr_pool_check_integrity(apr_pool_t *pool) #if (APR_POOL_DEBUG & APR_POOL_DEBUG_OWNER) #if APR_HAS_THREADS - if (!apr_os_thread_equal(pool->owner, apr_os_thread_current())) { + if (!fspr_os_thread_equal(pool->owner, fspr_os_thread_current())) { #if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) - apr_pool_log_event(pool, "THREAD", - __FILE__ ":apr_pool_integrity check", 0); + fspr_pool_log_event(pool, "THREAD", + __FILE__ ":fspr_pool_integrity check", 0); #endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) */ abort(); } @@ -1267,14 +1267,14 @@ static void apr_pool_check_integrity(apr_pool_t *pool) * Initialization (debug) */ -APR_DECLARE(apr_status_t) apr_pool_initialize(void) +APR_DECLARE(fspr_status_t) fspr_pool_initialize(void) { - apr_status_t rv; + fspr_status_t rv; #if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) char *logpath; #endif - if (apr_pools_initialized++) + if (fspr_pools_initialized++) return APR_SUCCESS; /* Since the debug code works a bit differently then the @@ -1282,35 +1282,35 @@ APR_DECLARE(apr_status_t) apr_pool_initialize(void) * pools code has got this lock embedded in the global * allocator, a concept unknown to debug mode. */ - if ((rv = apr_pool_create_ex(&global_pool, NULL, NULL, + if ((rv = fspr_pool_create_ex(&global_pool, NULL, NULL, NULL)) != APR_SUCCESS) { return rv; } - apr_pool_tag(global_pool, "APR global pool"); + fspr_pool_tag(global_pool, "APR global pool"); - apr_pools_initialized = 1; + fspr_pools_initialized = 1; /* This has to happen here because mutexes might be backed by - * atomics. It used to be snug and safe in apr_initialize(). + * atomics. It used to be snug and safe in fspr_initialize(). */ - if ((rv = apr_atomic_init(global_pool)) != APR_SUCCESS) { + if ((rv = fspr_atomic_init(global_pool)) != APR_SUCCESS) { return rv; } #if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) - rv = apr_env_get(&logpath, "APR_POOL_DEBUG_LOG", global_pool); + rv = fspr_env_get(&logpath, "APR_POOL_DEBUG_LOG", global_pool); if (rv == APR_SUCCESS) { - apr_file_open(&file_stderr, logpath, APR_APPEND|APR_WRITE|APR_CREATE, + fspr_file_open(&file_stderr, logpath, APR_APPEND|APR_WRITE|APR_CREATE, APR_OS_DEFAULT, global_pool); } else { - apr_file_open_stderr(&file_stderr, global_pool); + fspr_file_open_stderr(&file_stderr, global_pool); } if (file_stderr) { - apr_file_printf(file_stderr, + fspr_file_printf(file_stderr, "POOL DEBUG: [PID" #if APR_HAS_THREADS "/TID" @@ -1318,21 +1318,21 @@ APR_DECLARE(apr_status_t) apr_pool_initialize(void) "] ACTION (SIZE /POOL SIZE /TOTAL SIZE) " "POOL \"TAG\" <__FILE__:__LINE__> (ALLOCS/TOTAL ALLOCS/CLEARS)\n"); - apr_pool_log_event(global_pool, "GLOBAL", __FILE__ ":apr_pool_initialize", 0); + fspr_pool_log_event(global_pool, "GLOBAL", __FILE__ ":fspr_pool_initialize", 0); } #endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) */ return APR_SUCCESS; } -APR_DECLARE(void) apr_pool_terminate(void) +APR_DECLARE(void) fspr_pool_terminate(void) { - if (!apr_pools_initialized) + if (!fspr_pools_initialized) return; - apr_pools_initialized = 0; + fspr_pools_initialized = 0; - apr_pool_destroy(global_pool); /* This will also destroy the mutex */ + fspr_pool_destroy(global_pool); /* This will also destroy the mutex */ global_pool = NULL; #if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) @@ -1345,7 +1345,7 @@ APR_DECLARE(void) apr_pool_terminate(void) * Memory allocation (debug) */ -static void *pool_alloc(apr_pool_t *pool, apr_size_t size) +static void *pool_alloc(fspr_pool_t *pool, fspr_size_t size) { debug_node_t *node; void *mem; @@ -1383,34 +1383,34 @@ static void *pool_alloc(apr_pool_t *pool, apr_size_t size) return mem; } -APR_DECLARE(void *) apr_palloc_debug(apr_pool_t *pool, apr_size_t size, +APR_DECLARE(void *) fspr_palloc_debug(fspr_pool_t *pool, fspr_size_t size, const char *file_line) { void *mem; - apr_pool_check_integrity(pool); + fspr_pool_check_integrity(pool); mem = pool_alloc(pool, size); #if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALLOC) - apr_pool_log_event(pool, "PALLOC", file_line, 1); + fspr_pool_log_event(pool, "PALLOC", file_line, 1); #endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALLOC) */ return mem; } -APR_DECLARE(void *) apr_pcalloc_debug(apr_pool_t *pool, apr_size_t size, +APR_DECLARE(void *) fspr_pcalloc_debug(fspr_pool_t *pool, fspr_size_t size, const char *file_line) { void *mem; - apr_pool_check_integrity(pool); + fspr_pool_check_integrity(pool); mem = pool_alloc(pool, size); memset(mem, 0, size); #if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALLOC) - apr_pool_log_event(pool, "PCALLOC", file_line, 1); + fspr_pool_log_event(pool, "PCALLOC", file_line, 1); #endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALLOC) */ return mem; @@ -1423,10 +1423,10 @@ APR_DECLARE(void *) apr_pcalloc_debug(apr_pool_t *pool, apr_size_t size, #define POOL_POISON_BYTE 'A' -static void pool_clear_debug(apr_pool_t *pool, const char *file_line) +static void pool_clear_debug(fspr_pool_t *pool, const char *file_line) { debug_node_t *node; - apr_uint32_t index; + fspr_uint32_t index; /* Destroy the subpools. The subpools will detach themselves from * this pool thus this loop is safe and easy. @@ -1469,17 +1469,17 @@ static void pool_clear_debug(apr_pool_t *pool, const char *file_line) pool->stat_clear++; } -APR_DECLARE(void) apr_pool_clear_debug(apr_pool_t *pool, +APR_DECLARE(void) fspr_pool_clear_debug(fspr_pool_t *pool, const char *file_line) { #if APR_HAS_THREADS - apr_thread_mutex_t *mutex = NULL; + fspr_thread_mutex_t *mutex = NULL; #endif - apr_pool_check_integrity(pool); + fspr_pool_check_integrity(pool); #if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE) - apr_pool_log_event(pool, "CLEAR", file_line, 1); + fspr_pool_log_event(pool, "CLEAR", file_line, 1); #endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE) */ #if APR_HAS_THREADS @@ -1487,11 +1487,11 @@ APR_DECLARE(void) apr_pool_clear_debug(apr_pool_t *pool, mutex = pool->parent->mutex; /* Lock the parent mutex before clearing so that if we have our - * own mutex it won't be accessed by apr_pool_walk_tree after + * own mutex it won't be accessed by fspr_pool_walk_tree after * it has been destroyed. */ if (mutex != NULL && mutex != pool->mutex) { - apr_thread_mutex_lock(mutex); + fspr_thread_mutex_lock(mutex); } #endif @@ -1503,21 +1503,21 @@ APR_DECLARE(void) apr_pool_clear_debug(apr_pool_t *pool, * the mutex we obtained above. */ if (mutex != pool->mutex) { - (void)apr_thread_mutex_create(&pool->mutex, + (void)fspr_thread_mutex_create(&pool->mutex, APR_THREAD_MUTEX_NESTED, pool); if (mutex != NULL) - (void)apr_thread_mutex_unlock(mutex); + (void)fspr_thread_mutex_unlock(mutex); } #endif /* APR_HAS_THREADS */ } -static void pool_destroy_debug(apr_pool_t *pool, const char *file_line) +static void pool_destroy_debug(fspr_pool_t *pool, const char *file_line) { - apr_pool_check_integrity(pool); + fspr_pool_check_integrity(pool); #if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE) - apr_pool_log_event(pool, "DESTROY", file_line, 1); + fspr_pool_log_event(pool, "DESTROY", file_line, 1); #endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE) */ pool_clear_debug(pool, file_line); @@ -1525,10 +1525,10 @@ static void pool_destroy_debug(apr_pool_t *pool, const char *file_line) /* Remove the pool from the parents child list */ if (pool->parent) { #if APR_HAS_THREADS - apr_thread_mutex_t *mutex; + fspr_thread_mutex_t *mutex; if ((mutex = pool->parent->mutex) != NULL) - apr_thread_mutex_lock(mutex); + fspr_thread_mutex_lock(mutex); #endif /* APR_HAS_THREADS */ if ((*pool->ref = pool->sibling) != NULL) @@ -1536,28 +1536,28 @@ static void pool_destroy_debug(apr_pool_t *pool, const char *file_line) #if APR_HAS_THREADS if (mutex) - apr_thread_mutex_unlock(mutex); + fspr_thread_mutex_unlock(mutex); #endif /* APR_HAS_THREADS */ } if (pool->allocator != NULL - && apr_allocator_owner_get(pool->allocator) == pool) { - apr_allocator_destroy(pool->allocator); + && fspr_allocator_owner_get(pool->allocator) == pool) { + fspr_allocator_destroy(pool->allocator); } /* Free the pool itself */ free(pool); } -APR_DECLARE(void) apr_pool_destroy_debug(apr_pool_t *pool, +APR_DECLARE(void) fspr_pool_destroy_debug(fspr_pool_t *pool, const char *file_line) { if (pool->joined) { /* Joined pools must not be explicitly destroyed; the caller * has broken the guarantee. */ #if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) - apr_pool_log_event(pool, "LIFE", - __FILE__ ":apr_pool_destroy abort on joined", 0); + fspr_pool_log_event(pool, "LIFE", + __FILE__ ":fspr_pool_destroy abort on joined", 0); #endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) */ abort(); @@ -1565,13 +1565,13 @@ APR_DECLARE(void) apr_pool_destroy_debug(apr_pool_t *pool, pool_destroy_debug(pool, file_line); } -APR_DECLARE(apr_status_t) apr_pool_create_ex_debug(apr_pool_t **newpool, - apr_pool_t *parent, - apr_abortfunc_t abort_fn, - apr_allocator_t *allocator, +APR_DECLARE(fspr_status_t) fspr_pool_create_ex_debug(fspr_pool_t **newpool, + fspr_pool_t *parent, + fspr_abortfunc_t abort_fn, + fspr_allocator_t *allocator, const char *file_line) { - apr_pool_t *pool; + fspr_pool_t *pool; *newpool = NULL; @@ -1579,7 +1579,7 @@ APR_DECLARE(apr_status_t) apr_pool_create_ex_debug(apr_pool_t **newpool, parent = global_pool; } else { - apr_pool_check_integrity(parent); + fspr_pool_check_integrity(parent); if (!allocator) allocator = parent->allocator; @@ -1605,7 +1605,7 @@ APR_DECLARE(apr_status_t) apr_pool_create_ex_debug(apr_pool_t **newpool, if ((pool->parent = parent) != NULL) { #if APR_HAS_THREADS if (parent->mutex) - apr_thread_mutex_lock(parent->mutex); + fspr_thread_mutex_lock(parent->mutex); #endif /* APR_HAS_THREADS */ if ((pool->sibling = parent->child) != NULL) pool->sibling->ref = &pool->sibling; @@ -1615,7 +1615,7 @@ APR_DECLARE(apr_status_t) apr_pool_create_ex_debug(apr_pool_t **newpool, #if APR_HAS_THREADS if (parent->mutex) - apr_thread_mutex_unlock(parent->mutex); + fspr_thread_mutex_unlock(parent->mutex); #endif /* APR_HAS_THREADS */ } else { @@ -1624,26 +1624,26 @@ APR_DECLARE(apr_status_t) apr_pool_create_ex_debug(apr_pool_t **newpool, } #if APR_HAS_THREADS - pool->owner = apr_os_thread_current(); + pool->owner = fspr_os_thread_current(); #endif /* APR_HAS_THREADS */ #ifdef NETWARE - pool->owner_proc = (apr_os_proc_t)getnlmhandle(); + pool->owner_proc = (fspr_os_proc_t)getnlmhandle(); #endif /* defined(NETWARE) */ if (parent == NULL || parent->allocator != allocator) { #if APR_HAS_THREADS - apr_status_t rv; + fspr_status_t rv; /* No matter what the creation flags say, always create - * a lock. Without it integrity_check and apr_pool_num_bytes + * a lock. Without it integrity_check and fspr_pool_num_bytes * blow up (because they traverse pools child lists that * possibly belong to another thread, in combination with * the pool having no lock). However, this might actually * hide problems like creating a child pool of a pool * belonging to another thread. */ - if ((rv = apr_thread_mutex_create(&pool->mutex, + if ((rv = fspr_thread_mutex_create(&pool->mutex, APR_THREAD_MUTEX_NESTED, pool)) != APR_SUCCESS) { free(pool); return rv; @@ -1660,7 +1660,7 @@ APR_DECLARE(apr_status_t) apr_pool_create_ex_debug(apr_pool_t **newpool, *newpool = pool; #if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE) - apr_pool_log_event(pool, "CREATE", file_line, 1); + fspr_pool_log_event(pool, "CREATE", file_line, 1); #endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE) */ return APR_SUCCESS; @@ -1672,15 +1672,15 @@ APR_DECLARE(apr_status_t) apr_pool_create_ex_debug(apr_pool_t **newpool, */ struct psprintf_data { - apr_vformatter_buff_t vbuff; + fspr_vformatter_buff_t vbuff; char *mem; - apr_size_t size; + fspr_size_t size; }; -static int psprintf_flush(apr_vformatter_buff_t *vbuff) +static int psprintf_flush(fspr_vformatter_buff_t *vbuff) { struct psprintf_data *ps = (struct psprintf_data *)vbuff; - apr_size_t size; + fspr_size_t size; size = ps->vbuff.curpos - ps->mem; @@ -1694,12 +1694,12 @@ static int psprintf_flush(apr_vformatter_buff_t *vbuff) return 0; } -APR_DECLARE(char *) apr_pvsprintf(apr_pool_t *pool, const char *fmt, va_list ap) +APR_DECLARE(char *) fspr_pvsprintf(fspr_pool_t *pool, const char *fmt, va_list ap) { struct psprintf_data ps; debug_node_t *node; - apr_pool_check_integrity(pool); + fspr_pool_check_integrity(pool); ps.size = 64; ps.mem = malloc(ps.size); @@ -1708,7 +1708,7 @@ APR_DECLARE(char *) apr_pvsprintf(apr_pool_t *pool, const char *fmt, va_list ap) /* Save a byte for the NUL terminator */ ps.vbuff.endpos = ps.mem + ps.size - 1; - if (apr_vformatter(psprintf_flush, &ps.vbuff, fmt, ap) == -1) { + if (fspr_vformatter(psprintf_flush, &ps.vbuff, fmt, ap) == -1) { if (pool->abort_fn) pool->abort_fn(APR_ENOMEM); @@ -1746,7 +1746,7 @@ APR_DECLARE(char *) apr_pvsprintf(apr_pool_t *pool, const char *fmt, va_list ap) * Debug functions */ -APR_DECLARE(void) apr_pool_join(apr_pool_t *p, apr_pool_t *sub) +APR_DECLARE(void) fspr_pool_join(fspr_pool_t *p, fspr_pool_t *sub) { #if APR_POOL_DEBUG if (sub->parent != p) { @@ -1756,11 +1756,11 @@ APR_DECLARE(void) apr_pool_join(apr_pool_t *p, apr_pool_t *sub) #endif } -static int pool_find(apr_pool_t *pool, void *data) +static int pool_find(fspr_pool_t *pool, void *data) { void **pmem = (void **)data; debug_node_t *node; - apr_uint32_t index; + fspr_uint32_t index; node = pool->nodes; @@ -1779,21 +1779,21 @@ static int pool_find(apr_pool_t *pool, void *data) return 0; } -APR_DECLARE(apr_pool_t *) apr_pool_find(const void *mem) +APR_DECLARE(fspr_pool_t *) fspr_pool_find(const void *mem) { void *pool = (void *)mem; - if (apr_pool_walk_tree(global_pool, pool_find, &pool)) + if (fspr_pool_walk_tree(global_pool, pool_find, &pool)) return pool; return NULL; } -static int pool_num_bytes(apr_pool_t *pool, void *data) +static int pool_num_bytes(fspr_pool_t *pool, void *data) { - apr_size_t *psize = (apr_size_t *)data; + fspr_size_t *psize = (fspr_size_t *)data; debug_node_t *node; - apr_uint32_t index; + fspr_uint32_t index; node = pool->nodes; @@ -1808,9 +1808,9 @@ static int pool_num_bytes(apr_pool_t *pool, void *data) return 0; } -APR_DECLARE(apr_size_t) apr_pool_num_bytes(apr_pool_t *pool, int recurse) +APR_DECLARE(fspr_size_t) fspr_pool_num_bytes(fspr_pool_t *pool, int recurse) { - apr_size_t size = 0; + fspr_size_t size = 0; if (!recurse) { pool_num_bytes(pool, &size); @@ -1818,12 +1818,12 @@ APR_DECLARE(apr_size_t) apr_pool_num_bytes(apr_pool_t *pool, int recurse) return size; } - apr_pool_walk_tree(pool, pool_num_bytes, &size); + fspr_pool_walk_tree(pool, pool_num_bytes, &size); return size; } -APR_DECLARE(void) apr_pool_lock(apr_pool_t *pool, int flag) +APR_DECLARE(void) fspr_pool_lock(fspr_pool_t *pool, int flag) { } @@ -1832,12 +1832,12 @@ APR_DECLARE(void) apr_pool_lock(apr_pool_t *pool, int flag) #ifdef NETWARE void netware_pool_proc_cleanup () { - apr_pool_t *pool = global_pool->child; - apr_os_proc_t owner_proc = (apr_os_proc_t)getnlmhandle(); + fspr_pool_t *pool = global_pool->child; + fspr_os_proc_t owner_proc = (fspr_os_proc_t)getnlmhandle(); while (pool) { if (pool->owner_proc == owner_proc) { - apr_pool_destroy (pool); + fspr_pool_destroy (pool); pool = global_pool->child; } else { @@ -1853,13 +1853,13 @@ void netware_pool_proc_cleanup () * "Print" functions (common) */ -APR_DECLARE_NONSTD(char *) apr_psprintf(apr_pool_t *p, const char *fmt, ...) +APR_DECLARE_NONSTD(char *) fspr_psprintf(fspr_pool_t *p, const char *fmt, ...) { va_list ap; char *res; va_start(ap, fmt); - res = apr_pvsprintf(p, fmt, ap); + res = fspr_pvsprintf(p, fmt, ap); va_end(ap); return res; } @@ -1868,18 +1868,18 @@ APR_DECLARE_NONSTD(char *) apr_psprintf(apr_pool_t *p, const char *fmt, ...) * Pool Properties */ -APR_DECLARE(void) apr_pool_abort_set(apr_abortfunc_t abort_fn, - apr_pool_t *pool) +APR_DECLARE(void) fspr_pool_abort_set(fspr_abortfunc_t abort_fn, + fspr_pool_t *pool) { pool->abort_fn = abort_fn; } -APR_DECLARE(apr_abortfunc_t) apr_pool_abort_get(apr_pool_t *pool) +APR_DECLARE(fspr_abortfunc_t) fspr_pool_abort_get(fspr_pool_t *pool) { return pool->abort_fn; } -APR_DECLARE(apr_pool_t *) apr_pool_parent_get(apr_pool_t *pool) +APR_DECLARE(fspr_pool_t *) fspr_pool_parent_get(fspr_pool_t *pool) { #ifdef NETWARE /* On NetWare, don't return the global_pool, return the application pool @@ -1891,7 +1891,7 @@ APR_DECLARE(apr_pool_t *) apr_pool_parent_get(apr_pool_t *pool) return pool->parent; } -APR_DECLARE(apr_allocator_t *) apr_pool_allocator_get(apr_pool_t *pool) +APR_DECLARE(fspr_allocator_t *) fspr_pool_allocator_get(fspr_pool_t *pool) { return pool->allocator; } @@ -1899,7 +1899,7 @@ APR_DECLARE(apr_allocator_t *) apr_pool_allocator_get(apr_pool_t *pool) /* return TRUE if a is an ancestor of b * NULL is considered an ancestor of all pools */ -APR_DECLARE(int) apr_pool_is_ancestor(apr_pool_t *a, apr_pool_t *b) +APR_DECLARE(int) fspr_pool_is_ancestor(fspr_pool_t *a, fspr_pool_t *b) { if (a == NULL) return 1; @@ -1922,7 +1922,7 @@ APR_DECLARE(int) apr_pool_is_ancestor(apr_pool_t *a, apr_pool_t *b) return 0; } -APR_DECLARE(const char *) apr_pool_tag(apr_pool_t *pool, const char *tag) +APR_DECLARE(const char *) fspr_pool_tag(fspr_pool_t *pool, const char *tag) { if (tag) { pool->tag = tag; @@ -1936,63 +1936,63 @@ APR_DECLARE(const char *) apr_pool_tag(apr_pool_t *pool, const char *tag) * User data management */ -APR_DECLARE(apr_status_t) apr_pool_userdata_set(const void *data, const char *key, - apr_status_t (*cleanup) (void *), - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_pool_userdata_set(const void *data, const char *key, + fspr_status_t (*cleanup) (void *), + fspr_pool_t *pool) { #if APR_POOL_DEBUG - apr_pool_check_integrity(pool); + fspr_pool_check_integrity(pool); #endif /* APR_POOL_DEBUG */ if (pool->user_data == NULL) - pool->user_data = apr_hash_make(pool); + pool->user_data = fspr_hash_make(pool); - if (apr_hash_get(pool->user_data, key, APR_HASH_KEY_STRING) == NULL) { - char *new_key = apr_pstrdup(pool, key); - apr_hash_set(pool->user_data, new_key, APR_HASH_KEY_STRING, data); + if (fspr_hash_get(pool->user_data, key, APR_HASH_KEY_STRING) == NULL) { + char *new_key = fspr_pstrdup(pool, key); + fspr_hash_set(pool->user_data, new_key, APR_HASH_KEY_STRING, data); } else { - apr_hash_set(pool->user_data, key, APR_HASH_KEY_STRING, data); + fspr_hash_set(pool->user_data, key, APR_HASH_KEY_STRING, data); } if (cleanup) - apr_pool_cleanup_register(pool, data, cleanup, cleanup); + fspr_pool_cleanup_register(pool, data, cleanup, cleanup); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_pool_userdata_setn(const void *data, +APR_DECLARE(fspr_status_t) fspr_pool_userdata_setn(const void *data, const char *key, - apr_status_t (*cleanup)(void *), - apr_pool_t *pool) + fspr_status_t (*cleanup)(void *), + fspr_pool_t *pool) { #if APR_POOL_DEBUG - apr_pool_check_integrity(pool); + fspr_pool_check_integrity(pool); #endif /* APR_POOL_DEBUG */ if (pool->user_data == NULL) - pool->user_data = apr_hash_make(pool); + pool->user_data = fspr_hash_make(pool); - apr_hash_set(pool->user_data, key, APR_HASH_KEY_STRING, data); + fspr_hash_set(pool->user_data, key, APR_HASH_KEY_STRING, data); if (cleanup) - apr_pool_cleanup_register(pool, data, cleanup, cleanup); + fspr_pool_cleanup_register(pool, data, cleanup, cleanup); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_pool_userdata_get(void **data, const char *key, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_pool_userdata_get(void **data, const char *key, + fspr_pool_t *pool) { #if APR_POOL_DEBUG - apr_pool_check_integrity(pool); + fspr_pool_check_integrity(pool); #endif /* APR_POOL_DEBUG */ if (pool->user_data == NULL) { *data = NULL; } else { - *data = apr_hash_get(pool->user_data, key, APR_HASH_KEY_STRING); + *data = fspr_hash_get(pool->user_data, key, APR_HASH_KEY_STRING); } return APR_SUCCESS; @@ -2006,18 +2006,18 @@ APR_DECLARE(apr_status_t) apr_pool_userdata_get(void **data, const char *key, struct cleanup_t { struct cleanup_t *next; const void *data; - apr_status_t (*plain_cleanup_fn)(void *data); - apr_status_t (*child_cleanup_fn)(void *data); + fspr_status_t (*plain_cleanup_fn)(void *data); + fspr_status_t (*child_cleanup_fn)(void *data); }; -APR_DECLARE(void) apr_pool_cleanup_register(apr_pool_t *p, const void *data, - apr_status_t (*plain_cleanup_fn)(void *data), - apr_status_t (*child_cleanup_fn)(void *data)) +APR_DECLARE(void) fspr_pool_cleanup_register(fspr_pool_t *p, const void *data, + fspr_status_t (*plain_cleanup_fn)(void *data), + fspr_status_t (*child_cleanup_fn)(void *data)) { cleanup_t *c; #if APR_POOL_DEBUG - apr_pool_check_integrity(p); + fspr_pool_check_integrity(p); #endif /* APR_POOL_DEBUG */ if (p != NULL) { @@ -2026,7 +2026,7 @@ APR_DECLARE(void) apr_pool_cleanup_register(apr_pool_t *p, const void *data, c = p->free_cleanups; p->free_cleanups = c->next; } else { - c = apr_palloc(p, sizeof(cleanup_t)); + c = fspr_palloc(p, sizeof(cleanup_t)); } c->data = data; c->plain_cleanup_fn = plain_cleanup_fn; @@ -2036,13 +2036,13 @@ APR_DECLARE(void) apr_pool_cleanup_register(apr_pool_t *p, const void *data, } } -APR_DECLARE(void) apr_pool_cleanup_kill(apr_pool_t *p, const void *data, - apr_status_t (*cleanup_fn)(void *)) +APR_DECLARE(void) fspr_pool_cleanup_kill(fspr_pool_t *p, const void *data, + fspr_status_t (*cleanup_fn)(void *)) { cleanup_t *c, **lastp; #if APR_POOL_DEBUG - apr_pool_check_integrity(p); + fspr_pool_check_integrity(p); #endif /* APR_POOL_DEBUG */ if (p == NULL) @@ -2069,14 +2069,14 @@ APR_DECLARE(void) apr_pool_cleanup_kill(apr_pool_t *p, const void *data, } } -APR_DECLARE(void) apr_pool_child_cleanup_set(apr_pool_t *p, const void *data, - apr_status_t (*plain_cleanup_fn)(void *), - apr_status_t (*child_cleanup_fn)(void *)) +APR_DECLARE(void) fspr_pool_child_cleanup_set(fspr_pool_t *p, const void *data, + fspr_status_t (*plain_cleanup_fn)(void *), + fspr_status_t (*child_cleanup_fn)(void *)) { cleanup_t *c; #if APR_POOL_DEBUG - apr_pool_check_integrity(p); + fspr_pool_check_integrity(p); #endif /* APR_POOL_DEBUG */ if (p == NULL) @@ -2093,10 +2093,10 @@ APR_DECLARE(void) apr_pool_child_cleanup_set(apr_pool_t *p, const void *data, } } -APR_DECLARE(apr_status_t) apr_pool_cleanup_run(apr_pool_t *p, void *data, - apr_status_t (*cleanup_fn)(void *)) +APR_DECLARE(fspr_status_t) fspr_pool_cleanup_run(fspr_pool_t *p, void *data, + fspr_status_t (*cleanup_fn)(void *)) { - apr_pool_cleanup_kill(p, data, cleanup_fn); + fspr_pool_cleanup_kill(p, data, cleanup_fn); return (*cleanup_fn)(data); } @@ -2122,7 +2122,7 @@ static void run_child_cleanups(cleanup_t **cref) } } -static void cleanup_pool_for_exec(apr_pool_t *p) +static void cleanup_pool_for_exec(fspr_pool_t *p) { run_child_cleanups(&p->cleanups); @@ -2130,7 +2130,7 @@ static void cleanup_pool_for_exec(apr_pool_t *p) cleanup_pool_for_exec(p); } -APR_DECLARE(void) apr_pool_cleanup_for_exec(void) +APR_DECLARE(void) fspr_pool_cleanup_for_exec(void) { #if !defined(WIN32) && !defined(OS2) /* @@ -2146,7 +2146,7 @@ APR_DECLARE(void) apr_pool_cleanup_for_exec(void) #endif /* !defined(WIN32) && !defined(OS2) */ } -APR_DECLARE_NONSTD(apr_status_t) apr_pool_cleanup_null(void *data) +APR_DECLARE_NONSTD(fspr_status_t) fspr_pool_cleanup_null(void *data) { /* do nothing cleanup routine */ return APR_SUCCESS; @@ -2159,10 +2159,10 @@ APR_DECLARE_NONSTD(apr_status_t) apr_pool_cleanup_null(void *data) * we might want to fold support for that into the generic interface. * For now, it's a special case. */ -APR_DECLARE(void) apr_pool_note_subprocess(apr_pool_t *pool, apr_proc_t *proc, - apr_kill_conditions_e how) +APR_DECLARE(void) fspr_pool_note_subprocess(fspr_pool_t *pool, fspr_proc_t *proc, + fspr_kill_conditions_e how) { - struct process_chain *pc = apr_palloc(pool, sizeof(struct process_chain)); + struct process_chain *pc = fspr_palloc(pool, sizeof(struct process_chain)); pc->proc = proc; pc->kill_how = how; @@ -2178,7 +2178,7 @@ static void free_proc_chain(struct process_chain *procs) */ struct process_chain *pc; int need_timeout = 0; - apr_time_t timeout_interval; + fspr_time_t timeout_interval; if (!procs) return; /* No work. Whew! */ @@ -2193,7 +2193,7 @@ static void free_proc_chain(struct process_chain *procs) #ifndef NEED_WAITPID /* Pick up all defunct processes */ for (pc = procs; pc; pc = pc->next) { - if (apr_proc_wait(pc->proc, NULL, NULL, APR_NOWAIT) != APR_CHILD_NOTDONE) + if (fspr_proc_wait(pc->proc, NULL, NULL, APR_NOWAIT) != APR_CHILD_NOTDONE) pc->kill_how = APR_KILL_NEVER; } #endif /* !defined(NEED_WAITPID) */ @@ -2204,11 +2204,11 @@ static void free_proc_chain(struct process_chain *procs) || (pc->kill_how == APR_KILL_ONLY_ONCE)) { /* * Subprocess may be dead already. Only need the timeout if not. - * Note: apr_proc_kill on Windows is TerminateProcess(), which is + * Note: fspr_proc_kill on Windows is TerminateProcess(), which is * similar to a SIGKILL, so always give the process a timeout * under Windows before killing it. */ - if (apr_proc_kill(pc->proc, SIGTERM) == APR_SUCCESS) + if (fspr_proc_kill(pc->proc, SIGTERM) == APR_SUCCESS) need_timeout = 1; } else if (pc->kill_how == APR_KILL_ALWAYS) { @@ -2217,7 +2217,7 @@ static void free_proc_chain(struct process_chain *procs) need_timeout = 1; pc->kill_how = APR_KILL_ALWAYS; #endif - apr_proc_kill(pc->proc, SIGKILL); + fspr_proc_kill(pc->proc, SIGKILL); } } @@ -2227,14 +2227,14 @@ static void free_proc_chain(struct process_chain *procs) */ if (need_timeout) { timeout_interval = TIMEOUT_INTERVAL; - apr_sleep(timeout_interval); + fspr_sleep(timeout_interval); do { /* check the status of the subprocesses */ need_timeout = 0; for (pc = procs; pc; pc = pc->next) { if (pc->kill_how == APR_KILL_AFTER_TIMEOUT) { - if (apr_proc_wait(pc->proc, NULL, NULL, APR_NOWAIT) + if (fspr_proc_wait(pc->proc, NULL, NULL, APR_NOWAIT) == APR_CHILD_NOTDONE) need_timeout = 1; /* subprocess is still active */ else @@ -2245,7 +2245,7 @@ static void free_proc_chain(struct process_chain *procs) if (timeout_interval >= TIMEOUT_USECS) { break; } - apr_sleep(timeout_interval); + fspr_sleep(timeout_interval); timeout_interval *= 2; } } while (need_timeout); @@ -2257,13 +2257,13 @@ static void free_proc_chain(struct process_chain *procs) */ for (pc = procs; pc; pc = pc->next) { if (pc->kill_how == APR_KILL_AFTER_TIMEOUT) - apr_proc_kill(pc->proc, SIGKILL); + fspr_proc_kill(pc->proc, SIGKILL); } /* Now wait for all the signaled processes to die */ for (pc = procs; pc; pc = pc->next) { if (pc->kill_how != APR_KILL_NEVER) - (void)apr_proc_wait(pc->proc, NULL, NULL, APR_WAIT); + (void)fspr_proc_wait(pc->proc, NULL, NULL, APR_WAIT); } } @@ -2274,85 +2274,85 @@ static void free_proc_chain(struct process_chain *procs) */ #if !APR_POOL_DEBUG -APR_DECLARE(void *) apr_palloc_debug(apr_pool_t *pool, apr_size_t size, +APR_DECLARE(void *) fspr_palloc_debug(fspr_pool_t *pool, fspr_size_t size, const char *file_line) { - return apr_palloc(pool, size); + return fspr_palloc(pool, size); } -APR_DECLARE(void *) apr_pcalloc_debug(apr_pool_t *pool, apr_size_t size, +APR_DECLARE(void *) fspr_pcalloc_debug(fspr_pool_t *pool, fspr_size_t size, const char *file_line) { - return apr_pcalloc(pool, size); + return fspr_pcalloc(pool, size); } -APR_DECLARE(void) apr_pool_clear_debug(apr_pool_t *pool, +APR_DECLARE(void) fspr_pool_clear_debug(fspr_pool_t *pool, const char *file_line) { - apr_pool_clear(pool); + fspr_pool_clear(pool); } -APR_DECLARE(void) apr_pool_destroy_debug(apr_pool_t *pool, +APR_DECLARE(void) fspr_pool_destroy_debug(fspr_pool_t *pool, const char *file_line) { - apr_pool_destroy(pool); + fspr_pool_destroy(pool); } -APR_DECLARE(apr_status_t) apr_pool_create_ex_debug(apr_pool_t **newpool, - apr_pool_t *parent, - apr_abortfunc_t abort_fn, - apr_allocator_t *allocator, +APR_DECLARE(fspr_status_t) fspr_pool_create_ex_debug(fspr_pool_t **newpool, + fspr_pool_t *parent, + fspr_abortfunc_t abort_fn, + fspr_allocator_t *allocator, const char *file_line) { - return apr_pool_create_ex(newpool, parent, abort_fn, allocator); + return fspr_pool_create_ex(newpool, parent, abort_fn, allocator); } #else /* APR_POOL_DEBUG */ -#undef apr_palloc -APR_DECLARE(void *) apr_palloc(apr_pool_t *pool, apr_size_t size); +#undef fspr_palloc +APR_DECLARE(void *) fspr_palloc(fspr_pool_t *pool, fspr_size_t size); -APR_DECLARE(void *) apr_palloc(apr_pool_t *pool, apr_size_t size) +APR_DECLARE(void *) fspr_palloc(fspr_pool_t *pool, fspr_size_t size) { - return apr_palloc_debug(pool, size, "undefined"); + return fspr_palloc_debug(pool, size, "undefined"); } -#undef apr_pcalloc -APR_DECLARE(void *) apr_pcalloc(apr_pool_t *pool, apr_size_t size); +#undef fspr_pcalloc +APR_DECLARE(void *) fspr_pcalloc(fspr_pool_t *pool, fspr_size_t size); -APR_DECLARE(void *) apr_pcalloc(apr_pool_t *pool, apr_size_t size) +APR_DECLARE(void *) fspr_pcalloc(fspr_pool_t *pool, fspr_size_t size) { - return apr_pcalloc_debug(pool, size, "undefined"); + return fspr_pcalloc_debug(pool, size, "undefined"); } -#undef apr_pool_clear -APR_DECLARE(void) apr_pool_clear(apr_pool_t *pool); +#undef fspr_pool_clear +APR_DECLARE(void) fspr_pool_clear(fspr_pool_t *pool); -APR_DECLARE(void) apr_pool_clear(apr_pool_t *pool) +APR_DECLARE(void) fspr_pool_clear(fspr_pool_t *pool) { - apr_pool_clear_debug(pool, "undefined"); + fspr_pool_clear_debug(pool, "undefined"); } -#undef apr_pool_destroy -APR_DECLARE(void) apr_pool_destroy(apr_pool_t *pool); +#undef fspr_pool_destroy +APR_DECLARE(void) fspr_pool_destroy(fspr_pool_t *pool); -APR_DECLARE(void) apr_pool_destroy(apr_pool_t *pool) +APR_DECLARE(void) fspr_pool_destroy(fspr_pool_t *pool) { - apr_pool_destroy_debug(pool, "undefined"); + fspr_pool_destroy_debug(pool, "undefined"); } -#undef apr_pool_create_ex -APR_DECLARE(apr_status_t) apr_pool_create_ex(apr_pool_t **newpool, - apr_pool_t *parent, - apr_abortfunc_t abort_fn, - apr_allocator_t *allocator); +#undef fspr_pool_create_ex +APR_DECLARE(fspr_status_t) fspr_pool_create_ex(fspr_pool_t **newpool, + fspr_pool_t *parent, + fspr_abortfunc_t abort_fn, + fspr_allocator_t *allocator); -APR_DECLARE(apr_status_t) apr_pool_create_ex(apr_pool_t **newpool, - apr_pool_t *parent, - apr_abortfunc_t abort_fn, - apr_allocator_t *allocator) +APR_DECLARE(fspr_status_t) fspr_pool_create_ex(fspr_pool_t **newpool, + fspr_pool_t *parent, + fspr_abortfunc_t abort_fn, + fspr_allocator_t *allocator) { - return apr_pool_create_ex_debug(newpool, parent, + return fspr_pool_create_ex_debug(newpool, parent, abort_fn, allocator, "undefined"); } diff --git a/libs/apr/misc/netware/charset.c b/libs/apr/misc/netware/charset.c index b79add10b5..f8f376d86b 100644 --- a/libs/apr/misc/netware/charset.c +++ b/libs/apr/misc/netware/charset.c @@ -14,21 +14,21 @@ * limitations under the License. */ -#include "apr.h" -#include "apr_strings.h" -#include "apr_portable.h" +#include "fspr.h" +#include "fspr_strings.h" +#include "fspr_portable.h" /* static struct utsname sysinfo; */ /* XXX This needs to be fixed to produce the correct system language */ -APR_DECLARE(const char*) apr_os_default_encoding (apr_pool_t *pool) +APR_DECLARE(const char*) fspr_os_default_encoding (fspr_pool_t *pool) { - return apr_pstrdup(pool, "CP1252"); + return fspr_pstrdup(pool, "CP1252"); } -APR_DECLARE(const char*) apr_os_locale_encoding (apr_pool_t *pool) +APR_DECLARE(const char*) fspr_os_locale_encoding (fspr_pool_t *pool) { - return apr_os_default_encoding(pool); + return fspr_os_default_encoding(pool); } diff --git a/libs/apr/misc/netware/libprews.c b/libs/apr/misc/netware/libprews.c index 624bf22cfa..11fec7e7bc 100644 --- a/libs/apr/misc/netware/libprews.c +++ b/libs/apr/misc/netware/libprews.c @@ -20,8 +20,8 @@ #include "novsock2.h" #endif -#include "apr_pools.h" -#include "apr_private.h" +#include "fspr_pools.h" +#include "fspr_private.h" /* library-private data...*/ @@ -51,7 +51,7 @@ int _NonAppStart #ifdef USE_WINSOCK WSADATA wsaData; #endif - apr_status_t status; + fspr_status_t status; NX_LOCK_INFO_ALLOC(liblock, "Per-Application Data Lock", 0); @@ -83,9 +83,9 @@ int _NonAppStart return -1; } - apr_netware_setup_time(); + fspr_netware_setup_time(); - if ((status = apr_pool_initialize()) != APR_SUCCESS) + if ((status = fspr_pool_initialize()) != APR_SUCCESS) return status; #ifdef USE_WINSOCK @@ -97,7 +97,7 @@ int _NonAppStart void _NonAppStop( void ) { - apr_pool_terminate(); + fspr_pool_terminate(); #ifdef USE_WINSOCK WSACleanup(); diff --git a/libs/apr/misc/netware/rand.c b/libs/apr/misc/netware/rand.c index a2baae7ecd..f9bee2153a 100644 --- a/libs/apr/misc/netware/rand.c +++ b/libs/apr/misc/netware/rand.c @@ -15,9 +15,9 @@ */ #define APR_WANT_MEMFUNC -#include "apr_want.h" -#include "apr_general.h" -#include "apr_private.h" +#include "fspr_want.h" +#include "fspr_general.h" +#include "fspr_private.h" #if APR_HAS_RANDOM @@ -56,8 +56,8 @@ static int NXSeedRandomInternal( size_t width, void *seed ) return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_generate_random_bytes(unsigned char *buf, - apr_size_t length) +APR_DECLARE(fspr_status_t) fspr_generate_random_bytes(unsigned char *buf, + fspr_size_t length) { if (NXSeedRandom(length, buf) != 0) { return NXSeedRandomInternal (length, buf); diff --git a/libs/apr/misc/netware/start.c b/libs/apr/misc/netware/start.c index c8ccc1c1c4..7636b2beea 100644 --- a/libs/apr/misc/netware/start.c +++ b/libs/apr/misc/netware/start.c @@ -14,14 +14,14 @@ * limitations under the License. */ -#include "apr.h" -#include "apr_general.h" -#include "apr_pools.h" -#include "apr_signal.h" +#include "fspr.h" +#include "fspr_general.h" +#include "fspr_pools.h" +#include "fspr_signal.h" -#include "apr_arch_misc.h" /* for WSAHighByte / WSALowByte */ -#include "apr_arch_proc_mutex.h" /* for apr_proc_mutex_unix_setup_lock() */ -#include "apr_arch_internal_time.h" +#include "fspr_arch_misc.h" /* for WSAHighByte / WSALowByte */ +#include "fspr_arch_proc_mutex.h" /* for fspr_proc_mutex_unix_setup_lock() */ +#include "fspr_arch_internal_time.h" #ifdef USE_WINSOCK /* @@ -108,7 +108,7 @@ static int RegisterAppWithWinSock (void *nlm_handle) -APR_DECLARE(apr_status_t) apr_app_initialize(int *argc, +APR_DECLARE(fspr_status_t) fspr_app_initialize(int *argc, const char * const * *argv, const char * const * *env) { @@ -117,12 +117,12 @@ APR_DECLARE(apr_status_t) apr_app_initialize(int *argc, * control manager into the process, and it's required to fix the char* * data passed in from win32 unicode into utf-8, win32's apr internal fmt. */ - return apr_initialize(); + return fspr_initialize(); } -APR_DECLARE(apr_status_t) apr_initialize(void) +APR_DECLARE(fspr_status_t) fspr_initialize(void) { - apr_pool_t *pool; + fspr_pool_t *pool; int err; void *nlmhandle = getnlmhandle(); @@ -132,15 +132,15 @@ APR_DECLARE(apr_status_t) apr_initialize(void) return APR_SUCCESS; } - /* apr_pool_initialize() is being called from the library + /* fspr_pool_initialize() is being called from the library startup code since all of the memory resources belong to the library rather than the application. */ - if (apr_pool_create(&pool, NULL) != APR_SUCCESS) { + if (fspr_pool_create(&pool, NULL) != APR_SUCCESS) { return APR_ENOPOOL; } - apr_pool_tag(pool, "apr_initilialize"); + fspr_pool_tag(pool, "fspr_initilialize"); #ifdef USE_WINSOCK err = RegisterAppWithWinSock (nlmhandle); @@ -150,12 +150,12 @@ APR_DECLARE(apr_status_t) apr_initialize(void) } #endif - apr_signal_init(pool); + fspr_signal_init(pool); return APR_SUCCESS; } -APR_DECLARE_NONSTD(void) apr_terminate(void) +APR_DECLARE_NONSTD(void) fspr_terminate(void) { APP_DATA *app_data; @@ -169,7 +169,7 @@ APR_DECLARE_NONSTD(void) apr_terminate(void) return; } - /* apr_pool_terminate() is being called from the + /* fspr_pool_terminate() is being called from the library shutdown code since the memory resources belong to the library rather than the application */ @@ -182,7 +182,7 @@ APR_DECLARE_NONSTD(void) apr_terminate(void) #endif } -APR_DECLARE(void) apr_terminate2(void) +APR_DECLARE(void) fspr_terminate2(void) { - apr_terminate(); + fspr_terminate(); } diff --git a/libs/apr/misc/unix/charset.c b/libs/apr/misc/unix/charset.c index a66724d720..02991a7d78 100644 --- a/libs/apr/misc/unix/charset.c +++ b/libs/apr/misc/unix/charset.c @@ -14,10 +14,10 @@ * limitations under the License. */ -#include "apr.h" -#include "apr_private.h" -#include "apr_strings.h" -#include "apr_portable.h" +#include "fspr.h" +#include "fspr_private.h" +#include "fspr_strings.h" +#include "fspr_portable.h" #ifdef HAVE_LANGINFO_H #include @@ -33,7 +33,7 @@ * unpacked. */ -APR_DECLARE(const char*) apr_os_default_encoding (apr_pool_t *pool) +APR_DECLARE(const char*) fspr_os_default_encoding (fspr_pool_t *pool) { #ifdef __MVS__ # ifdef __CODESET__ @@ -63,7 +63,7 @@ APR_DECLARE(const char*) apr_os_default_encoding (apr_pool_t *pool) } -APR_DECLARE(const char*) apr_os_locale_encoding (apr_pool_t *pool) +APR_DECLARE(const char*) fspr_os_locale_encoding (fspr_pool_t *pool) { #if defined(HAVE_NL_LANGINFO) && defined(CODESET) const char *charset; @@ -72,12 +72,12 @@ APR_DECLARE(const char*) apr_os_locale_encoding (apr_pool_t *pool) if (charset && *charset) { #ifdef _OSD_POSIX /* Bug workaround - delete as soon as fixed in OSD_POSIX */ /* Some versions of OSD_POSIX return nl_langinfo(CODESET)="^[nN]" */ - /* Ignore the bogus information and use apr_os_default_encoding() */ + /* Ignore the bogus information and use fspr_os_default_encoding() */ if (charset[0] != '^') #endif return charset; } #endif - return apr_os_default_encoding(pool); + return fspr_os_default_encoding(pool); } diff --git a/libs/apr/misc/unix/env.c b/libs/apr/misc/unix/env.c index 9ba6b61e78..37b64f107d 100644 --- a/libs/apr/misc/unix/env.c +++ b/libs/apr/misc/unix/env.c @@ -15,10 +15,10 @@ */ #define APR_WANT_STRFUNC -#include "apr_want.h" -#include "apr.h" -#include "apr_private.h" -#include "apr_env.h" +#include "fspr_want.h" +#include "fspr.h" +#include "fspr_private.h" +#include "fspr_env.h" #if APR_HAVE_UNISTD_H #include @@ -27,9 +27,9 @@ #include #endif -APR_DECLARE(apr_status_t) apr_env_get(char **value, +APR_DECLARE(fspr_status_t) fspr_env_get(char **value, const char *envvar, - apr_pool_t *pool) + fspr_pool_t *pool) { #ifdef HAVE_GETENV @@ -45,9 +45,9 @@ APR_DECLARE(apr_status_t) apr_env_get(char **value, } -APR_DECLARE(apr_status_t) apr_env_set(const char *envvar, +APR_DECLARE(fspr_status_t) fspr_env_set(const char *envvar, const char *value, - apr_pool_t *pool) + fspr_pool_t *pool) { #if defined(HAVE_SETENV) @@ -57,9 +57,9 @@ APR_DECLARE(apr_status_t) apr_env_set(const char *envvar, #elif defined(HAVE_PUTENV) - apr_size_t elen = strlen(envvar); - apr_size_t vlen = strlen(value); - char *env = apr_palloc(pool, elen + vlen + 2); + fspr_size_t elen = strlen(envvar); + fspr_size_t vlen = strlen(value); + char *env = fspr_palloc(pool, elen + vlen + 2); char *p = env + elen; memcpy(env, envvar, elen); @@ -77,7 +77,7 @@ APR_DECLARE(apr_status_t) apr_env_set(const char *envvar, } -APR_DECLARE(apr_status_t) apr_env_delete(const char *envvar, apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_env_delete(const char *envvar, fspr_pool_t *pool) { #ifdef HAVE_UNSETENV diff --git a/libs/apr/misc/unix/errorcodes.c b/libs/apr/misc/unix/errorcodes.c index e953d10927..3be0b25b93 100644 --- a/libs/apr/misc/unix/errorcodes.c +++ b/libs/apr/misc/unix/errorcodes.c @@ -14,10 +14,10 @@ * limitations under the License. */ -#include "apr_arch_misc.h" -#include "apr_strings.h" -#include "apr_lib.h" -#include "apr_dso.h" +#include "fspr_arch_misc.h" +#include "fspr_strings.h" +#include "fspr_lib.h" +#include "fspr_dso.h" #if APR_HAVE_NETDB_H #include @@ -27,16 +27,16 @@ #endif /* - * stuffbuffer - like apr_cpystrn() but returns the address of the + * stuffbuffer - like fspr_cpystrn() but returns the address of the * dest buffer instead of the address of the terminating '\0' */ -static char *stuffbuffer(char *buf, apr_size_t bufsize, const char *s) +static char *stuffbuffer(char *buf, fspr_size_t bufsize, const char *s) { - apr_cpystrn(buf,s,bufsize); + fspr_cpystrn(buf,s,bufsize); return buf; } -static char *apr_error_string(apr_status_t statcode) +static char *fspr_error_string(fspr_status_t statcode) { switch (statcode) { case APR_ENOPOOL: @@ -141,9 +141,9 @@ static char *apr_error_string(apr_status_t statcode) #ifdef OS2 #include -int apr_canonical_error(apr_status_t err); +int fspr_canonical_error(fspr_status_t err); -static char *apr_os_strerror(char* buf, apr_size_t bufsize, int err) +static char *fspr_os_strerror(char* buf, fspr_size_t bufsize, int err) { char result[200]; unsigned char message[HUGE_STRING_LEN]; @@ -153,7 +153,7 @@ static char *apr_os_strerror(char* buf, apr_size_t bufsize, int err) if (err >= 10000 && err < 12000) { /* socket error codes */ return stuffbuffer(buf, bufsize, - strerror(apr_canonical_error(err+APR_OS_START_SYSERR))); + strerror(fspr_canonical_error(err+APR_OS_START_SYSERR))); } else if (DosGetMessage(NULL, 0, message, HUGE_STRING_LEN, err, "OSO001.MSG", &len) == 0) { @@ -166,9 +166,9 @@ static char *apr_os_strerror(char* buf, apr_size_t bufsize, int err) for (c=0; ccont = cont; (*os)->reset = 0; - (*os)->errfn = (apr_getopt_err_fn_t*)(fprintf); + (*os)->errfn = (fspr_getopt_err_fn_t*)(fprintf); (*os)->errarg = (void*)(stderr); (*os)->place = EMSG; @@ -55,7 +55,7 @@ APR_DECLARE(apr_status_t) apr_getopt_init(apr_getopt_t **os, apr_pool_t *cont, that's the primary purpose of this function. But people might want to use this function with arrays other than the main argv, and we shouldn't touch the caller's data. So we copy. */ - argv_buff = apr_palloc(cont, (argc + 1) * sizeof(const char *)); + argv_buff = fspr_palloc(cont, (argc + 1) * sizeof(const char *)); memcpy(argv_buff, argv, argc * sizeof(const char *)); (*os)->argv = argv_buff; (*os)->argv[argc] = NULL; @@ -68,7 +68,7 @@ APR_DECLARE(apr_status_t) apr_getopt_init(apr_getopt_t **os, apr_pool_t *cont, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_getopt(apr_getopt_t *os, const char *opts, +APR_DECLARE(fspr_status_t) fspr_getopt(fspr_getopt_t *os, const char *opts, char *optch, const char **optarg) { const char *oli; /* option letter list index */ @@ -101,7 +101,7 @@ APR_DECLARE(apr_status_t) apr_getopt(apr_getopt_t *os, const char *opts, ++os->ind; if (os->errfn && *opts != ':') { (os->errfn)(os->errarg, "%s: illegal option -- %c\n", - apr_filepath_name_get(*os->argv), os->opt); + fspr_filepath_name_get(*os->argv), os->opt); } *optch = os->opt; return (APR_BADCH); @@ -123,7 +123,7 @@ APR_DECLARE(apr_status_t) apr_getopt(apr_getopt_t *os, const char *opts, if (os->errfn) { (os->errfn)(os->errarg, "%s: option requires an argument -- %c\n", - apr_filepath_name_get(*os->argv), os->opt); + fspr_filepath_name_get(*os->argv), os->opt); } *optch = os->opt; return (APR_BADCH); @@ -155,7 +155,7 @@ static void reverse(const char **argv, int start, int len) * non-option arguments, os->skip_end is where we stopped, and os->ind * is where we are now. */ -static void permute(apr_getopt_t *os) +static void permute(fspr_getopt_t *os) { int len1 = os->skip_end - os->skip_start; int len2 = os->ind - os->skip_end; @@ -178,27 +178,27 @@ static void permute(apr_getopt_t *os) } /* Helper function to print out an error involving a long option */ -static apr_status_t serr(apr_getopt_t *os, const char *err, const char *str, - apr_status_t status) +static fspr_status_t serr(fspr_getopt_t *os, const char *err, const char *str, + fspr_status_t status) { if (os->errfn) (os->errfn)(os->errarg, "%s: %s: %s\n", - apr_filepath_name_get(*os->argv), err, str); + fspr_filepath_name_get(*os->argv), err, str); return status; } /* Helper function to print out an error involving a short option */ -static apr_status_t cerr(apr_getopt_t *os, const char *err, int ch, - apr_status_t status) +static fspr_status_t cerr(fspr_getopt_t *os, const char *err, int ch, + fspr_status_t status) { if (os->errfn) (os->errfn)(os->errarg, "%s: %s: %c\n", - apr_filepath_name_get(*os->argv), err, ch); + fspr_filepath_name_get(*os->argv), err, ch); return status; } -APR_DECLARE(apr_status_t) apr_getopt_long(apr_getopt_t *os, - const apr_getopt_option_t *opts, +APR_DECLARE(fspr_status_t) fspr_getopt_long(fspr_getopt_t *os, + const fspr_getopt_option_t *opts, int *optch, const char **optarg) { const char *p; @@ -232,7 +232,7 @@ APR_DECLARE(apr_status_t) apr_getopt_long(apr_getopt_t *os, p = os->argv[os->ind++] + 1; if (*p == '-' && p[1] != '\0') { /* Long option */ /* Search for the long option name in the caller's table. */ - apr_size_t len = 0; + fspr_size_t len = 0; p++; for (i = 0; ; i++) { diff --git a/libs/apr/misc/unix/otherchild.c b/libs/apr/misc/unix/otherchild.c index c97cfdd644..147ff6b808 100644 --- a/libs/apr/misc/unix/otherchild.c +++ b/libs/apr/misc/unix/otherchild.c @@ -14,10 +14,10 @@ * limitations under the License. */ -#include "apr.h" -#include "apr_arch_misc.h" -#include "apr_arch_threadproc.h" -#include "apr_arch_file_io.h" +#include "fspr.h" +#include "fspr_arch_misc.h" +#include "fspr_arch_threadproc.h" +#include "fspr_arch_file_io.h" #if APR_HAS_OTHER_CHILD @@ -34,11 +34,11 @@ #include /* for fd_set definition! */ #endif -static apr_other_child_rec_t *other_children = NULL; +static fspr_other_child_rec_t *other_children = NULL; -static apr_status_t other_child_cleanup(void *data) +static fspr_status_t other_child_cleanup(void *data) { - apr_other_child_rec_t **pocr, *nocr; + fspr_other_child_rec_t **pocr, *nocr; for (pocr = &other_children; *pocr; pocr = &(*pocr)->next) { if ((*pocr)->data == data) { @@ -52,24 +52,24 @@ static apr_status_t other_child_cleanup(void *data) return APR_SUCCESS; } -APR_DECLARE(void) apr_proc_other_child_register(apr_proc_t *proc, +APR_DECLARE(void) fspr_proc_other_child_register(fspr_proc_t *proc, void (*maintenance) (int reason, void *, int status), - void *data, apr_file_t *write_fd, apr_pool_t *p) + void *data, fspr_file_t *write_fd, fspr_pool_t *p) { - apr_other_child_rec_t *ocr; + fspr_other_child_rec_t *ocr; - ocr = apr_palloc(p, sizeof(*ocr)); + ocr = fspr_palloc(p, sizeof(*ocr)); ocr->p = p; ocr->proc = proc; ocr->maintenance = maintenance; ocr->data = data; if (write_fd == NULL) { - ocr->write_fd = (apr_os_file_t) -1; + ocr->write_fd = (fspr_os_file_t) -1; } else { #ifdef WIN32 - /* This should either go away as part of eliminating apr_proc_probe_writable_fds - * or write_fd should point to an apr_file_t + /* This should either go away as part of eliminating fspr_proc_probe_writable_fds + * or write_fd should point to an fspr_file_t */ ocr->write_fd = write_fd->filehand; #else @@ -79,13 +79,13 @@ APR_DECLARE(void) apr_proc_other_child_register(apr_proc_t *proc, } ocr->next = other_children; other_children = ocr; - apr_pool_cleanup_register(p, ocr->data, other_child_cleanup, - apr_pool_cleanup_null); + fspr_pool_cleanup_register(p, ocr->data, other_child_cleanup, + fspr_pool_cleanup_null); } -APR_DECLARE(void) apr_proc_other_child_unregister(void *data) +APR_DECLARE(void) fspr_proc_other_child_unregister(void *data) { - apr_other_child_rec_t *cur; + fspr_other_child_rec_t *cur; cur = other_children; while (cur) { @@ -96,15 +96,15 @@ APR_DECLARE(void) apr_proc_other_child_unregister(void *data) } /* segfault if this function called with invalid parm */ - if (cur) apr_pool_cleanup_kill(cur->p, cur->data, other_child_cleanup); + if (cur) fspr_pool_cleanup_kill(cur->p, cur->data, other_child_cleanup); other_child_cleanup(data); } -APR_DECLARE(apr_status_t) apr_proc_other_child_alert(apr_proc_t *proc, +APR_DECLARE(fspr_status_t) fspr_proc_other_child_alert(fspr_proc_t *proc, int reason, int status) { - apr_other_child_rec_t *ocr, *nocr; + fspr_other_child_rec_t *ocr, *nocr; for (ocr = other_children; ocr; ocr = nocr) { nocr = ocr->next; @@ -118,7 +118,7 @@ APR_DECLARE(apr_status_t) apr_proc_other_child_alert(apr_proc_t *proc, return APR_EPROC_UNKNOWN; } -APR_DECLARE(void) apr_proc_other_child_refresh(apr_other_child_rec_t *ocr, +APR_DECLARE(void) fspr_proc_other_child_refresh(fspr_other_child_rec_t *ocr, int reason) { /* Todo: @@ -131,7 +131,7 @@ APR_DECLARE(void) apr_proc_other_child_refresh(apr_other_child_rec_t *ocr, return; if (!ocr->proc->hproc) { - /* Already mopped up, perhaps we apr_proc_kill'ed it, + /* Already mopped up, perhaps we fspr_proc_kill'ed it, * they should have already unregistered! */ ocr->proc = NULL; @@ -176,44 +176,44 @@ APR_DECLARE(void) apr_proc_other_child_refresh(apr_other_child_rec_t *ocr, #endif } -APR_DECLARE(void) apr_proc_other_child_refresh_all(int reason) +APR_DECLARE(void) fspr_proc_other_child_refresh_all(int reason) { - apr_other_child_rec_t *ocr, *next_ocr; + fspr_other_child_rec_t *ocr, *next_ocr; for (ocr = other_children; ocr; ocr = next_ocr) { next_ocr = ocr->next; - apr_proc_other_child_refresh(ocr, reason); + fspr_proc_other_child_refresh(ocr, reason); } } #else /* !APR_HAS_OTHER_CHILD */ -APR_DECLARE(void) apr_proc_other_child_register(apr_proc_t *proc, +APR_DECLARE(void) fspr_proc_other_child_register(fspr_proc_t *proc, void (*maintenance) (int reason, void *, int status), - void *data, apr_file_t *write_fd, apr_pool_t *p) + void *data, fspr_file_t *write_fd, fspr_pool_t *p) { return; } -APR_DECLARE(void) apr_proc_other_child_unregister(void *data) +APR_DECLARE(void) fspr_proc_other_child_unregister(void *data) { return; } -APR_DECLARE(apr_status_t) apr_proc_other_child_alert(apr_proc_t *proc, +APR_DECLARE(fspr_status_t) fspr_proc_other_child_alert(fspr_proc_t *proc, int reason, int status) { return APR_ENOTIMPL; } -APR_DECLARE(void) apr_proc_other_child_refresh(apr_other_child_rec_t *ocr, +APR_DECLARE(void) fspr_proc_other_child_refresh(fspr_other_child_rec_t *ocr, int reason) { return; } -APR_DECLARE(void) apr_proc_other_child_refresh_all(int reason) +APR_DECLARE(void) fspr_proc_other_child_refresh_all(int reason) { return; } diff --git a/libs/apr/misc/unix/rand.c b/libs/apr/misc/unix/rand.c index 7af77eb5af..d0b5cc1294 100644 --- a/libs/apr/misc/unix/rand.c +++ b/libs/apr/misc/unix/rand.c @@ -15,10 +15,10 @@ */ #define APR_WANT_MEMFUNC -#include "apr_want.h" -#include "apr_general.h" +#include "fspr_want.h" +#include "fspr_general.h" -#include "apr_arch_misc.h" +#include "fspr_arch_misc.h" #include #if APR_HAVE_SYS_TYPES_H #include @@ -51,7 +51,7 @@ #if defined(HAVE_UUID_CREATE) -APR_DECLARE(apr_status_t) apr_os_uuid_get(unsigned char *uuid_data) +APR_DECLARE(fspr_status_t) fspr_os_uuid_get(unsigned char *uuid_data) { uint32_t rv; uuid_t g; @@ -68,7 +68,7 @@ APR_DECLARE(apr_status_t) apr_os_uuid_get(unsigned char *uuid_data) #elif defined(HAVE_UUID_GENERATE) -APR_DECLARE(apr_status_t) apr_os_uuid_get(unsigned char *uuid_data) +APR_DECLARE(fspr_status_t) fspr_os_uuid_get(unsigned char *uuid_data) { uuid_t g; @@ -84,8 +84,8 @@ APR_DECLARE(apr_status_t) apr_os_uuid_get(unsigned char *uuid_data) #if APR_HAS_RANDOM -APR_DECLARE(apr_status_t) apr_generate_random_bytes(unsigned char *buf, - apr_size_t length) +APR_DECLARE(fspr_status_t) fspr_generate_random_bytes(unsigned char *buf, + fspr_size_t length) { #ifdef DEV_RANDOM @@ -95,7 +95,7 @@ APR_DECLARE(apr_status_t) apr_generate_random_bytes(unsigned char *buf, * gives EOF, so reading 'length' bytes may require opening the * device several times. */ do { - apr_ssize_t rc; + fspr_ssize_t rc; if (fd == -1) if ((fd = open(DEV_RANDOM, O_RDONLY)) == -1) @@ -145,8 +145,8 @@ APR_DECLARE(apr_status_t) apr_generate_random_bytes(unsigned char *buf, int egd_socket, egd_path_len, rv, bad_errno; struct sockaddr_un addr; - apr_socklen_t egd_addr_len; - apr_size_t resp_expected; + fspr_socklen_t egd_addr_len; + fspr_size_t resp_expected; unsigned char req[2], resp[255]; unsigned char *curbuf = buf; @@ -178,7 +178,7 @@ APR_DECLARE(apr_status_t) apr_generate_random_bytes(unsigned char *buf, /* EGD can only return 255 bytes of data at a time. Silly. */ while (length > 0) { - apr_ssize_t srv; + fspr_ssize_t srv; req[0] = 2; /* We'll block for now. */ req[1] = length > 255 ? 255: length; diff --git a/libs/apr/misc/unix/start.c b/libs/apr/misc/unix/start.c index 4b8ad990de..b7b239587c 100644 --- a/libs/apr/misc/unix/start.c +++ b/libs/apr/misc/unix/start.c @@ -14,17 +14,17 @@ * limitations under the License. */ -#include "apr.h" -#include "apr_general.h" -#include "apr_pools.h" -#include "apr_signal.h" -#include "apr_atomic.h" +#include "fspr.h" +#include "fspr_general.h" +#include "fspr_pools.h" +#include "fspr_signal.h" +#include "fspr_atomic.h" -#include "apr_arch_proc_mutex.h" /* for apr_proc_mutex_unix_setup_lock() */ -#include "apr_arch_internal_time.h" +#include "fspr_arch_proc_mutex.h" /* for fspr_proc_mutex_unix_setup_lock() */ +#include "fspr_arch_internal_time.h" -APR_DECLARE(apr_status_t) apr_app_initialize(int *argc, +APR_DECLARE(fspr_status_t) fspr_app_initialize(int *argc, const char * const * *argv, const char * const * *env) { @@ -33,57 +33,57 @@ APR_DECLARE(apr_status_t) apr_app_initialize(int *argc, * control manager into the process, and it's required to fix the char* * data passed in from win32 unicode into utf-8, win32's apr internal fmt. */ - return apr_initialize(); + return fspr_initialize(); } static int initialized = 0; -APR_DECLARE(apr_status_t) apr_initialize(void) +APR_DECLARE(fspr_status_t) fspr_initialize(void) { - apr_pool_t *pool; - apr_status_t status; + fspr_pool_t *pool; + fspr_status_t status; if (initialized++) { return APR_SUCCESS; } #if !defined(BEOS) && !defined(OS2) - apr_proc_mutex_unix_setup_lock(); - apr_unix_setup_time(); + fspr_proc_mutex_unix_setup_lock(); + fspr_unix_setup_time(); #endif - if ((status = apr_pool_initialize()) != APR_SUCCESS) + if ((status = fspr_pool_initialize()) != APR_SUCCESS) return status; - if (apr_pool_create(&pool, NULL) != APR_SUCCESS) { + if (fspr_pool_create(&pool, NULL) != APR_SUCCESS) { return APR_ENOPOOL; } - apr_pool_tag(pool, "apr_initialize"); + fspr_pool_tag(pool, "fspr_initialize"); - /* apr_atomic_init() used to be called from here aswell. + /* fspr_atomic_init() used to be called from here aswell. * Pools rely on mutexes though, which can be backed by * atomics. Due to this circular dependency - * apr_pool_initialize() is taking care of calling - * apr_atomic_init() at the correct time. + * fspr_pool_initialize() is taking care of calling + * fspr_atomic_init() at the correct time. */ - apr_signal_init(pool); + fspr_signal_init(pool); return APR_SUCCESS; } -APR_DECLARE_NONSTD(void) apr_terminate(void) +APR_DECLARE_NONSTD(void) fspr_terminate(void) { initialized--; if (initialized) { return; } - apr_pool_terminate(); + fspr_pool_terminate(); } -APR_DECLARE(void) apr_terminate2(void) +APR_DECLARE(void) fspr_terminate2(void) { - apr_terminate(); + fspr_terminate(); } diff --git a/libs/apr/misc/unix/version.c b/libs/apr/misc/unix/version.c index 2f111bf9dc..39fb71c5b3 100644 --- a/libs/apr/misc/unix/version.c +++ b/libs/apr/misc/unix/version.c @@ -14,10 +14,10 @@ * limitations under the License. */ -#include "apr_version.h" -#include "apr_general.h" /* for APR_STRINGIFY */ +#include "fspr_version.h" +#include "fspr_general.h" /* for APR_STRINGIFY */ -APR_DECLARE(void) apr_version(apr_version_t *pvsn) +APR_DECLARE(void) fspr_version(fspr_version_t *pvsn) { pvsn->major = APR_MAJOR_VERSION; pvsn->minor = APR_MINOR_VERSION; @@ -29,7 +29,7 @@ APR_DECLARE(void) apr_version(apr_version_t *pvsn) #endif } -APR_DECLARE(const char *) apr_version_string(void) +APR_DECLARE(const char *) fspr_version_string(void) { return APR_VERSION_STRING; } diff --git a/libs/apr/misc/win32/charset.c b/libs/apr/misc/win32/charset.c index d54d6e645c..041b60bd09 100644 --- a/libs/apr/misc/win32/charset.c +++ b/libs/apr/misc/win32/charset.c @@ -14,22 +14,22 @@ * limitations under the License. */ -#include "apr.h" -#include "apr_strings.h" -#include "apr_portable.h" +#include "fspr.h" +#include "fspr_strings.h" +#include "fspr_portable.h" -APR_DECLARE(const char*) apr_os_default_encoding (apr_pool_t *pool) +APR_DECLARE(const char*) fspr_os_default_encoding (fspr_pool_t *pool) { - return apr_psprintf(pool, "CP%u", (unsigned) GetACP()); + return fspr_psprintf(pool, "CP%u", (unsigned) GetACP()); } -APR_DECLARE(const char*) apr_os_locale_encoding (apr_pool_t *pool) +APR_DECLARE(const char*) fspr_os_locale_encoding (fspr_pool_t *pool) { LCID locale = GetThreadLocale(); int len = GetLocaleInfo(locale, LOCALE_IDEFAULTANSICODEPAGE, NULL, 0); - char *cp = apr_palloc(pool, len + 2); + char *cp = fspr_palloc(pool, len + 2); if (0 < GetLocaleInfo(locale, LOCALE_IDEFAULTANSICODEPAGE, cp + 2, len)) { /* Fix up the returned number to make a valid codepage name of @@ -39,5 +39,5 @@ APR_DECLARE(const char*) apr_os_locale_encoding (apr_pool_t *pool) return cp; } - return apr_os_default_encoding(pool); + return fspr_os_default_encoding(pool); } diff --git a/libs/apr/misc/win32/env.c b/libs/apr/misc/win32/env.c index e99ff8d476..7b174bba1d 100644 --- a/libs/apr/misc/win32/env.c +++ b/libs/apr/misc/win32/env.c @@ -15,26 +15,26 @@ */ #define APR_WANT_STRFUNC -#include "apr_want.h" -#include "apr.h" -#include "apr_arch_misc.h" -#include "apr_arch_utf8.h" -#include "apr_env.h" -#include "apr_errno.h" -#include "apr_pools.h" -#include "apr_strings.h" +#include "fspr_want.h" +#include "fspr.h" +#include "fspr_arch_misc.h" +#include "fspr_arch_utf8.h" +#include "fspr_env.h" +#include "fspr_errno.h" +#include "fspr_pools.h" +#include "fspr_strings.h" #if APR_HAS_UNICODE_FS -static apr_status_t widen_envvar_name (apr_wchar_t *buffer, - apr_size_t bufflen, +static fspr_status_t widen_envvar_name (fspr_wchar_t *buffer, + fspr_size_t bufflen, const char *envvar) { - apr_size_t inchars; - apr_status_t status; + fspr_size_t inchars; + fspr_status_t status; inchars = strlen(envvar) + 1; - status = apr_conv_utf8_to_ucs2(envvar, &inchars, buffer, &bufflen); + status = fspr_conv_utf8_to_ucs2(envvar, &inchars, buffer, &bufflen); if (status == APR_INCOMPLETE) status = APR_ENAMETOOLONG; @@ -43,9 +43,9 @@ static apr_status_t widen_envvar_name (apr_wchar_t *buffer, #endif -APR_DECLARE(apr_status_t) apr_env_get(char **value, +APR_DECLARE(fspr_status_t) fspr_env_get(char **value, const char *envvar, - apr_pool_t *pool) + fspr_pool_t *pool) { char *val = NULL; DWORD size; @@ -53,10 +53,10 @@ APR_DECLARE(apr_status_t) apr_env_get(char **value, #if APR_HAS_UNICODE_FS IF_WIN_OS_IS_UNICODE { - apr_wchar_t wenvvar[APR_PATH_MAX]; - apr_size_t inchars, outchars; - apr_wchar_t *wvalue, dummy; - apr_status_t status; + fspr_wchar_t wenvvar[APR_PATH_MAX]; + fspr_size_t inchars, outchars; + fspr_wchar_t *wvalue, dummy; + fspr_status_t status; status = widen_envvar_name(wenvvar, APR_PATH_MAX, envvar); if (status) @@ -70,11 +70,11 @@ APR_DECLARE(apr_status_t) apr_env_get(char **value, if (size == 0) { /* The environment value exists, but is zero-length. */ - *value = apr_pstrdup(pool, ""); + *value = fspr_pstrdup(pool, ""); return APR_SUCCESS; } - wvalue = apr_palloc(pool, size * sizeof(*wvalue)); + wvalue = fspr_palloc(pool, size * sizeof(*wvalue)); size = GetEnvironmentVariableW(wenvvar, wvalue, size); if (size == 0) /* Mid-air collision?. Somebody must've changed the env. var. */ @@ -82,8 +82,8 @@ APR_DECLARE(apr_status_t) apr_env_get(char **value, inchars = wcslen(wvalue) + 1; outchars = 3 * inchars; /* Enougn for any UTF-8 representation */ - val = apr_palloc(pool, outchars); - status = apr_conv_ucs2_to_utf8(wvalue, &inchars, val, &outchars); + val = fspr_palloc(pool, outchars); + status = fspr_conv_ucs2_to_utf8(wvalue, &inchars, val, &outchars); if (status) return status; } @@ -101,11 +101,11 @@ APR_DECLARE(apr_status_t) apr_env_get(char **value, if (size == 0) { /* The environment value exists, but is zero-length. */ - *value = apr_pstrdup(pool, ""); + *value = fspr_pstrdup(pool, ""); return APR_SUCCESS; } - val = apr_palloc(pool, size); + val = fspr_palloc(pool, size); size = GetEnvironmentVariableA(envvar, val, size); if (size == 0) /* Mid-air collision?. Somebody must've changed the env. var. */ @@ -118,37 +118,37 @@ APR_DECLARE(apr_status_t) apr_env_get(char **value, } -APR_DECLARE(apr_status_t) apr_env_set(const char *envvar, +APR_DECLARE(fspr_status_t) fspr_env_set(const char *envvar, const char *value, - apr_pool_t *pool) + fspr_pool_t *pool) { #if APR_HAS_UNICODE_FS IF_WIN_OS_IS_UNICODE { - apr_wchar_t wenvvar[APR_PATH_MAX]; - apr_wchar_t *wvalue; - apr_size_t inchars, outchars; - apr_status_t status; + fspr_wchar_t wenvvar[APR_PATH_MAX]; + fspr_wchar_t *wvalue; + fspr_size_t inchars, outchars; + fspr_status_t status; status = widen_envvar_name(wenvvar, APR_PATH_MAX, envvar); if (status) return status; outchars = inchars = strlen(value) + 1; - wvalue = apr_palloc(pool, outchars * sizeof(*wvalue)); - status = apr_conv_utf8_to_ucs2(value, &inchars, wvalue, &outchars); + wvalue = fspr_palloc(pool, outchars * sizeof(*wvalue)); + status = fspr_conv_utf8_to_ucs2(value, &inchars, wvalue, &outchars); if (status) return status; if (!SetEnvironmentVariableW(wenvvar, wvalue)) - return apr_get_os_error(); + return fspr_get_os_error(); } #endif #if APR_HAS_ANSI_FS ELSE_WIN_OS_IS_ANSI { if (!SetEnvironmentVariableA(envvar, value)) - return apr_get_os_error(); + return fspr_get_os_error(); } #endif @@ -156,27 +156,27 @@ APR_DECLARE(apr_status_t) apr_env_set(const char *envvar, } -APR_DECLARE(apr_status_t) apr_env_delete(const char *envvar, apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_env_delete(const char *envvar, fspr_pool_t *pool) { #if APR_HAS_UNICODE_FS IF_WIN_OS_IS_UNICODE { - apr_wchar_t wenvvar[APR_PATH_MAX]; - apr_status_t status; + fspr_wchar_t wenvvar[APR_PATH_MAX]; + fspr_status_t status; status = widen_envvar_name(wenvvar, APR_PATH_MAX, envvar); if (status) return status; if (!SetEnvironmentVariableW(wenvvar, NULL)) - return apr_get_os_error(); + return fspr_get_os_error(); } #endif #if APR_HAS_ANSI_FS ELSE_WIN_OS_IS_ANSI { if (!SetEnvironmentVariableA(envvar, NULL)) - return apr_get_os_error(); + return fspr_get_os_error(); } #endif diff --git a/libs/apr/misc/win32/apr_app.c b/libs/apr/misc/win32/fspr_app.c similarity index 90% rename from libs/apr/misc/win32/apr_app.c rename to libs/apr/misc/win32/fspr_app.c index baac96e811..d6b580c007 100644 --- a/libs/apr/misc/win32/apr_app.c +++ b/libs/apr/misc/win32/fspr_app.c @@ -24,7 +24,7 @@ * * This module is only compatible with Unicode-only executables. * Mixed (Win9x backwards compatible) binaries should refer instead - * to the apr_startup.c module. + * to the fspr_startup.c module. * * _dbg_malloc/realloc is used in place of the usual API, in order * to convince the MSVCRT that they created these entities. If we @@ -33,14 +33,14 @@ * since we are single threaded [so far]. */ -#include "apr_general.h" +#include "fspr_general.h" #include "ShellAPI.h" #include "crtdbg.h" #include "wchar.h" -#include "apr_arch_file_io.h" +#include "fspr_arch_file_io.h" #include "assert.h" -#include "apr_private.h" -#include "apr_arch_misc.h" +#include "fspr_private.h" +#include "fspr_arch_misc.h" /* This symbol is _private_, although it must be exported. */ @@ -53,9 +53,9 @@ int wmain(int argc, const wchar_t **wargv, const wchar_t **wenv) char **env; int dupenv; - (void)apr_wastrtoastr(&argv, wargv, argc); + (void)fspr_wastrtoastr(&argv, wargv, argc); - dupenv = apr_wastrtoastr(&env, wenv, -1); + dupenv = fspr_wastrtoastr(&env, wenv, -1); _environ = _malloc_dbg((dupenv + 1) * sizeof (char *), _CRT_BLOCK, __FILE__, __LINE__ ); @@ -74,7 +74,7 @@ int wmain(int argc, const wchar_t **wargv, const wchar_t **wenv) free((wchar_t **)wenv); } - apr_app_init_complete = 1; + fspr_app_init_complete = 1; return main(argc, argv, env); } diff --git a/libs/apr/misc/win32/internal.c b/libs/apr/misc/win32/internal.c index b045bd4258..22c9122a65 100644 --- a/libs/apr/misc/win32/internal.c +++ b/libs/apr/misc/win32/internal.c @@ -14,10 +14,10 @@ * limitations under the License. */ -#include "apr_private.h" +#include "fspr_private.h" -#include "apr_arch_misc.h" -#include "apr_arch_file_io.h" +#include "fspr_arch_misc.h" +#include "fspr_arch_file_io.h" #include #include @@ -30,7 +30,7 @@ */ -/* Shared by apr_app.c and start.c +/* Shared by fspr_app.c and start.c * * An internal apr function to convert an array of strings (either * a counted or NULL terminated list, such as an argv[argc] or env[] @@ -38,10 +38,10 @@ * These are allocated from the MSVCRT's _CRT_BLOCK to trick the system * into trusting our store. */ -int apr_wastrtoastr(char const * const * *retarr, +int fspr_wastrtoastr(char const * const * *retarr, wchar_t const * const *arr, int args) { - apr_size_t elesize = 0; + fspr_size_t elesize = 0; char **newarr; char *elements; char *ele; @@ -57,7 +57,7 @@ int apr_wastrtoastr(char const * const * *retarr, for (arg = 0; arg < args; ++arg) { newarr[arg] = (void*)(wcslen(arr[arg]) + 1); - elesize += (apr_size_t)newarr[arg]; + elesize += (fspr_size_t)newarr[arg]; } /* This is a safe max allocation, we will realloc after @@ -70,11 +70,11 @@ int apr_wastrtoastr(char const * const * *retarr, _CRT_BLOCK, __FILE__, __LINE__); for (arg = 0; arg < args; ++arg) { - apr_size_t len = (apr_size_t)newarr[arg]; - apr_size_t newlen = elesize; + fspr_size_t len = (fspr_size_t)newarr[arg]; + fspr_size_t newlen = elesize; newarr[arg] = ele; - (void)apr_conv_ucs2_to_utf8(arr[arg], &len, + (void)fspr_conv_ucs2_to_utf8(arr[arg], &len, newarr[arg], &elesize); newlen -= elesize; @@ -91,7 +91,7 @@ int apr_wastrtoastr(char const * const * *retarr, _CRT_BLOCK, __FILE__, __LINE__); if (ele != elements) { - apr_size_t diff = ele - elements; + fspr_size_t diff = ele - elements; for (arg = 0; arg < args; ++arg) { newarr[arg] += diff; } diff --git a/libs/apr/misc/win32/misc.c b/libs/apr/misc/win32/misc.c index 9975eef613..ad7bfdfbcb 100644 --- a/libs/apr/misc/win32/misc.c +++ b/libs/apr/misc/win32/misc.c @@ -14,18 +14,18 @@ * limitations under the License. */ -#include "apr_private.h" -#include "apr_arch_misc.h" +#include "fspr_private.h" +#include "fspr_arch_misc.h" #include "crtdbg.h" -#include "apr_arch_file_io.h" +#include "fspr_arch_file_io.h" #include "assert.h" -#include "apr_lib.h" +#include "fspr_lib.h" -APR_DECLARE_DATA apr_oslevel_e apr_os_level = APR_WIN_UNK; +APR_DECLARE_DATA fspr_oslevel_e fspr_os_level = APR_WIN_UNK; -apr_status_t apr_get_oslevel(apr_oslevel_e *level) +fspr_status_t fspr_get_oslevel(fspr_oslevel_e *level) { - if (apr_os_level == APR_WIN_UNK) + if (fspr_os_level == APR_WIN_UNK) { static OSVERSIONINFO oslev; oslev.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); @@ -36,7 +36,7 @@ apr_status_t apr_get_oslevel(apr_oslevel_e *level) static unsigned int servpack = 0; char *pservpack; if (pservpack = oslev.szCSDVersion) { - while (*pservpack && !apr_isdigit(*pservpack)) { + while (*pservpack && !fspr_isdigit(*pservpack)) { pservpack++; } if (*pservpack) @@ -44,63 +44,63 @@ apr_status_t apr_get_oslevel(apr_oslevel_e *level) } if (oslev.dwMajorVersion < 3) { - apr_os_level = APR_WIN_UNSUP; + fspr_os_level = APR_WIN_UNSUP; } else if (oslev.dwMajorVersion == 3) { if (oslev.dwMajorVersion < 50) { - apr_os_level = APR_WIN_UNSUP; + fspr_os_level = APR_WIN_UNSUP; } else if (oslev.dwMajorVersion == 50) { - apr_os_level = APR_WIN_NT_3_5; + fspr_os_level = APR_WIN_NT_3_5; } else { - apr_os_level = APR_WIN_NT_3_51; + fspr_os_level = APR_WIN_NT_3_51; } } else if (oslev.dwMajorVersion == 4) { if (servpack < 2) - apr_os_level = APR_WIN_NT_4; + fspr_os_level = APR_WIN_NT_4; else if (servpack <= 2) - apr_os_level = APR_WIN_NT_4_SP2; + fspr_os_level = APR_WIN_NT_4_SP2; else if (servpack <= 3) - apr_os_level = APR_WIN_NT_4_SP3; + fspr_os_level = APR_WIN_NT_4_SP3; else if (servpack <= 4) - apr_os_level = APR_WIN_NT_4_SP4; + fspr_os_level = APR_WIN_NT_4_SP4; else if (servpack <= 5) - apr_os_level = APR_WIN_NT_4_SP5; + fspr_os_level = APR_WIN_NT_4_SP5; else - apr_os_level = APR_WIN_NT_4_SP6; + fspr_os_level = APR_WIN_NT_4_SP6; } else if (oslev.dwMajorVersion == 5) { if (oslev.dwMinorVersion == 0) { if (servpack == 0) - apr_os_level = APR_WIN_2000; + fspr_os_level = APR_WIN_2000; else if (servpack == 1) - apr_os_level = APR_WIN_2000_SP1; + fspr_os_level = APR_WIN_2000_SP1; else - apr_os_level = APR_WIN_2000_SP2; + fspr_os_level = APR_WIN_2000_SP2; } else if (oslev.dwMinorVersion == 2) { - apr_os_level = APR_WIN_2003; + fspr_os_level = APR_WIN_2003; } else { if (servpack < 1) - apr_os_level = APR_WIN_XP; + fspr_os_level = APR_WIN_XP; else if (servpack == 1) - apr_os_level = APR_WIN_XP_SP1; + fspr_os_level = APR_WIN_XP_SP1; else - apr_os_level = APR_WIN_XP_SP2; + fspr_os_level = APR_WIN_XP_SP2; } } else { - apr_os_level = APR_WIN_XP; + fspr_os_level = APR_WIN_XP; } } #ifndef WINNT else if (oslev.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) { char *prevision; if (prevision = oslev.szCSDVersion) { - while (*prevision && !apr_isupper(*prevision)) { + while (*prevision && !fspr_isupper(*prevision)) { prevision++; } } @@ -108,18 +108,18 @@ apr_status_t apr_get_oslevel(apr_oslevel_e *level) if (oslev.dwMinorVersion < 10) { if (*prevision < 'C') - apr_os_level = APR_WIN_95; + fspr_os_level = APR_WIN_95; else - apr_os_level = APR_WIN_95_OSR2; + fspr_os_level = APR_WIN_95_OSR2; } else if (oslev.dwMinorVersion < 90) { if (*prevision < 'A') - apr_os_level = APR_WIN_98; + fspr_os_level = APR_WIN_98; else - apr_os_level = APR_WIN_98_SE; + fspr_os_level = APR_WIN_98_SE; } else { - apr_os_level = APR_WIN_ME; + fspr_os_level = APR_WIN_ME; } } #endif @@ -127,21 +127,21 @@ apr_status_t apr_get_oslevel(apr_oslevel_e *level) else if (oslev.dwPlatformId == VER_PLATFORM_WIN32_CE) { if (oslev.dwMajorVersion < 3) { - apr_os_level = APR_WIN_UNSUP; + fspr_os_level = APR_WIN_UNSUP; } else { - apr_os_level = APR_WIN_CE_3; + fspr_os_level = APR_WIN_CE_3; } } #endif else { - apr_os_level = APR_WIN_UNSUP; + fspr_os_level = APR_WIN_UNSUP; } } - *level = apr_os_level; + *level = fspr_os_level; - if (apr_os_level < APR_WIN_UNSUP) { + if (fspr_os_level < APR_WIN_UNSUP) { return APR_EGENERAL; } @@ -158,7 +158,7 @@ static const char* const lateDllName[DLL_defined] = { static HMODULE lateDllHandle[DLL_defined] = { NULL, NULL, NULL, NULL, NULL, NULL }; -FARPROC apr_load_dll_func(apr_dlltoken_e fnLib, char* fnName, int ordinal) +FARPROC fspr_load_dll_func(fspr_dlltoken_e fnLib, char* fnName, int ordinal) { if (!lateDllHandle[fnLib]) { lateDllHandle[fnLib] = LoadLibrary(lateDllName[fnLib]); @@ -171,9 +171,9 @@ FARPROC apr_load_dll_func(apr_dlltoken_e fnLib, char* fnName, int ordinal) return GetProcAddress(lateDllHandle[fnLib], fnName); } -/* Declared in include/arch/win32/apr_dbg_win32_handles.h +/* Declared in include/arch/win32/fspr_dbg_win32_handles.h */ -APR_DECLARE_NONSTD(HANDLE) apr_dbg_log(char* fn, HANDLE ha, char* fl, int ln, +APR_DECLARE_NONSTD(HANDLE) fspr_dbg_log(char* fn, HANDLE ha, char* fl, int ln, int nh, /* HANDLE hv, char *dsc */...) { static DWORD tlsid = 0xFFFFFFFF; diff --git a/libs/apr/misc/win32/rand.c b/libs/apr/misc/win32/rand.c index fb50fb9b32..130c87b85b 100644 --- a/libs/apr/misc/win32/rand.c +++ b/libs/apr/misc/win32/rand.c @@ -14,42 +14,42 @@ * limitations under the License. */ -#include "apr.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_portable.h" -#include "apr_arch_misc.h" +#include "fspr.h" +#include "fspr_private.h" +#include "fspr_general.h" +#include "fspr_portable.h" +#include "fspr_arch_misc.h" #include -APR_DECLARE(apr_status_t) apr_generate_random_bytes(unsigned char * buf, - apr_size_t length) +APR_DECLARE(fspr_status_t) fspr_generate_random_bytes(unsigned char * buf, + fspr_size_t length) { HCRYPTPROV hProv; - apr_status_t res = APR_SUCCESS; + fspr_status_t res = APR_SUCCESS; /* 0x40 bit = CRYPT_SILENT, only introduced in more recent PSDKs * and will only work for Win2K and later. */ DWORD flags = CRYPT_VERIFYCONTEXT - | ((apr_os_level >= APR_WIN_2000) ? 0x40 : 0); + | ((fspr_os_level >= APR_WIN_2000) ? 0x40 : 0); if (!CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL, flags)) { - return apr_get_os_error(); + return fspr_get_os_error(); } /* XXX: An ugly hack for Win64, randomness is such that noone should * ever expect > 2^31 bytes of data at once without the prng * coming to a complete halt. */ if (!CryptGenRandom(hProv, (DWORD)length, buf)) { - res = apr_get_os_error(); + res = fspr_get_os_error(); } CryptReleaseContext(hProv, 0); return res; } -APR_DECLARE(apr_status_t) apr_os_uuid_get(unsigned char *uuid_data) +APR_DECLARE(fspr_status_t) fspr_os_uuid_get(unsigned char *uuid_data) { /* Note: this call doesn't actually require CoInitialize() first * @@ -59,7 +59,7 @@ APR_DECLARE(apr_status_t) apr_os_uuid_get(unsigned char *uuid_data) * be appropriate in all cases. * * Note that Win2000, XP and later no longer suffer from this problem, - * a scrambling fix is only needed for (apr_os_level < APR_WIN_2000) + * a scrambling fix is only needed for (fspr_os_level < APR_WIN_2000) */ if (FAILED(UuidCreate((UUID *)uuid_data))) { return APR_EGENERAL; diff --git a/libs/apr/misc/win32/start.c b/libs/apr/misc/win32/start.c index f51b749d2c..4a87e23c1e 100644 --- a/libs/apr/misc/win32/start.c +++ b/libs/apr/misc/win32/start.c @@ -14,23 +14,23 @@ * limitations under the License. */ -#include "apr_private.h" -#include "apr_general.h" -#include "apr_pools.h" -#include "apr_signal.h" +#include "fspr_private.h" +#include "fspr_general.h" +#include "fspr_pools.h" +#include "fspr_signal.h" #include "ShellAPI.h" -#include "apr_arch_misc.h" /* for WSAHighByte / WSALowByte */ +#include "fspr_arch_misc.h" /* for WSAHighByte / WSALowByte */ #include "wchar.h" -#include "apr_arch_file_io.h" +#include "fspr_arch_file_io.h" #include "crtdbg.h" #include "assert.h" /* This symbol is _private_, although it must be exported. */ -int APR_DECLARE_DATA apr_app_init_complete = 0; +int APR_DECLARE_DATA fspr_app_init_complete = 0; -/* Used by apr_app_initialize to reprocess the environment +/* Used by fspr_app_initialize to reprocess the environment * * An internal apr function to convert a double-null terminated set * of single-null terminated strings from wide Unicode to narrow utf-8 @@ -40,10 +40,10 @@ int APR_DECLARE_DATA apr_app_init_complete = 0; static int warrsztoastr(const char * const * *retarr, const wchar_t * arrsz, int args) { - const apr_wchar_t *wch; - apr_size_t totlen; - apr_size_t newlen; - apr_size_t wsize; + const fspr_wchar_t *wch; + fspr_size_t totlen; + fspr_size_t newlen; + fspr_size_t wsize; char **newarr; int arg; @@ -66,7 +66,7 @@ static int warrsztoastr(const char * const * *retarr, newarr[0] = _malloc_dbg(newlen * sizeof(char), _CRT_BLOCK, __FILE__, __LINE__); - (void)apr_conv_ucs2_to_utf8(arrsz, &wsize, + (void)fspr_conv_ucs2_to_utf8(arrsz, &wsize, newarr[0], &newlen); assert(newlen && !wsize); @@ -91,11 +91,11 @@ static int warrsztoastr(const char * const * *retarr, /* Reprocess the arguments to main() for a completely apr-ized application */ -APR_DECLARE(apr_status_t) apr_app_initialize(int *argc, +APR_DECLARE(fspr_status_t) fspr_app_initialize(int *argc, const char * const * *argv, const char * const * *env) { - apr_status_t rv = apr_initialize(); + fspr_status_t rv = fspr_initialize(); if (rv != APR_SUCCESS) { return rv; @@ -104,22 +104,22 @@ APR_DECLARE(apr_status_t) apr_app_initialize(int *argc, #if APR_HAS_UNICODE_FS IF_WIN_OS_IS_UNICODE { - apr_wchar_t **wstrs; - apr_wchar_t *sysstr; + fspr_wchar_t **wstrs; + fspr_wchar_t *sysstr; int wstrc; int dupenv; - if (apr_app_init_complete) { + if (fspr_app_init_complete) { return rv; } - apr_app_init_complete = 1; + fspr_app_init_complete = 1; sysstr = GetCommandLineW(); if (sysstr) { wstrs = CommandLineToArgvW(sysstr, &wstrc); if (wstrs) { - *argc = apr_wastrtoastr(argv, wstrs, wstrc); + *argc = fspr_wastrtoastr(argv, wstrs, wstrc); GlobalFree(wstrs); } } @@ -145,7 +145,7 @@ APR_DECLARE(apr_status_t) apr_app_initialize(int *argc, * Reset _wenviron for good measure. */ if (_wenviron) { - apr_wchar_t **wenv = _wenviron; + fspr_wchar_t **wenv = _wenviron; _wenviron = NULL; free(wenv); } @@ -158,35 +158,35 @@ APR_DECLARE(apr_status_t) apr_app_initialize(int *argc, static int initialized = 0; /* Provide to win32/thread.c */ -extern DWORD tls_apr_thread; +extern DWORD tls_fspr_thread; -APR_DECLARE(apr_status_t) apr_initialize(void) +APR_DECLARE(fspr_status_t) fspr_initialize(void) { - apr_pool_t *pool; - apr_status_t status; + fspr_pool_t *pool; + fspr_status_t status; int iVersionRequested; WSADATA wsaData; int err; - apr_oslevel_e osver; + fspr_oslevel_e osver; if (initialized++) { return APR_SUCCESS; } - /* Initialize apr_os_level global */ - if (apr_get_oslevel(&osver) != APR_SUCCESS) { + /* Initialize fspr_os_level global */ + if (fspr_get_oslevel(&osver) != APR_SUCCESS) { return APR_EEXIST; } - tls_apr_thread = TlsAlloc(); - if ((status = apr_pool_initialize()) != APR_SUCCESS) + tls_fspr_thread = TlsAlloc(); + if ((status = fspr_pool_initialize()) != APR_SUCCESS) return status; - if (apr_pool_create(&pool, NULL) != APR_SUCCESS) { + if (fspr_pool_create(&pool, NULL) != APR_SUCCESS) { return APR_ENOPOOL; } - apr_pool_tag(pool, "apr_initialize"); + fspr_pool_tag(pool, "fspr_initialize"); iVersionRequested = MAKEWORD(WSAHighByte, WSALowByte); err = WSAStartup((WORD) iVersionRequested, &wsaData); @@ -199,25 +199,25 @@ APR_DECLARE(apr_status_t) apr_initialize(void) return APR_EEXIST; } - apr_signal_init(pool); + fspr_signal_init(pool); return APR_SUCCESS; } -APR_DECLARE_NONSTD(void) apr_terminate(void) +APR_DECLARE_NONSTD(void) fspr_terminate(void) { initialized--; if (initialized) { return; } - apr_pool_terminate(); + fspr_pool_terminate(); WSACleanup(); - TlsFree(tls_apr_thread); + TlsFree(tls_fspr_thread); } -APR_DECLARE(void) apr_terminate2(void) +APR_DECLARE(void) fspr_terminate2(void) { - apr_terminate(); + fspr_terminate(); } diff --git a/libs/apr/misc/win32/utf8.c b/libs/apr/misc/win32/utf8.c index b37dba44da..57167235c4 100644 --- a/libs/apr/misc/win32/utf8.c +++ b/libs/apr/misc/win32/utf8.c @@ -14,10 +14,10 @@ * limitations under the License. */ -#include "apr.h" -#include "apr_private.h" -#include "apr_errno.h" -#include "apr_arch_utf8.h" +#include "fspr.h" +#include "fspr_private.h" +#include "fspr_errno.h" +#include "fspr_arch_utf8.h" /* Implement the design principal specified by RFC 2718 2.2.5 * Guidelines for new URL Schemes - within the APR. @@ -58,18 +58,18 @@ * W1 = 110110yyyyyyyyyy * W2 = 110111xxxxxxxxxx * - * apr_conv_utf8_to_ucs2 out bytes:sizeof(in) * 1 <= Req <= sizeof(in) * 2 + * fspr_conv_utf8_to_ucs2 out bytes:sizeof(in) * 1 <= Req <= sizeof(in) * 2 * - * apr_conv_ucs2_to_utf8 out words:sizeof(in) / 2 <= Req <= sizeof(in) * 3 / 2 + * fspr_conv_ucs2_to_utf8 out words:sizeof(in) / 2 <= Req <= sizeof(in) * 3 / 2 */ -APR_DECLARE(apr_status_t) apr_conv_utf8_to_ucs2(const char *in, - apr_size_t *inbytes, - apr_wchar_t *out, - apr_size_t *outwords) +APR_DECLARE(fspr_status_t) fspr_conv_utf8_to_ucs2(const char *in, + fspr_size_t *inbytes, + fspr_wchar_t *out, + fspr_size_t *outwords) { - apr_int64_t newch, mask; - apr_size_t expect, eating; + fspr_int64_t newch, mask; + fspr_size_t expect, eating; int ch; while (*inbytes && *outwords) @@ -138,7 +138,7 @@ APR_DECLARE(apr_status_t) apr_conv_utf8_to_ucs2(const char *in, /* Where the boolean (expect > 2) is true, we will need * an extra word for the output. */ - if (*outwords < (apr_size_t)(expect > 2) + 1) + if (*outwords < (fspr_size_t)(expect > 2) + 1) break; /* buffer full */ while (expect--) { @@ -156,14 +156,14 @@ APR_DECLARE(apr_status_t) apr_conv_utf8_to_ucs2(const char *in, if (newch < 0x10000) { --*outwords; - *(out++) = (apr_wchar_t) newch; + *(out++) = (fspr_wchar_t) newch; } else { *outwords -= 2; newch -= 0x10000; - *(out++) = (apr_wchar_t) (0xD800 | (newch >> 10)); - *(out++) = (apr_wchar_t) (0xDC00 | (newch & 0x03FF)); + *(out++) = (fspr_wchar_t) (0xD800 | (newch >> 10)); + *(out++) = (fspr_wchar_t) (0xDC00 | (newch & 0x03FF)); } } } @@ -174,13 +174,13 @@ APR_DECLARE(apr_status_t) apr_conv_utf8_to_ucs2(const char *in, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_conv_ucs2_to_utf8(const apr_wchar_t *in, - apr_size_t *inwords, +APR_DECLARE(fspr_status_t) fspr_conv_ucs2_to_utf8(const fspr_wchar_t *in, + fspr_size_t *inwords, char *out, - apr_size_t *outbytes) + fspr_size_t *outbytes) { - apr_int64_t newch, require; - apr_size_t need; + fspr_int64_t newch, require; + fspr_size_t need; char *invout; int ch; diff --git a/libs/apr/mmap/unix/common.c b/libs/apr/mmap/unix/common.c index a978992880..a9b0b4c2f6 100644 --- a/libs/apr/mmap/unix/common.c +++ b/libs/apr/mmap/unix/common.c @@ -23,15 +23,15 @@ * */ -#include "apr.h" -#include "apr_private.h" -#include "apr_mmap.h" -#include "apr_errno.h" +#include "fspr.h" +#include "fspr_private.h" +#include "fspr_mmap.h" +#include "fspr_errno.h" #if APR_HAS_MMAP || defined(BEOS) -APR_DECLARE(apr_status_t) apr_mmap_offset(void **addr, apr_mmap_t *mmap, - apr_off_t offset) +APR_DECLARE(fspr_status_t) fspr_mmap_offset(void **addr, fspr_mmap_t *mmap, + fspr_off_t offset) { if (offset < 0 || offset > mmap->size) return APR_EINVAL; diff --git a/libs/apr/mmap/unix/mmap.c b/libs/apr/mmap/unix/mmap.c index 6719570967..e86938bde5 100644 --- a/libs/apr/mmap/unix/mmap.c +++ b/libs/apr/mmap/unix/mmap.c @@ -14,14 +14,14 @@ * limitations under the License. */ -#include "apr.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_strings.h" -#include "apr_mmap.h" -#include "apr_errno.h" -#include "apr_arch_file_io.h" -#include "apr_portable.h" +#include "fspr.h" +#include "fspr_private.h" +#include "fspr_general.h" +#include "fspr_strings.h" +#include "fspr_mmap.h" +#include "fspr_errno.h" +#include "fspr_arch_file_io.h" +#include "fspr_portable.h" /* System headers required for the mmap library */ #ifdef BEOS @@ -42,10 +42,10 @@ #if APR_HAS_MMAP || defined(BEOS) -static apr_status_t mmap_cleanup(void *themmap) +static fspr_status_t mmap_cleanup(void *themmap) { - apr_mmap_t *mm = themmap; - apr_mmap_t *next = APR_RING_NEXT(mm,link); + fspr_mmap_t *mm = themmap; + fspr_mmap_t *next = APR_RING_NEXT(mm,link); int rv = 0; /* we no longer refer to the mmaped region */ @@ -71,24 +71,24 @@ static apr_status_t mmap_cleanup(void *themmap) return errno; } -APR_DECLARE(apr_status_t) apr_mmap_create(apr_mmap_t **new, - apr_file_t *file, apr_off_t offset, - apr_size_t size, apr_int32_t flag, - apr_pool_t *cont) +APR_DECLARE(fspr_status_t) fspr_mmap_create(fspr_mmap_t **new, + fspr_file_t *file, fspr_off_t offset, + fspr_size_t size, fspr_int32_t flag, + fspr_pool_t *cont) { void *mm; #ifdef BEOS area_id aid = -1; uint32 pages = 0; #else - apr_int32_t native_flags = 0; + fspr_int32_t native_flags = 0; #endif #if APR_HAS_LARGE_FILES && defined(HAVE_MMAP64) #define mmap mmap64 #elif APR_HAS_LARGE_FILES && SIZEOF_OFF_T == 4 /* LFS but no mmap64: check for overflow */ - if ((apr_int64_t)offset + size > INT_MAX) + if ((fspr_int64_t)offset + size > INT_MAX) return APR_EINVAL; #endif @@ -97,18 +97,18 @@ APR_DECLARE(apr_status_t) apr_mmap_create(apr_mmap_t **new, if (file == NULL || file->filedes == -1 || file->buffered) return APR_EBADF; - (*new) = (apr_mmap_t *)apr_pcalloc(cont, sizeof(apr_mmap_t)); + (*new) = (fspr_mmap_t *)fspr_pcalloc(cont, sizeof(fspr_mmap_t)); #ifdef BEOS /* XXX: mmap shouldn't really change the seek offset */ - apr_file_seek(file, APR_SET, &offset); + fspr_file_seek(file, APR_SET, &offset); /* There seems to be some strange interactions that mean our area must * be set as READ & WRITE or writev will fail! Go figure... * So we ignore the value in flags and always ask for both READ and WRITE */ pages = (size + B_PAGE_SIZE -1) / B_PAGE_SIZE; - aid = create_area("apr_mmap", &mm , B_ANY_ADDRESS, pages * B_PAGE_SIZE, + aid = create_area("fspr_mmap", &mm , B_ANY_ADDRESS, pages * B_PAGE_SIZE, B_NO_LOCK, B_WRITE_AREA|B_READ_AREA); if (aid < B_NO_ERROR) { @@ -145,28 +145,28 @@ APR_DECLARE(apr_status_t) apr_mmap_create(apr_mmap_t **new, APR_RING_ELEM_INIT(*new, link); /* register the cleanup... */ - apr_pool_cleanup_register((*new)->cntxt, (void*)(*new), mmap_cleanup, - apr_pool_cleanup_null); + fspr_pool_cleanup_register((*new)->cntxt, (void*)(*new), mmap_cleanup, + fspr_pool_cleanup_null); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_mmap_dup(apr_mmap_t **new_mmap, - apr_mmap_t *old_mmap, - apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_mmap_dup(fspr_mmap_t **new_mmap, + fspr_mmap_t *old_mmap, + fspr_pool_t *p) { - *new_mmap = (apr_mmap_t *)apr_pmemdup(p, old_mmap, sizeof(apr_mmap_t)); + *new_mmap = (fspr_mmap_t *)fspr_pmemdup(p, old_mmap, sizeof(fspr_mmap_t)); (*new_mmap)->cntxt = p; APR_RING_INSERT_AFTER(old_mmap, *new_mmap, link); - apr_pool_cleanup_register(p, *new_mmap, mmap_cleanup, - apr_pool_cleanup_null); + fspr_pool_cleanup_register(p, *new_mmap, mmap_cleanup, + fspr_pool_cleanup_null); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_mmap_delete(apr_mmap_t *mm) +APR_DECLARE(fspr_status_t) fspr_mmap_delete(fspr_mmap_t *mm) { - return apr_pool_cleanup_run(mm->cntxt, mm, mmap_cleanup); + return fspr_pool_cleanup_run(mm->cntxt, mm, mmap_cleanup); } #endif diff --git a/libs/apr/mmap/win32/mmap.c b/libs/apr/mmap/win32/mmap.c index 134417707f..495b168438 100644 --- a/libs/apr/mmap/win32/mmap.c +++ b/libs/apr/mmap/win32/mmap.c @@ -14,22 +14,22 @@ * limitations under the License. */ -#include "apr.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_mmap.h" -#include "apr_errno.h" -#include "apr_arch_file_io.h" -#include "apr_portable.h" -#include "apr_strings.h" +#include "fspr.h" +#include "fspr_private.h" +#include "fspr_general.h" +#include "fspr_mmap.h" +#include "fspr_errno.h" +#include "fspr_arch_file_io.h" +#include "fspr_portable.h" +#include "fspr_strings.h" #if APR_HAS_MMAP -static apr_status_t mmap_cleanup(void *themmap) +static fspr_status_t mmap_cleanup(void *themmap) { - apr_mmap_t *mm = themmap; - apr_mmap_t *next = APR_RING_NEXT(mm,link); - apr_status_t rv = 0; + fspr_mmap_t *mm = themmap; + fspr_mmap_t *next = APR_RING_NEXT(mm,link); + fspr_status_t rv = 0; /* we no longer refer to the mmaped region */ APR_RING_REMOVE(mm,link); @@ -44,7 +44,7 @@ static apr_status_t mmap_cleanup(void *themmap) if (mm->mv) { if (!UnmapViewOfFile(mm->mv)) { - apr_status_t rv = apr_get_os_error(); + fspr_status_t rv = fspr_get_os_error(); CloseHandle(mm->mhandle); mm->mv = NULL; mm->mhandle = NULL; @@ -56,7 +56,7 @@ static apr_status_t mmap_cleanup(void *themmap) { if (!CloseHandle(mm->mhandle)) { - apr_status_t rv = apr_get_os_error(); + fspr_status_t rv = fspr_get_os_error(); CloseHandle(mm->mhandle); mm->mhandle = NULL; return rv; @@ -66,9 +66,9 @@ static apr_status_t mmap_cleanup(void *themmap) return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_mmap_create(apr_mmap_t **new, apr_file_t *file, - apr_off_t offset, apr_size_t size, - apr_int32_t flag, apr_pool_t *cont) +APR_DECLARE(fspr_status_t) fspr_mmap_create(fspr_mmap_t **new, fspr_file_t *file, + fspr_off_t offset, fspr_size_t size, + fspr_int32_t flag, fspr_pool_t *cont) { static DWORD memblock = 0; DWORD fmaccess = 0; @@ -100,10 +100,10 @@ APR_DECLARE(apr_status_t) apr_mmap_create(apr_mmap_t **new, apr_file_t *file, memblock = si.dwAllocationGranularity; } - *new = apr_pcalloc(cont, sizeof(apr_mmap_t)); + *new = fspr_pcalloc(cont, sizeof(fspr_mmap_t)); (*new)->pstart = (offset / memblock) * memblock; (*new)->poffset = offset - (*new)->pstart; - (*new)->psize = (apr_size_t)((*new)->poffset) + size; + (*new)->psize = (fspr_size_t)((*new)->poffset) + size; /* The size of the CreateFileMapping object is the current size * of the size of the mmap object (e.g. file size), not the size * of the mapped region! @@ -114,7 +114,7 @@ APR_DECLARE(apr_status_t) apr_mmap_create(apr_mmap_t **new, apr_file_t *file, if (!(*new)->mhandle || (*new)->mhandle == INVALID_HANDLE_VALUE) { *new = NULL; - return apr_get_os_error(); + return fspr_get_os_error(); } offlo = (DWORD)(*new)->pstart; @@ -123,7 +123,7 @@ APR_DECLARE(apr_status_t) apr_mmap_create(apr_mmap_t **new, apr_file_t *file, offlo, (*new)->psize); if (!(*new)->mv) { - apr_status_t rv = apr_get_os_error(); + fspr_status_t rv = fspr_get_os_error(); CloseHandle((*new)->mhandle); *new = NULL; return rv; @@ -135,28 +135,28 @@ APR_DECLARE(apr_status_t) apr_mmap_create(apr_mmap_t **new, apr_file_t *file, APR_RING_ELEM_INIT(*new, link); /* register the cleanup... */ - apr_pool_cleanup_register((*new)->cntxt, (void*)(*new), mmap_cleanup, - apr_pool_cleanup_null); + fspr_pool_cleanup_register((*new)->cntxt, (void*)(*new), mmap_cleanup, + fspr_pool_cleanup_null); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_mmap_dup(apr_mmap_t **new_mmap, - apr_mmap_t *old_mmap, - apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_mmap_dup(fspr_mmap_t **new_mmap, + fspr_mmap_t *old_mmap, + fspr_pool_t *p) { - *new_mmap = (apr_mmap_t *)apr_pmemdup(p, old_mmap, sizeof(apr_mmap_t)); + *new_mmap = (fspr_mmap_t *)fspr_pmemdup(p, old_mmap, sizeof(fspr_mmap_t)); (*new_mmap)->cntxt = p; APR_RING_INSERT_AFTER(old_mmap, *new_mmap, link); - apr_pool_cleanup_register(p, *new_mmap, mmap_cleanup, - apr_pool_cleanup_null); + fspr_pool_cleanup_register(p, *new_mmap, mmap_cleanup, + fspr_pool_cleanup_null); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_mmap_delete(apr_mmap_t *mm) +APR_DECLARE(fspr_status_t) fspr_mmap_delete(fspr_mmap_t *mm) { - return apr_pool_cleanup_run(mm->cntxt, mm, mmap_cleanup); + return fspr_pool_cleanup_run(mm->cntxt, mm, mmap_cleanup); } #endif diff --git a/libs/apr/network_io/beos/sendrecv.c b/libs/apr/network_io/beos/sendrecv.c index 1aeb426e9c..618b2c6a8b 100644 --- a/libs/apr/network_io/beos/sendrecv.c +++ b/libs/apr/network_io/beos/sendrecv.c @@ -14,14 +14,14 @@ * limitations under the License. */ -#include "apr_private.h" +#include "fspr_private.h" #if BEOS_BONE /* BONE uses the unix code - woohoo */ #include "../unix/sendrecv.c" #else -#include "apr_arch_networkio.h" -#include "apr_time.h" +#include "fspr_arch_networkio.h" +#include "fspr_time.h" -static apr_status_t wait_for_io_or_timeout(apr_socket_t *sock, int for_read) +static fspr_status_t wait_for_io_or_timeout(fspr_socket_t *sock, int for_read) { struct timeval tv, *tvptr; fd_set fdset; @@ -57,23 +57,23 @@ static apr_status_t wait_for_io_or_timeout(apr_socket_t *sock, int for_read) #define SEND_WAIT APR_USEC_PER_SEC / 10 -APR_DECLARE(apr_status_t) apr_socket_send(apr_socket_t *sock, const char *buf, - apr_size_t *len) +APR_DECLARE(fspr_status_t) fspr_socket_send(fspr_socket_t *sock, const char *buf, + fspr_size_t *len) { - apr_ssize_t rv; + fspr_ssize_t rv; do { rv = send(sock->socketdes, buf, (*len), 0); } while (rv == -1 && errno == EINTR); if (rv == -1 && errno == EWOULDBLOCK && sock->timeout > 0) { - apr_int32_t snooze_val = SEND_WAIT; - apr_int32_t zzz = 0; + fspr_int32_t snooze_val = SEND_WAIT; + fspr_int32_t zzz = 0; do { rv = send(sock->socketdes, buf, (*len), 0); if (rv == -1 && errno == EWOULDBLOCK){ - apr_sleep (snooze_val); + fspr_sleep (snooze_val); zzz += snooze_val; snooze_val += SEND_WAIT; /* have we passed our timeout value */ @@ -91,17 +91,17 @@ APR_DECLARE(apr_status_t) apr_socket_send(apr_socket_t *sock, const char *buf, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_socket_recv(apr_socket_t *sock, char *buf, - apr_size_t *len) +APR_DECLARE(fspr_status_t) fspr_socket_recv(fspr_socket_t *sock, char *buf, + fspr_size_t *len) { - apr_ssize_t rv; + fspr_ssize_t rv; do { rv = recv(sock->socketdes, buf, (*len), 0); } while (rv == -1 && errno == EINTR); if (rv == -1 && errno == EWOULDBLOCK && sock->timeout > 0) { - apr_status_t arv = wait_for_io_or_timeout(sock, 1); + fspr_status_t arv = wait_for_io_or_timeout(sock, 1); if (arv != APR_SUCCESS) { *len = 0; return arv; @@ -124,20 +124,20 @@ APR_DECLARE(apr_status_t) apr_socket_recv(apr_socket_t *sock, char *buf, /* BeOS doesn't have writev for sockets so we use the following instead... */ -APR_DECLARE(apr_status_t) apr_socket_sendv(apr_socket_t * sock, +APR_DECLARE(fspr_status_t) fspr_socket_sendv(fspr_socket_t * sock, const struct iovec *vec, - apr_int32_t nvec, apr_size_t *len) + fspr_int32_t nvec, fspr_size_t *len) { *len = vec[0].iov_len; - return apr_socket_send(sock, vec[0].iov_base, len); + return fspr_socket_send(sock, vec[0].iov_base, len); } -APR_DECLARE(apr_status_t) apr_socket_sendto(apr_socket_t *sock, - apr_sockaddr_t *where, - apr_int32_t flags, const char *buf, - apr_size_t *len) +APR_DECLARE(fspr_status_t) fspr_socket_sendto(fspr_socket_t *sock, + fspr_sockaddr_t *where, + fspr_int32_t flags, const char *buf, + fspr_size_t *len) { - apr_ssize_t rv; + fspr_ssize_t rv; do { rv = sendto(sock->socketdes, buf, (*len), flags, @@ -147,7 +147,7 @@ APR_DECLARE(apr_status_t) apr_socket_sendto(apr_socket_t *sock, if (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK) && sock->timeout != 0) { - apr_status_t arv = wait_for_io_or_timeout(sock, 0); + fspr_status_t arv = wait_for_io_or_timeout(sock, 0); if (arv != APR_SUCCESS) { *len = 0; return arv; @@ -167,12 +167,12 @@ APR_DECLARE(apr_status_t) apr_socket_sendto(apr_socket_t *sock, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_socket_recvfrom(apr_sockaddr_t *from, - apr_socket_t *sock, - apr_int32_t flags, char *buf, - apr_size_t *len) +APR_DECLARE(fspr_status_t) fspr_socket_recvfrom(fspr_sockaddr_t *from, + fspr_socket_t *sock, + fspr_int32_t flags, char *buf, + fspr_size_t *len) { - apr_ssize_t rv; + fspr_ssize_t rv; if (from == NULL){ return APR_ENOMEM; @@ -188,7 +188,7 @@ APR_DECLARE(apr_status_t) apr_socket_recvfrom(apr_sockaddr_t *from, if (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK) && sock->timeout != 0) { - apr_status_t arv = wait_for_io_or_timeout(sock, 1); + fspr_status_t arv = wait_for_io_or_timeout(sock, 1); if (arv != APR_SUCCESS) { *len = 0; return arv; diff --git a/libs/apr/network_io/os2/os2calls.c b/libs/apr/network_io/os2/os2calls.c index 6bf1fcd02e..b68e93e294 100644 --- a/libs/apr/network_io/os2/os2calls.c +++ b/libs/apr/network_io/os2/os2calls.c @@ -14,33 +14,33 @@ * limitations under the License. */ -#include "apr_arch_networkio.h" -#include "apr_network_io.h" -#include "apr_portable.h" -#include "apr_general.h" -#include "apr_lib.h" +#include "fspr_arch_networkio.h" +#include "fspr_network_io.h" +#include "fspr_portable.h" +#include "fspr_general.h" +#include "fspr_lib.h" static int os2_socket_init(int, int ,int); -int (*apr_os2_socket)(int, int, int) = os2_socket_init; -int (*apr_os2_select)(int *, int, int, int, long) = NULL; -int (*apr_os2_sock_errno)() = NULL; -int (*apr_os2_accept)(int, struct sockaddr *, int *) = NULL; -int (*apr_os2_bind)(int, struct sockaddr *, int) = NULL; -int (*apr_os2_connect)(int, struct sockaddr *, int) = NULL; -int (*apr_os2_getpeername)(int, struct sockaddr *, int *) = NULL; -int (*apr_os2_getsockname)(int, struct sockaddr *, int *) = NULL; -int (*apr_os2_getsockopt)(int, int, int, char *, int *) = NULL; -int (*apr_os2_ioctl)(int, int, caddr_t, int) = NULL; -int (*apr_os2_listen)(int, int) = NULL; -int (*apr_os2_recv)(int, char *, int, int) = NULL; -int (*apr_os2_send)(int, const char *, int, int) = NULL; -int (*apr_os2_setsockopt)(int, int, int, char *, int) = NULL; -int (*apr_os2_shutdown)(int, int) = NULL; -int (*apr_os2_soclose)(int) = NULL; -int (*apr_os2_writev)(int, struct iovec *, int) = NULL; -int (*apr_os2_sendto)(int, const char *, int, int, const struct sockaddr *, int); -int (*apr_os2_recvfrom)(int, char *, int, int, struct sockaddr *, int *); +int (*fspr_os2_socket)(int, int, int) = os2_socket_init; +int (*fspr_os2_select)(int *, int, int, int, long) = NULL; +int (*fspr_os2_sock_errno)() = NULL; +int (*fspr_os2_accept)(int, struct sockaddr *, int *) = NULL; +int (*fspr_os2_bind)(int, struct sockaddr *, int) = NULL; +int (*fspr_os2_connect)(int, struct sockaddr *, int) = NULL; +int (*fspr_os2_getpeername)(int, struct sockaddr *, int *) = NULL; +int (*fspr_os2_getsockname)(int, struct sockaddr *, int *) = NULL; +int (*fspr_os2_getsockopt)(int, int, int, char *, int *) = NULL; +int (*fspr_os2_ioctl)(int, int, caddr_t, int) = NULL; +int (*fspr_os2_listen)(int, int) = NULL; +int (*fspr_os2_recv)(int, char *, int, int) = NULL; +int (*fspr_os2_send)(int, const char *, int, int) = NULL; +int (*fspr_os2_setsockopt)(int, int, int, char *, int) = NULL; +int (*fspr_os2_shutdown)(int, int) = NULL; +int (*fspr_os2_soclose)(int) = NULL; +int (*fspr_os2_writev)(int, struct iovec *, int) = NULL; +int (*fspr_os2_sendto)(int, const char *, int, int, const struct sockaddr *, int); +int (*fspr_os2_recvfrom)(int, char *, int, int, struct sockaddr *, int *); static HMODULE hSO32DLL; @@ -48,7 +48,7 @@ static int os2_fn_link() { DosEnterCritSec(); /* Stop two threads doing this at the same time */ - if (apr_os2_socket == os2_socket_init) { + if (fspr_os2_socket == os2_socket_init) { ULONG rc; char errorstr[200]; @@ -57,61 +57,61 @@ static int os2_fn_link() if (rc) return APR_OS2_STATUS(rc); - rc = DosQueryProcAddr(hSO32DLL, 0, "SOCKET", &apr_os2_socket); + rc = DosQueryProcAddr(hSO32DLL, 0, "SOCKET", &fspr_os2_socket); if (!rc) - rc = DosQueryProcAddr(hSO32DLL, 0, "SELECT", &apr_os2_select); + rc = DosQueryProcAddr(hSO32DLL, 0, "SELECT", &fspr_os2_select); if (!rc) - rc = DosQueryProcAddr(hSO32DLL, 0, "SOCK_ERRNO", &apr_os2_sock_errno); + rc = DosQueryProcAddr(hSO32DLL, 0, "SOCK_ERRNO", &fspr_os2_sock_errno); if (!rc) - rc = DosQueryProcAddr(hSO32DLL, 0, "ACCEPT", &apr_os2_accept); + rc = DosQueryProcAddr(hSO32DLL, 0, "ACCEPT", &fspr_os2_accept); if (!rc) - rc = DosQueryProcAddr(hSO32DLL, 0, "BIND", &apr_os2_bind); + rc = DosQueryProcAddr(hSO32DLL, 0, "BIND", &fspr_os2_bind); if (!rc) - rc = DosQueryProcAddr(hSO32DLL, 0, "CONNECT", &apr_os2_connect); + rc = DosQueryProcAddr(hSO32DLL, 0, "CONNECT", &fspr_os2_connect); if (!rc) - rc = DosQueryProcAddr(hSO32DLL, 0, "GETPEERNAME", &apr_os2_getpeername); + rc = DosQueryProcAddr(hSO32DLL, 0, "GETPEERNAME", &fspr_os2_getpeername); if (!rc) - rc = DosQueryProcAddr(hSO32DLL, 0, "GETSOCKNAME", &apr_os2_getsockname); + rc = DosQueryProcAddr(hSO32DLL, 0, "GETSOCKNAME", &fspr_os2_getsockname); if (!rc) - rc = DosQueryProcAddr(hSO32DLL, 0, "GETSOCKOPT", &apr_os2_getsockopt); + rc = DosQueryProcAddr(hSO32DLL, 0, "GETSOCKOPT", &fspr_os2_getsockopt); if (!rc) - rc = DosQueryProcAddr(hSO32DLL, 0, "IOCTL", &apr_os2_ioctl); + rc = DosQueryProcAddr(hSO32DLL, 0, "IOCTL", &fspr_os2_ioctl); if (!rc) - rc = DosQueryProcAddr(hSO32DLL, 0, "LISTEN", &apr_os2_listen); + rc = DosQueryProcAddr(hSO32DLL, 0, "LISTEN", &fspr_os2_listen); if (!rc) - rc = DosQueryProcAddr(hSO32DLL, 0, "RECV", &apr_os2_recv); + rc = DosQueryProcAddr(hSO32DLL, 0, "RECV", &fspr_os2_recv); if (!rc) - rc = DosQueryProcAddr(hSO32DLL, 0, "SEND", &apr_os2_send); + rc = DosQueryProcAddr(hSO32DLL, 0, "SEND", &fspr_os2_send); if (!rc) - rc = DosQueryProcAddr(hSO32DLL, 0, "SETSOCKOPT", &apr_os2_setsockopt); + rc = DosQueryProcAddr(hSO32DLL, 0, "SETSOCKOPT", &fspr_os2_setsockopt); if (!rc) - rc = DosQueryProcAddr(hSO32DLL, 0, "SHUTDOWN", &apr_os2_shutdown); + rc = DosQueryProcAddr(hSO32DLL, 0, "SHUTDOWN", &fspr_os2_shutdown); if (!rc) - rc = DosQueryProcAddr(hSO32DLL, 0, "SOCLOSE", &apr_os2_soclose); + rc = DosQueryProcAddr(hSO32DLL, 0, "SOCLOSE", &fspr_os2_soclose); if (!rc) - rc = DosQueryProcAddr(hSO32DLL, 0, "WRITEV", &apr_os2_writev); + rc = DosQueryProcAddr(hSO32DLL, 0, "WRITEV", &fspr_os2_writev); if (!rc) - rc = DosQueryProcAddr(hSO32DLL, 0, "SENDTO", &apr_os2_sendto); + rc = DosQueryProcAddr(hSO32DLL, 0, "SENDTO", &fspr_os2_sendto); if (!rc) - rc = DosQueryProcAddr(hSO32DLL, 0, "RECVFROM", &apr_os2_recvfrom); + rc = DosQueryProcAddr(hSO32DLL, 0, "RECVFROM", &fspr_os2_recvfrom); if (rc) return APR_OS2_STATUS(rc); @@ -127,6 +127,6 @@ static int os2_socket_init(int domain, int type, int protocol) { int rc = os2_fn_link(); if (rc == APR_SUCCESS) - return apr_os2_socket(domain, type, protocol); + return fspr_os2_socket(domain, type, protocol); return rc; } diff --git a/libs/apr/network_io/os2/sendrecv.c b/libs/apr/network_io/os2/sendrecv.c index 839ff3f831..8f0fbf805c 100644 --- a/libs/apr/network_io/os2/sendrecv.c +++ b/libs/apr/network_io/os2/sendrecv.c @@ -14,17 +14,17 @@ * limitations under the License. */ -#include "apr_arch_networkio.h" -#include "apr_errno.h" -#include "apr_general.h" -#include "apr_network_io.h" -#include "apr_lib.h" +#include "fspr_arch_networkio.h" +#include "fspr_errno.h" +#include "fspr_general.h" +#include "fspr_network_io.h" +#include "fspr_lib.h" #include -APR_DECLARE(apr_status_t) apr_socket_send(apr_socket_t *sock, const char *buf, - apr_size_t *len) +APR_DECLARE(fspr_status_t) fspr_socket_send(fspr_socket_t *sock, const char *buf, + fspr_size_t *len) { - apr_ssize_t rv; + fspr_ssize_t rv; int fds, err = 0; if (*len > 65536) { @@ -65,10 +65,10 @@ APR_DECLARE(apr_status_t) apr_socket_send(apr_socket_t *sock, const char *buf, -APR_DECLARE(apr_status_t) apr_socket_recv(apr_socket_t *sock, char *buf, - apr_size_t *len) +APR_DECLARE(fspr_status_t) fspr_socket_recv(fspr_socket_t *sock, char *buf, + fspr_size_t *len) { - apr_ssize_t rv; + fspr_ssize_t rv; int fds, err = 0; do { @@ -105,11 +105,11 @@ APR_DECLARE(apr_status_t) apr_socket_recv(apr_socket_t *sock, char *buf, -APR_DECLARE(apr_status_t) apr_socket_sendv(apr_socket_t *sock, +APR_DECLARE(fspr_status_t) fspr_socket_sendv(fspr_socket_t *sock, const struct iovec *vec, - apr_int32_t nvec, apr_size_t *len) + fspr_int32_t nvec, fspr_size_t *len) { - apr_status_t rv; + fspr_status_t rv; struct iovec *tmpvec; int fds, err = 0; int nv_tosend, total = 0; diff --git a/libs/apr/network_io/os2/sendrecv_udp.c b/libs/apr/network_io/os2/sendrecv_udp.c index c0dcd8562e..7a8d0c36db 100644 --- a/libs/apr/network_io/os2/sendrecv_udp.c +++ b/libs/apr/network_io/os2/sendrecv_udp.c @@ -14,21 +14,21 @@ * limitations under the License. */ -#include "apr_arch_networkio.h" -#include "apr_errno.h" -#include "apr_general.h" -#include "apr_network_io.h" -#include "apr_support.h" -#include "apr_lib.h" +#include "fspr_arch_networkio.h" +#include "fspr_errno.h" +#include "fspr_general.h" +#include "fspr_network_io.h" +#include "fspr_support.h" +#include "fspr_lib.h" #include -APR_DECLARE(apr_status_t) apr_socket_sendto(apr_socket_t *sock, - apr_sockaddr_t *where, - apr_int32_t flags, const char *buf, - apr_size_t *len) +APR_DECLARE(fspr_status_t) fspr_socket_sendto(fspr_socket_t *sock, + fspr_sockaddr_t *where, + fspr_int32_t flags, const char *buf, + fspr_size_t *len) { - apr_ssize_t rv; + fspr_ssize_t rv; int serrno; do { @@ -38,7 +38,7 @@ APR_DECLARE(apr_status_t) apr_socket_sendto(apr_socket_t *sock, } while (rv == -1 && (serrno = sock_errno()) == EINTR); if (rv == -1 && serrno == SOCEWOULDBLOCK && sock->timeout != 0) { - apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 0); + fspr_status_t arv = fspr_wait_for_io_or_timeout(NULL, sock, 0); if (arv != APR_SUCCESS) { *len = 0; @@ -63,12 +63,12 @@ APR_DECLARE(apr_status_t) apr_socket_sendto(apr_socket_t *sock, -APR_DECLARE(apr_status_t) apr_socket_recvfrom(apr_sockaddr_t *from, - apr_socket_t *sock, - apr_int32_t flags, char *buf, - apr_size_t *len) +APR_DECLARE(fspr_status_t) fspr_socket_recvfrom(fspr_sockaddr_t *from, + fspr_socket_t *sock, + fspr_int32_t flags, char *buf, + fspr_size_t *len) { - apr_ssize_t rv; + fspr_ssize_t rv; int serrno; do { @@ -77,7 +77,7 @@ APR_DECLARE(apr_status_t) apr_socket_recvfrom(apr_sockaddr_t *from, } while (rv == -1 && (serrno = sock_errno()) == EINTR); if (rv == -1 && serrno == SOCEWOULDBLOCK && sock->timeout != 0) { - apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 1); + fspr_status_t arv = fspr_wait_for_io_or_timeout(NULL, sock, 1); if (arv != APR_SUCCESS) { *len = 0; diff --git a/libs/apr/network_io/os2/sockets.c b/libs/apr/network_io/os2/sockets.c index bb951e4c86..1035889b4b 100644 --- a/libs/apr/network_io/os2/sockets.c +++ b/libs/apr/network_io/os2/sockets.c @@ -14,13 +14,13 @@ * limitations under the License. */ -#include "apr_arch_networkio.h" -#include "apr_arch_inherit.h" -#include "apr_network_io.h" -#include "apr_general.h" -#include "apr_portable.h" -#include "apr_lib.h" -#include "apr_strings.h" +#include "fspr_arch_networkio.h" +#include "fspr_arch_inherit.h" +#include "fspr_network_io.h" +#include "fspr_general.h" +#include "fspr_portable.h" +#include "fspr_lib.h" +#include "fspr_strings.h" #include #include #include @@ -28,11 +28,11 @@ #include #include #include -#include "apr_arch_os2calls.h" +#include "fspr_arch_os2calls.h" -static apr_status_t socket_cleanup(void *sock) +static fspr_status_t socket_cleanup(void *sock) { - apr_socket_t *thesocket = sock; + fspr_socket_t *thesocket = sock; if (thesocket->socketdes < 0) { return APR_EINVALSOCK; @@ -47,43 +47,43 @@ static apr_status_t socket_cleanup(void *sock) } } -static void set_socket_vars(apr_socket_t *sock, int family, int type, int protocol) +static void set_socket_vars(fspr_socket_t *sock, int family, int type, int protocol) { sock->type = type; sock->protocol = protocol; - apr_sockaddr_vars_set(sock->local_addr, family, 0); - apr_sockaddr_vars_set(sock->remote_addr, family, 0); + fspr_sockaddr_vars_set(sock->local_addr, family, 0); + fspr_sockaddr_vars_set(sock->remote_addr, family, 0); } -static void alloc_socket(apr_socket_t **new, apr_pool_t *p) +static void alloc_socket(fspr_socket_t **new, fspr_pool_t *p) { - *new = (apr_socket_t *)apr_pcalloc(p, sizeof(apr_socket_t)); + *new = (fspr_socket_t *)fspr_pcalloc(p, sizeof(fspr_socket_t)); (*new)->pool = p; - (*new)->local_addr = (apr_sockaddr_t *)apr_pcalloc((*new)->pool, - sizeof(apr_sockaddr_t)); + (*new)->local_addr = (fspr_sockaddr_t *)fspr_pcalloc((*new)->pool, + sizeof(fspr_sockaddr_t)); (*new)->local_addr->pool = p; - (*new)->remote_addr = (apr_sockaddr_t *)apr_pcalloc((*new)->pool, - sizeof(apr_sockaddr_t)); + (*new)->remote_addr = (fspr_sockaddr_t *)fspr_pcalloc((*new)->pool, + sizeof(fspr_sockaddr_t)); (*new)->remote_addr->pool = p; (*new)->remote_addr_unknown = 1; /* Create a pollset with room for one descriptor. */ /* ### check return codes */ - (void) apr_pollset_create(&(*new)->pollset, 1, p, 0); + (void) fspr_pollset_create(&(*new)->pollset, 1, p, 0); } -APR_DECLARE(apr_status_t) apr_socket_protocol_get(apr_socket_t *sock, int *protocol) +APR_DECLARE(fspr_status_t) fspr_socket_protocol_get(fspr_socket_t *sock, int *protocol) { *protocol = sock->protocol; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_socket_create(apr_socket_t **new, int family, int type, - int protocol, apr_pool_t *cont) +APR_DECLARE(fspr_status_t) fspr_socket_create(fspr_socket_t **new, int family, int type, + int protocol, fspr_pool_t *cont) { int downgrade = (family == AF_UNSPEC); - apr_pollfd_t pfd; + fspr_pollfd_t pfd; if (family == AF_UNSPEC) { #if APR_HAVE_IPV6 @@ -110,14 +110,14 @@ APR_DECLARE(apr_status_t) apr_socket_create(apr_socket_t **new, int family, int (*new)->timeout = -1; (*new)->nonblock = FALSE; - apr_pool_cleanup_register((*new)->pool, (void *)(*new), - socket_cleanup, apr_pool_cleanup_null); + fspr_pool_cleanup_register((*new)->pool, (void *)(*new), + socket_cleanup, fspr_pool_cleanup_null); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_socket_shutdown(apr_socket_t *thesocket, - apr_shutdown_how_e how) +APR_DECLARE(fspr_status_t) fspr_socket_shutdown(fspr_socket_t *thesocket, + fspr_shutdown_how_e how) { if (shutdown(thesocket->socketdes, how) == 0) { return APR_SUCCESS; @@ -127,14 +127,14 @@ APR_DECLARE(apr_status_t) apr_socket_shutdown(apr_socket_t *thesocket, } } -APR_DECLARE(apr_status_t) apr_socket_close(apr_socket_t *thesocket) +APR_DECLARE(fspr_status_t) fspr_socket_close(fspr_socket_t *thesocket) { - apr_pool_cleanup_kill(thesocket->pool, thesocket, socket_cleanup); + fspr_pool_cleanup_kill(thesocket->pool, thesocket, socket_cleanup); return socket_cleanup(thesocket); } -APR_DECLARE(apr_status_t) apr_socket_bind(apr_socket_t *sock, - apr_sockaddr_t *sa) +APR_DECLARE(fspr_status_t) fspr_socket_bind(fspr_socket_t *sock, + fspr_sockaddr_t *sa) { if (bind(sock->socketdes, (struct sockaddr *)&sa->sa, @@ -150,8 +150,8 @@ APR_DECLARE(apr_status_t) apr_socket_bind(apr_socket_t *sock, } } -APR_DECLARE(apr_status_t) apr_socket_listen(apr_socket_t *sock, - apr_int32_t backlog) +APR_DECLARE(fspr_status_t) fspr_socket_listen(fspr_socket_t *sock, + fspr_int32_t backlog) { if (listen(sock->socketdes, backlog) == -1) return APR_OS2_STATUS(sock_errno()); @@ -159,9 +159,9 @@ APR_DECLARE(apr_status_t) apr_socket_listen(apr_socket_t *sock, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_socket_accept(apr_socket_t **new, - apr_socket_t *sock, - apr_pool_t *connection_context) +APR_DECLARE(fspr_status_t) fspr_socket_accept(fspr_socket_t **new, + fspr_socket_t *sock, + fspr_pool_t *connection_context) { alloc_socket(new, connection_context); set_socket_vars(*new, sock->local_addr->sa.sin.sin_family, SOCK_STREAM, sock->protocol); @@ -186,13 +186,13 @@ APR_DECLARE(apr_status_t) apr_socket_accept(apr_socket_t **new, (*new)->local_addr->ipaddr_ptr = &(*new)->local_addr->sa.sin.sin_addr; } - apr_pool_cleanup_register((*new)->pool, (void *)(*new), - socket_cleanup, apr_pool_cleanup_null); + fspr_pool_cleanup_register((*new)->pool, (void *)(*new), + socket_cleanup, fspr_pool_cleanup_null); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_socket_connect(apr_socket_t *sock, - apr_sockaddr_t *sa) +APR_DECLARE(fspr_status_t) fspr_socket_connect(fspr_socket_t *sock, + fspr_sockaddr_t *sa) { if ((connect(sock->socketdes, (struct sockaddr *)&sa->sa.sin, sa->salen) < 0) && @@ -208,14 +208,14 @@ APR_DECLARE(apr_status_t) apr_socket_connect(apr_socket_t *sock, } } -APR_DECLARE(apr_status_t) apr_socket_type_get(apr_socket_t *sock, int *type) +APR_DECLARE(fspr_status_t) fspr_socket_type_get(fspr_socket_t *sock, int *type) { *type = sock->type; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_socket_data_get(void **data, const char *key, - apr_socket_t *sock) +APR_DECLARE(fspr_status_t) fspr_socket_data_get(void **data, const char *key, + fspr_socket_t *sock) { sock_userdata_t *cur = sock->userdata; @@ -234,65 +234,65 @@ APR_DECLARE(apr_status_t) apr_socket_data_get(void **data, const char *key, -APR_DECLARE(apr_status_t) apr_socket_data_set(apr_socket_t *sock, void *data, const char *key, - apr_status_t (*cleanup) (void *)) +APR_DECLARE(fspr_status_t) fspr_socket_data_set(fspr_socket_t *sock, void *data, const char *key, + fspr_status_t (*cleanup) (void *)) { - sock_userdata_t *new = apr_palloc(sock->pool, sizeof(sock_userdata_t)); + sock_userdata_t *new = fspr_palloc(sock->pool, sizeof(sock_userdata_t)); - new->key = apr_pstrdup(sock->pool, key); + new->key = fspr_pstrdup(sock->pool, key); new->data = data; new->next = sock->userdata; sock->userdata = new; if (cleanup) { - apr_pool_cleanup_register(sock->pool, data, cleanup, cleanup); + fspr_pool_cleanup_register(sock->pool, data, cleanup, cleanup); } return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_os_sock_get(apr_os_sock_t *thesock, apr_socket_t *sock) +APR_DECLARE(fspr_status_t) fspr_os_sock_get(fspr_os_sock_t *thesock, fspr_socket_t *sock) { *thesock = sock->socketdes; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_os_sock_make(apr_socket_t **apr_sock, - apr_os_sock_info_t *os_sock_info, - apr_pool_t *cont) +APR_DECLARE(fspr_status_t) fspr_os_sock_make(fspr_socket_t **fspr_sock, + fspr_os_sock_info_t *os_sock_info, + fspr_pool_t *cont) { - alloc_socket(apr_sock, cont); - set_socket_vars(*apr_sock, os_sock_info->family, os_sock_info->type, os_sock_info->protocol); - (*apr_sock)->timeout = -1; - (*apr_sock)->socketdes = *os_sock_info->os_sock; + alloc_socket(fspr_sock, cont); + set_socket_vars(*fspr_sock, os_sock_info->family, os_sock_info->type, os_sock_info->protocol); + (*fspr_sock)->timeout = -1; + (*fspr_sock)->socketdes = *os_sock_info->os_sock; if (os_sock_info->local) { - memcpy(&(*apr_sock)->local_addr->sa.sin, + memcpy(&(*fspr_sock)->local_addr->sa.sin, os_sock_info->local, - (*apr_sock)->local_addr->salen); + (*fspr_sock)->local_addr->salen); /* XXX IPv6 - this assumes sin_port and sin6_port at same offset */ - (*apr_sock)->local_addr->port = ntohs((*apr_sock)->local_addr->sa.sin.sin_port); + (*fspr_sock)->local_addr->port = ntohs((*fspr_sock)->local_addr->sa.sin.sin_port); } else { - (*apr_sock)->local_port_unknown = (*apr_sock)->local_interface_unknown = 1; + (*fspr_sock)->local_port_unknown = (*fspr_sock)->local_interface_unknown = 1; } if (os_sock_info->remote) { - memcpy(&(*apr_sock)->remote_addr->sa.sin, + memcpy(&(*fspr_sock)->remote_addr->sa.sin, os_sock_info->remote, - (*apr_sock)->remote_addr->salen); + (*fspr_sock)->remote_addr->salen); /* XXX IPv6 - this assumes sin_port and sin6_port at same offset */ - (*apr_sock)->remote_addr->port = ntohs((*apr_sock)->remote_addr->sa.sin.sin_port); + (*fspr_sock)->remote_addr->port = ntohs((*fspr_sock)->remote_addr->sa.sin.sin_port); } else { - (*apr_sock)->remote_addr_unknown = 1; + (*fspr_sock)->remote_addr_unknown = 1; } - apr_pool_cleanup_register((*apr_sock)->pool, (void *)(*apr_sock), - socket_cleanup, apr_pool_cleanup_null); + fspr_pool_cleanup_register((*fspr_sock)->pool, (void *)(*fspr_sock), + socket_cleanup, fspr_pool_cleanup_null); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_os_sock_put(apr_socket_t **sock, apr_os_sock_t *thesock, apr_pool_t *cont) +APR_DECLARE(fspr_status_t) fspr_os_sock_put(fspr_socket_t **sock, fspr_os_sock_t *thesock, fspr_pool_t *cont) { if (cont == NULL) { return APR_ENOPOOL; diff --git a/libs/apr/network_io/os2/sockopt.c b/libs/apr/network_io/os2/sockopt.c index 85ff35331a..4123de5eca 100644 --- a/libs/apr/network_io/os2/sockopt.c +++ b/libs/apr/network_io/os2/sockopt.c @@ -14,11 +14,11 @@ * limitations under the License. */ -#include "apr_arch_networkio.h" -#include "apr_network_io.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_strings.h" +#include "fspr_arch_networkio.h" +#include "fspr_network_io.h" +#include "fspr_general.h" +#include "fspr_lib.h" +#include "fspr_strings.h" #include #include #include @@ -29,16 +29,16 @@ #include -APR_DECLARE(apr_status_t) apr_socket_timeout_set(apr_socket_t *sock, - apr_interval_time_t t) +APR_DECLARE(fspr_status_t) fspr_socket_timeout_set(fspr_socket_t *sock, + fspr_interval_time_t t) { sock->timeout = t; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_socket_opt_set(apr_socket_t *sock, - apr_int32_t opt, apr_int32_t on) +APR_DECLARE(fspr_status_t) fspr_socket_opt_set(fspr_socket_t *sock, + fspr_int32_t opt, fspr_int32_t on) { int one; struct linger li; @@ -91,16 +91,16 @@ APR_DECLARE(apr_status_t) apr_socket_opt_set(apr_socket_t *sock, } -APR_DECLARE(apr_status_t) apr_socket_timeout_get(apr_socket_t *sock, - apr_interval_time_t *t) +APR_DECLARE(fspr_status_t) fspr_socket_timeout_get(fspr_socket_t *sock, + fspr_interval_time_t *t) { *t = sock->timeout; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_socket_opt_get(apr_socket_t *sock, - apr_int32_t opt, apr_int32_t *on) +APR_DECLARE(fspr_status_t) fspr_socket_opt_get(fspr_socket_t *sock, + fspr_int32_t opt, fspr_int32_t *on) { switch(opt) { default: @@ -110,7 +110,7 @@ APR_DECLARE(apr_status_t) apr_socket_opt_get(apr_socket_t *sock, } -APR_DECLARE(int) apr_socket_fd_get(apr_socket_t *sock) +APR_DECLARE(int) fspr_socket_fd_get(fspr_socket_t *sock) { if (sock) { return sock->socketdes; @@ -120,7 +120,7 @@ APR_DECLARE(int) apr_socket_fd_get(apr_socket_t *sock) } -APR_DECLARE(apr_status_t) apr_socket_atmark(apr_socket_t *sock, int *atmark) +APR_DECLARE(fspr_status_t) fspr_socket_atmark(fspr_socket_t *sock, int *atmark) { int oobmark; @@ -134,8 +134,8 @@ APR_DECLARE(apr_status_t) apr_socket_atmark(apr_socket_t *sock, int *atmark) } -APR_DECLARE(apr_status_t) apr_gethostname(char *buf, apr_int32_t len, - apr_pool_t *cont) +APR_DECLARE(fspr_status_t) fspr_gethostname(char *buf, fspr_int32_t len, + fspr_pool_t *cont) { if (gethostname(buf, len) == -1) { buf[0] = '\0'; diff --git a/libs/apr/network_io/unix/inet_ntop.c b/libs/apr/network_io/unix/inet_ntop.c index a96eb18f7a..cdf1d08176 100644 --- a/libs/apr/network_io/unix/inet_ntop.c +++ b/libs/apr/network_io/unix/inet_ntop.c @@ -14,9 +14,9 @@ * SOFTWARE. */ -#include "apr_private.h" -#include "apr_arch_networkio.h" -#include "apr_strings.h" +#include "fspr_private.h" +#include "fspr_arch_networkio.h" +#include "fspr_strings.h" #if APR_HAVE_SYS_TYPES_H #include @@ -41,7 +41,7 @@ #endif #ifndef INT16SZ -#define INT16SZ sizeof(apr_int16_t) +#define INT16SZ sizeof(fspr_int16_t) #endif #ifndef __P @@ -57,9 +57,9 @@ * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. */ -static const char *inet_ntop4 __P((const unsigned char *src, char *dst, apr_size_t size)); +static const char *inet_ntop4 __P((const unsigned char *src, char *dst, fspr_size_t size)); #if APR_HAVE_IPV6 -static const char *inet_ntop6 __P((const unsigned char *src, char *dst, apr_size_t size)); +static const char *inet_ntop6 __P((const unsigned char *src, char *dst, fspr_size_t size)); #endif /* char * @@ -71,7 +71,7 @@ static const char *inet_ntop6 __P((const unsigned char *src, char *dst, apr_size * Paul Vixie, 1996. */ const char * -apr_inet_ntop(int af, const void *src, char *dst, apr_size_t size) +fspr_inet_ntop(int af, const void *src, char *dst, fspr_size_t size) { switch (af) { case AF_INET: @@ -99,9 +99,9 @@ apr_inet_ntop(int af, const void *src, char *dst, apr_size_t size) * Paul Vixie, 1996. */ static const char * -inet_ntop4(const unsigned char *src, char *dst, apr_size_t size) +inet_ntop4(const unsigned char *src, char *dst, fspr_size_t size) { - const apr_size_t MIN_SIZE = 16; /* space for 255.255.255.255\0 */ + const fspr_size_t MIN_SIZE = 16; /* space for 255.255.255.255\0 */ int n = 0; char *next = dst; @@ -137,7 +137,7 @@ inet_ntop4(const unsigned char *src, char *dst, apr_size_t size) * Paul Vixie, 1996. */ static const char * -inet_ntop6(const unsigned char *src, char *dst, apr_size_t size) +inet_ntop6(const unsigned char *src, char *dst, fspr_size_t size) { /* * Note that int32_t and int16_t need only be "at least" large enough @@ -224,7 +224,7 @@ inet_ntop6(const unsigned char *src, char *dst, apr_size_t size) tp += strlen(tp); break; } - tp += apr_snprintf(tp, sizeof tmp - (tp - tmp), "%x", words[i]); + tp += fspr_snprintf(tp, sizeof tmp - (tp - tmp), "%x", words[i]); i++; } /* Was it a trailing run of 0x00's? */ @@ -236,7 +236,7 @@ inet_ntop6(const unsigned char *src, char *dst, apr_size_t size) /* * Check for overflow, copy, and we're done. */ - if ((apr_size_t)(tp - tmp) > size) { + if ((fspr_size_t)(tp - tmp) > size) { errno = ENOSPC; return (NULL); } diff --git a/libs/apr/network_io/unix/inet_pton.c b/libs/apr/network_io/unix/inet_pton.c index 22b15390fc..890691b533 100644 --- a/libs/apr/network_io/unix/inet_pton.c +++ b/libs/apr/network_io/unix/inet_pton.c @@ -14,8 +14,8 @@ * SOFTWARE. */ -#include "apr_private.h" -#include "apr_arch_networkio.h" +#include "fspr_private.h" +#include "fspr_arch_networkio.h" #if APR_HAVE_SYS_TYPES_H #include @@ -39,7 +39,7 @@ #endif #ifndef INT16SZ -#define INT16SZ sizeof(apr_int16_t) +#define INT16SZ sizeof(fspr_int16_t) #endif #ifndef INADDRSZ @@ -76,7 +76,7 @@ static int inet_pton6 __P((const char *src, unsigned char *dst)); * Paul Vixie, 1996. */ int -apr_inet_pton(int af, const char *src, void *dst) +fspr_inet_pton(int af, const char *src, void *dst) { switch (af) { case AF_INET: diff --git a/libs/apr/network_io/unix/multicast.c b/libs/apr/network_io/unix/multicast.c index 7f8f759dd7..5047e3b928 100644 --- a/libs/apr/network_io/unix/multicast.c +++ b/libs/apr/network_io/unix/multicast.c @@ -14,11 +14,11 @@ * limitations under the License. */ -#include "apr_arch_networkio.h" -#include "apr_network_io.h" -#include "apr_support.h" -#include "apr_portable.h" -#include "apr_arch_inherit.h" +#include "fspr_arch_networkio.h" +#include "fspr_network_io.h" +#include "fspr_support.h" +#include "fspr_portable.h" +#include "fspr_arch_inherit.h" #ifdef HAVE_GETIFADDRS #include @@ -27,12 +27,12 @@ #ifdef HAVE_STRUCT_IPMREQ /* Only UDP and Raw Sockets can be used for Multicast */ -static apr_status_t mcast_check_type(apr_socket_t *sock) +static fspr_status_t mcast_check_type(fspr_socket_t *sock) { int type; - apr_status_t rv; + fspr_status_t rv; - rv = apr_socket_type_get(sock, &type); + rv = fspr_socket_type_get(sock, &type); if (rv != APR_SUCCESS) { return rv; @@ -45,8 +45,8 @@ static apr_status_t mcast_check_type(apr_socket_t *sock) } } -static void fill_mip_v4(struct ip_mreq *mip, apr_sockaddr_t *mcast, - apr_sockaddr_t *iface) +static void fill_mip_v4(struct ip_mreq *mip, fspr_sockaddr_t *mcast, + fspr_sockaddr_t *iface) { mip->imr_multiaddr = mcast->sa.sin.sin_addr; if (iface == NULL) { @@ -57,7 +57,7 @@ static void fill_mip_v4(struct ip_mreq *mip, apr_sockaddr_t *mcast, } } -static unsigned int find_if_index(const apr_sockaddr_t *iface) +static unsigned int find_if_index(const fspr_sockaddr_t *iface) { unsigned int index = 0; #if defined(HAVE_GETIFADDRS) && APR_HAVE_IPV6 @@ -92,8 +92,8 @@ static unsigned int find_if_index(const apr_sockaddr_t *iface) } #if APR_HAVE_IPV6 -static void fill_mip_v6(struct ipv6_mreq *mip, const apr_sockaddr_t *mcast, - const apr_sockaddr_t *iface) +static void fill_mip_v6(struct ipv6_mreq *mip, const fspr_sockaddr_t *mcast, + const fspr_sockaddr_t *iface) { memcpy(&mip->ipv6mr_multiaddr, mcast->ipaddr_ptr, sizeof(mip->ipv6mr_multiaddr)); @@ -107,7 +107,7 @@ static void fill_mip_v6(struct ipv6_mreq *mip, const apr_sockaddr_t *mcast, } #endif -static int sock_is_ipv4(apr_socket_t *sock) +static int sock_is_ipv4(fspr_socket_t *sock) { if (sock->local_addr->family == APR_INET) return 1; @@ -115,7 +115,7 @@ static int sock_is_ipv4(apr_socket_t *sock) } #if APR_HAVE_IPV6 -static int sock_is_ipv6(apr_socket_t *sock) +static int sock_is_ipv6(fspr_socket_t *sock) { if (sock->local_addr->family == APR_INET6) return 1; @@ -123,12 +123,12 @@ static int sock_is_ipv6(apr_socket_t *sock) } #endif -static apr_status_t do_mcast(int type, apr_socket_t *sock, - apr_sockaddr_t *mcast, apr_sockaddr_t *iface, - apr_sockaddr_t *source) +static fspr_status_t do_mcast(int type, fspr_socket_t *sock, + fspr_sockaddr_t *mcast, fspr_sockaddr_t *iface, + fspr_sockaddr_t *source) { struct ip_mreq mip4; - apr_status_t rv = APR_SUCCESS; + fspr_status_t rv = APR_SUCCESS; #if APR_HAVE_IPV6 struct ipv6_mreq mip6; #endif @@ -214,10 +214,10 @@ static apr_status_t do_mcast(int type, apr_socket_t *sock, return rv; } -static apr_status_t do_mcast_opt(int type, apr_socket_t *sock, - apr_byte_t value) +static fspr_status_t do_mcast_opt(int type, fspr_socket_t *sock, + fspr_byte_t value) { - apr_status_t rv = APR_SUCCESS; + fspr_status_t rv = APR_SUCCESS; rv = mcast_check_type(sock); @@ -262,10 +262,10 @@ static apr_status_t do_mcast_opt(int type, apr_socket_t *sock, } #endif -APR_DECLARE(apr_status_t) apr_mcast_join(apr_socket_t *sock, - apr_sockaddr_t *join, - apr_sockaddr_t *iface, - apr_sockaddr_t *source) +APR_DECLARE(fspr_status_t) fspr_mcast_join(fspr_socket_t *sock, + fspr_sockaddr_t *join, + fspr_sockaddr_t *iface, + fspr_sockaddr_t *source) { #if defined(IP_ADD_MEMBERSHIP) && defined(HAVE_STRUCT_IPMREQ) return do_mcast(IP_ADD_MEMBERSHIP, sock, join, iface, source); @@ -274,10 +274,10 @@ APR_DECLARE(apr_status_t) apr_mcast_join(apr_socket_t *sock, #endif } -APR_DECLARE(apr_status_t) apr_mcast_leave(apr_socket_t *sock, - apr_sockaddr_t *addr, - apr_sockaddr_t *iface, - apr_sockaddr_t *source) +APR_DECLARE(fspr_status_t) fspr_mcast_leave(fspr_socket_t *sock, + fspr_sockaddr_t *addr, + fspr_sockaddr_t *iface, + fspr_sockaddr_t *source) { #if defined(IP_DROP_MEMBERSHIP) && defined(HAVE_STRUCT_IPMREQ) return do_mcast(IP_DROP_MEMBERSHIP, sock, addr, iface, source); @@ -286,7 +286,7 @@ APR_DECLARE(apr_status_t) apr_mcast_leave(apr_socket_t *sock, #endif } -APR_DECLARE(apr_status_t) apr_mcast_hops(apr_socket_t *sock, apr_byte_t ttl) +APR_DECLARE(fspr_status_t) fspr_mcast_hops(fspr_socket_t *sock, fspr_byte_t ttl) { #if defined(IP_MULTICAST_TTL) && defined(HAVE_STRUCT_IPMREQ) return do_mcast_opt(IP_MULTICAST_TTL, sock, ttl); @@ -295,8 +295,8 @@ APR_DECLARE(apr_status_t) apr_mcast_hops(apr_socket_t *sock, apr_byte_t ttl) #endif } -APR_DECLARE(apr_status_t) apr_mcast_loopback(apr_socket_t *sock, - apr_byte_t opt) +APR_DECLARE(fspr_status_t) fspr_mcast_loopback(fspr_socket_t *sock, + fspr_byte_t opt) { #if defined(IP_MULTICAST_LOOP) && defined(HAVE_STRUCT_IPMREQ) return do_mcast_opt(IP_MULTICAST_LOOP, sock, opt); @@ -305,11 +305,11 @@ APR_DECLARE(apr_status_t) apr_mcast_loopback(apr_socket_t *sock, #endif } -APR_DECLARE(apr_status_t) apr_mcast_interface(apr_socket_t *sock, - apr_sockaddr_t *iface) +APR_DECLARE(fspr_status_t) fspr_mcast_interface(fspr_socket_t *sock, + fspr_sockaddr_t *iface) { #if defined(IP_MULTICAST_IF) && defined(HAVE_STRUCT_IPMREQ) - apr_status_t rv = APR_SUCCESS; + fspr_status_t rv = APR_SUCCESS; if (sock_is_ipv4(sock)) { if (setsockopt(sock->socketdes, IPPROTO_IP, IP_MULTICAST_IF, diff --git a/libs/apr/network_io/unix/sendrecv.c b/libs/apr/network_io/unix/sendrecv.c index ca7230accc..2015bf0bfc 100644 --- a/libs/apr/network_io/unix/sendrecv.c +++ b/libs/apr/network_io/unix/sendrecv.c @@ -14,12 +14,12 @@ * limitations under the License. */ -#include "apr_arch_networkio.h" -#include "apr_support.h" +#include "fspr_arch_networkio.h" +#include "fspr_support.h" #if APR_HAS_SENDFILE -/* This file is needed to allow us access to the apr_file_t internals. */ -#include "apr_arch_file_io.h" +/* This file is needed to allow us access to the fspr_file_t internals. */ +#include "fspr_arch_file_io.h" #endif /* APR_HAS_SENDFILE */ /* osreldate.h is only needed on FreeBSD for sendfile detection */ @@ -29,10 +29,10 @@ #include /* assert() */ -apr_status_t apr_socket_send(apr_socket_t *sock, const char *buf, - apr_size_t *len) +fspr_status_t fspr_socket_send(fspr_socket_t *sock, const char *buf, + fspr_size_t *len) { - apr_ssize_t rv; + fspr_ssize_t rv; if (sock->options & APR_INCOMPLETE_WRITE) { sock->options &= ~APR_INCOMPLETE_WRITE; @@ -45,9 +45,9 @@ apr_status_t apr_socket_send(apr_socket_t *sock, const char *buf, while (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK) && (sock->timeout > 0)) { - apr_status_t arv; + fspr_status_t arv; do_select: - arv = apr_wait_for_io_or_timeout(NULL, sock, 0); + arv = fspr_wait_for_io_or_timeout(NULL, sock, 0); if (arv != APR_SUCCESS) { *len = 0; return arv; @@ -69,10 +69,10 @@ do_select: return APR_SUCCESS; } -apr_status_t apr_socket_recv(apr_socket_t *sock, char *buf, apr_size_t *len) +fspr_status_t fspr_socket_recv(fspr_socket_t *sock, char *buf, fspr_size_t *len) { - apr_ssize_t rv; - apr_status_t arv; + fspr_ssize_t rv; + fspr_status_t arv; if (sock->options & APR_INCOMPLETE_READ) { sock->options &= ~APR_INCOMPLETE_READ; @@ -86,7 +86,7 @@ apr_status_t apr_socket_recv(apr_socket_t *sock, char *buf, apr_size_t *len) while ((rv == -1) && (errno == EAGAIN || errno == EWOULDBLOCK) && (sock->timeout > 0)) { do_select: - arv = apr_wait_for_io_or_timeout(NULL, sock, 1); + arv = fspr_wait_for_io_or_timeout(NULL, sock, 1); if (arv != APR_SUCCESS) { *len = 0; return arv; @@ -111,11 +111,11 @@ do_select: return APR_SUCCESS; } -apr_status_t apr_socket_sendto(apr_socket_t *sock, apr_sockaddr_t *where, - apr_int32_t flags, const char *buf, - apr_size_t *len) +fspr_status_t fspr_socket_sendto(fspr_socket_t *sock, fspr_sockaddr_t *where, + fspr_int32_t flags, const char *buf, + fspr_size_t *len) { - apr_ssize_t rv; + fspr_ssize_t rv; do { rv = sendto(sock->socketdes, buf, (*len), flags, @@ -125,7 +125,7 @@ apr_status_t apr_socket_sendto(apr_socket_t *sock, apr_sockaddr_t *where, while ((rv == -1) && (errno == EAGAIN || errno == EWOULDBLOCK) && (sock->timeout > 0)) { - apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 0); + fspr_status_t arv = fspr_wait_for_io_or_timeout(NULL, sock, 0); if (arv != APR_SUCCESS) { *len = 0; return arv; @@ -145,11 +145,11 @@ apr_status_t apr_socket_sendto(apr_socket_t *sock, apr_sockaddr_t *where, return APR_SUCCESS; } -apr_status_t apr_socket_recvfrom(apr_sockaddr_t *from, apr_socket_t *sock, - apr_int32_t flags, char *buf, - apr_size_t *len) +fspr_status_t fspr_socket_recvfrom(fspr_sockaddr_t *from, fspr_socket_t *sock, + fspr_int32_t flags, char *buf, + fspr_size_t *len) { - apr_ssize_t rv; + fspr_ssize_t rv; from->salen = sizeof(from->sa); @@ -160,7 +160,7 @@ apr_status_t apr_socket_recvfrom(apr_sockaddr_t *from, apr_socket_t *sock, while ((rv == -1) && (errno == EAGAIN || errno == EWOULDBLOCK) && (sock->timeout > 0)) { - apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 1); + fspr_status_t arv = fspr_wait_for_io_or_timeout(NULL, sock, 1); if (arv != APR_SUCCESS) { *len = 0; return arv; @@ -176,7 +176,7 @@ apr_status_t apr_socket_recvfrom(apr_sockaddr_t *from, apr_socket_t *sock, return errno; } - apr_sockaddr_vars_set(from, from->sa.sin.sin_family, ntohs(from->sa.sin.sin_port)); + fspr_sockaddr_vars_set(from, from->sa.sin.sin_family, ntohs(from->sa.sin.sin_port)); (*len) = rv; if (rv == 0 && sock->type == SOCK_STREAM) { @@ -186,13 +186,13 @@ apr_status_t apr_socket_recvfrom(apr_sockaddr_t *from, apr_socket_t *sock, return APR_SUCCESS; } -apr_status_t apr_socket_sendv(apr_socket_t * sock, const struct iovec *vec, - apr_int32_t nvec, apr_size_t *len) +fspr_status_t fspr_socket_sendv(fspr_socket_t * sock, const struct iovec *vec, + fspr_int32_t nvec, fspr_size_t *len) { #ifdef HAVE_WRITEV - apr_ssize_t rv; - apr_size_t requested_len = 0; - apr_int32_t i; + fspr_ssize_t rv; + fspr_size_t requested_len = 0; + fspr_int32_t i; for (i = 0; i < nvec; i++) { requested_len += vec[i].iov_len; @@ -209,9 +209,9 @@ apr_status_t apr_socket_sendv(apr_socket_t * sock, const struct iovec *vec, while ((rv == -1) && (errno == EAGAIN || errno == EWOULDBLOCK) && (sock->timeout > 0)) { - apr_status_t arv; + fspr_status_t arv; do_select: - arv = apr_wait_for_io_or_timeout(NULL, sock, 0); + arv = fspr_wait_for_io_or_timeout(NULL, sock, 0); if (arv != APR_SUCCESS) { *len = 0; return arv; @@ -233,7 +233,7 @@ do_select: return APR_SUCCESS; #else *len = vec[0].iov_len; - return apr_socket_send(sock, vec[0].iov_base, len); + return fspr_socket_send(sock, vec[0].iov_base, len); #endif } @@ -245,27 +245,27 @@ do_select: /* TODO: what should flags be? int_32? */ /* Define a structure to pass in when we have a NULL header value */ -static apr_hdtr_t no_hdtr; +static fspr_hdtr_t no_hdtr; #if defined(__linux__) && defined(HAVE_WRITEV) -apr_status_t apr_socket_sendfile(apr_socket_t *sock, apr_file_t *file, - apr_hdtr_t *hdtr, apr_off_t *offset, - apr_size_t *len, apr_int32_t flags) +fspr_status_t fspr_socket_sendfile(fspr_socket_t *sock, fspr_file_t *file, + fspr_hdtr_t *hdtr, fspr_off_t *offset, + fspr_size_t *len, fspr_int32_t flags) { int rv, nbytes = 0, total_hdrbytes, i; - apr_status_t arv; + fspr_status_t arv; #if APR_HAS_LARGE_FILES && defined(HAVE_SENDFILE64) - apr_off_t off = *offset; + fspr_off_t off = *offset; #define sendfile sendfile64 #elif APR_HAS_LARGE_FILES && SIZEOF_OFF_T == 4 - /* 64-bit apr_off_t but no sendfile64(): fail if trying to send + /* 64-bit fspr_off_t but no sendfile64(): fail if trying to send * past the 2Gb limit. */ off_t off; - if ((apr_int64_t)*offset + *len > INT_MAX) { + if ((fspr_int64_t)*offset + *len > INT_MAX) { return EINVAL; } @@ -292,16 +292,16 @@ apr_status_t apr_socket_sendfile(apr_socket_t *sock, apr_file_t *file, assert(flags==0); if (hdtr->numheaders > 0) { - apr_size_t hdrbytes; + fspr_size_t hdrbytes; /* cork before writing headers */ - rv = apr_socket_opt_set(sock, APR_TCP_NOPUSH, 1); + rv = fspr_socket_opt_set(sock, APR_TCP_NOPUSH, 1); if (rv != APR_SUCCESS) { return rv; } /* Now write the headers */ - arv = apr_socket_sendv(sock, hdtr->headers, hdtr->numheaders, + arv = fspr_socket_sendv(sock, hdtr->headers, hdtr->numheaders, &hdrbytes); if (arv != APR_SUCCESS) { *len = 0; @@ -319,7 +319,7 @@ apr_status_t apr_socket_sendfile(apr_socket_t *sock, apr_file_t *file, } if (hdrbytes < total_hdrbytes) { *len = hdrbytes; - return apr_socket_opt_set(sock, APR_TCP_NOPUSH, 0); + return fspr_socket_opt_set(sock, APR_TCP_NOPUSH, 0); } } @@ -338,7 +338,7 @@ apr_status_t apr_socket_sendfile(apr_socket_t *sock, apr_file_t *file, while ((rv == -1) && (errno == EAGAIN || errno == EWOULDBLOCK) && (sock->timeout > 0)) { do_select: - arv = apr_wait_for_io_or_timeout(NULL, sock, 0); + arv = fspr_wait_for_io_or_timeout(NULL, sock, 0); if (arv != APR_SUCCESS) { *len = 0; return arv; @@ -356,7 +356,7 @@ do_select: if (rv == -1) { *len = nbytes; rv = errno; - apr_socket_opt_set(sock, APR_TCP_NOPUSH, 0); + fspr_socket_opt_set(sock, APR_TCP_NOPUSH, 0); return rv; } @@ -364,7 +364,7 @@ do_select: if (rv < *len) { *len = nbytes; - arv = apr_socket_opt_set(sock, APR_TCP_NOPUSH, 0); + arv = fspr_socket_opt_set(sock, APR_TCP_NOPUSH, 0); if (rv > 0) { /* If this was a partial write, return now with the @@ -388,19 +388,19 @@ do_select: /* Now write the footers */ if (hdtr->numtrailers > 0) { - apr_size_t trbytes; - arv = apr_socket_sendv(sock, hdtr->trailers, hdtr->numtrailers, + fspr_size_t trbytes; + arv = fspr_socket_sendv(sock, hdtr->trailers, hdtr->numtrailers, &trbytes); nbytes += trbytes; if (arv != APR_SUCCESS) { *len = nbytes; rv = errno; - apr_socket_opt_set(sock, APR_TCP_NOPUSH, 0); + fspr_socket_opt_set(sock, APR_TCP_NOPUSH, 0); return rv; } } - apr_socket_opt_set(sock, APR_TCP_NOPUSH, 0); + fspr_socket_opt_set(sock, APR_TCP_NOPUSH, 0); (*len) = nbytes; return rv < 0 ? errno : APR_SUCCESS; @@ -409,11 +409,11 @@ do_select: #elif defined(DARWIN) /* OS/X Release 10.5 or greater */ -apr_status_t apr_socket_sendfile(apr_socket_t * sock, apr_file_t * file, - apr_hdtr_t * hdtr, apr_off_t * offset, - apr_size_t * len, apr_int32_t flags) +fspr_status_t fspr_socket_sendfile(fspr_socket_t * sock, fspr_file_t * file, + fspr_hdtr_t * hdtr, fspr_off_t * offset, + fspr_size_t * len, fspr_int32_t flags) { - apr_off_t nbytes = *len; + fspr_off_t nbytes = *len; int rv; struct sf_hdtr headerstruct; @@ -432,9 +432,9 @@ apr_status_t apr_socket_sendfile(apr_socket_t * sock, apr_file_t * file, /* BSD can send the headers/footers as part of the system call */ do { if (sock->options & APR_INCOMPLETE_WRITE) { - apr_status_t arv; + fspr_status_t arv; sock->options &= ~APR_INCOMPLETE_WRITE; - arv = apr_wait_for_io_or_timeout(NULL, sock, 0); + arv = fspr_wait_for_io_or_timeout(NULL, sock, 0); if (arv != APR_SUCCESS) { *len = 0; return arv; @@ -494,7 +494,7 @@ apr_status_t apr_socket_sendfile(apr_socket_t * sock, apr_file_t * file, } if ((rv == -1) && (errno == EAGAIN) && (sock->timeout > 0)) { - apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 0); + fspr_status_t arv = fspr_wait_for_io_or_timeout(NULL, sock, 0); if (arv != APR_SUCCESS) { *len = 0; return arv; @@ -512,9 +512,9 @@ apr_status_t apr_socket_sendfile(apr_socket_t * sock, apr_file_t * file, #elif defined(__FreeBSD__) || defined(__DragonFly__) /* Release 3.1 or greater */ -apr_status_t apr_socket_sendfile(apr_socket_t * sock, apr_file_t * file, - apr_hdtr_t * hdtr, apr_off_t * offset, - apr_size_t * len, apr_int32_t flags) +fspr_status_t fspr_socket_sendfile(fspr_socket_t * sock, fspr_file_t * file, + fspr_hdtr_t * hdtr, fspr_off_t * offset, + fspr_size_t * len, fspr_int32_t flags) { off_t nbytes = 0; int rv; @@ -522,7 +522,7 @@ apr_status_t apr_socket_sendfile(apr_socket_t * sock, apr_file_t * file, int i; #endif struct sf_hdtr headerstruct; - apr_size_t bytes_to_send = *len; + fspr_size_t bytes_to_send = *len; /* Ignore flags for now. */ flags = 0; @@ -555,9 +555,9 @@ apr_status_t apr_socket_sendfile(apr_socket_t * sock, apr_file_t * file, /* FreeBSD can send the headers/footers as part of the system call */ do { if (sock->options & APR_INCOMPLETE_WRITE) { - apr_status_t arv; + fspr_status_t arv; sock->options &= ~APR_INCOMPLETE_WRITE; - arv = apr_wait_for_io_or_timeout(NULL, sock, 0); + arv = fspr_wait_for_io_or_timeout(NULL, sock, 0); if (arv != APR_SUCCESS) { *len = 0; return arv; @@ -618,7 +618,7 @@ apr_status_t apr_socket_sendfile(apr_socket_t * sock, apr_file_t * file, } if ((rv == -1) && (errno == EAGAIN) && (sock->timeout > 0)) { - apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 0); + fspr_status_t arv = fspr_wait_for_io_or_timeout(NULL, sock, 0); if (arv != APR_SUCCESS) { *len = 0; return arv; @@ -639,13 +639,13 @@ apr_status_t apr_socket_sendfile(apr_socket_t * sock, apr_file_t * file, sendfile(int fd, int s, off_t offset, off_t *len, struct sf_hdtr *hdtr, int flags); */ -apr_status_t apr_socket_sendfile(apr_socket_t * sock, apr_file_t * file, - apr_hdtr_t * hdtr, apr_off_t * offset, - apr_size_t * len, apr_int32_t flags) +fspr_status_t fspr_socket_sendfile(fspr_socket_t * sock, fspr_file_t * file, + fspr_hdtr_t * hdtr, fspr_off_t * offset, + fspr_size_t * len, fspr_int32_t flags) { int rv, i; struct sf_hdtr headerstruct; - apr_off_t bytes_to_send = *len; + fspr_off_t bytes_to_send = *len; /* Ignore flags for now. */ flags = 0; @@ -670,9 +670,9 @@ apr_status_t apr_socket_sendfile(apr_socket_t * sock, apr_file_t * file, do { if (sock->options & APR_INCOMPLETE_WRITE) { - apr_status_t arv; + fspr_status_t arv; sock->options &= ~APR_INCOMPLETE_WRITE; - arv = apr_wait_for_io_or_timeout(NULL, sock, 0); + arv = fspr_wait_for_io_or_timeout(NULL, sock, 0); if (arv != APR_SUCCESS) { *len = 0; return arv; @@ -736,7 +736,7 @@ apr_status_t apr_socket_sendfile(apr_socket_t * sock, apr_file_t * file, } if ((rv == -1) && (errno == EAGAIN) && (sock->timeout > 0)) { - apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 0); + fspr_status_t arv = fspr_wait_for_io_or_timeout(NULL, sock, 0); if (arv != APR_SUCCESS) { *len = 0; return arv; @@ -767,32 +767,32 @@ apr_status_t apr_socket_sendfile(apr_socket_t * sock, apr_file_t * file, * if nbytes == 0, the rest of the file (from offset) is sent */ -apr_status_t apr_socket_sendfile(apr_socket_t *sock, apr_file_t *file, - apr_hdtr_t *hdtr, apr_off_t *offset, - apr_size_t *len, apr_int32_t flags) +fspr_status_t fspr_socket_sendfile(fspr_socket_t *sock, fspr_file_t *file, + fspr_hdtr_t *hdtr, fspr_off_t *offset, + fspr_size_t *len, fspr_int32_t flags) { int i; - apr_ssize_t rc; - apr_size_t nbytes = *len, headerlen, trailerlen; + fspr_ssize_t rc; + fspr_size_t nbytes = *len, headerlen, trailerlen; struct iovec hdtrarray[2]; char *headerbuf, *trailerbuf; #if APR_HAS_LARGE_FILES && defined(HAVE_SENDFILE64) /* later HP-UXes have a sendfile64() */ #define sendfile sendfile64 - apr_off_t off = *offset; + fspr_off_t off = *offset; #elif APR_HAS_LARGE_FILES && SIZEOF_OFF_T == 4 /* HP-UX 11.00 doesn't have a sendfile64(): fail if trying to send * past the 2Gb limit */ off_t off; - if ((apr_int64_t)*offset + *len > INT_MAX) { + if ((fspr_int64_t)*offset + *len > INT_MAX) { return EINVAL; } off = *offset; #else - apr_off_t off = *offset; + fspr_off_t off = *offset; #endif if (!hdtr) { @@ -821,7 +821,7 @@ apr_status_t apr_socket_sendfile(apr_socket_t *sock, apr_file_t *file, } /* XXX: BUHHH? wow, what a memory leak! */ - headerbuf = hdtrarray[0].iov_base = apr_palloc(sock->pool, headerlen); + headerbuf = hdtrarray[0].iov_base = fspr_palloc(sock->pool, headerlen); hdtrarray[0].iov_len = headerlen; for (i = 0; i < hdtr->numheaders; i++) { @@ -846,7 +846,7 @@ apr_status_t apr_socket_sendfile(apr_socket_t *sock, apr_file_t *file, } /* XXX: BUHHH? wow, what a memory leak! */ - trailerbuf = hdtrarray[1].iov_base = apr_palloc(sock->pool, trailerlen); + trailerbuf = hdtrarray[1].iov_base = fspr_palloc(sock->pool, trailerlen); hdtrarray[1].iov_len = trailerlen; for (i = 0; i < hdtr->numtrailers; i++) { @@ -872,7 +872,7 @@ apr_status_t apr_socket_sendfile(apr_socket_t *sock, apr_file_t *file, while ((rc == -1) && (errno == EAGAIN || errno == EWOULDBLOCK) && (sock->timeout > 0)) { - apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 0); + fspr_status_t arv = fspr_wait_for_io_or_timeout(NULL, sock, 0); if (arv != APR_SUCCESS) { *len = 0; @@ -915,13 +915,13 @@ apr_status_t apr_socket_sendfile(apr_socket_t *sock, apr_file_t *file, * AIX - version 4.3.2 with APAR IX85388, or version 4.3.3 and above * OS/390 - V2R7 and above */ -apr_status_t apr_socket_sendfile(apr_socket_t * sock, apr_file_t * file, - apr_hdtr_t * hdtr, apr_off_t * offset, - apr_size_t * len, apr_int32_t flags) +fspr_status_t fspr_socket_sendfile(fspr_socket_t * sock, fspr_file_t * file, + fspr_hdtr_t * hdtr, fspr_off_t * offset, + fspr_size_t * len, fspr_int32_t flags) { int i, ptr, rv = 0; void * hbuf=NULL, * tbuf=NULL; - apr_status_t arv; + fspr_status_t arv; struct sf_parms parms; if (!hdtr) { @@ -951,13 +951,13 @@ apr_status_t apr_socket_sendfile(apr_socket_t * sock, apr_file_t * file, parms.header_length += hdtr->headers[i].iov_len; } #if 0 - /* Keepalives make apr_palloc a bad idea */ + /* Keepalives make fspr_palloc a bad idea */ hbuf = malloc(parms.header_length); #else /* but headers are small, so maybe we can hold on to the * memory for the life of the socket... */ - hbuf = apr_palloc(sock->pool, parms.header_length); + hbuf = fspr_palloc(sock->pool, parms.header_length); #endif ptr = 0; for (i = 0; i < hdtr->numheaders; i++) { @@ -980,10 +980,10 @@ apr_status_t apr_socket_sendfile(apr_socket_t * sock, apr_file_t * file, parms.trailer_length += hdtr->trailers[i].iov_len; } #if 0 - /* Keepalives make apr_palloc a bad idea */ + /* Keepalives make fspr_palloc a bad idea */ tbuf = malloc(parms.trailer_length); #else - tbuf = apr_palloc(sock->pool, parms.trailer_length); + tbuf = fspr_palloc(sock->pool, parms.trailer_length); #endif ptr = 0; for (i = 0; i < hdtr->numtrailers; i++) { @@ -1020,7 +1020,7 @@ apr_status_t apr_socket_sendfile(apr_socket_t * sock, apr_file_t * file, while ((rv == -1) && (errno == EAGAIN || errno == EWOULDBLOCK) && (sock->timeout > 0)) { do_select: - arv = apr_wait_for_io_or_timeout(NULL, sock, 0); + arv = fspr_wait_for_io_or_timeout(NULL, sock, 0); if (arv != APR_SUCCESS) { *len = 0; return arv; @@ -1077,15 +1077,15 @@ do_select: #define sendfilev sendfilev64 #endif -apr_status_t apr_socket_sendfile(apr_socket_t *sock, apr_file_t *file, - apr_hdtr_t *hdtr, apr_off_t *offset, - apr_size_t *len, apr_int32_t flags) +fspr_status_t fspr_socket_sendfile(fspr_socket_t *sock, fspr_file_t *file, + fspr_hdtr_t *hdtr, fspr_off_t *offset, + fspr_size_t *len, fspr_int32_t flags) { - apr_status_t rv, arv; - apr_size_t nbytes; + fspr_status_t rv, arv; + fspr_size_t nbytes; sendfilevec_t *sfv; int vecs, curvec, i, repeat; - apr_size_t requested_len = 0; + fspr_size_t requested_len = 0; if (!hdtr) { hdtr = &no_hdtr; @@ -1096,7 +1096,7 @@ apr_status_t apr_socket_sendfile(apr_socket_t *sock, apr_file_t *file, /* Calculate how much space we need. */ vecs = hdtr->numheaders + hdtr->numtrailers + 1; - sfv = apr_palloc(sock->pool, sizeof(sendfilevec_t) * vecs); + sfv = fspr_palloc(sock->pool, sizeof(sendfilevec_t) * vecs); curvec = 0; @@ -1140,7 +1140,7 @@ apr_status_t apr_socket_sendfile(apr_socket_t *sock, apr_file_t *file, */ if (sock->options & APR_INCOMPLETE_WRITE) { sock->options &= ~APR_INCOMPLETE_WRITE; - arv = apr_wait_for_io_or_timeout(NULL, sock, 0); + arv = fspr_wait_for_io_or_timeout(NULL, sock, 0); if (arv != APR_SUCCESS) { *len = 0; return arv; @@ -1170,7 +1170,7 @@ apr_status_t apr_socket_sendfile(apr_socket_t *sock, apr_file_t *file, rv = 0; } else if (!arv && (sock->timeout > 0)) { - apr_status_t t = apr_wait_for_io_or_timeout(NULL, sock, 0); + fspr_status_t t = fspr_wait_for_io_or_timeout(NULL, sock, 0); if (t != APR_SUCCESS) { *len = 0; @@ -1198,7 +1198,7 @@ apr_status_t apr_socket_sendfile(apr_socket_t *sock, apr_file_t *file, #else #error APR has detected sendfile on your system, but nobody has written a #error version of it for APR yet. To get past this, either write -#error apr_socket_sendfile or change APR_HAS_SENDFILE in apr.h to 0. +#error fspr_socket_sendfile or change APR_HAS_SENDFILE in apr.h to 0. #endif /* __linux__, __FreeBSD__, __DragonFly__, __HPUX__, _AIX, __MVS__, Tru64/OSF1 */ diff --git a/libs/apr/network_io/unix/sockaddr.c b/libs/apr/network_io/unix/sockaddr.c index 33d2400a74..fd9aae8108 100644 --- a/libs/apr/network_io/unix/sockaddr.c +++ b/libs/apr/network_io/unix/sockaddr.c @@ -14,28 +14,28 @@ * limitations under the License. */ -#include "apr_arch_networkio.h" -#include "apr_strings.h" -#include "apr.h" -#include "apr_lib.h" -#include "apr_strings.h" -#include "apr_private.h" +#include "fspr_arch_networkio.h" +#include "fspr_strings.h" +#include "fspr.h" +#include "fspr_lib.h" +#include "fspr_strings.h" +#include "fspr_private.h" #if APR_HAVE_STDLIB_H #include #endif #define APR_WANT_STRFUNC -#include "apr_want.h" +#include "fspr_want.h" -struct apr_ipsubnet_t { +struct fspr_ipsubnet_t { int family; #if APR_HAVE_IPV6 - apr_uint32_t sub[4]; /* big enough for IPv4 and IPv6 addresses */ - apr_uint32_t mask[4]; + fspr_uint32_t sub[4]; /* big enough for IPv4 and IPv6 addresses */ + fspr_uint32_t mask[4]; #else - apr_uint32_t sub[1]; - apr_uint32_t mask[1]; + fspr_uint32_t sub[1]; + fspr_uint32_t mask[1]; #endif }; @@ -68,12 +68,12 @@ static void *getservbyname(const char *name, const char *proto) } #endif -static apr_status_t get_local_addr(apr_socket_t *sock) +static fspr_status_t get_local_addr(fspr_socket_t *sock) { sock->local_addr->salen = sizeof(sock->local_addr->sa); if (getsockname(sock->socketdes, (struct sockaddr *)&sock->local_addr->sa, &sock->local_addr->salen) < 0) { - return apr_get_netos_error(); + return fspr_get_netos_error(); } else { sock->local_port_unknown = sock->local_interface_unknown = 0; @@ -83,12 +83,12 @@ static apr_status_t get_local_addr(apr_socket_t *sock) } } -static apr_status_t get_remote_addr(apr_socket_t *sock) +static fspr_status_t get_remote_addr(fspr_socket_t *sock) { sock->remote_addr->salen = sizeof(sock->remote_addr->sa); if (getpeername(sock->socketdes, (struct sockaddr *)&sock->remote_addr->sa, &sock->remote_addr->salen) < 0) { - return apr_get_netos_error(); + return fspr_get_netos_error(); } else { sock->remote_addr_unknown = 0; @@ -98,11 +98,11 @@ static apr_status_t get_remote_addr(apr_socket_t *sock) } } -APR_DECLARE(apr_status_t) apr_sockaddr_ip_get(char **addr, - apr_sockaddr_t *sockaddr) +APR_DECLARE(fspr_status_t) fspr_sockaddr_ip_get(char **addr, + fspr_sockaddr_t *sockaddr) { - *addr = apr_palloc(sockaddr->pool, sockaddr->addr_str_len); - apr_inet_ntop(sockaddr->family, + *addr = fspr_palloc(sockaddr->pool, sockaddr->addr_str_len); + fspr_inet_ntop(sockaddr->family, sockaddr->ipaddr_ptr, *addr, sockaddr->addr_str_len); @@ -119,7 +119,7 @@ APR_DECLARE(apr_status_t) apr_sockaddr_ip_get(char **addr, return APR_SUCCESS; } -void apr_sockaddr_vars_set(apr_sockaddr_t *addr, int family, apr_port_t port) +void fspr_sockaddr_vars_set(fspr_sockaddr_t *addr, int family, fspr_port_t port) { addr->family = family; addr->sa.sin.sin_family = family; @@ -145,13 +145,13 @@ void apr_sockaddr_vars_set(apr_sockaddr_t *addr, int family, apr_port_t port) #endif } -APR_DECLARE(apr_status_t) apr_socket_addr_get(apr_sockaddr_t **sa, - apr_interface_e which, - apr_socket_t *sock) +APR_DECLARE(fspr_status_t) fspr_socket_addr_get(fspr_sockaddr_t **sa, + fspr_interface_e which, + fspr_socket_t *sock) { if (which == APR_LOCAL) { if (sock->local_interface_unknown || sock->local_port_unknown) { - apr_status_t rv = get_local_addr(sock); + fspr_status_t rv = get_local_addr(sock); if (rv != APR_SUCCESS) { return rv; @@ -161,7 +161,7 @@ APR_DECLARE(apr_status_t) apr_socket_addr_get(apr_sockaddr_t **sa, } else if (which == APR_REMOTE) { if (sock->remote_addr_unknown) { - apr_status_t rv = get_remote_addr(sock); + fspr_status_t rv = get_remote_addr(sock); if (rv != APR_SUCCESS) { return rv; @@ -176,15 +176,15 @@ APR_DECLARE(apr_status_t) apr_socket_addr_get(apr_sockaddr_t **sa, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_parse_addr_port(char **addr, +APR_DECLARE(fspr_status_t) fspr_parse_addr_port(char **addr, char **scope_id, - apr_port_t *port, + fspr_port_t *port, const char *str, - apr_pool_t *p) + fspr_pool_t *p) { const char *ch, *lastchar; int big_port; - apr_size_t addrlen; + fspr_size_t addrlen; *addr = NULL; /* assume not specified */ *scope_id = NULL; /* assume not specified */ @@ -194,7 +194,7 @@ APR_DECLARE(apr_status_t) apr_parse_addr_port(char **addr, * is specified in the string. */ ch = lastchar = str + strlen(str) - 1; - while (ch >= str && apr_isdigit(*ch)) { + while (ch >= str && fspr_isdigit(*ch)) { --ch; } @@ -245,7 +245,7 @@ APR_DECLARE(apr_status_t) apr_parse_addr_port(char **addr, return APR_EINVAL; } addrlen = scope_delim - str - 1; - *scope_id = apr_palloc(p, end_bracket - scope_delim); + *scope_id = fspr_palloc(p, end_bracket - scope_delim); memcpy(*scope_id, scope_delim + 1, end_bracket - scope_delim - 1); (*scope_id)[end_bracket - scope_delim - 1] = '\0'; } @@ -253,12 +253,12 @@ APR_DECLARE(apr_status_t) apr_parse_addr_port(char **addr, addrlen = addrlen - 2; /* minus 2 for '[' and ']' */ } - *addr = apr_palloc(p, addrlen + 1); + *addr = fspr_palloc(p, addrlen + 1); memcpy(*addr, str + 1, addrlen); (*addr)[addrlen] = '\0'; - if (apr_inet_pton(AF_INET6, *addr, &ipaddr) != 1) { + if (fspr_inet_pton(AF_INET6, *addr, &ipaddr) != 1) { *addr = NULL; *scope_id = NULL; *port = 0; @@ -271,7 +271,7 @@ APR_DECLARE(apr_status_t) apr_parse_addr_port(char **addr, /* XXX If '%' is not a valid char in a DNS name, we *could* check * for bogus scope ids first. */ - *addr = apr_palloc(p, addrlen + 1); + *addr = fspr_palloc(p, addrlen + 1); memcpy(*addr, str, addrlen); (*addr)[addrlen] = '\0'; } @@ -280,13 +280,13 @@ APR_DECLARE(apr_status_t) apr_parse_addr_port(char **addr, #if defined(HAVE_GETADDRINFO) -static apr_status_t call_resolver(apr_sockaddr_t **sa, - const char *hostname, apr_int32_t family, - apr_port_t port, apr_int32_t flags, - apr_pool_t *p) +static fspr_status_t call_resolver(fspr_sockaddr_t **sa, + const char *hostname, fspr_int32_t family, + fspr_port_t port, fspr_int32_t flags, + fspr_pool_t *p) { struct addrinfo hints, *ai, *ai_list; - apr_sockaddr_t *prev_sa; + fspr_sockaddr_t *prev_sa; int error; char *servname = NULL; @@ -331,7 +331,7 @@ static apr_status_t call_resolver(apr_sockaddr_t **sa, } else #endif /* _AIX */ - servname = apr_itoa(p, port); + servname = fspr_itoa(p, port); #endif /* OSF1 */ } error = getaddrinfo(hostname, servname, &hints, &ai_list); @@ -365,7 +365,7 @@ static apr_status_t call_resolver(apr_sockaddr_t **sa, prev_sa = NULL; ai = ai_list; while (ai) { /* while more addresses to report */ - apr_sockaddr_t *new_sa; + fspr_sockaddr_t *new_sa; /* Ignore anything bogus: getaddrinfo in some old versions of * glibc will return AF_UNIX entries for APR_UNSPEC+AI_PASSIVE @@ -375,15 +375,15 @@ static apr_status_t call_resolver(apr_sockaddr_t **sa, continue; } - new_sa = apr_pcalloc(p, sizeof(apr_sockaddr_t)); + new_sa = fspr_pcalloc(p, sizeof(fspr_sockaddr_t)); new_sa->pool = p; memcpy(&new_sa->sa, ai->ai_addr, ai->ai_addrlen); - apr_sockaddr_vars_set(new_sa, ai->ai_family, port); + fspr_sockaddr_vars_set(new_sa, ai->ai_family, port); if (!prev_sa) { /* first element in new list */ if (hostname) { - new_sa->hostname = apr_pstrdup(p, hostname); + new_sa->hostname = fspr_pstrdup(p, hostname); } *sa = new_sa; } @@ -399,13 +399,13 @@ static apr_status_t call_resolver(apr_sockaddr_t **sa, return APR_SUCCESS; } -static apr_status_t find_addresses(apr_sockaddr_t **sa, - const char *hostname, apr_int32_t family, - apr_port_t port, apr_int32_t flags, - apr_pool_t *p) +static fspr_status_t find_addresses(fspr_sockaddr_t **sa, + const char *hostname, fspr_int32_t family, + fspr_port_t port, fspr_int32_t flags, + fspr_pool_t *p) { if (flags & APR_IPV4_ADDR_OK) { - apr_status_t error = call_resolver(sa, hostname, AF_INET, port, flags, p); + fspr_status_t error = call_resolver(sa, hostname, AF_INET, port, flags, p); #if APR_HAVE_IPV6 if (error) { @@ -417,7 +417,7 @@ static apr_status_t find_addresses(apr_sockaddr_t **sa, } #if APR_HAVE_IPV6 else if (flags & APR_IPV6_ADDR_OK) { - apr_status_t error = call_resolver(sa, hostname, AF_INET6, port, flags, p); + fspr_status_t error = call_resolver(sa, hostname, AF_INET6, port, flags, p); if (error) { family = AF_INET; /* try again */ @@ -433,13 +433,13 @@ static apr_status_t find_addresses(apr_sockaddr_t **sa, #else /* end of HAVE_GETADDRINFO code */ -static apr_status_t find_addresses(apr_sockaddr_t **sa, - const char *hostname, apr_int32_t family, - apr_port_t port, apr_int32_t flags, - apr_pool_t *p) +static fspr_status_t find_addresses(fspr_sockaddr_t **sa, + const char *hostname, fspr_int32_t family, + fspr_port_t port, fspr_int32_t flags, + fspr_pool_t *p) { struct hostent *hp; - apr_sockaddr_t *prev_sa; + fspr_sockaddr_t *prev_sa; int curaddr; #if APR_HAS_THREADS && !defined(GETHOSTBYNAME_IS_THREAD_SAFE) && \ defined(HAVE_GETHOSTBYNAME_R) && !defined(BEOS) @@ -498,7 +498,7 @@ static apr_status_t find_addresses(apr_sockaddr_t **sa, if (!hp) { #ifdef WIN32 - return apr_get_netos_error(); + return fspr_get_netos_error(); #else return (h_errno + APR_OS_START_SYSERR); #endif @@ -508,15 +508,15 @@ static apr_status_t find_addresses(apr_sockaddr_t **sa, prev_sa = NULL; curaddr = 0; while (hp->h_addr_list[curaddr]) { - apr_sockaddr_t *new_sa = apr_pcalloc(p, sizeof(apr_sockaddr_t)); + fspr_sockaddr_t *new_sa = fspr_pcalloc(p, sizeof(fspr_sockaddr_t)); new_sa->pool = p; new_sa->sa.sin.sin_addr = *(struct in_addr *)hp->h_addr_list[curaddr]; - apr_sockaddr_vars_set(new_sa, AF_INET, port); + fspr_sockaddr_vars_set(new_sa, AF_INET, port); if (!prev_sa) { /* first element in new list */ if (orig_hostname) { - new_sa->hostname = apr_pstrdup(p, orig_hostname); + new_sa->hostname = fspr_pstrdup(p, orig_hostname); } *sa = new_sa; } @@ -534,12 +534,12 @@ static apr_status_t find_addresses(apr_sockaddr_t **sa, #endif /* end of !HAVE_GETADDRINFO code */ -APR_DECLARE(apr_status_t) apr_sockaddr_info_get(apr_sockaddr_t **sa, +APR_DECLARE(fspr_status_t) fspr_sockaddr_info_get(fspr_sockaddr_t **sa, const char *hostname, - apr_int32_t family, apr_port_t port, - apr_int32_t flags, apr_pool_t *p) + fspr_int32_t family, fspr_port_t port, + fspr_int32_t flags, fspr_pool_t *p) { - apr_int32_t masked; + fspr_int32_t masked; *sa = NULL; if ((masked = flags & (APR_IPV4_ADDR_OK | APR_IPV6_ADDR_OK))) { @@ -568,9 +568,9 @@ APR_DECLARE(apr_status_t) apr_sockaddr_info_get(apr_sockaddr_t **sa, return find_addresses(sa, hostname, family, port, flags, p); } -APR_DECLARE(apr_status_t) apr_getnameinfo(char **hostname, - apr_sockaddr_t *sockaddr, - apr_int32_t flags) +APR_DECLARE(fspr_status_t) fspr_getnameinfo(char **hostname, + fspr_sockaddr_t *sockaddr, + fspr_int32_t flags) { #if defined(HAVE_GETNAMEINFO) int rc; @@ -597,7 +597,7 @@ APR_DECLARE(apr_status_t) apr_getnameinfo(char **hostname, struct sockaddr_in tmpsa; tmpsa.sin_family = AF_INET; tmpsa.sin_port = 0; - tmpsa.sin_addr.s_addr = ((apr_uint32_t *)sockaddr->ipaddr_ptr)[3]; + tmpsa.sin_addr.s_addr = ((fspr_uint32_t *)sockaddr->ipaddr_ptr)[3]; #ifdef SIN6_LEN tmpsa.sin_len = sizeof(tmpsa); #endif @@ -635,7 +635,7 @@ APR_DECLARE(apr_status_t) apr_getnameinfo(char **hostname, return rc + APR_OS_START_EAIERR; /* return the EAI_ error */ } } - *hostname = sockaddr->hostname = apr_pstrdup(sockaddr->pool, + *hostname = sockaddr->hostname = fspr_pstrdup(sockaddr->pool, tmphostname); return APR_SUCCESS; #else @@ -678,12 +678,12 @@ APR_DECLARE(apr_status_t) apr_getnameinfo(char **hostname, #endif if (hptr) { - *hostname = sockaddr->hostname = apr_pstrdup(sockaddr->pool, hptr->h_name); + *hostname = sockaddr->hostname = fspr_pstrdup(sockaddr->pool, hptr->h_name); return APR_SUCCESS; } *hostname = NULL; #if defined(WIN32) - return apr_get_netos_error(); + return fspr_get_netos_error(); #elif defined(OS2) return h_errno; #else @@ -692,7 +692,7 @@ APR_DECLARE(apr_status_t) apr_getnameinfo(char **hostname, #endif } -APR_DECLARE(apr_status_t) apr_getservbyname(apr_sockaddr_t *sockaddr, +APR_DECLARE(fspr_status_t) fspr_getservbyname(fspr_sockaddr_t *sockaddr, const char *servname) { struct servent *se; @@ -702,7 +702,7 @@ APR_DECLARE(apr_status_t) apr_getservbyname(apr_sockaddr_t *sockaddr, if ((se = getservbyname(servname, NULL)) != NULL){ sockaddr->port = htons(se->s_port); - sockaddr->servname = apr_pstrdup(sockaddr->pool, servname); + sockaddr->servname = fspr_pstrdup(sockaddr->pool, servname); sockaddr->sa.sin.sin_port = se->s_port; return APR_SUCCESS; } @@ -717,8 +717,8 @@ APR_DECLARE(apr_status_t) apr_getservbyname(apr_sockaddr_t *sockaddr, &((struct in6_addr *)(b)->ipaddr_ptr)->s6_addr[12], \ (a)->ipaddr_len)) -APR_DECLARE(int) apr_sockaddr_equal(const apr_sockaddr_t *addr1, - const apr_sockaddr_t *addr2) +APR_DECLARE(int) fspr_sockaddr_equal(const fspr_sockaddr_t *addr1, + const fspr_sockaddr_t *addr2) { if (addr1->ipaddr_len == addr2->ipaddr_len && !memcmp(addr1->ipaddr_ptr, addr2->ipaddr_ptr, addr1->ipaddr_len)) { @@ -735,7 +735,7 @@ APR_DECLARE(int) apr_sockaddr_equal(const apr_sockaddr_t *addr1, return 0; /* not equal */ } -static apr_status_t parse_network(apr_ipsubnet_t *ipsub, const char *network) +static fspr_status_t parse_network(fspr_ipsubnet_t *ipsub, const char *network) { /* legacy syntax for ip addrs: a.b.c. ==> a.b.c.0/24 for example */ int shift; @@ -757,10 +757,10 @@ static apr_status_t parse_network(apr_ipsubnet_t *ipsub, const char *network) shift = 24; while (*s) { t = s; - if (!apr_isdigit(*t)) { + if (!fspr_isdigit(*t)) { return APR_EBADIP; } - while (apr_isdigit(*t)) { + while (fspr_isdigit(*t)) { ++t; } if (*t == '.') { @@ -793,7 +793,7 @@ static apr_status_t parse_network(apr_ipsubnet_t *ipsub, const char *network) * APR_BADMASK mask portion is not valid */ -static apr_status_t parse_ip(apr_ipsubnet_t *ipsub, const char *ipstr, int network_allowed) +static fspr_status_t parse_ip(fspr_ipsubnet_t *ipsub, const char *ipstr, int network_allowed) { /* supported flavors of IP: * @@ -810,10 +810,10 @@ static apr_status_t parse_ip(apr_ipsubnet_t *ipsub, const char *ipstr, int netwo int rc; #if APR_HAVE_IPV6 - rc = apr_inet_pton(AF_INET6, ipstr, ipsub->sub); + rc = fspr_inet_pton(AF_INET6, ipstr, ipsub->sub); if (rc == 1) { if (IN6_IS_ADDR_V4MAPPED((struct in6_addr *)ipsub->sub)) { - /* apr_ipsubnet_test() assumes that we don't create IPv4-mapped IPv6 + /* fspr_ipsubnet_test() assumes that we don't create IPv4-mapped IPv6 * addresses; this of course forces the user to specify IPv4 addresses * in a.b.c.d style instead of ::ffff:a.b.c.d style. */ @@ -824,7 +824,7 @@ static apr_status_t parse_ip(apr_ipsubnet_t *ipsub, const char *ipstr, int netwo else #endif { - rc = apr_inet_pton(AF_INET, ipstr, ipsub->sub); + rc = fspr_inet_pton(AF_INET, ipstr, ipsub->sub); if (rc == 1) { ipsub->family = AF_INET; } @@ -848,28 +848,28 @@ static int looks_like_ip(const char *ipstr) } /* simple IPv4 address string check */ - while ((*ipstr == '.') || apr_isdigit(*ipstr)) + while ((*ipstr == '.') || fspr_isdigit(*ipstr)) ipstr++; return (*ipstr == '\0'); } -static void fix_subnet(apr_ipsubnet_t *ipsub) +static void fix_subnet(fspr_ipsubnet_t *ipsub) { /* in case caller specified more bits in network address than are * valid according to the mask, turn off the extra bits */ int i; - for (i = 0; i < sizeof ipsub->mask / sizeof(apr_int32_t); i++) { + for (i = 0; i < sizeof ipsub->mask / sizeof(fspr_int32_t); i++) { ipsub->sub[i] &= ipsub->mask[i]; } } /* be sure not to store any IPv4 address as a v4-mapped IPv6 address */ -APR_DECLARE(apr_status_t) apr_ipsubnet_create(apr_ipsubnet_t **ipsub, const char *ipstr, - const char *mask_or_numbits, apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_ipsubnet_create(fspr_ipsubnet_t **ipsub, const char *ipstr, + const char *mask_or_numbits, fspr_pool_t *p) { - apr_status_t rv; + fspr_status_t rv; char *endptr; long bits, maxbits = 32; @@ -882,7 +882,7 @@ APR_DECLARE(apr_status_t) apr_ipsubnet_create(apr_ipsubnet_t **ipsub, const char return APR_EINVAL; } - *ipsub = apr_pcalloc(p, sizeof(apr_ipsubnet_t)); + *ipsub = fspr_pcalloc(p, sizeof(fspr_ipsubnet_t)); /* assume ipstr is an individual IP address, not a subnet */ memset((*ipsub)->mask, 0xFF, sizeof (*ipsub)->mask); @@ -902,7 +902,7 @@ APR_DECLARE(apr_status_t) apr_ipsubnet_create(apr_ipsubnet_t **ipsub, const char if (*endptr == '\0' && bits > 0 && bits <= maxbits) { /* valid num-bits string; fill in mask appropriately */ int cur_entry = 0; - apr_int32_t cur_bit_value; + fspr_int32_t cur_bit_value; memset((*ipsub)->mask, 0, sizeof (*ipsub)->mask); while (bits > 32) { @@ -918,7 +918,7 @@ APR_DECLARE(apr_status_t) apr_ipsubnet_create(apr_ipsubnet_t **ipsub, const char } (*ipsub)->mask[cur_entry] = htonl((*ipsub)->mask[cur_entry]); } - else if (apr_inet_pton(AF_INET, mask_or_numbits, (*ipsub)->mask) == 1 && + else if (fspr_inet_pton(AF_INET, mask_or_numbits, (*ipsub)->mask) == 1 && (*ipsub)->family == AF_INET) { /* valid IPv4 netmask */ } @@ -932,7 +932,7 @@ APR_DECLARE(apr_status_t) apr_ipsubnet_create(apr_ipsubnet_t **ipsub, const char return APR_SUCCESS; } -APR_DECLARE(int) apr_ipsubnet_test(apr_ipsubnet_t *ipsub, apr_sockaddr_t *sa) +APR_DECLARE(int) fspr_ipsubnet_test(fspr_ipsubnet_t *ipsub, fspr_sockaddr_t *sa) { #if APR_HAVE_IPV6 /* XXX This line will segv on Win32 build with APR_HAVE_IPV6, @@ -946,12 +946,12 @@ APR_DECLARE(int) apr_ipsubnet_test(apr_ipsubnet_t *ipsub, apr_sockaddr_t *sa) } else if (IN6_IS_ADDR_V4MAPPED((struct in6_addr *)sa->ipaddr_ptr)) { if (ipsub->family == AF_INET && - (((apr_uint32_t *)sa->ipaddr_ptr)[3] & ipsub->mask[0]) == ipsub->sub[0]) { + (((fspr_uint32_t *)sa->ipaddr_ptr)[3] & ipsub->mask[0]) == ipsub->sub[0]) { return 1; } } else { - apr_uint32_t *addr = (apr_uint32_t *)sa->ipaddr_ptr; + fspr_uint32_t *addr = (fspr_uint32_t *)sa->ipaddr_ptr; if ((addr[0] & ipsub->mask[0]) == ipsub->sub[0] && (addr[1] & ipsub->mask[1]) == ipsub->sub[1] && diff --git a/libs/apr/network_io/unix/sockets.c b/libs/apr/network_io/unix/sockets.c index 72dab7b89c..6475599cfd 100644 --- a/libs/apr/network_io/unix/sockets.c +++ b/libs/apr/network_io/unix/sockets.c @@ -14,12 +14,12 @@ * limitations under the License. */ -#include "apr_arch_networkio.h" -#include "apr_network_io.h" -#include "apr_strings.h" -#include "apr_support.h" -#include "apr_portable.h" -#include "apr_arch_inherit.h" +#include "fspr_arch_networkio.h" +#include "fspr_network_io.h" +#include "fspr_strings.h" +#include "fspr_support.h" +#include "fspr_portable.h" +#include "fspr_arch_inherit.h" #ifdef BEOS_R5 #undef close @@ -28,9 +28,9 @@ static char generic_inaddr_any[16] = {0}; /* big enough for IPv4 or IPv6 */ -static apr_status_t socket_cleanup(void *sock) +static fspr_status_t socket_cleanup(void *sock) { - apr_socket_t *thesocket = sock; + fspr_socket_t *thesocket = sock; if (!thesocket) { return APR_ENOTSOCK; @@ -49,12 +49,12 @@ static apr_status_t socket_cleanup(void *sock) } } -static void set_socket_vars(apr_socket_t *sock, int family, int type, int protocol) +static void set_socket_vars(fspr_socket_t *sock, int family, int type, int protocol) { sock->type = type; sock->protocol = protocol; - apr_sockaddr_vars_set(sock->local_addr, family, 0); - apr_sockaddr_vars_set(sock->remote_addr, family, 0); + fspr_sockaddr_vars_set(sock->local_addr, family, 0); + fspr_sockaddr_vars_set(sock->remote_addr, family, 0); sock->options = 0; #if defined(BEOS) && !defined(BEOS_BONE) /* BeOS pre-BONE has TCP_NODELAY on by default and it can't be @@ -64,32 +64,32 @@ static void set_socket_vars(apr_socket_t *sock, int family, int type, int protoc #endif } -static void alloc_socket(apr_socket_t **new, apr_pool_t *p) +static void alloc_socket(fspr_socket_t **new, fspr_pool_t *p) { - *new = (apr_socket_t *)apr_pcalloc(p, sizeof(apr_socket_t)); + *new = (fspr_socket_t *)fspr_pcalloc(p, sizeof(fspr_socket_t)); (*new)->pool = p; - (*new)->local_addr = (apr_sockaddr_t *)apr_pcalloc((*new)->pool, - sizeof(apr_sockaddr_t)); + (*new)->local_addr = (fspr_sockaddr_t *)fspr_pcalloc((*new)->pool, + sizeof(fspr_sockaddr_t)); (*new)->local_addr->pool = p; - (*new)->remote_addr = (apr_sockaddr_t *)apr_pcalloc((*new)->pool, - sizeof(apr_sockaddr_t)); + (*new)->remote_addr = (fspr_sockaddr_t *)fspr_pcalloc((*new)->pool, + sizeof(fspr_sockaddr_t)); (*new)->remote_addr->pool = p; (*new)->remote_addr_unknown = 1; #ifndef WAITIO_USES_POLL /* Create a pollset with room for one descriptor. */ /* ### check return codes */ - (void) apr_pollset_create(&(*new)->pollset, 1, p, 0); + (void) fspr_pollset_create(&(*new)->pollset, 1, p, 0); #endif } -apr_status_t apr_socket_protocol_get(apr_socket_t *sock, int *protocol) +fspr_status_t fspr_socket_protocol_get(fspr_socket_t *sock, int *protocol) { *protocol = sock->protocol; return APR_SUCCESS; } -apr_status_t apr_socket_create(apr_socket_t **new, int ofamily, int type, - int protocol, apr_pool_t *cont) +fspr_status_t fspr_socket_create(fspr_socket_t **new, int ofamily, int type, + int protocol, fspr_pool_t *cont) { int family = ofamily; @@ -140,24 +140,24 @@ apr_status_t apr_socket_create(apr_socket_t **new, int ofamily, int type, (*new)->timeout = -1; (*new)->inherit = 0; - apr_pool_cleanup_register((*new)->pool, (void *)(*new), socket_cleanup, + fspr_pool_cleanup_register((*new)->pool, (void *)(*new), socket_cleanup, socket_cleanup); return APR_SUCCESS; } -apr_status_t apr_socket_shutdown(apr_socket_t *thesocket, - apr_shutdown_how_e how) +fspr_status_t fspr_socket_shutdown(fspr_socket_t *thesocket, + fspr_shutdown_how_e how) { return (shutdown(thesocket->socketdes, how) == -1) ? errno : APR_SUCCESS; } -apr_status_t apr_socket_close(apr_socket_t *thesocket) +fspr_status_t fspr_socket_close(fspr_socket_t *thesocket) { - return apr_pool_cleanup_run(thesocket->pool, thesocket, socket_cleanup); + return fspr_pool_cleanup_run(thesocket->pool, thesocket, socket_cleanup); } -apr_status_t apr_socket_bind(apr_socket_t *sock, apr_sockaddr_t *sa) +fspr_status_t fspr_socket_bind(fspr_socket_t *sock, fspr_sockaddr_t *sa) { if (bind(sock->socketdes, (struct sockaddr *)&sa->sa, sa->salen) == -1) { @@ -173,7 +173,7 @@ apr_status_t apr_socket_bind(apr_socket_t *sock, apr_sockaddr_t *sa) } } -apr_status_t apr_socket_listen(apr_socket_t *sock, apr_int32_t backlog) +fspr_status_t fspr_socket_listen(fspr_socket_t *sock, fspr_int32_t backlog) { if (listen(sock->socketdes, backlog) == -1) return errno; @@ -181,8 +181,8 @@ apr_status_t apr_socket_listen(apr_socket_t *sock, apr_int32_t backlog) return APR_SUCCESS; } -apr_status_t apr_socket_accept(apr_socket_t **new, apr_socket_t *sock, - apr_pool_t *connection_context) +fspr_status_t fspr_socket_accept(fspr_socket_t **new, fspr_socket_t *sock, + fspr_pool_t *connection_context) { alloc_socket(new, connection_context); set_socket_vars(*new, sock->local_addr->sa.sin.sin_family, SOCK_STREAM, sock->protocol); @@ -232,13 +232,13 @@ apr_status_t apr_socket_accept(apr_socket_t **new, apr_socket_t *sock, } #if APR_TCP_NODELAY_INHERITED - if (apr_is_option_set(sock, APR_TCP_NODELAY) == 1) { - apr_set_option(*new, APR_TCP_NODELAY, 1); + if (fspr_is_option_set(sock, APR_TCP_NODELAY) == 1) { + fspr_set_option(*new, APR_TCP_NODELAY, 1); } #endif /* TCP_NODELAY_INHERITED */ #if APR_O_NONBLOCK_INHERITED - if (apr_is_option_set(sock, APR_SO_NONBLOCK) == 1) { - apr_set_option(*new, APR_SO_NONBLOCK, 1); + if (fspr_is_option_set(sock, APR_SO_NONBLOCK) == 1) { + fspr_set_option(*new, APR_SO_NONBLOCK, 1); } #endif /* APR_O_NONBLOCK_INHERITED */ @@ -256,12 +256,12 @@ apr_status_t apr_socket_accept(apr_socket_t **new, apr_socket_t *sock, } (*new)->inherit = 0; - apr_pool_cleanup_register((*new)->pool, (void *)(*new), socket_cleanup, + fspr_pool_cleanup_register((*new)->pool, (void *)(*new), socket_cleanup, socket_cleanup); return APR_SUCCESS; } -apr_status_t apr_socket_connect(apr_socket_t *sock, apr_sockaddr_t *sa) +fspr_status_t fspr_socket_connect(fspr_socket_t *sock, fspr_sockaddr_t *sa) { int rc; @@ -276,7 +276,7 @@ apr_status_t apr_socket_connect(apr_socket_t *sock, apr_sockaddr_t *sa) */ if ((rc == -1) && (errno == EINPROGRESS || errno == EALREADY) && (sock->timeout > 0)) { - rc = apr_wait_for_io_or_timeout(NULL, sock, 0); + rc = fspr_wait_for_io_or_timeout(NULL, sock, 0); if (rc != APR_SUCCESS) { return rc; } @@ -284,7 +284,7 @@ apr_status_t apr_socket_connect(apr_socket_t *sock, apr_sockaddr_t *sa) #ifdef SO_ERROR { int error; - apr_socklen_t len = sizeof(error); + fspr_socklen_t len = sizeof(error); if ((rc = getsockopt(sock->socketdes, SOL_SOCKET, SO_ERROR, (char *)&error, &len)) < 0) { return errno; @@ -328,13 +328,13 @@ apr_status_t apr_socket_connect(apr_socket_t *sock, apr_sockaddr_t *sa) return APR_SUCCESS; } -apr_status_t apr_socket_type_get(apr_socket_t *sock, int *type) +fspr_status_t fspr_socket_type_get(fspr_socket_t *sock, int *type) { *type = sock->type; return APR_SUCCESS; } -apr_status_t apr_socket_data_get(void **data, const char *key, apr_socket_t *sock) +fspr_status_t fspr_socket_data_get(void **data, const char *key, fspr_socket_t *sock) { sock_userdata_t *cur = sock->userdata; @@ -351,76 +351,76 @@ apr_status_t apr_socket_data_get(void **data, const char *key, apr_socket_t *soc return APR_SUCCESS; } -apr_status_t apr_socket_data_set(apr_socket_t *sock, void *data, const char *key, - apr_status_t (*cleanup) (void *)) +fspr_status_t fspr_socket_data_set(fspr_socket_t *sock, void *data, const char *key, + fspr_status_t (*cleanup) (void *)) { - sock_userdata_t *new = apr_palloc(sock->pool, sizeof(sock_userdata_t)); + sock_userdata_t *new = fspr_palloc(sock->pool, sizeof(sock_userdata_t)); - new->key = apr_pstrdup(sock->pool, key); + new->key = fspr_pstrdup(sock->pool, key); new->data = data; new->next = sock->userdata; sock->userdata = new; if (cleanup) { - apr_pool_cleanup_register(sock->pool, data, cleanup, cleanup); + fspr_pool_cleanup_register(sock->pool, data, cleanup, cleanup); } return APR_SUCCESS; } -apr_status_t apr_os_sock_get(apr_os_sock_t *thesock, apr_socket_t *sock) +fspr_status_t fspr_os_sock_get(fspr_os_sock_t *thesock, fspr_socket_t *sock) { *thesock = sock->socketdes; return APR_SUCCESS; } -apr_status_t apr_os_sock_make(apr_socket_t **apr_sock, - apr_os_sock_info_t *os_sock_info, - apr_pool_t *cont) +fspr_status_t fspr_os_sock_make(fspr_socket_t **fspr_sock, + fspr_os_sock_info_t *os_sock_info, + fspr_pool_t *cont) { - alloc_socket(apr_sock, cont); - set_socket_vars(*apr_sock, os_sock_info->family, os_sock_info->type, os_sock_info->protocol); - (*apr_sock)->timeout = -1; - (*apr_sock)->socketdes = *os_sock_info->os_sock; + alloc_socket(fspr_sock, cont); + set_socket_vars(*fspr_sock, os_sock_info->family, os_sock_info->type, os_sock_info->protocol); + (*fspr_sock)->timeout = -1; + (*fspr_sock)->socketdes = *os_sock_info->os_sock; if (os_sock_info->local) { - memcpy(&(*apr_sock)->local_addr->sa.sin, + memcpy(&(*fspr_sock)->local_addr->sa.sin, os_sock_info->local, - (*apr_sock)->local_addr->salen); + (*fspr_sock)->local_addr->salen); /* XXX IPv6 - this assumes sin_port and sin6_port at same offset */ - (*apr_sock)->local_addr->port = ntohs((*apr_sock)->local_addr->sa.sin.sin_port); + (*fspr_sock)->local_addr->port = ntohs((*fspr_sock)->local_addr->sa.sin.sin_port); } else { - (*apr_sock)->local_port_unknown = (*apr_sock)->local_interface_unknown = 1; + (*fspr_sock)->local_port_unknown = (*fspr_sock)->local_interface_unknown = 1; } if (os_sock_info->remote) { #ifndef HAVE_POLL - (*apr_sock)->connected = 1; + (*fspr_sock)->connected = 1; #endif - memcpy(&(*apr_sock)->remote_addr->sa.sin, + memcpy(&(*fspr_sock)->remote_addr->sa.sin, os_sock_info->remote, - (*apr_sock)->remote_addr->salen); + (*fspr_sock)->remote_addr->salen); /* XXX IPv6 - this assumes sin_port and sin6_port at same offset */ - (*apr_sock)->remote_addr->port = ntohs((*apr_sock)->remote_addr->sa.sin.sin_port); + (*fspr_sock)->remote_addr->port = ntohs((*fspr_sock)->remote_addr->sa.sin.sin_port); } else { - (*apr_sock)->remote_addr_unknown = 1; + (*fspr_sock)->remote_addr_unknown = 1; } - (*apr_sock)->inherit = 0; - apr_pool_cleanup_register((*apr_sock)->pool, (void *)(*apr_sock), + (*fspr_sock)->inherit = 0; + fspr_pool_cleanup_register((*fspr_sock)->pool, (void *)(*fspr_sock), socket_cleanup, socket_cleanup); return APR_SUCCESS; } -apr_status_t apr_os_sock_put(apr_socket_t **sock, apr_os_sock_t *thesock, - apr_pool_t *cont) +fspr_status_t fspr_os_sock_put(fspr_socket_t **sock, fspr_os_sock_t *thesock, + fspr_pool_t *cont) { /* XXX Bogus assumption that *sock points at anything legit */ if ((*sock) == NULL) { alloc_socket(sock, cont); /* XXX IPv6 figure out the family here! */ /* XXX figure out the actual socket type here */ - /* *or* just decide that apr_os_sock_put() has to be told the family and type */ + /* *or* just decide that fspr_os_sock_put() has to be told the family and type */ set_socket_vars(*sock, APR_INET, SOCK_STREAM, 0); (*sock)->timeout = -1; } diff --git a/libs/apr/network_io/unix/sockopt.c b/libs/apr/network_io/unix/sockopt.c index 344b0484b4..87f27f7014 100644 --- a/libs/apr/network_io/unix/sockopt.c +++ b/libs/apr/network_io/unix/sockopt.c @@ -14,11 +14,11 @@ * limitations under the License. */ -#include "apr_arch_networkio.h" -#include "apr_strings.h" +#include "fspr_arch_networkio.h" +#include "fspr_strings.h" -static apr_status_t soblock(int sd) +static fspr_status_t soblock(int sd) { /* BeOS uses setsockopt at present for non blocking... */ #ifndef BEOS @@ -45,7 +45,7 @@ static apr_status_t soblock(int sd) return APR_SUCCESS; } -static apr_status_t sononblock(int sd) +static fspr_status_t sononblock(int sd) { #ifndef BEOS int fd_flags; @@ -72,9 +72,9 @@ static apr_status_t sononblock(int sd) } -apr_status_t apr_socket_timeout_set(apr_socket_t *sock, apr_interval_time_t t) +fspr_status_t fspr_socket_timeout_set(fspr_socket_t *sock, fspr_interval_time_t t) { - apr_status_t stat; + fspr_status_t stat; /* If our new timeout is non-negative and our old timeout was * negative, then we need to ensure that we are non-blocking. @@ -84,19 +84,19 @@ apr_status_t apr_socket_timeout_set(apr_socket_t *sock, apr_interval_time_t t) * socket. */ if (t >= 0 && sock->timeout < 0) { - if (apr_is_option_set(sock, APR_SO_NONBLOCK) != 1) { + if (fspr_is_option_set(sock, APR_SO_NONBLOCK) != 1) { if ((stat = sononblock(sock->socketdes)) != APR_SUCCESS) { return stat; } - apr_set_option(sock, APR_SO_NONBLOCK, 1); + fspr_set_option(sock, APR_SO_NONBLOCK, 1); } } else if (t < 0 && sock->timeout >= 0) { - if (apr_is_option_set(sock, APR_SO_NONBLOCK) != 0) { + if (fspr_is_option_set(sock, APR_SO_NONBLOCK) != 0) { if ((stat = soblock(sock->socketdes)) != APR_SUCCESS) { return stat; } - apr_set_option(sock, APR_SO_NONBLOCK, 0); + fspr_set_option(sock, APR_SO_NONBLOCK, 0); } } /* must disable the incomplete read support if we disable @@ -110,11 +110,11 @@ apr_status_t apr_socket_timeout_set(apr_socket_t *sock, apr_interval_time_t t) } -apr_status_t apr_socket_opt_set(apr_socket_t *sock, - apr_int32_t opt, apr_int32_t on) +fspr_status_t fspr_socket_opt_set(fspr_socket_t *sock, + fspr_int32_t opt, fspr_int32_t on) { int one; - apr_status_t rv; + fspr_status_t rv; if (on) one = 1; @@ -123,30 +123,30 @@ apr_status_t apr_socket_opt_set(apr_socket_t *sock, switch(opt) { case APR_SO_KEEPALIVE: #ifdef SO_KEEPALIVE - if (on != apr_is_option_set(sock, APR_SO_KEEPALIVE)) { + if (on != fspr_is_option_set(sock, APR_SO_KEEPALIVE)) { if (setsockopt(sock->socketdes, SOL_SOCKET, SO_KEEPALIVE, (void *)&one, sizeof(int)) == -1) { return errno; } - apr_set_option(sock, APR_SO_KEEPALIVE, on); + fspr_set_option(sock, APR_SO_KEEPALIVE, on); } #else return APR_ENOTIMPL; #endif break; case APR_SO_DEBUG: - if (on != apr_is_option_set(sock, APR_SO_DEBUG)) { + if (on != fspr_is_option_set(sock, APR_SO_DEBUG)) { if (setsockopt(sock->socketdes, SOL_SOCKET, SO_DEBUG, (void *)&one, sizeof(int)) == -1) { return errno; } - apr_set_option(sock, APR_SO_DEBUG, on); + fspr_set_option(sock, APR_SO_DEBUG, on); } break; case APR_SO_REUSEADDR: - if (on != apr_is_option_set(sock, APR_SO_REUSEADDR)) { + if (on != fspr_is_option_set(sock, APR_SO_REUSEADDR)) { if (setsockopt(sock->socketdes, SOL_SOCKET, SO_REUSEADDR, (void *)&one, sizeof(int)) == -1) { return errno; } - apr_set_option(sock, APR_SO_REUSEADDR, on); + fspr_set_option(sock, APR_SO_REUSEADDR, on); } break; case APR_SO_SNDBUF: @@ -168,7 +168,7 @@ apr_status_t apr_socket_opt_set(apr_socket_t *sock, #endif break; case APR_SO_NONBLOCK: - if (apr_is_option_set(sock, APR_SO_NONBLOCK) != on) { + if (fspr_is_option_set(sock, APR_SO_NONBLOCK) != on) { if (on) { if ((rv = sononblock(sock->socketdes)) != APR_SUCCESS) return rv; @@ -177,19 +177,19 @@ apr_status_t apr_socket_opt_set(apr_socket_t *sock, if ((rv = soblock(sock->socketdes)) != APR_SUCCESS) return rv; } - apr_set_option(sock, APR_SO_NONBLOCK, on); + fspr_set_option(sock, APR_SO_NONBLOCK, on); } break; case APR_SO_LINGER: #ifdef SO_LINGER - if (apr_is_option_set(sock, APR_SO_LINGER) != on) { + if (fspr_is_option_set(sock, APR_SO_LINGER) != on) { struct linger li; li.l_onoff = on; li.l_linger = APR_MAX_SECS_TO_LINGER; if (setsockopt(sock->socketdes, SOL_SOCKET, SO_LINGER, (char *) &li, sizeof(struct linger)) == -1) { return errno; } - apr_set_option(sock, APR_SO_LINGER, on); + fspr_set_option(sock, APR_SO_LINGER, on); } #else return APR_ENOTIMPL; @@ -197,7 +197,7 @@ apr_status_t apr_socket_opt_set(apr_socket_t *sock, break; case APR_TCP_DEFER_ACCEPT: #if defined(TCP_DEFER_ACCEPT) - if (apr_is_option_set(sock, APR_TCP_DEFER_ACCEPT) != on) { + if (fspr_is_option_set(sock, APR_TCP_DEFER_ACCEPT) != on) { int optlevel = IPPROTO_TCP; int optname = TCP_DEFER_ACCEPT; @@ -205,7 +205,7 @@ apr_status_t apr_socket_opt_set(apr_socket_t *sock, (void *)&on, sizeof(int)) == -1) { return errno; } - apr_set_option(sock, APR_TCP_DEFER_ACCEPT, on); + fspr_set_option(sock, APR_TCP_DEFER_ACCEPT, on); } #else return APR_ENOTIMPL; @@ -213,7 +213,7 @@ apr_status_t apr_socket_opt_set(apr_socket_t *sock, break; case APR_TCP_NODELAY: #if defined(TCP_NODELAY) - if (apr_is_option_set(sock, APR_TCP_NODELAY) != on) { + if (fspr_is_option_set(sock, APR_TCP_NODELAY) != on) { int optlevel = IPPROTO_TCP; int optname = TCP_NODELAY; @@ -226,7 +226,7 @@ apr_status_t apr_socket_opt_set(apr_socket_t *sock, if (setsockopt(sock->socketdes, optlevel, optname, (void *)&on, sizeof(int)) == -1) { return errno; } - apr_set_option(sock, APR_TCP_NODELAY, on); + fspr_set_option(sock, APR_TCP_NODELAY, on); } #else /* BeOS pre-BONE has TCP_NODELAY set by default. @@ -248,7 +248,7 @@ apr_status_t apr_socket_opt_set(apr_socket_t *sock, * and TCP_CORK takes preference, which is the desired * behaviour. On older kernels, TCP_NODELAY must be toggled * to "off" whilst TCP_CORK is in effect. */ - if (apr_is_option_set(sock, APR_TCP_NOPUSH) != on) { + if (fspr_is_option_set(sock, APR_TCP_NOPUSH) != on) { #ifndef HAVE_TCP_NODELAY_WITH_CORK int optlevel = IPPROTO_TCP; int optname = TCP_NODELAY; @@ -260,7 +260,7 @@ apr_status_t apr_socket_opt_set(apr_socket_t *sock, } #endif /* OK we're going to change some settings here... */ - if (apr_is_option_set(sock, APR_TCP_NODELAY) == 1 && on) { + if (fspr_is_option_set(sock, APR_TCP_NODELAY) == 1 && on) { /* Now toggle TCP_NODELAY to off, if TCP_CORK is being * turned on: */ int tmpflag = 0; @@ -268,10 +268,10 @@ apr_status_t apr_socket_opt_set(apr_socket_t *sock, (void*)&tmpflag, sizeof(int)) == -1) { return errno; } - apr_set_option(sock, APR_RESET_NODELAY, 1); - apr_set_option(sock, APR_TCP_NODELAY, 0); + fspr_set_option(sock, APR_RESET_NODELAY, 1); + fspr_set_option(sock, APR_TCP_NODELAY, 0); } else if (on) { - apr_set_option(sock, APR_RESET_NODELAY, 0); + fspr_set_option(sock, APR_RESET_NODELAY, 0); } #endif /* HAVE_TCP_NODELAY_WITH_CORK */ @@ -280,9 +280,9 @@ apr_status_t apr_socket_opt_set(apr_socket_t *sock, (void*)&on, sizeof(int)) == -1) { return errno; } - apr_set_option(sock, APR_TCP_NOPUSH, on); + fspr_set_option(sock, APR_TCP_NOPUSH, on); #ifndef HAVE_TCP_NODELAY_WITH_CORK - if (!on && apr_is_option_set(sock, APR_RESET_NODELAY)) { + if (!on && fspr_is_option_set(sock, APR_RESET_NODELAY)) { /* Now, if TCP_CORK was just turned off, turn * TCP_NODELAY back on again if it was earlier toggled * to off: */ @@ -291,8 +291,8 @@ apr_status_t apr_socket_opt_set(apr_socket_t *sock, (void*)&tmpflag, sizeof(int)) == -1) { return errno; } - apr_set_option(sock, APR_RESET_NODELAY,0); - apr_set_option(sock, APR_TCP_NODELAY, 1); + fspr_set_option(sock, APR_RESET_NODELAY,0); + fspr_set_option(sock, APR_TCP_NODELAY, 1); } #endif /* HAVE_TCP_NODELAY_WITH_CORK */ } @@ -301,7 +301,7 @@ apr_status_t apr_socket_opt_set(apr_socket_t *sock, #endif break; case APR_INCOMPLETE_READ: - apr_set_option(sock, APR_INCOMPLETE_READ, on); + fspr_set_option(sock, APR_INCOMPLETE_READ, on); break; case APR_IPV6_V6ONLY: #if APR_HAVE_IPV6 && defined(IPV6_V6ONLY) @@ -313,7 +313,7 @@ apr_status_t apr_socket_opt_set(apr_socket_t *sock, (void *)&on, sizeof(int)) == -1) { return errno; } - apr_set_option(sock, APR_IPV6_V6ONLY, on); + fspr_set_option(sock, APR_IPV6_V6ONLY, on); #else return APR_ENOTIMPL; #endif @@ -326,25 +326,25 @@ apr_status_t apr_socket_opt_set(apr_socket_t *sock, } -apr_status_t apr_socket_timeout_get(apr_socket_t *sock, apr_interval_time_t *t) +fspr_status_t fspr_socket_timeout_get(fspr_socket_t *sock, fspr_interval_time_t *t) { *t = sock->timeout; return APR_SUCCESS; } -apr_status_t apr_socket_opt_get(apr_socket_t *sock, - apr_int32_t opt, apr_int32_t *on) +fspr_status_t fspr_socket_opt_get(fspr_socket_t *sock, + fspr_int32_t opt, fspr_int32_t *on) { switch(opt) { default: - *on = apr_is_option_set(sock, opt); + *on = fspr_is_option_set(sock, opt); } return APR_SUCCESS; } -int apr_socket_fd_get(apr_socket_t *sock) +int fspr_socket_fd_get(fspr_socket_t *sock) { if (sock) { return sock->socketdes; @@ -354,13 +354,13 @@ int apr_socket_fd_get(apr_socket_t *sock) } -apr_status_t apr_socket_atmark(apr_socket_t *sock, int *atmark) +fspr_status_t fspr_socket_atmark(fspr_socket_t *sock, int *atmark) { #ifndef BEOS_R5 int oobmark; if (ioctl(sock->socketdes, SIOCATMARK, (void*) &oobmark) < 0) - return apr_get_netos_error(); + return fspr_get_netos_error(); *atmark = (oobmark != 0); @@ -370,7 +370,7 @@ apr_status_t apr_socket_atmark(apr_socket_t *sock, int *atmark) #endif } -apr_status_t apr_gethostname(char *buf, apr_int32_t len, apr_pool_t *cont) +fspr_status_t fspr_gethostname(char *buf, fspr_int32_t len, fspr_pool_t *cont) { #ifdef BEOS_R5 if (gethostname(buf, len) == 0) { @@ -391,7 +391,7 @@ apr_status_t apr_gethostname(char *buf, apr_int32_t len, apr_pool_t *cont) } #if APR_HAS_SO_ACCEPTFILTER -apr_status_t apr_socket_accept_filter(apr_socket_t *sock, char *name, +fspr_status_t fspr_socket_accept_filter(fspr_socket_t *sock, char *name, char *args) { struct accept_filter_arg af; diff --git a/libs/apr/network_io/win32/sendrecv.c b/libs/apr/network_io/win32/sendrecv.c index faab51d492..63891a50c6 100644 --- a/libs/apr/network_io/win32/sendrecv.c +++ b/libs/apr/network_io/win32/sendrecv.c @@ -14,12 +14,12 @@ * limitations under the License. */ -#include "apr_arch_networkio.h" -#include "apr_errno.h" -#include "apr_general.h" -#include "apr_network_io.h" -#include "apr_lib.h" -#include "apr_arch_file_io.h" +#include "fspr_arch_networkio.h" +#include "fspr_errno.h" +#include "fspr_general.h" +#include "fspr_network_io.h" +#include "fspr_lib.h" +#include "fspr_arch_file_io.h" #if APR_HAVE_TIME_H #include #endif @@ -27,19 +27,19 @@ /* MAX_SEGMENT_SIZE is the maximum amount of data that will be sent to a client * in one call of TransmitFile. This number must be small enough to give the * slowest client time to receive the data before the socket timeout triggers. - * The same problem can exist with apr_socket_send(). In that case, we rely on + * The same problem can exist with fspr_socket_send(). In that case, we rely on * the application to adjust socket timeouts and max send segment * sizes appropriately. - * For example, Apache will in most cases call apr_socket_send() with less + * For example, Apache will in most cases call fspr_socket_send() with less * than 8193 bytes. */ #define MAX_SEGMENT_SIZE 65536 #define WSABUF_ON_STACK 50 -APR_DECLARE(apr_status_t) apr_socket_send(apr_socket_t *sock, const char *buf, - apr_size_t *len) +APR_DECLARE(fspr_status_t) fspr_socket_send(fspr_socket_t *sock, const char *buf, + fspr_size_t *len) { - apr_ssize_t rv; + fspr_ssize_t rv; WSABUF wsaData; int lasterror; DWORD dwBytes = 0; @@ -54,7 +54,7 @@ APR_DECLARE(apr_status_t) apr_socket_send(apr_socket_t *sock, const char *buf, dwBytes = rv; #endif if (rv == SOCKET_ERROR) { - lasterror = apr_get_netos_error(); + lasterror = fspr_get_netos_error(); *len = 0; return lasterror; } @@ -65,10 +65,10 @@ APR_DECLARE(apr_status_t) apr_socket_send(apr_socket_t *sock, const char *buf, } -APR_DECLARE(apr_status_t) apr_socket_recv(apr_socket_t *sock, char *buf, - apr_size_t *len) +APR_DECLARE(fspr_status_t) fspr_socket_recv(fspr_socket_t *sock, char *buf, + fspr_size_t *len) { - apr_ssize_t rv; + fspr_ssize_t rv; WSABUF wsaData; int lasterror; DWORD dwBytes = 0; @@ -84,7 +84,7 @@ APR_DECLARE(apr_status_t) apr_socket_recv(apr_socket_t *sock, char *buf, dwBytes = rv; #endif if (rv == SOCKET_ERROR) { - lasterror = apr_get_netos_error(); + lasterror = fspr_get_netos_error(); *len = 0; return lasterror; } @@ -94,14 +94,14 @@ APR_DECLARE(apr_status_t) apr_socket_recv(apr_socket_t *sock, char *buf, } -APR_DECLARE(apr_status_t) apr_socket_sendv(apr_socket_t *sock, +APR_DECLARE(fspr_status_t) fspr_socket_sendv(fspr_socket_t *sock, const struct iovec *vec, - apr_int32_t in_vec, apr_size_t *nbytes) + fspr_int32_t in_vec, fspr_size_t *nbytes) { - apr_status_t rc = APR_SUCCESS; - apr_ssize_t rv; - apr_size_t cur_len; - apr_int32_t nvec = 0; + fspr_status_t rc = APR_SUCCESS; + fspr_ssize_t rv; + fspr_size_t cur_len; + fspr_int32_t nvec = 0; int i, j = 0; DWORD dwBytes = 0; WSABUF *pWsaBuf; @@ -143,13 +143,13 @@ APR_DECLARE(apr_status_t) apr_socket_sendv(apr_socket_t *sock, #ifndef _WIN32_WCE rv = WSASend(sock->socketdes, pWsaBuf, nvec, &dwBytes, 0, NULL, NULL); if (rv == SOCKET_ERROR) { - rc = apr_get_netos_error(); + rc = fspr_get_netos_error(); } #else for (i = 0; i < nvec; i++) { rv = send(sock->socketdes, pWsaBuf[i].buf, pWsaBuf[i].len, 0); if (rv == SOCKET_ERROR) { - rc = apr_get_netos_error(); + rc = fspr_get_netos_error(); break; } dwBytes += rv; @@ -163,19 +163,19 @@ APR_DECLARE(apr_status_t) apr_socket_sendv(apr_socket_t *sock, } -APR_DECLARE(apr_status_t) apr_socket_sendto(apr_socket_t *sock, - apr_sockaddr_t *where, - apr_int32_t flags, const char *buf, - apr_size_t *len) +APR_DECLARE(fspr_status_t) fspr_socket_sendto(fspr_socket_t *sock, + fspr_sockaddr_t *where, + fspr_int32_t flags, const char *buf, + fspr_size_t *len) { - apr_ssize_t rv; + fspr_ssize_t rv; rv = sendto(sock->socketdes, buf, (int)*len, flags, (const struct sockaddr*)&where->sa, where->salen); if (rv == SOCKET_ERROR) { *len = 0; - return apr_get_netos_error(); + return fspr_get_netos_error(); } *len = rv; @@ -183,18 +183,18 @@ APR_DECLARE(apr_status_t) apr_socket_sendto(apr_socket_t *sock, } -APR_DECLARE(apr_status_t) apr_socket_recvfrom(apr_sockaddr_t *from, - apr_socket_t *sock, - apr_int32_t flags, - char *buf, apr_size_t *len) +APR_DECLARE(fspr_status_t) fspr_socket_recvfrom(fspr_sockaddr_t *from, + fspr_socket_t *sock, + fspr_int32_t flags, + char *buf, fspr_size_t *len) { - apr_ssize_t rv; + fspr_ssize_t rv; rv = recvfrom(sock->socketdes, buf, (int)*len, flags, (struct sockaddr*)&from->sa, &from->salen); if (rv == SOCKET_ERROR) { (*len) = 0; - return apr_get_netos_error(); + return fspr_get_netos_error(); } (*len) = rv; if (rv == 0 && sock->type == SOCK_STREAM) @@ -204,9 +204,9 @@ APR_DECLARE(apr_status_t) apr_socket_recvfrom(apr_sockaddr_t *from, } -static apr_status_t collapse_iovec(char **off, apr_size_t *len, +static fspr_status_t collapse_iovec(char **off, fspr_size_t *len, struct iovec *iovec, int numvec, - char *buf, apr_size_t buflen) + char *buf, fspr_size_t buflen) { if (numvec == 1) { *off = iovec[0].iov_base; @@ -236,8 +236,8 @@ static apr_status_t collapse_iovec(char **off, apr_size_t *len, #if APR_HAS_SENDFILE /* - * apr_status_t apr_socket_sendfile(apr_socket_t *, apr_file_t *, apr_hdtr_t *, - * apr_off_t *, apr_size_t *, apr_int32_t flags) + * fspr_status_t fspr_socket_sendfile(fspr_socket_t *, fspr_file_t *, fspr_hdtr_t *, + * fspr_off_t *, fspr_size_t *, fspr_int32_t flags) * Send a file from an open file descriptor to a socket, along with * optional headers and trailers * arg 1) The socket to which we're writing @@ -247,26 +247,26 @@ static apr_status_t collapse_iovec(char **off, apr_size_t *len, * arg 5) Number of bytes to send out of the file * arg 6) APR flags that are mapped to OS specific flags */ -APR_DECLARE(apr_status_t) apr_socket_sendfile(apr_socket_t *sock, - apr_file_t *file, - apr_hdtr_t *hdtr, - apr_off_t *offset, - apr_size_t *len, - apr_int32_t flags) +APR_DECLARE(fspr_status_t) fspr_socket_sendfile(fspr_socket_t *sock, + fspr_file_t *file, + fspr_hdtr_t *hdtr, + fspr_off_t *offset, + fspr_size_t *len, + fspr_int32_t flags) { - apr_status_t status = APR_SUCCESS; - apr_status_t rv; - apr_off_t curoff = *offset; + fspr_status_t status = APR_SUCCESS; + fspr_status_t rv; + fspr_off_t curoff = *offset; DWORD dwFlags = 0; - apr_size_t nbytes; + fspr_size_t nbytes; TRANSMIT_FILE_BUFFERS tfb, *ptfb = NULL; int ptr = 0; - apr_size_t bytes_to_send; /* Bytes to send out of the file (not including headers) */ + fspr_size_t bytes_to_send; /* Bytes to send out of the file (not including headers) */ int disconnected = 0; int sendv_trailers = 0; char hdtrbuf[4096]; - if (apr_os_level < APR_WIN_NT) { + if (fspr_os_level < APR_WIN_NT) { return APR_ENOTIMPL; } @@ -277,14 +277,14 @@ APR_DECLARE(apr_status_t) apr_socket_sendfile(apr_socket_t *sock, /* Handle the goofy case of sending headers/trailers and a zero byte file */ if (!bytes_to_send && hdtr) { if (hdtr->numheaders) { - rv = apr_socket_sendv(sock, hdtr->headers, hdtr->numheaders, + rv = fspr_socket_sendv(sock, hdtr->headers, hdtr->numheaders, &nbytes); if (rv != APR_SUCCESS) return rv; *len += nbytes; } if (hdtr->numtrailers) { - rv = apr_socket_sendv(sock, hdtr->trailers, hdtr->numtrailers, + rv = fspr_socket_sendv(sock, hdtr->trailers, hdtr->numtrailers, &nbytes); if (rv != APR_SUCCESS) return rv; @@ -297,7 +297,7 @@ APR_DECLARE(apr_status_t) apr_socket_sendfile(apr_socket_t *sock, /* Collapse the headers into a single buffer */ if (hdtr && hdtr->numheaders) { - apr_size_t head_length = tfb.HeadLength; + fspr_size_t head_length = tfb.HeadLength; ptfb = &tfb; nbytes = 0; rv = collapse_iovec((char **)&ptfb->Head, &head_length, @@ -308,7 +308,7 @@ APR_DECLARE(apr_status_t) apr_socket_sendfile(apr_socket_t *sock, /* If not enough buffer, punt to sendv */ if (rv == APR_INCOMPLETE) { - rv = apr_socket_sendv(sock, hdtr->headers, hdtr->numheaders, &nbytes); + rv = fspr_socket_sendv(sock, hdtr->headers, hdtr->numheaders, &nbytes); if (rv != APR_SUCCESS) return rv; *len += nbytes; @@ -319,7 +319,7 @@ APR_DECLARE(apr_status_t) apr_socket_sendfile(apr_socket_t *sock, /* Initialize the overlapped structure used on TransmitFile */ if (!sock->overlapped) { - sock->overlapped = apr_pcalloc(sock->pool, sizeof(OVERLAPPED)); + sock->overlapped = fspr_pcalloc(sock->pool, sizeof(OVERLAPPED)); sock->overlapped->hEvent = CreateEvent(NULL, FALSE, FALSE, NULL); } while (bytes_to_send) { @@ -333,7 +333,7 @@ APR_DECLARE(apr_status_t) apr_socket_sendfile(apr_socket_t *sock, xmitbytes = (DWORD)bytes_to_send; /* Collapse the trailers into a single buffer */ if (hdtr && hdtr->numtrailers) { - apr_size_t tail_length = tfb.TailLength; + fspr_size_t tail_length = tfb.TailLength; ptfb = &tfb; rv = collapse_iovec((char**) &ptfb->Tail, &tail_length, hdtr->trailers, hdtr->numtrailers, @@ -369,7 +369,7 @@ APR_DECLARE(apr_status_t) apr_socket_sendfile(apr_socket_t *sock, ptfb, /* header and trailer buffers */ dwFlags); /* flags to control various aspects of TransmitFile */ if (!rv) { - status = apr_get_netos_error(); + status = fspr_get_netos_error(); if ((status == APR_FROM_OS_ERROR(ERROR_IO_PENDING)) || (status == APR_FROM_OS_ERROR(WSA_IO_PENDING))) { @@ -384,7 +384,7 @@ APR_DECLARE(apr_status_t) apr_socket_sendfile(apr_socket_t *sock, &xmitbytes, FALSE, &dwFlags)) { - status = apr_get_netos_error(); + status = fspr_get_netos_error(); } /* Ugly code alert: WSAGetOverlappedResult returns * a count of all bytes sent. This loop only @@ -408,7 +408,7 @@ APR_DECLARE(apr_status_t) apr_socket_sendfile(apr_socket_t *sock, status = APR_FROM_OS_ERROR(WAIT_TIMEOUT); } else - status = apr_get_os_error(); + status = fspr_get_os_error(); } } if (status != APR_SUCCESS) @@ -427,7 +427,7 @@ APR_DECLARE(apr_status_t) apr_socket_sendfile(apr_socket_t *sock, if (status == APR_SUCCESS) { if (sendv_trailers) { - rv = apr_socket_sendv(sock, hdtr->trailers, hdtr->numtrailers, &nbytes); + rv = fspr_socket_sendv(sock, hdtr->trailers, hdtr->numtrailers, &nbytes); if (rv != APR_SUCCESS) return rv; *len += nbytes; @@ -436,7 +436,7 @@ APR_DECLARE(apr_status_t) apr_socket_sendfile(apr_socket_t *sock, /* Mark the socket as disconnected, but do not close it. * Note: The application must have stored the socket prior to making - * the call to apr_socket_sendfile in order to either reuse it + * the call to fspr_socket_sendfile in order to either reuse it * or close it. */ if (disconnected) { diff --git a/libs/apr/network_io/win32/sockets.c b/libs/apr/network_io/win32/sockets.c index eed351b04a..0a649c6f2d 100644 --- a/libs/apr/network_io/win32/sockets.c +++ b/libs/apr/network_io/win32/sockets.c @@ -14,25 +14,25 @@ * limitations under the License. */ -#include "apr_arch_networkio.h" -#include "apr_network_io.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_portable.h" -#include "apr_strings.h" +#include "fspr_arch_networkio.h" +#include "fspr_network_io.h" +#include "fspr_general.h" +#include "fspr_lib.h" +#include "fspr_portable.h" +#include "fspr_strings.h" #include -#include "apr_arch_inherit.h" -#include "apr_arch_misc.h" +#include "fspr_arch_inherit.h" +#include "fspr_arch_misc.h" static char generic_inaddr_any[16] = {0}; /* big enough for IPv4 or IPv6 */ -static apr_status_t socket_cleanup(void *sock) +static fspr_status_t socket_cleanup(void *sock) { - apr_socket_t *thesocket = sock; + fspr_socket_t *thesocket = sock; if (thesocket->socketdes != INVALID_SOCKET) { if (closesocket(thesocket->socketdes) == SOCKET_ERROR) { - return apr_get_netos_error(); + return fspr_get_netos_error(); } thesocket->socketdes = INVALID_SOCKET; } @@ -45,41 +45,41 @@ static apr_status_t socket_cleanup(void *sock) return APR_SUCCESS; } -static void set_socket_vars(apr_socket_t *sock, int family, int type, int protocol) +static void set_socket_vars(fspr_socket_t *sock, int family, int type, int protocol) { sock->type = type; sock->protocol = protocol; - apr_sockaddr_vars_set(sock->local_addr, family, 0); - apr_sockaddr_vars_set(sock->remote_addr, family, 0); + fspr_sockaddr_vars_set(sock->local_addr, family, 0); + fspr_sockaddr_vars_set(sock->remote_addr, family, 0); } -static void alloc_socket(apr_socket_t **new, apr_pool_t *p) +static void alloc_socket(fspr_socket_t **new, fspr_pool_t *p) { - *new = (apr_socket_t *)apr_pcalloc(p, sizeof(apr_socket_t)); + *new = (fspr_socket_t *)fspr_pcalloc(p, sizeof(fspr_socket_t)); (*new)->pool = p; - (*new)->local_addr = (apr_sockaddr_t *)apr_pcalloc((*new)->pool, - sizeof(apr_sockaddr_t)); + (*new)->local_addr = (fspr_sockaddr_t *)fspr_pcalloc((*new)->pool, + sizeof(fspr_sockaddr_t)); (*new)->local_addr->pool = p; - (*new)->remote_addr = (apr_sockaddr_t *)apr_pcalloc((*new)->pool, - sizeof(apr_sockaddr_t)); + (*new)->remote_addr = (fspr_sockaddr_t *)fspr_pcalloc((*new)->pool, + sizeof(fspr_sockaddr_t)); (*new)->remote_addr->pool = p; (*new)->remote_addr_unknown = 1; /* Create a pollset with room for one descriptor. */ /* ### check return codes */ - (void) apr_pollset_create(&(*new)->pollset, 1, p, 0); + (void) fspr_pollset_create(&(*new)->pollset, 1, p, 0); } -APR_DECLARE(apr_status_t) apr_socket_protocol_get(apr_socket_t *sock, +APR_DECLARE(fspr_status_t) fspr_socket_protocol_get(fspr_socket_t *sock, int *protocol) { *protocol = sock->protocol; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_socket_create(apr_socket_t **new, int family, +APR_DECLARE(fspr_status_t) fspr_socket_create(fspr_socket_t **new, int family, int type, int protocol, - apr_pool_t *cont) + fspr_pool_t *cont) { int downgrade = (family == AF_UNSPEC); @@ -105,7 +105,7 @@ APR_DECLARE(apr_status_t) apr_socket_create(apr_socket_t **new, int family, #endif if ((*new)->socketdes == INVALID_SOCKET) { - return apr_get_netos_error(); + return fspr_get_netos_error(); } #ifdef WIN32 @@ -148,14 +148,14 @@ APR_DECLARE(apr_status_t) apr_socket_create(apr_socket_t **new, int family, (*new)->timeout = -1; (*new)->disconnected = 0; - apr_pool_cleanup_register((*new)->pool, (void *)(*new), - socket_cleanup, apr_pool_cleanup_null); + fspr_pool_cleanup_register((*new)->pool, (void *)(*new), + socket_cleanup, fspr_pool_cleanup_null); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_socket_shutdown(apr_socket_t *thesocket, - apr_shutdown_how_e how) +APR_DECLARE(fspr_status_t) fspr_socket_shutdown(fspr_socket_t *thesocket, + fspr_shutdown_how_e how) { int winhow = 0; @@ -181,23 +181,23 @@ APR_DECLARE(apr_status_t) apr_socket_shutdown(apr_socket_t *thesocket, return APR_SUCCESS; } else { - return apr_get_netos_error(); + return fspr_get_netos_error(); } } -APR_DECLARE(apr_status_t) apr_socket_close(apr_socket_t *thesocket) +APR_DECLARE(fspr_status_t) fspr_socket_close(fspr_socket_t *thesocket) { - apr_pool_cleanup_kill(thesocket->pool, thesocket, socket_cleanup); + fspr_pool_cleanup_kill(thesocket->pool, thesocket, socket_cleanup); return socket_cleanup(thesocket); } -APR_DECLARE(apr_status_t) apr_socket_bind(apr_socket_t *sock, - apr_sockaddr_t *sa) +APR_DECLARE(fspr_status_t) fspr_socket_bind(fspr_socket_t *sock, + fspr_sockaddr_t *sa) { if (bind(sock->socketdes, (struct sockaddr *)&sa->sa, sa->salen) == -1) { - return apr_get_netos_error(); + return fspr_get_netos_error(); } else { sock->local_addr = sa; @@ -208,17 +208,17 @@ APR_DECLARE(apr_status_t) apr_socket_bind(apr_socket_t *sock, } } -APR_DECLARE(apr_status_t) apr_socket_listen(apr_socket_t *sock, - apr_int32_t backlog) +APR_DECLARE(fspr_status_t) fspr_socket_listen(fspr_socket_t *sock, + fspr_int32_t backlog) { if (listen(sock->socketdes, backlog) == SOCKET_ERROR) - return apr_get_netos_error(); + return fspr_get_netos_error(); else return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_socket_accept(apr_socket_t **new, - apr_socket_t *sock, apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_socket_accept(fspr_socket_t **new, + fspr_socket_t *sock, fspr_pool_t *p) { SOCKET s; #if APR_HAVE_IPV6 @@ -232,7 +232,7 @@ APR_DECLARE(apr_status_t) apr_socket_accept(apr_socket_t **new, us to work with nonblocking sockets. */ s = accept(sock->socketdes, (struct sockaddr *)&sa, &salen); if (s == INVALID_SOCKET) { - return apr_get_netos_error(); + return fspr_get_netos_error(); } alloc_socket(new, p); @@ -270,13 +270,13 @@ APR_DECLARE(apr_status_t) apr_socket_accept(apr_socket_t **new, } #if APR_TCP_NODELAY_INHERITED - if (apr_is_option_set(sock, APR_TCP_NODELAY) == 1) { - apr_set_option(*new, APR_TCP_NODELAY, 1); + if (fspr_is_option_set(sock, APR_TCP_NODELAY) == 1) { + fspr_set_option(*new, APR_TCP_NODELAY, 1); } #endif /* TCP_NODELAY_INHERITED */ #if APR_O_NONBLOCK_INHERITED - if (apr_is_option_set(sock, APR_SO_NONBLOCK) == 1) { - apr_set_option(*new, APR_SO_NONBLOCK, 1); + if (fspr_is_option_set(sock, APR_SO_NONBLOCK) == 1) { + fspr_set_option(*new, APR_SO_NONBLOCK, 1); } #endif /* APR_O_NONBLOCK_INHERITED */ @@ -293,15 +293,15 @@ APR_DECLARE(apr_status_t) apr_socket_accept(apr_socket_t **new, (*new)->local_interface_unknown = 1; } - apr_pool_cleanup_register((*new)->pool, (void *)(*new), - socket_cleanup, apr_pool_cleanup_null); + fspr_pool_cleanup_register((*new)->pool, (void *)(*new), + socket_cleanup, fspr_pool_cleanup_null); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_socket_connect(apr_socket_t *sock, - apr_sockaddr_t *sa) +APR_DECLARE(fspr_status_t) fspr_socket_connect(fspr_socket_t *sock, + fspr_sockaddr_t *sa) { - apr_status_t rv; + fspr_status_t rv; if ((sock->socketdes == INVALID_SOCKET) || (!sock->local_addr)) { return APR_ENOTSOCK; @@ -313,7 +313,7 @@ APR_DECLARE(apr_status_t) apr_socket_connect(apr_socket_t *sock, struct timeval tv, *tvptr; fd_set wfdset, efdset; - rv = apr_get_netos_error(); + rv = fspr_get_netos_error(); if (rv != APR_FROM_OS_ERROR(WSAEWOULDBLOCK)) { return rv; } @@ -338,13 +338,13 @@ APR_DECLARE(apr_status_t) apr_socket_connect(apr_socket_t *sock, } else { /* casts for winsock/timeval definition */ - tv.tv_sec = (long)apr_time_sec(sock->timeout); - tv.tv_usec = (int)apr_time_usec(sock->timeout); + tv.tv_sec = (long)fspr_time_sec(sock->timeout); + tv.tv_usec = (int)fspr_time_usec(sock->timeout); tvptr = &tv; } rc = select(FD_SETSIZE+1, NULL, &wfdset, &efdset, tvptr); if (rc == SOCKET_ERROR) { - return apr_get_netos_error(); + return fspr_get_netos_error(); } else if (!rc) { return APR_FROM_OS_ERROR(WSAETIMEDOUT); @@ -354,7 +354,7 @@ APR_DECLARE(apr_status_t) apr_socket_connect(apr_socket_t *sock, /* The connect failed. */ int rclen = sizeof(rc); if (getsockopt(sock->socketdes, SOL_SOCKET, SO_ERROR, (char*) &rc, &rclen)) { - return apr_get_netos_error(); + return fspr_get_netos_error(); } return APR_FROM_OS_ERROR(rc); } @@ -375,14 +375,14 @@ APR_DECLARE(apr_status_t) apr_socket_connect(apr_socket_t *sock, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_socket_type_get(apr_socket_t *sock, int *type) +APR_DECLARE(fspr_status_t) fspr_socket_type_get(fspr_socket_t *sock, int *type) { *type = sock->type; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_socket_data_get(void **data, const char *key, - apr_socket_t *sock) +APR_DECLARE(fspr_status_t) fspr_socket_data_get(void **data, const char *key, + fspr_socket_t *sock) { sock_userdata_t *cur = sock->userdata; @@ -399,77 +399,77 @@ APR_DECLARE(apr_status_t) apr_socket_data_get(void **data, const char *key, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_socket_data_set(apr_socket_t *sock, void *data, +APR_DECLARE(fspr_status_t) fspr_socket_data_set(fspr_socket_t *sock, void *data, const char *key, - apr_status_t (*cleanup)(void *)) + fspr_status_t (*cleanup)(void *)) { - sock_userdata_t *new = apr_palloc(sock->pool, sizeof(sock_userdata_t)); + sock_userdata_t *new = fspr_palloc(sock->pool, sizeof(sock_userdata_t)); - new->key = apr_pstrdup(sock->pool, key); + new->key = fspr_pstrdup(sock->pool, key); new->data = data; new->next = sock->userdata; sock->userdata = new; if (cleanup) { - apr_pool_cleanup_register(sock->pool, data, cleanup, cleanup); + fspr_pool_cleanup_register(sock->pool, data, cleanup, cleanup); } return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_os_sock_get(apr_os_sock_t *thesock, - apr_socket_t *sock) +APR_DECLARE(fspr_status_t) fspr_os_sock_get(fspr_os_sock_t *thesock, + fspr_socket_t *sock) { *thesock = sock->socketdes; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_os_sock_make(apr_socket_t **apr_sock, - apr_os_sock_info_t *os_sock_info, - apr_pool_t *cont) +APR_DECLARE(fspr_status_t) fspr_os_sock_make(fspr_socket_t **fspr_sock, + fspr_os_sock_info_t *os_sock_info, + fspr_pool_t *cont) { - alloc_socket(apr_sock, cont); - set_socket_vars(*apr_sock, os_sock_info->family, os_sock_info->type, os_sock_info->protocol); - (*apr_sock)->timeout = -1; - (*apr_sock)->disconnected = 0; - (*apr_sock)->socketdes = *os_sock_info->os_sock; + alloc_socket(fspr_sock, cont); + set_socket_vars(*fspr_sock, os_sock_info->family, os_sock_info->type, os_sock_info->protocol); + (*fspr_sock)->timeout = -1; + (*fspr_sock)->disconnected = 0; + (*fspr_sock)->socketdes = *os_sock_info->os_sock; if (os_sock_info->local) { - memcpy(&(*apr_sock)->local_addr->sa.sin, + memcpy(&(*fspr_sock)->local_addr->sa.sin, os_sock_info->local, - (*apr_sock)->local_addr->salen); - (*apr_sock)->local_addr->pool = cont; + (*fspr_sock)->local_addr->salen); + (*fspr_sock)->local_addr->pool = cont; /* XXX IPv6 - this assumes sin_port and sin6_port at same offset */ - (*apr_sock)->local_addr->port = ntohs((*apr_sock)->local_addr->sa.sin.sin_port); + (*fspr_sock)->local_addr->port = ntohs((*fspr_sock)->local_addr->sa.sin.sin_port); } else { - (*apr_sock)->local_port_unknown = (*apr_sock)->local_interface_unknown = 1; + (*fspr_sock)->local_port_unknown = (*fspr_sock)->local_interface_unknown = 1; } if (os_sock_info->remote) { - memcpy(&(*apr_sock)->remote_addr->sa.sin, + memcpy(&(*fspr_sock)->remote_addr->sa.sin, os_sock_info->remote, - (*apr_sock)->remote_addr->salen); - (*apr_sock)->remote_addr->pool = cont; + (*fspr_sock)->remote_addr->salen); + (*fspr_sock)->remote_addr->pool = cont; /* XXX IPv6 - this assumes sin_port and sin6_port at same offset */ - (*apr_sock)->remote_addr->port = ntohs((*apr_sock)->remote_addr->sa.sin.sin_port); + (*fspr_sock)->remote_addr->port = ntohs((*fspr_sock)->remote_addr->sa.sin.sin_port); } else { - (*apr_sock)->remote_addr_unknown = 1; + (*fspr_sock)->remote_addr_unknown = 1; } - apr_pool_cleanup_register((*apr_sock)->pool, (void *)(*apr_sock), - socket_cleanup, apr_pool_cleanup_null); + fspr_pool_cleanup_register((*fspr_sock)->pool, (void *)(*fspr_sock), + socket_cleanup, fspr_pool_cleanup_null); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_os_sock_put(apr_socket_t **sock, - apr_os_sock_t *thesock, - apr_pool_t *cont) +APR_DECLARE(fspr_status_t) fspr_os_sock_put(fspr_socket_t **sock, + fspr_os_sock_t *thesock, + fspr_pool_t *cont) { if ((*sock) == NULL) { alloc_socket(sock, cont); /* XXX figure out the actual socket type here */ - /* *or* just decide that apr_os_sock_put() has to be told the family and type */ + /* *or* just decide that fspr_os_sock_put() has to be told the family and type */ set_socket_vars(*sock, AF_INET, SOCK_STREAM, 0); (*sock)->timeout = -1; (*sock)->disconnected = 0; @@ -486,12 +486,12 @@ APR_DECLARE(apr_status_t) apr_os_sock_put(apr_socket_t **sock, * This is not trivial to implement. */ -APR_DECLARE(apr_status_t) apr_socket_inherit_set(apr_socket_t *socket) +APR_DECLARE(fspr_status_t) fspr_socket_inherit_set(fspr_socket_t *socket) { return APR_ENOTIMPL; } -APR_DECLARE(apr_status_t) apr_socket_inherit_unset(apr_socket_t *socket) +APR_DECLARE(fspr_status_t) fspr_socket_inherit_unset(fspr_socket_t *socket) { return APR_ENOTIMPL; } diff --git a/libs/apr/network_io/win32/sockopt.c b/libs/apr/network_io/win32/sockopt.c index 05ba19c9b8..ee92233836 100644 --- a/libs/apr/network_io/win32/sockopt.c +++ b/libs/apr/network_io/win32/sockopt.c @@ -14,36 +14,36 @@ * limitations under the License. */ -#include "apr_arch_networkio.h" -#include "apr_network_io.h" -#include "apr_general.h" -#include "apr_strings.h" +#include "fspr_arch_networkio.h" +#include "fspr_network_io.h" +#include "fspr_general.h" +#include "fspr_strings.h" #include -apr_status_t soblock(SOCKET sd) +fspr_status_t soblock(SOCKET sd) { u_long zero = 0; if (ioctlsocket(sd, FIONBIO, &zero) == SOCKET_ERROR) { - return apr_get_netos_error(); + return fspr_get_netos_error(); } return APR_SUCCESS; } -apr_status_t sononblock(SOCKET sd) +fspr_status_t sononblock(SOCKET sd) { u_long one = 1; if (ioctlsocket(sd, FIONBIO, &one) == SOCKET_ERROR) { - return apr_get_netos_error(); + return fspr_get_netos_error(); } return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_socket_timeout_set(apr_socket_t *sock, apr_interval_time_t t) +APR_DECLARE(fspr_status_t) fspr_socket_timeout_set(fspr_socket_t *sock, fspr_interval_time_t t) { - apr_status_t stat; + fspr_status_t stat; if (t == 0) { /* Set the socket non-blocking if it was previously blocking */ @@ -62,7 +62,7 @@ APR_DECLARE(apr_status_t) apr_socket_timeout_set(apr_socket_t *sock, apr_interva if (sock->timeout != t) { /* Win32 timeouts are in msec, represented as int */ - sock->timeout_ms = (int)apr_time_as_msec(t); + sock->timeout_ms = (int)fspr_time_as_msec(t); setsockopt(sock->socketdes, SOL_SOCKET, SO_RCVTIMEO, (char *) &sock->timeout_ms, sizeof(sock->timeout_ms)); @@ -86,56 +86,56 @@ APR_DECLARE(apr_status_t) apr_socket_timeout_set(apr_socket_t *sock, apr_interva } -APR_DECLARE(apr_status_t) apr_socket_opt_set(apr_socket_t *sock, - apr_int32_t opt, apr_int32_t on) +APR_DECLARE(fspr_status_t) fspr_socket_opt_set(fspr_socket_t *sock, + fspr_int32_t opt, fspr_int32_t on) { int one; - apr_status_t stat; + fspr_status_t stat; one = on ? 1 : 0; switch (opt) { case APR_SO_KEEPALIVE: - if (on != apr_is_option_set(sock, APR_SO_KEEPALIVE)) { + if (on != fspr_is_option_set(sock, APR_SO_KEEPALIVE)) { if (setsockopt(sock->socketdes, SOL_SOCKET, SO_KEEPALIVE, (void *)&one, sizeof(int)) == -1) { - return apr_get_netos_error(); + return fspr_get_netos_error(); } - apr_set_option(sock, APR_SO_KEEPALIVE, on); + fspr_set_option(sock, APR_SO_KEEPALIVE, on); } break; case APR_SO_DEBUG: - if (on != apr_is_option_set(sock, APR_SO_DEBUG)) { + if (on != fspr_is_option_set(sock, APR_SO_DEBUG)) { if (setsockopt(sock->socketdes, SOL_SOCKET, SO_DEBUG, (void *)&one, sizeof(int)) == -1) { - return apr_get_netos_error(); + return fspr_get_netos_error(); } - apr_set_option(sock, APR_SO_DEBUG, on); + fspr_set_option(sock, APR_SO_DEBUG, on); } break; case APR_SO_SNDBUF: if (setsockopt(sock->socketdes, SOL_SOCKET, SO_SNDBUF, (void *)&on, sizeof(int)) == -1) { - return apr_get_netos_error(); + return fspr_get_netos_error(); } break; case APR_SO_RCVBUF: if (setsockopt(sock->socketdes, SOL_SOCKET, SO_RCVBUF, (void *)&on, sizeof(int)) == -1) { - return apr_get_netos_error(); + return fspr_get_netos_error(); } break; case APR_SO_REUSEADDR: - if (on != apr_is_option_set(sock, APR_SO_REUSEADDR)) { + if (on != fspr_is_option_set(sock, APR_SO_REUSEADDR)) { if (setsockopt(sock->socketdes, SOL_SOCKET, SO_REUSEADDR, (void *)&one, sizeof(int)) == -1) { - return apr_get_netos_error(); + return fspr_get_netos_error(); } - apr_set_option(sock, APR_SO_REUSEADDR, on); + fspr_set_option(sock, APR_SO_REUSEADDR, on); } break; case APR_SO_NONBLOCK: - if (apr_is_option_set(sock, APR_SO_NONBLOCK) != on) { + if (fspr_is_option_set(sock, APR_SO_NONBLOCK) != on) { if (on) { if ((stat = sononblock(sock->socketdes)) != APR_SUCCESS) return stat; @@ -144,26 +144,26 @@ APR_DECLARE(apr_status_t) apr_socket_opt_set(apr_socket_t *sock, if ((stat = soblock(sock->socketdes)) != APR_SUCCESS) return stat; } - apr_set_option(sock, APR_SO_NONBLOCK, on); + fspr_set_option(sock, APR_SO_NONBLOCK, on); } break; case APR_SO_LINGER: { - if (apr_is_option_set(sock, APR_SO_LINGER) != on) { + if (fspr_is_option_set(sock, APR_SO_LINGER) != on) { struct linger li; li.l_onoff = on; li.l_linger = APR_MAX_SECS_TO_LINGER; if (setsockopt(sock->socketdes, SOL_SOCKET, SO_LINGER, (char *) &li, sizeof(struct linger)) == -1) { - return apr_get_netos_error(); + return fspr_get_netos_error(); } - apr_set_option(sock, APR_SO_LINGER, on); + fspr_set_option(sock, APR_SO_LINGER, on); } break; } case APR_TCP_DEFER_ACCEPT: #if defined(TCP_DEFER_ACCEPT) - if (apr_is_option_set(sock, APR_TCP_DEFER_ACCEPT) != on) { + if (fspr_is_option_set(sock, APR_TCP_DEFER_ACCEPT) != on) { int optlevel = IPPROTO_TCP; int optname = TCP_DEFER_ACCEPT; @@ -171,13 +171,13 @@ APR_DECLARE(apr_status_t) apr_socket_opt_set(apr_socket_t *sock, (void *)&on, sizeof(int)) == -1) { return errno; } - apr_set_option(sock, APR_TCP_DEFER_ACCEPT, on); + fspr_set_option(sock, APR_TCP_DEFER_ACCEPT, on); } #else return APR_ENOTIMPL; #endif case APR_TCP_NODELAY: - if (apr_is_option_set(sock, APR_TCP_NODELAY) != on) { + if (fspr_is_option_set(sock, APR_TCP_NODELAY) != on) { int optlevel = IPPROTO_TCP; int optname = TCP_NODELAY; @@ -189,9 +189,9 @@ APR_DECLARE(apr_status_t) apr_socket_opt_set(apr_socket_t *sock, #endif if (setsockopt(sock->socketdes, optlevel, optname, (void *)&on, sizeof(int)) == -1) { - return apr_get_netos_error(); + return fspr_get_netos_error(); } - apr_set_option(sock, APR_TCP_NODELAY, on); + fspr_set_option(sock, APR_TCP_NODELAY, on); } break; case APR_IPV6_V6ONLY: @@ -202,9 +202,9 @@ APR_DECLARE(apr_status_t) apr_socket_opt_set(apr_socket_t *sock, */ if (setsockopt(sock->socketdes, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&on, sizeof(int)) == -1) { - return apr_get_netos_error(); + return fspr_get_netos_error(); } - apr_set_option(sock, APR_IPV6_V6ONLY, on); + fspr_set_option(sock, APR_IPV6_V6ONLY, on); #else return APR_ENOTIMPL; #endif @@ -217,15 +217,15 @@ APR_DECLARE(apr_status_t) apr_socket_opt_set(apr_socket_t *sock, } -APR_DECLARE(apr_status_t) apr_socket_timeout_get(apr_socket_t *sock, apr_interval_time_t *t) +APR_DECLARE(fspr_status_t) fspr_socket_timeout_get(fspr_socket_t *sock, fspr_interval_time_t *t) { *t = sock->timeout; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_socket_opt_get(apr_socket_t *sock, - apr_int32_t opt, apr_int32_t *on) +APR_DECLARE(fspr_status_t) fspr_socket_opt_get(fspr_socket_t *sock, + fspr_int32_t opt, fspr_int32_t *on) { switch (opt) { case APR_SO_DISCONNECTED: @@ -237,14 +237,14 @@ APR_DECLARE(apr_status_t) apr_socket_opt_get(apr_socket_t *sock, case APR_SO_NONBLOCK: case APR_SO_LINGER: default: - *on = apr_is_option_set(sock, opt); + *on = fspr_is_option_set(sock, opt); break; } return APR_SUCCESS; } -APR_DECLARE(int) apr_socket_fd_get(apr_socket_t *sock) +APR_DECLARE(int) fspr_socket_fd_get(fspr_socket_t *sock) { if (sock) { return sock->socketdes; @@ -254,12 +254,12 @@ APR_DECLARE(int) apr_socket_fd_get(apr_socket_t *sock) } -APR_DECLARE(apr_status_t) apr_socket_atmark(apr_socket_t *sock, int *atmark) +APR_DECLARE(fspr_status_t) fspr_socket_atmark(fspr_socket_t *sock, int *atmark) { u_long oobmark; if (ioctlsocket(sock->socketdes, SIOCATMARK, (void*) &oobmark) < 0) - return apr_get_netos_error(); + return fspr_get_netos_error(); *atmark = (oobmark != 0); @@ -267,12 +267,12 @@ APR_DECLARE(apr_status_t) apr_socket_atmark(apr_socket_t *sock, int *atmark) } -APR_DECLARE(apr_status_t) apr_gethostname(char *buf, int len, - apr_pool_t *cont) +APR_DECLARE(fspr_status_t) fspr_gethostname(char *buf, int len, + fspr_pool_t *cont) { if (gethostname(buf, len) == -1) { buf[0] = '\0'; - return apr_get_netos_error(); + return fspr_get_netos_error(); } else if (!memchr(buf, '\0', len)) { /* buffer too small */ buf[0] = '\0'; diff --git a/libs/apr/passwd/apr_getpass.c b/libs/apr/passwd/fspr_getpass.c similarity index 93% rename from libs/apr/passwd/apr_getpass.c rename to libs/apr/passwd/fspr_getpass.c index 7e89774948..c03087f027 100644 --- a/libs/apr/passwd/apr_getpass.c +++ b/libs/apr/passwd/fspr_getpass.c @@ -14,15 +14,15 @@ * limitations under the License. */ -/* apr_password_get.c: abstraction to provide for obtaining a password from the +/* fspr_password_get.c: abstraction to provide for obtaining a password from the * command line in whatever way the OS supports. In the best case, it's a * wrapper for the system library's getpass() routine; otherwise, we * use one we define ourselves. */ -#include "apr_private.h" -#include "apr_strings.h" -#include "apr_lib.h" -#include "apr_errno.h" +#include "fspr_private.h" +#include "fspr_strings.h" +#include "fspr_lib.h" +#include "fspr_errno.h" #if APR_HAVE_SYS_TYPES_H #include #endif @@ -179,7 +179,7 @@ static char *getpass(const char *prompt) fputs(prompt, stderr); n = 0; } - else if ((n < sizeof(password) - 1) && !apr_iscntrl(ch)) { + else if ((n < sizeof(password) - 1) && !fspr_iscntrl(ch)) { password[n++] = ch; fputc('*', stderr); } @@ -213,21 +213,21 @@ static char *getpass(const char *prompt) * smaller than our own. */ -APR_DECLARE(apr_status_t) apr_password_get(const char *prompt, char *pwbuf, apr_size_t *bufsiz) +APR_DECLARE(fspr_status_t) fspr_password_get(const char *prompt, char *pwbuf, fspr_size_t *bufsiz) { #ifdef HAVE_GETPASSPHRASE char *pw_got = getpassphrase(prompt); #else char *pw_got = getpass(prompt); #endif - apr_status_t rv = APR_SUCCESS; + fspr_status_t rv = APR_SUCCESS; if (!pw_got) return APR_EINVAL; if (strlen(pw_got) >= *bufsiz) { rv = APR_ENAMETOOLONG; } - apr_cpystrn(pwbuf, pw_got, *bufsiz); + fspr_cpystrn(pwbuf, pw_got, *bufsiz); memset(pw_got, 0, strlen(pw_got)); return rv; } diff --git a/libs/apr/poll/os2/poll.c b/libs/apr/poll/os2/poll.c index 3c36e5e688..f27b17e975 100644 --- a/libs/apr/poll/os2/poll.c +++ b/libs/apr/poll/os2/poll.c @@ -14,12 +14,12 @@ * limitations under the License. */ -#include "apr.h" -#include "apr_poll.h" -#include "apr_arch_networkio.h" +#include "fspr.h" +#include "fspr_poll.h" +#include "fspr_arch_networkio.h" -APR_DECLARE(apr_status_t) apr_poll(apr_pollfd_t *aprset, apr_int32_t num, - apr_int32_t *nsds, apr_interval_time_t timeout) +APR_DECLARE(fspr_status_t) fspr_poll(fspr_pollfd_t *aprset, fspr_int32_t num, + fspr_int32_t *nsds, fspr_interval_time_t timeout) { int *pollset; int i; diff --git a/libs/apr/poll/os2/pollset.c b/libs/apr/poll/os2/pollset.c index 0680c29c09..69f5f10cae 100644 --- a/libs/apr/poll/os2/pollset.c +++ b/libs/apr/poll/os2/pollset.c @@ -14,46 +14,46 @@ * limitations under the License. */ -#include "apr.h" -#include "apr_poll.h" -#include "apr_arch_networkio.h" +#include "fspr.h" +#include "fspr_poll.h" +#include "fspr_arch_networkio.h" -struct apr_pollset_t { - apr_pool_t *pool; - apr_uint32_t nelts; - apr_uint32_t nalloc; +struct fspr_pollset_t { + fspr_pool_t *pool; + fspr_uint32_t nelts; + fspr_uint32_t nalloc; int *pollset; int num_read; int num_write; int num_except; int num_total; - apr_pollfd_t *query_set; - apr_pollfd_t *result_set; + fspr_pollfd_t *query_set; + fspr_pollfd_t *result_set; }; -APR_DECLARE(apr_status_t) apr_pollset_create(apr_pollset_t **pollset, - apr_uint32_t size, - apr_pool_t *p, - apr_uint32_t flags) +APR_DECLARE(fspr_status_t) fspr_pollset_create(fspr_pollset_t **pollset, + fspr_uint32_t size, + fspr_pool_t *p, + fspr_uint32_t flags) { - *pollset = apr_palloc(p, sizeof(**pollset)); + *pollset = fspr_palloc(p, sizeof(**pollset)); (*pollset)->pool = p; (*pollset)->nelts = 0; (*pollset)->nalloc = size; - (*pollset)->pollset = apr_palloc(p, size * sizeof(int) * 3); - (*pollset)->query_set = apr_palloc(p, size * sizeof(apr_pollfd_t)); - (*pollset)->result_set = apr_palloc(p, size * sizeof(apr_pollfd_t)); + (*pollset)->pollset = fspr_palloc(p, size * sizeof(int) * 3); + (*pollset)->query_set = fspr_palloc(p, size * sizeof(fspr_pollfd_t)); + (*pollset)->result_set = fspr_palloc(p, size * sizeof(fspr_pollfd_t)); (*pollset)->num_read = -1; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_pollset_destroy(apr_pollset_t *pollset) +APR_DECLARE(fspr_status_t) fspr_pollset_destroy(fspr_pollset_t *pollset) { /* A no-op function for now. If we later implement /dev/poll * support, we'll need to close the /dev/poll fd here @@ -63,8 +63,8 @@ APR_DECLARE(apr_status_t) apr_pollset_destroy(apr_pollset_t *pollset) -APR_DECLARE(apr_status_t) apr_pollset_add(apr_pollset_t *pollset, - const apr_pollfd_t *descriptor) +APR_DECLARE(fspr_status_t) fspr_pollset_add(fspr_pollset_t *pollset, + const fspr_pollfd_t *descriptor) { if (pollset->nelts == pollset->nalloc) { return APR_ENOMEM; @@ -83,16 +83,16 @@ APR_DECLARE(apr_status_t) apr_pollset_add(apr_pollset_t *pollset, -APR_DECLARE(apr_status_t) apr_pollset_remove(apr_pollset_t *pollset, - const apr_pollfd_t *descriptor) +APR_DECLARE(fspr_status_t) fspr_pollset_remove(fspr_pollset_t *pollset, + const fspr_pollfd_t *descriptor) { - apr_uint32_t i; + fspr_uint32_t i; for (i = 0; i < pollset->nelts; i++) { if (descriptor->desc.s == pollset->query_set[i].desc.s) { /* Found an instance of the fd: remove this and any other copies */ - apr_uint32_t dst = i; - apr_uint32_t old_nelts = pollset->nelts; + fspr_uint32_t dst = i; + fspr_uint32_t old_nelts = pollset->nelts; pollset->nelts--; for (i++; i < old_nelts; i++) { @@ -116,7 +116,7 @@ APR_DECLARE(apr_status_t) apr_pollset_remove(apr_pollset_t *pollset, -static void make_pollset(apr_pollset_t *pollset) +static void make_pollset(fspr_pollset_t *pollset) { int i; int pos = 0; @@ -151,13 +151,13 @@ static void make_pollset(apr_pollset_t *pollset) -APR_DECLARE(apr_status_t) apr_pollset_poll(apr_pollset_t *pollset, - apr_interval_time_t timeout, - apr_int32_t *num, - const apr_pollfd_t **descriptors) +APR_DECLARE(fspr_status_t) fspr_pollset_poll(fspr_pollset_t *pollset, + fspr_interval_time_t timeout, + fspr_int32_t *num, + const fspr_pollfd_t **descriptors) { int rv; - apr_uint32_t i; + fspr_uint32_t i; int *pollresult; int read_pos, write_pos, except_pos; diff --git a/libs/apr/poll/unix/epoll.c b/libs/apr/poll/unix/epoll.c index 388c67c041..cf9e47392b 100644 --- a/libs/apr/poll/unix/epoll.c +++ b/libs/apr/poll/unix/epoll.c @@ -14,13 +14,13 @@ * limitations under the License. */ -#include "apr_arch_poll_private.h" +#include "fspr_arch_poll_private.h" #ifdef POLLSET_USES_EPOLL -static apr_int16_t get_epoll_event(apr_int16_t event) +static fspr_int16_t get_epoll_event(fspr_int16_t event) { - apr_int16_t rv = 0; + fspr_int16_t rv = 0; if (event & APR_POLLIN) rv |= EPOLLIN; @@ -37,9 +37,9 @@ static apr_int16_t get_epoll_event(apr_int16_t event) return rv; } -static apr_int16_t get_epoll_revent(apr_int16_t event) +static fspr_int16_t get_epoll_revent(fspr_int16_t event) { - apr_int16_t rv = 0; + fspr_int16_t rv = 0; if (event & EPOLLIN) rv |= APR_POLLIN; @@ -56,18 +56,18 @@ static apr_int16_t get_epoll_revent(apr_int16_t event) return rv; } -struct apr_pollset_t +struct fspr_pollset_t { - apr_pool_t *pool; - apr_uint32_t nelts; - apr_uint32_t nalloc; + fspr_pool_t *pool; + fspr_uint32_t nelts; + fspr_uint32_t nalloc; int epoll_fd; struct epoll_event *pollset; - apr_pollfd_t *result_set; - apr_uint32_t flags; + fspr_pollfd_t *result_set; + fspr_uint32_t flags; #if APR_HAS_THREADS /* A thread mutex to protect operations on the rings */ - apr_thread_mutex_t *ring_lock; + fspr_thread_mutex_t *ring_lock; #endif /* A ring containing all of the pollfd_t that are active */ APR_RING_HEAD(pfd_query_ring_t, pfd_elem_t) query_ring; @@ -78,19 +78,19 @@ struct apr_pollset_t APR_RING_HEAD(pfd_dead_ring_t, pfd_elem_t) dead_ring; }; -static apr_status_t backend_cleanup(void *p_) +static fspr_status_t backend_cleanup(void *p_) { - apr_pollset_t *pollset = (apr_pollset_t *) p_; + fspr_pollset_t *pollset = (fspr_pollset_t *) p_; close(pollset->epoll_fd); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_pollset_create(apr_pollset_t **pollset, - apr_uint32_t size, - apr_pool_t *p, - apr_uint32_t flags) +APR_DECLARE(fspr_status_t) fspr_pollset_create(fspr_pollset_t **pollset, + fspr_uint32_t size, + fspr_pool_t *p, + fspr_uint32_t flags) { - apr_status_t rv; + fspr_status_t rv; int fd; fd = epoll_create(size); @@ -99,10 +99,10 @@ APR_DECLARE(apr_status_t) apr_pollset_create(apr_pollset_t **pollset, return errno; } - *pollset = apr_palloc(p, sizeof(**pollset)); + *pollset = fspr_palloc(p, sizeof(**pollset)); #if APR_HAS_THREADS if (flags & APR_POLLSET_THREADSAFE && - ((rv = apr_thread_mutex_create(&(*pollset)->ring_lock, + ((rv = fspr_thread_mutex_create(&(*pollset)->ring_lock, APR_THREAD_MUTEX_DEFAULT, p) != APR_SUCCESS))) { *pollset = NULL; @@ -119,9 +119,9 @@ APR_DECLARE(apr_status_t) apr_pollset_create(apr_pollset_t **pollset, (*pollset)->flags = flags; (*pollset)->pool = p; (*pollset)->epoll_fd = fd; - (*pollset)->pollset = apr_palloc(p, size * sizeof(struct epoll_event)); - apr_pool_cleanup_register(p, *pollset, backend_cleanup, backend_cleanup); - (*pollset)->result_set = apr_palloc(p, size * sizeof(apr_pollfd_t)); + (*pollset)->pollset = fspr_palloc(p, size * sizeof(struct epoll_event)); + fspr_pool_cleanup_register(p, *pollset, backend_cleanup, backend_cleanup); + (*pollset)->result_set = fspr_palloc(p, size * sizeof(fspr_pollfd_t)); APR_RING_INIT(&(*pollset)->query_ring, pfd_elem_t, link); APR_RING_INIT(&(*pollset)->free_ring, pfd_elem_t, link); @@ -130,18 +130,18 @@ APR_DECLARE(apr_status_t) apr_pollset_create(apr_pollset_t **pollset, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_pollset_destroy(apr_pollset_t *pollset) +APR_DECLARE(fspr_status_t) fspr_pollset_destroy(fspr_pollset_t *pollset) { - return apr_pool_cleanup_run(pollset->pool, pollset, backend_cleanup); + return fspr_pool_cleanup_run(pollset->pool, pollset, backend_cleanup); } -APR_DECLARE(apr_status_t) apr_pollset_add(apr_pollset_t *pollset, - const apr_pollfd_t *descriptor) +APR_DECLARE(fspr_status_t) fspr_pollset_add(fspr_pollset_t *pollset, + const fspr_pollfd_t *descriptor) { struct epoll_event ev; int ret = -1; pfd_elem_t *elem; - apr_status_t rv = APR_SUCCESS; + fspr_status_t rv = APR_SUCCESS; pollset_lock_rings(); @@ -150,7 +150,7 @@ APR_DECLARE(apr_status_t) apr_pollset_add(apr_pollset_t *pollset, APR_RING_REMOVE(elem, link); } else { - elem = (pfd_elem_t *) apr_palloc(pollset->pool, sizeof(pfd_elem_t)); + elem = (pfd_elem_t *) fspr_palloc(pollset->pool, sizeof(pfd_elem_t)); APR_RING_ELEM_INIT(elem, link); } elem->pfd = *descriptor; @@ -180,11 +180,11 @@ APR_DECLARE(apr_status_t) apr_pollset_add(apr_pollset_t *pollset, return rv; } -APR_DECLARE(apr_status_t) apr_pollset_remove(apr_pollset_t *pollset, - const apr_pollfd_t *descriptor) +APR_DECLARE(fspr_status_t) fspr_pollset_remove(fspr_pollset_t *pollset, + const fspr_pollfd_t *descriptor) { pfd_elem_t *ep; - apr_status_t rv = APR_SUCCESS; + fspr_status_t rv = APR_SUCCESS; struct epoll_event ev; int ret = -1; @@ -224,13 +224,13 @@ APR_DECLARE(apr_status_t) apr_pollset_remove(apr_pollset_t *pollset, return rv; } -APR_DECLARE(apr_status_t) apr_pollset_poll(apr_pollset_t *pollset, - apr_interval_time_t timeout, - apr_int32_t *num, - const apr_pollfd_t **descriptors) +APR_DECLARE(fspr_status_t) fspr_pollset_poll(fspr_pollset_t *pollset, + fspr_interval_time_t timeout, + fspr_int32_t *num, + const fspr_pollfd_t **descriptors) { int ret, i; - apr_status_t rv = APR_SUCCESS; + fspr_status_t rv = APR_SUCCESS; if (timeout > 0) { timeout /= 1000; @@ -241,7 +241,7 @@ APR_DECLARE(apr_status_t) apr_pollset_poll(apr_pollset_t *pollset, (*num) = ret; if (ret < 0) { - rv = apr_get_netos_error(); + rv = fspr_get_netos_error(); } else if (ret == 0) { rv = APR_TIMEUP; diff --git a/libs/apr/poll/unix/kqueue.c b/libs/apr/poll/unix/kqueue.c index a8bea919c3..2938791007 100644 --- a/libs/apr/poll/unix/kqueue.c +++ b/libs/apr/poll/unix/kqueue.c @@ -14,13 +14,13 @@ * limitations under the License. */ -#include "apr_arch_poll_private.h" +#include "fspr_arch_poll_private.h" #ifdef POLLSET_USES_KQUEUE -static apr_int16_t get_kqueue_revent(apr_int16_t event, apr_int16_t flags) +static fspr_int16_t get_kqueue_revent(fspr_int16_t event, fspr_int16_t flags) { - apr_int16_t rv = 0; + fspr_int16_t rv = 0; if (event == EVFILT_READ) rv |= APR_POLLIN; @@ -34,19 +34,19 @@ static apr_int16_t get_kqueue_revent(apr_int16_t event, apr_int16_t flags) return rv; } -struct apr_pollset_t +struct fspr_pollset_t { - apr_pool_t *pool; - apr_uint32_t nelts; - apr_uint32_t nalloc; + fspr_pool_t *pool; + fspr_uint32_t nelts; + fspr_uint32_t nalloc; int kqueue_fd; struct kevent kevent; struct kevent *ke_set; - apr_pollfd_t *result_set; - apr_uint32_t flags; + fspr_pollfd_t *result_set; + fspr_uint32_t flags; #if APR_HAS_THREADS /* A thread mutex to protect operations on the rings */ - apr_thread_mutex_t *ring_lock; + fspr_thread_mutex_t *ring_lock; #endif /* A ring containing all of the pollfd_t that are active */ APR_RING_HEAD(pfd_query_ring_t, pfd_elem_t) query_ring; @@ -57,23 +57,23 @@ struct apr_pollset_t APR_RING_HEAD(pfd_dead_ring_t, pfd_elem_t) dead_ring; }; -static apr_status_t backend_cleanup(void *p_) +static fspr_status_t backend_cleanup(void *p_) { - apr_pollset_t *pollset = (apr_pollset_t *) p_; + fspr_pollset_t *pollset = (fspr_pollset_t *) p_; close(pollset->kqueue_fd); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_pollset_create(apr_pollset_t **pollset, - apr_uint32_t size, - apr_pool_t *p, - apr_uint32_t flags) +APR_DECLARE(fspr_status_t) fspr_pollset_create(fspr_pollset_t **pollset, + fspr_uint32_t size, + fspr_pool_t *p, + fspr_uint32_t flags) { - apr_status_t rv = APR_SUCCESS; - *pollset = apr_palloc(p, sizeof(**pollset)); + fspr_status_t rv = APR_SUCCESS; + *pollset = fspr_palloc(p, sizeof(**pollset)); #if APR_HAS_THREADS if (flags & APR_POLLSET_THREADSAFE && - ((rv = apr_thread_mutex_create(&(*pollset)->ring_lock, + ((rv = fspr_thread_mutex_create(&(*pollset)->ring_lock, APR_THREAD_MUTEX_DEFAULT, p) != APR_SUCCESS))) { *pollset = NULL; @@ -91,7 +91,7 @@ APR_DECLARE(apr_status_t) apr_pollset_create(apr_pollset_t **pollset, (*pollset)->pool = p; (*pollset)->ke_set = - (struct kevent *) apr_palloc(p, size * sizeof(struct kevent)); + (struct kevent *) fspr_palloc(p, size * sizeof(struct kevent)); memset((*pollset)->ke_set, 0, size * sizeof(struct kevent)); @@ -101,10 +101,10 @@ APR_DECLARE(apr_status_t) apr_pollset_create(apr_pollset_t **pollset, return APR_ENOMEM; } - apr_pool_cleanup_register(p, (void *) (*pollset), backend_cleanup, - apr_pool_cleanup_null); + fspr_pool_cleanup_register(p, (void *) (*pollset), backend_cleanup, + fspr_pool_cleanup_null); - (*pollset)->result_set = apr_palloc(p, size * sizeof(apr_pollfd_t)); + (*pollset)->result_set = fspr_palloc(p, size * sizeof(fspr_pollfd_t)); APR_RING_INIT(&(*pollset)->query_ring, pfd_elem_t, link); APR_RING_INIT(&(*pollset)->free_ring, pfd_elem_t, link); @@ -113,17 +113,17 @@ APR_DECLARE(apr_status_t) apr_pollset_create(apr_pollset_t **pollset, return rv; } -APR_DECLARE(apr_status_t) apr_pollset_destroy(apr_pollset_t * pollset) +APR_DECLARE(fspr_status_t) fspr_pollset_destroy(fspr_pollset_t * pollset) { - return apr_pool_cleanup_run(pollset->pool, pollset, backend_cleanup); + return fspr_pool_cleanup_run(pollset->pool, pollset, backend_cleanup); } -APR_DECLARE(apr_status_t) apr_pollset_add(apr_pollset_t *pollset, - const apr_pollfd_t *descriptor) +APR_DECLARE(fspr_status_t) fspr_pollset_add(fspr_pollset_t *pollset, + const fspr_pollfd_t *descriptor) { - apr_os_sock_t fd; + fspr_os_sock_t fd; pfd_elem_t *elem; - apr_status_t rv = APR_SUCCESS; + fspr_status_t rv = APR_SUCCESS; pollset_lock_rings(); @@ -132,7 +132,7 @@ APR_DECLARE(apr_status_t) apr_pollset_add(apr_pollset_t *pollset, APR_RING_REMOVE(elem, link); } else { - elem = (pfd_elem_t *) apr_palloc(pollset->pool, sizeof(pfd_elem_t)); + elem = (pfd_elem_t *) fspr_palloc(pollset->pool, sizeof(pfd_elem_t)); APR_RING_ELEM_INIT(elem, link); } elem->pfd = *descriptor; @@ -175,12 +175,12 @@ APR_DECLARE(apr_status_t) apr_pollset_add(apr_pollset_t *pollset, return rv; } -APR_DECLARE(apr_status_t) apr_pollset_remove(apr_pollset_t *pollset, - const apr_pollfd_t *descriptor) +APR_DECLARE(fspr_status_t) fspr_pollset_remove(fspr_pollset_t *pollset, + const fspr_pollfd_t *descriptor) { pfd_elem_t *ep; - apr_status_t rv = APR_SUCCESS; - apr_os_sock_t fd; + fspr_status_t rv = APR_SUCCESS; + fspr_os_sock_t fd; pollset_lock_rings(); @@ -229,21 +229,21 @@ APR_DECLARE(apr_status_t) apr_pollset_remove(apr_pollset_t *pollset, return rv; } -APR_DECLARE(apr_status_t) apr_pollset_poll(apr_pollset_t *pollset, - apr_interval_time_t timeout, - apr_int32_t *num, - const apr_pollfd_t **descriptors) +APR_DECLARE(fspr_status_t) fspr_pollset_poll(fspr_pollset_t *pollset, + fspr_interval_time_t timeout, + fspr_int32_t *num, + const fspr_pollfd_t **descriptors) { int ret, i; struct timespec tv, *tvptr; - apr_status_t rv = APR_SUCCESS; + fspr_status_t rv = APR_SUCCESS; if (timeout < 0) { tvptr = NULL; } else { - tv.tv_sec = (long) apr_time_sec(timeout); - tv.tv_nsec = (long) apr_time_msec(timeout); + tv.tv_sec = (long) fspr_time_sec(timeout); + tv.tv_nsec = (long) fspr_time_msec(timeout); tvptr = &tv; } @@ -251,7 +251,7 @@ APR_DECLARE(apr_status_t) apr_pollset_poll(apr_pollset_t *pollset, tvptr); (*num) = ret; if (ret < 0) { - rv = apr_get_netos_error(); + rv = fspr_get_netos_error(); } else if (ret == 0) { rv = APR_TIMEUP; diff --git a/libs/apr/poll/unix/poll.c b/libs/apr/poll/unix/poll.c index d27a9998d4..6b2a3c9fc0 100644 --- a/libs/apr/poll/unix/poll.c +++ b/libs/apr/poll/unix/poll.c @@ -14,13 +14,13 @@ * limitations under the License. */ -#include "apr_arch_poll_private.h" +#include "fspr_arch_poll_private.h" #if defined(POLL_USES_POLL) || defined(POLLSET_USES_POLL) -static apr_int16_t get_event(apr_int16_t event) +static fspr_int16_t get_event(fspr_int16_t event) { - apr_int16_t rv = 0; + fspr_int16_t rv = 0; if (event & APR_POLLIN) rv |= POLLIN; @@ -38,9 +38,9 @@ static apr_int16_t get_event(apr_int16_t event) return rv; } -static apr_int16_t get_revent(apr_int16_t event) +static fspr_int16_t get_revent(fspr_int16_t event) { - apr_int16_t rv = 0; + fspr_int16_t rv = 0; if (event & POLLIN) rv |= APR_POLLIN; @@ -65,9 +65,9 @@ static apr_int16_t get_revent(apr_int16_t event) #define SMALL_POLLSET_LIMIT 8 -APR_DECLARE(apr_status_t) apr_poll(apr_pollfd_t *aprset, apr_int32_t num, - apr_int32_t *nsds, - apr_interval_time_t timeout) +APR_DECLARE(fspr_status_t) fspr_poll(fspr_pollfd_t *aprset, fspr_int32_t num, + fspr_int32_t *nsds, + fspr_interval_time_t timeout) { int i, num_to_poll; #ifdef HAVE_VLA @@ -89,7 +89,7 @@ APR_DECLARE(apr_status_t) apr_poll(apr_pollfd_t *aprset, apr_int32_t num, * mapping. */ pollset = malloc(sizeof(struct pollfd) * num); - /* The other option is adding an apr_pool_abort() fn to invoke + /* The other option is adding an fspr_pool_abort() fn to invoke * the pool's out of memory handler */ if (!pollset) @@ -133,7 +133,7 @@ APR_DECLARE(apr_status_t) apr_poll(apr_pollfd_t *aprset, apr_int32_t num, #endif if ((*nsds) < 0) { - return apr_get_netos_error(); + return fspr_get_netos_error(); } if ((*nsds) == 0) { return APR_TIMEUP; @@ -147,43 +147,43 @@ APR_DECLARE(apr_status_t) apr_poll(apr_pollfd_t *aprset, apr_int32_t num, #ifdef POLLSET_USES_POLL -struct apr_pollset_t +struct fspr_pollset_t { - apr_pool_t *pool; - apr_uint32_t nelts; - apr_uint32_t nalloc; + fspr_pool_t *pool; + fspr_uint32_t nelts; + fspr_uint32_t nalloc; struct pollfd *pollset; - apr_pollfd_t *query_set; - apr_pollfd_t *result_set; + fspr_pollfd_t *query_set; + fspr_pollfd_t *result_set; }; -APR_DECLARE(apr_status_t) apr_pollset_create(apr_pollset_t **pollset, - apr_uint32_t size, - apr_pool_t *p, - apr_uint32_t flags) +APR_DECLARE(fspr_status_t) fspr_pollset_create(fspr_pollset_t **pollset, + fspr_uint32_t size, + fspr_pool_t *p, + fspr_uint32_t flags) { if (flags & APR_POLLSET_THREADSAFE) { *pollset = NULL; return APR_ENOTIMPL; } - *pollset = apr_palloc(p, sizeof(**pollset)); + *pollset = fspr_palloc(p, sizeof(**pollset)); (*pollset)->nelts = 0; (*pollset)->nalloc = size; (*pollset)->pool = p; - (*pollset)->pollset = apr_palloc(p, size * sizeof(struct pollfd)); - (*pollset)->query_set = apr_palloc(p, size * sizeof(apr_pollfd_t)); - (*pollset)->result_set = apr_palloc(p, size * sizeof(apr_pollfd_t)); + (*pollset)->pollset = fspr_palloc(p, size * sizeof(struct pollfd)); + (*pollset)->query_set = fspr_palloc(p, size * sizeof(fspr_pollfd_t)); + (*pollset)->result_set = fspr_palloc(p, size * sizeof(fspr_pollfd_t)); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_pollset_destroy(apr_pollset_t *pollset) +APR_DECLARE(fspr_status_t) fspr_pollset_destroy(fspr_pollset_t *pollset) { return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_pollset_add(apr_pollset_t *pollset, - const apr_pollfd_t *descriptor) +APR_DECLARE(fspr_status_t) fspr_pollset_add(fspr_pollset_t *pollset, + const fspr_pollfd_t *descriptor) { if (pollset->nelts == pollset->nalloc) { return APR_ENOMEM; @@ -205,16 +205,16 @@ APR_DECLARE(apr_status_t) apr_pollset_add(apr_pollset_t *pollset, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_pollset_remove(apr_pollset_t *pollset, - const apr_pollfd_t *descriptor) +APR_DECLARE(fspr_status_t) fspr_pollset_remove(fspr_pollset_t *pollset, + const fspr_pollfd_t *descriptor) { - apr_uint32_t i; + fspr_uint32_t i; for (i = 0; i < pollset->nelts; i++) { if (descriptor->desc.s == pollset->query_set[i].desc.s) { /* Found an instance of the fd: remove this and any other copies */ - apr_uint32_t dst = i; - apr_uint32_t old_nelts = pollset->nelts; + fspr_uint32_t dst = i; + fspr_uint32_t old_nelts = pollset->nelts; pollset->nelts--; for (i++; i < old_nelts; i++) { if (descriptor->desc.s == pollset->query_set[i].desc.s) { @@ -233,13 +233,13 @@ APR_DECLARE(apr_status_t) apr_pollset_remove(apr_pollset_t *pollset, return APR_NOTFOUND; } -APR_DECLARE(apr_status_t) apr_pollset_poll(apr_pollset_t *pollset, - apr_interval_time_t timeout, - apr_int32_t *num, - const apr_pollfd_t **descriptors) +APR_DECLARE(fspr_status_t) fspr_pollset_poll(fspr_pollset_t *pollset, + fspr_interval_time_t timeout, + fspr_int32_t *num, + const fspr_pollfd_t **descriptors) { int rv; - apr_uint32_t i, j; + fspr_uint32_t i, j; if (timeout > 0) { timeout /= 1000; @@ -247,7 +247,7 @@ APR_DECLARE(apr_status_t) apr_pollset_poll(apr_pollset_t *pollset, rv = poll(pollset->pollset, pollset->nelts, timeout); (*num) = rv; if (rv < 0) { - return apr_get_netos_error(); + return fspr_get_netos_error(); } if (rv == 0) { return APR_TIMEUP; diff --git a/libs/apr/poll/unix/port.c b/libs/apr/poll/unix/port.c index f668912b3f..626a690d40 100644 --- a/libs/apr/poll/unix/port.c +++ b/libs/apr/poll/unix/port.c @@ -14,13 +14,13 @@ * limitations under the License. */ -#include "apr_arch_poll_private.h" +#include "fspr_arch_poll_private.h" #ifdef POLLSET_USES_PORT -static apr_int16_t get_event(apr_int16_t event) +static fspr_int16_t get_event(fspr_int16_t event) { - apr_int16_t rv = 0; + fspr_int16_t rv = 0; if (event & APR_POLLIN) rv |= POLLIN; @@ -38,9 +38,9 @@ static apr_int16_t get_event(apr_int16_t event) return rv; } -static apr_int16_t get_revent(apr_int16_t event) +static fspr_int16_t get_revent(fspr_int16_t event) { - apr_int16_t rv = 0; + fspr_int16_t rv = 0; if (event & POLLIN) rv |= APR_POLLIN; @@ -59,18 +59,18 @@ static apr_int16_t get_revent(apr_int16_t event) } -struct apr_pollset_t +struct fspr_pollset_t { - apr_pool_t *pool; - apr_uint32_t nelts; - apr_uint32_t nalloc; + fspr_pool_t *pool; + fspr_uint32_t nelts; + fspr_uint32_t nalloc; int port_fd; port_event_t *port_set; - apr_pollfd_t *result_set; - apr_uint32_t flags; + fspr_pollfd_t *result_set; + fspr_uint32_t flags; #if APR_HAS_THREADS /* A thread mutex to protect operations on the rings */ - apr_thread_mutex_t *ring_lock; + fspr_thread_mutex_t *ring_lock; #endif /* A ring containing all of the pollfd_t that are active */ APR_RING_HEAD(pfd_query_ring_t, pfd_elem_t) query_ring; @@ -82,23 +82,23 @@ struct apr_pollset_t APR_RING_HEAD(pfd_dead_ring_t, pfd_elem_t) dead_ring; }; -static apr_status_t backend_cleanup(void *p_) +static fspr_status_t backend_cleanup(void *p_) { - apr_pollset_t *pollset = (apr_pollset_t *) p_; + fspr_pollset_t *pollset = (fspr_pollset_t *) p_; close(pollset->port_fd); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_pollset_create(apr_pollset_t **pollset, - apr_uint32_t size, - apr_pool_t *p, - apr_uint32_t flags) +APR_DECLARE(fspr_status_t) fspr_pollset_create(fspr_pollset_t **pollset, + fspr_uint32_t size, + fspr_pool_t *p, + fspr_uint32_t flags) { - apr_status_t rv = APR_SUCCESS; - *pollset = apr_palloc(p, sizeof(**pollset)); + fspr_status_t rv = APR_SUCCESS; + *pollset = fspr_palloc(p, sizeof(**pollset)); #if APR_HAS_THREADS if (flags & APR_POLLSET_THREADSAFE && - ((rv = apr_thread_mutex_create(&(*pollset)->ring_lock, + ((rv = fspr_thread_mutex_create(&(*pollset)->ring_lock, APR_THREAD_MUTEX_DEFAULT, p) != APR_SUCCESS))) { *pollset = NULL; @@ -115,7 +115,7 @@ APR_DECLARE(apr_status_t) apr_pollset_create(apr_pollset_t **pollset, (*pollset)->flags = flags; (*pollset)->pool = p; - (*pollset)->port_set = apr_palloc(p, size * sizeof(port_event_t)); + (*pollset)->port_set = fspr_palloc(p, size * sizeof(port_event_t)); (*pollset)->port_fd = port_create(); @@ -123,10 +123,10 @@ APR_DECLARE(apr_status_t) apr_pollset_create(apr_pollset_t **pollset, return APR_ENOMEM; } - apr_pool_cleanup_register(p, (void *) (*pollset), backend_cleanup, - apr_pool_cleanup_null); + fspr_pool_cleanup_register(p, (void *) (*pollset), backend_cleanup, + fspr_pool_cleanup_null); - (*pollset)->result_set = apr_palloc(p, size * sizeof(apr_pollfd_t)); + (*pollset)->result_set = fspr_palloc(p, size * sizeof(fspr_pollfd_t)); APR_RING_INIT(&(*pollset)->query_ring, pfd_elem_t, link); APR_RING_INIT(&(*pollset)->add_ring, pfd_elem_t, link); @@ -136,18 +136,18 @@ APR_DECLARE(apr_status_t) apr_pollset_create(apr_pollset_t **pollset, return rv; } -APR_DECLARE(apr_status_t) apr_pollset_destroy(apr_pollset_t *pollset) +APR_DECLARE(fspr_status_t) fspr_pollset_destroy(fspr_pollset_t *pollset) { - return apr_pool_cleanup_run(pollset->pool, pollset, backend_cleanup); + return fspr_pool_cleanup_run(pollset->pool, pollset, backend_cleanup); } -APR_DECLARE(apr_status_t) apr_pollset_add(apr_pollset_t *pollset, - const apr_pollfd_t *descriptor) +APR_DECLARE(fspr_status_t) fspr_pollset_add(fspr_pollset_t *pollset, + const fspr_pollfd_t *descriptor) { - apr_os_sock_t fd; + fspr_os_sock_t fd; pfd_elem_t *elem; int res; - apr_status_t rv = APR_SUCCESS; + fspr_status_t rv = APR_SUCCESS; pollset_lock_rings(); @@ -156,7 +156,7 @@ APR_DECLARE(apr_status_t) apr_pollset_add(apr_pollset_t *pollset, APR_RING_REMOVE(elem, link); } else { - elem = (pfd_elem_t *) apr_palloc(pollset->pool, sizeof(pfd_elem_t)); + elem = (pfd_elem_t *) fspr_palloc(pollset->pool, sizeof(pfd_elem_t)); APR_RING_ELEM_INIT(elem, link); } elem->pfd = *descriptor; @@ -185,12 +185,12 @@ APR_DECLARE(apr_status_t) apr_pollset_add(apr_pollset_t *pollset, return rv; } -APR_DECLARE(apr_status_t) apr_pollset_remove(apr_pollset_t *pollset, - const apr_pollfd_t *descriptor) +APR_DECLARE(fspr_status_t) fspr_pollset_remove(fspr_pollset_t *pollset, + const fspr_pollfd_t *descriptor) { - apr_os_sock_t fd; + fspr_os_sock_t fd; pfd_elem_t *ep; - apr_status_t rv = APR_SUCCESS; + fspr_status_t rv = APR_SUCCESS; int res; pollset_lock_rings(); @@ -243,24 +243,24 @@ APR_DECLARE(apr_status_t) apr_pollset_remove(apr_pollset_t *pollset, return rv; } -APR_DECLARE(apr_status_t) apr_pollset_poll(apr_pollset_t *pollset, - apr_interval_time_t timeout, - apr_int32_t *num, - const apr_pollfd_t **descriptors) +APR_DECLARE(fspr_status_t) fspr_pollset_poll(fspr_pollset_t *pollset, + fspr_interval_time_t timeout, + fspr_int32_t *num, + const fspr_pollfd_t **descriptors) { - apr_os_sock_t fd; + fspr_os_sock_t fd; int ret, i; unsigned int nget; pfd_elem_t *ep; struct timespec tv, *tvptr; - apr_status_t rv = APR_SUCCESS; + fspr_status_t rv = APR_SUCCESS; if (timeout < 0) { tvptr = NULL; } else { - tv.tv_sec = (long) apr_time_sec(timeout); - tv.tv_nsec = (long) apr_time_msec(timeout); + tv.tv_sec = (long) fspr_time_sec(timeout); + tv.tv_nsec = (long) fspr_time_msec(timeout); tvptr = &tv; } diff --git a/libs/apr/poll/unix/select.c b/libs/apr/poll/unix/select.c index ca35b77db9..fecdaf845a 100644 --- a/libs/apr/poll/unix/select.c +++ b/libs/apr/poll/unix/select.c @@ -19,34 +19,34 @@ #define FD_SETSIZE 1024 #endif -#include "apr.h" -#include "apr_poll.h" -#include "apr_time.h" -#include "apr_portable.h" -#include "apr_arch_networkio.h" -#include "apr_arch_file_io.h" -#include "apr_arch_poll_private.h" +#include "fspr.h" +#include "fspr_poll.h" +#include "fspr_time.h" +#include "fspr_portable.h" +#include "fspr_arch_networkio.h" +#include "fspr_arch_file_io.h" +#include "fspr_arch_poll_private.h" #ifdef POLL_USES_SELECT -APR_DECLARE(apr_status_t) apr_poll(apr_pollfd_t *aprset, int num, - apr_int32_t *nsds, - apr_interval_time_t timeout) +APR_DECLARE(fspr_status_t) fspr_poll(fspr_pollfd_t *aprset, int num, + fspr_int32_t *nsds, + fspr_interval_time_t timeout) { fd_set readset, writeset, exceptset; int rv, i; int maxfd = -1; struct timeval tv, *tvptr; #ifdef NETWARE - apr_datatype_e set_type = APR_NO_DESC; + fspr_datatype_e set_type = APR_NO_DESC; #endif if (timeout < 0) { tvptr = NULL; } else { - tv.tv_sec = (long) apr_time_sec(timeout); - tv.tv_usec = (long) apr_time_usec(timeout); + tv.tv_sec = (long) fspr_time_sec(timeout); + tv.tv_usec = (long) fspr_time_usec(timeout); tvptr = &tv; } @@ -55,7 +55,7 @@ APR_DECLARE(apr_status_t) apr_poll(apr_pollfd_t *aprset, int num, FD_ZERO(&exceptset); for (i = 0; i < num; i++) { - apr_os_sock_t fd; + fspr_os_sock_t fd; aprset[i].rtnevents = 0; @@ -128,12 +128,12 @@ APR_DECLARE(apr_status_t) apr_poll(apr_pollfd_t *aprset, int num, return APR_TIMEUP; } if ((*nsds) < 0) { - return apr_get_netos_error(); + return fspr_get_netos_error(); } (*nsds) = 0; for (i = 0; i < num; i++) { - apr_os_sock_t fd; + fspr_os_sock_t fd; if (aprset[i].desc_type == APR_POLL_SOCKET) { fd = aprset[i].desc.s->socketdes; @@ -169,25 +169,25 @@ APR_DECLARE(apr_status_t) apr_poll(apr_pollfd_t *aprset, int num, #ifdef POLLSET_USES_SELECT -struct apr_pollset_t +struct fspr_pollset_t { - apr_pool_t *pool; + fspr_pool_t *pool; - apr_uint32_t nelts; - apr_uint32_t nalloc; + fspr_uint32_t nelts; + fspr_uint32_t nalloc; fd_set readset, writeset, exceptset; int maxfd; - apr_pollfd_t *query_set; - apr_pollfd_t *result_set; + fspr_pollfd_t *query_set; + fspr_pollfd_t *result_set; #ifdef NETWARE int set_type; #endif }; -APR_DECLARE(apr_status_t) apr_pollset_create(apr_pollset_t **pollset, - apr_uint32_t size, - apr_pool_t *p, - apr_uint32_t flags) +APR_DECLARE(fspr_status_t) fspr_pollset_create(fspr_pollset_t **pollset, + fspr_uint32_t size, + fspr_pool_t *p, + fspr_uint32_t flags) { if (flags & APR_POLLSET_THREADSAFE) { *pollset = NULL; @@ -199,7 +199,7 @@ APR_DECLARE(apr_status_t) apr_pollset_create(apr_pollset_t **pollset, return APR_EINVAL; } #endif - *pollset = apr_palloc(p, sizeof(**pollset)); + *pollset = fspr_palloc(p, sizeof(**pollset)); (*pollset)->nelts = 0; (*pollset)->nalloc = size; (*pollset)->pool = p; @@ -210,21 +210,21 @@ APR_DECLARE(apr_status_t) apr_pollset_create(apr_pollset_t **pollset, #ifdef NETWARE (*pollset)->set_type = APR_NO_DESC; #endif - (*pollset)->query_set = apr_palloc(p, size * sizeof(apr_pollfd_t)); - (*pollset)->result_set = apr_palloc(p, size * sizeof(apr_pollfd_t)); + (*pollset)->query_set = fspr_palloc(p, size * sizeof(fspr_pollfd_t)); + (*pollset)->result_set = fspr_palloc(p, size * sizeof(fspr_pollfd_t)); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_pollset_destroy(apr_pollset_t * pollset) +APR_DECLARE(fspr_status_t) fspr_pollset_destroy(fspr_pollset_t * pollset) { return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_pollset_add(apr_pollset_t *pollset, - const apr_pollfd_t *descriptor) +APR_DECLARE(fspr_status_t) fspr_pollset_add(fspr_pollset_t *pollset, + const fspr_pollfd_t *descriptor) { - apr_os_sock_t fd; + fspr_os_sock_t fd; if (pollset->nelts == pollset->nalloc) { return APR_ENOMEM; @@ -285,11 +285,11 @@ APR_DECLARE(apr_status_t) apr_pollset_add(apr_pollset_t *pollset, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_pollset_remove(apr_pollset_t * pollset, - const apr_pollfd_t * descriptor) +APR_DECLARE(fspr_status_t) fspr_pollset_remove(fspr_pollset_t * pollset, + const fspr_pollfd_t * descriptor) { - apr_uint32_t i; - apr_os_sock_t fd; + fspr_uint32_t i; + fspr_os_sock_t fd; if (descriptor->desc_type == APR_POLL_SOCKET) { fd = descriptor->desc.s->socketdes; @@ -305,8 +305,8 @@ APR_DECLARE(apr_status_t) apr_pollset_remove(apr_pollset_t * pollset, for (i = 0; i < pollset->nelts; i++) { if (descriptor->desc.s == pollset->query_set[i].desc.s) { /* Found an instance of the fd: remove this and any other copies */ - apr_uint32_t dst = i; - apr_uint32_t old_nelts = pollset->nelts; + fspr_uint32_t dst = i; + fspr_uint32_t old_nelts = pollset->nelts; pollset->nelts--; for (i++; i < old_nelts; i++) { if (descriptor->desc.s == pollset->query_set[i].desc.s) { @@ -330,13 +330,13 @@ APR_DECLARE(apr_status_t) apr_pollset_remove(apr_pollset_t * pollset, return APR_NOTFOUND; } -APR_DECLARE(apr_status_t) apr_pollset_poll(apr_pollset_t *pollset, - apr_interval_time_t timeout, - apr_int32_t *num, - const apr_pollfd_t **descriptors) +APR_DECLARE(fspr_status_t) fspr_pollset_poll(fspr_pollset_t *pollset, + fspr_interval_time_t timeout, + fspr_int32_t *num, + const fspr_pollfd_t **descriptors) { int rv; - apr_uint32_t i, j; + fspr_uint32_t i, j; struct timeval tv, *tvptr; fd_set readset, writeset, exceptset; @@ -344,8 +344,8 @@ APR_DECLARE(apr_status_t) apr_pollset_poll(apr_pollset_t *pollset, tvptr = NULL; } else { - tv.tv_sec = (long) apr_time_sec(timeout); - tv.tv_usec = (long) apr_time_usec(timeout); + tv.tv_sec = (long) fspr_time_sec(timeout); + tv.tv_usec = (long) fspr_time_usec(timeout); tvptr = &tv; } @@ -365,14 +365,14 @@ APR_DECLARE(apr_status_t) apr_pollset_poll(apr_pollset_t *pollset, (*num) = rv; if (rv < 0) { - return apr_get_netos_error(); + return fspr_get_netos_error(); } if (rv == 0) { return APR_TIMEUP; } j = 0; for (i = 0; i < pollset->nelts; i++) { - apr_os_sock_t fd; + fspr_os_sock_t fd; if (pollset->query_set[i].desc_type == APR_POLL_SOCKET) { fd = pollset->query_set[i].desc.s->socketdes; } diff --git a/libs/apr/random/unix/apr_random.c b/libs/apr/random/unix/fspr_random.c similarity index 71% rename from libs/apr/random/unix/apr_random.c rename to libs/apr/random/unix/fspr_random.c index f574b590d4..5657624512 100644 --- a/libs/apr/random/unix/apr_random.c +++ b/libs/apr/random/unix/fspr_random.c @@ -17,10 +17,10 @@ * See the paper "???" by Ben Laurie for an explanation of this PRNG. */ -#include "apr.h" -#include "apr_pools.h" -#include "apr_random.h" -#include "apr_thread_proc.h" +#include "fspr.h" +#include "fspr_pools.h" +#include "fspr_random.h" +#include "fspr_thread_proc.h" #include #ifdef min @@ -35,11 +35,11 @@ #define APR_RANDOM_DEFAULT_G_FOR_INSECURE 32 #define APR_RANDOM_DEFAULT_G_FOR_SECURE 320 -typedef struct apr_random_pool_t { +typedef struct fspr_random_pool_t { unsigned char *pool; unsigned int bytes; unsigned int pool_size; -} apr_random_pool_t; +} fspr_random_pool_t; #define hash_init(h) (h)->init(h) #define hash_add(h,b,n) (h)->add(h,b,n) @@ -50,18 +50,18 @@ typedef struct apr_random_pool_t { #define crypt_setkey(c,k) (c)->set_key((c)->data,k) #define crypt_crypt(c,out,in) (c)->crypt((c)->date,out,in) -struct apr_random_t { - apr_pool_t *apr_pool; - apr_crypto_hash_t *pool_hash; +struct fspr_random_t { + fspr_pool_t *fspr_pool; + fspr_crypto_hash_t *pool_hash; unsigned int npools; - apr_random_pool_t *pools; + fspr_random_pool_t *pools; unsigned int next_pool; unsigned int generation; - apr_size_t rehash_size; - apr_size_t reseed_size; - apr_crypto_hash_t *key_hash; + fspr_size_t rehash_size; + fspr_size_t reseed_size; + fspr_crypto_hash_t *key_hash; #define K_size(g) ((g)->key_hash->size) - apr_crypto_hash_t *prng_hash; + fspr_crypto_hash_t *prng_hash; #define B_size(g) ((g)->prng_hash->size) unsigned char *H; @@ -71,33 +71,33 @@ struct apr_random_t { ? (g)->H_waiting : (g)->H) unsigned char *randomness; - apr_size_t random_bytes; + fspr_size_t random_bytes; unsigned int g_for_insecure; unsigned int g_for_secure; unsigned int secure_base; unsigned int insecure_started:1; unsigned int secure_started:1; - apr_random_t *next; + fspr_random_t *next; }; -static apr_random_t *all_random; +static fspr_random_t *all_random; -APR_DECLARE(void) apr_random_init(apr_random_t *g,apr_pool_t *p, - apr_crypto_hash_t *pool_hash, - apr_crypto_hash_t *key_hash, - apr_crypto_hash_t *prng_hash) +APR_DECLARE(void) fspr_random_init(fspr_random_t *g,fspr_pool_t *p, + fspr_crypto_hash_t *pool_hash, + fspr_crypto_hash_t *key_hash, + fspr_crypto_hash_t *prng_hash) { unsigned int n; - g->apr_pool = p; + g->fspr_pool = p; g->pool_hash = pool_hash; g->key_hash = key_hash; g->prng_hash = prng_hash; g->npools = APR_RANDOM_DEFAULT_POOLS; - g->pools = apr_palloc(p,g->npools*sizeof *g->pools); + g->pools = fspr_palloc(p,g->npools*sizeof *g->pools); for (n = 0; n < g->npools; ++n) { g->pools[n].bytes = g->pools[n].pool_size = 0; g->pools[n].pool = NULL; @@ -112,10 +112,10 @@ APR_DECLARE(void) apr_random_init(apr_random_t *g,apr_pool_t *p, /2)*g->pool_hash->size*2; g->reseed_size = APR_RANDOM_DEFAULT_RESEED_SIZE; - g->H = apr_pcalloc(p,H_size(g)); - g->H_waiting = apr_pcalloc(p,H_size(g)); + g->H = fspr_pcalloc(p,H_size(g)); + g->H_waiting = fspr_pcalloc(p,H_size(g)); - g->randomness = apr_palloc(p,B_size(g)); + g->randomness = fspr_palloc(p,B_size(g)); g->random_bytes = 0; g->g_for_insecure = APR_RANDOM_DEFAULT_G_FOR_INSECURE; @@ -127,7 +127,7 @@ APR_DECLARE(void) apr_random_init(apr_random_t *g,apr_pool_t *p, all_random = g; } -static void mix_pid(apr_random_t *g,unsigned char *H,pid_t pid) +static void mix_pid(fspr_random_t *g,unsigned char *H,pid_t pid) { hash_init(g->key_hash); hash_add(g->key_hash,H,H_size(g)); @@ -135,7 +135,7 @@ static void mix_pid(apr_random_t *g,unsigned char *H,pid_t pid) hash_finish(g->key_hash,H); } -static void mixer(apr_random_t *g,pid_t pid) +static void mixer(fspr_random_t *g,pid_t pid) { unsigned char *H = H_current(g); @@ -151,24 +151,24 @@ static void mixer(apr_random_t *g,pid_t pid) g->random_bytes = 0; } -APR_DECLARE(void) apr_random_after_fork(apr_proc_t *proc) +APR_DECLARE(void) fspr_random_after_fork(fspr_proc_t *proc) { - apr_random_t *r; + fspr_random_t *r; for (r = all_random; r; r = r->next) mixer(r,proc->pid); } -APR_DECLARE(apr_random_t *) apr_random_standard_new(apr_pool_t *p) +APR_DECLARE(fspr_random_t *) fspr_random_standard_new(fspr_pool_t *p) { - apr_random_t *r = apr_palloc(p,sizeof *r); + fspr_random_t *r = fspr_palloc(p,sizeof *r); - apr_random_init(r,p,apr_crypto_sha256_new(p),apr_crypto_sha256_new(p), - apr_crypto_sha256_new(p)); + fspr_random_init(r,p,fspr_crypto_sha256_new(p),fspr_crypto_sha256_new(p), + fspr_crypto_sha256_new(p)); return r; } -static void rekey(apr_random_t *g) +static void rekey(fspr_random_t *g) { unsigned int n; unsigned char *H = H_current(g); @@ -197,20 +197,20 @@ static void rekey(apr_random_t *g) } } -APR_DECLARE(void) apr_random_add_entropy(apr_random_t *g,const void *entropy_, - apr_size_t bytes) +APR_DECLARE(void) fspr_random_add_entropy(fspr_random_t *g,const void *entropy_, + fspr_size_t bytes) { unsigned int n; const unsigned char *entropy = entropy_; for (n = 0; n < bytes; ++n) { - apr_random_pool_t *p = &g->pools[g->next_pool]; + fspr_random_pool_t *p = &g->pools[g->next_pool]; if (++g->next_pool == g->npools) g->next_pool = 0; if (p->pool_size < p->bytes+1) { - unsigned char *np = apr_palloc(g->apr_pool,(p->bytes+1)*2); + unsigned char *np = fspr_palloc(g->fspr_pool,(p->bytes+1)*2); memcpy(np,p->pool,p->bytes); p->pool = np; @@ -233,23 +233,23 @@ APR_DECLARE(void) apr_random_add_entropy(apr_random_t *g,const void *entropy_, } /* This will give g->B_size bytes of randomness */ -static void apr_random_block(apr_random_t *g,unsigned char *random) +static void fspr_random_block(fspr_random_t *g,unsigned char *random) { /* FIXME: in principle, these are different hashes */ hash(g->prng_hash,g->H,g->H,H_size(g)); hash(g->prng_hash,random,g->H,B_size(g)); } -static void apr_random_bytes(apr_random_t *g,unsigned char *random, - apr_size_t bytes) +static void fspr_random_bytes(fspr_random_t *g,unsigned char *random, + fspr_size_t bytes) { - apr_size_t n; + fspr_size_t n; for (n = 0; n < bytes; ) { int l; if (g->random_bytes == 0) { - apr_random_block(g,g->randomness); + fspr_random_block(g,g->randomness); g->random_bytes = B_size(g); } l = min(bytes-n,g->random_bytes); @@ -259,40 +259,40 @@ static void apr_random_bytes(apr_random_t *g,unsigned char *random, } } -APR_DECLARE(apr_status_t) apr_random_secure_bytes(apr_random_t *g, +APR_DECLARE(fspr_status_t) fspr_random_secure_bytes(fspr_random_t *g, void *random, - apr_size_t bytes) + fspr_size_t bytes) { if (!g->secure_started) return APR_ENOTENOUGHENTROPY; - apr_random_bytes(g,random,bytes); + fspr_random_bytes(g,random,bytes); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_random_insecure_bytes(apr_random_t *g, +APR_DECLARE(fspr_status_t) fspr_random_insecure_bytes(fspr_random_t *g, void *random, - apr_size_t bytes) + fspr_size_t bytes) { if (!g->insecure_started) return APR_ENOTENOUGHENTROPY; - apr_random_bytes(g,random,bytes); + fspr_random_bytes(g,random,bytes); return APR_SUCCESS; } -APR_DECLARE(void) apr_random_barrier(apr_random_t *g) +APR_DECLARE(void) fspr_random_barrier(fspr_random_t *g) { g->secure_started = 0; g->secure_base = g->generation; } -APR_DECLARE(apr_status_t) apr_random_secure_ready(apr_random_t *r) +APR_DECLARE(fspr_status_t) fspr_random_secure_ready(fspr_random_t *r) { if (!r->secure_started) return APR_ENOTENOUGHENTROPY; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_random_insecure_ready(apr_random_t *r) +APR_DECLARE(fspr_status_t) fspr_random_insecure_ready(fspr_random_t *r) { if (!r->insecure_started) return APR_ENOTENOUGHENTROPY; diff --git a/libs/apr/random/unix/sha2.c b/libs/apr/random/unix/sha2.c index b8bd241d85..5a3f217822 100644 --- a/libs/apr/random/unix/sha2.c +++ b/libs/apr/random/unix/sha2.c @@ -45,9 +45,9 @@ */ /*** SHA-256/384/512 Machine Architecture Definitions *****************/ -typedef apr_byte_t sha2_byte; /* Exactly 1 byte */ -typedef apr_uint32_t sha2_word32; /* Exactly 4 bytes */ -typedef apr_uint64_t sha2_word64; /* Exactly 8 bytes */ +typedef fspr_byte_t sha2_byte; /* Exactly 1 byte */ +typedef fspr_uint32_t sha2_word32; /* Exactly 4 bytes */ +typedef fspr_uint64_t sha2_word64; /* Exactly 8 bytes */ /*** SHA-256/384/512 Various Length Definitions ***********************/ /* NOTE: Most of these are in sha2.h */ @@ -150,9 +150,9 @@ typedef apr_uint64_t sha2_word64; /* Exactly 8 bytes */ * library -- they are intended for private internal visibility/use * only. */ -void apr__SHA512_Last(SHA512_CTX*); -void apr__SHA256_Transform(SHA256_CTX*, const sha2_word32*); -void apr__SHA512_Transform(SHA512_CTX*, const sha2_word64*); +void fspr__SHA512_Last(SHA512_CTX*); +void fspr__SHA256_Transform(SHA256_CTX*, const sha2_word32*); +void fspr__SHA512_Transform(SHA512_CTX*, const sha2_word64*); /*** SHA-XYZ INITIAL HASH VALUES AND CONSTANTS ************************/ @@ -264,7 +264,7 @@ static const char *sha2_hex_digits = "0123456789abcdef"; /*** SHA-256: *********************************************************/ -void apr__SHA256_Init(SHA256_CTX* context) { +void fspr__SHA256_Init(SHA256_CTX* context) { if (context == (SHA256_CTX*)0) { return; } @@ -310,7 +310,7 @@ void apr__SHA256_Init(SHA256_CTX* context) { (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \ j++ -void apr__SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) { +void fspr__SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) { sha2_word32 a, b, c, d, e, f, g, h, s0, s1; sha2_word32 T1, *W256; int j; @@ -368,7 +368,7 @@ void apr__SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) { #else /* SHA2_UNROLL_TRANSFORM */ -void apr__SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) { +void fspr__SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) { sha2_word32 a, b, c, d, e, f, g, h, s0, s1; sha2_word32 T1, T2, *W256; int j; @@ -458,7 +458,7 @@ void apr__SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) { #endif /* SHA2_UNROLL_TRANSFORM */ -void apr__SHA256_Update(SHA256_CTX* context, const sha2_byte *data, size_t len) { +void fspr__SHA256_Update(SHA256_CTX* context, const sha2_byte *data, size_t len) { unsigned int freespace, usedspace; if (len == 0) { @@ -481,7 +481,7 @@ void apr__SHA256_Update(SHA256_CTX* context, const sha2_byte *data, size_t len) context->bitcount += freespace << 3; len -= freespace; data += freespace; - apr__SHA256_Transform(context, (sha2_word32*)context->buffer); + fspr__SHA256_Transform(context, (sha2_word32*)context->buffer); } else { /* The buffer is not yet full */ MEMCPY_BCOPY(&context->buffer[usedspace], data, len); @@ -495,7 +495,7 @@ void apr__SHA256_Update(SHA256_CTX* context, const sha2_byte *data, size_t len) } while (len >= SHA256_BLOCK_LENGTH) { /* Process as many complete blocks as we can */ - apr__SHA256_Transform(context, (sha2_word32*)data); + fspr__SHA256_Transform(context, (sha2_word32*)data); context->bitcount += SHA256_BLOCK_LENGTH << 3; len -= SHA256_BLOCK_LENGTH; data += SHA256_BLOCK_LENGTH; @@ -511,7 +511,7 @@ void apr__SHA256_Update(SHA256_CTX* context, const sha2_byte *data, size_t len) assert(freespace==0); } -void apr__SHA256_Final(sha2_byte digest[], SHA256_CTX* context) { +void fspr__SHA256_Final(sha2_byte digest[], SHA256_CTX* context) { sha2_word32 *d = (sha2_word32*)digest; unsigned int usedspace; @@ -538,7 +538,7 @@ void apr__SHA256_Final(sha2_byte digest[], SHA256_CTX* context) { MEMSET_BZERO(&context->buffer[usedspace], SHA256_BLOCK_LENGTH - usedspace); } /* Do second-to-last transform: */ - apr__SHA256_Transform(context, (sha2_word32*)context->buffer); + fspr__SHA256_Transform(context, (sha2_word32*)context->buffer); /* And set-up for the last transform: */ MEMSET_BZERO(context->buffer, SHA256_SHORT_BLOCK_LENGTH); @@ -554,7 +554,7 @@ void apr__SHA256_Final(sha2_byte digest[], SHA256_CTX* context) { *(sha2_word64*)&context->buffer[SHA256_SHORT_BLOCK_LENGTH] = context->bitcount; /* Final transform: */ - apr__SHA256_Transform(context, (sha2_word32*)context->buffer); + fspr__SHA256_Transform(context, (sha2_word32*)context->buffer); #if !APR_IS_BIGENDIAN { @@ -576,7 +576,7 @@ void apr__SHA256_Final(sha2_byte digest[], SHA256_CTX* context) { assert(usedspace==0); } -char *apr__SHA256_End(SHA256_CTX* context, char buffer[]) { +char *fspr__SHA256_End(SHA256_CTX* context, char buffer[]) { sha2_byte digest[SHA256_DIGEST_LENGTH], *d = digest; int i; @@ -584,7 +584,7 @@ char *apr__SHA256_End(SHA256_CTX* context, char buffer[]) { assert(context != (SHA256_CTX*)0); if (buffer != (char*)0) { - apr__SHA256_Final(digest, context); + fspr__SHA256_Final(digest, context); for (i = 0; i < SHA256_DIGEST_LENGTH; i++) { *buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4]; @@ -599,17 +599,17 @@ char *apr__SHA256_End(SHA256_CTX* context, char buffer[]) { return buffer; } -char* apr__SHA256_Data(const sha2_byte* data, size_t len, char digest[SHA256_DIGEST_STRING_LENGTH]) { +char* fspr__SHA256_Data(const sha2_byte* data, size_t len, char digest[SHA256_DIGEST_STRING_LENGTH]) { SHA256_CTX context; - apr__SHA256_Init(&context); - apr__SHA256_Update(&context, data, len); - return apr__SHA256_End(&context, digest); + fspr__SHA256_Init(&context); + fspr__SHA256_Update(&context, data, len); + return fspr__SHA256_End(&context, digest); } /*** SHA-512: *********************************************************/ -void apr__SHA512_Init(SHA512_CTX* context) { +void fspr__SHA512_Init(SHA512_CTX* context) { if (context == (SHA512_CTX*)0) { return; } @@ -654,7 +654,7 @@ void apr__SHA512_Init(SHA512_CTX* context) { (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)); \ j++ -void apr__SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) { +void fspr__SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) { sha2_word64 a, b, c, d, e, f, g, h, s0, s1; sha2_word64 T1, *W512 = (sha2_word64*)context->buffer; int j; @@ -709,7 +709,7 @@ void apr__SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) { #else /* SHA2_UNROLL_TRANSFORM */ -void apr__SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) { +void fspr__SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) { sha2_word64 a, b, c, d, e, f, g, h, s0, s1; sha2_word64 T1, T2, *W512 = (sha2_word64*)context->buffer; int j; @@ -797,7 +797,7 @@ void apr__SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) { #endif /* SHA2_UNROLL_TRANSFORM */ -void apr__SHA512_Update(SHA512_CTX* context, const sha2_byte *data, size_t len) { +void fspr__SHA512_Update(SHA512_CTX* context, const sha2_byte *data, size_t len) { unsigned int freespace, usedspace; if (len == 0) { @@ -820,7 +820,7 @@ void apr__SHA512_Update(SHA512_CTX* context, const sha2_byte *data, size_t len) ADDINC128(context->bitcount, freespace << 3); len -= freespace; data += freespace; - apr__SHA512_Transform(context, (sha2_word64*)context->buffer); + fspr__SHA512_Transform(context, (sha2_word64*)context->buffer); } else { /* The buffer is not yet full */ MEMCPY_BCOPY(&context->buffer[usedspace], data, len); @@ -834,7 +834,7 @@ void apr__SHA512_Update(SHA512_CTX* context, const sha2_byte *data, size_t len) } while (len >= SHA512_BLOCK_LENGTH) { /* Process as many complete blocks as we can */ - apr__SHA512_Transform(context, (sha2_word64*)data); + fspr__SHA512_Transform(context, (sha2_word64*)data); ADDINC128(context->bitcount, SHA512_BLOCK_LENGTH << 3); len -= SHA512_BLOCK_LENGTH; data += SHA512_BLOCK_LENGTH; @@ -850,7 +850,7 @@ void apr__SHA512_Update(SHA512_CTX* context, const sha2_byte *data, size_t len) assert(freespace==0); } -void apr__SHA512_Last(SHA512_CTX* context) { +void fspr__SHA512_Last(SHA512_CTX* context) { unsigned int usedspace; usedspace = (unsigned int)((context->bitcount[0] >> 3) @@ -872,7 +872,7 @@ void apr__SHA512_Last(SHA512_CTX* context) { MEMSET_BZERO(&context->buffer[usedspace], SHA512_BLOCK_LENGTH - usedspace); } /* Do second-to-last transform: */ - apr__SHA512_Transform(context, (sha2_word64*)context->buffer); + fspr__SHA512_Transform(context, (sha2_word64*)context->buffer); /* And set-up for the last transform: */ MEMSET_BZERO(context->buffer, SHA512_BLOCK_LENGTH - 2); @@ -889,10 +889,10 @@ void apr__SHA512_Last(SHA512_CTX* context) { *(sha2_word64*)&context->buffer[SHA512_SHORT_BLOCK_LENGTH+8] = context->bitcount[0]; /* Final transform: */ - apr__SHA512_Transform(context, (sha2_word64*)context->buffer); + fspr__SHA512_Transform(context, (sha2_word64*)context->buffer); } -void apr__SHA512_Final(sha2_byte digest[], SHA512_CTX* context) { +void fspr__SHA512_Final(sha2_byte digest[], SHA512_CTX* context) { sha2_word64 *d = (sha2_word64*)digest; /* Sanity check: */ @@ -900,7 +900,7 @@ void apr__SHA512_Final(sha2_byte digest[], SHA512_CTX* context) { /* If no digest buffer is passed, we don't bother doing this: */ if (digest != (sha2_byte*)0) { - apr__SHA512_Last(context); + fspr__SHA512_Last(context); /* Save the hash data for output: */ #if !APR_IS_BIGENDIAN @@ -921,7 +921,7 @@ void apr__SHA512_Final(sha2_byte digest[], SHA512_CTX* context) { MEMSET_BZERO(context, sizeof(*context)); } -char *apr__SHA512_End(SHA512_CTX* context, char buffer[]) { +char *fspr__SHA512_End(SHA512_CTX* context, char buffer[]) { sha2_byte digest[SHA512_DIGEST_LENGTH], *d = digest; int i; @@ -929,7 +929,7 @@ char *apr__SHA512_End(SHA512_CTX* context, char buffer[]) { assert(context != (SHA512_CTX*)0); if (buffer != (char*)0) { - apr__SHA512_Final(digest, context); + fspr__SHA512_Final(digest, context); for (i = 0; i < SHA512_DIGEST_LENGTH; i++) { *buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4]; @@ -944,17 +944,17 @@ char *apr__SHA512_End(SHA512_CTX* context, char buffer[]) { return buffer; } -char* apr__SHA512_Data(const sha2_byte* data, size_t len, char digest[SHA512_DIGEST_STRING_LENGTH]) { +char* fspr__SHA512_Data(const sha2_byte* data, size_t len, char digest[SHA512_DIGEST_STRING_LENGTH]) { SHA512_CTX context; - apr__SHA512_Init(&context); - apr__SHA512_Update(&context, data, len); - return apr__SHA512_End(&context, digest); + fspr__SHA512_Init(&context); + fspr__SHA512_Update(&context, data, len); + return fspr__SHA512_End(&context, digest); } /*** SHA-384: *********************************************************/ -void apr__SHA384_Init(SHA384_CTX* context) { +void fspr__SHA384_Init(SHA384_CTX* context) { if (context == (SHA384_CTX*)0) { return; } @@ -963,11 +963,11 @@ void apr__SHA384_Init(SHA384_CTX* context) { context->bitcount[0] = context->bitcount[1] = 0; } -void apr__SHA384_Update(SHA384_CTX* context, const sha2_byte* data, size_t len) { - apr__SHA512_Update((SHA512_CTX*)context, data, len); +void fspr__SHA384_Update(SHA384_CTX* context, const sha2_byte* data, size_t len) { + fspr__SHA512_Update((SHA512_CTX*)context, data, len); } -void apr__SHA384_Final(sha2_byte digest[], SHA384_CTX* context) { +void fspr__SHA384_Final(sha2_byte digest[], SHA384_CTX* context) { sha2_word64 *d = (sha2_word64*)digest; /* Sanity check: */ @@ -975,7 +975,7 @@ void apr__SHA384_Final(sha2_byte digest[], SHA384_CTX* context) { /* If no digest buffer is passed, we don't bother doing this: */ if (digest != (sha2_byte*)0) { - apr__SHA512_Last((SHA512_CTX*)context); + fspr__SHA512_Last((SHA512_CTX*)context); /* Save the hash data for output: */ #if !APR_IS_BIGENDIAN @@ -996,7 +996,7 @@ void apr__SHA384_Final(sha2_byte digest[], SHA384_CTX* context) { MEMSET_BZERO(context, sizeof(*context)); } -char *apr__SHA384_End(SHA384_CTX* context, char buffer[]) { +char *fspr__SHA384_End(SHA384_CTX* context, char buffer[]) { sha2_byte digest[SHA384_DIGEST_LENGTH], *d = digest; int i; @@ -1004,7 +1004,7 @@ char *apr__SHA384_End(SHA384_CTX* context, char buffer[]) { assert(context != (SHA384_CTX*)0); if (buffer != (char*)0) { - apr__SHA384_Final(digest, context); + fspr__SHA384_Final(digest, context); for (i = 0; i < SHA384_DIGEST_LENGTH; i++) { *buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4]; @@ -1019,11 +1019,11 @@ char *apr__SHA384_End(SHA384_CTX* context, char buffer[]) { return buffer; } -char* apr__SHA384_Data(const sha2_byte* data, size_t len, char digest[SHA384_DIGEST_STRING_LENGTH]) { +char* fspr__SHA384_Data(const sha2_byte* data, size_t len, char digest[SHA384_DIGEST_STRING_LENGTH]) { SHA384_CTX context; - apr__SHA384_Init(&context); - apr__SHA384_Update(&context, data, len); - return apr__SHA384_End(&context, digest); + fspr__SHA384_Init(&context); + fspr__SHA384_Update(&context, data, len); + return fspr__SHA384_End(&context, digest); } diff --git a/libs/apr/random/unix/sha2.h b/libs/apr/random/unix/sha2.h index 9f0d93e1e0..0696d4e0b1 100644 --- a/libs/apr/random/unix/sha2.h +++ b/libs/apr/random/unix/sha2.h @@ -27,7 +27,7 @@ extern "C" { #endif -#include "apr.h" +#include "fspr.h" /*** SHA-256/384/512 Various Length Definitions ***********************/ #define SHA256_BLOCK_LENGTH 64 @@ -43,39 +43,39 @@ extern "C" { /*** SHA-256/384/512 Context Structures *******************************/ typedef struct _SHA256_CTX { - apr_uint32_t state[8]; - apr_uint64_t bitcount; - apr_byte_t buffer[SHA256_BLOCK_LENGTH]; + fspr_uint32_t state[8]; + fspr_uint64_t bitcount; + fspr_byte_t buffer[SHA256_BLOCK_LENGTH]; } SHA256_CTX; typedef struct _SHA512_CTX { - apr_uint64_t state[8]; - apr_uint64_t bitcount[2]; - apr_byte_t buffer[SHA512_BLOCK_LENGTH]; + fspr_uint64_t state[8]; + fspr_uint64_t bitcount[2]; + fspr_byte_t buffer[SHA512_BLOCK_LENGTH]; } SHA512_CTX; typedef SHA512_CTX SHA384_CTX; /*** SHA-256/384/512 Function Prototypes ******************************/ -void apr__SHA256_Init(SHA256_CTX *); -void apr__SHA256_Update(SHA256_CTX *, const apr_byte_t *, size_t); -void apr__SHA256_Final(apr_byte_t [SHA256_DIGEST_LENGTH], SHA256_CTX *); -char* apr__SHA256_End(SHA256_CTX *, char [SHA256_DIGEST_STRING_LENGTH]); -char* apr__SHA256_Data(const apr_byte_t *, size_t, +void fspr__SHA256_Init(SHA256_CTX *); +void fspr__SHA256_Update(SHA256_CTX *, const fspr_byte_t *, size_t); +void fspr__SHA256_Final(fspr_byte_t [SHA256_DIGEST_LENGTH], SHA256_CTX *); +char* fspr__SHA256_End(SHA256_CTX *, char [SHA256_DIGEST_STRING_LENGTH]); +char* fspr__SHA256_Data(const fspr_byte_t *, size_t, char [SHA256_DIGEST_STRING_LENGTH]); -void apr__SHA384_Init(SHA384_CTX *); -void apr__SHA384_Update(SHA384_CTX *, const apr_byte_t *, size_t); -void apr__SHA384_Final(apr_byte_t [SHA384_DIGEST_LENGTH], SHA384_CTX *); -char* apr__SHA384_End(SHA384_CTX *, char [SHA384_DIGEST_STRING_LENGTH]); -char* apr__SHA384_Data(const apr_byte_t *, size_t, +void fspr__SHA384_Init(SHA384_CTX *); +void fspr__SHA384_Update(SHA384_CTX *, const fspr_byte_t *, size_t); +void fspr__SHA384_Final(fspr_byte_t [SHA384_DIGEST_LENGTH], SHA384_CTX *); +char* fspr__SHA384_End(SHA384_CTX *, char [SHA384_DIGEST_STRING_LENGTH]); +char* fspr__SHA384_Data(const fspr_byte_t *, size_t, char [SHA384_DIGEST_STRING_LENGTH]); -void apr__SHA512_Init(SHA512_CTX *); -void apr__SHA512_Update(SHA512_CTX *, const apr_byte_t *, size_t); -void apr__SHA512_Final(apr_byte_t [SHA512_DIGEST_LENGTH], SHA512_CTX *); -char* apr__SHA512_End(SHA512_CTX *, char [SHA512_DIGEST_STRING_LENGTH]); -char* apr__SHA512_Data(const apr_byte_t *, size_t, +void fspr__SHA512_Init(SHA512_CTX *); +void fspr__SHA512_Update(SHA512_CTX *, const fspr_byte_t *, size_t); +void fspr__SHA512_Final(fspr_byte_t [SHA512_DIGEST_LENGTH], SHA512_CTX *); +char* fspr__SHA512_End(SHA512_CTX *, char [SHA512_DIGEST_STRING_LENGTH]); +char* fspr__SHA512_Data(const fspr_byte_t *, size_t, char [SHA512_DIGEST_STRING_LENGTH]); #ifdef __cplusplus diff --git a/libs/apr/random/unix/sha2_glue.c b/libs/apr/random/unix/sha2_glue.c index 4909a8fe1f..17bc4bd356 100644 --- a/libs/apr/random/unix/sha2_glue.c +++ b/libs/apr/random/unix/sha2_glue.c @@ -1,29 +1,29 @@ -#include -#include -#include +#include +#include +#include #include "sha2.h" -static void sha256_init(apr_crypto_hash_t *h) +static void sha256_init(fspr_crypto_hash_t *h) { - apr__SHA256_Init(h->data); + fspr__SHA256_Init(h->data); } -static void sha256_add(apr_crypto_hash_t *h,const void *data, - apr_size_t bytes) +static void sha256_add(fspr_crypto_hash_t *h,const void *data, + fspr_size_t bytes) { - apr__SHA256_Update(h->data,data,bytes); + fspr__SHA256_Update(h->data,data,bytes); } -static void sha256_finish(apr_crypto_hash_t *h,unsigned char *result) +static void sha256_finish(fspr_crypto_hash_t *h,unsigned char *result) { - apr__SHA256_Final(result,h->data); + fspr__SHA256_Final(result,h->data); } -APR_DECLARE(apr_crypto_hash_t *) apr_crypto_sha256_new(apr_pool_t *p) +APR_DECLARE(fspr_crypto_hash_t *) fspr_crypto_sha256_new(fspr_pool_t *p) { - apr_crypto_hash_t *h=apr_palloc(p,sizeof *h); + fspr_crypto_hash_t *h=fspr_palloc(p,sizeof *h); - h->data=apr_palloc(p,sizeof(SHA256_CTX)); + h->data=fspr_palloc(p,sizeof(SHA256_CTX)); h->init=sha256_init; h->add=sha256_add; h->finish=sha256_finish; diff --git a/libs/apr/renames_pending b/libs/apr/renames_pending index ca007a729c..58757f69b2 100644 --- a/libs/apr/renames_pending +++ b/libs/apr/renames_pending @@ -1,39 +1,39 @@ Pending symbol renames for APR [for some discussion yet] -apr_file_info_t from apr_finfo_t -apr_file_attrs_t from apr_fileattrs_t -apr_file_seek_where_t from apr_seek_where_t +fspr_file_info_t from fspr_finfo_t +fspr_file_attrs_t from fspr_fileattrs_t +fspr_file_seek_where_t from fspr_seek_where_t -#apr_filepath_name_get from apr_filename_of_pathname +#fspr_filepath_name_get from fspr_filename_of_pathname -apr_lock_mech_e from apr_lockmech_e +fspr_lock_mech_e from fspr_lockmech_e -#apr_gid_get from apr_get_groupid -#apr_gid_name_get from apr_get_groupname -#apr_gid_name_get from apr_group_name_get -#apr_gid_compare from apr_compare_groups +#fspr_gid_get from fspr_get_groupid +#fspr_gid_name_get from fspr_get_groupname +#fspr_gid_name_get from fspr_group_name_get +#fspr_gid_compare from fspr_compare_groups -#apr_socket_shutdown from apr_shutdown -#apr_socket_bind from apr_bind -#apr_socket_listen from apr_listen -#apr_socket_accept from apr_accept -#apr_socket_connect from apr_connect -#apr_socket_send from apr_send -#apr_socket_sendv from apr_sendv -#apr_socket_sendto from apr_sendto -#apr_socket_recvfrom from apr_recvfrom -#apr_socket_sendfile from apr_sendfile -#apr_socket_recv from apr_recv -#apr_socket_inherit_set from apr_socket_set_inherit -#apr_socket_inherit_unset from apr_socket_unset_inherit +#fspr_socket_shutdown from fspr_shutdown +#fspr_socket_bind from fspr_bind +#fspr_socket_listen from fspr_listen +#fspr_socket_accept from fspr_accept +#fspr_socket_connect from fspr_connect +#fspr_socket_send from fspr_send +#fspr_socket_sendv from fspr_sendv +#fspr_socket_sendto from fspr_sendto +#fspr_socket_recvfrom from fspr_recvfrom +#fspr_socket_sendfile from fspr_sendfile +#fspr_socket_recv from fspr_recv +#fspr_socket_inherit_set from fspr_socket_set_inherit +#fspr_socket_inherit_unset from fspr_socket_unset_inherit -#apr_time_exp_gmt_get from apr_implode_gmt -apr_time_interval_t from apr_interval_time_t -apr_time_interval_short_t from apr_short_interval_time_t +#fspr_time_exp_gmt_get from fspr_implode_gmt +fspr_time_interval_t from fspr_interval_time_t +fspr_time_interval_short_t from fspr_short_interval_time_t -#apr_uid_homepath_get from apr_get_home_directory -#apr_uid_get from apr_get_userid -#apr_uid_current from apr_current_userid -#apr_uid_compare from apr_compare_users -#apr_uid_name_get from apr_get_username +#fspr_uid_homepath_get from fspr_get_home_directory +#fspr_uid_get from fspr_get_userid +#fspr_uid_current from fspr_current_userid +#fspr_uid_compare from fspr_compare_users +#fspr_uid_name_get from fspr_get_username diff --git a/libs/apr/shmem/beos/shm.c b/libs/apr/shmem/beos/shm.c index 1f06f78acd..f8cb22db29 100644 --- a/libs/apr/shmem/beos/shm.c +++ b/libs/apr/shmem/beos/shm.c @@ -14,44 +14,44 @@ * limitations under the License. */ -#include "apr_general.h" -#include "apr_shm.h" -#include "apr_errno.h" -#include "apr_lib.h" -#include "apr_strings.h" +#include "fspr_general.h" +#include "fspr_shm.h" +#include "fspr_errno.h" +#include "fspr_lib.h" +#include "fspr_strings.h" #include #include #include -#include "apr_portable.h" +#include "fspr_portable.h" -struct apr_shm_t { - apr_pool_t *pool; +struct fspr_shm_t { + fspr_pool_t *pool; void *memblock; void *ptr; - apr_size_t reqsize; - apr_size_t avail; + fspr_size_t reqsize; + fspr_size_t avail; area_id aid; }; -APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, - apr_size_t reqsize, +APR_DECLARE(fspr_status_t) fspr_shm_create(fspr_shm_t **m, + fspr_size_t reqsize, const char *filename, - apr_pool_t *p) + fspr_pool_t *p) { - apr_size_t pagesize; + fspr_size_t pagesize; area_id newid; char *addr; char shname[B_OS_NAME_LENGTH]; - (*m) = (apr_shm_t *)apr_pcalloc(p, sizeof(apr_shm_t)); + (*m) = (fspr_shm_t *)fspr_pcalloc(p, sizeof(fspr_shm_t)); /* we MUST allocate in pages, so calculate how big an area we need... */ pagesize = ((reqsize + B_PAGE_SIZE - 1) / B_PAGE_SIZE) * B_PAGE_SIZE; if (!filename) { int num = 0; - snprintf(shname, B_OS_NAME_LENGTH, "apr_shmem_%ld", find_thread(NULL)); + snprintf(shname, B_OS_NAME_LENGTH, "fspr_shmem_%ld", find_thread(NULL)); while (find_area(shname) >= 0) - snprintf(shname, B_OS_NAME_LENGTH, "apr_shmem_%ld_%d", + snprintf(shname, B_OS_NAME_LENGTH, "fspr_shmem_%ld_%d", find_thread(NULL), num++); } newid = create_area(filename ? filename : shname, @@ -71,7 +71,7 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_shm_destroy(apr_shm_t *m) +APR_DECLARE(fspr_status_t) fspr_shm_destroy(fspr_shm_t *m) { delete_area(m->aid); m->avail = 0; @@ -79,8 +79,8 @@ APR_DECLARE(apr_status_t) apr_shm_destroy(apr_shm_t *m) return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_shm_remove(const char *filename, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_shm_remove(const char *filename, + fspr_pool_t *pool) { area_id deleteme = find_area(filename); @@ -91,19 +91,19 @@ APR_DECLARE(apr_status_t) apr_shm_remove(const char *filename, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m, +APR_DECLARE(fspr_status_t) fspr_shm_attach(fspr_shm_t **m, const char *filename, - apr_pool_t *pool) + fspr_pool_t *pool) { area_info ai; thread_info ti; - apr_shm_t *new_m; + fspr_shm_t *new_m; area_id deleteme = find_area(filename); if (deleteme == B_NAME_NOT_FOUND) return APR_EINVAL; - new_m = (apr_shm_t*)apr_palloc(pool, sizeof(apr_shm_t*)); + new_m = (fspr_shm_t*)fspr_palloc(pool, sizeof(fspr_shm_t*)); if (new_m == NULL) return APR_ENOMEM; new_m->pool = pool; @@ -133,33 +133,33 @@ APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_shm_detach(apr_shm_t *m) +APR_DECLARE(fspr_status_t) fspr_shm_detach(fspr_shm_t *m) { delete_area(m->aid); return APR_SUCCESS; } -APR_DECLARE(void *) apr_shm_baseaddr_get(const apr_shm_t *m) +APR_DECLARE(void *) fspr_shm_baseaddr_get(const fspr_shm_t *m) { return m->memblock; } -APR_DECLARE(apr_size_t) apr_shm_size_get(const apr_shm_t *m) +APR_DECLARE(fspr_size_t) fspr_shm_size_get(const fspr_shm_t *m) { return m->reqsize; } APR_POOL_IMPLEMENT_ACCESSOR(shm) -APR_DECLARE(apr_status_t) apr_os_shm_get(apr_os_shm_t *osshm, - apr_shm_t *shm) +APR_DECLARE(fspr_status_t) fspr_os_shm_get(fspr_os_shm_t *osshm, + fspr_shm_t *shm) { return APR_ENOTIMPL; } -APR_DECLARE(apr_status_t) apr_os_shm_put(apr_shm_t **m, - apr_os_shm_t *osshm, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_os_shm_put(fspr_shm_t **m, + fspr_os_shm_t *osshm, + fspr_pool_t *pool) { return APR_ENOTIMPL; } diff --git a/libs/apr/shmem/os2/shm.c b/libs/apr/shmem/os2/shm.c index 340cae4074..c08f517818 100644 --- a/libs/apr/shmem/os2/shm.c +++ b/libs/apr/shmem/os2/shm.c @@ -14,32 +14,32 @@ * limitations under the License. */ -#include "apr_general.h" -#include "apr_shm.h" -#include "apr_errno.h" -#include "apr_lib.h" -#include "apr_strings.h" -#include "apr_portable.h" +#include "fspr_general.h" +#include "fspr_shm.h" +#include "fspr_errno.h" +#include "fspr_lib.h" +#include "fspr_strings.h" +#include "fspr_portable.h" -struct apr_shm_t { - apr_pool_t *pool; +struct fspr_shm_t { + fspr_pool_t *pool; void *memblock; }; -APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, - apr_size_t reqsize, +APR_DECLARE(fspr_status_t) fspr_shm_create(fspr_shm_t **m, + fspr_size_t reqsize, const char *filename, - apr_pool_t *pool) + fspr_pool_t *pool) { int rc; - apr_shm_t *newm = (apr_shm_t *)apr_palloc(pool, sizeof(apr_shm_t)); + fspr_shm_t *newm = (fspr_shm_t *)fspr_palloc(pool, sizeof(fspr_shm_t)); char *name = NULL; ULONG flags = PAG_COMMIT|PAG_READ|PAG_WRITE; newm->pool = pool; if (filename) { - name = apr_pstrcat(pool, "\\SHAREMEM\\", filename, NULL); + name = fspr_pstrcat(pool, "\\SHAREMEM\\", filename, NULL); } if (name == NULL) { @@ -56,29 +56,29 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_shm_destroy(apr_shm_t *m) +APR_DECLARE(fspr_status_t) fspr_shm_destroy(fspr_shm_t *m) { DosFreeMem(m->memblock); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_shm_remove(const char *filename, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_shm_remove(const char *filename, + fspr_pool_t *pool) { return APR_ENOTIMPL; } -APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m, +APR_DECLARE(fspr_status_t) fspr_shm_attach(fspr_shm_t **m, const char *filename, - apr_pool_t *pool) + fspr_pool_t *pool) { int rc; - apr_shm_t *newm = (apr_shm_t *)apr_palloc(pool, sizeof(apr_shm_t)); + fspr_shm_t *newm = (fspr_shm_t *)fspr_palloc(pool, sizeof(fspr_shm_t)); char *name = NULL; ULONG flags = PAG_READ|PAG_WRITE; newm->pool = pool; - name = apr_pstrcat(pool, "\\SHAREMEM\\", filename, NULL); + name = fspr_pstrcat(pool, "\\SHAREMEM\\", filename, NULL); rc = DosGetNamedSharedMem(&(newm->memblock), name, flags); @@ -90,7 +90,7 @@ APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_shm_detach(apr_shm_t *m) +APR_DECLARE(fspr_status_t) fspr_shm_detach(fspr_shm_t *m) { int rc = 0; @@ -101,12 +101,12 @@ APR_DECLARE(apr_status_t) apr_shm_detach(apr_shm_t *m) return APR_FROM_OS_ERROR(rc); } -APR_DECLARE(void *) apr_shm_baseaddr_get(const apr_shm_t *m) +APR_DECLARE(void *) fspr_shm_baseaddr_get(const fspr_shm_t *m) { return m->memblock; } -APR_DECLARE(apr_size_t) apr_shm_size_get(const apr_shm_t *m) +APR_DECLARE(fspr_size_t) fspr_shm_size_get(const fspr_shm_t *m) { ULONG flags, size = 0x1000000; DosQueryMem(m->memblock, &size, &flags); @@ -115,19 +115,19 @@ APR_DECLARE(apr_size_t) apr_shm_size_get(const apr_shm_t *m) APR_POOL_IMPLEMENT_ACCESSOR(shm) -APR_DECLARE(apr_status_t) apr_os_shm_get(apr_os_shm_t *osshm, - apr_shm_t *shm) +APR_DECLARE(fspr_status_t) fspr_os_shm_get(fspr_os_shm_t *osshm, + fspr_shm_t *shm) { *osshm = shm->memblock; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_os_shm_put(apr_shm_t **m, - apr_os_shm_t *osshm, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_os_shm_put(fspr_shm_t **m, + fspr_os_shm_t *osshm, + fspr_pool_t *pool) { int rc; - apr_shm_t *newm = (apr_shm_t *)apr_palloc(pool, sizeof(apr_shm_t)); + fspr_shm_t *newm = (fspr_shm_t *)fspr_palloc(pool, sizeof(fspr_shm_t)); ULONG flags = PAG_COMMIT|PAG_READ|PAG_WRITE; newm->pool = pool; diff --git a/libs/apr/shmem/unix/shm.c b/libs/apr/shmem/unix/shm.c index 95d1c053f0..36b16d91cc 100644 --- a/libs/apr/shmem/unix/shm.c +++ b/libs/apr/shmem/unix/shm.c @@ -14,16 +14,16 @@ * limitations under the License. */ -#include "apr_arch_shm.h" +#include "fspr_arch_shm.h" -#include "apr_general.h" -#include "apr_errno.h" -#include "apr_user.h" -#include "apr_strings.h" +#include "fspr_general.h" +#include "fspr_errno.h" +#include "fspr_user.h" +#include "fspr_strings.h" -static apr_status_t shm_cleanup_owner(void *m_) +static fspr_status_t shm_cleanup_owner(void *m_) { - apr_shm_t *m = (apr_shm_t *)m_; + fspr_shm_t *m = (fspr_shm_t *)m_; /* anonymous shared memory */ if (m->filename == NULL) { @@ -49,7 +49,7 @@ static apr_status_t shm_cleanup_owner(void *m_) if (munmap(m->base, m->realsize) == -1) { return errno; } - return apr_file_remove(m->filename, m->pool); + return fspr_file_remove(m->filename, m->pool); #endif #if APR_USE_SHMEM_MMAP_SHM if (munmap(m->base, m->realsize) == -1) { @@ -70,55 +70,55 @@ static apr_status_t shm_cleanup_owner(void *m_) if (shmdt(m->base) == -1) { return errno; } - return apr_file_remove(m->filename, m->pool); + return fspr_file_remove(m->filename, m->pool); #endif } return APR_ENOTIMPL; } -APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, - apr_size_t reqsize, +APR_DECLARE(fspr_status_t) fspr_shm_create(fspr_shm_t **m, + fspr_size_t reqsize, const char *filename, - apr_pool_t *pool) + fspr_pool_t *pool) { - apr_shm_t *new_m; - apr_status_t status; + fspr_shm_t *new_m; + fspr_status_t status; #if APR_USE_SHMEM_SHMGET || APR_USE_SHMEM_SHMGET_ANON struct shmid_ds shmbuf; - apr_uid_t uid; - apr_gid_t gid; + fspr_uid_t uid; + fspr_gid_t gid; #endif #if APR_USE_SHMEM_MMAP_TMP || APR_USE_SHMEM_MMAP_SHM || \ APR_USE_SHMEM_MMAP_ZERO int tmpfd; #endif #if APR_USE_SHMEM_SHMGET - apr_size_t nbytes; + fspr_size_t nbytes; key_t shmkey; #endif #if APR_USE_SHMEM_MMAP_ZERO || APR_USE_SHMEM_SHMGET || \ APR_USE_SHMEM_MMAP_TMP || APR_USE_SHMEM_MMAP_SHM - apr_file_t *file; /* file where metadata is stored */ + fspr_file_t *file; /* file where metadata is stored */ #endif /* Check if they want anonymous or name-based shared memory */ if (filename == NULL) { #if APR_USE_SHMEM_MMAP_ZERO || APR_USE_SHMEM_MMAP_ANON - new_m = apr_palloc(pool, sizeof(apr_shm_t)); + new_m = fspr_palloc(pool, sizeof(fspr_shm_t)); new_m->pool = pool; new_m->reqsize = reqsize; new_m->realsize = reqsize + - APR_ALIGN_DEFAULT(sizeof(apr_size_t)); /* room for metadata */ + APR_ALIGN_DEFAULT(sizeof(fspr_size_t)); /* room for metadata */ new_m->filename = NULL; #if APR_USE_SHMEM_MMAP_ZERO - status = apr_file_open(&file, "/dev/zero", APR_READ | APR_WRITE, + status = fspr_file_open(&file, "/dev/zero", APR_READ | APR_WRITE, APR_OS_DEFAULT, pool); if (status != APR_SUCCESS) { return status; } - status = apr_os_file_get(&tmpfd, file); + status = fspr_os_file_get(&tmpfd, file); if (status != APR_SUCCESS) { return status; } @@ -129,18 +129,18 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, return errno; } - status = apr_file_close(file); + status = fspr_file_close(file); if (status != APR_SUCCESS) { return status; } /* store the real size in the metadata */ - *(apr_size_t*)(new_m->base) = new_m->realsize; + *(fspr_size_t*)(new_m->base) = new_m->realsize; /* metadata isn't usable */ - new_m->usable = (char *)new_m->base + APR_ALIGN_DEFAULT(sizeof(apr_size_t)); + new_m->usable = (char *)new_m->base + APR_ALIGN_DEFAULT(sizeof(fspr_size_t)); - apr_pool_cleanup_register(new_m->pool, new_m, shm_cleanup_owner, - apr_pool_cleanup_null); + fspr_pool_cleanup_register(new_m->pool, new_m, shm_cleanup_owner, + fspr_pool_cleanup_null); *m = new_m; return APR_SUCCESS; @@ -152,12 +152,12 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, } /* store the real size in the metadata */ - *(apr_size_t*)(new_m->base) = new_m->realsize; + *(fspr_size_t*)(new_m->base) = new_m->realsize; /* metadata isn't usable */ - new_m->usable = (char *)new_m->base + APR_ALIGN_DEFAULT(sizeof(apr_size_t)); + new_m->usable = (char *)new_m->base + APR_ALIGN_DEFAULT(sizeof(fspr_size_t)); - apr_pool_cleanup_register(new_m->pool, new_m, shm_cleanup_owner, - apr_pool_cleanup_null); + fspr_pool_cleanup_register(new_m->pool, new_m, shm_cleanup_owner, + fspr_pool_cleanup_null); *m = new_m; return APR_SUCCESS; @@ -165,7 +165,7 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, #endif /* APR_USE_SHMEM_MMAP_ZERO || APR_USE_SHMEM_MMAP_ANON */ #if APR_USE_SHMEM_SHMGET_ANON - new_m = apr_palloc(pool, sizeof(apr_shm_t)); + new_m = fspr_palloc(pool, sizeof(fspr_shm_t)); new_m->pool = pool; new_m->reqsize = reqsize; new_m->realsize = reqsize; @@ -184,7 +184,7 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, if (shmctl(new_m->shmid, IPC_STAT, &shmbuf) == -1) { return errno; } - apr_uid_current(&uid, &gid, pool); + fspr_uid_current(&uid, &gid, pool); shmbuf.shm_perm.uid = uid; shmbuf.shm_perm.gid = gid; if (shmctl(new_m->shmid, IPC_SET, &shmbuf) == -1) { @@ -199,8 +199,8 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, return errno; } - apr_pool_cleanup_register(new_m->pool, new_m, shm_cleanup_owner, - apr_pool_cleanup_null); + fspr_pool_cleanup_register(new_m->pool, new_m, shm_cleanup_owner, + fspr_pool_cleanup_null); *m = new_m; return APR_SUCCESS; #endif /* APR_USE_SHMEM_SHMGET_ANON */ @@ -210,38 +210,38 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, /* Name-based shared memory */ else { - new_m = apr_palloc(pool, sizeof(apr_shm_t)); + new_m = fspr_palloc(pool, sizeof(fspr_shm_t)); new_m->pool = pool; new_m->reqsize = reqsize; - new_m->filename = apr_pstrdup(pool, filename); + new_m->filename = fspr_pstrdup(pool, filename); #if APR_USE_SHMEM_MMAP_TMP || APR_USE_SHMEM_MMAP_SHM new_m->realsize = reqsize + - APR_ALIGN_DEFAULT(sizeof(apr_size_t)); /* room for metadata */ + APR_ALIGN_DEFAULT(sizeof(fspr_size_t)); /* room for metadata */ /* FIXME: Ignore error for now. * - * status = apr_file_remove(file, pool);*/ + * status = fspr_file_remove(file, pool);*/ status = APR_SUCCESS; #if APR_USE_SHMEM_MMAP_TMP /* FIXME: Is APR_OS_DEFAULT sufficient? */ - status = apr_file_open(&file, filename, + status = fspr_file_open(&file, filename, APR_READ | APR_WRITE | APR_CREATE | APR_EXCL, APR_OS_DEFAULT, pool); if (status != APR_SUCCESS) { return status; } - status = apr_os_file_get(&tmpfd, file); + status = fspr_os_file_get(&tmpfd, file); if (status != APR_SUCCESS) { - apr_file_close(file); /* ignore errors, we're failing */ - apr_file_remove(new_m->filename, new_m->pool); + fspr_file_close(file); /* ignore errors, we're failing */ + fspr_file_remove(new_m->filename, new_m->pool); return status; } - status = apr_file_trunc(file, new_m->realsize); + status = fspr_file_trunc(file, new_m->realsize); if (status != APR_SUCCESS) { - apr_file_close(file); /* ignore errors, we're failing */ - apr_file_remove(new_m->filename, new_m->pool); + fspr_file_close(file); /* ignore errors, we're failing */ + fspr_file_remove(new_m->filename, new_m->pool); return status; } @@ -249,7 +249,7 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, MAP_SHARED, tmpfd, 0); /* FIXME: check for errors */ - status = apr_file_close(file); + status = fspr_file_close(file); if (status != APR_SUCCESS) { return status; } @@ -260,14 +260,14 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, return errno; } - status = apr_os_file_put(&file, &tmpfd, + status = fspr_os_file_put(&file, &tmpfd, APR_READ | APR_WRITE | APR_CREATE | APR_EXCL, pool); if (status != APR_SUCCESS) { return status; } - status = apr_file_trunc(file, new_m->realsize); + status = fspr_file_trunc(file, new_m->realsize); if (status != APR_SUCCESS) { shm_unlink(filename); /* we're failing, remove the object */ return status; @@ -277,19 +277,19 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, /* FIXME: check for errors */ - status = apr_file_close(file); + status = fspr_file_close(file); if (status != APR_SUCCESS) { return status; } #endif /* APR_USE_SHMEM_MMAP_SHM */ /* store the real size in the metadata */ - *(apr_size_t*)(new_m->base) = new_m->realsize; + *(fspr_size_t*)(new_m->base) = new_m->realsize; /* metadata isn't usable */ - new_m->usable = (char *)new_m->base + APR_ALIGN_DEFAULT(sizeof(apr_size_t)); + new_m->usable = (char *)new_m->base + APR_ALIGN_DEFAULT(sizeof(fspr_size_t)); - apr_pool_cleanup_register(new_m->pool, new_m, shm_cleanup_owner, - apr_pool_cleanup_null); + fspr_pool_cleanup_register(new_m->pool, new_m, shm_cleanup_owner, + fspr_pool_cleanup_null); *m = new_m; return APR_SUCCESS; @@ -299,7 +299,7 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, new_m->realsize = reqsize; /* FIXME: APR_OS_DEFAULT is too permissive, switch to 600 I think. */ - status = apr_file_open(&file, filename, + status = fspr_file_open(&file, filename, APR_WRITE | APR_CREATE | APR_EXCL, APR_OS_DEFAULT, pool); if (status != APR_SUCCESS) { @@ -326,7 +326,7 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, if (shmctl(new_m->shmid, IPC_STAT, &shmbuf) == -1) { return errno; } - apr_uid_current(&uid, &gid, pool); + fspr_uid_current(&uid, &gid, pool); shmbuf.shm_perm.uid = uid; shmbuf.shm_perm.gid = gid; if (shmctl(new_m->shmid, IPC_SET, &shmbuf) == -1) { @@ -334,18 +334,18 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, } nbytes = sizeof(reqsize); - status = apr_file_write(file, (const void *)&reqsize, + status = fspr_file_write(file, (const void *)&reqsize, &nbytes); if (status != APR_SUCCESS) { return status; } - status = apr_file_close(file); + status = fspr_file_close(file); if (status != APR_SUCCESS) { return status; } - apr_pool_cleanup_register(new_m->pool, new_m, shm_cleanup_owner, - apr_pool_cleanup_null); + fspr_pool_cleanup_register(new_m->pool, new_m, shm_cleanup_owner, + fspr_pool_cleanup_null); *m = new_m; return APR_SUCCESS; @@ -355,18 +355,18 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, return APR_ENOTIMPL; } -APR_DECLARE(apr_status_t) apr_shm_remove(const char *filename, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_shm_remove(const char *filename, + fspr_pool_t *pool) { #if APR_USE_SHMEM_SHMGET - apr_status_t status; - apr_file_t *file; + fspr_status_t status; + fspr_file_t *file; key_t shmkey; int shmid; #endif #if APR_USE_SHMEM_MMAP_TMP - return apr_file_remove(filename, pool); + return fspr_file_remove(filename, pool); #endif #if APR_USE_SHMEM_MMAP_SHM if (shm_unlink(filename) == -1) { @@ -376,7 +376,7 @@ APR_DECLARE(apr_status_t) apr_shm_remove(const char *filename, #endif #if APR_USE_SHMEM_SHMGET /* Presume that the file already exists; just open for writing */ - status = apr_file_open(&file, filename, APR_WRITE, + status = fspr_file_open(&file, filename, APR_WRITE, APR_OS_DEFAULT, pool); if (status) { return status; @@ -389,7 +389,7 @@ APR_DECLARE(apr_status_t) apr_shm_remove(const char *filename, goto shm_remove_failed; } - apr_file_close(file); + fspr_file_close(file); if ((shmid = shmget(shmkey, 0, SHM_R | SHM_W)) < 0) { goto shm_remove_failed; @@ -401,12 +401,12 @@ APR_DECLARE(apr_status_t) apr_shm_remove(const char *filename, if (shmctl(shmid, IPC_RMID, NULL) == -1) { goto shm_remove_failed; } - return apr_file_remove(filename, pool); + return fspr_file_remove(filename, pool); shm_remove_failed: status = errno; /* ensure the file has been removed anyway. */ - apr_file_remove(filename, pool); + fspr_file_remove(filename, pool); return status; #endif @@ -414,14 +414,14 @@ shm_remove_failed: return APR_ENOTIMPL; } -APR_DECLARE(apr_status_t) apr_shm_destroy(apr_shm_t *m) +APR_DECLARE(fspr_status_t) fspr_shm_destroy(fspr_shm_t *m) { - return apr_pool_cleanup_run(m->pool, m, shm_cleanup_owner); + return fspr_pool_cleanup_run(m->pool, m, shm_cleanup_owner); } -static apr_status_t shm_cleanup_attach(void *m_) +static fspr_status_t shm_cleanup_attach(void *m_) { - apr_shm_t *m = (apr_shm_t *)m_; + fspr_shm_t *m = (fspr_shm_t *)m_; if (m->filename == NULL) { /* It doesn't make sense to detach from an anonymous memory segment. */ @@ -445,9 +445,9 @@ static apr_status_t shm_cleanup_attach(void *m_) return APR_ENOTIMPL; } -APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m, +APR_DECLARE(fspr_status_t) fspr_shm_attach(fspr_shm_t **m, const char *filename, - apr_pool_t *pool) + fspr_pool_t *pool) { if (filename == NULL) { /* It doesn't make sense to attach to a segment if you don't know @@ -456,88 +456,88 @@ APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m, } else { #if APR_USE_SHMEM_MMAP_TMP || APR_USE_SHMEM_MMAP_SHM - apr_shm_t *new_m; - apr_status_t status; + fspr_shm_t *new_m; + fspr_status_t status; int tmpfd; - apr_file_t *file; /* file where metadata is stored */ - apr_size_t nbytes; + fspr_file_t *file; /* file where metadata is stored */ + fspr_size_t nbytes; - new_m = apr_palloc(pool, sizeof(apr_shm_t)); + new_m = fspr_palloc(pool, sizeof(fspr_shm_t)); new_m->pool = pool; - new_m->filename = apr_pstrdup(pool, filename); + new_m->filename = fspr_pstrdup(pool, filename); - status = apr_file_open(&file, filename, + status = fspr_file_open(&file, filename, APR_READ | APR_WRITE, APR_OS_DEFAULT, pool); if (status != APR_SUCCESS) { return status; } - status = apr_os_file_get(&tmpfd, file); + status = fspr_os_file_get(&tmpfd, file); if (status != APR_SUCCESS) { return status; } nbytes = sizeof(new_m->realsize); - status = apr_file_read(file, (void *)&(new_m->realsize), + status = fspr_file_read(file, (void *)&(new_m->realsize), &nbytes); if (status != APR_SUCCESS) { return status; } - status = apr_os_file_get(&tmpfd, file); + status = fspr_os_file_get(&tmpfd, file); if (status != APR_SUCCESS) { - apr_file_close(file); /* ignore errors, we're failing */ - apr_file_remove(new_m->filename, new_m->pool); + fspr_file_close(file); /* ignore errors, we're failing */ + fspr_file_remove(new_m->filename, new_m->pool); return status; } - new_m->reqsize = new_m->realsize - sizeof(apr_size_t); + new_m->reqsize = new_m->realsize - sizeof(fspr_size_t); new_m->base = mmap(NULL, new_m->realsize, PROT_READ | PROT_WRITE, MAP_SHARED, tmpfd, 0); /* FIXME: check for errors */ - status = apr_file_close(file); + status = fspr_file_close(file); if (status != APR_SUCCESS) { return status; } /* metadata isn't part of the usable segment */ - new_m->usable = (char *)new_m->base + APR_ALIGN_DEFAULT(sizeof(apr_size_t)); + new_m->usable = (char *)new_m->base + APR_ALIGN_DEFAULT(sizeof(fspr_size_t)); - apr_pool_cleanup_register(new_m->pool, new_m, shm_cleanup_attach, - apr_pool_cleanup_null); + fspr_pool_cleanup_register(new_m->pool, new_m, shm_cleanup_attach, + fspr_pool_cleanup_null); *m = new_m; return APR_SUCCESS; #endif /* APR_USE_SHMEM_MMAP_TMP || APR_USE_SHMEM_MMAP_SHM */ #if APR_USE_SHMEM_SHMGET - apr_shm_t *new_m; - apr_status_t status; - apr_file_t *file; /* file where metadata is stored */ - apr_size_t nbytes; + fspr_shm_t *new_m; + fspr_status_t status; + fspr_file_t *file; /* file where metadata is stored */ + fspr_size_t nbytes; key_t shmkey; - new_m = apr_palloc(pool, sizeof(apr_shm_t)); + new_m = fspr_palloc(pool, sizeof(fspr_shm_t)); - status = apr_file_open(&file, filename, + status = fspr_file_open(&file, filename, APR_READ, APR_OS_DEFAULT, pool); if (status != APR_SUCCESS) { return status; } nbytes = sizeof(new_m->reqsize); - status = apr_file_read(file, (void *)&(new_m->reqsize), + status = fspr_file_read(file, (void *)&(new_m->reqsize), &nbytes); if (status != APR_SUCCESS) { return status; } - status = apr_file_close(file); + status = fspr_file_close(file); if (status != APR_SUCCESS) { return status; } - new_m->filename = apr_pstrdup(pool, filename); + new_m->filename = fspr_pstrdup(pool, filename); new_m->pool = pool; shmkey = ftok(filename, 1); if (shmkey == (key_t)-1) { @@ -552,8 +552,8 @@ APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m, new_m->usable = new_m->base; new_m->realsize = new_m->reqsize; - apr_pool_cleanup_register(new_m->pool, new_m, shm_cleanup_attach, - apr_pool_cleanup_null); + fspr_pool_cleanup_register(new_m->pool, new_m, shm_cleanup_attach, + fspr_pool_cleanup_null); *m = new_m; return APR_SUCCESS; @@ -563,34 +563,34 @@ APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m, return APR_ENOTIMPL; } -APR_DECLARE(apr_status_t) apr_shm_detach(apr_shm_t *m) +APR_DECLARE(fspr_status_t) fspr_shm_detach(fspr_shm_t *m) { - apr_status_t rv = shm_cleanup_attach(m); - apr_pool_cleanup_kill(m->pool, m, shm_cleanup_attach); + fspr_status_t rv = shm_cleanup_attach(m); + fspr_pool_cleanup_kill(m->pool, m, shm_cleanup_attach); return rv; } -APR_DECLARE(void *) apr_shm_baseaddr_get(const apr_shm_t *m) +APR_DECLARE(void *) fspr_shm_baseaddr_get(const fspr_shm_t *m) { return m->usable; } -APR_DECLARE(apr_size_t) apr_shm_size_get(const apr_shm_t *m) +APR_DECLARE(fspr_size_t) fspr_shm_size_get(const fspr_shm_t *m) { return m->reqsize; } APR_POOL_IMPLEMENT_ACCESSOR(shm) -APR_DECLARE(apr_status_t) apr_os_shm_get(apr_os_shm_t *osshm, - apr_shm_t *shm) +APR_DECLARE(fspr_status_t) fspr_os_shm_get(fspr_os_shm_t *osshm, + fspr_shm_t *shm) { return APR_ENOTIMPL; } -APR_DECLARE(apr_status_t) apr_os_shm_put(apr_shm_t **m, - apr_os_shm_t *osshm, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_os_shm_put(fspr_shm_t **m, + fspr_os_shm_t *osshm, + fspr_pool_t *pool) { return APR_ENOTIMPL; } diff --git a/libs/apr/shmem/win32/shm.c b/libs/apr/shmem/win32/shm.c index 36af743964..15578f553e 100644 --- a/libs/apr/shmem/win32/shm.c +++ b/libs/apr/shmem/win32/shm.c @@ -14,54 +14,54 @@ * limitations under the License. */ -#include "apr_general.h" -#include "apr_errno.h" -#include "apr_file_io.h" -#include "apr_shm.h" -#include "apr_arch_file_io.h" +#include "fspr_general.h" +#include "fspr_errno.h" +#include "fspr_file_io.h" +#include "fspr_shm.h" +#include "fspr_arch_file_io.h" #include "limits.h" typedef struct memblock_t { - apr_size_t size; - apr_size_t length; + fspr_size_t size; + fspr_size_t length; } memblock_t; -struct apr_shm_t { - apr_pool_t *pool; +struct fspr_shm_t { + fspr_pool_t *pool; memblock_t *memblk; void *usrmem; - apr_size_t size; - apr_size_t length; + fspr_size_t size; + fspr_size_t length; HANDLE hMap; }; -static apr_status_t shm_cleanup(void* shm) +static fspr_status_t shm_cleanup(void* shm) { - apr_status_t rv = APR_SUCCESS; - apr_shm_t *m = shm; + fspr_status_t rv = APR_SUCCESS; + fspr_shm_t *m = shm; if (UnmapViewOfFile(m->memblk)) { - rv = apr_get_os_error(); + rv = fspr_get_os_error(); } if (CloseHandle(m->hMap)) { - return (rv != APR_SUCCESS) ? rv : apr_get_os_error(); + return (rv != APR_SUCCESS) ? rv : fspr_get_os_error(); } /* ### Do we want to make a point of unlinking m->file here? - * Need to add the fname to the apr_shm_t, in that case. + * Need to add the fname to the fspr_shm_t, in that case. */ return rv; } -APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, - apr_size_t reqsize, +APR_DECLARE(fspr_status_t) fspr_shm_create(fspr_shm_t **m, + fspr_size_t reqsize, const char *file, - apr_pool_t *pool) + fspr_pool_t *pool) { - static apr_size_t memblock = 0; + static fspr_size_t memblock = 0; HANDLE hMap, hFile; - apr_status_t rv; - apr_size_t size; - apr_file_t *f; + fspr_status_t rv; + fspr_size_t size; + fspr_file_t *f; void *base; void *mapkey; DWORD err, sizelo, sizehi; @@ -97,14 +97,14 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, * ever did. Ignore that error here, but fail later when * we discover we aren't the creator of the file map object. */ - rv = apr_file_open(&f, file, + rv = fspr_file_open(&f, file, APR_READ | APR_WRITE | APR_BINARY | APR_CREATE, APR_UREAD | APR_UWRITE, pool); if ((rv != APR_SUCCESS) - || ((rv = apr_os_file_get(&hFile, f)) != APR_SUCCESS)) { + || ((rv = fspr_os_file_get(&hFile, f)) != APR_SUCCESS)) { return rv; } - rv = apr_file_trunc(f, size); + rv = fspr_file_trunc(f, size); /* res_name_from_filename turns file into a pseudo-name * without slashes or backslashes, and prepends the \global @@ -127,10 +127,10 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, sizehi, sizelo, mapkey); } #endif - err = apr_get_os_error(); + err = fspr_get_os_error(); if (file) { - apr_file_close(f); + fspr_file_close(f); } if (hMap && err == ERROR_ALREADY_EXISTS) { @@ -145,10 +145,10 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, 0, 0, size); if (!base) { CloseHandle(hMap); - return apr_get_os_error(); + return fspr_get_os_error(); } - *m = (apr_shm_t *) apr_palloc(pool, sizeof(apr_shm_t)); + *m = (fspr_shm_t *) fspr_palloc(pool, sizeof(fspr_shm_t)); (*m)->pool = pool; (*m)->hMap = hMap; (*m)->memblk = base; @@ -160,27 +160,27 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, (*m)->memblk->length = (*m)->length; (*m)->memblk->size = (*m)->size; - apr_pool_cleanup_register((*m)->pool, *m, - shm_cleanup, apr_pool_cleanup_null); + fspr_pool_cleanup_register((*m)->pool, *m, + shm_cleanup, fspr_pool_cleanup_null); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_shm_destroy(apr_shm_t *m) +APR_DECLARE(fspr_status_t) fspr_shm_destroy(fspr_shm_t *m) { - apr_status_t rv = shm_cleanup(m); - apr_pool_cleanup_kill(m->pool, m, shm_cleanup); + fspr_status_t rv = shm_cleanup(m); + fspr_pool_cleanup_kill(m->pool, m, shm_cleanup); return rv; } -APR_DECLARE(apr_status_t) apr_shm_remove(const char *filename, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_shm_remove(const char *filename, + fspr_pool_t *pool) { return APR_ENOTIMPL; } -APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m, +APR_DECLARE(fspr_status_t) fspr_shm_attach(fspr_shm_t **m, const char *file, - apr_pool_t *pool) + fspr_pool_t *pool) { HANDLE hMap; void *mapkey; @@ -207,7 +207,7 @@ APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m, * opening the existing shmem and reading its size from the header */ hMap = CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, - PAGE_READWRITE, 0, sizeof(apr_shm_t), mapkey); + PAGE_READWRITE, 0, sizeof(fspr_shm_t), mapkey); #endif } #endif @@ -219,16 +219,16 @@ APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m, #endif if (!hMap) { - return apr_get_os_error(); + return fspr_get_os_error(); } base = MapViewOfFile(hMap, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0); if (!base) { CloseHandle(hMap); - return apr_get_os_error(); + return fspr_get_os_error(); } - *m = (apr_shm_t *) apr_palloc(pool, sizeof(apr_shm_t)); + *m = (fspr_shm_t *) fspr_palloc(pool, sizeof(fspr_shm_t)); (*m)->pool = pool; (*m)->memblk = base; /* Real (*m)->mem->size could be recovered with VirtualQuery */ @@ -241,59 +241,59 @@ APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m, hMap = CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, (*m)->size, mapkey); if (!hMap) { - return apr_get_os_error(); + return fspr_get_os_error(); } base = MapViewOfFile(hMap, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0); if (!base) { CloseHandle(hMap); - return apr_get_os_error(); + return fspr_get_os_error(); } #endif (*m)->hMap = hMap; (*m)->length = (*m)->memblk->length; (*m)->usrmem = (char*)base + sizeof(memblock_t); - apr_pool_cleanup_register((*m)->pool, *m, - shm_cleanup, apr_pool_cleanup_null); + fspr_pool_cleanup_register((*m)->pool, *m, + shm_cleanup, fspr_pool_cleanup_null); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_shm_detach(apr_shm_t *m) +APR_DECLARE(fspr_status_t) fspr_shm_detach(fspr_shm_t *m) { - apr_status_t rv = shm_cleanup(m); - apr_pool_cleanup_kill(m->pool, m, shm_cleanup); + fspr_status_t rv = shm_cleanup(m); + fspr_pool_cleanup_kill(m->pool, m, shm_cleanup); return rv; } -APR_DECLARE(void *) apr_shm_baseaddr_get(const apr_shm_t *m) +APR_DECLARE(void *) fspr_shm_baseaddr_get(const fspr_shm_t *m) { return m->usrmem; } -APR_DECLARE(apr_size_t) apr_shm_size_get(const apr_shm_t *m) +APR_DECLARE(fspr_size_t) fspr_shm_size_get(const fspr_shm_t *m) { return m->length; } APR_POOL_IMPLEMENT_ACCESSOR(shm) -APR_DECLARE(apr_status_t) apr_os_shm_get(apr_os_shm_t *osshm, - apr_shm_t *shm) +APR_DECLARE(fspr_status_t) fspr_os_shm_get(fspr_os_shm_t *osshm, + fspr_shm_t *shm) { *osshm = shm->hMap; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_os_shm_put(apr_shm_t **m, - apr_os_shm_t *osshm, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_os_shm_put(fspr_shm_t **m, + fspr_os_shm_t *osshm, + fspr_pool_t *pool) { void* base; base = MapViewOfFile(*osshm, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0); if (!base) { - return apr_get_os_error(); + return fspr_get_os_error(); } - *m = (apr_shm_t *) apr_palloc(pool, sizeof(apr_shm_t)); + *m = (fspr_shm_t *) fspr_palloc(pool, sizeof(fspr_shm_t)); (*m)->pool = pool; (*m)->hMap = *osshm; (*m)->memblk = base; @@ -302,8 +302,8 @@ APR_DECLARE(apr_status_t) apr_os_shm_put(apr_shm_t **m, (*m)->size = (*m)->memblk->size; (*m)->length = (*m)->memblk->length; - apr_pool_cleanup_register((*m)->pool, *m, - shm_cleanup, apr_pool_cleanup_null); + fspr_pool_cleanup_register((*m)->pool, *m, + shm_cleanup, fspr_pool_cleanup_null); return APR_SUCCESS; } diff --git a/libs/apr/strings/apr_cpystrn.c b/libs/apr/strings/fspr_cpystrn.c similarity index 89% rename from libs/apr/strings/apr_cpystrn.c rename to libs/apr/strings/fspr_cpystrn.c index 888b2e5db6..704ebca623 100644 --- a/libs/apr/strings/apr_cpystrn.c +++ b/libs/apr/strings/fspr_cpystrn.c @@ -14,10 +14,10 @@ * limitations under the License. */ -#include "apr.h" -#include "apr_strings.h" -#include "apr_private.h" -#include "apr_lib.h" +#include "fspr.h" +#include "fspr_strings.h" +#include "fspr_private.h" +#include "fspr_lib.h" #if APR_HAVE_SYS_TYPES_H #include @@ -39,10 +39,10 @@ * the destination string, we return a pointer to the * terminating '\0' to allow us to "check" for truncation * - * apr_cpystrn() follows the same call structure as strncpy(). + * fspr_cpystrn() follows the same call structure as strncpy(). */ -APR_DECLARE(char *) apr_cpystrn(char *dst, const char *src, apr_size_t dst_size) +APR_DECLARE(char *) fspr_cpystrn(char *dst, const char *src, fspr_size_t dst_size) { char *d, *end; @@ -70,7 +70,7 @@ APR_DECLARE(char *) apr_cpystrn(char *dst, const char *src, apr_size_t dst_size) * This function provides a way to parse a generic argument string * into a standard argv[] form of argument list. It respects the * usual "whitespace" and quoteing rules. In the future this could - * be expanded to include support for the apr_call_exec command line + * be expanded to include support for the fspr_call_exec command line * string processing (including converting '+' to ' ' and doing the * url processing. It does not currently support this function. * @@ -82,9 +82,9 @@ APR_DECLARE(char *) apr_cpystrn(char *dst, const char *src, apr_size_t dst_size) * pool and filled in with copies of the tokens * found during parsing of the arg_str. */ -APR_DECLARE(apr_status_t) apr_tokenize_to_argv(const char *arg_str, +APR_DECLARE(fspr_status_t) fspr_tokenize_to_argv(const char *arg_str, char ***argv_out, - apr_pool_t *token_context) + fspr_pool_t *token_context) { const char *cp; const char *ct; @@ -165,7 +165,7 @@ APR_DECLARE(apr_status_t) apr_tokenize_to_argv(const char *arg_str, numargs++; SKIP_WHITESPACE(ct); } - *argv_out = apr_palloc(token_context, numargs * sizeof(char*)); + *argv_out = fspr_palloc(token_context, numargs * sizeof(char*)); /* determine first argument */ for (argnum = 0; argnum < (numargs-1); argnum++) { @@ -174,8 +174,8 @@ APR_DECLARE(apr_status_t) apr_tokenize_to_argv(const char *arg_str, ct = cp; DETERMINE_NEXTSTRING(cp, isquoted); cp++; - (*argv_out)[argnum] = apr_palloc(token_context, cp - ct); - apr_cpystrn((*argv_out)[argnum], ct, cp - ct); + (*argv_out)[argnum] = fspr_palloc(token_context, cp - ct); + fspr_cpystrn((*argv_out)[argnum], ct, cp - ct); cleaned = dirty = (*argv_out)[argnum]; REMOVE_ESCAPE_CHARS(cleaned, dirty, escaped); } @@ -194,7 +194,7 @@ APR_DECLARE(apr_status_t) apr_tokenize_to_argv(const char *arg_str, * Corrected Win32 to accept "a/b\\stuff", "a:stuff" */ -APR_DECLARE(const char *) apr_filepath_name_get(const char *pathname) +APR_DECLARE(const char *) fspr_filepath_name_get(const char *pathname) { const char path_separator = '/'; const char *s = strrchr(pathname, path_separator); @@ -216,10 +216,10 @@ APR_DECLARE(const char *) apr_filepath_name_get(const char *pathname) * collapse in place (src == dest) is legal. * returns terminating null ptr to dest string. */ -APR_DECLARE(char *) apr_collapse_spaces(char *dest, const char *src) +APR_DECLARE(char *) fspr_collapse_spaces(char *dest, const char *src) { while (*src) { - if (!apr_isspace(*src)) + if (!fspr_isspace(*src)) *dest++ = *src; ++src; } @@ -247,7 +247,7 @@ int strcasecmp(const char *a, const char *b) const char *p = a; const char *q = b; for (p = a, q = b; *p && *q; p++, q++) { - int diff = apr_tolower(*p) - apr_tolower(*q); + int diff = fspr_tolower(*p) - fspr_tolower(*q); if (diff) return diff; } @@ -272,7 +272,7 @@ int strncasecmp(const char *a, const char *b, size_t n) return 0; /* Match up to n characters */ if (!(*p && *q)) return *p - *q; - diff = apr_tolower(*p) - apr_tolower(*q); + diff = fspr_tolower(*p) - fspr_tolower(*q); if (diff) return diff; } diff --git a/libs/apr/strings/apr_fnmatch.c b/libs/apr/strings/fspr_fnmatch.c similarity index 84% rename from libs/apr/strings/apr_fnmatch.c rename to libs/apr/strings/fspr_fnmatch.c index 7c41ea6585..d65570cf67 100644 --- a/libs/apr/strings/apr_fnmatch.c +++ b/libs/apr/strings/fspr_fnmatch.c @@ -43,13 +43,13 @@ static char sccsid[] = "@(#)fnmatch.c 8.2 (Berkeley) 4/16/94"; * Compares a filename or pathname to a pattern. */ #ifndef WIN32 -#include "apr_private.h" +#include "fspr_private.h" #endif -#include "apr_file_info.h" -#include "apr_fnmatch.h" -#include "apr_tables.h" -#include "apr_lib.h" -#include "apr_strings.h" +#include "fspr_file_info.h" +#include "fspr_fnmatch.h" +#include "fspr_tables.h" +#include "fspr_lib.h" +#include "fspr_strings.h" #include #if APR_HAVE_CTYPE_H # include @@ -59,7 +59,7 @@ static char sccsid[] = "@(#)fnmatch.c 8.2 (Berkeley) 4/16/94"; static const char *rangematch(const char *, int, int); -APR_DECLARE(apr_status_t) apr_fnmatch(const char *pattern, const char *string, int flags) +APR_DECLARE(fspr_status_t) fspr_fnmatch(const char *pattern, const char *string, int flags) { const char *stringstart; char c, test; @@ -113,7 +113,7 @@ APR_DECLARE(apr_status_t) apr_fnmatch(const char *pattern, const char *string, i /* General case, use recursion. */ while ((test = *string) != EOS) { - if (!apr_fnmatch(pattern, string, flags & ~APR_FNM_PERIOD)) { + if (!fspr_fnmatch(pattern, string, flags & ~APR_FNM_PERIOD)) { return (APR_SUCCESS); } if (test == '/' && flags & APR_FNM_PATHNAME) { @@ -149,7 +149,7 @@ APR_DECLARE(apr_status_t) apr_fnmatch(const char *pattern, const char *string, i /* FALLTHROUGH */ default: if (flags & APR_FNM_CASE_BLIND) { - if (apr_tolower(c) != apr_tolower(*string)) { + if (fspr_tolower(c) != fspr_tolower(*string)) { return (APR_FNM_NOMATCH); } } @@ -196,14 +196,14 @@ static const char *rangematch(const char *pattern, int test, int flags) } if ((c <= test && test <= c2) || ((flags & APR_FNM_CASE_BLIND) - && ((apr_tolower(c) <= apr_tolower(test)) - && (apr_tolower(test) <= apr_tolower(c2))))) { + && ((fspr_tolower(c) <= fspr_tolower(test)) + && (fspr_tolower(test) <= fspr_tolower(c2))))) { ok = 1; } } else if ((c == test) || ((flags & APR_FNM_CASE_BLIND) - && (apr_tolower(c) == apr_tolower(test)))) { + && (fspr_tolower(c) == fspr_tolower(test)))) { ok = 1; } } @@ -213,7 +213,7 @@ static const char *rangematch(const char *pattern, int test, int flags) /* This function is an Apache addition */ /* return non-zero if pattern has any glob chars in it */ -APR_DECLARE(int) apr_fnmatch_test(const char *pattern) +APR_DECLARE(int) fspr_fnmatch_test(const char *pattern) { int nesting; @@ -246,13 +246,13 @@ APR_DECLARE(int) apr_fnmatch_test(const char *pattern) } /* Find all files matching the specified pattern */ -APR_DECLARE(apr_status_t) apr_match_glob(const char *pattern, - apr_array_header_t **result, - apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_match_glob(const char *pattern, + fspr_array_header_t **result, + fspr_pool_t *p) { - apr_dir_t *dir; - apr_finfo_t finfo; - apr_status_t rv; + fspr_dir_t *dir; + fspr_finfo_t finfo; + fspr_status_t rv; char *path; /* XXX So, this is kind of bogus. Basically, I need to strip any leading @@ -261,7 +261,7 @@ APR_DECLARE(apr_status_t) apr_match_glob(const char *pattern, * return anything, then we look for '\'. This means that we could * screw up on unix if the pattern is something like "foo\.*" That '\' * isn't a directory delimiter, it is a part of the filename. To fix this, - * we really need apr_filepath_basename, which will be coming as soon as + * we really need fspr_filepath_basename, which will be coming as soon as * I get to it. rbb */ char *idx = strrchr(pattern, '/'); @@ -273,21 +273,21 @@ APR_DECLARE(apr_status_t) apr_match_glob(const char *pattern, path = "."; } else { - path = apr_pstrndup(p, pattern, idx - pattern); + path = fspr_pstrndup(p, pattern, idx - pattern); pattern = idx + 1; } - *result = apr_array_make(p, 0, sizeof(char *)); - rv = apr_dir_open(&dir, path, p); + *result = fspr_array_make(p, 0, sizeof(char *)); + rv = fspr_dir_open(&dir, path, p); if (rv != APR_SUCCESS) { return rv; } - while (apr_dir_read(&finfo, APR_FINFO_NAME, dir) == APR_SUCCESS) { - if (apr_fnmatch(pattern, finfo.name, 0) == APR_SUCCESS) { - *(const char **)apr_array_push(*result) = apr_pstrdup(p, finfo.name); + while (fspr_dir_read(&finfo, APR_FINFO_NAME, dir) == APR_SUCCESS) { + if (fspr_fnmatch(pattern, finfo.name, 0) == APR_SUCCESS) { + *(const char **)fspr_array_push(*result) = fspr_pstrdup(p, finfo.name); } } - apr_dir_close(dir); + fspr_dir_close(dir); return APR_SUCCESS; } diff --git a/libs/apr/strings/apr_snprintf.c b/libs/apr/strings/fspr_snprintf.c similarity index 90% rename from libs/apr/strings/apr_snprintf.c rename to libs/apr/strings/fspr_snprintf.c index 611f2d7972..cc7d2faf67 100644 --- a/libs/apr/strings/apr_snprintf.c +++ b/libs/apr/strings/fspr_snprintf.c @@ -14,13 +14,13 @@ * limitations under the License. */ -#include "apr.h" -#include "apr_private.h" +#include "fspr.h" +#include "fspr_private.h" -#include "apr_lib.h" -#include "apr_strings.h" -#include "apr_network_io.h" -#include "apr_portable.h" +#include "fspr_lib.h" +#include "fspr_strings.h" +#include "fspr_network_io.h" +#include "fspr_portable.h" #include #if APR_HAVE_CTYPE_H #include @@ -56,12 +56,12 @@ typedef enum { typedef WIDE_INT wide_int; typedef unsigned WIDE_INT u_wide_int; -typedef apr_int64_t widest_int; +typedef fspr_int64_t widest_int; #ifdef __TANDEM /* Although Tandem supports "long long" there is no unsigned variant. */ typedef unsigned long u_widest_int; #else -typedef apr_uint64_t u_widest_int; +typedef fspr_uint64_t u_widest_int; #endif typedef int bool_int; @@ -84,7 +84,7 @@ typedef int bool_int; */ /* - * apr_ecvt converts to decimal + * fspr_ecvt converts to decimal * the number of digits is specified by ndigit * decpt is set to the position of the decimal point * sign is set to 0 for positive, 1 for negative @@ -93,7 +93,7 @@ typedef int bool_int; #define NDIG 80 /* buf must have at least NDIG bytes */ -static char *apr_cvt(double arg, int ndigits, int *decpt, int *sign, +static char *fspr_cvt(double arg, int ndigits, int *decpt, int *sign, int eflag, char *buf) { register int r2; @@ -167,29 +167,29 @@ static char *apr_cvt(double arg, int ndigits, int *decpt, int *sign, return (buf); } -static char *apr_ecvt(double arg, int ndigits, int *decpt, int *sign, char *buf) +static char *fspr_ecvt(double arg, int ndigits, int *decpt, int *sign, char *buf) { - return (apr_cvt(arg, ndigits, decpt, sign, 1, buf)); + return (fspr_cvt(arg, ndigits, decpt, sign, 1, buf)); } -static char *apr_fcvt(double arg, int ndigits, int *decpt, int *sign, char *buf) +static char *fspr_fcvt(double arg, int ndigits, int *decpt, int *sign, char *buf) { - return (apr_cvt(arg, ndigits, decpt, sign, 0, buf)); + return (fspr_cvt(arg, ndigits, decpt, sign, 0, buf)); } /* - * apr_gcvt - Floating output conversion to + * fspr_gcvt - Floating output conversion to * minimal length string */ -static char *apr_gcvt(double number, int ndigit, char *buf, boolean_e altform) +static char *fspr_gcvt(double number, int ndigit, char *buf, boolean_e altform) { int sign, decpt; register char *p1, *p2; register int i; char buf1[NDIG]; - p1 = apr_ecvt(number, ndigit, &decpt, &sign, buf1); + p1 = fspr_ecvt(number, ndigit, &decpt, &sign, buf1); p2 = buf; if (sign) *p2++ = '-'; @@ -270,7 +270,7 @@ static char *apr_gcvt(double number, int ndigit, char *buf, boolean_e altform) #define STR_TO_DEC(str, num) \ num = NUM(*str++); \ - while (apr_isdigit(*str)) \ + while (fspr_isdigit(*str)) \ { \ num *= 10 ; \ num += NUM(*str++); \ @@ -288,7 +288,7 @@ static char *apr_gcvt(double number, int ndigit, char *buf, boolean_e altform) */ #define FIX_PRECISION(adjust, precision, s, s_len) \ if (adjust) { \ - apr_size_t p = (precision + 1 < NUM_BUF_SIZE) \ + fspr_size_t p = (precision + 1 < NUM_BUF_SIZE) \ ? precision : NUM_BUF_SIZE - 1; \ while (s_len < p) \ { \ @@ -338,7 +338,7 @@ while (width > len) */ static char *conv_10(register wide_int num, register bool_int is_unsigned, register bool_int *is_negative, char *buf_end, - register apr_size_t *len) + register fspr_size_t *len) { register char *p = buf_end; register u_wide_int magnitude; @@ -385,7 +385,7 @@ static char *conv_10(register wide_int num, register bool_int is_unsigned, static char *conv_10_quad(widest_int num, register bool_int is_unsigned, register bool_int *is_negative, char *buf_end, - register apr_size_t *len) + register fspr_size_t *len) { register char *p = buf_end; u_widest_int magnitude; @@ -442,12 +442,12 @@ static char *conv_10_quad(widest_int num, register bool_int is_unsigned, -static char *conv_in_addr(struct in_addr *ia, char *buf_end, apr_size_t *len) +static char *conv_in_addr(struct in_addr *ia, char *buf_end, fspr_size_t *len) { unsigned addr = ntohl(ia->s_addr); char *p = buf_end; bool_int is_negative; - apr_size_t sub_len; + fspr_size_t sub_len; p = conv_10((addr & 0x000000FF) , TRUE, &is_negative, p, &sub_len); *--p = '.'; @@ -463,16 +463,16 @@ static char *conv_in_addr(struct in_addr *ia, char *buf_end, apr_size_t *len) -static char *conv_apr_sockaddr(apr_sockaddr_t *sa, char *buf_end, apr_size_t *len) +static char *conv_fspr_sockaddr(fspr_sockaddr_t *sa, char *buf_end, fspr_size_t *len) { char *p = buf_end; bool_int is_negative; - apr_size_t sub_len; + fspr_size_t sub_len; char *ipaddr_str; p = conv_10(sa->port, TRUE, &is_negative, p, &sub_len); *--p = ':'; - apr_sockaddr_ip_get(&ipaddr_str, sa); + fspr_sockaddr_ip_get(&ipaddr_str, sa); sub_len = strlen(ipaddr_str); #if APR_HAVE_IPV6 if (sa->family == APR_INET6 && @@ -496,20 +496,20 @@ static char *conv_apr_sockaddr(apr_sockaddr_t *sa, char *buf_end, apr_size_t *le #if APR_HAS_THREADS -static char *conv_os_thread_t(apr_os_thread_t *tid, char *buf_end, apr_size_t *len) +static char *conv_os_thread_t(fspr_os_thread_t *tid, char *buf_end, fspr_size_t *len) { union { - apr_os_thread_t tid; - apr_uint64_t alignme; + fspr_os_thread_t tid; + fspr_uint64_t alignme; } u; int is_negative; u.tid = *tid; switch(sizeof(u.tid)) { - case sizeof(apr_int32_t): - return conv_10(*(apr_uint32_t *)&u.tid, TRUE, &is_negative, buf_end, len); - case sizeof(apr_int64_t): - return conv_10_quad(*(apr_uint64_t *)&u.tid, TRUE, &is_negative, buf_end, len); + case sizeof(fspr_int32_t): + return conv_10(*(fspr_uint32_t *)&u.tid, TRUE, &is_negative, buf_end, len); + case sizeof(fspr_int64_t): + return conv_10_quad(*(fspr_uint64_t *)&u.tid, TRUE, &is_negative, buf_end, len); default: /* not implemented; stick 0 in the buffer */ return conv_10(0, TRUE, &is_negative, buf_end, len); @@ -527,7 +527,7 @@ static char *conv_os_thread_t(apr_os_thread_t *tid, char *buf_end, apr_size_t *l */ static char *conv_fp(register char format, register double num, boolean_e add_dp, int precision, bool_int *is_negative, - char *buf, apr_size_t *len) + char *buf, fspr_size_t *len) { register char *s = buf; register char *p; @@ -535,14 +535,14 @@ static char *conv_fp(register char format, register double num, char buf1[NDIG]; if (format == 'f') - p = apr_fcvt(num, precision, &decimal_point, is_negative, buf1); + p = fspr_fcvt(num, precision, &decimal_point, is_negative, buf1); else /* either e or E format */ - p = apr_ecvt(num, precision + 1, &decimal_point, is_negative, buf1); + p = fspr_ecvt(num, precision + 1, &decimal_point, is_negative, buf1); /* * Check for Infinity and NaN */ - if (apr_isalpha(*p)) { + if (fspr_isalpha(*p)) { *len = strlen(p); memcpy(buf, p, *len + 1); *is_negative = FALSE; @@ -581,7 +581,7 @@ static char *conv_fp(register char format, register double num, if (format != 'f') { char temp[EXPONENT_LENGTH]; /* for exponent conversion */ - apr_size_t t_len; + fspr_size_t t_len; bool_int exponent_is_negative; *s++ = format; /* either e or E */ @@ -625,7 +625,7 @@ static char *conv_fp(register char format, register double num, * the number isn't quad size. */ static char *conv_p2(register u_wide_int num, register int nbits, - char format, char *buf_end, register apr_size_t *len) + char format, char *buf_end, register fspr_size_t *len) { register int mask = (1 << nbits) - 1; register char *p = buf_end; @@ -644,7 +644,7 @@ static char *conv_p2(register u_wide_int num, register int nbits, } static char *conv_p2_quad(u_widest_int num, register int nbits, - char format, char *buf_end, register apr_size_t *len) + char format, char *buf_end, register fspr_size_t *len) { register int mask = (1 << nbits) - 1; register char *p = buf_end; @@ -666,20 +666,20 @@ static char *conv_p2_quad(u_widest_int num, register int nbits, } #if APR_HAS_THREADS -static char *conv_os_thread_t_hex(apr_os_thread_t *tid, char *buf_end, apr_size_t *len) +static char *conv_os_thread_t_hex(fspr_os_thread_t *tid, char *buf_end, fspr_size_t *len) { union { - apr_os_thread_t tid; - apr_uint64_t alignme; + fspr_os_thread_t tid; + fspr_uint64_t alignme; } u; int is_negative; u.tid = *tid; switch(sizeof(u.tid)) { - case sizeof(apr_int32_t): - return conv_p2(*(apr_uint32_t *)&u.tid, 4, 'x', buf_end, len); - case sizeof(apr_int64_t): - return conv_p2_quad(*(apr_uint64_t *)&u.tid, 4, 'x', buf_end, len); + case sizeof(fspr_int32_t): + return conv_p2(*(fspr_uint32_t *)&u.tid, 4, 'x', buf_end, len); + case sizeof(fspr_int64_t): + return conv_p2_quad(*(fspr_uint64_t *)&u.tid, 4, 'x', buf_end, len); default: /* not implemented; stick 0 in the buffer */ return conv_10(0, TRUE, &is_negative, buf_end, len); @@ -690,20 +690,20 @@ static char *conv_os_thread_t_hex(apr_os_thread_t *tid, char *buf_end, apr_size_ /* * Do format conversion placing the output in buffer */ -APR_DECLARE(int) apr_vformatter(int (*flush_func)(apr_vformatter_buff_t *), - apr_vformatter_buff_t *vbuff, const char *fmt, va_list ap) +APR_DECLARE(int) fspr_vformatter(int (*flush_func)(fspr_vformatter_buff_t *), + fspr_vformatter_buff_t *vbuff, const char *fmt, va_list ap) { register char *sp; register char *bep; register int cc = 0; - register apr_size_t i; + register fspr_size_t i; register char *s = NULL; char *q; - apr_size_t s_len; + fspr_size_t s_len; - register apr_size_t min_width = 0; - apr_size_t precision = 0; + register fspr_size_t min_width = 0; + fspr_size_t precision = 0; enum { LEFT, RIGHT } adjust; @@ -756,7 +756,7 @@ APR_DECLARE(int) apr_vformatter(int (*flush_func)(apr_vformatter_buff_t *), /* * Try to avoid checking for flags, width or precision */ - if (!apr_islower(*fmt)) { + if (!fspr_islower(*fmt)) { /* * Recognize flags: -, #, BLANK, + */ @@ -778,7 +778,7 @@ APR_DECLARE(int) apr_vformatter(int (*flush_func)(apr_vformatter_buff_t *), /* * Check if a width was specified */ - if (apr_isdigit(*fmt)) { + if (fspr_isdigit(*fmt)) { STR_TO_DEC(fmt, min_width); adjust_width = YES; } @@ -788,10 +788,10 @@ APR_DECLARE(int) apr_vformatter(int (*flush_func)(apr_vformatter_buff_t *), adjust_width = YES; if (v < 0) { adjust = LEFT; - min_width = (apr_size_t)(-v); + min_width = (fspr_size_t)(-v); } else - min_width = (apr_size_t)v; + min_width = (fspr_size_t)v; } else adjust_width = NO; @@ -802,13 +802,13 @@ APR_DECLARE(int) apr_vformatter(int (*flush_func)(apr_vformatter_buff_t *), if (*fmt == '.') { adjust_precision = YES; fmt++; - if (apr_isdigit(*fmt)) { + if (fspr_isdigit(*fmt)) { STR_TO_DEC(fmt, precision); } else if (*fmt == '*') { int v = va_arg(ap, int); fmt++; - precision = (v < 0) ? 0 : (apr_size_t)v; + precision = (v < 0) ? 0 : (fspr_size_t)v; } else precision = 0; @@ -1058,7 +1058,7 @@ APR_DECLARE(int) apr_vformatter(int (*flush_func)(apr_vformatter_buff_t *), /* * * We use &num_buf[ 1 ], so that we have room for the sign */ - s = apr_gcvt(va_arg(ap, double), precision, &num_buf[1], + s = fspr_gcvt(va_arg(ap, double), precision, &num_buf[1], alternate_form); if (*s == '-') prefix_char = *s++; @@ -1069,7 +1069,7 @@ APR_DECLARE(int) apr_vformatter(int (*flush_func)(apr_vformatter_buff_t *), s_len = strlen(s); - if (alternate_form && (q = strchr(s, '.')) == NULL) { + if (alternate_form && strchr(s, '.') == NULL) { s[s_len++] = '.'; s[s_len] = '\0'; /* delimit for following strchr() */ } @@ -1140,14 +1140,14 @@ APR_DECLARE(int) apr_vformatter(int (*flush_func)(apr_vformatter_buff_t *), pad_char = ' '; break; - /* print an apr_sockaddr_t as a.b.c.d:port */ + /* print an fspr_sockaddr_t as a.b.c.d:port */ case 'I': { - apr_sockaddr_t *sa; + fspr_sockaddr_t *sa; - sa = va_arg(ap, apr_sockaddr_t *); + sa = va_arg(ap, fspr_sockaddr_t *); if (sa != NULL) { - s = conv_apr_sockaddr(sa, &num_buf[NUM_BUF_SIZE], &s_len); + s = conv_fspr_sockaddr(sa, &num_buf[NUM_BUF_SIZE], &s_len); if (adjust_precision && precision < s_len) s_len = precision; } @@ -1181,9 +1181,9 @@ APR_DECLARE(int) apr_vformatter(int (*flush_func)(apr_vformatter_buff_t *), case 'T': #if APR_HAS_THREADS { - apr_os_thread_t *tid; + fspr_os_thread_t *tid; - tid = va_arg(ap, apr_os_thread_t *); + tid = va_arg(ap, fspr_os_thread_t *); if (tid != NULL) { s = conv_os_thread_t(tid, &num_buf[NUM_BUF_SIZE], &s_len); if (adjust_precision && precision < s_len) @@ -1206,9 +1206,9 @@ APR_DECLARE(int) apr_vformatter(int (*flush_func)(apr_vformatter_buff_t *), case 't': #if APR_HAS_THREADS { - apr_os_thread_t *tid; + fspr_os_thread_t *tid; - tid = va_arg(ap, apr_os_thread_t *); + tid = va_arg(ap, fspr_os_thread_t *); if (tid != NULL) { s = conv_os_thread_t_hex(tid, &num_buf[NUM_BUF_SIZE], &s_len); if (adjust_precision && precision < s_len) @@ -1304,21 +1304,21 @@ APR_DECLARE(int) apr_vformatter(int (*flush_func)(apr_vformatter_buff_t *), } -static int snprintf_flush(apr_vformatter_buff_t *vbuff) +static int snprintf_flush(fspr_vformatter_buff_t *vbuff) { /* if the buffer fills we have to abort immediately, there is no way - * to "flush" an apr_snprintf... there's nowhere to flush it to. + * to "flush" an fspr_snprintf... there's nowhere to flush it to. */ return -1; } -APR_DECLARE_NONSTD(int) apr_snprintf(char *buf, apr_size_t len, +APR_DECLARE_NONSTD(int) fspr_snprintf(char *buf, fspr_size_t len, const char *format, ...) { int cc; va_list ap; - apr_vformatter_buff_t vbuff; + fspr_vformatter_buff_t vbuff; if (len == 0) { /* NOTE: This is a special case; we just want to return the number @@ -1336,7 +1336,7 @@ APR_DECLARE_NONSTD(int) apr_snprintf(char *buf, apr_size_t len, vbuff.endpos = buf + len - 1; } va_start(ap, format); - cc = apr_vformatter(snprintf_flush, &vbuff, format, ap); + cc = fspr_vformatter(snprintf_flush, &vbuff, format, ap); va_end(ap); if (len != 0) { *vbuff.curpos = '\0'; @@ -1345,11 +1345,11 @@ APR_DECLARE_NONSTD(int) apr_snprintf(char *buf, apr_size_t len, } -APR_DECLARE(int) apr_vsnprintf(char *buf, apr_size_t len, const char *format, +APR_DECLARE(int) fspr_vsnprintf(char *buf, fspr_size_t len, const char *format, va_list ap) { int cc; - apr_vformatter_buff_t vbuff; + fspr_vformatter_buff_t vbuff; if (len == 0) { /* See above note */ @@ -1360,7 +1360,7 @@ APR_DECLARE(int) apr_vsnprintf(char *buf, apr_size_t len, const char *format, vbuff.curpos = buf; vbuff.endpos = buf + len - 1; } - cc = apr_vformatter(snprintf_flush, &vbuff, format, ap); + cc = fspr_vformatter(snprintf_flush, &vbuff, format, ap); if (len != 0) { *vbuff.curpos = '\0'; } diff --git a/libs/apr/strings/apr_strings.c b/libs/apr/strings/fspr_strings.c similarity index 82% rename from libs/apr/strings/apr_strings.c rename to libs/apr/strings/fspr_strings.c index 771d351f19..48dd08b953 100644 --- a/libs/apr/strings/apr_strings.c +++ b/libs/apr/strings/fspr_strings.c @@ -46,14 +46,14 @@ * SUCH DAMAGE. */ -#include "apr.h" -#include "apr_strings.h" -#include "apr_general.h" -#include "apr_private.h" -#include "apr_lib.h" +#include "fspr.h" +#include "fspr_strings.h" +#include "fspr_general.h" +#include "fspr_private.h" +#include "fspr_lib.h" #define APR_WANT_STDIO #define APR_WANT_STRFUNC -#include "apr_want.h" +#include "fspr_want.h" #ifdef HAVE_STDDEF_H #include /* NULL */ @@ -63,24 +63,24 @@ #include /* strtol and strtoll */ #endif -/** this is used to cache lengths in apr_pstrcat */ +/** this is used to cache lengths in fspr_pstrcat */ #define MAX_SAVED_LENGTHS 6 -APR_DECLARE(char *) apr_pstrdup(apr_pool_t *a, const char *s) +APR_DECLARE(char *) fspr_pstrdup(fspr_pool_t *a, const char *s) { char *res; - apr_size_t len; + fspr_size_t len; if (s == NULL) { return NULL; } len = strlen(s) + 1; - res = apr_palloc(a, len); + res = fspr_palloc(a, len); memcpy(res, s, len); return res; } -APR_DECLARE(char *) apr_pstrndup(apr_pool_t *a, const char *s, apr_size_t n) +APR_DECLARE(char *) fspr_pstrndup(fspr_pool_t *a, const char *s, fspr_size_t n) { char *res; const char *end; @@ -91,51 +91,51 @@ APR_DECLARE(char *) apr_pstrndup(apr_pool_t *a, const char *s, apr_size_t n) end = memchr(s, '\0', n); if (end != NULL) n = end - s; - res = apr_palloc(a, n + 1); + res = fspr_palloc(a, n + 1); memcpy(res, s, n); res[n] = '\0'; return res; } -APR_DECLARE(char *) apr_pstrmemdup(apr_pool_t *a, const char *s, apr_size_t n) +APR_DECLARE(char *) fspr_pstrmemdup(fspr_pool_t *a, const char *s, fspr_size_t n) { char *res; if (s == NULL) { return NULL; } - res = apr_palloc(a, n + 1); + res = fspr_palloc(a, n + 1); memcpy(res, s, n); res[n] = '\0'; return res; } -APR_DECLARE(void *) apr_pmemdup(apr_pool_t *a, const void *m, apr_size_t n) +APR_DECLARE(void *) fspr_pmemdup(fspr_pool_t *a, const void *m, fspr_size_t n) { void *res; if (m == NULL) return NULL; - res = apr_palloc(a, n); + res = fspr_palloc(a, n); memcpy(res, m, n); return res; } -APR_DECLARE_NONSTD(char *) apr_pstrcat(apr_pool_t *a, ...) +APR_DECLARE_NONSTD(char *) fspr_pstrcat(fspr_pool_t *a, ...) { char *cp, *argp, *res; - apr_size_t saved_lengths[MAX_SAVED_LENGTHS] = { 0 }; + fspr_size_t saved_lengths[MAX_SAVED_LENGTHS] = { 0 }; int nargs = 0; /* Pass one --- find length of required string */ - apr_size_t len = 0; + fspr_size_t len = 0; va_list adummy; va_start(adummy, a); while ((cp = va_arg(adummy, char *)) != NULL) { - apr_size_t cplen = strlen(cp); + fspr_size_t cplen = strlen(cp); if (nargs < MAX_SAVED_LENGTHS) { saved_lengths[nargs++] = cplen; } @@ -146,7 +146,7 @@ APR_DECLARE_NONSTD(char *) apr_pstrcat(apr_pool_t *a, ...) /* Allocate the required string */ - res = (char *) apr_palloc(a, len + 1); + res = (char *) fspr_palloc(a, len + 1); cp = res; /* Pass two --- copy the argument strings into the result space */ @@ -175,11 +175,11 @@ APR_DECLARE_NONSTD(char *) apr_pstrcat(apr_pool_t *a, ...) return res; } -APR_DECLARE(char *) apr_pstrcatv(apr_pool_t *a, const struct iovec *vec, - apr_size_t nvec, apr_size_t *nbytes) +APR_DECLARE(char *) fspr_pstrcatv(fspr_pool_t *a, const struct iovec *vec, + fspr_size_t nvec, fspr_size_t *nbytes) { - apr_size_t i; - apr_size_t len; + fspr_size_t i; + fspr_size_t len; const struct iovec *src; char *res; char *dst; @@ -196,7 +196,7 @@ APR_DECLARE(char *) apr_pstrcatv(apr_pool_t *a, const struct iovec *vec, } /* Allocate the required string */ - res = (char *) apr_palloc(a, len + 1); + res = (char *) fspr_palloc(a, len + 1); /* Pass two --- copy the argument strings into the result space */ src = vec; @@ -234,7 +234,7 @@ void *memchr(const void *s, int c, size_t n) #define INT64_MIN (-APR_INT64_C(0x7fffffffffffffff) - APR_INT64_C(1)) #endif -APR_DECLARE(apr_status_t) apr_strtoff(apr_off_t *offset, const char *nptr, +APR_DECLARE(fspr_status_t) fspr_strtoff(fspr_off_t *offset, const char *nptr, char **endptr, int base) { errno = 0; @@ -242,14 +242,14 @@ APR_DECLARE(apr_status_t) apr_strtoff(apr_off_t *offset, const char *nptr, return APR_FROM_OS_ERROR(errno); } -APR_DECLARE(apr_int64_t) apr_strtoi64(const char *nptr, char **endptr, int base) +APR_DECLARE(fspr_int64_t) fspr_strtoi64(const char *nptr, char **endptr, int base) { #ifdef APR_INT64_STRFN return APR_INT64_STRFN(nptr, endptr, base); #else const char *s; - apr_int64_t acc; - apr_int64_t val; + fspr_int64_t acc; + fspr_int64_t val; int neg, any; char c; @@ -261,7 +261,7 @@ APR_DECLARE(apr_int64_t) apr_strtoi64(const char *nptr, char **endptr, int base) s = nptr; do { c = *s++; - } while (apr_isspace(c)); + } while (fspr_isspace(c)); if (c == '-') { neg = 1; c = *s++; @@ -319,7 +319,7 @@ APR_DECLARE(apr_int64_t) apr_strtoi64(const char *nptr, char **endptr, int base) else if (c >= 's' && c <= 'z') c -= 'z' - 28; #else -#error "CANNOT COMPILE apr_strtoi64(), only ASCII and EBCDIC supported" +#error "CANNOT COMPILE fspr_strtoi64(), only ASCII and EBCDIC supported" #endif else break; @@ -351,15 +351,15 @@ APR_DECLARE(apr_int64_t) apr_strtoi64(const char *nptr, char **endptr, int base) #endif } -APR_DECLARE(apr_int64_t) apr_atoi64(const char *buf) +APR_DECLARE(fspr_int64_t) fspr_atoi64(const char *buf) { - return apr_strtoi64(buf, NULL, 10); + return fspr_strtoi64(buf, NULL, 10); } -APR_DECLARE(char *) apr_itoa(apr_pool_t *p, int n) +APR_DECLARE(char *) fspr_itoa(fspr_pool_t *p, int n) { const int BUFFER_SIZE = sizeof(int) * 3 + 2; - char *buf = apr_palloc(p, BUFFER_SIZE); + char *buf = fspr_palloc(p, BUFFER_SIZE); char *start = buf + BUFFER_SIZE - 1; int negative; if (n < 0) { @@ -380,10 +380,10 @@ APR_DECLARE(char *) apr_itoa(apr_pool_t *p, int n) return start; } -APR_DECLARE(char *) apr_ltoa(apr_pool_t *p, long n) +APR_DECLARE(char *) fspr_ltoa(fspr_pool_t *p, long n) { const int BUFFER_SIZE = sizeof(long) * 3 + 2; - char *buf = apr_palloc(p, BUFFER_SIZE); + char *buf = fspr_palloc(p, BUFFER_SIZE); char *start = buf + BUFFER_SIZE - 1; int negative; if (n < 0) { @@ -404,10 +404,10 @@ APR_DECLARE(char *) apr_ltoa(apr_pool_t *p, long n) return start; } -APR_DECLARE(char *) apr_off_t_toa(apr_pool_t *p, apr_off_t n) +APR_DECLARE(char *) fspr_off_t_toa(fspr_pool_t *p, fspr_off_t n) { - const int BUFFER_SIZE = sizeof(apr_off_t) * 3 + 2; - char *buf = apr_palloc(p, BUFFER_SIZE); + const int BUFFER_SIZE = sizeof(fspr_off_t) * 3 + 2; + char *buf = fspr_palloc(p, BUFFER_SIZE); char *start = buf + BUFFER_SIZE - 1; int negative; if (n < 0) { @@ -428,7 +428,7 @@ APR_DECLARE(char *) apr_off_t_toa(apr_pool_t *p, apr_off_t n) return start; } -APR_DECLARE(char *) apr_strfsize(apr_off_t size, char *buf) +APR_DECLARE(char *) fspr_strfsize(fspr_off_t size, char *buf) { const char ord[] = "KMGTPE"; const char *o = ord; @@ -438,7 +438,7 @@ APR_DECLARE(char *) apr_strfsize(apr_off_t size, char *buf) return strcpy(buf, " - "); } if (size < 973) { - if (apr_snprintf(buf, 5, "%3d ", (int) size) < 0) + if (fspr_snprintf(buf, 5, "%3d ", (int) size) < 0) return strcpy(buf, "****"); return buf; } @@ -452,13 +452,13 @@ APR_DECLARE(char *) apr_strfsize(apr_off_t size, char *buf) if (size < 9 || (size == 9 && remain < 973)) { if ((remain = ((remain * 5) + 256) / 512) >= 10) ++size, remain = 0; - if (apr_snprintf(buf, 5, "%d.%d%c", (int) size, remain, *o) < 0) + if (fspr_snprintf(buf, 5, "%d.%d%c", (int) size, remain, *o) < 0) return strcpy(buf, "****"); return buf; } if (remain >= 512) ++size; - if (apr_snprintf(buf, 5, "%3d%c", (int) size, *o) < 0) + if (fspr_snprintf(buf, 5, "%3d%c", (int) size, *o) < 0) return strcpy(buf, "****"); return buf; } while (1); diff --git a/libs/apr/strings/apr_strnatcmp.c b/libs/apr/strings/fspr_strnatcmp.c similarity index 84% rename from libs/apr/strings/apr_strnatcmp.c rename to libs/apr/strings/fspr_strnatcmp.c index 0e960e8a90..f80b8e4aec 100644 --- a/libs/apr/strings/apr_strnatcmp.c +++ b/libs/apr/strings/fspr_strnatcmp.c @@ -22,8 +22,8 @@ #include #include -#include "apr_strings.h" -#include "apr_lib.h" /* for apr_is*() */ +#include "fspr_strings.h" +#include "fspr_lib.h" /* for fspr_is*() */ #if defined(__GNUC__) # define UNUSED __attribute__((__unused__)) @@ -43,11 +43,11 @@ compare_right(char const *a, char const *b) both numbers to know that they have the same magnitude, so we remember it in BIAS. */ for (;; a++, b++) { - if (!apr_isdigit(*a) && !apr_isdigit(*b)) + if (!fspr_isdigit(*a) && !fspr_isdigit(*b)) break; - else if (!apr_isdigit(*a)) + else if (!fspr_isdigit(*a)) return -1; - else if (!apr_isdigit(*b)) + else if (!fspr_isdigit(*b)) return +1; else if (*a < *b) { if (!bias) @@ -69,11 +69,11 @@ compare_left(char const *a, char const *b) /* Compare two left-aligned numbers: the first to have a different value wins. */ for (;; a++, b++) { - if (!apr_isdigit(*a) && !apr_isdigit(*b)) + if (!fspr_isdigit(*a) && !fspr_isdigit(*b)) break; - else if (!apr_isdigit(*a)) + else if (!fspr_isdigit(*a)) return -1; - else if (!apr_isdigit(*b)) + else if (!fspr_isdigit(*b)) return +1; else if (*a < *b) return -1; @@ -95,14 +95,14 @@ static int strnatcmp0(char const *a, char const *b, int fold_case) ca = a[ai]; cb = b[bi]; /* skip over leading spaces or zeros */ - while (apr_isspace(ca)) + while (fspr_isspace(ca)) ca = a[++ai]; - while (apr_isspace(cb)) + while (fspr_isspace(cb)) cb = b[++bi]; /* process run of digits */ - if (apr_isdigit(ca) && apr_isdigit(cb)) { + if (fspr_isdigit(ca) && fspr_isdigit(cb)) { fractional = (ca == '0' || cb == '0'); if (fractional) { @@ -121,8 +121,8 @@ static int strnatcmp0(char const *a, char const *b, int fold_case) } if (fold_case) { - ca = apr_toupper(ca); - cb = apr_toupper(cb); + ca = fspr_toupper(ca); + cb = fspr_toupper(cb); } if (ca < cb) @@ -136,14 +136,14 @@ static int strnatcmp0(char const *a, char const *b, int fold_case) -APR_DECLARE(int) apr_strnatcmp(char const *a, char const *b) +APR_DECLARE(int) fspr_strnatcmp(char const *a, char const *b) { return strnatcmp0(a, b, 0); } /* Compare, recognizing numeric string and ignoring case. */ -APR_DECLARE(int) apr_strnatcasecmp(char const *a, char const *b) +APR_DECLARE(int) fspr_strnatcasecmp(char const *a, char const *b) { return strnatcmp0(a, b, 1); } diff --git a/libs/apr/strings/apr_strtok.c b/libs/apr/strings/fspr_strtok.c similarity index 91% rename from libs/apr/strings/apr_strtok.c rename to libs/apr/strings/fspr_strtok.c index 517b319d47..eb7d5687bc 100644 --- a/libs/apr/strings/apr_strtok.c +++ b/libs/apr/strings/fspr_strtok.c @@ -18,13 +18,13 @@ #include /* for NULL */ #endif -#include "apr.h" -#include "apr_strings.h" +#include "fspr.h" +#include "fspr_strings.h" #define APR_WANT_STRFUNC /* for strchr() */ -#include "apr_want.h" +#include "fspr_want.h" -APR_DECLARE(char *) apr_strtok(char *str, const char *sep, char **last) +APR_DECLARE(char *) fspr_strtok(char *str, const char *sep, char **last) { char *token; diff --git a/libs/apr/support/unix/waitio.c b/libs/apr/support/unix/waitio.c index 7232cdd9ce..70594824aa 100644 --- a/libs/apr/support/unix/waitio.c +++ b/libs/apr/support/unix/waitio.c @@ -14,11 +14,11 @@ * limitations under the License. */ -#include "apr_arch_file_io.h" -#include "apr_arch_networkio.h" -#include "apr_poll.h" -#include "apr_errno.h" -#include "apr_support.h" +#include "fspr_arch_file_io.h" +#include "fspr_arch_networkio.h" +#include "fspr_poll.h" +#include "fspr_errno.h" +#include "fspr_support.h" /* The only case where we don't use wait_for_io_or_timeout is on * pre-BONE BeOS, so this check should be sufficient and simpler */ @@ -37,7 +37,7 @@ #include #endif -apr_status_t apr_wait_for_io_or_timeout(apr_file_t *f, apr_socket_t *s, +fspr_status_t fspr_wait_for_io_or_timeout(fspr_file_t *f, fspr_socket_t *s, int for_read) { struct pollfd pfd; @@ -63,14 +63,14 @@ apr_status_t apr_wait_for_io_or_timeout(apr_file_t *f, apr_socket_t *s, #else /* !WAITIO_USES_POLL */ -apr_status_t apr_wait_for_io_or_timeout(apr_file_t *f, apr_socket_t *s, +fspr_status_t fspr_wait_for_io_or_timeout(fspr_file_t *f, fspr_socket_t *s, int for_read) { - apr_interval_time_t timeout; - apr_pollfd_t pfd; + fspr_interval_time_t timeout; + fspr_pollfd_t pfd; int type = for_read ? APR_POLLIN : APR_POLLOUT; - apr_pollset_t *pollset; - apr_status_t status; + fspr_pollset_t *pollset; + fspr_status_t status; /* TODO - timeout should be less each time through this loop */ if (f) { @@ -79,7 +79,7 @@ apr_status_t apr_wait_for_io_or_timeout(apr_file_t *f, apr_socket_t *s, pollset = f->pollset; if (pollset == NULL) { - status = apr_pollset_create(&(f->pollset), 1, f->pool, 0); + status = fspr_pollset_create(&(f->pollset), 1, f->pool, 0); if (status != APR_SUCCESS) { return status; } @@ -100,16 +100,16 @@ apr_status_t apr_wait_for_io_or_timeout(apr_file_t *f, apr_socket_t *s, * object with the correct reqevents value. Ignore the status result * on the remove, because it might not be in there (yet). */ - (void) apr_pollset_remove(pollset, &pfd); + (void) fspr_pollset_remove(pollset, &pfd); /* ### check status code */ - (void) apr_pollset_add(pollset, &pfd); + (void) fspr_pollset_add(pollset, &pfd); do { int numdesc; - const apr_pollfd_t *pdesc; + const fspr_pollfd_t *pdesc; - status = apr_pollset_poll(pollset, timeout, &numdesc, &pdesc); + status = fspr_pollset_poll(pollset, timeout, &numdesc, &pdesc); if (numdesc == 1 && (pdesc[0].rtnevents & type) != 0) { return APR_SUCCESS; diff --git a/libs/apr/tables/apr_hash.c b/libs/apr/tables/fspr_hash.c similarity index 71% rename from libs/apr/tables/apr_hash.c rename to libs/apr/tables/fspr_hash.c index 5cac297af9..259d66562b 100644 --- a/libs/apr/tables/apr_hash.c +++ b/libs/apr/tables/fspr_hash.c @@ -14,12 +14,12 @@ * limitations under the License. */ -#include "apr_private.h" +#include "fspr_private.h" -#include "apr_general.h" -#include "apr_pools.h" +#include "fspr_general.h" +#include "fspr_pools.h" -#include "apr_hash.h" +#include "fspr_hash.h" #if APR_HAVE_STDLIB_H #include @@ -28,6 +28,8 @@ #include #endif +#include /* assert() */ + #if APR_POOL_DEBUG && APR_HAVE_STDIO_H #include #endif @@ -41,13 +43,13 @@ * isn't too bad given that pools have a low allocation overhead. */ -typedef struct apr_hash_entry_t apr_hash_entry_t; +typedef struct fspr_hash_entry_t fspr_hash_entry_t; -struct apr_hash_entry_t { - apr_hash_entry_t *next; +struct fspr_hash_entry_t { + fspr_hash_entry_t *next; unsigned int hash; const void *key; - apr_ssize_t klen; + fspr_ssize_t klen; const void *val; }; @@ -56,11 +58,11 @@ struct apr_hash_entry_t { * * We keep a pointer to the next hash entry here to allow the current * hash entry to be freed or otherwise mangled between calls to - * apr_hash_next(). + * fspr_hash_next(). */ -struct apr_hash_index_t { - apr_hash_t *ht; - apr_hash_entry_t *this, *next; +struct fspr_hash_index_t { + fspr_hash_t *ht; + fspr_hash_entry_t *this, *next; unsigned int index; }; @@ -71,13 +73,13 @@ struct apr_hash_index_t { * The count of hash entries may be greater depending on the chosen * collision rate. */ -struct apr_hash_t { - apr_pool_t *pool; - apr_hash_entry_t **array; - apr_hash_index_t iterator; /* For apr_hash_first(NULL, ...) */ +struct fspr_hash_t { + fspr_pool_t *pool; + fspr_hash_entry_t **array; + fspr_hash_index_t iterator; /* For fspr_hash_first(NULL, ...) */ unsigned int count, max; - apr_hashfunc_t hash_func; - apr_hash_entry_t *free; /* List of recycled entries */ + fspr_hashfunc_t hash_func; + fspr_hash_entry_t *free; /* List of recycled entries */ }; #define INITIAL_MAX 15 /* tunable == 2^n - 1 */ @@ -87,28 +89,28 @@ struct apr_hash_t { * Hash creation functions. */ -static apr_hash_entry_t **alloc_array(apr_hash_t *ht, unsigned int max) +static fspr_hash_entry_t **alloc_array(fspr_hash_t *ht, unsigned int max) { - return apr_pcalloc(ht->pool, sizeof(*ht->array) * (max + 1)); + return fspr_pcalloc(ht->pool, sizeof(*ht->array) * (max + 1)); } -APR_DECLARE(apr_hash_t *) apr_hash_make(apr_pool_t *pool) +APR_DECLARE(fspr_hash_t *) fspr_hash_make(fspr_pool_t *pool) { - apr_hash_t *ht; - ht = apr_palloc(pool, sizeof(apr_hash_t)); + fspr_hash_t *ht; + ht = fspr_palloc(pool, sizeof(fspr_hash_t)); ht->pool = pool; ht->free = NULL; ht->count = 0; ht->max = INITIAL_MAX; ht->array = alloc_array(ht, ht->max); - ht->hash_func = apr_hashfunc_default; + ht->hash_func = fspr_hashfunc_default; return ht; } -APR_DECLARE(apr_hash_t *) apr_hash_make_custom(apr_pool_t *pool, - apr_hashfunc_t hash_func) +APR_DECLARE(fspr_hash_t *) fspr_hash_make_custom(fspr_pool_t *pool, + fspr_hashfunc_t hash_func) { - apr_hash_t *ht = apr_hash_make(pool); + fspr_hash_t *ht = fspr_hash_make(pool); ht->hash_func = hash_func; return ht; } @@ -118,7 +120,7 @@ APR_DECLARE(apr_hash_t *) apr_hash_make_custom(apr_pool_t *pool, * Hash iteration functions. */ -APR_DECLARE(apr_hash_index_t *) apr_hash_next(apr_hash_index_t *hi) +APR_DECLARE(fspr_hash_index_t *) fspr_hash_next(fspr_hash_index_t *hi) { hi->this = hi->next; while (!hi->this) { @@ -131,11 +133,11 @@ APR_DECLARE(apr_hash_index_t *) apr_hash_next(apr_hash_index_t *hi) return hi; } -APR_DECLARE(apr_hash_index_t *) apr_hash_first(apr_pool_t *p, apr_hash_t *ht) +APR_DECLARE(fspr_hash_index_t *) fspr_hash_first(fspr_pool_t *p, fspr_hash_t *ht) { - apr_hash_index_t *hi; + fspr_hash_index_t *hi; if (p) - hi = apr_palloc(p, sizeof(*hi)); + hi = fspr_palloc(p, sizeof(*hi)); else hi = &ht->iterator; @@ -143,12 +145,12 @@ APR_DECLARE(apr_hash_index_t *) apr_hash_first(apr_pool_t *p, apr_hash_t *ht) hi->index = 0; hi->this = NULL; hi->next = NULL; - return apr_hash_next(hi); + return fspr_hash_next(hi); } -APR_DECLARE(void) apr_hash_this(apr_hash_index_t *hi, +APR_DECLARE(void) fspr_hash_this(fspr_hash_index_t *hi, const void **key, - apr_ssize_t *klen, + fspr_ssize_t *klen, void **val) { if (key) *key = hi->this->key; @@ -161,15 +163,15 @@ APR_DECLARE(void) apr_hash_this(apr_hash_index_t *hi, * Expanding a hash table */ -static void expand_array(apr_hash_t *ht) +static void expand_array(fspr_hash_t *ht) { - apr_hash_index_t *hi; - apr_hash_entry_t **new_array; + fspr_hash_index_t *hi; + fspr_hash_entry_t **new_array; unsigned int new_max; new_max = ht->max * 2 + 1; new_array = alloc_array(ht, new_max); - for (hi = apr_hash_first(NULL, ht); hi; hi = apr_hash_next(hi)) { + for (hi = fspr_hash_first(NULL, ht); hi; hi = fspr_hash_next(hi)) { unsigned int i = hi->this->hash & new_max; hi->this->next = new_array[i]; new_array[i] = hi->this; @@ -178,13 +180,13 @@ static void expand_array(apr_hash_t *ht) ht->max = new_max; } -APR_DECLARE_NONSTD(unsigned int) apr_hashfunc_default(const char *char_key, - apr_ssize_t *klen) +APR_DECLARE_NONSTD(unsigned int) fspr_hashfunc_default(const char *char_key, + fspr_ssize_t *klen) { unsigned int hash = 0; const unsigned char *key = (const unsigned char *)char_key; const unsigned char *p; - apr_ssize_t i; + fspr_ssize_t i; /* * This is the popular `times 33' hash algorithm which is used by @@ -249,12 +251,12 @@ APR_DECLARE_NONSTD(unsigned int) apr_hashfunc_default(const char *char_key, * that hash entries can be removed. */ -static apr_hash_entry_t **find_entry(apr_hash_t *ht, +static fspr_hash_entry_t **find_entry(fspr_hash_t *ht, const void *key, - apr_ssize_t klen, + fspr_ssize_t klen, const void *val) { - apr_hash_entry_t **hep, *he; + fspr_hash_entry_t **hep, *he; unsigned int hash; hash = ht->hash_func(key, &klen); @@ -274,7 +276,7 @@ static apr_hash_entry_t **find_entry(apr_hash_t *ht, if ((he = ht->free) != NULL) ht->free = he->next; else - he = apr_palloc(ht->pool, sizeof(*he)); + he = fspr_palloc(ht->pool, sizeof(*he)); he->next = NULL; he->hash = hash; he->key = key; @@ -285,29 +287,29 @@ static apr_hash_entry_t **find_entry(apr_hash_t *ht, return hep; } -APR_DECLARE(apr_hash_t *) apr_hash_copy(apr_pool_t *pool, - const apr_hash_t *orig) +APR_DECLARE(fspr_hash_t *) fspr_hash_copy(fspr_pool_t *pool, + const fspr_hash_t *orig) { - apr_hash_t *ht; - apr_hash_entry_t *new_vals; + fspr_hash_t *ht; + fspr_hash_entry_t *new_vals; unsigned int i, j; - ht = apr_palloc(pool, sizeof(apr_hash_t) + + ht = fspr_palloc(pool, sizeof(fspr_hash_t) + sizeof(*ht->array) * (orig->max + 1) + - sizeof(apr_hash_entry_t) * orig->count); + sizeof(fspr_hash_entry_t) * orig->count); ht->pool = pool; ht->free = NULL; ht->count = orig->count; ht->max = orig->max; ht->hash_func = orig->hash_func; - ht->array = (apr_hash_entry_t **)((char *)ht + sizeof(apr_hash_t)); + ht->array = (fspr_hash_entry_t **)((char *)ht + sizeof(fspr_hash_t)); - new_vals = (apr_hash_entry_t *)((char *)(ht) + sizeof(apr_hash_t) + + new_vals = (fspr_hash_entry_t *)((char *)(ht) + sizeof(fspr_hash_t) + sizeof(*ht->array) * (orig->max + 1)); j = 0; for (i = 0; i <= ht->max; i++) { - apr_hash_entry_t **new_entry = &(ht->array[i]); - apr_hash_entry_t *orig_entry = orig->array[i]; + fspr_hash_entry_t **new_entry = &(ht->array[i]); + fspr_hash_entry_t *orig_entry = orig->array[i]; while (orig_entry) { *new_entry = &new_vals[j++]; (*new_entry)->hash = orig_entry->hash; @@ -322,11 +324,11 @@ APR_DECLARE(apr_hash_t *) apr_hash_copy(apr_pool_t *pool, return ht; } -APR_DECLARE(void *) apr_hash_get(apr_hash_t *ht, +APR_DECLARE(void *) fspr_hash_get(fspr_hash_t *ht, const void *key, - apr_ssize_t klen) + fspr_ssize_t klen) { - apr_hash_entry_t *he; + fspr_hash_entry_t *he; he = *find_entry(ht, key, klen, NULL); if (he) return (void *)he->val; @@ -334,17 +336,17 @@ APR_DECLARE(void *) apr_hash_get(apr_hash_t *ht, return NULL; } -APR_DECLARE(void) apr_hash_set(apr_hash_t *ht, +APR_DECLARE(void) fspr_hash_set(fspr_hash_t *ht, const void *key, - apr_ssize_t klen, + fspr_ssize_t klen, const void *val) { - apr_hash_entry_t **hep; + fspr_hash_entry_t **hep; hep = find_entry(ht, key, klen, val); if (*hep) { if (!val) { /* delete entry */ - apr_hash_entry_t *old = *hep; + fspr_hash_entry_t *old = *hep; *hep = (*hep)->next; old->next = ht->free; ht->free = old; @@ -362,40 +364,40 @@ APR_DECLARE(void) apr_hash_set(apr_hash_t *ht, /* else key not present and val==NULL */ } -APR_DECLARE(unsigned int) apr_hash_count(apr_hash_t *ht) +APR_DECLARE(unsigned int) fspr_hash_count(fspr_hash_t *ht) { return ht->count; } -APR_DECLARE(void) apr_hash_clear(apr_hash_t *ht) +APR_DECLARE(void) fspr_hash_clear(fspr_hash_t *ht) { - apr_hash_index_t *hi; - for (hi = apr_hash_first(NULL, ht); hi; hi = apr_hash_next(hi)) - apr_hash_set(ht, hi->this->key, hi->this->klen, NULL); + fspr_hash_index_t *hi; + for (hi = fspr_hash_first(NULL, ht); hi; hi = fspr_hash_next(hi)) + fspr_hash_set(ht, hi->this->key, hi->this->klen, NULL); } -APR_DECLARE(apr_hash_t*) apr_hash_overlay(apr_pool_t *p, - const apr_hash_t *overlay, - const apr_hash_t *base) +APR_DECLARE(fspr_hash_t*) fspr_hash_overlay(fspr_pool_t *p, + const fspr_hash_t *overlay, + const fspr_hash_t *base) { - return apr_hash_merge(p, overlay, base, NULL, NULL); + return fspr_hash_merge(p, overlay, base, NULL, NULL); } -APR_DECLARE(apr_hash_t *) apr_hash_merge(apr_pool_t *p, - const apr_hash_t *overlay, - const apr_hash_t *base, - void * (*merger)(apr_pool_t *p, +APR_DECLARE(fspr_hash_t *) fspr_hash_merge(fspr_pool_t *p, + const fspr_hash_t *overlay, + const fspr_hash_t *base, + void * (*merger)(fspr_pool_t *p, const void *key, - apr_ssize_t klen, + fspr_ssize_t klen, const void *h1_val, const void *h2_val, const void *data), const void *data) { - apr_hash_t *res; - apr_hash_entry_t *new_vals = NULL; - apr_hash_entry_t *iter; - apr_hash_entry_t *ent; + fspr_hash_t *res; + fspr_hash_entry_t *new_vals = NULL; + fspr_hash_entry_t *iter; + fspr_hash_entry_t *ent; unsigned int i,j,k; #if APR_POOL_DEBUG @@ -403,19 +405,19 @@ APR_DECLARE(apr_hash_t *) apr_hash_merge(apr_pool_t *p, * overlay->a.pool and base->a.pool have a life span at least * as long as p */ - if (!apr_pool_is_ancestor(overlay->pool, p)) { + if (!fspr_pool_is_ancestor(overlay->pool, p)) { fprintf(stderr, - "apr_hash_merge: overlay's pool is not an ancestor of p\n"); + "fspr_hash_merge: overlay's pool is not an ancestor of p\n"); abort(); } - if (!apr_pool_is_ancestor(base->pool, p)) { + if (!fspr_pool_is_ancestor(base->pool, p)) { fprintf(stderr, - "apr_hash_merge: base's pool is not an ancestor of p\n"); + "fspr_hash_merge: base's pool is not an ancestor of p\n"); abort(); } #endif - res = apr_palloc(p, sizeof(apr_hash_t)); + res = fspr_palloc(p, sizeof(fspr_hash_t)); res->pool = p; res->free = NULL; res->hash_func = base->hash_func; @@ -426,13 +428,14 @@ APR_DECLARE(apr_hash_t *) apr_hash_merge(apr_pool_t *p, } res->array = alloc_array(res, res->max); if (base->count + overlay->count) { - new_vals = apr_palloc(p, sizeof(apr_hash_entry_t) * + new_vals = fspr_palloc(p, sizeof(fspr_hash_entry_t) * (base->count + overlay->count)); } j = 0; for (k = 0; k <= base->max; k++) { for (iter = base->array[k]; iter; iter = iter->next) { i = iter->hash & res->max; + assert(new_vals); new_vals[j].klen = iter->klen; new_vals[j].key = iter->key; new_vals[j].val = iter->val; diff --git a/libs/apr/tables/apr_tables.c b/libs/apr/tables/fspr_tables.c similarity index 71% rename from libs/apr/tables/apr_tables.c rename to libs/apr/tables/fspr_tables.c index 5a1dfa2619..46153d8c38 100644 --- a/libs/apr/tables/apr_tables.c +++ b/libs/apr/tables/fspr_tables.c @@ -21,13 +21,13 @@ * rst --- 4/95 --- 6/95 */ -#include "apr_private.h" +#include "fspr_private.h" -#include "apr_general.h" -#include "apr_pools.h" -#include "apr_tables.h" -#include "apr_strings.h" -#include "apr_lib.h" +#include "fspr_general.h" +#include "fspr_pools.h" +#include "fspr_tables.h" +#include "fspr_strings.h" +#include "fspr_lib.h" #if APR_HAVE_STDLIB_H #include #endif @@ -43,7 +43,7 @@ #endif /***************************************************************** - * This file contains array and apr_table_t functions only. + * This file contains array and fspr_table_t functions only. */ /***************************************************************** @@ -51,7 +51,7 @@ * The 'array' functions... */ -static void make_array_core(apr_array_header_t *res, apr_pool_t *p, +static void make_array_core(fspr_array_header_t *res, fspr_pool_t *p, int nelts, int elt_size, int clear) { /* @@ -63,10 +63,10 @@ static void make_array_core(apr_array_header_t *res, apr_pool_t *p, } if (clear) { - res->elts = apr_pcalloc(p, nelts * elt_size); + res->elts = fspr_pcalloc(p, nelts * elt_size); } else { - res->elts = apr_palloc(p, nelts * elt_size); + res->elts = fspr_palloc(p, nelts * elt_size); } res->pool = p; @@ -75,42 +75,42 @@ static void make_array_core(apr_array_header_t *res, apr_pool_t *p, res->nalloc = nelts; /* ...but this many allocated */ } -APR_DECLARE(int) apr_is_empty_array(const apr_array_header_t *a) +APR_DECLARE(int) fspr_is_empty_array(const fspr_array_header_t *a) { return ((a == NULL) || (a->nelts == 0)); } -APR_DECLARE(apr_array_header_t *) apr_array_make(apr_pool_t *p, +APR_DECLARE(fspr_array_header_t *) fspr_array_make(fspr_pool_t *p, int nelts, int elt_size) { - apr_array_header_t *res; + fspr_array_header_t *res; - res = (apr_array_header_t *) apr_palloc(p, sizeof(apr_array_header_t)); + res = (fspr_array_header_t *) fspr_palloc(p, sizeof(fspr_array_header_t)); make_array_core(res, p, nelts, elt_size, 1); return res; } -APR_DECLARE(void) apr_array_clear(apr_array_header_t *arr) +APR_DECLARE(void) fspr_array_clear(fspr_array_header_t *arr) { arr->nelts = 0; } -APR_DECLARE(void *) apr_array_pop(apr_array_header_t *arr) +APR_DECLARE(void *) fspr_array_pop(fspr_array_header_t *arr) { - if (apr_is_empty_array(arr)) { + if (fspr_is_empty_array(arr)) { return NULL; } return arr->elts + (arr->elt_size * (--arr->nelts)); } -APR_DECLARE(void *) apr_array_push(apr_array_header_t *arr) +APR_DECLARE(void *) fspr_array_push(fspr_array_header_t *arr) { if (arr->nelts == arr->nalloc) { int new_size = (arr->nalloc <= 0) ? 1 : arr->nalloc * 2; char *new_data; - new_data = apr_palloc(arr->pool, arr->elt_size * new_size); + new_data = fspr_palloc(arr->pool, arr->elt_size * new_size); memcpy(new_data, arr->elts, arr->nalloc * arr->elt_size); memset(new_data + arr->nalloc * arr->elt_size, 0, @@ -123,13 +123,13 @@ APR_DECLARE(void *) apr_array_push(apr_array_header_t *arr) return arr->elts + (arr->elt_size * (arr->nelts - 1)); } -static void *apr_array_push_noclear(apr_array_header_t *arr) +static void *fspr_array_push_noclear(fspr_array_header_t *arr) { if (arr->nelts == arr->nalloc) { int new_size = (arr->nalloc <= 0) ? 1 : arr->nalloc * 2; char *new_data; - new_data = apr_palloc(arr->pool, arr->elt_size * new_size); + new_data = fspr_palloc(arr->pool, arr->elt_size * new_size); memcpy(new_data, arr->elts, arr->nalloc * arr->elt_size); arr->elts = new_data; @@ -140,8 +140,8 @@ static void *apr_array_push_noclear(apr_array_header_t *arr) return arr->elts + (arr->elt_size * (arr->nelts - 1)); } -APR_DECLARE(void) apr_array_cat(apr_array_header_t *dst, - const apr_array_header_t *src) +APR_DECLARE(void) fspr_array_cat(fspr_array_header_t *dst, + const fspr_array_header_t *src) { int elt_size = dst->elt_size; @@ -153,7 +153,7 @@ APR_DECLARE(void) apr_array_cat(apr_array_header_t *dst, new_size *= 2; } - new_data = apr_pcalloc(dst->pool, elt_size * new_size); + new_data = fspr_pcalloc(dst->pool, elt_size * new_size); memcpy(new_data, dst->elts, dst->nalloc * elt_size); dst->elts = new_data; @@ -165,11 +165,11 @@ APR_DECLARE(void) apr_array_cat(apr_array_header_t *dst, dst->nelts += src->nelts; } -APR_DECLARE(apr_array_header_t *) apr_array_copy(apr_pool_t *p, - const apr_array_header_t *arr) +APR_DECLARE(fspr_array_header_t *) fspr_array_copy(fspr_pool_t *p, + const fspr_array_header_t *arr) { - apr_array_header_t *res = - (apr_array_header_t *) apr_palloc(p, sizeof(apr_array_header_t)); + fspr_array_header_t *res = + (fspr_array_header_t *) fspr_palloc(p, sizeof(fspr_array_header_t)); make_array_core(res, p, arr->nalloc, arr->elt_size, 0); memcpy(res->elts, arr->elts, arr->elt_size * arr->nelts); @@ -186,8 +186,8 @@ APR_DECLARE(apr_array_header_t *) apr_array_copy(apr_pool_t *p, * overhead of the full copy only where it is really needed. */ -static APR_INLINE void copy_array_hdr_core(apr_array_header_t *res, - const apr_array_header_t *arr) +static APR_INLINE void copy_array_hdr_core(fspr_array_header_t *res, + const fspr_array_header_t *arr) { res->elts = arr->elts; res->elt_size = arr->elt_size; @@ -195,13 +195,13 @@ static APR_INLINE void copy_array_hdr_core(apr_array_header_t *res, res->nalloc = arr->nelts; /* Force overflow on push */ } -APR_DECLARE(apr_array_header_t *) - apr_array_copy_hdr(apr_pool_t *p, - const apr_array_header_t *arr) +APR_DECLARE(fspr_array_header_t *) + fspr_array_copy_hdr(fspr_pool_t *p, + const fspr_array_header_t *arr) { - apr_array_header_t *res; + fspr_array_header_t *res; - res = (apr_array_header_t *) apr_palloc(p, sizeof(apr_array_header_t)); + res = (fspr_array_header_t *) fspr_palloc(p, sizeof(fspr_array_header_t)); res->pool = p; copy_array_hdr_core(res, arr); return res; @@ -209,33 +209,33 @@ APR_DECLARE(apr_array_header_t *) /* The above is used here to avoid consing multiple new array bodies... */ -APR_DECLARE(apr_array_header_t *) - apr_array_append(apr_pool_t *p, - const apr_array_header_t *first, - const apr_array_header_t *second) +APR_DECLARE(fspr_array_header_t *) + fspr_array_append(fspr_pool_t *p, + const fspr_array_header_t *first, + const fspr_array_header_t *second) { - apr_array_header_t *res = apr_array_copy_hdr(p, first); + fspr_array_header_t *res = fspr_array_copy_hdr(p, first); - apr_array_cat(res, second); + fspr_array_cat(res, second); return res; } -/* apr_array_pstrcat generates a new string from the apr_pool_t containing +/* fspr_array_pstrcat generates a new string from the fspr_pool_t containing * the concatenated sequence of substrings referenced as elements within * the array. The string will be empty if all substrings are empty or null, * or if there are no elements in the array. * If sep is non-NUL, it will be inserted between elements as a separator. */ -APR_DECLARE(char *) apr_array_pstrcat(apr_pool_t *p, - const apr_array_header_t *arr, +APR_DECLARE(char *) fspr_array_pstrcat(fspr_pool_t *p, + const fspr_array_header_t *arr, const char sep) { char *cp, *res, **strpp; - apr_size_t len; + fspr_size_t len; int i; if (arr->nelts <= 0 || arr->elts == NULL) { /* Empty table? */ - return (char *) apr_pcalloc(p, 1); + return (char *) fspr_pcalloc(p, 1); } /* Pass one --- find length of required string */ @@ -255,7 +255,7 @@ APR_DECLARE(char *) apr_array_pstrcat(apr_pool_t *p, /* Allocate the required string */ - res = (char *) apr_palloc(p, len + 1); + res = (char *) fspr_palloc(p, len + 1); cp = res; /* Pass two --- copy the argument strings into the result space */ @@ -308,35 +308,35 @@ APR_DECLARE(char *) apr_array_pstrcat(apr_pool_t *p, #define COMPUTE_KEY_CHECKSUM(key, checksum) \ { \ const char *k = (key); \ - apr_uint32_t c = (apr_uint32_t)*k; \ + fspr_uint32_t c = (fspr_uint32_t)*k; \ (checksum) = c; \ (checksum) <<= 8; \ if (c) { \ - c = (apr_uint32_t)*++k; \ + c = (fspr_uint32_t)*++k; \ checksum |= c; \ } \ (checksum) <<= 8; \ if (c) { \ - c = (apr_uint32_t)*++k; \ + c = (fspr_uint32_t)*++k; \ checksum |= c; \ } \ (checksum) <<= 8; \ if (c) { \ - c = (apr_uint32_t)*++k; \ + c = (fspr_uint32_t)*++k; \ checksum |= c; \ } \ checksum &= CASE_MASK; \ } /** The opaque string-content table type */ -struct apr_table_t { +struct fspr_table_t { /* This has to be first to promote backwards compatibility with - * older modules which cast a apr_table_t * to an apr_array_header_t *... - * they should use the apr_table_elts() function for most of the + * older modules which cast a fspr_table_t * to an fspr_array_header_t *... + * they should use the fspr_table_elts() function for most of the * cases they do this for. */ /** The underlying array for the table */ - apr_array_header_t a; + fspr_array_header_t a; #ifdef MAKE_TABLE_PROFILE /** Who created the array. */ void *creator; @@ -352,7 +352,7 @@ struct apr_table_t { * of index_initialized will be zero. (Check this before * trying to use index_first[i] or index_last[i]!) */ - apr_uint32_t index_initialized; + fspr_uint32_t index_initialized; int index_first[TABLE_HASH_SIZE]; int index_last[TABLE_HASH_SIZE]; }; @@ -362,32 +362,32 @@ struct apr_table_t { * and table_elts() in alloc.h */ #ifdef MAKE_TABLE_PROFILE -static apr_table_entry_t *table_push(apr_table_t *t) +static fspr_table_entry_t *table_push(fspr_table_t *t) { if (t->a.nelts == t->a.nalloc) { return NULL; } - return (apr_table_entry_t *) apr_array_push_noclear(&t->a); + return (fspr_table_entry_t *) fspr_array_push_noclear(&t->a); } #else /* MAKE_TABLE_PROFILE */ -#define table_push(t) ((apr_table_entry_t *) apr_array_push_noclear(&(t)->a)) +#define table_push(t) ((fspr_table_entry_t *) fspr_array_push_noclear(&(t)->a)) #endif /* MAKE_TABLE_PROFILE */ -APR_DECLARE(const apr_array_header_t *) apr_table_elts(const apr_table_t *t) +APR_DECLARE(const fspr_array_header_t *) fspr_table_elts(const fspr_table_t *t) { - return (const apr_array_header_t *)t; + return (const fspr_array_header_t *)t; } -APR_DECLARE(int) apr_is_empty_table(const apr_table_t *t) +APR_DECLARE(int) fspr_is_empty_table(const fspr_table_t *t) { return ((t == NULL) || (t->a.nelts == 0)); } -APR_DECLARE(apr_table_t *) apr_table_make(apr_pool_t *p, int nelts) +APR_DECLARE(fspr_table_t *) fspr_table_make(fspr_pool_t *p, int nelts) { - apr_table_t *t = apr_palloc(p, sizeof(apr_table_t)); + fspr_table_t *t = fspr_palloc(p, sizeof(fspr_table_t)); - make_array_core(&t->a, p, nelts, sizeof(apr_table_entry_t), 0); + make_array_core(&t->a, p, nelts, sizeof(fspr_table_entry_t), 0); #ifdef MAKE_TABLE_PROFILE t->creator = __builtin_return_address(0); #endif @@ -395,21 +395,21 @@ APR_DECLARE(apr_table_t *) apr_table_make(apr_pool_t *p, int nelts) return t; } -APR_DECLARE(apr_table_t *) apr_table_copy(apr_pool_t *p, const apr_table_t *t) +APR_DECLARE(fspr_table_t *) fspr_table_copy(fspr_pool_t *p, const fspr_table_t *t) { - apr_table_t *new = apr_palloc(p, sizeof(apr_table_t)); + fspr_table_t *new = fspr_palloc(p, sizeof(fspr_table_t)); #if APR_POOL_DEBUG /* we don't copy keys and values, so it's necessary that t->a.pool * have a life span at least as long as p */ - if (!apr_pool_is_ancestor(t->a.pool, p)) { - fprintf(stderr, "apr_table_copy: t's pool is not an ancestor of p\n"); + if (!fspr_pool_is_ancestor(t->a.pool, p)) { + fprintf(stderr, "fspr_table_copy: t's pool is not an ancestor of p\n"); abort(); } #endif - make_array_core(&new->a, p, t->a.nalloc, sizeof(apr_table_entry_t), 0); - memcpy(new->a.elts, t->a.elts, t->a.nelts * sizeof(apr_table_entry_t)); + make_array_core(&new->a, p, t->a.nalloc, sizeof(fspr_table_entry_t), 0); + memcpy(new->a.elts, t->a.elts, t->a.nelts * sizeof(fspr_table_entry_t)); new->a.nelts = t->a.nelts; memcpy(new->index_first, t->index_first, sizeof(int) * TABLE_HASH_SIZE); memcpy(new->index_last, t->index_last, sizeof(int) * TABLE_HASH_SIZE); @@ -417,11 +417,11 @@ APR_DECLARE(apr_table_t *) apr_table_copy(apr_pool_t *p, const apr_table_t *t) return new; } -static void table_reindex(apr_table_t *t) +static void table_reindex(fspr_table_t *t) { int i; int hash; - apr_table_entry_t *next_elt = (apr_table_entry_t *) t->a.elts; + fspr_table_entry_t *next_elt = (fspr_table_entry_t *) t->a.elts; t->index_initialized = 0; for (i = 0; i < t->a.nelts; i++, next_elt++) { @@ -434,17 +434,17 @@ static void table_reindex(apr_table_t *t) } } -APR_DECLARE(void) apr_table_clear(apr_table_t *t) +APR_DECLARE(void) fspr_table_clear(fspr_table_t *t) { t->a.nelts = 0; t->index_initialized = 0; } -APR_DECLARE(const char *) apr_table_get(const apr_table_t *t, const char *key) +APR_DECLARE(const char *) fspr_table_get(const fspr_table_t *t, const char *key) { - apr_table_entry_t *next_elt; - apr_table_entry_t *end_elt; - apr_uint32_t checksum; + fspr_table_entry_t *next_elt; + fspr_table_entry_t *end_elt; + fspr_uint32_t checksum; int hash; if (key == NULL) { @@ -456,8 +456,8 @@ APR_DECLARE(const char *) apr_table_get(const apr_table_t *t, const char *key) return NULL; } COMPUTE_KEY_CHECKSUM(key, checksum); - next_elt = ((apr_table_entry_t *) t->a.elts) + t->index_first[hash];; - end_elt = ((apr_table_entry_t *) t->a.elts) + t->index_last[hash]; + next_elt = ((fspr_table_entry_t *) t->a.elts) + t->index_first[hash];; + end_elt = ((fspr_table_entry_t *) t->a.elts) + t->index_last[hash]; for (; next_elt <= end_elt; next_elt++) { if ((checksum == next_elt->key_checksum) && @@ -469,13 +469,13 @@ APR_DECLARE(const char *) apr_table_get(const apr_table_t *t, const char *key) return NULL; } -APR_DECLARE(void) apr_table_set(apr_table_t *t, const char *key, +APR_DECLARE(void) fspr_table_set(fspr_table_t *t, const char *key, const char *val) { - apr_table_entry_t *next_elt; - apr_table_entry_t *end_elt; - apr_table_entry_t *table_end; - apr_uint32_t checksum; + fspr_table_entry_t *next_elt; + fspr_table_entry_t *end_elt; + fspr_table_entry_t *table_end; + fspr_uint32_t checksum; int hash; COMPUTE_KEY_CHECKSUM(key, checksum); @@ -485,9 +485,9 @@ APR_DECLARE(void) apr_table_set(apr_table_t *t, const char *key, TABLE_SET_INDEX_INITIALIZED(t, hash); goto add_new_elt; } - next_elt = ((apr_table_entry_t *) t->a.elts) + t->index_first[hash];; - end_elt = ((apr_table_entry_t *) t->a.elts) + t->index_last[hash]; - table_end =((apr_table_entry_t *) t->a.elts) + t->a.nelts; + next_elt = ((fspr_table_entry_t *) t->a.elts) + t->index_first[hash];; + end_elt = ((fspr_table_entry_t *) t->a.elts) + t->index_last[hash]; + table_end =((fspr_table_entry_t *) t->a.elts) + t->a.nelts; for (; next_elt <= end_elt; next_elt++) { if ((checksum == next_elt->key_checksum) && @@ -496,9 +496,9 @@ APR_DECLARE(void) apr_table_set(apr_table_t *t, const char *key, /* Found an existing entry with the same key, so overwrite it */ int must_reindex = 0; - apr_table_entry_t *dst_elt = NULL; + fspr_table_entry_t *dst_elt = NULL; - next_elt->val = apr_pstrdup(t->a.pool, val); + next_elt->val = fspr_pstrdup(t->a.pool, val); /* Remove any other instances of this key */ for (next_elt++; next_elt <= end_elt; next_elt++) { @@ -535,19 +535,19 @@ APR_DECLARE(void) apr_table_set(apr_table_t *t, const char *key, add_new_elt: t->index_last[hash] = t->a.nelts; - next_elt = (apr_table_entry_t *) table_push(t); - next_elt->key = apr_pstrdup(t->a.pool, key); - next_elt->val = apr_pstrdup(t->a.pool, val); + next_elt = (fspr_table_entry_t *) table_push(t); + next_elt->key = fspr_pstrdup(t->a.pool, key); + next_elt->val = fspr_pstrdup(t->a.pool, val); next_elt->key_checksum = checksum; } -APR_DECLARE(void) apr_table_setn(apr_table_t *t, const char *key, +APR_DECLARE(void) fspr_table_setn(fspr_table_t *t, const char *key, const char *val) { - apr_table_entry_t *next_elt; - apr_table_entry_t *end_elt; - apr_table_entry_t *table_end; - apr_uint32_t checksum; + fspr_table_entry_t *next_elt; + fspr_table_entry_t *end_elt; + fspr_table_entry_t *table_end; + fspr_uint32_t checksum; int hash; COMPUTE_KEY_CHECKSUM(key, checksum); @@ -557,9 +557,9 @@ APR_DECLARE(void) apr_table_setn(apr_table_t *t, const char *key, TABLE_SET_INDEX_INITIALIZED(t, hash); goto add_new_elt; } - next_elt = ((apr_table_entry_t *) t->a.elts) + t->index_first[hash];; - end_elt = ((apr_table_entry_t *) t->a.elts) + t->index_last[hash]; - table_end =((apr_table_entry_t *) t->a.elts) + t->a.nelts; + next_elt = ((fspr_table_entry_t *) t->a.elts) + t->index_first[hash];; + end_elt = ((fspr_table_entry_t *) t->a.elts) + t->index_last[hash]; + table_end =((fspr_table_entry_t *) t->a.elts) + t->a.nelts; for (; next_elt <= end_elt; next_elt++) { if ((checksum == next_elt->key_checksum) && @@ -568,7 +568,7 @@ APR_DECLARE(void) apr_table_setn(apr_table_t *t, const char *key, /* Found an existing entry with the same key, so overwrite it */ int must_reindex = 0; - apr_table_entry_t *dst_elt = NULL; + fspr_table_entry_t *dst_elt = NULL; next_elt->val = (char *)val; @@ -607,18 +607,18 @@ APR_DECLARE(void) apr_table_setn(apr_table_t *t, const char *key, add_new_elt: t->index_last[hash] = t->a.nelts; - next_elt = (apr_table_entry_t *) table_push(t); + next_elt = (fspr_table_entry_t *) table_push(t); next_elt->key = (char *)key; next_elt->val = (char *)val; next_elt->key_checksum = checksum; } -APR_DECLARE(void) apr_table_unset(apr_table_t *t, const char *key) +APR_DECLARE(void) fspr_table_unset(fspr_table_t *t, const char *key) { - apr_table_entry_t *next_elt; - apr_table_entry_t *end_elt; - apr_table_entry_t *dst_elt; - apr_uint32_t checksum; + fspr_table_entry_t *next_elt; + fspr_table_entry_t *end_elt; + fspr_table_entry_t *dst_elt; + fspr_uint32_t checksum; int hash; int must_reindex; @@ -627,8 +627,8 @@ APR_DECLARE(void) apr_table_unset(apr_table_t *t, const char *key) return; } COMPUTE_KEY_CHECKSUM(key, checksum); - next_elt = ((apr_table_entry_t *) t->a.elts) + t->index_first[hash]; - end_elt = ((apr_table_entry_t *) t->a.elts) + t->index_last[hash]; + next_elt = ((fspr_table_entry_t *) t->a.elts) + t->index_first[hash]; + end_elt = ((fspr_table_entry_t *) t->a.elts) + t->index_last[hash]; must_reindex = 0; for (; next_elt <= end_elt; next_elt++) { if ((checksum == next_elt->key_checksum) && @@ -637,7 +637,7 @@ APR_DECLARE(void) apr_table_unset(apr_table_t *t, const char *key) /* Found a match: remove this entry, plus any additional * matches for the same key that might follow */ - apr_table_entry_t *table_end = ((apr_table_entry_t *) t->a.elts) + + fspr_table_entry_t *table_end = ((fspr_table_entry_t *) t->a.elts) + t->a.nelts; t->a.nelts--; dst_elt = next_elt; @@ -667,12 +667,12 @@ APR_DECLARE(void) apr_table_unset(apr_table_t *t, const char *key) } } -APR_DECLARE(void) apr_table_merge(apr_table_t *t, const char *key, +APR_DECLARE(void) fspr_table_merge(fspr_table_t *t, const char *key, const char *val) { - apr_table_entry_t *next_elt; - apr_table_entry_t *end_elt; - apr_uint32_t checksum; + fspr_table_entry_t *next_elt; + fspr_table_entry_t *end_elt; + fspr_uint32_t checksum; int hash; COMPUTE_KEY_CHECKSUM(key, checksum); @@ -682,15 +682,15 @@ APR_DECLARE(void) apr_table_merge(apr_table_t *t, const char *key, TABLE_SET_INDEX_INITIALIZED(t, hash); goto add_new_elt; } - next_elt = ((apr_table_entry_t *) t->a.elts) + t->index_first[hash]; - end_elt = ((apr_table_entry_t *) t->a.elts) + t->index_last[hash]; + next_elt = ((fspr_table_entry_t *) t->a.elts) + t->index_first[hash]; + end_elt = ((fspr_table_entry_t *) t->a.elts) + t->index_last[hash]; for (; next_elt <= end_elt; next_elt++) { if ((checksum == next_elt->key_checksum) && !strcasecmp(next_elt->key, key)) { /* Found an existing entry with the same key, so merge with it */ - next_elt->val = apr_pstrcat(t->a.pool, next_elt->val, ", ", + next_elt->val = fspr_pstrcat(t->a.pool, next_elt->val, ", ", val, NULL); return; } @@ -698,28 +698,28 @@ APR_DECLARE(void) apr_table_merge(apr_table_t *t, const char *key, add_new_elt: t->index_last[hash] = t->a.nelts; - next_elt = (apr_table_entry_t *) table_push(t); - next_elt->key = apr_pstrdup(t->a.pool, key); - next_elt->val = apr_pstrdup(t->a.pool, val); + next_elt = (fspr_table_entry_t *) table_push(t); + next_elt->key = fspr_pstrdup(t->a.pool, key); + next_elt->val = fspr_pstrdup(t->a.pool, val); next_elt->key_checksum = checksum; } -APR_DECLARE(void) apr_table_mergen(apr_table_t *t, const char *key, +APR_DECLARE(void) fspr_table_mergen(fspr_table_t *t, const char *key, const char *val) { - apr_table_entry_t *next_elt; - apr_table_entry_t *end_elt; - apr_uint32_t checksum; + fspr_table_entry_t *next_elt; + fspr_table_entry_t *end_elt; + fspr_uint32_t checksum; int hash; #if APR_POOL_DEBUG { - if (!apr_pool_is_ancestor(apr_pool_find(key), t->a.pool)) { - fprintf(stderr, "apr_table_mergen: key not in ancestor pool of t\n"); + if (!fspr_pool_is_ancestor(fspr_pool_find(key), t->a.pool)) { + fprintf(stderr, "fspr_table_mergen: key not in ancestor pool of t\n"); abort(); } - if (!apr_pool_is_ancestor(apr_pool_find(val), t->a.pool)) { - fprintf(stderr, "apr_table_mergen: key not in ancestor pool of t\n"); + if (!fspr_pool_is_ancestor(fspr_pool_find(val), t->a.pool)) { + fprintf(stderr, "fspr_table_mergen: key not in ancestor pool of t\n"); abort(); } } @@ -732,15 +732,15 @@ APR_DECLARE(void) apr_table_mergen(apr_table_t *t, const char *key, TABLE_SET_INDEX_INITIALIZED(t, hash); goto add_new_elt; } - next_elt = ((apr_table_entry_t *) t->a.elts) + t->index_first[hash];; - end_elt = ((apr_table_entry_t *) t->a.elts) + t->index_last[hash]; + next_elt = ((fspr_table_entry_t *) t->a.elts) + t->index_first[hash];; + end_elt = ((fspr_table_entry_t *) t->a.elts) + t->index_last[hash]; for (; next_elt <= end_elt; next_elt++) { if ((checksum == next_elt->key_checksum) && !strcasecmp(next_elt->key, key)) { /* Found an existing entry with the same key, so merge with it */ - next_elt->val = apr_pstrcat(t->a.pool, next_elt->val, ", ", + next_elt->val = fspr_pstrcat(t->a.pool, next_elt->val, ", ", val, NULL); return; } @@ -748,17 +748,17 @@ APR_DECLARE(void) apr_table_mergen(apr_table_t *t, const char *key, add_new_elt: t->index_last[hash] = t->a.nelts; - next_elt = (apr_table_entry_t *) table_push(t); + next_elt = (fspr_table_entry_t *) table_push(t); next_elt->key = (char *)key; next_elt->val = (char *)val; next_elt->key_checksum = checksum; } -APR_DECLARE(void) apr_table_add(apr_table_t *t, const char *key, +APR_DECLARE(void) fspr_table_add(fspr_table_t *t, const char *key, const char *val) { - apr_table_entry_t *elts; - apr_uint32_t checksum; + fspr_table_entry_t *elts; + fspr_uint32_t checksum; int hash; hash = TABLE_HASH(key); @@ -768,27 +768,27 @@ APR_DECLARE(void) apr_table_add(apr_table_t *t, const char *key, TABLE_SET_INDEX_INITIALIZED(t, hash); } COMPUTE_KEY_CHECKSUM(key, checksum); - elts = (apr_table_entry_t *) table_push(t); - elts->key = apr_pstrdup(t->a.pool, key); - elts->val = apr_pstrdup(t->a.pool, val); + elts = (fspr_table_entry_t *) table_push(t); + elts->key = fspr_pstrdup(t->a.pool, key); + elts->val = fspr_pstrdup(t->a.pool, val); elts->key_checksum = checksum; } -APR_DECLARE(void) apr_table_addn(apr_table_t *t, const char *key, +APR_DECLARE(void) fspr_table_addn(fspr_table_t *t, const char *key, const char *val) { - apr_table_entry_t *elts; - apr_uint32_t checksum; + fspr_table_entry_t *elts; + fspr_uint32_t checksum; int hash; #if APR_POOL_DEBUG { - if (!apr_pool_is_ancestor(apr_pool_find(key), t->a.pool)) { - fprintf(stderr, "apr_table_addn: key not in ancestor pool of t\n"); + if (!fspr_pool_is_ancestor(fspr_pool_find(key), t->a.pool)) { + fprintf(stderr, "fspr_table_addn: key not in ancestor pool of t\n"); abort(); } - if (!apr_pool_is_ancestor(apr_pool_find(val), t->a.pool)) { - fprintf(stderr, "apr_table_addn: key not in ancestor pool of t\n"); + if (!fspr_pool_is_ancestor(fspr_pool_find(val), t->a.pool)) { + fprintf(stderr, "fspr_table_addn: key not in ancestor pool of t\n"); abort(); } } @@ -801,40 +801,40 @@ APR_DECLARE(void) apr_table_addn(apr_table_t *t, const char *key, TABLE_SET_INDEX_INITIALIZED(t, hash); } COMPUTE_KEY_CHECKSUM(key, checksum); - elts = (apr_table_entry_t *) table_push(t); + elts = (fspr_table_entry_t *) table_push(t); elts->key = (char *)key; elts->val = (char *)val; elts->key_checksum = checksum; } -APR_DECLARE(apr_table_t *) apr_table_overlay(apr_pool_t *p, - const apr_table_t *overlay, - const apr_table_t *base) +APR_DECLARE(fspr_table_t *) fspr_table_overlay(fspr_pool_t *p, + const fspr_table_t *overlay, + const fspr_table_t *base) { - apr_table_t *res; + fspr_table_t *res; #if APR_POOL_DEBUG /* we don't copy keys and values, so it's necessary that * overlay->a.pool and base->a.pool have a life span at least * as long as p */ - if (!apr_pool_is_ancestor(overlay->a.pool, p)) { + if (!fspr_pool_is_ancestor(overlay->a.pool, p)) { fprintf(stderr, - "apr_table_overlay: overlay's pool is not an ancestor of p\n"); + "fspr_table_overlay: overlay's pool is not an ancestor of p\n"); abort(); } - if (!apr_pool_is_ancestor(base->a.pool, p)) { + if (!fspr_pool_is_ancestor(base->a.pool, p)) { fprintf(stderr, - "apr_table_overlay: base's pool is not an ancestor of p\n"); + "fspr_table_overlay: base's pool is not an ancestor of p\n"); abort(); } #endif - res = apr_palloc(p, sizeof(apr_table_t)); + res = fspr_palloc(p, sizeof(fspr_table_t)); /* behave like append_arrays */ res->a.pool = p; copy_array_hdr_core(&res->a, &overlay->a); - apr_array_cat(&res->a, &base->a); + fspr_array_cat(&res->a, &base->a); table_reindex(res); return res; } @@ -844,7 +844,7 @@ APR_DECLARE(apr_table_t *) apr_table_overlay(apr_pool_t *p, * For each key value given as a vararg: * run the function pointed to as * int comp(void *r, char *key, char *value); - * on each valid key-value pair in the apr_table_t t that matches the vararg key, + * on each valid key-value pair in the fspr_table_t t that matches the vararg key, * or once for every valid key-value pair if the vararg list is empty, * until the function returns false (0) or we finish the table. * @@ -854,42 +854,42 @@ APR_DECLARE(apr_table_t *) apr_table_overlay(apr_pool_t *p, * only one traversal will be made and will cut short if comp returns 0. * * Note that the table_get and table_merge functions assume that each key in - * the apr_table_t is unique (i.e., no multiple entries with the same key). This + * the fspr_table_t is unique (i.e., no multiple entries with the same key). This * function does not make that assumption, since it (unfortunately) isn't * true for some of Apache's tables. * * Note that rec is simply passed-on to the comp function, so that the * caller can pass additional info for the task. * - * ADDENDUM for apr_table_vdo(): + * ADDENDUM for fspr_table_vdo(): * * The caching api will allow a user to walk the header values: * - * apr_status_t apr_cache_el_header_walk(apr_cache_el *el, + * fspr_status_t fspr_cache_el_header_walk(fspr_cache_el *el, * int (*comp)(void *, const char *, const char *), void *rec, ...); * * So it can be ..., however from there I use a callback that use a va_list: * - * apr_status_t (*cache_el_header_walk)(apr_cache_el *el, + * fspr_status_t (*cache_el_header_walk)(fspr_cache_el *el, * int (*comp)(void *, const char *, const char *), void *rec, va_list); * * To pass those ...'s on down to the actual module that will handle walking - * their headers, in the file case this is actually just an apr_table - and - * rather than reimplementing apr_table_do (which IMHO would be bad) I just + * their headers, in the file case this is actually just an fspr_table - and + * rather than reimplementing fspr_table_do (which IMHO would be bad) I just * called it with the va_list. For mod_shmem_cache I don't need it since I - * can't use apr_table's, but mod_file_cache should (though a good hash would + * can't use fspr_table's, but mod_file_cache should (though a good hash would * be better, but that's a different issue :). * * So to make mod_file_cache easier to maintain, it's a good thing */ -APR_DECLARE_NONSTD(int) apr_table_do(apr_table_do_callback_fn_t *comp, - void *rec, const apr_table_t *t, ...) +APR_DECLARE_NONSTD(int) fspr_table_do(fspr_table_do_callback_fn_t *comp, + void *rec, const fspr_table_t *t, ...) { int rv; va_list vp; va_start(vp, t); - rv = apr_table_vdo(comp, rec, t, vp); + rv = fspr_table_vdo(comp, rec, t, vp); va_end(vp); return rv; @@ -905,12 +905,12 @@ APR_DECLARE_NONSTD(int) apr_table_do(apr_table_do_callback_fn_t *comp, * * Note also that this behavior is at odds with the behavior seen if an * empty va_list is passed in -- in that case, a zero return value terminates - * the entire apr_table_vdo (which is what I think should happen in + * the entire fspr_table_vdo (which is what I think should happen in * both cases). * * If nobody objects soon, I'm going to change the order of the nested * loops in this function so that any zero return value from the (*comp) - * function will cause a full termination of apr_table_vdo. I'm hesitant + * function will cause a full termination of fspr_table_vdo. I'm hesitant * at the moment because these (funky) semantics have been around for a * very long time, and although Apache doesn't seem to use them at all, * some third-party vendor might. I can only think of one possible reason @@ -925,11 +925,11 @@ APR_DECLARE_NONSTD(int) apr_table_do(apr_table_do_callback_fn_t *comp, * * Sigh. --JCW, 06/28/02 */ -APR_DECLARE(int) apr_table_vdo(apr_table_do_callback_fn_t *comp, - void *rec, const apr_table_t *t, va_list vp) +APR_DECLARE(int) fspr_table_vdo(fspr_table_do_callback_fn_t *comp, + void *rec, const fspr_table_t *t, va_list vp) { char *argp; - apr_table_entry_t *elts = (apr_table_entry_t *) t->a.elts; + fspr_table_entry_t *elts = (fspr_table_entry_t *) t->a.elts; int vdorv = 1; argp = va_arg(vp, char *); @@ -939,7 +939,7 @@ APR_DECLARE(int) apr_table_vdo(apr_table_do_callback_fn_t *comp, /* Scan for entries that match the next key */ int hash = TABLE_HASH(argp); if (TABLE_INDEX_IS_INITIALIZED(t, hash)) { - apr_uint32_t checksum; + fspr_uint32_t checksum; COMPUTE_KEY_CHECKSUM(argp, checksum); for (i = t->index_first[hash]; rv && (i <= t->index_last[hash]); ++i) { @@ -966,22 +966,22 @@ APR_DECLARE(int) apr_table_vdo(apr_table_do_callback_fn_t *comp, return vdorv; } -static apr_table_entry_t **table_mergesort(apr_pool_t *pool, - apr_table_entry_t **values, - apr_size_t n) +static fspr_table_entry_t **table_mergesort(fspr_pool_t *pool, + fspr_table_entry_t **values, + fspr_size_t n) { /* Bottom-up mergesort, based on design in Sedgewick's "Algorithms * in C," chapter 8 */ - apr_table_entry_t **values_tmp = - (apr_table_entry_t **)apr_palloc(pool, n * sizeof(apr_table_entry_t*)); - apr_size_t i; - apr_size_t blocksize; + fspr_table_entry_t **values_tmp = + (fspr_table_entry_t **)fspr_palloc(pool, n * sizeof(fspr_table_entry_t*)); + fspr_size_t i; + fspr_size_t blocksize; /* First pass: sort pairs of elements (blocksize=1) */ for (i = 0; i + 1 < n; i += 2) { if (strcasecmp(values[i]->key, values[i + 1]->key) > 0) { - apr_table_entry_t *swap = values[i]; + fspr_table_entry_t *swap = values[i]; values[i] = values[i + 1]; values[i + 1] = swap; } @@ -990,9 +990,9 @@ static apr_table_entry_t **table_mergesort(apr_pool_t *pool, /* Merge successively larger blocks */ blocksize = 2; while (blocksize < n) { - apr_table_entry_t **dst = values_tmp; - apr_size_t next_start; - apr_table_entry_t **swap; + fspr_table_entry_t **dst = values_tmp; + fspr_size_t next_start; + fspr_table_entry_t **swap; /* Merge consecutive pairs blocks of the next blocksize. * Within a block, elements are in sorted order due to @@ -1001,10 +1001,10 @@ static apr_table_entry_t **table_mergesort(apr_pool_t *pool, for (next_start = 0; next_start + blocksize < n; next_start += (blocksize + blocksize)) { - apr_size_t block1_start = next_start; - apr_size_t block2_start = block1_start + blocksize; - apr_size_t block1_end = block2_start; - apr_size_t block2_end = block2_start + blocksize; + fspr_size_t block1_start = next_start; + fspr_size_t block2_start = block1_start + blocksize; + fspr_size_t block1_end = block2_start; + fspr_size_t block2_end = block2_start + blocksize; if (block2_end > n) { /* The last block may be smaller than blocksize */ block2_end = n; @@ -1060,13 +1060,13 @@ static apr_table_entry_t **table_mergesort(apr_pool_t *pool, return values; } -APR_DECLARE(void) apr_table_compress(apr_table_t *t, unsigned flags) +APR_DECLARE(void) fspr_table_compress(fspr_table_t *t, unsigned flags) { - apr_table_entry_t **sort_array; - apr_table_entry_t **sort_next; - apr_table_entry_t **sort_end; - apr_table_entry_t *table_next; - apr_table_entry_t **last; + fspr_table_entry_t **sort_array; + fspr_table_entry_t **sort_next; + fspr_table_entry_t **sort_end; + fspr_table_entry_t *table_next; + fspr_table_entry_t **last; int i; int dups_found; @@ -1078,10 +1078,10 @@ APR_DECLARE(void) apr_table_compress(apr_table_t *t, unsigned flags) * array and sort to allow for easy detection of * duplicate keys */ - sort_array = (apr_table_entry_t **) - apr_palloc(t->a.pool, t->a.nelts * sizeof(apr_table_entry_t*)); + sort_array = (fspr_table_entry_t **) + fspr_palloc(t->a.pool, t->a.nelts * sizeof(fspr_table_entry_t*)); sort_next = sort_array; - table_next = (apr_table_entry_t *)t->a.elts; + table_next = (fspr_table_entry_t *)t->a.elts; i = t->a.nelts; do { *sort_next++ = table_next++; @@ -1102,7 +1102,7 @@ APR_DECLARE(void) apr_table_compress(apr_table_t *t, unsigned flags) while (sort_next < sort_end) { if (((*sort_next)->key_checksum == (*last)->key_checksum) && !strcasecmp((*sort_next)->key, (*last)->key)) { - apr_table_entry_t **dup_last = sort_next + 1; + fspr_table_entry_t **dup_last = sort_next + 1; dups_found = 1; while ((dup_last < sort_end) && ((*dup_last)->key_checksum == (*last)->key_checksum) && @@ -1113,15 +1113,15 @@ APR_DECLARE(void) apr_table_compress(apr_table_t *t, unsigned flags) * all have the same key */ if (flags == APR_OVERLAP_TABLES_MERGE) { - apr_size_t len = 0; - apr_table_entry_t **next = last; + fspr_size_t len = 0; + fspr_table_entry_t **next = last; char *new_val; char *val_dst; do { len += strlen((*next)->val); len += 2; /* for ", " or trailing null */ } while (++next <= dup_last); - new_val = (char *)apr_palloc(t->a.pool, len); + new_val = (char *)fspr_palloc(t->a.pool, len); val_dst = new_val; next = last; for (;;) { @@ -1153,9 +1153,9 @@ APR_DECLARE(void) apr_table_compress(apr_table_t *t, unsigned flags) /* Shift elements to the left to fill holes left by removing duplicates */ if (dups_found) { - apr_table_entry_t *src = (apr_table_entry_t *)t->a.elts; - apr_table_entry_t *dst = (apr_table_entry_t *)t->a.elts; - apr_table_entry_t *last_elt = src + t->a.nelts; + fspr_table_entry_t *src = (fspr_table_entry_t *)t->a.elts; + fspr_table_entry_t *dst = (fspr_table_entry_t *)t->a.elts; + fspr_table_entry_t *last_elt = src + t->a.nelts; do { if (src->key) { *dst++ = *src; @@ -1167,12 +1167,12 @@ APR_DECLARE(void) apr_table_compress(apr_table_t *t, unsigned flags) table_reindex(t); } -static void apr_table_cat(apr_table_t *t, const apr_table_t *s) +static void fspr_table_cat(fspr_table_t *t, const fspr_table_t *s) { const int n = t->a.nelts; register int idx; - apr_array_cat(&t->a,&s->a); + fspr_array_cat(&t->a,&s->a); if (n == 0) { memcpy(t->index_first,s->index_first,sizeof(int) * TABLE_HASH_SIZE); @@ -1193,7 +1193,7 @@ static void apr_table_cat(apr_table_t *t, const apr_table_t *s) t->index_initialized |= s->index_initialized; } -APR_DECLARE(void) apr_table_overlap(apr_table_t *a, const apr_table_t *b, +APR_DECLARE(void) fspr_table_overlap(fspr_table_t *a, const fspr_table_t *b, unsigned flags) { if (a->a.nelts + b->a.nelts == 0) { @@ -1203,13 +1203,13 @@ APR_DECLARE(void) apr_table_overlap(apr_table_t *a, const apr_table_t *b, #if APR_POOL_DEBUG /* Since the keys and values are not copied, it's required that * b->a.pool has a lifetime at least as long as a->a.pool. */ - if (!apr_pool_is_ancestor(b->a.pool, a->a.pool)) { - fprintf(stderr, "apr_table_overlap: b's pool is not an ancestor of a's\n"); + if (!fspr_pool_is_ancestor(b->a.pool, a->a.pool)) { + fprintf(stderr, "fspr_table_overlap: b's pool is not an ancestor of a's\n"); abort(); } #endif - apr_table_cat(a, b); + fspr_table_cat(a, b); - apr_table_compress(a, flags); + fspr_table_compress(a, flags); } diff --git a/libs/apr/test/globalmutexchild.c b/libs/apr/test/globalmutexchild.c index 4b8737b02b..194cfb54ad 100644 --- a/libs/apr/test/globalmutexchild.c +++ b/libs/apr/test/globalmutexchild.c @@ -15,12 +15,12 @@ */ #include "testglobalmutex.h" -#include "apr_pools.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_global_mutex.h" -#include "apr_strings.h" -#include "apr.h" +#include "fspr_pools.h" +#include "fspr_file_io.h" +#include "fspr_general.h" +#include "fspr_global_mutex.h" +#include "fspr_strings.h" +#include "fspr.h" #if APR_HAVE_STDLIB_H #include @@ -29,36 +29,36 @@ int main(int argc, const char * const argv[]) { - apr_pool_t *p; + fspr_pool_t *p; int i = 0; - apr_lockmech_e mech; - apr_global_mutex_t *global_lock; - apr_status_t rv; + fspr_lockmech_e mech; + fspr_global_mutex_t *global_lock; + fspr_status_t rv; - apr_initialize(); - atexit(apr_terminate); + fspr_initialize(); + atexit(fspr_terminate); - apr_pool_create(&p, NULL); + fspr_pool_create(&p, NULL); if (argc >= 2) { - mech = (apr_lockmech_e)apr_strtoi64(argv[1], NULL, 0); + mech = (fspr_lockmech_e)fspr_strtoi64(argv[1], NULL, 0); } else { mech = APR_LOCK_DEFAULT; } - rv = apr_global_mutex_create(&global_lock, LOCKNAME, mech, p); + rv = fspr_global_mutex_create(&global_lock, LOCKNAME, mech, p); if (rv != APR_SUCCESS) { exit(-rv); } - apr_global_mutex_child_init(&global_lock, LOCKNAME, p); + fspr_global_mutex_child_init(&global_lock, LOCKNAME, p); while (1) { - apr_global_mutex_lock(global_lock); + fspr_global_mutex_lock(global_lock); if (i == MAX_ITER) { - apr_global_mutex_unlock(global_lock); + fspr_global_mutex_unlock(global_lock); exit(i); } i++; - apr_global_mutex_unlock(global_lock); + fspr_global_mutex_unlock(global_lock); } exit(0); } diff --git a/libs/apr/test/internal/testregex.c b/libs/apr/test/internal/testregex.c index 20dcfdebe7..7a46b78364 100644 --- a/libs/apr/test/internal/testregex.c +++ b/libs/apr/test/internal/testregex.c @@ -15,25 +15,25 @@ */ -#include "apr_strings.h" -#include "apr_pools.h" -#include "apr_general.h" -#include "apr_hash.h" -#include "apr_lib.h" -#include "apr_time.h" +#include "fspr_strings.h" +#include "fspr_pools.h" +#include "fspr_general.h" +#include "fspr_hash.h" +#include "fspr_lib.h" +#include "fspr_time.h" #include #include #include int main( int argc, char** argv) { - apr_pool_t *context; + fspr_pool_t *context; regex_t regex; int rc; int i; int iters; - apr_time_t now; - apr_time_t end; - apr_hash_t *h; + fspr_time_t now; + fspr_time_t end; + fspr_hash_t *h; if (argc !=4 ) { @@ -42,9 +42,9 @@ int main( int argc, char** argv) { } iters = atoi( argv[3]); - apr_initialize() ; - atexit(apr_terminate); - if (apr_pool_create(&context, NULL) != APR_SUCCESS) { + fspr_initialize() ; + atexit(fspr_terminate); + if (fspr_pool_create(&context, NULL) != APR_SUCCESS) { fprintf(stderr, "Something went wrong\n"); exit(-1); } @@ -63,29 +63,29 @@ int main( int argc, char** argv) { else { fprintf(stderr,"No Match\n"); } - now = apr_time_now(); + now = fspr_time_now(); for (i=0;i #include @@ -54,15 +54,15 @@ void displaynw(struct testval *f, struct testval *l) void test_nrange(struct testval *p) { struct testval f, l, s; - apr_status_t rc; + fspr_status_t rc; int success = 0; memcpy (&s, p, sizeof(s)); ++s.nl; do { - apr_size_t nl = s.nl, wl = sizeof(s.w) / 2; - rc = apr_conv_utf8_to_ucs2(s.n, &nl, s.w, &wl); + fspr_size_t nl = s.nl, wl = sizeof(s.w) / 2; + rc = fspr_conv_utf8_to_ucs2(s.n, &nl, s.w, &wl); s.wl = (sizeof(s.w) / 2) - wl; if (!nl && rc == APR_SUCCESS) { if (!success) { @@ -106,15 +106,15 @@ void test_nrange(struct testval *p) void test_wrange(struct testval *p) { struct testval f, l, s; - apr_status_t rc; + fspr_status_t rc; int success = 0; memcpy (&s, p, sizeof(s)); ++s.wl; do { - apr_size_t nl = sizeof(s.n), wl = s.wl; - rc = apr_conv_ucs2_to_utf8(s.w, &wl, s.n, &nl); + fspr_size_t nl = sizeof(s.n), wl = s.wl; + rc = fspr_conv_ucs2_to_utf8(s.w, &wl, s.n, &nl); s.nl = sizeof(s.n) - nl; if (!wl && rc == APR_SUCCESS) { if (!success) { @@ -146,7 +146,7 @@ void test_wrange(struct testval *p) do { int wl = s.wl, nl = sizeof(s.n); - rc = apr_conv_ucs2_to_utf8(s.w, &wl, s.n, &nl); + rc = fspr_conv_ucs2_to_utf8(s.w, &wl, s.n, &nl); s.nl = sizeof(s.n) - s.nl; if (rc == APR_INCOMPLETE) { test_wrange(&s); @@ -164,11 +164,11 @@ int main(int argc, char **argv) struct testval s; memset (&s, 0, sizeof(s)); - if (argc < 2 || apr_tolower(*argv[1]) != 'w') { + if (argc < 2 || fspr_tolower(*argv[1]) != 'w') { printf ("\n\nTesting Narrow Char Ranges\n"); test_nrange(&s); } - if (argc < 2 || apr_tolower(*argv[1]) != 'n') { + if (argc < 2 || fspr_tolower(*argv[1]) != 'n') { printf ("\n\nTesting Wide Char Ranges\n"); test_wrange(&s); } diff --git a/libs/apr/test/mod_test.c b/libs/apr/test/mod_test.c index 2178e94059..ecae249f9f 100644 --- a/libs/apr/test/mod_test.c +++ b/libs/apr/test/mod_test.c @@ -14,14 +14,14 @@ * limitations under the License. */ -#include "apr_strings.h" +#include "fspr_strings.h" void print_hello(char str[256]); int count_reps(int reps); void print_hello(char str[256]) { - apr_cpystrn(str, "Hello - I'm a DSO!\n", strlen("Hello - I'm a DSO!\n") + 1); + fspr_cpystrn(str, "Hello - I'm a DSO!\n", strlen("Hello - I'm a DSO!\n") + 1); } int count_reps(int reps) diff --git a/libs/apr/test/occhild.c b/libs/apr/test/occhild.c index a96885d827..09954d1ac5 100644 --- a/libs/apr/test/occhild.c +++ b/libs/apr/test/occhild.c @@ -1,6 +1,6 @@ -#include "apr.h" -#include "apr_file_io.h" -#include "apr.h" +#include "fspr.h" +#include "fspr_file_io.h" +#include "fspr.h" #if APR_HAVE_STDLIB_H #include @@ -9,18 +9,18 @@ int main(void) { char buf[256]; - apr_file_t *err; - apr_pool_t *p; + fspr_file_t *err; + fspr_pool_t *p; - apr_initialize(); - atexit(apr_terminate); + fspr_initialize(); + atexit(fspr_terminate); - apr_pool_create(&p, NULL); - apr_file_open_stdin(&err, p); + fspr_pool_create(&p, NULL); + fspr_file_open_stdin(&err, p); while (1) { - apr_size_t length = 256; - apr_file_read(err, buf, &length); + fspr_size_t length = 256; + fspr_file_read(err, buf, &length); } exit(0); /* just to keep the compiler happy */ } diff --git a/libs/apr/test/proc_child.c b/libs/apr/test/proc_child.c index 405bb7f5b6..b712dddcee 100644 --- a/libs/apr/test/proc_child.c +++ b/libs/apr/test/proc_child.c @@ -1,4 +1,4 @@ -#include "apr.h" +#include "fspr.h" #include #if APR_HAVE_UNISTD_H #include @@ -11,7 +11,7 @@ int main(void) { char buf[256]; - apr_ssize_t bytes; + fspr_ssize_t bytes; bytes = read(STDIN_FILENO, buf, 256); if (bytes > 0) diff --git a/libs/apr/test/readchild.c b/libs/apr/test/readchild.c index f8443cceb8..92eb1af06c 100644 --- a/libs/apr/test/readchild.c +++ b/libs/apr/test/readchild.c @@ -16,31 +16,31 @@ #include -#include "apr_file_io.h" +#include "fspr_file_io.h" int main(int argc, char *argv[]) { - apr_file_t *in, *out; - apr_size_t nbytes, total_bytes; - apr_pool_t *p; + fspr_file_t *in, *out; + fspr_size_t nbytes, total_bytes; + fspr_pool_t *p; char buf[128]; - apr_status_t rv; + fspr_status_t rv; - apr_initialize(); - atexit(apr_terminate); - apr_pool_create(&p, NULL); + fspr_initialize(); + atexit(fspr_terminate); + fspr_pool_create(&p, NULL); - apr_file_open_stdin(&in, p); - apr_file_open_stdout(&out, p); + fspr_file_open_stdin(&in, p); + fspr_file_open_stdout(&out, p); total_bytes = 0; nbytes = sizeof(buf); - while ((rv = apr_file_read(in, buf, &nbytes)) == APR_SUCCESS) { + while ((rv = fspr_file_read(in, buf, &nbytes)) == APR_SUCCESS) { total_bytes += nbytes; nbytes = sizeof(buf); } - apr_file_printf(out, "%" APR_SIZE_T_FMT " bytes were read\n", + fspr_file_printf(out, "%" APR_SIZE_T_FMT " bytes were read\n", total_bytes); return 0; } diff --git a/libs/apr/test/sendfile.c b/libs/apr/test/sendfile.c index cfa1fb8a76..a788ba98b9 100644 --- a/libs/apr/test/sendfile.c +++ b/libs/apr/test/sendfile.c @@ -19,10 +19,10 @@ #include #include #include -#include "apr_network_io.h" -#include "apr_errno.h" -#include "apr_general.h" -#include "apr_poll.h" +#include "fspr_network_io.h" +#include "fspr_errno.h" +#include "fspr_general.h" +#include "fspr_poll.h" #if !APR_HAS_SENDFILE int main(void) @@ -53,103 +53,103 @@ int main(void) typedef enum {BLK, NONBLK, TIMEOUT} client_socket_mode_t; -static void apr_setup(apr_pool_t **p, apr_socket_t **sock, int *family) +static void fspr_setup(fspr_pool_t **p, fspr_socket_t **sock, int *family) { char buf[120]; - apr_status_t rv; + fspr_status_t rv; - rv = apr_initialize(); + rv = fspr_initialize(); if (rv != APR_SUCCESS) { - fprintf(stderr, "apr_initialize()->%d/%s\n", + fprintf(stderr, "fspr_initialize()->%d/%s\n", rv, - apr_strerror(rv, buf, sizeof buf)); + fspr_strerror(rv, buf, sizeof buf)); exit(1); } - atexit(apr_terminate); + atexit(fspr_terminate); - rv = apr_pool_create(p, NULL); + rv = fspr_pool_create(p, NULL); if (rv != APR_SUCCESS) { - fprintf(stderr, "apr_pool_create()->%d/%s\n", + fprintf(stderr, "fspr_pool_create()->%d/%s\n", rv, - apr_strerror(rv, buf, sizeof buf)); + fspr_strerror(rv, buf, sizeof buf)); exit(1); } *sock = NULL; - rv = apr_socket_create(sock, *family, SOCK_STREAM, 0, *p); + rv = fspr_socket_create(sock, *family, SOCK_STREAM, 0, *p); if (rv != APR_SUCCESS) { - fprintf(stderr, "apr_socket_create()->%d/%s\n", + fprintf(stderr, "fspr_socket_create()->%d/%s\n", rv, - apr_strerror(rv, buf, sizeof buf)); + fspr_strerror(rv, buf, sizeof buf)); exit(1); } if (*family == APR_UNSPEC) { - apr_sockaddr_t *localsa; + fspr_sockaddr_t *localsa; - rv = apr_socket_addr_get(&localsa, APR_LOCAL, *sock); + rv = fspr_socket_addr_get(&localsa, APR_LOCAL, *sock); if (rv != APR_SUCCESS) { - fprintf(stderr, "apr_socket_addr_get()->%d/%s\n", + fprintf(stderr, "fspr_socket_addr_get()->%d/%s\n", rv, - apr_strerror(rv, buf, sizeof buf)); + fspr_strerror(rv, buf, sizeof buf)); exit(1); } *family = localsa->family; } } -static void create_testfile(apr_pool_t *p, const char *fname) +static void create_testfile(fspr_pool_t *p, const char *fname) { - apr_file_t *f = NULL; - apr_status_t rv; + fspr_file_t *f = NULL; + fspr_status_t rv; char buf[120]; int i; - apr_finfo_t finfo; + fspr_finfo_t finfo; printf("Creating a test file...\n"); - rv = apr_file_open(&f, fname, + rv = fspr_file_open(&f, fname, APR_CREATE | APR_WRITE | APR_TRUNCATE | APR_BUFFERED, APR_UREAD | APR_UWRITE, p); if (rv) { - fprintf(stderr, "apr_file_open()->%d/%s\n", - rv, apr_strerror(rv, buf, sizeof buf)); + fprintf(stderr, "fspr_file_open()->%d/%s\n", + rv, fspr_strerror(rv, buf, sizeof buf)); exit(1); } buf[0] = FILE_DATA_CHAR; buf[1] = '\0'; for (i = 0; i < FILE_LENGTH; i++) { - /* exercise apr_file_putc() and apr_file_puts() on buffered files */ + /* exercise fspr_file_putc() and fspr_file_puts() on buffered files */ if ((i % 2) == 0) { - rv = apr_file_putc(buf[0], f); + rv = fspr_file_putc(buf[0], f); if (rv) { - fprintf(stderr, "apr_file_putc()->%d/%s\n", - rv, apr_strerror(rv, buf, sizeof buf)); + fprintf(stderr, "fspr_file_putc()->%d/%s\n", + rv, fspr_strerror(rv, buf, sizeof buf)); exit(1); } } else { - rv = apr_file_puts(buf, f); + rv = fspr_file_puts(buf, f); if (rv) { - fprintf(stderr, "apr_file_puts()->%d/%s\n", - rv, apr_strerror(rv, buf, sizeof buf)); + fprintf(stderr, "fspr_file_puts()->%d/%s\n", + rv, fspr_strerror(rv, buf, sizeof buf)); exit(1); } } } - rv = apr_file_close(f); + rv = fspr_file_close(f); if (rv) { - fprintf(stderr, "apr_file_close()->%d/%s\n", - rv, apr_strerror(rv, buf, sizeof buf)); + fprintf(stderr, "fspr_file_close()->%d/%s\n", + rv, fspr_strerror(rv, buf, sizeof buf)); exit(1); } - rv = apr_stat(&finfo, fname, APR_FINFO_NORM, p); + rv = fspr_stat(&finfo, fname, APR_FINFO_NORM, p); if (rv != APR_SUCCESS && rv != APR_INCOMPLETE) { - fprintf(stderr, "apr_stat()->%d/%s\n", - rv, apr_strerror(rv, buf, sizeof buf)); + fprintf(stderr, "fspr_stat()->%d/%s\n", + rv, fspr_strerror(rv, buf, sizeof buf)); exit(1); } @@ -166,52 +166,52 @@ static void create_testfile(apr_pool_t *p, const char *fname) static int client(client_socket_mode_t socket_mode, char *host) { - apr_status_t rv, tmprv; - apr_socket_t *sock; - apr_pool_t *p; + fspr_status_t rv, tmprv; + fspr_socket_t *sock; + fspr_pool_t *p; char buf[120]; - apr_file_t *f = NULL; - apr_size_t len; - apr_size_t expected_len; - apr_off_t current_file_offset; - apr_hdtr_t hdtr; + fspr_file_t *f = NULL; + fspr_size_t len; + fspr_size_t expected_len; + fspr_off_t current_file_offset; + fspr_hdtr_t hdtr; struct iovec headers[3]; struct iovec trailers[3]; - apr_size_t bytes_read; - apr_pollset_t *pset; - apr_int32_t nsocks; + fspr_size_t bytes_read; + fspr_pollset_t *pset; + fspr_int32_t nsocks; int i; int family; - apr_sockaddr_t *destsa; + fspr_sockaddr_t *destsa; family = APR_INET; - apr_setup(&p, &sock, &family); + fspr_setup(&p, &sock, &family); create_testfile(p, TESTFILE); - rv = apr_file_open(&f, TESTFILE, APR_READ, 0, p); + rv = fspr_file_open(&f, TESTFILE, APR_READ, 0, p); if (rv != APR_SUCCESS) { - fprintf(stderr, "apr_file_open()->%d/%s\n", + fprintf(stderr, "fspr_file_open()->%d/%s\n", rv, - apr_strerror(rv, buf, sizeof buf)); + fspr_strerror(rv, buf, sizeof buf)); exit(1); } if (!host) { host = "127.0.0.1"; } - rv = apr_sockaddr_info_get(&destsa, host, family, TESTSF_PORT, 0, p); + rv = fspr_sockaddr_info_get(&destsa, host, family, TESTSF_PORT, 0, p); if (rv != APR_SUCCESS) { - fprintf(stderr, "apr_sockaddr_info_get()->%d/%s\n", + fprintf(stderr, "fspr_sockaddr_info_get()->%d/%s\n", rv, - apr_strerror(rv, buf, sizeof buf)); + fspr_strerror(rv, buf, sizeof buf)); exit(1); } - rv = apr_socket_connect(sock, destsa); + rv = fspr_socket_connect(sock, destsa); if (rv != APR_SUCCESS) { - fprintf(stderr, "apr_socket_connect()->%d/%s\n", + fprintf(stderr, "fspr_socket_connect()->%d/%s\n", rv, - apr_strerror(rv, buf, sizeof buf)); + fspr_strerror(rv, buf, sizeof buf)); exit(1); } @@ -221,21 +221,21 @@ static int client(client_socket_mode_t socket_mode, char *host) break; case NONBLK: /* set it non-blocking */ - rv = apr_socket_opt_set(sock, APR_SO_NONBLOCK, 1); + rv = fspr_socket_opt_set(sock, APR_SO_NONBLOCK, 1); if (rv != APR_SUCCESS) { - fprintf(stderr, "apr_socket_opt_set(APR_SO_NONBLOCK)->%d/%s\n", + fprintf(stderr, "fspr_socket_opt_set(APR_SO_NONBLOCK)->%d/%s\n", rv, - apr_strerror(rv, buf, sizeof buf)); + fspr_strerror(rv, buf, sizeof buf)); exit(1); } break; case TIMEOUT: /* set a timeout */ - rv = apr_socket_timeout_set(sock, 100 * APR_USEC_PER_SEC); + rv = fspr_socket_timeout_set(sock, 100 * APR_USEC_PER_SEC); if (rv != APR_SUCCESS) { - fprintf(stderr, "apr_socket_opt_set(APR_SO_NONBLOCK)->%d/%s\n", + fprintf(stderr, "fspr_socket_opt_set(APR_SO_NONBLOCK)->%d/%s\n", rv, - apr_strerror(rv, buf, sizeof buf)); + fspr_strerror(rv, buf, sizeof buf)); exit(1); } break; @@ -275,36 +275,36 @@ static int client(client_socket_mode_t socket_mode, char *host) if (socket_mode == BLK) { current_file_offset = 0; len = FILE_LENGTH; - rv = apr_socket_sendfile(sock, f, &hdtr, ¤t_file_offset, &len, 0); + rv = fspr_socket_sendfile(sock, f, &hdtr, ¤t_file_offset, &len, 0); if (rv != APR_SUCCESS) { - fprintf(stderr, "apr_socket_sendfile()->%d/%s\n", + fprintf(stderr, "fspr_socket_sendfile()->%d/%s\n", rv, - apr_strerror(rv, buf, sizeof buf)); + fspr_strerror(rv, buf, sizeof buf)); exit(1); } - printf("apr_socket_sendfile() updated offset with %ld\n", + printf("fspr_socket_sendfile() updated offset with %ld\n", (long int)current_file_offset); - printf("apr_socket_sendfile() updated len with %ld\n", + printf("fspr_socket_sendfile() updated len with %ld\n", (long int)len); printf("bytes really sent: %" APR_SIZE_T_FMT "\n", expected_len); if (len != expected_len) { - fprintf(stderr, "apr_socket_sendfile() didn't report the correct " + fprintf(stderr, "fspr_socket_sendfile() didn't report the correct " "number of bytes sent!\n"); exit(1); } } else { /* non-blocking... wooooooo */ - apr_size_t total_bytes_sent; - apr_pollfd_t pfd; + fspr_size_t total_bytes_sent; + fspr_pollfd_t pfd; pset = NULL; - rv = apr_pollset_create(&pset, 1, p, 0); + rv = fspr_pollset_create(&pset, 1, p, 0); assert(!rv); pfd.p = p; pfd.desc_type = APR_POLL_SOCKET; @@ -313,17 +313,17 @@ static int client(client_socket_mode_t socket_mode, char *host) pfd.desc.s = sock; pfd.client_data = NULL; - rv = apr_pollset_add(pset, &pfd); + rv = fspr_pollset_add(pset, &pfd); assert(!rv); total_bytes_sent = 0; current_file_offset = 0; len = FILE_LENGTH; do { - apr_size_t tmplen; + fspr_size_t tmplen; tmplen = len; /* bytes remaining to send from the file */ - printf("Calling apr_socket_sendfile()...\n"); + printf("Calling fspr_socket_sendfile()...\n"); printf("Headers (%d):\n", hdtr.numheaders); for (i = 0; i < hdtr.numheaders; i++) { printf("\t%ld bytes (%c)\n", @@ -338,13 +338,13 @@ static int client(client_socket_mode_t socket_mode, char *host) (long)hdtr.trailers[i].iov_len); } - rv = apr_socket_sendfile(sock, f, &hdtr, ¤t_file_offset, &tmplen, 0); - printf("apr_socket_sendfile()->%d, sent %ld bytes\n", rv, (long)tmplen); + rv = fspr_socket_sendfile(sock, f, &hdtr, ¤t_file_offset, &tmplen, 0); + printf("fspr_socket_sendfile()->%d, sent %ld bytes\n", rv, (long)tmplen); if (rv) { if (APR_STATUS_IS_EAGAIN(rv)) { assert(tmplen == 0); nsocks = 1; - tmprv = apr_pollset_poll(pset, -1, &nsocks, NULL); + tmprv = fspr_pollset_poll(pset, -1, &nsocks, NULL); assert(!tmprv); assert(nsocks == 1); /* continue; */ @@ -426,43 +426,43 @@ static int client(client_socket_mode_t socket_mode, char *host) } current_file_offset = 0; - rv = apr_file_seek(f, APR_CUR, ¤t_file_offset); + rv = fspr_file_seek(f, APR_CUR, ¤t_file_offset); if (rv != APR_SUCCESS) { - fprintf(stderr, "apr_file_seek()->%d/%s\n", + fprintf(stderr, "fspr_file_seek()->%d/%s\n", rv, - apr_strerror(rv, buf, sizeof buf)); + fspr_strerror(rv, buf, sizeof buf)); exit(1); } - printf("After apr_socket_sendfile(), the kernel file pointer is " + printf("After fspr_socket_sendfile(), the kernel file pointer is " "at offset %ld.\n", (long int)current_file_offset); - rv = apr_socket_shutdown(sock, APR_SHUTDOWN_WRITE); + rv = fspr_socket_shutdown(sock, APR_SHUTDOWN_WRITE); if (rv != APR_SUCCESS) { - fprintf(stderr, "apr_socket_shutdown()->%d/%s\n", + fprintf(stderr, "fspr_socket_shutdown()->%d/%s\n", rv, - apr_strerror(rv, buf, sizeof buf)); + fspr_strerror(rv, buf, sizeof buf)); exit(1); } /* in case this is the non-blocking test, set socket timeout; * we're just waiting for EOF */ - rv = apr_socket_timeout_set(sock, apr_time_from_sec(3)); + rv = fspr_socket_timeout_set(sock, fspr_time_from_sec(3)); if (rv != APR_SUCCESS) { - fprintf(stderr, "apr_socket_timeout_set()->%d/%s\n", + fprintf(stderr, "fspr_socket_timeout_set()->%d/%s\n", rv, - apr_strerror(rv, buf, sizeof buf)); + fspr_strerror(rv, buf, sizeof buf)); exit(1); } bytes_read = 1; - rv = apr_socket_recv(sock, buf, &bytes_read); + rv = fspr_socket_recv(sock, buf, &bytes_read); if (rv != APR_EOF) { - fprintf(stderr, "apr_socket_recv()->%d/%s (expected APR_EOF)\n", + fprintf(stderr, "fspr_socket_recv()->%d/%s (expected APR_EOF)\n", rv, - apr_strerror(rv, buf, sizeof buf)); + fspr_strerror(rv, buf, sizeof buf)); exit(1); } if (bytes_read != 0) { @@ -472,13 +472,13 @@ static int client(client_socket_mode_t socket_mode, char *host) exit(1); } - printf("client: apr_socket_sendfile() worked as expected!\n"); + printf("client: fspr_socket_sendfile() worked as expected!\n"); - rv = apr_file_remove(TESTFILE, p); + rv = fspr_file_remove(TESTFILE, p); if (rv != APR_SUCCESS) { - fprintf(stderr, "apr_file_remove()->%d/%s\n", + fprintf(stderr, "fspr_file_remove()->%d/%s\n", rv, - apr_strerror(rv, buf, sizeof buf)); + fspr_strerror(rv, buf, sizeof buf)); exit(1); } @@ -487,58 +487,58 @@ static int client(client_socket_mode_t socket_mode, char *host) static int server(void) { - apr_status_t rv; - apr_socket_t *sock; - apr_pool_t *p; + fspr_status_t rv; + fspr_socket_t *sock; + fspr_pool_t *p; char buf[120]; int i; - apr_socket_t *newsock = NULL; - apr_size_t bytes_read; - apr_sockaddr_t *localsa; + fspr_socket_t *newsock = NULL; + fspr_size_t bytes_read; + fspr_sockaddr_t *localsa; int family; family = APR_UNSPEC; - apr_setup(&p, &sock, &family); + fspr_setup(&p, &sock, &family); - rv = apr_socket_opt_set(sock, APR_SO_REUSEADDR, 1); + rv = fspr_socket_opt_set(sock, APR_SO_REUSEADDR, 1); if (rv != APR_SUCCESS) { - fprintf(stderr, "apr_socket_opt_set()->%d/%s\n", + fprintf(stderr, "fspr_socket_opt_set()->%d/%s\n", rv, - apr_strerror(rv, buf, sizeof buf)); + fspr_strerror(rv, buf, sizeof buf)); exit(1); } - rv = apr_sockaddr_info_get(&localsa, NULL, family, TESTSF_PORT, 0, p); + rv = fspr_sockaddr_info_get(&localsa, NULL, family, TESTSF_PORT, 0, p); if (rv != APR_SUCCESS) { - fprintf(stderr, "apr_sockaddr_info_get()->%d/%s\n", + fprintf(stderr, "fspr_sockaddr_info_get()->%d/%s\n", rv, - apr_strerror(rv, buf, sizeof buf)); + fspr_strerror(rv, buf, sizeof buf)); exit(1); } - rv = apr_socket_bind(sock, localsa); + rv = fspr_socket_bind(sock, localsa); if (rv != APR_SUCCESS) { - fprintf(stderr, "apr_socket_bind()->%d/%s\n", + fprintf(stderr, "fspr_socket_bind()->%d/%s\n", rv, - apr_strerror(rv, buf, sizeof buf)); + fspr_strerror(rv, buf, sizeof buf)); exit(1); } - rv = apr_socket_listen(sock, 5); + rv = fspr_socket_listen(sock, 5); if (rv != APR_SUCCESS) { - fprintf(stderr, "apr_socket_listen()->%d/%s\n", + fprintf(stderr, "fspr_socket_listen()->%d/%s\n", rv, - apr_strerror(rv, buf, sizeof buf)); + fspr_strerror(rv, buf, sizeof buf)); exit(1); } printf("Waiting for a client to connect...\n"); - rv = apr_socket_accept(&newsock, sock, p); + rv = fspr_socket_accept(&newsock, sock, p); if (rv != APR_SUCCESS) { - fprintf(stderr, "apr_socket_accept()->%d/%s\n", + fprintf(stderr, "fspr_socket_accept()->%d/%s\n", rv, - apr_strerror(rv, buf, sizeof buf)); + fspr_strerror(rv, buf, sizeof buf)); exit(1); } @@ -546,11 +546,11 @@ static int server(void) assert(sizeof buf > strlen(HDR1)); bytes_read = strlen(HDR1); - rv = apr_socket_recv(newsock, buf, &bytes_read); + rv = fspr_socket_recv(newsock, buf, &bytes_read); if (rv != APR_SUCCESS) { - fprintf(stderr, "apr_socket_recv()->%d/%s\n", + fprintf(stderr, "fspr_socket_recv()->%d/%s\n", rv, - apr_strerror(rv, buf, sizeof buf)); + fspr_strerror(rv, buf, sizeof buf)); exit(1); } if (bytes_read != strlen(HDR1)) { @@ -566,11 +566,11 @@ static int server(void) assert(sizeof buf > strlen(HDR2)); bytes_read = strlen(HDR2); - rv = apr_socket_recv(newsock, buf, &bytes_read); + rv = fspr_socket_recv(newsock, buf, &bytes_read); if (rv != APR_SUCCESS) { - fprintf(stderr, "apr_socket_recv()->%d/%s\n", + fprintf(stderr, "fspr_socket_recv()->%d/%s\n", rv, - apr_strerror(rv, buf, sizeof buf)); + fspr_strerror(rv, buf, sizeof buf)); exit(1); } if (bytes_read != strlen(HDR2)) { @@ -586,15 +586,15 @@ static int server(void) for (i = 0; i < HDR3_LEN; i++) { bytes_read = 1; - rv = apr_socket_recv(newsock, buf, &bytes_read); + rv = fspr_socket_recv(newsock, buf, &bytes_read); if (rv != APR_SUCCESS) { - fprintf(stderr, "apr_socket_recv()->%d/%s\n", + fprintf(stderr, "fspr_socket_recv()->%d/%s\n", rv, - apr_strerror(rv, buf, sizeof buf)); + fspr_strerror(rv, buf, sizeof buf)); exit(1); } if (bytes_read != 1) { - fprintf(stderr, "apr_socket_recv()->%ld bytes instead of 1\n", + fprintf(stderr, "fspr_socket_recv()->%ld bytes instead of 1\n", (long int)bytes_read); exit(1); } @@ -611,15 +611,15 @@ static int server(void) for (i = 0; i < FILE_LENGTH; i++) { bytes_read = 1; - rv = apr_socket_recv(newsock, buf, &bytes_read); + rv = fspr_socket_recv(newsock, buf, &bytes_read); if (rv != APR_SUCCESS) { - fprintf(stderr, "apr_socket_recv()->%d/%s\n", + fprintf(stderr, "fspr_socket_recv()->%d/%s\n", rv, - apr_strerror(rv, buf, sizeof buf)); + fspr_strerror(rv, buf, sizeof buf)); exit(1); } if (bytes_read != 1) { - fprintf(stderr, "apr_socket_recv()->%ld bytes instead of 1\n", + fprintf(stderr, "fspr_socket_recv()->%ld bytes instead of 1\n", (long int)bytes_read); exit(1); } @@ -636,11 +636,11 @@ static int server(void) assert(sizeof buf > strlen(TRL1)); bytes_read = strlen(TRL1); - rv = apr_socket_recv(newsock, buf, &bytes_read); + rv = fspr_socket_recv(newsock, buf, &bytes_read); if (rv != APR_SUCCESS) { - fprintf(stderr, "apr_socket_recv()->%d/%s\n", + fprintf(stderr, "fspr_socket_recv()->%d/%s\n", rv, - apr_strerror(rv, buf, sizeof buf)); + fspr_strerror(rv, buf, sizeof buf)); exit(1); } if (bytes_read != strlen(TRL1)) { @@ -656,11 +656,11 @@ static int server(void) assert(sizeof buf > strlen(TRL2)); bytes_read = strlen(TRL2); - rv = apr_socket_recv(newsock, buf, &bytes_read); + rv = fspr_socket_recv(newsock, buf, &bytes_read); if (rv != APR_SUCCESS) { - fprintf(stderr, "apr_socket_recv()->%d/%s\n", + fprintf(stderr, "fspr_socket_recv()->%d/%s\n", rv, - apr_strerror(rv, buf, sizeof buf)); + fspr_strerror(rv, buf, sizeof buf)); exit(1); } if (bytes_read != strlen(TRL2)) { @@ -676,15 +676,15 @@ static int server(void) for (i = 0; i < TRL3_LEN; i++) { bytes_read = 1; - rv = apr_socket_recv(newsock, buf, &bytes_read); + rv = fspr_socket_recv(newsock, buf, &bytes_read); if (rv != APR_SUCCESS) { - fprintf(stderr, "apr_socket_recv()->%d/%s\n", + fprintf(stderr, "fspr_socket_recv()->%d/%s\n", rv, - apr_strerror(rv, buf, sizeof buf)); + fspr_strerror(rv, buf, sizeof buf)); exit(1); } if (bytes_read != 1) { - fprintf(stderr, "apr_socket_recv()->%ld bytes instead of 1\n", + fprintf(stderr, "fspr_socket_recv()->%ld bytes instead of 1\n", (long int)bytes_read); exit(1); } @@ -700,11 +700,11 @@ static int server(void) } bytes_read = 1; - rv = apr_socket_recv(newsock, buf, &bytes_read); + rv = fspr_socket_recv(newsock, buf, &bytes_read); if (rv != APR_EOF) { - fprintf(stderr, "apr_socket_recv()->%d/%s (expected APR_EOF)\n", + fprintf(stderr, "fspr_socket_recv()->%d/%s (expected APR_EOF)\n", rv, - apr_strerror(rv, buf, sizeof buf)); + fspr_strerror(rv, buf, sizeof buf)); exit(1); } if (bytes_read != 0) { @@ -714,7 +714,7 @@ static int server(void) exit(1); } - printf("server: apr_socket_sendfile() worked as expected!\n"); + printf("server: fspr_socket_sendfile() worked as expected!\n"); return 0; } diff --git a/libs/apr/test/sockchild.c b/libs/apr/test/sockchild.c index 5c15d113fb..d1d5e3a8b4 100644 --- a/libs/apr/test/sockchild.c +++ b/libs/apr/test/sockchild.c @@ -16,49 +16,49 @@ #include #include "testsock.h" -#include "apr_network_io.h" -#include "apr_pools.h" +#include "fspr_network_io.h" +#include "fspr_pools.h" int main(int argc, char *argv[]) { - apr_pool_t *p; - apr_socket_t *sock; - apr_status_t rv; - apr_sockaddr_t *remote_sa; + fspr_pool_t *p; + fspr_socket_t *sock; + fspr_status_t rv; + fspr_sockaddr_t *remote_sa; - apr_initialize(); - atexit(apr_terminate); - apr_pool_create(&p, NULL); + fspr_initialize(); + atexit(fspr_terminate); + fspr_pool_create(&p, NULL); if (argc < 2) { exit(-1); } - rv = apr_sockaddr_info_get(&remote_sa, "127.0.0.1", APR_UNSPEC, 8021, 0, p); + rv = fspr_sockaddr_info_get(&remote_sa, "127.0.0.1", APR_UNSPEC, 8021, 0, p); if (rv != APR_SUCCESS) { exit(-1); } - if (apr_socket_create(&sock, remote_sa->family, SOCK_STREAM, 0, + if (fspr_socket_create(&sock, remote_sa->family, SOCK_STREAM, 0, p) != APR_SUCCESS) { exit(-1); } - rv = apr_socket_timeout_set(sock, apr_time_from_sec(3)); + rv = fspr_socket_timeout_set(sock, fspr_time_from_sec(3)); if (rv) { exit(-1); } - apr_socket_connect(sock, remote_sa); + fspr_socket_connect(sock, remote_sa); if (!strcmp("read", argv[1])) { char datarecv[STRLEN]; - apr_size_t length = STRLEN; - apr_status_t rv; + fspr_size_t length = STRLEN; + fspr_status_t rv; memset(datarecv, 0, STRLEN); - rv = apr_socket_recv(sock, datarecv, &length); - apr_socket_close(sock); + rv = fspr_socket_recv(sock, datarecv, &length); + fspr_socket_close(sock); if (APR_STATUS_IS_TIMEUP(rv)) { exit(SOCKET_TIMEOUT); } @@ -70,10 +70,10 @@ int main(int argc, char *argv[]) exit(length); } else if (!strcmp("write", argv[1])) { - apr_size_t length = strlen(DATASTR); - apr_socket_send(sock, DATASTR, &length); + fspr_size_t length = strlen(DATASTR); + fspr_socket_send(sock, DATASTR, &length); - apr_socket_close(sock); + fspr_socket_close(sock); exit(length); } exit(-1); diff --git a/libs/apr/test/testapp.c b/libs/apr/test/testapp.c index 77607aa388..53b3dfedb3 100644 --- a/libs/apr/test/testapp.c +++ b/libs/apr/test/testapp.c @@ -1,10 +1,10 @@ -#include -#include +#include +#include int main(int argc, const char * const * argv, const char * const *env) { - apr_app_initialize(&argc, &argv, &env); + fspr_app_initialize(&argc, &argv, &env); - apr_terminate(); + fspr_terminate(); } diff --git a/libs/apr/test/testargs.c b/libs/apr/test/testargs.c index cb501924f1..9aab69e4f2 100644 --- a/libs/apr/test/testargs.c +++ b/libs/apr/test/testargs.c @@ -14,19 +14,19 @@ * limitations under the License. */ -#include "apr_errno.h" -#include "apr_general.h" -#include "apr_getopt.h" -#include "apr_strings.h" +#include "fspr_errno.h" +#include "fspr_general.h" +#include "fspr_getopt.h" +#include "fspr_strings.h" #include "testutil.h" static void format_arg(char *str, char option, const char *arg) { if (arg) { - apr_snprintf(str, 8196, "%soption: %c with %s\n", str, option, arg); + fspr_snprintf(str, 8196, "%soption: %c with %s\n", str, option, arg); } else { - apr_snprintf(str, 8196, "%soption: %c\n", str, option); + fspr_snprintf(str, 8196, "%soption: %c\n", str, option); } } @@ -35,7 +35,7 @@ static void unknown_arg(void *str, const char *err, ...) va_list va; va_start(va, err); - apr_vsnprintf(str, 8196, err, va); + fspr_vsnprintf(str, 8196, err, va); va_end(va); } @@ -43,17 +43,17 @@ static void no_options_found(abts_case *tc, void *data) { int largc = 5; const char * const largv[] = {"testprog", "-a", "-b", "-c", "-d"}; - apr_getopt_t *opt; - apr_status_t rv; + fspr_getopt_t *opt; + fspr_status_t rv; char ch; const char *optarg; char str[8196]; str[0] = '\0'; - rv = apr_getopt_init(&opt, p, largc, largv); + rv = fspr_getopt_init(&opt, p, largc, largv); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - while (apr_getopt(opt, "abcd", &ch, &optarg) == APR_SUCCESS) { + while (fspr_getopt(opt, "abcd", &ch, &optarg) == APR_SUCCESS) { switch (ch) { case 'a': case 'b': @@ -73,20 +73,20 @@ static void no_options(abts_case *tc, void *data) { int largc = 5; const char * const largv[] = {"testprog", "-a", "-b", "-c", "-d"}; - apr_getopt_t *opt; - apr_status_t rv; + fspr_getopt_t *opt; + fspr_status_t rv; char ch; const char *optarg; char str[8196]; str[0] = '\0'; - rv = apr_getopt_init(&opt, p, largc, largv); + rv = fspr_getopt_init(&opt, p, largc, largv); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); opt->errfn = unknown_arg; opt->errarg = str; - while (apr_getopt(opt, "efgh", &ch, &optarg) == APR_SUCCESS) { + while (fspr_getopt(opt, "efgh", &ch, &optarg) == APR_SUCCESS) { switch (ch) { case 'a': case 'b': @@ -105,20 +105,20 @@ static void required_option(abts_case *tc, void *data) { int largc = 3; const char * const largv[] = {"testprog", "-a", "foo"}; - apr_getopt_t *opt; - apr_status_t rv; + fspr_getopt_t *opt; + fspr_status_t rv; char ch; const char *optarg; char str[8196]; str[0] = '\0'; - rv = apr_getopt_init(&opt, p, largc, largv); + rv = fspr_getopt_init(&opt, p, largc, largv); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); opt->errfn = unknown_arg; opt->errarg = str; - while (apr_getopt(opt, "a:", &ch, &optarg) == APR_SUCCESS) { + while (fspr_getopt(opt, "a:", &ch, &optarg) == APR_SUCCESS) { switch (ch) { case 'a': format_arg(str, ch, optarg); @@ -134,20 +134,20 @@ static void required_option_notgiven(abts_case *tc, void *data) { int largc = 2; const char * const largv[] = {"testprog", "-a"}; - apr_getopt_t *opt; - apr_status_t rv; + fspr_getopt_t *opt; + fspr_status_t rv; char ch; const char *optarg; char str[8196]; str[0] = '\0'; - rv = apr_getopt_init(&opt, p, largc, largv); + rv = fspr_getopt_init(&opt, p, largc, largv); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); opt->errfn = unknown_arg; opt->errarg = str; - while (apr_getopt(opt, "a:", &ch, &optarg) == APR_SUCCESS) { + while (fspr_getopt(opt, "a:", &ch, &optarg) == APR_SUCCESS) { switch (ch) { case 'a': format_arg(str, ch, optarg); @@ -163,20 +163,20 @@ static void optional_option(abts_case *tc, void *data) { int largc = 3; const char * const largv[] = {"testprog", "-a", "foo"}; - apr_getopt_t *opt; - apr_status_t rv; + fspr_getopt_t *opt; + fspr_status_t rv; char ch; const char *optarg; char str[8196]; str[0] = '\0'; - rv = apr_getopt_init(&opt, p, largc, largv); + rv = fspr_getopt_init(&opt, p, largc, largv); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); opt->errfn = unknown_arg; opt->errarg = str; - while (apr_getopt(opt, "a::", &ch, &optarg) == APR_SUCCESS) { + while (fspr_getopt(opt, "a::", &ch, &optarg) == APR_SUCCESS) { switch (ch) { case 'a': format_arg(str, ch, optarg); @@ -192,20 +192,20 @@ static void optional_option_notgiven(abts_case *tc, void *data) { int largc = 2; const char * const largv[] = {"testprog", "-a"}; - apr_getopt_t *opt; - apr_status_t rv; + fspr_getopt_t *opt; + fspr_status_t rv; char ch; const char *optarg; char str[8196]; str[0] = '\0'; - rv = apr_getopt_init(&opt, p, largc, largv); + rv = fspr_getopt_init(&opt, p, largc, largv); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); opt->errfn = unknown_arg; opt->errarg = str; - while (apr_getopt(opt, "a::", &ch, &optarg) == APR_SUCCESS) { + while (fspr_getopt(opt, "a::", &ch, &optarg) == APR_SUCCESS) { switch (ch) { case 'a': format_arg(str, ch, optarg); diff --git a/libs/apr/test/testatomic.c b/libs/apr/test/testatomic.c index 7fae5c759f..c3ae095798 100644 --- a/libs/apr/test/testatomic.c +++ b/libs/apr/test/testatomic.c @@ -15,12 +15,12 @@ */ #include "testutil.h" -#include "apr_strings.h" -#include "apr_thread_proc.h" -#include "apr_errno.h" -#include "apr_general.h" -#include "apr_atomic.h" -#include "apr_time.h" +#include "fspr_strings.h" +#include "fspr_thread_proc.h" +#include "fspr_errno.h" +#include "fspr_general.h" +#include "fspr_atomic.h" +#include "fspr_time.h" /* Use pthread_setconcurrency where it is available and not a nullop, * i.e. platforms using M:N or M:1 thread models: */ @@ -36,46 +36,46 @@ static void test_init(abts_case *tc, void *data) { - APR_ASSERT_SUCCESS(tc, "Could not initliaze atomics", apr_atomic_init(p)); + APR_ASSERT_SUCCESS(tc, "Could not initliaze atomics", fspr_atomic_init(p)); } static void test_set32(abts_case *tc, void *data) { - apr_uint32_t y32; - apr_atomic_set32(&y32, 2); + fspr_uint32_t y32; + fspr_atomic_set32(&y32, 2); ABTS_INT_EQUAL(tc, 2, y32); } static void test_read32(abts_case *tc, void *data) { - apr_uint32_t y32; - apr_atomic_set32(&y32, 2); - ABTS_INT_EQUAL(tc, 2, apr_atomic_read32(&y32)); + fspr_uint32_t y32; + fspr_atomic_set32(&y32, 2); + ABTS_INT_EQUAL(tc, 2, fspr_atomic_read32(&y32)); } static void test_dec32(abts_case *tc, void *data) { - apr_uint32_t y32; + fspr_uint32_t y32; int rv; - apr_atomic_set32(&y32, 2); + fspr_atomic_set32(&y32, 2); - rv = apr_atomic_dec32(&y32); + rv = fspr_atomic_dec32(&y32); ABTS_INT_EQUAL(tc, 1, y32); ABTS_ASSERT(tc, "atomic_dec returned zero when it shouldn't", rv != 0); - rv = apr_atomic_dec32(&y32); + rv = fspr_atomic_dec32(&y32); ABTS_INT_EQUAL(tc, 0, y32); ABTS_ASSERT(tc, "atomic_dec didn't returned zero when it should", rv == 0); } static void test_xchg32(abts_case *tc, void *data) { - apr_uint32_t oldval; - apr_uint32_t y32; + fspr_uint32_t oldval; + fspr_uint32_t y32; - apr_atomic_set32(&y32, 100); - oldval = apr_atomic_xchg32(&y32, 50); + fspr_atomic_set32(&y32, 100); + oldval = fspr_atomic_xchg32(&y32, 50); ABTS_INT_EQUAL(tc, 100, oldval); ABTS_INT_EQUAL(tc, 50, y32); @@ -83,182 +83,182 @@ static void test_xchg32(abts_case *tc, void *data) static void test_cas_equal(abts_case *tc, void *data) { - apr_uint32_t casval = 0; - apr_uint32_t oldval; + fspr_uint32_t casval = 0; + fspr_uint32_t oldval; - oldval = apr_atomic_cas32(&casval, 12, 0); + oldval = fspr_atomic_cas32(&casval, 12, 0); ABTS_INT_EQUAL(tc, 0, oldval); ABTS_INT_EQUAL(tc, 12, casval); } static void test_cas_equal_nonnull(abts_case *tc, void *data) { - apr_uint32_t casval = 12; - apr_uint32_t oldval; + fspr_uint32_t casval = 12; + fspr_uint32_t oldval; - oldval = apr_atomic_cas32(&casval, 23, 12); + oldval = fspr_atomic_cas32(&casval, 23, 12); ABTS_INT_EQUAL(tc, 12, oldval); ABTS_INT_EQUAL(tc, 23, casval); } static void test_cas_notequal(abts_case *tc, void *data) { - apr_uint32_t casval = 12; - apr_uint32_t oldval; + fspr_uint32_t casval = 12; + fspr_uint32_t oldval; - oldval = apr_atomic_cas32(&casval, 23, 2); + oldval = fspr_atomic_cas32(&casval, 23, 2); ABTS_INT_EQUAL(tc, 12, oldval); ABTS_INT_EQUAL(tc, 12, casval); } static void test_add32(abts_case *tc, void *data) { - apr_uint32_t oldval; - apr_uint32_t y32; + fspr_uint32_t oldval; + fspr_uint32_t y32; - apr_atomic_set32(&y32, 23); - oldval = apr_atomic_add32(&y32, 4); + fspr_atomic_set32(&y32, 23); + oldval = fspr_atomic_add32(&y32, 4); ABTS_INT_EQUAL(tc, 23, oldval); ABTS_INT_EQUAL(tc, 27, y32); } static void test_inc32(abts_case *tc, void *data) { - apr_uint32_t oldval; - apr_uint32_t y32; + fspr_uint32_t oldval; + fspr_uint32_t y32; - apr_atomic_set32(&y32, 23); - oldval = apr_atomic_inc32(&y32); + fspr_atomic_set32(&y32, 23); + oldval = fspr_atomic_inc32(&y32); ABTS_INT_EQUAL(tc, 23, oldval); ABTS_INT_EQUAL(tc, 24, y32); } static void test_set_add_inc_sub(abts_case *tc, void *data) { - apr_uint32_t y32; + fspr_uint32_t y32; - apr_atomic_set32(&y32, 0); - apr_atomic_add32(&y32, 20); - apr_atomic_inc32(&y32); - apr_atomic_sub32(&y32, 10); + fspr_atomic_set32(&y32, 0); + fspr_atomic_add32(&y32, 20); + fspr_atomic_inc32(&y32); + fspr_atomic_sub32(&y32, 10); ABTS_INT_EQUAL(tc, 11, y32); } static void test_wrap_zero(abts_case *tc, void *data) { - apr_uint32_t y32; - apr_uint32_t rv; - apr_uint32_t minus1 = -1; + fspr_uint32_t y32; + fspr_uint32_t rv; + fspr_uint32_t minus1 = -1; char *str; - apr_atomic_set32(&y32, 0); - rv = apr_atomic_dec32(&y32); + fspr_atomic_set32(&y32, 0); + rv = fspr_atomic_dec32(&y32); - ABTS_ASSERT(tc, "apr_atomic_dec32 on zero returned zero.", rv != 0); - str = apr_psprintf(p, "zero wrap failed: 0 - 1 = %d", y32); + ABTS_ASSERT(tc, "fspr_atomic_dec32 on zero returned zero.", rv != 0); + str = fspr_psprintf(p, "zero wrap failed: 0 - 1 = %d", y32); ABTS_ASSERT(tc, str, y32 == minus1); } static void test_inc_neg1(abts_case *tc, void *data) { - apr_uint32_t y32 = -1; - apr_uint32_t minus1 = -1; - apr_uint32_t rv; + fspr_uint32_t y32 = -1; + fspr_uint32_t minus1 = -1; + fspr_uint32_t rv; char *str; - rv = apr_atomic_inc32(&y32); + rv = fspr_atomic_inc32(&y32); - ABTS_ASSERT(tc, "apr_atomic_dec32 on zero returned zero.", rv == minus1); - str = apr_psprintf(p, "zero wrap failed: -1 + 1 = %d", y32); + ABTS_ASSERT(tc, "fspr_atomic_dec32 on zero returned zero.", rv == minus1); + str = fspr_psprintf(p, "zero wrap failed: -1 + 1 = %d", y32); ABTS_ASSERT(tc, str, y32 == 0); } #if APR_HAS_THREADS -void * APR_THREAD_FUNC thread_func_mutex(apr_thread_t *thd, void *data); -void * APR_THREAD_FUNC thread_func_atomic(apr_thread_t *thd, void *data); -void * APR_THREAD_FUNC thread_func_none(apr_thread_t *thd, void *data); +void * APR_THREAD_FUNC thread_func_mutex(fspr_thread_t *thd, void *data); +void * APR_THREAD_FUNC thread_func_atomic(fspr_thread_t *thd, void *data); +void * APR_THREAD_FUNC thread_func_none(fspr_thread_t *thd, void *data); -apr_thread_mutex_t *thread_lock; -volatile apr_uint32_t x = 0; /* mutex locks */ -volatile apr_uint32_t y = 0; /* atomic operations */ -volatile apr_uint32_t z = 0; /* no locks */ -apr_status_t exit_ret_val = 123; /* just some made up number to check on later */ +fspr_thread_mutex_t *thread_lock; +volatile fspr_uint32_t x = 0; /* mutex locks */ +volatile fspr_uint32_t y = 0; /* atomic operations */ +volatile fspr_uint32_t z = 0; /* no locks */ +fspr_status_t exit_ret_val = 123; /* just some made up number to check on later */ #define NUM_THREADS 40 #define NUM_ITERATIONS 20000 -void * APR_THREAD_FUNC thread_func_mutex(apr_thread_t *thd, void *data) +void * APR_THREAD_FUNC thread_func_mutex(fspr_thread_t *thd, void *data) { int i; for (i = 0; i < NUM_ITERATIONS; i++) { - apr_thread_mutex_lock(thread_lock); + fspr_thread_mutex_lock(thread_lock); x++; - apr_thread_mutex_unlock(thread_lock); + fspr_thread_mutex_unlock(thread_lock); } - apr_thread_exit(thd, exit_ret_val); + fspr_thread_exit(thd, exit_ret_val); return NULL; } -void * APR_THREAD_FUNC thread_func_atomic(apr_thread_t *thd, void *data) +void * APR_THREAD_FUNC thread_func_atomic(fspr_thread_t *thd, void *data) { int i; for (i = 0; i < NUM_ITERATIONS ; i++) { - apr_atomic_inc32(&y); - apr_atomic_add32(&y, 2); - apr_atomic_dec32(&y); - apr_atomic_dec32(&y); + fspr_atomic_inc32(&y); + fspr_atomic_add32(&y, 2); + fspr_atomic_dec32(&y); + fspr_atomic_dec32(&y); } - apr_thread_exit(thd, exit_ret_val); + fspr_thread_exit(thd, exit_ret_val); return NULL; } -void * APR_THREAD_FUNC thread_func_none(apr_thread_t *thd, void *data) +void * APR_THREAD_FUNC thread_func_none(fspr_thread_t *thd, void *data) { int i; for (i = 0; i < NUM_ITERATIONS ; i++) { z++; } - apr_thread_exit(thd, exit_ret_val); + fspr_thread_exit(thd, exit_ret_val); return NULL; } static void test_atomics_threaded(abts_case *tc, void *data) { - apr_thread_t *t1[NUM_THREADS]; - apr_thread_t *t2[NUM_THREADS]; - apr_thread_t *t3[NUM_THREADS]; - apr_status_t s1[NUM_THREADS]; - apr_status_t s2[NUM_THREADS]; - apr_status_t s3[NUM_THREADS]; - apr_status_t rv; + fspr_thread_t *t1[NUM_THREADS]; + fspr_thread_t *t2[NUM_THREADS]; + fspr_thread_t *t3[NUM_THREADS]; + fspr_status_t s1[NUM_THREADS]; + fspr_status_t s2[NUM_THREADS]; + fspr_status_t s3[NUM_THREADS]; + fspr_status_t rv; int i; #ifdef HAVE_PTHREAD_SETCONCURRENCY pthread_setconcurrency(8); #endif - rv = apr_thread_mutex_create(&thread_lock, APR_THREAD_MUTEX_DEFAULT, p); + rv = fspr_thread_mutex_create(&thread_lock, APR_THREAD_MUTEX_DEFAULT, p); APR_ASSERT_SUCCESS(tc, "Could not create lock", rv); for (i = 0; i < NUM_THREADS; i++) { - apr_status_t r1, r2, r3; - r1 = apr_thread_create(&t1[i], NULL, thread_func_mutex, NULL, p); - r2 = apr_thread_create(&t2[i], NULL, thread_func_atomic, NULL, p); - r3 = apr_thread_create(&t3[i], NULL, thread_func_none, NULL, p); + fspr_status_t r1, r2, r3; + r1 = fspr_thread_create(&t1[i], NULL, thread_func_mutex, NULL, p); + r2 = fspr_thread_create(&t2[i], NULL, thread_func_atomic, NULL, p); + r3 = fspr_thread_create(&t3[i], NULL, thread_func_none, NULL, p); ABTS_ASSERT(tc, "Failed creating threads", r1 == APR_SUCCESS && r2 == APR_SUCCESS && r3 == APR_SUCCESS); } for (i = 0; i < NUM_THREADS; i++) { - apr_thread_join(&s1[i], t1[i]); - apr_thread_join(&s2[i], t2[i]); - apr_thread_join(&s3[i], t3[i]); + fspr_thread_join(&s1[i], t1[i]); + fspr_thread_join(&s2[i], t2[i]); + fspr_thread_join(&s3[i], t3[i]); ABTS_ASSERT(tc, "Invalid return value from thread_join", s1[i] == exit_ret_val && s2[i] == exit_ret_val && @@ -266,7 +266,7 @@ static void test_atomics_threaded(abts_case *tc, void *data) } ABTS_INT_EQUAL(tc, x, NUM_THREADS * NUM_ITERATIONS); - ABTS_INT_EQUAL(tc, apr_atomic_read32(&y), NUM_THREADS * NUM_ITERATIONS); + ABTS_INT_EQUAL(tc, fspr_atomic_read32(&y), NUM_THREADS * NUM_ITERATIONS); /* Comment out this test, because I have no clue what this test is * actually telling us. We are checking something that may or may not * be true, and it isn't really testing APR at all. diff --git a/libs/apr/test/testdir.c b/libs/apr/test/testdir.c index 82f145d6f1..97c21cc365 100644 --- a/libs/apr/test/testdir.c +++ b/libs/apr/test/testdir.c @@ -17,204 +17,204 @@ #include #include #include -#include "apr_file_io.h" -#include "apr_file_info.h" -#include "apr_errno.h" -#include "apr_general.h" -#include "apr_lib.h" +#include "fspr_file_io.h" +#include "fspr_file_info.h" +#include "fspr_errno.h" +#include "fspr_general.h" +#include "fspr_lib.h" #include "testutil.h" static void test_mkdir(abts_case *tc, void *data) { - apr_status_t rv; - apr_finfo_t finfo; + fspr_status_t rv; + fspr_finfo_t finfo; - rv = apr_dir_make("data/testdir", APR_UREAD | APR_UWRITE | APR_UEXECUTE, p); + rv = fspr_dir_make("data/testdir", APR_UREAD | APR_UWRITE | APR_UEXECUTE, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_stat(&finfo, "data/testdir", APR_FINFO_TYPE, p); + rv = fspr_stat(&finfo, "data/testdir", APR_FINFO_TYPE, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, APR_DIR, finfo.filetype); } static void test_mkdir_recurs(abts_case *tc, void *data) { - apr_status_t rv; - apr_finfo_t finfo; + fspr_status_t rv; + fspr_finfo_t finfo; - rv = apr_dir_make_recursive("data/one/two/three", + rv = fspr_dir_make_recursive("data/one/two/three", APR_UREAD | APR_UWRITE | APR_UEXECUTE, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_stat(&finfo, "data/one", APR_FINFO_TYPE, p); + rv = fspr_stat(&finfo, "data/one", APR_FINFO_TYPE, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, APR_DIR, finfo.filetype); - rv = apr_stat(&finfo, "data/one/two", APR_FINFO_TYPE, p); + rv = fspr_stat(&finfo, "data/one/two", APR_FINFO_TYPE, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, APR_DIR, finfo.filetype); - rv = apr_stat(&finfo, "data/one/two/three", APR_FINFO_TYPE, p); + rv = fspr_stat(&finfo, "data/one/two/three", APR_FINFO_TYPE, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, APR_DIR, finfo.filetype); } static void test_remove(abts_case *tc, void *data) { - apr_status_t rv; - apr_finfo_t finfo; + fspr_status_t rv; + fspr_finfo_t finfo; - rv = apr_dir_remove("data/testdir", p); + rv = fspr_dir_remove("data/testdir", p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_stat(&finfo, "data/testdir", APR_FINFO_TYPE, p); + rv = fspr_stat(&finfo, "data/testdir", APR_FINFO_TYPE, p); ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_ENOENT(rv)); } static void test_removeall_fail(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; - rv = apr_dir_remove("data/one", p); + rv = fspr_dir_remove("data/one", p); ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_ENOTEMPTY(rv)); } static void test_removeall(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; - rv = apr_dir_remove("data/one/two/three", p); + rv = fspr_dir_remove("data/one/two/three", p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_dir_remove("data/one/two", p); + rv = fspr_dir_remove("data/one/two", p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_dir_remove("data/one", p); + rv = fspr_dir_remove("data/one", p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); } static void test_remove_notthere(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; - rv = apr_dir_remove("data/notthere", p); + rv = fspr_dir_remove("data/notthere", p); ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_ENOENT(rv)); } static void test_mkdir_twice(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; - rv = apr_dir_make("data/testdir", APR_UREAD | APR_UWRITE | APR_UEXECUTE, p); + rv = fspr_dir_make("data/testdir", APR_UREAD | APR_UWRITE | APR_UEXECUTE, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_dir_make("data/testdir", APR_UREAD | APR_UWRITE | APR_UEXECUTE, p); + rv = fspr_dir_make("data/testdir", APR_UREAD | APR_UWRITE | APR_UEXECUTE, p); ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_EEXIST(rv)); - rv = apr_dir_remove("data/testdir", p); + rv = fspr_dir_remove("data/testdir", p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); } static void test_opendir(abts_case *tc, void *data) { - apr_status_t rv; - apr_dir_t *dir; + fspr_status_t rv; + fspr_dir_t *dir; - rv = apr_dir_open(&dir, "data", p); + rv = fspr_dir_open(&dir, "data", p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - apr_dir_close(dir); + fspr_dir_close(dir); } static void test_opendir_notthere(abts_case *tc, void *data) { - apr_status_t rv; - apr_dir_t *dir; + fspr_status_t rv; + fspr_dir_t *dir; - rv = apr_dir_open(&dir, "notthere", p); + rv = fspr_dir_open(&dir, "notthere", p); ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_ENOENT(rv)); } static void test_closedir(abts_case *tc, void *data) { - apr_status_t rv; - apr_dir_t *dir; + fspr_status_t rv; + fspr_dir_t *dir; - rv = apr_dir_open(&dir, "data", p); + rv = fspr_dir_open(&dir, "data", p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_dir_close(dir); + rv = fspr_dir_close(dir); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); } static void test_rewind(abts_case *tc, void *data) { - apr_dir_t *dir; - apr_finfo_t first, second; + fspr_dir_t *dir; + fspr_finfo_t first, second; - APR_ASSERT_SUCCESS(tc, "apr_dir_open failed", apr_dir_open(&dir, "data", p)); + APR_ASSERT_SUCCESS(tc, "fspr_dir_open failed", fspr_dir_open(&dir, "data", p)); - APR_ASSERT_SUCCESS(tc, "apr_dir_read failed", - apr_dir_read(&first, APR_FINFO_DIRENT, dir)); + APR_ASSERT_SUCCESS(tc, "fspr_dir_read failed", + fspr_dir_read(&first, APR_FINFO_DIRENT, dir)); - APR_ASSERT_SUCCESS(tc, "apr_dir_rewind failed", apr_dir_rewind(dir)); + APR_ASSERT_SUCCESS(tc, "fspr_dir_rewind failed", fspr_dir_rewind(dir)); - APR_ASSERT_SUCCESS(tc, "second apr_dir_read failed", - apr_dir_read(&second, APR_FINFO_DIRENT, dir)); + APR_ASSERT_SUCCESS(tc, "second fspr_dir_read failed", + fspr_dir_read(&second, APR_FINFO_DIRENT, dir)); - APR_ASSERT_SUCCESS(tc, "apr_dir_close failed", apr_dir_close(dir)); + APR_ASSERT_SUCCESS(tc, "fspr_dir_close failed", fspr_dir_close(dir)); ABTS_STR_EQUAL(tc, first.name, second.name); } -/* Test for a (fixed) bug in apr_dir_read(). This bug only happened +/* Test for a (fixed) bug in fspr_dir_read(). This bug only happened in threadless cases. */ static void test_uncleared_errno(abts_case *tc, void *data) { - apr_file_t *thefile = NULL; - apr_finfo_t finfo; - apr_int32_t finfo_flags = APR_FINFO_TYPE | APR_FINFO_NAME; - apr_dir_t *this_dir; - apr_status_t rv; + fspr_file_t *thefile = NULL; + fspr_finfo_t finfo; + fspr_int32_t finfo_flags = APR_FINFO_TYPE | APR_FINFO_NAME; + fspr_dir_t *this_dir; + fspr_status_t rv; - rv = apr_dir_make("dir1", APR_OS_DEFAULT, p); + rv = fspr_dir_make("dir1", APR_OS_DEFAULT, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_dir_make("dir2", APR_OS_DEFAULT, p); + rv = fspr_dir_make("dir2", APR_OS_DEFAULT, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_file_open(&thefile, "dir1/file1", + rv = fspr_file_open(&thefile, "dir1/file1", APR_READ | APR_WRITE | APR_CREATE, APR_OS_DEFAULT, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_file_close(thefile); + rv = fspr_file_close(thefile); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); /* Try to remove dir1. This should fail because it's not empty. However, on a platform with threads disabled (such as FreeBSD), `errno' will be set as a result. */ - rv = apr_dir_remove("dir1", p); + rv = fspr_dir_remove("dir1", p); ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_ENOTEMPTY(rv)); /* Read `.' and `..' out of dir2. */ - rv = apr_dir_open(&this_dir, "dir2", p); + rv = fspr_dir_open(&this_dir, "dir2", p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_dir_read(&finfo, finfo_flags, this_dir); + rv = fspr_dir_read(&finfo, finfo_flags, this_dir); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_dir_read(&finfo, finfo_flags, this_dir); + rv = fspr_dir_read(&finfo, finfo_flags, this_dir); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); /* Now, when we attempt to do a third read of empty dir2, and the underlying system readdir() returns NULL, the old value of errno shouldn't cause a false alarm. We should get an ENOENT - back from apr_dir_read, and *not* the old errno. */ - rv = apr_dir_read(&finfo, finfo_flags, this_dir); + back from fspr_dir_read, and *not* the old errno. */ + rv = fspr_dir_read(&finfo, finfo_flags, this_dir); ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_ENOENT(rv)); - rv = apr_dir_close(this_dir); + rv = fspr_dir_close(this_dir); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); /* Cleanup */ - rv = apr_file_remove("dir1/file1", p); + rv = fspr_file_remove("dir1/file1", p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_dir_remove("dir1", p); + rv = fspr_dir_remove("dir1", p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_dir_remove("dir2", p); + rv = fspr_dir_remove("dir2", p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); } @@ -222,30 +222,30 @@ static void test_uncleared_errno(abts_case *tc, void *data) static void test_rmkdir_nocwd(abts_case *tc, void *data) { char *cwd, *path; - apr_status_t rv; + fspr_status_t rv; APR_ASSERT_SUCCESS(tc, "make temp dir", - apr_dir_make("dir3", APR_OS_DEFAULT, p)); + fspr_dir_make("dir3", APR_OS_DEFAULT, p)); - APR_ASSERT_SUCCESS(tc, "obtain cwd", apr_filepath_get(&cwd, 0, p)); + APR_ASSERT_SUCCESS(tc, "obtain cwd", fspr_filepath_get(&cwd, 0, p)); APR_ASSERT_SUCCESS(tc, "determine path to temp dir", - apr_filepath_merge(&path, cwd, "dir3", 0, p)); + fspr_filepath_merge(&path, cwd, "dir3", 0, p)); - APR_ASSERT_SUCCESS(tc, "change to temp dir", apr_filepath_set(path, p)); + APR_ASSERT_SUCCESS(tc, "change to temp dir", fspr_filepath_set(path, p)); - rv = apr_dir_remove(path, p); + rv = fspr_dir_remove(path, p); /* Some platforms cannot remove a directory which is in use. */ if (rv == APR_SUCCESS) { ABTS_ASSERT(tc, "fail to create dir", - apr_dir_make_recursive("foobar", APR_OS_DEFAULT, + fspr_dir_make_recursive("foobar", APR_OS_DEFAULT, p) != APR_SUCCESS); } - APR_ASSERT_SUCCESS(tc, "restore cwd", apr_filepath_set(cwd, p)); + APR_ASSERT_SUCCESS(tc, "restore cwd", fspr_filepath_set(cwd, p)); if (rv) { - apr_dir_remove(path, p); + fspr_dir_remove(path, p); ABTS_NOT_IMPL(tc, "cannot remove in-use directory"); } } diff --git a/libs/apr/test/testdso.c b/libs/apr/test/testdso.c index b87bdf70e1..aaeffcfee0 100644 --- a/libs/apr/test/testdso.c +++ b/libs/apr/test/testdso.c @@ -16,13 +16,13 @@ #include "testutil.h" -#include "apr_general.h" -#include "apr_pools.h" -#include "apr_errno.h" -#include "apr_dso.h" -#include "apr_strings.h" -#include "apr_file_info.h" -#include "apr.h" +#include "fspr_general.h" +#include "fspr_pools.h" +#include "fspr_errno.h" +#include "fspr_dso.h" +#include "fspr_strings.h" +#include "fspr_file_info.h" +#include "fspr.h" #if APR_HAVE_UNISTD_H #include #endif @@ -53,32 +53,32 @@ static char *modname; static void test_load_module(abts_case *tc, void *data) { - apr_dso_handle_t *h = NULL; - apr_status_t status; + fspr_dso_handle_t *h = NULL; + fspr_status_t status; char errstr[256]; - status = apr_dso_load(&h, modname, p); - ABTS_ASSERT(tc, apr_dso_error(h, errstr, 256), APR_SUCCESS == status); + status = fspr_dso_load(&h, modname, p); + ABTS_ASSERT(tc, fspr_dso_error(h, errstr, 256), APR_SUCCESS == status); ABTS_PTR_NOTNULL(tc, h); - apr_dso_unload(h); + fspr_dso_unload(h); } static void test_dso_sym(abts_case *tc, void *data) { - apr_dso_handle_t *h = NULL; - apr_dso_handle_sym_t func1 = NULL; - apr_status_t status; + fspr_dso_handle_t *h = NULL; + fspr_dso_handle_sym_t func1 = NULL; + fspr_status_t status; void (*function)(char str[256]); char teststr[256]; char errstr[256]; - status = apr_dso_load(&h, modname, p); - ABTS_ASSERT(tc, apr_dso_error(h, errstr, 256), APR_SUCCESS == status); + status = fspr_dso_load(&h, modname, p); + ABTS_ASSERT(tc, fspr_dso_error(h, errstr, 256), APR_SUCCESS == status); ABTS_PTR_NOTNULL(tc, h); - status = apr_dso_sym(&func1, h, "print_hello"); - ABTS_ASSERT(tc, apr_dso_error(h, errstr, 256), APR_SUCCESS == status); + status = fspr_dso_sym(&func1, h, "print_hello"); + ABTS_ASSERT(tc, fspr_dso_error(h, errstr, 256), APR_SUCCESS == status); ABTS_PTR_NOTNULL(tc, func1); if (!tc->failed) { @@ -87,23 +87,23 @@ static void test_dso_sym(abts_case *tc, void *data) ABTS_STR_EQUAL(tc, "Hello - I'm a DSO!\n", teststr); } - apr_dso_unload(h); + fspr_dso_unload(h); } static void test_dso_sym_return_value(abts_case *tc, void *data) { - apr_dso_handle_t *h = NULL; - apr_dso_handle_sym_t func1 = NULL; - apr_status_t status; + fspr_dso_handle_t *h = NULL; + fspr_dso_handle_sym_t func1 = NULL; + fspr_status_t status; int (*function)(int); char errstr[256]; - status = apr_dso_load(&h, modname, p); - ABTS_ASSERT(tc, apr_dso_error(h, errstr, 256), APR_SUCCESS == status); + status = fspr_dso_load(&h, modname, p); + ABTS_ASSERT(tc, fspr_dso_error(h, errstr, 256), APR_SUCCESS == status); ABTS_PTR_NOTNULL(tc, h); - status = apr_dso_sym(&func1, h, "count_reps"); - ABTS_ASSERT(tc, apr_dso_error(h, errstr, 256), APR_SUCCESS == status); + status = fspr_dso_sym(&func1, h, "count_reps"); + ABTS_ASSERT(tc, fspr_dso_error(h, errstr, 256), APR_SUCCESS == status); ABTS_PTR_NOTNULL(tc, func1); if (!tc->failed) { @@ -112,24 +112,24 @@ static void test_dso_sym_return_value(abts_case *tc, void *data) ABTS_INT_EQUAL(tc, 5, status); } - apr_dso_unload(h); + fspr_dso_unload(h); } static void test_unload_module(abts_case *tc, void *data) { - apr_dso_handle_t *h = NULL; - apr_status_t status; + fspr_dso_handle_t *h = NULL; + fspr_status_t status; char errstr[256]; - apr_dso_handle_sym_t func1 = NULL; + fspr_dso_handle_sym_t func1 = NULL; - status = apr_dso_load(&h, modname, p); - ABTS_ASSERT(tc, apr_dso_error(h, errstr, 256), APR_SUCCESS == status); + status = fspr_dso_load(&h, modname, p); + ABTS_ASSERT(tc, fspr_dso_error(h, errstr, 256), APR_SUCCESS == status); ABTS_PTR_NOTNULL(tc, h); - status = apr_dso_unload(h); - ABTS_ASSERT(tc, apr_dso_error(h, errstr, 256), APR_SUCCESS == status); + status = fspr_dso_unload(h); + ABTS_ASSERT(tc, fspr_dso_error(h, errstr, 256), APR_SUCCESS == status); - status = apr_dso_sym(&func1, h, "print_hello"); + status = fspr_dso_sym(&func1, h, "print_hello"); ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_ESYMNOTFOUND(status)); } @@ -139,32 +139,32 @@ static char *libname; static void test_load_library(abts_case *tc, void *data) { - apr_dso_handle_t *h = NULL; - apr_status_t status; + fspr_dso_handle_t *h = NULL; + fspr_status_t status; char errstr[256]; - status = apr_dso_load(&h, libname, p); - ABTS_ASSERT(tc, apr_dso_error(h, errstr, 256), APR_SUCCESS == status); + status = fspr_dso_load(&h, libname, p); + ABTS_ASSERT(tc, fspr_dso_error(h, errstr, 256), APR_SUCCESS == status); ABTS_PTR_NOTNULL(tc, h); - apr_dso_unload(h); + fspr_dso_unload(h); } static void test_dso_sym_library(abts_case *tc, void *data) { - apr_dso_handle_t *h = NULL; - apr_dso_handle_sym_t func1 = NULL; - apr_status_t status; + fspr_dso_handle_t *h = NULL; + fspr_dso_handle_sym_t func1 = NULL; + fspr_status_t status; void (*function)(char str[256]); char teststr[256]; char errstr[256]; - status = apr_dso_load(&h, libname, p); - ABTS_ASSERT(tc, apr_dso_error(h, errstr, 256), APR_SUCCESS == status); + status = fspr_dso_load(&h, libname, p); + ABTS_ASSERT(tc, fspr_dso_error(h, errstr, 256), APR_SUCCESS == status); ABTS_PTR_NOTNULL(tc, h); - status = apr_dso_sym(&func1, h, "print_hello"); - ABTS_ASSERT(tc, apr_dso_error(h, errstr, 256), APR_SUCCESS == status); + status = fspr_dso_sym(&func1, h, "print_hello"); + ABTS_ASSERT(tc, fspr_dso_error(h, errstr, 256), APR_SUCCESS == status); ABTS_PTR_NOTNULL(tc, func1); if (!tc->failed) { @@ -173,23 +173,23 @@ static void test_dso_sym_library(abts_case *tc, void *data) ABTS_STR_EQUAL(tc, "Hello - I'm a DSO!\n", teststr); } - apr_dso_unload(h); + fspr_dso_unload(h); } static void test_dso_sym_return_value_library(abts_case *tc, void *data) { - apr_dso_handle_t *h = NULL; - apr_dso_handle_sym_t func1 = NULL; - apr_status_t status; + fspr_dso_handle_t *h = NULL; + fspr_dso_handle_sym_t func1 = NULL; + fspr_status_t status; int (*function)(int); char errstr[256]; - status = apr_dso_load(&h, libname, p); - ABTS_ASSERT(tc, apr_dso_error(h, errstr, 256), APR_SUCCESS == status); + status = fspr_dso_load(&h, libname, p); + ABTS_ASSERT(tc, fspr_dso_error(h, errstr, 256), APR_SUCCESS == status); ABTS_PTR_NOTNULL(tc, h); - status = apr_dso_sym(&func1, h, "count_reps"); - ABTS_ASSERT(tc, apr_dso_error(h, errstr, 256), APR_SUCCESS == status); + status = fspr_dso_sym(&func1, h, "count_reps"); + ABTS_ASSERT(tc, fspr_dso_error(h, errstr, 256), APR_SUCCESS == status); ABTS_PTR_NOTNULL(tc, func1); if (!tc->failed) { @@ -198,24 +198,24 @@ static void test_dso_sym_return_value_library(abts_case *tc, void *data) ABTS_INT_EQUAL(tc, 5, status); } - apr_dso_unload(h); + fspr_dso_unload(h); } static void test_unload_library(abts_case *tc, void *data) { - apr_dso_handle_t *h = NULL; - apr_status_t status; + fspr_dso_handle_t *h = NULL; + fspr_status_t status; char errstr[256]; - apr_dso_handle_sym_t func1 = NULL; + fspr_dso_handle_sym_t func1 = NULL; - status = apr_dso_load(&h, libname, p); - ABTS_ASSERT(tc, apr_dso_error(h, errstr, 256), APR_SUCCESS == status); + status = fspr_dso_load(&h, libname, p); + ABTS_ASSERT(tc, fspr_dso_error(h, errstr, 256), APR_SUCCESS == status); ABTS_PTR_NOTNULL(tc, h); - status = apr_dso_unload(h); - ABTS_ASSERT(tc, apr_dso_error(h, errstr, 256), APR_SUCCESS == status); + status = fspr_dso_unload(h); + ABTS_ASSERT(tc, fspr_dso_error(h, errstr, 256), APR_SUCCESS == status); - status = apr_dso_sym(&func1, h, "print_hello"); + status = fspr_dso_sym(&func1, h, "print_hello"); ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_ESYMNOTFOUND(status)); } @@ -223,10 +223,10 @@ static void test_unload_library(abts_case *tc, void *data) static void test_load_notthere(abts_case *tc, void *data) { - apr_dso_handle_t *h = NULL; - apr_status_t status; + fspr_dso_handle_t *h = NULL; + fspr_status_t status; - status = apr_dso_load(&h, "No_File.so", p); + status = fspr_dso_load(&h, "No_File.so", p); ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_EDSOOPEN(status)); ABTS_PTR_NOTNULL(tc, h); @@ -239,7 +239,7 @@ abts_suite *testdso(abts_suite *suite) suite = ADD_SUITE(suite) #if APR_HAS_DSO - apr_filepath_merge(&modname, NULL, MOD_NAME, 0, p); + fspr_filepath_merge(&modname, NULL, MOD_NAME, 0, p); abts_run_test(suite, test_load_module, NULL); abts_run_test(suite, test_dso_sym, NULL); @@ -247,7 +247,7 @@ abts_suite *testdso(abts_suite *suite) abts_run_test(suite, test_unload_module, NULL); #ifdef LIB_NAME - apr_filepath_merge(&libname, NULL, LIB_NAME, 0, p); + fspr_filepath_merge(&libname, NULL, LIB_NAME, 0, p); abts_run_test(suite, test_load_library, NULL); abts_run_test(suite, test_dso_sym_library, NULL); diff --git a/libs/apr/test/testdup.c b/libs/apr/test/testdup.c index 9d064ec0d8..a6fd1c8e83 100644 --- a/libs/apr/test/testdup.c +++ b/libs/apr/test/testdup.c @@ -15,10 +15,10 @@ */ -#include "apr_general.h" -#include "apr_pools.h" -#include "apr_errno.h" -#include "apr_file_io.h" +#include "fspr_general.h" +#include "fspr_pools.h" +#include "fspr_errno.h" +#include "fspr_file_io.h" #include "testutil.h" #define TEST "Testing\n" @@ -27,155 +27,155 @@ static void test_file_dup(abts_case *tc, void *data) { - apr_file_t *file1 = NULL; - apr_file_t *file3 = NULL; - apr_status_t rv; - apr_finfo_t finfo; + fspr_file_t *file1 = NULL; + fspr_file_t *file3 = NULL; + fspr_status_t rv; + fspr_finfo_t finfo; /* First, create a new file, empty... */ - rv = apr_file_open(&file1, FILEPATH "testdup.file", + rv = fspr_file_open(&file1, FILEPATH "testdup.file", APR_READ | APR_WRITE | APR_CREATE | APR_DELONCLOSE, APR_OS_DEFAULT, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_PTR_NOTNULL(tc, file1); - rv = apr_file_dup(&file3, file1, p); + rv = fspr_file_dup(&file3, file1, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_PTR_NOTNULL(tc, file3); - rv = apr_file_close(file1); + rv = fspr_file_close(file1); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); /* cleanup after ourselves */ - rv = apr_file_close(file3); + rv = fspr_file_close(file3); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_stat(&finfo, FILEPATH "testdup.file", APR_FINFO_NORM, p); + rv = fspr_stat(&finfo, FILEPATH "testdup.file", APR_FINFO_NORM, p); ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_ENOENT(rv)); } static void test_file_readwrite(abts_case *tc, void *data) { - apr_file_t *file1 = NULL; - apr_file_t *file3 = NULL; - apr_status_t rv; - apr_finfo_t finfo; - apr_size_t txtlen = sizeof(TEST); + fspr_file_t *file1 = NULL; + fspr_file_t *file3 = NULL; + fspr_status_t rv; + fspr_finfo_t finfo; + fspr_size_t txtlen = sizeof(TEST); char buff[50]; - apr_off_t fpos; + fspr_off_t fpos; /* First, create a new file, empty... */ - rv = apr_file_open(&file1, FILEPATH "testdup.readwrite.file", + rv = fspr_file_open(&file1, FILEPATH "testdup.readwrite.file", APR_READ | APR_WRITE | APR_CREATE | APR_DELONCLOSE, APR_OS_DEFAULT, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_PTR_NOTNULL(tc, file1); - rv = apr_file_dup(&file3, file1, p); + rv = fspr_file_dup(&file3, file1, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_PTR_NOTNULL(tc, file3); - rv = apr_file_write(file3, TEST, &txtlen); + rv = fspr_file_write(file3, TEST, &txtlen); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, sizeof(TEST), txtlen); fpos = 0; - rv = apr_file_seek(file1, APR_SET, &fpos); + rv = fspr_file_seek(file1, APR_SET, &fpos); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_ASSERT(tc, "File position mismatch, expected 0", fpos == 0); txtlen = 50; - rv = apr_file_read(file1, buff, &txtlen); + rv = fspr_file_read(file1, buff, &txtlen); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_STR_EQUAL(tc, TEST, buff); /* cleanup after ourselves */ - rv = apr_file_close(file1); + rv = fspr_file_close(file1); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_file_close(file3); + rv = fspr_file_close(file3); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_stat(&finfo, FILEPATH "testdup.readwrite.file", APR_FINFO_NORM, p); + rv = fspr_stat(&finfo, FILEPATH "testdup.readwrite.file", APR_FINFO_NORM, p); ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_ENOENT(rv)); } static void test_dup2(abts_case *tc, void *data) { - apr_file_t *testfile = NULL; - apr_file_t *errfile = NULL; - apr_file_t *saveerr = NULL; - apr_status_t rv; + fspr_file_t *testfile = NULL; + fspr_file_t *errfile = NULL; + fspr_file_t *saveerr = NULL; + fspr_status_t rv; - rv = apr_file_open(&testfile, FILEPATH "testdup2.file", + rv = fspr_file_open(&testfile, FILEPATH "testdup2.file", APR_READ | APR_WRITE | APR_CREATE | APR_DELONCLOSE, APR_OS_DEFAULT, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_PTR_NOTNULL(tc, testfile); - rv = apr_file_open_stderr(&errfile, p); + rv = fspr_file_open_stderr(&errfile, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); /* Set aside the real errfile */ - rv = apr_file_dup(&saveerr, errfile, p); + rv = fspr_file_dup(&saveerr, errfile, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_PTR_NOTNULL(tc, saveerr); - rv = apr_file_dup2(errfile, testfile, p); + rv = fspr_file_dup2(errfile, testfile, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_PTR_NOTNULL(tc, errfile); - apr_file_close(testfile); + fspr_file_close(testfile); - rv = apr_file_dup2(errfile, saveerr, p); + rv = fspr_file_dup2(errfile, saveerr, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_PTR_NOTNULL(tc, errfile); } static void test_dup2_readwrite(abts_case *tc, void *data) { - apr_file_t *errfile = NULL; - apr_file_t *testfile = NULL; - apr_file_t *saveerr = NULL; - apr_status_t rv; - apr_size_t txtlen = sizeof(TEST); + fspr_file_t *errfile = NULL; + fspr_file_t *testfile = NULL; + fspr_file_t *saveerr = NULL; + fspr_status_t rv; + fspr_size_t txtlen = sizeof(TEST); char buff[50]; - apr_off_t fpos; + fspr_off_t fpos; - rv = apr_file_open(&testfile, FILEPATH "testdup2.readwrite.file", + rv = fspr_file_open(&testfile, FILEPATH "testdup2.readwrite.file", APR_READ | APR_WRITE | APR_CREATE | APR_DELONCLOSE, APR_OS_DEFAULT, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_PTR_NOTNULL(tc, testfile); - rv = apr_file_open_stderr(&errfile, p); + rv = fspr_file_open_stderr(&errfile, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); /* Set aside the real errfile */ - rv = apr_file_dup(&saveerr, errfile, p); + rv = fspr_file_dup(&saveerr, errfile, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_PTR_NOTNULL(tc, saveerr); - rv = apr_file_dup2(errfile, testfile, p); + rv = fspr_file_dup2(errfile, testfile, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_PTR_NOTNULL(tc, errfile); txtlen = sizeof(TEST2); - rv = apr_file_write(errfile, TEST2, &txtlen); + rv = fspr_file_write(errfile, TEST2, &txtlen); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, sizeof(TEST2), txtlen); fpos = 0; - rv = apr_file_seek(testfile, APR_SET, &fpos); + rv = fspr_file_seek(testfile, APR_SET, &fpos); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_ASSERT(tc, "File position mismatch, expected 0", fpos == 0); txtlen = 50; - rv = apr_file_read(testfile, buff, &txtlen); + rv = fspr_file_read(testfile, buff, &txtlen); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_STR_EQUAL(tc, TEST2, buff); - apr_file_close(testfile); + fspr_file_close(testfile); - rv = apr_file_dup2(errfile, saveerr, p); + rv = fspr_file_dup2(errfile, saveerr, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_PTR_NOTNULL(tc, errfile); } diff --git a/libs/apr/test/testenv.c b/libs/apr/test/testenv.c index d292c26e7d..91aa889e43 100644 --- a/libs/apr/test/testenv.c +++ b/libs/apr/test/testenv.c @@ -14,12 +14,12 @@ * limitations under the License. */ -#include "apr_env.h" -#include "apr_errno.h" +#include "fspr_env.h" +#include "fspr_errno.h" #include "testutil.h" -#define TEST_ENVVAR_NAME "apr_test_envvar" -#define TEST_ENVVAR2_NAME "apr_test_envvar2" +#define TEST_ENVVAR_NAME "fspr_test_envvar" +#define TEST_ENVVAR2_NAME "fspr_test_envvar2" #define TEST_ENVVAR_VALUE "Just a value that we'll check" static int have_env_set; @@ -28,12 +28,12 @@ static int have_env_del; static void test_setenv(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; - rv = apr_env_set(TEST_ENVVAR_NAME, TEST_ENVVAR_VALUE, p); + rv = fspr_env_set(TEST_ENVVAR_NAME, TEST_ENVVAR_VALUE, p); have_env_set = (rv != APR_ENOTIMPL); if (!have_env_set) { - ABTS_NOT_IMPL(tc, "apr_env_set"); + ABTS_NOT_IMPL(tc, "fspr_env_set"); } else { APR_ASSERT_SUCCESS(tc, "set environment variable", rv); } @@ -42,17 +42,17 @@ static void test_setenv(abts_case *tc, void *data) static void test_getenv(abts_case *tc, void *data) { char *value; - apr_status_t rv; + fspr_status_t rv; if (!have_env_set) { - ABTS_NOT_IMPL(tc, "apr_env_set (skip test for apr_env_get)"); + ABTS_NOT_IMPL(tc, "fspr_env_set (skip test for fspr_env_get)"); return; } - rv = apr_env_get(&value, TEST_ENVVAR_NAME, p); + rv = fspr_env_get(&value, TEST_ENVVAR_NAME, p); have_env_get = (rv != APR_ENOTIMPL); if (!have_env_get) { - ABTS_NOT_IMPL(tc, "apr_env_get"); + ABTS_NOT_IMPL(tc, "fspr_env_get"); return; } APR_ASSERT_SUCCESS(tc, "get environment variable", rv); @@ -62,26 +62,26 @@ static void test_getenv(abts_case *tc, void *data) static void test_delenv(abts_case *tc, void *data) { char *value; - apr_status_t rv; + fspr_status_t rv; if (!have_env_set) { - ABTS_NOT_IMPL(tc, "apr_env_set (skip test for apr_env_delete)"); + ABTS_NOT_IMPL(tc, "fspr_env_set (skip test for fspr_env_delete)"); return; } - rv = apr_env_delete(TEST_ENVVAR_NAME, p); + rv = fspr_env_delete(TEST_ENVVAR_NAME, p); have_env_del = (rv != APR_ENOTIMPL); if (!have_env_del) { - ABTS_NOT_IMPL(tc, "apr_env_delete"); + ABTS_NOT_IMPL(tc, "fspr_env_delete"); return; } APR_ASSERT_SUCCESS(tc, "delete environment variable", rv); if (!have_env_get) { - ABTS_NOT_IMPL(tc, "apr_env_get (skip sanity check for apr_env_delete)"); + ABTS_NOT_IMPL(tc, "fspr_env_get (skip sanity check for fspr_env_delete)"); return; } - rv = apr_env_get(&value, TEST_ENVVAR_NAME, p); + rv = fspr_env_get(&value, TEST_ENVVAR_NAME, p); ABTS_INT_EQUAL(tc, APR_ENOENT, rv); } @@ -89,45 +89,45 @@ static void test_delenv(abts_case *tc, void *data) static void test_emptyenv(abts_case *tc, void *data) { char *value; - apr_status_t rv; + fspr_status_t rv; if (!(have_env_set && have_env_get)) { - ABTS_NOT_IMPL(tc, "apr_env_set (skip test_emptyenv)"); + ABTS_NOT_IMPL(tc, "fspr_env_set (skip test_emptyenv)"); return; } /** Set empty string and test that rv != ENOENT) */ - rv = apr_env_set(TEST_ENVVAR_NAME, "", p); + rv = fspr_env_set(TEST_ENVVAR_NAME, "", p); APR_ASSERT_SUCCESS(tc, "set environment variable", rv); - rv = apr_env_get(&value, TEST_ENVVAR_NAME, p); + rv = fspr_env_get(&value, TEST_ENVVAR_NAME, p); APR_ASSERT_SUCCESS(tc, "get environment variable", rv); ABTS_STR_EQUAL(tc, "", value); if (!have_env_del) { - ABTS_NOT_IMPL(tc, "apr_env_del (skip recycle test_emptyenv)"); + ABTS_NOT_IMPL(tc, "fspr_env_del (skip recycle test_emptyenv)"); return; } /** Delete and retest */ - rv = apr_env_delete(TEST_ENVVAR_NAME, p); + rv = fspr_env_delete(TEST_ENVVAR_NAME, p); APR_ASSERT_SUCCESS(tc, "delete environment variable", rv); - rv = apr_env_get(&value, TEST_ENVVAR_NAME, p); + rv = fspr_env_get(&value, TEST_ENVVAR_NAME, p); ABTS_INT_EQUAL(tc, APR_ENOENT, rv); /** Set second variable + test*/ - rv = apr_env_set(TEST_ENVVAR2_NAME, TEST_ENVVAR_VALUE, p); + rv = fspr_env_set(TEST_ENVVAR2_NAME, TEST_ENVVAR_VALUE, p); APR_ASSERT_SUCCESS(tc, "set second environment variable", rv); - rv = apr_env_get(&value, TEST_ENVVAR2_NAME, p); + rv = fspr_env_get(&value, TEST_ENVVAR2_NAME, p); APR_ASSERT_SUCCESS(tc, "get second environment variable", rv); ABTS_STR_EQUAL(tc, TEST_ENVVAR_VALUE, value); /** Finally, test ENOENT (first variable) followed by second != ENOENT) */ - rv = apr_env_get(&value, TEST_ENVVAR_NAME, p); + rv = fspr_env_get(&value, TEST_ENVVAR_NAME, p); ABTS_INT_EQUAL(tc, APR_ENOENT, rv); - rv = apr_env_get(&value, TEST_ENVVAR2_NAME, p); + rv = fspr_env_get(&value, TEST_ENVVAR2_NAME, p); APR_ASSERT_SUCCESS(tc, "verify second environment variable", rv); ABTS_STR_EQUAL(tc, TEST_ENVVAR_VALUE, value); /** Cleanup */ - apr_env_delete(TEST_ENVVAR2_NAME, p); + fspr_env_delete(TEST_ENVVAR2_NAME, p); } abts_suite *testenv(abts_suite *suite) diff --git a/libs/apr/test/testfile.c b/libs/apr/test/testfile.c index 2ffc82643d..7e2be1204c 100644 --- a/libs/apr/test/testfile.c +++ b/libs/apr/test/testfile.c @@ -14,13 +14,13 @@ * limitations under the License. */ -#include "apr_file_io.h" -#include "apr_file_info.h" -#include "apr_network_io.h" -#include "apr_errno.h" -#include "apr_general.h" -#include "apr_poll.h" -#include "apr_lib.h" +#include "fspr_file_io.h" +#include "fspr_file_info.h" +#include "fspr_network_io.h" +#include "fspr_errno.h" +#include "fspr_general.h" +#include "fspr_poll.h" +#include "fspr_lib.h" #include "testutil.h" #define DIRNAME "data" @@ -34,10 +34,10 @@ static void test_open_noreadwrite(abts_case *tc, void *data) { - apr_status_t rv; - apr_file_t *thefile = NULL; + fspr_status_t rv; + fspr_file_t *thefile = NULL; - rv = apr_file_open(&thefile, FILENAME, + rv = fspr_file_open(&thefile, FILENAME, APR_CREATE | APR_EXCL, APR_UREAD | APR_UWRITE | APR_GREAD, p); ABTS_TRUE(tc, rv != APR_SUCCESS); @@ -47,10 +47,10 @@ static void test_open_noreadwrite(abts_case *tc, void *data) static void test_open_excl(abts_case *tc, void *data) { - apr_status_t rv; - apr_file_t *thefile = NULL; + fspr_status_t rv; + fspr_file_t *thefile = NULL; - rv = apr_file_open(&thefile, FILENAME, + rv = fspr_file_open(&thefile, FILENAME, APR_CREATE | APR_EXCL | APR_WRITE, APR_UREAD | APR_UWRITE | APR_GREAD, p); ABTS_TRUE(tc, rv != APR_SUCCESS); @@ -60,111 +60,111 @@ static void test_open_excl(abts_case *tc, void *data) static void test_open_read(abts_case *tc, void *data) { - apr_status_t rv; - apr_file_t *filetest = NULL; + fspr_status_t rv; + fspr_file_t *filetest = NULL; - rv = apr_file_open(&filetest, FILENAME, + rv = fspr_file_open(&filetest, FILENAME, APR_READ, APR_UREAD | APR_UWRITE | APR_GREAD, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_PTR_NOTNULL(tc, filetest); - apr_file_close(filetest); + fspr_file_close(filetest); } static void test_read(abts_case *tc, void *data) { - apr_status_t rv; - apr_size_t nbytes = 256; - char *str = apr_pcalloc(p, nbytes + 1); - apr_file_t *filetest = NULL; + fspr_status_t rv; + fspr_size_t nbytes = 256; + char *str = fspr_pcalloc(p, nbytes + 1); + fspr_file_t *filetest = NULL; - rv = apr_file_open(&filetest, FILENAME, + rv = fspr_file_open(&filetest, FILENAME, APR_READ, APR_UREAD | APR_UWRITE | APR_GREAD, p); APR_ASSERT_SUCCESS(tc, "Opening test file " FILENAME, rv); - rv = apr_file_read(filetest, str, &nbytes); + rv = fspr_file_read(filetest, str, &nbytes); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, strlen(TESTSTR), nbytes); ABTS_STR_EQUAL(tc, TESTSTR, str); - apr_file_close(filetest); + fspr_file_close(filetest); } static void test_readzero(abts_case *tc, void *data) { - apr_status_t rv; - apr_size_t nbytes = 0; + fspr_status_t rv; + fspr_size_t nbytes = 0; char *str = NULL; - apr_file_t *filetest; + fspr_file_t *filetest; - rv = apr_file_open(&filetest, FILENAME, APR_READ, APR_OS_DEFAULT, p); + rv = fspr_file_open(&filetest, FILENAME, APR_READ, APR_OS_DEFAULT, p); APR_ASSERT_SUCCESS(tc, "Opening test file " FILENAME, rv); - rv = apr_file_read(filetest, str, &nbytes); + rv = fspr_file_read(filetest, str, &nbytes); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, 0, nbytes); - apr_file_close(filetest); + fspr_file_close(filetest); } static void test_filename(abts_case *tc, void *data) { const char *str; - apr_status_t rv; - apr_file_t *filetest = NULL; + fspr_status_t rv; + fspr_file_t *filetest = NULL; - rv = apr_file_open(&filetest, FILENAME, + rv = fspr_file_open(&filetest, FILENAME, APR_READ, APR_UREAD | APR_UWRITE | APR_GREAD, p); APR_ASSERT_SUCCESS(tc, "Opening test file " FILENAME, rv); - rv = apr_file_name_get(&str, filetest); + rv = fspr_file_name_get(&str, filetest); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_STR_EQUAL(tc, FILENAME, str); - apr_file_close(filetest); + fspr_file_close(filetest); } static void test_fileclose(abts_case *tc, void *data) { char str; - apr_status_t rv; - apr_size_t one = 1; - apr_file_t *filetest = NULL; + fspr_status_t rv; + fspr_size_t one = 1; + fspr_file_t *filetest = NULL; - rv = apr_file_open(&filetest, FILENAME, + rv = fspr_file_open(&filetest, FILENAME, APR_READ, APR_UREAD | APR_UWRITE | APR_GREAD, p); APR_ASSERT_SUCCESS(tc, "Opening test file " FILENAME, rv); - rv = apr_file_close(filetest); + rv = fspr_file_close(filetest); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); /* We just closed the file, so this should fail */ - rv = apr_file_read(filetest, &str, &one); + rv = fspr_file_read(filetest, &str, &one); ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_EBADF(rv)); } static void test_file_remove(abts_case *tc, void *data) { - apr_status_t rv; - apr_file_t *filetest = NULL; + fspr_status_t rv; + fspr_file_t *filetest = NULL; - rv = apr_file_remove(FILENAME, p); + rv = fspr_file_remove(FILENAME, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_file_open(&filetest, FILENAME, APR_READ, + rv = fspr_file_open(&filetest, FILENAME, APR_READ, APR_UREAD | APR_UWRITE | APR_GREAD, p); ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_ENOENT(rv)); } static void test_open_write(abts_case *tc, void *data) { - apr_status_t rv; - apr_file_t *filetest = NULL; + fspr_status_t rv; + fspr_file_t *filetest = NULL; filetest = NULL; - rv = apr_file_open(&filetest, FILENAME, + rv = fspr_file_open(&filetest, FILENAME, APR_WRITE, APR_UREAD | APR_UWRITE | APR_GREAD, p); ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_ENOENT(rv)); @@ -173,229 +173,229 @@ static void test_open_write(abts_case *tc, void *data) static void test_open_writecreate(abts_case *tc, void *data) { - apr_status_t rv; - apr_file_t *filetest = NULL; + fspr_status_t rv; + fspr_file_t *filetest = NULL; filetest = NULL; - rv = apr_file_open(&filetest, FILENAME, + rv = fspr_file_open(&filetest, FILENAME, APR_WRITE | APR_CREATE, APR_UREAD | APR_UWRITE | APR_GREAD, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - apr_file_close(filetest); + fspr_file_close(filetest); } static void test_write(abts_case *tc, void *data) { - apr_status_t rv; - apr_size_t bytes = strlen(TESTSTR); - apr_file_t *filetest = NULL; + fspr_status_t rv; + fspr_size_t bytes = strlen(TESTSTR); + fspr_file_t *filetest = NULL; - rv = apr_file_open(&filetest, FILENAME, + rv = fspr_file_open(&filetest, FILENAME, APR_WRITE | APR_CREATE, APR_UREAD | APR_UWRITE | APR_GREAD, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_file_write(filetest, TESTSTR, &bytes); + rv = fspr_file_write(filetest, TESTSTR, &bytes); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - apr_file_close(filetest); + fspr_file_close(filetest); } static void test_open_readwrite(abts_case *tc, void *data) { - apr_status_t rv; - apr_file_t *filetest = NULL; + fspr_status_t rv; + fspr_file_t *filetest = NULL; filetest = NULL; - rv = apr_file_open(&filetest, FILENAME, + rv = fspr_file_open(&filetest, FILENAME, APR_READ | APR_WRITE, APR_UREAD | APR_UWRITE | APR_GREAD, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_PTR_NOTNULL(tc, filetest); - apr_file_close(filetest); + fspr_file_close(filetest); } static void test_seek(abts_case *tc, void *data) { - apr_status_t rv; - apr_off_t offset = 5; - apr_size_t nbytes = 256; - char *str = apr_pcalloc(p, nbytes + 1); - apr_file_t *filetest = NULL; + fspr_status_t rv; + fspr_off_t offset = 5; + fspr_size_t nbytes = 256; + char *str = fspr_pcalloc(p, nbytes + 1); + fspr_file_t *filetest = NULL; - rv = apr_file_open(&filetest, FILENAME, + rv = fspr_file_open(&filetest, FILENAME, APR_READ, APR_UREAD | APR_UWRITE | APR_GREAD, p); APR_ASSERT_SUCCESS(tc, "Open test file " FILENAME, rv); - rv = apr_file_read(filetest, str, &nbytes); + rv = fspr_file_read(filetest, str, &nbytes); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, strlen(TESTSTR), nbytes); ABTS_STR_EQUAL(tc, TESTSTR, str); memset(str, 0, nbytes + 1); - rv = apr_file_seek(filetest, SEEK_SET, &offset); + rv = fspr_file_seek(filetest, SEEK_SET, &offset); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_file_read(filetest, str, &nbytes); + rv = fspr_file_read(filetest, str, &nbytes); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, strlen(TESTSTR) - 5, nbytes); ABTS_STR_EQUAL(tc, TESTSTR + 5, str); - apr_file_close(filetest); + fspr_file_close(filetest); /* Test for regression of sign error bug with SEEK_END and buffered files. */ - rv = apr_file_open(&filetest, FILENAME, + rv = fspr_file_open(&filetest, FILENAME, APR_READ | APR_BUFFERED, APR_UREAD | APR_UWRITE | APR_GREAD, p); APR_ASSERT_SUCCESS(tc, "Open test file " FILENAME, rv); offset = -5; - rv = apr_file_seek(filetest, SEEK_END, &offset); + rv = fspr_file_seek(filetest, SEEK_END, &offset); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, strlen(TESTSTR) - 5, nbytes); memset(str, 0, nbytes + 1); nbytes = 256; - rv = apr_file_read(filetest, str, &nbytes); + rv = fspr_file_read(filetest, str, &nbytes); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, 5, nbytes); ABTS_STR_EQUAL(tc, TESTSTR + strlen(TESTSTR) - 5, str); - apr_file_close(filetest); + fspr_file_close(filetest); } static void test_userdata_set(abts_case *tc, void *data) { - apr_status_t rv; - apr_file_t *filetest = NULL; + fspr_status_t rv; + fspr_file_t *filetest = NULL; - rv = apr_file_open(&filetest, FILENAME, + rv = fspr_file_open(&filetest, FILENAME, APR_WRITE, APR_UREAD | APR_UWRITE | APR_GREAD, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_file_data_set(filetest, "This is a test", - "test", apr_pool_cleanup_null); + rv = fspr_file_data_set(filetest, "This is a test", + "test", fspr_pool_cleanup_null); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - apr_file_close(filetest); + fspr_file_close(filetest); } static void test_userdata_get(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; void *udata; char *teststr; - apr_file_t *filetest = NULL; + fspr_file_t *filetest = NULL; - rv = apr_file_open(&filetest, FILENAME, + rv = fspr_file_open(&filetest, FILENAME, APR_WRITE, APR_UREAD | APR_UWRITE | APR_GREAD, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_file_data_set(filetest, "This is a test", - "test", apr_pool_cleanup_null); + rv = fspr_file_data_set(filetest, "This is a test", + "test", fspr_pool_cleanup_null); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_file_data_get(&udata, "test", filetest); + rv = fspr_file_data_get(&udata, "test", filetest); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); teststr = udata; ABTS_STR_EQUAL(tc, "This is a test", teststr); - apr_file_close(filetest); + fspr_file_close(filetest); } static void test_userdata_getnokey(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; void *teststr; - apr_file_t *filetest = NULL; + fspr_file_t *filetest = NULL; - rv = apr_file_open(&filetest, FILENAME, + rv = fspr_file_open(&filetest, FILENAME, APR_WRITE, APR_UREAD | APR_UWRITE | APR_GREAD, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_file_data_get(&teststr, "nokey", filetest); + rv = fspr_file_data_get(&teststr, "nokey", filetest); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_PTR_EQUAL(tc, NULL, teststr); - apr_file_close(filetest); + fspr_file_close(filetest); } static void test_getc(abts_case *tc, void *data) { - apr_file_t *f = NULL; - apr_status_t rv; + fspr_file_t *f = NULL; + fspr_status_t rv; char ch; - rv = apr_file_open(&f, FILENAME, APR_READ, 0, p); + rv = fspr_file_open(&f, FILENAME, APR_READ, 0, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - apr_file_getc(&ch, f); + fspr_file_getc(&ch, f); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, (int)TESTSTR[0], (int)ch); - apr_file_close(f); + fspr_file_close(f); } static void test_ungetc(abts_case *tc, void *data) { - apr_file_t *f = NULL; - apr_status_t rv; + fspr_file_t *f = NULL; + fspr_status_t rv; char ch; - rv = apr_file_open(&f, FILENAME, APR_READ, 0, p); + rv = fspr_file_open(&f, FILENAME, APR_READ, 0, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - apr_file_getc(&ch, f); + fspr_file_getc(&ch, f); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, (int)TESTSTR[0], (int)ch); - apr_file_ungetc('X', f); + fspr_file_ungetc('X', f); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - apr_file_getc(&ch, f); + fspr_file_getc(&ch, f); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, 'X', (int)ch); - apr_file_close(f); + fspr_file_close(f); } static void test_gets(abts_case *tc, void *data) { - apr_file_t *f = NULL; - apr_status_t rv; - char *str = apr_palloc(p, 256); + fspr_file_t *f = NULL; + fspr_status_t rv; + char *str = fspr_palloc(p, 256); - rv = apr_file_open(&f, FILENAME, APR_READ, 0, p); + rv = fspr_file_open(&f, FILENAME, APR_READ, 0, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_file_gets(str, 256, f); + rv = fspr_file_gets(str, 256, f); /* Only one line in the test file, so APR will encounter EOF on the first * call to gets, but we should get APR_SUCCESS on this call and * APR_EOF on the next. */ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_STR_EQUAL(tc, TESTSTR, str); - rv = apr_file_gets(str, 256, f); + rv = fspr_file_gets(str, 256, f); ABTS_INT_EQUAL(tc, APR_EOF, rv); ABTS_STR_EQUAL(tc, "", str); - apr_file_close(f); + fspr_file_close(f); } static void test_bigread(abts_case *tc, void *data) { - apr_file_t *f = NULL; - apr_status_t rv; + fspr_file_t *f = NULL; + fspr_status_t rv; char buf[APR_BUFFERSIZE * 2]; - apr_size_t nbytes; + fspr_size_t nbytes; /* Create a test file with known content. */ - rv = apr_file_open(&f, "data/created_file", + rv = fspr_file_open(&f, "data/created_file", APR_CREATE | APR_WRITE | APR_TRUNCATE, APR_UREAD | APR_UWRITE, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); @@ -403,26 +403,26 @@ static void test_bigread(abts_case *tc, void *data) nbytes = APR_BUFFERSIZE; memset(buf, 0xFE, nbytes); - rv = apr_file_write(f, buf, &nbytes); + rv = fspr_file_write(f, buf, &nbytes); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, APR_BUFFERSIZE, nbytes); - rv = apr_file_close(f); + rv = fspr_file_close(f); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); f = NULL; - rv = apr_file_open(&f, "data/created_file", APR_READ, 0, p); + rv = fspr_file_open(&f, "data/created_file", APR_READ, 0, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); nbytes = sizeof buf; - rv = apr_file_read(f, buf, &nbytes); + rv = fspr_file_read(f, buf, &nbytes); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, APR_BUFFERSIZE, nbytes); - rv = apr_file_close(f); + rv = fspr_file_close(f); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_file_remove("data/created_file", p); + rv = fspr_file_remove("data/created_file", p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); } @@ -431,80 +431,80 @@ static void test_bigread(abts_case *tc, void *data) */ static void test_mod_neg(abts_case *tc, void *data) { - apr_status_t rv; - apr_file_t *f; + fspr_status_t rv; + fspr_file_t *f; const char *s; int i; - apr_size_t nbytes; + fspr_size_t nbytes; char buf[8192]; - apr_off_t cur; + fspr_off_t cur; const char *fname = "data/modneg.dat"; - rv = apr_file_open(&f, fname, + rv = fspr_file_open(&f, fname, APR_CREATE | APR_WRITE, APR_UREAD | APR_UWRITE, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); s = "body56789\n"; nbytes = strlen(s); - rv = apr_file_write(f, s, &nbytes); + rv = fspr_file_write(f, s, &nbytes); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, strlen(s), nbytes); for (i = 0; i < 7980; i++) { s = "0"; nbytes = strlen(s); - rv = apr_file_write(f, s, &nbytes); + rv = fspr_file_write(f, s, &nbytes); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, strlen(s), nbytes); } s = "end456789\n"; nbytes = strlen(s); - rv = apr_file_write(f, s, &nbytes); + rv = fspr_file_write(f, s, &nbytes); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, strlen(s), nbytes); for (i = 0; i < 10000; i++) { s = "1"; nbytes = strlen(s); - rv = apr_file_write(f, s, &nbytes); + rv = fspr_file_write(f, s, &nbytes); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, strlen(s), nbytes); } - rv = apr_file_close(f); + rv = fspr_file_close(f); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_file_open(&f, fname, APR_READ, 0, p); + rv = fspr_file_open(&f, fname, APR_READ, 0, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_file_gets(buf, 11, f); + rv = fspr_file_gets(buf, 11, f); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_STR_EQUAL(tc, "body56789\n", buf); cur = 0; - rv = apr_file_seek(f, APR_CUR, &cur); + rv = fspr_file_seek(f, APR_CUR, &cur); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_ASSERT(tc, "File Pointer Mismatch, expected 10", cur == 10); nbytes = sizeof(buf); - rv = apr_file_read(f, buf, &nbytes); + rv = fspr_file_read(f, buf, &nbytes); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, nbytes, sizeof(buf)); - cur = -((apr_off_t)nbytes - 7980); - rv = apr_file_seek(f, APR_CUR, &cur); + cur = -((fspr_off_t)nbytes - 7980); + rv = fspr_file_seek(f, APR_CUR, &cur); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_ASSERT(tc, "File Pointer Mismatch, expected 7990", cur == 7990); - rv = apr_file_gets(buf, 11, f); + rv = fspr_file_gets(buf, 11, f); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_STR_EQUAL(tc, "end456789\n", buf); - rv = apr_file_close(f); + rv = fspr_file_close(f); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_file_remove(fname, p); + rv = fspr_file_remove(fname, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); } @@ -513,21 +513,21 @@ static void test_mod_neg(abts_case *tc, void *data) static void file_contents_equal(abts_case *tc, const char *fname, const void *expect, - apr_size_t expectlen) + fspr_size_t expectlen) { - void *actual = apr_palloc(p, expectlen); - apr_file_t *f; + void *actual = fspr_palloc(p, expectlen); + fspr_file_t *f; APR_ASSERT_SUCCESS(tc, "open file", - apr_file_open(&f, fname, APR_READ|APR_BUFFERED, + fspr_file_open(&f, fname, APR_READ|APR_BUFFERED, 0, p)); APR_ASSERT_SUCCESS(tc, "read from file", - apr_file_read_full(f, actual, expectlen, NULL)); + fspr_file_read_full(f, actual, expectlen, NULL)); ABTS_ASSERT(tc, "matched expected file contents", memcmp(expect, actual, expectlen) == 0); - APR_ASSERT_SUCCESS(tc, "close file", apr_file_close(f)); + APR_ASSERT_SUCCESS(tc, "close file", fspr_file_close(f)); } #define LINE1 "this is a line of text\n" @@ -535,34 +535,34 @@ static void file_contents_equal(abts_case *tc, static void test_puts(abts_case *tc, void *data) { - apr_file_t *f; + fspr_file_t *f; const char *fname = "data/testputs.txt"; APR_ASSERT_SUCCESS(tc, "open file for writing", - apr_file_open(&f, fname, + fspr_file_open(&f, fname, APR_WRITE|APR_CREATE|APR_TRUNCATE, APR_OS_DEFAULT, p)); APR_ASSERT_SUCCESS(tc, "write line to file", - apr_file_puts(LINE1, f)); + fspr_file_puts(LINE1, f)); APR_ASSERT_SUCCESS(tc, "write second line to file", - apr_file_puts(LINE2, f)); + fspr_file_puts(LINE2, f)); APR_ASSERT_SUCCESS(tc, "close for writing", - apr_file_close(f)); + fspr_file_close(f)); file_contents_equal(tc, fname, LINE1 LINE2, strlen(LINE1 LINE2)); } static void test_writev(abts_case *tc, void *data) { - apr_file_t *f; - apr_size_t nbytes; + fspr_file_t *f; + fspr_size_t nbytes; struct iovec vec[5]; const char *fname = "data/testwritev.txt"; APR_ASSERT_SUCCESS(tc, "open file for writing", - apr_file_open(&f, fname, + fspr_file_open(&f, fname, APR_WRITE|APR_CREATE|APR_TRUNCATE, APR_OS_DEFAULT, p)); @@ -570,7 +570,7 @@ static void test_writev(abts_case *tc, void *data) vec[0].iov_len = strlen(LINE1); APR_ASSERT_SUCCESS(tc, "writev of size 1 to file", - apr_file_writev(f, vec, 1, &nbytes)); + fspr_file_writev(f, vec, 1, &nbytes)); file_contents_equal(tc, fname, LINE1, strlen(LINE1)); @@ -586,10 +586,10 @@ static void test_writev(abts_case *tc, void *data) vec[4].iov_len = strlen(LINE2); APR_ASSERT_SUCCESS(tc, "writev of size 5 to file", - apr_file_writev(f, vec, 5, &nbytes)); + fspr_file_writev(f, vec, 5, &nbytes)); APR_ASSERT_SUCCESS(tc, "close for writing", - apr_file_close(f)); + fspr_file_close(f)); file_contents_equal(tc, fname, LINE1 LINE1 LINE2 LINE1 LINE1 LINE2, strlen(LINE1)*4 + strlen(LINE2)*2); @@ -598,13 +598,13 @@ static void test_writev(abts_case *tc, void *data) static void test_writev_full(abts_case *tc, void *data) { - apr_file_t *f; - apr_size_t nbytes; + fspr_file_t *f; + fspr_size_t nbytes; struct iovec vec[5]; const char *fname = "data/testwritev_full.txt"; APR_ASSERT_SUCCESS(tc, "open file for writing", - apr_file_open(&f, fname, + fspr_file_open(&f, fname, APR_WRITE|APR_CREATE|APR_TRUNCATE, APR_OS_DEFAULT, p)); @@ -620,12 +620,12 @@ static void test_writev_full(abts_case *tc, void *data) vec[4].iov_len = strlen(LINE2); APR_ASSERT_SUCCESS(tc, "writev_full of size 5 to file", - apr_file_writev_full(f, vec, 5, &nbytes)); + fspr_file_writev_full(f, vec, 5, &nbytes)); ABTS_INT_EQUAL(tc, strlen(LINE1)*3 + strlen(LINE2)*2, nbytes); APR_ASSERT_SUCCESS(tc, "close for writing", - apr_file_close(f)); + fspr_file_close(f)); file_contents_equal(tc, fname, LINE1 LINE2 LINE1 LINE1 LINE2, strlen(LINE1)*3 + strlen(LINE2)*2); @@ -634,54 +634,54 @@ static void test_writev_full(abts_case *tc, void *data) static void test_truncate(abts_case *tc, void *data) { - apr_status_t rv; - apr_file_t *f; + fspr_status_t rv; + fspr_file_t *f; const char *fname = "data/testtruncate.dat"; const char *s; - apr_size_t nbytes; - apr_finfo_t finfo; + fspr_size_t nbytes; + fspr_finfo_t finfo; - apr_file_remove(fname, p); + fspr_file_remove(fname, p); - rv = apr_file_open(&f, fname, + rv = fspr_file_open(&f, fname, APR_CREATE | APR_WRITE, APR_UREAD | APR_UWRITE, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); s = "some data"; nbytes = strlen(s); - rv = apr_file_write(f, s, &nbytes); + rv = fspr_file_write(f, s, &nbytes); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, strlen(s), nbytes); - rv = apr_file_close(f); + rv = fspr_file_close(f); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_file_open(&f, fname, + rv = fspr_file_open(&f, fname, APR_TRUNCATE | APR_WRITE, APR_UREAD | APR_UWRITE, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_file_close(f); + rv = fspr_file_close(f); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_stat(&finfo, fname, APR_FINFO_SIZE, p); + rv = fspr_stat(&finfo, fname, APR_FINFO_SIZE, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_ASSERT(tc, "File size mismatch, expected 0 (empty)", finfo.size == 0); - rv = apr_file_remove(fname, p); + rv = fspr_file_remove(fname, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); } static void test_bigfprintf(abts_case *tc, void *data) { - apr_file_t *f; + fspr_file_t *f; const char *fname = "data/testbigfprintf.dat"; char *to_write; int i; - apr_file_remove(fname, p); + fspr_file_remove(fname, p); APR_ASSERT_SUCCESS(tc, "open test file", - apr_file_open(&f, fname, + fspr_file_open(&f, fname, APR_CREATE|APR_WRITE, APR_UREAD|APR_UWRITE, p)); @@ -693,10 +693,10 @@ static void test_bigfprintf(abts_case *tc, void *data) strcpy(to_write + HUGE_STRING_LEN, "42"); - i = apr_file_printf(f, "%s", to_write); + i = fspr_file_printf(f, "%s", to_write); ABTS_INT_EQUAL(tc, HUGE_STRING_LEN + 2, i); - apr_file_close(f); + fspr_file_close(f); file_contents_equal(tc, fname, to_write, HUGE_STRING_LEN + 2); @@ -705,16 +705,16 @@ static void test_bigfprintf(abts_case *tc, void *data) static void test_fail_write_flush(abts_case *tc, void *data) { - apr_file_t *f; + fspr_file_t *f; const char *fname = "data/testflush.dat"; - apr_status_t rv; + fspr_status_t rv; char buf[APR_BUFFERSIZE]; int n; - apr_file_remove(fname, p); + fspr_file_remove(fname, p); APR_ASSERT_SUCCESS(tc, "open test file", - apr_file_open(&f, fname, + fspr_file_open(&f, fname, APR_CREATE|APR_READ|APR_BUFFERED, APR_UREAD|APR_UWRITE, p)); @@ -724,110 +724,110 @@ static void test_fail_write_flush(abts_case *tc, void *data) * internal buffer and actually tries to write to the file, which * was opened read-only and hence should be unwritable. */ for (n = 0, rv = APR_SUCCESS; n < 4 && rv == APR_SUCCESS; n++) { - apr_size_t bytes = sizeof buf; - rv = apr_file_write(f, buf, &bytes); + fspr_size_t bytes = sizeof buf; + rv = fspr_file_write(f, buf, &bytes); } ABTS_ASSERT(tc, "failed to write to read-only buffered fd", rv != APR_SUCCESS); - apr_file_close(f); + fspr_file_close(f); } static void test_fail_read_flush(abts_case *tc, void *data) { - apr_file_t *f; + fspr_file_t *f; const char *fname = "data/testflush.dat"; - apr_status_t rv; + fspr_status_t rv; char buf[2]; - apr_file_remove(fname, p); + fspr_file_remove(fname, p); APR_ASSERT_SUCCESS(tc, "open test file", - apr_file_open(&f, fname, + fspr_file_open(&f, fname, APR_CREATE|APR_READ|APR_BUFFERED, APR_UREAD|APR_UWRITE, p)); /* this write should be buffered. */ APR_ASSERT_SUCCESS(tc, "buffered write should succeed", - apr_file_puts("hello", f)); + fspr_file_puts("hello", f)); /* Now, trying a read should fail since the write must be flushed, * and should fail with something other than EOF since the file is * opened read-only. */ - rv = apr_file_read_full(f, buf, 2, NULL); + rv = fspr_file_read_full(f, buf, 2, NULL); ABTS_ASSERT(tc, "read should flush buffered write and fail", rv != APR_SUCCESS && rv != APR_EOF); /* Likewise for gets */ - rv = apr_file_gets(buf, 2, f); + rv = fspr_file_gets(buf, 2, f); ABTS_ASSERT(tc, "gets should flush buffered write and fail", rv != APR_SUCCESS && rv != APR_EOF); /* Likewise for seek. */ { - apr_off_t offset = 0; + fspr_off_t offset = 0; - rv = apr_file_seek(f, APR_SET, &offset); + rv = fspr_file_seek(f, APR_SET, &offset); } ABTS_ASSERT(tc, "seek should flush buffered write and fail", rv != APR_SUCCESS && rv != APR_EOF); - apr_file_close(f); + fspr_file_close(f); } static void test_xthread(abts_case *tc, void *data) { - apr_file_t *f; + fspr_file_t *f; const char *fname = "data/testxthread.dat"; - apr_status_t rv; - apr_int32_t flags = APR_CREATE|APR_READ|APR_WRITE|APR_APPEND|APR_XTHREAD; + fspr_status_t rv; + fspr_int32_t flags = APR_CREATE|APR_READ|APR_WRITE|APR_APPEND|APR_XTHREAD; char buf[128] = { 0 }; /* Test for bug 38438, opening file with append + xthread and seeking to the end of the file resulted in writes going to the beginning not the end. */ - apr_file_remove(fname, p); + fspr_file_remove(fname, p); APR_ASSERT_SUCCESS(tc, "open test file", - apr_file_open(&f, fname, flags, + fspr_file_open(&f, fname, flags, APR_UREAD|APR_UWRITE, p)); APR_ASSERT_SUCCESS(tc, "write should succeed", - apr_file_puts("hello", f)); + fspr_file_puts("hello", f)); - apr_file_close(f); + fspr_file_close(f); APR_ASSERT_SUCCESS(tc, "open test file", - apr_file_open(&f, fname, flags, + fspr_file_open(&f, fname, flags, APR_UREAD|APR_UWRITE, p)); /* Seek to the end. */ { - apr_off_t offset = 0; + fspr_off_t offset = 0; - rv = apr_file_seek(f, APR_END, &offset); + rv = fspr_file_seek(f, APR_END, &offset); } APR_ASSERT_SUCCESS(tc, "more writes should succeed", - apr_file_puts("world", f)); + fspr_file_puts("world", f)); /* Back to the beginning. */ { - apr_off_t offset = 0; + fspr_off_t offset = 0; - rv = apr_file_seek(f, APR_SET, &offset); + rv = fspr_file_seek(f, APR_SET, &offset); } - apr_file_read_full(f, buf, sizeof(buf), NULL); + fspr_file_read_full(f, buf, sizeof(buf), NULL); ABTS_STR_EQUAL(tc, "helloworld", buf); - apr_file_close(f); + fspr_file_close(f); } abts_suite *testfile(abts_suite *suite) diff --git a/libs/apr/test/testfilecopy.c b/libs/apr/test/testfilecopy.c index 730b1f0195..17d9fdda6b 100644 --- a/libs/apr/test/testfilecopy.c +++ b/libs/apr/test/testfilecopy.c @@ -15,34 +15,34 @@ */ #include "testutil.h" -#include "apr_file_io.h" -#include "apr_file_info.h" -#include "apr_errno.h" -#include "apr_pools.h" +#include "fspr_file_io.h" +#include "fspr_file_info.h" +#include "fspr_errno.h" +#include "fspr_pools.h" static void copy_helper(abts_case *tc, const char *from, const char * to, - apr_fileperms_t perms, int append, apr_pool_t *p) + fspr_fileperms_t perms, int append, fspr_pool_t *p) { - apr_status_t rv; - apr_status_t dest_rv; - apr_finfo_t copy; - apr_finfo_t orig; - apr_finfo_t dest; + fspr_status_t rv; + fspr_status_t dest_rv; + fspr_finfo_t copy; + fspr_finfo_t orig; + fspr_finfo_t dest; - dest_rv = apr_stat(&dest, to, APR_FINFO_SIZE, p); + dest_rv = fspr_stat(&dest, to, APR_FINFO_SIZE, p); if (!append) { - rv = apr_file_copy(from, to, perms, p); + rv = fspr_file_copy(from, to, perms, p); } else { - rv = apr_file_append(from, to, perms, p); + rv = fspr_file_append(from, to, perms, p); } APR_ASSERT_SUCCESS(tc, "Error copying file", rv); - rv = apr_stat(&orig, from, APR_FINFO_SIZE, p); + rv = fspr_stat(&orig, from, APR_FINFO_SIZE, p); APR_ASSERT_SUCCESS(tc, "Couldn't stat original file", rv); - rv = apr_stat(©, to, APR_FINFO_SIZE, p); + rv = fspr_stat(©, to, APR_FINFO_SIZE, p); APR_ASSERT_SUCCESS(tc, "Couldn't stat copy file", rv); if (!append) { @@ -57,23 +57,23 @@ static void copy_helper(abts_case *tc, const char *from, const char * to, static void copy_short_file(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; /* make absolutely sure that the dest file doesn't exist. */ - apr_file_remove("data/file_copy.txt", p); + fspr_file_remove("data/file_copy.txt", p); copy_helper(tc, "data/file_datafile.txt", "data/file_copy.txt", APR_FILE_SOURCE_PERMS, 0, p); - rv = apr_file_remove("data/file_copy.txt", p); + rv = fspr_file_remove("data/file_copy.txt", p); APR_ASSERT_SUCCESS(tc, "Couldn't remove copy file", rv); } static void copy_over_existing(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; /* make absolutely sure that the dest file doesn't exist. */ - apr_file_remove("data/file_copy.txt", p); + fspr_file_remove("data/file_copy.txt", p); /* This is a cheat. I don't want to create a new file, so I just copy * one file, then I copy another. If the second copy succeeds, then @@ -85,29 +85,29 @@ static void copy_over_existing(abts_case *tc, void *data) copy_helper(tc, "data/mmap_datafile.txt", "data/file_copy.txt", APR_FILE_SOURCE_PERMS, 0, p); - rv = apr_file_remove("data/file_copy.txt", p); + rv = fspr_file_remove("data/file_copy.txt", p); APR_ASSERT_SUCCESS(tc, "Couldn't remove copy file", rv); } static void append_nonexist(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; /* make absolutely sure that the dest file doesn't exist. */ - apr_file_remove("data/file_copy.txt", p); + fspr_file_remove("data/file_copy.txt", p); copy_helper(tc, "data/file_datafile.txt", "data/file_copy.txt", APR_FILE_SOURCE_PERMS, 0, p); - rv = apr_file_remove("data/file_copy.txt", p); + rv = fspr_file_remove("data/file_copy.txt", p); APR_ASSERT_SUCCESS(tc, "Couldn't remove copy file", rv); } static void append_exist(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; /* make absolutely sure that the dest file doesn't exist. */ - apr_file_remove("data/file_copy.txt", p); + fspr_file_remove("data/file_copy.txt", p); /* This is a cheat. I don't want to create a new file, so I just copy * one file, then I copy another. If the second copy succeeds, then @@ -119,7 +119,7 @@ static void append_exist(abts_case *tc, void *data) copy_helper(tc, "data/mmap_datafile.txt", "data/file_copy.txt", APR_FILE_SOURCE_PERMS, 1, p); - rv = apr_file_remove("data/file_copy.txt", p); + rv = fspr_file_remove("data/file_copy.txt", p); APR_ASSERT_SUCCESS(tc, "Couldn't remove copy file", rv); } diff --git a/libs/apr/test/testfileinfo.c b/libs/apr/test/testfileinfo.c index f437d7dddc..0fb02b991d 100644 --- a/libs/apr/test/testfileinfo.c +++ b/libs/apr/test/testfileinfo.c @@ -14,13 +14,13 @@ * limitations under the License. */ -#include "apr_file_io.h" -#include "apr_file_info.h" -#include "apr_strings.h" -#include "apr_errno.h" -#include "apr_general.h" -#include "apr_poll.h" -#include "apr_lib.h" +#include "fspr_file_io.h" +#include "fspr_file_info.h" +#include "fspr_strings.h" +#include "fspr_errno.h" +#include "fspr_general.h" +#include "fspr_poll.h" +#include "fspr_lib.h" #include "testutil.h" #define FILENAME "data/file_datafile.txt" @@ -29,7 +29,7 @@ static const struct view_fileinfo { - apr_int32_t bits; + fspr_int32_t bits; char *description; } vfi[] = { {APR_FINFO_MTIME, "MTIME"}, @@ -48,99 +48,99 @@ static const struct view_fileinfo {0, NULL} }; -static void finfo_equal(abts_case *tc, apr_finfo_t *f1, apr_finfo_t *f2) +static void finfo_equal(abts_case *tc, fspr_finfo_t *f1, fspr_finfo_t *f2) { /* Minimum supported flags across all platforms (APR_FINFO_MIN) */ - ABTS_ASSERT(tc, "apr_stat and apr_getfileinfo must return APR_FINFO_TYPE", + ABTS_ASSERT(tc, "fspr_stat and fspr_getfileinfo must return APR_FINFO_TYPE", (f1->valid & f2->valid & APR_FINFO_TYPE)); - ABTS_ASSERT(tc, "apr_stat and apr_getfileinfo differ in filetype", + ABTS_ASSERT(tc, "fspr_stat and fspr_getfileinfo differ in filetype", f1->filetype == f2->filetype); - ABTS_ASSERT(tc, "apr_stat and apr_getfileinfo must return APR_FINFO_SIZE", + ABTS_ASSERT(tc, "fspr_stat and fspr_getfileinfo must return APR_FINFO_SIZE", (f1->valid & f2->valid & APR_FINFO_SIZE)); - ABTS_ASSERT(tc, "apr_stat and apr_getfileinfo differ in size", + ABTS_ASSERT(tc, "fspr_stat and fspr_getfileinfo differ in size", f1->size == f2->size); - ABTS_ASSERT(tc, "apr_stat and apr_getfileinfo must return APR_FINFO_ATIME", + ABTS_ASSERT(tc, "fspr_stat and fspr_getfileinfo must return APR_FINFO_ATIME", (f1->valid & f2->valid & APR_FINFO_ATIME)); - ABTS_ASSERT(tc, "apr_stat and apr_getfileinfo differ in atime", + ABTS_ASSERT(tc, "fspr_stat and fspr_getfileinfo differ in atime", f1->atime == f2->atime); - ABTS_ASSERT(tc, "apr_stat and apr_getfileinfo must return APR_FINFO_MTIME", + ABTS_ASSERT(tc, "fspr_stat and fspr_getfileinfo must return APR_FINFO_MTIME", (f1->valid & f2->valid & APR_FINFO_MTIME)); - ABTS_ASSERT(tc, "apr_stat and apr_getfileinfo differ in mtime", + ABTS_ASSERT(tc, "fspr_stat and fspr_getfileinfo differ in mtime", f1->mtime == f2->mtime); - ABTS_ASSERT(tc, "apr_stat and apr_getfileinfo must return APR_FINFO_CTIME", + ABTS_ASSERT(tc, "fspr_stat and fspr_getfileinfo must return APR_FINFO_CTIME", (f1->valid & f2->valid & APR_FINFO_CTIME)); - ABTS_ASSERT(tc, "apr_stat and apr_getfileinfo differ in ctime", + ABTS_ASSERT(tc, "fspr_stat and fspr_getfileinfo differ in ctime", f1->ctime == f2->ctime); if (f1->valid & f2->valid & APR_FINFO_NAME) - ABTS_ASSERT(tc, "apr_stat and apr_getfileinfo differ in name", + ABTS_ASSERT(tc, "fspr_stat and fspr_getfileinfo differ in name", !strcmp(f1->name, f2->name)); if (f1->fname && f2->fname) - ABTS_ASSERT(tc, "apr_stat and apr_getfileinfo differ in fname", + ABTS_ASSERT(tc, "fspr_stat and fspr_getfileinfo differ in fname", !strcmp(f1->fname, f2->fname)); /* Additional supported flags not supported on all platforms */ if (f1->valid & f2->valid & APR_FINFO_USER) - ABTS_ASSERT(tc, "apr_stat and apr_getfileinfo differ in user", - !apr_uid_compare(f1->user, f2->user)); + ABTS_ASSERT(tc, "fspr_stat and fspr_getfileinfo differ in user", + !fspr_uid_compare(f1->user, f2->user)); if (f1->valid & f2->valid & APR_FINFO_GROUP) - ABTS_ASSERT(tc, "apr_stat and apr_getfileinfo differ in group", - !apr_gid_compare(f1->group, f2->group)); + ABTS_ASSERT(tc, "fspr_stat and fspr_getfileinfo differ in group", + !fspr_gid_compare(f1->group, f2->group)); if (f1->valid & f2->valid & APR_FINFO_INODE) - ABTS_ASSERT(tc, "apr_stat and apr_getfileinfo differ in inode", + ABTS_ASSERT(tc, "fspr_stat and fspr_getfileinfo differ in inode", f1->inode == f2->inode); if (f1->valid & f2->valid & APR_FINFO_DEV) - ABTS_ASSERT(tc, "apr_stat and apr_getfileinfo differ in device", + ABTS_ASSERT(tc, "fspr_stat and fspr_getfileinfo differ in device", f1->device == f2->device); if (f1->valid & f2->valid & APR_FINFO_NLINK) - ABTS_ASSERT(tc, "apr_stat and apr_getfileinfo differ in nlink", + ABTS_ASSERT(tc, "fspr_stat and fspr_getfileinfo differ in nlink", f1->nlink == f2->nlink); if (f1->valid & f2->valid & APR_FINFO_CSIZE) - ABTS_ASSERT(tc, "apr_stat and apr_getfileinfo differ in csize", + ABTS_ASSERT(tc, "fspr_stat and fspr_getfileinfo differ in csize", f1->csize == f2->csize); if (f1->valid & f2->valid & APR_FINFO_PROT) - ABTS_ASSERT(tc, "apr_stat and apr_getfileinfo differ in protection", + ABTS_ASSERT(tc, "fspr_stat and fspr_getfileinfo differ in protection", f1->protection == f2->protection); } static void test_info_get(abts_case *tc, void *data) { - apr_file_t *thefile; - apr_finfo_t finfo; - apr_status_t rv; + fspr_file_t *thefile; + fspr_finfo_t finfo; + fspr_status_t rv; - rv = apr_file_open(&thefile, FILENAME, APR_READ, APR_OS_DEFAULT, p); + rv = fspr_file_open(&thefile, FILENAME, APR_READ, APR_OS_DEFAULT, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_file_info_get(&finfo, APR_FINFO_NORM, thefile); + rv = fspr_file_info_get(&finfo, APR_FINFO_NORM, thefile); if (rv == APR_INCOMPLETE) { char *str; int i; - str = apr_pstrdup(p, "APR_INCOMPLETE: Missing "); + str = fspr_pstrdup(p, "APR_INCOMPLETE: Missing "); for (i = 0; vfi[i].bits; ++i) { if (vfi[i].bits & ~finfo.valid) { - str = apr_pstrcat(p, str, vfi[i].description, " ", NULL); + str = fspr_pstrcat(p, str, vfi[i].description, " ", NULL); } } ABTS_FAIL(tc, str); } ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - apr_file_close(thefile); + fspr_file_close(thefile); } static void test_stat(abts_case *tc, void *data) { - apr_finfo_t finfo; - apr_status_t rv; + fspr_finfo_t finfo; + fspr_status_t rv; - rv = apr_stat(&finfo, FILENAME, APR_FINFO_NORM, p); + rv = fspr_stat(&finfo, FILENAME, APR_FINFO_NORM, p); if (rv == APR_INCOMPLETE) { char *str; int i; - str = apr_pstrdup(p, "APR_INCOMPLETE: Missing "); + str = fspr_pstrdup(p, "APR_INCOMPLETE: Missing "); for (i = 0; vfi[i].bits; ++i) { if (vfi[i].bits & ~finfo.valid) { - str = apr_pstrcat(p, str, vfi[i].description, " ", NULL); + str = fspr_pstrcat(p, str, vfi[i].description, " ", NULL); } } ABTS_FAIL(tc, str); @@ -150,36 +150,36 @@ static void test_stat(abts_case *tc, void *data) static void test_stat_eq_finfo(abts_case *tc, void *data) { - apr_file_t *thefile; - apr_finfo_t finfo; - apr_finfo_t stat_finfo; - apr_status_t rv; + fspr_file_t *thefile; + fspr_finfo_t finfo; + fspr_finfo_t stat_finfo; + fspr_status_t rv; - rv = apr_file_open(&thefile, FILENAME, APR_READ, APR_OS_DEFAULT, p); + rv = fspr_file_open(&thefile, FILENAME, APR_READ, APR_OS_DEFAULT, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_file_info_get(&finfo, APR_FINFO_NORM, thefile); + rv = fspr_file_info_get(&finfo, APR_FINFO_NORM, thefile); /* Opening the file may have toggled the atime member (time last - * accessed), so fetch our apr_stat() after getting the fileinfo + * accessed), so fetch our fspr_stat() after getting the fileinfo * of the open file... */ - rv = apr_stat(&stat_finfo, FILENAME, APR_FINFO_NORM, p); + rv = fspr_stat(&stat_finfo, FILENAME, APR_FINFO_NORM, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - apr_file_close(thefile); + fspr_file_close(thefile); finfo_equal(tc, &stat_finfo, &finfo); } static void test_buffered_write_size(abts_case *tc, void *data) { - const apr_size_t data_len = strlen(NEWFILEDATA); - apr_file_t *thefile; - apr_finfo_t finfo; - apr_status_t rv; - apr_size_t bytes; + const fspr_size_t data_len = strlen(NEWFILEDATA); + fspr_file_t *thefile; + fspr_finfo_t finfo; + fspr_status_t rv; + fspr_size_t bytes; - rv = apr_file_open(&thefile, NEWFILENAME, + rv = fspr_file_open(&thefile, NEWFILENAME, APR_READ | APR_WRITE | APR_CREATE | APR_TRUNCATE | APR_BUFFERED | APR_DELONCLOSE, APR_OS_DEFAULT, p); @@ -187,46 +187,46 @@ static void test_buffered_write_size(abts_case *tc, void *data) /* A funny thing happened to me the other day: I wrote something * into a buffered file, then asked for its size using - * apr_file_info_get; and guess what? The size was 0! That's not a + * fspr_file_info_get; and guess what? The size was 0! That's not a * nice way to behave. */ bytes = data_len; - rv = apr_file_write(thefile, NEWFILEDATA, &bytes); + rv = fspr_file_write(thefile, NEWFILEDATA, &bytes); APR_ASSERT_SUCCESS(tc, "write file contents", rv); ABTS_TRUE(tc, data_len == bytes); - rv = apr_file_info_get(&finfo, APR_FINFO_SIZE, thefile); + rv = fspr_file_info_get(&finfo, APR_FINFO_SIZE, thefile); APR_ASSERT_SUCCESS(tc, "get file size", rv); - ABTS_TRUE(tc, bytes == (apr_size_t) finfo.size); - apr_file_close(thefile); + ABTS_TRUE(tc, bytes == (fspr_size_t) finfo.size); + fspr_file_close(thefile); } static void test_mtime_set(abts_case *tc, void *data) { - apr_file_t *thefile; - apr_finfo_t finfo; - apr_time_t epoch = 0; - apr_status_t rv; + fspr_file_t *thefile; + fspr_finfo_t finfo; + fspr_time_t epoch = 0; + fspr_status_t rv; /* This test sort of depends on the system clock being at least * marginally ccorrect; We'll be setting the modification time to * the epoch. */ - rv = apr_file_open(&thefile, NEWFILENAME, + rv = fspr_file_open(&thefile, NEWFILENAME, APR_READ | APR_WRITE | APR_CREATE | APR_TRUNCATE | APR_BUFFERED | APR_DELONCLOSE, APR_OS_DEFAULT, p); APR_ASSERT_SUCCESS(tc, "open file", rv); /* Check that the current mtime is not the epoch */ - rv = apr_stat(&finfo, NEWFILENAME, APR_FINFO_MTIME, p); + rv = fspr_stat(&finfo, NEWFILENAME, APR_FINFO_MTIME, p); if (rv == APR_INCOMPLETE) { char *str; int i; - str = apr_pstrdup(p, "APR_INCOMPLETE: Missing "); + str = fspr_pstrdup(p, "APR_INCOMPLETE: Missing "); for (i = 0; vfi[i].bits; ++i) { if (vfi[i].bits & ~finfo.valid) { - str = apr_pstrcat(p, str, vfi[i].description, " ", NULL); + str = fspr_pstrcat(p, str, vfi[i].description, " ", NULL); } } ABTS_FAIL(tc, str); @@ -235,17 +235,17 @@ static void test_mtime_set(abts_case *tc, void *data) ABTS_TRUE(tc, finfo.mtime != epoch); /* Reset the mtime to the epoch and verify the result. - * Note: we blindly assume that if the first apr_stat succeeded, + * Note: we blindly assume that if the first fspr_stat succeeded, * the second one will, too. */ - rv = apr_file_mtime_set(NEWFILENAME, epoch, p); + rv = fspr_file_mtime_set(NEWFILENAME, epoch, p); APR_ASSERT_SUCCESS(tc, "set mtime", rv); - rv = apr_stat(&finfo, NEWFILENAME, APR_FINFO_MTIME, p); + rv = fspr_stat(&finfo, NEWFILENAME, APR_FINFO_MTIME, p); APR_ASSERT_SUCCESS(tc, "get modified mtime", rv); ABTS_TRUE(tc, finfo.mtime == epoch); - apr_file_close(thefile); + fspr_file_close(thefile); } abts_suite *testfileinfo(abts_suite *suite) diff --git a/libs/apr/test/testflock.c b/libs/apr/test/testflock.c index 6eac94a7a0..545ba300ce 100644 --- a/libs/apr/test/testflock.c +++ b/libs/apr/test/testflock.c @@ -16,39 +16,39 @@ #include "testflock.h" #include "testutil.h" -#include "apr_pools.h" -#include "apr_thread_proc.h" -#include "apr_file_io.h" -#include "apr_file_info.h" -#include "apr_general.h" -#include "apr_strings.h" +#include "fspr_pools.h" +#include "fspr_thread_proc.h" +#include "fspr_file_io.h" +#include "fspr_file_info.h" +#include "fspr_general.h" +#include "fspr_strings.h" static int launch_reader(abts_case *tc) { - apr_proc_t proc = {0}; - apr_procattr_t *procattr; + fspr_proc_t proc = {0}; + fspr_procattr_t *procattr; const char *args[2]; - apr_status_t rv; - apr_exit_why_e why; + fspr_status_t rv; + fspr_exit_why_e why; int exitcode; - rv = apr_procattr_create(&procattr, p); + rv = fspr_procattr_create(&procattr, p); APR_ASSERT_SUCCESS(tc, "Couldn't create procattr", rv); - rv = apr_procattr_io_set(procattr, APR_NO_PIPE, APR_NO_PIPE, + rv = fspr_procattr_io_set(procattr, APR_NO_PIPE, APR_NO_PIPE, APR_NO_PIPE); APR_ASSERT_SUCCESS(tc, "Couldn't set io in procattr", rv); - rv = apr_procattr_error_check_set(procattr, 1); + rv = fspr_procattr_error_check_set(procattr, 1); APR_ASSERT_SUCCESS(tc, "Couldn't set error check in procattr", rv); args[0] = "tryread" EXTENSION; args[1] = NULL; - rv = apr_proc_create(&proc, "./tryread" EXTENSION, args, NULL, procattr, p); + rv = fspr_proc_create(&proc, "./tryread" EXTENSION, args, NULL, procattr, p); APR_ASSERT_SUCCESS(tc, "Couldn't launch program", rv); ABTS_ASSERT(tc, "wait for child process", - apr_proc_wait(&proc, &exitcode, &why, APR_WAIT) == APR_CHILD_DONE); + fspr_proc_wait(&proc, &exitcode, &why, APR_WAIT) == APR_CHILD_DONE); ABTS_ASSERT(tc, "child terminated normally", why == APR_PROC_EXIT); return exitcode; @@ -56,23 +56,23 @@ static int launch_reader(abts_case *tc) static void test_withlock(abts_case *tc, void *data) { - apr_file_t *file; - apr_status_t rv; + fspr_file_t *file; + fspr_status_t rv; int code; - rv = apr_file_open(&file, TESTFILE, APR_WRITE|APR_CREATE, + rv = fspr_file_open(&file, TESTFILE, APR_WRITE|APR_CREATE, APR_OS_DEFAULT, p); APR_ASSERT_SUCCESS(tc, "Could not create file.", rv); ABTS_PTR_NOTNULL(tc, file); - rv = apr_file_lock(file, APR_FLOCK_EXCLUSIVE); + rv = fspr_file_lock(file, APR_FLOCK_EXCLUSIVE); APR_ASSERT_SUCCESS(tc, "Could not lock the file.", rv); ABTS_PTR_NOTNULL(tc, file); code = launch_reader(tc); ABTS_INT_EQUAL(tc, FAILED_READ, code); - (void) apr_file_close(file); + (void) fspr_file_close(file); } static void test_withoutlock(abts_case *tc, void *data) @@ -86,7 +86,7 @@ static void test_withoutlock(abts_case *tc, void *data) static void remove_lockfile(abts_case *tc, void *data) { APR_ASSERT_SUCCESS(tc, "Couldn't remove lock file.", - apr_file_remove(TESTFILE, p)); + fspr_file_remove(TESTFILE, p)); } abts_suite *testflock(abts_suite *suite) diff --git a/libs/apr/test/testfmt.c b/libs/apr/test/testfmt.c index 9ddb639f0f..5e345c45e8 100644 --- a/libs/apr/test/testfmt.c +++ b/libs/apr/test/testfmt.c @@ -15,40 +15,40 @@ */ #include "testutil.h" -#include "apr.h" -#include "apr_portable.h" -#include "apr_strings.h" +#include "fspr.h" +#include "fspr_portable.h" +#include "fspr_strings.h" static void ssize_t_fmt(abts_case *tc, void *data) { char buf[100]; - apr_ssize_t var = 0; + fspr_ssize_t var = 0; sprintf(buf, "%" APR_SSIZE_T_FMT, var); ABTS_STR_EQUAL(tc, "0", buf); - apr_snprintf(buf, sizeof(buf), "%" APR_SSIZE_T_FMT, var); + fspr_snprintf(buf, sizeof(buf), "%" APR_SSIZE_T_FMT, var); ABTS_STR_EQUAL(tc, "0", buf); } static void size_t_fmt(abts_case *tc, void *data) { char buf[100]; - apr_size_t var = 0; + fspr_size_t var = 0; sprintf(buf, "%" APR_SIZE_T_FMT, var); ABTS_STR_EQUAL(tc, "0", buf); - apr_snprintf(buf, sizeof(buf), "%" APR_SIZE_T_FMT, var); + fspr_snprintf(buf, sizeof(buf), "%" APR_SIZE_T_FMT, var); ABTS_STR_EQUAL(tc, "0", buf); } static void off_t_fmt(abts_case *tc, void *data) { char buf[100]; - apr_off_t var = 0; + fspr_off_t var = 0; sprintf(buf, "%" APR_OFF_T_FMT, var); ABTS_STR_EQUAL(tc, "0", buf); - apr_snprintf(buf, sizeof(buf), "%" APR_OFF_T_FMT, var); + fspr_snprintf(buf, sizeof(buf), "%" APR_OFF_T_FMT, var); ABTS_STR_EQUAL(tc, "0", buf); } @@ -59,61 +59,61 @@ static void pid_t_fmt(abts_case *tc, void *data) sprintf(buf, "%" APR_PID_T_FMT, var); ABTS_STR_EQUAL(tc, "0", buf); - apr_snprintf(buf, sizeof(buf), "%" APR_PID_T_FMT, var); + fspr_snprintf(buf, sizeof(buf), "%" APR_PID_T_FMT, var); ABTS_STR_EQUAL(tc, "0", buf); } static void int64_t_fmt(abts_case *tc, void *data) { char buf[100]; - apr_int64_t var = 0; + fspr_int64_t var = 0; sprintf(buf, "%" APR_INT64_T_FMT, var); ABTS_STR_EQUAL(tc, "0", buf); - apr_snprintf(buf, sizeof(buf), "%" APR_INT64_T_FMT, var); + fspr_snprintf(buf, sizeof(buf), "%" APR_INT64_T_FMT, var); ABTS_STR_EQUAL(tc, "0", buf); } static void uint64_t_fmt(abts_case *tc, void *data) { char buf[100]; - apr_uint64_t var = APR_UINT64_C(14000000); + fspr_uint64_t var = APR_UINT64_C(14000000); sprintf(buf, "%" APR_UINT64_T_FMT, var); ABTS_STR_EQUAL(tc, "14000000", buf); - apr_snprintf(buf, sizeof(buf), "%" APR_UINT64_T_FMT, var); + fspr_snprintf(buf, sizeof(buf), "%" APR_UINT64_T_FMT, var); ABTS_STR_EQUAL(tc, "14000000", buf); } static void uint64_t_hex_fmt(abts_case *tc, void *data) { char buf[100]; - apr_uint64_t var = APR_UINT64_C(14000000); + fspr_uint64_t var = APR_UINT64_C(14000000); sprintf(buf, "%" APR_UINT64_T_HEX_FMT, var); ABTS_STR_EQUAL(tc, "d59f80", buf); - apr_snprintf(buf, sizeof(buf), "%" APR_UINT64_T_HEX_FMT, var); + fspr_snprintf(buf, sizeof(buf), "%" APR_UINT64_T_HEX_FMT, var); ABTS_STR_EQUAL(tc, "d59f80", buf); } static void more_int64_fmts(abts_case *tc, void *data) { char buf[100]; - apr_int64_t i = APR_INT64_C(-42); - apr_int64_t ibig = APR_INT64_C(-314159265358979323); - apr_uint64_t ui = APR_UINT64_C(42); - apr_uint64_t big = APR_UINT64_C(3141592653589793238); + fspr_int64_t i = APR_INT64_C(-42); + fspr_int64_t ibig = APR_INT64_C(-314159265358979323); + fspr_uint64_t ui = APR_UINT64_C(42); + fspr_uint64_t big = APR_UINT64_C(3141592653589793238); - apr_snprintf(buf, sizeof buf, "%" APR_INT64_T_FMT, i); + fspr_snprintf(buf, sizeof buf, "%" APR_INT64_T_FMT, i); ABTS_STR_EQUAL(tc, buf, "-42"); - apr_snprintf(buf, sizeof buf, "%" APR_UINT64_T_FMT, ui); + fspr_snprintf(buf, sizeof buf, "%" APR_UINT64_T_FMT, ui); ABTS_STR_EQUAL(tc, buf, "42"); - apr_snprintf(buf, sizeof buf, "%" APR_UINT64_T_FMT, big); + fspr_snprintf(buf, sizeof buf, "%" APR_UINT64_T_FMT, big); ABTS_STR_EQUAL(tc, buf, "3141592653589793238"); - apr_snprintf(buf, sizeof buf, "%" APR_INT64_T_FMT, ibig); + fspr_snprintf(buf, sizeof buf, "%" APR_INT64_T_FMT, ibig); ABTS_STR_EQUAL(tc, buf, "-314159265358979323"); } diff --git a/libs/apr/test/testfnmatch.c b/libs/apr/test/testfnmatch.c index b54502fd29..41f8bb34b2 100644 --- a/libs/apr/test/testfnmatch.c +++ b/libs/apr/test/testfnmatch.c @@ -15,9 +15,9 @@ */ #include "testutil.h" -#include "apr_file_info.h" -#include "apr_fnmatch.h" -#include "apr_tables.h" +#include "fspr_file_info.h" +#include "fspr_fnmatch.h" +#include "fspr_tables.h" /* XXX NUM_FILES must be equal to the nummber of expected files with a * .txt extension in the data directory at the time testfnmatch @@ -29,10 +29,10 @@ static void test_glob(abts_case *tc, void *data) { int i; char **list; - apr_array_header_t *result; + fspr_array_header_t *result; APR_ASSERT_SUCCESS(tc, "glob match against data/*.txt", - apr_match_glob("data\\*.txt", &result, p)); + fspr_match_glob("data\\*.txt", &result, p)); ABTS_INT_EQUAL(tc, NUM_FILES, result->nelts); @@ -47,11 +47,11 @@ static void test_glob_currdir(abts_case *tc, void *data) { int i; char **list; - apr_array_header_t *result; - apr_filepath_set("data", p); + fspr_array_header_t *result; + fspr_filepath_set("data", p); APR_ASSERT_SUCCESS(tc, "glob match against *.txt with data as current", - apr_match_glob("*.txt", &result, p)); + fspr_match_glob("*.txt", &result, p)); ABTS_INT_EQUAL(tc, NUM_FILES, result->nelts); @@ -61,7 +61,7 @@ static void test_glob_currdir(abts_case *tc, void *data) char *dot = strrchr(list[i], '.'); ABTS_STR_EQUAL(tc, dot, ".txt"); } - apr_filepath_set("..", p); + fspr_filepath_set("..", p); } abts_suite *testfnmatch(abts_suite *suite) diff --git a/libs/apr/test/testglobalmutex.c b/libs/apr/test/testglobalmutex.c index a10742d92f..b0d2f50976 100644 --- a/libs/apr/test/testglobalmutex.c +++ b/libs/apr/test/testglobalmutex.c @@ -15,51 +15,51 @@ */ #include "testglobalmutex.h" -#include "apr_thread_proc.h" -#include "apr_global_mutex.h" -#include "apr_strings.h" -#include "apr_errno.h" +#include "fspr_thread_proc.h" +#include "fspr_global_mutex.h" +#include "fspr_strings.h" +#include "fspr_errno.h" #include "testutil.h" -static void launch_child(abts_case *tc, apr_lockmech_e mech, - apr_proc_t *proc, apr_pool_t *p) +static void launch_child(abts_case *tc, fspr_lockmech_e mech, + fspr_proc_t *proc, fspr_pool_t *p) { - apr_procattr_t *procattr; + fspr_procattr_t *procattr; const char *args[3]; - apr_status_t rv; + fspr_status_t rv; - rv = apr_procattr_create(&procattr, p); + rv = fspr_procattr_create(&procattr, p); APR_ASSERT_SUCCESS(tc, "Couldn't create procattr", rv); - rv = apr_procattr_io_set(procattr, APR_NO_PIPE, APR_NO_PIPE, + rv = fspr_procattr_io_set(procattr, APR_NO_PIPE, APR_NO_PIPE, APR_NO_PIPE); APR_ASSERT_SUCCESS(tc, "Couldn't set io in procattr", rv); - rv = apr_procattr_error_check_set(procattr, 1); + rv = fspr_procattr_error_check_set(procattr, 1); APR_ASSERT_SUCCESS(tc, "Couldn't set error check in procattr", rv); args[0] = "globalmutexchild" EXTENSION; - args[1] = (const char*)apr_itoa(p, (int)mech); + args[1] = (const char*)fspr_itoa(p, (int)mech); args[2] = NULL; - rv = apr_proc_create(proc, "./globalmutexchild" EXTENSION, args, NULL, + rv = fspr_proc_create(proc, "./globalmutexchild" EXTENSION, args, NULL, procattr, p); APR_ASSERT_SUCCESS(tc, "Couldn't launch program", rv); } -static int wait_child(abts_case *tc, apr_proc_t *proc) +static int wait_child(abts_case *tc, fspr_proc_t *proc) { int exitcode; - apr_exit_why_e why; + fspr_exit_why_e why; ABTS_ASSERT(tc, "Error waiting for child process", - apr_proc_wait(proc, &exitcode, &why, APR_WAIT) == APR_CHILD_DONE); + fspr_proc_wait(proc, &exitcode, &why, APR_WAIT) == APR_CHILD_DONE); ABTS_ASSERT(tc, "child didn't terminate normally", why == APR_PROC_EXIT); return exitcode; } /* return symbolic name for a locking meechanism */ -static const char *mutexname(apr_lockmech_e mech) +static const char *mutexname(fspr_lockmech_e mech) { switch (mech) { case APR_LOCK_FCNTL: return "fcntl"; @@ -74,15 +74,15 @@ static const char *mutexname(apr_lockmech_e mech) static void test_exclusive(abts_case *tc, void *data) { - apr_lockmech_e mech = *(apr_lockmech_e *)data; - apr_proc_t p1, p2, p3, p4; - apr_status_t rv; - apr_global_mutex_t *global_lock; + fspr_lockmech_e mech = *(fspr_lockmech_e *)data; + fspr_proc_t p1, p2, p3, p4; + fspr_status_t rv; + fspr_global_mutex_t *global_lock; int x = 0; abts_log_message("lock mechanism is: "); abts_log_message(mutexname(mech)); - rv = apr_global_mutex_create(&global_lock, LOCKNAME, mech, p); + rv = fspr_global_mutex_create(&global_lock, LOCKNAME, mech, p); APR_ASSERT_SUCCESS(tc, "Error creating mutex", rv); launch_child(tc, mech, &p1, p); @@ -105,7 +105,7 @@ static void test_exclusive(abts_case *tc, void *data) abts_suite *testglobalmutex(abts_suite *suite) { - apr_lockmech_e mech = APR_LOCK_DEFAULT; + fspr_lockmech_e mech = APR_LOCK_DEFAULT; suite = ADD_SUITE(suite) abts_run_test(suite, test_exclusive, &mech); diff --git a/libs/apr/test/testglobalmutex.h b/libs/apr/test/testglobalmutex.h index 027062843d..a23df50fe4 100644 --- a/libs/apr/test/testglobalmutex.h +++ b/libs/apr/test/testglobalmutex.h @@ -21,7 +21,7 @@ #define MAX_ITER 255 #define MAX_COUNTER (MAX_ITER * 4) -#define LOCKNAME "data/apr_globalmutex.lock" +#define LOCKNAME "data/fspr_globalmutex.lock" #endif diff --git a/libs/apr/test/testhash.c b/libs/apr/test/testhash.c index c9b1cdb07c..924d722e6e 100644 --- a/libs/apr/test/testhash.c +++ b/libs/apr/test/testhash.c @@ -15,41 +15,41 @@ */ #include "testutil.h" -#include "apr.h" -#include "apr_strings.h" -#include "apr_general.h" -#include "apr_pools.h" -#include "apr_hash.h" +#include "fspr.h" +#include "fspr_strings.h" +#include "fspr_general.h" +#include "fspr_pools.h" +#include "fspr_hash.h" -static void dump_hash(apr_pool_t *p, apr_hash_t *h, char *str) +static void dump_hash(fspr_pool_t *p, fspr_hash_t *h, char *str) { - apr_hash_index_t *hi; + fspr_hash_index_t *hi; char *val, *key; - apr_ssize_t len; + fspr_ssize_t len; int i = 0; str[0] = '\0'; - for (hi = apr_hash_first(p, h); hi; hi = apr_hash_next(hi)) { - apr_hash_this(hi,(void*) &key, &len, (void*) &val); - apr_snprintf(str, 8196, "%sKey %s (%" APR_SSIZE_T_FMT ") Value %s\n", + for (hi = fspr_hash_first(p, h); hi; hi = fspr_hash_next(hi)) { + fspr_hash_this(hi,(void*) &key, &len, (void*) &val); + fspr_snprintf(str, 8196, "%sKey %s (%" APR_SSIZE_T_FMT ") Value %s\n", str, key, len, val); i++; } - apr_snprintf(str, 8196, "%s#entries %d\n", str, i); + fspr_snprintf(str, 8196, "%s#entries %d\n", str, i); } -static void sum_hash(apr_pool_t *p, apr_hash_t *h, int *pcount, int *keySum, int *valSum) +static void sum_hash(fspr_pool_t *p, fspr_hash_t *h, int *pcount, int *keySum, int *valSum) { - apr_hash_index_t *hi; + fspr_hash_index_t *hi; void *val, *key; int count = 0; *keySum = 0; *valSum = 0; *pcount = 0; - for (hi = apr_hash_first(p, h); hi; hi = apr_hash_next(hi)) { - apr_hash_this(hi, (void*)&key, NULL, &val); + for (hi = fspr_hash_first(p, h); hi; hi = fspr_hash_next(hi)) { + fspr_hash_this(hi, (void*)&key, NULL, &val); *valSum += *(int *)val; *keySum += *(int *)key; count++; @@ -59,60 +59,60 @@ static void sum_hash(apr_pool_t *p, apr_hash_t *h, int *pcount, int *keySum, int static void hash_make(abts_case *tc, void *data) { - apr_hash_t *h = NULL; + fspr_hash_t *h = NULL; - h = apr_hash_make(p); + h = fspr_hash_make(p); ABTS_PTR_NOTNULL(tc, h); } static void hash_set(abts_case *tc, void *data) { - apr_hash_t *h = NULL; + fspr_hash_t *h = NULL; char *result = NULL; - h = apr_hash_make(p); + h = fspr_hash_make(p); ABTS_PTR_NOTNULL(tc, h); - apr_hash_set(h, "key", APR_HASH_KEY_STRING, "value"); - result = apr_hash_get(h, "key", APR_HASH_KEY_STRING); + fspr_hash_set(h, "key", APR_HASH_KEY_STRING, "value"); + result = fspr_hash_get(h, "key", APR_HASH_KEY_STRING); ABTS_STR_EQUAL(tc, "value", result); } static void hash_reset(abts_case *tc, void *data) { - apr_hash_t *h = NULL; + fspr_hash_t *h = NULL; char *result = NULL; - h = apr_hash_make(p); + h = fspr_hash_make(p); ABTS_PTR_NOTNULL(tc, h); - apr_hash_set(h, "key", APR_HASH_KEY_STRING, "value"); - result = apr_hash_get(h, "key", APR_HASH_KEY_STRING); + fspr_hash_set(h, "key", APR_HASH_KEY_STRING, "value"); + result = fspr_hash_get(h, "key", APR_HASH_KEY_STRING); ABTS_STR_EQUAL(tc, "value", result); - apr_hash_set(h, "key", APR_HASH_KEY_STRING, "new"); - result = apr_hash_get(h, "key", APR_HASH_KEY_STRING); + fspr_hash_set(h, "key", APR_HASH_KEY_STRING, "new"); + result = fspr_hash_get(h, "key", APR_HASH_KEY_STRING); ABTS_STR_EQUAL(tc, "new", result); } static void same_value(abts_case *tc, void *data) { - apr_hash_t *h = NULL; + fspr_hash_t *h = NULL; char *result = NULL; - h = apr_hash_make(p); + h = fspr_hash_make(p); ABTS_PTR_NOTNULL(tc, h); - apr_hash_set(h, "same1", APR_HASH_KEY_STRING, "same"); - result = apr_hash_get(h, "same1", APR_HASH_KEY_STRING); + fspr_hash_set(h, "same1", APR_HASH_KEY_STRING, "same"); + result = fspr_hash_get(h, "same1", APR_HASH_KEY_STRING); ABTS_STR_EQUAL(tc, "same", result); - apr_hash_set(h, "same2", APR_HASH_KEY_STRING, "same"); - result = apr_hash_get(h, "same2", APR_HASH_KEY_STRING); + fspr_hash_set(h, "same2", APR_HASH_KEY_STRING, "same"); + result = fspr_hash_get(h, "same2", APR_HASH_KEY_STRING); ABTS_STR_EQUAL(tc, "same", result); } -static unsigned int hash_custom( const char *key, apr_ssize_t *klen) +static unsigned int hash_custom( const char *key, fspr_ssize_t *klen) { unsigned int hash = 0; while( *klen ) { @@ -124,55 +124,55 @@ static unsigned int hash_custom( const char *key, apr_ssize_t *klen) static void same_value_custom(abts_case *tc, void *data) { - apr_hash_t *h = NULL; + fspr_hash_t *h = NULL; char *result = NULL; - h = apr_hash_make_custom(p, hash_custom); + h = fspr_hash_make_custom(p, hash_custom); ABTS_PTR_NOTNULL(tc, h); - apr_hash_set(h, "same1", 5, "same"); - result = apr_hash_get(h, "same1", 5); + fspr_hash_set(h, "same1", 5, "same"); + result = fspr_hash_get(h, "same1", 5); ABTS_STR_EQUAL(tc, "same", result); - apr_hash_set(h, "same2", 5, "same"); - result = apr_hash_get(h, "same2", 5); + fspr_hash_set(h, "same2", 5, "same"); + result = fspr_hash_get(h, "same2", 5); ABTS_STR_EQUAL(tc, "same", result); } static void key_space(abts_case *tc, void *data) { - apr_hash_t *h = NULL; + fspr_hash_t *h = NULL; char *result = NULL; - h = apr_hash_make(p); + h = fspr_hash_make(p); ABTS_PTR_NOTNULL(tc, h); - apr_hash_set(h, "key with space", APR_HASH_KEY_STRING, "value"); - result = apr_hash_get(h, "key with space", APR_HASH_KEY_STRING); + fspr_hash_set(h, "key with space", APR_HASH_KEY_STRING, "value"); + result = fspr_hash_get(h, "key with space", APR_HASH_KEY_STRING); ABTS_STR_EQUAL(tc, "value", result); } /* This is kind of a hack, but I am just keeping an existing test. This is - * really testing apr_hash_first, apr_hash_next, and apr_hash_this which + * really testing fspr_hash_first, fspr_hash_next, and fspr_hash_this which * should be tested in three separate tests, but this will do for now. */ static void hash_traverse(abts_case *tc, void *data) { - apr_hash_t *h; + fspr_hash_t *h; char str[8196]; - h = apr_hash_make(p); + h = fspr_hash_make(p); ABTS_PTR_NOTNULL(tc, h); - apr_hash_set(h, "OVERWRITE", APR_HASH_KEY_STRING, "should not see this"); - apr_hash_set(h, "FOO3", APR_HASH_KEY_STRING, "bar3"); - apr_hash_set(h, "FOO3", APR_HASH_KEY_STRING, "bar3"); - apr_hash_set(h, "FOO1", APR_HASH_KEY_STRING, "bar1"); - apr_hash_set(h, "FOO2", APR_HASH_KEY_STRING, "bar2"); - apr_hash_set(h, "FOO4", APR_HASH_KEY_STRING, "bar4"); - apr_hash_set(h, "SAME1", APR_HASH_KEY_STRING, "same"); - apr_hash_set(h, "SAME2", APR_HASH_KEY_STRING, "same"); - apr_hash_set(h, "OVERWRITE", APR_HASH_KEY_STRING, "Overwrite key"); + fspr_hash_set(h, "OVERWRITE", APR_HASH_KEY_STRING, "should not see this"); + fspr_hash_set(h, "FOO3", APR_HASH_KEY_STRING, "bar3"); + fspr_hash_set(h, "FOO3", APR_HASH_KEY_STRING, "bar3"); + fspr_hash_set(h, "FOO1", APR_HASH_KEY_STRING, "bar1"); + fspr_hash_set(h, "FOO2", APR_HASH_KEY_STRING, "bar2"); + fspr_hash_set(h, "FOO4", APR_HASH_KEY_STRING, "bar4"); + fspr_hash_set(h, "SAME1", APR_HASH_KEY_STRING, "same"); + fspr_hash_set(h, "SAME2", APR_HASH_KEY_STRING, "same"); + fspr_hash_set(h, "OVERWRITE", APR_HASH_KEY_STRING, "Overwrite key"); dump_hash(p, h, str); ABTS_STR_EQUAL(tc, "Key FOO1 (4) Value bar1\n" @@ -186,16 +186,16 @@ static void hash_traverse(abts_case *tc, void *data) } /* This is kind of a hack, but I am just keeping an existing test. This is - * really testing apr_hash_first, apr_hash_next, and apr_hash_this which + * really testing fspr_hash_first, fspr_hash_next, and fspr_hash_this which * should be tested in three separate tests, but this will do for now. */ static void summation_test(abts_case *tc, void *data) { - apr_hash_t *h; + fspr_hash_t *h; int sumKeys, sumVal, trySumKey, trySumVal; int i, j, *val, *key; - h =apr_hash_make(p); + h =fspr_hash_make(p); ABTS_PTR_NOTNULL(tc, h); sumKeys = 0; @@ -207,11 +207,11 @@ static void summation_test(abts_case *tc, void *data) j = i * 10 + 1; sumKeys += j; sumVal += i; - key = apr_palloc(p, sizeof(int)); + key = fspr_palloc(p, sizeof(int)); *key = j; - val = apr_palloc(p, sizeof(int)); + val = fspr_palloc(p, sizeof(int)); *val = i; - apr_hash_set(h, key, sizeof(int), val); + fspr_hash_set(h, key, sizeof(int), val); } sum_hash(p, h, &i, &trySumKey, &trySumVal); @@ -222,96 +222,96 @@ static void summation_test(abts_case *tc, void *data) static void delete_key(abts_case *tc, void *data) { - apr_hash_t *h = NULL; + fspr_hash_t *h = NULL; char *result = NULL; - h = apr_hash_make(p); + h = fspr_hash_make(p); ABTS_PTR_NOTNULL(tc, h); - apr_hash_set(h, "key", APR_HASH_KEY_STRING, "value"); - apr_hash_set(h, "key2", APR_HASH_KEY_STRING, "value2"); + fspr_hash_set(h, "key", APR_HASH_KEY_STRING, "value"); + fspr_hash_set(h, "key2", APR_HASH_KEY_STRING, "value2"); - result = apr_hash_get(h, "key", APR_HASH_KEY_STRING); + result = fspr_hash_get(h, "key", APR_HASH_KEY_STRING); ABTS_STR_EQUAL(tc, "value", result); - result = apr_hash_get(h, "key2", APR_HASH_KEY_STRING); + result = fspr_hash_get(h, "key2", APR_HASH_KEY_STRING); ABTS_STR_EQUAL(tc, "value2", result); - apr_hash_set(h, "key", APR_HASH_KEY_STRING, NULL); + fspr_hash_set(h, "key", APR_HASH_KEY_STRING, NULL); - result = apr_hash_get(h, "key", APR_HASH_KEY_STRING); + result = fspr_hash_get(h, "key", APR_HASH_KEY_STRING); ABTS_PTR_EQUAL(tc, NULL, result); - result = apr_hash_get(h, "key2", APR_HASH_KEY_STRING); + result = fspr_hash_get(h, "key2", APR_HASH_KEY_STRING); ABTS_STR_EQUAL(tc, "value2", result); } static void hash_count_0(abts_case *tc, void *data) { - apr_hash_t *h = NULL; + fspr_hash_t *h = NULL; int count; - h = apr_hash_make(p); + h = fspr_hash_make(p); ABTS_PTR_NOTNULL(tc, h); - count = apr_hash_count(h); + count = fspr_hash_count(h); ABTS_INT_EQUAL(tc, 0, count); } static void hash_count_1(abts_case *tc, void *data) { - apr_hash_t *h = NULL; + fspr_hash_t *h = NULL; int count; - h = apr_hash_make(p); + h = fspr_hash_make(p); ABTS_PTR_NOTNULL(tc, h); - apr_hash_set(h, "key", APR_HASH_KEY_STRING, "value"); + fspr_hash_set(h, "key", APR_HASH_KEY_STRING, "value"); - count = apr_hash_count(h); + count = fspr_hash_count(h); ABTS_INT_EQUAL(tc, 1, count); } static void hash_count_5(abts_case *tc, void *data) { - apr_hash_t *h = NULL; + fspr_hash_t *h = NULL; int count; - h = apr_hash_make(p); + h = fspr_hash_make(p); ABTS_PTR_NOTNULL(tc, h); - apr_hash_set(h, "key1", APR_HASH_KEY_STRING, "value1"); - apr_hash_set(h, "key2", APR_HASH_KEY_STRING, "value2"); - apr_hash_set(h, "key3", APR_HASH_KEY_STRING, "value3"); - apr_hash_set(h, "key4", APR_HASH_KEY_STRING, "value4"); - apr_hash_set(h, "key5", APR_HASH_KEY_STRING, "value5"); + fspr_hash_set(h, "key1", APR_HASH_KEY_STRING, "value1"); + fspr_hash_set(h, "key2", APR_HASH_KEY_STRING, "value2"); + fspr_hash_set(h, "key3", APR_HASH_KEY_STRING, "value3"); + fspr_hash_set(h, "key4", APR_HASH_KEY_STRING, "value4"); + fspr_hash_set(h, "key5", APR_HASH_KEY_STRING, "value5"); - count = apr_hash_count(h); + count = fspr_hash_count(h); ABTS_INT_EQUAL(tc, 5, count); } static void overlay_empty(abts_case *tc, void *data) { - apr_hash_t *base = NULL; - apr_hash_t *overlay = NULL; - apr_hash_t *result = NULL; + fspr_hash_t *base = NULL; + fspr_hash_t *overlay = NULL; + fspr_hash_t *result = NULL; int count; char str[8196]; - base = apr_hash_make(p); - overlay = apr_hash_make(p); + base = fspr_hash_make(p); + overlay = fspr_hash_make(p); ABTS_PTR_NOTNULL(tc, base); ABTS_PTR_NOTNULL(tc, overlay); - apr_hash_set(base, "key1", APR_HASH_KEY_STRING, "value1"); - apr_hash_set(base, "key2", APR_HASH_KEY_STRING, "value2"); - apr_hash_set(base, "key3", APR_HASH_KEY_STRING, "value3"); - apr_hash_set(base, "key4", APR_HASH_KEY_STRING, "value4"); - apr_hash_set(base, "key5", APR_HASH_KEY_STRING, "value5"); + fspr_hash_set(base, "key1", APR_HASH_KEY_STRING, "value1"); + fspr_hash_set(base, "key2", APR_HASH_KEY_STRING, "value2"); + fspr_hash_set(base, "key3", APR_HASH_KEY_STRING, "value3"); + fspr_hash_set(base, "key4", APR_HASH_KEY_STRING, "value4"); + fspr_hash_set(base, "key5", APR_HASH_KEY_STRING, "value5"); - result = apr_hash_overlay(p, overlay, base); + result = fspr_hash_overlay(p, overlay, base); - count = apr_hash_count(result); + count = fspr_hash_count(result); ABTS_INT_EQUAL(tc, 5, count); dump_hash(p, result, str); @@ -325,32 +325,32 @@ static void overlay_empty(abts_case *tc, void *data) static void overlay_2unique(abts_case *tc, void *data) { - apr_hash_t *base = NULL; - apr_hash_t *overlay = NULL; - apr_hash_t *result = NULL; + fspr_hash_t *base = NULL; + fspr_hash_t *overlay = NULL; + fspr_hash_t *result = NULL; int count; char str[8196]; - base = apr_hash_make(p); - overlay = apr_hash_make(p); + base = fspr_hash_make(p); + overlay = fspr_hash_make(p); ABTS_PTR_NOTNULL(tc, base); ABTS_PTR_NOTNULL(tc, overlay); - apr_hash_set(base, "base1", APR_HASH_KEY_STRING, "value1"); - apr_hash_set(base, "base2", APR_HASH_KEY_STRING, "value2"); - apr_hash_set(base, "base3", APR_HASH_KEY_STRING, "value3"); - apr_hash_set(base, "base4", APR_HASH_KEY_STRING, "value4"); - apr_hash_set(base, "base5", APR_HASH_KEY_STRING, "value5"); + fspr_hash_set(base, "base1", APR_HASH_KEY_STRING, "value1"); + fspr_hash_set(base, "base2", APR_HASH_KEY_STRING, "value2"); + fspr_hash_set(base, "base3", APR_HASH_KEY_STRING, "value3"); + fspr_hash_set(base, "base4", APR_HASH_KEY_STRING, "value4"); + fspr_hash_set(base, "base5", APR_HASH_KEY_STRING, "value5"); - apr_hash_set(overlay, "overlay1", APR_HASH_KEY_STRING, "value1"); - apr_hash_set(overlay, "overlay2", APR_HASH_KEY_STRING, "value2"); - apr_hash_set(overlay, "overlay3", APR_HASH_KEY_STRING, "value3"); - apr_hash_set(overlay, "overlay4", APR_HASH_KEY_STRING, "value4"); - apr_hash_set(overlay, "overlay5", APR_HASH_KEY_STRING, "value5"); + fspr_hash_set(overlay, "overlay1", APR_HASH_KEY_STRING, "value1"); + fspr_hash_set(overlay, "overlay2", APR_HASH_KEY_STRING, "value2"); + fspr_hash_set(overlay, "overlay3", APR_HASH_KEY_STRING, "value3"); + fspr_hash_set(overlay, "overlay4", APR_HASH_KEY_STRING, "value4"); + fspr_hash_set(overlay, "overlay5", APR_HASH_KEY_STRING, "value5"); - result = apr_hash_overlay(p, overlay, base); + result = fspr_hash_overlay(p, overlay, base); - count = apr_hash_count(result); + count = fspr_hash_count(result); ABTS_INT_EQUAL(tc, 10, count); dump_hash(p, result, str); @@ -372,23 +372,23 @@ static void overlay_2unique(abts_case *tc, void *data) static void overlay_same(abts_case *tc, void *data) { - apr_hash_t *base = NULL; - apr_hash_t *result = NULL; + fspr_hash_t *base = NULL; + fspr_hash_t *result = NULL; int count; char str[8196]; - base = apr_hash_make(p); + base = fspr_hash_make(p); ABTS_PTR_NOTNULL(tc, base); - apr_hash_set(base, "base1", APR_HASH_KEY_STRING, "value1"); - apr_hash_set(base, "base2", APR_HASH_KEY_STRING, "value2"); - apr_hash_set(base, "base3", APR_HASH_KEY_STRING, "value3"); - apr_hash_set(base, "base4", APR_HASH_KEY_STRING, "value4"); - apr_hash_set(base, "base5", APR_HASH_KEY_STRING, "value5"); + fspr_hash_set(base, "base1", APR_HASH_KEY_STRING, "value1"); + fspr_hash_set(base, "base2", APR_HASH_KEY_STRING, "value2"); + fspr_hash_set(base, "base3", APR_HASH_KEY_STRING, "value3"); + fspr_hash_set(base, "base4", APR_HASH_KEY_STRING, "value4"); + fspr_hash_set(base, "base5", APR_HASH_KEY_STRING, "value5"); - result = apr_hash_overlay(p, base, base); + result = fspr_hash_overlay(p, base, base); - count = apr_hash_count(result); + count = fspr_hash_count(result); ABTS_INT_EQUAL(tc, 5, count); dump_hash(p, result, str); diff --git a/libs/apr/test/testipsub.c b/libs/apr/test/testipsub.c index 1411cd05a7..bdf5b78a64 100644 --- a/libs/apr/test/testipsub.c +++ b/libs/apr/test/testipsub.c @@ -15,16 +15,16 @@ */ #include "testutil.h" -#include "apr_general.h" -#include "apr_network_io.h" -#include "apr_errno.h" +#include "fspr_general.h" +#include "fspr_network_io.h" +#include "fspr_errno.h" static void test_bad_input(abts_case *tc, void *data) { struct { const char *ipstr; const char *mask; - apr_status_t expected_rv; + fspr_status_t expected_rv; } testcases[] = { /* so we have a few good inputs in here; sue me */ @@ -63,11 +63,11 @@ static void test_bad_input(abts_case *tc, void *data) #endif }; int i; - apr_ipsubnet_t *ipsub; - apr_status_t rv; + fspr_ipsubnet_t *ipsub; + fspr_status_t rv; for (i = 0; i < (sizeof testcases / sizeof testcases[0]); i++) { - rv = apr_ipsubnet_create(&ipsub, testcases[i].ipstr, testcases[i].mask, p); + rv = fspr_ipsubnet_create(&ipsub, testcases[i].ipstr, testcases[i].mask, p); ABTS_INT_EQUAL(tc, rv, testcases[i].expected_rv); } } @@ -79,18 +79,18 @@ static void test_singleton_subnets(abts_case *tc, void *data) "198.144.203.195", "192.18.97.241", "198.137.240.91", "62.156.179.119", "204.177.92.181" }; - apr_ipsubnet_t *ipsub; - apr_sockaddr_t *sa; - apr_status_t rv; + fspr_ipsubnet_t *ipsub; + fspr_sockaddr_t *sa; + fspr_status_t rv; int i, j, rc; for (i = 0; i < sizeof v4addrs / sizeof v4addrs[0]; i++) { - rv = apr_ipsubnet_create(&ipsub, v4addrs[i], NULL, p); + rv = fspr_ipsubnet_create(&ipsub, v4addrs[i], NULL, p); ABTS_TRUE(tc, rv == APR_SUCCESS); for (j = 0; j < sizeof v4addrs / sizeof v4addrs[0]; j++) { - rv = apr_sockaddr_info_get(&sa, v4addrs[j], APR_INET, 0, 0, p); + rv = fspr_sockaddr_info_get(&sa, v4addrs[j], APR_INET, 0, 0, p); ABTS_TRUE(tc, rv == APR_SUCCESS); - rc = apr_ipsubnet_test(ipsub, sa); + rc = fspr_ipsubnet_test(ipsub, sa); if (!strcmp(v4addrs[i], v4addrs[j])) { ABTS_TRUE(tc, rc != 0); } @@ -124,21 +124,21 @@ static void test_interesting_subnets(abts_case *tc, void *data) ,{"127.0.0.1", "8", APR_INET6, "::ffff:127.0.0.1", "fe80::1"} #endif }; - apr_ipsubnet_t *ipsub; - apr_sockaddr_t *sa; - apr_status_t rv; + fspr_ipsubnet_t *ipsub; + fspr_sockaddr_t *sa; + fspr_status_t rv; int i, rc; for (i = 0; i < sizeof testcases / sizeof testcases[0]; i++) { - rv = apr_ipsubnet_create(&ipsub, testcases[i].ipstr, testcases[i].mask, p); + rv = fspr_ipsubnet_create(&ipsub, testcases[i].ipstr, testcases[i].mask, p); ABTS_TRUE(tc, rv == APR_SUCCESS); - rv = apr_sockaddr_info_get(&sa, testcases[i].in_subnet, testcases[i].family, 0, 0, p); + rv = fspr_sockaddr_info_get(&sa, testcases[i].in_subnet, testcases[i].family, 0, 0, p); ABTS_TRUE(tc, rv == APR_SUCCESS); - rc = apr_ipsubnet_test(ipsub, sa); + rc = fspr_ipsubnet_test(ipsub, sa); ABTS_TRUE(tc, rc != 0); - rv = apr_sockaddr_info_get(&sa, testcases[i].not_in_subnet, testcases[i].family, 0, 0, p); + rv = fspr_sockaddr_info_get(&sa, testcases[i].not_in_subnet, testcases[i].family, 0, 0, p); ABTS_TRUE(tc, rv == APR_SUCCESS); - rc = apr_ipsubnet_test(ipsub, sa); + rc = fspr_ipsubnet_test(ipsub, sa); ABTS_TRUE(tc, rc == 0); } } @@ -147,7 +147,7 @@ static void test_badmask_str(abts_case *tc, void *data) { char buf[128]; - ABTS_STR_EQUAL(tc, apr_strerror(APR_EBADMASK, buf, sizeof buf), + ABTS_STR_EQUAL(tc, fspr_strerror(APR_EBADMASK, buf, sizeof buf), "The specified network mask is invalid."); } @@ -155,7 +155,7 @@ static void test_badip_str(abts_case *tc, void *data) { char buf[128]; - ABTS_STR_EQUAL(tc, apr_strerror(APR_EBADIP, buf, sizeof buf), + ABTS_STR_EQUAL(tc, fspr_strerror(APR_EBADIP, buf, sizeof buf), "The specified IP address is invalid."); } diff --git a/libs/apr/test/testlfs.c b/libs/apr/test/testlfs.c index c502400eef..08b0521584 100644 --- a/libs/apr/test/testlfs.c +++ b/libs/apr/test/testlfs.c @@ -14,14 +14,14 @@ * limitations under the License. */ -#include "apr_file_io.h" -#include "apr_file_info.h" -#include "apr_errno.h" -#include "apr_general.h" -#include "apr_poll.h" -#include "apr_strings.h" -#include "apr_lib.h" -#include "apr_mmap.h" +#include "fspr_file_io.h" +#include "fspr_file_info.h" +#include "fspr_errno.h" +#include "fspr_general.h" +#include "fspr_poll.h" +#include "fspr_strings.h" +#include "fspr_lib.h" +#include "fspr_mmap.h" #include "testutil.h" /* Only enable these tests by default on platforms which support sparse @@ -37,7 +37,7 @@ static void test_nolfs(abts_case *tc, void *data) /* Tests which create an 8Gb sparse file and then check it can be used * as normal. */ -static apr_off_t eightGb = APR_INT64_C(2) << 32; +static fspr_off_t eightGb = APR_INT64_C(2) << 32; static int madefile = 0; @@ -49,22 +49,22 @@ static int madefile = 0; static void test_open(abts_case *tc, void *data) { - apr_file_t *f; - apr_status_t rv; + fspr_file_t *f; + fspr_status_t rv; - rv = apr_dir_make(TESTDIR, APR_OS_DEFAULT, p); + rv = fspr_dir_make(TESTDIR, APR_OS_DEFAULT, p); if (rv && !APR_STATUS_IS_EEXIST(rv)) { APR_ASSERT_SUCCESS(tc, "make test directory", rv); } APR_ASSERT_SUCCESS(tc, "open file", - apr_file_open(&f, TESTFN, + fspr_file_open(&f, TESTFN, APR_CREATE | APR_WRITE | APR_TRUNCATE, APR_OS_DEFAULT, p)); - rv = apr_file_trunc(f, eightGb); + rv = fspr_file_trunc(f, eightGb); - APR_ASSERT_SUCCESS(tc, "close large file", apr_file_close(f)); + APR_ASSERT_SUCCESS(tc, "close large file", fspr_file_close(f)); /* 8Gb may pass rlimits or filesystem limits */ @@ -84,178 +84,178 @@ static void test_open(abts_case *tc, void *data) static void test_reopen(abts_case *tc, void *data) { - apr_file_t *fh; - apr_finfo_t finfo; + fspr_file_t *fh; + fspr_finfo_t finfo; PRECOND; APR_ASSERT_SUCCESS(tc, "re-open 8Gb file", - apr_file_open(&fh, TESTFN, APR_READ, APR_OS_DEFAULT, p)); + fspr_file_open(&fh, TESTFN, APR_READ, APR_OS_DEFAULT, p)); APR_ASSERT_SUCCESS(tc, "file_info_get failed", - apr_file_info_get(&finfo, APR_FINFO_NORM, fh)); + fspr_file_info_get(&finfo, APR_FINFO_NORM, fh)); ABTS_ASSERT(tc, "file_info_get gave incorrect size", finfo.size == eightGb); - APR_ASSERT_SUCCESS(tc, "re-close large file", apr_file_close(fh)); + APR_ASSERT_SUCCESS(tc, "re-close large file", fspr_file_close(fh)); } static void test_stat(abts_case *tc, void *data) { - apr_finfo_t finfo; + fspr_finfo_t finfo; PRECOND; APR_ASSERT_SUCCESS(tc, "stat large file", - apr_stat(&finfo, TESTFN, APR_FINFO_NORM, p)); + fspr_stat(&finfo, TESTFN, APR_FINFO_NORM, p)); ABTS_ASSERT(tc, "stat gave incorrect size", finfo.size == eightGb); } static void test_readdir(abts_case *tc, void *data) { - apr_dir_t *dh; - apr_status_t rv; + fspr_dir_t *dh; + fspr_status_t rv; PRECOND; APR_ASSERT_SUCCESS(tc, "open test directory", - apr_dir_open(&dh, TESTDIR, p)); + fspr_dir_open(&dh, TESTDIR, p)); do { - apr_finfo_t finfo; + fspr_finfo_t finfo; - rv = apr_dir_read(&finfo, APR_FINFO_NORM, dh); + rv = fspr_dir_read(&finfo, APR_FINFO_NORM, dh); if (rv == APR_SUCCESS && strcmp(finfo.name, TESTFILE) == 0) { - ABTS_ASSERT(tc, "apr_dir_read gave incorrect size for large file", + ABTS_ASSERT(tc, "fspr_dir_read gave incorrect size for large file", finfo.size == eightGb); } } while (rv == APR_SUCCESS); if (!APR_STATUS_IS_ENOENT(rv)) { - APR_ASSERT_SUCCESS(tc, "apr_dir_read failed", rv); + APR_ASSERT_SUCCESS(tc, "fspr_dir_read failed", rv); } APR_ASSERT_SUCCESS(tc, "close test directory", - apr_dir_close(dh)); + fspr_dir_close(dh)); } #define TESTSTR "Hello, world." static void test_append(abts_case *tc, void *data) { - apr_file_t *fh; - apr_finfo_t finfo; + fspr_file_t *fh; + fspr_finfo_t finfo; PRECOND; APR_ASSERT_SUCCESS(tc, "open 8Gb file for append", - apr_file_open(&fh, TESTFN, APR_WRITE | APR_APPEND, + fspr_file_open(&fh, TESTFN, APR_WRITE | APR_APPEND, APR_OS_DEFAULT, p)); APR_ASSERT_SUCCESS(tc, "append to 8Gb file", - apr_file_write_full(fh, TESTSTR, strlen(TESTSTR), NULL)); + fspr_file_write_full(fh, TESTSTR, strlen(TESTSTR), NULL)); APR_ASSERT_SUCCESS(tc, "file_info_get failed", - apr_file_info_get(&finfo, APR_FINFO_NORM, fh)); + fspr_file_info_get(&finfo, APR_FINFO_NORM, fh)); ABTS_ASSERT(tc, "file_info_get gave incorrect size", finfo.size == eightGb + strlen(TESTSTR)); - APR_ASSERT_SUCCESS(tc, "close 8Gb file", apr_file_close(fh)); + APR_ASSERT_SUCCESS(tc, "close 8Gb file", fspr_file_close(fh)); } static void test_seek(abts_case *tc, void *data) { - apr_file_t *fh; - apr_off_t pos; + fspr_file_t *fh; + fspr_off_t pos; PRECOND; APR_ASSERT_SUCCESS(tc, "open 8Gb file for writing", - apr_file_open(&fh, TESTFN, APR_WRITE, + fspr_file_open(&fh, TESTFN, APR_WRITE, APR_OS_DEFAULT, p)); pos = 0; APR_ASSERT_SUCCESS(tc, "relative seek to end", - apr_file_seek(fh, APR_END, &pos)); + fspr_file_seek(fh, APR_END, &pos)); ABTS_ASSERT(tc, "seek to END gave 8Gb", pos == eightGb); pos = eightGb; - APR_ASSERT_SUCCESS(tc, "seek to 8Gb", apr_file_seek(fh, APR_SET, &pos)); + APR_ASSERT_SUCCESS(tc, "seek to 8Gb", fspr_file_seek(fh, APR_SET, &pos)); ABTS_ASSERT(tc, "seek gave 8Gb offset", pos == eightGb); pos = 0; - APR_ASSERT_SUCCESS(tc, "relative seek to 0", apr_file_seek(fh, APR_CUR, &pos)); + APR_ASSERT_SUCCESS(tc, "relative seek to 0", fspr_file_seek(fh, APR_CUR, &pos)); ABTS_ASSERT(tc, "relative seek gave 8Gb offset", pos == eightGb); - apr_file_close(fh); + fspr_file_close(fh); } static void test_write(abts_case *tc, void *data) { - apr_file_t *fh; - apr_off_t pos = eightGb - 4; + fspr_file_t *fh; + fspr_off_t pos = eightGb - 4; PRECOND; APR_ASSERT_SUCCESS(tc, "re-open 8Gb file", - apr_file_open(&fh, TESTFN, APR_WRITE, APR_OS_DEFAULT, p)); + fspr_file_open(&fh, TESTFN, APR_WRITE, APR_OS_DEFAULT, p)); APR_ASSERT_SUCCESS(tc, "seek to 8Gb - 4", - apr_file_seek(fh, APR_SET, &pos)); + fspr_file_seek(fh, APR_SET, &pos)); ABTS_ASSERT(tc, "seek gave 8Gb-4 offset", pos == eightGb - 4); APR_ASSERT_SUCCESS(tc, "write magic string to 8Gb-4", - apr_file_write_full(fh, "FISH", 4, NULL)); + fspr_file_write_full(fh, "FISH", 4, NULL)); - APR_ASSERT_SUCCESS(tc, "close 8Gb file", apr_file_close(fh)); + APR_ASSERT_SUCCESS(tc, "close 8Gb file", fspr_file_close(fh)); } #if APR_HAS_MMAP static void test_mmap(abts_case *tc, void *data) { - apr_mmap_t *map; - apr_file_t *fh; - apr_size_t len = 16384; /* hopefully a multiple of the page size */ - apr_off_t off = eightGb - len; + fspr_mmap_t *map; + fspr_file_t *fh; + fspr_size_t len = 16384; /* hopefully a multiple of the page size */ + fspr_off_t off = eightGb - len; void *ptr; PRECOND; APR_ASSERT_SUCCESS(tc, "open 8gb file for mmap", - apr_file_open(&fh, TESTFN, APR_READ, APR_OS_DEFAULT, p)); + fspr_file_open(&fh, TESTFN, APR_READ, APR_OS_DEFAULT, p)); APR_ASSERT_SUCCESS(tc, "mmap 8Gb file", - apr_mmap_create(&map, fh, off, len, APR_MMAP_READ, p)); + fspr_mmap_create(&map, fh, off, len, APR_MMAP_READ, p)); - APR_ASSERT_SUCCESS(tc, "close file", apr_file_close(fh)); + APR_ASSERT_SUCCESS(tc, "close file", fspr_file_close(fh)); ABTS_ASSERT(tc, "mapped a 16K block", map->size == len); APR_ASSERT_SUCCESS(tc, "get pointer into mmaped region", - apr_mmap_offset(&ptr, map, len - 4)); + fspr_mmap_offset(&ptr, map, len - 4)); ABTS_ASSERT(tc, "pointer was not NULL", ptr != NULL); ABTS_ASSERT(tc, "found the magic string", memcmp(ptr, "FISH", 4) == 0); - APR_ASSERT_SUCCESS(tc, "delete mmap handle", apr_mmap_delete(map)); + APR_ASSERT_SUCCESS(tc, "delete mmap handle", fspr_mmap_delete(map)); } #endif /* APR_HAS_MMAP */ static void test_format(abts_case *tc, void *data) { - apr_off_t off; + fspr_off_t off; PRECOND; - off = apr_atoi64(apr_off_t_toa(p, eightGb)); + off = fspr_atoi64(fspr_off_t_toa(p, eightGb)); - ABTS_ASSERT(tc, "apr_atoi64 parsed apr_off_t_toa result incorrectly", + ABTS_ASSERT(tc, "fspr_atoi64 parsed fspr_off_t_toa result incorrectly", off == eightGb); } diff --git a/libs/apr/test/testlock.c b/libs/apr/test/testlock.c index dddb52f76a..51dfc5602c 100644 --- a/libs/apr/test/testlock.c +++ b/libs/apr/test/testlock.c @@ -14,14 +14,14 @@ * limitations under the License. */ -#include "apr_thread_proc.h" -#include "apr_file_io.h" -#include "apr_thread_mutex.h" -#include "apr_thread_rwlock.h" -#include "apr_thread_cond.h" -#include "apr_errno.h" -#include "apr_general.h" -#include "apr_getopt.h" +#include "fspr_thread_proc.h" +#include "fspr_file_io.h" +#include "fspr_thread_mutex.h" +#include "fspr_thread_rwlock.h" +#include "fspr_thread_cond.h" +#include "fspr_errno.h" +#include "fspr_general.h" +#include "fspr_getopt.h" #include "testutil.h" #if APR_HAS_THREADS @@ -30,67 +30,67 @@ #define MAX_COUNTER 100000 #define MAX_RETRY 5 -static void *APR_THREAD_FUNC thread_rwlock_func(apr_thread_t *thd, void *data); -static void *APR_THREAD_FUNC thread_mutex_function(apr_thread_t *thd, void *data); -static void *APR_THREAD_FUNC thread_cond_producer(apr_thread_t *thd, void *data); -static void *APR_THREAD_FUNC thread_cond_consumer(apr_thread_t *thd, void *data); +static void *APR_THREAD_FUNC thread_rwlock_func(fspr_thread_t *thd, void *data); +static void *APR_THREAD_FUNC thread_mutex_function(fspr_thread_t *thd, void *data); +static void *APR_THREAD_FUNC thread_cond_producer(fspr_thread_t *thd, void *data); +static void *APR_THREAD_FUNC thread_cond_consumer(fspr_thread_t *thd, void *data); -static apr_thread_mutex_t *thread_mutex; -static apr_thread_rwlock_t *rwlock; +static fspr_thread_mutex_t *thread_mutex; +static fspr_thread_rwlock_t *rwlock; static int i = 0, x = 0; static int buff[MAX_COUNTER]; struct { - apr_thread_mutex_t *mutex; + fspr_thread_mutex_t *mutex; int nput; int nval; } put; struct { - apr_thread_mutex_t *mutex; - apr_thread_cond_t *cond; + fspr_thread_mutex_t *mutex; + fspr_thread_cond_t *cond; int nready; } nready; -static apr_thread_mutex_t *timeout_mutex; -static apr_thread_cond_t *timeout_cond; +static fspr_thread_mutex_t *timeout_mutex; +static fspr_thread_cond_t *timeout_cond; -static void *APR_THREAD_FUNC thread_rwlock_func(apr_thread_t *thd, void *data) +static void *APR_THREAD_FUNC thread_rwlock_func(fspr_thread_t *thd, void *data) { int exitLoop = 1; while (1) { - apr_thread_rwlock_rdlock(rwlock); + fspr_thread_rwlock_rdlock(rwlock); if (i == MAX_ITER) exitLoop = 0; - apr_thread_rwlock_unlock(rwlock); + fspr_thread_rwlock_unlock(rwlock); if (!exitLoop) break; - apr_thread_rwlock_wrlock(rwlock); + fspr_thread_rwlock_wrlock(rwlock); if (i != MAX_ITER) { i++; x++; } - apr_thread_rwlock_unlock(rwlock); + fspr_thread_rwlock_unlock(rwlock); } return NULL; } -static void *APR_THREAD_FUNC thread_mutex_function(apr_thread_t *thd, void *data) +static void *APR_THREAD_FUNC thread_mutex_function(fspr_thread_t *thd, void *data) { int exitLoop = 1; /* slight delay to allow things to settle */ - apr_sleep (1); + fspr_sleep (1); while (1) { - apr_thread_mutex_lock(thread_mutex); + fspr_thread_mutex_lock(thread_mutex); if (i == MAX_ITER) exitLoop = 0; else @@ -98,7 +98,7 @@ static void *APR_THREAD_FUNC thread_mutex_function(apr_thread_t *thd, void *data i++; x++; } - apr_thread_mutex_unlock(thread_mutex); + fspr_thread_mutex_unlock(thread_mutex); if (!exitLoop) break; @@ -106,24 +106,24 @@ static void *APR_THREAD_FUNC thread_mutex_function(apr_thread_t *thd, void *data return NULL; } -static void *APR_THREAD_FUNC thread_cond_producer(apr_thread_t *thd, void *data) +static void *APR_THREAD_FUNC thread_cond_producer(fspr_thread_t *thd, void *data) { for (;;) { - apr_thread_mutex_lock(put.mutex); + fspr_thread_mutex_lock(put.mutex); if (put.nput >= MAX_COUNTER) { - apr_thread_mutex_unlock(put.mutex); + fspr_thread_mutex_unlock(put.mutex); return NULL; } buff[put.nput] = put.nval; put.nput++; put.nval++; - apr_thread_mutex_unlock(put.mutex); + fspr_thread_mutex_unlock(put.mutex); - apr_thread_mutex_lock(nready.mutex); + fspr_thread_mutex_lock(nready.mutex); if (nready.nready == 0) - apr_thread_cond_signal(nready.cond); + fspr_thread_cond_signal(nready.cond); nready.nready++; - apr_thread_mutex_unlock(nready.mutex); + fspr_thread_mutex_unlock(nready.mutex); *((int *) data) += 1; } @@ -131,16 +131,16 @@ static void *APR_THREAD_FUNC thread_cond_producer(apr_thread_t *thd, void *data) return NULL; } -static void *APR_THREAD_FUNC thread_cond_consumer(apr_thread_t *thd, void *data) +static void *APR_THREAD_FUNC thread_cond_consumer(fspr_thread_t *thd, void *data) { int i; for (i = 0; i < MAX_COUNTER; i++) { - apr_thread_mutex_lock(nready.mutex); + fspr_thread_mutex_lock(nready.mutex); while (nready.nready == 0) - apr_thread_cond_wait(nready.cond, nready.mutex); + fspr_thread_cond_wait(nready.cond, nready.mutex); nready.nready--; - apr_thread_mutex_unlock(nready.mutex); + fspr_thread_mutex_unlock(nready.mutex); if (buff[i] != i) printf("buff[%d] = %d\n", i, buff[i]); @@ -151,39 +151,39 @@ static void *APR_THREAD_FUNC thread_cond_consumer(apr_thread_t *thd, void *data) static void test_thread_mutex(abts_case *tc, void *data) { - apr_thread_t *t1, *t2, *t3, *t4; - apr_status_t s1, s2, s3, s4; + fspr_thread_t *t1, *t2, *t3, *t4; + fspr_status_t s1, s2, s3, s4; - s1 = apr_thread_mutex_create(&thread_mutex, APR_THREAD_MUTEX_DEFAULT, p); + s1 = fspr_thread_mutex_create(&thread_mutex, APR_THREAD_MUTEX_DEFAULT, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, s1); ABTS_PTR_NOTNULL(tc, thread_mutex); i = 0; x = 0; - s1 = apr_thread_create(&t1, NULL, thread_mutex_function, NULL, p); + s1 = fspr_thread_create(&t1, NULL, thread_mutex_function, NULL, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, s1); - s2 = apr_thread_create(&t2, NULL, thread_mutex_function, NULL, p); + s2 = fspr_thread_create(&t2, NULL, thread_mutex_function, NULL, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, s2); - s3 = apr_thread_create(&t3, NULL, thread_mutex_function, NULL, p); + s3 = fspr_thread_create(&t3, NULL, thread_mutex_function, NULL, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, s3); - s4 = apr_thread_create(&t4, NULL, thread_mutex_function, NULL, p); + s4 = fspr_thread_create(&t4, NULL, thread_mutex_function, NULL, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, s4); - apr_thread_join(&s1, t1); - apr_thread_join(&s2, t2); - apr_thread_join(&s3, t3); - apr_thread_join(&s4, t4); + fspr_thread_join(&s1, t1); + fspr_thread_join(&s2, t2); + fspr_thread_join(&s3, t3); + fspr_thread_join(&s4, t4); ABTS_INT_EQUAL(tc, MAX_ITER, x); } static void test_thread_rwlock(abts_case *tc, void *data) { - apr_thread_t *t1, *t2, *t3, *t4; - apr_status_t s1, s2, s3, s4; + fspr_thread_t *t1, *t2, *t3, *t4; + fspr_status_t s1, s2, s3, s4; - s1 = apr_thread_rwlock_create(&rwlock, p); + s1 = fspr_thread_rwlock_create(&rwlock, p); if (s1 == APR_ENOTIMPL) { ABTS_NOT_IMPL(tc, "rwlocks not implemented"); return; @@ -194,44 +194,44 @@ static void test_thread_rwlock(abts_case *tc, void *data) i = 0; x = 0; - s1 = apr_thread_create(&t1, NULL, thread_rwlock_func, NULL, p); + s1 = fspr_thread_create(&t1, NULL, thread_rwlock_func, NULL, p); APR_ASSERT_SUCCESS(tc, "create thread 1", s1); - s2 = apr_thread_create(&t2, NULL, thread_rwlock_func, NULL, p); + s2 = fspr_thread_create(&t2, NULL, thread_rwlock_func, NULL, p); APR_ASSERT_SUCCESS(tc, "create thread 2", s2); - s3 = apr_thread_create(&t3, NULL, thread_rwlock_func, NULL, p); + s3 = fspr_thread_create(&t3, NULL, thread_rwlock_func, NULL, p); APR_ASSERT_SUCCESS(tc, "create thread 3", s3); - s4 = apr_thread_create(&t4, NULL, thread_rwlock_func, NULL, p); + s4 = fspr_thread_create(&t4, NULL, thread_rwlock_func, NULL, p); APR_ASSERT_SUCCESS(tc, "create thread 4", s4); - apr_thread_join(&s1, t1); - apr_thread_join(&s2, t2); - apr_thread_join(&s3, t3); - apr_thread_join(&s4, t4); + fspr_thread_join(&s1, t1); + fspr_thread_join(&s2, t2); + fspr_thread_join(&s3, t3); + fspr_thread_join(&s4, t4); ABTS_INT_EQUAL(tc, MAX_ITER, x); - apr_thread_rwlock_destroy(rwlock); + fspr_thread_rwlock_destroy(rwlock); } static void test_cond(abts_case *tc, void *data) { - apr_thread_t *p1, *p2, *p3, *p4, *c1; - apr_status_t s0, s1, s2, s3, s4; + fspr_thread_t *p1, *p2, *p3, *p4, *c1; + fspr_status_t s0, s1, s2, s3, s4; int count1, count2, count3, count4; int sum; APR_ASSERT_SUCCESS(tc, "create put mutex", - apr_thread_mutex_create(&put.mutex, + fspr_thread_mutex_create(&put.mutex, APR_THREAD_MUTEX_DEFAULT, p)); ABTS_PTR_NOTNULL(tc, put.mutex); APR_ASSERT_SUCCESS(tc, "create nready mutex", - apr_thread_mutex_create(&nready.mutex, + fspr_thread_mutex_create(&nready.mutex, APR_THREAD_MUTEX_DEFAULT, p)); ABTS_PTR_NOTNULL(tc, nready.mutex); APR_ASSERT_SUCCESS(tc, "create condvar", - apr_thread_cond_create(&nready.cond, p)); + fspr_thread_cond_create(&nready.cond, p)); ABTS_PTR_NOTNULL(tc, nready.cond); count1 = count2 = count3 = count4 = 0; @@ -240,25 +240,25 @@ static void test_cond(abts_case *tc, void *data) i = 0; x = 0; - s0 = apr_thread_create(&p1, NULL, thread_cond_producer, &count1, p); + s0 = fspr_thread_create(&p1, NULL, thread_cond_producer, &count1, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, s0); - s1 = apr_thread_create(&p2, NULL, thread_cond_producer, &count2, p); + s1 = fspr_thread_create(&p2, NULL, thread_cond_producer, &count2, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, s1); - s2 = apr_thread_create(&p3, NULL, thread_cond_producer, &count3, p); + s2 = fspr_thread_create(&p3, NULL, thread_cond_producer, &count3, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, s2); - s3 = apr_thread_create(&p4, NULL, thread_cond_producer, &count4, p); + s3 = fspr_thread_create(&p4, NULL, thread_cond_producer, &count4, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, s3); - s4 = apr_thread_create(&c1, NULL, thread_cond_consumer, NULL, p); + s4 = fspr_thread_create(&c1, NULL, thread_cond_consumer, NULL, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, s4); - apr_thread_join(&s0, p1); - apr_thread_join(&s1, p2); - apr_thread_join(&s2, p3); - apr_thread_join(&s3, p4); - apr_thread_join(&s4, c1); + fspr_thread_join(&s0, p1); + fspr_thread_join(&s1, p2); + fspr_thread_join(&s2, p3); + fspr_thread_join(&s3, p4); + fspr_thread_join(&s4, c1); APR_ASSERT_SUCCESS(tc, "destroy condvar", - apr_thread_cond_destroy(nready.cond)); + fspr_thread_cond_destroy(nready.cond)); sum = count1 + count2 + count3 + count4; /* @@ -270,28 +270,28 @@ static void test_cond(abts_case *tc, void *data) static void test_timeoutcond(abts_case *tc, void *data) { - apr_status_t s; - apr_interval_time_t timeout; - apr_time_t begin, end; + fspr_status_t s; + fspr_interval_time_t timeout; + fspr_time_t begin, end; int i; - s = apr_thread_mutex_create(&timeout_mutex, APR_THREAD_MUTEX_DEFAULT, p); + s = fspr_thread_mutex_create(&timeout_mutex, APR_THREAD_MUTEX_DEFAULT, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, s); ABTS_PTR_NOTNULL(tc, timeout_mutex); - s = apr_thread_cond_create(&timeout_cond, p); + s = fspr_thread_cond_create(&timeout_cond, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, s); ABTS_PTR_NOTNULL(tc, timeout_cond); - timeout = apr_time_from_sec(5); + timeout = fspr_time_from_sec(5); for (i = 0; i < MAX_RETRY; i++) { - apr_thread_mutex_lock(timeout_mutex); + fspr_thread_mutex_lock(timeout_mutex); - begin = apr_time_now(); - s = apr_thread_cond_timedwait(timeout_cond, timeout_mutex, timeout); - end = apr_time_now(); - apr_thread_mutex_unlock(timeout_mutex); + begin = fspr_time_now(); + s = fspr_thread_cond_timedwait(timeout_cond, timeout_mutex, timeout); + end = fspr_time_now(); + fspr_thread_mutex_unlock(timeout_mutex); if (s != APR_SUCCESS && !APR_STATUS_IS_TIMEUP(s)) { continue; @@ -302,7 +302,7 @@ static void test_timeoutcond(abts_case *tc, void *data) } ABTS_ASSERT(tc, "Too many retries", i < MAX_RETRY); APR_ASSERT_SUCCESS(tc, "Unable to destroy the conditional", - apr_thread_cond_destroy(timeout_cond)); + fspr_thread_cond_destroy(timeout_cond)); } #endif /* !APR_HAS_THREADS */ diff --git a/libs/apr/test/testlockperf.c b/libs/apr/test/testlockperf.c index e0bf75ae83..afee9c3db6 100644 --- a/libs/apr/test/testlockperf.c +++ b/libs/apr/test/testlockperf.c @@ -14,13 +14,13 @@ * limitations under the License. */ -#include "apr_thread_proc.h" -#include "apr_thread_mutex.h" -#include "apr_thread_rwlock.h" -#include "apr_file_io.h" -#include "apr_errno.h" -#include "apr_general.h" -#include "apr_getopt.h" +#include "fspr_thread_proc.h" +#include "fspr_thread_mutex.h" +#include "fspr_thread_rwlock.h" +#include "fspr_file_io.h" +#include "fspr_errno.h" +#include "fspr_general.h" +#include "fspr_getopt.h" #include "errno.h" #include #include @@ -40,66 +40,66 @@ int main(void) static long mutex_counter; -static apr_thread_mutex_t *thread_lock; -void * APR_THREAD_FUNC thread_mutex_func(apr_thread_t *thd, void *data); -apr_status_t test_thread_mutex(int num_threads); /* apr_thread_mutex_t */ +static fspr_thread_mutex_t *thread_lock; +void * APR_THREAD_FUNC thread_mutex_func(fspr_thread_t *thd, void *data); +fspr_status_t test_thread_mutex(int num_threads); /* fspr_thread_mutex_t */ -static apr_thread_rwlock_t *thread_rwlock; -void * APR_THREAD_FUNC thread_rwlock_func(apr_thread_t *thd, void *data); -apr_status_t test_thread_rwlock(int num_threads); /* apr_thread_rwlock_t */ +static fspr_thread_rwlock_t *thread_rwlock; +void * APR_THREAD_FUNC thread_rwlock_func(fspr_thread_t *thd, void *data); +fspr_status_t test_thread_rwlock(int num_threads); /* fspr_thread_rwlock_t */ int test_thread_mutex_nested(int num_threads); -apr_pool_t *pool; +fspr_pool_t *pool; int i = 0, x = 0; -void * APR_THREAD_FUNC thread_mutex_func(apr_thread_t *thd, void *data) +void * APR_THREAD_FUNC thread_mutex_func(fspr_thread_t *thd, void *data) { int i; for (i = 0; i < MAX_COUNTER; i++) { - apr_thread_mutex_lock(thread_lock); + fspr_thread_mutex_lock(thread_lock); mutex_counter++; - apr_thread_mutex_unlock(thread_lock); + fspr_thread_mutex_unlock(thread_lock); } return NULL; } -void * APR_THREAD_FUNC thread_rwlock_func(apr_thread_t *thd, void *data) +void * APR_THREAD_FUNC thread_rwlock_func(fspr_thread_t *thd, void *data) { int i; for (i = 0; i < MAX_COUNTER; i++) { - apr_thread_rwlock_wrlock(thread_rwlock); + fspr_thread_rwlock_wrlock(thread_rwlock); mutex_counter++; - apr_thread_rwlock_unlock(thread_rwlock); + fspr_thread_rwlock_unlock(thread_rwlock); } return NULL; } int test_thread_mutex(int num_threads) { - apr_thread_t *t[MAX_THREADS]; - apr_status_t s[MAX_THREADS]; - apr_time_t time_start, time_stop; + fspr_thread_t *t[MAX_THREADS]; + fspr_status_t s[MAX_THREADS]; + fspr_time_t time_start, time_stop; int i; mutex_counter = 0; - printf("apr_thread_mutex_t Tests\n"); - printf("%-60s", " Initializing the apr_thread_mutex_t (UNNESTED)"); - s[0] = apr_thread_mutex_create(&thread_lock, APR_THREAD_MUTEX_UNNESTED, pool); + printf("fspr_thread_mutex_t Tests\n"); + printf("%-60s", " Initializing the fspr_thread_mutex_t (UNNESTED)"); + s[0] = fspr_thread_mutex_create(&thread_lock, APR_THREAD_MUTEX_UNNESTED, pool); if (s[0] != APR_SUCCESS) { printf("Failed!\n"); return s[0]; } printf("OK\n"); - apr_thread_mutex_lock(thread_lock); + fspr_thread_mutex_lock(thread_lock); /* set_concurrency(4)? -aaron */ printf(" Starting %d threads ", num_threads); for (i = 0; i < num_threads; ++i) { - s[i] = apr_thread_create(&t[i], NULL, thread_mutex_func, NULL, pool); + s[i] = fspr_thread_create(&t[i], NULL, thread_mutex_func, NULL, pool); if (s[i] != APR_SUCCESS) { printf("Failed!\n"); return s[i]; @@ -107,16 +107,16 @@ int test_thread_mutex(int num_threads) } printf("OK\n"); - time_start = apr_time_now(); - apr_thread_mutex_unlock(thread_lock); + time_start = fspr_time_now(); + fspr_thread_mutex_unlock(thread_lock); /* printf("%-60s", " Waiting for threads to exit"); */ for (i = 0; i < num_threads; ++i) { - apr_thread_join(&s[i], t[i]); + fspr_thread_join(&s[i], t[i]); } /* printf("OK\n"); */ - time_stop = apr_time_now(); + time_stop = fspr_time_now(); printf("microseconds: %" APR_INT64_T_FMT " usec\n", (time_stop - time_start)); if (mutex_counter != MAX_COUNTER * num_threads) @@ -127,27 +127,27 @@ int test_thread_mutex(int num_threads) int test_thread_mutex_nested(int num_threads) { - apr_thread_t *t[MAX_THREADS]; - apr_status_t s[MAX_THREADS]; - apr_time_t time_start, time_stop; + fspr_thread_t *t[MAX_THREADS]; + fspr_status_t s[MAX_THREADS]; + fspr_time_t time_start, time_stop; int i; mutex_counter = 0; - printf("apr_thread_mutex_t Tests\n"); - printf("%-60s", " Initializing the apr_thread_mutex_t (NESTED)"); - s[0] = apr_thread_mutex_create(&thread_lock, APR_THREAD_MUTEX_NESTED, pool); + printf("fspr_thread_mutex_t Tests\n"); + printf("%-60s", " Initializing the fspr_thread_mutex_t (NESTED)"); + s[0] = fspr_thread_mutex_create(&thread_lock, APR_THREAD_MUTEX_NESTED, pool); if (s[0] != APR_SUCCESS) { printf("Failed!\n"); return s[0]; } printf("OK\n"); - apr_thread_mutex_lock(thread_lock); + fspr_thread_mutex_lock(thread_lock); /* set_concurrency(4)? -aaron */ printf(" Starting %d threads ", num_threads); for (i = 0; i < num_threads; ++i) { - s[i] = apr_thread_create(&t[i], NULL, thread_mutex_func, NULL, pool); + s[i] = fspr_thread_create(&t[i], NULL, thread_mutex_func, NULL, pool); if (s[i] != APR_SUCCESS) { printf("Failed!\n"); return s[i]; @@ -155,16 +155,16 @@ int test_thread_mutex_nested(int num_threads) } printf("OK\n"); - time_start = apr_time_now(); - apr_thread_mutex_unlock(thread_lock); + time_start = fspr_time_now(); + fspr_thread_mutex_unlock(thread_lock); /* printf("%-60s", " Waiting for threads to exit"); */ for (i = 0; i < num_threads; ++i) { - apr_thread_join(&s[i], t[i]); + fspr_thread_join(&s[i], t[i]); } /* printf("OK\n"); */ - time_stop = apr_time_now(); + time_stop = fspr_time_now(); printf("microseconds: %" APR_INT64_T_FMT " usec\n", (time_stop - time_start)); if (mutex_counter != MAX_COUNTER * num_threads) @@ -175,27 +175,27 @@ int test_thread_mutex_nested(int num_threads) int test_thread_rwlock(int num_threads) { - apr_thread_t *t[MAX_THREADS]; - apr_status_t s[MAX_THREADS]; - apr_time_t time_start, time_stop; + fspr_thread_t *t[MAX_THREADS]; + fspr_status_t s[MAX_THREADS]; + fspr_time_t time_start, time_stop; int i; mutex_counter = 0; - printf("apr_thread_rwlock_t Tests\n"); - printf("%-60s", " Initializing the apr_thread_rwlock_t"); - s[0] = apr_thread_rwlock_create(&thread_rwlock, pool); + printf("fspr_thread_rwlock_t Tests\n"); + printf("%-60s", " Initializing the fspr_thread_rwlock_t"); + s[0] = fspr_thread_rwlock_create(&thread_rwlock, pool); if (s[0] != APR_SUCCESS) { printf("Failed!\n"); return s[0]; } printf("OK\n"); - apr_thread_rwlock_wrlock(thread_rwlock); + fspr_thread_rwlock_wrlock(thread_rwlock); /* set_concurrency(4)? -aaron */ printf(" Starting %d threads ", num_threads); for (i = 0; i < num_threads; ++i) { - s[i] = apr_thread_create(&t[i], NULL, thread_rwlock_func, NULL, pool); + s[i] = fspr_thread_create(&t[i], NULL, thread_rwlock_func, NULL, pool); if (s[i] != APR_SUCCESS) { printf("Failed!\n"); return s[i]; @@ -203,16 +203,16 @@ int test_thread_rwlock(int num_threads) } printf("OK\n"); - time_start = apr_time_now(); - apr_thread_rwlock_unlock(thread_rwlock); + time_start = fspr_time_now(); + fspr_thread_rwlock_unlock(thread_rwlock); /* printf("%-60s", " Waiting for threads to exit"); */ for (i = 0; i < num_threads; ++i) { - apr_thread_join(&s[i], t[i]); + fspr_thread_join(&s[i], t[i]); } /* printf("OK\n"); */ - time_stop = apr_time_now(); + time_stop = fspr_time_now(); printf("microseconds: %" APR_INT64_T_FMT " usec\n", (time_stop - time_start)); if (mutex_counter != MAX_COUNTER * num_threads) @@ -223,28 +223,28 @@ int test_thread_rwlock(int num_threads) int main(int argc, const char * const *argv) { - apr_status_t rv; + fspr_status_t rv; char errmsg[200]; const char *lockname = "multi.lock"; - apr_getopt_t *opt; + fspr_getopt_t *opt; char optchar; const char *optarg; printf("APR Lock Performance Test\n==============\n\n"); - apr_initialize(); - atexit(apr_terminate); + fspr_initialize(); + atexit(fspr_terminate); - if (apr_pool_create(&pool, NULL) != APR_SUCCESS) + if (fspr_pool_create(&pool, NULL) != APR_SUCCESS) exit(-1); - if ((rv = apr_getopt_init(&opt, pool, argc, argv)) != APR_SUCCESS) { + if ((rv = fspr_getopt_init(&opt, pool, argc, argv)) != APR_SUCCESS) { fprintf(stderr, "Could not set up to parse options: [%d] %s\n", - rv, apr_strerror(rv, errmsg, sizeof errmsg)); + rv, fspr_strerror(rv, errmsg, sizeof errmsg)); exit(-1); } - while ((rv = apr_getopt(opt, "f:", &optchar, &optarg)) == APR_SUCCESS) { + while ((rv = fspr_getopt(opt, "f:", &optchar, &optarg)) == APR_SUCCESS) { if (optchar == 'f') { lockname = optarg; } @@ -252,26 +252,26 @@ int main(int argc, const char * const *argv) if (rv != APR_SUCCESS && rv != APR_EOF) { fprintf(stderr, "Could not parse options: [%d] %s\n", - rv, apr_strerror(rv, errmsg, sizeof errmsg)); + rv, fspr_strerror(rv, errmsg, sizeof errmsg)); exit(-1); } for (i = 1; i <= MAX_THREADS; ++i) { if ((rv = test_thread_mutex(i)) != APR_SUCCESS) { fprintf(stderr,"thread_mutex test failed : [%d] %s\n", - rv, apr_strerror(rv, (char*)errmsg, 200)); + rv, fspr_strerror(rv, (char*)errmsg, 200)); exit(-3); } if ((rv = test_thread_mutex_nested(i)) != APR_SUCCESS) { fprintf(stderr,"thread_mutex (NESTED) test failed : [%d] %s\n", - rv, apr_strerror(rv, (char*)errmsg, 200)); + rv, fspr_strerror(rv, (char*)errmsg, 200)); exit(-4); } if ((rv = test_thread_rwlock(i)) != APR_SUCCESS) { fprintf(stderr,"thread_rwlock test failed : [%d] %s\n", - rv, apr_strerror(rv, (char*)errmsg, 200)); + rv, fspr_strerror(rv, (char*)errmsg, 200)); exit(-6); } } diff --git a/libs/apr/test/testmmap.c b/libs/apr/test/testmmap.c index 61b7481e5a..1e42d5e073 100644 --- a/libs/apr/test/testmmap.c +++ b/libs/apr/test/testmmap.c @@ -15,12 +15,12 @@ */ #include "testutil.h" -#include "apr_mmap.h" -#include "apr_errno.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_file_io.h" -#include "apr_strings.h" +#include "fspr_mmap.h" +#include "fspr_errno.h" +#include "fspr_general.h" +#include "fspr_lib.h" +#include "fspr_file_io.h" +#include "fspr_strings.h" /* hmmm, what is a truly portable define for the max path * length on a platform? @@ -36,17 +36,17 @@ static void not_implemented(abts_case *tc, void *data) #else -static apr_mmap_t *themmap = NULL; -static apr_file_t *thefile = NULL; +static fspr_mmap_t *themmap = NULL; +static fspr_file_t *thefile = NULL; static char *file1; -static apr_finfo_t finfo; +static fspr_finfo_t finfo; static int fsize; static void create_filename(abts_case *tc, void *data) { char *oldfileptr; - apr_filepath_get(&file1, 0, p); + fspr_filepath_get(&file1, 0, p); #ifndef NETWARE #ifdef WIN32 ABTS_TRUE(tc, file1[1] == ':'); @@ -57,41 +57,41 @@ static void create_filename(abts_case *tc, void *data) ABTS_TRUE(tc, file1[strlen(file1) - 1] != '/'); oldfileptr = file1; - file1 = apr_pstrcat(p, file1,"/data/mmap_datafile.txt" ,NULL); + file1 = fspr_pstrcat(p, file1,"/data/mmap_datafile.txt" ,NULL); ABTS_TRUE(tc, oldfileptr != file1); } static void test_file_close(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; - rv = apr_file_close(thefile); + rv = fspr_file_close(thefile); ABTS_INT_EQUAL(tc, rv, APR_SUCCESS); } static void test_file_open(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; - rv = apr_file_open(&thefile, file1, APR_READ, APR_UREAD | APR_GREAD, p); + rv = fspr_file_open(&thefile, file1, APR_READ, APR_UREAD | APR_GREAD, p); ABTS_INT_EQUAL(tc, rv, APR_SUCCESS); ABTS_PTR_NOTNULL(tc, thefile); } static void test_get_filesize(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; - rv = apr_file_info_get(&finfo, APR_FINFO_NORM, thefile); + rv = fspr_file_info_get(&finfo, APR_FINFO_NORM, thefile); ABTS_INT_EQUAL(tc, rv, APR_SUCCESS); ABTS_ASSERT(tc, "File size mismatch", fsize == finfo.size); } static void test_mmap_create(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; - rv = apr_mmap_create(&themmap, thefile, 0, (apr_size_t) finfo.size, + rv = fspr_mmap_create(&themmap, thefile, 0, (fspr_size_t) finfo.size, APR_MMAP_READ, p); ABTS_PTR_NOTNULL(tc, themmap); ABTS_INT_EQUAL(tc, rv, APR_SUCCESS); @@ -110,20 +110,20 @@ static void test_mmap_contents(abts_case *tc, void *data) static void test_mmap_delete(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; ABTS_PTR_NOTNULL(tc, themmap); - rv = apr_mmap_delete(themmap); + rv = fspr_mmap_delete(themmap); ABTS_INT_EQUAL(tc, rv, APR_SUCCESS); } static void test_mmap_offset(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; void *addr; ABTS_PTR_NOTNULL(tc, themmap); - rv = apr_mmap_offset(&addr, themmap, 5); + rv = fspr_mmap_offset(&addr, themmap, 5); /* Must use nEquals since the string is not guaranteed to be NULL terminated */ ABTS_STR_NEQUAL(tc, addr, TEST_STRING + 5, fsize-5); diff --git a/libs/apr/test/testmutexscope.c b/libs/apr/test/testmutexscope.c index 0ea08cc634..0d8cb30d6c 100644 --- a/libs/apr/test/testmutexscope.c +++ b/libs/apr/test/testmutexscope.c @@ -19,11 +19,11 @@ #include #include -#include "apr.h" -#include "apr_general.h" -#include "apr_proc_mutex.h" -#include "apr_global_mutex.h" -#include "apr_thread_proc.h" +#include "fspr.h" +#include "fspr_general.h" +#include "fspr_proc_mutex.h" +#include "fspr_global_mutex.h" +#include "fspr_thread_proc.h" #if !APR_HAS_THREADS int main(void) @@ -34,23 +34,23 @@ int main(void) #else /* APR_HAS_THREADS */ -static apr_thread_mutex_t *thread_mutex; -static apr_proc_mutex_t *proc_mutex; -static apr_global_mutex_t *global_mutex; -static apr_pool_t *p; +static fspr_thread_mutex_t *thread_mutex; +static fspr_proc_mutex_t *proc_mutex; +static fspr_global_mutex_t *global_mutex; +static fspr_pool_t *p; static volatile int counter; typedef enum {TEST_GLOBAL, TEST_PROC} test_mode_e; -static void lock_init(apr_lockmech_e mech, test_mode_e test_mode) +static void lock_init(fspr_lockmech_e mech, test_mode_e test_mode) { if (test_mode == TEST_PROC) { - assert(apr_proc_mutex_create(&proc_mutex, + assert(fspr_proc_mutex_create(&proc_mutex, NULL, mech, p) == APR_SUCCESS); } else { - assert(apr_global_mutex_create(&global_mutex, + assert(fspr_global_mutex_create(&global_mutex, NULL, mech, p) == APR_SUCCESS); @@ -60,62 +60,62 @@ static void lock_init(apr_lockmech_e mech, test_mode_e test_mode) static void lock_destroy(test_mode_e test_mode) { if (test_mode == TEST_PROC) { - assert(apr_proc_mutex_destroy(proc_mutex) == APR_SUCCESS); + assert(fspr_proc_mutex_destroy(proc_mutex) == APR_SUCCESS); } else { - assert(apr_global_mutex_destroy(global_mutex) == APR_SUCCESS); + assert(fspr_global_mutex_destroy(global_mutex) == APR_SUCCESS); } } static void lock_grab(test_mode_e test_mode) { if (test_mode == TEST_PROC) { - assert(apr_proc_mutex_lock(proc_mutex) == APR_SUCCESS); + assert(fspr_proc_mutex_lock(proc_mutex) == APR_SUCCESS); } else { - assert(apr_global_mutex_lock(global_mutex) == APR_SUCCESS); + assert(fspr_global_mutex_lock(global_mutex) == APR_SUCCESS); } } static void lock_release(test_mode_e test_mode) { if (test_mode == TEST_PROC) { - assert(apr_proc_mutex_unlock(proc_mutex) == APR_SUCCESS); + assert(fspr_proc_mutex_unlock(proc_mutex) == APR_SUCCESS); } else { - assert(apr_global_mutex_unlock(global_mutex) == APR_SUCCESS); + assert(fspr_global_mutex_unlock(global_mutex) == APR_SUCCESS); } } -static void * APR_THREAD_FUNC eachThread(apr_thread_t *id, void *p) +static void * APR_THREAD_FUNC eachThread(fspr_thread_t *id, void *p) { test_mode_e test_mode = (test_mode_e)p; lock_grab(test_mode); ++counter; - assert(apr_thread_mutex_lock(thread_mutex) == APR_SUCCESS); - assert(apr_thread_mutex_unlock(thread_mutex) == APR_SUCCESS); + assert(fspr_thread_mutex_lock(thread_mutex) == APR_SUCCESS); + assert(fspr_thread_mutex_unlock(thread_mutex) == APR_SUCCESS); lock_release(test_mode); return NULL; } -static void test_mech_mode(apr_lockmech_e mech, const char *mech_name, +static void test_mech_mode(fspr_lockmech_e mech, const char *mech_name, test_mode_e test_mode) { - apr_thread_t *threads[20]; + fspr_thread_t *threads[20]; int numThreads = 5; int i; - apr_status_t rv; + fspr_status_t rv; printf("Trying %s mutexes with mechanism `%s'...\n", test_mode == TEST_GLOBAL ? "global" : "proc", mech_name); assert(numThreads <= sizeof(threads) / sizeof(threads[0])); - assert(apr_pool_create(&p, NULL) == APR_SUCCESS); + assert(fspr_pool_create(&p, NULL) == APR_SUCCESS); - assert(apr_thread_mutex_create(&thread_mutex, 0, p) == APR_SUCCESS); - assert(apr_thread_mutex_lock(thread_mutex) == APR_SUCCESS); + assert(fspr_thread_mutex_create(&thread_mutex, 0, p) == APR_SUCCESS); + assert(fspr_thread_mutex_lock(thread_mutex) == APR_SUCCESS); lock_init(mech, test_mode); @@ -124,19 +124,19 @@ static void test_mech_mode(apr_lockmech_e mech, const char *mech_name, i = 0; while (i < numThreads) { - rv = apr_thread_create(&threads[i], + rv = fspr_thread_create(&threads[i], NULL, eachThread, (void *)test_mode, p); if (rv != APR_SUCCESS) { - fprintf(stderr, "apr_thread_create->%d\n", rv); + fprintf(stderr, "fspr_thread_create->%d\n", rv); exit(1); } ++i; } - apr_sleep(apr_time_from_sec(5)); + fspr_sleep(fspr_time_from_sec(5)); if (test_mode == TEST_PROC) { printf(" Mutex mechanism `%s' is %sglobal in scope on this platform.\n", @@ -144,7 +144,7 @@ static void test_mech_mode(apr_lockmech_e mech, const char *mech_name, } else { if (counter != 1) { - fprintf(stderr, "\n!!!apr_global_mutex operations are broken on this " + fprintf(stderr, "\n!!!fspr_global_mutex operations are broken on this " "platform for mutex mechanism `%s'!\n" "They don't block out threads within the same process.\n", mech_name); @@ -156,25 +156,25 @@ static void test_mech_mode(apr_lockmech_e mech, const char *mech_name, } } - assert(apr_thread_mutex_unlock(thread_mutex) == APR_SUCCESS); + assert(fspr_thread_mutex_unlock(thread_mutex) == APR_SUCCESS); i = 0; while (i < numThreads) { - apr_status_t ignored; + fspr_status_t ignored; - rv = apr_thread_join(&ignored, + rv = fspr_thread_join(&ignored, threads[i]); assert(rv == APR_SUCCESS); ++i; } lock_destroy(test_mode); - apr_thread_mutex_destroy(thread_mutex); - apr_pool_destroy(p); + fspr_thread_mutex_destroy(thread_mutex); + fspr_pool_destroy(p); } -static void test_mech(apr_lockmech_e mech, const char *mech_name) +static void test_mech(fspr_lockmech_e mech, const char *mech_name) { test_mech_mode(mech, mech_name, TEST_PROC); test_mech_mode(mech, mech_name, TEST_GLOBAL); @@ -183,7 +183,7 @@ static void test_mech(apr_lockmech_e mech, const char *mech_name) int main(void) { struct { - apr_lockmech_e mech; + fspr_lockmech_e mech; const char *mech_name; } lockmechs[] = { {APR_LOCK_DEFAULT, "default"} @@ -205,13 +205,13 @@ int main(void) }; int i; - assert(apr_initialize() == APR_SUCCESS); + assert(fspr_initialize() == APR_SUCCESS); for (i = 0; i < sizeof(lockmechs) / sizeof(lockmechs[0]); i++) { test_mech(lockmechs[i].mech, lockmechs[i].mech_name); } - apr_terminate(); + fspr_terminate(); return 0; } diff --git a/libs/apr/test/testnames.c b/libs/apr/test/testnames.c index fca79f3ee8..e35e4d7bf4 100644 --- a/libs/apr/test/testnames.c +++ b/libs/apr/test/testnames.c @@ -15,12 +15,12 @@ */ #include "testutil.h" -#include "apr_file_io.h" -#include "apr_file_info.h" -#include "apr_errno.h" -#include "apr_general.h" -#include "apr_pools.h" -#include "apr_lib.h" +#include "fspr_file_io.h" +#include "fspr_file_info.h" +#include "fspr_errno.h" +#include "fspr_general.h" +#include "fspr_pools.h" +#include "fspr_lib.h" #if WIN32 #define ABS_ROOT "C:/" @@ -32,13 +32,13 @@ static void merge_aboveroot(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; char *dstpath = NULL; char errmsg[256]; - rv = apr_filepath_merge(&dstpath, ABS_ROOT"foo", ABS_ROOT"bar", APR_FILEPATH_NOTABOVEROOT, + rv = fspr_filepath_merge(&dstpath, ABS_ROOT"foo", ABS_ROOT"bar", APR_FILEPATH_NOTABOVEROOT, p); - apr_strerror(rv, errmsg, sizeof(errmsg)); + fspr_strerror(rv, errmsg, sizeof(errmsg)); ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_EABOVEROOT(rv)); ABTS_PTR_EQUAL(tc, NULL, dstpath); ABTS_STR_EQUAL(tc, "The given path was above the root path", errmsg); @@ -46,10 +46,10 @@ static void merge_aboveroot(abts_case *tc, void *data) static void merge_belowroot(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; char *dstpath = NULL; - rv = apr_filepath_merge(&dstpath, ABS_ROOT"foo", ABS_ROOT"foo/bar", + rv = fspr_filepath_merge(&dstpath, ABS_ROOT"foo", ABS_ROOT"foo/bar", APR_FILEPATH_NOTABOVEROOT, p); ABTS_PTR_NOTNULL(tc, dstpath); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); @@ -58,10 +58,10 @@ static void merge_belowroot(abts_case *tc, void *data) static void merge_noflag(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; char *dstpath = NULL; - rv = apr_filepath_merge(&dstpath, ABS_ROOT"foo", ABS_ROOT"foo/bar", 0, p); + rv = fspr_filepath_merge(&dstpath, ABS_ROOT"foo", ABS_ROOT"foo/bar", 0, p); ABTS_PTR_NOTNULL(tc, dstpath); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_STR_EQUAL(tc, ABS_ROOT"foo/bar", dstpath); @@ -69,15 +69,15 @@ static void merge_noflag(abts_case *tc, void *data) static void merge_dotdot(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; char *dstpath = NULL; - rv = apr_filepath_merge(&dstpath, ABS_ROOT"foo/bar", "../baz", 0, p); + rv = fspr_filepath_merge(&dstpath, ABS_ROOT"foo/bar", "../baz", 0, p); ABTS_PTR_NOTNULL(tc, dstpath); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_STR_EQUAL(tc, ABS_ROOT"foo/baz", dstpath); - rv = apr_filepath_merge(&dstpath, "", "../test", 0, p); + rv = fspr_filepath_merge(&dstpath, "", "../test", 0, p); ABTS_INT_EQUAL(tc, 0, APR_SUCCESS); ABTS_STR_EQUAL(tc, "../test", dstpath); @@ -86,23 +86,23 @@ static void merge_dotdot(abts_case *tc, void *data) * return ../test unless a previously fixed bug remains or the developer changes * the case of the test directory: */ - rv = apr_filepath_merge(&dstpath, "", "../test", APR_FILEPATH_TRUENAME, p); + rv = fspr_filepath_merge(&dstpath, "", "../test", APR_FILEPATH_TRUENAME, p); ABTS_INT_EQUAL(tc, 0, APR_SUCCESS); ABTS_STR_EQUAL(tc, "../test", dstpath); } static void merge_dotdot_dotdot_dotdot(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; char *dstpath = NULL; - rv = apr_filepath_merge(&dstpath, "", + rv = fspr_filepath_merge(&dstpath, "", "../../..", APR_FILEPATH_TRUENAME, p); ABTS_PTR_NOTNULL(tc, dstpath); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_STR_EQUAL(tc, "../../..", dstpath); - rv = apr_filepath_merge(&dstpath, "", + rv = fspr_filepath_merge(&dstpath, "", "../../../", APR_FILEPATH_TRUENAME, p); ABTS_PTR_NOTNULL(tc, dstpath); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); @@ -111,10 +111,10 @@ static void merge_dotdot_dotdot_dotdot(abts_case *tc, void *data) static void merge_secure(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; char *dstpath = NULL; - rv = apr_filepath_merge(&dstpath, ABS_ROOT"foo/bar", "../bar/baz", 0, p); + rv = fspr_filepath_merge(&dstpath, ABS_ROOT"foo/bar", "../bar/baz", 0, p); ABTS_PTR_NOTNULL(tc, dstpath); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_STR_EQUAL(tc, ABS_ROOT"foo/bar/baz", dstpath); @@ -122,10 +122,10 @@ static void merge_secure(abts_case *tc, void *data) static void merge_notrel(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; char *dstpath = NULL; - rv = apr_filepath_merge(&dstpath, ABS_ROOT"foo/bar", "../baz", + rv = fspr_filepath_merge(&dstpath, ABS_ROOT"foo/bar", "../baz", APR_FILEPATH_NOTRELATIVE, p); ABTS_PTR_NOTNULL(tc, dstpath); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); @@ -134,13 +134,13 @@ static void merge_notrel(abts_case *tc, void *data) static void merge_notrelfail(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; char *dstpath = NULL; char errmsg[256]; - rv = apr_filepath_merge(&dstpath, "foo/bar", "../baz", + rv = fspr_filepath_merge(&dstpath, "foo/bar", "../baz", APR_FILEPATH_NOTRELATIVE, p); - apr_strerror(rv, errmsg, sizeof(errmsg)); + fspr_strerror(rv, errmsg, sizeof(errmsg)); ABTS_PTR_EQUAL(tc, NULL, dstpath); ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_ERELATIVE(rv)); @@ -149,13 +149,13 @@ static void merge_notrelfail(abts_case *tc, void *data) static void merge_notabsfail(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; char *dstpath = NULL; char errmsg[256]; - rv = apr_filepath_merge(&dstpath, ABS_ROOT"foo/bar", "../baz", + rv = fspr_filepath_merge(&dstpath, ABS_ROOT"foo/bar", "../baz", APR_FILEPATH_NOTABSOLUTE, p); - apr_strerror(rv, errmsg, sizeof(errmsg)); + fspr_strerror(rv, errmsg, sizeof(errmsg)); ABTS_PTR_EQUAL(tc, NULL, dstpath); ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_EABSOLUTE(rv)); @@ -164,10 +164,10 @@ static void merge_notabsfail(abts_case *tc, void *data) static void merge_notabs(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; char *dstpath = NULL; - rv = apr_filepath_merge(&dstpath, "foo/bar", "../baz", + rv = fspr_filepath_merge(&dstpath, "foo/bar", "../baz", APR_FILEPATH_NOTABSOLUTE, p); ABTS_PTR_NOTNULL(tc, dstpath); @@ -177,11 +177,11 @@ static void merge_notabs(abts_case *tc, void *data) static void root_absolute(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; const char *root = NULL; const char *path = ABS_ROOT"foo/bar"; - rv = apr_filepath_root(&root, &path, 0, p); + rv = fspr_filepath_root(&root, &path, 0, p); ABTS_PTR_NOTNULL(tc, root); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); @@ -190,13 +190,13 @@ static void root_absolute(abts_case *tc, void *data) static void root_relative(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; const char *root = NULL; const char *path = "foo/bar"; char errmsg[256]; - rv = apr_filepath_root(&root, &path, 0, p); - apr_strerror(rv, errmsg, sizeof(errmsg)); + rv = fspr_filepath_root(&root, &path, 0, p); + fspr_strerror(rv, errmsg, sizeof(errmsg)); ABTS_PTR_EQUAL(tc, NULL, root); ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_ERELATIVE(rv)); @@ -205,11 +205,11 @@ static void root_relative(abts_case *tc, void *data) static void root_from_slash(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; const char *root = NULL; const char *path = "//"; - rv = apr_filepath_root(&root, &path, APR_FILEPATH_TRUENAME, p); + rv = fspr_filepath_root(&root, &path, APR_FILEPATH_TRUENAME, p); #if defined(WIN32) || defined(OS2) ABTS_INT_EQUAL(tc, APR_EINCOMPLETE, rv); @@ -223,15 +223,15 @@ static void root_from_slash(abts_case *tc, void *data) static void root_from_cwd_and_back(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; const char *root = NULL; const char *path = "//"; char *origpath; char *testpath; - ABTS_INT_EQUAL(tc, APR_SUCCESS, apr_filepath_get(&origpath, 0, p)); + ABTS_INT_EQUAL(tc, APR_SUCCESS, fspr_filepath_get(&origpath, 0, p)); path = origpath; - rv = apr_filepath_root(&root, &path, APR_FILEPATH_TRUENAME, p); + rv = fspr_filepath_root(&root, &path, APR_FILEPATH_TRUENAME, p); #if defined(WIN32) || defined(OS2) ABTS_INT_EQUAL(tc, origpath[0], root[0]); @@ -257,7 +257,7 @@ static void root_from_cwd_and_back(abts_case *tc, void *data) ABTS_STR_EQUAL(tc, origpath + 1, path); #endif - rv = apr_filepath_merge(&testpath, root, path, + rv = fspr_filepath_merge(&testpath, root, path, APR_FILEPATH_TRUENAME | APR_FILEPATH_NOTABOVEROOT | APR_FILEPATH_NOTRELATIVE, p); diff --git a/libs/apr/test/testoc.c b/libs/apr/test/testoc.c index 9dbaff8c37..c067f78f83 100644 --- a/libs/apr/test/testoc.c +++ b/libs/apr/test/testoc.c @@ -15,11 +15,11 @@ */ #include "testutil.h" -#include "apr_thread_proc.h" -#include "apr_errno.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_strings.h" +#include "fspr_thread_proc.h" +#include "fspr_errno.h" +#include "fspr_general.h" +#include "fspr_lib.h" +#include "fspr_strings.h" #if APR_HAS_OTHER_CHILD @@ -29,19 +29,19 @@ static void ocmaint(int reason, void *data, int status) { switch (reason) { case APR_OC_REASON_DEATH: - apr_cpystrn(reasonstr, "APR_OC_REASON_DEATH", + fspr_cpystrn(reasonstr, "APR_OC_REASON_DEATH", strlen("APR_OC_REASON_DEATH") + 1); break; case APR_OC_REASON_LOST: - apr_cpystrn(reasonstr, "APR_OC_REASON_LOST", + fspr_cpystrn(reasonstr, "APR_OC_REASON_LOST", strlen("APR_OC_REASON_LOST") + 1); break; case APR_OC_REASON_UNWRITABLE: - apr_cpystrn(reasonstr, "APR_OC_REASON_UNWRITEABLE", + fspr_cpystrn(reasonstr, "APR_OC_REASON_UNWRITEABLE", strlen("APR_OC_REASON_UNWRITEABLE") + 1); break; case APR_OC_REASON_RESTART: - apr_cpystrn(reasonstr, "APR_OC_REASON_RESTART", + fspr_cpystrn(reasonstr, "APR_OC_REASON_RESTART", strlen("APR_OC_REASON_RESTART") + 1); break; } @@ -56,24 +56,24 @@ static void ocmaint(int reason, void *data, int status) */ static void test_child_kill(abts_case *tc, void *data) { - apr_file_t *std = NULL; - apr_proc_t newproc; - apr_procattr_t *procattr = NULL; + fspr_file_t *std = NULL; + fspr_proc_t newproc; + fspr_procattr_t *procattr = NULL; const char *args[3]; - apr_status_t rv; + fspr_status_t rv; - args[0] = apr_pstrdup(p, "occhild" EXTENSION); - args[1] = apr_pstrdup(p, "-X"); + args[0] = fspr_pstrdup(p, "occhild" EXTENSION); + args[1] = fspr_pstrdup(p, "-X"); args[2] = NULL; - rv = apr_procattr_create(&procattr, p); + rv = fspr_procattr_create(&procattr, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_procattr_io_set(procattr, APR_FULL_BLOCK, APR_NO_PIPE, + rv = fspr_procattr_io_set(procattr, APR_FULL_BLOCK, APR_NO_PIPE, APR_NO_PIPE); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_proc_create(&newproc, "./occhild" EXTENSION, args, NULL, procattr, p); + rv = fspr_proc_create(&newproc, "./occhild" EXTENSION, args, NULL, procattr, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_PTR_NOTNULL(tc, newproc.in); ABTS_PTR_EQUAL(tc, NULL, newproc.out); @@ -81,16 +81,16 @@ static void test_child_kill(abts_case *tc, void *data) std = newproc.in; - apr_proc_other_child_register(&newproc, ocmaint, NULL, std, p); + fspr_proc_other_child_register(&newproc, ocmaint, NULL, std, p); - apr_sleep(apr_time_from_sec(1)); - rv = apr_proc_kill(&newproc, SIGKILL); + fspr_sleep(fspr_time_from_sec(1)); + rv = fspr_proc_kill(&newproc, SIGKILL); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); /* allow time for things to settle... */ - apr_sleep(apr_time_from_sec(3)); + fspr_sleep(fspr_time_from_sec(3)); - apr_proc_other_child_refresh_all(APR_OC_REASON_RUNNING); + fspr_proc_other_child_refresh_all(APR_OC_REASON_RUNNING); ABTS_STR_EQUAL(tc, "APR_OC_REASON_DEATH", reasonstr); } #else diff --git a/libs/apr/test/testpath.c b/libs/apr/test/testpath.c index b05ae9917e..6de85b8400 100644 --- a/libs/apr/test/testpath.c +++ b/libs/apr/test/testpath.c @@ -15,10 +15,10 @@ */ #include "testutil.h" -#include "apr_file_info.h" -#include "apr_errno.h" -#include "apr_pools.h" -#include "apr_tables.h" +#include "fspr_file_info.h" +#include "fspr_errno.h" +#include "fspr_pools.h" +#include "fspr_tables.h" #if defined(WIN32) || defined(NETWARE) || defined(OS2) #define PSEP ";" @@ -46,11 +46,11 @@ static const int parts_out_count = sizeof(parts_out)/sizeof(*parts_out); static void list_split_multi(abts_case *tc, void *data) { int i; - apr_status_t rv; - apr_array_header_t *pathelts; + fspr_status_t rv; + fspr_array_header_t *pathelts; pathelts = NULL; - rv = apr_filepath_list_split(&pathelts, path_in, p); + rv = fspr_filepath_list_split(&pathelts, path_in, p); ABTS_PTR_NOTNULL(tc, pathelts); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, parts_out_count, pathelts->nelts); @@ -61,13 +61,13 @@ static void list_split_multi(abts_case *tc, void *data) static void list_split_single(abts_case *tc, void *data) { int i; - apr_status_t rv; - apr_array_header_t *pathelts; + fspr_status_t rv; + fspr_array_header_t *pathelts; for (i = 0; i < parts_in_count; ++i) { pathelts = NULL; - rv = apr_filepath_list_split(&pathelts, parts_in[i], p); + rv = fspr_filepath_list_split(&pathelts, parts_in[i], p); ABTS_PTR_NOTNULL(tc, pathelts); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); if (parts_in[i][0] == '\0') @@ -84,15 +84,15 @@ static void list_merge_multi(abts_case *tc, void *data) { int i; char *liststr; - apr_status_t rv; - apr_array_header_t *pathelts; + fspr_status_t rv; + fspr_array_header_t *pathelts; - pathelts = apr_array_make(p, parts_in_count, sizeof(const char*)); + pathelts = fspr_array_make(p, parts_in_count, sizeof(const char*)); for (i = 0; i < parts_in_count; ++i) - *(const char**)apr_array_push(pathelts) = parts_in[i]; + *(const char**)fspr_array_push(pathelts) = parts_in[i]; liststr = NULL; - rv = apr_filepath_list_merge(&liststr, pathelts, p); + rv = fspr_filepath_list_merge(&liststr, pathelts, p); ABTS_PTR_NOTNULL(tc, liststr); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_STR_EQUAL(tc, liststr, path_out); @@ -102,16 +102,16 @@ static void list_merge_single(abts_case *tc, void *data) { int i; char *liststr; - apr_status_t rv; - apr_array_header_t *pathelts; + fspr_status_t rv; + fspr_array_header_t *pathelts; - pathelts = apr_array_make(p, 1, sizeof(const char*)); - apr_array_push(pathelts); + pathelts = fspr_array_make(p, 1, sizeof(const char*)); + fspr_array_push(pathelts); for (i = 0; i < parts_in_count; ++i) { *(const char**)pathelts->elts = parts_in[i]; liststr = NULL; - rv = apr_filepath_list_merge(&liststr, pathelts, p); + rv = fspr_filepath_list_merge(&liststr, pathelts, p); if (parts_in[i][0] == '\0') ABTS_PTR_EQUAL(tc, NULL, liststr); else diff --git a/libs/apr/test/testpipe.c b/libs/apr/test/testpipe.c index db3c77ffc3..add6c384a7 100644 --- a/libs/apr/test/testpipe.c +++ b/libs/apr/test/testpipe.c @@ -17,21 +17,21 @@ #include #include "testutil.h" -#include "apr_file_io.h" -#include "apr_errno.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_thread_proc.h" -#include "apr_strings.h" +#include "fspr_file_io.h" +#include "fspr_errno.h" +#include "fspr_general.h" +#include "fspr_lib.h" +#include "fspr_thread_proc.h" +#include "fspr_strings.h" -static apr_file_t *readp = NULL; -static apr_file_t *writep = NULL; +static fspr_file_t *readp = NULL; +static fspr_file_t *writep = NULL; static void create_pipe(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; - rv = apr_file_pipe_create(&readp, &writep, p); + rv = fspr_file_pipe_create(&readp, &writep, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_PTR_NOTNULL(tc, readp); ABTS_PTR_NOTNULL(tc, writep); @@ -39,60 +39,60 @@ static void create_pipe(abts_case *tc, void *data) static void close_pipe(abts_case *tc, void *data) { - apr_status_t rv; - apr_size_t nbytes = 256; + fspr_status_t rv; + fspr_size_t nbytes = 256; char buf[256]; - rv = apr_file_close(readp); - rv = apr_file_close(writep); + rv = fspr_file_close(readp); + rv = fspr_file_close(writep); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_file_read(readp, buf, &nbytes); + rv = fspr_file_read(readp, buf, &nbytes); ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_EBADF(rv)); } static void set_timeout(abts_case *tc, void *data) { - apr_status_t rv; - apr_interval_time_t timeout; + fspr_status_t rv; + fspr_interval_time_t timeout; - rv = apr_file_pipe_create(&readp, &writep, p); + rv = fspr_file_pipe_create(&readp, &writep, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_PTR_NOTNULL(tc, readp); ABTS_PTR_NOTNULL(tc, writep); - rv = apr_file_pipe_timeout_get(readp, &timeout); + rv = fspr_file_pipe_timeout_get(readp, &timeout); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_ASSERT(tc, "Timeout mismatch, expected -1", timeout == -1); - rv = apr_file_pipe_timeout_set(readp, apr_time_from_sec(1)); + rv = fspr_file_pipe_timeout_set(readp, fspr_time_from_sec(1)); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_file_pipe_timeout_get(readp, &timeout); + rv = fspr_file_pipe_timeout_get(readp, &timeout); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_ASSERT(tc, "Timeout mismatch, expected 1 second", - timeout == apr_time_from_sec(1)); + timeout == fspr_time_from_sec(1)); } static void read_write(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; char *buf; - apr_size_t nbytes; + fspr_size_t nbytes; nbytes = strlen("this is a test"); - buf = (char *)apr_palloc(p, nbytes + 1); + buf = (char *)fspr_palloc(p, nbytes + 1); - rv = apr_file_pipe_create(&readp, &writep, p); + rv = fspr_file_pipe_create(&readp, &writep, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_PTR_NOTNULL(tc, readp); ABTS_PTR_NOTNULL(tc, writep); - rv = apr_file_pipe_timeout_set(readp, apr_time_from_sec(1)); + rv = fspr_file_pipe_timeout_set(readp, fspr_time_from_sec(1)); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); if (!rv) { - rv = apr_file_read(readp, buf, &nbytes); + rv = fspr_file_read(readp, buf, &nbytes); ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_TIMEUP(rv)); ABTS_INT_EQUAL(tc, 0, nbytes); } @@ -100,25 +100,25 @@ static void read_write(abts_case *tc, void *data) static void read_write_notimeout(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; char *buf = "this is a test"; char *input; - apr_size_t nbytes; + fspr_size_t nbytes; nbytes = strlen("this is a test"); - rv = apr_file_pipe_create(&readp, &writep, p); + rv = fspr_file_pipe_create(&readp, &writep, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_PTR_NOTNULL(tc, readp); ABTS_PTR_NOTNULL(tc, writep); - rv = apr_file_write(writep, buf, &nbytes); + rv = fspr_file_write(writep, buf, &nbytes); ABTS_INT_EQUAL(tc, strlen("this is a test"), nbytes); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); nbytes = 256; - input = apr_pcalloc(p, nbytes + 1); - rv = apr_file_read(readp, input, &nbytes); + input = fspr_pcalloc(p, nbytes + 1); + rv = fspr_file_read(readp, input, &nbytes); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, strlen("this is a test"), nbytes); ABTS_STR_EQUAL(tc, "this is a test", input); @@ -131,54 +131,54 @@ static void test_pipe_writefull(abts_case *tc, void *data) int bytes_per_iteration = 8000; char *buf = (char *)malloc(bytes_per_iteration); char responsebuf[128]; - apr_size_t nbytes; + fspr_size_t nbytes; int bytes_processed; - apr_proc_t proc = {0}; - apr_procattr_t *procattr; + fspr_proc_t proc = {0}; + fspr_procattr_t *procattr; const char *args[2]; - apr_status_t rv; - apr_exit_why_e why; + fspr_status_t rv; + fspr_exit_why_e why; - rv = apr_procattr_create(&procattr, p); + rv = fspr_procattr_create(&procattr, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_procattr_io_set(procattr, APR_CHILD_BLOCK, APR_CHILD_BLOCK, + rv = fspr_procattr_io_set(procattr, APR_CHILD_BLOCK, APR_CHILD_BLOCK, APR_CHILD_BLOCK); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_procattr_error_check_set(procattr, 1); + rv = fspr_procattr_error_check_set(procattr, 1); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); args[0] = "readchild" EXTENSION; args[1] = NULL; - rv = apr_proc_create(&proc, "./readchild" EXTENSION, args, NULL, procattr, p); + rv = fspr_proc_create(&proc, "./readchild" EXTENSION, args, NULL, procattr, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_file_pipe_timeout_set(proc.in, apr_time_from_sec(10)); + rv = fspr_file_pipe_timeout_set(proc.in, fspr_time_from_sec(10)); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_file_pipe_timeout_set(proc.out, apr_time_from_sec(10)); + rv = fspr_file_pipe_timeout_set(proc.out, fspr_time_from_sec(10)); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); i = iterations; do { - rv = apr_file_write_full(proc.in, buf, bytes_per_iteration, NULL); + rv = fspr_file_write_full(proc.in, buf, bytes_per_iteration, NULL); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); } while (--i); free(buf); - rv = apr_file_close(proc.in); + rv = fspr_file_close(proc.in); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); nbytes = sizeof(responsebuf); - rv = apr_file_read(proc.out, responsebuf, &nbytes); + rv = fspr_file_read(proc.out, responsebuf, &nbytes); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - bytes_processed = (int)apr_strtoi64(responsebuf, NULL, 10); + bytes_processed = (int)fspr_strtoi64(responsebuf, NULL, 10); ABTS_INT_EQUAL(tc, iterations * bytes_per_iteration, bytes_processed); ABTS_ASSERT(tc, "wait for child process", - apr_proc_wait(&proc, NULL, &why, APR_WAIT) == APR_CHILD_DONE); + fspr_proc_wait(&proc, NULL, &why, APR_WAIT) == APR_CHILD_DONE); ABTS_ASSERT(tc, "child terminated normally", why == APR_PROC_EXIT); } diff --git a/libs/apr/test/testpoll.c b/libs/apr/test/testpoll.c index 36dd8a06bf..1b1424614a 100644 --- a/libs/apr/test/testpoll.c +++ b/libs/apr/test/testpoll.c @@ -15,12 +15,12 @@ */ #include "testutil.h" -#include "apr_strings.h" -#include "apr_errno.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_network_io.h" -#include "apr_poll.h" +#include "fspr_strings.h" +#include "fspr_errno.h" +#include "fspr_general.h" +#include "fspr_lib.h" +#include "fspr_network_io.h" +#include "fspr_poll.h" #define SMALL_NUM_SOCKETS 3 /* We can't use 64 here, because some platforms *ahem* Solaris *ahem* have @@ -29,83 +29,83 @@ */ #define LARGE_NUM_SOCKETS 50 -static apr_socket_t *s[LARGE_NUM_SOCKETS]; -static apr_sockaddr_t *sa[LARGE_NUM_SOCKETS]; -static apr_pollset_t *pollset; +static fspr_socket_t *s[LARGE_NUM_SOCKETS]; +static fspr_sockaddr_t *sa[LARGE_NUM_SOCKETS]; +static fspr_pollset_t *pollset; /* ###: tests surrounded by ifdef OLD_POLL_INTERFACE either need to be * converted to use the pollset interface or removed. */ #ifdef OLD_POLL_INTERFACE -static apr_pollfd_t *pollarray; -static apr_pollfd_t *pollarray_large; +static fspr_pollfd_t *pollarray; +static fspr_pollfd_t *pollarray_large; #endif -static void make_socket(apr_socket_t **sock, apr_sockaddr_t **sa, - apr_port_t port, apr_pool_t *p, abts_case *tc) +static void make_socket(fspr_socket_t **sock, fspr_sockaddr_t **sa, + fspr_port_t port, fspr_pool_t *p, abts_case *tc) { - apr_status_t rv; + fspr_status_t rv; - rv = apr_sockaddr_info_get(sa, "127.0.0.1", APR_UNSPEC, port, 0, p); + rv = fspr_sockaddr_info_get(sa, "127.0.0.1", APR_UNSPEC, port, 0, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_socket_create(sock, (*sa)->family, SOCK_DGRAM, 0, p); + rv = fspr_socket_create(sock, (*sa)->family, SOCK_DGRAM, 0, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv =apr_socket_bind((*sock), (*sa)); + rv =fspr_socket_bind((*sock), (*sa)); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); } #ifdef OLD_POLL_INTERFACE -static void check_sockets(const apr_pollfd_t *pollarray, - apr_socket_t **sockarray, int which, int pollin, +static void check_sockets(const fspr_pollfd_t *pollarray, + fspr_socket_t **sockarray, int which, int pollin, abts_case *tc) { - apr_status_t rv; - apr_int16_t event; + fspr_status_t rv; + fspr_int16_t event; char *str; - rv = apr_poll_revents_get(&event, sockarray[which], - (apr_pollfd_t *)pollarray); + rv = fspr_poll_revents_get(&event, sockarray[which], + (fspr_pollfd_t *)pollarray); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); if (pollin) { - str = apr_psprintf(p, "Socket %d not signalled when it should be", + str = fspr_psprintf(p, "Socket %d not signalled when it should be", which); ABTS_ASSERT(tc, str, event & APR_POLLIN); } else { - str = apr_psprintf(p, "Socket %d signalled when it should not be", + str = fspr_psprintf(p, "Socket %d signalled when it should not be", which); ABTS_ASSERT(tc, str, !(event & APR_POLLIN)); } } #endif -static void send_msg(apr_socket_t **sockarray, apr_sockaddr_t **sas, int which, +static void send_msg(fspr_socket_t **sockarray, fspr_sockaddr_t **sas, int which, abts_case *tc) { - apr_size_t len = 5; - apr_status_t rv; + fspr_size_t len = 5; + fspr_status_t rv; ABTS_PTR_NOTNULL(tc, sockarray[which]); - rv = apr_socket_sendto(sockarray[which], sas[which], 0, "hello", &len); + rv = fspr_socket_sendto(sockarray[which], sas[which], 0, "hello", &len); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, strlen("hello"), len); } -static void recv_msg(apr_socket_t **sockarray, int which, apr_pool_t *p, +static void recv_msg(fspr_socket_t **sockarray, int which, fspr_pool_t *p, abts_case *tc) { - apr_size_t buflen = 5; - char *buffer = apr_pcalloc(p, sizeof(char) * (buflen + 1)); - apr_sockaddr_t *recsa; - apr_status_t rv; + fspr_size_t buflen = 5; + char *buffer = fspr_pcalloc(p, sizeof(char) * (buflen + 1)); + fspr_sockaddr_t *recsa; + fspr_status_t rv; ABTS_PTR_NOTNULL(tc, sockarray[which]); - apr_sockaddr_info_get(&recsa, "127.0.0.1", APR_UNSPEC, 7770, 0, p); + fspr_sockaddr_info_get(&recsa, "127.0.0.1", APR_UNSPEC, 7770, 0, p); - rv = apr_socket_recvfrom(recsa, sockarray[which], 0, buffer, &buflen); + rv = fspr_socket_recvfrom(recsa, sockarray[which], 0, buffer, &buflen); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, strlen("hello"), buflen); ABTS_STR_EQUAL(tc, "hello", buffer); @@ -124,17 +124,17 @@ static void create_all_sockets(abts_case *tc, void *data) #ifdef OLD_POLL_INTERFACE static void setup_small_poll(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; int i; - rv = apr_poll_setup(&pollarray, SMALL_NUM_SOCKETS, p); + rv = fspr_poll_setup(&pollarray, SMALL_NUM_SOCKETS, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); for (i = 0; i < SMALL_NUM_SOCKETS;i++){ ABTS_INT_EQUAL(tc, 0, pollarray[i].reqevents); ABTS_INT_EQUAL(tc, 0, pollarray[i].rtnevents); - rv = apr_poll_socket_add(pollarray, s[i], APR_POLLIN); + rv = fspr_poll_socket_add(pollarray, s[i], APR_POLLIN); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_PTR_EQUAL(tc, s[i], pollarray[i].desc.s); } @@ -142,17 +142,17 @@ static void setup_small_poll(abts_case *tc, void *data) static void setup_large_poll(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; int i; - rv = apr_poll_setup(&pollarray_large, LARGE_NUM_SOCKETS, p); + rv = fspr_poll_setup(&pollarray_large, LARGE_NUM_SOCKETS, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); for (i = 0; i < LARGE_NUM_SOCKETS;i++){ ABTS_INT_EQUAL(tc, 0, pollarray_large[i].reqevents); ABTS_INT_EQUAL(tc, 0, pollarray_large[i].rtnevents); - rv = apr_poll_socket_add(pollarray_large, s[i], APR_POLLIN); + rv = fspr_poll_socket_add(pollarray_large, s[i], APR_POLLIN); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_PTR_EQUAL(tc, s[i], pollarray_large[i].desc.s); } @@ -160,10 +160,10 @@ static void setup_large_poll(abts_case *tc, void *data) static void nomessage(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; int srv = SMALL_NUM_SOCKETS; - rv = apr_poll(pollarray, SMALL_NUM_SOCKETS, &srv, 2 * APR_USEC_PER_SEC); + rv = fspr_poll(pollarray, SMALL_NUM_SOCKETS, &srv, 2 * APR_USEC_PER_SEC); ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_TIMEUP(rv)); check_sockets(pollarray, s, 0, 0, tc); check_sockets(pollarray, s, 1, 0, tc); @@ -172,12 +172,12 @@ static void nomessage(abts_case *tc, void *data) static void send_2(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; int srv = SMALL_NUM_SOCKETS; send_msg(s, sa, 2, tc); - rv = apr_poll(pollarray, SMALL_NUM_SOCKETS, &srv, 2 * APR_USEC_PER_SEC); + rv = fspr_poll(pollarray, SMALL_NUM_SOCKETS, &srv, 2 * APR_USEC_PER_SEC); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); check_sockets(pollarray, s, 0, 0, tc); check_sockets(pollarray, s, 1, 0, tc); @@ -186,13 +186,13 @@ static void send_2(abts_case *tc, void *data) static void recv_2_send_1(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; int srv = SMALL_NUM_SOCKETS; recv_msg(s, 2, p, tc); send_msg(s, sa, 1, tc); - rv = apr_poll(pollarray, SMALL_NUM_SOCKETS, &srv, 2 * APR_USEC_PER_SEC); + rv = fspr_poll(pollarray, SMALL_NUM_SOCKETS, &srv, 2 * APR_USEC_PER_SEC); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); check_sockets(pollarray, s, 0, 0, tc); check_sockets(pollarray, s, 1, 1, tc); @@ -201,12 +201,12 @@ static void recv_2_send_1(abts_case *tc, void *data) static void send_2_signaled_1(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; int srv = SMALL_NUM_SOCKETS; send_msg(s, sa, 2, tc); - rv = apr_poll(pollarray, SMALL_NUM_SOCKETS, &srv, 2 * APR_USEC_PER_SEC); + rv = fspr_poll(pollarray, SMALL_NUM_SOCKETS, &srv, 2 * APR_USEC_PER_SEC); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); check_sockets(pollarray, s, 0, 0, tc); check_sockets(pollarray, s, 1, 1, tc); @@ -215,13 +215,13 @@ static void send_2_signaled_1(abts_case *tc, void *data) static void recv_1_send_0(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; int srv = SMALL_NUM_SOCKETS; recv_msg(s, 1, p, tc); send_msg(s, sa, 0, tc); - rv = apr_poll(pollarray, SMALL_NUM_SOCKETS, &srv, 2 * APR_USEC_PER_SEC); + rv = fspr_poll(pollarray, SMALL_NUM_SOCKETS, &srv, 2 * APR_USEC_PER_SEC); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); check_sockets(pollarray, s, 0, 1, tc); check_sockets(pollarray, s, 1, 0, tc); @@ -230,13 +230,13 @@ static void recv_1_send_0(abts_case *tc, void *data) static void clear_all_signalled(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; int srv = SMALL_NUM_SOCKETS; recv_msg(s, 0, p, tc); recv_msg(s, 2, p, tc); - rv = apr_poll(pollarray, SMALL_NUM_SOCKETS, &srv, 2 * APR_USEC_PER_SEC); + rv = fspr_poll(pollarray, SMALL_NUM_SOCKETS, &srv, 2 * APR_USEC_PER_SEC); ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_TIMEUP(rv)); check_sockets(pollarray, s, 0, 0, tc); check_sockets(pollarray, s, 1, 0, tc); @@ -245,13 +245,13 @@ static void clear_all_signalled(abts_case *tc, void *data) static void send_large_pollarray(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; int lrv = LARGE_NUM_SOCKETS; int i; send_msg(s, sa, LARGE_NUM_SOCKETS - 1, tc); - rv = apr_poll(pollarray_large, LARGE_NUM_SOCKETS, &lrv, + rv = fspr_poll(pollarray_large, LARGE_NUM_SOCKETS, &lrv, 2 * APR_USEC_PER_SEC); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); @@ -267,13 +267,13 @@ static void send_large_pollarray(abts_case *tc, void *data) static void recv_large_pollarray(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; int lrv = LARGE_NUM_SOCKETS; int i; recv_msg(s, LARGE_NUM_SOCKETS - 1, p, tc); - rv = apr_poll(pollarray_large, LARGE_NUM_SOCKETS, &lrv, + rv = fspr_poll(pollarray_large, LARGE_NUM_SOCKETS, &lrv, 2 * APR_USEC_PER_SEC); ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_TIMEUP(rv)); @@ -285,29 +285,29 @@ static void recv_large_pollarray(abts_case *tc, void *data) static void setup_pollset(abts_case *tc, void *data) { - apr_status_t rv; - rv = apr_pollset_create(&pollset, LARGE_NUM_SOCKETS, p, 0); + fspr_status_t rv; + rv = fspr_pollset_create(&pollset, LARGE_NUM_SOCKETS, p, 0); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); } static void multi_event_pollset(abts_case *tc, void *data) { - apr_status_t rv; - apr_pollfd_t socket_pollfd; + fspr_status_t rv; + fspr_pollfd_t socket_pollfd; int lrv; - const apr_pollfd_t *descs = NULL; + const fspr_pollfd_t *descs = NULL; ABTS_PTR_NOTNULL(tc, s[0]); socket_pollfd.desc_type = APR_POLL_SOCKET; socket_pollfd.reqevents = APR_POLLIN | APR_POLLOUT; socket_pollfd.desc.s = s[0]; socket_pollfd.client_data = s[0]; - rv = apr_pollset_add(pollset, &socket_pollfd); + rv = fspr_pollset_add(pollset, &socket_pollfd); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); send_msg(s, sa, 0, tc); - rv = apr_pollset_poll(pollset, 0, &lrv, &descs); + rv = fspr_pollset_poll(pollset, 0, &lrv, &descs); ABTS_INT_EQUAL(tc, 0, APR_STATUS_IS_TIMEUP(rv)); if (lrv == 1) { ABTS_PTR_EQUAL(tc, s[0], descs[0].desc.s); @@ -331,24 +331,24 @@ static void multi_event_pollset(abts_case *tc, void *data) recv_msg(s, 0, p, tc); - rv = apr_pollset_poll(pollset, 0, &lrv, &descs); + rv = fspr_pollset_poll(pollset, 0, &lrv, &descs); ABTS_INT_EQUAL(tc, 0, APR_STATUS_IS_TIMEUP(rv)); ABTS_INT_EQUAL(tc, 1, lrv); ABTS_PTR_EQUAL(tc, s[0], descs[0].desc.s); ABTS_INT_EQUAL(tc, APR_POLLOUT, descs[0].rtnevents); ABTS_PTR_EQUAL(tc, s[0], descs[0].client_data); - rv = apr_pollset_remove(pollset, &socket_pollfd); + rv = fspr_pollset_remove(pollset, &socket_pollfd); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); } static void add_sockets_pollset(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; int i; for (i = 0; i < LARGE_NUM_SOCKETS;i++){ - apr_pollfd_t socket_pollfd; + fspr_pollfd_t socket_pollfd; ABTS_PTR_NOTNULL(tc, s[i]); @@ -356,18 +356,18 @@ static void add_sockets_pollset(abts_case *tc, void *data) socket_pollfd.reqevents = APR_POLLIN; socket_pollfd.desc.s = s[i]; socket_pollfd.client_data = s[i]; - rv = apr_pollset_add(pollset, &socket_pollfd); + rv = fspr_pollset_add(pollset, &socket_pollfd); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); } } static void nomessage_pollset(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; int lrv; - const apr_pollfd_t *descs = NULL; + const fspr_pollfd_t *descs = NULL; - rv = apr_pollset_poll(pollset, 0, &lrv, &descs); + rv = fspr_pollset_poll(pollset, 0, &lrv, &descs); ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_TIMEUP(rv)); ABTS_INT_EQUAL(tc, 0, lrv); ABTS_PTR_EQUAL(tc, NULL, descs); @@ -375,12 +375,12 @@ static void nomessage_pollset(abts_case *tc, void *data) static void send0_pollset(abts_case *tc, void *data) { - apr_status_t rv; - const apr_pollfd_t *descs = NULL; + fspr_status_t rv; + const fspr_pollfd_t *descs = NULL; int num; send_msg(s, sa, 0, tc); - rv = apr_pollset_poll(pollset, 0, &num, &descs); + rv = fspr_pollset_poll(pollset, 0, &num, &descs); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, 1, num); ABTS_PTR_NOTNULL(tc, descs); @@ -391,12 +391,12 @@ static void send0_pollset(abts_case *tc, void *data) static void recv0_pollset(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; int lrv; - const apr_pollfd_t *descs = NULL; + const fspr_pollfd_t *descs = NULL; recv_msg(s, 0, p, tc); - rv = apr_pollset_poll(pollset, 0, &lrv, &descs); + rv = fspr_pollset_poll(pollset, 0, &lrv, &descs); ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_TIMEUP(rv)); ABTS_INT_EQUAL(tc, 0, lrv); ABTS_PTR_EQUAL(tc, NULL, descs); @@ -404,13 +404,13 @@ static void recv0_pollset(abts_case *tc, void *data) static void send_middle_pollset(abts_case *tc, void *data) { - apr_status_t rv; - const apr_pollfd_t *descs = NULL; + fspr_status_t rv; + const fspr_pollfd_t *descs = NULL; int num; send_msg(s, sa, 2, tc); send_msg(s, sa, 5, tc); - rv = apr_pollset_poll(pollset, 0, &num, &descs); + rv = fspr_pollset_poll(pollset, 0, &num, &descs); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, 2, num); ABTS_PTR_NOTNULL(tc, descs); @@ -422,14 +422,14 @@ static void send_middle_pollset(abts_case *tc, void *data) static void clear_middle_pollset(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; int lrv; - const apr_pollfd_t *descs = NULL; + const fspr_pollfd_t *descs = NULL; recv_msg(s, 2, p, tc); recv_msg(s, 5, p, tc); - rv = apr_pollset_poll(pollset, 0, &lrv, &descs); + rv = fspr_pollset_poll(pollset, 0, &lrv, &descs); ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_TIMEUP(rv)); ABTS_INT_EQUAL(tc, 0, lrv); ABTS_PTR_EQUAL(tc, NULL, descs); @@ -437,12 +437,12 @@ static void clear_middle_pollset(abts_case *tc, void *data) static void send_last_pollset(abts_case *tc, void *data) { - apr_status_t rv; - const apr_pollfd_t *descs = NULL; + fspr_status_t rv; + const fspr_pollfd_t *descs = NULL; int num; send_msg(s, sa, LARGE_NUM_SOCKETS - 1, tc); - rv = apr_pollset_poll(pollset, 0, &num, &descs); + rv = fspr_pollset_poll(pollset, 0, &num, &descs); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, 1, num); ABTS_PTR_NOTNULL(tc, descs); @@ -453,13 +453,13 @@ static void send_last_pollset(abts_case *tc, void *data) static void clear_last_pollset(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; int lrv; - const apr_pollfd_t *descs = NULL; + const fspr_pollfd_t *descs = NULL; recv_msg(s, LARGE_NUM_SOCKETS - 1, p, tc); - rv = apr_pollset_poll(pollset, 0, &lrv, &descs); + rv = fspr_pollset_poll(pollset, 0, &lrv, &descs); ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_TIMEUP(rv)); ABTS_INT_EQUAL(tc, 0, lrv); ABTS_PTR_EQUAL(tc, NULL, descs); @@ -467,24 +467,24 @@ static void clear_last_pollset(abts_case *tc, void *data) static void close_all_sockets(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; int i; for (i = 0; i < LARGE_NUM_SOCKETS; i++){ - rv = apr_socket_close(s[i]); + rv = fspr_socket_close(s[i]); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); } } static void pollset_remove(abts_case *tc, void *data) { - apr_status_t rv; - apr_pollset_t *pollset; - const apr_pollfd_t *hot_files; - apr_pollfd_t pfd; - apr_int32_t num; + fspr_status_t rv; + fspr_pollset_t *pollset; + const fspr_pollfd_t *hot_files; + fspr_pollfd_t pfd; + fspr_int32_t num; - rv = apr_pollset_create(&pollset, 5, p, 0); + rv = fspr_pollset_create(&pollset, 5, p, 0); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); pfd.p = p; @@ -493,36 +493,36 @@ static void pollset_remove(abts_case *tc, void *data) pfd.desc.s = s[0]; pfd.client_data = (void *)1; - rv = apr_pollset_add(pollset, &pfd); + rv = fspr_pollset_add(pollset, &pfd); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); pfd.desc.s = s[1]; pfd.client_data = (void *)2; - rv = apr_pollset_add(pollset, &pfd); + rv = fspr_pollset_add(pollset, &pfd); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); pfd.desc.s = s[2]; pfd.client_data = (void *)3; - rv = apr_pollset_add(pollset, &pfd); + rv = fspr_pollset_add(pollset, &pfd); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); pfd.desc.s = s[3]; pfd.client_data = (void *)4; - rv = apr_pollset_add(pollset, &pfd); + rv = fspr_pollset_add(pollset, &pfd); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_pollset_poll(pollset, 1000, &num, &hot_files); + rv = fspr_pollset_poll(pollset, 1000, &num, &hot_files); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, 4, num); /* now remove the pollset element referring to desc s[1] */ pfd.desc.s = s[1]; pfd.client_data = (void *)999; /* not used on this call */ - rv = apr_pollset_remove(pollset, &pfd); + rv = fspr_pollset_remove(pollset, &pfd); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); /* this time only three should match */ - rv = apr_pollset_poll(pollset, 1000, &num, &hot_files); + rv = fspr_pollset_poll(pollset, 1000, &num, &hot_files); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, 3, num); ABTS_PTR_EQUAL(tc, (void *)1, hot_files[0].client_data); @@ -535,11 +535,11 @@ static void pollset_remove(abts_case *tc, void *data) /* now remove the pollset elements referring to desc s[2] */ pfd.desc.s = s[2]; pfd.client_data = (void *)999; /* not used on this call */ - rv = apr_pollset_remove(pollset, &pfd); + rv = fspr_pollset_remove(pollset, &pfd); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); /* this time only two should match */ - rv = apr_pollset_poll(pollset, 1000, &num, &hot_files); + rv = fspr_pollset_poll(pollset, 1000, &num, &hot_files); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, 2, num); ABTS_ASSERT(tc, "Incorrect socket in result set", diff --git a/libs/apr/test/testpools.c b/libs/apr/test/testpools.c index cb45552e77..9354dd44f8 100644 --- a/libs/apr/test/testpools.c +++ b/libs/apr/test/testpools.c @@ -15,10 +15,10 @@ */ -#include "apr_general.h" -#include "apr_pools.h" -#include "apr_errno.h" -#include "apr_file_io.h" +#include "fspr_general.h" +#include "fspr_pools.h" +#include "fspr_errno.h" +#include "fspr_file_io.h" #include #include #include @@ -29,15 +29,15 @@ #define ALLOC_BYTES 1024 -static apr_pool_t *pmain = NULL; -static apr_pool_t *pchild = NULL; +static fspr_pool_t *pmain = NULL; +static fspr_pool_t *pchild = NULL; static void alloc_bytes(abts_case *tc, void *data) { int i; char *alloc; - alloc = apr_palloc(pmain, ALLOC_BYTES); + alloc = fspr_palloc(pmain, ALLOC_BYTES); ABTS_PTR_NOTNULL(tc, alloc); for (i=0;i #include @@ -32,47 +32,47 @@ #define CHILDREN 6 #define MAX_COUNTER (MAX_ITER * CHILDREN) -static apr_proc_mutex_t *proc_lock; +static fspr_proc_mutex_t *proc_lock; static volatile int *x; /* a slower more racy way to implement (*x)++ */ static int increment(int n) { - apr_sleep(1); + fspr_sleep(1); return n+1; } -static void make_child(abts_case *tc, apr_proc_t **proc, apr_pool_t *p) +static void make_child(abts_case *tc, fspr_proc_t **proc, fspr_pool_t *p) { - apr_status_t rv; + fspr_status_t rv; - *proc = apr_pcalloc(p, sizeof(**proc)); + *proc = fspr_pcalloc(p, sizeof(**proc)); /* slight delay to allow things to settle */ - apr_sleep (1); + fspr_sleep (1); - rv = apr_proc_fork(*proc, p); + rv = fspr_proc_fork(*proc, p); if (rv == APR_INCHILD) { int i = 0; - /* The parent process has setup all processes to call apr_terminate + /* The parent process has setup all processes to call fspr_terminate * at exit. But, that means that all processes must also call - * apr_initialize at startup. You cannot have an unequal number - * of apr_terminate and apr_initialize calls. If you do, bad things + * fspr_initialize at startup. You cannot have an unequal number + * of fspr_terminate and fspr_initialize calls. If you do, bad things * will happen. In this case, the bad thing is that if the mutex * is a semaphore, it will be destroyed before all of the processes * die. That means that the test will most likely fail. */ - apr_initialize(); + fspr_initialize(); - if (apr_proc_mutex_child_init(&proc_lock, NULL, p)) + if (fspr_proc_mutex_child_init(&proc_lock, NULL, p)) exit(1); do { - if (apr_proc_mutex_lock(proc_lock)) + if (fspr_proc_mutex_lock(proc_lock)) exit(1); i++; *x = increment(*x); - if (apr_proc_mutex_unlock(proc_lock)) + if (fspr_proc_mutex_unlock(proc_lock)) exit(1); } while (i < MAX_ITER); exit(0); @@ -82,25 +82,25 @@ static void make_child(abts_case *tc, apr_proc_t **proc, apr_pool_t *p) } /* Wait for a child process and check it terminated with success. */ -static void await_child(abts_case *tc, apr_proc_t *proc) +static void await_child(abts_case *tc, fspr_proc_t *proc) { int code; - apr_exit_why_e why; - apr_status_t rv; + fspr_exit_why_e why; + fspr_status_t rv; - rv = apr_proc_wait(proc, &code, &why, APR_WAIT); + rv = fspr_proc_wait(proc, &code, &why, APR_WAIT); ABTS_ASSERT(tc, "child did not terminate with success", rv == APR_CHILD_DONE && why == APR_PROC_EXIT && code == 0); } static void test_exclusive(abts_case *tc, const char *lockname, - apr_lockmech_e mech) + fspr_lockmech_e mech) { - apr_proc_t *child[CHILDREN]; - apr_status_t rv; + fspr_proc_t *child[CHILDREN]; + fspr_status_t rv; int n; - rv = apr_proc_mutex_create(&proc_lock, lockname, mech, p); + rv = fspr_proc_mutex_create(&proc_lock, lockname, mech, p); APR_ASSERT_SUCCESS(tc, "create the mutex", rv); if (rv != APR_SUCCESS) return; @@ -118,25 +118,25 @@ static void test_exclusive(abts_case *tc, const char *lockname, static void proc_mutex(abts_case *tc, void *data) { #if APR_HAS_FORK - apr_status_t rv; + fspr_status_t rv; const char *shmname = "tpm.shm"; - apr_shm_t *shm; - apr_lockmech_e *mech = data; + fspr_shm_t *shm; + fspr_lockmech_e *mech = data; /* Use anonymous shm if available. */ - rv = apr_shm_create(&shm, sizeof(int), NULL, p); + rv = fspr_shm_create(&shm, sizeof(int), NULL, p); if (rv == APR_ENOTIMPL) { - apr_file_remove(shmname, p); - rv = apr_shm_create(&shm, sizeof(int), shmname, p); + fspr_file_remove(shmname, p); + rv = fspr_shm_create(&shm, sizeof(int), shmname, p); } APR_ASSERT_SUCCESS(tc, "create shm segment", rv); if (rv != APR_SUCCESS) return; - x = apr_shm_baseaddr_get(shm); + x = fspr_shm_baseaddr_get(shm); test_exclusive(tc, NULL, *mech); - rv = apr_shm_destroy(shm); + rv = fspr_shm_destroy(shm); APR_ASSERT_SUCCESS(tc, "Error destroying shared memory block", rv); #else ABTS_NOT_IMPL(tc, "APR lacks fork() support"); @@ -146,7 +146,7 @@ static void proc_mutex(abts_case *tc, void *data) abts_suite *testprocmutex(abts_suite *suite) { - apr_lockmech_e mech = APR_LOCK_DEFAULT; + fspr_lockmech_e mech = APR_LOCK_DEFAULT; suite = ADD_SUITE(suite) abts_run_test(suite, proc_mutex, &mech); diff --git a/libs/apr/test/testrand.c b/libs/apr/test/testrand.c index befed08745..346d8fb3a9 100644 --- a/libs/apr/test/testrand.c +++ b/libs/apr/test/testrand.c @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "apr_general.h" +#include "fspr_general.h" #include #include #include @@ -23,15 +23,15 @@ static void rand_exists(abts_case *tc, void *data) { #if !APR_HAS_RANDOM - ABTS_NOT_IMPL(tc, "apr_generate_random_bytes"); + ABTS_NOT_IMPL(tc, "fspr_generate_random_bytes"); #else unsigned char c[42]; /* There must be a better way to test random-ness, but I don't know * what it is right now. */ - APR_ASSERT_SUCCESS(tc, "apr_generate_random_bytes failed", - apr_generate_random_bytes(c, sizeof c)); + APR_ASSERT_SUCCESS(tc, "fspr_generate_random_bytes failed", + fspr_generate_random_bytes(c, sizeof c)); #endif } diff --git a/libs/apr/test/testrand2.c b/libs/apr/test/testrand2.c index f9f8286400..e233d18b6b 100644 --- a/libs/apr/test/testrand2.c +++ b/libs/apr/test/testrand2.c @@ -14,9 +14,9 @@ * limitations under the License. */ -#include "apr_general.h" -#include "apr_random.h" -#include "apr_thread_proc.h" +#include "fspr_general.h" +#include "fspr_random.h" +#include "fspr_thread_proc.h" #include #include #include @@ -43,15 +43,15 @@ static void hexdump(const unsigned char *b,int n) printf("\n"); } -static apr_random_t *r; +static fspr_random_t *r; -typedef apr_status_t APR_THREAD_FUNC rnd_fn(apr_random_t *r,void *b,apr_size_t n); +typedef fspr_status_t APR_THREAD_FUNC rnd_fn(fspr_random_t *r,void *b,fspr_size_t n); -static void rand_run_kat(abts_case *tc,rnd_fn *f,apr_random_t *r, +static void rand_run_kat(abts_case *tc,rnd_fn *f,fspr_random_t *r, const unsigned char expected[128]) { unsigned char c[128]; - apr_status_t rv; + fspr_status_t rv; rv=f(r,c,128); ABTS_INT_EQUAL(tc,0,rv); @@ -65,11 +65,11 @@ static void rand_run_kat(abts_case *tc,rnd_fn *f,apr_random_t *r, } } -static int rand_check_kat(rnd_fn *f,apr_random_t *r, +static int rand_check_kat(rnd_fn *f,fspr_random_t *r, const unsigned char expected[128]) { unsigned char c[128]; - apr_status_t rv; + fspr_status_t rv; rv=f(r,c,128); if(rv) @@ -79,18 +79,18 @@ static int rand_check_kat(rnd_fn *f,apr_random_t *r, return 0; } -static void rand_add_zeroes(apr_random_t *r) +static void rand_add_zeroes(fspr_random_t *r) { static unsigned char c[2048]; - apr_random_add_entropy(r,c,sizeof c); + fspr_random_add_entropy(r,c,sizeof c); } -static void rand_run_seed_short(abts_case *tc,rnd_fn *f,apr_random_t *r, +static void rand_run_seed_short(abts_case *tc,rnd_fn *f,fspr_random_t *r, int count) { int i; - apr_status_t rv; + fspr_status_t rv; char c[1]; for(i=0 ; i < count ; ++i) @@ -101,8 +101,8 @@ static void rand_run_seed_short(abts_case *tc,rnd_fn *f,apr_random_t *r, static void rand_seed_short(abts_case *tc, void *data) { - r=apr_random_standard_new(p); - rand_run_seed_short(tc,apr_random_insecure_bytes,r,32); + r=fspr_random_standard_new(p); + rand_run_seed_short(tc,fspr_random_insecure_bytes,r,32); } static void rand_kat(abts_case *tc, void *data) @@ -126,12 +126,12 @@ static void rand_kat(abts_case *tc, void *data) 0x87,0xec,0x2e,0xb1,0x2d,0x6a,0xbd,0x46 }; rand_add_zeroes(r); - rand_run_kat(tc,apr_random_insecure_bytes,r,expected); + rand_run_kat(tc,fspr_random_insecure_bytes,r,expected); } static void rand_seed_short2(abts_case *tc, void *data) { - rand_run_seed_short(tc,apr_random_secure_bytes,r,320); + rand_run_seed_short(tc,fspr_random_secure_bytes,r,320); } static void rand_kat2(abts_case *tc, void *data) @@ -155,13 +155,13 @@ static void rand_kat2(abts_case *tc, void *data) 0xed,0xd2,0xde,0xce,0x18,0x70,0x57,0x12 }; rand_add_zeroes(r); - rand_run_kat(tc,apr_random_secure_bytes,r,expected); + rand_run_kat(tc,fspr_random_secure_bytes,r,expected); } static void rand_barrier(abts_case *tc, void *data) { - apr_random_barrier(r); - rand_run_seed_short(tc,apr_random_secure_bytes,r,320); + fspr_random_barrier(r); + rand_run_seed_short(tc,fspr_random_secure_bytes,r,320); } static void rand_kat3(abts_case *tc, void *data) @@ -184,7 +184,7 @@ static void rand_kat3(abts_case *tc, void *data) 0x04,0xbf,0x32,0xd6,0xdc,0xb7,0x31,0x01, 0x29,0x51,0x51,0xb3,0x19,0x6e,0xe4,0xf8 }; - rand_run_kat(tc,apr_random_insecure_bytes,r,expected); + rand_run_kat(tc,fspr_random_insecure_bytes,r,expected); } static void rand_kat4(abts_case *tc, void *data) @@ -208,14 +208,14 @@ static void rand_kat4(abts_case *tc, void *data) 0x17,0x35,0x5f,0x35,0x8d,0x55,0x0c,0x07 }; rand_add_zeroes(r); - rand_run_kat(tc,apr_random_secure_bytes,r,expected); + rand_run_kat(tc,fspr_random_secure_bytes,r,expected); } #if APR_HAS_FORK static void rand_fork(abts_case *tc, void *data) { - apr_proc_t proc; - apr_status_t rv; + fspr_proc_t proc; + fspr_status_t rv; unsigned char expected[128]= { 0xac,0x93,0xd2,0x5c,0xc7,0xf5,0x8d,0xc2, 0xd8,0x8d,0xb6,0x7a,0x94,0xe1,0x83,0x4c, @@ -234,22 +234,22 @@ static void rand_fork(abts_case *tc, void *data) 0x32,0x8a,0x54,0x01,0xd0,0xaf,0x3f,0x13, 0xc1,0x7f,0x10,0x2e,0x08,0x1c,0x28,0x4b, }; - rv=apr_proc_fork(&proc,p); + rv=fspr_proc_fork(&proc,p); if(rv == APR_INCHILD) { int n; - n=rand_check_kat(apr_random_secure_bytes,r,expected); + n=rand_check_kat(fspr_random_secure_bytes,r,expected); exit(n); } else if(rv == APR_INPARENT) { int exitcode; - apr_exit_why_e why; + fspr_exit_why_e why; - rand_run_kat(tc,apr_random_secure_bytes,r,expected); - apr_proc_wait(&proc,&exitcode,&why,APR_WAIT); + rand_run_kat(tc,fspr_random_secure_bytes,r,expected); + fspr_proc_wait(&proc,&exitcode,&why,APR_WAIT); if(why != APR_PROC_EXIT) { ABTS_FAIL(tc,"Child terminated abnormally"); diff --git a/libs/apr/test/testshm.c b/libs/apr/test/testshm.c index 3691dd52ce..7839156583 100644 --- a/libs/apr/test/testshm.c +++ b/libs/apr/test/testshm.c @@ -15,15 +15,15 @@ */ #include "testutil.h" -#include "apr_shm.h" -#include "apr_errno.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_strings.h" -#include "apr_thread_proc.h" -#include "apr_time.h" +#include "fspr_shm.h" +#include "fspr_errno.h" +#include "fspr_general.h" +#include "fspr_lib.h" +#include "fspr_strings.h" +#include "fspr_thread_proc.h" +#include "fspr_time.h" #include "testshm.h" -#include "apr.h" +#include "fspr.h" #if APR_HAVE_STDLIB_H #include @@ -35,9 +35,9 @@ static int msgwait(int sleep_sec, int first_box, int last_box) { int i; int recvd = 0; - apr_time_t start = apr_time_now(); - apr_interval_time_t sleep_duration = apr_time_from_sec(sleep_sec); - while (apr_time_now() - start < sleep_duration) { + fspr_time_t start = fspr_time_now(); + fspr_interval_time_t sleep_duration = fspr_time_from_sec(sleep_sec); + while (fspr_time_now() - start < sleep_duration) { for (i = first_box; i < last_box; i++) { if (boxes[i].msgavail && !strcmp(boxes[i].msg, MSG)) { recvd++; @@ -48,84 +48,84 @@ static int msgwait(int sleep_sec, int first_box, int last_box) memset(boxes[i].msg, 0, 1024); } } - apr_sleep(apr_time_make(0, 10000)); /* 10ms */ + fspr_sleep(fspr_time_make(0, 10000)); /* 10ms */ } return recvd; } static void msgput(int boxnum, char *msg) { - apr_cpystrn(boxes[boxnum].msg, msg, strlen(msg) + 1); + fspr_cpystrn(boxes[boxnum].msg, msg, strlen(msg) + 1); boxes[boxnum].msgavail = 1; } static void test_anon_create(abts_case *tc, void *data) { - apr_status_t rv; - apr_shm_t *shm = NULL; + fspr_status_t rv; + fspr_shm_t *shm = NULL; - rv = apr_shm_create(&shm, SHARED_SIZE, NULL, p); + rv = fspr_shm_create(&shm, SHARED_SIZE, NULL, p); APR_ASSERT_SUCCESS(tc, "Error allocating shared memory block", rv); ABTS_PTR_NOTNULL(tc, shm); - rv = apr_shm_destroy(shm); + rv = fspr_shm_destroy(shm); APR_ASSERT_SUCCESS(tc, "Error destroying shared memory block", rv); } static void test_check_size(abts_case *tc, void *data) { - apr_status_t rv; - apr_shm_t *shm = NULL; - apr_size_t retsize; + fspr_status_t rv; + fspr_shm_t *shm = NULL; + fspr_size_t retsize; - rv = apr_shm_create(&shm, SHARED_SIZE, NULL, p); + rv = fspr_shm_create(&shm, SHARED_SIZE, NULL, p); APR_ASSERT_SUCCESS(tc, "Error allocating shared memory block", rv); ABTS_PTR_NOTNULL(tc, shm); - retsize = apr_shm_size_get(shm); + retsize = fspr_shm_size_get(shm); ABTS_INT_EQUAL(tc, SHARED_SIZE, retsize); - rv = apr_shm_destroy(shm); + rv = fspr_shm_destroy(shm); APR_ASSERT_SUCCESS(tc, "Error destroying shared memory block", rv); } static void test_shm_allocate(abts_case *tc, void *data) { - apr_status_t rv; - apr_shm_t *shm = NULL; + fspr_status_t rv; + fspr_shm_t *shm = NULL; - rv = apr_shm_create(&shm, SHARED_SIZE, NULL, p); + rv = fspr_shm_create(&shm, SHARED_SIZE, NULL, p); APR_ASSERT_SUCCESS(tc, "Error allocating shared memory block", rv); ABTS_PTR_NOTNULL(tc, shm); - boxes = apr_shm_baseaddr_get(shm); + boxes = fspr_shm_baseaddr_get(shm); ABTS_PTR_NOTNULL(tc, boxes); - rv = apr_shm_destroy(shm); + rv = fspr_shm_destroy(shm); APR_ASSERT_SUCCESS(tc, "Error destroying shared memory block", rv); } #if APR_HAS_FORK static void test_anon(abts_case *tc, void *data) { - apr_proc_t proc; - apr_status_t rv; - apr_shm_t *shm; - apr_size_t retsize; + fspr_proc_t proc; + fspr_status_t rv; + fspr_shm_t *shm; + fspr_size_t retsize; int cnt, i; int recvd; - rv = apr_shm_create(&shm, SHARED_SIZE, NULL, p); + rv = fspr_shm_create(&shm, SHARED_SIZE, NULL, p); APR_ASSERT_SUCCESS(tc, "Error allocating shared memory block", rv); ABTS_PTR_NOTNULL(tc, shm); - retsize = apr_shm_size_get(shm); + retsize = fspr_shm_size_get(shm); ABTS_INT_EQUAL(tc, SHARED_SIZE, retsize); - boxes = apr_shm_baseaddr_get(shm); + boxes = fspr_shm_baseaddr_get(shm); ABTS_PTR_NOTNULL(tc, boxes); - rv = apr_proc_fork(&proc, p); + rv = fspr_proc_fork(&proc, p); if (rv == APR_INCHILD) { /* child */ int num = msgwait(5, 0, N_BOXES); /* exit with the number of messages received so that the parent @@ -141,69 +141,69 @@ static void test_anon(abts_case *tc, void *data) i += N_BOXES; /* start over at the top */ } msgput(i, MSG); - apr_sleep(apr_time_make(0, 10000)); + fspr_sleep(fspr_time_make(0, 10000)); } } else { - ABTS_FAIL(tc, "apr_proc_fork failed"); + ABTS_FAIL(tc, "fspr_proc_fork failed"); } /* wait for the child */ - rv = apr_proc_wait(&proc, &recvd, NULL, APR_WAIT); + rv = fspr_proc_wait(&proc, &recvd, NULL, APR_WAIT); ABTS_INT_EQUAL(tc, N_MESSAGES, recvd); - rv = apr_shm_destroy(shm); + rv = fspr_shm_destroy(shm); APR_ASSERT_SUCCESS(tc, "Error destroying shared memory block", rv); } #endif static void test_named(abts_case *tc, void *data) { - apr_status_t rv; - apr_shm_t *shm = NULL; - apr_size_t retsize; - apr_proc_t pidproducer, pidconsumer; - apr_procattr_t *attr1 = NULL, *attr2 = NULL; + fspr_status_t rv; + fspr_shm_t *shm = NULL; + fspr_size_t retsize; + fspr_proc_t pidproducer, pidconsumer; + fspr_procattr_t *attr1 = NULL, *attr2 = NULL; int sent, received; - apr_exit_why_e why; + fspr_exit_why_e why; const char *args[4]; - apr_shm_remove(SHARED_FILENAME, p); + fspr_shm_remove(SHARED_FILENAME, p); - rv = apr_shm_create(&shm, SHARED_SIZE, SHARED_FILENAME, p); + rv = fspr_shm_create(&shm, SHARED_SIZE, SHARED_FILENAME, p); APR_ASSERT_SUCCESS(tc, "Error allocating shared memory block", rv); if (rv != APR_SUCCESS) { return; } ABTS_PTR_NOTNULL(tc, shm); - retsize = apr_shm_size_get(shm); + retsize = fspr_shm_size_get(shm); ABTS_INT_EQUAL(tc, SHARED_SIZE, retsize); - boxes = apr_shm_baseaddr_get(shm); + boxes = fspr_shm_baseaddr_get(shm); ABTS_PTR_NOTNULL(tc, boxes); - rv = apr_procattr_create(&attr1, p); + rv = fspr_procattr_create(&attr1, p); ABTS_PTR_NOTNULL(tc, attr1); APR_ASSERT_SUCCESS(tc, "Couldn't create attr1", rv); - args[0] = apr_pstrdup(p, "testshmproducer" EXTENSION); + args[0] = fspr_pstrdup(p, "testshmproducer" EXTENSION); args[1] = NULL; - rv = apr_proc_create(&pidproducer, "./testshmproducer" EXTENSION, args, + rv = fspr_proc_create(&pidproducer, "./testshmproducer" EXTENSION, args, NULL, attr1, p); APR_ASSERT_SUCCESS(tc, "Couldn't launch producer", rv); - rv = apr_procattr_create(&attr2, p); + rv = fspr_procattr_create(&attr2, p); ABTS_PTR_NOTNULL(tc, attr2); APR_ASSERT_SUCCESS(tc, "Couldn't create attr2", rv); - args[0] = apr_pstrdup(p, "testshmconsumer" EXTENSION); - rv = apr_proc_create(&pidconsumer, "./testshmconsumer" EXTENSION, args, + args[0] = fspr_pstrdup(p, "testshmconsumer" EXTENSION); + rv = fspr_proc_create(&pidconsumer, "./testshmconsumer" EXTENSION, args, NULL, attr2, p); APR_ASSERT_SUCCESS(tc, "Couldn't launch consumer", rv); - rv = apr_proc_wait(&pidconsumer, &received, &why, APR_WAIT); + rv = fspr_proc_wait(&pidconsumer, &received, &why, APR_WAIT); ABTS_INT_EQUAL(tc, APR_CHILD_DONE, rv); ABTS_INT_EQUAL(tc, APR_PROC_EXIT, why); - rv = apr_proc_wait(&pidproducer, &sent, &why, APR_WAIT); + rv = fspr_proc_wait(&pidproducer, &sent, &why, APR_WAIT); ABTS_INT_EQUAL(tc, APR_CHILD_DONE, rv); ABTS_INT_EQUAL(tc, APR_PROC_EXIT, why); @@ -212,7 +212,7 @@ static void test_named(abts_case *tc, void *data) * without having to cleanup manually. */ APR_ASSERT_SUCCESS(tc, "Error destroying shared memory", - apr_shm_destroy(shm)); + fspr_shm_destroy(shm)); ABTS_INT_EQUAL(tc, sent, received); @@ -220,32 +220,32 @@ static void test_named(abts_case *tc, void *data) static void test_named_remove(abts_case *tc, void *data) { - apr_status_t rv; - apr_shm_t *shm; + fspr_status_t rv; + fspr_shm_t *shm; - apr_shm_remove(SHARED_FILENAME, p); + fspr_shm_remove(SHARED_FILENAME, p); - rv = apr_shm_create(&shm, SHARED_SIZE, SHARED_FILENAME, p); + rv = fspr_shm_create(&shm, SHARED_SIZE, SHARED_FILENAME, p); APR_ASSERT_SUCCESS(tc, "Error allocating shared memory block", rv); if (rv != APR_SUCCESS) { return; } ABTS_PTR_NOTNULL(tc, shm); - rv = apr_shm_remove(SHARED_FILENAME, p); + rv = fspr_shm_remove(SHARED_FILENAME, p); APR_ASSERT_SUCCESS(tc, "Error removing shared memory block", rv); if (rv != APR_SUCCESS) { return ; } - rv = apr_shm_create(&shm, SHARED_SIZE, SHARED_FILENAME, p); + rv = fspr_shm_create(&shm, SHARED_SIZE, SHARED_FILENAME, p); APR_ASSERT_SUCCESS(tc, "Error allocating shared memory block", rv); if (rv != APR_SUCCESS) { return; } ABTS_PTR_NOTNULL(tc, shm); - rv = apr_shm_destroy(shm); + rv = fspr_shm_destroy(shm); APR_ASSERT_SUCCESS(tc, "Error destroying shared memory block", rv); } diff --git a/libs/apr/test/testshm.h b/libs/apr/test/testshm.h index 5b24a9d427..efcfc062de 100644 --- a/libs/apr/test/testshm.h +++ b/libs/apr/test/testshm.h @@ -24,7 +24,7 @@ typedef struct mbox { mbox *boxes; #define N_BOXES 10 -#define SHARED_SIZE (apr_size_t)(N_BOXES * sizeof(mbox)) +#define SHARED_SIZE (fspr_size_t)(N_BOXES * sizeof(mbox)) #define SHARED_FILENAME "data/apr.testshm.shm" #define N_MESSAGES 100 #define MSG "Sending a message" diff --git a/libs/apr/test/testshmconsumer.c b/libs/apr/test/testshmconsumer.c index 6a2a3c30d3..5e67e837b9 100644 --- a/libs/apr/test/testshmconsumer.c +++ b/libs/apr/test/testshmconsumer.c @@ -14,14 +14,14 @@ * limitations under the License. */ -#include "apr_shm.h" -#include "apr_errno.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_strings.h" -#include "apr_time.h" +#include "fspr_shm.h" +#include "fspr_errno.h" +#include "fspr_general.h" +#include "fspr_lib.h" +#include "fspr_strings.h" +#include "fspr_time.h" #include "testshm.h" -#include "apr.h" +#include "fspr.h" #if APR_HAVE_STDLIB_H #include @@ -34,9 +34,9 @@ static int msgwait(int sleep_sec, int first_box, int last_box) { int i; int recvd = 0; - apr_time_t start = apr_time_now(); - apr_interval_time_t sleep_duration = apr_time_from_sec(sleep_sec); - while (apr_time_now() - start < sleep_duration) { + fspr_time_t start = fspr_time_now(); + fspr_interval_time_t sleep_duration = fspr_time_from_sec(sleep_sec); + while (fspr_time_now() - start < sleep_duration) { for (i = first_box; i < last_box; i++) { if (boxes[i].msgavail && !strcmp(boxes[i].msg, MSG)) { recvd++; @@ -44,35 +44,35 @@ static int msgwait(int sleep_sec, int first_box, int last_box) memset(boxes[i].msg, 0, 1024); } } - apr_sleep(apr_time_from_sec(1)); + fspr_sleep(fspr_time_from_sec(1)); } return recvd; } int main(void) { - apr_status_t rv; - apr_pool_t *pool; - apr_shm_t *shm; + fspr_status_t rv; + fspr_pool_t *pool; + fspr_shm_t *shm; int recvd; - apr_initialize(); + fspr_initialize(); - if (apr_pool_create(&pool, NULL) != APR_SUCCESS) { + if (fspr_pool_create(&pool, NULL) != APR_SUCCESS) { exit(-1); } - rv = apr_shm_attach(&shm, SHARED_FILENAME, pool); + rv = fspr_shm_attach(&shm, SHARED_FILENAME, pool); if (rv != APR_SUCCESS) { exit(-2); } - boxes = apr_shm_baseaddr_get(shm); + boxes = fspr_shm_baseaddr_get(shm); /* consume messages on all of the boxes */ recvd = msgwait(30, 0, N_BOXES); /* wait for 30 seconds for messages */ - rv = apr_shm_detach(shm); + rv = fspr_shm_detach(shm); if (rv != APR_SUCCESS) { exit(-3); } diff --git a/libs/apr/test/testshmproducer.c b/libs/apr/test/testshmproducer.c index 58eb94fcd3..70073db7bd 100644 --- a/libs/apr/test/testshmproducer.c +++ b/libs/apr/test/testshmproducer.c @@ -14,14 +14,14 @@ * limitations under the License. */ -#include "apr_shm.h" -#include "apr_errno.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_strings.h" -#include "apr_time.h" +#include "fspr_shm.h" +#include "fspr_errno.h" +#include "fspr_general.h" +#include "fspr_lib.h" +#include "fspr_strings.h" +#include "fspr_time.h" #include "testshm.h" -#include "apr.h" +#include "fspr.h" #if APR_HAVE_STDLIB_H #include @@ -31,30 +31,30 @@ #if APR_HAS_SHARED_MEMORY static void msgput(int boxnum, char *msg) { - apr_cpystrn(boxes[boxnum].msg, msg, strlen(msg) + 1); + fspr_cpystrn(boxes[boxnum].msg, msg, strlen(msg) + 1); boxes[boxnum].msgavail = 1; } int main(void) { - apr_status_t rv; - apr_pool_t *pool; - apr_shm_t *shm; + fspr_status_t rv; + fspr_pool_t *pool; + fspr_shm_t *shm; int i; int sent = 0; - apr_initialize(); + fspr_initialize(); - if (apr_pool_create(&pool, NULL) != APR_SUCCESS) { + if (fspr_pool_create(&pool, NULL) != APR_SUCCESS) { exit(-1); } - rv = apr_shm_attach(&shm, SHARED_FILENAME, pool); + rv = fspr_shm_attach(&shm, SHARED_FILENAME, pool); if (rv != APR_SUCCESS) { exit(-2); } - boxes = apr_shm_baseaddr_get(shm); + boxes = fspr_shm_baseaddr_get(shm); /* produce messages on all of the boxes, in descending order, * Yes, we could just return N_BOXES, but I want to have a double-check @@ -64,10 +64,10 @@ int main(void) */ for (i = N_BOXES - 1, sent = 0; i >= 0; i--, sent++) { msgput(i, MSG); - apr_sleep(apr_time_from_sec(1)); + fspr_sleep(fspr_time_from_sec(1)); } - rv = apr_shm_detach(shm); + rv = fspr_shm_detach(shm); if (rv != APR_SUCCESS) { exit(-3); } diff --git a/libs/apr/test/testsleep.c b/libs/apr/test/testsleep.c index d50cc1b49d..6112a85907 100644 --- a/libs/apr/test/testsleep.c +++ b/libs/apr/test/testsleep.c @@ -15,10 +15,10 @@ */ #include "time.h" -#include "apr_thread_proc.h" -#include "apr_errno.h" -#include "apr_general.h" -#include "apr_lib.h" +#include "fspr_thread_proc.h" +#include "fspr_errno.h" +#include "fspr_general.h" +#include "fspr_lib.h" #include #include #include @@ -32,7 +32,7 @@ static void sleep_one(abts_case *tc, void *data) time_t posttime; time_t timediff; - apr_sleep(apr_time_from_sec(SLEEP_INTERVAL)); + fspr_sleep(fspr_time_from_sec(SLEEP_INTERVAL)); posttime = time(NULL); /* normalize the timediff. We should have slept for SLEEP_INTERVAL, so diff --git a/libs/apr/test/testsock.c b/libs/apr/test/testsock.c index 7c1759e924..f731630dc3 100644 --- a/libs/apr/test/testsock.c +++ b/libs/apr/test/testsock.c @@ -16,45 +16,45 @@ #include "testutil.h" #include "testsock.h" -#include "apr_thread_proc.h" -#include "apr_network_io.h" -#include "apr_errno.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_strings.h" -#include "apr_poll.h" +#include "fspr_thread_proc.h" +#include "fspr_network_io.h" +#include "fspr_errno.h" +#include "fspr_general.h" +#include "fspr_lib.h" +#include "fspr_strings.h" +#include "fspr_poll.h" -static void launch_child(abts_case *tc, apr_proc_t *proc, const char *arg1, apr_pool_t *p) +static void launch_child(abts_case *tc, fspr_proc_t *proc, const char *arg1, fspr_pool_t *p) { - apr_procattr_t *procattr; + fspr_procattr_t *procattr; const char *args[3]; - apr_status_t rv; + fspr_status_t rv; - rv = apr_procattr_create(&procattr, p); + rv = fspr_procattr_create(&procattr, p); APR_ASSERT_SUCCESS(tc, "Couldn't create procattr", rv); - rv = apr_procattr_io_set(procattr, APR_NO_PIPE, APR_NO_PIPE, + rv = fspr_procattr_io_set(procattr, APR_NO_PIPE, APR_NO_PIPE, APR_NO_PIPE); APR_ASSERT_SUCCESS(tc, "Couldn't set io in procattr", rv); - rv = apr_procattr_error_check_set(procattr, 1); + rv = fspr_procattr_error_check_set(procattr, 1); APR_ASSERT_SUCCESS(tc, "Couldn't set error check in procattr", rv); args[0] = "sockchild" EXTENSION; args[1] = arg1; args[2] = NULL; - rv = apr_proc_create(proc, "./sockchild" EXTENSION, args, NULL, + rv = fspr_proc_create(proc, "./sockchild" EXTENSION, args, NULL, procattr, p); APR_ASSERT_SUCCESS(tc, "Couldn't launch program", rv); } -static int wait_child(abts_case *tc, apr_proc_t *proc) +static int wait_child(abts_case *tc, fspr_proc_t *proc) { int exitcode; - apr_exit_why_e why; + fspr_exit_why_e why; ABTS_ASSERT(tc, "Error waiting for child process", - apr_proc_wait(proc, &exitcode, &why, APR_WAIT) == APR_CHILD_DONE); + fspr_proc_wait(proc, &exitcode, &why, APR_WAIT) == APR_CHILD_DONE); ABTS_ASSERT(tc, "child terminated normally", why == APR_PROC_EXIT); return exitcode; @@ -62,37 +62,37 @@ static int wait_child(abts_case *tc, apr_proc_t *proc) static void test_addr_info(abts_case *tc, void *data) { - apr_status_t rv; - apr_sockaddr_t *sa; + fspr_status_t rv; + fspr_sockaddr_t *sa; - rv = apr_sockaddr_info_get(&sa, NULL, APR_UNSPEC, 80, 0, p); + rv = fspr_sockaddr_info_get(&sa, NULL, APR_UNSPEC, 80, 0, p); APR_ASSERT_SUCCESS(tc, "Problem generating sockaddr", rv); - rv = apr_sockaddr_info_get(&sa, "127.0.0.1", APR_UNSPEC, 80, 0, p); + rv = fspr_sockaddr_info_get(&sa, "127.0.0.1", APR_UNSPEC, 80, 0, p); APR_ASSERT_SUCCESS(tc, "Problem generating sockaddr", rv); ABTS_STR_EQUAL(tc, "127.0.0.1", sa->hostname); } -static apr_socket_t *setup_socket(abts_case *tc) +static fspr_socket_t *setup_socket(abts_case *tc) { - apr_status_t rv; - apr_sockaddr_t *sa; - apr_socket_t *sock; + fspr_status_t rv; + fspr_sockaddr_t *sa; + fspr_socket_t *sock; - rv = apr_sockaddr_info_get(&sa, "127.0.0.1", APR_INET, 8021, 0, p); + rv = fspr_sockaddr_info_get(&sa, "127.0.0.1", APR_INET, 8021, 0, p); APR_ASSERT_SUCCESS(tc, "Problem generating sockaddr", rv); - rv = apr_socket_create(&sock, sa->family, SOCK_STREAM, APR_PROTO_TCP, p); + rv = fspr_socket_create(&sock, sa->family, SOCK_STREAM, APR_PROTO_TCP, p); APR_ASSERT_SUCCESS(tc, "Problem creating socket", rv); - rv = apr_socket_opt_set(sock, APR_SO_REUSEADDR, 1); + rv = fspr_socket_opt_set(sock, APR_SO_REUSEADDR, 1); APR_ASSERT_SUCCESS(tc, "Could not set REUSEADDR on socket", rv); - rv = apr_socket_bind(sock, sa); + rv = fspr_socket_bind(sock, sa); APR_ASSERT_SUCCESS(tc, "Problem binding to port", rv); if (rv) return NULL; - rv = apr_socket_listen(sock, 5); + rv = fspr_socket_listen(sock, 5); APR_ASSERT_SUCCESS(tc, "Problem listening on socket", rv); return sock; @@ -100,55 +100,55 @@ static apr_socket_t *setup_socket(abts_case *tc) static void test_create_bind_listen(abts_case *tc, void *data) { - apr_status_t rv; - apr_socket_t *sock = setup_socket(tc); + fspr_status_t rv; + fspr_socket_t *sock = setup_socket(tc); if (!sock) return; - rv = apr_socket_close(sock); + rv = fspr_socket_close(sock); APR_ASSERT_SUCCESS(tc, "Problem closing socket", rv); } static void test_send(abts_case *tc, void *data) { - apr_status_t rv; - apr_socket_t *sock; - apr_socket_t *sock2; - apr_proc_t proc; + fspr_status_t rv; + fspr_socket_t *sock; + fspr_socket_t *sock2; + fspr_proc_t proc; int protocol; - apr_size_t length; + fspr_size_t length; sock = setup_socket(tc); if (!sock) return; launch_child(tc, &proc, "read", p); - rv = apr_socket_accept(&sock2, sock, p); + rv = fspr_socket_accept(&sock2, sock, p); APR_ASSERT_SUCCESS(tc, "Problem with receiving connection", rv); - apr_socket_protocol_get(sock2, &protocol); + fspr_socket_protocol_get(sock2, &protocol); ABTS_INT_EQUAL(tc, APR_PROTO_TCP, protocol); length = strlen(DATASTR); - apr_socket_send(sock2, DATASTR, &length); + fspr_socket_send(sock2, DATASTR, &length); /* Make sure that the client received the data we sent */ ABTS_INT_EQUAL(tc, strlen(DATASTR), wait_child(tc, &proc)); - rv = apr_socket_close(sock2); + rv = fspr_socket_close(sock2); APR_ASSERT_SUCCESS(tc, "Problem closing connected socket", rv); - rv = apr_socket_close(sock); + rv = fspr_socket_close(sock); APR_ASSERT_SUCCESS(tc, "Problem closing socket", rv); } static void test_recv(abts_case *tc, void *data) { - apr_status_t rv; - apr_socket_t *sock; - apr_socket_t *sock2; - apr_proc_t proc; + fspr_status_t rv; + fspr_socket_t *sock; + fspr_socket_t *sock2; + fspr_proc_t proc; int protocol; - apr_size_t length = STRLEN; + fspr_size_t length = STRLEN; char datastr[STRLEN]; sock = setup_socket(tc); @@ -156,31 +156,31 @@ static void test_recv(abts_case *tc, void *data) launch_child(tc, &proc, "write", p); - rv = apr_socket_accept(&sock2, sock, p); + rv = fspr_socket_accept(&sock2, sock, p); APR_ASSERT_SUCCESS(tc, "Problem with receiving connection", rv); - apr_socket_protocol_get(sock2, &protocol); + fspr_socket_protocol_get(sock2, &protocol); ABTS_INT_EQUAL(tc, APR_PROTO_TCP, protocol); memset(datastr, 0, STRLEN); - apr_socket_recv(sock2, datastr, &length); + fspr_socket_recv(sock2, datastr, &length); /* Make sure that the server received the data we sent */ ABTS_STR_EQUAL(tc, DATASTR, datastr); ABTS_INT_EQUAL(tc, strlen(datastr), wait_child(tc, &proc)); - rv = apr_socket_close(sock2); + rv = fspr_socket_close(sock2); APR_ASSERT_SUCCESS(tc, "Problem closing connected socket", rv); - rv = apr_socket_close(sock); + rv = fspr_socket_close(sock); APR_ASSERT_SUCCESS(tc, "Problem closing socket", rv); } static void test_timeout(abts_case *tc, void *data) { - apr_status_t rv; - apr_socket_t *sock; - apr_socket_t *sock2; - apr_proc_t proc; + fspr_status_t rv; + fspr_socket_t *sock; + fspr_socket_t *sock2; + fspr_proc_t proc; int protocol; int exit; @@ -189,10 +189,10 @@ static void test_timeout(abts_case *tc, void *data) launch_child(tc, &proc, "read", p); - rv = apr_socket_accept(&sock2, sock, p); + rv = fspr_socket_accept(&sock2, sock, p); APR_ASSERT_SUCCESS(tc, "Problem with receiving connection", rv); - apr_socket_protocol_get(sock2, &protocol); + fspr_socket_protocol_get(sock2, &protocol); ABTS_INT_EQUAL(tc, APR_PROTO_TCP, protocol); exit = wait_child(tc, &proc); @@ -201,57 +201,57 @@ static void test_timeout(abts_case *tc, void *data) /* We didn't write any data, so make sure the child program returns * an error. */ - rv = apr_socket_close(sock2); + rv = fspr_socket_close(sock2); APR_ASSERT_SUCCESS(tc, "Problem closing connected socket", rv); - rv = apr_socket_close(sock); + rv = fspr_socket_close(sock); APR_ASSERT_SUCCESS(tc, "Problem closing socket", rv); } static void test_get_addr(abts_case *tc, void *data) { - apr_status_t rv; - apr_socket_t *ld, *sd, *cd; - apr_sockaddr_t *sa, *ca; + fspr_status_t rv; + fspr_socket_t *ld, *sd, *cd; + fspr_sockaddr_t *sa, *ca; char a[128], b[128]; ld = setup_socket(tc); APR_ASSERT_SUCCESS(tc, "get local address of bound socket", - apr_socket_addr_get(&sa, APR_LOCAL, ld)); + fspr_socket_addr_get(&sa, APR_LOCAL, ld)); - rv = apr_socket_create(&cd, sa->family, SOCK_STREAM, + rv = fspr_socket_create(&cd, sa->family, SOCK_STREAM, APR_PROTO_TCP, p); APR_ASSERT_SUCCESS(tc, "create client socket", rv); APR_ASSERT_SUCCESS(tc, "enable non-block mode", - apr_socket_opt_set(cd, APR_SO_NONBLOCK, 1)); + fspr_socket_opt_set(cd, APR_SO_NONBLOCK, 1)); /* It is valid for a connect() on a socket with NONBLOCK set to * succeed (if the connection can be established synchronously), * but if it does, this test cannot proceed. */ - rv = apr_socket_connect(cd, sa); + rv = fspr_socket_connect(cd, sa); if (rv == APR_SUCCESS) { - apr_socket_close(ld); - apr_socket_close(cd); + fspr_socket_close(ld); + fspr_socket_close(cd); ABTS_NOT_IMPL(tc, "Cannot test if connect completes " "synchronously"); return; } if (!APR_STATUS_IS_EINPROGRESS(rv)) { - apr_socket_close(ld); - apr_socket_close(cd); + fspr_socket_close(ld); + fspr_socket_close(cd); APR_ASSERT_SUCCESS(tc, "connect to listener", rv); return; } APR_ASSERT_SUCCESS(tc, "accept connection", - apr_socket_accept(&sd, ld, p)); + fspr_socket_accept(&sd, ld, p)); { /* wait for writability */ - apr_pollfd_t pfd; + fspr_pollfd_t pfd; int n; pfd.p = p; @@ -261,24 +261,24 @@ static void test_get_addr(abts_case *tc, void *data) pfd.client_data = NULL; APR_ASSERT_SUCCESS(tc, "poll for connect completion", - apr_poll(&pfd, 1, &n, 5 * APR_USEC_PER_SEC)); + fspr_poll(&pfd, 1, &n, 5 * APR_USEC_PER_SEC)); } APR_ASSERT_SUCCESS(tc, "get local address of server socket", - apr_socket_addr_get(&sa, APR_LOCAL, sd)); + fspr_socket_addr_get(&sa, APR_LOCAL, sd)); APR_ASSERT_SUCCESS(tc, "get remote address of client socket", - apr_socket_addr_get(&ca, APR_REMOTE, cd)); + fspr_socket_addr_get(&ca, APR_REMOTE, cd)); - apr_snprintf(a, sizeof(a), "%pI", sa); - apr_snprintf(b, sizeof(b), "%pI", ca); + fspr_snprintf(a, sizeof(a), "%pI", sa); + fspr_snprintf(b, sizeof(b), "%pI", ca); ABTS_STR_EQUAL(tc, a, b); - apr_socket_close(cd); - apr_socket_close(sd); - apr_socket_close(ld); + fspr_socket_close(cd); + fspr_socket_close(sd); + fspr_socket_close(ld); } abts_suite *testsock(abts_suite *suite) diff --git a/libs/apr/test/testsockets.c b/libs/apr/test/testsockets.c index 6328af8d9b..9337886ab7 100644 --- a/libs/apr/test/testsockets.c +++ b/libs/apr/test/testsockets.c @@ -14,46 +14,46 @@ * limitations under the License. */ -#include "apr_network_io.h" -#include "apr_errno.h" -#include "apr_general.h" -#include "apr_lib.h" +#include "fspr_network_io.h" +#include "fspr_errno.h" +#include "fspr_general.h" +#include "fspr_lib.h" #include "testutil.h" #define STRLEN 21 static void tcp_socket(abts_case *tc, void *data) { - apr_status_t rv; - apr_socket_t *sock = NULL; + fspr_status_t rv; + fspr_socket_t *sock = NULL; int type; - rv = apr_socket_create(&sock, APR_INET, SOCK_STREAM, 0, p); + rv = fspr_socket_create(&sock, APR_INET, SOCK_STREAM, 0, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_PTR_NOTNULL(tc, sock); - rv = apr_socket_type_get(sock, &type); + rv = fspr_socket_type_get(sock, &type); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, SOCK_STREAM, type); - apr_socket_close(sock); + fspr_socket_close(sock); } static void udp_socket(abts_case *tc, void *data) { - apr_status_t rv; - apr_socket_t *sock = NULL; + fspr_status_t rv; + fspr_socket_t *sock = NULL; int type; - rv = apr_socket_create(&sock, APR_INET, SOCK_DGRAM, 0, p); + rv = fspr_socket_create(&sock, APR_INET, SOCK_DGRAM, 0, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_PTR_NOTNULL(tc, sock); - rv = apr_socket_type_get(sock, &type); + rv = fspr_socket_type_get(sock, &type); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, SOCK_DGRAM, type); - apr_socket_close(sock); + fspr_socket_close(sock); } /* On recent Linux systems, whilst IPv6 is always supported by glibc, @@ -68,17 +68,17 @@ static void udp_socket(abts_case *tc, void *data) static void tcp6_socket(abts_case *tc, void *data) { #if APR_HAVE_IPV6 - apr_status_t rv; - apr_socket_t *sock = NULL; + fspr_status_t rv; + fspr_socket_t *sock = NULL; - rv = apr_socket_create(&sock, APR_INET6, SOCK_STREAM, 0, p); + rv = fspr_socket_create(&sock, APR_INET6, SOCK_STREAM, 0, p); if (V6_NOT_ENABLED(rv)) { ABTS_NOT_IMPL(tc, "IPv6 not enabled"); return; } ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_PTR_NOTNULL(tc, sock); - apr_socket_close(sock); + fspr_socket_close(sock); #else ABTS_NOT_IMPL(tc, "IPv6"); #endif @@ -87,17 +87,17 @@ static void tcp6_socket(abts_case *tc, void *data) static void udp6_socket(abts_case *tc, void *data) { #if APR_HAVE_IPV6 - apr_status_t rv; - apr_socket_t *sock = NULL; + fspr_status_t rv; + fspr_socket_t *sock = NULL; - rv = apr_socket_create(&sock, APR_INET6, SOCK_DGRAM, 0, p); + rv = fspr_socket_create(&sock, APR_INET6, SOCK_DGRAM, 0, p); if (V6_NOT_ENABLED(rv)) { ABTS_NOT_IMPL(tc, "IPv6 not enabled"); return; } ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_PTR_NOTNULL(tc, sock); - apr_socket_close(sock); + fspr_socket_close(sock); #else ABTS_NOT_IMPL(tc, "IPv6"); #endif @@ -105,91 +105,91 @@ static void udp6_socket(abts_case *tc, void *data) static void sendto_receivefrom(abts_case *tc, void *data) { - apr_status_t rv; - apr_socket_t *sock = NULL; - apr_socket_t *sock2 = NULL; + fspr_status_t rv; + fspr_socket_t *sock = NULL; + fspr_socket_t *sock2 = NULL; char sendbuf[STRLEN] = "APR_INET, SOCK_DGRAM"; char recvbuf[80]; char *ip_addr; - apr_port_t fromport; - apr_sockaddr_t *from; - apr_sockaddr_t *to; - apr_size_t len = 30; + fspr_port_t fromport; + fspr_sockaddr_t *from; + fspr_sockaddr_t *to; + fspr_size_t len = 30; int family; const char *addr; #if APR_HAVE_IPV6 family = APR_INET6; addr = "::1"; - rv = apr_socket_create(&sock, family, SOCK_DGRAM, 0, p); + rv = fspr_socket_create(&sock, family, SOCK_DGRAM, 0, p); if (V6_NOT_ENABLED(rv)) { #endif family = APR_INET; addr = "127.0.0.1"; - rv = apr_socket_create(&sock, family, SOCK_DGRAM, 0, p); + rv = fspr_socket_create(&sock, family, SOCK_DGRAM, 0, p); #if APR_HAVE_IPV6 } #endif ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_socket_create(&sock2, family, SOCK_DGRAM, 0, p); + rv = fspr_socket_create(&sock2, family, SOCK_DGRAM, 0, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_sockaddr_info_get(&to, addr, APR_UNSPEC, 7772, 0, p); + rv = fspr_sockaddr_info_get(&to, addr, APR_UNSPEC, 7772, 0, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_sockaddr_info_get(&from, addr, APR_UNSPEC, 7771, 0, p); + rv = fspr_sockaddr_info_get(&from, addr, APR_UNSPEC, 7771, 0, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_socket_opt_set(sock, APR_SO_REUSEADDR, 1); + rv = fspr_socket_opt_set(sock, APR_SO_REUSEADDR, 1); APR_ASSERT_SUCCESS(tc, "Could not set REUSEADDR on socket", rv); - rv = apr_socket_opt_set(sock2, APR_SO_REUSEADDR, 1); + rv = fspr_socket_opt_set(sock2, APR_SO_REUSEADDR, 1); APR_ASSERT_SUCCESS(tc, "Could not set REUSEADDR on socket2", rv); - rv = apr_socket_bind(sock, to); + rv = fspr_socket_bind(sock, to); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_socket_bind(sock2, from); + rv = fspr_socket_bind(sock2, from); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); len = STRLEN; - rv = apr_socket_sendto(sock2, to, 0, sendbuf, &len); + rv = fspr_socket_sendto(sock2, to, 0, sendbuf, &len); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, STRLEN, len); len = 80; - rv = apr_socket_recvfrom(from, sock, 0, recvbuf, &len); + rv = fspr_socket_recvfrom(from, sock, 0, recvbuf, &len); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, STRLEN, len); ABTS_STR_EQUAL(tc, "APR_INET, SOCK_DGRAM", recvbuf); - apr_sockaddr_ip_get(&ip_addr, from); + fspr_sockaddr_ip_get(&ip_addr, from); fromport = from->port; ABTS_STR_EQUAL(tc, addr, ip_addr); ABTS_INT_EQUAL(tc, 7771, fromport); - apr_socket_close(sock); - apr_socket_close(sock2); + fspr_socket_close(sock); + fspr_socket_close(sock2); } static void socket_userdata(abts_case *tc, void *data) { - apr_socket_t *sock1, *sock2; - apr_status_t rv; + fspr_socket_t *sock1, *sock2; + fspr_status_t rv; void *user; const char *key = "GENERICKEY"; - rv = apr_socket_create(&sock1, AF_INET, SOCK_STREAM, 0, p); + rv = fspr_socket_create(&sock1, AF_INET, SOCK_STREAM, 0, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_socket_create(&sock2, AF_INET, SOCK_STREAM, 0, p); + rv = fspr_socket_create(&sock2, AF_INET, SOCK_STREAM, 0, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_socket_data_set(sock1, "SOCK1", key, NULL); + rv = fspr_socket_data_set(sock1, "SOCK1", key, NULL); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_socket_data_set(sock2, "SOCK2", key, NULL); + rv = fspr_socket_data_set(sock2, "SOCK2", key, NULL); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_socket_data_get(&user, key, sock1); + rv = fspr_socket_data_get(&user, key, sock1); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_STR_EQUAL(tc, "SOCK1", user); - rv = apr_socket_data_get(&user, key, sock2); + rv = fspr_socket_data_get(&user, key, sock2); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_STR_EQUAL(tc, "SOCK2", user); } diff --git a/libs/apr/test/testsockopt.c b/libs/apr/test/testsockopt.c index 203e2c39ff..9328bfd340 100644 --- a/libs/apr/test/testsockopt.c +++ b/libs/apr/test/testsockopt.c @@ -14,45 +14,45 @@ * limitations under the License. */ -#include "apr_network_io.h" -#include "apr_errno.h" -#include "apr_general.h" -#include "apr_lib.h" +#include "fspr_network_io.h" +#include "fspr_errno.h" +#include "fspr_general.h" +#include "fspr_lib.h" #include "testutil.h" -static apr_socket_t *sock = NULL; +static fspr_socket_t *sock = NULL; static void create_socket(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; - rv = apr_socket_create(&sock, APR_INET, SOCK_STREAM, 0, p); + rv = fspr_socket_create(&sock, APR_INET, SOCK_STREAM, 0, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_PTR_NOTNULL(tc, sock); } static void set_keepalive(abts_case *tc, void *data) { - apr_status_t rv; - apr_int32_t ck; + fspr_status_t rv; + fspr_int32_t ck; - rv = apr_socket_opt_set(sock, APR_SO_KEEPALIVE, 1); + rv = fspr_socket_opt_set(sock, APR_SO_KEEPALIVE, 1); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_socket_opt_get(sock, APR_SO_KEEPALIVE, &ck); + rv = fspr_socket_opt_get(sock, APR_SO_KEEPALIVE, &ck); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, 1, ck); } static void set_debug(abts_case *tc, void *data) { - apr_status_t rv1, rv2; - apr_int32_t ck; + fspr_status_t rv1, rv2; + fspr_int32_t ck; /* On some platforms APR_SO_DEBUG can only be set as root; just test * for get/set consistency of this option. */ - rv1 = apr_socket_opt_set(sock, APR_SO_DEBUG, 1); - rv2 = apr_socket_opt_get(sock, APR_SO_DEBUG, &ck); + rv1 = fspr_socket_opt_set(sock, APR_SO_DEBUG, 1); + rv2 = fspr_socket_opt_get(sock, APR_SO_DEBUG, &ck); APR_ASSERT_SUCCESS(tc, "get SO_DEBUG option", rv2); if (rv1 == APR_SUCCESS) { ABTS_INT_EQUAL(tc, 1, ck); @@ -63,17 +63,17 @@ static void set_debug(abts_case *tc, void *data) static void remove_keepalive(abts_case *tc, void *data) { - apr_status_t rv; - apr_int32_t ck; + fspr_status_t rv; + fspr_int32_t ck; - rv = apr_socket_opt_get(sock, APR_SO_KEEPALIVE, &ck); + rv = fspr_socket_opt_get(sock, APR_SO_KEEPALIVE, &ck); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, 1, ck); - rv = apr_socket_opt_set(sock, APR_SO_KEEPALIVE, 0); + rv = fspr_socket_opt_set(sock, APR_SO_KEEPALIVE, 0); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_socket_opt_get(sock, APR_SO_KEEPALIVE, &ck); + rv = fspr_socket_opt_get(sock, APR_SO_KEEPALIVE, &ck); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, 0, ck); } @@ -83,33 +83,33 @@ static void corkable(abts_case *tc, void *data) #if !APR_HAVE_CORKABLE_TCP ABTS_NOT_IMPL(tc, "TCP isn't corkable"); #else - apr_status_t rv; - apr_int32_t ck; + fspr_status_t rv; + fspr_int32_t ck; - rv = apr_socket_opt_set(sock, APR_TCP_NODELAY, 1); + rv = fspr_socket_opt_set(sock, APR_TCP_NODELAY, 1); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_socket_opt_get(sock, APR_TCP_NODELAY, &ck); + rv = fspr_socket_opt_get(sock, APR_TCP_NODELAY, &ck); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, 1, ck); - rv = apr_socket_opt_set(sock, APR_TCP_NOPUSH, 1); + rv = fspr_socket_opt_set(sock, APR_TCP_NOPUSH, 1); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_socket_opt_get(sock, APR_TCP_NOPUSH, &ck); + rv = fspr_socket_opt_get(sock, APR_TCP_NOPUSH, &ck); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, 1, ck); - rv = apr_socket_opt_get(sock, APR_TCP_NODELAY, &ck); + rv = fspr_socket_opt_get(sock, APR_TCP_NODELAY, &ck); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); /* TCP_NODELAY is now in an unknown state; it may be zero if * TCP_NOPUSH and TCP_NODELAY are mutually exclusive on this * platform, e.g. Linux < 2.6. */ - rv = apr_socket_opt_set(sock, APR_TCP_NOPUSH, 0); + rv = fspr_socket_opt_set(sock, APR_TCP_NOPUSH, 0); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_socket_opt_get(sock, APR_TCP_NODELAY, &ck); + rv = fspr_socket_opt_get(sock, APR_TCP_NODELAY, &ck); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, 1, ck); #endif @@ -117,9 +117,9 @@ static void corkable(abts_case *tc, void *data) static void close_socket(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; - rv = apr_socket_close(sock); + rv = fspr_socket_close(sock); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); } diff --git a/libs/apr/test/teststr.c b/libs/apr/test/teststr.c index ec382c343a..4ed57dec4f 100644 --- a/libs/apr/test/teststr.c +++ b/libs/apr/test/teststr.c @@ -25,9 +25,9 @@ #include #endif -#include "apr_general.h" -#include "apr_strings.h" -#include "apr_errno.h" +#include "fspr_general.h" +#include "fspr_strings.h" +#include "fspr_errno.h" /* I haven't bothered to check for APR_ENOTIMPL here, AFAIK, all string * functions exist on all platforms. @@ -49,7 +49,7 @@ static void test_strtok(abts_case *tc, void *data) " \r\n\3\2\1" }, { - NULL, /* but who cares if apr_strtok() segfaults? */ + NULL, /* but who cares if fspr_strtok() segfaults? */ " \t" }, #if 0 /* don't do this... you deserve to segfault */ @@ -74,11 +74,11 @@ static void test_strtok(abts_case *tc, void *data) char *str1, *str2; char *state; - str1 = apr_pstrdup(p, cases[curtc].input); - str2 = apr_pstrdup(p, cases[curtc].input); + str1 = fspr_pstrdup(p, cases[curtc].input); + str2 = fspr_pstrdup(p, cases[curtc].input); do { - retval1 = apr_strtok(str1, cases[curtc].sep, &state); + retval1 = fspr_strtok(str1, cases[curtc].sep, &state); retval2 = strtok(str2, cases[curtc].sep); if (!retval1) { @@ -97,7 +97,7 @@ static void test_strtok(abts_case *tc, void *data) static void snprintf_noNULL(abts_case *tc, void *data) { char buff[100]; - char *testing = apr_palloc(p, 10); + char *testing = fspr_palloc(p, 10); testing[0] = 't'; testing[1] = 'e'; @@ -108,7 +108,7 @@ static void snprintf_noNULL(abts_case *tc, void *data) testing[6] = 'g'; /* If this test fails, we are going to seg fault. */ - apr_snprintf(buff, sizeof(buff), "%.*s", 7, testing); + fspr_snprintf(buff, sizeof(buff), "%.*s", 7, testing); ABTS_STR_NEQUAL(tc, buff, testing, 7); } @@ -116,7 +116,7 @@ static void snprintf_0NULL(abts_case *tc, void *data) { int rv; - rv = apr_snprintf(NULL, 0, "%sBAR", "FOO"); + rv = fspr_snprintf(NULL, 0, "%sBAR", "FOO"); ABTS_INT_EQUAL(tc, 6, rv); } @@ -125,7 +125,7 @@ static void snprintf_0nonNULL(abts_case *tc, void *data) int rv; char *buff = "testing"; - rv = apr_snprintf(buff, 0, "%sBAR", "FOO"); + rv = fspr_snprintf(buff, 0, "%sBAR", "FOO"); ABTS_INT_EQUAL(tc, 6, rv); ABTS_ASSERT(tc, "buff unmangled", strcmp(buff, "FOOBAR") != 0); } @@ -135,15 +135,15 @@ static void snprintf_underflow(abts_case *tc, void *data) char buf[20]; int rv; - rv = apr_snprintf(buf, sizeof buf, "%.2f", (double)0.0001); + rv = fspr_snprintf(buf, sizeof buf, "%.2f", (double)0.0001); ABTS_INT_EQUAL(tc, 4, rv); ABTS_STR_EQUAL(tc, "0.00", buf); - rv = apr_snprintf(buf, sizeof buf, "%.2f", (double)0.001); + rv = fspr_snprintf(buf, sizeof buf, "%.2f", (double)0.001); ABTS_INT_EQUAL(tc, 4, rv); ABTS_STR_EQUAL(tc, "0.00", buf); - rv = apr_snprintf(buf, sizeof buf, "%.2f", (double)0.01); + rv = fspr_snprintf(buf, sizeof buf, "%.2f", (double)0.01); ABTS_INT_EQUAL(tc, 4, rv); ABTS_STR_EQUAL(tc, "0.01", buf); } @@ -151,20 +151,20 @@ static void snprintf_underflow(abts_case *tc, void *data) static void string_error(abts_case *tc, void *data) { char buf[128], *rv; - apr_status_t n; + fspr_status_t n; buf[0] = '\0'; - rv = apr_strerror(APR_ENOENT, buf, sizeof buf); + rv = fspr_strerror(APR_ENOENT, buf, sizeof buf); ABTS_PTR_EQUAL(tc, buf, rv); ABTS_TRUE(tc, strlen(buf) > 0); - rv = apr_strerror(APR_TIMEUP, buf, sizeof buf); + rv = fspr_strerror(APR_TIMEUP, buf, sizeof buf); ABTS_PTR_EQUAL(tc, buf, rv); ABTS_STR_EQUAL(tc, "The timeout specified has expired", buf); /* throw some randomish numbers at it to check for robustness */ for (n = 1; n < 1000000; n *= 2) { - apr_strerror(n, buf, sizeof buf); + fspr_strerror(n, buf, sizeof buf); } } @@ -176,10 +176,10 @@ static void string_long(abts_case *tc, void *data) memset(s, 'A', SIZE); s[SIZE] = '\0'; - apr_psprintf(p, "%s", s); + fspr_psprintf(p, "%s", s); } -/* ### FIXME: apr.h/apr_strings.h should provide these! */ +/* ### FIXME: apr.h/fspr_strings.h should provide these! */ #define MY_LLONG_MAX (APR_INT64_C(9223372036854775807)) #define MY_LLONG_MIN (-MY_LLONG_MAX - APR_INT64_C(1)) @@ -188,7 +188,7 @@ static void string_strtoi64(abts_case *tc, void *data) static const struct { int errnum, base; const char *in, *end; - apr_int64_t result; + fspr_int64_t result; } ts[] = { /* base 10 tests */ @@ -243,22 +243,22 @@ static void string_strtoi64(abts_case *tc, void *data) for (n = 0; n < sizeof(ts)/sizeof(ts[0]); n++) { char *end = "end ptr not changed"; - apr_int64_t result; + fspr_int64_t result; int errnum; errno = 0; - result = apr_strtoi64(ts[n].in, &end, ts[n].base); + result = fspr_strtoi64(ts[n].in, &end, ts[n].base); errnum = errno; ABTS_ASSERT(tc, - apr_psprintf(p, "for '%s': result was %" APR_INT64_T_FMT + fspr_psprintf(p, "for '%s': result was %" APR_INT64_T_FMT " not %" APR_INT64_T_FMT, ts[n].in, result, ts[n].result), result == ts[n].result); if (ts[n].errnum != -1) { ABTS_ASSERT(tc, - apr_psprintf(p, "for '%s': errno was %d not %d", ts[n].in, + fspr_psprintf(p, "for '%s': errno was %d not %d", ts[n].in, errnum, ts[n].errnum), ts[n].errnum == errnum); } @@ -268,7 +268,7 @@ static void string_strtoi64(abts_case *tc, void *data) ABTS_PTR_EQUAL(tc, ts[n].in + strlen(ts[n].in), end); } else if (ts[n].end != (void *)-1) { ABTS_ASSERT(tc, - apr_psprintf(p, "for '%s', end was '%s' not '%s'", + fspr_psprintf(p, "for '%s', end was '%s' not '%s'", ts[n].in, end, ts[n].end), strcmp(ts[n].end, end) == 0); } @@ -277,14 +277,14 @@ static void string_strtoi64(abts_case *tc, void *data) static void string_strtoff(abts_case *tc, void *data) { - apr_off_t off; + fspr_off_t off; ABTS_ASSERT(tc, "strtoff fails on out-of-range integer", - apr_strtoff(&off, "999999999999999999999999999999", + fspr_strtoff(&off, "999999999999999999999999999999", NULL, 10) != APR_SUCCESS); ABTS_ASSERT(tc, "strtoff failed for 1234", - apr_strtoff(&off, "1234", NULL, 10) == APR_SUCCESS); + fspr_strtoff(&off, "1234", NULL, 10) == APR_SUCCESS); ABTS_ASSERT(tc, "strtoff failed to parse 1234", off == 1234); } @@ -292,25 +292,25 @@ static void string_strtoff(abts_case *tc, void *data) /* random-ish checks for strfsize buffer overflows */ static void overflow_strfsize(abts_case *tc, void *data) { - apr_off_t off; + fspr_off_t off; char buf[7]; buf[5] = '$'; buf[6] = '@'; for (off = -9999; off < 20000; off++) { - apr_strfsize(off, buf); + fspr_strfsize(off, buf); } for (; off < 9999999; off += 9) { - apr_strfsize(off, buf); + fspr_strfsize(off, buf); } for (; off < 999999999; off += 999) { - apr_strfsize(off, buf); + fspr_strfsize(off, buf); } for (off = 1; off < LONG_MAX && off > 0; off *= 2) { - apr_strfsize(off, buf); - apr_strfsize(off + 1, buf); - apr_strfsize(off - 1, buf); + fspr_strfsize(off, buf); + fspr_strfsize(off + 1, buf); + fspr_strfsize(off - 1, buf); } ABTS_ASSERT(tc, "strfsize overflowed", buf[5] == '$'); @@ -320,7 +320,7 @@ static void overflow_strfsize(abts_case *tc, void *data) static void string_strfsize(abts_case *tc, void *data) { static const struct { - apr_off_t size; + fspr_off_t size; const char *buf; } ts[] = { { -1, " - " }, @@ -334,14 +334,14 @@ static void string_strfsize(abts_case *tc, void *data) { 103809024, " 99M" }, { 1047527424, "1.0G" } /* "999M" would be more correct */ }; - apr_size_t n; + fspr_size_t n; for (n = 0; n < sizeof(ts)/sizeof(ts[0]); n++) { char buf[6], *ret; buf[5] = '%'; - ret = apr_strfsize(ts[n].size, buf); + ret = fspr_strfsize(ts[n].size, buf); ABTS_ASSERT(tc, "strfsize returned wrong buffer", ret == buf); ABTS_ASSERT(tc, "strfsize overflowed", buf[5] == '%'); @@ -357,10 +357,10 @@ static void snprintf_overflow(abts_case *tc, void *data) buf[2] = '4'; buf[3] = '2'; - rv = apr_snprintf(buf, 2, "%s", "a"); + rv = fspr_snprintf(buf, 2, "%s", "a"); ABTS_INT_EQUAL(tc, 1, rv); - rv = apr_snprintf(buf, 2, "%s", "abcd"); + rv = fspr_snprintf(buf, 2, "%s", "abcd"); ABTS_INT_EQUAL(tc, 1, rv); ABTS_STR_EQUAL(tc, buf, "a"); diff --git a/libs/apr/test/teststrnatcmp.c b/libs/apr/test/teststrnatcmp.c index 3a5e4c67ba..7e62742a0c 100644 --- a/libs/apr/test/teststrnatcmp.c +++ b/libs/apr/test/teststrnatcmp.c @@ -14,50 +14,50 @@ * limitations under the License. */ -#include "apr_file_io.h" -#include "apr_errno.h" -#include "apr_strings.h" +#include "fspr_file_io.h" +#include "fspr_errno.h" +#include "fspr_strings.h" #include "testutil.h" static void less0(abts_case *tc, void *data) { - int rv = apr_strnatcmp("a", "b"); + int rv = fspr_strnatcmp("a", "b"); ABTS_ASSERT(tc, "didn't compare simple strings properly", rv < 0); } static void str_equal(abts_case *tc, void *data) { - int rv = apr_strnatcmp("a", "a"); + int rv = fspr_strnatcmp("a", "a"); ABTS_ASSERT(tc, "didn't compare simple strings properly", rv == 0); } static void more0(abts_case *tc, void *data) { - int rv = apr_strnatcmp("b", "a"); + int rv = fspr_strnatcmp("b", "a"); ABTS_ASSERT(tc, "didn't compare simple strings properly", rv > 0); } static void less_ignore_case(abts_case *tc, void *data) { - int rv = apr_strnatcasecmp("a", "B"); + int rv = fspr_strnatcasecmp("a", "B"); ABTS_ASSERT(tc, "didn't compare simple strings properly", rv < 0); } static void str_equal_ignore_case(abts_case *tc, void *data) { - int rv = apr_strnatcasecmp("a", "A"); + int rv = fspr_strnatcasecmp("a", "A"); ABTS_ASSERT(tc, "didn't compare simple strings properly", rv == 0); } static void more_ignore_case(abts_case *tc, void *data) { - int rv = apr_strnatcasecmp("b", "A"); + int rv = fspr_strnatcasecmp("b", "A"); ABTS_ASSERT(tc, "didn't compare simple strings properly", rv > 0); } static void natcmp(abts_case *tc, void *data) { - int rv = apr_strnatcasecmp("a2", "a10"); + int rv = fspr_strnatcasecmp("a2", "a10"); ABTS_ASSERT(tc, "didn't compare simple strings properly", rv < 0); } diff --git a/libs/apr/test/testtable.c b/libs/apr/test/testtable.c index d377eaf5a1..e9696d768d 100644 --- a/libs/apr/test/testtable.c +++ b/libs/apr/test/testtable.c @@ -15,11 +15,11 @@ */ #include "testutil.h" -#include "apr.h" -#include "apr_strings.h" -#include "apr_general.h" -#include "apr_pools.h" -#include "apr_tables.h" +#include "fspr.h" +#include "fspr_strings.h" +#include "fspr_general.h" +#include "fspr_pools.h" +#include "fspr_tables.h" #if APR_HAVE_STDIO_H #include #endif @@ -30,11 +30,11 @@ #include #endif -static apr_table_t *t1 = NULL; +static fspr_table_t *t1 = NULL; static void table_make(abts_case *tc, void *data) { - t1 = apr_table_make(p, 5); + t1 = fspr_table_make(p, 5); ABTS_PTR_NOTNULL(tc, t1); } @@ -42,8 +42,8 @@ static void table_get(abts_case *tc, void *data) { const char *val; - apr_table_set(t1, "foo", "bar"); - val = apr_table_get(t1, "foo"); + fspr_table_set(t1, "foo", "bar"); + val = fspr_table_get(t1, "foo"); ABTS_STR_EQUAL(tc, val, "bar"); } @@ -51,9 +51,9 @@ static void table_set(abts_case *tc, void *data) { const char *val; - apr_table_set(t1, "setkey", "bar"); - apr_table_set(t1, "setkey", "2ndtry"); - val = apr_table_get(t1, "setkey"); + fspr_table_set(t1, "setkey", "bar"); + fspr_table_set(t1, "setkey", "2ndtry"); + val = fspr_table_get(t1, "setkey"); ABTS_STR_EQUAL(tc, val, "2ndtry"); } @@ -61,7 +61,7 @@ static void table_getnotthere(abts_case *tc, void *data) { const char *val; - val = apr_table_get(t1, "keynotthere"); + val = fspr_table_get(t1, "keynotthere"); ABTS_PTR_EQUAL(tc, NULL, (void *)val); } @@ -69,9 +69,9 @@ static void table_add(abts_case *tc, void *data) { const char *val; - apr_table_add(t1, "addkey", "bar"); - apr_table_add(t1, "addkey", "foo"); - val = apr_table_get(t1, "addkey"); + fspr_table_add(t1, "addkey", "bar"); + fspr_table_add(t1, "addkey", "foo"); + val = fspr_table_get(t1, "addkey"); ABTS_STR_EQUAL(tc, val, "bar"); } @@ -79,94 +79,94 @@ static void table_add(abts_case *tc, void *data) static void table_nelts(abts_case *tc, void *data) { const char *val; - apr_table_t *t = apr_table_make(p, 1); + fspr_table_t *t = fspr_table_make(p, 1); - apr_table_set(t, "abc", "def"); - apr_table_set(t, "def", "abc"); - apr_table_set(t, "foo", "zzz"); - val = apr_table_get(t, "foo"); + fspr_table_set(t, "abc", "def"); + fspr_table_set(t, "def", "abc"); + fspr_table_set(t, "foo", "zzz"); + val = fspr_table_get(t, "foo"); ABTS_STR_EQUAL(tc, val, "zzz"); - val = apr_table_get(t, "abc"); + val = fspr_table_get(t, "abc"); ABTS_STR_EQUAL(tc, val, "def"); - val = apr_table_get(t, "def"); + val = fspr_table_get(t, "def"); ABTS_STR_EQUAL(tc, val, "abc"); - ABTS_INT_EQUAL(tc, 3, apr_table_elts(t)->nelts); + ABTS_INT_EQUAL(tc, 3, fspr_table_elts(t)->nelts); } static void table_clear(abts_case *tc, void *data) { - apr_table_clear(t1); - ABTS_INT_EQUAL(tc, 0, apr_table_elts(t1)->nelts); + fspr_table_clear(t1); + ABTS_INT_EQUAL(tc, 0, fspr_table_elts(t1)->nelts); } static void table_unset(abts_case *tc, void *data) { const char *val; - apr_table_t *t = apr_table_make(p, 1); + fspr_table_t *t = fspr_table_make(p, 1); - apr_table_set(t, "a", "1"); - apr_table_set(t, "b", "2"); - apr_table_unset(t, "b"); - ABTS_INT_EQUAL(tc, 1, apr_table_elts(t)->nelts); - val = apr_table_get(t, "a"); + fspr_table_set(t, "a", "1"); + fspr_table_set(t, "b", "2"); + fspr_table_unset(t, "b"); + ABTS_INT_EQUAL(tc, 1, fspr_table_elts(t)->nelts); + val = fspr_table_get(t, "a"); ABTS_STR_EQUAL(tc, val, "1"); - val = apr_table_get(t, "b"); + val = fspr_table_get(t, "b"); ABTS_PTR_EQUAL(tc, (void *)val, (void *)NULL); } static void table_overlap(abts_case *tc, void *data) { const char *val; - apr_table_t *t1 = apr_table_make(p, 1); - apr_table_t *t2 = apr_table_make(p, 1); + fspr_table_t *t1 = fspr_table_make(p, 1); + fspr_table_t *t2 = fspr_table_make(p, 1); - apr_table_addn(t1, "a", "0"); - apr_table_addn(t1, "g", "7"); - apr_table_addn(t2, "a", "1"); - apr_table_addn(t2, "b", "2"); - apr_table_addn(t2, "c", "3"); - apr_table_addn(t2, "b", "2.0"); - apr_table_addn(t2, "d", "4"); - apr_table_addn(t2, "e", "5"); - apr_table_addn(t2, "b", "2."); - apr_table_addn(t2, "f", "6"); - apr_table_overlap(t1, t2, APR_OVERLAP_TABLES_SET); + fspr_table_addn(t1, "a", "0"); + fspr_table_addn(t1, "g", "7"); + fspr_table_addn(t2, "a", "1"); + fspr_table_addn(t2, "b", "2"); + fspr_table_addn(t2, "c", "3"); + fspr_table_addn(t2, "b", "2.0"); + fspr_table_addn(t2, "d", "4"); + fspr_table_addn(t2, "e", "5"); + fspr_table_addn(t2, "b", "2."); + fspr_table_addn(t2, "f", "6"); + fspr_table_overlap(t1, t2, APR_OVERLAP_TABLES_SET); - ABTS_INT_EQUAL(tc, apr_table_elts(t1)->nelts, 7); - val = apr_table_get(t1, "a"); + ABTS_INT_EQUAL(tc, fspr_table_elts(t1)->nelts, 7); + val = fspr_table_get(t1, "a"); ABTS_STR_EQUAL(tc, val, "1"); - val = apr_table_get(t1, "b"); + val = fspr_table_get(t1, "b"); ABTS_STR_EQUAL(tc, val, "2."); - val = apr_table_get(t1, "c"); + val = fspr_table_get(t1, "c"); ABTS_STR_EQUAL(tc, val, "3"); - val = apr_table_get(t1, "d"); + val = fspr_table_get(t1, "d"); ABTS_STR_EQUAL(tc, val, "4"); - val = apr_table_get(t1, "e"); + val = fspr_table_get(t1, "e"); ABTS_STR_EQUAL(tc, val, "5"); - val = apr_table_get(t1, "f"); + val = fspr_table_get(t1, "f"); ABTS_STR_EQUAL(tc, val, "6"); - val = apr_table_get(t1, "g"); + val = fspr_table_get(t1, "g"); ABTS_STR_EQUAL(tc, val, "7"); } static void table_overlap2(abts_case *tc, void *data) { - apr_pool_t *subp; - apr_table_t *t1, *t2; + fspr_pool_t *subp; + fspr_table_t *t1, *t2; - apr_pool_create(&subp, p); + fspr_pool_create(&subp, p); - t1 = apr_table_make(subp, 1); - t2 = apr_table_make(p, 1); - apr_table_addn(t1, "t1", "one"); - apr_table_addn(t2, "t2", "two"); + t1 = fspr_table_make(subp, 1); + t2 = fspr_table_make(p, 1); + fspr_table_addn(t1, "t1", "one"); + fspr_table_addn(t2, "t2", "two"); - apr_table_overlap(t1, t2, APR_OVERLAP_TABLES_SET); + fspr_table_overlap(t1, t2, APR_OVERLAP_TABLES_SET); - ABTS_INT_EQUAL(tc, 2, apr_table_elts(t1)->nelts); + ABTS_INT_EQUAL(tc, 2, fspr_table_elts(t1)->nelts); - ABTS_STR_EQUAL(tc, apr_table_get(t1, "t1"), "one"); - ABTS_STR_EQUAL(tc, apr_table_get(t1, "t2"), "two"); + ABTS_STR_EQUAL(tc, fspr_table_get(t1, "t1"), "one"); + ABTS_STR_EQUAL(tc, fspr_table_get(t1, "t2"), "two"); } diff --git a/libs/apr/test/testtemp.c b/libs/apr/test/testtemp.c index 1f1143ee35..6d94c193e9 100644 --- a/libs/apr/test/testtemp.c +++ b/libs/apr/test/testtemp.c @@ -15,31 +15,31 @@ */ #include "testutil.h" -#include "apr_file_io.h" -#include "apr_strings.h" +#include "fspr_file_io.h" +#include "fspr_strings.h" static void test_temp_dir(abts_case *tc, void *data) { const char *tempdir = NULL; - apr_status_t rv; + fspr_status_t rv; - rv = apr_temp_dir_get(&tempdir, p); + rv = fspr_temp_dir_get(&tempdir, p); APR_ASSERT_SUCCESS(tc, "Error finding Temporary Directory", rv); ABTS_PTR_NOTNULL(tc, tempdir); } static void test_mktemp(abts_case *tc, void *data) { - apr_file_t *f = NULL; + fspr_file_t *f = NULL; const char *tempdir = NULL; char *filetemplate; - apr_status_t rv; + fspr_status_t rv; - rv = apr_temp_dir_get(&tempdir, p); + rv = fspr_temp_dir_get(&tempdir, p); APR_ASSERT_SUCCESS(tc, "Error finding Temporary Directory", rv); - filetemplate = apr_pstrcat(p, tempdir, "/tempfileXXXXXX", NULL); - rv = apr_file_mktemp(&f, filetemplate, 0, p); + filetemplate = fspr_pstrcat(p, tempdir, "/tempfileXXXXXX", NULL); + rv = fspr_file_mktemp(&f, filetemplate, 0, p); APR_ASSERT_SUCCESS(tc, "Error opening Temporary file", rv); } diff --git a/libs/apr/test/testthread.c b/libs/apr/test/testthread.c index 35ef293bec..a5709aac74 100644 --- a/libs/apr/test/testthread.c +++ b/libs/apr/test/testthread.c @@ -14,84 +14,84 @@ * limitations under the License. */ -#include "apr_thread_proc.h" -#include "apr_errno.h" -#include "apr_general.h" +#include "fspr_thread_proc.h" +#include "fspr_errno.h" +#include "fspr_general.h" #include "errno.h" -#include "apr_time.h" +#include "fspr_time.h" #include "testutil.h" #if APR_HAS_THREADS -static apr_thread_mutex_t *thread_lock; -static apr_thread_once_t *control = NULL; +static fspr_thread_mutex_t *thread_lock; +static fspr_thread_once_t *control = NULL; static int x = 0; static int value = 0; -static apr_thread_t *t1; -static apr_thread_t *t2; -static apr_thread_t *t3; -static apr_thread_t *t4; +static fspr_thread_t *t1; +static fspr_thread_t *t2; +static fspr_thread_t *t3; +static fspr_thread_t *t4; /* just some made up number to check on later */ -static apr_status_t exit_ret_val = 123; +static fspr_status_t exit_ret_val = 123; static void init_func(void) { value++; } -static void * APR_THREAD_FUNC thread_func1(apr_thread_t *thd, void *data) +static void * APR_THREAD_FUNC thread_func1(fspr_thread_t *thd, void *data) { int i; - apr_thread_once(control, init_func); + fspr_thread_once(control, init_func); for (i = 0; i < 10000; i++) { - apr_thread_mutex_lock(thread_lock); + fspr_thread_mutex_lock(thread_lock); x++; - apr_thread_mutex_unlock(thread_lock); + fspr_thread_mutex_unlock(thread_lock); } - apr_thread_exit(thd, exit_ret_val); + fspr_thread_exit(thd, exit_ret_val); return NULL; } static void thread_init(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; - rv = apr_thread_once_init(&control, p); + rv = fspr_thread_once_init(&control, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_thread_mutex_create(&thread_lock, APR_THREAD_MUTEX_DEFAULT, p); + rv = fspr_thread_mutex_create(&thread_lock, APR_THREAD_MUTEX_DEFAULT, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); } static void create_threads(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; - rv = apr_thread_create(&t1, NULL, thread_func1, NULL, p); + rv = fspr_thread_create(&t1, NULL, thread_func1, NULL, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_thread_create(&t2, NULL, thread_func1, NULL, p); + rv = fspr_thread_create(&t2, NULL, thread_func1, NULL, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_thread_create(&t3, NULL, thread_func1, NULL, p); + rv = fspr_thread_create(&t3, NULL, thread_func1, NULL, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_thread_create(&t4, NULL, thread_func1, NULL, p); + rv = fspr_thread_create(&t4, NULL, thread_func1, NULL, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); } static void join_threads(abts_case *tc, void *data) { - apr_status_t s; + fspr_status_t s; - apr_thread_join(&s, t1); + fspr_thread_join(&s, t1); ABTS_INT_EQUAL(tc, exit_ret_val, s); - apr_thread_join(&s, t2); + fspr_thread_join(&s, t2); ABTS_INT_EQUAL(tc, exit_ret_val, s); - apr_thread_join(&s, t3); + fspr_thread_join(&s, t3); ABTS_INT_EQUAL(tc, exit_ret_val, s); - apr_thread_join(&s, t4); + fspr_thread_join(&s, t4); ABTS_INT_EQUAL(tc, exit_ret_val, s); } diff --git a/libs/apr/test/testtime.c b/libs/apr/test/testtime.c index 84b4772695..2922d095d6 100644 --- a/libs/apr/test/testtime.c +++ b/libs/apr/test/testtime.c @@ -14,12 +14,12 @@ * limitations under the License. */ -#include "apr_time.h" -#include "apr_errno.h" -#include "apr_general.h" -#include "apr_lib.h" +#include "fspr_time.h" +#include "fspr_errno.h" +#include "fspr_general.h" +#include "fspr_lib.h" #include "testutil.h" -#include "apr_strings.h" +#include "fspr_strings.h" #include #define STR_SIZE 45 @@ -30,11 +30,11 @@ * 2002-08-14 12:05:36.186711 -25200 [257 Sat]. * Which happens to be when I wrote the new tests. */ -static apr_time_t now = APR_INT64_C(1032030336186711); +static fspr_time_t now = APR_INT64_C(1032030336186711); -static char* print_time (apr_pool_t *pool, const apr_time_exp_t *xt) +static char* print_time (fspr_pool_t *pool, const fspr_time_exp_t *xt) { - return apr_psprintf (pool, + return fspr_psprintf (pool, "%04d-%02d-%02d %02d:%02d:%02d.%06d %+05d [%d %s]%s", xt->tm_year + 1900, xt->tm_mon, @@ -45,18 +45,18 @@ static char* print_time (apr_pool_t *pool, const apr_time_exp_t *xt) xt->tm_usec, xt->tm_gmtoff, xt->tm_yday + 1, - apr_day_snames[xt->tm_wday], + fspr_day_snames[xt->tm_wday], (xt->tm_isdst ? " DST" : "")); } static void test_now(abts_case *tc, void *data) { - apr_time_t timediff; - apr_time_t current; + fspr_time_t timediff; + fspr_time_t current; time_t os_now; - current = apr_time_now(); + current = fspr_time_now(); time(&os_now); timediff = os_now - (current / APR_USEC_PER_SEC); @@ -64,18 +64,18 @@ static void test_now(abts_case *tc, void *data) * that the time will be slightly off, so accept anything between -1 and * 1 second. */ - ABTS_ASSERT(tc, "apr_time and OS time do not agree", + ABTS_ASSERT(tc, "fspr_time and OS time do not agree", (timediff > -2) && (timediff < 2)); } static void test_gmtstr(abts_case *tc, void *data) { - apr_status_t rv; - apr_time_exp_t xt; + fspr_status_t rv; + fspr_time_exp_t xt; - rv = apr_time_exp_gmt(&xt, now); + rv = fspr_time_exp_gmt(&xt, now); if (rv == APR_ENOTIMPL) { - ABTS_NOT_IMPL(tc, "apr_time_exp_gmt"); + ABTS_NOT_IMPL(tc, "fspr_time_exp_gmt"); } ABTS_TRUE(tc, rv == APR_SUCCESS); ABTS_STR_EQUAL(tc, "2002-08-14 19:05:36.186711 +0000 [257 Sat]", @@ -84,14 +84,14 @@ static void test_gmtstr(abts_case *tc, void *data) static void test_exp_lt(abts_case *tc, void *data) { - apr_status_t rv; - apr_time_exp_t xt; - time_t posix_secs = (time_t)apr_time_sec(now); + fspr_status_t rv; + fspr_time_exp_t xt; + time_t posix_secs = (time_t)fspr_time_sec(now); struct tm *posix_exp = localtime(&posix_secs); - rv = apr_time_exp_lt(&xt, now); + rv = fspr_time_exp_lt(&xt, now); if (rv == APR_ENOTIMPL) { - ABTS_NOT_IMPL(tc, "apr_time_exp_lt"); + ABTS_NOT_IMPL(tc, "fspr_time_exp_lt"); } ABTS_TRUE(tc, rv == APR_SUCCESS); @@ -112,51 +112,51 @@ static void test_exp_lt(abts_case *tc, void *data) static void test_exp_get_gmt(abts_case *tc, void *data) { - apr_status_t rv; - apr_time_exp_t xt; - apr_time_t imp; - apr_int64_t hr_off_64; + fspr_status_t rv; + fspr_time_exp_t xt; + fspr_time_t imp; + fspr_int64_t hr_off_64; - rv = apr_time_exp_gmt(&xt, now); + rv = fspr_time_exp_gmt(&xt, now); ABTS_TRUE(tc, rv == APR_SUCCESS); - rv = apr_time_exp_get(&imp, &xt); + rv = fspr_time_exp_get(&imp, &xt); if (rv == APR_ENOTIMPL) { - ABTS_NOT_IMPL(tc, "apr_time_exp_get"); + ABTS_NOT_IMPL(tc, "fspr_time_exp_get"); } ABTS_TRUE(tc, rv == APR_SUCCESS); - hr_off_64 = (apr_int64_t) xt.tm_gmtoff * APR_USEC_PER_SEC; + hr_off_64 = (fspr_int64_t) xt.tm_gmtoff * APR_USEC_PER_SEC; ABTS_TRUE(tc, now + hr_off_64 == imp); } static void test_exp_get_lt(abts_case *tc, void *data) { - apr_status_t rv; - apr_time_exp_t xt; - apr_time_t imp; - apr_int64_t hr_off_64; + fspr_status_t rv; + fspr_time_exp_t xt; + fspr_time_t imp; + fspr_int64_t hr_off_64; - rv = apr_time_exp_lt(&xt, now); + rv = fspr_time_exp_lt(&xt, now); ABTS_TRUE(tc, rv == APR_SUCCESS); - rv = apr_time_exp_get(&imp, &xt); + rv = fspr_time_exp_get(&imp, &xt); if (rv == APR_ENOTIMPL) { - ABTS_NOT_IMPL(tc, "apr_time_exp_get"); + ABTS_NOT_IMPL(tc, "fspr_time_exp_get"); } ABTS_TRUE(tc, rv == APR_SUCCESS); - hr_off_64 = (apr_int64_t) xt.tm_gmtoff * APR_USEC_PER_SEC; + hr_off_64 = (fspr_int64_t) xt.tm_gmtoff * APR_USEC_PER_SEC; ABTS_TRUE(tc, now + hr_off_64 == imp); } static void test_imp_gmt(abts_case *tc, void *data) { - apr_status_t rv; - apr_time_exp_t xt; - apr_time_t imp; + fspr_status_t rv; + fspr_time_exp_t xt; + fspr_time_t imp; - rv = apr_time_exp_gmt(&xt, now); + rv = fspr_time_exp_gmt(&xt, now); ABTS_TRUE(tc, rv == APR_SUCCESS); - rv = apr_time_exp_gmt_get(&imp, &xt); + rv = fspr_time_exp_gmt_get(&imp, &xt); if (rv == APR_ENOTIMPL) { - ABTS_NOT_IMPL(tc, "apr_time_exp_gmt_get"); + ABTS_NOT_IMPL(tc, "fspr_time_exp_gmt_get"); } ABTS_TRUE(tc, rv == APR_SUCCESS); ABTS_TRUE(tc, now == imp); @@ -164,12 +164,12 @@ static void test_imp_gmt(abts_case *tc, void *data) static void test_rfcstr(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; char str[STR_SIZE]; - rv = apr_rfc822_date(str, now); + rv = fspr_rfc822_date(str, now); if (rv == APR_ENOTIMPL) { - ABTS_NOT_IMPL(tc, "apr_rfc822_date"); + ABTS_NOT_IMPL(tc, "fspr_rfc822_date"); } ABTS_TRUE(tc, rv == APR_SUCCESS); ABTS_STR_EQUAL(tc, "Sat, 14 Sep 2002 19:05:36 GMT", str); @@ -177,35 +177,35 @@ static void test_rfcstr(abts_case *tc, void *data) static void test_ctime(abts_case *tc, void *data) { - apr_status_t rv; - char apr_str[STR_SIZE]; + fspr_status_t rv; + char fspr_str[STR_SIZE]; char libc_str[STR_SIZE]; - apr_time_t now_sec = apr_time_sec(now); + fspr_time_t now_sec = fspr_time_sec(now); time_t posix_sec = (time_t) now_sec; - rv = apr_ctime(apr_str, now); + rv = fspr_ctime(fspr_str, now); if (rv == APR_ENOTIMPL) { - ABTS_NOT_IMPL(tc, "apr_ctime"); + ABTS_NOT_IMPL(tc, "fspr_ctime"); } ABTS_TRUE(tc, rv == APR_SUCCESS); strcpy(libc_str, ctime(&posix_sec)); *strchr(libc_str, '\n') = '\0'; - ABTS_STR_EQUAL(tc, libc_str, apr_str); + ABTS_STR_EQUAL(tc, libc_str, fspr_str); } static void test_strftime(abts_case *tc, void *data) { - apr_status_t rv; - apr_time_exp_t xt; + fspr_status_t rv; + fspr_time_exp_t xt; char *str = NULL; - apr_size_t sz; + fspr_size_t sz; - rv = apr_time_exp_gmt(&xt, now); - str = apr_palloc(p, STR_SIZE + 1); - rv = apr_strftime(str, &sz, STR_SIZE, "%R %A %d %B %Y", &xt); + rv = fspr_time_exp_gmt(&xt, now); + str = fspr_palloc(p, STR_SIZE + 1); + rv = fspr_strftime(str, &sz, STR_SIZE, "%R %A %d %B %Y", &xt); if (rv == APR_ENOTIMPL) { - ABTS_NOT_IMPL(tc, "apr_strftime"); + ABTS_NOT_IMPL(tc, "fspr_strftime"); } ABTS_TRUE(tc, rv == APR_SUCCESS); ABTS_STR_EQUAL(tc, "19:05 Saturday 14 September 2002", str); @@ -213,15 +213,15 @@ static void test_strftime(abts_case *tc, void *data) static void test_strftimesmall(abts_case *tc, void *data) { - apr_status_t rv; - apr_time_exp_t xt; + fspr_status_t rv; + fspr_time_exp_t xt; char str[STR_SIZE]; - apr_size_t sz; + fspr_size_t sz; - rv = apr_time_exp_gmt(&xt, now); - rv = apr_strftime(str, &sz, STR_SIZE, "%T", &xt); + rv = fspr_time_exp_gmt(&xt, now); + rv = fspr_strftime(str, &sz, STR_SIZE, "%T", &xt); if (rv == APR_ENOTIMPL) { - ABTS_NOT_IMPL(tc, "apr_strftime"); + ABTS_NOT_IMPL(tc, "fspr_strftime"); } ABTS_TRUE(tc, rv == APR_SUCCESS); ABTS_STR_EQUAL(tc, "19:05:36", str); @@ -229,13 +229,13 @@ static void test_strftimesmall(abts_case *tc, void *data) static void test_exp_tz(abts_case *tc, void *data) { - apr_status_t rv; - apr_time_exp_t xt; - apr_int32_t hr_off = -5 * 3600; /* 5 hours in seconds */ + fspr_status_t rv; + fspr_time_exp_t xt; + fspr_int32_t hr_off = -5 * 3600; /* 5 hours in seconds */ - rv = apr_time_exp_tz(&xt, now, hr_off); + rv = fspr_time_exp_tz(&xt, now, hr_off); if (rv == APR_ENOTIMPL) { - ABTS_NOT_IMPL(tc, "apr_time_exp_tz"); + ABTS_NOT_IMPL(tc, "fspr_time_exp_tz"); } ABTS_TRUE(tc, rv == APR_SUCCESS); ABTS_TRUE(tc, (xt.tm_usec == 186711) && @@ -251,16 +251,16 @@ static void test_exp_tz(abts_case *tc, void *data) static void test_strftimeoffset(abts_case *tc, void *data) { - apr_status_t rv; - apr_time_exp_t xt; + fspr_status_t rv; + fspr_time_exp_t xt; char str[STR_SIZE]; - apr_size_t sz; - apr_int32_t hr_off = -5 * 3600; /* 5 hours in seconds */ + fspr_size_t sz; + fspr_int32_t hr_off = -5 * 3600; /* 5 hours in seconds */ - apr_time_exp_tz(&xt, now, hr_off); - rv = apr_strftime(str, &sz, STR_SIZE, "%T", &xt); + fspr_time_exp_tz(&xt, now, hr_off); + rv = fspr_strftime(str, &sz, STR_SIZE, "%T", &xt); if (rv == APR_ENOTIMPL) { - ABTS_NOT_IMPL(tc, "apr_strftime"); + ABTS_NOT_IMPL(tc, "fspr_strftime"); } ABTS_TRUE(tc, rv == APR_SUCCESS); } @@ -268,8 +268,8 @@ static void test_strftimeoffset(abts_case *tc, void *data) /* 0.9.4 and earlier rejected valid dates in 2038 */ static void test_2038(abts_case *tc, void *data) { - apr_time_exp_t xt; - apr_time_t t; + fspr_time_exp_t xt; + fspr_time_t t; /* 2038-01-19T03:14:07.000000Z */ xt.tm_year = 138; @@ -280,7 +280,7 @@ static void test_2038(abts_case *tc, void *data) xt.tm_sec = 7; APR_ASSERT_SUCCESS(tc, "explode January 19th, 2038", - apr_time_exp_get(&t, &xt)); + fspr_time_exp_get(&t, &xt)); } abts_suite *testtime(abts_suite *suite) diff --git a/libs/apr/test/testud.c b/libs/apr/test/testud.c index 77cd28faa9..22f30787cf 100644 --- a/libs/apr/test/testud.c +++ b/libs/apr/test/testud.c @@ -16,18 +16,18 @@ #include #include -#include "apr_file_io.h" -#include "apr_errno.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_strings.h" +#include "fspr_file_io.h" +#include "fspr_errno.h" +#include "fspr_general.h" +#include "fspr_lib.h" +#include "fspr_strings.h" #include "testutil.h" -static apr_pool_t *pool; +static fspr_pool_t *pool; static char *testdata; static int cleanup_called = 0; -static apr_status_t string_cleanup(void *data) +static fspr_status_t string_cleanup(void *data) { cleanup_called = 1; return APR_SUCCESS; @@ -35,38 +35,38 @@ static apr_status_t string_cleanup(void *data) static void set_userdata(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; - rv = apr_pool_userdata_set(testdata, "TEST", string_cleanup, pool); + rv = fspr_pool_userdata_set(testdata, "TEST", string_cleanup, pool); ABTS_INT_EQUAL(tc, rv, APR_SUCCESS); } static void get_userdata(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; void *retdata; - rv = apr_pool_userdata_get(&retdata, "TEST", pool); + rv = fspr_pool_userdata_get(&retdata, "TEST", pool); ABTS_INT_EQUAL(tc, rv, APR_SUCCESS); ABTS_STR_EQUAL(tc, retdata, testdata); } static void get_nonexistkey(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; void *retdata; - rv = apr_pool_userdata_get(&retdata, "DOESNTEXIST", pool); + rv = fspr_pool_userdata_get(&retdata, "DOESNTEXIST", pool); ABTS_INT_EQUAL(tc, rv, APR_SUCCESS); ABTS_PTR_EQUAL(tc, retdata, NULL); } static void post_pool_clear(abts_case *tc, void *data) { - apr_status_t rv; + fspr_status_t rv; void *retdata; - rv = apr_pool_userdata_get(&retdata, "DOESNTEXIST", pool); + rv = fspr_pool_userdata_get(&retdata, "DOESNTEXIST", pool); ABTS_INT_EQUAL(tc, rv, APR_SUCCESS); ABTS_PTR_EQUAL(tc, retdata, NULL); } @@ -75,14 +75,14 @@ abts_suite *testud(abts_suite *suite) { suite = ADD_SUITE(suite) - apr_pool_create(&pool, p); - testdata = apr_pstrdup(pool, "This is a test\n"); + fspr_pool_create(&pool, p); + testdata = fspr_pstrdup(pool, "This is a test\n"); abts_run_test(suite, set_userdata, NULL); abts_run_test(suite, get_userdata, NULL); abts_run_test(suite, get_nonexistkey, NULL); - apr_pool_clear(pool); + fspr_pool_clear(pool); abts_run_test(suite, post_pool_clear, NULL); diff --git a/libs/apr/test/testuser.c b/libs/apr/test/testuser.c index 834abaf3a7..49f285b839 100644 --- a/libs/apr/test/testuser.c +++ b/libs/apr/test/testuser.c @@ -15,59 +15,59 @@ */ #include "testutil.h" -#include "apr_errno.h" -#include "apr_general.h" -#include "apr_user.h" +#include "fspr_errno.h" +#include "fspr_general.h" +#include "fspr_user.h" #if APR_HAS_USER static void uid_current(abts_case *tc, void *data) { - apr_uid_t uid; - apr_gid_t gid; + fspr_uid_t uid; + fspr_gid_t gid; - APR_ASSERT_SUCCESS(tc, "apr_uid_current failed", - apr_uid_current(&uid, &gid, p)); + APR_ASSERT_SUCCESS(tc, "fspr_uid_current failed", + fspr_uid_current(&uid, &gid, p)); } static void username(abts_case *tc, void *data) { - apr_uid_t uid; - apr_gid_t gid; - apr_uid_t retreived_uid; - apr_gid_t retreived_gid; + fspr_uid_t uid; + fspr_gid_t gid; + fspr_uid_t retreived_uid; + fspr_gid_t retreived_gid; char *uname = NULL; - APR_ASSERT_SUCCESS(tc, "apr_uid_current failed", - apr_uid_current(&uid, &gid, p)); + APR_ASSERT_SUCCESS(tc, "fspr_uid_current failed", + fspr_uid_current(&uid, &gid, p)); - APR_ASSERT_SUCCESS(tc, "apr_uid_name_get failed", - apr_uid_name_get(&uname, uid, p)); + APR_ASSERT_SUCCESS(tc, "fspr_uid_name_get failed", + fspr_uid_name_get(&uname, uid, p)); ABTS_PTR_NOTNULL(tc, uname); - APR_ASSERT_SUCCESS(tc, "apr_uid_get failed", - apr_uid_get(&retreived_uid, &retreived_gid, uname, p)); + APR_ASSERT_SUCCESS(tc, "fspr_uid_get failed", + fspr_uid_get(&retreived_uid, &retreived_gid, uname, p)); - APR_ASSERT_SUCCESS(tc, "apr_uid_compare failed", - apr_uid_compare(uid, retreived_uid)); + APR_ASSERT_SUCCESS(tc, "fspr_uid_compare failed", + fspr_uid_compare(uid, retreived_uid)); #ifdef WIN32 /* ### this fudge was added for Win32 but makes the test return NotImpl * on Unix if run as root, when !gid is also true. */ if (!gid || !retreived_gid) { /* The function had no way to recover the gid (this would have been - * an ENOTIMPL if apr_uid_ functions didn't try to double-up and - * also return apr_gid_t values, which was bogus. + * an ENOTIMPL if fspr_uid_ functions didn't try to double-up and + * also return fspr_gid_t values, which was bogus. */ if (!gid) { - ABTS_NOT_IMPL(tc, "Groups from apr_uid_current"); + ABTS_NOT_IMPL(tc, "Groups from fspr_uid_current"); } else { - ABTS_NOT_IMPL(tc, "Groups from apr_uid_get"); + ABTS_NOT_IMPL(tc, "Groups from fspr_uid_get"); } } else { #endif - APR_ASSERT_SUCCESS(tc, "apr_gid_compare failed", - apr_gid_compare(gid, retreived_gid)); + APR_ASSERT_SUCCESS(tc, "fspr_gid_compare failed", + fspr_gid_compare(gid, retreived_gid)); #ifdef WIN32 } #endif @@ -75,67 +75,67 @@ static void username(abts_case *tc, void *data) static void groupname(abts_case *tc, void *data) { - apr_uid_t uid; - apr_gid_t gid; - apr_gid_t retreived_gid; + fspr_uid_t uid; + fspr_gid_t gid; + fspr_gid_t retreived_gid; char *gname = NULL; - APR_ASSERT_SUCCESS(tc, "apr_uid_current failed", - apr_uid_current(&uid, &gid, p)); + APR_ASSERT_SUCCESS(tc, "fspr_uid_current failed", + fspr_uid_current(&uid, &gid, p)); - APR_ASSERT_SUCCESS(tc, "apr_gid_name_get failed", - apr_gid_name_get(&gname, gid, p)); + APR_ASSERT_SUCCESS(tc, "fspr_gid_name_get failed", + fspr_gid_name_get(&gname, gid, p)); ABTS_PTR_NOTNULL(tc, gname); - APR_ASSERT_SUCCESS(tc, "apr_gid_get failed", - apr_gid_get(&retreived_gid, gname, p)); + APR_ASSERT_SUCCESS(tc, "fspr_gid_get failed", + fspr_gid_get(&retreived_gid, gname, p)); - APR_ASSERT_SUCCESS(tc, "apr_gid_compare failed", - apr_gid_compare(gid, retreived_gid)); + APR_ASSERT_SUCCESS(tc, "fspr_gid_compare failed", + fspr_gid_compare(gid, retreived_gid)); } #ifndef WIN32 static void fail_userinfo(abts_case *tc, void *data) { - apr_uid_t uid; - apr_gid_t gid; - apr_status_t rv; + fspr_uid_t uid; + fspr_gid_t gid; + fspr_status_t rv; char *tmp; errno = 0; gid = uid = 9999999; tmp = NULL; - rv = apr_uid_name_get(&tmp, uid, p); - ABTS_ASSERT(tc, "apr_uid_name_get should fail or " + rv = fspr_uid_name_get(&tmp, uid, p); + ABTS_ASSERT(tc, "fspr_uid_name_get should fail or " "return a user name", rv != APR_SUCCESS || tmp != NULL); errno = 0; tmp = NULL; - rv = apr_gid_name_get(&tmp, gid, p); - ABTS_ASSERT(tc, "apr_gid_name_get should fail or " + rv = fspr_gid_name_get(&tmp, gid, p); + ABTS_ASSERT(tc, "fspr_gid_name_get should fail or " "return a group name", rv != APR_SUCCESS || tmp != NULL); gid = 424242; errno = 0; - rv = apr_gid_get(&gid, "I_AM_NOT_A_GROUP", p); - ABTS_ASSERT(tc, "apr_gid_get should fail or " + rv = fspr_gid_get(&gid, "I_AM_NOT_A_GROUP", p); + ABTS_ASSERT(tc, "fspr_gid_get should fail or " "set a group number", rv != APR_SUCCESS || gid == 424242); gid = uid = 424242; errno = 0; - rv = apr_uid_get(&uid, &gid, "I_AM_NOT_A_USER", p); - ABTS_ASSERT(tc, "apr_gid_get should fail or " + rv = fspr_uid_get(&uid, &gid, "I_AM_NOT_A_USER", p); + ABTS_ASSERT(tc, "fspr_gid_get should fail or " "set a user and group number", rv != APR_SUCCESS || uid == 424242 || gid == 4242442); errno = 0; tmp = NULL; - rv = apr_uid_homepath_get(&tmp, "I_AM_NOT_A_USER", p); - ABTS_ASSERT(tc, "apr_uid_homepath_get should fail or " + rv = fspr_uid_homepath_get(&tmp, "I_AM_NOT_A_USER", p); + ABTS_ASSERT(tc, "fspr_uid_homepath_get should fail or " "set a path name", rv != APR_SUCCESS || tmp != NULL); } diff --git a/libs/apr/test/testutil.c b/libs/apr/test/testutil.c index c433e92c39..2b094cc8ec 100644 --- a/libs/apr/test/testutil.c +++ b/libs/apr/test/testutil.c @@ -19,11 +19,11 @@ #include "abts.h" #include "testutil.h" -#include "apr_pools.h" +#include "fspr_pools.h" -apr_pool_t *p; +fspr_pool_t *p; -void apr_assert_success(abts_case* tc, const char* context, apr_status_t rv, +void fspr_assert_success(abts_case* tc, const char* context, fspr_status_t rv, int lineno) { if (rv == APR_ENOTIMPL) { @@ -31,14 +31,14 @@ void apr_assert_success(abts_case* tc, const char* context, apr_status_t rv, } else if (rv != APR_SUCCESS) { char buf[STRING_MAX], ebuf[128]; sprintf(buf, "%s (%d): %s\n", context, rv, - apr_strerror(rv, ebuf, sizeof ebuf)); + fspr_strerror(rv, ebuf, sizeof ebuf)); abts_fail(tc, buf, lineno); } } void initialize(void) { - apr_initialize(); - atexit(apr_terminate); + fspr_initialize(); + atexit(fspr_terminate); - apr_pool_create(&p, NULL); + fspr_pool_create(&p, NULL); } diff --git a/libs/apr/test/testutil.h b/libs/apr/test/testutil.h index 96394c5eb0..9ad9182445 100644 --- a/libs/apr/test/testutil.h +++ b/libs/apr/test/testutil.h @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "apr_pools.h" +#include "fspr_pools.h" #include "abts.h" #ifndef APR_TEST_UTIL @@ -35,14 +35,14 @@ * a bit more consistent... */ -extern apr_pool_t *p; +extern fspr_pool_t *p; /* Assert that RV is an APR_SUCCESS value; else fail giving strerror * for RV and CONTEXT message. */ -void apr_assert_success(abts_case* tc, const char *context, - apr_status_t rv, int lineno); +void fspr_assert_success(abts_case* tc, const char *context, + fspr_status_t rv, int lineno); #define APR_ASSERT_SUCCESS(tc, ctxt, rv) \ - apr_assert_success(tc, ctxt, rv, __LINE__) + fspr_assert_success(tc, ctxt, rv, __LINE__) void initialize(void); diff --git a/libs/apr/test/testvsn.c b/libs/apr/test/testvsn.c index dbc218a13f..32ffafc95e 100644 --- a/libs/apr/test/testvsn.c +++ b/libs/apr/test/testvsn.c @@ -17,13 +17,13 @@ #include #include "testutil.h" -#include "apr_version.h" -#include "apr_general.h" +#include "fspr_version.h" +#include "fspr_general.h" static void test_strings(abts_case *tc, void *data) { - ABTS_STR_EQUAL(tc, APR_VERSION_STRING, apr_version_string()); + ABTS_STR_EQUAL(tc, APR_VERSION_STRING, fspr_version_string()); } #ifdef APR_IS_DEV_VERSION @@ -34,9 +34,9 @@ static void test_strings(abts_case *tc, void *data) static void test_ints(abts_case *tc, void *data) { - apr_version_t vsn; + fspr_version_t vsn; - apr_version(&vsn); + fspr_version(&vsn); ABTS_INT_EQUAL(tc, APR_MAJOR_VERSION, vsn.major); ABTS_INT_EQUAL(tc, APR_MINOR_VERSION, vsn.minor); diff --git a/libs/apr/test/tryread.c b/libs/apr/test/tryread.c index 729f8e699b..6ff6ce0399 100644 --- a/libs/apr/test/tryread.c +++ b/libs/apr/test/tryread.c @@ -15,10 +15,10 @@ */ #include "testflock.h" -#include "apr_pools.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr.h" +#include "fspr_pools.h" +#include "fspr_file_io.h" +#include "fspr_general.h" +#include "fspr.h" #if APR_HAVE_STDLIB_H #include @@ -26,19 +26,19 @@ int main(int argc, const char * const *argv) { - apr_file_t *file; - apr_status_t status; - apr_pool_t *p; + fspr_file_t *file; + fspr_status_t status; + fspr_pool_t *p; - apr_initialize(); - apr_pool_create(&p, NULL); + fspr_initialize(); + fspr_pool_create(&p, NULL); - if (apr_file_open(&file, TESTFILE, APR_WRITE, APR_OS_DEFAULT, p) + if (fspr_file_open(&file, TESTFILE, APR_WRITE, APR_OS_DEFAULT, p) != APR_SUCCESS) { exit(UNEXPECTED_ERROR); } - status = apr_file_lock(file, APR_FLOCK_EXCLUSIVE | APR_FLOCK_NONBLOCK); + status = fspr_file_lock(file, APR_FLOCK_EXCLUSIVE | APR_FLOCK_NONBLOCK); if (status == APR_SUCCESS) { exit(SUCCESSFUL_READ); } diff --git a/libs/apr/threadproc/beos/apr_proc_stub.c b/libs/apr/threadproc/beos/fspr_proc_stub.c similarity index 100% rename from libs/apr/threadproc/beos/apr_proc_stub.c rename to libs/apr/threadproc/beos/fspr_proc_stub.c diff --git a/libs/apr/threadproc/beos/proc.c b/libs/apr/threadproc/beos/proc.c index 7af73036f5..fb2012e065 100644 --- a/libs/apr/threadproc/beos/proc.c +++ b/libs/apr/threadproc/beos/proc.c @@ -14,8 +14,8 @@ * limitations under the License. */ -#include "apr_arch_threadproc.h" -#include "apr_strings.h" +#include "fspr_arch_threadproc.h" +#include "fspr_strings.h" struct send_pipe { int in; @@ -23,10 +23,10 @@ struct send_pipe { int err; }; -APR_DECLARE(apr_status_t) apr_procattr_create(apr_procattr_t **new, apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_procattr_create(fspr_procattr_t **new, fspr_pool_t *pool) { - (*new) = (apr_procattr_t *)apr_palloc(pool, - sizeof(apr_procattr_t)); + (*new) = (fspr_procattr_t *)fspr_palloc(pool, + sizeof(fspr_procattr_t)); if ((*new) == NULL) { return APR_ENOMEM; @@ -44,65 +44,65 @@ APR_DECLARE(apr_status_t) apr_procattr_create(apr_procattr_t **new, apr_pool_t * return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_procattr_io_set(apr_procattr_t *attr, apr_int32_t in, - apr_int32_t out, apr_int32_t err) +APR_DECLARE(fspr_status_t) fspr_procattr_io_set(fspr_procattr_t *attr, fspr_int32_t in, + fspr_int32_t out, fspr_int32_t err) { - apr_status_t status; + fspr_status_t status; if (in != 0) { - if ((status = apr_file_pipe_create(&attr->child_in, &attr->parent_in, + if ((status = fspr_file_pipe_create(&attr->child_in, &attr->parent_in, attr->pool)) != APR_SUCCESS) { return status; } switch (in) { case APR_FULL_BLOCK: - apr_file_pipe_timeout_set(attr->child_in, -1); - apr_file_pipe_timeout_set(attr->parent_in, -1); + fspr_file_pipe_timeout_set(attr->child_in, -1); + fspr_file_pipe_timeout_set(attr->parent_in, -1); break; case APR_PARENT_BLOCK: - apr_file_pipe_timeout_set(attr->child_in, -1); + fspr_file_pipe_timeout_set(attr->child_in, -1); break; case APR_CHILD_BLOCK: - apr_file_pipe_timeout_set(attr->parent_in, -1); + fspr_file_pipe_timeout_set(attr->parent_in, -1); break; default: break; } } if (out) { - if ((status = apr_file_pipe_create(&attr->parent_out, &attr->child_out, + if ((status = fspr_file_pipe_create(&attr->parent_out, &attr->child_out, attr->pool)) != APR_SUCCESS) { return status; } switch (out) { case APR_FULL_BLOCK: - apr_file_pipe_timeout_set(attr->child_out, -1); - apr_file_pipe_timeout_set(attr->parent_out, -1); + fspr_file_pipe_timeout_set(attr->child_out, -1); + fspr_file_pipe_timeout_set(attr->parent_out, -1); break; case APR_PARENT_BLOCK: - apr_file_pipe_timeout_set(attr->child_out, -1); + fspr_file_pipe_timeout_set(attr->child_out, -1); break; case APR_CHILD_BLOCK: - apr_file_pipe_timeout_set(attr->parent_out, -1); + fspr_file_pipe_timeout_set(attr->parent_out, -1); break; default: break; } } if (err) { - if ((status = apr_file_pipe_create(&attr->parent_err, &attr->child_err, + if ((status = fspr_file_pipe_create(&attr->parent_err, &attr->child_err, attr->pool)) != APR_SUCCESS) { return status; } switch (err) { case APR_FULL_BLOCK: - apr_file_pipe_timeout_set(attr->child_err, -1); - apr_file_pipe_timeout_set(attr->parent_err, -1); + fspr_file_pipe_timeout_set(attr->child_err, -1); + fspr_file_pipe_timeout_set(attr->parent_err, -1); break; case APR_PARENT_BLOCK: - apr_file_pipe_timeout_set(attr->child_err, -1); + fspr_file_pipe_timeout_set(attr->child_err, -1); break; case APR_CHILD_BLOCK: - apr_file_pipe_timeout_set(attr->parent_err, -1); + fspr_file_pipe_timeout_set(attr->parent_err, -1); break; default: break; @@ -111,17 +111,17 @@ APR_DECLARE(apr_status_t) apr_procattr_io_set(apr_procattr_t *attr, apr_int32_t return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_procattr_dir_set(apr_procattr_t *attr, +APR_DECLARE(fspr_status_t) fspr_procattr_dir_set(fspr_procattr_t *attr, const char *dir) { char * cwd; if (dir[0] != '/') { cwd = (char*)malloc(sizeof(char) * PATH_MAX); getcwd(cwd, PATH_MAX); - attr->currdir = (char *)apr_pstrcat(attr->pool, cwd, "/", dir, NULL); + attr->currdir = (char *)fspr_pstrcat(attr->pool, cwd, "/", dir, NULL); free(cwd); } else { - attr->currdir = (char *)apr_pstrdup(attr->pool, dir); + attr->currdir = (char *)fspr_pstrdup(attr->pool, dir); } if (attr->currdir) { return APR_SUCCESS; @@ -129,20 +129,20 @@ APR_DECLARE(apr_status_t) apr_procattr_dir_set(apr_procattr_t *attr, return APR_ENOMEM; } -APR_DECLARE(apr_status_t) apr_procattr_cmdtype_set(apr_procattr_t *attr, - apr_cmdtype_e cmd) +APR_DECLARE(fspr_status_t) fspr_procattr_cmdtype_set(fspr_procattr_t *attr, + fspr_cmdtype_e cmd) { attr->cmdtype = cmd; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_procattr_detach_set(apr_procattr_t *attr, apr_int32_t detach) +APR_DECLARE(fspr_status_t) fspr_procattr_detach_set(fspr_procattr_t *attr, fspr_int32_t detach) { attr->detached = detach; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_proc_fork(apr_proc_t *proc, apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_proc_fork(fspr_proc_t *proc, fspr_pool_t *pool) { int pid; @@ -195,32 +195,32 @@ APR_DECLARE(apr_status_t) apr_proc_fork(apr_proc_t *proc, apr_pool_t *pool) return APR_INPARENT; } -APR_DECLARE(apr_status_t) apr_procattr_child_errfn_set(apr_procattr_t *attr, - apr_child_errfn_t *errfn) +APR_DECLARE(fspr_status_t) fspr_procattr_child_errfn_set(fspr_procattr_t *attr, + fspr_child_errfn_t *errfn) { /* won't ever be called on this platform, so don't save the function pointer */ return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_procattr_error_check_set(apr_procattr_t *attr, - apr_int32_t chk) +APR_DECLARE(fspr_status_t) fspr_procattr_error_check_set(fspr_procattr_t *attr, + fspr_int32_t chk) { /* won't ever be used on this platform, so don't save the flag */ return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_procattr_addrspace_set(apr_procattr_t *attr, - apr_int32_t addrspace) +APR_DECLARE(fspr_status_t) fspr_procattr_addrspace_set(fspr_procattr_t *attr, + fspr_int32_t addrspace) { /* won't ever be used on this platform, so don't save the flag */ return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, const char *progname, +APR_DECLARE(fspr_status_t) fspr_proc_create(fspr_proc_t *new, const char *progname, const char * const *args, const char * const *env, - apr_procattr_t *attr, - apr_pool_t *pool) + fspr_procattr_t *attr, + fspr_pool_t *pool) { int i=0,nargs=0; char **newargs = NULL; @@ -228,7 +228,7 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, const char *progname, struct send_pipe *sp; char * dir = NULL; - sp = (struct send_pipe *)apr_palloc(pool, sizeof(struct send_pipe)); + sp = (struct send_pipe *)fspr_palloc(pool, sizeof(struct send_pipe)); new->in = attr->parent_in; new->err = attr->parent_err; @@ -243,7 +243,7 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, const char *progname, } newargs = (char**)malloc(sizeof(char *) * (i + 4)); - newargs[0] = strdup("/boot/home/config/bin/apr_proc_stub"); + newargs[0] = strdup("/boot/home/config/bin/fspr_proc_stub"); if (attr->currdir == NULL) { /* we require the directory , so use a temp. variable */ dir = malloc(sizeof(char) * PATH_MAX); @@ -278,13 +278,13 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, const char *progname, resume_thread(newproc); if (attr->child_in) { - apr_file_close(attr->child_in); + fspr_file_close(attr->child_in); } if (attr->child_out) { - apr_file_close(attr->child_out); + fspr_file_close(attr->child_out); } if (attr->child_err) { - apr_file_close(attr->child_err); + fspr_file_close(attr->child_err); } send_data(newproc, 0, (void*)sp, sizeof(struct send_pipe)); @@ -298,26 +298,26 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, const char *progname, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_proc_wait_all_procs(apr_proc_t *proc, +APR_DECLARE(fspr_status_t) fspr_proc_wait_all_procs(fspr_proc_t *proc, int *exitcode, - apr_exit_why_e *exitwhy, - apr_wait_how_e waithow, - apr_pool_t *p) + fspr_exit_why_e *exitwhy, + fspr_wait_how_e waithow, + fspr_pool_t *p) { proc->pid = -1; - return apr_proc_wait(proc, exitcode, exitwhy, waithow); + return fspr_proc_wait(proc, exitcode, exitwhy, waithow); } -APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc, +APR_DECLARE(fspr_status_t) fspr_proc_wait(fspr_proc_t *proc, int *exitcode, - apr_exit_why_e *exitwhy, - apr_wait_how_e waithow) + fspr_exit_why_e *exitwhy, + fspr_wait_how_e waithow) { pid_t pstatus; int waitpid_options = WUNTRACED; int exit_int; int ignore; - apr_exit_why_e ignorewhy; + fspr_exit_why_e ignorewhy; if (exitcode == NULL) { exitcode = &ignore; @@ -354,65 +354,65 @@ APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc, return errno; } -APR_DECLARE(apr_status_t) apr_procattr_child_in_set(apr_procattr_t *attr, apr_file_t *child_in, - apr_file_t *parent_in) +APR_DECLARE(fspr_status_t) fspr_procattr_child_in_set(fspr_procattr_t *attr, fspr_file_t *child_in, + fspr_file_t *parent_in) { if (attr->child_in == NULL && attr->parent_in == NULL) - apr_file_pipe_create(&attr->child_in, &attr->parent_in, attr->pool); + fspr_file_pipe_create(&attr->child_in, &attr->parent_in, attr->pool); if (child_in != NULL) - apr_file_dup(&attr->child_in, child_in, attr->pool); + fspr_file_dup(&attr->child_in, child_in, attr->pool); if (parent_in != NULL) - apr_file_dup(&attr->parent_in, parent_in, attr->pool); + fspr_file_dup(&attr->parent_in, parent_in, attr->pool); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_procattr_child_out_set(apr_procattr_t *attr, apr_file_t *child_out, - apr_file_t *parent_out) +APR_DECLARE(fspr_status_t) fspr_procattr_child_out_set(fspr_procattr_t *attr, fspr_file_t *child_out, + fspr_file_t *parent_out) { if (attr->child_out == NULL && attr->parent_out == NULL) - apr_file_pipe_create(&attr->child_out, &attr->parent_out, attr->pool); + fspr_file_pipe_create(&attr->child_out, &attr->parent_out, attr->pool); if (child_out != NULL) - apr_file_dup(&attr->child_out, child_out, attr->pool); + fspr_file_dup(&attr->child_out, child_out, attr->pool); if (parent_out != NULL) - apr_file_dup(&attr->parent_out, parent_out, attr->pool); + fspr_file_dup(&attr->parent_out, parent_out, attr->pool); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_procattr_child_err_set(apr_procattr_t *attr, apr_file_t *child_err, - apr_file_t *parent_err) +APR_DECLARE(fspr_status_t) fspr_procattr_child_err_set(fspr_procattr_t *attr, fspr_file_t *child_err, + fspr_file_t *parent_err) { if (attr->child_err == NULL && attr->parent_err == NULL) - apr_file_pipe_create(&attr->child_err, &attr->parent_err, attr->pool); + fspr_file_pipe_create(&attr->child_err, &attr->parent_err, attr->pool); if (child_err != NULL) - apr_file_dup(&attr->child_err, child_err, attr->pool); + fspr_file_dup(&attr->child_err, child_err, attr->pool); if (parent_err != NULL) - apr_file_dup(&attr->parent_err, parent_err, attr->pool); + fspr_file_dup(&attr->parent_err, parent_err, attr->pool); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_procattr_limit_set(apr_procattr_t *attr, apr_int32_t what, +APR_DECLARE(fspr_status_t) fspr_procattr_limit_set(fspr_procattr_t *attr, fspr_int32_t what, void *limit) { return APR_ENOTIMPL; } -APR_DECLARE(apr_status_t) apr_procattr_user_set(apr_procattr_t *attr, +APR_DECLARE(fspr_status_t) fspr_procattr_user_set(fspr_procattr_t *attr, const char *username, const char *password) { return APR_ENOTIMPL; } -APR_DECLARE(apr_status_t) apr_procattr_group_set(apr_procattr_t *attr, +APR_DECLARE(fspr_status_t) fspr_procattr_group_set(fspr_procattr_t *attr, const char *groupname) { return APR_ENOTIMPL; diff --git a/libs/apr/threadproc/beos/thread.c b/libs/apr/threadproc/beos/thread.c index 629c86def7..79248cc0c5 100644 --- a/libs/apr/threadproc/beos/thread.c +++ b/libs/apr/threadproc/beos/thread.c @@ -14,13 +14,13 @@ * limitations under the License. */ -#include "apr_arch_threadproc.h" -#include "apr_portable.h" +#include "fspr_arch_threadproc.h" +#include "fspr_portable.h" -APR_DECLARE(apr_status_t) apr_threadattr_create(apr_threadattr_t **new, apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_threadattr_create(fspr_threadattr_t **new, fspr_pool_t *pool) { - (*new) = (apr_threadattr_t *)apr_palloc(pool, - sizeof(apr_threadattr_t)); + (*new) = (fspr_threadattr_t *)fspr_palloc(pool, + sizeof(fspr_threadattr_t)); if ((*new) == NULL) { return APR_ENOMEM; @@ -32,7 +32,7 @@ APR_DECLARE(apr_status_t) apr_threadattr_create(apr_threadattr_t **new, apr_pool return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_threadattr_detach_set(apr_threadattr_t *attr, apr_int32_t on) +APR_DECLARE(fspr_status_t) fspr_threadattr_detach_set(fspr_threadattr_t *attr, fspr_int32_t on) { if (on == 1){ attr->detached = 1; @@ -42,7 +42,7 @@ APR_DECLARE(apr_status_t) apr_threadattr_detach_set(apr_threadattr_t *attr, apr_ return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_threadattr_detach_get(apr_threadattr_t *attr) +APR_DECLARE(fspr_status_t) fspr_threadattr_detach_get(fspr_threadattr_t *attr) { if (attr->detached == 1){ return APR_DETACH; @@ -50,32 +50,32 @@ APR_DECLARE(apr_status_t) apr_threadattr_detach_get(apr_threadattr_t *attr) return APR_NOTDETACH; } -APR_DECLARE(apr_status_t) apr_threadattr_stacksize_set(apr_threadattr_t *attr, - apr_size_t stacksize) +APR_DECLARE(fspr_status_t) fspr_threadattr_stacksize_set(fspr_threadattr_t *attr, + fspr_size_t stacksize) { return APR_ENOTIMPL; } -APR_DECLARE(apr_status_t) apr_threadattr_guardsize_set(apr_threadattr_t *attr, - apr_size_t size) +APR_DECLARE(fspr_status_t) fspr_threadattr_guardsize_set(fspr_threadattr_t *attr, + fspr_size_t size) { return APR_ENOTIMPL; } static void *dummy_worker(void *opaque) { - apr_thread_t *thd = (apr_thread_t*)opaque; + fspr_thread_t *thd = (fspr_thread_t*)opaque; return thd->func(thd, thd->data); } -APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new, apr_threadattr_t *attr, - apr_thread_start_t func, void *data, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_thread_create(fspr_thread_t **new, fspr_threadattr_t *attr, + fspr_thread_start_t func, void *data, + fspr_pool_t *pool) { int32 temp; - apr_status_t stat; + fspr_status_t stat; - (*new) = (apr_thread_t *)apr_palloc(pool, sizeof(apr_thread_t)); + (*new) = (fspr_thread_t *)fspr_palloc(pool, sizeof(fspr_thread_t)); if ((*new) == NULL) { return APR_ENOMEM; } @@ -91,7 +91,7 @@ APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new, apr_threadattr_t else temp = B_NORMAL_PRIORITY; - stat = apr_pool_create(&(*new)->pool, pool); + stat = fspr_pool_create(&(*new)->pool, pool); if (stat != APR_SUCCESS) { return stat; } @@ -110,26 +110,26 @@ APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new, apr_threadattr_t } } -APR_DECLARE(apr_os_thread_t) apr_os_thread_current(void) +APR_DECLARE(fspr_os_thread_t) fspr_os_thread_current(void) { return find_thread(NULL); } -int apr_os_thread_equal(apr_os_thread_t tid1, apr_os_thread_t tid2) +int fspr_os_thread_equal(fspr_os_thread_t tid1, fspr_os_thread_t tid2) { return tid1 == tid2; } -APR_DECLARE(apr_status_t) apr_thread_exit(apr_thread_t *thd, apr_status_t retval) +APR_DECLARE(fspr_status_t) fspr_thread_exit(fspr_thread_t *thd, fspr_status_t retval) { - apr_pool_destroy(thd->pool); + fspr_pool_destroy(thd->pool); thd->exitval = retval; exit_thread ((status_t)(retval)); /* This will never be reached... */ return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_join(apr_status_t *retval, apr_thread_t *thd) +APR_DECLARE(fspr_status_t) fspr_thread_join(fspr_status_t *retval, fspr_thread_t *thd) { status_t rv = 0, ret; ret = wait_for_thread(thd->td, &rv); @@ -149,7 +149,7 @@ APR_DECLARE(apr_status_t) apr_thread_join(apr_status_t *retval, apr_thread_t *th } } -APR_DECLARE(apr_status_t) apr_thread_detach(apr_thread_t *thd) +APR_DECLARE(fspr_status_t) fspr_thread_detach(fspr_thread_t *thd) { if (suspend_thread(thd->td) == B_NO_ERROR){ return APR_SUCCESS; @@ -159,45 +159,45 @@ APR_DECLARE(apr_status_t) apr_thread_detach(apr_thread_t *thd) } } -void apr_thread_yield() +void fspr_thread_yield() { } -APR_DECLARE(apr_status_t) apr_thread_data_get(void **data, const char *key, apr_thread_t *thread) +APR_DECLARE(fspr_status_t) fspr_thread_data_get(void **data, const char *key, fspr_thread_t *thread) { - return apr_pool_userdata_get(data, key, thread->pool); + return fspr_pool_userdata_get(data, key, thread->pool); } -APR_DECLARE(apr_status_t) apr_thread_data_set(void *data, const char *key, - apr_status_t (*cleanup) (void *), - apr_thread_t *thread) +APR_DECLARE(fspr_status_t) fspr_thread_data_set(void *data, const char *key, + fspr_status_t (*cleanup) (void *), + fspr_thread_t *thread) { - return apr_pool_userdata_set(data, key, cleanup, thread->pool); + return fspr_pool_userdata_set(data, key, cleanup, thread->pool); } -APR_DECLARE(apr_status_t) apr_os_thread_get(apr_os_thread_t **thethd, apr_thread_t *thd) +APR_DECLARE(fspr_status_t) fspr_os_thread_get(fspr_os_thread_t **thethd, fspr_thread_t *thd) { *thethd = &thd->td; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_os_thread_put(apr_thread_t **thd, apr_os_thread_t *thethd, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_os_thread_put(fspr_thread_t **thd, fspr_os_thread_t *thethd, + fspr_pool_t *pool) { if (pool == NULL) { return APR_ENOPOOL; } if ((*thd) == NULL) { - (*thd) = (apr_thread_t *)apr_pcalloc(pool, sizeof(apr_thread_t)); + (*thd) = (fspr_thread_t *)fspr_pcalloc(pool, sizeof(fspr_thread_t)); (*thd)->pool = pool; } (*thd)->td = *thethd; return APR_SUCCESS; } -static apr_status_t thread_once_cleanup(void *vcontrol) +static fspr_status_t thread_once_cleanup(void *vcontrol) { - apr_thread_once_t *control = (apr_thread_once_t *)vcontrol; + fspr_thread_once_t *control = (fspr_thread_once_t *)vcontrol; if (control->sem) { release_sem(control->sem); @@ -207,23 +207,23 @@ static apr_status_t thread_once_cleanup(void *vcontrol) return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_once_init(apr_thread_once_t **control, - apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_thread_once_init(fspr_thread_once_t **control, + fspr_pool_t *p) { int rc; - *control = (apr_thread_once_t *)apr_pcalloc(p, sizeof(apr_thread_once_t)); + *control = (fspr_thread_once_t *)fspr_pcalloc(p, sizeof(fspr_thread_once_t)); (*control)->hit = 0; /* we haven't done it yet... */ rc = ((*control)->sem = create_sem(1, "thread_once")); if (rc < 0) return rc; - apr_pool_cleanup_register(p, control, thread_once_cleanup, apr_pool_cleanup_null); + fspr_pool_cleanup_register(p, control, thread_once_cleanup, fspr_pool_cleanup_null); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_once(apr_thread_once_t *control, +APR_DECLARE(fspr_status_t) fspr_thread_once(fspr_thread_once_t *control, void (*func)(void)) { if (!control->hit) { diff --git a/libs/apr/threadproc/beos/threadpriv.c b/libs/apr/threadproc/beos/threadpriv.c index 442235f7dd..a50d62caa6 100644 --- a/libs/apr/threadproc/beos/threadpriv.c +++ b/libs/apr/threadproc/beos/threadpriv.c @@ -14,16 +14,16 @@ * limitations under the License. */ -#include "apr_arch_threadproc.h" +#include "fspr_arch_threadproc.h" static struct beos_key key_table[BEOS_MAX_DATAKEYS]; static struct beos_private_data *beos_data[BEOS_MAX_DATAKEYS]; static sem_id lock; -APR_DECLARE(apr_status_t) apr_threadkey_private_create(apr_threadkey_t **key, - void (*dest)(void *), apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_threadkey_private_create(fspr_threadkey_t **key, + void (*dest)(void *), fspr_pool_t *pool) { - (*key) = (apr_threadkey_t *)apr_palloc(pool, sizeof(apr_threadkey_t)); + (*key) = (fspr_threadkey_t *)fspr_palloc(pool, sizeof(fspr_threadkey_t)); if ((*key) == NULL) { return APR_ENOMEM; } @@ -44,7 +44,7 @@ APR_DECLARE(apr_status_t) apr_threadkey_private_create(apr_threadkey_t **key, return APR_ENOMEM; } -APR_DECLARE(apr_status_t) apr_threadkey_private_get(void **new, apr_threadkey_t *key) +APR_DECLARE(fspr_status_t) fspr_threadkey_private_get(void **new, fspr_threadkey_t *key) { thread_id tid; int i, index=0; @@ -76,7 +76,7 @@ APR_DECLARE(apr_status_t) apr_threadkey_private_get(void **new, apr_threadkey_t return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_threadkey_private_set(void *priv, apr_threadkey_t *key) +APR_DECLARE(fspr_status_t) fspr_threadkey_private_set(void *priv, fspr_threadkey_t *key) { thread_id tid; int i,index = 0, ret = 0; @@ -131,7 +131,7 @@ APR_DECLARE(apr_status_t) apr_threadkey_private_set(void *priv, apr_threadkey_t return APR_ENOMEM; } -APR_DECLARE(apr_status_t) apr_threadkey_private_delete(apr_threadkey_t *key) +APR_DECLARE(fspr_status_t) fspr_threadkey_private_delete(fspr_threadkey_t *key) { if (key->key < BEOS_MAX_DATAKEYS){ acquire_sem(key_table[key->key].lock); @@ -146,33 +146,33 @@ APR_DECLARE(apr_status_t) apr_threadkey_private_delete(apr_threadkey_t *key) return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_threadkey_data_get(void **data, const char *key, - apr_threadkey_t *threadkey) +APR_DECLARE(fspr_status_t) fspr_threadkey_data_get(void **data, const char *key, + fspr_threadkey_t *threadkey) { - return apr_pool_userdata_get(data, key, threadkey->pool); + return fspr_pool_userdata_get(data, key, threadkey->pool); } -APR_DECLARE(apr_status_t) apr_threadkey_data_set(void *data, const char *key, - apr_status_t (*cleanup) (void *), - apr_threadkey_t *threadkey) +APR_DECLARE(fspr_status_t) fspr_threadkey_data_set(void *data, const char *key, + fspr_status_t (*cleanup) (void *), + fspr_threadkey_t *threadkey) { - return apr_pool_userdata_set(data, key, cleanup, threadkey->pool); + return fspr_pool_userdata_set(data, key, cleanup, threadkey->pool); } -APR_DECLARE(apr_status_t) apr_os_threadkey_get(apr_os_threadkey_t *thekey, apr_threadkey_t *key) +APR_DECLARE(fspr_status_t) fspr_os_threadkey_get(fspr_os_threadkey_t *thekey, fspr_threadkey_t *key) { *thekey = key->key; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_os_threadkey_put(apr_threadkey_t **key, - apr_os_threadkey_t *thekey, apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_os_threadkey_put(fspr_threadkey_t **key, + fspr_os_threadkey_t *thekey, fspr_pool_t *pool) { if (pool == NULL) { return APR_ENOPOOL; } if ((*key) == NULL) { - (*key) = (apr_threadkey_t *)apr_pcalloc(pool, sizeof(apr_threadkey_t)); + (*key) = (fspr_threadkey_t *)fspr_pcalloc(pool, sizeof(fspr_threadkey_t)); (*key)->pool = pool; } (*key)->key = *thekey; diff --git a/libs/apr/threadproc/netware/proc.c b/libs/apr/threadproc/netware/proc.c index 0f70776999..58fb147453 100644 --- a/libs/apr/threadproc/netware/proc.c +++ b/libs/apr/threadproc/netware/proc.c @@ -14,16 +14,16 @@ * limitations under the License. */ -#include "apr_arch_threadproc.h" -#include "apr_arch_file_io.h" -#include "apr_strings.h" -#include "apr_portable.h" +#include "fspr_arch_threadproc.h" +#include "fspr_arch_file_io.h" +#include "fspr_strings.h" +#include "fspr_portable.h" #include -apr_status_t apr_netware_proc_cleanup(void *theproc) +fspr_status_t fspr_netware_proc_cleanup(void *theproc) { - apr_proc_t *proc = theproc; + fspr_proc_t *proc = theproc; int exit_int; int waitpid_options = WUNTRACED | WNOHANG; @@ -35,9 +35,9 @@ apr_status_t apr_netware_proc_cleanup(void *theproc) return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_procattr_create(apr_procattr_t **new,apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_procattr_create(fspr_procattr_t **new,fspr_pool_t *pool) { - (*new) = (apr_procattr_t *)apr_pcalloc(pool, sizeof(apr_procattr_t)); + (*new) = (fspr_procattr_t *)fspr_pcalloc(pool, sizeof(fspr_procattr_t)); if ((*new) == NULL) { return APR_ENOMEM; @@ -45,18 +45,18 @@ APR_DECLARE(apr_status_t) apr_procattr_create(apr_procattr_t **new,apr_pool_t *p (*new)->pool = pool; (*new)->cmdtype = APR_PROGRAM; /* Default to a current path since NetWare doesn't handle it very well */ - apr_filepath_get(&((*new)->currdir), APR_FILEPATH_NATIVE, pool); + fspr_filepath_get(&((*new)->currdir), APR_FILEPATH_NATIVE, pool); (*new)->detached = 1; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_procattr_io_set(apr_procattr_t *attr, apr_int32_t in, - apr_int32_t out, apr_int32_t err) +APR_DECLARE(fspr_status_t) fspr_procattr_io_set(fspr_procattr_t *attr, fspr_int32_t in, + fspr_int32_t out, fspr_int32_t err) { - apr_status_t status; + fspr_status_t status; if (in != 0) { - if ((status = apr_file_pipe_create(&attr->child_in, &attr->parent_in, + if ((status = fspr_file_pipe_create(&attr->child_in, &attr->parent_in, attr->pool)) != APR_SUCCESS) { return status; } @@ -64,18 +64,18 @@ APR_DECLARE(apr_status_t) apr_procattr_io_set(apr_procattr_t *attr, apr_int32_t case APR_FULL_BLOCK: break; case APR_PARENT_BLOCK: - apr_file_pipe_timeout_set(attr->child_in, 0); + fspr_file_pipe_timeout_set(attr->child_in, 0); break; case APR_CHILD_BLOCK: - apr_file_pipe_timeout_set(attr->parent_in, 0); + fspr_file_pipe_timeout_set(attr->parent_in, 0); break; default: - apr_file_pipe_timeout_set(attr->child_in, 0); - apr_file_pipe_timeout_set(attr->parent_in, 0); + fspr_file_pipe_timeout_set(attr->child_in, 0); + fspr_file_pipe_timeout_set(attr->parent_in, 0); } } if (out) { - if ((status = apr_file_pipe_create(&attr->parent_out, &attr->child_out, + if ((status = fspr_file_pipe_create(&attr->parent_out, &attr->child_out, attr->pool)) != APR_SUCCESS) { return status; } @@ -83,18 +83,18 @@ APR_DECLARE(apr_status_t) apr_procattr_io_set(apr_procattr_t *attr, apr_int32_t case APR_FULL_BLOCK: break; case APR_PARENT_BLOCK: - apr_file_pipe_timeout_set(attr->child_out, 0); + fspr_file_pipe_timeout_set(attr->child_out, 0); break; case APR_CHILD_BLOCK: - apr_file_pipe_timeout_set(attr->parent_out, 0); + fspr_file_pipe_timeout_set(attr->parent_out, 0); break; default: - apr_file_pipe_timeout_set(attr->child_out, 0); - apr_file_pipe_timeout_set(attr->parent_out, 0); + fspr_file_pipe_timeout_set(attr->child_out, 0); + fspr_file_pipe_timeout_set(attr->parent_out, 0); } } if (err) { - if ((status = apr_file_pipe_create(&attr->parent_err, &attr->child_err, + if ((status = fspr_file_pipe_create(&attr->parent_err, &attr->child_err, attr->pool)) != APR_SUCCESS) { return status; } @@ -102,90 +102,90 @@ APR_DECLARE(apr_status_t) apr_procattr_io_set(apr_procattr_t *attr, apr_int32_t case APR_FULL_BLOCK: break; case APR_PARENT_BLOCK: - apr_file_pipe_timeout_set(attr->child_err, 0); + fspr_file_pipe_timeout_set(attr->child_err, 0); break; case APR_CHILD_BLOCK: - apr_file_pipe_timeout_set(attr->parent_err, 0); + fspr_file_pipe_timeout_set(attr->parent_err, 0); break; default: - apr_file_pipe_timeout_set(attr->child_err, 0); - apr_file_pipe_timeout_set(attr->parent_err, 0); + fspr_file_pipe_timeout_set(attr->child_err, 0); + fspr_file_pipe_timeout_set(attr->parent_err, 0); } } return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_procattr_child_in_set(apr_procattr_t *attr, apr_file_t *child_in, - apr_file_t *parent_in) +APR_DECLARE(fspr_status_t) fspr_procattr_child_in_set(fspr_procattr_t *attr, fspr_file_t *child_in, + fspr_file_t *parent_in) { if (attr->child_in == NULL && attr->parent_in == NULL) - apr_file_pipe_create(&attr->child_in, &attr->parent_in, attr->pool); + fspr_file_pipe_create(&attr->child_in, &attr->parent_in, attr->pool); if (child_in != NULL) - apr_file_dup2(attr->child_in, child_in, attr->pool); + fspr_file_dup2(attr->child_in, child_in, attr->pool); if (parent_in != NULL) - apr_file_dup2(attr->parent_in, parent_in, attr->pool); + fspr_file_dup2(attr->parent_in, parent_in, attr->pool); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_procattr_child_out_set(apr_procattr_t *attr, apr_file_t *child_out, - apr_file_t *parent_out) +APR_DECLARE(fspr_status_t) fspr_procattr_child_out_set(fspr_procattr_t *attr, fspr_file_t *child_out, + fspr_file_t *parent_out) { if (attr->child_out == NULL && attr->parent_out == NULL) - apr_file_pipe_create(&attr->child_out, &attr->parent_out, attr->pool); + fspr_file_pipe_create(&attr->child_out, &attr->parent_out, attr->pool); if (child_out != NULL) - apr_file_dup2(attr->child_out, child_out, attr->pool); + fspr_file_dup2(attr->child_out, child_out, attr->pool); if (parent_out != NULL) - apr_file_dup2(attr->parent_out, parent_out, attr->pool); + fspr_file_dup2(attr->parent_out, parent_out, attr->pool); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_procattr_child_err_set(apr_procattr_t *attr, apr_file_t *child_err, - apr_file_t *parent_err) +APR_DECLARE(fspr_status_t) fspr_procattr_child_err_set(fspr_procattr_t *attr, fspr_file_t *child_err, + fspr_file_t *parent_err) { if (attr->child_err == NULL && attr->parent_err == NULL) - apr_file_pipe_create(&attr->child_err, &attr->parent_err, attr->pool); + fspr_file_pipe_create(&attr->child_err, &attr->parent_err, attr->pool); if (child_err != NULL) - apr_file_dup2(attr->child_err, child_err, attr->pool); + fspr_file_dup2(attr->child_err, child_err, attr->pool); if (parent_err != NULL) - apr_file_dup2(attr->parent_err, parent_err, attr->pool); + fspr_file_dup2(attr->parent_err, parent_err, attr->pool); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_procattr_dir_set(apr_procattr_t *attr, +APR_DECLARE(fspr_status_t) fspr_procattr_dir_set(fspr_procattr_t *attr, const char *dir) { - return apr_filepath_merge(&attr->currdir, NULL, dir, + return fspr_filepath_merge(&attr->currdir, NULL, dir, APR_FILEPATH_NATIVE, attr->pool); } -APR_DECLARE(apr_status_t) apr_procattr_cmdtype_set(apr_procattr_t *attr, - apr_cmdtype_e cmd) +APR_DECLARE(fspr_status_t) fspr_procattr_cmdtype_set(fspr_procattr_t *attr, + fspr_cmdtype_e cmd) { /* won't ever be called on this platform, so don't save the function pointer */ return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_procattr_detach_set(apr_procattr_t *attr, apr_int32_t detach) +APR_DECLARE(fspr_status_t) fspr_procattr_detach_set(fspr_procattr_t *attr, fspr_int32_t detach) { attr->detached = detach; return APR_SUCCESS; } #if APR_HAS_FORK -APR_DECLARE(apr_status_t) apr_proc_fork(apr_proc_t *proc, apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_proc_fork(fspr_proc_t *proc, fspr_pool_t *pool) { int pid; @@ -207,7 +207,7 @@ APR_DECLARE(apr_status_t) apr_proc_fork(apr_proc_t *proc, apr_pool_t *pool) } #endif -static apr_status_t limit_proc(apr_procattr_t *attr) +static fspr_status_t limit_proc(fspr_procattr_t *attr) { #if APR_HAVE_STRUCT_RLIMIT && APR_HAVE_SETRLIMIT #ifdef RLIMIT_CPU @@ -252,33 +252,33 @@ static apr_status_t limit_proc(apr_procattr_t *attr) return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_procattr_child_errfn_set(apr_procattr_t *attr, - apr_child_errfn_t *errfn) +APR_DECLARE(fspr_status_t) fspr_procattr_child_errfn_set(fspr_procattr_t *attr, + fspr_child_errfn_t *errfn) { /* won't ever be called on this platform, so don't save the function pointer */ return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_procattr_error_check_set(apr_procattr_t *attr, - apr_int32_t chk) +APR_DECLARE(fspr_status_t) fspr_procattr_error_check_set(fspr_procattr_t *attr, + fspr_int32_t chk) { /* won't ever be used on this platform, so don't save the flag */ return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_procattr_addrspace_set(apr_procattr_t *attr, - apr_int32_t addrspace) +APR_DECLARE(fspr_status_t) fspr_procattr_addrspace_set(fspr_procattr_t *attr, + fspr_int32_t addrspace) { attr->addrspace = addrspace; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *newproc, +APR_DECLARE(fspr_status_t) fspr_proc_create(fspr_proc_t *newproc, const char *progname, const char * const *args, const char * const *env, - apr_procattr_t *attr, - apr_pool_t *pool) + fspr_procattr_t *attr, + fspr_pool_t *pool) { wiring_t wire; int addr_space; @@ -299,9 +299,9 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *newproc, if (attr->currdir) { char *fullpath = NULL; - apr_status_t rv; + fspr_status_t rv; - if ((rv = apr_filepath_merge(&fullpath, attr->currdir, progname, + if ((rv = fspr_filepath_merge(&fullpath, attr->currdir, progname, APR_FILEPATH_NATIVE, pool)) != APR_SUCCESS) { return rv; } @@ -314,47 +314,47 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *newproc, } if (attr->child_in) { - apr_pool_cleanup_kill(apr_file_pool_get(attr->child_in), - attr->child_in, apr_unix_file_cleanup); - apr_file_close(attr->child_in); + fspr_pool_cleanup_kill(fspr_file_pool_get(attr->child_in), + attr->child_in, fspr_unix_file_cleanup); + fspr_file_close(attr->child_in); } if (attr->child_out) { - apr_pool_cleanup_kill(apr_file_pool_get(attr->child_out), - attr->child_out, apr_unix_file_cleanup); - apr_file_close(attr->child_out); + fspr_pool_cleanup_kill(fspr_file_pool_get(attr->child_out), + attr->child_out, fspr_unix_file_cleanup); + fspr_file_close(attr->child_out); } if (attr->child_err) { - apr_pool_cleanup_kill(apr_file_pool_get(attr->child_err), - attr->child_err, apr_unix_file_cleanup); - apr_file_close(attr->child_err); + fspr_pool_cleanup_kill(fspr_file_pool_get(attr->child_err), + attr->child_err, fspr_unix_file_cleanup); + fspr_file_close(attr->child_err); } - apr_pool_cleanup_register(pool, (void *)newproc, apr_netware_proc_cleanup, - apr_pool_cleanup_null); + fspr_pool_cleanup_register(pool, (void *)newproc, fspr_netware_proc_cleanup, + fspr_pool_cleanup_null); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_proc_wait_all_procs(apr_proc_t *proc, +APR_DECLARE(fspr_status_t) fspr_proc_wait_all_procs(fspr_proc_t *proc, int *exitcode, - apr_exit_why_e *exitwhy, - apr_wait_how_e waithow, - apr_pool_t *p) + fspr_exit_why_e *exitwhy, + fspr_wait_how_e waithow, + fspr_pool_t *p) { proc->pid = -1; - return apr_proc_wait(proc, exitcode, exitwhy, waithow); + return fspr_proc_wait(proc, exitcode, exitwhy, waithow); } -APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc, - int *exitcode, apr_exit_why_e *exitwhy, - apr_wait_how_e waithow) +APR_DECLARE(fspr_status_t) fspr_proc_wait(fspr_proc_t *proc, + int *exitcode, fspr_exit_why_e *exitwhy, + fspr_wait_how_e waithow) { pid_t pstatus; int waitpid_options = WUNTRACED; int exit_int; int ignore; - apr_exit_why_e ignorewhy; + fspr_exit_why_e ignorewhy; if (exitcode == NULL) { exitcode = &ignore; @@ -407,7 +407,7 @@ APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc, return errno; } -APR_DECLARE(apr_status_t) apr_procattr_limit_set(apr_procattr_t *attr, apr_int32_t what, +APR_DECLARE(fspr_status_t) fspr_procattr_limit_set(fspr_procattr_t *attr, fspr_int32_t what, struct rlimit *limit) { switch(what) { @@ -436,7 +436,7 @@ APR_DECLARE(apr_status_t) apr_procattr_limit_set(apr_procattr_t *attr, apr_int32 return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_procattr_user_set(apr_procattr_t *attr, +APR_DECLARE(fspr_status_t) fspr_procattr_user_set(fspr_procattr_t *attr, const char *username, const char *password) { @@ -444,7 +444,7 @@ APR_DECLARE(apr_status_t) apr_procattr_user_set(apr_procattr_t *attr, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_procattr_group_set(apr_procattr_t *attr, +APR_DECLARE(fspr_status_t) fspr_procattr_group_set(fspr_procattr_t *attr, const char *groupname) { /* Always return SUCCESS because NetWare threads don't run within a group */ diff --git a/libs/apr/threadproc/netware/procsup.c b/libs/apr/threadproc/netware/procsup.c index 72fa1d9764..07b67f65c8 100644 --- a/libs/apr/threadproc/netware/procsup.c +++ b/libs/apr/threadproc/netware/procsup.c @@ -14,9 +14,9 @@ * limitations under the License. */ -#include "apr_arch_threadproc.h" +#include "fspr_arch_threadproc.h" -apr_status_t apr_proc_detach(int daemonize) +fspr_status_t fspr_proc_detach(int daemonize) { #if 0 int x; diff --git a/libs/apr/threadproc/netware/signals.c b/libs/apr/threadproc/netware/signals.c index bc660af7dc..a50519a0e6 100644 --- a/libs/apr/threadproc/netware/signals.c +++ b/libs/apr/threadproc/netware/signals.c @@ -14,29 +14,29 @@ * limitations under the License. */ -#include "apr_arch_threadproc.h" +#include "fspr_arch_threadproc.h" #include -#include "apr_private.h" -#include "apr_pools.h" -#include "apr_signal.h" -#include "apr_strings.h" +#include "fspr_private.h" +#include "fspr_pools.h" +#include "fspr_signal.h" +#include "fspr_strings.h" #include #if APR_HAS_THREADS && APR_HAVE_PTHREAD_H #include #endif -APR_DECLARE(apr_status_t) apr_proc_kill(apr_proc_t *proc, int signum) +APR_DECLARE(fspr_status_t) fspr_proc_kill(fspr_proc_t *proc, int signum) { return APR_ENOTIMPL; } -void apr_signal_init(apr_pool_t *pglobal) +void fspr_signal_init(fspr_pool_t *pglobal) { } -const char *apr_signal_description_get(int signum) +const char *fspr_signal_description_get(int signum) { switch (signum) { @@ -64,19 +64,19 @@ static void *signal_thread_func(void *signal_handler) return NULL; } -APR_DECLARE(apr_status_t) apr_setup_signal_thread(void) +APR_DECLARE(fspr_status_t) fspr_setup_signal_thread(void) { int rv = 0; return rv; } -APR_DECLARE(apr_status_t) apr_signal_block(int signum) +APR_DECLARE(fspr_status_t) fspr_signal_block(int signum) { return APR_ENOTIMPL; } -APR_DECLARE(apr_status_t) apr_signal_unblock(int signum) +APR_DECLARE(fspr_status_t) fspr_signal_unblock(int signum) { return APR_ENOTIMPL; } diff --git a/libs/apr/threadproc/netware/thread.c b/libs/apr/threadproc/netware/thread.c index dcf4993db9..6bcddac2c2 100644 --- a/libs/apr/threadproc/netware/thread.c +++ b/libs/apr/threadproc/netware/thread.c @@ -14,18 +14,18 @@ * limitations under the License. */ -#include "apr.h" -#include "apr_portable.h" -#include "apr_strings.h" -#include "apr_arch_threadproc.h" +#include "fspr.h" +#include "fspr_portable.h" +#include "fspr_strings.h" +#include "fspr_arch_threadproc.h" static int thread_count = 0; -apr_status_t apr_threadattr_create(apr_threadattr_t **new, - apr_pool_t *pool) +fspr_status_t fspr_threadattr_create(fspr_threadattr_t **new, + fspr_pool_t *pool) { - (*new) = (apr_threadattr_t *)apr_palloc(pool, - sizeof(apr_threadattr_t)); + (*new) = (fspr_threadattr_t *)fspr_palloc(pool, + sizeof(fspr_threadattr_t)); if ((*new) == NULL) { return APR_ENOMEM; @@ -38,45 +38,45 @@ apr_status_t apr_threadattr_create(apr_threadattr_t **new, return APR_SUCCESS; } -apr_status_t apr_threadattr_detach_set(apr_threadattr_t *attr,apr_int32_t on) +fspr_status_t fspr_threadattr_detach_set(fspr_threadattr_t *attr,fspr_int32_t on) { attr->detach = on; return APR_SUCCESS; } -apr_status_t apr_threadattr_detach_get(apr_threadattr_t *attr) +fspr_status_t fspr_threadattr_detach_get(fspr_threadattr_t *attr) { if (attr->detach == 1) return APR_DETACH; return APR_NOTDETACH; } -APR_DECLARE(apr_status_t) apr_threadattr_stacksize_set(apr_threadattr_t *attr, - apr_size_t stacksize) +APR_DECLARE(fspr_status_t) fspr_threadattr_stacksize_set(fspr_threadattr_t *attr, + fspr_size_t stacksize) { attr->stack_size = stacksize; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_threadattr_guardsize_set(apr_threadattr_t *attr, - apr_size_t size) +APR_DECLARE(fspr_status_t) fspr_threadattr_guardsize_set(fspr_threadattr_t *attr, + fspr_size_t size) { return APR_ENOTIMPL; } static void *dummy_worker(void *opaque) { - apr_thread_t *thd = (apr_thread_t *)opaque; + fspr_thread_t *thd = (fspr_thread_t *)opaque; return thd->func(thd, thd->data); } -apr_status_t apr_thread_create(apr_thread_t **new, - apr_threadattr_t *attr, - apr_thread_start_t func, +fspr_status_t fspr_thread_create(fspr_thread_t **new, + fspr_threadattr_t *attr, + fspr_thread_start_t func, void *data, - apr_pool_t *pool) + fspr_pool_t *pool) { - apr_status_t stat; + fspr_status_t stat; long flags = NX_THR_BIND_CONTEXT; char threadName[NX_MAX_OBJECT_NAME_LEN+1]; size_t stack_size = APR_DEFAULT_STACK_SIZE; @@ -97,7 +97,7 @@ apr_status_t apr_thread_create(apr_thread_t **new, stack_size = attr->stack_size; } - (*new) = (apr_thread_t *)apr_palloc(pool, sizeof(apr_thread_t)); + (*new) = (fspr_thread_t *)fspr_palloc(pool, sizeof(fspr_thread_t)); if ((*new) == NULL) { return APR_ENOMEM; @@ -106,9 +106,9 @@ apr_status_t apr_thread_create(apr_thread_t **new, (*new)->pool = pool; (*new)->data = data; (*new)->func = func; - (*new)->thread_name = (char*)apr_pstrdup(pool, threadName); + (*new)->thread_name = (char*)fspr_pstrdup(pool, threadName); - stat = apr_pool_create(&(*new)->pool, pool); + stat = fspr_pool_create(&(*new)->pool, pool); if (stat != APR_SUCCESS) { return stat; } @@ -141,34 +141,34 @@ apr_status_t apr_thread_create(apr_thread_t **new, return(stat);// if error } -apr_os_thread_t apr_os_thread_current() +fspr_os_thread_t fspr_os_thread_current() { return NXThreadGetId(); } -int apr_os_thread_equal(apr_os_thread_t tid1, apr_os_thread_t tid2) +int fspr_os_thread_equal(fspr_os_thread_t tid1, fspr_os_thread_t tid2) { return (tid1 == tid2); } -void apr_thread_yield() +void fspr_thread_yield() { NXThreadYield(); } -apr_status_t apr_thread_exit(apr_thread_t *thd, - apr_status_t retval) +fspr_status_t fspr_thread_exit(fspr_thread_t *thd, + fspr_status_t retval) { thd->exitval = retval; - apr_pool_destroy(thd->pool); + fspr_pool_destroy(thd->pool); NXThreadExit(NULL); return APR_SUCCESS; } -apr_status_t apr_thread_join(apr_status_t *retval, - apr_thread_t *thd) +fspr_status_t fspr_thread_join(fspr_status_t *retval, + fspr_thread_t *thd) { - apr_status_t stat; + fspr_status_t stat; NXThreadId_t dthr; if ((stat = NXThreadJoin(thd->td, &dthr, NULL)) == 0) { @@ -180,16 +180,16 @@ apr_status_t apr_thread_join(apr_status_t *retval, } } -apr_status_t apr_thread_detach(apr_thread_t *thd) +fspr_status_t fspr_thread_detach(fspr_thread_t *thd) { return APR_SUCCESS; } -apr_status_t apr_thread_data_get(void **data, const char *key, - apr_thread_t *thread) +fspr_status_t fspr_thread_data_get(void **data, const char *key, + fspr_thread_t *thread) { if (thread != NULL) { - return apr_pool_userdata_get(data, key, thread->pool); + return fspr_pool_userdata_get(data, key, thread->pool); } else { data = NULL; @@ -197,12 +197,12 @@ apr_status_t apr_thread_data_get(void **data, const char *key, } } -apr_status_t apr_thread_data_set(void *data, const char *key, - apr_status_t (*cleanup) (void *), - apr_thread_t *thread) +fspr_status_t fspr_thread_data_set(void *data, const char *key, + fspr_status_t (*cleanup) (void *), + fspr_thread_t *thread) { if (thread != NULL) { - return apr_pool_userdata_set(data, key, cleanup, thread->pool); + return fspr_pool_userdata_set(data, key, cleanup, thread->pool); } else { data = NULL; @@ -210,8 +210,8 @@ apr_status_t apr_thread_data_set(void *data, const char *key, } } -APR_DECLARE(apr_status_t) apr_os_thread_get(apr_os_thread_t **thethd, - apr_thread_t *thd) +APR_DECLARE(fspr_status_t) fspr_os_thread_get(fspr_os_thread_t **thethd, + fspr_thread_t *thd) { if (thd == NULL) { return APR_ENOTHREAD; @@ -220,29 +220,29 @@ APR_DECLARE(apr_status_t) apr_os_thread_get(apr_os_thread_t **thethd, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_os_thread_put(apr_thread_t **thd, - apr_os_thread_t *thethd, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_os_thread_put(fspr_thread_t **thd, + fspr_os_thread_t *thethd, + fspr_pool_t *pool) { if (pool == NULL) { return APR_ENOPOOL; } if ((*thd) == NULL) { - (*thd) = (apr_thread_t *)apr_palloc(pool, sizeof(apr_thread_t)); + (*thd) = (fspr_thread_t *)fspr_palloc(pool, sizeof(fspr_thread_t)); (*thd)->pool = pool; } (*thd)->td = *thethd; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_once_init(apr_thread_once_t **control, - apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_thread_once_init(fspr_thread_once_t **control, + fspr_pool_t *p) { - (*control) = apr_pcalloc(p, sizeof(**control)); + (*control) = fspr_pcalloc(p, sizeof(**control)); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_once(apr_thread_once_t *control, +APR_DECLARE(fspr_status_t) fspr_thread_once(fspr_thread_once_t *control, void (*func)(void)) { if (!atomic_xchg(&control->value, 1)) { diff --git a/libs/apr/threadproc/netware/threadpriv.c b/libs/apr/threadproc/netware/threadpriv.c index 54680a5634..3813fdfc38 100644 --- a/libs/apr/threadproc/netware/threadpriv.c +++ b/libs/apr/threadproc/netware/threadpriv.c @@ -14,15 +14,15 @@ * limitations under the License. */ -#include "apr_portable.h" -#include "apr_arch_threadproc.h" +#include "fspr_portable.h" +#include "fspr_arch_threadproc.h" -apr_status_t apr_threadkey_private_create(apr_threadkey_t **key, - void (*dest)(void *), apr_pool_t *pool) +fspr_status_t fspr_threadkey_private_create(fspr_threadkey_t **key, + void (*dest)(void *), fspr_pool_t *pool) { - apr_status_t stat; + fspr_status_t stat; - (*key) = (apr_threadkey_t *)apr_palloc(pool, sizeof(apr_threadkey_t)); + (*key) = (fspr_threadkey_t *)fspr_palloc(pool, sizeof(fspr_threadkey_t)); if ((*key) == NULL) { return APR_ENOMEM; } @@ -35,9 +35,9 @@ apr_status_t apr_threadkey_private_create(apr_threadkey_t **key, return stat; } -apr_status_t apr_threadkey_private_get(void **new, apr_threadkey_t *key) +fspr_status_t fspr_threadkey_private_get(void **new, fspr_threadkey_t *key) { - apr_status_t stat; + fspr_status_t stat; if ((stat = NXKeyGetValue(key->key, new)) == 0) { return APR_SUCCESS; @@ -47,9 +47,9 @@ apr_status_t apr_threadkey_private_get(void **new, apr_threadkey_t *key) } } -apr_status_t apr_threadkey_private_set(void *priv, apr_threadkey_t *key) +fspr_status_t fspr_threadkey_private_set(void *priv, fspr_threadkey_t *key) { - apr_status_t stat; + fspr_status_t stat; if ((stat = NXKeySetValue(key->key, priv)) == 0) { return APR_SUCCESS; } @@ -58,42 +58,42 @@ apr_status_t apr_threadkey_private_set(void *priv, apr_threadkey_t *key) } } -apr_status_t apr_threadkey_private_delete(apr_threadkey_t *key) +fspr_status_t fspr_threadkey_private_delete(fspr_threadkey_t *key) { - apr_status_t stat; + fspr_status_t stat; if ((stat = NXKeyDelete(key->key)) == 0) { return APR_SUCCESS; } return stat; } -apr_status_t apr_threadkey_data_get(void **data, const char *key, apr_threadkey_t *threadkey) +fspr_status_t fspr_threadkey_data_get(void **data, const char *key, fspr_threadkey_t *threadkey) { - return apr_pool_userdata_get(data, key, threadkey->pool); + return fspr_pool_userdata_get(data, key, threadkey->pool); } -apr_status_t apr_threadkey_data_set(void *data, - const char *key, apr_status_t (*cleanup) (void *), - apr_threadkey_t *threadkey) +fspr_status_t fspr_threadkey_data_set(void *data, + const char *key, fspr_status_t (*cleanup) (void *), + fspr_threadkey_t *threadkey) { - return apr_pool_userdata_set(data, key, cleanup, threadkey->pool); + return fspr_pool_userdata_set(data, key, cleanup, threadkey->pool); } -apr_status_t apr_os_threadkey_get(apr_os_threadkey_t *thekey, - apr_threadkey_t *key) +fspr_status_t fspr_os_threadkey_get(fspr_os_threadkey_t *thekey, + fspr_threadkey_t *key) { thekey = &(key->key); return APR_SUCCESS; } -apr_status_t apr_os_threadkey_put(apr_threadkey_t **key, - apr_os_threadkey_t *thekey, apr_pool_t *pool) +fspr_status_t fspr_os_threadkey_put(fspr_threadkey_t **key, + fspr_os_threadkey_t *thekey, fspr_pool_t *pool) { if (pool == NULL) { return APR_ENOPOOL; } if ((*key) == NULL) { - (*key) = (apr_threadkey_t *)apr_palloc(pool, sizeof(apr_threadkey_t)); + (*key) = (fspr_threadkey_t *)fspr_palloc(pool, sizeof(fspr_threadkey_t)); (*key)->pool = pool; } (*key)->key = *thekey; diff --git a/libs/apr/threadproc/os2/proc.c b/libs/apr/threadproc/os2/proc.c index 20dfffb8b8..8448a33bc5 100644 --- a/libs/apr/threadproc/os2/proc.c +++ b/libs/apr/threadproc/os2/proc.c @@ -17,16 +17,16 @@ #define INCL_DOS #define INCL_DOSERRORS -#include "apr_arch_threadproc.h" -#include "apr_arch_file_io.h" -#include "apr_private.h" -#include "apr_thread_proc.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_portable.h" -#include "apr_strings.h" -#include "apr_signal.h" +#include "fspr_arch_threadproc.h" +#include "fspr_arch_file_io.h" +#include "fspr_private.h" +#include "fspr_thread_proc.h" +#include "fspr_file_io.h" +#include "fspr_general.h" +#include "fspr_lib.h" +#include "fspr_portable.h" +#include "fspr_strings.h" +#include "fspr_signal.h" #include #include #include @@ -34,10 +34,10 @@ #include #include -APR_DECLARE(apr_status_t) apr_procattr_create(apr_procattr_t **new, apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_procattr_create(fspr_procattr_t **new, fspr_pool_t *pool) { - (*new) = (apr_procattr_t *)apr_palloc(pool, - sizeof(apr_procattr_t)); + (*new) = (fspr_procattr_t *)fspr_palloc(pool, + sizeof(fspr_procattr_t)); if ((*new) == NULL) { return APR_ENOMEM; @@ -55,12 +55,12 @@ APR_DECLARE(apr_status_t) apr_procattr_create(apr_procattr_t **new, apr_pool_t * return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_procattr_io_set(apr_procattr_t *attr, apr_int32_t in, - apr_int32_t out, apr_int32_t err) +APR_DECLARE(fspr_status_t) fspr_procattr_io_set(fspr_procattr_t *attr, fspr_int32_t in, + fspr_int32_t out, fspr_int32_t err) { - apr_status_t stat; + fspr_status_t stat; if (in) { - if ((stat = apr_file_pipe_create(&attr->child_in, &attr->parent_in, + if ((stat = fspr_file_pipe_create(&attr->child_in, &attr->parent_in, attr->pool)) != APR_SUCCESS) { return stat; } @@ -68,18 +68,18 @@ APR_DECLARE(apr_status_t) apr_procattr_io_set(apr_procattr_t *attr, apr_int32_t case APR_FULL_BLOCK: break; case APR_PARENT_BLOCK: - apr_file_pipe_timeout_set(attr->child_in, 0); + fspr_file_pipe_timeout_set(attr->child_in, 0); break; case APR_CHILD_BLOCK: - apr_file_pipe_timeout_set(attr->parent_in, 0); + fspr_file_pipe_timeout_set(attr->parent_in, 0); break; default: - apr_file_pipe_timeout_set(attr->child_in, 0); - apr_file_pipe_timeout_set(attr->parent_in, 0); + fspr_file_pipe_timeout_set(attr->child_in, 0); + fspr_file_pipe_timeout_set(attr->parent_in, 0); } } if (out) { - if ((stat = apr_file_pipe_create(&attr->parent_out, &attr->child_out, + if ((stat = fspr_file_pipe_create(&attr->parent_out, &attr->child_out, attr->pool)) != APR_SUCCESS) { return stat; } @@ -87,18 +87,18 @@ APR_DECLARE(apr_status_t) apr_procattr_io_set(apr_procattr_t *attr, apr_int32_t case APR_FULL_BLOCK: break; case APR_PARENT_BLOCK: - apr_file_pipe_timeout_set(attr->child_out, 0); + fspr_file_pipe_timeout_set(attr->child_out, 0); break; case APR_CHILD_BLOCK: - apr_file_pipe_timeout_set(attr->parent_out, 0); + fspr_file_pipe_timeout_set(attr->parent_out, 0); break; default: - apr_file_pipe_timeout_set(attr->child_out, 0); - apr_file_pipe_timeout_set(attr->parent_out, 0); + fspr_file_pipe_timeout_set(attr->child_out, 0); + fspr_file_pipe_timeout_set(attr->parent_out, 0); } } if (err) { - if ((stat = apr_file_pipe_create(&attr->parent_err, &attr->child_err, + if ((stat = fspr_file_pipe_create(&attr->parent_err, &attr->child_err, attr->pool)) != APR_SUCCESS) { return stat; } @@ -106,90 +106,90 @@ APR_DECLARE(apr_status_t) apr_procattr_io_set(apr_procattr_t *attr, apr_int32_t case APR_FULL_BLOCK: break; case APR_PARENT_BLOCK: - apr_file_pipe_timeout_set(attr->child_err, 0); + fspr_file_pipe_timeout_set(attr->child_err, 0); break; case APR_CHILD_BLOCK: - apr_file_pipe_timeout_set(attr->parent_err, 0); + fspr_file_pipe_timeout_set(attr->parent_err, 0); break; default: - apr_file_pipe_timeout_set(attr->child_err, 0); - apr_file_pipe_timeout_set(attr->parent_err, 0); + fspr_file_pipe_timeout_set(attr->child_err, 0); + fspr_file_pipe_timeout_set(attr->parent_err, 0); } } return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_procattr_child_in_set(apr_procattr_t *attr, apr_file_t *child_in, - apr_file_t *parent_in) +APR_DECLARE(fspr_status_t) fspr_procattr_child_in_set(fspr_procattr_t *attr, fspr_file_t *child_in, + fspr_file_t *parent_in) { if (attr->child_in == NULL && attr->parent_in == NULL) - apr_file_pipe_create(&attr->child_in, &attr->parent_in, attr->pool); + fspr_file_pipe_create(&attr->child_in, &attr->parent_in, attr->pool); if (child_in != NULL) - apr_file_dup(&attr->child_in, child_in, attr->pool); + fspr_file_dup(&attr->child_in, child_in, attr->pool); if (parent_in != NULL) - apr_file_dup(&attr->parent_in, parent_in, attr->pool); + fspr_file_dup(&attr->parent_in, parent_in, attr->pool); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_procattr_child_out_set(apr_procattr_t *attr, apr_file_t *child_out, - apr_file_t *parent_out) +APR_DECLARE(fspr_status_t) fspr_procattr_child_out_set(fspr_procattr_t *attr, fspr_file_t *child_out, + fspr_file_t *parent_out) { if (attr->child_out == NULL && attr->parent_out == NULL) - apr_file_pipe_create(&attr->child_out, &attr->parent_out, attr->pool); + fspr_file_pipe_create(&attr->child_out, &attr->parent_out, attr->pool); if (child_out != NULL) - apr_file_dup(&attr->child_out, child_out, attr->pool); + fspr_file_dup(&attr->child_out, child_out, attr->pool); if (parent_out != NULL) - apr_file_dup(&attr->parent_out, parent_out, attr->pool); + fspr_file_dup(&attr->parent_out, parent_out, attr->pool); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_procattr_child_err_set(apr_procattr_t *attr, apr_file_t *child_err, - apr_file_t *parent_err) +APR_DECLARE(fspr_status_t) fspr_procattr_child_err_set(fspr_procattr_t *attr, fspr_file_t *child_err, + fspr_file_t *parent_err) { if (attr->child_err == NULL && attr->parent_err == NULL) - apr_file_pipe_create(&attr->child_err, &attr->parent_err, attr->pool); + fspr_file_pipe_create(&attr->child_err, &attr->parent_err, attr->pool); if (child_err != NULL) - apr_file_dup(&attr->child_err, child_err, attr->pool); + fspr_file_dup(&attr->child_err, child_err, attr->pool); if (parent_err != NULL) - apr_file_dup(&attr->parent_err, parent_err, attr->pool); + fspr_file_dup(&attr->parent_err, parent_err, attr->pool); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_procattr_dir_set(apr_procattr_t *attr, const char *dir) +APR_DECLARE(fspr_status_t) fspr_procattr_dir_set(fspr_procattr_t *attr, const char *dir) { - attr->currdir = apr_pstrdup(attr->pool, dir); + attr->currdir = fspr_pstrdup(attr->pool, dir); if (attr->currdir) { return APR_SUCCESS; } return APR_ENOMEM; } -APR_DECLARE(apr_status_t) apr_procattr_cmdtype_set(apr_procattr_t *attr, - apr_cmdtype_e cmd) +APR_DECLARE(fspr_status_t) fspr_procattr_cmdtype_set(fspr_procattr_t *attr, + fspr_cmdtype_e cmd) { attr->cmdtype = cmd; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_procattr_detach_set(apr_procattr_t *attr, apr_int32_t detach) +APR_DECLARE(fspr_status_t) fspr_procattr_detach_set(fspr_procattr_t *attr, fspr_int32_t detach) { attr->detached = detach; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_proc_fork(apr_proc_t *proc, apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_proc_fork(fspr_proc_t *proc, fspr_pool_t *pool) { int pid; @@ -215,7 +215,7 @@ APR_DECLARE(apr_status_t) apr_proc_fork(apr_proc_t *proc, apr_pool_t *pool) /* quotes in the string are doubled up. * Used to escape quotes in args passed to OS/2's cmd.exe */ -static char *double_quotes(apr_pool_t *pool, const char *str) +static char *double_quotes(fspr_pool_t *pool, const char *str) { int num_quotes = 0; int len = 0; @@ -225,7 +225,7 @@ static char *double_quotes(apr_pool_t *pool, const char *str) num_quotes += str[len++] == '\"'; } - quote_doubled_str = apr_palloc(pool, len + num_quotes + 1); + quote_doubled_str = fspr_palloc(pool, len + num_quotes + 1); dest = quote_doubled_str; while (*str) { @@ -240,8 +240,8 @@ static char *double_quotes(apr_pool_t *pool, const char *str) -APR_DECLARE(apr_status_t) apr_procattr_child_errfn_set(apr_procattr_t *attr, - apr_child_errfn_t *errfn) +APR_DECLARE(fspr_status_t) fspr_procattr_child_errfn_set(fspr_procattr_t *attr, + fspr_child_errfn_t *errfn) { /* won't ever be called on this platform, so don't save the function pointer */ return APR_SUCCESS; @@ -249,15 +249,15 @@ APR_DECLARE(apr_status_t) apr_procattr_child_errfn_set(apr_procattr_t *attr, -APR_DECLARE(apr_status_t) apr_procattr_error_check_set(apr_procattr_t *attr, - apr_int32_t chk) +APR_DECLARE(fspr_status_t) fspr_procattr_error_check_set(fspr_procattr_t *attr, + fspr_int32_t chk) { /* won't ever be used on this platform, so don't save the flag */ return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_procattr_addrspace_set(apr_procattr_t *attr, - apr_int32_t addrspace) +APR_DECLARE(fspr_status_t) fspr_procattr_addrspace_set(fspr_procattr_t *attr, + fspr_int32_t addrspace) { /* won't ever be used on this platform, so don't save the flag */ return APR_SUCCESS; @@ -265,13 +265,13 @@ APR_DECLARE(apr_status_t) apr_procattr_addrspace_set(apr_procattr_t *attr, -APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *proc, const char *progname, +APR_DECLARE(fspr_status_t) fspr_proc_create(fspr_proc_t *proc, const char *progname, const char * const *args, const char * const *env, - apr_procattr_t *attr, apr_pool_t *pool) + fspr_procattr_t *attr, fspr_pool_t *pool) { int i, arg, numargs, cmdlen; - apr_status_t status; + fspr_status_t status; const char **newargs; char savedir[300]; HFILE save_in, save_out, save_err, dup; @@ -279,7 +279,7 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *proc, const char *progname char *extension, *newprogname, *extra_arg = NULL, *cmdline, *cmdline_pos; char interpreter[1024]; char error_object[260]; - apr_file_t *progfile; + fspr_file_t *progfile; int env_len, e; char *env_block, *env_block_pos; RESULTCODES rescodes; @@ -314,7 +314,7 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *proc, const char *progname DosSetFHState(attr->parent_err->filedes, OPEN_FLAGS_NOINHERIT); } - apr_signal(SIGCHLD, SIG_DFL); /*not sure if this is needed or not */ + fspr_signal(SIGCHLD, SIG_DFL); /*not sure if this is needed or not */ if (attr->currdir != NULL) { _getcwd2(savedir, sizeof(savedir)); @@ -340,21 +340,21 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *proc, const char *progname strcpy(interpreter, "#!" SHELL_PATH); extra_arg = "/C"; } else if (stricmp(extension, ".exe") != 0) { - status = apr_file_open(&progfile, progname, APR_READ|APR_BUFFERED, 0, pool); + status = fspr_file_open(&progfile, progname, APR_READ|APR_BUFFERED, 0, pool); if (status != APR_SUCCESS && APR_STATUS_IS_ENOENT(status)) { - progname = apr_pstrcat(pool, progname, ".exe", NULL); + progname = fspr_pstrcat(pool, progname, ".exe", NULL); } if (status == APR_SUCCESS) { - status = apr_file_gets(interpreter, sizeof(interpreter), progfile); + status = fspr_file_gets(interpreter, sizeof(interpreter), progfile); if (status == APR_SUCCESS) { if (interpreter[0] == '#' && interpreter[1] == '!') { /* delete CR/LF & any other whitespace off the end */ int end = strlen(interpreter) - 1; - while (end >= 0 && apr_isspace(interpreter[end])) { + while (end >= 0 && fspr_isspace(interpreter[end])) { interpreter[end] = '\0'; end--; } @@ -376,7 +376,7 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *proc, const char *progname } } - apr_file_close(progfile); + fspr_file_close(progfile); } } @@ -386,7 +386,7 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *proc, const char *progname i++; } - newargs = (const char **)apr_palloc(pool, sizeof (char *) * (i + 4)); + newargs = (const char **)fspr_palloc(pool, sizeof (char *) * (i + 4)); numargs = 0; if (interpreter[0]) @@ -394,7 +394,7 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *proc, const char *progname if (extra_arg) newargs[numargs++] = "/c"; - newargs[numargs++] = newprogname = apr_pstrdup(pool, progname); + newargs[numargs++] = newprogname = fspr_pstrdup(pool, progname); arg = 1; while (args && args[arg]) { @@ -412,14 +412,14 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *proc, const char *progname for (i=0; i\" ")) - a = apr_pstrcat(pool, "\"", double_quotes(pool, a), "\"", NULL); + a = fspr_pstrcat(pool, "\"", double_quotes(pool, a), "\"", NULL); if (i) *(cmdline_pos++) = ' '; @@ -441,7 +441,7 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *proc, const char *progname for (env_len=1, e=0; env[e]; e++) env_len += strlen(env[e]) + 1; - env_block = apr_palloc(pool, env_len); + env_block = fspr_palloc(pool, env_len); env_block_pos = env_block; for (e=0; env[e]; e++) { @@ -464,21 +464,21 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *proc, const char *progname } if (attr->child_in) { - apr_file_close(attr->child_in); + fspr_file_close(attr->child_in); dup = STDIN_FILENO; DosDupHandle(save_in, &dup); DosClose(save_in); } if (attr->child_out) { - apr_file_close(attr->child_out); + fspr_file_close(attr->child_out); dup = STDOUT_FILENO; DosDupHandle(save_out, &dup); DosClose(save_out); } if (attr->child_err) { - apr_file_close(attr->child_err); + fspr_file_close(attr->child_err); dup = STDERR_FILENO; DosDupHandle(save_err, &dup); DosClose(save_err); @@ -497,10 +497,10 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *proc, const char *progname static void proces_result_codes(RESULTCODES codes, int *exitcode, - apr_exit_why_e *exitwhy) + fspr_exit_why_e *exitwhy) { int result = 0; - apr_exit_why_e why = APR_PROC_EXIT; + fspr_exit_why_e why = APR_PROC_EXIT; switch (codes.codeTerminate) { case TC_EXIT: /* Normal exit */ @@ -553,11 +553,11 @@ static void proces_result_codes(RESULTCODES codes, -APR_DECLARE(apr_status_t) apr_proc_wait_all_procs(apr_proc_t *proc, +APR_DECLARE(fspr_status_t) fspr_proc_wait_all_procs(fspr_proc_t *proc, int *exitcode, - apr_exit_why_e *exitwhy, - apr_wait_how_e waithow, - apr_pool_t *p) + fspr_exit_why_e *exitwhy, + fspr_wait_how_e waithow, + fspr_pool_t *p) { RESULTCODES codes; ULONG rc; @@ -578,9 +578,9 @@ APR_DECLARE(apr_status_t) apr_proc_wait_all_procs(apr_proc_t *proc, -APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc, - int *exitcode, apr_exit_why_e *exitwhy, - apr_wait_how_e waithow) +APR_DECLARE(fspr_status_t) fspr_proc_wait(fspr_proc_t *proc, + int *exitcode, fspr_exit_why_e *exitwhy, + fspr_wait_how_e waithow) { RESULTCODES codes; ULONG rc; @@ -599,19 +599,19 @@ APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc, -APR_DECLARE(apr_status_t) apr_proc_detach(int daemonize) +APR_DECLARE(fspr_status_t) fspr_proc_detach(int daemonize) { return APR_ENOTIMPL; } -APR_DECLARE(apr_status_t) apr_procattr_user_set(apr_procattr_t *attr, +APR_DECLARE(fspr_status_t) fspr_procattr_user_set(fspr_procattr_t *attr, const char *username, const char *password) { return APR_ENOTIMPL; } -APR_DECLARE(apr_status_t) apr_procattr_group_set(apr_procattr_t *attr, +APR_DECLARE(fspr_status_t) fspr_procattr_group_set(fspr_procattr_t *attr, const char *groupname) { return APR_ENOTIMPL; diff --git a/libs/apr/threadproc/os2/thread.c b/libs/apr/threadproc/os2/thread.c index c1c35219d0..bed45d3ffd 100644 --- a/libs/apr/threadproc/os2/thread.c +++ b/libs/apr/threadproc/os2/thread.c @@ -16,17 +16,17 @@ #define INCL_DOSERRORS #define INCL_DOS -#include "apr_arch_threadproc.h" -#include "apr_thread_proc.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_portable.h" -#include "apr_arch_file_io.h" +#include "fspr_arch_threadproc.h" +#include "fspr_thread_proc.h" +#include "fspr_general.h" +#include "fspr_lib.h" +#include "fspr_portable.h" +#include "fspr_arch_file_io.h" #include -APR_DECLARE(apr_status_t) apr_threadattr_create(apr_threadattr_t **new, apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_threadattr_create(fspr_threadattr_t **new, fspr_pool_t *pool) { - (*new) = (apr_threadattr_t *)apr_palloc(pool, sizeof(apr_threadattr_t)); + (*new) = (fspr_threadattr_t *)fspr_palloc(pool, sizeof(fspr_threadattr_t)); if ((*new) == NULL) { return APR_ENOMEM; @@ -40,7 +40,7 @@ APR_DECLARE(apr_status_t) apr_threadattr_create(apr_threadattr_t **new, apr_pool -APR_DECLARE(apr_status_t) apr_threadattr_detach_set(apr_threadattr_t *attr, apr_int32_t on) +APR_DECLARE(fspr_status_t) fspr_threadattr_detach_set(fspr_threadattr_t *attr, fspr_int32_t on) { attr->attr |= APR_THREADATTR_DETACHED; return APR_SUCCESS; @@ -48,40 +48,40 @@ APR_DECLARE(apr_status_t) apr_threadattr_detach_set(apr_threadattr_t *attr, apr_ -APR_DECLARE(apr_status_t) apr_threadattr_detach_get(apr_threadattr_t *attr) +APR_DECLARE(fspr_status_t) fspr_threadattr_detach_get(fspr_threadattr_t *attr) { return (attr->attr & APR_THREADATTR_DETACHED) ? APR_DETACH : APR_NOTDETACH; } -APR_DECLARE(apr_status_t) apr_threadattr_stacksize_set(apr_threadattr_t *attr, - apr_size_t stacksize) +APR_DECLARE(fspr_status_t) fspr_threadattr_stacksize_set(fspr_threadattr_t *attr, + fspr_size_t stacksize) { attr->stacksize = stacksize; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_threadattr_guardsize_set(apr_threadattr_t *attr, - apr_size_t size) +APR_DECLARE(fspr_status_t) fspr_threadattr_guardsize_set(fspr_threadattr_t *attr, + fspr_size_t size) { return APR_ENOTIMPL; } -static void apr_thread_begin(void *arg) +static void fspr_thread_begin(void *arg) { - apr_thread_t *thread = (apr_thread_t *)arg; + fspr_thread_t *thread = (fspr_thread_t *)arg; thread->exitval = thread->func(thread, thread->data); } -APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new, apr_threadattr_t *attr, - apr_thread_start_t func, void *data, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_thread_create(fspr_thread_t **new, fspr_threadattr_t *attr, + fspr_thread_start_t func, void *data, + fspr_pool_t *pool) { - apr_status_t stat; - apr_thread_t *thread; + fspr_status_t stat; + fspr_thread_t *thread; - thread = (apr_thread_t *)apr_palloc(pool, sizeof(apr_thread_t)); + thread = (fspr_thread_t *)fspr_palloc(pool, sizeof(fspr_thread_t)); *new = thread; if (thread == NULL) { @@ -92,21 +92,21 @@ APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new, apr_threadattr_t thread->attr = attr; thread->func = func; thread->data = data; - stat = apr_pool_create(&thread->pool, pool); + stat = fspr_pool_create(&thread->pool, pool); if (stat != APR_SUCCESS) { return stat; } if (attr == NULL) { - stat = apr_threadattr_create(&thread->attr, thread->pool); + stat = fspr_threadattr_create(&thread->attr, thread->pool); if (stat != APR_SUCCESS) { return stat; } } - thread->tid = _beginthread(apr_thread_begin, NULL, + thread->tid = _beginthread(fspr_thread_begin, NULL, thread->attr->stacksize > 0 ? thread->attr->stacksize : APR_THREAD_STACKSIZE, thread); @@ -120,7 +120,7 @@ APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new, apr_threadattr_t -APR_DECLARE(apr_os_thread_t) apr_os_thread_current() +APR_DECLARE(fspr_os_thread_t) fspr_os_thread_current() { PIB *ppib; TIB *ptib; @@ -130,7 +130,7 @@ APR_DECLARE(apr_os_thread_t) apr_os_thread_current() -APR_DECLARE(apr_status_t) apr_thread_exit(apr_thread_t *thd, apr_status_t retval) +APR_DECLARE(fspr_status_t) fspr_thread_exit(fspr_thread_t *thd, fspr_status_t retval) { thd->exitval = retval; _endthread(); @@ -139,7 +139,7 @@ APR_DECLARE(apr_status_t) apr_thread_exit(apr_thread_t *thd, apr_status_t retval -APR_DECLARE(apr_status_t) apr_thread_join(apr_status_t *retval, apr_thread_t *thd) +APR_DECLARE(fspr_status_t) fspr_thread_join(fspr_status_t *retval, fspr_thread_t *thd) { ULONG rc; TID waittid = thd->tid; @@ -158,7 +158,7 @@ APR_DECLARE(apr_status_t) apr_thread_join(apr_status_t *retval, apr_thread_t *th -APR_DECLARE(apr_status_t) apr_thread_detach(apr_thread_t *thd) +APR_DECLARE(fspr_status_t) fspr_thread_detach(fspr_thread_t *thd) { thd->attr->attr |= APR_THREADATTR_DETACHED; return APR_SUCCESS; @@ -166,14 +166,14 @@ APR_DECLARE(apr_status_t) apr_thread_detach(apr_thread_t *thd) -void apr_thread_yield() +void fspr_thread_yield() { DosSleep(0); } -APR_DECLARE(apr_status_t) apr_os_thread_get(apr_os_thread_t **thethd, apr_thread_t *thd) +APR_DECLARE(fspr_status_t) fspr_os_thread_get(fspr_os_thread_t **thethd, fspr_thread_t *thd) { *thethd = &thd->tid; return APR_SUCCESS; @@ -181,11 +181,11 @@ APR_DECLARE(apr_status_t) apr_os_thread_get(apr_os_thread_t **thethd, apr_thread -APR_DECLARE(apr_status_t) apr_os_thread_put(apr_thread_t **thd, apr_os_thread_t *thethd, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_os_thread_put(fspr_thread_t **thd, fspr_os_thread_t *thethd, + fspr_pool_t *pool) { if ((*thd) == NULL) { - (*thd) = (apr_thread_t *)apr_pcalloc(pool, sizeof(apr_thread_t)); + (*thd) = (fspr_thread_t *)fspr_pcalloc(pool, sizeof(fspr_thread_t)); (*thd)->pool = pool; } (*thd)->tid = *thethd; @@ -194,34 +194,34 @@ APR_DECLARE(apr_status_t) apr_os_thread_put(apr_thread_t **thd, apr_os_thread_t -int apr_os_thread_equal(apr_os_thread_t tid1, apr_os_thread_t tid2) +int fspr_os_thread_equal(fspr_os_thread_t tid1, fspr_os_thread_t tid2) { return tid1 == tid2; } -APR_DECLARE(apr_status_t) apr_thread_data_get(void **data, const char *key, apr_thread_t *thread) +APR_DECLARE(fspr_status_t) fspr_thread_data_get(void **data, const char *key, fspr_thread_t *thread) { - return apr_pool_userdata_get(data, key, thread->pool); + return fspr_pool_userdata_get(data, key, thread->pool); } -APR_DECLARE(apr_status_t) apr_thread_data_set(void *data, const char *key, - apr_status_t (*cleanup) (void *), - apr_thread_t *thread) +APR_DECLARE(fspr_status_t) fspr_thread_data_set(void *data, const char *key, + fspr_status_t (*cleanup) (void *), + fspr_thread_t *thread) { - return apr_pool_userdata_set(data, key, cleanup, thread->pool); + return fspr_pool_userdata_set(data, key, cleanup, thread->pool); } APR_POOL_IMPLEMENT_ACCESSOR(thread) -static apr_status_t thread_once_cleanup(void *vcontrol) +static fspr_status_t thread_once_cleanup(void *vcontrol) { - apr_thread_once_t *control = (apr_thread_once_t *)vcontrol; + fspr_thread_once_t *control = (fspr_thread_once_t *)vcontrol; if (control->sem) { DosCloseEventSem(control->sem); @@ -232,19 +232,19 @@ static apr_status_t thread_once_cleanup(void *vcontrol) -APR_DECLARE(apr_status_t) apr_thread_once_init(apr_thread_once_t **control, - apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_thread_once_init(fspr_thread_once_t **control, + fspr_pool_t *p) { ULONG rc; - *control = (apr_thread_once_t *)apr_pcalloc(p, sizeof(apr_thread_once_t)); + *control = (fspr_thread_once_t *)fspr_pcalloc(p, sizeof(fspr_thread_once_t)); rc = DosCreateEventSem(NULL, &(*control)->sem, 0, TRUE); - apr_pool_cleanup_register(p, control, thread_once_cleanup, apr_pool_cleanup_null); + fspr_pool_cleanup_register(p, control, thread_once_cleanup, fspr_pool_cleanup_null); return APR_FROM_OS_ERROR(rc); } -APR_DECLARE(apr_status_t) apr_thread_once(apr_thread_once_t *control, +APR_DECLARE(fspr_status_t) fspr_thread_once(fspr_thread_once_t *control, void (*func)(void)) { if (!control->hit) { diff --git a/libs/apr/threadproc/os2/threadpriv.c b/libs/apr/threadproc/os2/threadpriv.c index 107ec10d71..2e315abedd 100644 --- a/libs/apr/threadproc/os2/threadpriv.c +++ b/libs/apr/threadproc/os2/threadpriv.c @@ -14,19 +14,19 @@ * limitations under the License. */ -#include "apr_arch_threadproc.h" -#include "apr_thread_proc.h" -#include "apr_portable.h" -#include "apr_general.h" -#include "apr_errno.h" -#include "apr_lib.h" -#include "apr_arch_file_io.h" +#include "fspr_arch_threadproc.h" +#include "fspr_thread_proc.h" +#include "fspr_portable.h" +#include "fspr_general.h" +#include "fspr_errno.h" +#include "fspr_lib.h" +#include "fspr_arch_file_io.h" -APR_DECLARE(apr_status_t) apr_threadkey_private_create(apr_threadkey_t **key, +APR_DECLARE(fspr_status_t) fspr_threadkey_private_create(fspr_threadkey_t **key, void (*dest)(void *), - apr_pool_t *pool) + fspr_pool_t *pool) { - (*key) = (apr_threadkey_t *)apr_palloc(pool, sizeof(apr_threadkey_t)); + (*key) = (fspr_threadkey_t *)fspr_palloc(pool, sizeof(fspr_threadkey_t)); if ((*key) == NULL) { return APR_ENOMEM; @@ -36,51 +36,51 @@ APR_DECLARE(apr_status_t) apr_threadkey_private_create(apr_threadkey_t **key, return APR_OS2_STATUS(DosAllocThreadLocalMemory(1, &((*key)->key))); } -APR_DECLARE(apr_status_t) apr_threadkey_private_get(void **new, apr_threadkey_t *key) +APR_DECLARE(fspr_status_t) fspr_threadkey_private_get(void **new, fspr_threadkey_t *key) { (*new) = (void *)*(key->key); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_threadkey_private_set(void *priv, apr_threadkey_t *key) +APR_DECLARE(fspr_status_t) fspr_threadkey_private_set(void *priv, fspr_threadkey_t *key) { *(key->key) = (ULONG)priv; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_threadkey_private_delete(apr_threadkey_t *key) +APR_DECLARE(fspr_status_t) fspr_threadkey_private_delete(fspr_threadkey_t *key) { return APR_OS2_STATUS(DosFreeThreadLocalMemory(key->key)); } -APR_DECLARE(apr_status_t) apr_threadkey_data_get(void **data, const char *key, - apr_threadkey_t *threadkey) +APR_DECLARE(fspr_status_t) fspr_threadkey_data_get(void **data, const char *key, + fspr_threadkey_t *threadkey) { - return apr_pool_userdata_get(data, key, threadkey->pool); + return fspr_pool_userdata_get(data, key, threadkey->pool); } -APR_DECLARE(apr_status_t) apr_threadkey_data_set(void *data, const char *key, - apr_status_t (*cleanup) (void *), - apr_threadkey_t *threadkey) +APR_DECLARE(fspr_status_t) fspr_threadkey_data_set(void *data, const char *key, + fspr_status_t (*cleanup) (void *), + fspr_threadkey_t *threadkey) { - return apr_pool_userdata_set(data, key, cleanup, threadkey->pool); + return fspr_pool_userdata_set(data, key, cleanup, threadkey->pool); } -APR_DECLARE(apr_status_t) apr_os_threadkey_get(apr_os_threadkey_t *thekey, apr_threadkey_t *key) +APR_DECLARE(fspr_status_t) fspr_os_threadkey_get(fspr_os_threadkey_t *thekey, fspr_threadkey_t *key) { *thekey = key->key; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_os_threadkey_put(apr_threadkey_t **key, - apr_os_threadkey_t *thekey, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_os_threadkey_put(fspr_threadkey_t **key, + fspr_os_threadkey_t *thekey, + fspr_pool_t *pool) { if (pool == NULL) { return APR_ENOPOOL; } if ((*key) == NULL) { - (*key) = (apr_threadkey_t *)apr_pcalloc(pool, sizeof(apr_threadkey_t)); + (*key) = (fspr_threadkey_t *)fspr_pcalloc(pool, sizeof(fspr_threadkey_t)); (*key)->pool = pool; } (*key)->key = *thekey; diff --git a/libs/apr/threadproc/unix/proc.c b/libs/apr/threadproc/unix/proc.c index 0f3437aee0..3781876edb 100644 --- a/libs/apr/threadproc/unix/proc.c +++ b/libs/apr/threadproc/unix/proc.c @@ -14,16 +14,16 @@ * limitations under the License. */ -#include "apr_arch_threadproc.h" -#include "apr_strings.h" -#include "apr_portable.h" -#include "apr_signal.h" -#include "apr_random.h" +#include "fspr_arch_threadproc.h" +#include "fspr_strings.h" +#include "fspr_portable.h" +#include "fspr_signal.h" +#include "fspr_random.h" -APR_DECLARE(apr_status_t) apr_procattr_create(apr_procattr_t **new, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_procattr_create(fspr_procattr_t **new, + fspr_pool_t *pool) { - (*new) = (apr_procattr_t *)apr_pcalloc(pool, sizeof(apr_procattr_t)); + (*new) = (fspr_procattr_t *)fspr_pcalloc(pool, sizeof(fspr_procattr_t)); if ((*new) == NULL) { return APR_ENOMEM; @@ -34,14 +34,14 @@ APR_DECLARE(apr_status_t) apr_procattr_create(apr_procattr_t **new, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_procattr_io_set(apr_procattr_t *attr, - apr_int32_t in, - apr_int32_t out, - apr_int32_t err) +APR_DECLARE(fspr_status_t) fspr_procattr_io_set(fspr_procattr_t *attr, + fspr_int32_t in, + fspr_int32_t out, + fspr_int32_t err) { - apr_status_t status; + fspr_status_t status; if (in != 0) { - if ((status = apr_file_pipe_create(&attr->child_in, &attr->parent_in, + if ((status = fspr_file_pipe_create(&attr->child_in, &attr->parent_in, attr->pool)) != APR_SUCCESS) { return status; } @@ -50,19 +50,19 @@ APR_DECLARE(apr_status_t) apr_procattr_io_set(apr_procattr_t *attr, case APR_FULL_BLOCK: break; case APR_PARENT_BLOCK: - apr_file_pipe_timeout_set(attr->child_in, 0); + fspr_file_pipe_timeout_set(attr->child_in, 0); break; case APR_CHILD_BLOCK: - apr_file_pipe_timeout_set(attr->parent_in, 0); + fspr_file_pipe_timeout_set(attr->parent_in, 0); break; default: - apr_file_pipe_timeout_set(attr->child_in, 0); - apr_file_pipe_timeout_set(attr->parent_in, 0); + fspr_file_pipe_timeout_set(attr->child_in, 0); + fspr_file_pipe_timeout_set(attr->parent_in, 0); } } if (out) { - if ((status = apr_file_pipe_create(&attr->parent_out, &attr->child_out, + if ((status = fspr_file_pipe_create(&attr->parent_out, &attr->child_out, attr->pool)) != APR_SUCCESS) { return status; } @@ -71,19 +71,19 @@ APR_DECLARE(apr_status_t) apr_procattr_io_set(apr_procattr_t *attr, case APR_FULL_BLOCK: break; case APR_PARENT_BLOCK: - apr_file_pipe_timeout_set(attr->child_out, 0); + fspr_file_pipe_timeout_set(attr->child_out, 0); break; case APR_CHILD_BLOCK: - apr_file_pipe_timeout_set(attr->parent_out, 0); + fspr_file_pipe_timeout_set(attr->parent_out, 0); break; default: - apr_file_pipe_timeout_set(attr->child_out, 0); - apr_file_pipe_timeout_set(attr->parent_out, 0); + fspr_file_pipe_timeout_set(attr->child_out, 0); + fspr_file_pipe_timeout_set(attr->parent_out, 0); } } if (err) { - if ((status = apr_file_pipe_create(&attr->parent_err, &attr->child_err, + if ((status = fspr_file_pipe_create(&attr->parent_err, &attr->child_err, attr->pool)) != APR_SUCCESS) { return status; } @@ -92,14 +92,14 @@ APR_DECLARE(apr_status_t) apr_procattr_io_set(apr_procattr_t *attr, case APR_FULL_BLOCK: break; case APR_PARENT_BLOCK: - apr_file_pipe_timeout_set(attr->child_err, 0); + fspr_file_pipe_timeout_set(attr->child_err, 0); break; case APR_CHILD_BLOCK: - apr_file_pipe_timeout_set(attr->parent_err, 0); + fspr_file_pipe_timeout_set(attr->parent_err, 0); break; default: - apr_file_pipe_timeout_set(attr->child_err, 0); - apr_file_pipe_timeout_set(attr->parent_err, 0); + fspr_file_pipe_timeout_set(attr->child_err, 0); + fspr_file_pipe_timeout_set(attr->parent_err, 0); } } @@ -107,67 +107,67 @@ APR_DECLARE(apr_status_t) apr_procattr_io_set(apr_procattr_t *attr, } -APR_DECLARE(apr_status_t) apr_procattr_child_in_set(apr_procattr_t *attr, - apr_file_t *child_in, - apr_file_t *parent_in) +APR_DECLARE(fspr_status_t) fspr_procattr_child_in_set(fspr_procattr_t *attr, + fspr_file_t *child_in, + fspr_file_t *parent_in) { - apr_status_t rv = APR_SUCCESS; + fspr_status_t rv = APR_SUCCESS; if (attr->child_in == NULL && attr->parent_in == NULL) - rv = apr_file_pipe_create(&attr->child_in, &attr->parent_in, attr->pool); + rv = fspr_file_pipe_create(&attr->child_in, &attr->parent_in, attr->pool); if (child_in != NULL && rv == APR_SUCCESS) - rv = apr_file_dup2(attr->child_in, child_in, attr->pool); + rv = fspr_file_dup2(attr->child_in, child_in, attr->pool); if (parent_in != NULL && rv == APR_SUCCESS) - rv = apr_file_dup2(attr->parent_in, parent_in, attr->pool); + rv = fspr_file_dup2(attr->parent_in, parent_in, attr->pool); return rv; } -APR_DECLARE(apr_status_t) apr_procattr_child_out_set(apr_procattr_t *attr, - apr_file_t *child_out, - apr_file_t *parent_out) +APR_DECLARE(fspr_status_t) fspr_procattr_child_out_set(fspr_procattr_t *attr, + fspr_file_t *child_out, + fspr_file_t *parent_out) { - apr_status_t rv = APR_SUCCESS; + fspr_status_t rv = APR_SUCCESS; if (attr->child_out == NULL && attr->parent_out == NULL) - rv = apr_file_pipe_create(&attr->child_out, &attr->parent_out, attr->pool); + rv = fspr_file_pipe_create(&attr->child_out, &attr->parent_out, attr->pool); if (child_out != NULL && rv == APR_SUCCESS) - rv = apr_file_dup2(attr->child_out, child_out, attr->pool); + rv = fspr_file_dup2(attr->child_out, child_out, attr->pool); if (parent_out != NULL && rv == APR_SUCCESS) - rv = apr_file_dup2(attr->parent_out, parent_out, attr->pool); + rv = fspr_file_dup2(attr->parent_out, parent_out, attr->pool); return rv; } -APR_DECLARE(apr_status_t) apr_procattr_child_err_set(apr_procattr_t *attr, - apr_file_t *child_err, - apr_file_t *parent_err) +APR_DECLARE(fspr_status_t) fspr_procattr_child_err_set(fspr_procattr_t *attr, + fspr_file_t *child_err, + fspr_file_t *parent_err) { - apr_status_t rv = APR_SUCCESS; + fspr_status_t rv = APR_SUCCESS; if (attr->child_err == NULL && attr->parent_err == NULL) - rv = apr_file_pipe_create(&attr->child_err, &attr->parent_err, attr->pool); + rv = fspr_file_pipe_create(&attr->child_err, &attr->parent_err, attr->pool); if (child_err != NULL && rv == APR_SUCCESS) - rv = apr_file_dup2(attr->child_err, child_err, attr->pool); + rv = fspr_file_dup2(attr->child_err, child_err, attr->pool); if (parent_err != NULL && rv == APR_SUCCESS) - rv = apr_file_dup2(attr->parent_err, parent_err, attr->pool); + rv = fspr_file_dup2(attr->parent_err, parent_err, attr->pool); return rv; } -APR_DECLARE(apr_status_t) apr_procattr_dir_set(apr_procattr_t *attr, +APR_DECLARE(fspr_status_t) fspr_procattr_dir_set(fspr_procattr_t *attr, const char *dir) { - attr->currdir = apr_pstrdup(attr->pool, dir); + attr->currdir = fspr_pstrdup(attr->pool, dir); if (attr->currdir) { return APR_SUCCESS; } @@ -175,21 +175,21 @@ APR_DECLARE(apr_status_t) apr_procattr_dir_set(apr_procattr_t *attr, return APR_ENOMEM; } -APR_DECLARE(apr_status_t) apr_procattr_cmdtype_set(apr_procattr_t *attr, - apr_cmdtype_e cmd) +APR_DECLARE(fspr_status_t) fspr_procattr_cmdtype_set(fspr_procattr_t *attr, + fspr_cmdtype_e cmd) { attr->cmdtype = cmd; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_procattr_detach_set(apr_procattr_t *attr, - apr_int32_t detach) +APR_DECLARE(fspr_status_t) fspr_procattr_detach_set(fspr_procattr_t *attr, + fspr_int32_t detach) { attr->detached = detach; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_proc_fork(apr_proc_t *proc, apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_proc_fork(fspr_proc_t *proc, fspr_pool_t *pool) { int pid; @@ -202,7 +202,7 @@ APR_DECLARE(apr_status_t) apr_proc_fork(apr_proc_t *proc, apr_pool_t *pool) proc->out = NULL; proc->err = NULL; - apr_random_after_fork(proc); + fspr_random_after_fork(proc); return APR_INCHILD; } @@ -215,7 +215,7 @@ APR_DECLARE(apr_status_t) apr_proc_fork(apr_proc_t *proc, apr_pool_t *pool) return APR_INPARENT; } -static apr_status_t limit_proc(apr_procattr_t *attr) +static fspr_status_t limit_proc(fspr_procattr_t *attr) { #if APR_HAVE_STRUCT_RLIMIT && APR_HAVE_SETRLIMIT #ifdef RLIMIT_CPU @@ -267,35 +267,35 @@ static apr_status_t limit_proc(apr_procattr_t *attr) return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_procattr_child_errfn_set(apr_procattr_t *attr, - apr_child_errfn_t *errfn) +APR_DECLARE(fspr_status_t) fspr_procattr_child_errfn_set(fspr_procattr_t *attr, + fspr_child_errfn_t *errfn) { attr->errfn = errfn; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_procattr_error_check_set(apr_procattr_t *attr, - apr_int32_t chk) +APR_DECLARE(fspr_status_t) fspr_procattr_error_check_set(fspr_procattr_t *attr, + fspr_int32_t chk) { attr->errchk = chk; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_procattr_addrspace_set(apr_procattr_t *attr, - apr_int32_t addrspace) +APR_DECLARE(fspr_status_t) fspr_procattr_addrspace_set(fspr_procattr_t *attr, + fspr_int32_t addrspace) { /* won't ever be used on this platform, so don't save the flag */ return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_procattr_user_set(apr_procattr_t *attr, +APR_DECLARE(fspr_status_t) fspr_procattr_user_set(fspr_procattr_t *attr, const char *username, const char *password) { - apr_status_t rv; - apr_gid_t gid; + fspr_status_t rv; + fspr_gid_t gid; - if ((rv = apr_uid_get(&attr->uid, &gid, username, + if ((rv = fspr_uid_get(&attr->uid, &gid, username, attr->pool)) != APR_SUCCESS) { attr->uid = -1; return rv; @@ -308,22 +308,22 @@ APR_DECLARE(apr_status_t) apr_procattr_user_set(apr_procattr_t *attr, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_procattr_group_set(apr_procattr_t *attr, +APR_DECLARE(fspr_status_t) fspr_procattr_group_set(fspr_procattr_t *attr, const char *groupname) { - apr_status_t rv; + fspr_status_t rv; - if ((rv = apr_gid_get(&attr->gid, groupname, attr->pool)) != APR_SUCCESS) + if ((rv = fspr_gid_get(&attr->gid, groupname, attr->pool)) != APR_SUCCESS) attr->gid = -1; return rv; } -APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, +APR_DECLARE(fspr_status_t) fspr_proc_create(fspr_proc_t *new, const char *progname, const char * const *args, const char * const *env, - apr_procattr_t *attr, - apr_pool_t *pool) + fspr_procattr_t *attr, + fspr_pool_t *pool) { int i; const char * const empty_envp[] = {NULL}; @@ -369,7 +369,6 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, return errno; } else if (new->pid == 0) { - int status; /* child process */ /* @@ -386,41 +385,41 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, */ if (attr->child_in) { - apr_pool_cleanup_kill(apr_file_pool_get(attr->child_in), - attr->child_in, apr_unix_file_cleanup); + fspr_pool_cleanup_kill(fspr_file_pool_get(attr->child_in), + attr->child_in, fspr_unix_file_cleanup); } if (attr->child_out) { - apr_pool_cleanup_kill(apr_file_pool_get(attr->child_out), - attr->child_out, apr_unix_file_cleanup); + fspr_pool_cleanup_kill(fspr_file_pool_get(attr->child_out), + attr->child_out, fspr_unix_file_cleanup); } if (attr->child_err) { - apr_pool_cleanup_kill(apr_file_pool_get(attr->child_err), - attr->child_err, apr_unix_file_cleanup); + fspr_pool_cleanup_kill(fspr_file_pool_get(attr->child_err), + attr->child_err, fspr_unix_file_cleanup); } - apr_pool_cleanup_for_exec(); + fspr_pool_cleanup_for_exec(); if (attr->child_in) { - apr_file_close(attr->parent_in); + fspr_file_close(attr->parent_in); dup2(attr->child_in->filedes, STDIN_FILENO); - apr_file_close(attr->child_in); + fspr_file_close(attr->child_in); } if (attr->child_out) { - apr_file_close(attr->parent_out); + fspr_file_close(attr->parent_out); dup2(attr->child_out->filedes, STDOUT_FILENO); - apr_file_close(attr->child_out); + fspr_file_close(attr->child_out); } if (attr->child_err) { - apr_file_close(attr->parent_err); + fspr_file_close(attr->parent_err); dup2(attr->child_err->filedes, STDERR_FILENO); - apr_file_close(attr->child_err); + fspr_file_close(attr->child_err); } - apr_signal(SIGCHLD, SIG_DFL); /* not sure if this is needed or not */ + fspr_signal(SIGCHLD, SIG_DFL); /* not sure if this is needed or not */ if (attr->currdir != NULL) { if (chdir(attr->currdir) == -1) { @@ -433,7 +432,7 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, /* Only try to switch if we are running as root */ if (attr->gid != -1 && !geteuid()) { - if ((status = setgid(attr->gid))) { + if (setgid(attr->gid)) { if (attr->errfn) { attr->errfn(pool, errno, "setting of group failed"); } @@ -442,7 +441,7 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, } if (attr->uid != -1 && !geteuid()) { - if ((status = setuid(attr->uid))) { + if (setuid(attr->uid)) { if (attr->errfn) { attr->errfn(pool, errno, "setting of user failed"); } @@ -450,7 +449,7 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, } } - if ((status = limit_proc(attr)) != APR_SUCCESS) { + if (limit_proc(attr) != APR_SUCCESS) { if (attr->errfn) { attr->errfn(pool, errno, "setting of resource limits failed"); } @@ -486,7 +485,7 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, { char *ch, *onearg; - ch = onearg = apr_palloc(pool, onearg_len); + ch = onearg = fspr_palloc(pool, onearg_len); i = 0; while (args[i]) { size_t len = strlen(args[i]); @@ -506,7 +505,7 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, newargs[3] = NULL; if (attr->detached) { - apr_proc_detach(APR_PROC_DETACH_DAEMONIZE); + fspr_proc_detach(APR_PROC_DETACH_DAEMONIZE); } if (attr->cmdtype == APR_SHELLCMD) { @@ -518,14 +517,14 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, } else if (attr->cmdtype == APR_PROGRAM) { if (attr->detached) { - apr_proc_detach(APR_PROC_DETACH_DAEMONIZE); + fspr_proc_detach(APR_PROC_DETACH_DAEMONIZE); } execve(progname, (char * const *)args, (char * const *)env); } else if (attr->cmdtype == APR_PROGRAM_ENV) { if (attr->detached) { - apr_proc_detach(APR_PROC_DETACH_DAEMONIZE); + fspr_proc_detach(APR_PROC_DETACH_DAEMONIZE); } execv(progname, (char * const *)args); @@ -533,7 +532,7 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, else { /* APR_PROGRAM_PATH */ if (attr->detached) { - apr_proc_detach(APR_PROC_DETACH_DAEMONIZE); + fspr_proc_detach(APR_PROC_DETACH_DAEMONIZE); } execvp(progname, (char * const *)args); @@ -541,7 +540,7 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, if (attr->errfn) { char *desc; - desc = apr_psprintf(pool, "exec of '%s' failed", + desc = fspr_psprintf(pool, "exec of '%s' failed", progname); attr->errfn(pool, errno, desc); } @@ -552,39 +551,39 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, /* Parent process */ if (attr->child_in) { - apr_file_close(attr->child_in); + fspr_file_close(attr->child_in); } if (attr->child_out) { - apr_file_close(attr->child_out); + fspr_file_close(attr->child_out); } if (attr->child_err) { - apr_file_close(attr->child_err); + fspr_file_close(attr->child_err); } return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_proc_wait_all_procs(apr_proc_t *proc, +APR_DECLARE(fspr_status_t) fspr_proc_wait_all_procs(fspr_proc_t *proc, int *exitcode, - apr_exit_why_e *exitwhy, - apr_wait_how_e waithow, - apr_pool_t *p) + fspr_exit_why_e *exitwhy, + fspr_wait_how_e waithow, + fspr_pool_t *p) { proc->pid = -1; - return apr_proc_wait(proc, exitcode, exitwhy, waithow); + return fspr_proc_wait(proc, exitcode, exitwhy, waithow); } -APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc, - int *exitcode, apr_exit_why_e *exitwhy, - apr_wait_how_e waithow) +APR_DECLARE(fspr_status_t) fspr_proc_wait(fspr_proc_t *proc, + int *exitcode, fspr_exit_why_e *exitwhy, + fspr_wait_how_e waithow) { pid_t pstatus; int waitpid_options = WUNTRACED; int exit_int; int ignore; - apr_exit_why_e ignorewhy; + fspr_exit_why_e ignorewhy; if (exitcode == NULL) { exitcode = &ignore; @@ -634,8 +633,8 @@ APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc, return errno; } -APR_DECLARE(apr_status_t) apr_procattr_limit_set(apr_procattr_t *attr, - apr_int32_t what, +APR_DECLARE(fspr_status_t) fspr_procattr_limit_set(fspr_procattr_t *attr, + fspr_int32_t what, struct rlimit *limit) { switch(what) { diff --git a/libs/apr/threadproc/unix/procsup.c b/libs/apr/threadproc/unix/procsup.c index caf13bfa73..d37828c515 100644 --- a/libs/apr/threadproc/unix/procsup.c +++ b/libs/apr/threadproc/unix/procsup.c @@ -14,9 +14,9 @@ * limitations under the License. */ -#include "apr_arch_threadproc.h" +#include "fspr_arch_threadproc.h" -APR_DECLARE(apr_status_t) apr_proc_detach(int daemonize) +APR_DECLARE(fspr_status_t) fspr_proc_detach(int daemonize) { int x; diff --git a/libs/apr/threadproc/unix/signals.c b/libs/apr/threadproc/unix/signals.c index f44c3d7859..44da95a335 100644 --- a/libs/apr/threadproc/unix/signals.c +++ b/libs/apr/threadproc/unix/signals.c @@ -15,11 +15,11 @@ */ #define INCL_DOSEXCEPTIONS /* for OS2 */ -#include "apr_arch_threadproc.h" -#include "apr_private.h" -#include "apr_pools.h" -#include "apr_signal.h" -#include "apr_strings.h" +#include "fspr_arch_threadproc.h" +#include "fspr_private.h" +#include "fspr_pools.h" +#include "fspr_signal.h" +#include "fspr_strings.h" #include #if APR_HAS_THREADS && APR_HAVE_PTHREAD_H @@ -27,12 +27,12 @@ #endif #ifdef SIGWAIT_TAKES_ONE_ARG -#define apr_sigwait(a,b) ((*(b)=sigwait((a)))<0?-1:0) +#define fspr_sigwait(a,b) ((*(b)=sigwait((a)))<0?-1:0) #else -#define apr_sigwait(a,b) sigwait((a),(b)) +#define fspr_sigwait(a,b) sigwait((a),(b)) #endif -APR_DECLARE(apr_status_t) apr_proc_kill(apr_proc_t *proc, int signum) +APR_DECLARE(fspr_status_t) fspr_proc_kill(fspr_proc_t *proc, int signum) { #ifdef OS2 /* SIGTERM's don't work too well in OS/2 (only affects other EMX @@ -71,7 +71,7 @@ static void avoid_zombies(int signo) * from W. Richard Stevens' "Advanced Programming in the UNIX Environment" * (the version that does not automatically restart system calls). */ -APR_DECLARE(apr_sigfunc_t *) apr_signal(int signo, apr_sigfunc_t * func) +APR_DECLARE(fspr_sigfunc_t *) fspr_signal(int signo, fspr_sigfunc_t * func) { struct sigaction act, oact; @@ -111,10 +111,10 @@ APR_DECLARE(apr_sigfunc_t *) apr_signal(int signo, apr_sigfunc_t * func) * on the version of autoconf used. */ #if defined(SYS_SIGLIST_DECLARED) || HAVE_DECL_SYS_SIGLIST -void apr_signal_init(apr_pool_t *pglobal) +void fspr_signal_init(fspr_pool_t *pglobal) { } -const char *apr_signal_description_get(int signum) +const char *fspr_signal_description_get(int signum) { return sys_siglist[signum]; } @@ -145,7 +145,7 @@ static const char *signal_description[APR_NUMSIG]; } \ } while (0) -void apr_signal_init(apr_pool_t *pglobal) +void fspr_signal_init(fspr_pool_t *pglobal) { int sig; @@ -256,10 +256,10 @@ void apr_signal_init(apr_pool_t *pglobal) for (sig = 0; sig < APR_NUMSIG; ++sig) if (signal_description[sig] == NULL) - signal_description[sig] = apr_psprintf(pglobal, "signal #%d", sig); + signal_description[sig] = fspr_psprintf(pglobal, "signal #%d", sig); } -const char *apr_signal_description_get(int signum) +const char *fspr_signal_description_get(int signum) { return signum < APR_NUMSIG @@ -316,7 +316,7 @@ static void remove_sync_sigs(sigset_t *sig_mask) #endif } -APR_DECLARE(apr_status_t) apr_signal_thread(int(*signal_handler)(int signum)) +APR_DECLARE(fspr_status_t) fspr_signal_thread(int(*signal_handler)(int signum)) { sigset_t sig_mask; #if APR_HAVE_SIGWAIT @@ -380,7 +380,7 @@ APR_DECLARE(apr_status_t) apr_signal_thread(int(*signal_handler)(int signum)) #if APR_HAVE_SIGWAIT int signal_received; - if (apr_sigwait(&sig_mask, &signal_received) != 0) + if (fspr_sigwait(&sig_mask, &signal_received) != 0) { /* handle sigwait() error here */ } @@ -391,12 +391,12 @@ APR_DECLARE(apr_status_t) apr_signal_thread(int(*signal_handler)(int signum)) #elif HAVE_SIGSUSPEND sigsuspend(&sig_mask); #else -#error No apr_sigwait() and no sigsuspend() +#error No fspr_sigwait() and no sigsuspend() #endif } } -APR_DECLARE(apr_status_t) apr_setup_signal_thread(void) +APR_DECLARE(fspr_status_t) fspr_setup_signal_thread(void) { sigset_t sig_mask; int rv; @@ -432,7 +432,7 @@ APR_DECLARE(apr_status_t) apr_setup_signal_thread(void) #endif /* APR_HAS_THREADS && ... */ -APR_DECLARE(apr_status_t) apr_signal_block(int signum) +APR_DECLARE(fspr_status_t) fspr_signal_block(int signum) { #if APR_HAVE_SIGACTION sigset_t sig_mask; @@ -459,7 +459,7 @@ APR_DECLARE(apr_status_t) apr_signal_block(int signum) #endif } -APR_DECLARE(apr_status_t) apr_signal_unblock(int signum) +APR_DECLARE(fspr_status_t) fspr_signal_unblock(int signum) { #if APR_HAVE_SIGACTION sigset_t sig_mask; diff --git a/libs/apr/threadproc/unix/thread.c b/libs/apr/threadproc/unix/thread.c index 165dddc238..0deaefa1a8 100644 --- a/libs/apr/threadproc/unix/thread.c +++ b/libs/apr/threadproc/unix/thread.c @@ -14,19 +14,19 @@ * limitations under the License. */ -#include "apr.h" -#include "apr_portable.h" -#include "apr_arch_threadproc.h" +#include "fspr.h" +#include "fspr_portable.h" +#include "fspr_arch_threadproc.h" #if APR_HAS_THREADS #if APR_HAVE_PTHREAD_H /* Destroy the threadattr object */ -static apr_status_t threadattr_cleanup(void *data) +static fspr_status_t threadattr_cleanup(void *data) { - apr_threadattr_t *attr = data; - apr_status_t rv; + fspr_threadattr_t *attr = data; + fspr_status_t rv; rv = pthread_attr_destroy(&attr->attr); #ifdef PTHREAD_SETS_ERRNO @@ -37,18 +37,18 @@ static apr_status_t threadattr_cleanup(void *data) return rv; } -APR_DECLARE(apr_status_t) apr_threadattr_create(apr_threadattr_t **new, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_threadattr_create(fspr_threadattr_t **new, + fspr_pool_t *pool) { - apr_status_t stat; + fspr_status_t stat; - (*new) = apr_palloc(pool, sizeof(apr_threadattr_t)); + (*new) = fspr_palloc(pool, sizeof(fspr_threadattr_t)); (*new)->pool = pool; stat = pthread_attr_init(&(*new)->attr); if (stat == 0) { - apr_pool_cleanup_register(pool, *new, threadattr_cleanup, - apr_pool_cleanup_null); + fspr_pool_cleanup_register(pool, *new, threadattr_cleanup, + fspr_pool_cleanup_null); return APR_SUCCESS; } #ifdef PTHREAD_SETS_ERRNO @@ -60,10 +60,10 @@ APR_DECLARE(apr_status_t) apr_threadattr_create(apr_threadattr_t **new, #define DETACH_ARG(v) ((v) ? PTHREAD_CREATE_DETACHED : PTHREAD_CREATE_JOINABLE) -APR_DECLARE(apr_status_t) apr_threadattr_detach_set(apr_threadattr_t *attr, - apr_int32_t on) +APR_DECLARE(fspr_status_t) fspr_threadattr_detach_set(fspr_threadattr_t *attr, + fspr_int32_t on) { - apr_status_t stat; + fspr_status_t stat; #ifdef PTHREAD_ATTR_SETDETACHSTATE_ARG2_ADDR int arg = DETACH_ARG(v); @@ -83,7 +83,7 @@ APR_DECLARE(apr_status_t) apr_threadattr_detach_set(apr_threadattr_t *attr, } } -APR_DECLARE(apr_status_t) apr_threadattr_detach_get(apr_threadattr_t *attr) +APR_DECLARE(fspr_status_t) fspr_threadattr_detach_get(fspr_threadattr_t *attr) { int state; @@ -97,8 +97,8 @@ APR_DECLARE(apr_status_t) apr_threadattr_detach_get(apr_threadattr_t *attr) return APR_NOTDETACH; } -APR_DECLARE(apr_status_t) apr_threadattr_stacksize_set(apr_threadattr_t *attr, - apr_size_t stacksize) +APR_DECLARE(fspr_status_t) fspr_threadattr_stacksize_set(fspr_threadattr_t *attr, + fspr_size_t stacksize) { int stat; @@ -113,11 +113,11 @@ APR_DECLARE(apr_status_t) apr_threadattr_stacksize_set(apr_threadattr_t *attr, return stat; } -APR_DECLARE(apr_status_t) apr_threadattr_guardsize_set(apr_threadattr_t *attr, - apr_size_t size) +APR_DECLARE(fspr_status_t) fspr_threadattr_guardsize_set(fspr_threadattr_t *attr, + fspr_size_t size) { #ifdef HAVE_PTHREAD_ATTR_SETGUARDSIZE - apr_status_t rv; + fspr_status_t rv; rv = pthread_attr_setguardsize(&attr->attr, size); if (rv == 0) { @@ -134,7 +134,7 @@ APR_DECLARE(apr_status_t) apr_threadattr_guardsize_set(apr_threadattr_t *attr, static void *dummy_worker(void *opaque) { - apr_thread_t *thread = (apr_thread_t*)opaque; + fspr_thread_t *thread = (fspr_thread_t*)opaque; #ifdef HAVE_PTHREAD_SETSCHEDPARAM if (thread->priority) { @@ -151,23 +151,23 @@ static void *dummy_worker(void *opaque) return thread->func(thread, thread->data); } -APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new, - apr_threadattr_t *attr, - apr_thread_start_t func, +APR_DECLARE(fspr_status_t) fspr_thread_create(fspr_thread_t **new, + fspr_threadattr_t *attr, + fspr_thread_start_t func, void *data, - apr_pool_t *pool) + fspr_pool_t *pool) { - apr_status_t stat; + fspr_status_t stat; pthread_attr_t *temp; pthread_t tt; - (*new) = (apr_thread_t *)apr_pcalloc(pool, sizeof(apr_thread_t)); + (*new) = (fspr_thread_t *)fspr_pcalloc(pool, sizeof(fspr_thread_t)); if ((*new) == NULL) { return APR_ENOMEM; } - (*new)->td = (pthread_t *)apr_pcalloc(pool, sizeof(pthread_t)); + (*new)->td = (pthread_t *)fspr_pcalloc(pool, sizeof(pthread_t)); if ((*new)->td == NULL) { return APR_ENOMEM; @@ -182,7 +182,7 @@ APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new, else temp = NULL; - stat = apr_pool_create(&(*new)->pool, pool); + stat = fspr_pool_create(&(*new)->pool, pool); if (stat != APR_SUCCESS) { return stat; } @@ -205,31 +205,31 @@ APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new, } } -APR_DECLARE(apr_os_thread_t) apr_os_thread_current(void) +APR_DECLARE(fspr_os_thread_t) fspr_os_thread_current(void) { return pthread_self(); } -APR_DECLARE(int) apr_os_thread_equal(apr_os_thread_t tid1, - apr_os_thread_t tid2) +APR_DECLARE(int) fspr_os_thread_equal(fspr_os_thread_t tid1, + fspr_os_thread_t tid2) { return pthread_equal(tid1, tid2); } -APR_DECLARE(apr_status_t) apr_thread_exit(apr_thread_t *thd, - apr_status_t retval) +APR_DECLARE(fspr_status_t) fspr_thread_exit(fspr_thread_t *thd, + fspr_status_t retval) { thd->exitval = retval; - apr_pool_destroy(thd->pool); + fspr_pool_destroy(thd->pool); pthread_exit(NULL); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_join(apr_status_t *retval, - apr_thread_t *thd) +APR_DECLARE(fspr_status_t) fspr_thread_join(fspr_status_t *retval, + fspr_thread_t *thd) { - apr_status_t stat; - apr_status_t *thread_stat; + fspr_status_t stat; + fspr_status_t *thread_stat; if ((stat = pthread_join(*thd->td,(void *)&thread_stat)) == 0) { *retval = thd->exitval; @@ -244,9 +244,9 @@ APR_DECLARE(apr_status_t) apr_thread_join(apr_status_t *retval, } } -APR_DECLARE(apr_status_t) apr_thread_detach(apr_thread_t *thd) +APR_DECLARE(fspr_status_t) fspr_thread_detach(fspr_thread_t *thd) { - apr_status_t stat; + fspr_status_t stat; #ifdef PTHREAD_DETACH_ARG1_ADDR if ((stat = pthread_detach(thd->td)) == 0) { @@ -265,40 +265,40 @@ APR_DECLARE(apr_status_t) apr_thread_detach(apr_thread_t *thd) } } -void apr_thread_yield() +void fspr_thread_yield() { } -APR_DECLARE(apr_status_t) apr_thread_data_get(void **data, const char *key, - apr_thread_t *thread) +APR_DECLARE(fspr_status_t) fspr_thread_data_get(void **data, const char *key, + fspr_thread_t *thread) { - return apr_pool_userdata_get(data, key, thread->pool); + return fspr_pool_userdata_get(data, key, thread->pool); } -APR_DECLARE(apr_status_t) apr_thread_data_set(void *data, const char *key, - apr_status_t (*cleanup)(void *), - apr_thread_t *thread) +APR_DECLARE(fspr_status_t) fspr_thread_data_set(void *data, const char *key, + fspr_status_t (*cleanup)(void *), + fspr_thread_t *thread) { - return apr_pool_userdata_set(data, key, cleanup, thread->pool); + return fspr_pool_userdata_set(data, key, cleanup, thread->pool); } -APR_DECLARE(apr_status_t) apr_os_thread_get(apr_os_thread_t **thethd, - apr_thread_t *thd) +APR_DECLARE(fspr_status_t) fspr_os_thread_get(fspr_os_thread_t **thethd, + fspr_thread_t *thd) { *thethd = thd->td; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_os_thread_put(apr_thread_t **thd, - apr_os_thread_t *thethd, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_os_thread_put(fspr_thread_t **thd, + fspr_os_thread_t *thethd, + fspr_pool_t *pool) { if (pool == NULL) { return APR_ENOPOOL; } if ((*thd) == NULL) { - (*thd) = (apr_thread_t *)apr_pcalloc(pool, sizeof(apr_thread_t)); + (*thd) = (fspr_thread_t *)fspr_pcalloc(pool, sizeof(fspr_thread_t)); (*thd)->pool = pool; } @@ -306,17 +306,17 @@ APR_DECLARE(apr_status_t) apr_os_thread_put(apr_thread_t **thd, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_once_init(apr_thread_once_t **control, - apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_thread_once_init(fspr_thread_once_t **control, + fspr_pool_t *p) { static const pthread_once_t once_init = PTHREAD_ONCE_INIT; - *control = apr_palloc(p, sizeof(**control)); + *control = fspr_palloc(p, sizeof(**control)); (*control)->once = once_init; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_once(apr_thread_once_t *control, +APR_DECLARE(fspr_status_t) fspr_thread_once(fspr_thread_once_t *control, void (*func)(void)) { return pthread_once(&control->once, func); @@ -330,9 +330,9 @@ APR_POOL_IMPLEMENT_ACCESSOR(thread) #if !APR_HAS_THREADS /* avoid warning for no prototype */ -APR_DECLARE(apr_status_t) apr_os_thread_get(void); +APR_DECLARE(fspr_status_t) fspr_os_thread_get(void); -APR_DECLARE(apr_status_t) apr_os_thread_get(void) +APR_DECLARE(fspr_status_t) fspr_os_thread_get(void) { return APR_ENOTIMPL; } diff --git a/libs/apr/threadproc/unix/threadpriv.c b/libs/apr/threadproc/unix/threadpriv.c index c278520380..fcc0e4d753 100644 --- a/libs/apr/threadproc/unix/threadpriv.c +++ b/libs/apr/threadproc/unix/threadpriv.c @@ -14,18 +14,18 @@ * limitations under the License. */ -#include "apr.h" -#include "apr_portable.h" -#include "apr_arch_threadproc.h" +#include "fspr.h" +#include "fspr_portable.h" +#include "fspr_arch_threadproc.h" #if APR_HAS_THREADS #if APR_HAVE_PTHREAD_H -APR_DECLARE(apr_status_t) apr_threadkey_private_create(apr_threadkey_t **key, +APR_DECLARE(fspr_status_t) fspr_threadkey_private_create(fspr_threadkey_t **key, void (*dest)(void *), - apr_pool_t *pool) + fspr_pool_t *pool) { - (*key) = (apr_threadkey_t *)apr_pcalloc(pool, sizeof(apr_threadkey_t)); + (*key) = (fspr_threadkey_t *)fspr_pcalloc(pool, sizeof(fspr_threadkey_t)); if ((*key) == NULL) { return APR_ENOMEM; @@ -37,8 +37,8 @@ APR_DECLARE(apr_status_t) apr_threadkey_private_create(apr_threadkey_t **key, } -APR_DECLARE(apr_status_t) apr_threadkey_private_get(void **new, - apr_threadkey_t *key) +APR_DECLARE(fspr_status_t) fspr_threadkey_private_get(void **new, + fspr_threadkey_t *key) { #ifdef PTHREAD_GETSPECIFIC_TAKES_TWO_ARGS if (pthread_getspecific(key->key,new)) @@ -49,10 +49,10 @@ APR_DECLARE(apr_status_t) apr_threadkey_private_get(void **new, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_threadkey_private_set(void *priv, - apr_threadkey_t *key) +APR_DECLARE(fspr_status_t) fspr_threadkey_private_set(void *priv, + fspr_threadkey_t *key) { - apr_status_t stat; + fspr_status_t stat; if ((stat = pthread_setspecific(key->key, priv)) == 0) { return APR_SUCCESS; @@ -62,10 +62,10 @@ APR_DECLARE(apr_status_t) apr_threadkey_private_set(void *priv, } } -APR_DECLARE(apr_status_t) apr_threadkey_private_delete(apr_threadkey_t *key) +APR_DECLARE(fspr_status_t) fspr_threadkey_private_delete(fspr_threadkey_t *key) { #ifdef HAVE_PTHREAD_KEY_DELETE - apr_status_t stat; + fspr_status_t stat; if ((stat = pthread_key_delete(key->key)) == 0) { return APR_SUCCESS; @@ -77,36 +77,36 @@ APR_DECLARE(apr_status_t) apr_threadkey_private_delete(apr_threadkey_t *key) #endif } -APR_DECLARE(apr_status_t) apr_threadkey_data_get(void **data, const char *key, - apr_threadkey_t *threadkey) +APR_DECLARE(fspr_status_t) fspr_threadkey_data_get(void **data, const char *key, + fspr_threadkey_t *threadkey) { - return apr_pool_userdata_get(data, key, threadkey->pool); + return fspr_pool_userdata_get(data, key, threadkey->pool); } -APR_DECLARE(apr_status_t) apr_threadkey_data_set(void *data, const char *key, - apr_status_t (*cleanup)(void *), - apr_threadkey_t *threadkey) +APR_DECLARE(fspr_status_t) fspr_threadkey_data_set(void *data, const char *key, + fspr_status_t (*cleanup)(void *), + fspr_threadkey_t *threadkey) { - return apr_pool_userdata_set(data, key, cleanup, threadkey->pool); + return fspr_pool_userdata_set(data, key, cleanup, threadkey->pool); } -APR_DECLARE(apr_status_t) apr_os_threadkey_get(apr_os_threadkey_t *thekey, - apr_threadkey_t *key) +APR_DECLARE(fspr_status_t) fspr_os_threadkey_get(fspr_os_threadkey_t *thekey, + fspr_threadkey_t *key) { *thekey = key->key; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_os_threadkey_put(apr_threadkey_t **key, - apr_os_threadkey_t *thekey, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_os_threadkey_put(fspr_threadkey_t **key, + fspr_os_threadkey_t *thekey, + fspr_pool_t *pool) { if (pool == NULL) { return APR_ENOPOOL; } if ((*key) == NULL) { - (*key) = (apr_threadkey_t *)apr_pcalloc(pool, sizeof(apr_threadkey_t)); + (*key) = (fspr_threadkey_t *)fspr_pcalloc(pool, sizeof(fspr_threadkey_t)); (*key)->pool = pool; } @@ -119,9 +119,9 @@ APR_DECLARE(apr_status_t) apr_os_threadkey_put(apr_threadkey_t **key, #if !APR_HAS_THREADS /* avoid warning for no prototype */ -APR_DECLARE(apr_status_t) apr_os_threadkey_get(void); +APR_DECLARE(fspr_status_t) fspr_os_threadkey_get(void); -APR_DECLARE(apr_status_t) apr_os_threadkey_get(void) +APR_DECLARE(fspr_status_t) fspr_os_threadkey_get(void) { return APR_ENOTIMPL; } diff --git a/libs/apr/threadproc/win32/proc.c b/libs/apr/threadproc/win32/proc.c index 014dfc8428..24f725d3dd 100644 --- a/libs/apr/threadproc/win32/proc.c +++ b/libs/apr/threadproc/win32/proc.c @@ -14,15 +14,15 @@ * limitations under the License. */ -#include "win32/apr_arch_threadproc.h" -#include "win32/apr_arch_file_io.h" +#include "win32/fspr_arch_threadproc.h" +#include "win32/fspr_arch_file_io.h" -#include "apr_thread_proc.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_strings.h" -#include "apr_portable.h" -#include "apr_lib.h" +#include "fspr_thread_proc.h" +#include "fspr_file_io.h" +#include "fspr_general.h" +#include "fspr_strings.h" +#include "fspr_portable.h" +#include "fspr_lib.h" #include #if APR_HAVE_SIGNAL_H #include @@ -52,21 +52,21 @@ * */ -APR_DECLARE(apr_status_t) apr_procattr_create(apr_procattr_t **new, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_procattr_create(fspr_procattr_t **new, + fspr_pool_t *pool) { - (*new) = (apr_procattr_t *)apr_pcalloc(pool, sizeof(apr_procattr_t)); + (*new) = (fspr_procattr_t *)fspr_pcalloc(pool, sizeof(fspr_procattr_t)); (*new)->pool = pool; (*new)->cmdtype = APR_PROGRAM; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_procattr_io_set(apr_procattr_t *attr, - apr_int32_t in, - apr_int32_t out, - apr_int32_t err) +APR_DECLARE(fspr_status_t) fspr_procattr_io_set(fspr_procattr_t *attr, + fspr_int32_t in, + fspr_int32_t out, + fspr_int32_t err) { - apr_status_t stat = APR_SUCCESS; + fspr_status_t stat = APR_SUCCESS; if (in) { /* APR_CHILD_BLOCK maps to APR_WRITE_BLOCK, while @@ -79,138 +79,138 @@ APR_DECLARE(apr_status_t) apr_procattr_io_set(apr_procattr_t *attr, in = APR_READ_BLOCK; else if (in == APR_PARENT_BLOCK) in = APR_WRITE_BLOCK; - stat = apr_create_nt_pipe(&attr->child_in, &attr->parent_in, in, + stat = fspr_create_nt_pipe(&attr->child_in, &attr->parent_in, in, attr->pool); if (stat == APR_SUCCESS) - stat = apr_file_inherit_unset(attr->parent_in); + stat = fspr_file_inherit_unset(attr->parent_in); } if (out && stat == APR_SUCCESS) { - stat = apr_create_nt_pipe(&attr->parent_out, &attr->child_out, out, + stat = fspr_create_nt_pipe(&attr->parent_out, &attr->child_out, out, attr->pool); if (stat == APR_SUCCESS) - stat = apr_file_inherit_unset(attr->parent_out); + stat = fspr_file_inherit_unset(attr->parent_out); } if (err && stat == APR_SUCCESS) { - stat = apr_create_nt_pipe(&attr->parent_err, &attr->child_err, err, + stat = fspr_create_nt_pipe(&attr->parent_err, &attr->child_err, err, attr->pool); if (stat == APR_SUCCESS) - stat = apr_file_inherit_unset(attr->parent_err); + stat = fspr_file_inherit_unset(attr->parent_err); } return stat; } -APR_DECLARE(apr_status_t) apr_procattr_child_in_set(apr_procattr_t *attr, - apr_file_t *child_in, - apr_file_t *parent_in) +APR_DECLARE(fspr_status_t) fspr_procattr_child_in_set(fspr_procattr_t *attr, + fspr_file_t *child_in, + fspr_file_t *parent_in) { - apr_status_t rv = APR_SUCCESS; + fspr_status_t rv = APR_SUCCESS; if (child_in) { if (attr->child_in == NULL) - rv = apr_file_dup(&attr->child_in, child_in, attr->pool); + rv = fspr_file_dup(&attr->child_in, child_in, attr->pool); else - rv = apr_file_dup2(attr->child_in, child_in, attr->pool); + rv = fspr_file_dup2(attr->child_in, child_in, attr->pool); if (rv == APR_SUCCESS) - rv = apr_file_inherit_set(attr->child_in); + rv = fspr_file_inherit_set(attr->child_in); } if (parent_in && rv == APR_SUCCESS) { if (attr->parent_in == NULL) - rv = apr_file_dup(&attr->parent_in, parent_in, attr->pool); + rv = fspr_file_dup(&attr->parent_in, parent_in, attr->pool); else - rv = apr_file_dup2(attr->parent_in, parent_in, attr->pool); + rv = fspr_file_dup2(attr->parent_in, parent_in, attr->pool); } return rv; } -APR_DECLARE(apr_status_t) apr_procattr_child_out_set(apr_procattr_t *attr, - apr_file_t *child_out, - apr_file_t *parent_out) +APR_DECLARE(fspr_status_t) fspr_procattr_child_out_set(fspr_procattr_t *attr, + fspr_file_t *child_out, + fspr_file_t *parent_out) { - apr_status_t rv = APR_SUCCESS; + fspr_status_t rv = APR_SUCCESS; if (child_out) { if (attr->child_out == NULL) - rv = apr_file_dup(&attr->child_out, child_out, attr->pool); + rv = fspr_file_dup(&attr->child_out, child_out, attr->pool); else - rv = apr_file_dup2(attr->child_out, child_out, attr->pool); + rv = fspr_file_dup2(attr->child_out, child_out, attr->pool); if (rv == APR_SUCCESS) - rv = apr_file_inherit_set(attr->child_out); + rv = fspr_file_inherit_set(attr->child_out); } if (parent_out && rv == APR_SUCCESS) { if (attr->parent_out == NULL) - rv = apr_file_dup(&attr->parent_out, parent_out, attr->pool); + rv = fspr_file_dup(&attr->parent_out, parent_out, attr->pool); else - rv = apr_file_dup2(attr->parent_out, parent_out, attr->pool); + rv = fspr_file_dup2(attr->parent_out, parent_out, attr->pool); } return rv; } -APR_DECLARE(apr_status_t) apr_procattr_child_err_set(apr_procattr_t *attr, - apr_file_t *child_err, - apr_file_t *parent_err) +APR_DECLARE(fspr_status_t) fspr_procattr_child_err_set(fspr_procattr_t *attr, + fspr_file_t *child_err, + fspr_file_t *parent_err) { - apr_status_t rv = APR_SUCCESS; + fspr_status_t rv = APR_SUCCESS; if (child_err) { if (attr->child_err == NULL) - rv = apr_file_dup(&attr->child_err, child_err, attr->pool); + rv = fspr_file_dup(&attr->child_err, child_err, attr->pool); else - rv = apr_file_dup2(attr->child_err, child_err, attr->pool); + rv = fspr_file_dup2(attr->child_err, child_err, attr->pool); if (rv == APR_SUCCESS) - rv = apr_file_inherit_set(attr->child_err); + rv = fspr_file_inherit_set(attr->child_err); } if (parent_err && rv == APR_SUCCESS) { if (attr->parent_err == NULL) - rv = apr_file_dup(&attr->parent_err, parent_err, attr->pool); + rv = fspr_file_dup(&attr->parent_err, parent_err, attr->pool); else - rv = apr_file_dup2(attr->parent_err, parent_err, attr->pool); + rv = fspr_file_dup2(attr->parent_err, parent_err, attr->pool); } return rv; } -APR_DECLARE(apr_status_t) apr_procattr_dir_set(apr_procattr_t *attr, +APR_DECLARE(fspr_status_t) fspr_procattr_dir_set(fspr_procattr_t *attr, const char *dir) { /* curr dir must be in native format, there are all sorts of bugs in * the NT library loading code that flunk the '/' parsing test. */ - return apr_filepath_merge(&attr->currdir, NULL, dir, + return fspr_filepath_merge(&attr->currdir, NULL, dir, APR_FILEPATH_NATIVE, attr->pool); } -APR_DECLARE(apr_status_t) apr_procattr_cmdtype_set(apr_procattr_t *attr, - apr_cmdtype_e cmd) +APR_DECLARE(fspr_status_t) fspr_procattr_cmdtype_set(fspr_procattr_t *attr, + fspr_cmdtype_e cmd) { attr->cmdtype = cmd; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_procattr_detach_set(apr_procattr_t *attr, - apr_int32_t det) +APR_DECLARE(fspr_status_t) fspr_procattr_detach_set(fspr_procattr_t *attr, + fspr_int32_t det) { attr->detached = det; return APR_SUCCESS; } -static apr_status_t attr_cleanup(void *theattr) +static fspr_status_t attr_cleanup(void *theattr) { - apr_procattr_t *attr = (apr_procattr_t *)theattr; + fspr_procattr_t *attr = (fspr_procattr_t *)theattr; if (attr->user_token) CloseHandle(attr->user_token); attr->user_token = NULL; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_procattr_user_set(apr_procattr_t *attr, +APR_DECLARE(fspr_status_t) fspr_procattr_user_set(fspr_procattr_t *attr, const char *username, const char *password) { @@ -218,18 +218,18 @@ APR_DECLARE(apr_status_t) apr_procattr_user_set(apr_procattr_t *attr, return APR_ENOTIMPL; #else HANDLE user; - apr_wchar_t *wusername = NULL; - apr_wchar_t *wpassword = NULL; - apr_status_t rv; - apr_size_t len, wlen; + fspr_wchar_t *wusername = NULL; + fspr_wchar_t *wpassword = NULL; + fspr_status_t rv; + fspr_size_t len, wlen; - if (apr_os_level >= APR_WIN_NT_4) + if (fspr_os_level >= APR_WIN_NT_4) { if (attr->user_token) { /* Cannot set that twice */ if (attr->errfn) { attr->errfn(attr->pool, 0, - apr_pstrcat(attr->pool, + fspr_pstrcat(attr->pool, "function called twice" " on username: ", username, NULL)); } @@ -237,12 +237,12 @@ APR_DECLARE(apr_status_t) apr_procattr_user_set(apr_procattr_t *attr, } len = strlen(username) + 1; wlen = len; - wusername = apr_palloc(attr->pool, wlen * sizeof(apr_wchar_t)); - if ((rv = apr_conv_utf8_to_ucs2(username, &len, wusername, &wlen)) + wusername = fspr_palloc(attr->pool, wlen * sizeof(fspr_wchar_t)); + if ((rv = fspr_conv_utf8_to_ucs2(username, &len, wusername, &wlen)) != APR_SUCCESS) { if (attr->errfn) { attr->errfn(attr->pool, rv, - apr_pstrcat(attr->pool, + fspr_pstrcat(attr->pool, "utf8 to ucs2 conversion failed" " on username: ", username, NULL)); } @@ -251,12 +251,12 @@ APR_DECLARE(apr_status_t) apr_procattr_user_set(apr_procattr_t *attr, if (password) { len = strlen(password) + 1; wlen = len; - wpassword = apr_palloc(attr->pool, wlen * sizeof(apr_wchar_t)); - if ((rv = apr_conv_utf8_to_ucs2(password, &len, wpassword, &wlen)) + wpassword = fspr_palloc(attr->pool, wlen * sizeof(fspr_wchar_t)); + if ((rv = fspr_conv_utf8_to_ucs2(password, &len, wpassword, &wlen)) != APR_SUCCESS) { if (attr->errfn) { attr->errfn(attr->pool, rv, - apr_pstrcat(attr->pool, + fspr_pstrcat(attr->pool, "utf8 to ucs2 conversion failed" " on password: ", password, NULL)); } @@ -270,10 +270,10 @@ APR_DECLARE(apr_status_t) apr_procattr_user_set(apr_procattr_t *attr, LOGON32_PROVIDER_DEFAULT, &user)) { /* Logon Failed */ - return apr_get_os_error(); + return fspr_get_os_error(); } if (wpassword) - memset(wpassword, 0, wlen * sizeof(apr_wchar_t)); + memset(wpassword, 0, wlen * sizeof(fspr_wchar_t)); /* Get the primary token for user */ if (!DuplicateTokenEx(user, TOKEN_QUERY | TOKEN_DUPLICATE | TOKEN_ASSIGN_PRIMARY, @@ -282,24 +282,24 @@ APR_DECLARE(apr_status_t) apr_procattr_user_set(apr_procattr_t *attr, TokenPrimary, &(attr->user_token))) { /* Failed to duplicate the user token */ - rv = apr_get_os_error(); + rv = fspr_get_os_error(); CloseHandle(user); return rv; } CloseHandle(user); - attr->sd = apr_pcalloc(attr->pool, SECURITY_DESCRIPTOR_MIN_LENGTH); + attr->sd = fspr_pcalloc(attr->pool, SECURITY_DESCRIPTOR_MIN_LENGTH); InitializeSecurityDescriptor(attr->sd, SECURITY_DESCRIPTOR_REVISION); SetSecurityDescriptorDacl(attr->sd, -1, 0, 0); - attr->sa = apr_palloc(attr->pool, sizeof(SECURITY_ATTRIBUTES)); + attr->sa = fspr_palloc(attr->pool, sizeof(SECURITY_ATTRIBUTES)); attr->sa->nLength = sizeof (SECURITY_ATTRIBUTES); attr->sa->lpSecurityDescriptor = attr->sd; attr->sa->bInheritHandle = TRUE; /* register the cleanup */ - apr_pool_cleanup_register(attr->pool, (void *)attr, + fspr_pool_cleanup_register(attr->pool, (void *)attr, attr_cleanup, - apr_pool_cleanup_null); + fspr_pool_cleanup_null); return APR_SUCCESS; } else @@ -307,7 +307,7 @@ APR_DECLARE(apr_status_t) apr_procattr_user_set(apr_procattr_t *attr, #endif } -APR_DECLARE(apr_status_t) apr_procattr_group_set(apr_procattr_t *attr, +APR_DECLARE(fspr_status_t) fspr_procattr_group_set(fspr_procattr_t *attr, const char *groupname) { /* Always return SUCCESS cause groups are irrelevant */ @@ -318,20 +318,20 @@ static const char* has_space(const char *str) { const char *ch; for (ch = str; *ch; ++ch) { - if (apr_isspace(*ch)) { + if (fspr_isspace(*ch)) { return ch; } } return NULL; } -static char *apr_caret_escape_args(apr_pool_t *p, const char *str) +static char *fspr_caret_escape_args(fspr_pool_t *p, const char *str) { char *cmd; unsigned char *d; const unsigned char *s; - cmd = apr_palloc(p, 2 * strlen(str) + 1); /* Be safe */ + cmd = fspr_palloc(p, 2 * strlen(str) + 1); /* Be safe */ d = (unsigned char *)cmd; s = (const unsigned char *)str; for (; *s; ++s) { @@ -356,36 +356,36 @@ static char *apr_caret_escape_args(apr_pool_t *p, const char *str) return cmd; } -APR_DECLARE(apr_status_t) apr_procattr_child_errfn_set(apr_procattr_t *attr, - apr_child_errfn_t *errfn) +APR_DECLARE(fspr_status_t) fspr_procattr_child_errfn_set(fspr_procattr_t *attr, + fspr_child_errfn_t *errfn) { attr->errfn = errfn; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_procattr_error_check_set(apr_procattr_t *attr, - apr_int32_t chk) +APR_DECLARE(fspr_status_t) fspr_procattr_error_check_set(fspr_procattr_t *attr, + fspr_int32_t chk) { attr->errchk = chk; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_procattr_addrspace_set(apr_procattr_t *attr, - apr_int32_t addrspace) +APR_DECLARE(fspr_status_t) fspr_procattr_addrspace_set(fspr_procattr_t *attr, + fspr_int32_t addrspace) { /* won't ever be used on this platform, so don't save the flag */ return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, +APR_DECLARE(fspr_status_t) fspr_proc_create(fspr_proc_t *new, const char *progname, const char * const *args, const char * const *env, - apr_procattr_t *attr, - apr_pool_t *pool) + fspr_procattr_t *attr, + fspr_pool_t *pool) { - apr_status_t rv; - apr_size_t i; + fspr_status_t rv; + fspr_size_t i; const char *argv0; char *cmdline; char *pEnvBlock; @@ -404,7 +404,7 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, * not manage the stdio handles properly when running old 16 * bit executables if the detached attribute is set. */ - if (apr_os_level >= APR_WIN_NT) { + if (fspr_os_level >= APR_WIN_NT) { /* * XXX DETACHED_PROCESS won't on Win9x at all; on NT/W2K * 16 bit executables fail (MS KB: Q150956) @@ -418,16 +418,16 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, * XXX progname must be NULL if this is a 16 bit app running in WOW */ if (progname[0] == '\"') { - progname = apr_pstrndup(pool, progname + 1, strlen(progname) - 2); + progname = fspr_pstrndup(pool, progname + 1, strlen(progname) - 2); } if (attr->cmdtype == APR_PROGRAM || attr->cmdtype == APR_PROGRAM_ENV) { char *fullpath = NULL; - if ((rv = apr_filepath_merge(&fullpath, attr->currdir, progname, + if ((rv = fspr_filepath_merge(&fullpath, attr->currdir, progname, APR_FILEPATH_NATIVE, pool)) != APR_SUCCESS) { if (attr->errfn) { attr->errfn(pool, rv, - apr_pstrcat(pool, "filepath_merge failed.", + fspr_pstrcat(pool, "filepath_merge failed.", " currdir: ", attr->currdir, " progname: ", progname, NULL)); } @@ -437,21 +437,21 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, } else { /* Do not fail if the path isn't parseable for APR_PROGRAM_PATH - * or APR_SHELLCMD. We only invoke apr_filepath_merge (with no + * or APR_SHELLCMD. We only invoke fspr_filepath_merge (with no * left hand side expression) in order to correct the path slash * delimiters. But the filename doesn't need to be in the CWD, * nor does it need to be a filename at all (it could be a * built-in shell command.) */ char *fullpath = NULL; - if ((rv = apr_filepath_merge(&fullpath, "", progname, + if ((rv = fspr_filepath_merge(&fullpath, "", progname, APR_FILEPATH_NATIVE, pool)) == APR_SUCCESS) { progname = fullpath; } } if (has_space(progname)) { - argv0 = apr_pstrcat(pool, "\"", progname, "\"", NULL); + argv0 = fspr_pstrcat(pool, "\"", progname, "\"", NULL); } else { argv0 = progname; @@ -461,10 +461,10 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, cmdline = ""; for (i = 1; args && args[i]; ++i) { if (has_space(args[i]) || !args[i][0]) { - cmdline = apr_pstrcat(pool, cmdline, " \"", args[i], "\"", NULL); + cmdline = fspr_pstrcat(pool, cmdline, " \"", args[i], "\"", NULL); } else { - cmdline = apr_pstrcat(pool, cmdline, " ", args[i], NULL); + cmdline = fspr_pstrcat(pool, cmdline, " ", args[i], NULL); } } @@ -478,22 +478,22 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, return APR_EINVAL; } if (shellcmd[0] == '"') { - progname = apr_pstrndup(pool, shellcmd + 1, strlen(shellcmd) - 2); + progname = fspr_pstrndup(pool, shellcmd + 1, strlen(shellcmd) - 2); } else { progname = shellcmd; if (has_space(shellcmd)) { - shellcmd = apr_pstrcat(pool, "\"", shellcmd, "\"", NULL); + shellcmd = fspr_pstrcat(pool, "\"", shellcmd, "\"", NULL); } } /* Command.com does not support a quoted command, while cmd.exe demands one. */ i = strlen(progname); if (i >= 11 && strcasecmp(progname + i - 11, "command.com") == 0) { - cmdline = apr_pstrcat(pool, shellcmd, " /C ", argv0, cmdline, NULL); + cmdline = fspr_pstrcat(pool, shellcmd, " /C ", argv0, cmdline, NULL); } else { - cmdline = apr_pstrcat(pool, shellcmd, " /C \"", argv0, cmdline, "\"", NULL); + cmdline = fspr_pstrcat(pool, shellcmd, " /C \"", argv0, cmdline, "\"", NULL); } } else @@ -517,12 +517,12 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, return APR_EINVAL; } if (shellcmd[0] == '"') { - progname = apr_pstrndup(pool, shellcmd + 1, strlen(shellcmd) - 2); + progname = fspr_pstrndup(pool, shellcmd + 1, strlen(shellcmd) - 2); } else { progname = shellcmd; if (has_space(shellcmd)) { - shellcmd = apr_pstrcat(pool, "\"", shellcmd, "\"", NULL); + shellcmd = fspr_pstrcat(pool, "\"", shellcmd, "\"", NULL); } } i = strlen(progname); @@ -532,7 +532,7 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, * until this moment in all four code paths, with some flags * to toggle 'which flavor' is needed. */ - cmdline = apr_pstrcat(pool, shellcmd, " /C ", argv0, cmdline, NULL); + cmdline = fspr_pstrcat(pool, shellcmd, " /C ", argv0, cmdline, NULL); } else { /* We must protect the cmdline args from any interpolation - this @@ -542,16 +542,16 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, * the shift-state to be toggled, and the application will * not see the caret escapes. */ - cmdline = apr_caret_escape_args(pool, cmdline); + cmdline = fspr_caret_escape_args(pool, cmdline); /* * Our app name must always be quoted so the quotes surrounding * the entire /c "command args" are unambigious. */ if (*argv0 != '"') { - cmdline = apr_pstrcat(pool, shellcmd, " /C \"\"", argv0, "\"", cmdline, "\"", NULL); + cmdline = fspr_pstrcat(pool, shellcmd, " /C \"\"", argv0, "\"", cmdline, "\"", NULL); } else { - cmdline = apr_pstrcat(pool, shellcmd, " /C \"", argv0, cmdline, "\"", NULL); + cmdline = fspr_pstrcat(pool, shellcmd, " /C \"", argv0, cmdline, "\"", NULL); } } } @@ -563,7 +563,7 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, * would succeed, but "c:\bin\aprtest" or "aprtest.exe" * can fail. */ - cmdline = apr_pstrcat(pool, argv0, cmdline, NULL); + cmdline = fspr_pstrcat(pool, argv0, cmdline, NULL); if (attr->cmdtype == APR_PROGRAM_PATH) { progname = NULL; @@ -576,7 +576,7 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, pEnvBlock = NULL; } else { - apr_size_t iEnvBlockLen; + fspr_size_t iEnvBlockLen; /* * Win32's CreateProcess call requires that the environment * be passed in an environment block, a null terminated block of @@ -594,20 +594,20 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, #if APR_HAS_UNICODE_FS IF_WIN_OS_IS_UNICODE { - apr_wchar_t *pNext; - pEnvBlock = (char *)apr_palloc(pool, iEnvBlockLen * 2); + fspr_wchar_t *pNext; + pEnvBlock = (char *)fspr_palloc(pool, iEnvBlockLen * 2); dwCreationFlags |= CREATE_UNICODE_ENVIRONMENT; i = 0; - pNext = (apr_wchar_t*)pEnvBlock; + pNext = (fspr_wchar_t*)pEnvBlock; while (env[i]) { - apr_size_t in = strlen(env[i]) + 1; - if ((rv = apr_conv_utf8_to_ucs2(env[i], &in, + fspr_size_t in = strlen(env[i]) + 1; + if ((rv = fspr_conv_utf8_to_ucs2(env[i], &in, pNext, &iEnvBlockLen)) != APR_SUCCESS) { if (attr->errfn) { attr->errfn(pool, rv, - apr_pstrcat(pool, + fspr_pstrcat(pool, "utf8 to ucs2 conversion failed" " on this string: ", env[i], NULL)); } @@ -625,7 +625,7 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, ELSE_WIN_OS_IS_ANSI { char *pNext; - pEnvBlock = (char *)apr_palloc(pool, iEnvBlockLen); + pEnvBlock = (char *)fspr_palloc(pool, iEnvBlockLen); i = 0; pNext = pEnvBlock; @@ -647,19 +647,19 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, IF_WIN_OS_IS_UNICODE { STARTUPINFOW si; - apr_wchar_t *wprg = NULL; - apr_wchar_t *wcmd = NULL; - apr_wchar_t *wcwd = NULL; + fspr_wchar_t *wprg = NULL; + fspr_wchar_t *wcmd = NULL; + fspr_wchar_t *wcwd = NULL; if (progname) { - apr_size_t nprg = strlen(progname) + 1; - apr_size_t nwprg = nprg + 6; - wprg = apr_palloc(pool, nwprg * sizeof(wprg[0])); - if ((rv = apr_conv_utf8_to_ucs2(progname, &nprg, wprg, &nwprg)) + fspr_size_t nprg = strlen(progname) + 1; + fspr_size_t nwprg = nprg + 6; + wprg = fspr_palloc(pool, nwprg * sizeof(wprg[0])); + if ((rv = fspr_conv_utf8_to_ucs2(progname, &nprg, wprg, &nwprg)) != APR_SUCCESS) { if (attr->errfn) { attr->errfn(pool, rv, - apr_pstrcat(pool, + fspr_pstrcat(pool, "utf8 to ucs2 conversion failed" " on progname: ", progname, NULL)); } @@ -668,14 +668,14 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, } if (cmdline) { - apr_size_t ncmd = strlen(cmdline) + 1; - apr_size_t nwcmd = ncmd; - wcmd = apr_palloc(pool, nwcmd * sizeof(wcmd[0])); - if ((rv = apr_conv_utf8_to_ucs2(cmdline, &ncmd, wcmd, &nwcmd)) + fspr_size_t ncmd = strlen(cmdline) + 1; + fspr_size_t nwcmd = ncmd; + wcmd = fspr_palloc(pool, nwcmd * sizeof(wcmd[0])); + if ((rv = fspr_conv_utf8_to_ucs2(cmdline, &ncmd, wcmd, &nwcmd)) != APR_SUCCESS) { if (attr->errfn) { attr->errfn(pool, rv, - apr_pstrcat(pool, + fspr_pstrcat(pool, "utf8 to ucs2 conversion failed" " on cmdline: ", cmdline, NULL)); } @@ -685,15 +685,15 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, if (attr->currdir) { - apr_size_t ncwd = strlen(attr->currdir) + 1; - apr_size_t nwcwd = ncwd; - wcwd = apr_palloc(pool, ncwd * sizeof(wcwd[0])); - if ((rv = apr_conv_utf8_to_ucs2(attr->currdir, &ncwd, + fspr_size_t ncwd = strlen(attr->currdir) + 1; + fspr_size_t nwcwd = ncwd; + wcwd = fspr_palloc(pool, ncwd * sizeof(wcwd[0])); + if ((rv = fspr_conv_utf8_to_ucs2(attr->currdir, &ncwd, wcwd, &nwcwd)) != APR_SUCCESS) { if (attr->errfn) { attr->errfn(pool, rv, - apr_pstrcat(pool, + fspr_pstrcat(pool, "utf8 to ucs2 conversion failed" " on currdir: ", attr->currdir, NULL)); } @@ -732,7 +732,7 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, si.lpDesktop = L"Winsta0\\Default"; if (!ImpersonateLoggedOnUser(attr->user_token)) { /* failed to impersonate the logged user */ - rv = apr_get_os_error(); + rv = fspr_get_os_error(); CloseHandle(attr->user_token); attr->user_token = NULL; return rv; @@ -814,43 +814,43 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, /* Check CreateProcess result */ if (!rv) - return apr_get_os_error(); + return fspr_get_os_error(); - /* XXX Orphaned handle warning - no fix due to broken apr_proc_t api. + /* XXX Orphaned handle warning - no fix due to broken fspr_proc_t api. */ new->hproc = pi.hProcess; new->pid = pi.dwProcessId; if (attr->child_in) { - apr_file_close(attr->child_in); + fspr_file_close(attr->child_in); } if (attr->child_out) { - apr_file_close(attr->child_out); + fspr_file_close(attr->child_out); } if (attr->child_err) { - apr_file_close(attr->child_err); + fspr_file_close(attr->child_err); } CloseHandle(pi.hThread); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_proc_wait_all_procs(apr_proc_t *proc, +APR_DECLARE(fspr_status_t) fspr_proc_wait_all_procs(fspr_proc_t *proc, int *exitcode, - apr_exit_why_e *exitwhy, - apr_wait_how_e waithow, - apr_pool_t *p) + fspr_exit_why_e *exitwhy, + fspr_wait_how_e waithow, + fspr_pool_t *p) { - /* Unix does apr_proc_wait(proc(-1), exitcode, exitwhy, waithow) - * but Win32's apr_proc_wait won't work that way. We can either + /* Unix does fspr_proc_wait(proc(-1), exitcode, exitwhy, waithow) + * but Win32's fspr_proc_wait won't work that way. We can either * register all APR created processes in some sort of AsyncWait * thread, or simply walk from the global process pool for all - * apr_pool_note_subprocess()es registered with APR. + * fspr_pool_note_subprocess()es registered with APR. */ return APR_ENOTIMPL; } -static apr_exit_why_e why_from_exit_code(DWORD exit) { +static fspr_exit_why_e why_from_exit_code(DWORD exit) { /* See WinNT.h STATUS_ACCESS_VIOLATION and family for how * this class of failures was determined */ @@ -863,9 +863,9 @@ static apr_exit_why_e why_from_exit_code(DWORD exit) { /* ### No way to tell if Dr Watson grabbed a core, AFAICT. */ } -APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc, - int *exitcode, apr_exit_why_e *exitwhy, - apr_wait_how_e waithow) +APR_DECLARE(fspr_status_t) fspr_proc_wait(fspr_proc_t *proc, + int *exitcode, fspr_exit_why_e *exitwhy, + fspr_wait_how_e waithow) { DWORD stat; DWORD time; @@ -889,10 +889,10 @@ APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc, else if (stat == WAIT_TIMEOUT) { return APR_CHILD_NOTDONE; } - return apr_get_os_error(); + return fspr_get_os_error(); } -APR_DECLARE(apr_status_t) apr_proc_detach(int daemonize) +APR_DECLARE(fspr_status_t) fspr_proc_detach(int daemonize) { return APR_ENOTIMPL; } diff --git a/libs/apr/threadproc/win32/signals.c b/libs/apr/threadproc/win32/signals.c index 5e714931dc..c733c4dbd8 100644 --- a/libs/apr/threadproc/win32/signals.c +++ b/libs/apr/threadproc/win32/signals.c @@ -14,11 +14,11 @@ * limitations under the License. */ -#include "win32/apr_arch_threadproc.h" -#include "win32/apr_arch_file_io.h" -#include "apr_thread_proc.h" -#include "apr_file_io.h" -#include "apr_general.h" +#include "win32/fspr_arch_threadproc.h" +#include "win32/fspr_arch_file_io.h" +#include "fspr_thread_proc.h" +#include "fspr_file_io.h" +#include "fspr_general.h" #if APR_HAVE_SIGNAL_H #include #endif @@ -32,35 +32,35 @@ * ### Actually, closing the input handle to the proc should also do fine * for most console apps. This definately needs improvement... */ -APR_DECLARE(apr_status_t) apr_proc_kill(apr_proc_t *proc, int signal) +APR_DECLARE(fspr_status_t) fspr_proc_kill(fspr_proc_t *proc, int signal) { if (proc->hproc != NULL) { if (TerminateProcess(proc->hproc, signal) == 0) { - return apr_get_os_error(); + return fspr_get_os_error(); } - /* On unix, SIGKILL leaves a apr_proc_wait()able pid lying around, - * so we will leave hproc alone until the app calls apr_proc_wait(). + /* On unix, SIGKILL leaves a fspr_proc_wait()able pid lying around, + * so we will leave hproc alone until the app calls fspr_proc_wait(). */ return APR_SUCCESS; } return APR_EPROC_UNKNOWN; } -void apr_signal_init(apr_pool_t *pglobal) +void fspr_signal_init(fspr_pool_t *pglobal) { } -const char *apr_signal_description_get(int signum) +const char *fspr_signal_description_get(int signum) { return "unknown signal (not supported)"; } -APR_DECLARE(apr_status_t) apr_signal_block(int signum) +APR_DECLARE(fspr_status_t) fspr_signal_block(int signum) { return APR_ENOTIMPL; } -APR_DECLARE(apr_status_t) apr_signal_unblock(int signum) +APR_DECLARE(fspr_status_t) fspr_signal_unblock(int signum) { return APR_ENOTIMPL; } diff --git a/libs/apr/threadproc/win32/thread.c b/libs/apr/threadproc/win32/thread.c index 280213f2a1..e049c272db 100644 --- a/libs/apr/threadproc/win32/thread.c +++ b/libs/apr/threadproc/win32/thread.c @@ -14,25 +14,25 @@ * limitations under the License. */ -#include "apr_private.h" -#include "win32/apr_arch_threadproc.h" -#include "apr_thread_proc.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_portable.h" +#include "fspr_private.h" +#include "win32/fspr_arch_threadproc.h" +#include "fspr_thread_proc.h" +#include "fspr_general.h" +#include "fspr_lib.h" +#include "fspr_portable.h" #if APR_HAVE_PROCESS_H #include #endif -#include "apr_arch_misc.h" +#include "fspr_arch_misc.h" -/* Chosen for us by apr_initialize */ -DWORD tls_apr_thread = 0; +/* Chosen for us by fspr_initialize */ +DWORD tls_fspr_thread = 0; -APR_DECLARE(apr_status_t) apr_threadattr_create(apr_threadattr_t **new, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_threadattr_create(fspr_threadattr_t **new, + fspr_pool_t *pool) { - (*new) = (apr_threadattr_t *)apr_palloc(pool, - sizeof(apr_threadattr_t)); + (*new) = (fspr_threadattr_t *)fspr_palloc(pool, + sizeof(fspr_threadattr_t)); if ((*new) == NULL) { return APR_ENOMEM; @@ -45,51 +45,51 @@ APR_DECLARE(apr_status_t) apr_threadattr_create(apr_threadattr_t **new, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_threadattr_detach_set(apr_threadattr_t *attr, - apr_int32_t on) +APR_DECLARE(fspr_status_t) fspr_threadattr_detach_set(fspr_threadattr_t *attr, + fspr_int32_t on) { attr->detach = on; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_threadattr_detach_get(apr_threadattr_t *attr) +APR_DECLARE(fspr_status_t) fspr_threadattr_detach_get(fspr_threadattr_t *attr) { if (attr->detach == 1) return APR_DETACH; return APR_NOTDETACH; } -APR_DECLARE(apr_status_t) apr_threadattr_stacksize_set(apr_threadattr_t *attr, - apr_size_t stacksize) +APR_DECLARE(fspr_status_t) fspr_threadattr_stacksize_set(fspr_threadattr_t *attr, + fspr_size_t stacksize) { attr->stacksize = stacksize; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_threadattr_guardsize_set(apr_threadattr_t *attr, - apr_size_t size) +APR_DECLARE(fspr_status_t) fspr_threadattr_guardsize_set(fspr_threadattr_t *attr, + fspr_size_t size) { return APR_ENOTIMPL; } static void *dummy_worker(void *opaque) { - apr_thread_t *thd = (apr_thread_t *)opaque; - TlsSetValue(tls_apr_thread, thd->td); + fspr_thread_t *thd = (fspr_thread_t *)opaque; + TlsSetValue(tls_fspr_thread, thd->td); return thd->func(thd, thd->data); } -APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new, - apr_threadattr_t *attr, - apr_thread_start_t func, - void *data, apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_thread_create(fspr_thread_t **new, + fspr_threadattr_t *attr, + fspr_thread_start_t func, + void *data, fspr_pool_t *pool) { - apr_status_t stat; + fspr_status_t stat; unsigned temp; HANDLE handle; int priority = THREAD_PRIORITY_NORMAL; - (*new) = (apr_thread_t *)apr_palloc(pool, sizeof(apr_thread_t)); + (*new) = (fspr_thread_t *)fspr_palloc(pool, sizeof(fspr_thread_t)); if ((*new) == NULL) { return APR_ENOMEM; @@ -99,7 +99,7 @@ APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new, (*new)->data = data; (*new)->func = func; (*new)->td = NULL; - stat = apr_pool_create(&(*new)->pool, pool); + stat = fspr_pool_create(&(*new)->pool, pool); if (stat != APR_SUCCESS) { return stat; } @@ -131,7 +131,7 @@ APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new, attr && attr->stacksize > 0 ? attr->stacksize : 0, (unsigned int (APR_THREAD_FUNC *)(void *))dummy_worker, (*new), 0, &temp)) == 0) { - return apr_get_os_error(); + return fspr_get_os_error(); } #endif @@ -148,11 +148,11 @@ APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_exit(apr_thread_t *thd, - apr_status_t retval) +APR_DECLARE(fspr_status_t) fspr_thread_exit(fspr_thread_t *thd, + fspr_status_t retval) { thd->exitval = retval; - apr_pool_destroy(thd->pool); + fspr_pool_destroy(thd->pool); thd->pool = NULL; #ifndef _WIN32_WCE _endthreadex(0); @@ -162,10 +162,10 @@ APR_DECLARE(apr_status_t) apr_thread_exit(apr_thread_t *thd, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_join(apr_status_t *retval, - apr_thread_t *thd) +APR_DECLARE(fspr_status_t) fspr_thread_join(fspr_status_t *retval, + fspr_thread_t *thd) { - apr_status_t rv = APR_SUCCESS; + fspr_status_t rv = APR_SUCCESS; if (!thd->td) { /* Can not join on detached threads */ @@ -180,25 +180,25 @@ APR_DECLARE(apr_status_t) apr_thread_join(apr_status_t *retval, rv = APR_INCOMPLETE; } else - rv = apr_get_os_error(); + rv = fspr_get_os_error(); CloseHandle(thd->td); thd->td = NULL; return rv; } -APR_DECLARE(apr_status_t) apr_thread_detach(apr_thread_t *thd) +APR_DECLARE(fspr_status_t) fspr_thread_detach(fspr_thread_t *thd) { if (thd->td && CloseHandle(thd->td)) { thd->td = NULL; return APR_SUCCESS; } else { - return apr_get_os_error(); + return fspr_get_os_error(); } } -APR_DECLARE(void) apr_thread_yield() +APR_DECLARE(void) fspr_thread_yield() { /* SwitchToThread is not supported on Win9x, but since it's * primarily a noop (entering time consuming code, therefore @@ -206,29 +206,29 @@ APR_DECLARE(void) apr_thread_yield() * we won't worry too much if it's not available. */ #ifndef _WIN32_WCE - if (apr_os_level >= APR_WIN_NT) { + if (fspr_os_level >= APR_WIN_NT) { SwitchToThread(); } #endif } -APR_DECLARE(apr_status_t) apr_thread_data_get(void **data, const char *key, - apr_thread_t *thread) +APR_DECLARE(fspr_status_t) fspr_thread_data_get(void **data, const char *key, + fspr_thread_t *thread) { - return apr_pool_userdata_get(data, key, thread->pool); + return fspr_pool_userdata_get(data, key, thread->pool); } -APR_DECLARE(apr_status_t) apr_thread_data_set(void *data, const char *key, - apr_status_t (*cleanup) (void *), - apr_thread_t *thread) +APR_DECLARE(fspr_status_t) fspr_thread_data_set(void *data, const char *key, + fspr_status_t (*cleanup) (void *), + fspr_thread_t *thread) { - return apr_pool_userdata_set(data, key, cleanup, thread->pool); + return fspr_pool_userdata_set(data, key, cleanup, thread->pool); } -APR_DECLARE(apr_os_thread_t) apr_os_thread_current(void) +APR_DECLARE(fspr_os_thread_t) fspr_os_thread_current(void) { - HANDLE hthread = (HANDLE)TlsGetValue(tls_apr_thread); + HANDLE hthread = (HANDLE)TlsGetValue(tls_fspr_thread); HANDLE hproc; if (hthread) { @@ -242,12 +242,12 @@ APR_DECLARE(apr_os_thread_t) apr_os_thread_current(void) DUPLICATE_SAME_ACCESS)) { return NULL; } - TlsSetValue(tls_apr_thread, hthread); + TlsSetValue(tls_fspr_thread, hthread); return hthread; } -APR_DECLARE(apr_status_t) apr_os_thread_get(apr_os_thread_t **thethd, - apr_thread_t *thd) +APR_DECLARE(fspr_status_t) fspr_os_thread_get(fspr_os_thread_t **thethd, + fspr_thread_t *thd) { if (thd == NULL) { return APR_ENOTHREAD; @@ -256,29 +256,29 @@ APR_DECLARE(apr_status_t) apr_os_thread_get(apr_os_thread_t **thethd, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_os_thread_put(apr_thread_t **thd, - apr_os_thread_t *thethd, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_os_thread_put(fspr_thread_t **thd, + fspr_os_thread_t *thethd, + fspr_pool_t *pool) { if (pool == NULL) { return APR_ENOPOOL; } if ((*thd) == NULL) { - (*thd) = (apr_thread_t *)apr_palloc(pool, sizeof(apr_thread_t)); + (*thd) = (fspr_thread_t *)fspr_palloc(pool, sizeof(fspr_thread_t)); (*thd)->pool = pool; } (*thd)->td = thethd; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_once_init(apr_thread_once_t **control, - apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_thread_once_init(fspr_thread_once_t **control, + fspr_pool_t *p) { - (*control) = apr_pcalloc(p, sizeof(**control)); + (*control) = fspr_pcalloc(p, sizeof(**control)); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_thread_once(apr_thread_once_t *control, +APR_DECLARE(fspr_status_t) fspr_thread_once(fspr_thread_once_t *control, void (*func)(void)) { if (!InterlockedExchange(&control->value, 1)) { @@ -287,11 +287,11 @@ APR_DECLARE(apr_status_t) apr_thread_once(apr_thread_once_t *control, return APR_SUCCESS; } -APR_DECLARE(int) apr_os_thread_equal(apr_os_thread_t tid1, - apr_os_thread_t tid2) +APR_DECLARE(int) fspr_os_thread_equal(fspr_os_thread_t tid1, + fspr_os_thread_t tid2) { /* Since the only tid's we support our are own, and - * apr_os_thread_current returns the identical handle + * fspr_os_thread_current returns the identical handle * to the one we created initially, the test is simple. */ return (tid1 == tid2); diff --git a/libs/apr/threadproc/win32/threadpriv.c b/libs/apr/threadproc/win32/threadpriv.c index 9ddc24fbd1..3f9530ab6e 100644 --- a/libs/apr/threadproc/win32/threadpriv.c +++ b/libs/apr/threadproc/win32/threadpriv.c @@ -14,18 +14,18 @@ * limitations under the License. */ -#include "win32/apr_arch_threadproc.h" -#include "apr_thread_proc.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_errno.h" -#include "apr_portable.h" +#include "win32/fspr_arch_threadproc.h" +#include "fspr_thread_proc.h" +#include "fspr_general.h" +#include "fspr_lib.h" +#include "fspr_errno.h" +#include "fspr_portable.h" -APR_DECLARE(apr_status_t) apr_threadkey_private_create(apr_threadkey_t **key, +APR_DECLARE(fspr_status_t) fspr_threadkey_private_create(fspr_threadkey_t **key, void (*dest)(void *), - apr_pool_t *pool) + fspr_pool_t *pool) { - (*key) = (apr_threadkey_t *)apr_palloc(pool, sizeof(apr_threadkey_t)); + (*key) = (fspr_threadkey_t *)fspr_palloc(pool, sizeof(fspr_threadkey_t)); if ((*key) == NULL) { return APR_ENOMEM; } @@ -35,64 +35,64 @@ APR_DECLARE(apr_status_t) apr_threadkey_private_create(apr_threadkey_t **key, if (((*key)->key = TlsAlloc()) != 0xFFFFFFFF) { return APR_SUCCESS; } - return apr_get_os_error(); + return fspr_get_os_error(); } -APR_DECLARE(apr_status_t) apr_threadkey_private_get(void **new, - apr_threadkey_t *key) +APR_DECLARE(fspr_status_t) fspr_threadkey_private_get(void **new, + fspr_threadkey_t *key) { if ((*new) = TlsGetValue(key->key)) { return APR_SUCCESS; } - return apr_get_os_error(); + return fspr_get_os_error(); } -APR_DECLARE(apr_status_t) apr_threadkey_private_set(void *priv, - apr_threadkey_t *key) +APR_DECLARE(fspr_status_t) fspr_threadkey_private_set(void *priv, + fspr_threadkey_t *key) { if (TlsSetValue(key->key, priv)) { return APR_SUCCESS; } - return apr_get_os_error(); + return fspr_get_os_error(); } -APR_DECLARE(apr_status_t) apr_threadkey_private_delete(apr_threadkey_t *key) +APR_DECLARE(fspr_status_t) fspr_threadkey_private_delete(fspr_threadkey_t *key) { if (TlsFree(key->key)) { return APR_SUCCESS; } - return apr_get_os_error(); + return fspr_get_os_error(); } -APR_DECLARE(apr_status_t) apr_threadkey_data_get(void **data, const char *key, - apr_threadkey_t *threadkey) +APR_DECLARE(fspr_status_t) fspr_threadkey_data_get(void **data, const char *key, + fspr_threadkey_t *threadkey) { - return apr_pool_userdata_get(data, key, threadkey->pool); + return fspr_pool_userdata_get(data, key, threadkey->pool); } -APR_DECLARE(apr_status_t) apr_threadkey_data_set(void *data, const char *key, - apr_status_t (*cleanup)(void *), - apr_threadkey_t *threadkey) +APR_DECLARE(fspr_status_t) fspr_threadkey_data_set(void *data, const char *key, + fspr_status_t (*cleanup)(void *), + fspr_threadkey_t *threadkey) { - return apr_pool_userdata_set(data, key, cleanup, threadkey->pool); + return fspr_pool_userdata_set(data, key, cleanup, threadkey->pool); } -APR_DECLARE(apr_status_t) apr_os_threadkey_get(apr_os_threadkey_t *thekey, - apr_threadkey_t *key) +APR_DECLARE(fspr_status_t) fspr_os_threadkey_get(fspr_os_threadkey_t *thekey, + fspr_threadkey_t *key) { *thekey = key->key; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_os_threadkey_put(apr_threadkey_t **key, - apr_os_threadkey_t *thekey, - apr_pool_t *pool) +APR_DECLARE(fspr_status_t) fspr_os_threadkey_put(fspr_threadkey_t **key, + fspr_os_threadkey_t *thekey, + fspr_pool_t *pool) { if (pool == NULL) { return APR_ENOPOOL; } if ((*key) == NULL) { - (*key) = (apr_threadkey_t *)apr_palloc(pool, sizeof(apr_threadkey_t)); + (*key) = (fspr_threadkey_t *)fspr_palloc(pool, sizeof(fspr_threadkey_t)); (*key)->pool = pool; } (*key)->key = *thekey; diff --git a/libs/apr/time/unix/time.c b/libs/apr/time/unix/time.c index dfa45e690c..8e77d740d3 100644 --- a/libs/apr/time/unix/time.c +++ b/libs/apr/time/unix/time.c @@ -14,14 +14,14 @@ * limitations under the License. */ -#include "apr_portable.h" -#include "apr_time.h" -#include "apr_lib.h" -#include "apr_private.h" -#include "apr_strings.h" +#include "fspr_portable.h" +#include "fspr_time.h" +#include "fspr_lib.h" +#include "fspr_private.h" +#include "fspr_strings.h" /* private APR headers */ -#include "apr_arch_internal_time.h" +#include "fspr_arch_internal_time.h" /* System Headers required for time library */ #if APR_HAVE_SYS_TIME_H @@ -36,11 +36,11 @@ /* End System Headers */ #if !defined(HAVE_STRUCT_TM_TM_GMTOFF) && !defined(HAVE_STRUCT_TM___TM_GMTOFF) -static apr_int32_t server_gmt_offset; +static fspr_int32_t server_gmt_offset; #define NO_GMTOFF_IN_STRUCT_TM #endif -static apr_int32_t get_offset(struct tm *tm) +static fspr_int32_t get_offset(struct tm *tm) { #if defined(HAVE_STRUCT_TM_TM_GMTOFF) return tm->tm_gmtoff; @@ -63,23 +63,23 @@ static apr_int32_t get_offset(struct tm *tm) #endif } -APR_DECLARE(apr_status_t) apr_time_ansi_put(apr_time_t *result, +APR_DECLARE(fspr_status_t) fspr_time_ansi_put(fspr_time_t *result, time_t input) { - *result = (apr_time_t)input * APR_USEC_PER_SEC; + *result = (fspr_time_t)input * APR_USEC_PER_SEC; return APR_SUCCESS; } /* NB NB NB NB This returns GMT!!!!!!!!!! */ -APR_DECLARE(apr_time_t) apr_time_now(void) +APR_DECLARE(fspr_time_t) fspr_time_now(void) { struct timeval tv; gettimeofday(&tv, NULL); return tv.tv_sec * APR_USEC_PER_SEC + tv.tv_usec; } -static void explode_time(apr_time_exp_t *xt, apr_time_t t, - apr_int32_t offset, int use_localtime) +static void explode_time(fspr_time_exp_t *xt, fspr_time_t t, + fspr_int32_t offset, int use_localtime) { struct tm tm; time_t tt = (t / APR_USEC_PER_SEC) + offset; @@ -109,36 +109,36 @@ static void explode_time(apr_time_exp_t *xt, apr_time_t t, xt->tm_gmtoff = get_offset(&tm); } -APR_DECLARE(apr_status_t) apr_time_exp_tz(apr_time_exp_t *result, - apr_time_t input, apr_int32_t offs) +APR_DECLARE(fspr_status_t) fspr_time_exp_tz(fspr_time_exp_t *result, + fspr_time_t input, fspr_int32_t offs) { explode_time(result, input, offs, 0); result->tm_gmtoff = offs; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_time_exp_gmt(apr_time_exp_t *result, - apr_time_t input) +APR_DECLARE(fspr_status_t) fspr_time_exp_gmt(fspr_time_exp_t *result, + fspr_time_t input) { - return apr_time_exp_tz(result, input, 0); + return fspr_time_exp_tz(result, input, 0); } -APR_DECLARE(apr_status_t) apr_time_exp_lt(apr_time_exp_t *result, - apr_time_t input) +APR_DECLARE(fspr_status_t) fspr_time_exp_lt(fspr_time_exp_t *result, + fspr_time_t input) { #if defined(__EMX__) /* EMX gcc (OS/2) has a timezone global we can use */ - return apr_time_exp_tz(result, input, -timezone); + return fspr_time_exp_tz(result, input, -timezone); #else explode_time(result, input, 0, 1); return APR_SUCCESS; #endif /* __EMX__ */ } -APR_DECLARE(apr_status_t) apr_time_exp_get(apr_time_t *t, apr_time_exp_t *xt) +APR_DECLARE(fspr_status_t) fspr_time_exp_get(fspr_time_t *t, fspr_time_exp_t *xt) { - apr_time_t year = xt->tm_year; - apr_time_t days; + fspr_time_t year = xt->tm_year; + fspr_time_t days; static const int dayoffset[12] = {306, 337, 0, 31, 61, 92, 122, 153, 184, 214, 245, 275}; @@ -161,25 +161,25 @@ APR_DECLARE(apr_status_t) apr_time_exp_get(apr_time_t *t, apr_time_exp_t *xt) return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_time_exp_gmt_get(apr_time_t *t, - apr_time_exp_t *xt) +APR_DECLARE(fspr_status_t) fspr_time_exp_gmt_get(fspr_time_t *t, + fspr_time_exp_t *xt) { - apr_status_t status = apr_time_exp_get(t, xt); + fspr_status_t status = fspr_time_exp_get(t, xt); if (status == APR_SUCCESS) - *t -= (apr_time_t) xt->tm_gmtoff * APR_USEC_PER_SEC; + *t -= (fspr_time_t) xt->tm_gmtoff * APR_USEC_PER_SEC; return status; } -APR_DECLARE(apr_status_t) apr_os_imp_time_get(apr_os_imp_time_t **ostime, - apr_time_t *aprtime) +APR_DECLARE(fspr_status_t) fspr_os_imp_time_get(fspr_os_imp_time_t **ostime, + fspr_time_t *aprtime) { (*ostime)->tv_usec = *aprtime % APR_USEC_PER_SEC; (*ostime)->tv_sec = *aprtime / APR_USEC_PER_SEC; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_os_exp_time_get(apr_os_exp_time_t **ostime, - apr_time_exp_t *aprtime) +APR_DECLARE(fspr_status_t) fspr_os_exp_time_get(fspr_os_exp_time_t **ostime, + fspr_time_exp_t *aprtime) { (*ostime)->tm_sec = aprtime->tm_sec; (*ostime)->tm_min = aprtime->tm_min; @@ -200,17 +200,17 @@ APR_DECLARE(apr_status_t) apr_os_exp_time_get(apr_os_exp_time_t **ostime, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_os_imp_time_put(apr_time_t *aprtime, - apr_os_imp_time_t **ostime, - apr_pool_t *cont) +APR_DECLARE(fspr_status_t) fspr_os_imp_time_put(fspr_time_t *aprtime, + fspr_os_imp_time_t **ostime, + fspr_pool_t *cont) { *aprtime = (*ostime)->tv_sec * APR_USEC_PER_SEC + (*ostime)->tv_usec; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_os_exp_time_put(apr_time_exp_t *aprtime, - apr_os_exp_time_t **ostime, - apr_pool_t *cont) +APR_DECLARE(fspr_status_t) fspr_os_exp_time_put(fspr_time_exp_t *aprtime, + fspr_os_exp_time_t **ostime, + fspr_pool_t *cont) { aprtime->tm_sec = (*ostime)->tm_sec; aprtime->tm_min = (*ostime)->tm_min; @@ -231,7 +231,7 @@ APR_DECLARE(apr_status_t) apr_os_exp_time_put(apr_time_exp_t *aprtime, return APR_SUCCESS; } -APR_DECLARE(void) apr_sleep(apr_interval_time_t t) +APR_DECLARE(void) fspr_sleep(fspr_interval_time_t t) { #ifdef OS2 DosSleep(t/1000); @@ -248,7 +248,7 @@ APR_DECLARE(void) apr_sleep(apr_interval_time_t t) } #ifdef OS2 -APR_DECLARE(apr_status_t) apr_os2_time_to_apr_time(apr_time_t *result, +APR_DECLARE(fspr_status_t) fspr_os2_time_to_fspr_time(fspr_time_t *result, FDATE os2date, FTIME os2time) { @@ -268,9 +268,9 @@ APR_DECLARE(apr_status_t) apr_os2_time_to_apr_time(apr_time_t *result, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_apr_time_to_os2_time(FDATE *os2date, +APR_DECLARE(fspr_status_t) fspr_fspr_time_to_os2_time(FDATE *os2date, FTIME *os2time, - apr_time_t aprtime) + fspr_time_t aprtime) { time_t ansitime = aprtime / APR_USEC_PER_SEC; struct tm *lt; @@ -287,13 +287,13 @@ APR_DECLARE(apr_status_t) apr_apr_time_to_os2_time(FDATE *os2date, #endif #ifdef NETWARE -APR_DECLARE(void) apr_netware_setup_time(void) +APR_DECLARE(void) fspr_netware_setup_time(void) { tzset(); server_gmt_offset = -TZONE; } #else -APR_DECLARE(void) apr_unix_setup_time(void) +APR_DECLARE(void) fspr_unix_setup_time(void) { #ifdef NO_GMTOFF_IN_STRUCT_TM /* Precompute the offset from GMT on systems where it's not @@ -334,14 +334,14 @@ APR_DECLARE(void) apr_unix_setup_time(void) #endif t.tm_isdst = 0; /* we know this GMT time isn't daylight-savings */ t2 = mktime(&t); - server_gmt_offset = (apr_int32_t) difftime(t1, t2); + server_gmt_offset = (fspr_int32_t) difftime(t1, t2); #endif /* NO_GMTOFF_IN_STRUCT_TM */ } #endif /* A noop on all known Unix implementations */ -APR_DECLARE(void) apr_time_clock_hires(apr_pool_t *p) +APR_DECLARE(void) fspr_time_clock_hires(fspr_pool_t *p) { return; } diff --git a/libs/apr/time/unix/timestr.c b/libs/apr/time/unix/timestr.c index f74febac19..3519f26d23 100644 --- a/libs/apr/time/unix/timestr.c +++ b/libs/apr/time/unix/timestr.c @@ -14,10 +14,10 @@ * limitations under the License. */ -#include "apr_portable.h" -#include "apr_time.h" -#include "apr_lib.h" -#include "apr_private.h" +#include "fspr_portable.h" +#include "fspr_time.h" +#include "fspr_lib.h" +#include "fspr_private.h" /* System Headers required for time library */ #if APR_HAVE_SYS_TIME_H #include @@ -30,27 +30,27 @@ #endif /* End System Headers */ -APR_DECLARE_DATA const char apr_month_snames[12][4] = +APR_DECLARE_DATA const char fspr_month_snames[12][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; -APR_DECLARE_DATA const char apr_day_snames[7][4] = +APR_DECLARE_DATA const char fspr_day_snames[7][4] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; -apr_status_t apr_rfc822_date(char *date_str, apr_time_t t) +fspr_status_t fspr_rfc822_date(char *date_str, fspr_time_t t) { - apr_time_exp_t xt; + fspr_time_exp_t xt; const char *s; int real_year; - apr_time_exp_gmt(&xt, t); + fspr_time_exp_gmt(&xt, t); /* example: "Sat, 08 Jan 2000 18:31:41 GMT" */ /* 12345678901234567890123456789 */ - s = &apr_day_snames[xt.tm_wday][0]; + s = &fspr_day_snames[xt.tm_wday][0]; *date_str++ = *s++; *date_str++ = *s++; *date_str++ = *s++; @@ -59,7 +59,7 @@ apr_status_t apr_rfc822_date(char *date_str, apr_time_t t) *date_str++ = xt.tm_mday / 10 + '0'; *date_str++ = xt.tm_mday % 10 + '0'; *date_str++ = ' '; - s = &apr_month_snames[xt.tm_mon][0]; + s = &fspr_month_snames[xt.tm_mon][0]; *date_str++ = *s++; *date_str++ = *s++; *date_str++ = *s++; @@ -87,22 +87,22 @@ apr_status_t apr_rfc822_date(char *date_str, apr_time_t t) return APR_SUCCESS; } -apr_status_t apr_ctime(char *date_str, apr_time_t t) +fspr_status_t fspr_ctime(char *date_str, fspr_time_t t) { - apr_time_exp_t xt; + fspr_time_exp_t xt; const char *s; int real_year; /* example: "Wed Jun 30 21:49:08 1993" */ /* 123456789012345678901234 */ - apr_time_exp_lt(&xt, t); - s = &apr_day_snames[xt.tm_wday][0]; + fspr_time_exp_lt(&xt, t); + s = &fspr_day_snames[xt.tm_wday][0]; *date_str++ = *s++; *date_str++ = *s++; *date_str++ = *s++; *date_str++ = ' '; - s = &apr_month_snames[xt.tm_mon][0]; + s = &fspr_month_snames[xt.tm_mon][0]; *date_str++ = *s++; *date_str++ = *s++; *date_str++ = *s++; @@ -129,8 +129,8 @@ apr_status_t apr_ctime(char *date_str, apr_time_t t) return APR_SUCCESS; } -apr_status_t apr_strftime(char *s, apr_size_t *retsize, apr_size_t max, - const char *format, apr_time_exp_t *xt) +fspr_status_t fspr_strftime(char *s, fspr_size_t *retsize, fspr_size_t max, + const char *format, fspr_time_exp_t *xt) { struct tm tm; memset(&tm, 0, sizeof tm); diff --git a/libs/apr/time/win32/access.c b/libs/apr/time/win32/access.c index cd25e2f0bf..189e06d19c 100644 --- a/libs/apr/time/win32/access.c +++ b/libs/apr/time/win32/access.c @@ -14,12 +14,12 @@ * limitations under the License. */ -#include "win32/apr_arch_atime.h" -#include "apr_time.h" -#include "apr_general.h" -#include "apr_lib.h" +#include "win32/fspr_arch_atime.h" +#include "fspr_time.h" +#include "fspr_general.h" +#include "fspr_lib.h" -apr_status_t apr_get_curtime(struct atime_t *time, apr_time_t *rv) +fspr_status_t fspr_get_curtime(struct atime_t *time, fspr_time_t *rv) { if (time) { (*rv) = time->currtime; @@ -28,7 +28,7 @@ apr_status_t apr_get_curtime(struct atime_t *time, apr_time_t *rv) return APR_ENOTIME; } -apr_status_t apr_get_sec(struct atime_t *time, apr_int32_t *rv) +fspr_status_t fspr_get_sec(struct atime_t *time, fspr_int32_t *rv) { if (time) { (*rv) = time->explodedtime->wSecond; @@ -37,7 +37,7 @@ apr_status_t apr_get_sec(struct atime_t *time, apr_int32_t *rv) return APR_ENOTIME; } -apr_status_t apr_get_min(struct atime_t *time, apr_int32_t *rv) +fspr_status_t fspr_get_min(struct atime_t *time, fspr_int32_t *rv) { if (time) { (*rv) = time->explodedtime->wMinute; @@ -46,7 +46,7 @@ apr_status_t apr_get_min(struct atime_t *time, apr_int32_t *rv) return APR_ENOTIME; } -apr_status_t apr_get_hour(struct atime_t *time, apr_int32_t *rv) +fspr_status_t fspr_get_hour(struct atime_t *time, fspr_int32_t *rv) { if (time) { (*rv) = time->explodedtime->wHour; @@ -55,7 +55,7 @@ apr_status_t apr_get_hour(struct atime_t *time, apr_int32_t *rv) return APR_ENOTIME; } -apr_status_t apr_get_mday(struct atime_t *time, apr_int32_t *rv) +fspr_status_t fspr_get_mday(struct atime_t *time, fspr_int32_t *rv) { if (time) { (*rv) = time->explodedtime->wDay; @@ -64,7 +64,7 @@ apr_status_t apr_get_mday(struct atime_t *time, apr_int32_t *rv) return APR_ENOTIME; } -apr_status_t apr_get_mon(struct atime_t *time, apr_int32_t *rv) +fspr_status_t fspr_get_mon(struct atime_t *time, fspr_int32_t *rv) { if (time) { (*rv) = time->explodedtime->wMonth; @@ -73,7 +73,7 @@ apr_status_t apr_get_mon(struct atime_t *time, apr_int32_t *rv) return APR_ENOTIME; } -apr_status_t apr_get_year(struct atime_t *time, apr_int32_t *rv) +fspr_status_t fspr_get_year(struct atime_t *time, fspr_int32_t *rv) { if (time) { (*rv) = time->explodedtime->wYear; @@ -82,7 +82,7 @@ apr_status_t apr_get_year(struct atime_t *time, apr_int32_t *rv) return APR_ENOTIME; } -apr_status_t apr_get_wday(struct atime_t *time, apr_int32_t *rv) +fspr_status_t fspr_get_wday(struct atime_t *time, fspr_int32_t *rv) { if (time) { (*rv) = time->explodedtime->wDayOfWeek; @@ -91,13 +91,13 @@ apr_status_t apr_get_wday(struct atime_t *time, apr_int32_t *rv) return APR_ENOTIME; } -apr_status_t apr_set_sec(struct atime_t *time, apr_int32_t value) +fspr_status_t fspr_set_sec(struct atime_t *time, fspr_int32_t value) { if (!time) { return APR_ENOTIME; } if (time->explodedtime == NULL) { - time->explodedtime = (SYSTEMTIME *)apr_pcalloc(time->cntxt, + time->explodedtime = (SYSTEMTIME *)fspr_pcalloc(time->cntxt, sizeof(SYSTEMTIME)); } if (time->explodedtime == NULL) { @@ -107,13 +107,13 @@ apr_status_t apr_set_sec(struct atime_t *time, apr_int32_t value) return APR_SUCCESS; } -apr_status_t apr_set_min(struct atime_t *time, apr_int32_t value) +fspr_status_t fspr_set_min(struct atime_t *time, fspr_int32_t value) { if (!time) { return APR_ENOTIME; } if (time->explodedtime == NULL) { - time->explodedtime = (SYSTEMTIME *)apr_pcalloc(time->cntxt, + time->explodedtime = (SYSTEMTIME *)fspr_pcalloc(time->cntxt, sizeof(SYSTEMTIME)); } if (time->explodedtime == NULL) { @@ -123,13 +123,13 @@ apr_status_t apr_set_min(struct atime_t *time, apr_int32_t value) return APR_SUCCESS; } -apr_status_t apr_set_hour(struct atime_t *time, apr_int32_t value) +fspr_status_t fspr_set_hour(struct atime_t *time, fspr_int32_t value) { if (!time) { return APR_ENOTIME; } if (time->explodedtime == NULL) { - time->explodedtime = (SYSTEMTIME *)apr_pcalloc(time->cntxt, + time->explodedtime = (SYSTEMTIME *)fspr_pcalloc(time->cntxt, sizeof(SYSTEMTIME)); } if (time->explodedtime == NULL) { @@ -139,13 +139,13 @@ apr_status_t apr_set_hour(struct atime_t *time, apr_int32_t value) return APR_SUCCESS; } -apr_status_t apr_set_mday(struct atime_t *time, apr_int32_t value) +fspr_status_t fspr_set_mday(struct atime_t *time, fspr_int32_t value) { if (!time) { return APR_ENOTIME; } if (time->explodedtime == NULL) { - time->explodedtime = (SYSTEMTIME *)apr_pcalloc(time->cntxt, + time->explodedtime = (SYSTEMTIME *)fspr_pcalloc(time->cntxt, sizeof(SYSTEMTIME)); } if (time->explodedtime == NULL) { @@ -155,13 +155,13 @@ apr_status_t apr_set_mday(struct atime_t *time, apr_int32_t value) return APR_SUCCESS; } -apr_status_t apr_set_mon(struct atime_t *time, apr_int32_t value) +fspr_status_t fspr_set_mon(struct atime_t *time, fspr_int32_t value) { if (!time) { return APR_ENOTIME; } if (time->explodedtime == NULL) { - time->explodedtime = (SYSTEMTIME *)apr_pcalloc(time->cntxt, + time->explodedtime = (SYSTEMTIME *)fspr_pcalloc(time->cntxt, sizeof(SYSTEMTIME)); } if (time->explodedtime == NULL) { @@ -171,13 +171,13 @@ apr_status_t apr_set_mon(struct atime_t *time, apr_int32_t value) return APR_SUCCESS; } -apr_status_t apr_set_year(struct atime_t *time, apr_int32_t value) +fspr_status_t fspr_set_year(struct atime_t *time, fspr_int32_t value) { if (!time) { return APR_ENOTIME; } if (time->explodedtime == NULL) { - time->explodedtime = (SYSTEMTIME *)apr_pcalloc(time->cntxt, + time->explodedtime = (SYSTEMTIME *)fspr_pcalloc(time->cntxt, sizeof(SYSTEMTIME)); } if (time->explodedtime == NULL) { @@ -187,13 +187,13 @@ apr_status_t apr_set_year(struct atime_t *time, apr_int32_t value) return APR_SUCCESS; } -apr_status_t apr_set_wday(struct atime_t *time, apr_int32_t value) +fspr_status_t fspr_set_wday(struct atime_t *time, fspr_int32_t value) { if (!time) { return APR_ENOTIME; } if (time->explodedtime == NULL) { - time->explodedtime = (SYSTEMTIME *)apr_pcalloc(time->cntxt, + time->explodedtime = (SYSTEMTIME *)fspr_pcalloc(time->cntxt, sizeof(SYSTEMTIME)); } if (time->explodedtime == NULL) { diff --git a/libs/apr/time/win32/time.c b/libs/apr/time/win32/time.c index 6a2b2737de..3dd473a8b4 100644 --- a/libs/apr/time/win32/time.c +++ b/libs/apr/time/win32/time.c @@ -14,11 +14,11 @@ * limitations under the License. */ -#include "win32/apr_arch_atime.h" -#include "apr_time.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_portable.h" +#include "win32/fspr_arch_atime.h" +#include "fspr_time.h" +#include "fspr_general.h" +#include "fspr_lib.h" +#include "fspr_portable.h" #if APR_HAVE_TIME_H #include #endif @@ -27,7 +27,7 @@ #endif #include #include -#include "apr_arch_misc.h" +#include "fspr_arch_misc.h" /* Leap year is any year divisible by four, but not by 100 unless also * divisible by 400 @@ -49,7 +49,7 @@ static DWORD get_local_timezone(TIME_ZONE_INFORMATION **tzresult) return result; } -static void SystemTimeToAprExpTime(apr_time_exp_t *xt, SYSTEMTIME *tm) +static void SystemTimeToAprExpTime(fspr_time_exp_t *xt, SYSTEMTIME *tm) { static const int dayoffset[12] = {0, 31, 59, 90, 120, 151, 182, 212, 243, 273, 304, 334}; @@ -76,15 +76,15 @@ static void SystemTimeToAprExpTime(apr_time_exp_t *xt, SYSTEMTIME *tm) xt->tm_yday++; } -APR_DECLARE(apr_status_t) apr_time_ansi_put(apr_time_t *result, +APR_DECLARE(fspr_status_t) fspr_time_ansi_put(fspr_time_t *result, time_t input) { - *result = (apr_time_t) input * APR_USEC_PER_SEC; + *result = (fspr_time_t) input * APR_USEC_PER_SEC; return APR_SUCCESS; } /* Return micro-seconds since the Unix epoch (jan. 1, 1970) UTC */ -APR_DECLARE(apr_time_t) apr_time_now(void) +APR_DECLARE(fspr_time_t) fspr_time_now(void) { LONGLONG aprtime = 0; FILETIME time; @@ -99,8 +99,8 @@ APR_DECLARE(apr_time_t) apr_time_now(void) return aprtime; } -APR_DECLARE(apr_status_t) apr_time_exp_gmt(apr_time_exp_t *result, - apr_time_t input) +APR_DECLARE(fspr_status_t) fspr_time_exp_gmt(fspr_time_exp_t *result, + fspr_time_t input) { FILETIME ft; SYSTEMTIME st; @@ -110,13 +110,13 @@ APR_DECLARE(apr_status_t) apr_time_exp_gmt(apr_time_exp_t *result, * generally UTC, so no timezone info needed */ SystemTimeToAprExpTime(result, &st); - result->tm_usec = (apr_int32_t) (input % APR_USEC_PER_SEC); + result->tm_usec = (fspr_int32_t) (input % APR_USEC_PER_SEC); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_time_exp_tz(apr_time_exp_t *result, - apr_time_t input, - apr_int32_t offs) +APR_DECLARE(fspr_status_t) fspr_time_exp_tz(fspr_time_exp_t *result, + fspr_time_t input, + fspr_int32_t offs) { FILETIME ft; SYSTEMTIME st; @@ -126,13 +126,13 @@ APR_DECLARE(apr_status_t) apr_time_exp_tz(apr_time_exp_t *result, * generally UTC, so we will simply note the offs used. */ SystemTimeToAprExpTime(result, &st); - result->tm_usec = (apr_int32_t) (input % APR_USEC_PER_SEC); + result->tm_usec = (fspr_int32_t) (input % APR_USEC_PER_SEC); result->tm_gmtoff = offs; return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_time_exp_lt(apr_time_exp_t *result, - apr_time_t input) +APR_DECLARE(fspr_status_t) fspr_time_exp_lt(fspr_time_exp_t *result, + fspr_time_t input) { SYSTEMTIME st; FILETIME ft, localft; @@ -144,7 +144,7 @@ APR_DECLARE(apr_status_t) apr_time_exp_lt(apr_time_exp_t *result, { TIME_ZONE_INFORMATION *tz; SYSTEMTIME localst; - apr_time_t localtime; + fspr_time_t localtime; get_local_timezone(&tz); @@ -158,7 +158,7 @@ APR_DECLARE(apr_status_t) apr_time_exp_lt(apr_time_exp_t *result, */ SystemTimeToTzSpecificLocalTime(tz, &st, &localst); SystemTimeToAprExpTime(result, &localst); - result->tm_usec = (apr_int32_t) (input % APR_USEC_PER_SEC); + result->tm_usec = (fspr_int32_t) (input % APR_USEC_PER_SEC); /* Recover the resulting time as an apr time and use the @@ -166,8 +166,8 @@ APR_DECLARE(apr_status_t) apr_time_exp_lt(apr_time_exp_t *result, */ SystemTimeToFileTime(&localst, &localft); FileTimeToAprTime(&localtime, &localft); - result->tm_gmtoff = (int)apr_time_sec(localtime) - - (int)apr_time_sec(input); + result->tm_gmtoff = (int)fspr_time_sec(localtime) + - (int)fspr_time_sec(input); /* To compute the dst flag, we compare the expected * local (standard) timezone bias to the delta. @@ -189,7 +189,7 @@ APR_DECLARE(apr_status_t) apr_time_exp_lt(apr_time_exp_t *result, FileTimeToLocalFileTime(&ft, &localft); FileTimeToSystemTime(&localft, &st); SystemTimeToAprExpTime(result, &st); - result->tm_usec = (apr_int32_t) (input % APR_USEC_PER_SEC); + result->tm_usec = (fspr_int32_t) (input % APR_USEC_PER_SEC); switch (GetTimeZoneInformation(&tz)) { case TIME_ZONE_ID_UNKNOWN: @@ -216,11 +216,11 @@ APR_DECLARE(apr_status_t) apr_time_exp_lt(apr_time_exp_t *result, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_time_exp_get(apr_time_t *t, - apr_time_exp_t *xt) +APR_DECLARE(fspr_status_t) fspr_time_exp_get(fspr_time_t *t, + fspr_time_exp_t *xt) { - apr_time_t year = xt->tm_year; - apr_time_t days; + fspr_time_t year = xt->tm_year; + fspr_time_t days; static const int dayoffset[12] = {306, 337, 0, 31, 61, 92, 122, 153, 184, 214, 245, 275}; @@ -244,25 +244,25 @@ APR_DECLARE(apr_status_t) apr_time_exp_get(apr_time_t *t, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_time_exp_gmt_get(apr_time_t *t, - apr_time_exp_t *xt) +APR_DECLARE(fspr_status_t) fspr_time_exp_gmt_get(fspr_time_t *t, + fspr_time_exp_t *xt) { - apr_status_t status = apr_time_exp_get(t, xt); + fspr_status_t status = fspr_time_exp_get(t, xt); if (status == APR_SUCCESS) - *t -= (apr_time_t) xt->tm_gmtoff * APR_USEC_PER_SEC; + *t -= (fspr_time_t) xt->tm_gmtoff * APR_USEC_PER_SEC; return status; } -APR_DECLARE(apr_status_t) apr_os_imp_time_get(apr_os_imp_time_t **ostime, - apr_time_t *aprtime) +APR_DECLARE(fspr_status_t) fspr_os_imp_time_get(fspr_os_imp_time_t **ostime, + fspr_time_t *aprtime) { - /* TODO: Consider not passing in pointer to apr_time_t (e.g., call by value) */ + /* TODO: Consider not passing in pointer to fspr_time_t (e.g., call by value) */ AprTimeToFileTime(*ostime, *aprtime); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_os_exp_time_get(apr_os_exp_time_t **ostime, - apr_time_exp_t *aprexptime) +APR_DECLARE(fspr_status_t) fspr_os_exp_time_get(fspr_os_exp_time_t **ostime, + fspr_time_exp_t *aprexptime) { (*ostime)->wYear = aprexptime->tm_year + 1900; (*ostime)->wMonth = aprexptime->tm_mon + 1; @@ -275,9 +275,9 @@ APR_DECLARE(apr_status_t) apr_os_exp_time_get(apr_os_exp_time_t **ostime, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_os_imp_time_put(apr_time_t *aprtime, - apr_os_imp_time_t **ostime, - apr_pool_t *cont) +APR_DECLARE(fspr_status_t) fspr_os_imp_time_put(fspr_time_t *aprtime, + fspr_os_imp_time_t **ostime, + fspr_pool_t *cont) { /* XXX: sanity failure, what is file time, gmt or local ? */ @@ -285,9 +285,9 @@ APR_DECLARE(apr_status_t) apr_os_imp_time_put(apr_time_t *aprtime, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_os_exp_time_put(apr_time_exp_t *aprtime, - apr_os_exp_time_t **ostime, - apr_pool_t *cont) +APR_DECLARE(fspr_status_t) fspr_os_exp_time_put(fspr_time_exp_t *aprtime, + fspr_os_exp_time_t **ostime, + fspr_pool_t *cont) { /* The Platform SDK documents that SYSTEMTIME/FILETIME are * generally UTC, so no timezone info needed @@ -296,7 +296,7 @@ APR_DECLARE(apr_status_t) apr_os_exp_time_put(apr_time_exp_t *aprtime, return APR_SUCCESS; } -APR_DECLARE(void) apr_sleep(apr_interval_time_t t) +APR_DECLARE(void) fspr_sleep(fspr_interval_time_t t) { /* One of the few sane situations for a cast, Sleep * is in ms, not us, and passed as a DWORD value @@ -305,14 +305,14 @@ APR_DECLARE(void) apr_sleep(apr_interval_time_t t) } -static apr_status_t clock_restore(void *unsetres) +static fspr_status_t clock_restore(void *unsetres) { ULONG newRes; SetTimerResolution((ULONG)unsetres, FALSE, &newRes); return APR_SUCCESS; } -APR_DECLARE(void) apr_time_clock_hires(apr_pool_t *p) +APR_DECLARE(void) fspr_time_clock_hires(fspr_pool_t *p) { ULONG newRes; /* Timer resolution is stated in 100ns units. Note that TRUE requests the @@ -320,7 +320,7 @@ APR_DECLARE(void) apr_time_clock_hires(apr_pool_t *p) */ if (SetTimerResolution(10000, TRUE, &newRes) == 0 /* STATUS_SUCCESS */) { /* register the cleanup... */ - apr_pool_cleanup_register(p, (void*)10000, clock_restore, - apr_pool_cleanup_null); + fspr_pool_cleanup_register(p, (void*)10000, clock_restore, + fspr_pool_cleanup_null); } } diff --git a/libs/apr/time/win32/timestr.c b/libs/apr/time/win32/timestr.c index af1526497b..606291e0be 100644 --- a/libs/apr/time/win32/timestr.c +++ b/libs/apr/time/win32/timestr.c @@ -14,31 +14,31 @@ * limitations under the License. */ -#include "win32/apr_arch_atime.h" -#include "apr_portable.h" -#include "apr_strings.h" +#include "win32/fspr_arch_atime.h" +#include "fspr_portable.h" +#include "fspr_strings.h" -APR_DECLARE_DATA const char apr_month_snames[12][4] = +APR_DECLARE_DATA const char fspr_month_snames[12][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; -APR_DECLARE_DATA const char apr_day_snames[7][4] = +APR_DECLARE_DATA const char fspr_day_snames[7][4] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; -APR_DECLARE(apr_status_t) apr_rfc822_date(char *date_str, apr_time_t t) +APR_DECLARE(fspr_status_t) fspr_rfc822_date(char *date_str, fspr_time_t t) { - apr_time_exp_t xt; + fspr_time_exp_t xt; const char *s; int real_year; - apr_time_exp_gmt(&xt, t); + fspr_time_exp_gmt(&xt, t); /* example: "Sat, 08 Jan 2000 18:31:41 GMT" */ /* 12345678901234567890123456789 */ - s = &apr_day_snames[xt.tm_wday][0]; + s = &fspr_day_snames[xt.tm_wday][0]; *date_str++ = *s++; *date_str++ = *s++; *date_str++ = *s++; @@ -47,7 +47,7 @@ APR_DECLARE(apr_status_t) apr_rfc822_date(char *date_str, apr_time_t t) *date_str++ = xt.tm_mday / 10 + '0'; *date_str++ = xt.tm_mday % 10 + '0'; *date_str++ = ' '; - s = &apr_month_snames[xt.tm_mon][0]; + s = &fspr_month_snames[xt.tm_mon][0]; *date_str++ = *s++; *date_str++ = *s++; *date_str++ = *s++; @@ -75,22 +75,22 @@ APR_DECLARE(apr_status_t) apr_rfc822_date(char *date_str, apr_time_t t) return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_ctime(char *date_str, apr_time_t t) +APR_DECLARE(fspr_status_t) fspr_ctime(char *date_str, fspr_time_t t) { - apr_time_exp_t xt; + fspr_time_exp_t xt; const char *s; int real_year; /* example: "Wed Jun 30 21:49:08 1993" */ /* 123456789012345678901234 */ - apr_time_exp_lt(&xt, t); - s = &apr_day_snames[xt.tm_wday][0]; + fspr_time_exp_lt(&xt, t); + s = &fspr_day_snames[xt.tm_wday][0]; *date_str++ = *s++; *date_str++ = *s++; *date_str++ = *s++; *date_str++ = ' '; - s = &apr_month_snames[xt.tm_mon][0]; + s = &fspr_month_snames[xt.tm_mon][0]; *date_str++ = *s++; *date_str++ = *s++; *date_str++ = *s++; @@ -120,7 +120,7 @@ APR_DECLARE(apr_status_t) apr_ctime(char *date_str, apr_time_t t) #ifndef _WIN32_WCE -apr_size_t win32_strftime_extra(char *s, size_t max, const char *format, +fspr_size_t win32_strftime_extra(char *s, size_t max, const char *format, const struct tm *tm) { /* If the new format string is bigger than max, the result string won't fit @@ -128,7 +128,7 @@ apr_size_t win32_strftime_extra(char *s, size_t max, const char *format, * enough */ char *new_format = (char *) malloc(max + 11); size_t i, j, format_length = strlen(format); - apr_size_t return_value; + fspr_size_t return_value; int length_written; for (i = 0, j = 0; (i < format_length && j < max);) { @@ -138,7 +138,7 @@ apr_size_t win32_strftime_extra(char *s, size_t max, const char *format, } switch (format[i+1]) { case 'C': - length_written = apr_snprintf(new_format + j, max - j, "%2d", + length_written = fspr_snprintf(new_format + j, max - j, "%2d", (tm->tm_year + 1970)/100); j = (length_written == -1) ? max : (j + length_written); i += 2; @@ -166,7 +166,7 @@ apr_size_t win32_strftime_extra(char *s, size_t max, const char *format, j += 8; break; case 'e': - length_written = apr_snprintf(new_format + j, max - j, "%2d", + length_written = fspr_snprintf(new_format + j, max - j, "%2d", tm->tm_mday); j = (length_written == -1) ? max : (j + length_written); i += 2; @@ -192,9 +192,9 @@ apr_size_t win32_strftime_extra(char *s, size_t max, const char *format, #endif -APR_DECLARE(apr_status_t) apr_strftime(char *s, apr_size_t *retsize, - apr_size_t max, const char *format, - apr_time_exp_t *xt) +APR_DECLARE(fspr_status_t) fspr_strftime(char *s, fspr_size_t *retsize, + fspr_size_t max, const char *format, + fspr_time_exp_t *xt) { #ifdef _WIN32_WCE return APR_ENOTIMPL; diff --git a/libs/apr/user/netware/groupinfo.c b/libs/apr/user/netware/groupinfo.c index e7cfd9b267..86a22df502 100644 --- a/libs/apr/user/netware/groupinfo.c +++ b/libs/apr/user/netware/groupinfo.c @@ -14,10 +14,10 @@ * limitations under the License. */ -#include "apr_strings.h" -#include "apr_portable.h" -#include "apr_user.h" -#include "apr_private.h" +#include "fspr_strings.h" +#include "fspr_portable.h" +#include "fspr_user.h" +#include "fspr_private.h" #ifdef HAVE_GRP_H #include #endif @@ -28,14 +28,14 @@ #include /* for _POSIX_THREAD_SAFE_FUNCTIONS */ #endif -APR_DECLARE(apr_status_t) apr_gid_name_get(char **groupname, apr_gid_t groupid, - apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_gid_name_get(char **groupname, fspr_gid_t groupid, + fspr_pool_t *p) { return APR_ENOTIMPL; } -APR_DECLARE(apr_status_t) apr_gid_get(apr_gid_t *groupid, - const char *groupname, apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_gid_get(fspr_gid_t *groupid, + const char *groupname, fspr_pool_t *p) { return APR_ENOTIMPL; } diff --git a/libs/apr/user/netware/userinfo.c b/libs/apr/user/netware/userinfo.c index b58991b8ea..c5677dab7e 100644 --- a/libs/apr/user/netware/userinfo.c +++ b/libs/apr/user/netware/userinfo.c @@ -14,10 +14,10 @@ * limitations under the License. */ -#include "apr_strings.h" -#include "apr_portable.h" -#include "apr_user.h" -#include "apr_private.h" +#include "fspr_strings.h" +#include "fspr_portable.h" +#include "fspr_user.h" +#include "fspr_private.h" #ifdef HAVE_PWD_H #include #endif @@ -30,25 +30,25 @@ #define PWBUF_SIZE 512 -static apr_status_t getpwnam_safe(const char *username, +static fspr_status_t getpwnam_safe(const char *username, struct passwd *pw, char pwbuf[PWBUF_SIZE]) { return APR_ENOTIMPL; } -APR_DECLARE(apr_status_t) apr_uid_homepath_get(char **dirname, +APR_DECLARE(fspr_status_t) fspr_uid_homepath_get(char **dirname, const char *username, - apr_pool_t *p) + fspr_pool_t *p) { return APR_ENOTIMPL; } -APR_DECLARE(apr_status_t) apr_uid_current(apr_uid_t *uid, - apr_gid_t *gid, - apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_uid_current(fspr_uid_t *uid, + fspr_gid_t *gid, + fspr_pool_t *p) { return APR_ENOTIMPL; } @@ -56,14 +56,14 @@ APR_DECLARE(apr_status_t) apr_uid_current(apr_uid_t *uid, -APR_DECLARE(apr_status_t) apr_uid_get(apr_uid_t *uid, apr_gid_t *gid, - const char *username, apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_uid_get(fspr_uid_t *uid, fspr_gid_t *gid, + const char *username, fspr_pool_t *p) { return APR_ENOTIMPL; } -APR_DECLARE(apr_status_t) apr_uid_name_get(char **username, apr_uid_t userid, - apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_uid_name_get(char **username, fspr_uid_t userid, + fspr_pool_t *p) { return APR_ENOTIMPL; } diff --git a/libs/apr/user/unix/groupinfo.c b/libs/apr/user/unix/groupinfo.c index 89ae966b67..994eda17a3 100644 --- a/libs/apr/user/unix/groupinfo.c +++ b/libs/apr/user/unix/groupinfo.c @@ -14,10 +14,10 @@ * limitations under the License. */ -#include "apr_strings.h" -#include "apr_portable.h" -#include "apr_user.h" -#include "apr_private.h" +#include "fspr_strings.h" +#include "fspr_portable.h" +#include "fspr_user.h" +#include "fspr_private.h" #ifdef HAVE_GRP_H #include #endif @@ -28,15 +28,15 @@ #include /* for _POSIX_THREAD_SAFE_FUNCTIONS */ #endif -APR_DECLARE(apr_status_t) apr_gid_name_get(char **groupname, apr_gid_t groupid, - apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_gid_name_get(char **groupname, fspr_gid_t groupid, + fspr_pool_t *p) { struct group *gr; #if APR_HAS_THREADS && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) struct group grp; char grbuf[512]; - apr_status_t rv; + fspr_status_t rv; /* See comment in getpwnam_safe on error handling. */ rv = getgrgid_r(groupid, &grp, grbuf, sizeof(grbuf), &gr); @@ -52,19 +52,19 @@ APR_DECLARE(apr_status_t) apr_gid_name_get(char **groupname, apr_gid_t groupid, return errno ? errno : APR_ENOENT; } #endif - *groupname = apr_pstrdup(p, gr->gr_name); + *groupname = fspr_pstrdup(p, gr->gr_name); return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_gid_get(apr_gid_t *groupid, - const char *groupname, apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_gid_get(fspr_gid_t *groupid, + const char *groupname, fspr_pool_t *p) { struct group *gr; #if APR_HAS_THREADS && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRNAM_R) struct group grp; char grbuf[512]; - apr_status_t rv; + fspr_status_t rv; /* See comment in getpwnam_safe on error handling. */ rv = getgrnam_r(groupname, &grp, grbuf, sizeof(grbuf), &gr); diff --git a/libs/apr/user/unix/userinfo.c b/libs/apr/user/unix/userinfo.c index 8b1d6db808..3cb6c5abb7 100644 --- a/libs/apr/user/unix/userinfo.c +++ b/libs/apr/user/unix/userinfo.c @@ -14,10 +14,10 @@ * limitations under the License. */ -#include "apr_strings.h" -#include "apr_portable.h" -#include "apr_user.h" -#include "apr_private.h" +#include "fspr_strings.h" +#include "fspr_portable.h" +#include "fspr_user.h" +#include "fspr_private.h" #ifdef HAVE_PWD_H #include #endif @@ -28,17 +28,17 @@ #include /* for _POSIX_THREAD_SAFE_FUNCTIONS */ #endif #define APR_WANT_MEMFUNC -#include "apr_want.h" +#include "fspr_want.h" #define PWBUF_SIZE 512 -static apr_status_t getpwnam_safe(const char *username, +static fspr_status_t getpwnam_safe(const char *username, struct passwd *pw, char pwbuf[PWBUF_SIZE]) { struct passwd *pwptr; #if APR_HAS_THREADS && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) - apr_status_t rv; + fspr_status_t rv; /* POSIX defines getpwnam_r() et al to return the error number * rather than set errno, and requires pwptr to be set to NULL if @@ -66,31 +66,31 @@ static apr_status_t getpwnam_safe(const char *username, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_uid_homepath_get(char **dirname, +APR_DECLARE(fspr_status_t) fspr_uid_homepath_get(char **dirname, const char *username, - apr_pool_t *p) + fspr_pool_t *p) { struct passwd pw; char pwbuf[PWBUF_SIZE]; - apr_status_t rv; + fspr_status_t rv; if ((rv = getpwnam_safe(username, &pw, pwbuf)) != APR_SUCCESS) return rv; #ifdef OS2 /* Need to manually add user name for OS/2 */ - *dirname = apr_pstrcat(p, pw.pw_dir, pw.pw_name, NULL); + *dirname = fspr_pstrcat(p, pw.pw_dir, pw.pw_name, NULL); #else - *dirname = apr_pstrdup(p, pw.pw_dir); + *dirname = fspr_pstrdup(p, pw.pw_dir); #endif return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_uid_current(apr_uid_t *uid, - apr_gid_t *gid, - apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_uid_current(fspr_uid_t *uid, + fspr_gid_t *gid, + fspr_pool_t *p) { *uid = getuid(); *gid = getgid(); @@ -101,12 +101,12 @@ APR_DECLARE(apr_status_t) apr_uid_current(apr_uid_t *uid, -APR_DECLARE(apr_status_t) apr_uid_get(apr_uid_t *uid, apr_gid_t *gid, - const char *username, apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_uid_get(fspr_uid_t *uid, fspr_gid_t *gid, + const char *username, fspr_pool_t *p) { struct passwd pw; char pwbuf[PWBUF_SIZE]; - apr_status_t rv; + fspr_status_t rv; if ((rv = getpwnam_safe(username, &pw, pwbuf)) != APR_SUCCESS) return rv; @@ -117,14 +117,14 @@ APR_DECLARE(apr_status_t) apr_uid_get(apr_uid_t *uid, apr_gid_t *gid, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_uid_name_get(char **username, apr_uid_t userid, - apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_uid_name_get(char **username, fspr_uid_t userid, + fspr_pool_t *p) { struct passwd *pw; #if APR_HAS_THREADS && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWUID_R) struct passwd pwd; char pwbuf[PWBUF_SIZE]; - apr_status_t rv; + fspr_status_t rv; rv = getpwuid_r(userid, &pwd, pwbuf, sizeof(pwbuf), &pw); if (rv) { @@ -141,6 +141,6 @@ APR_DECLARE(apr_status_t) apr_uid_name_get(char **username, apr_uid_t userid, return errno ? errno : APR_ENOENT; } #endif - *username = apr_pstrdup(p, pw->pw_name); + *username = fspr_pstrdup(p, pw->pw_name); return APR_SUCCESS; } diff --git a/libs/apr/user/win32/groupinfo.c b/libs/apr/user/win32/groupinfo.c index 7739a5428d..5ed18ee323 100644 --- a/libs/apr/user/win32/groupinfo.c +++ b/libs/apr/user/win32/groupinfo.c @@ -14,16 +14,16 @@ * limitations under the License. */ -#include "apr_strings.h" -#include "apr_portable.h" -#include "apr_user.h" -#include "apr_private.h" +#include "fspr_strings.h" +#include "fspr_portable.h" +#include "fspr_user.h" +#include "fspr_private.h" #if APR_HAVE_SYS_TYPES_H #include #endif -APR_DECLARE(apr_status_t) apr_gid_get(apr_gid_t *gid, - const char *groupname, apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_gid_get(fspr_gid_t *gid, + const char *groupname, fspr_pool_t *p) { #ifdef _WIN32_WCE return APR_ENOTIMPL; @@ -37,11 +37,11 @@ APR_DECLARE(apr_status_t) apr_gid_get(apr_gid_t *gid, char *pos; if (pos = strchr(groupname, '/')) { - domain = apr_pstrndup(p, groupname, pos - groupname); + domain = fspr_pstrndup(p, groupname, pos - groupname); groupname = pos + 1; } else if (pos = strchr(groupname, '\\')) { - domain = apr_pstrndup(p, groupname, pos - groupname); + domain = fspr_pstrndup(p, groupname, pos - groupname); groupname = pos + 1; } else { @@ -54,22 +54,22 @@ APR_DECLARE(apr_status_t) apr_gid_get(apr_gid_t *gid, if (sidlen) { /* Give it back on the second pass */ - *gid = apr_palloc(p, sidlen); + *gid = fspr_palloc(p, sidlen); domlen = sizeof(anydomain); rv = LookupAccountName(domain, groupname, *gid, &sidlen, anydomain, &domlen, &sidtype); } if (!sidlen || !rv) { - return apr_get_os_error(); + return fspr_get_os_error(); } return APR_SUCCESS; #endif } -APR_DECLARE(apr_status_t) apr_gid_name_get(char **groupname, apr_gid_t groupid, apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_gid_name_get(char **groupname, fspr_gid_t groupid, fspr_pool_t *p) { #ifdef _WIN32_WCE - *groupname = apr_pstrdup(p, "Administrators"); + *groupname = fspr_pstrdup(p, "Administrators"); #else SID_NAME_USE type; char name[MAX_PATH], domain[MAX_PATH]; @@ -77,16 +77,16 @@ APR_DECLARE(apr_status_t) apr_gid_name_get(char **groupname, apr_gid_t groupid, if (!groupid) return APR_EINVAL; if (!LookupAccountSid(NULL, groupid, name, &cbname, domain, &cbdomain, &type)) - return apr_get_os_error(); + return fspr_get_os_error(); if (type != SidTypeGroup && type != SidTypeWellKnownGroup && type != SidTypeAlias) return APR_EINVAL; - *groupname = apr_pstrdup(p, name); + *groupname = fspr_pstrdup(p, name); #endif return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_gid_compare(apr_gid_t left, apr_gid_t right) +APR_DECLARE(fspr_status_t) fspr_gid_compare(fspr_gid_t left, fspr_gid_t right) { if (!left || !right) return APR_EINVAL; diff --git a/libs/apr/user/win32/userinfo.c b/libs/apr/user/win32/userinfo.c index aae3f9bec0..28b243d828 100644 --- a/libs/apr/user/win32/userinfo.c +++ b/libs/apr/user/win32/userinfo.c @@ -14,11 +14,11 @@ * limitations under the License. */ -#include "apr_private.h" -#include "apr_strings.h" -#include "apr_portable.h" -#include "apr_user.h" -#include "apr_arch_file_io.h" +#include "fspr_private.h" +#include "fspr_strings.h" +#include "fspr_portable.h" +#include "fspr_user.h" +#include "fspr_arch_file_io.h" #if APR_HAVE_SYS_TYPES_H #include #endif @@ -30,7 +30,7 @@ * depends on IsValidSid(), which internally we better test long * before we get here! */ -void get_sid_string(char *buf, apr_size_t blen, apr_uid_t id) +void get_sid_string(char *buf, fspr_size_t blen, fspr_uid_t id) { PSID_IDENTIFIER_AUTHORITY psia; DWORD nsa; @@ -45,10 +45,10 @@ void get_sid_string(char *buf, apr_size_t blen, apr_uid_t id) + ((DWORD)(psia->Value[3]) << 16) + ((DWORD)(psia->Value[2]) << 24); sa = (DWORD)(psia->Value[1]) + ((DWORD)(psia->Value[0]) << 8); if (sa) { - slen = apr_snprintf(buf, blen, "S-%lu-0x%04x%08x", + slen = fspr_snprintf(buf, blen, "S-%lu-0x%04x%08x", SID_REVISION, sa, nsa); } else { - slen = apr_snprintf(buf, blen, "S-%lu-%lu", + slen = fspr_snprintf(buf, blen, "S-%lu-%lu", SID_REVISION, nsa); } @@ -56,7 +56,7 @@ void get_sid_string(char *buf, apr_size_t blen, apr_uid_t id) */ nsa = *GetSidSubAuthorityCount(id); for (sa = 0; sa < nsa; ++sa) { - slen += apr_snprintf(buf + slen, blen - slen, "-%lu", + slen += fspr_snprintf(buf + slen, blen - slen, "-%lu", *GetSidSubAuthority(id, sa)); } } @@ -64,26 +64,26 @@ void get_sid_string(char *buf, apr_size_t blen, apr_uid_t id) /* Query the ProfileImagePath from the version-specific branch, where the * regkey uses the user's name on 9x, and user's sid string on NT. */ -APR_DECLARE(apr_status_t) apr_uid_homepath_get(char **dirname, +APR_DECLARE(fspr_status_t) fspr_uid_homepath_get(char **dirname, const char *username, - apr_pool_t *p) + fspr_pool_t *p) { #ifdef _WIN32_WCE - *dirname = apr_pstrdup(p, "/My Documents"); + *dirname = fspr_pstrdup(p, "/My Documents"); return APR_SUCCESS; #else - apr_status_t rv; + fspr_status_t rv; char regkey[MAX_PATH * 2]; char *fixch; DWORD keylen; DWORD type; HKEY key; - if (apr_os_level >= APR_WIN_NT) { - apr_uid_t uid; - apr_gid_t gid; + if (fspr_os_level >= APR_WIN_NT) { + fspr_uid_t uid; + fspr_gid_t gid; - if ((rv = apr_uid_get(&uid, &gid, username, p)) != APR_SUCCESS) + if ((rv = fspr_uid_get(&uid, &gid, username, p)) != APR_SUCCESS) return rv; strcpy(regkey, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\" @@ -95,7 +95,7 @@ APR_DECLARE(apr_status_t) apr_uid_homepath_get(char **dirname, strcpy(regkey, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\" "ProfileList\\"); keylen = (DWORD)strlen(regkey); - apr_cpystrn(regkey + keylen, username, sizeof(regkey) - keylen); + fspr_cpystrn(regkey + keylen, username, sizeof(regkey) - keylen); } if ((rv = RegOpenKeyEx(HKEY_LOCAL_MACHINE, regkey, 0, @@ -114,18 +114,18 @@ APR_DECLARE(apr_status_t) apr_uid_homepath_get(char **dirname, if (type == REG_SZ) { char retdir[MAX_PATH]; if ((rv = unicode_to_utf8_path(retdir, sizeof(retdir), - (apr_wchar_t*)regkey)) != APR_SUCCESS) + (fspr_wchar_t*)regkey)) != APR_SUCCESS) return rv; - *dirname = apr_pstrdup(p, retdir); + *dirname = fspr_pstrdup(p, retdir); } else if (type == REG_EXPAND_SZ) { - apr_wchar_t path[MAX_PATH]; + fspr_wchar_t path[MAX_PATH]; char retdir[MAX_PATH]; - ExpandEnvironmentStringsW((apr_wchar_t*)regkey, path, sizeof(path)); + ExpandEnvironmentStringsW((fspr_wchar_t*)regkey, path, sizeof(path)); if ((rv = unicode_to_utf8_path(retdir, sizeof(retdir), path)) != APR_SUCCESS) return rv; - *dirname = apr_pstrdup(p, retdir); + *dirname = fspr_pstrdup(p, retdir); } else return APR_ENOENT; @@ -141,12 +141,12 @@ APR_DECLARE(apr_status_t) apr_uid_homepath_get(char **dirname, if (rv != ERROR_SUCCESS) return APR_FROM_OS_ERROR(rv); if (type == REG_SZ) { - *dirname = apr_pstrdup(p, regkey); + *dirname = fspr_pstrdup(p, regkey); } else if (type == REG_EXPAND_SZ) { char path[MAX_PATH]; ExpandEnvironmentStrings(regkey, path, sizeof(path)); - *dirname = apr_pstrdup(p, path); + *dirname = fspr_pstrdup(p, path); } else return APR_ENOENT; @@ -159,9 +159,9 @@ APR_DECLARE(apr_status_t) apr_uid_homepath_get(char **dirname, #endif /* _WIN32_WCE */ } -APR_DECLARE(apr_status_t) apr_uid_current(apr_uid_t *uid, - apr_gid_t *gid, - apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_uid_current(fspr_uid_t *uid, + fspr_gid_t *gid, + fspr_pool_t *p) { #ifdef _WIN32_WCE return APR_ENOTIMPL; @@ -172,32 +172,32 @@ APR_DECLARE(apr_status_t) apr_uid_current(apr_uid_t *uid, TOKEN_PRIMARY_GROUP *grp; if(!OpenProcessToken(GetCurrentProcess(), STANDARD_RIGHTS_READ | READ_CONTROL | TOKEN_QUERY, &threadtok)) { - return apr_get_os_error(); + return fspr_get_os_error(); } *uid = NULL; if (!GetTokenInformation(threadtok, TokenUser, NULL, 0, &needed) && (GetLastError() == ERROR_INSUFFICIENT_BUFFER) - && (usr = apr_palloc(p, needed)) + && (usr = fspr_palloc(p, needed)) && GetTokenInformation(threadtok, TokenUser, usr, needed, &needed)) *uid = usr->User.Sid; else - return apr_get_os_error(); + return fspr_get_os_error(); if (!GetTokenInformation(threadtok, TokenPrimaryGroup, NULL, 0, &needed) && (GetLastError() == ERROR_INSUFFICIENT_BUFFER) - && (grp = apr_palloc(p, needed)) + && (grp = fspr_palloc(p, needed)) && GetTokenInformation(threadtok, TokenPrimaryGroup, grp, needed, &needed)) *gid = grp->PrimaryGroup; else - return apr_get_os_error(); + return fspr_get_os_error(); return APR_SUCCESS; #endif } -APR_DECLARE(apr_status_t) apr_uid_get(apr_uid_t *uid, apr_gid_t *gid, - const char *username, apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_uid_get(fspr_uid_t *uid, fspr_gid_t *gid, + const char *username, fspr_pool_t *p) { #ifdef _WIN32_WCE return APR_ENOTIMPL; @@ -211,11 +211,11 @@ APR_DECLARE(apr_status_t) apr_uid_get(apr_uid_t *uid, apr_gid_t *gid, char *pos; if (pos = strchr(username, '/')) { - domain = apr_pstrndup(p, username, pos - username); + domain = fspr_pstrndup(p, username, pos - username); username = pos + 1; } else if (pos = strchr(username, '\\')) { - domain = apr_pstrndup(p, username, pos - username); + domain = fspr_pstrndup(p, username, pos - username); username = pos + 1; } else { @@ -228,13 +228,13 @@ APR_DECLARE(apr_status_t) apr_uid_get(apr_uid_t *uid, apr_gid_t *gid, if (sidlen) { /* Give it back on the second pass */ - *uid = apr_palloc(p, sidlen); + *uid = fspr_palloc(p, sidlen); domlen = sizeof(anydomain); rv = LookupAccountName(domain, username, *uid, &sidlen, anydomain, &domlen, &sidtype); } if (!sidlen || !rv) { - return apr_get_os_error(); + return fspr_get_os_error(); } /* There doesn't seem to be a simple way to retrieve the primary group sid */ @@ -243,11 +243,11 @@ APR_DECLARE(apr_status_t) apr_uid_get(apr_uid_t *uid, apr_gid_t *gid, #endif } -APR_DECLARE(apr_status_t) apr_uid_name_get(char **username, apr_uid_t userid, - apr_pool_t *p) +APR_DECLARE(fspr_status_t) fspr_uid_name_get(char **username, fspr_uid_t userid, + fspr_pool_t *p) { #ifdef _WIN32_WCE - *username = apr_pstrdup(p, "Administrator"); + *username = fspr_pstrdup(p, "Administrator"); return APR_SUCCESS; #else SID_NAME_USE type; @@ -256,15 +256,15 @@ APR_DECLARE(apr_status_t) apr_uid_name_get(char **username, apr_uid_t userid, if (!userid) return APR_EINVAL; if (!LookupAccountSid(NULL, userid, name, &cbname, domain, &cbdomain, &type)) - return apr_get_os_error(); + return fspr_get_os_error(); if (type != SidTypeUser && type != SidTypeAlias && type != SidTypeWellKnownGroup) return APR_EINVAL; - *username = apr_pstrdup(p, name); + *username = fspr_pstrdup(p, name); return APR_SUCCESS; #endif } -APR_DECLARE(apr_status_t) apr_uid_compare(apr_uid_t left, apr_uid_t right) +APR_DECLARE(fspr_status_t) fspr_uid_compare(fspr_uid_t left, fspr_uid_t right) { if (!left || !right) return APR_EINVAL; diff --git a/libs/esl/Makefile.am b/libs/esl/Makefile.am index b946712311..695d9af841 100644 --- a/libs/esl/Makefile.am +++ b/libs/esl/Makefile.am @@ -54,6 +54,7 @@ reswig: swigclean $(MAKE) -C php reswig $(MAKE) -C lua reswig $(MAKE) -C python reswig + $(MAKE) -C python3 reswig $(MAKE) -C ruby reswig $(MAKE) -C java reswig $(MAKE) -C managed reswig @@ -63,6 +64,7 @@ swigclean: clean $(MAKE) -C php swigclean $(MAKE) -C lua swigclean $(MAKE) -C python swigclean + $(MAKE) -C python3 swigclean $(MAKE) -C ruby swigclean $(MAKE) -C java swigclean $(MAKE) -C managed swigclean @@ -77,7 +79,10 @@ luamod: $(MYLIB) $(MAKE) MYLIB="../$(MYLIB)" SOLINK="$(SOLINK)" CFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CFLAGS)" CXXFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CXXFLAGS)" CXX_CFLAGS="$(CXX_CFLAGS)" LUA_CFLAGS="$(LUA_CFLAGS)" LUA_LIBS="$(LUA_LIBS)" -C lua pymod: $(MYLIB) - $(MAKE) MYLIB="../$(MYLIB)" SOLINK="$(SOLINK)" CFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CFLAGS)" CXXFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CXXFLAGS)" CXX_CFLAGS="$(CXX_CFLAGS)" -C python + $(MAKE) PYTHON=$(PYTHON) MYLIB="../$(MYLIB)" SOLINK="$(SOLINK)" CFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CFLAGS)" CXXFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CXXFLAGS)" CXX_CFLAGS="$(CXX_CFLAGS)" -C python + +py3mod: $(MYLIB) + $(MAKE) PYTHON3=$(PYTHON3) MYLIB="../$(MYLIB)" SOLINK="$(SOLINK)" CFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CFLAGS)" CXXFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CXXFLAGS)" CXX_CFLAGS="$(CXX_CFLAGS)" -C python3 tclmod: $(MYLIB) $(MAKE) MYLIB="../$(MYLIB)" SOLINK="$(SOLINK)" CFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CFLAGS)" CXXFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CXXFLAGS)" CXX_CFLAGS="$(CXX_CFLAGS)" -C tcl @@ -98,9 +103,12 @@ phpmod-install: phpmod $(MAKE) -C php install pymod-install: pymod - $(MAKE) -C python install + $(MAKE) PYTHON=$(PYTHON) -C python install + +py3mod-install: py3mod + $(MAKE) PYTHON3=$(PYTHON3) -C python3 install rubymod-install: rubymod $(MAKE) -C ruby install -everymod: perlmod phpmod luamod pymod rubymod javamod managedmod +everymod: perlmod phpmod luamod pymod py3mod rubymod javamod managedmod diff --git a/libs/esl/fs_cli.c b/libs/esl/fs_cli.c index 76e85b450d..973df741e0 100644 --- a/libs/esl/fs_cli.c +++ b/libs/esl/fs_cli.c @@ -632,7 +632,8 @@ static const char *usage_str = " -b, --batchmode Batch mode\n" " -t, --timeout Timeout for API commands (in milliseconds)\n" " -T, --connect-timeout Timeout for socket connection (in milliseconds)\n" - " -n, --no-color Disable color\n\n"; + " -n, --no-color Disable color\n" + " -s, --set-log-uuid Set UUID to filter log events\n\n"; static int usage(char *name){ printf(usage_str, name); @@ -1468,6 +1469,7 @@ int main(int argc, char *argv[]) {"reconnect", 0, 0, 'R'}, {"timeout", 1, 0, 't'}, {"connect-timeout", 1, 0, 'T'}, + {"set-log-uuid", 1, 0, 's'}, {0, 0, 0, 0} }; char temp_host[128]; @@ -1483,6 +1485,7 @@ int main(int argc, char *argv[]) int argv_exec = 0; char argv_command[1024] = ""; char argv_loglevel[127] = ""; + char argv_filter_uuid[64] = {0}; int argv_log_uuid = 0; int argv_log_uuid_short = 0; int argv_quiet = 0; @@ -1539,7 +1542,7 @@ int main(int argc, char *argv[]) esl_global_set_default_logger(6); /* default debug level to 6 (info) */ for(;;) { int option_index = 0; - opt = getopt_long(argc, argv, "H:P:u:p:d:x:l:USt:T:qQrRhib?n", options, &option_index); + opt = getopt_long(argc, argv, "H:P:u:p:d:x:l:USt:T:qQrRhib?ns:", options, &option_index); if (opt == -1) break; switch (opt) { case 'H': @@ -1614,6 +1617,11 @@ int main(int argc, char *argv[]) case 'T': connect_timeout = atoi(optarg); break; + case 's': + esl_set_string(argv_filter_uuid, optarg); + filter_uuid = strdup(argv_filter_uuid); + break; + case 'h': case '?': print_banner(stdout, is_color); diff --git a/libs/esl/python/Makefile b/libs/esl/python/Makefile index 71396dd4ba..824d3afe7f 100644 --- a/libs/esl/python/Makefile +++ b/libs/esl/python/Makefile @@ -1,6 +1,6 @@ -LOCAL_CFLAGS=`python ./python-config --includes` -LOCAL_LDFLAGS=`python ./python-config --ldflags` -SITE_DIR=$(DESTDIR)/`python -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)"` +LOCAL_CFLAGS=`$(PYTHON) ./python-config --includes` +LOCAL_LDFLAGS=`$(PYTHON) ./python-config --ldflags` +SITE_DIR=$(DESTDIR)/`$(PYTHON) -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)"` all: _ESL.so diff --git a/libs/esl/python/python-config b/libs/esl/python/python-config index 71699916f5..1e60a89047 100644 --- a/libs/esl/python/python-config +++ b/libs/esl/python/python-config @@ -1,5 +1,6 @@ -#! /usr/bin/python2.5 +#!/usr/bin/env python +from __future__ import print_function import sys import os import getopt @@ -9,8 +10,7 @@ valid_opts = ['prefix', 'exec-prefix', 'includes', 'libs', 'cflags', 'ldflags', 'help'] def exit_with_usage(code=1): - print >>sys.stderr, "Usage: %s [%s]" % (sys.argv[0], - '|'.join('--'+opt for opt in valid_opts)) + print("Usage: %s [%s]" % (sys.argv[0], '|'.join('--'+opt for opt in valid_opts)), file=sys.stderr) sys.exit(code) try: @@ -30,17 +30,17 @@ if opt == '--help': exit_with_usage(0) elif opt == '--prefix': - print sysconfig.PREFIX + print(sysconfig.PREFIX) elif opt == '--exec-prefix': - print sysconfig.EXEC_PREFIX + print(sysconfig.EXEC_PREFIX) elif opt in ('--includes', '--cflags'): flags = ['-I' + sysconfig.get_python_inc(), '-I' + sysconfig.get_python_inc(plat_specific=True)] if opt == '--cflags': flags.extend(getvar('CFLAGS').split()) - print ' '.join(flags) + print(' '.join(flags)) elif opt in ('--libs', '--ldflags'): libs = getvar('LIBS').split() + getvar('SYSLIBS').split() @@ -49,5 +49,5 @@ elif opt in ('--libs', '--ldflags'): # shared library in prefix/lib/. if opt == '--ldflags' and not getvar('Py_ENABLE_SHARED'): libs.insert(0, '-L' + getvar('LIBPL')) - print ' '.join(libs) + print(' '.join(libs)) diff --git a/libs/esl/python3/ESL.py b/libs/esl/python3/ESL.py new file mode 100644 index 0000000000..cd9b7c4f3f --- /dev/null +++ b/libs/esl/python3/ESL.py @@ -0,0 +1,132 @@ +# This file was automatically generated by SWIG (http://www.swig.org). +# Version 3.0.2 +# +# Do not make changes to this file unless you know what you are doing--modify +# the SWIG interface file instead. + + + + + +from sys import version_info +if version_info >= (2,6,0): + def swig_import_helper(): + from os.path import dirname + import imp + fp = None + try: + fp, pathname, description = imp.find_module('_ESL', [dirname(__file__)]) + except ImportError: + import _ESL + return _ESL + if fp is not None: + try: + _mod = imp.load_module('_ESL', fp, pathname, description) + finally: + fp.close() + return _mod + _ESL = swig_import_helper() + del swig_import_helper +else: + import _ESL +del version_info +def _swig_setattr_nondynamic(self,class_type,name,value,static=1): + if (name == "thisown"): return self.this.own(value) + if (name == "this"): + if type(value).__name__ == 'SwigPyObject': + self.__dict__[name] = value + return + method = class_type.__swig_setmethods__.get(name,None) + if method: return method(self,value) + if (not static): + self.__dict__[name] = value + else: + raise AttributeError("You cannot add attributes to %s" % self) + +def _swig_setattr(self,class_type,name,value): + return _swig_setattr_nondynamic(self,class_type,name,value,0) + +def _swig_getattr(self,class_type,name): + if (name == "thisown"): return self.this.own() + method = class_type.__swig_getmethods__.get(name,None) + if method: return method(self) + raise AttributeError(name) + +def _swig_repr(self): + try: strthis = "proxy of " + self.this.__repr__() + except: strthis = "" + return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) + +class ESLevent: + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, ESLevent, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, ESLevent, name) + __repr__ = _swig_repr + __swig_setmethods__["event"] = _ESL.ESLevent_event_set + __swig_getmethods__["event"] = _ESL.ESLevent_event_get + __swig_setmethods__["serialized_string"] = _ESL.ESLevent_serialized_string_set + __swig_getmethods__["serialized_string"] = _ESL.ESLevent_serialized_string_get + __swig_setmethods__["mine"] = _ESL.ESLevent_mine_set + __swig_getmethods__["mine"] = _ESL.ESLevent_mine_get + def __init__(self, *args): + this = _ESL.new_ESLevent(*args) + try: self.this.append(this) + except: self.this = this + __swig_destroy__ = _ESL.delete_ESLevent + __del__ = lambda self : None; + def serialize(self, format=None): return _ESL.ESLevent_serialize(self, format) + def setPriority(self, *args): return _ESL.ESLevent_setPriority(self, *args) + def getHeader(self, *args): return _ESL.ESLevent_getHeader(self, *args) + def getBody(self): return _ESL.ESLevent_getBody(self) + def getType(self): return _ESL.ESLevent_getType(self) + def addBody(self, *args): return _ESL.ESLevent_addBody(self, *args) + def addHeader(self, *args): return _ESL.ESLevent_addHeader(self, *args) + def pushHeader(self, *args): return _ESL.ESLevent_pushHeader(self, *args) + def unshiftHeader(self, *args): return _ESL.ESLevent_unshiftHeader(self, *args) + def delHeader(self, *args): return _ESL.ESLevent_delHeader(self, *args) + def firstHeader(self): return _ESL.ESLevent_firstHeader(self) + def nextHeader(self): return _ESL.ESLevent_nextHeader(self) +ESLevent_swigregister = _ESL.ESLevent_swigregister +ESLevent_swigregister(ESLevent) + +class ESLconnection: + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, ESLconnection, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, ESLconnection, name) + __repr__ = _swig_repr + def __init__(self, *args): + this = _ESL.new_ESLconnection(*args) + try: self.this.append(this) + except: self.this = this + __swig_destroy__ = _ESL.delete_ESLconnection + __del__ = lambda self : None; + def socketDescriptor(self): return _ESL.ESLconnection_socketDescriptor(self) + def connected(self): return _ESL.ESLconnection_connected(self) + def getInfo(self): return _ESL.ESLconnection_getInfo(self) + def send(self, *args): return _ESL.ESLconnection_send(self, *args) + def sendRecv(self, *args): return _ESL.ESLconnection_sendRecv(self, *args) + def api(self, *args): return _ESL.ESLconnection_api(self, *args) + def bgapi(self, *args): return _ESL.ESLconnection_bgapi(self, *args) + def sendEvent(self, *args): return _ESL.ESLconnection_sendEvent(self, *args) + def sendMSG(self, *args): return _ESL.ESLconnection_sendMSG(self, *args) + def recvEvent(self): return _ESL.ESLconnection_recvEvent(self) + def recvEventTimed(self, *args): return _ESL.ESLconnection_recvEventTimed(self, *args) + def filter(self, *args): return _ESL.ESLconnection_filter(self, *args) + def events(self, *args): return _ESL.ESLconnection_events(self, *args) + def execute(self, *args): return _ESL.ESLconnection_execute(self, *args) + def executeAsync(self, *args): return _ESL.ESLconnection_executeAsync(self, *args) + def setAsyncExecute(self, *args): return _ESL.ESLconnection_setAsyncExecute(self, *args) + def setEventLock(self, *args): return _ESL.ESLconnection_setEventLock(self, *args) + def disconnect(self): return _ESL.ESLconnection_disconnect(self) +ESLconnection_swigregister = _ESL.ESLconnection_swigregister +ESLconnection_swigregister(ESLconnection) + + +def eslSetLogLevel(*args): + return _ESL.eslSetLogLevel(*args) +eslSetLogLevel = _ESL.eslSetLogLevel +# This file is compatible with both classic and new-style classes. + + diff --git a/libs/esl/python3/Makefile b/libs/esl/python3/Makefile new file mode 100644 index 0000000000..1c838534fd --- /dev/null +++ b/libs/esl/python3/Makefile @@ -0,0 +1,28 @@ +LOCAL_CFLAGS=`$(PYTHON3) ./python-config --includes` +LOCAL_LDFLAGS=`$(PYTHON3) ./python-config --ldflags` +SITE_DIR=$(DESTDIR)/`$(PYTHON3) -c "from distutils.sysconfig import get_python_lib; print (get_python_lib(1))"` + +all: _ESL.so + +esl_wrap.cpp: + swig3.0 -module ESL -classic -python -c++ -DMULTIPLICITY -threads -I../src/include -o esl_wrap.cpp ../ESL.i + +esl_wrap.o: esl_wrap.cpp + $(CXX) $(CXX_CFLAGS) $(CXXFLAGS) $(LOCAL_CFLAGS) -c esl_wrap.cpp -o esl_wrap.o + +_ESL.so: esl_wrap.o + $(CXX) $(SOLINK) esl_wrap.o $(MYLIB) $(LOCAL_LDFLAGS) -o _ESL.so -L. $(LIBS) + +install: _ESL.so + mkdir -p $(SITE_DIR) + install -m 755 _ESL.so $(SITE_DIR) + install -m 755 ESL.py $(SITE_DIR) + +clean: + rm -f *.o *.so *~ + +swigclean: + rm -f esl_wrap.* ESL.so + +reswig: swigclean esl_wrap.cpp + diff --git a/libs/esl/python3/esl_wrap.cpp b/libs/esl/python3/esl_wrap.cpp new file mode 100644 index 0000000000..b67be5488a --- /dev/null +++ b/libs/esl/python3/esl_wrap.cpp @@ -0,0 +1,6128 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.2 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +#define SWIGPYTHON +#define SWIG_PYTHON_THREADS +#define SWIG_PYTHON_DIRECTOR_NO_VTABLE +#define SWIG_PYTHON_CLASSIC + + +#ifdef __cplusplus +/* SwigValueWrapper is described in swig.swg */ +template class SwigValueWrapper { + struct SwigMovePointer { + T *ptr; + SwigMovePointer(T *p) : ptr(p) { } + ~SwigMovePointer() { delete ptr; } + SwigMovePointer& operator=(SwigMovePointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; } + } pointer; + SwigValueWrapper& operator=(const SwigValueWrapper& rhs); + SwigValueWrapper(const SwigValueWrapper& rhs); +public: + SwigValueWrapper() : pointer(0) { } + SwigValueWrapper& operator=(const T& t) { SwigMovePointer tmp(new T(t)); pointer = tmp; return *this; } + operator T&() const { return *pointer.ptr; } + T *operator&() { return pointer.ptr; } +}; + +template T SwigValueInit() { + return T(); +} +#endif + +/* ----------------------------------------------------------------------------- + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * ----------------------------------------------------------------------------- */ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# elif defined(__HP_aCC) +/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ +/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +# elif defined(__ICC) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +#endif + +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + +#ifndef SWIGUNUSEDPARM +# ifdef __cplusplus +# define SWIGUNUSEDPARM(p) +# else +# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* exporting methods */ +#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif +#endif + +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) +# define SWIGEXPORT __attribute__ ((visibility("default"))) +# else +# define SWIGEXPORT +# endif +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) +# define _CRT_SECURE_NO_DEPRECATE +#endif + +/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ +#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) +# define _SCL_SECURE_NO_DEPRECATE +#endif + + + +#if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG) +/* Use debug wrappers with the Python release dll */ +# undef _DEBUG +# include +# define _DEBUG +#else +# include +#endif + +/* ----------------------------------------------------------------------------- + * swigrun.swg + * + * This file contains generic C API SWIG runtime support for pointer + * type checking. + * ----------------------------------------------------------------------------- */ + +/* This should only be incremented when either the layout of swig_type_info changes, + or for whatever reason, the runtime changes incompatibly */ +#define SWIG_RUNTIME_VERSION "4" + +/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ +#ifdef SWIG_TYPE_TABLE +# define SWIG_QUOTE_STRING(x) #x +# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) +# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) +#else +# define SWIG_TYPE_TABLE_NAME +#endif + +/* + You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for + creating a static or dynamic library from the SWIG runtime code. + In 99.9% of the cases, SWIG just needs to declare them as 'static'. + + But only do this if strictly necessary, ie, if you have problems + with your compiler or suchlike. +*/ + +#ifndef SWIGRUNTIME +# define SWIGRUNTIME SWIGINTERN +#endif + +#ifndef SWIGRUNTIMEINLINE +# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE +#endif + +/* Generic buffer size */ +#ifndef SWIG_BUFFER_SIZE +# define SWIG_BUFFER_SIZE 1024 +#endif + +/* Flags for pointer conversions */ +#define SWIG_POINTER_DISOWN 0x1 +#define SWIG_CAST_NEW_MEMORY 0x2 + +/* Flags for new pointer objects */ +#define SWIG_POINTER_OWN 0x1 + + +/* + Flags/methods for returning states. + + The SWIG conversion methods, as ConvertPtr, return an integer + that tells if the conversion was successful or not. And if not, + an error code can be returned (see swigerrors.swg for the codes). + + Use the following macros/flags to set or process the returning + states. + + In old versions of SWIG, code such as the following was usually written: + + if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { + // success code + } else { + //fail code + } + + Now you can be more explicit: + + int res = SWIG_ConvertPtr(obj,vptr,ty.flags); + if (SWIG_IsOK(res)) { + // success code + } else { + // fail code + } + + which is the same really, but now you can also do + + Type *ptr; + int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); + if (SWIG_IsOK(res)) { + // success code + if (SWIG_IsNewObj(res) { + ... + delete *ptr; + } else { + ... + } + } else { + // fail code + } + + I.e., now SWIG_ConvertPtr can return new objects and you can + identify the case and take care of the deallocation. Of course that + also requires SWIG_ConvertPtr to return new result values, such as + + int SWIG_ConvertPtr(obj, ptr,...) { + if () { + if () { + *ptr = ; + return SWIG_NEWOBJ; + } else { + *ptr = ; + return SWIG_OLDOBJ; + } + } else { + return SWIG_BADOBJ; + } + } + + Of course, returning the plain '0(success)/-1(fail)' still works, but you can be + more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the + SWIG errors code. + + Finally, if the SWIG_CASTRANK_MODE is enabled, the result code + allows to return the 'cast rank', for example, if you have this + + int food(double) + int fooi(int); + + and you call + + food(1) // cast rank '1' (1 -> 1.0) + fooi(1) // cast rank '0' + + just use the SWIG_AddCast()/SWIG_CheckState() +*/ + +#define SWIG_OK (0) +#define SWIG_ERROR (-1) +#define SWIG_IsOK(r) (r >= 0) +#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) + +/* The CastRankLimit says how many bits are used for the cast rank */ +#define SWIG_CASTRANKLIMIT (1 << 8) +/* The NewMask denotes the object was created (using new/malloc) */ +#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1) +/* The TmpMask is for in/out typemaps that use temporal objects */ +#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1) +/* Simple returning values */ +#define SWIG_BADOBJ (SWIG_ERROR) +#define SWIG_OLDOBJ (SWIG_OK) +#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK) +#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK) +/* Check, add and del mask methods */ +#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r) +#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r) +#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK)) +#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r) +#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) +#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) + +/* Cast-Rank Mode */ +#if defined(SWIG_CASTRANK_MODE) +# ifndef SWIG_TypeRank +# define SWIG_TypeRank unsigned long +# endif +# ifndef SWIG_MAXCASTRANK /* Default cast allowed */ +# define SWIG_MAXCASTRANK (2) +# endif +# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) +# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) +SWIGINTERNINLINE int SWIG_AddCast(int r) { + return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; +} +SWIGINTERNINLINE int SWIG_CheckState(int r) { + return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; +} +#else /* no cast-rank mode */ +# define SWIG_AddCast(r) (r) +# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) +#endif + + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void *(*swig_converter_func)(void *, int *); +typedef struct swig_type_info *(*swig_dycast_func)(void **); + +/* Structure to store information on one type */ +typedef struct swig_type_info { + const char *name; /* mangled name of this type */ + const char *str; /* human readable name of this type */ + swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ + struct swig_cast_info *cast; /* linked list of types that can cast into this type */ + void *clientdata; /* language specific type data */ + int owndata; /* flag if the structure owns the clientdata */ +} swig_type_info; + +/* Structure to store a type and conversion function used for casting */ +typedef struct swig_cast_info { + swig_type_info *type; /* pointer to type that is equivalent to this type */ + swig_converter_func converter; /* function to cast the void pointers */ + struct swig_cast_info *next; /* pointer to next cast in linked list */ + struct swig_cast_info *prev; /* pointer to the previous cast */ +} swig_cast_info; + +/* Structure used to store module information + * Each module generates one structure like this, and the runtime collects + * all of these structures and stores them in a circularly linked list.*/ +typedef struct swig_module_info { + swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ + size_t size; /* Number of types in this module */ + struct swig_module_info *next; /* Pointer to next element in circularly linked list */ + swig_type_info **type_initial; /* Array of initially generated type structures */ + swig_cast_info **cast_initial; /* Array of initially generated casting structures */ + void *clientdata; /* Language specific module data */ +} swig_module_info; + +/* + Compare two type names skipping the space characters, therefore + "char*" == "char *" and "Class" == "Class", etc. + + Return 0 when the two name types are equivalent, as in + strncmp, but skipping ' '. +*/ +SWIGRUNTIME int +SWIG_TypeNameComp(const char *f1, const char *l1, + const char *f2, const char *l2) { + for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { + while ((*f1 == ' ') && (f1 != l1)) ++f1; + while ((*f2 == ' ') && (f2 != l2)) ++f2; + if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; + } + return (int)((l1 - f1) - (l2 - f2)); +} + +/* + Check type equivalence in a name list like ||... + Return 0 if equal, -1 if nb < tb, 1 if nb > tb +*/ +SWIGRUNTIME int +SWIG_TypeCmp(const char *nb, const char *tb) { + int equiv = 1; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (equiv != 0 && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = SWIG_TypeNameComp(nb, ne, tb, te); + if (*ne) ++ne; + } + return equiv; +} + +/* + Check type equivalence in a name list like ||... + Return 0 if not equal, 1 if equal +*/ +SWIGRUNTIME int +SWIG_TypeEquiv(const char *nb, const char *tb) { + return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0; +} + +/* + Check the typename +*/ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheck(const char *c, swig_type_info *ty) { + if (ty) { + swig_cast_info *iter = ty->cast; + while (iter) { + if (strcmp(iter->type->name, c) == 0) { + if (iter == ty->cast) + return iter; + /* Move iter to the top of the linked list */ + iter->prev->next = iter->next; + if (iter->next) + iter->next->prev = iter->prev; + iter->next = ty->cast; + iter->prev = 0; + if (ty->cast) ty->cast->prev = iter; + ty->cast = iter; + return iter; + } + iter = iter->next; + } + } + return 0; +} + +/* + Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison +*/ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) { + if (ty) { + swig_cast_info *iter = ty->cast; + while (iter) { + if (iter->type == from) { + if (iter == ty->cast) + return iter; + /* Move iter to the top of the linked list */ + iter->prev->next = iter->next; + if (iter->next) + iter->next->prev = iter->prev; + iter->next = ty->cast; + iter->prev = 0; + if (ty->cast) ty->cast->prev = iter; + ty->cast = iter; + return iter; + } + iter = iter->next; + } + } + return 0; +} + +/* + Cast a pointer up an inheritance hierarchy +*/ +SWIGRUNTIMEINLINE void * +SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { + return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); +} + +/* + Dynamic pointer casting. Down an inheritance hierarchy +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { + swig_type_info *lastty = ty; + if (!ty || !ty->dcast) return ty; + while (ty && (ty->dcast)) { + ty = (*ty->dcast)(ptr); + if (ty) lastty = ty; + } + return lastty; +} + +/* + Return the name associated with this type +*/ +SWIGRUNTIMEINLINE const char * +SWIG_TypeName(const swig_type_info *ty) { + return ty->name; +} + +/* + Return the pretty name associated with this type, + that is an unmangled type name in a form presentable to the user. +*/ +SWIGRUNTIME const char * +SWIG_TypePrettyName(const swig_type_info *type) { + /* The "str" field contains the equivalent pretty names of the + type, separated by vertical-bar characters. We choose + to print the last name, as it is often (?) the most + specific. */ + if (!type) return NULL; + if (type->str != NULL) { + const char *last_name = type->str; + const char *s; + for (s = type->str; *s; s++) + if (*s == '|') last_name = s+1; + return last_name; + } + else + return type->name; +} + +/* + Set the clientdata field for a type +*/ +SWIGRUNTIME void +SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { + swig_cast_info *cast = ti->cast; + /* if (ti->clientdata == clientdata) return; */ + ti->clientdata = clientdata; + + while (cast) { + if (!cast->converter) { + swig_type_info *tc = cast->type; + if (!tc->clientdata) { + SWIG_TypeClientData(tc, clientdata); + } + } + cast = cast->next; + } +} +SWIGRUNTIME void +SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { + SWIG_TypeClientData(ti, clientdata); + ti->owndata = 1; +} + +/* + Search for a swig_type_info structure only by mangled name + Search is a O(log #types) + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_MangledTypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + swig_module_info *iter = start; + do { + if (iter->size) { + size_t l = 0; + size_t r = iter->size - 1; + do { + /* since l+r >= 0, we can (>> 1) instead (/ 2) */ + size_t i = (l + r) >> 1; + const char *iname = iter->types[i]->name; + if (iname) { + int compare = strcmp(name, iname); + if (compare == 0) { + return iter->types[i]; + } else if (compare < 0) { + if (i) { + r = i - 1; + } else { + break; + } + } else if (compare > 0) { + l = i + 1; + } + } else { + break; /* should never happen */ + } + } while (l <= r); + } + iter = iter->next; + } while (iter != end); + return 0; +} + +/* + Search for a swig_type_info structure for either a mangled name or a human readable name. + It first searches the mangled names of the types, which is a O(log #types) + If a type is not found it then searches the human readable names, which is O(#types). + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + /* STEP 1: Search the name field using binary search */ + swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); + if (ret) { + return ret; + } else { + /* STEP 2: If the type hasn't been found, do a complete search + of the str field (the human readable name) */ + swig_module_info *iter = start; + do { + size_t i = 0; + for (; i < iter->size; ++i) { + if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) + return iter->types[i]; + } + iter = iter->next; + } while (iter != end); + } + + /* neither found a match */ + return 0; +} + +/* + Pack binary data into a string +*/ +SWIGRUNTIME char * +SWIG_PackData(char *c, void *ptr, size_t sz) { + static const char hex[17] = "0123456789abcdef"; + const unsigned char *u = (unsigned char *) ptr; + const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + unsigned char uu = *u; + *(c++) = hex[(uu & 0xf0) >> 4]; + *(c++) = hex[uu & 0xf]; + } + return c; +} + +/* + Unpack binary data from a string +*/ +SWIGRUNTIME const char * +SWIG_UnpackData(const char *c, void *ptr, size_t sz) { + unsigned char *u = (unsigned char *) ptr; + const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + char d = *(c++); + unsigned char uu; + if ((d >= '0') && (d <= '9')) + uu = ((d - '0') << 4); + else if ((d >= 'a') && (d <= 'f')) + uu = ((d - ('a'-10)) << 4); + else + return (char *) 0; + d = *(c++); + if ((d >= '0') && (d <= '9')) + uu |= (d - '0'); + else if ((d >= 'a') && (d <= 'f')) + uu |= (d - ('a'-10)); + else + return (char *) 0; + *u = uu; + } + return c; +} + +/* + Pack 'void *' into a string buffer. +*/ +SWIGRUNTIME char * +SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { + char *r = buff; + if ((2*sizeof(void *) + 2) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,&ptr,sizeof(void *)); + if (strlen(name) + 1 > (bsz - (r - buff))) return 0; + strcpy(r,name); + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + *ptr = (void *) 0; + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sizeof(void *)); +} + +SWIGRUNTIME char * +SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { + char *r = buff; + size_t lname = (name ? strlen(name) : 0); + if ((2*sz + 2 + lname) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + if (lname) { + strncpy(r,name,lname+1); + } else { + *r = 0; + } + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + memset(ptr,0,sz); + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sz); +} + +#ifdef __cplusplus +} +#endif + +/* Errors in SWIG */ +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 +#define SWIG_SystemError -10 +#define SWIG_AttributeError -11 +#define SWIG_MemoryError -12 +#define SWIG_NullReferenceError -13 + + + +/* Compatibility macros for Python 3 */ +#if PY_VERSION_HEX >= 0x03000000 + +#define PyClass_Check(obj) PyObject_IsInstance(obj, (PyObject *)&PyType_Type) +#define PyInt_Check(x) PyLong_Check(x) +#define PyInt_AsLong(x) PyLong_AsLong(x) +#define PyInt_FromLong(x) PyLong_FromLong(x) +#define PyInt_FromSize_t(x) PyLong_FromSize_t(x) +#define PyString_Check(name) PyBytes_Check(name) +#define PyString_FromString(x) PyUnicode_FromString(x) +#define PyString_Format(fmt, args) PyUnicode_Format(fmt, args) +#define PyString_AsString(str) PyBytes_AsString(str) +#define PyString_Size(str) PyBytes_Size(str) +#define PyString_InternFromString(key) PyUnicode_InternFromString(key) +#define Py_TPFLAGS_HAVE_CLASS Py_TPFLAGS_BASETYPE +#define PyString_AS_STRING(x) PyUnicode_AS_STRING(x) +#define _PyLong_FromSsize_t(x) PyLong_FromSsize_t(x) + +#endif + +#ifndef Py_TYPE +# define Py_TYPE(op) ((op)->ob_type) +#endif + +/* SWIG APIs for compatibility of both Python 2 & 3 */ + +#if PY_VERSION_HEX >= 0x03000000 +# define SWIG_Python_str_FromFormat PyUnicode_FromFormat +#else +# define SWIG_Python_str_FromFormat PyString_FromFormat +#endif + + +/* Warning: This function will allocate a new string in Python 3, + * so please call SWIG_Python_str_DelForPy3(x) to free the space. + */ +SWIGINTERN char* +SWIG_Python_str_AsChar(PyObject *str) +{ +#if PY_VERSION_HEX >= 0x03000000 + char *cstr; + char *newstr; + Py_ssize_t len; + str = PyUnicode_AsUTF8String(str); + PyBytes_AsStringAndSize(str, &cstr, &len); + newstr = (char *) malloc(len+1); + memcpy(newstr, cstr, len+1); + Py_XDECREF(str); + return newstr; +#else + return PyString_AsString(str); +#endif +} + +#if PY_VERSION_HEX >= 0x03000000 +# define SWIG_Python_str_DelForPy3(x) free( (void*) (x) ) +#else +# define SWIG_Python_str_DelForPy3(x) +#endif + + +SWIGINTERN PyObject* +SWIG_Python_str_FromChar(const char *c) +{ +#if PY_VERSION_HEX >= 0x03000000 + return PyUnicode_FromString(c); +#else + return PyString_FromString(c); +#endif +} + +/* Add PyOS_snprintf for old Pythons */ +#if PY_VERSION_HEX < 0x02020000 +# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) +# define PyOS_snprintf _snprintf +# else +# define PyOS_snprintf snprintf +# endif +#endif + +/* A crude PyString_FromFormat implementation for old Pythons */ +#if PY_VERSION_HEX < 0x02020000 + +#ifndef SWIG_PYBUFFER_SIZE +# define SWIG_PYBUFFER_SIZE 1024 +#endif + +static PyObject * +PyString_FromFormat(const char *fmt, ...) { + va_list ap; + char buf[SWIG_PYBUFFER_SIZE * 2]; + int res; + va_start(ap, fmt); + res = vsnprintf(buf, sizeof(buf), fmt, ap); + va_end(ap); + return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf); +} +#endif + +/* Add PyObject_Del for old Pythons */ +#if PY_VERSION_HEX < 0x01060000 +# define PyObject_Del(op) PyMem_DEL((op)) +#endif +#ifndef PyObject_DEL +# define PyObject_DEL PyObject_Del +#endif + +/* A crude PyExc_StopIteration exception for old Pythons */ +#if PY_VERSION_HEX < 0x02020000 +# ifndef PyExc_StopIteration +# define PyExc_StopIteration PyExc_RuntimeError +# endif +# ifndef PyObject_GenericGetAttr +# define PyObject_GenericGetAttr 0 +# endif +#endif + +/* Py_NotImplemented is defined in 2.1 and up. */ +#if PY_VERSION_HEX < 0x02010000 +# ifndef Py_NotImplemented +# define Py_NotImplemented PyExc_RuntimeError +# endif +#endif + +/* A crude PyString_AsStringAndSize implementation for old Pythons */ +#if PY_VERSION_HEX < 0x02010000 +# ifndef PyString_AsStringAndSize +# define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;} +# endif +#endif + +/* PySequence_Size for old Pythons */ +#if PY_VERSION_HEX < 0x02000000 +# ifndef PySequence_Size +# define PySequence_Size PySequence_Length +# endif +#endif + +/* PyBool_FromLong for old Pythons */ +#if PY_VERSION_HEX < 0x02030000 +static +PyObject *PyBool_FromLong(long ok) +{ + PyObject *result = ok ? Py_True : Py_False; + Py_INCREF(result); + return result; +} +#endif + +/* Py_ssize_t for old Pythons */ +/* This code is as recommended by: */ +/* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */ +#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) +typedef int Py_ssize_t; +# define PY_SSIZE_T_MAX INT_MAX +# define PY_SSIZE_T_MIN INT_MIN +typedef inquiry lenfunc; +typedef intargfunc ssizeargfunc; +typedef intintargfunc ssizessizeargfunc; +typedef intobjargproc ssizeobjargproc; +typedef intintobjargproc ssizessizeobjargproc; +typedef getreadbufferproc readbufferproc; +typedef getwritebufferproc writebufferproc; +typedef getsegcountproc segcountproc; +typedef getcharbufferproc charbufferproc; +static long PyNumber_AsSsize_t (PyObject *x, void *SWIGUNUSEDPARM(exc)) +{ + long result = 0; + PyObject *i = PyNumber_Int(x); + if (i) { + result = PyInt_AsLong(i); + Py_DECREF(i); + } + return result; +} +#endif + +#if PY_VERSION_HEX < 0x02050000 +#define PyInt_FromSize_t(x) PyInt_FromLong((long)x) +#endif + +#if PY_VERSION_HEX < 0x02040000 +#define Py_VISIT(op) \ + do { \ + if (op) { \ + int vret = visit((op), arg); \ + if (vret) \ + return vret; \ + } \ + } while (0) +#endif + +#if PY_VERSION_HEX < 0x02030000 +typedef struct { + PyTypeObject type; + PyNumberMethods as_number; + PyMappingMethods as_mapping; + PySequenceMethods as_sequence; + PyBufferProcs as_buffer; + PyObject *name, *slots; +} PyHeapTypeObject; +#endif + +#if PY_VERSION_HEX < 0x02030000 +typedef destructor freefunc; +#endif + +#if ((PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION > 6) || \ + (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION > 0) || \ + (PY_MAJOR_VERSION > 3)) +# define SWIGPY_USE_CAPSULE +# define SWIGPY_CAPSULE_NAME ((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME) +#endif + +#if PY_VERSION_HEX < 0x03020000 +#define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type) +#define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name) +#endif + +/* ----------------------------------------------------------------------------- + * error manipulation + * ----------------------------------------------------------------------------- */ + +SWIGRUNTIME PyObject* +SWIG_Python_ErrorType(int code) { + PyObject* type = 0; + switch(code) { + case SWIG_MemoryError: + type = PyExc_MemoryError; + break; + case SWIG_IOError: + type = PyExc_IOError; + break; + case SWIG_RuntimeError: + type = PyExc_RuntimeError; + break; + case SWIG_IndexError: + type = PyExc_IndexError; + break; + case SWIG_TypeError: + type = PyExc_TypeError; + break; + case SWIG_DivisionByZero: + type = PyExc_ZeroDivisionError; + break; + case SWIG_OverflowError: + type = PyExc_OverflowError; + break; + case SWIG_SyntaxError: + type = PyExc_SyntaxError; + break; + case SWIG_ValueError: + type = PyExc_ValueError; + break; + case SWIG_SystemError: + type = PyExc_SystemError; + break; + case SWIG_AttributeError: + type = PyExc_AttributeError; + break; + default: + type = PyExc_RuntimeError; + } + return type; +} + + +SWIGRUNTIME void +SWIG_Python_AddErrorMsg(const char* mesg) +{ + PyObject *type = 0; + PyObject *value = 0; + PyObject *traceback = 0; + + if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback); + if (value) { + char *tmp; + PyObject *old_str = PyObject_Str(value); + PyErr_Clear(); + Py_XINCREF(type); + + PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); + SWIG_Python_str_DelForPy3(tmp); + Py_DECREF(old_str); + Py_DECREF(value); + } else { + PyErr_SetString(PyExc_RuntimeError, mesg); + } +} + +#if defined(SWIG_PYTHON_NO_THREADS) +# if defined(SWIG_PYTHON_THREADS) +# undef SWIG_PYTHON_THREADS +# endif +#endif +#if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */ +# if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL) +# if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */ +# define SWIG_PYTHON_USE_GIL +# endif +# endif +# if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */ +# ifndef SWIG_PYTHON_INITIALIZE_THREADS +# define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads() +# endif +# ifdef __cplusplus /* C++ code */ + class SWIG_Python_Thread_Block { + bool status; + PyGILState_STATE state; + public: + void end() { if (status) { PyGILState_Release(state); status = false;} } + SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {} + ~SWIG_Python_Thread_Block() { end(); } + }; + class SWIG_Python_Thread_Allow { + bool status; + PyThreadState *save; + public: + void end() { if (status) { PyEval_RestoreThread(save); status = false; }} + SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {} + ~SWIG_Python_Thread_Allow() { end(); } + }; +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block +# define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end() +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow +# define SWIG_PYTHON_THREAD_END_ALLOW _swig_thread_allow.end() +# else /* C code */ +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK PyGILState_STATE _swig_thread_block = PyGILState_Ensure() +# define SWIG_PYTHON_THREAD_END_BLOCK PyGILState_Release(_swig_thread_block) +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW PyThreadState *_swig_thread_allow = PyEval_SaveThread() +# define SWIG_PYTHON_THREAD_END_ALLOW PyEval_RestoreThread(_swig_thread_allow) +# endif +# else /* Old thread way, not implemented, user must provide it */ +# if !defined(SWIG_PYTHON_INITIALIZE_THREADS) +# define SWIG_PYTHON_INITIALIZE_THREADS +# endif +# if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK) +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK +# endif +# if !defined(SWIG_PYTHON_THREAD_END_BLOCK) +# define SWIG_PYTHON_THREAD_END_BLOCK +# endif +# if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW) +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW +# endif +# if !defined(SWIG_PYTHON_THREAD_END_ALLOW) +# define SWIG_PYTHON_THREAD_END_ALLOW +# endif +# endif +#else /* No thread support */ +# define SWIG_PYTHON_INITIALIZE_THREADS +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK +# define SWIG_PYTHON_THREAD_END_BLOCK +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW +# define SWIG_PYTHON_THREAD_END_ALLOW +#endif + +/* ----------------------------------------------------------------------------- + * Python API portion that goes into the runtime + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* ----------------------------------------------------------------------------- + * Constant declarations + * ----------------------------------------------------------------------------- */ + +/* Constant Types */ +#define SWIG_PY_POINTER 4 +#define SWIG_PY_BINARY 5 + +/* Constant information structure */ +typedef struct swig_const_info { + int type; + char *name; + long lvalue; + double dvalue; + void *pvalue; + swig_type_info **ptype; +} swig_const_info; + + +/* ----------------------------------------------------------------------------- + * Wrapper of PyInstanceMethod_New() used in Python 3 + * It is exported to the generated module, used for -fastproxy + * ----------------------------------------------------------------------------- */ +#if PY_VERSION_HEX >= 0x03000000 +SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) +{ + return PyInstanceMethod_New(func); +} +#else +SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *SWIGUNUSEDPARM(func)) +{ + return NULL; +} +#endif + +#ifdef __cplusplus +} +#endif + + +/* ----------------------------------------------------------------------------- + * pyrun.swg + * + * This file contains the runtime support for Python modules + * and includes code for managing global variables and pointer + * type checking. + * + * ----------------------------------------------------------------------------- */ + +/* Common SWIG API */ + +/* for raw pointers */ +#define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0) +#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags) +#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own) + +#ifdef SWIGPYTHON_BUILTIN +#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(self, ptr, type, flags) +#else +#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags) +#endif + +#define SWIG_InternalNewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags) + +#define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty) +#define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src) +#define swig_owntype int + +/* for raw packed data */ +#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) +#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) + +/* for class or struct pointers */ +#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) +#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) + +/* for C or C++ function pointers */ +#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type) +#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(NULL, ptr, type, 0) + +/* for C++ member pointers, ie, member methods */ +#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) +#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) + + +/* Runtime API */ + +#define SWIG_GetModule(clientdata) SWIG_Python_GetModule(clientdata) +#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) +#define SWIG_NewClientData(obj) SwigPyClientData_New(obj) + +#define SWIG_SetErrorObj SWIG_Python_SetErrorObj +#define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg +#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code) +#define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) +#define SWIG_fail goto fail + + +/* Runtime API implementation */ + +/* Error manipulation */ + +SWIGINTERN void +SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyErr_SetObject(errtype, obj); + Py_DECREF(obj); + SWIG_PYTHON_THREAD_END_BLOCK; +} + +SWIGINTERN void +SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyErr_SetString(errtype, msg); + SWIG_PYTHON_THREAD_END_BLOCK; +} + +#define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj) + +/* Set a constant value */ + +#if defined(SWIGPYTHON_BUILTIN) + +SWIGINTERN void +SwigPyBuiltin_AddPublicSymbol(PyObject *seq, const char *key) { + PyObject *s = PyString_InternFromString(key); + PyList_Append(seq, s); + Py_DECREF(s); +} + +SWIGINTERN void +SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *name, PyObject *obj) { +#if PY_VERSION_HEX < 0x02030000 + PyDict_SetItemString(d, (char *)name, obj); +#else + PyDict_SetItemString(d, name, obj); +#endif + Py_DECREF(obj); + if (public_interface) + SwigPyBuiltin_AddPublicSymbol(public_interface, name); +} + +#else + +SWIGINTERN void +SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { +#if PY_VERSION_HEX < 0x02030000 + PyDict_SetItemString(d, (char *)name, obj); +#else + PyDict_SetItemString(d, name, obj); +#endif + Py_DECREF(obj); +} + +#endif + +/* Append a value to the result obj */ + +SWIGINTERN PyObject* +SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { +#if !defined(SWIG_PYTHON_OUTPUT_TUPLE) + if (!result) { + result = obj; + } else if (result == Py_None) { + Py_DECREF(result); + result = obj; + } else { + if (!PyList_Check(result)) { + PyObject *o2 = result; + result = PyList_New(1); + PyList_SetItem(result, 0, o2); + } + PyList_Append(result,obj); + Py_DECREF(obj); + } + return result; +#else + PyObject* o2; + PyObject* o3; + if (!result) { + result = obj; + } else if (result == Py_None) { + Py_DECREF(result); + result = obj; + } else { + if (!PyTuple_Check(result)) { + o2 = result; + result = PyTuple_New(1); + PyTuple_SET_ITEM(result, 0, o2); + } + o3 = PyTuple_New(1); + PyTuple_SET_ITEM(o3, 0, obj); + o2 = result; + result = PySequence_Concat(o2, o3); + Py_DECREF(o2); + Py_DECREF(o3); + } + return result; +#endif +} + +/* Unpack the argument tuple */ + +SWIGINTERN int +SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs) +{ + if (!args) { + if (!min && !max) { + return 1; + } else { + PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none", + name, (min == max ? "" : "at least "), (int)min); + return 0; + } + } + if (!PyTuple_Check(args)) { + if (min <= 1 && max >= 1) { + int i; + objs[0] = args; + for (i = 1; i < max; ++i) { + objs[i] = 0; + } + return 2; + } + PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple"); + return 0; + } else { + Py_ssize_t l = PyTuple_GET_SIZE(args); + if (l < min) { + PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", + name, (min == max ? "" : "at least "), (int)min, (int)l); + return 0; + } else if (l > max) { + PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", + name, (min == max ? "" : "at most "), (int)max, (int)l); + return 0; + } else { + int i; + for (i = 0; i < l; ++i) { + objs[i] = PyTuple_GET_ITEM(args, i); + } + for (; l < max; ++l) { + objs[l] = 0; + } + return i + 1; + } + } +} + +/* A functor is a function object with one single object argument */ +#if PY_VERSION_HEX >= 0x02020000 +#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL); +#else +#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj); +#endif + +/* + Helper for static pointer initialization for both C and C++ code, for example + static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...); +*/ +#ifdef __cplusplus +#define SWIG_STATIC_POINTER(var) var +#else +#define SWIG_STATIC_POINTER(var) var = 0; if (!var) var +#endif + +/* ----------------------------------------------------------------------------- + * Pointer declarations + * ----------------------------------------------------------------------------- */ + +/* Flags for new pointer objects */ +#define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1) +#define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN) + +#define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1) + +#define SWIG_BUILTIN_TP_INIT (SWIG_POINTER_OWN << 2) +#define SWIG_BUILTIN_INIT (SWIG_BUILTIN_TP_INIT | SWIG_POINTER_OWN) + +#ifdef __cplusplus +extern "C" { +#endif + +/* How to access Py_None */ +#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# ifndef SWIG_PYTHON_NO_BUILD_NONE +# ifndef SWIG_PYTHON_BUILD_NONE +# define SWIG_PYTHON_BUILD_NONE +# endif +# endif +#endif + +#ifdef SWIG_PYTHON_BUILD_NONE +# ifdef Py_None +# undef Py_None +# define Py_None SWIG_Py_None() +# endif +SWIGRUNTIMEINLINE PyObject * +_SWIG_Py_None(void) +{ + PyObject *none = Py_BuildValue((char*)""); + Py_DECREF(none); + return none; +} +SWIGRUNTIME PyObject * +SWIG_Py_None(void) +{ + static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None(); + return none; +} +#endif + +/* The python void return value */ + +SWIGRUNTIMEINLINE PyObject * +SWIG_Py_Void(void) +{ + PyObject *none = Py_None; + Py_INCREF(none); + return none; +} + +/* SwigPyClientData */ + +typedef struct { + PyObject *klass; + PyObject *newraw; + PyObject *newargs; + PyObject *destroy; + int delargs; + int implicitconv; + PyTypeObject *pytype; +} SwigPyClientData; + +SWIGRUNTIMEINLINE int +SWIG_Python_CheckImplicit(swig_type_info *ty) +{ + SwigPyClientData *data = (SwigPyClientData *)ty->clientdata; + return data ? data->implicitconv : 0; +} + +SWIGRUNTIMEINLINE PyObject * +SWIG_Python_ExceptionType(swig_type_info *desc) { + SwigPyClientData *data = desc ? (SwigPyClientData *) desc->clientdata : 0; + PyObject *klass = data ? data->klass : 0; + return (klass ? klass : PyExc_RuntimeError); +} + + +SWIGRUNTIME SwigPyClientData * +SwigPyClientData_New(PyObject* obj) +{ + if (!obj) { + return 0; + } else { + SwigPyClientData *data = (SwigPyClientData *)malloc(sizeof(SwigPyClientData)); + /* the klass element */ + data->klass = obj; + Py_INCREF(data->klass); + /* the newraw method and newargs arguments used to create a new raw instance */ + if (PyClass_Check(obj)) { + data->newraw = 0; + data->newargs = obj; + Py_INCREF(obj); + } else { +#if (PY_VERSION_HEX < 0x02020000) + data->newraw = 0; +#else + data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__"); +#endif + if (data->newraw) { + Py_INCREF(data->newraw); + data->newargs = PyTuple_New(1); + PyTuple_SetItem(data->newargs, 0, obj); + } else { + data->newargs = obj; + } + Py_INCREF(data->newargs); + } + /* the destroy method, aka as the C++ delete method */ + data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__"); + if (PyErr_Occurred()) { + PyErr_Clear(); + data->destroy = 0; + } + if (data->destroy) { + int flags; + Py_INCREF(data->destroy); + flags = PyCFunction_GET_FLAGS(data->destroy); +#ifdef METH_O + data->delargs = !(flags & (METH_O)); +#else + data->delargs = 0; +#endif + } else { + data->delargs = 0; + } + data->implicitconv = 0; + data->pytype = 0; + return data; + } +} + +SWIGRUNTIME void +SwigPyClientData_Del(SwigPyClientData *data) { + Py_XDECREF(data->newraw); + Py_XDECREF(data->newargs); + Py_XDECREF(data->destroy); +} + +/* =============== SwigPyObject =====================*/ + +typedef struct { + PyObject_HEAD + void *ptr; + swig_type_info *ty; + int own; + PyObject *next; +#ifdef SWIGPYTHON_BUILTIN + PyObject *dict; +#endif +} SwigPyObject; + +SWIGRUNTIME PyObject * +SwigPyObject_long(SwigPyObject *v) +{ + return PyLong_FromVoidPtr(v->ptr); +} + +SWIGRUNTIME PyObject * +SwigPyObject_format(const char* fmt, SwigPyObject *v) +{ + PyObject *res = NULL; + PyObject *args = PyTuple_New(1); + if (args) { + if (PyTuple_SetItem(args, 0, SwigPyObject_long(v)) == 0) { + PyObject *ofmt = SWIG_Python_str_FromChar(fmt); + if (ofmt) { +#if PY_VERSION_HEX >= 0x03000000 + res = PyUnicode_Format(ofmt,args); +#else + res = PyString_Format(ofmt,args); +#endif + Py_DECREF(ofmt); + } + Py_DECREF(args); + } + } + return res; +} + +SWIGRUNTIME PyObject * +SwigPyObject_oct(SwigPyObject *v) +{ + return SwigPyObject_format("%o",v); +} + +SWIGRUNTIME PyObject * +SwigPyObject_hex(SwigPyObject *v) +{ + return SwigPyObject_format("%x",v); +} + +SWIGRUNTIME PyObject * +#ifdef METH_NOARGS +SwigPyObject_repr(SwigPyObject *v) +#else +SwigPyObject_repr(SwigPyObject *v, PyObject *args) +#endif +{ + const char *name = SWIG_TypePrettyName(v->ty); + PyObject *repr = SWIG_Python_str_FromFormat("", (name ? name : "unknown"), (void *)v); + if (v->next) { +# ifdef METH_NOARGS + PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next); +# else + PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next, args); +# endif +# if PY_VERSION_HEX >= 0x03000000 + PyObject *joined = PyUnicode_Concat(repr, nrep); + Py_DecRef(repr); + Py_DecRef(nrep); + repr = joined; +# else + PyString_ConcatAndDel(&repr,nrep); +# endif + } + return repr; +} + +SWIGRUNTIME int +SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w) +{ + void *i = v->ptr; + void *j = w->ptr; + return (i < j) ? -1 : ((i > j) ? 1 : 0); +} + +/* Added for Python 3.x, would it also be useful for Python 2.x? */ +SWIGRUNTIME PyObject* +SwigPyObject_richcompare(SwigPyObject *v, SwigPyObject *w, int op) +{ + PyObject* res; + if( op != Py_EQ && op != Py_NE ) { + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; + } + res = PyBool_FromLong( (SwigPyObject_compare(v, w)==0) == (op == Py_EQ) ? 1 : 0); + return res; +} + + +SWIGRUNTIME PyTypeObject* SwigPyObject_TypeOnce(void); + +#ifdef SWIGPYTHON_BUILTIN +static swig_type_info *SwigPyObject_stype = 0; +SWIGRUNTIME PyTypeObject* +SwigPyObject_type(void) { + SwigPyClientData *cd; + assert(SwigPyObject_stype); + cd = (SwigPyClientData*) SwigPyObject_stype->clientdata; + assert(cd); + assert(cd->pytype); + return cd->pytype; +} +#else +SWIGRUNTIME PyTypeObject* +SwigPyObject_type(void) { + static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyObject_TypeOnce(); + return type; +} +#endif + +SWIGRUNTIMEINLINE int +SwigPyObject_Check(PyObject *op) { +#ifdef SWIGPYTHON_BUILTIN + PyTypeObject *target_tp = SwigPyObject_type(); + if (PyType_IsSubtype(op->ob_type, target_tp)) + return 1; + return (strcmp(op->ob_type->tp_name, "SwigPyObject") == 0); +#else + return (Py_TYPE(op) == SwigPyObject_type()) + || (strcmp(Py_TYPE(op)->tp_name,"SwigPyObject") == 0); +#endif +} + +SWIGRUNTIME PyObject * +SwigPyObject_New(void *ptr, swig_type_info *ty, int own); + +SWIGRUNTIME void +SwigPyObject_dealloc(PyObject *v) +{ + SwigPyObject *sobj = (SwigPyObject *) v; + PyObject *next = sobj->next; + if (sobj->own == SWIG_POINTER_OWN) { + swig_type_info *ty = sobj->ty; + SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; + PyObject *destroy = data ? data->destroy : 0; + if (destroy) { + /* destroy is always a VARARGS method */ + PyObject *res; + if (data->delargs) { + /* we need to create a temporary object to carry the destroy operation */ + PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0); + res = SWIG_Python_CallFunctor(destroy, tmp); + Py_DECREF(tmp); + } else { + PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); + PyObject *mself = PyCFunction_GET_SELF(destroy); + res = ((*meth)(mself, v)); + } + Py_XDECREF(res); + } +#if !defined(SWIG_PYTHON_SILENT_MEMLEAK) + else { + const char *name = SWIG_TypePrettyName(ty); + printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown")); + } +#endif + } + Py_XDECREF(next); + PyObject_DEL(v); +} + +SWIGRUNTIME PyObject* +SwigPyObject_append(PyObject* v, PyObject* next) +{ + SwigPyObject *sobj = (SwigPyObject *) v; +#ifndef METH_O + PyObject *tmp = 0; + if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL; + next = tmp; +#endif + if (!SwigPyObject_Check(next)) { + return NULL; + } + sobj->next = next; + Py_INCREF(next); + return SWIG_Py_Void(); +} + +SWIGRUNTIME PyObject* +#ifdef METH_NOARGS +SwigPyObject_next(PyObject* v) +#else +SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +#endif +{ + SwigPyObject *sobj = (SwigPyObject *) v; + if (sobj->next) { + Py_INCREF(sobj->next); + return sobj->next; + } else { + return SWIG_Py_Void(); + } +} + +SWIGINTERN PyObject* +#ifdef METH_NOARGS +SwigPyObject_disown(PyObject *v) +#else +SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +#endif +{ + SwigPyObject *sobj = (SwigPyObject *)v; + sobj->own = 0; + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject* +#ifdef METH_NOARGS +SwigPyObject_acquire(PyObject *v) +#else +SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +#endif +{ + SwigPyObject *sobj = (SwigPyObject *)v; + sobj->own = SWIG_POINTER_OWN; + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject* +SwigPyObject_own(PyObject *v, PyObject *args) +{ + PyObject *val = 0; +#if (PY_VERSION_HEX < 0x02020000) + if (!PyArg_ParseTuple(args,(char *)"|O:own",&val)) +#elif (PY_VERSION_HEX < 0x02050000) + if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val)) +#else + if (!PyArg_UnpackTuple(args, "own", 0, 1, &val)) +#endif + { + return NULL; + } + else + { + SwigPyObject *sobj = (SwigPyObject *)v; + PyObject *obj = PyBool_FromLong(sobj->own); + if (val) { +#ifdef METH_NOARGS + if (PyObject_IsTrue(val)) { + SwigPyObject_acquire(v); + } else { + SwigPyObject_disown(v); + } +#else + if (PyObject_IsTrue(val)) { + SwigPyObject_acquire(v,args); + } else { + SwigPyObject_disown(v,args); + } +#endif + } + return obj; + } +} + +#ifdef METH_O +static PyMethodDef +swigobject_methods[] = { + {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"}, + {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, (char *)"acquires ownership of the pointer"}, + {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, + {(char *)"append", (PyCFunction)SwigPyObject_append, METH_O, (char *)"appends another 'this' object"}, + {(char *)"next", (PyCFunction)SwigPyObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, + {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_NOARGS, (char *)"returns object representation"}, + {0, 0, 0, 0} +}; +#else +static PyMethodDef +swigobject_methods[] = { + {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"}, + {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"}, + {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, + {(char *)"append", (PyCFunction)SwigPyObject_append, METH_VARARGS, (char *)"appends another 'this' object"}, + {(char *)"next", (PyCFunction)SwigPyObject_next, METH_VARARGS, (char *)"returns the next 'this' object"}, + {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_VARARGS, (char *)"returns object representation"}, + {0, 0, 0, 0} +}; +#endif + +#if PY_VERSION_HEX < 0x02020000 +SWIGINTERN PyObject * +SwigPyObject_getattr(SwigPyObject *sobj,char *name) +{ + return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name); +} +#endif + +SWIGRUNTIME PyTypeObject* +SwigPyObject_TypeOnce(void) { + static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer"; + + static PyNumberMethods SwigPyObject_as_number = { + (binaryfunc)0, /*nb_add*/ + (binaryfunc)0, /*nb_subtract*/ + (binaryfunc)0, /*nb_multiply*/ + /* nb_divide removed in Python 3 */ +#if PY_VERSION_HEX < 0x03000000 + (binaryfunc)0, /*nb_divide*/ +#endif + (binaryfunc)0, /*nb_remainder*/ + (binaryfunc)0, /*nb_divmod*/ + (ternaryfunc)0,/*nb_power*/ + (unaryfunc)0, /*nb_negative*/ + (unaryfunc)0, /*nb_positive*/ + (unaryfunc)0, /*nb_absolute*/ + (inquiry)0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ +#if PY_VERSION_HEX < 0x03000000 + 0, /*nb_coerce*/ +#endif + (unaryfunc)SwigPyObject_long, /*nb_int*/ +#if PY_VERSION_HEX < 0x03000000 + (unaryfunc)SwigPyObject_long, /*nb_long*/ +#else + 0, /*nb_reserved*/ +#endif + (unaryfunc)0, /*nb_float*/ +#if PY_VERSION_HEX < 0x03000000 + (unaryfunc)SwigPyObject_oct, /*nb_oct*/ + (unaryfunc)SwigPyObject_hex, /*nb_hex*/ +#endif +#if PY_VERSION_HEX >= 0x03000000 /* 3.0 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */ +#elif PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */ +#elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ +#elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */ + 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */ +#endif + }; + + static PyTypeObject swigpyobject_type; + static int type_init = 0; + if (!type_init) { + const PyTypeObject tmp = { + /* PyObject header changed in Python 3 */ +#if PY_VERSION_HEX >= 0x03000000 + PyVarObject_HEAD_INIT(NULL, 0) +#else + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ +#endif + (char *)"SwigPyObject", /* tp_name */ + sizeof(SwigPyObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)SwigPyObject_dealloc, /* tp_dealloc */ + 0, /* tp_print */ +#if PY_VERSION_HEX < 0x02020000 + (getattrfunc)SwigPyObject_getattr, /* tp_getattr */ +#else + (getattrfunc)0, /* tp_getattr */ +#endif + (setattrfunc)0, /* tp_setattr */ +#if PY_VERSION_HEX >= 0x03000000 + 0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */ +#else + (cmpfunc)SwigPyObject_compare, /* tp_compare */ +#endif + (reprfunc)SwigPyObject_repr, /* tp_repr */ + &SwigPyObject_as_number, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + (hashfunc)0, /* tp_hash */ + (ternaryfunc)0, /* tp_call */ + 0, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + swigobject_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + (richcmpfunc)SwigPyObject_richcompare,/* tp_richcompare */ + 0, /* tp_weaklistoffset */ +#if PY_VERSION_HEX >= 0x02020000 + 0, /* tp_iter */ + 0, /* tp_iternext */ + swigobject_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + 0, /* tp_free */ + 0, /* tp_is_gc */ + 0, /* tp_bases */ + 0, /* tp_mro */ + 0, /* tp_cache */ + 0, /* tp_subclasses */ + 0, /* tp_weaklist */ +#endif +#if PY_VERSION_HEX >= 0x02030000 + 0, /* tp_del */ +#endif +#if PY_VERSION_HEX >= 0x02060000 + 0, /* tp_version */ +#endif +#ifdef COUNT_ALLOCS + 0,0,0,0 /* tp_alloc -> tp_next */ +#endif + }; + swigpyobject_type = tmp; + type_init = 1; +#if PY_VERSION_HEX < 0x02020000 + swigpyobject_type.ob_type = &PyType_Type; +#else + if (PyType_Ready(&swigpyobject_type) < 0) + return NULL; +#endif + } + return &swigpyobject_type; +} + +SWIGRUNTIME PyObject * +SwigPyObject_New(void *ptr, swig_type_info *ty, int own) +{ + SwigPyObject *sobj = PyObject_NEW(SwigPyObject, SwigPyObject_type()); + if (sobj) { + sobj->ptr = ptr; + sobj->ty = ty; + sobj->own = own; + sobj->next = 0; + } + return (PyObject *)sobj; +} + +/* ----------------------------------------------------------------------------- + * Implements a simple Swig Packed type, and use it instead of string + * ----------------------------------------------------------------------------- */ + +typedef struct { + PyObject_HEAD + void *pack; + swig_type_info *ty; + size_t size; +} SwigPyPacked; + +SWIGRUNTIME int +SwigPyPacked_print(SwigPyPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags)) +{ + char result[SWIG_BUFFER_SIZE]; + fputs("pack, v->size, 0, sizeof(result))) { + fputs("at ", fp); + fputs(result, fp); + } + fputs(v->ty->name,fp); + fputs(">", fp); + return 0; +} + +SWIGRUNTIME PyObject * +SwigPyPacked_repr(SwigPyPacked *v) +{ + char result[SWIG_BUFFER_SIZE]; + if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { + return SWIG_Python_str_FromFormat("", result, v->ty->name); + } else { + return SWIG_Python_str_FromFormat("", v->ty->name); + } +} + +SWIGRUNTIME PyObject * +SwigPyPacked_str(SwigPyPacked *v) +{ + char result[SWIG_BUFFER_SIZE]; + if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ + return SWIG_Python_str_FromFormat("%s%s", result, v->ty->name); + } else { + return SWIG_Python_str_FromChar(v->ty->name); + } +} + +SWIGRUNTIME int +SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w) +{ + size_t i = v->size; + size_t j = w->size; + int s = (i < j) ? -1 : ((i > j) ? 1 : 0); + return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size); +} + +SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void); + +SWIGRUNTIME PyTypeObject* +SwigPyPacked_type(void) { + static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyPacked_TypeOnce(); + return type; +} + +SWIGRUNTIMEINLINE int +SwigPyPacked_Check(PyObject *op) { + return ((op)->ob_type == SwigPyPacked_TypeOnce()) + || (strcmp((op)->ob_type->tp_name,"SwigPyPacked") == 0); +} + +SWIGRUNTIME void +SwigPyPacked_dealloc(PyObject *v) +{ + if (SwigPyPacked_Check(v)) { + SwigPyPacked *sobj = (SwigPyPacked *) v; + free(sobj->pack); + } + PyObject_DEL(v); +} + +SWIGRUNTIME PyTypeObject* +SwigPyPacked_TypeOnce(void) { + static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer"; + static PyTypeObject swigpypacked_type; + static int type_init = 0; + if (!type_init) { + const PyTypeObject tmp = { + /* PyObject header changed in Python 3 */ +#if PY_VERSION_HEX>=0x03000000 + PyVarObject_HEAD_INIT(NULL, 0) +#else + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ +#endif + (char *)"SwigPyPacked", /* tp_name */ + sizeof(SwigPyPacked), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)SwigPyPacked_dealloc, /* tp_dealloc */ + (printfunc)SwigPyPacked_print, /* tp_print */ + (getattrfunc)0, /* tp_getattr */ + (setattrfunc)0, /* tp_setattr */ +#if PY_VERSION_HEX>=0x03000000 + 0, /* tp_reserved in 3.0.1 */ +#else + (cmpfunc)SwigPyPacked_compare, /* tp_compare */ +#endif + (reprfunc)SwigPyPacked_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + (hashfunc)0, /* tp_hash */ + (ternaryfunc)0, /* tp_call */ + (reprfunc)SwigPyPacked_str, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + swigpacked_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ +#if PY_VERSION_HEX >= 0x02020000 + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + 0, /* tp_free */ + 0, /* tp_is_gc */ + 0, /* tp_bases */ + 0, /* tp_mro */ + 0, /* tp_cache */ + 0, /* tp_subclasses */ + 0, /* tp_weaklist */ +#endif +#if PY_VERSION_HEX >= 0x02030000 + 0, /* tp_del */ +#endif +#if PY_VERSION_HEX >= 0x02060000 + 0, /* tp_version */ +#endif +#ifdef COUNT_ALLOCS + 0,0,0,0 /* tp_alloc -> tp_next */ +#endif + }; + swigpypacked_type = tmp; + type_init = 1; +#if PY_VERSION_HEX < 0x02020000 + swigpypacked_type.ob_type = &PyType_Type; +#else + if (PyType_Ready(&swigpypacked_type) < 0) + return NULL; +#endif + } + return &swigpypacked_type; +} + +SWIGRUNTIME PyObject * +SwigPyPacked_New(void *ptr, size_t size, swig_type_info *ty) +{ + SwigPyPacked *sobj = PyObject_NEW(SwigPyPacked, SwigPyPacked_type()); + if (sobj) { + void *pack = malloc(size); + if (pack) { + memcpy(pack, ptr, size); + sobj->pack = pack; + sobj->ty = ty; + sobj->size = size; + } else { + PyObject_DEL((PyObject *) sobj); + sobj = 0; + } + } + return (PyObject *) sobj; +} + +SWIGRUNTIME swig_type_info * +SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size) +{ + if (SwigPyPacked_Check(obj)) { + SwigPyPacked *sobj = (SwigPyPacked *)obj; + if (sobj->size != size) return 0; + memcpy(ptr, sobj->pack, size); + return sobj->ty; + } else { + return 0; + } +} + +/* ----------------------------------------------------------------------------- + * pointers/data manipulation + * ----------------------------------------------------------------------------- */ + +SWIGRUNTIMEINLINE PyObject * +_SWIG_This(void) +{ + return SWIG_Python_str_FromChar("this"); +} + +static PyObject *swig_this = NULL; + +SWIGRUNTIME PyObject * +SWIG_This(void) +{ + if (swig_this == NULL) + swig_this = _SWIG_This(); + return swig_this; +} + +/* #define SWIG_PYTHON_SLOW_GETSET_THIS */ + +/* TODO: I don't know how to implement the fast getset in Python 3 right now */ +#if PY_VERSION_HEX>=0x03000000 +#define SWIG_PYTHON_SLOW_GETSET_THIS +#endif + +SWIGRUNTIME SwigPyObject * +SWIG_Python_GetSwigThis(PyObject *pyobj) +{ + PyObject *obj; + + if (SwigPyObject_Check(pyobj)) + return (SwigPyObject *) pyobj; + +#ifdef SWIGPYTHON_BUILTIN + (void)obj; +# ifdef PyWeakref_CheckProxy + if (PyWeakref_CheckProxy(pyobj)) { + pyobj = PyWeakref_GET_OBJECT(pyobj); + if (pyobj && SwigPyObject_Check(pyobj)) + return (SwigPyObject*) pyobj; + } +# endif + return NULL; +#else + + obj = 0; + +#if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000)) + if (PyInstance_Check(pyobj)) { + obj = _PyInstance_Lookup(pyobj, SWIG_This()); + } else { + PyObject **dictptr = _PyObject_GetDictPtr(pyobj); + if (dictptr != NULL) { + PyObject *dict = *dictptr; + obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0; + } else { +#ifdef PyWeakref_CheckProxy + if (PyWeakref_CheckProxy(pyobj)) { + PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); + return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; + } +#endif + obj = PyObject_GetAttr(pyobj,SWIG_This()); + if (obj) { + Py_DECREF(obj); + } else { + if (PyErr_Occurred()) PyErr_Clear(); + return 0; + } + } + } +#else + obj = PyObject_GetAttr(pyobj,SWIG_This()); + if (obj) { + Py_DECREF(obj); + } else { + if (PyErr_Occurred()) PyErr_Clear(); + return 0; + } +#endif + if (obj && !SwigPyObject_Check(obj)) { + /* a PyObject is called 'this', try to get the 'real this' + SwigPyObject from it */ + return SWIG_Python_GetSwigThis(obj); + } + return (SwigPyObject *)obj; +#endif +} + +/* Acquire a pointer value */ + +SWIGRUNTIME int +SWIG_Python_AcquirePtr(PyObject *obj, int own) { + if (own == SWIG_POINTER_OWN) { + SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj); + if (sobj) { + int oldown = sobj->own; + sobj->own = own; + return oldown; + } + } + return 0; +} + +/* Convert a pointer value */ + +SWIGRUNTIME int +SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) { + int res; + SwigPyObject *sobj; + int implicit_conv = (flags & SWIG_POINTER_IMPLICIT_CONV) != 0; + + if (!obj) + return SWIG_ERROR; + if (obj == Py_None && !implicit_conv) { + if (ptr) + *ptr = 0; + return SWIG_OK; + } + + res = SWIG_ERROR; + + sobj = SWIG_Python_GetSwigThis(obj); + if (own) + *own = 0; + while (sobj) { + void *vptr = sobj->ptr; + if (ty) { + swig_type_info *to = sobj->ty; + if (to == ty) { + /* no type cast needed */ + if (ptr) *ptr = vptr; + break; + } else { + swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); + if (!tc) { + sobj = (SwigPyObject *)sobj->next; + } else { + if (ptr) { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc,vptr,&newmemory); + if (newmemory == SWIG_CAST_NEW_MEMORY) { + assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ + if (own) + *own = *own | SWIG_CAST_NEW_MEMORY; + } + } + break; + } + } + } else { + if (ptr) *ptr = vptr; + break; + } + } + if (sobj) { + if (own) + *own = *own | sobj->own; + if (flags & SWIG_POINTER_DISOWN) { + sobj->own = 0; + } + res = SWIG_OK; + } else { + if (implicit_conv) { + SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; + if (data && !data->implicitconv) { + PyObject *klass = data->klass; + if (klass) { + PyObject *impconv; + data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/ + impconv = SWIG_Python_CallFunctor(klass, obj); + data->implicitconv = 0; + if (PyErr_Occurred()) { + PyErr_Clear(); + impconv = 0; + } + if (impconv) { + SwigPyObject *iobj = SWIG_Python_GetSwigThis(impconv); + if (iobj) { + void *vptr; + res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0); + if (SWIG_IsOK(res)) { + if (ptr) { + *ptr = vptr; + /* transfer the ownership to 'ptr' */ + iobj->own = 0; + res = SWIG_AddCast(res); + res = SWIG_AddNewMask(res); + } else { + res = SWIG_AddCast(res); + } + } + } + Py_DECREF(impconv); + } + } + } + } + if (!SWIG_IsOK(res) && obj == Py_None) { + if (ptr) + *ptr = 0; + if (PyErr_Occurred()) + PyErr_Clear(); + res = SWIG_OK; + } + } + return res; +} + +/* Convert a function ptr value */ + +SWIGRUNTIME int +SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { + if (!PyCFunction_Check(obj)) { + return SWIG_ConvertPtr(obj, ptr, ty, 0); + } else { + void *vptr = 0; + + /* here we get the method pointer for callbacks */ + const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); + const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; + if (desc) + desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; + if (!desc) + return SWIG_ERROR; + if (ty) { + swig_cast_info *tc = SWIG_TypeCheck(desc,ty); + if (tc) { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc,vptr,&newmemory); + assert(!newmemory); /* newmemory handling not yet implemented */ + } else { + return SWIG_ERROR; + } + } else { + *ptr = vptr; + } + return SWIG_OK; + } +} + +/* Convert a packed value value */ + +SWIGRUNTIME int +SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) { + swig_type_info *to = SwigPyPacked_UnpackData(obj, ptr, sz); + if (!to) return SWIG_ERROR; + if (ty) { + if (to != ty) { + /* check type cast? */ + swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); + if (!tc) return SWIG_ERROR; + } + } + return SWIG_OK; +} + +/* ----------------------------------------------------------------------------- + * Create a new pointer object + * ----------------------------------------------------------------------------- */ + +/* + Create a new instance object, without calling __init__, and set the + 'this' attribute. +*/ + +SWIGRUNTIME PyObject* +SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) +{ +#if (PY_VERSION_HEX >= 0x02020000) + PyObject *inst = 0; + PyObject *newraw = data->newraw; + if (newraw) { + inst = PyObject_Call(newraw, data->newargs, NULL); + if (inst) { +#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) + PyObject **dictptr = _PyObject_GetDictPtr(inst); + if (dictptr != NULL) { + PyObject *dict = *dictptr; + if (dict == NULL) { + dict = PyDict_New(); + *dictptr = dict; + PyDict_SetItem(dict, SWIG_This(), swig_this); + } + } +#else + PyObject *key = SWIG_This(); + PyObject_SetAttr(inst, key, swig_this); +#endif + } + } else { +#if PY_VERSION_HEX >= 0x03000000 + inst = ((PyTypeObject*) data->newargs)->tp_new((PyTypeObject*) data->newargs, Py_None, Py_None); + if (inst) { + PyObject_SetAttr(inst, SWIG_This(), swig_this); + Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; + } +#else + PyObject *dict = PyDict_New(); + if (dict) { + PyDict_SetItem(dict, SWIG_This(), swig_this); + inst = PyInstance_NewRaw(data->newargs, dict); + Py_DECREF(dict); + } +#endif + } + return inst; +#else +#if (PY_VERSION_HEX >= 0x02010000) + PyObject *inst = 0; + PyObject *dict = PyDict_New(); + if (dict) { + PyDict_SetItem(dict, SWIG_This(), swig_this); + inst = PyInstance_NewRaw(data->newargs, dict); + Py_DECREF(dict); + } + return (PyObject *) inst; +#else + PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type); + if (inst == NULL) { + return NULL; + } + inst->in_class = (PyClassObject *)data->newargs; + Py_INCREF(inst->in_class); + inst->in_dict = PyDict_New(); + if (inst->in_dict == NULL) { + Py_DECREF(inst); + return NULL; + } +#ifdef Py_TPFLAGS_HAVE_WEAKREFS + inst->in_weakreflist = NULL; +#endif +#ifdef Py_TPFLAGS_GC + PyObject_GC_Init(inst); +#endif + PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this); + return (PyObject *) inst; +#endif +#endif +} + +SWIGRUNTIME void +SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) +{ + PyObject *dict; +#if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS) + PyObject **dictptr = _PyObject_GetDictPtr(inst); + if (dictptr != NULL) { + dict = *dictptr; + if (dict == NULL) { + dict = PyDict_New(); + *dictptr = dict; + } + PyDict_SetItem(dict, SWIG_This(), swig_this); + return; + } +#endif + dict = PyObject_GetAttrString(inst, (char*)"__dict__"); + PyDict_SetItem(dict, SWIG_This(), swig_this); + Py_DECREF(dict); +} + + +SWIGINTERN PyObject * +SWIG_Python_InitShadowInstance(PyObject *args) { + PyObject *obj[2]; + if (!SWIG_Python_UnpackTuple(args, "swiginit", 2, 2, obj)) { + return NULL; + } else { + SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]); + if (sthis) { + SwigPyObject_append((PyObject*) sthis, obj[1]); + } else { + SWIG_Python_SetSwigThis(obj[0], obj[1]); + } + return SWIG_Py_Void(); + } +} + +/* Create a new pointer object */ + +SWIGRUNTIME PyObject * +SWIG_Python_NewPointerObj(PyObject *self, void *ptr, swig_type_info *type, int flags) { + SwigPyClientData *clientdata; + PyObject * robj; + int own; + + if (!ptr) + return SWIG_Py_Void(); + + clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0; + own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0; + if (clientdata && clientdata->pytype) { + SwigPyObject *newobj; + if (flags & SWIG_BUILTIN_TP_INIT) { + newobj = (SwigPyObject*) self; + if (newobj->ptr) { + PyObject *next_self = clientdata->pytype->tp_alloc(clientdata->pytype, 0); + while (newobj->next) + newobj = (SwigPyObject *) newobj->next; + newobj->next = next_self; + newobj = (SwigPyObject *)next_self; + } + } else { + newobj = PyObject_New(SwigPyObject, clientdata->pytype); + } + if (newobj) { + newobj->ptr = ptr; + newobj->ty = type; + newobj->own = own; + newobj->next = 0; +#ifdef SWIGPYTHON_BUILTIN + newobj->dict = 0; +#endif + return (PyObject*) newobj; + } + return SWIG_Py_Void(); + } + + assert(!(flags & SWIG_BUILTIN_TP_INIT)); + + robj = SwigPyObject_New(ptr, type, own); + if (robj && clientdata && !(flags & SWIG_POINTER_NOSHADOW)) { + PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj); + Py_DECREF(robj); + robj = inst; + } + return robj; +} + +/* Create a new packed object */ + +SWIGRUNTIMEINLINE PyObject * +SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { + return ptr ? SwigPyPacked_New((void *) ptr, sz, type) : SWIG_Py_Void(); +} + +/* -----------------------------------------------------------------------------* + * Get type list + * -----------------------------------------------------------------------------*/ + +#ifdef SWIG_LINK_RUNTIME +void *SWIG_ReturnGlobalTypeList(void *); +#endif + +SWIGRUNTIME swig_module_info * +SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) { + static void *type_pointer = (void *)0; + /* first check if module already created */ + if (!type_pointer) { +#ifdef SWIG_LINK_RUNTIME + type_pointer = SWIG_ReturnGlobalTypeList((void *)0); +#else +# ifdef SWIGPY_USE_CAPSULE + type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0); +# else + type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, + (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); +# endif + if (PyErr_Occurred()) { + PyErr_Clear(); + type_pointer = (void *)0; + } +#endif + } + return (swig_module_info *) type_pointer; +} + +#if PY_MAJOR_VERSION < 2 +/* PyModule_AddObject function was introduced in Python 2.0. The following function + is copied out of Python/modsupport.c in python version 2.3.4 */ +SWIGINTERN int +PyModule_AddObject(PyObject *m, char *name, PyObject *o) +{ + PyObject *dict; + if (!PyModule_Check(m)) { + PyErr_SetString(PyExc_TypeError, + "PyModule_AddObject() needs module as first arg"); + return SWIG_ERROR; + } + if (!o) { + PyErr_SetString(PyExc_TypeError, + "PyModule_AddObject() needs non-NULL value"); + return SWIG_ERROR; + } + + dict = PyModule_GetDict(m); + if (dict == NULL) { + /* Internal error -- modules must have a dict! */ + PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", + PyModule_GetName(m)); + return SWIG_ERROR; + } + if (PyDict_SetItemString(dict, name, o)) + return SWIG_ERROR; + Py_DECREF(o); + return SWIG_OK; +} +#endif + +SWIGRUNTIME void +#ifdef SWIGPY_USE_CAPSULE +SWIG_Python_DestroyModule(PyObject *obj) +#else +SWIG_Python_DestroyModule(void *vptr) +#endif +{ +#ifdef SWIGPY_USE_CAPSULE + swig_module_info *swig_module = (swig_module_info *) PyCapsule_GetPointer(obj, SWIGPY_CAPSULE_NAME); +#else + swig_module_info *swig_module = (swig_module_info *) vptr; +#endif + swig_type_info **types = swig_module->types; + size_t i; + for (i =0; i < swig_module->size; ++i) { + swig_type_info *ty = types[i]; + if (ty->owndata) { + SwigPyClientData *data = (SwigPyClientData *) ty->clientdata; + if (data) SwigPyClientData_Del(data); + } + } + Py_DECREF(SWIG_This()); + swig_this = NULL; +} + +SWIGRUNTIME void +SWIG_Python_SetModule(swig_module_info *swig_module) { +#if PY_VERSION_HEX >= 0x03000000 + /* Add a dummy module object into sys.modules */ + PyObject *module = PyImport_AddModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION); +#else + static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */ + PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table); +#endif +#ifdef SWIGPY_USE_CAPSULE + PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule); + if (pointer && module) { + PyModule_AddObject(module, (char*)"type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer); + } else { + Py_XDECREF(pointer); + } +#else + PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule); + if (pointer && module) { + PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); + } else { + Py_XDECREF(pointer); + } +#endif +} + +/* The python cached type query */ +SWIGRUNTIME PyObject * +SWIG_Python_TypeCache(void) { + static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New(); + return cache; +} + +SWIGRUNTIME swig_type_info * +SWIG_Python_TypeQuery(const char *type) +{ + PyObject *cache = SWIG_Python_TypeCache(); + PyObject *key = SWIG_Python_str_FromChar(type); + PyObject *obj = PyDict_GetItem(cache, key); + swig_type_info *descriptor; + if (obj) { +#ifdef SWIGPY_USE_CAPSULE + descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, NULL); +#else + descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj); +#endif + } else { + swig_module_info *swig_module = SWIG_GetModule(0); + descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); + if (descriptor) { +#ifdef SWIGPY_USE_CAPSULE + obj = PyCapsule_New((void*) descriptor, NULL, NULL); +#else + obj = PyCObject_FromVoidPtr(descriptor, NULL); +#endif + PyDict_SetItem(cache, key, obj); + Py_DECREF(obj); + } + } + Py_DECREF(key); + return descriptor; +} + +/* + For backward compatibility only +*/ +#define SWIG_POINTER_EXCEPTION 0 +#define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg) +#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags) + +SWIGRUNTIME int +SWIG_Python_AddErrMesg(const char* mesg, int infront) +{ + if (PyErr_Occurred()) { + PyObject *type = 0; + PyObject *value = 0; + PyObject *traceback = 0; + PyErr_Fetch(&type, &value, &traceback); + if (value) { + char *tmp; + PyObject *old_str = PyObject_Str(value); + Py_XINCREF(type); + PyErr_Clear(); + if (infront) { + PyErr_Format(type, "%s %s", mesg, tmp = SWIG_Python_str_AsChar(old_str)); + } else { + PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); + } + SWIG_Python_str_DelForPy3(tmp); + Py_DECREF(old_str); + } + return 1; + } else { + return 0; + } +} + +SWIGRUNTIME int +SWIG_Python_ArgFail(int argnum) +{ + if (PyErr_Occurred()) { + /* add information about failing argument */ + char mesg[256]; + PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum); + return SWIG_Python_AddErrMesg(mesg, 1); + } else { + return 0; + } +} + +SWIGRUNTIMEINLINE const char * +SwigPyObject_GetDesc(PyObject *self) +{ + SwigPyObject *v = (SwigPyObject *)self; + swig_type_info *ty = v ? v->ty : 0; + return ty ? ty->str : ""; +} + +SWIGRUNTIME void +SWIG_Python_TypeError(const char *type, PyObject *obj) +{ + if (type) { +#if defined(SWIG_COBJECT_TYPES) + if (obj && SwigPyObject_Check(obj)) { + const char *otype = (const char *) SwigPyObject_GetDesc(obj); + if (otype) { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received", + type, otype); + return; + } + } else +#endif + { + const char *otype = (obj ? obj->ob_type->tp_name : 0); + if (otype) { + PyObject *str = PyObject_Str(obj); + const char *cstr = str ? SWIG_Python_str_AsChar(str) : 0; + if (cstr) { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", + type, otype, cstr); + SWIG_Python_str_DelForPy3(cstr); + } else { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", + type, otype); + } + Py_XDECREF(str); + return; + } + } + PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); + } else { + PyErr_Format(PyExc_TypeError, "unexpected type is received"); + } +} + + +/* Convert a pointer value, signal an exception on a type mismatch */ +SWIGRUNTIME void * +SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int SWIGUNUSEDPARM(argnum), int flags) { + void *result; + if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { + PyErr_Clear(); +#if SWIG_POINTER_EXCEPTION + if (flags) { + SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); + SWIG_Python_ArgFail(argnum); + } +#endif + } + return result; +} + +#ifdef SWIGPYTHON_BUILTIN +SWIGRUNTIME int +SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { + PyTypeObject *tp = obj->ob_type; + PyObject *descr; + PyObject *encoded_name; + descrsetfunc f; + int res = -1; + +# ifdef Py_USING_UNICODE + if (PyString_Check(name)) { + name = PyUnicode_Decode(PyString_AsString(name), PyString_Size(name), NULL, NULL); + if (!name) + return -1; + } else if (!PyUnicode_Check(name)) +# else + if (!PyString_Check(name)) +# endif + { + PyErr_Format(PyExc_TypeError, "attribute name must be string, not '%.200s'", name->ob_type->tp_name); + return -1; + } else { + Py_INCREF(name); + } + + if (!tp->tp_dict) { + if (PyType_Ready(tp) < 0) + goto done; + } + + descr = _PyType_Lookup(tp, name); + f = NULL; + if (descr != NULL) + f = descr->ob_type->tp_descr_set; + if (!f) { + if (PyString_Check(name)) { + encoded_name = name; + Py_INCREF(name); + } else { + encoded_name = PyUnicode_AsUTF8String(name); + } + PyErr_Format(PyExc_AttributeError, "'%.100s' object has no attribute '%.200s'", tp->tp_name, PyString_AsString(encoded_name)); + Py_DECREF(encoded_name); + } else { + res = f(descr, obj, value); + } + + done: + Py_DECREF(name); + return res; +} +#endif + + +#ifdef __cplusplus +} +#endif + + + +#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) + +#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else + + + +/* -------- TYPES TABLE (BEGIN) -------- */ + +#define SWIGTYPE_p_ESLconnection swig_types[0] +#define SWIGTYPE_p_ESLevent swig_types[1] +#define SWIGTYPE_p_char swig_types[2] +#define SWIGTYPE_p_esl_event_t swig_types[3] +#define SWIGTYPE_p_esl_priority_t swig_types[4] +static swig_type_info *swig_types[6]; +static swig_module_info swig_module = {swig_types, 5, 0, 0, 0, 0}; +#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) +#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) + +/* -------- TYPES TABLE (END) -------- */ + +#if (PY_VERSION_HEX <= 0x02000000) +# if !defined(SWIG_PYTHON_CLASSIC) +# error "This python version requires swig to be run with the '-classic' option" +# endif +#endif + +/*----------------------------------------------- + @(target):= _ESL.so + ------------------------------------------------*/ +#if PY_VERSION_HEX >= 0x03000000 +# define SWIG_init PyInit__ESL + +#else +# define SWIG_init init_ESL + +#endif +#define SWIG_name "_ESL" + +#define SWIGVERSION 0x030002 +#define SWIG_VERSION SWIGVERSION + + +#define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a)) +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),reinterpret_cast< void** >(a)) + + +#include + + +namespace swig { + class SwigPtr_PyObject { + protected: + PyObject *_obj; + + public: + SwigPtr_PyObject() :_obj(0) + { + } + + SwigPtr_PyObject(const SwigPtr_PyObject& item) : _obj(item._obj) + { + Py_XINCREF(_obj); + } + + SwigPtr_PyObject(PyObject *obj, bool initial_ref = true) :_obj(obj) + { + if (initial_ref) { + Py_XINCREF(_obj); + } + } + + SwigPtr_PyObject & operator=(const SwigPtr_PyObject& item) + { + Py_XINCREF(item._obj); + Py_XDECREF(_obj); + _obj = item._obj; + return *this; + } + + ~SwigPtr_PyObject() + { + Py_XDECREF(_obj); + } + + operator PyObject *() const + { + return _obj; + } + + PyObject *operator->() const + { + return _obj; + } + }; +} + + +namespace swig { + struct SwigVar_PyObject : SwigPtr_PyObject { + SwigVar_PyObject(PyObject* obj = 0) : SwigPtr_PyObject(obj, false) { } + + SwigVar_PyObject & operator = (PyObject* obj) + { + Py_XDECREF(_obj); + _obj = obj; + return *this; + } + }; +} + + +#include "esl.h" +#include "esl_oop.h" + + +SWIGINTERN swig_type_info* +SWIG_pchar_descriptor(void) +{ + static int init = 0; + static swig_type_info* info = 0; + if (!init) { + info = SWIG_TypeQuery("_p_char"); + init = 1; + } + return info; +} + + +SWIGINTERN int +SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) +{ +#if PY_VERSION_HEX>=0x03000000 + if (PyUnicode_Check(obj)) +#else + if (PyString_Check(obj)) +#endif + { + char *cstr; Py_ssize_t len; +#if PY_VERSION_HEX>=0x03000000 + if (!alloc && cptr) { + /* We can't allow converting without allocation, since the internal + representation of string in Python 3 is UCS-2/UCS-4 but we require + a UTF-8 representation. + TODO(bhy) More detailed explanation */ + return SWIG_RuntimeError; + } + obj = PyUnicode_AsUTF8String(obj); + PyBytes_AsStringAndSize(obj, &cstr, &len); + if(alloc) *alloc = SWIG_NEWOBJ; +#else + PyString_AsStringAndSize(obj, &cstr, &len); +#endif + if (cptr) { + if (alloc) { + /* + In python the user should not be able to modify the inner + string representation. To warranty that, if you define + SWIG_PYTHON_SAFE_CSTRINGS, a new/copy of the python string + buffer is always returned. + + The default behavior is just to return the pointer value, + so, be careful. + */ +#if defined(SWIG_PYTHON_SAFE_CSTRINGS) + if (*alloc != SWIG_OLDOBJ) +#else + if (*alloc == SWIG_NEWOBJ) +#endif + { + *cptr = reinterpret_cast< char* >(memcpy((new char[len + 1]), cstr, sizeof(char)*(len + 1))); + *alloc = SWIG_NEWOBJ; + } + else { + *cptr = cstr; + *alloc = SWIG_OLDOBJ; + } + } else { + #if PY_VERSION_HEX>=0x03000000 + assert(0); /* Should never reach here in Python 3 */ + #endif + *cptr = SWIG_Python_str_AsChar(obj); + } + } + if (psize) *psize = len + 1; +#if PY_VERSION_HEX>=0x03000000 + Py_XDECREF(obj); +#endif + return SWIG_OK; + } else { + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + if (pchar_descriptor) { + void* vptr = 0; + if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) { + if (cptr) *cptr = (char *) vptr; + if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0; + if (alloc) *alloc = SWIG_OLDOBJ; + return SWIG_OK; + } + } + } + return SWIG_TypeError; +} + + + + + +SWIGINTERNINLINE PyObject * +SWIG_FromCharPtrAndSize(const char* carray, size_t size) +{ + if (carray) { + if (size > INT_MAX) { + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + return pchar_descriptor ? + SWIG_InternalNewPointerObj(const_cast< char * >(carray), pchar_descriptor, 0) : SWIG_Py_Void(); + } else { +#if PY_VERSION_HEX >= 0x03000000 +#if PY_VERSION_HEX >= 0x03010000 + return PyUnicode_DecodeUTF8(carray, static_cast< int >(size), "surrogateescape"); +#else + return PyUnicode_FromStringAndSize(carray, static_cast< int >(size)); +#endif +#else + return PyString_FromStringAndSize(carray, static_cast< int >(size)); +#endif + } + } else { + return SWIG_Py_Void(); + } +} + + +SWIGINTERNINLINE PyObject * +SWIG_FromCharPtr(const char *cptr) +{ + return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0)); +} + + +#include +#if !defined(SWIG_NO_LLONG_MAX) +# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) +# define LLONG_MAX __LONG_LONG_MAX__ +# define LLONG_MIN (-LLONG_MAX - 1LL) +# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) +# endif +#endif + + +SWIGINTERN int +SWIG_AsVal_double (PyObject *obj, double *val) +{ + int res = SWIG_TypeError; + if (PyFloat_Check(obj)) { + if (val) *val = PyFloat_AsDouble(obj); + return SWIG_OK; + } else if (PyInt_Check(obj)) { + if (val) *val = PyInt_AsLong(obj); + return SWIG_OK; + } else if (PyLong_Check(obj)) { + double v = PyLong_AsDouble(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + } + } +#ifdef SWIG_PYTHON_CAST_MODE + { + int dispatch = 0; + double d = PyFloat_AsDouble(obj); + if (!PyErr_Occurred()) { + if (val) *val = d; + return SWIG_AddCast(SWIG_OK); + } else { + PyErr_Clear(); + } + if (!dispatch) { + long v = PyLong_AsLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_AddCast(SWIG_AddCast(SWIG_OK)); + } else { + PyErr_Clear(); + } + } + } +#endif + return res; +} + + +#include + + +#include + + +SWIGINTERNINLINE int +SWIG_CanCastAsInteger(double *d, double min, double max) { + double x = *d; + if ((min <= x && x <= max)) { + double fx = floor(x); + double cx = ceil(x); + double rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */ + if ((errno == EDOM) || (errno == ERANGE)) { + errno = 0; + } else { + double summ, reps, diff; + if (rd < x) { + diff = x - rd; + } else if (rd > x) { + diff = rd - x; + } else { + return 1; + } + summ = rd + x; + reps = diff/summ; + if (reps < 8*DBL_EPSILON) { + *d = rd; + return 1; + } + } + } + return 0; +} + + +SWIGINTERN int +SWIG_AsVal_long (PyObject *obj, long* val) +{ + if (PyInt_Check(obj)) { + if (val) *val = PyInt_AsLong(obj); + return SWIG_OK; + } else if (PyLong_Check(obj)) { + long v = PyLong_AsLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + } + } +#ifdef SWIG_PYTHON_CAST_MODE + { + int dispatch = 0; + long v = PyInt_AsLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_AddCast(SWIG_OK); + } else { + PyErr_Clear(); + } + if (!dispatch) { + double d; + int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d)); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) { + if (val) *val = (long)(d); + return res; + } + } + } +#endif + return SWIG_TypeError; +} + + +SWIGINTERN int +SWIG_AsVal_int (PyObject * obj, int *val) +{ + long v; + int res = SWIG_AsVal_long (obj, &v); + if (SWIG_IsOK(res)) { + if ((v < INT_MIN || v > INT_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = static_cast< int >(v); + } + } + return res; +} + + +SWIGINTERNINLINE PyObject* + SWIG_From_int (int value) +{ + return PyInt_FromLong((long) value); +} + + +SWIGINTERNINLINE PyObject* + SWIG_From_bool (bool value) +{ + return PyBool_FromLong(value ? 1 : 0); +} + +#ifdef __cplusplus +extern "C" { +#endif +SWIGINTERN PyObject *_wrap_ESLevent_event_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLevent *arg1 = (ESLevent *) 0 ; + esl_event_t *arg2 = (esl_event_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:ESLevent_event_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_event_set" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_esl_event_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_event_set" "', argument " "2"" of type '" "esl_event_t *""'"); + } + arg2 = reinterpret_cast< esl_event_t * >(argp2); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + if (arg1) (arg1)->event = arg2; + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ESLevent_event_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLevent *arg1 = (ESLevent *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + esl_event_t *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:ESLevent_event_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_event_get" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (esl_event_t *) ((arg1)->event); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_esl_event_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ESLevent_serialized_string_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLevent *arg1 = (ESLevent *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:ESLevent_serialized_string_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_serialized_string_set" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_serialized_string_set" "', argument " "2"" of type '" "char *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + if (arg1->serialized_string) delete[] arg1->serialized_string; + if (arg2) { + size_t size = strlen(reinterpret_cast< const char * >(arg2)) + 1; + arg1->serialized_string = (char *)reinterpret_cast< char* >(memcpy((new char[size]), reinterpret_cast< const char * >(arg2), sizeof(char)*(size))); + } else { + arg1->serialized_string = 0; + } + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_Py_Void(); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ESLevent_serialized_string_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLevent *arg1 = (ESLevent *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + char *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:ESLevent_serialized_string_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_serialized_string_get" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (char *) ((arg1)->serialized_string); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ESLevent_mine_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLevent *arg1 = (ESLevent *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:ESLevent_mine_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_mine_set" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ESLevent_mine_set" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + if (arg1) (arg1)->mine = arg2; + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ESLevent_mine_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLevent *arg1 = (ESLevent *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"O:ESLevent_mine_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_mine_get" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int) ((arg1)->mine); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_ESLevent__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + char *arg2 = (char *) NULL ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + ESLevent *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O|O:new_ESLevent",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_ESLevent" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = reinterpret_cast< char * >(buf1); + if (obj1) { + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_ESLevent" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (ESLevent *)new ESLevent((char const *)arg1,(char const *)arg2); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, SWIG_POINTER_NEW | 0 ); + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_ESLevent__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + esl_event_t *arg1 = (esl_event_t *) 0 ; + int arg2 = (int) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + ESLevent *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O|O:new_ESLevent",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_esl_event_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_ESLevent" "', argument " "1"" of type '" "esl_event_t *""'"); + } + arg1 = reinterpret_cast< esl_event_t * >(argp1); + if (obj1) { + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_ESLevent" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (ESLevent *)new ESLevent(arg1,arg2); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_ESLevent__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLevent *arg1 = (ESLevent *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + ESLevent *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:new_ESLevent",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_ESLevent" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (ESLevent *)new ESLevent(arg1); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_ESLevent(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[3]; + int ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = args ? (int)PyObject_Length(args) : 0; + for (ii = 0; (ii < 2) && (ii < argc); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if ((argc >= 1) && (argc <= 2)) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_esl_event_t, 0); + _v = SWIG_CheckState(res); + if (_v) { + if (argc <= 1) { + return _wrap_new_ESLevent__SWIG_1(self, args); + } + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_new_ESLevent__SWIG_1(self, args); + } + } + } + if (argc == 1) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_ESLevent, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_new_ESLevent__SWIG_2(self, args); + } + } + if ((argc >= 1) && (argc <= 2)) { + int _v; + int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + if (argc <= 1) { + return _wrap_new_ESLevent__SWIG_0(self, args); + } + int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_new_ESLevent__SWIG_0(self, args); + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_ESLevent'.\n" + " Possible C/C++ prototypes are:\n" + " ESLevent::ESLevent(char const *,char const *)\n" + " ESLevent::ESLevent(esl_event_t *,int)\n" + " ESLevent::ESLevent(ESLevent *)\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_delete_ESLevent(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLevent *arg1 = (ESLevent *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_ESLevent",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLevent, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_ESLevent" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + delete arg1; + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ESLevent_serialize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLevent *arg1 = (ESLevent *) 0 ; + char *arg2 = (char *) NULL ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + char *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O|O:ESLevent_serialize",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_serialize" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + if (obj1) { + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_serialize" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (char *)(arg1)->serialize((char const *)arg2); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_FromCharPtr((const char *)result); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ESLevent_setPriority(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLevent *arg1 = (ESLevent *) 0 ; + esl_priority_t arg2 = (esl_priority_t) ESL_PRIORITY_NORMAL ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"O|O:ESLevent_setPriority",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_setPriority" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + if (obj1) { + { + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_esl_priority_t, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_setPriority" "', argument " "2"" of type '" "esl_priority_t""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "ESLevent_setPriority" "', argument " "2"" of type '" "esl_priority_t""'"); + } else { + esl_priority_t * temp = reinterpret_cast< esl_priority_t * >(argp2); + arg2 = *temp; + if (SWIG_IsNewObj(res2)) delete temp; + } + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (bool)(arg1)->setPriority(arg2); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ESLevent_getHeader(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLevent *arg1 = (ESLevent *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 = (int) -1 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + char *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO|O:ESLevent_getHeader",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_getHeader" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_getHeader" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + if (obj2) { + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "ESLevent_getHeader" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (char *)(arg1)->getHeader((char const *)arg2,arg3); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_FromCharPtr((const char *)result); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ESLevent_getBody(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLevent *arg1 = (ESLevent *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + char *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:ESLevent_getBody",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_getBody" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (char *)(arg1)->getBody(); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ESLevent_getType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLevent *arg1 = (ESLevent *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + char *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:ESLevent_getType",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_getType" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (char *)(arg1)->getType(); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ESLevent_addBody(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLevent *arg1 = (ESLevent *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:ESLevent_addBody",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_addBody" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_addBody" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (bool)(arg1)->addBody((char const *)arg2); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_From_bool(static_cast< bool >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ESLevent_addHeader(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLevent *arg1 = (ESLevent *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:ESLevent_addHeader",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_addHeader" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_addHeader" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLevent_addHeader" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (bool)(arg1)->addHeader((char const *)arg2,(char const *)arg3); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_From_bool(static_cast< bool >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ESLevent_pushHeader(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLevent *arg1 = (ESLevent *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:ESLevent_pushHeader",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_pushHeader" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_pushHeader" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLevent_pushHeader" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (bool)(arg1)->pushHeader((char const *)arg2,(char const *)arg3); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_From_bool(static_cast< bool >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ESLevent_unshiftHeader(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLevent *arg1 = (ESLevent *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:ESLevent_unshiftHeader",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_unshiftHeader" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_unshiftHeader" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLevent_unshiftHeader" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (bool)(arg1)->unshiftHeader((char const *)arg2,(char const *)arg3); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_From_bool(static_cast< bool >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ESLevent_delHeader(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLevent *arg1 = (ESLevent *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:ESLevent_delHeader",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_delHeader" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLevent_delHeader" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (bool)(arg1)->delHeader((char const *)arg2); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_From_bool(static_cast< bool >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ESLevent_firstHeader(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLevent *arg1 = (ESLevent *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + char *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:ESLevent_firstHeader",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_firstHeader" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (char *)(arg1)->firstHeader(); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ESLevent_nextHeader(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLevent *arg1 = (ESLevent *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + char *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:ESLevent_nextHeader",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLevent_nextHeader" "', argument " "1"" of type '" "ESLevent *""'"); + } + arg1 = reinterpret_cast< ESLevent * >(argp1); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (char *)(arg1)->nextHeader(); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *ESLevent_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_ESLevent, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_new_ESLconnection__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + ESLconnection *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOO:new_ESLconnection",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_ESLconnection" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = reinterpret_cast< char * >(buf1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_ESLconnection" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "new_ESLconnection" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + res4 = SWIG_AsCharPtrAndSize(obj3, &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "new_ESLconnection" "', argument " "4"" of type '" "char const *""'"); + } + arg4 = reinterpret_cast< char * >(buf4); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (ESLconnection *)new ESLconnection((char const *)arg1,arg2,(char const *)arg3,(char const *)arg4); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLconnection, SWIG_POINTER_NEW | 0 ); + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_ESLconnection__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + ESLconnection *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOO:new_ESLconnection",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_ESLconnection" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = reinterpret_cast< char * >(buf1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_ESLconnection" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "new_ESLconnection" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (ESLconnection *)new ESLconnection((char const *)arg1,arg2,(char const *)arg3); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLconnection, SWIG_POINTER_NEW | 0 ); + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_ESLconnection__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + ESLconnection *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOO:new_ESLconnection",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_ESLconnection" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = reinterpret_cast< char * >(buf1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_ESLconnection" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "new_ESLconnection" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + res4 = SWIG_AsCharPtrAndSize(obj3, &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "new_ESLconnection" "', argument " "4"" of type '" "char const *""'"); + } + arg4 = reinterpret_cast< char * >(buf4); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (ESLconnection *)new ESLconnection((char const *)arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLconnection, SWIG_POINTER_NEW | 0 ); + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_ESLconnection__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + ESLconnection *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOO:new_ESLconnection",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_ESLconnection" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = reinterpret_cast< char * >(buf1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_ESLconnection" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "new_ESLconnection" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (ESLconnection *)new ESLconnection((char const *)arg1,(char const *)arg2,(char const *)arg3); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLconnection, SWIG_POINTER_NEW | 0 ); + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_ESLconnection__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int val1 ; + int ecode1 = 0 ; + PyObject * obj0 = 0 ; + ESLconnection *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:new_ESLconnection",&obj0)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_ESLconnection" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (ESLconnection *)new ESLconnection(arg1); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLconnection, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_ESLconnection(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[5]; + int ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = args ? (int)PyObject_Length(args) : 0; + for (ii = 0; (ii < 4) && (ii < argc); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 1) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_new_ESLconnection__SWIG_4(self, args); + } + } + if (argc == 3) { + int _v; + int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_new_ESLconnection__SWIG_1(self, args); + } + } + } + } + if (argc == 3) { + int _v; + int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_new_ESLconnection__SWIG_3(self, args); + } + } + } + } + if (argc == 4) { + int _v; + int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsCharPtrAndSize(argv[3], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_new_ESLconnection__SWIG_0(self, args); + } + } + } + } + } + if (argc == 4) { + int _v; + int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsCharPtrAndSize(argv[3], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_new_ESLconnection__SWIG_2(self, args); + } + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_ESLconnection'.\n" + " Possible C/C++ prototypes are:\n" + " ESLconnection::ESLconnection(char const *,int const,char const *,char const *)\n" + " ESLconnection::ESLconnection(char const *,int const,char const *)\n" + " ESLconnection::ESLconnection(char const *,char const *,char const *,char const *)\n" + " ESLconnection::ESLconnection(char const *,char const *,char const *)\n" + " ESLconnection::ESLconnection(int)\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_delete_ESLconnection(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLconnection *arg1 = (ESLconnection *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_ESLconnection",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLconnection, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_ESLconnection" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + delete arg1; + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ESLconnection_socketDescriptor(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLconnection *arg1 = (ESLconnection *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"O:ESLconnection_socketDescriptor",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_socketDescriptor" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)(arg1)->socketDescriptor(); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ESLconnection_connected(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLconnection *arg1 = (ESLconnection *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"O:ESLconnection_connected",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_connected" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)(arg1)->connected(); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ESLconnection_getInfo(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLconnection *arg1 = (ESLconnection *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + ESLevent *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:ESLconnection_getInfo",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_getInfo" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (ESLevent *)(arg1)->getInfo(); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ESLconnection_send(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLconnection *arg1 = (ESLconnection *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"OO:ESLconnection_send",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_send" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_send" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)(arg1)->send((char const *)arg2); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_From_int(static_cast< int >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ESLconnection_sendRecv(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLconnection *arg1 = (ESLconnection *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + ESLevent *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:ESLconnection_sendRecv",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_sendRecv" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_sendRecv" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (ESLevent *)(arg1)->sendRecv((char const *)arg2); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, SWIG_POINTER_OWN | 0 ); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ESLconnection_api(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLconnection *arg1 = (ESLconnection *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) NULL ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + ESLevent *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO|O:ESLconnection_api",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_api" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_api" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + if (obj2) { + res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLconnection_api" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (ESLevent *)(arg1)->api((char const *)arg2,(char const *)arg3); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, SWIG_POINTER_OWN | 0 ); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ESLconnection_bgapi(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLconnection *arg1 = (ESLconnection *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) NULL ; + char *arg4 = (char *) NULL ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + ESLevent *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO|OO:ESLconnection_bgapi",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_bgapi" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_bgapi" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + if (obj2) { + res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLconnection_bgapi" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + } + if (obj3) { + res4 = SWIG_AsCharPtrAndSize(obj3, &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "ESLconnection_bgapi" "', argument " "4"" of type '" "char const *""'"); + } + arg4 = reinterpret_cast< char * >(buf4); + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (ESLevent *)(arg1)->bgapi((char const *)arg2,(char const *)arg3,(char const *)arg4); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, SWIG_POINTER_OWN | 0 ); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ESLconnection_sendEvent(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLconnection *arg1 = (ESLconnection *) 0 ; + ESLevent *arg2 = (ESLevent *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + ESLevent *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:ESLconnection_sendEvent",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_sendEvent" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_sendEvent" "', argument " "2"" of type '" "ESLevent *""'"); + } + arg2 = reinterpret_cast< ESLevent * >(argp2); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (ESLevent *)(arg1)->sendEvent(arg2); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ESLconnection_sendMSG(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLconnection *arg1 = (ESLconnection *) 0 ; + ESLevent *arg2 = (ESLevent *) 0 ; + char *arg3 = (char *) NULL ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"OO|O:ESLconnection_sendMSG",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_sendMSG" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ESLevent, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_sendMSG" "', argument " "2"" of type '" "ESLevent *""'"); + } + arg2 = reinterpret_cast< ESLevent * >(argp2); + if (obj2) { + res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLconnection_sendMSG" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)(arg1)->sendMSG(arg2,(char const *)arg3); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_From_int(static_cast< int >(result)); + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return resultobj; +fail: + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ESLconnection_recvEvent(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLconnection *arg1 = (ESLconnection *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + ESLevent *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:ESLconnection_recvEvent",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_recvEvent" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (ESLevent *)(arg1)->recvEvent(); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ESLconnection_recvEventTimed(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLconnection *arg1 = (ESLconnection *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + ESLevent *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:ESLconnection_recvEventTimed",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_recvEventTimed" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ESLconnection_recvEventTimed" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (ESLevent *)(arg1)->recvEventTimed(arg2); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ESLconnection_filter(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLconnection *arg1 = (ESLconnection *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + ESLevent *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOO:ESLconnection_filter",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_filter" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_filter" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLconnection_filter" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (ESLevent *)(arg1)->filter((char const *)arg2,(char const *)arg3); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, SWIG_POINTER_OWN | 0 ); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ESLconnection_events(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLconnection *arg1 = (ESLconnection *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:ESLconnection_events",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_events" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_events" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLconnection_events" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)(arg1)->events((char const *)arg2,(char const *)arg3); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_From_int(static_cast< int >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ESLconnection_execute(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLconnection *arg1 = (ESLconnection *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) NULL ; + char *arg4 = (char *) NULL ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + ESLevent *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO|OO:ESLconnection_execute",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_execute" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_execute" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + if (obj2) { + res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLconnection_execute" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + } + if (obj3) { + res4 = SWIG_AsCharPtrAndSize(obj3, &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "ESLconnection_execute" "', argument " "4"" of type '" "char const *""'"); + } + arg4 = reinterpret_cast< char * >(buf4); + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (ESLevent *)(arg1)->execute((char const *)arg2,(char const *)arg3,(char const *)arg4); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, SWIG_POINTER_OWN | 0 ); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ESLconnection_executeAsync(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLconnection *arg1 = (ESLconnection *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) NULL ; + char *arg4 = (char *) NULL ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + ESLevent *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO|OO:ESLconnection_executeAsync",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_executeAsync" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_executeAsync" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + if (obj2) { + res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLconnection_executeAsync" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + } + if (obj3) { + res4 = SWIG_AsCharPtrAndSize(obj3, &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "ESLconnection_executeAsync" "', argument " "4"" of type '" "char const *""'"); + } + arg4 = reinterpret_cast< char * >(buf4); + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (ESLevent *)(arg1)->executeAsync((char const *)arg2,(char const *)arg3,(char const *)arg4); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, SWIG_POINTER_OWN | 0 ); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ESLconnection_setAsyncExecute(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLconnection *arg1 = (ESLconnection *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"OO:ESLconnection_setAsyncExecute",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_setAsyncExecute" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_setAsyncExecute" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)(arg1)->setAsyncExecute((char const *)arg2); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_From_int(static_cast< int >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ESLconnection_setEventLock(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLconnection *arg1 = (ESLconnection *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"OO:ESLconnection_setEventLock",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_setEventLock" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_setEventLock" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)(arg1)->setEventLock((char const *)arg2); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_From_int(static_cast< int >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ESLconnection_disconnect(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLconnection *arg1 = (ESLconnection *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"O:ESLconnection_disconnect",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_disconnect" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)(arg1)->disconnect(); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *ESLconnection_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_ESLconnection, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_eslSetLogLevel(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int val1 ; + int ecode1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:eslSetLogLevel",&obj0)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "eslSetLogLevel" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + eslSetLogLevel(arg1); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +static PyMethodDef SwigMethods[] = { + { (char *)"SWIG_PyInstanceMethod_New", (PyCFunction)SWIG_PyInstanceMethod_New, METH_O, NULL}, + { (char *)"ESLevent_event_set", _wrap_ESLevent_event_set, METH_VARARGS, NULL}, + { (char *)"ESLevent_event_get", _wrap_ESLevent_event_get, METH_VARARGS, NULL}, + { (char *)"ESLevent_serialized_string_set", _wrap_ESLevent_serialized_string_set, METH_VARARGS, NULL}, + { (char *)"ESLevent_serialized_string_get", _wrap_ESLevent_serialized_string_get, METH_VARARGS, NULL}, + { (char *)"ESLevent_mine_set", _wrap_ESLevent_mine_set, METH_VARARGS, NULL}, + { (char *)"ESLevent_mine_get", _wrap_ESLevent_mine_get, METH_VARARGS, NULL}, + { (char *)"new_ESLevent", _wrap_new_ESLevent, METH_VARARGS, NULL}, + { (char *)"delete_ESLevent", _wrap_delete_ESLevent, METH_VARARGS, NULL}, + { (char *)"ESLevent_serialize", _wrap_ESLevent_serialize, METH_VARARGS, NULL}, + { (char *)"ESLevent_setPriority", _wrap_ESLevent_setPriority, METH_VARARGS, NULL}, + { (char *)"ESLevent_getHeader", _wrap_ESLevent_getHeader, METH_VARARGS, NULL}, + { (char *)"ESLevent_getBody", _wrap_ESLevent_getBody, METH_VARARGS, NULL}, + { (char *)"ESLevent_getType", _wrap_ESLevent_getType, METH_VARARGS, NULL}, + { (char *)"ESLevent_addBody", _wrap_ESLevent_addBody, METH_VARARGS, NULL}, + { (char *)"ESLevent_addHeader", _wrap_ESLevent_addHeader, METH_VARARGS, NULL}, + { (char *)"ESLevent_pushHeader", _wrap_ESLevent_pushHeader, METH_VARARGS, NULL}, + { (char *)"ESLevent_unshiftHeader", _wrap_ESLevent_unshiftHeader, METH_VARARGS, NULL}, + { (char *)"ESLevent_delHeader", _wrap_ESLevent_delHeader, METH_VARARGS, NULL}, + { (char *)"ESLevent_firstHeader", _wrap_ESLevent_firstHeader, METH_VARARGS, NULL}, + { (char *)"ESLevent_nextHeader", _wrap_ESLevent_nextHeader, METH_VARARGS, NULL}, + { (char *)"ESLevent_swigregister", ESLevent_swigregister, METH_VARARGS, NULL}, + { (char *)"new_ESLconnection", _wrap_new_ESLconnection, METH_VARARGS, NULL}, + { (char *)"delete_ESLconnection", _wrap_delete_ESLconnection, METH_VARARGS, NULL}, + { (char *)"ESLconnection_socketDescriptor", _wrap_ESLconnection_socketDescriptor, METH_VARARGS, NULL}, + { (char *)"ESLconnection_connected", _wrap_ESLconnection_connected, METH_VARARGS, NULL}, + { (char *)"ESLconnection_getInfo", _wrap_ESLconnection_getInfo, METH_VARARGS, NULL}, + { (char *)"ESLconnection_send", _wrap_ESLconnection_send, METH_VARARGS, NULL}, + { (char *)"ESLconnection_sendRecv", _wrap_ESLconnection_sendRecv, METH_VARARGS, NULL}, + { (char *)"ESLconnection_api", _wrap_ESLconnection_api, METH_VARARGS, NULL}, + { (char *)"ESLconnection_bgapi", _wrap_ESLconnection_bgapi, METH_VARARGS, NULL}, + { (char *)"ESLconnection_sendEvent", _wrap_ESLconnection_sendEvent, METH_VARARGS, NULL}, + { (char *)"ESLconnection_sendMSG", _wrap_ESLconnection_sendMSG, METH_VARARGS, NULL}, + { (char *)"ESLconnection_recvEvent", _wrap_ESLconnection_recvEvent, METH_VARARGS, NULL}, + { (char *)"ESLconnection_recvEventTimed", _wrap_ESLconnection_recvEventTimed, METH_VARARGS, NULL}, + { (char *)"ESLconnection_filter", _wrap_ESLconnection_filter, METH_VARARGS, NULL}, + { (char *)"ESLconnection_events", _wrap_ESLconnection_events, METH_VARARGS, NULL}, + { (char *)"ESLconnection_execute", _wrap_ESLconnection_execute, METH_VARARGS, NULL}, + { (char *)"ESLconnection_executeAsync", _wrap_ESLconnection_executeAsync, METH_VARARGS, NULL}, + { (char *)"ESLconnection_setAsyncExecute", _wrap_ESLconnection_setAsyncExecute, METH_VARARGS, NULL}, + { (char *)"ESLconnection_setEventLock", _wrap_ESLconnection_setEventLock, METH_VARARGS, NULL}, + { (char *)"ESLconnection_disconnect", _wrap_ESLconnection_disconnect, METH_VARARGS, NULL}, + { (char *)"ESLconnection_swigregister", ESLconnection_swigregister, METH_VARARGS, NULL}, + { (char *)"eslSetLogLevel", _wrap_eslSetLogLevel, METH_VARARGS, NULL}, + { NULL, NULL, 0, NULL } +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ + +static swig_type_info _swigt__p_ESLconnection = {"_p_ESLconnection", "ESLconnection *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_ESLevent = {"_p_ESLevent", "ESLevent *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_esl_event_t = {"_p_esl_event_t", "esl_event_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_esl_priority_t = {"_p_esl_priority_t", "esl_priority_t *", 0, 0, (void*)0, 0}; + +static swig_type_info *swig_type_initial[] = { + &_swigt__p_ESLconnection, + &_swigt__p_ESLevent, + &_swigt__p_char, + &_swigt__p_esl_event_t, + &_swigt__p_esl_priority_t, +}; + +static swig_cast_info _swigc__p_ESLconnection[] = { {&_swigt__p_ESLconnection, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_ESLevent[] = { {&_swigt__p_ESLevent, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_esl_event_t[] = { {&_swigt__p_esl_event_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_esl_priority_t[] = { {&_swigt__p_esl_priority_t, 0, 0, 0},{0, 0, 0, 0}}; + +static swig_cast_info *swig_cast_initial[] = { + _swigc__p_ESLconnection, + _swigc__p_ESLevent, + _swigc__p_char, + _swigc__p_esl_event_t, + _swigc__p_esl_priority_t, +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ + +static swig_const_info swig_const_table[] = { +{0, 0, 0, 0.0, 0, 0}}; + +#ifdef __cplusplus +} +#endif +/* ----------------------------------------------------------------------------- + * Type initialization: + * This problem is tough by the requirement that no dynamic + * memory is used. Also, since swig_type_info structures store pointers to + * swig_cast_info structures and swig_cast_info structures store pointers back + * to swig_type_info structures, we need some lookup code at initialization. + * The idea is that swig generates all the structures that are needed. + * The runtime then collects these partially filled structures. + * The SWIG_InitializeModule function takes these initial arrays out of + * swig_module, and does all the lookup, filling in the swig_module.types + * array with the correct data and linking the correct swig_cast_info + * structures together. + * + * The generated swig_type_info structures are assigned statically to an initial + * array. We just loop through that array, and handle each type individually. + * First we lookup if this type has been already loaded, and if so, use the + * loaded structure instead of the generated one. Then we have to fill in the + * cast linked list. The cast data is initially stored in something like a + * two-dimensional array. Each row corresponds to a type (there are the same + * number of rows as there are in the swig_type_initial array). Each entry in + * a column is one of the swig_cast_info structures for that type. + * The cast_initial array is actually an array of arrays, because each row has + * a variable number of columns. So to actually build the cast linked list, + * we find the array of casts associated with the type, and loop through it + * adding the casts to the list. The one last trick we need to do is making + * sure the type pointer in the swig_cast_info struct is correct. + * + * First off, we lookup the cast->type name to see if it is already loaded. + * There are three cases to handle: + * 1) If the cast->type has already been loaded AND the type we are adding + * casting info to has not been loaded (it is in this module), THEN we + * replace the cast->type pointer with the type pointer that has already + * been loaded. + * 2) If BOTH types (the one we are adding casting info to, and the + * cast->type) are loaded, THEN the cast info has already been loaded by + * the previous module so we just ignore it. + * 3) Finally, if cast->type has not already been loaded, then we add that + * swig_cast_info to the linked list (because the cast->type) pointer will + * be correct. + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#if 0 +} /* c-mode */ +#endif +#endif + +#if 0 +#define SWIGRUNTIME_DEBUG +#endif + + +SWIGRUNTIME void +SWIG_InitializeModule(void *clientdata) { + size_t i; + swig_module_info *module_head, *iter; + int found, init; + + /* check to see if the circular list has been setup, if not, set it up */ + if (swig_module.next==0) { + /* Initialize the swig_module */ + swig_module.type_initial = swig_type_initial; + swig_module.cast_initial = swig_cast_initial; + swig_module.next = &swig_module; + init = 1; + } else { + init = 0; + } + + /* Try and load any already created modules */ + module_head = SWIG_GetModule(clientdata); + if (!module_head) { + /* This is the first module loaded for this interpreter */ + /* so set the swig module into the interpreter */ + SWIG_SetModule(clientdata, &swig_module); + module_head = &swig_module; + } else { + /* the interpreter has loaded a SWIG module, but has it loaded this one? */ + found=0; + iter=module_head; + do { + if (iter==&swig_module) { + found=1; + break; + } + iter=iter->next; + } while (iter!= module_head); + + /* if the is found in the list, then all is done and we may leave */ + if (found) return; + /* otherwise we must add out module into the list */ + swig_module.next = module_head->next; + module_head->next = &swig_module; + } + + /* When multiple interpreters are used, a module could have already been initialized in + a different interpreter, but not yet have a pointer in this interpreter. + In this case, we do not want to continue adding types... everything should be + set up already */ + if (init == 0) return; + + /* Now work on filling in swig_module.types */ +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: size %d\n", swig_module.size); +#endif + for (i = 0; i < swig_module.size; ++i) { + swig_type_info *type = 0; + swig_type_info *ret; + swig_cast_info *cast; + +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); +#endif + + /* if there is another module already loaded */ + if (swig_module.next != &swig_module) { + type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); + } + if (type) { + /* Overwrite clientdata field */ +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: found type %s\n", type->name); +#endif + if (swig_module.type_initial[i]->clientdata) { + type->clientdata = swig_module.type_initial[i]->clientdata; +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name); +#endif + } + } else { + type = swig_module.type_initial[i]; + } + + /* Insert casting types */ + cast = swig_module.cast_initial[i]; + while (cast->type) { + /* Don't need to add information already in the list */ + ret = 0; +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: look cast %s\n", cast->type->name); +#endif + if (swig_module.next != &swig_module) { + ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); +#ifdef SWIGRUNTIME_DEBUG + if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name); +#endif + } + if (ret) { + if (type == swig_module.type_initial[i]) { +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: skip old type %s\n", ret->name); +#endif + cast->type = ret; + ret = 0; + } else { + /* Check for casting already in the list */ + swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type); +#ifdef SWIGRUNTIME_DEBUG + if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name); +#endif + if (!ocast) ret = 0; + } + } + + if (!ret) { +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name); +#endif + if (type->cast) { + type->cast->prev = cast; + cast->next = type->cast; + } + type->cast = cast; + } + cast++; + } + /* Set entry in modules->types array equal to the type */ + swig_module.types[i] = type; + } + swig_module.types[i] = 0; + +#ifdef SWIGRUNTIME_DEBUG + printf("**** SWIG_InitializeModule: Cast List ******\n"); + for (i = 0; i < swig_module.size; ++i) { + int j = 0; + swig_cast_info *cast = swig_module.cast_initial[i]; + printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + while (cast->type) { + printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); + cast++; + ++j; + } + printf("---- Total casts: %d\n",j); + } + printf("**** SWIG_InitializeModule: Cast List ******\n"); +#endif +} + +/* This function will propagate the clientdata field of type to +* any new swig_type_info structures that have been added into the list +* of equivalent types. It is like calling +* SWIG_TypeClientData(type, clientdata) a second time. +*/ +SWIGRUNTIME void +SWIG_PropagateClientData(void) { + size_t i; + swig_cast_info *equiv; + static int init_run = 0; + + if (init_run) return; + init_run = 1; + + for (i = 0; i < swig_module.size; i++) { + if (swig_module.types[i]->clientdata) { + equiv = swig_module.types[i]->cast; + while (equiv) { + if (!equiv->converter) { + if (equiv->type && !equiv->type->clientdata) + SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); + } + equiv = equiv->next; + } + } + } +} + +#ifdef __cplusplus +#if 0 +{ + /* c-mode */ +#endif +} +#endif + + + +#ifdef __cplusplus +extern "C" { +#endif + + /* Python-specific SWIG API */ +#define SWIG_newvarlink() SWIG_Python_newvarlink() +#define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr) +#define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants) + + /* ----------------------------------------------------------------------------- + * global variable support code. + * ----------------------------------------------------------------------------- */ + + typedef struct swig_globalvar { + char *name; /* Name of global variable */ + PyObject *(*get_attr)(void); /* Return the current value */ + int (*set_attr)(PyObject *); /* Set the value */ + struct swig_globalvar *next; + } swig_globalvar; + + typedef struct swig_varlinkobject { + PyObject_HEAD + swig_globalvar *vars; + } swig_varlinkobject; + + SWIGINTERN PyObject * + swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) { +#if PY_VERSION_HEX >= 0x03000000 + return PyUnicode_InternFromString(""); +#else + return PyString_FromString(""); +#endif + } + + SWIGINTERN PyObject * + swig_varlink_str(swig_varlinkobject *v) { +#if PY_VERSION_HEX >= 0x03000000 + PyObject *str = PyUnicode_InternFromString("("); + PyObject *tail; + PyObject *joined; + swig_globalvar *var; + for (var = v->vars; var; var=var->next) { + tail = PyUnicode_FromString(var->name); + joined = PyUnicode_Concat(str, tail); + Py_DecRef(str); + Py_DecRef(tail); + str = joined; + if (var->next) { + tail = PyUnicode_InternFromString(", "); + joined = PyUnicode_Concat(str, tail); + Py_DecRef(str); + Py_DecRef(tail); + str = joined; + } + } + tail = PyUnicode_InternFromString(")"); + joined = PyUnicode_Concat(str, tail); + Py_DecRef(str); + Py_DecRef(tail); + str = joined; +#else + PyObject *str = PyString_FromString("("); + swig_globalvar *var; + for (var = v->vars; var; var=var->next) { + PyString_ConcatAndDel(&str,PyString_FromString(var->name)); + if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", ")); + } + PyString_ConcatAndDel(&str,PyString_FromString(")")); +#endif + return str; + } + + SWIGINTERN int + swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { + char *tmp; + PyObject *str = swig_varlink_str(v); + fprintf(fp,"Swig global variables "); + fprintf(fp,"%s\n", tmp = SWIG_Python_str_AsChar(str)); + SWIG_Python_str_DelForPy3(tmp); + Py_DECREF(str); + return 0; + } + + SWIGINTERN void + swig_varlink_dealloc(swig_varlinkobject *v) { + swig_globalvar *var = v->vars; + while (var) { + swig_globalvar *n = var->next; + free(var->name); + free(var); + var = n; + } + } + + SWIGINTERN PyObject * + swig_varlink_getattr(swig_varlinkobject *v, char *n) { + PyObject *res = NULL; + swig_globalvar *var = v->vars; + while (var) { + if (strcmp(var->name,n) == 0) { + res = (*var->get_attr)(); + break; + } + var = var->next; + } + if (res == NULL && !PyErr_Occurred()) { + PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n); + } + return res; + } + + SWIGINTERN int + swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) { + int res = 1; + swig_globalvar *var = v->vars; + while (var) { + if (strcmp(var->name,n) == 0) { + res = (*var->set_attr)(p); + break; + } + var = var->next; + } + if (res == 1 && !PyErr_Occurred()) { + PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n); + } + return res; + } + + SWIGINTERN PyTypeObject* + swig_varlink_type(void) { + static char varlink__doc__[] = "Swig var link object"; + static PyTypeObject varlink_type; + static int type_init = 0; + if (!type_init) { + const PyTypeObject tmp = { + /* PyObject header changed in Python 3 */ +#if PY_VERSION_HEX >= 0x03000000 + PyVarObject_HEAD_INIT(NULL, 0) +#else + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ +#endif + (char *)"swigvarlink", /* tp_name */ + sizeof(swig_varlinkobject), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) swig_varlink_dealloc, /* tp_dealloc */ + (printfunc) swig_varlink_print, /* tp_print */ + (getattrfunc) swig_varlink_getattr, /* tp_getattr */ + (setattrfunc) swig_varlink_setattr, /* tp_setattr */ + 0, /* tp_compare */ + (reprfunc) swig_varlink_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) swig_varlink_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + 0, /* tp_flags */ + varlink__doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ +#if PY_VERSION_HEX >= 0x02020000 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ +#endif +#if PY_VERSION_HEX >= 0x02030000 + 0, /* tp_del */ +#endif +#if PY_VERSION_HEX >= 0x02060000 + 0, /* tp_version */ +#endif +#ifdef COUNT_ALLOCS + 0,0,0,0 /* tp_alloc -> tp_next */ +#endif + }; + varlink_type = tmp; + type_init = 1; +#if PY_VERSION_HEX < 0x02020000 + varlink_type.ob_type = &PyType_Type; +#else + if (PyType_Ready(&varlink_type) < 0) + return NULL; +#endif + } + return &varlink_type; + } + + /* Create a variable linking object for use later */ + SWIGINTERN PyObject * + SWIG_Python_newvarlink(void) { + swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type()); + if (result) { + result->vars = 0; + } + return ((PyObject*) result); + } + + SWIGINTERN void + SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { + swig_varlinkobject *v = (swig_varlinkobject *) p; + swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar)); + if (gv) { + size_t size = strlen(name)+1; + gv->name = (char *)malloc(size); + if (gv->name) { + strncpy(gv->name,name,size); + gv->get_attr = get_attr; + gv->set_attr = set_attr; + gv->next = v->vars; + } + } + v->vars = gv; + } + + SWIGINTERN PyObject * + SWIG_globals(void) { + static PyObject *_SWIG_globals = 0; + if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink(); + return _SWIG_globals; + } + + /* ----------------------------------------------------------------------------- + * constants/methods manipulation + * ----------------------------------------------------------------------------- */ + + /* Install Constants */ + SWIGINTERN void + SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) { + PyObject *obj = 0; + size_t i; + for (i = 0; constants[i].type; ++i) { + switch(constants[i].type) { + case SWIG_PY_POINTER: + obj = SWIG_InternalNewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0); + break; + case SWIG_PY_BINARY: + obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype)); + break; + default: + obj = 0; + break; + } + if (obj) { + PyDict_SetItemString(d, constants[i].name, obj); + Py_DECREF(obj); + } + } + } + + /* -----------------------------------------------------------------------------*/ + /* Fix SwigMethods to carry the callback ptrs when needed */ + /* -----------------------------------------------------------------------------*/ + + SWIGINTERN void + SWIG_Python_FixMethods(PyMethodDef *methods, + swig_const_info *const_table, + swig_type_info **types, + swig_type_info **types_initial) { + size_t i; + for (i = 0; methods[i].ml_name; ++i) { + const char *c = methods[i].ml_doc; + if (c && (c = strstr(c, "swig_ptr: "))) { + int j; + swig_const_info *ci = 0; + const char *name = c + 10; + for (j = 0; const_table[j].type; ++j) { + if (strncmp(const_table[j].name, name, + strlen(const_table[j].name)) == 0) { + ci = &(const_table[j]); + break; + } + } + if (ci) { + void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0; + if (ptr) { + size_t shift = (ci->ptype) - types; + swig_type_info *ty = types_initial[shift]; + size_t ldoc = (c - methods[i].ml_doc); + size_t lptr = strlen(ty->name)+2*sizeof(void*)+2; + char *ndoc = (char*)malloc(ldoc + lptr + 10); + if (ndoc) { + char *buff = ndoc; + strncpy(buff, methods[i].ml_doc, ldoc); + buff += ldoc; + strncpy(buff, "swig_ptr: ", 10); + buff += 10; + SWIG_PackVoidPtr(buff, ptr, ty->name, lptr); + methods[i].ml_doc = ndoc; + } + } + } + } + } + } + +#ifdef __cplusplus +} +#endif + +/* -----------------------------------------------------------------------------* + * Partial Init method + * -----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +#endif + +SWIGEXPORT +#if PY_VERSION_HEX >= 0x03000000 +PyObject* +#else +void +#endif +SWIG_init(void) { + PyObject *m, *d, *md; +#if PY_VERSION_HEX >= 0x03000000 + static struct PyModuleDef SWIG_module = { +# if PY_VERSION_HEX >= 0x03020000 + PyModuleDef_HEAD_INIT, +# else + { + PyObject_HEAD_INIT(NULL) + NULL, /* m_init */ + 0, /* m_index */ + NULL, /* m_copy */ + }, +# endif + (char *) SWIG_name, + NULL, + -1, + SwigMethods, + NULL, + NULL, + NULL, + NULL + }; +#endif + +#if defined(SWIGPYTHON_BUILTIN) + static SwigPyClientData SwigPyObject_clientdata = { + 0, 0, 0, 0, 0, 0, 0 + }; + static PyGetSetDef this_getset_def = { + (char *)"this", &SwigPyBuiltin_ThisClosure, NULL, NULL, NULL + }; + static SwigPyGetSet thisown_getset_closure = { + (PyCFunction) SwigPyObject_own, + (PyCFunction) SwigPyObject_own + }; + static PyGetSetDef thisown_getset_def = { + (char *)"thisown", SwigPyBuiltin_GetterClosure, SwigPyBuiltin_SetterClosure, NULL, &thisown_getset_closure + }; + PyObject *metatype_args; + PyTypeObject *builtin_pytype; + int builtin_base_count; + swig_type_info *builtin_basetype; + PyObject *tuple; + PyGetSetDescrObject *static_getset; + PyTypeObject *metatype; + SwigPyClientData *cd; + PyObject *public_interface, *public_symbol; + PyObject *this_descr; + PyObject *thisown_descr; + int i; + + (void)builtin_pytype; + (void)builtin_base_count; + (void)builtin_basetype; + (void)tuple; + (void)static_getset; + + /* metatype is used to implement static member variables. */ + metatype_args = Py_BuildValue("(s(O){})", "SwigPyObjectType", &PyType_Type); + assert(metatype_args); + metatype = (PyTypeObject *) PyType_Type.tp_call((PyObject *) &PyType_Type, metatype_args, NULL); + assert(metatype); + Py_DECREF(metatype_args); + metatype->tp_setattro = (setattrofunc) &SwigPyObjectType_setattro; + assert(PyType_Ready(metatype) >= 0); +#endif + + /* Fix SwigMethods to carry the callback ptrs when needed */ + SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial); + +#if PY_VERSION_HEX >= 0x03000000 + m = PyModule_Create(&SWIG_module); +#else + m = Py_InitModule((char *) SWIG_name, SwigMethods); +#endif + md = d = PyModule_GetDict(m); + (void)md; + + SWIG_InitializeModule(0); + +#ifdef SWIGPYTHON_BUILTIN + SwigPyObject_stype = SWIG_MangledTypeQuery("_p_SwigPyObject"); + assert(SwigPyObject_stype); + cd = (SwigPyClientData*) SwigPyObject_stype->clientdata; + if (!cd) { + SwigPyObject_stype->clientdata = &SwigPyObject_clientdata; + SwigPyObject_clientdata.pytype = SwigPyObject_TypeOnce(); + } else if (SwigPyObject_TypeOnce()->tp_basicsize != cd->pytype->tp_basicsize) { + PyErr_SetString(PyExc_RuntimeError, "Import error: attempted to load two incompatible swig-generated modules."); +# if PY_VERSION_HEX >= 0x03000000 + return NULL; +# else + return; +# endif + } + + /* All objects have a 'this' attribute */ + this_descr = PyDescr_NewGetSet(SwigPyObject_type(), &this_getset_def); + (void)this_descr; + + /* All objects have a 'thisown' attribute */ + thisown_descr = PyDescr_NewGetSet(SwigPyObject_type(), &thisown_getset_def); + (void)thisown_descr; + + public_interface = PyList_New(0); + public_symbol = 0; + (void)public_symbol; + + PyDict_SetItemString(md, "__all__", public_interface); + Py_DECREF(public_interface); + for (i = 0; SwigMethods[i].ml_name != NULL; ++i) + SwigPyBuiltin_AddPublicSymbol(public_interface, SwigMethods[i].ml_name); + for (i = 0; swig_const_table[i].name != 0; ++i) + SwigPyBuiltin_AddPublicSymbol(public_interface, swig_const_table[i].name); +#endif + + SWIG_InstallConstants(d,swig_const_table); + + + /* Initialize threading */ + SWIG_PYTHON_INITIALIZE_THREADS; +#if PY_VERSION_HEX >= 0x03000000 + return m; +#else + return; +#endif +} + diff --git a/libs/esl/python3/events.py b/libs/esl/python3/events.py new file mode 100644 index 0000000000..2c59043447 --- /dev/null +++ b/libs/esl/python3/events.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python + +import string +import sys + +from ESL import * + +con = ESLconnection("localhost","8021","ClueCon") +#are we connected? + +if con.connected: + + con.events("plain", "all"); + + while 1: + #my $e = $con->recvEventTimed(100); + e = con.recvEvent() + + if e: + print e.serialize() diff --git a/libs/esl/python3/python-config b/libs/esl/python3/python-config new file mode 100644 index 0000000000..cb4a6eff0a --- /dev/null +++ b/libs/esl/python3/python-config @@ -0,0 +1,55 @@ +#!/usr/bin/env python3 + +from __future__ import print_function +import sys +import os +import getopt +from distutils import sysconfig + +valid_opts = ['prefix', 'exec-prefix', 'includes', 'libs', 'cflags', + 'ldflags', 'help'] + +def exit_with_usage(code=1): + print("Usage: %s [%s]" % (sys.argv[0], '|'.join('--'+opt for opt in valid_opts)), file=sys.stderr) + sys.exit(code) + +try: + opts, args = getopt.getopt(sys.argv[1:], '', valid_opts) +except getopt.error: + exit_with_usage() + +if not opts: + exit_with_usage() + +opt = opts[0][0] + +pyver = sysconfig.get_config_var('LDVERSION') +if pyver == None: + pyver = sysconfig.get_config_var('VERSION') +getvar = sysconfig.get_config_var + +if opt == '--help': + exit_with_usage(0) + +elif opt == '--prefix': + print(sysconfig.PREFIX) + +elif opt == '--exec-prefix': + print(sysconfig.EXEC_PREFIX) + +elif opt in ('--includes', '--cflags'): + flags = ['-I' + sysconfig.get_python_inc(), + '-I' + sysconfig.get_python_inc(plat_specific=True)] + if opt == '--cflags': + flags.extend(getvar('CFLAGS').split()) + print(' '.join(flags)) + +elif opt in ('--libs', '--ldflags'): + libs = getvar('LIBS').split() + getvar('SYSLIBS').split() + libs.append('-lpython'+pyver) + # add the prefix/lib/pythonX.Y/config dir, but only if there is no + # shared library in prefix/lib/. + if opt == '--ldflags' and not getvar('Py_ENABLE_SHARED'): + libs.insert(0, '-L' + getvar('LIBPL')) + print(' '.join(libs)) + diff --git a/libs/esl/python3/server.py b/libs/esl/python3/server.py new file mode 100644 index 0000000000..deba5f2ab9 --- /dev/null +++ b/libs/esl/python3/server.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python + +import SocketServer +from ESL import * + +class ESLRequestHandler(SocketServer.BaseRequestHandler ): + def setup(self): + print self.client_address, 'connected!' + + fd = self.request.fileno() + print fd + + con = ESLconnection(fd) + print "Connected: " + print con.connected() + if con.connected(): + + info = con.getInfo() + + uuid = info.getHeader("unique-id") + print uuid + con.execute("answer", "", uuid) + con.execute("playback", "/ram/swimp.raw", uuid); + +#server host is a tuple ('host', port) +server = SocketServer.ThreadingTCPServer(('', 8040), ESLRequestHandler) +server.serve_forever() + + diff --git a/libs/esl/python3/single_command.py b/libs/esl/python3/single_command.py new file mode 100644 index 0000000000..c47c57c13c --- /dev/null +++ b/libs/esl/python3/single_command.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python + +import string +import sys +from optparse import OptionParser +from ESL import * + +def main(argv): + + try: + + parser = OptionParser() + parser.add_option("-a", "--auth", dest="auth", default="ClueCon", + help="ESL password") + parser.add_option("-s", "--server", dest="server", default="127.0.0.1", + help="FreeSWITCH server IP address") + parser.add_option("-p", "--port", dest="port", default="8021", + help="FreeSWITCH server event socket port") + parser.add_option("-c", "--command", dest="command", + help="command to run, surround mutli word commands in \"\'s") + + (options, args) = parser.parse_args() + + + con = ESLconnection(options.server, options.port, options.auth) + #are we connected? + + if con.connected(): + #run command + e = con.api(options.command) + print e.getBody() + + else: + + print "Not Connected" + sys.exit(2) + + except: + + print parser.get_usage() + +if __name__ == "__main__": + main(sys.argv[1:]) \ No newline at end of file diff --git a/libs/esl/src/esl.c b/libs/esl/src/esl.c index e23144b9c0..825d89dd54 100644 --- a/libs/esl/src/esl.c +++ b/libs/esl/src/esl.c @@ -1444,7 +1444,7 @@ ESL_DECLARE(esl_status_t) esl_recv_event(esl_handle_t *handle, int check_q, esl_ } } - if (beg && (cl = esl_event_get_header(handle->last_ievent, "content-length"))) { + if (beg && esl_event_get_header(handle->last_ievent, "content-length")) { handle->last_ievent->body = strdup(beg); } diff --git a/libs/esl/src/esl_event.c b/libs/esl/src/esl_event.c index fa51194853..cca7899d80 100644 --- a/libs/esl/src/esl_event.c +++ b/libs/esl/src/esl_event.c @@ -54,6 +54,8 @@ static char *my_dup(const char *s) #define FREE(ptr) esl_safe_free(ptr) #endif +static void free_header(esl_event_header_t **header); + /* make sure this is synced with the esl_event_types_t enum in esl_types.h also never put any new ones before EVENT_ALL */ @@ -130,6 +132,7 @@ static const char *EVENT_NAMES[] = { "SEND_INFO", "RECV_INFO", "RECV_RTCP_MESSAGE", + "SEND_RTCP_MESSAGE", "CALL_SECURE", "NAT", "RECORD_START", @@ -319,27 +322,8 @@ ESL_DECLARE(esl_status_t) esl_event_del_header_val(esl_event_t *event, const cha if (hp == event->last_header || !hp->next) { event->last_header = lp; } - FREE(hp->name); - if (hp->idx) { - int i = 0; - - for (i = 0; i < hp->idx; i++) { - FREE(hp->array[i]); - } - FREE(hp->array); - } - - FREE(hp->value); - - memset(hp, 0, sizeof(*hp)); -#ifdef ESL_EVENT_RECYCLE - if (esl_queue_trypush(EVENT_HEADER_RECYCLE_QUEUE, hp) != ESL_SUCCESS) { - FREE(hp); - } -#else - FREE(hp); -#endif + free_header(&hp); status = ESL_SUCCESS; } else { lp = hp; @@ -369,7 +353,34 @@ static esl_event_header_t *new_header(const char *header_name) header->name = DUP(header_name); return header; +} +static void free_header(esl_event_header_t **header) +{ + assert(header); + + if (*header) { + FREE((*header)->name); + + if ((*header)->idx) { + int i = 0; + + for (i = 0; i < (*header)->idx; i++) { + FREE((*header)->array[i]); + } + FREE((*header)->array); + } + + FREE((*header)->value); + +#ifdef ESL_EVENT_RECYCLE + if (esl_queue_trypush(EVENT_HEADER_RECYCLE_QUEUE, *header) != ESL_SUCCESS) { + FREE(*header); + } +#else + FREE(*header); +#endif + } } ESL_DECLARE(int) esl_event_add_array(esl_event_t *event, const char *var, const char *val) @@ -437,10 +448,11 @@ static esl_status_t esl_event_base_add_header(esl_event_t *event, esl_stack_t st } if (index_ptr || (stack & ESL_STACK_PUSH) || (stack & ESL_STACK_UNSHIFT)) { + esl_event_header_t *tmp_header = NULL; if (!(header = esl_event_get_header_ptr(event, header_name)) && index_ptr) { - header = new_header(header_name); + tmp_header = header = new_header(header_name); if (esl_test_flag(event, ESL_EF_UNIQ_HEADERS)) { esl_event_del_header(event, header_name); @@ -472,9 +484,14 @@ static esl_status_t esl_event_base_add_header(esl_event_t *event, esl_stack_t st exists = 1; } + FREE(data); goto redraw; } + } else if (tmp_header) { + free_header(&tmp_header); } + + FREE(data); goto end; } else { if ((stack & ESL_STACK_PUSH) || (stack & ESL_STACK_UNSHIFT)) { @@ -675,29 +692,7 @@ ESL_DECLARE(void) esl_event_destroy(esl_event_t **event) for (hp = ep->headers; hp;) { this = hp; hp = hp->next; - FREE(this->name); - - if (this->idx) { - int i = 0; - - for (i = 0; i < this->idx; i++) { - FREE(this->array[i]); - } - FREE(this->array); - } - - FREE(this->value); - - -#ifdef ESL_EVENT_RECYCLE - if (esl_queue_trypush(EVENT_HEADER_RECYCLE_QUEUE, this) != ESL_SUCCESS) { - FREE(this); - } -#else - FREE(this); -#endif - - + free_header(&this); } FREE(ep->body); FREE(ep->subclass_name); diff --git a/libs/esl/src/include/esl_event.h b/libs/esl/src/include/esl_event.h index de070ad723..01e7ada07e 100644 --- a/libs/esl/src/include/esl_event.h +++ b/libs/esl/src/include/esl_event.h @@ -120,6 +120,7 @@ typedef enum { ESL_EVENT_SEND_INFO, ESL_EVENT_RECV_INFO, ESL_EVENT_RECV_RTCP_MESSAGE, + ESL_EVENT_SEND_RTCP_MESSAGE, ESL_EVENT_CALL_SECURE, ESL_EVENT_NAT, ESL_EVENT_RECORD_START, diff --git a/libs/freetdm/.gitignore b/libs/freetdm/.gitignore deleted file mode 100644 index da2caa7d87..0000000000 --- a/libs/freetdm/.gitignore +++ /dev/null @@ -1,39 +0,0 @@ -*.o -*.lo -*.so -*.a -*.orig -*.rej -*.log - -Makefile -config.* -configure -libtool -aclocal.m4 -build/libtool.m4 -build/ltoptions.m4 -build/ltsugar.m4 -build/ltversion.m4 -build/lt~obsolete.m4 - -testanalog -testapp -testboost -testcid -testpri -testr2 -testsangomaboost -testtones - -!/msvc/testanalog/ -!/msvc/testboost/ - -!/sample/boost/Makefile -!/sample/dso/Makefile - -freetdm.2010.sdf -/mod_freetdm/Win32/ -/msvc/Win32/ -/src/ftmod/*/Win32/ -/src/ftmod/*/x64/ diff --git a/libs/freetdm/.update b/libs/freetdm/.update deleted file mode 100644 index b537cc4f2d..0000000000 --- a/libs/freetdm/.update +++ /dev/null @@ -1 +0,0 @@ -Fri Feb 3 11:55:29 PST 2012 diff --git a/libs/freetdm/AUTHORS b/libs/freetdm/AUTHORS deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/libs/freetdm/CMakeLists.txt b/libs/freetdm/CMakeLists.txt deleted file mode 100644 index 24cbf7c9eb..0000000000 --- a/libs/freetdm/CMakeLists.txt +++ /dev/null @@ -1,244 +0,0 @@ -# -# cmake file that generate build files for freetdm. -# this automatically includes the tests and also -# mod_freetdm -# -# Arnaldo M Pereira -# -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(freetdm) - -ADD_SUBDIRECTORY(sample) -ADD_SUBDIRECTORY(mod_freetdm) - -# includes -SET(freetdm_INCLUDES - ${PROJECT_SOURCE_DIR}/src/include - ${PROJECT_SOURCE_DIR}/src/isdn/include - ${PROJECT_SOURCE_DIR}/src/include/private - ${PROJECT_SOURCE_DIR}/src/ftmod/ftmod_sangoma_boost -) -INCLUDE_DIRECTORIES(${freetdm_INCLUDES}) -LINK_DIRECTORIES(${freetdm_BINARY_DIR}) - -# optional includes -IF(DEFINED SNGSS7) - SET(freetdm_INCLUDES ${freetdm_INCLUDES} /usr/include/sng_ss7) -ENDIF(DEFINED SNGSS7) - -IF(DEFINED SNGISDN) - SET(freetdm_INCLUDES ${freetdm_INCLUDES} /usr/include/sng_isdn) -ENDIF(DEFINED SNGISDN) - -# definitions / CFLAGS -ADD_DEFINITIONS(-DFTDM_CONFIG_DIR="/FIXME" -DFTDM_MOD_DIR="/FIXME") -IF(DEFINED WIN32) - ADD_DEFINITIONS(-DFREETDM_EXPORTS -DTELETONE_EXPORTS -DMOD_EXPORTS -DDLL_EXPORTS) -ENDIF(DEFINED WIN32) -IF(DEFINED SNGISDN) - SET(freetdm_INCLUDES ${freetdm_INCLUDES} /usr/include/sng_isdn) -ENDIF(DEFINED SNGISDN) - -# lib sources -SET(freetdm_SOURCES - ${PROJECT_SOURCE_DIR}/src/hashtable.c - ${PROJECT_SOURCE_DIR}/src/hashtable_itr.c - ${PROJECT_SOURCE_DIR}/src/ftdm_io.c - ${PROJECT_SOURCE_DIR}/src/ftdm_queue.c - ${PROJECT_SOURCE_DIR}/src/ftdm_sched.c - ${PROJECT_SOURCE_DIR}/src/ftdm_call_utils.c - ${PROJECT_SOURCE_DIR}/src/ftdm_config.c - ${PROJECT_SOURCE_DIR}/src/ftdm_callerid.c - ${PROJECT_SOURCE_DIR}/src/fsk.c - ${PROJECT_SOURCE_DIR}/src/uart.c - ${PROJECT_SOURCE_DIR}/src/g711.c - ${PROJECT_SOURCE_DIR}/src/libteletone_detect.c - ${PROJECT_SOURCE_DIR}/src/libteletone_generate.c - ${PROJECT_SOURCE_DIR}/src/ftdm_buffer.c - ${PROJECT_SOURCE_DIR}/src/ftdm_threadmutex.c - ${PROJECT_SOURCE_DIR}/src/ftdm_dso.c - ${PROJECT_SOURCE_DIR}/src/ftdm_cpu_monitor.c -) - -# libfreetdm.so -ADD_LIBRARY(${PROJECT_NAME} SHARED ${freetdm_SOURCES}) - -IF(NOT DEFINED WIN32) - TARGET_LINK_LIBRARIES(${PROJECT_NAME} m pthread dl) -ENDIF(NOT DEFINED WIN32) - -REMOVE_DEFINITIONS(-DLL_EXPORTS) - -# tools & tests -IF(NOT DEFINED WIN32) - FOREACH(TOOL testtones testpri testr2 testapp testcid) - ADD_EXECUTABLE(${TOOL} ${PROJECT_SOURCE_DIR}/src/${TOOL}.c) - TARGET_LINK_LIBRARIES(${TOOL} -l${PROJECT_NAME}) - ADD_DEPENDENCIES(${TOOL} ${PROJECT_NAME}) - ENDFOREACH(TOOL) - - ADD_EXECUTABLE(detect_dtmf - ${PROJECT_SOURCE_DIR}/src/detect_dtmf.c - ${PROJECT_SOURCE_DIR}/src/libteletone_detect.c - ) - TARGET_LINK_LIBRARIES(detect_dtmf ${PROJECT_NAME}) - ADD_DEPENDENCIES(detect_dtmf ${PROJECT_NAME}) - - ADD_EXECUTABLE(detect_tones - ${PROJECT_SOURCE_DIR}/src/detect_tones.c - ${PROJECT_SOURCE_DIR}/src/libteletone_detect.c - ) - TARGET_LINK_LIBRARIES(detect_tones ${PROJECT_NAME}) - ADD_DEPENDENCIES(detect_tones ${PROJECT_NAME}) - - ADD_EXECUTABLE(testanalog - ${PROJECT_SOURCE_DIR}/src/testanalog.c - ) - TARGET_LINK_LIBRARIES(testanalog -l${PROJECT_NAME}) - ADD_DEPENDENCIES(testanalog ${PROJECT_NAME}) - - # optional tests/tools - IF(HAVE_SCTP) - ADD_EXECUTABLE(testboost src/testboost.c) - TARGET_LINK_LIBRARIES(testboost ${PROJECT_NAME}) - ENDIF(HAVE_SCTP) -ELSE(NOT DEFINED WIN32) - MESSAGE(WARNING "Not building tools/tests on WIN32 yet.") -ENDIF(NOT DEFINED WIN32) - -# -# ftmod modules -# -SET(ftmod_DIR ${PROJECT_SOURCE_DIR}/src/ftmod) - -IF(DEFINED WIN32) - SET(ftmod_ADDITIONAL_SOURCES - ${PROJECT_SOURCE_DIR}/src/ftdm_io.c - ${PROJECT_SOURCE_DIR}/src/ftdm_config.c - ${PROJECT_SOURCE_DIR}/src/ftdm_queue.c - ${PROJECT_SOURCE_DIR}/src/g711.c - ) - SET(module_list skel analog analog_em) -ELSE(DEFINED WIN32) - SET(module_list skel analog analog_em zt) -ENDIF(DEFINED WIN32) - -# build default modules -FOREACH(module ${module_list}) - ADD_LIBRARY(ftmod_${module} MODULE ${ftmod_DIR}/ftmod_${module}/ftmod_${module}.c ${ftmod_ADDITIONAL_SOURCES}) - TARGET_LINK_LIBRARIES(ftmod_${module} ${PROJECT_NAME}) -ENDFOREACH(module) - -# build isdn ftmod -IF(DEFINED BUILD_FTMOD_ISDN) - SET(ftmod_isdn_SOURCES - ${PROJECT_SOURCE_DIR}/src/isdn/EuroISDNStateNT.c - ${PROJECT_SOURCE_DIR}/src/isdn/EuroISDNStateTE.c - ${PROJECT_SOURCE_DIR}/src/isdn/mfifo.c - ${PROJECT_SOURCE_DIR}/src/isdn/Q921.c - ${PROJECT_SOURCE_DIR}/src/isdn/Q931api.c - ${PROJECT_SOURCE_DIR}/src/isdn/Q931.c - ${PROJECT_SOURCE_DIR}/src/isdn/Q931ie.c - ${PROJECT_SOURCE_DIR}/src/isdn/Q931mes.c - ${PROJECT_SOURCE_DIR}/src/isdn/Q931StateNT.c - ${PROJECT_SOURCE_DIR}/src/isdn/Q931StateTE.c - ${PROJECT_SOURCE_DIR}/src/isdn/nationalmes.c - ${PROJECT_SOURCE_DIR}/src/isdn/nationalStateNT.c - ${PROJECT_SOURCE_DIR}/src/isdn/nationalStateTE.c - ${PROJECT_SOURCE_DIR}/src/isdn/DMSmes.c - ${PROJECT_SOURCE_DIR}/src/isdn/DMSStateNT.c - ${PROJECT_SOURCE_DIR}/src/isdn/DMSStateTE.c - ${PROJECT_SOURCE_DIR}/src/isdn/5ESSmes.c - ${PROJECT_SOURCE_DIR}/src/isdn/5ESSStateNT.c - ${PROJECT_SOURCE_DIR}/src/isdn/5ESSStateTE.c - ${PROJECT_SOURCE_DIR}/src/isdn/Q932mes.c - ${ftmod_DIR}/ftmod_isdn/ftmod_isdn.c - ) - IF(NOT DEFINED WIN32) - ADD_DEFINITIONS(-D_GNU_SOURCE) - ENDIF(NOT DEFINED WIN32) - ADD_LIBRARY(ftmod_isdn MODULE ${ftmod_isdn_SOURCES}) - TARGET_LINK_LIBRARIES(ftmod_isdn ${PROJECT_NAME}) -ENDIF(DEFINED BUILD_FTMOD_ISDN) - -# from now on, optionals -IF(DEFINED LIBSANGOMA) - ADD_LIBRARY(ftmod_wanpipe MODULE ${ftmod_DIR}/ftmod_wanpipe/ftmod_wanpipe.c) - IF(DEFINED WIN32) - MESSAGE(WARNING "FIXME: look for wanpipe headers on win32") - ELSE(DEFINED WIN32) - ADD_DEFINITIONS(-D__LINUX__) - INCLUDE_DIRECTORIES(/usr/include/wanpipe) - ENDIF(DEFINED WIN32) - TARGET_LINK_LIBRARIES(ftmod_wanpipe sangoma ${PROJECT_NAME}) -ENDIF(DEFINED LIBSANGOMA) - -IF(DEFINED HAVE_SCTP) - ADD_LIBRARY(ftmod_sangoma_boost MODULE - ${ftmod_DIR}/ftmod_sangoma_boost/sangoma_boost_client.c - ${ftmod_DIR}/ftmod_sangoma_boost/ftmod_sangoma_boost.c - ) - TARGET_LINK_LIBRARIES(ftmod_sangoma_boost ${PROJECT_NAME}) -ENDIF(DEFINED HAVE_SCTP) - -IF(DEFINED LIBPRI) - ADD_LIBRARY(ftmod_libpri MODULE - ${ftmod_DIR}/ftmod_libpri/libpri_client.c - ${ftmod_DIR}/ftmod_libpri/ftmod_libpri.c - ) - TARGET_LINK_LIBRARIES(ftmod_libpri ${PROJECT_NAME}) -ENDIF(DEFINED LIBPRI) - -IF(DEFINED PRITAP) - ADD_LIBRARY(ftmod_pritap MODULE - ${ftmod_DIR}/ftmod_pritap/pritap_client.c - ${ftmod_DIR}/ftmod_pritap/ftmod_pritap.c - ) - TARGET_LINK_LIBRARIES(ftmod_pritap ${PROJECT_NAME} pri) -ENDIF(DEFINED PRITAP) - -IF(DEFINED SNGSS7) - ADD_LIBRARY(ftmod_sangoma_ss7 MODULE - ${ftmod_DIR}/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c - ${ftmod_DIR}/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c - ${ftmod_DIR}/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c - ${ftmod_DIR}/ftmod_sangoma_ss7/ftmod_sangoma_ss7_in.c - ${ftmod_DIR}/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c - ${ftmod_DIR}/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cntrl.c - ${ftmod_DIR}/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c - ${ftmod_DIR}/ftmod_sangoma_ss7/ftmod_sangoma_ss7_timers.c - ${ftmod_DIR}/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c - ${ftmod_DIR}/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c - ${ftmod_DIR}/ftmod_sangoma_ss7/ftmod_sangoma_ss7_sta.c - ${ftmod_DIR}/ftmod_sangoma_ss7/ftmod_sangoma_ss7_sts.c - ${ftmod_DIR}/ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.c - ) - IF(NOT DEFINED WIN32) - ADD_DEFINITIONS(-D_GNU_SOURCE) - ENDIF(NOT DEFINED WIN32) - TARGET_LINK_LIBRARIES(ftmod_sangoma_ss7 ${PROJECT_NAME} sng_ss7) -ENDIF(DEFINED SNGSS7) - -IF(DEFINED SNGISDN) - ADD_LIBRARY(ftmod_sangoma_isdn MODULE - ${ftmod_DIR}/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c - ${ftmod_DIR}/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c - ${ftmod_DIR}/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cntrl.c - ${ftmod_DIR}/ftmod_sangoma_isdn/ftmod_sangoma_isdn_trace.c - ${ftmod_DIR}/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c - ${ftmod_DIR}/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cntrl.c - ${ftmod_DIR}/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c - ${ftmod_DIR}/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c - ${ftmod_DIR}/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c - ${ftmod_DIR}/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c - ) - IF(NOT DEFINED WIN32) - ADD_DEFINITIONS(-D_GNU_SOURCE) - ENDIF(NOT DEFINED WIN32) - TARGET_LINK_LIBRARIES(ftmod_sangoma_isdn ${PROJECT_NAME} sng_isdn) -ENDIF(DEFINED SNGISDN) - -IF(DEFINED OPENR2) - ADD_LIBRARY(ftmod_r2 MODULE ${ftmod_DIR}/ftmod_r2/ftmod_r2.c) - TARGET_LINK_LIBRARIES(ftmod_r2 ${PROJECT_NAME} openr2) -ENDIF(DEFINED OPENR2) diff --git a/libs/freetdm/ChangeLog b/libs/freetdm/ChangeLog deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/libs/freetdm/Makefile.am b/libs/freetdm/Makefile.am deleted file mode 100644 index f6211e58e8..0000000000 --- a/libs/freetdm/Makefile.am +++ /dev/null @@ -1,290 +0,0 @@ -# Copyright (c) 2007-2014, Anthony Minessale II -# All rights reserved. -# -# 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 original author; nor the names of any contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "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 THE COPYRIGHT OWNER -# OR CONTRIBUTORS 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 -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -ACLOCAL_AMFLAGS = -I build -AUTOMAKE_OPTIONS = foreign - -SRC = src - -moddir = @modinstdir@ -libdir = @libdir@ -library_includedir = $(prefix)/include - -INCS = -I$(FT_SRCDIR)/$(SRC)/include -I$(FT_SRCDIR)/$(SRC)/include/private - -# we needed to separate CFLAGS in FTDM_COMPAT_CFLAGS and FTDM_CFLAGS due to -c99 which causes problems with wanpipe headers -FTDM_COMPAT_CFLAGS = $(INCS) -DFTDM_CONFIG_DIR=\"@confdir@\" -DFTDM_MOD_DIR=\"$(moddir)\" @COMP_VENDOR_COMPAT_CFLAGS@ @DEFS@ -FTDM_CFLAGS = $(INCS) -DFTDM_CONFIG_DIR=\"@confdir@\" -DFTDM_MOD_DIR=\"$(moddir)\" @COMP_VENDOR_CFLAGS@ @DEFS@ -COMPILE = $(CC) $(FTDM_CFLAGS) -LTCOMPILE = $(LIBTOOL) --mode=compile --tag=CC $(COMPILE) -LINK = $(LIBTOOL) --mode=link --tag=CC $(CC) $(FTDM_CFLAGS) $(LDFLAGS) -o $@ - - -# -# GNU pkgconfig file -# -EXTRA_DIST = freetdm.pc.in - -pkgconfigdir = @pkgconfigdir@ -pkgconfig_DATA = freetdm.pc - - -# -# libfreetdm -# -libfreetdm_la_SOURCES = \ - $(SRC)/hashtable.c \ - $(SRC)/hashtable_itr.c \ - $(SRC)/ftdm_io.c \ - $(SRC)/ftdm_state.c \ - $(SRC)/ftdm_queue.c \ - $(SRC)/ftdm_sched.c \ - $(SRC)/ftdm_call_utils.c \ - $(SRC)/ftdm_variables.c \ - $(SRC)/ftdm_config.c \ - $(SRC)/ftdm_callerid.c \ - $(SRC)/fsk.c \ - $(SRC)/uart.c \ - $(SRC)/g711.c \ - $(SRC)/libteletone_detect.c \ - $(SRC)/libteletone_generate.c \ - $(SRC)/ftdm_buffer.c \ - $(SRC)/ftdm_threadmutex.c \ - $(SRC)/ftdm_dso.c \ - $(SRC)/ftdm_cpu_monitor.c \ - $(SRC)/ftdm_backtrace.c - -library_include_HEADERS = \ - $(SRC)/include/freetdm.h \ - $(SRC)/include/ftdm_declare.h \ - $(SRC)/include/ftdm_threadmutex.h \ - $(SRC)/include/ftdm_os.h \ - $(SRC)/include/ftdm_call_utils.h \ - $(SRC)/include/ftdm_dso.h - -lib_LTLIBRARIES = libfreetdm.la -libfreetdm_la_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS) -libfreetdm_la_LDFLAGS = -version-info 1:0:0 $(AM_LDFLAGS) -libfreetdm_la_LIBADD = $(LIBS) - -core: libfreetdm.la -core-install: install-libLTLIBRARIES - -# -# tools & test programs -# -noinst_PROGRAMS = testtones detect_tones detect_dtmf testpri testr2 testanalog testapp testcid - -testapp_SOURCES = $(SRC)/testapp.c -testapp_LDADD = libfreetdm.la -testapp_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS) - -testcid_SOURCES = $(SRC)/testcid.c -testcid_LDADD = libfreetdm.la -testcid_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS) - -testtones_SOURCES = $(SRC)/testtones.c -testtones_LDADD = libfreetdm.la -testtones_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS) - -detect_tones_SOURCES = $(SRC)/detect_tones.c -detect_tones_LDADD = libfreetdm.la -detect_tones_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS) - -detect_dtmf_SOURCES = $(SRC)/detect_dtmf.c -detect_dtmf_LDADD = libfreetdm.la -detect_dtmf_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS) - -#testisdn_SOURCES = $(SRC)/testisdn.c -#testisdn_LDADD = libfreetdm.la -#testisdn_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS) - -testpri_SOURCES = $(SRC)/testpri.c -testpri_LDADD = libfreetdm.la -testpri_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS) - -testr2_SOURCES = $(SRC)/testr2.c -testr2_LDADD = libfreetdm.la -testr2_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS) - -testanalog_SOURCES = $(SRC)/testanalog.c -testanalog_LDADD = libfreetdm.la -testanalog_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS) - -# -# ftmod modules -# -mod_LTLIBRARIES = ftmod_zt.la ftmod_skel.la ftmod_analog.la ftmod_analog_em.la - -ftmod_zt_la_SOURCES = $(SRC)/ftmod/ftmod_zt/ftmod_zt.c -ftmod_zt_la_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS) -ftmod_zt_la_LDFLAGS = -shared -module -avoid-version -ftmod_zt_la_LIBADD = libfreetdm.la - -ftmod_skel_la_SOURCES = $(SRC)/ftmod/ftmod_skel/ftmod_skel.c -ftmod_skel_la_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS) -ftmod_skel_la_LDFLAGS = -shared -module -avoid-version -ftmod_skel_la_LIBADD = libfreetdm.la - -ftmod_analog_la_SOURCES = $(SRC)/ftmod/ftmod_analog/ftmod_analog.c -ftmod_analog_la_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS) -ftmod_analog_la_LDFLAGS = -shared -module -avoid-version -ftmod_analog_la_LIBADD = libfreetdm.la - -ftmod_analog_em_la_SOURCES = $(SRC)/ftmod/ftmod_analog_em/ftmod_analog_em.c -ftmod_analog_em_la_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS) -ftmod_analog_em_la_LDFLAGS = -shared -module -avoid-version -ftmod_analog_em_la_LIBADD = libfreetdm.la - -if HAVE_LIBSANGOMA -mod_LTLIBRARIES += ftmod_wanpipe.la -ftmod_wanpipe_la_SOURCES = $(SRC)/ftmod/ftmod_wanpipe/ftmod_wanpipe.c -# some structures within Wanpipe drivers are not c99 compatible, so we need to compile ftmod_wanpipe -# without c99 flags, use FTDM_COMPAT_CFLAGS instead -ftmod_wanpipe_la_CFLAGS = $(FTDM_COMPAT_CFLAGS) $(AM_CFLAGS) -D__LINUX__ -I/usr/include/wanpipe -ftmod_wanpipe_la_LDFLAGS = -shared -module -avoid-version -ftmod_wanpipe_la_LIBADD = libfreetdm.la -lsangoma -endif - -if HAVE_LIBISDN -mod_LTLIBRARIES += ftmod_isdn.la -ftmod_isdn_la_SOURCES = $(SRC)/ftmod/ftmod_isdn/ftmod_isdn.c -ftmod_isdn_la_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS) -D_GNU_SOURCE $(LIBISDN_CPPFLAGS) $(PCAP_CPPFLAGS) -ftmod_isdn_la_LDFLAGS = -shared -module -avoid-version $(LIBISDN_LDFLAGS) $(PCAP_LDFLAGS) -ftmod_isdn_la_LIBADD = libfreetdm.la $(LIBISDN_LIBS) $(PCAP_LIBS) -endif - -if HAVE_LIBPRI -mod_LTLIBRARIES += ftmod_libpri.la -ftmod_libpri_la_SOURCES = $(SRC)/ftmod/ftmod_libpri/ftmod_libpri.c $(SRC)/ftmod/ftmod_libpri/lpwrap_pri.c -ftmod_libpri_la_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS) $(LIBPRI_CPPFLAGS) -ftmod_libpri_la_LDFLAGS = -shared -module -avoid-version $(LIBPRI_LDFLAGS) -ftmod_libpri_la_LIBADD = libfreetdm.la $(LIBPRI_LIBS) -endif - -if HAVE_PRITAP -mod_LTLIBRARIES += ftmod_pritap.la -ftmod_pritap_la_SOURCES = $(SRC)/ftmod/ftmod_pritap/ftmod_pritap.c -ftmod_pritap_la_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS) -ftmod_pritap_la_LDFLAGS = -shared -module -avoid-version -ftmod_pritap_la_LIBADD = libfreetdm.la -lpri -endif - -if HAVE_SNG_SS7 -mod_LTLIBRARIES += ftmod_sangoma_ss7.la -ftmod_sangoma_ss7_la_SOURCES = \ - $(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c \ - $(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c \ - $(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c \ - $(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_in.c \ - $(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c \ - $(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cntrl.c \ - $(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c \ - $(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_timers.c \ - $(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c \ - $(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c \ - $(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_sta.c \ - $(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_sts.c \ - $(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.c \ - $(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_m2ua_xml.c \ - $(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_m2ua.c \ - $(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_relay.c - -ftmod_sangoma_ss7_la_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS) -D_GNU_SOURCE -ftmod_sangoma_ss7_la_LDFLAGS = -shared -module -avoid-version -ftmod_sangoma_ss7_la_LIBADD = libfreetdm.la -lsng_ss7 -endif - -if HAVE_SNG_ISDN -mod_LTLIBRARIES += ftmod_sangoma_isdn.la -ftmod_sangoma_isdn_la_SOURCES = \ - $(SRC)/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c \ - $(SRC)/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c \ - $(SRC)/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cntrl.c \ - $(SRC)/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_trace.c \ - $(SRC)/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_transfer.c \ - $(SRC)/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c \ - $(SRC)/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cntrl.c \ - $(SRC)/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c \ - $(SRC)/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c \ - $(SRC)/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c \ - $(SRC)/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c - -ftmod_sangoma_isdn_la_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS) -D_GNU_SOURCE -ftmod_sangoma_isdn_la_LDFLAGS = -shared -module -avoid-version -ftmod_sangoma_isdn_la_LIBADD = libfreetdm.la -lsng_isdn -endif - -if HAVE_OPENR2 -mod_LTLIBRARIES += ftmod_r2.la -ftmod_r2_la_SOURCES = $(SRC)/ftmod/ftmod_r2/ftmod_r2.c $(SRC)/ftmod/ftmod_r2/ftmod_r2_io_mf_lib.c -ftmod_r2_la_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS) -ftmod_r2_la_LDFLAGS = -shared -module -avoid-version -ftmod_r2_la_LIBADD = libfreetdm.la -lopenr2 -endif - -if HAVE_WAT -mod_LTLIBRARIES += ftmod_gsm.la -ftmod_gsm_la_SOURCES = $(SRC)/ftmod/ftmod_gsm/ftmod_gsm.c -ftmod_gsm_la_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS) -ftmod_gsm_la_LDFLAGS = -shared -module -avoid-version -ftmod_gsm_la_LIBADD = libfreetdm.la -lwat -endif - -if HAVE_MISDN -mod_LTLIBRARIES += ftmod_misdn.la -ftmod_misdn_la_SOURCES = $(SRC)/ftmod/ftmod_misdn/ftmod_misdn.c -ftmod_misdn_la_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS) $(MISDN_CFLAGS) -D_GNU_SOURCE -ftmod_misdn_la_LDFLAGS = -shared -module -avoid-version -ftmod_misdn_la_LIBADD = libfreetdm.la -endif - -dox doxygen: - doxygen $(FT_SRCDIR)/docs/Doxygen.conf - -mod_freetdm/mod_freetdm.so: libfreetdm.la mod_freetdm/mod_freetdm.c - $(MAKE) -C mod_freetdm - -mod_freetdm: mod_freetdm/mod_freetdm.so - -mod_freetdm-install: mod_freetdm - $(MAKE) -C mod_freetdm install - -mod_freetdm-clean: - @if [ -f mod_freetdm/mod_freetdm.so ] ; then \ - $(MAKE) -C mod_freetdm clean ; \ - fi - -install-data-local: - $(mkinstalldirs) $(DESTDIR)$(prefix) - $(mkinstalldirs) $(DESTDIR)@confdir@ - @[ -f "$(DESTDIR)@confdir@/freetdm.conf" ] || ( cp conf/*.conf $(DESTDIR)@confdir@) - @echo FreeTDM Installed diff --git a/libs/freetdm/NEWS b/libs/freetdm/NEWS deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/libs/freetdm/README b/libs/freetdm/README deleted file mode 100644 index 4ca13d19c9..0000000000 --- a/libs/freetdm/README +++ /dev/null @@ -1,3 +0,0 @@ -FreeTDM -http://wiki.freeswitch.org/wiki/FreeTDM - diff --git a/libs/freetdm/TODO b/libs/freetdm/TODO deleted file mode 100644 index 6b4cf71f5f..0000000000 --- a/libs/freetdm/TODO +++ /dev/null @@ -1,22 +0,0 @@ -== Interface inconsistency == -- enum_id member of ftdm_event_t is inconsistent. Most of the time is just for OOB events, the only other - type of event as of now is FTDM_EVENT_DTMF and is not using the enum_id member. I think we can get rid - of the FTDM_EVENT_DTMF and create ftdm_dtmf_event_t type instead of reusing ftdm_event_t - then ftdm_event_t would be renamed to ftdm_oob_event_t and the enum_id renamed to type, then ftdm_span_next_event() - will only return OOB events - -- Deprecate last_error members. - It requires a lot of discipline to set the last_error string for every failure. - It does not add much value to the user either, most of the errors are criptic and - cannot be shown to end users, we already provide extensive logging for problem - troubleshooting. - -- Implement threaded IO. - Currently IO modules only work on-demand, where the user (ie, FreeSWITCH) drives the read/write - of media. If the user stops reading, some functions are not possible - (DTMF detection or Hangup tone detection). It would be useful to implement a FreeTDM mode - where the media is driven by a group of threads that are always reading (and possibly writing) - then when the user does ftdm_channel_read(), the media would be read from the buffers filled - by the media thread and not from the underlying IO device, this gives a chance to FreeTDM to - still perform hangup detection or other media services even if the application is not reading. - diff --git a/libs/freetdm/acinclude.m4 b/libs/freetdm/acinclude.m4 deleted file mode 100644 index 097278b6ef..0000000000 --- a/libs/freetdm/acinclude.m4 +++ /dev/null @@ -1,2 +0,0 @@ -m4_include([build/ax_compiler_vendor.m4]) -m4_include([build/libpcap.m4]) diff --git a/libs/freetdm/bootstrap b/libs/freetdm/bootstrap deleted file mode 100755 index 247d396da5..0000000000 --- a/libs/freetdm/bootstrap +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -autoheader -libtoolize --force --copy -aclocal -automake -f --copy --add-missing -autoconf diff --git a/libs/freetdm/build/ax_compiler_vendor.m4 b/libs/freetdm/build/ax_compiler_vendor.m4 deleted file mode 100644 index a24a58da0f..0000000000 --- a/libs/freetdm/build/ax_compiler_vendor.m4 +++ /dev/null @@ -1,15 +0,0 @@ -AC_DEFUN([AX_COMPILER_VENDOR], -[ -AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor, - [ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=unknown - # note: don't check for gcc first since some other compilers define __GNUC__ - for ventest in intel:__ICC,__ECC,__INTEL_COMPILER ibm:__xlc__,__xlC__,__IBMC__,__IBMCPP__ gnu:__GNUC__ sun:__SUNPRO_C,__SUNPRO_CC hp:__HP_cc,__HP_aCC dec:__DECC,__DECCXX,__DECC_VER,__DECCXX_VER borland:__BORLANDC__,__TURBOC__ comeau:__COMO__ cray:_CRAYC kai:__KCC lcc:__LCC__ metrowerks:__MWERKS__ sgi:__sgi,sgi microsoft:_MSC_VER watcom:__WATCOMC__ portland:__PGI; do - vencpp="defined("`echo $ventest | cut -d: -f2 | sed 's/,/) || defined(/g'`")" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ -#if !($vencpp) - thisisanerror; -#endif -])], [ax_cv_]_AC_LANG_ABBREV[_compiler_vendor=`echo $ventest | cut -d: -f1`; break]) - done - ]) -]) diff --git a/libs/freetdm/build/libpcap.m4 b/libs/freetdm/build/libpcap.m4 deleted file mode 100644 index ea7581e69b..0000000000 --- a/libs/freetdm/build/libpcap.m4 +++ /dev/null @@ -1,150 +0,0 @@ -dnl libpcap.m4--PCAP libraries and includes -dnl Derrick Brashear -dnl from KTH krb and Arla -dnl $Id: libpcap.m4,v 1.4 2006/01/20 20:21:09 snsimon Exp $ -dnl 2010/10/31 (stkn): -dnl rename: PCAP_INC_FLAGS -> PCAP_CPPFLAGS -dnl rename: PCAP_LIB_FLAGS -> PCAP_LDFLAGS (-L flags only) -dnl add: PCAP_LIBS (libs only) - -AC_DEFUN([PCAP_INC_WHERE1], [ -ac_cv_found_pcap_inc=no -if test -f "$1/pcap.h" ; then - ac_cv_found_pcap_inc=yes -fi -]) - -AC_DEFUN([PCAP_INC_WHERE], [ - for i in $1; do - AC_MSG_CHECKING(for pcap header in $i) - PCAP_INC_WHERE1($i) - if test "$ac_cv_found_pcap_inc" = "yes"; then - ac_cv_pcap_where_inc=$i - AC_MSG_RESULT(found) - break - else - AC_MSG_RESULT(no found) - fi - done -]) - -AC_DEFUN([PCAP_LIB_WHERE1], [ -saved_LIBS=$LIBS -LIBS="$saved_LIBS -L$1 -lpcap" -AC_TRY_LINK(, -[pcap_lookupdev("");], -[ac_cv_found_pcap_lib=yes], -ac_cv_found_pcap_lib=no) -LIBS=$saved_LIBS -]) - -AC_DEFUN([TEST_LIBPATH], [ -changequote(<<, >>) -define(<>, translit(ac_cv_found_$2_lib, <<- *>>, <<__p>>)) -changequote([, ]) -if test "$AC_CV_FOUND" = "yes"; then - if test \! -r "$1/lib$2.a" -a \! -r "$1/lib$2.so" -a \! -r "$1/lib$2.sl" -a \! -r "$1/lib$2.dylib"; then - AC_CV_FOUND=no - fi -fi -]) - - -AC_DEFUN([PCAP_LIB_WHERE], [ - for i in $1; do - AC_MSG_CHECKING(for pcap library in $i) - PCAP_LIB_WHERE1($i) - TEST_LIBPATH($i, pcap) - if test "$ac_cv_found_pcap_lib" = "yes" ; then - ac_cv_pcap_where_lib=$i - AC_MSG_RESULT(found) - break - else - AC_MSG_RESULT(no found) - fi - done -]) - -AC_DEFUN([FIND_LIB_SUBDIR], -[dnl -AC_ARG_WITH([lib-subdir], AC_HELP_STRING([--with-lib-subdir=DIR],[Find libraries in DIR instead of lib])) -AC_CHECK_SIZEOF(long) -AC_CACHE_CHECK([what directory libraries are found in], [ac_cv_cmu_lib_subdir], -[test "X$with_lib_subdir" = "Xyes" && with_lib_subdir= -test "X$with_lib_subdir" = "Xno" && with_lib_subdir= - if test "X$with_lib_subdir" = "X" ; then - ac_cv_cmu_lib_subdir=lib - if test $ac_cv_sizeof_long -eq 4 ; then - test -d /usr/lib32 && ac_cv_cmu_lib_subdir=lib32 - test -r /usr/lib/libpcap.so && ac_cv_cmu_lib_subdir=lib - fi - if test $ac_cv_sizeof_long -eq 8 ; then - test -d /usr/lib64 && ac_cv_cmu_lib_subdir=lib64 - fi - else - ac_cv_cmu_lib_subdir=$with_lib_subdir - fi]) - AC_SUBST(LIB_SUBDIR, $ac_cv_cmu_lib_subdir) - ]) - - -AC_DEFUN([AX_LIB_PCAP], [ -AC_REQUIRE([FIND_LIB_SUBDIR]) -AC_ARG_WITH(pcap, - [ --with-pcap=PREFIX Compile with PCAP support], - [if test "X$with_pcap" = "X"; then - with_pcap=yes - fi]) -AC_ARG_WITH(pcap-lib, - [ --with-pcap-lib=dir use pcap libraries in dir], - [if test "$withval" = "yes" -o "$withval" = "no"; then - AC_MSG_ERROR([No argument for --with-pcap-lib]) - fi]) -AC_ARG_WITH(pcap-include, - [ --with-pcap-include=dir use pcap headers in dir], - [if test "$withval" = "yes" -o "$withval" = "no"; then - AC_MSG_ERROR([No argument for --with-pcap-include]) - fi]) - - if test "X$with_pcap" != "X"; then - if test "$with_pcap" != "yes"; then - ac_cv_pcap_where_lib=$with_pcap - ac_cv_pcap_where_inc=$with_pcap/include - fi - fi - - if test "X$with_pcap_lib" != "X"; then - ac_cv_pcap_where_lib=$with_pcap_lib - fi - if test "X$ac_cv_pcap_where_lib" = "X"; then - PCAP_LIB_WHERE(/usr/$LIB_SUBDIR /usr/local/$LIB_SUBDIR) - fi - - if test "X$with_pcap_include" != "X"; then - ac_cv_pcap_where_inc=$with_pcap_include - fi - if test "X$ac_cv_pcap_where_inc" = "X"; then - PCAP_INC_WHERE(/usr/ng/include /usr/include /usr/local/include) - fi - - AC_MSG_CHECKING(whether to include pcap) - if test "X$ac_cv_pcap_where_lib" != "X" -a "X$ac_cv_pcap_where_inc" != "X"; then - ac_cv_found_pcap=yes - AC_MSG_RESULT(yes) - PCAP_INC_DIR=$ac_cv_pcap_where_inc - PCAP_LIB_DIR=$ac_cv_pcap_where_lib - PCAP_CPPFLAGS="-I${PCAP_INC_DIR}" - PCAP_LDFLAGS="-L${PCAP_LIB_DIR}" - PCAP_LIBS="-lpcap" - AC_SUBST(PCAP_INC_DIR) - AC_SUBST(PCAP_LIB_DIR) - AC_SUBST(PCAP_CPPFLAGS) - AC_SUBST(PCAP_LDFLAGS) - AC_SUBST(PCAP_LIBS) - AC_DEFINE([HAVE_LIBPCAP],[1],[libpcap]) - else - ac_cv_found_pcap=no - AC_MSG_RESULT(no) - fi - ]) - diff --git a/libs/freetdm/conf/freetdm.conf b/libs/freetdm/conf/freetdm.conf deleted file mode 100644 index 0d53992979..0000000000 --- a/libs/freetdm/conf/freetdm.conf +++ /dev/null @@ -1,82 +0,0 @@ -; !! THIS IS A SAMPLE CONFIGURATION ONLY !! - -; refer to http://wiki.freeswitch.org/wiki/FreeTDM for further documentation - -[general] -; whether to launch a thread for CPU usage monitoring -cpu_monitor => no - -; How often (in milliseconds) monitor CPU usage -cpu_monitoring_interval => 1000 - -; At what CPU percentage raise a CPU alarm -cpu_set_alarm_threshold => 80 - -; At what CPU percentage stop the CPU alarm -cpu_clear_alarm_threshold => 70 - -; Which action to take when the CPU alarm is raised -; it can be warn and/or reject calls -; cpu_alarm_action => warn,reject -cpu_alarm_action => warn - -; Where to dump DTMF debug files (see per span debugdtmf=yes option) -debugdtmf_directory=/full/path/to/dtmf/directory - -; spans are defined with [span ] -; the span type can either be zt, wanpipe or pika -; the span name can be any unique string -[span wanpipe myWanpipe] - -; valid trunk types are: FXO, FXS, EM, E1, T1, J1, BRI, BRI_PTMP -trunk_type => FXS - -; add FXS channels from 3 to 4 at wanpipe span 1 to this freetdm span -fxs-channel => 1:3-4 - -; IO stats. Defaults to yes, you can print the stats with ftdm iostats print -; This feature depends on the span IO type, currently only Wanpipe spans support it -; This may cause a warning to be printed once in a while if audio is not provided fast enough -; and causes the driver to transmit an idle frame (when there is no data provided by the application) -iostats => yes - -[span wanpipe myWanpipe2] -trunk_type => FXO -; This number will be used as DNIS for FXO devices -fxo-channel => 1:1-2 - -[span zt myZaptelSpan] -number => 9999 -fxs-channel => 1 - -[span zt mySecondZaptelSpan] -; This number will be used as DNIS for FXO devices -number => 2 -fxo-channel => 3 - -; MFC-R2 typical span configuration - -; MFC-R2 with wanpipe (Sangoma) -[span wanpipe myWanpipeSpan] -trunk_type => E1 -cas-channel => 1-15:1101 -cas-channel => 17-31:1101 - -; MFC-R2 with Zaptel/DAHDI -[span zt myWanpipeSpan] -trunk_type => E1 -cas-channel => 1-15:1101 -cas-channel => 17-31:1101 - -; generic channel parameters -; this parameters are accepted by any type of span/channel -; remember that for generic channel parameters only channels -; below the parameter within the span will be affected - -; Channel audio gain -; rxgain => 0.0 -; txgain => 0.0 - -; Whether to perform media dumps for DTMF debugging -; debugdtmf => yes - diff --git a/libs/freetdm/conf/freetdm.conf.xml b/libs/freetdm/conf/freetdm.conf.xml deleted file mode 100644 index 0b006dc704..0000000000 --- a/libs/freetdm/conf/freetdm.conf.xml +++ /dev/null @@ -1,633 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/freetdm/conf/pika.conf b/libs/freetdm/conf/pika.conf deleted file mode 100644 index 01629fd08e..0000000000 --- a/libs/freetdm/conf/pika.conf +++ /dev/null @@ -1,43 +0,0 @@ -; you dont need this file unless you use PIKA boards - -; each category is a config profile -; to apply the profile append it to a channel def in -; freetdm.conf with @ -; e.g. -; [span pika] -; name => pika -; number => pika -; fxs-channel => 1:0:1-12@default - -[default] -; region is na or eu -;region => na -;rx-gain => 0.00 -;rx-agc-enabled => false -;rx-agc-targetPower => -15.00 -;rx-agc-minGain => -6.00 -;rx-agc-maxGain => 18.00 -;rx-agc-attackRate => 170 -;rx-agc-decayRate => 750 -;rx-agc-speechThreshold => -36.00 -;rx-vad-enabled => false -;rx-vad-activationThreshold => -40.00 -;rx-vad-activationDebounceTime => 72 -;rx-vad-deactivationThreshold => -40.00 -;rx-vad-deactivationDebounceTime => 984 -;rx-vad-preSpeechBufferSize => 240 -;tx-gain => 0.00 -;tx-agc-enabled => true -;tx-agc-targetPower => -15.00 -;tx-agc-minGain => -6.00 -;tx-agc-maxGain => 18.00 -;tx-agc-attackRate => 170 -;tx-agc-decayRate => 750 -;tx-agc-speechThreshold => -36.00 -;ec-enabled => false -;ec-doubleTalkerThreshold => -6.00 -;ec-speechPresentThreshold => -40.00 -;ec-echoSuppressionThreshold => -18.00 -;ec-echoSuppressionEnabled => true -;ec-comfortNoiseEnabled => true -;ec-adaptationModeEnabled => true diff --git a/libs/freetdm/conf/tones.conf b/libs/freetdm/conf/tones.conf deleted file mode 100644 index 9bb0b43e92..0000000000 --- a/libs/freetdm/conf/tones.conf +++ /dev/null @@ -1,142 +0,0 @@ -[us] -generate-dial => v=-7;%(1000,0,350,440) -detect-dial => 350,440 - -generate-ring => v=-7;%(2000,4000,440,480) -detect-ring => 440,480 - -generate-busy => v=-7;%(500,500,480,620) -detect-busy => 480,620 - -generate-attn => v=0;%(100,100,1400,2060,2450,2600) -detect-attn => 1400,2060,2450,2600 - -generate-callwaiting-sas => v=0;%(300,0,440) -detect-callwaiting-sas => 440 - -generate-callwaiting-cas => v=0;%(80,0,2750,2130) -detect-callwaiting-cas => 2750,2130 - -detect-fail1 => 913.8 -detect-fail2 => 1370.6 -detect-fail3 => 1776.7 - - -[sg] -generate-dial => v=-7;%(1000,0,425) -detect-dial => 425 - -generate-ring => v=-7;%(2000,4000,425) -detect-ring => 425 - -generate-busy => v=-7;%(750,750,425) -detect-busy => 425 - -generate-attn => v=0;%(100,100,1400,2060,2450,2600) -detect-attn => 1400,2060,2450,2600 - -generate-callwaiting-sas => v=0;%(300,0,440) -detect-callwaiting-sas => 440 - -generate-callwaiting-cas => v=0;%(80,0,2750,2130) -detect-callwaiting-cas => 2750,2130 - -detect-fail1 => 913.8 -detect-fail2 => 1370.6 -detect-fail3 => 1776.7 - - -[ru] -generate-dial => v=-7;%(1000,425) -detect-dial => 0 - -generate-ring => v=-7;%(800,5000,425,0) -detect-ring => 425,0 - -generate-busy => v=-7;%(350,350,425,0) -detect-busy => 425,0 - -generate-attn => v=0;%(100,100,1400,2060,2450,2600) -detect-attn => 1400,2060,2450,2600 - -generate-callwaiting-sas => v=0;%(300,0,440) -detect-callwaiting-sas => 440,480 - -generate-callwaiting-cas => v=0;%(80,0,2750,2130) -detect-callwaiting-cas => 2750,2130 - -detect-fail1 => 913.8 -detect-fail2 => 1370.6 -detect-fail3 => 1776.7 - - -[in] -generate-dial => v=-7;%(1000,0,375,425) -detect-dial => 375,425 - -generate-ring => v=-7;%(2000,4000,440,480) -detect-ring => 440,480 - -generate-busy => v=-7;%(500,500,480,620) -detect-busy => 480,620 - -generate-attn => v=0;%(100,100,1400,2060,2450,2600) -detect-attn => 1400,2060,2450,2600 - -generate-callwaiting-sas => v=0;%(300,0,440) -detect-callwaiting-sas => 440 - -generate-callwaiting-cas => v=0;%(80,0,2750,2130) -detect-callwaiting-cas => 2750,2130 - -detect-fail1 => 913.8 -detect-fail2 => 1370.6 -detect-fail3 => 776.7 - - -[th] -generate-dial => v=-7;%(1000,0,400,400) -detect-dial => 400,400 - -generate-ring => v=-7;%(2000,4000,400,400) -detect-ring => 400,400 - -generate-busy => v=-7;%(500,500,480,620) -detect-busy => 480,620 - -generate-attn => v=0;%(100,100,1400,2060,2450,2600) -detect-attn => 1400,2060,2450,2600 - -generate-callwaiting-sas => v=0;%(300,0,440) -detect-callwaiting-sas => 440 - -generate-callwaiting-cas => v=0;%(80,0,2750,2130) -detect-callwaiting-cas => 2750,2130 - -detect-fail1 => 913.8 -detect-fail2 => 1370.6 -detect-fail3 => 1776.7 - - -[au] -generate-dial => v=-7;%(1000,0,413,438) -detect-dial => 413,438 - -generate-ring => v=-7;%(400,200,413,438);%(400,2000,413,438) -detect-ring => 413,438 - -generate-busy => v=-7;%(375,375,425) -detect-busy => 425 - -generate-attn => v=0;%(100,100,1400,2060,2450,2600) -detect-attn => 1400,2060,2450,2600 - -generate-callwaiting-sas => v=0;%(300,0,440) -detect-callwaiting-sas => 440 - -generate-callwaiting-cas => v=0;%(80,0,2750,2130) -detect-callwaiting-cas => 2750,2130 - -detect-fail1 => 913.8 -detect-fail2 => 1370.6 -detect-fail3 => 776.7 diff --git a/libs/freetdm/conf/wanpipe.conf b/libs/freetdm/conf/wanpipe.conf deleted file mode 100644 index 3784eaf17a..0000000000 --- a/libs/freetdm/conf/wanpipe.conf +++ /dev/null @@ -1,13 +0,0 @@ -[defaults] -; User space interval at which data will be delivered -codec_ms => 20 - -; wink and flash interval -wink_ms => 150 -flash_ms => 750 - -; size of the driver queue of elements of MTU size -; typical case is 10 elements of 80 bytes each (10ms of ulaw/alaw) -; don't mess with this if you don't know what you're doing -; txqueue_size => 10 -; rxqueue_size => 10 diff --git a/libs/freetdm/conf/zt.conf b/libs/freetdm/conf/zt.conf deleted file mode 100644 index a060a40315..0000000000 --- a/libs/freetdm/conf/zt.conf +++ /dev/null @@ -1,8 +0,0 @@ -[defaults] -codec_ms => 20 -wink_ms => 150 -flash_ms => 750 -echo_cancel_level => 64 -rxgain => 0.0 -txgain => 0.0 - diff --git a/libs/freetdm/configure.ac b/libs/freetdm/configure.ac deleted file mode 100644 index e6aad59e52..0000000000 --- a/libs/freetdm/configure.ac +++ /dev/null @@ -1,480 +0,0 @@ -# -*- Autoconf -*- -# Process this file with autoconf to produce a configure script. - -AC_PREREQ([2.59]) -AC_INIT([freetdm], [0.1], [bugs@freeswitch.org]) -AC_CONFIG_SRCDIR([src/ftdm_io.c]) - -AC_CONFIG_AUX_DIR([build]) -AC_CONFIG_MACRO_DIR([build]) -AM_INIT_AUTOMAKE - -# >=automake-1.11 -m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) - -# override some default libtool behavior and invoke AC_PROG_LIBTOOL -# (see http://lists.gnu.org/archive/html/libtool/2007-03/msg00000.html) -m4_defun([_LT_AC_LANG_F77_CONFIG], [:]) -m4_defun([_LT_AC_LANG_GCJ_CONFIG], [:]) -m4_defun([_LT_AC_LANG_RC_CONFIG], [:]) - -# Checks for programs. -AC_PROG_CC -AC_PROG_MAKE_SET -AM_PROG_CC_C_O -AC_PROG_LIBTOOL -AC_PROG_INSTALL - -# NOTE: pkg-config is used to detect libisdn -m4_ifdef([PKG_PROG_PKG_CONFIG], - [PKG_PROG_PKG_CONFIG], - [AC_MSG_WARN([pkg-config missing (required for libisdn detection)])] -) - -AX_COMPILER_VENDOR - -# AC_PREFIX_DEFAULT does not get expanded until too late so we need -# to do this to use prefix in this script -AC_PREFIX_DEFAULT([/usr/local/freetdm]) -if test "x${prefix}" = "xNONE" ; then - prefix='/usr/local/freetdm' -fi - -# Absolute source/build directory -FT_SRCDIR=`(cd $srcdir && pwd)` -ft_builddir=`pwd` -AC_SUBST([FT_SRCDIR]) -AC_SUBST([ft_builddir]) - -if test "$sysconfdir" = "\${prefix}/etc" ; then - confdir="$prefix/conf" -else - confdir="$sysconfdir" -fi - -AC_SUBST([confdir]) - -DEFAULT_INCLUDES="-I. -I./src/include -I\$(srcdir)" -AC_SUBST([DEFAULT_INCLUDES]) - -# Where to install the modules -AC_ARG_WITH([modinstdir], - [AS_HELP_STRING([--with-modinstdir=DIR], [Install modules into this location (default: ${prefix}/mod)])], - [case "${withval}" in - no|yes) AC_MSG_ERROR([Invalid value \"${withval}\", option requires a valid path]) ;; - *) modinstdir="${withval}" ;; - esac], - [modinstdir="${prefix}/mod"] -) -AC_SUBST([modinstdir]) - -# freetdm.pc pkgconfig file -AC_ARG_WITH([pkgconfigdir], - [AS_HELP_STRING([--with-pkgconfigdir=DIR], [Installation directory for pkgconfig file (default: ${libdir}/pkgconfig)])], - [case "${withval}" in - yes|no) AC_MSG_ERROR([Invalid value ${withval} for option --with-pkgconfigdir]) ;; - *) pkgconfigdir="${withval}" ;; - esac - ], - [pkgconfigdir="${libdir}/pkgconfig"] -) -AC_SUBST([pkgconfigdir]) - -AC_ARG_ENABLE([enable_64], - [AS_HELP_STRING([--enable-64], [Enable 64bit compilation])], - [enable_64="${enableval}"], - [enable_64="no"] -) - -case "${ax_cv_c_compiler_vendor}" in -gnu) - COMP_VENDOR_CFLAGS="-ffast-math -Wall -Werror -Wunused-variable -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -O0" - ;; -sun) - COMP_VENDOR_CFLAGS="-xc99=all -mt -xCC -xvpara" - if test "$enable_64" != "no" ; then - COMP_VENDOR_CFLAGS="-m64 $COMP_VENDOR_CFLAGS" - fi - ;; -*) - COMP_VENDOR_COMPAT_CFLAGS="-Wall -Werror -Wunused-variable -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes" - COMP_VENDOR_CFLAGS="-std=c99 $COMP_VENDOR_COMPAT_CFLAGS" - ;; -esac -AC_SUBST([COMP_VENDOR_COMPAT_CFLAGS]) -AC_SUBST([COMP_VENDOR_CFLAGS]) - - -# Enable debugging -AC_ARG_ENABLE([debug], - [AC_HELP_STRING([--enable-debug], [build with debug information])], - [enable_debug="${enableval}"], - [enable_debug="yes"] -) -if test "${enable_debug}" != "no"; then - AC_DEFINE([DEBUG], [], [Enable extra debugging.]) - - if test "x${ax_cv_c_compiler_vendor}" = "xgnu" ; then - COMP_VENDOR_CFLAGS="$COMP_VENDOR_CFLAGS -g -ggdb" - fi -fi -AC_SUBST([COMP_VENDOR_CFLAGS]) - -AC_CHECK_LIB([dl], [dlopen]) -AC_CHECK_LIB([pthread], [pthread_create]) -AC_CHECK_LIB([m], [cos]) - -AC_CHECK_HEADERS([netdb.h sys/select.h execinfo.h]) - -AC_CHECK_FUNC([gethostbyname_r], - [], [AC_CHECK_LIB([nsl], [gethostbyname_r])] -) -if test "$ac_cv_func_gethostbyname_r" = "yes" -o "$ac_cv_lib_nsl_gethostbyname_r" = "yes" -then - AC_MSG_CHECKING([whether gethostbyname_r requires five arguments]) - - ac_cv_func_gethostbyname_r_five_args="no" - - AC_TRY_COMPILE([#include ], - [char *name; - struct hostent *he, *res; - char buffer[2048]; - int buflen = 2048; - (void)gethostbyname_r(name, he, buffer, buflen, &res)], - [ac_cv_func_gethostbyname_r_five_args="yes" - AC_DEFINE([HAVE_GETHOSTBYNAME_R_FIVE], [1], [gethostbyname_r has five arguments])] - ) - - AC_MSG_RESULT([$ac_cv_func_gethostbyname_r_five_args]) - AC_DEFINE([HAVE_GETHOSTBYNAME_R], [1], [threadsafe gethostbyname]) -fi - -## -## Modules and optional features -## -AC_MSG_RESULT([${as_nl}<<>> Modules and optional features]) - -## -# pritap (TODO: add checks) -# -HAVE_PRITAP="no" -AC_ARG_WITH([pritap], - [AS_HELP_STRING([--with-pritap], [Install ftmod_pritap])], - [case "${withval}" in - no) enable_pritap="no" ;; - *) enable_pritap="yes" ;; - esac], - [enable_pritap="no"] -) -HAVE_PRITAP="${enable_pritap}" -AM_CONDITIONAL([HAVE_PRITAP],[test "${enable_pritap}" = "yes"]) - -## -# OpenR2 stack -# -HAVE_OPENR2="no" -AC_CHECK_LIB([openr2], [openr2_context_set_io_type], [HAVE_OPENR2="yes"]) -AC_MSG_RESULT([checking whether to build ftmod_r2... ${HAVE_OPENR2}]) -AM_CONDITIONAL([HAVE_OPENR2], [test "${HAVE_OPENR2}" = "yes"]) - -## -# WAT GSM stack -# -HAVE_WAT="no" -AC_CHECK_LIB([wat], [wat_version], [HAVE_WAT="yes"]) -AC_MSG_RESULT([checking whether to build ftmod_wat... ${HAVE_WAT}]) -AM_CONDITIONAL([HAVE_WAT], [test "${HAVE_WAT}" = "yes"]) - -## -# Digium libpri (TODO: add checks) -# -HAVE_LIBPRI="no" -AC_ARG_WITH([libpri], - [AS_HELP_STRING([--with-libpri@<:@=PREFIX@:>@], [Install ftmod_libpri])], - [case "${withval}" in - no|yes) with_libpri="${withval}" ;; - *) AS_IF([test -d "${withval}"], - [with_libpri="${withval}"], - [AC_MSG_ERROR([Invalid argument for --with-libpri, \"${withval}\" is not a directory])] - ) ;; - esac], - [with_libpri="no"] -) -if test "x${with_libpri}" != "xno" -then - save_LIBS="${LIBS}" - save_CPPFLAGS="${CPPFLAGS}" - save_LDFLAGS="${LDFLAGS}" - - LIBPRI_CPPFLAGS="" - LIBPRI_LDFLAGS="" - - AC_MSG_RESULT([${as_nl}<<>> Digium libpri]) - - AS_IF([test "x${with_libpri}" != "xyes"], - [LIBPRI_CPPFLAGS="-I${with_libpri}/include" - LIBPRI_LDFLAGS="-L${with_libpri}/lib"], - ) - - LDFLAGS="${save_LDFLAGS} ${LIBPRI_LDFLAGS}" - CPPFLAGS="${save_CPPFLAGS} ${LIBPRI_CPPFLAGS}" - LIBS="${LIBS} -lpri" - - AC_MSG_CHECKING([whether libpri is usable]) - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [#include ], - [const char *version = pri_get_version(); - (void)version;] - )], - [AC_MSG_RESULT([yes]) - HAVE_LIBPRI="yes"], - [AC_MSG_RESULT([no]) - AC_MSG_ERROR([libpri not found or unusable (see config.log for details)])] - ) - - AC_MSG_CHECKING([whether libpri is too old]) - AC_PREPROC_IFELSE( - [AC_LANG_PROGRAM( - [#include ], - [#if !defined(PRI_IO_FUNCS) - #error "libpri is lacking PRI_IO_FUNCS" - #elif !defined(PRI_NEW_SET_API) - #error "libpri is lacking PRI_NEW_SET_API" - #endif] - )], - [AC_MSG_RESULT([no])], - [AC_MSG_RESULT([yes]) - AC_MSG_ERROR([Your version of libpri is too old (pre 1.2), please update!])] - ) - - AC_MSG_CHECKING([whether libpri has BRI support]) - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [extern void pri_new_bri_cb(void);], - [pri_new_bri_cb();] - )], - [AC_DEFINE([HAVE_LIBPRI_BRI], [1], [libpri has BRI support]) - AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no]) - AC_MSG_NOTICE([You will need libpri-1.4.12_beta1 or newer for BRI support])] - ) - - AC_MSG_CHECKING([whether libpri has AOC event support]) - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [extern void pri_aoc_events_enable(void);], - [pri_aoc_events_enable();] - )], - [AC_DEFINE([HAVE_LIBPRI_AOC], [1], [libpri has AOC event support]) - AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no]) - AC_MSG_NOTICE([You will need libpri-1.4.12_beta1 or newer for AOC event support])] - ) - - - AC_MSG_CHECKING([whether libpri has pri_maintenance_service()]) - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [extern int pri_maintenance_service(void);], - [pri_maintenance_service();] - )], - [AC_DEFINE([HAVE_LIBPRI_MAINT_SERVICE], [1], [libpri has pri_maintenance_service()]) - AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no]) - AC_MSG_NOTICE([You will need libpri-1.4.11 or newer for the ftdm libpri maintenance set of commands])] - ) - - # libpri is available, set variables for Makefile(.am) - AC_SUBST([LIBPRI_LIBS], [-lpri]) - AC_SUBST([LIBPRI_LDFLAGS]) - AC_SUBST([LIBPRI_CPPFLAGS]) - - LIBS="${save_LIBS}" - LDFLAGS="${save_LDFLAGS}" - CPPFLAGS="${save_CPPFLAGS}" -fi -AM_CONDITIONAL([HAVE_LIBPRI],[test "x${HAVE_LIBPRI}" = "xyes"]) - -## -# Sangoma Wanpipe -# -HAVE_LIBSANGOMA="no" -AC_MSG_RESULT([${as_nl}<<>> Sangoma Wanpipe]) -AC_CHECK_LIB([sangoma], [sangoma_span_chan_toif], [HAVE_LIBSANGOMA="yes"]) -AC_MSG_RESULT([checking whether to build ftmod_wanpipe... ${HAVE_LIBSANGOMA}]) -AM_CONDITIONAL([HAVE_LIBSANGOMA], [test "${HAVE_LIBSANGOMA}" = "yes"]) - -## -# Sangoma ISDN stack -# -HAVE_SNG_ISDN="no" -AC_MSG_RESULT([${as_nl}<<>> Sangoma ISDN stack]) -AC_CHECK_LIB([sng_isdn], [sng_isdn_init], [HAVE_SNG_ISDN="yes"]) -AC_MSG_RESULT([checking whether to build ftmod_sangoma_isdn... ${HAVE_SNG_ISDN}]) -AM_CONDITIONAL([HAVE_SNG_ISDN], [test "${HAVE_SNG_ISDN}" = "yes"]) - -if test "${HAVE_SNG_ISDN}" = "yes"; then - if test "${build}" = "${host}" - then - case "${host}" in - x86_64-*) - # X86_64 machines need additional flags when compiling against libsng_isdn - CFLAGS="$CFLAGS -DBIT_64 -DALIGN_64BIT" - ;; - esac - fi -fi - -## -# Sangoma SS7 stack -# -HAVE_SNG_SS7="no" -AC_MSG_RESULT([${as_nl}<<>> Sangoma SS7 stack]) -AC_CHECK_LIB([sng_ss7], [sng_isup_init_gen], [HAVE_SNG_SS7="yes"]) -AC_MSG_RESULT([checking whether to build ftmod_sangoma_ss7... ${HAVE_SNG_SS7}]) -AM_CONDITIONAL([HAVE_SNG_SS7], [test "${HAVE_SNG_SS7}" = "yes"]) - -if test "${HAVE_SNG_SS7}" = "yes"; then - if test "${build}" = "${host}" - then - case "${host}" in - x86_64-*) - # X86_64 machines need additional flags when compiling against libsng_isdn - CFLAGS="$CFLAGS -DBIT_64 -DALIGN_64BIT" - ;; - esac - fi -fi - - -## -# zlib (required for Sangoma SS7 Transparent IAM) -# -HAVE_ZLIB="no" -AC_MSG_RESULT([${as_nl}<<>> zlib]) -AC_CHECK_LIB([z], [compress], [HAVE_ZLIB="yes"]) -AC_MSG_RESULT([checking whether zlib is installed... ${HAVE_ZLIB}]) -AM_CONDITIONAL([HAVE_ZLIB], [test "{HAVE_ZLIB]" = "yes"]) -if test "${HAVE_ZLIB}" = "yes"; then - CFLAGS="$CFLAGS -DHAVE_ZLIB" -fi - -## -# libisdn -# -HAVE_LIBISDN="no" -AC_ARG_WITH([libisdn], - [AS_HELP_STRING([--with-libisdn], [Install ftmod_isdn (libisdn stack)])], - [case "${withval}" in - no) with_libisdn="no" ;; - *) with_libisdn="yes" ;; - esac - ], - [with_libisdn="no"] -) -if test "${with_libisdn}" != "no" -then - AC_MSG_RESULT([${as_nl}<<>> ftmod_isdn (libisdn stack)]) - m4_ifdef([PKG_CHECK_MODULES], - [PKG_CHECK_MODULES([libisdn], - [libisdn >= 0.0.1], - [AC_MSG_CHECKING([libisdn version]) - LIBISDN_VERSION="`${PKG_CONFIG} --modversion libisdn`" - if test -z "${LIBISDN_VERSION}"; then - AC_MSG_ERROR([Failed to retrieve libisdn version]) - fi - AC_MSG_RESULT([${LIBISDN_VERSION}]) - - # check features - AC_MSG_CHECKING([for new experimental API]) - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [#include - #if !LIBISDN_FEATURE(API2) - #error "libisdn API v2 not available" - #endif - ], - [;] - )], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - HAVE_LIBISDN="yes" - AC_DEFINE([HAVE_LIBISDN], [1], [libisdn support]) - AC_SUBST([LIBISDN_CFLAGS], [${libisdn_CFLAGS}]) - AC_SUBST([LIBISDN_CPPFLAGS],[${libisdn_CPPFLAGS}]) - AC_SUBST([LIBISDN_LDFLAGS], [${libisdn_LDFLAGS}]) - AC_SUBST([LIBISDN_LIBS], [${libisdn_LIBS}]) - AC_SUBST([LIBISDN_VERSION]) - ], - [AC_MSG_ERROR([Need libisdn-0.0.1 or higher])] - ) - AX_LIB_PCAP], - [AC_MSG_WARN([pkg-config missing (required for libisdn detection)])] - ) -fi -AM_CONDITIONAL([HAVE_LIBISDN], [test "${HAVE_LIBISDN}" = "yes"]) - - -## -# mISDN dependencies -# -HAVE_MISDN="no" -AC_ARG_WITH([misdn], - [AS_HELP_STRING([--with-misdn], [Install ftmod_misdn (mISDN I/O plugin)])], - [case "${withval}" in - no|yes) with_misdn="${withval}" ;; - *) AC_MSG_ERROR([Invalid value \"${with_misdn}\" for --with-misdn option]) ;; - esac], - [with_misdn="auto"] -) -AS_IF([test "${with_misdn}" != "no"], - [AC_MSG_RESULT([${as_nl}<<>> ftmod_misdn (Linux mISDN I/O plugin)]) - AC_CHECK_HEADER([mISDN/mISDNif.h], - [HAVE_MISDN="yes" - AC_CHECK_LIB([rt], [clock_gettime])], - [AS_IF([test "${with_misdn}" = "yes"], - [AC_MSG_ERROR([mISDN/mISDNif.h not found])], - [AC_MSG_NOTICE([mISDN/mISDNif.h not found])] - )], - [#include ] - )] -) -AM_CONDITIONAL([HAVE_MISDN], [test "${HAVE_MISDN}" = "yes"]) - - -AC_MSG_RESULT([${as_nl}<<>> Creating output files]) -AC_CONFIG_FILES([ - Makefile - freetdm.pc - mod_freetdm/Makefile -]) -AC_OUTPUT - -# -# summary screen -# -AC_MSG_RESULT([ -============================ FreeTDM configuration ============================ - -+ Modules - - Signalling: - ftmod_analog....................... yes - ftmod_analog_em.................... yes - ftmod_isdn......................... ${HAVE_LIBISDN} - ftmod_libpri....................... ${HAVE_LIBPRI} - ftmod_sangoma_isdn................. ${HAVE_SNG_ISDN} - ftmod_sangoma_ss7.................. ${HAVE_SNG_SS7} - ftmod_r2........................... ${HAVE_OPENR2} - ftmod_gsm.......................... ${HAVE_WAT} - ftmod_pritap....................... ${HAVE_PRITAP} - I/O: - ftmod_zt........................... yes - ftmod_wanpipe...................... ${HAVE_LIBSANGOMA} - ftmod_misdn........................ ${HAVE_MISDN} - -=============================================================================== -]) diff --git a/libs/freetdm/configure.gnu b/libs/freetdm/configure.gnu deleted file mode 100755 index d00cd18473..0000000000 --- a/libs/freetdm/configure.gnu +++ /dev/null @@ -1,3 +0,0 @@ -#! /bin/sh -srcpath=$(dirname $0 2>/dev/null ) || srcpath="." -$srcpath/configure "$@" --with-pic diff --git a/libs/freetdm/cyginstall.sh b/libs/freetdm/cyginstall.sh deleted file mode 100755 index e7953675b6..0000000000 --- a/libs/freetdm/cyginstall.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -# this script must be run from freetdm root dir and it is assuming -# FreeSWITCH is trunk is located at ../../ -fsdir=../.. -set -x -cp Debug/mod/*.dll $fsdir/Debug/mod/ -cp mod_freetdm/Debug/*.pdb $fsdir/Debug/mod/ -cp Debug/freetdm.dll $fsdir/Debug/ -cp Debug/ftmod_*.dll $fsdir/Debug/mod/ -cp Debug/*.pdb $fsdir/Debug/mod/ -#cp Debug/testsangomaboost.exe $fsdir/Debug/ -echo "FRIENDLY REMINDER: RECOMPILE ftmod_wanpipe WHENEVER YOU INSTALL NEW DRIVERS" -set +x - diff --git a/libs/freetdm/docs/Doxygen.conf b/libs/freetdm/docs/Doxygen.conf deleted file mode 100644 index 1f69952879..0000000000 --- a/libs/freetdm/docs/Doxygen.conf +++ /dev/null @@ -1,265 +0,0 @@ -# Doxyfile 1.4.6 - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- -PROJECT_NAME = FreeTDM -PROJECT_NUMBER = -OUTPUT_DIRECTORY = docs/ -CREATE_SUBDIRS = NO -OUTPUT_LANGUAGE = English -USE_WINDOWS_ENCODING = YES -BRIEF_MEMBER_DESC = YES -REPEAT_BRIEF = YES -ABBREVIATE_BRIEF = "The $name class" \ - "The $name widget" \ - "The $name file" \ - is \ - provides \ - specifies \ - contains \ - represents \ - a \ - an \ - the -ALWAYS_DETAILED_SEC = NO -INLINE_INHERITED_MEMB = NO -FULL_PATH_NAMES = NO -STRIP_FROM_PATH = -STRIP_FROM_INC_PATH = -SHORT_NAMES = NO -JAVADOC_AUTOBRIEF = NO -MULTILINE_CPP_IS_BRIEF = NO -DETAILS_AT_TOP = NO -INHERIT_DOCS = YES -SEPARATE_MEMBER_PAGES = NO -TAB_SIZE = 8 -ALIASES = -OPTIMIZE_OUTPUT_FOR_C = YES -OPTIMIZE_OUTPUT_JAVA = NO -DISTRIBUTE_GROUP_DOC = NO -SUBGROUPING = YES -IGNORE_PREFIX = ftdm_ FTDM_ Q921 Q931 - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- -EXTRACT_ALL = YES -EXTRACT_PRIVATE = YES -EXTRACT_STATIC = YES -EXTRACT_LOCAL_CLASSES = YES -EXTRACT_LOCAL_METHODS = YES -HIDE_UNDOC_MEMBERS = YES -HIDE_UNDOC_CLASSES = YES -HIDE_FRIEND_COMPOUNDS = NO -HIDE_IN_BODY_DOCS = NO -INTERNAL_DOCS = NO -CASE_SENSE_NAMES = NO -HIDE_SCOPE_NAMES = NO -SHOW_INCLUDE_FILES = YES -INLINE_INFO = YES -SORT_MEMBER_DOCS = YES -SORT_BRIEF_DOCS = NO -SORT_BY_SCOPE_NAME = NO -GENERATE_TODOLIST = YES -GENERATE_TESTLIST = YES -GENERATE_BUGLIST = YES -GENERATE_DEPRECATEDLIST= YES -ENABLED_SECTIONS = -MAX_INITIALIZER_LINES = 30 -SHOW_USED_FILES = YES -SHOW_DIRECTORIES = YES -FILE_VERSION_FILTER = -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- -QUIET = NO -WARNINGS = YES -WARN_IF_UNDOCUMENTED = YES -WARN_IF_DOC_ERROR = YES -WARN_NO_PARAMDOC = NO -WARN_FORMAT = "$file:$line: $text" -WARN_LOGFILE = -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- -INPUT = src/include/freetdm.h - -FILE_PATTERNS = *.c \ - *.cc \ - *.cxx \ - *.cpp \ - *.c++ \ - *.d \ - *.java \ - *.ii \ - *.ixx \ - *.ipp \ - *.i++ \ - *.inl \ - *.h \ - *.hh \ - *.hxx \ - *.hpp \ - *.h++ \ - *.idl \ - *.odl \ - *.cs \ - *.php \ - *.php3 \ - *.inc \ - *.m \ - *.mm \ - *.dox \ - *.py -RECURSIVE = NO -EXCLUDE = -EXCLUDE_SYMLINKS = NO -EXCLUDE_PATTERNS = -EXAMPLE_PATH = -EXAMPLE_PATTERNS = -EXAMPLE_RECURSIVE = NO -IMAGE_PATH = -INPUT_FILTER = -FILTER_PATTERNS = -FILTER_SOURCE_FILES = NO -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- -SOURCE_BROWSER = NO -INLINE_SOURCES = YES -STRIP_CODE_COMMENTS = YES -REFERENCED_BY_RELATION = YES -REFERENCES_RELATION = YES -USE_HTAGS = YES -VERBATIM_HEADERS = NO -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- -ALPHABETICAL_INDEX = YES -COLS_IN_ALPHA_INDEX = 1 -IGNORE_PREFIX = ftdm_ -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- -GENERATE_HTML = YES -HTML_OUTPUT = html -HTML_FILE_EXTENSION = .html -HTML_HEADER = -HTML_FOOTER = -HTML_STYLESHEET = -HTML_ALIGN_MEMBERS = YES -GENERATE_HTMLHELP = NO -CHM_FILE = freetdm.chm -HHC_LOCATION = -GENERATE_CHI = YES -BINARY_TOC = NO -TOC_EXPAND = NO -DISABLE_INDEX = NO -ENUM_VALUES_PER_LINE = 4 -GENERATE_TREEVIEW = YES -TREEVIEW_WIDTH = 250 - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- -GENERATE_LATEX = NO -LATEX_OUTPUT = latex -LATEX_CMD_NAME = latex -MAKEINDEX_CMD_NAME = makeindex -COMPACT_LATEX = NO -PAPER_TYPE = a4wide -EXTRA_PACKAGES = -LATEX_HEADER = -PDF_HYPERLINKS = NO -USE_PDFLATEX = NO -LATEX_BATCHMODE = NO -LATEX_HIDE_INDICES = NO -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- -GENERATE_RTF = NO -RTF_OUTPUT = rtf -COMPACT_RTF = NO -RTF_HYPERLINKS = NO -RTF_STYLESHEET_FILE = -RTF_EXTENSIONS_FILE = -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- -GENERATE_MAN = NO -MAN_OUTPUT = man -MAN_EXTENSION = .3 -MAN_LINKS = NO -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- -GENERATE_XML = NO -XML_OUTPUT = xml -XML_SCHEMA = -XML_DTD = -XML_PROGRAMLISTING = YES -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- -GENERATE_AUTOGEN_DEF = NO -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- -GENERATE_PERLMOD = NO -PERLMOD_LATEX = NO -PERLMOD_PRETTY = YES -PERLMOD_MAKEVAR_PREFIX = -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- -ENABLE_PREPROCESSING = YES -MACRO_EXPANSION = YES -EXPAND_ONLY_PREDEF = NO -SEARCH_INCLUDES = NO -INCLUDE_PATH = -INCLUDE_FILE_PATTERNS = *.h -PREDEFINED = FT_DECLARE(x)=x \ - FT_MOD_DECLARE(x)=x \ - DoxyDefine(x)=x - -EXPAND_AS_DEFINED = NO -SKIP_FUNCTION_MACROS = NO -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- -TAGFILES = -GENERATE_TAGFILE = -ALLEXTERNALS = NO -EXTERNAL_GROUPS = YES -PERL_PATH = /usr/bin/perl -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- -CLASS_DIAGRAMS = YES -HIDE_UNDOC_RELATIONS = YES -HAVE_DOT = YES -CLASS_GRAPH = YES -COLLABORATION_GRAPH = YES -GROUP_GRAPHS = YES -UML_LOOK = YES -TEMPLATE_RELATIONS = YES -INCLUDE_GRAPH = YES -INCLUDED_BY_GRAPH = YES -CALL_GRAPH = YES -GRAPHICAL_HIERARCHY = YES -DIRECTORY_GRAPH = YES -DOT_IMAGE_FORMAT = jpg -DOT_PATH = -DOTFILE_DIRS = -MAX_DOT_GRAPH_WIDTH = 1024 -MAX_DOT_GRAPH_HEIGHT = 1024 -MAX_DOT_GRAPH_DEPTH = 1000 -DOT_TRANSPARENT = NO -DOT_MULTI_TARGETS = NO -GENERATE_LEGEND = YES -DOT_CLEANUP = YES -#--------------------------------------------------------------------------- -# Configuration::additions related to the search engine -#--------------------------------------------------------------------------- -SEARCHENGINE = NO diff --git a/libs/freetdm/docs/PRI-BRI-Debug.pdf b/libs/freetdm/docs/PRI-BRI-Debug.pdf deleted file mode 100755 index 53386b1b52..0000000000 Binary files a/libs/freetdm/docs/PRI-BRI-Debug.pdf and /dev/null differ diff --git a/libs/freetdm/docs/async.txt b/libs/freetdm/docs/async.txt deleted file mode 100644 index c5d706ecba..0000000000 --- a/libs/freetdm/docs/async.txt +++ /dev/null @@ -1,15 +0,0 @@ -APIs that result in an event when the API returns FTDM_SUCCESS - -ftdm_channel_call_answer() -ftdm_channel_call_indicate() -ftdm_channel_call_transfer() - FTDM_SIGEVENT_INDICATION_COMPLETED - *note that FTDM_SIGEVENT_INDICATION_COMPLETED has associated data to indicate the result of the indication - *note this event is only delivered on non-blocking channels - -ftdm_call_place - FTDM_SIGEVENT_DIALING - -ftdm_channel_call_hangup - FTDM_SIGEVENT_RELEASED - diff --git a/libs/freetdm/docs/ftdm-open-issues.txt b/libs/freetdm/docs/ftdm-open-issues.txt deleted file mode 100644 index 8088c85bd0..0000000000 --- a/libs/freetdm/docs/ftdm-open-issues.txt +++ /dev/null @@ -1,76 +0,0 @@ -== This is an email sent to stkn responding to his post http://stkn.techmage.de/archives/200 == - -1. FreeTDM open channels immediately. - -Yes, this seems to come from the early days of Freetdm where probably the analog modules were implemented first and was dragged incorrectly to ISDN. -The open API also sets the flag in use so others cannot use it. We should decouple this open and reserve operations. Does not seem very hard to do, -I'll take a look at it on my way back to Toronto this week or earlier if possible, I'll create a git branch for it and send you the url for peer review. -Feel free to do the opposite if you are in a hurry. - -2. FreeTDM does not completely close the channel on hangup. - -As long as the signaling module calls ftdm_channel_close() the fio->close API will be called where the IO module is responsible -for turning off ec or any other operations to leave the channel unused/idle (not really closed). There was indeed a bug where ftdm_zt module -was not properly closing the channel, if that is what you mean, then it means that was already fixed by you with your audio mode turn off patch. - -Now, a more lengthy response ... - -When we, Sangoma, took over freetdm and renamed it to freetdm, it was not just a name change, many API cleanups were done so API users cannot access - -the internal data structures and cannot explicitly move between channel states. Also, some order on the state transitions has been put into place. - -We've tried to keep backwards compatibility though, so old modules may not follow all of the conventions. Some unwritten conventions are: - -1. Signaling modules are responsible for calling ftdm_channel_close() when done with the channel. In fact, signaling modules should not - call ftdm_channel_done unless they really know what they're doing. ftdm_channel_close will call ftdm_channel_done anyways. - -2. When remote end hangs up a call, signaling module should go to TERMINATING state and send SIGEVENT_STOP to the user. The signaling stack - should not acknowledge the hangup until the user implicitly moves us to HANGUP (via ftdm_channel_call_hangup()). There is a core timer - that will ensure we move from TERMINATING to HANGUP if the user does not moves us fast enough (arbitrarely 3000ms), although that is considered - a bug in the user application (at some point we saw that in FreeSWITCH) and we complain loudly when that happens. - -3. Signaling modules should leave the channel with NO pending states once they unlock it. This means, whenever you have a message to process - you must lock the channel, check its current state (the user may have already changed the state to something else), process any pending - state set by the user, then process your message and if required move the channel to a new state and process that state before releasing the lock. - There is a chance of a deadlock due to the callbacks we use to notify users of messages if we call those callbacks with the channel lock held and - that is why new signaling modules should use the FTDM_SPAN_USE_SIGNALS_QUEUE to defer the notification to the user when the ftdm_channel_t is not - locked calling ftdm_span_trigger_signals() at the end of their processing loop which delivers the callback notifications to users. - -Having said that, there is a major architectural change coming, probably early 2011, and I'd like to have your input. - -== Decoupling calls from IO channels == - -We've also found that the concept of a channel and a call are unnecesarily coupled together in FreeTDM. I've never asked Anthony the reasoning -for this, but it seems the API was meant to be used with, or without calls. That is, a user should be able to just 'open' a channel and start -reading and writing raw data without ever launching one of the provided signaling stacks on top, may be just because the user is using their -own signaling stack and just needs freetdm as an I/O API. In fact, signaling modules work like this (but there are defects there). -The problem is, as you have noticed, the way ftdm_channel_open_xx APIs has been implemented is abusing this concept. - -Problems with current implementation. - -1. Exclusive channel is the only way we can request channels to the ISDN network. There is no room to change the channel later on easily. -2. Multi-rate calls cannot be done. We need to associate multiple B-channels to a single call. -3. Low-bit-rate calls (not sure what is the proper name for them) where a single B-channel can feed media to multiple calls with a low bit-rate - codec (I know of at least one request from a big company for this to support some Q.SIG stuff for Eurocontrol). - - -What do we need? - -I think there should be only one open() API that wraps calls around fio->open(), the other current open_xx functions that do hunting, should -be eliminated and some extra arguments provided to ftdm_channel_call_place to provide information about the channel where we would like to -place the call or group hunting information and the API would return immediately providing a ftdm_call_t reference pointer that can be used -to further track the status of that call, or in the case where a channel exclusivity was requested and we know for a fact is not available, -just return failure. At that point there is no I/O channel involved yet. Eventually after the signaling stack hunts the channel and -negotiaties its availability with the network, an I/O channel can be attached to that call, or even attach multiple channels (for the case -of multi rate calls?). - -This involves heavy changes. The state machine should be moved out of the ftdm_channel_t structure along with probably some other members -and stuffed into a new ftdm_call_t structure. Signaling modules would have to be updated to run their state machines with this call -structure and then at some point attach IO channels to the call. There would be 2 type of read/write APIs, one low level ftdm_channel_read -which receives an ftdm_channel_t as parameter and an ftdm_call_read() which receives an ftdm_call_t as parameter, for the case of multi-rate -calls or low-bit-rate multiplexed calls in the same B-channel this API would return just the media corresponding to that call already -demultiplexed or concatenated, or whatever needs to be done with the media from the multiple low-level IO channels. - -This is fairly disruptive, but I believe should be done sooner or later. - - diff --git a/libs/freetdm/docs/glare.txt b/libs/freetdm/docs/glare.txt deleted file mode 100644 index 0753db817f..0000000000 --- a/libs/freetdm/docs/glare.txt +++ /dev/null @@ -1,25 +0,0 @@ -Glare is a PITA. - -Although configuration of ISDN links can be done to minimize glare, we also must have a clear policy -on how the FreeTDM API is supposed to behave on glare across signaling modules. - -There is a well-known race in the FreeTDM API since the beginning. When a user wants to place a call with -the old APIs: - -1. ftdm_channel_open_xx (to hunt the channel by group, span or select a channel individually) -2. ftdm_channel_call_place() to place the actual call. - -Since the user has no access to channel locking, between opening a channel and placing a call, an incoming call could be -received. Therefore things can get complicated and that is why you should STOP USING those 2 deprecated functions. - -The replacement is ftdm_call_place(). - -ftdm_call_place receives the information required to hunt the channel and place the call. - -If glare is detected after placing the call and the signaling stack decides to drop the local call, a regular -SIGEVENT_STOP will be sent with the hangup cause FTDM_CAUSE_REQUESTED_CHAN_UNAVAIL. - -ftdm_call_place may return FTDM_BREAK if glare is detected while placing the call, in such cases you can try -calling ftdm_call_place again to hunt another channel. - - diff --git a/libs/freetdm/docs/io_modules.txt b/libs/freetdm/docs/io_modules.txt deleted file mode 100644 index a164bbb249..0000000000 --- a/libs/freetdm/docs/io_modules.txt +++ /dev/null @@ -1,13 +0,0 @@ -Last Updated: Jan 19, 2011 - -== BACKGROUND == - -The IO module provides an abstracted IO interface to FreeTDM. - -== SHUTDOWN == -Upon global shutdown, for each channel FIO_CLOSE_FUNCTION will be called. -When FIO_CLOSE_FUNCTION is called, all waiters on this channel shall be signalled. -If FIO_WAIT_FUNCTION is called on a function that has already been closed, this function shall return FTDM_TIMEOUT without blocking. -FIO_CHANNEL_DESTROY will eventually be called, and IO module is responsible for clearing all internal states and free allocated memory upon channel destroy. - - diff --git a/libs/freetdm/docs/locking.txt b/libs/freetdm/docs/locking.txt deleted file mode 100644 index 851d045b41..0000000000 --- a/libs/freetdm/docs/locking.txt +++ /dev/null @@ -1,125 +0,0 @@ -Last Updated: Fri 30 Dec, 2010 - -== Background == - -FreeTDM is a threaded library. As such, locking considerations must be taken when using it and when writing code inside the library. - -At the moment locks are not exposed to users. This means API users cannot acquire a lock on a channel or span structure. There is no -need for users to lock channels or spans since all their interactions with those structures should be done thru the FreeTDM API which -can (and in most cases must) internally lock on their behalf. - -Internally, locking can be done either by the core or the signaling modules. To better understand the locking considerations we must -understand first the threading model of FreeTDM. - -== Threading Model == - -At startup, when the user calls ftdm_global_init(), just one timing thread is created to dispatch internal timers. If you write -a signaling module or any other code using the scheduling API, you can choose to run your schedule in this timing thread or in -a thread of your choice. This is the only thread launched at initialization. - -If the application decides to use ftdm_global_configuration(), which reads freetdm.conf to create the spans and channels data -structures, then possibly another thread will be launched for CPU usage monitoring (only if enabled in the configuration cpu_monitor=yes -This thread sole purpose is to check the CPU and raise an alarm if reaches a configurable threshold, the alarm then is checked to avoid -placing or receiving further calls. - -At this point FreeTDM has initialized and configured its channels input output configuration. - -The user is then supposed to configure the signaling via ftdm_configure_span_signaling() and then start the signaling work -using ftdm_span_start(). This will typically launch at least 1 thread per span. Some signaling modules (actually just the analog one) -launches another thread per channel when receiving a call. The rest of the signaling modules currently launch only one thread per -span and the signaling for all channels within the span is handled in that thread. We call that thread 'the signaling thread'. - -At this point the user can start placing calls using the FreeTDM call API ftdm_channel_call_place(). Any of the possible threads in -which the user calls the FreeTDM API is called 'the user thread', depending on the application thread model (the application using FreeTDM) -this user thread may be different each time or the same all the time, we cannot make any assumptions. In the case of FreeSWITCH, the most -common user of FreeTDM, the user thread is most of the cases a thread for each new call leg. - -At this point we have identified 4 types of threads. - -1. The timing thread (the core thread that triggers timers). - Its responsibility is simply check for timers that were scheduled and trigger them when the time comes. This means that if you decide - to use the scheduling API in freerun mode (where you use the core timer thread) you callbacks will be executed in this global thread - and you MUST not block at all since there might be other events waiting. - -2. The CPU thread (we don't really care about this one as it does not interact with channels or spans). - -3. The signaling thread. - There is one thread of this per span. This thread takes care of reading signaling specific messages from the network (ISDN network, etc) and - changing the channel call state accordingly and processing state changes caused by user API calls (like ftdm_channel_call_hangup for example). - -4. The user thread. - This is a thread in which the user decides to execute FreeTDM APIs, in some cases it might even be the same than the signaling thread (because - most SIGEVENT notifications are delivered by the signaling thread, however we are advicing users to not use FreeTDM unsafe APIs from the - thread where they receive SIGEVENT notifications as some APIs may block for a few milliseconds, effectively blocking the whole signaling thread - that is servicing a span. - -== Application Locking == - -Users of the FreeTDM API will typically have locking of their own for their own application-specific data structures (in the case of FreeSWITCH, the -session lock for example). Other application-specific locks may be involved. - -== DeadLocks == - -As soon as we think of application locks, and we mix them with the FreeTDM internal locks, the possibility of deadlocks arise. - -A typical deadlock scenario when 2 locks are involved is: - -- User Thread - - Signaling Thread - -1. Application locks applock. 1. A network message is received for a channel. - -2. Aplication invokes a FreeTDM call API (ie: ftdm_channel_call_hangup()). 2. The involved channel is locked. - -3. The FreeTDM API attempts to acquire the channel lock and stalls because 3. The message processing results in a notification - the signaling thread just acquired it. to be delivered to the user via the callback function - provided for that purpose. The callback is then called. - -4. The thread is now deadlocked because the signaling thread will never 4. The application callback attempts to acquire its application - release the channel lock. lock but deadlocks because the user thread already has it. - -To avoid this signaling modules should not deliver signals to the user while holding the channel lock. An easy way to avoid this is -to not deliver signals while processing a state change, but rather defer them until the channel lock is released. Most new signaling modules -accomplish this by setting the span flag FTDM_SPAN_USE_SIGNALS_QUEUE, this flag tells the core to enqueue signals (ie FTDM_SIGEVENT_START) -when ftdm_span_send_signal() is called and not deliver them until ftdm_span_trigger_signals() is called, which is done by the signaling module -in its signaling thread when no channel lock is being held. - -== State changes while locking == - -Only 2 types of threads should be performing state changes. - -User threads. -The user thread is a random thread that was crated by the API user. We do not know what threading model users of FreeTDM will follow -and therefore cannot make assumptions about it. The user should be free to call FreeTDM APIs from any thread, except threads that -are under our control, like the signaling threads. Although it may work in most situations, is discouraged for users to try -to use FreeTDM APIs from the signaling thread, that is, the thread where the signaling callback provided during configuration -is called (the callback where FTDM_SIGEVENT_XXX signals are delivered). - -A user thread may request state changes implicitly through calls to FreeTDM API's. The idea of state changes is internal to freetdm -and should not be exposed to users of the API (except for debugging purposes, like the ftdm_channel_get_state, ftdm_channel_get_state_str etc) - -This is an example of the API's that implicitly request a state change. - -ftdm_channel_call_answer() - -Signaling modules should guarantee that upon releasing a lock on a channel, any state changes will be already processed and -not deferred to other threads, otherwise that leads to a situation where a state change requested by the signaling module is pending -to be serviced by another signaling module thread but a user thread wins the channel lock and attempts to perform a state change which will -fail because another state change is pending (and user threads are not meant to process signaling states). - -ONLY one signaling thread per channel should try to perform state changes and processing of the states, -otherwise complexity arises and is not worth it! - -At some point before we stablished this policies we could have 3 different threads doing state changes. - -1. A user random thread could implcitly try to change the state in response to a call API. -2. The ftmod signaling thread could try to change the state in response to other state changes. -3. The lower level signaling stack threads could try to change the state in response to stack events. - -As a result, lower level signaling stack thread could set a state and then let the signaling thread to -process it, but when unlocking the channel, the user thread may win the lock over the signaling thread and -may try to set a state change of its own and fail (due to the unprocessed state change)! - -The rule is, the signaling module should never unlock a channel with states pending to process this way the user, -when acquiring a channel lock (inside ftdm_channel_call_answer for example) it will always find a consistent state -for the channel and not in the middle of state processing. - - diff --git a/libs/freetdm/docs/sigstatus.txt b/libs/freetdm/docs/sigstatus.txt deleted file mode 100644 index 10561bfb5b..0000000000 --- a/libs/freetdm/docs/sigstatus.txt +++ /dev/null @@ -1,59 +0,0 @@ -FreeTDM can both notify and set signaling status changes in the different protocols thru a unified interface. More -specific details on the C data types and function prototypes are found in freetdm.h - -The API provides the following functions and data types to do it: - -The signaling status in any channel/span is represented thru ftdm_signaling_status_t - - /* The signaling link is down (no d-chans up in the span/group, MFC-R2 bit pattern unidentified) */ - FTDM_SIG_STATE_DOWN, - /* The signaling link is suspended (MFC-R2 bit pattern blocked, PRI maintenance, ss7 blocked?) */ - FTDM_SIG_STATE_SUSPENDED, - /* The signaling link is ready and calls can be placed (ie: d-chan up, MFC-R2 both rx and tx in IDLE) */ - FTDM_SIG_STATE_UP, - /* Invalid status */ - FTDM_SIG_STATE_INVALID - -Changes in the signaling status are notified to the user using the standard callback notification function provided -during configuration using the sigevent type FTDM_SIGEVENT_SIGSTATUS_CHANGED which is sent when the line status changes. - -On startup the signalling status default is FTDM_SIG_STATE_DOWN, and no notification is provided until the state change, -so applications must assume the status is down unless told otherwise. - -When ftdm_span_start is called, the signaling stack takes care of attempting to bring the status to UP -but it will ultimately depend on the other side too. - -== Setting the signaling status == - -Users can set the signaling status on a given channel/span thru FreeTDM the following API functions: - -ftdm_channel_set_sig_status -ftdm_span_set_sig_status - -If the user calls ftdm_channel_set_sig_status(chan, FTDM_SIG_STATE_SUSPENDED), the signaling stack will try to set -the status of the line to the one requested, if successful, it will result in a SIGEVENT_SIGSTATUS_CHANGED notification -being sent with status FTDM_SIG_STATE_SUSPENDED. - -** MFC-R2 Signaling Notes ** -For MFC-R2, calling ftdm_span_start() results in setting the tx CAS bits to IDLE. However, if the rx bits are in BLOCKED state -the signaling status will be reported as SUSPENDED. - -If the user calls ftdm_channel_set_sig_status(chan, SUSPENDED), the tx CAS bits will be set to BLOCKED and, if, the current rx bits -are IDLE then a SIGEVENT_SIGSTATUS_CHANGED with state SUSPENDED will be sent. If the rx bits are already in blocked then no further -SIGEVENT_SIGSTATUS_CHANGED notification is needed (because it was already sent when the rx bits were initially detected as BLOCKED). - -If the user calls ftdm_channel_set_sig_status(chan, UP), the tx CAS bits will be set to IDLE and, if, the current rx bits -are IDLE, then SIGEVENT_SIGSTATUS_CHANGED with state UP will be sent. If the rx bits are BLOCKED, then no notification is -sent at all until the rx bits change. - -Bottom line is, for MFC-R2, SIGEVENT_SIGSTATUS_CHANGED UP is only sent to the user when both the rx and tx bits are in IDLE, and -SIGEVENT_SIGSTATUS_CHANGED SUSPENDED is only sent to the user when any of the rx or tx bits are in BLOCKED. - -== Getting the signaling status == -Users can get the signaling status on a given channel/span thru FreeTDM the following API functions: - -ftdm_channel_get_sig_status -ftdm_span_get_sig_status - -The line status returned should be the same as the last time a SIGEVENT_SIGSTATUS_CHANGED was reported. - diff --git a/libs/freetdm/docs/ss7-native-bridge.txt b/libs/freetdm/docs/ss7-native-bridge.txt deleted file mode 100644 index d44b067b0a..0000000000 --- a/libs/freetdm/docs/ss7-native-bridge.txt +++ /dev/null @@ -1,43 +0,0 @@ -SS7 Native Bridge - -Native bridge is enabled on 2 conditions: - -* The SIP header FreeTDM-TransUUID is set in the originating leg and matches a freetdm channel -* The variable freetdm_native_sigbridge is true and the originating leg is also a freetdm channel - -Some coding rules apply to this feature: - -- Each channel is responsible for clearning its own peer_data and event queue - at the end of the call (when moving to DOWN state) - -- Each channel dequeues messages only from its own queue and enqueues messages - in the peer's queue, with the only exception being messages received before - the bridge is stablished (IAM for sure and possible SAM messages) because - if the bridge is not yet stablished the messages must be queued by the channel - in its own queue temporarily until the bridge is ready - -- When the bridge is ready it is the responsibility of the incoming channel to - move the messages that stored temporarily in its own queue to the bridged peer queue - -- During hangup, each channel is responsible for moving itself to DOWN. The procedure - however differs slightly depending on the hangup conditions - - If the user requests hangup (ie, FreeSWITCH) the request will be noted by setting the - FTDM_CHANNEL_USER_HANGUP flag but will not be processed yet because call control is - driven only by the link messages (so no hangup from ESL or command line allowed) - - When REL message comes, the channel receiving it must move to TERMINATING state and: - - - If the user has not hangup yet (FTDM_CHANNEL_USER_HANGUP flag not set) then - notify the user via SIGEVENT_STOP and wait for the user to move to HANGUP - state by calling ftdm_channel_call_hangup() before sending RLC - - - If the user did hangup already (FTDM_CHANNEL_USER_HANGUP flag is set) then - skip user notification and move to HANGUP state directly where the RLC message - will be sent - -- On HANGUP state the RLC is sent and the channel is moved to DOWN, final state - The peer channel will forward the REL message and wait for RLC from the network, when - RLC is received the channel can move straight to DOWN itself because the peer channel - is completing its own shutdown procedure when it received the REL message - diff --git a/libs/freetdm/docs/variables.txt b/libs/freetdm/docs/variables.txt deleted file mode 100644 index cb518e14d8..0000000000 --- a/libs/freetdm/docs/variables.txt +++ /dev/null @@ -1,122 +0,0 @@ -Using FreeTDM Variables - -1. User application sending variables or raw buffer to FreeTDM -============================================================== - -The User can include a ftdm_usrmsg_t before sending an event to freetdm. - -example #1a - Making an outbound call: --------------------------------------- - -To make an outbound call: - ftdm_usrmsg_t usrmsg; - memset(&usrmsg, 0, sizeof(usrmsg)); - - /* Attach variable to usrmsg */ - ftdm_usrmsg_add_var(&usrmsg, "isdn.prog_ind.descr", "inband-info-available"); - - ftdm_channel_call_place_ex(ftdmchan, &usrmsg); - -example #1b - Adding a variable: --------------------------------- -When using ftmod_sangoma_isdn, user want to specify progress indicator inside PROCEED message. - - - ftdm_usrmsg_t usrmsg; - memset(&usrmsg, 0, sizeof(usrmsg)); - - /* Attach variable to usrmsg */ - ftdm_usrmsg_add_var(&usrmsg, "isdn.prog_ind.descr", "inband-info-available"); - - /* Request FreeTDM to send a PROCEED msg */ - ftdm_channel_call_indicate_ex(ftdmchan, FTDM_CHANNEL_INDICATE_PROCEED, &usrmsg); - - -example #2 - Setting raw data: --------------------------------------------------------- - -When using ftmod_sangoma_isdn, user wants to transmit a custom Facility IE, inside a FACILITY message. - - ftdm_usrmsg_t usrmsg; - - uint8_t *my_facility_ie = ftdm_calloc(1, 200); /*memory has to be allocated using ftdm_calloc !! */ - unsigned my_facility_ie_len = 0; - - memset(&usrmsg, 0, sizeof(usrmsg)); - - /* Fill my_facility_ie with custom data here */ - my_facility_ie[my_facility_ie_len++] = 0x1C; /* Q.931 Facility IE ID */ - my_facility_ie[my_facility_ie_len++] = 0x03; /* Length of facility IE */ - my_facility_ie[my_facility_ie_len++] = 0x01; - my_facility_ie[my_facility_ie_len++] = 0x02; - my_facility_ie[my_facility_ie_len++] = 0x03; - - ftdm_usrmsg_set_raw_data(&usrmsg, my_facility_ie, my_facility_ie_len); - - ftdm_channel_call_indicate_ex(ftdmchan, FTDM_CHANNEL_INDICATE_FACILITY, &usrmsg); - - /* FreeTDM will automatically free my_facility_ie */ - - -2. User application receiving variables and raw buffer from FreeTDM -================================================================== - -example #1 - print all variables received from FreeTDM ------------------------------------------------------- - - /* Inside event call-back function */ - ftdm_iterator_t *iter = NULL; - ftdm_iterator_t *curr = NULL; - const char *var_name = NULL; - const char *var_value = NULL; - - /* Read all variables attached to this event */ - iter = ftdm_sigmsg_get_var_iterator(sigmsg, iter); - for (curr = iter ; curr; curr = ftdm_iterator_next(curr)) { - ftdm_get_current_var(curr, &var_name, &var_value); - fprintf("Call Variable: %s=%s\n", var_name, var_value); - } - ftdm_iterator_free(iter); - - -example #2 - accessing a specific variable ------------------------------------------- - - /* Inside event call-back function */ - char *string = NULL; - string = ftdm_sigmsg_get_var(sigmsg, "isdn.prog_ind.descr"); - if (string && *string) { - fprintf("Progress indicator:%s\n", string); - } - - -example #3a - accessing raw data -------------------------------- - - /* Inside event call-back function */ - ftdm_size_t len; - uint8_t *mydata; - if (ftdm_sigmsg_get_raw_data(sigmsg, (void**)&mydata, &len) == FTDM_SUCCESS) { - /* raw data is available, do something with mydata here */ - } - /* Once this function returns, raw data will be free'd inside FreeTDM */ - - -example #3b - accessing raw data -------------------------------- - - /* Inside event call-back function */ - ftdm_size_t len; - uint8_t *mydata; - if (ftdm_sigmsg_get_raw_data_detached(sigmsg, (void**)&mydata, &len) == FTDM_SUCCESS) { - /* raw data is available, do something with mydata here */ - - } - - : - : - : - - /* User owns raw data and is responsible for free'ing it*/ - ftdm_safe_free(mydata); - diff --git a/libs/freetdm/freetdm.2008.sln b/libs/freetdm/freetdm.2008.sln deleted file mode 100644 index 4bf2c795a6..0000000000 --- a/libs/freetdm/freetdm.2008.sln +++ /dev/null @@ -1,155 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "freetdm", "msvc\freetdm.2008.vcproj", "{93B8812C-3EC4-4F78-8970-FFBFC99E167D}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testanalog", "msvc\testanalog\testanalog.2008.vcproj", "{BB833648-BAFF-4BE2-94DB-F8BB043C588C}" - ProjectSection(ProjectDependencies) = postProject - {93B8812C-3EC4-4F78-8970-FFBFC99E167D} = {93B8812C-3EC4-4F78-8970-FFBFC99E167D} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testisdn", "msvc\testisdn\testisdn.2008.vcproj", "{6DA6FD42-641D-4147-92F5-3BC4AAA6589B}" - ProjectSection(ProjectDependencies) = postProject - {93B8812C-3EC4-4F78-8970-FFBFC99E167D} = {93B8812C-3EC4-4F78-8970-FFBFC99E167D} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_freetdm", "mod_freetdm\mod_freetdm.2008.vcproj", "{FE3540C5-3303-46E0-A69E-D92F775687F1}" - ProjectSection(ProjectDependencies) = postProject - {93B8812C-3EC4-4F78-8970-FFBFC99E167D} = {93B8812C-3EC4-4F78-8970-FFBFC99E167D} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_analog", "src\ftmod\ftmod_analog\ftmod_analog.2008.vcproj", "{37C94798-6E33-4B4F-8EE0-C72A7DC91157}" - ProjectSection(ProjectDependencies) = postProject - {93B8812C-3EC4-4F78-8970-FFBFC99E167D} = {93B8812C-3EC4-4F78-8970-FFBFC99E167D} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_analog_em", "src\ftmod\ftmod_analog_em\ftmod_analog_em.2008.vcproj", "{B3F49375-2834-4937-9D8C-4AC2EC911010}" - ProjectSection(ProjectDependencies) = postProject - {93B8812C-3EC4-4F78-8970-FFBFC99E167D} = {93B8812C-3EC4-4F78-8970-FFBFC99E167D} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_isdn", "src\ftmod\ftmod_isdn\ftmod_isdn.2008.vcproj", "{729344A5-D5E9-434D-8EE8-AF8C6C795D15}" - ProjectSection(ProjectDependencies) = postProject - {93B8812C-3EC4-4F78-8970-FFBFC99E167D} = {93B8812C-3EC4-4F78-8970-FFBFC99E167D} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_pika", "src\ftmod\ftmod_pika\ftmod_pika.2008.vcproj", "{E886B4D5-AB4F-4092-B8F4-3B06E1E462EF}" - ProjectSection(ProjectDependencies) = postProject - {93B8812C-3EC4-4F78-8970-FFBFC99E167D} = {93B8812C-3EC4-4F78-8970-FFBFC99E167D} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_wanpipe", "src\ftmod\ftmod_wanpipe\ftmod_wanpipe.2008.vcproj", "{1A145EE9-BBD8-45E5-98CD-EB4BE99E1DCD}" - ProjectSection(ProjectDependencies) = postProject - {93B8812C-3EC4-4F78-8970-FFBFC99E167D} = {93B8812C-3EC4-4F78-8970-FFBFC99E167D} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_sangoma_isdn", "src\ftmod\ftmod_sangoma_isdn\ftmod_sangoma_isdn.2008.vcproj", "{B2AF4EA6-0CD7-4529-9EB5-5AF43DB90395}" - ProjectSection(ProjectDependencies) = postProject - {93B8812C-3EC4-4F78-8970-FFBFC99E167D} = {93B8812C-3EC4-4F78-8970-FFBFC99E167D} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_r2", "src\ftmod\ftmod_r2\ftmod_r2.2008.vcproj", "{08C3EA27-A51D-47F8-B47D-B189C649CF30}" - ProjectSection(ProjectDependencies) = postProject - {93B8812C-3EC4-4F78-8970-FFBFC99E167D} = {93B8812C-3EC4-4F78-8970-FFBFC99E167D} - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {93B8812C-3EC4-4F78-8970-FFBFC99E167D}.Debug|Win32.ActiveCfg = Debug|Win32 - {93B8812C-3EC4-4F78-8970-FFBFC99E167D}.Debug|Win32.Build.0 = Debug|Win32 - {93B8812C-3EC4-4F78-8970-FFBFC99E167D}.Debug|x64.ActiveCfg = Debug|x64 - {93B8812C-3EC4-4F78-8970-FFBFC99E167D}.Debug|x64.Build.0 = Debug|x64 - {93B8812C-3EC4-4F78-8970-FFBFC99E167D}.Release|Win32.ActiveCfg = Release|Win32 - {93B8812C-3EC4-4F78-8970-FFBFC99E167D}.Release|Win32.Build.0 = Release|Win32 - {93B8812C-3EC4-4F78-8970-FFBFC99E167D}.Release|x64.ActiveCfg = Release|x64 - {93B8812C-3EC4-4F78-8970-FFBFC99E167D}.Release|x64.Build.0 = Release|x64 - {BB833648-BAFF-4BE2-94DB-F8BB043C588C}.Debug|Win32.ActiveCfg = Debug|Win32 - {BB833648-BAFF-4BE2-94DB-F8BB043C588C}.Debug|Win32.Build.0 = Debug|Win32 - {BB833648-BAFF-4BE2-94DB-F8BB043C588C}.Debug|x64.ActiveCfg = Debug|x64 - {BB833648-BAFF-4BE2-94DB-F8BB043C588C}.Debug|x64.Build.0 = Debug|x64 - {BB833648-BAFF-4BE2-94DB-F8BB043C588C}.Release|Win32.ActiveCfg = Release|Win32 - {BB833648-BAFF-4BE2-94DB-F8BB043C588C}.Release|Win32.Build.0 = Release|Win32 - {BB833648-BAFF-4BE2-94DB-F8BB043C588C}.Release|x64.ActiveCfg = Release|x64 - {BB833648-BAFF-4BE2-94DB-F8BB043C588C}.Release|x64.Build.0 = Release|x64 - {6DA6FD42-641D-4147-92F5-3BC4AAA6589B}.Debug|Win32.ActiveCfg = Debug|Win32 - {6DA6FD42-641D-4147-92F5-3BC4AAA6589B}.Debug|x64.ActiveCfg = Debug|x64 - {6DA6FD42-641D-4147-92F5-3BC4AAA6589B}.Release|Win32.ActiveCfg = Release|Win32 - {6DA6FD42-641D-4147-92F5-3BC4AAA6589B}.Release|x64.ActiveCfg = Release|x64 - {FE3540C5-3303-46E0-A69E-D92F775687F1}.Debug|Win32.ActiveCfg = Debug|Win32 - {FE3540C5-3303-46E0-A69E-D92F775687F1}.Debug|Win32.Build.0 = Debug|Win32 - {FE3540C5-3303-46E0-A69E-D92F775687F1}.Debug|x64.ActiveCfg = Debug|x64 - {FE3540C5-3303-46E0-A69E-D92F775687F1}.Debug|x64.Build.0 = Debug|x64 - {FE3540C5-3303-46E0-A69E-D92F775687F1}.Release|Win32.ActiveCfg = Release|Win32 - {FE3540C5-3303-46E0-A69E-D92F775687F1}.Release|Win32.Build.0 = Release|Win32 - {FE3540C5-3303-46E0-A69E-D92F775687F1}.Release|x64.ActiveCfg = Release|x64 - {FE3540C5-3303-46E0-A69E-D92F775687F1}.Release|x64.Build.0 = Release|x64 - {37C94798-6E33-4B4F-8EE0-C72A7DC91157}.Debug|Win32.ActiveCfg = Debug|Win32 - {37C94798-6E33-4B4F-8EE0-C72A7DC91157}.Debug|Win32.Build.0 = Debug|Win32 - {37C94798-6E33-4B4F-8EE0-C72A7DC91157}.Debug|x64.ActiveCfg = Debug|x64 - {37C94798-6E33-4B4F-8EE0-C72A7DC91157}.Debug|x64.Build.0 = Debug|x64 - {37C94798-6E33-4B4F-8EE0-C72A7DC91157}.Release|Win32.ActiveCfg = Release|Win32 - {37C94798-6E33-4B4F-8EE0-C72A7DC91157}.Release|Win32.Build.0 = Release|Win32 - {37C94798-6E33-4B4F-8EE0-C72A7DC91157}.Release|x64.ActiveCfg = Release|x64 - {37C94798-6E33-4B4F-8EE0-C72A7DC91157}.Release|x64.Build.0 = Release|x64 - {B3F49375-2834-4937-9D8C-4AC2EC911010}.Debug|Win32.ActiveCfg = Debug|Win32 - {B3F49375-2834-4937-9D8C-4AC2EC911010}.Debug|Win32.Build.0 = Debug|Win32 - {B3F49375-2834-4937-9D8C-4AC2EC911010}.Debug|x64.ActiveCfg = Debug|x64 - {B3F49375-2834-4937-9D8C-4AC2EC911010}.Debug|x64.Build.0 = Debug|x64 - {B3F49375-2834-4937-9D8C-4AC2EC911010}.Release|Win32.ActiveCfg = Release|Win32 - {B3F49375-2834-4937-9D8C-4AC2EC911010}.Release|Win32.Build.0 = Release|Win32 - {B3F49375-2834-4937-9D8C-4AC2EC911010}.Release|x64.ActiveCfg = Release|x64 - {B3F49375-2834-4937-9D8C-4AC2EC911010}.Release|x64.Build.0 = Release|x64 - {729344A5-D5E9-434D-8EE8-AF8C6C795D15}.Debug|Win32.ActiveCfg = Debug|Win32 - {729344A5-D5E9-434D-8EE8-AF8C6C795D15}.Debug|x64.ActiveCfg = Debug|x64 - {729344A5-D5E9-434D-8EE8-AF8C6C795D15}.Release|Win32.ActiveCfg = Release|Win32 - {729344A5-D5E9-434D-8EE8-AF8C6C795D15}.Release|x64.ActiveCfg = Release|x64 - {E886B4D5-AB4F-4092-B8F4-3B06E1E462EF}.Debug|Win32.ActiveCfg = Debug|Win32 - {E886B4D5-AB4F-4092-B8F4-3B06E1E462EF}.Debug|x64.ActiveCfg = Debug|x64 - {E886B4D5-AB4F-4092-B8F4-3B06E1E462EF}.Release|Win32.ActiveCfg = Release|Win32 - {E886B4D5-AB4F-4092-B8F4-3B06E1E462EF}.Release|x64.ActiveCfg = Release|x64 - {1A145EE9-BBD8-45E5-98CD-EB4BE99E1DCD}.Debug|Win32.ActiveCfg = Debug|Win32 - {1A145EE9-BBD8-45E5-98CD-EB4BE99E1DCD}.Debug|Win32.Build.0 = Debug|Win32 - {1A145EE9-BBD8-45E5-98CD-EB4BE99E1DCD}.Debug|x64.ActiveCfg = Debug|x64 - {1A145EE9-BBD8-45E5-98CD-EB4BE99E1DCD}.Release|Win32.ActiveCfg = Release|Win32 - {1A145EE9-BBD8-45E5-98CD-EB4BE99E1DCD}.Release|x64.ActiveCfg = Release|x64 - {D021EF2A-460D-4827-A0F7-41FDECF46F1B}.Debug|Win32.ActiveCfg = Debug|Win32 - {D021EF2A-460D-4827-A0F7-41FDECF46F1B}.Debug|x64.ActiveCfg = Debug|x64 - {D021EF2A-460D-4827-A0F7-41FDECF46F1B}.Debug|x64.Build.0 = Debug|x64 - {D021EF2A-460D-4827-A0F7-41FDECF46F1B}.Release|Win32.ActiveCfg = Release|Win32 - {D021EF2A-460D-4827-A0F7-41FDECF46F1B}.Release|Win32.Build.0 = Release|Win32 - {D021EF2A-460D-4827-A0F7-41FDECF46F1B}.Release|x64.ActiveCfg = Release|x64 - {D021EF2A-460D-4827-A0F7-41FDECF46F1B}.Release|x64.Build.0 = Release|x64 - {2B1BAF36-0241-43E7-B865-A8338AD48E2E}.Debug|Win32.ActiveCfg = Debug|Win32 - {2B1BAF36-0241-43E7-B865-A8338AD48E2E}.Debug|x64.ActiveCfg = Debug|x64 - {2B1BAF36-0241-43E7-B865-A8338AD48E2E}.Debug|x64.Build.0 = Debug|x64 - {2B1BAF36-0241-43E7-B865-A8338AD48E2E}.Release|Win32.ActiveCfg = Release|Win32 - {2B1BAF36-0241-43E7-B865-A8338AD48E2E}.Release|Win32.Build.0 = Release|Win32 - {2B1BAF36-0241-43E7-B865-A8338AD48E2E}.Release|x64.ActiveCfg = Release|x64 - {2B1BAF36-0241-43E7-B865-A8338AD48E2E}.Release|x64.Build.0 = Release|x64 - {0DA69C18-4FA1-4E8C-89CE-12498637C5BE}.Debug|Win32.ActiveCfg = Debug|Win32 - {0DA69C18-4FA1-4E8C-89CE-12498637C5BE}.Debug|x64.ActiveCfg = Debug|x64 - {0DA69C18-4FA1-4E8C-89CE-12498637C5BE}.Debug|x64.Build.0 = Debug|x64 - {0DA69C18-4FA1-4E8C-89CE-12498637C5BE}.Release|Win32.ActiveCfg = Release|Win32 - {0DA69C18-4FA1-4E8C-89CE-12498637C5BE}.Release|Win32.Build.0 = Release|Win32 - {0DA69C18-4FA1-4E8C-89CE-12498637C5BE}.Release|x64.ActiveCfg = Release|x64 - {0DA69C18-4FA1-4E8C-89CE-12498637C5BE}.Release|x64.Build.0 = Release|x64 - {B2AF4EA6-0CD7-4529-9EB5-5AF43DB90395}.Debug|Win32.ActiveCfg = Debug|Win32 - {B2AF4EA6-0CD7-4529-9EB5-5AF43DB90395}.Debug|x64.ActiveCfg = Debug|Win32 - {B2AF4EA6-0CD7-4529-9EB5-5AF43DB90395}.Release|Win32.ActiveCfg = Release|Win32 - {B2AF4EA6-0CD7-4529-9EB5-5AF43DB90395}.Release|Win32.Build.0 = Release|Win32 - {B2AF4EA6-0CD7-4529-9EB5-5AF43DB90395}.Release|x64.ActiveCfg = Release|Win32 - {08C3EA27-A51D-47F8-B47D-B189C649CF30}.Debug|Win32.ActiveCfg = Debug|Win32 - {08C3EA27-A51D-47F8-B47D-B189C649CF30}.Debug|x64.ActiveCfg = Debug|Win32 - {08C3EA27-A51D-47F8-B47D-B189C649CF30}.Release|Win32.ActiveCfg = Release|Win32 - {08C3EA27-A51D-47F8-B47D-B189C649CF30}.Release|x64.ActiveCfg = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/libs/freetdm/freetdm.2010.sln b/libs/freetdm/freetdm.2010.sln deleted file mode 100644 index b6259e5960..0000000000 --- a/libs/freetdm/freetdm.2010.sln +++ /dev/null @@ -1,127 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "freetdm", "msvc\freetdm.2010.vcxproj", "{93B8812C-3EC4-4F78-8970-FFBFC99E167D}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testanalog", "msvc\testanalog\testanalog.2010.vcxproj", "{BB833648-BAFF-4BE2-94DB-F8BB043C588C}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testisdn", "msvc\testisdn\testisdn.2010.vcxproj", "{6DA6FD42-641D-4147-92F5-3BC4AAA6589B}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_freetdm", "mod_freetdm\mod_freetdm.2010.vcxproj", "{FE3540C5-3303-46E0-A69E-D92F775687F1}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_analog", "src\ftmod\ftmod_analog\ftmod_analog.2010.vcxproj", "{37C94798-6E33-4B4F-8EE0-C72A7DC91157}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_analog_em", "src\ftmod\ftmod_analog_em\ftmod_analog_em.2010.vcxproj", "{B3F49375-2834-4937-9D8C-4AC2EC911010}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_isdn", "src\ftmod\ftmod_isdn\ftmod_isdn.2010.vcxproj", "{729344A5-D5E9-434D-8EE8-AF8C6C795D15}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_pika", "src\ftmod\ftmod_pika\ftmod_pika.2010.vcxproj", "{E886B4D5-AB4F-4092-B8F4-3B06E1E462EF}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_wanpipe", "src\ftmod\ftmod_wanpipe\ftmod_wanpipe.2010.vcxproj", "{1A145EE9-BBD8-45E5-98CD-EB4BE99E1DCD}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_sangoma_isdn", "src\ftmod\ftmod_sangoma_isdn\ftmod_sangoma_isdn.2010.vcxproj", "{B2AF4EA6-0CD7-4529-9EB5-5AF43DB90395}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_r2", "src\ftmod\ftmod_r2\ftmod_r2.2010.vcxproj", "{08C3EA27-A51D-47F8-B47D-B189C649CF30}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {93B8812C-3EC4-4F78-8970-FFBFC99E167D}.Debug|Win32.ActiveCfg = Debug|Win32 - {93B8812C-3EC4-4F78-8970-FFBFC99E167D}.Debug|Win32.Build.0 = Debug|Win32 - {93B8812C-3EC4-4F78-8970-FFBFC99E167D}.Debug|x64.ActiveCfg = Debug|x64 - {93B8812C-3EC4-4F78-8970-FFBFC99E167D}.Debug|x64.Build.0 = Debug|x64 - {93B8812C-3EC4-4F78-8970-FFBFC99E167D}.Release|Win32.ActiveCfg = Release|Win32 - {93B8812C-3EC4-4F78-8970-FFBFC99E167D}.Release|Win32.Build.0 = Release|Win32 - {93B8812C-3EC4-4F78-8970-FFBFC99E167D}.Release|x64.ActiveCfg = Release|x64 - {93B8812C-3EC4-4F78-8970-FFBFC99E167D}.Release|x64.Build.0 = Release|x64 - {BB833648-BAFF-4BE2-94DB-F8BB043C588C}.Debug|Win32.ActiveCfg = Debug|Win32 - {BB833648-BAFF-4BE2-94DB-F8BB043C588C}.Debug|Win32.Build.0 = Debug|Win32 - {BB833648-BAFF-4BE2-94DB-F8BB043C588C}.Debug|x64.ActiveCfg = Debug|x64 - {BB833648-BAFF-4BE2-94DB-F8BB043C588C}.Debug|x64.Build.0 = Debug|x64 - {BB833648-BAFF-4BE2-94DB-F8BB043C588C}.Release|Win32.ActiveCfg = Release|Win32 - {BB833648-BAFF-4BE2-94DB-F8BB043C588C}.Release|Win32.Build.0 = Release|Win32 - {BB833648-BAFF-4BE2-94DB-F8BB043C588C}.Release|x64.ActiveCfg = Release|x64 - {BB833648-BAFF-4BE2-94DB-F8BB043C588C}.Release|x64.Build.0 = Release|x64 - {6DA6FD42-641D-4147-92F5-3BC4AAA6589B}.Debug|Win32.ActiveCfg = Debug|Win32 - {6DA6FD42-641D-4147-92F5-3BC4AAA6589B}.Debug|x64.ActiveCfg = Debug|x64 - {6DA6FD42-641D-4147-92F5-3BC4AAA6589B}.Release|Win32.ActiveCfg = Release|Win32 - {6DA6FD42-641D-4147-92F5-3BC4AAA6589B}.Release|x64.ActiveCfg = Release|x64 - {FE3540C5-3303-46E0-A69E-D92F775687F1}.Debug|Win32.ActiveCfg = Debug|Win32 - {FE3540C5-3303-46E0-A69E-D92F775687F1}.Debug|Win32.Build.0 = Debug|Win32 - {FE3540C5-3303-46E0-A69E-D92F775687F1}.Debug|x64.ActiveCfg = Debug|x64 - {FE3540C5-3303-46E0-A69E-D92F775687F1}.Debug|x64.Build.0 = Debug|x64 - {FE3540C5-3303-46E0-A69E-D92F775687F1}.Release|Win32.ActiveCfg = Release|Win32 - {FE3540C5-3303-46E0-A69E-D92F775687F1}.Release|Win32.Build.0 = Release|Win32 - {FE3540C5-3303-46E0-A69E-D92F775687F1}.Release|x64.ActiveCfg = Release|x64 - {FE3540C5-3303-46E0-A69E-D92F775687F1}.Release|x64.Build.0 = Release|x64 - {37C94798-6E33-4B4F-8EE0-C72A7DC91157}.Debug|Win32.ActiveCfg = Debug|Win32 - {37C94798-6E33-4B4F-8EE0-C72A7DC91157}.Debug|Win32.Build.0 = Debug|Win32 - {37C94798-6E33-4B4F-8EE0-C72A7DC91157}.Debug|x64.ActiveCfg = Debug|x64 - {37C94798-6E33-4B4F-8EE0-C72A7DC91157}.Debug|x64.Build.0 = Debug|x64 - {37C94798-6E33-4B4F-8EE0-C72A7DC91157}.Release|Win32.ActiveCfg = Release|Win32 - {37C94798-6E33-4B4F-8EE0-C72A7DC91157}.Release|Win32.Build.0 = Release|Win32 - {37C94798-6E33-4B4F-8EE0-C72A7DC91157}.Release|x64.ActiveCfg = Release|x64 - {37C94798-6E33-4B4F-8EE0-C72A7DC91157}.Release|x64.Build.0 = Release|x64 - {B3F49375-2834-4937-9D8C-4AC2EC911010}.Debug|Win32.ActiveCfg = Debug|Win32 - {B3F49375-2834-4937-9D8C-4AC2EC911010}.Debug|Win32.Build.0 = Debug|Win32 - {B3F49375-2834-4937-9D8C-4AC2EC911010}.Debug|x64.ActiveCfg = Debug|x64 - {B3F49375-2834-4937-9D8C-4AC2EC911010}.Debug|x64.Build.0 = Debug|x64 - {B3F49375-2834-4937-9D8C-4AC2EC911010}.Release|Win32.ActiveCfg = Release|Win32 - {B3F49375-2834-4937-9D8C-4AC2EC911010}.Release|Win32.Build.0 = Release|Win32 - {B3F49375-2834-4937-9D8C-4AC2EC911010}.Release|x64.ActiveCfg = Release|x64 - {B3F49375-2834-4937-9D8C-4AC2EC911010}.Release|x64.Build.0 = Release|x64 - {729344A5-D5E9-434D-8EE8-AF8C6C795D15}.Debug|Win32.ActiveCfg = Debug|Win32 - {729344A5-D5E9-434D-8EE8-AF8C6C795D15}.Debug|x64.ActiveCfg = Debug|x64 - {729344A5-D5E9-434D-8EE8-AF8C6C795D15}.Release|Win32.ActiveCfg = Release|Win32 - {729344A5-D5E9-434D-8EE8-AF8C6C795D15}.Release|x64.ActiveCfg = Release|x64 - {E886B4D5-AB4F-4092-B8F4-3B06E1E462EF}.Debug|Win32.ActiveCfg = Debug|Win32 - {E886B4D5-AB4F-4092-B8F4-3B06E1E462EF}.Debug|x64.ActiveCfg = Debug|x64 - {E886B4D5-AB4F-4092-B8F4-3B06E1E462EF}.Release|Win32.ActiveCfg = Release|Win32 - {E886B4D5-AB4F-4092-B8F4-3B06E1E462EF}.Release|x64.ActiveCfg = Release|x64 - {1A145EE9-BBD8-45E5-98CD-EB4BE99E1DCD}.Debug|Win32.ActiveCfg = Debug|Win32 - {1A145EE9-BBD8-45E5-98CD-EB4BE99E1DCD}.Debug|Win32.Build.0 = Debug|Win32 - {1A145EE9-BBD8-45E5-98CD-EB4BE99E1DCD}.Debug|x64.ActiveCfg = Debug|x64 - {1A145EE9-BBD8-45E5-98CD-EB4BE99E1DCD}.Release|Win32.ActiveCfg = Release|Win32 - {1A145EE9-BBD8-45E5-98CD-EB4BE99E1DCD}.Release|x64.ActiveCfg = Release|x64 - {D021EF2A-460D-4827-A0F7-41FDECF46F1B}.Debug|Win32.ActiveCfg = Debug|Win32 - {D021EF2A-460D-4827-A0F7-41FDECF46F1B}.Debug|Win32.Build.0 = Debug|Win32 - {D021EF2A-460D-4827-A0F7-41FDECF46F1B}.Debug|x64.ActiveCfg = Debug|x64 - {D021EF2A-460D-4827-A0F7-41FDECF46F1B}.Debug|x64.Build.0 = Debug|x64 - {D021EF2A-460D-4827-A0F7-41FDECF46F1B}.Release|Win32.ActiveCfg = Release|Win32 - {D021EF2A-460D-4827-A0F7-41FDECF46F1B}.Release|Win32.Build.0 = Release|Win32 - {D021EF2A-460D-4827-A0F7-41FDECF46F1B}.Release|x64.ActiveCfg = Release|x64 - {D021EF2A-460D-4827-A0F7-41FDECF46F1B}.Release|x64.Build.0 = Release|x64 - {2B1BAF36-0241-43E7-B865-A8338AD48E2E}.Debug|Win32.ActiveCfg = Debug|Win32 - {2B1BAF36-0241-43E7-B865-A8338AD48E2E}.Debug|Win32.Build.0 = Debug|Win32 - {2B1BAF36-0241-43E7-B865-A8338AD48E2E}.Debug|x64.ActiveCfg = Debug|x64 - {2B1BAF36-0241-43E7-B865-A8338AD48E2E}.Debug|x64.Build.0 = Debug|x64 - {2B1BAF36-0241-43E7-B865-A8338AD48E2E}.Release|Win32.ActiveCfg = Release|Win32 - {2B1BAF36-0241-43E7-B865-A8338AD48E2E}.Release|Win32.Build.0 = Release|Win32 - {2B1BAF36-0241-43E7-B865-A8338AD48E2E}.Release|x64.ActiveCfg = Release|x64 - {2B1BAF36-0241-43E7-B865-A8338AD48E2E}.Release|x64.Build.0 = Release|x64 - {0DA69C18-4FA1-4E8C-89CE-12498637C5BE}.Debug|Win32.ActiveCfg = Debug|Win32 - {0DA69C18-4FA1-4E8C-89CE-12498637C5BE}.Debug|Win32.Build.0 = Debug|Win32 - {0DA69C18-4FA1-4E8C-89CE-12498637C5BE}.Debug|x64.ActiveCfg = Debug|x64 - {0DA69C18-4FA1-4E8C-89CE-12498637C5BE}.Debug|x64.Build.0 = Debug|x64 - {0DA69C18-4FA1-4E8C-89CE-12498637C5BE}.Release|Win32.ActiveCfg = Release|Win32 - {0DA69C18-4FA1-4E8C-89CE-12498637C5BE}.Release|Win32.Build.0 = Release|Win32 - {0DA69C18-4FA1-4E8C-89CE-12498637C5BE}.Release|x64.ActiveCfg = Release|x64 - {0DA69C18-4FA1-4E8C-89CE-12498637C5BE}.Release|x64.Build.0 = Release|x64 - {B2AF4EA6-0CD7-4529-9EB5-5AF43DB90395}.Debug|Win32.ActiveCfg = Debug|Win32 - {B2AF4EA6-0CD7-4529-9EB5-5AF43DB90395}.Debug|x64.ActiveCfg = Debug|x64 - {B2AF4EA6-0CD7-4529-9EB5-5AF43DB90395}.Release|Win32.ActiveCfg = Release|Win32 - {B2AF4EA6-0CD7-4529-9EB5-5AF43DB90395}.Release|x64.ActiveCfg = Release|x64 - {08C3EA27-A51D-47F8-B47D-B189C649CF30}.Debug|Win32.ActiveCfg = Debug|Win32 - {08C3EA27-A51D-47F8-B47D-B189C649CF30}.Debug|x64.ActiveCfg = Debug|x64 - {08C3EA27-A51D-47F8-B47D-B189C649CF30}.Release|Win32.ActiveCfg = Release|Win32 - {08C3EA27-A51D-47F8-B47D-B189C649CF30}.Release|x64.ActiveCfg = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/libs/freetdm/freetdm.2012.sln b/libs/freetdm/freetdm.2012.sln deleted file mode 100644 index 1d4c335a8d..0000000000 --- a/libs/freetdm/freetdm.2012.sln +++ /dev/null @@ -1,127 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2012 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "freetdm", "msvc\freetdm.2012.vcxproj", "{93B8812C-3EC4-4F78-8970-FFBFC99E167D}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testanalog", "msvc\testanalog\testanalog.2012.vcxproj", "{BB833648-BAFF-4BE2-94DB-F8BB043C588C}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testisdn", "msvc\testisdn\testisdn.2012.vcxproj", "{6DA6FD42-641D-4147-92F5-3BC4AAA6589B}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_freetdm", "mod_freetdm\mod_freetdm.2012.vcxproj", "{FE3540C5-3303-46E0-A69E-D92F775687F1}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_analog", "src\ftmod\ftmod_analog\ftmod_analog.2012.vcxproj", "{37C94798-6E33-4B4F-8EE0-C72A7DC91157}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_analog_em", "src\ftmod\ftmod_analog_em\ftmod_analog_em.2012.vcxproj", "{B3F49375-2834-4937-9D8C-4AC2EC911010}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_isdn", "src\ftmod\ftmod_isdn\ftmod_isdn.2012.vcxproj", "{729344A5-D5E9-434D-8EE8-AF8C6C795D15}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_pika", "src\ftmod\ftmod_pika\ftmod_pika.2012.vcxproj", "{E886B4D5-AB4F-4092-B8F4-3B06E1E462EF}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_wanpipe", "src\ftmod\ftmod_wanpipe\ftmod_wanpipe.2012.vcxproj", "{1A145EE9-BBD8-45E5-98CD-EB4BE99E1DCD}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_sangoma_isdn", "src\ftmod\ftmod_sangoma_isdn\ftmod_sangoma_isdn.2012.vcxproj", "{B2AF4EA6-0CD7-4529-9EB5-5AF43DB90395}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_r2", "src\ftmod\ftmod_r2\ftmod_r2.2012.vcxproj", "{08C3EA27-A51D-47F8-B47D-B189C649CF30}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {93B8812C-3EC4-4F78-8970-FFBFC99E167D}.Debug|Win32.ActiveCfg = Debug|Win32 - {93B8812C-3EC4-4F78-8970-FFBFC99E167D}.Debug|Win32.Build.0 = Debug|Win32 - {93B8812C-3EC4-4F78-8970-FFBFC99E167D}.Debug|x64.ActiveCfg = Debug|x64 - {93B8812C-3EC4-4F78-8970-FFBFC99E167D}.Debug|x64.Build.0 = Debug|x64 - {93B8812C-3EC4-4F78-8970-FFBFC99E167D}.Release|Win32.ActiveCfg = Release|Win32 - {93B8812C-3EC4-4F78-8970-FFBFC99E167D}.Release|Win32.Build.0 = Release|Win32 - {93B8812C-3EC4-4F78-8970-FFBFC99E167D}.Release|x64.ActiveCfg = Release|x64 - {93B8812C-3EC4-4F78-8970-FFBFC99E167D}.Release|x64.Build.0 = Release|x64 - {BB833648-BAFF-4BE2-94DB-F8BB043C588C}.Debug|Win32.ActiveCfg = Debug|Win32 - {BB833648-BAFF-4BE2-94DB-F8BB043C588C}.Debug|Win32.Build.0 = Debug|Win32 - {BB833648-BAFF-4BE2-94DB-F8BB043C588C}.Debug|x64.ActiveCfg = Debug|x64 - {BB833648-BAFF-4BE2-94DB-F8BB043C588C}.Debug|x64.Build.0 = Debug|x64 - {BB833648-BAFF-4BE2-94DB-F8BB043C588C}.Release|Win32.ActiveCfg = Release|Win32 - {BB833648-BAFF-4BE2-94DB-F8BB043C588C}.Release|Win32.Build.0 = Release|Win32 - {BB833648-BAFF-4BE2-94DB-F8BB043C588C}.Release|x64.ActiveCfg = Release|x64 - {BB833648-BAFF-4BE2-94DB-F8BB043C588C}.Release|x64.Build.0 = Release|x64 - {6DA6FD42-641D-4147-92F5-3BC4AAA6589B}.Debug|Win32.ActiveCfg = Debug|Win32 - {6DA6FD42-641D-4147-92F5-3BC4AAA6589B}.Debug|x64.ActiveCfg = Debug|x64 - {6DA6FD42-641D-4147-92F5-3BC4AAA6589B}.Release|Win32.ActiveCfg = Release|Win32 - {6DA6FD42-641D-4147-92F5-3BC4AAA6589B}.Release|x64.ActiveCfg = Release|x64 - {FE3540C5-3303-46E0-A69E-D92F775687F1}.Debug|Win32.ActiveCfg = Debug|Win32 - {FE3540C5-3303-46E0-A69E-D92F775687F1}.Debug|Win32.Build.0 = Debug|Win32 - {FE3540C5-3303-46E0-A69E-D92F775687F1}.Debug|x64.ActiveCfg = Debug|x64 - {FE3540C5-3303-46E0-A69E-D92F775687F1}.Debug|x64.Build.0 = Debug|x64 - {FE3540C5-3303-46E0-A69E-D92F775687F1}.Release|Win32.ActiveCfg = Release|Win32 - {FE3540C5-3303-46E0-A69E-D92F775687F1}.Release|Win32.Build.0 = Release|Win32 - {FE3540C5-3303-46E0-A69E-D92F775687F1}.Release|x64.ActiveCfg = Release|x64 - {FE3540C5-3303-46E0-A69E-D92F775687F1}.Release|x64.Build.0 = Release|x64 - {37C94798-6E33-4B4F-8EE0-C72A7DC91157}.Debug|Win32.ActiveCfg = Debug|Win32 - {37C94798-6E33-4B4F-8EE0-C72A7DC91157}.Debug|Win32.Build.0 = Debug|Win32 - {37C94798-6E33-4B4F-8EE0-C72A7DC91157}.Debug|x64.ActiveCfg = Debug|x64 - {37C94798-6E33-4B4F-8EE0-C72A7DC91157}.Debug|x64.Build.0 = Debug|x64 - {37C94798-6E33-4B4F-8EE0-C72A7DC91157}.Release|Win32.ActiveCfg = Release|Win32 - {37C94798-6E33-4B4F-8EE0-C72A7DC91157}.Release|Win32.Build.0 = Release|Win32 - {37C94798-6E33-4B4F-8EE0-C72A7DC91157}.Release|x64.ActiveCfg = Release|x64 - {37C94798-6E33-4B4F-8EE0-C72A7DC91157}.Release|x64.Build.0 = Release|x64 - {B3F49375-2834-4937-9D8C-4AC2EC911010}.Debug|Win32.ActiveCfg = Debug|Win32 - {B3F49375-2834-4937-9D8C-4AC2EC911010}.Debug|Win32.Build.0 = Debug|Win32 - {B3F49375-2834-4937-9D8C-4AC2EC911010}.Debug|x64.ActiveCfg = Debug|x64 - {B3F49375-2834-4937-9D8C-4AC2EC911010}.Debug|x64.Build.0 = Debug|x64 - {B3F49375-2834-4937-9D8C-4AC2EC911010}.Release|Win32.ActiveCfg = Release|Win32 - {B3F49375-2834-4937-9D8C-4AC2EC911010}.Release|Win32.Build.0 = Release|Win32 - {B3F49375-2834-4937-9D8C-4AC2EC911010}.Release|x64.ActiveCfg = Release|x64 - {B3F49375-2834-4937-9D8C-4AC2EC911010}.Release|x64.Build.0 = Release|x64 - {729344A5-D5E9-434D-8EE8-AF8C6C795D15}.Debug|Win32.ActiveCfg = Debug|Win32 - {729344A5-D5E9-434D-8EE8-AF8C6C795D15}.Debug|x64.ActiveCfg = Debug|x64 - {729344A5-D5E9-434D-8EE8-AF8C6C795D15}.Release|Win32.ActiveCfg = Release|Win32 - {729344A5-D5E9-434D-8EE8-AF8C6C795D15}.Release|x64.ActiveCfg = Release|x64 - {E886B4D5-AB4F-4092-B8F4-3B06E1E462EF}.Debug|Win32.ActiveCfg = Debug|Win32 - {E886B4D5-AB4F-4092-B8F4-3B06E1E462EF}.Debug|x64.ActiveCfg = Debug|x64 - {E886B4D5-AB4F-4092-B8F4-3B06E1E462EF}.Release|Win32.ActiveCfg = Release|Win32 - {E886B4D5-AB4F-4092-B8F4-3B06E1E462EF}.Release|x64.ActiveCfg = Release|x64 - {1A145EE9-BBD8-45E5-98CD-EB4BE99E1DCD}.Debug|Win32.ActiveCfg = Debug|Win32 - {1A145EE9-BBD8-45E5-98CD-EB4BE99E1DCD}.Debug|Win32.Build.0 = Debug|Win32 - {1A145EE9-BBD8-45E5-98CD-EB4BE99E1DCD}.Debug|x64.ActiveCfg = Debug|x64 - {1A145EE9-BBD8-45E5-98CD-EB4BE99E1DCD}.Release|Win32.ActiveCfg = Release|Win32 - {1A145EE9-BBD8-45E5-98CD-EB4BE99E1DCD}.Release|x64.ActiveCfg = Release|x64 - {D021EF2A-460D-4827-A0F7-41FDECF46F1B}.Debug|Win32.ActiveCfg = Debug|Win32 - {D021EF2A-460D-4827-A0F7-41FDECF46F1B}.Debug|Win32.Build.0 = Debug|Win32 - {D021EF2A-460D-4827-A0F7-41FDECF46F1B}.Debug|x64.ActiveCfg = Debug|x64 - {D021EF2A-460D-4827-A0F7-41FDECF46F1B}.Debug|x64.Build.0 = Debug|x64 - {D021EF2A-460D-4827-A0F7-41FDECF46F1B}.Release|Win32.ActiveCfg = Release|Win32 - {D021EF2A-460D-4827-A0F7-41FDECF46F1B}.Release|Win32.Build.0 = Release|Win32 - {D021EF2A-460D-4827-A0F7-41FDECF46F1B}.Release|x64.ActiveCfg = Release|x64 - {D021EF2A-460D-4827-A0F7-41FDECF46F1B}.Release|x64.Build.0 = Release|x64 - {2B1BAF36-0241-43E7-B865-A8338AD48E2E}.Debug|Win32.ActiveCfg = Debug|Win32 - {2B1BAF36-0241-43E7-B865-A8338AD48E2E}.Debug|Win32.Build.0 = Debug|Win32 - {2B1BAF36-0241-43E7-B865-A8338AD48E2E}.Debug|x64.ActiveCfg = Debug|x64 - {2B1BAF36-0241-43E7-B865-A8338AD48E2E}.Debug|x64.Build.0 = Debug|x64 - {2B1BAF36-0241-43E7-B865-A8338AD48E2E}.Release|Win32.ActiveCfg = Release|Win32 - {2B1BAF36-0241-43E7-B865-A8338AD48E2E}.Release|Win32.Build.0 = Release|Win32 - {2B1BAF36-0241-43E7-B865-A8338AD48E2E}.Release|x64.ActiveCfg = Release|x64 - {2B1BAF36-0241-43E7-B865-A8338AD48E2E}.Release|x64.Build.0 = Release|x64 - {0DA69C18-4FA1-4E8C-89CE-12498637C5BE}.Debug|Win32.ActiveCfg = Debug|Win32 - {0DA69C18-4FA1-4E8C-89CE-12498637C5BE}.Debug|Win32.Build.0 = Debug|Win32 - {0DA69C18-4FA1-4E8C-89CE-12498637C5BE}.Debug|x64.ActiveCfg = Debug|x64 - {0DA69C18-4FA1-4E8C-89CE-12498637C5BE}.Debug|x64.Build.0 = Debug|x64 - {0DA69C18-4FA1-4E8C-89CE-12498637C5BE}.Release|Win32.ActiveCfg = Release|Win32 - {0DA69C18-4FA1-4E8C-89CE-12498637C5BE}.Release|Win32.Build.0 = Release|Win32 - {0DA69C18-4FA1-4E8C-89CE-12498637C5BE}.Release|x64.ActiveCfg = Release|x64 - {0DA69C18-4FA1-4E8C-89CE-12498637C5BE}.Release|x64.Build.0 = Release|x64 - {B2AF4EA6-0CD7-4529-9EB5-5AF43DB90395}.Debug|Win32.ActiveCfg = Debug|Win32 - {B2AF4EA6-0CD7-4529-9EB5-5AF43DB90395}.Debug|x64.ActiveCfg = Debug|x64 - {B2AF4EA6-0CD7-4529-9EB5-5AF43DB90395}.Release|Win32.ActiveCfg = Release|Win32 - {B2AF4EA6-0CD7-4529-9EB5-5AF43DB90395}.Release|x64.ActiveCfg = Release|x64 - {08C3EA27-A51D-47F8-B47D-B189C649CF30}.Debug|Win32.ActiveCfg = Debug|Win32 - {08C3EA27-A51D-47F8-B47D-B189C649CF30}.Debug|x64.ActiveCfg = Debug|x64 - {08C3EA27-A51D-47F8-B47D-B189C649CF30}.Release|Win32.ActiveCfg = Release|Win32 - {08C3EA27-A51D-47F8-B47D-B189C649CF30}.Release|x64.ActiveCfg = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/libs/freetdm/freetdm.pc.in b/libs/freetdm/freetdm.pc.in deleted file mode 100644 index 0b563f9840..0000000000 --- a/libs/freetdm/freetdm.pc.in +++ /dev/null @@ -1,18 +0,0 @@ -# -# FreeTDM pkg-config file -# -prefix=@prefix@ -exec_prefix=${prefix} -libdir=${exec_prefix}/lib -includedir=${prefix}/include -modulesdir=@modinstdir@ - -Name: FreeTDM -Description: -Version: @PACKAGE_VERSION@ -URL: http://www.openzap.org/ -Requires: -Conflicts: -Libs: -L${libdir} -lfreetdm -Libs.private: -lm -Cflags: -I${includedir} diff --git a/libs/freetdm/mkrelease.sh b/libs/freetdm/mkrelease.sh deleted file mode 100755 index b079158541..0000000000 --- a/libs/freetdm/mkrelease.sh +++ /dev/null @@ -1,144 +0,0 @@ -#!/bin/bash -INSTALLPREFIX="/usr/local/freetdm" -VERSION="" -NODOCS="NO" - -for i in $* -do - case $i in - --version=*) - VERSION=`echo $i | sed 's/[-a-zA-Z0-9]*=//'` - ;; - --prefix=*) - INSTALLPREFIX=`echo $i | sed 's/[-a-zA-Z0-9]*=//'` - ;; - --nodocs) - NODOCS="YES" - ;; - *) - # unknown option - echo "Unknown option $i" - exit - ;; - esac -done - -if [ "x$VERSION" = "x" ] -then - echo "Provide a version number with --version=" - exit 1 -fi - -arch=$(uname -m) - -# defs -LIBSNG_ISDN_URL=ftp://ftp.sangoma.com/linux/libsng_isdn -LIBSNG_ISDN_NAME=libsng_isdn-7-current -LIBSNG_SS7_URL=ftp://ftp.sangoma.com/linux/libsng_ss7 -LIBSNG_SS7_NAME=libsng_ss7-3-current -LIBSNG_ISDN_DIR="$LIBSNG_ISDN_NAME.$arch" -LIBSNG_SS7_DIR="$LIBSNG_SS7_NAME.$arch" - -# download and decompress a tarball -# $1 = prefix_url, such as ftp://ftp.sangoma.com/foo/bar -# $2 = package name, such as libsng_isdn-7.0.0.x86_64 -function download() { - wget $1/$2.tgz - if [ $? = 0 ] - then - tardir=$(tar -tf $2.tgz | head -n1 | sed 's,\/,,g') - tar -xvzf $2.tgz || echo "FAILED to decompress $2.tgz" - if [ "$tardir" != "$2" ] - then - mv $tardir $2 || echo "FAILED to move $tardir to $2" - fi - echo "SUCCESSFULLY downloaded $2" - else - echo "FAILED to download $1/$2.tgz" - fi -} - -# download and build libsng-ss7 -fullname="$LIBSNG_ISDN_NAME.$arch" -if [ -d $fullname ] -then - echo "skipping isdn download since $fullname directory already exists ... remove if you want this step to be performed" -else - download $LIBSNG_ISDN_URL $fullname -fi - -cd $LIBSNG_ISDN_DIR -make DESTDIR=$INSTALLPREFIX install || echo "Failed to build libsng-isdn" -cd .. - -# download and build libsng-ss7 -fullname="$LIBSNG_SS7_NAME.$arch" -if [ -d $fullname ] -then - echo "skipping ss7 download since $fullname directory already exists ... remove if you want this step to be performed" -else - download $LIBSNG_SS7_URL $fullname -fi - -cd $LIBSNG_SS7_DIR -make DESTDIR=$INSTALLPREFIX install || echo "Failed to build libsng-ss7" -cd .. - -if [ ! -d $INSTALLPREFIX ] -then - mkdir -p $INSTALLPREFIX || exit 1 -fi - -if [ ! -d $INSTALLPREFIX/bin-releases ] -then - mkdir -p $INSTALLPREFIX/bin-releases || exit 1 -fi - -# attempt to compile freetdm -echo "Build freetdm and mod_freetdm now..." -make all mod_freetdm || exit 1 -echo "freetdm built OK" - -major=$(echo "$VERSION" | cut -d. -f1) -minor=$(echo "$VERSION" | cut -d. -f2) -micro=$(echo "$VERSION" | cut -d. -f3) -release="freetdm-$VERSION" - -# ABI compatibility check -if [ -x /usr/local/bin/ftdm_abi_check.py ]; then - /usr/local/bin/ftdm_abi_check.py --release_path=$(pwd) --archive_path=$INSTALLPREFIX/bin-releases --version=$VERSION - - if [ $? -ne 0 ]; then - echo "ABI compabitility test failed, not creating release. Either increment the major version number or fix the interface." - exit 1 - fi -else - echo -ne "\n\nWARNING: /usr/local/bin/ftdm_abi_check.py not found, skipping ABI compatibility test\n\n" -fi - -if [ $NODOCS = "NO" ] -then - make dox || exit 1 -fi - -echo "Creating $release ($major.$minor.$micro) at $INSTALLPREFIX/$release (directory will be removed if exists already) ... " - -mkdir -p $INSTALLPREFIX/$release $INSTALLPREFIX/bin-releases/$major/$release - -cp -r ./* $INSTALLPREFIX/bin-releases/$major/$release -cp -r ./.libs $INSTALLPREFIX/bin-releases/$major/$release - -make clean -make mod_freetdm-clean - -cp -r ./* $INSTALLPREFIX/$release - -# copy ABI compatibility reports to release -if [ -d compat_reports ]; then - mv ./compat_reports $INSTALLPREFIX/$release -fi - -rm -rf $INSTALLPREFIX/$release/{$LIBSNG_ISDN_DIR,$LIBSNG_SS7_DIR,*.tgz} -rm -rf $INSTALLPREFIX/bin-releases/$major/$release/{$LIBSNG_ISDN_DIR,$LIBSNG_SS7_DIR,*.tgz} - -tar -C $INSTALLPREFIX -czf $INSTALLPREFIX/$release.tar.gz $release/ diff --git a/libs/freetdm/mod_freetdm/CMakeLists.txt b/libs/freetdm/mod_freetdm/CMakeLists.txt deleted file mode 100644 index 25847e713f..0000000000 --- a/libs/freetdm/mod_freetdm/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -# -# Arnaldo M Pereira -# -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(mod_freetdm) - -IF(NOT DEFINED WIN32) - ADD_DEFINITIONS(-g -O2 -ffast-math -Wall -Werror -Wunused-variable -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -O0 -g -ggdb -DPACKAGE_NAME=\"freetdm\" -DPACKAGE_TARNAME=\"freetdm\" -DPACKAGE_VERSION=\"pre-alpha\" -DPACKAGE_STRING=\"freetdm\ pre-alpha\" -DPACKAGE_BUGREPORT=\"bugs@freeswitch.org\" -DPACKAGE_URL=\"\" -DPACKAGE=\"libfreetdm\" -DVERSION=\"0.1\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DHAVE_LIBDL=1 -DHAVE_LIBPTHREAD=1 -DHAVE_LIBM=1 -DSIZEOF_LONG=8 -DHAVE_NETINET_SCTP_H=1 -DHAVE_NETDB_H=1 -DHAVE_SYS_SELECT_H=1 -DHAVE_GETHOSTBYNAME_R=1) # -DDEBUG=/\*\*/) -ENDIF(NOT DEFINED WIN32) - -# includes -SET(mod_freetdm_INCLUDES - ${PROJECT_SOURCE_DIR}/../src/include - ${PROJECT_SOURCE_DIR}/../src/isdn/include - ${PROJECT_SOURCE_DIR}/../../libteletone/src - ${PROJECT_SOURCE_DIR}/../../../src/include -) -INCLUDE_DIRECTORIES(${mod_freetdm_INCLUDES}) - -LINK_DIRECTORIES(${PROJECT_SOURCE_DIR}/..) -ADD_LIBRARY(${PROJECT_NAME} SHARED mod_freetdm.c) -TARGET_LINK_LIBRARIES(${PROJECT_NAME} freetdm -fPIC -Werror -fvisibility=hidden) - -IF(DEFINED WIN32) - SET(EXT lib) -ELSE(DEFINED WIN32) - SET(EXT so) -ENDIF(DEFINED WIN32) - -ADD_CUSTOM_COMMAND(TARGET ${PROJECT_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E rename lib${PROJECT_NAME}.${EXT} ${PROJECT_NAME}.${EXT} -) diff --git a/libs/freetdm/mod_freetdm/Makefile.in b/libs/freetdm/mod_freetdm/Makefile.in deleted file mode 100644 index 33ca03b440..0000000000 --- a/libs/freetdm/mod_freetdm/Makefile.in +++ /dev/null @@ -1,24 +0,0 @@ -FT_CFLAGS=@CFLAGS@ @COMP_VENDOR_CFLAGS@ @DEFS@ - -BASE=../../.. -FT_DIR=.. -VERBOSE=1 -FTLA=$(FT_DIR)/libfreetdm.la -LOCAL_OBJS=tdm.o -LOCAL_CFLAGS=-I$(FT_DIR)/src/include -I$(FT_DIR)/src/isdn/include $(FT_CFLAGS) -LOCAL_LDFLAGS=-L$(FT_DIR) -lfreetdm -include $(BASE)/build/modmake.rules - -local_depend: $(FTLA) - -$(FTLA): $(FT_DIR)/.update - cd $(FT_DIR) && $(MAKE) - -local_install: - cd $(FT_DIR) && $(MAKE) install - [ -f $(DESTDIR)@confdir@/autoload_configs/freetdm.conf.xml ] || cp -f $(FT_DIR)/conf/freetdm.conf.xml $(DESTDIR)@confdir@/autoload_configs - -local_clean: - cd $(FT_DIR) && $(MAKE) clean - - diff --git a/libs/freetdm/mod_freetdm/clean.sh b/libs/freetdm/mod_freetdm/clean.sh deleted file mode 100755 index 7e531ac7ff..0000000000 --- a/libs/freetdm/mod_freetdm/clean.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -rm -rf mod_freetdm.so -rm -rf .libs/mod_freetdm.so -rm -rf mod_freetdm.o -rm -rf .libs/mod_freetdm.o -rm -rf mod_freetdm.lo diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.2008.vcproj b/libs/freetdm/mod_freetdm/mod_freetdm.2008.vcproj deleted file mode 100644 index 3fdd92af05..0000000000 --- a/libs/freetdm/mod_freetdm/mod_freetdm.2008.vcproj +++ /dev/null @@ -1,369 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.2010.vcxproj.filters b/libs/freetdm/mod_freetdm/mod_freetdm.2010.vcxproj.filters deleted file mode 100644 index 92ac5ead47..0000000000 --- a/libs/freetdm/mod_freetdm/mod_freetdm.2010.vcxproj.filters +++ /dev/null @@ -1,14 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - Source Files - - - \ No newline at end of file diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c deleted file mode 100644 index 5126a3690a..0000000000 --- a/libs/freetdm/mod_freetdm/mod_freetdm.c +++ /dev/null @@ -1,5715 +0,0 @@ -/* - * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2014, Anthony Minessale II - * - * Version: MPL 1.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * - * The Initial Developer of the Original Code is - * Anthony Minessale II - * Portions created by the Initial Developer are Copyright (C) - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Anthony Minessale II - * Moises Silva - * David Yat Sin - * James Zhang - * Gideon Sadan - * - * mod_freetdm.c -- FreeTDM Endpoint Module - * - */ -#include -#include "freetdm.h" - -//#define BACKTRACE_DEBUG - -#define FREETDM_LIMIT_REALM "__freetdm" -#define FREETDM_VAR_PREFIX "freetdm_" -#define FREETDM_VAR_PREFIX_LEN (sizeof(FREETDM_VAR_PREFIX)-1) - -/* How many consecutive IO errors before giving up */ -#define FTDM_MAX_READ_WRITE_ERRORS 10 - -#define get_ss7_config_node(_cfg, _confname) _get_ss7_config_node(cfg, confname, "ISUP") - -SWITCH_MODULE_LOAD_FUNCTION(mod_freetdm_load); -SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_freetdm_shutdown); -SWITCH_MODULE_DEFINITION(mod_freetdm, mod_freetdm_load, mod_freetdm_shutdown, NULL); - -switch_endpoint_interface_t *freetdm_endpoint_interface; - -static switch_memory_pool_t *module_pool = NULL; - -typedef enum { - ANALOG_OPTION_NONE = 0, - ANALOG_OPTION_3WAY = (1 << 0), - ANALOG_OPTION_CALL_SWAP = (1 << 1) -} analog_option_t; - -typedef enum { - FTDM_LIMIT_RESET_ON_TIMEOUT = 0, - FTDM_LIMIT_RESET_ON_ANSWER = 1 -} limit_reset_event_t; - -typedef enum { - TFLAG_IO = (1 << 0), - TFLAG_DTMF = (1 << 1), - TFLAG_CODEC = (1 << 2), - TFLAG_BREAK = (1 << 3), - TFLAG_HOLD = (1 << 4), - TFLAG_DEAD = (1 << 5), - TFLAG_TRANSFER = (1 << 6), -} TFLAGS; - -static struct { - int debug; - char *dialplan; - char *codec_string; - char *codec_order[SWITCH_MAX_CODECS]; - int codec_order_last; - char *codec_rates_string; - char *codec_rates[SWITCH_MAX_CODECS]; - int codec_rates_last; - unsigned int flags; - int fd; - int calls; - char hold_music[256]; - switch_mutex_t *mutex; - analog_option_t analog_options; - switch_hash_t *ss7_configs; - int sip_headers; - uint8_t crash_on_assert; - uint8_t fail_on_error; - uint8_t config_error; -} globals; - -/* private data attached to each fs session */ -struct private_object { - unsigned int flags; - switch_codec_t read_codec; - switch_codec_t write_codec; - switch_frame_t read_frame; - unsigned char databuf[SWITCH_RECOMMENDED_BUFFER_SIZE]; - switch_frame_t cng_frame; - unsigned char cng_databuf[SWITCH_RECOMMENDED_BUFFER_SIZE]; - switch_core_session_t *session; - switch_caller_profile_t *caller_profile; - unsigned int codec; - unsigned int codecs; - unsigned short samprate; - switch_mutex_t *mutex; - switch_mutex_t *flag_mutex; - ftdm_channel_t *ftdmchan; - uint32_t write_error; - uint32_t read_error; - char network_peer_uuid[SWITCH_UUID_FORMATTED_LENGTH + 1]; -}; - -/* private data attached to FTDM channels (only FXS for now) */ -typedef struct chan_pvt { - unsigned int flags; -} chan_pvt_t; - -typedef struct private_object private_t; - -struct span_config { - ftdm_span_t *span; - char dialplan[80]; - char context[80]; - char dial_regex[256]; - char fail_dial_regex[256]; - char hold_music[256]; - char type[256]; - analog_option_t analog_options; - const char *limit_backend; - int limit_calls; - int limit_seconds; - limit_reset_event_t limit_reset_event; - /* digital codec and digital sampling rate are used to configure the codec - * when bearer capability is set to unrestricted digital */ - const char *digital_codec; - int digital_sampling_rate; - chan_pvt_t pvts[FTDM_MAX_CHANNELS_SPAN]; -}; - -static struct span_config SPAN_CONFIG[FTDM_MAX_SPANS_INTERFACE] = {{0}}; - -static switch_status_t channel_on_init(switch_core_session_t *session); -static switch_status_t channel_on_hangup(switch_core_session_t *session); -static switch_status_t channel_on_destroy(switch_core_session_t *session); -static switch_status_t channel_on_routing(switch_core_session_t *session); -static switch_status_t channel_on_exchange_media(switch_core_session_t *session); -static switch_status_t channel_on_soft_execute(switch_core_session_t *session); -static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event, - switch_caller_profile_t *outbound_profile, - switch_core_session_t **new_session, - switch_memory_pool_t **pool, - switch_originate_flag_t flags, switch_call_cause_t *cancel_cause); -static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id); -static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id); -static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig); -static const char* channel_get_variable(switch_core_session_t *session, switch_event_t *var_event, const char *variable_name); -ftdm_status_t ftdm_channel_from_event(ftdm_sigmsg_t *sigmsg, switch_core_session_t **sp); -void dump_chan(ftdm_span_t *span, uint32_t chan_id, switch_stream_handle_t *stream); -void dump_chan_xml(ftdm_span_t *span, uint32_t chan_id, switch_stream_handle_t *stream); -#if 0 -void ctdm_init(switch_loadable_module_interface_t *module_interface); -#endif - -static switch_core_session_t *ftdm_channel_get_session(ftdm_channel_t *channel, int32_t id) -{ - switch_core_session_t *session = NULL; - const char *token = ftdm_channel_get_token(channel, id); - - if (!zstr(token)) { - if (!(session = switch_core_session_locate(token))) { - ftdm_channel_clear_token(channel, token); - } - } - - return session; -} - -static const char *ftdm_channel_get_uuid(ftdm_channel_t *channel, int32_t id) -{ - return ftdm_channel_get_token(channel, id); -} - -static void stop_hold(switch_core_session_t *session_a, const char *uuid) -{ - switch_core_session_t *session; - switch_channel_t *channel, *channel_a; - - if (!uuid) { - return; - } - - if ((session = switch_core_session_locate(uuid))) { - channel = switch_core_session_get_channel(session); - - if (switch_channel_test_flag(channel, CF_HOLD)) { - channel_a = switch_core_session_get_channel(session_a); - switch_ivr_unhold(session); - switch_channel_clear_flag(channel_a, CF_SUSPEND); - switch_channel_clear_flag(channel_a, CF_HOLD); - } else { - switch_channel_stop_broadcast(channel); - switch_channel_wait_for_flag(channel, CF_BROADCAST, SWITCH_FALSE, 2000, NULL); - } - - switch_core_session_rwunlock(session); - } -} - -static void start_hold(ftdm_channel_t *ftdmchan, switch_core_session_t *session_a, const char *uuid, const char *stream) -{ - switch_core_session_t *session; - switch_channel_t *channel, *channel_a; - int32_t spanid = 0; - - if (!uuid) { - return; - } - - spanid = ftdm_channel_get_span_id(ftdmchan); - if ((session = switch_core_session_locate(uuid))) { - channel = switch_core_session_get_channel(session); - if (zstr(stream)) { - if (!strcasecmp(globals.hold_music, "indicate_hold")) { - stream = "indicate_hold"; - } - if (!strcasecmp(SPAN_CONFIG[spanid].hold_music, "indicate_hold")) { - stream = "indicate_hold"; - } - } - - if (zstr(stream)) { - stream = switch_channel_get_variable(channel, SWITCH_HOLD_MUSIC_VARIABLE); - } - - if (zstr(stream)) { - stream = SPAN_CONFIG[spanid].hold_music; - } - - if (zstr(stream)) { - stream = globals.hold_music; - } - - if (zstr(stream) && !(stream = switch_channel_get_variable(channel, SWITCH_HOLD_MUSIC_VARIABLE))) { - stream = globals.hold_music; - } - - if (!zstr(stream)) { - if (!strcasecmp(stream, "indicate_hold")) { - channel_a = switch_core_session_get_channel(session_a); - switch_ivr_hold_uuid(uuid, NULL, 0); - switch_channel_set_flag(channel_a, CF_SUSPEND); - switch_channel_set_flag(channel_a, CF_HOLD); - } else { - switch_ivr_broadcast(switch_core_session_get_uuid(session), stream, SMF_ECHO_ALEG | SMF_LOOP); - } - } - - switch_core_session_rwunlock(session); - } -} - - -static void cycle_foreground(ftdm_channel_t *ftdmchan, int flash, const char *bcast) { - uint32_t i = 0; - switch_core_session_t *session; - switch_channel_t *channel; - private_t *tech_pvt; - uint32_t tokencnt = ftdm_channel_get_token_count(ftdmchan); - - for (i = 0; i < tokencnt; i++) { - if ((session = ftdm_channel_get_session(ftdmchan, i))) { - const char *buuid; - tech_pvt = switch_core_session_get_private(session); - channel = switch_core_session_get_channel(session); - buuid = switch_channel_get_partner_uuid(channel); - - if (tokencnt == 1 && flash) { - if (switch_test_flag(tech_pvt, TFLAG_HOLD)) { - stop_hold(session, buuid); - switch_clear_flag_locked(tech_pvt, TFLAG_HOLD); - } else { - start_hold(ftdmchan, session, buuid, bcast); - switch_set_flag_locked(tech_pvt, TFLAG_HOLD); - } - } else if (i) { - start_hold(ftdmchan, session, buuid, bcast); - switch_set_flag_locked(tech_pvt, TFLAG_HOLD); - } else { - stop_hold(session, buuid); - switch_clear_flag_locked(tech_pvt, TFLAG_HOLD); - if (!switch_channel_test_flag(channel, CF_ANSWERED)) { - switch_channel_mark_answered(channel); - } - } - switch_core_session_rwunlock(session); - } - } -} - -static switch_status_t tech_init(private_t *tech_pvt, switch_core_session_t *session, ftdm_channel_t *ftdmchan, ftdm_caller_data_t *caller_data) -{ - const char *dname = NULL; - uint32_t interval = 0, srate = 8000; - uint32_t span_id; - ftdm_codec_t codec; - - tech_pvt->ftdmchan = ftdmchan; - tech_pvt->read_frame.data = tech_pvt->databuf; - tech_pvt->read_frame.buflen = sizeof(tech_pvt->databuf); - tech_pvt->cng_frame.data = tech_pvt->cng_databuf; - tech_pvt->cng_frame.buflen = sizeof(tech_pvt->cng_databuf); - tech_pvt->cng_frame.flags = SFF_CNG; - tech_pvt->cng_frame.codec = &tech_pvt->read_codec; - memset(tech_pvt->cng_frame.data, 255, tech_pvt->cng_frame.buflen); - switch_mutex_init(&tech_pvt->mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session)); - switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session)); - switch_core_session_set_private(session, tech_pvt); - tech_pvt->session = session; - - if (FTDM_SUCCESS != ftdm_channel_command(ftdmchan, FTDM_COMMAND_GET_INTERVAL, &interval)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to retrieve channel interval.\n"); - return SWITCH_STATUS_GENERR; - } - - span_id = ftdm_channel_get_span_id(ftdmchan); - if (caller_data->bearer_capability == FTDM_BEARER_CAP_UNRESTRICTED - && SPAN_CONFIG[span_id].digital_codec) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Initializing digital call with codec %s at %dhz.\n", - SPAN_CONFIG[span_id].digital_codec, SPAN_CONFIG[span_id].digital_sampling_rate); - dname = SPAN_CONFIG[span_id].digital_codec; - srate = SPAN_CONFIG[span_id].digital_sampling_rate; - goto init_codecs; - } - - if (FTDM_SUCCESS != ftdm_channel_command(ftdmchan, FTDM_COMMAND_GET_CODEC, &codec)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to retrieve channel codec.\n"); - return SWITCH_STATUS_GENERR; - } - - switch (codec) { - case FTDM_CODEC_ULAW: - { - dname = "PCMU"; - } - break; - case FTDM_CODEC_ALAW: - { - dname = "PCMA"; - } - break; - case FTDM_CODEC_SLIN: - { - dname = "L16"; - } - break; - default: - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid codec value retrieved from channel, codec value: %d\n", codec); - return SWITCH_STATUS_GENERR; - } - } - -init_codecs: - - if (switch_core_codec_init(&tech_pvt->read_codec, - dname, - NULL, - NULL, - srate, - interval, - 1, - SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, - NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n"); - return SWITCH_STATUS_GENERR; - } else { - if (switch_core_codec_init(&tech_pvt->write_codec, - dname, - NULL, - NULL, - srate, - interval, - 1, - SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, - NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n"); - switch_core_codec_destroy(&tech_pvt->read_codec); - return SWITCH_STATUS_GENERR; - } - } - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set codec %s %dms\n", dname, interval); - switch_core_session_set_read_codec(tech_pvt->session, &tech_pvt->read_codec); - switch_core_session_set_write_codec(tech_pvt->session, &tech_pvt->write_codec); - switch_set_flag_locked(tech_pvt, TFLAG_CODEC); - tech_pvt->read_frame.codec = &tech_pvt->read_codec; - switch_set_flag_locked(tech_pvt, TFLAG_IO); - - return SWITCH_STATUS_SUCCESS; -} - -static switch_status_t channel_on_init(switch_core_session_t *session) -{ - switch_channel_t *channel; - private_t *tech_pvt = NULL; - - tech_pvt = switch_core_session_get_private(session); - assert(tech_pvt != NULL); - - channel = switch_core_session_get_channel(session); - assert(channel != NULL); - - if (switch_test_flag(tech_pvt, TFLAG_DEAD)) { - switch_channel_hangup(channel, SWITCH_CAUSE_LOSE_RACE); - return SWITCH_STATUS_SUCCESS; - } - - /* Move channel's state machine to ROUTING */ - switch_channel_set_state(channel, CS_ROUTING); - switch_mutex_lock(globals.mutex); - globals.calls++; - switch_mutex_unlock(globals.mutex); - - //switch_channel_set_flag(channel, CF_ACCEPT_CNG); - - return SWITCH_STATUS_SUCCESS; -} - -static switch_status_t channel_on_routing(switch_core_session_t *session) -{ - switch_channel_t *channel = NULL; - private_t *tech_pvt = NULL; - - channel = switch_core_session_get_channel(session); - switch_assert(channel != NULL); - - tech_pvt = switch_core_session_get_private(session); - switch_assert(tech_pvt != NULL); - - switch_assert(tech_pvt->ftdmchan != NULL); - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL ROUTING\n", switch_channel_get_name(channel)); - - if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_INBOUND) { - ftdm_channel_call_indicate(tech_pvt->ftdmchan, FTDM_CHANNEL_INDICATE_PROCEED); - } - return SWITCH_STATUS_SUCCESS; -} - -static switch_status_t channel_on_execute(switch_core_session_t *session) -{ - - switch_channel_t *channel = NULL; - private_t *tech_pvt = NULL; - - channel = switch_core_session_get_channel(session); - switch_assert(channel != NULL); - - tech_pvt = switch_core_session_get_private(session); - switch_assert(tech_pvt != NULL); - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL EXECUTE\n", switch_channel_get_name(channel)); - - - return SWITCH_STATUS_SUCCESS; -} - -static switch_status_t channel_on_destroy(switch_core_session_t *session) -{ - private_t *tech_pvt = NULL; - - if ((tech_pvt = switch_core_session_get_private(session))) { - - if (tech_pvt->read_codec.implementation) { - switch_core_codec_destroy(&tech_pvt->read_codec); - } - - if (tech_pvt->write_codec.implementation) { - switch_core_codec_destroy(&tech_pvt->write_codec); - } - - switch_core_session_unset_read_codec(session); - switch_core_session_unset_write_codec(session); - - } - - return SWITCH_STATUS_SUCCESS; -} - -#ifdef BACKTRACE_DEBUG -struct debug_trace_priv { - const char *name; - int span_id; - int chan_id; -}; - -static void debug_trace(const int tid, const void *addr, const char *symbol, void *priv) -{ - struct debug_trace_priv *data = priv; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "[%d:%d][tid:%d] %s -> %s\n", - data->span_id, data->chan_id, tid, data->name, symbol); -} -#endif - -static switch_status_t channel_on_hangup(switch_core_session_t *session) -{ - switch_channel_t *channel = NULL; - private_t *tech_pvt = NULL; - ftdm_chan_type_t chantype; - const char *name = NULL; - int span_id = 0; - int chan_id = 0; - uint32_t t = 0; - uint32_t tokencnt; - char *uuid = NULL; - const char *token = NULL; - uint8_t uuid_found = 0; - - channel = switch_core_session_get_channel(session); - assert(channel != NULL); - - tech_pvt = switch_core_session_get_private(session); - assert(tech_pvt != NULL); - - /* ignore any further I/O requests, we're hanging up already! */ - switch_clear_flag_locked(tech_pvt, TFLAG_IO); - - name = switch_channel_get_name(channel); - - span_id = tech_pvt->ftdmchan ? ftdm_channel_get_span_id(tech_pvt->ftdmchan) : 0; - chan_id = tech_pvt->ftdmchan ? ftdm_channel_get_id(tech_pvt->ftdmchan) : 0; - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "[%d:%d] %s CHANNEL HANGUP ENTER\n", span_id, chan_id, name); - - /* First verify this call has a device attached */ - if (!tech_pvt->ftdmchan) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s does not have any ftdmchan attached\n", name); - goto end; - } - - /* Now verify the device is still attached to this call :-) - * Sometimes the FS core takes too long (more than 3 seconds) in calling - * channel_on_hangup() and the FreeTDM core decides to take the brute - * force approach and hangup and detach themselves from the call. Later - * when FS finally comes around, we might end up hanging up the device - * attached to another call, this verification avoids that. */ - uuid = switch_core_session_get_uuid(session); - tokencnt = ftdm_channel_get_token_count(tech_pvt->ftdmchan); - for (t = 0; t < tokencnt; t++) { - token = ftdm_channel_get_token(tech_pvt->ftdmchan, t); - if (!zstr(token) && !strcasecmp(uuid, token)) { - uuid_found = 1; - break; - } - } - - if (!uuid_found) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Device [%d:%d] is no longer attached to %s\n", span_id, chan_id, name); - goto end; - } - -#ifdef BACKTRACE_DEBUG - { - struct debug_trace_priv trace_data; - trace_data.name = name; - trace_data.span_id = span_id; - trace_data.chan_id = chan_id; - ftdm_backtrace_walk(&debug_trace, &trace_data); - } -#endif - - ftdm_channel_clear_token(tech_pvt->ftdmchan, switch_core_session_get_uuid(session)); - - chantype = ftdm_channel_get_type(tech_pvt->ftdmchan); - switch (chantype) { - case FTDM_CHAN_TYPE_FXO: - case FTDM_CHAN_TYPE_EM: - { - ftdm_channel_call_hangup(tech_pvt->ftdmchan); - } - break; - case FTDM_CHAN_TYPE_FXS: - { - tokencnt = ftdm_channel_get_token_count(tech_pvt->ftdmchan); - if (!ftdm_channel_call_check_busy(tech_pvt->ftdmchan) && !ftdm_channel_call_check_done(tech_pvt->ftdmchan)) { - if (tokencnt) { - cycle_foreground(tech_pvt->ftdmchan, 0, NULL); - } else { - ftdm_channel_call_hangup(tech_pvt->ftdmchan); - } - } - } - break; - case FTDM_CHAN_TYPE_CAS: - case FTDM_CHAN_TYPE_B: - { - const char *var = NULL; - switch_call_cause_t ccause = switch_channel_get_cause_q850(channel); - ftdm_call_cause_t hcause; - if (ccause < 1 || ccause > 127) { - hcause = FTDM_CAUSE_DESTINATION_OUT_OF_ORDER; - } else { - hcause = (ftdm_call_cause_t)ccause; - } - var = switch_channel_get_variable(channel, "ss7_rel_loc"); - if (var) { - ftdm_usrmsg_t usrmsg; - memset(&usrmsg, 0, sizeof(ftdm_usrmsg_t)); - ftdm_usrmsg_add_var(&usrmsg, "ss7_rel_loc", var); - ftdm_channel_call_hangup_with_cause_ex(tech_pvt->ftdmchan, hcause, &usrmsg); - } else { - ftdm_channel_call_hangup_with_cause(tech_pvt->ftdmchan, hcause); - } - } - break; - default: - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Unhandled channel type %d for channel %s\n", chantype, switch_channel_get_name(channel)); - } - break; - } - - end: - - switch_mutex_lock(globals.mutex); - globals.calls--; - if (globals.calls < 0) { - globals.calls = 0; - } - switch_mutex_unlock(globals.mutex); - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "[%d:%d] %s CHANNEL HANGUP EXIT\n", span_id, chan_id, name); - return SWITCH_STATUS_SUCCESS; -} - -static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig) -{ - switch_channel_t *channel = NULL; - private_t *tech_pvt = NULL; - - channel = switch_core_session_get_channel(session); - assert(channel != NULL); - - tech_pvt = switch_core_session_get_private(session); - assert(tech_pvt != NULL); - - switch (sig) { - case SWITCH_SIG_KILL: - switch_clear_flag_locked(tech_pvt, TFLAG_IO); - switch_set_flag_locked(tech_pvt, TFLAG_DEAD); - break; - case SWITCH_SIG_BREAK: - switch_set_flag_locked(tech_pvt, TFLAG_BREAK); - break; - default: - break; - } - - return SWITCH_STATUS_SUCCESS; -} - -static switch_status_t channel_on_exchange_media(switch_core_session_t *session) -{ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL EXCHANGE_MEDIA\n"); - return SWITCH_STATUS_SUCCESS; -} - -static switch_status_t channel_on_soft_execute(switch_core_session_t *session) -{ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL SOFT_EXECUTE\n"); - return SWITCH_STATUS_SUCCESS; -} - -static switch_status_t channel_send_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf) -{ - private_t *tech_pvt = NULL; - char tmp[2] = ""; - - tech_pvt = switch_core_session_get_private(session); - assert(tech_pvt != NULL); - - if (switch_test_flag(tech_pvt, TFLAG_DEAD)) { - switch_channel_hangup(switch_core_session_get_channel(session), SWITCH_CAUSE_LOSE_RACE); - return SWITCH_STATUS_FALSE; - } - - tmp[0] = dtmf->digit; - ftdm_channel_command(tech_pvt->ftdmchan, FTDM_COMMAND_SEND_DTMF, tmp); - - return SWITCH_STATUS_SUCCESS; -} - -static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id) -{ - switch_channel_t *channel = NULL; - private_t *tech_pvt = NULL; - ftdm_size_t len; - ftdm_wait_flag_t wflags = FTDM_READ; - char dtmf[128] = ""; - ftdm_status_t status; - int total_to; - int chunk, do_break = 0; - uint32_t span_id, chan_id; - const char *name = NULL; - - channel = switch_core_session_get_channel(session); - assert(channel != NULL); - - tech_pvt = switch_core_session_get_private(session); - assert(tech_pvt != NULL); - - name = switch_channel_get_name(channel); - if (!tech_pvt->ftdmchan) { - switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "no ftdmchan set in channel %s!\n", name); - return SWITCH_STATUS_FALSE; - } - - span_id = ftdm_channel_get_span_id(tech_pvt->ftdmchan); - chan_id = ftdm_channel_get_id(tech_pvt->ftdmchan); - if (switch_test_flag(tech_pvt, TFLAG_DEAD)) { - switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "TFLAG_DEAD is set in channel %s device %d:%d!\n", name, span_id, chan_id); - return SWITCH_STATUS_FALSE; - } - - /* Digium Cards sometimes timeout several times in a row here. - Yes, we support digium cards, ain't we nice....... - 6 double length intervals should compensate */ - chunk = ftdm_channel_get_io_interval(tech_pvt->ftdmchan) * 2; - total_to = chunk * 6; - - top: - - if (switch_channel_test_flag(channel, CF_SUSPEND)) { - do_break = 1; - } - - if (switch_test_flag(tech_pvt, TFLAG_BREAK)) { - switch_clear_flag_locked(tech_pvt, TFLAG_BREAK); - do_break = 1; - } - - if (switch_test_flag(tech_pvt, TFLAG_HOLD) || do_break) { - switch_yield(ftdm_channel_get_io_interval(tech_pvt->ftdmchan) * 1000); - tech_pvt->cng_frame.datalen = ftdm_channel_get_io_packet_len(tech_pvt->ftdmchan); - tech_pvt->cng_frame.samples = tech_pvt->cng_frame.datalen; - tech_pvt->cng_frame.flags = SFF_CNG; - *frame = &tech_pvt->cng_frame; - if (ftdm_channel_get_codec(tech_pvt->ftdmchan) == FTDM_CODEC_SLIN) { - tech_pvt->cng_frame.samples /= 2; - } - return SWITCH_STATUS_SUCCESS; - } - - if (!switch_test_flag(tech_pvt, TFLAG_IO)) { - switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "TFLAG_IO is not set in channel %s device %d:%d!\n", name, span_id, chan_id); - goto fail; - } - - wflags = FTDM_READ; - status = ftdm_channel_wait(tech_pvt->ftdmchan, &wflags, chunk); - - if (status == FTDM_FAIL) { - switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_ERROR, "Failed to read from channel %s device %d:%d!\n", name, span_id, chan_id); - goto fail; - } - - if (status == FTDM_TIMEOUT) { - if (!switch_test_flag(tech_pvt, TFLAG_HOLD)) { - total_to -= chunk; - if (total_to <= 0) { - switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_WARNING, "Too many timeouts while waiting I/O in channel %s device %d:%d!\n", name, span_id, chan_id); - goto fail; - } - } - goto top; - } - - if (!(wflags & FTDM_READ)) { - goto top; - } - - len = tech_pvt->read_frame.buflen; - if (ftdm_channel_read(tech_pvt->ftdmchan, tech_pvt->read_frame.data, &len) != FTDM_SUCCESS) { - if (switch_test_flag(tech_pvt, TFLAG_DEAD)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Failed to read from dead channel %s device %d:%d\n", name, span_id, chan_id); - goto normal_failure; - } - switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_WARNING, "Failed to read from channel %s device %d:%d!\n", name, span_id, chan_id); - if (++tech_pvt->read_error > FTDM_MAX_READ_WRITE_ERRORS) { - switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_ERROR, "too many I/O read errors on channel %s device %d:%d!\n", name, span_id, chan_id); - goto fail; - } - - } else { - tech_pvt->read_error = 0; - } - - *frame = &tech_pvt->read_frame; - tech_pvt->read_frame.datalen = (uint32_t)len; - tech_pvt->read_frame.samples = tech_pvt->read_frame.datalen; - - if (ftdm_channel_get_codec(tech_pvt->ftdmchan) == FTDM_CODEC_SLIN) { - tech_pvt->read_frame.samples /= 2; - } - - while (ftdm_channel_dequeue_dtmf(tech_pvt->ftdmchan, dtmf, sizeof(dtmf))) { - switch_dtmf_t _dtmf = { 0, switch_core_default_dtmf_duration(0) }; - char *p; - for (p = dtmf; p && *p; p++) { - if (is_dtmf(*p)) { - _dtmf.digit = *p; - switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "Queuing DTMF [%c] in channel %s device %d:%d\n", *p, name, span_id, chan_id); - switch_channel_queue_dtmf(channel, &_dtmf); - } - } - } - - return SWITCH_STATUS_SUCCESS; - -fail: - switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_ERROR, "clearing IO in channel %s device %d:%d!\n", name, span_id, chan_id); -normal_failure: - switch_clear_flag_locked(tech_pvt, TFLAG_IO); - return SWITCH_STATUS_GENERR; -} - -static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id) -{ - switch_channel_t *channel = NULL; - private_t *tech_pvt = NULL; - ftdm_size_t len; - unsigned char data[SWITCH_RECOMMENDED_BUFFER_SIZE] = {0}; - const char *name = "(none)"; - ftdm_wait_flag_t wflags = FTDM_WRITE; - uint32_t span_id = 0, chan_id = 0; - - channel = switch_core_session_get_channel(session); - assert(channel != NULL); - - tech_pvt = switch_core_session_get_private(session); - assert(tech_pvt != NULL); - - name = switch_channel_get_name(channel); - if (!tech_pvt->ftdmchan) { - switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "no ftdmchan set in channel %s!\n", name); - return SWITCH_STATUS_FALSE; - } - - span_id = ftdm_channel_get_span_id(tech_pvt->ftdmchan); - chan_id = ftdm_channel_get_id(tech_pvt->ftdmchan); - - if (switch_test_flag(tech_pvt, TFLAG_DEAD)) { - switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "TFLAG_DEAD is set in channel %s device %d:%d!\n", name, span_id, chan_id); - return SWITCH_STATUS_FALSE; - } - - if (switch_test_flag(tech_pvt, TFLAG_HOLD)) { - return SWITCH_STATUS_SUCCESS; - } - - if (!switch_test_flag(tech_pvt, TFLAG_IO)) { - switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "TFLAG_IO is not set in channel %s device %d:%d!\n", name, span_id, chan_id); - goto fail; - } - - if (switch_test_flag(frame, SFF_CNG)) { - frame->data = data; - frame->buflen = sizeof(data); - if ((frame->datalen = tech_pvt->write_codec.implementation->encoded_bytes_per_packet) > frame->buflen) { - goto fail; - } - memset(data, 255, frame->datalen); - } - - - wflags = FTDM_WRITE; - ftdm_channel_wait(tech_pvt->ftdmchan, &wflags, ftdm_channel_get_io_interval(tech_pvt->ftdmchan) * 10); - - if (!(wflags & FTDM_WRITE)) { - switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "Dropping frame! (write not ready) in channel %s device %d:%d!\n", name, span_id, chan_id); - return SWITCH_STATUS_SUCCESS; - } - - len = frame->datalen; - if (ftdm_channel_write(tech_pvt->ftdmchan, frame->data, frame->buflen, &len) != FTDM_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "Failed to write to channel %s device %d:%d!\n", name, span_id, chan_id); - if (++tech_pvt->write_error > FTDM_MAX_READ_WRITE_ERRORS) { - switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), - SWITCH_LOG_ERROR, "Too many I/O write errors on channel %s device %d:%d!\n", name, span_id, chan_id); - goto fail; - } - } else { - tech_pvt->write_error = 0; - } - - return SWITCH_STATUS_SUCCESS; - - fail: - switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "Error writing to channel %s device %d:%d!\n", name, span_id, chan_id); - switch_clear_flag_locked(tech_pvt, TFLAG_IO); - return SWITCH_STATUS_GENERR; - -} - -static switch_status_t channel_receive_message_cas(switch_core_session_t *session, switch_core_session_message_t *msg) -{ - switch_channel_t *channel; - private_t *tech_pvt; - uint32_t phy_id; - - channel = switch_core_session_get_channel(session); - assert(channel != NULL); - - tech_pvt = (private_t *) switch_core_session_get_private(session); - assert(tech_pvt != NULL); - - if (switch_test_flag(tech_pvt, TFLAG_DEAD)) { - switch_channel_hangup(channel, SWITCH_CAUSE_LOSE_RACE); - return SWITCH_STATUS_FALSE; - } - - phy_id = ftdm_channel_get_ph_id(tech_pvt->ftdmchan); - ftdm_log(FTDM_LOG_DEBUG, "Got Freeswitch message in R2 channel %d [%d]\n", phy_id, msg->message_id); - - if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) { - return SWITCH_STATUS_SUCCESS; - } - - switch (msg->message_id) { - case SWITCH_MESSAGE_INDICATE_RINGING: - { - ftdm_channel_call_indicate(tech_pvt->ftdmchan, FTDM_CHANNEL_INDICATE_PROGRESS); - } - break; - case SWITCH_MESSAGE_INDICATE_PROGRESS: - { - ftdm_channel_call_indicate(tech_pvt->ftdmchan, FTDM_CHANNEL_INDICATE_PROGRESS_MEDIA); - } - break; - case SWITCH_MESSAGE_INDICATE_ANSWER: - { - ftdm_channel_call_answer(tech_pvt->ftdmchan); - } - break; - default: - break; - } - - return SWITCH_STATUS_SUCCESS; -} - -static switch_status_t channel_receive_message_b(switch_core_session_t *session, switch_core_session_message_t *msg) -{ - switch_channel_t *channel; - private_t *tech_pvt; - - channel = switch_core_session_get_channel(session); - assert(channel != NULL); - - tech_pvt = (private_t *) switch_core_session_get_private(session); - assert(tech_pvt != NULL); - - if (switch_test_flag(tech_pvt, TFLAG_DEAD)) { - switch_channel_hangup(channel, SWITCH_CAUSE_LOSE_RACE); - return SWITCH_STATUS_FALSE; - } - - if (ftdm_channel_call_check_hangup(tech_pvt->ftdmchan)) { - return SWITCH_STATUS_SUCCESS; - } - - if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) { - return SWITCH_STATUS_SUCCESS; - } - - switch (msg->message_id) { - case SWITCH_MESSAGE_INDICATE_RINGING: - { - ftdm_channel_call_indicate(tech_pvt->ftdmchan, FTDM_CHANNEL_INDICATE_RINGING); - } - break; - case SWITCH_MESSAGE_INDICATE_PROGRESS: - { - ftdm_channel_call_indicate(tech_pvt->ftdmchan, FTDM_CHANNEL_INDICATE_PROGRESS_MEDIA); - } - break; - case SWITCH_MESSAGE_INDICATE_ANSWER: - { - ftdm_channel_call_answer(tech_pvt->ftdmchan); - } - break; - case SWITCH_MESSAGE_INDICATE_REDIRECT: - case SWITCH_MESSAGE_INDICATE_DEFLECT: - { - ftdm_usrmsg_t usrmsg; - const char *val = NULL; - - memset(&usrmsg, 0, sizeof(usrmsg)); - - if ((val = switch_channel_get_variable(channel, "freetdm_transfer_data"))) { - ftdm_usrmsg_add_var(&usrmsg, "transfer_data", val); - } - - switch_set_flag(tech_pvt, TFLAG_TRANSFER); - if (ftdm_channel_call_transfer_ex(tech_pvt->ftdmchan, msg->string_arg, &usrmsg) != FTDM_SUCCESS) { - switch_clear_flag(tech_pvt, TFLAG_TRANSFER); - } - while (switch_test_flag(tech_pvt, TFLAG_TRANSFER)) { - switch_yield(100000); - } - } - default: - break; - } - - return SWITCH_STATUS_SUCCESS; -} - -static switch_status_t channel_receive_message_fxo(switch_core_session_t *session, switch_core_session_message_t *msg) -{ - switch_channel_t *channel; - private_t *tech_pvt; - - channel = switch_core_session_get_channel(session); - assert(channel != NULL); - - tech_pvt = (private_t *) switch_core_session_get_private(session); - assert(tech_pvt != NULL); - - if (switch_test_flag(tech_pvt, TFLAG_DEAD)) { - switch_channel_hangup(channel, SWITCH_CAUSE_LOSE_RACE); - return SWITCH_STATUS_FALSE; - } - - if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) { - return SWITCH_STATUS_SUCCESS; - } - - switch (msg->message_id) { - case SWITCH_MESSAGE_INDICATE_PROGRESS: - case SWITCH_MESSAGE_INDICATE_ANSWER: - ftdm_channel_call_answer(tech_pvt->ftdmchan); - break; - default: - break; - } - - return SWITCH_STATUS_SUCCESS; -} - -static switch_status_t channel_receive_message_fxs(switch_core_session_t *session, switch_core_session_message_t *msg) -{ - switch_channel_t *channel; - private_t *tech_pvt; - - channel = switch_core_session_get_channel(session); - assert(channel != NULL); - - tech_pvt = (private_t *) switch_core_session_get_private(session); - assert(tech_pvt != NULL); - - if (switch_test_flag(tech_pvt, TFLAG_DEAD)) { - switch_channel_hangup(channel, SWITCH_CAUSE_LOSE_RACE); - return SWITCH_STATUS_FALSE; - } - - if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) { - return SWITCH_STATUS_SUCCESS; - } - - switch (msg->message_id) { - case SWITCH_MESSAGE_INDICATE_PROGRESS: - case SWITCH_MESSAGE_INDICATE_ANSWER: - ftdm_channel_call_answer(tech_pvt->ftdmchan); - switch_channel_mark_answered(channel); - break; - case SWITCH_MESSAGE_INDICATE_RINGING: - if (!switch_channel_test_flag(channel, CF_ANSWERED) && - !switch_channel_test_flag(channel, CF_EARLY_MEDIA) && - !switch_channel_test_flag(channel, CF_RING_READY) - ) { - ftdm_channel_call_indicate(tech_pvt->ftdmchan, FTDM_CHANNEL_INDICATE_RINGING); - switch_channel_mark_ring_ready(channel); - } - break; - default: - break; - } - - return SWITCH_STATUS_SUCCESS; -} - -static switch_status_t channel_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg) -{ - private_t *tech_pvt; - switch_status_t status; - switch_channel_t *channel; - const char *var; - ftdm_channel_t *ftdmchan = NULL; - - tech_pvt = (private_t *) switch_core_session_get_private(session); - assert(tech_pvt != NULL); - - channel = switch_core_session_get_channel(session); - - if (switch_test_flag(tech_pvt, TFLAG_DEAD)) { - switch_channel_hangup(channel, SWITCH_CAUSE_LOSE_RACE); - return SWITCH_STATUS_FALSE; - } - - if (!(ftdmchan = tech_pvt->ftdmchan)) { - switch_channel_hangup(channel, SWITCH_CAUSE_LOSE_RACE); - return SWITCH_STATUS_FALSE; - } - - if (!tech_pvt->ftdmchan) { - switch_channel_hangup(channel, SWITCH_CAUSE_LOSE_RACE); - return SWITCH_STATUS_FALSE; - } - - switch (msg->message_id) { - case SWITCH_MESSAGE_INDICATE_PROGRESS: - case SWITCH_MESSAGE_INDICATE_ANSWER: - if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_INBOUND) { - if ((var = switch_channel_get_variable(channel, "freetdm_pre_buffer_size"))) { - int tmp = atoi(var); - if (tmp > -1) { - ftdm_channel_command(tech_pvt->ftdmchan, FTDM_COMMAND_SET_PRE_BUFFER_SIZE, &tmp); - } - } - if ((var = switch_channel_get_variable(channel, "freetdm_disable_dtmf"))) { - ftdm_channel_command(tech_pvt->ftdmchan, FTDM_COMMAND_DISABLE_DTMF_DETECT, NULL); - } - } - break; - case SWITCH_MESSAGE_INDICATE_UUID_CHANGE: - { - ftdm_channel_replace_token(tech_pvt->ftdmchan, msg->string_array_arg[0], msg->string_array_arg[1]); - } - break; - default: - break; - } - - switch (ftdm_channel_get_type(tech_pvt->ftdmchan)) { - case FTDM_CHAN_TYPE_FXS: - case FTDM_CHAN_TYPE_EM: - status = channel_receive_message_fxs(session, msg); - break; - case FTDM_CHAN_TYPE_FXO: - status = channel_receive_message_fxo(session, msg); - break; - case FTDM_CHAN_TYPE_B: - status = channel_receive_message_b(session, msg); - break; - case FTDM_CHAN_TYPE_CAS: - status = channel_receive_message_cas(session, msg); - break; - default: - status = SWITCH_STATUS_FALSE; - break; - } - - return status; -} - -switch_state_handler_table_t freetdm_state_handlers = { - /*.on_init */ channel_on_init, - /*.on_routing */ channel_on_routing, - /*.on_execute */ channel_on_execute, - /*.on_hangup */ channel_on_hangup, - /*.on_exchange_media */ channel_on_exchange_media, - /*.on_soft_execute */ channel_on_soft_execute, - /*.on_consume_media */ NULL, - /*.on_hibernate */ NULL, - /*.on_reset */ NULL, - /*.on_park*/ NULL, - /*.on_reporting*/ NULL, - /*.on_destroy*/ channel_on_destroy -}; - -switch_io_routines_t freetdm_io_routines = { - /*.outgoing_channel */ channel_outgoing_channel, - /*.read_frame */ channel_read_frame, - /*.write_frame */ channel_write_frame, - /*.kill_channel */ channel_kill_channel, - /*.send_dtmf */ channel_send_dtmf, - /*.receive_message*/ channel_receive_message -}; - -static const char* channel_get_variable(switch_core_session_t *session, switch_event_t *var_event, const char *variable_name) -{ - const char *variable = NULL; - - if (var_event) { - if ((variable = switch_event_get_header(var_event, variable_name))) { - return variable; - } - } - - if (session) { - switch_channel_t *channel = switch_core_session_get_channel(session); - if ((variable = switch_channel_get_variable(channel, variable_name))) { - return variable; - } - } - return NULL; -} - -typedef struct { - switch_event_t *var_event; - switch_core_session_t *new_session; - private_t *tech_pvt; - switch_caller_profile_t *caller_profile; -} hunt_data_t; - -static ftdm_status_t on_channel_found(ftdm_channel_t *fchan, ftdm_caller_data_t *caller_data) -{ - uint32_t span_id, chan_id; - const char *var; - char *sess_uuid; - char name[128]; - ftdm_status_t status; - hunt_data_t *hdata = caller_data->priv; - switch_channel_t *channel = switch_core_session_get_channel(hdata->new_session); - - if ((var = switch_event_get_header(hdata->var_event, "freetdm_pre_buffer_size"))) { - int tmp = atoi(var); - if (tmp > -1) { - ftdm_channel_command(fchan, FTDM_COMMAND_SET_PRE_BUFFER_SIZE, &tmp); - } - } - - span_id = ftdm_channel_get_span_id(fchan); - chan_id = ftdm_channel_get_id(fchan); - - tech_init(hdata->tech_pvt, hdata->new_session, fchan, caller_data); - - snprintf(name, sizeof(name), "FreeTDM/%u:%u/%s", span_id, chan_id, caller_data->dnis.digits); - switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "Connect outbound channel %s\n", name); - switch_channel_set_name(channel, name); - switch_channel_set_variable(channel, "freetdm_span_name", ftdm_channel_get_span_name(fchan)); - switch_channel_set_variable_printf(channel, "freetdm_span_number", "%d", span_id); - switch_channel_set_variable_printf(channel, "freetdm_chan_number", "%d", chan_id); - - switch_channel_set_caller_profile(channel, hdata->caller_profile); - hdata->tech_pvt->caller_profile = hdata->caller_profile; - - switch_channel_set_state(channel, CS_INIT); - sess_uuid = switch_core_session_get_uuid(hdata->new_session); - status = ftdm_channel_add_token(fchan, sess_uuid, ftdm_channel_get_token_count(fchan)); - switch_assert(status == FTDM_SUCCESS); - - if (SPAN_CONFIG[span_id].limit_calls) { - char spanresource[512]; - snprintf(spanresource, sizeof(spanresource), "span_%s_%s", ftdm_channel_get_span_name(fchan), - caller_data->dnis.digits); - - ftdm_log(FTDM_LOG_DEBUG, "Adding rate limit resource on channel %d:%d (%s/%s/%d/%d)\n", - span_id, chan_id, FREETDM_LIMIT_REALM, - spanresource, SPAN_CONFIG[span_id].limit_calls, SPAN_CONFIG[span_id].limit_seconds); - - if (switch_limit_incr("hash", hdata->new_session, FREETDM_LIMIT_REALM, spanresource, - SPAN_CONFIG[span_id].limit_calls, SPAN_CONFIG[span_id].limit_seconds) != SWITCH_STATUS_SUCCESS) { - return FTDM_BREAK; - } - } - switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "Attached session %s to channel %d:%d\n", sess_uuid, span_id, chan_id); - return FTDM_SUCCESS; -} - -/* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines -that allocate memory or you will have 1 channel with memory allocated from another channel's pool! -*/ -static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event, - switch_caller_profile_t *outbound_profile, - switch_core_session_t **new_session, switch_memory_pool_t **pool, - switch_originate_flag_t flags, switch_call_cause_t *cancel_cause) -{ - hunt_data_t hunt_data; - const char *dest = NULL; - char *data = NULL; - int span_id = -1, group_id = -1, chan_id = 0; - switch_call_cause_t cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; - ftdm_status_t status; - ftdm_hunt_direction_t direction = FTDM_HUNT_BOTTOM_UP; - ftdm_caller_data_t caller_data = {{ 0 }}; - char *span_name = NULL; - switch_event_header_t *h; - char *argv[3]; - int argc = 0; - const char *var; - const char *dest_num = NULL, *callerid_num = NULL; - const char *network_peer_uuid = NULL; - char sigbridge_peer[255]; - switch_channel_t *peer_chan = NULL; - switch_channel_t *our_chan = NULL; - ftdm_hunting_scheme_t hunting; - ftdm_usrmsg_t usrmsg; - - memset(&usrmsg, 0, sizeof(ftdm_usrmsg_t)); - memset(sigbridge_peer, 0, sizeof(sigbridge_peer)); - - if (!outbound_profile) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing caller profile\n"); - return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; - } - - if (zstr(outbound_profile->destination_number)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid dial string\n"); - return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; - } - - - data = switch_core_strdup(outbound_profile->pool, outbound_profile->destination_number); - - if (!zstr(outbound_profile->destination_number)) { - dest_num = switch_sanitize_number(switch_core_strdup(outbound_profile->pool, outbound_profile->destination_number)); - } - - if (!zstr(outbound_profile->caller_id_number)) { - callerid_num = switch_sanitize_number(switch_core_strdup(outbound_profile->pool, outbound_profile->caller_id_number)); - if ( callerid_num && *callerid_num == '+' ) { - callerid_num++; - } - } - - if (!zstr(callerid_num) && !strcmp(callerid_num, SWITCH_DEFAULT_CLID_NUMBER)) { - callerid_num = NULL; - } - - if ((argc = switch_separate_string(data, '/', argv, (sizeof(argv) / sizeof(argv[0])))) < 2) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid dial string\n"); - return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; - } - - if (switch_is_number(argv[0])) { - span_id = atoi(argv[0]); - } else { - span_name = argv[0]; - } - - if (*argv[1] == 'a') { - direction = FTDM_HUNT_BOTTOM_UP; - } else if (*argv[1] == 'A') { - direction = FTDM_HUNT_TOP_DOWN; - } else if (*argv[1] == 'R') { - direction = FTDM_HUNT_RR_DOWN; - } else if (*argv[1] == 'r') { - direction = FTDM_HUNT_RR_UP; - } else { - chan_id = atoi(argv[1]); - } - - if (!(dest = argv[2])) { - dest = ""; - } - - if (span_id == 0 && chan_id != 0) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Span 0 is used to pick the first available span, selecting a channel is not supported (and doesn't make sense)\n"); - return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; - } - - if (span_id == -1 && !zstr(span_name)) { - ftdm_span_t *span; - ftdm_status_t zstatus = ftdm_span_find_by_name(span_name, &span); - if (zstatus == FTDM_SUCCESS && span) { - span_id = ftdm_span_get_id(span); - } - } - - if (span_id == -1) { - //Look for a group - ftdm_group_t *group; - ftdm_status_t zstatus = ftdm_group_find_by_name(span_name, &group); - if (zstatus == FTDM_SUCCESS && group) { - group_id = ftdm_group_get_id(group); - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing ftdm span or group: %s\n", span_name); - return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; - } - } - - if (group_id < 0 && chan_id < 0) { - direction = FTDM_HUNT_BOTTOM_UP; - chan_id = 0; - } - - if (session && globals.sip_headers && !switch_core_session_check_interface (session,freetdm_endpoint_interface) ) { - switch_channel_t *channel = switch_core_session_get_channel(session); - const char *sipvar; - - network_peer_uuid = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-TransUUID"); - - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-CallerName"); - if (sipvar) { - ftdm_set_string(caller_data.cid_name, sipvar); - } - - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-CallerNumber"); - if (sipvar) { - if ( *sipvar == '+' ) { - sipvar++; - } - ftdm_set_string(caller_data.cid_num.digits, sipvar); - } - - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-ANI"); - if (sipvar) { - ftdm_set_string(caller_data.ani.digits, sipvar); - } - - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-ANI-TON"); - if (sipvar) { - caller_data.ani.type = (uint8_t)atoi(sipvar); - } - - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-ANI-Plan"); - if (sipvar) { - caller_data.ani.plan = (uint8_t)atoi(sipvar); - } - - /* Used by ftmod_sangoma_ss7 only */ - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-ANI-NADI"); - if (sipvar) { - ftdm_usrmsg_add_var(&usrmsg, "ss7_clg_nadi", sipvar); - } - - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-ANI2"); - if (sipvar) { - ftdm_set_string(caller_data.aniII, sipvar); - } - - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-DNIS"); - if (sipvar) { - ftdm_set_string(caller_data.dnis.digits, sipvar); - } - - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-LOC"); - if (sipvar) { - ftdm_set_string(caller_data.loc.digits, sipvar); - } - - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-Access-Transport-URLENC"); - if (sipvar) { - ftdm_usrmsg_add_var(&usrmsg, "ss7_access_transport_urlenc", sipvar); - } - - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-LOC-Screen"); - if (sipvar) { - ftdm_usrmsg_add_var(&usrmsg, "ss7_loc_screen_ind", sipvar); - } - - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-LOC-Presentation"); - if (sipvar) { - ftdm_usrmsg_add_var(&usrmsg, "ss7_loc_pres_ind", sipvar); - } - - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-LOC-NADI"); - if (sipvar) { - ftdm_usrmsg_add_var(&usrmsg, "ss7_loc_nadi", sipvar); - } - - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-DNIS-TON"); - if (sipvar) { - caller_data.dnis.type = (uint8_t)atoi(sipvar); - } - - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-DNIS-Plan"); - if (sipvar) { - caller_data.dnis.plan = (uint8_t)atoi(sipvar); - } - - /* Used by ftmod_sangoma_ss7 only */ - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-DNIS-NADI"); - if (sipvar) { - ftdm_usrmsg_add_var(&usrmsg, "ss7_cld_nadi", sipvar); - } - - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-RDNIS"); - if (sipvar) { - ftdm_set_string(caller_data.rdnis.digits, sipvar); - ftdm_usrmsg_add_var(&usrmsg, "ss7_rdnis_digits", sipvar); - } - - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-RDNIS-Plan"); - if (sipvar) { - ftdm_usrmsg_add_var(&usrmsg, "ss7_rdnis_plan", sipvar); - } - - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-RDNIS-NADI"); - if (sipvar) { - ftdm_usrmsg_add_var(&usrmsg, "ss7_rdnis_nadi", sipvar); - } - - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-RDNIS-Screen"); - if (sipvar) { - ftdm_usrmsg_add_var(&usrmsg, "ss7_rdnis_screen_ind", sipvar); - } - - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-RDNIS-Presentation"); - if (sipvar) { - ftdm_usrmsg_add_var(&usrmsg, "ss7_rdnis_pres_ind", sipvar); - } - - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-GN"); - if (sipvar) { - ftdm_usrmsg_add_var(&usrmsg, "ss7_gn_digits", sipvar); - } - - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-GN-NumQual"); - if (sipvar) { - ftdm_usrmsg_add_var(&usrmsg, "ss7_gn_numqual", sipvar); - } - - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-GN-NADI"); - if (sipvar) { - ftdm_usrmsg_add_var(&usrmsg, "ss7_gn_nadi", sipvar); - } - - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-GN-Screen"); - if (sipvar) { - ftdm_usrmsg_add_var(&usrmsg, "ss7_gn_screen_ind", sipvar); - } - - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-GN-Presentation"); - if (sipvar) { - ftdm_usrmsg_add_var(&usrmsg, "ss7_gn_pres_ind", sipvar); - } - - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-GN-Plan"); - if (sipvar) { - ftdm_usrmsg_add_var(&usrmsg, "ss7_gn_npi", sipvar); - } - - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-GN-NumInComp"); - if (sipvar) { - ftdm_usrmsg_add_var(&usrmsg, "ss7_gn_num_inc_ind", sipvar); - } - - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-Screen"); - if (sipvar) { - ftdm_usrmsg_add_var(&usrmsg, "ss7_screen_ind", sipvar); - } - - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-Presentation"); - if (sipvar) { - ftdm_usrmsg_add_var(&usrmsg, "ss7_pres_ind", sipvar); - } - - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-CPC"); - if (sipvar) { - ftdm_set_calling_party_category(sipvar, (uint8_t *)&caller_data.cpc); - } - - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-IAM"); - if (sipvar) { - ftdm_usrmsg_add_var(&usrmsg, "ss7_iam", sipvar); - } - - /* redirection information */ - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-RDINF-Indicator"); - if (sipvar) { - ftdm_usrmsg_add_var(&usrmsg, "ss7_rdinfo_indicator", sipvar); - } - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-RDINF-OrigReason"); - if (sipvar) { - ftdm_usrmsg_add_var(&usrmsg, "ss7_rdinfo_orig", sipvar); - } - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-RDINF-Count"); - if (sipvar) { - ftdm_usrmsg_add_var(&usrmsg, "ss7_rdinfo_count", sipvar); - } - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-RDINF-Reason"); - if (sipvar) { - ftdm_usrmsg_add_var(&usrmsg, "ss7_rdinfo_reason", sipvar); - } - - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-OCN"); - if (sipvar) { - ftdm_usrmsg_add_var(&usrmsg, "ss7_ocn", sipvar); - } - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-OCN-NADI"); - if (sipvar) { - ftdm_usrmsg_add_var(&usrmsg, "ss7_ocn_nadi", sipvar); - } - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-OCN-Plan"); - if (sipvar) { - ftdm_usrmsg_add_var(&usrmsg, "ss7_ocn_plan", sipvar); - } - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-OCN-Presentation"); - if (sipvar) { - ftdm_usrmsg_add_var(&usrmsg, "ss7_ocn_pres", sipvar); - } - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-IAM-FWD-IND-HEX"); - if (sipvar) { - ftdm_usrmsg_add_var(&usrmsg, "ss7_iam_fwd_ind_hex", sipvar); - } - - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-IAM-NATURE-CONN-HEX"); - if (sipvar) { - ftdm_usrmsg_add_var(&usrmsg, "ss7_iam_nature_connection_hex", sipvar); - } - } - - if (switch_test_flag(outbound_profile, SWITCH_CPF_SCREEN)) { - caller_data.screen = FTDM_SCREENING_VERIFIED_PASSED; - } - - if (switch_test_flag(outbound_profile, SWITCH_CPF_HIDE_NUMBER)) { - caller_data.pres = FTDM_PRES_RESTRICTED; - } - - if ((var = channel_get_variable(session, var_event, "freetdm_iam_fwd_ind_isdn_access_ind"))) { - ftdm_usrmsg_add_var(&usrmsg, "iam_fwd_ind_isdn_access_ind", var); - } - - if ((var = channel_get_variable(session, var_event, "freetdm_bearer_capability"))) { - caller_data.bearer_capability = (uint8_t)atoi(var); - } - - if ((var = channel_get_variable(session, var_event, "freetdm_bearer_layer1"))) { - caller_data.bearer_layer1 = (uint8_t)atoi(var); - } - - if ((var = channel_get_variable(session, var_event, "freetdm_screening_ind"))) { - ftdm_set_screening_ind(var, &caller_data.screen); - } - - if ((var = channel_get_variable(session, var_event, "freetdm_presentation_ind"))) { - ftdm_set_presentation_ind(var, &caller_data.pres); - } - - if ((var = channel_get_variable(session, var_event, "freetdm_outbound_ton"))) { - ftdm_set_ton(var, &caller_data.dnis.type); - } else { - caller_data.dnis.type = outbound_profile->destination_number_ton; - } - - if ((var = channel_get_variable(session, var_event, "freetdm_outbound_npi"))) { - ftdm_set_npi(var, &caller_data.dnis.plan); - } else { - caller_data.dnis.plan = outbound_profile->destination_number_numplan; - } - - if ((var = channel_get_variable(session, var_event, "freetdm_calling_party_category"))) { - ftdm_set_calling_party_category(var, (uint8_t *)&caller_data.cpc); - } - - if (!zstr(dest)) { - ftdm_set_string(caller_data.dnis.digits, dest); - } - - caller_data.dnis.plan = outbound_profile->destination_number_numplan; - - /* blindly copy data from outbound_profile. They will be overwritten - * by calling ftdm_caller_data if needed after */ - caller_data.cid_num.type = outbound_profile->caller_ton; - caller_data.cid_num.plan = outbound_profile->caller_numplan; - caller_data.rdnis.type = outbound_profile->rdnis_ton; - caller_data.rdnis.plan = outbound_profile->rdnis_numplan; - - ftdm_set_string(caller_data.cid_name, outbound_profile->caller_id_name); - ftdm_set_string(caller_data.cid_num.digits, switch_str_nil(callerid_num)); - - memset(&hunting, 0, sizeof(hunting)); - - if (group_id >= 0) { - hunting.mode = FTDM_HUNT_GROUP; - hunting.mode_data.group.group_id = group_id; - hunting.mode_data.group.direction = direction; - } else if (chan_id) { - hunting.mode = FTDM_HUNT_CHAN; - hunting.mode_data.chan.span_id = span_id; - hunting.mode_data.chan.chan_id = chan_id; - } else { - hunting.mode = FTDM_HUNT_SPAN; - hunting.mode_data.span.span_id = span_id; - hunting.mode_data.span.direction = direction; - } - - for (h = var_event->headers; h; h = h->next) { - if (!strncasecmp(h->name, FREETDM_VAR_PREFIX, FREETDM_VAR_PREFIX_LEN)) { - char *v = h->name + FREETDM_VAR_PREFIX_LEN; - if (!zstr(v)) { - if (!strcasecmp(v, "ss7_iam")) { - /* Do not print the value of ss7_iam as it is very long */ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding outbound freetdm variable %s to channel %d:%d\n", v, span_id, chan_id); - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding outbound freetdm variable %s=%s to channel %d:%d\n", v, h->value, span_id, chan_id); - } - - ftdm_usrmsg_add_var(&usrmsg, v, h->value); - } - } - } - - if ((*new_session = switch_core_session_request(freetdm_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, flags, pool)) != 0) { - private_t *tech_pvt; - switch_caller_profile_t *caller_profile; - - switch_core_session_add_stream(*new_session, NULL); - if (!(tech_pvt = (private_t *) switch_core_session_alloc(*new_session, sizeof(private_t)))) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Hey where is my memory pool?\n"); - switch_core_session_destroy(new_session); - cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; - goto fail; - } - - our_chan = switch_core_session_get_channel(*new_session); - - switch_channel_set_flag(our_chan, CF_AUDIO); - - /* Figure out if there is a native bridge requested through SIP x headers */ - if (network_peer_uuid) { - switch_core_session_t *network_peer = switch_core_session_locate(network_peer_uuid); - if (network_peer) { - const char *my_uuid = switch_core_session_get_uuid(*new_session); - private_t *peer_private = switch_core_session_get_private(network_peer); - peer_chan = switch_core_session_get_channel(network_peer); - switch_set_string(tech_pvt->network_peer_uuid, network_peer_uuid); - switch_set_string(peer_private->network_peer_uuid, my_uuid); - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Session %s is network-bridged with %s\n", - my_uuid, network_peer_uuid); - - snprintf(sigbridge_peer, sizeof(sigbridge_peer), "%u:%u", - ftdm_channel_get_span_id(peer_private->ftdmchan), ftdm_channel_get_id(peer_private->ftdmchan)); - switch_core_session_rwunlock(network_peer); - } - /* Figure out if there is a native bridge requested through dial plan variable and the originating channel is also freetdm (not going through SIP) */ - } else if (session - && (var = channel_get_variable(session, var_event, FREETDM_VAR_PREFIX "native_sigbridge")) - && switch_true(var) - && switch_core_session_compare(*new_session, session)) { - private_t *peer_pvt = switch_core_session_get_private(session); - peer_chan = switch_core_session_get_channel(session); - snprintf(sigbridge_peer, sizeof(sigbridge_peer), "%u:%u", - ftdm_channel_get_span_id(peer_pvt->ftdmchan), ftdm_channel_get_id(peer_pvt->ftdmchan)); - } - - caller_profile = switch_caller_profile_clone(*new_session, outbound_profile); - caller_profile->destination_number = switch_core_strdup(caller_profile->pool, switch_str_nil(dest_num)); - caller_profile->caller_id_number = switch_core_strdup(caller_profile->pool, switch_str_nil(callerid_num)); - - hunting.result_cb = on_channel_found; - hunt_data.var_event = var_event; - hunt_data.new_session = *new_session; - hunt_data.caller_profile = caller_profile; - hunt_data.tech_pvt = tech_pvt; - caller_data.priv = &hunt_data; - - if (session && !zstr(sigbridge_peer)) { - peer_chan = switch_core_session_get_channel(session); - ftdm_usrmsg_add_var(&usrmsg, "sigbridge_peer", sigbridge_peer); - } - - if ((status = ftdm_call_place_ex(&caller_data, &hunting, &usrmsg)) != FTDM_SUCCESS) { - if (tech_pvt->read_codec.implementation) { - switch_core_codec_destroy(&tech_pvt->read_codec); - } - - if (tech_pvt->write_codec.implementation) { - switch_core_codec_destroy(&tech_pvt->write_codec); - } - switch_core_session_destroy(new_session); - if (status == FTDM_BREAK || status == FTDM_EBUSY) { - cause = SWITCH_CAUSE_NORMAL_CIRCUIT_CONGESTION; - } else { - cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; - } - goto fail; - } - - if (our_chan && peer_chan) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, - "Bridging native signaling of channel %s to channel %s\n", - switch_channel_get_name(peer_chan), switch_channel_get_name(our_chan)); - } - - return SWITCH_CAUSE_SUCCESS; - } - -fail: - return cause; -} - -static void ftdm_enable_channel_dtmf(ftdm_channel_t *fchan, switch_channel_t *channel) -{ - if (channel) { - const char *var; - if ((var = switch_channel_get_variable(channel, "freetdm_disable_dtmf"))) { - if (switch_true(var)) { - ftdm_channel_command(fchan, FTDM_COMMAND_DISABLE_DTMF_DETECT, NULL); - ftdm_log(FTDM_LOG_INFO, "DTMF detection disabled in channel %d:%d\n", ftdm_channel_get_span_id(fchan), ftdm_channel_get_id(fchan)); - return; - } - } - /* the variable is not present or has a negative value then proceed to enable DTMF ... */ - } - if (ftdm_channel_command(fchan, FTDM_COMMAND_ENABLE_DTMF_DETECT, NULL) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "Failed to enable DTMF detection in channel %d:%d\n", ftdm_channel_get_span_id(fchan), ftdm_channel_get_id(fchan)); - } -} - -ftdm_status_t ftdm_channel_from_event(ftdm_sigmsg_t *sigmsg, switch_core_session_t **sp) -{ - switch_core_session_t *session = NULL; - private_t *tech_pvt = NULL; - switch_channel_t *channel = NULL; - ftdm_iterator_t *iter = NULL; - ftdm_iterator_t *curr = NULL; - const char *var_name = NULL; - const char *var_value = NULL; - uint32_t spanid, chanid; - char name[128]; - ftdm_caller_data_t *channel_caller_data = ftdm_channel_get_caller_data(sigmsg->channel); - - *sp = NULL; - - spanid = ftdm_channel_get_span_id(sigmsg->channel); - chanid = ftdm_channel_get_id(sigmsg->channel); - - if (!(session = switch_core_session_request(freetdm_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, SOF_NONE, NULL))) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Initilization Error!\n"); - return FTDM_FAIL; - } - - /* I guess we always want DTMF detection */ - ftdm_enable_channel_dtmf(sigmsg->channel, NULL); - - switch_core_session_add_stream(session, NULL); - - tech_pvt = (private_t *) switch_core_session_alloc(session, sizeof(private_t)); - assert(tech_pvt != NULL); - channel = switch_core_session_get_channel(session); - if (tech_init(tech_pvt, session, sigmsg->channel, channel_caller_data) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Initilization Error!\n"); - switch_core_session_destroy(&session); - return FTDM_FAIL; - } - - switch_channel_set_flag(channel, CF_AUDIO); - - channel_caller_data->collected[0] = '\0'; - - if (zstr(channel_caller_data->cid_name)) { - switch_set_string(channel_caller_data->cid_name, ftdm_channel_get_name(sigmsg->channel)); - } - - if (zstr(channel_caller_data->cid_num.digits)) { - if (!zstr(channel_caller_data->ani.digits)) { - switch_set_string(channel_caller_data->cid_num.digits, channel_caller_data->ani.digits); - } else { - switch_set_string(channel_caller_data->cid_num.digits, ftdm_channel_get_number(sigmsg->channel)); - } - } - - tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session), - "FreeTDM", - SPAN_CONFIG[spanid].dialplan, - channel_caller_data->cid_name, - channel_caller_data->cid_num.digits, - NULL, - channel_caller_data->ani.digits, - channel_caller_data->aniII, - channel_caller_data->rdnis.digits, - (char *)modname, - SPAN_CONFIG[spanid].context, - channel_caller_data->dnis.digits); - - assert(tech_pvt->caller_profile != NULL); - - if (channel_caller_data->screen == 1 || channel_caller_data->screen == 3) { - switch_set_flag(tech_pvt->caller_profile, SWITCH_CPF_SCREEN); - } - - tech_pvt->caller_profile->caller_ton = channel_caller_data->cid_num.type; - tech_pvt->caller_profile->caller_numplan = channel_caller_data->cid_num.plan; - tech_pvt->caller_profile->ani_ton = channel_caller_data->ani.type; - tech_pvt->caller_profile->ani_numplan = channel_caller_data->ani.plan; - tech_pvt->caller_profile->destination_number_ton = channel_caller_data->dnis.type; - tech_pvt->caller_profile->destination_number_numplan = channel_caller_data->dnis.plan; - tech_pvt->caller_profile->rdnis_ton = channel_caller_data->rdnis.type; - tech_pvt->caller_profile->rdnis_numplan = channel_caller_data->rdnis.plan; - - if (channel_caller_data->pres) { - switch_set_flag(tech_pvt->caller_profile, SWITCH_CPF_HIDE_NAME | SWITCH_CPF_HIDE_NUMBER); - } - - snprintf(name, sizeof(name), "FreeTDM/%u:%u/%s", spanid, chanid, tech_pvt->caller_profile->destination_number); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Connect inbound channel %s\n", name); - switch_channel_set_name(channel, name); - switch_channel_set_caller_profile(channel, tech_pvt->caller_profile); - - switch_channel_set_variable(channel, "freetdm_span_name", ftdm_channel_get_span_name(sigmsg->channel)); - switch_channel_set_variable_printf(channel, "freetdm_span_number", "%d", spanid); - switch_channel_set_variable_printf(channel, "freetdm_chan_number", "%d", chanid); - switch_channel_set_variable_printf(channel, "freetdm_bearer_capability", "%d", channel_caller_data->bearer_capability); - switch_channel_set_variable_printf(channel, "freetdm_bearer_layer1", "%d", channel_caller_data->bearer_layer1); - switch_channel_set_variable_printf(channel, "freetdm_calling_party_category", ftdm_calling_party_category2str(channel_caller_data->cpc)); - switch_channel_set_variable_printf(channel, "screening_ind", ftdm_screening2str(channel_caller_data->screen)); - switch_channel_set_variable_printf(channel, "presentation_ind", ftdm_presentation2str(channel_caller_data->pres)); - - if (globals.sip_headers) { - switch_channel_set_variable(channel, "sip_h_X-FreeTDM-SpanName", ftdm_channel_get_span_name(sigmsg->channel)); - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-SpanNumber", "%d", spanid); - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-TransUUID", "%s",switch_core_session_get_uuid(session)); - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-SpanNumber", "%d", spanid); - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-ChanNumber", "%d", chanid); - - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-CallerName", "%s", channel_caller_data->cid_name); - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-CallerNumber", "%s", channel_caller_data->cid_num.digits); - - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-ANI", "%s", channel_caller_data->ani.digits); - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-ANI-TON", "%d", channel_caller_data->ani.type); - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-ANI-Plan", "%d", channel_caller_data->ani.plan); - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-ANI2", "%s", channel_caller_data->aniII); - - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-DNIS", "%s", channel_caller_data->dnis.digits); - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-DNIS-TON", "%d", channel_caller_data->dnis.type); - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-DNIS-Plan", "%d", channel_caller_data->dnis.plan); - - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-RDNIS", "%s", channel_caller_data->rdnis.digits); - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-RDNIS-NADI", "%d", channel_caller_data->rdnis.type); - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-RDNIS-Plan", "%d", channel_caller_data->rdnis.plan); - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-CPC", "%s", ftdm_calling_party_category2str(channel_caller_data->cpc)); - - var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_iam_nature_connection_hex"); - if (!ftdm_strlen_zero(var_value)) { - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-IAM-NATURE-CONN-HEX", "%s", var_value); - } - - var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_iam_fwd_ind_hex"); - if (!ftdm_strlen_zero(var_value)) { - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-IAM-FWD-IND-HEX", "%s", var_value); - } - - var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_access_transport_urlenc"); - if (!ftdm_strlen_zero(var_value)) { - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-Access-Transport-URLENC", "%s", var_value); - } - - var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_rdinfo_indicator"); - if (!ftdm_strlen_zero(var_value)) { - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-RDINF-Indicator", "%s", var_value); - } - - var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_rdinfo_orig"); - if (!ftdm_strlen_zero(var_value)) { - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-RDINF-OrigReason", "%s", var_value); - } - - var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_rdinfo_count"); - if (!ftdm_strlen_zero(var_value)) { - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-RDINF-Count", "%s", var_value); - } - - var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_rdinfo_reason"); - if (!ftdm_strlen_zero(var_value)) { - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-RDINF-Reason", "%s", var_value); - } - - var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_clg_nadi"); - if (!ftdm_strlen_zero(var_value)) { - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-NADI", "%s", var_value); - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-ANI-NADI", "%s", var_value); - } - - var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_cld_nadi"); - if (!ftdm_strlen_zero(var_value)) { - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-DNIS-NADI", "%s", var_value); - } - - var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_rdnis_screen_ind"); - if (!ftdm_strlen_zero(var_value)) { - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-RDNIS-Screen", "%s", var_value); - } - - var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_rdnis_pres_ind"); - if (!ftdm_strlen_zero(var_value)) { - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-RDNIS-Presentation", "%s", var_value); - } - - var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_gn_digits"); - if (!ftdm_strlen_zero(var_value)) { - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-GN", "%s", var_value); - - var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_gn_numqual"); - if (!ftdm_strlen_zero(var_value)) { - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-GN-NumQual", "%s", var_value); - } - - var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_gn_nadi"); - if (!ftdm_strlen_zero(var_value)) { - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-GN-NADI", "%s", var_value); - } - - var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_gn_screen_ind"); - if (!ftdm_strlen_zero(var_value)) { - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-GN-Screen", "%s", var_value); - } - - var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_gn_pres_ind"); - if (!ftdm_strlen_zero(var_value)) { - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-GN-Presentation", "%s", var_value); - } - - var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_gn_npi"); - if (!ftdm_strlen_zero(var_value)) { - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-GN-Plan", "%s", var_value); - } - - var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_gn_num_inc_ind"); - if (!ftdm_strlen_zero(var_value)) { - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-GN-NumInComp", "%s", var_value); - } - } /* End - var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_gn_digits"); */ - - var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_iam"); - if (!ftdm_strlen_zero(var_value)) { - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-IAM", "%s", var_value); - } - - var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_cic"); - if (!ftdm_strlen_zero(var_value)) { - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-CIC", "%s", var_value); - } - - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-Screen", "%d", channel_caller_data->screen); - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-Presentation", "%d", channel_caller_data->pres); - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-CallReference", "%d", channel_caller_data->call_reference); - - var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_opc"); - if (!ftdm_strlen_zero(var_value)) { - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-OPC", "%s", var_value); - } - - var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_loc_digits"); - if (!ftdm_strlen_zero(var_value)) { - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-LOC", "%s", var_value); - } - - var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_loc_screen_ind"); - if (!ftdm_strlen_zero(var_value)) { - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-LOC-Screen", "%s", var_value); - } - - var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_loc_pres_ind"); - if (!ftdm_strlen_zero(var_value)) { - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-LOC-Presentation", "%s", var_value); - } - - var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_loc_nadi"); - if (!ftdm_strlen_zero(var_value)) { - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-LOC-NADI", "%s", var_value); - } - - var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_ocn"); - if (!ftdm_strlen_zero(var_value)) { - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-OCN", "%s", var_value); - } - - var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_ocn_nadi"); - if (!ftdm_strlen_zero(var_value)) { - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-OCN-NADI", "%s", var_value); - } - - var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_ocn_plan"); - if (!ftdm_strlen_zero(var_value)) { - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-OCN-Plan", "%s", var_value); - } - - var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_ocn_pres"); - if (!ftdm_strlen_zero(var_value)) { - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-OCN-Presentation", "%s", var_value); - } - } - - /* Add any call variable to the dial plan */ - iter = ftdm_sigmsg_get_var_iterator(sigmsg, iter); - for (curr = iter ; curr; curr = ftdm_iterator_next(curr)) { - ftdm_get_current_var(curr, &var_name, &var_value); - snprintf(name, sizeof(name), FREETDM_VAR_PREFIX "%s", var_name); - switch_channel_set_variable_printf(channel, name, "%s", var_value); - if (!strcasecmp(var_name, "ss7_iam")) { - /* Do not print freetdm_ss7_iam as it is a very long variable */ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Call Variable: %s is present\n", name); - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Call Variable: %s = %s\n", name, var_value); - } - } - ftdm_iterator_free(iter); - - switch_channel_set_state(channel, CS_INIT); - if (switch_core_session_thread_launch(session) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error spawning thread\n"); - switch_core_session_destroy(&session); - return FTDM_FAIL; - } - - if (ftdm_channel_add_token(sigmsg->channel, switch_core_session_get_uuid(session), 0) != FTDM_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error adding token\n"); - switch_core_session_destroy(&session); - return FTDM_FAIL; - } - *sp = session; - - return FTDM_SUCCESS; -} - -static FIO_SIGNAL_CB_FUNCTION(on_common_signal) -{ - uint32_t chanid, spanid; - switch_event_t *event = NULL; - ftdm_alarm_flag_t alarmbits = FTDM_ALARM_NONE; - - chanid = ftdm_channel_get_id(sigmsg->channel); - spanid = ftdm_channel_get_span_id(sigmsg->channel); - - switch (sigmsg->event_id) { - case FTDM_SIGEVENT_SMS: - { - ftdm_caller_data_t *caller_data = ftdm_channel_get_caller_data(sigmsg->channel); - ftdm_sms_data_t *sms = (ftdm_sms_data_t*) caller_data->priv; - - ftdm_log(FTDM_LOG_INFO, "SMS received on %d:%d from %s: %s", spanid, chanid, sms->from, sms->body); - if (switch_event_create(&event, SWITCH_EVENT_TRAP) != SWITCH_STATUS_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "failed to create SMS event\n"); - return FTDM_FAIL; - } - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", sms->from); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "body", sms->body); - alarmbits = 0; - } - //return FTDM_BREAK; - break; - case FTDM_SIGEVENT_ALARM_CLEAR: - case FTDM_SIGEVENT_ALARM_TRAP: - { - if (ftdm_channel_get_alarms(sigmsg->channel, &alarmbits) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "failed to retrieve alarms\n"); - return FTDM_FAIL; - } - if (switch_event_create(&event, SWITCH_EVENT_TRAP) != SWITCH_STATUS_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "failed to create alarms events\n"); - return FTDM_FAIL; - } - if (sigmsg->event_id == FTDM_SIGEVENT_ALARM_CLEAR) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "condition", "ftdm-alarm-clear"); - } else { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "condition", "ftdm-alarm-trap"); - } - } - break; - case FTDM_SIGEVENT_UP: - { - /* clear any rate limit resource for this span */ - char spanresource[512]; - if (SPAN_CONFIG[spanid].limit_reset_event == FTDM_LIMIT_RESET_ON_ANSWER && SPAN_CONFIG[spanid].limit_calls) { - ftdm_caller_data_t *caller_data = ftdm_channel_get_caller_data(sigmsg->channel); - snprintf(spanresource, sizeof(spanresource), "span_%s_%s", ftdm_channel_get_span_name(sigmsg->channel), caller_data->dnis.digits); - ftdm_log(FTDM_LOG_DEBUG, "Clearing rate limit resource on channel %d:%d (%s/%s)\n", spanid, chanid, FREETDM_LIMIT_REALM, spanresource); - switch_limit_interval_reset("hash", FREETDM_LIMIT_REALM, spanresource); - } - return FTDM_SUCCESS; - } - break; - case FTDM_SIGEVENT_TRANSFER_COMPLETED: - { - switch_core_session_t *session = NULL; - switch_channel_t *channel = NULL; - private_t *tech_pvt = NULL; - - if ((session = ftdm_channel_get_session(sigmsg->channel, 0))) { - channel = switch_core_session_get_channel(session); - tech_pvt = switch_core_session_get_private(session); - - switch_clear_flag_locked(tech_pvt, TFLAG_TRANSFER); - switch_channel_set_variable(channel, "freetdm_transfer_response", ftdm_transfer_response2str(sigmsg->ev_data.transfer_completed.response)); - switch_core_session_rwunlock(session); - } - return FTDM_SUCCESS; - } - break; - case FTDM_SIGEVENT_RELEASED: - case FTDM_SIGEVENT_INDICATION_COMPLETED: - case FTDM_SIGEVENT_DIALING: - { - /* Swallow these events */ - return FTDM_BREAK; - } - break; - case FTDM_SIGEVENT_STOP: - case FTDM_SIGEVENT_RESTART: - { - switch_core_session_t *session = NULL; - private_t *tech_pvt = NULL; - while ((session = ftdm_channel_get_session(sigmsg->channel, 0))) { - tech_pvt = switch_core_session_get_private(session); - - switch_clear_flag_locked(tech_pvt, TFLAG_TRANSFER); - switch_core_session_rwunlock(session); - return FTDM_SUCCESS; - } - } - break; - default: - return FTDM_SUCCESS; - break; - } - - if (event) { - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "span-name", "%s", ftdm_channel_get_span_name(sigmsg->channel)); - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "span-number", "%d", ftdm_channel_get_span_id(sigmsg->channel)); - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "chan-number", "%d", ftdm_channel_get_id(sigmsg->channel)); - - if (alarmbits & FTDM_ALARM_RED) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "red"); - } - if (alarmbits & FTDM_ALARM_YELLOW) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "yellow"); - } - if (alarmbits & FTDM_ALARM_RAI) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "rai"); - } - if (alarmbits & FTDM_ALARM_BLUE) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "blue"); - } - if (alarmbits & FTDM_ALARM_AIS) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "ais"); - } - if (alarmbits & FTDM_ALARM_GENERAL) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "general"); - } - switch_event_fire(&event); - } - - return FTDM_BREAK; -} - -static FIO_SIGNAL_CB_FUNCTION(on_fxo_signal) -{ - switch_core_session_t *session = NULL; - switch_channel_t *channel = NULL; - ftdm_status_t status = FTDM_SUCCESS; - uint32_t spanid; - uint32_t chanid; - ftdm_caller_data_t *caller_data; - - spanid = ftdm_channel_get_span_id(sigmsg->channel); - chanid = ftdm_channel_get_id(sigmsg->channel); - caller_data = ftdm_channel_get_caller_data(sigmsg->channel); - - ftdm_log(FTDM_LOG_DEBUG, "got FXO sig %d:%d [%s]\n", spanid, chanid, ftdm_signal_event2str(sigmsg->event_id)); - - switch (sigmsg->event_id) { - case FTDM_SIGEVENT_PROGRESS_MEDIA: - { - if ((session = ftdm_channel_get_session(sigmsg->channel, 0))) { - channel = switch_core_session_get_channel(session); - switch_channel_mark_pre_answered(channel); - switch_core_session_rwunlock(session); - } - } - break; - case FTDM_SIGEVENT_STOP: - { - private_t *tech_pvt = NULL; - while ((session = ftdm_channel_get_session(sigmsg->channel, 0))) { - tech_pvt = switch_core_session_get_private(session); - switch_set_flag_locked(tech_pvt, TFLAG_DEAD); - ftdm_channel_clear_token(sigmsg->channel, 0); - channel = switch_core_session_get_channel(session); - switch_channel_hangup(channel, caller_data->hangup_cause); - ftdm_channel_clear_token(sigmsg->channel, switch_core_session_get_uuid(session)); - switch_core_session_rwunlock(session); - } - } - break; - case FTDM_SIGEVENT_UP: - { - if ((session = ftdm_channel_get_session(sigmsg->channel, 0))) { - channel = switch_core_session_get_channel(session); - switch_channel_mark_answered(channel); - ftdm_enable_channel_dtmf(sigmsg->channel, channel); - switch_core_session_rwunlock(session); - } - } - break; - case FTDM_SIGEVENT_START: - { - status = ftdm_channel_from_event(sigmsg, &session); - if (status != FTDM_SUCCESS) { - ftdm_channel_call_hangup(sigmsg->channel); - } - } - break; - case FTDM_SIGEVENT_COLLECTED_DIGIT: /* Analog E&M */ - { - int span_id = ftdm_channel_get_span_id(sigmsg->channel); - char *dtmf = sigmsg->ev_data.collected.digits; - char *regex = SPAN_CONFIG[span_id].dial_regex; - char *fail_regex = SPAN_CONFIG[span_id].fail_dial_regex; - ftdm_caller_data_t *caller_data = ftdm_channel_get_caller_data(sigmsg->channel); - - if (zstr(regex)) { - regex = NULL; - } - - if (zstr(fail_regex)) { - fail_regex = NULL; - } - - ftdm_log(FTDM_LOG_DEBUG, "got DTMF sig [%s]\n", dtmf); - switch_set_string(caller_data->collected, dtmf); - - if ((regex || fail_regex) && !zstr(dtmf)) { - switch_regex_t *re = NULL; - int ovector[30]; - int match = 0; - - if (fail_regex) { - match = switch_regex_perform(dtmf, fail_regex, &re, ovector, sizeof(ovector) / sizeof(ovector[0])); - status = match ? FTDM_SUCCESS : FTDM_BREAK; - switch_regex_safe_free(re); - ftdm_log(FTDM_LOG_DEBUG, "DTMF [%s] vs fail regex %s %s\n", dtmf, fail_regex, match ? "matched" : "did not match"); - } - - if (status == FTDM_SUCCESS && regex) { - match = switch_regex_perform(dtmf, regex, &re, ovector, sizeof(ovector) / sizeof(ovector[0])); - status = match ? FTDM_BREAK : FTDM_SUCCESS; - switch_regex_safe_free(re); - ftdm_log(FTDM_LOG_DEBUG, "DTMF [%s] vs dial regex %s %s\n", dtmf, regex, match ? "matched" : "did not match"); - } - ftdm_log(FTDM_LOG_DEBUG, "returning %s to COLLECT event with DTMF %s\n", status == FTDM_SUCCESS ? "success" : "break", dtmf); - } - } - break; - case FTDM_SIGEVENT_SIGSTATUS_CHANGED: - /* span signaling status changed ... nothing to do here .. */ - break; - default: - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Unhandled msg type %d for channel %d:%d\n", - sigmsg->event_id, spanid, chanid); - } - break; - } - - return status; -} - -static FIO_SIGNAL_CB_FUNCTION(on_fxs_signal) -{ - switch_core_session_t *session = NULL; - switch_channel_t *channel = NULL; - ftdm_status_t status = FTDM_SUCCESS; - uint32_t chanid, spanid, tokencount; - - chanid = ftdm_channel_get_id(sigmsg->channel); - spanid = ftdm_channel_get_span_id(sigmsg->channel); - tokencount = ftdm_channel_get_token_count(sigmsg->channel); - - ftdm_log(FTDM_LOG_DEBUG, "got FXS sig [%s]\n", ftdm_signal_event2str(sigmsg->event_id)); - - switch (sigmsg->event_id) { - case FTDM_SIGEVENT_UP: - { - if ((session = ftdm_channel_get_session(sigmsg->channel, 0))) { - channel = switch_core_session_get_channel(session); - switch_channel_mark_answered(channel); - ftdm_enable_channel_dtmf(sigmsg->channel, channel); - switch_core_session_rwunlock(session); - } - } - break; - case FTDM_SIGEVENT_PROGRESS: - { - if ((session = ftdm_channel_get_session(sigmsg->channel, 0))) { - channel = switch_core_session_get_channel(session); - switch_channel_mark_ring_ready(channel); - switch_core_session_rwunlock(session); - } - } - break; - case FTDM_SIGEVENT_START: - { - status = ftdm_channel_from_event(sigmsg, &session); - if (status != FTDM_SUCCESS) { - ftdm_channel_call_indicate(sigmsg->channel, FTDM_CHANNEL_INDICATE_BUSY); - } - } - break; - case FTDM_SIGEVENT_STOP: - { - private_t *tech_pvt = NULL; - switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING; - if (tokencount) { - ftdm_caller_data_t *caller_data = ftdm_channel_get_caller_data(sigmsg->channel); - switch_core_session_t *session_a, *session_b, *session_t = NULL; - switch_channel_t *channel_a = NULL, *channel_b = NULL; - int digits = !zstr(caller_data->collected); - const char *br_a_uuid = NULL, *br_b_uuid = NULL; - private_t *tech_pvt = NULL; - - - if ((session_a = switch_core_session_locate(ftdm_channel_get_token(sigmsg->channel, 0)))) { - channel_a = switch_core_session_get_channel(session_a); - br_a_uuid = switch_channel_get_partner_uuid(channel_a); - - tech_pvt = switch_core_session_get_private(session_a); - stop_hold(session_a, switch_channel_get_partner_uuid(channel_a)); - switch_clear_flag_locked(tech_pvt, TFLAG_HOLD); - } - - if ((session_b = switch_core_session_locate(ftdm_channel_get_token(sigmsg->channel, 1)))) { - channel_b = switch_core_session_get_channel(session_b); - br_b_uuid = switch_channel_get_partner_uuid(channel_b); - - tech_pvt = switch_core_session_get_private(session_b); - stop_hold(session_a, switch_channel_get_partner_uuid(channel_b)); - switch_clear_flag_locked(tech_pvt, TFLAG_HOLD); - } - - if (channel_a && channel_b && switch_channel_direction(channel_a) == SWITCH_CALL_DIRECTION_INBOUND && - switch_channel_direction(channel_b) == SWITCH_CALL_DIRECTION_INBOUND) { - - cause = SWITCH_CAUSE_ATTENDED_TRANSFER; - if (br_a_uuid && br_b_uuid) { - switch_ivr_uuid_bridge(br_a_uuid, br_b_uuid); - } else if (br_a_uuid && digits) { - session_t = switch_core_session_locate(br_a_uuid); - } else if (br_b_uuid && digits) { - session_t = switch_core_session_locate(br_b_uuid); - } - } - - if (session_t) { - switch_ivr_session_transfer(session_t, caller_data->collected, NULL, NULL); - switch_core_session_rwunlock(session_t); - } - - if (session_a) { - switch_core_session_rwunlock(session_a); - } - - if (session_b) { - switch_core_session_rwunlock(session_b); - } - } - - while ((session = ftdm_channel_get_session(sigmsg->channel, 0))) { - tech_pvt = switch_core_session_get_private(session); - switch_set_flag_locked(tech_pvt, TFLAG_DEAD); - channel = switch_core_session_get_channel(session); - switch_channel_hangup(channel, cause); - ftdm_channel_clear_token(sigmsg->channel, switch_core_session_get_uuid(session)); - switch_core_session_rwunlock(session); - } - ftdm_channel_clear_token(sigmsg->channel, NULL); - } - break; - case FTDM_SIGEVENT_ADD_CALL: - { - cycle_foreground(sigmsg->channel, 1, NULL); - } - break; - case FTDM_SIGEVENT_FLASH: - { - chan_pvt_t *chanpvt = ftdm_channel_get_private(sigmsg->channel); - if (!chanpvt) { - ftdm_log(FTDM_LOG_ERROR, "%d:%d has no private data, can't handle FXS features! (this is a bug)\n", - chanid, spanid); - break; - } - if (ftdm_channel_call_check_hold(sigmsg->channel) && tokencount == 1) { - switch_core_session_t *session; - if ((session = ftdm_channel_get_session(sigmsg->channel, 0))) { - const char *buuid; - switch_channel_t *channel; - private_t *tech_pvt; - - tech_pvt = switch_core_session_get_private(session); - channel = switch_core_session_get_channel(session); - buuid = switch_channel_get_partner_uuid(channel); - ftdm_channel_call_unhold(sigmsg->channel); - stop_hold(session, buuid); - switch_clear_flag_locked(tech_pvt, TFLAG_HOLD); - switch_core_session_rwunlock(session); - } - } else if (tokencount == 2 && (SPAN_CONFIG[sigmsg->span_id].analog_options & ANALOG_OPTION_3WAY)) { - if (switch_test_flag(chanpvt, ANALOG_OPTION_3WAY)) { - switch_clear_flag(chanpvt, ANALOG_OPTION_3WAY); - if ((session = ftdm_channel_get_session(sigmsg->channel, 1))) { - channel = switch_core_session_get_channel(session); - switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); - ftdm_channel_clear_token(sigmsg->channel, switch_core_session_get_uuid(session)); - switch_core_session_rwunlock(session); - } - cycle_foreground(sigmsg->channel, 1, NULL); - } else { - char *cmd; - cmd = switch_mprintf("three_way::%s", ftdm_channel_get_token(sigmsg->channel, 0)); - switch_set_flag(chanpvt, ANALOG_OPTION_3WAY); - cycle_foreground(sigmsg->channel, 1, cmd); - free(cmd); - } - } else if ((SPAN_CONFIG[sigmsg->span_id].analog_options & ANALOG_OPTION_CALL_SWAP) - || (SPAN_CONFIG[sigmsg->span_id].analog_options & ANALOG_OPTION_3WAY) - ) { - cycle_foreground(sigmsg->channel, 1, NULL); - if (tokencount == 1) { - ftdm_channel_call_hold(sigmsg->channel); - } - } - } - break; - case FTDM_SIGEVENT_COLLECTED_DIGIT: - { - int span_id = ftdm_channel_get_span_id(sigmsg->channel); - char *dtmf = sigmsg->ev_data.collected.digits; - char *regex = SPAN_CONFIG[span_id].dial_regex; - char *fail_regex = SPAN_CONFIG[span_id].fail_dial_regex; - ftdm_caller_data_t *caller_data = ftdm_channel_get_caller_data(sigmsg->channel); - - if (zstr(regex)) { - regex = NULL; - } - - if (zstr(fail_regex)) { - fail_regex = NULL; - } - - ftdm_log(FTDM_LOG_DEBUG, "got DTMF sig [%s]\n", dtmf); - switch_set_string(caller_data->collected, dtmf); - - if ((regex || fail_regex) && !zstr(dtmf)) { - switch_regex_t *re = NULL; - int ovector[30]; - int match = 0; - - if (fail_regex) { - match = switch_regex_perform(dtmf, fail_regex, &re, ovector, sizeof(ovector) / sizeof(ovector[0])); - status = match ? FTDM_SUCCESS : FTDM_BREAK; - switch_regex_safe_free(re); - ftdm_log(FTDM_LOG_DEBUG, "DTMF [%s] vs fail regex %s %s\n", dtmf, fail_regex, match ? "matched" : "did not match"); - } - - if (status == FTDM_SUCCESS && regex) { - match = switch_regex_perform(dtmf, regex, &re, ovector, sizeof(ovector) / sizeof(ovector[0])); - status = match ? FTDM_BREAK : FTDM_SUCCESS; - switch_regex_safe_free(re); - ftdm_log(FTDM_LOG_DEBUG, "DTMF [%s] vs dial regex %s %s\n", dtmf, regex, match ? "matched" : "did not match"); - } - ftdm_log(FTDM_LOG_DEBUG, "returning %s to COLLECT event with DTMF %s\n", status == FTDM_SUCCESS ? "success" : "break", dtmf); - } - } - break; - default: - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Unhandled msg type %d for channel %d:%d\n", - sigmsg->event_id, spanid, chanid); - } - break; - } - - return status; -} - -static FIO_SIGNAL_CB_FUNCTION(on_r2_signal) -{ - uint32_t phyid, chanid, spanid; - switch_core_session_t *session = NULL; - switch_channel_t *channel = NULL; - ftdm_status_t status = FTDM_SUCCESS; - ftdm_caller_data_t *caller_data = ftdm_channel_get_caller_data(sigmsg->channel); - - phyid = ftdm_channel_get_ph_id(sigmsg->channel); - chanid = ftdm_channel_get_id(sigmsg->channel); - spanid = ftdm_channel_get_span_id(sigmsg->channel); - - ftdm_log(FTDM_LOG_DEBUG, "Got R2 channel sig [%s] in channel %d\n", ftdm_signal_event2str(sigmsg->event_id), phyid); - - if (on_common_signal(sigmsg) == FTDM_BREAK) { - return FTDM_SUCCESS; - } - - switch (sigmsg->event_id) { - case FTDM_SIGEVENT_STOP: /* on_call_disconnect from the R2 side */ - { - private_t *tech_pvt = NULL; - while ((session = ftdm_channel_get_session(sigmsg->channel, 0))) { - tech_pvt = switch_core_session_get_private(session); - switch_set_flag_locked(tech_pvt, TFLAG_DEAD); - channel = switch_core_session_get_channel(session); - switch_channel_hangup(channel, caller_data->hangup_cause); - switch_core_session_rwunlock(session); - } - } - break; - case FTDM_SIGEVENT_START: /* on_call_offered from the R2 side */ - { - status = ftdm_channel_from_event(sigmsg, &session); - } - break; - case FTDM_SIGEVENT_COLLECTED_DIGIT: /* on DNIS received from the R2 forward side, return status == FTDM_BREAK to stop requesting DNIS */ - { - ftdm_caller_data_t *caller_data = ftdm_channel_get_caller_data(sigmsg->channel); - int span_id = ftdm_channel_get_span_id(sigmsg->channel); - char *regex = SPAN_CONFIG[span_id].dial_regex; - char *fail_regex = SPAN_CONFIG[span_id].fail_dial_regex; - - if (zstr(regex)) { - regex = NULL; - } - - if (zstr(fail_regex)) { - fail_regex = NULL; - } - - ftdm_log(FTDM_LOG_DEBUG, "R2 DNIS so far [%s]\n", caller_data->dnis.digits); - - if ((regex || fail_regex) && !zstr(caller_data->dnis.digits)) { - switch_regex_t *re = NULL; - int ovector[30]; - int match = 0; - - if (fail_regex) { - match = switch_regex_perform(caller_data->dnis.digits, fail_regex, &re, ovector, sizeof(ovector) / sizeof(ovector[0])); - status = match ? FTDM_SUCCESS : FTDM_BREAK; - switch_regex_safe_free(re); - } - - if (status == FTDM_SUCCESS && regex) { - match = switch_regex_perform(caller_data->dnis.digits, regex, &re, ovector, sizeof(ovector) / sizeof(ovector[0])); - status = match ? FTDM_BREAK : FTDM_SUCCESS; - } - - switch_regex_safe_free(re); - } - } - break; - case FTDM_SIGEVENT_PROGRESS: - { - if ((session = ftdm_channel_get_session(sigmsg->channel, 0))) { - channel = switch_core_session_get_channel(session); - switch_channel_mark_ring_ready(channel); - switch_core_session_rwunlock(session); - } - } - break; - case FTDM_SIGEVENT_PROGRESS_MEDIA: - { - if ((session = ftdm_channel_get_session(sigmsg->channel, 0))) { - channel = switch_core_session_get_channel(session); - switch_channel_mark_pre_answered(channel); - switch_core_session_rwunlock(session); - } - } - break; - case FTDM_SIGEVENT_UP: - { - if ((session = ftdm_channel_get_session(sigmsg->channel, 0))) { - channel = switch_core_session_get_channel(session); - switch_channel_mark_answered(channel); - ftdm_enable_channel_dtmf(sigmsg->channel, channel); - switch_core_session_rwunlock(session); - } - } - break; - case FTDM_SIGEVENT_SIGSTATUS_CHANGED: - { - ftdm_signaling_status_t sigstatus = sigmsg->ev_data.sigstatus.status; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%d:%d signalling changed to: %s\n", - spanid, chanid, ftdm_signaling_status2str(sigstatus)); - } - break; - case FTDM_SIGEVENT_PROCEED: - case FTDM_SIGEVENT_INDICATION_COMPLETED: - break; - default: - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Unhandled event %d from R2 for channel %d:%d\n", - sigmsg->event_id, spanid, chanid); - } - break; - } - - return status; -} - -static FIO_SIGNAL_CB_FUNCTION(on_clear_channel_signal) -{ - switch_core_session_t *session = NULL; - switch_channel_t *channel = NULL; - ftdm_caller_data_t *caller_data; - uint32_t spanid, chanid; - - ftdm_log(FTDM_LOG_DEBUG, "got clear channel sig [%s]\n", ftdm_signal_event2str(sigmsg->event_id)); - - caller_data = ftdm_channel_get_caller_data(sigmsg->channel); - chanid = ftdm_channel_get_id(sigmsg->channel); - spanid = ftdm_channel_get_span_id(sigmsg->channel); - - if (on_common_signal(sigmsg) == FTDM_BREAK) { - return FTDM_SUCCESS; - } - - switch (sigmsg->event_id) { - case FTDM_SIGEVENT_START: - { - return ftdm_channel_from_event(sigmsg, &session); - } - break; - case FTDM_SIGEVENT_STOP: - case FTDM_SIGEVENT_RESTART: - { - private_t *tech_pvt = NULL; - while ((session = ftdm_channel_get_session(sigmsg->channel, 0))) { - tech_pvt = switch_core_session_get_private(session); - switch_set_flag_locked(tech_pvt, TFLAG_DEAD); - channel = switch_core_session_get_channel(session); - switch_channel_hangup(channel, caller_data->hangup_cause); - switch_core_session_rwunlock(session); - } - } - break; - case FTDM_SIGEVENT_UP: - { - if ((session = ftdm_channel_get_session(sigmsg->channel, 0))) { - channel = switch_core_session_get_channel(session); - switch_channel_mark_answered(channel); - ftdm_enable_channel_dtmf(sigmsg->channel, channel); - switch_core_session_rwunlock(session); - } else { - const char *uuid = ftdm_channel_get_uuid(sigmsg->channel, 0); - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session for channel %d:%d not found [UUID: %s]\n", - spanid, chanid, (uuid) ? uuid : "N/A"); - } - } - break; - case FTDM_SIGEVENT_PROGRESS_MEDIA: - { - if ((session = ftdm_channel_get_session(sigmsg->channel, 0))) { - channel = switch_core_session_get_channel(session); - switch_channel_mark_pre_answered(channel); - switch_core_session_rwunlock(session); - } else { - const char *uuid = ftdm_channel_get_uuid(sigmsg->channel, 0); - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session for channel %d:%d not found [UUID: %s]\n", - spanid, chanid, (uuid) ? uuid : "N/A"); - } - } - break; - case FTDM_SIGEVENT_PROGRESS: - case FTDM_SIGEVENT_RINGING: - { - if ((session = ftdm_channel_get_session(sigmsg->channel, 0))) { - channel = switch_core_session_get_channel(session); - switch_channel_mark_ring_ready(channel); - switch_core_session_rwunlock(session); - } else { - const char *uuid = ftdm_channel_get_uuid(sigmsg->channel, 0); - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session for channel %d:%d not found [UUID: %s]\n", - spanid, chanid, (uuid) ? uuid : "N/A"); - } - } - break; - case FTDM_SIGEVENT_SIGSTATUS_CHANGED: - { - ftdm_signaling_status_t sigstatus = sigmsg->ev_data.sigstatus.status; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%d:%d signalling changed to :%s\n", - spanid, chanid, ftdm_signaling_status2str(sigstatus)); - } - break; - case FTDM_SIGEVENT_PROCEED: - case FTDM_SIGEVENT_FACILITY: - case FTDM_SIGEVENT_TRANSFER_COMPLETED: - /* FS does not have handlers for these messages, so ignore them for now */ - break; - default: - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Unhandled msg type %d for channel %d:%d\n", - sigmsg->event_id, spanid, chanid); - } - break; - } - - return FTDM_SUCCESS; -} - -static FIO_SIGNAL_CB_FUNCTION(on_analog_signal) -{ - uint32_t spanid, chanid; - ftdm_chan_type_t type; - ftdm_status_t status = FTDM_FAIL; - - spanid = ftdm_channel_get_span_id(sigmsg->channel); - chanid = ftdm_channel_get_span_id(sigmsg->channel); - type = ftdm_channel_get_type(sigmsg->channel); - - if (on_common_signal(sigmsg) == FTDM_BREAK) { - return FTDM_SUCCESS; - } - - switch (type) { - case FTDM_CHAN_TYPE_FXO: - case FTDM_CHAN_TYPE_EM: - { - status = on_fxo_signal(sigmsg); - } - break; - case FTDM_CHAN_TYPE_FXS: - { - status = on_fxs_signal(sigmsg); - } - break; - default: - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Unhandled analog channel type %d for channel %d:%d\n", - type, spanid, chanid); - } - break; - } - - return status; -} - -static void ftdm_logger(const char *file, const char *func, int line, int level, const char *fmt, ...) -{ - char *data = NULL; - va_list ap; - - va_start(ap, fmt); - - if (switch_vasprintf(&data, fmt, ap) != -1) { - switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, (char *)func, line, NULL, level, "%s", data); - } - if (data) { - free(data); - } - - va_end(ap); -} - -static uint32_t enable_analog_option(const char *str, uint32_t current_options) -{ - if (!strcasecmp(str, "3-way")) { - current_options |= ANALOG_OPTION_3WAY; - current_options &= ~ANALOG_OPTION_CALL_SWAP; - } else if (!strcasecmp(str, "call-swap")) { - current_options |= ANALOG_OPTION_CALL_SWAP; - current_options &= ~ANALOG_OPTION_3WAY; - } - - return current_options; -} - -#define LOAD_ERROR(...) { \ - ftdm_log(FTDM_LOG_ERROR, __VA_ARGS__); \ - globals.config_error = 1; \ - } - -/* - * Create ftdm_conf_node_t tree based on a fixed pattern XML configuration list. - * Last 2 args are for limited aka dumb recursivity. - */ -static int add_config_list_nodes(switch_xml_t swnode, ftdm_conf_node_t *rootnode, - const char *list_name, const char *list_element_name, - const char *sub_list_name, const char *sub_list_element_name) -{ - char *var, *val; - switch_xml_t list; - switch_xml_t element; - switch_xml_t param; - - ftdm_conf_node_t *n_list; - ftdm_conf_node_t *n_element; - - list = switch_xml_child(swnode, list_name); - if (!list) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "no list %s found\n", list_name); - return -1; - } - - if ((FTDM_SUCCESS != ftdm_conf_node_create(list_name, &n_list, rootnode))) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed to create %s node\n", list_name); - return -1; - } - - for (element = switch_xml_child(list, list_element_name); element; element = element->next) { - char *element_name = (char *) switch_xml_attr(element, "name"); - - if (!element_name) { - continue; - } - - if ((FTDM_SUCCESS != ftdm_conf_node_create(list_element_name, &n_element, n_list))) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed to create %s node for %s\n", list_element_name, element_name); - return -1; - } - ftdm_conf_node_add_param(n_element, "name", element_name); - - for (param = switch_xml_child(element, "param"); param; param = param->next) { - var = (char *) switch_xml_attr_soft(param, "name"); - val = (char *) switch_xml_attr_soft(param, "value"); - ftdm_conf_node_add_param(n_element, var, val); - } - - if (sub_list_name && sub_list_element_name) { - if (add_config_list_nodes(element, n_element, sub_list_name, sub_list_element_name, NULL, NULL)) { - return -1; - } - } - } - - return 0; -} - -/* - * Create ftdm_conf_node_t tree based on a fixed pattern XML configuration list. - * Last arg is to specify if we have any sublist for e.g.: - * - * - * - * - * - * - * - * - * - */ -static int add_config_nodes(switch_xml_t swnode, ftdm_conf_node_t *rootnode, - const char *list_name, const char *list_element_name, const char *sub_list_name) -{ - char *var, *val; - switch_xml_t list; - switch_xml_t sub_list; - switch_xml_t element; - switch_xml_t param; - - ftdm_conf_node_t *n_list; - ftdm_conf_node_t *n_element; - - list = switch_xml_child(swnode, list_name); - if (!list) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "no list %s found\n", list_name); - return -1; - } - - if ((FTDM_SUCCESS != ftdm_conf_node_create(list_name, &n_list, rootnode))) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed to create %s node\n", list_name); - return -1; - } - - for (element = switch_xml_child(list, list_element_name); element; element = element->next) { - char *element_name = (char *) switch_xml_attr(element, "name"); - - if (!element_name) { - continue; - } - - if ((FTDM_SUCCESS != ftdm_conf_node_create(list_element_name, &n_element, n_list))) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed to create %s node for %s\n", list_element_name, element_name); - return -1; - } - ftdm_conf_node_add_param(n_element, "name", element_name); - - for (param = switch_xml_child(element, "param"); param; param = param->next) { - var = (char *) switch_xml_attr_soft(param, "name"); - val = (char *) switch_xml_attr_soft(param, "value"); - ftdm_conf_node_add_param(n_element, var, val); - } - - /*If we have single node list */ - if (sub_list_name ) { - sub_list = switch_xml_child(element, sub_list_name); - if (!sub_list) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "no sub_list %s found\n", sub_list_name); - return -1; - } - for (param = switch_xml_child(sub_list, "param"); param; param = param->next) { - var = (char *) switch_xml_attr_soft(param, "name"); - val = (char *) switch_xml_attr_soft(param, "value"); - ftdm_conf_node_add_param(n_element, var, val); - } - } - } - - return 0; -} - -static ftdm_conf_node_t *_get_ss7_config_node(switch_xml_t cfg, const char *confname, const char *operating_mode) -{ - switch_xml_t signode, ss7configs, isup, gen, param; - ftdm_conf_node_t *rootnode, *list; - char *var, *val; - int is_isup = 0x00; - - /* try to find the conf in the hash first */ - rootnode = switch_core_hash_find(globals.ss7_configs, confname); - if (rootnode) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "ss7 config %s was found in the hash already\n", confname); - return rootnode; - } - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "not found %s config in hash, searching in xml ...\n", confname); - - signode = switch_xml_child(cfg, "signaling_configs"); - if (!signode) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "not found 'signaling_configs' XML config section\n"); - return NULL; - } - - ss7configs = switch_xml_child(signode, "sngss7_configs"); - if (!ss7configs) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "not found 'sngss7_configs' XML config section\n"); - return NULL; - } - - /* sng_isup and ss7config xml childs are treated the same way. sng_isup was used initially, but does not make sense - * for configurations that do not have an ISUP layer, sng_isup is kept for backward compatibility */ - - /* search the ss7config */ - for (isup = switch_xml_child(ss7configs, "sngss7_config"); isup; isup = isup->next) { - char *name = (char *) switch_xml_attr(isup, "name"); - if (!name) { - continue; - } - if (!strcasecmp(name, confname)) { - break; - } - } - - if (!isup) { - /* search the isup config */ - for (isup = switch_xml_child(ss7configs, "sng_isup"); isup; isup = isup->next) { - char *name = (char *) switch_xml_attr(isup, "name"); - if (!name) { - continue; - } - if (!strcasecmp(name, confname)) { - break; - } - } - - if (!isup) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "not found '%s' ss7config or sng_isup XML config section\n", confname); - return NULL; - } - } - - /* found our XML chunk, create the root node */ - if ((FTDM_SUCCESS != ftdm_conf_node_create("sng_isup", &rootnode, NULL))) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed to create root node for sng_isup config %s\n", confname); - return NULL; - } - - /* operating mode , M2UA or ISUP */ - if (operating_mode && ('\0' != operating_mode[0])) { - if (!strcasecmp(operating_mode, "ISUP")) { - is_isup = 0x01; - } - else if (!strcasecmp(operating_mode, "M2UA_SG")) { - is_isup = 0x00; - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid operating Mode[%s] \n", operating_mode); - ftdm_conf_node_destroy(rootnode); - return NULL; - } - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Operating mode not specified, default to ISUP \n"); - is_isup = 0x01; - } - - /* add sng_gen */ - gen = switch_xml_child(isup, "sng_gen"); - if (gen == NULL) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed to process sng_gen for sng_isup config %s\n", confname); - ftdm_conf_node_destroy(rootnode); - return NULL; - } - - if ((FTDM_SUCCESS != ftdm_conf_node_create("sng_gen", &list, rootnode))) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed to create %s node for %s\n", "sng_gen", confname); - ftdm_conf_node_destroy(rootnode); - return NULL; - } - - for (param = switch_xml_child(gen, "param"); param; param = param->next) { - var = (char *) switch_xml_attr_soft(param, "name"); - val = (char *) switch_xml_attr_soft(param, "value"); - ftdm_conf_node_add_param(list, var, val); - } - - /* add relay channels */ - if (add_config_list_nodes(isup, rootnode, "sng_relay", "relay_channel", NULL, NULL)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed to process sng_relay for sng_isup config %s\n", confname); - ftdm_conf_node_destroy(rootnode); - return NULL; - } - - /* add mtp1 links */ - if (add_config_list_nodes(isup, rootnode, "mtp1_links", "mtp1_link", NULL, NULL)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed to process mtp1_links for sng_isup config %s\n", confname); - ftdm_conf_node_destroy(rootnode); - return NULL; - } - - /* add mtp2 links */ - if (add_config_list_nodes(isup, rootnode, "mtp2_links", "mtp2_link", NULL, NULL)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed to process mtp2_links for sng_isup config %s\n", confname); - ftdm_conf_node_destroy(rootnode); - return NULL; - } - - if (is_isup) { - /* add mtp3 links */ - if (add_config_list_nodes(isup, rootnode, "mtp3_links", "mtp3_link", NULL, NULL)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed to process mtp3_links for sng_isup config %s\n", confname); - ftdm_conf_node_destroy(rootnode); - return NULL; - } - - /* add mtp linksets */ - if (add_config_list_nodes(isup, rootnode, "mtp_linksets", "mtp_linkset", NULL, NULL)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed to process mtp_linksets for sng_isup config %s\n", confname); - ftdm_conf_node_destroy(rootnode); - return NULL; - } - - /* add mtp routes */ - if (add_config_list_nodes(isup, rootnode, "mtp_routes", "mtp_route", "linksets", "linkset")) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed to process mtp_routes for sng_isup config %s\n", confname); - ftdm_conf_node_destroy(rootnode); - return NULL; - } - - /* add isup interfaces */ - if (add_config_list_nodes(isup, rootnode, "isup_interfaces", "isup_interface", NULL, NULL)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed to process isup_interfaces for sng_isup config %s\n", confname); - ftdm_conf_node_destroy(rootnode); - return NULL; - } - - /* add cc spans */ - if (add_config_list_nodes(isup, rootnode, "cc_spans", "cc_span", NULL, NULL)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed to process cc_spans for sng_isup config %s\n", confname); - ftdm_conf_node_destroy(rootnode); - return NULL; - } - } else { - /* add sctp links */ - if (add_config_nodes(isup, rootnode, "sng_sctp_interfaces", "sng_sctp_interface", "sng_source_addresses")) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed to process sng_sctp_interface for sng_isup config %s\n", confname); - ftdm_conf_node_destroy(rootnode); - return NULL; - } - - if (add_config_list_nodes(isup, rootnode, "sng_nif_interfaces", "sng_nif_interface", NULL, NULL)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed to process sng_nif_interfaces for sng_isup config %s\n", confname); - ftdm_conf_node_destroy(rootnode); - return NULL; - } - - if (add_config_list_nodes(isup, rootnode, "sng_m2ua_interfaces", "sng_m2ua_interface", NULL, NULL)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed to process sng_m2ua_interfaces for sng_isup config %s\n", confname); - ftdm_conf_node_destroy(rootnode); - return NULL; - } - - if (add_config_nodes(isup, rootnode, "sng_m2ua_peer_interfaces", "sng_m2ua_peer_interface", "sng_destination_addresses")) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed to process sng_m2ua_peer_interfaces for sng_isup config %s\n", confname); - ftdm_conf_node_destroy(rootnode); - return NULL; - } - - if (add_config_nodes(isup, rootnode, "sng_m2ua_cluster_interfaces", "sng_m2ua_cluster_interface", "sng_m2ua_peers")) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed to process sng_m2ua_cluster_interfaces for sng_isup config %s\n", confname); - ftdm_conf_node_destroy(rootnode); - return NULL; - } - } - - switch_core_hash_insert(globals.ss7_configs, confname, rootnode); - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Added SS7 node configuration %s\n", confname); - return rootnode; -} - -static int add_profile_parameters(switch_xml_t cfg, const char *profname, ftdm_conf_parameter_t *parameters, int len) -{ - switch_xml_t profnode, profile, param; - int paramindex = 0; - - profnode = switch_xml_child(cfg, "config_profiles"); - if (!profnode) { - LOAD_ERROR("cannot find profile '%s', there is no 'config_profiles' XML section\n", profname); - return 0; - } - - /* search the profile */ - for (profile = switch_xml_child(profnode, "profile"); profile; profile = profile->next) { - char *name = (char *) switch_xml_attr(profile, "name"); - if (!name) { - continue; - } - if (!strcasecmp(name, profname)) { - break; - } - } - - if (!profile) { - LOAD_ERROR("failed to find profile '%s'\n", profname); - return 0; - } - - for (param = switch_xml_child(profile, "param"); param; param = param->next) { - char *var = (char *) switch_xml_attr_soft(param, "name"); - char *val = (char *) switch_xml_attr_soft(param, "value"); - if (!var || !val) { - continue; - } - parameters[paramindex].var = var; - parameters[paramindex].val = val; - paramindex++; - } - - return paramindex; -} - -static void parse_gsm_spans(switch_xml_t cfg, switch_xml_t spans) -{ - switch_xml_t myspan, param; - - for (myspan = switch_xml_child(spans, "span"); myspan; myspan = myspan->next) { - ftdm_status_t zstatus = FTDM_FAIL; - const char *context = "default"; - const char *dialplan = "XML"; - ftdm_conf_parameter_t spanparameters[FTDM_MAX_SIG_PARAMETERS]; - char *id = (char *) switch_xml_attr(myspan, "id"); - char *name = (char *) switch_xml_attr(myspan, "name"); - char *configname = (char *) switch_xml_attr(myspan, "cfgprofile"); - ftdm_span_t *span = NULL; - uint32_t span_id = 0; - unsigned paramindex = 0; - - if (!name && !id) { - LOAD_ERROR("GSM span missing required attribute 'id' or 'name', skipping ...\n"); - continue; - } - - if (name) { - zstatus = ftdm_span_find_by_name(name, &span); - } else { - if (switch_is_number(id)) { - span_id = atoi(id); - zstatus = ftdm_span_find(span_id, &span); - } - - if (zstatus != FTDM_SUCCESS) { - zstatus = ftdm_span_find_by_name(id, &span); - } - } - - if (zstatus != FTDM_SUCCESS) { - LOAD_ERROR("Error finding FreeTDM span id:%s name:%s\n", switch_str_nil(id), switch_str_nil(name)); - continue; - } - - if (!span_id) { - span_id = ftdm_span_get_id(span); - } - - memset(spanparameters, 0, sizeof(spanparameters)); - paramindex = 0; - - if (configname) { - paramindex = add_profile_parameters(cfg, configname, spanparameters, ftdm_array_len(spanparameters)); - if (paramindex) { - ftdm_log(FTDM_LOG_DEBUG, "Added %d parameters from profile %s for span %d\n", paramindex, configname, span_id); - } - } - - for (param = switch_xml_child(myspan, "param"); param; param = param->next) { - char *var = (char *) switch_xml_attr_soft(param, "name"); - char *val = (char *) switch_xml_attr_soft(param, "value"); - - if (ftdm_array_len(spanparameters) - 1 == paramindex) { - LOAD_ERROR("Too many parameters for GSM span, ignoring any parameter after %s\n", var); - break; - } - - if (!strcasecmp(var, "context")) { - context = val; - } else if (!strcasecmp(var, "dialplan")) { - dialplan = val; - } else { - spanparameters[paramindex].var = var; - spanparameters[paramindex].val = val; - paramindex++; - } - } - - if (ftdm_configure_span_signaling(span, - "gsm", - on_clear_channel_signal, - spanparameters) != FTDM_SUCCESS) { - LOAD_ERROR("Error configuring Sangoma GSM FreeTDM span %d\n", span_id); - continue; - } - - SPAN_CONFIG[span_id].span = span; - switch_copy_string(SPAN_CONFIG[span_id].context, context, sizeof(SPAN_CONFIG[span_id].context)); - switch_copy_string(SPAN_CONFIG[span_id].dialplan, dialplan, sizeof(SPAN_CONFIG[span_id].dialplan)); - switch_copy_string(SPAN_CONFIG[span_id].type, "GSM", sizeof(SPAN_CONFIG[span_id].type)); - - ftdm_log(FTDM_LOG_DEBUG, "Configured GSM FreeTDM span %d\n", span_id); - ftdm_span_start(span); - } -} - -static void parse_bri_pri_spans(switch_xml_t cfg, switch_xml_t spans) -{ - switch_xml_t myspan, param; - - for (myspan = switch_xml_child(spans, "span"); myspan; myspan = myspan->next) { - ftdm_status_t zstatus = FTDM_FAIL; - const char *context = "default"; - const char *dialplan = "XML"; - ftdm_conf_parameter_t spanparameters[FTDM_MAX_SIG_PARAMETERS]; - char *id = (char *) switch_xml_attr(myspan, "id"); - char *name = (char *) switch_xml_attr(myspan, "name"); - char *configname = (char *) switch_xml_attr(myspan, "cfgprofile"); - ftdm_span_t *span = NULL; - uint32_t span_id = 0; - unsigned paramindex = 0; - - if (!name && !id) { - LOAD_ERROR("sangoma isdn span missing required attribute 'id' or 'name', skipping ...\n"); - continue; - } - - if (name) { - zstatus = ftdm_span_find_by_name(name, &span); - } else { - if (switch_is_number(id)) { - span_id = atoi(id); - zstatus = ftdm_span_find(span_id, &span); - } - - if (zstatus != FTDM_SUCCESS) { - zstatus = ftdm_span_find_by_name(id, &span); - } - } - - if (zstatus != FTDM_SUCCESS) { - LOAD_ERROR("Error finding FreeTDM span id:%s name:%s\n", switch_str_nil(id), switch_str_nil(name)); - continue; - } - - if (!span_id) { - span_id = ftdm_span_get_id(span); - } - - memset(spanparameters, 0, sizeof(spanparameters)); - paramindex = 0; - - if (configname) { - paramindex = add_profile_parameters(cfg, configname, spanparameters, ftdm_array_len(spanparameters)); - if (paramindex) { - ftdm_log(FTDM_LOG_DEBUG, "Added %d parameters from profile %s for span %d\n", paramindex, configname, span_id); - } - } - - /* some defaults first */ - SPAN_CONFIG[span_id].limit_backend = "hash"; - SPAN_CONFIG[span_id].limit_reset_event = FTDM_LIMIT_RESET_ON_TIMEOUT; - SPAN_CONFIG[span_id].digital_sampling_rate = 8000; - - for (param = switch_xml_child(myspan, "param"); param; param = param->next) { - char *var = (char *) switch_xml_attr_soft(param, "name"); - char *val = (char *) switch_xml_attr_soft(param, "value"); - - if (ftdm_array_len(spanparameters) - 1 == paramindex) { - LOAD_ERROR("Too many parameters for ss7 span, ignoring any parameter after %s\n", var); - break; - } - - if (!strcasecmp(var, "context")) { - context = val; - } else if (!strcasecmp(var, "dialplan")) { - dialplan = val; - } else if (!strcasecmp(var, "unrestricted-digital-codec")) { - //switch_core_strdup(pool, val); - const switch_codec_implementation_t *codec = NULL; - int num_codecs; - num_codecs = switch_loadable_module_get_codecs_sorted(&codec, NULL, 1, &val, 1); - if (num_codecs != 1 || !codec) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, - "Failed finding codec %s for unrestricted digital calls\n", val); - } else { - SPAN_CONFIG[span_id].digital_codec = switch_core_strdup(module_pool, codec->iananame); - SPAN_CONFIG[span_id].digital_sampling_rate = codec->samples_per_second; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, - "Unrestricted digital codec is %s at %dhz for span %d\n", - SPAN_CONFIG[span_id].digital_codec, SPAN_CONFIG[span_id].digital_sampling_rate, span_id); - } - } else if (!strcasecmp(var, "call_limit_backend")) { - SPAN_CONFIG[span_id].limit_backend = val; - ftdm_log(FTDM_LOG_DEBUG, "Using limit backend %s for span %d\n", SPAN_CONFIG[span_id].limit_backend, span_id); - } else if (!strcasecmp(var, "call_limit_rate")) { - int calls; - int seconds; - if (sscanf(val, "%d/%d", &calls, &seconds) != 2) { - LOAD_ERROR("Invalid %s parameter, format example: 3/1 for 3 calls per second\n", var); - } else { - if (calls < 1 || seconds < 1) { - LOAD_ERROR("Invalid %s parameter value, minimum call limit must be 1 per second\n", var); - } else { - SPAN_CONFIG[span_id].limit_calls = calls; - SPAN_CONFIG[span_id].limit_seconds = seconds; - } - } - } else if (!strcasecmp(var, "call_limit_reset_event")) { - if (!strcasecmp(val, "answer")) { - SPAN_CONFIG[span_id].limit_reset_event = FTDM_LIMIT_RESET_ON_ANSWER; - } else { - LOAD_ERROR("Invalid %s parameter value, only accepted event is 'answer'\n", var); - } - } else { - spanparameters[paramindex].var = var; - spanparameters[paramindex].val = val; - paramindex++; - } - } - - if (ftdm_configure_span_signaling(span, - "sangoma_isdn", - on_clear_channel_signal, - spanparameters) != FTDM_SUCCESS) { - LOAD_ERROR("Error configuring Sangoma ISDN FreeTDM span %d\n", span_id); - continue; - } - - SPAN_CONFIG[span_id].span = span; - switch_copy_string(SPAN_CONFIG[span_id].context, context, sizeof(SPAN_CONFIG[span_id].context)); - switch_copy_string(SPAN_CONFIG[span_id].dialplan, dialplan, sizeof(SPAN_CONFIG[span_id].dialplan)); - switch_copy_string(SPAN_CONFIG[span_id].type, "Sangoma (ISDN)", sizeof(SPAN_CONFIG[span_id].type)); - - ftdm_log(FTDM_LOG_DEBUG, "Configured Sangoma ISDN FreeTDM span %d\n", span_id); - ftdm_span_start(span); - } -} -static switch_status_t load_config_path(void) -{ - const char *cf = "freetdm.conf"; - switch_xml_t cfg, xml, settings, param; - if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf); - return SWITCH_STATUS_TERM; - } - - if ((settings = switch_xml_child(cfg, "settings"))) { - for (param = switch_xml_child(settings, "param"); param; param = param->next) { - char *var = (char *) switch_xml_attr_soft(param, "name"); - char *val = (char *) switch_xml_attr_soft(param, "value"); - - if (!strcasecmp(var, "mod-dir")) { - ftdm_global_set_mod_directory(val); - } else if (!strcasecmp(var, "conf-dir")) { - ftdm_global_set_config_directory(val); - } - } - } - - switch_xml_free(xml); - - return SWITCH_STATUS_SUCCESS; -} - -static switch_status_t load_config(void) -{ - const char *cf = "freetdm.conf"; - switch_xml_t cfg, xml, settings, param, spans, myspan; - ftdm_conf_node_t *ss7confnode = NULL; - unsigned int i = 0; - ftdm_channel_t *fchan = NULL; - ftdm_iterator_t *chaniter = NULL; - ftdm_iterator_t *curr = NULL; - - memset(&globals, 0, sizeof(globals)); - switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, module_pool); - - if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf); - return SWITCH_STATUS_TERM; - } - - if ((settings = switch_xml_child(cfg, "settings"))) { - for (param = switch_xml_child(settings, "param"); param; param = param->next) { - char *var = (char *) switch_xml_attr_soft(param, "name"); - char *val = (char *) switch_xml_attr_soft(param, "value"); - - if (!strcasecmp(var, "debug")) { - globals.debug = atoi(val); - } else if (!strcasecmp(var, "hold-music")) { - switch_set_string(globals.hold_music, val); - } else if (!strcasecmp(var, "crash-on-assert")) { - globals.crash_on_assert = (uint8_t)switch_true(val); - } else if (!strcasecmp(var, "fail-on-error")) { - globals.fail_on_error = (uint8_t)switch_true(val); - } else if (!strcasecmp(var, "sip-headers")) { - globals.sip_headers = switch_true(val); - } else if (!strcasecmp(var, "enable-analog-option")) { - globals.analog_options = enable_analog_option(val, globals.analog_options); - } - } - } - - if ((spans = switch_xml_child(cfg, "sangoma_pri_spans"))) { - parse_bri_pri_spans(cfg, spans); - } - - if ((spans = switch_xml_child(cfg, "sangoma_bri_spans"))) { - parse_bri_pri_spans(cfg, spans); - } - - if ((spans = switch_xml_child(cfg, "gsm_spans"))) { - parse_gsm_spans(cfg, spans); - } - - switch_core_hash_init(&globals.ss7_configs); - if ((spans = switch_xml_child(cfg, "sangoma_ss7_spans"))) { - for (myspan = switch_xml_child(spans, "span"); myspan; myspan = myspan->next) { - ftdm_status_t zstatus = FTDM_FAIL; - const char *context = "default"; - const char *dialplan = "XML"; - ftdm_conf_parameter_t spanparameters[FTDM_MAX_SIG_PARAMETERS]; - char *id = (char *) switch_xml_attr(myspan, "id"); - char *name = (char *) switch_xml_attr(myspan, "name"); - char *configname = (char *) switch_xml_attr(myspan, "cfgprofile"); - char *operating_mode = (char *) switch_xml_attr(myspan, "operating_mode"); - ftdm_span_t *span = NULL; - uint32_t span_id = 0; - unsigned paramindex = 0; - if (!name && !id) { - LOAD_ERROR("ss7 span missing required attribute 'id' or 'name', skipping ...\n"); - continue; - } - if (!configname) { - LOAD_ERROR("ss7 span missing required attribute, skipping ...\n"); - continue; - } - if (name) { - zstatus = ftdm_span_find_by_name(name, &span); - } else { - if (switch_is_number(id)) { - span_id = atoi(id); - zstatus = ftdm_span_find(span_id, &span); - } - - if (zstatus != FTDM_SUCCESS) { - zstatus = ftdm_span_find_by_name(id, &span); - } - } - - if (zstatus != FTDM_SUCCESS) { - LOAD_ERROR("Error finding FreeTDM span id:%s name:%s\n", switch_str_nil(id), switch_str_nil(name)); - continue; - } - - if (!span_id) { - span_id = ftdm_span_get_id(span); - } - - ss7confnode = _get_ss7_config_node(cfg, configname, operating_mode); - if (!ss7confnode) { - LOAD_ERROR("Error finding ss7config '%s' for FreeTDM span id: %s\n", configname, switch_str_nil(id)); - continue; - } - - memset(spanparameters, 0, sizeof(spanparameters)); - paramindex = 0; - - if (operating_mode) { - spanparameters[paramindex].var = "operating-mode"; - spanparameters[paramindex].val = operating_mode; - paramindex++; - } - - spanparameters[paramindex].var = "confnode"; - spanparameters[paramindex].ptr = ss7confnode; - paramindex++; - - for (param = switch_xml_child(myspan, "param"); param; param = param->next) { - char *var = (char *) switch_xml_attr_soft(param, "name"); - char *val = (char *) switch_xml_attr_soft(param, "value"); - - if (ftdm_array_len(spanparameters) - 1 == paramindex) { - LOAD_ERROR("Too many parameters for ss7 span, ignoring any parameter after %s\n", var); - break; - } - - if (!strcasecmp(var, "context")) { - context = val; - } else if (!strcasecmp(var, "dialplan")) { - dialplan = val; - } else { - spanparameters[paramindex].var = var; - spanparameters[paramindex].val = val; - paramindex++; - } - } - - if (ftdm_configure_span_signaling(span, - "sangoma_ss7", - on_clear_channel_signal, - spanparameters) != FTDM_SUCCESS) { - LOAD_ERROR("Error configuring ss7 FreeTDM span %d\n", span_id); - continue; - } - - SPAN_CONFIG[span_id].span = span; - - switch_copy_string(SPAN_CONFIG[span_id].context, context, sizeof(SPAN_CONFIG[span_id].context)); - switch_copy_string(SPAN_CONFIG[span_id].dialplan, dialplan, sizeof(SPAN_CONFIG[span_id].dialplan)); - switch_copy_string(SPAN_CONFIG[span_id].type, "Sangoma (SS7)", sizeof(SPAN_CONFIG[span_id].type)); - - ftdm_log(FTDM_LOG_DEBUG, "Configured ss7 FreeTDM span %d with config node %s\n", span_id, configname); - - if (FTDM_SUCCESS != ftdm_span_start(span)) { - LOAD_ERROR("Error Starting ss7 FreeTDM span %d\n", span_id); - continue; - } - } - } - - if ((spans = switch_xml_child(cfg, "analog_spans"))) { - for (myspan = switch_xml_child(spans, "span"); myspan; myspan = myspan->next) { - char *id = (char *) switch_xml_attr(myspan, "id"); - char *name = (char *) switch_xml_attr(myspan, "name"); - ftdm_status_t zstatus = FTDM_FAIL; - const char *context = "default"; - const char *dialplan = "XML"; - const char *tonegroup = NULL; - char *digit_timeout = NULL; - char *max_digits = NULL; - char *hotline = NULL; - char *dial_regex = NULL; - char *hold_music = NULL; - char *fail_dial_regex = NULL; - const char *enable_callerid = "true"; - const char *answer_polarity = "false"; - const char *hangup_polarity = "false"; - const char *polarity_callerid = "false"; - int polarity_delay = 600; - int callwaiting = 1; - int dialtone_timeout = 5000; - - uint32_t span_id = 0, to = 0, max = 0; - ftdm_span_t *span = NULL; - analog_option_t analog_options = ANALOG_OPTION_NONE; - - if (name) { - zstatus = ftdm_span_find_by_name(name, &span); - } else { - if (switch_is_number(id)) { - span_id = atoi(id); - zstatus = ftdm_span_find(span_id, &span); - } - - if (zstatus != FTDM_SUCCESS) { - zstatus = ftdm_span_find_by_name(id, &span); - } - } - - if (zstatus != FTDM_SUCCESS) { - LOAD_ERROR("Error finding FreeTDM span id:%s name:%s\n", switch_str_nil(id), switch_str_nil(name)); - continue; - } - - if (!span_id) { - span_id = ftdm_span_get_id(span); - } - - /* some defaults first */ - SPAN_CONFIG[span_id].limit_backend = "hash"; - SPAN_CONFIG[span_id].limit_reset_event = FTDM_LIMIT_RESET_ON_TIMEOUT; - - for (param = switch_xml_child(myspan, "param"); param; param = param->next) { - char *var = (char *) switch_xml_attr_soft(param, "name"); - char *val = (char *) switch_xml_attr_soft(param, "value"); - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "analog_spans var = %s\n", var); - if (!strcasecmp(var, "tonegroup")) { - tonegroup = val; - } else if (!strcasecmp(var, "digit_timeout") || !strcasecmp(var, "digit-timeout")) { - digit_timeout = val; - } else if (!strcasecmp(var, "wait-dialtone-timeout")) { - dialtone_timeout = atoi(val); - } else if (!strcasecmp(var, "context")) { - context = val; - } else if (!strcasecmp(var, "dialplan")) { - dialplan = val; - } else if (!strcasecmp(var, "call_limit_backend")) { - SPAN_CONFIG[span_id].limit_backend = val; - ftdm_log(FTDM_LOG_DEBUG, "Using limit backend %s for span %d\n", SPAN_CONFIG[span_id].limit_backend, span_id); - } else if (!strcasecmp(var, "call_limit_rate")) { - int calls; - int seconds; - if (sscanf(val, "%d/%d", &calls, &seconds) != 2) { - LOAD_ERROR("Invalid %s parameter, format example: 3/1 for 3 calls per second\n", var); - } else { - if (calls < 1 || seconds < 1) { - LOAD_ERROR("Invalid %s parameter value, minimum call limit must be 1 per second\n", var); - } else { - SPAN_CONFIG[span_id].limit_calls = calls; - SPAN_CONFIG[span_id].limit_seconds = seconds; - } - } - } else if (!strcasecmp(var, "call_limit_reset_event")) { - if (!strcasecmp(val, "answer")) { - SPAN_CONFIG[span_id].limit_reset_event = FTDM_LIMIT_RESET_ON_ANSWER; - } else { - LOAD_ERROR("Invalid %s parameter value, only accepted event is 'answer'\n", var); - } - } else if (!strcasecmp(var, "dial-regex")) { - dial_regex = val; - } else if (!strcasecmp(var, "enable-callerid")) { - enable_callerid = val; - } else if (!strcasecmp(var, "answer-polarity-reverse")) { - answer_polarity = val; - } else if (!strcasecmp(var, "hangup-polarity-reverse")) { - hangup_polarity = val; - } else if (!strcasecmp(var, "polarity-delay")) { - polarity_delay = atoi(val); - } else if (!strcasecmp(var, "polarity-callerid")) { - polarity_callerid = val; - } else if (!strcasecmp(var, "fail-dial-regex")) { - fail_dial_regex = val; - } else if (!strcasecmp(var, "hold-music")) { - hold_music = val; - } else if (!strcasecmp(var, "max_digits") || !strcasecmp(var, "max-digits")) { - max_digits = val; - } else if (!strcasecmp(var, "hotline")) { - hotline = val; - } else if (!strcasecmp(var, "callwaiting")) { - callwaiting = switch_true(val) ? 1 : 0; - } else if (!strcasecmp(var, "enable-analog-option")) { - analog_options = enable_analog_option(val, analog_options); - } - } - - if (!id && !name) { - LOAD_ERROR("span missing required param 'id'\n"); - continue; - } - - if (!tonegroup) { - tonegroup = "us"; - } - - if (digit_timeout) { - to = atoi(digit_timeout); - } - - if (max_digits) { - max = atoi(max_digits); - } - - if (name) { - zstatus = ftdm_span_find_by_name(name, &span); - } else { - if (switch_is_number(id)) { - span_id = atoi(id); - zstatus = ftdm_span_find(span_id, &span); - } - - if (zstatus != FTDM_SUCCESS) { - zstatus = ftdm_span_find_by_name(id, &span); - } - } - - if (zstatus != FTDM_SUCCESS) { - LOAD_ERROR("Error finding FreeTDM span id:%s name:%s\n", switch_str_nil(id), switch_str_nil(name)); - continue; - } - - if (!span_id) { - span_id = ftdm_span_get_id(span); - } - - if (ftdm_configure_span(span, "analog", on_analog_signal, - "tonemap", tonegroup, - "digit_timeout", &to, - "max_dialstr", &max, - "hotline", hotline ? hotline : "", - "enable_callerid", enable_callerid, - "answer_polarity_reverse", answer_polarity, - "hangup_polarity_reverse", hangup_polarity, - "polarity_callerid", polarity_callerid, - "polarity_delay", &polarity_delay, - "callwaiting", &callwaiting, - "wait_dialtone_timeout", &dialtone_timeout, - FTDM_TAG_END) != FTDM_SUCCESS) { - LOAD_ERROR("Error configuring FreeTDM analog span %s\n", ftdm_span_get_name(span)); - continue; - } - - SPAN_CONFIG[span_id].span = span; - switch_set_string(SPAN_CONFIG[span_id].context, context); - switch_set_string(SPAN_CONFIG[span_id].dialplan, dialplan); - SPAN_CONFIG[span_id].analog_options = analog_options | globals.analog_options; - - chaniter = ftdm_span_get_chan_iterator(span, NULL); - for (curr = chaniter; curr; curr = ftdm_iterator_next(curr)) { - fchan = ftdm_iterator_current(curr); - ftdm_channel_set_private(fchan, &SPAN_CONFIG[span_id].pvts[i]); - } - ftdm_iterator_free(chaniter); - - if (dial_regex) { - switch_set_string(SPAN_CONFIG[span_id].dial_regex, dial_regex); - } - - if (fail_dial_regex) { - switch_set_string(SPAN_CONFIG[span_id].fail_dial_regex, fail_dial_regex); - } - - if (hold_music) { - switch_set_string(SPAN_CONFIG[span_id].hold_music, hold_music); - } - switch_copy_string(SPAN_CONFIG[span_id].type, "analog", sizeof(SPAN_CONFIG[span_id].type)); - ftdm_span_start(span); - } - } - - if ((spans = switch_xml_child(cfg, "analog_em_spans"))) { - for (myspan = switch_xml_child(spans, "span"); myspan; myspan = myspan->next) { - char *id = (char *) switch_xml_attr(myspan, "id"); - char *name = (char *) switch_xml_attr(myspan, "name"); - ftdm_status_t zstatus = FTDM_FAIL; - const char *context = "default"; - const char *dialplan = "XML"; - const char *tonegroup = NULL; - char *digit_timeout = NULL; - char *dial_timeout = NULL; - char *release_guard_time_ms = NULL; - char *max_digits = NULL; - char *dial_regex = NULL; - char *hold_music = NULL; - char *fail_dial_regex = NULL; - char str_false[] = "false"; - char str_empty[] = ""; - char *answer_supervision = str_false; - char *immediate_ringback = str_false; - char *ringback_file = str_empty; - uint32_t span_id = 0, to = 0, max = 0, dial_timeout_int = 0, release_guard_time_ms_int = 0; - ftdm_span_t *span = NULL; - analog_option_t analog_options = ANALOG_OPTION_NONE; - - for (param = switch_xml_child(myspan, "param"); param; param = param->next) { - char *var = (char *) switch_xml_attr_soft(param, "name"); - char *val = (char *) switch_xml_attr_soft(param, "value"); - - if (!strcasecmp(var, "tonegroup")) { - tonegroup = val; - } else if (!strcasecmp(var, "digit_timeout") || !strcasecmp(var, "digit-timeout")) { - digit_timeout = val; - } else if (!strcasecmp(var, "dial-timeout")) { - dial_timeout = val; - } else if (!strcasecmp(var, "release-guard-time-ms")) { - release_guard_time_ms = val; - } else if (!strcasecmp(var, "context")) { - context = val; - } else if (!strcasecmp(var, "dialplan")) { - dialplan = val; - } else if (!strcasecmp(var, "dial-regex")) { - dial_regex = val; - } else if (!strcasecmp(var, "fail-dial-regex")) { - fail_dial_regex = val; - } else if (!strcasecmp(var, "hold-music")) { - hold_music = val; - } else if (!strcasecmp(var, "max_digits") || !strcasecmp(var, "max-digits")) { - max_digits = val; - } else if (!strcasecmp(var, "answer-supervision")) { - answer_supervision = val; - } else if (!strcasecmp(var, "immediate-ringback")) { - immediate_ringback = val; - } else if (!strcasecmp(var, "ringback-file")) { - ringback_file = val; - } else if (!strcasecmp(var, "enable-analog-option")) { - analog_options = enable_analog_option(val, analog_options); - } - } - - if (!id && !name) { - LOAD_ERROR("span missing required param 'id'\n"); - continue; - } - - if (!tonegroup) { - tonegroup = "us"; - } - - if (digit_timeout) { - to = atoi(digit_timeout); - } - - if (dial_timeout) { - dial_timeout_int = atoi(dial_timeout); - } - - if (release_guard_time_ms) { - release_guard_time_ms_int = atoi(release_guard_time_ms); - } - - if (max_digits) { - max = atoi(max_digits); - } - - - if (name) { - zstatus = ftdm_span_find_by_name(name, &span); - } else { - if (switch_is_number(id)) { - span_id = atoi(id); - zstatus = ftdm_span_find(span_id, &span); - } - - if (zstatus != FTDM_SUCCESS) { - zstatus = ftdm_span_find_by_name(id, &span); - } - } - - if (zstatus != FTDM_SUCCESS) { - LOAD_ERROR("Error finding FreeTDM span id:%s name:%s\n", switch_str_nil(id), switch_str_nil(name)); - continue; - } - - if (!span_id) { - span_id = ftdm_span_get_id(span); - } - - - if (ftdm_configure_span(span, "analog_em", on_analog_signal, - "tonemap", tonegroup, - "answer_supervision", answer_supervision, - "immediate_ringback", immediate_ringback, - "ringback_file", ringback_file, - "digit_timeout", &to, - "dial_timeout", &dial_timeout_int, - "release_guard_time_ms", &release_guard_time_ms_int, - "max_dialstr", &max, - FTDM_TAG_END) != FTDM_SUCCESS) { - LOAD_ERROR("Error starting FreeTDM span %d\n", span_id); - continue; - } - - SPAN_CONFIG[span_id].span = span; - switch_set_string(SPAN_CONFIG[span_id].context, context); - switch_set_string(SPAN_CONFIG[span_id].dialplan, dialplan); - SPAN_CONFIG[span_id].analog_options = analog_options | globals.analog_options; - - if (dial_regex) { - switch_set_string(SPAN_CONFIG[span_id].dial_regex, dial_regex); - } - - if (fail_dial_regex) { - switch_set_string(SPAN_CONFIG[span_id].fail_dial_regex, fail_dial_regex); - } - - if (hold_music) { - switch_set_string(SPAN_CONFIG[span_id].hold_music, hold_music); - } - switch_copy_string(SPAN_CONFIG[span_id].type, "analog_em", sizeof(SPAN_CONFIG[span_id].type)); - ftdm_span_start(span); - } - } - - if ((spans = switch_xml_child(cfg, "pri_spans"))) { - for (myspan = switch_xml_child(spans, "span"); myspan; myspan = myspan->next) { - char *name = (char *) switch_xml_attr(myspan, "name"); - ftdm_conf_parameter_t spanparameters[FTDM_MAX_SIG_PARAMETERS]; - ftdm_status_t zstatus = FTDM_FAIL; - const char *context = "default"; - const char *dialplan = "XML"; - unsigned paramindex = 0; - ftdm_span_t *span = NULL; - uint32_t span_id = 0; - - if (!name) { - LOAD_ERROR("span missing required attribute 'name'\n"); - continue; - } - - memset(spanparameters, 0, sizeof(spanparameters)); - - for (param = switch_xml_child(myspan, "param"); param; param = param->next) { - char *var = (char *) switch_xml_attr_soft(param, "name"); - char *val = (char *) switch_xml_attr_soft(param, "value"); - - if (ftdm_array_len(spanparameters) - 1 == paramindex) { - LOAD_ERROR("Too many parameters for pri span '%s', ignoring everything after '%s'\n", name, var); - break; - } - - if (ftdm_strlen_zero(var) || ftdm_strlen_zero(val)) { - ftdm_log(FTDM_LOG_WARNING, "Skipping parameter with empty name or value\n"); - continue; - } - - if (!strcasecmp(var, "context")) { - context = val; - } else if (!strcasecmp(var, "dialplan")) { - dialplan = val; - } else { - spanparameters[paramindex].var = var; - spanparameters[paramindex].val = val; - paramindex++; - } - } - - zstatus = ftdm_span_find_by_name(name, &span); - if (zstatus != FTDM_SUCCESS) { - LOAD_ERROR("Error finding FreeTDM span %s\n", name); - continue; - } - - span_id = ftdm_span_get_id(span); - if (ftdm_configure_span_signaling(span, "isdn", on_clear_channel_signal, spanparameters) != FTDM_SUCCESS) { - LOAD_ERROR("Error configuring FreeTDM span %s\n", name); - continue; - } - - SPAN_CONFIG[span_id].span = span; - switch_copy_string(SPAN_CONFIG[span_id].context, context, sizeof(SPAN_CONFIG[span_id].context)); - switch_copy_string(SPAN_CONFIG[span_id].dialplan, dialplan, sizeof(SPAN_CONFIG[span_id].dialplan)); - switch_copy_string(SPAN_CONFIG[span_id].type, "isdn", sizeof(SPAN_CONFIG[span_id].type)); - - ftdm_span_start(span); - } - } - - if ((spans = switch_xml_child(cfg, "pritap_spans"))) { - for (myspan = switch_xml_child(spans, "span"); myspan; myspan = myspan->next) { - - char *name = (char *) switch_xml_attr(myspan, "name"); - - ftdm_status_t zstatus = FTDM_FAIL; - unsigned paramindex = 0; - ftdm_conf_parameter_t spanparameters[FTDM_MAX_SIG_PARAMETERS]; - const char *context = "default"; - const char *dialplan = "XML"; - ftdm_span_t *span = NULL; - int span_id = 0; - - if (!name) { - LOAD_ERROR("span missing required attribute 'name'\n"); - continue; - } - - memset(spanparameters, 0, sizeof(spanparameters)); - - for (param = switch_xml_child(myspan, "param"); param; param = param->next) { - char *var = (char *) switch_xml_attr_soft(param, "name"); - char *val = (char *) switch_xml_attr_soft(param, "value"); - - if (ftdm_array_len(spanparameters) - 1 == paramindex) { - LOAD_ERROR("Too many parameters for pritap span '%s', ignoring everything after '%s'\n", name, var); - break; - } - - if (!strcasecmp(var, "context")) { - context = val; - } else if (!strcasecmp(var, "dialplan")) { - dialplan = val; - } else { - spanparameters[paramindex].var = var; - spanparameters[paramindex].val = val; - paramindex++; - } - } - - zstatus = ftdm_span_find_by_name(name, &span); - if (zstatus != FTDM_SUCCESS) { - LOAD_ERROR("Error finding FreeTDM span %s\n", name); - continue; - } - - span_id = ftdm_span_get_id(span); - if (ftdm_configure_span_signaling(span, "pritap", on_clear_channel_signal, spanparameters) != FTDM_SUCCESS) { - LOAD_ERROR("Error configuring FreeTDM span %s\n", name); - continue; - } - - SPAN_CONFIG[span_id].span = span; - switch_copy_string(SPAN_CONFIG[span_id].context, context, sizeof(SPAN_CONFIG[span_id].context)); - switch_copy_string(SPAN_CONFIG[span_id].dialplan, dialplan, sizeof(SPAN_CONFIG[span_id].dialplan)); - switch_copy_string(SPAN_CONFIG[span_id].type, "isdn", sizeof(SPAN_CONFIG[span_id].type)); - - ftdm_span_start(span); - } - } - - - if ((spans = switch_xml_child(cfg, "libpri_spans"))) { - for (myspan = switch_xml_child(spans, "span"); myspan; myspan = myspan->next) { - char *name = (char *) switch_xml_attr(myspan, "name"); - ftdm_conf_parameter_t spanparameters[FTDM_MAX_SIG_PARAMETERS]; - ftdm_status_t zstatus = FTDM_FAIL; - const char *context = "default"; - const char *dialplan = "XML"; - unsigned paramindex = 0; - ftdm_span_t *span = NULL; - uint32_t span_id = 0; - - if (!name) { - LOAD_ERROR("span missing required attribute 'name'\n"); - continue; - } - - memset(spanparameters, 0, sizeof(spanparameters)); - - for (param = switch_xml_child(myspan, "param"); param; param = param->next) { - char *var = (char *) switch_xml_attr_soft(param, "name"); - char *val = (char *) switch_xml_attr_soft(param, "value"); - - if (ftdm_array_len(spanparameters) - 1 == paramindex) { - LOAD_ERROR("Too many parameters for libpri span, ignoring everything after '%s'\n", var); - break; - } - - if (ftdm_strlen_zero(var) || ftdm_strlen_zero(val)) { - ftdm_log(FTDM_LOG_WARNING, "Skipping parameter with empty name or value\n"); - continue; - } - - if (!strcasecmp(var, "context")) { - context = val; - } else if (!strcasecmp(var, "dialplan")) { - dialplan = val; - } else { - spanparameters[paramindex].var = var; - spanparameters[paramindex].val = val; - paramindex++; - } - } - - zstatus = ftdm_span_find_by_name(name, &span); - if (zstatus != FTDM_SUCCESS) { - LOAD_ERROR("Error finding FreeTDM span %s\n", name); - continue; - } - - span_id = ftdm_span_get_id(span); - if (ftdm_configure_span_signaling(span, "libpri", on_clear_channel_signal, spanparameters) != FTDM_SUCCESS) { - LOAD_ERROR("Error configuring FreeTDM span %s\n", name); - continue; - } - - SPAN_CONFIG[span_id].span = span; - switch_copy_string(SPAN_CONFIG[span_id].context, context, sizeof(SPAN_CONFIG[span_id].context)); - switch_copy_string(SPAN_CONFIG[span_id].dialplan, dialplan, sizeof(SPAN_CONFIG[span_id].dialplan)); - switch_copy_string(SPAN_CONFIG[span_id].type, "isdn", sizeof(SPAN_CONFIG[span_id].type)); - - ftdm_span_start(span); - } - } - - if ((spans = switch_xml_child(cfg, "r2_spans"))) { - for (myspan = switch_xml_child(spans, "span"); myspan; myspan = myspan->next) { - char *name = (char *) switch_xml_attr(myspan, "name"); - char *configname = (char *) switch_xml_attr(myspan, "cfgprofile"); - ftdm_status_t zstatus = FTDM_FAIL; - - /* common non r2 stuff */ - const char *context = "default"; - const char *dialplan = "XML"; - char *dial_regex = NULL; - char *fail_dial_regex = NULL; - uint32_t span_id = 0; - ftdm_span_t *span = NULL; - - ftdm_conf_parameter_t spanparameters[FTDM_MAX_SIG_PARAMETERS]; - unsigned paramindex = 0; - - if (!name) { - LOAD_ERROR("'name' attribute required for R2 spans!\n"); - continue; - } - - memset(spanparameters, 0, sizeof(spanparameters)); - - if (configname) { - paramindex = add_profile_parameters(cfg, configname, spanparameters, ftdm_array_len(spanparameters)); - if (paramindex) { - ftdm_log(FTDM_LOG_DEBUG, "Added %d parameters from profile %s for span %d\n", paramindex, configname, span_id); - } - } - - for (param = switch_xml_child(myspan, "param"); param; param = param->next) { - char *var = (char *) switch_xml_attr_soft(param, "name"); - char *val = (char *) switch_xml_attr_soft(param, "value"); - - /* string parameters */ - if (!strcasecmp(var, "context")) { - context = val; - } else if (!strcasecmp(var, "dialplan")) { - dialplan = val; - } else if (!strcasecmp(var, "dial-regex")) { - dial_regex = val; - } else if (!strcasecmp(var, "fail-dial-regex")) { - fail_dial_regex = val; - } else { - spanparameters[paramindex].var = var; - spanparameters[paramindex].val = val; - paramindex++; - } - } - - zstatus = ftdm_span_find_by_name(name, &span); - if (zstatus != FTDM_SUCCESS) { - LOAD_ERROR("Error finding FreeTDM R2 Span '%s'\n", name); - continue; - } - span_id = ftdm_span_get_id(span); - - if (ftdm_configure_span_signaling(span, "r2", on_r2_signal, spanparameters) != FTDM_SUCCESS) { - LOAD_ERROR("Error configuring FreeTDM R2 span %s, error: %s\n", name, ftdm_span_get_last_error(span)); - continue; - } - - if (dial_regex) { - switch_set_string(SPAN_CONFIG[span_id].dial_regex, dial_regex); - } - - if (fail_dial_regex) { - switch_set_string(SPAN_CONFIG[span_id].fail_dial_regex, fail_dial_regex); - } - - SPAN_CONFIG[span_id].span = span; - switch_copy_string(SPAN_CONFIG[span_id].context, context, sizeof(SPAN_CONFIG[span_id].context)); - switch_copy_string(SPAN_CONFIG[span_id].dialplan, dialplan, sizeof(SPAN_CONFIG[span_id].dialplan)); - switch_copy_string(SPAN_CONFIG[span_id].type, "R2", sizeof(SPAN_CONFIG[span_id].type)); - - if (ftdm_span_start(span) == FTDM_FAIL) { - LOAD_ERROR("Error starting FreeTDM R2 span %s, error: %s\n", name, ftdm_span_get_last_error(span)); - continue; - } - } - } - - if (globals.crash_on_assert) { - ftdm_log(FTDM_LOG_WARNING, "Crash on assert enabled\n"); - ftdm_global_set_crash_policy(FTDM_CRASH_ON_ASSERT); - } - - switch_xml_free(xml); - - if (globals.fail_on_error && globals.config_error) { - ftdm_log(FTDM_LOG_ERROR, "Refusing to load module with errors\n"); - return SWITCH_STATUS_TERM; - } - - return SWITCH_STATUS_SUCCESS; -} - -void dump_chan(ftdm_span_t *span, uint32_t chan_id, switch_stream_handle_t *stream) -{ - uint32_t span_id; - uint32_t phspan_id, phchan_id; - const char *chan_type; - const char *state; - const char *last_state; - const char *uuid = NULL; - char sessionid[255]; - float txgain, rxgain; - switch_core_session_t *session = NULL; - ftdm_alarm_flag_t alarmflag; - ftdm_caller_data_t *caller_data; - ftdm_channel_t *ftdmchan; - ftdm_signaling_status_t sigstatus = FTDM_SIG_STATE_DOWN; - - if (chan_id > ftdm_span_get_chan_count(span)) { - return; - } - - strcpy(sessionid, "(none)"); - ftdmchan = ftdm_span_get_channel(span, chan_id); - span_id = ftdm_span_get_id(span); - - phspan_id = ftdm_channel_get_ph_span_id(ftdmchan); - phchan_id = ftdm_channel_get_ph_id(ftdmchan); - chan_type = ftdm_chan_type2str(ftdm_channel_get_type(ftdmchan)); - state = ftdm_channel_get_state_str(ftdmchan); - last_state = ftdm_channel_get_last_state_str(ftdmchan); - ftdm_channel_command(ftdmchan, FTDM_COMMAND_GET_RX_GAIN, &rxgain); - ftdm_channel_command(ftdmchan, FTDM_COMMAND_GET_TX_GAIN, &txgain); - caller_data = ftdm_channel_get_caller_data(ftdmchan); - ftdm_channel_get_sig_status(ftdmchan, &sigstatus); - ftdm_channel_get_alarms(ftdmchan, &alarmflag); - - uuid = ftdm_channel_get_uuid(ftdmchan, 0); - if (!zstr(uuid)) { - if (!(session = switch_core_session_locate(uuid))) { - snprintf(sessionid, sizeof(sessionid), "%s (dead)", uuid); - } else { - snprintf(sessionid, sizeof(sessionid), "%s", uuid); - switch_core_session_rwunlock(session); - } - } - - stream->write_function(stream, - "span_id: %u\n" - "chan_id: %u\n" - "physical_span_id: %u\n" - "physical_chan_id: %u\n" - "physical_status: %s\n" - "physical_status_red: %d\n" - "physical_status_yellow: %d\n" - "physical_status_rai: %d\n" - "physical_status_blue: %d\n" - "physical_status_ais: %d\n" - "physical_status_general: %d\n" - "signaling_status: %s\n" - "type: %s\n" - "state: %s\n" - "last_state: %s\n" - "txgain: %3.2f\n" - "rxgain: %3.2f\n" - "cid_date: %s\n" - "cid_name: %s\n" - "cid_num: %s\n" - "ani: %s\n" - "aniII: %s\n" - "dnis: %s\n" - "rdnis: %s\n" - "cause: %s\n" - "session: %s\n\n", - span_id, - chan_id, - phspan_id, - phchan_id, - alarmflag ? "alarmed" : "ok", - (alarmflag & FTDM_ALARM_RED) ? 1 : 0, - (alarmflag & FTDM_ALARM_YELLOW) ? 1 : 0, - (alarmflag & FTDM_ALARM_RAI) ? 1 : 0, - (alarmflag & FTDM_ALARM_BLUE) ? 1 : 0, - (alarmflag & FTDM_ALARM_AIS) ? 1 : 0, - (alarmflag & FTDM_ALARM_GENERAL) ? 1 : 0, - ftdm_signaling_status2str(sigstatus), - chan_type, - state, - last_state, - txgain, - rxgain, - caller_data->cid_date, - caller_data->cid_name, - caller_data->cid_num.digits, - caller_data->ani.digits, - caller_data->aniII, - caller_data->dnis.digits, - caller_data->rdnis.digits, - switch_channel_cause2str(caller_data->hangup_cause), - sessionid); -} - -void dump_chan_xml(ftdm_span_t *span, uint32_t chan_id, switch_stream_handle_t *stream) -{ - uint32_t span_id; - uint32_t phspan_id, phchan_id; - const char *chan_type; - const char *state; - const char *last_state; - float txgain, rxgain; - ftdm_caller_data_t *caller_data; - ftdm_channel_t *ftdmchan; - ftdm_alarm_flag_t alarmflag; - ftdm_signaling_status_t sigstatus = FTDM_SIG_STATE_DOWN; - - if (chan_id > ftdm_span_get_chan_count(span)) { - return; - } - - ftdmchan = ftdm_span_get_channel(span, chan_id); - span_id = ftdm_span_get_id(span); - - phspan_id = ftdm_channel_get_ph_span_id(ftdmchan); - phchan_id = ftdm_channel_get_ph_id(ftdmchan); - chan_type = ftdm_chan_type2str(ftdm_channel_get_type(ftdmchan)); - state = ftdm_channel_get_state_str(ftdmchan); - last_state = ftdm_channel_get_last_state_str(ftdmchan); - ftdm_channel_command(ftdmchan, FTDM_COMMAND_GET_RX_GAIN, &rxgain); - ftdm_channel_command(ftdmchan, FTDM_COMMAND_GET_TX_GAIN, &txgain); - caller_data = ftdm_channel_get_caller_data(ftdmchan); - ftdm_channel_get_sig_status(ftdmchan, &sigstatus); - ftdm_channel_get_alarms(ftdmchan, &alarmflag); - - - stream->write_function(stream, - " \n" - " %u\n" - " %u>\n" - " %u\n" - " %u\n" - " %s\n" - " %d\n" - " %d\n" - " %d\n" - " %d\n" - " %d\n" - " %d\n" - " %s\n" - " %s\n" - " %s\n" - " %s\n" - " %3.2f\n" - " %3.2f\n" - " %s\n" - " %s\n" - " %s\n" - " %s\n" - " %s\n" - " %s\n" - " %s\n" - " %s\n" - " \n", - span_id, - chan_id, - phspan_id, - phchan_id, - alarmflag ? "alarmed" : "ok", - (alarmflag & FTDM_ALARM_RED) ? 1 : 0, - (alarmflag & FTDM_ALARM_YELLOW) ? 1 : 0, - (alarmflag & FTDM_ALARM_RAI) ? 1 : 0, - (alarmflag & FTDM_ALARM_BLUE) ? 1 : 0, - (alarmflag & FTDM_ALARM_AIS) ? 1 : 0, - (alarmflag & FTDM_ALARM_GENERAL) ? 1 : 0, - ftdm_signaling_status2str(sigstatus), - chan_type, - state, - last_state, - txgain, - rxgain, - caller_data->cid_date, - caller_data->cid_name, - caller_data->cid_num.digits, - caller_data->ani.digits, - caller_data->aniII, - caller_data->dnis.digits, - caller_data->rdnis.digits, - switch_channel_cause2str(caller_data->hangup_cause)); -} - -typedef struct ftdm_cli_entry ftdm_cli_entry_t; -typedef switch_status_t (*ftdm_cli_function_t)(ftdm_cli_entry_t *cli, const char *cmd, switch_core_session_t *session, - switch_stream_handle_t *stream, int argc, char *argv[]); -#define FTDM_CLI_DECLARE(name) static switch_status_t name(ftdm_cli_entry_t *cli, const char *cmd, \ - switch_core_session_t *session, switch_stream_handle_t *stream, \ - int argc, char *argv[]) -static void print_usage(switch_stream_handle_t *stream, ftdm_cli_entry_t *cli); - - -typedef struct cmd_ioread_data { - int num_times; - uint32_t interval; - ftdm_span_t *span; - ftdm_channel_t *fchan; - switch_memory_pool_t *pool; - int already_open; -} cmd_ioread_data_t; - -static void *SWITCH_THREAD_FUNC ioread_thread(switch_thread_t *thread, void *obj) -{ - ftdm_wait_flag_t wflags = FTDM_READ; - ftdm_status_t status = FTDM_FAIL; - unsigned char iobuf[SWITCH_RECOMMENDED_BUFFER_SIZE]; - cmd_ioread_data_t *data = obj; - int span_id = ftdm_span_get_id(data->span); - int chan_id = ftdm_channel_get_id(data->fchan); - ftdm_size_t len = ftdm_channel_get_io_packet_len(data->fchan); - ftdm_size_t origlen = len; - unsigned int pbuf[5]; - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, - "Started ioread thread (times = %d, interval = %ums, len = %"FTDM_SIZE_FMT", span = %d, chan = %d\n", - data->num_times, data->interval, len, span_id, chan_id); - - while (ftdm_running() && data->num_times > 0) { - data->num_times--; - - wflags = FTDM_READ; - status = ftdm_channel_wait(data->fchan, &wflags, (data->interval * 10)); - - if (status == FTDM_FAIL) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to wait for IO in device %d:%d!\n", span_id, chan_id); - continue; - } - - if (status == FTDM_TIMEOUT) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Timed out while waiting I/O in device %d:%d!\n", span_id, chan_id); - continue; - } - - len = origlen; - if (ftdm_channel_read(data->fchan, iobuf, &len) != FTDM_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Failed to read from device %d:%d!\n", span_id, chan_id); - continue; - } - pbuf[0] = iobuf[0]; - pbuf[1] = iobuf[1]; - pbuf[2] = iobuf[2]; - pbuf[3] = iobuf[3]; - pbuf[4] = iobuf[4]; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Read 0x%1X 0x%1X 0x%1X 0x%1X 0x%1X\n", - pbuf[0], pbuf[1], pbuf[2], pbuf[3], pbuf[4]); - } - - if (!data->already_open) { - ftdm_channel_close(&data->fchan); - } - - switch_core_destroy_memory_pool(&data->pool); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, - "Done ioread thread (times = %d, interval = %ums, len = %"FTDM_SIZE_FMT", span = %d, chan = %d\n", - data->num_times, data->interval, origlen, span_id, chan_id); - return NULL; -} - -FTDM_CLI_DECLARE(ftdm_cmd_ioread) -{ - char *span_name = NULL; - int channo = 0; - ftdm_status_t status = FTDM_SUCCESS; - switch_threadattr_t *attr = NULL; - switch_thread_t *thread = NULL; - - cmd_ioread_data_t *thdata; - cmd_ioread_data_t data; - - memset(&data, 0, sizeof(data)); - data.num_times = 1; - - if (argc < 3) { - print_usage(stream, cli); - goto end; - } - - span_name = argv[1]; - - ftdm_span_find_by_name(span_name, &data.span); - if (!data.span) { - stream->write_function(stream, "-ERR span %s not found\n", span_name); - goto end; - } - - channo = atoi(argv[2]); - - status = ftdm_channel_open(ftdm_span_get_id(data.span), channo, &data.fchan); - if (!data.fchan || (status != FTDM_SUCCESS && status != FTDM_EBUSY)) { - stream->write_function(stream, "-ERR Failed to open channel %d in span %s\n", channo, span_name); - goto end; - } - - if (status == FTDM_EBUSY) { - data.already_open = 1; - } - - if (argc > 3) { - data.num_times = atoi(argv[3]); - if (data.num_times < 1) { - data.num_times = 1; - } - } - - if (argc > 4) { - data.interval = atoi(argv[4]); - } - - if (data.interval <= 0 || data.interval > 10000) { - data.interval = ftdm_channel_get_io_interval(data.fchan); - } - - switch_core_new_memory_pool(&data.pool); - - thdata = switch_core_alloc(data.pool, sizeof(data)); - memcpy(thdata, &data, sizeof(*thdata)); - - switch_threadattr_create(&attr, data.pool); - switch_threadattr_detach_set(attr, 1); - switch_threadattr_stacksize_set(attr, SWITCH_THREAD_STACKSIZE); - switch_thread_create(&thread, attr, ioread_thread, thdata, data.pool); - -end: - return SWITCH_STATUS_SUCCESS; -} - -FTDM_CLI_DECLARE(ftdm_cmd_list) -{ - int j; - - for (j = 0 ; j < FTDM_MAX_SPANS_INTERFACE; j++) { - ftdm_channel_t *fchan; - ftdm_alarm_flag_t alarmbits = FTDM_ALARM_NONE; - const char *flags = "none"; - ftdm_signaling_status_t sigstatus; - - if (!SPAN_CONFIG[j].span) { - continue; - } - - if (SPAN_CONFIG[j].analog_options & ANALOG_OPTION_3WAY) { - flags = "3way"; - } else if (SPAN_CONFIG[j].analog_options & ANALOG_OPTION_CALL_SWAP) { - flags = "call swap"; - } - fchan = ftdm_span_get_channel(SPAN_CONFIG[j].span, 1); - ftdm_channel_get_alarms(fchan, &alarmbits); - - if ((FTDM_SUCCESS == ftdm_span_get_sig_status(SPAN_CONFIG[j].span, &sigstatus))) { - stream->write_function(stream, - "+OK\n" - "span: %u (%s)\n" - "type: %s\n" - "physical_status: %s\n" - "signaling_status: %s\n" - "chan_count: %u\n" - "dialplan: %s\n" - "context: %s\n" - "dial_regex: %s\n" - "fail_dial_regex: %s\n" - "hold_music: %s\n" - "analog_options: %s\n", - j, - ftdm_span_get_name(SPAN_CONFIG[j].span), - SPAN_CONFIG[j].type, - alarmbits ? "alarmed" : "ok", - ftdm_signaling_status2str(sigstatus), - ftdm_span_get_chan_count(SPAN_CONFIG[j].span), - SPAN_CONFIG[j].dialplan, - SPAN_CONFIG[j].context, - SPAN_CONFIG[j].dial_regex, - SPAN_CONFIG[j].fail_dial_regex, - SPAN_CONFIG[j].hold_music, - flags - ); - } else { - stream->write_function(stream, - "+OK\n" - "span: %u (%s)\n" - "type: %s\n" - "physical_status: %s\n" - "chan_count: %u\n" - "dialplan: %s\n" - "context: %s\n" - "dial_regex: %s\n" - "fail_dial_regex: %s\n" - "hold_music: %s\n" - "analog_options: %s\n", - j, - ftdm_span_get_name(SPAN_CONFIG[j].span), - SPAN_CONFIG[j].type, - alarmbits ? "alarmed" : "ok", - ftdm_span_get_chan_count(SPAN_CONFIG[j].span), - SPAN_CONFIG[j].dialplan, - SPAN_CONFIG[j].context, - SPAN_CONFIG[j].dial_regex, - SPAN_CONFIG[j].fail_dial_regex, - SPAN_CONFIG[j].hold_music, - flags); - } - } - return SWITCH_STATUS_SUCCESS; -} - -FTDM_CLI_DECLARE(ftdm_cmd_start_stop) -{ - char *span_name = argv[1]; - ftdm_span_t *span = NULL; - ftdm_status_t status; - - if (argc < 2) { - print_usage(stream, cli); - goto end; - } - - ftdm_span_find_by_name(span_name, &span); - if (!span) { - stream->write_function(stream, "-ERR span %s not found\n", span_name); - goto end; - } - - if (!strcasecmp(argv[0], "stop")) { - status = ftdm_span_stop(span); - } else { - status = ftdm_span_start(span); - } - - stream->write_function(stream, status == FTDM_SUCCESS ? "+OK\n" : "-ERR failure\n"); -end: - return SWITCH_STATUS_SUCCESS; -} - -FTDM_CLI_DECLARE(ftdm_cmd_reset) -{ - uint32_t chan_id = 0; - uint32_t ccount = 0; - ftdm_channel_t *chan; - ftdm_span_t *span = NULL; - - if (argc < 2) { - print_usage(stream, cli); - goto end; - } - - ftdm_span_find_by_name(argv[1], &span); - if (!span) { - stream->write_function(stream, "-ERR span %s not found\n", argv[1]); - goto end; - } - - if (argc > 2) { - chan_id = atoi(argv[2]); - if (chan_id > ftdm_span_get_chan_count(span)) { - stream->write_function(stream, "-ERR invalid channel %d\n", chan_id); - goto end; - } - } - - if (chan_id) { - chan = ftdm_span_get_channel(span, chan_id); - if (!chan) { - stream->write_function(stream, "-ERR Could not find channel %d\n", chan_id); - goto end; - } - stream->write_function(stream, "Resetting channel %s:%s\n", argv[1], argv[2]); - ftdm_channel_reset(chan); - } else { - uint32_t i = 0; - ccount = ftdm_span_get_chan_count(span); - for (i = 1; i < ccount; i++) { - chan = ftdm_span_get_channel(span, i); - stream->write_function(stream, "Resetting channel %s:%d\n", argv[1], i); - ftdm_channel_reset(chan); - } - } - -end: - - return SWITCH_STATUS_SUCCESS; -} - -FTDM_CLI_DECLARE(ftdm_cmd_dump) -{ - ftdm_iterator_t *chaniter = NULL; - ftdm_iterator_t *curr = NULL; - uint32_t chan_id = 0; - ftdm_span_t *span; - char *as = NULL; - - if (argc < 2) { - print_usage(stream, cli); - goto end; - } - - ftdm_span_find_by_name(argv[1], &span); - if (argc > 2) { - if (argv[3] && !strcasecmp(argv[2], "as")) { - as = argv[3]; - } else { - chan_id = atoi(argv[2]); - } - } - - if (argv[4] && !strcasecmp(argv[3], "as")) { - as = argv[4]; - } - - if (!zstr(as) && !strcasecmp(as, "xml")) { - stream->write_function(stream, "\n"); - if (!span) { - stream->write_function(stream, "invalid span\n"); - } else { - if (chan_id) { - if (chan_id > ftdm_span_get_chan_count(span)) { - stream->write_function(stream, "invalid channel\n"); - } else { - dump_chan_xml(span, chan_id, stream); - } - } else { - chaniter = ftdm_span_get_chan_iterator(span, NULL); - for (curr = chaniter; curr; curr = ftdm_iterator_next(curr)) { - dump_chan_xml(span, ftdm_channel_get_id(ftdm_iterator_current(curr)), stream); - } - ftdm_iterator_free(chaniter); - } - } - stream->write_function(stream, "\n"); - } else { - if (!span) { - stream->write_function(stream, "-ERR invalid span\n"); - } else { - if (chan_id) { - if (chan_id > ftdm_span_get_chan_count(span)) { - stream->write_function(stream, "-ERR invalid channel\n"); - } else { - char *dbgstr = NULL; - ftdm_channel_t *fchan = ftdm_span_get_channel(span, chan_id); - dump_chan(span, chan_id, stream); - dbgstr = ftdm_channel_get_history_str(fchan); - stream->write_function(stream, "%s\n", dbgstr); - ftdm_free(dbgstr); - } - } else { - stream->write_function(stream, "+OK\n"); - chaniter = ftdm_span_get_chan_iterator(span, NULL); - for (curr = chaniter; curr; curr = ftdm_iterator_next(curr)) { - dump_chan(span, ftdm_channel_get_id(ftdm_iterator_current(curr)), stream); - } - ftdm_iterator_free(chaniter); - } - } - } - -end: - return SWITCH_STATUS_SUCCESS; -} - -FTDM_CLI_DECLARE(ftdm_cmd_alarms) -{ - ftdm_alarm_flag_t alarmbits = FTDM_ALARM_NONE; - uint32_t chan_id = 0; - ftdm_span_t *span; - - if (argc < 3) { - print_usage(stream, cli); - goto end; - } - - ftdm_span_find_by_name(argv[1], &span); - chan_id = atoi(argv[2]); - if (!span) { - stream->write_function(stream, "-ERR invalid span\n"); - } else if (chan_id) { - if (chan_id > ftdm_span_get_chan_count(span)) { - stream->write_function(stream, "-ERR invalid channel\n"); - } else { - ftdm_channel_t *chan = ftdm_span_get_channel(span, chan_id); - if (!chan) { - stream->write_function(stream, "-ERR channel not configured\n"); - } else { - ftdm_channel_get_alarms(chan, &alarmbits); - if (!strlen(ftdm_channel_get_last_error(chan))) { - stream->write_function(stream, "+OK No alarms\n"); - } else { - stream->write_function(stream, "-ERR %s on %s:%d\n", ftdm_channel_get_last_error(chan), argv[1], chan); - } - } - } - } -end: - return SWITCH_STATUS_SUCCESS; -} - -FTDM_CLI_DECLARE(ftdm_cmd_sigstatus) -{ - ftdm_span_t *span = NULL; - ftdm_signaling_status_t sigstatus; - - if (argc < 3) { - print_usage(stream, cli); - goto end; - } - - if (!strcasecmp(argv[1], "get") && argc < 3) { - print_usage(stream, cli); - goto end; - } - - if (!strcasecmp(argv[1], "set") && argc != 5) { - print_usage(stream, cli); - goto end; - } - - ftdm_span_find_by_name(argv[2], &span); - if (!span) { - stream->write_function(stream, "-ERR invalid span %s\n", argv[2]); - goto end; - } - - if (!strcasecmp(argv[1], "get")) { - if (argc == 4) { - uint32_t chan_id = atol(argv[3]); - ftdm_channel_t *fchan = ftdm_span_get_channel(span, chan_id); - if (!fchan) { - stream->write_function(stream, "-ERR invalid channel id '%d'\n", chan_id); - goto end; - } - - if ((FTDM_SUCCESS == ftdm_channel_get_sig_status(fchan, &sigstatus))) { - stream->write_function(stream, "Channel %d signaling status: %s\n", chan_id, ftdm_signaling_status2str(sigstatus)); - } else { - stream->write_function(stream, "-ERR failed to get channel signaling status\n"); - } - goto end; - } else { - if ((FTDM_SUCCESS == ftdm_span_get_sig_status(span, &sigstatus))) { - stream->write_function(stream, "signaling_status: %s\n", ftdm_signaling_status2str(sigstatus)); - } else { - stream->write_function(stream, "-ERR failed to read span signaling status: %s\n", ftdm_span_get_last_error(span)); - } - } - goto end; - } - if (!strcasecmp(argv[1], "set")) { - sigstatus = ftdm_str2ftdm_signaling_status(argv[4]); - - if (!strcasecmp(argv[3], "all")) { - if ((FTDM_SUCCESS == ftdm_span_set_sig_status(span, sigstatus))) { - stream->write_function(stream, "Signaling status of all channels from span %s set to %s\n", - ftdm_span_get_name(span), ftdm_signaling_status2str(sigstatus)); - } else { - stream->write_function(stream, "-ERR failed to set span sigstatus to '%s'\n", ftdm_signaling_status2str(sigstatus)); - } - goto end; - } else { - uint32_t chan_id = atol(argv[3]); - ftdm_channel_t *fchan = ftdm_span_get_channel(span, chan_id); - if (!fchan) { - stream->write_function(stream, "-ERR failed to get channel id '%d'\n", chan_id); - goto end; - } - - if ((FTDM_SUCCESS == ftdm_channel_set_sig_status(fchan, sigstatus))) { - stream->write_function(stream, "Signaling status of channel %d set to %s\n", chan_id, - ftdm_signaling_status2str(sigstatus)); - } else { - stream->write_function(stream, "-ERR failed to set span sigstatus to '%s'\n", ftdm_signaling_status2str(sigstatus)); - } - goto end; - } - } - -end: - return SWITCH_STATUS_SUCCESS; -} - -FTDM_CLI_DECLARE(ftdm_cmd_trace) -{ - char tracepath[255]; - unsigned i = 0; - uint32_t chan_id = 0; - uint32_t span_id = 0; - uint32_t chan_count = 0; - ftdm_status_t status; - ftdm_span_t *span = NULL; - ftdm_channel_t *chan = NULL; - - if (argc < 3) { - print_usage(stream, cli); - goto end; - } - - ftdm_span_find_by_name(argv[2], &span); - if (!span) { - stream->write_function(stream, "-ERR failed to find span %s\n", argv[2]); - goto end; - } - - chan_count = ftdm_span_get_chan_count(span); - - if (argc > 3) { - chan_id = atoi(argv[3]); - if (chan_id > chan_count) { - stream->write_function(stream, "-ERR invalid channel\n"); - goto end; - } - } - - span_id = ftdm_span_get_id(span); - - if (chan_id) { - chan = ftdm_span_get_channel(span, chan_id); - - snprintf(tracepath, sizeof(tracepath), "%s-in-s%dc%d", argv[1], span_id, chan_id); - status = ftdm_channel_command(chan, FTDM_COMMAND_TRACE_INPUT, tracepath); - if (status != FTDM_SUCCESS) { - stream->write_function(stream, "-ERR failed to enable input trace at path %s\n", tracepath); - goto end; - } - - snprintf(tracepath, sizeof(tracepath), "%s-out-s%dc%d", argv[1], span_id, chan_id); - status = ftdm_channel_command(chan, FTDM_COMMAND_TRACE_OUTPUT, tracepath); - if (status != FTDM_SUCCESS) { - stream->write_function(stream, "-ERR failed to enable output trace at path %s\n", tracepath); - ftdm_channel_command(chan, FTDM_COMMAND_TRACE_END_ALL, NULL); - goto end; - } - } else { - for (i = 1; i <= chan_count; i++) { - chan = ftdm_span_get_channel(span, i); - - snprintf(tracepath, sizeof(tracepath), "%s-in-s%dc%d", argv[1], span_id, i); - status = ftdm_channel_command(chan, FTDM_COMMAND_TRACE_INPUT, tracepath); - if (status != FTDM_SUCCESS) { - stream->write_function(stream, "-ERR failed to enable input trace at path %s\n", tracepath); - goto end; - } - - snprintf(tracepath, sizeof(tracepath), "%s-out-s%dc%d", argv[1], span_id, i); - status = ftdm_channel_command(chan, FTDM_COMMAND_TRACE_OUTPUT, tracepath); - if (status != FTDM_SUCCESS) { - stream->write_function(stream, "-ERR failed to enable output trace at path %s\n", tracepath); - ftdm_channel_command(chan, FTDM_COMMAND_TRACE_END_ALL, NULL); - goto end; - } - } - } - stream->write_function(stream, "+OK trace enabled with prefix path %s\n", argv[1]); -end: - return SWITCH_STATUS_SUCCESS; -} - -FTDM_CLI_DECLARE(ftdm_cmd_notrace) -{ - uint32_t i = 0; - uint32_t chan_id = 0; - uint32_t chan_count = 0; - ftdm_channel_t *fchan = NULL; - ftdm_span_t *span = NULL; - - if (argc < 2) { - print_usage(stream, cli); - goto end; - } - - ftdm_span_find_by_name(argv[1], &span); - if (!span) { - stream->write_function(stream, "-ERR failed to find span %s\n", argv[1]); - goto end; - } - - chan_count = ftdm_span_get_chan_count(span); - - if (argc > 2) { - chan_id = atoi(argv[2]); - if (chan_id > chan_count) { - stream->write_function(stream, "-ERR invalid channel\n"); - goto end; - } - } - - if (chan_id) { - fchan = ftdm_span_get_channel(span, chan_id); - ftdm_channel_command(fchan, FTDM_COMMAND_TRACE_END_ALL, NULL); - } else { - for (i = 1; i <= chan_count; i++) { - fchan = ftdm_span_get_channel(span, i); - ftdm_channel_command(fchan, FTDM_COMMAND_TRACE_END_ALL, NULL); - } - } - stream->write_function(stream, "+OK trace disabled\n"); - -end: - return SWITCH_STATUS_SUCCESS; -} - -FTDM_CLI_DECLARE(ftdm_cmd_gains) -{ - unsigned int i = 0; - float txgain = 0.0; - float rxgain = 0.0; - uint32_t chan_id = 0; - uint32_t ccount = 0; - ftdm_channel_t *chan; - ftdm_span_t *span = NULL; - - if (argc < 4) { - print_usage(stream, cli); - goto end; - } - - ftdm_span_find_by_name(argv[3], &span); - if (!span) { - stream->write_function(stream, "-ERR failed to find span %s\n", argv[3]); - goto end; - } - - if (argc > 4) { - chan_id = atoi(argv[4]); - if (chan_id > ftdm_span_get_chan_count(span)) { - stream->write_function(stream, "-ERR invalid channel\n"); - goto end; - } - } - - i = sscanf(argv[1], "%f", &rxgain); - i += sscanf(argv[2], "%f", &txgain); - if (i != 2) { - stream->write_function(stream, "-ERR invalid gains\n"); - goto end; - } - - if (chan_id) { - chan = ftdm_span_get_channel(span, chan_id); - ftdm_channel_command(chan, FTDM_COMMAND_SET_RX_GAIN, &rxgain); - ftdm_channel_command(chan, FTDM_COMMAND_SET_TX_GAIN, &txgain); - } else { - ccount = ftdm_span_get_chan_count(span); - for (i = 1; i < ccount; i++) { - chan = ftdm_span_get_channel(span, i); - ftdm_channel_command(chan, FTDM_COMMAND_SET_RX_GAIN, &rxgain); - ftdm_channel_command(chan, FTDM_COMMAND_SET_TX_GAIN, &txgain); - } - } - stream->write_function(stream, "+OK gains set to Rx %f and Tx %f\n", rxgain, txgain); -end: - return SWITCH_STATUS_SUCCESS; -} - -FTDM_CLI_DECLARE(ftdm_cmd_dtmf) -{ - unsigned i = 0; - uint32_t chan_id = 0; - unsigned schan_count = 0; - ftdm_span_t *span = NULL; - ftdm_command_t fcmd = FTDM_COMMAND_ENABLE_DTMF_DETECT; - ftdm_channel_t *fchan; - - if (argc < 3) { - print_usage(stream, cli); - goto end; - } - - if (switch_true(argv[1])) { - fcmd = FTDM_COMMAND_ENABLE_DTMF_DETECT; - } else { - fcmd = FTDM_COMMAND_DISABLE_DTMF_DETECT; - } - - ftdm_span_find_by_name(argv[2], &span); - if (!span) { - stream->write_function(stream, "-ERR failed to find span %s\n", argv[2]); - goto end; - } - - schan_count = ftdm_span_get_chan_count(span); - if (argc > 3) { - chan_id = atoi(argv[3]); - if (chan_id > schan_count) { - stream->write_function(stream, "-ERR invalid channel\n"); - goto end; - } - } - - if (chan_id) { - fchan = ftdm_span_get_channel(span, chan_id); - ftdm_channel_command(fchan, fcmd, NULL); - } else { - for (i = 1; i <= schan_count; i++) { - fchan = ftdm_span_get_channel(span, i); - ftdm_channel_command(fchan, fcmd, NULL); - } - } - - stream->write_function(stream, "+OK DTMF detection was %s\n", fcmd == FTDM_COMMAND_ENABLE_DTMF_DETECT ? "enabled" : "disabled"); -end: - return SWITCH_STATUS_SUCCESS; -} - -FTDM_CLI_DECLARE(ftdm_cmd_queuesize) -{ - unsigned int i = 0; - uint32_t rxsize = 10; - uint32_t txsize = 10; - uint32_t chan_id = 0; - uint32_t ccount = 0; - ftdm_channel_t *chan; - ftdm_span_t *span = NULL; - - if (argc < 4) { - print_usage(stream, cli); - goto end; - } - - ftdm_span_find_by_name(argv[3], &span); - if (!span) { - stream->write_function(stream, "-ERR failed to find span %s\n", argv[3]); - goto end; - } - - if (argc > 4) { - chan_id = atoi(argv[4]); - if (chan_id > ftdm_span_get_chan_count(span)) { - stream->write_function(stream, "-ERR invalid channel\n"); - goto end; - } - } - - i = sscanf(argv[1], "%u", &rxsize); - i += sscanf(argv[2], "%u", &txsize); - if (i != 2) { - stream->write_function(stream, "-ERR invalid queue sizes provided\n"); - goto end; - } - - if (chan_id) { - chan = ftdm_span_get_channel(span, chan_id); - ftdm_channel_command(chan, FTDM_COMMAND_SET_RX_QUEUE_SIZE, &rxsize); - ftdm_channel_command(chan, FTDM_COMMAND_SET_TX_QUEUE_SIZE, &txsize); - } else { - ccount = ftdm_span_get_chan_count(span); - for (i = 1; i < ccount; i++) { - chan = ftdm_span_get_channel(span, i); - ftdm_channel_command(chan, FTDM_COMMAND_SET_RX_QUEUE_SIZE, &rxsize); - ftdm_channel_command(chan, FTDM_COMMAND_SET_TX_QUEUE_SIZE, &txsize); - } - } - stream->write_function(stream, "+OK queue sizes set to Rx %d and Tx %d\n", rxsize, txsize); -end: - return SWITCH_STATUS_SUCCESS; -} - -static void exec_io_command(const char *cmd, switch_stream_handle_t *stream, ftdm_channel_t *fchan) -{ - int enable = 0; - ftdm_channel_iostats_t stats; - - if (!strcasecmp("enable", cmd)) { - enable = 1; - ftdm_channel_command(fchan, FTDM_COMMAND_SWITCH_IOSTATS, &enable); - } else if (!strcasecmp("disable", cmd)) { - enable = 0; - ftdm_channel_command(fchan, FTDM_COMMAND_SWITCH_IOSTATS, &enable); - } else if (!strcasecmp("flush", cmd)) { - ftdm_channel_command(fchan, FTDM_COMMAND_FLUSH_IOSTATS, NULL); - } else { - ftdm_channel_command(fchan, FTDM_COMMAND_GET_IOSTATS, &stats); - stream->write_function(stream, "-- IO statistics for channel %d:%d --\n", - ftdm_channel_get_span_id(fchan), ftdm_channel_get_id(fchan)); - stream->write_function(stream, "Rx errors: %u\n", stats.rx.errors); - stream->write_function(stream, "Rx queue size: %u\n", stats.rx.queue_size); - stream->write_function(stream, "Rx queue len: %u\n", stats.rx.queue_len); - stream->write_function(stream, "Rx count: %lu\n", stats.rx.packets); - - stream->write_function(stream, "Tx errors: %u\n", stats.tx.errors); - stream->write_function(stream, "Tx queue size: %u\n", stats.tx.queue_size); - stream->write_function(stream, "Tx queue len: %u\n", stats.tx.queue_len); - stream->write_function(stream, "Tx count: %lu\n", stats.tx.packets); - stream->write_function(stream, "Tx idle: %u\n", stats.tx.idle_packets); - } -} - -FTDM_CLI_DECLARE(ftdm_cmd_iostats) -{ - uint32_t chan_id = 0; - ftdm_channel_t *chan; - ftdm_iterator_t *iter = NULL; - ftdm_iterator_t *curr = NULL; - ftdm_span_t *span = NULL; - - if (argc < 3) { - print_usage(stream, cli); - goto end; - } - - ftdm_span_find_by_name(argv[2], &span); - if (!span) { - stream->write_function(stream, "-ERR failed to find span %s\n", argv[2]); - goto end; - } - - if (argc > 3) { - chan_id = atoi(argv[3]); - if (chan_id > ftdm_span_get_chan_count(span)) { - stream->write_function(stream, "-ERR invalid channel\n"); - goto end; - } - chan = ftdm_span_get_channel(span, chan_id); - exec_io_command(argv[1], stream, chan); - } else { - iter = ftdm_span_get_chan_iterator(span, NULL); - for (curr = iter; curr; curr = ftdm_iterator_next(curr)) { - chan = ftdm_iterator_current(curr); - exec_io_command(argv[1], stream, chan); - } - ftdm_iterator_free(iter); - } - stream->write_function(stream, "+OK\n"); -end: - return SWITCH_STATUS_SUCCESS; -} - -#define CASINTS(cas) ((cas) & (1 << 3)) ? 1 : 0, \ - ((cas) & (1 << 2)) ? 1 : 0, \ - ((cas) & (1 << 1)) ? 1 : 0, \ - ((cas) & (1 << 0)) ? 1 : 0 -FTDM_CLI_DECLARE(ftdm_cmd_cas) -{ - uint32_t chan_id = 0; - switch_bool_t do_read = SWITCH_FALSE; - ftdm_channel_t *chan; - ftdm_iterator_t *iter = NULL; - ftdm_iterator_t *curr = NULL; - ftdm_span_t *span = NULL; - const char *write_bits_str = ""; - int32_t abcd_bits = 0; - - if (argc < 3) { - print_usage(stream, cli); - goto end; - } - - if (!strcasecmp(argv[1], "read")) { - do_read = SWITCH_TRUE; - chan_id = argc > 3 ? atoi(argv[3]) : 0; - } else if (!strcasecmp(argv[1], "write") && argc >= 4) { - const char *str = NULL; - int mask = 0x08; - do_read = SWITCH_FALSE; - if (argc == 4) { - chan_id = 0; - write_bits_str = argv[3]; - } else { - chan_id = atoi(argv[3]); - write_bits_str = argv[4]; - } - if (strlen(write_bits_str) != 4) { - stream->write_function(stream, "-ERR Invalid CAS bits '%s'. CAS ABCD string must be composed of only four 1's and 0's (e.g. 1101)\n", write_bits_str); - goto end; - } - str = write_bits_str; - while (*str) { - if (*str == '1') { - abcd_bits |= mask; - } else if (*str != '0') { - stream->write_function(stream, "-ERR Invalid CAS bits '%s'. CAS ABCD string must be composed of only four 1's and 0's (e.g. 1101)\n", write_bits_str); - goto end; - } - str++; - mask = (mask >> 1); - } - } else { - print_usage(stream, cli); - goto end; - } - - ftdm_span_find_by_name(argv[2], &span); - if (!span) { - stream->write_function(stream, "-ERR failed to find span %s\n", argv[2]); - goto end; - } - - if (chan_id) { - if (chan_id > ftdm_span_get_chan_count(span)) { - stream->write_function(stream, "-ERR invalid channel\n"); - goto end; - } - chan = ftdm_span_get_channel(span, chan_id); - if (do_read) { - ftdm_channel_command(chan, FTDM_COMMAND_GET_CAS_BITS, &abcd_bits); - stream->write_function(stream, "Read CAS bits from channel %d: %d%d%d%d (0x0%X)\n", chan_id, CASINTS(abcd_bits), abcd_bits); - } else { - stream->write_function(stream, "Writing 0x0%X to channel %d\n", abcd_bits, chan_id); - } - } else { - iter = ftdm_span_get_chan_iterator(span, NULL); - for (curr = iter; curr; curr = ftdm_iterator_next(curr)) { - chan = ftdm_iterator_current(curr); - //ftdm_channel_command(); - chan_id = ftdm_channel_get_id(chan); - if (do_read) { - ftdm_channel_command(chan, FTDM_COMMAND_GET_CAS_BITS, &abcd_bits); - stream->write_function(stream, "Read CAS bits from channel %d: %d%d%d%d (0x0%X)\n", chan_id, CASINTS(abcd_bits), abcd_bits); - } else { - stream->write_function(stream, "Writing 0x0%X to channel %d\n", abcd_bits, chan_id); - } - } - ftdm_iterator_free(iter); - } - stream->write_function(stream, "+OK\n"); -end: - return SWITCH_STATUS_SUCCESS; -} - -SWITCH_STANDARD_API(ftdm_api_exec_usage) -{ - char *mycmd = NULL, *argv[10] = { 0 }; - int argc = 0; - uint32_t chan_id = 0; - ftdm_channel_t *chan = NULL; - ftdm_span_t *span = NULL; - uint32_t tokencnt = 0; - /*ftdm_cli_entry_t *entry = NULL;*/ - - if (!zstr(cmd) && (mycmd = strdup(cmd))) { - argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); - } - - if (!argc) { - stream->write_function(stream, "-ERR invalid args\n"); - goto end; - } - - if (argc < 2) { - stream->write_function(stream, "-ERR invalid args\n"); - goto end; - } - - ftdm_span_find_by_name(argv[0], &span); - chan_id = atoi(argv[1]); - if (!span) { - stream->write_function(stream, "-ERR invalid span\n"); - goto end; - } - - if (chan_id <= 0) { - stream->write_function(stream, "-ERR invalid channel\n"); - goto end; - } - - if (chan_id > ftdm_span_get_chan_count(span)) { - stream->write_function(stream, "-ERR invalid channel\n"); - goto end; - } - - chan = ftdm_span_get_channel(span, chan_id); - if (!chan) { - stream->write_function(stream, "-ERR channel not configured\n"); - goto end; - } - - tokencnt = ftdm_channel_get_token_count(chan); - stream->write_function(stream, "%d", tokencnt); - -end: - switch_safe_free(mycmd); - return SWITCH_STATUS_SUCCESS; -} - -struct ftdm_cli_entry { - const char *name; - const char *args; - const char *complete; - const char *desc; - ftdm_cli_function_t execute; - switch_api_function_t execute_api; -}; - -static ftdm_cli_entry_t ftdm_cli_options[] = -{ - { "list", "", "", NULL, ftdm_cmd_list, NULL }, - { "start", "", "", NULL, ftdm_cmd_start_stop, NULL }, - { "stop", "", "", NULL, ftdm_cmd_start_stop, NULL }, - { "reset", " []", "", NULL, ftdm_cmd_reset, NULL }, - { "alarms", " ", "", NULL, ftdm_cmd_alarms, NULL }, - { "dump", " []", "", NULL, ftdm_cmd_dump, NULL }, - { "sigstatus", "get|set [] []", "::[set:get", NULL, ftdm_cmd_sigstatus, NULL }, - { "trace", " []", "", NULL, ftdm_cmd_trace, NULL }, - { "notrace", " []", "", NULL, ftdm_cmd_notrace, NULL }, - { "gains", " []", "", NULL, ftdm_cmd_gains, NULL }, - { "dtmf", "on|off []", "::[on:off", NULL, ftdm_cmd_dtmf, NULL }, - { "queuesize", " []", "", NULL, ftdm_cmd_queuesize, NULL }, - { "iostats", "enable|disable|flush|print ", "::[enable:disable:flush:print", NULL, ftdm_cmd_iostats, NULL }, - { "ioread", " [num_times] [interval]", "", NULL, ftdm_cmd_ioread, NULL }, - { "cas", "read|write [] []", "::[read:write", NULL, ftdm_cmd_cas, NULL }, - - /* Stand-alone commands (not part of the generic ftdm API */ - { "ftdm_usage", " ", "", "Return channel call count", NULL, ftdm_api_exec_usage }, - - /* Fake handlers as they are handled within freetdm library, - * we should provide a way inside freetdm to query for completions from signaling modules */ - { "core state", "[!]", "", NULL, NULL, NULL }, - { "core flag", "[!] [] []", "", NULL, NULL, NULL }, - { "core spanflag", "[!] []", "", NULL, NULL, NULL }, - { "core calls", "", "", NULL, NULL, NULL }, -}; - -static void print_usage(switch_stream_handle_t *stream, ftdm_cli_entry_t *cli) -{ - stream->write_function(stream, "-ERR Usage: ftdm %s %s\n", cli->name, cli->args); -} - -static void print_full_usage(switch_stream_handle_t *stream) -{ - int i = 0; - ftdm_cli_entry_t *entry = NULL; - - stream->write_function(stream, "USAGE:\n"); - stream->write_function(stream, "--------------------------------------------------------------------------------\n"); - for (i = 0 ; i < ftdm_array_len(ftdm_cli_options); i++) { - entry = &ftdm_cli_options[i]; - if (entry->execute_api) { - continue; - } - stream->write_function(stream, "ftdm %s %s\n", entry->name, entry->args); - } - stream->write_function(stream, "--------------------------------------------------------------------------------\n"); -} - -SWITCH_STANDARD_API(ftdm_api_exec) -{ - char *mycmd = NULL, *argv[10] = { 0 }; - int argc = 0; - int i = 0; - ftdm_cli_entry_t *entry = NULL; - - if (!zstr(cmd) && (mycmd = strdup(cmd))) { - argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); - } - - if (!argc) { - print_full_usage(stream); - goto end; - } - - for (i = 0 ; i < ftdm_array_len(ftdm_cli_options); i++) { - entry = &ftdm_cli_options[i]; - if (!strcasecmp(argv[0], entry->name) && entry->execute) { - entry->execute(entry, cmd, session, stream, argc, argv); - break; - } - } - - /* if the command was not found in the main CLI entries, try to execute it as a FreeTDM API */ - if (i == ftdm_array_len(ftdm_cli_options)) { - char *rply = ftdm_api_execute(cmd); - if (rply) { - stream->write_function(stream, "%s", rply); - ftdm_free(rply); - } else { - print_full_usage(stream); - } - } - -end: - switch_safe_free(mycmd); - return SWITCH_STATUS_SUCCESS; -} - -SWITCH_STANDARD_APP(enable_dtmf_function) -{ - private_t *tech_pvt; - - if (!switch_core_session_check_interface(session, freetdm_endpoint_interface)) { - ftdm_log(FTDM_LOG_ERROR, "This application is only for FreeTDM channels.\n"); - return; - } - - tech_pvt = switch_core_session_get_private(session); - - if (switch_test_flag(tech_pvt, TFLAG_DEAD)) { - switch_channel_hangup(switch_core_session_get_channel(session), SWITCH_CAUSE_LOSE_RACE); - return; - } - - ftdm_channel_command(tech_pvt->ftdmchan, FTDM_COMMAND_ENABLE_DTMF_DETECT, NULL); - ftdm_log(FTDM_LOG_INFO, "DTMF detection enabled in channel %d:%d\n", ftdm_channel_get_id(tech_pvt->ftdmchan), ftdm_channel_get_span_id(tech_pvt->ftdmchan)); -} - -SWITCH_STANDARD_APP(disable_dtmf_function) -{ - private_t *tech_pvt; - - if (!switch_core_session_check_interface(session, freetdm_endpoint_interface)) { - ftdm_log(FTDM_LOG_ERROR, "This application is only for FreeTDM channels.\n"); - return; - } - - tech_pvt = switch_core_session_get_private(session); - - if (switch_test_flag(tech_pvt, TFLAG_DEAD)) { - switch_channel_hangup(switch_core_session_get_channel(session), SWITCH_CAUSE_LOSE_RACE); - return; - } - - ftdm_channel_command(tech_pvt->ftdmchan, FTDM_COMMAND_DISABLE_DTMF_DETECT, NULL); - ftdm_log(FTDM_LOG_INFO, "DTMF detection Disabled in channel %d:%d\n", ftdm_channel_get_id(tech_pvt->ftdmchan), ftdm_channel_get_span_id(tech_pvt->ftdmchan)); -} - -SWITCH_STANDARD_APP(disable_ec_function) -{ - private_t *tech_pvt; - int x = 0; - - if (!switch_core_session_check_interface(session, freetdm_endpoint_interface)) { - ftdm_log(FTDM_LOG_ERROR, "This application is only for FreeTDM channels.\n"); - return; - } - - tech_pvt = switch_core_session_get_private(session); - - if (switch_test_flag(tech_pvt, TFLAG_DEAD)) { - switch_channel_hangup(switch_core_session_get_channel(session), SWITCH_CAUSE_LOSE_RACE); - return; - } - - ftdm_channel_command(tech_pvt->ftdmchan, FTDM_COMMAND_DISABLE_ECHOCANCEL, &x); - ftdm_channel_command(tech_pvt->ftdmchan, FTDM_COMMAND_DISABLE_ECHOTRAIN, &x); - ftdm_log(FTDM_LOG_INFO, "Echo Canceller Disabled\n"); -} - - -SWITCH_MODULE_LOAD_FUNCTION(mod_freetdm_load) -{ - int i = 0; - ftdm_cli_entry_t *entry = NULL; - switch_api_interface_t *commands_api_interface = NULL; - switch_application_interface_t *app_interface = NULL; - - module_pool = pool; - - ftdm_global_set_logger(ftdm_logger); - - ftdm_global_set_mod_directory(SWITCH_GLOBAL_dirs.mod_dir); - - ftdm_global_set_config_directory(SWITCH_GLOBAL_dirs.conf_dir); - - if (load_config_path() != SWITCH_STATUS_SUCCESS) { - ftdm_global_destroy(); - return SWITCH_STATUS_TERM; - } - - if (ftdm_global_init() != FTDM_SUCCESS) { - ftdm_global_destroy(); - ftdm_log(FTDM_LOG_ERROR, "Error loading FreeTDM\n"); - return SWITCH_STATUS_TERM; - } - - if (ftdm_global_configuration() != FTDM_SUCCESS) { - ftdm_global_destroy(); - ftdm_log(FTDM_LOG_ERROR, "Error configuring FreeTDM\n"); - return SWITCH_STATUS_TERM; - } - - if (load_config() != SWITCH_STATUS_SUCCESS) { - ftdm_global_destroy(); - return SWITCH_STATUS_TERM; - } - - *module_interface = switch_loadable_module_create_module_interface(pool, modname); - freetdm_endpoint_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE); - freetdm_endpoint_interface->interface_name = "freetdm"; - freetdm_endpoint_interface->io_routines = &freetdm_io_routines; - freetdm_endpoint_interface->state_handler = &freetdm_state_handlers; - - SWITCH_ADD_API(commands_api_interface, "ftdm", "FreeTDM commands", ftdm_api_exec, " "); - for (i = 0 ; i < ftdm_array_len(ftdm_cli_options); i++) { - char complete_cli[512]; - entry = &ftdm_cli_options[i]; - if (entry->execute_api) { - /* This is a stand-alone API */ - SWITCH_ADD_API(commands_api_interface, entry->name, entry->desc, ftdm_api_exec_usage, entry->args); - snprintf(complete_cli, sizeof(complete_cli), "add %s %s", entry->name, entry->complete); - switch_console_set_complete(complete_cli); - } else { - snprintf(complete_cli, sizeof(complete_cli), "add ftdm %s %s", entry->name, entry->complete); - switch_console_set_complete(complete_cli); - } - } - - SWITCH_ADD_APP(app_interface, "disable_ec", "Disable Echo Canceller", "Disable Echo Canceller", disable_ec_function, "", SAF_NONE); - SWITCH_ADD_APP(app_interface, "disable_dtmf", "Disable DTMF Detection", "Disable DTMF Detection", disable_dtmf_function, "", SAF_NONE); - SWITCH_ADD_APP(app_interface, "enable_dtmf", "Enable DTMF Detection", "Enable DTMF Detection", enable_dtmf_function, "", SAF_NONE); -#if 0 - ctdm_init(*module_interface); -#endif - /* indicate that the module should continue to be loaded */ - return SWITCH_STATUS_SUCCESS; -} - -SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_freetdm_shutdown) -{ - switch_hash_index_t *hi; - const void *var; - void *val; - - /* destroy ss7 configs */ - for (hi = switch_core_hash_first(globals.ss7_configs); hi; hi = switch_core_hash_next(&hi)) { - switch_core_hash_this(hi, &var, NULL, &val); - ftdm_conf_node_destroy(val); - } - - switch_core_hash_destroy(&globals.ss7_configs); - ftdm_global_destroy(); - - // this breaks pika but they are MIA so *shrug* - //return SWITCH_STATUS_NOUNLOAD; - return SWITCH_STATUS_SUCCESS; -} - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/mod_freetdm/mod_openzap.2005.vcproj b/libs/freetdm/mod_freetdm/mod_openzap.2005.vcproj deleted file mode 100644 index 491d0d574a..0000000000 --- a/libs/freetdm/mod_freetdm/mod_openzap.2005.vcproj +++ /dev/null @@ -1,201 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/freetdm/mod_freetdm/tdm.c b/libs/freetdm/mod_freetdm/tdm.c deleted file mode 100644 index d53c8a584b..0000000000 --- a/libs/freetdm/mod_freetdm/tdm.c +++ /dev/null @@ -1,719 +0,0 @@ -/* -* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application -* Copyright (C) 2005-2011, Anthony Minessale II -* -* Version: MPL 1.1 -* -* The contents of this file are subject to the Mozilla Public License Version -* 1.1 (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -* for the specific language governing rights and limitations under the -* License. -* -* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application -* -* The Initial Developer of the Original Code is -* Anthony Minessale II -* Portions created by the Initial Developer are Copyright (C) -* the Initial Developer. All Rights Reserved. -* -* Contributor(s): -* -* Mathieu Rene -* -* tdm.c -- FreeTDM Controllable Channel Module -* -*/ - -#include -#include "freetdm.h" - -void ctdm_init(switch_loadable_module_interface_t *module_interface); - -/* Parameters */ - -#define kSPAN_ID "span" -#define kCHAN_ID "chan" -#define kSPAN_NAME "span_name" -#define kPREBUFFER_LEN "prebuffer_len" -#define kECHOCANCEL "echo_cancel" - - -static struct { - switch_memory_pool_t *pool; - switch_endpoint_interface_t *endpoint_interface; -} ctdm; - -typedef struct { - int span_id; - int chan_id; - ftdm_channel_t *ftdm_channel; - switch_core_session_t *session; - switch_codec_t read_codec, write_codec; - switch_frame_t read_frame; - int prebuffer_len; - - unsigned char databuf[SWITCH_RECOMMENDED_BUFFER_SIZE]; -} ctdm_private_t; - -static switch_status_t channel_on_init(switch_core_session_t *session); -static switch_status_t channel_on_destroy(switch_core_session_t *session); -static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event, - switch_caller_profile_t *outbound_profile, - switch_core_session_t **new_session, - switch_memory_pool_t **pool, - switch_originate_flag_t flags, switch_call_cause_t *cancel_cause); -static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id); -static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id); -static switch_status_t channel_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg); -static switch_status_t channel_receive_event(switch_core_session_t *session, switch_event_t *event); -static switch_status_t channel_send_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf); - - -static ftdm_status_t ctdm_span_prepare(ftdm_span_t *span); - -switch_state_handler_table_t ctdm_state_handlers = { - .on_init = channel_on_init, - .on_destroy = channel_on_destroy -}; - -switch_io_routines_t ctdm_io_routines = { - .send_dtmf = channel_send_dtmf, - .outgoing_channel = channel_outgoing_channel, - .read_frame = channel_read_frame, - .write_frame = channel_write_frame, - .receive_message = channel_receive_message, - .receive_event = channel_receive_event -}; - -static void ctdm_report_alarms(ftdm_channel_t *channel) -{ - switch_event_t *event = NULL; - ftdm_alarm_flag_t alarmflag = 0; - - if (switch_event_create(&event, SWITCH_EVENT_TRAP) != SWITCH_STATUS_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "failed to create alarms events\n"); - return; - } - - if (ftdm_channel_get_alarms(channel, &alarmflag) != FTDM_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to retrieve alarms %s:%d\n", ftdm_channel_get_span_name(channel), ftdm_channel_get_id(channel)); - return; - } - - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "span-name", "%s", ftdm_channel_get_span_name(channel)); - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "span-number", "%d", ftdm_channel_get_span_id(channel)); - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "chan-number", "%d", ftdm_channel_get_id(channel)); - - if (alarmflag) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "condition", "ftdm-alarm-trap"); - } else { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "condition", "ftdm-alarm-clear"); - } - - if (alarmflag & FTDM_ALARM_RED) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "red"); - } - if (alarmflag & FTDM_ALARM_YELLOW) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "yellow"); - } - if (alarmflag & FTDM_ALARM_RAI) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "rai"); - } - if (alarmflag & FTDM_ALARM_BLUE) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "blue"); - } - if (alarmflag & FTDM_ALARM_AIS) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "ais"); - } - if (alarmflag & FTDM_ALARM_GENERAL) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "general"); - } - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Reporting [%s] alarms for %s:%d\n", - (alarmflag?"ftdm-alarm-trap":"ftdm-alarm-clear"), ftdm_channel_get_span_name(channel), ftdm_channel_get_id(channel)); - - switch_event_fire(&event); - return; -} - -static ftdm_channel_t *ctdm_get_channel_from_event(switch_event_t *event, ftdm_span_t *span) -{ - uint32_t chan_id = 0; - const char *chan_number = NULL; - - chan_number = switch_event_get_header(event, "chan-number"); - - if (zstr(chan_number)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No channel number specified\n"); - return NULL; - } - chan_id = atoi(chan_number); - if (!chan_id) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid channel number:%s\n", chan_number); - return NULL; - } - - return ftdm_span_get_channel_ph(span, chan_id); -} - - -static void ctdm_event_handler(switch_event_t *event) -{ - ftdm_status_t status = FTDM_FAIL; - switch(event->event_id) { - case SWITCH_EVENT_TRAP: - { - ftdm_span_t *span = NULL; - ftdm_channel_t *channel = NULL; - const char *span_name = NULL; - - const char *cond = switch_event_get_header(event, "condition"); - const char *command = switch_event_get_header(event, "command"); - if (zstr(cond)) { - return; - } - - span_name = switch_event_get_header(event, "span-name"); - - if (ftdm_span_find_by_name(span_name, &span) != FTDM_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find span [%s]\n", span_name); - return; - } - - if (!strcmp(cond, "mg-tdm-prepare")) { - status = ctdm_span_prepare(span); - if (status == FTDM_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s:prepared successfully\n", span_name); - } else if (status != FTDM_EINVAL) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s:Failed to prepare span\n", span_name); - } - } else if (!strcmp(cond, "mg-tdm-check")) { - channel = ctdm_get_channel_from_event(event, span); - if (!channel) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find channel\n"); - return; - } - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Requesting alarm status for %s:%d\n", - ftdm_channel_get_span_name(channel), ftdm_channel_get_id(channel)); - - ctdm_report_alarms(channel); - } else if (!strcmp(cond, "mg-tdm-dtmfremoval")) { - uint8_t enable = 0; - channel = ctdm_get_channel_from_event(event, span); - if (!channel) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find channel\n"); - return; - } - - if (zstr(command)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s:No command specified for mg-tdm-dtmfremoval\n", span_name); - return; - } - - if (!strcmp(command, "enable")) { - enable = 1; - } - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s DTMF-removal for %s:%d\n", - enable ? "Enabling" : "Disabling", ftdm_channel_get_span_name(channel), ftdm_channel_get_id(channel)); - - ftdm_channel_command(channel, enable ? FTDM_COMMAND_ENABLE_DTMF_REMOVAL : FTDM_COMMAND_DISABLE_DTMF_REMOVAL, 0); - } - } - break; - default: - break; - } - return; -} - -void ctdm_init(switch_loadable_module_interface_t *module_interface) -{ - switch_endpoint_interface_t *endpoint_interface; - ctdm.pool = module_interface->pool; - endpoint_interface = switch_loadable_module_create_interface(module_interface, SWITCH_ENDPOINT_INTERFACE); - endpoint_interface->interface_name = "tdm"; - endpoint_interface->io_routines = &ctdm_io_routines; - endpoint_interface->state_handler = &ctdm_state_handlers; - ctdm.endpoint_interface = endpoint_interface; - - switch_event_bind("mod_freetdm", SWITCH_EVENT_TRAP, SWITCH_EVENT_SUBCLASS_ANY, ctdm_event_handler, NULL); -} - -static FIO_SIGNAL_CB_FUNCTION(on_signal_cb) -{ - uint32_t chanid, spanid; - switch_event_t *event = NULL; - ftdm_alarm_flag_t alarmbits = FTDM_ALARM_NONE; - - chanid = ftdm_channel_get_id(sigmsg->channel); - spanid = ftdm_channel_get_span_id(sigmsg->channel); - - switch(sigmsg->event_id) { - case FTDM_SIGEVENT_ALARM_CLEAR: - case FTDM_SIGEVENT_ALARM_TRAP: - { - if (ftdm_channel_get_alarms(sigmsg->channel, &alarmbits) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "failed to retrieve alarms\n"); - return FTDM_FAIL; - } - - if (switch_event_create(&event, SWITCH_EVENT_TRAP) != SWITCH_STATUS_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "failed to create alarms events\n"); - return FTDM_FAIL; - } - if (sigmsg->event_id == FTDM_SIGEVENT_ALARM_CLEAR) { - ftdm_log(FTDM_LOG_NOTICE, "Alarm cleared on channel %d:%d\n", spanid, chanid); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "condition", "ftdm-alarm-clear"); - } else { - ftdm_log(FTDM_LOG_NOTICE, "Alarm raised on channel %d:%d\n", spanid, chanid); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "condition", "ftdm-alarm-trap"); - } - } - break; - default: - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unhandled event %d\n", sigmsg->event_id); - break; - } - - if (event) { - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "span-name", "%s", ftdm_channel_get_span_name(sigmsg->channel)); - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "span-number", "%d", ftdm_channel_get_span_id(sigmsg->channel)); - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "chan-number", "%d", ftdm_channel_get_id(sigmsg->channel)); - - if (alarmbits & FTDM_ALARM_RED) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "red"); - } - if (alarmbits & FTDM_ALARM_YELLOW) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "yellow"); - } - if (alarmbits & FTDM_ALARM_RAI) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "rai"); - } - if (alarmbits & FTDM_ALARM_BLUE) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "blue"); - } - if (alarmbits & FTDM_ALARM_AIS) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "ais"); - } - if (alarmbits & FTDM_ALARM_GENERAL) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "general"); - } - - switch_event_fire(&event); - } - return FTDM_SUCCESS; -} - -static ftdm_status_t ctdm_span_prepare(ftdm_span_t *span) -{ - if (ftdm_span_register_signal_cb(span, on_signal_cb) != FTDM_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register signal CB\n"); - return FTDM_FAIL; - } - return ftdm_span_start(span); -} - -static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event, - switch_caller_profile_t *outbound_profile, - switch_core_session_t **new_session, - switch_memory_pool_t **pool, - switch_originate_flag_t flags, switch_call_cause_t *cancel_cause) -{ - const char *szchanid = switch_event_get_header(var_event, kCHAN_ID), - *span_name = switch_event_get_header(var_event, kSPAN_NAME), - *szprebuffer_len = switch_event_get_header(var_event, kPREBUFFER_LEN); - int chan_id; - int span_id; - switch_caller_profile_t *caller_profile; - ftdm_span_t *span; - ftdm_channel_t *chan; - switch_channel_t *channel; - char name[128]; - const char *dname; - ftdm_codec_t codec; - uint32_t interval; - ctdm_private_t *tech_pvt = NULL; - - if (zstr(szchanid) || zstr(span_name)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Both ["kSPAN_ID"] and ["kCHAN_ID"] have to be set.\n"); - goto fail; - } - - chan_id = atoi(szchanid); - - if (ftdm_span_find_by_name(span_name, &span) == FTDM_SUCCESS) { - span_id = ftdm_span_get_id(span); - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find span [%s]\n", span_name); - goto fail; - } - - if (!(*new_session = switch_core_session_request(ctdm.endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, 0, pool))) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't request session.\n"); - goto fail; - } - - channel = switch_core_session_get_channel(*new_session); - - if (ftdm_channel_open_ph(span_id, chan_id, &chan) != FTDM_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't open span or channel.\n"); - goto fail; - } - - switch_channel_set_flag(channel, CF_AUDIO); - - span = ftdm_channel_get_span(chan); - - tech_pvt = switch_core_session_alloc(*new_session, sizeof *tech_pvt); - tech_pvt->chan_id = chan_id; - tech_pvt->span_id = span_id; - tech_pvt->ftdm_channel = chan; - tech_pvt->session = *new_session; - tech_pvt->read_frame.buflen = sizeof(tech_pvt->databuf); - tech_pvt->read_frame.data = tech_pvt->databuf; - tech_pvt->prebuffer_len = zstr(szprebuffer_len) ? 0 : atoi(szprebuffer_len); - switch_core_session_set_private(*new_session, tech_pvt); - - - caller_profile = switch_caller_profile_clone(*new_session, outbound_profile); - switch_channel_set_caller_profile(channel, caller_profile); - - snprintf(name, sizeof(name), "tdm/%d:%d", span_id, chan_id); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Connect outbound channel %s\n", name); - switch_channel_set_name(channel, name); - - switch_channel_set_state(channel, CS_INIT); - - if (FTDM_SUCCESS != ftdm_channel_command(chan, FTDM_COMMAND_GET_CODEC, &codec)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to retrieve channel codec.\n"); - return SWITCH_CAUSE_NETWORK_OUT_OF_ORDER; - } - - if (FTDM_SUCCESS != ftdm_channel_command(chan, FTDM_COMMAND_GET_INTERVAL, &interval)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to retrieve channel interval.\n"); - return SWITCH_CAUSE_NETWORK_OUT_OF_ORDER; - } - - if (FTDM_SUCCESS != ftdm_channel_command(chan, FTDM_COMMAND_SET_PRE_BUFFER_SIZE, &tech_pvt->prebuffer_len)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to set channel pre buffer size.\n"); - return SWITCH_CAUSE_NETWORK_OUT_OF_ORDER; - } - - if (FTDM_SUCCESS != ftdm_channel_command(tech_pvt->ftdm_channel, FTDM_COMMAND_ENABLE_ECHOCANCEL, NULL)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Failed to set enable echo cancellation.\n"); - } - - switch(codec) { - case FTDM_CODEC_ULAW: - { - dname = "PCMU"; - } - break; - case FTDM_CODEC_ALAW: - { - dname = "PCMA"; - } - break; - case FTDM_CODEC_SLIN: - { - dname = "L16"; - } - break; - default: - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid codec value retrieved from channel, codec value: %d\n", codec); - goto fail; - } - } - - - if (switch_core_codec_init(&tech_pvt->read_codec, - dname, - NULL, - NULL, - 8000, - interval, - 1, - SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, - NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n"); - goto fail; - } else { - if (switch_core_codec_init(&tech_pvt->write_codec, - dname, - NULL, - NULL, - 8000, - interval, - 1, - SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, - NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n"); - switch_core_codec_destroy(&tech_pvt->read_codec); - goto fail; - } - } - - if (switch_core_session_set_read_codec(*new_session, &tech_pvt->read_codec) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't set read codec?\n"); - goto fail; - } - - if (switch_core_session_set_write_codec(*new_session, &tech_pvt->write_codec) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't set write codec?\n"); - } - - if (switch_core_session_thread_launch(*new_session) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't start session thread.\n"); - goto fail; - } - - switch_channel_mark_answered(channel); - - return SWITCH_CAUSE_SUCCESS; - -fail: - - if (tech_pvt) { - if (tech_pvt->ftdm_channel) { - ftdm_channel_close(&tech_pvt->ftdm_channel); - } - - if (tech_pvt->read_codec.implementation) { - switch_core_codec_destroy(&tech_pvt->read_codec); - } - - if (tech_pvt->write_codec.implementation) { - switch_core_codec_destroy(&tech_pvt->write_codec); - } - } - - if (*new_session) { - switch_core_session_destroy(new_session); - } - return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; -} - -static switch_status_t channel_on_init(switch_core_session_t *session) -{ - switch_channel_t *channel = switch_core_session_get_channel(session); - - switch_channel_set_state(channel, CS_CONSUME_MEDIA); - return SWITCH_STATUS_SUCCESS; -} - -static switch_status_t channel_on_destroy(switch_core_session_t *session) -{ - ctdm_private_t *tech_pvt = switch_core_session_get_private(session); - - if ((tech_pvt = switch_core_session_get_private(session))) { - - if (FTDM_SUCCESS != ftdm_channel_command(tech_pvt->ftdm_channel, FTDM_COMMAND_ENABLE_ECHOCANCEL, NULL)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Failed to enable echo cancellation.\n"); - } - - if (tech_pvt->read_codec.implementation) { - switch_core_codec_destroy(&tech_pvt->read_codec); - } - - if (tech_pvt->write_codec.implementation) { - switch_core_codec_destroy(&tech_pvt->write_codec); - } - - switch_core_session_unset_read_codec(session); - switch_core_session_unset_write_codec(session); - - ftdm_channel_close(&tech_pvt->ftdm_channel); - } - - return SWITCH_STATUS_SUCCESS; -} - - -static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id) -{ - ftdm_wait_flag_t wflags = FTDM_READ; - ftdm_status_t status; - ctdm_private_t *tech_pvt; - const char *name; - switch_channel_t *channel; - int chunk; - uint32_t span_id, chan_id; - ftdm_size_t len; - char dtmf[128] = ""; - - channel = switch_core_session_get_channel(session); - assert(channel != NULL); - - tech_pvt = switch_core_session_get_private(session); - assert(tech_pvt != NULL); - - name = switch_channel_get_name(channel); - -top: - wflags = FTDM_READ; - chunk = ftdm_channel_get_io_interval(tech_pvt->ftdm_channel) * 2; - status = ftdm_channel_wait(tech_pvt->ftdm_channel, &wflags, chunk); - - - span_id = ftdm_channel_get_span_id(tech_pvt->ftdm_channel); - chan_id = ftdm_channel_get_id(tech_pvt->ftdm_channel); - - if (status == FTDM_FAIL) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to read from channel %s device %d:%d!\n", name, span_id, chan_id); - goto fail; - } - - if (status == FTDM_TIMEOUT) { - goto top; - } - - if (!(wflags & FTDM_READ)) { - goto top; - } - - len = tech_pvt->read_frame.buflen; - if (ftdm_channel_read(tech_pvt->ftdm_channel, tech_pvt->read_frame.data, &len) != FTDM_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Failed to read from channel %s device %d:%d!\n", name, span_id, chan_id); - } - - *frame = &tech_pvt->read_frame; - tech_pvt->read_frame.datalen = (uint32_t)len; - tech_pvt->read_frame.samples = tech_pvt->read_frame.datalen; - tech_pvt->read_frame.codec = &tech_pvt->read_codec; - - if (ftdm_channel_get_codec(tech_pvt->ftdm_channel) == FTDM_CODEC_SLIN) { - tech_pvt->read_frame.samples /= 2; - } - - while (ftdm_channel_dequeue_dtmf(tech_pvt->ftdm_channel, dtmf, sizeof(dtmf))) { - switch_dtmf_t _dtmf = { 0, switch_core_default_dtmf_duration(0) }; - char *p; - for (p = dtmf; p && *p; p++) { - if (is_dtmf(*p)) { - _dtmf.digit = *p; - ftdm_log(FTDM_LOG_DEBUG, "Queuing DTMF [%c] in channel %s device %d:%d\n", *p, name, span_id, chan_id); - switch_channel_queue_dtmf(channel, &_dtmf); - } - } - } - - return SWITCH_STATUS_SUCCESS; - -fail: - return SWITCH_STATUS_GENERR; -} - -static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id) -{ - ftdm_wait_flag_t wflags = FTDM_WRITE; - ctdm_private_t *tech_pvt; - const char *name; - switch_channel_t *channel; - uint32_t span_id, chan_id; - ftdm_size_t len; - unsigned char data[SWITCH_RECOMMENDED_BUFFER_SIZE] = {0}; - - channel = switch_core_session_get_channel(session); - assert(channel != NULL); - - tech_pvt = switch_core_session_get_private(session); - assert(tech_pvt != NULL); - - span_id = ftdm_channel_get_span_id(tech_pvt->ftdm_channel); - chan_id = ftdm_channel_get_id(tech_pvt->ftdm_channel); - - name = switch_channel_get_name(channel); - - if (switch_test_flag(frame, SFF_CNG)) { - frame->data = data; - frame->buflen = sizeof(data); - if ((frame->datalen = tech_pvt->write_codec.implementation->encoded_bytes_per_packet) > frame->buflen) { - goto fail; - } - memset(data, 255, frame->datalen); - } - - wflags = FTDM_WRITE; - ftdm_channel_wait(tech_pvt->ftdm_channel, &wflags, ftdm_channel_get_io_interval(tech_pvt->ftdm_channel) * 10); - - if (!(wflags & FTDM_WRITE)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Dropping frame! (write not ready) in channel %s device %d:%d!\n", name, span_id, chan_id); - return SWITCH_STATUS_SUCCESS; - } - - len = frame->datalen; - if (ftdm_channel_write(tech_pvt->ftdm_channel, frame->data, frame->buflen, &len) != FTDM_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Failed to write to channel %s device %d:%d!\n", name, span_id, chan_id); - } - - return SWITCH_STATUS_SUCCESS; - -fail: - return SWITCH_STATUS_GENERR; -} - -static switch_status_t channel_send_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf) -{ - ctdm_private_t *tech_pvt = NULL; - char tmp[2] = ""; - - tech_pvt = switch_core_session_get_private(session); - assert(tech_pvt != NULL); - - tmp[0] = dtmf->digit; - ftdm_channel_command(tech_pvt->ftdm_channel, FTDM_COMMAND_SEND_DTMF, tmp); - - return SWITCH_STATUS_SUCCESS; -} - -static switch_status_t channel_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg) -{ - return SWITCH_STATUS_SUCCESS; -} - -static switch_status_t channel_receive_event(switch_core_session_t *session, switch_event_t *event) -{ - const char *command = switch_event_get_header(event, "command"); - ctdm_private_t *tech_pvt = switch_core_session_get_private(session); - - if (!zstr(command)) { - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "FreeTDM received %s command \n",command); - - if (!strcasecmp(command, kPREBUFFER_LEN)) { - const char *szval = switch_event_get_header(event, kPREBUFFER_LEN); - int val = !zstr(szval) ? atoi(szval) : 0; - - if (tech_pvt->prebuffer_len == val) { - tech_pvt->prebuffer_len = val; - if (FTDM_SUCCESS != ftdm_channel_command(tech_pvt->ftdm_channel, FTDM_COMMAND_SET_PRE_BUFFER_SIZE, &tech_pvt->prebuffer_len)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to set channel pre buffer size.\n"); - return SWITCH_STATUS_GENERR; - } - } - } else if (!strcasecmp(command, kECHOCANCEL)) { - const char *szval = switch_event_get_header(event, kECHOCANCEL); - int enabled = !!switch_true(szval); - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "FreeTDM sending echo cancel [%s] command \n",enabled ? "enable" : "disable"); - - if (FTDM_SUCCESS != ftdm_channel_command(tech_pvt->ftdm_channel, enabled ? FTDM_COMMAND_ENABLE_ECHOCANCEL : FTDM_COMMAND_DISABLE_ECHOCANCEL, NULL)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Failed to %s echo cancellation.\n", enabled ? "enable" : "disable"); - } - - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "FreeTDM received unknown command [%s] \n",command); - } - } - - return SWITCH_STATUS_SUCCESS; -} - diff --git a/libs/freetdm/msvc/freetdm.2008.vcproj b/libs/freetdm/msvc/freetdm.2008.vcproj deleted file mode 100644 index 46594bf38c..0000000000 --- a/libs/freetdm/msvc/freetdm.2008.vcproj +++ /dev/null @@ -1,499 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/freetdm/msvc/freetdm.2010.vcxproj.filters b/libs/freetdm/msvc/freetdm.2010.vcxproj.filters deleted file mode 100644 index 9f15c9c737..0000000000 --- a/libs/freetdm/msvc/freetdm.2010.vcxproj.filters +++ /dev/null @@ -1,137 +0,0 @@ - - - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - diff --git a/libs/freetdm/msvc/openzap.2005.vcproj b/libs/freetdm/msvc/openzap.2005.vcproj deleted file mode 100644 index 85d4a89206..0000000000 --- a/libs/freetdm/msvc/openzap.2005.vcproj +++ /dev/null @@ -1,301 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/freetdm/msvc/testanalog/testanalog.2005.vcproj b/libs/freetdm/msvc/testanalog/testanalog.2005.vcproj deleted file mode 100644 index 93553d2a5f..0000000000 --- a/libs/freetdm/msvc/testanalog/testanalog.2005.vcproj +++ /dev/null @@ -1,193 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/freetdm/msvc/testanalog/testanalog.2008.vcproj b/libs/freetdm/msvc/testanalog/testanalog.2008.vcproj deleted file mode 100644 index 24f418ab19..0000000000 --- a/libs/freetdm/msvc/testanalog/testanalog.2008.vcproj +++ /dev/null @@ -1,349 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/freetdm/msvc/testanalog/testanalog.2010.vcxproj.filters b/libs/freetdm/msvc/testanalog/testanalog.2010.vcxproj.filters deleted file mode 100644 index 7ac3635cc5..0000000000 --- a/libs/freetdm/msvc/testanalog/testanalog.2010.vcxproj.filters +++ /dev/null @@ -1,14 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - Source Files - - - \ No newline at end of file diff --git a/libs/freetdm/msvc/testboost/testboost.2008.vcproj b/libs/freetdm/msvc/testboost/testboost.2008.vcproj deleted file mode 100644 index c273b3c02b..0000000000 --- a/libs/freetdm/msvc/testboost/testboost.2008.vcproj +++ /dev/null @@ -1,354 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/freetdm/msvc/testboost/testboost.2010.vcxproj.filters b/libs/freetdm/msvc/testboost/testboost.2010.vcxproj.filters deleted file mode 100644 index 74181d60a8..0000000000 --- a/libs/freetdm/msvc/testboost/testboost.2010.vcxproj.filters +++ /dev/null @@ -1,14 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - Source Files - - - \ No newline at end of file diff --git a/libs/freetdm/msvc/testboost/testsangomaboost.2008.vcproj b/libs/freetdm/msvc/testboost/testsangomaboost.2008.vcproj deleted file mode 100644 index 77ca1594df..0000000000 --- a/libs/freetdm/msvc/testboost/testsangomaboost.2008.vcproj +++ /dev/null @@ -1,354 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/freetdm/msvc/testboost/testsangomaboost.2010.vcxproj.filters b/libs/freetdm/msvc/testboost/testsangomaboost.2010.vcxproj.filters deleted file mode 100644 index e72f14e161..0000000000 --- a/libs/freetdm/msvc/testboost/testsangomaboost.2010.vcxproj.filters +++ /dev/null @@ -1,14 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - Source Files - - - \ No newline at end of file diff --git a/libs/freetdm/msvc/testisdn/testisdn.2005.vcproj b/libs/freetdm/msvc/testisdn/testisdn.2005.vcproj deleted file mode 100644 index 133557166b..0000000000 --- a/libs/freetdm/msvc/testisdn/testisdn.2005.vcproj +++ /dev/null @@ -1,193 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/freetdm/msvc/testisdn/testisdn.2008.vcproj b/libs/freetdm/msvc/testisdn/testisdn.2008.vcproj deleted file mode 100644 index 86698ec3e4..0000000000 --- a/libs/freetdm/msvc/testisdn/testisdn.2008.vcproj +++ /dev/null @@ -1,349 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/freetdm/msvc/testisdn/testisdn.2010.vcxproj.filters b/libs/freetdm/msvc/testisdn/testisdn.2010.vcxproj.filters deleted file mode 100644 index 9d48828d4a..0000000000 --- a/libs/freetdm/msvc/testisdn/testisdn.2010.vcxproj.filters +++ /dev/null @@ -1,14 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - Source Files - - - \ No newline at end of file diff --git a/libs/freetdm/sample/CMakeLists.txt b/libs/freetdm/sample/CMakeLists.txt deleted file mode 100644 index 9baf1bdf16..0000000000 --- a/libs/freetdm/sample/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -# -# Arnaldo M Pereira -# -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(sample) - -#ADD_SUBDIRECTORY(sched) FIXME: this code doesnt compile diff --git a/libs/freetdm/sample/dso/CMakeLists.txt b/libs/freetdm/sample/dso/CMakeLists.txt deleted file mode 100644 index defcc5c7f5..0000000000 --- a/libs/freetdm/sample/dso/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -# -# Arnaldo M Pereira -# -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(dso) - -IF(NOT DEFINED WIN32) - INCLUDE_DIRECTORIES(/usr/local/freeswitch/include) - ADD_DEFINITIONS(-Wall) - ADD_EXECUTABLE(ftdmload ftdmload.c) - TARGET_LINK_LIBRARIES(ftdmload freetdm) -ENDIF(NOT DEFINED WIN32) diff --git a/libs/freetdm/sample/dso/Makefile b/libs/freetdm/sample/dso/Makefile deleted file mode 100644 index 51067191d2..0000000000 --- a/libs/freetdm/sample/dso/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -CC=gcc -CFLAGS=-Wall -I/usr/local/freeswitch/include -LDFLAGS=-L/usr/local/freeswitch/lib -lfreetdm - -ftdmload: ftdmload.o - -clean: - rm -rf ftdmload.o - rm -rf ftdmload - -export: - export LD_LIBRARY_PATH=/usr/local/freeswitch/lib - - diff --git a/libs/freetdm/sample/dso/ftdmload.c b/libs/freetdm/sample/dso/ftdmload.c deleted file mode 100644 index 80bcc02fc0..0000000000 --- a/libs/freetdm/sample/dso/ftdmload.c +++ /dev/null @@ -1,168 +0,0 @@ -#define _GNU_SOURCE -#include -#include -#include -#include -#include -#include - -#define ARRLEN(obj) (sizeof(obj)/sizeof(obj[0])) - -struct dso_entry { - char name[25]; - ftdm_dso_lib_t lib; -}; - -struct dso_entry loaded[10]; - -static void *(*real_dlopen)(const char *filename, int flag) = NULL; -static int (*real_dlclose)(void *handle) = NULL; - -static void print_stack() -{ - void *stacktrace[100]; - char **symbols; - int size; - int i; - size = backtrace(stacktrace, ARRLEN(stacktrace)); - symbols = backtrace_symbols(stacktrace, size); - if (!symbols) { - return; - } - for (i = 0; i < size; i++) { - ftdm_log(FTDM_LOG_DEBUG, "%s\n", symbols[i]); - } - free(symbols); -} - -void *dlopen(const char *filename, int flag) -{ - char *msg = NULL; - void *handle = NULL; - print_stack(); - if (real_dlopen == NULL) { - dlerror(); - real_dlopen = dlsym(RTLD_NEXT, "dlopen"); - if ((msg = dlerror()) != NULL) { - fprintf(stderr, "dlsym failed: %s\n", msg); - exit(1); - } - fprintf(stderr, "Real dlopen at addr %p\n", real_dlopen); - } - handle = real_dlopen(filename, flag); - if (!handle) { - return NULL; - } - ftdm_log(FTDM_LOG_NOTICE, "Loaded %s with handle %p\n", filename, handle); - return handle; -} - -int dlclose(void *handle) -{ - char *msg = NULL; - print_stack(); - if (real_dlclose == NULL) { - dlerror(); - real_dlclose = dlsym(RTLD_NEXT, "dlclose"); - if ((msg = dlerror()) != NULL) { - fprintf(stderr, "dlsym failed: %s\n", msg); - exit(1); - } - fprintf(stderr, "Real dlclose at addr %p\n", real_dlclose); - } - ftdm_log(FTDM_LOG_NOTICE, "Unloading %p\n", handle); - return real_dlclose(handle); -} - -int load(char *name) -{ - char path[255]; - char *err; - struct dso_entry *entry = NULL; - int i; - - for (i = 0; i < ARRLEN(loaded); i++) { - if (!loaded[i].lib) { - entry = &loaded[i]; - break; - } - } - - if (!entry) { - ftdm_log(FTDM_LOG_CRIT, "Cannot load more libraries\n"); - return -1; - } - - ftdm_build_dso_path(name, path, sizeof(path)); - ftdm_log(FTDM_LOG_DEBUG, "Loading %s!\n", path); - entry->lib = ftdm_dso_open(path, &err); - if (!entry->lib) { - ftdm_log(FTDM_LOG_CRIT, "Cannot load library '%s': %s\n", path, err); - return -1; - } - strncpy(entry->name, name, sizeof(entry->name)-1); - entry->name[sizeof(entry->name)-1] = 0; - return 0; -} - -int unload(char *name) -{ - int i; - struct dso_entry *entry = NULL; - ftdm_log(FTDM_LOG_DEBUG, "Unloading %s!\n", name); - for (i = 0; i < ARRLEN(loaded); i++) { - if (loaded[i].lib && !strcasecmp(loaded[i].name, name)) { - entry = &loaded[i]; - break; - } - } - - if (!entry) { - ftdm_log(FTDM_LOG_CRIT, "Library %s not found\n", name); - return -1; - } - - ftdm_dso_destroy(&entry->lib); - entry->lib = NULL; - return 0; -} - -int main(int argc, char *argv[]) -{ - char cmdline[255]; - char name[255]; - - ftdm_global_set_default_logger(FTDM_LOG_LEVEL_DEBUG); - - if (ftdm_global_init() != FTDM_SUCCESS) { - fprintf(stderr, "Error loading FreeTDM\n"); - exit(-1); - } - - memset(loaded, 0, sizeof(loaded)); - - printf("CLI> "); - while (fgets(cmdline, sizeof(cmdline), stdin)) { - if (sscanf(cmdline, "load=%s\n", name) == 1) { - load(name); - } else if (sscanf(cmdline, "unload=%s\n", name) == 1) { - unload(name); - } else if (!strncasecmp(cmdline, "exit", sizeof("exit")-1)) { - printf("Quitting ...\n"); - sleep(1); - break; - } else { - fprintf(stderr, "load= | unload= | exit\n"); - } - printf("\nCLI> "); - } - - - ftdm_global_destroy(); - - printf("Done, press any key to die!\n"); - - getchar(); - return 0; -} - diff --git a/libs/freetdm/sample/sched/CMakeLists.txt b/libs/freetdm/sample/sched/CMakeLists.txt deleted file mode 100644 index d769925be0..0000000000 --- a/libs/freetdm/sample/sched/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -# -# Arnaldo M Pereira -# -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(sched) - -IF(NOT DEFINED WIN32) - INCLUDE_DIRECTORIES(/usr/local/freeswitch/include) - ADD_DEFINITIONS(-Wall) - ADD_EXECUTABLE(ftdmsched ftdmsched.c) - TARGET_LINK_LIBRARIES(ftdmsched freetdm) -ENDIF(NOT DEFINED WIN32) diff --git a/libs/freetdm/sample/sched/ftdmsched.c b/libs/freetdm/sample/sched/ftdmsched.c deleted file mode 100644 index e6e391ee4b..0000000000 --- a/libs/freetdm/sample/sched/ftdmsched.c +++ /dev/null @@ -1,110 +0,0 @@ -#define _GNU_SOURCE -#include -#include -#include -#include "../../src/include/private/ftdm_core.h" - -static int running = 1; - -typedef struct custom_data { - ftdm_timer_t *heartbeat_timer; - int beat; - int counter; - ftdm_sched_callback_t callback; - ftdm_sched_t *sched; -} custom_data_t; - -void trap(int signal) -{ - running = 0; -} - -void handle_heartbeat(void *usrdata) -{ - ftdm_status_t status; - custom_data_t *data = usrdata; - - printf("beep (elapsed %dms count= %d)\n", data->beat, data->counter); - if (data->beat > 1000) { - data->beat -= 1000; - } else if (data->beat <= 1000 && data->beat > 200) { - data->beat -= 100; - } else if (data->beat <= 200 && data->beat > 100) { - if (!data->counter--) { - data->counter = 5; - data->beat -= 100; - } - } else if (data->beat <= 100 && data->beat > 10) { - if (!data->counter--) { - data->counter = 10; - data->beat -= 10; - if (data->beat == 10) { - data->counter = 200; - } - } - } else { - if (!data->counter--) { - data->counter = 5; - data->beat--; - } - } - - if (!data->beat) { - printf("beeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeep you're dead!\n"); - return; - } - - data->heartbeat_timer = NULL; - status = ftdm_sched_timer(data->sched, "heartbeat", data->beat, data->callback, data, &data->heartbeat_timer); - if (status != FTDM_SUCCESS) { - fprintf(stderr, "Error creating heartbeat timer\n"); - running = 0; - return; - } -} - -int main(int argc, char *argv[]) -{ - ftdm_status_t status; - custom_data_t data; - - ftdm_sched_t *sched; - signal(SIGINT, trap); - - ftdm_global_set_default_logger(FTDM_LOG_LEVEL_DEBUG); - - if (ftdm_global_init() != FTDM_SUCCESS) { - fprintf(stderr, "Error loading FreeTDM\n"); - exit(-1); - } - - status = ftdm_sched_create(&sched, "testsched"); - if (status != FTDM_SUCCESS) { - fprintf(stderr, "Error creating sched\n"); - exit(-1); - } - - data.sched = sched; - data.counter = 10; - data.beat = 5000; - data.callback = handle_heartbeat; - status = ftdm_sched_timer(sched, "heartbeat", data.beat, data.callback, &data, &data.heartbeat_timer); - if (status != FTDM_SUCCESS) { - fprintf(stderr, "Error creating heartbeat timer\n"); - exit(-1); - } - - ftdm_sched_free_run(sched); - - while (running) { - ftdm_sleep(10); - } - - ftdm_global_destroy(); - - printf("Done, press any key to die!\n"); - - getchar(); - return 0; -} - diff --git a/libs/freetdm/src/detect_dtmf.c b/libs/freetdm/src/detect_dtmf.c deleted file mode 100644 index 34335256f0..0000000000 --- a/libs/freetdm/src/detect_dtmf.c +++ /dev/null @@ -1,54 +0,0 @@ -//#include "freetdm.h" -#include "libteletone_detect.h" - -int main(int argc, char *argv[]) -{ - int fd, b; - short sln[512] = {0}; - teletone_dtmf_detect_state_t dtmf_detect = {0}; - teletone_hit_type_t hit; - - if (argc < 2) { - fprintf(stderr, "Arg Error!\n"); - exit(-1); - } - - teletone_dtmf_detect_init (&dtmf_detect, 8000); - - if ((fd = open(argv[1], O_RDONLY)) < 0) { - fprintf(stderr, "File Error! [%s]\n", strerror(errno)); - exit(-1); - } - - while((b = read(fd, sln, 320)) > 0) { - char digit_char; - unsigned int dur; - - teletone_dtmf_detect(&dtmf_detect, sln, b / 2); - if ((hit = teletone_dtmf_get(&dtmf_detect, &digit_char, &dur))) { - const char *hs = NULL; - - - switch(hit) { - case TT_HIT_BEGIN: - hs = "begin"; - break; - - case TT_HIT_MIDDLE: - hs = "middle"; - break; - - case TT_HIT_END: - hs = "end"; - break; - default: - break; - } - - printf("%s digit: %c\n", hs, digit_char); - } - } - close(fd); - return 0; -} - diff --git a/libs/freetdm/src/detect_tones.c b/libs/freetdm/src/detect_tones.c deleted file mode 100644 index 5cd52d4d99..0000000000 --- a/libs/freetdm/src/detect_tones.c +++ /dev/null @@ -1,32 +0,0 @@ -//#include "freetdm.h" -#include "libteletone_detect.h" - -int main(int argc, char *argv[]) -{ - teletone_multi_tone_t mt = {0}; - teletone_tone_map_t map = {{0}}; - - int fd, b; - short sln[512] = {0}; - - if (argc < 2) { - fprintf(stderr, "Arg Error!\n"); - exit(-1); - } - - map.freqs[0] = atof("350"); - map.freqs[1] = atof("440"); - teletone_multi_tone_init(&mt, &map); - - if ((fd = open(argv[1], O_RDONLY)) < 0) { - fprintf(stderr, "File Error! [%s]\n", strerror(errno)); - exit(-1); - } - - while((b = read(fd, sln, 320)) > 0) { - printf("TEST %d %d\n", b, teletone_multi_tone_detect(&mt, sln, b / 2)); - } - close(fd); - return 0; -} - diff --git a/libs/freetdm/src/fsk.c b/libs/freetdm/src/fsk.c deleted file mode 100644 index 9e6f97287e..0000000000 --- a/libs/freetdm/src/fsk.c +++ /dev/null @@ -1,351 +0,0 @@ - -/* - * bell202.c - * - * Copyright (c) 2005 Robert Krten. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This module contains a Bell-202 1200-baud FSK decoder, suitable for - * use in a library. The general style of the library calls is modeled - * after the POSIX pthread_*() functions. - * - * 2005 03 20 R. Krten created -*/ -#include -#include -#include -#include -#include -#include - -#include "fsk.h" -#include "uart.h" - -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - -fsk_modem_definition_t fsk_modem_definitions[] = -{ - { /* FSK_V23_FORWARD_MODE1 */ 1700, 1300, 600 }, - { /* FSK_V23_FORWARD_MODE2 */ 2100, 1300, 1200 }, - { /* FSK_V23_BACKWARD */ 450, 390, 75 }, - { /* FSK_BELL202 */ 2200, 1200, 1200 }, -}; - -/* - * dsp_fsk_attr_init - * - * Initializes the attributes structure; this must be done before the - * attributes structure is used. -*/ - -void dsp_fsk_attr_init (dsp_fsk_attr_t *attr) -{ - memset(attr, 0, sizeof(*attr)); -} - -/* - * dsp_fsk_attr_get_bithandler - * dsp_fsk_attr_set_bithandler - * dsp_fsk_attr_get_bytehandler - * dsp_fsk_attr_set_bytehandler - * dsp_fsk_attr_getsamplerate - * dsp_fsk_attr_setsamplerate - * - * These functions get and set their respective elements from the - * attributes structure. If an error code is returned, it is just - * zero == ok, -1 == fail. -*/ - -bithandler_func_t dsp_fsk_attr_get_bithandler(dsp_fsk_attr_t *attr, void **bithandler_arg) -{ - *bithandler_arg = attr->bithandler_arg; - return attr->bithandler; -} - -void dsp_fsk_attr_set_bithandler(dsp_fsk_attr_t *attr, bithandler_func_t bithandler, void *bithandler_arg) -{ - attr->bithandler = bithandler; - attr->bithandler_arg = bithandler_arg; -} - -bytehandler_func_t dsp_fsk_attr_get_bytehandler(dsp_fsk_attr_t *attr, void **bytehandler_arg) -{ - *bytehandler_arg = attr->bytehandler_arg; - return attr->bytehandler; -} - -void dsp_fsk_attr_set_bytehandler(dsp_fsk_attr_t *attr, bytehandler_func_t bytehandler, void *bytehandler_arg) -{ - attr->bytehandler = bytehandler; - attr->bytehandler_arg = bytehandler_arg; -} - -int dsp_fsk_attr_get_samplerate (dsp_fsk_attr_t *attr) -{ - return attr->sample_rate; -} - -int dsp_fsk_attr_set_samplerate (dsp_fsk_attr_t *attr, int samplerate) -{ - if (samplerate <= 0) { - return -1; - } - attr->sample_rate = samplerate; - return 0; -} - -/* - * dsp_fsk_create - * - * Creates a handle for subsequent use. The handle is created to contain - * a context data structure for use by the sample handler function. The - * function expects an initialized attributes structure, and returns the - * handle or a NULL if there were errors. - * - * Once created, the handle can be used until it is destroyed. -*/ - -dsp_fsk_handle_t *dsp_fsk_create(dsp_fsk_attr_t *attr) -{ - int i; - double phi_mark, phi_space; - dsp_fsk_handle_t *handle; - - handle = ftdm_malloc(sizeof(*handle)); - if (!handle) { - return NULL; - } - - memset(handle, 0, sizeof(*handle)); - - /* fill the attributes member */ - memcpy(&handle->attr, attr, sizeof(*attr)); - - /* see if we can do downsampling. We only really need 6 samples to "match" */ - if (attr->sample_rate / fsk_modem_definitions[FSK_BELL202].freq_mark > 6) { - handle->downsampling_count = attr->sample_rate / fsk_modem_definitions[FSK_BELL202].freq_mark / 6; - } else { - handle->downsampling_count = 1; - } - handle->current_downsample = 1; - - /* calculate the correlate size (number of samples required for slowest wave) */ - handle->corrsize = attr->sample_rate / handle->downsampling_count / fsk_modem_definitions[FSK_BELL202].freq_mark; - - /* allocate the correlation sin/cos arrays and initialize */ - for (i = 0; i < 4; i++) { - handle->correlates[i] = ftdm_malloc(sizeof(double) * handle->corrsize); - if (handle->correlates[i] == NULL) { - /* some failed, back out memory allocations */ - dsp_fsk_destroy(&handle); - return NULL; - } - } - - /* now initialize them */ - phi_mark = 2. * M_PI / ((double) attr->sample_rate / (double) handle->downsampling_count / (double) fsk_modem_definitions[FSK_BELL202].freq_mark); - phi_space = 2. * M_PI / ((double) attr->sample_rate / (double) handle->downsampling_count / (double) fsk_modem_definitions[FSK_BELL202].freq_space); - - for (i = 0; i < handle->corrsize; i++) { - handle->correlates[0][i] = sin(phi_mark * (double) i); - handle->correlates[1][i] = cos(phi_mark * (double) i); - handle->correlates[2][i] = sin(phi_space * (double) i); - handle->correlates[3][i] = cos(phi_space * (double) i); - } - - /* initialize the ring buffer */ - handle->buffer = ftdm_malloc(sizeof(double) * handle->corrsize); - if (!handle->buffer) { /* failed; back out memory allocations */ - dsp_fsk_destroy(&handle); - return NULL; - } - memset(handle->buffer, 0, sizeof(double) * handle->corrsize); - handle->ringstart = 0; - - /* initalize intra-cell position */ - handle->cellpos = 0; - handle->celladj = fsk_modem_definitions[FSK_BELL202].baud_rate / (double) attr->sample_rate * (double) handle->downsampling_count; - - /* if they have provided a byte handler, add a UART to the processing chain */ - if (handle->attr.bytehandler) { - dsp_uart_attr_t uart_attr; - dsp_uart_handle_t *uart_handle; - - dsp_uart_attr_init(&uart_attr); - dsp_uart_attr_set_bytehandler(&uart_attr, handle->attr.bytehandler, handle->attr.bytehandler_arg); - uart_handle = dsp_uart_create(&uart_attr); - if (uart_handle == NULL) { - dsp_fsk_destroy(&handle); - return NULL; - } - handle->attr.bithandler = dsp_uart_bit_handler; - handle->attr.bithandler_arg = uart_handle; - } - - return handle; -} - -/* - * dsp_fsk_destroy - * - * Destroys a handle, releasing any associated memory. Sets handle pointer to NULL - * so A destroyed handle can not be used for anything after the destroy. -*/ - -void dsp_fsk_destroy(dsp_fsk_handle_t **handle) -{ - int i; - - /* if empty handle, just return */ - if (*handle == NULL) { - return; - } - - for (i = 0; i < 4; i++) { - if ((*handle)->correlates[i] != NULL) { - ftdm_safe_free((*handle)->correlates[i]); - (*handle)->correlates[i] = NULL; - } - } - - if ((*handle)->buffer != NULL) { - ftdm_safe_free((*handle)->buffer); - (*handle)->buffer = NULL; - } - - if ((*handle)->attr.bytehandler) { - dsp_uart_handle_t** dhandle = (void *)(&(*handle)->attr.bithandler_arg); - dsp_uart_destroy(dhandle); - } - - ftdm_safe_free(*handle); - *handle = NULL; -} - -/* - * dsp_fsk_sample - * - * This is the main processing entry point. The function accepts a normalized - * sample (i.e., one whose range is between -1 and +1). The function performs - * the Bell-202 FSK modem decode processing, and, if it detects a valid bit, - * will call the bithandler associated with the attributes structure. - * - * For the Bell-202 standard, a logical zero (space) is 2200 Hz, and a logical - * one (mark) is 1200 Hz. -*/ - -void -dsp_fsk_sample (dsp_fsk_handle_t *handle, double normalized_sample) -{ - double val; - double factors[4]; - int i, j; - - /* if we can avoid processing samples, do so */ - if (handle->downsampling_count != 1) { - if (handle->current_downsample < handle->downsampling_count) { - handle->current_downsample++; - return; /* throw this sample out */ - } - handle->current_downsample = 1; - } - - /* store sample in buffer */ - handle->buffer[handle->ringstart++] = normalized_sample; - if (handle->ringstart >= handle->corrsize) { - handle->ringstart = 0; - } - - /* do the correlation calculation */ - factors[0] = factors[1] = factors[2] = factors[3] = 0; /* clear out intermediate sums */ - j = handle->ringstart; - for (i = 0; i < handle->corrsize; i++) { - if (j >= handle->corrsize) { - j = 0; - } - val = handle->buffer[j]; - factors[0] += handle->correlates[0][i] * val; - factors[1] += handle->correlates[1][i] * val; - factors[2] += handle->correlates[2][i] * val; - factors[3] += handle->correlates[3][i] * val; - j++; - } - - /* store the bit (bit value is comparison of the two sets of correlate factors) */ - handle->previous_bit = handle->current_bit; - handle->current_bit = (factors[0] * factors[0] + factors[1] * factors[1] > factors[2] * factors[2] + factors[3] * factors[3]); - - /* if there's a transition, we can synchronize the cell position */ - if (handle->previous_bit != handle->current_bit) { - handle->cellpos = 0.5; /* adjust cell position to be in the middle of the cell */ - } - handle->cellpos += handle->celladj; /* walk the cell along */ - - if (handle->cellpos > 1.0) { - handle->cellpos -= 1.0; - - switch (handle->state) { - case FSK_STATE_DATA: - { - - (*handle->attr.bithandler) (handle->attr.bithandler_arg, handle->current_bit); - } - break; - case FSK_STATE_CHANSEIZE: - { - - if (handle->last_bit != handle->current_bit) { - handle->conscutive_state_bits++; - } else { - handle->conscutive_state_bits = 0; - } - - if (handle->conscutive_state_bits > 15) { - handle->state = FSK_STATE_CARRIERSIG; - handle->conscutive_state_bits = 0; - } - } - break; - case FSK_STATE_CARRIERSIG: - { - if (handle->current_bit) { - handle->conscutive_state_bits++; - } else { - handle->conscutive_state_bits = 0; - } - - if (handle->conscutive_state_bits > 15) { - handle->state = FSK_STATE_DATA; - handle->conscutive_state_bits = 0; - } - } - break; - } - - handle->last_bit = handle->current_bit; - } -} - diff --git a/libs/freetdm/src/ftdm_backtrace.c b/libs/freetdm/src/ftdm_backtrace.c deleted file mode 100644 index 8f6756d939..0000000000 --- a/libs/freetdm/src/ftdm_backtrace.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * - * - */ -#ifndef _DEFAULT_SOURCE -#define _DEFAULT_SOURCE -#endif -#define _BSD_SOURCE -#include "private/ftdm_core.h" - -#if defined(HAVE_EXECINFO_H) && !defined(__FreeBSD__) -#include -#include -#include -#include - -#define FTDM_BACKTRACE_MAX 50 - -FT_DECLARE(ftdm_status_t) ftdm_backtrace_walk(void (* callback)(const int tid, const void *addr, const char *symbol, void *priv), void *priv) -{ - void *stacktrace[FTDM_BACKTRACE_MAX]; - char **symbols = NULL; - size_t size = 0; - pid_t tid = 0; - int si = 0; - - if (!callback) { - return FTDM_EINVAL; - } - - tid = syscall(SYS_gettid); - - size = backtrace(stacktrace, ftdm_array_len(stacktrace)); - symbols = backtrace_symbols(stacktrace, size); - - for (si = 0; si < size; si++) { - callback(tid, stacktrace[si], symbols[si], priv); - } - - free(symbols); - return FTDM_SUCCESS; -} - -#else /* !HAVE_EXECINFO_H */ - -FT_DECLARE(ftdm_status_t) ftdm_backtrace_walk(void (* callback)(const int tid, const void *addr, const char *symbol, void *priv), void *priv) -{ - ftdm_log(FTDM_LOG_DEBUG, "Stack traces are not available on this platform!\n"); - return FTDM_NOTIMPL; -} - -#endif - - -static void span_backtrace(const int tid, const void *addr, const char *symbol, void *priv) -{ - ftdm_span_t *span = priv; - ftdm_log(FTDM_LOG_DEBUG, "[%d][tid:%d] %p -> %s\n", - ftdm_span_get_id(span), tid, addr, symbol); -} - -FT_DECLARE(ftdm_status_t) ftdm_backtrace_span(ftdm_span_t *span) -{ - return ftdm_backtrace_walk(&span_backtrace, span); -} - - -static void chan_backtrace(const int tid, const void *addr, const char *symbol, void *priv) -{ - ftdm_channel_t *chan = priv; - ftdm_log(FTDM_LOG_DEBUG, "[%d:%d][tid:%d] %p -> %s\n", - ftdm_channel_get_span_id(chan), ftdm_channel_get_id(chan), tid, addr, symbol); -} - -FT_DECLARE(ftdm_status_t) ftdm_backtrace_chan(ftdm_channel_t *chan) -{ - return ftdm_backtrace_walk(&chan_backtrace, chan); -} diff --git a/libs/freetdm/src/ftdm_buffer.c b/libs/freetdm/src/ftdm_buffer.c deleted file mode 100644 index 42d5fbaec6..0000000000 --- a/libs/freetdm/src/ftdm_buffer.c +++ /dev/null @@ -1,308 +0,0 @@ -/* - * Copyright (c) 2007-2014, Anthony Minessale II - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "private/ftdm_core.h" -#include "ftdm_buffer.h" - -static unsigned buffer_id = 0; - -struct ftdm_buffer { - unsigned char *data; - unsigned char *head; - ftdm_size_t used; - ftdm_size_t actually_used; - ftdm_size_t datalen; - ftdm_size_t max_len; - ftdm_size_t blocksize; - unsigned id; - int loops; -}; - - -FT_DECLARE(ftdm_status_t) ftdm_buffer_create(ftdm_buffer_t **buffer, ftdm_size_t blocksize, ftdm_size_t start_len, ftdm_size_t max_len) -{ - ftdm_buffer_t *new_buffer; - - new_buffer = ftdm_malloc(sizeof(*new_buffer)); - if (new_buffer) { - memset(new_buffer, 0, sizeof(*new_buffer)); - - if (!start_len) { - start_len = 250; - } - - if (!blocksize) { - blocksize = start_len; - } - - new_buffer->data = ftdm_malloc(start_len); - if (!new_buffer->data) { - ftdm_safe_free(new_buffer); - return FTDM_MEMERR; - } - memset(new_buffer->data, 0, start_len); - - new_buffer->max_len = max_len; - new_buffer->datalen = start_len; - new_buffer->id = buffer_id++; - new_buffer->blocksize = blocksize; - new_buffer->head = new_buffer->data; - - *buffer = new_buffer; - return FTDM_SUCCESS; - } - - return FTDM_MEMERR; -} - -FT_DECLARE(ftdm_size_t) ftdm_buffer_len(ftdm_buffer_t *buffer) -{ - - assert(buffer != NULL); - - return buffer->datalen; - -} - - -FT_DECLARE(ftdm_size_t) ftdm_buffer_freespace(ftdm_buffer_t *buffer) -{ - assert(buffer != NULL); - - - if (buffer->max_len) { - return (ftdm_size_t) (buffer->max_len - buffer->used); - } - return 1000000; - -} - -FT_DECLARE(ftdm_size_t) ftdm_buffer_inuse(ftdm_buffer_t *buffer) -{ - assert(buffer != NULL); - - return buffer->used; -} - -FT_DECLARE(ftdm_size_t) ftdm_buffer_seek(ftdm_buffer_t *buffer, ftdm_size_t datalen) -{ - ftdm_size_t reading = 0; - - assert(buffer != NULL); - - if (buffer->used < 1) { - buffer->used = 0; - return 0; - } else if (buffer->used >= datalen) { - reading = datalen; - } else { - reading = buffer->used; - } - - buffer->used = buffer->actually_used - reading; - buffer->head = buffer->data + reading; - - return reading; -} - -FT_DECLARE(ftdm_size_t) ftdm_buffer_toss(ftdm_buffer_t *buffer, ftdm_size_t datalen) -{ - ftdm_size_t reading = 0; - - assert(buffer != NULL); - - if (buffer->used < 1) { - buffer->used = 0; - return 0; - } else if (buffer->used >= datalen) { - reading = datalen; - } else { - reading = buffer->used; - } - - buffer->used -= reading; - buffer->head += reading; - - return buffer->used; -} - -FT_DECLARE(void) ftdm_buffer_set_loops(ftdm_buffer_t *buffer, int loops) -{ - buffer->loops = loops; -} - -FT_DECLARE(ftdm_size_t) ftdm_buffer_read_loop(ftdm_buffer_t *buffer, void *data, ftdm_size_t datalen) -{ - ftdm_size_t len; - if ((len = ftdm_buffer_read(buffer, data, datalen)) < datalen) { - if (buffer->loops == 0) { - return len; - } - buffer->head = buffer->data; - buffer->used = buffer->actually_used; - len = ftdm_buffer_read(buffer, (char*)data + len, datalen - len); - buffer->loops--; - } - return len; -} - -FT_DECLARE(ftdm_size_t) ftdm_buffer_read(ftdm_buffer_t *buffer, void *data, ftdm_size_t datalen) -{ - ftdm_size_t reading = 0; - - assert(buffer != NULL); - assert(data != NULL); - - - if (buffer->used < 1) { - buffer->used = 0; - return 0; - } else if (buffer->used >= datalen) { - reading = datalen; - } else { - reading = buffer->used; - } - - memcpy(data, buffer->head, reading); - buffer->used -= reading; - buffer->head += reading; - - /* if (buffer->id == 4) printf("%u o %d = %d\n", buffer->id, (unsigned)reading, (unsigned)buffer->used); */ - return reading; -} - -FT_DECLARE(ftdm_size_t) ftdm_buffer_write(ftdm_buffer_t *buffer, const void *data, ftdm_size_t datalen) -{ - ftdm_size_t freespace, actual_freespace; - - assert(buffer != NULL); - assert(data != NULL); - assert(buffer->data != NULL); - - if (!datalen) { - return buffer->used; - } - - actual_freespace = buffer->datalen - buffer->actually_used; - if (actual_freespace < datalen && (!buffer->max_len || (buffer->used + datalen <= buffer->max_len))) { - memmove(buffer->data, buffer->head, buffer->used); - buffer->head = buffer->data; - buffer->actually_used = buffer->used; - } - - freespace = buffer->datalen - buffer->used; - - /* - if (buffer->data != buffer->head) { - memmove(buffer->data, buffer->head, buffer->used); - buffer->head = buffer->data; - } - */ - - if (freespace < datalen) { - ftdm_size_t new_size, new_block_size; - void *data; - - new_size = buffer->datalen + datalen; - new_block_size = buffer->datalen + buffer->blocksize; - - if (new_block_size > new_size) { - new_size = new_block_size; - } - buffer->head = buffer->data; - data = realloc(buffer->data, new_size); - if (!data) { - return 0; - } - buffer->data = data; - buffer->head = buffer->data; - buffer->datalen = new_size; - } - - - freespace = buffer->datalen - buffer->used; - - if (freespace < datalen) { - return 0; - } else { - memcpy(buffer->head + buffer->used, data, datalen); - buffer->used += datalen; - buffer->actually_used += datalen; - } - /* if (buffer->id == 4) printf("%u i %d = %d\n", buffer->id, (unsigned)datalen, (unsigned)buffer->used); */ - - return buffer->used; -} - -FT_DECLARE(void) ftdm_buffer_zero(ftdm_buffer_t *buffer) -{ - assert(buffer != NULL); - assert(buffer->data != NULL); - - buffer->used = 0; - buffer->actually_used = 0; - buffer->head = buffer->data; -} - -FT_DECLARE(ftdm_size_t) ftdm_buffer_zwrite(ftdm_buffer_t *buffer, const void *data, ftdm_size_t datalen) -{ - ftdm_size_t w; - - if (!(w = ftdm_buffer_write(buffer, data, datalen))) { - ftdm_buffer_zero(buffer); - return ftdm_buffer_write(buffer, data, datalen); - } - - return w; -} - -FT_DECLARE(void) ftdm_buffer_destroy(ftdm_buffer_t **buffer) -{ - if (*buffer) { - ftdm_safe_free((*buffer)->data); - ftdm_safe_free(*buffer); - } - - *buffer = NULL; -} - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/ftdm_call_utils.c b/libs/freetdm/src/ftdm_call_utils.c deleted file mode 100644 index d23c95af4e..0000000000 --- a/libs/freetdm/src/ftdm_call_utils.c +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright (c) 2010, Sangoma Technologies - * David Yat Sin - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Contributors: - * - * Moises Silva - * Ricardo Barroetaveña - * - */ - -#include "private/ftdm_core.h" -#include - - - - -FT_DECLARE(char *) ftdm_url_encode(const char *url, char *buf, ftdm_size_t len) -{ - /* This implementation of url_encode is slightly different compared to the - * Freeswitch one. This is because this implementation accepts the full - * range of values (0x00 - 0xFF) compared to the Freeswitch implementation - * that does not accept 0x00 */ - - const char *p; - size_t x = 0,y = 0; - const char urlunsafe[] = "\r\n \"#%&+:;<=>?@[\\]^`{|}"; - const char hex[] = "0123456789ABCDEF"; - - if (!buf) { - return 0; - } - - if (!url) { - return 0; - } - - len--; - - for (p = url; y <= len; p++) { - if (*p < ' ' || *p > '~' || strchr(urlunsafe, *p)) { - buf[x++] = '%'; - buf[x++] = hex[(*p >> 4) & 0x0f]; - buf[x++] = hex[*p & 0x0f]; - } else { - buf[x++] = *p; - } - y++; - } - buf[x] = '\0'; - return buf; -} - - -FT_DECLARE(char *) ftdm_url_decode(char *s, ftdm_size_t *len) -{ - /* This implementation of url_decode is slightly different compared to the - * Freeswitch one. This is because this implementation accepts the full - * range of values (0x00 - 0xFF) compared to the Freeswitch implementation - * that does not accept 0x00 */ - - char *o; - unsigned int tmp; - ftdm_size_t mylen = 0; - - if (ftdm_strlen_zero(s)) { - return s; - } - - for (o = s; *s; s++, o++) { - if (*s == '%' && strlen(s) > 2 && sscanf(s + 1, "%2x", &tmp) == 1) { - *o = (char) tmp; - s += 2; - } else { - *o = *s; - } - mylen++; - } - *o = '\0'; - *len = mylen; - return s; -} - -FT_DECLARE(ftdm_status_t) ftdm_set_npi(const char *string, uint8_t *target) -{ - uint8_t val; - ftdm_status_t status = FTDM_SUCCESS; - - val = ftdm_str2ftdm_npi(string); - if (val == FTDM_NPI_INVALID) { - ftdm_log(FTDM_LOG_WARNING, "Invalid NPI string (%s)\n", string); - status = FTDM_FAIL; - val = FTDM_NPI_UNKNOWN; - } - *target = val; - return status; -} - -FT_DECLARE(ftdm_status_t) ftdm_set_ton(const char *string, uint8_t *target) -{ - uint8_t val; - ftdm_status_t status = FTDM_SUCCESS; - - val = ftdm_str2ftdm_ton(string); - if (val == FTDM_TON_INVALID) { - ftdm_log(FTDM_LOG_WARNING, "Invalid TON string (%s)\n", string); - status = FTDM_FAIL; - val = FTDM_TON_UNKNOWN; - } - *target = val; - return status; -} - -FT_DECLARE(ftdm_status_t) ftdm_set_bearer_capability(const char *string, uint8_t *target) -{ - uint8_t val; - ftdm_status_t status = FTDM_SUCCESS; - - val = ftdm_str2ftdm_bearer_cap(string); - if (val == FTDM_NPI_INVALID) { - ftdm_log(FTDM_LOG_WARNING, "Invalid Bearer-Capability string (%s)\n", string); - status = FTDM_FAIL; - val = FTDM_BEARER_CAP_SPEECH; - } - - *target = val; - return status; -} - -FT_DECLARE(ftdm_status_t) ftdm_set_bearer_layer1(const char *string, uint8_t *target) -{ - uint8_t val; - ftdm_status_t status = FTDM_SUCCESS; - - val = ftdm_str2ftdm_usr_layer1_prot(string); - if (val == FTDM_USER_LAYER1_PROT_INVALID) { - ftdm_log(FTDM_LOG_WARNING, "Invalid Bearer Layer 1 Protocol string (%s)\n", string); - status = FTDM_FAIL; - val = FTDM_USER_LAYER1_PROT_ULAW; - } - - *target = val; - return status; -} - -FT_DECLARE(ftdm_status_t) ftdm_set_screening_ind(const char *string, uint8_t *target) -{ - uint8_t val; - ftdm_status_t status = FTDM_SUCCESS; - - val = ftdm_str2ftdm_screening(string); - if (val == FTDM_SCREENING_INVALID) { - ftdm_log(FTDM_LOG_WARNING, "Invalid screening indicator string (%s)\n", string); - status = FTDM_FAIL; - val = FTDM_SCREENING_NOT_SCREENED; - } - - *target = val; - return status; -} - -FT_DECLARE(ftdm_status_t) ftdm_set_presentation_ind(const char *string, uint8_t *target) -{ - uint8_t val; - ftdm_status_t status = FTDM_SUCCESS; - - val = ftdm_str2ftdm_presentation(string); - if (val == FTDM_PRES_INVALID) { - ftdm_log(FTDM_LOG_WARNING, "Invalid presentation string (%s)\n", string); - status = FTDM_FAIL; - val = FTDM_PRES_ALLOWED; - } - - *target = val; - return status; -} - -FT_DECLARE(ftdm_status_t) ftdm_is_number(const char *number) -{ - if (!number) { - return FTDM_FAIL; - } - - for ( ; *number; number++) { - if (!isdigit(*number)) { - return FTDM_FAIL; - } - } - return FTDM_SUCCESS; -} - - -FT_DECLARE(ftdm_status_t) ftdm_set_calling_party_category(const char *string, uint8_t *target) -{ - uint8_t val; - ftdm_status_t status = FTDM_SUCCESS; - - val = ftdm_str2ftdm_calling_party_category(string); - if (val == FTDM_CPC_INVALID) { - ftdm_log(FTDM_LOG_WARNING, "Invalid category string (%s)\n", string); - val = FTDM_CPC_ORDINARY; - status = FTDM_FAIL; - } - - *target = val; - return status; -} - diff --git a/libs/freetdm/src/ftdm_callerid.c b/libs/freetdm/src/ftdm_callerid.c deleted file mode 100644 index d3223502f4..0000000000 --- a/libs/freetdm/src/ftdm_callerid.c +++ /dev/null @@ -1,307 +0,0 @@ -#include "private/ftdm_core.h" -#include "fsk.h" -#include "uart.h" - - - -static void fsk_byte_handler (void *x, int data) -{ - ftdm_fsk_data_state_t *state = (ftdm_fsk_data_state_t *) x; - uint8_t byte = (uint8_t)data; - - top: - - if (state->init == 3) { - return; - } - - if (state->dlen) { - goto add_byte; - } - - if (state->bpos == 1) { - state->blen = byte; - - if ((uint32_t)(state->dlen = state->bpos + byte + 2) > state->bufsize) { - state->dlen = state->bufsize; - } - goto top; - } - - add_byte: - - if (state->bpos <= state->dlen) { - state->buf[state->bpos++] = byte; - } else { - state->init = 3; - } -} - -FT_DECLARE(ftdm_status_t) ftdm_fsk_data_init(ftdm_fsk_data_state_t *state, uint8_t *data, uint32_t datalen) -{ - memset(state, 0, sizeof(*state)); - state->buf = data; - state->bufsize = datalen; - state->bpos = 2; - - return FTDM_SUCCESS; -} - -FT_DECLARE(ftdm_status_t) ftdm_fsk_data_add_sdmf(ftdm_fsk_data_state_t *state, const char *date, char *number) -{ - size_t dlen = strlen(date); - size_t nlen = strlen(number); - - state->buf[0] = FTDM_CID_TYPE_SDMF; - memcpy(&state->buf[state->bpos], date, dlen); - state->bpos += dlen; - memcpy(&state->buf[state->bpos], number, nlen); - state->bpos += nlen; - - return FTDM_SUCCESS; -} - -FT_DECLARE(ftdm_status_t) ftdm_fsk_data_add_mdmf(ftdm_fsk_data_state_t *state, ftdm_mdmf_type_t type, const uint8_t *data, uint32_t datalen) -{ - state->buf[0] = FTDM_CID_TYPE_MDMF; - state->buf[state->bpos++] = type; - state->buf[state->bpos++] = (uint8_t)datalen; - memcpy(&state->buf[state->bpos], data, datalen); - state->bpos += datalen; - return FTDM_SUCCESS; -} - - -FT_DECLARE(ftdm_status_t) ftdm_fsk_data_add_checksum(ftdm_fsk_data_state_t *state) -{ - uint32_t i; - uint8_t check = 0; - - state->buf[1] = (uint8_t)(state->bpos - 2); - - for (i = 0; i < state->bpos; i++) { - check = check + state->buf[i]; - } - - state->checksum = state->buf[state->bpos] = (uint8_t)(256 - check); - state->bpos++; - - state->dlen = state->bpos; - state->blen = state->buf[1]; - - return FTDM_SUCCESS; -} - - -FT_DECLARE(ftdm_status_t) ftdm_fsk_data_parse(ftdm_fsk_data_state_t *state, ftdm_size_t *type, char **data, ftdm_size_t *len) -{ - - ftdm_size_t i; - int sum = 0; - - top: - - if (state->checksum != 0 || state->ppos >= state->dlen - 1) { - return FTDM_FAIL; - } - - if (!state->ppos) { - for(i = 0; i < state->bpos; i++) { - sum += state->buf[i]; - } - state->checksum = sum % 256; - state->ppos = 2; - - if (state->buf[0] != FTDM_CID_TYPE_MDMF && state->buf[0] != FTDM_CID_TYPE_SDMF) { - state->checksum = -1; - } - goto top; - } - - if (state->buf[0] == FTDM_CID_TYPE_SDMF) { - /* convert sdmf to mdmf so we don't need 2 parsers */ - if (state->ppos == 2) { - *type = MDMF_DATETIME; - *len = 8; - } else { - if (state->buf[state->ppos] == 'P' || state->buf[state->ppos] == 'O') { - *type = MDMF_NO_NUM; - *len = 1; - } else { - *type = MDMF_PHONE_NUM; - *len = state->blen - 8; - } - } - *data = (char *)&state->buf[state->ppos]; - state->ppos += *len; - return FTDM_SUCCESS; - } else if (state->buf[0] == FTDM_CID_TYPE_MDMF) { - *type = state->buf[state->ppos++]; - *len = state->buf[state->ppos++]; - *data = (char *)&state->buf[state->ppos]; - state->ppos += *len; - return FTDM_SUCCESS; - } - - return FTDM_FAIL; -} - -FT_DECLARE(ftdm_status_t) ftdm_fsk_demod_feed(ftdm_fsk_data_state_t *state, int16_t *data, ftdm_size_t samples) -{ - uint32_t x; - int16_t *sp = data; - - if (state->init == 3) { - return FTDM_FAIL; - } - - for (x = 0; x < samples; x++) { - dsp_fsk_sample (state->fsk1200_handle, (double) *sp++ / 32767.0); - if (state->dlen && state->bpos >= state->dlen) { - state->init = 3; - return FTDM_FAIL; - } - } - - return FTDM_SUCCESS; -} - -FT_DECLARE(ftdm_status_t) ftdm_fsk_demod_destroy(ftdm_fsk_data_state_t *state) -{ - dsp_fsk_destroy(&state->fsk1200_handle); - memset(state, 0, sizeof(*state)); - return FTDM_SUCCESS; -} - -FT_DECLARE(int) ftdm_fsk_demod_init(ftdm_fsk_data_state_t *state, int rate, uint8_t *buf, ftdm_size_t bufsize) -{ - - dsp_fsk_attr_t fsk1200_attr; - - if (state->fsk1200_handle) { - dsp_fsk_destroy(&state->fsk1200_handle); - } - - memset(state, 0, sizeof(*state)); - memset(buf, 0, bufsize); - state->buf = buf; - state->bufsize = bufsize; - - dsp_fsk_attr_init (&fsk1200_attr); - dsp_fsk_attr_set_samplerate (&fsk1200_attr, rate); - dsp_fsk_attr_set_bytehandler (&fsk1200_attr, fsk_byte_handler, state); - state->fsk1200_handle = dsp_fsk_create (&fsk1200_attr); - - if (state->fsk1200_handle == NULL) { - return FTDM_FAIL; - } - - return FTDM_SUCCESS; -} - -FT_DECLARE(ftdm_size_t) ftdm_fsk_modulator_generate_bit(ftdm_fsk_modulator_t *fsk_trans, int8_t bit, int16_t *buf, ftdm_size_t buflen) -{ - ftdm_size_t i; - - for(i = 0 ; i < buflen; i++) { - fsk_trans->bit_accum += fsk_trans->bit_factor; - if (fsk_trans->bit_accum >= FTDM_FSK_MOD_FACTOR) { - fsk_trans->bit_accum -= (FTDM_FSK_MOD_FACTOR + fsk_trans->bit_factor); - break; - } - - buf[i] = teletone_dds_state_modulate_sample(&fsk_trans->dds, bit); - } - - return i; -} - - -FT_DECLARE(int32_t) ftdm_fsk_modulator_generate_carrier_bits(ftdm_fsk_modulator_t *fsk_trans, uint32_t bits) -{ - uint32_t i = 0; - ftdm_size_t r = 0; - int8_t bit = 1; - - for (i = 0; i < bits; i++) { - if ((r = ftdm_fsk_modulator_generate_bit(fsk_trans, bit, fsk_trans->sample_buffer, sizeof(fsk_trans->sample_buffer) / 2))) { - if (fsk_trans->write_sample_callback(fsk_trans->sample_buffer, r, fsk_trans->user_data) != FTDM_SUCCESS) { - break; - } - } else { - break; - } - } - - return i; -} - - -FT_DECLARE(void) ftdm_fsk_modulator_generate_chan_sieze(ftdm_fsk_modulator_t *fsk_trans) -{ - uint32_t i = 0; - ftdm_size_t r = 0; - int8_t bit = 0; - - for (i = 0; i < fsk_trans->chan_sieze_bits; i++) { - if ((r = ftdm_fsk_modulator_generate_bit(fsk_trans, bit, fsk_trans->sample_buffer, sizeof(fsk_trans->sample_buffer) / 2))) { - if (fsk_trans->write_sample_callback(fsk_trans->sample_buffer, r, fsk_trans->user_data) != FTDM_SUCCESS) { - break; - } - } else { - break; - } - bit = !bit; - } - - -} - - -FT_DECLARE(void) ftdm_fsk_modulator_send_data(ftdm_fsk_modulator_t *fsk_trans) -{ - ftdm_size_t r = 0; - int8_t bit = 0; - - while((bit = ftdm_bitstream_get_bit(&fsk_trans->bs)) > -1) { - if ((r = ftdm_fsk_modulator_generate_bit(fsk_trans, bit, fsk_trans->sample_buffer, sizeof(fsk_trans->sample_buffer) / 2))) { - if (fsk_trans->write_sample_callback(fsk_trans->sample_buffer, r, fsk_trans->user_data) != FTDM_SUCCESS) { - break; - } - } else { - break; - } - } -} - - -FT_DECLARE(ftdm_status_t) ftdm_fsk_modulator_init(ftdm_fsk_modulator_t *fsk_trans, - fsk_modem_types_t modem_type, - uint32_t sample_rate, - ftdm_fsk_data_state_t *fsk_data, - float db_level, - uint32_t carrier_bits_start, - uint32_t carrier_bits_stop, - uint32_t chan_sieze_bits, - ftdm_fsk_write_sample_t write_sample_callback, - void *user_data) -{ - memset(fsk_trans, 0, sizeof(*fsk_trans)); - fsk_trans->modem_type = modem_type; - teletone_dds_state_set_tone(&fsk_trans->dds, fsk_modem_definitions[fsk_trans->modem_type].freq_space, sample_rate, 0); - teletone_dds_state_set_tone(&fsk_trans->dds, fsk_modem_definitions[fsk_trans->modem_type].freq_mark, sample_rate, 1); - fsk_trans->bit_factor = (uint32_t)((fsk_modem_definitions[fsk_trans->modem_type].baud_rate * FTDM_FSK_MOD_FACTOR) / (float)sample_rate); - fsk_trans->samples_per_bit = (uint32_t) (sample_rate / fsk_modem_definitions[fsk_trans->modem_type].baud_rate); - fsk_trans->est_bytes = (int32_t)(((fsk_data->dlen * 10) + carrier_bits_start + carrier_bits_stop + chan_sieze_bits) * ((fsk_trans->samples_per_bit + 1) * 2)); - fsk_trans->bit_accum = 0; - fsk_trans->fsk_data = fsk_data; - teletone_dds_state_set_tx_level(&fsk_trans->dds, db_level); - ftdm_bitstream_init(&fsk_trans->bs, fsk_trans->fsk_data->buf, (uint32_t)fsk_trans->fsk_data->dlen, FTDM_ENDIAN_BIG, 1); - fsk_trans->carrier_bits_start = carrier_bits_start; - fsk_trans->carrier_bits_stop = carrier_bits_stop; - fsk_trans->chan_sieze_bits = chan_sieze_bits; - fsk_trans->write_sample_callback = write_sample_callback; - fsk_trans->user_data = user_data; - return FTDM_SUCCESS; -} - diff --git a/libs/freetdm/src/ftdm_config.c b/libs/freetdm/src/ftdm_config.c deleted file mode 100644 index 9352284edf..0000000000 --- a/libs/freetdm/src/ftdm_config.c +++ /dev/null @@ -1,383 +0,0 @@ -/* - * Copyright (c) 2007-2014, Anthony Minessale II - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Contributors: - * - * Moises Silva - */ - -#include "private/ftdm_core.h" - -#ifndef FTDM_MOD_DIR -#define FTDM_MOD_DIR "." -#endif - -#define FTDM_MAX_CONF_DIR 512 - -static char g_ftdm_config_dir[FTDM_MAX_CONF_DIR] = FTDM_CONFIG_DIR; -static char g_ftdm_mod_dir[FTDM_MAX_CONF_DIR] = FTDM_MOD_DIR; - -FT_DECLARE(void) ftdm_global_set_mod_directory(const char *path) -{ - snprintf(g_ftdm_mod_dir, sizeof(g_ftdm_mod_dir), "%s", path); - ftdm_log(FTDM_LOG_DEBUG, "New mod directory: %s\n", g_ftdm_mod_dir); -} - -FT_DECLARE(void) ftdm_global_set_config_directory(const char *path) -{ - snprintf(g_ftdm_config_dir, sizeof(g_ftdm_config_dir), "%s", path); - ftdm_log(FTDM_LOG_DEBUG, "New config directory: %s\n", g_ftdm_config_dir); -} - -int ftdm_config_open_file(ftdm_config_t *cfg, const char *file_path) -{ - FILE *f; - const char *path = NULL; - char path_buf[1024]; - - if (file_path[0] == '/') { - path = file_path; - } else { - snprintf(path_buf, sizeof(path_buf), "%s%s%s", g_ftdm_config_dir, FTDM_PATH_SEPARATOR, file_path); - path = path_buf; - } - - if (!path) { - return 0; - } - - memset(cfg, 0, sizeof(*cfg)); - cfg->lockto = -1; - ftdm_log(FTDM_LOG_DEBUG, "Configuration file is %s\n", path); - f = fopen(path, "r"); - - if (!f) { - if (file_path[0] != '/') { - int last = -1; - char *var, *val; - - snprintf(path_buf, sizeof(path_buf), "%s%sfreetdm.conf", g_ftdm_config_dir, FTDM_PATH_SEPARATOR); - path = path_buf; - - if ((f = fopen(path, "r")) == 0) { - return 0; - } - - cfg->file = f; - ftdm_set_string(cfg->path, path); - - while (ftdm_config_next_pair(cfg, &var, &val)) { - if ((cfg->sectno != last) && !strcmp(cfg->section, file_path)) { - cfg->lockto = cfg->sectno; - return 1; - } - } - - ftdm_config_close_file(cfg); - memset(cfg, 0, sizeof(*cfg)); - return 0; - } - - return 0; - } else { - cfg->file = f; - ftdm_set_string(cfg->path, path); - return 1; - } -} - -void ftdm_config_close_file(ftdm_config_t *cfg) -{ - - if (cfg->file) { - fclose(cfg->file); - } - - memset(cfg, 0, sizeof(*cfg)); -} - - - -int ftdm_config_next_pair(ftdm_config_t *cfg, char **var, char **val) -{ - int ret = 0; - char *p, *end; - - *var = *val = NULL; - - if (!cfg->path) { - return 0; - } - - for (;;) { - cfg->lineno++; - - if (!fgets(cfg->buf, sizeof(cfg->buf), cfg->file)) { - ret = 0; - break; - } - *var = cfg->buf; - - if (**var == '[' && (end = strchr(*var, ']')) != 0) { - *end = '\0'; - (*var)++; - if (**var == '+') { - (*var)++; - ftdm_copy_string(cfg->section, *var, sizeof(cfg->section)); - cfg->sectno++; - - if (cfg->lockto > -1 && cfg->sectno != cfg->lockto) { - break; - } - cfg->catno = 0; - cfg->lineno = 0; - *var = (char *) ""; - *val = (char *) ""; - return 1; - } else { - ftdm_copy_string(cfg->category, *var, sizeof(cfg->category)); - cfg->catno++; - } - continue; - } - - - - if (**var == '#' || **var == ';' || **var == '\n' || **var == '\r') { - continue; - } - - if (!strncmp(*var, "__END__", 7)) { - break; - } - - - if ((end = strchr(*var, ';')) && *(end+1) == *end) { - *end = '\0'; - end--; - } else if ((end = strchr(*var, '\n')) != 0) { - if (*(end - 1) == '\r') { - end--; - } - *end = '\0'; - } - - p = *var; - while ((*p == ' ' || *p == '\t') && p != end) { - *p = '\0'; - p++; - } - *var = p; - - - if ((*val = strchr(*var, '=')) == 0) { - ret = -1; - /* log_printf(0, server.log, "Invalid syntax on %s: line %d\n", cfg->path, cfg->lineno); */ - continue; - } else { - p = *val - 1; - *(*val) = '\0'; - (*val)++; - if (*(*val) == '>') { - *(*val) = '\0'; - (*val)++; - } - - while ((*p == ' ' || *p == '\t') && p != *var) { - *p = '\0'; - p--; - } - - p = *val; - while ((*p == ' ' || *p == '\t') && p != end) { - *p = '\0'; - p++; - } - *val = p; - ret = 1; - break; - } - } - - - return ret; - -} - -FT_DECLARE (int) ftdm_config_get_cas_bits(char *strvalue, unsigned char *outbits) -{ - char cas_bits[5]; - unsigned char bit = 0x8; - int x = 0; - char *double_colon = strchr(strvalue, ':'); - if (!double_colon) { - ftdm_log(FTDM_LOG_ERROR, "No CAS bits specified: %s, :xxxx definition expected, where x is 1 or 0\n", strvalue); - return -1; - } - double_colon++; - *outbits = 0; - cas_bits[4] = 0; - if (sscanf(double_colon, "%c%c%c%c", &cas_bits[0], &cas_bits[1], &cas_bits[2], &cas_bits[3]) != 4) { - ftdm_log(FTDM_LOG_ERROR, "Invalid CAS bits specified: '%s', :xxxx definition expected, where x is 1 or 0\n", double_colon); - return -1; - } - ftdm_log(FTDM_LOG_DEBUG, "CAS bits specification found: %s\n", cas_bits); - for (; cas_bits[x]; x++) { - if ('1' == cas_bits[x]) { - *outbits |= bit; - } else if ('0' != cas_bits[x]) { - ftdm_log(FTDM_LOG_ERROR, "Invalid CAS pattern specified: %s, just 0 or 1 allowed for each bit\n", - strvalue); - return -1; - } - bit >>= 1; - } - return 0; -} - -#define PARAMETERS_CHUNK_SIZE 20 -FT_DECLARE(ftdm_status_t) ftdm_conf_node_create(const char *name, ftdm_conf_node_t **node, ftdm_conf_node_t *parent) -{ - ftdm_conf_node_t *newnode; - ftdm_conf_node_t *sibling = NULL; - - ftdm_assert_return(name != NULL, FTDM_FAIL, "null node name"); - - newnode = ftdm_calloc(1, sizeof(**node)); - if (!newnode) { - return FTDM_MEMERR; - } - - strncpy(newnode->name, name, sizeof(newnode->name)-1); - newnode->name[sizeof(newnode->name)-1] = 0; - - newnode->parameters = ftdm_calloc(PARAMETERS_CHUNK_SIZE, sizeof(*newnode->parameters)); - if (!newnode->parameters) { - ftdm_safe_free(newnode); - return FTDM_MEMERR; - } - newnode->t_parameters = PARAMETERS_CHUNK_SIZE; - - if (parent) { - /* store who my parent is */ - newnode->parent = parent; - - /* arrange them in FIFO order (newnode should be last) */ - if (!parent->child) { - /* we're the first node being added */ - parent->child = newnode; - } else { - if (!parent->last) { - /* we're the second node being added */ - parent->last = newnode; - parent->child->next = newnode; - newnode->prev = parent->child; - } else { - /* we're the third or Nth node to be added */ - sibling = parent->last; - sibling->next = newnode; - parent->last = newnode; - newnode->prev = sibling; - } - } - } - - *node = newnode; - - return FTDM_SUCCESS; -} - -FT_DECLARE(ftdm_status_t) ftdm_conf_node_add_param(ftdm_conf_node_t *node, const char *param, const char *val) -{ - void *newparameters; - - ftdm_assert_return(param != NULL, FTDM_FAIL, "param is null"); - ftdm_assert_return(val != NULL, FTDM_FAIL, "val is null"); - - if (node->n_parameters == node->t_parameters) { - newparameters = ftdm_realloc(node->parameters, (node->t_parameters + PARAMETERS_CHUNK_SIZE) * sizeof(*node->parameters)); - if (!newparameters) { - return FTDM_MEMERR; - } - node->parameters = newparameters; - node->t_parameters = node->n_parameters + PARAMETERS_CHUNK_SIZE; - } - node->parameters[node->n_parameters].var = param; - node->parameters[node->n_parameters].val = val; - node->n_parameters++; - return FTDM_SUCCESS; -} - -FT_DECLARE(ftdm_status_t) ftdm_conf_node_destroy(ftdm_conf_node_t *node) -{ - ftdm_conf_node_t *curr = NULL; - ftdm_conf_node_t *child = node->child; - while (child) { - curr = child; - child = curr->next; - ftdm_conf_node_destroy(curr); - } - ftdm_free(node->parameters); - ftdm_free(node); - return FTDM_SUCCESS; -} - -FT_DECLARE(char *) ftdm_build_dso_path(const char *name, char *path, ftdm_size_t len) -{ -#ifdef WIN32 - const char *ext = ".dll"; - //const char *EXT = ".DLL"; -#elif defined (MACOSX) || defined (DARWIN) - const char *ext = ".dylib"; - //const char *EXT = ".DYLIB"; -#else - const char *ext = ".so"; - //const char *EXT = ".SO"; -#endif - if (*name == *FTDM_PATH_SEPARATOR) { - snprintf(path, len, "%s%s", name, ext); - } else { - snprintf(path, len, "%s%s%s%s", g_ftdm_mod_dir, FTDM_PATH_SEPARATOR, name, ext); - } - return path; -} - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/ftdm_cpu_monitor.c b/libs/freetdm/src/ftdm_cpu_monitor.c deleted file mode 100644 index 1aa9b16c41..0000000000 --- a/libs/freetdm/src/ftdm_cpu_monitor.c +++ /dev/null @@ -1,307 +0,0 @@ -/* - * Copyright (c) 2010, Sangoma Technologies - * Moises Silva - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Contributors: - * David Yat Sin - * - */ - -#ifdef WIN32 -# if (_WIN32_WINNT < 0x0501) -# error "Need to target at least Windows XP/Server 2003 because GetSystemTimes is needed" -# endif -# include -#else /* LINUX */ - -#include -#include -#include -#include -#include -#include -#include -#endif - -#include "private/ftdm_core.h" -#include "ftdm_cpu_monitor.h" -struct ftdm_cpu_monitor_stats -{ - /* bool, just used to retrieve the values for the first time and not calculate the percentage of idle time */ - int valid_last_times; - - /* last calculated percentage of idle time */ - double last_percentage_of_idle_time; - -#ifdef __linux__ - /* the cpu feature gets disabled on errors */ - int disabled; - - /* all of these are the Linux jiffies last retrieved count */ - unsigned long long last_user_time; - unsigned long long last_system_time; - unsigned long long last_idle_time; - - unsigned long long last_nice_time; - unsigned long long last_irq_time; - unsigned long long last_soft_irq_time; - unsigned long long last_io_wait_time; - unsigned long long last_steal_time; - - /* /proc/stat file descriptor used to retrieve the counters */ - int procfd; - int initd; -#elif defined (WIN32) || defined (WIN64) - __int64 i64LastUserTime; - __int64 i64LastKernelTime; - __int64 i64LastIdleTime; -#else -/* Unsupported */ -#endif -}; - -#ifdef __linux__ -static ftdm_status_t ftdm_cpu_read_stats(struct ftdm_cpu_monitor_stats *p, - unsigned long long *user, - unsigned long long *nice, - unsigned long long *system, - unsigned long long *idle, - unsigned long long *iowait, - unsigned long long *irq, - unsigned long long *softirq, - unsigned long long *steal) -{ -// the output of proc should not change that often from one kernel to other -// see fs/proc/proc_misc.c or fs/proc/stat.c in the Linux kernel for more details -// also man 5 proc is useful. -#define CPU_ELEMENTS_1 7 // change this if you change the format string -#define CPU_INFO_FORMAT_1 "cpu %llu %llu %llu %llu %llu %llu %llu" - -#define CPU_ELEMENTS_2 8 // change this if you change the format string -#define CPU_INFO_FORMAT_2 "cpu %llu %llu %llu %llu %llu %llu %llu %llu" - -#define CPU_ELEMENTS_3 9 // change this if you change the format string -#define CPU_INFO_FORMAT_3 "cpu %llu %llu %llu %llu %llu %llu %llu %llu %llu" - - static const char procfile[] = "/proc/stat"; - int rc = 0; - int myerrno = 0; - int elements = 0; - const char *cpustr = NULL; - char statbuff[1024]; - unsigned long long guest = 0; - - if (!p->initd) { - p->procfd = open(procfile, O_RDONLY, 0); - if(p->procfd == -1) { - ftdm_log(FTDM_LOG_ERROR, "Failed to open CPU statistics file %s: %s\n", procfile, strerror(myerrno)); - return FTDM_FAIL; - } - p->initd = 1; - } else { - lseek(p->procfd, 0L, SEEK_SET); - } - - rc = read(p->procfd, statbuff, sizeof(statbuff) - 1); - if (rc <= 0) { - myerrno = errno; - ftdm_log(FTDM_LOG_ERROR, "Failed to read CPU statistics file %s: %s\n", procfile, strerror(myerrno)); - return FTDM_FAIL; - } - - cpustr = strstr(statbuff, "cpu "); - if (!cpustr) { - ftdm_log(FTDM_LOG_ERROR, "wrong format for Linux proc cpu statistics: missing cpu string\n"); - return FTDM_FAIL; - } - - /* test each of the known formats starting from the bigger one */ - elements = sscanf(cpustr, CPU_INFO_FORMAT_3, user, nice, system, idle, iowait, irq, softirq, steal, &guest); - if (elements == CPU_ELEMENTS_3) { - user += guest; /* guest operating system's run in user space */ - return FTDM_SUCCESS; - } - - elements = sscanf(cpustr, CPU_INFO_FORMAT_2, user, nice, system, idle, iowait, irq, softirq, steal); - if (elements == CPU_ELEMENTS_2) { - return FTDM_SUCCESS; - } - - elements = sscanf(cpustr, CPU_INFO_FORMAT_1, user, nice, system, idle, iowait, irq, softirq); - if (elements == CPU_ELEMENTS_1) { - *steal = 0; - return FTDM_SUCCESS; - } - - ftdm_log(FTDM_LOG_ERROR, "Unexpected format for Linux proc cpu statistics:%s\n", cpustr); - return FTDM_FAIL; -} -#endif - -#ifdef __linux__ -FT_DECLARE(ftdm_status_t) ftdm_cpu_get_system_idle_time (struct ftdm_cpu_monitor_stats *p, double *idle_percentage) -{ - unsigned long long user, nice, system, idle, iowait, irq, softirq, steal; - unsigned long long usertime, kerneltime, idletime, totaltime, halftime; - - *idle_percentage = 100.0; - if (p->disabled) { - return FTDM_FAIL; - } - if (ftdm_cpu_read_stats(p, &user, &nice, &system, &idle, &iowait, &irq, &softirq, &steal)) { - ftdm_log(FTDM_LOG_ERROR, "Failed to retrieve Linux CPU statistics - disabling cpu monitor\n"); - p->disabled = 1; - return FTDM_FAIL; - } - - if (!p->valid_last_times) { - // we dont strictly need to save all of them but I feel code is more clear if we do - p->valid_last_times = 1; - p->last_user_time = user; - p->last_nice_time = nice; - p->last_system_time = system; - p->last_irq_time = irq; - p->last_soft_irq_time = softirq; - p->last_io_wait_time = iowait; - p->last_steal_time = steal; - p->last_idle_time = idle; - p->last_percentage_of_idle_time = 100.0; - *idle_percentage = p->last_percentage_of_idle_time; - return FTDM_SUCCESS; - } - - usertime = (user - p->last_user_time) + (nice - p->last_nice_time); - kerneltime = (system - p->last_system_time) + (irq - p->last_irq_time) + (softirq - p->last_soft_irq_time); - kerneltime += (iowait - p->last_io_wait_time); - kerneltime += (steal - p->last_steal_time); - idletime = (idle - p->last_idle_time); - - totaltime = usertime + kerneltime + idletime; - - if (totaltime <= 0) { - // this may happen if not enough time has elapsed and the jiffies counters are the same than the last time we checked - // jiffies depend on timer interrupts which depend on the number of HZ compile time setting of the kernel - // typical configs set HZ to 100 (that means, 100 jiffies updates per second, that is one each 10ms) - // avoid an arithmetic exception and return the same values - *idle_percentage = p->last_percentage_of_idle_time; - return FTDM_SUCCESS; - } - - halftime = totaltime / 2UL; - - p->last_percentage_of_idle_time = ((100 * idletime + halftime) / totaltime); - *idle_percentage = p->last_percentage_of_idle_time; - - p->last_user_time = user; - p->last_nice_time = nice; - p->last_system_time = system; - p->last_irq_time = irq; - p->last_soft_irq_time = softirq; - p->last_io_wait_time = iowait; - p->last_steal_time = steal; - p->last_idle_time = idle; - - return FTDM_SUCCESS; -} - -#elif defined (__WINDOWS__) -FT_DECLARE(ftdm_status_t) ftdm_cpu_get_system_idle_time(struct ftdm_cpu_monitor_stats *p, double *idle_percentage) -{ - FILETIME idleTime; - FILETIME kernelTime; - FILETIME userTime; - int64_t i64UserTime; - int64_t i64KernelTime; - int64_t i64IdleTime; - - if (!GetSystemTimes(&idleTime, &kernelTime, &userTime)) { - return FTDM_FAIL; - } - - i64UserTime = (int64_t)userTime.dwLowDateTime | ((int64_t)userTime.dwHighDateTime << 32); - - i64KernelTime = (int64_t)kernelTime.dwLowDateTime | ((int64_t)kernelTime.dwHighDateTime << 32); - - i64IdleTime = (int64_t)idleTime.dwLowDateTime | ((int64_t)idleTime.dwHighDateTime << 32); - - if (p->valid_last_times) { - int64_t i64User = i64UserTime - p->i64LastUserTime; - int64_t i64Kernel = i64KernelTime - p->i64LastKernelTime; - int64_t i64Idle = i64IdleTime - p->i64LastIdleTime; - int64_t i64System = i64User + i64Kernel; - *idle_percentage = 100.0 * i64Idle / i64System; - } else { - *idle_percentage = 100.0; - p->valid_last_times = 1; - } - - /* Remember current value for the next call */ - p->i64LastUserTime = i64UserTime; - p->i64LastKernelTime = i64KernelTime; - p->i64LastIdleTime = i64IdleTime; - - /* Success */ - return FTDM_SUCCESS; -} -#else -/* Unsupported */ -FT_DECLARE(ftdm_status_t) ftdm_cpu_get_system_idle_time(struct ftdm_cpu_monitor_stats *p, double *idle_percentage) -{ - *idle_percentage = 100.0; - return FTDM_FAIL; -} -#endif - -FT_DECLARE(struct ftdm_cpu_monitor_stats*) ftdm_new_cpu_monitor(void) -{ - return calloc(1, sizeof(struct ftdm_cpu_monitor_stats)); -} - -FT_DECLARE(void) ftdm_delete_cpu_monitor(struct ftdm_cpu_monitor_stats *p) -{ -#ifdef __linux__ - close(p->procfd); -#endif - free(p); -} - - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/ftdm_dso.c b/libs/freetdm/src/ftdm_dso.c deleted file mode 100755 index a646ed3469..0000000000 --- a/libs/freetdm/src/ftdm_dso.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Cross Platform dso/dll load abstraction - * Copyright(C) 2008 Michael Jerris - * - * You may opt to use, copy, modify, merge, publish, distribute and/or sell - * copies of the Software, and permit persons to whom the Software is - * furnished to do so. - * - * This work is provided under this license on an "as is" basis, without warranty of any kind, - * either expressed or implied, including, without limitation, warranties that the covered code - * is free of defects, merchantable, fit for a particular purpose or non-infringing. The entire - * risk as to the quality and performance of the covered code is with you. Should any covered - * code prove defective in any respect, you (not the initial developer or any other contributor) - * assume the cost of any necessary servicing, repair or correction. This disclaimer of warranty - * constitutes an essential part of this license. No use of any covered code is authorized hereunder - * except under this disclaimer. - * - */ - -#include "private/ftdm_core.h" -#include "ftdm_dso.h" -#include -#include - -#ifdef WIN32 -#include -#include - - -FT_DECLARE(ftdm_status_t) ftdm_dso_destroy(ftdm_dso_lib_t *lib) { - if (lib && *lib) { - FreeLibrary(*lib); - *lib = NULL; - } - return FTDM_SUCCESS; -} - -FT_DECLARE(ftdm_dso_lib_t) ftdm_dso_open(const char *path, char **err) { - HINSTANCE lib; - - lib = LoadLibraryEx(path, NULL, 0); - - if (!lib) { - LoadLibraryEx(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); - } - - if (!lib) { - DWORD error = GetLastError(); - char tmp[80]; - sprintf(tmp, "dll open error [%ul]\n", error); - *err = ftdm_strdup(tmp); - } - - return lib; -} - -FT_DECLARE(void*) ftdm_dso_func_sym(ftdm_dso_lib_t lib, const char *sym, char **err) { - FARPROC func = GetProcAddress(lib, sym); - if (!func) { - DWORD error = GetLastError(); - char tmp[80]; - sprintf(tmp, "dll sym error [%ul]\n", error); - *err = ftdm_strdup(tmp); - } - return (void *)(intptr_t)func; // this should really be addr - ftdm_dso_func_data -} - -#else - -/* -** {======================================================================== -** This is an implementation of loadlib based on the dlfcn interface. -** The dlfcn interface is available in Linux, SunOS, Solaris, IRIX, FreeBSD, -** NetBSD, AIX 4.2, HPUX 11, and probably most other Unix flavors, at least -** as an emulation layer on top of native functions. -** ========================================================================= -*/ - - -#include - -FT_DECLARE(ftdm_status_t) ftdm_dso_destroy(ftdm_dso_lib_t *lib) { - int rc; - if (lib && *lib) { - rc = dlclose(*lib); - if (rc) { - ftdm_log(FTDM_LOG_ERROR, "Failed to close lib %p: %s\n", *lib, dlerror()); - return FTDM_FAIL; - } - ftdm_log(FTDM_LOG_DEBUG, "lib %p was closed with success\n", *lib); - *lib = NULL; - return FTDM_SUCCESS; - } - ftdm_log(FTDM_LOG_ERROR, "Invalid pointer provided to ftdm_dso_destroy\n"); - return FTDM_FAIL; -} - -FT_DECLARE(ftdm_dso_lib_t) ftdm_dso_open(const char *path, char **err) { - void *lib = dlopen(path, RTLD_NOW | RTLD_LOCAL); - if (lib == NULL) { - *err = ftdm_strdup(dlerror()); - } - return lib; -} - -FT_DECLARE(void *) ftdm_dso_func_sym(ftdm_dso_lib_t lib, const char *sym, char **err) { - void *func = dlsym(lib, sym); - if (!func) { - *err = ftdm_strdup(dlerror()); - } - return func; -} -#endif - -/* }====================================================== */ - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c deleted file mode 100644 index 9adcd27509..0000000000 --- a/libs/freetdm/src/ftdm_io.c +++ /dev/null @@ -1,7027 +0,0 @@ -/* - * Copyright (c) 2007-2014, Anthony Minessale II - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Contributors: - * - * Moises Silva - * David Yat Sin - * - */ -#define _GNU_SOURCE -#include "private/ftdm_core.h" -#include -#include -#ifdef WIN32 -#include -#endif -#ifdef FTDM_PIKA_SUPPORT -#include "ftdm_pika.h" -#endif -#include "ftdm_cpu_monitor.h" - -#ifndef localtime_r -struct tm *localtime_r(const time_t *clock, struct tm *result); -#endif - -#define FORCE_HANGUP_TIMER 30000 -#define FTDM_READ_TRACE_INDEX 0 -#define FTDM_WRITE_TRACE_INDEX 1 -#define MAX_CALLIDS 6000 -#define FTDM_HALF_DTMF_PAUSE 500 -#define FTDM_FULL_DTMF_PAUSE 1000 - -#define FTDM_CHANNEL_SW_DTMF_ALLOWED(ftdmchan) (!ftdm_channel_test_feature(ftdmchan, FTDM_CHANNEL_FEATURE_DTMF_DETECT) && !ftdm_test_flag(ftdmchan, FTDM_CHANNEL_SIG_DTMF_DETECTION)) - -ftdm_time_t time_last_throttle_log = 0; -ftdm_time_t time_current_throttle_log = 0; - -typedef struct val_str { - const char *str; - unsigned long long val; -} val_str_t; - -static val_str_t channel_flag_strs[] = { - { "configured" , FTDM_CHANNEL_CONFIGURED}, - { "ready", FTDM_CHANNEL_READY}, - { "open", FTDM_CHANNEL_OPEN}, - { "dtmf-detect", FTDM_CHANNEL_DTMF_DETECT}, - { "suppress-dtmf", FTDM_CHANNEL_SUPRESS_DTMF}, - { "transcode", FTDM_CHANNEL_TRANSCODE}, - { "buffer", FTDM_CHANNEL_BUFFER}, - { "in-thread", FTDM_CHANNEL_INTHREAD}, - { "wink", FTDM_CHANNEL_WINK}, - { "flash", FTDM_CHANNEL_FLASH}, - { "state-change", FTDM_CHANNEL_STATE_CHANGE}, - { "hold", FTDM_CHANNEL_HOLD}, - { "in-use", FTDM_CHANNEL_INUSE}, - { "off-hook", FTDM_CHANNEL_OFFHOOK}, - { "ringing", FTDM_CHANNEL_RINGING}, - { "progress-detect", FTDM_CHANNEL_PROGRESS_DETECT}, - { "callerid-detect", FTDM_CHANNEL_CALLERID_DETECT}, - { "outbound", FTDM_CHANNEL_OUTBOUND}, - { "suspended", FTDM_CHANNEL_SUSPENDED}, - { "3-way", FTDM_CHANNEL_3WAY}, - { "progress", FTDM_CHANNEL_PROGRESS}, - { "media", FTDM_CHANNEL_MEDIA}, - { "answered", FTDM_CHANNEL_ANSWERED}, - { "mute", FTDM_CHANNEL_MUTE}, - { "use-rx-gain", FTDM_CHANNEL_USE_RX_GAIN}, - { "use-tx-gain", FTDM_CHANNEL_USE_TX_GAIN}, - { "in-alarm", FTDM_CHANNEL_IN_ALARM}, - { "sig-up", FTDM_CHANNEL_SIG_UP}, - { "user-hangup", FTDM_CHANNEL_USER_HANGUP}, - { "rx-disabled", FTDM_CHANNEL_RX_DISABLED}, - { "tx-disabled", FTDM_CHANNEL_TX_DISABLED}, - { "call-started", FTDM_CHANNEL_CALL_STARTED}, - { "non-block", FTDM_CHANNEL_NONBLOCK}, - { "ind-ack-pending", FTDM_CHANNEL_IND_ACK_PENDING}, - { "blocking", FTDM_CHANNEL_BLOCKING}, - { "media", FTDM_CHANNEL_DIGITAL_MEDIA}, - { "native-sigbridge", FTDM_CHANNEL_NATIVE_SIGBRIDGE}, - { "sig-dtmf-detection", FTDM_CHANNEL_SIG_DTMF_DETECTION}, - { "invalid", FTDM_CHANNEL_MAX_FLAG}, -}; - -static val_str_t span_flag_strs[] = { - { "configured", FTDM_SPAN_CONFIGURED}, - { "started", FTDM_SPAN_STARTED}, - { "state-change", FTDM_SPAN_STATE_CHANGE}, - { "suspended", FTDM_SPAN_SUSPENDED}, - { "in-thread", FTDM_SPAN_IN_THREAD}, - { "stop-thread", FTDM_SPAN_STOP_THREAD}, - { "use-chan-queue", FTDM_SPAN_USE_CHAN_QUEUE}, - { "suggest-chan-id", FTDM_SPAN_SUGGEST_CHAN_ID}, - { "use-av-rate", FTDM_SPAN_USE_AV_RATE}, - { "power-saving", FTDM_SPAN_PWR_SAVING}, - { "signals-queue", FTDM_SPAN_USE_SIGNALS_QUEUE}, - { "proceed-state", FTDM_SPAN_USE_PROCEED_STATE}, - { "skip-state", FTDM_SPAN_USE_SKIP_STATES}, - { "non-stoppable", FTDM_SPAN_NON_STOPPABLE}, - { "use-transfer", FTDM_SPAN_USE_TRANSFER}, -}; - -static ftdm_status_t ftdm_call_set_call_id(ftdm_channel_t *fchan, ftdm_caller_data_t *caller_data); -static ftdm_status_t ftdm_call_clear_call_id(ftdm_caller_data_t *caller_data); -static ftdm_status_t ftdm_channel_done(ftdm_channel_t *ftdmchan); -static ftdm_status_t ftdm_channel_sig_indicate(ftdm_channel_t *ftdmchan, ftdm_channel_indication_t indication, ftdm_usrmsg_t *usrmsg); - -static const char *ftdm_val2str(unsigned long long val, val_str_t *val_str_table, ftdm_size_t array_size, const char *default_str); -static unsigned long long ftdm_str2val(const char *str, val_str_t *val_str_table, ftdm_size_t array_size, unsigned long long default_val); - - -static int time_is_init = 0; - -static void time_init(void) -{ -#ifdef WIN32 - timeBeginPeriod(1); -#endif - time_is_init = 1; -} - -static void time_end(void) -{ -#ifdef WIN32 - timeEndPeriod(1); -#endif - time_is_init = 0; -} - -FT_DECLARE(ftdm_time_t) ftdm_current_time_in_ms(void) -{ -#ifdef WIN32 - return timeGetTime(); -#else - struct timeval tv; - gettimeofday(&tv, NULL); - return ((tv.tv_sec * 1000) + (tv.tv_usec / 1000)); -#endif -} - -static void write_chan_io_dump(ftdm_io_dump_t *dump, char *dataptr, int dlen) -{ - int windex = dump->windex; - int avail = (int)dump->size - windex; - - if (!dump->buffer) { - return; - } - - if (dlen > avail) { - int diff = dlen - avail; - - ftdm_assert(diff < (int)dump->size, "Very small buffer or very big IO chunk!\n"); - - /* write only what we can and the rest at the beginning of the buffer */ - memcpy(&dump->buffer[windex], dataptr, avail); - memcpy(&dump->buffer[0], &dataptr[avail], diff); - windex = diff; - - /*ftdm_log_chan(fchan, FTDM_LOG_DEBUG, "wrapping around dump buffer %p up to index %d\n\n", dump, windex);*/ - dump->wrapped = 1; - } else { - memcpy(&dump->buffer[windex], dataptr, dlen); - windex += dlen; - } - - if (windex == (int)dump->size) { - /*ftdm_log_chan(fchan, FTDM_LOG_DEBUG, "wrapping around dump buffer %p\n", dump);*/ - windex = 0; - dump->wrapped = 1; - } - - dump->windex = windex; -} - -static void dump_chan_io_to_file(ftdm_channel_t *fchan, ftdm_io_dump_t *dump, FILE *file) -{ - /* write the saved audio buffer */ - ftdm_size_t rc = 0; - ftdm_size_t towrite = 0; - - if (!dump->buffer) { - return; - } - - towrite = dump->size - dump->windex; - - if (dump->wrapped) { - rc = fwrite(&dump->buffer[dump->windex], 1, towrite, file); - if (rc != towrite) { - ftdm_log_chan(fchan, FTDM_LOG_ERROR, "only wrote %"FTDM_SIZE_FMT" out of %"FTDM_SIZE_FMT" bytes in io dump buffer: %s\n", - rc, towrite, strerror(errno)); - } - } - if (dump->windex) { - towrite = dump->windex; - rc = fwrite(&dump->buffer[0], 1, towrite, file); - if (rc != towrite) { - ftdm_log_chan(fchan, FTDM_LOG_ERROR, "only wrote %"FTDM_SIZE_FMT" out of %"FTDM_SIZE_FMT" bytes in io dump buffer: %s\n", - rc, towrite, strerror(errno)); - } - } - dump->windex = 0; - dump->wrapped = 0; -} - -static void stop_chan_io_dump(ftdm_io_dump_t *dump) -{ - if (!dump->buffer) { - return; - } - ftdm_safe_free(dump->buffer); - memset(dump, 0, sizeof(*dump)); -} - -static ftdm_status_t start_chan_io_dump(ftdm_channel_t *chan, ftdm_io_dump_t *dump, ftdm_size_t size) -{ - if (dump->buffer) { - ftdm_log_chan_msg(chan, FTDM_LOG_ERROR, "IO dump is already started\n"); - return FTDM_FAIL; - } - memset(dump, 0, sizeof(*dump)); - dump->buffer = ftdm_malloc(size); - if (!dump->buffer) { - return FTDM_FAIL; - } - dump->size = size; - return FTDM_SUCCESS; -} - - -static void close_dtmf_debug_file(ftdm_channel_t *ftdmchan) -{ - if (ftdmchan->dtmfdbg.file) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "closing debug dtmf file\n"); - fclose(ftdmchan->dtmfdbg.file); - ftdmchan->dtmfdbg.file = NULL; - } -} - -static ftdm_status_t disable_dtmf_debug(ftdm_channel_t *ftdmchan) -{ - if (!ftdmchan->dtmfdbg.enabled) { - return FTDM_SUCCESS; - } - - if (!ftdmchan->rxdump.buffer) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "DTMF debug enabled but no rx dump?\n"); - return FTDM_FAIL; - } - - close_dtmf_debug_file(ftdmchan); - stop_chan_io_dump(&ftdmchan->rxdump); - ftdmchan->dtmfdbg.enabled = 0; - return FTDM_SUCCESS; -} - -typedef struct { - uint8_t enabled; - uint8_t running; - uint8_t alarm; - uint32_t interval; - uint8_t alarm_action_flags; - uint8_t set_alarm_threshold; - uint8_t clear_alarm_threshold; - ftdm_interrupt_t *interrupt; -} cpu_monitor_t; - -static struct { - ftdm_hash_t *interface_hash; - ftdm_hash_t *module_hash; - ftdm_hash_t *span_hash; - ftdm_hash_t *group_hash; - ftdm_mutex_t *mutex; - ftdm_mutex_t *span_mutex; - ftdm_mutex_t *group_mutex; - ftdm_sched_t *timingsched; - uint32_t span_index; - uint32_t group_index; - uint32_t running; - ftdm_span_t *spans; - ftdm_group_t *groups; - cpu_monitor_t cpu_monitor; - - ftdm_caller_data_t *call_ids[MAX_CALLIDS+1]; - ftdm_mutex_t *call_id_mutex; - uint32_t last_call_id; - char dtmfdebug_directory[1024]; -} globals; - -enum ftdm_enum_cpu_alarm_action_flags -{ - FTDM_CPU_ALARM_ACTION_WARN = (1 << 0), - FTDM_CPU_ALARM_ACTION_REJECT = (1 << 1) -}; - -/* enum lookup funcs */ -FTDM_ENUM_NAMES(TONEMAP_NAMES, TONEMAP_STRINGS) -FTDM_STR2ENUM(ftdm_str2ftdm_tonemap, ftdm_tonemap2str, ftdm_tonemap_t, TONEMAP_NAMES, FTDM_TONEMAP_INVALID) - -FTDM_ENUM_NAMES(OOB_NAMES, OOB_STRINGS) -FTDM_STR2ENUM(ftdm_str2ftdm_oob_event, ftdm_oob_event2str, ftdm_oob_event_t, OOB_NAMES, FTDM_OOB_INVALID) - -FTDM_ENUM_NAMES(TRUNK_TYPE_NAMES, TRUNK_TYPE_STRINGS) -FTDM_STR2ENUM(ftdm_str2ftdm_trunk_type, ftdm_trunk_type2str, ftdm_trunk_type_t, TRUNK_TYPE_NAMES, FTDM_TRUNK_NONE) - -FTDM_ENUM_NAMES(TRUNK_MODE_NAMES, TRUNK_MODE_STRINGS) -FTDM_STR2ENUM(ftdm_str2ftdm_trunk_mode, ftdm_trunk_mode2str, ftdm_trunk_mode_t, TRUNK_MODE_NAMES, FTDM_TRUNK_MODE_INVALID) - -FTDM_ENUM_NAMES(START_TYPE_NAMES, START_TYPE_STRINGS) -FTDM_STR2ENUM(ftdm_str2ftdm_analog_start_type, ftdm_analog_start_type2str, ftdm_analog_start_type_t, START_TYPE_NAMES, FTDM_ANALOG_START_NA) - -FTDM_ENUM_NAMES(SIGNAL_NAMES, SIGNAL_STRINGS) -FTDM_STR2ENUM(ftdm_str2ftdm_signal_event, ftdm_signal_event2str, ftdm_signal_event_t, SIGNAL_NAMES, FTDM_SIGEVENT_INVALID) - -FTDM_ENUM_NAMES(MDMF_TYPE_NAMES, MDMF_STRINGS) -FTDM_STR2ENUM(ftdm_str2ftdm_mdmf_type, ftdm_mdmf_type2str, ftdm_mdmf_type_t, MDMF_TYPE_NAMES, MDMF_INVALID) - -FTDM_ENUM_NAMES(CHAN_TYPE_NAMES, CHAN_TYPE_STRINGS) -FTDM_STR2ENUM(ftdm_str2ftdm_chan_type, ftdm_chan_type2str, ftdm_chan_type_t, CHAN_TYPE_NAMES, FTDM_CHAN_TYPE_COUNT) - -FTDM_ENUM_NAMES(SIGNALING_STATUS_NAMES, SIGSTATUS_STRINGS) -FTDM_STR2ENUM(ftdm_str2ftdm_signaling_status, ftdm_signaling_status2str, ftdm_signaling_status_t, SIGNALING_STATUS_NAMES, FTDM_SIG_STATE_INVALID) - -FTDM_ENUM_NAMES(TRACE_DIR_NAMES, TRACE_DIR_STRINGS) -FTDM_STR2ENUM(ftdm_str2ftdm_trace_dir, ftdm_trace_dir2str, ftdm_trace_dir_t, TRACE_DIR_NAMES, FTDM_TRACE_DIR_INVALID) - -FTDM_ENUM_NAMES(TRACE_TYPE_NAMES, TRACE_TYPE_STRINGS) -FTDM_STR2ENUM(ftdm_str2ftdm_trace_type, ftdm_trace_type2str, ftdm_trace_type_t, TRACE_TYPE_NAMES, FTDM_TRACE_TYPE_INVALID) - -FTDM_ENUM_NAMES(TON_NAMES, TON_STRINGS) -FTDM_STR2ENUM(ftdm_str2ftdm_ton, ftdm_ton2str, ftdm_ton_t, TON_NAMES, FTDM_TON_INVALID) - -FTDM_ENUM_NAMES(NPI_NAMES, NPI_STRINGS) -FTDM_STR2ENUM(ftdm_str2ftdm_npi, ftdm_npi2str, ftdm_npi_t, NPI_NAMES, FTDM_NPI_INVALID) - -FTDM_ENUM_NAMES(PRESENTATION_NAMES, PRESENTATION_STRINGS) -FTDM_STR2ENUM(ftdm_str2ftdm_presentation, ftdm_presentation2str, ftdm_presentation_t, PRESENTATION_NAMES, FTDM_PRES_INVALID) - -FTDM_ENUM_NAMES(SCREENING_NAMES, SCREENING_STRINGS) -FTDM_STR2ENUM(ftdm_str2ftdm_screening, ftdm_screening2str, ftdm_screening_t, SCREENING_NAMES, FTDM_SCREENING_INVALID) - -FTDM_ENUM_NAMES(BEARER_CAP_NAMES, BEARER_CAP_STRINGS) -FTDM_STR2ENUM(ftdm_str2ftdm_bearer_cap, ftdm_bearer_cap2str, ftdm_bearer_cap_t, BEARER_CAP_NAMES, FTDM_BEARER_CAP_INVALID) - -FTDM_ENUM_NAMES(USER_LAYER1_PROT_NAMES, USER_LAYER1_PROT_STRINGS) -FTDM_STR2ENUM(ftdm_str2ftdm_usr_layer1_prot, ftdm_user_layer1_prot2str, ftdm_user_layer1_prot_t, USER_LAYER1_PROT_NAMES, FTDM_USER_LAYER1_PROT_INVALID) - -FTDM_ENUM_NAMES(CALLING_PARTY_CATEGORY_NAMES, CALLING_PARTY_CATEGORY_STRINGS) -FTDM_STR2ENUM(ftdm_str2ftdm_calling_party_category, ftdm_calling_party_category2str, ftdm_calling_party_category_t, CALLING_PARTY_CATEGORY_NAMES, FTDM_CPC_INVALID) - -FTDM_ENUM_NAMES(INDICATION_NAMES, INDICATION_STRINGS) -FTDM_STR2ENUM(ftdm_str2ftdm_channel_indication, ftdm_channel_indication2str, ftdm_channel_indication_t, INDICATION_NAMES, FTDM_CHANNEL_INDICATE_INVALID) - -FTDM_ENUM_NAMES(TRANSFER_RESPONSE_NAMES, TRANSFER_RESPONSE_STRINGS) -FTDM_STR2ENUM(ftdm_str2ftdm_transfer_response, ftdm_transfer_response2str, ftdm_transfer_response_t, TRANSFER_RESPONSE_NAMES, FTDM_TRANSFER_RESPONSE_INVALID) - -static ftdm_status_t ftdm_group_add_channels(ftdm_span_t* span, int currindex, const char* name); - -static void null_logger(const char *file, const char *func, int line, int level, const char *fmt, ...) -{ - ftdm_unused_arg(file); - ftdm_unused_arg(func); - ftdm_unused_arg(line); - ftdm_unused_arg(level); - ftdm_unused_arg(fmt); -} - - -const char *FTDM_LEVEL_NAMES[9] = { - "EMERG", - "ALERT", - "CRIT", - "ERROR", - "WARNING", - "NOTICE", - "INFO", - "DEBUG", - NULL -}; - -static int ftdm_log_level = FTDM_LOG_LEVEL_DEBUG; - -static void default_logger(const char *file, const char *func, int line, int level, const char *fmt, ...) -{ - char data[1024]; - va_list ap; - - if (level < 0 || level > 7) { - level = 7; - } - if (level > ftdm_log_level) { - return; - } - - va_start(ap, fmt); - - vsnprintf(data, sizeof(data), fmt, ap); - - fprintf(stderr, "[%s] %s:%d %s() %s", FTDM_LEVEL_NAMES[level], file, line, func, data); - - va_end(ap); - -} - -static __inline__ void *ftdm_std_malloc(void *pool, ftdm_size_t size) -{ - void *ptr = malloc(size); - ftdm_unused_arg(pool); - ftdm_assert_return(ptr != NULL, NULL, "Out of memory\n"); - return ptr; -} - -static __inline__ void *ftdm_std_calloc(void *pool, ftdm_size_t elements, ftdm_size_t size) -{ - void *ptr = calloc(elements, size); - ftdm_unused_arg(pool); - ftdm_assert_return(ptr != NULL, NULL, "Out of memory\n"); - return ptr; -} - -static __inline__ void *ftdm_std_realloc(void *pool, void *buff, ftdm_size_t size) -{ - buff = realloc(buff, size); - ftdm_unused_arg(pool); - ftdm_assert_return(buff != NULL, NULL, "Out of memory\n"); - return buff; -} - -static __inline__ void ftdm_std_free(void *pool, void *ptr) -{ - ftdm_unused_arg(pool); - ftdm_assert_return(ptr != NULL, , "Attempted to free null pointer"); - free(ptr); -} - -FT_DECLARE(void) ftdm_set_echocancel_call_begin(ftdm_channel_t *chan) -{ - ftdm_caller_data_t *caller_data = ftdm_channel_get_caller_data(chan); - if (ftdm_channel_test_feature(chan, FTDM_CHANNEL_FEATURE_HWEC)) { - if (ftdm_channel_test_feature(chan, FTDM_CHANNEL_FEATURE_HWEC_DISABLED_ON_IDLE)) { - /* If the ec is disabled on idle, we need to enable it unless is a digital call */ - if (caller_data->bearer_capability != FTDM_BEARER_CAP_UNRESTRICTED) { - ftdm_log_chan(chan, FTDM_LOG_DEBUG, "Enabling ec for call in channel state %s\n", ftdm_channel_state2str(chan->state)); - ftdm_channel_command(chan, FTDM_COMMAND_ENABLE_ECHOCANCEL, NULL); - } - } else { - /* If the ec is enabled on idle, we do nothing unless is a digital call that needs it disabled */ - if (caller_data->bearer_capability == FTDM_BEARER_CAP_UNRESTRICTED) { - ftdm_log_chan(chan, FTDM_LOG_DEBUG, "Disabling ec for digital call in channel state %s\n", ftdm_channel_state2str(chan->state)); - ftdm_channel_command(chan, FTDM_COMMAND_DISABLE_ECHOCANCEL, NULL); - } - } - } -} - -FT_DECLARE(void) ftdm_set_echocancel_call_end(ftdm_channel_t *chan) -{ - if (ftdm_channel_test_feature(chan, FTDM_CHANNEL_FEATURE_HWEC)) { - if (ftdm_channel_test_feature(chan, FTDM_CHANNEL_FEATURE_HWEC_DISABLED_ON_IDLE)) { - ftdm_log_chan(chan, FTDM_LOG_DEBUG, "Disabling ec on call end in channel state %s\n", ftdm_channel_state2str(chan->state)); - ftdm_channel_command(chan, FTDM_COMMAND_DISABLE_ECHOCANCEL, NULL); - } else { - ftdm_log_chan(chan, FTDM_LOG_DEBUG, "Enabling ec back on call end in channel state %s\n", ftdm_channel_state2str(chan->state)); - ftdm_channel_command(chan, FTDM_COMMAND_ENABLE_ECHOCANCEL, NULL); - } - } -} - -FT_DECLARE_DATA ftdm_memory_handler_t g_ftdm_mem_handler = -{ - /*.pool =*/ NULL, - /*.malloc =*/ ftdm_std_malloc, - /*.calloc =*/ ftdm_std_calloc, - /*.realloc =*/ ftdm_std_realloc, - /*.free =*/ ftdm_std_free -}; - -FT_DECLARE_DATA ftdm_crash_policy_t g_ftdm_crash_policy = FTDM_CRASH_NEVER; - -static ftdm_status_t ftdm_set_caller_data(ftdm_span_t *span, ftdm_caller_data_t *caller_data) -{ - if (!caller_data) { - ftdm_log(FTDM_LOG_CRIT, "Error: trying to set caller data, but no caller_data!\n"); - return FTDM_FAIL; - } - - if (caller_data->dnis.plan >= FTDM_NPI_INVALID) { - caller_data->dnis.plan = span->default_caller_data.dnis.plan; - } - - if (caller_data->dnis.type >= FTDM_TON_INVALID) { - caller_data->dnis.type = span->default_caller_data.dnis.type; - } - - if (caller_data->cid_num.plan >= FTDM_NPI_INVALID) { - caller_data->cid_num.plan = span->default_caller_data.cid_num.plan; - } - - if (caller_data->cid_num.type >= FTDM_TON_INVALID) { - caller_data->cid_num.type = span->default_caller_data.cid_num.type; - } - - if (caller_data->ani.plan >= FTDM_NPI_INVALID) { - caller_data->ani.plan = span->default_caller_data.ani.plan; - } - - if (caller_data->ani.type >= FTDM_TON_INVALID) { - caller_data->ani.type = span->default_caller_data.ani.type; - } - - if (caller_data->rdnis.plan >= FTDM_NPI_INVALID) { - caller_data->rdnis.plan = span->default_caller_data.rdnis.plan; - } - - if (caller_data->rdnis.type >= FTDM_NPI_INVALID) { - caller_data->rdnis.type = span->default_caller_data.rdnis.type; - } - - if (caller_data->bearer_capability >= FTDM_BEARER_CAP_INVALID) { - caller_data->bearer_capability = span->default_caller_data.bearer_capability; - } - - if (caller_data->bearer_layer1 >= FTDM_USER_LAYER1_PROT_INVALID) { - caller_data->bearer_layer1 = span->default_caller_data.bearer_layer1; - } - - if (FTDM_FAIL == ftdm_is_number(caller_data->cid_num.digits)) { - ftdm_log(FTDM_LOG_DEBUG, "dropping caller id number %s since we only accept digits\n", caller_data->cid_num.digits); - caller_data->cid_num.digits[0] = '\0'; - } - - return FTDM_SUCCESS; -} - -FT_DECLARE(ftdm_status_t) ftdm_channel_set_caller_data(ftdm_channel_t *ftdmchan, ftdm_caller_data_t *caller_data) -{ - ftdm_status_t err = FTDM_SUCCESS; - if (!ftdmchan) { - ftdm_log(FTDM_LOG_CRIT, "trying to set caller data, but no ftdmchan!\n"); - return FTDM_FAIL; - } - if ((err = ftdm_set_caller_data(ftdmchan->span, caller_data)) != FTDM_SUCCESS) { - return err; - } - ftdmchan->caller_data = *caller_data; - if (ftdmchan->caller_data.bearer_capability == FTDM_BEARER_CAP_UNRESTRICTED) { - ftdm_set_flag(ftdmchan, FTDM_CHANNEL_DIGITAL_MEDIA); - } - return FTDM_SUCCESS; -} - -FT_DECLARE_DATA ftdm_logger_t ftdm_log = null_logger; - -FT_DECLARE(void) ftdm_global_set_crash_policy(ftdm_crash_policy_t policy) -{ - g_ftdm_crash_policy |= policy; -} - -FT_DECLARE(ftdm_status_t) ftdm_global_set_memory_handler(ftdm_memory_handler_t *handler) -{ - if (!handler) { - return FTDM_FAIL; - } - if (!handler->malloc) { - return FTDM_FAIL; - } - if (!handler->calloc) { - return FTDM_FAIL; - } - if (!handler->free) { - return FTDM_FAIL; - } - memcpy(&g_ftdm_mem_handler, handler, sizeof(*handler)); - return FTDM_SUCCESS; -} - -FT_DECLARE(void) ftdm_global_set_logger(ftdm_logger_t logger) -{ - if (logger) { - ftdm_log = logger; - } else { - ftdm_log = null_logger; - } -} - -FT_DECLARE(void) ftdm_global_set_default_logger(int level) -{ - if (level < 0 || level > 7) { - level = 7; - } - - ftdm_log = default_logger; - ftdm_log_level = level; -} - -FT_DECLARE_NONSTD(int) ftdm_hash_equalkeys(void *k1, void *k2) -{ - return strcmp((char *) k1, (char *) k2) ? 0 : 1; -} - -FT_DECLARE_NONSTD(uint32_t) ftdm_hash_hashfromstring(void *ky) -{ - unsigned char *str = (unsigned char *) ky; - uint32_t hash = 0; - int c; - - while ((c = *str++)) { - hash = c + (hash << 6) + (hash << 16) - hash; - } - - return hash; -} - -static ftdm_status_t ftdm_channel_destroy(ftdm_channel_t *ftdmchan) -{ - - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_CONFIGURED)) { - - while (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_INTHREAD)) { - ftdm_log(FTDM_LOG_INFO, "Waiting for thread to exit on channel %u:%u\n", ftdmchan->span_id, ftdmchan->chan_id); - ftdm_sleep(500); - } - - ftdm_mutex_lock(ftdmchan->pre_buffer_mutex); - ftdm_buffer_destroy(&ftdmchan->pre_buffer); - ftdm_mutex_unlock(ftdmchan->pre_buffer_mutex); - - ftdm_buffer_destroy(&ftdmchan->digit_buffer); - ftdm_buffer_destroy(&ftdmchan->gen_dtmf_buffer); - ftdm_buffer_destroy(&ftdmchan->dtmf_buffer); - ftdm_buffer_destroy(&ftdmchan->fsk_buffer); - ftdmchan->pre_buffer_size = 0; - - ftdm_safe_free(ftdmchan->dtmf_hangup_buf); - - if (ftdmchan->tone_session.buffer) { - teletone_destroy_session(&ftdmchan->tone_session); - memset(&ftdmchan->tone_session, 0, sizeof(ftdmchan->tone_session)); - } - - - if (ftdmchan->span->fio->channel_destroy) { - ftdm_log(FTDM_LOG_INFO, "Closing channel %s:%u:%u fd:%d\n", ftdmchan->span->type, ftdmchan->span_id, ftdmchan->chan_id, ftdmchan->sockfd); - if (ftdmchan->span->fio->channel_destroy(ftdmchan) == FTDM_SUCCESS) { - ftdm_clear_flag_locked(ftdmchan, FTDM_CHANNEL_CONFIGURED); - } else { - ftdm_log(FTDM_LOG_ERROR, "Error Closing channel %u:%u fd:%d\n", ftdmchan->span_id, ftdmchan->chan_id, ftdmchan->sockfd); - } - } - - ftdm_mutex_destroy(&ftdmchan->mutex); - ftdm_mutex_destroy(&ftdmchan->pre_buffer_mutex); - if (ftdmchan->state_completed_interrupt) { - ftdm_interrupt_destroy(&ftdmchan->state_completed_interrupt); - } - } - - return FTDM_SUCCESS; -} - -static ftdm_status_t ftdm_span_destroy(ftdm_span_t *span) -{ - ftdm_status_t status = FTDM_SUCCESS; - unsigned j; - - /* The signaling must be already stopped (this is just a sanity check, should never happen) */ - ftdm_assert_return(!ftdm_test_flag(span, FTDM_SPAN_STARTED), FTDM_FAIL, "Signaling for span %s has not been stopped, refusing to destroy span\n"); - - ftdm_mutex_lock(span->mutex); - - /* destroy the channels */ - ftdm_clear_flag(span, FTDM_SPAN_CONFIGURED); - for(j = 1; j <= span->chan_count && span->channels[j]; j++) { - ftdm_channel_t *cur_chan = span->channels[j]; - if (cur_chan) { - if (ftdm_test_flag(cur_chan, FTDM_CHANNEL_CONFIGURED)) { - ftdm_channel_destroy(cur_chan); - } - ftdm_safe_free(cur_chan); - cur_chan = NULL; - } - } - - /* destroy the I/O for the span */ - if (span->fio && span->fio->span_destroy) { - ftdm_log(FTDM_LOG_INFO, "Destroying span %u type (%s)\n", span->span_id, span->type); - if (span->fio->span_destroy(span) != FTDM_SUCCESS) { - status = FTDM_FAIL; - } - } - - /* destroy final basic resources of the span data structure */ - if (span->pendingchans) { - ftdm_queue_destroy(&span->pendingchans); - } - if (span->pendingsignals) { - ftdm_sigmsg_t *sigmsg = NULL; - while ((sigmsg = ftdm_queue_dequeue(span->pendingsignals))) { - ftdm_sigmsg_free(&sigmsg); - } - ftdm_queue_destroy(&span->pendingsignals); - } - ftdm_mutex_unlock(span->mutex); - ftdm_mutex_destroy(&span->mutex); - - /* Give the span a chance to destroy its own signaling data */ - if (span->destroy) { - span->destroy(span); - } else if (span->signal_data) { - /* We take care of their dirty business ... */ - ftdm_free(span->signal_data); - } - - return status; -} - -FT_DECLARE(ftdm_status_t) ftdm_channel_get_alarms(ftdm_channel_t *ftdmchan, ftdm_alarm_flag_t *alarmbits) -{ - ftdm_status_t status = FTDM_FAIL; - - ftdm_assert_return(alarmbits != NULL, FTDM_EINVAL, "null alarmbits argument\n"); - ftdm_assert_return(ftdmchan != NULL, FTDM_EINVAL, "null channel argument\n"); - ftdm_assert_return(ftdmchan->span != NULL, FTDM_EINVAL, "null span\n"); - ftdm_assert_return(ftdmchan->span->fio != NULL, FTDM_EINVAL, "null io\n"); - - *alarmbits = FTDM_ALARM_NONE; - - if (!ftdmchan->span->fio->get_alarms) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "No get_alarms interface for this channel\n"); - return FTDM_ENOSYS; - } - - if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_CONFIGURED)) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "Cannot get alarms from an unconfigured channel\n"); - return FTDM_EINVAL; - } - - ftdm_channel_lock(ftdmchan); - - if ((status = ftdmchan->span->fio->get_alarms(ftdmchan)) != FTDM_SUCCESS) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "Failed to get alarms from channel\n"); - goto done; - } - - *ftdmchan->last_error = '\0'; - *alarmbits = ftdmchan->alarm_flags; - if (ftdm_test_alarm_flag(ftdmchan, FTDM_ALARM_RED)) { - snprintf(ftdmchan->last_error + strlen(ftdmchan->last_error), sizeof(ftdmchan->last_error) - strlen(ftdmchan->last_error), "RED/"); - } - if (ftdm_test_alarm_flag(ftdmchan, FTDM_ALARM_YELLOW)) { - snprintf(ftdmchan->last_error + strlen(ftdmchan->last_error), sizeof(ftdmchan->last_error) - strlen(ftdmchan->last_error), "YELLOW/"); - } - if (ftdm_test_alarm_flag(ftdmchan, FTDM_ALARM_RAI)) { - snprintf(ftdmchan->last_error + strlen(ftdmchan->last_error), sizeof(ftdmchan->last_error) - strlen(ftdmchan->last_error), "RAI/"); - } - if (ftdm_test_alarm_flag(ftdmchan, FTDM_ALARM_BLUE)) { - snprintf(ftdmchan->last_error + strlen(ftdmchan->last_error), sizeof(ftdmchan->last_error) - strlen(ftdmchan->last_error), "BLUE/"); - } - if (ftdm_test_alarm_flag(ftdmchan, FTDM_ALARM_AIS)) { - snprintf(ftdmchan->last_error + strlen(ftdmchan->last_error), sizeof(ftdmchan->last_error) - strlen(ftdmchan->last_error), "AIS/"); - } - if (ftdm_test_alarm_flag(ftdmchan, FTDM_ALARM_GENERAL)) { - snprintf(ftdmchan->last_error + strlen(ftdmchan->last_error), sizeof(ftdmchan->last_error) - strlen(ftdmchan->last_error), "GENERAL"); - } - *(ftdmchan->last_error + strlen(ftdmchan->last_error) - 1) = '\0'; - -done: - - ftdm_channel_unlock(ftdmchan); - - return status; -} - -static void ftdm_span_add(ftdm_span_t *span) -{ - ftdm_span_t *sp; - ftdm_mutex_lock(globals.span_mutex); - for (sp = globals.spans; sp && sp->next; sp = sp->next); - if (sp) { - sp->next = span; - } else { - globals.spans = span; - } - hashtable_insert(globals.span_hash, (void *)span->name, span, HASHTABLE_FLAG_FREE_VALUE); - ftdm_mutex_unlock(globals.span_mutex); -} - -FT_DECLARE(ftdm_status_t) ftdm_span_stop(ftdm_span_t *span) -{ - ftdm_status_t status = FTDM_SUCCESS; - - ftdm_mutex_lock(span->mutex); - - if (ftdm_test_flag(span, FTDM_SPAN_NON_STOPPABLE)) { - status = FTDM_NOTIMPL; - goto done; - } - - if (!ftdm_test_flag(span, FTDM_SPAN_STARTED)) { - status = FTDM_EINVAL; - goto done; - } - - if (!span->stop) { - status = FTDM_ENOSYS; - goto done; - } - - /* Stop SIG */ - status = span->stop(span); - if (status == FTDM_SUCCESS) { - ftdm_clear_flag(span, FTDM_SPAN_STARTED); - } - - /* Stop I/O */ - if (span->fio && span->fio->span_stop) { - status = span->fio->span_stop(span); - } -done: - ftdm_mutex_unlock(span->mutex); - - return status; -} - -FT_DECLARE(ftdm_status_t) ftdm_span_create(const char *iotype, const char *name, ftdm_span_t **span) -{ - ftdm_span_t *new_span = NULL; - ftdm_io_interface_t *fio = NULL; - ftdm_status_t status = FTDM_FAIL; - char buf[128] = ""; - - ftdm_assert_return(iotype != NULL, FTDM_FAIL, "No IO type provided\n"); - ftdm_assert_return(name != NULL, FTDM_FAIL, "No span name provided\n"); - - *span = NULL; - - fio = ftdm_global_get_io_interface(iotype, FTDM_TRUE); - if (!fio) { - ftdm_log(FTDM_LOG_CRIT, "failure creating span, no such I/O type '%s'\n", iotype); - return FTDM_FAIL; - } - - if (!fio->configure_span) { - ftdm_log(FTDM_LOG_CRIT, "failure creating span, no configure_span method for I/O type '%s'\n", iotype); - return FTDM_FAIL; - } - - ftdm_mutex_lock(globals.mutex); - if (globals.span_index < FTDM_MAX_SPANS_INTERFACE) { - new_span = ftdm_calloc(sizeof(*new_span), 1); - - ftdm_assert(new_span, "allocating span failed\n"); - - status = ftdm_mutex_create(&new_span->mutex); - ftdm_assert(status == FTDM_SUCCESS, "mutex creation failed\n"); - - ftdm_set_flag(new_span, FTDM_SPAN_CONFIGURED); - new_span->span_id = ++globals.span_index; - new_span->fio = fio; - ftdm_copy_string(new_span->tone_map[FTDM_TONEMAP_DIAL], "%(1000,0,350,440)", FTDM_TONEMAP_LEN); - ftdm_copy_string(new_span->tone_map[FTDM_TONEMAP_RING], "%(2000,4000,440,480)", FTDM_TONEMAP_LEN); - ftdm_copy_string(new_span->tone_map[FTDM_TONEMAP_BUSY], "%(500,500,480,620)", FTDM_TONEMAP_LEN); - ftdm_copy_string(new_span->tone_map[FTDM_TONEMAP_ATTN], "%(100,100,1400,2060,2450,2600)", FTDM_TONEMAP_LEN); - new_span->trunk_type = FTDM_TRUNK_NONE; - new_span->trunk_mode = FTDM_TRUNK_MODE_CPE; - new_span->data_type = FTDM_TYPE_SPAN; - - ftdm_mutex_lock(globals.span_mutex); - if (!ftdm_strlen_zero(name) && hashtable_search(globals.span_hash, (void *)name)) { - ftdm_log(FTDM_LOG_WARNING, "name %s is already used, substituting 'span%d' as the name\n", name, new_span->span_id); - name = NULL; - } - ftdm_mutex_unlock(globals.span_mutex); - - if (!name) { - snprintf(buf, sizeof(buf), "span%d", new_span->span_id); - name = buf; - } - new_span->name = ftdm_strdup(name); - new_span->type = ftdm_strdup(iotype); - ftdm_span_add(new_span); - *span = new_span; - status = FTDM_SUCCESS; - } - ftdm_mutex_unlock(globals.mutex); - return status; -} - -FT_DECLARE(ftdm_status_t) ftdm_span_close_all(void) -{ - ftdm_span_t *span; - uint32_t i = 0, j; - - ftdm_mutex_lock(globals.span_mutex); - for (span = globals.spans; span; span = span->next) { - if (ftdm_test_flag(span, FTDM_SPAN_CONFIGURED)) { - for(j = 1; j <= span->chan_count && span->channels[j]; j++) { - ftdm_channel_t *toclose = span->channels[j]; - if (ftdm_test_flag(toclose, FTDM_CHANNEL_INUSE)) { - ftdm_channel_close(&toclose); - } - i++; - } - } - } - ftdm_mutex_unlock(globals.span_mutex); - - return i ? FTDM_SUCCESS : FTDM_FAIL; -} - -FT_DECLARE(ftdm_status_t) ftdm_span_load_tones(ftdm_span_t *span, const char *mapname) -{ - ftdm_config_t cfg; - char *var, *val; - int x = 0; - - if (!ftdm_config_open_file(&cfg, "tones.conf")) { - snprintf(span->last_error, sizeof(span->last_error), "error loading tones."); - return FTDM_FAIL; - } - - while (ftdm_config_next_pair(&cfg, &var, &val)) { - int detect = 0; - - if (!strcasecmp(cfg.category, mapname) && var && val) { - uint32_t index; - char *name = NULL; - - if (!strncasecmp(var, "detect-", 7)) { - name = var + 7; - detect = 1; - } else if (!strncasecmp(var, "generate-", 9)) { - name = var + 9; - } else { - ftdm_log(FTDM_LOG_WARNING, "Unknown tone name %s\n", var); - continue; - } - - index = ftdm_str2ftdm_tonemap(name); - - if (index >= FTDM_TONEMAP_INVALID || index == FTDM_TONEMAP_NONE) { - ftdm_log(FTDM_LOG_WARNING, "Unknown tone name %s\n", name); - } else { - if (detect) { - char *p = val, *next; - int i = 0; - do { - teletone_process_t this; - next = strchr(p, ','); - this = (teletone_process_t)atof(p); - span->tone_detect_map[index].freqs[i++] = this; - if (next) { - p = next + 1; - } - } while (next); - ftdm_log(FTDM_LOG_DEBUG, "added tone detect [%s] = [%s]\n", name, val); - } else { - ftdm_log(FTDM_LOG_DEBUG, "added tone generation [%s] = [%s]\n", name, val); - ftdm_copy_string(span->tone_map[index], val, sizeof(span->tone_map[index])); - } - x++; - } - } - } - - ftdm_config_close_file(&cfg); - - if (!x) { - snprintf(span->last_error, sizeof(span->last_error), "error loading tones."); - return FTDM_FAIL; - } - - return FTDM_SUCCESS; - -} - -#define FTDM_SLINEAR_MAX_VALUE 32767 -#define FTDM_SLINEAR_MIN_VALUE -32767 -static void reset_gain_table(uint8_t *gain_table, float new_gain, ftdm_codec_t codec_gain) -{ - /* sample value */ - uint8_t sv = 0; - /* linear gain factor */ - float lingain = 0; - /* linear value for each table sample */ - float linvalue = 0; - /* amplified (or attenuated in case of negative amplification) sample value */ - int ampvalue = 0; - - /* gain tables are only for alaw and ulaw */ - if (codec_gain != FTDM_CODEC_ALAW && codec_gain != FTDM_CODEC_ULAW) { - ftdm_log(FTDM_LOG_DEBUG, "Not resetting gain table because codec is not ALAW or ULAW but %d\n", codec_gain); - return; - } - - if (!new_gain) { - /* for a 0.0db gain table, each alaw/ulaw sample value is left untouched (0 ==0, 1 == 1, 2 == 2 etc)*/ - sv = 0; - while (1) { - gain_table[sv] = sv; - if (sv == (FTDM_GAINS_TABLE_SIZE-1)) { - break; - } - sv++; - } - return; - } - - /* use the 20log rule to increase the gain: http://en.wikipedia.org/wiki/Gain, http:/en.wipedia.org/wiki/20_log_rule#Definitions */ - lingain = (float)pow(10.0, new_gain/ 20.0); - sv = 0; - while (1) { - /* get the linear value for this alaw/ulaw sample value */ - linvalue = codec_gain == FTDM_CODEC_ALAW ? (float)alaw_to_linear(sv) : (float)ulaw_to_linear(sv); - - /* multiply the linear value and the previously calculated linear gain */ - ampvalue = (int)(linvalue * lingain); - - /* chop it if goes beyond the limits */ - if (ampvalue > FTDM_SLINEAR_MAX_VALUE) { - ampvalue = FTDM_SLINEAR_MAX_VALUE; - } - - if (ampvalue < FTDM_SLINEAR_MIN_VALUE) { - ampvalue = FTDM_SLINEAR_MIN_VALUE; - } - gain_table[sv] = codec_gain == FTDM_CODEC_ALAW ? linear_to_alaw(ampvalue) : linear_to_ulaw(ampvalue); - if (sv == (FTDM_GAINS_TABLE_SIZE-1)) { - break; - } - sv++; - } -} - -FT_DECLARE(ftdm_status_t) ftdm_span_add_channel(ftdm_span_t *span, ftdm_socket_t sockfd, ftdm_chan_type_t type, ftdm_channel_t **chan) -{ - unsigned char i = 0; - if (span->chan_count < FTDM_MAX_CHANNELS_SPAN) { - ftdm_channel_t *new_chan = span->channels[++span->chan_count]; - - if (!new_chan) { -#ifdef FTDM_DEBUG_CHAN_MEMORY - void *chanmem = NULL; - int pages = 1; - int pagesize = sysconf(_SC_PAGE_SIZE); - if (sizeof(*new_chan) > pagesize) { - pages = sizeof(*new_chan)/pagesize; - pages++; - } - ftdm_log(FTDM_LOG_DEBUG, "Allocating %d pages of %d bytes for channel of size %d\n", pages, pagesize, sizeof(*new_chan)); - if (posix_memalign(&chanmem, pagesize, pagesize*pages)) { - return FTDM_FAIL; - } - ftdm_log(FTDM_LOG_DEBUG, "Channel pages allocated start at mem %p\n", chanmem); - memset(chanmem, 0, sizeof(*new_chan)); - new_chan = chanmem; -#else - if (!(new_chan = ftdm_calloc(1, sizeof(*new_chan)))) { - return FTDM_FAIL; - } -#endif - span->channels[span->chan_count] = new_chan; - } - - new_chan->type = type; - new_chan->sockfd = sockfd; - new_chan->fio = span->fio; - new_chan->span_id = span->span_id; - new_chan->chan_id = span->chan_count; - new_chan->span = span; - new_chan->fds[FTDM_READ_TRACE_INDEX] = -1; - new_chan->fds[FTDM_WRITE_TRACE_INDEX] = -1; - new_chan->data_type = FTDM_TYPE_CHANNEL; - if (!new_chan->dtmf_on) { - new_chan->dtmf_on = FTDM_DEFAULT_DTMF_ON; - } - - if (!new_chan->dtmf_off) { - new_chan->dtmf_off = FTDM_DEFAULT_DTMF_OFF; - } - - ftdm_mutex_create(&new_chan->mutex); - ftdm_mutex_create(&new_chan->pre_buffer_mutex); - - ftdm_buffer_create(&new_chan->digit_buffer, 128, 128, 0); - ftdm_buffer_create(&new_chan->gen_dtmf_buffer, 128, 128, 0); - - new_chan->dtmf_hangup_buf = ftdm_calloc (span->dtmf_hangup_len + 1, sizeof (char)); - - /* set 0.0db gain table */ - i = 0; - while (1) { - new_chan->txgain_table[i] = i; - new_chan->rxgain_table[i] = i; - if (i == (sizeof(new_chan->txgain_table)-1)) { - break; - } - i++; - } - - ftdm_set_flag(new_chan, FTDM_CHANNEL_CONFIGURED | FTDM_CHANNEL_READY); - new_chan->state = FTDM_CHANNEL_STATE_DOWN; - new_chan->state_status = FTDM_STATE_STATUS_COMPLETED; - *chan = new_chan; - return FTDM_SUCCESS; - } - - return FTDM_FAIL; -} - -FT_DECLARE(ftdm_status_t) ftdm_span_find_by_name(const char *name, ftdm_span_t **span) -{ - ftdm_status_t status = FTDM_FAIL; - - ftdm_mutex_lock(globals.span_mutex); - if (!ftdm_strlen_zero(name)) { - if ((*span = hashtable_search(globals.span_hash, (void *)name))) { - status = FTDM_SUCCESS; - } else { - int span_id = atoi(name); - - ftdm_span_find(span_id, span); - if (*span) { - status = FTDM_SUCCESS; - } - } - } - ftdm_mutex_unlock(globals.span_mutex); - - return status; -} - -FT_DECLARE(ftdm_status_t) ftdm_span_find(uint32_t id, ftdm_span_t **span) -{ - ftdm_span_t *fspan = NULL, *sp; - - if (id > FTDM_MAX_SPANS_INTERFACE) { - return FTDM_FAIL; - } - - ftdm_mutex_lock(globals.span_mutex); - for (sp = globals.spans; sp; sp = sp->next) { - if (sp->span_id == id) { - fspan = sp; - break; - } - } - ftdm_mutex_unlock(globals.span_mutex); - - if (!fspan || !ftdm_test_flag(fspan, FTDM_SPAN_CONFIGURED)) { - return FTDM_FAIL; - } - - *span = fspan; - - return FTDM_SUCCESS; - -} - -FT_DECLARE(ftdm_status_t) ftdm_span_poll_event(ftdm_span_t *span, uint32_t ms, short *poll_events) -{ - assert(span->fio != NULL); - - if (span->fio->poll_event) { - return span->fio->poll_event(span, ms, poll_events); - } else { - ftdm_log(FTDM_LOG_ERROR, "poll_event method not implemented in module %s!", span->fio->name); - } - - return FTDM_NOTIMPL; -} - -/* handle oob events and send the proper SIGEVENT signal to user, when applicable */ -static __inline__ ftdm_status_t ftdm_event_handle_oob(ftdm_event_t *event) -{ - ftdm_sigmsg_t sigmsg; - ftdm_status_t status = FTDM_SUCCESS; - ftdm_channel_t *fchan = event->channel; - ftdm_span_t *span = fchan->span; - - memset(&sigmsg, 0, sizeof(sigmsg)); - sigmsg.span_id = span->span_id; - sigmsg.chan_id = fchan->chan_id; - sigmsg.channel = fchan; - switch (event->enum_id) { - case FTDM_OOB_ALARM_CLEAR: - { - sigmsg.event_id = FTDM_SIGEVENT_ALARM_CLEAR; - ftdm_clear_flag_locked(fchan, FTDM_CHANNEL_IN_ALARM); - status = ftdm_span_send_signal(span, &sigmsg); - } - break; - case FTDM_OOB_ALARM_TRAP: - { - sigmsg.event_id = FTDM_SIGEVENT_ALARM_TRAP; - ftdm_set_flag_locked(fchan, FTDM_CHANNEL_IN_ALARM); - status = ftdm_span_send_signal(span, &sigmsg); - } - break; - default: - /* NOOP */ - break; - } - return status; -} - -FT_DECLARE(ftdm_status_t) ftdm_span_next_event(ftdm_span_t *span, ftdm_event_t **event) -{ - ftdm_status_t status = FTDM_FAIL; - ftdm_assert_return(span->fio != NULL, FTDM_FAIL, "No I/O module attached to this span!\n"); - - if (!span->fio->next_event) { - ftdm_log(FTDM_LOG_ERROR, "next_event method not implemented in module %s!", span->fio->name); - return FTDM_NOTIMPL; - } - - status = span->fio->next_event(span, event); - if (status != FTDM_SUCCESS) { - return status; - } - - status = ftdm_event_handle_oob(*event); - if (status != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "failed to handle event %d\n", (*event)->e_type); - } - return status; -} - -FT_DECLARE(ftdm_status_t) ftdm_channel_read_event(ftdm_channel_t *ftdmchan, ftdm_event_t **event) -{ - ftdm_status_t status = FTDM_FAIL; - ftdm_span_t *span = ftdmchan->span; - ftdm_assert_return(span->fio != NULL, FTDM_FAIL, "No I/O module attached to this span!\n"); - - ftdm_channel_lock(ftdmchan); - - if (!span->fio->channel_next_event) { - ftdm_log(FTDM_LOG_ERROR, "channel_next_event method not implemented in module %s!\n", span->fio->name); - status = FTDM_NOTIMPL; - goto done; - } - - if (ftdm_test_io_flag(ftdmchan, FTDM_CHANNEL_IO_EVENT)) { - ftdm_clear_io_flag(ftdmchan, FTDM_CHANNEL_IO_EVENT); - } - - status = span->fio->channel_next_event(ftdmchan, event); - if (status != FTDM_SUCCESS) { - goto done; - } - - status = ftdm_event_handle_oob(*event); - if (status != FTDM_SUCCESS) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "failed to handle event %d\n", (*event)->e_type); - } - -done: - ftdm_channel_unlock(ftdmchan); - return status; -} - -static ftdm_status_t ftdmchan_fsk_write_sample(int16_t *buf, ftdm_size_t buflen, void *user_data) -{ - ftdm_channel_t *ftdmchan = (ftdm_channel_t *) user_data; - ftdm_buffer_write(ftdmchan->fsk_buffer, buf, buflen * 2); - return FTDM_SUCCESS; -} - -FT_DECLARE(ftdm_status_t) ftdm_channel_send_fsk_data(ftdm_channel_t *ftdmchan, ftdm_fsk_data_state_t *fsk_data, float db_level) -{ - struct ftdm_fsk_modulator fsk_trans; - - if (!ftdmchan->fsk_buffer) { - ftdm_buffer_create(&ftdmchan->fsk_buffer, 128, 128, 0); - } else { - ftdm_buffer_zero(ftdmchan->fsk_buffer); - } - - if (ftdmchan->token_count > 1) { - ftdm_fsk_modulator_init(&fsk_trans, FSK_BELL202, ftdmchan->rate, fsk_data, db_level, 80, 5, 0, ftdmchan_fsk_write_sample, ftdmchan); - ftdm_fsk_modulator_send_all((&fsk_trans)); - } else { - ftdm_fsk_modulator_init(&fsk_trans, FSK_BELL202, ftdmchan->rate, fsk_data, db_level, 180, 5, 300, ftdmchan_fsk_write_sample, ftdmchan); - ftdm_fsk_modulator_send_all((&fsk_trans)); - ftdmchan->buffer_delay = 3500 / ftdmchan->effective_interval; - } - - return FTDM_SUCCESS; -} - -FT_DECLARE(ftdm_status_t) ftdm_channel_clear_token(ftdm_channel_t *ftdmchan, const char *token) -{ - ftdm_status_t status = FTDM_FAIL; - - ftdm_mutex_lock(ftdmchan->mutex); - if (token == NULL) { - memset(ftdmchan->tokens, 0, sizeof(ftdmchan->tokens)); - ftdmchan->token_count = 0; - } else if (*token != '\0') { - char tokens[FTDM_MAX_TOKENS][FTDM_TOKEN_STRLEN]; - int32_t i, count = ftdmchan->token_count; - memcpy(tokens, ftdmchan->tokens, sizeof(tokens)); - memset(ftdmchan->tokens, 0, sizeof(ftdmchan->tokens)); - ftdmchan->token_count = 0; - - for (i = 0; i < count; i++) { - if (strcmp(tokens[i], token)) { - ftdm_copy_string(ftdmchan->tokens[ftdmchan->token_count], tokens[i], sizeof(ftdmchan->tokens[ftdmchan->token_count])); - ftdmchan->token_count++; - } - } - - status = FTDM_SUCCESS; - } - ftdm_mutex_unlock(ftdmchan->mutex); - - return status; -} - -FT_DECLARE(void) ftdm_channel_rotate_tokens(ftdm_channel_t *ftdmchan) -{ - if (ftdmchan->token_count) { - memmove(ftdmchan->tokens[1], ftdmchan->tokens[0], ftdmchan->token_count * FTDM_TOKEN_STRLEN); - ftdm_copy_string(ftdmchan->tokens[0], ftdmchan->tokens[ftdmchan->token_count], FTDM_TOKEN_STRLEN); - *ftdmchan->tokens[ftdmchan->token_count] = '\0'; - } -} - -FT_DECLARE(void) ftdm_channel_replace_token(ftdm_channel_t *ftdmchan, const char *old_token, const char *new_token) -{ - unsigned int i; - - if (ftdmchan->token_count) { - for(i = 0; i < ftdmchan->token_count; i++) { - if (!strcmp(ftdmchan->tokens[i], old_token)) { - ftdm_copy_string(ftdmchan->tokens[i], new_token, FTDM_TOKEN_STRLEN); - break; - } - } - } -} - -FT_DECLARE(void) ftdm_channel_set_private(ftdm_channel_t *ftdmchan, void *pvt) -{ - ftdmchan->user_private = pvt; -} - -FT_DECLARE(void *) ftdm_channel_get_private(const ftdm_channel_t *ftdmchan) -{ - return ftdmchan->user_private; -} - -FT_DECLARE(uint32_t) ftdm_channel_get_token_count(const ftdm_channel_t *ftdmchan) -{ - uint32_t count; - ftdm_mutex_lock(ftdmchan->mutex); - count = ftdmchan->token_count; - ftdm_mutex_unlock(ftdmchan->mutex); - return count; -} - -FT_DECLARE(uint32_t) ftdm_channel_get_io_interval(const ftdm_channel_t *ftdmchan) -{ - uint32_t count; - ftdm_mutex_lock(ftdmchan->mutex); - count = ftdmchan->effective_interval; - ftdm_mutex_unlock(ftdmchan->mutex); - return count; -} - -FT_DECLARE(uint32_t) ftdm_channel_get_io_packet_len(const ftdm_channel_t *ftdmchan) -{ - uint32_t count; - ftdm_mutex_lock(ftdmchan->mutex); - count = ftdmchan->packet_len; - ftdm_mutex_unlock(ftdmchan->mutex); - return count; -} - -FT_DECLARE(uint32_t) ftdm_channel_get_type(const ftdm_channel_t *ftdmchan) -{ - return ftdmchan->type; -} - -FT_DECLARE(ftdm_codec_t) ftdm_channel_get_codec(const ftdm_channel_t *ftdmchan) -{ - return ftdmchan->effective_codec; -} - -FT_DECLARE(const char *) ftdm_channel_get_token(const ftdm_channel_t *ftdmchan, uint32_t tokenid) -{ - const char *token = NULL; - ftdm_mutex_lock(ftdmchan->mutex); - - if (ftdmchan->token_count <= tokenid) { - ftdm_mutex_unlock(ftdmchan->mutex); - return NULL; - } - - token = ftdmchan->tokens[tokenid]; - ftdm_mutex_unlock(ftdmchan->mutex); - return token; -} - -FT_DECLARE(ftdm_status_t) ftdm_channel_add_token(ftdm_channel_t *ftdmchan, char *token, int end) -{ - ftdm_status_t status = FTDM_FAIL; - - ftdm_mutex_lock(ftdmchan->mutex); - if (ftdmchan->token_count < FTDM_MAX_TOKENS) { - if (end) { - ftdm_copy_string(ftdmchan->tokens[ftdmchan->token_count++], token, FTDM_TOKEN_STRLEN); - } else { - memmove(ftdmchan->tokens[1], ftdmchan->tokens[0], ftdmchan->token_count * FTDM_TOKEN_STRLEN); - ftdm_copy_string(ftdmchan->tokens[0], token, FTDM_TOKEN_STRLEN); - ftdmchan->token_count++; - } - status = FTDM_SUCCESS; - } - ftdm_mutex_unlock(ftdmchan->mutex); - - return status; -} - - -FT_DECLARE(uint32_t) ftdm_group_get_id(const ftdm_group_t *group) -{ - return group->group_id; -} - -FT_DECLARE(ftdm_status_t) ftdm_group_channel_use_count(ftdm_group_t *group, uint32_t *count) -{ - uint32_t j; - - *count = 0; - - if (!group) { - return FTDM_FAIL; - } - - for(j = 0; j < group->chan_count && group->channels[j]; j++) { - if (group->channels[j]) { - if (ftdm_test_flag(group->channels[j], FTDM_CHANNEL_INUSE)) { - (*count)++; - } - } - } - - return FTDM_SUCCESS; -} - -static __inline__ int chan_is_avail(ftdm_channel_t *check) -{ - if ((check->span->signal_type == FTDM_SIGTYPE_M2UA) || - (check->span->signal_type == FTDM_SIGTYPE_NONE)) { - if (!ftdm_test_flag(check, FTDM_CHANNEL_READY) || - ftdm_test_flag(check, FTDM_CHANNEL_INUSE) || - ftdm_test_flag(check, FTDM_CHANNEL_SUSPENDED) || - ftdm_test_flag(check, FTDM_CHANNEL_IN_ALARM) || - check->state != FTDM_CHANNEL_STATE_DOWN) { - return 0; - } - } else { - if (!ftdm_test_flag(check, FTDM_CHANNEL_READY) || - !ftdm_test_flag(check, FTDM_CHANNEL_SIG_UP) || - ftdm_test_flag(check, FTDM_CHANNEL_INUSE) || - ftdm_test_flag(check, FTDM_CHANNEL_SUSPENDED) || - ftdm_test_flag(check, FTDM_CHANNEL_IN_ALARM) || - check->state != FTDM_CHANNEL_STATE_DOWN) { - return 0; - } - } - /* release guard time check */ - if (check->span->sig_release_guard_time_ms && check->last_release_time) { - ftdm_time_t time_diff = (ftdm_current_time_in_ms() - check->last_release_time); - if (time_diff < check->span->sig_release_guard_time_ms) { - return 0; - } - /* circuit now available for outbound dialing */ - check->last_release_time = 0; - ftdm_log_chan(check, FTDM_LOG_DEBUG, "Channel is now available, release guard timer expired %" FTDM_UINT64_FMT "ms ago\n", (time_diff - check->span->sig_release_guard_time_ms)); - } - return 1; -} - -static __inline__ int chan_voice_is_avail(ftdm_channel_t *check) -{ - if (!FTDM_IS_VOICE_CHANNEL(check)) { - return 0; - } - return chan_is_avail(check); -} - -static __inline__ int request_voice_channel(ftdm_channel_t *check, ftdm_channel_t **ftdmchan, - ftdm_caller_data_t *caller_data, ftdm_hunt_direction_t direction) -{ - ftdm_status_t status; - if (chan_voice_is_avail(check)) { - /* unlocked testing passed, try again with the channel locked */ - ftdm_mutex_lock(check->mutex); - if (chan_voice_is_avail(check)) { - if (check->span && check->span->channel_request) { - /* I am only unlocking here cuz this function is called - * sometimes with the group or span lock held and were - * blocking anyone hunting for channels available and - * I believe teh channel_request() function may take - * a bit of time. However channel_request is a callback - * used by boost and may be only a few other old sig mods - * and it should be deprecated */ - ftdm_mutex_unlock(check->mutex); - ftdm_set_caller_data(check->span, caller_data); - status = check->span->channel_request(check->span, check->chan_id, - direction, caller_data, ftdmchan); - if (status == FTDM_SUCCESS) { - return 1; - } - } else { - status = ftdm_channel_open_chan(check); - if (status == FTDM_SUCCESS) { - *ftdmchan = check; - ftdm_set_flag(check, FTDM_CHANNEL_OUTBOUND); -#if 0 - ftdm_mutex_unlock(check->mutex); -#endif - return 1; - } - } - } - ftdm_mutex_unlock(check->mutex); - } - return 0; -} - -static void __inline__ calculate_best_rate(ftdm_channel_t *check, ftdm_channel_t **best_rated, int *best_rate) -{ - if (ftdm_test_flag(check->span, FTDM_SPAN_USE_AV_RATE)) { - ftdm_mutex_lock(check->mutex); - if (ftdm_test_flag(check, FTDM_CHANNEL_INUSE)) { - /* twiddle */ - } else if (ftdm_test_flag(check, FTDM_CHANNEL_SIG_UP)) { - /* twiddle */ - } else if (check->availability_rate > *best_rate){ - /* the channel is not in use and the signaling status is down, - * it is a potential candidate to place a call */ - *best_rated = check; - *best_rate = check->availability_rate; - } - ftdm_mutex_unlock(check->mutex); - } -} - -static ftdm_status_t __inline__ get_best_rated(ftdm_channel_t **fchan, ftdm_channel_t *best_rated) -{ - ftdm_status_t status; - - if (!best_rated) { - return FTDM_FAIL; - } - - ftdm_mutex_lock(best_rated->mutex); - - if (ftdm_test_flag(best_rated, FTDM_CHANNEL_INUSE)) { - ftdm_mutex_unlock(best_rated->mutex); - return FTDM_FAIL; - } - - ftdm_log_chan_msg(best_rated, FTDM_LOG_DEBUG, "I may not be available but I had the best availability rate, trying to open I/O now\n"); - - status = ftdm_channel_open_chan(best_rated); - if (status != FTDM_SUCCESS) { - ftdm_mutex_unlock(best_rated->mutex); - return FTDM_FAIL; - } - *fchan = best_rated; - ftdm_set_flag(best_rated, FTDM_CHANNEL_OUTBOUND); -#if 0 - ftdm_mutex_unlock(best_rated->mutex); -#endif - return FTDM_SUCCESS; -} - -static uint32_t __inline__ rr_next(uint32_t last, uint32_t min, uint32_t max, ftdm_hunt_direction_t direction) -{ - uint32_t next = min; - - ftdm_log(FTDM_LOG_DEBUG, "last = %d, min = %d, max = %d\n", last, min, max); - - if (direction == FTDM_HUNT_RR_UP) { - next = (last >= max) ? min : ++last; - } else { - next = (last <= min) ? max : --last; - } - return next; -} - - -FT_DECLARE(int) ftdm_channel_get_availability(ftdm_channel_t *ftdmchan) -{ - int availability = -1; - ftdm_channel_lock(ftdmchan); - if (ftdm_test_flag(ftdmchan->span, FTDM_SPAN_USE_AV_RATE)) { - availability = ftdmchan->availability_rate; - } - ftdm_channel_unlock(ftdmchan); - return availability; -} - -static ftdm_status_t _ftdm_channel_open_by_group(uint32_t group_id, ftdm_hunt_direction_t direction, ftdm_caller_data_t *caller_data, ftdm_channel_t **ftdmchan) -{ - ftdm_status_t status = FTDM_FAIL; - ftdm_channel_t *check = NULL; - ftdm_channel_t *best_rated = NULL; - ftdm_group_t *group = NULL; - int best_rate = 0; - uint32_t i = 0; - uint32_t count = 0; - uint32_t first_channel = 0; - - if (group_id) { - ftdm_group_find(group_id, &group); - } - - if (!group) { - ftdm_log(FTDM_LOG_ERROR, "Group %d not defined!\n", group_id); - *ftdmchan = NULL; - return FTDM_FAIL; - } - - ftdm_group_channel_use_count(group, &count); - - if (count >= group->chan_count) { - ftdm_log(FTDM_LOG_WARNING, "All circuits are busy (%d channels used out of %d available).\n", count, group->chan_count); - *ftdmchan = NULL; - return FTDM_FAIL; - } - - - if (direction == FTDM_HUNT_BOTTOM_UP) { - i = 0; - } else if (direction == FTDM_HUNT_RR_DOWN || direction == FTDM_HUNT_RR_UP) { - i = rr_next(group->last_used_index, 0, group->chan_count - 1, direction); - first_channel = i; - } else { - i = group->chan_count-1; - } - - ftdm_mutex_lock(group->mutex); - for (;;) { - - if (!(check = group->channels[i])) { - status = FTDM_FAIL; - break; - } - - if (request_voice_channel(check, ftdmchan, caller_data, direction)) { - status = FTDM_SUCCESS; - if (direction == FTDM_HUNT_RR_UP || direction == FTDM_HUNT_RR_DOWN) { - group->last_used_index = i; - } - break; - } - - calculate_best_rate(check, &best_rated, &best_rate); - - if (direction == FTDM_HUNT_BOTTOM_UP) { - if (i >= (group->chan_count - 1)) { - break; - } - i++; - } else if (direction == FTDM_HUNT_RR_DOWN || direction == FTDM_HUNT_RR_UP) { - if (check == best_rated) { - group->last_used_index = i; - } - i = rr_next(i, 0, group->chan_count - 1, direction); - if (first_channel == i) { - break; - } - } else { - if (i == 0) { - break; - } - i--; - } - } - - if (status == FTDM_FAIL) { - status = get_best_rated(ftdmchan, best_rated); - } - - ftdm_mutex_unlock(group->mutex); - return status; -} - -FT_DECLARE(ftdm_status_t) ftdm_channel_open_by_group(uint32_t group_id, ftdm_hunt_direction_t direction, ftdm_caller_data_t *caller_data, ftdm_channel_t **ftdmchan) -{ - ftdm_status_t status; - status = _ftdm_channel_open_by_group(group_id, direction, caller_data, ftdmchan); - if (status == FTDM_SUCCESS) { - ftdm_channel_t *fchan = *ftdmchan; - ftdm_channel_unlock(fchan); - } - return status; -} - -FT_DECLARE(ftdm_status_t) ftdm_span_channel_use_count(ftdm_span_t *span, uint32_t *count) -{ - uint32_t j; - - *count = 0; - - if (!span || !ftdm_test_flag(span, FTDM_SPAN_CONFIGURED)) { - return FTDM_FAIL; - } - - for(j = 1; j <= span->chan_count && span->channels[j]; j++) { - if (span->channels[j]) { - if (ftdm_test_flag(span->channels[j], FTDM_CHANNEL_INUSE)) { - (*count)++; - } - } - } - - return FTDM_SUCCESS; -} - -/* Hunt a channel by span, if successful the channel is returned locked */ -static ftdm_status_t _ftdm_channel_open_by_span(uint32_t span_id, ftdm_hunt_direction_t direction, ftdm_caller_data_t *caller_data, ftdm_channel_t **ftdmchan) -{ - ftdm_status_t status = FTDM_FAIL; - ftdm_channel_t *check = NULL; - ftdm_channel_t *best_rated = NULL; - ftdm_span_t *span = NULL; - int best_rate = 0; - uint32_t i = 0; - uint32_t count = 0; - uint32_t first_channel = 0; - - *ftdmchan = NULL; - - if (!span_id) { - ftdm_log(FTDM_LOG_CRIT, "No span supplied\n"); - return FTDM_FAIL; - } - - ftdm_span_find(span_id, &span); - - if (!span || !ftdm_test_flag(span, FTDM_SPAN_CONFIGURED)) { - ftdm_log(FTDM_LOG_CRIT, "span %d not defined or configured!\n", span_id); - return FTDM_FAIL; - } - - ftdm_span_channel_use_count(span, &count); - - if (count >= span->chan_count) { - ftdm_log(FTDM_LOG_WARNING, "All circuits are busy: active=%i max=%i.\n", count, span->chan_count); - return FTDM_FAIL; - } - - if (span->channel_request && !ftdm_test_flag(span, FTDM_SPAN_SUGGEST_CHAN_ID)) { - ftdm_set_caller_data(span, caller_data); - return span->channel_request(span, 0, direction, caller_data, ftdmchan); - } - - ftdm_mutex_lock(span->mutex); - - if (direction == FTDM_HUNT_BOTTOM_UP) { - i = 1; - } else if (direction == FTDM_HUNT_RR_DOWN || direction == FTDM_HUNT_RR_UP) { - i = rr_next(span->last_used_index, 1, span->chan_count, direction); - first_channel = i; - } else { - i = span->chan_count; - } - - for(;;) { - - if (direction == FTDM_HUNT_BOTTOM_UP) { - if (i > span->chan_count) { - break; - } - } else { - if (i == 0) { - break; - } - } - - if (!(check = span->channels[i])) { - status = FTDM_FAIL; - break; - } - - if (request_voice_channel(check, ftdmchan, caller_data, direction)) { - status = FTDM_SUCCESS; - if (direction == FTDM_HUNT_RR_UP || direction == FTDM_HUNT_RR_DOWN) { - span->last_used_index = i; - } - break; - } - - calculate_best_rate(check, &best_rated, &best_rate); - - if (direction == FTDM_HUNT_BOTTOM_UP) { - i++; - } else if (direction == FTDM_HUNT_RR_DOWN || direction == FTDM_HUNT_RR_UP) { - if (check == best_rated) { - span->last_used_index = i; - } - i = rr_next(i, 1, span->chan_count, direction); - if (first_channel == i) { - break; - } - } else { - i--; - } - } - - if (status == FTDM_FAIL) { - status = get_best_rated(ftdmchan, best_rated); - } - - ftdm_mutex_unlock(span->mutex); - - return status; -} - -FT_DECLARE(ftdm_status_t) ftdm_channel_open_by_span(uint32_t span_id, ftdm_hunt_direction_t direction, ftdm_caller_data_t *caller_data, ftdm_channel_t **ftdmchan) -{ - ftdm_status_t status; - status = _ftdm_channel_open_by_span(span_id, direction, caller_data, ftdmchan); - if (status == FTDM_SUCCESS) { - ftdm_channel_t *fchan = *ftdmchan; - ftdm_channel_unlock(fchan); - } - return status; -} - -FT_DECLARE(ftdm_status_t) ftdm_channel_open_chan(ftdm_channel_t *ftdmchan) -{ - ftdm_status_t status = FTDM_FAIL; - - ftdm_assert_return(ftdmchan != NULL, FTDM_FAIL, "invalid ftdmchan pointer\n"); - - ftdm_mutex_lock(ftdmchan->mutex); - - if (FTDM_IS_VOICE_CHANNEL(ftdmchan)) { - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_SUSPENDED)) { - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "%s", "Channel is suspended\n"); - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "Cannot open channel when is suspended\n"); - goto done; - } - - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_IN_ALARM) && !ftdm_test_flag(ftdmchan->span, FTDM_SPAN_PWR_SAVING)) { - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "%s", "Channel is alarmed\n"); - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "Cannot open channel when is alarmed\n"); - goto done; - } - - if (globals.cpu_monitor.alarm && - globals.cpu_monitor.alarm_action_flags & FTDM_CPU_ALARM_ACTION_REJECT) { - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "%s", "CPU usage alarm is on - refusing to open channel\n"); - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "CPU usage alarm is on - refusing to open channel\n"); - ftdmchan->caller_data.hangup_cause = FTDM_CAUSE_SWITCH_CONGESTION; - goto done; - } - } - - if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_READY)) { - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "Channel is not ready"); - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "Cannot open channel when is not ready\n"); - goto done; - } - - status = ftdmchan->fio->open(ftdmchan); - if (status == FTDM_SUCCESS) { - ftdm_set_flag(ftdmchan, FTDM_CHANNEL_OPEN | FTDM_CHANNEL_INUSE); - } else { - ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "IO open failed: %d\n", status); - } - -done: - - ftdm_mutex_unlock(ftdmchan->mutex); - - return status; -} - -static ftdm_status_t _ftdm_channel_open(uint32_t span_id, uint32_t chan_id, ftdm_channel_t **ftdmchan, uint8_t physical) -{ - ftdm_channel_t *check = NULL; - ftdm_span_t *span = NULL; - ftdm_channel_t *best_rated = NULL; - ftdm_status_t status = FTDM_FAIL; - int best_rate = 0; - - *ftdmchan = NULL; - - ftdm_mutex_lock(globals.mutex); - - ftdm_span_find(span_id, &span); - - if (!span) { - ftdm_log(FTDM_LOG_CRIT, "Could not find span!\n"); - goto done; - } - - if (!ftdm_test_flag(span, FTDM_SPAN_CONFIGURED)) { - ftdm_log(FTDM_LOG_CRIT, "Span %d is not configured\n", span_id); - goto done; - } - - if (span->channel_request) { - ftdm_log(FTDM_LOG_ERROR, "Individual channel selection not implemented on this span.\n"); - goto done; - } - - if (physical) { /* Open by physical */ - ftdm_channel_t *fchan = NULL; - ftdm_iterator_t *citer = NULL; - ftdm_iterator_t *curr = NULL; - - if (chan_id < 1) { - ftdm_log(FTDM_LOG_ERROR, "Invalid physical channel %d to open in span %d\n", chan_id, span_id); - status = FTDM_FAIL; - goto done; - } - - citer = ftdm_span_get_chan_iterator(span, NULL); - if (!citer) { - status = ENOMEM; - goto done; - } - - for (curr = citer ; curr; curr = ftdm_iterator_next(curr)) { - fchan = ftdm_iterator_current(curr); - if (fchan->physical_chan_id == chan_id) { - check = fchan; - break; - } - } - - ftdm_iterator_free(citer); - if (!check) { - ftdm_log(FTDM_LOG_CRIT, "Wow, no physical channel %d in span %d\n", chan_id, span_id); - goto done; - } - } else { /* Open by logical */ - if (chan_id < 1 || chan_id > span->chan_count) { - ftdm_log(FTDM_LOG_ERROR, "Invalid channel %d to open in span %d\n", chan_id, span_id); - goto done; - } - - if (!(check = span->channels[chan_id])) { - ftdm_log(FTDM_LOG_CRIT, "Wow, no channel %d in span %d\n", chan_id, span_id); - goto done; - } - } - - ftdm_channel_lock(check); - - if (ftdm_test_flag(check, FTDM_CHANNEL_OPEN)) { - /* let them know is already open, but return the channel anyway */ - status = FTDM_EBUSY; - *ftdmchan = check; - goto unlockchan; - } - - /* The following if's and gotos replace a big if (this || this || this || this) else { nothing; } */ - - /* if it is not a voice channel, nothing else to check to open it */ - if (!FTDM_IS_VOICE_CHANNEL(check)) { - goto openchan; - } - - /* if it's an FXS device with a call active and has callwaiting enabled, we allow to open it twice */ - if (check->type == FTDM_CHAN_TYPE_FXS - && check->token_count == 1 - && ftdm_channel_test_feature(check, FTDM_CHANNEL_FEATURE_CALLWAITING)) { - goto openchan; - } - - /* if channel is available, time to open it */ - if (chan_is_avail(check)) { - goto openchan; - } - - /* not available, but still might be available ... */ - calculate_best_rate(check, &best_rated, &best_rate); - if (best_rated) { - goto openchan; - } - - /* channel is unavailable, do not open the channel */ - goto unlockchan; - -openchan: - if (!ftdm_test_flag(check, FTDM_CHANNEL_OPEN)) { - status = check->fio->open(check); - if (status == FTDM_SUCCESS) { - ftdm_set_flag(check, FTDM_CHANNEL_OPEN); - } - } else { - status = FTDM_SUCCESS; - } - ftdm_set_flag(check, FTDM_CHANNEL_INUSE); - ftdm_set_flag(check, FTDM_CHANNEL_OUTBOUND); - *ftdmchan = check; - - /* we've got the channel, do not unlock it */ - goto done; - -unlockchan: - ftdm_channel_unlock(check); - -done: - ftdm_mutex_unlock(globals.mutex); - if (status != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "Failed to open channel %d:%d\n", span_id, chan_id); - } - - return status; -} - -FT_DECLARE(ftdm_status_t) ftdm_channel_open(uint32_t span_id, uint32_t chan_id, ftdm_channel_t **ftdmchan) -{ - ftdm_status_t status; - status = _ftdm_channel_open(span_id, chan_id, ftdmchan, 0); - if (status == FTDM_SUCCESS) { - ftdm_channel_t *fchan = *ftdmchan; - ftdm_channel_unlock(fchan); - } - return status; -} - -FT_DECLARE(ftdm_status_t) ftdm_channel_open_ph(uint32_t span_id, uint32_t chan_id, ftdm_channel_t **ftdmchan) -{ - ftdm_status_t status; - status = _ftdm_channel_open(span_id, chan_id, ftdmchan, 1); - if (status == FTDM_SUCCESS) { - ftdm_channel_t *fchan = *ftdmchan; - ftdm_channel_unlock(fchan); - } - return status; -} - -FT_DECLARE(uint32_t) ftdm_channel_get_id(const ftdm_channel_t *ftdmchan) -{ - return ftdmchan->chan_id; -} - -FT_DECLARE(uint32_t) ftdm_channel_get_ph_id(const ftdm_channel_t *ftdmchan) -{ - return ftdmchan->physical_chan_id; -} - -FT_DECLARE(uint32_t) ftdm_channel_get_span_id(const ftdm_channel_t *ftdmchan) -{ - return ftdmchan->span_id; -} - -FT_DECLARE(ftdm_span_t *) ftdm_channel_get_span(const ftdm_channel_t *ftdmchan) -{ - return ftdmchan->span; -} - -FT_DECLARE(const char *) ftdm_channel_get_span_name(const ftdm_channel_t *ftdmchan) -{ - return ftdmchan->span->name; -} - -FT_DECLARE(void) ftdm_span_set_trunk_type(ftdm_span_t *span, ftdm_trunk_type_t type) -{ - span->trunk_type = type; -} - -FT_DECLARE(ftdm_status_t) ftdm_span_set_blocking_mode(const ftdm_span_t *span, ftdm_bool_t enabled) -{ - ftdm_channel_t *fchan = NULL; - ftdm_iterator_t *citer = NULL; - ftdm_iterator_t *curr = NULL; - - citer = ftdm_span_get_chan_iterator(span, NULL); - if (!citer) { - return FTDM_ENOMEM; - } - - for (curr = citer ; curr; curr = ftdm_iterator_next(curr)) { - fchan = ftdm_iterator_current(curr); - if (enabled) { - ftdm_clear_flag_locked(fchan, FTDM_CHANNEL_NONBLOCK); - } else { - ftdm_set_flag_locked(fchan, FTDM_CHANNEL_NONBLOCK); - } - } - ftdm_iterator_free(citer); - return FTDM_SUCCESS; -} - -FT_DECLARE(ftdm_trunk_type_t) ftdm_span_get_trunk_type(const ftdm_span_t *span) -{ - return span->trunk_type; -} - -FT_DECLARE(const char *) ftdm_span_get_trunk_type_str(const ftdm_span_t *span) -{ - return ftdm_trunk_type2str(span->trunk_type); -} - -FT_DECLARE(void) ftdm_span_set_trunk_mode(ftdm_span_t *span, ftdm_trunk_mode_t mode) -{ - span->trunk_mode = mode; -} - -FT_DECLARE(ftdm_trunk_mode_t) ftdm_span_get_trunk_mode(const ftdm_span_t *span) -{ - return span->trunk_mode; -} - -FT_DECLARE(const char *) ftdm_span_get_trunk_mode_str(const ftdm_span_t *span) -{ - return ftdm_trunk_mode2str(span->trunk_mode); -} - -FT_DECLARE(uint32_t) ftdm_span_get_id(const ftdm_span_t *span) -{ - return span->span_id; -} - -FT_DECLARE(const char *) ftdm_span_get_name(const ftdm_span_t *span) -{ - return span->name; -} - -FT_DECLARE(const char *) ftdm_channel_get_name(const ftdm_channel_t *ftdmchan) -{ - return ftdmchan->chan_name; -} - -FT_DECLARE(const char *) ftdm_channel_get_number(const ftdm_channel_t *ftdmchan) -{ - return ftdmchan->chan_number; -} - -FT_DECLARE(ftdm_bool_t) ftdm_channel_call_check_hold(const ftdm_channel_t *ftdmchan) -{ - ftdm_bool_t condition; - ftdm_channel_lock(ftdmchan); - condition = ftdm_test_flag(ftdmchan, FTDM_CHANNEL_HOLD) ? FTDM_TRUE : FTDM_FALSE; - ftdm_channel_unlock(ftdmchan); - return condition; -} - -FT_DECLARE(ftdm_bool_t) ftdm_channel_call_check_answered(const ftdm_channel_t *ftdmchan) -{ - ftdm_bool_t condition = FTDM_FALSE; - - ftdm_channel_lock(ftdmchan); - condition = (ftdmchan->state == FTDM_CHANNEL_STATE_UP) ? FTDM_TRUE : FTDM_FALSE; - ftdm_channel_unlock(ftdmchan); - - return condition; -} - -FT_DECLARE(ftdm_bool_t) ftdm_channel_call_check_busy(const ftdm_channel_t *ftdmchan) -{ - ftdm_bool_t condition = FTDM_FALSE; - - ftdm_channel_lock(ftdmchan); - condition = (ftdmchan->state == FTDM_CHANNEL_STATE_BUSY) ? FTDM_TRUE : FTDM_FALSE; - ftdm_channel_unlock(ftdmchan); - - return condition; -} - -FT_DECLARE(ftdm_bool_t) ftdm_channel_call_check_hangup(const ftdm_channel_t *ftdmchan) -{ - ftdm_bool_t condition = FTDM_FALSE; - - ftdm_channel_lock(ftdmchan); - condition = (ftdmchan->state == FTDM_CHANNEL_STATE_HANGUP || ftdmchan->state == FTDM_CHANNEL_STATE_TERMINATING) - ? FTDM_TRUE : FTDM_FALSE; - ftdm_channel_unlock(ftdmchan); - - return condition; -} - -FT_DECLARE(ftdm_bool_t) ftdm_channel_call_check_done(const ftdm_channel_t *ftdmchan) -{ - ftdm_bool_t condition = FTDM_FALSE; - - ftdm_channel_lock(ftdmchan); - condition = (ftdmchan->state == FTDM_CHANNEL_STATE_DOWN) ? FTDM_TRUE : FTDM_FALSE; - ftdm_channel_unlock(ftdmchan); - - return condition; -} - -FT_DECLARE(ftdm_status_t) _ftdm_channel_call_hold(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_usrmsg_t *usrmsg) -{ - ftdm_status_t status; - ftdm_channel_lock(ftdmchan); - - ftdm_set_flag(ftdmchan, FTDM_CHANNEL_HOLD); - status = ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_DIALTONE, 0, usrmsg); - ftdm_channel_unlock(ftdmchan); - - return status; -} - -FT_DECLARE(ftdm_status_t) _ftdm_channel_call_unhold(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_usrmsg_t *usrmsg) -{ - ftdm_status_t status; - - ftdm_channel_lock(ftdmchan); - - status = ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_UP, 0, usrmsg); - - ftdm_channel_unlock(ftdmchan); - - return status; -} - -FT_DECLARE(void) ftdm_ack_indication(ftdm_channel_t *fchan, ftdm_channel_indication_t indication, ftdm_status_t status) -{ - ftdm_sigmsg_t msg; - - if (!ftdm_test_flag(fchan, FTDM_CHANNEL_IND_ACK_PENDING)) { - return; - } - - ftdm_log_chan(fchan, FTDM_LOG_DEBUG, "Acknowledging indication %s in state %s (rc = %d)\n", - ftdm_channel_indication2str(indication), ftdm_channel_state2str(fchan->state), status); - ftdm_clear_flag(fchan, FTDM_CHANNEL_IND_ACK_PENDING); - memset(&msg, 0, sizeof(msg)); - msg.channel = fchan; - msg.event_id = FTDM_SIGEVENT_INDICATION_COMPLETED; - msg.ev_data.indication_completed.indication = indication; - msg.ev_data.indication_completed.status = status; - ftdm_span_send_signal(fchan->span, &msg); -} - -/*! Answer call without locking the channel. The caller must have locked first */ -static ftdm_status_t _ftdm_channel_call_answer_nl(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_usrmsg_t *usrmsg) -{ - ftdm_status_t status = FTDM_SUCCESS; - - if (!ftdm_test_flag(ftdmchan->span, FTDM_SPAN_USE_SKIP_STATES)) { - /* We will fail RFC's if we not skip states, but some modules apart from ftmod_sangoma_isdn - * expect the call to always to go PROGRESS and PROGRESS MEDIA state before going to UP, so - * use FTDM_SPAN_USE_SKIP_STATES for now while we update the sig modules */ - - if (ftdmchan->state < FTDM_CHANNEL_STATE_PROGRESS) { - status = ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_PROGRESS, 1, usrmsg); - if (status != FTDM_SUCCESS) { - status = FTDM_ECANCELED; - goto done; - } - } - - /* set state unlocks the channel so we need to re-confirm that the channel hasn't gone to hell */ - if (ftdmchan->state == FTDM_CHANNEL_STATE_TERMINATING) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Ignoring answer because the call has moved to TERMINATING while we're moving to PROGRESS\n"); - status = FTDM_ECANCELED; - goto done; - } - - if (ftdmchan->state < FTDM_CHANNEL_STATE_PROGRESS_MEDIA) { - status = ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, 1, usrmsg); - if (status != FTDM_SUCCESS) { - status = FTDM_ECANCELED; - goto done; - } - } - - /* set state unlocks the channel so we need to re-confirm that the channel hasn't gone to hell */ - if (ftdmchan->state == FTDM_CHANNEL_STATE_TERMINATING) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Ignoring answer because the call has moved to TERMINATING while we're moving to UP\n"); - status = FTDM_ECANCELED; - goto done; - } - } - - status = ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_UP, 1, usrmsg); - if (status != FTDM_SUCCESS) { - status = FTDM_ECANCELED; - goto done; - } - -done: - - return status; -} - -FT_DECLARE(ftdm_status_t) _ftdm_channel_call_answer(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_usrmsg_t *usrmsg) -{ - ftdm_status_t status; - - /* we leave the locking up to ftdm_channel_call_indicate, DO NOT lock here since ftdm_channel_call_indicate expects - * the lock recursivity to be 1 */ - status = _ftdm_channel_call_indicate(file, func, line, ftdmchan, FTDM_CHANNEL_INDICATE_ANSWER, usrmsg); - - return status; -} - -FT_DECLARE(ftdm_status_t) _ftdm_channel_call_transfer(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, const char* arg, ftdm_usrmsg_t *usrmsg) -{ - ftdm_status_t status; - ftdm_usrmsg_t *msg = NULL; - ftdm_bool_t free_msg = FTDM_FALSE; - - if (!usrmsg) { - msg = ftdm_calloc(1, sizeof(*msg)); - ftdm_assert_return(msg, FTDM_FAIL, "Failed to allocate usr msg"); - memset(msg, 0, sizeof(*msg)); - free_msg = FTDM_TRUE; - } else { - msg = usrmsg; - } - - ftdm_usrmsg_add_var(msg, "transfer_arg", arg); - /* we leave the locking up to ftdm_channel_call_indicate, DO NOT lock here since ftdm_channel_call_indicate expects - * the lock recursivity to be 1 */ - status = _ftdm_channel_call_indicate(file, func, line, ftdmchan, FTDM_CHANNEL_INDICATE_TRANSFER, msg); - if (free_msg == FTDM_TRUE) { - ftdm_safe_free(msg); - } - return status; -} - -/* lock must be acquired by the caller! */ -static ftdm_status_t _ftdm_channel_call_hangup_nl(const char *file, const char *func, int line, ftdm_channel_t *chan, ftdm_usrmsg_t *usrmsg) -{ - ftdm_status_t status = FTDM_SUCCESS; - - /* In native sigbridge mode we ignore hangup requests from the user and hangup only when the signaling module decides it */ - if (ftdm_test_flag(chan, FTDM_CHANNEL_NATIVE_SIGBRIDGE) && chan->state != FTDM_CHANNEL_STATE_TERMINATING) { - - ftdm_log_chan_ex(chan, file, func, line, FTDM_LOG_LEVEL_DEBUG, - "Ignoring hangup in channel in state %s (native bridge enabled)\n", ftdm_channel_state2str(chan->state)); - ftdm_set_flag(chan, FTDM_CHANNEL_USER_HANGUP); - goto done; - } - - if (chan->state != FTDM_CHANNEL_STATE_DOWN) { - if (chan->state == FTDM_CHANNEL_STATE_HANGUP) { - /* make user's life easier, and just ignore double hangup requests */ - return FTDM_SUCCESS; - } - if (chan->hangup_timer) { - ftdm_sched_cancel_timer(globals.timingsched, chan->hangup_timer); - } - ftdm_set_flag(chan, FTDM_CHANNEL_USER_HANGUP); - /* if a state change requested by the user was pending, a hangup certainly cancels that request */ - if (ftdm_test_flag(chan, FTDM_CHANNEL_STATE_CHANGE)) { - ftdm_channel_cancel_state(file, func, line, chan); - } - status = ftdm_channel_set_state(file, func, line, chan, FTDM_CHANNEL_STATE_HANGUP, 1, usrmsg); - } else { - /* the signaling stack did not touch the state, - * core is responsible from clearing flags and stuff, however, because ftmod_analog - * is a bitch in a serious need of refactoring, we also check whether the channel is open - * to avoid an spurious warning about the channel not being open. This is because ftmod_analog - * does not follow our convention of sending SIGEVENT_STOP and waiting for the user to move - * to HANGUP (implicitly through ftdm_channel_call_hangup(), as soon as ftmod_analog is fixed - * this check can be removed */ - if (ftdm_test_flag(chan, FTDM_CHANNEL_OPEN)) { - ftdm_channel_close(&chan); - } - } - -done: - return status; -} - -FT_DECLARE(ftdm_status_t) _ftdm_channel_call_hangup_with_cause(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_call_cause_t cause, ftdm_usrmsg_t *usrmsg) -{ - ftdm_status_t status = FTDM_SUCCESS; - ftdm_channel_lock(ftdmchan); - - ftdmchan->caller_data.hangup_cause = cause; - - status = _ftdm_channel_call_hangup_nl(file, func, line, ftdmchan, usrmsg); - - ftdm_channel_unlock(ftdmchan); - return status; -} - -FT_DECLARE(ftdm_status_t) _ftdm_channel_call_hangup(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_usrmsg_t *usrmsg) -{ - ftdm_status_t status = FTDM_SUCCESS; - - ftdm_channel_lock(ftdmchan); - - ftdmchan->caller_data.hangup_cause = FTDM_CAUSE_NORMAL_CLEARING; - - status = _ftdm_channel_call_hangup_nl(file, func, line, ftdmchan, usrmsg); - - ftdm_channel_unlock(ftdmchan); - return status; -} - -FT_DECLARE(const char *) ftdm_channel_get_last_error(const ftdm_channel_t *ftdmchan) -{ - return ftdmchan->last_error; -} - -FT_DECLARE(const char *) ftdm_span_get_last_error(const ftdm_span_t *span) -{ - return span->last_error; -} - -FT_DECLARE(ftdm_caller_data_t *) ftdm_channel_get_caller_data(ftdm_channel_t *ftdmchan) -{ - return &ftdmchan->caller_data; -} - -FT_DECLARE(ftdm_channel_t *) ftdm_span_get_channel(const ftdm_span_t *span, uint32_t chanid) -{ - ftdm_channel_t *chan; - ftdm_mutex_lock(span->mutex); - if (chanid == 0 || chanid > span->chan_count) { - ftdm_mutex_unlock(span->mutex); - return NULL; - } - chan = span->channels[chanid]; - ftdm_mutex_unlock(span->mutex); - return chan; -} - -FT_DECLARE(ftdm_channel_t *) ftdm_span_get_channel_ph(const ftdm_span_t *span, uint32_t chanid) -{ - ftdm_channel_t *chan = NULL; - ftdm_channel_t *fchan = NULL; - ftdm_iterator_t *citer = NULL; - ftdm_iterator_t *curr = NULL; - - ftdm_mutex_lock(span->mutex); - if (chanid == 0) { - ftdm_mutex_unlock(span->mutex); - return NULL; - } - - citer = ftdm_span_get_chan_iterator(span, NULL); - if (!citer) { - ftdm_mutex_unlock(span->mutex); - return NULL; - } - - for (curr = citer ; curr; curr = ftdm_iterator_next(curr)) { - fchan = ftdm_iterator_current(curr); - if (fchan->physical_chan_id == chanid) { - chan = fchan; - break; - } - } - - ftdm_iterator_free(citer); - - ftdm_mutex_unlock(span->mutex); - return chan; -} - -FT_DECLARE(uint32_t) ftdm_span_get_chan_count(const ftdm_span_t *span) -{ - uint32_t count; - ftdm_mutex_lock(span->mutex); - count = span->chan_count; - ftdm_mutex_unlock(span->mutex); - return count; -} - -FT_DECLARE(uint32_t) ftdm_channel_get_ph_span_id(const ftdm_channel_t *ftdmchan) -{ - uint32_t id; - ftdm_channel_lock(ftdmchan); - id = ftdmchan->physical_span_id; - ftdm_channel_unlock(ftdmchan); - return id; -} - -/* - * Every user requested indication *MUST* be acknowledged with the proper status (ftdm_status_t) - * However, if the indication fails before we notify the signaling stack, we don't need to ack - * but if we already notified the signaling stack about the indication, the signaling stack is - * responsible for the acknowledge. Bottom line is, whenever this function returns FTDM_SUCCESS - * someone *MUST* acknowledge the indication, either the signaling stack, this function or the core - * at some later point - * */ -FT_DECLARE(ftdm_status_t) _ftdm_channel_call_indicate(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_channel_indication_t indication, ftdm_usrmsg_t *usrmsg) -{ - ftdm_status_t status = FTDM_SUCCESS; - - ftdm_assert_return(ftdmchan, FTDM_FAIL, "Null channel\n"); - - ftdm_log_chan_ex(ftdmchan, file, func, line, FTDM_LOG_LEVEL_DEBUG, "Indicating %s in state %s\n", - ftdm_channel_indication2str(indication), ftdm_channel_state2str(ftdmchan->state)); - - ftdm_channel_lock(ftdmchan); - - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_NATIVE_SIGBRIDGE)) { - ftdm_log_chan_ex(ftdmchan, file, func, line, FTDM_LOG_LEVEL_DEBUG, - "Ignoring indication %s in channel in state %s (native bridge enabled)\n", - ftdm_channel_indication2str(indication), - ftdm_channel_state2str(ftdmchan->state)); - status = FTDM_SUCCESS; - goto done; - } - - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_IND_ACK_PENDING)) { - ftdm_log_chan_ex(ftdmchan, file, func, line, FTDM_LOG_LEVEL_WARNING, "Cannot indicate %s in channel with indication %s still pending in state %s\n", - ftdm_channel_indication2str(indication), - ftdm_channel_indication2str(ftdmchan->indication), - ftdm_channel_state2str(ftdmchan->state)); - status = FTDM_EBUSY; - goto done; - } - - ftdmchan->indication = indication; - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_NONBLOCK)) { - ftdm_set_flag(ftdmchan, FTDM_CHANNEL_IND_ACK_PENDING); - } - - if (indication != FTDM_CHANNEL_INDICATE_FACILITY && - ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { - - ftdm_log_chan_ex(ftdmchan, file, func, line, FTDM_LOG_LEVEL_WARNING, "Cannot indicate %s in outgoing channel in state %s\n", - ftdm_channel_indication2str(indication), ftdm_channel_state2str(ftdmchan->state)); - status = FTDM_EINVAL; - goto done; - } - - if (ftdmchan->state == FTDM_CHANNEL_STATE_TERMINATING) { - ftdm_log_chan_ex(ftdmchan, file, func, line, FTDM_LOG_LEVEL_DEBUG, "Ignoring indication %s because the call is in %s state\n", - ftdm_channel_indication2str(indication), ftdm_channel_state2str(ftdmchan->state)); - status = FTDM_ECANCELED; - goto done; - } - - switch (indication) { - /* FIXME: ring and busy cannot be used with all signaling stacks - * (particularly isdn stacks I think, we should emulate or just move to hangup with busy cause) */ - case FTDM_CHANNEL_INDICATE_RINGING: - status = ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_RINGING, 1, usrmsg); - break; - case FTDM_CHANNEL_INDICATE_BUSY: - status = ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_BUSY, 1, usrmsg); - break; - case FTDM_CHANNEL_INDICATE_PROCEED: - if (!ftdm_test_flag(ftdmchan->span, FTDM_SPAN_USE_PROCEED_STATE) || - ftdmchan->state >= FTDM_CHANNEL_STATE_PROCEED) { - ftdm_ack_indication(ftdmchan, indication, status); - goto done; - } - status = ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_PROCEED, 1, usrmsg); - break; - case FTDM_CHANNEL_INDICATE_PROGRESS: - status = ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_PROGRESS, 1, usrmsg); - break; - case FTDM_CHANNEL_INDICATE_PROGRESS_MEDIA: - if (!ftdm_test_flag(ftdmchan->span, FTDM_SPAN_USE_SKIP_STATES)) { - if (ftdmchan->state < FTDM_CHANNEL_STATE_PROGRESS) { - status = ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_PROGRESS, 1, usrmsg); - if (status != FTDM_SUCCESS) { - goto done; - } - } - - /* set state unlocks the channel so we need to re-confirm that the channel hasn't gone to hell */ - if (ftdmchan->state == FTDM_CHANNEL_STATE_TERMINATING) { - ftdm_log_chan_ex_msg(ftdmchan, file, func, line, FTDM_LOG_LEVEL_DEBUG, "Ignoring progress media because the call is terminating\n"); - goto done; - } - } - status = ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, 1, usrmsg); - break; - case FTDM_CHANNEL_INDICATE_ANSWER: - status = _ftdm_channel_call_answer_nl(file, func, line, ftdmchan, usrmsg); - break; - case FTDM_CHANNEL_INDICATE_TRANSFER: - if (!ftdm_test_flag(ftdmchan->span, FTDM_SPAN_USE_TRANSFER)) { - ftdm_log_chan_ex_msg(ftdmchan, file, func, line, FTDM_LOG_LEVEL_WARNING, "Transfer not supported\n"); - status = FTDM_EINVAL; - goto done; - } - status = ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_TRANSFER, 1, usrmsg); - break; - default: - /* See if signalling module can provide this indication */ - status = ftdm_channel_sig_indicate(ftdmchan, indication, usrmsg); - break; - } - -done: - ftdm_channel_unlock(ftdmchan); - - return status; -} - -FT_DECLARE(ftdm_status_t) _ftdm_channel_reset(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_usrmsg_t *usrmsg) -{ - ftdm_assert_return(ftdmchan != NULL, FTDM_FAIL, "null channel"); - - ftdm_channel_lock(ftdmchan); - ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_RESET, 1, usrmsg); - ftdm_channel_unlock(ftdmchan); - return FTDM_SUCCESS; -} - -FT_DECLARE(ftdm_status_t) ftdm_get_channel_from_string(const char *string_id, ftdm_span_t **out_span, ftdm_channel_t **out_channel) -{ - ftdm_status_t status = FTDM_SUCCESS; - int rc = 0; - ftdm_span_t *span = NULL; - ftdm_channel_t *ftdmchan = NULL; - unsigned span_id = 0; - unsigned chan_id = 0; - - *out_span = NULL; - *out_channel = NULL; - - if (!string_id) { - ftdm_log(FTDM_LOG_ERROR, "Cannot parse NULL channel id string\n"); - status = FTDM_EINVAL; - goto done; - } - - rc = sscanf(string_id, "%u:%u", &span_id, &chan_id); - if (rc != 2) { - ftdm_log(FTDM_LOG_ERROR, "Failed to parse channel id string '%s'\n", string_id); - status = FTDM_EINVAL; - goto done; - } - - status = ftdm_span_find(span_id, &span); - if (status != FTDM_SUCCESS || !span) { - ftdm_log(FTDM_LOG_ERROR, "Failed to find span for channel id string '%s'\n", string_id); - status = FTDM_EINVAL; - goto done; - } - - if (chan_id > (FTDM_MAX_CHANNELS_SPAN+1) || !(ftdmchan = span->channels[chan_id])) { - ftdm_log(FTDM_LOG_ERROR, "Invalid channel id string '%s'\n", string_id); - status = FTDM_EINVAL; - goto done; - } - - status = FTDM_SUCCESS; - *out_span = span; - *out_channel = ftdmchan; -done: - return status; -} - -/* this function MUST be called with the channel lock held with lock recursivity of 1 exactly, - * and the caller must be aware we might unlock the channel for a brief period of time and then lock it again */ -static ftdm_status_t _ftdm_channel_call_place_nl(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_usrmsg_t *usrmsg) -{ - const char *var = NULL; - ftdm_status_t status = FTDM_FAIL; - - ftdm_assert_return(ftdmchan != NULL, FTDM_FAIL, "null channel"); - ftdm_assert_return(ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND), FTDM_FAIL, "Call place, but outbound flag not set\n"); - - if (!ftdmchan->span->outgoing_call) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "outgoing_call method not implemented in this span!\n"); - status = FTDM_ENOSYS; - goto done; - } - - if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OPEN)) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "Cannot place call in channel that is not open!\n"); - goto done; - } - - if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Cannot place call in non outbound channel in state %s!\n", ftdm_channel_state2str(ftdmchan->state)); - goto done; - } - - status = ftdmchan->span->outgoing_call(ftdmchan); - if (status == FTDM_BREAK) { - /* the signaling module detected glare on time */ - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "Glare detected, you should hunt in another channel!\n"); - goto done; - } - - if (status != FTDM_SUCCESS) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "Failed to place call!\n"); - goto done; - } - - ftdm_set_flag(ftdmchan, FTDM_CHANNEL_CALL_STARTED); - ftdm_call_set_call_id(ftdmchan, &ftdmchan->caller_data); - var = ftdm_usrmsg_get_var(usrmsg, "sigbridge_peer"); - if (var) { - ftdm_span_t *peer_span = NULL; - ftdm_channel_t *peer_chan = NULL; - ftdm_set_flag(ftdmchan, FTDM_CHANNEL_NATIVE_SIGBRIDGE); - ftdm_get_channel_from_string(var, &peer_span, &peer_chan); - if (peer_chan) { - ftdm_set_flag(peer_chan, FTDM_CHANNEL_NATIVE_SIGBRIDGE); - } - } - - /* if the signaling stack left the channel in state down on success, is expecting us to move to DIALING */ - if (ftdmchan->state == FTDM_CHANNEL_STATE_DOWN) { - if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_NONBLOCK)) { - ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_DIALING, 1, usrmsg); - } else { - ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_DIALING, 0, usrmsg); - } - } else if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_STATE_CHANGE) && - !ftdm_test_flag(ftdmchan, FTDM_CHANNEL_NONBLOCK)) { - - ftdm_channel_unlock(ftdmchan); - - ftdm_interrupt_wait(ftdmchan->state_completed_interrupt, 500); - - ftdm_channel_lock(ftdmchan); - } - -done: - ftdm_unused_arg(file); - ftdm_unused_arg(func); - ftdm_unused_arg(line); - return status; -} - -FT_DECLARE(ftdm_status_t) _ftdm_channel_call_place(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_usrmsg_t *usrmsg) -{ - ftdm_status_t status; - ftdm_channel_lock(ftdmchan); - - /* be aware that _ftdm_channl_call_place_nl can unlock/lock the channel quickly if working in blocking mode */ - status = _ftdm_channel_call_place_nl(file, func, line, ftdmchan, usrmsg); - - ftdm_channel_unlock(ftdmchan); - return status; -} - -FT_DECLARE(ftdm_status_t) _ftdm_call_place(const char *file, const char *func, int line, - ftdm_caller_data_t *caller_data, ftdm_hunting_scheme_t *hunting, ftdm_usrmsg_t *usrmsg) -{ - ftdm_status_t status = FTDM_SUCCESS; - ftdm_channel_t *fchan = NULL; - - ftdm_assert_return(caller_data, FTDM_EINVAL, "Invalid caller data\n"); - ftdm_assert_return(hunting, FTDM_EINVAL, "Invalid hunting scheme\n"); - - if (hunting->mode == FTDM_HUNT_SPAN) { - status = _ftdm_channel_open_by_span(hunting->mode_data.span.span_id, - hunting->mode_data.span.direction, caller_data, &fchan); - } else if (hunting->mode == FTDM_HUNT_GROUP) { - status = _ftdm_channel_open_by_group(hunting->mode_data.group.group_id, - hunting->mode_data.group.direction, caller_data, &fchan); - } else if (hunting->mode == FTDM_HUNT_CHAN) { - status = _ftdm_channel_open(hunting->mode_data.chan.span_id, hunting->mode_data.chan.chan_id, &fchan, 0); - } else { - ftdm_log(FTDM_LOG_ERROR, "Cannot make outbound call with invalid hunting mode %d\n", hunting->mode); - return FTDM_EINVAL; - } - - if (status != FTDM_SUCCESS) { - return FTDM_EBUSY; - } - - /* we have a locked channel and are not afraid of using it! */ - if (hunting->result_cb) { - status = hunting->result_cb(fchan, caller_data); - if (status != FTDM_SUCCESS) { - status = FTDM_ECANCELED; - goto done; - } - } - - ftdm_channel_set_caller_data(fchan, caller_data); - - /* be aware that _ftdm_channl_call_place_nl can unlock/lock the channel quickly if working in blocking mode */ - status = _ftdm_channel_call_place_nl(file, func, line, fchan, usrmsg); - if (status != FTDM_SUCCESS) { - _ftdm_channel_call_hangup_nl(file, func, line, fchan, usrmsg); - goto done; - } - - /* let the user know which channel was picked and which call id was generated */ - caller_data->fchan = fchan; - caller_data->call_id = fchan->caller_data.call_id; -done: - ftdm_channel_unlock(fchan); - - return status; -} - -FT_DECLARE(ftdm_status_t) ftdm_channel_set_sig_status(ftdm_channel_t *fchan, ftdm_signaling_status_t sigstatus) -{ - ftdm_status_t res; - - ftdm_assert_return(fchan != NULL, FTDM_FAIL, "Null channel\n"); - ftdm_assert_return(fchan->span != NULL, FTDM_FAIL, "Null span\n"); - ftdm_assert_return(fchan->span->set_channel_sig_status != NULL, FTDM_ENOSYS, "Not implemented\n"); - - ftdm_channel_lock(fchan); - - res = fchan->span->set_channel_sig_status(fchan, sigstatus); - - ftdm_channel_unlock(fchan); - - return res; -} - -FT_DECLARE(ftdm_status_t) ftdm_channel_get_sig_status(ftdm_channel_t *ftdmchan, ftdm_signaling_status_t *sigstatus) -{ - ftdm_assert_return(ftdmchan != NULL, FTDM_FAIL, "Null channel\n"); - ftdm_assert_return(ftdmchan->span != NULL, FTDM_FAIL, "Null span\n"); - ftdm_assert_return(sigstatus != NULL, FTDM_FAIL, "Null sig status parameter\n"); - - if (ftdmchan->span->get_channel_sig_status) { - ftdm_status_t res; - ftdm_channel_lock(ftdmchan); - res = ftdmchan->span->get_channel_sig_status(ftdmchan, sigstatus); - ftdm_channel_unlock(ftdmchan); - return res; - } else { - /* don't log error here, it can be called just to test if its supported */ - return FTDM_NOTIMPL; - } -} - -FT_DECLARE(ftdm_status_t) ftdm_span_set_sig_status(ftdm_span_t *span, ftdm_signaling_status_t sigstatus) -{ - ftdm_assert_return(span != NULL, FTDM_FAIL, "Null span\n"); - - if (sigstatus == FTDM_SIG_STATE_DOWN) { - ftdm_log(FTDM_LOG_WARNING, "The user is not allowed to set the signaling status to DOWN, valid states are UP or SUSPENDED\n"); - return FTDM_FAIL; - } - - if (span->set_span_sig_status) { - return span->set_span_sig_status(span, sigstatus); - } else { - ftdm_log(FTDM_LOG_ERROR, "set_span_sig_status method not implemented!\n"); - return FTDM_FAIL; - } -} - -FT_DECLARE(ftdm_status_t) ftdm_span_get_sig_status(ftdm_span_t *span, ftdm_signaling_status_t *sigstatus) -{ - ftdm_assert_return(span != NULL, FTDM_FAIL, "Null span\n"); - ftdm_assert_return(sigstatus != NULL, FTDM_FAIL, "Null sig status parameter\n"); - - if (span->get_span_sig_status) { - return span->get_span_sig_status(span, sigstatus); - } else { - return FTDM_FAIL; - } -} - -static ftdm_status_t ftdm_channel_sig_indicate(ftdm_channel_t *ftdmchan, ftdm_channel_indication_t indication, ftdm_usrmsg_t *usrmsg) -{ - ftdm_status_t status = FTDM_FAIL; - if (ftdmchan->span->indicate) { - - ftdm_channel_save_usrmsg(ftdmchan, usrmsg); - - status = ftdmchan->span->indicate(ftdmchan, indication); - if (status == FTDM_NOTIMPL) { - ftdm_log(FTDM_LOG_WARNING, "Do not know how to indicate %s\n", ftdm_channel_indication2str(indication)); - } else if (status != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_WARNING, "Failed to indicate %s\n", ftdm_channel_indication2str(indication)); - } else { /* SUCCESS */ - ftdm_ack_indication(ftdmchan, indication, FTDM_SUCCESS); - } - ftdm_usrmsg_free(&ftdmchan->usrmsg); - } else { - return FTDM_NOTIMPL; - } - return status; -} - - -/* this function must be called with the channel lock */ -static ftdm_status_t ftdm_channel_done(ftdm_channel_t *ftdmchan) -{ - ftdm_assert_return(ftdmchan != NULL, FTDM_FAIL, "Null channel can't be done!\n"); - - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_OPEN); - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_DTMF_DETECT); - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_SUPRESS_DTMF); - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_INUSE); - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND); - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_WINK); - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_FLASH); - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_STATE_CHANGE); - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_HOLD); - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_OFFHOOK); - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_RINGING); - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_PROGRESS_DETECT); - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_CALLERID_DETECT); - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_3WAY); - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_PROGRESS); - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_MEDIA); - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_ANSWERED); - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_USER_HANGUP); - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_DIGITAL_MEDIA); - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_NATIVE_SIGBRIDGE); - ftdm_mutex_lock(ftdmchan->pre_buffer_mutex); - ftdm_buffer_destroy(&ftdmchan->pre_buffer); - ftdmchan->pre_buffer_size = 0; - ftdm_mutex_unlock(ftdmchan->pre_buffer_mutex); - - if (ftdmchan->hangup_timer) { - ftdm_sched_cancel_timer(globals.timingsched, ftdmchan->hangup_timer); - } - - ftdmchan->init_state = FTDM_CHANNEL_STATE_DOWN; - ftdmchan->state = FTDM_CHANNEL_STATE_DOWN; - ftdmchan->state_status = FTDM_STATE_STATUS_COMPLETED; - - ftdm_channel_command(ftdmchan, FTDM_COMMAND_DISABLE_DEBUG_DTMF, NULL); - ftdm_channel_command(ftdmchan, FTDM_COMMAND_DISABLE_INPUT_DUMP, NULL); - ftdm_channel_command(ftdmchan, FTDM_COMMAND_DISABLE_OUTPUT_DUMP, NULL); - - if (FTDM_IS_VOICE_CHANNEL(ftdmchan) && ftdm_test_flag(ftdmchan, FTDM_CHANNEL_CALL_STARTED)) { - ftdm_sigmsg_t sigmsg; - memset(&sigmsg, 0, sizeof(sigmsg)); - sigmsg.span_id = ftdmchan->span_id; - sigmsg.chan_id = ftdmchan->chan_id; - sigmsg.channel = ftdmchan; - sigmsg.event_id = FTDM_SIGEVENT_RELEASED; - ftdm_span_send_signal(ftdmchan->span, &sigmsg); - ftdm_call_clear_call_id(&ftdmchan->caller_data); - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_CALL_STARTED); - } - - if (ftdmchan->txdrops || ftdmchan->rxdrops) { - ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "channel dropped data: txdrops = %d, rxdrops = %d\n", - ftdmchan->txdrops, ftdmchan->rxdrops); - } - - memset(&ftdmchan->caller_data, 0, sizeof(ftdmchan->caller_data)); - - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_HOLD); - - memset(ftdmchan->tokens, 0, sizeof(ftdmchan->tokens)); - ftdmchan->token_count = 0; - - ftdm_channel_flush_dtmf(ftdmchan); - - if (ftdmchan->gen_dtmf_buffer) { - ftdm_buffer_zero(ftdmchan->gen_dtmf_buffer); - } - - if (ftdmchan->dtmf_buffer) { - ftdm_buffer_zero(ftdmchan->dtmf_buffer); - } - - if (ftdmchan->digit_buffer) { - ftdm_buffer_zero(ftdmchan->digit_buffer); - } - - if (!ftdmchan->dtmf_on) { - ftdmchan->dtmf_on = FTDM_DEFAULT_DTMF_ON; - } - - if (!ftdmchan->dtmf_off) { - ftdmchan->dtmf_off = FTDM_DEFAULT_DTMF_OFF; - } - - memset(ftdmchan->dtmf_hangup_buf, '\0', ftdmchan->span->dtmf_hangup_len); - - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_TRANSCODE)) { - ftdmchan->effective_codec = ftdmchan->native_codec; - ftdmchan->packet_len = ftdmchan->native_interval * (ftdmchan->effective_codec == FTDM_CODEC_SLIN ? 16 : 8); - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_TRANSCODE); - } - - if (ftdmchan->span->sig_release_guard_time_ms) { - ftdmchan->last_release_time = ftdm_current_time_in_ms(); - } - - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "channel done\n"); - return FTDM_SUCCESS; -} - -FT_DECLARE(ftdm_status_t) ftdm_channel_use(ftdm_channel_t *ftdmchan) -{ - - ftdm_assert(ftdmchan != NULL, "Null channel\n"); - - ftdm_set_flag_locked(ftdmchan, FTDM_CHANNEL_INUSE); - - return FTDM_SUCCESS; -} - -FT_DECLARE(ftdm_status_t) ftdm_channel_close(ftdm_channel_t **ftdmchan) -{ - ftdm_channel_t *check; - ftdm_status_t status = FTDM_FAIL; - - ftdm_assert_return(ftdmchan != NULL, FTDM_FAIL, "null channel double pointer provided!\n"); - ftdm_assert_return(*ftdmchan != NULL, FTDM_FAIL, "null channel pointer provided!\n"); - - check = *ftdmchan; - *ftdmchan = NULL; - - if (ftdm_test_flag(check, FTDM_CHANNEL_CONFIGURED)) { - ftdm_mutex_lock(check->mutex); - if (!ftdm_test_flag(check, FTDM_CHANNEL_OPEN)) { - ftdm_log_chan_msg(check, FTDM_LOG_WARNING, "Channel not opened, proceeding anyway\n"); - } - status = check->fio->close(check); - ftdm_assert(status == FTDM_SUCCESS, "Failed to close channel!\n"); - ftdm_channel_done(check); - *ftdmchan = NULL; - check->ring_count = 0; - ftdm_mutex_unlock(check->mutex); - } - - return status; -} - -static ftdm_status_t ftdmchan_activate_dtmf_buffer(ftdm_channel_t *ftdmchan) -{ - if (!ftdmchan->dtmf_buffer) { - if (ftdm_buffer_create(&ftdmchan->dtmf_buffer, 1024, 3192, 0) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "Failed to allocate DTMF Buffer!\n"); - return FTDM_FAIL; - } else { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Created DTMF buffer\n"); - } - } - - - if (!ftdmchan->tone_session.buffer) { - memset(&ftdmchan->tone_session, 0, sizeof(ftdmchan->tone_session)); - teletone_init_session(&ftdmchan->tone_session, 0, NULL, NULL); - } - - ftdmchan->tone_session.rate = ftdmchan->rate; - ftdmchan->tone_session.duration = ftdmchan->dtmf_on * (ftdmchan->tone_session.rate / 1000); - ftdmchan->tone_session.wait = ftdmchan->dtmf_off * (ftdmchan->tone_session.rate / 1000); - ftdmchan->tone_session.volume = -7; - - /* - ftdmchan->tone_session.debug = 1; - ftdmchan->tone_session.debug_stream = stdout; - */ - - return FTDM_SUCCESS; -} - -/* - * ftdmchan_activate_dtmf_buffer to initialize ftdmchan->dtmf_buffer should be called prior to - * calling ftdm_insert_dtmf_pause - */ -static ftdm_status_t ftdm_insert_dtmf_pause(ftdm_channel_t *ftdmchan, ftdm_size_t pausems) -{ - void *data = NULL; - ftdm_size_t datalen = pausems * sizeof(uint16_t); - - data = ftdm_malloc(datalen); - ftdm_assert(data, "Failed to allocate memory\n"); - - memset(data, FTDM_SILENCE_VALUE(ftdmchan), datalen); - - ftdm_buffer_write(ftdmchan->dtmf_buffer, data, datalen); - ftdm_safe_free(data); - return FTDM_SUCCESS; -} - -FT_DECLARE(ftdm_status_t) ftdm_channel_command(ftdm_channel_t *ftdmchan, ftdm_command_t command, void *obj) -{ - ftdm_status_t status = FTDM_FAIL; - - ftdm_assert_return(ftdmchan != NULL, FTDM_FAIL, "No channel\n"); - ftdm_assert_return(ftdmchan->fio != NULL, FTDM_FAIL, "No IO attached to channel\n"); - - ftdm_channel_lock(ftdmchan); - - switch (command) { - - case FTDM_COMMAND_ENABLE_CALLERID_DETECT: - { - if (!ftdm_channel_test_feature(ftdmchan, FTDM_CHANNEL_FEATURE_CALLERID)) { - if (ftdm_fsk_demod_init(&ftdmchan->fsk, ftdmchan->rate, ftdmchan->fsk_buf, sizeof(ftdmchan->fsk_buf)) != FTDM_SUCCESS) { - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "%s", strerror(errno)); - GOTO_STATUS(done, FTDM_FAIL); - } - ftdm_set_flag(ftdmchan, FTDM_CHANNEL_CALLERID_DETECT); - GOTO_STATUS(done, FTDM_SUCCESS); - } - } - break; - case FTDM_COMMAND_DISABLE_CALLERID_DETECT: - { - if (!ftdm_channel_test_feature(ftdmchan, FTDM_CHANNEL_FEATURE_CALLERID)) { - ftdm_fsk_demod_destroy(&ftdmchan->fsk); - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_CALLERID_DETECT); - GOTO_STATUS(done, FTDM_SUCCESS); - } - } - break; - case FTDM_COMMAND_TRACE_INPUT: - { - char *path = FTDM_COMMAND_OBJ_CHAR_P; - if (ftdmchan->fds[FTDM_READ_TRACE_INDEX] > 0) { - close(ftdmchan->fds[FTDM_READ_TRACE_INDEX]); - ftdmchan->fds[FTDM_READ_TRACE_INDEX] = -1; - } - if ((ftdmchan->fds[FTDM_READ_TRACE_INDEX] = open(path, O_WRONLY | O_CREAT | O_TRUNC - | FTDM_O_BINARY, S_IRUSR | S_IWUSR)) > -1) { - ftdm_log(FTDM_LOG_DEBUG, "Tracing channel %u:%u input to [%s]\n", ftdmchan->span_id, ftdmchan->chan_id, path); - GOTO_STATUS(done, FTDM_SUCCESS); - } - - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "%s", strerror(errno)); - GOTO_STATUS(done, FTDM_FAIL); - } - break; - case FTDM_COMMAND_TRACE_OUTPUT: - { - char *path = (char *) obj; - if (ftdmchan->fds[FTDM_WRITE_TRACE_INDEX] > 0) { - close(ftdmchan->fds[FTDM_WRITE_TRACE_INDEX]); - ftdmchan->fds[FTDM_WRITE_TRACE_INDEX] = -1; - } - if ((ftdmchan->fds[FTDM_WRITE_TRACE_INDEX] = open(path, O_WRONLY | O_CREAT | O_TRUNC - | FTDM_O_BINARY, S_IRUSR | S_IWUSR)) > -1) { - ftdm_log(FTDM_LOG_DEBUG, "Tracing channel %u:%u output to [%s]\n", ftdmchan->span_id, ftdmchan->chan_id, path); - GOTO_STATUS(done, FTDM_SUCCESS); - } - - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "%s", strerror(errno)); - GOTO_STATUS(done, FTDM_FAIL); - } - break; - case FTDM_COMMAND_TRACE_END_ALL: - { - if (ftdmchan->fds[FTDM_READ_TRACE_INDEX] > 0) { - close(ftdmchan->fds[FTDM_READ_TRACE_INDEX]); - ftdmchan->fds[FTDM_READ_TRACE_INDEX] = -1; - } - if (ftdmchan->fds[FTDM_WRITE_TRACE_INDEX] > 0) { - close(ftdmchan->fds[FTDM_WRITE_TRACE_INDEX]); - ftdmchan->fds[FTDM_WRITE_TRACE_INDEX] = -1; - } - GOTO_STATUS(done, FTDM_SUCCESS); - } - break; - - /*!< Enable DTMF debugging */ - case FTDM_COMMAND_ENABLE_DEBUG_DTMF: - { - if (ftdmchan->dtmfdbg.enabled) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "Cannot enable debug DTMF again\n"); - GOTO_STATUS(done, FTDM_FAIL); - } - if (ftdmchan->rxdump.buffer) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "Cannot debug DTMF if Rx dumping is already enabled\n"); - GOTO_STATUS(done, FTDM_FAIL); - } - if (start_chan_io_dump(ftdmchan, &ftdmchan->rxdump, FTDM_IO_DUMP_DEFAULT_BUFF_SIZE) != FTDM_SUCCESS) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "Failed to enable rx dump for DTMF debugging\n"); - GOTO_STATUS(done, FTDM_FAIL); - } - ftdmchan->dtmfdbg.enabled = 1; - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Enabled DTMF debugging\n"); - GOTO_STATUS(done, FTDM_SUCCESS); - } - break; - - /*!< Disable DTMF debugging (if not disabled explicitly, it is disabled automatically when calls hangup) */ - case FTDM_COMMAND_DISABLE_DEBUG_DTMF: - { - if (!ftdmchan->dtmfdbg.enabled) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "DTMF debug is already disabled\n"); - GOTO_STATUS(done, FTDM_SUCCESS); - } - if (disable_dtmf_debug(ftdmchan) != FTDM_SUCCESS) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "Failed to disable DTMF debug\n"); - GOTO_STATUS(done, FTDM_FAIL); - } - GOTO_STATUS(done, FTDM_SUCCESS); - } - break; - - /*!< Start dumping all input to a circular buffer. The size of the circular buffer can be specified, default used otherwise */ - case FTDM_COMMAND_ENABLE_INPUT_DUMP: - { - ftdm_size_t size = obj ? FTDM_COMMAND_OBJ_SIZE : FTDM_IO_DUMP_DEFAULT_BUFF_SIZE; - if (ftdmchan->rxdump.buffer) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "Input dump is already enabled\n"); - GOTO_STATUS(done, FTDM_FAIL); - } - if (start_chan_io_dump(ftdmchan, &ftdmchan->rxdump, size) != FTDM_SUCCESS) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Failed to enable input dump of size %"FTDM_SIZE_FMT"\n", size); - GOTO_STATUS(done, FTDM_FAIL); - } - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Enabled input dump with size %"FTDM_SIZE_FMT"\n", size); - GOTO_STATUS(done, FTDM_SUCCESS); - } - break; - - /*!< Stop dumping all input to a circular buffer. */ - case FTDM_COMMAND_DISABLE_INPUT_DUMP: - { - if (!ftdmchan->rxdump.buffer) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "No need to disable input dump\n"); - GOTO_STATUS(done, FTDM_SUCCESS); - } - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Disabled input dump of size %"FTDM_SIZE_FMT"\n", - ftdmchan->rxdump.size); - stop_chan_io_dump(&ftdmchan->rxdump); - GOTO_STATUS(done, FTDM_SUCCESS); - } - break; - - /*!< Start dumping all output to a circular buffer. The size of the circular buffer can be specified, default used otherwise */ - case FTDM_COMMAND_ENABLE_OUTPUT_DUMP: - { - ftdm_size_t size = obj ? FTDM_COMMAND_OBJ_SIZE : FTDM_IO_DUMP_DEFAULT_BUFF_SIZE; - if (ftdmchan->txdump.buffer) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "Output dump is already enabled\n"); - GOTO_STATUS(done, FTDM_FAIL); - } - if (start_chan_io_dump(ftdmchan, &ftdmchan->txdump, size) != FTDM_SUCCESS) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Failed to enable output dump of size %"FTDM_SIZE_FMT"\n", size); - GOTO_STATUS(done, FTDM_FAIL); - } - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Enabled output dump with size %"FTDM_SIZE_FMT"\n", size); - GOTO_STATUS(done, FTDM_SUCCESS); - } - break; - - /*!< Stop dumping all output to a circular buffer. */ - case FTDM_COMMAND_DISABLE_OUTPUT_DUMP: - { - if (!ftdmchan->txdump.buffer) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "No need to disable output dump\n"); - GOTO_STATUS(done, FTDM_SUCCESS); - } - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Disabled output dump of size %"FTDM_SIZE_FMT"\n", ftdmchan->rxdump.size); - stop_chan_io_dump(&ftdmchan->txdump); - GOTO_STATUS(done, FTDM_SUCCESS); - } - break; - - /*!< Dump the current input circular buffer to the specified FILE* structure */ - case FTDM_COMMAND_DUMP_INPUT: - { - if (!obj) { - GOTO_STATUS(done, FTDM_FAIL); - } - if (!ftdmchan->rxdump.buffer) { - ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Not dumped input to file %p, input dump is not enabled\n", obj); - GOTO_STATUS(done, FTDM_FAIL); - } - dump_chan_io_to_file(ftdmchan, &ftdmchan->rxdump, obj); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Dumped input of size %"FTDM_SIZE_FMT" to file %p\n", ftdmchan->rxdump.size, obj); - GOTO_STATUS(done, FTDM_SUCCESS); - } - break; - - /*!< Dump the current output circular buffer to the specified FILE* structure */ - case FTDM_COMMAND_DUMP_OUTPUT: - { - if (!obj) { - GOTO_STATUS(done, FTDM_FAIL); - } - if (!ftdmchan->txdump.buffer) { - ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Not dumped output to file %p, output dump is not enabled\n", obj); - GOTO_STATUS(done, FTDM_FAIL); - } - dump_chan_io_to_file(ftdmchan, &ftdmchan->txdump, obj); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Dumped input of size %"FTDM_SIZE_FMT" to file %p\n", ftdmchan->txdump.size, obj); - GOTO_STATUS(done, FTDM_SUCCESS); - } - break; - - case FTDM_COMMAND_SET_INTERVAL: - { - if (!ftdm_channel_test_feature(ftdmchan, FTDM_CHANNEL_FEATURE_INTERVAL)) { - ftdmchan->effective_interval = FTDM_COMMAND_OBJ_INT; - if (ftdmchan->effective_interval == ftdmchan->native_interval) { - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_BUFFER); - } else { - ftdm_set_flag(ftdmchan, FTDM_CHANNEL_BUFFER); - } - ftdmchan->packet_len = ftdmchan->native_interval * (ftdmchan->effective_codec == FTDM_CODEC_SLIN ? 16 : 8); - GOTO_STATUS(done, FTDM_SUCCESS); - } - } - break; - case FTDM_COMMAND_GET_INTERVAL: - { - if (!ftdm_channel_test_feature(ftdmchan, FTDM_CHANNEL_FEATURE_INTERVAL)) { - FTDM_COMMAND_OBJ_INT = ftdmchan->effective_interval; - GOTO_STATUS(done, FTDM_SUCCESS); - } - } - break; - case FTDM_COMMAND_SET_CODEC: - { - if (!ftdm_channel_test_feature(ftdmchan, FTDM_CHANNEL_FEATURE_CODECS)) { - ftdmchan->effective_codec = FTDM_COMMAND_OBJ_INT; - - if (ftdmchan->effective_codec == ftdmchan->native_codec) { - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_TRANSCODE); - } else { - ftdm_set_flag(ftdmchan, FTDM_CHANNEL_TRANSCODE); - } - ftdmchan->packet_len = ftdmchan->native_interval * (ftdmchan->effective_codec == FTDM_CODEC_SLIN ? 16 : 8); - GOTO_STATUS(done, FTDM_SUCCESS); - } - } - break; - - case FTDM_COMMAND_SET_NATIVE_CODEC: - { - if (!ftdm_channel_test_feature(ftdmchan, FTDM_CHANNEL_FEATURE_CODECS)) { - ftdmchan->effective_codec = ftdmchan->native_codec; - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_TRANSCODE); - ftdmchan->packet_len = ftdmchan->native_interval * (ftdmchan->effective_codec == FTDM_CODEC_SLIN ? 16 : 8); - GOTO_STATUS(done, FTDM_SUCCESS); - } - } - break; - - case FTDM_COMMAND_GET_CODEC: - { - if (!ftdm_channel_test_feature(ftdmchan, FTDM_CHANNEL_FEATURE_CODECS)) { - FTDM_COMMAND_OBJ_INT = ftdmchan->effective_codec; - GOTO_STATUS(done, FTDM_SUCCESS); - } - } - break; - case FTDM_COMMAND_GET_NATIVE_CODEC: - { - if (!ftdm_channel_test_feature(ftdmchan, FTDM_CHANNEL_FEATURE_CODECS)) { - FTDM_COMMAND_OBJ_INT = ftdmchan->native_codec; - GOTO_STATUS(done, FTDM_SUCCESS); - } - } - break; - case FTDM_COMMAND_ENABLE_PROGRESS_DETECT: - { - if (!ftdm_channel_test_feature(ftdmchan, FTDM_CHANNEL_FEATURE_PROGRESS)) { - /* if they don't have thier own, use ours */ - ftdm_channel_clear_detected_tones(ftdmchan); - ftdm_channel_clear_needed_tones(ftdmchan); - teletone_multi_tone_init(&ftdmchan->span->tone_finder[FTDM_TONEMAP_DIAL], &ftdmchan->span->tone_detect_map[FTDM_TONEMAP_DIAL]); - teletone_multi_tone_init(&ftdmchan->span->tone_finder[FTDM_TONEMAP_RING], &ftdmchan->span->tone_detect_map[FTDM_TONEMAP_RING]); - teletone_multi_tone_init(&ftdmchan->span->tone_finder[FTDM_TONEMAP_BUSY], &ftdmchan->span->tone_detect_map[FTDM_TONEMAP_BUSY]); - ftdm_set_flag(ftdmchan, FTDM_CHANNEL_PROGRESS_DETECT); - GOTO_STATUS(done, FTDM_SUCCESS); - } - } - break; - case FTDM_COMMAND_DISABLE_PROGRESS_DETECT: - { - if (!ftdm_channel_test_feature(ftdmchan, FTDM_CHANNEL_FEATURE_PROGRESS)) { - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_PROGRESS_DETECT); - ftdm_channel_clear_detected_tones(ftdmchan); - ftdm_channel_clear_needed_tones(ftdmchan); - GOTO_STATUS(done, FTDM_SUCCESS); - } - } - break; - case FTDM_COMMAND_ENABLE_DTMF_DETECT: - { - /* if they don't have thier own, use ours */ - if (FTDM_IS_VOICE_CHANNEL(ftdmchan)) { - if (FTDM_CHANNEL_SW_DTMF_ALLOWED(ftdmchan)) { - teletone_dtmf_detect_init (&ftdmchan->dtmf_detect, ftdmchan->rate); - ftdm_set_flag(ftdmchan, FTDM_CHANNEL_DTMF_DETECT); - ftdm_set_flag(ftdmchan, FTDM_CHANNEL_SUPRESS_DTMF); - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Enabled software DTMF detector\n"); - GOTO_STATUS(done, FTDM_SUCCESS); - } - } - } - break; - case FTDM_COMMAND_DISABLE_DTMF_DETECT: - { - if (FTDM_IS_VOICE_CHANNEL(ftdmchan)) { - if (FTDM_CHANNEL_SW_DTMF_ALLOWED(ftdmchan)) { - teletone_dtmf_detect_init (&ftdmchan->dtmf_detect, ftdmchan->rate); - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_DTMF_DETECT); - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_SUPRESS_DTMF); - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Disabled software DTMF detector\n"); - GOTO_STATUS(done, FTDM_SUCCESS); - } - } - } - break; - case FTDM_COMMAND_SET_PRE_BUFFER_SIZE: - { - int val = FTDM_COMMAND_OBJ_INT; - - if (val < 0) { - val = 0; - } - - ftdmchan->pre_buffer_size = val * 8; - - ftdm_mutex_lock(ftdmchan->pre_buffer_mutex); - if (!ftdmchan->pre_buffer_size) { - ftdm_buffer_destroy(&ftdmchan->pre_buffer); - } else if (!ftdmchan->pre_buffer) { - ftdm_buffer_create(&ftdmchan->pre_buffer, 1024, ftdmchan->pre_buffer_size, 0); - } - ftdm_mutex_unlock(ftdmchan->pre_buffer_mutex); - - GOTO_STATUS(done, FTDM_SUCCESS); - - } - break; - case FTDM_COMMAND_GET_DTMF_ON_PERIOD: - { - if (!ftdm_channel_test_feature(ftdmchan, FTDM_CHANNEL_FEATURE_DTMF_GENERATE)) { - FTDM_COMMAND_OBJ_INT = ftdmchan->dtmf_on; - GOTO_STATUS(done, FTDM_SUCCESS); - } - } - break; - case FTDM_COMMAND_GET_DTMF_OFF_PERIOD: - { - if (!ftdm_channel_test_feature(ftdmchan, FTDM_CHANNEL_FEATURE_DTMF_GENERATE)) { - FTDM_COMMAND_OBJ_INT = ftdmchan->dtmf_on; - GOTO_STATUS(done, FTDM_SUCCESS); - } - } - break; - case FTDM_COMMAND_SET_DTMF_ON_PERIOD: - { - if (!ftdm_channel_test_feature(ftdmchan, FTDM_CHANNEL_FEATURE_DTMF_GENERATE)) { - int val = FTDM_COMMAND_OBJ_INT; - if (val > 10 && val < 1000) { - ftdmchan->dtmf_on = val; - GOTO_STATUS(done, FTDM_SUCCESS); - } else { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "invalid value %d range 10-1000", val); - GOTO_STATUS(done, FTDM_FAIL); - } - } - } - break; - case FTDM_COMMAND_SET_DTMF_OFF_PERIOD: - { - if (!ftdm_channel_test_feature(ftdmchan, FTDM_CHANNEL_FEATURE_DTMF_GENERATE)) { - int val = FTDM_COMMAND_OBJ_INT; - if (val > 10 && val < 1000) { - ftdmchan->dtmf_off = val; - GOTO_STATUS(done, FTDM_SUCCESS); - } else { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "invalid value %d range 10-1000", val); - GOTO_STATUS(done, FTDM_FAIL); - } - } - } - break; - case FTDM_COMMAND_SEND_DTMF: - { - char *digits = FTDM_COMMAND_OBJ_CHAR_P; - if (ftdmchan->span->sig_send_dtmf) { - status = ftdmchan->span->sig_send_dtmf(ftdmchan, digits); - GOTO_STATUS(done, status); - } else if (!ftdm_channel_test_feature(ftdmchan, FTDM_CHANNEL_FEATURE_DTMF_GENERATE)) { - - if ((status = ftdmchan_activate_dtmf_buffer(ftdmchan)) != FTDM_SUCCESS) { - GOTO_STATUS(done, status); - } - - ftdm_buffer_write(ftdmchan->gen_dtmf_buffer, digits, strlen(digits)); - - GOTO_STATUS(done, FTDM_SUCCESS); - } - } - break; - - case FTDM_COMMAND_DISABLE_ECHOCANCEL: - { - ftdm_mutex_lock(ftdmchan->pre_buffer_mutex); - ftdm_buffer_destroy(&ftdmchan->pre_buffer); - ftdmchan->pre_buffer_size = 0; - ftdm_mutex_unlock(ftdmchan->pre_buffer_mutex); - } - break; - - case FTDM_COMMAND_SET_RX_GAIN: - { - if (!FTDM_IS_VOICE_CHANNEL(ftdmchan)) { - ftdm_log(FTDM_LOG_ERROR, "Cannot set rx gain in non-voice channel of type: %s\n", ftdm_chan_type2str(ftdmchan->type)); - GOTO_STATUS(done, FTDM_FAIL); - } - ftdmchan->rxgain = FTDM_COMMAND_OBJ_FLOAT; - reset_gain_table(ftdmchan->rxgain_table, ftdmchan->rxgain, ftdmchan->native_codec); - if (ftdmchan->rxgain == 0.0) { - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_USE_RX_GAIN); - } else { - ftdm_set_flag(ftdmchan, FTDM_CHANNEL_USE_RX_GAIN); - } - GOTO_STATUS(done, FTDM_SUCCESS); - } - break; - case FTDM_COMMAND_GET_RX_GAIN: - { - FTDM_COMMAND_OBJ_FLOAT = ftdmchan->rxgain; - GOTO_STATUS(done, FTDM_SUCCESS); - } - break; - case FTDM_COMMAND_SET_TX_GAIN: - { - if (!FTDM_IS_VOICE_CHANNEL(ftdmchan)) { - ftdm_log(FTDM_LOG_ERROR, "Cannot set tx gain in non-voice channel of type: %s\n", ftdm_chan_type2str(ftdmchan->type)); - GOTO_STATUS(done, FTDM_FAIL); - } - ftdmchan->txgain = FTDM_COMMAND_OBJ_FLOAT; - reset_gain_table(ftdmchan->txgain_table, ftdmchan->txgain, ftdmchan->native_codec); - if (ftdmchan->txgain == 0.0) { - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_USE_TX_GAIN); - } else { - ftdm_set_flag(ftdmchan, FTDM_CHANNEL_USE_TX_GAIN); - } - GOTO_STATUS(done, FTDM_SUCCESS); - } - break; - case FTDM_COMMAND_GET_TX_GAIN: - { - FTDM_COMMAND_OBJ_FLOAT = ftdmchan->txgain; - GOTO_STATUS(done, FTDM_SUCCESS); - } - break; - case FTDM_COMMAND_GET_IOSTATS: - { - if (!obj) { - GOTO_STATUS(done, FTDM_EINVAL); - } - memcpy(obj, &ftdmchan->iostats, sizeof(ftdmchan->iostats)); - GOTO_STATUS(done, FTDM_SUCCESS); - } - break; - case FTDM_COMMAND_SWITCH_IOSTATS: - { - ftdm_bool_t enable = *(ftdm_bool_t *)obj; - if (enable) { - ftdm_channel_set_feature(ftdmchan, FTDM_CHANNEL_FEATURE_IO_STATS); - } else { - ftdm_channel_clear_feature(ftdmchan, FTDM_CHANNEL_FEATURE_IO_STATS); - } - GOTO_STATUS(done, FTDM_SUCCESS); - } - break; - default: - break; - } - - if (!ftdmchan->fio->command) { - ftdm_log(FTDM_LOG_ERROR, "no command function defined by the I/O freetdm module!\n"); - GOTO_STATUS(done, FTDM_FAIL); - } - - status = ftdmchan->fio->command(ftdmchan, command, obj); - - if (status == FTDM_NOTIMPL) { - ftdm_log(FTDM_LOG_ERROR, "I/O backend does not support command %d!\n", command); - } - -done: - ftdm_channel_unlock(ftdmchan); - - return status; - -} - -FT_DECLARE(ftdm_status_t) ftdm_channel_wait(ftdm_channel_t *ftdmchan, ftdm_wait_flag_t *flags, int32_t to) -{ - ftdm_status_t status = FTDM_FAIL; - ftdm_assert_return(ftdmchan != NULL, FTDM_FAIL, "Null channel\n"); - ftdm_assert_return(ftdmchan->fio != NULL, FTDM_FAIL, "Null io interface\n"); - ftdm_assert_return(ftdmchan->fio->wait != NULL, FTDM_NOTIMPL, "wait method not implemented\n"); - - status = ftdmchan->fio->wait(ftdmchan, flags, to); - if (status == FTDM_TIMEOUT) { - /* make sure the flags are cleared on timeout */ - *flags = 0; - } - return status; -} - -/*******************************/ -FIO_CODEC_FUNCTION(fio_slin2ulaw) -{ - int16_t sln_buf[512] = {0}, *sln = sln_buf; - uint8_t *lp = data; - uint32_t i; - ftdm_size_t len = *datalen; - - if (max > len) { - max = len; - } - - memcpy(sln, data, max); - - for(i = 0; i < max; i++) { - *lp++ = linear_to_ulaw(*sln++); - } - - *datalen = max / 2; - - return FTDM_SUCCESS; - -} - - -FIO_CODEC_FUNCTION(fio_ulaw2slin) -{ - int16_t *sln = data; - uint8_t law[1024] = {0}, *lp = law; - uint32_t i; - ftdm_size_t len = *datalen; - - if (max > len) { - max = len; - } - - memcpy(law, data, max); - - for(i = 0; i < max; i++) { - *sln++ = ulaw_to_linear(*lp++); - } - - *datalen = max * 2; - - return FTDM_SUCCESS; -} - -FIO_CODEC_FUNCTION(fio_slin2alaw) -{ - int16_t sln_buf[512] = {0}, *sln = sln_buf; - uint8_t *lp = data; - uint32_t i; - ftdm_size_t len = *datalen; - - if (max > len) { - max = len; - } - - memcpy(sln, data, max); - - for(i = 0; i < max; i++) { - *lp++ = linear_to_alaw(*sln++); - } - - *datalen = max / 2; - - return FTDM_SUCCESS; - -} - - -FIO_CODEC_FUNCTION(fio_alaw2slin) -{ - int16_t *sln = data; - uint8_t law[1024] = {0}, *lp = law; - uint32_t i; - ftdm_size_t len = *datalen; - - if (max > len) { - max = len; - } - - memcpy(law, data, max); - - for(i = 0; i < max; i++) { - *sln++ = alaw_to_linear(*lp++); - } - - *datalen = max * 2; - - return FTDM_SUCCESS; -} - -FIO_CODEC_FUNCTION(fio_ulaw2alaw) -{ - ftdm_size_t len = *datalen; - uint32_t i; - uint8_t *lp = data; - - if (max > len) { - max = len; - } - - for(i = 0; i < max; i++) { - *lp = ulaw_to_alaw(*lp); - lp++; - } - - return FTDM_SUCCESS; -} - -FIO_CODEC_FUNCTION(fio_alaw2ulaw) -{ - ftdm_size_t len = *datalen; - uint32_t i; - uint8_t *lp = data; - - if (max > len) { - max = len; - } - - for(i = 0; i < max; i++) { - *lp = alaw_to_ulaw(*lp); - lp++; - } - - return FTDM_SUCCESS; -} - -/******************************/ - -FT_DECLARE(void) ftdm_channel_clear_detected_tones(ftdm_channel_t *ftdmchan) -{ - uint32_t i; - - memset(ftdmchan->detected_tones, 0, sizeof(ftdmchan->detected_tones[0]) * FTDM_TONEMAP_INVALID); - - for (i = 1; i < FTDM_TONEMAP_INVALID; i++) { - ftdmchan->span->tone_finder[i].tone_count = 0; - } -} - -FT_DECLARE(void) ftdm_channel_clear_needed_tones(ftdm_channel_t *ftdmchan) -{ - memset(ftdmchan->needed_tones, 0, sizeof(ftdmchan->needed_tones[0]) * FTDM_TONEMAP_INVALID); -} - -FT_DECLARE(ftdm_size_t) ftdm_channel_dequeue_dtmf(ftdm_channel_t *ftdmchan, char *dtmf, ftdm_size_t len) -{ - ftdm_size_t bytes = 0; - - assert(ftdmchan != NULL); - - if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_READY)) { - return 0; - } - - if (ftdmchan->digit_buffer && ftdm_buffer_inuse(ftdmchan->digit_buffer)) { - ftdm_mutex_lock(ftdmchan->mutex); - if ((bytes = ftdm_buffer_read(ftdmchan->digit_buffer, dtmf, len)) > 0) { - *(dtmf + bytes) = '\0'; - } - ftdm_mutex_unlock(ftdmchan->mutex); - } - - return bytes; -} - -FT_DECLARE(void) ftdm_channel_flush_dtmf(ftdm_channel_t *ftdmchan) -{ - if (ftdmchan->digit_buffer && ftdm_buffer_inuse(ftdmchan->digit_buffer)) { - ftdm_mutex_lock(ftdmchan->mutex); - ftdm_buffer_zero(ftdmchan->digit_buffer); - ftdm_mutex_unlock(ftdmchan->mutex); - } -} - -FT_DECLARE(ftdm_status_t) ftdm_channel_queue_dtmf(ftdm_channel_t *ftdmchan, const char *dtmf) -{ - ftdm_status_t status; - register ftdm_size_t len, inuse; - ftdm_size_t wr = 0; - const char *p; - - ftdm_assert_return(ftdmchan != NULL, FTDM_FAIL, "No channel\n"); - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Queuing DTMF %s (debug = %d)\n", dtmf, ftdmchan->dtmfdbg.enabled); - - if (ftdmchan->span->sig_queue_dtmf && (ftdmchan->span->sig_queue_dtmf(ftdmchan, dtmf) == FTDM_BREAK)) { - /* Signalling module wants to absorb this DTMF event */ - return FTDM_SUCCESS; - } - - if (!ftdmchan->dtmfdbg.enabled) { - goto skipdebug; - } - - if (!ftdmchan->dtmfdbg.file) { - struct tm currtime; - time_t currsec; - char dfile[1138]; - - currsec = time(NULL); - -#ifdef WIN32 - _tzset(); - _localtime64_s(&currtime, &currsec); -#else - localtime_r(&currsec, &currtime); -#endif - - if (ftdm_strlen_zero(globals.dtmfdebug_directory)) { - snprintf(dfile, sizeof(dfile), "dtmf-s%dc%d-20%d-%d-%d-%d%d%d.%s", - ftdmchan->span_id, ftdmchan->chan_id, - currtime.tm_year-100, currtime.tm_mon+1, currtime.tm_mday, - currtime.tm_hour, currtime.tm_min, currtime.tm_sec, ftdmchan->native_codec == FTDM_CODEC_ULAW ? "ulaw" : ftdmchan->native_codec == FTDM_CODEC_ALAW ? "alaw" : "sln"); - } else { - snprintf(dfile, sizeof(dfile), "%s/dtmf-s%dc%d-20%d-%d-%d-%d%d%d.%s", - globals.dtmfdebug_directory, - ftdmchan->span_id, ftdmchan->chan_id, - currtime.tm_year-100, currtime.tm_mon+1, currtime.tm_mday, - currtime.tm_hour, currtime.tm_min, currtime.tm_sec, ftdmchan->native_codec == FTDM_CODEC_ULAW ? "ulaw" : ftdmchan->native_codec == FTDM_CODEC_ALAW ? "alaw" : "sln"); - } - ftdmchan->dtmfdbg.file = fopen(dfile, "wb"); - if (!ftdmchan->dtmfdbg.file) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "failed to open debug dtmf file %s\n", dfile); - } else { - ftdmchan->dtmfdbg.closetimeout = DTMF_DEBUG_TIMEOUT; - ftdm_channel_command(ftdmchan, FTDM_COMMAND_DUMP_INPUT, ftdmchan->dtmfdbg.file); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Dumped initial DTMF output to %s\n", dfile); - } - } else { - ftdmchan->dtmfdbg.closetimeout = DTMF_DEBUG_TIMEOUT; - } - -skipdebug: - - if (ftdmchan->pre_buffer) { - ftdm_buffer_zero(ftdmchan->pre_buffer); - } - - ftdm_mutex_lock(ftdmchan->mutex); - - inuse = ftdm_buffer_inuse(ftdmchan->digit_buffer); - len = strlen(dtmf); - - if (len + inuse > ftdm_buffer_len(ftdmchan->digit_buffer)) { - ftdm_buffer_toss(ftdmchan->digit_buffer, strlen(dtmf)); - } - - if (ftdmchan->span->dtmf_hangup_len) { - for (p = dtmf; ftdm_is_dtmf(*p); p++) { - memmove (ftdmchan->dtmf_hangup_buf, ftdmchan->dtmf_hangup_buf + 1, ftdmchan->span->dtmf_hangup_len - 1); - ftdmchan->dtmf_hangup_buf[ftdmchan->span->dtmf_hangup_len - 1] = *p; - if (!strcmp(ftdmchan->dtmf_hangup_buf, ftdmchan->span->dtmf_hangup)) { - ftdm_log(FTDM_LOG_DEBUG, "DTMF hangup detected.\n"); - - ftdm_channel_set_state(__FILE__, __FTDM_FUNC__, __LINE__, ftdmchan, FTDM_CHANNEL_STATE_HANGUP, 0, NULL); - break; - } - } - } - - p = dtmf; - while (wr < len && p) { - if (ftdm_is_dtmf(*p)) { - wr++; - } else { - break; - } - p++; - } - - status = ftdm_buffer_write(ftdmchan->digit_buffer, dtmf, wr) ? FTDM_SUCCESS : FTDM_FAIL; - ftdm_mutex_unlock(ftdmchan->mutex); - - return status; -} - -FT_DECLARE(ftdm_status_t) ftdm_raw_write (ftdm_channel_t *ftdmchan, void *data, ftdm_size_t *datalen) -{ - int dlen = (int) *datalen; - - if (ftdm_test_io_flag(ftdmchan, FTDM_CHANNEL_IO_WRITE)) { - ftdm_clear_io_flag(ftdmchan, FTDM_CHANNEL_IO_WRITE); - } - - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_TX_DISABLED)) { - ftdmchan->txdrops++; - if (ftdmchan->txdrops <= 10) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "cannot write in channel with tx disabled\n"); - } - if (ftdmchan->txdrops == 10) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "Too many tx drops, not printing anymore\n"); - } - return FTDM_FAIL; - } - if (ftdmchan->fds[FTDM_WRITE_TRACE_INDEX] > -1) { - if ((write(ftdmchan->fds[FTDM_WRITE_TRACE_INDEX], data, dlen)) != dlen) { - ftdm_log(FTDM_LOG_WARNING, "Raw output trace failed to write all of the %d bytes\n", dlen); - } - } - write_chan_io_dump(&ftdmchan->txdump, data, dlen); - return ftdmchan->fio->write(ftdmchan, data, datalen); -} - -FT_DECLARE(ftdm_status_t) ftdm_raw_read (ftdm_channel_t *ftdmchan, void *data, ftdm_size_t *datalen) -{ - ftdm_status_t status; - - if (ftdm_test_io_flag(ftdmchan, FTDM_CHANNEL_IO_READ)) { - ftdm_clear_io_flag(ftdmchan, FTDM_CHANNEL_IO_READ); - } - status = ftdmchan->fio->read(ftdmchan, data, datalen); - - if (status == FTDM_SUCCESS && ftdm_test_flag(ftdmchan, FTDM_CHANNEL_USE_RX_GAIN) - && (ftdmchan->native_codec == FTDM_CODEC_ALAW || ftdmchan->native_codec == FTDM_CODEC_ULAW)) { - ftdm_size_t i = 0; - unsigned char *rdata = data; - for (i = 0; i < *datalen; i++) { - rdata[i] = ftdmchan->rxgain_table[rdata[i]]; - } - } - - if (status == FTDM_SUCCESS && ftdmchan->fds[FTDM_READ_TRACE_INDEX] > -1) { - ftdm_size_t dlen = *datalen; - if ((ftdm_size_t)write(ftdmchan->fds[FTDM_READ_TRACE_INDEX], data, (int)dlen) != dlen) { - ftdm_log(FTDM_LOG_WARNING, "Raw input trace failed to write all of the %"FTDM_SIZE_FMT" bytes\n", dlen); - } - } - - if (status == FTDM_SUCCESS && ftdmchan->span->sig_read) { - ftdmchan->span->sig_read(ftdmchan, data, *datalen); - } - - if (status == FTDM_SUCCESS) { - ftdm_size_t dlen = *datalen; - ftdm_size_t rc = 0; - - write_chan_io_dump(&ftdmchan->rxdump, data, (int)dlen); - - /* if dtmf debug is enabled and initialized, write there too */ - if (ftdmchan->dtmfdbg.file) { - rc = fwrite(data, 1, dlen, ftdmchan->dtmfdbg.file); - if (rc != dlen) { - ftdm_log(FTDM_LOG_WARNING, "DTMF debugger wrote only %"FTDM_SIZE_FMT" out of %"FTDM_SIZE_FMT" bytes: %s\n", - rc, *datalen, strerror(errno)); - } - ftdmchan->dtmfdbg.closetimeout--; - if (!ftdmchan->dtmfdbg.closetimeout) { - close_dtmf_debug_file(ftdmchan); - } - } - } - return status; -} - -/* This function takes care of automatically generating DTMF or FSK tones when needed */ -static ftdm_status_t handle_tone_generation(ftdm_channel_t *ftdmchan) -{ - /* - * datalen: size in bytes of the chunk of data the user requested to read (this function - * is called from the ftdm_channel_read function) - * dblen: size currently in use in any of the tone generation buffers (data available in the buffer) - * gen_dtmf_buffer: buffer holding the raw ASCII digits that the user requested to generate - * dtmf_buffer: raw linear tone data generated by teletone to be written to the devices - * fsk_buffer: raw linear FSK modulated data for caller id - */ - ftdm_buffer_t *buffer = NULL; - ftdm_size_t dblen = 0; - int wrote = 0; - - if (ftdmchan->gen_dtmf_buffer && (dblen = ftdm_buffer_inuse(ftdmchan->gen_dtmf_buffer))) { - char digits[128] = ""; - char *cur; - int x = 0; - - if (dblen > sizeof(digits) - 1) { - dblen = sizeof(digits) - 1; - } - - if (ftdm_buffer_read(ftdmchan->gen_dtmf_buffer, digits, dblen) && !ftdm_strlen_zero_buf(digits)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Generating DTMF [%s]\n", digits); - - cur = digits; - - for (; *cur; cur++) { - if (*cur == 'F') { - ftdm_channel_command(ftdmchan, FTDM_COMMAND_FLASH, NULL); - } else if (*cur == 'w') { - ftdm_insert_dtmf_pause(ftdmchan, FTDM_HALF_DTMF_PAUSE); - } else if (*cur == 'W') { - ftdm_insert_dtmf_pause(ftdmchan, FTDM_FULL_DTMF_PAUSE); - } else { - if ((wrote = teletone_mux_tones(&ftdmchan->tone_session, &ftdmchan->tone_session.TONES[(int)*cur]))) { - ftdm_buffer_write(ftdmchan->dtmf_buffer, ftdmchan->tone_session.buffer, wrote * 2); - x++; - } else { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Problem adding DTMF sequence [%s]\n", digits); - return FTDM_FAIL; - } - } - if (x) { - ftdmchan->skip_read_frames = (wrote / (ftdmchan->effective_interval * 8)) + 4; - } - } - } - } - - if (!ftdmchan->buffer_delay || --ftdmchan->buffer_delay == 0) { - /* time to pick a buffer, either the dtmf or fsk buffer */ - if (ftdmchan->dtmf_buffer && (dblen = ftdm_buffer_inuse(ftdmchan->dtmf_buffer))) { - buffer = ftdmchan->dtmf_buffer; - } else if (ftdmchan->fsk_buffer && (dblen = ftdm_buffer_inuse(ftdmchan->fsk_buffer))) { - buffer = ftdmchan->fsk_buffer; - } - } - - /* if we picked a buffer, time to read from it and write the linear data to the device */ - if (buffer) { - uint8_t auxbuf[1024]; - ftdm_size_t dlen = ftdmchan->packet_len; - ftdm_size_t len, br, max = sizeof(auxbuf); - - /* if the codec is not linear, then data is really twice as much cuz - tone generation is done in linear (we assume anything different than linear is G.711) */ - if (ftdmchan->native_codec != FTDM_CODEC_SLIN) { - dlen *= 2; - } - - /* we do not expect the user chunks to be bigger than auxbuf */ - ftdm_assert((dlen <= sizeof(auxbuf)), "Unexpected size for user data chunk size\n"); - - /* dblen is the size in use for dtmf_buffer or fsk_buffer, and dlen is the size - * of the io chunks to write, we pick the smaller one */ - len = dblen > dlen ? dlen : dblen; - - /* we can't read more than the size of our auxiliary buffer */ - ftdm_assert((len <= sizeof(auxbuf)), "Unexpected size to read into auxbuf\n"); - - br = ftdm_buffer_read(buffer, auxbuf, len); - - /* the amount read can't possibly be bigger than what we requested */ - ftdm_assert((br <= len), "Unexpected size read from tone generation buffer\n"); - - /* if we read less than the chunk size, we must fill in with silence the rest */ - if (br < dlen) { - memset(auxbuf + br, 0, dlen - br); - } - - /* finally we convert to the native format for the channel if necessary */ - if (ftdmchan->native_codec != FTDM_CODEC_SLIN) { - if (ftdmchan->native_codec == FTDM_CODEC_ULAW) { - fio_slin2ulaw(auxbuf, max, &dlen); - } else if (ftdmchan->native_codec == FTDM_CODEC_ALAW) { - fio_slin2alaw(auxbuf, max, &dlen); - } - } - - /* write the tone to the channel */ - return ftdm_raw_write(ftdmchan, auxbuf, &dlen); - } - - return FTDM_SUCCESS; - -} - - -FT_DECLARE(void) ftdm_generate_sln_silence(int16_t *data, uint32_t samples, uint32_t divisor) -{ - int16_t x; - uint32_t i; - int sum_rnd = 0; - int16_t rnd2 = (int16_t) ftdm_current_time_in_ms() * (int16_t) (intptr_t) data; - - assert(divisor); - - for (i = 0; i < samples; i++, sum_rnd = 0) { - for (x = 0; x < 6; x++) { - rnd2 = rnd2 * 31821U + 13849U; - sum_rnd += rnd2 ; - } - //switch_normalize_to_16bit(sum_rnd); - *data = (int16_t) ((int16_t) sum_rnd / (int) divisor); - - data++; - } -} - -FT_DECLARE(ftdm_status_t) ftdm_channel_process_media(ftdm_channel_t *ftdmchan, void *data, ftdm_size_t *datalen) -{ - fio_codec_t codec_func = NULL; - ftdm_size_t max = *datalen; - - handle_tone_generation(ftdmchan); - - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_DIGITAL_MEDIA)) { - goto done; - } - - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_TRANSCODE) && ftdmchan->effective_codec != ftdmchan->native_codec) { - if (ftdmchan->native_codec == FTDM_CODEC_ULAW && ftdmchan->effective_codec == FTDM_CODEC_SLIN) { - codec_func = fio_ulaw2slin; - } else if (ftdmchan->native_codec == FTDM_CODEC_ULAW && ftdmchan->effective_codec == FTDM_CODEC_ALAW) { - codec_func = fio_ulaw2alaw; - } else if (ftdmchan->native_codec == FTDM_CODEC_ALAW && ftdmchan->effective_codec == FTDM_CODEC_SLIN) { - codec_func = fio_alaw2slin; - } else if (ftdmchan->native_codec == FTDM_CODEC_ALAW && ftdmchan->effective_codec == FTDM_CODEC_ULAW) { - codec_func = fio_alaw2ulaw; - } - - if (codec_func) { - codec_func(data, max, datalen); - } else { - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "codec error!"); - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "no codec function to perform transcoding from %d to %d\n", ftdmchan->native_codec, ftdmchan->effective_codec); - } - } - - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_DTMF_DETECT) || - ftdm_test_flag(ftdmchan, FTDM_CHANNEL_PROGRESS_DETECT) || - ftdm_test_flag(ftdmchan, FTDM_CHANNEL_CALLERID_DETECT)) { - - uint8_t sln_buf[1024] = {0}; - int16_t *sln; - ftdm_size_t slen = 0; - - if (ftdmchan->effective_codec == FTDM_CODEC_SLIN) { - sln = data; - slen = *datalen / 2; - } else { - ftdm_size_t len = *datalen; - uint32_t i; - uint8_t *lp = data; - - slen = sizeof(sln_buf) / 2; - if (len > slen) { - len = slen; - } - - sln = (int16_t *) sln_buf; - for(i = 0; i < len; i++) { - if (ftdmchan->effective_codec == FTDM_CODEC_ULAW) { - *sln++ = ulaw_to_linear(*lp++); - } else if (ftdmchan->effective_codec == FTDM_CODEC_ALAW) { - *sln++ = alaw_to_linear(*lp++); - } else { - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "codec error!"); - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "invalid effective codec %d\n", ftdmchan->effective_codec); - goto done; - } - } - sln = (int16_t *) sln_buf; - slen = len; - } - - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_CALLERID_DETECT)) { - if (ftdm_fsk_demod_feed(&ftdmchan->fsk, sln, slen) != FTDM_SUCCESS) { - ftdm_size_t type, mlen; - char str[128], *sp; - - while(ftdm_fsk_data_parse(&ftdmchan->fsk, &type, &sp, &mlen) == FTDM_SUCCESS) { - *(str+mlen) = '\0'; - ftdm_copy_string(str, sp, ++mlen); - ftdm_clean_string(str); - - ftdm_log(FTDM_LOG_DEBUG, "FSK: TYPE %s LEN %"FTDM_SIZE_FMT" VAL [%s]\n", - ftdm_mdmf_type2str(type), mlen-1, str); - - switch(type) { - case MDMF_DDN: - case MDMF_PHONE_NUM: - { - if (mlen > sizeof(ftdmchan->caller_data.ani)) { - mlen = sizeof(ftdmchan->caller_data.ani); - } - ftdm_set_string(ftdmchan->caller_data.ani.digits, str); - ftdm_set_string(ftdmchan->caller_data.cid_num.digits, ftdmchan->caller_data.ani.digits); - } - break; - case MDMF_NO_NUM: - { - ftdm_set_string(ftdmchan->caller_data.ani.digits, *str == 'P' ? "private" : "unknown"); - ftdm_set_string(ftdmchan->caller_data.cid_name, ftdmchan->caller_data.ani.digits); - } - break; - case MDMF_PHONE_NAME: - { - if (mlen > sizeof(ftdmchan->caller_data.cid_name)) { - mlen = sizeof(ftdmchan->caller_data.cid_name); - } - ftdm_set_string(ftdmchan->caller_data.cid_name, str); - } - break; - case MDMF_NO_NAME: - { - ftdm_set_string(ftdmchan->caller_data.cid_name, *str == 'P' ? "private" : "unknown"); - } - case MDMF_DATETIME: - { - if (mlen > sizeof(ftdmchan->caller_data.cid_date)) { - mlen = sizeof(ftdmchan->caller_data.cid_date); - } - ftdm_set_string(ftdmchan->caller_data.cid_date, str); - } - break; - } - } - ftdm_channel_command(ftdmchan, FTDM_COMMAND_DISABLE_CALLERID_DETECT, NULL); - } - } - - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_PROGRESS_DETECT) && !ftdm_channel_test_feature(ftdmchan, FTDM_CHANNEL_FEATURE_PROGRESS)) { - uint32_t i; - - for (i = 1; i < FTDM_TONEMAP_INVALID; i++) { - if (ftdmchan->span->tone_finder[i].tone_count) { - if (ftdmchan->needed_tones[i] && teletone_multi_tone_detect(&ftdmchan->span->tone_finder[i], sln, (int)slen)) { - if (++ftdmchan->detected_tones[i]) { - ftdmchan->needed_tones[i] = 0; - ftdmchan->detected_tones[0]++; - } - } - } - } - } - - if (FTDM_CHANNEL_SW_DTMF_ALLOWED(ftdmchan) && ftdm_test_flag(ftdmchan, FTDM_CHANNEL_DTMF_DETECT)) { - teletone_hit_type_t hit; - char digit_char; - uint32_t dur; - - if ((hit = teletone_dtmf_detect(&ftdmchan->dtmf_detect, sln, (int)slen)) == TT_HIT_END) { - teletone_dtmf_get(&ftdmchan->dtmf_detect, &digit_char, &dur); - - if (ftdmchan->state == FTDM_CHANNEL_STATE_CALLWAITING && (digit_char == 'D' || digit_char == 'A')) { - ftdmchan->detected_tones[FTDM_TONEMAP_CALLWAITING_ACK]++; - } else { - char digit_str[2] = { 0 }; - - digit_str[0] = digit_char; - - ftdm_channel_queue_dtmf(ftdmchan, digit_str); - - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_SUPRESS_DTMF)) { - ftdmchan->skip_read_frames = 20; - } - } - } - } - } - - if (ftdmchan->skip_read_frames > 0 || ftdm_test_flag(ftdmchan, FTDM_CHANNEL_MUTE)) { - - ftdm_mutex_lock(ftdmchan->pre_buffer_mutex); - if (ftdmchan->pre_buffer && ftdm_buffer_inuse(ftdmchan->pre_buffer)) { - ftdm_buffer_zero(ftdmchan->pre_buffer); - } - ftdm_mutex_unlock(ftdmchan->pre_buffer_mutex); - - memset(data, FTDM_SILENCE_VALUE(ftdmchan), *datalen); - - if (ftdmchan->skip_read_frames > 0) { - ftdmchan->skip_read_frames--; - } - } else { - ftdm_mutex_lock(ftdmchan->pre_buffer_mutex); - if (ftdmchan->pre_buffer_size && ftdmchan->pre_buffer) { - ftdm_buffer_write(ftdmchan->pre_buffer, data, *datalen); - if (ftdm_buffer_inuse(ftdmchan->pre_buffer) >= ftdmchan->pre_buffer_size) { - ftdm_buffer_read(ftdmchan->pre_buffer, data, *datalen); - } else { - memset(data, FTDM_SILENCE_VALUE(ftdmchan), *datalen); - } - } - ftdm_mutex_unlock(ftdmchan->pre_buffer_mutex); - } - -done: - return FTDM_SUCCESS; -} - - -FT_DECLARE(ftdm_status_t) ftdm_channel_read(ftdm_channel_t *ftdmchan, void *data, ftdm_size_t *datalen) -{ - - ftdm_status_t status = FTDM_FAIL; - - ftdm_assert_return(ftdmchan != NULL, FTDM_FAIL, "ftdmchan is null\n"); - ftdm_assert_return(ftdmchan->fio != NULL, FTDM_FAIL, "No I/O module attached to ftdmchan\n"); - - ftdm_channel_lock(ftdmchan); - - if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OPEN)) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "cannot read from channel that is not open\n"); - status = FTDM_FAIL; - goto done; - } - - if (!ftdmchan->fio->read) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "read method not implemented\n"); - status = FTDM_FAIL; - goto done; - } - - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_RX_DISABLED)) { - ftdmchan->rxdrops++; - if (ftdmchan->rxdrops <= 10) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "cannot read from channel with rx disabled\n"); - } - if (ftdmchan->rxdrops == 10) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "too many rx drops, not logging anymore\n"); - } - status = FTDM_FAIL; - goto done; - } - status = ftdm_raw_read(ftdmchan, data, datalen); - if (status != FTDM_SUCCESS) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "raw I/O read filed\n"); - goto done; - } - - status = ftdm_channel_process_media(ftdmchan, data, datalen); - if (status != FTDM_SUCCESS) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "Failed to process media\n"); - } -done: - ftdm_channel_unlock(ftdmchan); - return status; -} - - -FT_DECLARE(ftdm_status_t) ftdm_channel_write(ftdm_channel_t *ftdmchan, void *data, ftdm_size_t datasize, ftdm_size_t *datalen) -{ - ftdm_status_t status = FTDM_SUCCESS; - fio_codec_t codec_func = NULL; - ftdm_size_t max = datasize; - unsigned int i = 0; - - ftdm_assert_return(ftdmchan != NULL, FTDM_FAIL, "null channel on write!\n"); - ftdm_assert_return(ftdmchan->fio != NULL, FTDM_FAIL, "null I/O on write!\n"); - - ftdm_channel_lock(ftdmchan); - - if (!ftdmchan->buffer_delay && - ((ftdmchan->dtmf_buffer && ftdm_buffer_inuse(ftdmchan->dtmf_buffer)) || - (ftdmchan->fsk_buffer && ftdm_buffer_inuse(ftdmchan->fsk_buffer)))) { - /* generating some kind of tone at the moment (see handle_tone_generation), - * we ignore user data ... */ - goto done; - } - - - if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OPEN)) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "cannot write in channel not open\n"); - status = FTDM_FAIL; - goto done; - } - - if (!ftdmchan->fio->write) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "write method not implemented\n"); - status = FTDM_FAIL; - goto done; - } - - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_DIGITAL_MEDIA)) { - goto do_write; - } - - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_TRANSCODE) && ftdmchan->effective_codec != ftdmchan->native_codec) { - if (ftdmchan->native_codec == FTDM_CODEC_ULAW && ftdmchan->effective_codec == FTDM_CODEC_SLIN) { - codec_func = fio_slin2ulaw; - } else if (ftdmchan->native_codec == FTDM_CODEC_ULAW && ftdmchan->effective_codec == FTDM_CODEC_ALAW) { - codec_func = fio_alaw2ulaw; - } else if (ftdmchan->native_codec == FTDM_CODEC_ALAW && ftdmchan->effective_codec == FTDM_CODEC_SLIN) { - codec_func = fio_slin2alaw; - } else if (ftdmchan->native_codec == FTDM_CODEC_ALAW && ftdmchan->effective_codec == FTDM_CODEC_ULAW) { - codec_func = fio_ulaw2alaw; - } - - if (codec_func) { - status = codec_func(data, max, datalen); - } else { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Do not know how to handle transcoding from %d to %d\n", - ftdmchan->effective_codec, ftdmchan->native_codec); - status = FTDM_FAIL; - goto done; - } - } - - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_USE_TX_GAIN) - && (ftdmchan->native_codec == FTDM_CODEC_ALAW || ftdmchan->native_codec == FTDM_CODEC_ULAW)) { - unsigned char *wdata = data; - for (i = 0; i < *datalen; i++) { - wdata[i] = ftdmchan->txgain_table[wdata[i]]; - } - } - -do_write: - - if (ftdmchan->span->sig_write) { - status = ftdmchan->span->sig_write(ftdmchan, data, *datalen); - if (status == FTDM_BREAK) { - /* signaling module decided to drop user frame */ - status = FTDM_SUCCESS; - goto done; - } - } - - status = ftdm_raw_write(ftdmchan, data, datalen); - -done: - ftdm_channel_unlock(ftdmchan); - - return status; -} - -FT_DECLARE(ftdm_iterator_t *) ftdm_get_iterator(ftdm_iterator_type_t type, ftdm_iterator_t *iter) -{ - int allocated = 0; - if (iter) { - if (iter->type != type) { - ftdm_log(FTDM_LOG_ERROR, "Cannot switch iterator types\n"); - return NULL; - } - allocated = iter->allocated; - memset(iter, 0, sizeof(*iter)); - iter->type = type; - iter->allocated = allocated; - return iter; - } - - iter = ftdm_calloc(1, sizeof(*iter)); - if (!iter) { - return NULL; - } - iter->type = type; - iter->allocated = 1; - return iter; -} - -FT_DECLARE(ftdm_iterator_t *) ftdm_get_span_iterator(ftdm_iterator_t *iter) -{ - if (!(iter = ftdm_get_iterator(FTDM_ITERATOR_SPANS, iter))) { - return NULL; - } - - iter->pvt.hashiter = hashtable_first(globals.span_hash); - return iter; -} - -FT_DECLARE(ftdm_iterator_t *) ftdm_span_get_chan_iterator(const ftdm_span_t *span, ftdm_iterator_t *iter) -{ - if (!span->chan_count) { - return NULL; - } - if (!(iter = ftdm_get_iterator(FTDM_ITERATOR_CHANS, iter))) { - return NULL; - } - iter->pvt.chaniter.index = 1; - iter->pvt.chaniter.span = span; - return iter; -} - -FT_DECLARE(ftdm_iterator_t *) ftdm_iterator_next(ftdm_iterator_t *iter) -{ - ftdm_assert_return(iter && iter->type, NULL, "Invalid iterator\n"); - - switch (iter->type) { - case FTDM_ITERATOR_VARS: - case FTDM_ITERATOR_SPANS: - if (!iter->pvt.hashiter) { - return NULL; - } - iter->pvt.hashiter = hashtable_next(iter->pvt.hashiter); - if (!iter->pvt.hashiter) { - return NULL; - } - return iter; - case FTDM_ITERATOR_CHANS: - ftdm_assert_return(iter->pvt.chaniter.index, NULL, "channel iterator index cannot be zero!\n"); - if (iter->pvt.chaniter.index == iter->pvt.chaniter.span->chan_count) { - return NULL; - } - iter->pvt.chaniter.index++; - return iter; - default: - break; - } - - ftdm_assert_return(0, NULL, "Unknown iterator type\n"); - return NULL; -} - -FT_DECLARE(void *) ftdm_iterator_current(ftdm_iterator_t *iter) -{ - const void *key = NULL; - void *val = NULL; - - ftdm_assert_return(iter && iter->type, NULL, "Invalid iterator\n"); - - switch (iter->type) { - case FTDM_ITERATOR_VARS: - hashtable_this(iter->pvt.hashiter, &key, NULL, &val); - /* I decided to return the key instead of the value since the value can be retrieved using the key */ - return (void *)key; - case FTDM_ITERATOR_SPANS: - hashtable_this(iter->pvt.hashiter, &key, NULL, &val); - return (void *)val; - case FTDM_ITERATOR_CHANS: - ftdm_assert_return(iter->pvt.chaniter.index, NULL, "channel iterator index cannot be zero!\n"); - ftdm_assert_return(iter->pvt.chaniter.index <= iter->pvt.chaniter.span->chan_count, NULL, "channel iterator index bigger than span chan count!\n"); - return iter->pvt.chaniter.span->channels[iter->pvt.chaniter.index]; - default: - break; - } - - ftdm_assert_return(0, NULL, "Unknown iterator type\n"); - return NULL; -} - -FT_DECLARE(ftdm_status_t) ftdm_iterator_free(ftdm_iterator_t *iter) -{ - /* it's valid to pass a NULL iterator, do not return failure */ - if (!iter) { - return FTDM_SUCCESS; - } - - if (!iter->allocated) { - memset(iter, 0, sizeof(*iter)); - return FTDM_SUCCESS; - } - - ftdm_assert_return(iter->type, FTDM_FAIL, "Cannot free invalid iterator\n"); - ftdm_safe_free(iter); - - return FTDM_SUCCESS; -} - - -static const char *print_neg_char[] = { "", "!" }; -static const char *print_flag_state[] = { "OFF", "ON" }; - -static void print_channels_by_flag(ftdm_stream_handle_t *stream, ftdm_span_t *inspan, uint32_t inchan_id, uint64_t flagval, int not, int *count) -{ - ftdm_bool_t neg = !!not; - const char *negind = print_neg_char[neg]; - const char *flagname; - uint64_t flag = ((uint64_t)1 << flagval); - int mycount = 0; - - flagname = ftdm_val2str(flag, channel_flag_strs, ftdm_array_len(channel_flag_strs), "invalid"); - - ftdm_mutex_lock(globals.mutex); - - if (inspan) { - ftdm_iterator_t *c_iter, *c_cur; - - c_iter = ftdm_span_get_chan_iterator(inspan, NULL); - - for (c_cur = c_iter; c_cur; c_cur = ftdm_iterator_next(c_cur)) { - ftdm_channel_t *fchan; - ftdm_bool_t cond; - - fchan = ftdm_iterator_current(c_cur); - if (inchan_id && inchan_id != fchan->chan_id) { - continue; - } - - cond = !!ftdm_test_flag(fchan, flag); - if (neg ^ cond) { - mycount++; - } - - stream->write_function(stream, "[s%dc%d][%d:%d] flag %s%"FTDM_UINT64_FMT"(%s%s) %s\n", - fchan->span_id, fchan->chan_id, - fchan->physical_span_id, fchan->physical_chan_id, - negind, flagval, negind, flagname, - print_flag_state[cond]); - } - - ftdm_iterator_free(c_iter); - - } else { - ftdm_iterator_t *s_iter, *s_cur; - - s_iter = ftdm_get_span_iterator(NULL); - - for (s_cur = s_iter; s_cur; s_cur = ftdm_iterator_next(s_cur)) { - ftdm_iterator_t *c_iter, *c_cur; - ftdm_span_t *span; - - span = ftdm_iterator_current(s_cur); - if (!span) { - break; - } - - c_iter = ftdm_span_get_chan_iterator(span, NULL); - - for (c_cur = c_iter; c_cur; c_cur = ftdm_iterator_next(c_cur)) { - ftdm_channel_t *fchan; - - fchan = ftdm_iterator_current(c_cur); - - if (neg ^ !!ftdm_test_flag(fchan, flag)) { - stream->write_function(stream, "[s%dc%d][%d:%d] flag %s%"FTDM_UINT64_FMT"(%s%s)\n", - fchan->span_id, fchan->chan_id, - fchan->physical_span_id, fchan->physical_chan_id, - negind, flagval, negind, flagname); - mycount++; - } - } - - ftdm_iterator_free(c_iter); - } - - ftdm_iterator_free(s_iter); - } - - *count = mycount; - ftdm_mutex_unlock(globals.mutex); -} - -static void print_spans_by_flag(ftdm_stream_handle_t *stream, ftdm_span_t *inspan, uint64_t flagval, int not, int *count) -{ - ftdm_bool_t neg = !!not; - const char *negind = print_neg_char[neg]; - const char *flagname; - uint64_t flag = ((uint64_t)1 << flagval); - int mycount = 0; - - flagname = ftdm_val2str(flag, span_flag_strs, ftdm_array_len(span_flag_strs), "invalid"); - - ftdm_mutex_lock(globals.mutex); - - if (inspan) { - ftdm_bool_t cond; - - cond = !!ftdm_test_flag(inspan, flag); - if (neg ^ cond) { - mycount++; - } - - stream->write_function(stream, "[s%d] flag %s%"FTDM_UINT64_FMT"(%s%s) %s\n", - inspan->span_id, negind, flagval, negind, flagname, - print_flag_state[cond]); - } else { - ftdm_iterator_t *s_iter, *s_cur; - - s_iter = ftdm_get_span_iterator(NULL); - - for (s_cur = s_iter; s_cur; s_cur = ftdm_iterator_next(s_cur)) { - ftdm_span_t *span; - - span = ftdm_iterator_current(s_cur); - if (!span) { - break; - } - - if (neg ^ !!ftdm_test_flag(span, flag)) { - stream->write_function(stream, "[s%d] flag %s%"FTDM_UINT64_FMT"(%s%s)\n", - span->span_id, negind, flagval, negind, flagname); - mycount++; - } - } - - ftdm_iterator_free(s_iter); - } - - *count = mycount; - ftdm_mutex_unlock(globals.mutex); -} - -static void print_channels_by_state(ftdm_stream_handle_t *stream, ftdm_channel_state_t state, int not, int *count) -{ - ftdm_iterator_t *s_iter, *s_cur; - ftdm_bool_t neg = !!not; - int mycount = 0; - - s_iter = ftdm_get_span_iterator(NULL); - - ftdm_mutex_lock(globals.mutex); - - for (s_cur = s_iter; s_cur; s_cur = ftdm_iterator_next(s_cur)) { - ftdm_iterator_t *c_iter, *c_cur; - ftdm_span_t *span; - - span = ftdm_iterator_current(s_cur); - if (!span) { - break; - } - - c_iter = ftdm_span_get_chan_iterator(span, NULL); - - for (c_cur = c_iter ; c_cur; c_cur = ftdm_iterator_next(c_cur)) { - ftdm_channel_t *fchan = ftdm_iterator_current(c_cur); - - if (neg ^ (fchan->state == state)) { - stream->write_function(stream, "[s%dc%d][%d:%d] in state %s\n", - fchan->span_id, fchan->chan_id, - fchan->physical_span_id, fchan->physical_chan_id, ftdm_channel_state2str(fchan->state)); - mycount++; - } - } - - ftdm_iterator_free(c_iter); - } - - *count = mycount; - ftdm_mutex_unlock(globals.mutex); - - ftdm_iterator_free(s_iter); -} - -static void print_core_usage(ftdm_stream_handle_t *stream) -{ - stream->write_function(stream, - "--------------------------------------------------------------------------------\n" - "ftdm core state [!] - List all channels in or not in the given state\n" - "ftdm core flag [!] [] [] - List all channels with the given flag value set\n" - "ftdm core spanflag [!] [] - List all spans with the given span flag value set\n" - "ftdm core calls - List all known calls to the FreeTDM core\n" - "--------------------------------------------------------------------------------\n"); -} - - -static unsigned long long ftdm_str2val(const char *str, val_str_t *val_str_table, ftdm_size_t array_size, unsigned long long default_val) -{ - ftdm_size_t i; - for (i = 0; i < array_size; i++) { - if (!strcasecmp(val_str_table[i].str, str)) { - return val_str_table[i].val; - } - } - return default_val; -} - -static const char *ftdm_val2str(unsigned long long val, val_str_t *val_str_table, ftdm_size_t array_size, const char *default_str) -{ - ftdm_size_t i; - for (i = 0; i < array_size; i++) { - if (val_str_table[i].val == val) { - return val_str_table[i].str; - } - } - return default_str; -} - -static void print_channel_flag_values(ftdm_stream_handle_t *stream) -{ - int i; - for (i = 0; i < ftdm_array_len(channel_flag_strs); i++) { - stream->write_function(stream, "%s\n", channel_flag_strs[i].str); - } -} - -static void print_span_flag_values(ftdm_stream_handle_t *stream) -{ - int i; - for (i = 0; i < ftdm_array_len(span_flag_strs); i++) { - stream->write_function(stream, "%s\n", span_flag_strs[i].str); - } -} - -/** - * Compute log2 of 64bit integer v - * - * Bit Twiddling Hacks - * http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog - */ -static int ftdm_log2_64(uint64_t v) -{ - unsigned int shift; - uint64_t r; - - r = (v > 0xFFFFFFFF) << 5; v >>= r; - shift = (v > 0xFFFF ) << 4; v >>= shift; r |= shift; - shift = (v > 0xFF ) << 3; v >>= shift; r |= shift; - shift = (v > 0xF ) << 2; v >>= shift; r |= shift; - shift = (v > 0x3 ) << 1; v >>= shift; r |= shift; - - return ((int)(r | (v >> 1))); -} - -static char *handle_core_command(const char *cmd) -{ - char *mycmd = NULL; - int argc = 0; - int count = 0; - int not = 0; - char *argv[10] = { 0 }; - char *flag = NULL; - uint64_t flagval = 0; - ftdm_channel_t *fchan = NULL; - ftdm_span_t *fspan = NULL; - ftdm_stream_handle_t stream = { 0 }; - - FTDM_STANDARD_STREAM(stream); - - if (!ftdm_strlen_zero(cmd)) { - mycmd = ftdm_strdup(cmd); - argc = ftdm_separate_string(mycmd, ' ', argv, ftdm_array_len(argv)); - } else { - print_core_usage(&stream); - goto done; - } - - if (!argc) { - print_core_usage(&stream); - goto done; - } - - if (!strcasecmp(argv[0], "state")) { - ftdm_channel_state_t st = FTDM_CHANNEL_STATE_INVALID; - char *state = NULL; - - if (argc < 2) { - stream.write_function(&stream, "core state command requires an argument\n"); - print_core_usage(&stream); - goto done; - } - - state = argv[1]; - if (state[0] == '!') { - not = 1; - state++; - } - - for (st = FTDM_CHANNEL_STATE_DOWN; st < FTDM_CHANNEL_STATE_INVALID; st++) { - if (!strcasecmp(state, ftdm_channel_state2str(st))) { - break; - } - } - if (st == FTDM_CHANNEL_STATE_INVALID) { - stream.write_function(&stream, "invalid state %s\n", state); - goto done; - } - print_channels_by_state(&stream, st, not, &count); - stream.write_function(&stream, "\nTotal channels %s state %s: %d\n", - not ? "not in" : "in", ftdm_channel_state2str(st), count); - } else if (!strcasecmp(argv[0], "flag")) { - uint32_t chan_id = 0; - - if (argc < 2) { - stream.write_function(&stream, "core flag command requires an argument\n"); - print_core_usage(&stream); - goto done; - } - - flag = argv[1]; - if (flag[0] == '!') { - not = 1; - flag++; - } - - if (isalpha(flag[0])) { - flagval = ftdm_str2val(flag, channel_flag_strs, ftdm_array_len(channel_flag_strs), FTDM_CHANNEL_MAX_FLAG); - if (flagval == FTDM_CHANNEL_MAX_FLAG) { - stream.write_function(&stream, "\nInvalid channel flag value. Possible channel flags:\n"); - print_channel_flag_values(&stream); - goto done; - } - flagval = ftdm_log2_64(flagval); - } else { - flagval = atoi(flag); - } - - /* Specific span specified */ - if (argv[2]) { - ftdm_span_find_by_name(argv[2], &fspan); - if (!fspan) { - stream.write_function(&stream, "-ERR span:%s not found\n", argv[2]); - goto done; - } - } - - /* Specific channel specified */ - if (argv[3]) { - chan_id = atoi(argv[3]); - if (chan_id == 0 || chan_id >= ftdm_span_get_chan_count(fspan)) { - stream.write_function(&stream, "-ERR invalid channel %u\n", chan_id); - goto done; - } - } - - print_channels_by_flag(&stream, fspan, chan_id, flagval, not, &count); - stream.write_function(&stream, "\nTotal channels %s flag %"FTDM_UINT64_FMT": %d\n", not ? "without" : "with", flagval, count); - } else if (!strcasecmp(argv[0], "spanflag")) { - if (argc < 2) { - stream.write_function(&stream, "core spanflag command requires an argument\n"); - print_core_usage(&stream); - goto done; - } - - flag = argv[1]; - if (flag[0] == '!') { - not = 1; - flag++; - } - - if (isalpha(flag[0])) { - flagval = ftdm_str2val(flag, span_flag_strs, ftdm_array_len(span_flag_strs), FTDM_SPAN_MAX_FLAG); - if (flagval == FTDM_SPAN_MAX_FLAG) { - stream.write_function(&stream, "\nInvalid span flag value. Possible span flags\n"); - print_span_flag_values(&stream); - goto done; - } - flagval = ftdm_log2_64(flagval); - } else { - flagval = atoi(flag); - } - - /* Specific span specified */ - if (argv[2]) { - ftdm_span_find_by_name(argv[2], &fspan); - if (!fspan) { - stream.write_function(&stream, "-ERR span:%s not found\n", argv[2]); - goto done; - } - } - - print_spans_by_flag(&stream, fspan, flagval, not, &count); - if (!fspan) { - stream.write_function(&stream, "\nTotal spans %s flag %"FTDM_UINT64_FMT": %d\n", not ? "without" : "with", flagval, count); - } - } else if (!strcasecmp(argv[0], "calls")) { - uint32_t current_call_id = 0; - - ftdm_mutex_lock(globals.call_id_mutex); - for (current_call_id = 0; current_call_id <= MAX_CALLIDS; current_call_id++) { - ftdm_caller_data_t *calldata = NULL; - - if (!globals.call_ids[current_call_id]) { - continue; - } - - calldata = globals.call_ids[current_call_id]; - fchan = calldata->fchan; - if (fchan) { - stream.write_function(&stream, "Call %u on channel %d:%d\n", current_call_id, - fchan->span_id, fchan->chan_id); - } else { - stream.write_function(&stream, "Call %u without a channel?\n", current_call_id); - } - count++; - } - ftdm_mutex_unlock(globals.call_id_mutex); - stream.write_function(&stream, "\nTotal calls: %d\n", count); - } else { - stream.write_function(&stream, "invalid core command %s\n", argv[0]); - print_core_usage(&stream); - } - -done: - ftdm_safe_free(mycmd); - - return stream.data; -} - -FT_DECLARE(char *) ftdm_api_execute(const char *cmd) -{ - ftdm_io_interface_t *fio = NULL; - char *dup = NULL, *p; - char *rval = NULL; - char *type = NULL; - - dup = ftdm_strdup(cmd); - if ((p = strchr(dup, ' '))) { - *p++ = '\0'; - cmd = p; - } else { - cmd = ""; - } - - type = dup; - - if (!strcasecmp(type, "core")) { - return handle_core_command(cmd); - } - - fio = ftdm_global_get_io_interface(type, FTDM_TRUE); - if (fio && fio->api) { - ftdm_stream_handle_t stream = { 0 }; - ftdm_status_t status; - FTDM_STANDARD_STREAM(stream); - - status = fio->api(&stream, cmd); - if (status != FTDM_SUCCESS) { - ftdm_safe_free(stream.data); - } else { - rval = (char *) stream.data; - } - } - - ftdm_safe_free(dup); - - return rval; -} - -static ftdm_status_t ftdm_set_channels_gains(ftdm_span_t *span, int currindex, float rxgain, float txgain) -{ - unsigned chan_index = 0; - - if (!span->chan_count) { - ftdm_log(FTDM_LOG_ERROR, "Failed to set channel gains because span %s has no channels\n", span->name); - return FTDM_FAIL; - } - - for (chan_index = currindex+1; chan_index <= span->chan_count; chan_index++) { - if (!FTDM_IS_VOICE_CHANNEL(span->channels[chan_index])) { - continue; - } - if (ftdm_channel_command(span->channels[chan_index], FTDM_COMMAND_SET_RX_GAIN, &rxgain) != FTDM_SUCCESS) { - return FTDM_FAIL; - } - if (ftdm_channel_command(span->channels[chan_index], FTDM_COMMAND_SET_TX_GAIN, &txgain) != FTDM_SUCCESS) { - return FTDM_FAIL; - } - } - return FTDM_SUCCESS; -} - -static ftdm_status_t ftdm_report_initial_channels_alarms(ftdm_span_t *span) -{ - ftdm_channel_t *fchan = NULL; - ftdm_iterator_t *curr = NULL; - ftdm_status_t status = FTDM_SUCCESS; - ftdm_alarm_flag_t alarmbits; - ftdm_event_t fake_event; - ftdm_iterator_t *citer = ftdm_span_get_chan_iterator(span, NULL); - - if (!citer) { - status = FTDM_ENOMEM; - goto done; - } - - memset(&fake_event, 0, sizeof(fake_event)); - fake_event.e_type = FTDM_EVENT_OOB; - - for (curr = citer; curr; curr = ftdm_iterator_next(curr)) { - fchan = ftdm_iterator_current(curr); - status = ftdm_channel_get_alarms(fchan, &alarmbits); - if (status != FTDM_SUCCESS) { - ftdm_log_chan_msg(fchan, FTDM_LOG_ERROR, "Failed to initialize alarms\n"); - continue; - } - fake_event.channel = fchan; - fake_event.enum_id = fchan->alarm_flags ? FTDM_OOB_ALARM_TRAP : FTDM_OOB_ALARM_CLEAR; - ftdm_event_handle_oob(&fake_event); - } - -done: - - ftdm_iterator_free(citer); - return status; -} - -FT_DECLARE(ftdm_status_t) ftdm_configure_span_channels(ftdm_span_t *span, const char* str, ftdm_channel_config_t *chan_config, unsigned *configured) -{ - int currindex; - unsigned chan_index = 0; - - ftdm_assert_return(span != NULL, FTDM_EINVAL, "span is null\n"); - ftdm_assert_return(chan_config != NULL, FTDM_EINVAL, "config is null\n"); - ftdm_assert_return(configured != NULL, FTDM_EINVAL, "configured pointer is null\n"); - ftdm_assert_return(span->fio != NULL, FTDM_EINVAL, "span with no I/O configured\n"); - ftdm_assert_return(span->fio->configure_span != NULL, FTDM_NOTIMPL, "span I/O with no channel configuration implemented\n"); - - currindex = span->chan_count; - *configured = 0; - *configured = span->fio->configure_span(span, str, chan_config->type, chan_config->name, chan_config->number); - if (!*configured) { - ftdm_log(FTDM_LOG_ERROR, "%d:Failed to configure span\n", span->span_id); - return FTDM_FAIL; - } - - if (chan_config->group_name[0]) { - if (ftdm_group_add_channels(span, currindex, chan_config->group_name) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "%d:Failed to add channels to group %s\n", span->span_id, chan_config->group_name); - return FTDM_FAIL; - } - } - - if (ftdm_set_channels_gains(span, currindex, chan_config->rxgain, chan_config->txgain) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "%d:Failed to set channel gains\n", span->span_id); - return FTDM_FAIL; - } - - for (chan_index = currindex + 1; chan_index <= span->chan_count; chan_index++) { - if (chan_config->iostats) { - ftdm_channel_set_feature(span->channels[chan_index], FTDM_CHANNEL_FEATURE_IO_STATS); - } - - if (!FTDM_IS_VOICE_CHANNEL(span->channels[chan_index])) { - continue; - } - - if (chan_config->debugdtmf) { - span->channels[chan_index]->dtmfdbg.requested = 1; - } - - span->channels[chan_index]->dtmfdetect.duration_ms = chan_config->dtmfdetect_ms; - if (chan_config->dtmf_on_start) { - span->channels[chan_index]->dtmfdetect.trigger_on_start = 1; - } - if (chan_config->dtmf_time_on) { - ftdm_channel_command(span->channels[chan_index], FTDM_COMMAND_SET_DTMF_ON_PERIOD, &chan_config->dtmf_time_on); - } - if (chan_config->dtmf_time_off) { - ftdm_channel_command(span->channels[chan_index], FTDM_COMMAND_SET_DTMF_OFF_PERIOD, &chan_config->dtmf_time_off); - } - } - - return FTDM_SUCCESS; -} - - -static ftdm_status_t load_config(void) -{ - const char cfg_name[] = "freetdm.conf"; - ftdm_config_t cfg; - char *var, *val; - int catno = -1; - int intparam = 0; - ftdm_span_t *span = NULL; - unsigned configured = 0, d = 0; - ftdm_analog_start_type_t tmp; - ftdm_size_t len = 0; - ftdm_channel_config_t chan_config; - ftdm_status_t ret = FTDM_SUCCESS; - - memset(&chan_config, 0, sizeof(chan_config)); - sprintf(chan_config.group_name, "__default"); - - if (!ftdm_config_open_file(&cfg, cfg_name)) { - ftdm_log(FTDM_LOG_ERROR, "Failed to open configuration file %s\n", cfg_name); - return FTDM_FAIL; - } - - ftdm_log(FTDM_LOG_DEBUG, "Reading FreeTDM configuration file\n"); - - while (ftdm_config_next_pair(&cfg, &var, &val)) { - if (*cfg.category == '#') { - if (cfg.catno != catno) { - ftdm_log(FTDM_LOG_DEBUG, "Skipping %s\n", cfg.category); - catno = cfg.catno; - } - } else if (!strncasecmp(cfg.category, "span", 4)) { - if (cfg.catno != catno) { - char *type = cfg.category + 4; - char *name; - - if (*type == ' ') { - type++; - } - - ftdm_log(FTDM_LOG_DEBUG, "found config for span\n"); - catno = cfg.catno; - - if (ftdm_strlen_zero(type)) { - ftdm_log(FTDM_LOG_CRIT, "failure creating span, no type specified.\n"); - span = NULL; - continue; - } - - if ((name = strchr(type, ' '))) { - *name++ = '\0'; - } - - /* Verify if trunk_type was specified for previous span */ - if (span && span->trunk_type == FTDM_TRUNK_NONE) { - ftdm_log(FTDM_LOG_ERROR, "trunk_type not specified for span %d (%s)\n", span->span_id, span->name); - ret = FTDM_FAIL; - goto done; - } - - if (ftdm_span_create(type, name, &span) == FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_DEBUG, "created span %d (%s) of type %s\n", span->span_id, span->name, type); - d = 0; - /* it is confusing that parameters from one span affect others, so let's clear them */ - memset(&chan_config, 0, sizeof(chan_config)); - sprintf(chan_config.group_name, "__default"); - /* default to storing iostats */ - chan_config.iostats = FTDM_TRUE; - } else { - ftdm_log(FTDM_LOG_CRIT, "failure creating span of type %s\n", type); - span = NULL; - continue; - } - } - - if (!span) { - continue; - } - - ftdm_log(FTDM_LOG_DEBUG, "span %d [%s]=[%s]\n", span->span_id, var, val); - - if (!strcasecmp(var, "trunk_type")) { - ftdm_trunk_type_t trtype = ftdm_str2ftdm_trunk_type(val); - ftdm_span_set_trunk_type(span, trtype); - ftdm_log(FTDM_LOG_DEBUG, "setting trunk type to '%s'\n", ftdm_trunk_type2str(trtype)); - } else if (!strcasecmp(var, "trunk_mode")) { - ftdm_trunk_mode_t trmode = ftdm_str2ftdm_trunk_mode(val); - ftdm_span_set_trunk_mode(span, trmode); - ftdm_log(FTDM_LOG_DEBUG, "setting trunk mode to '%s'\n", ftdm_trunk_mode2str(trmode)); - } else if (!strcasecmp(var, "name")) { - if (!strcasecmp(val, "undef")) { - chan_config.name[0] = '\0'; - } else { - ftdm_copy_string(chan_config.name, val, FTDM_MAX_NAME_STR_SZ); - } - } else if (!strcasecmp(var, "number")) { - if (!strcasecmp(val, "undef")) { - chan_config.number[0] = '\0'; - } else { - ftdm_copy_string(chan_config.number, val, FTDM_MAX_NUMBER_STR_SZ); - } - } else if (!strcasecmp(var, "analog-start-type")) { - if (span->trunk_type == FTDM_TRUNK_FXS || span->trunk_type == FTDM_TRUNK_FXO || span->trunk_type == FTDM_TRUNK_EM) { - if ((tmp = ftdm_str2ftdm_analog_start_type(val)) != FTDM_ANALOG_START_NA) { - span->start_type = tmp; - ftdm_log(FTDM_LOG_DEBUG, "changing start type to '%s'\n", ftdm_analog_start_type2str(span->start_type)); - } - } else { - ftdm_log(FTDM_LOG_ERROR, "This option is only valid on analog trunks!\n"); - } - } else if (!strcasecmp(var, "fxo-channel")) { - if (span->trunk_type == FTDM_TRUNK_NONE) { - span->trunk_type = FTDM_TRUNK_FXO; - span->trunk_mode = FTDM_TRUNK_MODE_CPE; - ftdm_log(FTDM_LOG_DEBUG, "setting trunk type to '%s' start(%s), mode(%s)\n", ftdm_trunk_type2str(span->trunk_type), - ftdm_analog_start_type2str(span->start_type), ftdm_trunk_mode2str(span->trunk_mode)); - } - if (span->trunk_type == FTDM_TRUNK_FXO) { - unsigned chans_configured = 0; - chan_config.type = FTDM_CHAN_TYPE_FXO; - if (ftdm_configure_span_channels(span, val, &chan_config, &chans_configured) == FTDM_SUCCESS) { - configured += chans_configured; - } - } else { - ftdm_log(FTDM_LOG_WARNING, "Cannot add FXO channels to a %s trunk!\n", ftdm_trunk_type2str(span->trunk_type)); - } - } else if (!strcasecmp(var, "fxs-channel")) { - if (span->trunk_type == FTDM_TRUNK_NONE) { - span->trunk_type = FTDM_TRUNK_FXS; - span->trunk_mode = FTDM_TRUNK_MODE_NET; - ftdm_log(FTDM_LOG_DEBUG, "setting trunk type to '%s' start(%s), mode(%s)\n", ftdm_trunk_type2str(span->trunk_type), - ftdm_analog_start_type2str(span->start_type), ftdm_trunk_mode2str(span->trunk_mode)); - } - if (span->trunk_type == FTDM_TRUNK_FXS) { - unsigned chans_configured = 0; - chan_config.type = FTDM_CHAN_TYPE_FXS; - if (ftdm_configure_span_channels(span, val, &chan_config, &chans_configured) == FTDM_SUCCESS) { - configured += chans_configured; - } - } else { - ftdm_log(FTDM_LOG_WARNING, "Cannot add FXS channels to a %s trunk!\n", ftdm_trunk_type2str(span->trunk_type)); - } - } else if (!strcasecmp(var, "em-channel")) { - if (span->trunk_type == FTDM_TRUNK_NONE) { - span->trunk_type = FTDM_TRUNK_EM; - span->trunk_mode = FTDM_TRUNK_MODE_CPE; - ftdm_log(FTDM_LOG_DEBUG, "setting trunk type to '%s' start(%s), mode(%s)\n", ftdm_trunk_type2str(span->trunk_type), - ftdm_analog_start_type2str(span->start_type), ftdm_trunk_mode2str(span->trunk_mode)); - } - if (span->trunk_type == FTDM_TRUNK_EM) { - unsigned chans_configured = 0; - chan_config.type = FTDM_CHAN_TYPE_EM; - if (ftdm_configure_span_channels(span, val, &chan_config, &chans_configured) == FTDM_SUCCESS) { - configured += chans_configured; - } - } else { - ftdm_log(FTDM_LOG_WARNING, "Cannot add EM channels to a %s trunk!\n", ftdm_trunk_type2str(span->trunk_type)); - } - } else if (!strcasecmp(var, "b-channel")) { - if (span->trunk_type == FTDM_TRUNK_NONE) { - ftdm_log(FTDM_LOG_ERROR, "No trunk type specified in configuration file\n"); - break; - } - if (FTDM_SPAN_IS_DIGITAL(span)) { - unsigned chans_configured = 0; - chan_config.type = FTDM_CHAN_TYPE_B; - if (ftdm_configure_span_channels(span, val, &chan_config, &chans_configured) == FTDM_SUCCESS) { - configured += chans_configured; - } - } else { - ftdm_log(FTDM_LOG_WARNING, "Cannot add B channels to a %s trunk!\n", ftdm_trunk_type2str(span->trunk_type)); - } - } else if (!strcasecmp(var, "d-channel")) { - if (span->trunk_type == FTDM_TRUNK_NONE) { - ftdm_log(FTDM_LOG_ERROR, "No trunk type specified in configuration file\n"); - break; - } - if (FTDM_SPAN_IS_DIGITAL(span)) { - unsigned chans_configured = 0; - if (d) { - ftdm_log(FTDM_LOG_WARNING, "ignoring extra d-channel\n"); - continue; - } - if (!strncasecmp(val, "lapd:", 5)) { - chan_config.type = FTDM_CHAN_TYPE_DQ931; - val += 5; - } else { - chan_config.type = FTDM_CHAN_TYPE_DQ921; - } - if (ftdm_configure_span_channels(span, val, &chan_config, &chans_configured) == FTDM_SUCCESS) { - configured += chans_configured; - } - d++; - } else { - ftdm_log(FTDM_LOG_WARNING, "Cannot add D channels to a %s trunk!\n", ftdm_trunk_type2str(span->trunk_type)); - } - } else if (!strcasecmp(var, "cas-channel")) { - unsigned chans_configured = 0; - chan_config.type = FTDM_CHAN_TYPE_CAS; - if (ftdm_configure_span_channels(span, val, &chan_config, &chans_configured) == FTDM_SUCCESS) { - configured += chans_configured; - } - } else if (!strcasecmp(var, "dtmf_hangup")) { - span->dtmf_hangup = ftdm_strdup(val); - span->dtmf_hangup_len = strlen(val); - } else if (!strcasecmp(var, "txgain")) { - if (sscanf(val, "%f", &(chan_config.txgain)) != 1) { - ftdm_log(FTDM_LOG_ERROR, "invalid txgain: '%s'\n", val); - } - } else if (!strcasecmp(var, "rxgain")) { - if (sscanf(val, "%f", &(chan_config.rxgain)) != 1) { - ftdm_log(FTDM_LOG_ERROR, "invalid rxgain: '%s'\n", val); - } - } else if (!strcasecmp(var, "debugdtmf")) { - chan_config.debugdtmf = ftdm_true(val); - ftdm_log(FTDM_LOG_DEBUG, "Setting debugdtmf to '%s'\n", chan_config.debugdtmf ? "yes" : "no"); - } else if (!strncasecmp(var, "dtmfdetect_ms", sizeof("dtmfdetect_ms")-1)) { - if (chan_config.dtmf_on_start == FTDM_TRUE) { - chan_config.dtmf_on_start = FTDM_FALSE; - ftdm_log(FTDM_LOG_WARNING, "dtmf_on_start parameter disabled because dtmfdetect_ms specified\n"); - } - if (sscanf(val, "%d", &(chan_config.dtmfdetect_ms)) != 1) { - ftdm_log(FTDM_LOG_ERROR, "invalid dtmfdetect_ms: '%s'\n", val); - } - } else if (!strncasecmp(var, "dtmf_on_start", sizeof("dtmf_on_start")-1)) { - if (chan_config.dtmfdetect_ms) { - ftdm_log(FTDM_LOG_WARNING, "dtmf_on_start parameter ignored because dtmf_detect_ms specified\n"); - } else { - if (ftdm_true(val)) { - chan_config.dtmf_on_start = FTDM_TRUE; - } else { - chan_config.dtmf_on_start = FTDM_FALSE; - } - } - } else if (!strcasecmp(var, "dtmf_time_on")) { - if (sscanf(val, "%u", &(chan_config.dtmf_time_on)) != 1) { - ftdm_log(FTDM_LOG_ERROR, "invalid dtmf_time_on: '%s'\n", val); - } - } else if (!strcasecmp(var, "dtmf_time_off")) { - if (sscanf(val, "%u", &(chan_config.dtmf_time_off)) != 1) { - ftdm_log(FTDM_LOG_ERROR, "invalid dtmf_time_off: '%s'\n", val); - } - } else if (!strncasecmp(var, "iostats", sizeof("iostats")-1)) { - if (ftdm_true(val)) { - chan_config.iostats = FTDM_TRUE; - } else { - chan_config.iostats = FTDM_FALSE; - } - ftdm_log(FTDM_LOG_DEBUG, "Setting iostats to '%s'\n", chan_config.iostats ? "yes" : "no"); - } else if (!strcasecmp(var, "group")) { - len = strlen(val); - if (len >= FTDM_MAX_NAME_STR_SZ) { - len = FTDM_MAX_NAME_STR_SZ - 1; - ftdm_log(FTDM_LOG_WARNING, "Truncating group name %s to %"FTDM_SIZE_FMT" length\n", val, len); - } - memcpy(chan_config.group_name, val, len); - chan_config.group_name[len] = '\0'; - } else { - ftdm_log(FTDM_LOG_ERROR, "unknown span variable '%s'\n", var); - } - } else if (!strncasecmp(cfg.category, "general", 7)) { - if (!strncasecmp(var, "cpu_monitor", sizeof("cpu_monitor")-1)) { - if (!strncasecmp(val, "yes", 3)) { - globals.cpu_monitor.enabled = 1; - if (!globals.cpu_monitor.alarm_action_flags) { - globals.cpu_monitor.alarm_action_flags |= FTDM_CPU_ALARM_ACTION_WARN; - } - } - } else if (!strncasecmp(var, "debugdtmf_directory", sizeof("debugdtmf_directory")-1)) { - ftdm_set_string(globals.dtmfdebug_directory, val); - ftdm_log(FTDM_LOG_DEBUG, "Debug DTMF directory set to '%s'\n", globals.dtmfdebug_directory); - } else if (!strncasecmp(var, "cpu_monitoring_interval", sizeof("cpu_monitoring_interval")-1)) { - if (atoi(val) > 0) { - globals.cpu_monitor.interval = atoi(val); - } else { - ftdm_log(FTDM_LOG_ERROR, "Invalid cpu monitoring interval %s\n", val); - } - } else if (!strncasecmp(var, "cpu_set_alarm_threshold", sizeof("cpu_set_alarm_threshold")-1)) { - intparam = atoi(val); - if (intparam > 0 && intparam < 100) { - globals.cpu_monitor.set_alarm_threshold = (uint8_t)intparam; - } else { - ftdm_log(FTDM_LOG_ERROR, "Invalid cpu alarm set threshold %s\n", val); - } - } else if (!strncasecmp(var, "cpu_reset_alarm_threshold", sizeof("cpu_reset_alarm_threshold")-1) || - !strncasecmp(var, "cpu_clear_alarm_threshold", sizeof("cpu_clear_alarm_threshold")-1)) { - intparam = atoi(val); - if (intparam > 0 && intparam < 100) { - globals.cpu_monitor.clear_alarm_threshold = (uint8_t)intparam; - if (globals.cpu_monitor.clear_alarm_threshold > globals.cpu_monitor.set_alarm_threshold) { - globals.cpu_monitor.clear_alarm_threshold = globals.cpu_monitor.set_alarm_threshold - 10; - ftdm_log(FTDM_LOG_ERROR, "Cpu alarm clear threshold must be lower than set threshold, " - "setting clear threshold to %d\n", globals.cpu_monitor.clear_alarm_threshold); - } - } else { - ftdm_log(FTDM_LOG_ERROR, "Invalid cpu alarm reset threshold %s\n", val); - } - } else if (!strncasecmp(var, "cpu_alarm_action", sizeof("cpu_alarm_action")-1)) { - char* p = val; - do { - if (!strncasecmp(p, "reject", sizeof("reject")-1)) { - globals.cpu_monitor.alarm_action_flags |= FTDM_CPU_ALARM_ACTION_REJECT; - } else if (!strncasecmp(p, "warn", sizeof("warn")-1)) { - globals.cpu_monitor.alarm_action_flags |= FTDM_CPU_ALARM_ACTION_WARN; - } - p = strchr(p, ','); - if (p) { - while(*p++) if (*p != 0x20) break; - } - } while (p); - } - } else { - ftdm_log(FTDM_LOG_ERROR, "unknown param [%s] '%s' / '%s'\n", cfg.category, var, val); - } - } - - /* Verify is trunk_type was specified for the last span */ - if (span && span->trunk_type == FTDM_TRUNK_NONE) { - ftdm_log(FTDM_LOG_ERROR, "trunk_type not specified for span %d (%s)\n", span->span_id, span->name); - ret = FTDM_FAIL; - } - -done: - ftdm_config_close_file(&cfg); - - ftdm_log(FTDM_LOG_INFO, "Configured %u channel(s)\n", configured); - if (!configured) { - ret = FTDM_FAIL; - } - - return ret; -} - -static ftdm_status_t process_module_config(ftdm_io_interface_t *fio) -{ - ftdm_config_t cfg; - char *var, *val; - char filename[256] = ""; - - ftdm_assert_return(fio != NULL, FTDM_FAIL, "fio argument is null\n"); - - snprintf(filename, sizeof(filename), "%s.conf", fio->name); - - if (!fio->configure) { - ftdm_log(FTDM_LOG_DEBUG, "Module %s does not support configuration.\n", fio->name); - return FTDM_FAIL; - } - - if (!ftdm_config_open_file(&cfg, filename)) { - /* This is normal if the user did not provide a configuration for this module */ - ftdm_log(FTDM_LOG_DEBUG, "File %s is not available\n", filename); - return FTDM_FAIL; - } - - while (ftdm_config_next_pair(&cfg, &var, &val)) { - fio->configure(cfg.category, var, val, cfg.lineno); - } - - ftdm_config_close_file(&cfg); - - return FTDM_SUCCESS; -} - -FT_DECLARE(ftdm_status_t) ftdm_global_add_io_interface(ftdm_io_interface_t *interface1) -{ - ftdm_status_t ret = FTDM_SUCCESS; - ftdm_mutex_lock(globals.mutex); - if (hashtable_search(globals.interface_hash, (void *)interface1->name)) { - ftdm_log(FTDM_LOG_ERROR, "Interface %s already loaded!\n", interface1->name); - } else { - hashtable_insert(globals.interface_hash, (void *)interface1->name, interface1, HASHTABLE_FLAG_NONE); - } - ftdm_mutex_unlock(globals.mutex); - return ret; -} - -FT_DECLARE(ftdm_io_interface_t *) ftdm_global_get_io_interface(const char *iotype, ftdm_bool_t autoload) -{ - ftdm_io_interface_t *fio = NULL; - - ftdm_mutex_lock(globals.mutex); - - fio = (ftdm_io_interface_t *) hashtable_search(globals.interface_hash, (void *)iotype); - if (!fio && autoload) { - ftdm_load_module_assume(iotype); - fio = (ftdm_io_interface_t *) hashtable_search(globals.interface_hash, (void *)iotype); - if (fio) { - ftdm_log(FTDM_LOG_INFO, "Auto-loaded I/O module '%s'\n", iotype); - } - } - - ftdm_mutex_unlock(globals.mutex); - return fio; -} - -FT_DECLARE(int) ftdm_load_module(const char *name) -{ - ftdm_dso_lib_t lib; - int count = 0; - ftdm_bool_t load_proceed = FTDM_TRUE; - char path[512] = ""; - char *err; - ftdm_module_t *mod; - - ftdm_build_dso_path(name, path, sizeof(path)); - - if (!(lib = ftdm_dso_open(path, &err))) { - ftdm_log(FTDM_LOG_ERROR, "Error loading %s [%s]\n", path, err); - ftdm_safe_free(err); - return 0; - } - - if (!(mod = (ftdm_module_t *) ftdm_dso_func_sym(lib, "ftdm_module", &err))) { - ftdm_log(FTDM_LOG_ERROR, "Error loading %s [%s]\n", path, err); - ftdm_safe_free(err); - return 0; - } - - if (mod->io_load) { - ftdm_io_interface_t *interface1 = NULL; /* name conflict w/windows here */ - - if (mod->io_load(&interface1) != FTDM_SUCCESS || !interface1 || !interface1->name) { - ftdm_log(FTDM_LOG_ERROR, "Error loading %s\n", path); - load_proceed = FTDM_FALSE; - } else { - ftdm_log(FTDM_LOG_INFO, "Loading IO from %s [%s]\n", path, interface1->name); - if (ftdm_global_add_io_interface(interface1) == FTDM_SUCCESS) { - process_module_config(interface1); - } - } - } - - if (mod->sig_load) { - if (mod->sig_load() != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "Error loading %s\n", path); - load_proceed = FTDM_FALSE; - } else { - ftdm_log(FTDM_LOG_INFO, "Loading SIG from %s\n", path); - } - } - - if (load_proceed) { - char *p; - mod->lib = lib; - ftdm_set_string(mod->path, path); - if (mod->name[0] == '\0') { - if (!(p = strrchr(path, *FTDM_PATH_SEPARATOR))) { - p = path; - } - ftdm_set_string(mod->name, p); - } - - ftdm_mutex_lock(globals.mutex); - if (hashtable_search(globals.module_hash, (void *)mod->name)) { - ftdm_log(FTDM_LOG_ERROR, "Module %s already loaded!\n", mod->name); - ftdm_dso_destroy(&lib); - } else { - hashtable_insert(globals.module_hash, (void *)mod->name, mod, HASHTABLE_FLAG_NONE); - count++; - } - ftdm_mutex_unlock(globals.mutex); - } else { - ftdm_log(FTDM_LOG_ERROR, "Errors during module load. Unloading %s\n", path); - ftdm_dso_destroy(&lib); - } - - return count; -} - -FT_DECLARE(int) ftdm_load_module_assume(const char *name) -{ - char buf[256] = ""; - - snprintf(buf, sizeof(buf), "ftmod_%s", name); - return ftdm_load_module(buf); -} - -FT_DECLARE(int) ftdm_load_modules(void) -{ - char cfg_name[] = "modules.conf"; - ftdm_config_t cfg; - char *var, *val; - int count = 0; - - if (!ftdm_config_open_file(&cfg, cfg_name)) { - return FTDM_FAIL; - } - - while (ftdm_config_next_pair(&cfg, &var, &val)) { - if (!strcasecmp(cfg.category, "modules")) { - if (!strcasecmp(var, "load")) { - count += ftdm_load_module(val); - } - } - } - - return count; -} - -FT_DECLARE(ftdm_status_t) ftdm_unload_modules(void) -{ - ftdm_hash_iterator_t *i = NULL; - ftdm_dso_lib_t lib = NULL; - char modpath[256] = { 0 }; - - /* stop signaling interfaces first as signaling depends on I/O and not the other way around */ - for (i = hashtable_first(globals.module_hash); i; i = hashtable_next(i)) { - const void *key = NULL; - void *val = NULL; - ftdm_module_t *mod = NULL; - - hashtable_this(i, &key, NULL, &val); - - if (!key || !val) { - continue; - } - - mod = (ftdm_module_t *) val; - - if (!mod->sig_unload) { - continue; - } - - ftdm_log(FTDM_LOG_INFO, "Unloading signaling interface %s\n", mod->name); - - if (mod->sig_unload() != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "Error unloading signaling interface %s\n", mod->name); - continue; - } - - ftdm_log(FTDM_LOG_INFO, "Unloaded signaling interface %s\n", mod->name); - } - - /* Now go ahead with I/O interfaces */ - for (i = hashtable_first(globals.module_hash); i; i = hashtable_next(i)) { - const void *key = NULL; - void *val = NULL; - ftdm_module_t *mod = NULL; - - hashtable_this(i, &key, NULL, &val); - - if (!key || !val) { - continue; - } - - mod = (ftdm_module_t *) val; - - if (!mod->io_unload) { - continue; - } - - ftdm_log(FTDM_LOG_INFO, "Unloading I/O interface %s\n", mod->name); - - if (mod->io_unload() != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "Error unloading I/O interface %s\n", mod->name); - continue; - } - - ftdm_log(FTDM_LOG_INFO, "Unloaded I/O interface %s\n", mod->name); - } - - /* Now unload the actual shared object/dll */ - for (i = hashtable_first(globals.module_hash); i; i = hashtable_next(i)) { - ftdm_module_t *mod = NULL; - const void *key = NULL; - void *val = NULL; - - hashtable_this(i, &key, NULL, &val); - - if (!key || !val) { - continue; - } - - mod = (ftdm_module_t *) val; - - lib = mod->lib; - snprintf(modpath, sizeof(modpath), "%s", mod->path); - ftdm_log(FTDM_LOG_INFO, "Unloading module %s\n", modpath); - ftdm_dso_destroy(&lib); - ftdm_log(FTDM_LOG_INFO, "Unloaded module %s\n", modpath); - } - - return FTDM_SUCCESS; -} - -static ftdm_status_t post_configure_span_channels(ftdm_span_t *span) -{ - unsigned i = 0; - ftdm_status_t status = FTDM_SUCCESS; - ftdm_signaling_status_t sigstatus = FTDM_SIG_STATE_DOWN; - for (i = 1; i <= span->chan_count; i++) { - sigstatus = FTDM_SIG_STATE_DOWN; - ftdm_channel_get_sig_status(span->channels[i], &sigstatus); - if (sigstatus == FTDM_SIG_STATE_UP) { - ftdm_set_flag(span->channels[i], FTDM_CHANNEL_SIG_UP); - } - } - if (ftdm_test_flag(span, FTDM_SPAN_USE_CHAN_QUEUE)) { - status = ftdm_queue_create(&span->pendingchans, SPAN_PENDING_CHANS_QUEUE_SIZE); - } - if (status == FTDM_SUCCESS && ftdm_test_flag(span, FTDM_SPAN_USE_SIGNALS_QUEUE)) { - status = ftdm_queue_create(&span->pendingsignals, SPAN_PENDING_SIGNALS_QUEUE_SIZE); - } - return status; -} - -FT_DECLARE(ftdm_status_t) ftdm_configure_span(ftdm_span_t *span, const char *type, fio_signal_cb_t sig_cb, ...) -{ - ftdm_module_t *mod = (ftdm_module_t *) hashtable_search(globals.module_hash, (void *)type); - ftdm_status_t status = FTDM_FAIL; - - if (!span->chan_count) { - ftdm_log(FTDM_LOG_WARNING, "Cannot configure signaling on span with no channels\n"); - return FTDM_FAIL; - } - - if (!mod) { - ftdm_load_module_assume(type); - if ((mod = (ftdm_module_t *) hashtable_search(globals.module_hash, (void *)type))) { - ftdm_log(FTDM_LOG_INFO, "auto-loaded '%s'\n", type); - } else { - ftdm_log(FTDM_LOG_ERROR, "can't load '%s'\n", type); - return FTDM_FAIL; - } - } - - if (mod->sig_configure) { - va_list ap; - va_start(ap, sig_cb); - status = mod->sig_configure(span, sig_cb, ap); - va_end(ap); - if (status == FTDM_SUCCESS) { - status = post_configure_span_channels(span); - } - } else { - ftdm_log(FTDM_LOG_CRIT, "module '%s' did not implement the sig_configure method\n", type); - status = FTDM_FAIL; - } - - return status; -} - -FT_DECLARE(ftdm_status_t) ftdm_configure_span_signaling(ftdm_span_t *span, const char *type, fio_signal_cb_t sig_cb, ftdm_conf_parameter_t *parameters) -{ - ftdm_module_t *mod = (ftdm_module_t *) hashtable_search(globals.module_hash, (void *)type); - ftdm_status_t status = FTDM_FAIL; - - ftdm_assert_return(type != NULL, FTDM_FAIL, "No signaling type"); - ftdm_assert_return(span != NULL, FTDM_FAIL, "No span"); - ftdm_assert_return(sig_cb != NULL, FTDM_FAIL, "No signaling callback"); - ftdm_assert_return(parameters != NULL, FTDM_FAIL, "No parameters"); - - if (!span->chan_count) { - ftdm_log(FTDM_LOG_WARNING, "Cannot configure signaling on span %s with no channels\n", span->name); - return FTDM_FAIL; - } - - if (!mod) { - ftdm_load_module_assume(type); - if ((mod = (ftdm_module_t *) hashtable_search(globals.module_hash, (void *)type))) { - ftdm_log(FTDM_LOG_INFO, "auto-loaded '%s'\n", type); - } - } - - if (!mod) { - ftdm_log(FTDM_LOG_ERROR, "Failed to load module type: %s\n", type); - return FTDM_FAIL; - } - - if (mod->configure_span_signaling) { - status = mod->configure_span_signaling(span, sig_cb, parameters); - if (status == FTDM_SUCCESS) { - status = post_configure_span_channels(span); - } - } else { - ftdm_log(FTDM_LOG_ERROR, "Module %s did not implement the signaling configuration method\n", type); - } - - return status; -} - -static void *ftdm_span_service_events(ftdm_thread_t *me, void *obj) -{ - uint32_t i; - unsigned waitms; - ftdm_event_t *event; - ftdm_status_t status = FTDM_SUCCESS; - ftdm_span_t *span = (ftdm_span_t*) obj; - short *poll_events = ftdm_malloc(sizeof(short) * span->chan_count); - - if (me == 0) {}; - - memset(poll_events, 0, sizeof(short) * span->chan_count); - - for(i = 1; i <= span->chan_count; i++) { - poll_events[i] |= FTDM_EVENTS; - } - - while (ftdm_running() && !(ftdm_test_flag(span, FTDM_SPAN_STOP_THREAD))) { - waitms = 1000; - status = ftdm_span_poll_event(span, waitms, poll_events); - switch (status) { - case FTDM_FAIL: - ftdm_log(FTDM_LOG_CRIT, "%s:Failed to poll span for events\n", span->name); - break; - case FTDM_TIMEOUT: - break; - case FTDM_SUCCESS: - /* Check if there are any channels that have events available */ - while (ftdm_span_next_event(span, &event) == FTDM_SUCCESS); - break; - default: - ftdm_log(FTDM_LOG_CRIT, "%s:Unhandled IO event\n", span->name); - } - } - return NULL; -} - -FT_DECLARE(ftdm_status_t) ftdm_span_register_signal_cb(ftdm_span_t *span, fio_signal_cb_t sig_cb) -{ - span->signal_cb = sig_cb; - return FTDM_SUCCESS; -} - -FT_DECLARE(ftdm_status_t) ftdm_span_start(ftdm_span_t *span) -{ - ftdm_status_t status = FTDM_FAIL; - ftdm_mutex_lock(span->mutex); - - if (ftdm_test_flag(span, FTDM_SPAN_STARTED)) { - status = FTDM_EINVAL; - goto done; - } - if (span->signal_type == FTDM_SIGTYPE_NONE) { - /* If there is no signalling component, start a thread to poll events */ - status = ftdm_thread_create_detached(ftdm_span_service_events, span); - if (status != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_CRIT,"Failed to start span event monitor thread!\n"); - goto done; - } - - //ftdm_report_initial_channels_alarms(span); - ftdm_set_flag_locked(span, FTDM_SPAN_STARTED); - goto done; - } - - if (!span->start) { - status = FTDM_ENOSYS; - goto done; - } - - /* Start I/O */ - if (span->fio && span->fio->span_start) { - status = span->fio->span_start(span); - if (status != FTDM_SUCCESS) - goto done; - } - - /* Start SIG */ - status = ftdm_report_initial_channels_alarms(span); - if (status != FTDM_SUCCESS) { - goto done; - } - - status = span->start(span); - if (status == FTDM_SUCCESS) { - ftdm_set_flag_locked(span, FTDM_SPAN_STARTED); - } -done: - ftdm_mutex_unlock(span->mutex); - return status; -} - -FT_DECLARE(ftdm_status_t) ftdm_channel_add_to_group(const char* name, ftdm_channel_t* ftdmchan) -{ - unsigned int i; - ftdm_group_t* group = NULL; - - ftdm_mutex_lock(globals.group_mutex); - - ftdm_assert_return(ftdmchan != NULL, FTDM_FAIL, "Cannot add a null channel to a group\n"); - - if (ftdm_group_find_by_name(name, &group) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_DEBUG, "Creating new group:%s\n", name); - ftdm_group_create(&group, name); - } - - /*verify that group does not already include this channel first */ - for(i = 0; i < group->chan_count; i++) { - if (group->channels[i]->physical_span_id == ftdmchan->physical_span_id && - group->channels[i]->physical_chan_id == ftdmchan->physical_chan_id) { - - ftdm_mutex_unlock(globals.group_mutex); - ftdm_log(FTDM_LOG_DEBUG, "Channel %d:%d is already added to group %s\n", - group->channels[i]->physical_span_id, - group->channels[i]->physical_chan_id, - name); - return FTDM_SUCCESS; - } - } - - if (group->chan_count >= FTDM_MAX_CHANNELS_GROUP) { - ftdm_log(FTDM_LOG_ERROR, "Max number of channels exceeded (max:%d)\n", FTDM_MAX_CHANNELS_GROUP); - ftdm_mutex_unlock(globals.group_mutex); - return FTDM_FAIL; - } - - group->channels[group->chan_count++] = ftdmchan; - ftdm_mutex_unlock(globals.group_mutex); - return FTDM_SUCCESS; -} - -FT_DECLARE(ftdm_status_t) ftdm_channel_remove_from_group(ftdm_group_t* group, ftdm_channel_t* ftdmchan) -{ - unsigned int i, j; - //Need to test this function - ftdm_mutex_lock(globals.group_mutex); - - for (i=0; i < group->chan_count; i++) { - if (group->channels[i]->physical_span_id == ftdmchan->physical_span_id && - group->channels[i]->physical_chan_id == ftdmchan->physical_chan_id) { - - j=i; - while(j < group->chan_count-1) { - group->channels[j] = group->channels[j+1]; - j++; - } - group->channels[group->chan_count--] = NULL; - if (group->chan_count <=0) { - /* Delete group if it is empty */ - hashtable_remove(globals.group_hash, (void *)group->name); - } - ftdm_mutex_unlock(globals.group_mutex); - return FTDM_SUCCESS; - } - } - - ftdm_mutex_unlock(globals.group_mutex); - //Group does not contain this channel - return FTDM_FAIL; -} - -static ftdm_status_t ftdm_group_add_channels(ftdm_span_t* span, int currindex, const char* name) -{ - unsigned chan_index = 0; - - ftdm_assert_return(strlen(name) > 0, FTDM_FAIL, "Invalid group name provided\n"); - ftdm_assert_return(currindex >= 0, FTDM_FAIL, "Invalid current channel index provided\n"); - - if (!span->chan_count) { - return FTDM_SUCCESS; - } - - for (chan_index = currindex+1; chan_index <= span->chan_count; chan_index++) { - if (!FTDM_IS_VOICE_CHANNEL(span->channels[chan_index])) { - continue; - } - if (ftdm_channel_add_to_group(name, span->channels[chan_index])) { - ftdm_log(FTDM_LOG_ERROR, "Failed to add chan:%d to group:%s\n", chan_index, name); - } - } - return FTDM_SUCCESS; -} - -FT_DECLARE(ftdm_status_t) ftdm_group_find(uint32_t id, ftdm_group_t **group) -{ - ftdm_group_t *fgroup = NULL, *grp; - - if (id > FTDM_MAX_GROUPS_INTERFACE) { - return FTDM_FAIL; - } - - - ftdm_mutex_lock(globals.group_mutex); - for (grp = globals.groups; grp; grp = grp->next) { - if (grp->group_id == id) { - fgroup = grp; - break; - } - } - ftdm_mutex_unlock(globals.group_mutex); - - if (!fgroup) { - return FTDM_FAIL; - } - - *group = fgroup; - - return FTDM_SUCCESS; - -} - -FT_DECLARE(ftdm_status_t) ftdm_group_find_by_name(const char *name, ftdm_group_t **group) -{ - ftdm_status_t status = FTDM_FAIL; - *group = NULL; - ftdm_mutex_lock(globals.group_mutex); - if (!ftdm_strlen_zero(name)) { - if ((*group = hashtable_search(globals.group_hash, (void *) name))) { - status = FTDM_SUCCESS; - } - } - ftdm_mutex_unlock(globals.group_mutex); - return status; -} - -static void ftdm_group_add(ftdm_group_t *group) -{ - ftdm_group_t *grp; - ftdm_mutex_lock(globals.group_mutex); - - for (grp = globals.groups; grp && grp->next; grp = grp->next); - - if (grp) { - grp->next = group; - } else { - globals.groups = group; - } - hashtable_insert(globals.group_hash, (void *)group->name, group, HASHTABLE_FLAG_NONE); - - ftdm_mutex_unlock(globals.group_mutex); -} - -FT_DECLARE(ftdm_status_t) ftdm_group_create(ftdm_group_t **group, const char *name) -{ - ftdm_group_t *new_group = NULL; - ftdm_status_t status = FTDM_FAIL; - - ftdm_mutex_lock(globals.mutex); - if (globals.group_index < FTDM_MAX_GROUPS_INTERFACE) { - new_group = ftdm_calloc(1, sizeof(*new_group)); - - ftdm_assert(new_group != NULL, "Failed to create new ftdm group, expect a crash\n"); - - status = ftdm_mutex_create(&new_group->mutex); - - ftdm_assert(status == FTDM_SUCCESS, "Failed to create group mutex, expect a crash\n"); - - new_group->group_id = ++globals.group_index; - new_group->name = ftdm_strdup(name); - ftdm_group_add(new_group); - *group = new_group; - status = FTDM_SUCCESS; - } else { - ftdm_log(FTDM_LOG_ERROR, "Group %s was not added, we exceeded the max number of groups\n", name); - } - ftdm_mutex_unlock(globals.mutex); - return status; -} - -static void ftdm_group_destroy(ftdm_group_t **group) -{ - ftdm_group_t *grp = NULL; - ftdm_assert(group != NULL, "Group must not be null\n"); - grp = *group; - ftdm_mutex_destroy(&grp->mutex); - ftdm_safe_free(grp->name); - ftdm_safe_free(grp); - *group = NULL; -} - -static ftdm_status_t ftdm_span_trigger_signal(const ftdm_span_t *span, ftdm_sigmsg_t *sigmsg) -{ - if (!span->signal_cb) { - return FTDM_FAIL; - } - return span->signal_cb(sigmsg); -} - -static ftdm_status_t ftdm_span_queue_signal(const ftdm_span_t *span, ftdm_sigmsg_t *sigmsg) -{ - ftdm_sigmsg_t *new_sigmsg = NULL; - - new_sigmsg = ftdm_calloc(1, sizeof(*sigmsg)); - if (!new_sigmsg) { - return FTDM_FAIL; - } - memcpy(new_sigmsg, sigmsg, sizeof(*sigmsg)); - - ftdm_queue_enqueue(span->pendingsignals, new_sigmsg); - return FTDM_SUCCESS; -} - -FT_DECLARE(ftdm_status_t) ftdm_span_trigger_signals(const ftdm_span_t *span) -{ - ftdm_sigmsg_t *sigmsg = NULL; - while ((sigmsg = ftdm_queue_dequeue(span->pendingsignals))) { - ftdm_span_trigger_signal(span, sigmsg); - ftdm_sigmsg_free(&sigmsg); - } - return FTDM_SUCCESS; -} - -static void execute_safety_hangup(void *data) -{ - ftdm_channel_t *fchan = data; - ftdm_channel_lock(fchan); - fchan->hangup_timer = 0; - if (fchan->state == FTDM_CHANNEL_STATE_TERMINATING) { - ftdm_log_chan(fchan, FTDM_LOG_WARNING, "Forcing hangup since the user did not confirmed our hangup after %dms\n", FORCE_HANGUP_TIMER); - _ftdm_channel_call_hangup_nl(__FILE__, __FTDM_FUNC__, __LINE__, fchan, NULL); - } else { - ftdm_log_chan(fchan, FTDM_LOG_CRIT, "Not performing safety hangup, channel state is %s\n", ftdm_channel_state2str(fchan->state)); - } - ftdm_channel_unlock(fchan); -} - -FT_DECLARE(ftdm_status_t) ftdm_span_send_signal(ftdm_span_t *span, ftdm_sigmsg_t *sigmsg) -{ - ftdm_channel_t *fchan = NULL; - ftdm_status_t status = FTDM_SUCCESS; - if (sigmsg->channel) { - fchan = sigmsg->channel; - ftdm_channel_lock(fchan); - } - - /* some core things to do on special events */ - switch (sigmsg->event_id) { - - case FTDM_SIGEVENT_SIGSTATUS_CHANGED: - { - if (sigmsg->ev_data.sigstatus.status == FTDM_SIG_STATE_UP) { - ftdm_set_flag(fchan, FTDM_CHANNEL_SIG_UP); - ftdm_clear_flag(fchan, FTDM_CHANNEL_SUSPENDED); - } else { - ftdm_clear_flag(fchan, FTDM_CHANNEL_SIG_UP); - if (sigmsg->ev_data.sigstatus.status == FTDM_SIG_STATE_SUSPENDED) { - ftdm_set_flag(fchan, FTDM_CHANNEL_SUSPENDED); - } else { - ftdm_clear_flag(fchan, FTDM_CHANNEL_SUSPENDED); - } - } - } - break; - - case FTDM_SIGEVENT_START: - { - ftdm_assert(!ftdm_test_flag(fchan, FTDM_CHANNEL_CALL_STARTED), "Started call twice!\n"); - - if (ftdm_test_flag(fchan, FTDM_CHANNEL_OUTBOUND)) { - ftdm_log_chan_msg(fchan, FTDM_LOG_WARNING, "Inbound call taking over outbound channel\n"); - ftdm_clear_flag(fchan, FTDM_CHANNEL_OUTBOUND); - } - ftdm_set_flag(fchan, FTDM_CHANNEL_CALL_STARTED); - ftdm_call_set_call_id(fchan, &fchan->caller_data); - /* when cleaning up the public API I added this because mod_freetdm.c on_fxs_signal was - * doing it during SIGEVENT_START, but now that flags are private they can't, wonder if - * is needed at all? */ - ftdm_clear_flag(sigmsg->channel, FTDM_CHANNEL_HOLD); - if (sigmsg->channel->caller_data.bearer_capability == FTDM_BEARER_CAP_UNRESTRICTED) { - ftdm_set_flag(sigmsg->channel, FTDM_CHANNEL_DIGITAL_MEDIA); - } - } - break; - - case FTDM_SIGEVENT_PROGRESS_MEDIA: - { - /* test signaling module compliance */ - if (fchan->state != FTDM_CHANNEL_STATE_PROGRESS_MEDIA) { - ftdm_log_chan(fchan, FTDM_LOG_WARNING, "FTDM_SIGEVENT_PROGRESS_MEDIA sent in state %s\n", ftdm_channel_state2str(fchan->state)); - } - } - break; - - case FTDM_SIGEVENT_UP: - { - /* test signaling module compliance */ - if (fchan->state != FTDM_CHANNEL_STATE_UP) { - ftdm_log_chan(fchan, FTDM_LOG_WARNING, "FTDM_SIGEVENT_UP sent in state %s\n", ftdm_channel_state2str(fchan->state)); - } - } - break; - - case FTDM_SIGEVENT_STOP: - { - /* TODO: we could test for compliance here and check the state is FTDM_CHANNEL_STATE_TERMINATING - * but several modules need to be updated first */ - - /* if the call was never started, do not send SIGEVENT_STOP - this happens for FXS devices in ftmod_analog which blindly send SIGEVENT_STOP, we should fix it there ... */ - if (!ftdm_test_flag(fchan, FTDM_CHANNEL_CALL_STARTED)) { - ftdm_log_chan_msg(fchan, FTDM_LOG_DEBUG, "Ignoring SIGEVENT_STOP since user never knew about a call in this channel\n"); - goto done; - } - - if (ftdm_test_flag(fchan, FTDM_CHANNEL_USER_HANGUP)) { - ftdm_log_chan_msg(fchan, FTDM_LOG_DEBUG, "Ignoring SIGEVENT_STOP since user already requested hangup\n"); - goto done; - } - - if (fchan->state == FTDM_CHANNEL_STATE_TERMINATING) { - ftdm_log_chan_msg(fchan, FTDM_LOG_DEBUG, "Scheduling safety hangup timer\n"); - /* if the user does not move us to hangup in 2 seconds, we will do it ourselves */ - ftdm_sched_timer(globals.timingsched, "safety-hangup", FORCE_HANGUP_TIMER, execute_safety_hangup, fchan, &fchan->hangup_timer); - } - } - break; - - default: - break; - - } - - if (fchan) { - /* set members of the sigmsg that must be present for all events */ - sigmsg->chan_id = fchan->chan_id; - sigmsg->span_id = fchan->span_id; - sigmsg->call_id = fchan->caller_data.call_id; - sigmsg->call_priv = fchan->caller_data.priv; - } - - /* if the signaling module uses a queue for signaling notifications, then enqueue it */ - if (ftdm_test_flag(span, FTDM_SPAN_USE_SIGNALS_QUEUE)) { - ftdm_span_queue_signal(span, sigmsg); - } else { - status = ftdm_span_trigger_signal(span, sigmsg); - } - -done: - - if (fchan) { - ftdm_channel_unlock(fchan); - } - - return status; -} - -static void *ftdm_cpu_monitor_run(ftdm_thread_t *me, void *obj) -{ - cpu_monitor_t *monitor = (cpu_monitor_t *)obj; - struct ftdm_cpu_monitor_stats *cpu_stats = ftdm_new_cpu_monitor(); - - ftdm_log(FTDM_LOG_DEBUG, "CPU monitor thread is now running\n"); - if (!cpu_stats) { - goto done; - } - monitor->running = 1; - - while (ftdm_running()) { - double idle_time = 0.0; - int cpu_usage = 0; - - if (ftdm_cpu_get_system_idle_time(cpu_stats, &idle_time)) { - break; - } - - cpu_usage = (int)(100 - idle_time); - if (monitor->alarm) { - if (cpu_usage <= monitor->clear_alarm_threshold) { - ftdm_log(FTDM_LOG_DEBUG, "CPU alarm is now OFF (cpu usage: %d)\n", cpu_usage); - monitor->alarm = 0; - } else if (monitor->alarm_action_flags & FTDM_CPU_ALARM_ACTION_WARN) { - ftdm_log(FTDM_LOG_WARNING, "CPU alarm is still ON (cpu usage: %d)\n", cpu_usage); - } - } else { - if (cpu_usage >= monitor->set_alarm_threshold) { - ftdm_log(FTDM_LOG_WARNING, "CPU alarm is now ON (cpu usage: %d)\n", cpu_usage); - monitor->alarm = 1; - } - } - ftdm_interrupt_wait(monitor->interrupt, monitor->interval); - } - - ftdm_delete_cpu_monitor(cpu_stats); - monitor->running = 0; - -done: - ftdm_unused_arg(me); - ftdm_log(FTDM_LOG_DEBUG, "CPU monitor thread is now terminating\n"); - return NULL; -} - -static ftdm_status_t ftdm_cpu_monitor_start(void) -{ - if (ftdm_interrupt_create(&globals.cpu_monitor.interrupt, FTDM_INVALID_SOCKET, FTDM_NO_FLAGS) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_CRIT, "Failed to create CPU monitor interrupt\n"); - return FTDM_FAIL; - } - - if (ftdm_thread_create_detached(ftdm_cpu_monitor_run, &globals.cpu_monitor) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_CRIT, "Failed to create cpu monitor thread!!\n"); - return FTDM_FAIL; - } - return FTDM_SUCCESS; -} - -static void ftdm_cpu_monitor_stop(void) -{ - if (!globals.cpu_monitor.interrupt) { - return; - } - - if (!globals.cpu_monitor.running) { - return; - } - - if (ftdm_interrupt_signal(globals.cpu_monitor.interrupt) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_CRIT, "Failed to interrupt the CPU monitor\n"); - return; - } - - while (globals.cpu_monitor.running) { - ftdm_sleep(10); - } - - ftdm_interrupt_destroy(&globals.cpu_monitor.interrupt); -} - -FT_DECLARE(ftdm_status_t) ftdm_global_init(void) -{ - memset(&globals, 0, sizeof(globals)); - - time_init(); - - ftdm_thread_override_default_stacksize(FTDM_THREAD_STACKSIZE); - - globals.interface_hash = create_hashtable(16, ftdm_hash_hashfromstring, ftdm_hash_equalkeys); - globals.module_hash = create_hashtable(16, ftdm_hash_hashfromstring, ftdm_hash_equalkeys); - globals.span_hash = create_hashtable(16, ftdm_hash_hashfromstring, ftdm_hash_equalkeys); - globals.group_hash = create_hashtable(16, ftdm_hash_hashfromstring, ftdm_hash_equalkeys); - ftdm_mutex_create(&globals.mutex); - ftdm_mutex_create(&globals.span_mutex); - ftdm_mutex_create(&globals.group_mutex); - ftdm_mutex_create(&globals.call_id_mutex); - - ftdm_sched_global_init(); - globals.running = 1; - if (ftdm_sched_create(&globals.timingsched, "freetdm-master") != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_CRIT, "Failed to create master timing schedule context\n"); - goto global_init_fail; - } - if (ftdm_sched_free_run(globals.timingsched) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_CRIT, "Failed to run master timing schedule context\n"); - goto global_init_fail; - } - - return FTDM_SUCCESS; - -global_init_fail: - globals.running = 0; - ftdm_mutex_destroy(&globals.mutex); - ftdm_mutex_destroy(&globals.span_mutex); - ftdm_mutex_destroy(&globals.group_mutex); - ftdm_mutex_destroy(&globals.call_id_mutex); - hashtable_destroy(globals.interface_hash); - hashtable_destroy(globals.module_hash); - hashtable_destroy(globals.span_hash); - hashtable_destroy(globals.group_hash); - - return FTDM_FAIL; -} - -FT_DECLARE(ftdm_status_t) ftdm_global_configuration(void) -{ - int modcount = 0; - - if (!globals.running) { - return FTDM_FAIL; - } - - modcount = ftdm_load_modules(); - - ftdm_log(FTDM_LOG_NOTICE, "Modules configured: %d \n", modcount); - - globals.cpu_monitor.enabled = 0; - globals.cpu_monitor.interval = 1000; - globals.cpu_monitor.alarm_action_flags = 0; - globals.cpu_monitor.set_alarm_threshold = 92; - globals.cpu_monitor.clear_alarm_threshold = 82; - - if (load_config() != FTDM_SUCCESS) { - globals.running = 0; - ftdm_log(FTDM_LOG_ERROR, "FreeTDM global configuration failed!\n"); - return FTDM_FAIL; - } - - if (globals.cpu_monitor.enabled) { - ftdm_log(FTDM_LOG_INFO, "CPU Monitor is running interval:%d set-thres:%d clear-thres:%d\n", - globals.cpu_monitor.interval, - globals.cpu_monitor.set_alarm_threshold, - globals.cpu_monitor.clear_alarm_threshold); - - if (ftdm_cpu_monitor_start() != FTDM_SUCCESS) { - return FTDM_FAIL; - } - } - - - return FTDM_SUCCESS; -} - -FT_DECLARE(uint32_t) ftdm_running(void) -{ - return globals.running; -} - -static void destroy_span(ftdm_span_t *span) -{ - if (ftdm_test_flag(span, FTDM_SPAN_CONFIGURED)) { - ftdm_span_destroy(span); - } - hashtable_remove(globals.span_hash, (void *)span->name); - ftdm_safe_free(span->dtmf_hangup); - ftdm_safe_free(span->type); - ftdm_safe_free(span->name); - ftdm_safe_free(span); -} - -static void force_stop_span(ftdm_span_t *span) -{ - /* This is a forced stop */ - ftdm_clear_flag(span, FTDM_SPAN_NON_STOPPABLE); - ftdm_span_stop(span); -} - -static void span_for_each(void (*func)(ftdm_span_t *span)) -{ - ftdm_span_t *sp = NULL, *next = NULL; - for (sp = globals.spans; sp; sp = next) { - next = sp->next; - func(sp); - } -} - -FT_DECLARE(ftdm_status_t) ftdm_global_destroy(void) -{ - ftdm_group_t *grp = NULL, *next_grp = NULL; - - time_end(); - - /* many freetdm event loops rely on this variable to decide when to stop, do this first */ - globals.running = 0; - - /* stop the scheduling thread */ - ftdm_free_sched_stop(); - - /* stop the cpu monitor thread */ - ftdm_cpu_monitor_stop(); - - /* now destroy channels and spans */ - globals.span_index = 0; - - ftdm_span_close_all(); - - /* Stop and destroy alls pans */ - ftdm_mutex_lock(globals.span_mutex); - - span_for_each(force_stop_span); - span_for_each(destroy_span); - globals.spans = NULL; - - ftdm_mutex_unlock(globals.span_mutex); - - /* destroy signaling and io modules */ - ftdm_unload_modules(); - - /* Destroy hunting groups */ - ftdm_mutex_lock(globals.group_mutex); - grp = globals.groups; - while (grp) { - next_grp = grp->next; - ftdm_group_destroy(&grp); - grp = next_grp; - } - ftdm_mutex_unlock(globals.group_mutex); - - /* finally destroy the globals */ - ftdm_mutex_lock(globals.mutex); - - ftdm_sched_destroy(&globals.timingsched); - - hashtable_destroy(globals.interface_hash); - hashtable_destroy(globals.module_hash); - hashtable_destroy(globals.span_hash); - hashtable_destroy(globals.group_hash); - - ftdm_mutex_destroy(&globals.span_mutex); - ftdm_mutex_destroy(&globals.group_mutex); - ftdm_mutex_destroy(&globals.call_id_mutex); - - ftdm_mutex_unlock(globals.mutex); - - ftdm_mutex_destroy(&globals.mutex); - - ftdm_sched_global_destroy(); - - ftdm_global_set_logger(NULL); - memset(&globals, 0, sizeof(globals)); - return FTDM_SUCCESS; -} - - -FT_DECLARE(uint32_t) ftdm_separate_string(char *buf, char delim, char **array, int arraylen) -{ - int argc; - char *ptr; - int quot = 0; - char qc = '\''; - int x; - - if (!buf || !array || !arraylen) { - return 0; - } - - memset(array, 0, arraylen * sizeof(*array)); - - ptr = buf; - - /* we swallow separators that are contiguous */ - while (*ptr == delim) ptr++; - - for (argc = 0; *ptr && (argc < arraylen - 1); argc++) { - array[argc] = ptr; - for (; *ptr; ptr++) { - if (*ptr == qc) { - if (quot) { - quot--; - } else { - quot++; - } - } else if ((*ptr == delim) && !quot) { - *ptr++ = '\0'; - /* we swallow separators that are contiguous */ - while (*ptr == delim) ptr++; - break; - } - } - } - - if (*ptr) { - array[argc++] = ptr; - } - - /* strip quotes */ - for (x = 0; x < argc; x++) { - char *p = array[x]; - while((p = strchr(array[x], qc))) { - memmove(p, p+1, strlen(p)); - p++; - } - } - - return argc; -} - -FT_DECLARE(void) ftdm_bitstream_init(ftdm_bitstream_t *bsp, uint8_t *data, uint32_t datalen, ftdm_endian_t endian, uint8_t ss) -{ - memset(bsp, 0, sizeof(*bsp)); - bsp->data = data; - bsp->datalen = datalen; - bsp->endian = endian; - bsp->ss = ss; - - if (endian < 0) { - bsp->top = bsp->bit_index = 7; - bsp->bot = 0; - } else { - bsp->top = bsp->bit_index = 0; - bsp->bot = 7; - } - -} - -FT_DECLARE(int8_t) ftdm_bitstream_get_bit(ftdm_bitstream_t *bsp) -{ - int8_t bit = -1; - - - if (bsp->byte_index >= bsp->datalen) { - goto done; - } - - if (bsp->ss) { - if (!bsp->ssv) { - bsp->ssv = 1; - return 0; - } else if (bsp->ssv == 2) { - bsp->byte_index++; - bsp->ssv = 0; - return 1; - } - } - - - - - bit = (bsp->data[bsp->byte_index] >> (bsp->bit_index)) & 1; - - if (bsp->bit_index == bsp->bot) { - bsp->bit_index = bsp->top; - if (bsp->ss) { - bsp->ssv = 2; - goto done; - } - - if (++bsp->byte_index > bsp->datalen) { - bit = -1; - goto done; - } - - } else { - bsp->bit_index = bsp->bit_index + bsp->endian; - } - - - done: - return bit; -} - -FT_DECLARE(void) print_hex_bytes(uint8_t *data, ftdm_size_t dlen, char *buf, ftdm_size_t blen) -{ - char *bp = buf; - uint8_t *byte = data; - uint32_t i, j = 0; - - if (blen < (dlen * 3) + 2) { - return; - } - - *bp++ = '['; - j++; - - for(i = 0; i < dlen; i++) { - snprintf(bp, blen-j, "%02x ", *byte++); - bp += 3; - j += 3; - } - - *--bp = ']'; - -} - -FT_DECLARE(void) print_bits(uint8_t *b, int bl, char *buf, int blen, ftdm_endian_t e, uint8_t ss) -{ - ftdm_bitstream_t bs; - int j = 0, c = 0; - int8_t bit; - uint32_t last; - - if (blen < (bl * 10) + 2) { - return; - } - - ftdm_bitstream_init(&bs, b, bl, e, ss); - last = bs.byte_index; - while((bit = ftdm_bitstream_get_bit(&bs)) > -1) { - buf[j++] = bit ? '1' : '0'; - if (bs.byte_index != last) { - buf[j++] = ' '; - last = bs.byte_index; - if (++c == 8) { - buf[j++] = '\n'; - c = 0; - } - } - } - -} - - - -FT_DECLARE_NONSTD(ftdm_status_t) ftdm_console_stream_raw_write(ftdm_stream_handle_t *handle, uint8_t *data, ftdm_size_t datalen) -{ - ftdm_size_t need = handle->data_len + datalen; - - if (need >= handle->data_size) { - void *new_data; - need += handle->alloc_chunk; - - if (!(new_data = realloc(handle->data, need))) { - return FTDM_MEMERR; - } - - handle->data = new_data; - handle->data_size = need; - } - - memcpy((uint8_t *) (handle->data) + handle->data_len, data, datalen); - handle->data_len += datalen; - handle->end = (uint8_t *) (handle->data) + handle->data_len; - *(uint8_t *)handle->end = '\0'; - - return FTDM_SUCCESS; -} - -FT_DECLARE(int) ftdm_vasprintf(char **ret, const char *fmt, va_list ap) /* code from switch_apr.c */ -{ -#ifdef HAVE_VASPRINTF - return vasprintf(ret, fmt, ap); -#else - char *buf; - int len; - size_t buflen; - va_list ap2; - char *tmp = NULL; - -#ifdef _MSC_VER -#if _MSC_VER >= 1500 - /* hack for incorrect assumption in msvc header files for code analysis */ - __analysis_assume(tmp); -#endif - ap2 = ap; -#else - va_copy(ap2, ap); -#endif - - len = vsnprintf(tmp, 0, fmt, ap2); - - if (len > 0 && (buf = ftdm_malloc((buflen = (size_t) (len + 1)))) != NULL) { - len = vsnprintf(buf, buflen, fmt, ap); - *ret = buf; - } else { - *ret = NULL; - len = -1; - } - - va_end(ap2); - return len; -#endif -} - -FT_DECLARE_NONSTD(ftdm_status_t) ftdm_console_stream_write(ftdm_stream_handle_t *handle, const char *fmt, ...) -{ - va_list ap; - char *buf = handle->data; - char *end = handle->end; - int ret = 0; - char *data = NULL; - - if (handle->data_len >= handle->data_size) { - return FTDM_FAIL; - } - - va_start(ap, fmt); - ret = ftdm_vasprintf(&data, fmt, ap); - va_end(ap); - - if (data) { - ftdm_size_t remaining = handle->data_size - handle->data_len; - ftdm_size_t need = strlen(data) + 1; - - if ((remaining < need) && handle->alloc_len) { - ftdm_size_t new_len; - void *new_data; - - new_len = handle->data_size + need + handle->alloc_chunk; - if ((new_data = ftdm_realloc(handle->data, new_len))) { - handle->data_size = handle->alloc_len = new_len; - handle->data = new_data; - buf = handle->data; - remaining = handle->data_size - handle->data_len; - handle->end = (uint8_t *) (handle->data) + handle->data_len; - end = handle->end; - } else { - ftdm_log(FTDM_LOG_CRIT, "Memory Error!\n"); - ftdm_safe_free(data); - return FTDM_FAIL; - } - } - - if (remaining < need) { - ret = -1; - } else { - ret = 0; - snprintf(end, remaining, "%s", data); - handle->data_len = strlen(buf); - handle->end = (uint8_t *) (handle->data) + handle->data_len; - } - ftdm_safe_free(data); - } - - return ret ? FTDM_FAIL : FTDM_SUCCESS; -} - -FT_DECLARE(char *) ftdm_strdup(const char *str) -{ - ftdm_size_t len = strlen(str) + 1; - void *new = ftdm_malloc(len); - - if (!new) { - return NULL; - } - - return (char *)memcpy(new, str, len); -} - -FT_DECLARE(char *) ftdm_strndup(const char *str, ftdm_size_t inlen) -{ - char *new = NULL; - ftdm_size_t len = strlen(str) + 1; - if (len > (inlen+1)) { - len = inlen+1; - } - new = (char *)ftdm_malloc(len); - - if (!new) { - return NULL; - } - - memcpy(new, str, len-1); - new[len-1] = 0; - return new; -} - -static ftdm_status_t ftdm_call_set_call_id(ftdm_channel_t *fchan, ftdm_caller_data_t *caller_data) -{ - uint32_t current_call_id; - - ftdm_assert_return(!caller_data->call_id, FTDM_FAIL, "Overwriting non-cleared call-id\n"); - - ftdm_mutex_lock(globals.call_id_mutex); - - current_call_id = globals.last_call_id; - - for (current_call_id = globals.last_call_id + 1; - current_call_id != globals.last_call_id; - current_call_id++ ) { - if (current_call_id > MAX_CALLIDS) { - current_call_id = 1; - } - if (globals.call_ids[current_call_id] == NULL) { - break; - } - } - - ftdm_assert_return(globals.call_ids[current_call_id] == NULL, FTDM_FAIL, "We ran out of call ids\n"); - - globals.last_call_id = current_call_id; - caller_data->call_id = current_call_id; - - globals.call_ids[current_call_id] = caller_data; - caller_data->fchan = fchan; - - ftdm_mutex_unlock(globals.call_id_mutex); - return FTDM_SUCCESS; -} - -static ftdm_status_t ftdm_call_clear_call_id(ftdm_caller_data_t *caller_data) -{ - if (caller_data->call_id) { - ftdm_assert_return((caller_data->call_id <= MAX_CALLIDS), FTDM_FAIL, "Cannot clear call with invalid call-id\n"); - } else { - /* there might not be a call at all */ - return FTDM_SUCCESS; - } - - ftdm_mutex_lock(globals.call_id_mutex); - if (globals.call_ids[caller_data->call_id]) { - ftdm_log(FTDM_LOG_DEBUG, "Cleared call with id %u\n", caller_data->call_id); - globals.call_ids[caller_data->call_id] = NULL; - caller_data->call_id = 0; - } else { - ftdm_log(FTDM_LOG_CRIT, "call-id did not exist %u\n", caller_data->call_id); - } - ftdm_mutex_unlock(globals.call_id_mutex); - - return FTDM_SUCCESS; -} - -FT_DECLARE(ftdm_status_t) ftdm_sigmsg_get_raw_data(ftdm_sigmsg_t *sigmsg, void **data, ftdm_size_t *datalen) -{ - if (!sigmsg || !sigmsg->raw.len) { - return FTDM_FAIL; - } - - *data = sigmsg->raw.data; - *datalen = sigmsg->raw.len; - - return FTDM_SUCCESS; -} - -FT_DECLARE(ftdm_status_t) ftdm_sigmsg_get_raw_data_detached(ftdm_sigmsg_t *sigmsg, void **data, ftdm_size_t *datalen) -{ - if (!sigmsg || !sigmsg->raw.len) { - return FTDM_FAIL; - } - - *data = sigmsg->raw.data; - *datalen = sigmsg->raw.len; - - sigmsg->raw.data = NULL; - sigmsg->raw.len = 0; - return FTDM_SUCCESS; -} - -FT_DECLARE(ftdm_status_t) ftdm_sigmsg_set_raw_data(ftdm_sigmsg_t *sigmsg, void *data, ftdm_size_t datalen) -{ - ftdm_assert_return(sigmsg, FTDM_FAIL, "Trying to set raw data on a NULL event\n"); - ftdm_assert_return(!sigmsg->raw.len, FTDM_FAIL, "Overwriting existing raw data\n"); - ftdm_assert_return(datalen, FTDM_FAIL, "Data length not set\n"); - - sigmsg->raw.data = data; - sigmsg->raw.len = datalen; - return FTDM_SUCCESS; -} - -FT_DECLARE(ftdm_status_t) ftdm_usrmsg_get_raw_data(ftdm_usrmsg_t *usrmsg, void **data, ftdm_size_t *datalen) -{ - if (!usrmsg || !usrmsg->raw.len) { - return FTDM_FAIL; - } - - *data = usrmsg->raw.data; - *datalen = usrmsg->raw.len; - - return FTDM_SUCCESS; -} - -FT_DECLARE(ftdm_status_t) ftdm_usrmsg_set_raw_data(ftdm_usrmsg_t *usrmsg, void *data, ftdm_size_t datalen) -{ - ftdm_assert_return(usrmsg, FTDM_FAIL, "Trying to set raw data on a NULL event\n"); - ftdm_assert_return(!usrmsg->raw.len, FTDM_FAIL, "Overwriting existing raw data\n"); - ftdm_assert_return(datalen, FTDM_FAIL, "Data length not set\n"); - - usrmsg->raw.data = data; - usrmsg->raw.len = datalen; - return FTDM_SUCCESS; -} - -FT_DECLARE(ftdm_status_t) ftdm_channel_save_usrmsg(ftdm_channel_t *ftdmchan, ftdm_usrmsg_t *usrmsg) -{ - ftdm_assert_return(!ftdmchan->usrmsg, FTDM_FAIL, "Info from previous event was not cleared\n"); - if (usrmsg) { - /* Copy sigmsg from user to internal copy so user can set new variables without race condition */ - ftdmchan->usrmsg = ftdm_calloc(1, sizeof(ftdm_usrmsg_t)); - memcpy(ftdmchan->usrmsg, usrmsg, sizeof(ftdm_usrmsg_t)); - - if (usrmsg->raw.data) { - usrmsg->raw.data = NULL; - usrmsg->raw.len = 0; - } - if (usrmsg->variables) { - usrmsg->variables = NULL; - } - } - return FTDM_SUCCESS; -} - -FT_DECLARE(ftdm_status_t) ftdm_sigmsg_free(ftdm_sigmsg_t **sigmsg) -{ - if (!*sigmsg) { - return FTDM_SUCCESS; - } - - if ((*sigmsg)->variables) { - hashtable_destroy((*sigmsg)->variables); - (*sigmsg)->variables = NULL; - } - - if ((*sigmsg)->raw.data) { - ftdm_safe_free((*sigmsg)->raw.data); - (*sigmsg)->raw.data = NULL; - (*sigmsg)->raw.len = 0; - } - - ftdm_safe_free(*sigmsg); - return FTDM_SUCCESS; -} - -FT_DECLARE(ftdm_status_t) ftdm_usrmsg_free(ftdm_usrmsg_t **usrmsg) -{ - if (!*usrmsg) { - return FTDM_SUCCESS; - } - - if ((*usrmsg)->variables) { - hashtable_destroy((*usrmsg)->variables); - (*usrmsg)->variables = NULL; - } - - if ((*usrmsg)->raw.data) { - ftdm_safe_free((*usrmsg)->raw.data); - (*usrmsg)->raw.data = NULL; - (*usrmsg)->raw.len = 0; - } - - ftdm_safe_free(*usrmsg); - return FTDM_SUCCESS; -} - - - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/ftdm_queue.c b/libs/freetdm/src/ftdm_queue.c deleted file mode 100644 index c4c6524064..0000000000 --- a/libs/freetdm/src/ftdm_queue.c +++ /dev/null @@ -1,234 +0,0 @@ -/* - * Copyright (c) 2009, Sangoma Technologies - * Moises Silva - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "private/ftdm_core.h" - -static ftdm_status_t ftdm_std_queue_create(ftdm_queue_t **outqueue, ftdm_size_t capacity); -static ftdm_status_t ftdm_std_queue_enqueue(ftdm_queue_t *queue, void *obj); -static void *ftdm_std_queue_dequeue(ftdm_queue_t *queue); -static ftdm_status_t ftdm_std_queue_wait(ftdm_queue_t *queue, int ms); -static ftdm_status_t ftdm_std_queue_get_interrupt(ftdm_queue_t *queue, ftdm_interrupt_t **interrupt); -static ftdm_status_t ftdm_std_queue_destroy(ftdm_queue_t **inqueue); - -struct ftdm_queue { - ftdm_mutex_t *mutex; - ftdm_interrupt_t *interrupt; - ftdm_size_t capacity; - ftdm_size_t size; - unsigned rindex; - unsigned windex; - void **elements; -}; - -FT_DECLARE_DATA ftdm_queue_handler_t g_ftdm_queue_handler = -{ - /*.create = */ ftdm_std_queue_create, - /*.enqueue = */ ftdm_std_queue_enqueue, - /*.dequeue = */ ftdm_std_queue_dequeue, - /*.wait = */ ftdm_std_queue_wait, - /*.get_interrupt = */ ftdm_std_queue_get_interrupt, - /*.destroy = */ ftdm_std_queue_destroy -}; - -FT_DECLARE(ftdm_status_t) ftdm_global_set_queue_handler(ftdm_queue_handler_t *handler) -{ - if (!handler || - !handler->create || - !handler->enqueue || - !handler->dequeue || - !handler->wait || - !handler->get_interrupt || - !handler->destroy) { - return FTDM_FAIL; - } - memcpy(&g_ftdm_queue_handler, handler, sizeof(*handler)); - return FTDM_SUCCESS; -} - -static ftdm_status_t ftdm_std_queue_create(ftdm_queue_t **outqueue, ftdm_size_t capacity) -{ - ftdm_queue_t *queue = NULL; - ftdm_assert_return(outqueue, FTDM_FAIL, "Queue double pointer is null\n"); - ftdm_assert_return(capacity > 0, FTDM_FAIL, "Queue capacity is not bigger than 0\n"); - - *outqueue = NULL; - queue = ftdm_calloc(1, sizeof(*queue)); - if (!queue) { - return FTDM_FAIL; - } - - queue->elements = ftdm_calloc(1, (sizeof(void*)*capacity)); - if (!queue->elements) { - goto failed; - } - queue->capacity = capacity; - - if (ftdm_mutex_create(&queue->mutex) != FTDM_SUCCESS) { - goto failed; - } - - if (ftdm_interrupt_create(&queue->interrupt, FTDM_INVALID_SOCKET, FTDM_NO_FLAGS) != FTDM_SUCCESS) { - goto failed; - } - - *outqueue = queue; - return FTDM_SUCCESS; - -failed: - if (queue) { - if (queue->interrupt) { - ftdm_interrupt_destroy(&queue->interrupt); - } - if (queue->mutex) { - ftdm_mutex_destroy(&queue->mutex); - } - ftdm_safe_free(queue->elements); - ftdm_safe_free(queue); - } - return FTDM_FAIL; -} - -static ftdm_status_t ftdm_std_queue_enqueue(ftdm_queue_t *queue, void *obj) -{ - ftdm_status_t status = FTDM_FAIL; - - ftdm_assert_return(queue != NULL, FTDM_FAIL, "Queue is null!"); - - ftdm_mutex_lock(queue->mutex); - - if (queue->windex == queue->capacity) { - /* try to see if we can wrap around */ - queue->windex = 0; - } - - if (queue->size != 0 && queue->windex == queue->rindex) { - ftdm_log(FTDM_LOG_ERROR, "Failed to enqueue obj %p in queue %p, no more room! windex == rindex == %d!\n", obj, queue, queue->windex); - goto done; - } - - queue->elements[queue->windex++] = obj; - queue->size++; - status = FTDM_SUCCESS; - - /* wake up queue reader */ - ftdm_interrupt_signal(queue->interrupt); - -done: - - ftdm_mutex_unlock(queue->mutex); - - return status; -} - -static void *ftdm_std_queue_dequeue(ftdm_queue_t *queue) -{ - void *obj = NULL; - - ftdm_assert_return(queue != NULL, NULL, "Queue is null!"); - - ftdm_mutex_lock(queue->mutex); - - if (queue->size == 0) { - goto done; - } - - obj = queue->elements[queue->rindex]; - queue->elements[queue->rindex++] = NULL; - queue->size--; - if (queue->rindex == queue->capacity) { - queue->rindex = 0; - } - -done: - - ftdm_mutex_unlock(queue->mutex); - - return obj; -} - -static ftdm_status_t ftdm_std_queue_wait(ftdm_queue_t *queue, int ms) -{ - ftdm_status_t ret; - ftdm_assert_return(queue != NULL, FTDM_FAIL, "Queue is null!"); - - ftdm_mutex_lock(queue->mutex); - - /* if there is elements in the queue, no need to wait */ - if (queue->size != 0) { - ftdm_mutex_unlock(queue->mutex); - return FTDM_SUCCESS; - } - - /* no elements on the queue, wait for someone to write an element */ - ret = ftdm_interrupt_wait(queue->interrupt, ms); - - /* got an element or timeout, bail out */ - ftdm_mutex_unlock(queue->mutex); - - return ret; -} - -static ftdm_status_t ftdm_std_queue_get_interrupt(ftdm_queue_t *queue, ftdm_interrupt_t **interrupt) -{ - ftdm_assert_return(queue != NULL, FTDM_FAIL, "Queue is null!\n"); - ftdm_assert_return(interrupt != NULL, FTDM_FAIL, "Queue is null!\n"); - *interrupt = queue->interrupt; - return FTDM_SUCCESS; -} - -static ftdm_status_t ftdm_std_queue_destroy(ftdm_queue_t **inqueue) -{ - ftdm_queue_t *queue = NULL; - ftdm_assert_return(inqueue != NULL, FTDM_FAIL, "Queue is null!\n"); - ftdm_assert_return(*inqueue != NULL, FTDM_FAIL, "Queue is null!\n"); - - queue = *inqueue; - ftdm_interrupt_destroy(&queue->interrupt); - ftdm_mutex_destroy(&queue->mutex); - ftdm_safe_free(queue->elements); - ftdm_safe_free(queue); - *inqueue = NULL; - return FTDM_SUCCESS; -} - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/ftdm_sched.c b/libs/freetdm/src/ftdm_sched.c deleted file mode 100644 index 324073976c..0000000000 --- a/libs/freetdm/src/ftdm_sched.c +++ /dev/null @@ -1,576 +0,0 @@ -/* - * Copyright (c) 2010, Sangoma Technologies - * Moises Silva - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "private/ftdm_core.h" - -#ifdef __WINDOWS__ -struct ftdm_timezone { - int tz_minuteswest; /* minutes W of Greenwich */ - int tz_dsttime; /* type of dst correction */ -}; -int gettimeofday(struct timeval *tv, struct ftdm_timezone *tz) -{ - FILETIME ft; - unsigned __int64 tmpres = 0; - static int tzflag; - if (NULL != tv) { - GetSystemTimeAsFileTime(&ft); - tmpres |= ft.dwHighDateTime; - tmpres <<= 32; - tmpres |= ft.dwLowDateTime; - - /*converting file time to unix epoch */ - tmpres /= 10; /*convert into microseconds */ - tmpres -= DELTA_EPOCH_IN_MICROSECS; - tv->tv_sec = (long) (tmpres / 1000000UL); - tv->tv_usec = (long) (tmpres % 1000000UL); - } - if (NULL != tz) { - if (!tzflag) { - _tzset(); - tzflag++; - } - tz->tz_minuteswest = _timezone / 60; - tz->tz_dsttime = _daylight; - } - return 0; -} -#endif /* __WINDOWS__ */ - -typedef struct ftdm_timer ftdm_timer_t; - -static struct { - ftdm_sched_t *freeruns; - ftdm_mutex_t *mutex; - ftdm_bool_t running; -} sched_globals; - -struct ftdm_sched { - char name[80]; - ftdm_timer_id_t currid; - ftdm_mutex_t *mutex; - ftdm_timer_t *timers; - int freerun; - ftdm_sched_t *next; - ftdm_sched_t *prev; -}; - -struct ftdm_timer { - char name[80]; - ftdm_timer_id_t id; - struct timeval time; - void *usrdata; - ftdm_sched_callback_t callback; - ftdm_timer_t *next; - ftdm_timer_t *prev; -}; - -/* FIXME: use ftdm_interrupt_t to wait for new schedules to monitor */ -#define SCHED_MAX_SLEEP 100 -static void *run_main_schedule(ftdm_thread_t *thread, void *data) -{ - int32_t timeto; - int32_t sleepms; - ftdm_status_t status; - ftdm_sched_t *current = NULL; - - ftdm_unused_arg(data); - ftdm_unused_arg(thread); - - while (ftdm_running()) { - - sleepms = SCHED_MAX_SLEEP; - - ftdm_mutex_lock(sched_globals.mutex); - - if (!sched_globals.freeruns) { - - /* there are no free runs, wait a bit and check again (FIXME: use ftdm_interrupt_t for this) */ - ftdm_mutex_unlock(sched_globals.mutex); - - if (ftdm_running()) { - ftdm_sleep(sleepms); - } - } - - for (current = sched_globals.freeruns; current; current = current->next) { - if (!ftdm_running()) { - break; - } - - /* first run the schedule */ - ftdm_sched_run(current); - - /* now find out how much time to sleep until running them again */ - status = ftdm_sched_get_time_to_next_timer(current, &timeto); - if (status != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_WARNING, "Failed to get time to next timer for schedule %s, skipping\n", current->name); - continue; - } - - /* if timeto == -1 we don't want to sleep forever, so keep the last sleepms */ - if (timeto != -1 && sleepms > timeto) { - sleepms = timeto; - } - } - - ftdm_mutex_unlock(sched_globals.mutex); - - if (ftdm_running()) { - ftdm_sleep(sleepms); - } - } - ftdm_log(FTDM_LOG_NOTICE, "Main scheduling thread going out ...\n"); - sched_globals.running = 0; - return NULL; -} - -FT_DECLARE(ftdm_status_t) ftdm_sched_global_init() -{ - ftdm_log(FTDM_LOG_DEBUG, "Initializing scheduling API\n"); - memset(&sched_globals, 0, sizeof(sched_globals)); - if (ftdm_mutex_create(&sched_globals.mutex) == FTDM_SUCCESS) { - return FTDM_SUCCESS; - } - return FTDM_FAIL; -} - -FT_DECLARE(ftdm_status_t) ftdm_sched_global_destroy() -{ - ftdm_mutex_destroy(&sched_globals.mutex); - memset(&sched_globals, 0, sizeof(sched_globals)); - return FTDM_SUCCESS; -} - -FT_DECLARE(ftdm_status_t) ftdm_sched_free_run(ftdm_sched_t *sched) -{ - ftdm_status_t status = FTDM_FAIL; - ftdm_assert_return(sched != NULL, FTDM_EINVAL, "invalid pointer\n"); - - ftdm_mutex_lock(sched->mutex); - - ftdm_mutex_lock(sched_globals.mutex); - - if (sched->freerun) { - ftdm_log(FTDM_LOG_ERROR, "Schedule %s is already running in free run\n", sched->name); - goto done; - } - sched->freerun = 1; - - if (sched_globals.running == FTDM_FALSE) { - ftdm_log(FTDM_LOG_NOTICE, "Launching main schedule thread\n"); - status = ftdm_thread_create_detached(run_main_schedule, NULL); - if (status != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_CRIT, "Failed to launch main schedule thread\n"); - goto done; - } - sched_globals.running = FTDM_TRUE; - } - - ftdm_log(FTDM_LOG_DEBUG, "Running schedule %s in the main schedule thread\n", sched->name); - status = FTDM_SUCCESS; - - /* Add the schedule to the global list of free runs */ - if (!sched_globals.freeruns) { - sched_globals.freeruns = sched; - } else { - sched->next = sched_globals.freeruns; - sched_globals.freeruns->prev = sched; - sched_globals.freeruns = sched; - } - -done: - ftdm_mutex_unlock(sched_globals.mutex); - - ftdm_mutex_unlock(sched->mutex); - return status; -} - -FT_DECLARE(ftdm_bool_t) ftdm_free_sched_running(void) -{ - return sched_globals.running; -} - -FT_DECLARE(ftdm_bool_t) ftdm_free_sched_stop(void) -{ - /* currently we really dont stop the thread here, we rely on freetdm being shutdown and ftdm_running() to be false - * so the scheduling thread dies and we just wait for it here */ - uint32_t sanity = 100; - while (ftdm_free_sched_running() && --sanity) { - ftdm_log(FTDM_LOG_DEBUG, "Waiting for main schedule thread to finish\n"); - ftdm_sleep(100); - } - - if (!sanity) { - ftdm_log(FTDM_LOG_CRIT, "schedule thread did not stop running, we may crash on shutdown\n"); - return FTDM_FALSE; - } - - return FTDM_TRUE; -} - -FT_DECLARE(ftdm_status_t) ftdm_sched_create(ftdm_sched_t **sched, const char *name) -{ - ftdm_sched_t *newsched = NULL; - - ftdm_assert_return(sched != NULL, FTDM_EINVAL, "invalid pointer\n"); - ftdm_assert_return(name != NULL, FTDM_EINVAL, "invalid sched name\n"); - - *sched = NULL; - - newsched = ftdm_calloc(1, sizeof(*newsched)); - if (!newsched) { - return FTDM_MEMERR; - } - - if (ftdm_mutex_create(&newsched->mutex) != FTDM_SUCCESS) { - goto failed; - } - - ftdm_set_string(newsched->name, name); - newsched->currid = 1; - - *sched = newsched; - ftdm_log(FTDM_LOG_DEBUG, "Created schedule %s\n", name); - return FTDM_SUCCESS; - -failed: - ftdm_log(FTDM_LOG_CRIT, "Failed to create schedule\n"); - - if (newsched) { - if (newsched->mutex) { - ftdm_mutex_destroy(&newsched->mutex); - } - ftdm_safe_free(newsched); - } - return FTDM_FAIL; -} - -FT_DECLARE(ftdm_status_t) ftdm_sched_run(ftdm_sched_t *sched) -{ - ftdm_status_t status = FTDM_FAIL; - ftdm_timer_t *runtimer; - ftdm_timer_t *timer; - ftdm_sched_callback_t callback; - int ms = 0; - int rc = -1; - void *data; - struct timeval now; - - ftdm_assert_return(sched != NULL, FTDM_EINVAL, "sched is null!\n"); - -tryagain: - - ftdm_mutex_lock(sched->mutex); - - rc = gettimeofday(&now, NULL); - if (rc == -1) { - ftdm_log(FTDM_LOG_ERROR, "Failed to retrieve time of day\n"); - goto done; - } - - timer = sched->timers; - while (timer) { - runtimer = timer; - timer = runtimer->next; - - ms = ((runtimer->time.tv_sec - now.tv_sec) * 1000) + - ((runtimer->time.tv_usec - now.tv_usec) / 1000); - - if (ms <= 0) { - - if (runtimer == sched->timers) { - sched->timers = runtimer->next; - if (sched->timers) { - sched->timers->prev = NULL; - } - } - - callback = runtimer->callback; - data = runtimer->usrdata; - if (runtimer->next) { - runtimer->next->prev = runtimer->prev; - } - if (runtimer->prev) { - runtimer->prev->next = runtimer->next; - } - - runtimer->id = 0; - ftdm_safe_free(runtimer); - - /* avoid deadlocks by releasing the sched lock before triggering callbacks */ - ftdm_mutex_unlock(sched->mutex); - - callback(data); - /* after calling a callback we must start the scanning again since the - * callback or some other thread may have added or cancelled timers to - * the linked list */ - goto tryagain; - } - } - - status = FTDM_SUCCESS; -done: - ftdm_mutex_unlock(sched->mutex); - ftdm_unused_arg(sched); - return status; -} - -FT_DECLARE(ftdm_status_t) ftdm_sched_timer(ftdm_sched_t *sched, const char *name, - int ms, ftdm_sched_callback_t callback, void *data, ftdm_timer_id_t *timerid) -{ - ftdm_status_t status = FTDM_FAIL; - struct timeval now; - int rc = 0; - ftdm_timer_t *newtimer; - - ftdm_assert_return(sched != NULL, FTDM_EINVAL, "sched is null!\n"); - ftdm_assert_return(name != NULL, FTDM_EINVAL, "timer name is null!\n"); - ftdm_assert_return(callback != NULL, FTDM_EINVAL, "sched callback is null!\n"); - ftdm_assert_return(ms > 0, FTDM_EINVAL, "milliseconds must be bigger than 0!\n"); - - if (timerid) { - *timerid = 0; - } - - rc = gettimeofday(&now, NULL); - if (rc == -1) { - ftdm_log(FTDM_LOG_ERROR, "Failed to retrieve time of day\n"); - return FTDM_FAIL; - } - - ftdm_mutex_lock(sched->mutex); - - newtimer = ftdm_calloc(1, sizeof(*newtimer)); - if (!newtimer) { - goto done; - } - newtimer->id = sched->currid; - sched->currid++; - if (!sched->currid) { - ftdm_log(FTDM_LOG_NOTICE, "Timer id wrap around for sched %s\n", sched->name); - /* we do not want currid to be zero since is an invalid id - * TODO: check that currid does not exists already in the context, it'd be insane - * though, having a timer to live all that time */ - sched->currid++; - } - - ftdm_set_string(newtimer->name, name); - newtimer->callback = callback; - newtimer->usrdata = data; - - newtimer->time.tv_sec = now.tv_sec + (ms / 1000); - newtimer->time.tv_usec = now.tv_usec + (ms % 1000) * 1000; - if (newtimer->time.tv_usec >= FTDM_MICROSECONDS_PER_SECOND) { - newtimer->time.tv_sec += 1; - newtimer->time.tv_usec -= FTDM_MICROSECONDS_PER_SECOND; - } - - if (!sched->timers) { - sched->timers = newtimer; - } else { - newtimer->next = sched->timers; - sched->timers->prev = newtimer; - sched->timers = newtimer; - } - - if (timerid) { - *timerid = newtimer->id; - } - - status = FTDM_SUCCESS; -done: - ftdm_mutex_unlock(sched->mutex); - ftdm_unused_arg(sched); - ftdm_unused_arg(name); - ftdm_unused_arg(ms); - ftdm_unused_arg(callback); - ftdm_unused_arg(data); - ftdm_unused_arg(timerid); - return status; -} - -FT_DECLARE(ftdm_status_t) ftdm_sched_get_time_to_next_timer(const ftdm_sched_t *sched, int32_t *timeto) -{ - ftdm_status_t status = FTDM_FAIL; - int res = -1; - int ms = 0; - struct timeval currtime; - ftdm_timer_t *current = NULL; - ftdm_timer_t *winner = NULL; - - /* forever by default */ - *timeto = -1; - - ftdm_mutex_lock(sched->mutex); - - res = gettimeofday(&currtime, NULL); - if (-1 == res) { - ftdm_log(FTDM_LOG_ERROR, "Failed to get next event time\n"); - goto done; - } - status = FTDM_SUCCESS; - current = sched->timers; - while (current) { - /* if no winner, set this as winner */ - if (!winner) { - winner = current; - } - current = current->next; - /* if no more timers, return the winner */ - if (!current) { - ms = (((winner->time.tv_sec - currtime.tv_sec) * 1000) + - ((winner->time.tv_usec - currtime.tv_usec) / 1000)); - - /* if the timer is expired already, return 0 to attend immediately */ - if (ms < 0) { - *timeto = 0; - break; - } - *timeto = ms; - break; - } - - /* if the winner timer is after the current timer, then we have a new winner */ - if (winner->time.tv_sec > current->time.tv_sec - || (winner->time.tv_sec == current->time.tv_sec && - winner->time.tv_usec > current->time.tv_usec)) { - winner = current; - } - } - -done: - ftdm_mutex_unlock(sched->mutex); - ftdm_unused_arg(timeto); - ftdm_unused_arg(sched); - return status; -} - -FT_DECLARE(ftdm_status_t) ftdm_sched_cancel_timer(ftdm_sched_t *sched, ftdm_timer_id_t timerid) -{ - ftdm_status_t status = FTDM_FAIL; - ftdm_timer_t *timer; - - ftdm_assert_return(sched != NULL, FTDM_EINVAL, "sched is null!\n"); - - if (!timerid) { - return FTDM_SUCCESS; - } - - ftdm_mutex_lock(sched->mutex); - - /* look for the timer and destroy it */ - for (timer = sched->timers; timer; timer = timer->next) { - if (timer->id == timerid) { - if (timer == sched->timers) { - /* it's the head timer, put a new head */ - sched->timers = timer->next; - } - if (timer->prev) { - timer->prev->next = timer->next; - } - if (timer->next) { - timer->next->prev = timer->prev; - } - ftdm_safe_free(timer); - status = FTDM_SUCCESS; - break; - } - } - - ftdm_mutex_unlock(sched->mutex); - - return status; -} - -FT_DECLARE(ftdm_status_t) ftdm_sched_destroy(ftdm_sched_t **insched) -{ - ftdm_sched_t *sched = NULL; - ftdm_timer_t *timer; - ftdm_timer_t *deltimer; - ftdm_assert_return(insched != NULL, FTDM_EINVAL, "sched is null!\n"); - ftdm_assert_return(*insched != NULL, FTDM_EINVAL, "sched is null!\n"); - - sched = *insched; - - /* since destroying a sched may affect the global list, we gotta check */ - ftdm_mutex_lock(sched_globals.mutex); - - /* if we're head, replace head with our next (whatever our next is, even null will do) */ - if (sched == sched_globals.freeruns) { - sched_globals.freeruns = sched->next; - } - /* if we have a previous member (then we were not head) set our previous next to our next */ - if (sched->prev) { - sched->prev->next = sched->next; - } - /* if we have a next then set their prev to our prev (if we were head prev will be null and sched->next is already the new head) */ - if (sched->next) { - sched->next->prev = sched->prev; - } - - ftdm_mutex_unlock(sched_globals.mutex); - - /* now grab the sched mutex */ - ftdm_mutex_lock(sched->mutex); - - timer = sched->timers; - while (timer) { - deltimer = timer; - timer = timer->next; - ftdm_safe_free(deltimer); - } - - ftdm_log(FTDM_LOG_DEBUG, "Destroying schedule %s\n", sched->name); - - ftdm_mutex_unlock(sched->mutex); - - ftdm_mutex_destroy(&sched->mutex); - - ftdm_safe_free(sched); - - *insched = NULL; - return FTDM_SUCCESS; -} - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/ftdm_state.c b/libs/freetdm/src/ftdm_state.c deleted file mode 100644 index f6bc0ef4c4..0000000000 --- a/libs/freetdm/src/ftdm_state.c +++ /dev/null @@ -1,575 +0,0 @@ -/* - * Copyright (c) 2010, Sangoma Technologies - * Moises Silva - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "private/ftdm_core.h" - -FTDM_ENUM_NAMES(CHANNEL_STATE_NAMES, CHANNEL_STATE_STRINGS) -FTDM_STR2ENUM(ftdm_str2ftdm_channel_state, ftdm_channel_state2str, ftdm_channel_state_t, CHANNEL_STATE_NAMES, FTDM_CHANNEL_STATE_INVALID) - -FTDM_ENUM_NAMES(CHANNEL_STATE_STATUS_NAMES, CHANNEL_STATE_STATUS_STRINGS) -FTDM_STR2ENUM(ftdm_str2ftdm_state_status, ftdm_state_status2str, ftdm_state_status_t, CHANNEL_STATE_STATUS_NAMES, FTDM_STATE_STATUS_INVALID) - -static ftdm_status_t ftdm_core_set_state(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_channel_state_t state, int waitrq); - -FT_DECLARE(ftdm_status_t) _ftdm_channel_complete_state(const char *file, const char *func, int line, ftdm_channel_t *fchan) -{ - uint8_t hindex = 0; - ftdm_time_t diff = 0; - ftdm_channel_state_t state = fchan->state; - -#if 0 - /* I could not perform this sanity check without more disruptive changes. Ideally we should check here if the signaling module completing the state - executed a state processor (called ftdm_channel_advance_states() which call fchan->span->state_processor(fchan)) for the state. That is just a - sanity check, as in the past we had at least one bug where the signaling module set the state and then accidentally changed the state to a new one - without calling ftdm_channel_advance_states(), meaning the state processor for the first state was not executed and that lead to unexpected behavior. - - If we want to be able to perform this kind of sanity check it would be nice to add a new state status (FTDM_STATE_STATUS_PROCESSING), the function - ftdm_channel_advance_states() would set the state_status to PROCESSING and then the check below for STATUS_NEW would be valid. Currently is not - valid because the signaling module may be completing the state at the end of the state_processor callback and therefore the state will still be - in STATUS_NEW, and is perfectly valid ... */ - - if (fchan->state_status == FTDM_STATE_STATUS_NEW) { - ftdm_log_chan_ex(fchan, file, func, line, FTDM_LOG_LEVEL_CRIT, - "Asking to complete state change from %s to %s in %llums, but the state is still unprocessed (this might be a bug!)\n", - ftdm_channel_state2str(fchan->last_state), ftdm_channel_state2str(state), diff); - } -#endif - - if (fchan->state_status == FTDM_STATE_STATUS_COMPLETED) { - ftdm_assert_return(!ftdm_test_flag(fchan, FTDM_CHANNEL_STATE_CHANGE), FTDM_FAIL, "State change flag set but state is already completed\n"); - return FTDM_SUCCESS; - } - - ftdm_usrmsg_free(&fchan->usrmsg); - - ftdm_clear_flag(fchan, FTDM_CHANNEL_STATE_CHANGE); - - if (state == FTDM_CHANNEL_STATE_PROGRESS) { - ftdm_set_flag(fchan, FTDM_CHANNEL_PROGRESS); - } else if (state == FTDM_CHANNEL_STATE_PROGRESS_MEDIA) { - ftdm_set_flag(fchan, FTDM_CHANNEL_PROGRESS); - ftdm_test_and_set_media(fchan); - } else if (state == FTDM_CHANNEL_STATE_UP) { - ftdm_set_flag(fchan, FTDM_CHANNEL_PROGRESS); - ftdm_set_flag(fchan, FTDM_CHANNEL_ANSWERED); - ftdm_test_and_set_media(fchan); - } else if (state == FTDM_CHANNEL_STATE_DIALING) { - ftdm_sigmsg_t msg; - memset(&msg, 0, sizeof(msg)); - msg.channel = fchan; - msg.event_id = FTDM_SIGEVENT_DIALING; - ftdm_span_send_signal(fchan->span, &msg); - } else if (state == FTDM_CHANNEL_STATE_HANGUP) { - ftdm_set_echocancel_call_end(fchan); - } - - /* MAINTENANCE WARNING - * we're assuming an indication performed - * via state change will involve a single state change */ - ftdm_ack_indication(fchan, fchan->indication, FTDM_SUCCESS); - - hindex = (fchan->hindex == 0) ? (ftdm_array_len(fchan->history) - 1) : (fchan->hindex - 1); - - ftdm_assert(!fchan->history[hindex].end_time, "End time should be zero!\n"); - - fchan->history[hindex].end_time = ftdm_current_time_in_ms(); - fchan->last_state_change_time = ftdm_current_time_in_ms(); - - fchan->state_status = FTDM_STATE_STATUS_COMPLETED; - - diff = fchan->history[hindex].end_time - fchan->history[hindex].time; - - ftdm_log_chan_ex(fchan, file, func, line, FTDM_LOG_LEVEL_DEBUG, "Completed state change from %s to %s in %"FTDM_TIME_FMT" ms\n", - ftdm_channel_state2str(fchan->last_state), ftdm_channel_state2str(state), diff); - - - if (ftdm_test_flag(fchan, FTDM_CHANNEL_BLOCKING)) { - ftdm_clear_flag(fchan, FTDM_CHANNEL_BLOCKING); - ftdm_interrupt_signal(fchan->state_completed_interrupt); - } - - return FTDM_SUCCESS; -} - -FT_DECLARE(ftdm_status_t) _ftdm_set_state(const char *file, const char *func, int line, - ftdm_channel_t *fchan, ftdm_channel_state_t state) -{ - if (fchan->state_status != FTDM_STATE_STATUS_COMPLETED) { - /* the current state is not completed, setting a new state from a signaling module - when the current state is not completed is equivalent to implicitly acknowledging - the current state */ - _ftdm_channel_complete_state(file, func, line, fchan); - } - return ftdm_core_set_state(file, func, line, fchan, state, 0); -} - -static int ftdm_parse_state_map(ftdm_channel_t *ftdmchan, ftdm_channel_state_t state, ftdm_state_map_t *state_map) -{ - int x = 0, ok = 0; - ftdm_state_direction_t direction = ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND) ? ZSD_OUTBOUND : ZSD_INBOUND; - - for(x = 0; x < FTDM_MAP_NODE_SIZE; x++) { - int i = 0, proceed = 0; - if (!state_map->nodes[x].type) { - break; - } - - if (state_map->nodes[x].direction != direction) { - continue; - } - - if (state_map->nodes[x].check_states[0] == FTDM_CHANNEL_STATE_ANY) { - proceed = 1; - } else { - for(i = 0; i < FTDM_MAP_MAX; i++) { - if (state_map->nodes[x].check_states[i] == ftdmchan->state) { - proceed = 1; - break; - } - } - } - - if (!proceed) { - continue; - } - - for(i = 0; i < FTDM_MAP_MAX; i++) { - ok = (state_map->nodes[x].type == ZSM_ACCEPTABLE); - if (state_map->nodes[x].states[i] == FTDM_CHANNEL_STATE_END) { - break; - } - if (state_map->nodes[x].states[i] == state) { - ok = !ok; - goto end; - } - } - } - end: - - return ok; -} - -FT_DECLARE(ftdm_status_t) ftdm_channel_cancel_state(const char *file, const char *func, int line, ftdm_channel_t *fchan) -{ - ftdm_time_t diff; - ftdm_channel_state_t state; - ftdm_channel_state_t last_state; - uint8_t hindex = 0; - - if (!ftdm_test_flag(fchan, FTDM_CHANNEL_STATE_CHANGE)) { - ftdm_log_chan(fchan, FTDM_LOG_WARNING, "Cannot cancel state change from %s to %s, it was already processed\n", - ftdm_channel_state2str(fchan->last_state), ftdm_channel_state2str(fchan->state)); - return FTDM_FAIL; - } - - if (fchan->state_status != FTDM_STATE_STATUS_NEW) { - ftdm_log_chan(fchan, FTDM_LOG_WARNING, "Failed to cancel state change from %s to %s, state is not new anymore\n", - ftdm_channel_state2str(fchan->last_state), ftdm_channel_state2str(fchan->state)); - return FTDM_FAIL; - } - - /* compute the last history index */ - hindex = (fchan->hindex == 0) ? (ftdm_array_len(fchan->history) - 1) : (fchan->hindex - 1); - diff = fchan->history[hindex].end_time - fchan->history[hindex].time; - - /* go back in time and revert the state to the previous state */ - state = fchan->state; - last_state = fchan->last_state; - - fchan->state = fchan->last_state; - fchan->state_status = FTDM_STATE_STATUS_COMPLETED; - fchan->last_state = fchan->history[hindex].last_state; - fchan->hindex = hindex; - - /* clear the state change flag */ - ftdm_clear_flag(fchan, FTDM_CHANNEL_STATE_CHANGE); - - /* ack any pending indications as cancelled */ - ftdm_ack_indication(fchan, fchan->indication, FTDM_ECANCELED); - - /* wake up anyone sleeping waiting for the state change to complete, it won't ever be completed */ - if (ftdm_test_flag(fchan, FTDM_CHANNEL_BLOCKING)) { - ftdm_clear_flag(fchan, FTDM_CHANNEL_BLOCKING); - ftdm_interrupt_signal(fchan->state_completed_interrupt); - } - - /* NOTE - * we could potentially also take out the channel from the pendingchans queue, but I believe is easier just leave it, - * the only side effect will be a call to ftdm_channel_advance_states() for a channel that has nothing to advance */ - ftdm_log_chan_ex(fchan, file, func, line, FTDM_LOG_LEVEL_DEBUG, "Cancelled state change from %s to %s in %"FTDM_TIME_FMT" ms\n", - ftdm_channel_state2str(last_state), ftdm_channel_state2str(state), diff); - - return FTDM_SUCCESS; -} - - -FT_DECLARE(ftdm_status_t) ftdm_channel_set_state(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_channel_state_t state, int waitrq, ftdm_usrmsg_t *usrmsg) -{ - ftdm_channel_save_usrmsg(ftdmchan, usrmsg); - - if (ftdm_core_set_state(file, func, line, ftdmchan, state, waitrq) != FTDM_SUCCESS) { - ftdm_usrmsg_free(&ftdmchan->usrmsg); - } - return FTDM_SUCCESS; -} - -/* this function MUST be called with the channel lock held. If waitrq == 1, the channel will be unlocked/locked (never call it with waitrq == 1 with an lock recursivity > 1) */ -#define DEFAULT_WAIT_TIME 1000 -static ftdm_status_t ftdm_core_set_state(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_channel_state_t state, int waitrq) -{ - ftdm_status_t status; - int ok = 1; - int waitms = DEFAULT_WAIT_TIME; - - if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_READY)) { - ftdm_log_chan_ex(ftdmchan, file, func, line, FTDM_LOG_LEVEL_ERROR, "Ignored state change request from %s to %s, the channel is not ready\n", - ftdm_channel_state2str(ftdmchan->state), ftdm_channel_state2str(state)); - return FTDM_FAIL; - } - - if (ftdmchan->state_status != FTDM_STATE_STATUS_COMPLETED) { - ftdm_log_chan_ex(ftdmchan, file, func, line, FTDM_LOG_LEVEL_ERROR, - "Ignored state change request from %s to %s, the previous state change has not been processed yet (status = %s)\n", - ftdm_channel_state2str(ftdmchan->state), ftdm_channel_state2str(state), - ftdm_state_status2str(ftdmchan->state_status)); - return FTDM_FAIL; - } - - if (ftdmchan->state == state) { - ftdm_log_chan_ex(ftdmchan, file, func, line, FTDM_LOG_LEVEL_WARNING, "Why bother changing state from %s to %s\n", ftdm_channel_state2str(ftdmchan->state), ftdm_channel_state2str(state)); - return FTDM_FAIL; - } - - if (!ftdmchan->state_completed_interrupt) { - status = ftdm_interrupt_create(&ftdmchan->state_completed_interrupt, FTDM_INVALID_SOCKET, FTDM_NO_FLAGS); - if (status != FTDM_SUCCESS) { - ftdm_log_chan_ex(ftdmchan, file, func, line, FTDM_LOG_LEVEL_CRIT, - "Failed to create state change interrupt when moving from %s to %s\n", ftdm_channel_state2str(ftdmchan->state), ftdm_channel_state2str(state)); - return status; - } - } - - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_NATIVE_SIGBRIDGE)) { - goto perform_state_change; - } - - if (ftdmchan->span->state_map) { - ok = ftdm_parse_state_map(ftdmchan, state, ftdmchan->span->state_map); - goto end; - } - - /* basic core state validation (by-passed if the signaling module provides a state_map) */ - switch(ftdmchan->state) { - case FTDM_CHANNEL_STATE_HANGUP: - case FTDM_CHANNEL_STATE_TERMINATING: - { - ok = 0; - switch(state) { - case FTDM_CHANNEL_STATE_DOWN: - case FTDM_CHANNEL_STATE_BUSY: - case FTDM_CHANNEL_STATE_RESTART: - ok = 1; - break; - default: - break; - } - } - break; - case FTDM_CHANNEL_STATE_UP: - { - ok = 1; - switch(state) { - case FTDM_CHANNEL_STATE_PROGRESS: - case FTDM_CHANNEL_STATE_PROGRESS_MEDIA: - case FTDM_CHANNEL_STATE_RING: - ok = 0; - break; - default: - break; - } - } - break; - case FTDM_CHANNEL_STATE_DOWN: - { - ok = 0; - - switch(state) { - case FTDM_CHANNEL_STATE_DIALTONE: - case FTDM_CHANNEL_STATE_COLLECT: - case FTDM_CHANNEL_STATE_DIALING: - case FTDM_CHANNEL_STATE_RING: - case FTDM_CHANNEL_STATE_PROGRESS_MEDIA: - case FTDM_CHANNEL_STATE_PROGRESS: - case FTDM_CHANNEL_STATE_IDLE: - case FTDM_CHANNEL_STATE_GET_CALLERID: - case FTDM_CHANNEL_STATE_GENRING: - ok = 1; - break; - default: - break; - } - } - break; - case FTDM_CHANNEL_STATE_BUSY: - { - switch(state) { - case FTDM_CHANNEL_STATE_UP: - ok = 0; - break; - default: - break; - } - } - break; - case FTDM_CHANNEL_STATE_RING: - { - switch(state) { - case FTDM_CHANNEL_STATE_UP: - ok = 1; - break; - default: - break; - } - } - break; - default: - break; - } - -end: - - if (!ok) { - ftdm_log_chan_ex(ftdmchan, file, func, line, FTDM_LOG_LEVEL_WARNING, "VETO state change from %s to %s\n", ftdm_channel_state2str(ftdmchan->state), ftdm_channel_state2str(state)); - goto done; - } - -perform_state_change: - - ftdm_log_chan_ex(ftdmchan, file, func, line, FTDM_LOG_LEVEL_DEBUG, "Changed state from %s to %s\n", ftdm_channel_state2str(ftdmchan->state), ftdm_channel_state2str(state)); - ftdmchan->last_state = ftdmchan->state; - ftdmchan->state = state; - ftdmchan->state_status = FTDM_STATE_STATUS_NEW; - ftdmchan->history[ftdmchan->hindex].file = file; - ftdmchan->history[ftdmchan->hindex].func = func; - ftdmchan->history[ftdmchan->hindex].line = line; - ftdmchan->history[ftdmchan->hindex].state = ftdmchan->state; - ftdmchan->history[ftdmchan->hindex].last_state = ftdmchan->last_state; - ftdmchan->history[ftdmchan->hindex].time = ftdm_current_time_in_ms(); - ftdmchan->history[ftdmchan->hindex].end_time = 0; - ftdmchan->hindex++; - if (ftdmchan->hindex == ftdm_array_len(ftdmchan->history)) { - ftdmchan->hindex = 0; - } - ftdm_set_flag(ftdmchan, FTDM_CHANNEL_STATE_CHANGE); - - if (ftdmchan->span->pendingchans) { - ftdm_queue_enqueue(ftdmchan->span->pendingchans, ftdmchan); - } else { - /* there is a potential deadlock here, if a signaling module is processing - * state changes while the ftdm_span_stop() function is called, the signaling - * thread will block until it can acquire the span lock, but the thread calling - * ftdm_span_stop() which holds the span lock is waiting on the signaling thread - * to finish ... The only reason to acquire the span lock is this flag, new - * signaling modules should use the pendingchans queue instead of this flag, - * as of today a few modules need still to be updated before we can get rid of - * this flag (ie, ftmod_libpri, ftmod_isdn, ftmod_analog) */ - ftdm_set_flag_locked(ftdmchan->span, FTDM_SPAN_STATE_CHANGE); - } - - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_NONBLOCK)) { - /* the channel should not block waiting for state processing */ - goto done; - } - - if (!waitrq) { - /* no waiting was requested */ - goto done; - } - - /* let's wait for the state change to be completed by the signaling stack */ - ftdm_set_flag(ftdmchan, FTDM_CHANNEL_BLOCKING); - - ftdm_mutex_unlock(ftdmchan->mutex); - - status = ftdm_interrupt_wait(ftdmchan->state_completed_interrupt, waitms); - - ftdm_mutex_lock(ftdmchan->mutex); - - if (status != FTDM_SUCCESS) { - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_BLOCKING); - ftdm_log_chan_ex(ftdmchan, file, func, line, - FTDM_LOG_LEVEL_WARNING, "state change from %s to %s was most likely not completed after aprox %dms\n", - ftdm_channel_state2str(ftdmchan->last_state), ftdm_channel_state2str(state), DEFAULT_WAIT_TIME); - ok = 0; - goto done; - } -done: - return ok ? FTDM_SUCCESS : FTDM_FAIL; -} - -FT_DECLARE(int) ftdm_channel_get_state(const ftdm_channel_t *ftdmchan) -{ - int state; - ftdm_channel_lock(ftdmchan); - state = ftdmchan->state; - ftdm_channel_unlock(ftdmchan); - return state; -} - -FT_DECLARE(const char *) ftdm_channel_get_state_str(const ftdm_channel_t *ftdmchan) -{ - const char *state; - ftdm_channel_lock(ftdmchan); - state = ftdm_channel_state2str(ftdmchan->state); - ftdm_channel_unlock(ftdmchan); - return state; -} - -FT_DECLARE(int) ftdm_channel_get_last_state(const ftdm_channel_t *ftdmchan) -{ - int last_state; - ftdm_channel_lock(ftdmchan); - last_state = ftdmchan->last_state; - ftdm_channel_unlock(ftdmchan); - return last_state; -} - -FT_DECLARE(const char *) ftdm_channel_get_last_state_str(const ftdm_channel_t *ftdmchan) -{ - const char *state; - ftdm_channel_lock(ftdmchan); - state = ftdm_channel_state2str(ftdmchan->last_state); - ftdm_channel_unlock(ftdmchan); - return state; -} - -static void write_history_entry(const ftdm_channel_t *fchan, ftdm_stream_handle_t *stream, int i, ftdm_time_t *prevtime) -{ - char func[255]; - char line[255]; - char states[255]; - const char *filename = NULL; - snprintf(states, sizeof(states), "%-5.15s => %-5.15s", ftdm_channel_state2str(fchan->history[i].last_state), ftdm_channel_state2str(fchan->history[i].state)); - snprintf(func, sizeof(func), "[%s]", fchan->history[i].func); - filename = strrchr(fchan->history[i].file, *FTDM_PATH_SEPARATOR); - if (!filename) { - filename = fchan->history[i].file; - } else { - filename++; - } - if (!(*prevtime)) { - *prevtime = fchan->history[i].time; - } - snprintf(line, sizeof(func), "[%s:%d]", filename, fchan->history[i].line); - stream->write_function(stream, "%-30.30s %-30.30s %-30.30s %lums\n", states, func, line, (fchan->history[i].time - *prevtime)); - *prevtime = fchan->history[i].time; -} - -FT_DECLARE(char *) ftdm_channel_get_history_str(const ftdm_channel_t *fchan) -{ - uint8_t i = 0; - ftdm_time_t currtime = 0; - ftdm_time_t prevtime = 0; - - ftdm_stream_handle_t stream = { 0 }; - FTDM_STANDARD_STREAM(stream); - if (!fchan->history[0].file) { - stream.write_function(&stream, "-- No state history --\n"); - return stream.data; - } - - stream.write_function(&stream, "%-30.30s %-30.30s %-30.30s %s", - "-- States --", "-- Function --", "-- Location --", "-- Time Offset --\n"); - - for (i = fchan->hindex; i < ftdm_array_len(fchan->history); i++) { - if (!fchan->history[i].file) { - break; - } - write_history_entry(fchan, &stream, i, &prevtime); - } - - for (i = 0; i < fchan->hindex; i++) { - write_history_entry(fchan, &stream, i, &prevtime); - } - - currtime = ftdm_current_time_in_ms(); - - stream.write_function(&stream, "\nTime since last state change: %lums\n", (currtime - prevtime)); - - return stream.data; -} - -FT_DECLARE(ftdm_status_t) ftdm_channel_advance_states(ftdm_channel_t *fchan) -{ - ftdm_channel_state_t state; - - ftdm_assert_return(fchan->span->state_processor, FTDM_FAIL, "Cannot process states without a state processor!\n"); - - while (fchan->state_status == FTDM_STATE_STATUS_NEW) { - state = fchan->state; - ftdm_log_chan(fchan, FTDM_LOG_DEBUG, "Executing state processor for %s\n", ftdm_channel_state2str(fchan->state)); - fchan->span->state_processor(fchan); - if (state == fchan->state && fchan->state_status == FTDM_STATE_STATUS_NEW) { - /* if the state did not change and is still NEW, the state status must go to PROCESSED - * otherwise we don't touch it since is a new state and the old state was - * already completed implicitly by the state_processor() function via some internal - * call to ftdm_set_state() */ - fchan->state_status = FTDM_STATE_STATUS_PROCESSED; - } - } - - return FTDM_SUCCESS; -} - -FT_DECLARE(int) ftdm_check_state_all(ftdm_span_t *span, ftdm_channel_state_t state) -{ - uint32_t j; - for(j = 1; j <= span->chan_count; j++) { - if (span->channels[j]->state != state || ftdm_test_flag(span->channels[j], FTDM_CHANNEL_STATE_CHANGE)) { - return 0; - } - } - return 1; -} - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/ftdm_threadmutex.c b/libs/freetdm/src/ftdm_threadmutex.c deleted file mode 100644 index 6dc2c64f8f..0000000000 --- a/libs/freetdm/src/ftdm_threadmutex.c +++ /dev/null @@ -1,635 +0,0 @@ -/* - * Cross Platform Thread/Mutex abstraction - * Copyright(C) 2007 Michael Jerris - * - * You may opt to use, copy, modify, merge, publish, distribute and/or sell - * copies of the Software, and permit persons to whom the Software is - * furnished to do so. - * - * This work is provided under this license on an "as is" basis, without warranty of any kind, - * either expressed or implied, including, without limitation, warranties that the covered code - * is free of defects, merchantable, fit for a particular purpose or non-infringing. The entire - * risk as to the quality and performance of the covered code is with you. Should any covered - * code prove defective in any respect, you (not the initial developer or any other contributor) - * assume the cost of any necessary servicing, repair or correction. This disclaimer of warranty - * constitutes an essential part of this license. No use of any covered code is authorized hereunder - * except under this disclaimer. - * - * Contributors: - * - * Moises Silva - * - */ - -#ifdef WIN32 -# if (_WIN32_WINNT < 0x0400) -# error "Need to target at least Windows 95/WINNT 4.0 because TryEnterCriticalSection is needed" -# endif -# include -#endif -/*#define FTDM_DEBUG_MUTEX 0*/ - -#include "private/ftdm_core.h" -#include "ftdm_threadmutex.h" - -#ifdef WIN32 -#include - -#define FTDM_THREAD_CALLING_CONVENTION __stdcall - -struct ftdm_mutex { - CRITICAL_SECTION mutex; -}; - -#else -#include -#include - -#define FTDM_THREAD_CALLING_CONVENTION - -#ifdef FTDM_DEBUG_MUTEX -#define FTDM_MUTEX_MAX_REENTRANCY 30 -typedef struct ftdm_lock_entry { - const char *file; - const char *func; - uint32_t line; -} ftdm_lock_entry_t; - -typedef struct ftdm_lock_history { - ftdm_lock_entry_t locked; - ftdm_lock_entry_t unlocked; -} ftdm_lock_history_t; -#endif - -struct ftdm_mutex { - pthread_mutex_t mutex; -#ifdef FTDM_DEBUG_MUTEX - ftdm_lock_history_t lock_history[FTDM_MUTEX_MAX_REENTRANCY]; - uint8_t reentrancy; -#endif -}; - -#endif - -struct ftdm_interrupt { - ftdm_socket_t device; - ftdm_wait_flag_t device_input_flags; - ftdm_wait_flag_t device_output_flags; -#ifdef WIN32 - /* for generic interruption */ - HANDLE event; -#else - /* In theory we could be using thread conditions for generic interruption, - * however, Linux does not have a primitive like Windows WaitForMultipleObjects - * to wait for both thread condition and file descriptors, therefore we decided - * to use a dummy pipe for generic interruption/condition logic - * */ - int readfd; - int writefd; -#endif -}; - -struct ftdm_thread { -#ifdef WIN32 - void *handle; -#else - pthread_t handle; -#endif - void *private_data; - ftdm_thread_function_t function; - ftdm_size_t stack_size; -#ifndef WIN32 - pthread_attr_t attribute; -#endif -}; - -ftdm_size_t thread_default_stacksize = 0; - -FT_DECLARE(void) ftdm_thread_override_default_stacksize(ftdm_size_t size) -{ - thread_default_stacksize = size; -} - -static void * FTDM_THREAD_CALLING_CONVENTION thread_launch(void *args) -{ - void *exit_val; - ftdm_thread_t *thread = (ftdm_thread_t *)args; - exit_val = thread->function(thread, thread->private_data); -#ifndef WIN32 - pthread_attr_destroy(&thread->attribute); -#endif - ftdm_safe_free(thread); - - return exit_val; -} - -FT_DECLARE(ftdm_status_t) ftdm_thread_create_detached(ftdm_thread_function_t func, void *data) -{ - return ftdm_thread_create_detached_ex(func, data, thread_default_stacksize); -} - -FT_DECLARE(ftdm_status_t) ftdm_thread_create_detached_ex(ftdm_thread_function_t func, void *data, ftdm_size_t stack_size) -{ - ftdm_thread_t *thread = NULL; - ftdm_status_t status = FTDM_FAIL; - - if (!func || !(thread = (ftdm_thread_t *)ftdm_calloc(1, sizeof(ftdm_thread_t)))) { - goto done; - } - - thread->private_data = data; - thread->function = func; - thread->stack_size = stack_size; - -#if defined(WIN32) - thread->handle = (void *)_beginthreadex(NULL, (unsigned)thread->stack_size, (unsigned int (__stdcall *)(void *))thread_launch, thread, 0, NULL); - if (!thread->handle) { - goto fail; - } - CloseHandle(thread->handle); - - status = FTDM_SUCCESS; - goto done; -#else - - if (pthread_attr_init(&thread->attribute) != 0) goto fail; - - if (pthread_attr_setdetachstate(&thread->attribute, PTHREAD_CREATE_DETACHED) != 0) goto failpthread; - - if (thread->stack_size && pthread_attr_setstacksize(&thread->attribute, thread->stack_size) != 0) goto failpthread; - - if (pthread_create(&thread->handle, &thread->attribute, thread_launch, thread) != 0) goto failpthread; - - status = FTDM_SUCCESS; - goto done; - failpthread: - pthread_attr_destroy(&thread->attribute); -#endif - - fail: - if (thread) { - ftdm_safe_free(thread); - } - done: - return status; -} - - -FT_DECLARE(ftdm_status_t) ftdm_mutex_create(ftdm_mutex_t **mutex) -{ - ftdm_status_t status = FTDM_FAIL; -#ifndef WIN32 - pthread_mutexattr_t attr; -#endif - ftdm_mutex_t *check = NULL; - - check = (ftdm_mutex_t *)ftdm_calloc(1, sizeof(**mutex)); - if (!check) - goto done; -#ifdef WIN32 - InitializeCriticalSection(&check->mutex); -#else - if (pthread_mutexattr_init(&attr)) - goto done; - - if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE)) - goto fail; - - if (pthread_mutex_init(&check->mutex, &attr)) - goto fail; - - goto success; - - fail: - pthread_mutexattr_destroy(&attr); - goto done; - - success: -#endif - *mutex = check; - status = FTDM_SUCCESS; - - done: - return status; -} - -FT_DECLARE(ftdm_status_t) ftdm_mutex_destroy(ftdm_mutex_t **mutex) -{ - ftdm_mutex_t *mp = *mutex; - *mutex = NULL; - if (!mp) { - return FTDM_FAIL; - } -#ifdef WIN32 - DeleteCriticalSection(&mp->mutex); -#else - if (pthread_mutex_destroy(&mp->mutex)) - return FTDM_FAIL; -#endif - ftdm_safe_free(mp); - return FTDM_SUCCESS; -} - -#define ADD_LOCK_HISTORY(mutex, file, line, func) \ - { \ - if ((mutex)->reentrancy < FTDM_MUTEX_MAX_REENTRANCY) { \ - (mutex)->lock_history[mutex->reentrancy].locked.file = (file); \ - (mutex)->lock_history[mutex->reentrancy].locked.func = (func); \ - (mutex)->lock_history[mutex->reentrancy].locked.line = (line); \ - (mutex)->lock_history[mutex->reentrancy].unlocked.file = NULL; \ - (mutex)->lock_history[mutex->reentrancy].unlocked.func = NULL; \ - (mutex)->lock_history[mutex->reentrancy].unlocked.line = 0; \ - (mutex)->reentrancy++; \ - if ((mutex)->reentrancy == FTDM_MUTEX_MAX_REENTRANCY) { \ - ftdm_log((file), (func), (line), FTDM_LOG_LEVEL_ERROR, "Max reentrancy reached for mutex %p\n", (mutex)); \ - } \ - } \ - } - -FT_DECLARE(ftdm_status_t) _ftdm_mutex_lock(const char *file, int line, const char *func, ftdm_mutex_t *mutex) -{ -#ifdef WIN32 - ftdm_unused_arg(file); - ftdm_unused_arg(line); - ftdm_unused_arg(func); - - EnterCriticalSection(&mutex->mutex); -#else - int err; - if ((err = pthread_mutex_lock(&mutex->mutex))) { - ftdm_log(file, func, line, FTDM_LOG_LEVEL_ERROR, "Failed to lock mutex %d:%s\n", err, strerror(err)); - return FTDM_FAIL; - } -#endif -#ifdef FTDM_DEBUG_MUTEX - ADD_LOCK_HISTORY(mutex, file, line, func); -#endif - return FTDM_SUCCESS; -} - -FT_DECLARE(ftdm_status_t) _ftdm_mutex_trylock(const char *file, int line, const char *func, ftdm_mutex_t *mutex) -{ - ftdm_unused_arg(file); - ftdm_unused_arg(line); - ftdm_unused_arg(func); -#ifdef WIN32 - if (!TryEnterCriticalSection(&mutex->mutex)) - return FTDM_FAIL; -#else - if (pthread_mutex_trylock(&mutex->mutex)) - return FTDM_FAIL; -#endif -#ifdef FTDM_DEBUG_MUTEX - ADD_LOCK_HISTORY(mutex, file, line, func); -#endif - return FTDM_SUCCESS; -} - -FT_DECLARE(ftdm_status_t) _ftdm_mutex_unlock(const char *file, int line, const char *func, ftdm_mutex_t *mutex) -{ -#ifdef FTDM_DEBUG_MUTEX - int i = 0; - if (mutex->reentrancy == 0) { - ftdm_log(file, func, line, FTDM_LOG_LEVEL_ERROR, "Cannot unlock something that is not locked!\n"); - return FTDM_FAIL; - } - i = mutex->reentrancy - 1; - /* I think this is a fair assumption when debugging */ - if (func != mutex->lock_history[i].locked.func) { - ftdm_log(file, func, line, FTDM_LOG_LEVEL_WARNING, "Mutex %p was suspiciously locked at %s->%s:%d but unlocked at %s->%s:%d!\n", - mutex, mutex->lock_history[i].locked.func, mutex->lock_history[i].locked.file, mutex->lock_history[i].locked.line, - func, file, line); - } - mutex->lock_history[i].unlocked.file = file; - mutex->lock_history[i].unlocked.line = line; - mutex->lock_history[i].unlocked.func = func; - mutex->reentrancy--; -#endif -#ifdef WIN32 - ftdm_unused_arg(file); - ftdm_unused_arg(line); - ftdm_unused_arg(func); - - LeaveCriticalSection(&mutex->mutex); -#else - if (pthread_mutex_unlock(&mutex->mutex)) { - ftdm_log(file, func, line, FTDM_LOG_LEVEL_ERROR, "Failed to unlock mutex: %s\n", strerror(errno)); -#ifdef FTDM_DEBUG_MUTEX - mutex->reentrancy++; -#endif - return FTDM_FAIL; - } -#endif - return FTDM_SUCCESS; -} - - -FT_DECLARE(ftdm_status_t) ftdm_interrupt_create(ftdm_interrupt_t **ininterrupt, ftdm_socket_t device, ftdm_wait_flag_t device_flags) -{ - ftdm_status_t status = FTDM_SUCCESS; - ftdm_interrupt_t *interrupt = NULL; -#ifndef WIN32 - int fds[2]; -#endif - - ftdm_assert_return(ininterrupt != NULL, FTDM_FAIL, "interrupt double pointer is null!\n"); - - interrupt = ftdm_calloc(1, sizeof(*interrupt)); - if (!interrupt) { - ftdm_log(FTDM_LOG_ERROR, "Failed to allocate interrupt memory\n"); - return FTDM_ENOMEM; - } - - interrupt->device = device; - interrupt->device_input_flags = device_flags; -#ifdef WIN32 - interrupt->event = CreateEvent(NULL, FALSE, FALSE, NULL); - if (!interrupt->event) { - ftdm_log(FTDM_LOG_ERROR, "Failed to allocate interrupt event\n"); - status = FTDM_ENOMEM; - goto failed; - } -#else - if (pipe(fds)) { - ftdm_log(FTDM_LOG_ERROR, "Failed to allocate interrupt pipe: %s\n", strerror(errno)); - status = FTDM_FAIL; - goto failed; - } - interrupt->readfd = fds[0]; - interrupt->writefd = fds[1]; -#endif - - *ininterrupt = interrupt; - return FTDM_SUCCESS; - -failed: - if (interrupt) { -#ifndef WIN32 - if (interrupt->readfd) { - close(interrupt->readfd); - close(interrupt->writefd); - interrupt->readfd = -1; - interrupt->writefd = -1; - } -#endif - ftdm_safe_free(interrupt); - } - return status; -} - -#define ONE_BILLION 1000000000 - -FT_DECLARE(ftdm_status_t) ftdm_interrupt_wait(ftdm_interrupt_t *interrupt, int ms) -{ - int num = 1; -#ifdef WIN32 - DWORD res = 0; - HANDLE ints[2]; -#else - int res = 0; - struct pollfd ints[2]; - char pipebuf[255]; -#endif - - ftdm_assert_return(interrupt != NULL, FTDM_FAIL, "Interrupt is null!\n"); - - interrupt->device_output_flags = FTDM_NO_FLAGS; - /* start implementation */ -#ifdef WIN32 - ints[0] = interrupt->event; - if (interrupt->device != FTDM_INVALID_SOCKET) { - num++; - ints[1] = interrupt->device; - ftdm_log(FTDM_LOG_CRIT, "implement me! (Windows support for device_output_flags member!)\n"); - } - res = WaitForMultipleObjects(num, ints, FALSE, ms >= 0 ? ms : INFINITE); - switch (res) { - case WAIT_TIMEOUT: - return FTDM_TIMEOUT; - case WAIT_FAILED: - case WAIT_ABANDONED: /* is it right to fail with abandoned? */ - return FTDM_FAIL; - default: - if (res >= (sizeof(ints)/sizeof(ints[0]))) { - ftdm_log(FTDM_LOG_ERROR, "Error waiting for freetdm interrupt event (WaitForSingleObject returned %d)\n", res); - return FTDM_FAIL; - } - return FTDM_SUCCESS; - } -#else -pollagain: - ints[0].fd = interrupt->readfd; - ints[0].events = POLLIN; - ints[0].revents = 0; - - if (interrupt->device != FTDM_INVALID_SOCKET) { - num++; - ints[1].fd = interrupt->device; - ints[1].events = interrupt->device_input_flags; - ints[1].revents = 0; - } - - res = poll(ints, num, ms); - - if (res == -1) { - if (errno == EINTR) { - goto pollagain; - } - ftdm_log(FTDM_LOG_CRIT, "interrupt poll failed (%s)\n", strerror(errno)); - return FTDM_FAIL; - } - - if (res == 0) { - return FTDM_TIMEOUT; - } - - if (ints[0].revents & POLLIN) { - res = read(ints[0].fd, pipebuf, sizeof(pipebuf)); - if (res == -1) { - ftdm_log(FTDM_LOG_CRIT, "reading interrupt descriptor failed (%s)\n", strerror(errno)); - } - } - if (interrupt->device != FTDM_INVALID_SOCKET) { - if (ints[1].revents & POLLIN) { - interrupt->device_output_flags |= FTDM_READ; - } - if (ints[1].revents & POLLOUT) { - interrupt->device_output_flags |= FTDM_WRITE; - } - if (ints[1].revents & POLLPRI) { - interrupt->device_output_flags |= FTDM_EVENTS; - } - } - return FTDM_SUCCESS; -#endif -} - -FT_DECLARE(ftdm_status_t) ftdm_interrupt_signal(ftdm_interrupt_t *interrupt) -{ - ftdm_assert_return(interrupt != NULL, FTDM_FAIL, "Interrupt is null!\n"); -#ifdef WIN32 - if (!SetEvent(interrupt->event)) { - ftdm_log(FTDM_LOG_ERROR, "Failed to signal interrupt\n"); - return FTDM_FAIL; - - } -#else - int err; - struct pollfd testpoll; - testpoll.revents = 0; - testpoll.events = POLLIN; - testpoll.fd = interrupt->readfd; - err = poll(&testpoll, 1, 0); - if (err == 0 && !(testpoll.revents & POLLIN)) { - /* we just try to notify if there is nothing on the read fd already, - * otherwise users that never call interrupt wait eventually will - * eventually have the pipe buffer filled */ - if ((err = write(interrupt->writefd, "w", 1)) != 1) { - ftdm_log(FTDM_LOG_ERROR, "Failed to signal interrupt: %s\n", strerror(errno)); - return FTDM_FAIL; - } - } -#endif - return FTDM_SUCCESS; -} - -FT_DECLARE(ftdm_status_t) ftdm_interrupt_destroy(ftdm_interrupt_t **ininterrupt) -{ - ftdm_interrupt_t *interrupt = NULL; - ftdm_assert_return(ininterrupt != NULL, FTDM_FAIL, "Interrupt null when destroying!\n"); - interrupt = *ininterrupt; -#ifdef WIN32 - CloseHandle(interrupt->event); -#else - close(interrupt->readfd); - close(interrupt->writefd); - - interrupt->readfd = -1; - interrupt->writefd = -1; -#endif - ftdm_safe_free(interrupt); - *ininterrupt = NULL; - return FTDM_SUCCESS; -} - -FT_DECLARE(ftdm_status_t) ftdm_interrupt_multiple_wait(ftdm_interrupt_t *interrupts[], ftdm_size_t size, int ms) -{ - int numdevices = 0; - unsigned i = 0; - -#if defined(__WINDOWS__) - DWORD res = 0; - HANDLE ints[20]; - if (size > (ftdm_array_len(ints)/2)) { - /* improve if needed: dynamically allocate the list of interrupts *only* when exceeding the default size */ - ftdm_log(FTDM_LOG_CRIT, "Unsupported size of interrupts: %d, implement me!\n", size); - return FTDM_FAIL; - } - - for (i = 0; i < size; i++) { - ints[i] = interrupts[i]->event; - interrupts[i]->device_output_flags = FTDM_NO_FLAGS; - if (interrupts[i]->device != FTDM_INVALID_SOCKET) { - /* WARNING: if the device is ready for data we must implement for Windows the device_output_flags member */ - ints[size+numdevices] = interrupts[i]->device; - numdevices++; - ftdm_log(FTDM_LOG_CRIT, "implement me! (Windows support for device_data_ready member!)\n", size); - } - } - - res = WaitForMultipleObjects((DWORD)size+numdevices, ints, FALSE, ms >= 0 ? ms : INFINITE); - - switch (res) { - case WAIT_TIMEOUT: - return FTDM_TIMEOUT; - case WAIT_FAILED: - case WAIT_ABANDONED: /* is it right to fail with abandoned? */ - return FTDM_FAIL; - default: - if (res >= (size+numdevices)) { - ftdm_log(FTDM_LOG_ERROR, "Error waiting for freetdm interrupt event (WaitForSingleObject returned %d)\n", res); - return FTDM_FAIL; - } - /* fall-through to FTDM_SUCCESS at the end of the function */ - } -#elif defined(__linux__) || defined(__FreeBSD__) - int res = 0; - char pipebuf[255]; - struct pollfd ints[size*2]; - - memset(&ints, 0, sizeof(ints)); -pollagain: - for (i = 0; i < size; i++) { - ints[i].events = POLLIN; - ints[i].revents = 0; - ints[i].fd = interrupts[i]->readfd; - interrupts[i]->device_output_flags = FTDM_NO_FLAGS; - if (interrupts[i]->device != FTDM_INVALID_SOCKET) { - ints[size+numdevices].events = interrupts[i]->device_input_flags; - ints[size+numdevices].revents = 0; - ints[size+numdevices].fd = interrupts[i]->device; - numdevices++; - } - } - - res = poll(ints, size + numdevices, ms); - if (res == -1) { - if (errno == EINTR) { - goto pollagain; - } - ftdm_log(FTDM_LOG_CRIT, "interrupt poll failed (%s)\n", strerror(errno)); - return FTDM_FAIL; - } - - if (res == 0) { - return FTDM_TIMEOUT; - } - - /* check for events in the pipes and in the devices, but service only the pipes */ - numdevices = 0; - for (i = 0; i < size; i++) { - if (ints[i].revents & POLLIN) { - res = read(ints[i].fd, pipebuf, sizeof(pipebuf)); - if (res == -1) { - ftdm_log(FTDM_LOG_CRIT, "reading interrupt descriptor failed (%s)\n", strerror(errno)); - } - } - if (interrupts[i]->device != FTDM_INVALID_SOCKET) { - if (ints[size+numdevices].revents & POLLIN) { - interrupts[i]->device_output_flags |= FTDM_READ; - } - if (ints[size+numdevices].revents & POLLOUT) { - interrupts[i]->device_output_flags |= FTDM_WRITE; - } - if (ints[size+numdevices].revents & POLLPRI) { - interrupts[i]->device_output_flags |= FTDM_EVENTS; - } - numdevices++; - } - } -#else - /* for MacOS compilation, unused vars */ - numdevices = i; -#endif - return FTDM_SUCCESS; -} - -FT_DECLARE(ftdm_wait_flag_t) ftdm_interrupt_device_ready(ftdm_interrupt_t *interrupt) -{ -#if defined(__WINDOWS__) - /* device output flags are not currently filled for Windows upon returning from a wait function */ - ftdm_log(FTDM_LOG_CRIT, "IMPLEMENT ME!\n"); -#endif - return interrupt->device_output_flags; -} - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/ftdm_variables.c b/libs/freetdm/src/ftdm_variables.c deleted file mode 100644 index a2899c4ca9..0000000000 --- a/libs/freetdm/src/ftdm_variables.c +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (c) 2010, Sangoma Technologies - * David Yat Sin - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Contributors: - * - * Moises Silva - * - */ - -#include "private/ftdm_core.h" - -FT_DECLARE(ftdm_status_t) ftdm_sigmsg_add_var(ftdm_sigmsg_t *sigmsg, const char *var_name, const char *value) -{ - char *t_name = 0, *t_val = 0; - - if (!sigmsg || !var_name || !value) { - return FTDM_FAIL; - } - - if (!sigmsg->variables) { - /* initialize on first use */ - sigmsg->variables = create_hashtable(16, ftdm_hash_hashfromstring, ftdm_hash_equalkeys); - ftdm_assert_return(sigmsg->variables, FTDM_FAIL, "Failed to create hash table\n"); - } - - t_name = ftdm_strdup(var_name); - t_val = ftdm_strdup(value); - hashtable_insert(sigmsg->variables, t_name, t_val, HASHTABLE_FLAG_FREE_KEY | HASHTABLE_FLAG_FREE_VALUE); - return FTDM_SUCCESS; -} - -FT_DECLARE(ftdm_status_t) ftdm_sigmsg_remove_var(ftdm_sigmsg_t *sigmsg, const char *var_name) -{ - if (sigmsg && sigmsg->variables) { - hashtable_remove(sigmsg->variables, (void *)var_name); - } - return FTDM_SUCCESS; -} - -FT_DECLARE(const char *) ftdm_sigmsg_get_var(ftdm_sigmsg_t *sigmsg, const char *var_name) -{ - const char *var = NULL; - - if (!sigmsg || !sigmsg->variables || !var_name) { - return NULL; - } - - var = (const char *)hashtable_search(((struct hashtable*)sigmsg->variables), (void *)var_name); - return var; -} - -FT_DECLARE(ftdm_iterator_t *) ftdm_sigmsg_get_var_iterator(const ftdm_sigmsg_t *sigmsg, ftdm_iterator_t *iter) -{ - ftdm_hash_iterator_t *hashiter = NULL; - if (!sigmsg) { - return NULL; - } - - hashiter = sigmsg->variables == NULL ? NULL : hashtable_first(sigmsg->variables); - - if (hashiter == NULL) { - return NULL; - } - - if (!(iter = ftdm_get_iterator(FTDM_ITERATOR_VARS, iter))) { - return NULL; - } - iter->pvt.hashiter = hashiter; - return iter; -} - -FT_DECLARE(ftdm_status_t) ftdm_get_current_var(ftdm_iterator_t *iter, const char **var_name, const char **var_val) -{ - const void *key = NULL; - void *val = NULL; - - *var_name = NULL; - *var_val = NULL; - - ftdm_assert_return(iter && (iter->type == FTDM_ITERATOR_VARS) && iter->pvt.hashiter, FTDM_FAIL, "Cannot get variable from invalid iterator!\n"); - - hashtable_this(iter->pvt.hashiter, &key, NULL, &val); - - *var_name = key; - *var_val = val; - - return FTDM_SUCCESS; -} - - -FT_DECLARE(ftdm_status_t) ftdm_usrmsg_add_var(ftdm_usrmsg_t *usrmsg, const char *var_name, const char *value) -{ - char *t_name = 0, *t_val = 0; - - if (!usrmsg || !var_name || !value) { - return FTDM_FAIL; - } - - if (!usrmsg->variables) { - /* initialize on first use */ - usrmsg->variables = create_hashtable(16, ftdm_hash_hashfromstring, ftdm_hash_equalkeys); - ftdm_assert_return(usrmsg->variables, FTDM_FAIL, "Failed to create hash table\n"); - } - - t_name = ftdm_strdup(var_name); - t_val = ftdm_strdup(value); - hashtable_insert(usrmsg->variables, t_name, t_val, HASHTABLE_FLAG_FREE_KEY | HASHTABLE_FLAG_FREE_VALUE); - return FTDM_SUCCESS; -} - -FT_DECLARE(const char *) ftdm_usrmsg_get_var(ftdm_usrmsg_t *usrmsg, const char *var_name) -{ - const char *var = NULL; - - if (!usrmsg || !usrmsg->variables || !var_name) { - return NULL; - } - - var = (const char *)hashtable_search(((struct hashtable*)usrmsg->variables), (void *)var_name); - return var; -} diff --git a/libs/freetdm/src/ftmod/ftmod_analog/ftdm_analog.h b/libs/freetdm/src/ftmod/ftmod_analog/ftdm_analog.h deleted file mode 100644 index 2bc1717556..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_analog/ftdm_analog.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2007-2014, Anthony Minessale II - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef FTDM_ANALOG_H -#define FTDM_ANALOG_H -#include "freetdm.h" - -typedef enum { - FTDM_ANALOG_RUNNING = (1 << 0), - FTDM_ANALOG_CALLERID = (1 << 1), - FTDM_ANALOG_ANSWER_POLARITY_REVERSE = (1 << 2), - FTDM_ANALOG_HANGUP_POLARITY_REVERSE = (1 << 3), - FTDM_ANALOG_POLARITY_CALLERID = (1 << 4) -} ftdm_analog_flag_t; - -#define FTDM_MAX_HOTLINE_STR 32 -#define MAX_DTMF 256 - -struct ftdm_analog_data { - uint32_t flags; - uint32_t max_dialstr; - uint32_t wait_dialtone_timeout; - uint32_t polarity_delay; - uint32_t digit_timeout; - char hotline[FTDM_MAX_HOTLINE_STR]; -}; - -/* Analog flags to be set in the sflags (signaling flags) channel memeber */ -#define AF_POLARITY_REVERSE (1 << 0) - -static void *ftdm_analog_run(ftdm_thread_t *me, void *obj); -typedef struct ftdm_analog_data ftdm_analog_data_t; - -#endif - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.2008.vcproj b/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.2008.vcproj deleted file mode 100644 index 09349fc05f..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.2008.vcproj +++ /dev/null @@ -1,353 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.2010.vcxproj.filters b/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.2010.vcxproj.filters deleted file mode 100644 index b6fed5927a..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.2010.vcxproj.filters +++ /dev/null @@ -1,23 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - - - Source Files - - - - - Header Files - - - \ No newline at end of file diff --git a/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.c b/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.c deleted file mode 100644 index 065e12a0d0..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.c +++ /dev/null @@ -1,1270 +0,0 @@ -/* - * Copyright (c) 2007-2014, Anthony Minessale II - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "private/ftdm_core.h" -#include "ftdm_analog.h" - -#ifndef localtime_r -struct tm * localtime_r(const time_t *clock, struct tm *result); -#endif - -static void *ftdm_analog_channel_run(ftdm_thread_t *me, void *obj); - -/** - * \brief Starts an FXO channel thread (outgoing call) - * \param ftdmchan Channel to initiate call on - * \return Success or failure - * - * Initialises state, starts tone progress detection and runs the channel in a new a thread. - */ -static FIO_CHANNEL_OUTGOING_CALL_FUNCTION(analog_fxo_outgoing_call) -{ - ftdm_analog_data_t *analog_data = ftdmchan->span->signal_data; - if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OFFHOOK) && !ftdm_test_flag(ftdmchan, FTDM_CHANNEL_INTHREAD)) { - ftdm_channel_clear_needed_tones(ftdmchan); - ftdm_channel_clear_detected_tones(ftdmchan); - - ftdm_channel_command(ftdmchan, FTDM_COMMAND_OFFHOOK, NULL); - ftdm_channel_command(ftdmchan, FTDM_COMMAND_ENABLE_PROGRESS_DETECT, NULL); - if (analog_data->wait_dialtone_timeout) { - ftdmchan->needed_tones[FTDM_TONEMAP_DIAL] = 1; - } - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DIALING); - ftdm_thread_create_detached(ftdm_analog_channel_run, ftdmchan); - return FTDM_SUCCESS; - } - - return FTDM_FAIL; -} - -/** - * \brief Starts an FXS channel thread (outgoing call) - * \param ftdmchan Channel to initiate call on - * \return Success or failure - * - * Indicates call waiting if channel is already in use, otherwise runs the channel in a new thread. - */ -static FIO_CHANNEL_OUTGOING_CALL_FUNCTION(analog_fxs_outgoing_call) -{ - - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_INTHREAD)) { - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_CALLWAITING); - } else { - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_GENRING); - ftdm_thread_create_detached(ftdm_analog_channel_run, ftdmchan); - } - - return FTDM_SUCCESS; -} - -/** - * \brief Returns the signalling status on a channel - * \param ftdmchan Channel to get status on - * \param status Pointer to set signalling status - * \return Success or failure - */ - -static FIO_CHANNEL_GET_SIG_STATUS_FUNCTION(analog_get_channel_sig_status) -{ - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_IN_ALARM)) { - *status = FTDM_SIG_STATE_DOWN; - return FTDM_SUCCESS; - } - *status = FTDM_SIG_STATE_UP; - return FTDM_SUCCESS; -} - -/** - * \brief Returns the signalling status on a span - * \param span Span to get status on - * \param status Pointer to set signalling status - * \return Success or failure - */ - -static FIO_SPAN_GET_SIG_STATUS_FUNCTION(analog_get_span_sig_status) -{ - ftdm_iterator_t *citer = NULL; - ftdm_iterator_t *chaniter = ftdm_span_get_chan_iterator(span, NULL); - if (!chaniter) { - ftdm_log(FTDM_LOG_CRIT, "Failed to allocate channel iterator for span %s!\n", span->name); - return FTDM_FAIL; - } - /* if ALL channels are in alarm, report DOWN, UP otherwise. */ - *status = FTDM_SIG_STATE_DOWN; - for (citer = chaniter; citer; citer = ftdm_iterator_next(citer)) { - ftdm_channel_t *fchan = ftdm_iterator_current(citer); - ftdm_channel_lock(fchan); - if (!ftdm_test_flag(fchan, FTDM_CHANNEL_IN_ALARM)) { - *status = FTDM_SIG_STATE_UP; - ftdm_channel_unlock(fchan); - break; - } - ftdm_channel_unlock(fchan); - } - ftdm_iterator_free(chaniter); - return FTDM_SUCCESS; -} - -/** - * \brief Starts an analog span thread (monitor) - * \param span Span to monitor - * \return Success or failure - */ -static ftdm_status_t ftdm_analog_start(ftdm_span_t *span) -{ - ftdm_analog_data_t *analog_data = span->signal_data; - ftdm_set_flag(analog_data, FTDM_ANALOG_RUNNING); - return ftdm_thread_create_detached(ftdm_analog_run, span); -} - -/** - * \brief Stops the analog span thread (monitor) - * \param span Span to stop - * \return Success or failure - */ -static ftdm_status_t ftdm_analog_stop(ftdm_span_t *span) -{ - ftdm_analog_data_t *analog_data = span->signal_data; - int32_t sanity = 100; - while (ftdm_test_flag(analog_data, FTDM_ANALOG_RUNNING) && sanity--) { - ftdm_sleep(100); - ftdm_log(FTDM_LOG_DEBUG, "Waiting for analog thread for span %s to stop\n", span->name); - } - - if (!sanity) { - ftdm_log(FTDM_LOG_ERROR, "The analog thread for span %s is probably still running, we may crash :(\n", span->name); - return FTDM_FAIL; - } - return FTDM_SUCCESS; -} - -/** - * \brief Initialises an analog span from configuration variables - * \param span Span to configure - * \param sig_cb Callback function for event signals - * \param ap List of configuration variables - * \return Success or failure - */ -static FIO_SIG_CONFIGURE_FUNCTION(ftdm_analog_configure_span) -//ftdm_status_t ftdm_analog_configure_span(ftdm_span_t *span, char *tonemap, uint32_t digit_timeout, uint32_t max_dialstr, fio_signal_cb_t sig_cb) -{ - ftdm_analog_data_t *analog_data; - const char *tonemap = "us"; - const char *hotline = ""; - uint32_t digit_timeout = 10; - uint32_t wait_dialtone_timeout = 5000; - uint32_t max_dialstr = MAX_DTMF; - uint32_t polarity_delay = 600; - const char *var, *val; - int *intval; - uint32_t flags = FTDM_ANALOG_CALLERID; - int callwaiting = 1; - unsigned int i = 0; - - assert(sig_cb != NULL); - ftdm_log(FTDM_LOG_DEBUG, "Configuring span %s for analog signaling ...\n", span->name); - - if (span->signal_type) { - ftdm_log(FTDM_LOG_ERROR, "Span %s is already configured for signaling %d\n", span->name, span->signal_type); - snprintf(span->last_error, sizeof(span->last_error), "Span is already configured for signalling."); - return FTDM_FAIL; - } - - analog_data = ftdm_malloc(sizeof(*analog_data)); - - ftdm_assert_return(analog_data != NULL, FTDM_FAIL, "malloc failure\n"); - - memset(analog_data, 0, sizeof(*analog_data)); - - while ((var = va_arg(ap, char *))) { - ftdm_log(FTDM_LOG_DEBUG, "Analog config var = %s\n", var); - if (!strcasecmp(var, "tonemap")) { - if (!(val = va_arg(ap, char *))) { - break; - } - tonemap = val; - } else if (!strcasecmp(var, "digit_timeout")) { - if (!(intval = va_arg(ap, int *))) { - break; - } - digit_timeout = *intval; - } else if (!strcasecmp(var, "wait_dialtone_timeout")) { - if (!(intval = va_arg(ap, int *))) { - break; - } - wait_dialtone_timeout = ftdm_max(0, *intval); - ftdm_log(FTDM_LOG_DEBUG, "Wait dial tone ms = %d\n", wait_dialtone_timeout); - } else if (!strcasecmp(var, "enable_callerid")) { - if (!(val = va_arg(ap, char *))) { - break; - } - - if (ftdm_true(val)) { - flags |= FTDM_ANALOG_CALLERID; - } else { - flags &= ~FTDM_ANALOG_CALLERID; - } - } else if (!strcasecmp(var, "answer_polarity_reverse")) { - if (!(val = va_arg(ap, char *))) { - break; - } - if (ftdm_true(val)) { - flags |= FTDM_ANALOG_ANSWER_POLARITY_REVERSE; - } else { - flags &= ~FTDM_ANALOG_ANSWER_POLARITY_REVERSE; - } - } else if (!strcasecmp(var, "hangup_polarity_reverse")) { - if (!(val = va_arg(ap, char *))) { - break; - } - if (ftdm_true(val)) { - flags |= FTDM_ANALOG_HANGUP_POLARITY_REVERSE; - } else { - flags &= ~FTDM_ANALOG_HANGUP_POLARITY_REVERSE; - } - } else if (!strcasecmp(var, "polarity_delay")) { - if (!(intval = va_arg(ap, int *))) { - break; - } - polarity_delay = *intval; - } else if (!strcasecmp(var, "callwaiting")) { - if (!(intval = va_arg(ap, int *))) { - break; - } - callwaiting = *intval; - } else if (!strcasecmp(var, "max_dialstr")) { - if (!(intval = va_arg(ap, int *))) { - break; - } - max_dialstr = *intval; - } else if (!strcasecmp(var, "hotline")) { - if (!(val = va_arg(ap, char *))) { - break; - } - hotline = val; - } else if (!strcasecmp(var, "polarity_callerid")) { - if (!(val = va_arg(ap, char *))) { - break; - } - if (ftdm_true(val)) { - flags |= FTDM_ANALOG_POLARITY_CALLERID; - } else { - flags &= ~FTDM_ANALOG_POLARITY_CALLERID; - } - } else { - ftdm_log(FTDM_LOG_ERROR, "Unknown parameter %s in span %s\n", var, span->name); - } - } - - if (digit_timeout < 2000 || digit_timeout > 10000) { - digit_timeout = 2000; - } - - if ((max_dialstr < 1 && !strlen(hotline)) || max_dialstr > MAX_DTMF) { - max_dialstr = MAX_DTMF; - } - - if (callwaiting) { - for (i = 1; i <= span->chan_count; i++) { - ftdm_log_chan_msg(span->channels[i], FTDM_LOG_DEBUG, "Enabled call waiting\n"); - ftdm_channel_set_feature(span->channels[i], FTDM_CHANNEL_FEATURE_CALLWAITING); - } - } - - span->start = ftdm_analog_start; - span->stop = ftdm_analog_stop; - analog_data->flags = flags; - analog_data->digit_timeout = digit_timeout; - analog_data->wait_dialtone_timeout = wait_dialtone_timeout; - analog_data->polarity_delay = polarity_delay; - analog_data->max_dialstr = max_dialstr; - span->signal_cb = sig_cb; - strncpy(analog_data->hotline, hotline, sizeof(analog_data->hotline)); - span->signal_type = FTDM_SIGTYPE_ANALOG; - span->signal_data = analog_data; - span->outgoing_call = span->trunk_type == FTDM_TRUNK_FXS ? analog_fxs_outgoing_call : analog_fxo_outgoing_call; - span->get_channel_sig_status = analog_get_channel_sig_status; - span->get_span_sig_status = analog_get_span_sig_status; - - ftdm_span_load_tones(span, tonemap); - - ftdm_log(FTDM_LOG_DEBUG, "Configuration of analog signaling for span %s is done\n", span->name); - return FTDM_SUCCESS; - -} - -/** - * \brief Retrieves tone generation output to be sent - * \param ts Teletone generator - * \param map Tone map - * \return -1 on error, 0 on success - */ -static int teletone_handler(teletone_generation_session_t *ts, teletone_tone_map_t *map) -{ - ftdm_buffer_t *dt_buffer = ts->user_data; - int wrote; - - if (!dt_buffer) { - return -1; - } - wrote = teletone_mux_tones(ts, map); - ftdm_buffer_write(dt_buffer, ts->buffer, wrote * 2); - return 0; -} - -/** - * \brief Sends caller id on an analog channel (FSK coded) - * \param ftdmchan Channel to send caller id on - */ -static void send_caller_id(ftdm_channel_t *ftdmchan) -{ - ftdm_fsk_data_state_t fsk_data; - uint8_t databuf[1024] = ""; - char time_str[9]; - struct tm tm; - time_t now; - ftdm_mdmf_type_t mt = MDMF_INVALID; - - time(&now); -#ifdef WIN32 - _tzset(); - _localtime64_s(&tm, &now); -#else - localtime_r(&now, &tm); -#endif - strftime(time_str, sizeof(time_str), "%m%d%H%M", &tm); - - ftdm_fsk_data_init(&fsk_data, databuf, sizeof(databuf)); - ftdm_fsk_data_add_mdmf(&fsk_data, MDMF_DATETIME, (uint8_t *) time_str, 8); - - if (ftdm_strlen_zero(ftdmchan->caller_data.cid_num.digits)) { - mt = MDMF_NO_NUM; - ftdm_set_string(ftdmchan->caller_data.cid_num.digits, "O"); - } else if (!strcasecmp(ftdmchan->caller_data.cid_num.digits, "P") || !strcasecmp(ftdmchan->caller_data.cid_num.digits, "O")) { - mt = MDMF_NO_NUM; - } else { - mt = MDMF_PHONE_NUM; - } - ftdm_fsk_data_add_mdmf(&fsk_data, mt, (uint8_t *) ftdmchan->caller_data.cid_num.digits, (uint8_t)strlen(ftdmchan->caller_data.cid_num.digits)); - - if (ftdm_strlen_zero(ftdmchan->caller_data.cid_name)) { - mt = MDMF_NO_NAME; - ftdm_set_string(ftdmchan->caller_data.cid_name, "O"); - } else if (!strcasecmp(ftdmchan->caller_data.cid_name, "P") || !strcasecmp(ftdmchan->caller_data.cid_name, "O")) { - mt = MDMF_NO_NAME; - } else { - mt = MDMF_PHONE_NAME; - } - ftdm_fsk_data_add_mdmf(&fsk_data, mt, (uint8_t *) ftdmchan->caller_data.cid_name, (uint8_t)strlen(ftdmchan->caller_data.cid_name)); - - ftdm_fsk_data_add_checksum(&fsk_data); - ftdm_channel_send_fsk_data(ftdmchan, &fsk_data, -14); -} - -static void analog_dial(ftdm_channel_t *ftdmchan, uint32_t *state_counter, uint32_t *dial_timeout) -{ - if (ftdm_strlen_zero(ftdmchan->caller_data.dnis.digits)) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "No digits to send, moving to UP!\n"); - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_UP); - } else { - if (ftdm_channel_command(ftdmchan, FTDM_COMMAND_SEND_DTMF, ftdmchan->caller_data.dnis.digits) != FTDM_SUCCESS) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Send Digits Failed [%s]\n", ftdmchan->last_error); - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_BUSY); - } else { - *state_counter = 0; - ftdmchan->needed_tones[FTDM_TONEMAP_RING] = 1; - ftdmchan->needed_tones[FTDM_TONEMAP_BUSY] = 1; - ftdmchan->needed_tones[FTDM_TONEMAP_FAIL1] = 1; - ftdmchan->needed_tones[FTDM_TONEMAP_FAIL2] = 1; - ftdmchan->needed_tones[FTDM_TONEMAP_FAIL3] = 1; - *dial_timeout = (uint32_t)((ftdmchan->dtmf_on + ftdmchan->dtmf_off) * strlen(ftdmchan->caller_data.dnis.digits)) + 2000; - } - } -} - -/** - * \brief Main thread function for analog channel (outgoing call) - * \param me Current thread - * \param obj Channel to run in this thread - */ -static void *ftdm_analog_channel_run(ftdm_thread_t *me, void *obj) -{ - ftdm_channel_t *ftdmchan = (ftdm_channel_t *) obj; - ftdm_buffer_t *dt_buffer = NULL; - teletone_generation_session_t ts; - uint8_t frame[1024]; - ftdm_size_t len, rlen; - ftdm_tone_type_t tt = FTDM_TONE_DTMF; - char dtmf[MAX_DTMF+1] = ""; - ftdm_size_t dtmf_offset = 0; - ftdm_analog_data_t *analog_data = ftdmchan->span->signal_data; - ftdm_channel_t *closed_chan; - uint32_t state_counter = 0, elapsed = 0, collecting = 0, interval = 0, last_digit = 0, indicate = 0, dial_timeout = analog_data->wait_dialtone_timeout; - uint32_t answer_on_polarity_counter = 0; - ftdm_sigmsg_t sig; - - ftdm_unused_arg(me); - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "ANALOG CHANNEL thread starting.\n"); - - ts.buffer = NULL; - - if (ftdm_channel_open_chan(ftdmchan) != FTDM_SUCCESS) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "OPEN ERROR [%s]\n", ftdmchan->last_error); - goto done; - } - - if (ftdm_buffer_create(&dt_buffer, 1024, 3192, 0) != FTDM_SUCCESS) { - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "memory error!"); - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "MEM ERROR\n"); - goto done; - } - - if (ftdm_channel_command(ftdmchan, FTDM_COMMAND_ENABLE_DTMF_DETECT, &tt) != FTDM_SUCCESS) { - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "error initilizing tone detector!"); - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "failed to initialize DTMF detector\n"); - goto done; - } - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Initialized DTMF detection\n"); - - ftdm_set_flag_locked(ftdmchan, FTDM_CHANNEL_INTHREAD); - teletone_init_session(&ts, 0, teletone_handler, dt_buffer); - ts.rate = 8000; -#if 0 - ts.debug = 1; - ts.debug_stream = stdout; -#endif - ftdm_channel_command(ftdmchan, FTDM_COMMAND_GET_INTERVAL, &interval); - ftdm_buffer_set_loops(dt_buffer, -1); - - memset(&sig, 0, sizeof(sig)); - sig.chan_id = ftdmchan->chan_id; - sig.span_id = ftdmchan->span_id; - sig.channel = ftdmchan; - - ftdm_assert(interval != 0, "Invalid interval"); - - if (!dial_timeout) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Not waiting for dial tone to dial number %s\n", ftdmchan->caller_data.dnis.digits); - } - - while (ftdm_running() && ftdm_test_flag(ftdmchan, FTDM_CHANNEL_INTHREAD)) { - ftdm_wait_flag_t flags = FTDM_READ; - ftdm_size_t dlen = 0; - - len = sizeof(frame); - - elapsed += interval; - state_counter += interval; - - if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_STATE_CHANGE)) { - switch(ftdmchan->state) { - case FTDM_CHANNEL_STATE_GET_CALLERID: - { - if (state_counter > 5000 || !ftdm_test_flag(ftdmchan, FTDM_CHANNEL_CALLERID_DETECT)) { - ftdm_channel_command(ftdmchan, FTDM_COMMAND_DISABLE_CALLERID_DETECT, NULL); - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_RING); - } - } - break; - case FTDM_CHANNEL_STATE_DIALING: - { - if (state_counter > dial_timeout) { - if (ftdmchan->needed_tones[FTDM_TONEMAP_DIAL]) { - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_BUSY); - } else { - /* do not go up if we're waiting for polarity reversal */ - if (ftdm_test_flag(analog_data, FTDM_ANALOG_ANSWER_POLARITY_REVERSE)) { - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA); - } else { - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_UP); - } - } - } - } - break; - case FTDM_CHANNEL_STATE_GENRING: - { - if (state_counter > 60000) { - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - } else if (!ftdmchan->fsk_buffer || !ftdm_buffer_inuse(ftdmchan->fsk_buffer)) { - ftdm_sleep(interval); - continue; - } - } - break; - case FTDM_CHANNEL_STATE_DIALTONE: - { - if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_HOLD) && state_counter > 10000) { - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_BUSY); - } - } - break; - case FTDM_CHANNEL_STATE_BUSY: - { - if (state_counter > 20000) { - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_ATTN); - } - } - break; - case FTDM_CHANNEL_STATE_ATTN: - { - if (state_counter > 20000) { - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - } - } - break; - case FTDM_CHANNEL_STATE_HANGUP: - { - if (state_counter > 500) { - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_RINGING)) { - ftdm_channel_command(ftdmchan, FTDM_COMMAND_GENERATE_RING_OFF, NULL); - } - - if (ftdmchan->type == FTDM_CHAN_TYPE_FXS && - ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OFFHOOK) && - (ftdmchan->last_state == FTDM_CHANNEL_STATE_RINGING - || ftdmchan->last_state == FTDM_CHANNEL_STATE_DIALTONE - || ftdmchan->last_state == FTDM_CHANNEL_STATE_RING - || ftdmchan->last_state == FTDM_CHANNEL_STATE_UP)) { - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_BUSY); - } else { - ftdmchan->caller_data.hangup_cause = FTDM_CAUSE_NORMAL_CLEARING; - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - } - } - } - break; - case FTDM_CHANNEL_STATE_CALLWAITING: - { - int done = 0; - - if (ftdmchan->detected_tones[FTDM_TONEMAP_CALLWAITING_ACK] == 1) { - send_caller_id(ftdmchan); - ftdmchan->detected_tones[FTDM_TONEMAP_CALLWAITING_ACK]++; - } else if (state_counter > 600 && !ftdmchan->detected_tones[FTDM_TONEMAP_CALLWAITING_ACK]) { - send_caller_id(ftdmchan); - ftdmchan->detected_tones[FTDM_TONEMAP_CALLWAITING_ACK]++; - } else if (state_counter > 1000 && !ftdmchan->detected_tones[FTDM_TONEMAP_CALLWAITING_ACK]) { - done = 1; - } else if (state_counter > 10000) { - if (ftdmchan->fsk_buffer) { - ftdm_buffer_zero(ftdmchan->fsk_buffer); - } else { - ftdm_buffer_create(&ftdmchan->fsk_buffer, 128, 128, 0); - } - - ts.user_data = ftdmchan->fsk_buffer; - teletone_run(&ts, ftdmchan->span->tone_map[FTDM_TONEMAP_CALLWAITING_SAS]); - ts.user_data = dt_buffer; - done = 1; - } - - if (done) { - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_UP); - ftdm_clear_flag_locked(ftdmchan->span, FTDM_SPAN_STATE_CHANGE); - ftdm_channel_complete_state(ftdmchan); - ftdmchan->detected_tones[FTDM_TONEMAP_CALLWAITING_ACK] = 0; - } - } - case FTDM_CHANNEL_STATE_UP: - case FTDM_CHANNEL_STATE_RING: - case FTDM_CHANNEL_STATE_PROGRESS_MEDIA: - { - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND) && - ftdmchan->state == FTDM_CHANNEL_STATE_PROGRESS_MEDIA && - ftdm_test_sflag(ftdmchan, AF_POLARITY_REVERSE)) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_NOTICE, "Answering on polarity reverse\n"); - ftdm_clear_sflag(ftdmchan, AF_POLARITY_REVERSE); - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_UP); - answer_on_polarity_counter = state_counter; - } else if (ftdmchan->state == FTDM_CHANNEL_STATE_UP - && ftdm_test_sflag(ftdmchan, AF_POLARITY_REVERSE)){ - /* if this polarity reverse is close to the answer polarity reverse, ignore it */ - if (answer_on_polarity_counter - && (state_counter - answer_on_polarity_counter) > analog_data->polarity_delay) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_NOTICE, "Hanging up on polarity reverse\n"); - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_HANGUP); - } else { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, - "Not hanging up on polarity reverse, too close to Answer reverse\n"); - } - ftdm_clear_sflag(ftdmchan, AF_POLARITY_REVERSE); - } else { - ftdm_sleep(interval); - } - continue; - } - break; - case FTDM_CHANNEL_STATE_DOWN: - { - goto done; - } - break; - default: - break; - } - } else { - ftdm_clear_flag_locked(ftdmchan->span, FTDM_SPAN_STATE_CHANGE); - ftdm_channel_complete_state(ftdmchan); - indicate = 0; - state_counter = 0; - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Executing state handler on %d:%d for %s\n", - ftdmchan->span_id, ftdmchan->chan_id, - ftdm_channel_state2str(ftdmchan->state)); - switch(ftdmchan->state) { - case FTDM_CHANNEL_STATE_UP: - { - ftdm_channel_use(ftdmchan); - ftdm_channel_clear_needed_tones(ftdmchan); - ftdm_channel_flush_dtmf(ftdmchan); - - if (ftdmchan->type == FTDM_CHAN_TYPE_FXO && !ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OFFHOOK)) { - ftdm_channel_command(ftdmchan, FTDM_COMMAND_OFFHOOK, NULL); - } - - if (ftdmchan->fsk_buffer && ftdm_buffer_inuse(ftdmchan->fsk_buffer)) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Cancel FSK transmit due to early answer.\n"); - ftdm_buffer_zero(ftdmchan->fsk_buffer); - } - - if (ftdmchan->type == FTDM_CHAN_TYPE_FXS && ftdm_test_flag(ftdmchan, FTDM_CHANNEL_RINGING)) { - ftdm_channel_command(ftdmchan, FTDM_COMMAND_GENERATE_RING_OFF, NULL); - } - - if (ftdmchan->token_count == 1) { - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_HOLD); - } - - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_HOLD)) { - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_HOLD); - sig.event_id = FTDM_SIGEVENT_ADD_CALL; - } else { - sig.event_id = FTDM_SIGEVENT_UP; - } - - if (ftdmchan->type == FTDM_CHAN_TYPE_FXS && - !ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND) && - ftdm_test_flag(analog_data, FTDM_ANALOG_ANSWER_POLARITY_REVERSE)) { - ftdm_polarity_t polarity = FTDM_POLARITY_REVERSE; - if (ftdmchan->polarity == FTDM_POLARITY_FORWARD) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Reversing polarity on answer\n"); - ftdm_channel_command(ftdmchan, FTDM_COMMAND_SET_POLARITY, &polarity); - } else { - /* the polarity may be already reversed if this is the second time we - * answer (ie, due to 2 calls being on the same line) */ - } - } - - ftdm_span_send_signal(ftdmchan->span, &sig); - continue; - } - break; - case FTDM_CHANNEL_STATE_DIALING: - { - ftdm_channel_use(ftdmchan); - } - break; - case FTDM_CHANNEL_STATE_RING: - { - ftdm_channel_use(ftdmchan); - sig.event_id = FTDM_SIGEVENT_START; - - if (ftdmchan->type == FTDM_CHAN_TYPE_FXO) { - ftdm_set_string(ftdmchan->caller_data.dnis.digits, ftdmchan->chan_number); - } else { - ftdm_set_string(ftdmchan->caller_data.dnis.digits, dtmf); - } - - ftdm_span_send_signal(ftdmchan->span, &sig); - continue; - } - break; - - case FTDM_CHANNEL_STATE_HANGUP: - /* this state is only used when the user hangup, if the device hang up (onhook) we currently - * go straight to DOWN. If we ever change this (as other signaling modules do) by using this - * state for both user and device hangup, we should check here for the type of hangup since - * some actions (polarity reverse) do not make sense if the device hung up */ - if (ftdmchan->type == FTDM_CHAN_TYPE_FXS && - ftdmchan->last_state == FTDM_CHANNEL_STATE_UP && - ftdm_test_flag(analog_data, FTDM_ANALOG_HANGUP_POLARITY_REVERSE)) { - ftdm_polarity_t polarity = ftdmchan->polarity == FTDM_POLARITY_REVERSE - ? FTDM_POLARITY_FORWARD : FTDM_POLARITY_REVERSE; - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Reversing polarity on hangup\n"); - ftdm_channel_command(ftdmchan, FTDM_COMMAND_SET_POLARITY, &polarity); - } - break; - - case FTDM_CHANNEL_STATE_DOWN: - { - sig.event_id = FTDM_SIGEVENT_STOP; - ftdm_span_send_signal(ftdmchan->span, &sig); - goto done; - } - break; - case FTDM_CHANNEL_STATE_DIALTONE: - { - memset(&ftdmchan->caller_data, 0, sizeof(ftdmchan->caller_data)); - *dtmf = '\0'; - dtmf_offset = 0; - ftdm_buffer_zero(dt_buffer); - teletone_run(&ts, ftdmchan->span->tone_map[FTDM_TONEMAP_DIAL]); - indicate = 1; - } - break; - case FTDM_CHANNEL_STATE_CALLWAITING: - { - ftdmchan->detected_tones[FTDM_TONEMAP_CALLWAITING_ACK] = 0; - if (ftdmchan->fsk_buffer) { - ftdm_buffer_zero(ftdmchan->fsk_buffer); - } else { - ftdm_buffer_create(&ftdmchan->fsk_buffer, 128, 128, 0); - } - - ts.user_data = ftdmchan->fsk_buffer; - teletone_run(&ts, ftdmchan->span->tone_map[FTDM_TONEMAP_CALLWAITING_SAS]); - teletone_run(&ts, ftdmchan->span->tone_map[FTDM_TONEMAP_CALLWAITING_CAS]); - ts.user_data = dt_buffer; - } - break; - case FTDM_CHANNEL_STATE_GENRING: - { - ftdm_sigmsg_t sig; - - send_caller_id(ftdmchan); - ftdm_channel_command(ftdmchan, FTDM_COMMAND_GENERATE_RING_ON, NULL); - - memset(&sig, 0, sizeof(sig)); - sig.chan_id = ftdmchan->chan_id; - sig.span_id = ftdmchan->span_id; - sig.channel = ftdmchan; - sig.event_id = FTDM_SIGEVENT_PROGRESS; - ftdm_span_send_signal(ftdmchan->span, &sig); - - } - break; - case FTDM_CHANNEL_STATE_GET_CALLERID: - { - memset(&ftdmchan->caller_data, 0, sizeof(ftdmchan->caller_data)); - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Initializing cid data!\n"); - ftdm_set_string(ftdmchan->caller_data.ani.digits, "unknown"); - ftdm_set_string(ftdmchan->caller_data.cid_name, ftdmchan->caller_data.ani.digits); - ftdm_channel_command(ftdmchan, FTDM_COMMAND_ENABLE_CALLERID_DETECT, NULL); - continue; - } - break; - case FTDM_CHANNEL_STATE_RINGING: - { - ftdm_buffer_zero(dt_buffer); - teletone_run(&ts, ftdmchan->span->tone_map[FTDM_TONEMAP_RING]); - indicate = 1; - - } - break; - case FTDM_CHANNEL_STATE_BUSY: - { - ftdmchan->caller_data.hangup_cause = FTDM_CAUSE_NORMAL_CIRCUIT_CONGESTION; - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OFFHOOK) && !ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { - ftdm_buffer_zero(dt_buffer); - teletone_run(&ts, ftdmchan->span->tone_map[FTDM_TONEMAP_BUSY]); - indicate = 1; - } else { - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - } - } - break; - case FTDM_CHANNEL_STATE_ATTN: - { - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OFFHOOK) && !ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { - ftdm_buffer_zero(dt_buffer); - teletone_run(&ts, ftdmchan->span->tone_map[FTDM_TONEMAP_ATTN]); - indicate = 1; - } else { - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - } - } - break; - default: - break; - } - } - - - if (ftdmchan->state == FTDM_CHANNEL_STATE_DIALTONE || ftdmchan->state == FTDM_CHANNEL_STATE_COLLECT) { - if ((dlen = ftdm_channel_dequeue_dtmf(ftdmchan, dtmf + dtmf_offset, sizeof(dtmf) - strlen(dtmf)))) { - - if (ftdmchan->state == FTDM_CHANNEL_STATE_DIALTONE) { - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_COLLECT); - collecting = 1; - } - dtmf_offset = strlen(dtmf); - last_digit = elapsed; - sig.event_id = FTDM_SIGEVENT_COLLECTED_DIGIT; - ftdm_set_string(sig.ev_data.collected.digits, dtmf); - if (ftdm_span_send_signal(ftdmchan->span, &sig) == FTDM_BREAK) { - collecting = 0; - } - } - else if(!analog_data->max_dialstr) - { - last_digit = elapsed; - collecting = 0; - strcpy(dtmf, analog_data->hotline); - } - } - - - if (last_digit && (!collecting || ((elapsed - last_digit > analog_data->digit_timeout) || strlen(dtmf) >= analog_data->max_dialstr))) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Number obtained [%s]\n", dtmf); - if (ftdmchan->state == FTDM_CHANNEL_STATE_COLLECT && ftdmchan->state_status != FTDM_STATE_STATUS_COMPLETED) { - ftdm_channel_complete_state(ftdmchan); - } - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_RING); - last_digit = 0; - collecting = 0; - } - - if (ftdm_channel_wait(ftdmchan, &flags, interval * 2) != FTDM_SUCCESS) { - continue; - } - - if (!(flags & FTDM_READ)) { - continue; - } - - if (ftdm_channel_read(ftdmchan, frame, &len) != FTDM_SUCCESS) { - ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "read error [%s]\n", ftdmchan->last_error); - continue; - } - - if (ftdmchan->type == FTDM_CHAN_TYPE_FXO && ftdmchan->detected_tones[0]) { - int i; - - for (i = 1; i < FTDM_TONEMAP_INVALID; i++) { - if (ftdmchan->detected_tones[i]) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Detected tone %s on %d:%d\n", ftdm_tonemap2str(i), ftdmchan->span_id, ftdmchan->chan_id); - } - } - - if (ftdmchan->detected_tones[FTDM_TONEMAP_BUSY] || - ftdmchan->detected_tones[FTDM_TONEMAP_FAIL1] || - ftdmchan->detected_tones[FTDM_TONEMAP_FAIL2] || - ftdmchan->detected_tones[FTDM_TONEMAP_FAIL3] || - ftdmchan->detected_tones[FTDM_TONEMAP_ATTN] - ) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "Failure indication detected!\n"); - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_BUSY); - } else if (ftdmchan->detected_tones[FTDM_TONEMAP_DIAL]) { - analog_dial(ftdmchan, &state_counter, &dial_timeout); - } else if (ftdmchan->detected_tones[FTDM_TONEMAP_RING]) { - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_UP); - } - - ftdm_channel_clear_detected_tones(ftdmchan); - } else if (!dial_timeout) { - /* we were requested not to wait for dial tone, we can dial immediately */ - analog_dial(ftdmchan, &state_counter, &dial_timeout); - } - - if ((ftdmchan->dtmf_buffer && ftdm_buffer_inuse(ftdmchan->dtmf_buffer)) || (ftdmchan->fsk_buffer && ftdm_buffer_inuse(ftdmchan->fsk_buffer))) { - //rlen = len; - //memset(frame, 0, len); - //ftdm_channel_write(ftdmchan, frame, sizeof(frame), &rlen); - continue; - } - - if (!indicate) { - continue; - } - - if (ftdmchan->type == FTDM_CHAN_TYPE_FXO && !ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OFFHOOK)) { - ftdm_channel_command(ftdmchan, FTDM_COMMAND_OFFHOOK, NULL); - } - - if (ftdmchan->effective_codec != FTDM_CODEC_SLIN) { - len *= 2; - } - - rlen = ftdm_buffer_read_loop(dt_buffer, frame, len); - - if (ftdmchan->effective_codec != FTDM_CODEC_SLIN) { - fio_codec_t codec_func = NULL; - - if (ftdmchan->native_codec == FTDM_CODEC_ULAW) { - codec_func = fio_slin2ulaw; - } else if (ftdmchan->native_codec == FTDM_CODEC_ALAW) { - codec_func = fio_slin2alaw; - } - - if (codec_func) { - codec_func(frame, sizeof(frame), &rlen); - } else { - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "codec error!"); - goto done; - } - } - - ftdm_channel_write(ftdmchan, frame, sizeof(frame), &rlen); - } - - done: - - closed_chan = ftdmchan; - - ftdm_channel_lock(closed_chan); - - if (ftdmchan->type == FTDM_CHAN_TYPE_FXO && ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OFFHOOK)) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Going onhook\n"); - ftdm_channel_command(ftdmchan, FTDM_COMMAND_ONHOOK, NULL); - } - - if (ftdmchan->type == FTDM_CHAN_TYPE_FXS && ftdm_test_flag(ftdmchan, FTDM_CHANNEL_RINGING)) { - ftdm_channel_command(ftdmchan, FTDM_COMMAND_GENERATE_RING_OFF, NULL); - } - - - ftdm_clear_sflag(ftdmchan, AF_POLARITY_REVERSE); - - ftdm_channel_close(&ftdmchan); - - ftdm_channel_command(closed_chan, FTDM_COMMAND_SET_NATIVE_CODEC, NULL); - - if (ts.buffer) { - teletone_destroy_session(&ts); - } - - if (dt_buffer) { - ftdm_buffer_destroy(&dt_buffer); - } - - if (closed_chan->state != FTDM_CHANNEL_STATE_DOWN) { - ftdm_set_state_locked(closed_chan, FTDM_CHANNEL_STATE_DOWN); - } - - ftdm_log_chan(closed_chan, FTDM_LOG_DEBUG, "ANALOG CHANNEL %d:%d thread ended.\n", closed_chan->span_id, closed_chan->chan_id); - - ftdm_clear_flag(closed_chan, FTDM_CHANNEL_INTHREAD); - - ftdm_channel_unlock(closed_chan); - - return NULL; -} - -/** - * \brief Processes freetdm event - * \param span Span on which the event was fired - * \param event Event to be treated - * \return Success or failure - */ -static __inline__ ftdm_status_t process_event(ftdm_span_t *span, ftdm_event_t *event) -{ - ftdm_sigmsg_t sig; - ftdm_analog_data_t *analog_data = event->channel->span->signal_data; - int locked = 0; - - memset(&sig, 0, sizeof(sig)); - sig.chan_id = event->channel->chan_id; - sig.span_id = event->channel->span_id; - sig.channel = event->channel; - - - ftdm_log_chan(event->channel, FTDM_LOG_DEBUG, "Received event [%s] in state [%s]\n", ftdm_oob_event2str(event->enum_id), ftdm_channel_state2str(event->channel->state)); - - ftdm_mutex_lock(event->channel->mutex); - locked++; - - /* MAINTENANCE WARNING: - * 1. Be aware you are working on the locked channel - * 2. We should not be calling ftdm_span_send_signal or ftdm_set_state when there is already a channel thread running - * however, since this is old code I am not changing it now, but new code should adhere to that convention - * otherwise, we have possible races where we compete with the user for state changes, ie, the user requests - * a state change and then we process an event, the state change from the user is pending so our ftdm_set_state - * operation will fail. In cases where we win the race, our state change will be accepted but if a user requests - * a state change before the state change we requested here is processed by the channel thread, we'll end up - * rejecting the user request. - * - * See docs/locking.txt for further information about what guarantees should signaling modules provide when - * locking/unlocking a channel - * */ - switch(event->enum_id) { - case FTDM_OOB_RING_START: - { - if (event->channel->type != FTDM_CHAN_TYPE_FXO) { - ftdm_log_chan_msg(event->channel, FTDM_LOG_ERROR, "Cannot get a RING_START event on a non-fxo channel, please check your config.\n"); - ftdm_set_state(event->channel, FTDM_CHANNEL_STATE_DOWN); - goto end; - } - if (!event->channel->ring_count && (event->channel->state == FTDM_CHANNEL_STATE_DOWN && !ftdm_test_flag(event->channel, FTDM_CHANNEL_INTHREAD))) { - if (ftdm_test_flag(analog_data, FTDM_ANALOG_CALLERID)) { - ftdm_set_state(event->channel, FTDM_CHANNEL_STATE_GET_CALLERID); - } else { - ftdm_set_state(event->channel, FTDM_CHANNEL_STATE_RING); - } - event->channel->ring_count = 1; - ftdm_mutex_unlock(event->channel->mutex); - locked = 0; - ftdm_thread_create_detached(ftdm_analog_channel_run, event->channel); - } else { - event->channel->ring_count++; - } - } - break; - case FTDM_OOB_ONHOOK: - { - if (ftdm_test_flag(event->channel, FTDM_CHANNEL_RINGING)) { - ftdm_channel_command(event->channel, FTDM_COMMAND_GENERATE_RING_OFF, NULL); - } - - if (event->channel->state != FTDM_CHANNEL_STATE_DOWN) { - if (event->channel->state == FTDM_CHANNEL_STATE_HANGUP && - ftdm_test_flag(event->channel, FTDM_CHANNEL_STATE_CHANGE)) { - /* we do not need to process HANGUP since the device also hangup already */ - ftdm_channel_complete_state(event->channel); - } - ftdm_set_state(event->channel, FTDM_CHANNEL_STATE_DOWN); - } - if (event->channel->type == FTDM_CHAN_TYPE_FXS) { - /* we always return to forward when the device goes onhook */ - ftdm_polarity_t forward_polarity = FTDM_POLARITY_FORWARD; - ftdm_channel_command(event->channel, FTDM_COMMAND_SET_POLARITY, &forward_polarity); - } - } - break; - case FTDM_OOB_FLASH: - { - if (event->channel->state == FTDM_CHANNEL_STATE_CALLWAITING) { - ftdm_set_state(event->channel, FTDM_CHANNEL_STATE_UP); - ftdm_clear_flag(event->channel->span, FTDM_SPAN_STATE_CHANGE); - ftdm_channel_complete_state(event->channel); - event->channel->detected_tones[FTDM_TONEMAP_CALLWAITING_ACK] = 0; - } - - ftdm_channel_rotate_tokens(event->channel); - - if (ftdm_test_flag(event->channel, FTDM_CHANNEL_HOLD) && event->channel->token_count != 1) { - ftdm_set_state(event->channel, FTDM_CHANNEL_STATE_UP); - } else { - sig.event_id = FTDM_SIGEVENT_FLASH; - ftdm_span_send_signal(span, &sig); - } - } - break; - case FTDM_OOB_OFFHOOK: - { - if (event->channel->type == FTDM_CHAN_TYPE_FXS) { - if (ftdm_test_flag(event->channel, FTDM_CHANNEL_INTHREAD)) { - if (ftdm_test_flag(event->channel, FTDM_CHANNEL_RINGING)) { - ftdm_channel_command(event->channel, FTDM_COMMAND_GENERATE_RING_OFF, NULL); - } - ftdm_set_state(event->channel, FTDM_CHANNEL_STATE_UP); - } else { - if(!analog_data->max_dialstr) { - ftdm_set_state(event->channel, FTDM_CHANNEL_STATE_COLLECT); - } else { - ftdm_set_state(event->channel, FTDM_CHANNEL_STATE_DIALTONE); - } - ftdm_mutex_unlock(event->channel->mutex); - locked = 0; - ftdm_thread_create_detached(ftdm_analog_channel_run, event->channel); - } - } else { - if (!ftdm_test_flag(event->channel, FTDM_CHANNEL_INTHREAD)) { - if (ftdm_test_flag(event->channel, FTDM_CHANNEL_OFFHOOK)) { - ftdm_channel_command(event->channel, FTDM_COMMAND_ONHOOK, NULL); - } - } - ftdm_set_state(event->channel, FTDM_CHANNEL_STATE_DOWN); - } - } - break; - case FTDM_OOB_ALARM_TRAP: - { - sig.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED; - sig.ev_data.sigstatus.status = FTDM_SIG_STATE_DOWN; - ftdm_span_send_signal(span, &sig); - } - break; - case FTDM_OOB_ALARM_CLEAR: - { - sig.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED; - sig.ev_data.sigstatus.status = FTDM_SIG_STATE_UP; - ftdm_span_send_signal(span, &sig); - } - break; - case FTDM_OOB_POLARITY_REVERSE: - { - if (event->channel->type != FTDM_CHAN_TYPE_FXO) { - ftdm_log_chan_msg(event->channel, FTDM_LOG_WARNING, - "Ignoring polarity reversal, this should not happen in non-FXO channels!\n"); - break; - } - if (!ftdm_test_flag(event->channel, FTDM_CHANNEL_INTHREAD) && - ftdm_test_flag(event->channel, FTDM_CHANNEL_OFFHOOK)) { - ftdm_log_chan_msg(event->channel, FTDM_LOG_WARNING, - "Forcing onhook in channel not in thread after polarity reversal\n"); - ftdm_channel_command(event->channel, FTDM_COMMAND_ONHOOK, NULL); - break; - } - if (!ftdm_test_flag(analog_data, FTDM_ANALOG_ANSWER_POLARITY_REVERSE) - && !ftdm_test_flag(analog_data, FTDM_ANALOG_HANGUP_POLARITY_REVERSE)) { - ftdm_log_chan_msg(event->channel, FTDM_LOG_DEBUG, - "Ignoring polarity reversal because this channel is not configured for it\n"); - break; - } - if (event->channel->state == FTDM_CHANNEL_STATE_DOWN) { - if (ftdm_test_flag(analog_data, FTDM_ANALOG_CALLERID) - && ftdm_test_flag(analog_data, FTDM_ANALOG_POLARITY_CALLERID)) { - ftdm_log_chan_msg(event->channel, FTDM_LOG_DEBUG, "Polarity reversal detected while down, getting caller id now\n"); - ftdm_set_state(event->channel, FTDM_CHANNEL_STATE_GET_CALLERID); - event->channel->ring_count = 1; - ftdm_mutex_unlock(event->channel->mutex); - locked = 0; - ftdm_thread_create_detached(ftdm_analog_channel_run, event->channel); - } else { - ftdm_log_chan_msg(event->channel, FTDM_LOG_DEBUG, - "Ignoring polarity reversal because this channel is down\n"); - } - break; - } - /* we have a good channel, set the polarity flag and let the channel thread deal with it */ - ftdm_set_sflag(event->channel, AF_POLARITY_REVERSE); - } - break; - default: - { - ftdm_log_chan(event->channel, FTDM_LOG_DEBUG, "Ignoring event [%s] in state [%s]\n", ftdm_oob_event2str(event->enum_id), ftdm_channel_state2str(event->channel->state)); - } - break; - } - - end: - - if (locked) { - ftdm_mutex_unlock(event->channel->mutex); - } - return FTDM_SUCCESS; -} - -/** - * \brief Main thread function for analog span (monitor) - * \param me Current thread - * \param obj Span to run in this thread - */ -static void *ftdm_analog_run(ftdm_thread_t *me, void *obj) -{ - ftdm_span_t *span = (ftdm_span_t *) obj; - ftdm_analog_data_t *analog_data = span->signal_data; - int errs = 0; - - ftdm_unused_arg(me); - ftdm_log(FTDM_LOG_DEBUG, "ANALOG thread starting.\n"); - - while(ftdm_running() && ftdm_test_flag(analog_data, FTDM_ANALOG_RUNNING)) { - int waitms = 1000; - ftdm_status_t status; - - if ((status = ftdm_span_poll_event(span, waitms, NULL)) != FTDM_FAIL) { - errs = 0; - } - - switch(status) { - case FTDM_SUCCESS: - { - ftdm_event_t *event; - while (ftdm_span_next_event(span, &event) == FTDM_SUCCESS) { - if (event->enum_id == FTDM_OOB_NOOP) { - continue; - } - if (process_event(span, event) != FTDM_SUCCESS) { - goto end; - } - } - } - break; - case FTDM_FAIL: - { - ftdm_log(FTDM_LOG_ERROR, "Failure Polling event! [%s]\n", span->last_error); - if (++errs > 300) { - ftdm_log(FTDM_LOG_CRIT, "Too Many Errors!\n"); - goto end; - } - } - break; - default: - break; - } - - } - - end: - - ftdm_clear_flag(analog_data, FTDM_ANALOG_RUNNING); - - ftdm_log(FTDM_LOG_DEBUG, "ANALOG thread ending.\n"); - - return NULL; -} - -/** - * \brief FreeTDM analog signaling module initialisation - * \return Success - */ -static FIO_SIG_LOAD_FUNCTION(ftdm_analog_init) -{ - return FTDM_SUCCESS; -} - -/** - * \brief FreeTDM analog signaling module definition - */ -EX_DECLARE_DATA ftdm_module_t ftdm_module = { - "analog", - NULL, - NULL, - ftdm_analog_init, - ftdm_analog_configure_span, - NULL -}; - - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/ftmod/ftmod_analog_em/ftdm_analog_em.h b/libs/freetdm/src/ftmod/ftmod_analog_em/ftdm_analog_em.h deleted file mode 100644 index e52a319155..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_analog_em/ftdm_analog_em.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2008-2012, Anthony Minessale II - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Contributor(s): - * - * John Wehle (john@feith.com) - * Moises Silva (moy@sangoma.com) - * - */ - -#ifndef FTDM_ANALOG_EM_H -#define FTDM_ANALOG_EM_H -#include "freetdm.h" - -#define MAX_DIALSTRING 256 - -typedef enum { - FTDM_ANALOG_EM_RUNNING = (1 << 0), - FTDM_ANALOG_EM_LOCAL_WRITE = (1 << 2), - FTDM_ANALOG_EM_LOCAL_SUSPEND = (1 << 3), - FTDM_ANALOG_EM_REMOTE_SUSPEND = (1 << 4), -} ftdm_analog_em_flag_t; - -struct ftdm_analog_data { - uint32_t flags; - uint32_t max_dialstr; - uint32_t digit_timeout; - uint32_t dial_timeout; - ftdm_bool_t answer_supervision; - ftdm_bool_t immediate_ringback; - char ringback_file[512]; -}; - -static void *ftdm_analog_em_run(ftdm_thread_t *me, void *obj); -typedef struct ftdm_analog_data ftdm_analog_em_data_t; - -#endif - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/ftmod/ftmod_analog_em/ftmod_analog_em.2008.vcproj b/libs/freetdm/src/ftmod/ftmod_analog_em/ftmod_analog_em.2008.vcproj deleted file mode 100644 index 837ba7de0f..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_analog_em/ftmod_analog_em.2008.vcproj +++ /dev/null @@ -1,353 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/freetdm/src/ftmod/ftmod_analog_em/ftmod_analog_em.2010.vcxproj.filters b/libs/freetdm/src/ftmod/ftmod_analog_em/ftmod_analog_em.2010.vcxproj.filters deleted file mode 100644 index 3326f9fd16..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_analog_em/ftmod_analog_em.2010.vcxproj.filters +++ /dev/null @@ -1,23 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - - - Source Files - - - - - Header Files - - - \ No newline at end of file diff --git a/libs/freetdm/src/ftmod/ftmod_analog_em/ftmod_analog_em.c b/libs/freetdm/src/ftmod/ftmod_analog_em/ftmod_analog_em.c deleted file mode 100644 index 98fde2a514..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_analog_em/ftmod_analog_em.c +++ /dev/null @@ -1,1160 +0,0 @@ -/* - * Copyright (c) 2008-2012, Anthony Minessale II - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Contributor(s): - * - * John Wehle (john@feith.com) - * Moises Silva (moy@sangoma.com) - * - */ - -#include "private/ftdm_core.h" -#include "ftdm_analog_em.h" - -#ifndef localtime_r -struct tm * localtime_r(const time_t *clock, struct tm *result); -#endif - -static FIO_SPAN_SET_SIG_STATUS_FUNCTION(analog_em_set_span_sig_status); - -/* check if the given file is a wave file and skip the header if it is */ -#define WAVE_CHUNK_ID "RIFF" -#define WAVE_FMT "WAVEfmt " -#define WAVE_HEADER_LEN 44 -static int skip_wave_header(const char *fname, FILE *f) -{ - char rbuff[10] = { 0 }; - unsigned int hz = 0; - unsigned int hs = 0; - unsigned short fmt = 0; - unsigned short chans = 0; - unsigned int size = 0; - - /* check chunk id */ - if (fread(rbuff, 1, 4, f) != 4) { - ftdm_log(FTDM_LOG_ERROR, "Unable to read wav chunk id from file %s\n", fname); - goto error; - } - rbuff[4] = 0; - - if (strncasecmp(rbuff, WAVE_CHUNK_ID, sizeof(WAVE_CHUNK_ID)-1)) { - goto notwave; - } - - /* read chunk size */ - if (fread(&size, 1, 4, f) != 4) { - ftdm_log(FTDM_LOG_ERROR, "Unable to read wav chunk size from file %s\n", fname); - goto error; - } - - /* check format and sub chunk id */ - if (fread(rbuff, 1, 8, f) != 8) { - ftdm_log(FTDM_LOG_ERROR, "Unable to read wav format and sub chunk id from file %s\n", fname); - goto error; - } - rbuff[8] = 0; - - if (strncasecmp(rbuff, WAVE_FMT, sizeof(WAVE_FMT)-1)) { - goto notwave; - } - - /* At this point we know is a wav file ... */ - - /* validate sub chunk size */ - if (fread(&hs, 1, 4, f) != 4) { - ftdm_log(FTDM_LOG_ERROR, "Unable to read wav sub chunk size from file %s\n", fname); - goto error; - } - - if (hs != 16) { - ftdm_log(FTDM_LOG_ERROR, "Unsupported wav sub chunk size %d from file %s\n", hs, fname); - goto error; - } - - /* validate audio format */ - if (fread(&fmt, 1, 2, f) != 2) { - ftdm_log(FTDM_LOG_ERROR, "Unable to read wav audio format from file %s\n", fname); - goto error; - } - - if (fmt != 1) { - ftdm_log(FTDM_LOG_ERROR, "Unsupported wav audio format %d in file %s, we only support PCM\n", fmt, fname); - goto error; - } - - /* validate channels */ - if (fread(&chans, 1, 2, f) != 2) { - ftdm_log(FTDM_LOG_ERROR, "Unable to read wav channels from file %s\n", fname); - goto error; - } - - if (chans != 1) { - ftdm_log(FTDM_LOG_ERROR, "Unsupported number of channels %d in file %s, we only support 1 (mono)\n", chans, fname); - goto error; - } - - /* validate sampling rate */ - if (fread(&hz, 1, 2, f) != 2) { - ftdm_log(FTDM_LOG_ERROR, "Unable to read wav sampling rate from file %s\n", fname); - goto error; - } - - if (hz != 8000) { - ftdm_log(FTDM_LOG_ERROR, "Invalid input wav sampling rate %dHz, only 8000Hz supported\n", hz); - goto error; - } - - ftdm_log(FTDM_LOG_DEBUG, "Found input file %s. PCM mono wav of %d bytes at %dHz, skipping header ...\n", fname, size, hz); - fseek(f, WAVE_HEADER_LEN, SEEK_SET); - - return 0; - -notwave: - ftdm_log(FTDM_LOG_ERROR, "File %s is not a wav file\n", fname); - return -1; - -error: - return -1; -} - -static void *ftdm_analog_em_channel_run(ftdm_thread_t *me, void *obj); - -/** - * \brief Starts an EM channel thread (outgoing call) - * \param ftdmchan Channel to initiate call on - * \return Success or failure - * - * Initialises state, starts tone progress detection and runs the channel in a new a thread. - */ -static FIO_CHANNEL_OUTGOING_CALL_FUNCTION(analog_em_outgoing_call) -{ - if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OFFHOOK) && !ftdm_test_flag(ftdmchan, FTDM_CHANNEL_INTHREAD)) { - ftdm_channel_clear_needed_tones(ftdmchan); - ftdm_channel_clear_detected_tones(ftdmchan); - - ftdm_set_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND); - - ftdm_channel_command(ftdmchan, FTDM_COMMAND_OFFHOOK, NULL); - ftdm_channel_command(ftdmchan, FTDM_COMMAND_ENABLE_PROGRESS_DETECT, NULL); - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DIALING); - ftdm_thread_create_detached(ftdm_analog_em_channel_run, ftdmchan); - return FTDM_SUCCESS; - } - - return FTDM_FAIL; -} - -static ftdm_status_t ftdm_analog_em_sig_write(ftdm_channel_t *ftdmchan, void *data, ftdm_size_t size) -{ - ftdm_analog_em_data_t *analog_data = ftdmchan->span->signal_data; - if (ftdmchan->state == FTDM_CHANNEL_STATE_PROGRESS_MEDIA - && analog_data->immediate_ringback - && ftdm_test_sflag(ftdmchan, FTDM_ANALOG_EM_LOCAL_WRITE)) { - /* ringback is being played in the analog thread, ignore user data for now */ - return FTDM_BREAK; - } - return FTDM_SUCCESS; -} - -/** - * \brief Starts an EM span thread (monitor) - * \param span Span to monitor - * \return Success or failure - */ -static ftdm_status_t ftdm_analog_em_start(ftdm_span_t *span) -{ - ftdm_analog_em_data_t *analog_data = span->signal_data; - ftdm_set_flag(analog_data, FTDM_ANALOG_EM_RUNNING); - return ftdm_thread_create_detached(ftdm_analog_em_run, span); -} - -static void ftdm_analog_set_chan_sig_status(ftdm_channel_t *ftdmchan, ftdm_signaling_status_t status) -{ - ftdm_sigmsg_t sig; - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Signalling link status changed to %s\n", ftdm_signaling_status2str(status)); - - memset(&sig, 0, sizeof(sig)); - sig.chan_id = ftdmchan->chan_id; - sig.span_id = ftdmchan->span_id; - sig.channel = ftdmchan; - sig.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED; - sig.ev_data.sigstatus.status = status; - if (ftdm_span_send_signal(ftdmchan->span, &sig) != FTDM_SUCCESS) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Failed to change channel status to %s\n", ftdm_signaling_status2str(status)); - } - return; -} - -/** - * \brief Stops EM span thread (monitor) - * \param span Span to monitor - * \return Success or failure - */ -static ftdm_status_t ftdm_analog_em_stop(ftdm_span_t *span) -{ - ftdm_analog_em_data_t *analog_data = span->signal_data; - ftdm_clear_flag(analog_data, FTDM_ANALOG_EM_RUNNING); - ftdm_sleep(100); - analog_em_set_span_sig_status(span, FTDM_SIG_STATE_SUSPENDED); - return FTDM_SUCCESS; -} - -/** - * \brief Returns the signalling status on a channel - * \param ftdmchan Channel to get status on - * \param status Pointer to set signalling status - * \return Success or failure - */ -static FIO_CHANNEL_GET_SIG_STATUS_FUNCTION(analog_em_get_channel_sig_status) -{ - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_IN_ALARM)) { - *status = FTDM_SIG_STATE_DOWN; - return FTDM_SUCCESS; - } - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_SUSPENDED)) { - *status = FTDM_SIG_STATE_SUSPENDED; - return FTDM_SUCCESS; - } - *status = FTDM_SIG_STATE_UP; - return FTDM_SUCCESS; -} - -/** - * \brief Returns the signalling status on a span - * \param span Span to get status on - * \param status Pointer to set signalling status - * \return Success or failure - */ -static FIO_SPAN_GET_SIG_STATUS_FUNCTION(analog_em_get_span_sig_status) -{ - ftdm_iterator_t *citer = NULL; - ftdm_iterator_t *chaniter = ftdm_span_get_chan_iterator(span, NULL); - if (!chaniter) { - ftdm_log(FTDM_LOG_CRIT, "Failed to allocate channel iterator for span %s!\n", span->name); - return FTDM_FAIL; - } - /* if ALL channels are in alarm, report DOWN, UP otherwise. */ - *status = FTDM_SIG_STATE_DOWN; - for (citer = chaniter; citer; citer = ftdm_iterator_next(citer)) { - ftdm_channel_t *fchan = ftdm_iterator_current(citer); - ftdm_channel_lock(fchan); - if (!ftdm_test_flag(fchan, FTDM_CHANNEL_IN_ALARM)) { - if (!ftdm_test_flag(fchan, FTDM_CHANNEL_SUSPENDED)) { - *status = FTDM_SIG_STATE_UP; - ftdm_channel_unlock(fchan); - break; - } else { - *status = FTDM_SIG_STATE_SUSPENDED; - } - } - ftdm_channel_unlock(fchan); - } - ftdm_iterator_free(chaniter); - return FTDM_SUCCESS; -} - -static ftdm_status_t analog_em_set_channel_sig_status_ex(ftdm_channel_t *ftdmchan, ftdm_signaling_status_t status, ftdm_bool_t remote) -{ - switch (status) { - case FTDM_SIG_STATE_DOWN: - ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Cannot bring channel down, perhaps you want to try '%s'\n", ftdm_signaling_status2str(FTDM_SIG_STATE_SUSPENDED)); - return FTDM_FAIL; - case FTDM_SIG_STATE_SUSPENDED: - if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_SUSPENDED)) { - int cas_bits = 0xFF; - ftdm_set_flag(ftdmchan, FTDM_CHANNEL_SUSPENDED); - ftdm_channel_command(ftdmchan, FTDM_COMMAND_SET_CAS_BITS, &cas_bits); - if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OFFHOOK)) { - ftdm_channel_command(ftdmchan, FTDM_COMMAND_OFFHOOK, NULL); - } - ftdm_analog_set_chan_sig_status(ftdmchan, FTDM_SIG_STATE_SUSPENDED); - } - if (remote) { - ftdm_set_sflag(ftdmchan, FTDM_ANALOG_EM_REMOTE_SUSPEND); - } else { - ftdm_set_sflag(ftdmchan, FTDM_ANALOG_EM_LOCAL_SUSPEND); - } - break; - case FTDM_SIG_STATE_UP: - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_SUSPENDED)) { - if (remote) { - ftdm_clear_sflag(ftdmchan, FTDM_ANALOG_EM_REMOTE_SUSPEND); - } else { - ftdm_clear_sflag(ftdmchan, FTDM_ANALOG_EM_LOCAL_SUSPEND); - } - if (!ftdm_test_sflag(ftdmchan, FTDM_ANALOG_EM_REMOTE_SUSPEND) && - !ftdm_test_sflag(ftdmchan, FTDM_ANALOG_EM_LOCAL_SUSPEND)) { - int cas_bits = 0x00; - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_SUSPENDED); - ftdm_channel_command(ftdmchan, FTDM_COMMAND_SET_CAS_BITS, &cas_bits); - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OFFHOOK)) { - ftdm_channel_command(ftdmchan, FTDM_COMMAND_ONHOOK, NULL); - } - if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_IN_ALARM)) { - ftdm_analog_set_chan_sig_status(ftdmchan, FTDM_SIG_STATE_UP); - } - } - } - break; - default: - ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Cannot set signaling status to unknown value '%d'\n", status); - return FTDM_FAIL; - } - return FTDM_SUCCESS; -} - -static FIO_CHANNEL_SET_SIG_STATUS_FUNCTION(analog_em_set_channel_sig_status) -{ - return analog_em_set_channel_sig_status_ex(ftdmchan, status, FTDM_FALSE); -} - -static FIO_SPAN_SET_SIG_STATUS_FUNCTION(analog_em_set_span_sig_status) -{ - ftdm_iterator_t *chaniter = NULL; - ftdm_iterator_t *citer = NULL; - - chaniter = ftdm_span_get_chan_iterator(span, NULL); - if (!chaniter) { - ftdm_log(FTDM_LOG_CRIT, "Failed to allocate channel iterator for span %s!\n", span->name); - return FTDM_FAIL; - } - /* iterate over all channels, setting them to the requested state */ - for (citer = chaniter; citer; citer = ftdm_iterator_next(citer)) { - ftdm_channel_t *fchan = ftdm_iterator_current(citer); - /* we set channel's state through analog_em_set_channel_sig_status(), since it already takes care of notifying the user when appropriate */ - ftdm_channel_lock(fchan); - if ((analog_em_set_channel_sig_status_ex(fchan, status, FTDM_FALSE)) != FTDM_SUCCESS) { - ftdm_log_chan(fchan, FTDM_LOG_ERROR, "Failed to set signaling status to %s\n", ftdm_signaling_status2str(status)); - } - ftdm_channel_unlock(fchan); - } - ftdm_iterator_free(chaniter); - return FTDM_SUCCESS; -} - -/** - * \brief Initialises an EM span from configuration variables - * \param span Span to configure - * \param sig_cb Callback function for event signals - * \param ap List of configuration variables - * \return Success or failure - */ -static FIO_SIG_CONFIGURE_FUNCTION(ftdm_analog_em_configure_span) -//ftdm_status_t ftdm_analog_em_configure_span(ftdm_span_t *span, char *tonemap, uint32_t digit_timeout, uint32_t max_dialstr, fio_signal_cb_t sig_cb) -{ - ftdm_analog_em_data_t *analog_data = NULL; - const char *tonemap = "us"; - const char *ringback_file = ""; - ftdm_bool_t immediate_ringback = FTDM_FALSE; - uint32_t digit_timeout = 2000; - uint32_t max_dialstr = 11; - uint32_t dial_timeout = 0; - uint32_t release_guard_time_ms = 500; - ftdm_bool_t answer_supervision = FTDM_FALSE; - const char *var, *val; - int *intval; - - assert(sig_cb != NULL); - - if (span->signal_type) { - snprintf(span->last_error, sizeof(span->last_error), "Span is already configured for signalling."); - return FTDM_FAIL; - } - - analog_data = ftdm_calloc(1, sizeof(*analog_data)); - assert(analog_data != NULL); - - while((var = va_arg(ap, char *))) { - ftdm_log(FTDM_LOG_DEBUG, "Parsing analog em parameter '%s'\n", var); - if (!strcasecmp(var, "tonemap")) { - if (!(val = va_arg(ap, char *))) { - break; - } - tonemap = val; - } else if (!strcasecmp(var, "immediate_ringback")) { - if (!(val = va_arg(ap, char *))) { - break; - } - immediate_ringback = ftdm_true(val); - } else if (!strcasecmp(var, "ringback_file")) { - if (!(val = va_arg(ap, char *))) { - break; - } - ringback_file = val; - } else if (!strcasecmp(var, "answer_supervision")) { - if (!(val = va_arg(ap, char *))) { - break; - } - answer_supervision = ftdm_true(val); - } else if (!strcasecmp(var, "dial_timeout")) { - if (!(intval = va_arg(ap, int *))) { - break; - } - dial_timeout = *intval; - } else if (!strcasecmp(var, "digit_timeout")) { - if (!(intval = va_arg(ap, int *))) { - break; - } - digit_timeout = *intval; - } else if (!strcasecmp(var, "max_dialstr")) { - if (!(intval = va_arg(ap, int *))) { - break; - } - max_dialstr = *intval; - } else if (!strcasecmp(var, "release_guard_time_ms")) { - if (!(intval = va_arg(ap, int *))) { - break; - } - release_guard_time_ms = *intval; - } else { - ftdm_log(FTDM_LOG_ERROR, "Invalid parameter for analog em span: '%s'\n", var); - return FTDM_FAIL; - } - } - - - if (digit_timeout < 2000 || digit_timeout > 10000) { - digit_timeout = 2000; - } - - if (max_dialstr < 2 || max_dialstr > MAX_DIALSTRING) { - ftdm_log(FTDM_LOG_ERROR, "Invalid max_dialstr, setting to %d\n", MAX_DIALSTRING); - max_dialstr = MAX_DIALSTRING; - } - - span->start = ftdm_analog_em_start; - span->stop = ftdm_analog_em_stop; - span->sig_write = ftdm_analog_em_sig_write; - analog_data->digit_timeout = digit_timeout; - analog_data->max_dialstr = max_dialstr; - analog_data->dial_timeout = dial_timeout; - analog_data->answer_supervision = answer_supervision; - span->signal_cb = sig_cb; - span->signal_type = FTDM_SIGTYPE_ANALOG; - span->signal_data = analog_data; - span->outgoing_call = analog_em_outgoing_call; - span->get_channel_sig_status = analog_em_get_channel_sig_status; - span->get_span_sig_status = analog_em_get_span_sig_status; - span->set_channel_sig_status = analog_em_set_channel_sig_status; - span->set_span_sig_status = analog_em_set_span_sig_status; - span->sig_release_guard_time_ms = release_guard_time_ms; - ftdm_span_load_tones(span, tonemap); - if (immediate_ringback || !ftdm_strlen_zero(ringback_file)) { - analog_data->immediate_ringback = FTDM_TRUE; - ftdm_set_string(analog_data->ringback_file, ringback_file); - } - - return FTDM_SUCCESS; - -} - -/** - * \brief Retrieves tone generation output to be sent - * \param ts Teletone generator - * \param map Tone map - * \return -1 on error, 0 on success - */ -static int teletone_handler(teletone_generation_session_t *ts, teletone_tone_map_t *map) -{ - ftdm_buffer_t *dt_buffer = ts->user_data; - int wrote; - - if (!dt_buffer) { - return -1; - } - wrote = teletone_mux_tones(ts, map); - ftdm_buffer_write(dt_buffer, ts->buffer, wrote * 2); - return 0; -} - -/** - * \brief Main thread function for EM channel (outgoing call) - * \param me Current thread - * \param obj Channel to run in this thread - */ -static void *ftdm_analog_em_channel_run(ftdm_thread_t *me, void *obj) -{ - ftdm_channel_t *ftdmchan = (ftdm_channel_t *) obj; - ftdm_buffer_t *dt_buffer = NULL; - teletone_generation_session_t ts; - uint8_t frame[1024]; - ftdm_size_t len, rlen; - ftdm_tone_type_t tt = FTDM_TONE_DTMF; - char dtmf[128] = ""; - ftdm_size_t dtmf_offset = 0; - ftdm_analog_em_data_t *analog_data = ftdmchan->span->signal_data; - ftdm_channel_t *closed_chan; - uint32_t state_counter = 0, elapsed = 0, collecting = 0, interval = 0, last_digit = 0, indicate = 0, dial_timeout = 30000; - ftdm_sigmsg_t sig; - int cas_bits = 0; - uint32_t cas_answer = 0; - uint32_t cas_hangup = 0; - int cas_answer_ms = 500; - int cas_hangup_ms = 500; - ftdm_bool_t busy_timeout = FTDM_FALSE; - FILE *ringback_f = NULL; - ftdm_bool_t digits_sent = FTDM_FALSE; - - ftdm_unused_arg(me); - ftdm_log(FTDM_LOG_DEBUG, "ANALOG EM CHANNEL thread starting.\n"); - - ts.buffer = NULL; - - if (ftdm_channel_open_chan(ftdmchan) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "OPEN ERROR [%s]\n", ftdmchan->last_error); - goto done; - } - - if (ftdm_buffer_create(&dt_buffer, 1024, 3192, 0) != FTDM_SUCCESS) { - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "memory error!"); - ftdm_log(FTDM_LOG_ERROR, "MEM ERROR\n"); - goto done; - } - - if (ftdm_channel_command(ftdmchan, FTDM_COMMAND_ENABLE_DTMF_DETECT, &tt) != FTDM_SUCCESS) { - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "error initilizing tone detector!"); - ftdm_log(FTDM_LOG_ERROR, "TONE ERROR\n"); - goto done; - } - - ftdm_set_flag_locked(ftdmchan, FTDM_CHANNEL_INTHREAD); - teletone_init_session(&ts, 0, teletone_handler, dt_buffer); - ts.rate = 8000; -#if 0 - ts.debug = 1; - ts.debug_stream = stdout; -#endif - ftdm_channel_command(ftdmchan, FTDM_COMMAND_GET_INTERVAL, &interval); - ftdm_buffer_set_loops(dt_buffer, -1); - - memset(&sig, 0, sizeof(sig)); - sig.chan_id = ftdmchan->chan_id; - sig.span_id = ftdmchan->span_id; - sig.channel = ftdmchan; - - assert(interval != 0); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "IO Interval: %u\n", interval); - - if (analog_data->immediate_ringback && !ftdm_strlen_zero(analog_data->ringback_file)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Using ringback file '%s'\n", analog_data->ringback_file); - ringback_f = fopen(analog_data->ringback_file, "rb"); - if (!ringback_f) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Failed to open ringback file '%s'\n", analog_data->ringback_file); - } else { - if (skip_wave_header(analog_data->ringback_file, ringback_f)) { - ringback_f = NULL; - } - } - } - - while (ftdm_running() && ftdm_test_flag(ftdmchan, FTDM_CHANNEL_INTHREAD)) { - ftdm_wait_flag_t flags = FTDM_READ; - ftdm_size_t dlen = 0; - - elapsed += interval; - state_counter += interval; - - if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_STATE_CHANGE)) { - switch(ftdmchan->state) { - case FTDM_CHANNEL_STATE_DIALING: - { - if (! ftdmchan->needed_tones[FTDM_TONEMAP_RING] - && ftdm_test_flag(ftdmchan, FTDM_CHANNEL_WINK) - && !digits_sent) { - if (ftdm_strlen_zero(ftdmchan->caller_data.dnis.digits)) { - ftdm_log(FTDM_LOG_ERROR, "No Digits to send!\n"); - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_BUSY); - } else { - if (ftdm_channel_command(ftdmchan, FTDM_COMMAND_SEND_DTMF, ftdmchan->caller_data.dnis.digits) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "Send Digits Failed [%s]\n", ftdmchan->last_error); - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_BUSY); - } else { - state_counter = 0; - digits_sent = FTDM_TRUE; - ftdmchan->needed_tones[FTDM_TONEMAP_RING] = 1; - ftdmchan->needed_tones[FTDM_TONEMAP_BUSY] = 1; - ftdmchan->needed_tones[FTDM_TONEMAP_FAIL1] = 1; - ftdmchan->needed_tones[FTDM_TONEMAP_FAIL2] = 1; - ftdmchan->needed_tones[FTDM_TONEMAP_FAIL3] = 1; - dial_timeout = ((ftdmchan->dtmf_on + ftdmchan->dtmf_off) * strlen(ftdmchan->caller_data.dnis.digits)) + 2000; - if (analog_data->dial_timeout) { - dial_timeout += analog_data->dial_timeout; - } - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Outbound dialing timeout: %dms\n", dial_timeout); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Outbound CAS answer timeout: %dms\n", cas_answer_ms); - } - } - break; - } - if (state_counter > dial_timeout) { - if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_WINK)) { - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_BUSY); - } else if (!analog_data->answer_supervision) { - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_UP); - } - } - cas_bits = 0; - ftdm_channel_command(ftdmchan, FTDM_COMMAND_GET_CAS_BITS, &cas_bits); - if (!(state_counter % 1000)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "CAS bits: 0x%X\n", cas_bits); - } - if (cas_bits == 0xF) { - cas_answer += interval; - if (cas_answer >= cas_answer_ms) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Answering on CAS answer signal persistence!\n"); - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_UP); - } - } else if (cas_answer) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Resetting cas answer to 0: 0x%X!\n", cas_bits); - cas_answer = 0; - } - } - break; - case FTDM_CHANNEL_STATE_DIALTONE: - { - if (state_counter > 10000) { - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_BUSY); - } - } - break; - case FTDM_CHANNEL_STATE_BUSY: - { - if (state_counter > 20000) { - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_ATTN); - } - } - break; - case FTDM_CHANNEL_STATE_ATTN: - { - if (state_counter > 20000) { - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - } - } - break; - case FTDM_CHANNEL_STATE_HANGUP: - { - if (state_counter > 500) { - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OFFHOOK) && - (ftdmchan->last_state == FTDM_CHANNEL_STATE_RINGING || ftdmchan->last_state == FTDM_CHANNEL_STATE_DIALTONE - || ftdmchan->last_state == FTDM_CHANNEL_STATE_RING)) { - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_BUSY); - } else { - ftdmchan->caller_data.hangup_cause = FTDM_CAUSE_NORMAL_CLEARING; - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - } - } - } - break; - case FTDM_CHANNEL_STATE_UP: - case FTDM_CHANNEL_STATE_RING: - { - ftdm_sleep(interval); - if (ftdmchan->state == FTDM_CHANNEL_STATE_UP) { - cas_bits = 0; - ftdm_channel_command(ftdmchan, FTDM_COMMAND_GET_CAS_BITS, &cas_bits); - if (cas_bits == 0x0) { - cas_hangup += interval; - if (cas_hangup >= cas_hangup_ms) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_INFO, "Hanging up on CAS hangup signal persistence\n"); - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_HANGUP); - } - } else if (cas_hangup) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Resetting cas hangup to 0: 0x%X!\n", cas_bits); - cas_hangup = 0; - } - } - continue; - } - break; - case FTDM_CHANNEL_STATE_DOWN: - { - goto done; - } - break; - default: - break; - } - } else { - ftdm_clear_flag_locked(ftdmchan->span, FTDM_SPAN_STATE_CHANGE); - ftdm_channel_complete_state(ftdmchan); - indicate = 0; - state_counter = 0; - - ftdm_log(FTDM_LOG_DEBUG, "Executing state handler on %d:%d for %s\n", - ftdmchan->span_id, ftdmchan->chan_id, - ftdm_channel_state2str(ftdmchan->state)); - switch(ftdmchan->state) { - case FTDM_CHANNEL_STATE_UP: - { - ftdm_channel_use(ftdmchan); - ftdm_channel_clear_needed_tones(ftdmchan); - ftdm_channel_flush_dtmf(ftdmchan); - - if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OFFHOOK)) { - ftdm_channel_command(ftdmchan, FTDM_COMMAND_OFFHOOK, NULL); - } - - sig.event_id = FTDM_SIGEVENT_UP; - - ftdm_span_send_signal(ftdmchan->span, &sig); - continue; - } - break; - case FTDM_CHANNEL_STATE_DIALING: - { - ftdm_channel_use(ftdmchan); - } - break; - case FTDM_CHANNEL_STATE_RING: - { - ftdm_channel_use(ftdmchan); - - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { - ftdm_set_string(ftdmchan->caller_data.dnis.digits, ftdmchan->chan_number); - } else { - ftdm_set_string(ftdmchan->caller_data.dnis.digits, dtmf); - } - - sig.event_id = FTDM_SIGEVENT_START; - - ftdm_span_send_signal(ftdmchan->span, &sig); - continue; - } - break; - case FTDM_CHANNEL_STATE_DOWN: - { - sig.event_id = FTDM_SIGEVENT_STOP; - ftdm_span_send_signal(ftdmchan->span, &sig); - goto done; - } - break; - case FTDM_CHANNEL_STATE_DIALTONE: - { - memset(&ftdmchan->caller_data, 0, sizeof(ftdmchan->caller_data)); - *dtmf = '\0'; - dtmf_offset = 0; - ftdm_buffer_zero(dt_buffer); - teletone_run(&ts, ftdmchan->span->tone_map[FTDM_TONEMAP_DIAL]); - indicate = 1; - - ftdm_channel_command(ftdmchan, FTDM_COMMAND_WINK, NULL); - } - break; - case FTDM_CHANNEL_STATE_RINGING: - { - if (!analog_data->immediate_ringback) { - ftdm_buffer_zero(dt_buffer); - teletone_run(&ts, ftdmchan->span->tone_map[FTDM_TONEMAP_RING]); - indicate = 1; - } - } - break; - case FTDM_CHANNEL_STATE_BUSY: - { - ftdmchan->caller_data.hangup_cause = FTDM_CAUSE_NORMAL_CIRCUIT_CONGESTION; - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OFFHOOK) && !ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { - ftdm_buffer_zero(dt_buffer); - teletone_run(&ts, ftdmchan->span->tone_map[FTDM_TONEMAP_BUSY]); - indicate = 1; - } else { - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - busy_timeout = FTDM_TRUE; - } - } - break; - case FTDM_CHANNEL_STATE_ATTN: - { - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OFFHOOK) && !ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { - ftdm_buffer_zero(dt_buffer); - teletone_run(&ts, ftdmchan->span->tone_map[FTDM_TONEMAP_ATTN]); - indicate = 1; - } else { - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - } - } - break; - default: - break; - } - } - - - if (ftdmchan->state == FTDM_CHANNEL_STATE_DIALTONE || ftdmchan->state == FTDM_CHANNEL_STATE_COLLECT) { - if ((dlen = ftdm_channel_dequeue_dtmf(ftdmchan, dtmf + dtmf_offset, sizeof(dtmf) - strlen(dtmf)))) { - - if (ftdmchan->state == FTDM_CHANNEL_STATE_DIALTONE) { - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_COLLECT); - collecting = 1; - } - dtmf_offset = strlen(dtmf); - last_digit = elapsed; - sig.event_id = FTDM_SIGEVENT_COLLECTED_DIGIT; - ftdm_set_string(sig.ev_data.collected.digits, dtmf); - if (ftdm_span_send_signal(ftdmchan->span, &sig) == FTDM_BREAK) { - collecting = 0; - } - } - } - - if (last_digit && (!collecting || ((elapsed - last_digit > analog_data->digit_timeout) || strlen(dtmf) > analog_data->max_dialstr))) { - ftdm_log(FTDM_LOG_DEBUG, "Number obtained [%s]\n", dtmf); - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_RING); - last_digit = 0; - collecting = 0; - } - - if (ftdm_channel_wait(ftdmchan, &flags, interval * 2) != FTDM_SUCCESS) { - continue; - } - - if (!(flags & FTDM_READ)) { - continue; - } - - /* Do not try to read more than the proper interval size */ - len = ftdmchan->packet_len * 2; - if (ftdm_channel_read(ftdmchan, frame, &len) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "READ ERROR [%s]\n", ftdmchan->last_error); - goto done; - } - - if (0 == len) { - ftdm_log(FTDM_LOG_DEBUG, "Nothing read\n"); - continue; - } - - if (len >= (sizeof(frame)/2)) { - ftdm_log(FTDM_LOG_CRIT, "Ignoring big read of %zd bytes!\n", len); - continue; - } - - if (ftdmchan->detected_tones[0]) { - int i; - - for (i = 1; i < FTDM_TONEMAP_INVALID; i++) { - if (ftdmchan->detected_tones[i]) { - ftdm_log(FTDM_LOG_DEBUG, "Detected tone %s on %d:%d\n", ftdm_tonemap2str(i), ftdmchan->span_id, ftdmchan->chan_id); - } - } - - if (ftdmchan->detected_tones[FTDM_TONEMAP_BUSY] || - ftdmchan->detected_tones[FTDM_TONEMAP_FAIL1] || - ftdmchan->detected_tones[FTDM_TONEMAP_FAIL2] || - ftdmchan->detected_tones[FTDM_TONEMAP_FAIL3] || - ftdmchan->detected_tones[FTDM_TONEMAP_ATTN] - ) { - ftdm_log(FTDM_LOG_ERROR, "Failure indication detected!\n"); - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_BUSY); - } else if (ftdmchan->detected_tones[FTDM_TONEMAP_RING]) { - if (!analog_data->answer_supervision) { - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_UP); - } else { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Ringing, but not answering since answer supervision is enabled\n"); - } - } - - ftdm_channel_clear_detected_tones(ftdmchan); - } - - if ((ftdmchan->dtmf_buffer && ftdm_buffer_inuse(ftdmchan->dtmf_buffer))) { - rlen = len; - memset(frame, 0, len); - ftdm_channel_write(ftdmchan, frame, sizeof(frame), &rlen); - continue; - } - - if (analog_data->immediate_ringback && - (ftdmchan->state == FTDM_CHANNEL_STATE_COLLECT || - ftdmchan->state == FTDM_CHANNEL_STATE_RING || - ftdmchan->state == FTDM_CHANNEL_STATE_RINGING || - ftdmchan->state == FTDM_CHANNEL_STATE_PROGRESS || - ftdmchan->state == FTDM_CHANNEL_STATE_PROGRESS_MEDIA - )) { - indicate = 1; - if (!ringback_f) { - ftdm_buffer_zero(dt_buffer); - teletone_run(&ts, ftdmchan->span->tone_map[FTDM_TONEMAP_RING]); - } - } - - if (!indicate) { - continue; - } - - if (ftdmchan->effective_codec != FTDM_CODEC_SLIN) { - len *= 2; - } - - if (ringback_f) { - uint8_t failed_read = 0; -read_try: - rlen = fread(frame, 1, len, ringback_f); - if (rlen != len) { - if (!feof(ringback_f)) { - ftdm_log(FTDM_LOG_ERROR, "Error reading from ringback file: %zd != %zd\n", rlen, len); - } - if (failed_read) { - continue; - } - /* return cursor to start of wav file */ - fseek(ringback_f, WAVE_HEADER_LEN, SEEK_SET); - failed_read++; - goto read_try; - } - } else { - rlen = ftdm_buffer_read_loop(dt_buffer, frame, len); - } - - if (ftdmchan->effective_codec != FTDM_CODEC_SLIN) { - fio_codec_t codec_func = NULL; - - if (ftdmchan->native_codec == FTDM_CODEC_ULAW) { - codec_func = fio_slin2ulaw; - } else if (ftdmchan->native_codec == FTDM_CODEC_ALAW) { - codec_func = fio_slin2alaw; - } - - if (codec_func) { - codec_func(frame, sizeof(frame), &rlen); - } else { - ftdm_log(FTDM_LOG_ERROR, "codec error, no codec function for native codec %d!", ftdmchan->native_codec); - goto done; - } - } - - /* we must lock the channel and make sure we let our own generated audio thru (FTDM_ANALOG_EM_LOCAL_WRITE is tested in the ftdm_analog_em_sig_write handler)*/ - ftdm_channel_lock(ftdmchan); - ftdm_set_sflag(ftdmchan, FTDM_ANALOG_EM_LOCAL_WRITE); - ftdm_channel_write(ftdmchan, frame, sizeof(frame), &rlen); - ftdm_clear_sflag(ftdmchan, FTDM_ANALOG_EM_LOCAL_WRITE); - ftdm_channel_unlock(ftdmchan); - } - - done: - - ftdm_channel_command(ftdmchan, FTDM_COMMAND_ONHOOK, NULL); - if (busy_timeout) { - ftdm_channel_command(ftdmchan, FTDM_COMMAND_GET_CAS_BITS, &cas_bits); - if (cas_bits == 0XF) { - /* the remote end never sent any digits, neither moved to onhook, let's stay suspended */ - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Moving channel to suspended after timeout, remote end still offhook\n"); - analog_em_set_channel_sig_status_ex(ftdmchan, FTDM_SIG_STATE_SUSPENDED, FTDM_TRUE); - } - } - - closed_chan = ftdmchan; - ftdm_channel_close(&ftdmchan); - - ftdm_channel_command(closed_chan, FTDM_COMMAND_SET_NATIVE_CODEC, NULL); - - if (ts.buffer) { - teletone_destroy_session(&ts); - } - - if (dt_buffer) { - ftdm_buffer_destroy(&dt_buffer); - } - - if (ringback_f) { - fclose(ringback_f); - } - - ftdm_clear_flag(closed_chan, FTDM_CHANNEL_INTHREAD); - - ftdm_log(FTDM_LOG_DEBUG, "ANALOG EM CHANNEL thread ended.\n"); - - return NULL; -} - -/** - * \brief Processes EM events coming from ftdmtel/dahdi - * \param span Span on which the event was fired - * \param event Event to be treated - * \return Success or failure - */ -static __inline__ ftdm_status_t process_event(ftdm_span_t *span, ftdm_event_t *event) -{ - ftdm_sigmsg_t sig; - int locked = 0; - - memset(&sig, 0, sizeof(sig)); - sig.chan_id = event->channel->chan_id; - sig.span_id = event->channel->span_id; - sig.channel = event->channel; - - ftdm_unused_arg(span); - ftdm_log(FTDM_LOG_DEBUG, "EVENT [%s][%d:%d] STATE [%s]\n", - ftdm_oob_event2str(event->enum_id), event->channel->span_id, event->channel->chan_id, ftdm_channel_state2str(event->channel->state)); - - ftdm_mutex_lock(event->channel->mutex); - locked++; - - if (event->enum_id == FTDM_OOB_ONHOOK && ftdm_test_sflag(event->channel, FTDM_ANALOG_EM_REMOTE_SUSPEND)) { - /* We've got remote suspend, now we're back on hook, lift the remote suspend status */ - analog_em_set_channel_sig_status_ex(event->channel, FTDM_SIG_STATE_UP, FTDM_TRUE); - } - - if (ftdm_test_flag(event->channel, FTDM_CHANNEL_SUSPENDED)) { - ftdm_log(FTDM_LOG_WARNING, "Ignoring event %s on channel %d:%d in state %s, channel is suspended\n", - ftdm_oob_event2str(event->enum_id), event->channel->span_id, event->channel->chan_id, ftdm_channel_state2str(event->channel->state)); - goto done; - } - - switch(event->enum_id) { - case FTDM_OOB_ONHOOK: - { - if (event->channel->state != FTDM_CHANNEL_STATE_DOWN) { - ftdm_set_state_locked(event->channel, FTDM_CHANNEL_STATE_DOWN); - } - - } - break; - case FTDM_OOB_OFFHOOK: - { - if (ftdm_test_flag(event->channel, FTDM_CHANNEL_INTHREAD)) { - if (event->channel->state < FTDM_CHANNEL_STATE_UP) { - ftdm_set_state_locked(event->channel, FTDM_CHANNEL_STATE_UP); - } - } else { - ftdm_set_state_locked(event->channel, FTDM_CHANNEL_STATE_DIALTONE); - ftdm_mutex_unlock(event->channel->mutex); - locked = 0; - ftdm_thread_create_detached(ftdm_analog_em_channel_run, event->channel); - } - break; - } - case FTDM_OOB_WINK: - { - if (event->channel->state != FTDM_CHANNEL_STATE_DIALING) { - ftdm_set_state_locked(event->channel, FTDM_CHANNEL_STATE_DOWN); - } else { - ftdm_set_flag_locked(event->channel, FTDM_CHANNEL_WINK); - } - - } - break; - } - -done: - - if (locked) { - ftdm_mutex_unlock(event->channel->mutex); - } - return FTDM_SUCCESS; -} - -/** - * \brief Main thread function for EM span (monitor) - * \param me Current thread - * \param obj Span to run in this thread - */ -static void *ftdm_analog_em_run(ftdm_thread_t *me, void *obj) -{ - ftdm_span_t *span = (ftdm_span_t *) obj; - ftdm_analog_em_data_t *analog_data = span->signal_data; - - ftdm_unused_arg(me); - ftdm_log(FTDM_LOG_DEBUG, "ANALOG EM thread starting.\n"); - analog_em_set_span_sig_status(span, FTDM_SIG_STATE_UP); - - while(ftdm_running() && ftdm_test_flag(analog_data, FTDM_ANALOG_EM_RUNNING)) { - int waitms = 10; - ftdm_status_t status; - - status = ftdm_span_poll_event(span, waitms, NULL); - - switch(status) { - case FTDM_SUCCESS: - { - ftdm_event_t *event; - while (ftdm_span_next_event(span, &event) == FTDM_SUCCESS) { - if (event->enum_id == FTDM_OOB_NOOP) { - continue; - } - if (process_event(span, event) != FTDM_SUCCESS) { - goto end; - } - } - } - break; - case FTDM_FAIL: - { - ftdm_log(FTDM_LOG_ERROR, "Failure Polling event! [%s]\n", span->last_error); - } - break; - default: - break; - } - - } - - end: - - ftdm_clear_flag(analog_data, FTDM_ANALOG_EM_RUNNING); - - ftdm_log(FTDM_LOG_DEBUG, "ANALOG EM thread ending.\n"); - - return NULL; -} - -/** - * \brief FreeTDM analog EM module initialisation - * \return Success - */ -static FIO_SIG_LOAD_FUNCTION(ftdm_analog_em_init) -{ - return FTDM_SUCCESS; -} - -/** - * \brief FreeTDM analog EM module definition - */ -EX_DECLARE_DATA ftdm_module_t ftdm_module = { - "analog_em", - NULL, - NULL, - ftdm_analog_em_init, - ftdm_analog_em_configure_span, - NULL -}; - - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/ftmod/ftmod_gsm/ftmod_gsm.c b/libs/freetdm/src/ftmod/ftmod_gsm/ftmod_gsm.c deleted file mode 100755 index 0dbe1e647b..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_gsm/ftmod_gsm.c +++ /dev/null @@ -1,1592 +0,0 @@ -/* - * Copyright (c) 2011, Sangoma Technologies - * All rights reserved. - * - 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Contributors: - * - * Gideon Sadan - * Moises Silva - * - */ - - -#define _GNU_SOURCE - -#include -#include - -#ifndef __WINDOWS__ -#include -#include -#include -#endif - -#include -#include -#include -/*========================*/ - -#include -#include -#include - -#include - -/********************************************************************************/ -/* */ -/* MACROS */ -/* */ -/********************************************************************************/ -// Macro to send signals -#define SEND_STATE_SIGNAL(sig) \ - { \ - ftdm_sigmsg_t sigev; \ - memset(&sigev, 0, sizeof(sigev)); \ - sigev.event_id = sig; \ - sigev.channel = ftdmchan; \ - ftdm_span_send_signal(ftdmchan->span, &sigev); \ - } - -// Syntax message -#define FT_SYNTAX "USAGE:\n" \ -"--------------------------------------------------------------------------------\n" \ -"ftdm gsm version \n" \ -"ftdm gsm status \n" \ -"ftdm gsm sms \n" \ -"ftdm gsm exec \n" \ -"ftdm gsm call [number]\n" \ -"--------------------------------------------------------------------------------\n" - -// Used to declare command handler -#define COMMAND_HANDLER(name) \ - static ftdm_status_t gsm_cmd_##name(ftdm_stream_handle_t *stream, char *argv[], int argc); \ - ftdm_status_t gsm_cmd_##name(ftdm_stream_handle_t *stream, char *argv[], int argc) - -// Used to define command entry in the command map -#define COMMAND(name, argc) {#name, argc, gsm_cmd_##name} - -/********************************************************************************/ -/* */ -/* types */ -/* */ -/********************************************************************************/ - -typedef enum { - FTDM_GSM_RUNNING = (1 << 0), - FTDM_GSM_SPAN_STARTED = (1 << 1), -} ftdm_gsm_flag_t; - -// private data -typedef struct ftdm_gsm_span_data_s { - ftdm_span_t *span; - ftdm_channel_t *dchan; - ftdm_channel_t *bchan; - int32_t call_id; - uint32_t sms_id; - char conditional_forward_prefix[10]; - char conditional_forward_number[50]; - char immediate_forward_prefix[10]; - struct { - char number[50]; - char span[50]; - } immediate_forward_numbers[10]; - char disable_forward_number[50]; - ftdm_sched_t *sched; - ftdm_timer_id_t conditional_forwarding_timer; - ftdm_timer_id_t immediate_forwarding_timer; - ftdm_bool_t init_conditional_forwarding; - ftdm_bool_t startup_forwarding_disabled; - char startup_commands[20][50]; - ftdm_gsm_flag_t flags; - ftdm_bool_t sig_up; -} ftdm_gsm_span_data_t; - -// command handler function type. -typedef ftdm_status_t (*command_handler_t)(ftdm_stream_handle_t *stream, char *argv[], int argc); - -typedef struct ftdm_gsm_exec_helper { - ftdm_span_t *span; - ftdm_stream_handle_t *stream; - uint8_t cmd_pending; -} ftdm_gsm_exec_helper_t; - -/********************************************************************************/ -/* */ -/* function declaration */ -/* */ -/********************************************************************************/ -static ftdm_status_t init_wat_lib(void); -static int wat_lib_initialized = 0; -static FIO_API_FUNCTION(ftdm_gsm_api); - -/* ugh, wasteful since unlikely anyone will ever have more than 4 or 8 GSM spans, but we couldn't use ftdm_find_span() - * because during the stop sequence the internal span lock is held and we end up deadlocked, ideally libwat would just give - * us a pointer we provide instead of a span id */ -static ftdm_span_t * span_map[255] = { 0 }; - -/* wat callbacks */ -static int on_wat_span_write(unsigned char span_id, void *buffer, unsigned len); - -static void on_wat_con_ind(unsigned char span_id, uint8_t call_id, wat_con_event_t *con_event); -static void on_wat_con_sts(unsigned char span_id, uint8_t call_id, wat_con_status_t *status); -static void on_wat_rel_ind(unsigned char span_id, uint8_t call_id, wat_rel_event_t *rel_event); -static void on_wat_rel_cfm(unsigned char span_id, uint8_t call_id); -static void on_wat_sms_ind(unsigned char span_id, wat_sms_event_t *sms_event); -static void on_wat_sms_sts(unsigned char span_id, uint8_t sms_id, wat_sms_status_t *status); - -static void on_wat_log(uint8_t level, char *fmt, ...); -static void *on_wat_malloc(size_t size); -static void *on_wat_calloc(size_t nmemb, size_t size); -static void on_wat_free(void *ptr); -static void on_wat_log_span(uint8_t span_id, uint8_t level, char *fmt, ...); - -static ftdm_span_t *get_span_by_id(uint8_t span_id, ftdm_gsm_span_data_t **gsm_data); - -static void *ftdm_gsm_run(ftdm_thread_t *me, void *obj); - -/********************************************************************************/ -/* */ -/* static & global data */ -/* */ -/********************************************************************************/ - -/* At the moment we support only one concurrent call per span, so no need to have different ids */ -#define GSM_OUTBOUND_CALL_ID 8 - -/* IO interface for the command API */ -static ftdm_io_interface_t g_ftdm_gsm_interface; - -/********************************************************************************/ -/* */ -/* implementation */ -/* */ -/********************************************************************************/ -static int on_wat_span_write(unsigned char span_id, void *buffer, unsigned len) -{ - ftdm_span_t *span = NULL; - ftdm_status_t status = FTDM_FAIL; - ftdm_gsm_span_data_t *gsm_data = NULL; - ftdm_size_t outsize = len; - - status = ftdm_span_find(span_id, &span); - if (status != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "Failed to find span %d to write %d bytes\n", span_id, len); - return -1; - } - - gsm_data = span->signal_data; - status = ftdm_channel_write(gsm_data->dchan, (void *)buffer, len, &outsize); - if (status != FTDM_SUCCESS) { - char errbuf[255]; - ftdm_log(FTDM_LOG_ERROR, "Failed to write %d bytes to d-channel in span %s: %s\n", len, span->name, strerror_r(errno, errbuf, sizeof(errbuf))); - return -1; - } - return len; -} - -static void ftdm_gsm_make_raw_call(ftdm_gsm_span_data_t *gsm_data, const char *number) -{ - wat_con_event_t con_event; - - ftdm_channel_lock(gsm_data->bchan); - - if (ftdm_test_flag(gsm_data->bchan, FTDM_CHANNEL_INUSE)) { - ftdm_log_chan(gsm_data->bchan, FTDM_LOG_ERROR, "Failed to place raw call to %s: channel busy\n", number); - goto done; - } - - ftdm_log_chan(gsm_data->bchan, FTDM_LOG_INFO, "Placing raw call to %s\n", number); - ftdm_set_flag(gsm_data->bchan, FTDM_CHANNEL_INUSE); - - gsm_data->call_id = GSM_OUTBOUND_CALL_ID; - memset(&con_event, 0, sizeof(con_event)); - ftdm_set_string(con_event.called_num.digits, number); - wat_con_req(gsm_data->span->span_id, gsm_data->call_id , &con_event); - -done: - ftdm_channel_unlock(gsm_data->bchan); -} - -static void ftdm_gsm_enable_conditional_forwarding(void *data) -{ - char number[255]; - ftdm_gsm_span_data_t *gsm_data = data; - snprintf(number, sizeof(number), "%s%s", gsm_data->conditional_forward_prefix, gsm_data->conditional_forward_number); - ftdm_log_chan(gsm_data->bchan, FTDM_LOG_INFO, "Enabling conditional forwarding to %s\n", number); - ftdm_gsm_make_raw_call(data, number); -} - -static void on_wat_span_status(unsigned char span_id, wat_span_status_t *status) -{ - ftdm_gsm_span_data_t *gsm_data = NULL; - ftdm_span_t *span = get_span_by_id(span_id, &gsm_data); - - switch (status->type) { - case WAT_SPAN_STS_READY: - { - int i = 0; - ftdm_log(FTDM_LOG_INFO, "span %s: Ready\n", span->name); - for (i = 0; !ftdm_strlen_zero_buf(gsm_data->startup_commands[i]); i++) { - ftdm_log(FTDM_LOG_INFO, "span %d: Executing startup command '%s'\n", span_id, gsm_data->startup_commands[i]); - if (WAT_SUCCESS != wat_cmd_req(span_id, gsm_data->startup_commands[i], NULL, NULL)) { - ftdm_log(FTDM_LOG_ERROR, "span %d: Failed requesting execution of command '%s'\n", span_id, gsm_data->startup_commands[i]); - } - } - } - break; - case WAT_SPAN_STS_SIGSTATUS: - { - if (status->sts.sigstatus == WAT_SIGSTATUS_UP) { - ftdm_log_chan_msg(gsm_data->bchan, FTDM_LOG_INFO, "Signaling is now up\n"); - gsm_data->sig_up = FTDM_TRUE; - } else { - ftdm_log_chan_msg(gsm_data->bchan, FTDM_LOG_INFO, "Signaling is now down\n"); - gsm_data->sig_up = FTDM_FALSE; - } - if (gsm_data->init_conditional_forwarding == FTDM_TRUE && !ftdm_strlen_zero_buf(gsm_data->conditional_forward_number)) { - ftdm_sched_timer(gsm_data->sched, "conditional_forwarding_delay", 1000, - ftdm_gsm_enable_conditional_forwarding, - gsm_data, - &gsm_data->conditional_forwarding_timer); - gsm_data->init_conditional_forwarding = FTDM_FALSE; - } - } - break; - case WAT_SPAN_STS_SIM_INFO_READY: - { - const wat_sim_info_t *sim_info = NULL; - ftdm_log(FTDM_LOG_INFO, "span %s: SIM information ready\n", span->name); - sim_info = wat_span_get_sim_info(span->span_id); - if (!ftdm_strlen_zero(sim_info->subscriber.digits)) { - ftdm_set_string(gsm_data->bchan->chan_number, sim_info->subscriber.digits); - } - } - break; - case WAT_SPAN_STS_ALARM: - { - ftdm_log(FTDM_LOG_INFO, "span %s: Alarm received\n", span->name); - } - break; - default: - { - ftdm_log(FTDM_LOG_INFO, "span %s: Unhandled span status notification %d\n", span->name, status->type); - } - break; - } -} - -static void on_wat_con_ind(uint8_t span_id, uint8_t call_id, wat_con_event_t *con_event) -{ - ftdm_span_t *span = NULL; - ftdm_gsm_span_data_t *gsm_data = NULL; - - ftdm_log(FTDM_LOG_INFO, "s%d: Incoming call (id:%d) Calling Number:%s Calling Name:\"%s\" type:%d plan:%d\n", span_id, call_id, con_event->calling_num.digits, con_event->calling_name, con_event->calling_num.type, con_event->calling_num.plan); - - span = get_span_by_id(span_id, &gsm_data); - - gsm_data->call_id = call_id; - - // cid name - ftdm_set_string(gsm_data->bchan->caller_data.cid_name, con_event->calling_name); - - // cid number - ftdm_set_string(gsm_data->bchan->caller_data.cid_num.digits, con_event->calling_num.digits); - - // destination number - ftdm_set_string(gsm_data->bchan->caller_data.dnis.digits, gsm_data->bchan->chan_number); - - ftdm_set_state(gsm_data->bchan, FTDM_CHANNEL_STATE_RING); - - if (ftdm_channel_open_chan(gsm_data->bchan) != FTDM_SUCCESS) { - ftdm_log_chan(gsm_data->bchan, FTDM_LOG_ERROR, "Failed to open GSM b-channel of span %s!\n", span->name); - } - -} - -static ftdm_span_t *get_span_by_id(unsigned char span_id, ftdm_gsm_span_data_t **gsm_data) -{ - ftdm_span_t *span = NULL; - - if (gsm_data) { - (*gsm_data) = NULL; - } - - span = span_map[span_id]; - if (gsm_data) { - (*gsm_data) = span->signal_data; - } - return span; -} - -static void on_wat_con_sts(unsigned char span_id, uint8_t call_id, wat_con_status_t *status) -{ - ftdm_span_t *span = NULL; - ftdm_channel_state_t state = FTDM_CHANNEL_STATE_END; - ftdm_gsm_span_data_t *gsm_data = NULL; - - if (!(span = get_span_by_id(span_id, &gsm_data))) { - return; - } - - switch (status->type) { - case WAT_CON_STATUS_TYPE_RINGING: - ftdm_log_chan_msg(gsm_data->bchan, FTDM_LOG_INFO, "Received ringing indication\n"); - state = FTDM_CHANNEL_STATE_RINGING; - break; - - case WAT_CON_STATUS_TYPE_ANSWER: - ftdm_log_chan_msg(gsm_data->bchan, FTDM_LOG_INFO, "Received answer indication\n"); - state = FTDM_CHANNEL_STATE_PROGRESS_MEDIA; - break; - - default: - ftdm_log_chan(gsm_data->bchan, FTDM_LOG_WARNING, "Unhandled indication status %d\n", status->type); - break; - - } - - if (state != FTDM_CHANNEL_STATE_END && gsm_data->bchan->state != FTDM_CHANNEL_STATE_DOWN) { - ftdm_set_state(gsm_data->bchan, state); - } -} - -static void on_wat_rel_ind(unsigned char span_id, uint8_t call_id, wat_rel_event_t *rel_event) -{ - ftdm_span_t *span = NULL; - ftdm_gsm_span_data_t *gsm_data = NULL; - - ftdm_log(FTDM_LOG_INFO, "s%d: Call hangup (id:%d) cause:%d\n", span_id, call_id, rel_event->cause); - - if (!(span = get_span_by_id(span_id, &gsm_data))) { - return; - } - - if (gsm_data->bchan->state == FTDM_CHANNEL_STATE_DOWN) { - /* This is most likely due to a call to enable call - * forwarding, which does not run the state machine */ - ftdm_clear_flag(gsm_data->bchan, FTDM_CHANNEL_INUSE); - wat_rel_req(span_id, call_id); - return; - } - - if (gsm_data->bchan->state > FTDM_CHANNEL_STATE_DOWN && - gsm_data->bchan->state < FTDM_CHANNEL_STATE_HANGUP) { - ftdm_set_state(gsm_data->bchan, FTDM_CHANNEL_STATE_HANGUP); - } -} - -static void on_wat_rel_cfm(unsigned char span_id, uint8_t call_id) -{ - ftdm_span_t *span = NULL; - ftdm_gsm_span_data_t *gsm_data = NULL; - - ftdm_log(FTDM_LOG_INFO, "s%d: Call hangup complete (id:%d)\n", span_id, call_id); - - if (!(span = get_span_by_id(span_id, &gsm_data))) { - return; - } - - if (gsm_data->bchan->state == FTDM_CHANNEL_STATE_DOWN) { - /* This is most likely due to a call to enable call - * forwarding, which does not run the state machine */ - ftdm_clear_flag(gsm_data->bchan, FTDM_CHANNEL_INUSE); - return; - } - - switch(gsm_data->dchan->state) { - case FTDM_CHANNEL_STATE_UP: - ftdm_set_state(gsm_data->bchan, FTDM_CHANNEL_STATE_HANGUP); - break; - default: - ftdm_set_state(gsm_data->bchan, FTDM_CHANNEL_STATE_DOWN); - break; - } -} - -static void on_wat_sms_ind(unsigned char span_id, wat_sms_event_t *sms_event) -{ - ftdm_span_t *span = NULL; - ftdm_channel_t *ftdmchan; - - ftdm_gsm_span_data_t *gsm_data = NULL; - - if(!(span = get_span_by_id(span_id, &gsm_data))) { - return; - } - - ftdmchan = gsm_data->dchan; - - { - ftdm_sms_data_t sms_data; - ftdm_sigmsg_t sigev; - memset(&sms_data, 0, sizeof(sms_data)); - - strncpy(sms_data.from, sms_event->from.digits, sizeof(sms_data.from)); - strncpy(sms_data.body, sms_event->content.data, sizeof(sms_data.body)); - - memset(&sigev, 0, sizeof(sigev)); - sigev.event_id = FTDM_SIGEVENT_SMS; - sigev.channel = ftdmchan ; - gsm_data->dchan->caller_data.priv = (void *)&sms_data; - ftdm_span_send_signal(span, &sigev); - } - return; -} - -static void on_wat_sms_sts(unsigned char span_id, uint8_t sms_id, wat_sms_status_t *status) -{ - if (status->success) { - ftdm_log(FTDM_LOG_INFO, "Span %d SMS Send - OK\n", span_id ); - } else { - ftdm_log(FTDM_LOG_CRIT, "Span %d SMS Send - FAIL (%s)\n", span_id, status->error); - } -} - -static void on_wat_dtmf_ind(unsigned char span_id, const char *dtmf) -{ - ftdm_span_t *span = NULL; - ftdm_gsm_span_data_t *gsm_data = NULL; - - if (!(span = get_span_by_id(span_id, &gsm_data))) { - return; - } - - ftdm_channel_queue_dtmf(gsm_data->bchan, dtmf); -} - - -static void on_wat_log(uint8_t level, char *fmt, ...) -{ - int ftdm_level; - char buff[4096]; - - va_list argptr; - va_start(argptr, fmt); - - switch(level) { - case WAT_LOG_CRIT: ftdm_level = FTDM_LOG_LEVEL_CRIT; break; - case WAT_LOG_ERROR: ftdm_level = FTDM_LOG_LEVEL_ERROR; break; - case WAT_LOG_WARNING: ftdm_level = FTDM_LOG_LEVEL_WARNING; break; - case WAT_LOG_INFO: ftdm_level = FTDM_LOG_LEVEL_INFO; break; - case WAT_LOG_NOTICE: ftdm_level = FTDM_LOG_LEVEL_NOTICE; break; - case WAT_LOG_DEBUG: ftdm_level = FTDM_LOG_LEVEL_DEBUG; break; - default: ftdm_level = FTDM_LOG_LEVEL_ERROR; break; - }; - - - vsprintf(buff, fmt, argptr); - - ftdm_log(FTDM_PRE, ftdm_level, "%s", buff); - - va_end(argptr); -} - - -static void *on_wat_malloc(size_t size) -{ - return ftdm_malloc(size); -} - -static void *on_wat_calloc(size_t nmemb, size_t size) -{ - return ftdm_calloc(nmemb, size); -} - -static void on_wat_free(void *ptr) -{ - ftdm_free(ptr); -} - -static void on_wat_log_span(uint8_t span_id, uint8_t level, char *fmt, ...) -{ - ftdm_span_t *span = NULL; - ftdm_gsm_span_data_t *gsm_data = NULL; - int ftdm_level; - char buff[4096]; - va_list argptr; - - if (!(span = get_span_by_id(span_id, &gsm_data))) { - return; - } - - va_start(argptr, fmt); - - switch(level) { - case WAT_LOG_CRIT: ftdm_level = FTDM_LOG_LEVEL_CRIT; break; - case WAT_LOG_ERROR: ftdm_level = FTDM_LOG_LEVEL_ERROR; break; - case WAT_LOG_WARNING: ftdm_level = FTDM_LOG_LEVEL_WARNING; break; - case WAT_LOG_INFO: ftdm_level = FTDM_LOG_LEVEL_INFO; break; - case WAT_LOG_NOTICE: ftdm_level = FTDM_LOG_LEVEL_NOTICE; break; - case WAT_LOG_DEBUG: ftdm_level = FTDM_LOG_LEVEL_DEBUG; break; - default: ftdm_level = FTDM_LOG_LEVEL_ERROR; break; - }; - - vsprintf(buff, fmt, argptr); - - ftdm_log_chan_ex(gsm_data->bchan, __FILE__, __FTDM_FUNC__, __LINE__, ftdm_level, "%s", buff); - - va_end(argptr); -} - - -/* END wat callbacks */ - -/* span monitor thread */ -static FIO_CHANNEL_OUTGOING_CALL_FUNCTION(gsm_outgoing_call) -{ - return FTDM_SUCCESS; -} - -static ftdm_status_t ftdm_gsm_start(ftdm_span_t *span) -{ - ftdm_gsm_span_data_t *gsm_data = span->signal_data; - ftdm_set_flag(gsm_data, FTDM_GSM_SPAN_STARTED); - return ftdm_thread_create_detached(ftdm_gsm_run, span); -} - -static ftdm_status_t ftdm_gsm_stop(ftdm_span_t *span) -{ - ftdm_gsm_span_data_t *gsm_data = span->signal_data; - ftdm_clear_flag(gsm_data, FTDM_GSM_SPAN_STARTED); - while (ftdm_test_flag(gsm_data, FTDM_GSM_RUNNING)) { - ftdm_log(FTDM_LOG_DEBUG, "Waiting for GSM span %s\n", span->name); - ftdm_sleep(100); - } - return FTDM_SUCCESS; -} - -static ftdm_status_t ftdm_gsm_destroy(ftdm_span_t *span) -{ - ftdm_gsm_span_data_t *gsm_data = span->signal_data; - ftdm_assert_return(gsm_data != NULL, FTDM_FAIL, "Span does not have GSM data!\n"); - if (gsm_data->sched) { - ftdm_sched_destroy(&gsm_data->sched); - } - ftdm_free(gsm_data); - return FTDM_SUCCESS; -} - -static FIO_CHANNEL_GET_SIG_STATUS_FUNCTION(ftdm_gsm_get_channel_sig_status) -{ - ftdm_gsm_span_data_t *gsm_data = ftdmchan->span->signal_data; - *status = gsm_data->sig_up ? FTDM_SIG_STATE_UP : FTDM_SIG_STATE_DOWN; - return FTDM_SUCCESS; -} - -static FIO_CHANNEL_SET_SIG_STATUS_FUNCTION(ftdm_gsm_set_channel_sig_status) -{ - ftdm_log(FTDM_LOG_ERROR, "You cannot set the signaling status for GSM channels (%s)\n", ftdmchan->span->name); - return FTDM_FAIL; -} - -static FIO_SPAN_GET_SIG_STATUS_FUNCTION(ftdm_gsm_get_span_sig_status) -{ - ftdm_gsm_span_data_t *gsm_data = span->signal_data; - *status = gsm_data->sig_up ? FTDM_SIG_STATE_UP : FTDM_SIG_STATE_DOWN; - return FTDM_SUCCESS; -} - -static FIO_SPAN_SET_SIG_STATUS_FUNCTION(ftdm_gsm_set_span_sig_status) -{ - ftdm_log(FTDM_LOG_ERROR, "You cannot set the signaling status for GSM spans (%s)\n", span->name); - return FTDM_FAIL; -} - -static ftdm_state_map_t gsm_state_map = { - { - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_ANY, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_RESET, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_RESET, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_RING, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_RING, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END}, - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_END}, - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END}, - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_END}, - }, - - /* Outbound states */ - - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_ANY, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_RESET, FTDM_CHANNEL_STATE_END} - }, - - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_RESET, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END} - }, - - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_DIALING, FTDM_CHANNEL_STATE_END} - }, - - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_DIALING, FTDM_CHANNEL_STATE_RINGING, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_RINGING, FTDM_CHANNEL_STATE_END} - }, - - - - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END} - }, - - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_END} - }, - - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END} - }, - - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_END} - }, - } -}; - -#define immediate_forward_enabled(gsm_data) !ftdm_strlen_zero_buf(gsm_data->immediate_forward_numbers[0].number) - -static void perform_enable_immediate_forward(void *data) -{ - ftdm_span_t *fwd_span = NULL; - ftdm_gsm_span_data_t *fwd_gsm_data = NULL; - char *fwd_span_name = NULL; - char *number = NULL; - char cmd[100]; - int i = 0; - ftdm_channel_t *ftdmchan = data; - ftdm_gsm_span_data_t *gsm_data = ftdmchan->span->signal_data; - - for (i = 0; i < ftdm_array_len(gsm_data->immediate_forward_numbers); i++) { - fwd_span_name = gsm_data->immediate_forward_numbers[i].span; - fwd_span = NULL; - if (!ftdm_strlen_zero_buf(fwd_span_name) && - ftdm_span_find_by_name(fwd_span_name, &fwd_span) != FTDM_SUCCESS) { - continue; - } - fwd_gsm_data = fwd_span ? fwd_span->signal_data : NULL; - if (fwd_gsm_data && fwd_gsm_data->call_id) { - /* span busy, do not forward here */ - continue; - } - number = gsm_data->immediate_forward_numbers[i].number; - break; - } - - if (!number) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_INFO, "No numbers available to enable immediate forwarding\n"); - return; - } - - ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Enabling immediate forwarding to %s\n", number); - snprintf(cmd, sizeof(cmd), "ATD%s%s", gsm_data->immediate_forward_prefix, number); - wat_cmd_req(ftdmchan->span->span_id, cmd, NULL, NULL); -} - -static __inline__ void enable_immediate_forward(ftdm_channel_t *ftdmchan) -{ - ftdm_gsm_span_data_t *gsm_data = ftdmchan->span->signal_data; - ftdm_sched_timer(gsm_data->sched, "immediate_forwarding_delay", 1000, - perform_enable_immediate_forward, - ftdmchan, - &gsm_data->immediate_forwarding_timer); -} - -static __inline__ void disable_all_forwarding(ftdm_channel_t *ftdmchan) -{ - char cmd[100]; - ftdm_gsm_span_data_t *gsm_data = ftdmchan->span->signal_data; - - if (ftdm_strlen_zero_buf(gsm_data->disable_forward_number)) { - return; - } - - snprintf(cmd, sizeof(cmd), "ATD%s", gsm_data->disable_forward_number); - ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Disabling GSM immediate forward dialing %s\n", gsm_data->disable_forward_number); - wat_cmd_req(ftdmchan->span->span_id, cmd, NULL, NULL); -} - -static ftdm_status_t ftdm_gsm_state_advance(ftdm_channel_t *ftdmchan) -{ - ftdm_gsm_span_data_t *gsm_data = ftdmchan->span->signal_data; - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Executing GSM state handler for %s\n", ftdm_channel_state2str(ftdmchan->state)); - - ftdm_channel_complete_state(ftdmchan); - - switch (ftdmchan->state) { - - /* starting an outgoing call */ - case FTDM_CHANNEL_STATE_DIALING: - { - uint32_t interval = 0; - wat_con_event_t con_event; - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Starting outgoing call with interval %d\n", interval); - - gsm_data->call_id = GSM_OUTBOUND_CALL_ID; - memset(&con_event, 0, sizeof(con_event)); - ftdm_set_string(con_event.called_num.digits, ftdmchan->caller_data.dnis.digits); - ftdm_log(FTDM_LOG_DEBUG, "Dialing number %s\n", con_event.called_num.digits); - wat_con_req(ftdmchan->span->span_id, gsm_data->call_id , &con_event); - - SEND_STATE_SIGNAL(FTDM_SIGEVENT_DIALING); - } - break; - - /* incoming call was offered */ - case FTDM_CHANNEL_STATE_RING: - { - /* notify the user about the new call */ - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Inbound call detected\n"); - SEND_STATE_SIGNAL(FTDM_SIGEVENT_START); - } - break; - - /* the call is making progress */ - case FTDM_CHANNEL_STATE_PROGRESS: - case FTDM_CHANNEL_STATE_PROGRESS_MEDIA: - { - SEND_STATE_SIGNAL(FTDM_SIGEVENT_PROGRESS_MEDIA); - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_UP); - } - break; - - /* the call was answered */ - case FTDM_CHANNEL_STATE_UP: - { - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { - SEND_STATE_SIGNAL(FTDM_SIGEVENT_UP); - } else { - wat_con_cfm(ftdmchan->span->span_id, gsm_data->call_id); - } - if (immediate_forward_enabled(gsm_data)) { - enable_immediate_forward(ftdmchan); - } - } - break; - - /* just got hangup */ - case FTDM_CHANNEL_STATE_HANGUP: - { - wat_rel_req(ftdmchan->span->span_id, gsm_data->call_id); - SEND_STATE_SIGNAL(FTDM_SIGEVENT_STOP); - } - break; - - /* finished call for good */ - case FTDM_CHANNEL_STATE_DOWN: - { - ftdm_channel_t *closed_chan; - gsm_data->call_id = 0; - closed_chan = ftdmchan; - ftdm_channel_close(&closed_chan); - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "State processing ended.\n"); - SEND_STATE_SIGNAL(FTDM_SIGEVENT_STOP); - if (immediate_forward_enabled(gsm_data)) { - disable_all_forwarding(ftdmchan); - } - } - break; - - /* Outbound call is ringing */ - case FTDM_CHANNEL_STATE_RINGING: - { - SEND_STATE_SIGNAL(FTDM_SIGEVENT_RINGING); - } - break; - - case FTDM_CHANNEL_STATE_RESET: - { - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - } - break; - - default: - { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Unhandled channel state: %s\n", ftdm_channel_state2str(ftdmchan->state)); - } - break; - } - - return FTDM_SUCCESS; -} - -static ftdm_status_t init_wat_lib(void) -{ - wat_interface_t wat_interface; - - if (wat_lib_initialized) { - return FTDM_SUCCESS; - } - - ftdm_log(FTDM_LOG_DEBUG, "Registering interface to WAT Library...\n"); - - memset(&wat_interface, 0, sizeof(wat_interface)); - wat_interface.wat_span_write = on_wat_span_write; - - wat_interface.wat_log = on_wat_log; - wat_interface.wat_log_span = on_wat_log_span; - wat_interface.wat_malloc = on_wat_malloc; - wat_interface.wat_calloc = on_wat_calloc; - wat_interface.wat_free = on_wat_free; - - wat_interface.wat_con_ind = on_wat_con_ind; - wat_interface.wat_con_sts = on_wat_con_sts; - wat_interface.wat_rel_ind = on_wat_rel_ind; - wat_interface.wat_rel_cfm = on_wat_rel_cfm; - wat_interface.wat_sms_ind = on_wat_sms_ind; - wat_interface.wat_sms_sts = on_wat_sms_sts; - wat_interface.wat_span_sts = on_wat_span_status; - wat_interface.wat_dtmf_ind = on_wat_dtmf_ind; - - if (wat_register(&wat_interface)) { - ftdm_log(FTDM_LOG_DEBUG, "Failed registering interface to WAT library ...\n"); - return FTDM_FAIL; - } - - ftdm_log(FTDM_LOG_DEBUG, "Registered interface to WAT library\n"); - - wat_lib_initialized = 1; - return FTDM_SUCCESS; -} - -WAT_AT_CMD_RESPONSE_FUNC(on_dtmf_sent) -{ - ftdm_channel_t *ftdmchan = obj; - ftdm_span_t *span = ftdmchan->span; - int i = 0; - - if (success == WAT_TRUE) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "DTMF successfully transmitted on span %s\n", span->name); - } else { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Command execution failed on span %s. Err: %s\n", span->name, error); - } - - for (i = 0; tokens[i]; i++) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "%s\n", tokens[i]); - } - return i; -} - -static ftdm_status_t ftdm_gsm_send_dtmf(ftdm_channel_t *ftdmchan, const char* dtmf) -{ - ftdm_gsm_span_data_t *gsm_data = ftdmchan->span->signal_data; - wat_send_dtmf(ftdmchan->span->span_id, gsm_data->call_id, dtmf, on_dtmf_sent, ftdmchan); - return FTDM_SUCCESS; -} - -static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_gsm_configure_span_signaling) -{ - wat_span_config_t span_config; - ftdm_gsm_span_data_t *gsm_data = NULL; - ftdm_iterator_t *chaniter = NULL; - ftdm_iterator_t *citer = NULL; - ftdm_channel_t *ftdmchan = NULL; - ftdm_channel_t *dchan = NULL; - ftdm_channel_t *bchan = NULL; - ftdm_bool_t hwdtmf_detect = FTDM_FALSE; - ftdm_bool_t hwdtmf_generate = FTDM_FALSE; - - unsigned paramindex = 0; - const char *var = NULL; - const char *val = NULL; - char schedname[255]; - int cmdindex = 0; - - int codec = FTDM_CODEC_SLIN; - int interval = 20; - - /* libwat is smart enough to set good default values for the timers if they are set to 0 */ - memset(&span_config, 0, sizeof(span_config)); - - /* set some span defaults */ - span_config.moduletype = WAT_MODULE_TELIT; - span_config.hardware_dtmf = WAT_FALSE; - - if (FTDM_SUCCESS != init_wat_lib()) { - return FTDM_FAIL; - } - - if (!sig_cb) { - ftdm_log(FTDM_LOG_ERROR, "No signaling callback provided\n"); - return FTDM_FAIL; - } - - if (span->signal_type) { - ftdm_log(FTDM_LOG_ERROR, "Span %s is already configured for another signaling\n", span->name); - return FTDM_FAIL; - } - - /* verify the span has one d-channel */ - chaniter = ftdm_span_get_chan_iterator(span, NULL); - - if (!chaniter) { - ftdm_log(FTDM_LOG_CRIT, "Failed to allocate channel iterator for span %s!\n", span->name); - return FTDM_FAIL; - } - - citer = ftdm_span_get_chan_iterator(span, chaniter); - for ( ; citer; citer = ftdm_iterator_next(citer)) { - ftdmchan = ftdm_iterator_current(citer); - - if ((NULL == dchan) && FTDM_IS_DCHAN(ftdmchan)) { - dchan = ftdmchan; - } - if ((NULL == bchan) && FTDM_IS_VOICE_CHANNEL(ftdmchan)) { - bchan = ftdmchan; - } - - } - ftdm_iterator_free(chaniter); - - if (!dchan) { - ftdm_log(FTDM_LOG_CRIT, "Could not find a d-channel for GSM span %s!\n", span->name); - return FTDM_FAIL; - } - if (!bchan) { - ftdm_log(FTDM_LOG_CRIT, "Could not find a b-channel for GSM span %s!\n", span->name); - return FTDM_FAIL; - } - - gsm_data = ftdm_calloc(1, sizeof(*gsm_data)); - if (!gsm_data) { - return FTDM_FAIL; - } - gsm_data->dchan = dchan; - gsm_data->bchan = bchan; - - cmdindex = 0; - for (paramindex = 0; ftdm_parameters[paramindex].var; paramindex++) { - var = ftdm_parameters[paramindex].var; - val = ftdm_parameters[paramindex].val; - if (ftdm_strlen_zero_buf(val)) { - ftdm_log(FTDM_LOG_WARNING, "Ignoring empty GSM parameter %s for span %s\n", var, span->name); - continue; - } - ftdm_log(FTDM_LOG_DEBUG, "Reading GSM parameter %s=%s for span %s\n", var, val, span->name); - if (!strcasecmp(var, "moduletype")) { - span_config.moduletype = wat_str2wat_moduletype(val); - if (span_config.moduletype == WAT_MODULE_INVALID) { - ftdm_log(FTDM_LOG_ERROR, "Unknown GSM module type %s for span %s\n", val, span->name); - continue; - } - ftdm_log(FTDM_LOG_DEBUG, "Configuring GSM span %s with moduletype %s\n", span->name, val); - } else if (!strcasecmp(var, "debug")) { - span_config.debug_mask = wat_str2debug(val); - ftdm_log(FTDM_LOG_DEBUG, "Configuring GSM span %s with debug mask %s == 0x%X\n", span->name, val, span_config.debug_mask); - } else if (!strcasecmp(var, "hwdtmf")) { - hwdtmf_detect = FTDM_FALSE; - hwdtmf_generate = FTDM_FALSE; - if (!strcasecmp(val, "generate")) { - hwdtmf_generate = FTDM_TRUE; - } else if (!strcasecmp(val, "detect")) { - hwdtmf_detect = FTDM_TRUE; - } else if (!strcasecmp(val, "both") || ftdm_true(val)) { - hwdtmf_detect = FTDM_TRUE; - hwdtmf_generate = FTDM_TRUE; - } else { - span_config.hardware_dtmf = WAT_FALSE; - } - ftdm_log(FTDM_LOG_DEBUG, "Configuring GSM span %s with hardware dtmf %s\n", span->name, val); - } else if (!strcasecmp(var, "conditional-forwarding-number")) { - ftdm_set_string(gsm_data->conditional_forward_number, val); - gsm_data->init_conditional_forwarding = FTDM_TRUE; - } else if (!strcasecmp(var, "conditional-forwarding-prefix")) { - ftdm_set_string(gsm_data->conditional_forward_prefix, val); - } else if (!strcasecmp(var, "immediate-forwarding-numbers")) { - char *state = NULL; - char *span_end = NULL; - char *number = NULL; - char *span_name = NULL; - int f = 0; - char *valdup = ftdm_strdup(val); - char *s = valdup; - - if (!ftdm_strlen_zero_buf(gsm_data->immediate_forward_numbers[0].number)) { - ftdm_log(FTDM_LOG_ERROR, "immediate-forwarding-numbers already parsed! failed to parse: %s\n", val); - goto ifn_parse_done; - } - - /* The string must be in the form [:], optionally multiple elements separated by comma */ - while ((number = strtok_r(s, ",", &state))) { - if (f == ftdm_array_len(gsm_data->immediate_forward_numbers)) { - ftdm_log(FTDM_LOG_ERROR, "Max number (%d) of immediate forwarding numbers reached!\n", f); - break; - } - - s = NULL; - span_end = strchr(number, ':'); - if (span_end) { - *span_end = '\0'; - span_name = number; - number = (span_end + 1); - ftdm_set_string(gsm_data->immediate_forward_numbers[f].span, span_name); - ftdm_log(FTDM_LOG_DEBUG, "Parsed immediate forwarding to span %s number %s\n", span_name, number); - } else { - ftdm_log(FTDM_LOG_DEBUG, "Parsed immediate forwarding to number %s\n", number); - } - ftdm_set_string(gsm_data->immediate_forward_numbers[f].number, number); - f++; - } -ifn_parse_done: - ftdm_safe_free(valdup); - } else if (!strcasecmp(var, "immediate-forwarding-prefix")) { - ftdm_set_string(gsm_data->immediate_forward_prefix, val); - } else if (!strcasecmp(var, "disable-forwarding-number")) { - ftdm_set_string(gsm_data->disable_forward_number, val); - } else if (!strcasecmp(var, "startup-command")) { - if (cmdindex < (ftdm_array_len(gsm_data->startup_commands) - 1)) { - ftdm_set_string(gsm_data->startup_commands[cmdindex], val); - ftdm_log(FTDM_LOG_DEBUG, "Adding startup command '%s' to GSM span %s\n", gsm_data->startup_commands[cmdindex], span->name); - cmdindex++; - } else { - ftdm_log(FTDM_LOG_ERROR, "Ignoring startup command '%s' ... max commands limit reached", val); - } - } else { - ftdm_log(FTDM_LOG_ERROR, "Ignoring unknown GSM parameter '%s'", var); - } - } - - /* Bind function pointers for control operations */ - span->start = ftdm_gsm_start; - span->stop = ftdm_gsm_stop; - span->destroy = ftdm_gsm_destroy; - span->sig_read = NULL; - span->sig_write = NULL; - if (hwdtmf_detect || hwdtmf_generate) { - span_config.hardware_dtmf = WAT_TRUE; - if (hwdtmf_generate) { - span->sig_send_dtmf = ftdm_gsm_send_dtmf; - } - if (hwdtmf_detect) { - ftdm_set_flag(ftdmchan, FTDM_CHANNEL_SIG_DTMF_DETECTION); - } - } - span->signal_cb = sig_cb; - span->signal_type = FTDM_SIGTYPE_GSM; - span->signal_data = gsm_data; - span->outgoing_call = gsm_outgoing_call; - span->get_span_sig_status = ftdm_gsm_get_span_sig_status; - span->set_span_sig_status = ftdm_gsm_set_span_sig_status; - span->get_channel_sig_status = ftdm_gsm_get_channel_sig_status; - span->set_channel_sig_status = ftdm_gsm_set_channel_sig_status; - - span->state_map = &gsm_state_map; - span->state_processor = ftdm_gsm_state_advance; - - /* use signals queue */ - ftdm_set_flag(span, FTDM_SPAN_USE_SIGNALS_QUEUE); - ftdm_set_flag(span, FTDM_SPAN_USE_CHAN_QUEUE); - - /* we can skip states (going straight from RING to UP) */ - ftdm_set_flag(span, FTDM_SPAN_USE_SKIP_STATES); - - gsm_data->span = span; - span_map[span->span_id] = span; - - /* Setup the scheduler */ - snprintf(schedname, sizeof(schedname), "ftmod_gsm_%s", span->name); - if (ftdm_sched_create(&gsm_data->sched, schedname) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "Failed to setup scheduler for span %s!\n", span->name); - ftdm_gsm_destroy(span); - return FTDM_FAIL; - } - - /* Start the signaling stack */ - if (wat_span_config(span->span_id, &span_config)) { - ftdm_log(FTDM_LOG_ERROR, "Failed to configure span %s for GSM signaling!!\n", span->name); - ftdm_gsm_destroy(span); - return FTDM_FAIL; - } - - ftdm_channel_command(gsm_data->bchan, FTDM_COMMAND_SET_NATIVE_CODEC, &codec); - ftdm_channel_command(gsm_data->bchan, FTDM_COMMAND_SET_CODEC, &codec); - ftdm_channel_command(gsm_data->bchan, FTDM_COMMAND_SET_INTERVAL, &interval); - - return FTDM_SUCCESS; - -} - -#define GSM_POLL_INTERVAL_MS 20 -static void *ftdm_gsm_run(ftdm_thread_t *me, void *obj) -{ - ftdm_channel_t *ftdmchan = NULL; - ftdm_span_t *span = (ftdm_span_t *) obj; - ftdm_gsm_span_data_t *gsm_data = NULL; - ftdm_interrupt_t *data_sources[2] = {NULL, NULL}; - ftdm_wait_flag_t flags = FTDM_READ | FTDM_EVENTS; - ftdm_status_t status = FTDM_SUCCESS; - ftdm_alarm_flag_t alarms; - char buffer[1024] = { 0 }; - ftdm_size_t bufsize = 0; - int waitms = 0; - - gsm_data = span->signal_data; - ftdm_assert_return(gsm_data != NULL, NULL, "No gsm data attached to span\n"); - - /* as long as this thread is running, this flag is set */ - ftdm_set_flag(gsm_data, FTDM_GSM_RUNNING); - - ftdm_log(FTDM_LOG_DEBUG, "GSM monitor thread for span %s started\n", span->name); - if (!gsm_data->dchan || ftdm_channel_open_chan(gsm_data->dchan) != FTDM_SUCCESS) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Failed to open GSM d-channel of span %s!\n", span->name); - gsm_data->dchan = NULL; - goto done; - } - - /* Do not start if the link layer is not ready yet */ - ftdm_channel_get_alarms(gsm_data->dchan, &alarms); - if (alarms != FTDM_ALARM_NONE) { - ftdm_log(FTDM_LOG_WARNING, "Delaying initialization of span %s until alarms are cleared\n", span->name); - while (ftdm_running() && ftdm_test_flag(gsm_data, FTDM_GSM_SPAN_STARTED) && alarms != FTDM_ALARM_NONE) { - ftdm_channel_get_alarms(gsm_data->dchan, &alarms); - ftdm_sleep(100); - } - if (!ftdm_running() || !ftdm_test_flag(gsm_data, FTDM_GSM_SPAN_STARTED)) { - goto done; - } - } - - if (wat_span_start(span->span_id)) { - ftdm_log(FTDM_LOG_ERROR, "Failed to start span %s!\n", span->name); - goto done; - } - - while (ftdm_running() && ftdm_test_flag(gsm_data, FTDM_GSM_SPAN_STARTED)) { - wat_span_run(span->span_id); - ftdm_sched_run(gsm_data->sched); - - waitms = wat_span_schedule_next(span->span_id); - if (waitms > GSM_POLL_INTERVAL_MS) { - waitms = GSM_POLL_INTERVAL_MS; - } - - flags = FTDM_READ | FTDM_EVENTS; - status = ftdm_channel_wait(gsm_data->dchan, &flags, waitms); - - /* check if this channel has a state change pending and process it if needed */ - ftdm_channel_lock(gsm_data->bchan); - ftdm_channel_advance_states(gsm_data->bchan); - - if (FTDM_SUCCESS == status && (flags & FTDM_READ)) { - bufsize = sizeof(buffer); - status = ftdm_channel_read(gsm_data->dchan, buffer, &bufsize); - if (status == FTDM_SUCCESS && bufsize > 0) { - wat_span_process_read(span->span_id, buffer, bufsize); - buffer[0] = 0; - } - } - - ftdm_channel_advance_states(gsm_data->bchan); - ftdm_channel_unlock(gsm_data->bchan); - - ftdm_span_trigger_signals(span); - - } - - if (wat_span_stop(span->span_id)) { - ftdm_log(FTDM_LOG_ERROR, "Failed to stop GSM span %s!\n", span->name); - } - - if (wat_span_unconfig(span->span_id)) { - ftdm_log(FTDM_LOG_ERROR, "Failed to unconfigure GSM span %s!\n", span->name); - } - -done: - if (data_sources[0]) { - ftdm_interrupt_destroy(&data_sources[0]); - } - - ftdm_log(FTDM_LOG_DEBUG, "GSM thread ending\n"); - ftdm_clear_flag(gsm_data, FTDM_GSM_RUNNING); - - return NULL; -} - - - -static FIO_IO_LOAD_FUNCTION(ftdm_gsm_io_init) -{ - assert(fio != NULL); - memset(&g_ftdm_gsm_interface, 0, sizeof(g_ftdm_gsm_interface)); - - g_ftdm_gsm_interface.name = "gsm"; - g_ftdm_gsm_interface.api = ftdm_gsm_api; - - *fio = &g_ftdm_gsm_interface; - - return (FTDM_SUCCESS); -} - -EX_DECLARE_DATA ftdm_module_t ftdm_module = { - /* .name */ "gsm", - /* .io_load */ ftdm_gsm_io_init, - /* .io_unload */ NULL, - /* .sig_load */ NULL, - /* .sig_configure */ NULL, - /* .sig_unload */ NULL, - /* .configure_span_signaling */ ftdm_gsm_configure_span_signaling -}; - -/********************************************************************************/ -/* */ -/* COMMAND HANDLERS */ -/* */ -/********************************************************************************/ - - -// Version Command Handler -COMMAND_HANDLER(version) -{ - uint8_t current = 0, revision = 0, age = 0; - wat_version(¤t, &revision, &age); - stream->write_function(stream, "libwat version: %d.%d.%d\n", current, revision, age); - stream->write_function(stream, "+OK.\n"); - return FTDM_SUCCESS; -} - - -// Status Command Handler -COMMAND_HANDLER(status) -{ - int span_id = 0; - ftdm_span_t *span = NULL; - const wat_chip_info_t *chip_info = NULL; - const wat_sim_info_t *sim_info = NULL; - const wat_net_info_t *net_info = NULL; - const wat_sig_info_t *sig_info = NULL; - wat_pin_stat_t pin_stat = 0; - - span_id = atoi(argv[0]); - if (ftdm_span_find_by_name(argv[0], &span) != FTDM_SUCCESS && ftdm_span_find(span_id, &span) != FTDM_SUCCESS) { - stream->write_function(stream, "-ERR Failed to find GSM span '%s'\n", argv[1]); - return FTDM_FAIL; - } - - if (!span || !span->signal_data || (span->start != ftdm_gsm_start)) { - stream->write_function(stream, "-ERR '%s' is not a valid GSM span\n", argv[1]); - return FTDM_FAIL; - } - - chip_info = wat_span_get_chip_info(span->span_id); - sim_info = wat_span_get_sim_info(span->span_id); - net_info = wat_span_get_net_info(span->span_id); - sig_info = wat_span_get_sig_info(span->span_id); - - /* This is absolutely retarded and should be fixed in libwat - * why the hell would you return a pointer to an internal state enum instead of a copy? - * probably the same applies to the rest of the info (sim_info, chip_info, net_info, etc), - * but at least there you could have the lame excuse that you don't need to copy the whole struct */ - pin_stat = *wat_span_get_pin_info(span->span_id); - - stream->write_function(stream, "Span %d (%s):\n", span->span_id, span->name); - - stream->write_function(stream, "CHIP type - %s (%s), revision %s, serial %s \n", - chip_info->manufacturer, - chip_info->model, - chip_info->revision, - chip_info->serial); - - stream->write_function(stream, "SIM - Subscriber type %s, imsi %s\n", sim_info->subscriber_type, sim_info->imsi); - - stream->write_function(stream, "Subscriber - Number %s, Plan %s, validity %s\n", - sim_info->subscriber.digits, - wat_number_type2str(sim_info->subscriber.type), - wat_number_plan2str(sim_info->subscriber.plan), - wat_number_validity2str(sim_info->subscriber.validity)); - - stream->write_function(stream, "Network - status %s, Area Code %d, Cell ID %d, Operator %s\n", - wat_net_stat2str(net_info->stat), net_info->lac, net_info->ci, net_info->operator_name); - - - stream->write_function(stream, "Sig Info: rssi(%d) ber(%d)\n", sig_info->rssi, sig_info->ber); - - stream->write_function(stream, "PIN Status: %s\n", wat_pin_stat2str(pin_stat)); - - stream->write_function(stream, "\n"); - - stream->write_function(stream, "+OK.\n"); - - return FTDM_SUCCESS; -} - -// SMS Command Handler -COMMAND_HANDLER(sms) -{ - int span_id = 0, i; - uint32_t sms_id = 0; - ftdm_span_t *span = NULL; - wat_sms_event_t sms; - ftdm_gsm_span_data_t *gsm_data = NULL; - - span_id = atoi(argv[0]); - if (ftdm_span_find_by_name(argv[0], &span) != FTDM_SUCCESS && ftdm_span_find(span_id, &span) != FTDM_SUCCESS) { - stream->write_function(stream, "-ERR Failed to find GSM span '%s'\n", argv[1]); - return FTDM_FAIL; - } - - if (!span || !span->signal_data || (span->start != ftdm_gsm_start)) { - stream->write_function(stream, "-ERR '%s' is not a valid GSM span\n", argv[1]); - return FTDM_FAIL; - } - gsm_data = span->signal_data; - - memset(&sms, 0, sizeof(sms)); - strcpy(sms.to.digits, argv[1]); - sms.type = WAT_SMS_TXT; - sms.content.data[0] = '\0'; - for(i=2;ibchan); - - sms_id = gsm_data->sms_id >= WAT_MAX_SMSS_PER_SPAN ? 0 : gsm_data->sms_id; - gsm_data->sms_id++; - - ftdm_channel_unlock(gsm_data->bchan); - - if (WAT_SUCCESS != wat_sms_req(span->span_id, sms_id, &sms)) { - stream->write_function(stream, "Failed to Send SMS \n"); - } else { - stream->write_function(stream, "SMS Sent.\n"); - } - return FTDM_SUCCESS; -} - -WAT_AT_CMD_RESPONSE_FUNC(gsm_exec_cb) -{ - ftdm_gsm_exec_helper_t *helper = (ftdm_gsm_exec_helper_t *)obj; - ftdm_stream_handle_t *stream = helper->stream; - ftdm_span_t *span = helper->span; - int i = 0; - - if (success == WAT_TRUE) { - stream->write_function(stream, "Command executed successfully on span %s\n", span->name); - } else { - stream->write_function(stream, "Command execution failed on span %s. Err: %s\n", span->name, error); - } - - for (i = 0; tokens[i]; i++) { - stream->write_function(stream, "%s\n", tokens[i]); - } - - helper->cmd_pending = 0; - return i; -} - -// AT Command Handler -COMMAND_HANDLER(exec) -{ - int span_id = 0; - int sanity = 100; - ftdm_span_t *span = NULL; - ftdm_gsm_exec_helper_t helper; - - span_id = atoi(argv[0]); - if (ftdm_span_find_by_name(argv[0], &span) != FTDM_SUCCESS && ftdm_span_find(span_id, &span) != FTDM_SUCCESS) { - stream->write_function(stream, "-ERR Failed to find GSM span '%s'\n", argv[0]); - return FTDM_FAIL; - } - - if (!span || !span->signal_data || (span->start != ftdm_gsm_start)) { - stream->write_function(stream, "-ERR '%s' is not a valid GSM span\n", argv[0]); - return FTDM_FAIL; - } - - helper.stream = stream; - helper.span = span; - helper.cmd_pending = 1; - if (WAT_SUCCESS != wat_cmd_req(span->span_id, argv[1], gsm_exec_cb, &helper)) { - stream->write_function(stream, "Failed to send AT command on span %s\n", span->name); - } else { - stream->write_function(stream, "AT command sent on span %s\n", span->name); - } - - while (helper.cmd_pending && (--sanity > 0)) { - ftdm_sleep(100); - } - - if (sanity < 0) { - stream->write_function(stream, "Timed out waiting for respons for AT command on span %s\n", span->name); - } - return FTDM_SUCCESS; -} - -// AT Command Handler -COMMAND_HANDLER(call) -{ - int span_id = 0; - ftdm_span_t *span = NULL; - - span_id = atoi(argv[0]); - if (ftdm_span_find_by_name(argv[0], &span) != FTDM_SUCCESS && ftdm_span_find(span_id, &span) != FTDM_SUCCESS) { - stream->write_function(stream, "-ERR Failed to find GSM span '%s'\n", argv[0]); - return FTDM_FAIL; - } - - if (!span || !span->signal_data || (span->start != ftdm_gsm_start)) { - stream->write_function(stream, "-ERR '%s' is not a valid GSM span\n", argv[0]); - return FTDM_FAIL; - } - - ftdm_gsm_make_raw_call(span->signal_data, argv[1]); - stream->write_function(stream, "+OK\n"); - return FTDM_SUCCESS; -} - -// command map -static struct { - const char *cmd; // command - int argc; // minimum args - command_handler_t handler; // handling function -} GSM_COMMANDS[] = { - COMMAND(version, 0), - COMMAND(status, 1), - COMMAND(sms, 3), - COMMAND(exec, 2), - COMMAND(call, 2), -}; - -// main command API entry point -static FIO_API_FUNCTION(ftdm_gsm_api) -{ - - char *mycmd = NULL, *argv[10] = { 0 }; - int argc = 0; - int i; - ftdm_status_t status = FTDM_FAIL; - ftdm_status_t syntax = FTDM_FAIL; - - - if (data) { - mycmd = ftdm_strdup(data); - argc = ftdm_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); - } - - if (argc > 0) { - for (i = 0; i< ftdm_array_len(GSM_COMMANDS); i++) { - if (strcasecmp(argv[0], GSM_COMMANDS[i].cmd) == 0) { - if (argc -1 >= GSM_COMMANDS[i].argc) { - syntax = FTDM_SUCCESS; - status = GSM_COMMANDS[i].handler(stream, &argv[1], argc-1); - } - break; - } - } - } - - if (FTDM_SUCCESS != syntax) { - stream->write_function(stream, "%s", FT_SYNTAX); - } else if (FTDM_SUCCESS != status) { - stream->write_function(stream, "%s Command Failed\r\n", GSM_COMMANDS[i].cmd); - } - - ftdm_safe_free(mycmd); - - return FTDM_SUCCESS; -} - - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/ftmod/ftmod_isdn/ftmod_isdn.2008.vcproj b/libs/freetdm/src/ftmod/ftmod_isdn/ftmod_isdn.2008.vcproj deleted file mode 100644 index 0177d4246a..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_isdn/ftmod_isdn.2008.vcproj +++ /dev/null @@ -1,465 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/freetdm/src/ftmod/ftmod_isdn/ftmod_isdn.2010.vcxproj.filters b/libs/freetdm/src/ftmod/ftmod_isdn/ftmod_isdn.2010.vcxproj.filters deleted file mode 100644 index 30824888fc..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_isdn/ftmod_isdn.2010.vcxproj.filters +++ /dev/null @@ -1,110 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - \ No newline at end of file diff --git a/libs/freetdm/src/ftmod/ftmod_isdn/ftmod_isdn.c b/libs/freetdm/src/ftmod/ftmod_isdn/ftmod_isdn.c deleted file mode 100644 index fba15eaca2..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_isdn/ftmod_isdn.c +++ /dev/null @@ -1,2927 +0,0 @@ -/* - * Copyright (c) 2007-2014, Anthony Minessale II - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#include -#include -#include - -#ifdef WIN32 -#include -#else -#include -#endif - -#include "ftmod_isdn.h" - -#define LINE "--------------------------------------------------------------------------------" - -/* helper macros */ -#define FTDM_SPAN_IS_NT(x) (((ftdm_isdn_data_t *)(x)->signal_data)->mode == Q921_NT) - -#define DEFAULT_NATIONAL_PREFIX "0" -#define DEFAULT_INTERNATIONAL_PREFIX "00" - -/***************************************************************************************** - * PCAP - * Based on Helmut Kuper's () implementation, - * but using a different approach (needs a recent libpcap + wireshark) - *****************************************************************************************/ -#ifdef HAVE_PCAP -#include /* htons() */ -#include - -#define PCAP_SNAPLEN 1500 - -struct pcap_context { - pcap_dumper_t *dump; /*!< pcap file handle */ - pcap_t *handle; /*!< pcap lib context */ - char *filename; /*!< capture file name */ -}; - -static inline ftdm_status_t isdn_pcap_is_open(struct ftdm_isdn_data *isdn) -{ - return (isdn->pcap) ? 1 : 0; -} - -static inline ftdm_status_t isdn_pcap_capture_both(struct ftdm_isdn_data *isdn) -{ - return ((isdn->flags & (FTDM_ISDN_CAPTURE | FTDM_ISDN_CAPTURE_L3ONLY)) == FTDM_ISDN_CAPTURE) ? 1 : 0; -} - -static inline ftdm_status_t isdn_pcap_capture_l3only(struct ftdm_isdn_data *isdn) -{ - return ((isdn->flags & FTDM_ISDN_CAPTURE) && (isdn->flags & FTDM_ISDN_CAPTURE_L3ONLY)) ? 1 : 0; -} - -static ftdm_status_t isdn_pcap_open(struct ftdm_isdn_data *isdn, char *filename) -{ - struct pcap_context *pcap = NULL; - - if (!isdn || ftdm_strlen_zero(filename)) - return FTDM_FAIL; - - pcap = malloc(sizeof(struct pcap_context)); - if (!pcap) { - ftdm_log(FTDM_LOG_ERROR, "Failed to allocate isdn pcap context\n"); - return FTDM_FAIL; - } - - memset(pcap, 0, sizeof(struct pcap_context)); - - pcap->filename = strdup(filename); - - pcap->handle = pcap_open_dead(DLT_LINUX_LAPD, PCAP_SNAPLEN); - if (!pcap->handle) { - ftdm_log(FTDM_LOG_ERROR, "Failed to open pcap handle\n"); - goto error; - } - - pcap->dump = pcap_dump_open(pcap->handle, pcap->filename); - if (!pcap->dump) { - ftdm_log(FTDM_LOG_ERROR, "Failed to open capture file: '%s'\n", pcap_geterr(pcap->handle)); - goto error; - } - - ftdm_log(FTDM_LOG_INFO, "Capture file '%s' opened\n", pcap->filename); - - isdn->pcap = pcap; - - return FTDM_SUCCESS; -error: - if (pcap->handle) - pcap_close(pcap->handle); - if (pcap->filename) - free(pcap->filename); - - free(pcap); - - return FTDM_FAIL; -} - -static ftdm_status_t isdn_pcap_close(struct ftdm_isdn_data *isdn) -{ - struct pcap_context *pcap = NULL; - long size; - - if (!isdn || !isdn->pcap) - return FTDM_FAIL; - - pcap = isdn->pcap; - - isdn->flags &= ~(FTDM_ISDN_CAPTURE | FTDM_ISDN_CAPTURE_L3ONLY); - isdn->pcap = NULL; - - pcap_dump_flush(pcap->dump); - - size = pcap_dump_ftell(pcap->dump); - ftdm_log(FTDM_LOG_INFO, "File '%s' captured %ld bytes of data\n", pcap->filename, size); - - pcap_dump_close(pcap->dump); - pcap_close(pcap->handle); - - free(pcap->filename); - free(pcap); - - return FTDM_SUCCESS; -} - -static inline void isdn_pcap_start(struct ftdm_isdn_data *isdn) -{ - if (!isdn->pcap) - return; - - isdn->flags |= FTDM_ISDN_CAPTURE; -} - -static inline void isdn_pcap_stop(struct ftdm_isdn_data *isdn) -{ - isdn->flags &= ~FTDM_ISDN_CAPTURE; -} - -#ifndef ETH_P_LAPD -#define ETH_P_LAPD 0x0030 -#endif - -struct isdn_sll_hdr { - uint16_t slltype; - uint16_t sllhatype; - uint16_t slladdrlen; - uint8_t slladdr[8]; - uint16_t sllproto; -}; - -/* Fake Q.921 I-frame */ -//static const char q921_fake_frame[] = { 0x00, 0x00, 0x00, 0x00 }; - -enum { - ISDN_PCAP_INCOMING = 0, - ISDN_PCAP_INCOMING_BCAST = 1, - ISDN_PCAP_OUTGOING = 4, -}; - -static ftdm_status_t isdn_pcap_write(struct ftdm_isdn_data *isdn, unsigned char *buf, ftdm_ssize_t len, int direction) -{ - unsigned char frame[PCAP_SNAPLEN]; - struct pcap_context *pcap; - struct isdn_sll_hdr *sll_hdr = (struct isdn_sll_hdr *)frame; - struct pcap_pkthdr hdr; - int offset = sizeof(struct isdn_sll_hdr); - int nbytes; - - if (!isdn || !isdn->pcap || !buf || !len) - return FTDM_FAIL; - - pcap = isdn->pcap; - - /* Update SLL header */ - sll_hdr->slltype = htons(direction); - sll_hdr->sllhatype = 0; - sll_hdr->slladdrlen = 1; - sll_hdr->slladdr[0] = (isdn->mode == Q921_NT) ? 1 : 0; /* TODO: NT/TE */ - sll_hdr->sllproto = htons(ETH_P_LAPD); - -#if 0 - /* Q.931-only mode: copy fake Q.921 header */ - if (isdn->flags & FTDM_ISDN_CAPTURE_L3ONLY) { - /* copy fake q921 header */ - memcpy(frame + offset, q921_fake_frame, sizeof(q921_fake_frame)); - offset += sizeof(q921_fake_frame); - } -#endif - - /* Copy data */ - nbytes = (len > (PCAP_SNAPLEN - offset)) ? (PCAP_SNAPLEN - offset) : len; - memcpy(frame + offset, buf, nbytes); - - /* Update timestamp */ - memset(&hdr, 0, sizeof(struct pcap_pkthdr)); - gettimeofday(&hdr.ts, NULL); - hdr.caplen = offset + nbytes; - hdr.len = hdr.caplen; - - /* Write packet */ - pcap_dump((unsigned char *)pcap->dump, &hdr, frame); - - return FTDM_SUCCESS; -} -#endif /* HAVE_PCAP */ - - -static L2ULONG ftdm_time_now(void) -{ - return (L2ULONG)ftdm_current_time_in_ms(); -} - -/** - * \brief Returns the signalling status on a channel - * \param ftdmchan Channel to get status on - * \param status Pointer to set signalling status - * \return Success or failure - */ -static FIO_CHANNEL_GET_SIG_STATUS_FUNCTION(isdn_get_channel_sig_status) -{ - *status = FTDM_SIG_STATE_DOWN; - - ftdm_isdn_data_t *isdn_data = ftdmchan->span->signal_data; - if (ftdm_test_flag(isdn_data, FTDM_ISDN_RUNNING)) { - *status = FTDM_SIG_STATE_UP; - } - return FTDM_SUCCESS; -} - -/** - * \brief Returns the signalling status on a span - * \param span Span to get status on - * \param status Pointer to set signalling status - * \return Success or failure - */ -static FIO_SPAN_GET_SIG_STATUS_FUNCTION(isdn_get_span_sig_status) -{ - *status = FTDM_SIG_STATE_DOWN; - - ftdm_isdn_data_t *isdn_data = span->signal_data; - if (ftdm_test_flag(isdn_data, FTDM_ISDN_RUNNING)) { - *status = FTDM_SIG_STATE_UP; - } - return FTDM_SUCCESS; -} - -/** - * \brief Create outgoing channel - * \param ftdmchan Channel to create outgoing call on - * \return Success or failure - */ -static FIO_CHANNEL_OUTGOING_CALL_FUNCTION(isdn_outgoing_call) -{ - return FTDM_SUCCESS; -} - -/** - * \brief Create outgoing channel, let module select the channel to use - * \param span Span to create outgoing call on - * \param caller_data - * \return Success or failure - */ -#ifdef __TODO__ -static FIO_CHANNEL_REQUEST_FUNCTION(isdn_channel_request) -{ -#if 1 /* FIXME caller_data.raw_data does not exist anymore, see docs/variables.txt for more info */ - Q931mes_Generic empty_gen; - Q931mes_Generic *gen = &empty_gen; - - memset(&empty_gen, 0, sizeof(empty_gen)) ; -#else - Q931mes_Generic *gen = (Q931mes_Generic *) caller_data->raw_data; -#endif - Q931ie_BearerCap BearerCap; - Q931ie_ChanID ChanID = { 0 }; - Q931ie_CallingNum CallingNum; - Q931ie_CallingNum *ptrCallingNum; - Q931ie_CalledNum CalledNum; - Q931ie_CalledNum *ptrCalledNum; - Q931ie_Display Display, *ptrDisplay; - Q931ie_HLComp HLComp; /* High-Layer Compatibility IE */ - Q931ie_ProgInd Progress; /* Progress Indicator IE */ - ftdm_status_t status = FTDM_FAIL; - ftdm_isdn_data_t *isdn_data = span->signal_data; - int sanity = 60000; - int codec = 0; - - /* - * get codec type - */ - ftdm_channel_command(span->channels[chan_id], FTDM_COMMAND_GET_NATIVE_CODEC, &codec); - - /* - * Q.931 Setup Message - */ - Q931InitMesGeneric(gen); - gen->MesType = Q931mes_SETUP; - gen->CRVFlag = 0; /* outgoing call */ - - /* - * Bearer Capability IE - */ - Q931InitIEBearerCap(&BearerCap); - BearerCap.CodStand = Q931_CODING_ITU; /* ITU-T = 0, ISO/IEC = 1, National = 2, Network = 3 */ - BearerCap.ITC = Q931_ITC_SPEECH; /* Speech */ - BearerCap.TransMode = 0; /* Circuit = 0, Packet = 1 */ - BearerCap.ITR = Q931_ITR_64K; /* 64k */ - BearerCap.Layer1Ident = 1; - BearerCap.UIL1Prot = (codec == FTDM_CODEC_ALAW) ? Q931_UIL1P_G711A : Q931_UIL1P_G711U; /* U-law = 2, A-law = 3 */ - gen->BearerCap = Q931AppendIE(gen, (L3UCHAR *) &BearerCap); - - /* - * Channel ID IE - */ - Q931InitIEChanID(&ChanID); - ChanID.IntType = FTDM_SPAN_IS_BRI(span) ? 0 : 1; /* PRI = 1, BRI = 0 */ - - if (!FTDM_SPAN_IS_NT(span)) { - ChanID.PrefExcl = (isdn_data->opts & FTDM_ISDN_OPT_SUGGEST_CHANNEL) ? 0 : 1; /* 0 = preferred, 1 exclusive */ - } else { - ChanID.PrefExcl = 1; /* always exclusive in NT-mode */ - } - - if (ChanID.IntType) { - ChanID.InfoChanSel = 1; /* None = 0, See Slot = 1, Any = 3 */ - ChanID.ChanMapType = 3; /* B-Chan */ - ChanID.ChanSlot = (unsigned char)chan_id; - } else { - ChanID.InfoChanSel = (unsigned char)chan_id & 0x03; /* None = 0, B1 = 1, B2 = 2, Any = 3 */ - } - gen->ChanID = Q931AppendIE(gen, (L3UCHAR *) &ChanID); - - /* - * Progress IE - */ - Q931InitIEProgInd(&Progress); - Progress.CodStand = Q931_CODING_ITU; /* 0 = ITU */ - Progress.Location = 0; /* 0 = User, 1 = Private Network */ - Progress.ProgDesc = 3; /* 1 = Not end-to-end ISDN */ - gen->ProgInd = Q931AppendIE(gen, (L3UCHAR *)&Progress); - - /* - * Display IE - */ - if (!(isdn_data->opts & FTDM_ISDN_OPT_OMIT_DISPLAY_IE) && FTDM_SPAN_IS_NT(span)) { - Q931InitIEDisplay(&Display); - Display.Size = Display.Size + (unsigned char)strlen(caller_data->cid_name); - gen->Display = Q931AppendIE(gen, (L3UCHAR *) &Display); - ptrDisplay = Q931GetIEPtr(gen->Display, gen->buf); - ftdm_copy_string((char *)ptrDisplay->Display, caller_data->cid_name, strlen(caller_data->cid_name)+1); - } - - /* - * Calling Number IE - */ - Q931InitIECallingNum(&CallingNum); - CallingNum.TypNum = Q931_TON_UNKNOWN; - CallingNum.NumPlanID = Q931_NUMPLAN_E164; - CallingNum.PresInd = Q931_PRES_ALLOWED; - CallingNum.ScreenInd = Q931_SCREEN_USER_NOT_SCREENED; - CallingNum.Size = CallingNum.Size + (unsigned char)strlen(caller_data->cid_num.digits); - gen->CallingNum = Q931AppendIE(gen, (L3UCHAR *) &CallingNum); - ptrCallingNum = Q931GetIEPtr(gen->CallingNum, gen->buf); - ftdm_copy_string((char *)ptrCallingNum->Digit, caller_data->cid_num.digits, strlen(caller_data->cid_num.digits)+1); - - - /* - * Called number IE - */ - Q931InitIECalledNum(&CalledNum); - CalledNum.TypNum = Q931_TON_UNKNOWN; - CalledNum.NumPlanID = Q931_NUMPLAN_E164; - CalledNum.Size = CalledNum.Size + (unsigned char)strlen(caller_data->ani.digits); - gen->CalledNum = Q931AppendIE(gen, (L3UCHAR *) &CalledNum); - ptrCalledNum = Q931GetIEPtr(gen->CalledNum, gen->buf); - ftdm_copy_string((char *)ptrCalledNum->Digit, caller_data->ani.digits, strlen(caller_data->ani.digits)+1); - - /* - * High-Layer Compatibility IE (Note: Required for AVM FritzBox) - */ - Q931InitIEHLComp(&HLComp); - HLComp.CodStand = Q931_CODING_ITU; /* ITU */ - HLComp.Interpret = 4; /* only possible value */ - HLComp.PresMeth = 1; /* High-layer protocol profile */ - HLComp.HLCharID = 1; /* Telephony = 1, Fax G2+3 = 4, Fax G4 = 65 (Class I)/ 68 (Class II or III) */ - gen->HLComp = Q931AppendIE(gen, (L3UCHAR *) &HLComp); - - caller_data->call_state = FTDM_CALLER_STATE_DIALING; - Q931Rx43(&isdn_data->q931, gen, gen->Size); - - isdn_data->outbound_crv[gen->CRV] = caller_data; - //isdn_data->channels_local_crv[gen->CRV] = ftdmchan; - - while (ftdm_running() && caller_data->call_state == FTDM_CALLER_STATE_DIALING) { - ftdm_sleep(1); - - if (!--sanity) { - caller_data->call_state = FTDM_CALLER_STATE_FAIL; - break; - } - } - isdn_data->outbound_crv[gen->CRV] = NULL; - - if (caller_data->call_state == FTDM_CALLER_STATE_SUCCESS) { - ftdm_channel_t *new_chan = NULL; - int fail = 1; - - new_chan = NULL; - if (caller_data->chan_id > 0 && caller_data->chan_id <= ftdm_span_get_chan_count(span)) { - new_chan = ftdm_span_get_channel(span, caller_data->chan_id); - } - - if (new_chan && (status = ftdm_channel_open_chan(new_chan) == FTDM_SUCCESS)) { - if (ftdm_test_flag(new_chan, FTDM_CHANNEL_INUSE) || new_chan->state != FTDM_CHANNEL_STATE_DOWN) { - if (new_chan->state == FTDM_CHANNEL_STATE_DOWN || new_chan->state >= FTDM_CHANNEL_STATE_TERMINATING) { - int x = 0; - ftdm_log(FTDM_LOG_WARNING, "Channel %d:%d ~ %d:%d is already in use waiting for it to become available.\n"); - - for (x = 0; x < 200; x++) { - if (!ftdm_test_flag(new_chan, FTDM_CHANNEL_INUSE)) { - break; - } - ftdm_sleep(5); - } - } - if (ftdm_test_flag(new_chan, FTDM_CHANNEL_INUSE)) { - ftdm_log(FTDM_LOG_ERROR, "Channel %d:%d ~ %d:%d is already in use.\n", - new_chan->span_id, - new_chan->chan_id, - new_chan->physical_span_id, - new_chan->physical_chan_id - ); - new_chan = NULL; - } - } - - if (new_chan && new_chan->state == FTDM_CHANNEL_STATE_DOWN) { - struct Q931_Call *call = NULL; - - memset(&new_chan->caller_data, 0, sizeof(new_chan->caller_data)); - ftdm_set_flag(new_chan, FTDM_CHANNEL_OUTBOUND); - ftdm_set_state_locked(new_chan, FTDM_CHANNEL_STATE_DIALING); - - call = Q931GetCallByCRV(&isdn_data->q931, gen->CRV); - Q931CallSetPrivate(call, new_chan); - - switch(gen->MesType) { - case Q931mes_ALERTING: - new_chan->init_state = FTDM_CHANNEL_STATE_PROGRESS_MEDIA; - break; - case Q931mes_CONNECT: - new_chan->init_state = FTDM_CHANNEL_STATE_UP; - break; - default: - new_chan->init_state = FTDM_CHANNEL_STATE_PROGRESS; - break; - } - - fail = 0; - } - } - - if (!fail) { - *ftdmchan = new_chan; - return FTDM_SUCCESS; - } else { - Q931ie_Cause cause; - gen->MesType = Q931mes_DISCONNECT; - cause.IEId = Q931ie_CAUSE; - cause.Size = sizeof(Q931ie_Cause); - cause.CodStand = 0; - cause.Location = 1; - cause.Recom = 1; - //should we be casting here.. or do we need to translate value? - cause.Value = (unsigned char) FTDM_CAUSE_WRONG_CALL_STATE; - *cause.Diag = '\0'; - gen->Cause = Q931AppendIE(gen, (L3UCHAR *) &cause); - Q931Rx43(&isdn_data->q931, gen, gen->Size); - - if (gen->CRV) { - Q931ReleaseCRV(&isdn_data->q931, gen->CRV); - } - - if (new_chan) { - ftdm_log(FTDM_LOG_CRIT, "Channel is busy\n"); - } else { - ftdm_log(FTDM_LOG_CRIT, "Failed to open channel for new setup message\n"); - } - } - } - - *ftdmchan = NULL; - return FTDM_FAIL; - -} -#endif /* __TODO__ */ - -static L3INT ftdm_isdn_931_err(void *pvt, L3INT id, L3INT p1, L3INT p2) -{ - ftdm_log(FTDM_LOG_ERROR, "ERROR: [%s] [%d] [%d]\n", q931_error_to_name(id), p1, p2); - return 0; -} - -/** - * \brief The new call event handler - * \note W000t!!! \o/ ;D - * \todo A lot - */ -static void ftdm_isdn_call_event(struct Q931_Call *call, struct Q931_CallEvent *event, void *priv) -{ - Q931_TrunkInfo_t *trunk = NULL; - ftdm_isdn_data_t *isdn_data = NULL; - ftdm_span_t *span = priv; - - assert(span); - assert(call); - assert(event); - - trunk = Q931CallGetTrunk(call); - assert(trunk); - - isdn_data = span->signal_data; - assert(isdn_data); - - if (Q931CallIsGlobal(call)) { - /* - * Global event - */ - ftdm_log(FTDM_LOG_DEBUG, "Received global event from Q.931\n"); - } else { - ftdm_channel_t *ftdmchan = NULL; - ftdm_sigmsg_t sig; - int call_crv = Q931CallGetCRV(call); - int type; - - /* - * Call-specific event - */ - ftdm_log(FTDM_LOG_DEBUG, "Received call-specific event from Q.931 for call %d [%hu]\n", Q931CallGetCRV(call), Q931CallGetCRV(call)); - - /* - * Try to get associated zap channel - * and init sigmsg struct if there is one - */ - ftdmchan = Q931CallGetPrivate(call); - if (ftdmchan) { - memset(&sig, 0, sizeof(ftdm_sigmsg_t)); - sig.chan_id = ftdmchan->chan_id; - sig.span_id = ftdmchan->span_id; - sig.channel = ftdmchan; - } - - type = Q931CallEventGetType(event); - - if (type == Q931_EVENT_TYPE_CRV) { - - ftdm_log(FTDM_LOG_DEBUG, "\tCRV event\n"); - - switch (Q931CallEventGetId(event)) { - case Q931_EVENT_RELEASE_CRV: - { - /* WARNING contains old interface code, yuck! */ - if (!ftdmchan) { - ftdm_log(FTDM_LOG_DEBUG, "Call %d [0x%x] not associated to zap channel\n", call_crv, call_crv); - return; - } - - if (ftdm_channel_get_state(ftdmchan) != FTDM_CHANNEL_STATE_DOWN && - ftdm_channel_get_state(ftdmchan) != FTDM_CHANNEL_STATE_HANGUP_COMPLETE) - { - ftdm_log(FTDM_LOG_DEBUG, "Channel %d:%d not in DOWN state, cleaning up\n", - ftdm_channel_get_span_id(ftdmchan), - ftdm_channel_get_id(ftdmchan)); - - /* - * Send hangup signal to mod_freetdm - */ - if (!sig.channel->caller_data.hangup_cause) { - sig.channel->caller_data.hangup_cause = FTDM_CAUSE_NORMAL_CLEARING; - } - - sig.event_id = FTDM_SIGEVENT_STOP; - ftdm_span_send_signal(ftdm_channel_get_span(ftdmchan), &sig); - - /* Release zap channel */ - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - } - return; - } - break; - default: - ftdm_log(FTDM_LOG_ERROR, "Unknown CRV event: %d\n", Q931CallEventGetId(event)); - return; - } - } - else if (type == Q931_EVENT_TYPE_TIMER) { - struct Q931_CallTimerEvent *timer_evt = Q931CallEventGetData(event); - - ftdm_log(FTDM_LOG_DEBUG, "\tTimer event\n"); - assert(timer_evt->id); - - switch (timer_evt->id) { - case Q931_TIMER_T303: - /* - * SETUP timeout - * - * TE-mode: Q931_EVENT_SETUP_CONFIRM (error) - * NT-mode: Q931_EVENT_RELEASE_INDICATION - */ - { - /* WARNING contains old interface code, yuck! */ - if (!ftdmchan) { - ftdm_log(FTDM_LOG_ERROR, "Call %d [0x%x] not associated to zap channel\n", call_crv, call_crv); - return; - } - - ftdm_log(FTDM_LOG_DEBUG, "Call setup failed on channel %d:%d\n", - ftdm_channel_get_span_id(ftdmchan), - ftdm_channel_get_id(ftdmchan)); - - /* - * Send signal to mod_freetdm - */ - sig.channel->caller_data.hangup_cause = FTDM_CAUSE_NETWORK_OUT_OF_ORDER; - - sig.event_id = FTDM_SIGEVENT_STOP; - ftdm_span_send_signal(ftdm_channel_get_span(ftdmchan), &sig); - - /* Release zap channel */ - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - return; - } - break; - - default: - ftdm_log(FTDM_LOG_ERROR, "Unhandled timer event %d\n", timer_evt->id); - } - } - else if (type == Q931_EVENT_TYPE_MESSAGE) { - struct Q931_CallMessageEvent *msg_evt = Q931CallEventGetData(event); - - ftdm_log(FTDM_LOG_DEBUG, "\tMessage event\n"); - assert(msg_evt); - - /* - * Slowly move stuff from the old event handler into this part... - */ - switch (Q931CallEventGetId(event)) { - case Q931_EVENT_SETUP_CONFIRM: - case Q931_EVENT_SETUP_COMPLETE_INDICATION: /* CONNECT */ - { - /* WARNING contains old interface code, yuck! */ - if (!ftdmchan) { - ftdm_log(FTDM_LOG_ERROR, "Call %d [0x%x] not associated to zap channel\n", call_crv, call_crv); - return; - } - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_UP); - } - break; - - default: - ftdm_log(FTDM_LOG_DEBUG, "Not yet handled message event %d\n", Q931CallEventGetId(event)); - } - } - else { - ftdm_log(FTDM_LOG_ERROR, "Unknown event type %d\n", type); - } - } -} - -/** - * Copy callednum, readding prefix as needed - */ -static void __isdn_get_number(const char *digits, const int ton, char *buf, int size) -{ - int offset = 0; - - if (!digits || !buf || size <= 0) - return; - - switch (ton) { - case Q931_TON_NATIONAL: - offset = strlen(DEFAULT_NATIONAL_PREFIX); - memcpy(buf, DEFAULT_NATIONAL_PREFIX, offset); - break; - case Q931_TON_INTERNATIONAL: - offset = strlen(DEFAULT_INTERNATIONAL_PREFIX); - memcpy(buf, DEFAULT_INTERNATIONAL_PREFIX, offset); - break; - default: - break; - } - - strncpy(&buf[offset], digits, size - (offset + 1)); - buf[size - 1] = '\0'; -} - -#define isdn_get_number(num, buf) \ - __isdn_get_number((const char *)(num)->Digit, (num)->TypNum, (char *)buf, sizeof(buf)) - - -/** - * \brief The old call event handler (err, call message handler) - * \todo This one must die! - */ -static L3INT ftdm_isdn_931_34(void *pvt, struct Q931_Call *call, Q931mes_Generic *msg, int mlen) -{ - Q931mes_Generic *gen = (Q931mes_Generic *) msg; - ftdm_span_t *span = (ftdm_span_t *) pvt; - ftdm_isdn_data_t *isdn_data = span->signal_data; - ftdm_channel_t *ftdmchan = NULL; - int chan_id = 0; - int chan_hunt = 0; - - if (Q931IsIEPresent(gen->ChanID)) { - Q931ie_ChanID *chanid = Q931GetIEPtr(gen->ChanID, gen->buf); - - if (chanid->IntType) - chan_id = chanid->ChanSlot; - else - chan_id = chanid->InfoChanSel; - - /* "any" channel specified */ - if (chanid->InfoChanSel == 3) { - chan_hunt++; - } - } else if (FTDM_SPAN_IS_NT(span)) { - /* no channel ie */ - chan_hunt++; - } - - assert(span != NULL); - assert(isdn_data != NULL); - - /* ftdm channel is stored in call private */ - if (call) { - ftdmchan = Q931CallGetPrivate(call); - if (!ftdmchan) { - ftdm_log(FTDM_LOG_DEBUG, "[s%d] No channel associated to call [%#x] private\n", - ftdm_span_get_id(span), Q931CallGetCRV(call)); - } - } - - ftdm_log(FTDM_LOG_DEBUG, "Yay I got an event! Type:[%02x] Size:[%d] CRV: %d (%#hx, CTX: %s)\n", - gen->MesType, gen->Size, gen->CRV, gen->CRV, gen->CRVFlag ? "Terminator" : "Originator"); - -#ifdef __TODO__ - /* - * This code block is needed for isdn_channel_request() - * isdn_data->outbound_crv has been removed so another way to pass data around is required - */ - if (gen->CRVFlag && (caller_data = isdn_data->outbound_crv[gen->CRV])) { - if (chan_id) { - caller_data->chan_id = chan_id; - } - - switch(gen->MesType) { - case Q931mes_STATUS: - case Q931mes_CALL_PROCEEDING: - break; - case Q931mes_ALERTING: - case Q931mes_PROGRESS: - case Q931mes_CONNECT: - caller_data->call_state = FTDM_CALLER_STATE_SUCCESS; - break; - default: - caller_data->call_state = FTDM_CALLER_STATE_FAIL; - break; - } - - return 0; - } -#endif - ftdm_log(FTDM_LOG_DEBUG, "ftdmchan %p (%d:%d) via CRV[%#hx]\n", - ftdmchan, - ((ftdmchan) ? ftdm_channel_get_span_id(ftdmchan) : -1), - ((ftdmchan) ? ftdm_channel_get_id(ftdmchan) : -1), - gen->CRV); - - if (gen->ProtDisc == 3) { - switch(gen->MesType) { - case Q931mes_SERVICE: - { - Q931ie_ChangeStatus *changestatus = Q931GetIEPtr(gen->ChangeStatus, gen->buf); - if (ftdmchan) { - switch (changestatus->NewStatus) { - case 0: /* change status to "in service" */ - { - ftdm_clear_flag_locked(ftdmchan, FTDM_CHANNEL_SUSPENDED); - ftdm_log(FTDM_LOG_DEBUG, "Channel %d:%d in service\n", - ftdm_channel_get_span_id(ftdmchan), - ftdm_channel_get_id(ftdmchan)); - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_RESTART); - } - break; - case 1: - { /* change status to "maintenance" */ - ftdm_set_flag_locked(ftdmchan, FTDM_CHANNEL_SUSPENDED); - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); - } - break; - case 2: - { /* change status to "out of service" */ - ftdm_set_flag_locked(ftdmchan, FTDM_CHANNEL_SUSPENDED); - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); - } - break; - default: /* unknown */ - { - break; - } - } - } - } - break; - default: - break; - } - } else { - switch(gen->MesType) { - case Q931mes_RESTART: - { - if (chan_id) { - ftdmchan = ftdm_span_get_channel(span, chan_id); - } - if (ftdmchan) { - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_RESTART); - } else { - uint32_t i; - - for (i = 1; i < ftdm_span_get_chan_count(span); i++) { - ftdmchan = ftdm_span_get_channel(span, chan_id); - - /* Skip channels that are down and D-Channels (#OpenZAP-39) */ - if (ftdm_channel_get_state(ftdmchan) == FTDM_CHANNEL_STATE_DOWN || - ftdm_channel_get_type(ftdmchan) == FTDM_CHAN_TYPE_DQ921) - continue; - - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_RESTART); - } - } - } - break; - case Q931mes_RELEASE: - case Q931mes_RELEASE_COMPLETE: - { - const char *what = gen->MesType == Q931mes_RELEASE ? "Release" : "Release Complete"; - if (ftdmchan) { - if (ftdm_channel_get_state(ftdmchan) == FTDM_CHANNEL_STATE_TERMINATING || - ftdm_channel_get_state(ftdmchan) == FTDM_CHANNEL_STATE_HANGUP) - { - if (gen->MesType == Q931mes_RELEASE) { - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_HANGUP_COMPLETE); - } else { - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - } - } - else if (gen->MesType == Q931mes_RELEASE_COMPLETE && ftdm_channel_get_state(ftdmchan) == FTDM_CHANNEL_STATE_DIALTONE) { - /* Go DOWN */ - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - } - else if ((gen->MesType == Q931mes_RELEASE && ftdm_channel_get_state(ftdmchan) <= FTDM_CHANNEL_STATE_UP) || - (gen->MesType == Q931mes_RELEASE_COMPLETE && ftdm_channel_get_state(ftdmchan) == FTDM_CHANNEL_STATE_DIALING)) { - - /* - * Don't keep inbound channels open if the remote side hangs up before we answered - */ - Q931ie_Cause *cause = Q931GetIEPtr(gen->Cause, gen->buf); - ftdm_sigmsg_t sig; - - memset(&sig, 0, sizeof(sig)); - sig.span_id = ftdm_channel_get_span_id(ftdmchan); - sig.chan_id = ftdm_channel_get_id(ftdmchan); - sig.channel = ftdmchan; - sig.channel->caller_data.hangup_cause = (cause) ? cause->Value : FTDM_CAUSE_NORMAL_UNSPECIFIED; - - sig.event_id = FTDM_SIGEVENT_STOP; - ftdm_span_send_signal(span, &sig); - - ftdm_log(FTDM_LOG_DEBUG, "Received %s in state %s, requested hangup for channel %d:%d\n", what, - ftdm_channel_get_state_str(ftdmchan), - ftdm_channel_get_span_id(ftdmchan), - ftdm_channel_get_id(ftdmchan)); - } else { - ftdm_log(FTDM_LOG_DEBUG, "Ignoring %s on channel %d in state %s\n", what, - ftdm_channel_get_id(ftdmchan), ftdm_channel_get_state_str(ftdmchan)); - } - } else { - ftdm_log(FTDM_LOG_CRIT, "Received %s with no matching channel %d\n", what, chan_id); - } - } - break; - case Q931mes_DISCONNECT: - { - if (ftdmchan) { - Q931ie_Cause *cause = Q931GetIEPtr(gen->Cause, gen->buf); - ftdmchan->caller_data.hangup_cause = cause->Value; - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); - } else { - ftdm_log(FTDM_LOG_CRIT, "Received Disconnect with no matching channel %d\n", chan_id); - } - } - break; - case Q931mes_ALERTING: - { - if (ftdmchan) { - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA); - } else { - ftdm_log(FTDM_LOG_CRIT, "Received Alerting with no matching channel %d\n", chan_id); - } - } - break; - case Q931mes_PROGRESS: - { - if (ftdmchan) { - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_PROGRESS); - } else { - ftdm_log(FTDM_LOG_CRIT, "Received Progress with no matching channel %d\n", chan_id); - } - } - break; - case Q931mes_CONNECT: -#if 0 /* Handled by new event code */ - { - if (ftdmchan) { - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_UP); - -#if 0 /* Auto-Ack is enabled, we actually don't need this */ - gen->MesType = Q931mes_CONNECT_ACKNOWLEDGE; - gen->CRVFlag = 0; /* outbound */ - Q931Rx43(&isdn_data->q931, gen, gen->Size); -#endif - } else { - ftdm_log(FTDM_LOG_CRIT, "Received Connect with no matching channel %d\n", chan_id); - } - } -#endif - break; - case Q931mes_SETUP: - { - Q931ie_CallingNum *callingnum = Q931GetIEPtr(gen->CallingNum, gen->buf); - Q931ie_CalledNum *callednum = Q931GetIEPtr(gen->CalledNum, gen->buf); - int overlap_dial = 0; - int fail_cause = 0; - int fail = 1; - - if (ftdmchan && ftdmchan == Q931CallGetPrivate(call)) { - ftdm_log(FTDM_LOG_INFO, "Duplicate SETUP message(?) for Channel %d:%d ~ %d:%d in state %s [ignoring]\n", - ftdm_channel_get_span_id(ftdmchan), - ftdm_channel_get_id(ftdmchan), - ftdm_channel_get_ph_span_id(ftdmchan), - ftdm_channel_get_ph_id(ftdmchan), - ftdm_channel_get_state_str(ftdmchan)); - break; - } - - ftdmchan = NULL; - /* - * Channel selection for incoming calls: - */ - if (FTDM_SPAN_IS_NT(span) && chan_hunt) { - int x; - - /* - * In NT-mode with channel selection "any", - * try to find a free channel - */ - for (x = 1; x <= ftdm_span_get_chan_count(span); x++) { - ftdm_channel_t *zc = ftdm_span_get_channel(span, x); - - if (!ftdm_test_flag(zc, FTDM_CHANNEL_INUSE) && ftdm_channel_get_state(zc) == FTDM_CHANNEL_STATE_DOWN) { - ftdmchan = zc; - break; - } - } - } - else if (!FTDM_SPAN_IS_NT(span) && chan_hunt) { - /* - * In TE-mode this ("any") is invalid - */ - fail_cause = FTDM_CAUSE_CHANNEL_UNACCEPTABLE; - - ftdm_log(FTDM_LOG_ERROR, "Invalid channel selection in incoming call (network side didn't specify a channel)\n"); - } - else { - /* - * Otherwise simply try to select the channel we've been told - * - * TODO: NT mode is abled to select a different channel if the one chosen - * by the TE side is already in use - */ - if (chan_id > 0 && chan_id < FTDM_MAX_CHANNELS_SPAN && chan_id <= ftdm_span_get_chan_count(span)) { - ftdmchan = ftdm_span_get_channel(span, chan_id); - } - else { - /* invalid channel id */ - fail_cause = FTDM_CAUSE_CHANNEL_UNACCEPTABLE; - - ftdm_log(FTDM_LOG_ERROR, "Invalid channel selection in incoming call (none selected or out of bounds)\n"); - } - } - - if (!callednum || ftdm_strlen_zero((char *)callednum->Digit)) { - if (FTDM_SPAN_IS_NT(span)) { - ftdm_log(FTDM_LOG_NOTICE, "No destination number found, assuming overlap dial\n"); - overlap_dial++; - } else { - ftdm_log(FTDM_LOG_ERROR, "No destination number found\n"); - ftdmchan = NULL; - } - } - - if (ftdmchan) { - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_INUSE) || ftdm_channel_get_state(ftdmchan) != FTDM_CHANNEL_STATE_DOWN) { - if (ftdm_channel_get_state(ftdmchan) == FTDM_CHANNEL_STATE_DOWN || ftdm_channel_get_state(ftdmchan) >= FTDM_CHANNEL_STATE_TERMINATING) - { - int x = 0; - ftdm_log(FTDM_LOG_WARNING, "Channel %d:%d ~ %d:%d is already in use waiting for it to become available.\n", - ftdm_channel_get_span_id(ftdmchan), - ftdm_channel_get_id(ftdmchan), - ftdm_channel_get_ph_span_id(ftdmchan), - ftdm_channel_get_ph_id(ftdmchan)); - - for (x = 0; x < 200; x++) { - if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_INUSE)) { - break; - } - ftdm_sleep(5); - } - } - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_INUSE)) { - ftdm_log(FTDM_LOG_ERROR, "Channel %d:%d ~ %d:%d is already in use.\n", - ftdm_channel_get_span_id(ftdmchan), - ftdm_channel_get_id(ftdmchan), - ftdm_channel_get_ph_span_id(ftdmchan), - ftdm_channel_get_ph_id(ftdmchan)); - ftdmchan = NULL; - } - } - - if (ftdmchan && ftdm_channel_get_state(ftdmchan) == FTDM_CHANNEL_STATE_DOWN) { - ftdm_caller_data_t *caller_data = ftdm_channel_get_caller_data(ftdmchan); - - memset(&ftdmchan->caller_data, 0, sizeof(ftdmchan->caller_data)); - - if (ftdmchan->call_data) { - memset(ftdmchan->call_data, 0, sizeof(ftdm_isdn_bchan_data_t)); - } - - /* copy number readd prefix as needed */ - isdn_get_number(callingnum, caller_data->cid_num.digits); - isdn_get_number(callingnum, caller_data->cid_name); - isdn_get_number(callingnum, caller_data->ani.digits); - - if (!overlap_dial) { - isdn_get_number(callednum, caller_data->dnis.digits); - } - - ftdmchan->caller_data.call_reference = gen->CRV; - Q931CallSetPrivate(call, ftdmchan); - - gen->CRVFlag = !(gen->CRVFlag); - - fail = 0; - } - } - - if (fail) { - Q931ie_Cause cause; - - gen->MesType = Q931mes_DISCONNECT; - gen->CRVFlag = 1; /* inbound call */ - - cause.IEId = Q931ie_CAUSE; - cause.Size = sizeof(Q931ie_Cause); - cause.CodStand = Q931_CODING_ITU; - cause.Location = 1; - cause.Recom = 1; - //should we be casting here.. or do we need to translate value? - cause.Value = (unsigned char)((fail_cause) ? fail_cause : FTDM_CAUSE_WRONG_CALL_STATE); - *cause.Diag = '\0'; - gen->Cause = Q931AppendIE(gen, (L3UCHAR *) &cause); - Q931Rx43(&isdn_data->q931, gen, gen->Size); - - if (gen->CRV) { - Q931ReleaseCRV(&isdn_data->q931, gen->CRV); - } - - if (ftdmchan) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "Channel is busy\n"); - } else { - ftdm_log(FTDM_LOG_CRIT, "Failed to open channel for new setup message\n"); - } - - } else { - Q931ie_ChanID ChanID; - - /* - * Update Channel ID IE - */ - Q931InitIEChanID(&ChanID); - ChanID.IntType = FTDM_SPAN_IS_BRI(ftdmchan->span) ? 0 : 1; /* PRI = 1, BRI = 0 */ - ChanID.PrefExcl = FTDM_SPAN_IS_NT(ftdmchan->span) ? 1 : 0; /* Exclusive in NT-mode = 1, Preferred otherwise = 0 */ - if (ChanID.IntType) { - ChanID.InfoChanSel = 1; /* None = 0, See Slot = 1, Any = 3 */ - ChanID.ChanMapType = 3; /* B-Chan */ - ChanID.ChanSlot = (unsigned char)ftdm_channel_get_id(ftdmchan); - } else { - ChanID.InfoChanSel = (unsigned char)ftdm_channel_get_id(ftdmchan) & 0x03; /* None = 0, B1 = 1, B2 = 2, Any = 3 */ - } - gen->ChanID = Q931AppendIE(gen, (L3UCHAR *) &ChanID); - - if (overlap_dial) { - Q931ie_ProgInd progress; - - /* - * Setup Progress indicator - */ - progress.IEId = Q931ie_PROGRESS_INDICATOR; - progress.Size = sizeof(Q931ie_ProgInd); - progress.CodStand = Q931_CODING_ITU; /* ITU */ - progress.Location = 1; /* private network serving the local user */ - progress.ProgDesc = 8; /* call is not end-to-end isdn = 1, in-band information available = 8 */ - gen->ProgInd = Q931AppendIE(gen, (L3UCHAR *) &progress); - - /* - * Send SETUP ACK - */ - gen->MesType = Q931mes_SETUP_ACKNOWLEDGE; - gen->CRVFlag = 1; /* inbound call */ - Q931Rx43(&isdn_data->q931, gen, gen->Size); - - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DIALTONE); - } else { - /* - * Advance to RING state - */ - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_RING); - } - } - } - break; - - case Q931mes_CALL_PROCEEDING: - { - if (ftdmchan) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "Received CALL PROCEEDING message for channel\n"); - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_PROGRESS); - } else { - ftdm_log(FTDM_LOG_CRIT, "Received CALL PROCEEDING with no matching channel %d\n", chan_id); - } - } - break; - case Q931mes_CONNECT_ACKNOWLEDGE: - { - if (ftdmchan) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Received CONNECT_ACK message for channel\n"); - } else { - ftdm_log(FTDM_LOG_DEBUG, "Received CONNECT_ACK with no matching channel %d\n", chan_id); - } - } - break; - - case Q931mes_INFORMATION: - { - if (ftdmchan) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "Received INFORMATION message for channel\n"); - - if (ftdm_channel_get_state(ftdmchan) == FTDM_CHANNEL_STATE_DIALTONE) { - char digit = '\0'; - - /* - * overlap dial digit indication - */ - if (Q931IsIEPresent(gen->CalledNum)) { - ftdm_isdn_bchan_data_t *data = (ftdm_isdn_bchan_data_t *)ftdmchan->call_data; - Q931ie_CalledNum *callednum = Q931GetIEPtr(gen->CalledNum, gen->buf); - int pos; - - digit = callednum->Digit[strlen((char *)callednum->Digit) - 1]; - if (digit == '#') { - callednum->Digit[strlen((char *)callednum->Digit) - 1] = '\0'; - } - - /* TODO: make this more safe with strncat() */ - pos = strlen(ftdmchan->caller_data.dnis.digits); - strcat(&ftdmchan->caller_data.dnis.digits[pos], (char *)callednum->Digit); - - /* update timer */ - data->digit_timeout = ftdm_time_now() + isdn_data->digit_timeout; - - ftdm_log(FTDM_LOG_DEBUG, "Received new overlap digit (%s), destination number: %s\n", callednum->Digit, ftdmchan->caller_data.dnis.digits); - } - - if (Q931IsIEPresent(gen->SendComplete) || digit == '#') { - ftdm_log(FTDM_LOG_DEBUG, "Leaving overlap dial mode\n"); - - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_RING); - } - } - } else { - ftdm_log(FTDM_LOG_CRIT, "Received INFORMATION message with no matching channel\n"); - } - } - break; - - default: - ftdm_log(FTDM_LOG_CRIT, "Received unhandled message %d (%#x)\n", (int)gen->MesType, (int)gen->MesType); - break; - } - } - - return 0; -} - -static int ftdm_isdn_921_23(void *pvt, Q921DLMsg_t ind, L2UCHAR tei, L2UCHAR *msg, L2INT mlen) -{ - ftdm_span_t *span = pvt; - ftdm_isdn_data_t *isdn_data = span->signal_data; - int ret, offset = (ind == Q921_DL_DATA) ? 4 : 3; - char bb[4096] = ""; - - switch(ind) { - case Q921_DL_DATA: - case Q921_DL_UNIT_DATA: - print_hex_bytes(msg + offset, mlen - offset, bb, sizeof(bb)); - ftdm_log(FTDM_LOG_DEBUG, "READ %d\n%s\n%s\n\n", (int)mlen - offset, LINE, bb); -#ifdef HAVE_PCAP - if (isdn_pcap_capture_l3only(isdn_data)) { - isdn_pcap_write(isdn_data, msg, mlen, (ind == Q921_DL_UNIT_DATA) ? ISDN_PCAP_INCOMING_BCAST : ISDN_PCAP_INCOMING); - } -#endif - default: - ret = Q931Rx23(&isdn_data->q931, ind, tei, msg, mlen); - if (ret != 0) - ftdm_log(FTDM_LOG_DEBUG, "931 parse error [%d] [%s]\n", ret, q931_error_to_name(ret)); - break; - } - - return ((ret >= 0) ? 1 : 0); -} - -static int ftdm_isdn_921_21(void *pvt, L2UCHAR *msg, L2INT mlen) -{ - ftdm_span_t *span = (ftdm_span_t *) pvt; - ftdm_size_t len = (ftdm_size_t) mlen; - ftdm_isdn_data_t *isdn_data = span->signal_data; - - assert(span != NULL); - -#ifdef HAVE_PCAP - if (isdn_pcap_capture_both(isdn_data)) { - isdn_pcap_write(isdn_data, msg, mlen, ISDN_PCAP_OUTGOING); - } -#endif - return ftdm_channel_write(isdn_data->dchan, msg, len, &len) == FTDM_SUCCESS ? 0 : -1; -} - -static __inline__ void state_advance(ftdm_channel_t *ftdmchan) -{ - ftdm_span_t *span = ftdm_channel_get_span(ftdmchan); - ftdm_isdn_data_t *isdn_data = NULL; - ftdm_sigmsg_t sig; - ftdm_status_t status; - - Q931mes_Generic empty_gen; - Q931mes_Generic *gen = &empty_gen; - struct Q931_Call *call = NULL; - - Q931InitMesGeneric(gen); - - isdn_data = span->signal_data; - assert(isdn_data); - - call = Q931GetCallByCRV(&isdn_data->q931, ftdmchan->caller_data.call_reference); - if (call) { - gen->CRV = Q931CallGetCRV(call); - gen->CRVFlag = Q931CallGetDirection(call) == Q931_DIRECTION_INBOUND ? 1 : 0; - } - - ftdm_log(FTDM_LOG_DEBUG, "%d:%d STATE [%s]\n", - ftdm_channel_get_span_id(ftdmchan), - ftdm_channel_get_id(ftdmchan), - ftdm_channel_get_state_str(ftdmchan)); - - memset(&sig, 0, sizeof(sig)); - sig.span_id = ftdm_channel_get_span_id(ftdmchan); - sig.chan_id = ftdm_channel_get_id(ftdmchan); - sig.channel = ftdmchan; - - /* Acknowledge channel state change */ - ftdm_channel_complete_state(ftdmchan); - - switch (ftdm_channel_get_state(ftdmchan)) { - case FTDM_CHANNEL_STATE_DOWN: - { - if (gen->CRV) { - Q931CallSetPrivate(call, NULL); - Q931ReleaseCRV(&isdn_data->q931, gen->CRV); - } - ftdmchan->caller_data.call_reference = 0; - ftdm_channel_close(&ftdmchan); - } - break; - case FTDM_CHANNEL_STATE_PROGRESS: - { - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { - sig.event_id = FTDM_SIGEVENT_PROGRESS; - if ((status = ftdm_span_send_signal(ftdm_channel_get_span(ftdmchan), &sig) != FTDM_SUCCESS)) { - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_HANGUP); - } - } else { - gen->MesType = Q931mes_CALL_PROCEEDING; - - if (FTDM_SPAN_IS_NT(ftdm_channel_get_span(ftdmchan))) { - Q931ie_ChanID ChanID; - - /* - * Set new Channel ID - */ - Q931InitIEChanID(&ChanID); - ChanID.IntType = FTDM_SPAN_IS_BRI(ftdm_channel_get_span(ftdmchan)) ? 0 : 1; /* PRI = 1, BRI = 0 */ - ChanID.PrefExcl = 1; /* always exclusive in NT-mode */ - - if (ChanID.IntType) { - ChanID.InfoChanSel = 1; /* None = 0, See Slot = 1, Any = 3 */ - ChanID.ChanMapType = 3; /* B-Chan */ - ChanID.ChanSlot = (unsigned char)ftdm_channel_get_id(ftdmchan); - } else { - ChanID.InfoChanSel = (unsigned char)ftdm_channel_get_id(ftdmchan) & 0x03; /* None = 0, B1 = 1, B2 = 2, Any = 3 */ - } - gen->ChanID = Q931AppendIE(gen, (L3UCHAR *) &ChanID); - } - - Q931Rx43(&isdn_data->q931, gen, gen->Size); - } - } - break; - case FTDM_CHANNEL_STATE_DIALTONE: - { - ftdm_isdn_bchan_data_t *data = (ftdm_isdn_bchan_data_t *)ftdmchan->call_data; - - if (data) { - data->digit_timeout = ftdm_time_now() + isdn_data->digit_timeout; - } - } - break; - case FTDM_CHANNEL_STATE_RING: - { - if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { - sig.event_id = FTDM_SIGEVENT_START; - if ((status = ftdm_span_send_signal(span, &sig) != FTDM_SUCCESS)) { - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_HANGUP); - } - } - } - break; - case FTDM_CHANNEL_STATE_RESTART: - { - ftdmchan->caller_data.hangup_cause = FTDM_CAUSE_NORMAL_UNSPECIFIED; - sig.event_id = FTDM_SIGEVENT_RESTART; - status = ftdm_span_send_signal(span, &sig); - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - } - break; - case FTDM_CHANNEL_STATE_PROGRESS_MEDIA: - { - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { - sig.event_id = FTDM_SIGEVENT_PROGRESS_MEDIA; - if ((status = ftdm_span_send_signal(span, &sig) != FTDM_SUCCESS)) { - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_HANGUP); - } - } else { - if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OPEN)) { - if (ftdm_channel_open_chan(ftdmchan) != FTDM_SUCCESS) { - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_HANGUP); - return; - } - } - gen->MesType = Q931mes_ALERTING; - Q931Rx43(&isdn_data->q931, gen, gen->Size); - } - } - break; - case FTDM_CHANNEL_STATE_UP: - { - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { - sig.event_id = FTDM_SIGEVENT_UP; - if ((status = ftdm_span_send_signal(span, &sig) != FTDM_SUCCESS)) { - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_HANGUP); - } - } else { - if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OPEN)) { - if (ftdm_channel_open_chan(ftdmchan) != FTDM_SUCCESS) { - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_HANGUP); - return; - } - } - - gen->MesType = Q931mes_CONNECT; - - Q931Rx43(&isdn_data->q931, gen, gen->Size); - } - } - break; - case FTDM_CHANNEL_STATE_DIALING: - if (!(isdn_data->opts & FTDM_ISDN_OPT_SUGGEST_CHANNEL)) { - ftdm_caller_data_t *caller_data = ftdm_channel_get_caller_data(ftdmchan); - Q931ie_BearerCap BearerCap; - Q931ie_ChanID ChanID; - Q931ie_CallingNum CallingNum; - Q931ie_CallingNum *ptrCallingNum; - Q931ie_CalledNum CalledNum; - Q931ie_CalledNum *ptrCalledNum; - Q931ie_Display Display, *ptrDisplay; - Q931ie_HLComp HLComp; /* High-Layer Compatibility IE */ - Q931ie_ProgInd Progress; /* Progress Indicator IE */ - int codec = 0; - - /* - * get codec type - */ - ftdm_channel_command(ftdmchan, FTDM_COMMAND_GET_NATIVE_CODEC, &codec); - - /* - * Q.931 Setup Message - */ - Q931InitMesGeneric(gen); - gen->MesType = Q931mes_SETUP; - gen->CRVFlag = 0; /* outbound(?) */ - - /* - * Bearer Capability IE - */ - Q931InitIEBearerCap(&BearerCap); - BearerCap.CodStand = Q931_CODING_ITU; /* ITU-T = 0, ISO/IEC = 1, National = 2, Network = 3 */ - BearerCap.ITC = Q931_ITC_SPEECH; /* Speech */ - BearerCap.TransMode = 0; /* Circuit = 0, Packet = 1 */ - BearerCap.ITR = Q931_ITR_64K; /* 64k = 16, Packet mode = 0 */ - BearerCap.Layer1Ident = 1; - BearerCap.UIL1Prot = (codec == FTDM_CODEC_ALAW) ? 3 : 2; /* U-law = 2, A-law = 3 */ - gen->BearerCap = Q931AppendIE(gen, (L3UCHAR *) &BearerCap); - - /* - * ChannelID IE - */ - Q931InitIEChanID(&ChanID); - ChanID.IntType = FTDM_SPAN_IS_BRI(ftdm_channel_get_span(ftdmchan)) ? 0 : 1; /* PRI = 1, BRI = 0 */ - ChanID.PrefExcl = FTDM_SPAN_IS_NT(ftdm_channel_get_span(ftdmchan)) ? 1 : 0; /* Exclusive in NT-mode = 1, Preferred otherwise = 0 */ - if (ChanID.IntType) { - ChanID.InfoChanSel = 1; /* None = 0, See Slot = 1, Any = 3 */ - ChanID.ChanMapType = 3; /* B-Chan */ - ChanID.ChanSlot = (unsigned char)ftdm_channel_get_id(ftdmchan); - } else { - ChanID.InfoChanSel = (unsigned char)ftdm_channel_get_id(ftdmchan) & 0x03; /* None = 0, B1 = 1, B2 = 2, Any = 3 */ - } - gen->ChanID = Q931AppendIE(gen, (L3UCHAR *) &ChanID); - - /* - * Progress IE - */ - Q931InitIEProgInd(&Progress); - Progress.CodStand = Q931_CODING_ITU; /* 0 = ITU */ - Progress.Location = 0; /* 0 = User, 1 = Private Network */ - Progress.ProgDesc = 3; /* 1 = Not end-to-end ISDN */ - gen->ProgInd = Q931AppendIE(gen, (L3UCHAR *)&Progress); - - /* - * Display IE - */ - if (!(isdn_data->opts & FTDM_ISDN_OPT_OMIT_DISPLAY_IE) && FTDM_SPAN_IS_NT(ftdm_channel_get_span(ftdmchan))) { - Q931InitIEDisplay(&Display); - Display.Size = Display.Size + (unsigned char)strlen(caller_data->cid_name); - gen->Display = Q931AppendIE(gen, (L3UCHAR *) &Display); - ptrDisplay = Q931GetIEPtr(gen->Display, gen->buf); - ftdm_copy_string((char *)ptrDisplay->Display, caller_data->cid_name, strlen(caller_data->cid_name) + 1); - } - - /* - * CallingNum IE - */ - Q931InitIECallingNum(&CallingNum); - CallingNum.TypNum = caller_data->ani.type; - CallingNum.NumPlanID = Q931_NUMPLAN_E164; - CallingNum.PresInd = Q931_PRES_ALLOWED; - CallingNum.ScreenInd = Q931_SCREEN_USER_NOT_SCREENED; - CallingNum.Size = CallingNum.Size + (unsigned char)strlen(caller_data->cid_num.digits); - gen->CallingNum = Q931AppendIE(gen, (L3UCHAR *) &CallingNum); - ptrCallingNum = Q931GetIEPtr(gen->CallingNum, gen->buf); - ftdm_copy_string((char *)ptrCallingNum->Digit, caller_data->cid_num.digits, strlen(caller_data->cid_num.digits) + 1); - - /* - * CalledNum IE - */ - Q931InitIECalledNum(&CalledNum); - CalledNum.TypNum = Q931_TON_UNKNOWN; - CalledNum.NumPlanID = Q931_NUMPLAN_E164; - CalledNum.Size = CalledNum.Size + (unsigned char)strlen(caller_data->ani.digits); - gen->CalledNum = Q931AppendIE(gen, (L3UCHAR *) &CalledNum); - ptrCalledNum = Q931GetIEPtr(gen->CalledNum, gen->buf); - ftdm_copy_string((char *)ptrCalledNum->Digit, caller_data->ani.digits, strlen(caller_data->ani.digits) + 1); - - /* - * High-Layer Compatibility IE (Note: Required for AVM FritzBox) - */ - Q931InitIEHLComp(&HLComp); - HLComp.CodStand = Q931_CODING_ITU; /* ITU */ - HLComp.Interpret = 4; /* only possible value */ - HLComp.PresMeth = 1; /* High-layer protocol profile */ - HLComp.HLCharID = Q931_HLCHAR_TELEPHONY; /* Telephony = 1, Fax G2+3 = 4, Fax G4 = 65 (Class I)/ 68 (Class II or III) */ /* TODO: make accessible from user layer */ - gen->HLComp = Q931AppendIE(gen, (L3UCHAR *) &HLComp); - - Q931Rx43(&isdn_data->q931, gen, gen->Size); - - /* - * Support code for the new event handling system - * Remove this as soon as we have the new api to set up calls - */ - if (gen->CRV) { - call = Q931GetCallByCRV(&isdn_data->q931, gen->CRV); - if (call) { - ftdm_log(FTDM_LOG_DEBUG, "Storing reference to current span in call %d [0x%x]\n", gen->CRV, gen->CRV); - - Q931CallSetPrivate(call, ftdmchan); - ftdmchan->caller_data.call_reference = gen->CRV; - } - } - } - break; - case FTDM_CHANNEL_STATE_HANGUP_COMPLETE: - { - /* reply RELEASE with RELEASE_COMPLETE message */ - if (ftdm_channel_get_last_state(ftdmchan) == FTDM_CHANNEL_STATE_HANGUP) { - gen->MesType = Q931mes_RELEASE_COMPLETE; - - Q931Rx43(&isdn_data->q931, gen, gen->Size); - } - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - } - break; - case FTDM_CHANNEL_STATE_HANGUP: - { - ftdm_caller_data_t *caller_data = ftdm_channel_get_caller_data(ftdmchan); - Q931ie_Cause cause; - - ftdm_log(FTDM_LOG_DEBUG, "Hangup: Call direction %s\n", - ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND) ? "Outbound" : "Inbound"); - - cause.IEId = Q931ie_CAUSE; - cause.Size = sizeof(Q931ie_Cause); - cause.CodStand = Q931_CODING_ITU; /* ITU */ - cause.Location = 1; /* private network */ - cause.Recom = 1; /* */ - - /* - * BRI PTMP needs special handling here... - * TODO: cleanup / refine (see above) - */ - if (ftdm_channel_get_last_state(ftdmchan) == FTDM_CHANNEL_STATE_RING) { - /* - * inbound call [was: number unknown (= not found in routing state)] - * (in Q.931 spec terms: Reject request) - */ - if (!FTDM_SPAN_IS_NT(span)) { - gen->MesType = Q931mes_RELEASE_COMPLETE; /* TE mode: Reject call */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - } else { - gen->MesType = Q931mes_DISCONNECT; /* NT mode: Disconnect and wait */ - //ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_HANGUP_COMPLETE); - } - - //cause.Value = (unsigned char) FTDM_CAUSE_UNALLOCATED; - cause.Value = (unsigned char) caller_data->hangup_cause; - *cause.Diag = '\0'; - gen->Cause = Q931AppendIE(gen, (L3UCHAR *) &cause); - Q931Rx43(&isdn_data->q931, gen, gen->Size); - - /* we're done, release channel */ - ////ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_HANGUP_COMPLETE); - //ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - } - else if (ftdm_channel_get_last_state(ftdmchan) <= FTDM_CHANNEL_STATE_PROGRESS) { - /* - * just release all unanswered calls [was: inbound call, remote side hung up before we answered] - */ - gen->MesType = Q931mes_RELEASE; - - cause.Value = (unsigned char) caller_data->hangup_cause; - *cause.Diag = '\0'; - gen->Cause = Q931AppendIE(gen, (L3UCHAR *) &cause); - Q931Rx43(&isdn_data->q931, gen, gen->Size); - - /* this will be triggered by the RELEASE_COMPLETE reply */ - /* ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_HANGUP_COMPLETE); */ - } - else { - /* - * call connected, hangup - */ - gen->MesType = Q931mes_DISCONNECT; - - cause.Value = (unsigned char) caller_data->hangup_cause; - *cause.Diag = '\0'; - gen->Cause = Q931AppendIE(gen, (L3UCHAR *) &cause); - Q931Rx43(&isdn_data->q931, gen, gen->Size); - } - } - break; - case FTDM_CHANNEL_STATE_TERMINATING: - { - ftdm_log(FTDM_LOG_DEBUG, "Terminating: Call direction %s\n", - ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND) ? "Outbound" : "Inbound"); - - sig.event_id = FTDM_SIGEVENT_STOP; - status = ftdm_span_send_signal(span, &sig); - - gen->MesType = Q931mes_RELEASE; - Q931Rx43(&isdn_data->q931, gen, gen->Size); - } - default: - break; - } -} - -static __inline__ void check_state(ftdm_span_t *span) -{ - if (ftdm_test_flag(span, FTDM_SPAN_STATE_CHANGE)) { - uint32_t j; - - ftdm_clear_flag_locked(span, FTDM_SPAN_STATE_CHANGE); - - for (j = 1; j <= ftdm_span_get_chan_count(span); j++) { - ftdm_channel_t *chan = ftdm_span_get_channel(span, j); - - if (ftdm_test_flag(chan, FTDM_CHANNEL_STATE_CHANGE)) { - ftdm_channel_lock(chan); - ftdm_clear_flag(chan, FTDM_CHANNEL_STATE_CHANGE); - state_advance(chan); - ftdm_channel_unlock(chan); - } - } - } -} - - -static __inline__ ftdm_status_t process_event(ftdm_span_t *span, ftdm_event_t *event) -{ - ftdm_alarm_flag_t alarmbits; - ftdm_sigmsg_t sig; - - memset(&sig, 0, sizeof(sig)); - sig.span_id = ftdm_channel_get_span_id(event->channel); - sig.chan_id = ftdm_channel_get_id(event->channel); - sig.channel = event->channel; - - ftdm_log(FTDM_LOG_DEBUG, "EVENT [%s][%d:%d] STATE [%s]\n", - ftdm_oob_event2str(event->enum_id), - ftdm_channel_get_span_id(event->channel), - ftdm_channel_get_id(event->channel), - ftdm_channel_get_state_str(event->channel)); - - switch (event->enum_id) { - case FTDM_OOB_ALARM_TRAP: - { - sig.event_id = FTDM_OOB_ALARM_TRAP; - if (ftdm_channel_get_state(event->channel) != FTDM_CHANNEL_STATE_DOWN) { - ftdm_set_state_locked(event->channel, FTDM_CHANNEL_STATE_RESTART); - } - ftdm_set_flag(event->channel, FTDM_CHANNEL_SUSPENDED); - ftdm_channel_get_alarms(event->channel, &alarmbits); - ftdm_span_send_signal(span, &sig); - - ftdm_log(FTDM_LOG_WARNING, "channel %d:%d (%d:%d) has alarms [%s]\n", - ftdm_channel_get_span_id(event->channel), - ftdm_channel_get_id(event->channel), - ftdm_channel_get_ph_span_id(event->channel), - ftdm_channel_get_ph_id(event->channel), - ftdm_channel_get_last_error(event->channel)); - } - break; - case FTDM_OOB_ALARM_CLEAR: - { - sig.event_id = FTDM_OOB_ALARM_CLEAR; - ftdm_clear_flag(event->channel, FTDM_CHANNEL_SUSPENDED); - ftdm_channel_get_alarms(event->channel, &alarmbits); - ftdm_span_send_signal(span, &sig); - } - break; -#ifdef __BROKEN_BY_FREETDM_CONVERSION__ - case FTDM_OOB_DTMF: /* Taken from ozmod_analog, minus the CALLWAITING state handling */ - { - const char * digit_str = (const char *)event->data; - - if (digit_str) { - fio_event_cb_t event_callback = NULL; - - ftdm_channel_queue_dtmf(event->channel, digit_str); - if (span->event_callback) { - event_callback = span->event_callback; - } else if (event->channel->event_callback) { - event_callback = event->channel->event_callback; - } - - if (event_callback) { - event->channel->event_header.channel = event->channel; - event->channel->event_header.e_type = FTDM_EVENT_DTMF; - event->channel->event_header.data = (void *)digit_str; - event_callback(event->channel, &event->channel->event_header); - event->channel->event_header.e_type = FTDM_EVENT_NONE; - event->channel->event_header.data = NULL; - } - ftdm_safe_free(event->data); - } - } - break; -#endif - } - - return FTDM_SUCCESS; -} - - -static __inline__ void check_events(ftdm_span_t *span) -{ - ftdm_status_t status = ftdm_span_poll_event(span, 5, NULL); - - switch (status) { - case FTDM_SUCCESS: - { - ftdm_event_t *event; - - while (ftdm_span_next_event(span, &event) == FTDM_SUCCESS) { - if (event->enum_id == FTDM_OOB_NOOP) { - continue; - } - if (process_event(span, event) != FTDM_SUCCESS) { - break; - } - } - } - break; - case FTDM_FAIL: - { - ftdm_log(FTDM_LOG_DEBUG, "Event Failure! %d\n", ftdm_running()); - } - break; - default: - break; - } -} - - -static int teletone_handler(teletone_generation_session_t *ts, teletone_tone_map_t *map) -{ - ftdm_buffer_t *dt_buffer = ts->user_data; - int wrote; - - if (!dt_buffer) { - return -1; - } - - wrote = teletone_mux_tones(ts, map); - ftdm_buffer_write(dt_buffer, ts->buffer, wrote * 2); - return 0; -} - -static void *ftdm_isdn_tones_run(ftdm_thread_t *me, void *obj) -{ - ftdm_span_t *span = (ftdm_span_t *) obj; - ftdm_isdn_data_t *isdn_data = span->signal_data; - ftdm_buffer_t *dt_buffer = NULL; - teletone_generation_session_t ts = {{{{0}}}};; - unsigned char frame[1024]; - int x, interval; - - ftdm_log(FTDM_LOG_DEBUG, "ISDN tones thread starting.\n"); - ftdm_set_flag(isdn_data, FTDM_ISDN_TONES_RUNNING); - - if (ftdm_buffer_create(&dt_buffer, 1024, 1024, 0) != FTDM_SUCCESS) { - snprintf(isdn_data->dchan->last_error, sizeof(isdn_data->dchan->last_error), "memory error!"); - ftdm_log(FTDM_LOG_ERROR, "MEM ERROR\n"); - goto done; - } - ftdm_buffer_set_loops(dt_buffer, -1); - - /* get a tone generation friendly interval to avoid distortions */ - for (x = 1; x <= ftdm_span_get_chan_count(span); x++) { - ftdm_channel_t *chan = ftdm_span_get_channel(span, x); - - if (ftdm_channel_get_type(chan) != FTDM_CHAN_TYPE_DQ921) { - ftdm_channel_command(chan, FTDM_COMMAND_GET_INTERVAL, &interval); - break; - } - } - if (!interval) { - interval = 20; - } - ftdm_log(FTDM_LOG_NOTICE, "Tone generating interval %d\n", interval); - - /* init teletone */ - teletone_init_session(&ts, 0, teletone_handler, dt_buffer); - ts.rate = 8000; - ts.duration = ts.rate; - - /* main loop */ - while (ftdm_running() && ftdm_test_flag(isdn_data, FTDM_ISDN_RUNNING)) { - ftdm_wait_flag_t flags; - ftdm_status_t status; - int last_chan_state = 0; - int gated = 0; - L2ULONG now = ftdm_time_now(); - - /* - * check b-channel states and generate & send tones if neccessary - */ - for (x = 1; x <= ftdm_span_get_chan_count(span); x++) { - ftdm_channel_t *chan = ftdm_span_get_channel(span, x); - ftdm_size_t len = sizeof(frame), rlen; - ftdm_isdn_bchan_data_t *data = chan->call_data; - - if (ftdm_channel_get_type(chan) == FTDM_CHAN_TYPE_DQ921) { - continue; - } - - /* - * Generate tones based on current bchan state - * (Recycle buffer content if succeeding channels share the - * same state, this saves some cpu cycles) - */ - switch (ftdm_channel_get_state(chan)) { - case FTDM_CHANNEL_STATE_DIALTONE: - { - ftdm_caller_data_t *caller_data = ftdm_channel_get_caller_data(chan); - - /* check overlap dial timeout first before generating tone */ - if (data && data->digit_timeout && data->digit_timeout <= now) { - if (strlen(caller_data->dnis.digits) > 0) { - ftdm_log(FTDM_LOG_DEBUG, "Overlap dial timeout, advancing to RING state\n"); - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_RING); - } else { - /* no digits received, hangup */ - ftdm_log(FTDM_LOG_DEBUG, "Overlap dial timeout, no digits received, going to HANGUP state\n"); - caller_data->hangup_cause = FTDM_CAUSE_RECOVERY_ON_TIMER_EXPIRE; /* TODO: probably wrong cause value */ - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_HANGUP); - } - data->digit_timeout = 0; - continue; - } - - if (last_chan_state != ftdm_channel_get_state(chan)) { - ftdm_buffer_zero(dt_buffer); - teletone_run(&ts, span->tone_map[FTDM_TONEMAP_DIAL]); - last_chan_state = ftdm_channel_get_state(chan); - } - } - break; - - case FTDM_CHANNEL_STATE_RING: - { - if (last_chan_state != ftdm_channel_get_state(chan)) { - ftdm_buffer_zero(dt_buffer); - teletone_run(&ts, span->tone_map[FTDM_TONEMAP_RING]); - last_chan_state = ftdm_channel_get_state(chan); - } - } - break; - - default: /* Not in a tone generating state, go to next round */ - continue; - } - - if (!ftdm_test_flag(chan, FTDM_CHANNEL_OPEN)) { - if (ftdm_channel_open_chan(chan) != FTDM_SUCCESS) { - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_HANGUP); - continue; - } - ftdm_log(FTDM_LOG_NOTICE, "Successfully opened channel %d:%d\n", - ftdm_channel_get_span_id(chan), - ftdm_channel_get_id(chan)); - } - - flags = FTDM_READ; - - status = ftdm_channel_wait(chan, &flags, (gated) ? 0 : interval); - switch (status) { - case FTDM_FAIL: - continue; - - case FTDM_TIMEOUT: - gated = 1; - continue; - - default: - if (!(flags & FTDM_READ)) { - continue; - } - } - gated = 1; - - status = ftdm_channel_read(chan, frame, &len); - if (status != FTDM_SUCCESS || len <= 0) { - continue; - } - - /* - * Teletone operates on SLIN data (2 bytes per sample). - * Convert the length of non-SLIN codecs, so we read - * the right amount of samples from the buffer. - */ - if (chan->effective_codec != FTDM_CODEC_SLIN) { - len *= 2; - } - - /* seek to current offset */ - ftdm_buffer_seek(dt_buffer, data->offset); - - /* - * ftdm_channel_read() can read up to sizeof(frame) bytes - * (in certain situations). Avoid overflowing the stack (and smashing dt_buffer) - * if the codec is not slin and we had to double the length. - */ - len = ftdm_min(len, sizeof(frame)); - rlen = ftdm_buffer_read_loop(dt_buffer, frame, len); - - if (chan->effective_codec != FTDM_CODEC_SLIN) { - fio_codec_t codec_func = NULL; - - if (chan->native_codec == FTDM_CODEC_ULAW) { - codec_func = fio_slin2ulaw; - } else if (chan->native_codec == FTDM_CODEC_ALAW) { - codec_func = fio_slin2alaw; - } - - /* - * Convert SLIN to native format (a-law/u-law), - * input size is 2 bytes per sample, output size - * (after conversion) is one byte per sample - * (= max. half the input size). - */ - if (codec_func) { - status = codec_func(frame, sizeof(frame), &rlen); - } else { - snprintf(chan->last_error, sizeof(chan->last_error), "codec error!"); - goto done; - } - } - - if (ftdm_channel_write(chan, frame, sizeof(frame), &rlen) == FTDM_SUCCESS) { - /* - * Advance offset in teletone buffer by amount - * of data actually written to channel. - */ - if (chan->effective_codec != FTDM_CODEC_SLIN) { - data->offset += rlen << 1; /* Teletone buffer is in SLIN (= rlen * 2) */ - } else { - data->offset += rlen; - } - - /* Limit offset to [0..Rate(Samples/s)-1] in SLIN (2 bytes per sample) units. */ - data->offset %= (ts.rate << 1); - } - } - - /* - * sleep a bit if there was nothing to do - */ - if (!gated) { - ftdm_sleep(interval); - } - } - -done: - if (ts.buffer) { - teletone_destroy_session(&ts); - } - - if (dt_buffer) { - ftdm_buffer_destroy(&dt_buffer); - } - - ftdm_log(FTDM_LOG_DEBUG, "ISDN tone thread ended.\n"); - ftdm_clear_flag(isdn_data, FTDM_ISDN_TONES_RUNNING); - - return NULL; -} - -static void *ftdm_isdn_run(ftdm_thread_t *me, void *obj) -{ - ftdm_span_t *span = (ftdm_span_t *) obj; - ftdm_isdn_data_t *isdn_data = span->signal_data; - unsigned char frame[1024]; - ftdm_size_t len = sizeof(frame); - int errs = 0; - -#ifdef WIN32 - timeBeginPeriod(1); -#endif - - ftdm_log(FTDM_LOG_DEBUG, "ISDN thread starting.\n"); - ftdm_set_flag(isdn_data, FTDM_ISDN_RUNNING); - - Q921Start(&isdn_data->q921); - Q931Start(&isdn_data->q931); - - while (ftdm_running() && ftdm_test_flag(isdn_data, FTDM_ISDN_RUNNING)) { - ftdm_wait_flag_t flags = FTDM_READ; - ftdm_status_t status = ftdm_channel_wait(isdn_data->dchan, &flags, 100); - - Q921TimerTick(&isdn_data->q921); - Q931TimerTick(&isdn_data->q931); - check_state(span); - check_events(span); - - /* - * - */ - switch (status) { - case FTDM_FAIL: - { - ftdm_log(FTDM_LOG_ERROR, "D-Chan Read Error!\n"); - snprintf(span->last_error, sizeof(span->last_error), "D-Chan Read Error!"); - if (++errs == 10) { - isdn_data->dchan->state = FTDM_CHANNEL_STATE_UP; - goto done; - } - } - break; - case FTDM_TIMEOUT: - { - errs = 0; - } - break; - default: - { - if (flags & FTDM_READ) { - len = sizeof(frame); - if (ftdm_channel_read(isdn_data->dchan, frame, &len) != FTDM_SUCCESS) { - ftdm_log_chan_msg(isdn_data->dchan, FTDM_LOG_ERROR, "Failed to read from D-Channel\n"); - continue; - } - if (len > 0) { -#ifdef HAVE_PCAP - if (isdn_pcap_capture_both(isdn_data)) { - isdn_pcap_write(isdn_data, frame, len, ISDN_PCAP_INCOMING); - } -#endif - Q921QueueHDLCFrame(&isdn_data->q921, frame, (int)len); - Q921Rx12(&isdn_data->q921); - - /* Successful read, reset error counter */ - errs = 0; - } - } else { - ftdm_log(FTDM_LOG_DEBUG, "No Read FLAG!\n"); - } - } - break; - } - } - -done: - ftdm_channel_close(&isdn_data->dchan); - ftdm_clear_flag(isdn_data, FTDM_ISDN_RUNNING); - -#ifdef WIN32 - timeEndPeriod(1); -#endif -#ifdef HAVE_PCAP - if (isdn_pcap_is_open(isdn_data)) { - isdn_pcap_close(isdn_data); - } -#endif - ftdm_log(FTDM_LOG_DEBUG, "ISDN thread ended.\n"); - return NULL; -} - -static int q931_rx_32(void *pvt, Q921DLMsg_t ind, L3UCHAR tei, L3UCHAR *msg, L3INT mlen) -{ - ftdm_span_t *span = pvt; - ftdm_isdn_data_t *isdn_data = span->signal_data; - int offset = 4; - char bb[4096] = ""; - - switch(ind) { - case Q921_DL_UNIT_DATA: - offset = 3; - - case Q921_DL_DATA: - print_hex_bytes(msg + offset, mlen - offset, bb, sizeof(bb)); - ftdm_log(FTDM_LOG_DEBUG, "WRITE %d\n%s\n%s\n\n", (int)mlen - offset, LINE, bb); - break; - - default: - break; - } - -#ifdef HAVE_PCAP - if (isdn_pcap_capture_l3only(isdn_data)) { - isdn_pcap_write(isdn_data, msg, mlen, ISDN_PCAP_OUTGOING); - } -#endif - return Q921Rx32(&isdn_data->q921, ind, tei, msg, mlen); -} - -static int ftdm_isdn_q921_log(void *pvt, Q921LogLevel_t level, char *msg, L2INT size) -{ - ftdm_span_t *span = (ftdm_span_t *) pvt; - - ftdm_log("Span", "Q.921", span->span_id, (int)level, "%s", msg); - return 0; -} - -static L3INT ftdm_isdn_q931_log(void *pvt, Q931LogLevel_t level, const char *msg, L3INT size) -{ - ftdm_span_t *span = (ftdm_span_t *) pvt; - - ftdm_log("Span", "Q.931", span->span_id, (int)level, "%s", msg); - return 0; -} - -static ftdm_state_map_t isdn_state_map = { - { - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_ANY}, - {FTDM_CHANNEL_STATE_RESTART, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_RESTART, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_DIALING, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_DIALING, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP_COMPLETE, FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_HANGUP_COMPLETE, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END}, - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_END} - }, - - /****************************************/ - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_ANY}, - {FTDM_CHANNEL_STATE_RESTART, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_RESTART, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_DIALTONE, FTDM_CHANNEL_STATE_RING, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_DIALTONE, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_RING, FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_RING, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP_COMPLETE, FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END}, - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_HANGUP_COMPLETE, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END}, - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, - FTDM_CHANNEL_STATE_CANCEL, FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END}, - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_END}, - }, - } -}; - -/** - * \brief Stop signalling on span - */ -static ftdm_status_t ftdm_isdn_stop(ftdm_span_t *span) -{ - ftdm_isdn_data_t *isdn_data = span->signal_data; - - if (!ftdm_test_flag(isdn_data, FTDM_ISDN_RUNNING)) { - return FTDM_FAIL; - } - - ftdm_set_flag(isdn_data, FTDM_ISDN_STOP); - - while (ftdm_test_flag(isdn_data, FTDM_ISDN_RUNNING)) { - ftdm_sleep(100); - } - - while (ftdm_test_flag(isdn_data, FTDM_ISDN_TONES_RUNNING)) { - ftdm_sleep(100); - } - - return FTDM_SUCCESS; -} - -/** - * \brief Start signalling on span - */ -static ftdm_status_t ftdm_isdn_start(ftdm_span_t *span) -{ - ftdm_isdn_data_t *isdn_data = span->signal_data; - ftdm_status_t ret; - - if (ftdm_test_flag(isdn_data, FTDM_ISDN_RUNNING)) { - return FTDM_FAIL; - } - - ftdm_clear_flag(isdn_data, FTDM_ISDN_STOP); - ret = ftdm_thread_create_detached(ftdm_isdn_run, span); - - if (ret != FTDM_SUCCESS) { - return ret; - } - - if (FTDM_SPAN_IS_NT(span) && !(isdn_data->opts & FTDM_ISDN_OPT_DISABLE_TONES)) { - ret = ftdm_thread_create_detached(ftdm_isdn_tones_run, span); - } - return ret; -} - - -/*###################################################################* - * (text) value parsing / translation - *###################################################################*/ - -static int32_t parse_loglevel(const char *level) -{ - if (!level) - return -1; - - if (!strcasecmp(level, "debug")) { - return FTDM_LOG_LEVEL_DEBUG; - } else if (!strcasecmp(level, "info")) { - return FTDM_LOG_LEVEL_INFO; - } else if (!strcasecmp(level, "notice")) { - return FTDM_LOG_LEVEL_NOTICE; - } else if (!strcasecmp(level, "warning")) { - return FTDM_LOG_LEVEL_WARNING; - } else if (!strcasecmp(level, "error")) { - return FTDM_LOG_LEVEL_ERROR; - } else if (!strcasecmp(level, "alert")) { - return FTDM_LOG_LEVEL_ALERT; - } else if (!strcasecmp(level, "crit")) { - return FTDM_LOG_LEVEL_CRIT; - } else if (!strcasecmp(level, "emerg")) { - return FTDM_LOG_LEVEL_EMERG; - } else { - return -1; - } -} - -static int parse_opts(const char *in, uint32_t *flags) -{ - if (!in || !flags) - return -1; - - if (strstr(in, "suggest_channel")) { - *flags |= FTDM_ISDN_OPT_SUGGEST_CHANNEL; - } - if (strstr(in, "omit_display")) { - *flags |= FTDM_ISDN_OPT_OMIT_DISPLAY_IE; - } - if (strstr(in, "disable_tones")) { - *flags |= FTDM_ISDN_OPT_DISABLE_TONES; - } - - return 0; -} - -static int parse_dialect(const char *in, uint32_t *dialect) -{ - if (!in || !dialect) - return -1; - -#if __UNSUPPORTED__ - if (!strcasecmp(in, "national")) { - *dialect = Q931_Dialect_National; - return 0; - } - if (!strcasecmp(in, "dms")) { - *dialect = Q931_Dialect_DMS; - return 0; - } -#endif - if (!strcasecmp(in, "5ess")) { - *dialect = Q931_Dialect_5ESS; - return 0; - } - if (!strcasecmp(in, "dss1") || !strcasecmp(in, "euroisdn")) { - *dialect = Q931_Dialect_DSS1; - return 0; - } - if (!strcasecmp(in, "q931")) { - *dialect = Q931_Dialect_Q931; - return 0; - } - - return -1; -} - - -/*###################################################################* - * API commands - *###################################################################*/ - -static const char isdn_api_usage[] = -#ifdef HAVE_PCAP - "isdn capture [q931only]\n" - "isdn capture \n" -#endif - "isdn loglevel \n" - "isdn dump calls\n" - "isdn help"; - - -/** - * isdn_api - */ -static FIO_API_FUNCTION(isdn_api) -{ - char *mycmd = NULL, *argv[10] = { 0 }; - int argc = 0; - - if (data) { - mycmd = strdup(data); - argc = ftdm_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); - } - - if (!argc || !strcasecmp(argv[0], "help")) { - stream->write_function(stream, "%s\n", isdn_api_usage); - goto done; - } - else if (!strcasecmp(argv[0], "dump")) { - ftdm_isdn_data_t *isdn_data = NULL; - ftdm_span_t *span = NULL; - int span_id = 0; - - /* dump calls */ - - if (argc < 3) { - stream->write_function(stream, "-ERR not enough arguments.\n"); - goto done; - } - - span_id = atoi(argv[1]); - - if (ftdm_span_find_by_name(argv[1], &span) == FTDM_SUCCESS || ftdm_span_find(span_id, &span) == FTDM_SUCCESS) { - isdn_data = span->signal_data; - } else { - stream->write_function(stream, "-ERR invalid span.\n"); - goto done; - } - - if (!strcasecmp(argv[2], "calls")) { - /* dump all calls to log */ - Q931DumpAllCalls(&isdn_data->q931); - stream->write_function(stream, "+OK call information dumped to log\n"); - goto done; - } - } - else if (!strcasecmp(argv[0], "loglevel")) { - ftdm_isdn_data_t *isdn_data = NULL; - ftdm_span_t *span = NULL; - int span_id = 0; - int layer = 0; - int level = 0; - - /* loglevel [level] */ - - if (argc < 3) { - stream->write_function(stream, "-ERR not enough arguments.\n"); - goto done; - } - - span_id = atoi(argv[1]); - - if (ftdm_span_find_by_name(argv[1], &span) == FTDM_SUCCESS || ftdm_span_find(span_id, &span) == FTDM_SUCCESS) { - isdn_data = span->signal_data; - } else { - stream->write_function(stream, "-ERR invalid span.\n"); - goto done; - } - - if (!strcasecmp(argv[2], "q921")) { - layer = 0x01; - } else if (!strcasecmp(argv[2], "q931")) { - layer = 0x02; - } else if (!strcasecmp(argv[2], "all")) { - layer = 0x03; - } else { - stream->write_function(stream, "-ERR invalid layer\n"); - goto done; - } - - if (argc > 3) { - /* set loglevel */ - if ((level = parse_loglevel(argv[3])) < 0) { - stream->write_function(stream, "-ERR invalid loglevel\n"); - goto done; - } - - if (layer & 0x01) { /* q921 */ - Q921SetLogLevel(&isdn_data->q921, (Q921LogLevel_t)level); - } - if (layer & 0x02) { /* q931 */ - Q931SetLogLevel(&isdn_data->q931, (Q931LogLevel_t)level); - } - stream->write_function(stream, "+OK loglevel set"); - } else { - /* get loglevel */ - if (layer & 0x01) { - stream->write_function(stream, "Q.921 loglevel: %s\n", - Q921GetLogLevelName(&isdn_data->q921)); - } - if (layer & 0x02) { - stream->write_function(stream, "Q.931 loglevel: %s\n", - Q931GetLogLevelName(&isdn_data->q931)); - } - stream->write_function(stream, "+OK"); - } - goto done; - } -#ifdef HAVE_PCAP - else if (!strcasecmp(argv[0], "capture")) { - ftdm_isdn_data_t *isdn_data = NULL; - ftdm_span_t *span = NULL; - int span_id = 0; - - /* capture [q931only] */ - /* capture */ - - if (argc < 3) { - stream->write_function(stream, "-ERR not enough arguments.\n"); - goto done; - } - - span_id = atoi(argv[1]); - - if (ftdm_span_find_by_name(argv[1], &span) == FTDM_SUCCESS || ftdm_span_find(span_id, &span) == FTDM_SUCCESS) { - isdn_data = span->signal_data; - } else { - stream->write_function(stream, "-ERR invalid span.\n"); - goto done; - } - - if (!strcasecmp(argv[2], "start")) { - char *filename = NULL; - - if (argc < 4) { - stream->write_function(stream, "-ERR not enough parameters.\n"); - goto done; - } - - if (isdn_pcap_is_open(isdn_data)) { - stream->write_function(stream, "-ERR capture is already running.\n"); - goto done; - } - - filename = argv[3]; - - if (isdn_pcap_open(isdn_data, filename) != FTDM_SUCCESS) { - stream->write_function(stream, "-ERR failed to open capture file.\n"); - goto done; - } - - if (argc > 4 && !strcasecmp(argv[4], "q931only")) { - isdn_data->flags |= FTDM_ISDN_CAPTURE_L3ONLY; - } - isdn_pcap_start(isdn_data); - - stream->write_function(stream, "+OK capture started.\n"); - goto done; - } - else if (!strcasecmp(argv[2], "stop")) { - - if (!isdn_pcap_is_open(isdn_data)) { - stream->write_function(stream, "-ERR capture is not running.\n"); - goto done; - } - - isdn_pcap_stop(isdn_data); - isdn_pcap_close(isdn_data); - - stream->write_function(stream, "+OK capture stopped.\n"); - goto done; - } - else if (!strcasecmp(argv[2], "suspend")) { - - if (!isdn_pcap_is_open(isdn_data)) { - stream->write_function(stream, "-ERR capture is not running.\n"); - goto done; - } - isdn_pcap_stop(isdn_data); - - stream->write_function(stream, "+OK capture suspended.\n"); - goto done; - } - else if (!strcasecmp(argv[2], "resume")) { - - if (!isdn_pcap_is_open(isdn_data)) { - stream->write_function(stream, "-ERR capture is not running.\n"); - goto done; - } - isdn_pcap_start(isdn_data); - - stream->write_function(stream, "+OK capture resumed.\n"); - goto done; - } - else { - stream->write_function(stream, "-ERR wrong action.\n"); - goto done; - } - } -#endif - else { - stream->write_function(stream, "-ERR invalid command.\n"); - } -done: - ftdm_safe_free(mycmd); - - return FTDM_SUCCESS; -} - -static int parse_mode(const char *mode) -{ - if (!mode) - return -1; - - if (!strcasecmp(mode, "user") || !strcasecmp(mode, "cpe")) { - return Q931_TE; - } - if (!strcasecmp(mode, "net") || !strcasecmp(mode, "network")) { - return Q931_NT; - } - - return -1; -} - -static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(isdn_configure_span) -{ - Q931Dialect_t dialect = Q931_Dialect_National; - ftdm_channel_t *dchan = NULL; - ftdm_isdn_data_t *isdn_data; - int32_t digit_timeout = 0; - const char *tonemap = "us"; - int dchan_count = 0, bchan_count = 0; - int q921loglevel = -1; - int q931loglevel = -1; - uint32_t i; - - if (span->signal_type) { - ftdm_log(FTDM_LOG_ERROR, "Span is already configured for signalling [%d]\n", span->signal_type); - snprintf(span->last_error, sizeof(span->last_error), "Span is already configured for signalling [%d]", span->signal_type); - return FTDM_FAIL; - } - - if (ftdm_span_get_trunk_type(span) >= FTDM_TRUNK_NONE) { - ftdm_log(FTDM_LOG_WARNING, "Invalid trunk type '%s' defaulting to T1\n", ftdm_span_get_trunk_type_str(span)); - span->trunk_type = FTDM_TRUNK_T1; - } - - for (i = 1; i <= ftdm_span_get_chan_count(span); i++) { - ftdm_channel_t *chan = ftdm_span_get_channel(span, i); - - switch (ftdm_channel_get_type(chan)) { - case FTDM_CHAN_TYPE_DQ921: - if (dchan_count > 1) { - ftdm_log(FTDM_LOG_ERROR, "Span has more than 1 D-Channel!\n"); - snprintf(span->last_error, sizeof(span->last_error), "Span has more than 1 D-Channel!"); - return FTDM_FAIL; - } - - if (ftdm_channel_open(ftdm_span_get_id(span), i, &dchan) == FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_DEBUG, "opening d-channel #%d %d:%d\n", dchan_count, - ftdm_channel_get_span_id(dchan), ftdm_channel_get_id(dchan)); - dchan->state = FTDM_CHANNEL_STATE_UP; - } - - dchan_count++; - break; - - case FTDM_CHAN_TYPE_B: - bchan_count++; - break; - - default: - break; - } - } - if (!dchan_count) { - ftdm_log(FTDM_LOG_ERROR, "Span has no D-Channel!\n"); - snprintf(span->last_error, sizeof(span->last_error), "Span has no D-Channel!"); - return FTDM_FAIL; - } - if (!bchan_count) { - ftdm_log(FTDM_LOG_ERROR, "Span has no B-Channels!\n"); - snprintf(span->last_error, sizeof(span->last_error), "Span has no B-Channels!"); - return FTDM_FAIL; - } - - isdn_data = malloc(sizeof(*isdn_data)); - assert(isdn_data != NULL); - - memset(isdn_data, 0, sizeof(*isdn_data)); - dialect = Q931_Dialect_Q931; - - /* Use trunk_mode span parameter to set default */ - switch (ftdm_span_get_trunk_mode(span)) { - case FTDM_TRUNK_MODE_NET: - ftdm_log(FTDM_LOG_INFO, "Span '%s' [s%d] defaulting to NET mode\n", - ftdm_span_get_name(span), ftdm_span_get_id(span)); - isdn_data->mode = Q931_NT; - break; - default: - ftdm_log(FTDM_LOG_INFO, "Span '%s' [s%d] defaulting to USER mode\n", - ftdm_span_get_name(span), ftdm_span_get_id(span)); - isdn_data->mode = Q931_TE; - break; - } - - for (i = 0; ftdm_parameters[i].var; i++) { - const char *var = ftdm_parameters[i].var; - const char *val = ftdm_parameters[i].val; - - if (ftdm_strlen_zero(var)) { - ftdm_log(FTDM_LOG_WARNING, "Skipping variable with no name\n"); - continue; - } - - if (ftdm_strlen_zero(val)) { - ftdm_log(FTDM_LOG_ERROR, "Variable '%s' has no value\n", var); - return FTDM_FAIL; - } - - if (!strcasecmp(var, "mode")) { - if ((isdn_data->mode = parse_mode(val)) < 0) { - ftdm_log(FTDM_LOG_ERROR, "Invalid/unknown mode '%s'\n", val); - snprintf(span->last_error, sizeof(span->last_error), "Invalid/unknown mode [%s]!", val); - return FTDM_FAIL; - } - } else if (!strcasecmp(var, "dialect")) { - if (parse_dialect(val, &dialect) < 0) { - ftdm_log(FTDM_LOG_ERROR, "Invalid/unknown dialect '%s'\n", val); - snprintf(span->last_error, sizeof(span->last_error), "Invalid/unknown dialect [%s]!", val); - return FTDM_FAIL; - } - } else if (!strcasecmp(var, "opts")) { - if (parse_opts(val, &isdn_data->opts) < 0) { - ftdm_log(FTDM_LOG_ERROR, "Invalid/unknown options '%s'\n", val); - snprintf(span->last_error, sizeof(span->last_error), "Invalid/unknown options [%s]!", val); - return FTDM_FAIL; - } - } else if (!strcasecmp(var, "tonemap")) { - tonemap = (const char *)val; - } else if (!strcasecmp(var, "digit_timeout")) { - digit_timeout = atoi(val); - if (digit_timeout < 3000 || digit_timeout > 30000) { - ftdm_log(FTDM_LOG_WARNING, "Digit timeout %d ms outside of range (3000 - 30000 ms), using default (10000 ms)\n", digit_timeout); - digit_timeout = DEFAULT_DIGIT_TIMEOUT; - } - } else if (!strcasecmp(var, "q921loglevel")) { - if ((q921loglevel = parse_loglevel(val)) < 0) { - ftdm_log(FTDM_LOG_ERROR, "Invalid/unknown loglevel '%s'\n", val); - snprintf(span->last_error, sizeof(span->last_error), "Invalid/unknown loglevel [%s]!", val); - return FTDM_FAIL; - } - } else if (!strcasecmp(var, "q931loglevel")) { - if ((q931loglevel = parse_loglevel(val)) < 0) { - ftdm_log(FTDM_LOG_ERROR, "Invalid/unknown loglevel '%s'\n", val); - snprintf(span->last_error, sizeof(span->last_error), "Invalid/unknown loglevel [%s]!", val); - return FTDM_FAIL; - } - } else { - ftdm_log(FTDM_LOG_ERROR, "Unknown parameter '%s'\n", var); - snprintf(span->last_error, sizeof(span->last_error), "Unknown parameter [%s]", var); - return FTDM_FAIL; - } - } - - if (!digit_timeout) { - digit_timeout = DEFAULT_DIGIT_TIMEOUT; - } - - /* Check if modes match and log a message if they do not. Just to be on the safe side. */ - if (isdn_data->mode == Q931_TE && ftdm_span_get_trunk_mode(span) == FTDM_TRUNK_MODE_NET) { - ftdm_log(FTDM_LOG_WARNING, "Span '%s' signalling set up for TE/CPE/USER mode, while port is running in NT/NET mode. You may want to check your 'trunk_mode' settings.\n", - ftdm_span_get_name(span)); - } - else if (isdn_data->mode == Q931_NT && ftdm_span_get_trunk_mode(span) == FTDM_TRUNK_MODE_CPE) { - ftdm_log(FTDM_LOG_WARNING, "Span '%s' signalling set up for NT/NET mode, while port is running in TE/CPE/USER mode. You may want to check your 'trunk_mode' settings.\n", - ftdm_span_get_name(span)); - } - - /* allocate per b-chan data */ - if (isdn_data->mode == Q931_NT) { - ftdm_isdn_bchan_data_t *data; - - data = malloc(bchan_count * sizeof(ftdm_isdn_bchan_data_t)); - if (!data) { - return FTDM_FAIL; - } - - for (i = 1; i <= ftdm_span_get_chan_count(span); i++, data++) { - ftdm_channel_t *chan = ftdm_span_get_channel(span, i); - - if (ftdm_channel_get_type(chan) == FTDM_CHAN_TYPE_B) { - chan->call_data = data; - memset(data, 0, sizeof(ftdm_isdn_bchan_data_t)); - } - } - } - - isdn_data->dchan = dchan; - isdn_data->digit_timeout = digit_timeout; - - Q921_InitTrunk(&isdn_data->q921, - 0, - 0, - isdn_data->mode, - (ftdm_span_get_trunk_type(span) == FTDM_TRUNK_BRI_PTMP) ? Q921_PTMP : Q921_PTP, - 0, - ftdm_isdn_921_21, - (Q921Tx23CB_t)ftdm_isdn_921_23, - span, - span); - - Q921SetLogCB(&isdn_data->q921, &ftdm_isdn_q921_log, span); - Q921SetLogLevel(&isdn_data->q921, (Q921LogLevel_t)q921loglevel); - - Q931InitTrunk(&isdn_data->q931, - dialect, - isdn_data->mode, - span->trunk_type, - ftdm_isdn_931_34, - (Q931Tx32CB_t)q931_rx_32, - ftdm_isdn_931_err, - span, - span); - - Q931SetLogCB(&isdn_data->q931, &ftdm_isdn_q931_log, span); - Q931SetLogLevel(&isdn_data->q931, (Q931LogLevel_t)q931loglevel); - - /* Register new event hander CB */ - Q931SetCallEventCB(&isdn_data->q931, ftdm_isdn_call_event, span); - - /* TODO: hmm, maybe drop the "Trunk" prefix */ - Q931TrunkSetAutoRestartAck(&isdn_data->q931, 1); - Q931TrunkSetAutoConnectAck(&isdn_data->q931, 1); - Q931TrunkSetAutoServiceAck(&isdn_data->q931, 1); - Q931TrunkSetStatusEnquiry(&isdn_data->q931, 0); - - span->state_map = &isdn_state_map; - span->signal_data = isdn_data; - span->signal_type = FTDM_SIGTYPE_ISDN; - span->signal_cb = sig_cb; - span->start = ftdm_isdn_start; - span->stop = ftdm_isdn_stop; - span->outgoing_call = isdn_outgoing_call; - - span->get_channel_sig_status = isdn_get_channel_sig_status; - span->get_span_sig_status = isdn_get_span_sig_status; - -#ifdef __TODO__ - if ((isdn_data->opts & FTDM_ISDN_OPT_SUGGEST_CHANNEL)) { - span->channel_request = isdn_channel_request; - span->flags |= FTDM_SPAN_SUGGEST_CHAN_ID; - } -#endif - ftdm_span_load_tones(span, tonemap); - - return FTDM_SUCCESS; -} - -/** - * ISDN module io interface - * \note This is really ugly... - */ -static ftdm_io_interface_t isdn_interface = { - .name = "isdn", - .api = isdn_api -}; - -/** - * \brief ISDN module io interface init callback - */ -static FIO_IO_LOAD_FUNCTION(isdn_io_load) -{ - assert(fio != NULL); - - *fio = &isdn_interface; - - return FTDM_SUCCESS; -} - -/** - * \brief ISDN module load callback - */ -static FIO_SIG_LOAD_FUNCTION(isdn_load) -{ - Q931Initialize(); - - Q921SetGetTimeCB(ftdm_time_now); - Q931SetGetTimeCB(ftdm_time_now); - - return FTDM_SUCCESS; -} - -/** - * \brief ISDN module shutdown callback - */ -static FIO_SIG_UNLOAD_FUNCTION(isdn_unload) -{ - return FTDM_SUCCESS; -}; - -ftdm_module_t ftdm_module = { - .name = "isdn", - .io_load = isdn_io_load, - .io_unload = NULL, - .sig_load = isdn_load, - .sig_unload = isdn_unload, - .configure_span_signaling = isdn_configure_span -}; - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet expandtab: - */ diff --git a/libs/freetdm/src/ftmod/ftmod_isdn/ftmod_isdn.h b/libs/freetdm/src/ftmod/ftmod_isdn/ftmod_isdn.h deleted file mode 100644 index 378f901320..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_isdn/ftmod_isdn.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2007-2014, Anthony Minessale II - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef FTDM_ISDN_H -#define FTDM_ISDN_H - -#define DEFAULT_DIGIT_TIMEOUT 10000 /* default overlap timeout: 10 seconds */ - - -typedef enum { - FTDM_ISDN_OPT_NONE = 0, - FTDM_ISDN_OPT_SUGGEST_CHANNEL = (1 << 0), - FTDM_ISDN_OPT_OMIT_DISPLAY_IE = (1 << 1), /*!< Do not send Caller name in outgoing SETUP message (= Display IE) */ - FTDM_ISDN_OPT_DISABLE_TONES = (1 << 2), /*!< Disable tone generating thread (NT mode) */ - - FTDM_ISDN_OPT_MAX = (2 << 0) -} ftdm_isdn_opts_t; - -typedef enum { - FTDM_ISDN_RUNNING = (1 << 0), - FTDM_ISDN_TONES_RUNNING = (1 << 1), - FTDM_ISDN_STOP = (1 << 2), - - FTDM_ISDN_CAPTURE = (1 << 3), - FTDM_ISDN_CAPTURE_L3ONLY = (1 << 4) -} ftdm_isdn_flag_t; - -#ifdef HAVE_PCAP -struct pcap_context; -#endif - -struct ftdm_isdn_data { - Q921Data_t q921; - Q931_TrunkInfo_t q931; - ftdm_channel_t *dchan; - uint32_t flags; - int32_t mode; - int32_t digit_timeout; - ftdm_isdn_opts_t opts; -#ifdef HAVE_PCAP - struct pcap_context *pcap; -#endif -}; - -typedef struct ftdm_isdn_data ftdm_isdn_data_t; - - -/* b-channel private data */ -struct ftdm_isdn_bchan_data -{ - ftdm_time_t digit_timeout; - int offset; /* offset in teletone buffer */ -}; - -typedef struct ftdm_isdn_bchan_data ftdm_isdn_bchan_data_t; - - -#endif - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet expandtab: - */ - diff --git a/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.c b/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.c deleted file mode 100644 index 03f2fc3c8b..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.c +++ /dev/null @@ -1,3248 +0,0 @@ -/* - * Copyright (c) 2007-2014, Anthony Minessale II - * Copyright (c) 2010, Stefan Knoblich - * Copyright (c) 2012-2013, Stefan Knoblich - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "private/ftdm_core.h" -#include "ftmod_libpri.h" - - -static ftdm_status_t ftdm_libpri_start(ftdm_span_t *span); -static ftdm_io_interface_t ftdm_libpri_interface; - -static int on_timeout_t302(struct lpwrap_pri *spri, struct lpwrap_timer *timer); -static int on_timeout_t316(struct lpwrap_pri *spri, struct lpwrap_timer *timer); -static int on_timeout_t3xx(struct lpwrap_pri *spri, struct lpwrap_timer *timer); - - -static void _ftdm_channel_set_state_force(ftdm_channel_t *chan, const ftdm_channel_state_t state) -{ - assert(chan); - chan->state = state; -} - -/** - * \brief Unloads libpri IO module - * \return Success - */ -static FIO_IO_UNLOAD_FUNCTION(ftdm_libpri_unload) -{ - return FTDM_SUCCESS; -} - -/** - * \brief Returns the signalling status on a channel - * \param ftdmchan Channel to get status on - * \param status Pointer to set signalling status - * \return Success or failure - */ - -static FIO_CHANNEL_GET_SIG_STATUS_FUNCTION(isdn_get_channel_sig_status) -{ - *status = FTDM_SIG_STATE_DOWN; - - ftdm_libpri_data_t *isdn_data = ftdmchan->span->signal_data; - if (ftdm_test_flag(&(isdn_data->spri), LPWRAP_PRI_READY)) { - *status = FTDM_SIG_STATE_UP; - } - return FTDM_SUCCESS; -} - -/** - * \brief Returns the signalling status on a span - * \param span Span to get status on - * \param status Pointer to set signalling status - * \return Success or failure - */ - -static FIO_SPAN_GET_SIG_STATUS_FUNCTION(isdn_get_span_sig_status) -{ - *status = FTDM_SIG_STATE_DOWN; - - ftdm_libpri_data_t *isdn_data = span->signal_data; - if (ftdm_test_flag(&(isdn_data->spri), LPWRAP_PRI_READY)) { - *status = FTDM_SIG_STATE_UP; - } - return FTDM_SUCCESS; -} - - -/** - * \brief Starts a libpri channel (outgoing call) - * \param ftdmchan Channel to initiate call on - * \return Success or failure - */ -static FIO_CHANNEL_OUTGOING_CALL_FUNCTION(isdn_outgoing_call) -{ - ftdm_unused_arg(ftdmchan); - return FTDM_SUCCESS; -} - -/** - * \brief Requests an libpri channel on a span (outgoing call) - * \param span Span where to get a channel (unused) - * \param chan_id Specific channel to get (0 for any) (unused) - * \param direction Call direction (unused) - * \param caller_data Caller information (unused) - * \param ftdmchan Channel to initialise (unused) - * \return Failure - */ -static FIO_CHANNEL_REQUEST_FUNCTION(isdn_channel_request) -{ - ftdm_unused_arg(span); - ftdm_unused_arg(chan_id); - ftdm_unused_arg(direction); - ftdm_unused_arg(caller_data); - ftdm_unused_arg(ftdmchan); - return FTDM_FAIL; -} - - -/** - * \brief Logs a libpri message - * \param pri libpri structure - * \param s Message string - */ -static void s_pri_message(struct pri *pri, char *s) -{ - struct lpwrap_pri *spri = pri_get_userdata(pri); - - if (spri && spri->dchan) { - ftdm_log_chan(spri->dchan, FTDM_LOG_DEBUG, "%s", s); - } else { - ftdm_log(FTDM_LOG_DEBUG, "%s", s); - } -} - -/** - * \brief Logs a libpri error - * \param pri libpri structure - * \param s Error string - */ -static void s_pri_error(struct pri *pri, char *s) -{ - struct lpwrap_pri *spri = pri_get_userdata(pri); - - if (spri && spri->dchan) { - ftdm_log_chan(spri->dchan, FTDM_LOG_ERROR, "%s", s); - } else { - ftdm_log(FTDM_LOG_ERROR, "%s", s); - } -} - - -#define PRI_DEBUG_Q921_ALL (PRI_DEBUG_Q921_RAW | PRI_DEBUG_Q921_DUMP | PRI_DEBUG_Q921_STATE) -#define PRI_DEBUG_Q931_ALL (PRI_DEBUG_Q931_DUMP | PRI_DEBUG_Q931_STATE | PRI_DEBUG_Q931_ANOMALY) - -static const struct ftdm_libpri_debug { - const char *name; - const int flags; -} ftdm_libpri_debug[] = { - /* NOTE: order is important for print_debug() */ - { "q921_all", PRI_DEBUG_Q921_ALL }, - { "q921_raw", PRI_DEBUG_Q921_RAW }, - { "q921_dump", PRI_DEBUG_Q921_DUMP }, - { "q921_state", PRI_DEBUG_Q921_STATE }, - - { "q931_all", PRI_DEBUG_Q931_ALL }, - { "q931_dump", PRI_DEBUG_Q931_DUMP }, - { "q931_state", PRI_DEBUG_Q931_STATE }, - { "q931_anomaly", PRI_DEBUG_Q931_ANOMALY }, - - { "config", PRI_DEBUG_CONFIG }, - { "apdu", PRI_DEBUG_APDU }, - { "aoc", PRI_DEBUG_AOC } -}; - -/** - * \brief Parses a debug string to flags - * \param in Debug string to parse for - * \return Flags or -1 if nothing matched - */ -static int parse_debug(const char *in, uint32_t *flags) -{ - int res = -1; - int i; - - if (!in || !flags) - return -1; - - if (!strcmp(in, "all")) { - *flags = PRI_DEBUG_ALL; - return 0; - } - if (strstr(in, "none")) { - *flags = 0; - return 0; - } - - for (i = 0; i < ftdm_array_len(ftdm_libpri_debug); i++) { - if (strstr(in, ftdm_libpri_debug[i].name)) { - *flags |= ftdm_libpri_debug[i].flags; - res = 0; - } - } - return res; -} - -#ifdef HAVE_LIBPRI_MAINT_SERVICE -/** - * \brief Parses a change status string to flags - * \param in change status string to parse for - * \return Flags - */ -static int parse_change_status(const char *in) -{ - int flags = 0; - if (!in) { - return 0; - } - - if (strstr(in, "in_service") || strstr(in, "in")) { - flags = SERVICE_CHANGE_STATUS_INSERVICE; - } - if (strstr(in, "maintenance") || strstr(in, "maint")) { - flags = SERVICE_CHANGE_STATUS_MAINTENANCE; - } - if (strstr(in, "out_of_service") || strstr(in, "out")) { - flags = SERVICE_CHANGE_STATUS_OUTOFSERVICE; - } - - - return flags; -} -#endif - - -static int print_debug(uint32_t flags, char *tmp, const int size) -{ - int offset = 0; - int res = 0; - int i; - - if ((flags & PRI_DEBUG_ALL) == PRI_DEBUG_ALL) { - strcat(tmp, "all"); - return 0; - } - else if (!flags) { - strcat(tmp, "none"); - return 0; - } - - for (i = 0; i < ftdm_array_len(ftdm_libpri_debug); i++) { - if ((flags & ftdm_libpri_debug[i].flags) == ftdm_libpri_debug[i].flags) { - res = snprintf(&tmp[offset], size - offset, "%s,", ftdm_libpri_debug[i].name); - if (res <= 0 || res == (size - offset)) - goto out; - offset += res; - flags &= ~ftdm_libpri_debug[i].flags; /* remove detected flags to make *_all work correctly */ - } - } - -out: - tmp[offset - 1] = '\0'; - return 0; -} - - -/*************************************************************** - * MSN filter - ***************************************************************/ - -/** - * Initialize MSN filter data structures - * \param[in] isdn_data Span private data - * \return FTDM_SUCCESS, FTDM_FAIL - */ -static int msn_filter_init(ftdm_libpri_data_t *isdn_data) -{ - if (!isdn_data) - return FTDM_FAIL; - - isdn_data->msn_hash = create_hashtable(16, ftdm_hash_hashfromstring, ftdm_hash_equalkeys); - if (!isdn_data->msn_hash) - return FTDM_FAIL; - - if (ftdm_mutex_create(&isdn_data->msn_mutex)) { - hashtable_destroy(isdn_data->msn_hash); - return FTDM_FAIL; - } - - return FTDM_SUCCESS; -} - -/** - * Destroy MSN filter data structures - * \param[in] isdn_data Span private data - * \return FTDM_SUCCESS, FTDM_FAIL - */ -static int msn_filter_destroy(ftdm_libpri_data_t *isdn_data) -{ - if (!isdn_data) - return FTDM_FAIL; - - if (isdn_data->msn_hash) - hashtable_destroy(isdn_data->msn_hash); - if (isdn_data->msn_mutex) - ftdm_mutex_destroy(&isdn_data->msn_mutex); - - return FTDM_SUCCESS; -} - -/** - * Check if the given string is a valid MSN/DDI - * (i.e.: Not empty, not longer than FDM_DIGITS_LIMIT and all numbers) - * \param[in] str String to check - * \return FTDM_SUCCESS, FTDM_FAIL - */ -static int msn_filter_verify(const char *str) -{ - if (ftdm_strlen_zero(str) || strlen(str) >= FTDM_DIGITS_LIMIT) - return FTDM_FALSE; - - if (ftdm_is_number(str) != FTDM_SUCCESS) - return FTDM_FALSE; - - return FTDM_TRUE; -} - -/** - * Add a new MSN/DDI to the filter - * \param[in] isdn_data Span private data - * \param[in] msn New MSN/DDI to add - * \return FTDM_SUCCESS, FTDM_FAIL - */ -static int msn_filter_add(ftdm_libpri_data_t *isdn_data, const char *msn) -{ - static const int value = 0xdeadbeef; - char *key = NULL; - int ret = FTDM_SUCCESS; - - if (!isdn_data || !msn_filter_verify(msn)) - return FTDM_FAIL; - - ftdm_mutex_lock(isdn_data->msn_mutex); - - /* check for duplicates (ignore if already in set) */ - if (hashtable_search(isdn_data->msn_hash, (void *)msn)) { - ret = FTDM_SUCCESS; - goto out; - } - - /* Copy MSN (transient string), hashtable will free it in hashtable_destroy() */ - key = ftdm_strdup(msn); - if (!key) { - ret = FTDM_FAIL; - goto out; - } - - /* add MSN to list/hash */ - if (!hashtable_insert(isdn_data->msn_hash, (void *)key, (void *)&value, HASHTABLE_FLAG_FREE_KEY)) { - ftdm_safe_free(key); - ret = FTDM_FAIL; - } -out: - ftdm_mutex_unlock(isdn_data->msn_mutex); - return ret; -} - - -/** - * Check if a DNIS (destination number) is a valid MSN/DDI - * \param[in] isdn_data Span private data - * \param[in] msn Number to check - * \retval FTDM_TRUE \p msn is a valid MSN/DDI or filter list is empty - * \retval FTDM_FALSE \p msn is not a valid MSN/DDI - */ -static int msn_filter_match(ftdm_libpri_data_t *isdn_data, const char *msn) -{ - int ret = FTDM_FALSE; - - if (!isdn_data) - return FTDM_FALSE; - /* No number? return match found */ - if (ftdm_strlen_zero(msn)) - return FTDM_TRUE; - - ftdm_mutex_lock(isdn_data->msn_mutex); - - /* No MSN configured? */ - if (hashtable_count(isdn_data->msn_hash) <= 0) { - ret = FTDM_TRUE; - goto out; - } - /* Search for a matching MSN */ - if (hashtable_search(isdn_data->msn_hash, (void *)msn)) - ret = FTDM_TRUE; -out: - ftdm_mutex_unlock(isdn_data->msn_mutex); - return ret; -} - -/** - * Helper function to iterate over MSNs in the filter hash (handles locking) - * \param[in] isdn_data Span private data - * \param[in] func Callback function that is invoked for each entry - * \param[in] data Private data passed to callback - * \return FTDM_SUCCESS, FTDM_FAIL - */ -static int msn_filter_foreach(ftdm_libpri_data_t *isdn_data, int (* func)(const char *, void *), void *data) -{ - ftdm_hash_iterator_t *iter = NULL; - int ret = FTDM_SUCCESS; - - if (!isdn_data || !func) - return FTDM_FAIL; - - /* iterate over MSNs */ - ftdm_mutex_lock(isdn_data->msn_mutex); - - for (iter = hashtable_first(isdn_data->msn_hash); iter; iter = hashtable_next(iter)) { - const void *msn = NULL; - - hashtable_this(iter, &msn, NULL, NULL); - - if (ftdm_strlen_zero((const char *)msn)) - break; - if ((ret = func(msn, data)) != FTDM_SUCCESS) - break; - } - - ftdm_mutex_unlock(isdn_data->msn_mutex); - return ret; -} - - -/*************************************************************** - * Module API (CLI) interface - ***************************************************************/ - -static const char *ftdm_libpri_usage = - "Usage:\n" - "libpri kill \n" - "libpri reset \n" - "libpri restart \n" -#ifdef HAVE_LIBPRI_MAINT_SERVICE - "libpri maintenance \n" -#endif - "libpri debug [all|none|flag,...flagN]\n" - "libpri msn \n" - "\n" - "Possible debug flags:\n" - "\tq921_raw - Q.921 Raw messages\n" - "\tq921_dump - Q.921 Decoded messages\n" - "\tq921_state - Q.921 State machine changes\n" - "\tq921_all - Enable all Q.921 debug options\n" - "\n" - "\tq931_dump - Q.931 Messages\n" - "\tq931_state - Q.931 State machine changes\n" - "\tq931_anomaly - Q.931 Anomalies\n" - "\tq931_all - Enable all Q.931 debug options\n" - "\n" - "\tapdu - Application protocol data unit\n" - "\taoc - Advice of Charge messages\n" - "\tconfig - Configuration\n" - "\n" - "\tnone - Disable debugging\n" - "\tall - Enable all debug options\n"; - - -/** - * Custom data handle for list iterator functions - */ -struct msn_list_cb_private { - ftdm_stream_handle_t *stream; - unsigned int count; -}; - -/** - * "ftdm libpri msn " API command callback - * function for msn_filter_foreach() - */ -static int msn_list_cb(const char *msn, void *priv) -{ - struct msn_list_cb_private *data = priv; - ftdm_stream_handle_t *stream = data->stream; - - if (!stream || ftdm_strlen_zero(msn)) - return FTDM_FAIL; - - stream->write_function(stream, "\t%s\n", msn); - data->count++; - return FTDM_SUCCESS; -} - - -/** - * \brief API function to kill or debug a libpri span - * \param stream API stream handler - * \param data String containing argurments - * \return Flags - */ -static FIO_API_FUNCTION(ftdm_libpri_api) -{ - char *mycmd = NULL, *argv[10] = { 0 }; - int argc = 0; - - if (data) { - mycmd = ftdm_strdup(data); - argc = ftdm_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); - } - - if (argc == 1) { - if (!strcasecmp(argv[0], "help") || !strcasecmp(argv[0], "usage")) { - stream->write_function(stream, ftdm_libpri_usage); - goto done; - } - } else if (argc == 2) { - if (!strcasecmp(argv[0], "kill")) { - int span_id = atoi(argv[1]); - ftdm_span_t *span = NULL; - - if (ftdm_span_find_by_name(argv[1], &span) == FTDM_SUCCESS || ftdm_span_find(span_id, &span) == FTDM_SUCCESS) { - ftdm_libpri_data_t *isdn_data = span->signal_data; - - if (span->start != ftdm_libpri_start) { - stream->write_function(stream, "%s: -ERR '%s' is not a libpri span.\n", - __FILE__, ftdm_span_get_name(span)); - goto done; - } - - ftdm_clear_flag(&(isdn_data->spri), LPWRAP_PRI_READY); - stream->write_function(stream, "%s: +OK killed.\n", __FILE__); - goto done; - } else { - stream->write_function(stream, "%s: -ERR span '%s' not found.\n", - __FILE__, argv[0]); - goto done; - } - } - if (!strcasecmp(argv[0], "msn")) { - ftdm_span_t *span = NULL; - struct msn_list_cb_private data; - data.stream = stream; - data.count = 0; - - if (ftdm_span_find_by_name(argv[1], &span) != FTDM_SUCCESS) { - stream->write_function(stream, "%s: -ERR span '%s' not found.\n", - __FILE__, argv[1]); - goto done; - } - if (span->start != ftdm_libpri_start) { - stream->write_function(stream, "%s: -ERR '%s' is not a libpri span.\n", - __FILE__, ftdm_span_get_name(span)); - goto done; - } - - /* header */ - stream->write_function(stream, "------------------------------------------------------------------------------\n"); - - if (msn_filter_foreach(span->signal_data, msn_list_cb, &data)) { - stream->write_function(stream, "-ERR: Failed to list MSN(s)\n"); - goto done; - } - if (data.count == 0) { - stream->write_function(stream, "\t\t\t -- no entries --\n"); - } - - /* footer */ - stream->write_function(stream, "---------------------------------------------------------------[ %02d MSN(s) ]--\n", - data.count); - stream->write_function(stream, "+OK"); - goto done; - } - } else if (argc >= 2) { - if (!strcasecmp(argv[0], "debug")) { - ftdm_span_t *span = NULL; - - if (ftdm_span_find_by_name(argv[1], &span) == FTDM_SUCCESS) { - ftdm_libpri_data_t *isdn_data = span->signal_data; - uint32_t flags = 0; - - if (span->start != ftdm_libpri_start) { - stream->write_function(stream, "%s: -ERR '%s' is not a libpri span.\n", - __FILE__, ftdm_span_get_name(span)); - goto done; - } - - if (argc == 2) { - char tmp[100] = { 0 }; - print_debug(pri_get_debug(isdn_data->spri.pri), tmp, sizeof(tmp)); - stream->write_function(stream, "%s: +OK current debug flags: '%s'\n", __FILE__, tmp); - goto done; - } - - if (parse_debug(argv[2], &flags) == -1) { - stream->write_function(stream, "%s: -ERR invalid debug flags given\n", __FILE__); - goto done; - } - - pri_set_debug(isdn_data->spri.pri, flags); - stream->write_function(stream, "%s: +OK debug %s.\n", __FILE__, (flags) ? "enabled" : "disabled"); - goto done; - } else { - stream->write_function(stream, "%s: -ERR span '%s' not found.\n", - __FILE__, argv[0]); - goto done; - } - } - if (!strcasecmp(argv[0], "reset")) { - ftdm_span_t *span = NULL; - if (ftdm_span_find_by_name(argv[1], &span) == FTDM_SUCCESS) { - ftdm_libpri_data_t *isdn_data = span->signal_data; - - if (span->start != ftdm_libpri_start) { - stream->write_function(stream, "%s: -ERR '%s' is not a libpri span.\n", - __FILE__, ftdm_span_get_name(span)); - goto done; - } - - pri_restart(isdn_data->spri.pri); - stream->write_function(stream, "%s: +OK reset.\n", __FILE__); - goto done; - } else { - stream->write_function(stream, "%s: -ERR span '%s' not found.\n", - __FILE__, argv[0]); - goto done; - } - } - if (!strcasecmp(argv[0], "restart") && argc == 3) { - ftdm_span_t *span = NULL; - if (ftdm_span_find_by_name(argv[1], &span) == FTDM_SUCCESS) { - ftdm_libpri_data_t *isdn_data = span->signal_data; - - if (span->start != ftdm_libpri_start) { - stream->write_function(stream, "%s: -ERR '%s' is not a libpri span.\n", - __FILE__, ftdm_span_get_name(span)); - goto done; - } - if (!strcasecmp(argv[2], "all")) { - int j; - for(j = 1; j <= span->chan_count; j++) { - pri_reset(isdn_data->spri.pri, j); - ftdm_sleep(50); - } - } else { - pri_reset(isdn_data->spri.pri, atoi(argv[2])); - } - stream->write_function(stream, "%s: +OK restart set.\n", __FILE__); - goto done; - } else { - stream->write_function(stream, "%s: -ERR span '%s' not found.\n", - __FILE__, argv[0]); - goto done; - } - } -#ifdef HAVE_LIBPRI_MAINT_SERVICE - if (!strcasecmp(argv[0], "maintenance") && argc > 3) { - ftdm_span_t *span = NULL; - if (ftdm_span_find_by_name(argv[1], &span) == FTDM_SUCCESS) { - ftdm_libpri_data_t *isdn_data = span->signal_data; - - if (span->start != ftdm_libpri_start) { - stream->write_function(stream, "%s: -ERR '%s' is not a libpri span.\n", - __FILE__, ftdm_span_get_name(span)); - goto done; - } - if (!isdn_data->service_message_support) { - stream->write_function(stream, "%s: -ERR service message support is disabled\n", __FILE__); - goto done; - } - if (!strcasecmp(argv[2], "all")) { - int j; - for(j = 1; j <= span->chan_count; j++) { - pri_maintenance_service(isdn_data->spri.pri, atoi(argv[1]), j, parse_change_status(argv[3])); - ftdm_sleep(50); - } - } else { - pri_maintenance_service(isdn_data->spri.pri, atoi(argv[1]), atoi(argv[2]), parse_change_status(argv[3])); - } - stream->write_function(stream, "%s: +OK change status set.\n", __FILE__); - goto done; - } else { - stream->write_function(stream, "%s: -ERR span '%s' not found.\n", - __FILE__, argv[0]); - goto done; - } - } -#endif - } else { - /* zero args print usage */ - stream->write_function(stream, ftdm_libpri_usage); - goto done; - } - - stream->write_function(stream, "%s: -ERR invalid command.\n", __FILE__); - -done: - ftdm_safe_free(mycmd); - - return FTDM_SUCCESS; -} - - -/** - * \brief Loads libpri IO module - * \param fio FreeTDM IO interface - * \return Success - */ -static FIO_IO_LOAD_FUNCTION(ftdm_libpri_io_init) -{ - assert(fio != NULL); - - memset(&ftdm_libpri_interface, 0, sizeof(ftdm_libpri_interface)); - ftdm_libpri_interface.name = "libpri"; - ftdm_libpri_interface.api = &ftdm_libpri_api; - - *fio = &ftdm_libpri_interface; - - return FTDM_SUCCESS; -} - -/** - * \brief Loads libpri signaling module - * \param fio FreeTDM IO interface - * \return Success - */ -static FIO_SIG_LOAD_FUNCTION(ftdm_libpri_init) -{ - pri_set_error(s_pri_error); - pri_set_message(s_pri_message); - return FTDM_SUCCESS; -} - -/** - * \brief libpri state map - */ -static ftdm_state_map_t isdn_state_map = { - { - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_ANY}, - {FTDM_CHANNEL_STATE_RESTART, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_RESTART, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_SUSPENDED, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_DIALING, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_DIALING, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, - FTDM_CHANNEL_STATE_PROCEED, FTDM_CHANNEL_STATE_RINGING, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_PROGRESS, - FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_PROCEED, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, - FTDM_CHANNEL_STATE_RINGING, FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END}, - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_RINGING, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, - FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END}, - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, - FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP_COMPLETE, FTDM_CHANNEL_STATE_END}, - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_HANGUP_COMPLETE, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END}, - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_SUSPENDED, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END}, - }, - - /****************************************/ - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_ANY}, - {FTDM_CHANNEL_STATE_RESTART, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_RESTART, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_SUSPENDED, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_DIALTONE, FTDM_CHANNEL_STATE_COLLECT, FTDM_CHANNEL_STATE_RING, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_DIALTONE, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_RING, FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_COLLECT, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_RING, FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_RING, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_PROCEED, FTDM_CHANNEL_STATE_RINGING, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_PROCEED, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_RINGING, FTDM_CHANNEL_STATE_PROGRESS, - FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_RINGING, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, - FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_END}, - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_END}, - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP_COMPLETE, FTDM_CHANNEL_STATE_END}, - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_HANGUP_COMPLETE, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END}, - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_SUSPENDED, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END}, - }, - } -}; - -/** - * \brief Handler for channel state change - * \param ftdmchan Channel to handle - * \note This function MUST be called with the channel locked - */ -static ftdm_status_t state_advance(ftdm_channel_t *chan) -{ - ftdm_span_t *span = ftdm_channel_get_span(chan); - ftdm_libpri_data_t *isdn_data = span->signal_data; - ftdm_libpri_b_chan_t *chan_priv = chan->call_data; - q931_call *call = chan_priv->call; - ftdm_status_t status; - ftdm_sigmsg_t sig; - - ftdm_log(FTDM_LOG_DEBUG, "-- %d:%d STATE [%s]\n", - ftdm_channel_get_span_id(chan), ftdm_channel_get_id(chan), ftdm_channel_get_state_str(chan)); - - memset(&sig, 0, sizeof(sig)); - sig.chan_id = ftdm_channel_get_id(chan); - sig.span_id = ftdm_channel_get_span_id(chan); - sig.channel = chan; - - ftdm_channel_complete_state(chan); - - switch (ftdm_channel_get_state(chan)) { - case FTDM_CHANNEL_STATE_DOWN: - { - if (ftdm_channel_get_type(chan) == FTDM_CHAN_TYPE_B) { - ftdm_channel_t *chtmp = chan; - - if (call) { - /* pri call destroy is done by libpri itself (on release_ack) */ - chan_priv->call = NULL; - } - - /* Stop T302 */ - lpwrap_stop_timer(&isdn_data->spri, &chan_priv->t302); - - /* Stop T316 and reset counter */ - lpwrap_stop_timer(&isdn_data->spri, &chan_priv->t316); - chan_priv->t316_timeout_cnt = 0; - - /* Unset remote hangup */ - chan_priv->peerhangup = 0; - - if (ftdm_channel_close(&chtmp) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_WARNING, "-- Failed to close channel %d:%d\n", - ftdm_channel_get_span_id(chan), - ftdm_channel_get_id(chan)); - } else { - ftdm_log(FTDM_LOG_DEBUG, "-- Closed channel %d:%d\n", - ftdm_channel_get_span_id(chan), - ftdm_channel_get_id(chan)); - } - } - } - break; - - case FTDM_CHANNEL_STATE_PROGRESS: - { - if (ftdm_test_flag(chan, FTDM_CHANNEL_OUTBOUND)) { - sig.event_id = FTDM_SIGEVENT_PROGRESS; - if ((status = ftdm_span_send_signal(span, &sig) != FTDM_SUCCESS)) { - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_HANGUP); - } - } else if (call) { - /* - * Even if we have no media, sending progress without PI is forbidden - * by Q.931 3.1.8, so a protocol error will be issued from libpri - * and from remote equipment. - * So just pretend we have PI. - */ - pri_progress(isdn_data->spri.pri, call, ftdm_channel_get_id(chan), 1); - } else { - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_RESTART); - } - } - break; - - case FTDM_CHANNEL_STATE_RINGING: - { - if (ftdm_test_flag(chan, FTDM_CHANNEL_OUTBOUND)) { - sig.event_id = FTDM_SIGEVENT_RINGING; - if ((status = ftdm_span_send_signal(span, &sig) != FTDM_SUCCESS)) { - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_HANGUP); - } - } else if (call) { -// pri_progress(isdn_data->spri.pri, call, ftdm_channel_get_id(chan), 1); - pri_acknowledge(isdn_data->spri.pri, call, ftdm_channel_get_id(chan), 0); - } else { - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_RESTART); - } - } - break; - - case FTDM_CHANNEL_STATE_PROGRESS_MEDIA: - { - if (ftdm_test_flag(chan, FTDM_CHANNEL_OUTBOUND)) { - sig.event_id = FTDM_SIGEVENT_PROGRESS_MEDIA; - if ((status = ftdm_span_send_signal(span, &sig) != FTDM_SUCCESS)) { - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_HANGUP); - } - } else if (call) { - /* make sure channel is open in this state (outbound handled in on_proceeding()) */ - if (!ftdm_test_flag(chan, FTDM_CHANNEL_OPEN)) { - ftdm_channel_open_chan(chan); - } - pri_progress(isdn_data->spri.pri, call, ftdm_channel_get_id(chan), 1); - } else { - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_RESTART); - } - } - break; - - case FTDM_CHANNEL_STATE_PROCEED: - { - if (ftdm_test_flag(chan, FTDM_CHANNEL_OUTBOUND)) { - /* PROCEED from other end, notify user */ - sig.event_id = FTDM_SIGEVENT_PROCEED; - if ((status = ftdm_span_send_signal(span, &sig) != FTDM_SUCCESS)) { - ftdm_log(FTDM_LOG_ERROR, "Failed to send PROCEED sigevent on Channel %d:%d\n", - ftdm_channel_get_span_id(chan), - ftdm_channel_get_id(chan)); - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_HANGUP); - } - } else if (call) { - pri_proceeding(isdn_data->spri.pri, call, ftdm_channel_get_id(chan), 0); - } else { - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_RESTART); - } - } - break; - - case FTDM_CHANNEL_STATE_COLLECT: /* Overlap receive */ - { - if (!ftdm_test_flag(chan, FTDM_CHANNEL_OUTBOUND)) { - if (!call) { - ftdm_log_chan_msg(chan, FTDM_LOG_ERROR, "No call handle\n"); - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_RESTART); - } - else if (pri_need_more_info(isdn_data->spri.pri, call, ftdm_channel_get_id(chan), 0)) { - ftdm_caller_data_t *caller_data = ftdm_channel_get_caller_data(chan); - - ftdm_log_chan_msg(chan, FTDM_LOG_ERROR, "Failed to send INFORMATION request\n"); - - /* hangup call */ - caller_data->hangup_cause = FTDM_CAUSE_DESTINATION_OUT_OF_ORDER; - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_HANGUP); - } - else { - /* Start T302 */ - lpwrap_start_timer(&isdn_data->spri, &chan_priv->t302, - isdn_data->overlap_timeout_ms, &on_timeout_t302); - } - } else { - ftdm_log_chan_msg(chan, FTDM_LOG_ERROR, "Overlap receiving on outbound call?\n"); - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_RESTART); - } - } - break; - - case FTDM_CHANNEL_STATE_RING: - { - /* - * This needs more auditing for BRI PTMP: - * does pri_acknowledge() steal the call from other devices? (yes, it does) - */ - if (!ftdm_test_flag(chan, FTDM_CHANNEL_OUTBOUND)) { - if (call) { - pri_proceeding(isdn_data->spri.pri, call, ftdm_channel_get_id(chan), 0); -// pri_acknowledge(isdn_data->spri.pri, call, ftdm_channel_get_id(chan), 0); - sig.event_id = FTDM_SIGEVENT_START; - if ((status = ftdm_span_send_signal(span, &sig) != FTDM_SUCCESS)) { - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_HANGUP); - } - } else { - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_RESTART); - } - } - } - break; - - case FTDM_CHANNEL_STATE_RESTART: - { - if (ftdm_channel_get_type(chan) == FTDM_CHAN_TYPE_B) { - chan->caller_data.hangup_cause = FTDM_CAUSE_NORMAL_UNSPECIFIED; - sig.event_id = FTDM_SIGEVENT_RESTART; - status = ftdm_span_send_signal(span, &sig); - - if (ftdm_span_get_trunk_type(span) == FTDM_TRUNK_BRI_PTMP) { - /* Just put the channel into DOWN state, libpri won't send RESTART on BRI PTMP */ - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_DOWN); - - } else if (!(chan_priv->flags & FTDM_LIBPRI_B_REMOTE_RESTART)) { - /* Locally triggered restart, send RESTART to remote, wait for ACK */ - pri_reset(isdn_data->spri.pri, ftdm_channel_get_id(chan)); - /* Start T316 */ - lpwrap_start_timer(&isdn_data->spri, &chan_priv->t316, isdn_data->t316_timeout_ms, &on_timeout_t316); - } else { - /* Remote restart complete, clear flag (RESTART ACK already sent by libpri) */ - chan_priv->flags &= ~FTDM_LIBPRI_B_REMOTE_RESTART; - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_DOWN); - } - } - } - break; - - case FTDM_CHANNEL_STATE_UP: - { - if (ftdm_test_flag(chan, FTDM_CHANNEL_OUTBOUND)) { - sig.event_id = FTDM_SIGEVENT_UP; - if ((status = ftdm_span_send_signal(span, &sig) != FTDM_SUCCESS)) { - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_HANGUP); - } - } else if (call) { - /* make sure channel is open in this state (outbound handled in on_answer()) */ - if (!ftdm_test_flag(chan, FTDM_CHANNEL_OPEN)) { - ftdm_channel_open_chan(chan); - } - pri_answer(isdn_data->spri.pri, call, 0, 1); - } else { - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_RESTART); - } - } - break; - - case FTDM_CHANNEL_STATE_DIALING: - if (isdn_data) { - ftdm_caller_data_t *caller_data = ftdm_channel_get_caller_data(chan); - struct pri_sr *sr; - int caller_ton; - int called_ton; - - if (!(call = pri_new_call(isdn_data->spri.pri))) { - ftdm_log(FTDM_LOG_ERROR, "Failed to create new call on channel %d:%d\n", - ftdm_channel_get_span_id(chan), ftdm_channel_get_id(chan)); - /* TODO: set hangup cause? */ - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_RESTART); - return FTDM_SUCCESS; - } - - caller_ton = caller_data->cid_num.type; - switch (caller_ton) { - case FTDM_TON_NATIONAL: - caller_ton = PRI_NATIONAL_ISDN; - break; - case FTDM_TON_INTERNATIONAL: - caller_ton = PRI_INTERNATIONAL_ISDN; - break; - case FTDM_TON_SUBSCRIBER_NUMBER: - caller_ton = PRI_LOCAL_ISDN; - break; - default: - caller_ton = isdn_data->ton; - } - - called_ton = caller_data->dnis.type; - switch (called_ton) { - case FTDM_TON_NATIONAL: - called_ton = PRI_NATIONAL_ISDN; - break; - case FTDM_TON_INTERNATIONAL: - called_ton = PRI_INTERNATIONAL_ISDN; - break; - case FTDM_TON_SUBSCRIBER_NUMBER: - called_ton = PRI_LOCAL_ISDN; - break; - default: - called_ton = isdn_data->ton; - } - - chan_priv->call = call; - - sr = pri_sr_new(); - if (!sr) { - ftdm_log(FTDM_LOG_ERROR, "Failed to create new setup request on channel %d:%d\n", - ftdm_channel_get_span_id(chan), ftdm_channel_get_id(chan)); - /* TODO: handle error properly */ - } - assert(sr); - - pri_sr_set_channel(sr, ftdm_channel_get_id(chan), 1, 0); - pri_sr_set_bearer(sr, PRI_TRANS_CAP_SPEECH, isdn_data->layer1); - - pri_sr_set_called(sr, caller_data->dnis.digits, called_ton, 1); - pri_sr_set_caller(sr, caller_data->cid_num.digits, - ((isdn_data->opts & FTMOD_LIBPRI_OPT_OMIT_DISPLAY_IE) ? NULL : caller_data->cid_name), - caller_ton, - ((caller_data->pres != 1) ? PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN : PRES_PROHIB_USER_NUMBER_NOT_SCREENED)); - - if (!(isdn_data->opts & FTMOD_LIBPRI_OPT_OMIT_REDIRECTING_NUMBER_IE)) { - pri_sr_set_redirecting(sr, caller_data->cid_num.digits, caller_ton, - PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN, PRI_REDIR_UNCONDITIONAL); - } -#ifdef HAVE_LIBPRI_AOC - if (isdn_data->opts & FTMOD_LIBPRI_OPT_FACILITY_AOC) { - /* request AOC on call */ - pri_sr_set_aoc_charging_request(sr, (PRI_AOC_REQUEST_S | PRI_AOC_REQUEST_E | PRI_AOC_REQUEST_D)); - ftdm_log(FTDM_LOG_DEBUG, "Requesting AOC-S/D/E on call\n"); - } -#endif - if (pri_setup(isdn_data->spri.pri, call, sr)) { - caller_data->hangup_cause = FTDM_CAUSE_DESTINATION_OUT_OF_ORDER; - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_HANGUP); - } - - pri_sr_free(sr); - } - break; - - case FTDM_CHANNEL_STATE_HANGUP: - { - if (call) { - ftdm_caller_data_t *caller_data = ftdm_channel_get_caller_data(chan); - pri_hangup(isdn_data->spri.pri, call, caller_data->hangup_cause); - - if (chan_priv->peerhangup) { - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_HANGUP_COMPLETE); - } - } - } - break; - - case FTDM_CHANNEL_STATE_HANGUP_COMPLETE: - { -// if (call) { -// pri_destroycall(isdn_data->spri.pri, call); -// chan_priv->call = NULL; -// } - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_DOWN); - } - break; - - case FTDM_CHANNEL_STATE_TERMINATING: - { - sig.event_id = FTDM_SIGEVENT_STOP; - status = ftdm_span_send_signal(span, &sig); - /* user moves us to HANGUP and from there we go to DOWN */ - } - default: - break; - } - return FTDM_SUCCESS; -} - -/** - * \brief Checks current state on a span - * \param span Span to check status on - */ -static __inline__ void check_state(ftdm_span_t *span) -{ - if (ftdm_test_flag(span, FTDM_SPAN_STATE_CHANGE)) { - uint32_t j; - - ftdm_clear_flag_locked(span, FTDM_SPAN_STATE_CHANGE); - - for (j = 1; j <= ftdm_span_get_chan_count(span); j++) { - ftdm_channel_t *chan = ftdm_span_get_channel(span, j); - ftdm_channel_lock(chan); - ftdm_channel_advance_states(chan); - ftdm_channel_unlock(chan); - } - } -} - - -/** - * \brief Handler for libpri keypad digit event - * \param spri Pri wrapper structure (libpri, span, dchan) - * \param event_type Event type (unused) - * \param pevent Event - * \return 0 - */ -static int on_keypad_digit(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_event *pevent) -{ - ftdm_span_t *span = spri->span; - ftdm_channel_t *chan = ftdm_span_get_channel(span, pevent->ring.channel); - - ftdm_unused_arg(event_type); - - if (!chan) { - ftdm_log(FTDM_LOG_ERROR, "-- Keypad event on invalid channel %d:%d\n", - ftdm_span_get_id(span), pevent->ring.channel); - return 0; - } - - ftdm_log_chan(chan, FTDM_LOG_DEBUG, "-- Keypad event received, incoming digits: '%s'\n", - pevent->digit.digits); - - /* Enqueue DTMF digits on channel */ - ftdm_channel_queue_dtmf(chan, pevent->digit.digits); - return 0; -} - - -/** - * \brief Handler for libpri information event (overlap receiving) - * \param spri Pri wrapper structure (libpri, span, dchan) - * \param event_type Event type (unused) - * \param pevent Event - * \return 0 - */ -static int on_information(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_event *pevent) -{ - ftdm_span_t *span = spri->span; - ftdm_channel_t *chan = ftdm_span_get_channel(span, pevent->ring.channel); - ftdm_libpri_b_chan_t *chan_priv = NULL; - ftdm_caller_data_t *caller_data = NULL; - ftdm_libpri_data_t *isdn_data = span->signal_data; - - ftdm_unused_arg(event_type); - - if (!chan) { - ftdm_log(FTDM_LOG_CRIT, "-- Info on channel %d:%d but it's not in use?\n", ftdm_span_get_id(span), pevent->ring.channel); - return 0; - } - - caller_data = ftdm_channel_get_caller_data(chan); - chan_priv = chan->call_data; - - switch (ftdm_channel_get_state(chan)) { - case FTDM_CHANNEL_STATE_COLLECT: /* TE-mode overlap receiving */ - case FTDM_CHANNEL_STATE_DIALTONE: /* NT-mode overlap receiving */ - - ftdm_log_chan(chan, FTDM_LOG_DEBUG, "-- Incoming INFORMATION indication, received digits: '%s', number complete: %c, collected digits: '%s'\n", - pevent->ring.callednum, - pevent->ring.complete ? 'Y' : 'N', - caller_data->dnis.digits); - - /* Stop T302 */ - lpwrap_stop_timer(spri, &chan_priv->t302); - - /* append digits to dnis */ - if (!ftdm_strlen_zero(pevent->ring.callednum)) { - int digits = strlen(pevent->ring.callednum); - int offset = strlen(caller_data->dnis.digits); - int len = 0; - - if (strchr(pevent->ring.callednum, '#')) { - pevent->ring.complete = 1; - digits--; - } - - len = ftdm_min(sizeof(caller_data->dnis.digits) - 1 - offset, digits); /* max. length without terminator */ - if (len < digits) { - ftdm_log_chan(chan, FTDM_LOG_WARNING, "Digit string of length %d exceeds available space %d of DNIS, truncating!\n", - digits, len); - } - if (len) { - ftdm_copy_string(&caller_data->dnis.digits[offset], (char *)pevent->ring.callednum, len + 1); /* max. length with terminator */ - caller_data->dnis.digits[offset + len] = '\0'; - } - } - if (pevent->ring.complete) { - ftdm_log_chan_msg(chan, FTDM_LOG_DEBUG, "Number complete indication received, moving channel to RING state\n"); - /* notify switch */ - ftdm_set_state(chan, FTDM_CHANNEL_STATE_RING); - } else { - /* Restart T302 */ - lpwrap_start_timer(spri, &chan_priv->t302, isdn_data->overlap_timeout_ms, &on_timeout_t302); - } - break; - default: - ftdm_log_chan(chan, FTDM_LOG_ERROR, "-- INFORMATION indication in invalid state '%s'\n", - ftdm_channel_get_state_str(chan)); - } - return 0; -} - -/** - * \brief Handler for libpri hangup event - * \param spri Pri wrapper structure (libpri, span, dchan) - * \param event_type Event type (unused) - * \param pevent Event - * \return 0 - */ -static int on_hangup(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_event *pevent) -{ - ftdm_span_t *span = spri->span; - ftdm_channel_t *chan = ftdm_span_get_channel(span, pevent->hangup.channel); - ftdm_libpri_b_chan_t *chan_priv = chan->call_data; - - if (!chan) { - ftdm_log(FTDM_LOG_CRIT, "-- Hangup on channel %d:%d but it's not in use?\n", ftdm_span_get_id(spri->span), pevent->hangup.channel); - return 0; - } - - ftdm_channel_lock(chan); - - switch (event_type) { - case LPWRAP_PRI_EVENT_HANGUP_REQ: /* DISCONNECT */ - if (ftdm_channel_get_state(chan) >= FTDM_CHANNEL_STATE_TERMINATING) { - ftdm_log_chan(chan, FTDM_LOG_DEBUG, "Ignoring remote hangup in state %s\n", - ftdm_channel_get_state_str(chan)); - goto done; - } - ftdm_log(FTDM_LOG_DEBUG, "-- Hangup REQ on channel %d:%d\n", - ftdm_span_get_id(spri->span), pevent->hangup.channel); - - chan->caller_data.hangup_cause = pevent->hangup.cause; - - switch (ftdm_channel_get_state(chan)) { - case FTDM_CHANNEL_STATE_DIALTONE: - case FTDM_CHANNEL_STATE_COLLECT: - ftdm_set_state(chan, FTDM_CHANNEL_STATE_HANGUP); - break; - default: - ftdm_set_state(chan, FTDM_CHANNEL_STATE_TERMINATING); - } - break; - - case LPWRAP_PRI_EVENT_HANGUP_ACK: /* RELEASE_COMPLETE */ - ftdm_log(FTDM_LOG_DEBUG, "-- Hangup ACK on channel %d:%d\n", - ftdm_span_get_id(spri->span), pevent->hangup.channel); - - switch (ftdm_channel_get_state(chan)) { - case FTDM_CHANNEL_STATE_RESTART: - /* ACK caused by DL FAILURE in DISC REQ */ - ftdm_set_state(chan, FTDM_CHANNEL_STATE_DOWN); - break; - default: - ftdm_set_state(chan, FTDM_CHANNEL_STATE_HANGUP_COMPLETE); - break; - } - break; - - case LPWRAP_PRI_EVENT_HANGUP: /* "RELEASE/RELEASE_COMPLETE/other" */ - ftdm_log(FTDM_LOG_DEBUG, "-- Hangup on channel %d:%d\n", - ftdm_span_get_id(spri->span), pevent->hangup.channel); - - chan_priv->peerhangup = 1; - - switch (ftdm_channel_get_state(chan)) { - case FTDM_CHANNEL_STATE_DIALING: - case FTDM_CHANNEL_STATE_RINGING: - case FTDM_CHANNEL_STATE_PROGRESS: - case FTDM_CHANNEL_STATE_PROGRESS_MEDIA: - case FTDM_CHANNEL_STATE_PROCEED: - case FTDM_CHANNEL_STATE_UP: - chan->caller_data.hangup_cause = pevent->hangup.cause; - ftdm_set_state(chan, FTDM_CHANNEL_STATE_TERMINATING); - break; - case FTDM_CHANNEL_STATE_HANGUP: - /* this will send "RELEASE_COMPLETE", eventually */ - pri_hangup(spri->pri, pevent->hangup.call, chan->caller_data.hangup_cause); - chan->caller_data.hangup_cause = pevent->hangup.cause; - ftdm_set_state(chan, FTDM_CHANNEL_STATE_HANGUP_COMPLETE); - break; - case FTDM_CHANNEL_STATE_RESTART: - /* - * We got an hungup doing a restart, normally beacause link has been lost during - * a call and the T309 timer has expired. So destroy it :) (DL_RELEASE_IND) - */ - pri_destroycall(spri->pri, pevent->hangup.call); - ftdm_set_state(chan, FTDM_CHANNEL_STATE_DOWN); - break; -// case FTDM_CHANNEL_STATE_TERMINATING: -// ftdm_set_state(chan, FTDM_CHANNEL_STATE_HANGUP); -// break; -// case FTDM_CHANNEL_STATE_HANGUP_COMPLETE: -// ftdm_set_state(chan, FTDM_CHANNEL_STATE_DOWN); -// break; - } - break; - default: - break; - } - -done: - ftdm_channel_unlock(chan); - return 0; -} - -/** - * \brief Handler for libpri answer event - * \param spri Pri wrapper structure (libpri, span, dchan) - * \param event_type Event type (unused) - * \param pevent Event - * \return 0 - */ -static int on_answer(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_event *pevent) -{ - ftdm_span_t *span = spri->span; - ftdm_channel_t *chan = ftdm_span_get_channel(span, pevent->answer.channel); - - ftdm_unused_arg(event_type); - - if (chan) { - if (!ftdm_test_flag(chan, FTDM_CHANNEL_OPEN)) { - ftdm_log(FTDM_LOG_DEBUG, "-- Call answered, opening B-Channel %d:%d\n", - ftdm_channel_get_span_id(chan), - ftdm_channel_get_id(chan)); - - if (ftdm_channel_open_chan(chan) != FTDM_SUCCESS) { - ftdm_caller_data_t *caller_data = ftdm_channel_get_caller_data(chan); - - ftdm_log(FTDM_LOG_ERROR, "-- Error opening channel %d:%d\n", - ftdm_channel_get_span_id(chan), - ftdm_channel_get_id(chan)); - - caller_data->hangup_cause = FTDM_CAUSE_DESTINATION_OUT_OF_ORDER; - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_TERMINATING); - goto out; - } - } - ftdm_log(FTDM_LOG_DEBUG, "-- Answer on channel %d:%d\n", ftdm_span_get_id(span), pevent->answer.channel); - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_UP); - } else { - ftdm_log(FTDM_LOG_DEBUG, "-- Answer on channel %d:%d but it's not in the span?\n", - ftdm_span_get_id(span), pevent->answer.channel); - } -out: - return 0; -} - -/** - * \brief Handler for libpri proceeding event - * \param spri Pri wrapper structure (libpri, span, dchan) - * \param event_type Event type (unused) - * \param pevent Event - * \return 0 - */ -static int on_proceeding(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_event *pevent) -{ - ftdm_span_t *span = spri->span; - ftdm_channel_t *chan = ftdm_span_get_channel(span, pevent->proceeding.channel); - - ftdm_unused_arg(event_type); - - if (chan) { - /* Open channel if inband information is available */ - if (pevent->proceeding.progressmask & PRI_PROG_INBAND_AVAILABLE || pevent->proceeding.progressmask & PRI_PROG_CALL_NOT_E2E_ISDN) { - ftdm_log(FTDM_LOG_DEBUG, "-- In-band information available, B-Channel %d:%d\n", - ftdm_channel_get_span_id(chan), - ftdm_channel_get_id(chan)); - - if (!ftdm_test_flag(chan, FTDM_CHANNEL_OPEN) && (ftdm_channel_open_chan(chan) != FTDM_SUCCESS)) { - ftdm_caller_data_t *caller_data = ftdm_channel_get_caller_data(chan); - - ftdm_log(FTDM_LOG_ERROR, "-- Error opening channel %d:%d\n", - ftdm_channel_get_span_id(chan), - ftdm_channel_get_id(chan)); - - caller_data->hangup_cause = FTDM_CAUSE_DESTINATION_OUT_OF_ORDER; - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_TERMINATING); - goto out; - } - } - ftdm_log(FTDM_LOG_DEBUG, "-- Proceeding on channel %d:%d\n", ftdm_span_get_id(span), pevent->proceeding.channel); - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_PROCEED); - } else { - ftdm_log(FTDM_LOG_DEBUG, "-- Proceeding on channel %d:%d but it's not in the span?\n", - ftdm_span_get_id(span), pevent->proceeding.channel); - } -out: - return 0; -} - -/** - * \brief Handler for libpri progress event - * \param spri Pri wrapper structure (libpri, span, dchan) - * \param event_type Event type (unused) - * \param pevent Event - * \return 0 - * \note also uses pri_event->proceeding - */ -static int on_progress(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_event *pevent) -{ - ftdm_span_t *span = spri->span; - ftdm_channel_t *chan = ftdm_span_get_channel(span, pevent->proceeding.channel); - - ftdm_unused_arg(event_type); - - if (chan) { - /* Open channel if inband information is available */ - if (pevent->proceeding.progressmask & PRI_PROG_INBAND_AVAILABLE || pevent->proceeding.progressmask & PRI_PROG_CALL_NOT_E2E_ISDN) { - ftdm_log(FTDM_LOG_DEBUG, "-- In-band information available, B-Channel %d:%d\n", - ftdm_channel_get_span_id(chan), - ftdm_channel_get_id(chan)); - - if (!ftdm_test_flag(chan, FTDM_CHANNEL_OPEN) && (ftdm_channel_open_chan(chan) != FTDM_SUCCESS)) { - ftdm_caller_data_t *caller_data = ftdm_channel_get_caller_data(chan); - - ftdm_log(FTDM_LOG_ERROR, "-- Error opening channel %d:%d\n", - ftdm_channel_get_span_id(chan), - ftdm_channel_get_id(chan)); - - caller_data->hangup_cause = FTDM_CAUSE_DESTINATION_OUT_OF_ORDER; - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_TERMINATING); - goto out; - } - ftdm_log(FTDM_LOG_DEBUG, "-- Progress on channel %d:%d with media\n", ftdm_span_get_id(span), pevent->proceeding.channel); - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA); - } else { - ftdm_log(FTDM_LOG_DEBUG, "-- Progress on channel %d:%d\n", ftdm_span_get_id(span), pevent->proceeding.channel); - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_PROGRESS); - } - } else { - ftdm_log(FTDM_LOG_DEBUG, "-- Progress on channel %d:%d but it's not in the span?\n", - ftdm_span_get_id(span), pevent->proceeding.channel); - } -out: - return 0; -} - -/** - * \brief Handler for libpri ringing event - * \param spri Pri wrapper structure (libpri, span, dchan) - * \param event_type Event type (unused) - * \param pevent Event - * \return 0 - */ -static int on_ringing(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_event *pevent) -{ - ftdm_span_t *span = spri->span; - ftdm_channel_t *chan = ftdm_span_get_channel(span, pevent->ringing.channel); - - ftdm_unused_arg(event_type); - - if (chan) { - /* we may get on_ringing even when we're already in FTDM_CHANNEL_STATE_PROGRESS_MEDIA */ -// if (ftdm_channel_get_state(chan) == FTDM_CHANNEL_STATE_PROGRESS_MEDIA) { -// /* dont try to move to STATE_PROGRESS to avoid annoying veto warning */ -// return 0; -// } - - /* Open channel if inband information is available */ - if ((pevent->ringing.progressmask & PRI_PROG_INBAND_AVAILABLE)) { - ftdm_log(FTDM_LOG_DEBUG, "-- In-band information available, B-Channel %d:%d\n", - ftdm_channel_get_span_id(chan), - ftdm_channel_get_id(chan)); - - if (!ftdm_test_flag(chan, FTDM_CHANNEL_OPEN) && (ftdm_channel_open_chan(chan) != FTDM_SUCCESS)) { - ftdm_caller_data_t *caller_data = ftdm_channel_get_caller_data(chan); - - ftdm_log(FTDM_LOG_ERROR, "-- Error opening channel %d:%d\n", - ftdm_channel_get_span_id(chan), - ftdm_channel_get_id(chan)); - - caller_data->hangup_cause = FTDM_CAUSE_DESTINATION_OUT_OF_ORDER; - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_TERMINATING); - goto out; - } - ftdm_log(FTDM_LOG_DEBUG, "-- Ringing on channel %d:%d with media\n", ftdm_span_get_id(span), pevent->proceeding.channel); - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA); - } else { -// ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_PROGRESS); - ftdm_log(FTDM_LOG_DEBUG, "-- Ringing on channel %d:%d\n", ftdm_span_get_id(span), pevent->proceeding.channel); - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_RINGING); - } - } else { - ftdm_log(FTDM_LOG_DEBUG, "-- Ringing on channel %d:%d but it's not in the span?\n", - ftdm_span_get_id(span), pevent->ringing.channel); - } -out: - return 0; -} - - -/** - * Look up FreeTDM channel by call reference value - * \param[in] span Span object - * \param[in] crv CRV to search for - * \return Channel on success, NULL otherwise - */ -static ftdm_channel_t *find_channel_by_cref(ftdm_span_t *span, const int cref) -{ - ftdm_iterator_t *c_iter, *c_cur; - ftdm_channel_t *chan = NULL; - - if (!span || cref <= 0) - return NULL; - - ftdm_mutex_lock(span->mutex); - - c_iter = ftdm_span_get_chan_iterator(span, NULL); - - /* Iterate over all channels on this span */ - for (c_cur = c_iter; c_cur; c_cur = ftdm_iterator_next(c_cur)) { - ftdm_channel_t *cur = ftdm_iterator_current(c_cur); - ftdm_caller_data_t *caller_data = NULL; - - if (ftdm_channel_get_type(cur) != FTDM_CHAN_TYPE_B) - continue; - - caller_data = ftdm_channel_get_caller_data(cur); - - if (caller_data->call_reference == cref) { - chan = cur; - break; - } - } - - ftdm_iterator_free(c_iter); - ftdm_mutex_unlock(span->mutex); - return chan; -} - - -/** - * Hunt for free channel (NT-mode only) - * \param[in] span Span to hunt on - * \param[in] hint Channel ID hint (preferred by remote end) - * \param[in] excl Is the hint exclusive (or preferred)? - * \param[out] chan Selected channel - * \retval FTDM_SUCCESS A free channel has been found - * \retval FTDM_FAIL No free channels could be found on the span - * \retval FTDM_EBUSY The channel indicated in the exclusive hint is already in use - */ -static ftdm_status_t hunt_channel(ftdm_span_t *span, const int hint, const ftdm_bool_t excl, ftdm_channel_t **chan) -{ - ftdm_iterator_t *c_iter, *c_cur; - ftdm_channel_t *tmp = NULL; - int ret = FTDM_FAIL; - - /* lock span */ - ftdm_mutex_lock(span->mutex); - - /* Check hint */ - if (hint > 0) { - tmp = ftdm_span_get_channel(span, hint); - if (!tmp) { - ftdm_log(FTDM_LOG_NOTICE, "Invalid channel hint '%d' given (out of bounds)\n", hint); - } - else if (!ftdm_test_flag(tmp, FTDM_CHANNEL_INUSE) && ftdm_channel_get_type(tmp) == FTDM_CHAN_TYPE_B) { - ftdm_log(FTDM_LOG_DEBUG, "Using channel '%d' from hint\n", ftdm_channel_get_id(tmp)); - ftdm_channel_use(tmp); - ret = FTDM_SUCCESS; - *chan = tmp; - goto out; - } - else if (excl) { - ftdm_log(FTDM_LOG_NOTICE, "Channel '%d' in exclusive hint is not available\n", - ftdm_channel_get_id(tmp)); - ret = FTDM_EBUSY; - goto out; - } - } - - c_iter = ftdm_span_get_chan_iterator(span, NULL); - - /* Iterate over all channels on this span */ - for (c_cur = c_iter; c_cur; c_cur = ftdm_iterator_next(c_cur)) { - tmp = ftdm_iterator_current(c_cur); - - if (ftdm_channel_get_type(tmp) != FTDM_CHAN_TYPE_B) - continue; - - if (!ftdm_test_flag(tmp, FTDM_CHANNEL_INUSE)) { - ftdm_channel_use(tmp); - ret = FTDM_SUCCESS; - *chan = tmp; - break; - } - } - - ftdm_iterator_free(c_iter); -out: - ftdm_mutex_unlock(span->mutex); - return ret; -} - - -/** - * \brief Handler for libpri ring event - * \param spri Pri wrapper structure (libpri, span, dchan) - * \param event_type Event type (unused) - * \param pevent Event - * \return 0 on success - */ -static int on_ring(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_event *pevent) -{ - ftdm_span_t *span = spri->span; - ftdm_libpri_data_t *isdn_data = span->signal_data; - ftdm_libpri_b_chan_t *chan_priv = NULL; - ftdm_channel_t *chan = NULL; - ftdm_caller_data_t *caller_data = NULL; - int ret = 0; - - ftdm_unused_arg(event_type); - - /* - * Check if call has an associated channel (duplicate ring event) - */ - if ((chan = find_channel_by_cref(span, pevent->ring.cref))) { - ftdm_log_chan_msg(chan, FTDM_LOG_NOTICE, "-- Duplicate ring received (ignored)\n"); - return ret; - } - - if (isdn_data->mode == PRI_NETWORK) { - /* - * Always hunt for a free channel in NT-mode, - * but use the pre-selected one as hint - */ - switch (hunt_channel(span, pevent->ring.channel, !pevent->ring.flexible, &chan)) { - case FTDM_SUCCESS: /* OK channel found */ - break; - case FTDM_EBUSY: /* Exclusive channel hint is not available */ - ftdm_log(FTDM_LOG_ERROR, "-- New call without channel on span '%s' [NOTE: Initial SETUP w/o channel selection is not supported by FreeTDM]\n", - ftdm_span_get_name(span)); - pri_hangup(spri->pri, pevent->ring.call, PRI_CAUSE_CHANNEL_UNACCEPTABLE); - return ret; - default: - ftdm_log(FTDM_LOG_ERROR, "-- New call without channel on span '%s' [NOTE: Initial SETUP w/o channel selection is not supported by FreeTDM]\n", - ftdm_span_get_name(span)); - pri_hangup(spri->pri, pevent->ring.call, PRI_CAUSE_NORMAL_CIRCUIT_CONGESTION); - return ret; - } - - ftdm_channel_lock(chan); - - } else if (pevent->ring.channel == -1) { - /* - * TE-mode incoming call without channel selection (not supported) - */ - ftdm_log(FTDM_LOG_ERROR, "-- New call without channel on span '%s' [NOTE: Initial SETUP w/o channel selection is not supported by FreeTDM]\n", - ftdm_span_get_name(span)); - pri_destroycall(spri->pri, pevent->ring.call); - return ret; - } else { - /* - * TE-mode, check MSN filter, ignore calls that aren't for this PTMP terminal - */ - if (!msn_filter_match(isdn_data, pevent->ring.callednum)) { - ftdm_log(FTDM_LOG_INFO, "-- MSN filter not matching incoming DNIS '%s', ignoring call\n", - pevent->ring.callednum); - pri_destroycall(spri->pri, pevent->ring.call); - return ret; - } - - /* - * TE-mode channel selection, use whatever the NT tells us to - */ - chan = ftdm_span_get_channel(span, pevent->ring.channel); - if (!chan) { - ftdm_log(FTDM_LOG_ERROR, "-- Unable to get channel %d:%d\n", - ftdm_span_get_id(span), pevent->ring.channel); - pri_hangup(spri->pri, pevent->ring.call, PRI_CAUSE_DESTINATION_OUT_OF_ORDER); - return ret; - } - - ftdm_channel_lock(chan); - - if (ftdm_channel_get_state(chan) != FTDM_CHANNEL_STATE_DOWN || ftdm_test_flag(chan, FTDM_CHANNEL_INUSE)) { - ftdm_log_chan_msg(chan, FTDM_LOG_ERROR, "-- Selected channel is already in use\n"); - pri_hangup(spri->pri, pevent->ring.call, PRI_CAUSE_DESTINATION_OUT_OF_ORDER); - goto done; - } - - /* Reserve channel */ - if (ftdm_channel_use(chan) != FTDM_SUCCESS) { - ftdm_log_chan_msg(chan, FTDM_LOG_ERROR, "-- Error reserving channel\n"); - pri_hangup(spri->pri, pevent->ring.call, PRI_CAUSE_DESTINATION_OUT_OF_ORDER); - goto done; - } - } - - /* Get per-channel private data */ - chan_priv = chan->call_data; - - if (chan_priv->call) { - /* we could drop the incoming call, but most likely the pointer is just a ghost of the past, - * this check is just to detect potentially unreleased pointers */ - ftdm_log_chan(chan, FTDM_LOG_WARNING, "Channel already has call %p!\n", chan_priv->call); - chan_priv->call = NULL; - } - - caller_data = ftdm_channel_get_caller_data(chan); - - memset(caller_data, 0, sizeof(*caller_data)); - - /* Save CRV, so we can do proper duplicate RING detection */ - caller_data->call_reference = pevent->ring.cref; - - ftdm_set_string(caller_data->cid_num.digits, (char *)pevent->ring.callingnum); - ftdm_set_string(caller_data->ani.digits, (char *)pevent->ring.callingani); - ftdm_set_string(caller_data->dnis.digits, (char *)pevent->ring.callednum); - ftdm_set_string(caller_data->rdnis.digits, (char *)pevent->ring.redirectingnum); - - if (pevent->ring.callingpres == PRES_ALLOWED_USER_NUMBER_NOT_SCREENED) { - caller_data->pres = FTDM_PRES_ALLOWED; - caller_data->screen = FTDM_SCREENING_NOT_SCREENED; - } else if (pevent->ring.callingpres == PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN) { - caller_data->pres = FTDM_PRES_ALLOWED; - caller_data->screen = FTDM_SCREENING_VERIFIED_PASSED; - } else if (pevent->ring.callingpres == PRES_ALLOWED_USER_NUMBER_FAILED_SCREEN) { - caller_data->pres = FTDM_PRES_ALLOWED; - caller_data->screen = FTDM_SCREENING_VERIFIED_FAILED; - } else if (pevent->ring.callingpres == PRES_ALLOWED_NETWORK_NUMBER) { - caller_data->pres = FTDM_PRES_ALLOWED; - caller_data->screen = FTDM_SCREENING_NETWORK_PROVIDED; - } else if (pevent->ring.callingpres == PRES_PROHIB_USER_NUMBER_NOT_SCREENED) { - caller_data->pres = FTDM_PRES_RESTRICTED; - caller_data->screen = FTDM_SCREENING_NOT_SCREENED; - } else if (pevent->ring.callingpres == PRES_PROHIB_USER_NUMBER_PASSED_SCREEN) { - caller_data->pres = FTDM_PRES_RESTRICTED; - caller_data->screen = FTDM_SCREENING_VERIFIED_PASSED; - } else if (pevent->ring.callingpres == PRES_PROHIB_USER_NUMBER_FAILED_SCREEN) { - caller_data->pres = FTDM_PRES_RESTRICTED; - caller_data->screen = FTDM_SCREENING_VERIFIED_FAILED; - } else if (pevent->ring.callingpres == PRES_PROHIB_NETWORK_NUMBER) { - caller_data->pres = FTDM_PRES_RESTRICTED; - caller_data->screen = FTDM_SCREENING_NETWORK_PROVIDED; - } else if (pevent->ring.callingpres == PRES_NUMBER_NOT_AVAILABLE) { - caller_data->pres = FTDM_PRES_NOT_AVAILABLE; - caller_data->screen = FTDM_SCREENING_NETWORK_PROVIDED; - } else { - caller_data->pres = FTDM_PRES_INVALID; - caller_data->screen = FTDM_SCREENING_INVALID; - } - - if (pevent->ring.callingplanani != -1) { - caller_data->ani.type = pevent->ring.callingplanani >> 4; - caller_data->ani.plan = pevent->ring.callingplanani & 0x0F; - } else { - /* the remote party did not sent a valid (according to libpri) ANI ton, - * so let's use the callingplan ton/type and hope is correct. - */ - caller_data->ani.type = pevent->ring.callingplan >> 4; - caller_data->ani.plan = pevent->ring.callingplan & 0x0F; - } - - caller_data->cid_num.type = pevent->ring.callingplan >> 4; - caller_data->cid_num.plan = pevent->ring.callingplan & 0x0F; - - caller_data->dnis.type = pevent->ring.calledplan >> 4; - caller_data->dnis.plan = pevent->ring.calledplan & 0x0F; - - if (!ftdm_strlen_zero((char *)pevent->ring.callingname)) { - ftdm_set_string(caller_data->cid_name, (char *)pevent->ring.callingname); - } else { - ftdm_set_string(caller_data->cid_name, (char *)pevent->ring.callingnum); - } - - if (pevent->ring.ani2 >= 0) { - snprintf(caller_data->aniII, 5, "%.2d", pevent->ring.ani2); - } - - // scary to trust this pointer, you'd think they would give you a copy of the call data so you own it...... - /* hurr, this is valid as along as nobody releases the call */ - chan_priv->call = pevent->ring.call; - - /* Open Channel if inband information is available */ - if ((pevent->ring.progressmask & PRI_PROG_INBAND_AVAILABLE)) { - /* Open channel if inband information is available */ - ftdm_log(FTDM_LOG_DEBUG, "-- In-band information available, opening B-Channel %d:%d\n", - ftdm_channel_get_span_id(chan), - ftdm_channel_get_id(chan)); - - if (!ftdm_test_flag(chan, FTDM_CHANNEL_OPEN) && ftdm_channel_open_chan(chan) != FTDM_SUCCESS) { -// ftdm_caller_data_t *caller_data = ftdm_channel_get_caller_data(chan); - - ftdm_log(FTDM_LOG_WARNING, "-- Error opening channel %d:%d (ignored)\n", - ftdm_channel_get_span_id(chan), - ftdm_channel_get_id(chan)); - -// caller_data->hangup_cause = FTDM_CAUSE_DESTINATION_OUT_OF_ORDER; -// ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_TERMINATING); -// goto done; - } - } - - ftdm_log(FTDM_LOG_NOTICE, "-- Ring on channel %d:%d (from %s to %s)\n", ftdm_span_get_id(span), pevent->ring.channel, - pevent->ring.callingnum, pevent->ring.callednum); - - /* Only go to RING state if we have the complete called number (indicated via pevent->complete flag) */ - if (!pevent->ring.complete && (isdn_data->overlap & FTMOD_LIBPRI_OVERLAP_RECEIVE)) { - ftdm_log(FTDM_LOG_DEBUG, "RING event without complete indicator, waiting for more digits\n"); - ftdm_set_state(chan, FTDM_CHANNEL_STATE_COLLECT); - } else { - ftdm_log(FTDM_LOG_DEBUG, "RING event with complete indicator (or overlap receive disabled)\n"); - ftdm_set_state(chan, FTDM_CHANNEL_STATE_RING); - } -done: - ftdm_channel_unlock(chan); - return ret; -} - - -/** - * Timeout handler for T302 (overlap receiving) - */ -static int on_timeout_t302(struct lpwrap_pri *spri, struct lpwrap_timer *timer) -{ - ftdm_libpri_b_chan_t *chan_priv = ftdm_container_of(timer, ftdm_libpri_b_chan_t, t302); - ftdm_channel_t *chan = chan_priv->channel; - - ftdm_unused_arg(spri); - - ftdm_log_chan_msg(chan, FTDM_LOG_INFO, "-- T302 timed out, going to state RING\n"); - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_RING); - return 0; -} - -/** - * Timeout handler for T316 (RESTART ACK timer) - */ -static int on_timeout_t316(struct lpwrap_pri *spri, struct lpwrap_timer *timer) -{ - ftdm_libpri_b_chan_t *chan_priv = ftdm_container_of(timer, ftdm_libpri_b_chan_t, t316); - ftdm_libpri_data_t *isdn_data = ftdm_container_of(spri, ftdm_libpri_data_t, spri); - ftdm_channel_t *chan = chan_priv->channel; - - if (++chan_priv->t316_timeout_cnt > isdn_data->t316_max_attempts) { - ftdm_log_chan(chan, FTDM_LOG_ERROR, "-- T316 timed out, channel reached restart attempt limit '%d' and is suspended\n", - isdn_data->t316_max_attempts); - - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_SUSPENDED); - } else { - ftdm_log_chan_msg(chan, FTDM_LOG_WARNING, "-- T316 timed out, resending RESTART request\n"); - pri_reset(spri->pri, ftdm_channel_get_id(chan)); - - /* Restart T316 */ - lpwrap_start_timer(spri, timer, isdn_data->t316_timeout_ms, &on_timeout_t316); - } - return 0; -} - - -/** - * Timeout handler for T3xx (NT-mode idle restart) - */ -static int on_timeout_t3xx(struct lpwrap_pri *spri, struct lpwrap_timer *timer) -{ - ftdm_span_t *span = spri->span; - ftdm_libpri_data_t *isdn_data = span->signal_data; - ftdm_iterator_t *c_iter, *c_cur; - - ftdm_log_chan_msg(isdn_data->dchan, FTDM_LOG_INFO, "-- T3xx timed out, restarting idle b-channels\n"); - ftdm_mutex_lock(span->mutex); - - c_iter = ftdm_span_get_chan_iterator(span, NULL); - - /* Iterate b-channels */ - for (c_cur = c_iter; c_cur; c_cur = ftdm_iterator_next(c_cur)) { - ftdm_channel_t *cur = ftdm_iterator_current(c_cur); - /* Skip non-b-channels */ - if (ftdm_channel_get_type(cur) != FTDM_CHAN_TYPE_B) - continue; - /* Restart idle b-channels */ - if (ftdm_channel_get_state(cur) == FTDM_CHANNEL_STATE_DOWN && !ftdm_test_flag(cur, FTDM_CHANNEL_INUSE)) { - ftdm_set_state_locked(cur, FTDM_CHANNEL_STATE_RESTART); - } - } - ftdm_iterator_free(c_iter); - ftdm_mutex_unlock(span->mutex); - - /* Start timer again */ - lpwrap_start_timer(spri, timer, isdn_data->idle_restart_timeout_ms, &on_timeout_t3xx); - return 0; -} - - -/** - * \brief Processes freetdm event - * \param span Span on which the event was fired - * \param event Event to be treated - * \return Success or failure - */ -static __inline__ ftdm_status_t process_event(ftdm_span_t *span, ftdm_event_t *event) -{ - ftdm_alarm_flag_t alarmbits; - - ftdm_unused_arg(span); - - ftdm_log(FTDM_LOG_DEBUG, "EVENT [%s][%d][%d:%d] STATE [%s]\n", - ftdm_oob_event2str(event->enum_id), - event->enum_id, - ftdm_channel_get_span_id(event->channel), - ftdm_channel_get_id(event->channel), - ftdm_channel_get_state_str(event->channel)); - - switch (event->enum_id) { - case FTDM_OOB_ALARM_TRAP: - { - if (ftdm_channel_get_state(event->channel) != FTDM_CHANNEL_STATE_DOWN) { - if (ftdm_channel_get_type(event->channel) == FTDM_CHAN_TYPE_B) { - ftdm_set_state_locked(event->channel, FTDM_CHANNEL_STATE_RESTART); - } - } - - ftdm_set_flag(event->channel, FTDM_CHANNEL_SUSPENDED); - ftdm_channel_get_alarms(event->channel, &alarmbits); - ftdm_log_chan_msg(event->channel, FTDM_LOG_WARNING, "channel has alarms!\n"); - } - break; - case FTDM_OOB_ALARM_CLEAR: - { - ftdm_clear_flag(event->channel, FTDM_CHANNEL_SUSPENDED); - ftdm_channel_get_alarms(event->channel, &alarmbits); - ftdm_log_chan_msg(event->channel, FTDM_LOG_WARNING, "channel alarms cleared!\n"); - } - break; - } - return FTDM_SUCCESS; -} - -/** - * \brief Checks for events on a span - * \param span Span to check for events - */ -static __inline__ void check_events(ftdm_span_t *span) -{ - ftdm_status_t status; - - status = ftdm_span_poll_event(span, 5, NULL); - - switch (status) { - case FTDM_SUCCESS: - { - ftdm_event_t *event; - - while (ftdm_span_next_event(span, &event) == FTDM_SUCCESS) { - if (event->enum_id == FTDM_OOB_NOOP) { - continue; - } - if (process_event(span, event) != FTDM_SUCCESS) { - break; - } - } - } - break; - - case FTDM_FAIL: - ftdm_log(FTDM_LOG_DEBUG, "Event Failure! %d\n", ftdm_running()); - ftdm_sleep(2000); - break; - - default: - break; - } -} - -/** - * \brief Checks flags on a pri span - * \param spri Pri wrapper structure (libpri, span, dchan) - * \return 0 on success, -1 on error - */ -static int check_flags(lpwrap_pri_t *spri) -{ - ftdm_span_t *span = spri->span; - check_state(span); - check_events(span); - return 0; -} - -/** - * \brief Handler for libpri restart event - * \param spri Pri wrapper structure (libpri, span, dchan) - * \param event_type Event type (unused) - * \param pevent Event - * \return 0 - */ -static int on_restart(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_event *pevent) -{ - ftdm_channel_t *chan = NULL; - ftdm_span_t *span = spri->span; - int i; - - ftdm_unused_arg(event_type); - - if (pevent->restart.channel < 1) { - ftdm_log_chan_msg(spri->dchan, FTDM_LOG_DEBUG, "-- Restarting interface\n"); - - for (i = 1; i <= ftdm_span_get_chan_count(span); i++) { - chan = ftdm_span_get_channel(span, i); - if (!chan) - continue; - if (ftdm_channel_get_type(chan) == FTDM_CHAN_TYPE_B) { - ftdm_libpri_b_chan_t *chan_priv = chan->call_data; - chan_priv->flags |= FTDM_LIBPRI_B_REMOTE_RESTART; /* Remote triggered RESTART, set flag */ - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_RESTART); - } - } - } - else if ((chan = ftdm_span_get_channel(span, pevent->restart.channel))) { - if (ftdm_channel_get_type(chan) == FTDM_CHAN_TYPE_B) { - ftdm_libpri_b_chan_t *chan_priv = chan->call_data; - - ftdm_log_chan_msg(chan, FTDM_LOG_DEBUG, "-- Restarting single channel\n"); - chan_priv->flags |= FTDM_LIBPRI_B_REMOTE_RESTART; - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_RESTART); - } else { - ftdm_log_chan_msg(chan, FTDM_LOG_NOTICE, "Ignoring RESTART on D-Channel\n"); - } - } - else { - ftdm_log(FTDM_LOG_ERROR, "Invalid restart indicator / channel id '%d' received\n", - pevent->restart.channel); - } - - _ftdm_channel_set_state_force(spri->dchan, FTDM_CHANNEL_STATE_UP); - return 0; -} - -/** - * \brief Handler for libpri restart acknowledge event - * \param spri Pri wrapper structure (libpri, span, dchan) - * \param event_type Event type (unused) - * \param pevent Event - * \return 0 - */ -static int on_restart_ack(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_event *pevent) -{ - ftdm_channel_t *chan = NULL; - ftdm_span_t *span = spri->span; - int i; - - ftdm_unused_arg(event_type); - - if (pevent->restartack.channel < 1) { - ftdm_log_chan_msg(spri->dchan, FTDM_LOG_DEBUG, "-- Restart of interface completed\n"); - - for (i = 1; i <= ftdm_span_get_chan_count(span); i++) { - chan = ftdm_span_get_channel(span, i); - if (!chan) - continue; - if (ftdm_channel_get_type(chan) == FTDM_CHAN_TYPE_B) { - ftdm_libpri_b_chan_t *chan_priv = chan->call_data; - if (!(chan_priv->flags & FTDM_LIBPRI_B_REMOTE_RESTART)) { - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_DOWN); - } - } - } - } - else if ((chan = ftdm_span_get_channel(span, pevent->restart.channel))) { - if (ftdm_channel_get_type(chan) == FTDM_CHAN_TYPE_B) { - ftdm_log_chan_msg(chan, FTDM_LOG_DEBUG, "-- Restart of channel completed\n"); - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_DOWN); - } else { - ftdm_log_chan_msg(chan, FTDM_LOG_NOTICE, "Ignoring RESTART ACK on D-Channel\n"); - } - } - else { - ftdm_log(FTDM_LOG_ERROR, "Invalid restart indicator / channel id '%d' received\n", - pevent->restartack.channel); - } - - _ftdm_channel_set_state_force(spri->dchan, FTDM_CHANNEL_STATE_UP); - return 0; -} - - - - -/* - * FACILITY Advice-On-Charge handler - */ -#if defined(HAVE_LIBPRI_AOC) && defined(PRI_EVENT_FACILITY) -static const char *aoc_billing_id(const int id) -{ - switch (id) { - case PRI_AOC_E_BILLING_ID_NOT_AVAILABLE: - return "not available"; - case PRI_AOC_E_BILLING_ID_NORMAL: - return "normal"; - case PRI_AOC_E_BILLING_ID_REVERSE: - return "reverse"; - case PRI_AOC_E_BILLING_ID_CREDIT_CARD: - return "credit card"; - case PRI_AOC_E_BILLING_ID_CALL_FORWARDING_UNCONDITIONAL: - return "call forwarding unconditional"; - case PRI_AOC_E_BILLING_ID_CALL_FORWARDING_BUSY: - return "call forwarding busy"; - case PRI_AOC_E_BILLING_ID_CALL_FORWARDING_NO_REPLY: - return "call forwarding no reply"; - case PRI_AOC_E_BILLING_ID_CALL_DEFLECTION: - return "call deflection"; - case PRI_AOC_E_BILLING_ID_CALL_TRANSFER: - return "call transfer"; - default: - return "unknown\n"; - } -} - -static float aoc_money_amount(const struct pri_aoc_amount *amount) -{ - switch (amount->multiplier) { - case PRI_AOC_MULTIPLIER_THOUSANDTH: - return amount->cost * 0.001f; - case PRI_AOC_MULTIPLIER_HUNDREDTH: - return amount->cost * 0.01f; - case PRI_AOC_MULTIPLIER_TENTH: - return amount->cost * 0.1f; - case PRI_AOC_MULTIPLIER_TEN: - return amount->cost * 10.0f; - case PRI_AOC_MULTIPLIER_HUNDRED: - return amount->cost * 100.0f; - case PRI_AOC_MULTIPLIER_THOUSAND: - return amount->cost * 1000.0f; - default: - return amount->cost; - } -} - -static int handle_facility_aoc_s(const struct pri_subcmd_aoc_s *aoc_s) -{ - /* Left as an excercise to the reader */ - ftdm_unused_arg(aoc_s); - return 0; -} - -static int handle_facility_aoc_d(const struct pri_subcmd_aoc_d *aoc_d) -{ - /* Left as an excercise to the reader */ - ftdm_unused_arg(aoc_d); - return 0; -} - -static int handle_facility_aoc_e(const struct pri_subcmd_aoc_e *aoc_e) -{ - char tmp[1024] = { 0 }; - int x = 0, offset = 0; - - switch (aoc_e->charge) { - case PRI_AOC_DE_CHARGE_FREE: - strcat(tmp, "\tcharge-type: none\n"); - offset = strlen(tmp); - break; - - case PRI_AOC_DE_CHARGE_CURRENCY: - sprintf(tmp, "\tcharge-type: money\n\tcharge-amount: %.2f\n\tcharge-currency: %s\n", - aoc_money_amount(&aoc_e->recorded.money.amount), - aoc_e->recorded.money.currency); - offset = strlen(tmp); - break; - - case PRI_AOC_DE_CHARGE_UNITS: - strcat(tmp, "\tcharge-type: units\n"); - offset = strlen(tmp); - - for (x = 0; x < aoc_e->recorded.unit.num_items; x++) { - sprintf(&tmp[offset], "\tcharge-amount: %ld (type: %d)\n", - aoc_e->recorded.unit.item[x].number, - aoc_e->recorded.unit.item[x].type); - offset += strlen(&tmp[offset]); - } - break; - - default: - strcat(tmp, "\tcharge-type: not available\n"); - offset = strlen(tmp); - } - - sprintf(&tmp[offset], "\tbilling-id: %s\n", aoc_billing_id(aoc_e->billing_id)); - offset += strlen(&tmp[offset]); - - strcat(&tmp[offset], "\tassociation-type: "); - offset += strlen(&tmp[offset]); - - switch (aoc_e->associated.charging_type) { - case PRI_AOC_E_CHARGING_ASSOCIATION_NOT_AVAILABLE: - strcat(&tmp[offset], "not available\n"); - break; - case PRI_AOC_E_CHARGING_ASSOCIATION_NUMBER: - sprintf(&tmp[offset], "number\n\tassociation-number: %s\n", aoc_e->associated.charge.number.str); - break; - case PRI_AOC_E_CHARGING_ASSOCIATION_ID: - sprintf(&tmp[offset], "id\n\tassociation-id: %d\n", aoc_e->associated.charge.id); - break; - default: - strcat(&tmp[offset], "unknown\n"); - } - - ftdm_log(FTDM_LOG_INFO, "AOC-E:\n%s", tmp); - return 0; -} -#endif - -#ifdef PRI_EVENT_FACILITY -/** - * \brief Handler for libpri facility events - * \param spri Pri wrapper structure (libpri, span, dchan) - * \param event_type Event type (unused) - * \param pevent Event - * \return 0 - */ -static int on_facility(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_event *pevent) -{ - struct pri_event_facility *pfac = &pevent->facility; - int i = 0; - - if (!pevent) - return 0; - - ftdm_log(FTDM_LOG_DEBUG, "Got a FACILITY event on span %d:%d\n", ftdm_span_get_id(spri->span), pfac->channel); - - if (!pfac->subcmds || pfac->subcmds->counter_subcmd <= 0) - return 0; - - for (i = 0; i < pfac->subcmds->counter_subcmd; i++) { - struct pri_subcommand *sub = &pfac->subcmds->subcmd[i]; - int res = -1; - - switch (sub->cmd) { -#ifdef HAVE_LIBPRI_AOC - case PRI_SUBCMD_AOC_S: /* AOC-S: Start of call */ - res = handle_facility_aoc_s(&sub->u.aoc_s); - break; - case PRI_SUBCMD_AOC_D: /* AOC-D: During call */ - res = handle_facility_aoc_d(&sub->u.aoc_d); - break; - case PRI_SUBCMD_AOC_E: /* AOC-E: End of call */ - res = handle_facility_aoc_e(&sub->u.aoc_e); - break; - case PRI_SUBCMD_AOC_CHARGING_REQ: - ftdm_log(FTDM_LOG_NOTICE, "AOC Charging Request received\n"); - break; - case PRI_SUBCMD_AOC_CHARGING_REQ_RSP: - ftdm_log(FTDM_LOG_NOTICE, "AOC Charging Request Response received [aoc_s data: %s, req: %x, resp: %x]\n", - sub->u.aoc_request_response.valid_aoc_s ? "yes" : "no", - sub->u.aoc_request_response.charging_request, - sub->u.aoc_request_response.charging_response); - break; -#endif - default: - ftdm_log(FTDM_LOG_DEBUG, "FACILITY subcommand %d is not implemented, ignoring\n", sub->cmd); - } - - ftdm_log(FTDM_LOG_DEBUG, "FACILITY subcommand %d handler returned %d\n", sub->cmd, res); - } - - ftdm_log(FTDM_LOG_DEBUG, "Caught Event on span %d %u (%s)\n", ftdm_span_get_id(spri->span), event_type, lpwrap_pri_event_str(event_type)); - return 0; -} -#endif - -/** - * \brief Handler for libpri dchan up event - * \param spri Pri wrapper structure (libpri, span, dchan) - * \param event_type Event type (unused) - * \param pevent Event - * \return 0 - */ -static int on_dchan_up(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_event *pevent) -{ - ftdm_unused_arg(event_type); - ftdm_unused_arg(pevent); - - if (!ftdm_test_flag(spri, LPWRAP_PRI_READY)) { - ftdm_signaling_status_t status = FTDM_SIG_STATE_UP; - ftdm_span_t *span = spri->span; - ftdm_libpri_data_t *isdn_data = span->signal_data; - ftdm_sigmsg_t sig; - int i; - - ftdm_log(FTDM_LOG_INFO, "Span %d D-Channel UP!\n", ftdm_span_get_id(span)); - ftdm_set_flag(spri, LPWRAP_PRI_READY); - ftdm_set_state_all(span, FTDM_CHANNEL_STATE_RESTART); - - ftdm_log(FTDM_LOG_NOTICE, "%d:Signaling link status changed to %s\n", ftdm_span_get_id(span), ftdm_signaling_status2str(status)); - - for (i = 1; i <= ftdm_span_get_chan_count(span); i++) { - ftdm_channel_t *chan = ftdm_span_get_channel(span, i); - - memset(&sig, 0, sizeof(sig)); - sig.span_id = ftdm_channel_get_span_id(chan); - sig.chan_id = ftdm_channel_get_id(chan); - sig.channel = chan; - sig.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED; - sig.ev_data.sigstatus.status = status; - ftdm_span_send_signal(span, &sig); - } - - /* NT-mode idle b-channel restart timer */ - if (ftdm_span_get_trunk_type(span) != FTDM_TRUNK_BRI_PTMP && - isdn_data->mode == PRI_NETWORK && isdn_data->idle_restart_timeout_ms > 0) - { - ftdm_log_chan(isdn_data->dchan, FTDM_LOG_INFO, "Starting NT-mode idle b-channel restart timer (%d ms)\n", - isdn_data->idle_restart_timeout_ms); - lpwrap_start_timer(&isdn_data->spri, &isdn_data->t3xx, isdn_data->idle_restart_timeout_ms, &on_timeout_t3xx); - } - } - return 0; -} - -/** - * \brief Handler for libpri dchan down event - * \param spri Pri wrapper structure (libpri, span, dchan) - * \param event_type Event type (unused) - * \param pevent Event - * \return 0 - */ -static int on_dchan_down(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_event *pevent) -{ - ftdm_unused_arg(event_type); - ftdm_unused_arg(pevent); - - if (ftdm_test_flag(spri, LPWRAP_PRI_READY)) { - ftdm_signaling_status_t status = FTDM_SIG_STATE_DOWN; - ftdm_span_t *span = spri->span; - ftdm_libpri_data_t *isdn_data = span->signal_data; - ftdm_sigmsg_t sig; - int i; - - ftdm_log(FTDM_LOG_INFO, "Span %d D-Channel DOWN!\n", ftdm_span_get_id(span)); - ftdm_clear_flag(spri, LPWRAP_PRI_READY); - ftdm_set_state_all(span, FTDM_CHANNEL_STATE_RESTART); - - ftdm_log(FTDM_LOG_NOTICE, "%d:Signaling link status changed to %s\n", ftdm_span_get_id(span), ftdm_signaling_status2str(status)); - - for (i = 1; i <= ftdm_span_get_chan_count(span); i++) { - ftdm_channel_t *chan = ftdm_span_get_channel(span, i); - - memset(&sig, 0, sizeof(sig)); - sig.span_id = ftdm_channel_get_span_id(chan); - sig.chan_id = ftdm_channel_get_id(chan); - sig.channel = chan; - sig.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED; - sig.ev_data.sigstatus.status = status; - - ftdm_span_send_signal(span, &sig); - - if (ftdm_channel_get_type(chan) == FTDM_CHAN_TYPE_B) { - ftdm_libpri_b_chan_t *chan_priv = chan->call_data; - /* Stop T316 and reset counter */ - lpwrap_stop_timer(spri, &chan_priv->t316); - chan_priv->t316_timeout_cnt = 0; - } - } - - /* NT-mode idle b-channel restart timer */ - ftdm_log_chan_msg(isdn_data->dchan, FTDM_LOG_INFO, "Stopping NT-mode idle b-channel restart timer\n"); - lpwrap_stop_timer(&isdn_data->spri, &isdn_data->t3xx); - } - return 0; -} - -/** - * \brief Handler for any libpri event - * \param spri Pri wrapper structure (libpri, span, dchan) - * \param event_type Event type (unused) - * \param pevent Event - * \return 0 - */ -static int on_anything(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_event *pevent) -{ - ftdm_log(FTDM_LOG_DEBUG, "-- Caught Event span %d %u (%s)\n", ftdm_span_get_id(spri->span), event_type, lpwrap_pri_event_str(event_type)); - switch (pevent->e) { - case PRI_EVENT_CONFIG_ERR: - { - ftdm_log(FTDM_LOG_WARNING, "-- PRI error event: %s\n", pevent->err.err); - } - break; - } - return 0; -} - -/** - * \brief Handler for libpri io fail event - * \param spri Pri wrapper structure (libpri, span, dchan) - * \param event_type Event type (unused) - * \param pevent Event - * \return 0 - */ -static int on_io_fail(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_event *pevent) -{ - ftdm_unused_arg(pevent); - - ftdm_log(FTDM_LOG_DEBUG, "-- Caught Event span %d %u (%s)\n", ftdm_span_get_id(spri->span), event_type, lpwrap_pri_event_str(event_type)); - return 0; -} - -/** - * \brief Main thread function for libpri span (monitor) - * \param me Current thread - * \param obj Span to run in this thread - * - * \todo Move all init stuff outside of loop or into ftdm_libpri_configure_span() - */ -static void *ftdm_libpri_run(ftdm_thread_t *me, void *obj) -{ - ftdm_span_t *span = (ftdm_span_t *) obj; - ftdm_libpri_data_t *isdn_data = span->signal_data; - int down = 0; - int res = 0; - int i; - - ftdm_unused_arg(me); - - ftdm_set_flag(span, FTDM_SPAN_IN_THREAD); - isdn_data->dchan = NULL; - - /* - * Open D-Channel - */ - for (i = 1; i <= ftdm_span_get_chan_count(span); i++) { - ftdm_channel_t *chan = ftdm_span_get_channel(span, i); - - if (ftdm_channel_get_type(chan) == FTDM_CHAN_TYPE_DQ921) { - if (ftdm_channel_open(ftdm_span_get_id(span), i, &isdn_data->dchan) == FTDM_SUCCESS) { - ftdm_log_chan_msg(chan, FTDM_LOG_DEBUG, "Opened D-Channel\n"); - break; - } else { - ftdm_log_chan_msg(chan, FTDM_LOG_CRIT, "Failed to open D-Channel\n"); - goto out; - } - } - } - - /* - * Initialize BRI/PRI context - */ - res = lpwrap_init_pri(&isdn_data->spri, span, isdn_data->dchan, - isdn_data->dialect, isdn_data->mode, isdn_data->debug_mask); - - if (res) { - ftdm_log(FTDM_LOG_CRIT, "Failed to initialize BRI/PRI on span %d\n", - ftdm_span_get_id(span)); - goto out; - } - -#ifdef HAVE_LIBPRI_AOC - /* - * Only enable facility on trunk if really required, - * this may help avoid problems on troublesome lines. - */ - if (isdn_data->opts & FTMOD_LIBPRI_OPT_FACILITY_AOC) { - pri_facility_enable(isdn_data->spri.pri); - } -#endif -#ifdef HAVE_LIBPRI_MAINT_SERVICE - /* Support the different switch of service status */ - if (isdn_data->service_message_support) { - pri_set_service_message_support(isdn_data->spri.pri, 1); - } -#endif - - /* Callbacks for libpri events */ - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_ANY, on_anything); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_RING, on_ring); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_RINGING, on_ringing); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_PROCEEDING, on_proceeding); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_PROGRESS, on_progress); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_ANSWER, on_answer); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_DCHAN_UP, on_dchan_up); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_DCHAN_DOWN, on_dchan_down); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_HANGUP_REQ, on_hangup); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_HANGUP_ACK, on_hangup); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_HANGUP, on_hangup); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_INFO_RECEIVED, on_information); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_KEYPAD_DIGIT, on_keypad_digit); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_RESTART, on_restart); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_RESTART_ACK, on_restart_ack); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_IO_FAIL, on_io_fail); -#ifdef PRI_EVENT_FACILITY - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_FACILITY, on_facility); -#endif - - /* Callback invoked on each iteration of the lpwrap_run_pri() event loop */ - isdn_data->spri.on_loop = check_flags; - - /* - * Event loop - */ - while (ftdm_running() && !ftdm_test_flag(span, FTDM_SPAN_STOP_THREAD)) { - if (down) { - ftdm_log(FTDM_LOG_INFO, "PRI back up on span %d\n", ftdm_span_get_id(span)); - ftdm_set_state_all(span, FTDM_CHANNEL_STATE_RESTART); - down = 0; - } - - lpwrap_run_pri(&isdn_data->spri); - - if (!ftdm_running() || ftdm_test_flag(span, FTDM_SPAN_STOP_THREAD)) { - break; - } - - ftdm_log(FTDM_LOG_CRIT, "PRI down on span %d\n", ftdm_span_get_id(span)); - if (isdn_data->spri.dchan) { - _ftdm_channel_set_state_force(isdn_data->spri.dchan, FTDM_CHANNEL_STATE_DOWN); - } - - if (!down) { - ftdm_set_state_all(span, FTDM_CHANNEL_STATE_RESTART); - check_state(span); - } - - check_state(span); - check_events(span); - - down = 1; - ftdm_sleep(5000); - } -out: - /* close d-channel, if set */ - if (isdn_data->dchan) { - if (ftdm_channel_close(&isdn_data->dchan) != FTDM_SUCCESS) { - ftdm_log_chan_msg(isdn_data->dchan, FTDM_LOG_ERROR, "Failed to close D-Channel\n"); - } - } - - ftdm_log(FTDM_LOG_DEBUG, "PRI thread ended on span %d\n", ftdm_span_get_id(span)); - - ftdm_clear_flag(span, FTDM_SPAN_IN_THREAD); - ftdm_clear_flag(isdn_data, FTMOD_LIBPRI_RUNNING); - - lpwrap_destroy_pri(&isdn_data->spri); - return NULL; -} - -/** - * \brief Stops a libpri span - * \param span Span to halt - * \return Success - * - * Sets a stop flag and waits for the thread to end - */ -static ftdm_status_t ftdm_libpri_stop(ftdm_span_t *span) -{ - ftdm_libpri_data_t *isdn_data = span->signal_data; - - if (!ftdm_test_flag(isdn_data, FTMOD_LIBPRI_RUNNING)) { - ftdm_log(FTDM_LOG_DEBUG, "Span %d already stopped, continuing anyway...\n", ftdm_span_get_id(span)); - return FTDM_SUCCESS; - } - - ftdm_log(FTDM_LOG_INFO, "Stopping span [s%d][%s]\n", - ftdm_span_get_id(span), ftdm_span_get_name(span)); - - ftdm_set_state_all(span, FTDM_CHANNEL_STATE_RESTART); - check_state(span); - - ftdm_set_flag(span, FTDM_SPAN_STOP_THREAD); - lpwrap_stop_pri(&isdn_data->spri); - - while (ftdm_test_flag(span, FTDM_SPAN_IN_THREAD)) { - ftdm_sleep(100); - } - - check_state(span); - - return FTDM_SUCCESS; -} - -/** - * \brief Starts a libpri span - * \param span Span to halt - * \return Success or failure - * - * Launches a thread to monitor the span - */ -static ftdm_status_t ftdm_libpri_start(ftdm_span_t *span) -{ - ftdm_libpri_data_t *isdn_data = span->signal_data; - - if (ftdm_test_flag(isdn_data, FTMOD_LIBPRI_RUNNING)) { - return FTDM_FAIL; - } - - ftdm_log(FTDM_LOG_INFO, "Starting span [s%d][%s]\n", - ftdm_span_get_id(span), ftdm_span_get_name(span)); - - ftdm_clear_flag(span, FTDM_SPAN_STOP_THREAD); - ftdm_clear_flag(span, FTDM_SPAN_IN_THREAD); - - ftdm_set_flag(isdn_data, FTMOD_LIBPRI_RUNNING); - - return ftdm_thread_create_detached(ftdm_libpri_run, span); -} - -/** - * \brief Converts a node string to node value - * \param node Node string to convert - * \return -1 on failure, node value on success - */ -static int parse_mode(const char *mode) -{ - if (!strcasecmp(mode, "cpe") || !strcasecmp(mode, "user")) - return PRI_CPE; - if (!strcasecmp(mode, "network") || !strcasecmp(mode, "net")) - return PRI_NETWORK; - - return -1; -} - -/** - * \brief Converts a switch string to switch value - * \param swtype Swtype string to convert - * \return Switch value - */ -static int parse_dialect(const char *dialect) -{ - if (!strcasecmp(dialect, "ni1")) - return PRI_SWITCH_NI1; - if (!strcasecmp(dialect, "ni2")) - return PRI_SWITCH_NI2; - if (!strcasecmp(dialect, "dms100")) - return PRI_SWITCH_DMS100; - if (!strcasecmp(dialect, "lucent5e") || !strcasecmp(dialect, "5ess")) - return PRI_SWITCH_LUCENT5E; - if (!strcasecmp(dialect, "att4ess") || !strcasecmp(dialect, "4ess")) - return PRI_SWITCH_ATT4ESS; - if (!strcasecmp(dialect, "euroisdn") || !strcasecmp(dialect, "q931")) - return PRI_SWITCH_EUROISDN_E1; - if (!strcasecmp(dialect, "gr303eoc")) - return PRI_SWITCH_GR303_EOC; - if (!strcasecmp(dialect, "gr303tmc")) - return PRI_SWITCH_GR303_TMC; - - return PRI_SWITCH_DMS100; -} - -/** - * \brief Converts a L1 string to L1 value - * \param l1 L1 string to convert - * \return L1 value - */ -static int parse_layer1(const char *val) -{ - if (!strcasecmp(val, "alaw")) - return PRI_LAYER_1_ALAW; - - return PRI_LAYER_1_ULAW; -} - -/** - * \brief Converts a DP string to DP value - * \param dp DP string to convert - * \return DP value - */ -static int parse_ton(const char *ton) -{ - if (!strcasecmp(ton, "international")) - return PRI_INTERNATIONAL_ISDN; - if (!strcasecmp(ton, "national")) - return PRI_NATIONAL_ISDN; - if (!strcasecmp(ton, "local")) - return PRI_LOCAL_ISDN; - if (!strcasecmp(ton, "private")) - return PRI_PRIVATE; - if (!strcasecmp(ton, "unknown")) - return PRI_UNKNOWN; - - return PRI_UNKNOWN; -} - -/** - * \brief Parse overlap string to value - * \param val String to parse - * \return Overlap flags - */ -static int parse_overlap_dial(const char *val) -{ - if (!strcasecmp(val, "yes") || !strcasecmp(val, "both")) - return FTMOD_LIBPRI_OVERLAP_BOTH; - if (!strcasecmp(val, "incoming") || !strcasecmp(val, "receive")) - return FTMOD_LIBPRI_OVERLAP_RECEIVE; - if (!strcasecmp(val, "outgoing") || !strcasecmp(val, "send")) - return FTMOD_LIBPRI_OVERLAP_SEND; - if (!strcasecmp(val, "no")) - return FTMOD_LIBPRI_OVERLAP_NONE; - - return -1; -} - -/** - * \brief Parses an option string to flags - * \param in String to parse for configuration options - * \return Flags - */ -static uint32_t parse_opts(const char *in) -{ - uint32_t flags = 0; - - if (!in) { - return 0; - } - - if (strstr(in, "suggest_channel")) { - flags |= FTMOD_LIBPRI_OPT_SUGGEST_CHANNEL; - } - if (strstr(in, "omit_display")) { - flags |= FTMOD_LIBPRI_OPT_OMIT_DISPLAY_IE; - } - if (strstr(in, "omit_redirecting_number")) { - flags |= FTMOD_LIBPRI_OPT_OMIT_REDIRECTING_NUMBER_IE; - } - if (strstr(in, "aoc")) { - flags |= FTMOD_LIBPRI_OPT_FACILITY_AOC; - } - return flags; -} - -/** - * Parse timeout value with (convenience) modifier suffix - * \param[in] in Input string, e.g. '1d' = 1 day, '7w' = 7 weeks, '3s' = 3 seconds - * \todo Could be simplified by using strtol() instead of atoi() - */ -static int parse_timeout(const char *in) -{ - const char *p_end = NULL, *p_start = in; - int msec = 0; - - if (ftdm_strlen_zero(in)) - return 0; - - p_end = in + strlen(in); - - /* skip whitespace at start */ - while (p_start != p_end && *p_start == ' ') - p_start++; - - /* skip whitespace at end */ - while (p_end != p_start && (*p_end == ' ' || *p_end == '\0')) - p_end--; - - msec = atoi(p_start); - - switch (p_end[0]) { - case 's': /* seconds */ - msec *= 1000; - break; - case 'm': /* minutes */ - if (p_end[1] != 's') msec *= 60 * 1000; - break; - case 'h': /* hours */ - msec *= 3600 * 1000; - break; - case 'd': /* days */ - msec *= 86400 * 1000; - break; - case 'w': /* weeks */ - msec *= 604800 * 1000; - break; - default: /* miliseconds */ - break; - } - return msec; -} - -/** - * \brief Initialises a libpri span from configuration variables - * \param span Span to configure - * \param sig_cb Callback function for event signals - * \param ftdm_parameters List of configuration variables - * \return Success or failure - */ -static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_libpri_configure_span) -{ - ftdm_libpri_data_t *isdn_data = NULL; - uint32_t bchan_count = 0; - uint32_t dchan_count = 0; - uint32_t i; - - if (ftdm_span_get_trunk_type(span) >= FTDM_TRUNK_NONE) { - ftdm_log(FTDM_LOG_WARNING, "Invalid trunk type '%s' defaulting to T1.\n", ftdm_span_get_trunk_type_str(span)); - ftdm_span_set_trunk_type(span, FTDM_TRUNK_T1); - } - - for (i = 1; i <= ftdm_span_get_chan_count(span); i++) { - ftdm_channel_t *chan = ftdm_span_get_channel(span, i); - - switch (ftdm_channel_get_type(chan)) { - case FTDM_CHAN_TYPE_DQ921: - if (dchan_count > 1) { - ftdm_log(FTDM_LOG_ERROR, "Span has more than 2 D-Channels!\n"); - return FTDM_FAIL; - } - dchan_count++; - break; - case FTDM_CHAN_TYPE_B: - bchan_count++; - break; - default: /* Ignore other channel types */ - break; - } - } - if (!dchan_count) { - ftdm_log(FTDM_LOG_ERROR, "Span has no D-Channel!\n"); - return FTDM_FAIL; - } - if (!bchan_count) { - ftdm_log(FTDM_LOG_ERROR, "Span has no B-Channels!\n"); - return FTDM_FAIL; - } - - isdn_data = ftdm_malloc(sizeof(*isdn_data)); - assert(isdn_data != NULL); - memset(isdn_data, 0, sizeof(*isdn_data)); - - /* set some default values */ - isdn_data->ton = PRI_UNKNOWN; - isdn_data->overlap_timeout_ms = OVERLAP_TIMEOUT_MS_DEFAULT; - isdn_data->idle_restart_timeout_ms = IDLE_RESTART_TIMEOUT_MS_DEFAULT; - - /* - * T316 restart ack timeout and retry limit - * (ITU-T Q.931 05/98 Paragraph 5.5.1 and Table 9-1) - */ - isdn_data->t316_timeout_ms = T316_TIMEOUT_MS_DEFAULT; - isdn_data->t316_max_attempts = T316_ATTEMPT_LIMIT_DEFAULT; - - - /* Use span's trunk_mode as a reference for the default libpri mode */ - if (ftdm_span_get_trunk_mode(span) == FTDM_TRUNK_MODE_NET) { - isdn_data->mode = PRI_NETWORK; - } else { - isdn_data->mode = PRI_CPE; - } - - switch (ftdm_span_get_trunk_type(span)) { - case FTDM_TRUNK_BRI: - case FTDM_TRUNK_BRI_PTMP: -#ifndef HAVE_LIBPRI_BRI - ftdm_log(FTDM_LOG_ERROR, "Unsupported trunk type: '%s', libpri too old\n", ftdm_span_get_trunk_type_str(span)); - goto error; -#endif - case FTDM_TRUNK_E1: - ftdm_log(FTDM_LOG_NOTICE, "Setting default Layer 1 to ALAW since this is an E1/BRI/BRI PTMP trunk\n"); - isdn_data->layer1 = PRI_LAYER_1_ALAW; - isdn_data->dialect = PRI_SWITCH_EUROISDN_E1; - break; - case FTDM_TRUNK_T1: - case FTDM_TRUNK_J1: - ftdm_log(FTDM_LOG_NOTICE, "Setting default Layer 1 to ULAW since this is a T1/J1 trunk\n"); - isdn_data->layer1 = PRI_LAYER_1_ULAW; - isdn_data->dialect = PRI_SWITCH_LUCENT5E; - break; - default: - ftdm_log(FTDM_LOG_ERROR, "Invalid trunk type: '%s'\n", ftdm_span_get_trunk_type_str(span)); - goto error; - } - - /* - * Init MSN filter - */ - if (msn_filter_init(isdn_data) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "Failed to init MSN filter\n"); - goto error; - } - - for (i = 0; ftdm_parameters[i].var; i++) { - const char *var = ftdm_parameters[i].var; - const char *val = ftdm_parameters[i].val; - - if (ftdm_strlen_zero(var)) { - ftdm_log(FTDM_LOG_WARNING, "Skipping parameter with no name\n"); - continue; - } - - if (ftdm_strlen_zero(val)) { - ftdm_log(FTDM_LOG_ERROR, "Parameter '%s' has no value\n", var); - goto error; - } - - if (!strcasecmp(var, "node") || !strcasecmp(var, "mode")) { - if ((isdn_data->mode = parse_mode(val)) == -1) { - ftdm_log(FTDM_LOG_ERROR, "Unknown node type '%s'\n", val); - goto error; - } - } - else if (!strcasecmp(var, "switch") || !strcasecmp(var, "dialect")) { - isdn_data->dialect = parse_dialect(val); - } - else if (!strcasecmp(var, "opts")) { - isdn_data->opts = parse_opts(val); - } - else if (!strcasecmp(var, "dp") || !strcasecmp(var, "ton")) { - isdn_data->ton = parse_ton(val); - } - else if (!strcasecmp(var, "l1") || !strcasecmp(var, "layer1")) { - isdn_data->layer1 = parse_layer1(val); - } - else if (!strcasecmp(var, "overlapdial")) { - if ((isdn_data->overlap = parse_overlap_dial(val)) == -1) { - ftdm_log(FTDM_LOG_ERROR, "Invalid overlap flag, ignoring parameter\n"); - isdn_data->overlap = FTMOD_LIBPRI_OVERLAP_NONE; - } - } - else if (!strcasecmp(var, "digit_timeout") || !strcasecmp(var, "t302")) { - int tmp = parse_timeout(val); - if (!tmp) { - isdn_data->overlap_timeout_ms = 0; /* disabled */ - } - else if ((isdn_data->overlap_timeout_ms = ftdm_clamp(tmp, OVERLAP_TIMEOUT_MS_MIN, OVERLAP_TIMEOUT_MS_MAX)) != tmp) { - ftdm_log(FTDM_LOG_WARNING, "'%s' value %d ms ('%s') outside of range [%d:%d] ms, using %d ms instead\n", - var, tmp, val, OVERLAP_TIMEOUT_MS_MIN, OVERLAP_TIMEOUT_MS_MAX, - isdn_data->overlap_timeout_ms); - } - } - else if (!strcasecmp(var, "idle_restart_interval")) { - int tmp = parse_timeout(val); - if (!tmp) { - isdn_data->idle_restart_timeout_ms = 0; /* disabled */ - } - else if ((isdn_data->idle_restart_timeout_ms = ftdm_clamp(tmp, IDLE_RESTART_TIMEOUT_MS_MIN, IDLE_RESTART_TIMEOUT_MS_MAX)) != tmp) { - ftdm_log(FTDM_LOG_WARNING, "'%s' value %d ms ('%s') outside of range [%d:%d] ms, using %d ms instead\n", - var, tmp, val, IDLE_RESTART_TIMEOUT_MS_MIN, IDLE_RESTART_TIMEOUT_MS_MAX, - isdn_data->idle_restart_timeout_ms); - } - } - else if (!strcasecmp(var, "restart_timeout") || !strcasecmp(var, "t316")) { - int tmp = parse_timeout(val); - if (tmp <= 0) { - ftdm_log(FTDM_LOG_ERROR, "'%s' value '%s' is invalid\n", var, val); - goto error; - } - else if ((isdn_data->t316_timeout_ms = ftdm_clamp(tmp, T316_TIMEOUT_MS_MIN, T316_TIMEOUT_MS_MAX)) != tmp) { - ftdm_log(FTDM_LOG_WARNING, "'%s' value %d ms ('%s') outside of range [%d:%d] ms, using %d ms instead\n", - var, tmp, val, T316_TIMEOUT_MS_MIN, T316_TIMEOUT_MS_MAX, - isdn_data->t316_timeout_ms); - } - } - else if (!strcasecmp(var, "restart_attempts") || !strcasecmp(var, "t316_limit")) { - int tmp = atoi(val); - if (tmp <= 0) { - ftdm_log(FTDM_LOG_ERROR, "'%s' value '%s' is invalid\n", var, val); - goto error; - } - else if ((isdn_data->t316_max_attempts = ftdm_clamp(tmp, T316_ATTEMPT_LIMIT_MIN, T316_ATTEMPT_LIMIT_MAX)) != tmp) { - ftdm_log(FTDM_LOG_WARNING, "'%s' value %d ('%s') outside of range [%d:%d], using %d instead\n", - var, tmp, val, T316_ATTEMPT_LIMIT_MIN, T316_ATTEMPT_LIMIT_MAX, - isdn_data->t316_max_attempts); - } - } - else if (!strcasecmp(var, "debug")) { - if (parse_debug(val, &isdn_data->debug_mask) == -1) { - ftdm_log(FTDM_LOG_ERROR, "Invalid debug flag, ignoring parameter\n"); - isdn_data->debug_mask = 0; - } - } - else if (!strcasecmp(var, "service_message_support")) { - if (ftdm_true(val)) { - isdn_data->service_message_support = 1; - } - } - else if (!strcasecmp(var, "local-number") || !strcasecmp(var, "msn")) { - if (msn_filter_add(isdn_data, val) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "Invalid MSN/DDI(s) '%s' specified\n", val); - goto error; - } - } - else { - ftdm_log(FTDM_LOG_ERROR, "Unknown parameter '%s', aborting configuration\n", var); - goto error; - } - } - - /* Check if modes match and log a message if they do not. Just to be on the safe side. */ - if (isdn_data->mode == PRI_CPE && ftdm_span_get_trunk_mode(span) == FTDM_TRUNK_MODE_NET) { - ftdm_log(FTDM_LOG_WARNING, "Span '%s' signalling set up for TE/CPE/USER mode, while port is running in NT/NET mode. You may want to check your 'trunk_mode' settings.\n", - ftdm_span_get_name(span)); - } - else if (isdn_data->mode == PRI_NETWORK && ftdm_span_get_trunk_mode(span) == FTDM_TRUNK_MODE_CPE) { - ftdm_log(FTDM_LOG_WARNING, "Span '%s' signalling set up for NT/NET mode, while port is running in TE/CPE/USER mode. You may want to check your 'trunk_mode' settings.\n", - ftdm_span_get_name(span)); - } - - span->start = ftdm_libpri_start; - span->stop = ftdm_libpri_stop; - span->signal_cb = sig_cb; - - span->signal_data = isdn_data; - span->signal_type = FTDM_SIGTYPE_ISDN; - span->outgoing_call = isdn_outgoing_call; - - span->state_map = &isdn_state_map; - span->state_processor = state_advance; - - span->get_channel_sig_status = isdn_get_channel_sig_status; - span->get_span_sig_status = isdn_get_span_sig_status; - - /* move calls to PROCEED state when they hit dialplan (ROUTING state in FreeSWITCH) */ - ftdm_set_flag(span, FTDM_SPAN_USE_PROCEED_STATE); - - if ((isdn_data->opts & FTMOD_LIBPRI_OPT_SUGGEST_CHANNEL)) { - span->channel_request = isdn_channel_request; - ftdm_set_flag(span, FTDM_SPAN_SUGGEST_CHAN_ID); - } - - /* Allocate per-channel private data */ - for (i = 1; i <= ftdm_span_get_chan_count(span); i++) { - ftdm_channel_t *chan = ftdm_span_get_channel(span, i); - - if (!chan) - continue; - - if (ftdm_channel_get_type(chan) == FTDM_CHAN_TYPE_B) { - ftdm_libpri_b_chan_t *priv = NULL; - - priv = calloc(1, sizeof(*priv)); - if (!priv) { - ftdm_log_chan_msg(chan, FTDM_LOG_CRIT, "Failed to allocate per-channel private data\n"); - goto error; - } - priv->channel = chan; - chan->call_data = priv; - } - } - return FTDM_SUCCESS; -error: - /* TODO: free per-channel private data */ - msn_filter_destroy(isdn_data); - ftdm_safe_free(isdn_data); - return FTDM_FAIL; -} - -/** - * \brief FreeTDM libpri signaling and IO module definition - */ -ftdm_module_t ftdm_module = { - "libpri", - ftdm_libpri_io_init, - ftdm_libpri_unload, - ftdm_libpri_init, - NULL, - NULL, - ftdm_libpri_configure_span -}; - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.h b/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.h deleted file mode 100644 index 8ace29693b..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.h +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (c) 2009-2012, Anthony Minessale II - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef FTMOD_LIBPRI_H -#define FTMOD_LIBPRI_H -#include "freetdm.h" -#include "lpwrap_pri.h" - -/* T302 Overlap receiving inter-digit timeout */ -#define OVERLAP_TIMEOUT_MS_DEFAULT 5000 /* 5 sec */ -#define OVERLAP_TIMEOUT_MS_MIN 3000 /* 3 sec */ -#define OVERLAP_TIMEOUT_MS_MAX 30000 /* 30 sec */ - -/* NT-mode idle b-channel restart timer */ -#define IDLE_RESTART_TIMEOUT_MS_DEFAULT 0 /* disabled */ -#define IDLE_RESTART_TIMEOUT_MS_MIN 10000 /* 10 sec */ -#define IDLE_RESTART_TIMEOUT_MS_MAX 86400000 /* 1 day */ - -/* T316 RESTART ACK wait timer */ -#define T316_TIMEOUT_MS_DEFAULT 30000 /* 30 sec */ -#define T316_TIMEOUT_MS_MIN 10000 /* 10 sec */ -#define T316_TIMEOUT_MS_MAX 300000 /* 5 min */ - -/* T316 restart attempts until channel is suspended */ -#define T316_ATTEMPT_LIMIT_DEFAULT 3 -#define T316_ATTEMPT_LIMIT_MIN 1 -#define T316_ATTEMPT_LIMIT_MAX 10 - - -typedef enum { - SERVICE_CHANGE_STATUS_INSERVICE = 0, - SERVICE_CHANGE_STATUS_MAINTENANCE, - SERVICE_CHANGE_STATUS_OUTOFSERVICE -} service_change_status_t; - -typedef enum { - FTMOD_LIBPRI_OPT_NONE = 0, - FTMOD_LIBPRI_OPT_SUGGEST_CHANNEL = (1 << 0), - FTMOD_LIBPRI_OPT_OMIT_DISPLAY_IE = (1 << 1), - FTMOD_LIBPRI_OPT_OMIT_REDIRECTING_NUMBER_IE = (1 << 2), - FTMOD_LIBPRI_OPT_FACILITY_AOC = (1 << 3), - - FTMOD_LIBPRI_OPT_MAX = (1 << 4) -} ftdm_isdn_opts_t; - -typedef enum { - FTMOD_LIBPRI_RUNNING = (1 << 0) -} ftdm_isdn_flag_t; - -typedef enum { - FTMOD_LIBPRI_OVERLAP_NONE = 0, - FTMOD_LIBPRI_OVERLAP_RECEIVE = (1 << 0), - FTMOD_LIBPRI_OVERLAP_SEND = (1 << 1) -#define FTMOD_LIBPRI_OVERLAP_BOTH (FTMOD_LIBPRI_OVERLAP_RECEIVE | FTMOD_LIBPRI_OVERLAP_SEND) -} ftdm_isdn_overlap_t; - -struct ftdm_libpri_data { - ftdm_channel_t *dchan; - ftdm_isdn_opts_t opts; - uint32_t flags; - uint32_t debug_mask; - - int mode; - int dialect; - int overlap; /*!< Overlap dial flags */ - int overlap_timeout_ms; /*!< Overlap dial timeout */ - int idle_restart_timeout_ms; /*!< NT-mode idle b-channel restart */ - int t316_timeout_ms; /*!< T316 RESTART ACK timeout */ - int t316_max_attempts; /*!< T316 timeout limit */ - unsigned int layer1; - unsigned int ton; - unsigned int service_message_support; - - lpwrap_pri_t spri; - - /* MSN filter */ - ftdm_hash_t *msn_hash; - ftdm_mutex_t *msn_mutex; - - /* NT-mode idle restart timer */ - struct lpwrap_timer t3xx; -}; - -typedef struct ftdm_libpri_data ftdm_libpri_data_t; - - -/* - * b-channel flags - */ -enum { - FTDM_LIBPRI_B_NONE = 0, - FTDM_LIBPRI_B_REMOTE_RESTART = (1 << 0), /*!< Remote triggered channel restart */ -}; - -/** - * Per-b-channel private data - */ -struct ftdm_libpri_b_chan { - struct lpwrap_timer t302; /*!< T302 overlap receive timer */ - struct lpwrap_timer t316; /*!< T316 restart ack timer */ - ftdm_channel_t *channel; /*!< back-pointer to b-channel */ - q931_call *call; /*!< libpri opaque call handle */ - uint32_t flags; /*!< channel flags */ - uint32_t t316_timeout_cnt; /*!< T316 timeout counter */ - int peerhangup; /*!< hangup requested from libpri (RELEASE/RELEASE_ACK/DL_RELEASE/TIMERS EXPIRY) */ -}; - -typedef struct ftdm_libpri_b_chan ftdm_libpri_b_chan_t; - -#endif - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ - diff --git a/libs/freetdm/src/ftmod/ftmod_libpri/lpwrap_pri.c b/libs/freetdm/src/ftmod/ftmod_libpri/lpwrap_pri.c deleted file mode 100644 index a59baccbe5..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_libpri/lpwrap_pri.c +++ /dev/null @@ -1,464 +0,0 @@ -/* - * Copyright (c) 2009-2012, Anthony Minessale II - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -//#define IODEBUG - -#include "private/ftdm_core.h" -#include "lpwrap_pri.h" - -static struct lpwrap_pri_event_list LPWRAP_PRI_EVENT_LIST[LPWRAP_PRI_EVENT_MAX] = { - {0, LPWRAP_PRI_EVENT_ANY, "ANY"}, - {1, LPWRAP_PRI_EVENT_DCHAN_UP, "DCHAN_UP"}, - {2, LPWRAP_PRI_EVENT_DCHAN_DOWN, "DCHAN_DOWN"}, - {3, LPWRAP_PRI_EVENT_RESTART, "RESTART"}, - {4, LPWRAP_PRI_EVENT_CONFIG_ERR, "CONFIG_ERR"}, - {5, LPWRAP_PRI_EVENT_RING, "RING"}, - {6, LPWRAP_PRI_EVENT_HANGUP, "HANGUP"}, - {7, LPWRAP_PRI_EVENT_RINGING, "RINGING"}, - {8, LPWRAP_PRI_EVENT_ANSWER, "ANSWER"}, - {9, LPWRAP_PRI_EVENT_HANGUP_ACK, "HANGUP_ACK"}, - {10, LPWRAP_PRI_EVENT_RESTART_ACK, "RESTART_ACK"}, - {11, LPWRAP_PRI_EVENT_FACILITY, "FACILITY"}, - {12, LPWRAP_PRI_EVENT_INFO_RECEIVED, "INFO_RECEIVED"}, - {13, LPWRAP_PRI_EVENT_PROCEEDING, "PROCEEDING"}, - {14, LPWRAP_PRI_EVENT_SETUP_ACK, "SETUP_ACK"}, - {15, LPWRAP_PRI_EVENT_HANGUP_REQ, "HANGUP_REQ"}, - {16, LPWRAP_PRI_EVENT_NOTIFY, "NOTIFY"}, - {17, LPWRAP_PRI_EVENT_PROGRESS, "PROGRESS"}, - {18, LPWRAP_PRI_EVENT_KEYPAD_DIGIT, "KEYPAD_DIGIT"}, - {19, LPWRAP_PRI_EVENT_IO_FAIL, "IO_FAIL"}, -}; - -const char *lpwrap_pri_event_str(lpwrap_pri_event_t event_id) -{ - if (event_id >= LPWRAP_PRI_EVENT_MAX) - return ""; - - return LPWRAP_PRI_EVENT_LIST[event_id].name; -} - -static int __pri_lpwrap_read(struct pri *pri, void *buf, int buflen) -{ - struct lpwrap_pri *spri = (struct lpwrap_pri *) pri_get_userdata(pri); - ftdm_size_t len = buflen; - ftdm_status_t zst; - int res; - - if ((zst = ftdm_channel_read(spri->dchan, buf, &len)) != FTDM_SUCCESS) { - if (zst == FTDM_FAIL) { - ftdm_log(FTDM_LOG_CRIT, "span %d D-READ FAIL! [%s]\n", spri->span->span_id, spri->dchan->last_error); - spri->errs++; - } else { - ftdm_log(FTDM_LOG_CRIT, "span %d D-READ TIMEOUT\n", spri->span->span_id); - } - /* we cannot return -1, libpri seems to expect values >= 0 */ - return 0; - } - spri->errs = 0; - res = (int)len; - - if (res > 0) { - memset(&((unsigned char*)buf)[res], 0, 2); - res += 2; -#ifdef IODEBUG - { - char bb[2048] = { 0 }; - - print_hex_bytes(buf, res - 2, bb, sizeof(bb)); - ftdm_log(FTDM_LOG_DEBUG, "READ %d\n", res - 2); - } -#endif - } - return res; -} - -static int __pri_lpwrap_write(struct pri *pri, void *buf, int buflen) -{ - struct lpwrap_pri *spri = (struct lpwrap_pri *) pri_get_userdata(pri); - ftdm_size_t len = buflen - 2; - - if (ftdm_channel_write(spri->dchan, buf, buflen, &len) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_CRIT, "span %d D-WRITE FAIL! [%s]\n", spri->span->span_id, spri->dchan->last_error); - /* we cannot return -1, libpri seems to expect values >= 0 */ - return 0; - } - -#ifdef IODEBUG - { - char bb[2048] = { 0 }; - - print_hex_bytes(buf, buflen - 2, bb, sizeof(bb)); - ftdm_log(FTDM_LOG_DEBUG, "WRITE %d\n", (int)buflen - 2); - } -#endif - return (int)buflen; -} - - -/* - * Unified init function for BRI + PRI libpri spans - */ -int lpwrap_init_pri(struct lpwrap_pri *spri, ftdm_span_t *span, ftdm_channel_t *dchan, int swtype, int node, int debug) -{ - int ret = -1; - - memset(spri, 0, sizeof(struct lpwrap_pri)); - spri->dchan = dchan; - spri->span = span; - - if (!spri->dchan) { - ftdm_log(FTDM_LOG_ERROR, "No D-Channel available, unable to create BRI/PRI\n"); - return ret; - } - - if (ftdm_mutex_create(&spri->timer_mutex) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "Failed to create timer list mutex\n"); - return ret; - } - - switch (ftdm_span_get_trunk_type(span)) { - case FTDM_TRUNK_E1: - case FTDM_TRUNK_J1: - case FTDM_TRUNK_T1: - spri->pri = pri_new_cb(spri->dchan->sockfd, node, swtype, __pri_lpwrap_read, __pri_lpwrap_write, spri); - break; -#ifdef HAVE_LIBPRI_BRI - case FTDM_TRUNK_BRI: - spri->pri = pri_new_bri_cb(spri->dchan->sockfd, 1, node, swtype, __pri_lpwrap_read, __pri_lpwrap_write, spri); - break; - case FTDM_TRUNK_BRI_PTMP: - spri->pri = pri_new_bri_cb(spri->dchan->sockfd, 0, node, swtype, __pri_lpwrap_read, __pri_lpwrap_write, spri); - break; -#endif - default: - ftdm_log(FTDM_LOG_CRIT, "Invalid/unsupported trunk type '%s'\n", - ftdm_span_get_trunk_type_str(span)); - ftdm_mutex_destroy(&spri->timer_mutex); - return ret; - } - - if (spri->pri) { - pri_set_debug(spri->pri, debug); -#ifdef HAVE_LIBPRI_BRI - /* "follow Q.931 Section 5.3.2 call hangup better" */ - pri_hangup_fix_enable(spri->pri, 1); -#endif -#ifdef HAVE_LIBPRI_AOC - pri_aoc_events_enable(spri->pri, 1); -#endif - ret = 0; - } else { - ftdm_log(FTDM_LOG_CRIT, "Unable to create BRI/PRI\n"); - ftdm_mutex_destroy(&spri->timer_mutex); - } - return ret; -} - - -#define timeval_to_ms(x) \ - (ftdm_time_t)(((x)->tv_sec * 1000) + ((x)->tv_usec / 1000)) - -int lpwrap_start_timer(struct lpwrap_pri *spri, struct lpwrap_timer *timer, const uint32_t timeout_ms, timeout_handler callback) -{ - struct lpwrap_timer **prev, *cur; - - if (!spri || !timer || timer->timeout) - return -1; - - ftdm_log_chan(spri->dchan, FTDM_LOG_DEBUG, "-- Starting timer %p with timeout %u ms\n", - timer, timeout_ms); - - timer->timeout = ftdm_current_time_in_ms() + timeout_ms; - timer->callback = callback; - timer->next = NULL; - - ftdm_mutex_lock(spri->timer_mutex); - - for (prev = &spri->timer_list, cur = spri->timer_list; cur; prev = &(*prev)->next, cur = cur->next) { - if (cur->timeout > timer->timeout) { - *prev = timer; - timer->next = cur; - break; - } - } - if (!cur) { - *prev = timer; - } - - ftdm_mutex_unlock(spri->timer_mutex); - return 0; -} - -int lpwrap_stop_timer(struct lpwrap_pri *spri, struct lpwrap_timer *timer) -{ - struct lpwrap_timer **prev, *cur; - - if (!spri || !timer) - return -1; - - if (!timer->timeout) - return 0; - - ftdm_log_chan(spri->dchan, FTDM_LOG_DEBUG, "-- Stopping timer %p\n", timer); - - ftdm_mutex_lock(spri->timer_mutex); - - for (prev = &spri->timer_list, cur = spri->timer_list; cur; prev = &(*prev)->next, cur = cur->next) { - if (cur == timer) { - *prev = cur->next; - break; - } - } - - ftdm_mutex_unlock(spri->timer_mutex); - - if (!cur) { - ftdm_log_chan(spri->dchan, FTDM_LOG_WARNING, "-- Timer %p not found in list\n", timer); - } - - timer->next = NULL; - timer->timeout = 0; - timer->callback = NULL; - return 0; -} - -static struct lpwrap_timer *lpwrap_timer_next(struct lpwrap_pri *spri) -{ - return spri ? spri->timer_list : NULL; -} - -static int lpwrap_run_expired(struct lpwrap_pri *spri, ftdm_time_t now_ms) -{ - struct lpwrap_timer *expired_list = NULL; - struct lpwrap_timer **prev, *cur; - - if (!spri || !spri->timer_list) - return 0; - - ftdm_mutex_lock(spri->timer_mutex); - - /* Move all timers to expired list */ - expired_list = spri->timer_list; - - for (prev = &expired_list, cur = expired_list; cur; prev = &(*prev)->next, cur = cur->next) { - if (cur->timeout > now_ms) { - *prev = NULL; - break; - } - } - /* Move non-expired timer to front of timer_list (or clear list if there are none) */ - spri->timer_list = cur; - - ftdm_mutex_unlock(spri->timer_mutex); - - /* fire callbacks */ - while ((cur = expired_list)) { - timeout_handler handler = cur->callback; - expired_list = cur->next; - - /* Stop timer */ - cur->next = NULL; - cur->timeout = 0; - cur->callback = NULL; - - if (handler) - handler(spri, cur); - } - return 0; -} - - -#define LPWRAP_MAX_TIMEOUT_MS 100 -#define LPWRAP_MAX_ERRORS 2 - -int lpwrap_run_pri_once(struct lpwrap_pri *spri) -{ - struct timeval *next = NULL; - struct lpwrap_timer *timer = NULL; - pri_event *event = NULL; - ftdm_wait_flag_t flags; - ftdm_time_t now_ms, next_ms, timeout_ms, tmp_ms; - int ret; - - if (spri->on_loop) { - if ((ret = spri->on_loop(spri)) < 0) - return FTDM_FAIL; - } - - /* Default timeout when no scheduled events are pending */ - timeout_ms = LPWRAP_MAX_TIMEOUT_MS; - next_ms = 0; - now_ms = ftdm_current_time_in_ms(); - - /* - * Get the next scheduled timer from libpri to set the maximum timeout, - * but limit it to MAX_TIMEOUT_MS (100ms). - */ - if ((next = pri_schedule_next(spri->pri))) { - next_ms = timeval_to_ms(next); - if (now_ms >= next_ms) { - /* Already late, handle timeout */ - timeout_ms = 0; - } else { - /* Calculate new timeout and limit it to MAX_TIMEOUT_MS miliseconds */ - tmp_ms = ftdm_min(next_ms - now_ms, LPWRAP_MAX_TIMEOUT_MS); - timeout_ms = ftdm_min(timeout_ms, tmp_ms); - } - } - - /* - * Next lpwrap_timer timeout - */ - if ((timer = lpwrap_timer_next(spri))) { - if (now_ms >= timer->timeout) { - /* Already late, handle timeout */ - timeout_ms = 0; - } else { - /* Calculate new timeout and limit it to MAX_TIMEOUT_MS miliseconds */ - tmp_ms = ftdm_min(timer->timeout - now_ms, LPWRAP_MAX_TIMEOUT_MS); - timeout_ms = ftdm_min(timeout_ms, tmp_ms); - } - } - - /* */ - if (timeout_ms > 0) { - flags = FTDM_READ | FTDM_EVENTS; - ret = ftdm_channel_wait(spri->dchan, &flags, timeout_ms); - - if (spri->flags & LPWRAP_PRI_ABORT) - return FTDM_SUCCESS; - - if (ret == FTDM_TIMEOUT) { - now_ms = ftdm_current_time_in_ms(); - - if (next) { - if (next_ms < now_ms) { - ftdm_log_chan(spri->dchan, FTDM_LOG_DEBUG, "pri timer %d ms late\n", - (int)(now_ms - next_ms)); - } - event = pri_schedule_run(spri->pri); - } - if (timer) { - if (timer->timeout < now_ms) { - ftdm_log_chan(spri->dchan, FTDM_LOG_DEBUG, "lpwrap timer %d ms late\n", - (int)(now_ms - timer->timeout)); - } - lpwrap_run_expired(spri, now_ms); - } - } else if (flags & (FTDM_READ | FTDM_EVENTS)) { - event = pri_check_event(spri->pri); - } - } else { - /* - * Scheduled event has already expired, handle it immediately - */ - if (next) { - event = pri_schedule_run(spri->pri); - } - if (timer) { - lpwrap_run_expired(spri, now_ms); - } - } - - if (spri->flags & LPWRAP_PRI_ABORT) - return FTDM_SUCCESS; - - if (event) { - event_handler handler; - - /* 0 is catchall event handler */ - if (event->e < 0 || event->e >= LPWRAP_PRI_EVENT_MAX) { - handler = spri->eventmap[0]; - } else if (spri->eventmap[event->e]) { - handler = spri->eventmap[event->e]; - } else { - handler = spri->eventmap[0]; - } - - if (handler) { - handler(spri, event->e, event); - } else { - ftdm_log(FTDM_LOG_CRIT, "No event handler found for event %d.\n", event->e); - } - } - - return FTDM_SUCCESS; -} - -int lpwrap_run_pri(struct lpwrap_pri *spri) -{ - int ret = 0; - - while (!(spri->flags & LPWRAP_PRI_ABORT)) { - ret = lpwrap_run_pri_once(spri); - if (ret) { - ftdm_log(FTDM_LOG_ERROR, "Error = %d, [%s]\n", - ret, strerror(errno)); - spri->errs++; - } else { - spri->errs = 0; - } - if (!ftdm_running()) - break; - if (spri->errs >= LPWRAP_MAX_ERRORS) { - ftdm_log(FTDM_LOG_CRIT, "Too many errors on span, restarting\n"); - spri->errs = 0; - break; - } - } - return ret; -} - -int lpwrap_stop_pri(struct lpwrap_pri *spri) -{ - spri->flags |= LPWRAP_PRI_ABORT; - return FTDM_SUCCESS; -} - -int lpwrap_destroy_pri(struct lpwrap_pri *spri) -{ - if (spri->timer_mutex) - ftdm_mutex_destroy(&spri->timer_mutex); - return FTDM_SUCCESS; -} - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/ftmod/ftmod_libpri/lpwrap_pri.h b/libs/freetdm/src/ftmod/ftmod_libpri/lpwrap_pri.h deleted file mode 100644 index 89708da270..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_libpri/lpwrap_pri.h +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright (c) 2009-2012, Anthony Minessale II - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _LPWRAP_PRI_H -#define _LPWRAP_PRI_H -#include -#include - - -#define LPWRAP_MAX_CHAN_PER_SPAN 32 - -typedef enum { - LPWRAP_PRI_EVENT_ANY = 0, - LPWRAP_PRI_EVENT_DCHAN_UP = PRI_EVENT_DCHAN_UP, - LPWRAP_PRI_EVENT_DCHAN_DOWN = PRI_EVENT_DCHAN_DOWN, - LPWRAP_PRI_EVENT_RESTART = PRI_EVENT_RESTART, - LPWRAP_PRI_EVENT_CONFIG_ERR = PRI_EVENT_CONFIG_ERR, - LPWRAP_PRI_EVENT_RING = PRI_EVENT_RING, - LPWRAP_PRI_EVENT_HANGUP = PRI_EVENT_HANGUP, - LPWRAP_PRI_EVENT_RINGING = PRI_EVENT_RINGING, - LPWRAP_PRI_EVENT_ANSWER = PRI_EVENT_ANSWER, - LPWRAP_PRI_EVENT_HANGUP_ACK = PRI_EVENT_HANGUP_ACK, - LPWRAP_PRI_EVENT_RESTART_ACK = PRI_EVENT_RESTART_ACK, -#ifdef PRI_EVENT_FACILITY - LPWRAP_PRI_EVENT_FACILITY = PRI_EVENT_FACILITY, -#else - LPWRAP_PRI_EVENT_FACILITY = PRI_EVENT_FACNAME, -#endif - LPWRAP_PRI_EVENT_INFO_RECEIVED = PRI_EVENT_INFO_RECEIVED, - LPWRAP_PRI_EVENT_PROCEEDING = PRI_EVENT_PROCEEDING, - LPWRAP_PRI_EVENT_SETUP_ACK = PRI_EVENT_SETUP_ACK, - LPWRAP_PRI_EVENT_HANGUP_REQ = PRI_EVENT_HANGUP_REQ, - LPWRAP_PRI_EVENT_NOTIFY = PRI_EVENT_NOTIFY, - LPWRAP_PRI_EVENT_PROGRESS = PRI_EVENT_PROGRESS, - LPWRAP_PRI_EVENT_KEYPAD_DIGIT = PRI_EVENT_KEYPAD_DIGIT, - LPWRAP_PRI_EVENT_IO_FAIL = 19, - - /* don't touch */ - LPWRAP_PRI_EVENT_MAX -} lpwrap_pri_event_t; - -typedef enum { - LPWRAP_PRI_NETWORK = PRI_NETWORK, - LPWRAP_PRI_CPE = PRI_CPE -} lpwrap_pri_node_t; - -typedef enum { - LPWRAP_PRI_SWITCH_UNKNOWN = PRI_SWITCH_UNKNOWN, - LPWRAP_PRI_SWITCH_NI2 = PRI_SWITCH_NI2, - LPWRAP_PRI_SWITCH_DMS100 = PRI_SWITCH_DMS100, - LPWRAP_PRI_SWITCH_LUCENT5E = PRI_SWITCH_LUCENT5E, - LPWRAP_PRI_SWITCH_ATT4ESS = PRI_SWITCH_ATT4ESS, - LPWRAP_PRI_SWITCH_EUROISDN_E1 = PRI_SWITCH_EUROISDN_E1, - LPWRAP_PRI_SWITCH_EUROISDN_T1 = PRI_SWITCH_EUROISDN_T1, - LPWRAP_PRI_SWITCH_NI1 = PRI_SWITCH_NI1, - LPWRAP_PRI_SWITCH_GR303_EOC = PRI_SWITCH_GR303_EOC, - LPWRAP_PRI_SWITCH_GR303_TMC = PRI_SWITCH_GR303_TMC, - LPWRAP_PRI_SWITCH_QSIG = PRI_SWITCH_QSIG, - - /* don't touch */ - LPWRAP_PRI_SWITCH_MAX -} lpwrap_pri_switch_t; - -typedef enum { - LPWRAP_PRI_READY = (1 << 0), - LPWRAP_PRI_ABORT = (1 << 1) -} lpwrap_pri_flag_t; - -struct lpwrap_pri; -struct lpwrap_timer; - -typedef int (*timeout_handler)(struct lpwrap_pri *, struct lpwrap_timer *); -typedef int (*event_handler)(struct lpwrap_pri *, lpwrap_pri_event_t, pri_event *); -typedef int (*loop_handler)(struct lpwrap_pri *); - -struct lpwrap_pri { - struct pri *pri; - ftdm_span_t *span; - ftdm_channel_t *dchan; - unsigned int flags; - void *private_info; - event_handler eventmap[LPWRAP_PRI_EVENT_MAX]; - loop_handler on_loop; - int errs; - struct lpwrap_timer *timer_list; - ftdm_mutex_t *timer_mutex; -}; - -typedef struct lpwrap_pri lpwrap_pri_t; - -struct lpwrap_pri_event_list { - int event_id; - int pri_event; - const char *name; -}; - -struct lpwrap_timer { - struct lpwrap_timer *next; - ftdm_time_t timeout; - timeout_handler callback; -}; - -int lpwrap_start_timer(struct lpwrap_pri *spri, struct lpwrap_timer *timer, const uint32_t timeout_ms, timeout_handler callback); -int lpwrap_stop_timer(struct lpwrap_pri *spri, struct lpwrap_timer *timer); - -#define LPWRAP_MAP_PRI_EVENT(spri, event, func) spri.eventmap[event] = func; -const char *lpwrap_pri_event_str(lpwrap_pri_event_t event_id); - -int lpwrap_init_pri(struct lpwrap_pri *spri, ftdm_span_t *span, ftdm_channel_t *dchan, int swtype, int node, int debug); -int lpwrap_destroy_pri(struct lpwrap_pri *spri); -int lpwrap_run_pri_once(struct lpwrap_pri *spri); -int lpwrap_run_pri(struct lpwrap_pri *spri); -int lpwrap_stop_pri(struct lpwrap_pri *spri); -#endif diff --git a/libs/freetdm/src/ftmod/ftmod_misdn/ftmod_misdn.c b/libs/freetdm/src/ftmod/ftmod_misdn/ftmod_misdn.c deleted file mode 100644 index 4909595a0b..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_misdn/ftmod_misdn.c +++ /dev/null @@ -1,2837 +0,0 @@ -/** - * mISDN HW interface - * - * Copyright (c) 2011, Stefan Knoblich - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * NOTE: This is intended as a Layer 1 interface only, signaling - * is handled by other modules (e.g. ftmod_libpri or ftmod_isdn). - */ -/* - * TODO: - * - Use a fifo and PH_DATA_CNF for b-channel write polling (drop timerfd) - * - * - Disable L1 idle deactivation on BRI PTMP with IMGL1HOLD ioctl(? optional) - * - * - Add hfcsusb specific state + flag defines and try to do something useful with - * it in misdn_handle_mph_information_ind(). - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* this is how it should have been... -#ifdef HAVE_FREETDM_FREETDM_H -#include -#else -#include -#endif -*/ -/* ... and this is how it is */ -#include - -#include - -/* - * mISDNcompat.h replaces these with references to an extern int, - * which is exported by libmisdn... unset them and use the official - * AF ID "34" - */ -#undef PF_ISDN -#undef AF_ISDN -#define AF_ISDN 34 -#define PF_ISDN AF_ISDN - -//#define MISDN_DEBUG_EVENTS -//#define MISDN_DEBUG_IO - -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x)) - -typedef enum { - MISDN_CAPS_NONE = 0, - - /* D-Channel */ - MISDN_CAPS_PRI = (1 << 0), - MISDN_CAPS_BRI = (1 << 1), - MISDN_CAPS_UP0 = (1 << 2), - MISDN_CAPS_NT = (1 << 3), - MISDN_CAPS_TE = (1 << 4), - - /* B-Channel */ - MISDN_CAPS_RAW = (1 << 10), - MISDN_CAPS_HDLC = (1 << 11), -} misdn_capability_flags_t; - -#define MISDN_IS_BRI(x) (x & MISDN_CAPS_BRI) -#define MISDN_IS_PRI(x) (x & MISDN_CAPS_PRI) - -#define MISDN_IS_TE(x) (x & MISDN_CAPS_TE) -#define MISDN_IS_NT(x) (x & MISDN_CAPS_NT) - -#define MISDN_IS_RAW(x) (x & MISDN_CAPS_RAW) -#define MISDN_IS_HDLC(x) (x & MISDN_CAPS_HDLC) - -#define MISDN_MSG_DATA(x) ((void *)((unsigned char *)(x) + MISDN_HEADER_LEN)) - -const static struct { - const int id; - const char *name; -} misdn_event_types[] = { -#define MISDN_EVENT_TYPE(x) { x, #x } - MISDN_EVENT_TYPE(PH_DATA_REQ), - MISDN_EVENT_TYPE(PH_DATA_IND), - MISDN_EVENT_TYPE(PH_DATA_CNF), - MISDN_EVENT_TYPE(PH_DATA_E_IND), - MISDN_EVENT_TYPE(PH_CONTROL_REQ), - MISDN_EVENT_TYPE(PH_CONTROL_IND), - MISDN_EVENT_TYPE(PH_CONTROL_CNF), - MISDN_EVENT_TYPE(PH_ACTIVATE_REQ), - MISDN_EVENT_TYPE(PH_ACTIVATE_IND), - MISDN_EVENT_TYPE(PH_ACTIVATE_CNF), - MISDN_EVENT_TYPE(PH_DEACTIVATE_REQ), - MISDN_EVENT_TYPE(PH_DEACTIVATE_IND), - MISDN_EVENT_TYPE(PH_DEACTIVATE_CNF), - MISDN_EVENT_TYPE(MPH_ACTIVATE_REQ), - MISDN_EVENT_TYPE(MPH_ACTIVATE_IND), - MISDN_EVENT_TYPE(MPH_DEACTIVATE_REQ), - MISDN_EVENT_TYPE(MPH_DEACTIVATE_IND), - MISDN_EVENT_TYPE(MPH_INFORMATION_REQ), - MISDN_EVENT_TYPE(MPH_INFORMATION_IND), -#undef MISDN_EVENT_TYPE -}; - -static const char *misdn_event2str(const int event) -{ - int x; - - for (x = 0; x < ftdm_array_len(misdn_event_types); x++) { - if (event == misdn_event_types[x].id) - return misdn_event_types[x].name; - } - return "unknown"; -} - - -const static struct { - const int id; - const char *name; -} misdn_control_types[] = { -#define MISDN_CONTROL_TYPE(x) { x, #x } - MISDN_CONTROL_TYPE(DTMF_HFC_COEF), - MISDN_CONTROL_TYPE(DSP_CONF_JOIN), - MISDN_CONTROL_TYPE(DSP_CONF_SPLIT), - MISDN_CONTROL_TYPE(DSP_RECEIVE_OFF), - MISDN_CONTROL_TYPE(DSP_RECEIVE_ON), - MISDN_CONTROL_TYPE(DSP_ECHO_ON), - MISDN_CONTROL_TYPE(DSP_ECHO_OFF), - MISDN_CONTROL_TYPE(DSP_MIX_ON), - MISDN_CONTROL_TYPE(DSP_MIX_OFF), - MISDN_CONTROL_TYPE(DSP_DELAY), - MISDN_CONTROL_TYPE(DSP_JITTER), - MISDN_CONTROL_TYPE(DSP_TXDATA_ON), - MISDN_CONTROL_TYPE(DSP_TXDATA_OFF), - MISDN_CONTROL_TYPE(DSP_TX_DEJITTER), - MISDN_CONTROL_TYPE(DSP_TX_DEJ_OFF), - MISDN_CONTROL_TYPE(DSP_TONE_PATT_ON), - MISDN_CONTROL_TYPE(DSP_TONE_PATT_OFF), - MISDN_CONTROL_TYPE(DSP_VOL_CHANGE_TX), - MISDN_CONTROL_TYPE(DSP_VOL_CHANGE_RX), - MISDN_CONTROL_TYPE(DSP_BF_ENABLE_KEY), - MISDN_CONTROL_TYPE(DSP_BF_DISABLE), - MISDN_CONTROL_TYPE(DSP_BF_ACCEPT), - MISDN_CONTROL_TYPE(DSP_BF_REJECT), - MISDN_CONTROL_TYPE(DSP_PIPELINE_CFG), - MISDN_CONTROL_TYPE(HFC_VOL_CHANGE_TX), - MISDN_CONTROL_TYPE(HFC_VOL_CHANGE_RX), - MISDN_CONTROL_TYPE(HFC_SPL_LOOP_ON), - MISDN_CONTROL_TYPE(HFC_SPL_LOOP_OFF), -#undef MISDN_CONTROL_TYPE -}; - -static const char *misdn_control2str(const int ctrl) -{ - int x; - - for (x = 0; x < ftdm_array_len(misdn_control_types); x++) { - if (ctrl == misdn_control_types[x].id) - return misdn_control_types[x].name; - } - return "unknown"; -} - - -/*********************************************************************************** - * mISDN <-> FreeTDM audio conversion - ***********************************************************************************/ - -/* - * Code used to generate table values taken from - * Linux Call Router (LCR) http://www.linux-call-router.de/ - * - * chan_lcr.c:3488 ff., load_module() - */ -static const unsigned char conv_audio_tbl[256] = { - 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, - 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, - 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, - 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, - 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, - 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, - 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, - 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, - 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, - 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, - 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, - 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, - 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, - 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, - 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, - 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, - 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, - 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, - 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, - 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, - 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, - 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, - 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, - 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, - 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, - 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, - 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, - 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, - 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, - 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, - 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, - 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff, -}; - -/* Convert ISDN_P_B_RAW audio data to/from a-/u-law */ -static inline void misdn_convert_audio_bits(char *buf, int buflen) -{ - int i; - - for (i = 0; i < buflen; i++) { - buf[i] = conv_audio_tbl[(unsigned char)buf[i]]; - } -} - - -/*********************************************************************************** - * mISDN <-> FreeTDM data structures - ***********************************************************************************/ - -typedef enum { - MISDN_CMD_NONE = 0, - MISDN_CMD_STOP, /*!< Stop the I/O thread */ -} misdn_cmd_t; - -struct misdn_command { - misdn_cmd_t type; -/* union { } cmd; */ /*!< Command-specific parameters */ -}; - -enum { - MISDN_SPAN_NONE = 0, - MISDN_SPAN_RUNNING = (1 << 0), - MISDN_SPAN_STOPPED = (1 << 1) -}; - -struct misdn_span_private { - int flags; - int running; - - int event_pipe_in; - int event_pipe_out; - - /* event conditional */ - pthread_mutex_t event_cond_mutex; - pthread_cond_t event_cond; - - /* start / stop feedback */ - pthread_mutex_t ctrl_cond_mutex; - pthread_cond_t ctrl_cond; -}; - -struct misdn_event_queue; - -struct misdn_chan_private { - /* */ - int debugfd; - int active; - - /* hw addr of channel */ - struct sockaddr_mISDN addr; - - /* audio tx pipe (= socketpair ends) */ - int tx_audio_pipe_in; - int tx_audio_pipe_out; - int rx_audio_pipe_in; - int rx_audio_pipe_out; - - /* counters */ - unsigned long tx_cnt; - unsigned long tx_ack_cnt; - unsigned long rx_cnt; - unsigned long slip_rx_cnt; - unsigned long slip_tx_cnt; - - unsigned long tx_pipe_wr_bytes; /*!< Number of bytes written into tx audio pipe */ - unsigned long tx_pipe_rd_bytes; /*!< Number of bytes read from tx audio pipe */ - unsigned long tx_miss_bytes; /*!< Number of bytes missing in short reads from tx audio pipe */ - unsigned long tx_lost_bytes; /*!< Number of bytes lost in short writes to the mISDN B-Channel */ - unsigned long tx_sent_bytes; /*!< Number of bytes successfully sent to the mISDN B-Channel */ - unsigned long tx_pipe_under_cnt; /*!< Number of tx audio pipe underflows */ - unsigned long tx_pipe_over_cnt; /*!< Number of tx audio pipe overflows */ - - struct misdn_event_queue *events; -}; - -#define ftdm_chan_io_private(x) ((x)->io_data) -#define ftdm_span_io_private(x) ((x)->io_data) - -static ftdm_status_t misdn_handle_incoming(ftdm_channel_t *ftdmchan, const char *rbuf, const int size); -static int misdn_handle_mph_information_ind(ftdm_channel_t *chan, const struct mISDNhead *hh, const void *data, const int data_len); - -static const char *ftdm_channel_get_type_str(const ftdm_channel_t *chan) -{ - return ftdm_chan_type2str(ftdm_channel_get_type(chan)); -} - -/*********************************************************************************** - * mISDN interface functions - ***********************************************************************************/ - -/* - * Event Queue - */ -#define MISDN_EVENTS_MAX 8 - -struct misdn_event { - int id; -}; - -struct misdn_event_queue { - int read_pos; - int write_pos; - pthread_mutex_t mutex; - - struct misdn_event events[MISDN_EVENTS_MAX]; -}; - -/** - * Initialize event queue - */ -static ftdm_status_t misdn_event_queue_create(struct misdn_event_queue **queue) -{ - struct misdn_event_queue *tmp = NULL; - - if (!queue) - return FTDM_FAIL; - - tmp = calloc(1, sizeof(*tmp)); - if (!tmp) - return FTDM_FAIL; - - pthread_mutex_init(&tmp->mutex, NULL); - - *queue = tmp; - return FTDM_SUCCESS; -} - -/** - * Destroy event queue - */ -static ftdm_status_t misdn_event_queue_destroy(struct misdn_event_queue **queue) -{ - if (!queue || !*queue) - return FTDM_FAIL; - - pthread_mutex_destroy(&(*queue)->mutex); - ftdm_safe_free(*queue); - *queue = NULL; - - return FTDM_SUCCESS; -} - -static ftdm_status_t misdn_event_queue_reset(struct misdn_event_queue *queue) -{ - if (!queue) - return FTDM_FAIL; - pthread_mutex_lock(&queue->mutex); - - memset(queue->events, 0, sizeof(queue->events)); - queue->read_pos = queue->write_pos = 0; - - pthread_mutex_unlock(&queue->mutex); - return FTDM_SUCCESS; -} - -static ftdm_bool_t misdn_event_queue_has_data(const struct misdn_event_queue *queue) -{ - if (!queue) - return FTDM_FALSE; - - return (queue->read_pos == queue->write_pos) ? FTDM_FALSE : FTDM_TRUE; -} - -static struct misdn_event *misdn_event_queue_pop(struct misdn_event_queue *queue) -{ - struct misdn_event *evt = NULL; - int next_idx = 0; - - if (!queue) - return NULL; - - pthread_mutex_lock(&queue->mutex); - - next_idx = (queue->read_pos + 1) % MISDN_EVENTS_MAX; - - if (queue->read_pos == queue->write_pos) { -#ifdef MISDN_DEBUG_EVENTS - ftdm_log(FTDM_LOG_DEBUG, "mISDN queue %p: empty\n", queue); -#endif - pthread_mutex_unlock(&queue->mutex); - return NULL; - } - -#ifdef MISDN_DEBUG_EVENTS - ftdm_log(FTDM_LOG_DEBUG, "mISDN queue %p: read event (read_pos: %d, write_pos: %d, next_write_pos: %d)\n", - queue, queue->read_pos, queue->write_pos, next_idx); -#endif - /* update read pos */ - evt = &queue->events[queue->read_pos]; - queue->read_pos = next_idx; - - pthread_mutex_unlock(&queue->mutex); - return evt; -} - -static ftdm_status_t misdn_event_queue_push(struct misdn_event_queue *queue, struct misdn_event *evt) -{ - int next_idx = 0; - - if (!queue || !evt) - return FTDM_FAIL; - - pthread_mutex_lock(&queue->mutex); - - next_idx = (queue->write_pos + 1) % MISDN_EVENTS_MAX; - - if (next_idx == queue->read_pos) { -#ifdef MISDN_DEBUG_EVENTS - ftdm_log(FTDM_LOG_DEBUG, "mISDN queue %p: full\n", queue); -#endif - pthread_mutex_unlock(&queue->mutex); - return FTDM_FAIL; - } - -#ifdef MISDN_DEBUG_EVENTS - ftdm_log(FTDM_LOG_DEBUG, "mISDN queue %p: wrote event (read_pos: %d, write_pos: %d, next_write_pos: %d)\n", - queue, queue->read_pos, queue->write_pos, next_idx); -#endif - memcpy(&queue->events[queue->write_pos], evt, sizeof(*evt)); - queue->write_pos = next_idx; - - pthread_mutex_unlock(&queue->mutex); - return FTDM_SUCCESS; -} - -#if 0 /* unused for now */ -static void misdn_event_queue_print_info(const struct misdn_event_queue *queue) -{ - ftdm_log(FTDM_LOG_DEBUG, "Queue %p\n\tread idx: %d\n\twrite idx: %d\n", queue, - queue->read_pos, queue->write_pos); -} -#endif - -/*********************************************************************************** - * mISDN helper functions - ***********************************************************************************/ - -#define MISDN_PH_ACTIVATE_TIMEOUT_MS 10000 -#define MISDN_MPH_INFORMATION_TIMEOUT_MS 3000 - -static inline void ts_add_msec(struct timespec *a, int msec) -{ - a->tv_sec += (msec / 1000); - a->tv_nsec += (msec % 1000) * 1000000; - if (a->tv_nsec >= 1000000000) { - a->tv_sec++; - a->tv_nsec -= 1000000000; - } -} - -static inline int ts_sub_msec(struct timespec *a, struct timespec *b) -{ - int msec = 0; - msec += (a->tv_sec - b->tv_sec) * 1000; - msec += (a->tv_nsec - b->tv_nsec) / 1000000; - return msec; -} - -static inline int ts_after(struct timespec *a, struct timespec *b) -{ - if (a->tv_sec > b->tv_sec) return 1; - if (a->tv_sec == b->tv_sec && a->tv_nsec > b->tv_nsec) return 1; - return 0; -} - -static inline int ts_before(struct timespec *a, struct timespec *b) -{ - if (a->tv_sec < b->tv_sec) return 1; - if (a->tv_sec == b->tv_sec && a->tv_nsec < b->tv_nsec) return 1; - return 0; -} - -/* - * Asynchronous channel (de-)activation - */ -static ftdm_status_t _misdn_toggle_channel_nowait(ftdm_channel_t *chan, int activate) -{ - struct misdn_chan_private *priv = ftdm_chan_io_private(chan); - char buf[MAX_DATA_MEM] = { 0 }; - struct mISDNhead *hh = (struct mISDNhead *) buf; - int retval; - - /* NOTE: sending PH_DEACTIVATE_REQ to closed b-channels kills the d-channel (hfcsusb)... */ - if ((activate && priv->active) || (!activate && !priv->active)) - return FTDM_SUCCESS; - - ftdm_log_chan(chan, FTDM_LOG_DEBUG, "mISDN sending %s request\n", - (activate) ? "activation" : "deactivation"); - - /* prepare + send request primitive */ - hh->prim = (activate) ? PH_ACTIVATE_REQ : PH_DEACTIVATE_REQ; - hh->id = MISDN_ID_ANY; - - if ((retval = sendto(chan->sockfd, hh, sizeof(*hh), 0, NULL, 0)) < sizeof(*hh)) { - ftdm_log_chan(chan, FTDM_LOG_ERROR, "mISDN failed to send activation request: %s\n", - strerror(errno)); - return FTDM_FAIL; - } - - return FTDM_SUCCESS; -} - -static ftdm_status_t misdn_activate_channel_nowait(ftdm_channel_t *chan) -{ - return _misdn_toggle_channel_nowait(chan, 1); -} - -static ftdm_status_t misdn_deactivate_channel_nowait(ftdm_channel_t *chan) -{ - return _misdn_toggle_channel_nowait(chan, 0); -} - -/* - * Synchronous channel (de-)activation - */ -static ftdm_status_t _misdn_toggle_channel(ftdm_channel_t *chan, int activate) -{ - struct misdn_chan_private *priv = ftdm_chan_io_private(chan); - char buf[MAX_DATA_MEM] = { 0 }; - struct mISDNhead *hh = (struct mISDNhead *) buf; - struct timespec abstimeout; - int req = 0, resp = 0, ms_left = MISDN_PH_ACTIVATE_TIMEOUT_MS; - int retval; - - /* NOTE: sending PH_DEACTIVATE_REQ to closed b-channels kills the d-channel (hfcsusb)... */ - if ((activate && priv->active) || (!activate && !priv->active)) - return FTDM_SUCCESS; - - ftdm_log_chan(chan, FTDM_LOG_DEBUG, "mISDN sending %s request\n", - (activate) ? "activation" : "deactivation"); - - /* prepare + send request primitive */ - req = (activate) ? PH_ACTIVATE_REQ : PH_DEACTIVATE_REQ; - hh->prim = req; - hh->id = MISDN_ID_ANY; - - if ((retval = sendto(chan->sockfd, hh, sizeof(*hh), 0, NULL, 0)) < sizeof(*hh)) { - ftdm_log_chan(chan, FTDM_LOG_ERROR, "mISDN failed to send activation request: %s\n", - strerror(errno)); - return FTDM_FAIL; - } - - clock_gettime(CLOCK_MONOTONIC, &abstimeout); - ts_add_msec(&abstimeout, ms_left); - - /* wait for answer */ - while (1) { - struct timespec now; - struct pollfd pfd; - - pfd.fd = chan->sockfd; - pfd.events = POLLIN | POLLPRI; - pfd.revents = 0; - - switch ((retval = poll(&pfd, 1, ms_left))) { - case 0: /* timeout */ - goto out; - case -1: /* error */ - if (!(retval == EAGAIN || retval == EINTR)) { - ftdm_log_chan(chan, FTDM_LOG_ERROR, "mISDN polling for activation confirmation failed: %s\n", - strerror(errno)); - return FTDM_FAIL; - } - break; - default: /* read data */ - break; - } - - if (pfd.revents & (POLLIN | POLLPRI)) { - /* handle incoming message */ - if ((retval = recvfrom(chan->sockfd, buf, sizeof(buf), 0, NULL, NULL)) <= 0) { - ftdm_log_chan(chan, FTDM_LOG_ERROR, "mISDN failed to receive possible answer for %s request: %s\n", - (activate) ? "activation" : "deactivation", strerror(errno)); - return FTDM_FAIL; - } -#ifdef MISDN_DEBUG_EVENTS - ftdm_log_chan(chan, FTDM_LOG_DEBUG, "mISDN got event '%s (%#x)', id %#x, while waiting for %s confirmation on %c-channel\n", - misdn_event2str(hh->prim), hh->prim, hh->id, (activate) ? "activation" : "deactivation", - ftdm_channel_get_type(chan) == FTDM_CHAN_TYPE_B ? 'B' : 'D'); -#endif - switch (hh->prim) { - case PH_ACTIVATE_IND: - case PH_ACTIVATE_CNF: - resp = hh->prim; - priv->active = 1; - if (activate) goto out; - break; - case PH_DEACTIVATE_CNF: - case PH_DEACTIVATE_IND: - resp = hh->prim; - priv->active = 0; - if (!activate) goto out; - break; - case PH_ACTIVATE_REQ: /* REQ echo, ignore */ - case PH_DEACTIVATE_REQ: - ftdm_log_chan(chan, FTDM_LOG_DEBUG, "mISDN got '%s' echo while waiting for %s confirmation (id: %#x)\n", - misdn_event2str(hh->prim), (activate) ? "activation" : "deactivation", hh->id); - break; - case MPH_INFORMATION_IND: - misdn_handle_mph_information_ind(chan, hh, MISDN_MSG_DATA(buf), retval - MISDN_HEADER_LEN); - break; - case PH_DATA_IND: /* ignore */ - case PH_DATA_CNF: /* ignore */ - break; - default: /* other messages, ignore */ - ftdm_log_chan(chan, FTDM_LOG_DEBUG, "mISDN ignoring event '%s (%#x)', id %#x, while waiting for %s confirmation\n", - misdn_event2str(hh->prim), hh->prim, hh->id, (activate) ? "activation" : "deactivation"); - break; - } - } - - /* check timeout */ - clock_gettime(CLOCK_MONOTONIC, &now); - - if (ts_after(&now, &abstimeout) || (ms_left = ts_sub_msec(&abstimeout, &now)) <= 0) - goto out; - } -out: - if (resp == 0) { - ftdm_log_chan(chan, FTDM_LOG_ERROR, "mISDN timeout waiting for %s confirmation\n", - (activate) ? "activation" : "deactivation"); - return FTDM_TIMEOUT; - } - if ((req == PH_ACTIVATE_REQ && !(resp == PH_ACTIVATE_CNF || resp == PH_ACTIVATE_IND)) || - (req == PH_DEACTIVATE_REQ && !(resp == PH_DEACTIVATE_CNF || resp == PH_DEACTIVATE_IND))) { - ftdm_log_chan(chan, FTDM_LOG_ERROR, "mISDN received '%s' while waiting for %s\n", - misdn_event2str(resp), (activate) ? "activation" : "deactivation"); - return FTDM_FAIL; - } - - ftdm_log_chan(chan, FTDM_LOG_DEBUG, "mISDN received %s confirmation\n", - (activate) ? "activation" : "deactivation"); - return FTDM_SUCCESS; -} - -static ftdm_status_t misdn_activate_channel(ftdm_channel_t *chan) -{ - return _misdn_toggle_channel(chan, 1); -} - -static ftdm_status_t misdn_deactivate_channel(ftdm_channel_t *chan) -{ - return _misdn_toggle_channel(chan, 0); -} - - -#if 0 /* unused for now */ -static ftdm_status_t misdn_get_ph_info(ftdm_channel_t *chan, struct ph_info *info) -{ - char buf[MAX_DATA_MEM] = { 0 }; - struct mISDNhead *hh; - struct timespec abstimeout; - int req = 0, resp = 0, ms_left = MISDN_MPH_INFORMATION_TIMEOUT_MS; - int retval; - - /* prepare + send request primitive */ - req = MPH_INFORMATION_REQ; - hh = (struct mISDNhead *)buf; - hh->prim = req; - hh->id = MISDN_ID_ANY; - - ftdm_log_chan(chan, FTDM_LOG_DEBUG, "mISDN sending %s request\n", - misdn_event2str(req)); - - if ((retval = sendto(chan->sockfd, &hh, sizeof(hh), 0, NULL, 0)) < sizeof(hh)) { - ftdm_log_chan(chan, FTDM_LOG_ERROR, "mISDN failed to send %s request: %s\n", - misdn_event2str(req), strerror(errno)); - return FTDM_FAIL; - } - - clock_gettime(CLOCK_MONOTONIC, &abstimeout); - ts_add_msec(&abstimeout, ms_left); - - /* wait for answer */ - while (1) { - struct timespec now; - struct pollfd pfd; - - pfd.fd = chan->sockfd; - pfd.events = POLLIN /* | POLLPRI */; - pfd.revents = 0; - - switch ((retval = poll(&pfd, 1, ms_left))) { - case 0: /* timeout */ - goto out; - case -1: /* error */ - if (!(retval == EAGAIN || retval == EINTR)) { - ftdm_log_chan(chan, FTDM_LOG_ERROR, "mISDN polling for %s answer failed: %s\n", - misdn_event2str(req), strerror(errno)); - return FTDM_FAIL; - } - break; - default: /* read data */ - break; - } - - if (pfd.revents & (POLLIN | POLLPRI)) { - /* handle incoming message */ - if ((retval = recvfrom(chan->sockfd, buf, sizeof(buf), 0, NULL, NULL)) <= 0) { - ftdm_log_chan(chan, FTDM_LOG_ERROR, "mISDN failed to receive possible answer for %s request: %s\n", - misdn_event2str(req), strerror(errno)); - return FTDM_FAIL; - } -#ifdef MISDN_DEBUG_EVENTS - ftdm_log_chan(chan, FTDM_LOG_DEBUG, "mISDN got event '%s' while waiting for %s answer\n", - misdn_event2str(hh->prim), misdn_event2str(req)); -#endif - switch (hh->prim) { - case MPH_INFORMATION_IND: /* success */ - if (retval < MISDN_HEADER_LEN + sizeof(*info)) { - ftdm_log_chan(chan, FTDM_LOG_ERROR, "mISDN answer for %s is too short\n", - misdn_event2str(req)); - return FTDM_FAIL; - } - resp = hh->prim; - /* TODO */ - goto out; - case MPH_INFORMATION_REQ: /* REQ echo, ignore */ - ftdm_log_chan(chan, FTDM_LOG_DEBUG, "mISDN got '%s' echo while waiting for %s answer\n", - misdn_event2str(hh->prim), misdn_event2str(req)); - break; - default: /* other messages, ignore */ - ftdm_log_chan(chan, FTDM_LOG_DEBUG, "mISDN ignoring event '%s' while waiting for %s answer\n", - misdn_event2str(hh->prim), misdn_event2str(req)); - break; - } - } - - /* check timeout */ - clock_gettime(CLOCK_MONOTONIC, &now); - - if (ts_after(&now, &abstimeout) || (ms_left = ts_sub_msec(&abstimeout, &now)) <= 0) - goto out; - } -out: - if (resp == 0) { - ftdm_log_chan(chan, FTDM_LOG_ERROR, "mISDN timeout waiting for %s answer\n", - misdn_event2str(req)); - return FTDM_TIMEOUT; - } - - return FTDM_SUCCESS; -} -#endif - -static int misdn_handle_ph_control_ind(ftdm_channel_t *chan, const struct mISDNhead *hh, const void *data, const int data_len) -{ - ftdm_unused_arg(data); - - ftdm_log_chan(chan, FTDM_LOG_DEBUG, - "PH_CONTROL_IND:\n" - "\tMessage:\t%s (%#x)\n" - "\tPayload:\t%d\n", - misdn_control2str(hh->id), hh->id, data_len); - - switch (hh->id) { - case DTMF_HFC_COEF: - break; - default: - break; - } - - return FTDM_SUCCESS; -} - -/* - * TE/NT state names - * taken from linux-3.2.1/drivers/isdn/hardware/mISDN/hfcsusb.h - */ -static const char *misdn_layer1_te_states[] = { - "TE F0 - Reset", - "TE F1 - Reset", - "TE F2 - Sensing", - "TE F3 - Deactivated", - "TE F4 - Awaiting signal", - "TE F5 - Identifying input", - "TE F6 - Synchronized", - "TE F7 - Activated", - "TE F8 - Lost framing", -}; - -static const char *misdn_layer1_nt_states[] = { - "NT G0 - Reset", - "NT G1 - Deactive", - "NT G2 - Pending activation", - "NT G3 - Active", - "NT G4 - Pending deactivation", -}; - -static const char *misdn_hw_state_name(const int proto, const int id) -{ - if (IS_ISDN_P_TE(proto)) { - if (id < 0 || id >= ftdm_array_len(misdn_layer1_te_states)) - return NULL; - return misdn_layer1_te_states[id]; - } - else if (IS_ISDN_P_NT(proto)) { - if (id < 0 || id >= ftdm_array_len(misdn_layer1_nt_states)) - return NULL; - return misdn_layer1_nt_states[id]; - } - return NULL; -} - - -static const struct misdn_hw_flag { - const unsigned int flag; - const char *name; -} misdn_hw_flags[] = { -#define MISDN_HW_FLAG(v,n) { v, #n } - MISDN_HW_FLAG(0, FLG_TX_BUSY), - MISDN_HW_FLAG(1, FLG_TX_NEXT), - MISDN_HW_FLAG(2, FLG_L1_BUSY), - MISDN_HW_FLAG(3, FLG_L2_ACTIVATED), - MISDN_HW_FLAG(5, FLG_OPEN), - MISDN_HW_FLAG(6, FLG_ACTIVE), - MISDN_HW_FLAG(7, FLG_BUSY_TIMER), - MISDN_HW_FLAG(8, FLG_DCHANNEL), - MISDN_HW_FLAG(9, FLG_BCHANNEL), - MISDN_HW_FLAG(10, FLG_ECHANNEL), - MISDN_HW_FLAG(12, FLG_TRANSPARENT), - MISDN_HW_FLAG(13, FLG_HDLC), - MISDN_HW_FLAG(14, FLG_L2DATA), - MISDN_HW_FLAG(15, FLG_ORIGIN), - MISDN_HW_FLAG(16, FLG_FILLEMPTY), - MISDN_HW_FLAG(17, FLG_ARCOFI_TIMER), - MISDN_HW_FLAG(18, FLG_ARCOFI_ERROR), - MISDN_HW_FLAG(17, FLG_INITIALIZED), - MISDN_HW_FLAG(18, FLG_DLEETX), - MISDN_HW_FLAG(19, FLG_LASTDLE), - MISDN_HW_FLAG(20, FLG_FIRST), - MISDN_HW_FLAG(21, FLG_LASTDATA), - MISDN_HW_FLAG(22, FLG_NMD_DATA), - MISDN_HW_FLAG(23, FLG_FTI_RUN), - MISDN_HW_FLAG(24, FLG_LL_OK), - MISDN_HW_FLAG(25, FLG_LL_CONN), - MISDN_HW_FLAG(26, FLG_DTMFSEND), - MISDN_HW_FLAG(30, FLG_RECVQUEUE), - MISDN_HW_FLAG(31, FLG_PHCHANGE), -#undef MISDN_HW_FLAG -}; - -static const char *misdn_hw_print_flags(unsigned int flags, char *buf, int buflen) -{ - int i; - - buf[0] = '\0'; - for (i = 0; i < ftdm_array_len(misdn_hw_flags); i++) { - if ((1 << misdn_hw_flags[i].flag) & flags) { - strncat(buf, misdn_hw_flags[i].name, buflen); - flags &= ~(1 << misdn_hw_flags[i].flag); - if (!flags) break; - strncat(buf, ",", buflen); - } - } - return buf; -} - -static int misdn_handle_mph_information_ind(ftdm_channel_t *chan, const struct mISDNhead *hh, const void *data, const int data_len) -{ - struct misdn_chan_private *priv = ftdm_chan_io_private(chan); - - ftdm_unused_arg(hh); - - /* - * mISDN has some inconsistency issues here. - * - * There are only two drivers that emit MPH_INFORMATION_IND messages, - * hfcsusb and hfcmulti. The former sends a set of ph_info and ph_info_ch structures, - * while the latter just sends an int containing the current L1_SIGNAL_* event id. - * - * The flags and state information in the ph_info and ph_info_ch structures - * are defined in kernel internal hw-specific headers (mISDNhw.h). - * - * Use the payload size to guess the type of message. - */ - if (data_len >= sizeof(struct ph_info)) { - /* complete port status, hfcsusb sends this */ - struct ph_info *info = (struct ph_info *)data; - struct ph_info_ch *bch_info = NULL; - char tmp[1024] = { 0 }; - - if (data_len < (sizeof(*info) + info->dch.num_bch * sizeof(*bch_info))) { - ftdm_log_chan_msg(chan, FTDM_LOG_ERROR, "mISDN MPH_INFORMATION_IND message is too short\n"); - return FTDM_FAIL; - } - bch_info = &info->bch[0]; - - ftdm_log_chan(chan, FTDM_LOG_DEBUG, "mISDN port state:\n\tD-Chan proto:\t%hu\n\tD-Chan state:\t%s (%hu)\n\tD-Chan flags:\t%#"FTDM_XINT64_FMT"\n\t\t\t%-70s\n", - info->dch.ch.protocol, - misdn_hw_state_name(info->dch.ch.protocol, info->dch.state), info->dch.state, - (uint64_t)info->dch.ch.Flags, - misdn_hw_print_flags(info->dch.ch.Flags, tmp, sizeof(tmp) - 1)); - - /* TODO: try to translate this to a usable set of alarm flags */ - - } else if (data_len == sizeof(int)) { - /* alarm info, sent by hfcmulti */ - int value = *(int *)data; - int alarm_flags = chan->alarm_flags; - - if (data_len < sizeof(value)) { - ftdm_log_chan_msg(chan, FTDM_LOG_ERROR, "mISDN MPH_INFORMATION_IND message is too short\n"); - return FTDM_FAIL; - } - - switch (value) { - case L1_SIGNAL_LOS_ON: - alarm_flags |= FTDM_ALARM_RED; - break; - case L1_SIGNAL_LOS_OFF: - alarm_flags &= ~FTDM_ALARM_RED; - break; - case L1_SIGNAL_AIS_ON: - alarm_flags |= FTDM_ALARM_AIS; - break; - case L1_SIGNAL_AIS_OFF: - alarm_flags &= ~FTDM_ALARM_AIS; - break; - case L1_SIGNAL_RDI_ON: - alarm_flags |= FTDM_ALARM_YELLOW; - break; - case L1_SIGNAL_RDI_OFF: - alarm_flags &= ~FTDM_ALARM_YELLOW; - break; - case L1_SIGNAL_SLIP_RX: - priv->slip_rx_cnt++; - break; - case L1_SIGNAL_SLIP_TX: - priv->slip_tx_cnt++; - break; - default: - ftdm_log_chan(chan, FTDM_LOG_ERROR, "mISDN unknown MPH_INFORMATION_IND signal: %#04x\n", - value); - return FTDM_FAIL; - } - - /* check whether alarm status has changed, update channel flags if it has */ - if ((value = (alarm_flags ^ chan->alarm_flags))) { - ftdm_log_chan(chan, FTDM_LOG_DEBUG, "mISDN alarm flags have changed %#x -> %#x\n", - chan->alarm_flags, alarm_flags); - chan->alarm_flags ^= value; - } - } else { - ftdm_log_chan(chan, FTDM_LOG_ERROR, "mISDN sent MPH_INFORMATION_IND message with unknown size %d\n", - data_len); - return FTDM_FAIL; - } - - return FTDM_SUCCESS; -} - -/*********************************************************************************** - * mISDN <-> FreeTDM interface functions - ***********************************************************************************/ - -static struct misdn_globals { - int sockfd; -} globals; - -/** - * \brief Open channel - * \param ftdmchan FreeTDM channel to open - */ -static FIO_OPEN_FUNCTION(misdn_open) -{ - struct misdn_chan_private *chan_priv = ftdm_chan_io_private(ftdmchan); - ftdm_span_t *span = ftdm_channel_get_span(ftdmchan); - struct misdn_span_private *span_priv = ftdm_span_io_private(span); - ftdm_status_t ret = 0; - - assert(chan_priv); - assert(span_priv); - - if (chan_priv->active) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_INFO, "mISDN channel is already open, skipping activation\n"); - return FTDM_SUCCESS; - } - - /* flush all events */ - misdn_event_queue_reset(chan_priv->events); - - /* - * Send activation request - */ - ret = misdn_activate_channel(ftdmchan); - if (ret != FTDM_SUCCESS) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Failed to activate channel (socket: %d)\n", - ftdmchan->sockfd); - /* - * Ignore error, ftdm_channel_open() does not correctly handle return FTDM_FAIL cases. - * We will try to activate the channel later. - */ - } else { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "mISDN channel activation request sent\n"); - - switch (ftdmchan->type) { - case FTDM_CHAN_TYPE_B: - case FTDM_CHAN_TYPE_DQ921: - chan_priv->active = 1; - break; - default: - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "mISDN invalid channel type '%s'\n", - ftdm_channel_get_type_str(ftdmchan)); - break; - } - } - return FTDM_SUCCESS; -} - -/** - * \brief Close channel - * \param ftdmchan FreeTDM channel to close - */ -static FIO_CLOSE_FUNCTION(misdn_close) -{ - struct misdn_chan_private *chan_priv = ftdm_chan_io_private(ftdmchan); - ftdm_status_t ret = 0; - - assert(chan_priv); - - ftdm_log_chan(ftdmchan, FTDM_LOG_NOTICE, "mISDN trying to close %c-channel\n", - ftdm_channel_get_type(ftdmchan) == FTDM_CHAN_TYPE_B ? 'B' : 'D'); - - if (chan_priv->active) { - - if (ftdm_channel_get_type(ftdmchan) == FTDM_CHAN_TYPE_B) { - ret = misdn_deactivate_channel(ftdmchan); - } else { - /* Don't wait for D-Channel deactivation */ - ret = misdn_deactivate_channel_nowait(ftdmchan); - } - - if (ret != FTDM_SUCCESS) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Failed to deactivate %c-channel\n", - ftdm_channel_get_type(ftdmchan) == FTDM_CHAN_TYPE_B ? 'B' : 'D'); - /* Ignore error, channel might be closed already */ - } else { - ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "mISDN %c-channel deactivated\n", - ftdm_channel_get_type(ftdmchan) == FTDM_CHAN_TYPE_B ? 'B' : 'D'); - } - - ftdm_log_chan(ftdmchan, FTDM_LOG_NOTICE, "mISDN tx stats: wr: %lu, rd: %lu, tx: %lu, tx-lost: %lu, tx-miss: %lu, tx-under#: %lu, tx-over#: %lu\n", - chan_priv->tx_pipe_wr_bytes, chan_priv->tx_pipe_rd_bytes, - chan_priv->tx_sent_bytes, chan_priv->tx_lost_bytes, chan_priv->tx_miss_bytes, - chan_priv->tx_pipe_over_cnt, chan_priv->tx_pipe_under_cnt); - - chan_priv->active = 0; - } - - return FTDM_SUCCESS; -} - -/** - * \brief Execute command - * \param ftdmchan FreeTDM channel - * \param command Command to execute - * \param obj Additional command data - */ -static FIO_COMMAND_FUNCTION(misdn_command) -{ - switch (command) { - case FTDM_COMMAND_NOOP: - break; - case FTDM_COMMAND_SET_INTERVAL: -// case FTDM_COMMAND_GET_INTERVAL: - case FTDM_COMMAND_SET_CODEC: - case FTDM_COMMAND_GET_CODEC: - case FTDM_COMMAND_SET_NATIVE_CODEC: - case FTDM_COMMAND_GET_NATIVE_CODEC: - case FTDM_COMMAND_ENABLE_DTMF_DETECT: - case FTDM_COMMAND_DISABLE_DTMF_DETECT: - case FTDM_COMMAND_SEND_DTMF: - case FTDM_COMMAND_SET_DTMF_ON_PERIOD: - case FTDM_COMMAND_GET_DTMF_ON_PERIOD: - case FTDM_COMMAND_SET_DTMF_OFF_PERIOD: - case FTDM_COMMAND_GET_DTMF_OFF_PERIOD: - case FTDM_COMMAND_SET_RX_GAIN: /* DSP_VOL_CHANGE_RX / HFC_VOL_CHANGE_RX */ - case FTDM_COMMAND_GET_RX_GAIN: - case FTDM_COMMAND_SET_TX_GAIN: /* DSP_VOL_CHANGE_TX / HFC_VOL_CHANGE_TX */ - case FTDM_COMMAND_GET_TX_GAIN: - case FTDM_COMMAND_FLUSH_TX_BUFFERS: - case FTDM_COMMAND_FLUSH_RX_BUFFERS: - case FTDM_COMMAND_FLUSH_BUFFERS: - case FTDM_COMMAND_FLUSH_IOSTATS: - case FTDM_COMMAND_SET_PRE_BUFFER_SIZE: - case FTDM_COMMAND_SET_LINK_STATUS: - case FTDM_COMMAND_GET_LINK_STATUS: - case FTDM_COMMAND_SET_RX_QUEUE_SIZE: - case FTDM_COMMAND_SET_TX_QUEUE_SIZE: - case FTDM_COMMAND_START_MF_PLAYBACK: - case FTDM_COMMAND_STOP_MF_PLAYBACK: - case FTDM_COMMAND_GET_IOSTATS: - case FTDM_COMMAND_SWITCH_IOSTATS: - /* Supported by mISDN */ - case FTDM_COMMAND_ENABLE_ECHOCANCEL: /* DSP_ECHO_ON */ - case FTDM_COMMAND_DISABLE_ECHOCANCEL: /* DSP_ECHO_OFF */ - case FTDM_COMMAND_ENABLE_LOOP: - case FTDM_COMMAND_DISABLE_LOOP: - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Received unimplemented command: %d\n", - command); - break; - - case FTDM_COMMAND_GET_INTERVAL: - FTDM_COMMAND_OBJ_INT = ftdm_channel_get_io_interval(ftdmchan); - ftdm_log_chan(ftdmchan, FTDM_LOG_NOTICE, "Interval %d ms\n", - ftdm_channel_get_io_interval(ftdmchan)); - break; - - default: - ftdm_log(FTDM_LOG_ERROR, "Unknown command %d\n", command); - } - return FTDM_SUCCESS; -} - - -/** - * \brief Wait for new data - * \param ftdmchan FreeTDM channel to wait on - * \param flags Wait flags - * \param to Timeout - */ -static FIO_WAIT_FUNCTION(misdn_wait) -{ - struct misdn_chan_private *chan_priv = ftdm_chan_io_private(ftdmchan); - struct pollfd pfds[2]; - int nr_fds = 0; - int retval; - - memset(pfds, 0, sizeof(pfds)); - - switch (ftdm_channel_get_type(ftdmchan)) { - case FTDM_CHAN_TYPE_B: - if (*flags & FTDM_WRITE) { - pfds[nr_fds].fd = chan_priv->tx_audio_pipe_in; - pfds[nr_fds].events = POLLOUT; - nr_fds++; - } - if (*flags & FTDM_READ) { - pfds[nr_fds].fd = chan_priv->rx_audio_pipe_out; - pfds[nr_fds].events = POLLIN; - nr_fds++; - } -/* if (*flags & (FTDM_READ | FTDM_EVENTS)) { - pfds[nr_fds].fd = ftdmchan->sockfd; - pfds[nr_fds].events |= (*flags & FTDM_READ) ? POLLIN : 0; - pfds[nr_fds].events |= (*flags & FTDM_EVENTS) ? POLLPRI : 0; - nr_fds++; - } -*/ - break; - default: - if (*flags & FTDM_READ) - pfds[0].events |= POLLIN; - if (*flags & FTDM_WRITE) - pfds[0].events |= POLLOUT; - if (*flags & FTDM_EVENTS) - pfds[0].events |= POLLPRI; - pfds[0].fd = ftdmchan->sockfd; - nr_fds++; - break; - } - - *flags = FTDM_NO_FLAGS; - - if (!(pfds[0].events || pfds[1].events)) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_NOTICE, "mISDN poll(): no flags set!\n"); - return FTDM_SUCCESS; - } - - if ((retval = poll(pfds, nr_fds, to)) < 0) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "mISDN poll() failed: %s\n", - strerror(errno)); - return FTDM_FAIL; - } - if (retval == 0) - return FTDM_TIMEOUT; - - switch (ftdm_channel_get_type(ftdmchan)) { - case FTDM_CHAN_TYPE_B: - if ((pfds[0].revents & POLLOUT) || (pfds[1].revents & POLLOUT)) - *flags |= FTDM_WRITE; - if ((pfds[0].revents & POLLIN) || (pfds[1].revents & POLLIN)) - *flags |= FTDM_READ; - if ((pfds[0].revents & POLLPRI) || (pfds[1].revents & POLLPRI)) - *flags |= FTDM_EVENTS; - break; - default: - if (pfds[0].revents & POLLIN) - *flags |= FTDM_READ; - if (pfds[0].revents & POLLOUT) - *flags |= FTDM_WRITE; - if (pfds[0].revents & POLLPRI) - *flags |= FTDM_EVENTS; - break; - } - return FTDM_SUCCESS; -} - - -/** - * Handle incoming mISDN message on d-channel - * \param[in] ftdmchan - * \param[in] msg_buf - * \param[in] msg_len - * \internal - */ -static ftdm_status_t misdn_handle_incoming(ftdm_channel_t *ftdmchan, const char *msg_buf, const int msg_len) -{ - struct misdn_chan_private *priv = ftdm_chan_io_private(ftdmchan); - struct mISDNhead *hh = (struct mISDNhead *)msg_buf; - const char *data = msg_buf + sizeof(*hh); - int data_len = msg_len - sizeof(*hh); - - assert(msg_buf); - assert(priv); - - if (msg_len < sizeof(*hh)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "mISDN message to small (%d < %"FTDM_SIZE_FMT" bytes)\n", - msg_len, sizeof(*hh)); - return FTDM_FAIL; - } - -#ifdef MISDN_DEBUG_EVENTS - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "mISDN %c-channel received '%s' message (id: 0x%x, additional data: %d bytes)\n", - ftdm_channel_get_type(ftdmchan) == FTDM_CHAN_TYPE_B ? 'B' : 'D', misdn_event2str(hh->prim), hh->id, data_len); -#endif - - switch (hh->prim) { - /* data events */ - case PH_DATA_CNF: /* TX: ack */ - priv->tx_ack_cnt++; - break; - case PH_DATA_REQ: /* TX: request echo (ignore) */ - break; - case PH_DATA_E_IND: /* RX: e-channel data received (monitoring?) */ - break; - - /* control requests */ - case PH_CONTROL_IND: - return misdn_handle_ph_control_ind(ftdmchan, hh, data, data_len); - case PH_CONTROL_REQ: - case PH_CONTROL_CNF: - break; - - /* information */ - case MPH_INFORMATION_IND: - return misdn_handle_mph_information_ind(ftdmchan, hh, data, data_len); - - /* channel de-/activation */ - case PH_ACTIVATE_REQ: /* Echoed requests, ignore */ - case PH_DEACTIVATE_REQ: - break; - case PH_ACTIVATE_IND: - case PH_DEACTIVATE_IND: { - /* other events, enqueue and let misdn_event_next handle it */ - struct misdn_span_private *span_priv = ftdm_span_io_private(ftdmchan->span); - struct misdn_event evt = { 0 }; - evt.id = hh->prim; - - misdn_event_queue_push(priv->events, &evt); - - /* wake possible readers */ - pthread_cond_signal(&span_priv->event_cond); - break; - } - default: /* error? */ - ftdm_log(FTDM_LOG_DEBUG, "mISDN channel %d:%d received unknown event %d\n", - ftdm_channel_get_span_id(ftdmchan), ftdm_channel_get_id(ftdmchan), hh->prim); - break; - } - return FTDM_SUCCESS; -} - -/** - * \brief Read data - * \param ftdmchan FreeTDM channel - * \param data Buffer for data - * \param datalen Number of bytes to read (contains bytes read after return) - */ -static FIO_READ_FUNCTION(misdn_read) -{ - struct misdn_chan_private *priv = ftdm_chan_io_private(ftdmchan); - char rbuf[MAX_DATA_MEM] = { 0 }; - struct mISDNhead *hh = (struct mISDNhead *)rbuf; - int bytes = *datalen; - int retval; - int maxretry = 10; - - /* nothing read yet */ - *datalen = 0; - - /* - * try to read all messages, as long as we haven't received a PH_DATA_IND one - * we'll get a lot of "mISDN_send: error -12" message in dmesg otherwise - * (= b-channel receive queue overflowing) - */ - switch (ftdm_channel_get_type(ftdmchan)) { - case FTDM_CHAN_TYPE_DQ921: { - while (maxretry--) { - struct sockaddr_mISDN addr; - socklen_t addrlen = sizeof(addr); - - if ((retval = recvfrom(ftdmchan->sockfd, rbuf, sizeof(rbuf), 0, (struct sockaddr *)&addr, &addrlen)) < 0) { - if (errno == EWOULDBLOCK || errno == EAGAIN) break; - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "mISDN failed to receive incoming message: %s\n", - strerror(errno)); - return FTDM_FAIL; - } - - if (retval < MISDN_HEADER_LEN) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "mISDN received message too small\n"); - return FTDM_FAIL; - } - - if (hh->prim == PH_DATA_IND) { - *datalen = ftdm_clamp(retval - MISDN_HEADER_LEN, 0, bytes); - - if (*datalen <= 0) - continue; - - /* - * Copy data into ouput buffer (excluding the mISDN message header) - * NOTE: audio data needs to be converted to a-law / u-law! - */ - memcpy(data, rbuf + MISDN_HEADER_LEN, *datalen); - return FTDM_SUCCESS; - } else { - *datalen = 0; - /* event */ - misdn_handle_incoming(ftdmchan, rbuf, retval); - } - } - break; - } - case FTDM_CHAN_TYPE_B: { - if (!priv->active) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "mISDN ignoring read on closed b-channel\n"); - return FTDM_SUCCESS; - } - - if ((retval = read(priv->rx_audio_pipe_out, data, bytes)) < 0) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "mISDN failed to read audio data from rx pipe: %s\n", - strerror(errno)); - return FTDM_FAIL; - } - *datalen = retval; - break; - } - default: - break; - } - return FTDM_SUCCESS; -} - -/** - * \brief Write data - * \param ftdmchan FreeTDM channel - * \param data Buffer for data - * \param datalen Number of bytes to write (contains bytes written after return) - */ -static FIO_WRITE_FUNCTION(misdn_write) -{ - struct misdn_chan_private *priv = ftdm_chan_io_private(ftdmchan); - char wbuf[MAX_DATA_MEM]; - struct mISDNhead *hh = (struct mISDNhead *)wbuf; - int size = *datalen; - int retval = 0; - ftdm_wait_flag_t wflags; - - assert(priv); - - /* ignore empty writes */ - if (*datalen <= 0) - return FTDM_SUCCESS; - -#ifdef MISDN_DEBUG_IO - { - char hbuf[MAX_DATA_MEM] = { 0 }; - print_hex_bytes(data, *datalen, hbuf, sizeof(hbuf)); - ftdm_log(FTDM_LOG_DEBUG, "mISDN write data: %s\n", hbuf); - } -#endif - *datalen = 0; - - switch (ftdm_channel_get_type(ftdmchan)) { - case FTDM_CHAN_TYPE_B: - /* - * Check state, send activation request (async) if channel is not open - */ - if (!priv->active) { - misdn_activate_channel_nowait(ftdmchan); - return FTDM_SUCCESS; /* eat data */ - } - /* - * Write to audio pipe, misdn_read() will pull - * from there as needed and send it to the b-channel - * - * NOTE: can't use blocking I/O here since both parts are serviced - * from the same thread - */ - if ((retval = write(priv->tx_audio_pipe_in, data, size)) < 0) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "mISDN channel audio pipe write error [wr: %lu, rd: %lu: tx: %lu, tx-under#: %lu, tx-over#: %lu]: %s\n", - priv->tx_pipe_wr_bytes, priv->tx_pipe_rd_bytes, priv->tx_sent_bytes, - priv->tx_pipe_under_cnt, priv->tx_pipe_over_cnt, strerror(errno)); - return FTDM_FAIL; - } else if (retval < size) { - priv->tx_pipe_over_cnt++; - ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "mISDN channel audio pipe short write [wr: %lu, rd: %lu: tx: %lu, tx-under#: %lu, tx-over#: %lu], expected: %d, written: %d\n", - priv->tx_pipe_wr_bytes, priv->tx_pipe_rd_bytes, priv->tx_sent_bytes, - priv->tx_pipe_under_cnt, priv->tx_pipe_over_cnt, size, retval); - } - ACCESS_ONCE(priv->tx_pipe_wr_bytes) += retval; - *datalen = retval; - break; - default: - hh->prim = PH_DATA_REQ; - hh->id = MISDN_ID_ANY; - - /* Avoid buffer overflow */ - size = ftdm_min(size, MAX_DATA_MEM - MISDN_HEADER_LEN); - - memcpy(wbuf + MISDN_HEADER_LEN, data, size); - size += MISDN_HEADER_LEN; - - /* - * Check state, send activation request (sync) if channel is not open - */ - if (!priv->active) { - retval = misdn_activate_channel(ftdmchan); - if (retval) { - *datalen = 0; - return FTDM_FAIL; - } - } - - /* wait for channel to get ready */ - wflags = FTDM_WRITE; - retval = misdn_wait(ftdmchan, &wflags, 20); - if (retval) { - /* timeout, io error */ - *datalen = 0; - return FTDM_FAIL; - } - -#ifdef MISDN_DEBUG_IO - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "mISDN writing %d bytes to channel socket %d [dev.ch: %d.%d]\n", - size, ftdmchan->sockfd, priv->addr.dev, priv->addr.channel); -#endif - - if ((retval = sendto(ftdmchan->sockfd, wbuf, size, 0, NULL, 0)) < size) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "mISDN channel socket write error: %s\n", - strerror(errno)); - return FTDM_FAIL; - } - *datalen = retval; - break; - } - - priv->tx_cnt++; - return FTDM_SUCCESS; -} - -/** - * Carefully choosen size for socket send/recv buffers - * larger values will add more latency, while lower values will cause deadlocks - * (see misdn_span_run() comments below for an explanation) - */ -#define SOCKETPAIR_BUFFER_SIZE 3072 - -static ftdm_status_t misdn_open_range(ftdm_span_t *span, ftdm_chan_type_t type, struct mISDN_devinfo *devinfo, int start, int end) -{ - int num_configured = 0; - int d_protocol, d_channel; - int x; - - ftdm_log(FTDM_LOG_DEBUG, "mISDN configuring card:range %d:%d->%d\n", - devinfo->id, start, end); - - switch (ftdm_span_get_trunk_type(span)) { - case FTDM_TRUNK_E1: - d_protocol = ftdm_span_get_trunk_mode(span) == FTDM_TRUNK_MODE_NET ? ISDN_P_NT_E1 : ISDN_P_TE_E1; - d_channel = 16; - break; - case FTDM_TRUNK_BRI: - case FTDM_TRUNK_BRI_PTMP: - d_protocol = ftdm_span_get_trunk_mode(span) == FTDM_TRUNK_MODE_NET ? ISDN_P_NT_S0 : ISDN_P_TE_S0; - d_channel = 0; - break; - default: - ftdm_log(FTDM_LOG_ERROR, "Unsupported span type %s\n", - ftdm_span_get_trunk_type_str(span)); - return FTDM_FAIL; - } - - for (x = start; x <= end; x++) { - struct misdn_chan_private *priv; - struct sockaddr_mISDN addr; - ftdm_channel_t *ftdmchan = NULL; - ftdm_socket_t sockfd = -1; - - ftdm_log(FTDM_LOG_DEBUG, "mISDN configuring card:channel => %d:%d\n", - devinfo->id, x); - - memset(&addr, 0, sizeof(addr)); - addr.family = AF_ISDN; - addr.dev = devinfo->id; - - switch (type) { - case FTDM_CHAN_TYPE_DQ931: /* unsupported */ - ftdm_log(FTDM_LOG_ERROR, "Unsupported channel type '%s'\n", - ftdm_chan_type2str(type)); - return FTDM_FAIL; - - case FTDM_CHAN_TYPE_DQ921: - /* No NT-mode support, since we have no idea which mode we should run in at this point */ - sockfd = socket(PF_ISDN, SOCK_DGRAM, d_protocol); - addr.channel = d_channel; /* 0 for S0 and 16 for E1 */ - break; - - case FTDM_CHAN_TYPE_B: - if (!test_channelmap(x, devinfo->channelmap)) { - ftdm_log(FTDM_LOG_ERROR, "Invalid B-Channel specified: %d\n", x); - return FTDM_FAIL; - } - sockfd = socket(PF_ISDN, SOCK_DGRAM, ISDN_P_B_RAW); - addr.channel = x; - break; - - default: - ftdm_log(FTDM_LOG_ERROR, "Invalid/unsupported channel type '%s' (%d)\n", - ftdm_chan_type2str(type), type); - return FTDM_FAIL; - } - - if (sockfd < 0) { - ftdm_log(FTDM_LOG_ERROR, "Failed to open socket: %s\n", strerror(errno)); - return FTDM_FAIL; - } - - ftdm_log(FTDM_LOG_DEBUG, "mISDN opened socket (on chan:dev => %d:%d): %d\n", - addr.dev, addr.channel, sockfd); - - /* Set mISDN channel socket non-blocking */ - if (fcntl(sockfd, F_SETFL, O_NONBLOCK) < 0) { - ftdm_log(FTDM_LOG_ERROR, "mISDN Failed to set socket fd to non-blocking: %s\n", - strerror(errno)); - close(sockfd); - return FTDM_FAIL; - } - - /* - * Bind socket to card:channel - */ - if (bind(sockfd, (struct sockaddr *)&addr, sizeof(addr)) < 0) { - ftdm_log(FTDM_LOG_ERROR, "Failed to bind mISDN socket [%d:%d]: %s\n", - addr.dev, x, strerror(errno)); - close(sockfd); - return FTDM_FAIL; - } - - /* - * Add channel to span - */ - if (ftdm_span_add_channel(span, sockfd, type, &ftdmchan) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "Failed to add mISDN ftdmchan to span\n"); - close(sockfd); - return FTDM_FAIL; - } - - priv = calloc(1, sizeof(*priv)); - if (!priv) { - ftdm_log(FTDM_LOG_ERROR, "mISDN failed to allocate channel private data\n"); - close(sockfd); - return FTDM_FAIL; - } - ftdm_chan_io_private(ftdmchan) = priv; - - priv->addr = addr; - priv->debugfd = -1; - - /* - * Create event queue - */ - misdn_event_queue_create(&priv->events); - - ftdmchan->rate = 8000; - ftdmchan->physical_span_id = devinfo->id; - ftdmchan->physical_chan_id = x; - - if (ftdmchan->type == FTDM_CHAN_TYPE_B) { - int pipefd[2] = { -1, -1 }; - - ftdmchan->packet_len = 30 /* ms */ * (ftdmchan->rate / 1000); - ftdmchan->effective_interval = ftdmchan->native_interval = ftdmchan->packet_len / 8; - ftdmchan->native_codec = ftdmchan->effective_codec = FTDM_CODEC_ALAW; - -// ftdm_channel_set_feature(ftdmchan, FTDM_CHANNEL_FEATURE_INTERVAL); - -#ifdef USE_PIPE - /* - * Create audio tx pipe, use non-blocking I/O to avoid deadlock since both ends - * are used from the same thread - */ - if (pipe2(pipefd, 0 | O_NONBLOCK) < 0) { - ftdm_log(FTDM_LOG_ERROR, "Failed to create mISDN audio tx pipe [%d:%d]: %s\n", - addr.dev, x, strerror(errno)); - close(sockfd); - return FTDM_FAIL; - } - priv->tx_audio_pipe_in = pipefd[1]; - priv->tx_audio_pipe_out = pipefd[0]; - -#if 1 || defined(HAVE_F_SETPIPE_SZ) - if (fcntl(priv->tx_audio_pipe_in, F_SETPIPE_SZ, 4096) < 0) { - ftdm_log(FTDM_LOG_WARNING, "Failed to set mISDN audio tx pipe size [%d:%d]: %s\n", - addr.dev, x, strerror(errno)); - } -#endif - /* - * Create audio rx pipe, use non-blocking I/O to avoid deadlock since both ends - * are used from the same thread - */ - if (pipe2(pipefd, 0 | O_NONBLOCK) < 0) { - ftdm_log(FTDM_LOG_ERROR, "Failed to create mISDN audio rx pipe [%d:%d]: %s\n", - addr.dev, x, strerror(errno)); - close(sockfd); - return FTDM_FAIL; - } - priv->rx_audio_pipe_in = pipefd[1]; - priv->rx_audio_pipe_out = pipefd[0]; - -#if 1 || defined(HAVE_F_SETPIPE_SZ) - if (fcntl(priv->rx_audio_pipe_in, F_SETPIPE_SZ, 4096) < 0) { - ftdm_log(FTDM_LOG_WARNING, "Failed to set mISDN audio rx pipe size [%d:%d]: %s\n", - addr.dev, x, strerror(errno)); - } -#endif -#else /* !USE_PIPE */ - /* - * Use a socket pair for audio rx/tx, allows for more fine-grained control - * of latency (= amounts of data in buffers) - */ - if (socketpair(AF_UNIX, SOCK_STREAM, 0, pipefd) < 0) { - ftdm_log(FTDM_LOG_ERROR, "Failed to create mISDN audio socket pair [%d:%d]: %s\n", - addr.dev, x, strerror(errno)); - close(sockfd); - return FTDM_FAIL; - } else { - int opt = SOCKETPAIR_BUFFER_SIZE; - socklen_t optlen = sizeof(opt); - - if (fcntl(pipefd[0], F_SETFL, O_NONBLOCK) < 0) { - ftdm_log(FTDM_LOG_ERROR, "mISDN Failed to set socket pair fd[0] to non-blocking: %s\n", - strerror(errno)); - close(sockfd); - close(pipefd[0]); - close(pipefd[1]); - return FTDM_FAIL; - } - if (fcntl(pipefd[1], F_SETFL, O_NONBLOCK) < 0) { - ftdm_log(FTDM_LOG_ERROR, "mISDN Failed to set socket pair fd[1] to non-blocking: %s\n", - strerror(errno)); - close(sockfd); - close(pipefd[0]); - close(pipefd[1]); - return FTDM_FAIL; - } - - /* - * Set RX/TX buffer sizes on each end of the socket pair - */ - if (setsockopt(pipefd[0], SOL_SOCKET, SO_RCVBUF, &opt, optlen) < 0) { - ftdm_log(FTDM_LOG_WARNING, "mISDN Failed to set socket pair fd[0] RCVBUF: %s\n", - strerror(errno)); - } - if (setsockopt(pipefd[0], SOL_SOCKET, SO_SNDBUF, &opt, optlen) < 0) { - ftdm_log(FTDM_LOG_WARNING, "mISDN Failed to set socket pair fd[0] SNDBUF: %s\n", - strerror(errno)); - } - if (setsockopt(pipefd[1], SOL_SOCKET, SO_RCVBUF, &opt, optlen) < 0) { - ftdm_log(FTDM_LOG_WARNING, "mISDN Failed to set socket pair fd[1] RCVBUF: %s\n", - strerror(errno)); - } - if (setsockopt(pipefd[1], SOL_SOCKET, SO_SNDBUF, &opt, optlen) < 0) { - ftdm_log(FTDM_LOG_WARNING, "mISDN Failed to set socket pair fd[1] SNDBUF: %s\n", - strerror(errno)); - } - - priv->rx_audio_pipe_in = pipefd[1]; - priv->rx_audio_pipe_out = pipefd[0]; - - priv->tx_audio_pipe_in = pipefd[0]; - priv->tx_audio_pipe_out = pipefd[1]; - } -#endif - } else { - /* early activate D-Channel */ - misdn_activate_channel(ftdmchan); - ftdmchan->native_codec = ftdmchan->effective_codec = FTDM_CODEC_NONE; - } - num_configured++; - } - - return num_configured; -} - -static int misdn_find_device(const char *name, int nr_devices, struct mISDN_devinfo *info) -{ - struct mISDN_devinfo devinfo; - char *endp = NULL; - int port_id = -1; - int i; - - port_id = strtoul(name, &endp, 10); - if (endp == name || errno == EINVAL) - port_id = -1; - if (port_id < 0 || port_id >= nr_devices) - port_id = -1; - - for (i = 0; i < nr_devices; i++) { - memset(&devinfo, 0, sizeof(devinfo)); - devinfo.id = i; - - if (ioctl(globals.sockfd, IMGETDEVINFO, &devinfo) < 0) { - ftdm_log(FTDM_LOG_ERROR, "mISDN unable to get device %d info: %s\n", - devinfo.id, strerror(errno)); - return FTDM_FAIL; - } - if (devinfo.id == port_id) - break; - if (strlen(devinfo.name) <= 0) - continue; - if (!strcasecmp(devinfo.name, name)) - break; - } - if (i == nr_devices) - return FTDM_FAIL; - - if (info) *info = devinfo; - return FTDM_SUCCESS; -} - -#define MISDN_PH_TE_PROTOCOLS(x) \ - ((x) & ((1 << ISDN_P_TE_S0) | (1 << ISDN_P_TE_E1) | (1 << ISDN_P_TE_UP0))) -#define MISDN_PH_NT_PROTOCOLS(x) \ - ((x) & ((1 << ISDN_P_NT_S0) | (1 << ISDN_P_NT_E1) | (1 << ISDN_P_NT_UP0))) - -/** - * \brief Configure/open span ftmod_misdn settings - */ -static FIO_CONFIGURE_SPAN_FUNCTION(misdn_configure_span) -{ - struct misdn_span_private *span_priv = ftdm_span_io_private(span); - struct mISDN_devinfo devinfo; - int range_start = 0, range_end = 0; - int nr_ports = 0, nr_items = 0; - int res = 0, i; - char *chan_str, *ptr; - char *data = strdup(str); - char *item_list[10]; - - ftdm_unused_arg(name); - ftdm_unused_arg(number); - - /* only these are supported */ - switch (ftdm_span_get_trunk_type(span)) { - case FTDM_TRUNK_E1: - case FTDM_TRUNK_BRI: - case FTDM_TRUNK_BRI_PTMP: - break; - default: - ftdm_log(FTDM_LOG_ERROR, "Unsupported span type %s\n", - ftdm_span_get_trunk_type_str(span)); - return FTDM_FAIL; - } - - /* get port count */ - if (ioctl(globals.sockfd, IMGETCOUNT, &nr_ports) < 0) { - ftdm_log(FTDM_LOG_ERROR, "mISDN unable to get port count: %s\n", - strerror(errno)); - goto error; - } - if (nr_ports <= 0) { - ftdm_log(FTDM_LOG_ERROR, "No mISDN devices found\n"); - goto error; - } - - /* split configuration string into port ID and channel list */ - if (!(chan_str = strchr(data, ':'))) { - ftdm_log(FTDM_LOG_ERROR, "Invalid configuration string: %s\nExpected format :[-]\n", str); - goto error; - } - *chan_str++ = '\0'; - - /* lookup port id, by number first, then by name */ - if (misdn_find_device(data, nr_ports, &devinfo) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "No such mISDN device/port: %s\n", - data); - goto error; - } - if (devinfo.nrbchan == 0 || devinfo.channelmap == 0) { - ftdm_log(FTDM_LOG_ERROR, "mISDN device '%s' has no b-channels\n", - data); - goto error; - } - if (!MISDN_PH_TE_PROTOCOLS(devinfo.Dprotocols)) { - ftdm_log(FTDM_LOG_ERROR, "mISDN device '%s' does not support any ISDN TE modes\n", - data); - goto error; - } - - /* allocate span private */ - if (!span_priv) { - int pipe[2] = { -1, -1 }; - - /* - * Not perfect, there should be something like span_create too - */ - span_priv = calloc(1, sizeof(*span_priv)); - if (!span_priv) { - ftdm_log(FTDM_LOG_ERROR, "mISDN failed to allocate span private data\n"); - return FTDM_FAIL; - } - ftdm_span_io_private(span) = span_priv; - - /* init event condition */ - pthread_cond_init(&span_priv->event_cond, NULL); - pthread_mutex_init(&span_priv->event_cond_mutex, NULL); - - /* init control condition */ - pthread_cond_init(&span_priv->ctrl_cond, NULL); - pthread_mutex_init(&span_priv->ctrl_cond_mutex, NULL); - - /* create event pipe */ - if (pipe2(pipe, O_CLOEXEC) < 0) { - ftdm_log(FTDM_LOG_ERROR, "mISDN failed to create event pipe: %s\n", - strerror(errno)); - return FTDM_FAIL; - } - span_priv->event_pipe_in = pipe[0]; - span_priv->event_pipe_out = pipe[1]; - } - - /* split channel list by ',' */ - nr_items = ftdm_separate_string(chan_str, ',', item_list, ftdm_array_len(item_list)); - - for (i = 0; i < nr_items; i++) { - /* */ - if (!(ptr = strchr(item_list[i], '-'))) { - /* single channel */ - range_start = atoi(item_list[i]); - range_end = range_start; - } else { - *ptr++ = '\0'; - /* channel range */ - range_start = atoi(item_list[i]); - range_end = atoi(ptr); - } - - /* check if channel range/id is valid */ - if (range_start <= 0 || range_end <= 0 || range_end < range_start) { - ftdm_log(FTDM_LOG_ERROR, "Invalid configuration string: %s\n", - item_list[i]); - goto error; - } - - /* add range to span */ - res = misdn_open_range(span, type, &devinfo, range_start, range_end); - if (res <= 0) { - ftdm_log(FTDM_LOG_ERROR, "mISDN failed to configure channel(s)\n"); - goto error; - } - } - - ftdm_safe_free(data); - return res; -error: - ftdm_span_io_private(span) = NULL; - ftdm_safe_free(span_priv); - ftdm_safe_free(data); - return res; -} - -/** - * \brief Configure global ftmod_misdn settings - */ -static FIO_CONFIGURE_FUNCTION(misdn_configure) -{ - ftdm_unused_arg(category); - ftdm_unused_arg(var); - ftdm_unused_arg(val); - ftdm_unused_arg(lineno); - return FTDM_SUCCESS; -} - -/** - * \brief Retrieve alarm event information (if any) - * \param ftdmchan FreeTDM channel - */ -static FIO_GET_ALARMS_FUNCTION(misdn_get_alarms) -{ - ftdm_unused_arg(ftdmchan); -#if 0 -/* - Nope, this won't work... - - There's no way to create a separate "control" socket for a device - that can be used to send / receive MPH_INFORMATION_REQ/_IND without - having to care about PH_* messages in between... - - ... well, unless we use our own event loop (= thread) and - add event queues and data fifos, so we can sift all the - messages we get to forward them to the right receiver -*/ - char buf[MAX_DATA_MEM] = { 0 }; - struct sockaddr_mISDN addr; - struct mISDNhead *hh; - struct ph_info *phi = NULL; - struct pollfd pfd; - socklen_t addrlen = sizeof(addr); - int retval; - - /* use the global socket to query alarms */ - ftdm_log(FTDM_LOG_DEBUG, "mISDN getting alarms for channel %d:%d [%d:%d]\n", - ftdm_channel_get_span_id(ftdmchan), ftdm_channel_get_id(ftdmchan), - ftdm_channel_get_ph_span_id(ftdmchan), ftdm_channel_get_ph_id(ftdmchan)); - - memset(&addr, 0, sizeof(addr)); - addr.family = AF_ISDN; - addr.dev = ftdm_channel_get_ph_span_id(ftdmchan) - 1; - addr.channel = ftdm_channel_get_ph_id(ftdmchan) - 1; - - hh = (struct mISDNhead *)buf; - hh->prim = MPH_INFORMATION_REQ; - hh->id = MISDN_ID_ANY; - - /* */ - if ((retval = sendto(span_priv->ctrlsock, hh, sizeof(*hh), 0, (struct sockaddr *)&addr, addrlen)) <= 0) { - ftdm_log(FTDM_LOG_ERROR, "mISDN failed to send '%s' to channel %d:%d: %s\n", - misdn_event2str(hh->prim), ftdm_channel_get_span_id(ftdmchan), - ftdm_channel_get_id(ftdmchan), strerror(errno)); - return FTDM_FAIL; - } - - pfd.fd = span_priv->ctrlsock; - pfd.events = POLLIN /*| POLLPRI*/; - pfd.revents = 0; - - if ((retval = poll(&pfd, 1, -1)) <= 0) { - ftdm_log(FTDM_LOG_ERROR, "mISDN failed to poll for '%s' answer on channel %d:%d: %s\n", - misdn_event2str(hh->prim), ftdm_channel_get_span_id(ftdmchan), - ftdm_channel_get_id(ftdmchan), strerror(errno)); - return FTDM_FAIL; - } - - if (!(pfd.revents & (POLLIN | POLLPRI))) { - ftdm_log(FTDM_LOG_ERROR, "mISDN failed to poll for '%s' answer on channel %d:%d: %s\n", - misdn_event2str(hh->prim), ftdm_channel_get_span_id(ftdmchan), - ftdm_channel_get_id(ftdmchan), "No read/pri flag"); - return FTDM_FAIL; - } - - if ((retval = recvfrom(span_priv->ctrlsock, buf, sizeof(buf), 0, (struct sockaddr *)&addr, &addrlen)) < 0) { - ftdm_log(FTDM_LOG_ERROR, "mISDN failed to receive answer for '%s' on channel %d:%d: %s\n", - misdn_event2str(hh->prim), ftdm_channel_get_span_id(ftdmchan), - ftdm_channel_get_id(ftdmchan), strerror(errno)); - return FTDM_FAIL; - } - if (retval < MISDN_HEADER_LEN) { - ftdm_log(FTDM_LOG_ERROR, "mISDN short read on channel %d:%d\n", - ftdm_channel_get_span_id(ftdmchan), ftdm_channel_get_id(ftdmchan)); - return FTDM_FAIL; - } - - switch (hh->prim) { - case MPH_INFORMATION_IND: - ftdm_log(FTDM_LOG_DEBUG, "mISDN received '%s' on channel %d:%d, size %d bytes\n", - misdn_event2str(hh->prim), ftdm_channel_get_span_id(ftdmchan), - ftdm_channel_get_id(ftdmchan), retval); - break; - default: - ftdm_log(FTDM_LOG_ERROR, "mISDN received unexpected answer '%s' on channel %d:%d: %s\n", - misdn_event2str(hh->prim), ftdm_channel_get_span_id(ftdmchan), - ftdm_channel_get_id(ftdmchan), strerror(errno)); - return FTDM_FAIL; - } -#endif - return FTDM_SUCCESS; -} - - -/** - * \brief Poll for new events - * \param span FreeTDM span - * \param ms Timeout (in ms) - */ -static FIO_SPAN_POLL_EVENT_FUNCTION(misdn_poll_event) -{ - struct misdn_span_private *span_priv = ftdm_span_io_private(span); - struct timespec ts; - int retval = 0, nr_events = 0; - int i; - - ftdm_unused_arg(poll_events); - - for (i = 1; i <= ftdm_span_get_chan_count(span); i++) { - ftdm_channel_t *chan = ftdm_span_get_channel(span, i); - struct misdn_chan_private *chan_priv = ftdm_chan_io_private(chan); - - /* Skip channels that have event processing pending (Avoids event storms) */ - if (ftdm_test_io_flag(chan, FTDM_CHANNEL_IO_EVENT)) - continue; - - if (misdn_event_queue_has_data(chan_priv->events)) { -#ifdef MISDN_DEBUG_EVENTS - ftdm_log(FTDM_LOG_DEBUG, "mISDN channel %d:%d has event(s)\n", - ftdm_channel_get_span_id(chan), ftdm_channel_get_id(chan)); -#endif - ftdm_set_io_flag(chan, FTDM_CHANNEL_IO_EVENT); - chan->last_event_time = ftdm_current_time_in_ms(); - nr_events++; - } - } - if (nr_events) { -#ifdef MISDN_DEBUG_EVENTS - ftdm_log(FTDM_LOG_DEBUG, "mISDN span %d has %d new events pending (pre poll)\n", - ftdm_span_get_id(span), nr_events); -#endif - return FTDM_SUCCESS; - } - - -#ifdef MISDN_DEBUG_EVENTS - ftdm_log(FTDM_LOG_DEBUG, "mISDN span %d has no events pending, polling for new events with %d ms timeout\n", - ftdm_span_get_id(span), ms); -#endif - /* Wait at least 1 ms, max 1 s */ - ms = ftdm_clamp(ms, 1, 1000); - - clock_gettime(CLOCK_REALTIME, &ts); - ts_add_msec(&ts, ms); - - if ((retval = pthread_cond_timedwait(&span_priv->event_cond, &span_priv->event_cond_mutex, &ts))) { - switch (retval) { - case ETIMEDOUT: -#ifdef MISDN_DEBUG_EVENTS - ftdm_log(FTDM_LOG_DEBUG, "mISDN span %d: No events within %d ms\n", - ftdm_span_get_id(span), ms); -#endif - return FTDM_TIMEOUT; - default: - ftdm_log(FTDM_LOG_DEBUG, "mISDN failed to poll for events on span %d: %s\n", - ftdm_span_get_id(span), strerror(retval)); - return FTDM_FAIL; - } - } - -#ifdef MISDN_DEBUG_EVENTS - ftdm_log(FTDM_LOG_DEBUG, "mISDN span %d received new event notification, checking channel event queues\n", - ftdm_span_get_id(span)); -#endif - for (i = 1; i <= ftdm_span_get_chan_count(span); i++) { - ftdm_channel_t *chan = ftdm_span_get_channel(span, i); - struct misdn_chan_private *chan_priv = ftdm_chan_io_private(chan); - - /* Skip channels that have event processing pending (Avoids event storms) */ - if (ftdm_test_io_flag(chan, FTDM_CHANNEL_IO_EVENT)) - continue; - - if (misdn_event_queue_has_data(chan_priv->events)) { - ftdm_set_io_flag(chan, FTDM_CHANNEL_IO_EVENT); - chan->last_event_time = ftdm_current_time_in_ms(); - nr_events++; - } - } - return (nr_events) ? FTDM_SUCCESS : FTDM_TIMEOUT; /* no events? => timeout */ -} - -/** - * Retrieve event from channel - * \param ftdmchan Channel to retrieve event from - * \param event FreeTDM event to return - * \return Success or failure - */ -static FIO_CHANNEL_NEXT_EVENT_FUNCTION(misdn_channel_next_event) -{ - struct misdn_chan_private *chan_priv = ftdm_chan_io_private(ftdmchan); - struct misdn_event *evt = NULL; - ftdm_span_t *span = ftdm_channel_get_span(ftdmchan); - uint32_t event_id = FTDM_OOB_INVALID; - - ftdm_assert(span, "span == NULL"); - - ftdm_clear_io_flag(ftdmchan, FTDM_CHANNEL_IO_EVENT); - - if (!(evt = misdn_event_queue_pop(chan_priv->events))) { -#ifdef MISDN_DEBUG_EVENTS - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "mISDN channel event queue has no events\n"); -#endif - return FTDM_FAIL; - } - -#ifdef MISDN_DEBUG_EVENTS - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Got event '%s' from channel event queue\n", - misdn_event2str(evt->id)); -#endif - /* Convert from misdn event to ftdm */ - switch (evt->id) { - case PH_DEACTIVATE_IND: - event_id = FTDM_OOB_ALARM_TRAP; - ftdmchan->alarm_flags |= FTDM_ALARM_RED; - break; - case PH_ACTIVATE_IND: - event_id = FTDM_OOB_ALARM_CLEAR; - ftdmchan->alarm_flags &= ~FTDM_ALARM_RED; - break; - default: - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Unhandled event id %d (0x%x) %s\n", - evt->id, evt->id, misdn_event2str(evt->id)); - } - - ftdmchan->last_event_time = 0; - span->event_header.e_type = FTDM_EVENT_OOB; - span->event_header.enum_id = event_id; - span->event_header.channel = ftdmchan; - *event = &span->event_header; - return FTDM_SUCCESS; -} - -/** - * \brief Retrieve event - * \param span FreeTDM span - * \param event FreeTDM event - */ -static FIO_SPAN_NEXT_EVENT_FUNCTION(misdn_next_event) -{ - int32_t event_id = FTDM_OOB_INVALID; - int i; - - ftdm_log(FTDM_LOG_DEBUG, "Reading next event from span %d\n", - ftdm_span_get_id(span)); - - for (i = 1; i <= ftdm_span_get_chan_count(span); i++) { - ftdm_channel_t *chan = ftdm_span_get_channel(span, i); - struct misdn_chan_private *chan_priv = ftdm_chan_io_private(chan); - struct misdn_event *evt = NULL; - - ftdm_clear_io_flag(chan, FTDM_CHANNEL_IO_EVENT); - - if (!(evt = misdn_event_queue_pop(chan_priv->events))) { -#ifdef MISDN_DEBUG_EVENTS - ftdm_log_chan_msg(chan, FTDM_LOG_DEBUG, "mISDN channel event queue has no events\n"); -#endif - continue; - } - -#ifdef MISDN_DEBUG_EVENTS - ftdm_log_chan(chan, FTDM_LOG_DEBUG, "Got event '%s' from channel event queue\n", - misdn_event2str(evt->id)); -#endif - switch (evt->id) { - case PH_DEACTIVATE_IND: - event_id = FTDM_OOB_ALARM_TRAP; - chan->alarm_flags |= FTDM_ALARM_RED; - break; - case PH_ACTIVATE_IND: - event_id = FTDM_OOB_ALARM_CLEAR; - chan->alarm_flags &= ~FTDM_ALARM_RED; - break; - default: - ftdm_log(FTDM_LOG_ERROR, "Unhandled event id %d (0x%x) %s\n", - evt->id, evt->id, misdn_event2str(evt->id)); - continue; - } - - chan->last_event_time = 0; - span->event_header.e_type = FTDM_EVENT_OOB; - span->event_header.enum_id = event_id; - span->event_header.channel = chan; - *event = &span->event_header; - return FTDM_SUCCESS; - } - return FTDM_FAIL; -} - -/** - * \brief Shutdown ftmod_misdn channel - * \param ftdmchan FreeTDM channel - */ -static FIO_CHANNEL_DESTROY_FUNCTION(misdn_channel_destroy) -{ - struct misdn_chan_private *chan_priv = ftdm_chan_io_private(ftdmchan); - assert(chan_priv); - - ftdm_log(FTDM_LOG_DEBUG, "Destroying channel %d:%d\n", - ftdm_channel_get_span_id(ftdmchan), - ftdm_channel_get_id(ftdmchan)); - - if (ftdmchan->sockfd >= 0) { - close(ftdmchan->sockfd); - ftdmchan->sockfd = -1; - } - - /* - * Destroy fifo + event queue - */ - if (chan_priv->events) - misdn_event_queue_destroy(&chan_priv->events); - - ftdm_chan_io_private(ftdmchan) = NULL; - ftdm_safe_free(chan_priv); - - ftdm_log(FTDM_LOG_DEBUG, "mISDN channel %d:%d destroyed\n", - ftdm_channel_get_span_id(ftdmchan), ftdm_channel_get_id(ftdmchan)); - return FTDM_SUCCESS; -} - -/** - * \brief Shutdown ftmod_misdn span - * \param span FreeTDM span - */ -static FIO_SPAN_DESTROY_FUNCTION(misdn_span_destroy) -{ - struct misdn_span_private *span_priv = ftdm_span_io_private(span); - - /* free resources */ - ftdm_span_io_private(span) = NULL; - ftdm_safe_free(span_priv); - - ftdm_log(FTDM_LOG_DEBUG, "mISDN span %d (%s) destroyed\n", - ftdm_span_get_id(span), ftdm_span_get_name(span)); - return FTDM_SUCCESS; -} - - -/** - * Called by misdn_span_run() to handle incoming b-channel events - * \param[in] chan FreeTDM channel object - * \return FTDM_SUCCESS on success, FTDM_* on error - */ -static ftdm_status_t handle_b_channel_event(ftdm_channel_t *chan) -{ - struct misdn_chan_private *priv = ftdm_chan_io_private(chan); - char buf[MAX_DATA_MEM] = { 0 }; - struct mISDNhead *mh = (void *)buf; - int retval, retries = 5; - - do { - /* - * Retry reading multiple times if recvfrom() returns EAGAIN - */ - retval = recvfrom(chan->sockfd, buf, sizeof(buf), 0, NULL, NULL); - if (retval < 0 && errno != EAGAIN) - break; - - } while (retval < 0 && retries-- > 0); - - if (retval < 0) { - ftdm_log_chan(chan, FTDM_LOG_ERROR, "mISDN failed to receive message: %s\n", - strerror(errno)); - return FTDM_FAIL; - } - if (retval < MISDN_HEADER_LEN) { - ftdm_log_chan(chan, FTDM_LOG_ERROR, "mISDN message too short, min.: %d, read: %d\n", - (int)MISDN_HEADER_LEN, retval); - return FTDM_FAIL; - } - - switch (mh->prim) { - case PH_DATA_IND: { - int datalen = retval - MISDN_HEADER_LEN; - char *data = buf + MISDN_HEADER_LEN; - - /* Discard incoming audio if not active */ - if (priv->active) { - /* Convert audio data */ - misdn_convert_audio_bits(data, datalen); - - /* Write audio into receive pipe */ - if ((retval = write(priv->rx_audio_pipe_in, data, datalen)) < 0) { - ftdm_log_chan(chan, FTDM_LOG_ERROR, "mISDN failed to write audio data into rx pipe: %s\n", - strerror(errno)); - return FTDM_FAIL; - } else if (retval < datalen) { - ftdm_log_chan(chan, FTDM_LOG_ERROR, "mISDN short write into rx pipe, written: %d, expected: %d\n", - retval, datalen); - return FTDM_FAIL; - } - } - - /* Get receive buffer usage */ - if (ioctl(priv->tx_audio_pipe_out, FIONREAD, &retval) < 0) { - ftdm_log_chan(chan, FTDM_LOG_ERROR, "mISDN failed to get tx audio buffer usage: %s\n", - strerror(errno)); - return FTDM_FAIL; - } else if (retval < datalen) { -// ftdm_log_chan(chan, FTDM_LOG_DEBUG, "mISDN has not enough bytes in tx audio pipe, available: %d, requested: %d\n", -// retval, datalen); - priv->tx_pipe_under_cnt++; - return FTDM_SUCCESS; - } - -#ifdef MISDN_DEBUG_IO - ftdm_log_chan(chan, FTDM_LOG_INFO, "mISDN tx audio buffer usage: %d\n", - retval); -#endif - - /* Get audio from tx pipe */ - if ((retval = read(priv->tx_audio_pipe_out, data, datalen)) < 0) { - ftdm_log_chan(chan, FTDM_LOG_ERROR, "mISDN failed to read audio data from tx pipe: %s\n", - strerror(errno)); - return FTDM_FAIL; - } else if (retval == 0) { - ftdm_log_chan_msg(chan, FTDM_LOG_NOTICE, "mISDN tx pipe is empty\n"); - priv->tx_pipe_under_cnt++; - return FTDM_SUCCESS; - } else if (retval < datalen) { - ftdm_log_chan(chan, FTDM_LOG_NOTICE, "mISDN short read from tx pipe, read: %d, expected: %d\n", - retval, datalen); - priv->tx_pipe_under_cnt++; - priv->tx_miss_bytes += ftdm_max(0, datalen - retval); - datalen = retval; - } - priv->tx_pipe_rd_bytes += retval; - - if (!priv->active) { - /* discard */ - return FTDM_SUCCESS; - } - - /* Convert audio data */ - misdn_convert_audio_bits(data, datalen); - - /* Write to channel */ - mh->prim = PH_DATA_REQ; - mh->id = 0; - datalen += MISDN_HEADER_LEN; - - if ((retval = write(chan->sockfd, buf, datalen)) < 0) { - ftdm_log_chan(chan, FTDM_LOG_ERROR, "mISDN failed to write audio data into b-channel: %s\n", - strerror(errno)); - return FTDM_FAIL; - } else if (retval < datalen) { - ftdm_log_chan(chan, FTDM_LOG_WARNING, "mISDN short write into b-channel, written: %d, expected: %d\n", - retval, datalen); - priv->tx_lost_bytes += ftdm_max(0, datalen - retval - MISDN_HEADER_LEN); - } - priv->tx_sent_bytes += ftdm_max(0, retval - MISDN_HEADER_LEN); - break; - } - case PH_DATA_CNF: - priv->tx_ack_cnt++; - break; - case PH_DEACTIVATE_IND: - priv->active = 0; - break; - case PH_ACTIVATE_IND: - priv->active = 1; - break; - case PH_CONTROL_IND: { - int datalen = retval - MISDN_HEADER_LEN; - char *data = buf + MISDN_HEADER_LEN; - - misdn_handle_ph_control_ind(chan, mh, data, datalen); - break; - } - default: - ftdm_log_chan(chan, FTDM_LOG_ERROR, "mISDN received unknown/unhandled event primitive: (%d) %s\n", - mh->prim, misdn_event2str(mh->prim)); - break; - } - return FTDM_SUCCESS; -} - - -/** - * Timeout (miliseconds) for epoll_wait() - */ -#define MISDN_EPOLL_WAIT_MAX_MSEC 1000 - -/** - * mISDN I/O thread - * This thread handles all of the B-Channel I/O, this avoids all of the hazzles with - * intermixed data + control frames on mISDN sockets and the missing write poll support on B-Channels. - * - * Each channel uses a unix stream socketpair as a two-way, pipe replacement for incoming and outgoing - * data. Socketpairs allow a more fine grained tuning of the buffer sizes (pipe are restricted to multiples of - * the native page size (with the smallest possible size (4k) being already 500ms worth of audio). - * - * The socketpair buffer sizes and the send algorithm have been carefully tuned to: - * - * - Minimize the risk of sending too much data and making the mISDN drivers unhappy, by - * sending PH_DATA_REQ only when there is as much data available as we have received in - * the PH_DATA_IND. - * - * - Avoid deadlocks between ftdm_write() trying to fill an almust full socket buffer and - * the I/O thread not having enough data to send a PH_DATA_REQ message. - * (The write() call will return EAGAIN since there is not ehough space free to send all audio data.) - * - * \param thread FreeTDM thread handle - * \param data Private data pointer passed to ftdm_thread_create_detached() (the span object) - * \return Always returns NULL (unused) - * - * \note - * ftdm_span_start/_stop() locks the span mutex, - * use direct access to span members to avoid deadlocking - * - * \todo - * Move D-Channel handling into the I/O thread too. - * Use custom ring buffer structures instead of socketpairs - * (for even more fine grained size control). - */ -static void *misdn_span_run(ftdm_thread_t *thread, void *data) -{ - ftdm_span_t *span = data; - struct misdn_span_private *priv = ftdm_span_io_private(span); - struct epoll_event evh; - int epfd = -1; - int ret; - int i; - - ftdm_unused_arg(thread); - ftdm_log(FTDM_LOG_NOTICE, "mISDN[%d:%s] span thread initializing\n", - ftdm_span_get_id(span), ftdm_span_get_name(span)); - - /* Use epoll for event handling */ - epfd = epoll_create(1); - if (epfd < 0) { - ftdm_log(FTDM_LOG_ERROR, "mISDN[%d:%s] failed to create epoll context: %s\n", - ftdm_span_get_id(span), ftdm_span_get_name(span), strerror(errno)); - goto error; - } - - ftdm_log(FTDM_LOG_DEBUG, "mISDN[%d:%s] adding event pipe to epoll context\n", - ftdm_span_get_id(span), ftdm_span_get_name(span)); - - /* Add event pipe */ - evh.events = EPOLLIN | EPOLLPRI | EPOLLERR; - evh.data.fd = priv->event_pipe_out; - - ret = epoll_ctl(epfd, EPOLL_CTL_ADD, priv->event_pipe_out, &evh); - if (ret < 0) { - ftdm_log(FTDM_LOG_ERROR, "mISDN[%d:%s] failed to add event pipe to epoll context: %s\n", - ftdm_span_get_id(span), ftdm_span_get_name(span), strerror(errno)); - goto error; - } - - ftdm_log(FTDM_LOG_DEBUG, "mISDN[%d:%s] adding b-channels to epoll context\n", - ftdm_span_get_id(span), ftdm_span_get_name(span)); - - /* Add b-channels */ - for (i = 1; i <= span->chan_count; i++) { - ftdm_channel_t *chan = span->channels[i]; - ftdm_assert(chan, "channel == NULL"); - - if (ftdm_channel_get_type(chan) != FTDM_CHAN_TYPE_B) - continue; - - ftdm_log(FTDM_LOG_DEBUG, "mISDN[%d:%s] adding b-channel [%d:%d] to epoll context\n", - ftdm_span_get_id(span), ftdm_span_get_name(span), - ftdm_channel_get_id(chan), ftdm_channel_get_ph_id(chan)); - - evh.events = EPOLLIN | EPOLLPRI | EPOLLERR; - evh.data.ptr = chan; - - ret = epoll_ctl(epfd, EPOLL_CTL_ADD, chan->sockfd, &evh); - if (ret < 0) { - ftdm_log(FTDM_LOG_ERROR, "mISDN[%d:%s] failed to add b-channel [%d] socket to epoll context: %s\n", - ftdm_span_get_id(span), ftdm_span_get_name(span), ftdm_channel_get_id(chan), strerror(errno)); - goto error; - } - } - - ftdm_log(FTDM_LOG_NOTICE, "mISDN[%d:%s] span thread started\n", - ftdm_span_get_id(span), ftdm_span_get_name(span)); - - /* Notify world we're running */ - priv->running = 1; - pthread_cond_signal(&priv->ctrl_cond); - - while (priv->running > 0) { - struct epoll_event ev[10]; - int timeout_ms = MISDN_EPOLL_WAIT_MAX_MSEC; - - ret = epoll_wait(epfd, ev, ftdm_array_len(ev), timeout_ms); - if (ret < 0) { - switch (errno) { - case EAGAIN: - case EINTR: - continue; - default: - ftdm_log(FTDM_LOG_ERROR, "mISDN[%d:%s] epoll_wait() failed: %s\n", - ftdm_span_get_id(span), ftdm_span_get_name(span), strerror(errno)); - goto error; - } - } - /* Check events */ - for (i = 0; i < ret; i++) { - /* */ - if (ev[i].data.fd == priv->event_pipe_out) { - struct misdn_command cmd; - /* event pipe */ - ftdm_log(FTDM_LOG_DEBUG, "mISDN[%d:%s] event pipe notification\n", - ftdm_span_get_id(span), ftdm_span_get_name(span)); - ret = read(priv->event_pipe_out, &cmd, sizeof(cmd)); - if (ret < sizeof(cmd)) { - ftdm_log(FTDM_LOG_ERROR, "mISDN[%d:%s] failed to read span thread command\n", - ftdm_span_get_id(span), ftdm_span_get_name(span)); - continue; - } - - switch (cmd.type) { - case MISDN_CMD_STOP: - ftdm_log(FTDM_LOG_ERROR, "mISDN[%d:%s] got STOP command\n", - ftdm_span_get_id(span), ftdm_span_get_name(span)); - priv->running = -1; - break; - default: - ftdm_log(FTDM_LOG_ERROR, "mISDN[%d:%s] got unknown command: %d\n", - ftdm_span_get_id(span), ftdm_span_get_name(span), cmd.type); - } - - } else { - ftdm_channel_t *chan = ev[i].data.ptr; - handle_b_channel_event(chan); - } - } - } -error: - ftdm_log(FTDM_LOG_NOTICE, "mISDN[%d:%s] span thread stopped\n", - ftdm_span_get_id(span), ftdm_span_get_name(span)); - - /* Remove epoll event sources */ - for (i = 1; i <= span->chan_count; i++) { - ftdm_channel_t *chan = span->channels[i]; - ftdm_assert(chan, "channel == NULL"); - - if (ftdm_channel_get_type(chan) != FTDM_CHAN_TYPE_B) - continue; - - ret = epoll_ctl(epfd, EPOLL_CTL_DEL, chan->sockfd, NULL); - if (ret < 0) { - ftdm_log(FTDM_LOG_ERROR, "mISDN[%d:%s] failed to remove b-channel [%d] socket from epoll context: %s\n", - ftdm_span_get_id(span), ftdm_span_get_name(span), ftdm_channel_get_id(chan), strerror(errno)); - } - } - - /* Close epoll context */ - if (epfd >= 0) close(epfd); - - /* Notify world we stopped running */ - priv->running = 0; - pthread_cond_signal(&priv->ctrl_cond); - return NULL; -} - -/** - * Timeout (miliseconds) for span start/stop completion - */ -#define SPAN_DEFAULT_TIMEOUT_MSEC 10000 - -static FIO_SPAN_START_FUNCTION(misdn_span_start) -{ - struct misdn_span_private *span_priv = ftdm_span_io_private(span); - struct timespec timeout; - int retval; - - ftdm_log(FTDM_LOG_NOTICE, "mISDN starting span %d (%s)\n", - ftdm_span_get_id(span), ftdm_span_get_name(span)); - - span_priv->running = 0; - - if (ftdm_thread_create_detached(misdn_span_run, span) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "mISDN failed to start span %d (%s)\n", - ftdm_span_get_id(span), ftdm_span_get_name(span)); - return FTDM_FAIL; - } - - /* - * Wait SPAN_DEFAULT_TIMEOUT_MSEC miliseconds for I/O thread to start up - */ - clock_gettime(CLOCK_REALTIME, &timeout); - ts_add_msec(&timeout, SPAN_DEFAULT_TIMEOUT_MSEC); - - pthread_mutex_lock(&span_priv->ctrl_cond_mutex); - - retval = pthread_cond_timedwait(&span_priv->ctrl_cond, &span_priv->ctrl_cond_mutex, &timeout); - if (retval == ETIMEDOUT) { - ftdm_log(FTDM_LOG_ERROR, "mISDN failed to start span %d (%s) in 10 seconds\n", - ftdm_span_get_id(span), ftdm_span_get_name(span)); - return FTDM_FAIL; - } else if (retval) { - ftdm_log(FTDM_LOG_ERROR, "mISDN failed to start span %d (%s): %s\n", - ftdm_span_get_id(span), ftdm_span_get_name(span), strerror(errno)); - return FTDM_FAIL; - } - - pthread_mutex_unlock(&span_priv->ctrl_cond_mutex); - return FTDM_SUCCESS; -} - -static FIO_SPAN_STOP_FUNCTION(misdn_span_stop) -{ - struct misdn_span_private *span_priv = ftdm_span_io_private(span); - struct timespec timeout; - struct misdn_command cmd; - int retval; - - ftdm_log(FTDM_LOG_NOTICE, "mISDN stopping span %d (%s)\n", - ftdm_span_get_id(span), ftdm_span_get_name(span)); - - span_priv->running = -1; - - /* Wake up thread */ - cmd.type = MISDN_CMD_STOP; - retval = write(span_priv->event_pipe_in, &cmd, sizeof(cmd)); - if (retval < sizeof(cmd)) { - ftdm_log(FTDM_LOG_WARNING, "mISDN failed to send STOP command to span thread\n"); - } - - /* - * Wait SPAN_DEFAULT_TIMEOUT_MSEC miliseconds for I/O thread to shut down - */ - clock_gettime(CLOCK_REALTIME, &timeout); - ts_add_msec(&timeout, SPAN_DEFAULT_TIMEOUT_MSEC); - - pthread_mutex_lock(&span_priv->ctrl_cond_mutex); - - retval = pthread_cond_timedwait(&span_priv->ctrl_cond, &span_priv->ctrl_cond_mutex, &timeout); - if (retval == ETIMEDOUT) { - ftdm_log(FTDM_LOG_ERROR, "mISDN failed to stop thread in 10 seconds\n"); - return FTDM_FAIL; - } else if (retval) { - ftdm_log(FTDM_LOG_ERROR, "mISDN failed to stop thread: %s\n", - strerror(errno)); - return FTDM_FAIL; - } - - pthread_mutex_unlock(&span_priv->ctrl_cond_mutex); - return FTDM_SUCCESS; -} - - -/** - * \brief ftmod_misdn interface - */ -static const ftdm_io_interface_t misdn_interface = { - .name = "misdn", - - .open = misdn_open, - .close = misdn_close, - .wait = misdn_wait, - .read = misdn_read, - .write = misdn_write, - - .poll_event = misdn_poll_event, - .next_event = misdn_next_event, - - .command = misdn_command, - .get_alarms = misdn_get_alarms, - .configure = misdn_configure, /* configure global parameters */ - .configure_span = misdn_configure_span, /* assign channels to span */ - .channel_next_event = misdn_channel_next_event, - .channel_destroy = misdn_channel_destroy, /* clean up channel */ - .span_destroy = misdn_span_destroy, /* clean up span */ - - .span_start = misdn_span_start, - .span_stop = misdn_span_stop, -}; - - -/** - * \brief ftmod_misdn module init function - */ -static FIO_IO_LOAD_FUNCTION(misdn_load) -{ - struct mISDNversion ver; - struct mISDN_devinfo devinfo; - int devcnt, usecnt; - int i; - - /* */ - globals.sockfd = socket(PF_ISDN, SOCK_RAW, ISDN_P_BASE); - if (globals.sockfd < 0) { - ftdm_log(FTDM_LOG_CRIT, "Unable to create mISDN base socket (are you sure this kernel has mISDN support?)\n"); - return FTDM_FAIL; - } - - if (ioctl(globals.sockfd, IMGETVERSION, &ver) < 0) { - ftdm_log(FTDM_LOG_CRIT, "Unable to retrieve mISDN version\n"); - goto error; - } - - ftdm_log(FTDM_LOG_INFO, "mISDN Interface version %hhd.%hhd.%hd\n", ver.major, ver.minor, ver.release); - - devcnt = 0; - if (ioctl(globals.sockfd, IMGETCOUNT, &devcnt) < 0) { - ftdm_log(FTDM_LOG_CRIT, "Unable to retrieve number of mISDN devices\n"); - goto error; - - } - - if (!devcnt) { - ftdm_log(FTDM_LOG_CRIT, "No mISDN devices found\n"); - goto error; - } - usecnt = devcnt; - - ftdm_log(FTDM_LOG_INFO, "Found %d mISDN devices:\n", devcnt); - - /* Output most important device information */ - for (i = 0; i < devcnt; i++) { - int caps = MISDN_CAPS_NONE; - - devinfo.id = i; - if (ioctl(globals.sockfd, IMGETDEVINFO, &devinfo) < 0) { - ftdm_log(FTDM_LOG_ERROR, "Failed to retrieve information for device %d\n", i); - continue; - } - - /* print */ - ftdm_log(FTDM_LOG_INFO, "<%d> Name: %s, B-Channels: %d\n", - devinfo.id, - ftdm_strlen_zero_buf(devinfo.name) ? "Unknown" : devinfo.name, - devinfo.nrbchan); - - /* D-Channels capabilities */ - if (devinfo.Dprotocols & (1 << ISDN_P_TE_E1)) - caps |= MISDN_CAPS_TE | MISDN_CAPS_PRI; - if (devinfo.Dprotocols & (1 << ISDN_P_NT_E1)) - caps |= MISDN_CAPS_NT | MISDN_CAPS_PRI; - if (devinfo.Dprotocols & (1 << ISDN_P_TE_S0)) - caps |= MISDN_CAPS_TE | MISDN_CAPS_BRI; - if (devinfo.Dprotocols & (1 << ISDN_P_NT_S0)) - caps |= MISDN_CAPS_NT | MISDN_CAPS_BRI; -#ifdef ISDN_P_TE_UP0 - if (devinfo.Dprotocols & (1 << ISDN_P_TE_UP0)) - caps |= MISDN_CAPS_TE | MISDN_CAPS_UP0 | MISDN_CAPS_BRI; -#endif -#ifdef ISDN_P_NT_UP0 - if (devinfo.Dprotocols & (1 << ISDN_P_NT_UP0)) - caps |= MISDN_CAPS_NT | MISDN_CAPS_UP0 | MISDN_CAPS_BRI; -#endif - /* B-Channel capabilities */ - if (devinfo.Bprotocols & (1 << (ISDN_P_B_RAW & ISDN_P_B_MASK))) - caps |= MISDN_CAPS_RAW; - if (devinfo.Bprotocols & (1 << (ISDN_P_B_HDLC & ISDN_P_B_MASK))) - caps |= MISDN_CAPS_HDLC; - - ftdm_log(FTDM_LOG_INFO, " Type: %s, Modes: %s %s\n", - MISDN_IS_PRI(caps) ? "PRI" : "BRI", - MISDN_IS_NT(caps) ? "NT" : "", - MISDN_IS_TE(caps) ? "TE" : ""); - - ftdm_log(FTDM_LOG_INFO, " B-Channel modes: %s %s\n", - MISDN_IS_RAW(caps) ? "RAW" : "", - MISDN_IS_HDLC(caps) ? "HDLC" : ""); - - if (!(MISDN_IS_NT(caps) || MISDN_IS_TE(caps)) && !MISDN_IS_RAW(caps)) { - ftdm_log(FTDM_LOG_ERROR, " This device is unusable!\n"); - usecnt--; - } - } - if (!usecnt) { - ftdm_log(FTDM_LOG_CRIT, "No useable devices found!\n"); - goto error; - } - - ftdm_log(FTDM_LOG_INFO, "Found %d useable mISDN devices\n", usecnt); - - /* assign interface struct */ - *fio = (ftdm_io_interface_t *)&misdn_interface; - return FTDM_SUCCESS; -error: - if (globals.sockfd >= 0) - close(globals.sockfd); - return FTDM_FAIL; -} - -/** - * \brief ftmod_misdn module shutdown - */ -static FIO_IO_UNLOAD_FUNCTION(misdn_unload) -{ - if (globals.sockfd >= 0) - close(globals.sockfd); - return FTDM_SUCCESS; -} - -/** - * \brief ftmod_misdn module - */ -ftdm_module_t ftdm_module = { - .name = "misdn", - .io_load = misdn_load, - .io_unload = misdn_unload -}; diff --git a/libs/freetdm/src/ftmod/ftmod_pika/ftdm_pika.h b/libs/freetdm/src/ftmod/ftmod_pika/ftdm_pika.h deleted file mode 100644 index 54c550e8e7..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_pika/ftdm_pika.h +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2007-2014, Anthony Minessale II - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef FTDM_PIKA_H -#define FTDM_PIKA_H -#include "freetdm.h" -#include "pikahmpapi.h" - - - -#define PIKA_STR2ENUM_P(_FUNC1, _FUNC2, _TYPE) _TYPE _FUNC1 (const char *name); const char * _FUNC2 (_TYPE type); -#define PIKA_STR2ENUM(_FUNC1, _FUNC2, _TYPE, _STRINGS, _MAX) \ - _TYPE _FUNC1 (const char *name) \ - { \ - int i; \ - _TYPE t = _MAX ; \ - \ - for (i = 0; i < _MAX ; i++) { \ - if (!strcasecmp(name, _STRINGS[i])) { \ - t = (_TYPE) i; \ - break; \ - } \ - } \ - \ - return t; \ - } \ - const char * _FUNC2 (_TYPE type) \ - { \ - if (type > _MAX) { \ - type = _MAX; \ - } \ - return _STRINGS[(int)type]; \ - } - - -typedef enum { - PIKA_SPAN_FRAMING_T1_D4, - PIKA_SPAN_FRAMING_T1_ESF, - PIKA_SPAN_FRAMING_E1_BASIC, - PIKA_SPAN_FRAMING_E1_CRC4, - PIKA_SPAN_INVALID -} PIKA_TSpanFraming; -#define PIKA_SPAN_STRINGS "T1_D4", "T1_ESF", "E1_BASIC", "E1_CRC4" -PIKA_STR2ENUM_P(pika_str2span, pika_span2str, PIKA_TSpanFraming) - -typedef enum { - PIKA_SPAN_ENCODING_T1_AMI_ZS_NONE, - PIKA_SPAN_ENCODING_T1_AMI_ZS_GTE, - PIKA_SPAN_ENCODING_T1_AMI_ZS_BELL, - PIKA_SPAN_ENCODING_T1_AMI_ZS_JAM8, - PIKA_SPAN_ENCODING_T1_B8ZS, - PIKA_SPAN_ENCODING_E1_AMI, - PIKA_SPAN_ENCODING_E1_HDB3, - PIKA_SPAN_ENCODING_INVALID -} PIKA_TSpanEncoding; -#define PIKA_SPAN_ENCODING_STRINGS "T1_AMI_ZS_NONE", "T1_AMI_ZS_GTE", "T1_AMI_ZS_BELL", "T1_AMI_ZS_JAM8", "T1_B8ZS", "E1_AMI", "E1_HDB3" -PIKA_STR2ENUM_P(pika_str2span_encoding, pika_span_encoding2str, PIKA_TSpanEncoding) - -typedef enum { - PIKA_SPAN_LOOP_LENGTH_SHORT_HAUL, - PIKA_SPAN_LOOP_LENGTH_LONG_HAUL, - PIKA_SPAN_LOOP_INVALID -} PIKA_TSpanLoopLength; -#define PIKA_LL_STRINGS "SHORT_HAUL", "LONG_HAUL" -PIKA_STR2ENUM_P(pika_str2loop_length, pika_loop_length2str, PIKA_TSpanLoopLength) - -typedef enum { - PIKA_SPAN_LBO_T1_LONG_0_DB, - PIKA_SPAN_LBO_T1_LONG_7_DB, - PIKA_SPAN_LBO_T1_LONG_15_DB, - PIKA_SPAN_LBO_T1_LONG_22_DB, - PIKA_SPAN_LBO_T1_SHORT_133_FT, - PIKA_SPAN_LBO_T1_SHORT_266_FT, - PIKA_SPAN_LBO_T1_SHORT_399_FT, - PIKA_SPAN_LBO_T1_SHORT_533_FT, - PIKA_SPAN_LBO_T1_SHORT_655_FT, - PIKA_SPAN_LBO_E1_WAVEFORM_120_OHM, - PIKA_SPAN_LBO_INVALID -} PIKA_TSpanBuildOut; -#define PIKA_LBO_STRINGS "T1_LONG_0_DB", "T1_LONG_7_DB", "T1_LONG_15_DB", "T1_LONG_22_DB", "T1_SHORT_133_FT", "T1_SHORT_266_FT", "T1_SHORT_399_FT", "T1_SHORT_533_FT", "T1_SHORT_655_FT", "E1_WAVEFORM_120_OHM" -PIKA_STR2ENUM_P(pika_str2lbo, pika_lbo2str, PIKA_TSpanBuildOut) - -typedef enum { - PIKA_SPAN_COMPAND_MODE_MU_LAW = 1, - PIKA_SPAN_COMPAND_MODE_A_LAW, - PIKA_SPAN_COMPAND_MODE_INVALID -} PIKA_TSpanCompandMode; -#define PIKA_SPAN_COMPAND_MODE_STRINGS "MU_LAW", "A_LAW" -PIKA_STR2ENUM_P(pika_str2compand_mode, pika_compand_mode2str, PIKA_TSpanCompandMode) - -#endif - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/ftmod/ftmod_pika/ftmod_pika.2008.vcproj b/libs/freetdm/src/ftmod/ftmod_pika/ftmod_pika.2008.vcproj deleted file mode 100644 index 7ad535ea3f..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_pika/ftmod_pika.2008.vcproj +++ /dev/null @@ -1,353 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/freetdm/src/ftmod/ftmod_pika/ftmod_pika.2010.vcxproj.filters b/libs/freetdm/src/ftmod/ftmod_pika/ftmod_pika.2010.vcxproj.filters deleted file mode 100644 index 4d4cec4668..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_pika/ftmod_pika.2010.vcxproj.filters +++ /dev/null @@ -1,23 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - - - Source Files - - - - - Header Files - - - \ No newline at end of file diff --git a/libs/freetdm/src/ftmod/ftmod_pika/ftmod_pika.c b/libs/freetdm/src/ftmod/ftmod_pika/ftmod_pika.c deleted file mode 100644 index fcd5149814..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_pika/ftmod_pika.c +++ /dev/null @@ -1,1469 +0,0 @@ -/* - * Copyright (c) 2007-2014, Anthony Minessale II - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -#include "freetdm.h" -#include "ftdm_pika.h" - - -#define MAX_NUMBER_OF_TRUNKS 64 -#define PIKA_BLOCK_SIZE 160 -#define PIKA_BLOCK_LEN 20 -#define PIKA_NUM_BUFFERS 8 -#define TRY_OR_DIE(__code, __status, __label) if ((status = __code ) != __status) goto __label -#define pk_atof(__a) (PK_FLOAT) atof(__a) - -PK_VOID PK_CALLBACK media_out_callback(PKH_TPikaEvent *event); - -FTDM_ENUM_NAMES(PIKA_SPAN_NAMES, PIKA_SPAN_STRINGS) -PIKA_STR2ENUM(pika_str2span, pika_span2str, PIKA_TSpanFraming, PIKA_SPAN_NAMES, PIKA_SPAN_INVALID) - -FTDM_ENUM_NAMES(PIKA_SPAN_ENCODING_NAMES, PIKA_SPAN_ENCODING_STRINGS) -PIKA_STR2ENUM(pika_str2span_encoding, pika_span_encoding2str, PIKA_TSpanEncoding, PIKA_SPAN_ENCODING_NAMES, PIKA_SPAN_ENCODING_INVALID) - -FTDM_ENUM_NAMES(PIKA_LL_NAMES, PIKA_LL_STRINGS) -PIKA_STR2ENUM(pika_str2loop_length, pika_loop_length2str, PIKA_TSpanLoopLength, PIKA_LL_NAMES, PIKA_SPAN_LOOP_INVALID) - -FTDM_ENUM_NAMES(PIKA_LBO_NAMES, PIKA_LBO_STRINGS) -PIKA_STR2ENUM(pika_str2lbo, pika_lbo2str, PIKA_TSpanBuildOut, PIKA_LBO_NAMES, PIKA_SPAN_LBO_INVALID) - -FTDM_ENUM_NAMES(PIKA_SPAN_COMPAND_MODE_NAMES, PIKA_SPAN_COMPAND_MODE_STRINGS) -PIKA_STR2ENUM(pika_str2compand_mode, pika_compand_mode2str, PIKA_TSpanCompandMode, PIKA_SPAN_COMPAND_MODE_NAMES, PIKA_SPAN_COMPAND_MODE_INVALID) - - -typedef enum { - PK_FLAG_READY = (1 << 0), - PK_FLAG_LOCKED = (1 << 1) -} pk_flag_t; - -struct general_config { - uint32_t region; -}; -typedef struct general_config general_config_t; - -struct pika_channel_profile { - char name[80]; - PKH_TRecordConfig record_config; - PKH_TPlayConfig play_config; - int ec_enabled; - PKH_TECConfig ec_config; - PKH_TSpanConfig span_config; - general_config_t general_config; - int cust_span; -}; -typedef struct pika_channel_profile pika_channel_profile_t; - -static struct { - PKH_TSystemDeviceList board_list; - TPikaHandle open_boards[MAX_NUMBER_OF_TRUNKS]; - TPikaHandle system_handle; - PKH_TSystemConfig system_config; - PKH_TRecordConfig record_config; - PKH_TPlayConfig play_config; - PKH_TECConfig ec_config; - PKH_TSpanConfig t1_span_config; - PKH_TSpanConfig e1_span_config; - ftdm_hash_t *profile_hash; - general_config_t general_config; -} globals; - - -struct pika_span_data { - TPikaHandle event_queue; - PKH_TPikaEvent last_oob_event; - uint32_t boardno; - PKH_TSpanConfig span_config; - TPikaHandle handle; - uint32_t flags; -}; -typedef struct pika_span_data pika_span_data_t; - -struct pika_chan_data { - TPikaHandle handle; - TPikaHandle media_in; - TPikaHandle media_out; - TPikaHandle media_in_queue; - TPikaHandle media_out_queue; - PKH_TPikaEvent last_media_event; - PKH_TPikaEvent last_oob_event; - PKH_TRecordConfig record_config; - PKH_TPlayConfig play_config; - int ec_enabled; - PKH_TECConfig ec_config; - PKH_THDLCConfig hdlc_config; - ftdm_buffer_t *digit_buffer; - ftdm_mutex_t *digit_mutex; - ftdm_size_t dtmf_len; - uint32_t flags; - uint32_t hdlc_bytes; -}; -typedef struct pika_chan_data pika_chan_data_t; - -static const char *pika_board_type_string(PK_UINT type) -{ - if (type == PKH_BOARD_TYPE_DIGITAL_GATEWAY) { - return "digital_gateway"; - } - - if (type == PKH_BOARD_TYPE_ANALOG_GATEWAY) { - return "analog_gateway"; - } - - return "unknown"; -} - -/** - * \brief Process configuration variable for a pika profile - * \param category Pika profile name - * \param var Variable name - * \param val Variable value - * \param lineno Line number from configuration file (unused) - * \return Success - */ -static FIO_CONFIGURE_FUNCTION(pika_configure) -{ - pika_channel_profile_t *profile = NULL; - int ok = 1; - - if (!(profile = (pika_channel_profile_t *) hashtable_search(globals.profile_hash, (char *)category))) { - profile = ftdm_malloc(sizeof(*profile)); - memset(profile, 0, sizeof(*profile)); - ftdm_set_string(profile->name, category); - profile->ec_config = globals.ec_config; - profile->record_config = globals.record_config; - profile->play_config = globals.play_config; - hashtable_insert(globals.profile_hash, (void *)profile->name, profile, HASHTABLE_FLAG_NONE); - ftdm_log(FTDM_LOG_INFO, "creating profile [%s]\n", category); - } - - if (!strcasecmp(var, "rx-gain")) { - profile->record_config.gain = pk_atof(val); - } else if (!strcasecmp(var, "rx-agc-enabled")) { - profile->record_config.AGC.enabled = ftdm_true(val); - } else if (!strcasecmp(var, "rx-agc-targetPower")) { - profile->record_config.AGC.targetPower = pk_atof(val); - } else if (!strcasecmp(var, "rx-agc-minGain")) { - profile->record_config.AGC.minGain = pk_atof(val); - } else if (!strcasecmp(var, "rx-agc-maxGain")) { - profile->record_config.AGC.maxGain = pk_atof(val); - } else if (!strcasecmp(var, "rx-agc-attackRate")) { - profile->record_config.AGC.attackRate = atoi(val); - } else if (!strcasecmp(var, "rx-agc-decayRate")) { - profile->record_config.AGC.decayRate = atoi(val); - } else if (!strcasecmp(var, "rx-agc-speechThreshold")) { - profile->record_config.AGC.speechThreshold = pk_atof(val); - } else if (!strcasecmp(var, "rx-vad-enabled")) { - profile->record_config.VAD.enabled = ftdm_true(val); - } else if (!strcasecmp(var, "rx-vad-activationThreshold")) { - profile->record_config.VAD.activationThreshold = pk_atof(val); - } else if (!strcasecmp(var, "rx-vad-activationDebounceTime")) { - profile->record_config.VAD.activationDebounceTime = atoi(val); - } else if (!strcasecmp(var, "rx-vad-deactivationThreshold")) { - profile->record_config.VAD.deactivationThreshold = pk_atof(val); - } else if (!strcasecmp(var, "rx-vad-deactivationDebounceTime")) { - profile->record_config.VAD.deactivationDebounceTime = atoi(val); - } else if (!strcasecmp(var, "rx-vad-preSpeechBufferSize")) { - profile->record_config.VAD.preSpeechBufferSize = atoi(val); - } else if (!strcasecmp(var, "tx-gain")) { - profile->play_config.gain = pk_atof(val); - } else if (!strcasecmp(var, "tx-agc-enabled")) { - profile->play_config.AGC.enabled = ftdm_true(val); - } else if (!strcasecmp(var, "tx-agc-targetPower")) { - profile->play_config.AGC.targetPower = pk_atof(val); - } else if (!strcasecmp(var, "tx-agc-minGain")) { - profile->play_config.AGC.minGain = pk_atof(val); - } else if (!strcasecmp(var, "tx-agc-maxGain")) { - profile->play_config.AGC.maxGain = pk_atof(val); - } else if (!strcasecmp(var, "tx-agc-attackRate")) { - profile->play_config.AGC.attackRate = atoi(val); - } else if (!strcasecmp(var, "tx-agc-decayRate")) { - profile->play_config.AGC.decayRate = atoi(val); - } else if (!strcasecmp(var, "tx-agc-speechThreshold")) { - profile->play_config.AGC.speechThreshold = pk_atof(val); - } else if (!strcasecmp(var, "ec-enabled")) { - profile->ec_enabled = ftdm_true(val); - } else if (!strcasecmp(var, "ec-doubleTalkerThreshold")) { - profile->ec_config.doubleTalkerThreshold = pk_atof(val); - } else if (!strcasecmp(var, "ec-speechPresentThreshold")) { - profile->ec_config.speechPresentThreshold = pk_atof(val); - } else if (!strcasecmp(var, "ec-echoSuppressionThreshold")) { - profile->ec_config.echoSuppressionThreshold = pk_atof(val); - } else if (!strcasecmp(var, "ec-echoSuppressionEnabled")) { - profile->ec_config.echoSuppressionEnabled = ftdm_true(val); - } else if (!strcasecmp(var, "ec-comfortNoiseEnabled")) { - profile->ec_config.comfortNoiseEnabled = ftdm_true(val); - } else if (!strcasecmp(var, "ec-adaptationModeEnabled")) { - profile->ec_config.adaptationModeEnabled = ftdm_true(val); - } else if (!strcasecmp(var, "framing")) { - profile->span_config.framing = pika_str2span(val); - profile->cust_span++; - } else if (!strcasecmp(var, "encoding")) { - profile->span_config.encoding = pika_str2span_encoding(val); - profile->cust_span++; - } else if (!strcasecmp(var, "loopLength")) { - profile->span_config.loopLength = pika_str2loop_length(val); - profile->cust_span++; - } else if (!strcasecmp(var, "buildOut")) { - profile->span_config.buildOut = pika_str2lbo(val); - profile->cust_span++; - } else if (!strcasecmp(var, "compandMode")) { - profile->span_config.compandMode = pika_str2compand_mode(val); - profile->cust_span++; - } else if (!strcasecmp(var, "region")) { - if (!strcasecmp(val, "eu")) { - profile->general_config.region = PKH_TRUNK_EU; - } else { - profile->general_config.region = PKH_TRUNK_NA; - } - } else { - ok = 0; - } - - if (ok) { - ftdm_log(FTDM_LOG_INFO, "setting param [%s]=[%s] for profile [%s]\n", var, val, category); - } else { - ftdm_log(FTDM_LOG_ERROR, "unknown param [%s]\n", var); - } - - return FTDM_SUCCESS; -} - -/** - * \brief Pika event handler - * \param event Pika event - */ -PK_VOID PK_CALLBACK media_out_callback(PKH_TPikaEvent *event) -{ - PK_STATUS pk_status; - ftdm_channel_t *ftdmchan = event->userData; - pika_chan_data_t *chan_data = (pika_chan_data_t *) ftdmchan->io_data; - - //PK_CHAR event_text[PKH_EVENT_MAX_NAME_LENGTH]; - //PKH_EVENT_GetText(event->id, event_text, sizeof(event_text)); - //ftdm_log(FTDM_LOG_DEBUG, "Event: %s\n", event_text); - - switch (event->id) { - case PKH_EVENT_PLAY_IDLE: - { - while (ftdm_buffer_inuse(chan_data->digit_buffer)) { - char dtmf[128] = ""; - ftdm_mutex_lock(chan_data->digit_mutex); - chan_data->dtmf_len = ftdm_buffer_read(chan_data->digit_buffer, dtmf, sizeof(dtmf)); - pk_status = PKH_TG_PlayDTMF(chan_data->media_out, dtmf); - ftdm_mutex_unlock(chan_data->digit_mutex); - } - } - break; - case PKH_EVENT_TG_TONE_PLAYED: - { - - if (!event->p1) { - ftdm_mutex_lock(chan_data->digit_mutex); - PKH_PLAY_Start(chan_data->media_out); - chan_data->dtmf_len = 0; - ftdm_mutex_unlock(chan_data->digit_mutex); - } - - - } - break; - default: - break; - } - -} - -/** - * \brief Initialises a range of pika channels - * \param span FreeTDM span - * \param boardno Pika board number - * \param spanno Pika span number - * \param start Initial pika channel number - * \param end Final pika channel number - * \param type FreeTDM channel type - * \param name FreeTDM span name - * \param number FreeTDM span number - * \param profile Pika channel profile - * \return number of spans configured - */ -static unsigned pika_open_range(ftdm_span_t *span, unsigned boardno, unsigned spanno, unsigned start, unsigned end, - ftdm_chan_type_t type, char *name, char *number, pika_channel_profile_t *profile) -{ - unsigned configured = 0, x; - PK_STATUS status; - PK_CHAR error_text[PKH_ERROR_MAX_NAME_LENGTH]; - pika_span_data_t *span_data; - - if (boardno >= globals.board_list.numberOfBoards) { - ftdm_log(FTDM_LOG_ERROR, "Board %u is not present!\n", boardno); - return 0; - } - - if (!globals.open_boards[boardno]) { - status = PKH_BOARD_Open(globals.board_list.board[boardno].id, - NULL, - &globals.open_boards[boardno]); - if(status != PK_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "Error: PKH_BOARD_Open %d failed(%s)!\n", boardno, - PKH_ERROR_GetText(status, error_text, sizeof(error_text))); - return 0; - } - - ftdm_log(FTDM_LOG_DEBUG, "Open board %u\n", boardno); - - //PKH_BOARD_SetDebugTrace(globals.open_boards[boardno], 1, 0); - - } - - if (span->io_data) { - span_data = span->io_data; - } else { - span_data = ftdm_malloc(sizeof(*span_data)); - assert(span_data != NULL); - memset(span_data, 0, sizeof(*span_data)); - span_data->boardno = boardno; - - status = PKH_QUEUE_Create(PKH_QUEUE_TYPE_NORMAL, &span_data->event_queue); - - if (status != PK_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "Error: PKH_QUEUE_Create failed(%s)!\n", - PKH_ERROR_GetText(status, error_text, sizeof(error_text))); - ftdm_safe_free(span_data); - return 0; - } - - //PKH_QUEUE_Attach(span_data->event_queue, globals.open_boards[boardno], NULL); - - span->io_data = span_data; - } - - if (type == FTDM_CHAN_TYPE_FXS || type == FTDM_CHAN_TYPE_FXO) { - start--; - end--; - } - - for(x = start; x < end; x++) { - ftdm_channel_t *chan; - pika_chan_data_t *chan_data = NULL; - - chan_data = ftdm_malloc(sizeof *chan_data); - assert(chan_data); - memset(chan_data, 0, sizeof(*chan_data)); - ftdm_span_add_channel(span, 0, type, &chan); - chan->io_data = chan_data; - - if ((type == FTDM_CHAN_TYPE_B || type == FTDM_CHAN_TYPE_DQ921) && !span_data->handle) { - PKH_TBoardConfig boardConfig; - - TRY_OR_DIE(PKH_BOARD_GetConfig(globals.open_boards[boardno], &boardConfig), PK_SUCCESS, error); - if ((profile && profile->general_config.region == PKH_TRUNK_EU) || ftdm_test_flag(span_data, PK_FLAG_LOCKED)) { - if (span->trunk_type == FTDM_TRUNK_T1) { - ftdm_log(FTDM_LOG_WARNING, "Changing trunk type to E1 based on previous config.\n"); - } - span->trunk_type = FTDM_TRUNK_E1; - } - - if (span->trunk_type == FTDM_TRUNK_T1) { - if (ftdm_test_flag(span_data, PK_FLAG_LOCKED)) { - ftdm_log(FTDM_LOG_WARNING, "Already locked into E1 mode!\n"); - } - } else if (span->trunk_type == FTDM_TRUNK_E1) { - boardConfig.specific.DigitalGateway.interfaceType = PKH_BOARD_INTERFACE_TYPE_E1; - if ((status = PKH_BOARD_SetConfig(globals.open_boards[boardno], &boardConfig)) != PK_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "Error: [%s]\n", - PKH_ERROR_GetText(status, error_text, sizeof(error_text))); - } - ftdm_set_flag(span_data, PK_FLAG_LOCKED); - } - - TRY_OR_DIE(PKH_SPAN_Open(globals.open_boards[boardno], spanno, NULL, &span_data->handle), PK_SUCCESS, error); - TRY_OR_DIE(PKH_SPAN_GetConfig(span_data->handle, &span_data->span_config), PK_SUCCESS, error); - TRY_OR_DIE(PKH_QUEUE_Attach(span_data->event_queue, span_data->handle, (PK_VOID*) span), PK_SUCCESS, error); - } - - if (type == FTDM_CHAN_TYPE_FXO) { - PKH_TTrunkConfig trunkConfig; - - TRY_OR_DIE(PKH_TRUNK_Open(globals.open_boards[boardno], x, &chan_data->handle), PK_SUCCESS, error); - TRY_OR_DIE(PKH_TRUNK_Seize(chan_data->handle), PK_SUCCESS, error); - - if (profile && profile->general_config.region == PKH_TRUNK_EU) { - TRY_OR_DIE(PKH_TRUNK_GetConfig(chan_data->handle, &trunkConfig), PK_SUCCESS, error); - trunkConfig.internationalControl = PKH_PHONE_INTERNATIONAL_CONTROL_EU; - trunkConfig.audioFormat = PKH_AUDIO_ALAW; - trunkConfig.compandMode = PKH_PHONE_AUDIO_ALAW; - chan->native_codec = chan->effective_codec = FTDM_CODEC_ALAW; - TRY_OR_DIE(PKH_TRUNK_SetConfig(chan_data->handle, &trunkConfig), PK_SUCCESS, error); - } else { - chan->native_codec = chan->effective_codec = FTDM_CODEC_ULAW; - } - - - TRY_OR_DIE(PKH_QUEUE_Attach(span_data->event_queue, chan_data->handle, (PK_VOID*) chan), PK_SUCCESS, error); - TRY_OR_DIE(PKH_TRUNK_GetMediaStreams(chan_data->handle, &chan_data->media_in, &chan_data->media_out), PK_SUCCESS, error); - TRY_OR_DIE(PKH_QUEUE_Create(PKH_QUEUE_TYPE_NORMAL, &chan_data->media_in_queue), PK_SUCCESS, error); - TRY_OR_DIE(PKH_QUEUE_Attach(chan_data->media_in_queue, chan_data->media_in, (PK_VOID*) chan), PK_SUCCESS, error); - TRY_OR_DIE(PKH_QUEUE_Create(PKH_QUEUE_TYPE_CALLBACK, &chan_data->media_out_queue), PK_SUCCESS, error); - TRY_OR_DIE(PKH_QUEUE_SetEventHandler(chan_data->media_out_queue, media_out_callback), PK_SUCCESS, error); - TRY_OR_DIE(PKH_QUEUE_Attach(chan_data->media_out_queue, chan_data->media_out, (PK_VOID*) chan), PK_SUCCESS, error); - TRY_OR_DIE(PKH_TRUNK_Start(chan_data->handle), PK_SUCCESS, error); - } else if (type == FTDM_CHAN_TYPE_FXS) { - PKH_TPhoneConfig phoneConfig; - - if (profile && profile->general_config.region == PKH_TRUNK_EU) { - TRY_OR_DIE(PKH_PHONE_GetConfig(chan_data->handle, &phoneConfig), PK_SUCCESS, error); - phoneConfig.internationalControl = PKH_PHONE_INTERNATIONAL_CONTROL_EU; - phoneConfig.compandMode = PKH_PHONE_AUDIO_ALAW; - chan->native_codec = chan->effective_codec = FTDM_CODEC_ALAW; - TRY_OR_DIE(PKH_PHONE_SetConfig(chan_data->handle, &phoneConfig), PK_SUCCESS, error); - } else { - chan->native_codec = chan->effective_codec = FTDM_CODEC_ULAW; - } - - TRY_OR_DIE(PKH_PHONE_Open(globals.open_boards[boardno], x, &chan_data->handle), PK_SUCCESS, error); - TRY_OR_DIE(PKH_PHONE_Seize(chan_data->handle), PK_SUCCESS, error); - TRY_OR_DIE(PKH_PHONE_GetMediaStreams(chan_data->handle, &chan_data->media_in, &chan_data->media_out), PK_SUCCESS, error); - TRY_OR_DIE(PKH_QUEUE_Attach(span_data->event_queue, chan_data->handle, (PK_VOID*) chan), PK_SUCCESS, error); - TRY_OR_DIE(PKH_QUEUE_Create(PKH_QUEUE_TYPE_NORMAL, &chan_data->media_in_queue), PK_SUCCESS, error); - TRY_OR_DIE(PKH_QUEUE_Attach(chan_data->media_in_queue, chan_data->media_in, (PK_VOID*) chan), PK_SUCCESS, error); - TRY_OR_DIE(PKH_QUEUE_Create(PKH_QUEUE_TYPE_CALLBACK, &chan_data->media_out_queue), PK_SUCCESS, error); - TRY_OR_DIE(PKH_QUEUE_SetEventHandler(chan_data->media_out_queue, media_out_callback), PK_SUCCESS, error); - TRY_OR_DIE(PKH_QUEUE_Attach(chan_data->media_out_queue, chan_data->media_out, (PK_VOID*) chan), PK_SUCCESS, error); - TRY_OR_DIE(PKH_PHONE_Start(chan_data->handle), PK_SUCCESS, error); - } else if (type == FTDM_CHAN_TYPE_B) { - TRY_OR_DIE(PKH_SPAN_SeizeChannel(span_data->handle, x), PK_SUCCESS, error); - TRY_OR_DIE(PKH_SPAN_GetMediaStreams(span_data->handle, x, &chan_data->media_in, &chan_data->media_out), PK_SUCCESS, error); - TRY_OR_DIE(PKH_QUEUE_Create(PKH_QUEUE_TYPE_NORMAL, &chan_data->media_in_queue), PK_SUCCESS, error); - TRY_OR_DIE(PKH_QUEUE_Attach(chan_data->media_in_queue, chan_data->media_in, (PK_VOID*) chan), PK_SUCCESS, error); - TRY_OR_DIE(PKH_QUEUE_Create(PKH_QUEUE_TYPE_CALLBACK, &chan_data->media_out_queue), PK_SUCCESS, error); - TRY_OR_DIE(PKH_QUEUE_SetEventHandler(chan_data->media_out_queue, media_out_callback), PK_SUCCESS, error); - TRY_OR_DIE(PKH_QUEUE_Attach(chan_data->media_out_queue, chan_data->media_out, (PK_VOID*) chan), PK_SUCCESS, error); - } else if (type == FTDM_CHAN_TYPE_DQ921) { - TRY_OR_DIE(PKH_SPAN_HDLC_Open(span_data->handle, PKH_SPAN_HDLC_MODE_NORMAL, &chan_data->handle), PK_SUCCESS, error); - TRY_OR_DIE(PKH_SPAN_HDLC_GetConfig(chan_data->handle, &chan_data->hdlc_config), PK_SUCCESS, error); - chan_data->hdlc_config.channelId = x; - TRY_OR_DIE(PKH_SPAN_HDLC_SetConfig(chan_data->handle, &chan_data->hdlc_config), PK_SUCCESS, error); - TRY_OR_DIE(PKH_QUEUE_Create(PKH_QUEUE_TYPE_NORMAL, &chan_data->media_in_queue), PK_SUCCESS, error); - TRY_OR_DIE(PKH_QUEUE_Attach(chan_data->media_in_queue, chan_data->handle, (PK_VOID*) chan), PK_SUCCESS, error); - TRY_OR_DIE(PKH_QUEUE_Attach(span_data->event_queue, chan_data->handle, (PK_VOID*) chan), PK_SUCCESS, error); - - if (profile) { - if (profile->cust_span) { - span_data->span_config.framing = profile->span_config.framing; - span_data->span_config.encoding = profile->span_config.encoding; - span_data->span_config.loopLength = profile->span_config.loopLength; - span_data->span_config.buildOut = profile->span_config.buildOut; - span_data->span_config.compandMode = profile->span_config.compandMode; - } else { - if (profile->general_config.region == PKH_TRUNK_EU) { - span_data->span_config = globals.e1_span_config; - } else { - span_data->span_config = globals.t1_span_config; - } - } - } else { - if (span->trunk_type == FTDM_TRUNK_E1) { - span_data->span_config = globals.e1_span_config; - } else { - span_data->span_config = globals.t1_span_config; - } - } - - PKH_SPAN_SetConfig(span_data->handle, &span_data->span_config); - TRY_OR_DIE(PKH_SPAN_Start(span_data->handle), PK_SUCCESS, error); - } - - goto ok; - - error: - PKH_ERROR_GetText(status, error_text, sizeof(error_text)); - ftdm_log(FTDM_LOG_ERROR, "failure configuring device b%ds%dc%d [%s]\n", boardno, spanno, x, error_text); - continue; - ok: - ftdm_set_flag(chan_data, PK_FLAG_READY); - status = PKH_RECORD_GetConfig(chan_data->media_in, &chan_data->record_config); - chan_data->record_config.encoding = PKH_RECORD_ENCODING_MU_LAW; - chan_data->record_config.samplingRate = PKH_RECORD_SAMPLING_RATE_8KHZ; - chan_data->record_config.bufferSize = PIKA_BLOCK_SIZE; - chan_data->record_config.numberOfBuffers = PIKA_NUM_BUFFERS; - chan_data->record_config.VAD.enabled = PK_FALSE; - //chan_data->record_config.speechSegmentEventsEnabled = PK_FALSE; - //chan_data->record_config.gain = rxgain; - - status = PKH_PLAY_GetConfig(chan_data->media_out, &chan_data->play_config); - chan_data->play_config.encoding = PKH_RECORD_ENCODING_MU_LAW; - chan_data->play_config.samplingRate = PKH_RECORD_SAMPLING_RATE_8KHZ; - chan_data->play_config.AGC.enabled = PK_FALSE; - ftdm_log(FTDM_LOG_INFO, "configuring device b%ds%dc%d as FreeTDM device %d:%d\n", boardno, spanno, x, chan->span_id, chan->chan_id); - - if (profile) { - ftdm_log(FTDM_LOG_INFO, "applying config profile %s to device %d:%d\n", profile->name, chan->span_id, chan->chan_id); - chan_data->record_config.gain = profile->record_config.gain; - chan_data->record_config.AGC = profile->record_config.AGC; - chan_data->record_config.VAD = profile->record_config.VAD; - chan_data->play_config.gain = profile->play_config.gain; - chan_data->play_config.AGC = profile->play_config.AGC; - chan_data->ec_enabled = profile->ec_enabled; - chan_data->ec_config = profile->ec_config; - } - - if (type == FTDM_CHAN_TYPE_B) { - if (span_data->span_config.compandMode == PKH_SPAN_COMPAND_MODE_A_LAW) { - chan->native_codec = chan->effective_codec = FTDM_CODEC_ALAW; - } else { - chan->native_codec = chan->effective_codec = FTDM_CODEC_ULAW; - } - } - - status = PKH_RECORD_SetConfig(chan_data->media_in, &chan_data->record_config); - status = PKH_PLAY_SetConfig(chan_data->media_out, &chan_data->play_config); - - chan->physical_span_id = spanno; - chan->physical_chan_id = x; - - chan->rate = 8000; - chan->packet_len = (uint32_t)chan_data->record_config.bufferSize; - chan->effective_interval = chan->native_interval = chan->packet_len / 8; - - PKH_RECORD_Start(chan_data->media_in); - PKH_PLAY_Start(chan_data->media_out); - if (chan_data->ec_enabled) { - PKH_EC_SetConfig(chan_data->media_in, &chan_data->ec_config); - PKH_EC_Start(chan_data->media_in, chan_data->media_in, chan_data->media_out); - } - - if (!ftdm_strlen_zero(name)) { - ftdm_copy_string(chan->chan_name, name, sizeof(chan->chan_name)); - } - - if (!ftdm_strlen_zero(number)) { - ftdm_copy_string(chan->chan_number, number, sizeof(chan->chan_number)); - } - - ftdm_channel_set_feature(chan, FTDM_CHANNEL_FEATURE_DTMF_GENERATE); - ftdm_buffer_create(&chan_data->digit_buffer, 128, 128, 0); - ftdm_mutex_create(&chan_data->digit_mutex); - - configured++; - } - - - return configured; -} - -/** - * \brief Initialises an freetdm pika span from a configuration string - * \param span FreeTDM span - * \param str Configuration string - * \param type FreeTDM span type - * \param name FreeTDM span name - * \param number FreeTDM span number - * \return Success or failure - */ -static FIO_CONFIGURE_SPAN_FUNCTION(pika_configure_span) -{ - int items, i; - char *mydata, *item_list[10]; - char *bd, *sp, *ch = NULL, *mx; - int boardno; - int channo; - int spanno; - int top = 0; - unsigned configured = 0; - char *profile_name = NULL; - pika_channel_profile_t *profile = NULL; - - assert(str != NULL); - - mydata = ftdm_strdup(str); - assert(mydata != NULL); - - if ((profile_name = strchr(mydata, '@'))) { - *profile_name++ = '\0'; - if (!ftdm_strlen_zero(profile_name)) { - profile = (pika_channel_profile_t *) hashtable_search(globals.profile_hash, (char *)profile_name); - } - } - - items = ftdm_separate_string(mydata, ',', item_list, (sizeof(item_list) / sizeof(item_list[0]))); - - for(i = 0; i < items; i++) { - bd = item_list[i]; - if ((sp = strchr(bd, ':'))) { - *sp++ = '\0'; - if ((ch = strchr(sp, ':'))) { - *ch++ = '\0'; - } - } - - if (!(bd && sp && ch)) { - ftdm_log(FTDM_LOG_ERROR, "Invalid input\n"); - continue; - } - - boardno = atoi(bd); - channo = atoi(ch); - spanno = atoi(sp); - - - if (boardno < 0) { - ftdm_log(FTDM_LOG_ERROR, "Invalid board number %d\n", boardno); - continue; - } - - if (channo < 0) { - ftdm_log(FTDM_LOG_ERROR, "Invalid channel number %d\n", channo); - continue; - } - - if (spanno < 0) { - ftdm_log(FTDM_LOG_ERROR, "Invalid span number %d\n", channo); - continue; - } - - if ((mx = strchr(ch, '-'))) { - mx++; - top = atoi(mx) + 1; - } else { - top = channo + 1; - } - - - if (top < 0) { - ftdm_log(FTDM_LOG_ERROR, "Invalid range number %d\n", top); - continue; - } - - configured += pika_open_range(span, boardno, spanno, channo, top, type, name, number, profile); - - } - - ftdm_safe_free(mydata); - - return configured; -} - -/** - * \brief Opens Pika channel - * \param ftdmchan Channel to open - * \return Success or failure - */ -static FIO_OPEN_FUNCTION(pika_open) -{ - pika_chan_data_t *chan_data = (pika_chan_data_t *) ftdmchan->io_data; - - if (!chan_data && !ftdm_test_flag(chan_data, PK_FLAG_READY)) { - return FTDM_FAIL; - } - - if (chan_data->media_in_queue) { - PKH_QUEUE_Flush(chan_data->media_in_queue); - } - - if (ftdmchan->type == FTDM_CHAN_TYPE_FXS || ftdmchan->type == FTDM_CHAN_TYPE_FXO || ftdmchan->type == FTDM_CHAN_TYPE_B) { - PKH_PLAY_Start(chan_data->media_out); - } - return FTDM_SUCCESS; -} - -/** - * \brief Closes Pika channel - * \param ftdmchan Channel to close - * \return Success - */ -static FIO_CLOSE_FUNCTION(pika_close) -{ - return FTDM_SUCCESS; -} - -/** - * \brief Waits for an event on a Pika channel - * \param ftdmchan Channel to open - * \param flags Type of event to wait for - * \param to Time to wait (in ms) - * \return Success, failure or timeout - */ -static FIO_WAIT_FUNCTION(pika_wait) -{ - pika_chan_data_t *chan_data = (pika_chan_data_t *) ftdmchan->io_data; - PK_STATUS status; - ftdm_wait_flag_t myflags = *flags; - PK_CHAR event_text[PKH_EVENT_MAX_NAME_LENGTH]; - - *flags = FTDM_NO_FLAGS; - - if (myflags & FTDM_READ) { - if (chan_data->hdlc_bytes) { - *flags |= FTDM_READ; - return FTDM_SUCCESS; - } - status = PKH_QUEUE_WaitOnEvent(chan_data->media_in_queue, to, &chan_data->last_media_event); - - if (status == PK_SUCCESS) { - if (chan_data->last_media_event.id == PKH_EVENT_QUEUE_TIMEOUT || chan_data->last_media_event.id == PKH_EVENT_RECORD_BUFFER_OVERFLOW) { - return FTDM_TIMEOUT; - } - - *flags |= FTDM_READ; - return FTDM_SUCCESS; - } - - PKH_EVENT_GetText(chan_data->last_media_event.id, event_text, sizeof(event_text)); - ftdm_log(FTDM_LOG_DEBUG, "Event: %s\n", event_text); - } - - return FTDM_SUCCESS; -} - -/** - * \brief Reads data from a Pika channel - * \param ftdmchan Channel to read from - * \param data Data buffer - * \param datalen Size of data buffer - * \return Success or failure - */ -static FIO_READ_FUNCTION(pika_read) -{ - pika_chan_data_t *chan_data = (pika_chan_data_t *) ftdmchan->io_data; - PK_STATUS status; - PK_CHAR event_text[PKH_EVENT_MAX_NAME_LENGTH]; - uint32_t len; - - if (ftdmchan->type == FTDM_CHAN_TYPE_DQ921) { - if ((status = PKH_SPAN_HDLC_GetMessage(chan_data->handle, data, *datalen)) == PK_SUCCESS) { - *datalen = chan_data->hdlc_bytes; - chan_data->hdlc_bytes = 0; - return FTDM_SUCCESS; - } - return FTDM_FAIL; - } - - if (!(len = chan_data->last_media_event.p0)) { - len = ftdmchan->packet_len; - } - - if (len < *datalen) { - *datalen = len; - } - - if ((status = PKH_RECORD_GetData(chan_data->media_in, data, *datalen)) == PK_SUCCESS) { - return FTDM_SUCCESS; - } - - - PKH_ERROR_GetText(status, event_text, sizeof(event_text)); - ftdm_log(FTDM_LOG_DEBUG, "ERR: %s\n", event_text); - return FTDM_FAIL; -} - -/** - * \brief Writes data to a Pika channel - * \param ftdmchan Channel to write to - * \param data Data buffer - * \param datalen Size of data buffer - * \return Success or failure - */ -static FIO_WRITE_FUNCTION(pika_write) -{ - pika_chan_data_t *chan_data = (pika_chan_data_t *) ftdmchan->io_data; - PK_STATUS status; - - if (ftdmchan->type == FTDM_CHAN_TYPE_DQ921) { - if ((status = PKH_SPAN_HDLC_SendMessage(chan_data->handle, data, *datalen)) == PK_SUCCESS) { - return FTDM_SUCCESS; - } - return FTDM_FAIL; - } - - if (PKH_PLAY_AddData(chan_data->media_out, 0, data, *datalen) == PK_SUCCESS) { - return FTDM_SUCCESS; - } - - return FTDM_FAIL; -} - -/** - * \brief Executes an FreeTDM command on a Pika channel - * \param ftdmchan Channel to execute command on - * \param command FreeTDM command to execute - * \param obj Object (unused) - * \return Success or failure - */ -static FIO_COMMAND_FUNCTION(pika_command) -{ - pika_chan_data_t *chan_data = (pika_chan_data_t *) ftdmchan->io_data; - //pika_span_data_t *span_data = (pika_span_data_t *) ftdmchan->span->io_data; - PK_STATUS pk_status; - ftdm_status_t status = FTDM_SUCCESS; - - switch(command) { - case FTDM_COMMAND_OFFHOOK: - { - if ((pk_status = PKH_TRUNK_SetHookSwitch(chan_data->handle, PKH_TRUNK_OFFHOOK)) != PK_SUCCESS) { - PKH_ERROR_GetText(pk_status, ftdmchan->last_error, sizeof(ftdmchan->last_error)); - GOTO_STATUS(done, FTDM_FAIL); - } else { - ftdm_set_flag_locked(ftdmchan, FTDM_CHANNEL_OFFHOOK); - } - } - break; - case FTDM_COMMAND_ONHOOK: - { - if ((pk_status = PKH_TRUNK_SetHookSwitch(chan_data->handle, PKH_TRUNK_ONHOOK)) != PK_SUCCESS) { - PKH_ERROR_GetText(pk_status, ftdmchan->last_error, sizeof(ftdmchan->last_error)); - GOTO_STATUS(done, FTDM_FAIL); - } else { - ftdm_clear_flag_locked(ftdmchan, FTDM_CHANNEL_OFFHOOK); - } - } - break; - case FTDM_COMMAND_GENERATE_RING_ON: - { - if ((pk_status = PKH_PHONE_RingStart(chan_data->handle, 0, 0)) != PK_SUCCESS) { - PKH_ERROR_GetText(pk_status, ftdmchan->last_error, sizeof(ftdmchan->last_error)); - GOTO_STATUS(done, FTDM_FAIL); - } else { - ftdm_set_flag_locked(ftdmchan, FTDM_CHANNEL_RINGING); - } - } - break; - case FTDM_COMMAND_GENERATE_RING_OFF: - { - if ((pk_status = PKH_PHONE_RingStop(chan_data->handle)) != PK_SUCCESS) { - PKH_ERROR_GetText(pk_status, ftdmchan->last_error, sizeof(ftdmchan->last_error)); - GOTO_STATUS(done, FTDM_FAIL); - } else { - ftdm_clear_flag_locked(ftdmchan, FTDM_CHANNEL_RINGING); - } - } - break; - case FTDM_COMMAND_GET_INTERVAL: - { - - FTDM_COMMAND_OBJ_INT = ftdmchan->native_interval; - - } - break; - case FTDM_COMMAND_SET_INTERVAL: - { - int interval = FTDM_COMMAND_OBJ_INT; - int len = interval * 8; - chan_data->record_config.bufferSize = len; - chan_data->record_config.numberOfBuffers = (PK_UINT)chan_data->record_config.bufferSize; - ftdmchan->packet_len = (uint32_t)chan_data->record_config.bufferSize; - ftdmchan->effective_interval = ftdmchan->native_interval = ftdmchan->packet_len / 8; - PKH_RECORD_SetConfig(chan_data->media_in, &chan_data->record_config); - GOTO_STATUS(done, FTDM_SUCCESS); - } - break; - case FTDM_COMMAND_GET_DTMF_ON_PERIOD: - { - - FTDM_COMMAND_OBJ_INT = ftdmchan->dtmf_on; - GOTO_STATUS(done, FTDM_SUCCESS); - - } - break; - case FTDM_COMMAND_GET_DTMF_OFF_PERIOD: - { - FTDM_COMMAND_OBJ_INT = ftdmchan->dtmf_on; - GOTO_STATUS(done, FTDM_SUCCESS); - } - break; - case FTDM_COMMAND_SET_DTMF_ON_PERIOD: - { - int val = FTDM_COMMAND_OBJ_INT; - if (val > 10 && val < 1000) { - ftdmchan->dtmf_on = val; - GOTO_STATUS(done, FTDM_SUCCESS); - } else { - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "invalid value %d range 10-1000", val); - GOTO_STATUS(done, FTDM_FAIL); - } - } - break; - case FTDM_COMMAND_SET_DTMF_OFF_PERIOD: - { - int val = FTDM_COMMAND_OBJ_INT; - if (val > 10 && val < 1000) { - ftdmchan->dtmf_off = val; - GOTO_STATUS(done, FTDM_SUCCESS); - } else { - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "invalid value %d range 10-1000", val); - GOTO_STATUS(done, FTDM_FAIL); - } - } - break; - case FTDM_COMMAND_SEND_DTMF: - { - char *digits = FTDM_COMMAND_OBJ_CHAR_P; - ftdm_log(FTDM_LOG_DEBUG, "Adding DTMF SEQ [%s]\n", digits); - ftdm_mutex_lock(chan_data->digit_mutex); - ftdm_buffer_write(chan_data->digit_buffer, digits, strlen(digits)); - ftdm_mutex_unlock(chan_data->digit_mutex); - pk_status = PKH_PLAY_Stop(chan_data->media_out); - - if (pk_status != PK_SUCCESS) { - PKH_ERROR_GetText(pk_status, ftdmchan->last_error, sizeof(ftdmchan->last_error)); - GOTO_STATUS(done, FTDM_FAIL); - } - GOTO_STATUS(done, FTDM_SUCCESS); - } - break; - default: - break; - }; - - done: - return status; -} - -/** - * \brief Checks for events on a Pika span - * \param span Span to check for events - * \param ms Time to wait for event - * \return Success if event is waiting or failure if not - */ -static FIO_SPAN_POLL_EVENT_FUNCTION(pika_poll_event) -{ - pika_span_data_t *span_data = (pika_span_data_t *) span->io_data; - PK_STATUS status; - PK_CHAR event_text[PKH_EVENT_MAX_NAME_LENGTH]; - - status = PKH_QUEUE_WaitOnEvent(span_data->event_queue, ms, &span_data->last_oob_event); - - if (status == PK_SUCCESS) { - ftdm_channel_t *ftdmchan = NULL; - uint32_t *data = (uint32_t *) span_data->last_oob_event.userData; - ftdm_data_type_t data_type = FTDM_TYPE_NONE; - - if (span_data->last_oob_event.id == PKH_EVENT_QUEUE_TIMEOUT) { - return FTDM_TIMEOUT; - } - - if (data) { - data_type = *data; - } - - if (data_type == FTDM_TYPE_CHANNEL) { - ftdmchan = span_data->last_oob_event.userData; - } else if (data_type == FTDM_TYPE_SPAN) { - ftdm_time_t last_event_time = ftdm_current_time_in_ms(); - uint32_t event_id = 0; - - switch (span_data->last_oob_event.id) { - case PKH_EVENT_SPAN_ALARM_T1_RED: - case PKH_EVENT_SPAN_ALARM_T1_YELLOW: - case PKH_EVENT_SPAN_ALARM_T1_AIS: - case PKH_EVENT_SPAN_ALARM_E1_RED: - case PKH_EVENT_SPAN_ALARM_E1_RAI: - case PKH_EVENT_SPAN_ALARM_E1_AIS: - case PKH_EVENT_SPAN_ALARM_E1_RMAI: - case PKH_EVENT_SPAN_ALARM_E1_TS16AIS: - case PKH_EVENT_SPAN_ALARM_E1_TS16LOS: - case PKH_EVENT_SPAN_OUT_OF_SYNC: - case PKH_EVENT_SPAN_FRAMING_ERROR: - case PKH_EVENT_SPAN_LOSS_OF_SIGNAL: - case PKH_EVENT_SPAN_OUT_OF_CRC_MF_SYNC: - case PKH_EVENT_SPAN_OUT_OF_CAS_MF_SYNC: - event_id = FTDM_OOB_ALARM_TRAP; - break; - case PKH_EVENT_SPAN_ALARM_T1_RED_CLEAR: - case PKH_EVENT_SPAN_ALARM_T1_YELLOW_CLEAR: - case PKH_EVENT_SPAN_ALARM_T1_AIS_CLEAR: - case PKH_EVENT_SPAN_ALARM_E1_RED_CLEAR: - case PKH_EVENT_SPAN_ALARM_E1_RAI_CLEAR: - case PKH_EVENT_SPAN_ALARM_E1_AIS_CLEAR: - case PKH_EVENT_SPAN_ALARM_E1_RMAI_CLEAR: - case PKH_EVENT_SPAN_ALARM_E1_TS16AIS_CLEAR: - case PKH_EVENT_SPAN_ALARM_E1_TS16LOS_CLEAR: - case PKH_EVENT_SPAN_IN_SYNC: - case PKH_EVENT_SPAN_LOSS_OF_SIGNAL_CLEAR: - case PKH_EVENT_SPAN_IN_CRC_MF_SYNC: - case PKH_EVENT_SPAN_IN_CAS_MF_SYNC: - event_id = FTDM_OOB_ALARM_CLEAR; - break; - case PKH_EVENT_SPAN_MESSAGE: - case PKH_EVENT_SPAN_ABCD_SIGNAL_CHANGE: - break; - } - - if (event_id) { - uint32_t x = 0; - ftdm_channel_t *ftdmchan; - pika_chan_data_t *chan_data; - for(x = 1; x <= span->chan_count; x++) { - ftdmchan = span->channels[x]; - assert(ftdmchan != NULL); - chan_data = (pika_chan_data_t *) ftdmchan->io_data; - assert(chan_data != NULL); - - - ftdm_set_flag(ftdmchan, FTDM_CHANNEL_EVENT); - ftdmchan->last_event_time = last_event_time; - chan_data->last_oob_event = span_data->last_oob_event; - } - - } - - } - - PKH_EVENT_GetText(span_data->last_oob_event.id, event_text, sizeof(event_text)); - //ftdm_log(FTDM_LOG_DEBUG, "Event: %s\n", event_text); - - if (ftdmchan) { - pika_chan_data_t *chan_data = (pika_chan_data_t *) ftdmchan->io_data; - - assert(chan_data != NULL); - ftdm_set_flag(ftdmchan, FTDM_CHANNEL_EVENT); - ftdmchan->last_event_time = ftdm_current_time_in_ms(); - chan_data->last_oob_event = span_data->last_oob_event; - } - - return FTDM_SUCCESS; - } - - return FTDM_FAIL; -} - -/** - * \brief Retrieves an event from a Pika span - * \param span Span to retrieve event from - * \param event FreeTDM event to return - * \return Success or failure - */ -static FIO_SPAN_NEXT_EVENT_FUNCTION(pika_next_event) -{ - uint32_t i, event_id = 0; - - for(i = 1; i <= span->chan_count; i++) { - if (ftdm_test_flag(span->channels[i], FTDM_CHANNEL_EVENT)) { - pika_chan_data_t *chan_data = (pika_chan_data_t *) span->channels[i]->io_data; - PK_CHAR event_text[PKH_EVENT_MAX_NAME_LENGTH]; - - ftdm_clear_flag(span->channels[i], FTDM_CHANNEL_EVENT); - - PKH_EVENT_GetText(chan_data->last_oob_event.id, event_text, sizeof(event_text)); - - switch(chan_data->last_oob_event.id) { - case PKH_EVENT_HDLC_MESSAGE: - chan_data->hdlc_bytes = chan_data->last_oob_event.p2; - continue; - case PKH_EVENT_TRUNK_HOOKFLASH: - event_id = FTDM_OOB_FLASH; - break; - case PKH_EVENT_TRUNK_RING_OFF: - event_id = FTDM_OOB_RING_STOP; - break; - case PKH_EVENT_TRUNK_RING_ON: - event_id = FTDM_OOB_RING_START; - break; - - case PKH_EVENT_PHONE_OFFHOOK: - ftdm_set_flag_locked(span->channels[i], FTDM_CHANNEL_OFFHOOK); - event_id = FTDM_OOB_OFFHOOK; - break; - - case PKH_EVENT_TRUNK_BELOW_THRESHOLD: - case PKH_EVENT_TRUNK_ABOVE_THRESHOLD: - case PKH_EVENT_PHONE_ONHOOK: - ftdm_clear_flag_locked(span->channels[i], FTDM_CHANNEL_OFFHOOK); - event_id = FTDM_OOB_ONHOOK; - break; - - - - case PKH_EVENT_SPAN_ALARM_T1_RED: - ftdm_set_alarm_flag(span->channels[i], FTDM_ALARM_RED); - snprintf(span->channels[i]->last_error, sizeof(span->channels[i]->last_error), "RED ALARM"); - event_id = FTDM_OOB_ALARM_TRAP; - break; - case PKH_EVENT_SPAN_ALARM_T1_YELLOW: - ftdm_set_alarm_flag(span->channels[i], FTDM_ALARM_YELLOW); - snprintf(span->channels[i]->last_error, sizeof(span->channels[i]->last_error), "YELLOW ALARM"); - event_id = FTDM_OOB_ALARM_TRAP; - break; - case PKH_EVENT_SPAN_ALARM_T1_AIS: - ftdm_set_alarm_flag(span->channels[i], FTDM_ALARM_AIS); - snprintf(span->channels[i]->last_error, sizeof(span->channels[i]->last_error), "AIS ALARM"); - event_id = FTDM_OOB_ALARM_TRAP; - break; - case PKH_EVENT_SPAN_ALARM_E1_RED: - ftdm_set_alarm_flag(span->channels[i], FTDM_ALARM_RED); - snprintf(span->channels[i]->last_error, sizeof(span->channels[i]->last_error), "RED ALARM"); - event_id = FTDM_OOB_ALARM_TRAP; - break; - case PKH_EVENT_SPAN_ALARM_E1_RAI: - ftdm_set_alarm_flag(span->channels[i], FTDM_ALARM_RAI); - snprintf(span->channels[i]->last_error, sizeof(span->channels[i]->last_error), "RAI ALARM"); - event_id = FTDM_OOB_ALARM_TRAP; - break; - case PKH_EVENT_SPAN_ALARM_E1_AIS: - ftdm_set_alarm_flag(span->channels[i], FTDM_ALARM_AIS); - snprintf(span->channels[i]->last_error, sizeof(span->channels[i]->last_error), "AIS ALARM"); - event_id = FTDM_OOB_ALARM_TRAP; - break; - case PKH_EVENT_SPAN_ALARM_E1_RMAI: - case PKH_EVENT_SPAN_ALARM_E1_TS16AIS: - case PKH_EVENT_SPAN_ALARM_E1_TS16LOS: - case PKH_EVENT_SPAN_OUT_OF_SYNC: - case PKH_EVENT_SPAN_FRAMING_ERROR: - case PKH_EVENT_SPAN_LOSS_OF_SIGNAL: - case PKH_EVENT_SPAN_OUT_OF_CRC_MF_SYNC: - case PKH_EVENT_SPAN_OUT_OF_CAS_MF_SYNC: - ftdm_set_alarm_flag(span->channels[i], FTDM_ALARM_GENERAL); - snprintf(span->channels[i]->last_error, sizeof(span->channels[i]->last_error), "GENERAL ALARM"); - event_id = FTDM_OOB_ALARM_TRAP; - break; - case PKH_EVENT_SPAN_ALARM_T1_RED_CLEAR: - ftdm_set_alarm_flag(span->channels[i], FTDM_ALARM_RED); - case PKH_EVENT_SPAN_ALARM_T1_YELLOW_CLEAR: - ftdm_set_alarm_flag(span->channels[i], FTDM_ALARM_YELLOW); - case PKH_EVENT_SPAN_ALARM_T1_AIS_CLEAR: - ftdm_set_alarm_flag(span->channels[i], FTDM_ALARM_AIS); - case PKH_EVENT_SPAN_ALARM_E1_RED_CLEAR: - ftdm_set_alarm_flag(span->channels[i], FTDM_ALARM_RED); - case PKH_EVENT_SPAN_ALARM_E1_RAI_CLEAR: - ftdm_set_alarm_flag(span->channels[i], FTDM_ALARM_RAI); - case PKH_EVENT_SPAN_ALARM_E1_AIS_CLEAR: - ftdm_set_alarm_flag(span->channels[i], FTDM_ALARM_AIS); - case PKH_EVENT_SPAN_ALARM_E1_RMAI_CLEAR: - case PKH_EVENT_SPAN_ALARM_E1_TS16AIS_CLEAR: - case PKH_EVENT_SPAN_ALARM_E1_TS16LOS_CLEAR: - case PKH_EVENT_SPAN_IN_SYNC: - case PKH_EVENT_SPAN_LOSS_OF_SIGNAL_CLEAR: - case PKH_EVENT_SPAN_IN_CRC_MF_SYNC: - case PKH_EVENT_SPAN_IN_CAS_MF_SYNC: - ftdm_clear_alarm_flag(span->channels[i], FTDM_ALARM_GENERAL); - event_id = FTDM_OOB_ALARM_CLEAR; - break; - case PKH_EVENT_SPAN_MESSAGE: - case PKH_EVENT_SPAN_ABCD_SIGNAL_CHANGE: - break; - - - - - case PKH_EVENT_TRUNK_ONHOOK: - case PKH_EVENT_TRUNK_OFFHOOK: - case PKH_EVENT_TRUNK_DIALED : - case PKH_EVENT_TRUNK_REVERSAL: - case PKH_EVENT_TRUNK_LCSO: - case PKH_EVENT_TRUNK_DROPOUT: - case PKH_EVENT_TRUNK_LOF: - case PKH_EVENT_TRUNK_RX_OVERLOAD: - default: - ftdm_log(FTDM_LOG_DEBUG, "Unhandled event %d on channel %d [%s]\n", chan_data->last_oob_event.id, i, event_text); - event_id = FTDM_OOB_INVALID; - break; - } - - span->channels[i]->last_event_time = 0; - span->event_header.e_type = FTDM_EVENT_OOB; - span->event_header.enum_id = event_id; - span->event_header.channel = span->channels[i]; - *event = &span->event_header; - return FTDM_SUCCESS; - } - } - - return FTDM_FAIL; -} - -/** - * \brief Destroys a Pika Span - * \param span Span to destroy - * \return Success - */ -static FIO_SPAN_DESTROY_FUNCTION(pika_span_destroy) -{ - pika_span_data_t *span_data = (pika_span_data_t *) span->io_data; - - if (span_data) { - PKH_QUEUE_Destroy(span_data->event_queue); - ftdm_safe_free(span_data); - } - - return FTDM_SUCCESS; -} - -/** - * \brief Destroys a Pika Channel - * \param ftdmchan Channel to destroy - * \return Success or failure - */ -static FIO_CHANNEL_DESTROY_FUNCTION(pika_channel_destroy) -{ - pika_chan_data_t *chan_data = (pika_chan_data_t *) ftdmchan->io_data; - pika_span_data_t *span_data = (pika_span_data_t *) ftdmchan->span->io_data; - - if (!chan_data) { - return FTDM_FAIL; - } - - if (!ftdm_test_flag(chan_data, PK_FLAG_READY)) { - goto end; - } - - PKH_RECORD_Stop(chan_data->media_in); - PKH_PLAY_Stop(chan_data->media_out); - PKH_QUEUE_Destroy(chan_data->media_in_queue); - PKH_QUEUE_Destroy(chan_data->media_out_queue); - - switch(ftdmchan->type) { - case FTDM_CHAN_TYPE_FXS: - PKH_QUEUE_Detach(span_data->event_queue, chan_data->handle); - PKH_PHONE_Close(chan_data->handle); - break; - case FTDM_CHAN_TYPE_FXO: - PKH_QUEUE_Detach(span_data->event_queue, chan_data->handle); - PKH_TRUNK_Close(chan_data->handle); - break; - case FTDM_CHAN_TYPE_DQ921: - PKH_SPAN_Stop(span_data->handle); - break; - default: - break; - } - - - ftdm_mutex_destroy(&chan_data->digit_mutex); - ftdm_buffer_destroy(&chan_data->digit_buffer); - - end: - ftdm_safe_free(chan_data); - - return FTDM_SUCCESS; -} - -/** - * \brief Gets alarms from a Pika Channel (does nothing) - * \param ftdmchan Channel to get alarms from - * \return Failure - */ -static FIO_GET_ALARMS_FUNCTION(pika_get_alarms) -{ - return FTDM_FAIL; -} - -static ftdm_io_interface_t pika_interface; - -/** - * \brief Loads Pika IO module - * \param fio FreeTDM IO interface - * \return Success or failure - */ -static FIO_IO_LOAD_FUNCTION(pika_init) -{ - - PK_STATUS status; - PK_CHAR error_text[PKH_ERROR_MAX_NAME_LENGTH]; - uint32_t i; - int ok = 0; - PKH_TLogMasks m; - TPikaHandle tmpHandle; - - assert(fio != NULL); - memset(&pika_interface, 0, sizeof(pika_interface)); - memset(&globals, 0, sizeof(globals)); - globals.general_config.region = PKH_TRUNK_NA; - - globals.profile_hash = create_hashtable(16, ftdm_hash_hashfromstring, ftdm_hash_equalkeys); - - // Open the system object, to enumerate boards configured for this system - if ((status = PKH_SYSTEM_Open(&globals.system_handle)) != PK_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "Error: PKH_SYSTEM_Open failed(%s)!\n", - PKH_ERROR_GetText(status, error_text, sizeof(error_text))); - return FTDM_FAIL; - } - - // Retrieves a list of all boards in this system, existing, - // or listed in pika.cfg - if ((status = PKH_SYSTEM_Detect(globals.system_handle, &globals.board_list)) != PK_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "Error: PKH_SYSTEM_Detect failed(%s)!\n", - PKH_ERROR_GetText(status, error_text, sizeof(error_text))); - return FTDM_FAIL; - } - - PKH_SYSTEM_GetConfig(globals.system_handle, &globals.system_config); - globals.system_config.maxAudioProcessBlockSize = PIKA_BLOCK_LEN; - globals.system_config.playBufferSize = PIKA_BLOCK_SIZE; - globals.system_config.recordBufferSize = PIKA_BLOCK_SIZE; - globals.system_config.recordNumberOfBuffers = PIKA_NUM_BUFFERS; - PKH_SYSTEM_SetConfig(globals.system_handle, &globals.system_config); - - status = PKH_MEDIA_STREAM_Create(&tmpHandle); - status = PKH_RECORD_GetConfig(tmpHandle, &globals.record_config); - status = PKH_PLAY_GetConfig(tmpHandle, &globals.play_config); - status = PKH_EC_GetConfig(tmpHandle, &globals.ec_config); - status = PKH_MEDIA_STREAM_Destroy(tmpHandle); - - - - ftdm_log(FTDM_LOG_DEBUG, "Found %u board%s\n", globals.board_list.numberOfBoards, globals.board_list.numberOfBoards == 1 ? "" : "s"); - for(i = 0; i < globals.board_list.numberOfBoards; ++i) { - ftdm_log(FTDM_LOG_INFO, "Found PIKA board type:[%s] id:[%u] serno:[%u]\n", - pika_board_type_string(globals.board_list.board[i].type), globals.board_list.board[i].id, (uint32_t) - globals.board_list.board[i].serialNumber); - - if (globals.board_list.board[i].type == PKH_BOARD_TYPE_DIGITAL_GATEWAY) { - TPikaHandle board_handle, span_handle; - PKH_TBoardConfig boardConfig; - PKH_BOARD_GetConfig(board_handle, &boardConfig); - PKH_BOARD_Open(globals.board_list.board[i].id, NULL, &board_handle); - PKH_SPAN_Open(board_handle, 0, NULL, &span_handle); - PKH_SPAN_GetConfig(span_handle, &globals.t1_span_config); - PKH_SPAN_Close(span_handle); - boardConfig.specific.DigitalGateway.interfaceType = PKH_BOARD_INTERFACE_TYPE_E1; - PKH_BOARD_SetConfig(board_handle, &boardConfig); - PKH_SPAN_Open(board_handle, 0, NULL, &span_handle); - PKH_SPAN_GetConfig(span_handle, &globals.e1_span_config); - PKH_SPAN_Close(span_handle); - boardConfig.specific.DigitalGateway.interfaceType = PKH_BOARD_INTERFACE_TYPE_T1; - PKH_BOARD_SetConfig(board_handle, &boardConfig); - PKH_BOARD_Close(board_handle); - } - ok++; - - } - - if (!ok) { - return FTDM_FAIL; - } - - pika_interface.name = "pika"; - pika_interface.configure = pika_configure; - pika_interface.configure_span = pika_configure_span; - pika_interface.open = pika_open; - pika_interface.close = pika_close; - pika_interface.wait = pika_wait; - pika_interface.read = pika_read; - pika_interface.write = pika_write; - pika_interface.command = pika_command; - pika_interface.poll_event = pika_poll_event; - pika_interface.next_event = pika_next_event; - pika_interface.channel_destroy = pika_channel_destroy; - pika_interface.span_destroy = pika_span_destroy; - pika_interface.get_alarms = pika_get_alarms; - *fio = &pika_interface; - - - ftdm_log(FTDM_LOG_INFO, "Dumping Default configs:\n"); - ftdm_log(FTDM_LOG_INFO, "rx-gain => %0.2f\n", (float)globals.record_config.gain); - ftdm_log(FTDM_LOG_INFO, "rx-agc-enabled => %s\n", globals.record_config.AGC.enabled ? "true" : "false"); - ftdm_log(FTDM_LOG_INFO, "rx-agc-targetPower => %0.2f\n", (float)globals.record_config.AGC.targetPower); - ftdm_log(FTDM_LOG_INFO, "rx-agc-minGain => %0.2f\n", (float)globals.record_config.AGC.minGain); - ftdm_log(FTDM_LOG_INFO, "rx-agc-maxGain => %0.2f\n", (float)globals.record_config.AGC.maxGain); - ftdm_log(FTDM_LOG_INFO, "rx-agc-attackRate => %d\n", (int)globals.record_config.AGC.attackRate); - ftdm_log(FTDM_LOG_INFO, "rx-agc-decayRate => %d\n", (int)globals.record_config.AGC.decayRate); - ftdm_log(FTDM_LOG_INFO, "rx-agc-speechThreshold => %0.2f\n", (float)globals.record_config.AGC.speechThreshold); - ftdm_log(FTDM_LOG_INFO, "rx-vad-enabled => %s\n", globals.record_config.VAD.enabled ? "true" : "false"); - ftdm_log(FTDM_LOG_INFO, "rx-vad-activationThreshold => %0.2f\n", (float)globals.record_config.VAD.activationThreshold); - ftdm_log(FTDM_LOG_INFO, "rx-vad-activationDebounceTime => %d\n", (int)globals.record_config.VAD.activationDebounceTime); - ftdm_log(FTDM_LOG_INFO, "rx-vad-deactivationThreshold => %0.2f\n", (float)globals.record_config.VAD.deactivationThreshold); - ftdm_log(FTDM_LOG_INFO, "rx-vad-deactivationDebounceTime => %d\n", (int)globals.record_config.VAD.deactivationDebounceTime); - ftdm_log(FTDM_LOG_INFO, "rx-vad-preSpeechBufferSize => %d\n", (int)globals.record_config.VAD.preSpeechBufferSize); - ftdm_log(FTDM_LOG_INFO, "tx-gain => %0.2f\n", (float)globals.play_config.gain); - ftdm_log(FTDM_LOG_INFO, "tx-agc-enabled => %s\n", globals.play_config.AGC.enabled ? "true" : "false"); - ftdm_log(FTDM_LOG_INFO, "tx-agc-targetPower => %0.2f\n", (float)globals.play_config.AGC.targetPower); - ftdm_log(FTDM_LOG_INFO, "tx-agc-minGain => %0.2f\n", (float)globals.play_config.AGC.minGain); - ftdm_log(FTDM_LOG_INFO, "tx-agc-maxGain => %0.2f\n", (float)globals.play_config.AGC.maxGain); - ftdm_log(FTDM_LOG_INFO, "tx-agc-attackRate => %d\n", (int)globals.play_config.AGC.attackRate); - ftdm_log(FTDM_LOG_INFO, "tx-agc-decayRate => %d\n", (int)globals.play_config.AGC.decayRate); - ftdm_log(FTDM_LOG_INFO, "tx-agc-speechThreshold => %0.2f\n", (float)globals.play_config.AGC.speechThreshold); - ftdm_log(FTDM_LOG_INFO, "ec-doubleTalkerThreshold => %0.2f\n", (float)globals.ec_config.doubleTalkerThreshold); - ftdm_log(FTDM_LOG_INFO, "ec-speechPresentThreshold => %0.2f\n", (float)globals.ec_config.speechPresentThreshold); - ftdm_log(FTDM_LOG_INFO, "ec-echoSuppressionThreshold => %0.2f\n", (float)globals.ec_config.echoSuppressionThreshold); - ftdm_log(FTDM_LOG_INFO, "ec-echoSuppressionEnabled => %s\n", globals.ec_config.echoSuppressionEnabled ? "true" : "false"); - ftdm_log(FTDM_LOG_INFO, "ec-comfortNoiseEnabled => %s\n", globals.ec_config.comfortNoiseEnabled ? "true" : "false"); - ftdm_log(FTDM_LOG_INFO, "ec-adaptationModeEnabled => %s\n", globals.ec_config.adaptationModeEnabled ? "true" : "false"); - - - - memset(&m, 0, sizeof(m)); - //m.apiMask = 0xffffffff; - //PKH_LOG_SetMasks(&m); - - return FTDM_SUCCESS; -} - -/** - * \brief Unloads Pika IO module - * \return Success - */ -static FIO_IO_UNLOAD_FUNCTION(pika_destroy) -{ - uint32_t x; - PK_STATUS status; - PK_CHAR error_text[PKH_ERROR_MAX_NAME_LENGTH]; - - for (x = 0; x < MAX_NUMBER_OF_TRUNKS; x++) { - if (globals.open_boards[x]) { - ftdm_log(FTDM_LOG_INFO, "Closing board %u\n", x); - PKH_BOARD_Close(globals.open_boards[x]); - } - } - - // The system can now be closed. - if ((status = PKH_SYSTEM_Close(globals.system_handle)) != PK_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "Error: PKH_SYSTEM_Close failed(%s)!\n", - PKH_ERROR_GetText(status, error_text, sizeof(error_text))); - } else { - ftdm_log(FTDM_LOG_INFO, "Closing system handle\n"); - } - - hashtable_destroy(globals.profile_hash); - - return FTDM_SUCCESS; -} - -/** - * \brief Pika IO module definition - */ -EX_DECLARE_DATA ftdm_module_t ftdm_module = { - "pika", - pika_init, - pika_destroy, -}; - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ - diff --git a/libs/freetdm/src/ftmod/ftmod_pika/ozmod_pika.2005.vcproj b/libs/freetdm/src/ftmod/ftmod_pika/ozmod_pika.2005.vcproj deleted file mode 100644 index 646cc11428..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_pika/ozmod_pika.2005.vcproj +++ /dev/null @@ -1,197 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/freetdm/src/ftmod/ftmod_pritap/ftmod_pritap.c b/libs/freetdm/src/ftmod/ftmod_pritap/ftmod_pritap.c deleted file mode 100644 index 38f9c48e84..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_pritap/ftmod_pritap.c +++ /dev/null @@ -1,1189 +0,0 @@ -/* - * Copyright (c) 2010, Moises Silva - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include "private/ftdm_core.h" - -#define PRI_SPAN(p) (((p) >> 8) & 0xff) -#define PRI_CHANNEL(p) ((p) & 0xff) - -#define PRITAP_NETWORK_ANSWER 0x1 - -typedef enum { - PRITAP_RUNNING = (1 << 0), - PRITAP_MASTER = (1 << 1), -} pritap_flags_t; - -typedef enum { - PRITAP_MIX_BOTH = 0, - PRITAP_MIX_PEER, - PRITAP_MIX_SELF, -} pritap_mix_mode_t; - -typedef struct { - void *callref; - ftdm_number_t callingnum; - ftdm_number_t callingani; - ftdm_number_t callednum; - ftdm_channel_t *fchan; - char callingname[80]; - uint8_t proceeding; - uint8_t inuse; -} passive_call_t; - -typedef enum pritap_iface { - PRITAP_IFACE_UNKNOWN = 0, - PRITAP_IFACE_CPE = 1, - PRITAP_IFACE_NET = 2, -} pritap_iface_t; - -typedef struct pritap { - int32_t flags; - struct pri *pri; - int debug; - pritap_mix_mode_t mixaudio; - ftdm_channel_t *dchan; - ftdm_span_t *span; - ftdm_span_t *peerspan; - ftdm_mutex_t *pcalls_lock; - passive_call_t pcalls[FTDM_MAX_CHANNELS_PHYSICAL_SPAN]; - pritap_iface_t iface; -} pritap_t; - -static FIO_IO_UNLOAD_FUNCTION(ftdm_pritap_unload) -{ - return FTDM_SUCCESS; -} - -static FIO_CHANNEL_GET_SIG_STATUS_FUNCTION(pritap_get_channel_sig_status) -{ - *status = FTDM_SIG_STATE_UP; - return FTDM_SUCCESS; -} - -static FIO_SPAN_GET_SIG_STATUS_FUNCTION(pritap_get_span_sig_status) -{ - *status = FTDM_SIG_STATE_UP; - return FTDM_SUCCESS; -} - - -static FIO_CHANNEL_OUTGOING_CALL_FUNCTION(pritap_outgoing_call) -{ - ftdm_log(FTDM_LOG_ERROR, "Cannot dial on PRI tapping line!\n"); - return FTDM_FAIL; -} - -static void s_pri_error(struct pri *pri, char *s) -{ - pritap_t *pritap = pri_get_userdata(pri); - - if (pritap && pritap->dchan) { - ftdm_log_chan(pritap->dchan, FTDM_LOG_ERROR, "%s", s); - } else { - ftdm_log(FTDM_LOG_ERROR, "%s", s); - } -} - -static void s_pri_message(struct pri *pri, char *s) -{ - pritap_t *pritap = pri_get_userdata(pri); - - if (pritap && pritap->dchan) { - ftdm_log_chan(pritap->dchan, FTDM_LOG_DEBUG, "%s", s); - } else { - ftdm_log(FTDM_LOG_DEBUG, "%s", s); - } -} - -#define PRI_DEBUG_Q921_ALL (PRI_DEBUG_Q921_RAW | PRI_DEBUG_Q921_DUMP | PRI_DEBUG_Q921_STATE) -#define PRI_DEBUG_Q931_ALL (PRI_DEBUG_Q931_DUMP | PRI_DEBUG_Q931_STATE | PRI_DEBUG_Q931_ANOMALY) - -static int parse_debug(const char *in) -{ - int flags = 0; - - if (!in) { - return 0; - } - - if (!strcmp(in, "none")) { - return 0; - } - - if (!strcmp(in, "all")) { - return PRI_DEBUG_ALL; - } - - if (strstr(in, "q921_all")) { - flags |= PRI_DEBUG_Q921_ALL; - } - - if (strstr(in, "q921_raw")) { - flags |= PRI_DEBUG_Q921_RAW; - } - - if (strstr(in, "q921_dump")) { - flags |= PRI_DEBUG_Q921_DUMP; - } - - if (strstr(in, "q921_state")) { - flags |= PRI_DEBUG_Q921_STATE; - } - - if (strstr(in, "config")) { - flags |= PRI_DEBUG_CONFIG; - } - - if (strstr(in, "q931_all")) { - flags |= PRI_DEBUG_Q931_ALL; - } - - if (strstr(in, "q931_dump")) { - flags |= PRI_DEBUG_Q931_DUMP; - } - - if (strstr(in, "q931_state")) { - flags |= PRI_DEBUG_Q931_STATE; - } - - if (strstr(in, "q931_anomaly")) { - flags |= PRI_DEBUG_Q931_ANOMALY; - } - - if (strstr(in, "apdu")) { - flags |= PRI_DEBUG_APDU; - } - - if (strstr(in, "aoc")) { - flags |= PRI_DEBUG_AOC; - } - - return flags; -} - -static ftdm_io_interface_t ftdm_pritap_interface; - -static ftdm_status_t ftdm_pritap_start(ftdm_span_t *span); - -static FIO_API_FUNCTION(ftdm_pritap_api) -{ - char *mycmd = NULL, *argv[10] = { 0 }; - int argc = 0; - - if (data) { - mycmd = ftdm_strdup(data); - argc = ftdm_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); - } - - if (argc > 2) { - if (!strcasecmp(argv[0], "debug")) { - ftdm_span_t *span = NULL; - - if (ftdm_span_find_by_name(argv[1], &span) == FTDM_SUCCESS) { - pritap_t *pritap = span->signal_data; - if (span->start != ftdm_pritap_start) { - stream->write_function(stream, "%s: -ERR invalid span.\n", __FILE__); - goto done; - } - - pri_set_debug(pritap->pri, parse_debug(argv[2])); - stream->write_function(stream, "%s: +OK debug set.\n", __FILE__); - goto done; - } else { - stream->write_function(stream, "%s: -ERR invalid span.\n", __FILE__); - goto done; - } - } - - } - - stream->write_function(stream, "%s: -ERR invalid command.\n", __FILE__); - - done: - - ftdm_safe_free(mycmd); - - return FTDM_SUCCESS; -} - -static FIO_IO_LOAD_FUNCTION(ftdm_pritap_io_init) -{ - memset(&ftdm_pritap_interface, 0, sizeof(ftdm_pritap_interface)); - - ftdm_pritap_interface.name = "pritap"; - ftdm_pritap_interface.api = ftdm_pritap_api; - - *fio = &ftdm_pritap_interface; - - return FTDM_SUCCESS; -} - -static FIO_SIG_LOAD_FUNCTION(ftdm_pritap_init) -{ - pri_set_error(s_pri_error); - pri_set_message(s_pri_message); - return FTDM_SUCCESS; -} - -static ftdm_state_map_t pritap_state_map = { - { - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_RING, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_RING, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_END}, - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END}, - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END}, - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END}, - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_END}, - }, - - } -}; - -#define PRITAP_GET_INTERFACE(iface) iface == PRITAP_IFACE_CPE ? "CPE" : \ - iface == PRITAP_IFACE_NET ? "NET" : "UNKNOWN" -static ftdm_status_t state_advance(ftdm_channel_t *ftdmchan) -{ - ftdm_status_t status; - ftdm_sigmsg_t sig; - pritap_t *pritap = ftdmchan->span->signal_data; - pritap_t *peer_pritap = pritap->peerspan->signal_data; - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "processing state %s\n", ftdm_channel_state2str(ftdmchan->state)); - - memset(&sig, 0, sizeof(sig)); - sig.chan_id = ftdmchan->chan_id; - sig.span_id = ftdmchan->span_id; - sig.channel = ftdmchan; - - ftdm_channel_complete_state(ftdmchan); - - switch (ftdmchan->state) { - case FTDM_CHANNEL_STATE_DOWN: - { - ftdm_channel_t *fchan = ftdmchan; - - /* Destroy the peer data first */ - if (fchan->call_data) { - ftdm_channel_t *peerchan = fchan->call_data; - ftdm_channel_t *pchan = peerchan; - - ftdm_channel_lock(peerchan); - - pchan->call_data = NULL; - pchan->pflags = 0; - ftdm_channel_close(&pchan); - - ftdm_channel_unlock(peerchan); - } else { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "No call data?\n"); - } - - ftdmchan->call_data = NULL; - ftdmchan->pflags = 0; - ftdm_channel_close(&fchan); - } - break; - - case FTDM_CHANNEL_STATE_PROGRESS: - case FTDM_CHANNEL_STATE_PROGRESS_MEDIA: - case FTDM_CHANNEL_STATE_HANGUP: - break; - - case FTDM_CHANNEL_STATE_UP: - { - if (ftdm_test_pflag(ftdmchan, PRITAP_NETWORK_ANSWER)) { - ftdm_clear_pflag(ftdmchan, PRITAP_NETWORK_ANSWER); - sig.event_id = FTDM_SIGEVENT_UP; - ftdm_span_send_signal(ftdmchan->span, &sig); - } - } - break; - - case FTDM_CHANNEL_STATE_RING: - { - sig.event_id = FTDM_SIGEVENT_START; - /* The ring interface (where the setup was received) is the peer, since we RING the channel - * where PROCEED/PROGRESS is received */ - ftdm_sigmsg_add_var(&sig, "pritap_ring_interface", PRITAP_GET_INTERFACE(peer_pritap->iface)); - if ((status = ftdm_span_send_signal(ftdmchan->span, &sig) != FTDM_SUCCESS)) { - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_HANGUP); - } - } - break; - - case FTDM_CHANNEL_STATE_TERMINATING: - { - if (ftdmchan->last_state != FTDM_CHANNEL_STATE_HANGUP) { - sig.event_id = FTDM_SIGEVENT_STOP; - status = ftdm_span_send_signal(ftdmchan->span, &sig); - } - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - } - break; - - default: - { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "ignoring state change from %s to %s\n", ftdm_channel_state2str(ftdmchan->last_state), ftdm_channel_state2str(ftdmchan->state)); - } - break; - } - - return FTDM_SUCCESS; -} - -static __inline__ void pritap_check_state(ftdm_span_t *span) -{ - if (ftdm_test_flag(span, FTDM_SPAN_STATE_CHANGE)) { - uint32_t j; - ftdm_clear_flag_locked(span, FTDM_SPAN_STATE_CHANGE); - for(j = 1; j <= span->chan_count; j++) { - ftdm_channel_lock(span->channels[j]); - ftdm_channel_advance_states(span->channels[j]); - ftdm_channel_unlock(span->channels[j]); - } - } -} - -static int pri_io_read(struct pri *pri, void *buf, int buflen) -{ - int res; - ftdm_status_t zst; - pritap_t *pritap = pri_get_userdata(pri); - ftdm_size_t len = buflen; - - if ((zst = ftdm_channel_read(pritap->dchan, buf, &len)) != FTDM_SUCCESS) { - if (zst == FTDM_FAIL) { - ftdm_log(FTDM_LOG_CRIT, "span %d D channel read fail! [%s]\n", pritap->span->span_id, pritap->dchan->last_error); - } else { - ftdm_log(FTDM_LOG_CRIT, "span %d D channel read timeout!\n", pritap->span->span_id); - } - return -1; - } - - res = (int)len; - - memset(&((unsigned char*)buf)[res],0,2); - res += 2; - - /* libpri passive q921 raw dump does not work for all frames */ - if (pritap->debug & PRI_DEBUG_Q921_RAW) { - char hbuf[2048] = { 0 }; - - print_hex_bytes(buf, len, hbuf, sizeof(hbuf)); - ftdm_log_chan(pritap->dchan, FTDM_LOG_DEBUG, "READ %"FTDM_SIZE_FMT"\n%s\n", len, hbuf); - } - return res; -} - -static int pri_io_write(struct pri *pri, void *buf, int buflen) -{ - pritap_t *pritap = pri_get_userdata(pri); - ftdm_size_t len = buflen - 2; - - /* libpri passive q921 raw dump does not work for all frames */ - if (pritap->debug & PRI_DEBUG_Q921_RAW) { - char hbuf[2048] = { 0 }; - - print_hex_bytes(buf, len, hbuf, sizeof(hbuf)); - ftdm_log_chan(pritap->dchan, FTDM_LOG_DEBUG, "WRITE %"FTDM_SIZE_FMT"\n%s\n", len, hbuf); - } - - if (ftdm_channel_write(pritap->dchan, buf, buflen, &len) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_CRIT, "span %d D channel write failed! [%s]\n", pritap->span->span_id, pritap->dchan->last_error); - return -1; - } - - return (int)buflen; -} - -static int tap_pri_get_crv(struct pri *ctrl, q931_call *call) -{ - int callmode = 0; - int crv = pri_get_crv(ctrl, call, &callmode); - crv <<= 3; - crv |= (callmode & 0x7); - return crv; -} - -static passive_call_t *tap_pri_get_pcall_bycrv(pritap_t *pritap, int crv) -{ - int i; - int tstcrv; - - ftdm_mutex_lock(pritap->pcalls_lock); - - for (i = 0; i < ftdm_array_len(pritap->pcalls); i++) { - tstcrv = pritap->pcalls[i].callref ? tap_pri_get_crv(pritap->pri, pritap->pcalls[i].callref) : 0; - if (pritap->pcalls[i].callref && tstcrv == crv) { - if (pritap->pcalls[i].inuse) { - ftdm_mutex_unlock(pritap->pcalls_lock); - return &pritap->pcalls[i]; - } - /* This just means the crv is being re-used in another call before this one was destroyed */ - ftdm_log(FTDM_LOG_DEBUG, "Found crv %d in slot %d of span %s with call %p but is no longer in use\n", - crv, i, pritap->span->name, pritap->pcalls[i].callref); - } - } - - ftdm_log(FTDM_LOG_DEBUG, "crv %d was not found active in span %s\n", crv, pritap->span->name); - - ftdm_mutex_unlock(pritap->pcalls_lock); - - return NULL; -} - -/* - * This is a tricky function with some side effects, some explanation needed ... - * - * The libpri stack process HDLC frames, then finds Q921 frames and Q931 events, each time - * it finds a new Q931 event, checks if the crv of that event matches a known call in the internal - * list found in the PRI control block (for us, one control block per span), if it does not find - * the call, allocates a new one and then sends the event up to the user (us, ftmod_pritap in this case) - * - * The user is then expected to destroy the call when done with it (on hangup), but things get tricky here - * because in ftmod_pritap we do not destroy the call right away to be sure we only destroy it when no one - * else needs that pointer, therefore we decide to delay the destruction of the call pointer until later - * when a new call comes which triggers the garbage collecting code in this function - * - * Now, what happens if a new call arrives right away with the same crv than the last call? the pri stack - * does *not* allocate a new call pointer because is still a known call and we must therefore re-use the - * same call pointer - * - * This function accepts a pointer to a callref, even a NULL one. When callref is NULL we search for an - * available slot so the caller of this function can use it to store a new callref pointer. In the process - * we also scan for slots that still have a callref pointer but are no longer in use (inuse=0) and we - * destroy that callref and clear the slot (memset). The trick is, we only do this if the callref to - * be garbage collected is NOT the one provided by the parameter callref, of course! otherwise we may - * be freeing a pointer to a callref for a new call that used an old (recycled) callref! - */ -static passive_call_t *tap_pri_get_pcall(pritap_t *pritap, void *callref) -{ - int i; - int crv; - - ftdm_mutex_lock(pritap->pcalls_lock); - - for (i = 0; i < ftdm_array_len(pritap->pcalls); i++) { - /* If this slot has a call reference - * and it is different than the *callref provided to us - * and is no longer in use, - * then it is time to garbage collect it ... */ - if (pritap->pcalls[i].callref && callref != pritap->pcalls[i].callref && !pritap->pcalls[i].inuse) { - crv = tap_pri_get_crv(pritap->pri, pritap->pcalls[i].callref); - /* garbage collection */ - ftdm_log(FTDM_LOG_DEBUG, "Garbage collecting callref %d/%p from span %s in slot %d\n", - crv, pritap->pcalls[i].callref, pritap->span->name, i); - pri_passive_destroycall(pritap->pri, pritap->pcalls[i].callref); - memset(&pritap->pcalls[i], 0, sizeof(pritap->pcalls[0])); - } - if (callref == pritap->pcalls[i].callref) { - if (callref == NULL) { - pritap->pcalls[i].inuse = 1; - ftdm_log(FTDM_LOG_DEBUG, "Enabling callref slot %d in span %s\n", i, pritap->span->name); - } else if (!pritap->pcalls[i].inuse) { - crv = tap_pri_get_crv(pritap->pri, callref); - ftdm_log(FTDM_LOG_DEBUG, "Recyclying callref slot %d in span %s for callref %d/%p\n", - i, pritap->span->name, crv, callref); - memset(&pritap->pcalls[i], 0, sizeof(pritap->pcalls[0])); - pritap->pcalls[i].callref = callref; - pritap->pcalls[i].inuse = 1; - } - - ftdm_mutex_unlock(pritap->pcalls_lock); - - return &pritap->pcalls[i]; - } - } - - ftdm_mutex_unlock(pritap->pcalls_lock); - - return NULL; -} - -static void tap_pri_put_pcall(pritap_t *pritap, void *callref) -{ - int i; - int crv; - int tstcrv; - - if (!callref) { - ftdm_log(FTDM_LOG_ERROR, "Cannot put pcall for null callref in span %s\n", pritap->span->name); - return; - } - - ftdm_mutex_lock(pritap->pcalls_lock); - - crv = tap_pri_get_crv(pritap->pri, callref); - for (i = 0; i < ftdm_array_len(pritap->pcalls); i++) { - if (!pritap->pcalls[i].callref) { - continue; - } - tstcrv = tap_pri_get_crv(pritap->pri, pritap->pcalls[i].callref); - if (tstcrv == crv) { - if (pritap->pcalls[i].inuse) { - ftdm_log(FTDM_LOG_DEBUG, "releasing slot %d in span %s used by callref %d/%p\n", i, - pritap->span->name, crv, pritap->pcalls[i].callref); - pritap->pcalls[i].inuse = 0; - } - } - } - - ftdm_mutex_unlock(pritap->pcalls_lock); -} - -static __inline__ ftdm_channel_t *tap_pri_get_fchan(pritap_t *pritap, passive_call_t *pcall, int channel) -{ - ftdm_channel_t *fchan = NULL; - int err = 0; - int chanpos = PRI_CHANNEL(channel); - if (!chanpos || chanpos > pritap->span->chan_count) { - ftdm_log(FTDM_LOG_CRIT, "Invalid pri tap channel %d requested in span %s\n", channel, pritap->span->name); - return NULL; - } - - fchan = pritap->span->channels[PRI_CHANNEL(channel)]; - - ftdm_channel_lock(fchan); - - if (ftdm_test_flag(fchan, FTDM_CHANNEL_INUSE)) { - ftdm_log(FTDM_LOG_ERROR, "Channel %d requested in span %s is already in use!\n", channel, pritap->span->name); - err = 1; - goto done; - } - - if (ftdm_channel_open_chan(fchan) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "Could not open tap channel %d requested in span %s\n", channel, pritap->span->name); - err = 1; - goto done; - } - - memset(&fchan->caller_data, 0, sizeof(fchan->caller_data)); - - ftdm_set_string(fchan->caller_data.cid_num.digits, pcall->callingnum.digits); - if (!ftdm_strlen_zero(pcall->callingname)) { - ftdm_set_string(fchan->caller_data.cid_name, pcall->callingname); - } else { - ftdm_set_string(fchan->caller_data.cid_name, pcall->callingnum.digits); - } - ftdm_set_string(fchan->caller_data.ani.digits, pcall->callingani.digits); - ftdm_set_string(fchan->caller_data.dnis.digits, pcall->callednum.digits); - -done: - if (fchan) { - ftdm_channel_unlock(fchan); - } - - if (err) { - return NULL; - } - - return fchan; -} - -static void handle_pri_passive_event(pritap_t *pritap, pri_event *e) -{ - passive_call_t *pcall = NULL; - passive_call_t *peerpcall = NULL; - ftdm_channel_t *fchan = NULL; - ftdm_channel_t *peerfchan = NULL; - int layer1, transcap = 0; - int crv = 0; - pritap_t *peertap = pritap->peerspan->signal_data; - - switch (e->e) { - - case PRI_EVENT_RING: - /* we cannot use ftdm_channel_t because we still dont know which channel will be used - * (ie, flexible channel was requested), thus, we need our own list of call references */ - crv = tap_pri_get_crv(pritap->pri, e->ring.call); - ftdm_log(FTDM_LOG_DEBUG, "Ring on channel %s:%d:%d with callref %d\n", - pritap->span->name, PRI_SPAN(e->ring.channel), PRI_CHANNEL(e->ring.channel), crv); - pcall = tap_pri_get_pcall_bycrv(pritap, crv); - if (pcall) { - ftdm_log(FTDM_LOG_WARNING, "There is a call with callref %d already, ignoring duplicated ring event\n", crv); - break; - } - - /* Try to get a recycled call (ie, e->ring.call is a call that the PRI stack allocated previously and then - * re-used for the next RING event because we did not destroy it fast enough) */ - pcall = tap_pri_get_pcall(pritap, e->ring.call); - if (!pcall) { - /* ok so the call is really not known to us, let's get a new one */ - pcall = tap_pri_get_pcall(pritap, NULL); - if (!pcall) { - ftdm_log(FTDM_LOG_ERROR, "Failed to get a free passive PRI call slot for callref %d, this is a bug!\n", crv); - break; - } - } - pcall->callref = e->ring.call; - ftdm_set_string(pcall->callingnum.digits, e->ring.callingnum); - ftdm_set_string(pcall->callingani.digits, e->ring.callingani); - ftdm_set_string(pcall->callednum.digits, e->ring.callednum); - ftdm_set_string(pcall->callingname, e->ring.callingname); - break; - - case PRI_EVENT_PROGRESS: - crv = tap_pri_get_crv(pritap->pri, e->proceeding.call); - ftdm_log(FTDM_LOG_DEBUG, "Progress on channel %s:%d:%d with callref %d\n", - pritap->span->name, PRI_SPAN(e->proceeding.channel), PRI_CHANNEL(e->proceeding.channel), crv); - break; - - case PRI_EVENT_PROCEEDING: - crv = tap_pri_get_crv(pritap->pri, e->proceeding.call); - /* at this point we should know the real b chan that will be used and can therefore proceed to notify about the call, but - * only if a couple of call tests are passed first */ - ftdm_log(FTDM_LOG_DEBUG, "Proceeding on channel %s:%d:%d with callref %d\n", - pritap->span->name, PRI_SPAN(e->proceeding.channel), PRI_CHANNEL(e->proceeding.channel), crv); - - /* check that we already know about this call in the peer PRI (which was the one receiving the PRI_EVENT_RING event) */ - if (!(pcall = tap_pri_get_pcall_bycrv(peertap, crv))) { - ftdm_log(FTDM_LOG_DEBUG, - "ignoring proceeding in channel %s:%d:%d for callref %d since we don't know about it\n", - pritap->span->name, PRI_SPAN(e->proceeding.channel), PRI_CHANNEL(e->proceeding.channel), crv); - break; - } - if (pcall->proceeding) { - ftdm_log(FTDM_LOG_DEBUG, "Ignoring duplicated proceeding with callref %d\n", crv); - break; - } - pcall->proceeding = 1; - - /* This call should not be known to this PRI yet ... */ - if ((peerpcall = tap_pri_get_pcall_bycrv(pritap, crv))) { - ftdm_log(FTDM_LOG_ERROR, - "ignoring proceeding in channel %s:%d:%d for callref %d, dup???\n", - pritap->span->name, PRI_SPAN(e->proceeding.channel), PRI_CHANNEL(e->proceeding.channel), crv); - break; - } - - /* Check if the call pointer is being recycled */ - peerpcall = tap_pri_get_pcall(pritap, e->proceeding.call); - if (!peerpcall) { - peerpcall = tap_pri_get_pcall(pritap, NULL); - if (!peerpcall) { - ftdm_log(FTDM_LOG_ERROR, "Failed to get a free peer PRI passive call slot for callref %d in span %s, this is a bug!\n", - crv, pritap->span->name); - break; - } - peerpcall->callref = e->proceeding.call; - } - - /* check that the layer 1 and trans capability are supported */ - layer1 = pri_get_layer1(peertap->pri, pcall->callref); - transcap = pri_get_transcap(peertap->pri, pcall->callref); - - if (PRI_LAYER_1_ULAW != layer1 && PRI_LAYER_1_ALAW != layer1) { - ftdm_log(FTDM_LOG_NOTICE, "Not monitoring callref %d with unsupported layer 1 format %d\n", crv, layer1); - break; - } - - if (transcap != PRI_TRANS_CAP_SPEECH && transcap != PRI_TRANS_CAP_3_1K_AUDIO && transcap != PRI_TRANS_CAP_7K_AUDIO) { - ftdm_log(FTDM_LOG_NOTICE, "Not monitoring callref %d with unsupported capability %d\n", crv, transcap); - break; - } - - fchan = tap_pri_get_fchan(pritap, pcall, e->proceeding.channel); - if (!fchan) { - ftdm_log(FTDM_LOG_ERROR, "Proceeding requested on odd/unavailable channel %s:%d:%d for callref %d\n", - pritap->span->name, PRI_SPAN(e->proceeding.channel), PRI_CHANNEL(e->proceeding.channel), crv); - break; - } - - peerfchan = tap_pri_get_fchan(peertap, pcall, e->proceeding.channel); - if (!peerfchan) { - ftdm_log(FTDM_LOG_ERROR, "Proceeding requested on odd/unavailable channel %s:%d:%d for callref %d\n", - peertap->span->name, PRI_SPAN(e->proceeding.channel), PRI_CHANNEL(e->proceeding.channel), crv); - break; - } - pcall->fchan = fchan; - peerpcall->fchan = fchan; - - ftdm_log_chan(fchan, FTDM_LOG_NOTICE, "Starting new tapped call with callref %d\n", crv); - - ftdm_channel_lock(fchan); - fchan->call_data = peerfchan; - ftdm_set_state(fchan, FTDM_CHANNEL_STATE_RING); - ftdm_channel_unlock(fchan); - - ftdm_channel_lock(peerfchan); - peerfchan->call_data = fchan; - ftdm_channel_unlock(peerfchan); - - break; - - case PRI_EVENT_ANSWER: - crv = tap_pri_get_crv(pritap->pri, e->answer.call); - ftdm_log(FTDM_LOG_DEBUG, "Answer on channel %s:%d:%d with callref %d\n", - pritap->span->name, PRI_SPAN(e->answer.channel), PRI_CHANNEL(e->answer.channel), crv); - if (!(pcall = tap_pri_get_pcall_bycrv(pritap, crv))) { - ftdm_log(FTDM_LOG_DEBUG, - "ignoring answer in channel %s:%d:%d for callref %d since we don't know about it\n", - pritap->span->name, PRI_SPAN(e->answer.channel), PRI_CHANNEL(e->proceeding.channel), crv); - break; - } - if (!pcall->fchan) { - ftdm_log(FTDM_LOG_ERROR, - "Received answer in channel %s:%d:%d for callref %d but we never got a channel\n", - pritap->span->name, PRI_SPAN(e->answer.channel), PRI_CHANNEL(e->answer.channel), crv); - break; - } - ftdm_channel_lock(pcall->fchan); - ftdm_log_chan(pcall->fchan, FTDM_LOG_NOTICE, "Tapped call was answered in state %s\n", ftdm_channel_state2str(pcall->fchan->state)); - ftdm_set_pflag(pcall->fchan, PRITAP_NETWORK_ANSWER); - ftdm_set_state(pcall->fchan, FTDM_CHANNEL_STATE_UP); - ftdm_channel_unlock(pcall->fchan); - break; - - case PRI_EVENT_HANGUP_REQ: - crv = tap_pri_get_crv(pritap->pri, e->hangup.call); - - ftdm_log(FTDM_LOG_DEBUG, "Hangup on channel %s:%d:%d with callref %d\n", - pritap->span->name, PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), crv); - - if (!(pcall = tap_pri_get_pcall_bycrv(pritap, crv))) { - ftdm_log(FTDM_LOG_DEBUG, - "ignoring hangup in channel %s:%d:%d for callref %d since we don't know about it", - pritap->span->name, PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), crv); - break; - } - - if (pcall->fchan) { - fchan = pcall->fchan; - ftdm_channel_lock(fchan); - if (fchan->state < FTDM_CHANNEL_STATE_TERMINATING) { - ftdm_set_state(fchan, FTDM_CHANNEL_STATE_TERMINATING); - } - pcall->fchan = NULL; /* after this event we're not supposed to need to do anything with the channel anymore */ - ftdm_channel_unlock(fchan); - } - - tap_pri_put_pcall(pritap, e->hangup.call); - tap_pri_put_pcall(peertap, e->hangup.call); - break; - - case PRI_EVENT_HANGUP_ACK: - crv = tap_pri_get_crv(pritap->pri, e->hangup.call); - ftdm_log(FTDM_LOG_DEBUG, "Hangup ack on channel %s:%d:%d with callref %d\n", - pritap->span->name, PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), crv); - tap_pri_put_pcall(pritap, e->hangup.call); - tap_pri_put_pcall(peertap, e->hangup.call); - break; - - default: - ftdm_log(FTDM_LOG_DEBUG, "Ignoring passive event %s on span %s\n", pri_event2str(e->gen.e), pritap->span->name); - break; - - } -} - -static void *ftdm_pritap_run(ftdm_thread_t *me, void *obj) -{ - ftdm_span_t *span = (ftdm_span_t *) obj; - ftdm_span_t *peer = NULL; - pritap_t *pritap = span->signal_data; - pritap_t *p_pritap = NULL; - pri_event *event = NULL; - struct pollfd dpoll[2]; - int rc = 0; - - ftdm_log(FTDM_LOG_DEBUG, "Tapping PRI thread started on span %s\n", span->name); - - pritap->span = span; - - ftdm_set_flag(span, FTDM_SPAN_IN_THREAD); - - if (ftdm_channel_open(span->span_id, pritap->dchan->chan_id, &pritap->dchan) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "Failed to open D-channel for span %s\n", span->name); - goto done; - } - - if ((pritap->pri = pri_new_cb(pritap->dchan->sockfd, PRI_NETWORK, PRI_SWITCH_NI2, pri_io_read, pri_io_write, pritap))){ - pri_set_debug(pritap->pri, pritap->debug); - } else { - ftdm_log(FTDM_LOG_CRIT, "Failed to create tapping PRI\n"); - goto done; - } - - /* The last span starting runs the show ... - * This simplifies locking and avoid races by having multiple threads for a single tapped link - * Since both threads really handle a single tapped link there is no benefit on multi-threading, just complications ... */ - peer = pritap->peerspan; - p_pritap = peer->signal_data; - if (!ftdm_test_flag(pritap, PRITAP_MASTER)) { - ftdm_log(FTDM_LOG_DEBUG, "Running dummy thread on span %s\n", span->name); - while (ftdm_running() && !ftdm_test_flag(span, FTDM_SPAN_STOP_THREAD)) { - poll(NULL, 0, 100); - } - } else { - memset(&dpoll, 0, sizeof(dpoll)); - dpoll[0].fd = pritap->dchan->sockfd; - dpoll[1].fd = p_pritap->dchan->sockfd; - - ftdm_log(FTDM_LOG_DEBUG, "Master tapping thread on span %s (fd1=%d, fd2=%d)\n", span->name, - pritap->dchan->sockfd, p_pritap->dchan->sockfd); - - while (ftdm_running() && !ftdm_test_flag(span, FTDM_SPAN_STOP_THREAD)) { - - pritap_check_state(span); - pritap_check_state(peer); - - dpoll[0].revents = 0; - dpoll[0].events = POLLIN; - - dpoll[1].revents = 0; - dpoll[1].events = POLLIN; - - rc = poll(&dpoll[0], 2, 10); - - if (rc < 0) { - if (errno == EINTR) { - ftdm_log(FTDM_LOG_DEBUG, "D-channel waiting interrupted, continuing ...\n"); - continue; - } - ftdm_log(FTDM_LOG_ERROR, "poll failed: %s\n", strerror(errno)); - continue; - } - - pri_schedule_run(pritap->pri); - pri_schedule_run(p_pritap->pri); - - pritap_check_state(span); - pritap_check_state(peer); - - if (rc) { - if (dpoll[0].revents & POLLIN) { - event = pri_read_event(pritap->pri); - if (event) { - handle_pri_passive_event(pritap, event); - pritap_check_state(span); - } - } - - if (dpoll[1].revents & POLLIN) { - event = pri_read_event(p_pritap->pri); - if (event) { - handle_pri_passive_event(p_pritap, event); - pritap_check_state(peer); - } - } - } - - } - } - - -done: - ftdm_log(FTDM_LOG_DEBUG, "Tapping PRI thread ended on span %s\n", span->name); - - ftdm_clear_flag(span, FTDM_SPAN_IN_THREAD); - ftdm_clear_flag(pritap, PRITAP_RUNNING); - ftdm_clear_flag(pritap, PRITAP_MASTER); - - return NULL; -} - -static ftdm_status_t ftdm_pritap_stop(ftdm_span_t *span) -{ - pritap_t *pritap = span->signal_data; - - if (!ftdm_test_flag(pritap, PRITAP_RUNNING)) { - return FTDM_FAIL; - } - - ftdm_set_flag(span, FTDM_SPAN_STOP_THREAD); - - while (ftdm_test_flag(span, FTDM_SPAN_IN_THREAD)) { - ftdm_sleep(100); - } - - ftdm_mutex_destroy(&pritap->pcalls_lock); - return FTDM_SUCCESS; -} - -static ftdm_status_t ftdm_pritap_sig_read(ftdm_channel_t *ftdmchan, void *data, ftdm_size_t size) -{ - ftdm_status_t status; - fio_codec_t codec_func; - ftdm_channel_t *peerchan = ftdmchan->call_data; - pritap_t *pritap = ftdmchan->span->signal_data; - int16_t chanbuf[size]; - int16_t peerbuf[size]; - int16_t mixedbuf[size]; - int i = 0; - ftdm_size_t sizeread = size; - - if (!FTDM_IS_VOICE_CHANNEL(ftdmchan) || !ftdmchan->call_data) { - return FTDM_SUCCESS; - } - - if (pritap->mixaudio == PRITAP_MIX_SELF) { - return FTDM_SUCCESS; - } - - if (pritap->mixaudio == PRITAP_MIX_PEER) { - /* start out by clearing the self audio to make sure we don't return audio we were - * not supposed to in an error condition */ - memset(data, FTDM_SILENCE_VALUE(ftdmchan), size); - } - - if (ftdmchan->native_codec != peerchan->native_codec) { - ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Invalid peer channel with format %d, ours = %d\n", - peerchan->native_codec, ftdmchan->native_codec); - return FTDM_FAIL; - } - - memcpy(chanbuf, data, size); - status = peerchan->fio->read(peerchan, peerbuf, &sizeread); - if (status != FTDM_SUCCESS) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "Failed to read from peer channel!\n"); - return FTDM_FAIL; - } - if (sizeread != size) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "read from peer channel only %"FTDM_SIZE_FMT" bytes!\n", sizeread); - return FTDM_FAIL; - } - - if (pritap->mixaudio == PRITAP_MIX_PEER) { - /* only the peer audio is requested */ - memcpy(data, peerbuf, size); - return FTDM_SUCCESS; - } - - codec_func = peerchan->native_codec == FTDM_CODEC_ULAW ? fio_ulaw2slin : peerchan->native_codec == FTDM_CODEC_ALAW ? fio_alaw2slin : NULL; - if (codec_func) { - sizeread = size; - codec_func(chanbuf, sizeof(chanbuf), &sizeread); - sizeread = size; - codec_func(peerbuf, sizeof(peerbuf), &sizeread); - } - - for (i = 0; i < size; i++) { - mixedbuf[i] = ftdm_saturated_add(chanbuf[i], peerbuf[i]); - } - - codec_func = peerchan->native_codec == FTDM_CODEC_ULAW ? fio_slin2ulaw : peerchan->native_codec == FTDM_CODEC_ALAW ? fio_slin2alaw : NULL; - if (codec_func) { - size = sizeof(mixedbuf); - codec_func(mixedbuf, size, &size); - } - memcpy(data, mixedbuf, size); - return FTDM_SUCCESS; -} - -static ftdm_status_t ftdm_pritap_start(ftdm_span_t *span) -{ - ftdm_status_t ret; - pritap_t *pritap = span->signal_data; - pritap_t *p_pritap = pritap->peerspan->signal_data; - - if (ftdm_test_flag(pritap, PRITAP_RUNNING)) { - return FTDM_FAIL; - } - - ftdm_mutex_create(&pritap->pcalls_lock); - - ftdm_clear_flag(span, FTDM_SPAN_STOP_THREAD); - ftdm_clear_flag(span, FTDM_SPAN_IN_THREAD); - - ftdm_set_flag(pritap, PRITAP_RUNNING); - if (p_pritap && ftdm_test_flag(p_pritap, PRITAP_RUNNING)) { - /* our peer already started, we're the master */ - ftdm_set_flag(pritap, PRITAP_MASTER); - } - ret = ftdm_thread_create_detached(ftdm_pritap_run, span); - - if (ret != FTDM_SUCCESS) { - return ret; - } - - return ret; -} - -static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_pritap_configure_span) -{ - uint32_t i; - const char *var, *val; - const char *debug = NULL; - pritap_mix_mode_t mixaudio = PRITAP_MIX_BOTH; - ftdm_channel_t *dchan = NULL; - pritap_t *pritap = NULL; - ftdm_span_t *peerspan = NULL; - pritap_iface_t iface = PRITAP_IFACE_UNKNOWN; - unsigned paramindex = 0; - - if (span->trunk_type >= FTDM_TRUNK_NONE) { - ftdm_log(FTDM_LOG_WARNING, "Invalid trunk type '%s' defaulting to T1.\n", ftdm_trunk_type2str(span->trunk_type)); - span->trunk_type = FTDM_TRUNK_T1; - } - - for (i = 1; i <= span->chan_count; i++) { - if (span->channels[i]->type == FTDM_CHAN_TYPE_DQ921) { - dchan = span->channels[i]; - } - } - - if (!dchan) { - ftdm_log(FTDM_LOG_ERROR, "No d-channel specified in freetdm.conf!\n"); - return FTDM_FAIL; - } - - for (paramindex = 0; ftdm_parameters[paramindex].var; paramindex++) { - var = ftdm_parameters[paramindex].var; - val = ftdm_parameters[paramindex].val; - ftdm_log(FTDM_LOG_DEBUG, "Tapping PRI key=value, %s=%s\n", var, val); - - if (!strcasecmp(var, "debug")) { - debug = val; - } else if (!strcasecmp(var, "mixaudio")) { - if (ftdm_true(val) || !strcasecmp(val, "both")) { - ftdm_log(FTDM_LOG_DEBUG, "Setting mix audio mode to 'both' for span %s\n", span->name); - mixaudio = PRITAP_MIX_BOTH; - } else if (!strcasecmp(val, "peer")) { - ftdm_log(FTDM_LOG_DEBUG, "Setting mix audio mode to 'peer' for span %s\n", span->name); - mixaudio = PRITAP_MIX_PEER; - } else { - ftdm_log(FTDM_LOG_DEBUG, "Setting mix audio mode to 'self' for span %s\n", span->name); - mixaudio = PRITAP_MIX_SELF; - } - } else if (!strcasecmp(var, "interface")) { - if (!strcasecmp(val, "cpe")) { - iface = PRITAP_IFACE_CPE; - } else if (!strcasecmp(val, "net")) { - iface = PRITAP_IFACE_NET; - } else { - ftdm_log(FTDM_LOG_WARNING, "Ignoring invalid tapping interface type %s\n", val); - } - } else if (!strcasecmp(var, "peerspan")) { - if (ftdm_span_find_by_name(val, &peerspan) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "Invalid tapping peer span %s\n", val); - break; - } - } else { - ftdm_log(FTDM_LOG_ERROR, "Unknown pri tapping parameter [%s]", var); - } - } - - if (!peerspan) { - ftdm_log(FTDM_LOG_ERROR, "No valid peerspan was specified!\n"); - return FTDM_FAIL; - } - - pritap = ftdm_calloc(1, sizeof(*pritap)); - if (!pritap) { - return FTDM_FAIL; - } - - pritap->debug = parse_debug(debug); - pritap->dchan = dchan; - pritap->peerspan = peerspan; - pritap->mixaudio = mixaudio; - pritap->iface = iface; - - span->start = ftdm_pritap_start; - span->stop = ftdm_pritap_stop; - span->sig_read = ftdm_pritap_sig_read; - span->signal_cb = sig_cb; - - span->signal_data = pritap; - span->signal_type = FTDM_SIGTYPE_ISDN; - span->outgoing_call = pritap_outgoing_call; - - span->get_channel_sig_status = pritap_get_channel_sig_status; - span->get_span_sig_status = pritap_get_span_sig_status; - - span->state_map = &pritap_state_map; - span->state_processor = state_advance; - - return FTDM_SUCCESS; -} - -/** - * \brief FreeTDM pritap signaling and IO module definition - */ -ftdm_module_t ftdm_module = { - "pritap", - ftdm_pritap_io_init, - ftdm_pritap_unload, - ftdm_pritap_init, - NULL, - NULL, - ftdm_pritap_configure_span, -}; - - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.2008.vcproj b/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.2008.vcproj deleted file mode 100644 index 565a31e505..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.2008.vcproj +++ /dev/null @@ -1,196 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.2010.vcxproj.filters b/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.2010.vcxproj.filters deleted file mode 100644 index 9c91228e09..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.2010.vcxproj.filters +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - Source Files - - - \ No newline at end of file diff --git a/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c b/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c deleted file mode 100755 index 8b36cdb8f3..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c +++ /dev/null @@ -1,2437 +0,0 @@ -/* - * Copyright (c) 2009, Moises Silva - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Contributors: - * - * Arnaldo Pereira - * Ricardo Barroetaveña - * - */ - -#ifdef __linux__ -#ifndef _DEFAULT_SOURCE -#define _DEFAULT_SOURCE -#endif -#ifndef _BSD_SOURCE -#define _BSD_SOURCE /* for strsep() */ -#endif -#include -#include -#include -#endif -#include -#include -#include -#include - -#include "ftmod_r2_io_mf_lib.h" // ftdm_r2_get_native_channel_mf_generation_iface - -/* when the user stops a span, we clear FTDM_R2_SPAN_STARTED, so that the signaling thread - * knows it must stop, and we wait for FTDM_R2_RUNNING to be clear, which tells us the - * signaling thread is done. */ -/* FIXME: what about the calls that are already up-and-running? */ -typedef enum { - FTDM_R2_RUNNING = (1 << 0), - FTDM_R2_SPAN_STARTED = (1 << 1), -} ftdm_r2_flag_t; - -/* private call information stored in ftdmchan->call_data void* ptr, - * remember that each time you add a new member to this structure - * most likely you want to clear it in ft_r2_clean_call function - * */ -#define R2CALL(ftdmchan) ((ftdm_r2_call_t*)((ftdmchan)->call_data)) -typedef struct ftdm_r2_call_t { - openr2_chan_t *r2chan; - int accepted:1; - int answer_pending:1; - int disconnect_rcvd:1; - int protocol_error:1; - int localsuspend_on_alarm:1; - ftdm_size_t dnis_index; - ftdm_size_t ani_index; - char logname[255]; - char name[10]; - ftdm_timer_id_t protocol_error_recovery_timer; -} ftdm_r2_call_t; - -/* this is just used as place holder in the stack when configuring the span to avoid using bunch of locals */ -typedef struct ft_r2_conf_s { - /* openr2 types */ - openr2_variant_t variant; - openr2_calling_party_category_t category; - openr2_log_level_t loglevel; - - /* strings */ - char *logdir; - char *advanced_protocol_file; - - /* ints */ - int32_t max_ani; - int32_t max_dnis; - int32_t mfback_timeout; - int32_t metering_pulse_timeout; - ftdm_size_t mf_dump_size; - - /* booleans */ - int immediate_accept; - int skip_category; - int get_ani_first; - int call_files; - int double_answer; - int charge_calls; - int forced_release; - int allow_collect_calls; - int use_channel_native_mf_generation; -} ft_r2_conf_t; - -/* r2 configuration stored in span->signal_data */ -typedef struct ftdm_r2_data_s { - /* span flags */ - ftdm_r2_flag_t flags; - /* openr2 handle for the R2 variant context */ - openr2_context_t *r2context; - /* category to use when making calls */ - openr2_calling_party_category_t category; - /* whether to use OR2_CALL_WITH_CHARGE or OR2_CALL_NO_CHARGE when accepting a call */ - int charge_calls:1; - /* allow or reject collect calls */ - int allow_collect_calls:1; - /* whether to use forced release when hanging up */ - int forced_release:1; - /* whether accept the call when offered, or wait until the user decides to accept */ - int accept_on_offer:1; - /* Size of multi-frequency (or any media) dumps used during protocol errors */ - ftdm_size_t mf_dump_size; - /* max time spent in ms doing real work in a single loop */ - int32_t jobmax; - /* Total number of loops performed so far */ - uint64_t total_loops; - /* number of loops per 10ms increment from 0-9ms, 10-19ms .. 100ms and above */ - uint64_t loops[11]; - /* Total number of sleeps performed so far */ - uint64_t total_sleeps; - /* number of sleeps per 10ms increment from 0-9ms, 10-19ms .. 100ms and above */ - uint64_t sleeps[11]; - /* max time spent in ms sleeping in a single loop */ - int32_t sleepmax; - /* LWP */ - uint32_t monitor_thread_id; - /* Logging directory */ - char logdir[512]; - /* scheduling context */ - ftdm_sched_t *sched; -} ftdm_r2_data_t; - -/* one element per span will be stored in g_mod_data_hash global var to keep track of them - and destroy them on module unload */ -typedef struct ftdm_r2_span_pvt_s { - openr2_context_t *r2context; /* r2 context allocated for this span */ - ftdm_hash_t *r2calls; /* hash table of allocated call data per channel for this span */ - ftdm_sched_t *sched; /* schedule for the span */ -} ftdm_r2_span_pvt_t; - -/* span monitor thread */ -static void *ftdm_r2_run(ftdm_thread_t *me, void *obj); - -/* hash of all the private span allocations - we need to keep track of them to destroy them when unloading the module - since freetdm does not notify signaling modules when destroying a span - span -> ftdm_r2_mod_allocs_t */ -static ftdm_hash_t *g_mod_data_hash; - -/* IO interface for the command API */ -static ftdm_io_interface_t g_ftdm_r2_interface; - -static ftdm_status_t ftdm_r2_state_advance(ftdm_channel_t *ftdmchan); - -/* whether R2 call accept process is pending */ -#define IS_ACCEPTING_PENDING(ftdmchan) \ - ( (!ftdm_test_flag((ftdmchan), FTDM_CHANNEL_OUTBOUND)) && !R2CALL((ftdmchan))->accepted && \ - ((ftdmchan)->state == FTDM_CHANNEL_STATE_PROGRESS || \ - (ftdmchan)->state == FTDM_CHANNEL_STATE_PROGRESS_MEDIA || \ - (ftdmchan)->state == FTDM_CHANNEL_STATE_UP) ) - -/* functions not available on windows */ -#ifdef WIN32 -#include - -static __inline int gettimeofday(struct timeval *tp, void *nothing) -{ -#ifdef WITHOUT_MM_LIB - SYSTEMTIME st; - time_t tt; - struct tm tmtm; - /* mktime converts local to UTC */ - GetLocalTime (&st); - tmtm.tm_sec = st.wSecond; - tmtm.tm_min = st.wMinute; - tmtm.tm_hour = st.wHour; - tmtm.tm_mday = st.wDay; - tmtm.tm_mon = st.wMonth - 1; - tmtm.tm_year = st.wYear - 1900; tmtm.tm_isdst = -1; - tt = mktime (&tmtm); - tp->tv_sec = tt; - tp->tv_usec = st.wMilliseconds * 1000; -#else - /** - ** The earlier time calculations using GetLocalTime - ** had a time resolution of 10ms.The timeGetTime, part - ** of multimedia apis offer a better time resolution - ** of 1ms.Need to link against winmm.lib for this - **/ - unsigned long Ticks = 0; - unsigned long Sec =0; - unsigned long Usec = 0; - Ticks = timeGetTime(); - - Sec = Ticks/1000; - Usec = (Ticks - (Sec*1000))*1000; - tp->tv_sec = Sec; - tp->tv_usec = Usec; -#endif /* WITHOUT_MM_LIB */ - (void)nothing; - return 0; -} - -static char *strsep(char **stringp, const char *delim) -{ - char *start = *stringp; - char *ptr; - - if (!start) - return NULL; - - if (!*delim) - ptr = start + strlen(start); - else { - ptr = strpbrk(start, delim); - if (!ptr) { - *stringp = NULL; - return start; - } - } - - *ptr = '\0'; - *stringp = ptr + 1; - - return start; -} -#endif /* WIN32 */ - -static void ftdm_r2_set_chan_sig_status(ftdm_channel_t *ftdmchan, ftdm_signaling_status_t status) -{ - ftdm_sigmsg_t sig; - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Signalling link status changed to %s\n", ftdm_signaling_status2str(status)); - - memset(&sig, 0, sizeof(sig)); - sig.chan_id = ftdmchan->chan_id; - sig.span_id = ftdmchan->span_id; - sig.channel = ftdmchan; - sig.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED; - sig.ev_data.sigstatus.status = status; - if (ftdm_span_send_signal(ftdmchan->span, &sig) != FTDM_SUCCESS) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Failed to change channel status to %s\n", ftdm_signaling_status2str(status)); - } - return; -} - -static ftdm_call_cause_t ftdm_r2_cause_to_ftdm_cause(ftdm_channel_t *fchan, openr2_call_disconnect_cause_t cause) -{ - switch (cause) { - - case OR2_CAUSE_NORMAL_CLEARING: - return FTDM_CAUSE_NORMAL_CLEARING; - - case OR2_CAUSE_BUSY_NUMBER: - return FTDM_CAUSE_USER_BUSY; - - case OR2_CAUSE_NETWORK_CONGESTION: - return FTDM_CAUSE_SWITCH_CONGESTION; - - case OR2_CAUSE_UNALLOCATED_NUMBER: - return FTDM_CAUSE_NO_ROUTE_DESTINATION; - - case OR2_CAUSE_NUMBER_CHANGED: - return FTDM_CAUSE_NUMBER_CHANGED; - - case OR2_CAUSE_OUT_OF_ORDER: - return FTDM_CAUSE_NETWORK_OUT_OF_ORDER; - - case OR2_CAUSE_NO_ANSWER: - return FTDM_CAUSE_NO_ANSWER; - - case OR2_CAUSE_UNSPECIFIED: - return FTDM_CAUSE_NORMAL_UNSPECIFIED; - - case OR2_CAUSE_FORCED_RELEASE: - return FTDM_CAUSE_NORMAL_CLEARING; - - case OR2_CAUSE_GLARE: - return FTDM_CAUSE_REQUESTED_CHAN_UNAVAIL; - } - ftdm_log_chan(fchan, FTDM_LOG_NOTICE, "Mapping openr2 cause %d to unspecified\n", cause); - return FTDM_CAUSE_NORMAL_UNSPECIFIED; -} - -static openr2_call_disconnect_cause_t ftdm_r2_ftdm_cause_to_openr2_cause(ftdm_channel_t *fchan) -{ - switch (fchan->caller_data.hangup_cause) { - - case FTDM_CAUSE_NORMAL_CLEARING: - return OR2_CAUSE_NORMAL_CLEARING; - - case FTDM_CAUSE_USER_BUSY: - case FTDM_CAUSE_CALL_REJECTED: - return OR2_CAUSE_BUSY_NUMBER; - - case FTDM_CAUSE_SWITCH_CONGESTION: - return OR2_CAUSE_NETWORK_CONGESTION; - - case FTDM_CAUSE_NO_ROUTE_DESTINATION: - return OR2_CAUSE_UNALLOCATED_NUMBER; - - case FTDM_CAUSE_NUMBER_CHANGED: - return OR2_CAUSE_NUMBER_CHANGED; - - case FTDM_CAUSE_NETWORK_OUT_OF_ORDER: - case FTDM_CAUSE_SERVICE_UNAVAILABLE: - case FTDM_CAUSE_PROTOCOL_ERROR: - return OR2_CAUSE_OUT_OF_ORDER; - - case FTDM_CAUSE_NO_ANSWER: - case FTDM_CAUSE_NO_USER_RESPONSE: - return OR2_CAUSE_NO_ANSWER; - - case FTDM_CAUSE_NORMAL_UNSPECIFIED: - return OR2_CAUSE_UNSPECIFIED; - - case FTDM_CAUSE_REQUESTED_CHAN_UNAVAIL: - return OR2_CAUSE_GLARE; - - } - ftdm_log_chan(fchan, FTDM_LOG_NOTICE, "freetdm hangup cause %d mapped to openr2 cause %s\n", - fchan->caller_data.hangup_cause, openr2_proto_get_disconnect_string(OR2_CAUSE_UNSPECIFIED)); - return OR2_CAUSE_UNSPECIFIED; -} - -static void ft_r2_clean_call(ftdm_r2_call_t *call) -{ - openr2_chan_t *r2chan = call->r2chan; - - /* Do not memset call structure, that clears values we do not want to clear, - * like the log name set in on_call_log_created() */ - call->r2chan = r2chan; - call->accepted = 0; - call->answer_pending = 0; - call->disconnect_rcvd = 0; - call->protocol_error = 0; - call->dnis_index = 0; - call->ani_index = 0; - call->name[0] = 0; - call->protocol_error_recovery_timer = 0; -} - -static void ft_r2_accept_call(ftdm_channel_t *ftdmchan) -{ - openr2_chan_t *r2chan = R2CALL(ftdmchan)->r2chan; - ftdm_r2_data_t *r2data = ftdmchan->span->signal_data; - - // FIXME: we should check the return code from openr2_chan_accept_call and handle error condition - // hanging up the call with protocol error as the reason, this openr2 API will fail only when there something - // wrong at the I/O layer or the library itself - if (r2data->charge_calls) - openr2_chan_accept_call(r2chan, OR2_CALL_WITH_CHARGE); - else - openr2_chan_accept_call(r2chan, OR2_CALL_NO_CHARGE); -} - -static void ft_r2_answer_call(ftdm_channel_t *ftdmchan) -{ - openr2_chan_t *r2chan = R2CALL(ftdmchan)->r2chan; - // FIXME - // 1. check openr2_chan_answer_call return code - // 2. The openr2_chan_answer_call_with_mode should be used depending on user settings - // openr2_chan_answer_call_with_mode(r2chan, OR2_ANSWER_SIMPLE); - openr2_chan_answer_call(r2chan); - R2CALL(ftdmchan)->answer_pending = 0; -} - -static __inline__ ftdm_calling_party_category_t ftdm_openr2_cpc_to_r2_ftdm_cpc(openr2_calling_party_category_t cpc) -{ - switch (cpc) { - case OR2_CALLING_PARTY_CATEGORY_UNKNOWN: - return FTDM_CPC_UNKNOWN; - - case OR2_CALLING_PARTY_CATEGORY_NATIONAL_SUBSCRIBER: - return FTDM_CPC_ORDINARY; - - case OR2_CALLING_PARTY_CATEGORY_NATIONAL_PRIORITY_SUBSCRIBER: - return FTDM_CPC_PRIORITY; - - case OR2_CALLING_PARTY_CATEGORY_INTERNATIONAL_SUBSCRIBER: - return FTDM_CPC_UNKNOWN; - - case OR2_CALLING_PARTY_CATEGORY_INTERNATIONAL_PRIORITY_SUBSCRIBER: - return FTDM_CPC_UNKNOWN; - - case OR2_CALLING_PARTY_CATEGORY_TEST_EQUIPMENT: - return FTDM_CPC_TEST; - - case OR2_CALLING_PARTY_CATEGORY_PAY_PHONE: - return FTDM_CPC_PAYPHONE; - - case OR2_CALLING_PARTY_CATEGORY_COLLECT_CALL: - return FTDM_CPC_OPERATOR; - } - return FTDM_CPC_INVALID; -} - -static __inline openr2_calling_party_category_t ftdm_r2_ftdm_cpc_to_openr2_cpc(ftdm_calling_party_category_t cpc) -{ - switch (cpc) { - case FTDM_CPC_UNKNOWN: - return OR2_CALLING_PARTY_CATEGORY_UNKNOWN; - - case FTDM_CPC_OPERATOR: - return OR2_CALLING_PARTY_CATEGORY_COLLECT_CALL; - - case FTDM_CPC_ORDINARY: - return OR2_CALLING_PARTY_CATEGORY_NATIONAL_SUBSCRIBER; - - case FTDM_CPC_PRIORITY: - return OR2_CALLING_PARTY_CATEGORY_NATIONAL_PRIORITY_SUBSCRIBER; - - case FTDM_CPC_DATA: - return OR2_CALLING_PARTY_CATEGORY_UNKNOWN; - - case FTDM_CPC_TEST: - return OR2_CALLING_PARTY_CATEGORY_TEST_EQUIPMENT; - - case FTDM_CPC_PAYPHONE: - return OR2_CALLING_PARTY_CATEGORY_PAY_PHONE; - - case FTDM_CPC_OPERATOR_FRENCH: - case FTDM_CPC_OPERATOR_ENGLISH: - case FTDM_CPC_OPERATOR_GERMAN: - case FTDM_CPC_OPERATOR_RUSSIAN: - case FTDM_CPC_OPERATOR_SPANISH: - return OR2_CALLING_PARTY_CATEGORY_COLLECT_CALL; - - case FTDM_CPC_INVALID: - return OR2_CALLING_PARTY_CATEGORY_UNKNOWN; - } - return OR2_CALLING_PARTY_CATEGORY_UNKNOWN; -} - -/* this function must be called with the chan mutex held! */ -static FIO_CHANNEL_OUTGOING_CALL_FUNCTION(r2_outgoing_call) -{ - int ret; - ftdm_r2_data_t *r2data; - openr2_calling_party_category_t category = OR2_CALLING_PARTY_CATEGORY_NATIONAL_SUBSCRIBER; - - r2data = ftdmchan->span->signal_data; - - ft_r2_clean_call(ftdmchan->call_data); - - if (ftdmchan->caller_data.cpc == FTDM_CPC_INVALID || ftdmchan->caller_data.cpc == FTDM_CPC_UNKNOWN) { - category = r2data->category; - } else { - category = ftdm_r2_ftdm_cpc_to_openr2_cpc(ftdmchan->caller_data.cpc); - } - - /* start io dump */ - if (r2data->mf_dump_size) { - ftdm_channel_command(ftdmchan, FTDM_COMMAND_ENABLE_INPUT_DUMP, &r2data->mf_dump_size); - ftdm_channel_command(ftdmchan, FTDM_COMMAND_ENABLE_OUTPUT_DUMP, &r2data->mf_dump_size); - } - - ret = openr2_chan_make_call(R2CALL(ftdmchan)->r2chan, - ftdmchan->caller_data.cid_num.digits, - ftdmchan->caller_data.dnis.digits, - category, - ftdmchan->caller_data.pres == FTDM_PRES_ALLOWED ? 0 : 1); - - if (ret) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "Failed to make call in R2 channel, openr2_chan_make_call failed\n"); - return FTDM_FAIL; - } - - ftdm_channel_set_feature(ftdmchan, FTDM_CHANNEL_FEATURE_IO_STATS); - ftdm_channel_command(ftdmchan, FTDM_COMMAND_FLUSH_TX_BUFFERS, NULL); - ftdm_channel_command(ftdmchan, FTDM_COMMAND_FLUSH_RX_BUFFERS, NULL); - return FTDM_SUCCESS; -} - -static ftdm_status_t ftdm_r2_start(ftdm_span_t *span) -{ - ftdm_r2_data_t *r2_data = span->signal_data; - ftdm_set_flag(r2_data, FTDM_R2_SPAN_STARTED); - return ftdm_thread_create_detached(ftdm_r2_run, span); -} - -static ftdm_status_t ftdm_r2_stop(ftdm_span_t *span) -{ - ftdm_r2_data_t *r2_data = span->signal_data; - ftdm_clear_flag(r2_data, FTDM_R2_SPAN_STARTED); - while (ftdm_test_flag(r2_data, FTDM_R2_RUNNING)) { - ftdm_log(FTDM_LOG_DEBUG, "Waiting for R2 span %s\n", span->name); - ftdm_sleep(100); - } - return FTDM_SUCCESS; -} - -static FIO_CHANNEL_GET_SIG_STATUS_FUNCTION(ftdm_r2_get_channel_sig_status) -{ - openr2_chan_t *r2chan = R2CALL(ftdmchan)->r2chan; - openr2_cas_signal_t rxcas, txcas; - - /* get the current rx and tx cas bits */ - openr2_chan_get_cas(r2chan, &rxcas, &txcas); - - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_SIG_UP)) { - *status = FTDM_SIG_STATE_UP; - } else if (rxcas == OR2_CAS_BLOCK || txcas == OR2_CAS_BLOCK) { - *status = FTDM_SIG_STATE_SUSPENDED; - } else { - *status = FTDM_SIG_STATE_DOWN; - } - - return FTDM_SUCCESS; -} - -static FIO_CHANNEL_SET_SIG_STATUS_FUNCTION(ftdm_r2_set_channel_sig_status) -{ - openr2_chan_t *r2chan = R2CALL(ftdmchan)->r2chan; - openr2_cas_signal_t rxcas, txcas; - - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_IN_ALARM)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, - "Received request to change sig status of alarmed channel to %s", ftdm_signaling_status2str(status)); - - switch (status) { - case FTDM_SIG_STATE_SUSPENDED: - openr2_chan_set_blocked(r2chan); - /* Need to send sig status change to SUSPENDED once out of alarm */ - R2CALL(ftdmchan)->localsuspend_on_alarm = 1; - break; - case FTDM_SIG_STATE_UP: - openr2_chan_set_blocked(r2chan); - /* DO NOT send sig status change to SUSPENDED once out of alarm */ - R2CALL(ftdmchan)->localsuspend_on_alarm = 0; - break; - default: - ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Cannot set signaling status to unknown value '%d'\n", status); - return FTDM_FAIL; - } - return FTDM_SUCCESS; - } - - /* get the current rx and tx cas bits */ - openr2_chan_get_cas(r2chan, &rxcas, &txcas); - - /* if we're already in the state the user asks us to be, we have nothing to do */ - if (status == FTDM_SIG_STATE_SUSPENDED && txcas == OR2_CAS_BLOCK) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Channel signaling status already in BLOCK state\n"); - return FTDM_SUCCESS; - } - if (status == FTDM_SIG_STATE_UP && txcas == OR2_CAS_IDLE) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Channel signaling status already in IDLE state\n"); - return FTDM_SUCCESS; - } - - /* set the signaling as requested and send SIGEVENT_SIGSTATUS_CHANGED, if applicable. - * see docs/sigstatus.txt for details */ - switch(status) { - case FTDM_SIG_STATE_SUSPENDED: - openr2_chan_set_blocked(r2chan); - if (rxcas == OR2_CAS_IDLE) { - ftdm_r2_set_chan_sig_status(ftdmchan, status); - } - break; - case FTDM_SIG_STATE_UP: - openr2_chan_set_idle(r2chan); - if (rxcas == OR2_CAS_IDLE) { - ftdm_r2_set_chan_sig_status(ftdmchan, status); - } - break; - default: - ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Cannot set signaling status to unknown value '%d'\n", status); - return FTDM_FAIL; - } - return FTDM_SUCCESS; -} - -static FIO_SPAN_GET_SIG_STATUS_FUNCTION(ftdm_r2_get_span_sig_status) -{ - ftdm_iterator_t *citer = NULL; - ftdm_iterator_t *chaniter = ftdm_span_get_chan_iterator(span, NULL); - if (!chaniter) { - ftdm_log(FTDM_LOG_CRIT, "Failed to allocate channel iterator for span %s!\n", span->name); - return FTDM_FAIL; - } - /* if ALL channels are non-idle, report SUSPENDED. UP otherwise. */ - *status = FTDM_SIG_STATE_SUSPENDED; - for (citer = chaniter; citer; citer = ftdm_iterator_next(citer)) { - ftdm_channel_t *fchan = ftdm_iterator_current(citer); - ftdm_channel_lock(fchan); - if (ftdm_test_flag(fchan, FTDM_CHANNEL_IN_ALARM)) { - *status = FTDM_SIG_STATE_DOWN; - ftdm_channel_unlock(fchan); - break; - } - if (ftdm_test_flag(fchan, FTDM_CHANNEL_SIG_UP)) { - *status = FTDM_SIG_STATE_UP; - ftdm_channel_unlock(fchan); - break; - } - ftdm_channel_unlock(fchan); - } - ftdm_iterator_free(chaniter); - return FTDM_SUCCESS; -} - -static FIO_SPAN_SET_SIG_STATUS_FUNCTION(ftdm_r2_set_span_sig_status) -{ - ftdm_iterator_t *chaniter = NULL; - ftdm_iterator_t *citer = NULL; - - chaniter = ftdm_span_get_chan_iterator(span, NULL); - if (!chaniter) { - ftdm_log(FTDM_LOG_CRIT, "Failed to allocate channel iterator for span %s!\n", span->name); - return FTDM_FAIL; - } - /* iterate over all channels, setting them to the requested state */ - for (citer = chaniter; citer; citer = ftdm_iterator_next(citer)) { - ftdm_channel_t *fchan = ftdm_iterator_current(citer); - /* we set channel's state through ftdm_r2_set_channel_sig_status(), since it already takes - * care of notifying the user when appropriate */ - ftdm_channel_lock(fchan); - if ((ftdm_r2_set_channel_sig_status(fchan, status)) != FTDM_SUCCESS) { - ftdm_log_chan(fchan, FTDM_LOG_ERROR, "Failed to set signaling status to %s\n", ftdm_signaling_status2str(status)); - } - ftdm_channel_unlock(fchan); - } - ftdm_iterator_free(chaniter); - return FTDM_SUCCESS; -} - -/* always called from the monitor thread */ -static void ftdm_r2_on_call_init(openr2_chan_t *r2chan) -{ - ftdm_r2_call_t *r2call; - ftdm_channel_t *ftdmchan = openr2_chan_get_client_data(r2chan); - ftdm_r2_data_t *r2data = ftdmchan->span->signal_data; - - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_NOTICE, "Received request to start call\n"); - - if (ftdmchan->state == FTDM_CHANNEL_STATE_HANGUP) { - r2call = R2CALL(ftdmchan); - if (r2call->protocol_error) { - /* we had a protocol error and we were giving some recovery time, cancel the recovery timer now - * that is obvious that the other side recovered */ - ftdm_sched_cancel_timer(r2data->sched, r2call->protocol_error_recovery_timer); - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Cancelled protocol error recovery timer\n"); - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - ftdm_channel_advance_states(ftdmchan); - } - } - - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_INUSE)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Cannot start call when channel is in use (state = %s)\n", ftdm_channel_state2str(ftdmchan->state)); - return; - } - - if (ftdmchan->state != FTDM_CHANNEL_STATE_DOWN) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Cannot handle request to start call in state %s\n", ftdm_channel_state2str(ftdmchan->state)); - return; - } - - if (ftdm_channel_open_chan(ftdmchan) != FTDM_SUCCESS) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Failed to open channel during incoming call! [%s]\n", ftdmchan->last_error); - return; - } - - memset(ftdmchan->caller_data.dnis.digits, 0, sizeof(ftdmchan->caller_data.collected)); - memset(ftdmchan->caller_data.ani.digits, 0, sizeof(ftdmchan->caller_data.collected)); - - ft_r2_clean_call(ftdmchan->call_data); - r2call = R2CALL(ftdmchan); - - /* start io dump */ - if (r2data->mf_dump_size) { - ftdm_channel_command(ftdmchan, FTDM_COMMAND_ENABLE_INPUT_DUMP, &r2data->mf_dump_size); - ftdm_channel_command(ftdmchan, FTDM_COMMAND_ENABLE_OUTPUT_DUMP, &r2data->mf_dump_size); - } - - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_COLLECT); - ftdm_channel_set_feature(ftdmchan, FTDM_CHANNEL_FEATURE_IO_STATS); - ftdm_channel_command(ftdmchan, FTDM_COMMAND_FLUSH_TX_BUFFERS, NULL); - ftdm_channel_command(ftdmchan, FTDM_COMMAND_FLUSH_RX_BUFFERS, NULL); -} - -static void dump_mf(openr2_chan_t *r2chan); -/* only called for incoming calls when the ANI, DNIS etc is complete and the user has to decide either to accept or reject the call */ -static void ftdm_r2_on_call_offered(openr2_chan_t *r2chan, const char *ani, const char *dnis, - openr2_calling_party_category_t category, int ani_restricted) -{ - ftdm_channel_t *ftdmchan = openr2_chan_get_client_data(r2chan); - ftdm_r2_data_t *r2data = ftdmchan->span->signal_data; - - ftdm_log_chan(ftdmchan, FTDM_LOG_NOTICE, "Call offered with ANI = %s, DNIS = %s, Category = %s, ANI restricted = %s\n", - ani, dnis, openr2_proto_get_category_string(category), ani_restricted ? "Yes" : "No"); - - /* check if this is a collect call and if we should accept it */ - if (!r2data->allow_collect_calls && category == OR2_CALLING_PARTY_CATEGORY_COLLECT_CALL) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_NOTICE, "Rejecting collect call\n"); - openr2_chan_disconnect_call(r2chan, OR2_CAUSE_UNALLOCATED_NUMBER); - } else { - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RING); - } - ftdmchan->caller_data.cpc = ftdm_openr2_cpc_to_r2_ftdm_cpc(category); - ftdmchan->caller_data.pres = ani_restricted ? FTDM_PRES_RESTRICTED : FTDM_PRES_ALLOWED; -} - -/* - * Accepting a call in R2 is a lengthy process due to MF tones, - * when the user sends PROGRESS indication (implicitly moving the - * ftdm channel to PROGRESS state) the R2 processing loop - * does not clear FTDM_CHANNEL_STATE_CHANGE immediately as it does - * for all the other states, instead has to wait for on_call_accepted - * callback from openr2, which means the MF has ended and the progress - * indication is done, in order to clear the flag. However, if - * a protocol error or call disconnection (which is indicated using CAS bits) - * occurrs while accepting, we must clear the pending flag, this function - * takes care of that - * */ -static void clear_accept_pending(ftdm_channel_t *fchan) -{ - if (IS_ACCEPTING_PENDING(fchan)) { - ftdm_channel_complete_state(fchan); - } else if (ftdm_test_flag(fchan, FTDM_CHANNEL_STATE_CHANGE)) { - ftdm_log_chan(fchan, FTDM_LOG_CRIT, "State change flag set in state %s, last state = %s\n", - ftdm_channel_state2str(fchan->state), ftdm_channel_state2str(fchan->last_state)); - ftdm_channel_complete_state(fchan); - } -} - -static void dump_mf(openr2_chan_t *r2chan) -{ - char dfile[512]; - FILE *f = NULL; - int rc = 0; - ftdm_channel_t *ftdmchan = openr2_chan_get_client_data(r2chan); - ftdm_r2_data_t *r2data = ftdmchan->span->signal_data; - if (r2data->mf_dump_size) { - char *logname = R2CALL(ftdmchan)->logname; - - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Dumping IO output in prefix %s\n", !ftdm_strlen_zero(logname) - ? logname : r2data->logdir); - snprintf(dfile, sizeof(dfile), !ftdm_strlen_zero(logname) ? "%s.s%dc%d.input.alaw" : "%s/s%dc%d.input.alaw", - !ftdm_strlen_zero(logname) ? logname : r2data->logdir, ftdmchan->span_id, ftdmchan->chan_id); - f = fopen(dfile, "wb"); - if (f) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Dumping IO input in file %s\n", dfile); - ftdm_channel_command(ftdmchan, FTDM_COMMAND_DUMP_INPUT, f); - rc = fclose(f); - if (rc) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Failure closing IO input file %s: %s\n", dfile, strerror(errno)); - } - } else { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Could not dump IO input in file %s, error: %s", dfile, strerror(errno)); - } - - snprintf(dfile, sizeof(dfile), !ftdm_strlen_zero(logname) ? "%s.s%dc%d.output.alaw" : "%s/s%dc%d.output.alaw", - !ftdm_strlen_zero(logname) ? logname : r2data->logdir, ftdmchan->span_id, ftdmchan->chan_id); - f = fopen(dfile, "wb"); - if (f) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Dumping IO output in file %s\n", dfile); - ftdm_channel_command(ftdmchan, FTDM_COMMAND_DUMP_OUTPUT, f); - rc = fclose(f); - if (rc) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Failure closing IO output file %s: %s\n", dfile, strerror(errno)); - } - } else { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Could not dump IO output in file %s, error: %s", dfile, strerror(errno)); - } - } -} - -static void ftdm_r2_on_call_accepted(openr2_chan_t *r2chan, openr2_call_mode_t mode) -{ - ftdm_channel_t *ftdmchan = openr2_chan_get_client_data(r2chan); - ftdm_r2_data_t *r2data = ftdmchan->span->signal_data; - - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_NOTICE, "Call accepted\n"); - - clear_accept_pending(ftdmchan); - - /* at this point the MF signaling has ended and there is no point on keep reading */ - openr2_chan_disable_read(r2chan); - - /* at this point we are no longer responsible for reading and writing, - * we are not interested in the stats anymore */ - ftdm_channel_clear_feature(ftdmchan, FTDM_CHANNEL_FEATURE_IO_STATS); - - - R2CALL(ftdmchan)->accepted = 1; - - /* nothing went wrong during call setup, MF has ended, we can and must disable the MF dump */ - if (r2data->mf_dump_size) { - ftdm_channel_command(ftdmchan, FTDM_COMMAND_DISABLE_INPUT_DUMP, NULL); - ftdm_channel_command(ftdmchan, FTDM_COMMAND_DISABLE_OUTPUT_DUMP, NULL); - } - - if (OR2_DIR_BACKWARD == openr2_chan_get_direction(r2chan)) { - if (R2CALL(ftdmchan)->answer_pending) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Answer was pending, answering now.\n"); - ft_r2_answer_call(ftdmchan); - R2CALL(ftdmchan)->answer_pending = 0; - return; - } - } else { - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA); - } -} - -static void ftdm_r2_on_call_answered(openr2_chan_t *r2chan) -{ - ftdm_channel_t *ftdmchan = openr2_chan_get_client_data(r2chan); - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_NOTICE, "Call answered\n"); - /* notify the upper layer of progress in the outbound call */ - if (OR2_DIR_FORWARD == openr2_chan_get_direction(r2chan)) { - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_UP); - } -} - -/* may be called in the signaling or media thread depending on whether the hangup is product of MF or CAS signaling */ -static void ftdm_r2_on_call_disconnect(openr2_chan_t *r2chan, openr2_call_disconnect_cause_t cause) -{ - ftdm_channel_t *ftdmchan = openr2_chan_get_client_data(r2chan); - - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_NOTICE, "Call disconnected\n"); - - clear_accept_pending(ftdmchan); - - R2CALL(ftdmchan)->disconnect_rcvd = 1; - - if (ftdmchan->state == FTDM_CHANNEL_STATE_HANGUP) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Call had been disconnected already by the user\n"); - /* just ack the hangup to trigger the on_call_end callback and go down */ - openr2_chan_disconnect_call(r2chan, OR2_CAUSE_NORMAL_CLEARING); - return; - } - - ftdmchan->caller_data.hangup_cause = ftdm_r2_cause_to_ftdm_cause(ftdmchan, cause); - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); -} - -static void ftdm_r2_on_call_end(openr2_chan_t *r2chan) -{ - ftdm_channel_t *ftdmchan = openr2_chan_get_client_data(r2chan); - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_NOTICE, "Call finished\n"); - - /* the call is done as far as the stack is concerned, lets move to down here */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - - /* in some circumstances openr2 can call on_call_init right after this, so let's advance the state right here */ - ftdm_channel_advance_states(ftdmchan); -} - -static void ftdm_r2_on_call_read(openr2_chan_t *r2chan, const unsigned char *buf, int buflen) -{ -#if 0 - ftdm_log(FTDM_LOG_NOTICE, "Call read data on chan %d\n", openr2_chan_get_number(r2chan)); -#endif -} - -static void ftdm_r2_on_hardware_alarm(openr2_chan_t *r2chan, int alarm) -{ - ftdm_channel_t *fchan = openr2_chan_get_client_data(r2chan); - - ftdm_log_chan(fchan, FTDM_LOG_DEBUG, "Alarm notification %d when in state %s (sigstatus = %d)\n", - alarm, ftdm_channel_state2str(fchan->state), ftdm_test_flag(fchan, FTDM_CHANNEL_SIG_UP) ? 1 : 0); - - if (alarm) { - R2CALL(fchan)->localsuspend_on_alarm = ftdm_test_flag(fchan, FTDM_CHANNEL_SUSPENDED) ? 1 : 0; - if (ftdm_test_flag(fchan, FTDM_CHANNEL_SIG_UP) || ftdm_test_flag(fchan, FTDM_CHANNEL_SUSPENDED)) { - ftdm_r2_set_chan_sig_status(fchan, FTDM_SIG_STATE_DOWN); - } - } -} - -static void ftdm_r2_on_os_error(openr2_chan_t *r2chan, int errorcode) -{ - ftdm_channel_t *ftdmchan = openr2_chan_get_client_data(r2chan); - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "OS error: %s\n", strerror(errorcode)); -} - -static void ftdm_r2_recover_from_protocol_error(void *data) -{ - openr2_chan_t *r2chan = data; - ftdm_channel_t *ftdmchan = openr2_chan_get_client_data(r2chan); - ftdm_channel_lock(ftdmchan); - if (ftdmchan->state != FTDM_CHANNEL_STATE_HANGUP) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Recovering from protocol error but state is %s!\n", ftdm_channel_state2str(ftdmchan->state)); - goto done; - } - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - ftdm_channel_advance_states(ftdmchan); -done: - ftdm_channel_unlock(ftdmchan); -} - -static void ftdm_r2_on_protocol_error(openr2_chan_t *r2chan, openr2_protocol_error_t reason) -{ - ftdm_channel_t *ftdmchan = openr2_chan_get_client_data(r2chan); - - if (ftdmchan->state == FTDM_CHANNEL_STATE_DOWN) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "Got protocol error when we're already down!\n"); - return; - } - - dump_mf(r2chan); - - clear_accept_pending(ftdmchan); - - R2CALL(ftdmchan)->disconnect_rcvd = 1; - R2CALL(ftdmchan)->protocol_error = 1; - - if (ftdmchan->state == FTDM_CHANNEL_STATE_HANGUP) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "The user already hung up, finishing call in protocol error\n"); - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - return; - } - - ftdmchan->caller_data.hangup_cause = FTDM_CAUSE_PROTOCOL_ERROR; - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); -} - -static void ftdm_r2_on_line_blocked(openr2_chan_t *r2chan) -{ - ftdm_channel_t *ftdmchan = openr2_chan_get_client_data(r2chan); - ftdm_log_chan(ftdmchan, FTDM_LOG_NOTICE, "Far end blocked in state %s\n", ftdm_channel_state2str(ftdmchan->state)); - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_SIG_UP) - || !ftdm_test_flag(ftdmchan, FTDM_CHANNEL_SUSPENDED)) { - ftdm_r2_set_chan_sig_status(ftdmchan, FTDM_SIG_STATE_SUSPENDED); - } -} - -static void ftdm_r2_on_line_idle(openr2_chan_t *r2chan) -{ - openr2_cas_signal_t rxcas, txcas; - ftdm_channel_t *ftdmchan = openr2_chan_get_client_data(r2chan); - - /* get the current rx and tx cas bits */ - openr2_chan_get_cas(r2chan, &rxcas, &txcas); - ftdm_log_chan(ftdmchan, FTDM_LOG_NOTICE, "Far end unblocked in state %s\n", ftdm_channel_state2str(ftdmchan->state)); - if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_SIG_UP) - && txcas == OR2_CAS_IDLE) { - /* if txcas is not idle, it means we're still blocked as far as the user is concerned, do not send SIGEVENT UP, - * it will be done when the user set the line to IDLE (if the remote is still also IDLE) */ - ftdm_r2_set_chan_sig_status(ftdmchan, FTDM_SIG_STATE_UP); - } else if (txcas == OR2_CAS_BLOCK && R2CALL(ftdmchan)->localsuspend_on_alarm) { - /* the user requested to block, we do not notify about state up until the user set the bits to IDLE, however - * if we're just getting back from alarmed condition, we notify about suspended again */ - ftdm_r2_set_chan_sig_status(ftdmchan, FTDM_SIG_STATE_SUSPENDED); - } - R2CALL(ftdmchan)->localsuspend_on_alarm = 0; -} - -static void ftdm_r2_write_log(openr2_log_level_t level, const char *file, const char *function, int line, const char *message) -{ - switch (level) { - case OR2_LOG_NOTICE: - ftdm_log(file, function, line, FTDM_LOG_LEVEL_NOTICE, "%s", message); - break; - case OR2_LOG_WARNING: - ftdm_log(file, function, line, FTDM_LOG_LEVEL_WARNING, "%s", message); - break; - case OR2_LOG_ERROR: - ftdm_log(file, function, line, FTDM_LOG_LEVEL_ERROR, "%s", message); - break; - case OR2_LOG_STACK_TRACE: - case OR2_LOG_MF_TRACE: - case OR2_LOG_CAS_TRACE: - case OR2_LOG_DEBUG: - case OR2_LOG_EX_DEBUG: - ftdm_log(file, function, line, FTDM_LOG_LEVEL_DEBUG, "%s", message); - break; - default: - ftdm_log(FTDM_LOG_WARNING, "We should handle logging level %d here.\n", level); - ftdm_log(file, function, line, FTDM_LOG_LEVEL_DEBUG, "%s", message); - break; - } -} - -static void ftdm_r2_on_context_log(openr2_context_t *r2context, const char *file, const char *function, unsigned int line, - openr2_log_level_t level, const char *fmt, va_list ap) -{ -#define CONTEXT_TAG "Context - " - char logmsg[256]; - char completemsg[sizeof(logmsg) + sizeof(CONTEXT_TAG) - 1]; - vsnprintf(logmsg, sizeof(logmsg), fmt, ap); - snprintf(completemsg, sizeof(completemsg), CONTEXT_TAG "%s", logmsg); - ftdm_r2_write_log(level, file, function, line, completemsg); -#undef CONTEXT_TAG -} - -static void ftdm_r2_on_chan_log(openr2_chan_t *r2chan, const char *file, const char *function, unsigned int line, - openr2_log_level_t level, const char *fmt, va_list ap) -{ - ftdm_channel_t *ftdmchan = openr2_chan_get_client_data(r2chan); - char logmsg[1024]; - char completemsg[sizeof(logmsg)]; - vsnprintf(logmsg, sizeof(logmsg), fmt, ap); - snprintf(completemsg, sizeof(completemsg), "[s%dc%d] [%d:%d] [%s] %s", - ftdmchan->span_id, ftdmchan->chan_id, ftdmchan->physical_span_id, ftdmchan->physical_chan_id, - ftdm_channel_state2str(ftdmchan->state), logmsg); - ftdm_r2_write_log(level, file, function, line, completemsg); -} - -static int ftdm_r2_on_dnis_digit_received(openr2_chan_t *r2chan, char digit) -{ - ftdm_sigmsg_t sigev; - ftdm_channel_t *ftdmchan = openr2_chan_get_client_data(r2chan); - ftdm_size_t collected_len = R2CALL(ftdmchan)->dnis_index; - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "DNIS digit %c received\n", digit); - - /* save the digit we just received */ - ftdmchan->caller_data.dnis.digits[collected_len] = digit; - collected_len++; - ftdmchan->caller_data.dnis.digits[collected_len] = '\0'; - R2CALL(ftdmchan)->dnis_index = collected_len; - - /* notify the user about the new digit and check if we should stop requesting more DNIS */ - memset(&sigev, 0, sizeof(sigev)); - sigev.chan_id = ftdmchan->chan_id; - sigev.span_id = ftdmchan->span_id; - sigev.channel = ftdmchan; - sigev.event_id = FTDM_SIGEVENT_COLLECTED_DIGIT; - if (ftdm_span_send_signal(ftdmchan->span, &sigev) == FTDM_BREAK) { - ftdm_log_chan(ftdmchan, FTDM_LOG_NOTICE, "Requested to stop getting DNIS. Current DNIS = %s\n", ftdmchan->caller_data.dnis.digits); - return OR2_STOP_DNIS_REQUEST; - } - - /* the only other reason to stop requesting DNIS is that there is no more room to save it */ - if (collected_len == (sizeof(ftdmchan->caller_data.dnis.digits) - 1)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "No more room for DNIS. Current DNIS = %s\n", ftdmchan->caller_data.dnis.digits); - return OR2_STOP_DNIS_REQUEST; - } - - return OR2_CONTINUE_DNIS_REQUEST; -} - -static void ftdm_r2_on_ani_digit_received(openr2_chan_t *r2chan, char digit) -{ - ftdm_channel_t *ftdmchan = openr2_chan_get_client_data(r2chan); - ftdm_size_t collected_len = R2CALL(ftdmchan)->ani_index; - - /* check if we should drop ANI */ - if (collected_len == (sizeof(ftdmchan->caller_data.ani.digits) - 1)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "No more room for ANI, digit dropped: %c\n", digit); - return; - } - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "ANI digit %c received\n", digit); - - /* save the digit we just received */ - ftdmchan->caller_data.ani.digits[collected_len] = digit; - collected_len++; - ftdmchan->caller_data.ani.digits[collected_len] = '\0'; - R2CALL(ftdmchan)->ani_index = collected_len; -} - -static void ftdm_r2_on_billing_pulse(openr2_chan_t *r2chan) {} - -static void ftdm_r2_on_call_log_created(openr2_chan_t *r2chan, const char *logname) -{ - ftdm_channel_t *ftdmchan = openr2_chan_get_client_data(r2chan); - ftdm_r2_call_t *r2call = R2CALL(ftdmchan); - /* this is used when dumping I/O for debugging */ - snprintf(r2call->logname, sizeof(r2call->logname), "%s", logname); -} - -static void ftdm_r2_on_call_proceed(openr2_chan_t *r2chan) -{ - ftdm_sigmsg_t sigev; - ftdm_channel_t *fchan = openr2_chan_get_client_data(r2chan); - memset(&sigev, 0, sizeof(sigev)); - sigev.event_id = FTDM_SIGEVENT_PROCEED; - sigev.channel = fchan; - ftdm_span_send_signal(fchan->span, &sigev); -} - -static openr2_event_interface_t ftdm_r2_event_iface = { - /* .on_call_init */ ftdm_r2_on_call_init, - /* .on_call_proceed */ ftdm_r2_on_call_proceed, - /* .on_call_offered */ ftdm_r2_on_call_offered, - /* .on_call_accepted */ ftdm_r2_on_call_accepted, - /* .on_call_answered */ ftdm_r2_on_call_answered, - /* .on_call_disconnect */ ftdm_r2_on_call_disconnect, - /* .on_call_end */ ftdm_r2_on_call_end, - /* .on_call_read */ ftdm_r2_on_call_read, - /* .on_hardware_alarm */ ftdm_r2_on_hardware_alarm, - /* .on_os_error */ ftdm_r2_on_os_error, - /* .on_protocol_error */ ftdm_r2_on_protocol_error, - /* .on_line_blocked */ ftdm_r2_on_line_blocked, - /* .on_line_idle */ ftdm_r2_on_line_idle, - - /* cast seems to be needed to get rid of the annoying warning regarding format attribute */ - /* .on_context_log */ (openr2_handle_context_logging_func)ftdm_r2_on_context_log, - /* .on_dnis_digit_received */ ftdm_r2_on_dnis_digit_received, - /* .on_ani_digit_received */ ftdm_r2_on_ani_digit_received, - - /* so far we do nothing with billing pulses */ - /* .on_billing_pulse_received */ ftdm_r2_on_billing_pulse, - /* .on_call_log_created */ ftdm_r2_on_call_log_created, -}; - -static int ftdm_r2_io_set_cas(openr2_chan_t *r2chan, int cas) -{ - ftdm_channel_t *ftdm_chan = openr2_chan_get_fd(r2chan); - ftdm_status_t status = ftdm_channel_command(ftdm_chan, FTDM_COMMAND_SET_CAS_BITS, &cas); - if (FTDM_FAIL == status) { - return -1; - } - return 0; -} - -static int ftdm_r2_io_get_cas(openr2_chan_t *r2chan, int *cas) -{ - ftdm_channel_t *ftdm_chan = openr2_chan_get_fd(r2chan); - ftdm_status_t status = ftdm_channel_command(ftdm_chan, FTDM_COMMAND_GET_CAS_BITS, cas); - if (FTDM_FAIL == status) { - return -1; - } - return 0; -} - -static int ftdm_r2_io_flush_write_buffers(openr2_chan_t *r2chan) -{ - ftdm_channel_t *ftdm_chan = openr2_chan_get_fd(r2chan); - ftdm_status_t status = ftdm_channel_command(ftdm_chan, FTDM_COMMAND_FLUSH_TX_BUFFERS, NULL); - if (FTDM_FAIL == status) { - return -1; - } - return 0; -} - -static int ftdm_r2_io_write(openr2_chan_t *r2chan, const void *buf, int size) -{ - ftdm_channel_t *ftdm_chan = openr2_chan_get_fd(r2chan); - ftdm_size_t outsize = size; - ftdm_status_t status = ftdm_channel_write(ftdm_chan, (void *)buf, size, &outsize); - if (FTDM_FAIL == status) { - return -1; - } - return (int)outsize; -} - -static int ftdm_r2_io_read(openr2_chan_t *r2chan, const void *buf, int size) -{ - ftdm_channel_t *ftdm_chan = openr2_chan_get_fd(r2chan); - ftdm_size_t outsize = size; - ftdm_status_t status = ftdm_channel_read(ftdm_chan, (void *)buf, &outsize); - if (FTDM_FAIL == status) { - return -1; - } - return (int)outsize; -} - -static int ftdm_r2_io_wait(openr2_chan_t *r2chan, int *flags, int block) -{ - ftdm_status_t status; - int32_t timeout; - ftdm_wait_flag_t ftdmflags = 0; - - ftdm_channel_t *fchan = openr2_chan_get_fd(r2chan); - timeout = block ? -1 : 0; - - if (*flags & OR2_IO_READ) { - ftdmflags |= FTDM_READ; - } - if (*flags & OR2_IO_WRITE) { - ftdmflags |= FTDM_WRITE; - } - if (*flags & OR2_IO_OOB_EVENT) { - ftdmflags |= FTDM_EVENTS; - } - - status = ftdm_channel_wait(fchan, &ftdmflags, timeout); - - if (FTDM_SUCCESS != status && FTDM_TIMEOUT != status) { - ftdm_log_chan_msg(fchan, FTDM_LOG_ERROR, "Failed to wait for events on channel\n"); - return -1; - } - - *flags = 0; - if (ftdmflags & FTDM_READ) { - *flags |= OR2_IO_READ; - } - if (ftdmflags & FTDM_WRITE) { - *flags |= OR2_IO_WRITE; - } - if (ftdmflags & FTDM_EVENTS) { - *flags |= OR2_IO_OOB_EVENT; - } - - return 0; -} - -/* The following openr2 hooks never get called, read on for reasoning ... */ -/* since freetdm takes care of opening the file descriptor and using openr2_chan_new_from_fd, openr2 should never call this hook */ -static openr2_io_fd_t ftdm_r2_io_open(openr2_context_t *r2context, int channo) -{ - ftdm_log(FTDM_LOG_ERROR, "I should not be called (I/O open)!!\n"); - return NULL; -} - -/* since freetdm takes care of closing the file descriptor and uses openr2_chan_new_from_fd, openr2 should never call this hook */ -static int ftdm_r2_io_close(openr2_chan_t *r2chan) -{ - ftdm_channel_t *fchan = openr2_chan_get_client_data(r2chan); - ftdm_log_chan_msg(fchan, FTDM_LOG_ERROR, "I should not be called (I/O close)!!\n"); - return 0; -} - -/* since freetdm takes care of opening the file descriptor and using openr2_chan_new_from_fd, openr2 should never call this hook */ -static int ftdm_r2_io_setup(openr2_chan_t *r2chan) -{ - ftdm_channel_t *fchan = openr2_chan_get_client_data(r2chan); - ftdm_log_chan_msg(fchan, FTDM_LOG_ERROR, "I should not be called (I/O Setup)!!\n"); - return 0; -} - -static int ftdm_r2_io_get_oob_event(openr2_chan_t *r2chan, openr2_oob_event_t *event) -{ - ftdm_status_t status; - ftdm_event_t *fevent = NULL; - ftdm_channel_t *ftdmchan = openr2_chan_get_fd(r2chan); - - *event = OR2_OOB_EVENT_NONE; - - status = ftdm_channel_read_event(ftdmchan, &fevent); - - if (status != FTDM_SUCCESS) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "failed to retrieve freetdm event!\n"); - return -1; - } - - if (fevent->e_type != FTDM_EVENT_OOB) { - return 0; - } - - switch (fevent->enum_id) { - case FTDM_OOB_CAS_BITS_CHANGE: - { - *event = OR2_OOB_EVENT_CAS_CHANGE; - } - break; - case FTDM_OOB_ALARM_TRAP: - { - *event = OR2_OOB_EVENT_ALARM_ON; - } - break; - case FTDM_OOB_ALARM_CLEAR: - { - *event = OR2_OOB_EVENT_ALARM_OFF; - } - break; - } - return 0; -} - -static int ftdm_r2_io_get_alarm_state(openr2_chan_t *r2chan, int *alarm) -{ - ftdm_channel_t *fchan = openr2_chan_get_fd(r2chan); - ftdm_assert_return(alarm, -1, "Alarm pointer is null\n"); - *alarm = ftdm_test_flag(fchan, FTDM_CHANNEL_IN_ALARM) ? 1 : 0; - return 0; -} - -static openr2_io_interface_t ftdm_r2_io_iface = { - /* .open */ ftdm_r2_io_open, /* never called */ - /* .close */ ftdm_r2_io_close, /* never called */ - /* .set_cas */ ftdm_r2_io_set_cas, - /* .get_cas */ ftdm_r2_io_get_cas, - /* .flush_write_buffers */ ftdm_r2_io_flush_write_buffers, - /* .write */ ftdm_r2_io_write, - /* .read */ ftdm_r2_io_read, - /* .setup */ ftdm_r2_io_setup, /* never called */ - /* .wait */ ftdm_r2_io_wait, - /* .get_oob_event */ ftdm_r2_io_get_oob_event, - /* .get_alarm_state */ ftdm_r2_io_get_alarm_state -}; - -/* resolve a loglevel string, such as "debug,notice,warning", to an openr2 log level integer */ -static openr2_log_level_t ftdm_r2_loglevel_from_string(const char *level) -{ - openr2_log_level_t tmplevel; - openr2_log_level_t newlevel = 0; - char *clevel = NULL; - char *logval = NULL; - - logval = ftdm_malloc(strlen(level)+1); /* alloca man page scared me, so better to use good ol' malloc */ - if (!logval) { - ftdm_log(FTDM_LOG_WARNING, "Ignoring R2 logging parameter: '%s', failed to alloc memory\n", level); - return newlevel; - } - strcpy(logval, level); - while (logval) { - clevel = strsep(&logval, ","); - if (-1 == (tmplevel = openr2_log_get_level(clevel))) { - ftdm_log(FTDM_LOG_WARNING, "Ignoring invalid R2 logging level: '%s'\n", clevel); - continue; - } - newlevel |= tmplevel; - } - ftdm_safe_free(logval); - return newlevel; -} - -static ftdm_state_map_t r2_state_map = { - { - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_ANY, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_RESET, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_RESET, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_COLLECT, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_COLLECT, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_RING, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_RING, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END}, - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_END}, - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END}, - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END}, - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_END}, - }, - - /* Outbound states */ - - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_ANY, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_RESET, FTDM_CHANNEL_STATE_END} - }, - - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_RESET, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END} - }, - - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_DIALING, FTDM_CHANNEL_STATE_END} - }, - - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_DIALING, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_END} - }, - - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END} - }, - - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_END} - }, - - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END} - }, - - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_END} - }, - } -}; - -static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_r2_configure_span_signaling) -{ - unsigned int i = 0; - int conf_failure = 0; - int intval = 0; - char schedname[255]; - const char *var = NULL, *val = NULL; - const char *log_level = "notice,warning,error"; /* default loglevel, if none is read from conf */ - ftdm_r2_data_t *r2data = NULL; - ftdm_r2_span_pvt_t *spanpvt = NULL; - ftdm_r2_call_t *r2call = NULL; - openr2_chan_t *r2chan = NULL; - unsigned paramindex = 0; - - ft_r2_conf_t r2conf = - { - /* .variant */ OR2_VAR_ITU, - /* .category */ OR2_CALLING_PARTY_CATEGORY_NATIONAL_SUBSCRIBER, - /* .loglevel */ OR2_LOG_ERROR | OR2_LOG_WARNING, -#ifdef WIN32 - /* .logdir */ (char *)"c:\\", -#else - /* .logdir */ (char *)"/tmp", -#endif - /* .advanced_protocol_file */ NULL, - /* .max_ani */ 10, - /* .max_dnis */ 4, - /* .mfback_timeout */ -1, - /* .metering_pulse_timeout */ -1, - /* .mf_dump_size */ 0, - /* .immediate_accept */ -1, - /* .skip_category */ -1, - /* .get_ani_first */ -1, - /* .call_files */ 0, - /* .double_answer */ -1, - /* .charge_calls */ -1, - /* .forced_release */ -1, - /* .allow_collect_calls */ -1, - /* .use_channel_native_mf_generation */ 0 - }; - - ftdm_assert_return(sig_cb != NULL, FTDM_FAIL, "No signaling cb provided\n"); - - if (span->signal_type) { - snprintf(span->last_error, sizeof(span->last_error), "Span is already configured for signalling."); - return FTDM_FAIL; - } - - for (; ftdm_parameters[paramindex].var; paramindex++) { - var = ftdm_parameters[paramindex].var; - val = ftdm_parameters[paramindex].val; - ftdm_log(FTDM_LOG_DEBUG, "Reading R2 parameter %s for span %d\n", var, span->span_id); - if (!strcasecmp(var, "variant")) { - if (!val) { - break; - } - if (ftdm_strlen_zero_buf(val)) { - ftdm_log(FTDM_LOG_NOTICE, "Ignoring empty R2 variant parameter\n"); - continue; - } - r2conf.variant = openr2_proto_get_variant(val); - if (r2conf.variant == OR2_VAR_UNKNOWN) { - ftdm_log(FTDM_LOG_ERROR, "Unknown R2 variant %s\n", val); - conf_failure = 1; - break; - } - ftdm_log(FTDM_LOG_DEBUG, "Configuring R2 span %d for variant %s\n", span->span_id, val); - } else if (!strcasecmp(var, "category")) { - if (!val) { - break; - } - if (ftdm_strlen_zero_buf(val)) { - ftdm_log(FTDM_LOG_NOTICE, "Ignoring empty R2 category parameter\n"); - continue; - } - r2conf.category = openr2_proto_get_category(val); - if (r2conf.category == OR2_CALLING_PARTY_CATEGORY_UNKNOWN) { - ftdm_log(FTDM_LOG_ERROR, "Unknown R2 caller category %s\n", val); - conf_failure = 1; - break; - } - ftdm_log(FTDM_LOG_DEBUG, "Configuring R2 span %d with default category %s\n", span->span_id, val); - } else if (!strcasecmp(var, "logdir")) { - if (!val) { - break; - } - if (ftdm_strlen_zero_buf(val)) { - ftdm_log(FTDM_LOG_NOTICE, "Ignoring empty R2 logdir parameter\n"); - continue; - } - r2conf.logdir = (char *)val; - ftdm_log(FTDM_LOG_DEBUG, "Configuring R2 span %d with logdir %s\n", span->span_id, val); - } else if (!strcasecmp(var, "logging")) { - if (!val) { - break; - } - if (ftdm_strlen_zero_buf(val)) { - ftdm_log(FTDM_LOG_NOTICE, "Ignoring empty R2 logging parameter\n"); - continue; - } - log_level = val; - ftdm_log(FTDM_LOG_DEBUG, "Configuring R2 span %s with loglevel %s\n", span->name, val); - } else if (!strcasecmp(var, "advanced_protocol_file")) { - if (!val) { - break; - } - if (ftdm_strlen_zero_buf(val)) { - ftdm_log(FTDM_LOG_NOTICE, "Ignoring empty R2 advanced_protocol_file parameter\n"); - continue; - } - r2conf.advanced_protocol_file = (char *)val; - ftdm_log(FTDM_LOG_DEBUG, "Configuring R2 span %s with advanced protocol file %s\n", span->name, val); - } else if (!strcasecmp(var, "mf_dump_size")) { - intval = atoi(val); - if (intval < 0) { - r2conf.mf_dump_size = FTDM_IO_DUMP_DEFAULT_BUFF_SIZE; - ftdm_log(FTDM_LOG_DEBUG, "Configuring R2 span %s with default mf_dump_size = %"FTDM_SIZE_FMT" bytes\n", span->name, r2conf.mf_dump_size); - } else { - r2conf.mf_dump_size = intval; - ftdm_log(FTDM_LOG_DEBUG, "Configuring R2 span %s with mf_dump_size = %"FTDM_SIZE_FMT" bytes\n", span->name, r2conf.mf_dump_size); - } - } else if (!strcasecmp(var, "allow_collect_calls")) { - r2conf.allow_collect_calls = ftdm_true(val); - ftdm_log(FTDM_LOG_DEBUG, "Configuring R2 span %s with allow collect calls max ani = %d\n", span->name, r2conf.allow_collect_calls); - } else if (!strcasecmp(var, "double_answer")) { - r2conf.double_answer = ftdm_true(val); - ftdm_log(FTDM_LOG_DEBUG, "Configuring R2 span %s with double answer = %d\n", span->name, r2conf.double_answer); - } else if (!strcasecmp(var, "immediate_accept")) { - r2conf.immediate_accept = ftdm_true(val); - ftdm_log(FTDM_LOG_DEBUG, "Configuring R2 span %s with immediate accept = %d\n", span->name, r2conf.immediate_accept); - } else if (!strcasecmp(var, "skip_category")) { - r2conf.skip_category = ftdm_true(val); - ftdm_log(FTDM_LOG_DEBUG, "Configuring R2 span %s with skip category = %d\n", span->name, r2conf.skip_category); - } else if (!strcasecmp(var, "forced_release")) { - r2conf.forced_release = ftdm_true(val); - ftdm_log(FTDM_LOG_DEBUG, "Configuring R2 span %s with forced release = %d\n", span->name, r2conf.forced_release); - } else if (!strcasecmp(var, "charge_calls")) { - r2conf.charge_calls = ftdm_true(val); - ftdm_log(FTDM_LOG_DEBUG, "Configuring R2 span %s with charge calls = %d\n", span->name, r2conf.charge_calls); - } else if (!strcasecmp(var, "get_ani_first")) { - r2conf.get_ani_first = ftdm_true(val); - ftdm_log(FTDM_LOG_DEBUG, "Configuring R2 span %s with get ani first = %d\n", span->name, r2conf.get_ani_first); - } else if (!strcasecmp(var, "call_files")) { - r2conf.call_files = ftdm_true(val); - ftdm_log(FTDM_LOG_DEBUG, "Configuring R2 span %s with call files = %d\n", span->name, r2conf.call_files); - } else if (!strcasecmp(var, "mfback_timeout")) { - r2conf.mfback_timeout = atoi(val); - ftdm_log(FTDM_LOG_DEBUG, "Configuring R2 span %s with MF backward timeout = %dms\n", span->name, r2conf.mfback_timeout); - } else if (!strcasecmp(var, "metering_pulse_timeout")) { - r2conf.metering_pulse_timeout = atoi(val); - ftdm_log(FTDM_LOG_DEBUG, "Configuring R2 span %s with metering pulse timeout = %dms\n", span->name, r2conf.metering_pulse_timeout); - } else if (!strcasecmp(var, "max_ani")) { - r2conf.max_ani = atoi(val); - ftdm_log(FTDM_LOG_DEBUG, "Configuring R2 span %s with max ani = %d\n", span->name, r2conf.max_ani); - } else if (!strcasecmp(var, "max_dnis")) { - r2conf.max_dnis = atoi(val); - ftdm_log(FTDM_LOG_DEBUG, "Configuring R2 span %s with max dnis = %d\n", span->name, r2conf.max_dnis); - } else if (!strcasecmp(var, "use_channel_native_mf_generation")) { - r2conf.use_channel_native_mf_generation = ftdm_true(val); - ftdm_log(FTDM_LOG_DEBUG, "Configuring R2 span %s with \"use native channel MF generation\" = %d\n", span->name, r2conf.use_channel_native_mf_generation); - } else { - snprintf(span->last_error, sizeof(span->last_error), "Unknown R2 parameter [%s]", var); - return FTDM_FAIL; - } - } - - if (conf_failure) { - snprintf(span->last_error, sizeof(span->last_error), "R2 configuration error"); - return FTDM_FAIL; - } - - /* set span log level */ - r2conf.loglevel = ftdm_r2_loglevel_from_string(log_level); - ftdm_log(FTDM_LOG_DEBUG, "Configuring R2 span %d with loglevel %s\n", span->span_id, log_level); - - r2data = ftdm_malloc(sizeof(*r2data)); - if (!r2data) { - snprintf(span->last_error, sizeof(span->last_error), "Failed to allocate R2 data."); - return FTDM_FAIL; - } - memset(r2data, 0, sizeof(*r2data)); - - spanpvt = ftdm_malloc(sizeof(*spanpvt)); - if (!spanpvt) { - snprintf(span->last_error, sizeof(span->last_error), "Failed to allocate private span data container."); - goto fail; - } - memset(spanpvt, 0, sizeof(*spanpvt)); - - r2data->r2context = openr2_context_new(r2conf.variant, &ftdm_r2_event_iface, r2conf.max_ani, r2conf.max_dnis); - if (!r2data->r2context) { - snprintf(span->last_error, sizeof(span->last_error), "Cannot create openr2 context for span."); - goto fail; - } - openr2_context_set_io_type(r2data->r2context, OR2_IO_CUSTOM, &ftdm_r2_io_iface); - openr2_context_set_log_level(r2data->r2context, r2conf.loglevel); - openr2_context_set_ani_first(r2data->r2context, r2conf.get_ani_first); - openr2_context_set_skip_category_request(r2data->r2context, r2conf.skip_category); - openr2_context_set_mf_back_timeout(r2data->r2context, r2conf.mfback_timeout); - openr2_context_set_metering_pulse_timeout(r2data->r2context, r2conf.metering_pulse_timeout); - openr2_context_set_double_answer(r2data->r2context, r2conf.double_answer); - openr2_context_set_immediate_accept(r2data->r2context, r2conf.immediate_accept); - - ftdm_log(FTDM_LOG_DEBUG, "Setting span %s logdir to %s\n", span->name, r2conf.logdir); - openr2_context_set_log_directory(r2data->r2context, r2conf.logdir); - snprintf(r2data->logdir, sizeof(r2data->logdir), "%s", r2conf.logdir); - - if (r2conf.advanced_protocol_file) { - openr2_context_configure_from_advanced_file(r2data->r2context, r2conf.advanced_protocol_file); - } - - if(r2conf.use_channel_native_mf_generation) { - openr2_context_set_mflib_interface(r2data->r2context, ftdm_r2_get_native_channel_mf_generation_iface()); - } - - spanpvt->r2calls = create_hashtable(FTDM_MAX_CHANNELS_SPAN, ftdm_hash_hashfromstring, ftdm_hash_equalkeys); - if (!spanpvt->r2calls) { - snprintf(span->last_error, sizeof(span->last_error), "Cannot create channel calls hash for span."); - goto fail; - } - - for (i = 1; (i <= span->chan_count) && (i <= FTDM_MAX_CHANNELS_SPAN); i++) { - r2chan = openr2_chan_new_from_fd(r2data->r2context, span->channels[i], span->channels[i]->chan_id); - if (!r2chan) { - snprintf(span->last_error, sizeof(span->last_error), "Cannot create all openr2 channels for span."); - goto fail; - } - openr2_chan_set_log_level(r2chan, r2conf.loglevel); - if (r2conf.call_files) { - openr2_chan_enable_call_files(r2chan); - } - - if (r2conf.use_channel_native_mf_generation) { - /* Allocate a new write handle per r2chan */ - ftdm_r2_mf_write_handle_t *mf_write_handle = ftdm_calloc(1, sizeof(*mf_write_handle)); - /* Associate to the FreeTDM channel */ - mf_write_handle->ftdmchan = span->channels[i]; - /* Make sure the FreeTDM channel supports MF the generation feature */ - if (!ftdm_channel_test_feature(mf_write_handle->ftdmchan, FTDM_CHANNEL_FEATURE_MF_GENERATE)) { - ftdm_log_chan_msg(mf_write_handle->ftdmchan, FTDM_LOG_ERROR, - "FreeTDM channel does not support native MF generation: " - "\"use_channel_native_mf_generation\" configuration parameter cannot" - " be used\n"); - goto fail; - } - /* Associate the mf_write_handle to the openR2 channel */ - openr2_chan_set_mflib_handles(r2chan, mf_write_handle, NULL); - } - - r2call = ftdm_calloc(1, sizeof(*r2call)); - if (!r2call) { - snprintf(span->last_error, sizeof(span->last_error), "Cannot create all R2 call data structures for the span."); - ftdm_safe_free(r2chan); - goto fail; - } - openr2_chan_set_logging_func(r2chan, ftdm_r2_on_chan_log); - openr2_chan_set_client_data(r2chan, span->channels[i]); - r2call->r2chan = r2chan; - span->channels[i]->call_data = r2call; - /* value and key are the same so just free one of them */ - snprintf(r2call->name, sizeof(r2call->name), "chancall%d", i); - hashtable_insert(spanpvt->r2calls, (void *)r2call->name, r2call, HASHTABLE_FLAG_FREE_VALUE); - } - r2data->mf_dump_size = r2conf.mf_dump_size; - r2data->category = r2conf.category; - r2data->allow_collect_calls = r2conf.allow_collect_calls; - r2data->flags = 0; - r2data->charge_calls = r2conf.charge_calls; - r2data->forced_release = r2conf.forced_release; - spanpvt->r2context = r2data->r2context; - - /* just the value must be freed by the hash */ - hashtable_insert(g_mod_data_hash, (void *)span->name, spanpvt, HASHTABLE_FLAG_FREE_VALUE); - - span->start = ftdm_r2_start; - span->stop = ftdm_r2_stop; - span->sig_read = NULL; - span->sig_write = NULL; - - span->signal_cb = sig_cb; - span->signal_type = FTDM_SIGTYPE_R2; - span->signal_data = r2data; - span->outgoing_call = r2_outgoing_call; - span->get_span_sig_status = ftdm_r2_get_span_sig_status; - span->set_span_sig_status = ftdm_r2_set_span_sig_status; - span->get_channel_sig_status = ftdm_r2_get_channel_sig_status; - span->set_channel_sig_status = ftdm_r2_set_channel_sig_status; - - span->state_map = &r2_state_map; - span->state_processor = ftdm_r2_state_advance; - - /* use signals queue */ - ftdm_set_flag(span, FTDM_SPAN_USE_SIGNALS_QUEUE); - - /* we can skip states (going straight from RING to UP) */ - ftdm_set_flag(span, FTDM_SPAN_USE_SKIP_STATES); - - /* setup the scheduler */ - snprintf(schedname, sizeof(schedname), "ftmod_r2_%s", span->name); - ftdm_assert(ftdm_sched_create(&r2data->sched, schedname) == FTDM_SUCCESS, "Failed to create schedule!\n"); - spanpvt->sched = r2data->sched; - - return FTDM_SUCCESS; - -fail: - - if (r2data && r2data->r2context) { - openr2_context_delete(r2data->r2context); - } - if (spanpvt && spanpvt->r2calls) { - hashtable_destroy(spanpvt->r2calls); - } - ftdm_safe_free(r2data); - ftdm_safe_free(spanpvt); - return FTDM_FAIL; - -} - -/* the channel must be locked when calling this function */ -static ftdm_status_t ftdm_r2_state_advance(ftdm_channel_t *ftdmchan) -{ - ftdm_sigmsg_t sigev; - ftdm_status_t ret; - ftdm_r2_call_t *r2call = R2CALL(ftdmchan); - openr2_chan_t *r2chan = r2call->r2chan; - ftdm_r2_data_t *r2data = ftdmchan->span->signal_data; - - memset(&sigev, 0, sizeof(sigev)); - sigev.chan_id = ftdmchan->chan_id; - sigev.span_id = ftdmchan->span_id; - sigev.channel = ftdmchan; - - ret = FTDM_SUCCESS; - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Executing state handler for %s\n", ftdm_channel_state2str(ftdmchan->state)); - - if (IS_ACCEPTING_PENDING(ftdmchan)) { - /* - Moving to PROGRESS, PROGRESS_MEDIA or UP means that we must accept the call first, and accepting - the call in R2 means sending a tone, then waiting for the acknowledge from the other end, - since all of that requires sending and detecting tones, it takes a few milliseconds (I'd say around 100) - which means during that time the user should not try to perform any operations like answer, hangup or anything - else, therefore we DO NOT clear the FTDM_CHANNEL_STATE_CHANGE flag here, we rely on ftdm_io.c to block - the user thread until we're done with the accept (see on_call_accepted callback) and then we clear the state change flag, - otherwise we have a race condition between freetdm calling openr2_chan_answer_call and openr2 accepting the call first, - if freetdm calls openr2_chan_answer_call before the accept cycle completes, openr2 will fail to answer the call */ - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "State ack for state %s will have to wait a bit\n", ftdm_channel_state2str(ftdmchan->state)); - } else if (ftdmchan->state != FTDM_CHANNEL_STATE_DOWN){ - ftdm_channel_complete_state(ftdmchan); - } - - switch (ftdmchan->state) { - - /* starting an incoming call */ - case FTDM_CHANNEL_STATE_COLLECT: - { - uint32_t interval = 0; - ftdm_channel_command(ftdmchan, FTDM_COMMAND_GET_INTERVAL, &interval); - ftdm_assert(interval != 0, "Invalid interval!"); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Starting processing of incoming call with interval %d\n", interval); - openr2_chan_enable_read(r2chan); - } - break; - - /* starting an outgoing call */ - case FTDM_CHANNEL_STATE_DIALING: - { - uint32_t interval = 0; - ftdm_channel_command(ftdmchan, FTDM_COMMAND_GET_INTERVAL, &interval); - ftdm_assert(interval != 0, "Invalid interval!"); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Starting outgoing call with interval %d\n", interval); - openr2_chan_enable_read(r2chan); - } - break; - - /* incoming call was offered */ - case FTDM_CHANNEL_STATE_RING: - - /* notify the user about the new call */ - sigev.event_id = FTDM_SIGEVENT_START; - ftdm_span_send_signal(ftdmchan->span, &sigev); - break; - - /* the call is making progress */ - case FTDM_CHANNEL_STATE_PROGRESS: - case FTDM_CHANNEL_STATE_PROGRESS_MEDIA: - { - if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { - if (!r2call->accepted) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Accepting call\n"); - ft_r2_accept_call(ftdmchan); - } - } else { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Notifying progress\n"); - sigev.event_id = FTDM_SIGEVENT_PROGRESS_MEDIA; - ftdm_span_send_signal(ftdmchan->span, &sigev); - } - } - break; - - /* the call was answered */ - case FTDM_CHANNEL_STATE_UP: - { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Call was answered\n"); - if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { - if (!r2call->accepted) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Call has not been accepted, need to accept first\n"); - // the answering will be done in the on_call_accepted handler - ft_r2_accept_call(ftdmchan); - r2call->answer_pending = 1; - } else { - ft_r2_answer_call(ftdmchan); - } - } else { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Notifying of call answered\n"); - sigev.event_id = FTDM_SIGEVENT_UP; - ftdm_span_send_signal(ftdmchan->span, &sigev); - } - } - break; - - /* just got hangup */ - case FTDM_CHANNEL_STATE_HANGUP: - { - if (!r2call->disconnect_rcvd) { - openr2_call_disconnect_cause_t disconnect_cause = ftdm_r2_ftdm_cause_to_openr2_cause(ftdmchan); - /* overwrite the hangup cause if this is an incoming call and forced_release is set */ - if (openr2_chan_get_direction(r2chan) == OR2_DIR_BACKWARD && r2data->forced_release) { - disconnect_cause = OR2_CAUSE_FORCED_RELEASE; - } - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Clearing call, cause = %s\n", openr2_proto_get_disconnect_string(disconnect_cause)); - /* this will disconnect the call, but need to wait for the call end before moving to DOWN */ - openr2_chan_disconnect_call(r2chan, disconnect_cause); - } else if (!r2call->protocol_error) { - /* just ack the hangup, on_call_end will be called by openr2 right after */ - openr2_chan_disconnect_call(r2chan, OR2_CAUSE_NORMAL_CLEARING); - } else { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "Clearing call due to protocol error\n"); - /* do not set to down yet, give some time for recovery */ - ftdm_sched_timer(r2data->sched, "protocolerr_recover", 100, - ftdm_r2_recover_from_protocol_error, r2chan, &r2call->protocol_error_recovery_timer); - } - } - break; - - case FTDM_CHANNEL_STATE_TERMINATING: - { - /* if the call has not been started yet we must go to HANGUP right here */ - if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_CALL_STARTED)) { - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_HANGUP); - } else { - openr2_call_disconnect_cause_t disconnect_cause = ftdm_r2_ftdm_cause_to_openr2_cause(ftdmchan); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Clearing call, cause = %s\n", openr2_proto_get_disconnect_string(disconnect_cause)); - /* notify the user of the call terminating and we wait for the user to move us to hangup */ - sigev.event_id = FTDM_SIGEVENT_STOP; - ftdm_span_send_signal(ftdmchan->span, &sigev); - } - } - break; - - /* finished call for good */ - case FTDM_CHANNEL_STATE_DOWN: - { - if (ftdmchan->last_state != FTDM_CHANNEL_STATE_RESET) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "R2 Call is down\n"); - } else { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "R2 Reset Complete\n"); - } - ret = FTDM_BREAK; - } - break; - - /* INDICATE_RINGING doesn't apply to MFC/R2. maybe we could generate a tone */ - case FTDM_CHANNEL_STATE_RINGING: - { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "RINGING indicated, ignoring it as it doesn't apply to MFC/R2\n"); - } - break; - - /* put the r2 channel back to IDLE, close ftdmchan and set it's state as DOWN */ - case FTDM_CHANNEL_STATE_RESET: - { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "RESET indicated, putting the R2 channel back to IDLE\n"); - openr2_chan_set_idle(r2chan); - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - } - break; - - default: - { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Unhandled channel state change: %s\n", ftdm_channel_state2str(ftdmchan->state)); - } - break; - } - - if (ret == FTDM_BREAK) { - ftdm_channel_t *closed_chan; - closed_chan = ftdmchan; - ftdm_channel_close(&closed_chan); - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "State processing ended.\n"); - } - return ret; -} - -static void *ftdm_r2_run(ftdm_thread_t *me, void *obj) -{ - openr2_chan_t *r2chan = NULL; - ftdm_channel_t *ftdmchan = NULL; - ftdm_r2_call_t *call = NULL; - ftdm_status_t status; - ftdm_span_t *span = (ftdm_span_t *) obj; - ftdm_r2_data_t *r2data = span->signal_data; - int waitms = 20; - unsigned int i; - int res, ms; - int index = 0; - struct timeval start, end; - ftdm_iterator_t *chaniter = NULL; - ftdm_iterator_t *citer = NULL; - uint32_t txqueue_size = 4; - short *poll_events = ftdm_malloc(sizeof(short) * span->chan_count); - - /* as long as this thread is running, this flag is set */ - ftdm_set_flag(r2data, FTDM_R2_RUNNING); - -#ifdef __linux__ - r2data->monitor_thread_id = syscall(SYS_gettid); -#endif - - ftdm_log(FTDM_LOG_DEBUG, "OpenR2 monitor thread %u started.\n", r2data->monitor_thread_id); - r2chan = NULL; - chaniter = ftdm_span_get_chan_iterator(span, NULL); - if (!chaniter) { - ftdm_log(FTDM_LOG_CRIT, "Failed to allocate channel iterator for span %s!\n", span->name); - goto done; - } - for (i = 1, citer = chaniter; citer; citer = ftdm_iterator_next(citer), i++) { - ftdmchan = ftdm_iterator_current(citer); - ftdm_channel_lock(ftdmchan); - r2chan = R2CALL(ftdmchan)->r2chan; - openr2_chan_set_span_id(r2chan, span->span_id); - openr2_chan_set_idle(r2chan); - openr2_chan_process_cas_signaling(r2chan); - ftdm_channel_unlock(ftdmchan); - ftdm_channel_command(ftdmchan, FTDM_COMMAND_SET_TX_QUEUE_SIZE, &txqueue_size); - } - - memset(&start, 0, sizeof(start)); - memset(&end, 0, sizeof(end)); - while (ftdm_running() && ftdm_test_flag(r2data, FTDM_R2_SPAN_STARTED)) { - res = gettimeofday(&end, NULL); - if (res) { - ftdm_log(FTDM_LOG_CRIT, "Failure gettimeofday [%s]\n", strerror(errno)); - } - if (start.tv_sec) { - ms = ((end.tv_sec - start.tv_sec) * 1000) - + ((( 1000000 + end.tv_usec - start.tv_usec) / 1000) - 1000); - if (ms < 0) { - ms = 0; - } - if (ms > r2data->jobmax) { - r2data->jobmax = ms; - } - index = (ms / 10); - index = (index > 10) ? 10 : index; - r2data->loops[index]++; - r2data->total_loops++; - } - - /* run any span timers */ - ftdm_sched_run(r2data->sched); - - /* deliver the actual channel events to the user now without any channel locking */ - ftdm_span_trigger_signals(span); - - /* figure out what event to poll each channel for. POLLPRI when the channel is down, - * POLLPRI|POLLIN|POLLOUT otherwise */ - memset(poll_events, 0, sizeof(short)*span->chan_count); - citer = ftdm_span_get_chan_iterator(span, chaniter); - if (!citer) { - ftdm_log(FTDM_LOG_CRIT, "Failed to allocate channel iterator for span %s!\n", span->name); - goto done; - } - for (i = 0; citer; citer = ftdm_iterator_next(citer), i++) { - ftdmchan = ftdm_iterator_current(citer); - r2chan = R2CALL(ftdmchan)->r2chan; - poll_events[i] = FTDM_EVENTS; - if (openr2_chan_get_read_enabled(r2chan)) { - poll_events[i] |= FTDM_READ; - } - } - status = ftdm_span_poll_event(span, waitms, poll_events); - - /* run any span timers */ - ftdm_sched_run(r2data->sched); - - res = gettimeofday(&start, NULL); - if (res) { - ftdm_log(FTDM_LOG_CRIT, "Failure gettimeofday [%s]\n", strerror(errno)); - } - - if (FTDM_FAIL == status) { - ftdm_log(FTDM_LOG_CRIT, "Failure waiting I/O! [%s]\n", span->channels[1]->last_error); - continue; - } - - ms = ((start.tv_sec - end.tv_sec) * 1000) - + ((( 1000000 + start.tv_usec - end.tv_usec) / 1000) - 1000); - if (ms < 0) { - ms = 0; - } - if (ms > r2data->sleepmax) { - r2data->sleepmax = ms; - } - index = (ms / 15); - index = (index > 10) ? 10 : index; - r2data->sleeps[index]++; - r2data->total_sleeps++; - - /* this main loop takes care of MF and CAS signaling during call setup and tear down - * for every single channel in the span, do not perform blocking operations here! */ - citer = ftdm_span_get_chan_iterator(span, chaniter); - for ( ; citer; citer = ftdm_iterator_next(citer)) { - ftdmchan = ftdm_iterator_current(citer); - - ftdm_channel_lock(ftdmchan); - - call = R2CALL(ftdmchan); - - /* This let knows the core and io signaling hooks know that - * read/writes come from us and should be allowed */ - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_RX_DISABLED); - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_TX_DISABLED); - - ftdm_channel_advance_states(ftdmchan); - - r2chan = call->r2chan; - openr2_chan_process_signaling(r2chan); - - ftdm_channel_advance_states(ftdmchan); - - if (!call->accepted) { - /* if the call is not accepted we do not want users reading */ - ftdm_set_flag(ftdmchan, FTDM_CHANNEL_RX_DISABLED); - ftdm_set_flag(ftdmchan, FTDM_CHANNEL_TX_DISABLED); - } - - ftdm_channel_unlock(ftdmchan); - } - } - -done: - citer = ftdm_span_get_chan_iterator(span, chaniter); - for ( ; citer; citer = ftdm_iterator_next(citer)) { - ftdmchan = ftdm_iterator_current(citer); - ftdm_channel_lock(ftdmchan); - r2chan = R2CALL(ftdmchan)->r2chan; - openr2_chan_set_blocked(r2chan); - ftdm_channel_unlock(ftdmchan); - } - - ftdm_iterator_free(chaniter); - ftdm_safe_free(poll_events); - - ftdm_clear_flag(r2data, FTDM_R2_RUNNING); - ftdm_log(FTDM_LOG_DEBUG, "R2 thread ending.\n"); - - return NULL; -} - -static void __inline__ block_channel(ftdm_channel_t *fchan, ftdm_stream_handle_t *stream) -{ - openr2_chan_t *r2chan = R2CALL(fchan)->r2chan; - ftdm_mutex_lock(fchan->mutex); - if (fchan->state != FTDM_CHANNEL_STATE_DOWN) { - stream->write_function(stream, "cannot block channel %d:%d because has a call in progress\n", - fchan->span_id, fchan->chan_id); - } else { - if (!openr2_chan_set_blocked(r2chan)) { - ftdm_set_flag(fchan, FTDM_CHANNEL_SUSPENDED); - stream->write_function(stream, "blocked channel %d:%d\n", - fchan->span_id, fchan->chan_id); - } else { - stream->write_function(stream, "failed to block channel %d:%d\n", - fchan->span_id, fchan->chan_id); - } - } - ftdm_mutex_unlock(fchan->mutex); -} - -static void __inline__ unblock_channel(ftdm_channel_t *fchan, ftdm_stream_handle_t *stream) -{ - openr2_chan_t *r2chan = R2CALL(fchan)->r2chan; - ftdm_mutex_lock(fchan->mutex); - if (!openr2_chan_set_idle(r2chan)) { - ftdm_clear_flag(fchan, FTDM_CHANNEL_SUSPENDED); - stream->write_function(stream, "unblocked channel %d:%d\n", - fchan->span_id, fchan->chan_id); - } else { - stream->write_function(stream, "failed to unblock channel %d:%d\n", - fchan->span_id, fchan->chan_id); - } - ftdm_mutex_unlock(fchan->mutex); -} - -#define FT_SYNTAX "USAGE:\n" \ -"--------------------------------------------------------------------------------\n" \ -"ftdm r2 status \n" \ -"ftdm r2 loopstats \n" \ -"ftdm r2 block|unblock []\n" \ -"ftdm r2 version\n" \ -"ftdm r2 variants\n" \ -"--------------------------------------------------------------------------------\n" -static FIO_API_FUNCTION(ftdm_r2_api) -{ - ftdm_span_t *span = NULL; - char *mycmd = NULL, *argv[10] = { 0 }; - int argc = 0; - int span_id = 0; - unsigned int chan_id = 0; - unsigned int i = 0; - ftdm_r2_data_t *r2data = NULL; - openr2_chan_t *r2chan = NULL; - openr2_context_t *r2context = NULL; - openr2_variant_t r2variant; - - if (data) { - mycmd = ftdm_strdup(data); - argc = ftdm_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); - } - - if (argc >= 2) { - if (!strcasecmp(argv[0], "block")) { - int span_id = atoi(argv[1]); - - if (ftdm_span_find_by_name(argv[1], &span) == FTDM_SUCCESS || ftdm_span_find(span_id, &span) == FTDM_SUCCESS) { - - if (span->start != ftdm_r2_start) { - stream->write_function(stream, "-ERR invalid span.\n"); - goto done; - } - - if (argc > 2) { - chan_id = atoi(argv[2]); - if (chan_id && chan_id <= span->chan_count) { - block_channel(span->channels[chan_id], stream); - } else { - stream->write_function(stream, "-ERR invalid chan %d.\n", chan_id); - } - } else { - for (i = 1; i <= span->chan_count; i++) { - block_channel(span->channels[i], stream); - } - } - stream->write_function(stream, "+OK blocked.\n"); - goto done; - } else { - stream->write_function(stream, "-ERR invalid span.\n"); - goto done; - } - } - - if (!strcasecmp(argv[0], "unblock")) { - span_id = atoi(argv[1]); - if (ftdm_span_find_by_name(argv[1], &span) == FTDM_SUCCESS || ftdm_span_find(span_id, &span) == FTDM_SUCCESS) { - - if (span->start != ftdm_r2_start) { - stream->write_function(stream, "-ERR invalid span.\n"); - goto done; - } - - if (argc > 2) { - chan_id = atoi(argv[2]); - if (chan_id && chan_id <= span->chan_count) { - unblock_channel(span->channels[chan_id], stream); - } else { - stream->write_function(stream, "-ERR invalid chan %d.\n", chan_id); - } - } else { - for (i = 1; i <= span->chan_count; i++) { - unblock_channel(span->channels[i], stream); - } - } - - stream->write_function(stream, "+OK.\n"); - goto done; - } else { - stream->write_function(stream, "-ERR invalid span.\n"); - goto done; - } - - } - - if (!strcasecmp(argv[0], "status")) { - //openr2_chan_stats_t stats; - span_id = atoi(argv[1]); - - if (ftdm_span_find_by_name(argv[1], &span) == FTDM_SUCCESS || ftdm_span_find(span_id, &span) == FTDM_SUCCESS) { - if (span->start != ftdm_r2_start) { - stream->write_function(stream, "-ERR not an R2 span.\n"); - goto done; - } - if (!(r2data = span->signal_data)) { - stream->write_function(stream, "-ERR invalid span. No R2 signal data in span.\n"); - goto done; - } - r2context = r2data->r2context; - r2variant = openr2_context_get_variant(r2context); - stream->write_function(stream, - "Variant: %s\n" - "Max ANI: %d\n" - "Max DNIS: %d\n" - "ANI First: %s\n" - "Immediate Accept: %s\n" - "Job Thread: %u\n" - "Job Max ms: %d\n" - "Job Loops: %lu\n", - openr2_proto_get_variant_string(r2variant), - openr2_context_get_max_ani(r2context), - openr2_context_get_max_dnis(r2context), - openr2_context_get_ani_first(r2context) ? "Yes" : "No", - openr2_context_get_immediate_accept(r2context) ? "Yes" : "No", - r2data->monitor_thread_id, - r2data->jobmax, - r2data->total_loops); - stream->write_function(stream, "\n"); - stream->write_function(stream, "%4s %-12.12s %-12.12s\n", "Channel", "Tx CAS", "Rx CAS"); - for (i = 1; i <= span->chan_count; i++) { - r2chan = R2CALL(span->channels[i])->r2chan; - stream->write_function(stream, "%4d %-12.12s %-12.12s\n", - span->channels[i]->chan_id, - openr2_chan_get_tx_cas_string(r2chan), - openr2_chan_get_rx_cas_string(r2chan)); - } - stream->write_function(stream, "\n"); - stream->write_function(stream, "+OK.\n"); - goto done; - } else { - stream->write_function(stream, "-ERR invalid span.\n"); - goto done; - } - } - - if (!strcasecmp(argv[0], "loopstats")) { - int range; - float pct; - span_id = atoi(argv[1]); - - if (ftdm_span_find_by_name(argv[1], &span) == FTDM_SUCCESS || ftdm_span_find(span_id, &span) == FTDM_SUCCESS) { - if (span->start != ftdm_r2_start) { - stream->write_function(stream, "-ERR not an R2 span.\n"); - goto done; - } - if (!(r2data = span->signal_data)) { - stream->write_function(stream, "-ERR invalid span. No R2 signal data in span.\n"); - goto done; - } - stream->write_function(stream, "-- Working --\n"); - stream->write_function(stream, "Total loops: %llu\n", r2data->total_loops); - range = 0; - for (i = 0; i < ftdm_array_len(r2data->loops); i++) { - pct = 100*(float)r2data->loops[i]/r2data->total_loops; - if ((i + 1) == ftdm_array_len(r2data->loops)) { - stream->write_function(stream, ">= %dms: %llu - %.03lf%%\n", range, r2data->loops[i], pct); - } else { - stream->write_function(stream, "%d-%dms: %llu - %.03lf%%\n", range, range + 9, r2data->loops[i], pct); - } - range += 10; - } - stream->write_function(stream, "\n"); - - stream->write_function(stream, "-- Sleeping --\n"); - stream->write_function(stream, "Total sleeps: %llu\n", r2data->total_sleeps); - range = 0; - for (i = 0; i < ftdm_array_len(r2data->sleeps); i++) { - pct = 100*(float)r2data->sleeps[i]/r2data->total_sleeps; - if ((i + 1) == ftdm_array_len(r2data->sleeps)) { - stream->write_function(stream, ">= %dms: %llu - %.03lf%%\n", range, r2data->sleeps[i], pct); - } else { - stream->write_function(stream, "%d-%dms: %llu - %.03lf%%\n", range, range + 14, r2data->sleeps[i], pct); - } - range += 15; - } - stream->write_function(stream, "\n"); - - stream->write_function(stream, "+OK.\n"); - goto done; - } else { - stream->write_function(stream, "-ERR invalid span.\n"); - goto done; - } - } - - } - - if (argc == 1) { - if (!strcasecmp(argv[0], "version")) { - stream->write_function(stream, "OpenR2 version: %s, revision: %s\n", openr2_get_version(), openr2_get_revision()); - stream->write_function(stream, "+OK.\n"); - goto done; - } - - if (!strcasecmp(argv[0], "variants")) { - int32_t numvariants = 0; - const openr2_variant_entry_t *variants = openr2_proto_get_variant_list(&numvariants); - if (!variants) { - stream->write_function(stream, "-ERR failed to retrieve openr2 variant list.\n"); - goto done; - } -#define VARIANT_FORMAT "%4s %40s\n" - stream->write_function(stream, VARIANT_FORMAT, "Variant Code", "Country"); - numvariants--; - for (; numvariants; numvariants--) { - stream->write_function(stream, VARIANT_FORMAT, variants[numvariants].name, variants[numvariants].country); - } - stream->write_function(stream, "+OK.\n"); -#undef VARIANT_FORMAT - goto done; - } - } - - stream->write_function(stream, "%s", FT_SYNTAX); - -done: - - ftdm_safe_free(mycmd); - - return FTDM_SUCCESS; - -} - -static FIO_IO_LOAD_FUNCTION(ftdm_r2_io_init) -{ - assert(fio != NULL); - memset(&g_ftdm_r2_interface, 0, sizeof(g_ftdm_r2_interface)); - - g_ftdm_r2_interface.name = "r2"; - g_ftdm_r2_interface.api = ftdm_r2_api; - - *fio = &g_ftdm_r2_interface; - - return FTDM_SUCCESS; -} - -static FIO_SIG_LOAD_FUNCTION(ftdm_r2_init) -{ - g_mod_data_hash = create_hashtable(10, ftdm_hash_hashfromstring, ftdm_hash_equalkeys); - if (!g_mod_data_hash) { - return FTDM_FAIL; - } - return FTDM_SUCCESS; -} - -static FIO_SIG_UNLOAD_FUNCTION(ftdm_r2_destroy) -{ - ftdm_hash_iterator_t *i = NULL; - ftdm_r2_span_pvt_t *spanpvt = NULL; - const void *key = NULL; - void *val = NULL; - for (i = hashtable_first(g_mod_data_hash); i; i = hashtable_next(i)) { - hashtable_this(i, &key, NULL, &val); - if (key && val) { - spanpvt = val; - openr2_context_delete(spanpvt->r2context); - hashtable_destroy(spanpvt->r2calls); - ftdm_sched_destroy(&spanpvt->sched); - } - } - hashtable_destroy(g_mod_data_hash); - return FTDM_SUCCESS; -} - -EX_DECLARE_DATA ftdm_module_t ftdm_module = { - /* .name */ "r2", - /* .io_load */ ftdm_r2_io_init, - /* .io_unload */ NULL, - /* .sig_load */ ftdm_r2_init, - /* .sig_configure */ NULL, - /* .sig_unload */ ftdm_r2_destroy, - /* .configure_span_signaling */ ftdm_r2_configure_span_signaling -}; - - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2_io_mf_lib.c b/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2_io_mf_lib.c deleted file mode 100755 index 0b17885ba9..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2_io_mf_lib.c +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) 2011 Sebastien Trottier - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include -#include - -#include - -#include "ftmod_r2_io_mf_lib.h" - -/* Convert openr2 MF tone enum value to FreeTDM MF tone value - 1-15 bitwise OR FTDM_MF_DIRECTION_FORWARD/BACKWARD - 0 (stop playing) - openr2_mf_tone_t defined in r2proto.h -*/ -static int ftdm_r2_openr2_mf_tone_to_ftdm_mf_tone(openr2_mf_tone_t - openr2_tone_value, int forward_signals) -{ - int tone; - - switch (openr2_tone_value) { - case 0: return 0; -#define TONE_FROM_NAME(name) case OR2_MF_TONE_##name: tone = name; break; - TONE_FROM_NAME(1) - TONE_FROM_NAME(2) - TONE_FROM_NAME(3) - TONE_FROM_NAME(4) - TONE_FROM_NAME(5) - TONE_FROM_NAME(6) - TONE_FROM_NAME(7) - TONE_FROM_NAME(8) - TONE_FROM_NAME(9) - TONE_FROM_NAME(10) - TONE_FROM_NAME(11) - TONE_FROM_NAME(12) - TONE_FROM_NAME(13) - TONE_FROM_NAME(14) - TONE_FROM_NAME(15) -#undef TONE_FROM_NAME - default: - ftdm_assert(0, "Invalid openr2_tone_value\n"); - return -1; - } - - /* Add flag corresponding to direction */ - if (forward_signals) { - tone |= FTDM_MF_DIRECTION_FORWARD; - } else { - tone |= FTDM_MF_DIRECTION_BACKWARD; - } - - return tone; -} - -/* MF generation routines (using IO command of a FreeTDM channel) - write_init stores the direction of the MF to generate */ -static void *ftdm_r2_io_mf_write_init(ftdm_r2_mf_write_handle_t *handle, int forward_signals) -{ - ftdm_log_chan(handle->ftdmchan, FTDM_LOG_DEBUG, "ftdm_r2_io_mf_write_init, " - "forward = %d\n", forward_signals); - - handle->fwd = forward_signals; - return handle; -} - -static int ftdm_r2_io_mf_generate_tone(ftdm_r2_mf_write_handle_t *handle, int16_t buffer[], int samples) -{ - /* Our mf_want_generate implementation always return 0, so mf_generate_tone should never be called */ - ftdm_assert(0, "ftdm_r2_io_mf_generate_tone not implemented\n"); - return 0; -} - -/* \brief mf_select_tone starts tone generation or stops current tone - * \return 0 on success, -1 on error - */ -static int ftdm_r2_io_mf_select_tone(ftdm_r2_mf_write_handle_t *handle, char signal) -{ - int tone; /* (0, 1-15) (0 meaning to stop playing) */ - - ftdm_log_chan(handle->ftdmchan, FTDM_LOG_DEBUG, "ftdm_r2_io_mf_select_tone, " - "signal = %c\n", signal); - - if (-1 == (tone = ftdm_r2_openr2_mf_tone_to_ftdm_mf_tone(signal, handle->fwd))) { - return -1; - } - - /* Start/stop playback directly here, as select tone is called each time a tone - is started or stopped (called if tone changes, but silence is tone 0, - triggering a tone change) */ - if (tone > 0) { - ftdm_channel_command(handle->ftdmchan, FTDM_COMMAND_START_MF_PLAYBACK, &tone); - } else { - /* tone 0 means to stop current tone */ - ftdm_channel_command(handle->ftdmchan, FTDM_COMMAND_STOP_MF_PLAYBACK, NULL); - } - return 0; -} - -static int ftdm_r2_io_mf_want_generate(ftdm_r2_mf_write_handle_t *handle, int signal) -{ - /* Return 0, meaning mf_generate_tone doesn't need to be called */ - return 0; -} - -/* MF lib interface that generate MF tones via FreeTDM channel IO commands - MF detection using the default openr2 provider (r2engine) */ -static openr2_mflib_interface_t g_mf_ftdm_io_iface = { - /* .mf_read_init */ (openr2_mf_read_init_func)openr2_mf_rx_init, - /* .mf_write_init */ (openr2_mf_write_init_func)ftdm_r2_io_mf_write_init, - /* .mf_detect_tone */ (openr2_mf_detect_tone_func)openr2_mf_rx, - /* .mf_generate_tone */ (openr2_mf_generate_tone_func)ftdm_r2_io_mf_generate_tone, - /* .mf_select_tone */ (openr2_mf_select_tone_func)ftdm_r2_io_mf_select_tone, - /* .mf_want_generate */ (openr2_mf_want_generate_func)ftdm_r2_io_mf_want_generate, - /* .mf_read_dispose */ NULL, - /* .mf_write_dispose */ NULL -}; - -openr2_mflib_interface_t *ftdm_r2_get_native_channel_mf_generation_iface() -{ - return &g_mf_ftdm_io_iface; -} - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet - */ diff --git a/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2_io_mf_lib.h b/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2_io_mf_lib.h deleted file mode 100755 index cf3c171c3d..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2_io_mf_lib.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2011 Sebastien Trottier - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef _FTMOD_R2_IO_MFLIB_H_ -#define _FTMOD_R2_IO_MFLIB_H_ - -#include - -#include - -#if defined(__cplusplus) -extern "C" { -#endif - -/* MFC/R2 tone generator handle (mf_write_handle) */ -typedef struct { - /*! FTDM channel performing the MF generation */ - ftdm_channel_t *ftdmchan; - /*! 1 if generating forward tones, otherwise generating reverse tones. */ - int fwd; -} ftdm_r2_mf_write_handle_t; - -/* MF lib interface that generate MF tones via FreeTDM channel IO commands - MF detection using the default openr2 provider (r2engine) */ -openr2_mflib_interface_t *ftdm_r2_get_native_channel_mf_generation_iface(void); - -#if defined(__cplusplus) -} /* endif extern "C" */ -#endif - -#endif /* endif defined _FTMOD_R2_IO_MFLIB_H_ */ - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.2008.vcproj b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.2008.vcproj deleted file mode 100644 index f6263907e1..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.2008.vcproj +++ /dev/null @@ -1,249 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.2010.vcxproj.filters b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.2010.vcxproj.filters deleted file mode 100644 index 5f592fa9ef..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.2010.vcxproj.filters +++ /dev/null @@ -1,57 +0,0 @@ - - - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c deleted file mode 100644 index ed0a99dc95..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c +++ /dev/null @@ -1,1563 +0,0 @@ - -/* - * Copyright (c) 2010, Sangoma Technologies - * David Yat Sin - * Moises Silva - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -#include "ftmod_sangoma_isdn.h" - -#ifdef FTDM_DEBUG_CHAN_MEMORY -#include -#endif - -static void *ftdm_sangoma_isdn_run(ftdm_thread_t *me, void *obj); -static ftdm_status_t ftdm_sangoma_isdn_stop(ftdm_span_t *span); -static ftdm_status_t ftdm_sangoma_isdn_start(ftdm_span_t *span); -static ftdm_status_t ftdm_sangoma_isdn_dtmf(ftdm_channel_t *ftdmchan, const char* dtmf); - -ftdm_channel_t* ftdm_sangoma_isdn_process_event_states(ftdm_span_t *span, sngisdn_event_data_t *sngisdn_event); -static void ftdm_sangoma_isdn_process_phy_events(ftdm_span_t *span, ftdm_oob_event_t event); -static ftdm_status_t ftdm_sangoma_isdn_process_state_change(ftdm_channel_t *ftdmchan); -static void ftdm_sangoma_isdn_process_stack_event (ftdm_span_t *span, sngisdn_event_data_t *sngisdn_event); -static void ftdm_sangoma_isdn_wakeup_phy(ftdm_channel_t *dchan); -static void ftdm_sangoma_isdn_dchan_set_queue_size(ftdm_channel_t *ftdmchan); - -static ftdm_io_interface_t g_sngisdn_io_interface; -static sng_isdn_event_interface_t g_sngisdn_event_interface; - -ftdm_sngisdn_data_t g_sngisdn_data; - -SNGISDN_ENUM_NAMES(SNGISDN_TRANSFER_TYPE_NAMES, SNGISDN_TRANSFER_TYPE_STRINGS) -SNGISDN_STR2ENUM(ftdm_str2sngisdn_transfer_type, sngisdn_transfer_type2str, sngisdn_transfer_type_t, SNGISDN_TRANSFER_TYPE_NAMES, SNGISDN_TRANSFER_INVALID) - -ftdm_state_map_t sangoma_isdn_state_map = { - { - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_ANY, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_RESET, FTDM_CHANNEL_STATE_RESTART, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_RESET, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_RESTART, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_CANCEL, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP_COMPLETE, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_SUSPENDED, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_COLLECT, FTDM_CHANNEL_STATE_RING, FTDM_CHANNEL_STATE_DIALING, - FTDM_CHANNEL_STATE_RESTART, FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_UP, - FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_CANCEL, FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_HANGUP_COMPLETE, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_COLLECT, FTDM_CHANNEL_STATE_RING, FTDM_CHANNEL_STATE_GET_CALLERID, FTDM_CHANNEL_STATE_IN_LOOP, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_GET_CALLERID, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_RING, FTDM_CHANNEL_STATE_CANCEL, FTDM_CHANNEL_STATE_IN_LOOP, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_COLLECT, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_RING, FTDM_CHANNEL_STATE_CANCEL, FTDM_CHANNEL_STATE_IN_LOOP, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_IN_LOOP, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_COLLECT, FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_RING, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_PROCEED, FTDM_CHANNEL_STATE_RINGING, FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_PROCEED, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_RINGING, FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_TRANSFER, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_RINGING, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END}, - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END}, - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END}, - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_TRANSFER, FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_END}, - }, - - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_TRANSFER, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_PROCEED, FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_TERMINATING,FTDM_CHANNEL_STATE_END}, - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_END}, - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP_COMPLETE, FTDM_CHANNEL_STATE_END}, - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_HANGUP_COMPLETE, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END}, - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_ANY, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_RESET, FTDM_CHANNEL_STATE_RESTART, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_RESET, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_RESTART, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_CANCEL, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_SUSPENDED, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_COLLECT, FTDM_CHANNEL_STATE_RING, FTDM_CHANNEL_STATE_DIALING, - FTDM_CHANNEL_STATE_RESTART, FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_UP, - FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_CANCEL, FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_HANGUP_COMPLETE, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_DIALING, FTDM_CHANNEL_STATE_HANGUP_COMPLETE, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_DIALING, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, - FTDM_CHANNEL_STATE_PROCEED, FTDM_CHANNEL_STATE_RINGING, FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_UP, - FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_PROCEED, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, - FTDM_CHANNEL_STATE_RINGING, FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END}, - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END}, - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_RINGING, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END}, - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END}, - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_END}, - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_END}, - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_HANGUP_COMPLETE, FTDM_CHANNEL_STATE_END}, - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_HANGUP_COMPLETE, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END}, - } - } -}; - -static void ftdm_sangoma_isdn_process_phy_events(ftdm_span_t *span, ftdm_oob_event_t event) -{ - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) span->signal_data; - sngisdn_snd_event(signal_data, event); - - switch (event) { - /* Check if the span woke up from power-saving mode */ - case FTDM_OOB_ALARM_CLEAR: - if (FTDM_SPAN_IS_BRI(span)) { - ftdm_channel_t *ftdmchan; - sngisdn_chan_data_t *sngisdn_info; - ftdm_iterator_t *chaniter = NULL; - ftdm_iterator_t *curr = NULL; - - chaniter = ftdm_span_get_chan_iterator(span, NULL); - for (curr = chaniter; curr; curr = ftdm_iterator_next(curr)) { - ftdmchan = (ftdm_channel_t*)ftdm_iterator_current(curr); - sngisdn_info = (sngisdn_chan_data_t*)ftdmchan->call_data; - - if (ftdm_test_flag(sngisdn_info, FLAG_ACTIVATING)) { - ftdm_clear_flag(sngisdn_info, FLAG_ACTIVATING); - - ftdm_sched_timer(signal_data->sched, "delayed_setup", 1000, sngisdn_delayed_setup, (void*) ftdmchan->call_data, NULL); - } - } - ftdm_iterator_free(chaniter); - } - break; - default: - /* Ignore other events for now */ - break; - } -} - -static void ftdm_sangoma_isdn_dchan_set_queue_size(ftdm_channel_t *dchan) -{ - ftdm_status_t ret_status; - uint32_t queue_size; - - queue_size = SNGISDN_DCHAN_QUEUE_LEN; - ret_status = ftdm_channel_command(dchan, FTDM_COMMAND_SET_RX_QUEUE_SIZE, &queue_size); - ftdm_assert(ret_status == FTDM_SUCCESS, "Failed to set Rx Queue size"); - - queue_size = SNGISDN_DCHAN_QUEUE_LEN; - ret_status = ftdm_channel_command(dchan, FTDM_COMMAND_SET_TX_QUEUE_SIZE, &queue_size); - ftdm_assert(ret_status == FTDM_SUCCESS, "Failed to set Tx Queue size"); - - RETVOID; -} - -static void ftdm_sangoma_isdn_wakeup_phy(ftdm_channel_t *dchan) -{ - ftdm_status_t ret_status; - ftdm_channel_hw_link_status_t status = FTDM_HW_LINK_CONNECTED; - ret_status = ftdm_channel_command(dchan, FTDM_COMMAND_SET_LINK_STATUS, &status); - if (ret_status != FTDM_SUCCESS) { - ftdm_log_chan_msg(dchan, FTDM_LOG_WARNING, "Failed to wake-up link\n"); - } - return; -} - -static void *ftdm_sangoma_isdn_io_run(ftdm_thread_t *me, void *obj) -{ - uint8_t data[8192]; - unsigned i = 0; - ftdm_status_t status = FTDM_SUCCESS; - ftdm_span_t *span = (ftdm_span_t*) obj; - ftdm_size_t len = 0; - ftdm_channel_t *ftdmchan = NULL; - unsigned waitms = 10000; - ftdm_iterator_t *chaniter = NULL; - ftdm_iterator_t *citer = NULL; - ftdm_event_t *event; - short *poll_events = ftdm_malloc(sizeof(short) * span->chan_count); - - /* Initialize the d-channel */ - chaniter = ftdm_span_get_chan_iterator(span, NULL); - if (!chaniter) { - ftdm_log(FTDM_LOG_CRIT, "Failed to allocate channel iterator for span %s!\n", span->name); - goto done; - } - - while (ftdm_running() && !(ftdm_test_flag(span, FTDM_SPAN_STOP_THREAD))) { - len = 1000; - waitms = 1000; - memset(poll_events, 0, sizeof(short)*span->chan_count); - - for (i = 0, citer = ftdm_span_get_chan_iterator(span, chaniter); citer; citer = ftdm_iterator_next(citer), i++) { - ftdmchan = ftdm_iterator_current(citer); - - poll_events[i] |= FTDM_EVENTS; - if (FTDM_IS_VOICE_CHANNEL(ftdmchan)) { - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_RX_DISABLED)) { - poll_events[i] |= FTDM_READ; - waitms = 20; - } - } else { - /* We always read the d-channel */ - poll_events[i] |= FTDM_READ; - } - } - - status = ftdm_span_poll_event(span, waitms, poll_events); - switch (status) { - case FTDM_FAIL: - ftdm_log(FTDM_LOG_CRIT, "Failed to poll span for IO\n"); - break; - case FTDM_TIMEOUT: - break; - case FTDM_SUCCESS: - /* Check if there are any channels that have data available */ - for (citer = ftdm_span_get_chan_iterator(span, chaniter); citer; citer = ftdm_iterator_next(citer)) { - len = sizeof(data); - ftdmchan = ftdm_iterator_current(citer); - if (FTDM_IS_VOICE_CHANNEL(ftdmchan)) { - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_RX_DISABLED)) { - if (ftdm_test_io_flag(ftdmchan, FTDM_CHANNEL_IO_READ)) { - status = ftdm_raw_read(ftdmchan, data, &len); - if (status != FTDM_SUCCESS) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "raw I/O read failed\n"); - continue; - } - - status = ftdm_channel_process_media(ftdmchan, data, &len); - if (status != FTDM_SUCCESS) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "Failed to process media\n"); - continue; - } - } - } - } else { - if (ftdm_test_io_flag(ftdmchan, FTDM_CHANNEL_IO_READ)) { - status = ftdm_channel_read(ftdmchan, data, &len); - if (status == FTDM_SUCCESS) { - sngisdn_snd_data(ftdmchan, data, len); - } - } - } - } - - /* Check if there are any channels that have events available */ - while (ftdm_span_next_event(span, &event) == FTDM_SUCCESS) { - ftdm_sangoma_isdn_process_phy_events(span, event->enum_id); - } - - break; - default: - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "Unhandled IO event\n"); - } - } -done: - ftdm_iterator_free(chaniter); - ftdm_safe_free(poll_events); - return NULL; -} - -static void *ftdm_sangoma_isdn_run(ftdm_thread_t *me, void *obj) -{ - ftdm_interrupt_t *ftdm_sangoma_isdn_int[3]; - ftdm_status_t ret_status; - ftdm_span_t *span = (ftdm_span_t *) obj; - ftdm_channel_t *ftdmchan = NULL; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)span->signal_data; - sngisdn_event_data_t *sngisdn_event = NULL; - int32_t sleep = SNGISDN_EVENT_POLL_RATE; - - ftdm_log(FTDM_LOG_INFO, "ftmod_sangoma_isdn monitor thread for span=%u started.\n", span->span_id); - - /* set IN_THREAD flag so that we know this thread is running */ - ftdm_set_flag(span, FTDM_SPAN_IN_THREAD); - - /* get an interrupt queue for this span */ - if (ftdm_queue_get_interrupt(span->pendingchans, &ftdm_sangoma_isdn_int[0]) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_CRIT, "Failed to get a ftdm_interrupt for span = %s!\n", span->name); - goto ftdm_sangoma_isdn_run_exit; - } - - if (ftdm_queue_get_interrupt(span->pendingsignals, &ftdm_sangoma_isdn_int[1]) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_CRIT, "Failed to get a signal interrupt for span = %s!\n", span->name); - goto ftdm_sangoma_isdn_run_exit; - } - - if (ftdm_queue_get_interrupt(signal_data->event_queue, &ftdm_sangoma_isdn_int[2]) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_CRIT, "Failed to get a event interrupt for span = %s!\n", span->name); - goto ftdm_sangoma_isdn_run_exit; - } - - while (ftdm_running() && !(ftdm_test_flag(span, FTDM_SPAN_STOP_THREAD))) { - /* Check if there are any timers to process */ - ftdm_sched_run(signal_data->sched); - ftdm_span_trigger_signals(span); - - if (ftdm_sched_get_time_to_next_timer(signal_data->sched, &sleep) == FTDM_SUCCESS) { - if (sleep < 0 || sleep > SNGISDN_EVENT_POLL_RATE) { - sleep = SNGISDN_EVENT_POLL_RATE; - } - } - ret_status = ftdm_interrupt_multiple_wait(ftdm_sangoma_isdn_int, 3, sleep); - /* find out why we returned from the interrupt queue */ - switch (ret_status) { - case FTDM_SUCCESS: /* there was a state change on the span */ - /* process all pending state changes */ - while ((ftdmchan = ftdm_queue_dequeue(span->pendingchans))) { - /* double check that this channel has a state change pending */ - ftdm_channel_lock(ftdmchan); - ftdm_channel_advance_states(ftdmchan); - ftdm_channel_unlock(ftdmchan); - } - - while ((sngisdn_event = ftdm_queue_dequeue(signal_data->event_queue))) { - ftdm_sangoma_isdn_process_stack_event(span, sngisdn_event); - ftdm_safe_free(sngisdn_event); - } - break; - case FTDM_TIMEOUT: - /* twiddle */ - break; - case FTDM_FAIL: - ftdm_log(FTDM_LOG_ERROR, "%s: ftdm_interrupt_wait returned error!\n", span->name); - break; - - default: - ftdm_log(FTDM_LOG_ERROR, "%s: ftdm_interrupt_wait returned with unknown code\n", span->name); - break; - } - } - - /* clear the IN_THREAD flag so that we know the thread is done */ - ftdm_clear_flag(span, FTDM_SPAN_IN_THREAD); - - ftdm_log(FTDM_LOG_INFO, "ftmod_sangoma_isdn monitor thread for span %s stopping.\n", span->name); - - return NULL; - -ftdm_sangoma_isdn_run_exit: - - /* clear the IN_THREAD flag so that we know the thread is done */ - ftdm_clear_flag(span, FTDM_SPAN_IN_THREAD); - - ftdm_log(FTDM_LOG_INFO, "ftmod_sangoma_isdn monitor thread for span %s stopping due to error.\n", span->name); - - return NULL; -} - - -/** - * \brief Checks if span has state changes pending and processes - * \param span Span where event was fired - * \param sngisdn_event Event to handle - * \return The locked FTDM channel associated to the event if any, NULL otherwise - */ - -ftdm_channel_t* ftdm_sangoma_isdn_process_event_states(ftdm_span_t *span, sngisdn_event_data_t *sngisdn_event) -{ - ftdm_channel_t *ftdmchan = NULL; - switch (sngisdn_event->event_id) { - /* Events that do not have a channel associated to them */ - case SNGISDN_EVENT_SRV_IND: - case SNGISDN_EVENT_SRV_CFM: - case SNGISDN_EVENT_RST_CFM: - case SNGISDN_EVENT_RST_IND: - return NULL; - break; - case SNGISDN_EVENT_CON_IND: - case SNGISDN_EVENT_CON_CFM: - case SNGISDN_EVENT_CNST_IND: - case SNGISDN_EVENT_DISC_IND: - case SNGISDN_EVENT_REL_IND: - case SNGISDN_EVENT_DAT_IND: - case SNGISDN_EVENT_SSHL_IND: - case SNGISDN_EVENT_SSHL_CFM: - case SNGISDN_EVENT_RMRT_IND: - case SNGISDN_EVENT_RMRT_CFM: - case SNGISDN_EVENT_FLC_IND: - case SNGISDN_EVENT_FAC_IND: - case SNGISDN_EVENT_STA_CFM: - ftdmchan = sngisdn_event->sngisdn_info->ftdmchan; - ftdm_assert_return(ftdmchan, NULL,"Event should have a channel associated\n"); - break; - } - ftdm_channel_lock(ftdmchan); - ftdm_channel_advance_states(ftdmchan); - return ftdmchan; -} - - - -static void ftdm_sangoma_isdn_process_stack_event (ftdm_span_t *span, sngisdn_event_data_t *sngisdn_event) -{ - ftdm_channel_t *ftdmchan = NULL; - - ftdmchan = ftdm_sangoma_isdn_process_event_states(span, sngisdn_event); - switch(sngisdn_event->event_id) { - case SNGISDN_EVENT_CON_IND: - sngisdn_process_con_ind(sngisdn_event); - break; - case SNGISDN_EVENT_CON_CFM: - sngisdn_process_con_cfm(sngisdn_event); - break; - case SNGISDN_EVENT_CNST_IND: - sngisdn_process_cnst_ind(sngisdn_event); - break; - case SNGISDN_EVENT_DISC_IND: - sngisdn_process_disc_ind(sngisdn_event); - break; - case SNGISDN_EVENT_REL_IND: - sngisdn_process_rel_ind(sngisdn_event); - break; - case SNGISDN_EVENT_DAT_IND: - sngisdn_process_dat_ind(sngisdn_event); - break; - case SNGISDN_EVENT_SSHL_IND: - sngisdn_process_sshl_ind(sngisdn_event); - break; - case SNGISDN_EVENT_SSHL_CFM: - sngisdn_process_sshl_cfm(sngisdn_event); - break; - case SNGISDN_EVENT_RMRT_IND: - sngisdn_process_rmrt_ind(sngisdn_event); - break; - case SNGISDN_EVENT_RMRT_CFM: - sngisdn_process_rmrt_cfm(sngisdn_event); - break; - case SNGISDN_EVENT_FLC_IND: - sngisdn_process_flc_ind(sngisdn_event); - break; - case SNGISDN_EVENT_FAC_IND: - sngisdn_process_fac_ind(sngisdn_event); - break; - case SNGISDN_EVENT_STA_CFM: - sngisdn_process_sta_cfm(sngisdn_event); - break; - case SNGISDN_EVENT_SRV_IND: - sngisdn_process_srv_ind(sngisdn_event); - break; - case SNGISDN_EVENT_SRV_CFM: - sngisdn_process_srv_cfm(sngisdn_event); - break; - case SNGISDN_EVENT_RST_CFM: - sngisdn_process_rst_cfm(sngisdn_event); - break; - case SNGISDN_EVENT_RST_IND: - sngisdn_process_rst_ind(sngisdn_event); - break; - } - if (ftdmchan != NULL) { - ftdm_channel_advance_states(ftdmchan); - ftdm_channel_unlock(ftdmchan); - } -} - -/* this function is called with the channel already locked by the core */ -static ftdm_status_t ftdm_sangoma_isdn_process_state_change(ftdm_channel_t *ftdmchan) -{ - ftdm_sigmsg_t sigev; - ftdm_channel_state_t initial_state; - sngisdn_chan_data_t *sngisdn_info = ftdmchan->call_data; - uint8_t state_change = 0; - - memset(&sigev, 0, sizeof(sigev)); - - sigev.chan_id = ftdmchan->chan_id; - sigev.span_id = ftdmchan->span_id; - sigev.channel = ftdmchan; - -#ifdef FTDM_DEBUG_CHAN_MEMORY - if (ftdmchan->state == FTDM_CHANNEL_STATE_DIALING) { - ftdm_assert(mprotect(ftdmchan, sizeof(*ftdmchan), PROT_READ) == 0, "Failed to mprotect"); - } -#endif - - /* Only needed for debugging */ - initial_state = ftdmchan->state; - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "processing state change to %s\n", ftdm_channel_state2str(ftdmchan->state)); - - switch (ftdmchan->state) { - case FTDM_CHANNEL_STATE_COLLECT: /* SETUP received but waiting on digits */ - { - /* TODO: Re-implement this. There is a way to re-evaluate new incoming digits from dialplan as they come */ - sngisdn_snd_setup_ack(ftdmchan); - /* Just wait in this state until we get enough digits or T302 timeout */ - } - break; - case FTDM_CHANNEL_STATE_GET_CALLERID: - { - /* By default, we do not send a progress indicator in the proceed */ - ftdm_sngisdn_progind_t prog_ind = {SNGISDN_PROGIND_LOC_USER, SNGISDN_PROGIND_DESCR_INVALID}; - sngisdn_snd_proceed(ftdmchan, prog_ind); - - /* Wait in this state until we get FACILITY msg */ - } - break; - case FTDM_CHANNEL_STATE_RING: /* incoming call request */ - { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Sending incoming call from %s to %s to FTDM core\n", ftdmchan->caller_data.ani.digits, ftdmchan->caller_data.dnis.digits); - - /* we have enough information to inform FTDM of the call*/ - sngisdn_send_signal(sngisdn_info, FTDM_SIGEVENT_START); - } - break; - case FTDM_CHANNEL_STATE_DIALING: /* outgoing call request */ - { - if (FTDM_SPAN_IS_BRI(ftdmchan->span) && ftdm_test_flag(ftdmchan->span, FTDM_SPAN_PWR_SAVING)) { - ftdm_signaling_status_t sigstatus; - ftdm_span_get_sig_status(ftdmchan->span, &sigstatus); - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_IN_ALARM)) { - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)ftdmchan->span->signal_data; - - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Requesting Physical Line activation\n"); - sngisdn_set_flag(sngisdn_info, FLAG_ACTIVATING); - ftdm_sangoma_isdn_wakeup_phy(ftdmchan); - ftdm_sched_timer(signal_data->sched, "timer_t3", signal_data->timer_t3*1000, sngisdn_t3_timeout, (void*) sngisdn_info, NULL); - } else if (sigstatus == FTDM_SIG_STATE_DOWN) { - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)ftdmchan->span->signal_data; - - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Requesting Q.921 Line activation\n"); - sngisdn_set_flag(sngisdn_info, FLAG_ACTIVATING); - sngisdn_snd_dl_req(ftdmchan); - ftdm_sched_timer(signal_data->sched, "timer_t3", signal_data->timer_t3*1000, sngisdn_t3_timeout, (void*) sngisdn_info, NULL); - } else { - sngisdn_snd_setup(ftdmchan); - } - } else { - sngisdn_snd_setup(ftdmchan); - } - } - break; - case FTDM_CHANNEL_STATE_PROCEED: - { - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { - /*OUTBOUND...so we were told by the line of this so noifiy the user*/ - sngisdn_send_signal(sngisdn_info, FTDM_SIGEVENT_PROCEED); - - if (sngisdn_test_flag(sngisdn_info, FLAG_MEDIA_READY)) { - state_change++; - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA); - } - } else { - ftdm_sngisdn_progind_t prog_ind = {SNGISDN_PROGIND_LOC_USER, SNGISDN_PROGIND_DESCR_INVALID}; - sngisdn_snd_proceed(ftdmchan, prog_ind); - } - } - break; - case FTDM_CHANNEL_STATE_RINGING: - { - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { - /* OUTBOUND...so we were told by the line of this so notify the user */ - sngisdn_send_signal(sngisdn_info, FTDM_SIGEVENT_RINGING); - - if (sngisdn_test_flag(sngisdn_info, FLAG_MEDIA_READY)) { - state_change++; - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA); - } - } else { - ftdm_sngisdn_progind_t prog_ind = {SNGISDN_PROGIND_LOC_USER, SNGISDN_PROGIND_DESCR_NETE_ISDN}; - sngisdn_snd_alert(ftdmchan, prog_ind); - } - } - break; - case FTDM_CHANNEL_STATE_PROGRESS: - { - /*check if the channel is inbound or outbound*/ - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { - /*OUTBOUND...so we were told by the line of this so noifiy the user*/ - - sngisdn_send_signal(sngisdn_info, FTDM_SIGEVENT_PROGRESS); - } else { - /* Send a progress message, indicating: Call is not end-to-end ISDN, further call progress may be available */ - ftdm_sngisdn_progind_t prog_ind = {SNGISDN_PROGIND_LOC_USER, SNGISDN_PROGIND_DESCR_NETE_ISDN}; - sngisdn_snd_progress(ftdmchan, prog_ind); - } - } - break; - case FTDM_CHANNEL_STATE_PROGRESS_MEDIA: - { - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { - sngisdn_send_signal(sngisdn_info, FTDM_SIGEVENT_PROGRESS_MEDIA); - } else { - /* Send a progress message, indicating: In-band information/pattern available */ - ftdm_sngisdn_progind_t prog_ind = {SNGISDN_PROGIND_LOC_USER, SNGISDN_PROGIND_DESCR_IB_AVAIL}; - sngisdn_snd_progress(ftdmchan, prog_ind); - } - } - break; - case FTDM_CHANNEL_STATE_UP: /* call is answered */ - { - /* check if the channel is inbound or outbound */ - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { - /* OUTBOUND ... so we were told by the line that the other side answered */ - - sngisdn_send_signal(sngisdn_info, FTDM_SIGEVENT_UP); - - if (ftdmchan->span->trunk_type == FTDM_TRUNK_BRI_PTMP && - ((sngisdn_span_data_t*)ftdmchan->span->signal_data)->signalling == SNGISDN_SIGNALING_NET) { - /* Assign the call to a specific equipment */ - sngisdn_snd_con_complete(ftdmchan); - } - } else { - /* INBOUND ... so FS told us it just answered ... tell the stack */ - sngisdn_snd_connect(ftdmchan); - } - } - break; - case FTDM_CHANNEL_STATE_CANCEL: - { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Hanging up call before informing user!\n"); - - /* Send a release complete */ - sngisdn_snd_release(ftdmchan, 0); - /*now go to the HANGUP complete state*/ - state_change++; - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_HANGUP_COMPLETE); - } - break; - case FTDM_CHANNEL_STATE_TERMINATING: /* call is hung up by the remote end */ - { - /* this state is set when the line is hanging up */ - sngisdn_send_signal(sngisdn_info, FTDM_SIGEVENT_STOP); - } - break; - case FTDM_CHANNEL_STATE_HANGUP: /* call is hung up locally */ - { - if (sngisdn_test_flag(sngisdn_info, FLAG_REMOTE_ABORT)) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Acknowledging remote abort\n"); - } else if (sngisdn_test_flag(sngisdn_info, FLAG_REMOTE_REL)) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Acknowledging remote hangup\n"); - sngisdn_snd_release(ftdmchan, 0); - } else if (sngisdn_test_flag(sngisdn_info, FLAG_LOCAL_ABORT)) { - /* We aborted this call before sending anything to the stack, so nothing to do anymore */ - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Clearing local states from local abort\n"); - } else if (sngisdn_test_flag(sngisdn_info, FLAG_GLARE)) { - /* We are hangup local call because there was a glare, we are waiting for a - RELEASE on this call, before we can process the saved call */ - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Waiting for RELEASE on hungup glared call\n"); - } else if (sngisdn_test_flag(sngisdn_info, FLAG_SEND_DISC)) { - /* Remote side sent a PROGRESS message, but cause indicates disconnect or T310 expired*/ - sngisdn_snd_disconnect(ftdmchan); - } else { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Hanging up call upon local request!\n"); - - /* set the flag to indicate this hangup is started from the local side */ - sngisdn_set_flag(sngisdn_info, FLAG_LOCAL_REL); - - switch(ftdmchan->last_state) { - case FTDM_CHANNEL_STATE_RING: - /* If we never sent PROCEED/ALERT/PROGRESS/CONNECT on an incoming call, we need to send release instead of disconnect */ - sngisdn_set_flag(sngisdn_info, FLAG_LOCAL_ABORT); - sngisdn_snd_release(ftdmchan, 0); - break; - case FTDM_CHANNEL_STATE_DIALING: - /* If we never received a PROCEED/ALERT/PROGRESS/CONNECT on an outgoing call, we need to send release instead of disconnect */ - sngisdn_snd_release(ftdmchan, 0); - break; - case FTDM_CHANNEL_STATE_PROCEED: - if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { - if (((sngisdn_span_data_t*)(ftdmchan->span->signal_data))->switchtype == SNGISDN_SWITCH_4ESS || - ((sngisdn_span_data_t*)(ftdmchan->span->signal_data))->switchtype == SNGISDN_SWITCH_5ESS) { - - /* When using 5ESS, if the user wants to clear an inbound call, the correct procedure is to send a PROGRESS with in-band info available, and play tones. Then send a DISCONNECT. If we reached this point, it means user did not try to play-tones, so send a RELEASE because remote side does not expect DISCONNECT in state 3 */ - sngisdn_snd_release(ftdmchan, 0); - break; - } - } - /* fall-through */ - default: - sngisdn_snd_disconnect(ftdmchan); - break; - } - } - /* now go to the HANGUP complete state */ - state_change++; - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_HANGUP_COMPLETE); - } - break; - case FTDM_CHANNEL_STATE_HANGUP_COMPLETE: - { - if (sngisdn_test_flag(sngisdn_info, FLAG_REMOTE_ABORT) || - sngisdn_test_flag(sngisdn_info, FLAG_LOCAL_ABORT)) { - /* If the remote side aborted, we will not get anymore message for this call */ - state_change++; - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - } else { - /* waiting on remote confirmation before moving to down */ - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Waiting for release from stack\n"); - } - } - break; - case FTDM_CHANNEL_STATE_DOWN: /* the call is finished and removed */ - { - uint8_t glare = sngisdn_test_flag(sngisdn_info, FLAG_GLARE); - /* clear all of the call specific data store in the channel structure */ - clear_call_data(sngisdn_info); - - /* Close the channel even if we had a glare, we will re-open it when processing state COLLECT for the - "glared call" */ - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OPEN)) { - ftdm_channel_t *close_chan = ftdmchan; - /* close the channel */ - ftdm_channel_close(&close_chan); - } - if (glare) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Glare detected, processing saved call\n"); - /* We are calling sngisdn_rcv_con_ind with ftdmchan->mutex being locked, - so no other threads will be able to touch this channel. The next time we will - process this channel is in this function, and it should be in state COLLECT (set inside - sngisdn_rcv_con_ind)*/ - sngisdn_rcv_con_ind(sngisdn_info->glare.suId, sngisdn_info->glare.suInstId, sngisdn_info->glare.spInstId, &sngisdn_info->glare.setup, sngisdn_info->glare.dChan, sngisdn_info->glare.ces); - } - } - break; - case FTDM_CHANNEL_STATE_TRANSFER: - { - /* sngisdn_transfer function will always result in a state change */ - sngisdn_transfer(ftdmchan); - state_change++; - } - break; - case FTDM_CHANNEL_STATE_RESTART: - { - /* IMPLEMENT ME */ - } - break; - case FTDM_CHANNEL_STATE_SUSPENDED: - { - /* IMPLEMENT ME */ - } - break; - case FTDM_CHANNEL_STATE_RESET: - { - sngisdn_snd_restart(ftdmchan); - } - break; - default: - { - ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "unsupported sngisdn_rcvd state %s\n", ftdm_channel_state2str(ftdmchan->state)); - } - break; - } - - if (!state_change) { - /* Acknowledge the state change */ - ftdm_channel_complete_state(ftdmchan); - } - - /* If sngisdn_info->variables is not NULL, it means did not send any - * sigevent to the user, therefore we have to free that hashtable */ - if (sngisdn_info->variables) { - hashtable_destroy(sngisdn_info->variables); - sngisdn_info->variables = NULL; - } - - /* If sngisdn_info->raw_data is not NULL, it means did not send any - * sigevent to the user, therefore we have to free that raw data */ - if (sngisdn_info->raw_data) { - ftdm_safe_free(sngisdn_info->raw_data); - sngisdn_info->raw_data = NULL; - sngisdn_info->raw_data_len = 0; - } - - if (ftdmchan->state == initial_state) { - ftdm_assert(!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_STATE_CHANGE), "state change flag is still set, but we did not change state\n"); - } -#ifdef FTDM_DEBUG_CHAN_MEMORY - if (ftdmchan->state == FTDM_CHANNEL_STATE_DIALING) { - ftdm_assert(mprotect(ftdmchan, sizeof(*ftdmchan), PROT_READ|PROT_WRITE) == 0, "Failed to mprotect"); - } -#endif - return FTDM_SUCCESS; -} - -static FIO_CHANNEL_INDICATE_FUNCTION(ftdm_sangoma_isdn_indicate) -{ - ftdm_status_t status = FTDM_FAIL; - - switch (indication) { - case FTDM_CHANNEL_INDICATE_FACILITY: - sngisdn_snd_fac_req(ftdmchan); - status = FTDM_SUCCESS; - break; - default: - status = FTDM_NOTIMPL; - } - return status; -} - -static FIO_CHANNEL_OUTGOING_CALL_FUNCTION(ftdm_sangoma_isdn_outgoing_call) -{ - sngisdn_chan_data_t *sngisdn_info = ftdmchan->call_data; - ftdm_status_t status = FTDM_FAIL; - - if (ftdmchan->state == FTDM_CHANNEL_STATE_DOWN) { - if (sngisdn_test_flag(sngisdn_info, FLAG_GLARE)) { - /* A call came in after we called ftdm_channel_open_chan for this call, but before we got here */ - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "Glare detected - aborting outgoing call\n"); - - sngisdn_set_flag(sngisdn_info, FLAG_LOCAL_ABORT); - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_HANGUP_COMPLETE); - - status = FTDM_BREAK; - } else { - status = FTDM_SUCCESS; - } - } else { - /* the channel is already used...this can't be, end the request */ - ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Outgoing call requested channel in already in use (%s)\n", ftdm_channel_state2str(ftdmchan->state)); - status = FTDM_BREAK; - } - - return status; -} -static FIO_CHANNEL_GET_SIG_STATUS_FUNCTION(ftdm_sangoma_isdn_get_chan_sig_status) -{ - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_SIG_UP)) { - *status = FTDM_SIG_STATE_UP; - } else { - *status = FTDM_SIG_STATE_DOWN; - } - - return FTDM_SUCCESS; -} - -static FIO_CHANNEL_SET_SIG_STATUS_FUNCTION(ftdm_sangoma_isdn_set_chan_sig_status) -{ - ftdm_log(FTDM_LOG_ERROR,"Cannot set channel status in this module\n"); - return FTDM_NOTIMPL; -} - -static FIO_SPAN_GET_SIG_STATUS_FUNCTION(ftdm_sangoma_isdn_get_span_sig_status) -{ - if (ftdm_test_flag(span->channels[1], FTDM_CHANNEL_SIG_UP)) { - *status = FTDM_SIG_STATE_UP; - } else { - *status = FTDM_SIG_STATE_DOWN; - } - - return FTDM_SUCCESS; -} - -static FIO_SPAN_SET_SIG_STATUS_FUNCTION(ftdm_sangoma_isdn_set_span_sig_status) -{ - ftdm_log(FTDM_LOG_ERROR,"Cannot set span status in this module\n"); - return FTDM_NOTIMPL; -} - -static ftdm_status_t ftdm_sangoma_isdn_dtmf(ftdm_channel_t *ftdmchan, const char* dtmf) -{ - sngisdn_chan_data_t *sngisdn_info = ftdmchan->call_data; - switch(sngisdn_info->transfer_data.type) { - case SNGISDN_TRANSFER_ATT_COURTESY_VRU: - case SNGISDN_TRANSFER_ATT_COURTESY_VRU_DATA: - return sngisdn_att_transfer_process_dtmf(ftdmchan, dtmf); - default: - /* We do not care about DTMF events, do nothing */ - break; - } - - return FTDM_SUCCESS; -} - -static ftdm_status_t ftdm_sangoma_isdn_perform_start(ftdm_span_t *span) -{ - sngisdn_span_data_t *signal_data = span->signal_data; - - ftdm_log(FTDM_LOG_DEBUG, "Actually starting span:%s\n", span->name); - /* clear the monitor thread stop flag */ - ftdm_clear_flag(span, FTDM_SPAN_STOP_THREAD); - ftdm_clear_flag(span, FTDM_SPAN_IN_THREAD); - - if (signal_data->trace_q921 == SNGISDN_OPT_TRUE || - signal_data->raw_trace_q921 == SNGISDN_OPT_TRUE) { - - sngisdn_activate_trace(span, SNGISDN_TRACE_Q921); - } - - if (signal_data->trace_q931 == SNGISDN_OPT_TRUE || - signal_data->raw_trace_q931 == SNGISDN_OPT_TRUE) { - - sngisdn_activate_trace(span, SNGISDN_TRACE_Q931); - } - - /*start the span monitor thread*/ - if (ftdm_thread_create_detached(ftdm_sangoma_isdn_run, span) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_CRIT,"Failed to start Sangoma ISDN Span Monitor Thread!\n"); - return FTDM_FAIL; - } - - /*start the dchan monitor thread*/ - if (ftdm_thread_create_detached(ftdm_sangoma_isdn_io_run, span) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_CRIT,"Failed to start Sangoma ISDN d-channel Monitor Thread!\n"); - return FTDM_FAIL; - } - - if (signal_data->restart_timeout) { - ftdm_log(FTDM_LOG_DEBUG, "%s:Scheduling Restart timeout\n", signal_data->ftdm_span->name); - ftdm_sched_timer(signal_data->sched, "restart_timeout", signal_data->restart_timeout, - sngisdn_restart_timeout, (void*) signal_data, &signal_data->timers[SNGISDN_SPAN_TIMER_RESTART]); - } - - ftdm_log(FTDM_LOG_DEBUG,"Finished starting span %s\n", span->name); - return FTDM_SUCCESS; -} - - -static ftdm_status_t ftdm_sangoma_isdn_start(ftdm_span_t *span) -{ - sngisdn_span_data_t *signal_data = span->signal_data; - - ftdm_log(FTDM_LOG_INFO,"Starting span %s:%u.\n",span->name,span->span_id); - - if (signal_data->dchan) { - ftdm_channel_set_feature(signal_data->dchan, FTDM_CHANNEL_FEATURE_IO_STATS); - ftdm_channel_open_chan(signal_data->dchan); - ftdm_sangoma_isdn_dchan_set_queue_size(signal_data->dchan); - } - - if (signal_data->nfas.trunk) { - if (signal_data->nfas.trunk->num_spans == signal_data->nfas.trunk->num_spans_configured) { - int i; - ftdm_log(FTDM_LOG_DEBUG, "Starting span for all spans within trunkgroup:%s\n", signal_data->nfas.trunk->name); - - sngisdn_stack_start(signal_data->nfas.trunk->dchan->ftdm_span); - ftdm_sangoma_isdn_perform_start(signal_data->nfas.trunk->dchan->ftdm_span); - - if (signal_data->nfas.trunk->backup) { - sngisdn_stack_start(signal_data->nfas.trunk->backup->ftdm_span); - ftdm_sangoma_isdn_perform_start(signal_data->nfas.trunk->backup->ftdm_span); - } - - for (i = 0; i < signal_data->nfas.trunk->num_spans; i++) { - if (signal_data->nfas.trunk->spans[i] && - signal_data->nfas.trunk->spans[i]->nfas.sigchan == SNGISDN_NFAS_DCHAN_NONE) { - sngisdn_stack_start(signal_data->nfas.trunk->spans[i]->ftdm_span); - ftdm_sangoma_isdn_perform_start(signal_data->nfas.trunk->spans[i]->ftdm_span); - } - } - - return FTDM_SUCCESS; - } else { - ftdm_log(FTDM_LOG_DEBUG, "Delaying span start until all spans within trunkgroup are started: %s\n", signal_data->nfas.trunk->name); - return FTDM_SUCCESS; - } - } - - if (sngisdn_stack_start(span) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_CRIT, "Failed to start span %s\n", span->name); - return FTDM_FAIL; - } - - ftdm_sangoma_isdn_perform_start(span); - - return FTDM_SUCCESS; -} - -static ftdm_status_t ftdm_sangoma_isdn_stop(ftdm_span_t *span) -{ - ftdm_iterator_t *chaniter = NULL; - ftdm_iterator_t *curr = NULL; - unsigned i; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) span->signal_data; - ftdm_log(FTDM_LOG_INFO, "Stopping span %s\n", span->name); - - /* throw the STOP_THREAD flag to signal monitor thread stop */ - ftdm_set_flag(span, FTDM_SPAN_STOP_THREAD); - - /* wait for the thread to stop */ - while (ftdm_test_flag(span, FTDM_SPAN_IN_THREAD)) { - ftdm_log(FTDM_LOG_DEBUG, "Waiting for monitor thread to end for span %s\n", span->name); - ftdm_sleep(10); - } - - if (sngisdn_stack_stop(span) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_CRIT, "Failed to stop span %s\n", span->name); - } - - chaniter = ftdm_span_get_chan_iterator(span, NULL); - for (curr = chaniter; curr; curr = ftdm_iterator_next(curr)) { - ftdm_safe_free(((ftdm_channel_t*)ftdm_iterator_current(curr))->call_data); - ((ftdm_channel_t*)ftdm_iterator_current(curr))->call_data = NULL; - } - ftdm_iterator_free(chaniter); - - ftdm_sched_destroy(&signal_data->sched); - ftdm_queue_destroy(&signal_data->event_queue); - for (i = 0 ; i < signal_data->num_local_numbers ; i++) { - if (signal_data->local_numbers[i] != NULL) { - ftdm_safe_free(signal_data->local_numbers[i]); - } - } - ftdm_safe_free(span->signal_data); - - ftdm_log(FTDM_LOG_DEBUG, "Finished stopping span %s\n", span->name); - - return FTDM_SUCCESS; -} - -static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_sangoma_isdn_span_config) -{ - ftdm_iterator_t *chaniter = NULL; - ftdm_iterator_t *curr = NULL; - - sngisdn_span_data_t *signal_data; - - ftdm_log(FTDM_LOG_INFO, "Configuring ftmod_sangoma_isdn span = %s\n", span->name); - - signal_data = ftdm_calloc(1, sizeof(sngisdn_span_data_t)); - signal_data->ftdm_span = span; - span->signal_data = signal_data; - - chaniter = ftdm_span_get_chan_iterator(span, NULL); - for (curr = chaniter; curr; curr = ftdm_iterator_next(curr)) { - sngisdn_chan_data_t *chan_data = ftdm_calloc(1, sizeof(sngisdn_chan_data_t)); - chan_data->ftdmchan = ((ftdm_channel_t*)ftdm_iterator_current(curr)); - ((ftdm_channel_t*)ftdm_iterator_current(curr))->call_data = chan_data; - - } - ftdm_iterator_free(chaniter); - - if (ftmod_isdn_parse_cfg(ftdm_parameters, span) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "Failed to parse configuration\n"); - return FTDM_FAIL; - } - - if (signal_data->nfas.trunk) { - if (signal_data->nfas.trunk->num_spans == ++signal_data->nfas.trunk->num_spans_configured) { - int i; - ftdm_log(FTDM_LOG_DEBUG, "Starting stack configuration for all spans within trunkgroup:%s\n", signal_data->nfas.trunk->name); - - sngisdn_stack_cfg(signal_data->nfas.trunk->dchan->ftdm_span); - if (signal_data->nfas.trunk->backup) { - sngisdn_stack_cfg(signal_data->nfas.trunk->backup->ftdm_span); - } - - for (i = 0; i < signal_data->nfas.trunk->num_spans; i++) { - if (signal_data->nfas.trunk->spans[i] && - signal_data->nfas.trunk->spans[i]->nfas.sigchan == SNGISDN_NFAS_DCHAN_NONE) { - sngisdn_stack_cfg(signal_data->nfas.trunk->spans[i]->ftdm_span); - } - } - } else { - ftdm_log(FTDM_LOG_DEBUG, "Delaying span stack configuration until all spans within trunkgroup are started:%s\n", signal_data->nfas.trunk->name); - } - } else if (sngisdn_stack_cfg(span) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_CRIT, "Sangoma ISDN Stack configuration failed\n"); - return FTDM_FAIL; - } - - if (signal_data->cid_name_method == SNGISDN_CID_NAME_AUTO) { - switch (signal_data->switchtype) { - case SNGISDN_SWITCH_EUROISDN: - if (FTDM_SPAN_IS_BRI(span)) { - signal_data->cid_name_method = SNGISDN_CID_NAME_USR_USR_IE; - } else { - signal_data->cid_name_method = SNGISDN_CID_NAME_DISPLAY_IE; - } - break; - case SNGISDN_SWITCH_DMS100: - signal_data->cid_name_method = SNGISDN_CID_NAME_DISPLAY_IE; - break; - case SNGISDN_SWITCH_NI2: - case SNGISDN_SWITCH_5ESS: - case SNGISDN_SWITCH_4ESS: - signal_data->cid_name_method = SNGISDN_CID_NAME_FACILITY_IE; - break; - default: - break; - } - } - - if (signal_data->send_cid_name == SNGISDN_OPT_DEFAULT) { - switch (signal_data->switchtype) { - case SNGISDN_SWITCH_EUROISDN: -#ifdef SNGISDN_SUPPORT_CALLING_NAME_IN_FACILITY - case SNGISDN_SWITCH_NI2: - case SNGISDN_SWITCH_5ESS: - case SNGISDN_SWITCH_4ESS: -#endif - if (signal_data->signalling == SNGISDN_SIGNALING_NET) { - signal_data->send_cid_name = SNGISDN_OPT_TRUE; - } else { - signal_data->send_cid_name = SNGISDN_OPT_FALSE; - } - break; - case SNGISDN_SWITCH_DMS100: - signal_data->send_cid_name = SNGISDN_OPT_TRUE; - break; -#ifndef SNGISDN_SUPPORT_CALLING_NAME_IN_FACILITY - case SNGISDN_SWITCH_NI2: - case SNGISDN_SWITCH_5ESS: - case SNGISDN_SWITCH_4ESS: - signal_data->send_cid_name = SNGISDN_OPT_FALSE; - break; -#endif - default: - signal_data->send_cid_name = SNGISDN_OPT_FALSE; - break; - } - } else if (signal_data->send_cid_name == SNGISDN_OPT_TRUE) { - switch (signal_data->switchtype) { - case SNGISDN_SWITCH_NI2: - case SNGISDN_SWITCH_5ESS: - case SNGISDN_SWITCH_4ESS: -#ifndef SNGISDN_SUPPORT_CALLING_NAME_IN_FACILITY - ftdm_log(FTDM_LOG_WARNING, "Sending Calling Name in Facility IE not supported, please update your libsng_isdn library\n"); - signal_data->send_cid_name = SNGISDN_OPT_FALSE; -#endif - break; - case SNGISDN_SWITCH_INSNET: /* Don't know how to transmit caller ID name on INSNET */ - case SNGISDN_SWITCH_QSIG: /* It seems like QSIG does not support Caller ID */ - signal_data->send_cid_name = SNGISDN_OPT_FALSE; - break; - case SNGISDN_SWITCH_EUROISDN: - break; - default: - signal_data->send_cid_name = SNGISDN_OPT_FALSE; - break; - } - } - - span->start = ftdm_sangoma_isdn_start; - span->stop = ftdm_sangoma_isdn_stop; - span->signal_type = FTDM_SIGTYPE_ISDN; - span->outgoing_call = ftdm_sangoma_isdn_outgoing_call; - span->indicate = ftdm_sangoma_isdn_indicate; - span->channel_request = NULL; - span->signal_cb = sig_cb; - span->sig_queue_dtmf = ftdm_sangoma_isdn_dtmf; - span->get_channel_sig_status = ftdm_sangoma_isdn_get_chan_sig_status; - span->set_channel_sig_status = ftdm_sangoma_isdn_set_chan_sig_status; - span->get_span_sig_status = ftdm_sangoma_isdn_get_span_sig_status; - span->set_span_sig_status = ftdm_sangoma_isdn_set_span_sig_status; - span->state_map = &sangoma_isdn_state_map; - span->state_processor = ftdm_sangoma_isdn_process_state_change; - ftdm_set_flag(span, FTDM_SPAN_USE_CHAN_QUEUE); - ftdm_set_flag(span, FTDM_SPAN_USE_SIGNALS_QUEUE); - ftdm_set_flag(span, FTDM_SPAN_USE_PROCEED_STATE); - ftdm_set_flag(span, FTDM_SPAN_USE_SKIP_STATES); - ftdm_set_flag(span, FTDM_SPAN_NON_STOPPABLE); - ftdm_set_flag(span, FTDM_SPAN_USE_TRANSFER); - - if (FTDM_SPAN_IS_BRI(span)) { - sngisdn_set_span_avail_rate(span, SNGISDN_AVAIL_PWR_SAVING); - } - - /* Initialize scheduling context */ - ftdm_assert(ftdm_sched_create(&((sngisdn_span_data_t*)span->signal_data)->sched, "sngisdn_schedule") == FTDM_SUCCESS, "Failed to create a new schedule!!"); - - /* Initialize the event queue */ - ftdm_assert(ftdm_queue_create(&((sngisdn_span_data_t*)span->signal_data)->event_queue, SNGISDN_EVENT_QUEUE_SIZE) == FTDM_SUCCESS, "Failed to create a new queue!!"); - - ftdm_log(FTDM_LOG_INFO, "Finished configuring ftmod_sangoma_isdn span = %s\n", span->name); - return FTDM_SUCCESS; -} - -static FIO_SIG_LOAD_FUNCTION(ftdm_sangoma_isdn_init) -{ - unsigned i; - ftdm_log(FTDM_LOG_INFO, "Loading ftmod_sangoma_isdn...\n"); - - memset(&g_sngisdn_data, 0, sizeof(g_sngisdn_data)); - memset(&g_sngisdn_event_interface, 0, sizeof(g_sngisdn_event_interface)); - /* set callbacks */ - g_sngisdn_event_interface.cc.sng_con_ind = sngisdn_rcv_con_ind; - g_sngisdn_event_interface.cc.sng_con_cfm = sngisdn_rcv_con_cfm; - g_sngisdn_event_interface.cc.sng_cnst_ind = sngisdn_rcv_cnst_ind; - g_sngisdn_event_interface.cc.sng_disc_ind = sngisdn_rcv_disc_ind; - g_sngisdn_event_interface.cc.sng_rel_ind = sngisdn_rcv_rel_ind; - g_sngisdn_event_interface.cc.sng_dat_ind = sngisdn_rcv_dat_ind; - g_sngisdn_event_interface.cc.sng_sshl_ind = sngisdn_rcv_sshl_ind; - g_sngisdn_event_interface.cc.sng_sshl_cfm = sngisdn_rcv_sshl_cfm; - g_sngisdn_event_interface.cc.sng_rmrt_ind = sngisdn_rcv_rmrt_ind; - g_sngisdn_event_interface.cc.sng_rmrt_cfm = sngisdn_rcv_rmrt_cfm; - g_sngisdn_event_interface.cc.sng_flc_ind = sngisdn_rcv_flc_ind; - g_sngisdn_event_interface.cc.sng_fac_ind = sngisdn_rcv_fac_ind; - g_sngisdn_event_interface.cc.sng_sta_cfm = sngisdn_rcv_sta_cfm; - g_sngisdn_event_interface.cc.sng_srv_ind = sngisdn_rcv_srv_ind; - g_sngisdn_event_interface.cc.sng_srv_cfm = sngisdn_rcv_srv_cfm; - g_sngisdn_event_interface.cc.sng_rst_ind = sngisdn_rcv_rst_ind; - g_sngisdn_event_interface.cc.sng_rst_cfm = sngisdn_rcv_rst_cfm; - - g_sngisdn_event_interface.lg.sng_log = sngisdn_rcv_sng_log; - g_sngisdn_event_interface.lg.sng_assert = sngisdn_rcv_sng_assert; - - g_sngisdn_event_interface.sta.sng_phy_sta_ind = sngisdn_rcv_phy_ind; - g_sngisdn_event_interface.sta.sng_q921_sta_ind = sngisdn_rcv_q921_ind; - g_sngisdn_event_interface.sta.sng_q921_trc_ind = sngisdn_rcv_q921_trace; - g_sngisdn_event_interface.sta.sng_q931_sta_ind = sngisdn_rcv_q931_ind; - g_sngisdn_event_interface.sta.sng_q931_trc_ind = sngisdn_rcv_q931_trace; - g_sngisdn_event_interface.sta.sng_cc_sta_ind = sngisdn_rcv_cc_ind; - - g_sngisdn_event_interface.io.sng_l1_data_req = sngisdn_rcv_l1_data_req; - g_sngisdn_event_interface.io.sng_l1_cmd_req = sngisdn_rcv_l1_cmd_req; - - for(i=1;i<=MAX_VARIANTS;i++) { - ftdm_mutex_create(&g_sngisdn_data.ccs[i].mutex); - } - - /* initalize sng_isdn library */ - ftdm_assert_return(!sng_isdn_init(&g_sngisdn_event_interface), FTDM_FAIL, "Failed to initialize stack\n"); - - /* Load Stack General Configuration */ - sngisdn_start_gen_cfg(); - - return FTDM_SUCCESS; -} - -static FIO_SIG_UNLOAD_FUNCTION(ftdm_sangoma_isdn_unload) -{ - unsigned i; - ftdm_log(FTDM_LOG_INFO, "Starting ftmod_sangoma_isdn unload...\n"); - - sng_isdn_free(); - - for(i=1;i<=MAX_VARIANTS;i++) { - ftdm_mutex_destroy(&g_sngisdn_data.ccs[i].mutex); - } - - ftdm_log(FTDM_LOG_INFO, "Finished ftmod_sangoma_isdn unload!\n"); - return FTDM_SUCCESS; -} - -#define SANGOMA_ISDN_API_USAGE_TRACE "ftdm sangoma_isdn trace \n" -#define SANGOMA_ISDN_API_USAGE_SHOW_L1_STATS "ftdm sangoma_isdn l1_stats \n" -#define SANGOMA_ISDN_API_USAGE_SHOW_SPANS "ftdm sangoma_isdn show_spans []\n" - -#define SANGOMA_ISDN_API_USAGE "\t"SANGOMA_ISDN_API_USAGE_TRACE \ - "\t"SANGOMA_ISDN_API_USAGE_SHOW_L1_STATS \ - "\t"SANGOMA_ISDN_API_USAGE_SHOW_SPANS - -static FIO_API_FUNCTION(ftdm_sangoma_isdn_api) -{ - ftdm_status_t status = FTDM_EINVAL; - char *mycmd = NULL, *argv[10] = { 0 }; - int argc = 0; - - if (data) { - mycmd = ftdm_strdup(data); - argc = ftdm_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); - } - - /*ftdm_log(FTDM_LOG_DEBUG, "Sangoma argc:%d argv[0]:%s argv[1]:%s argv[2]:%s \n", argc, argv[0], argv[1], argv[2]);*/ - if (argc <= 0) { - ftdm_log(FTDM_LOG_ERROR, "No parameters provided\n"); - goto done; - } - - /* TODO: Move functions to table + function pointers */ - if (!strcasecmp(argv[0], "trace")) { - char *trace_opt; - - ftdm_span_t *span; - - if (argc < 3) { - ftdm_log(FTDM_LOG_ERROR, "Usage: %s\n", SANGOMA_ISDN_API_USAGE_TRACE); - status = FTDM_FAIL; - goto done; - } - trace_opt = argv[1]; - - status = ftdm_span_find_by_name(argv[2], &span); - if (FTDM_SUCCESS != status) { - stream->write_function(stream, "-ERR failed to find span by name %s\n", argv[2]); - - status = FTDM_FAIL; - goto done; - } - - if (!strcasecmp(trace_opt, "q921")) { - status = sngisdn_activate_trace(span, SNGISDN_TRACE_Q921); - } else if (!strcasecmp(trace_opt, "q931")) { - status = sngisdn_activate_trace(span, SNGISDN_TRACE_Q931); - } else if (!strcasecmp(trace_opt, "disable")) { - status = sngisdn_activate_trace(span, SNGISDN_TRACE_DISABLE); - } else { - stream->write_function(stream, "-ERR invalid trace option \n"); - status = FTDM_FAIL; - } - goto done; - } - - if (!strcasecmp(argv[0], "l1_stats")) { - ftdm_span_t *span; - if (argc < 2) { - stream->write_function(stream, "Usage: %s\n", SANGOMA_ISDN_API_USAGE_SHOW_L1_STATS); - status = FTDM_FAIL; - goto done; - } - status = ftdm_span_find_by_name(argv[1], &span); - if (FTDM_SUCCESS != status) { - stream->write_function(stream, "-ERR failed to find span with name %s\n", argv[1]); - - status = FTDM_FAIL; - goto done; - } - status = sngisdn_show_l1_stats(stream, span); - goto done; - } - - if (!strcasecmp(argv[0], "show_spans")) { - ftdm_span_t *span = NULL; - if (argc == 2) { - status = ftdm_span_find_by_name(argv[1], &span); - if (FTDM_SUCCESS != status) { - stream->write_function(stream, "-ERR failed to find span with name %s\n", argv[1]); - - stream->write_function(stream, "Usage: %s\n", SANGOMA_ISDN_API_USAGE_SHOW_SPANS); - status = FTDM_FAIL; - goto done; - } - status = sngisdn_show_span(stream, span); - goto done; - } - status = sngisdn_show_spans(stream); - goto done; - } - - if (!strcasecmp(argv[0], "check_ids")) { - status = sngisdn_check_free_ids(); - goto done; - } - if (!strcasecmp(argv[0], "check_mem")) { - sngisdn_get_memory_info(); - } -done: - switch (status) { - case FTDM_SUCCESS: - stream->write_function(stream, "Command executed OK\n"); - break; - case FTDM_EINVAL: - stream->write_function(stream, "Invalid arguments [%s]\n", mycmd); - stream->write_function(stream, "Usage:\n%s\n", SANGOMA_ISDN_API_USAGE); - break; - default: - /* FTDM_FAIL - Do nothing since we already printed the cause of the error */ - break; - } - - /* Return SUCCESS because we do not want to print the general FTDM usage list */ - status = FTDM_SUCCESS; - - ftdm_safe_free(mycmd); - return status; -} - - -static FIO_IO_LOAD_FUNCTION(ftdm_sangoma_isdn_io_init) -{ - memset(&g_sngisdn_io_interface, 0, sizeof(g_sngisdn_io_interface)); - - g_sngisdn_io_interface.name = "sangoma_isdn"; - g_sngisdn_io_interface.api = ftdm_sangoma_isdn_api; - - *fio = &g_sngisdn_io_interface; - - return FTDM_SUCCESS; -} - -EX_DECLARE_DATA ftdm_module_t ftdm_module = -{ - "sangoma_isdn", /* char name[256]; */ - ftdm_sangoma_isdn_io_init, /* fio_io_load_t */ - NULL, /* fio_io_unload_t */ - ftdm_sangoma_isdn_init, /* fio_sig_load_t */ - NULL, /* fio_sig_configure_t */ - ftdm_sangoma_isdn_unload, /* fio_sig_unload_t */ - ftdm_sangoma_isdn_span_config /* fio_configure_span_signaling_t */ -}; - - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ - -/******************************************************************************/ - - diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h deleted file mode 100644 index 64c1a20999..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h +++ /dev/null @@ -1,613 +0,0 @@ -/* - * Copyright (c) 2010, Sangoma Technologies - * David Yat Sin - * Moises Silva - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __FTMOD_SNG_ISDN_H__ -#define __FTMOD_SNG_ISDN_H__ - -#include -#include -#include -#ifdef HAVE_STDINT_H -#include -#endif -#ifdef HAVE_UNISTD_H -#include -#endif -#include - -#include "private/ftdm_core.h" -#include "ftmod_sangoma_isdn_user.h" - -#ifdef WIN32 -#include -#else -#include -#endif - -/* Theoretical limit for MAX_SPANS_PER_NFAS_LINK is 31, - but set to 8 for now to save some memory */ - -#define MAX_SPANS_PER_NFAS_LINK 16 -#define MAX_NFAS_GROUPS 16 -#define NUM_E1_CHANNELS_PER_SPAN 32 -#define NUM_T1_CHANNELS_PER_SPAN 24 -#define NUM_BRI_CHANNELS_PER_SPAN 2 -#define SNGISDN_EVENT_QUEUE_SIZE 100 -#define SNGISDN_EVENT_POLL_RATE 100 -#define SNGISDN_NUM_LOCAL_NUMBERS 8 -#define SNGISDN_DCHAN_QUEUE_LEN 200 -#define MAX_NFAS_GROUP_NAME 50 - -#define NSG - -#ifndef MI_NOTIFY -#define MI_NOTIFY 0x14 -#endif - -typedef enum { - FLAG_RESET_RX = (1 << 0), - FLAG_RESET_TX = (1 << 1), - FLAG_REMOTE_REL = (1 << 2), - FLAG_LOCAL_REL = (1 << 3), - FLAG_REMOTE_ABORT = (1 << 4), - FLAG_LOCAL_ABORT = (1 << 5), - FLAG_GLARE = (1 << 6), - FLAG_DELAYED_REL = (1 << 7), - FLAG_SENT_PROCEED = (1 << 8), - FLAG_SEND_DISC = (1 << 9), - /* Used for BRI only, flag is set after we request line CONNECTED */ - FLAG_ACTIVATING = (1 << 10), - /* Used when we receive an ALERT msg + inband tones ready */ - FLAG_MEDIA_READY = (1 << 11), - /* Set when we already sent a Channel ID IE */ - FLAG_SENT_CHAN_ID = (1 << 12), - /* Set when we already sent a Connect */ - FLAG_SENT_CONNECT = (1 << 13), -} sngisdn_flag_t; - - -typedef enum { - SNGISDN_SWITCH_INVALID = 0, /* invalid */ - SNGISDN_SWITCH_NI2 , /* national isdn-2 */ - SNGISDN_SWITCH_5ESS, /* att 5ess */ - SNGISDN_SWITCH_4ESS, /* att 4ess */ - SNGISDN_SWITCH_DMS100, /* nt dms100 */ - SNGISDN_SWITCH_EUROISDN,/* etsi */ - SNGISDN_SWITCH_QSIG, /* etsi qsig */ - SNGISDN_SWITCH_INSNET, /* int - net */ -} sngisdn_switchtype_t; - -typedef enum { - SNGISDN_SIGNALING_INVALID = 0, /* invalid */ - SNGISDN_SIGNALING_CPE , /* customer side emulation */ - SNGISDN_SIGNALING_NET, /* network side emulation */ -} sngisdn_signalingtype_t; - -typedef enum { - SNGISDN_TRACE_DISABLE = 0, - SNGISDN_TRACE_Q921 = 1, - SNGISDN_TRACE_Q931 = 2, -} sngisdn_tracetype_t; - -typedef enum { - SNGISDN_OPT_DEFAULT = 0, - SNGISDN_OPT_TRUE = 1, - SNGISDN_OPT_FALSE = 2, -} sngisdn_opt_t; - -typedef enum { - SNGISDN_EARLY_MEDIA_ON_PROCEED = (1 << 0), - SNGISDN_EARLY_MEDIA_ON_PROGRESS = (1 << 1), - SNGISDN_EARLY_MEDIA_ON_ALERT= (1 << 2), -} sngisdn_early_media_opt_t; - -typedef enum { - SNGISDN_AVAIL_DOWN = 1, - SNGISDN_AVAIL_PWR_SAVING = 5, - SNGISDN_AVAIL_UP = 10, -} sngisdn_avail_t; - -typedef enum { - SNGISDN_CID_NAME_AUTO, - SNGISDN_CID_NAME_DISPLAY_IE, - SNGISDN_CID_NAME_USR_USR_IE, - SNGISDN_CID_NAME_FACILITY_IE, -} sngisdn_cid_name_t; - -typedef enum { - SNGISDN_EVENT_CON_IND = 1, - SNGISDN_EVENT_CON_CFM, - SNGISDN_EVENT_CNST_IND, - SNGISDN_EVENT_DISC_IND, - SNGISDN_EVENT_REL_IND, - SNGISDN_EVENT_DAT_IND, - SNGISDN_EVENT_SSHL_IND, - SNGISDN_EVENT_SSHL_CFM, - SNGISDN_EVENT_RMRT_IND, - SNGISDN_EVENT_RMRT_CFM, - SNGISDN_EVENT_FLC_IND, - SNGISDN_EVENT_FAC_IND, - SNGISDN_EVENT_STA_CFM, - SNGISDN_EVENT_SRV_IND, - SNGISDN_EVENT_SRV_CFM, - SNGISDN_EVENT_RST_CFM, - SNGISDN_EVENT_RST_IND, -} ftdm_sngisdn_event_id_t; - -typedef struct ftdm_sngisdn_prog_ind { - ftdm_sngisdn_progind_loc_t loc; /* location */ - ftdm_sngisdn_progind_descr_t descr; /* description */ -} ftdm_sngisdn_progind_t; - -/* Only timers that can be cancelled are listed here */ -#define SNGISDN_NUM_CHAN_TIMERS 2 -/* Increase SNGISDN_NUM_CHAN_TIMERS as number of ftdm_sngisdn_chan_timer_t increases */ -typedef enum { - SNGISDN_CHAN_TIMER_FACILITY, - SNGISDN_CHAN_TIMER_ATT_TRANSFER, -} ftdm_sngisdn_chan_timer_t; - -#define SNGISDN_NUM_SPAN_TIMERS 1 -/* Increase SNGISDN_NUM_SPAN_TIMERS as number of ftdm_sngisdn_spanan_timer_t increases */ -typedef enum { - SNGISDN_SPAN_TIMER_RESTART, -} ftdm_sngisdn_span_timer_t; - -typedef struct sngisdn_glare_data { - int16_t suId; - uint32_t suInstId; - uint32_t spInstId; - int16_t dChan; - ConEvnt setup; - uint8_t ces; -} sngisdn_glare_data_t; - -typedef enum { - SNGISDN_TRANSFER_NONE = 0, /* Default value, no transfer being done */ - SNGISDN_TRANSFER_ATT_COURTESY_VRU, - SNGISDN_TRANSFER_ATT_COURTESY_VRU_DATA, - SNGISDN_TRANSFER_INVALID, -} sngisdn_transfer_type_t; -#define SNGISDN_TRANSFER_TYPE_STRINGS "NONE", "ATT_COURTESY_VRU", "ATT_COURTERY_VRU_DATA", "INVALID" -SNGISDN_STR2ENUM_P(ftdm_str2sngisdn_transfer_type, sngisdn_transfer_type2str, sngisdn_transfer_type_t) - -/* From section 4.2 of TR50075, max length of data is 100 when single UUI is sent */ -#define COURTESY_TRANSFER_MAX_DATA_SIZE 100 - -typedef struct _att_courtesy_vru -{ - char dtmf_digits [20]; - char data[COURTESY_TRANSFER_MAX_DATA_SIZE]; -} att_courtesy_vru_t; - -typedef struct _sngisdn_transfer_data -{ - sngisdn_transfer_type_t type; /* Specifies which type of transfer is being used */ - ftdm_transfer_response_t response; - union - { - att_courtesy_vru_t att_courtesy_vru; - } tdata; -} sngisdn_transfer_data_t; - -/* Channel specific data */ -typedef struct sngisdn_chan_data { - ftdm_channel_t *ftdmchan; - uint32_t flags; - uint8_t ces; /* used only for BRI, otherwise always 0 */ - uint8_t dchan_id; - uint16_t call_ref; /* Q.931 call reference, only valid for ETSI/INSNET/QSIG */ - uint32_t suInstId; /* instance ID generated locally */ - uint32_t spInstId; /* instance ID generated by stack */ - - uint8_t globalFlg; - sngisdn_glare_data_t glare; - ftdm_timer_id_t timers[SNGISDN_NUM_CHAN_TIMERS]; - sngisdn_transfer_data_t transfer_data; - - /* variables saved here will be sent to the user application - on next SIGEVENT_XXX */ - ftdm_hash_t* variables; - - /* raw_data saved here will be sent to the user application - on next SIGEVENT_XXX */ - void *raw_data; - ftdm_size_t raw_data_len; -} sngisdn_chan_data_t; - -struct sngisdn_nfas_data; -typedef struct sngisdn_nfas_data sngisdn_nfas_data_t; - -typedef enum { - SNGISDN_NFAS_DCHAN_NONE, - SNGISDN_NFAS_DCHAN_PRIMARY, - SNGISDN_NFAS_DCHAN_BACKUP, -} sngisdn_nfas_sigchan_t; - -/* Span specific data */ -typedef struct sngisdn_span_data { - ftdm_span_t *ftdm_span; - ftdm_channel_t *dchan; - uint8_t link_id; - uint8_t switchtype; - uint8_t signalling; /* SNGISDN_SIGNALING_CPE or SNGISDN_SIGNALING_NET */ - uint8_t cc_id; - ftdm_signaling_status_t sigstatus; - - uint8_t tei; - uint8_t min_digits; - uint8_t trace_flags; /* TODO change to bit map of sngisdn_tracetype_t */ - uint8_t early_media_flags; /* bit map of ftdm_sngisdn_early_media_opt_t */ - uint8_t overlap_dial; - uint8_t setup_arb; - uint8_t facility_ie_decode; - uint8_t facility; - int32_t facility_timeout; - uint8_t att_remove_dtmf; - int32_t transfer_timeout; - uint8_t num_local_numbers; - uint8_t ignore_cause_value; - uint8_t trace_q931; /* TODO: combine with trace_flags */ - uint8_t trace_q921; /* TODO: combine with trace_flags */ - uint8_t raw_trace_q931; /* TODO: combine with trace_flags */ - uint8_t raw_trace_q921; /* TODO: combine with trace_flags */ - uint8_t timer_t3; - uint8_t restart_opt; - uint8_t restart_timeout; - uint8_t force_sending_complete; - uint8_t cid_name_method; - uint8_t send_cid_name; - uint8_t send_connect_ack; - uint8_t dl_request_pending; /* Whether we have a DL request pending */ - - - int32_t timer_t301; - int32_t timer_t302; - int32_t timer_t303; - int32_t timer_t304; - int32_t timer_t305; - int32_t timer_t306; - int32_t timer_t307; - int32_t timer_t308; - int32_t timer_t310; - int32_t timer_t312; - int32_t timer_t313; - int32_t timer_t314; - int32_t timer_t316; - int32_t timer_t318; - int32_t timer_t319; - int32_t timer_t322; - char* local_numbers[SNGISDN_NUM_LOCAL_NUMBERS]; - ftdm_timer_id_t timers[SNGISDN_NUM_SPAN_TIMERS]; - ftdm_sched_t *sched; - ftdm_queue_t *event_queue; - - struct nfas_info { - sngisdn_nfas_data_t *trunk; - sngisdn_nfas_sigchan_t sigchan; - uint8_t interface_id; - } nfas; - - uint32_t num_chans; - sngisdn_chan_data_t *channels[NUM_E1_CHANNELS_PER_SPAN]; -} sngisdn_span_data_t; - -typedef struct sngisdn_event_data { - - int16_t suId; - int16_t dChan; - uint32_t suInstId; - uint32_t spInstId; - uint8_t ces; - uint8_t action; - uint8_t evntType; - - sngisdn_chan_data_t *sngisdn_info; - sngisdn_span_data_t *signal_data; - - ftdm_sngisdn_event_id_t event_id; - - union - { - ConEvnt conEvnt; - CnStEvnt cnStEvnt; - DiscEvnt discEvnt; - RelEvnt relEvnt; - InfoEvnt infoEvnt; - SsHlEvnt ssHlEvnt; - RmRtEvnt rmRtEvnt; - StaEvnt staEvnt; - FacEvnt facEvnt; - Srv srvEvnt; - Rst rstEvnt; - }event; - -} sngisdn_event_data_t; - -struct sngisdn_nfas_data { - char name[MAX_NFAS_GROUP_NAME]; - - char dchan_span_name[20]; - sngisdn_span_data_t *dchan; /* Span that contains primary d-channel */ - - char backup_span_name[20]; - sngisdn_span_data_t *backup; /* Span that contains backup d-channel */ - uint8_t num_spans; /* Number of spans within this NFAS */ - uint8_t num_spans_configured; - sngisdn_span_data_t *spans[MAX_SPANS_PER_NFAS_LINK+1]; //indexed by logical span id -}; - -typedef struct sngisdn_cc { - /* TODO: use flags instead of config_done and activation_done */ - uint8_t config_done; - uint8_t activation_done; - uint8_t switchtype; - ftdm_trunk_type_t trunktype; - uint32_t last_suInstId; - ftdm_mutex_t *mutex; - sngisdn_chan_data_t *active_spInstIds[MAX_INSTID+1]; - sngisdn_chan_data_t *active_suInstIds[MAX_INSTID+1]; -}sngisdn_cc_t; - -/* Global sngisdn data */ -typedef struct ftdm_sngisdn_data { - uint8_t gen_config_done; - uint8_t num_cc; /* 1 ent per switchtype */ - struct sngisdn_cc ccs[MAX_VARIANTS+1]; - uint8_t num_nfas; - sngisdn_nfas_data_t nfass[MAX_NFAS_GROUPS+1]; - sngisdn_span_data_t *spans[MAX_L1_LINKS+1]; /* spans are indexed by link_id */ - -#ifdef SANGOMA_ISDN_CHAN_ID_INVERT_BIT - /* Since this is a global configuration, place it here instead of sngisdn_span_data_t */ - uint8_t chan_id_invert_extend_bit; -#endif -}ftdm_sngisdn_data_t; - -typedef struct ftdm2trillium -{ - uint8_t ftdm_val; - uint8_t trillium_val; -}ftdm2trillium_t; - - -/* TODO implement these 2 functions */ -#define ISDN_FUNC_TRACE_ENTER(a) -#define ISDN_FUNC_TRACE_EXIT(a) - -/* Global Structs */ -extern ftdm_sngisdn_data_t g_sngisdn_data; - -/* Configuration functions */ -ftdm_status_t ftmod_isdn_parse_cfg(ftdm_conf_parameter_t *ftdm_parameters, ftdm_span_t *span); - -/* Support functions */ -uint32_t get_unique_suInstId(int16_t cc_id); -void clear_call_data(sngisdn_chan_data_t *sngisdn_info); -void clear_call_glare_data(sngisdn_chan_data_t *sngisdn_info); -ftdm_status_t get_ftdmchan_by_suInstId(int16_t cc_id, uint32_t suInstId, sngisdn_chan_data_t **sngisdn_data); -ftdm_status_t get_ftdmchan_by_spInstId(int16_t cc_id, uint32_t spInstId, sngisdn_chan_data_t **sngisdn_data); - -ftdm_status_t sngisdn_set_span_avail_rate(ftdm_span_t *span, sngisdn_avail_t avail); -ftdm_status_t sngisdn_set_chan_avail_rate(ftdm_channel_t *chan, sngisdn_avail_t avail); -void sngisdn_set_span_sig_status(ftdm_span_t *ftdmspan, ftdm_signaling_status_t status); -void sngisdn_set_chan_sig_status(ftdm_channel_t *ftdmchan, ftdm_signaling_status_t status); - -ftdm_status_t sngisdn_activate_trace(ftdm_span_t *span, sngisdn_tracetype_t trace_opt); - - -void stack_hdr_init(Header *hdr); -void stack_pst_init(Pst *pst); - -/* Outbound Call Control functions */ -void sngisdn_snd_setup(ftdm_channel_t *ftdmchan); -void sngisdn_snd_setup_ack(ftdm_channel_t *ftdmchan); -void sngisdn_snd_proceed(ftdm_channel_t *ftdmchan, ftdm_sngisdn_progind_t prog_ind); -void sngisdn_snd_progress(ftdm_channel_t *ftdmchan, ftdm_sngisdn_progind_t prog_ind); -void sngisdn_snd_alert(ftdm_channel_t *ftdmchan, ftdm_sngisdn_progind_t prog_ind); -void sngisdn_snd_notify_req(ftdm_channel_t *ftdmchan); -void sngisdn_snd_connect(ftdm_channel_t *ftdmchan); -void sngisdn_snd_disconnect(ftdm_channel_t *ftdmchan); -void sngisdn_snd_release(ftdm_channel_t *ftdmchan, uint8_t glare); -void sngisdn_snd_reset(ftdm_channel_t *ftdmchan); -void sngisdn_snd_con_complete(ftdm_channel_t *ftdmchan); -void sngisdn_snd_fac_req(ftdm_channel_t *ftdmchan); -void sngisdn_snd_dl_req(ftdm_channel_t *ftdmchan); -void sngisdn_snd_status_enq(ftdm_channel_t *ftdmchan); -void sngisdn_snd_restart(ftdm_channel_t *ftdmchan); -void sngisdn_snd_data(ftdm_channel_t *dchan, uint8_t *data, ftdm_size_t len); -void sngisdn_snd_event(sngisdn_span_data_t *signal_data, ftdm_oob_event_t event); - -/* Inbound Call Control functions */ -void sngisdn_rcv_con_ind(int16_t suId, uint32_t suInstId, uint32_t spInstId, ConEvnt *conEvnt, int16_t dChan, uint8_t ces); -void sngisdn_rcv_con_cfm(int16_t suId, uint32_t suInstId, uint32_t spInstId, CnStEvnt *cnStEvnt, int16_t dChan, uint8_t ces); -void sngisdn_rcv_cnst_ind(int16_t suId, uint32_t suInstId, uint32_t spInstId, CnStEvnt *cnStEvnt, uint8_t evntType, int16_t dChan, uint8_t ces); -void sngisdn_rcv_disc_ind(int16_t suId, uint32_t suInstId, uint32_t spInstId, DiscEvnt *discEvnt); -void sngisdn_rcv_rel_ind(int16_t suId, uint32_t suInstId, uint32_t spInstId, RelEvnt *relEvnt); -void sngisdn_rcv_dat_ind(int16_t suId, uint32_t suInstId, uint32_t spInstId, InfoEvnt *infoEvnt); -void sngisdn_rcv_sshl_ind(int16_t suId, uint32_t suInstId, uint32_t spInstId, SsHlEvnt *ssHlEvnt, uint8_t action); -void sngisdn_rcv_sshl_cfm(int16_t suId, uint32_t suInstId, uint32_t spInstId, SsHlEvnt *ssHlEvnt, uint8_t action); -void sngisdn_rcv_rmrt_ind(int16_t suId, uint32_t suInstId, uint32_t spInstId, RmRtEvnt *rmRtEvnt, uint8_t action); -void sngisdn_rcv_rmrt_cfm(int16_t suId, uint32_t suInstId, uint32_t spInstId, RmRtEvnt *rmRtEvnt, uint8_t action); -void sngisdn_rcv_flc_ind(int16_t suId, uint32_t suInstId, uint32_t spInstId, StaEvnt *staEvnt); -void sngisdn_rcv_fac_ind(int16_t suId, uint32_t suInstId, uint32_t spInstId, FacEvnt *facEvnt, uint8_t evntType, int16_t dChan, uint8_t ces); -void sngisdn_rcv_sta_cfm(int16_t suId, uint32_t suInstId, uint32_t spInstId, StaEvnt *staEvnt); -void sngisdn_rcv_srv_ind(int16_t suId, Srv *srvEvnt, int16_t dChan, uint8_t ces); -void sngisdn_rcv_srv_cfm(int16_t suId, Srv *srvEvnt, int16_t dChan, uint8_t ces); -void sngisdn_rcv_rst_cfm(int16_t suId, Rst *rstEvnt, int16_t dChan, uint8_t ces, uint8_t evntType); -void sngisdn_rcv_rst_ind(int16_t suId, Rst *rstEvnt, int16_t dChan, uint8_t ces, uint8_t evntType); -int16_t sngisdn_rcv_l1_data_req(uint16_t spId, sng_l1_frame_t *l1_frame); -int16_t sngisdn_rcv_l1_cmd_req(uint16_t spId, sng_l1_cmd_t *l1_cmd); - - -void sngisdn_process_con_ind (sngisdn_event_data_t *sngisdn_event); -void sngisdn_process_con_cfm (sngisdn_event_data_t *sngisdn_event); -void sngisdn_process_cnst_ind (sngisdn_event_data_t *sngisdn_event); -void sngisdn_process_disc_ind (sngisdn_event_data_t *sngisdn_event); -void sngisdn_process_rel_ind (sngisdn_event_data_t *sngisdn_event); -void sngisdn_process_dat_ind (sngisdn_event_data_t *sngisdn_event); -void sngisdn_process_sshl_ind (sngisdn_event_data_t *sngisdn_event); -void sngisdn_process_sshl_cfm (sngisdn_event_data_t *sngisdn_event); -void sngisdn_process_rmrt_ind (sngisdn_event_data_t *sngisdn_event); -void sngisdn_process_rmrt_cfm (sngisdn_event_data_t *sngisdn_event); -void sngisdn_process_flc_ind (sngisdn_event_data_t *sngisdn_event); -void sngisdn_process_fac_ind (sngisdn_event_data_t *sngisdn_event); -void sngisdn_process_sta_cfm (sngisdn_event_data_t *sngisdn_event); - -void sngisdn_process_srv_ind (sngisdn_event_data_t *sngisdn_event); -void sngisdn_process_srv_cfm (sngisdn_event_data_t *sngisdn_event); -void sngisdn_process_rst_cfm (sngisdn_event_data_t *sngisdn_event); -void sngisdn_process_rst_ind (sngisdn_event_data_t *sngisdn_event); - -void sngisdn_rcv_phy_ind(SuId suId, Reason reason); -void sngisdn_rcv_q921_ind(BdMngmt *status); - -void sngisdn_trace_interpreted_q921(sngisdn_span_data_t *signal_data, ftdm_trace_dir_t dir, uint8_t *data, uint32_t data_len); -void sngisdn_trace_interpreted_q931(sngisdn_span_data_t *signal_data, ftdm_trace_dir_t dir, uint8_t *data, uint32_t data_len); -void sngisdn_trace_raw_q921(sngisdn_span_data_t *signal_data, ftdm_trace_dir_t dir, uint8_t *data, uint32_t data_len); -void sngisdn_trace_raw_q931(sngisdn_span_data_t *signal_data, ftdm_trace_dir_t dir, uint8_t *data, uint32_t data_len); - -void sngisdn_get_memory_info(void); - -ftdm_status_t sng_isdn_activate_trace(ftdm_span_t *span, sngisdn_tracetype_t trace_opt); -ftdm_status_t sngisdn_check_free_ids(void); - -void sngisdn_rcv_q921_trace(BdMngmt *trc, Buffer *mBuf); -void sngisdn_rcv_q931_ind(InMngmt *status); -void sngisdn_rcv_q931_trace(InMngmt *trc, Buffer *mBuf); -void sngisdn_rcv_cc_ind(CcMngmt *status); -void sngisdn_rcv_sng_log(uint8_t level, char *fmt,...); -void sngisdn_rcv_sng_assert(char *message); - -#ifdef NETBORDER_CALL_REF -ftdm_status_t get_callref(ftdm_channel_t *ftdmchan, BCCallRef* callRef); -#endif -ftdm_status_t get_calling_num(ftdm_channel_t *ftdmchan, CgPtyNmb *cgPtyNmb); -ftdm_status_t get_calling_num2(ftdm_channel_t *ftdmchan, CgPtyNmb *cgPtyNmb); -ftdm_status_t get_called_num(ftdm_channel_t *ftdmchan, CdPtyNmb *cdPtyNmb); -ftdm_status_t get_redir_num(ftdm_channel_t *ftdmchan, RedirNmb *redirNmb); -ftdm_status_t get_calling_name(ftdm_channel_t *ftdmchan, ConEvnt *conEvnt); -ftdm_status_t get_calling_subaddr(ftdm_channel_t *ftdmchan, CgPtySad *cgPtySad); -ftdm_status_t get_prog_ind_ie(ftdm_channel_t *ftdmchan, ProgInd *progInd); -ftdm_status_t get_facility_ie(ftdm_channel_t *ftdmchan, FacilityStr *facilityStr); -ftdm_status_t get_facility_ie_str(ftdm_channel_t *ftdmchan, uint8_t *data, uint8_t data_len); -ftdm_status_t get_network_specific_fac(ftdm_channel_t *ftdmchan, NetFac *netFac); - -ftdm_status_t set_calling_num(ftdm_channel_t *ftdmchan, CgPtyNmb *cgPtyNmb); -ftdm_status_t set_calling_num2(ftdm_channel_t *ftdmchan, CgPtyNmb *cgPtyNmb); -ftdm_status_t set_called_num(ftdm_channel_t *ftdmchan, CdPtyNmb *cdPtyNmb); -ftdm_status_t set_redir_num(ftdm_channel_t *ftdmchan, RedirNmb *redirNmb); -ftdm_status_t set_calling_name(ftdm_channel_t *ftdmchan, ConEvnt *conEvnt); -ftdm_status_t set_calling_subaddr(ftdm_channel_t *ftdmchan, CgPtySad *cgPtySad); -ftdm_status_t set_called_subaddr(ftdm_channel_t *ftdmchan, CdPtySad *cdPtySad); -ftdm_status_t set_prog_ind_ie(ftdm_channel_t *ftdmchan, ProgInd *progInd, ftdm_sngisdn_progind_t prog_ind); -ftdm_status_t set_bear_cap_ie(ftdm_channel_t *ftdmchan, BearCap *bearCap); -ftdm_status_t set_network_specific_fac(ftdm_channel_t *ftdmchan, NetFac *netFac); -ftdm_status_t set_chan_id_ie(ftdm_channel_t *ftdmchan, ChanId *chanId); -ftdm_status_t set_restart_ind_ie(ftdm_channel_t *ftdmchan, RstInd *rstInd); -ftdm_status_t set_facility_ie(ftdm_channel_t *ftdmchan, FacilityStr *facilityStr); -ftdm_status_t set_facility_ie_str(ftdm_channel_t *ftdmchan, uint8_t *data, uint8_t *data_len); -ftdm_status_t set_user_to_user_ie(ftdm_channel_t *ftdmchan, UsrUsr *usrUsr); -ftdm_status_t set_cause_ie(ftdm_channel_t *ftdmchan, CauseDgn *causeDgn); -ftdm_status_t set_not_ind_ie(ftdm_channel_t *ftdmchan, NotInd *notInd); - -ftdm_status_t sngisdn_add_var(sngisdn_chan_data_t *sngisdn_info, const char* var, const char* val); -ftdm_status_t sngisdn_add_raw_data(sngisdn_chan_data_t *sngisdn_info, uint8_t* data, ftdm_size_t data_len); -ftdm_status_t sngisdn_clear_data(sngisdn_chan_data_t *sngisdn_info); -void sngisdn_send_signal(sngisdn_chan_data_t *sngisdn_info, ftdm_signal_event_t event_id); - -uint8_t sngisdn_get_infoTranCap_from_user(ftdm_bearer_cap_t bearer_capability); -uint8_t sngisdn_get_usrInfoLyr1Prot_from_user(ftdm_user_layer1_prot_t layer1_prot); -ftdm_bearer_cap_t sngisdn_get_infoTranCap_from_stack(uint8_t bearer_capability); -ftdm_user_layer1_prot_t sngisdn_get_usrInfoLyr1Prot_from_stack(uint8_t layer1_prot); - -ftdm_status_t sngisdn_transfer(ftdm_channel_t *ftdmchan); -ftdm_status_t sngisdn_att_transfer_process_dtmf(ftdm_channel_t *ftdmchan, const char* dtmf); - -static __inline__ uint32_t sngisdn_test_flag(sngisdn_chan_data_t *sngisdn_info, sngisdn_flag_t flag) -{ - return (uint32_t) sngisdn_info->flags & flag; -} -static __inline__ void sngisdn_clear_flag(sngisdn_chan_data_t *sngisdn_info, sngisdn_flag_t flag) -{ - sngisdn_info->flags &= ~flag; -} - -static __inline__ void sngisdn_set_flag(sngisdn_chan_data_t *sngisdn_info, sngisdn_flag_t flag) -{ - sngisdn_info->flags |= flag; -} - -#define sngisdn_set_trace_flag(obj, flag) ((obj)->trace_flags |= (flag)) -#define sngisdn_clear_trace_flag(obj, flag) ((obj)->trace_flags &= ~(flag)) -#define sngisdn_test_trace_flag(obj, flag) ((obj)->trace_flags & flag) - - -void handle_sng_log(uint8_t level, char *fmt,...); -void sngisdn_delayed_setup(void* p_sngisdn_info); -void sngisdn_delayed_release(void* p_sngisdn_info); -void sngisdn_delayed_release_nfas(void *p_sngisdn_info); -void sngisdn_delayed_connect(void* p_sngisdn_info); -void sngisdn_delayed_disconnect(void* p_sngisdn_info); -void sngisdn_facility_timeout(void* p_sngisdn_info); -void sngisdn_t3_timeout(void* p_sngisdn_info); -void sngisdn_restart_timeout(void* p_signal_data); -void sngisdn_delayed_dl_req(void* p_signal_data); - -/* Stack management functions */ -ftdm_status_t sngisdn_start_gen_cfg(void); -ftdm_status_t sngisdn_stack_cfg(ftdm_span_t *span); -ftdm_status_t sngisdn_stack_start(ftdm_span_t *span); -ftdm_status_t sngisdn_stack_stop(ftdm_span_t *span); -ftdm_status_t sngisdn_wake_up_phy(ftdm_span_t *span); -sngisdn_span_data_t *sngisdn_dchan(sngisdn_span_data_t *signal_data); - -ftdm_status_t sngisdn_show_l1_stats(ftdm_stream_handle_t *stream, ftdm_span_t *span); -ftdm_status_t sngisdn_show_spans(ftdm_stream_handle_t *stream); -ftdm_status_t sngisdn_show_span(ftdm_stream_handle_t *stream, ftdm_span_t *span); - -#endif /* __FTMOD_SNG_ISDN_H__ */ - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ - -/******************************************************************************/ diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c deleted file mode 100644 index 31a1a5b69f..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c +++ /dev/null @@ -1,657 +0,0 @@ -/* - * Copyright (c) 2010, Sangoma Technologies - * David Yat Sin - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ - -#include "ftmod_sangoma_isdn.h" - -static ftdm_status_t parse_timer(const char* val, int32_t *target); -static ftdm_status_t parse_switchtype(const char* switch_name, ftdm_span_t *span); -static ftdm_status_t parse_signalling(const char* signalling, ftdm_span_t *span); -static ftdm_status_t parse_trunkgroup(const char *_trunkgroup); -static ftdm_status_t add_local_number(const char* val, ftdm_span_t *span); -static ftdm_status_t parse_yesno(const char* var, const char* val, uint8_t *target); -static ftdm_status_t set_switchtype_defaults(ftdm_span_t *span); - -extern ftdm_sngisdn_data_t g_sngisdn_data; - - -static ftdm_status_t parse_timer(const char* val, int32_t *target) -{ - *target = atoi(val); - if (*target < 0) { - *target = 0; - } - return FTDM_SUCCESS; -} - -static ftdm_status_t parse_yesno(const char* var, const char* val, uint8_t *target) -{ - if (ftdm_true(val)) { - *target = SNGISDN_OPT_TRUE; - } else { - *target = SNGISDN_OPT_FALSE; - } - return FTDM_SUCCESS; -} - -static ftdm_status_t add_local_number(const char* val, ftdm_span_t *span) -{ - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) span->signal_data; - - if (signal_data->num_local_numbers >= SNGISDN_NUM_LOCAL_NUMBERS) { - ftdm_log(FTDM_LOG_ERROR, "%s: Maximum number of local-numbers exceeded (max:%d)\n", span->name, SNGISDN_NUM_LOCAL_NUMBERS); - return FTDM_FAIL; - } - - signal_data->local_numbers[signal_data->num_local_numbers++] = ftdm_strdup(val); - return FTDM_SUCCESS; -} - -static ftdm_status_t parse_switchtype(const char* switch_name, ftdm_span_t *span) -{ - unsigned i; - ftdm_iterator_t *chaniter = NULL; - ftdm_iterator_t *curr = NULL; - //sngisdn_dchan_data_t *dchan_data; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) span->signal_data; - - switch(span->trunk_type) { - case FTDM_TRUNK_T1: - if (!strcasecmp(switch_name, "ni2") || - !strcasecmp(switch_name, "national")) { - signal_data->switchtype = SNGISDN_SWITCH_NI2; - } else if (!strcasecmp(switch_name, "5ess")) { - signal_data->switchtype = SNGISDN_SWITCH_5ESS; - } else if (!strcasecmp(switch_name, "4ess")) { - signal_data->switchtype = SNGISDN_SWITCH_4ESS; - } else if (!strcasecmp(switch_name, "dms100")) { - signal_data->switchtype = SNGISDN_SWITCH_DMS100; - } else if (!strcasecmp(switch_name, "qsig")) { - signal_data->switchtype = SNGISDN_SWITCH_QSIG; - } else { - ftdm_log(FTDM_LOG_ERROR, "%s:Unsupported switchtype %s for trunktype:%s\n", span->name, switch_name, ftdm_trunk_type2str(span->trunk_type)); - return FTDM_FAIL; - } - break; - case FTDM_TRUNK_E1: - if (!strcasecmp(switch_name, "euroisdn") || - !strcasecmp(switch_name, "etsi")) { - signal_data->switchtype = SNGISDN_SWITCH_EUROISDN; - } else if (!strcasecmp(switch_name, "qsig")) { - signal_data->switchtype = SNGISDN_SWITCH_QSIG; - } else { - ftdm_log(FTDM_LOG_ERROR, "%s:Unsupported switchtype %s for trunktype:%s\n", span->name, switch_name, ftdm_trunk_type2str(span->trunk_type)); - return FTDM_FAIL; - } - break; - case FTDM_TRUNK_BRI: - case FTDM_TRUNK_BRI_PTMP: - if (!strcasecmp(switch_name, "euroisdn") || - !strcasecmp(switch_name, "etsi")) { - signal_data->switchtype = SNGISDN_SWITCH_EUROISDN; - } else if (!strcasecmp(switch_name, "insnet") || - !strcasecmp(switch_name, "ntt")) { - signal_data->switchtype = SNGISDN_SWITCH_INSNET; - } else { - ftdm_log(FTDM_LOG_ERROR, "%s:Unsupported switchtype %s for trunktype:%s\n", span->name, switch_name, ftdm_trunk_type2str(span->trunk_type)); - return FTDM_FAIL; - } - ftdm_set_flag(span, FTDM_SPAN_USE_AV_RATE); - ftdm_set_flag(span, FTDM_SPAN_PWR_SAVING); - /* can be > 1 for some BRI variants */ - break; - default: - ftdm_log(FTDM_LOG_ERROR, "%s:Unsupported trunktype:%s\n", span->name, ftdm_trunk_type2str(span->trunk_type)); - return FTDM_FAIL; - } - - /* see if we have profile with this switch_type already */ - for (i = 1; i <= g_sngisdn_data.num_cc; i++) { - if (g_sngisdn_data.ccs[i].switchtype == signal_data->switchtype && - g_sngisdn_data.ccs[i].trunktype == span->trunk_type) { - break; - } - } - - /* need to create a new switch_type */ - if (i > g_sngisdn_data.num_cc) { - g_sngisdn_data.num_cc++; - g_sngisdn_data.ccs[i].switchtype = signal_data->switchtype; - g_sngisdn_data.ccs[i].trunktype = span->trunk_type; - ftdm_log(FTDM_LOG_DEBUG, "%s: New switchtype:%s cc_id:%u\n", span->name, switch_name, i); - } - - /* add this span to its ent_cc */ - signal_data->cc_id = i; - - g_sngisdn_data.spans[signal_data->link_id] = signal_data; - - ftdm_log(FTDM_LOG_DEBUG, "%s: cc_id:%d link_id:%d\n", span->name, signal_data->cc_id, signal_data->link_id); - - chaniter = ftdm_span_get_chan_iterator(span, NULL); - for (curr = chaniter; curr; curr = ftdm_iterator_next(curr)) { - int32_t chan_id; - ftdm_channel_t *ftdmchan = (ftdm_channel_t*)ftdm_iterator_current(curr); - if (ftdmchan->type == FTDM_CHAN_TYPE_DQ921) { - /* set the d-channel */ - signal_data->dchan = ftdmchan; - } else { - /* Add the channels to the span */ - chan_id = ftdmchan->physical_chan_id; - signal_data->channels[chan_id] = (sngisdn_chan_data_t*)ftdmchan->call_data; - signal_data->num_chans++; - } - } - ftdm_iterator_free(chaniter); - return FTDM_SUCCESS; -} - -static ftdm_status_t parse_signalling(const char *signalling, ftdm_span_t *span) -{ - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) span->signal_data; - if (!strcasecmp(signalling, "net") || - !strcasecmp(signalling, "pri_net")|| - !strcasecmp(signalling, "bri_net")) { - - signal_data->signalling = SNGISDN_SIGNALING_NET; - } else if (!strcasecmp(signalling, "cpe") || - !strcasecmp(signalling, "pri_cpe")|| - !strcasecmp(signalling, "bri_cpe")) { - - signal_data->signalling = SNGISDN_SIGNALING_CPE; - } else { - ftdm_log(FTDM_LOG_ERROR, "Unsupported signalling/interface %s\n", signalling); - return FTDM_FAIL; - } - return FTDM_SUCCESS; -} - -static ftdm_status_t parse_spanmap(const char *_spanmap, ftdm_span_t *span) -{ - int i; - char *p, *name, *spanmap; - uint8_t logical_span_id = 0; - ftdm_status_t ret = FTDM_SUCCESS; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) span->signal_data; - - spanmap = ftdm_strdup(_spanmap); - - p = name = NULL; - - i = 0; - for (p = strtok(spanmap, ","); p; p = strtok(NULL, ",")) { - while (*p == ' ') { - p++; - } - switch(i++) { - case 0: - name = ftdm_strdup(p); - break; - case 1: - logical_span_id = atoi(p); - break; - } - } - - if (!name) { - ftdm_log(FTDM_LOG_ERROR, "Invalid spanmap syntax %s\n", _spanmap); - ret = FTDM_FAIL; - goto done; - } - - for (i = 0; i < g_sngisdn_data.num_nfas; i++) { - if (!ftdm_strlen_zero(g_sngisdn_data.nfass[i].name) && - !strcasecmp(g_sngisdn_data.nfass[i].name, name)) { - - signal_data->nfas.trunk = &g_sngisdn_data.nfass[i]; - break; - } - } - - if (!signal_data->nfas.trunk) { - ftdm_log(FTDM_LOG_ERROR, "Could not find trunkgroup with name %s\n", name); - ret = FTDM_FAIL; - goto done; - } - - if (signal_data->nfas.trunk->spans[logical_span_id]) { - ftdm_log(FTDM_LOG_ERROR, "trunkgroup:%s already had a span with logical span id:%d\n", name, logical_span_id); - } else { - signal_data->nfas.trunk->spans[logical_span_id] = signal_data; - signal_data->nfas.interface_id = logical_span_id; - } - - if (!strcasecmp(signal_data->ftdm_span->name, signal_data->nfas.trunk->dchan_span_name)) { - - signal_data->nfas.sigchan = SNGISDN_NFAS_DCHAN_PRIMARY; - signal_data->nfas.trunk->dchan = signal_data; - } - - if (!strcasecmp(signal_data->ftdm_span->name, signal_data->nfas.trunk->backup_span_name)) { - - signal_data->nfas.sigchan = SNGISDN_NFAS_DCHAN_BACKUP; - signal_data->nfas.trunk->backup = signal_data; - } - -done: - ftdm_safe_free(spanmap); - ftdm_safe_free(name); - return ret; -} - -static ftdm_status_t parse_trunkgroup(const char *_trunkgroup) -{ - int i; - char *p, *name, *dchan_span, *backup_span, *trunkgroup; - uint8_t num_spans = 0; - ftdm_status_t ret = FTDM_SUCCESS; - - trunkgroup = ftdm_strdup(_trunkgroup); - - p = name = dchan_span = backup_span = NULL; - - /* format: name, num_chans, dchan_span, [backup_span] */ - - i = 0; - for (p = strtok(trunkgroup, ","); p; p = strtok(NULL, ",")) { - while (*p == ' ') { - p++; - } - switch(i++) { - case 0: - name = ftdm_strdup(p); - break; - case 1: - num_spans = atoi(p); - break; - case 2: - dchan_span = ftdm_strdup(p); - break; - case 3: - backup_span = ftdm_strdup(p); - } - } - - if (!name || !dchan_span || num_spans <= 0) { - ftdm_log(FTDM_LOG_ERROR, "Invalid parameters for trunkgroup:%s\n", _trunkgroup); - ret = FTDM_FAIL; - goto done; - } - - for (i = 0; i < g_sngisdn_data.num_nfas; i++) { - if (!ftdm_strlen_zero(g_sngisdn_data.nfass[i].name) && - !strcasecmp(g_sngisdn_data.nfass[i].name, name)) { - - /* We already configured this trunkgroup */ - goto done; - } - } - - /* Trunk group was not found, need to configure it */ - strncpy(g_sngisdn_data.nfass[i].name, name, sizeof(g_sngisdn_data.nfass[i].name)); - g_sngisdn_data.nfass[i].num_spans = num_spans; - strncpy(g_sngisdn_data.nfass[i].dchan_span_name, dchan_span, sizeof(g_sngisdn_data.nfass[i].dchan_span_name)); - - if (backup_span) { - strncpy(g_sngisdn_data.nfass[i].backup_span_name, backup_span, sizeof(g_sngisdn_data.nfass[i].backup_span_name)); - } - - - g_sngisdn_data.num_nfas++; -done: - ftdm_safe_free(trunkgroup); - ftdm_safe_free(name); - ftdm_safe_free(dchan_span); - ftdm_safe_free(backup_span); - return ret; -} - -static ftdm_status_t parse_early_media(const char* opt, ftdm_span_t *span) -{ - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) span->signal_data; - if (!strcasecmp(opt, "on-proceed")) { - signal_data->early_media_flags |= SNGISDN_EARLY_MEDIA_ON_PROCEED; - } else if (!strcasecmp(opt, "on-progress")) { - signal_data->early_media_flags |= SNGISDN_EARLY_MEDIA_ON_PROGRESS; - } else if (!strcasecmp(opt, "on-alert")) { - signal_data->early_media_flags |= SNGISDN_EARLY_MEDIA_ON_ALERT; - } else { - ftdm_log(FTDM_LOG_ERROR, "Unsupported early-media option %s\n", opt); - return FTDM_FAIL; - } - ftdm_log(FTDM_LOG_DEBUG, "Early media opt:0x%x\n", signal_data->early_media_flags); - return FTDM_SUCCESS; -} - - -static ftdm_status_t set_switchtype_defaults(ftdm_span_t *span) -{ - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) span->signal_data; - switch(signal_data->switchtype) { - case SNGISDN_SWITCH_NI2: - case SNGISDN_SWITCH_5ESS: - case SNGISDN_SWITCH_4ESS: - case SNGISDN_SWITCH_DMS100: - if (span->default_caller_data.dnis.plan >= FTDM_NPI_INVALID) { - ftdm_set_npi("isdn", &span->default_caller_data.dnis.plan); - } - if (span->default_caller_data.dnis.type >= FTDM_TON_INVALID) { - ftdm_set_ton("national", &span->default_caller_data.dnis.type); - } - if (span->default_caller_data.cid_num.plan >= FTDM_NPI_INVALID) { - ftdm_set_npi("isdn", &span->default_caller_data.cid_num.plan); - } - if (span->default_caller_data.cid_num.type >= FTDM_TON_INVALID) { - ftdm_set_ton("national", &span->default_caller_data.cid_num.type); - } - if (span->default_caller_data.rdnis.plan >= FTDM_NPI_INVALID) { - ftdm_set_npi("isdn", &span->default_caller_data.rdnis.plan); - } - if (span->default_caller_data.rdnis.type >= FTDM_TON_INVALID) { - ftdm_set_ton("national", &span->default_caller_data.rdnis.type); - } - break; - case SNGISDN_SWITCH_EUROISDN: - case SNGISDN_SWITCH_QSIG: - case SNGISDN_SWITCH_INSNET: - if (span->default_caller_data.dnis.plan >= FTDM_NPI_INVALID) { - ftdm_set_npi("unknown", &span->default_caller_data.dnis.plan); - } - if (span->default_caller_data.dnis.type >= FTDM_TON_INVALID) { - ftdm_set_ton("unknown", &span->default_caller_data.dnis.type); - } - if (span->default_caller_data.cid_num.plan >= FTDM_NPI_INVALID) { - ftdm_set_npi("unknown", &span->default_caller_data.cid_num.plan); - } - if (span->default_caller_data.cid_num.type >= FTDM_TON_INVALID) { - ftdm_set_ton("unknown", &span->default_caller_data.cid_num.type); - } - if (span->default_caller_data.rdnis.plan >= FTDM_NPI_INVALID) { - ftdm_set_npi("unknown", &span->default_caller_data.rdnis.plan); - } - if (span->default_caller_data.rdnis.type >= FTDM_TON_INVALID) { - ftdm_set_ton("unknown", &span->default_caller_data.rdnis.type); - } - break; - case SNGISDN_SWITCH_INVALID: - default: - ftdm_log(FTDM_LOG_ERROR, "Unsupported switchtype[%d]\n", signal_data->switchtype); - return FTDM_FAIL; - } - return FTDM_SUCCESS; -} - - -ftdm_status_t ftmod_isdn_parse_cfg(ftdm_conf_parameter_t *ftdm_parameters, ftdm_span_t *span) -{ - unsigned paramindex; - const char *var, *val; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) span->signal_data; - /* Set defaults here */ - signal_data->tei = 0; - signal_data->min_digits = 8; - signal_data->overlap_dial = SNGISDN_OPT_DEFAULT; - signal_data->setup_arb = SNGISDN_OPT_DEFAULT; - signal_data->facility_ie_decode = SNGISDN_OPT_DEFAULT; - signal_data->ignore_cause_value = SNGISDN_OPT_DEFAULT; - signal_data->timer_t3 = 8; - signal_data->restart_opt = SNGISDN_OPT_DEFAULT; - signal_data->link_id = span->span_id; - signal_data->transfer_timeout = 20000; - signal_data->att_remove_dtmf = SNGISDN_OPT_DEFAULT; - signal_data->force_sending_complete = SNGISDN_OPT_DEFAULT; - - signal_data->cid_name_method = SNGISDN_CID_NAME_AUTO; - signal_data->send_cid_name = SNGISDN_OPT_DEFAULT; - signal_data->send_connect_ack = SNGISDN_OPT_DEFAULT; - - span->default_caller_data.dnis.plan = FTDM_NPI_INVALID; - span->default_caller_data.dnis.type = FTDM_TON_INVALID; - span->default_caller_data.cid_num.plan = FTDM_NPI_INVALID; - span->default_caller_data.cid_num.type = FTDM_TON_INVALID; - span->default_caller_data.rdnis.plan = FTDM_NPI_INVALID; - span->default_caller_data.rdnis.type = FTDM_TON_INVALID; - - span->default_caller_data.bearer_capability = IN_ITC_SPEECH; - /* Cannot set default bearer_layer1 yet, as we do not know the switchtype */ - span->default_caller_data.bearer_layer1 = FTDM_INVALID_INT_PARM; - - /* Find out if NFAS is enabled first */ - for (paramindex = 0; ftdm_parameters[paramindex].var; paramindex++) { - ftdm_log(FTDM_LOG_DEBUG, "Sangoma ISDN key=value, %s=%s\n", ftdm_parameters[paramindex].var, ftdm_parameters[paramindex].val); - var = ftdm_parameters[paramindex].var; - val = ftdm_parameters[paramindex].val; - - if (!strcasecmp(var, "trunkgroup")) { - if (parse_trunkgroup(val) != FTDM_SUCCESS) { - return FTDM_FAIL; - } - } - } - - for (paramindex = 0; ftdm_parameters[paramindex].var; paramindex++) { - ftdm_log(FTDM_LOG_DEBUG, "Sangoma ISDN key=value, %s=%s\n", ftdm_parameters[paramindex].var, ftdm_parameters[paramindex].val); - var = ftdm_parameters[paramindex].var; - val = ftdm_parameters[paramindex].val; - - if (!strcasecmp(var, "switchtype")) { - if (parse_switchtype(val, span) != FTDM_SUCCESS) { - return FTDM_FAIL; - } - if (set_switchtype_defaults(span) != FTDM_SUCCESS) { - return FTDM_FAIL; - } - } else if (!strcasecmp(var, "signalling") || - !strcasecmp(var, "interface")) { - if (parse_signalling(val, span) != FTDM_SUCCESS) { - return FTDM_FAIL; - } - } else if (!strcasecmp(var, "spanmap")) { - if (parse_spanmap(val, span) != FTDM_SUCCESS) { - return FTDM_FAIL; - } - } else if (!strcasecmp(var, "tei")) { - uint8_t tei = atoi(val); - if (tei > 127) { - ftdm_log(FTDM_LOG_ERROR, "Invalid TEI %d, valid values are (0-127)", tei); - return FTDM_FAIL; - } - signal_data->tei = tei; - } else if (!strcasecmp(var, "overlap")) { - if (!strcasecmp(val, "yes")) { - signal_data->overlap_dial = SNGISDN_OPT_TRUE; - } else if (!strcasecmp(val, "no")) { - signal_data->overlap_dial = SNGISDN_OPT_FALSE; - } else { - ftdm_log(FTDM_LOG_ERROR, "Invalid value for parameter:%s:%s\n", var, val); - } - } else if (!strcasecmp(var, "setup-arbitration")) { - parse_yesno(var, val, &signal_data->setup_arb); - } else if (!strcasecmp(var, "facility")) { - parse_yesno(var, val, &signal_data->facility); - } else if (!strcasecmp(var, "min-digits") || - !strcasecmp(var, "min_digits")) { - signal_data->min_digits = atoi(val); - } else if (!strcasecmp(var, "outbound-called-ton")) { - ftdm_set_ton(val, &span->default_caller_data.dnis.type); - } else if (!strcasecmp(var, "outbound-called-npi")) { - ftdm_set_npi(val, &span->default_caller_data.dnis.plan); - } else if (!strcasecmp(var, "outbound-calling-ton")) { - ftdm_set_ton(val, &span->default_caller_data.cid_num.type); - } else if (!strcasecmp(var, "outbound-calling-npi")) { - ftdm_set_npi(val, &span->default_caller_data.cid_num.plan); - } else if (!strcasecmp(var, "outbound-rdnis-ton")) { - ftdm_set_ton(val, &span->default_caller_data.rdnis.type); - } else if (!strcasecmp(var, "outbound-rdnis-npi")) { - ftdm_set_npi(val, &span->default_caller_data.rdnis.plan); - } else if (!strcasecmp(var, "outbound-bc-transfer-cap") || - !strcasecmp(var, "outbound-bearer_cap")) { - ftdm_set_bearer_capability(val, (uint8_t*)&span->default_caller_data.bearer_capability); - } else if (!strcasecmp(var, "outbound-bc-user-layer1") || - !strcasecmp(var, "outbound-bearer_layer1")) { - ftdm_set_bearer_layer1(val, (uint8_t*)&span->default_caller_data.bearer_layer1); - } else if (!strcasecmp(var, "channel-restart-on-link-up")) { - parse_yesno(var, val, &signal_data->restart_opt); - } else if (!strcasecmp(var, "channel-restart-timeout")) { - signal_data->restart_timeout = atoi(val); - } else if (!strcasecmp(var, "local-number")) { - if (add_local_number(val, span) != FTDM_SUCCESS) { - return FTDM_FAIL; - } - } else if (!strcasecmp(var, "facility-timeout")) { - parse_timer(val, &signal_data->facility_timeout); - } else if (!strcasecmp(var, "transfer-timeout")) { - parse_timer(val, &signal_data->transfer_timeout); - } else if (!strcasecmp(var, "att-remove-dtmf")) { - parse_yesno(var, val, &signal_data->att_remove_dtmf); - } else if (!strcasecmp(var, "facility-ie-decode")) { - parse_yesno(var, val, &signal_data->facility_ie_decode); - } else if (!strcasecmp(var, "ignore-cause-value")) { - parse_yesno(var, val, &signal_data->ignore_cause_value); - } else if (!strcasecmp(var, "q931-trace")) { - parse_yesno(var, val, &signal_data->trace_q931); - } else if (!strcasecmp(var, "q921-trace")) { - parse_yesno(var, val, &signal_data->trace_q921); - } else if (!strcasecmp(var, "q931-raw-trace")) { - parse_yesno(var, val, &signal_data->raw_trace_q931); - } else if (!strcasecmp(var, "q921-raw-trace")) { - parse_yesno(var, val, &signal_data->raw_trace_q921); - } else if (!strcasecmp(var, "force-sending-complete")) { - parse_yesno(var, val, &signal_data->force_sending_complete); - } else if (!strcasecmp(var, "early-media-override")) { - if (parse_early_media(val, span) != FTDM_SUCCESS) { - return FTDM_FAIL; - } - } else if (!strcasecmp(var, "chan-id-invert-extend-bit")) { -#ifdef SANGOMA_ISDN_CHAN_ID_INVERT_BIT - parse_yesno(var, val, &g_sngisdn_data.chan_id_invert_extend_bit); -#else - ftdm_log(FTDM_LOG_WARNING, "chan-id-invert-extend-bit is not supported in your version of libsng_isdn\n"); -#endif - } else if (!strcasecmp(var, "cid-name-transmit-method")) { - if (!strcasecmp(val, "display-ie")) { - signal_data->cid_name_method = SNGISDN_CID_NAME_DISPLAY_IE; - } else if (!strcasecmp(val, "user-user-ie")) { - signal_data->cid_name_method = SNGISDN_CID_NAME_USR_USR_IE; - } else if (!strcasecmp(val, "facility-ie")) { - signal_data->cid_name_method = SNGISDN_CID_NAME_FACILITY_IE; - } else if (!strcasecmp(val, "auto") || !strcasecmp(val, "automatic") || !strcasecmp(val, "default")) { - signal_data->cid_name_method = SNGISDN_CID_NAME_AUTO; - } else { - ftdm_log(FTDM_LOG_WARNING, "Invalid option %s for parameter %s\n", val, var); - signal_data->cid_name_method = SNGISDN_CID_NAME_AUTO; - } - } else if (!strcasecmp(var, "send-cid-name")) { - if (!strcasecmp(val, "yes")) { - signal_data->send_cid_name = SNGISDN_OPT_TRUE; - } else if (!strcasecmp(val, "no")) { - signal_data->send_cid_name = SNGISDN_OPT_FALSE; - } else if (!strcasecmp(val, "auto") || !strcasecmp(val, "automatic") || !strcasecmp(val, "default")) { - signal_data->send_cid_name = SNGISDN_OPT_DEFAULT; - } else { - ftdm_log(FTDM_LOG_WARNING, "Invalid option %s for parameter %s\n", val, var); - signal_data->send_cid_name = SNGISDN_OPT_DEFAULT; - } - } else if (!strcasecmp(var, "timer-t301")) { - parse_timer(val, &signal_data->timer_t301); - } else if (!strcasecmp(var, "timer-t302")) { - parse_timer(val, &signal_data->timer_t302); - } else if (!strcasecmp(var, "timer-t303")) { - parse_timer(val, &signal_data->timer_t303); - } else if (!strcasecmp(var, "timer-t304")) { - parse_timer(val, &signal_data->timer_t304); - } else if (!strcasecmp(var, "timer-t305")) { - parse_timer(val, &signal_data->timer_t305); - } else if (!strcasecmp(var, "timer-t306")) { - parse_timer(val, &signal_data->timer_t306); - } else if (!strcasecmp(var, "timer-t307")) { - parse_timer(val, &signal_data->timer_t307); - } else if (!strcasecmp(var, "timer-t308")) { - parse_timer(val, &signal_data->timer_t308); - } else if (!strcasecmp(var, "timer-t310")) { - parse_timer(val, &signal_data->timer_t310); - } else if (!strcasecmp(var, "timer-t312")) { - parse_timer(val, &signal_data->timer_t312); - } else if (!strcasecmp(var, "timer-t313")) { - parse_timer(val, &signal_data->timer_t313); - } else if (!strcasecmp(var, "timer-t314")) { - parse_timer(val, &signal_data->timer_t314); - } else if (!strcasecmp(var, "timer-t316")) { - parse_timer(val, &signal_data->timer_t316); - } else if (!strcasecmp(var, "timer-t318")) { - parse_timer(val, &signal_data->timer_t318); - } else if (!strcasecmp(var, "timer-t319")) { - parse_timer(val, &signal_data->timer_t319); - } else if (!strcasecmp(var, "timer-t322")) { - parse_timer(val, &signal_data->timer_t322); - } else if (!strcasecmp(var, "trunkgroup")) { - /* Do nothing, we already parsed this parameter */ - } else if (!strcasecmp(var, "send-connect-ack")) { - parse_yesno(var, val, &signal_data->send_connect_ack); - } else { - ftdm_log(FTDM_LOG_WARNING, "Ignoring unknown parameter %s\n", ftdm_parameters[paramindex].var); - } - } /* for (paramindex = 0; ftdm_parameters[paramindex].var; paramindex++) */ - - if (signal_data->switchtype == SNGISDN_SWITCH_INVALID) { - ftdm_log(FTDM_LOG_ERROR, "%s: switchtype not specified", span->name); - return FTDM_FAIL; - } - if (signal_data->signalling == SNGISDN_SIGNALING_INVALID) { - ftdm_log(FTDM_LOG_ERROR, "%s: signalling not specified", span->name); - return FTDM_FAIL; - } - - if (span->default_caller_data.bearer_layer1 == FTDM_INVALID_INT_PARM) { - if (signal_data->switchtype == SNGISDN_SWITCH_EUROISDN || - signal_data->switchtype == SNGISDN_SWITCH_QSIG) { - span->default_caller_data.bearer_layer1 = IN_UIL1_G711ALAW; - } else { - span->default_caller_data.bearer_layer1 = IN_UIL1_G711ULAW; - } - } - return FTDM_SUCCESS; -} - - -/******************************************************************************/ -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cntrl.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cntrl.c deleted file mode 100644 index c0caf10ab7..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cntrl.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2010, Sangoma Technologies - * David Yat Sin - - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ - -#include "ftmod_sangoma_isdn.h" - -void sngisdn_set_chan_sig_status(ftdm_channel_t *ftdmchan, ftdm_signaling_status_t status); - -void sngisdn_set_chan_sig_status(ftdm_channel_t *ftdmchan, ftdm_signaling_status_t status) -{ - ftdm_sigmsg_t sig; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)ftdmchan->span->signal_data; - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Signalling link status changed to %s\n", ftdm_signaling_status2str(status)); - - memset(&sig, 0, sizeof(sig)); - sig.chan_id = ftdmchan->chan_id; - sig.span_id = ftdmchan->span_id; - sig.channel = ftdmchan; - sig.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED; - sig.ev_data.sigstatus.status = status; - ftdm_span_send_signal(ftdmchan->span, &sig); - - if (FTDM_SPAN_IS_BRI(ftdmchan->span)) { - sngisdn_chan_data_t *sngisdn_info = ftdmchan->call_data; - if (ftdm_test_flag(sngisdn_info, FLAG_ACTIVATING)) { - ftdm_clear_flag(sngisdn_info, FLAG_ACTIVATING); - - ftdm_sched_timer(signal_data->sched, "delayed_setup", 1000, sngisdn_delayed_setup, (void*) sngisdn_info, NULL); - } - } - return; -} - -void sngisdn_set_span_sig_status(ftdm_span_t *span, ftdm_signaling_status_t status) -{ - ftdm_iterator_t *chaniter = NULL; - ftdm_iterator_t *curr = NULL; - - ((sngisdn_span_data_t*)span->signal_data)->sigstatus = status; - - if (status == FTDM_SIG_STATE_UP) { - ((sngisdn_span_data_t*)span->signal_data)->dl_request_pending = 0; - } - - chaniter = ftdm_span_get_chan_iterator(span, NULL); - for (curr = chaniter; curr; curr = ftdm_iterator_next(curr)) { - sngisdn_set_chan_sig_status(((ftdm_channel_t*)ftdm_iterator_current(curr)), status); - } - ftdm_iterator_free(chaniter); - return; -} - - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ - -/******************************************************************************/ - diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c deleted file mode 100644 index 92d401d5e0..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c +++ /dev/null @@ -1,1273 +0,0 @@ -/* - * Copyright (c) 2010, Sangoma Technologies - * David Yat Sin - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "ftmod_sangoma_isdn.h" - -extern ftdm_sngisdn_data_t g_sngisdn_data; - -uint8_t sng_isdn_stack_switchtype(sngisdn_switchtype_t switchtype); - -ftdm_status_t sngisdn_cfg_phy(ftdm_span_t *span); -ftdm_status_t sngisdn_cfg_q921(ftdm_span_t *span); -ftdm_status_t sngisdn_cfg_q931(ftdm_span_t *span); -ftdm_status_t sngisdn_cfg_cc(ftdm_span_t *span); - -ftdm_status_t sngisdn_stack_cfg_phy_gen(void); -ftdm_status_t sngisdn_stack_cfg_q921_gen(void); -ftdm_status_t sngisdn_stack_cfg_q931_gen(void); -ftdm_status_t sngisdn_stack_cfg_cc_gen(void); - - -ftdm_status_t sngisdn_stack_cfg_phy_psap(ftdm_span_t *span); -ftdm_status_t sngisdn_stack_cfg_q921_msap(ftdm_span_t *span); -ftdm_status_t sngisdn_stack_cfg_q921_dlsap(ftdm_span_t *span, uint8_t management); -ftdm_status_t sngisdn_stack_cfg_q931_tsap(ftdm_span_t *span); -ftdm_status_t sngisdn_stack_cfg_q931_dlsap(ftdm_span_t *span); -ftdm_status_t sngisdn_stack_cfg_q931_lce(ftdm_span_t *span); - -ftdm_status_t sngisdn_stack_cfg_cc_sap(ftdm_span_t *span); - -ftdm_status_t sngisdn_start_gen_cfg(void) -{ - if (!g_sngisdn_data.gen_config_done) { - g_sngisdn_data.gen_config_done = 1; - ftdm_log(FTDM_LOG_DEBUG, "Starting general stack configuration\n"); - if(sngisdn_stack_cfg_phy_gen()!= FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_CRIT, "Failed general physical configuration\n"); - return FTDM_FAIL; - } - ftdm_log(FTDM_LOG_DEBUG, "General stack physical done\n"); - - if(sngisdn_stack_cfg_q921_gen()!= FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_CRIT, "Failed general q921 configuration\n"); - return FTDM_FAIL; - } - ftdm_log(FTDM_LOG_DEBUG, "General stack q921 done\n"); - - if(sngisdn_stack_cfg_q931_gen()!= FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_CRIT, "Failed general q921 configuration\n"); - return FTDM_FAIL; - } - ftdm_log(FTDM_LOG_DEBUG, "General stack q931 done\n"); - - if(sngisdn_stack_cfg_cc_gen()!= FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_CRIT, "Failed general CC configuration\n"); - return FTDM_FAIL; - } - ftdm_log(FTDM_LOG_DEBUG, "General stack CC done\n"); - ftdm_log(FTDM_LOG_INFO, "General stack configuration done\n"); - } - return FTDM_SUCCESS; -} - - -ftdm_status_t sngisdn_stack_cfg(ftdm_span_t *span) -{ - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)span->signal_data; - - ftdm_log(FTDM_LOG_DEBUG, "Starting stack configuration for span:%s\n", span->name); - - if (signal_data->dchan) { - if (sngisdn_stack_cfg_phy_psap(span) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "%s:phy_psap configuration failed\n", span->name); - return FTDM_FAIL; - } - ftdm_log(FTDM_LOG_DEBUG, "%s:phy_psap configuration done\n", span->name); - - if (sngisdn_stack_cfg_q921_msap(span) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "%s:q921_msap configuration failed\n", span->name); - return FTDM_FAIL; - } - ftdm_log(FTDM_LOG_DEBUG, "%s:q921_msap configuration done\n", span->name); - - if (sngisdn_stack_cfg_q921_dlsap(span, 0) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "%s:q921_dlsap configuration failed\n", span->name); - return FTDM_FAIL; - } - ftdm_log(FTDM_LOG_DEBUG, "%s:q921_dlsap configuration done\n", span->name); - - if (span->trunk_type == FTDM_TRUNK_BRI_PTMP) { - if (sngisdn_stack_cfg_q921_dlsap(span, 1) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "%s:q921_dlsap management configuration failed\n", span->name); - return FTDM_FAIL; - } - ftdm_log(FTDM_LOG_DEBUG, "%s:q921_dlsap management configuration done\n", span->name); - } - } - - if (sngisdn_stack_cfg_q931_dlsap(span) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "%s:q931_dlsap configuration failed\n", span->name); - return FTDM_FAIL; - } - ftdm_log(FTDM_LOG_DEBUG, "%s:q931_dlsap configuration done\n", span->name); - - if (signal_data->dchan) { - if (sngisdn_stack_cfg_q931_lce(span) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "%s:q931_lce configuration failed\n", span->name); - return FTDM_FAIL; - } - ftdm_log(FTDM_LOG_DEBUG, "%s:q931_lce configuration done\n", span->name); - } - - if (!g_sngisdn_data.ccs[signal_data->cc_id].config_done) { - g_sngisdn_data.ccs[signal_data->cc_id].config_done = 1; - /* if BRI, need to configure dlsap_mgmt */ - if (sngisdn_stack_cfg_q931_tsap(span) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "%s:q931_tsap configuration failed\n", span->name); - return FTDM_FAIL; - } - ftdm_log(FTDM_LOG_DEBUG, "%s:q931_tsap configuration done\n", span->name); - - if (sngisdn_stack_cfg_cc_sap(span) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "%s:cc_sap configuration failed\n", span->name); - return FTDM_FAIL; - } - ftdm_log(FTDM_LOG_DEBUG, "%s:cc_sap configuration done\n", span->name); - } - - ftdm_log(FTDM_LOG_INFO, "%s:stack configuration done\n", span->name); - return FTDM_SUCCESS; -} - - - -ftdm_status_t sngisdn_stack_cfg_phy_gen(void) -{ - /*local variables*/ - L1Mngmt cfg; /*configuration structure*/ - Pst pst; /*post structure*/ - - /* initalize the post structure */ - stack_pst_init(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTL1; - - /*clear the configuration structure*/ - memset(&cfg, 0, sizeof(cfg)); - - /*fill in some general sections of the header*/ - stack_hdr_init(&cfg.hdr); - - /*fill in the specific fields of the header*/ - cfg.hdr.msgType = TCFG; - cfg.hdr.entId.ent = ENTL1; - cfg.hdr.entId.inst = S_INST; - cfg.hdr.elmId.elmnt = STGEN; - - stack_pst_init(&cfg.t.cfg.s.l1Gen.sm ); - cfg.t.cfg.s.l1Gen.sm.srcEnt = ENTL1; - cfg.t.cfg.s.l1Gen.sm.dstEnt = ENTSM; - - cfg.t.cfg.s.l1Gen.nmbLnks = MAX_L1_LINKS; - cfg.t.cfg.s.l1Gen.poolTrUpper = POOL_UP_TR; /* upper pool threshold */ - cfg.t.cfg.s.l1Gen.poolTrLower = POOL_LW_TR; /* lower pool threshold */ - - if (sng_isdn_phy_config(&pst, &cfg)) { - return FTDM_FAIL; - } - return FTDM_SUCCESS; -} - -ftdm_status_t sngisdn_stack_cfg_phy_psap(ftdm_span_t *span) -{ - L1Mngmt cfg; - Pst pst; - - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)span->signal_data; - - /* initalize the post structure */ - stack_pst_init(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTL1; - - /*clear the configuration structure*/ - memset(&cfg, 0, sizeof(cfg)); - - /*fill in some general sections of the header*/ - stack_hdr_init(&cfg.hdr); - - /*fill in the specific fields of the header*/ - cfg.hdr.msgType = TCFG; - cfg.hdr.entId.ent = ENTL1; - cfg.hdr.entId.inst = S_INST; - cfg.hdr.elmId.elmnt = STPSAP; - - cfg.hdr.elmId.elmntInst1 = signal_data->link_id; - - if (!signal_data->dchan) { - ftdm_log(FTDM_LOG_ERROR, "%s:No d-channels specified\n", span->name); - return FTDM_FAIL; - } - - cfg.t.cfg.s.l1PSAP.sockfd = (int32_t)signal_data->dchan->sockfd; - - switch(span->trunk_type) { - case FTDM_TRUNK_E1: - cfg.t.cfg.s.l1PSAP.type = SNG_L1_TYPE_PRI; - break; - case FTDM_TRUNK_T1: - case FTDM_TRUNK_J1: - cfg.t.cfg.s.l1PSAP.type = SNG_L1_TYPE_PRI; - break; - case FTDM_TRUNK_BRI: - case FTDM_TRUNK_BRI_PTMP: - cfg.t.cfg.s.l1PSAP.type = SNG_L1_TYPE_BRI; - break; - default: - ftdm_log(FTDM_LOG_ERROR, "%s:Unsupported trunk type %d\n", span->name, span->trunk_type); - return FTDM_FAIL; - } - - cfg.t.cfg.s.l1PSAP.spId = signal_data->link_id; - - if (sng_isdn_phy_config(&pst, &cfg)) { - return FTDM_FAIL; - } - return FTDM_SUCCESS; -} - - -ftdm_status_t sngisdn_stack_cfg_q921_gen(void) -{ - BdMngmt cfg; - Pst pst; - - /* initalize the post structure */ - stack_pst_init(&pst); - /* insert the destination Entity */ - pst.dstEnt = ENTLD; - - /*clear the configuration structure*/ - memset(&cfg, 0, sizeof(cfg)); - /*fill in some general sections of the header*/ - stack_hdr_init(&cfg.hdr); - - cfg.hdr.msgType = TCFG; - cfg.hdr.entId.ent = ENTLD; - cfg.hdr.entId.inst = S_INST; - cfg.hdr.elmId.elmnt = STGEN; - /* fill in the Gen Conf structures internal pst struct */ - - stack_pst_init(&cfg.t.cfg.s.bdGen.sm); - - cfg.t.cfg.s.bdGen.sm.dstEnt = ENTSM; /* entity */ - - cfg.t.cfg.s.bdGen.nmbPLnks = MAX_L1_LINKS+1; - cfg.t.cfg.s.bdGen.nmbLDLnks = MAX_L1_LINKS+1; /* Not used in LAPD */ - cfg.t.cfg.s.bdGen.nmbDLCs = MAX_L1_LINKS+1; - cfg.t.cfg.s.bdGen.nmbDLCs = MAX_TEIS_PER_LINK*(MAX_L1_LINKS+1); - cfg.t.cfg.s.bdGen.nmbASPLnks = MAX_L1_LINKS+1; - -#ifdef LAPD_3_4 - cfg.t.cfg.s.bdGen.timeRes = 100; /* timer resolution = 1 sec */ -#endif - cfg.t.cfg.s.bdGen.poolTrUpper = 2; /* upper pool threshold */ - cfg.t.cfg.s.bdGen.poolTrLower = 1; /* lower pool threshold */ - - if (sng_isdn_q921_config(&pst, &cfg)) { - return FTDM_FAIL; - } - return FTDM_SUCCESS; -} - -ftdm_status_t sngisdn_stack_cfg_q921_msap(ftdm_span_t *span) -{ - BdMngmt cfg; - Pst pst; - - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)span->signal_data; - - /* initalize the post structure */ - stack_pst_init(&pst); - /* insert the destination Entity */ - pst.dstEnt = ENTLD; - - /*clear the configuration structure*/ - memset(&cfg, 0, sizeof(cfg)); - /*fill in some general sections of the header*/ - stack_hdr_init(&cfg.hdr); - - cfg.hdr.msgType = TCFG; - cfg.hdr.entId.ent = ENTLD; - cfg.hdr.entId.inst = S_INST; - cfg.hdr.elmId.elmnt = STMSAP; - - cfg.t.cfg.s.bdMSAP.lnkNmb = signal_data->link_id; - - cfg.t.cfg.s.bdMSAP.maxOutsFrms = 24; /* MAC window */ - cfg.t.cfg.s.bdMSAP.tQUpperTrs = 32; /* Tx Queue Upper Threshold */ - cfg.t.cfg.s.bdMSAP.tQLowerTrs = 24; /* Tx Queue Lower Threshold */ - cfg.t.cfg.s.bdMSAP.selector = 0; /* Selector 0 */ - /* TODO: check if bdMSAP parameters can be initialized by calling stack_pst_init */ - cfg.t.cfg.s.bdMSAP.mem.region = S_REG; /* Memory region */ - cfg.t.cfg.s.bdMSAP.mem.pool = S_POOL; /* Memory pool */ - cfg.t.cfg.s.bdMSAP.prior = PRIOR0; /* Priority */ - cfg.t.cfg.s.bdMSAP.route = RTESPEC; /* Route */ - cfg.t.cfg.s.bdMSAP.dstProcId = SFndProcId(); /* destination proc id */ - cfg.t.cfg.s.bdMSAP.dstEnt = ENTL1; /* entity */ - cfg.t.cfg.s.bdMSAP.dstInst = S_INST; /* instance */ - cfg.t.cfg.s.bdMSAP.t201Tmr = 1; /* T201 - should be equal to t200Tmr */ - cfg.t.cfg.s.bdMSAP.t202Tmr = 2; /* T202 */ - cfg.t.cfg.s.bdMSAP.bndRetryCnt = 2; /* bind retry counter */ - cfg.t.cfg.s.bdMSAP.tIntTmr = 200; /* bind retry timer */ - cfg.t.cfg.s.bdMSAP.n202 = 3; /* N202 */ - cfg.t.cfg.s.bdMSAP.lowTei = 64; /* Lowest dynamic TEI */ - - if (span->trunk_type == FTDM_TRUNK_BRI_PTMP && - signal_data->signalling == SNGISDN_SIGNALING_NET) { - cfg.t.cfg.s.bdMSAP.kpL1Up = FALSE; /* flag to keep l1 up or not */ - } else { - cfg.t.cfg.s.bdMSAP.kpL1Up = TRUE; /* flag to keep l1 up or not */ - } - - switch(signal_data->switchtype) { - case SNGISDN_SWITCH_NI2: - case SNGISDN_SWITCH_5ESS: - case SNGISDN_SWITCH_4ESS: - case SNGISDN_SWITCH_DMS100: - cfg.t.cfg.s.bdMSAP.type = SW_NI2; - break; - case SNGISDN_SWITCH_INSNET: - cfg.t.cfg.s.bdMSAP.type = SW_CCITT; - break; - case SNGISDN_SWITCH_EUROISDN: - case SNGISDN_SWITCH_QSIG: - cfg.t.cfg.s.bdMSAP.type = SW_ETSI; - break; - } - - if (span->trunk_type == FTDM_TRUNK_BRI_PTMP) { - cfg.t.cfg.s.bdMSAP.teiChkTmr = 20; /* Tei check timer */ - } else { - cfg.t.cfg.s.bdMSAP.teiChkTmr = 0; /* Tei check timer */ - } - - if (signal_data->signalling == SNGISDN_SIGNALING_NET) { - cfg.t.cfg.s.bdMSAP.logInt = 1; /* logical interface = 0 = user, 1= network */ - cfg.t.cfg.s.bdMSAP.setUpArb = PASSIVE; /* set up arbitration */ - } else { - cfg.t.cfg.s.bdMSAP.logInt = 0; /* logical interface = 0 = user, 1= network */ - cfg.t.cfg.s.bdMSAP.setUpArb = ACTIVE; /* set up arbitration */ - } - - /* Overwrite setUpArb value if user forced it */ - if (signal_data->setup_arb == SNGISDN_OPT_TRUE) { - cfg.t.cfg.s.bdMSAP.setUpArb = ACTIVE; - } else if (signal_data->setup_arb == SNGISDN_OPT_FALSE) { - cfg.t.cfg.s.bdMSAP.setUpArb = PASSIVE; - } - - if (sng_isdn_q921_config(&pst, &cfg)) { - return FTDM_FAIL; - } - return FTDM_SUCCESS; -} - -ftdm_status_t sngisdn_stack_cfg_q921_dlsap(ftdm_span_t *span, uint8_t management) -{ - BdMngmt cfg; - Pst pst; - - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)span->signal_data; - /* initalize the post structure */ - stack_pst_init(&pst); - /* insert the destination Entity */ - pst.dstEnt = ENTLD; - - /*clear the configuration structure*/ - memset(&cfg, 0, sizeof(cfg)); - /*fill in some general sections of the header*/ - stack_hdr_init(&cfg.hdr); - - /*fill in the specific fields of the header*/ - cfg.hdr.msgType = TCFG; - cfg.hdr.entId.ent = ENTLD; - cfg.hdr.entId.inst = S_INST; - cfg.hdr.elmId.elmnt = STDLSAP; - - cfg.t.cfg.s.bdDLSAP.lnkNmb = signal_data->link_id; - - cfg.t.cfg.s.bdDLSAP.n201 = 1028; /* n201 */ - if (span->trunk_type == FTDM_TRUNK_BRI_PTMP || - span->trunk_type == FTDM_TRUNK_BRI) { - - cfg.t.cfg.s.bdDLSAP.k = 1; /* Based on q.921 recommendations */ - } else { - cfg.t.cfg.s.bdDLSAP.k = 7; /* k */ - } - - cfg.t.cfg.s.bdDLSAP.n200 = 3; /* n200 */ - cfg.t.cfg.s.bdDLSAP.congTmr = 300; /* congestion timer */ - cfg.t.cfg.s.bdDLSAP.t200Tmr = 3; /* t1 changed from 25 */ - cfg.t.cfg.s.bdDLSAP.t203Tmr = 10; /* t3 changed from 50 */ - cfg.t.cfg.s.bdDLSAP.mod = 128; /* modulo */ - cfg.t.cfg.s.bdDLSAP.selector = 0; /* Selector 0 */ - cfg.t.cfg.s.bdDLSAP.mem.region = S_REG; /* Memory region */ - cfg.t.cfg.s.bdDLSAP.mem.pool = S_POOL; /* Memory pool */ - cfg.t.cfg.s.bdDLSAP.prior = PRIOR0; /* Priority */ - cfg.t.cfg.s.bdDLSAP.route = RTESPEC; /* Route */ - - if (management) { - cfg.t.cfg.s.bdDLSAP.sapi = MNGMT_SAPI; - cfg.t.cfg.s.bdDLSAP.teiAss = NON_AUTOMATIC; /* static tei assignment */ - cfg.t.cfg.s.bdDLSAP.noOfDlc = 1; - cfg.t.cfg.s.bdDLSAP.tei[0] = 0x7f; - } else { - cfg.t.cfg.s.bdDLSAP.sapi = Q930_SAPI; - if (span->trunk_type == FTDM_TRUNK_BRI_PTMP) { - if (signal_data->signalling == SNGISDN_SIGNALING_NET) { - cfg.t.cfg.s.bdDLSAP.teiAss = AUTOMATIC; - cfg.t.cfg.s.bdDLSAP.noOfDlc = 8; - - cfg.t.cfg.s.bdDLSAP.tei[0] = 64; - cfg.t.cfg.s.bdDLSAP.tei[1] = 65; - cfg.t.cfg.s.bdDLSAP.tei[2] = 66; - cfg.t.cfg.s.bdDLSAP.tei[3] = 67; - cfg.t.cfg.s.bdDLSAP.tei[4] = 68; - cfg.t.cfg.s.bdDLSAP.tei[5] = 69; - cfg.t.cfg.s.bdDLSAP.tei[6] = 70; - cfg.t.cfg.s.bdDLSAP.tei[7] = 71; - } else { - cfg.t.cfg.s.bdDLSAP.teiAss = AUTOMATIC; - cfg.t.cfg.s.bdDLSAP.noOfDlc = 1; - } - } else { - /* Point to point configs */ - cfg.t.cfg.s.bdDLSAP.teiAss = NON_AUTOMATIC; - cfg.t.cfg.s.bdDLSAP.noOfDlc = 1; - cfg.t.cfg.s.bdDLSAP.tei[0] = signal_data->tei; - } - } - - if (sng_isdn_q921_config(&pst, &cfg)) { - return FTDM_FAIL; - } - return FTDM_SUCCESS; -} - -ftdm_status_t sngisdn_stack_cfg_q931_gen(void) -{ - InMngmt cfg; - Pst pst; - - /* initalize the post structure */ - stack_pst_init(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTIN; - - /*clear the configuration structure*/ - memset(&cfg, 0, sizeof(cfg)); - - /*fill in some general sections of the header*/ - stack_hdr_init(&cfg.hdr); - - /*fill in the specific fields of the header*/ - cfg.hdr.msgType = TCFG; - cfg.hdr.entId.ent = ENTIN; - cfg.hdr.entId.inst = S_INST; - cfg.hdr.elmId.elmnt = STGEN; - - /* fill in the Gen Conf structures internal pst struct */ - stack_pst_init(&cfg.t.cfg.s.inGen.sm); - - cfg.t.cfg.s.inGen.nmbSaps = MAX_VARIANTS+1; /* Total number of variants supported */ - - cfg.t.cfg.s.inGen.nmbLnks = MAX_L1_LINKS+1; /* number of Data Link SAPs */ - cfg.t.cfg.s.inGen.nmbSigLnks = MAX_L1_LINKS+1; - - /* number of CESs */ - cfg.t.cfg.s.inGen.nmbCes = (MAX_L1_LINKS+1)*MAX_NUM_CES_PER_LINK; - /* number of global Call References can have 2 per channel when using HOLD/RESUME */ - cfg.t.cfg.s.inGen.nmbCalRef = MAX_NUM_CALLS; - /* number of bearer channels */ - cfg.t.cfg.s.inGen.nmbBearer = NUM_E1_CHANNELS_PER_SPAN*(MAX_L1_LINKS+1); - /* maximum number of routing entries */ - cfg.t.cfg.s.inGen.nmbRouts = 0; - /* number of profiles */ - cfg.t.cfg.s.inGen.nmbProfiles = 0; - /* upper pool threshold */ - cfg.t.cfg.s.inGen.poolTrUpper = INGEN_POOL_UP_TR; - /* time resolution */ - cfg.t.cfg.s.inGen.timeRes = 100; /* timer resolution = 1 sec */ - - cfg.t.cfg.s.inGen.sm.dstEnt = ENTSM; - - if (sng_isdn_q931_config(&pst, &cfg)) { - return FTDM_FAIL; - } - return FTDM_SUCCESS; -} - -/* Link between CC and q931 */ -ftdm_status_t sngisdn_stack_cfg_q931_tsap(ftdm_span_t *span) -{ - InMngmt cfg; - Pst pst; - unsigned i; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)span->signal_data; - /* initalize the post structure */ - stack_pst_init(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTIN; - - /*clear the configuration structure*/ - memset(&cfg, 0, sizeof(cfg)); - - /*fill in some general sections of the header*/ - stack_hdr_init(&cfg.hdr); - - /*fill in the specific fields of the header*/ - cfg.hdr.msgType = TCFG; - cfg.hdr.entId.ent = ENTIN; - cfg.hdr.entId.inst = S_INST; - cfg.hdr.elmId.elmnt = STTSAP; - - cfg.t.cfg.s.inTSAP.sapId = signal_data->cc_id; - - cfg.t.cfg.s.inTSAP.prior = PRIOR0; - cfg.t.cfg.s.inTSAP.route = RTESPEC; - - cfg.t.cfg.s.inTSAP.swtch = sng_isdn_stack_switchtype(signal_data->switchtype); - cfg.t.cfg.s.inTSAP.useSubAdr = 0; /* call routing on subaddress */ - cfg.t.cfg.s.inTSAP.adrPref = 0; /* use of prefix for int'l calls */ - cfg.t.cfg.s.inTSAP.nmbPrefDig = 0; /* number of digits used for prefix */ - - for (i = 0; i < IN_MAXPREFDIG; i++) - cfg.t.cfg.s.inTSAP.prefix[i] = 0; /* address prefix */ - - cfg.t.cfg.s.inTSAP.keyPad = 0; - cfg.t.cfg.s.inTSAP.wcRout = 0; - - for (i = 0; i < ADRLEN; i++) - cfg.t.cfg.s.inTSAP.wcMask[i] = 0; /* address prefix */ - - cfg.t.cfg.s.inTSAP.sidIns = FALSE; /* SID insertion Flag */ - cfg.t.cfg.s.inTSAP.sid.length = 0; /* SID */ - cfg.t.cfg.s.inTSAP.sidTon = 0; /* SID Type of Number */ - cfg.t.cfg.s.inTSAP.sidNPlan = 0; /* SID Numbering Plan */ - cfg.t.cfg.s.inTSAP.callId.len = 0; /* Default Call Identity */ - cfg.t.cfg.s.inTSAP.minAdrDig = 0; /* Minimum number of address digits */ - cfg.t.cfg.s.inTSAP.comptChck = FALSE; /* Validate compatibility */ - cfg.t.cfg.s.inTSAP.nmbApplProf = 0; /* Number of application profiles */ - cfg.t.cfg.s.inTSAP.profNmb[0] = 0; /* Application profiles */ - cfg.t.cfg.s.inTSAP.mem.region = S_REG; - cfg.t.cfg.s.inTSAP.mem.pool = S_POOL; - cfg.t.cfg.s.inTSAP.selector = 0; - - - if (sng_isdn_q931_config(&pst, &cfg)) { - return FTDM_FAIL; - } - return FTDM_SUCCESS; -} - -ftdm_status_t sngisdn_stack_cfg_q931_dlsap(ftdm_span_t *span) -{ - InMngmt cfg; - Pst pst; - - unsigned i; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)span->signal_data; - /* initalize the post structure */ - stack_pst_init(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTIN; - - /*clear the configuration structure*/ - memset(&cfg, 0, sizeof(cfg)); - - /*fill in some general sections of the header*/ - stack_hdr_init(&cfg.hdr); - - /*fill in the specific fields of the header*/ - cfg.hdr.msgType = TCFG; - cfg.hdr.entId.ent = ENTIN; - cfg.hdr.entId.inst = S_INST; - cfg.hdr.elmId.elmnt = STDLSAP; - - cfg.hdr.response.selector=0; - - cfg.t.cfg.s.inDLSAP.sapId = signal_data->link_id; - cfg.t.cfg.s.inDLSAP.spId = signal_data->link_id; - - cfg.t.cfg.s.inDLSAP.swtch = sng_isdn_stack_switchtype(signal_data->switchtype); - - cfg.t.cfg.s.inDLSAP.n201 = 1024; - cfg.t.cfg.s.inDLSAP.nmbRst = 2; - cfg.t.cfg.s.inDLSAP.tCbCfg = TRUE; - - cfg.t.cfg.s.inDLSAP.tCbId = signal_data->cc_id; - - if (signal_data->facility == SNGISDN_OPT_TRUE) { - cfg.t.cfg.s.inDLSAP.facilityHandling = IN_FACILITY_STANDRD; - } else { - cfg.t.cfg.s.inDLSAP.facilityHandling = 0; - } - - if (!signal_data->nfas.trunk) { - cfg.t.cfg.s.inDLSAP.nfasInt = FALSE; - cfg.t.cfg.s.inDLSAP.intId = 0; - cfg.t.cfg.s.inDLSAP.sigInt = 0; - cfg.t.cfg.s.inDLSAP.bupInt = 0; - cfg.t.cfg.s.inDLSAP.nmbNfasInt = 0; - cfg.t.cfg.s.inDLSAP.buIntPr = FALSE; - - for (i = 0; i < IN_MAX_NMB_INTRFS; i++) - cfg.t.cfg.s.inDLSAP.ctldInt[i] = IN_INT_NOT_CFGD; - - } else { - cfg.t.cfg.s.inDLSAP.nfasInt = TRUE; - cfg.t.cfg.s.inDLSAP.intId = signal_data->nfas.interface_id; - - for (i = 0; i < IN_MAX_NMB_INTRFS; i++) - cfg.t.cfg.s.inDLSAP.ctldInt[i] = IN_INT_NOT_CFGD; - - switch (signal_data->nfas.sigchan) { - case SNGISDN_NFAS_DCHAN_PRIMARY: - cfg.t.cfg.s.inDLSAP.sigInt = signal_data->nfas.trunk->dchan->link_id; - cfg.t.cfg.s.inDLSAP.nmbNfasInt = signal_data->nfas.trunk->num_spans; - - if (signal_data->nfas.trunk->backup) { - cfg.t.cfg.s.inDLSAP.buIntPr = TRUE; - cfg.t.cfg.s.inDLSAP.bupInt = signal_data->nfas.trunk->backup->link_id; - } else { - cfg.t.cfg.s.inDLSAP.buIntPr = FALSE; - } - - for (i = 0; i < MAX_SPANS_PER_NFAS_LINK; i++) { - if (signal_data->nfas.trunk->spans[i]) { - cfg.t.cfg.s.inDLSAP.ctldInt[i] = signal_data->nfas.trunk->spans[i]->link_id; - } - } - - break; - case SNGISDN_NFAS_DCHAN_BACKUP: - cfg.t.cfg.s.inDLSAP.sigInt = signal_data->nfas.trunk->dchan->link_id; - cfg.t.cfg.s.inDLSAP.nmbNfasInt = signal_data->nfas.trunk->num_spans; - - if (signal_data->nfas.trunk->backup) { - cfg.t.cfg.s.inDLSAP.buIntPr = TRUE; - cfg.t.cfg.s.inDLSAP.bupInt = signal_data->nfas.trunk->backup->link_id; - } else { - cfg.t.cfg.s.inDLSAP.buIntPr = FALSE; - } - - for (i = 0; i < MAX_SPANS_PER_NFAS_LINK; i++) { - if (signal_data->nfas.trunk->spans[i]) { - cfg.t.cfg.s.inDLSAP.ctldInt[i] = signal_data->nfas.trunk->spans[i]->link_id; - } - } - - break; - case SNGISDN_NFAS_DCHAN_NONE: - cfg.t.cfg.s.inDLSAP.sigInt = signal_data->nfas.trunk->dchan->link_id; - cfg.t.cfg.s.inDLSAP.nmbNfasInt = 0; - - break; - } - } - - cfg.t.cfg.s.inDLSAP.numRstInd = 255; - cfg.t.cfg.s.inDLSAP.relOpt = TRUE; -#ifdef ISDN_SRV - cfg.t.cfg.s.inDLSAP.bcas = FALSE; - cfg.t.cfg.s.inDLSAP.maxBSrvCnt = 2; - cfg.t.cfg.s.inDLSAP.maxDSrvCnt = 2; -#endif /* ISDN_SRV */ - - if (signal_data->switchtype == SNGISDN_SWITCH_QSIG) { - cfg.t.cfg.s.inDLSAP.intType = SYM_USER; - cfg.t.cfg.s.inDLSAP.clrGlr = TRUE; /* in case of glare, clear local call */ - cfg.t.cfg.s.inDLSAP.statEnqOpt = FALSE; - cfg.t.cfg.s.inDLSAP.rstOpt = FALSE; - } else { - if (signal_data->signalling == SNGISDN_SIGNALING_NET) { - cfg.t.cfg.s.inDLSAP.intType = NETWORK; - cfg.t.cfg.s.inDLSAP.clrGlr = FALSE; /* in case of glare, do not clear local call */ - cfg.t.cfg.s.inDLSAP.statEnqOpt = TRUE; - - if (signal_data->ftdm_span->trunk_type == FTDM_TRUNK_BRI_PTMP) { - cfg.t.cfg.s.inDLSAP.rstOpt = FALSE; - } else { - cfg.t.cfg.s.inDLSAP.rstOpt = TRUE; - } - } else { - cfg.t.cfg.s.inDLSAP.intType = USER; - cfg.t.cfg.s.inDLSAP.clrGlr = TRUE; /* in case of glare, clear local call */ - cfg.t.cfg.s.inDLSAP.statEnqOpt = FALSE; - cfg.t.cfg.s.inDLSAP.rstOpt = FALSE; - } - } - - if (signal_data->switchtype == SNGISDN_SWITCH_QSIG || - signal_data->switchtype == SNGISDN_SWITCH_5ESS) { - - cfg.t.cfg.s.inDLSAP.ackOpt = TRUE; - } else if (signal_data->signalling == SNGISDN_SIGNALING_NET) { - cfg.t.cfg.s.inDLSAP.ackOpt = TRUE; - } else { - cfg.t.cfg.s.inDLSAP.ackOpt = FALSE; - } - - if (signal_data->send_connect_ack != SNGISDN_OPT_DEFAULT) { - if (signal_data->send_connect_ack == SNGISDN_OPT_TRUE) { - cfg.t.cfg.s.inDLSAP.ackOpt = TRUE; - } else { - cfg.t.cfg.s.inDLSAP.ackOpt = FALSE; - } - } - - /* Override the restart options if user selected that option */ - if (signal_data->restart_opt != SNGISDN_OPT_DEFAULT) { - if (signal_data->restart_opt == SNGISDN_OPT_TRUE) { - cfg.t.cfg.s.inDLSAP.rstOpt = TRUE; - } else { - cfg.t.cfg.s.inDLSAP.rstOpt = FALSE; - } - } - - for (i = 0; i < IN_MAXBCHNL; i++) - { - cfg.t.cfg.s.inDLSAP.bProf[i].profNmb = 0; - cfg.t.cfg.s.inDLSAP.bProf[i].valid = FALSE; - cfg.t.cfg.s.inDLSAP.bProf[i].state = IN_PROV_AVAIL; - } - - if (span->trunk_type == FTDM_TRUNK_BRI_PTMP && - signal_data->signalling == SNGISDN_SIGNALING_NET) { - cfg.t.cfg.s.inDLSAP.nmbCes = MAX_NUM_CES_PER_LINK; - } else { - cfg.t.cfg.s.inDLSAP.nmbCes=1; - } - - cfg.t.cfg.s.inDLSAP.useSubAdr = 0; /* call routing on subaddress */ -#ifdef SANGOMA_ISDN_CHAN_ID_INVERT_BIT - if (signal_data->switchtype == SNGISDN_SWITCH_DMS100 && - g_sngisdn_data.chan_id_invert_extend_bit == SNGISDN_OPT_TRUE) { - /* Since this feature is not standard, we modified Trillium to check - the useSubAdr field and remove the extended bit if this is set, this - is a global configuration and once set, applies to all spans configured - as DMS 100 */ - cfg.t.cfg.s.inDLSAP.useSubAdr = PRSNT_NODEF; - } -#endif - cfg.t.cfg.s.inDLSAP.adrPref = 0; /* use of prefix for international calls */ - cfg.t.cfg.s.inDLSAP.nmbPrefDig = 0; /* number of digits used for prefix */ - for (i = 0; i < IN_MAXPREFDIG; i++) - cfg.t.cfg.s.inDLSAP.prefix[i] = 0; /* address prefix */ - cfg.t.cfg.s.inDLSAP.keyPad = 0; - cfg.t.cfg.s.inDLSAP.wcRout = 0; - for (i = 0; i < ADRLEN; i++) - cfg.t.cfg.s.inDLSAP.wcMask[i] = 0; /* address prefix */ - - cfg.t.cfg.s.inDLSAP.sidIns = FALSE; /* SID insertion flag */ - cfg.t.cfg.s.inDLSAP.sid.length = 0; /* SID */ - cfg.t.cfg.s.inDLSAP.sidTon = 0; /* SID Type of Number */ - cfg.t.cfg.s.inDLSAP.sidNPlan = 0; /* SID Numbering Plan */ - cfg.t.cfg.s.inDLSAP.sidPresInd = FALSE; /* SID Presentation Indicator */ - cfg.t.cfg.s.inDLSAP.minAdrDig = 0; /* minimum number of address digits */ - cfg.t.cfg.s.inDLSAP.srvOpt = FALSE; - cfg.t.cfg.s.inDLSAP.callId.len = 0; /* default call id */ - cfg.t.cfg.s.inDLSAP.redirSubsc = FALSE; /* subscription to call redirection */ - cfg.t.cfg.s.inDLSAP.redirAdr.eh.pres = NOTPRSNT; /* redirAdr Numbering Plan */ - cfg.t.cfg.s.inDLSAP.forwSubsc = FALSE; /* programmed forwarding subscription */ - cfg.t.cfg.s.inDLSAP.cndSubsc = TRUE; /* calling adddress delivery service subscription */ - - cfg.t.cfg.s.inDLSAP.tmr.t301.enb = TRUE; - cfg.t.cfg.s.inDLSAP.tmr.t301.val = 180; - if (signal_data->timer_t301 > 0) { - cfg.t.cfg.s.inDLSAP.tmr.t301.val = signal_data->timer_t301; - } - - /* It looks like ETSI is the only variant that supports Overlap */ - if (signal_data->switchtype == SNGISDN_SWITCH_EUROISDN) { - cfg.t.cfg.s.inDLSAP.tmr.t302.enb = TRUE; - cfg.t.cfg.s.inDLSAP.tmr.t302.val = 15; - } else { - cfg.t.cfg.s.inDLSAP.tmr.t302.enb = FALSE; - cfg.t.cfg.s.inDLSAP.tmr.t302.val = 0; - } - - if (signal_data->timer_t302 > 0) { - cfg.t.cfg.s.inDLSAP.tmr.t302.val = signal_data->timer_t302; - } - - cfg.t.cfg.s.inDLSAP.tmr.t303.enb = TRUE; - cfg.t.cfg.s.inDLSAP.tmr.t303.val = 4; - - if (signal_data->timer_t303 > 0) { - cfg.t.cfg.s.inDLSAP.tmr.t303.val = signal_data->timer_t303; - } - - cfg.t.cfg.s.inDLSAP.tmr.t304.enb = TRUE; - cfg.t.cfg.s.inDLSAP.tmr.t304.val = 30; - - if (signal_data->timer_t304 > 0) { - cfg.t.cfg.s.inDLSAP.tmr.t304.val = signal_data->timer_t304; - } - - cfg.t.cfg.s.inDLSAP.tmr.t305.enb = TRUE; - cfg.t.cfg.s.inDLSAP.tmr.t305.val = 30; - - if (signal_data->timer_t305 > 0) { - cfg.t.cfg.s.inDLSAP.tmr.t305.val = signal_data->timer_t305; - } - - cfg.t.cfg.s.inDLSAP.tmr.t306.enb = FALSE; - cfg.t.cfg.s.inDLSAP.tmr.t306.val = 35; - - if (signal_data->timer_t306 > 0) { - cfg.t.cfg.s.inDLSAP.tmr.t306.val = signal_data->timer_t306; - } - - cfg.t.cfg.s.inDLSAP.tmr.t307.enb = FALSE; - cfg.t.cfg.s.inDLSAP.tmr.t307.val = 35; - - if (signal_data->timer_t307 > 0) { - cfg.t.cfg.s.inDLSAP.tmr.t307.val = signal_data->timer_t307; - } - - cfg.t.cfg.s.inDLSAP.tmr.t308.enb = TRUE; - cfg.t.cfg.s.inDLSAP.tmr.t308.val = 4; - cfg.t.cfg.s.inDLSAP.tmr.t310.enb = TRUE; - cfg.t.cfg.s.inDLSAP.tmr.t310.val = 120; - - if (signal_data->timer_t308 > 0) { - cfg.t.cfg.s.inDLSAP.tmr.t308.val = signal_data->timer_t308; - } - - if (signal_data->signalling == SNGISDN_SIGNALING_NET) { - cfg.t.cfg.s.inDLSAP.tmr.t312.enb = TRUE; - cfg.t.cfg.s.inDLSAP.tmr.t312.val = cfg.t.cfg.s.inDLSAP.tmr.t303.val+2; - } else { - cfg.t.cfg.s.inDLSAP.tmr.t312.enb = FALSE; - } - - if (signal_data->timer_t310 > 0) { - cfg.t.cfg.s.inDLSAP.tmr.t310.val = signal_data->timer_t310; - } - - if (signal_data->timer_t312 > 0) { - cfg.t.cfg.s.inDLSAP.tmr.t312.val = signal_data->timer_t312; - } - - cfg.t.cfg.s.inDLSAP.tmr.t313.enb = TRUE; - cfg.t.cfg.s.inDLSAP.tmr.t313.val = 4; - - if (signal_data->timer_t313 > 0) { - cfg.t.cfg.s.inDLSAP.tmr.t313.val = signal_data->timer_t313; - } - - cfg.t.cfg.s.inDLSAP.tmr.t316.enb = TRUE; - cfg.t.cfg.s.inDLSAP.tmr.t316.val = 120; - - if (signal_data->timer_t316 > 0) { - cfg.t.cfg.s.inDLSAP.tmr.t316.val = signal_data->timer_t316; - } - - cfg.t.cfg.s.inDLSAP.tmr.t316c.enb = FALSE; - cfg.t.cfg.s.inDLSAP.tmr.t316c.val = 35; - - cfg.t.cfg.s.inDLSAP.tmr.t318.enb = TRUE; - cfg.t.cfg.s.inDLSAP.tmr.t318.val = 4; - - if (signal_data->timer_t318 > 0) { - cfg.t.cfg.s.inDLSAP.tmr.t318.val = signal_data->timer_t318; - } - - cfg.t.cfg.s.inDLSAP.tmr.t319.enb = TRUE; - cfg.t.cfg.s.inDLSAP.tmr.t319.val = 4; - - if (signal_data->timer_t319 > 0) { - cfg.t.cfg.s.inDLSAP.tmr.t319.val = signal_data->timer_t319; - } - - cfg.t.cfg.s.inDLSAP.tmr.t322.enb = TRUE; - cfg.t.cfg.s.inDLSAP.tmr.t322.val = 4; - - if (signal_data->timer_t322 > 0) { - cfg.t.cfg.s.inDLSAP.tmr.t322.val = signal_data->timer_t322; - } - - cfg.t.cfg.s.inDLSAP.tmr.t332.enb = FALSE; - cfg.t.cfg.s.inDLSAP.tmr.t332.val = 35; - - cfg.t.cfg.s.inDLSAP.tmr.tRst.enb = TRUE; - cfg.t.cfg.s.inDLSAP.tmr.tRst.val = 8; - - cfg.t.cfg.s.inDLSAP.tmr.tAns.enb = FALSE; /* non-standard timer */ - cfg.t.cfg.s.inDLSAP.tmr.t396.enb = FALSE; /* non-standard timer */ - cfg.t.cfg.s.inDLSAP.tmr.t397.enb = TRUE; /* non-standard timer */ - cfg.t.cfg.s.inDLSAP.tmr.tProg.enb= TRUE; - cfg.t.cfg.s.inDLSAP.tmr.tProg.val= 35; -#ifdef NI2 -#ifdef NI2_TREST - cfg.t.cfg.s.inDLSAP.tmr.tRest.enb= FALSE; - cfg.t.cfg.s.inDLSAP.tmr.tRest.val= 35; /* tRest timer for NI2 */ -#endif /* NI2_TREST */ -#endif /* NI2 */ - - cfg.t.cfg.s.inDLSAP.dstEnt = ENTLD; - cfg.t.cfg.s.inDLSAP.dstInst = S_INST; - cfg.t.cfg.s.inDLSAP.dstProcId = SFndProcId(); - cfg.t.cfg.s.inDLSAP.prior = PRIOR0; - cfg.t.cfg.s.inDLSAP.route = RTESPEC; - cfg.t.cfg.s.inDLSAP.selector = 0; - cfg.t.cfg.s.inDLSAP.mem.region = S_REG; - cfg.t.cfg.s.inDLSAP.mem.pool = S_POOL; - - switch (span->trunk_type) { - case FTDM_TRUNK_E1: - cfg.t.cfg.s.inDLSAP.dChannelNum = 16; - cfg.t.cfg.s.inDLSAP.nmbBearChan = NUM_E1_CHANNELS_PER_SPAN; - cfg.t.cfg.s.inDLSAP.firstBChanNum = 0; - cfg.t.cfg.s.inDLSAP.callRefLen = 2; - cfg.t.cfg.s.inDLSAP.teiAlloc = IN_STATIC; - cfg.t.cfg.s.inDLSAP.intCfg = IN_INTCFG_PTPT; - break; - case FTDM_TRUNK_T1: - case FTDM_TRUNK_J1: - /* if NFAS, could be 0 if no signalling */ - cfg.t.cfg.s.inDLSAP.callRefLen = 2; - cfg.t.cfg.s.inDLSAP.teiAlloc = IN_STATIC; - cfg.t.cfg.s.inDLSAP.intCfg = IN_INTCFG_PTPT; - cfg.t.cfg.s.inDLSAP.firstBChanNum = 1; - - if (signal_data->nfas.trunk) { - if (signal_data->nfas.sigchan == SNGISDN_NFAS_DCHAN_PRIMARY || - signal_data->nfas.sigchan == SNGISDN_NFAS_DCHAN_BACKUP) { - - cfg.t.cfg.s.inDLSAP.dChannelNum = 24; - cfg.t.cfg.s.inDLSAP.nmbBearChan = NUM_T1_CHANNELS_PER_SPAN - 1; - } else { - cfg.t.cfg.s.inDLSAP.dChannelNum = 0; - cfg.t.cfg.s.inDLSAP.nmbBearChan = NUM_T1_CHANNELS_PER_SPAN; - } - } else { - cfg.t.cfg.s.inDLSAP.dChannelNum = 24; - cfg.t.cfg.s.inDLSAP.nmbBearChan = NUM_T1_CHANNELS_PER_SPAN; - cfg.t.cfg.s.inDLSAP.firstBChanNum = 1; - } - break; - case FTDM_TRUNK_BRI: - cfg.t.cfg.s.inDLSAP.dChannelNum = 0; /* Unused for BRI */ - cfg.t.cfg.s.inDLSAP.nmbBearChan = NUM_BRI_CHANNELS_PER_SPAN; - cfg.t.cfg.s.inDLSAP.firstBChanNum = 1; - cfg.t.cfg.s.inDLSAP.callRefLen = 1; - cfg.t.cfg.s.inDLSAP.teiAlloc = IN_STATIC; - cfg.t.cfg.s.inDLSAP.intCfg = IN_INTCFG_PTPT; - break; - case FTDM_TRUNK_BRI_PTMP: - cfg.t.cfg.s.inDLSAP.dChannelNum = 0; /* Unused for BRI */ - cfg.t.cfg.s.inDLSAP.nmbBearChan = NUM_BRI_CHANNELS_PER_SPAN; - cfg.t.cfg.s.inDLSAP.firstBChanNum = 1; - cfg.t.cfg.s.inDLSAP.callRefLen = 1; - cfg.t.cfg.s.inDLSAP.teiAlloc = IN_DYNAMIC; - cfg.t.cfg.s.inDLSAP.intCfg = IN_INTCFG_MULTI; - break; - default: - ftdm_log(FTDM_LOG_ERROR, "%s: Unsupported trunk_type\n", span->name); - return FTDM_FAIL; - } - - if (sng_isdn_q931_config(&pst, &cfg)) { - return FTDM_FAIL; - } - return FTDM_SUCCESS; -} - -ftdm_status_t sngisdn_stack_cfg_q931_lce(ftdm_span_t *span) -{ - InMngmt cfg; - Pst pst; - uint8_t i; - uint8_t numCes=1; - - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)span->signal_data; - if (span->trunk_type == FTDM_TRUNK_BRI_PTMP && signal_data->signalling == SNGISDN_SIGNALING_NET) { - numCes = 8; - } - /* initalize the post structure */ - stack_pst_init(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTIN; - - /*clear the configuration structure*/ - memset(&cfg, 0, sizeof(cfg)); - - /*fill in some general sections of the header*/ - stack_hdr_init(&cfg.hdr); - - /*fill in the specific fields of the header*/ - cfg.hdr.msgType = TCFG; - cfg.hdr.entId.ent = ENTIN; - cfg.hdr.entId.inst = S_INST; - cfg.hdr.elmId.elmnt = STDLC; - - cfg.hdr.response.selector=0; - - cfg.t.cfg.s.inLCe.sapId = signal_data->link_id; - - if (span->trunk_type == FTDM_TRUNK_BRI_PTMP) { - /* Stack will send Restart CFM's each time link is established (TEI negotiated), - and we do not want thi s event */ - cfg.t.cfg.s.inLCe.lnkUpDwnInd = FALSE; - } else { - cfg.t.cfg.s.inLCe.lnkUpDwnInd = TRUE; - } - - if (FTDM_SPAN_IS_BRI(span)) { - /* tCon Timer causes unwanted hangup on BRI links - where the Q.921 link goes into disconnected - state when idle. */ - - cfg.t.cfg.s.inLCe.tCon.enb = FALSE; - cfg.t.cfg.s.inLCe.tCon.val = 0; - } else { - cfg.t.cfg.s.inLCe.tCon.enb = TRUE; - cfg.t.cfg.s.inLCe.tCon.val = 35; - } - - cfg.t.cfg.s.inLCe.tDisc.enb = TRUE; - cfg.t.cfg.s.inLCe.tDisc.val = 35; - cfg.t.cfg.s.inLCe.t314.enb = FALSE; /* if segmentation enabled, set to TRUE */ - cfg.t.cfg.s.inLCe.t314.val = 35; - - if (signal_data->nfas.trunk) { - cfg.t.cfg.s.inLCe.t332i.enb = TRUE; - cfg.t.cfg.s.inLCe.t332i.val = 35; - } else { - cfg.t.cfg.s.inLCe.t332i.enb = FALSE; - cfg.t.cfg.s.inLCe.t332i.val = 35; - } - -#if (ISDN_NI1 || ISDN_NT || ISDN_ATT) - cfg.t.cfg.s.inLCe.tSpid.enb = TRUE; - cfg.t.cfg.s.inLCe.tSpid.val = 5; - - /* In case we want to support BRI - NORTH America, we will need to configure 8 spid's per CES */ - cfg.t.cfg.s.inLCe.spid.pres = NOTPRSNT; - cfg.t.cfg.s.inLCe.spid.len = 0; -#endif - cfg.t.cfg.s.inLCe.tRstAck.enb = TRUE; - cfg.t.cfg.s.inLCe.tRstAck.val = 10; - - cfg.t.cfg.s.inLCe.usid = 0; - cfg.t.cfg.s.inLCe.tid = 0; - - for(i=0;isignal_data; - - /* initalize the post structure */ - stack_pst_init(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTCC; - - /*clear the configuration structure*/ - memset(&cfg, 0, sizeof(cfg)); - - /*fill in some general sections of the header*/ - stack_hdr_init(&cfg.hdr); - - /*fill in the specific fields of the header*/ - cfg.hdr.msgType = TCFG; - cfg.hdr.entId.ent = ENTCC; - cfg.hdr.entId.inst = S_INST; - cfg.hdr.elmId.elmnt = STTSAP; - - cfg.t.cfg.s.ccISAP.pst.srcProcId = SFndProcId(); - cfg.t.cfg.s.ccISAP.pst.srcEnt = ENTCC; - cfg.t.cfg.s.ccISAP.pst.srcInst = S_INST; - cfg.t.cfg.s.ccISAP.pst.dstEnt = ENTIN; - cfg.t.cfg.s.ccISAP.pst.dstInst = S_INST; - cfg.t.cfg.s.ccISAP.pst.dstProcId = SFndProcId(); - - cfg.t.cfg.s.ccISAP.pst.prior = PRIOR0; - cfg.t.cfg.s.ccISAP.pst.route = RTESPEC; - cfg.t.cfg.s.ccISAP.pst.region = S_REG; - cfg.t.cfg.s.ccISAP.pst.pool = S_POOL; - cfg.t.cfg.s.ccISAP.pst.selector = 0; - - cfg.t.cfg.s.ccISAP.suId = signal_data->cc_id; - cfg.t.cfg.s.ccISAP.spId = signal_data->cc_id; - - cfg.t.cfg.s.ccISAP.swtch = sng_isdn_stack_switchtype(signal_data->switchtype); - cfg.t.cfg.s.ccISAP.sapType = SNG_SAP_TYPE_ISDN; - - if (sng_isdn_cc_config(&pst, &cfg)) { - return FTDM_FAIL; - } - return FTDM_SUCCESS; -} - -/* TODO: see if we can move this to inside the library */ -void stack_pst_init(Pst *pst) -{ - memset(pst, 0, sizeof(Pst)); - /*fill in the post structure*/ - pst->dstProcId = SFndProcId(); - pst->dstInst = S_INST; - - pst->srcProcId = SFndProcId(); - pst->srcEnt = ENTSM; - pst->srcInst = S_INST; - - pst->prior = PRIOR0; - pst->route = RTESPEC; - pst->region = S_REG; - pst->pool = S_POOL; - pst->selector = 0; - return; -} - - - -void stack_hdr_init(Header *hdr) -{ - hdr->msgType = 0; - hdr->msgLen = 0; - hdr->entId.ent = 0; - hdr->entId.inst = 0; - hdr->elmId.elmnt = 0; - hdr->elmId.elmntInst1 = 0; - hdr->elmId.elmntInst2 = 0; - hdr->elmId.elmntInst3 = 0; - hdr->seqNmb = 0; - hdr->version = 0; - hdr->response.prior = PRIOR0; - hdr->response.route = RTESPEC; - hdr->response.mem.region = S_REG; - hdr->response.mem.pool = S_POOL; - hdr->transId = 0; - hdr->response.selector = 0; - return; -} - -uint8_t sng_isdn_stack_switchtype(sngisdn_switchtype_t switchtype) -{ - switch (switchtype) { - case SNGISDN_SWITCH_NI2: - return SW_NI2; - case SNGISDN_SWITCH_5ESS: - return SW_ATT5EP; - case SNGISDN_SWITCH_4ESS: - return SW_ATT4E; - case SNGISDN_SWITCH_DMS100: - return SW_NTDMS100P; - case SNGISDN_SWITCH_EUROISDN: - return SW_ETSI; - case SNGISDN_SWITCH_QSIG: - return SW_QSIG; - case SNGISDN_SWITCH_INSNET: - return SW_INSNET; - case SNGISDN_SWITCH_INVALID: - ftdm_log(FTDM_LOG_ERROR, "Invalid switchtype: %d\n", switchtype); - break; - } - return 0; -} - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ - -/******************************************************************************/ diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cntrl.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cntrl.c deleted file mode 100644 index 6a944e28bb..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cntrl.c +++ /dev/null @@ -1,403 +0,0 @@ -/* - * Copyright (c) 2010, Sangoma Technologies - * David Yat Sin - * Moises Silva - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "ftmod_sangoma_isdn.h" - -void stack_resp_hdr_init(Header *hdr); - -ftdm_status_t sngisdn_activate_phy(ftdm_span_t *span); -ftdm_status_t sngisdn_deactivate_phy(ftdm_span_t *span); - -ftdm_status_t sngisdn_activate_cc(ftdm_span_t *span); - -ftdm_status_t sngisdn_cntrl_q931(ftdm_span_t *span, uint8_t action, uint8_t subaction); -ftdm_status_t sngisdn_cntrl_q921(ftdm_span_t *span, uint8_t action, uint8_t subaction); - - -extern ftdm_sngisdn_data_t g_sngisdn_data; - -ftdm_status_t sngisdn_stack_stop(ftdm_span_t *span); - - -ftdm_status_t sngisdn_stack_start(ftdm_span_t *span) -{ - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)span->signal_data; - - if (signal_data->dchan) { - if (sngisdn_cntrl_q921(span, ABND_ENA, NOTUSED) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_CRIT, "%s:Failed to activate stack q921\n", span->name); - return FTDM_FAIL; - } - ftdm_log(FTDM_LOG_DEBUG, "%s:Stack q921 activated\n", span->name); - } - - /* Try to find an alternative for this */ - /* LAPD will call LdUiDatBndCfm before it received a LdLiMacBndCfm from L1, - so we need to give some time before activating q931, as q931 will send a - LdUiDatConReq when activated, and this requires the Mac SAP to be already - bound first */ - ftdm_sleep(500); - - if (!g_sngisdn_data.ccs[signal_data->cc_id].activation_done) { - g_sngisdn_data.ccs[signal_data->cc_id].activation_done = 1; - if (sngisdn_activate_cc(span) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_CRIT, "%s:Failed to activate stack CC\n", span->name); - return FTDM_FAIL; - } - ftdm_log(FTDM_LOG_DEBUG, "%s:Stack CC activated\n", span->name); - } - - if (sngisdn_cntrl_q931(span, ABND_ENA, SAELMNT) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_CRIT, "%s:Failed to activate stack q931\n", span->name); - return FTDM_FAIL; - } - ftdm_log(FTDM_LOG_DEBUG, "%s:Stack q931 activated\n", span->name); - - ftdm_log(FTDM_LOG_INFO, "%s:Stack activated\n",span->name); - return FTDM_SUCCESS; -} - -ftdm_status_t sngisdn_stack_stop(ftdm_span_t *span) -{ - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)span->signal_data; - /* Stop L1 first, so we do not receive any more frames */ - if (!signal_data->dchan) { - return FTDM_SUCCESS; - } - if (sngisdn_deactivate_phy(span) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_CRIT, "%s:Failed to deactivate stack phy\n", span->name); - return FTDM_FAIL; - } - - if (sngisdn_cntrl_q931(span, AUBND_DIS, SAELMNT) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_CRIT, "%s:Failed to deactivate stack q931\n", span->name); - return FTDM_FAIL; - } - - if (sngisdn_cntrl_q921(span, AUBND_DIS, SAELMNT) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_CRIT, "%s:Failed to deactivate stack q921\n", span->name); - return FTDM_FAIL; - } - - ftdm_log(FTDM_LOG_INFO, "%s:Signalling stopped\n", span->name); - return FTDM_SUCCESS; -} - - -ftdm_status_t sngisdn_activate_phy(ftdm_span_t *span) -{ - - /* There is no need to start phy, as it will Q921 will send a activate request to phy when it starts */ - - return FTDM_SUCCESS; -} - -ftdm_status_t sngisdn_deactivate_phy(ftdm_span_t *span) -{ - L1Mngmt cntrl; - Pst pst; - - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)span->signal_data; - - /* initalize the post structure */ - stack_pst_init(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTL1; - - /* initalize the control structure */ - memset(&cntrl, 0, sizeof(cntrl)); - - /* initalize the control header */ - stack_hdr_init(&cntrl.hdr); - - cntrl.hdr.msgType = TCNTRL; /* configuration */ - cntrl.hdr.entId.ent = ENTL1; /* entity */ - cntrl.hdr.entId.inst = S_INST; /* instance */ - cntrl.hdr.elmId.elmnt = STTSAP; /* SAP Specific cntrl */ - - cntrl.t.cntrl.action = AUBND_DIS; - cntrl.t.cntrl.subAction = SAELMNT; - - cntrl.t.cntrl.sapId = signal_data->link_id; - - if (sng_isdn_phy_cntrl(&pst, &cntrl)) { - return FTDM_FAIL; - } - return FTDM_SUCCESS; -} - -ftdm_status_t sngisdn_wake_up_phy(ftdm_span_t *span) -{ - L1Mngmt cntrl; - Pst pst; - - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)span->signal_data; - - /* initalize the post structure */ - stack_pst_init(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTL1; - - /* initalize the control structure */ - memset(&cntrl, 0, sizeof(cntrl)); - - /* initalize the control header */ - stack_hdr_init(&cntrl.hdr); - - cntrl.hdr.msgType = TCNTRL; /* configuration */ - cntrl.hdr.entId.ent = ENTL1; /* entity */ - cntrl.hdr.entId.inst = S_INST; /* instance */ - cntrl.hdr.elmId.elmnt = STTSAP; /* SAP Specific cntrl */ - - cntrl.t.cntrl.action = AENA; - cntrl.t.cntrl.subAction = SAELMNT; - - cntrl.t.cntrl.sapId = signal_data->link_id; - - if (sng_isdn_phy_cntrl(&pst, &cntrl)) { - return FTDM_FAIL; - } - return FTDM_SUCCESS; -} - -ftdm_status_t sngisdn_activate_cc(ftdm_span_t *span) -{ - CcMngmt cntrl; - Pst pst; - - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)span->signal_data; - - /* initalize the post structure */ - stack_pst_init(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTCC; - - /* initalize the control structure */ - memset(&cntrl, 0, sizeof(cntrl)); - - /* initalize the control header */ - stack_hdr_init(&cntrl.hdr); - - cntrl.hdr.msgType = TCNTRL; /* configuration */ - cntrl.hdr.entId.ent = ENTCC; /* entity */ - cntrl.hdr.entId.inst = S_INST; /* instance */ - cntrl.hdr.elmId.elmnt = STTSAP; /* physical sap */ - - cntrl.t.cntrl.action = ABND_ENA; - cntrl.t.cntrl.subAction = SAELMNT; - - cntrl.t.cntrl.sapId = signal_data->cc_id; - if (sng_isdn_cc_cntrl(&pst, &cntrl)) { - return FTDM_FAIL; - } - return FTDM_SUCCESS; -} - -ftdm_status_t sngisdn_activate_trace(ftdm_span_t *span, sngisdn_tracetype_t trace_opt) -{ - sngisdn_span_data_t *signal_data = sngisdn_dchan((sngisdn_span_data_t*)span->signal_data); - - if (!signal_data) { - ftdm_log(FTDM_LOG_ERROR, "%s:Span is not used by signalling module\n", span->name); - return FTDM_FAIL; - } - - switch (trace_opt) { - case SNGISDN_TRACE_DISABLE: - if (sngisdn_test_trace_flag(signal_data, SNGISDN_TRACE_Q921)) { - ftdm_log(FTDM_LOG_INFO, "%s:Disabling q921 trace\n", signal_data->ftdm_span->name); - sngisdn_clear_trace_flag(signal_data, SNGISDN_TRACE_Q921); - - if (sngisdn_cntrl_q921(signal_data->ftdm_span, ADISIMM, SATRC) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_INFO, "%s:Failed to disable q921 trace\n", signal_data->ftdm_span->name); - } - } - if (sngisdn_test_trace_flag(signal_data, SNGISDN_TRACE_Q931)) { - ftdm_log(FTDM_LOG_INFO, "%s:Disabling q921 trace\n", signal_data->ftdm_span->name); - sngisdn_clear_trace_flag(signal_data, SNGISDN_TRACE_Q931); - - if (sngisdn_cntrl_q931(signal_data->ftdm_span, ADISIMM, SATRC) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_INFO, "%s:Failed to disable q921 trace\n", signal_data->ftdm_span->name); - } - } - break; - case SNGISDN_TRACE_Q921: - if (!sngisdn_test_trace_flag(signal_data, SNGISDN_TRACE_Q921)) { - ftdm_log(FTDM_LOG_INFO, "%s:Enabling q921 trace\n", signal_data->ftdm_span->name); - sngisdn_set_trace_flag(signal_data, SNGISDN_TRACE_Q921); - - if (sngisdn_cntrl_q921(signal_data->ftdm_span, AENA, SATRC) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_INFO, "%s:Failed to enable q921 trace\n", signal_data->ftdm_span->name); - } - } - break; - case SNGISDN_TRACE_Q931: - if (!sngisdn_test_trace_flag(signal_data, SNGISDN_TRACE_Q931)) { - ftdm_log(FTDM_LOG_INFO, "s%d Enabling q931 trace\n", signal_data->link_id); - sngisdn_set_trace_flag(signal_data, SNGISDN_TRACE_Q931); - - if (sngisdn_cntrl_q931(signal_data->ftdm_span, AENA, SATRC) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_INFO, "%s:Failed to enable q931 trace\n", signal_data->ftdm_span->name); - } - } - break; - } - return FTDM_SUCCESS; -} - - -ftdm_status_t sngisdn_cntrl_q931(ftdm_span_t *span, uint8_t action, uint8_t subaction) -{ - InMngmt cntrl; - Pst pst; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)span->signal_data; - - /* initalize the post structure */ - stack_pst_init(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTIN; - - /* initalize the control structure */ - memset(&cntrl, 0, sizeof(cntrl)); - - /* initalize the control header */ - stack_hdr_init(&cntrl.hdr); - - cntrl.hdr.msgType = TCNTRL; /* configuration */ - cntrl.hdr.entId.ent = ENTIN; /* entity */ - cntrl.hdr.entId.inst = S_INST; /* instance */ - cntrl.hdr.elmId.elmnt = STDLSAP; /* physical sap */ - - cntrl.t.cntrl.action = action; - cntrl.t.cntrl.subAction = subaction; - - if (action == AENA && subaction == SATRC) { - cntrl.t.cntrl.trcLen = -1; /* Trace the entire message buffer */ - } - - cntrl.t.cntrl.sapId = signal_data->link_id; - cntrl.t.cntrl.ces = 0; - - if(sng_isdn_q931_cntrl(&pst, &cntrl)) { - return FTDM_FAIL; - } - return FTDM_SUCCESS; - -} - -ftdm_status_t sngisdn_cntrl_q921(ftdm_span_t *span, uint8_t action, uint8_t subaction) -{ - BdMngmt cntrl; - Pst pst; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)span->signal_data; - - /* initalize the post structure */ - stack_pst_init(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTLD; - - /* initalize the control structure */ - memset(&cntrl, 0, sizeof(cntrl)); - - /* initalize the control header */ - stack_hdr_init(&cntrl.hdr); - /* build control request */ - cntrl.hdr.msgType = TCNTRL; - cntrl.hdr.entId.ent = ENTLD; - cntrl.hdr.entId.inst = S_INST; - -#if (SMBD_LMINT3 || BD_LMINT3) - stack_resp_hdr_init(&cntrl.hdr); -#endif /* _LMINT3 */ - - cntrl.hdr.elmId.elmnt = STMSAP; - cntrl.t.cntrl.action = action; - cntrl.t.cntrl.subAction = subaction; - -#if (SMBD_LMINT3 || BD_LMINT3) - cntrl.t.cntrl.lnkNmb = signal_data->link_id; - cntrl.t.cntrl.sapi = NOTUSED; - cntrl.t.cntrl.tei = NOTUSED; -#else /* _LMINT3 */ - cntrl.hdr.elmId.elmntInst1 = signal_data->link_id; - cntrl.hdr.elmId.elmntInst2 = NOTUSED; - cntrl.hdr.elmId.elmntInst3 = NOTUSED; -#endif /* _LMINT3 */ - - cntrl.t.cntrl.logInt = NOTUSED; - cntrl.t.cntrl.trcLen = NOTUSED; - if (action == AENA && subaction == SATRC) { - cntrl.t.cntrl.trcLen = -1; /* Trace the entire message buffer */ - } - - SGetDateTime(&(cntrl.t.cntrl.dt)); - if(sng_isdn_q921_cntrl(&pst, &cntrl)) { - return FTDM_FAIL; - } - - return FTDM_SUCCESS; -} - - -void stack_resp_hdr_init(Header *hdr) -{ - hdr->response.selector = 0; - hdr->response.mem.region = RTESPEC; - hdr->response.mem.pool = S_POOL; - hdr->response.prior = PRIOR0; - hdr->response.route = RTESPEC; - - return; -} - - - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ - -/******************************************************************************/ diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c deleted file mode 100644 index 688c083adb..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c +++ /dev/null @@ -1,1437 +0,0 @@ -/* - * Copyright (c) 2010, Sangoma Technologies - * David Yat Sin - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "ftmod_sangoma_isdn.h" -static ftdm_status_t sngisdn_cause_val_requires_disconnect(ftdm_channel_t *ftdmchan, CauseDgn *causeDgn); -static ftdm_status_t sngisdn_bring_down(ftdm_channel_t *ftdmchan); - -/* Remote side transmit a SETUP */ -void sngisdn_process_con_ind (sngisdn_event_data_t *sngisdn_event) -{ - unsigned i; - int16_t suId = sngisdn_event->suId; - uint32_t suInstId = sngisdn_event->suInstId; - uint32_t spInstId = sngisdn_event->spInstId; - int16_t dChan = sngisdn_event->dChan; - uint8_t ces = sngisdn_event->ces; - sngisdn_chan_data_t *sngisdn_info = sngisdn_event->sngisdn_info; - ftdm_channel_t *ftdmchan = sngisdn_info->ftdmchan; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; - ConEvnt *conEvnt = &sngisdn_event->event.conEvnt; - - ISDN_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - ftdm_assert(!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_STATE_CHANGE), "State change flag pending\n"); - - ftdm_log_chan(sngisdn_info->ftdmchan, FTDM_LOG_DEBUG, "Processing SETUP (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId); - - switch (ftdmchan->state) { - case FTDM_CHANNEL_STATE_DOWN: /* Proper state to receive a SETUP */ - if (signal_data->nfas.trunk) { - ftdm_alarm_flag_t alarmflag = 0; - - ftdm_channel_get_alarms(ftdmchan, &alarmflag); - if (alarmflag) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_INFO, "Received SETUP but channel has physical layer alarm - rejecting\n"); - - ftdmchan->caller_data.hangup_cause = 0x2C; /* Channel requested not available */ - ftdm_sched_timer(signal_data->sched, "delayed_release", 1, sngisdn_delayed_release, (void*) sngisdn_info, NULL); - break; - } - } - - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_INUSE) || - ftdm_channel_open_chan(ftdmchan) != FTDM_SUCCESS) { - - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_INFO, "Received SETUP but channel is in USE, saving call for later processing\n"); - /* the flag the channel as having a collision */ - sngisdn_set_flag(sngisdn_info, FLAG_GLARE); - - /* save the SETUP for processing once the channel has gone to DOWN */ - memcpy(&sngisdn_info->glare.setup, conEvnt, sizeof(*conEvnt)); - sngisdn_info->glare.suId = suId; - sngisdn_info->glare.suInstId = suInstId; /* Do not generate a suInstId now, we will generate when glared call gets extracted */ - sngisdn_info->glare.spInstId = spInstId; - sngisdn_info->glare.dChan = dChan; - sngisdn_info->glare.ces = ces; - break; - } - - sngisdn_info->suInstId = get_unique_suInstId(suId); - sngisdn_info->spInstId = spInstId; - - if (conEvnt->cdPtyNmb.eh.pres && signal_data->num_local_numbers) { - uint8_t local_number_matched = 0; - for (i = 0 ; i < signal_data->num_local_numbers ; i++) { - if (!strcmp(signal_data->local_numbers[i], (char*)conEvnt->cdPtyNmb.nmbDigits.val)) { - local_number_matched++; - break; - } - } - if (!local_number_matched) { - ftdm_log_chan(sngisdn_info->ftdmchan, FTDM_LOG_INFO, "Received SETUP, but local-number %s does not match - ignoring\n", conEvnt->cdPtyNmb.nmbDigits.val); - /* Special case to tell the stack to clear all internal resources about this call. We will no receive any event for this call after sending disconnect request */ - ftdmchan->caller_data.hangup_cause = IN_CCNORTTODEST; - ftdm_sched_timer(signal_data->sched, "delayed_disconnect", 1, sngisdn_delayed_disconnect, (void*) sngisdn_info, NULL); - return; - } - } - - /* If this is a glared call that was previously saved, we moved - all the info to the current call, so clear the glared saved data */ - if (sngisdn_info->glare.spInstId == spInstId) { - clear_call_glare_data(sngisdn_info); - } - - - if (ftdmchan->span->trunk_type == FTDM_TRUNK_BRI_PTMP) { - if (signal_data->signalling == SNGISDN_SIGNALING_NET) { - sngisdn_info->ces = ces; - } - } - - ftdm_mutex_lock(g_sngisdn_data.ccs[suId].mutex); - g_sngisdn_data.ccs[suId].active_suInstIds[sngisdn_info->suInstId] = sngisdn_info; - ftdm_mutex_unlock(g_sngisdn_data.ccs[suId].mutex); - - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND); - - /* try to open the channel */ - if (ftdm_channel_open_chan(ftdmchan) != FTDM_SUCCESS) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "Failed to open channel"); - sngisdn_set_flag(sngisdn_info, FLAG_LOCAL_REL); - ftdmchan->caller_data.hangup_cause = FTDM_CAUSE_NORMAL_TEMPORARY_FAILURE; - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_CANCEL); - break; - } - - /* Fill in call information */ -#ifdef NETBORDER_CALL_REF - get_callref(ftdmchan, &conEvnt->callRef); -#endif - get_calling_num(ftdmchan, &conEvnt->cgPtyNmb); - get_calling_num2(ftdmchan, &conEvnt->cgPtyNmb2); - get_called_num(ftdmchan, &conEvnt->cdPtyNmb); - get_redir_num(ftdmchan, &conEvnt->redirNmb); - get_calling_subaddr(ftdmchan, &conEvnt->cgPtySad); - get_prog_ind_ie(ftdmchan, &conEvnt->progInd); - get_facility_ie(ftdmchan, &conEvnt->facilityStr); - get_calling_name(ftdmchan, conEvnt); - get_network_specific_fac(ftdmchan, &conEvnt->netFac[0]); - - ftdm_log_chan(sngisdn_info->ftdmchan, FTDM_LOG_INFO, "Incoming call: Called No:[%s] Calling No:[%s]\n", ftdmchan->caller_data.dnis.digits, ftdmchan->caller_data.cid_num.digits); - - if (conEvnt->bearCap[0].eh.pres) { - ftdmchan->caller_data.bearer_layer1 = sngisdn_get_usrInfoLyr1Prot_from_stack(conEvnt->bearCap[0].usrInfoLyr1Prot.val); - ftdmchan->caller_data.bearer_capability = sngisdn_get_infoTranCap_from_stack(conEvnt->bearCap[0].infoTranCap.val); - } - - if (conEvnt->shift11.eh.pres && conEvnt->ni2OctStr.eh.pres) { - if (conEvnt->ni2OctStr.str.len == 4 && conEvnt->ni2OctStr.str.val[0] == 0x37) { - uint8_t encoding = (conEvnt->ni2OctStr.str.val[2] >> 5); - if (encoding == 0 || encoding == 1) { - /* BCD even or BCD odd */ - uint8_t value = (conEvnt->ni2OctStr.str.val[3] & 0x0F)*10 + ((conEvnt->ni2OctStr.str.val[3] >> 4) & 0x0F); - snprintf(ftdmchan->caller_data.aniII, 5, "%.2d", value); - } else if (encoding == 2) { - /* IA 5 */ - snprintf(ftdmchan->caller_data.aniII, 5, "%c", conEvnt->ni2OctStr.str.val[3]); - } - } - } - -#if 1 - /* this section will not be needed once asn decoding function with key-value pairs is implemented */ - if (signal_data->facility == SNGISDN_OPT_TRUE && - signal_data->facility_ie_decode != SNGISDN_OPT_FALSE && - conEvnt->facilityStr.eh.pres) { - - /* Verify whether the Caller Name will come in a subsequent FACILITY message */ - uint16_t ret_val; - char retrieved_str[255]; - - ret_val = sng_isdn_retrieve_facility_caller_name(conEvnt->facilityStr.facilityStr.val, conEvnt->facilityStr.facilityStr.len, retrieved_str); - /* - return values for "sng_isdn_retrieve_facility_information_following": - If there will be no information following, or fails to decode IE, returns -1 - If there will be no information following, but current FACILITY IE contains a caller name, returns 0 - If there will be information following, returns 1 - */ - - if (ret_val == 1) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Expecting Caller name in FACILITY\n"); - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_GET_CALLERID); - /* Launch timer in case we never get a FACILITY msg */ - if (signal_data->facility_timeout) { - ftdm_sched_timer(signal_data->sched, "facility_timeout", signal_data->facility_timeout, - sngisdn_facility_timeout, (void*) sngisdn_info, &sngisdn_info->timers[SNGISDN_CHAN_TIMER_FACILITY]); - } - break; - } else if (ret_val == 0) { - strcpy(ftdmchan->caller_data.cid_name, retrieved_str); - } - } -#endif - if (signal_data->overlap_dial == SNGISDN_OPT_TRUE) { - ftdm_size_t min_digits = ((sngisdn_span_data_t*)ftdmchan->span->signal_data)->min_digits; - ftdm_size_t num_digits; - - num_digits = strlen(ftdmchan->caller_data.dnis.digits); - - if (conEvnt->sndCmplt.eh.pres || num_digits >= min_digits) { - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RING); - } else { - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_COLLECT); - } - } else { - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RING); - } - break; - case FTDM_CHANNEL_STATE_TERMINATING: - case FTDM_CHANNEL_STATE_HANGUP: - case FTDM_CHANNEL_STATE_HANGUP_COMPLETE: - ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Processing SETUP in %s state, saving SETUP info for later processing\n", ftdm_channel_state2str(ftdmchan->state)); - ftdm_assert(!sngisdn_test_flag(sngisdn_info, FLAG_GLARE), "Trying to save GLARE info, but we already had a glare\n"); - - sngisdn_set_flag(sngisdn_info, FLAG_GLARE); - - /* save the SETUP for processing once the channel has gone to DOWN */ - memcpy(&sngisdn_info->glare.setup, conEvnt, sizeof(*conEvnt)); - sngisdn_info->glare.suId = suId; - sngisdn_info->glare.suInstId = suInstId; /* Do not generate a suInstId now, we will generate when glared call gets extracted */ - sngisdn_info->glare.spInstId = spInstId; - sngisdn_info->glare.dChan = dChan; - sngisdn_info->glare.ces = ces; - - break; - case FTDM_CHANNEL_STATE_DIALING: /* glare */ - if (signal_data->signalling == SNGISDN_SIGNALING_NET) { - /* Save inbound call info so we can send a RELEASE when this channel goes to a different state */ - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "Processing SETUP in DIALING state, rejecting inbound call\n"); - sngisdn_set_flag(sngisdn_info, FLAG_DELAYED_REL); - - sngisdn_info->glare.suId = suId; - sngisdn_info->glare.suInstId = get_unique_suInstId(suId); - sngisdn_info->glare.spInstId = spInstId; - - sngisdn_info->glare.dChan = dChan; - sngisdn_info->glare.ces = ces; - ftdmchan->caller_data.hangup_cause = 0x2C; /* Channel requested not available */ - ftdm_sched_timer(signal_data->sched, "delayed_release", 1, sngisdn_delayed_release, (void*) sngisdn_info, NULL); - } else { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_INFO, "Processing SETUP in DIALING state, saving SETUP info for later processing\n"); - - /* the flag the channel as having a collision */ - ftdm_assert(!sngisdn_test_flag(sngisdn_info, FLAG_GLARE), "Trying to save GLARE info, but we already had a glare"); - sngisdn_set_flag(sngisdn_info, FLAG_GLARE); - - /* save the SETUP for processing once the channel has gone to DOWN */ - memcpy(&sngisdn_info->glare.setup, conEvnt, sizeof(*conEvnt)); - sngisdn_info->glare.suId = suId; - sngisdn_info->glare.suInstId = suInstId; /* Do not generate a suInstId now, we will generate when glared call gets extracted */ - sngisdn_info->glare.spInstId = spInstId; - sngisdn_info->glare.dChan = dChan; - sngisdn_info->glare.ces = ces; - - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); - } - break; - case FTDM_CHANNEL_STATE_RESET: - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Processing SETUP but channel in RESET state, ignoring\n"); - break; - default: - ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Processing SETUP in an invalid state (%s)\n", ftdm_channel_state2str(ftdmchan->state)); - break; - } - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; -} - -/* Remote side transmit a CONNECT or CONNECT ACK */ -void sngisdn_process_con_cfm (sngisdn_event_data_t *sngisdn_event) -{ - int16_t suId = sngisdn_event->suId; - uint32_t suInstId = sngisdn_event->suInstId; - uint32_t spInstId = sngisdn_event->spInstId; - uint8_t ces = sngisdn_event->ces; - sngisdn_chan_data_t *sngisdn_info = sngisdn_event->sngisdn_info; - ftdm_channel_t *ftdmchan = sngisdn_info->ftdmchan; - CnStEvnt *cnStEvnt = &sngisdn_event->event.cnStEvnt; - - ISDN_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - ftdm_assert(!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_STATE_CHANGE), "State change flag pending\n"); - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Processing CONNECT/CONNECT ACK (suId:%u suInstId:%u spInstId:%u ces:%d)\n", suId, suInstId, spInstId, ces); - - if (ftdmchan->span->trunk_type == FTDM_TRUNK_BRI_PTMP && - ((sngisdn_span_data_t*)ftdmchan->span->signal_data)->signalling == SNGISDN_SIGNALING_NET) { - - if(sngisdn_info->ces == CES_MNGMNT) { - /* We assign the call to the first TE */ - sngisdn_info->ces = ces; - } else { - /* We already assigned this call, do nothing */ - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Call already assigned, ignoring connect\n"); - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - } - - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { - switch(ftdmchan->state) { - case FTDM_CHANNEL_STATE_PROCEED: - case FTDM_CHANNEL_STATE_RINGING: - case FTDM_CHANNEL_STATE_PROGRESS: - case FTDM_CHANNEL_STATE_PROGRESS_MEDIA: - case FTDM_CHANNEL_STATE_DIALING: -#ifdef NETBORDER_CALL_REF - get_callref(ftdmchan, &cnStEvnt->callRef); -#endif - get_prog_ind_ie(ftdmchan, &cnStEvnt->progInd); - get_facility_ie(ftdmchan, &cnStEvnt->facilityStr); - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_UP); - break; - case FTDM_CHANNEL_STATE_HANGUP_COMPLETE: - case FTDM_CHANNEL_STATE_HANGUP: - /* Race condition, we just hung up the call - ignore this message */ - break; - case FTDM_CHANNEL_STATE_RESET: - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Processing SETUP but channel in RESET state, ignoring\n"); - break; - default: - ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Processing CONNECT/CONNECT ACK in an invalid state (%s)\n", ftdm_channel_state2str(ftdmchan->state)); - - /* Start the disconnect procedure */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); - break; - } - } else { - switch(ftdmchan->state) { - case FTDM_CHANNEL_STATE_TRANSFER: - case FTDM_CHANNEL_STATE_UP: - /* These are the only valid states we should get a CONNECT ACK on */ - /* do nothing */ - break; - case FTDM_CHANNEL_STATE_HANGUP_COMPLETE: - /* Race condition, We just hung up an incoming call right after we sent a CONNECT - ignore this message */ - break; - case FTDM_CHANNEL_STATE_RESET: - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Processing SETUP but channel in RESET state, ignoring\n"); - break; - default: - ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Processing CONNECT/CONNECT ACK in an invalid state (%s)\n", ftdm_channel_state2str(ftdmchan->state)); - - /* Start the disconnect procedure */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); - break; - } - } - - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; -} - -void sngisdn_process_cnst_ind (sngisdn_event_data_t *sngisdn_event) -{ - int16_t suId = sngisdn_event->suId; - uint32_t suInstId = sngisdn_event->suInstId; - uint32_t spInstId = sngisdn_event->spInstId; - uint8_t ces = sngisdn_event->ces; - uint8_t evntType = sngisdn_event->evntType; - - sngisdn_chan_data_t *sngisdn_info = sngisdn_event->sngisdn_info; - ftdm_channel_t *ftdmchan = sngisdn_info->ftdmchan; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; - - CnStEvnt *cnStEvnt = &sngisdn_event->event.cnStEvnt; - - ISDN_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - ftdm_assert(!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_STATE_CHANGE), "State change flag pending\n"); - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Processing %s (suId:%u suInstId:%u spInstId:%u ces:%d)\n", - (evntType == MI_ALERTING)?"ALERT": - (evntType == MI_CALLPROC)?"PROCEED": - (evntType == MI_PROGRESS)?"PROGRESS": - (evntType == MI_SETUPACK)?"SETUP ACK": - (evntType == MI_NOTIFY)?"NOTIFY": - (evntType == MI_INFO)?"INFO":"UNKNOWN", - suId, suInstId, spInstId, ces); - - switch(evntType) { - case MI_CALLPROC: - case MI_PROGRESS: - case MI_ALERTING: -#ifdef NETBORDER_CALL_REF - get_callref(ftdmchan, &cnStEvnt->callRef); -#endif - get_prog_ind_ie(ftdmchan, &cnStEvnt->progInd); - get_facility_ie(ftdmchan, &cnStEvnt->facilityStr); - - if (sngisdn_cause_val_requires_disconnect(ftdmchan, &cnStEvnt->causeDgn[0]) == FTDM_SUCCESS) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Cause requires disconnect (cause:%d)\n", cnStEvnt->causeDgn[0].causeVal.val); - ftdmchan->caller_data.hangup_cause = cnStEvnt->causeDgn[0].causeVal.val; - - sngisdn_set_flag(sngisdn_info, FLAG_SEND_DISC); - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); - goto sngisdn_process_cnst_ind_end; - } - - switch(ftdmchan->state) { - case FTDM_CHANNEL_STATE_DIALING: - case FTDM_CHANNEL_STATE_PROCEED: - case FTDM_CHANNEL_STATE_PROGRESS: - case FTDM_CHANNEL_STATE_RINGING: - if ((cnStEvnt->progInd.eh.pres && cnStEvnt->progInd.progDesc.val == IN_PD_IBAVAIL) || - (cnStEvnt->progInd1.eh.pres && cnStEvnt->progInd1.progDesc.val == IN_PD_IBAVAIL) || - (cnStEvnt->progInd2.eh.pres && cnStEvnt->progInd2.progDesc.val == IN_PD_IBAVAIL) || - (cnStEvnt->progInd3.eh.pres && cnStEvnt->progInd3.progDesc.val == IN_PD_IBAVAIL)) { - - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Early media available\n"); - sngisdn_set_flag(sngisdn_info, FLAG_MEDIA_READY); - } else { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Early media not available\n"); - } - switch (evntType) { - case MI_CALLPROC: - if (!sngisdn_test_flag(sngisdn_info, FLAG_MEDIA_READY) && - (signal_data->early_media_flags & SNGISDN_EARLY_MEDIA_ON_PROCEED)) { - - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Early media override on proceed\n"); - sngisdn_set_flag(sngisdn_info, FLAG_MEDIA_READY); - } - if (ftdmchan->state == FTDM_CHANNEL_STATE_DIALING) { - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_PROCEED); - } - break; - case MI_ALERTING: - if (!sngisdn_test_flag(sngisdn_info, FLAG_MEDIA_READY) && - (signal_data->early_media_flags & SNGISDN_EARLY_MEDIA_ON_ALERT)) { - - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Early media override on alert\n"); - sngisdn_set_flag(sngisdn_info, FLAG_MEDIA_READY); - } - if (ftdmchan->state == FTDM_CHANNEL_STATE_PROCEED) { - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RINGING); - } - break; - case MI_PROGRESS: - if (!sngisdn_test_flag(sngisdn_info, FLAG_MEDIA_READY) && - (signal_data->early_media_flags & SNGISDN_EARLY_MEDIA_ON_PROGRESS)) { - - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Early media override on progress\n"); - sngisdn_set_flag(sngisdn_info, FLAG_MEDIA_READY); - } - if (sngisdn_test_flag(sngisdn_info, FLAG_MEDIA_READY)) { - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA); - } else if (ftdmchan->state != FTDM_CHANNEL_STATE_PROGRESS) { - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_PROGRESS); - } - break; - default: - /* We should never reach this section !*/ - ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Don't know how to handle this event %d\n", evntType); - } - break; - case FTDM_CHANNEL_STATE_PROGRESS_MEDIA: - /* We are already in progress media, we can't go to any higher state except up */ - /* Do nothing */ - break; - case FTDM_CHANNEL_STATE_RESET: - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Ignoring ALERT/PROCEED/PROGRESS because channel is in RESET state\n"); - break; - case FTDM_CHANNEL_STATE_HANGUP: - case FTDM_CHANNEL_STATE_HANGUP_COMPLETE: - /* Ignore this message as we already started the hangup process */ - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Ignoring ALERT/PROCEED/PROGRESS because we are already hanging up\n"); - break; - default: - ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Processing ALERT/PROCEED/PROGRESS in an invalid state (%s)\n", ftdm_channel_state2str(ftdmchan->state)); - - /* Start the disconnect procedure */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); - break; - } - break; - case MI_SETUPACK: - ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Processing SETUP_ACK, but overlap sending not implemented (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId); - break; - case MI_INFO: - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Processing INFO (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId); - - if (cnStEvnt->cdPtyNmb.eh.pres) { - switch(ftdmchan->state) { - case FTDM_CHANNEL_STATE_COLLECT: - { - ftdm_size_t min_digits = ((sngisdn_span_data_t*)ftdmchan->span->signal_data)->min_digits; - ftdm_size_t num_digits; - - get_called_num(ftdmchan, &cnStEvnt->cdPtyNmb); - num_digits = strlen(ftdmchan->caller_data.dnis.digits); - - if (cnStEvnt->sndCmplt.eh.pres || num_digits >= min_digits) { - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RING); - } else { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "received %"FTDM_SIZE_FMT" of %"FTDM_SIZE_FMT" digits\n", num_digits, min_digits); - } - } - break; - case FTDM_CHANNEL_STATE_RING: - case FTDM_CHANNEL_STATE_RINGING: - case FTDM_CHANNEL_STATE_PROCEED: - case FTDM_CHANNEL_STATE_PROGRESS: - case FTDM_CHANNEL_STATE_PROGRESS_MEDIA: - case FTDM_CHANNEL_STATE_UP: - ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Receiving more digits %s, but we already proceeded with call\n", cnStEvnt->cdPtyNmb.nmbDigits.val); - break; - case FTDM_CHANNEL_STATE_RESET: - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Processing SETUP but channel in RESET state, ignoring\n"); - break; - default: - ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Unhandled INFO (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId); - break; - } - } - break; - case MI_NOTIFY: - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Processing NOTIFY (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId); - /* Do nothing */ - break; - default: - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "Unhandled STATUS event\n"); - break; - } - -sngisdn_process_cnst_ind_end: - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; -} - -void sngisdn_process_disc_ind (sngisdn_event_data_t *sngisdn_event) -{ - int16_t suId = sngisdn_event->suId; - uint32_t suInstId = sngisdn_event->suInstId; - uint32_t spInstId = sngisdn_event->spInstId; - sngisdn_chan_data_t *sngisdn_info = sngisdn_event->sngisdn_info; - ftdm_channel_t *ftdmchan = sngisdn_info->ftdmchan; - - DiscEvnt *discEvnt = &sngisdn_event->event.discEvnt; - - ISDN_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Processing DISCONNECT (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId); - - ftdm_assert(!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_STATE_CHANGE), "State change flag pending\n"); - switch (ftdmchan->state) { - case FTDM_CHANNEL_STATE_RING: - case FTDM_CHANNEL_STATE_RINGING: - case FTDM_CHANNEL_STATE_DIALING: - case FTDM_CHANNEL_STATE_PROCEED: - case FTDM_CHANNEL_STATE_PROGRESS: - case FTDM_CHANNEL_STATE_PROGRESS_MEDIA: - case FTDM_CHANNEL_STATE_UP: - get_facility_ie(ftdmchan, &discEvnt->facilityStr); - - if (discEvnt->causeDgn[0].eh.pres && discEvnt->causeDgn[0].causeVal.pres) { - ftdmchan->caller_data.hangup_cause = discEvnt->causeDgn[0].causeVal.val; - } else { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "DISCONNECT did not have a cause code\n"); - ftdmchan->caller_data.hangup_cause = 0; - } - sngisdn_set_flag(sngisdn_info, FLAG_REMOTE_REL); - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); - break; - case FTDM_CHANNEL_STATE_COLLECT: - case FTDM_CHANNEL_STATE_GET_CALLERID: - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_CANCEL); - break; - case FTDM_CHANNEL_STATE_DOWN: - /* somehow we are in down, nothing we can do locally */ - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "Received DISCONNECT but we are in DOWN state\n"); - break; - case FTDM_CHANNEL_STATE_HANGUP_COMPLETE: - /* This is a race condition. We just sent a DISCONNECT, on this channel */ - /* Do nothing */ - break; - case FTDM_CHANNEL_STATE_RESET: - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Processing SETUP but channel in RESET state, ignoring\n"); - break; - default: - ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Received DISCONNECT in an invalid state (%s)\n", - ftdm_channel_state2str(ftdmchan->state)); - /* start reset procedure */ - - /* Start the release procedure */ - ftdm_set_flag(sngisdn_info, FLAG_REMOTE_REL); - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); - break; - } - - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; -} - -void sngisdn_process_rel_ind (sngisdn_event_data_t *sngisdn_event) -{ - int16_t suId = sngisdn_event->suId; - uint32_t suInstId = sngisdn_event->suInstId; - uint32_t spInstId = sngisdn_event->spInstId; - sngisdn_chan_data_t *sngisdn_info = sngisdn_event->sngisdn_info; - ftdm_channel_t *ftdmchan = sngisdn_info->ftdmchan; - - RelEvnt *relEvnt = &sngisdn_event->event.relEvnt; - - ISDN_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Processing RELEASE/RELEASE COMPLETE (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId); - - ftdm_assert(!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_STATE_CHANGE), "State change flag pending\n"); - - if ((suInstId && (sngisdn_info->glare.suInstId == suInstId)) || - (spInstId && (sngisdn_info->glare.spInstId == spInstId))) { - - /* This hangup is for a glared saved call */ - ftdm_clear_flag(sngisdn_info, FLAG_DELAYED_REL); - clear_call_glare_data(sngisdn_info); - - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - - /* check whether the ftdm channel is in a state to accept a call */ - switch (ftdmchan->state) { - case FTDM_CHANNEL_STATE_HANGUP_COMPLETE: - /* go to DOWN */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - break; - case FTDM_CHANNEL_STATE_DOWN: - /* do nothing, just drop the message */ - break; - case FTDM_CHANNEL_STATE_DIALING: - /* Remote side rejected our SETUP message on outbound call */ - if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_SIG_UP)) { - sngisdn_set_span_avail_rate(ftdmchan->span, SNGISDN_AVAIL_DOWN); - } - /* fall-through */ - case FTDM_CHANNEL_STATE_PROCEED: - case FTDM_CHANNEL_STATE_PROGRESS: - case FTDM_CHANNEL_STATE_PROGRESS_MEDIA: - case FTDM_CHANNEL_STATE_UP: - case FTDM_CHANNEL_STATE_RING: - case FTDM_CHANNEL_STATE_RINGING: - /* If we previously had a glare on this channel, - this RELEASE could be for the previous call. Confirm whether call_data has - not changed while we were waiting for ftdmchan->mutex by comparing suInstId's */ - if (((sngisdn_chan_data_t*)ftdmchan->call_data)->suInstId == suInstId || - ((sngisdn_chan_data_t*)ftdmchan->call_data)->spInstId == spInstId) { - - get_facility_ie(ftdmchan, &relEvnt->facilityStr); - - if (relEvnt->causeDgn[0].eh.pres && relEvnt->causeDgn[0].causeVal.pres) { - ftdmchan->caller_data.hangup_cause = relEvnt->causeDgn[0].causeVal.val; - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "cause:%d\n", ftdmchan->caller_data.hangup_cause); - } else { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "RELEASE COMPLETE did not have a cause code\n"); - ftdmchan->caller_data.hangup_cause = FTDM_CAUSE_REQUESTED_CHAN_UNAVAIL; - } - - sngisdn_set_flag(sngisdn_info, FLAG_REMOTE_ABORT); - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); - - } else { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "RELEASE was for previous call (suInstId:%u spInstId:%u)\n", suInstId, spInstId); - } - break; - case FTDM_CHANNEL_STATE_COLLECT: - case FTDM_CHANNEL_STATE_GET_CALLERID: - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_CANCEL); - break; - case FTDM_CHANNEL_STATE_TERMINATING: - if (sngisdn_test_flag(sngisdn_info, FLAG_GLARE) && - sngisdn_info->glare.suInstId != suInstId) { - /* This release if for the outbound call that we already started clearing */ - - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Received RELEASE for local glared call\n"); - sngisdn_set_flag(sngisdn_info, FLAG_REMOTE_ABORT); - } else { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "Received release before we could clear local call\n"); - /* FS core took too long to respond to the SIG STOP event */ - sngisdn_set_flag(sngisdn_info, FLAG_REMOTE_ABORT); - /* set abort flag so that we do not transmit another release complete on this channel once FS core is done */ - } - break; - case FTDM_CHANNEL_STATE_RESET: - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Processing RELEASE but channel in RESET state, ignoring\n"); - break; - default: - ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Received RELEASE in an invalid state (%s)\n", - ftdm_channel_state2str(ftdmchan->state)); - break; - } - - - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; -} - -void sngisdn_process_dat_ind (sngisdn_event_data_t *sngisdn_event) -{ - int16_t suId = sngisdn_event->suId; - uint32_t suInstId = sngisdn_event->suInstId; - uint32_t spInstId = sngisdn_event->spInstId; - - sngisdn_chan_data_t *sngisdn_info = sngisdn_event->sngisdn_info; - ftdm_channel_t *ftdmchan = sngisdn_info->ftdmchan; - - ISDN_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - /* Function does not require any info from infoEvnt struct for now */ - /* InfoEvnt *infoEvnt = &sngisdn_event->event.infoEvnt; */ - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Processing DATA IND (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId); - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; -} - -void sngisdn_process_sshl_ind (sngisdn_event_data_t *sngisdn_event) -{ - int16_t suId = sngisdn_event->suId; - uint32_t suInstId = sngisdn_event->suInstId; - uint32_t spInstId = sngisdn_event->spInstId; - - sngisdn_chan_data_t *sngisdn_info = sngisdn_event->sngisdn_info; - ftdm_channel_t *ftdmchan = sngisdn_info->ftdmchan; - - ISDN_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - /* Function does not require any info from ssHlEvnt struct for now */ - /* SsHlEvnt *ssHlEvnt = &sngisdn_event->event.ssHlEvnt; */ - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Processing SSHL IND (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId); - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; -} - -void sngisdn_process_sshl_cfm (sngisdn_event_data_t *sngisdn_event) -{ - int16_t suId = sngisdn_event->suId; - uint32_t suInstId = sngisdn_event->suInstId; - uint32_t spInstId = sngisdn_event->spInstId; - - sngisdn_chan_data_t *sngisdn_info = sngisdn_event->sngisdn_info; - ftdm_channel_t *ftdmchan = sngisdn_info->ftdmchan; - - ISDN_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - /* Function does not require any info from ssHlEvnt struct for now */ - /* SsHlEvnt *ssHlEvnt = &sngisdn_event->event.ssHlEvnt; */ - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Processing SSHL CFM (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId); - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; -} - -void sngisdn_process_rmrt_ind (sngisdn_event_data_t *sngisdn_event) -{ - int16_t suId = sngisdn_event->suId; - uint32_t suInstId = sngisdn_event->suInstId; - uint32_t spInstId = sngisdn_event->spInstId; - - sngisdn_chan_data_t *sngisdn_info = sngisdn_event->sngisdn_info; - ftdm_channel_t *ftdmchan = sngisdn_info->ftdmchan; - - ISDN_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - /* Function does not require any info from ssHlEvnt struct for now */ - /* RmRtEvnt *rmRtEvnt = &sngisdn_event->event.rmRtEvnt; */ - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Processing RESUME/RETRIEVE IND (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId); - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; -} - -void sngisdn_process_rmrt_cfm (sngisdn_event_data_t *sngisdn_event) -{ - int16_t suId = sngisdn_event->suId; - uint32_t suInstId = sngisdn_event->suInstId; - uint32_t spInstId = sngisdn_event->spInstId; - - sngisdn_chan_data_t *sngisdn_info = sngisdn_event->sngisdn_info; - ftdm_channel_t *ftdmchan = sngisdn_info->ftdmchan; - - ISDN_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - /* Function does not require any info from ssHlEvnt struct for now */ - /* RmRtEvnt *rmRtEvnt = &sngisdn_event->event.rmRtEvnt; */ - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Processing RESUME/RETRIEVE CFM (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId); - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; -} - -void sngisdn_process_flc_ind (sngisdn_event_data_t *sngisdn_event) -{ - int16_t suId = sngisdn_event->suId; - uint32_t suInstId = sngisdn_event->suInstId; - uint32_t spInstId = sngisdn_event->spInstId; - - sngisdn_chan_data_t *sngisdn_info = sngisdn_event->sngisdn_info; - ftdm_channel_t *ftdmchan = sngisdn_info->ftdmchan; - - ISDN_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - /* Function does not require any info from ssHlEvnt struct for now */ - /* StaEvnt *staEvnt = &sngisdn_event->event.staEvnt; */ - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Processing FLOW CONTROL IND (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId); - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; -} - -void sngisdn_process_fac_ind (sngisdn_event_data_t *sngisdn_event) -{ - int16_t suId = sngisdn_event->suId; - uint32_t suInstId = sngisdn_event->suInstId; - uint32_t spInstId = sngisdn_event->spInstId; - - sngisdn_chan_data_t *sngisdn_info = sngisdn_event->sngisdn_info; - ftdm_channel_t *ftdmchan = sngisdn_info->ftdmchan; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; - - FacEvnt *facEvnt = &sngisdn_event->event.facEvnt; - - ISDN_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Processing FACILITY IND (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId); - - if (signal_data->facility_ie_decode == SNGISDN_OPT_FALSE) { - /* If Facility decoding is disabled, we do not care about current call state, just pass event up to user */ - if (facEvnt->facElmt.facStr.pres) { - get_facility_ie_str(ftdmchan, &facEvnt->facElmt.facStr.val[2], facEvnt->facElmt.facStr.len-2); - sngisdn_send_signal(sngisdn_info, FTDM_SIGEVENT_FACILITY); - } - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - - switch (ftdmchan->state) { - case FTDM_CHANNEL_STATE_GET_CALLERID: - /* Update the caller ID Name */ - - if (facEvnt->facElmt.facStr.pres) { - char retrieved_str[255]; - - /* return values for "sng_isdn_retrieve_facility_information_following": - If there will be no information following, or fails to decode IE, returns -1 - If there will be no information following, but current FACILITY IE contains a caller name, returns 0 - If there will be information following, returns 1 - */ - - if (sng_isdn_retrieve_facility_caller_name(&facEvnt->facElmt.facStr.val[2], facEvnt->facElmt.facStr.len, retrieved_str) == 0) { - strcpy(ftdmchan->caller_data.cid_name, retrieved_str); - } else { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Failed to retrieve Caller Name from Facility IE\n"); - } - if (signal_data->facility_timeout) { - /* Cancel facility timeout */ - ftdm_sched_cancel_timer(signal_data->sched, sngisdn_info->timers[SNGISDN_CHAN_TIMER_FACILITY]); - } - } - - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RING); - break; - case FTDM_CHANNEL_STATE_RING: - /* We received the caller ID Name in FACILITY, but its too late, facility-timeout already occurred */ - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "FACILITY received, but we already proceeded with call\n"); - break; - case FTDM_CHANNEL_STATE_UP: - { - ftdm_sigmsg_t sigev; - if (facEvnt->facElmt.facStr.pres) { - get_facility_ie_str(ftdmchan, &facEvnt->facElmt.facStr.val[2], facEvnt->facElmt.facStr.len-2); - } - memset(&sigev, 0, sizeof(sigev)); - sigev.chan_id = ftdmchan->chan_id; - sigev.span_id = ftdmchan->span_id; - sigev.channel = ftdmchan; - - sigev.event_id = FTDM_SIGEVENT_FACILITY; - ftdm_span_send_signal(ftdmchan->span, &sigev); - } - break; - default: - /* We do not support other FACILITY types for now, so do nothing */ - break; - } - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; -} - -void sngisdn_process_sta_cfm (sngisdn_event_data_t *sngisdn_event) -{ - int16_t suId = sngisdn_event->suId; - uint32_t suInstId = sngisdn_event->suInstId; - uint32_t spInstId = sngisdn_event->spInstId; - sngisdn_chan_data_t *sngisdn_info = sngisdn_event->sngisdn_info; - ftdm_channel_t *ftdmchan = sngisdn_info->ftdmchan; - - StaEvnt *staEvnt = &sngisdn_event->event.staEvnt; - - uint8_t call_state = 0; - - ISDN_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - if (!suInstId && !spInstId) { - /* We already cleared this call */ - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Dropping STATUS CONFIRM (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId); - return; - } - - if (staEvnt->callSte.eh.pres && staEvnt->callSte.callGlblSte.pres) { - call_state = staEvnt->callSte.callGlblSte.val; - } - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Processing STATUS CONFIRM (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId); - - ftdm_assert(!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_STATE_CHANGE), "State change flag pending\n"); - - if (staEvnt->causeDgn[0].eh.pres && staEvnt->causeDgn[0].causeVal.pres) { - if (staEvnt->callSte.eh.pres && staEvnt->callSte.callGlblSte.pres) { - call_state = staEvnt->callSte.callGlblSte.val; - } else { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "Received STATUS without call state\n"); - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - switch (staEvnt->causeDgn[0].causeVal.val) { - case FTDM_CAUSE_RESPONSE_TO_STATUS_ENQUIRY: - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Status Check OK:%d", call_state); - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - case FTDM_CAUSE_WRONG_CALL_STATE: - ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Message incompatible with call state (call_state:%d channel-state:%s cause:%d) (suId:%u suInstId:%u spInstId:%u)\n", call_state, ftdm_channel_state2str(ftdmchan->state), staEvnt->causeDgn[0].causeVal.val, suId, suInstId, spInstId); - break; - case FTDM_CAUSE_RECOVERY_ON_TIMER_EXPIRE: - ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Recovery on timer expire (call_state:%d channel-state:%s cause:%d) (suId:%u suInstId:%u spInstId:%u)\n", call_state, ftdm_channel_state2str(ftdmchan->state), staEvnt->causeDgn[0].causeVal.val, suId, suInstId, spInstId); - break; - default: - ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "STATUS CONFIRM (call_state:%d channel-state:%s cause:%d) (suId:%u suInstId:%u spInstId:%u)\n", call_state, ftdm_channel_state2str(ftdmchan->state), staEvnt->causeDgn[0].causeVal.val, suId, suInstId, spInstId); - break; - } - - /* Section 4.3.30 from INT Interface - Service Definition */ - ftdmchan->caller_data.hangup_cause = staEvnt->causeDgn[0].causeVal.val; - - switch(call_state) { - /* Sere ITU-T Q931 for definition of call states */ - case 0: /* Remote switch thinks there are no calls on this channel */ - if (sngisdn_bring_down(ftdmchan) != FTDM_SUCCESS) { - ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Don't know how to handle incompatible state. remote call state:%d our state:%s\n", call_state, ftdm_channel_state2str(ftdmchan->state)); - } - break; - case 1: - switch (ftdmchan->state) { - case FTDM_CHANNEL_STATE_UP: - /* Remote side is still waiting for our CONNECT message */ - if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { - ftdm_sched_timer(((sngisdn_span_data_t*)ftdmchan->span->signal_data)->sched, "delayed_connect", 1, sngisdn_delayed_connect, (void*) sngisdn_info, NULL); - break; - } - /* Fall-through */ - default: - ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Don't know how to handle incompatible state. remote call state:%d our state:%s\n", call_state, ftdm_channel_state2str(ftdmchan->state)); - break; - } - break; - case 2: /* overlap sending */ - switch (ftdmchan->state) { - case FTDM_CHANNEL_STATE_COLLECT: - /* T302 Timeout reached */ - /* Send the call to user, and see if they accept it */ - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "T302 Timer expired, proceeding with call\n"); - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RING); - break; - case FTDM_CHANNEL_STATE_PROCEED: - case FTDM_CHANNEL_STATE_PROGRESS: - case FTDM_CHANNEL_STATE_RINGING: - case FTDM_CHANNEL_STATE_PROGRESS_MEDIA: - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "Remote switch expecting OVERLAP receive, but we are already PROCEEDING\n"); - sngisdn_snd_disconnect(ftdmchan); - break; - case FTDM_CHANNEL_STATE_DOWN: - case FTDM_CHANNEL_STATE_HANGUP_COMPLETE: - /* We hung up locally, but remote switch doesn't know send disconnect again*/ - sngisdn_snd_disconnect(ftdmchan); - break; - default: - ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Don't know how to handle incompatible state. remote call state:%d our state:%s\n", call_state, ftdm_channel_state2str(ftdmchan->state)); - break; - } - break; - case 3: - switch (ftdmchan->state) { - case FTDM_CHANNEL_STATE_PROCEED: - case FTDM_CHANNEL_STATE_PROGRESS: - case FTDM_CHANNEL_STATE_RINGING: - /* T310 timer has expired */ - ftdmchan->caller_data.hangup_cause = staEvnt->causeDgn[0].causeVal.val; - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "T310 Timer expired, hanging up call\n"); - sngisdn_set_flag(sngisdn_info, FLAG_SEND_DISC); - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); - - break; - case FTDM_CHANNEL_STATE_UP: - /* Remote side is still waiting for our CONNECT message */ - if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { - ftdm_sched_timer(((sngisdn_span_data_t*)ftdmchan->span->signal_data)->sched, "delayed_connect", 1, sngisdn_delayed_connect, (void*) sngisdn_info, NULL); - break; - } - /* Fall-through */ - default: - ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Don't know how to handle incompatible state. remote call state:%d our state:%s\n", call_state, ftdm_channel_state2str(ftdmchan->state)); - break; - } - break; - case 8: /* Remote switch is in "Connect Request state" */ - switch (ftdmchan->state) { - case FTDM_CHANNEL_STATE_UP: - /* This is ok. We sent a Connect, and we are waiting for a connect ack */ - /* Do nothing */ - break; - case FTDM_CHANNEL_STATE_HANGUP_COMPLETE: - /* We hung up locally, but remote switch doesn't know send disconnect again*/ - sngisdn_snd_disconnect(ftdmchan); - break; - default: - ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Don't know how to handle incompatible state. remote call state:%d our state:%s\n", call_state, ftdm_channel_state2str(ftdmchan->state)); - break; - } - break; - case 9: /* Remote switch is in "Incoming call proceeding" state */ - switch (ftdmchan->state) { - case FTDM_CHANNEL_STATE_RINGING: - case FTDM_CHANNEL_STATE_PROGRESS: - case FTDM_CHANNEL_STATE_PROGRESS_MEDIA: - case FTDM_CHANNEL_STATE_GET_CALLERID: - /* Do nothing */ - break; - case FTDM_CHANNEL_STATE_UP: - /* Remote switch missed our CONNECT message, re-send */ - ftdm_sched_timer(((sngisdn_span_data_t*)ftdmchan->span->signal_data)->sched, "delayed_connect", 1, sngisdn_delayed_connect, (void*) sngisdn_info, NULL); - break; - default: - ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Don't know how to handle incompatible state. remote call state:%d our state:%s\n", call_state, ftdm_channel_state2str(ftdmchan->state)); - break; - } - break; - case 10: /* Remote switch is in active state */ - switch (ftdmchan->state) { - case FTDM_CHANNEL_STATE_UP: - /* This is ok, they are in active state and we are in active state */ - /* Do nothing */ - break; - case FTDM_CHANNEL_STATE_HANGUP_COMPLETE: - /* We sent a disconnect message, but remote side missed it ? */ - ftdm_sched_timer(((sngisdn_span_data_t*)ftdmchan->span->signal_data)->sched, "delayed_disconnect", 1, sngisdn_delayed_disconnect, (void*) sngisdn_info, NULL); - break; - default: - ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Don't know how to handle incompatible state. remote call state:%d our state:%s\n", call_state, ftdm_channel_state2str(ftdmchan->state)); - break; - } - break; - case 12: /* We received a disconnect indication */ - switch (ftdmchan->state) { - case FTDM_CHANNEL_STATE_TERMINATING: - /* We are already waiting for user app to handle the disconnect, do nothing */ - break; - default: - ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Don't know how to handle incompatible state. remote call state:%d our state:%s\n", call_state, ftdm_channel_state2str(ftdmchan->state)); - break; - } - break; - case 22: - switch (ftdmchan->state) { - case FTDM_CHANNEL_STATE_UP: - /* Stack is in the process of clearing the call*/ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); - break; - case FTDM_CHANNEL_STATE_HANGUP_COMPLETE: - /* Do nothing as we will get a RELEASE COMPLETE */ - break; - default: - ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Don't know how to handle incompatible state. remote call state:%d our state:%s\n", call_state, ftdm_channel_state2str(ftdmchan->state)); - //ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RESTART); - break; - } - break; - case 25: /* Overlap receiving */ - switch (ftdmchan->state) { - case FTDM_CHANNEL_STATE_COLLECT: - /* T302 Timeout reached */ - /* Send the call to user, and see if they accept it */ - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "T302 Timer expired, proceeding with call\n"); - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RING); - break; - default: - ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Don't know how to handle incompatible state. remote call state:%d our state:%s\n", call_state, ftdm_channel_state2str(ftdmchan->state)); - //ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RESTART); - break; - } - break; - default: - ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Don't know how to handle incompatible state. remote call state:%d our state:%s\n", call_state, ftdm_channel_state2str(ftdmchan->state)); - //ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RESTART); - break; - } - } - - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; -} - - -void sngisdn_process_srv_ind (sngisdn_event_data_t *sngisdn_event) -{ - int16_t suId = sngisdn_event->suId; - int16_t dChan = sngisdn_event->dChan; - uint8_t ces = sngisdn_event->ces; - - ISDN_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - /* Function does not require any info from ssHlEvnt struct for now */ - /*Srv *srvEvnt = &sngisdn_event->event.srvEvnt;*/ - - ftdm_log(FTDM_LOG_DEBUG, "Processing SERVICE IND (suId:%u dChan:%d ces:%d)\n", suId, dChan, ces); - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; -} - -void sngisdn_process_srv_cfm (sngisdn_event_data_t *sngisdn_event) -{ - int16_t suId = sngisdn_event->suId; - int16_t dChan = sngisdn_event->dChan; - uint8_t ces = sngisdn_event->ces; - - ISDN_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - /* Function does not require any info from ssHlEvnt struct for now */ - /*Srv *srvEvnt = &sngisdn_event->event.srvEvnt;*/ - - ftdm_log(FTDM_LOG_DEBUG, "Processing SERVICE CFM (suId:%u dChan:%d ces:%d)\n", suId, dChan, ces); - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; -} - -static ftdm_status_t sngisdn_bring_down(ftdm_channel_t *ftdmchan) -{ - sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*)ftdmchan->call_data; - ftdm_status_t status = FTDM_SUCCESS; - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Bringing channel to DOWN state (%s)\n", ftdm_channel_state2str(ftdmchan->state)); - switch (ftdmchan->state) { - case FTDM_CHANNEL_STATE_DOWN: - /* Do nothing */ - break; - case FTDM_CHANNEL_STATE_RESET: - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - break; - case FTDM_CHANNEL_STATE_COLLECT: - case FTDM_CHANNEL_STATE_DIALING: - case FTDM_CHANNEL_STATE_UP: - sngisdn_set_flag(sngisdn_info, FLAG_REMOTE_ABORT); - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); - break; - case FTDM_CHANNEL_STATE_TERMINATING: - /* We are already waiting for usr to respond to SIGEVENT stop. - FreeTDM already scheduled a timout in case the User does respond to - SIGEVENT_STOP, no need to do anything here */ - break; - case FTDM_CHANNEL_STATE_HANGUP: - /* This cannot happen, state_advance always sets - ftdmchan to STATE_HANGUP_COMPLETE when in STATE_HANGUP - and we called check_for_state_change earlier so something is very wrong here!!! */ - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "How can we we in FTDM_CHANNEL_STATE_HANGUP after checking for state change?\n"); - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - break; - case FTDM_CHANNEL_STATE_HANGUP_COMPLETE: - /* We were waiting for remote switch to send RELEASE COMPLETE - but this will not happen, so just clear local state */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - break; - default: - status = FTDM_FAIL; - - } - return status; -} - -void sngisdn_process_rst_cfm (sngisdn_event_data_t *sngisdn_event) -{ - ftdm_signaling_status_t sigstatus; - int16_t suId = sngisdn_event->suId; - int16_t dChan = sngisdn_event->dChan; - uint8_t ces = sngisdn_event->ces; - uint8_t evntType = sngisdn_event->evntType; - uint8_t chan_no = 0; - Rst *rstEvnt = &sngisdn_event->event.rstEvnt; - - sngisdn_span_data_t *signal_data = g_sngisdn_data.spans[dChan]; - if (!signal_data) { - ftdm_log(FTDM_LOG_CRIT, "Received RESTART CFM on unconfigured span (suId:%d)\n", suId); - return; - } - - ftdm_log(FTDM_LOG_DEBUG, "%s: Processing RESTART CFM (suId:%u dChan:%d ces:%d %s(%d))\n", - signal_data->ftdm_span->name, - suId, dChan, ces, - (evntType == IN_LNK_DWN)?"LNK_DOWN": - (evntType == IN_LNK_UP)?"LNK_UP": - (evntType == IN_INDCHAN)?"b-channel": - (evntType == IN_LNK_DWN_DM_RLS)?"NFAS service procedures": - (evntType == IN_SWCHD_BU_DCHAN)?"NFAS switchover to backup":"Unknown", evntType); - - if (rstEvnt->rstInd.eh.pres == PRSNT_NODEF && rstEvnt->rstInd.rstClass.pres == PRSNT_NODEF) { - switch(rstEvnt->rstInd.rstClass.val) { - case IN_CL_INDCHAN: /* Indicated b-channel */ - if (rstEvnt->chanId.eh.pres) { - if (rstEvnt->chanId.intType.val == IN_IT_BASIC) { - if (rstEvnt->chanId.infoChanSel.pres == PRSNT_NODEF) { - chan_no = rstEvnt->chanId.infoChanSel.val; - } - } else if (rstEvnt->chanId.intType.val == IN_IT_OTHER) { - if (rstEvnt->chanId.chanNmbSlotMap.pres == PRSNT_NODEF) { - chan_no = rstEvnt->chanId.chanNmbSlotMap.val[0]; - } - } - - if (signal_data->nfas.trunk) { - if (!rstEvnt->chanId.intIdent.pres) { - ftdm_log(FTDM_LOG_CRIT, "Failed to determine interface from RESTART\n"); - return; - } else if (signal_data->nfas.interface_id != rstEvnt->chanId.intIdent.val) { - /* This RESTART is for another interface */ - return; - } - } - } - if (!chan_no) { - ftdm_log(FTDM_LOG_CRIT, "Failed to determine channel from RESTART\n"); - return; - } - break; - case IN_CL_SNGINT: /* Single interface */ - case IN_CL_ALLINT: /* All interfaces */ - /* In case restart class indicates all interfaces, we will duplicate - this event on each span associated to this d-channel in sngisdn_rcv_rst_cfm, - so treat it as a single interface anyway */ - chan_no = 0; - break; - default: - ftdm_log(FTDM_LOG_CRIT, "Invalid restart indicator class:%d\n", rstEvnt->rstInd.rstClass.val); - return; - } - } - - ftdm_span_get_sig_status(signal_data->ftdm_span, &sigstatus); - if (sigstatus == FTDM_SIG_STATE_DOWN) { - if (chan_no) { /* For a single channel */ - if (chan_no > ftdm_span_get_chan_count(signal_data->ftdm_span)) { - ftdm_log(FTDM_LOG_CRIT, "Received RESTART on invalid channel:%d\n", chan_no); - } else { - ftdm_channel_t *ftdmchan = ftdm_span_get_channel(signal_data->ftdm_span, chan_no); - sngisdn_bring_down(ftdmchan); - } - } else { /* for all channels */ - ftdm_iterator_t *chaniter = NULL; - ftdm_iterator_t *curr = NULL; - - chaniter = ftdm_span_get_chan_iterator(signal_data->ftdm_span, NULL); - for (curr = chaniter; curr; curr = ftdm_iterator_next(curr)) { - sngisdn_bring_down((ftdm_channel_t*)ftdm_iterator_current(curr)); - } - ftdm_iterator_free(chaniter); - } - } - - ftdm_log(FTDM_LOG_DEBUG, "Processing RESTART CFM (suId:%u dChan:%d ces:%d type:%d)\n", suId, dChan, ces, evntType); - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; -} - - -/* The remote side sent us a RESTART Msg. Trillium automatically acks with RESTART ACK, but - we need to clear our call states if there is a call on this channel */ -void sngisdn_process_rst_ind (sngisdn_event_data_t *sngisdn_event) -{ - uint8_t chan_no = 0; - int16_t suId = sngisdn_event->suId; - int16_t dChan = sngisdn_event->dChan; - uint8_t ces = sngisdn_event->ces; - uint8_t evntType = sngisdn_event->evntType; - Rst *rstEvnt = NULL; - sngisdn_span_data_t *signal_data = NULL; - - ISDN_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - rstEvnt = &sngisdn_event->event.rstEvnt; - - signal_data = g_sngisdn_data.spans[dChan]; - - if (!signal_data) { - ftdm_log(FTDM_LOG_CRIT, "Received RESTART IND on unconfigured span (suId:%d)\n", suId); - return; - } - - if (signal_data->restart_timeout) { - ftdm_sched_cancel_timer(signal_data->sched, signal_data->timers[SNGISDN_SPAN_TIMER_RESTART]); - } - - ftdm_log(FTDM_LOG_DEBUG, "Processing RESTART IND (suId:%u dChan:%d ces:%d %s(%d))\n", suId, dChan, ces, - (evntType == IN_LNK_DWN)?"LNK_DOWN": - (evntType == IN_LNK_UP)?"LNK_UP": - (evntType == IN_INDCHAN)?"b-channel": - (evntType == IN_LNK_DWN_DM_RLS)?"NFAS service procedures": - (evntType == IN_SWCHD_BU_DCHAN)?"NFAS switchover to backup":"Unknown", evntType); - - if (rstEvnt->rstInd.eh.pres == PRSNT_NODEF && rstEvnt->rstInd.rstClass.pres == PRSNT_NODEF) { - switch(rstEvnt->rstInd.rstClass.val) { - case IN_CL_INDCHAN: /* Indicated b-channel */ - if (rstEvnt->chanId.eh.pres) { - if (rstEvnt->chanId.intType.val == IN_IT_BASIC) { - if (rstEvnt->chanId.infoChanSel.pres == PRSNT_NODEF) { - chan_no = rstEvnt->chanId.infoChanSel.val; - } - } else if (rstEvnt->chanId.intType.val == IN_IT_OTHER) { - if (rstEvnt->chanId.chanNmbSlotMap.pres == PRSNT_NODEF) { - chan_no = rstEvnt->chanId.chanNmbSlotMap.val[0]; - } - } - - if (signal_data->nfas.trunk) { - if (!rstEvnt->chanId.intIdent.pres) { - ftdm_log(FTDM_LOG_CRIT, "Failed to determine interface from RESTART\n"); - return; - } else if (signal_data->nfas.interface_id != rstEvnt->chanId.intIdent.val) { - /* This RESTART is for another interface */ - return; - } - } - } - if (!chan_no) { - ftdm_log(FTDM_LOG_CRIT, "Failed to determine channel from RESTART\n"); - return; - } - break; - case IN_CL_SNGINT: /* Single interface */ - case IN_CL_ALLINT: /* All interfaces */ - /* In case restart class indicates all interfaces, we will duplicated - this event on each span associated to this d-channel in sngisdn_rcv_rst_cfm, - so treat it as a single interface anyway */ - chan_no = 0; - break; - default: - ftdm_log(FTDM_LOG_CRIT, "Invalid restart indicator class:%d\n", rstEvnt->rstInd.rstClass.val); - return; - } - } - - if (chan_no) { /* For a single channel */ - ftdm_iterator_t *chaniter = NULL; - ftdm_iterator_t *curr = NULL; - - chaniter = ftdm_span_get_chan_iterator(signal_data->ftdm_span, NULL); - for (curr = chaniter; curr; curr = ftdm_iterator_next(curr)) { - ftdm_channel_t *ftdmchan = (ftdm_channel_t*)ftdm_iterator_current(curr); - sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*) ftdmchan->call_data; - if (sngisdn_info->ces == ces && ftdmchan->physical_chan_id == chan_no) { - sngisdn_bring_down(ftdmchan); - } - } - ftdm_iterator_free(chaniter); - } else { /* for all channels */ - ftdm_iterator_t *chaniter = NULL; - ftdm_iterator_t *curr = NULL; - - chaniter = ftdm_span_get_chan_iterator(signal_data->ftdm_span, NULL); - for (curr = chaniter; curr; curr = ftdm_iterator_next(curr)) { - ftdm_channel_t *ftdmchan = (ftdm_channel_t*)ftdm_iterator_current(curr); - sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*) ftdmchan->call_data; - if (sngisdn_info->ces == ces) { - sngisdn_bring_down(ftdmchan); - } - } - ftdm_iterator_free(chaniter); - } - - - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; -} - -static ftdm_status_t sngisdn_cause_val_requires_disconnect(ftdm_channel_t *ftdmchan, CauseDgn *causeDgn) -{ - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; - - if (signal_data->ignore_cause_value == SNGISDN_OPT_TRUE) { - return FTDM_FAIL; - } - - /* By default, we only evaluate cause value on 5ESS switches */ - if (signal_data->ignore_cause_value == SNGISDN_OPT_DEFAULT && - signal_data->switchtype != SNGISDN_SWITCH_5ESS) { - - return FTDM_FAIL; - } - - /* ignore_cause_value = SNGISDN_OPT_FALSE or switchtype == 5ESS */ - switch(causeDgn->causeVal.val) { - case 17: /* User Busy */ - case 18: /* No User responding */ - case 19: /* User alerting, no answer */ - case 21: /* Call rejected, the called party does not with to accept this call */ - case 27: /* Destination out of order */ - case 31: /* Normal, unspecified */ - case 34: /* Circuit/Channel congestion */ - case 41: /* Temporary failure */ - case 42: /* Switching equipment is experiencing a period of high traffic */ - case 47: /* Resource unavailable */ - case 58: /* Bearer Capability not available */ - case 63: /* Service or option not available */ - case 65: /* Bearer Cap not implemented, not supported */ - case 79: /* Service or option not implemented, unspecified */ - return FTDM_SUCCESS; - } - return FTDM_FAIL; -} diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c deleted file mode 100644 index 9fc8ad1d82..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c +++ /dev/null @@ -1,588 +0,0 @@ -/* - * Copyright (c) 2010, Sangoma Technologies - * David Yat Sin - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "ftmod_sangoma_isdn.h" - -void sngisdn_snd_setup(ftdm_channel_t *ftdmchan) -{ - ConEvnt conEvnt; - sngisdn_chan_data_t *sngisdn_info = ftdmchan->call_data; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; - ftdm_sngisdn_progind_t prog_ind = {SNGISDN_PROGIND_LOC_USER, SNGISDN_PROGIND_DESCR_INVALID}; - - ftdm_assert((!sngisdn_info->suInstId && !sngisdn_info->spInstId), "Trying to call out, but call data was not cleared\n"); - - sngisdn_info->suInstId = get_unique_suInstId(signal_data->cc_id); - sngisdn_info->spInstId = 0; - - ftdm_mutex_lock(g_sngisdn_data.ccs[signal_data->cc_id].mutex); - g_sngisdn_data.ccs[signal_data->cc_id].active_suInstIds[sngisdn_info->suInstId] = sngisdn_info; - ftdm_mutex_unlock(g_sngisdn_data.ccs[signal_data->cc_id].mutex); - - memset(&conEvnt, 0, sizeof(conEvnt)); - if (signal_data->switchtype == SNGISDN_SWITCH_EUROISDN || signal_data->force_sending_complete == SNGISDN_OPT_TRUE) { - conEvnt.sndCmplt.eh.pres = PRSNT_NODEF; - } - - if (ftdmchan->span->trunk_type == FTDM_TRUNK_BRI_PTMP && - signal_data->signalling == SNGISDN_SIGNALING_NET) { - sngisdn_info->ces = CES_MNGMNT; - } - ftdm_log_chan(sngisdn_info->ftdmchan, FTDM_LOG_INFO, "Outgoing call: Called No:[%s] Calling No:[%s]\n", ftdmchan->caller_data.dnis.digits, ftdmchan->caller_data.cid_num.digits); - - set_chan_id_ie(ftdmchan, &conEvnt.chanId); - set_bear_cap_ie(ftdmchan, &conEvnt.bearCap[0]); - set_called_num(ftdmchan, &conEvnt.cdPtyNmb); - set_calling_num(ftdmchan, &conEvnt.cgPtyNmb); - set_calling_num2(ftdmchan, &conEvnt.cgPtyNmb2); - set_calling_subaddr(ftdmchan, &conEvnt.cgPtySad); - set_called_subaddr(ftdmchan, &conEvnt.cdPtySad); - set_redir_num(ftdmchan, &conEvnt.redirNmb); - set_calling_name(ftdmchan, &conEvnt); - set_network_specific_fac(ftdmchan, &conEvnt.netFac[0]); - - /* set_facility_ie will overwrite Calling Name for NI-2 if user specifies custom Facility IE */ - set_facility_ie(ftdmchan, &conEvnt.facilityStr); - set_prog_ind_ie(ftdmchan, &conEvnt.progInd, prog_ind); - - ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending SETUP (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces); - - if (sng_isdn_con_request(signal_data->cc_id, sngisdn_info->suInstId, &conEvnt, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces)) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "stack refused SETUP request\n"); - } - - return; -} - -/* Unsed only for overlap receive */ -void sngisdn_snd_setup_ack(ftdm_channel_t *ftdmchan) -{ - CnStEvnt cnStEvnt; - - sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*) ftdmchan->call_data; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; - - if (!sngisdn_info->suInstId || !sngisdn_info->spInstId) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Sending SETUP ACK , but no call data, aborting (suId:%d suInstId:%u spInstId:%u)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId); - sngisdn_set_flag(sngisdn_info, FLAG_LOCAL_ABORT); - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); - return; - } - - memset(&cnStEvnt, 0, sizeof(cnStEvnt)); - - - - ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending SETUP ACK (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces); - - if(sng_isdn_con_status(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, &cnStEvnt, MI_SETUPACK, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces)) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "stack refused SETUP ACK request\n"); - } - return; -} - - -/* Used only for BRI PTMP - This function is used when the NT side makes a call out, - and one or multiple TE's reply, then NT assigns the call by sending a con_complete*/ -void sngisdn_snd_con_complete(ftdm_channel_t *ftdmchan) -{ - CnStEvnt cnStEvnt; - - sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*) ftdmchan->call_data; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; - - if (!sngisdn_info->suInstId || !sngisdn_info->spInstId) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Sending CONNECT COMPL , but no call data, aborting (suId:%d suInstId:%u spInstId:%u)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId); - sngisdn_set_flag(sngisdn_info, FLAG_LOCAL_ABORT); - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); - return; - } - - memset(&cnStEvnt, 0, sizeof(cnStEvnt)); - - /* Indicate channel ID only in first response */ - if (!ftdm_test_flag(sngisdn_info, FLAG_SENT_CHAN_ID)) { - set_chan_id_ie(ftdmchan, &cnStEvnt.chanId); - } - - ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending CONNECT COMPL (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces); - - if(sng_isdn_con_comp(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, &cnStEvnt, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces)) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "stack refused CONNECT ACK request\n"); - } - return; -} - - -void sngisdn_snd_proceed(ftdm_channel_t *ftdmchan, ftdm_sngisdn_progind_t prog_ind) -{ - CnStEvnt cnStEvnt; - sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*) ftdmchan->call_data; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; - - if (sngisdn_test_flag(sngisdn_info, FLAG_SENT_PROCEED)) { - return; - } - sngisdn_set_flag(sngisdn_info, FLAG_SENT_PROCEED); - - if (!sngisdn_info->suInstId || !sngisdn_info->spInstId) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Sending PROGRESS, but no call data, aborting (suId:%d suInstId:%u spInstId:%u)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId); - sngisdn_set_flag(sngisdn_info, FLAG_LOCAL_ABORT); - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); - return; - } - - memset(&cnStEvnt, 0, sizeof(cnStEvnt)); - - /* Indicate channel ID only in first response */ - if (!ftdm_test_flag(sngisdn_info, FLAG_SENT_CHAN_ID)) { - set_chan_id_ie(ftdmchan, &cnStEvnt.chanId); - } - set_prog_ind_ie(ftdmchan, &cnStEvnt.progInd, prog_ind); - set_facility_ie(ftdmchan, &cnStEvnt.facilityStr); - - ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending PROCEED (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces); - - if(sng_isdn_con_status(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, &cnStEvnt, MI_CALLPROC, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces)) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "stack refused PROCEED request\n"); - } - return; -} - -void sngisdn_snd_progress(ftdm_channel_t *ftdmchan, ftdm_sngisdn_progind_t prog_ind) -{ - CnStEvnt cnStEvnt; - - sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*) ftdmchan->call_data; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; - - if (!sngisdn_info->suInstId || !sngisdn_info->spInstId) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Sending PROGRESS, but no call data, aborting (suId:%d suInstId:%u spInstId:%u)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId); - sngisdn_set_flag(sngisdn_info, FLAG_LOCAL_ABORT); - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); - return; - } - - if (signal_data->switchtype == SNGISDN_SWITCH_INSNET) { - /* Trillium Q931 layer complains of invalid event when receiving PROGRESS in - INSNET variant, so PROGRESS event is probably invalid */ - return; - } - - memset(&cnStEvnt, 0, sizeof(cnStEvnt)); - set_prog_ind_ie(ftdmchan, &cnStEvnt.progInd, prog_ind); - set_facility_ie(ftdmchan, &cnStEvnt.facilityStr); - - ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending PROGRESS (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces); - if(sng_isdn_con_status(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId,&cnStEvnt, MI_PROGRESS, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces)) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "stack refused PROGRESS request\n"); - } - return; -} - -void sngisdn_snd_alert(ftdm_channel_t *ftdmchan, ftdm_sngisdn_progind_t prog_ind) -{ - CnStEvnt cnStEvnt; - - sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*) ftdmchan->call_data; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; - - if (!sngisdn_info->suInstId || !sngisdn_info->spInstId) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Sending ALERT, but no call data, aborting (suId:%d suInstId:%u spInstId:%u)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId); - sngisdn_set_flag(sngisdn_info, FLAG_LOCAL_ABORT); - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); - return; - } - - memset(&cnStEvnt, 0, sizeof(cnStEvnt)); - - set_prog_ind_ie(ftdmchan, &cnStEvnt.progInd, prog_ind); - set_facility_ie(ftdmchan, &cnStEvnt.facilityStr); - - ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending ALERT (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces); - - if(sng_isdn_con_status(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId,&cnStEvnt, MI_ALERTING, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces)) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "stack refused ALERT request\n"); - } - return; -} - -void sngisdn_snd_connect(ftdm_channel_t *ftdmchan) -{ - CnStEvnt cnStEvnt; - sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*) ftdmchan->call_data; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; - ftdm_sngisdn_progind_t prog_ind = {SNGISDN_PROGIND_LOC_USER, SNGISDN_PROGIND_DESCR_NETE_ISDN}; - - if (sngisdn_test_flag(sngisdn_info, FLAG_SENT_CONNECT)) { - return; - } - sngisdn_set_flag(sngisdn_info, FLAG_SENT_CONNECT); - - if (!sngisdn_info->suInstId || !sngisdn_info->spInstId) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Sending CONNECT, but no call data, aborting (suId:%d suInstId:%u spInstId:%u)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId); - sngisdn_set_flag(sngisdn_info, FLAG_LOCAL_ABORT); - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); - return; - } - - memset(&cnStEvnt, 0, sizeof(cnStEvnt)); - - /* Indicate channel ID only in first response */ - if (!ftdm_test_flag(sngisdn_info, FLAG_SENT_CHAN_ID)) { - set_chan_id_ie(ftdmchan, &cnStEvnt.chanId); - } - set_prog_ind_ie(ftdmchan, &cnStEvnt.progInd, prog_ind); - set_facility_ie(ftdmchan, &cnStEvnt.facilityStr); - - ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending CONNECT (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces); - if (sng_isdn_con_response(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, &cnStEvnt, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces)) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "stack refused CONNECT request\n"); - } - return; -} - -void sngisdn_snd_fac_req(ftdm_channel_t *ftdmchan) -{ - FacEvnt facEvnt; - - sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*) ftdmchan->call_data; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; - - if (!sngisdn_info->suInstId) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Sending FACILITY, but no call data, ignoring (suId:%d suInstId:%u spInstId:%u)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId); - return; - } - - memset(&facEvnt, 0, sizeof(facEvnt)); - - if (set_facility_ie_str(ftdmchan, &facEvnt.facElmt.facStr.val[2], (uint8_t*)&facEvnt.facElmt.facStr.len) != FTDM_SUCCESS) { - /* No point in sending a FACILITY message if there is no Facility IE to transmit */ - return; - } - - facEvnt.facElmt.eh.pres = PRSNT_NODEF; - facEvnt.facElmt.facStr.pres = PRSNT_NODEF; - facEvnt.facElmt.facStr.val[0] = 0x1C; - facEvnt.facElmt.facStr.val[1] = (uint8_t)facEvnt.facElmt.facStr.len; - facEvnt.facElmt.facStr.len +=2; /* Need to include the size of identifier + len */ - - ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending FACILITY (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces); - - if (sng_isdn_facility_request(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, &facEvnt, MI_FACIL, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces)) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "stack refused FACILITY request\n"); - } - return; -} - -/* This is used to request Q.921 to initiate link establishment */ -void sngisdn_snd_dl_req(ftdm_channel_t *ftdmchan) -{ - CnStEvnt cnStEvnt; - - sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*) ftdmchan->call_data; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; - - memset(&cnStEvnt, 0, sizeof(cnStEvnt)); - - ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Requesting Link establishment (suId:%d dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces); - - if (sng_isdn_con_status(signal_data->cc_id, 0, 0, &cnStEvnt, MI_INFO, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces)) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "stack refused Link establishment\n"); - } - return; -} - -void sngisdn_snd_notify_req(ftdm_channel_t *ftdmchan) -{ - CnStEvnt cnStEvnt; - - sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*) ftdmchan->call_data; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; - - if (!sngisdn_info->suInstId || !sngisdn_info->spInstId) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Sending NOTIFY, but no call data, aborting (suId:%d suInstId:%u spInstId:%u)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId); - sngisdn_set_flag(sngisdn_info, FLAG_LOCAL_ABORT); - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); - return; - } - - memset(&cnStEvnt, 0, sizeof(cnStEvnt)); - - set_not_ind_ie(ftdmchan, &cnStEvnt.notInd); - - ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending NOTIFY (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces); - - if(sng_isdn_con_status(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId,&cnStEvnt, MI_NOTIFY, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces)) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "stack refused NOTIFY request\n"); - } - return; -} - - -void sngisdn_snd_status_enq(ftdm_channel_t *ftdmchan) -{ - StaEvnt staEvnt; - - sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*) ftdmchan->call_data; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; - - //ftdm_log_chan_msg(ftdmchan, FTDM_LOG_INFO, "Sending STATUS ENQ\n"); - - memset(&staEvnt, 0, sizeof(StaEvnt)); - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Sending Status ENQ on suId:%d suInstId:%u spInstId:%d dchan:%d ces:%d\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces); - if (sng_isdn_status_request(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, &staEvnt, MI_STATENQ)) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "stack refused Status ENQ request\n"); - } - return; -} - - -void sngisdn_snd_disconnect(ftdm_channel_t *ftdmchan) -{ - DiscEvnt discEvnt; - - sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*) ftdmchan->call_data; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; - - if (!sngisdn_info->suInstId || !sngisdn_info->spInstId) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Sending DISCONNECT, but no call data, aborting (suId:%d suInstId:%u spInstId:%u)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId); - - sngisdn_set_flag(sngisdn_info, FLAG_LOCAL_ABORT); - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_HANGUP_COMPLETE); - return; - } - - memset(&discEvnt, 0, sizeof(discEvnt)); - - set_cause_ie(ftdmchan, &discEvnt.causeDgn[0]); - set_facility_ie(ftdmchan, &discEvnt.facilityStr); - set_user_to_user_ie(ftdmchan, &discEvnt.usrUsr); - - ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending DISCONNECT (suId:%d suInstId:%u spInstId:%u)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId); - if (sng_isdn_disc_request(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, &discEvnt)) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "stack refused DISCONNECT request\n"); - } - return; -} - -void sngisdn_snd_release(ftdm_channel_t *ftdmchan, uint8_t glare) -{ - RelEvnt relEvnt; - uint32_t suInstId, spInstId; - - sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*) ftdmchan->call_data; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; - - if (!sngisdn_info->suInstId) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Sending RELEASE, but no call data, aborting (suId:%d suInstId:%u spInstId:%u)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId); - - sngisdn_set_flag(sngisdn_info, FLAG_LOCAL_ABORT); - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_HANGUP_COMPLETE); - return; - } - - memset(&relEvnt, 0, sizeof(relEvnt)); - - /* Fill relEvnt here */ - relEvnt.causeDgn[0].eh.pres = PRSNT_NODEF; - relEvnt.causeDgn[0].location.pres = PRSNT_NODEF; - relEvnt.causeDgn[0].location.val = IN_LOC_PRIVNETLU; - relEvnt.causeDgn[0].codeStand3.pres = PRSNT_NODEF; - relEvnt.causeDgn[0].codeStand3.val = IN_CSTD_CCITT; - - relEvnt.causeDgn[0].causeVal.pres = PRSNT_NODEF; - relEvnt.causeDgn[0].causeVal.val = ftdmchan->caller_data.hangup_cause; - relEvnt.causeDgn[0].recommend.pres = NOTPRSNT; - relEvnt.causeDgn[0].dgnVal.pres = NOTPRSNT; - - if (glare) { - suInstId = sngisdn_info->glare.suInstId; - spInstId = sngisdn_info->glare.spInstId; - } else { - suInstId = sngisdn_info->suInstId; - spInstId = sngisdn_info->spInstId; - } - - set_facility_ie(ftdmchan, &relEvnt.facilityStr); - - ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending RELEASE/RELEASE COMPLETE (suId:%d suInstId:%u spInstId:%u)\n", signal_data->cc_id, suInstId, spInstId); - - if (glare) { - if (sng_isdn_release_request(signal_data->cc_id, suInstId, spInstId, &relEvnt)) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "stack refused RELEASE/RELEASE COMPLETE request\n"); - } - } else { - if (sng_isdn_release_request(signal_data->cc_id, suInstId, spInstId, &relEvnt)) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "stack refused RELEASE/RELEASE COMPLETE request\n"); - } - } - return; -} - -void sngisdn_snd_restart(ftdm_channel_t *ftdmchan) -{ - Rst rstEvnt; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; - - memset(&rstEvnt, 0, sizeof(rstEvnt)); - - set_chan_id_ie(ftdmchan, &rstEvnt.chanId); - set_restart_ind_ie(ftdmchan, &rstEvnt.rstInd); - - ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending RESTART (suId:%d dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_dchan(signal_data)->link_id, CES_MNGMNT); - - if (sng_isdn_restart_request(signal_data->cc_id, &rstEvnt, sngisdn_dchan(signal_data)->link_id, CES_MNGMNT, IN_SND_RST)) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "stack refused RESTART request\n"); - } - return; -} - - -/* We received an incoming frame on the d-channel, send data to the stack */ -void sngisdn_snd_data(ftdm_channel_t *dchan, uint8_t *data, ftdm_size_t len) -{ - sng_l1_frame_t l1_frame; - ftdm_alarm_flag_t alarmbits = 0; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) dchan->span->signal_data; - - ftdm_channel_get_alarms(dchan, &alarmbits); - - if (alarmbits) { - ftdm_log_chan_msg(dchan, FTDM_LOG_WARNING, "Dropping incoming data due to L1 alarm\n"); - return; - } - - if (len > sizeof(l1_frame.data)) { - ftdm_log_chan(dchan, FTDM_LOG_ERROR, "Received frame of %"FTDM_SIZE_FMT" bytes, exceeding max size of %"FTDM_SIZE_FMT" bytes\n", - len, sizeof(l1_frame.data)); - return; - } - if (len <= 2) { - return; - } - - memset(&l1_frame, 0, sizeof(l1_frame)); - l1_frame.len = len; - - memcpy(&l1_frame.data, data, len); - - if (ftdm_test_flag(&(dchan->iostats.rx), FTDM_IOSTATS_ERROR_CRC)) { - l1_frame.flags |= SNG_L1FRAME_ERROR_CRC; - } - - if (ftdm_test_flag(&(dchan->iostats.rx), FTDM_IOSTATS_ERROR_FRAME)) { - l1_frame.flags |= SNG_L1FRAME_ERROR_FRAME; - } - - if (ftdm_test_flag(&(dchan->iostats.rx), FTDM_IOSTATS_ERROR_ABORT)) { - l1_frame.flags |= SNG_L1FRAME_ERROR_ABORT; - } - - if (ftdm_test_flag(&(dchan->iostats.rx), FTDM_IOSTATS_ERROR_FIFO)) { - l1_frame.flags |= SNG_L1FRAME_ERROR_FIFO; - } - - if (ftdm_test_flag(&(dchan->iostats.rx), FTDM_IOSTATS_ERROR_DMA)) { - l1_frame.flags |= SNG_L1FRAME_ERROR_DMA; - } - - if (ftdm_test_flag(&(dchan->iostats.rx), FTDM_IOSTATS_ERROR_QUEUE_THRES)) { - /* Should we trigger congestion here? */ - l1_frame.flags |= SNG_L1FRAME_QUEUE_THRES; - } - - if (ftdm_test_flag(&(dchan->iostats.rx), FTDM_IOSTATS_ERROR_QUEUE_FULL)) { - /* Should we trigger congestion here? */ - l1_frame.flags |= SNG_L1FRAME_QUEUE_FULL; - } -#if 0 - if (1) { - int i; - char string [2000]; - unsigned string_len = 0; - for (i = 0; i < l1_frame.len; i++) { - string_len += sprintf(&string[string_len], "0x%02x ", l1_frame.data[i]); - } - - ftdm_log_chan(dchan, FTDM_LOG_CRIT, "\nL1 RX [%s] flags:%x\n", string, l1_frame.flags); - } -#endif - sng_isdn_data_ind(signal_data->link_id, &l1_frame); -} - -void sngisdn_snd_event(sngisdn_span_data_t *signal_data, ftdm_oob_event_t event) -{ - sng_l1_event_t l1_event; - - if (!signal_data->dchan) { - return; - } - memset(&l1_event, 0, sizeof(l1_event)); - - switch(event) { - case FTDM_OOB_ALARM_CLEAR: - l1_event.type = SNG_L1EVENT_ALARM_OFF; - sng_isdn_event_ind(signal_data->link_id, &l1_event); - - if (!signal_data->dl_request_pending) { - signal_data->dl_request_pending = 1; - ftdm_sched_timer(signal_data->sched, "delayed_dl_req", 8000, sngisdn_delayed_dl_req, (void*) signal_data, NULL); - } - break; - case FTDM_OOB_ALARM_TRAP: - l1_event.type = SNG_L1EVENT_ALARM_ON; - sng_isdn_event_ind(signal_data->link_id, &l1_event); - break; - default: - /* We do not care about the other OOB events for now */ - return; - } - return; -} - - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ - -/******************************************************************************/ diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c deleted file mode 100644 index e5bebb1c8b..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c +++ /dev/null @@ -1,1134 +0,0 @@ -/* - * Copyright (c) 2010, Sangoma Technologies - * David Yat Sin - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "ftmod_sangoma_isdn.h" -//static void sngisdn_rcv_q931_ind_span(sngisdn_span_data_t *signal_data, InMngmt *status); - -void sngisdn_rcv_con_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, ConEvnt *conEvnt, int16_t dChan, uint8_t ces) -{ - uint8_t bchan_no = 0; - int8_t interface_id = -1; /* Specifies which interface for NFAS */ - sngisdn_chan_data_t *sngisdn_info = NULL; - sngisdn_event_data_t *sngisdn_event = NULL; - - ISDN_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - ftdm_assert(g_sngisdn_data.ccs[suId].activation_done != 0, "Con Ind on unconfigured cc\n"); - ftdm_assert(g_sngisdn_data.spans[dChan], "Con Ind on unconfigured dchan\n"); - - if (conEvnt->chanId.eh.pres != PRSNT_NODEF) { - /* TODO: Implement me */ - ftdm_log(FTDM_LOG_ERROR, "Incoming call without Channel Id not supported yet\n"); - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - - if (conEvnt->chanId.chanNmbSlotMap.pres) { - bchan_no = conEvnt->chanId.chanNmbSlotMap.val[0]; - } else if (conEvnt->chanId.infoChanSel.pres) { - bchan_no = conEvnt->chanId.infoChanSel.val; - } - - if (conEvnt->chanId.intIdent.pres) { - interface_id = conEvnt->chanId.intIdent.val; - } - - if (!bchan_no) { - ftdm_log(FTDM_LOG_ERROR, "Failed to obtain b-channel number from SETUP message\n"); - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - - if (g_sngisdn_data.spans[dChan]->nfas.trunk) { - if (interface_id < 0) { - ftdm_log(FTDM_LOG_ERROR, "Interface ID not present on NFAS interface\n"); - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } else if (!g_sngisdn_data.spans[dChan]->nfas.trunk->spans[interface_id]) { - ftdm_log(FTDM_LOG_ERROR, "NFAS group:%s does not have logical interface %d\n", g_sngisdn_data.spans[dChan]->nfas.trunk->name, interface_id); - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } else { - sngisdn_info = g_sngisdn_data.spans[dChan]->nfas.trunk->spans[interface_id]->channels[bchan_no]; - } - } else { - if (g_sngisdn_data.spans[dChan]->channels[bchan_no] == NULL) { - ftdm_log(FTDM_LOG_ERROR, "Incoming call on unconfigured b-channel:%d\n", bchan_no); - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - - sngisdn_info = g_sngisdn_data.spans[dChan]->channels[bchan_no]; - } - - - ftdm_log_chan(sngisdn_info->ftdmchan, FTDM_LOG_INFO, "Received SETUP (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId); - - sngisdn_event = ftdm_malloc(sizeof(*sngisdn_event)); - ftdm_assert(sngisdn_event, "Failed to allocate memory\n"); - memset(sngisdn_event, 0, sizeof(*sngisdn_event)); - - sngisdn_event->event_id = SNGISDN_EVENT_CON_IND; - sngisdn_event->sngisdn_info = sngisdn_info; - sngisdn_event->suId = suId; - sngisdn_event->spInstId = spInstId; - sngisdn_event->dChan = dChan; - sngisdn_event->ces = ces; - - ftdm_mutex_lock(g_sngisdn_data.ccs[suId].mutex); - g_sngisdn_data.ccs[suId].active_spInstIds[spInstId] = sngisdn_info; - ftdm_mutex_unlock(g_sngisdn_data.ccs[suId].mutex); - - memcpy(&sngisdn_event->event.conEvnt, conEvnt, sizeof(*conEvnt)); - - ftdm_queue_enqueue(((sngisdn_span_data_t*)sngisdn_info->ftdmchan->span->signal_data)->event_queue, sngisdn_event); - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); -} - -void sngisdn_rcv_con_cfm (int16_t suId, uint32_t suInstId, uint32_t spInstId, CnStEvnt *cnStEvnt, int16_t dChan, uint8_t ces) -{ - sngisdn_chan_data_t *sngisdn_info = NULL; - sngisdn_event_data_t *sngisdn_event = NULL; - - ISDN_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - ftdm_assert(g_sngisdn_data.ccs[suId].activation_done != 0, "Con Cfm on unconfigured cc\n"); - ftdm_assert(g_sngisdn_data.spans[dChan] != 0, "Con Cfm on unconfigured dchan\n"); - - if (get_ftdmchan_by_suInstId(suId, suInstId, &sngisdn_info) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_CRIT, "Could not find matching call suId:%u suInstId:%u spInstId:%u\n", suId, suInstId, spInstId); - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - - if (!sngisdn_info->spInstId) { - ftdm_mutex_lock(g_sngisdn_data.ccs[suId].mutex); - - sngisdn_info->spInstId = spInstId; - g_sngisdn_data.ccs[suId].active_spInstIds[spInstId] = sngisdn_info; - ftdm_mutex_unlock(g_sngisdn_data.ccs[suId].mutex); - } - - - ftdm_log_chan(sngisdn_info->ftdmchan, FTDM_LOG_INFO, "Received CONNECT/CONNECT ACK (suId:%u suInstId:%u spInstId:%u ces:%d)\n", suId, suInstId, spInstId, ces); - - sngisdn_event = ftdm_malloc(sizeof(*sngisdn_event)); - ftdm_assert(sngisdn_event, "Failed to allocate memory\n"); - memset(sngisdn_event, 0, sizeof(*sngisdn_event)); - - sngisdn_event->event_id = SNGISDN_EVENT_CON_CFM; - sngisdn_event->sngisdn_info = sngisdn_info; - sngisdn_event->suId = suId; - sngisdn_event->suInstId = suInstId; - sngisdn_event->spInstId = spInstId; - sngisdn_event->dChan = dChan; - sngisdn_event->ces = ces; - memcpy(&sngisdn_event->event.cnStEvnt, cnStEvnt, sizeof(*cnStEvnt)); - - ftdm_queue_enqueue(((sngisdn_span_data_t*)sngisdn_info->ftdmchan->span->signal_data)->event_queue, sngisdn_event); - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); -} - -void sngisdn_rcv_cnst_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, CnStEvnt *cnStEvnt, uint8_t evntType, int16_t dChan, uint8_t ces) -{ - sngisdn_chan_data_t *sngisdn_info = NULL; - sngisdn_event_data_t *sngisdn_event = NULL; - - ISDN_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - ftdm_assert(g_sngisdn_data.ccs[suId].activation_done != 0, "Cnst Ind on unconfigured cc\n"); - ftdm_assert(g_sngisdn_data.spans[dChan] != 0, "Cnst Ind on unconfigured dchan\n"); - - if (get_ftdmchan_by_suInstId(suId, suInstId, &sngisdn_info) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_CRIT, "Could not find matching call suId:%u suInstId:%u spInstId:%u\n", suId, suInstId, spInstId); - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - - if (!sngisdn_info->spInstId) { - ftdm_mutex_lock(g_sngisdn_data.ccs[suId].mutex); - - sngisdn_info->spInstId = spInstId; - g_sngisdn_data.ccs[suId].active_spInstIds[spInstId] = sngisdn_info; - ftdm_mutex_unlock(g_sngisdn_data.ccs[suId].mutex); - } - - ftdm_log_chan(sngisdn_info->ftdmchan, FTDM_LOG_INFO, "Received %s (suId:%u suInstId:%u spInstId:%u ces:%d)\n", - (evntType == MI_ALERTING)?"ALERT": - (evntType == MI_CALLPROC)?"PROCEED": - (evntType == MI_PROGRESS)?"PROGRESS": - (evntType == MI_SETUPACK)?"SETUP ACK": - (evntType == MI_NOTIFY)?"NOTIFY": - (evntType == MI_INFO)?"INFO":"UNKNOWN", - suId, suInstId, spInstId, ces); - - sngisdn_event = ftdm_malloc(sizeof(*sngisdn_event)); - ftdm_assert(sngisdn_event, "Failed to allocate memory\n"); - memset(sngisdn_event, 0, sizeof(*sngisdn_event)); - - sngisdn_event->event_id = SNGISDN_EVENT_CNST_IND; - sngisdn_event->sngisdn_info = sngisdn_info; - sngisdn_event->suId = suId; - sngisdn_event->suInstId = suInstId; - sngisdn_event->spInstId = spInstId; - sngisdn_event->dChan = dChan; - sngisdn_event->ces = ces; - sngisdn_event->evntType = evntType; - - memcpy(&sngisdn_event->event.cnStEvnt, cnStEvnt, sizeof(*cnStEvnt)); - - ftdm_queue_enqueue(((sngisdn_span_data_t*)sngisdn_info->ftdmchan->span->signal_data)->event_queue, sngisdn_event); - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); -} - -void sngisdn_rcv_disc_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, DiscEvnt *discEvnt) -{ - sngisdn_chan_data_t *sngisdn_info = NULL; - sngisdn_event_data_t *sngisdn_event = NULL; - - ISDN_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - ftdm_assert(spInstId != 0, "Received DISCONNECT with invalid id"); - - if (!(spInstId && get_ftdmchan_by_spInstId(suId, spInstId, &sngisdn_info) == FTDM_SUCCESS) && - !(suInstId && get_ftdmchan_by_suInstId(suId, suInstId, &sngisdn_info) == FTDM_SUCCESS)) { - - ftdm_log(FTDM_LOG_CRIT, "Could not find matching call suId:%u suInstId:%u spInstId:%u\n", suId, suInstId, spInstId); - ftdm_assert(0, "Inconsistent call states\n"); - return; - } - - ftdm_log_chan(sngisdn_info->ftdmchan, FTDM_LOG_INFO, "Received DISCONNECT (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId); - - sngisdn_event = ftdm_malloc(sizeof(*sngisdn_event)); - ftdm_assert(sngisdn_event, "Failed to allocate memory\n"); - memset(sngisdn_event, 0, sizeof(*sngisdn_event)); - - sngisdn_event->event_id = SNGISDN_EVENT_DISC_IND; - sngisdn_event->sngisdn_info = sngisdn_info; - sngisdn_event->suId = suId; - sngisdn_event->suInstId = suInstId; - sngisdn_event->spInstId = spInstId; - - memcpy(&sngisdn_event->event.discEvnt, discEvnt, sizeof(*discEvnt)); - - ftdm_queue_enqueue(((sngisdn_span_data_t*)sngisdn_info->ftdmchan->span->signal_data)->event_queue, sngisdn_event); - - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); -} - -void sngisdn_rcv_rel_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, RelEvnt *relEvnt) -{ - sngisdn_chan_data_t *sngisdn_info = NULL; - sngisdn_event_data_t *sngisdn_event = NULL; - - ISDN_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - if (!(spInstId && get_ftdmchan_by_spInstId(suId, spInstId, &sngisdn_info) == FTDM_SUCCESS) && - !(suInstId && get_ftdmchan_by_suInstId(suId, suInstId, &sngisdn_info) == FTDM_SUCCESS)) { - - ftdm_log(FTDM_LOG_CRIT, "Could not find matching call suId:%u suInstId:%u spInstId:%u\n", suId, suInstId, spInstId); - /* It seems that Trillium has a bug where they sometimes send release twice on a call, so do not crash on these for now */ - /* ftdm_assert(0, "Inconsistent call states\n"); */ - return; - } - - ftdm_log_chan(sngisdn_info->ftdmchan, FTDM_LOG_INFO, "Received RELEASE/RELEASE COMPLETE (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId); - - sngisdn_event = ftdm_malloc(sizeof(*sngisdn_event)); - ftdm_assert(sngisdn_event != NULL, "Failed to allocate memory\n"); - memset(sngisdn_event, 0, sizeof(*sngisdn_event)); - - sngisdn_event->event_id = SNGISDN_EVENT_REL_IND; - sngisdn_event->sngisdn_info = sngisdn_info; - sngisdn_event->suId = suId; - sngisdn_event->suInstId = suInstId; - sngisdn_event->spInstId = spInstId; - - memcpy(&sngisdn_event->event.relEvnt, relEvnt, sizeof(*relEvnt)); - - ftdm_queue_enqueue(((sngisdn_span_data_t*)sngisdn_info->ftdmchan->span->signal_data)->event_queue, sngisdn_event); - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); -} - -void sngisdn_rcv_dat_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, InfoEvnt *infoEvnt) -{ - sngisdn_chan_data_t *sngisdn_info; - sngisdn_event_data_t *sngisdn_event = NULL; - - ISDN_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - if (!(spInstId && get_ftdmchan_by_spInstId(suId, spInstId, &sngisdn_info) == FTDM_SUCCESS) && - !(suInstId && get_ftdmchan_by_suInstId(suId, suInstId, &sngisdn_info) == FTDM_SUCCESS)) { - - ftdm_log(FTDM_LOG_CRIT, "Could not find matching call suId:%u suInstId:%u spInstId:%u\n", suId, suInstId, spInstId); - ftdm_assert(0, "Inconsistent call states\n"); - return; - } - - ftdm_log_chan(sngisdn_info->ftdmchan, FTDM_LOG_INFO, "Received DATA IND suId:%u suInstId:%u spInstId:%u\n", suId, suInstId, spInstId); - - sngisdn_event = ftdm_malloc(sizeof(*sngisdn_event)); - ftdm_assert(sngisdn_event != NULL, "Failed to allocate memory\n"); - memset(sngisdn_event, 0, sizeof(*sngisdn_event)); - - sngisdn_event->event_id = SNGISDN_EVENT_DAT_IND; - sngisdn_event->sngisdn_info = sngisdn_info; - sngisdn_event->suId = suId; - sngisdn_event->suInstId = suInstId; - sngisdn_event->spInstId = spInstId; - - memcpy(&sngisdn_event->event.infoEvnt, infoEvnt, sizeof(*infoEvnt)); - - ftdm_queue_enqueue(((sngisdn_span_data_t*)sngisdn_info->ftdmchan->span->signal_data)->event_queue, sngisdn_event); - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); -} - -void sngisdn_rcv_sshl_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, SsHlEvnt *ssHlEvnt, uint8_t action) -{ - sngisdn_chan_data_t *sngisdn_info; - sngisdn_event_data_t *sngisdn_event = NULL; - - ISDN_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - if (!(spInstId && get_ftdmchan_by_spInstId(suId, spInstId, &sngisdn_info) == FTDM_SUCCESS) && - !(suInstId && get_ftdmchan_by_suInstId(suId, suInstId, &sngisdn_info) == FTDM_SUCCESS)) { - - ftdm_log(FTDM_LOG_CRIT, "Could not find matching call suId:%u suInstId:%u spInstId:%u\n", suId, suInstId, spInstId); - ftdm_assert(0, "Inconsistent call states\n"); - return; - } - - ftdm_log_chan(sngisdn_info->ftdmchan, FTDM_LOG_INFO, "Received SSHL IND (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId); - - sngisdn_event = ftdm_malloc(sizeof(*sngisdn_event)); - ftdm_assert(sngisdn_event != NULL, "Failed to allocate memory\n"); - memset(sngisdn_event, 0, sizeof(*sngisdn_event)); - - sngisdn_event->event_id = SNGISDN_EVENT_SSHL_IND; - sngisdn_event->sngisdn_info = sngisdn_info; - sngisdn_event->suId = suId; - sngisdn_event->suInstId = suInstId; - sngisdn_event->spInstId = spInstId; - sngisdn_event->action = action; - - memcpy(&sngisdn_event->event.ssHlEvnt, ssHlEvnt, sizeof(*ssHlEvnt)); - - ftdm_queue_enqueue(((sngisdn_span_data_t*)sngisdn_info->ftdmchan->span->signal_data)->event_queue, sngisdn_event); - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); -} - -void sngisdn_rcv_sshl_cfm (int16_t suId, uint32_t suInstId, uint32_t spInstId, SsHlEvnt *ssHlEvnt, uint8_t action) -{ - sngisdn_chan_data_t *sngisdn_info; - sngisdn_event_data_t *sngisdn_event = NULL; - - ISDN_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - if (!(spInstId && get_ftdmchan_by_spInstId(suId, spInstId, &sngisdn_info) == FTDM_SUCCESS) && - !(suInstId && get_ftdmchan_by_suInstId(suId, suInstId, &sngisdn_info) == FTDM_SUCCESS)) { - - ftdm_log(FTDM_LOG_CRIT, "Could not find matching call suId:%u suInstId:%u spInstId:%u\n", suId, suInstId, spInstId); - ftdm_assert(0, "Inconsistent call states\n"); - return; - } - - ftdm_log_chan(sngisdn_info->ftdmchan, FTDM_LOG_INFO, "Received SSHL CFM (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId); - - sngisdn_event = ftdm_malloc(sizeof(*sngisdn_event)); - ftdm_assert(sngisdn_event != NULL, "Failed to allocate memory\n"); - memset(sngisdn_event, 0, sizeof(*sngisdn_event)); - - sngisdn_event->event_id = SNGISDN_EVENT_SSHL_CFM; - sngisdn_event->sngisdn_info = sngisdn_info; - sngisdn_event->suId = suId; - sngisdn_event->suInstId = suInstId; - sngisdn_event->spInstId = spInstId; - sngisdn_event->action = action; - - memcpy(&sngisdn_event->event.ssHlEvnt, ssHlEvnt, sizeof(*ssHlEvnt)); - - ftdm_queue_enqueue(((sngisdn_span_data_t*)sngisdn_info->ftdmchan->span->signal_data)->event_queue, sngisdn_event); - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); -} -void sngisdn_rcv_rmrt_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, RmRtEvnt *rmRtEvnt, uint8_t action) -{ - sngisdn_chan_data_t *sngisdn_info; - sngisdn_event_data_t *sngisdn_event = NULL; - - ISDN_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - if (!(spInstId && get_ftdmchan_by_spInstId(suId, spInstId, &sngisdn_info) == FTDM_SUCCESS) && - !(suInstId && get_ftdmchan_by_suInstId(suId, suInstId, &sngisdn_info) == FTDM_SUCCESS)) { - - ftdm_log(FTDM_LOG_CRIT, "Could not find matching call suId:%u suInstId:%u spInstId:%u\n", suId, suInstId, spInstId); - ftdm_assert(0, "Inconsistent call states\n"); - return; - } - - ftdm_log_chan(sngisdn_info->ftdmchan, FTDM_LOG_INFO, "Received RMRT IND (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId); - - sngisdn_event = ftdm_malloc(sizeof(*sngisdn_event)); - ftdm_assert(sngisdn_event != NULL, "Failed to allocate memory\n"); - memset(sngisdn_event, 0, sizeof(*sngisdn_event)); - - sngisdn_event->event_id = SNGISDN_EVENT_RMRT_IND; - sngisdn_event->sngisdn_info = sngisdn_info; - sngisdn_event->suId = suId; - sngisdn_event->suInstId = suInstId; - sngisdn_event->spInstId = spInstId; - sngisdn_event->action = action; - - memcpy(&sngisdn_event->event.rmRtEvnt, rmRtEvnt, sizeof(*rmRtEvnt)); - - ftdm_queue_enqueue(((sngisdn_span_data_t*)sngisdn_info->ftdmchan->span->signal_data)->event_queue, sngisdn_event); - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); -} - -void sngisdn_rcv_rmrt_cfm (int16_t suId, uint32_t suInstId, uint32_t spInstId, RmRtEvnt *rmRtEvnt, uint8_t action) -{ - sngisdn_chan_data_t *sngisdn_info; - sngisdn_event_data_t *sngisdn_event = NULL; - - ISDN_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - if (!(spInstId && get_ftdmchan_by_spInstId(suId, spInstId, &sngisdn_info) == FTDM_SUCCESS) && - !(suInstId && get_ftdmchan_by_suInstId(suId, suInstId, &sngisdn_info) == FTDM_SUCCESS)) { - - ftdm_log(FTDM_LOG_CRIT, "Could not find matching call suId:%u suInstId:%u spInstId:%u\n", suId, suInstId, spInstId); - ftdm_assert(0, "Inconsistent call states\n"); - return; - } - - ftdm_log_chan(sngisdn_info->ftdmchan, FTDM_LOG_INFO, "Received RESUME/RETRIEVE CFM (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId); - - sngisdn_event = ftdm_malloc(sizeof(*sngisdn_event)); - ftdm_assert(sngisdn_event != NULL, "Failed to allocate memory\n"); - memset(sngisdn_event, 0, sizeof(*sngisdn_event)); - - sngisdn_event->event_id = SNGISDN_EVENT_RMRT_CFM; - sngisdn_event->sngisdn_info = sngisdn_info; - sngisdn_event->suId = suId; - sngisdn_event->suInstId = suInstId; - sngisdn_event->spInstId = spInstId; - sngisdn_event->action = action; - - memcpy(&sngisdn_event->event.rmRtEvnt, rmRtEvnt, sizeof(*rmRtEvnt)); - - ftdm_queue_enqueue(((sngisdn_span_data_t*)sngisdn_info->ftdmchan->span->signal_data)->event_queue, sngisdn_event); - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); -} - -void sngisdn_rcv_flc_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, StaEvnt *staEvnt) -{ - sngisdn_chan_data_t *sngisdn_info; - sngisdn_event_data_t *sngisdn_event = NULL; - - ISDN_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - if (!(spInstId && get_ftdmchan_by_spInstId(suId, spInstId, &sngisdn_info) == FTDM_SUCCESS) && - !(suInstId && get_ftdmchan_by_suInstId(suId, suInstId, &sngisdn_info) == FTDM_SUCCESS)) { - - ftdm_log(FTDM_LOG_CRIT, "Could not find matching call suId:%u suInstId:%u spInstId:%u\n", suId, suInstId, spInstId); - ftdm_assert(0, "Inconsistent call states\n"); - return; - } - - ftdm_log_chan(sngisdn_info->ftdmchan, FTDM_LOG_INFO, "Received FLOW CONTROL IND (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId); - - sngisdn_event = ftdm_malloc(sizeof(*sngisdn_event)); - ftdm_assert(sngisdn_event != NULL, "Failed to allocate memory\n"); - memset(sngisdn_event, 0, sizeof(*sngisdn_event)); - - sngisdn_event->event_id = SNGISDN_EVENT_FLC_IND; - sngisdn_event->sngisdn_info = sngisdn_info; - sngisdn_event->suId = suId; - sngisdn_event->suInstId = suInstId; - sngisdn_event->spInstId = spInstId; - - memcpy(&sngisdn_event->event.staEvnt, staEvnt, sizeof(*staEvnt)); - - ftdm_queue_enqueue(((sngisdn_span_data_t*)sngisdn_info->ftdmchan->span->signal_data)->event_queue, sngisdn_event); - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); -} - - -void sngisdn_rcv_fac_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, FacEvnt *facEvnt, uint8_t evntType, int16_t dChan, uint8_t ces) -{ - sngisdn_chan_data_t *sngisdn_info; - sngisdn_event_data_t *sngisdn_event = NULL; - - ISDN_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - if (!(spInstId && get_ftdmchan_by_spInstId(suId, spInstId, &sngisdn_info) == FTDM_SUCCESS) && - !(suInstId && get_ftdmchan_by_suInstId(suId, suInstId, &sngisdn_info) == FTDM_SUCCESS)) { - - ftdm_log(FTDM_LOG_CRIT, "Could not find matching call suId:%u suInstId:%u spInstId:%u\n", suId, suInstId, spInstId); - ftdm_assert(0, "Inconsistent call states\n"); - return; - } - - ftdm_log_chan(sngisdn_info->ftdmchan, FTDM_LOG_INFO, "Received FACILITY IND (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId); - sngisdn_event = ftdm_malloc(sizeof(*sngisdn_event)); - ftdm_assert(sngisdn_event != NULL, "Failed to allocate memory\n"); - memset(sngisdn_event, 0, sizeof(*sngisdn_event)); - - sngisdn_event->event_id = SNGISDN_EVENT_FAC_IND; - sngisdn_event->sngisdn_info = sngisdn_info; - sngisdn_event->suId = suId; - sngisdn_event->suInstId = suInstId; - sngisdn_event->spInstId = spInstId; - sngisdn_event->evntType = evntType; - - memcpy(&sngisdn_event->event.facEvnt, facEvnt, sizeof(*facEvnt)); - - ftdm_queue_enqueue(((sngisdn_span_data_t*)sngisdn_info->ftdmchan->span->signal_data)->event_queue, sngisdn_event); - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); -} - - -void sngisdn_rcv_sta_cfm (int16_t suId, uint32_t suInstId, uint32_t spInstId, StaEvnt *staEvnt) -{ - sngisdn_chan_data_t *sngisdn_info; - sngisdn_event_data_t *sngisdn_event = NULL; - - ISDN_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - if (!suInstId && !spInstId) { - /* This is a response to a sngisdn_snd_info_req - * that was sent to attempt to re-establish DL link */ - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - - /* We sometimes receive a STA CFM after receiving a RELEASE/RELEASE COMPLETE, so we need to lock - here in case we are calling clear_call_data at the same time this function is called */ - - ftdm_mutex_lock(g_sngisdn_data.ccs[suId].mutex); - if (!(spInstId && get_ftdmchan_by_spInstId(suId, spInstId, &sngisdn_info) == FTDM_SUCCESS) && - !(suInstId && get_ftdmchan_by_suInstId(suId, suInstId, &sngisdn_info) == FTDM_SUCCESS)) { - - ftdm_log(FTDM_LOG_CRIT, "Could not find matching call suId:%u suInstId:%u spInstId:%u\n", suId, suInstId, spInstId); - ftdm_mutex_unlock(g_sngisdn_data.ccs[suId].mutex); - return; - } - - ftdm_log_chan(sngisdn_info->ftdmchan, FTDM_LOG_INFO, "Received STATUS CONFIRM (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId); - - sngisdn_event = ftdm_malloc(sizeof(*sngisdn_event)); - ftdm_assert(sngisdn_event != NULL, "Failed to allocate memory\n"); - memset(sngisdn_event, 0, sizeof(*sngisdn_event)); - - sngisdn_event->event_id = SNGISDN_EVENT_STA_CFM; - sngisdn_event->sngisdn_info = sngisdn_info; - sngisdn_event->suId = suId; - sngisdn_event->suInstId = suInstId; - sngisdn_event->spInstId = spInstId; - - memcpy(&sngisdn_event->event.staEvnt, staEvnt, sizeof(*staEvnt)); - - ftdm_queue_enqueue(((sngisdn_span_data_t*)sngisdn_info->ftdmchan->span->signal_data)->event_queue, sngisdn_event); - ftdm_mutex_unlock(g_sngisdn_data.ccs[suId].mutex); - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); -} - -void sngisdn_rcv_srv_ind (int16_t suId, Srv *srvEvnt, int16_t dChan, uint8_t ces) -{ - - sngisdn_span_data_t *signal_data; - sngisdn_event_data_t *sngisdn_event = NULL; - - ISDN_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - ftdm_log(FTDM_LOG_INFO, "Received SERVICE IND (dChan:%d ces:%u)\n", dChan, ces); - - signal_data = g_sngisdn_data.spans[dChan]; - - if (signal_data->nfas.trunk) { - unsigned i; - for (i = 0; i < signal_data->nfas.trunk->num_spans; i++) { - sngisdn_span_data_t *my_signal_data = signal_data->nfas.trunk->spans[i]; - - sngisdn_event = ftdm_malloc(sizeof(*sngisdn_event)); - ftdm_assert(sngisdn_event != NULL, "Failed to allocate memory\n"); - memset(sngisdn_event, 0, sizeof(*sngisdn_event)); - sngisdn_event->event_id = SNGISDN_EVENT_SRV_IND; - sngisdn_event->suId = suId; - sngisdn_event->dChan = dChan; - sngisdn_event->ces = ces; - sngisdn_event->signal_data = my_signal_data; - memcpy(&sngisdn_event->event.srvEvnt, srvEvnt, sizeof(*srvEvnt)); - ftdm_queue_enqueue(my_signal_data->event_queue, sngisdn_event); - } - } else { - ftdm_queue_enqueue(signal_data->event_queue, sngisdn_event); - } - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); -} - - -void sngisdn_rcv_srv_cfm (int16_t suId, Srv *srvEvnt, int16_t dChan, uint8_t ces) -{ - sngisdn_span_data_t *signal_data = NULL; - sngisdn_event_data_t *sngisdn_event = NULL; - - ISDN_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - ftdm_log(FTDM_LOG_INFO, "Received SERVICE CFM (dChan:%d ces:%u)\n", dChan, ces); - - signal_data = g_sngisdn_data.spans[dChan]; - - if (signal_data->nfas.trunk) { - unsigned i; - for (i = 0; i < signal_data->nfas.trunk->num_spans; i++) { - sngisdn_span_data_t *my_signal_data = signal_data->nfas.trunk->spans[i]; - - sngisdn_event = ftdm_malloc(sizeof(*sngisdn_event)); - ftdm_assert(sngisdn_event != NULL, "Failed to allocate memory\n"); - memset(sngisdn_event, 0, sizeof(*sngisdn_event)); - sngisdn_event->event_id = SNGISDN_EVENT_SRV_CFM; - sngisdn_event->suId = suId; - sngisdn_event->dChan = dChan; - sngisdn_event->ces = ces; - sngisdn_event->signal_data = my_signal_data; - memcpy(&sngisdn_event->event.srvEvnt, srvEvnt, sizeof(*srvEvnt)); - ftdm_queue_enqueue(my_signal_data->event_queue, sngisdn_event); - } - } else { - ftdm_queue_enqueue(signal_data->event_queue, sngisdn_event); - } - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); -} - -void sngisdn_rcv_rst_ind (int16_t suId, Rst *rstEvnt, int16_t dChan, uint8_t ces, uint8_t evntType) -{ - sngisdn_span_data_t *signal_data = NULL; - sngisdn_event_data_t *sngisdn_event = NULL; - - ISDN_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - ftdm_log(FTDM_LOG_INFO, "Received RESTART IND (dChan:%d ces:%u type:%u)\n", dChan, ces, evntType); - - signal_data = g_sngisdn_data.spans[dChan]; - - if (signal_data->nfas.trunk) { - unsigned i; - for (i = 0; i < signal_data->nfas.trunk->num_spans; i++) { - sngisdn_span_data_t *my_signal_data = signal_data->nfas.trunk->spans[i]; - - sngisdn_event = ftdm_malloc(sizeof(*sngisdn_event)); - ftdm_assert(sngisdn_event != NULL, "Failed to allocate memory\n"); - memset(sngisdn_event, 0, sizeof(*sngisdn_event)); - sngisdn_event->event_id = SNGISDN_EVENT_RST_IND; - sngisdn_event->suId = suId; - sngisdn_event->dChan = dChan; - sngisdn_event->ces = ces; - sngisdn_event->signal_data = my_signal_data; - memcpy(&sngisdn_event->event.rstEvnt, rstEvnt, sizeof(*rstEvnt)); - ftdm_queue_enqueue(my_signal_data->event_queue, sngisdn_event); - } - } else { - ftdm_queue_enqueue(signal_data->event_queue, sngisdn_event); - } - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); -} - -void sngisdn_rcv_rst_cfm (int16_t suId, Rst *rstEvnt, int16_t dChan, uint8_t ces, uint8_t evntType) -{ - sngisdn_span_data_t *signal_data; - sngisdn_event_data_t *sngisdn_event = NULL; - - ISDN_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - - ftdm_log(FTDM_LOG_INFO, "Received RESTART CFM (dChan:%d ces:%u type:%u)\n", dChan, ces, evntType); - - signal_data = g_sngisdn_data.spans[dChan]; - - if (signal_data->nfas.trunk) { - unsigned i; - for (i = 0; i < signal_data->nfas.trunk->num_spans; i++) { - sngisdn_span_data_t *my_signal_data = signal_data->nfas.trunk->spans[i]; - - sngisdn_event = ftdm_malloc(sizeof(*sngisdn_event)); - ftdm_assert(sngisdn_event != NULL, "Failed to allocate memory\n"); - memset(sngisdn_event, 0, sizeof(*sngisdn_event)); - sngisdn_event->event_id = SNGISDN_EVENT_RST_CFM; - sngisdn_event->suId = suId; - sngisdn_event->dChan = dChan; - sngisdn_event->ces = ces; - sngisdn_event->signal_data = my_signal_data; - memcpy(&sngisdn_event->event.rstEvnt, rstEvnt, sizeof(*rstEvnt)); - ftdm_queue_enqueue(my_signal_data->event_queue, sngisdn_event); - } - } else { - ftdm_queue_enqueue(signal_data->event_queue, sngisdn_event); - } - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); -} - - -void sngisdn_rcv_phy_ind(SuId suId, Reason reason) -{ - if (reason != LL1_REASON_CON_REQ_FAIL) { - ftdm_log(FTDM_LOG_DEBUG, "[SNGISDN PHY] D-chan %d : %s\n", suId, DECODE_LL1_REASON(reason)); - } - return; -} - -void sngisdn_rcv_q921_ind(BdMngmt *status) -{ - ftdm_span_t *ftdmspan; - - sngisdn_span_data_t *signal_data = g_sngisdn_data.spans[status->t.usta.lnkNmb]; - - if (!signal_data) { - ftdm_log(FTDM_LOG_INFO, "Received q921 status on unconfigured span (lnkNmb:%d)\n", status->t.usta.lnkNmb); - return; - } - ftdmspan = signal_data->ftdm_span; - - if (!ftdmspan) { - ftdm_log(FTDM_LOG_INFO, "Received q921 status on unconfigured span (lnkNmb:%d)\n", status->t.usta.lnkNmb); - return; - } - - switch (status->t.usta.alarm.category) { - case (LCM_CATEGORY_PROTOCOL): - ftdm_log(FTDM_LOG_DEBUG, "[SNGISDN Q921] %s: %s: %s(%d): %s(%d)\n", - ftdmspan->name, - DECODE_LCM_CATEGORY(status->t.usta.alarm.category), - DECODE_LLD_EVENT(status->t.usta.alarm.event), status->t.usta.alarm.event, - DECODE_LLD_CAUSE(status->t.usta.alarm.cause), status->t.usta.alarm.cause); - - if (FTDM_SPAN_IS_BRI(ftdmspan) && (status->t.usta.alarm.event == PROT_ST_DN)) { - /* Q.921 link is down - This is a line where the Q.921 stops transmitting - after the line goes idle. - - Do not drop current calls, but set sigstatus do down so that we - can try to re-initialize link before trying new outbound calls */ - - sngisdn_set_span_sig_status(ftdmspan, FTDM_SIG_STATE_DOWN); - sngisdn_set_span_avail_rate(ftdmspan, SNGISDN_AVAIL_PWR_SAVING); - } - break; - default: - ftdm_log(FTDM_LOG_INFO, "[SNGISDN Q921] %s: %s: %s(%d): %s(%d)\n", - ftdmspan->name, - DECODE_LCM_CATEGORY(status->t.usta.alarm.category), - DECODE_LLD_EVENT(status->t.usta.alarm.event), status->t.usta.alarm.event, - DECODE_LLD_CAUSE(status->t.usta.alarm.cause), status->t.usta.alarm.cause); - - switch (status->t.usta.alarm.event) { - case ENTR_CONG: /* Entering Congestion */ - ftdm_log(FTDM_LOG_WARNING, "s%d: Entering Congestion\n", ftdmspan->span_id); - ftdm_set_flag(ftdmspan, FTDM_SPAN_SUSPENDED); - break; - case EXIT_CONG: /* Exiting Congestion */ - ftdm_log(FTDM_LOG_WARNING, "s%d: Exiting Congestion\n", ftdmspan->span_id); - ftdm_clear_flag(ftdmspan, FTDM_SPAN_SUSPENDED); - break; - } - break; - } - return; -} - -#if 0 -static void sngisdn_rcv_q931_ind_span(sngisdn_span_data_t *signal_data, InMngmt *status) -{ - ftdm_span_t *ftdmspan = signal_data->ftdm_span; - uint32_t chan_no = status->t.usta.evntParm[2]; - - if (!signal_data) { - ftdm_log(FTDM_LOG_INFO, "Received q931 status on unconfigured span (lnkNmb:%d)\n", status->t.usta.suId); - return; - } - - ftdm_log(FTDM_LOG_INFO, "[SNGISDN Q931] s%d: %s: %s(%d): %s(%d)\n", - status->t.usta.suId, - DECODE_LCM_CATEGORY(status->t.usta.alarm.category), - DECODE_LCM_EVENT(status->t.usta.alarm.event), status->t.usta.alarm.event, - DECODE_LCM_CAUSE(status->t.usta.alarm.cause), status->t.usta.alarm.cause); - - if (chan_no) { - ftdm_channel_t *ftdmchan = ftdm_span_get_channel(ftdmspan, chan_no); - if (ftdmchan) { - sngisdn_set_chan_sig_status(ftdmchan, (status->t.usta.alarm.event == LCM_EVENT_UP) ? FTDM_SIG_STATE_UP : FTDM_SIG_STATE_DOWN); - sngisdn_set_chan_avail_rate(ftdmchan, (status->t.usta.alarm.event == LCM_EVENT_UP) ? SNGISDN_AVAIL_UP: SNGISDN_AVAIL_PWR_SAVING); - } else { - ftdm_log(FTDM_LOG_CRIT, "stack alarm event on invalid channel :%d\n", chan_no); - } - } else { - sngisdn_set_span_sig_status(ftdmspan, (status->t.usta.alarm.event == LCM_EVENT_UP) ? FTDM_SIG_STATE_UP : FTDM_SIG_STATE_DOWN); - sngisdn_set_span_avail_rate(ftdmspan, (status->t.usta.alarm.event == LCM_EVENT_UP) ? SNGISDN_AVAIL_UP: SNGISDN_AVAIL_PWR_SAVING); - } -} -#endif - -void sngisdn_rcv_q931_ind(InMngmt *status) -{ - sngisdn_span_data_t *signal_data = NULL; - ftdm_span_t *ftdmspan = NULL; -#ifndef WIN32 - if (status->t.usta.alarm.cause == 287) { - sngisdn_get_memory_info(); - return; - } -#endif - - signal_data = g_sngisdn_data.spans[status->t.usta.suId]; - if (!signal_data) { - ftdm_log(FTDM_LOG_INFO, "Received q931 status on unconfigured span (lnkNmb:%d)\n", status->t.usta.suId); - return; - } - - ftdmspan = signal_data->ftdm_span; - - switch (status->t.usta.alarm.event) { - case LCM_EVENT_UP: - case LCM_EVENT_DOWN: - { - int i; - sngisdn_nfas_data_t *nfas_data = NULL; - ftdm_log(FTDM_LOG_INFO, "[SNGISDN Q931] s%d: %s: %s(%d): %s(%d)\n", - status->t.usta.suId, - DECODE_LCM_CATEGORY(status->t.usta.alarm.category), - DECODE_LCM_EVENT(status->t.usta.alarm.event), status->t.usta.alarm.event, - DECODE_LCM_CAUSE(status->t.usta.alarm.cause), status->t.usta.alarm.cause); - - nfas_data = signal_data->nfas.trunk; - - if (nfas_data && status->t.usta.alarm.event == LCM_EVENT_UP) { - for (i = 0; i < ftdm_array_len(nfas_data->spans); i++) { - if (nfas_data->spans[i] && nfas_data->spans[i]->nfas.sigchan == SNGISDN_NFAS_DCHAN_NONE) { - - sngisdn_set_span_sig_status(nfas_data->spans[i]->ftdm_span, FTDM_SIG_STATE_UP); - sngisdn_set_span_avail_rate(nfas_data->spans[i]->ftdm_span, SNGISDN_AVAIL_UP); - } - } - } - - sngisdn_set_span_sig_status(ftdmspan, (status->t.usta.alarm.event == LCM_EVENT_UP) ? FTDM_SIG_STATE_UP : FTDM_SIG_STATE_DOWN); - sngisdn_set_span_avail_rate(ftdmspan, (status->t.usta.alarm.event == LCM_EVENT_UP) ? SNGISDN_AVAIL_UP: SNGISDN_AVAIL_PWR_SAVING); - - if (nfas_data && status->t.usta.alarm.event == LCM_EVENT_DOWN) { - if (nfas_data->dchan->sigstatus == FTDM_SIG_STATE_DOWN && - ((nfas_data->backup && nfas_data->backup->sigstatus == FTDM_SIG_STATE_DOWN) || !nfas_data->backup)) { - - for (i = 0; i < ftdm_array_len(nfas_data->spans); i++) { - if (nfas_data->spans[i] && nfas_data->spans[i]->nfas.sigchan == SNGISDN_NFAS_DCHAN_NONE) { - - sngisdn_set_span_sig_status(nfas_data->spans[i]->ftdm_span, FTDM_SIG_STATE_DOWN); - sngisdn_set_span_avail_rate(nfas_data->spans[i]->ftdm_span, SNGISDN_AVAIL_PWR_SAVING); - } - } - } - } - } - break; - default: - ftdm_log(FTDM_LOG_WARNING, "[SNGISDN Q931] s%d: %s: %s(%d): %s(%d)\n", - status->t.usta.suId, - DECODE_LCM_CATEGORY(status->t.usta.alarm.category), - DECODE_LCM_EVENT(status->t.usta.alarm.event), status->t.usta.alarm.event, - DECODE_LCM_CAUSE(status->t.usta.alarm.cause), status->t.usta.alarm.cause); - } - - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; -} - -void sngisdn_rcv_cc_ind(CcMngmt *status) -{ - ISDN_FUNC_TRACE_ENTER(__FTDM_FUNC__); - ftdm_log(FTDM_LOG_INFO, "RECEIVED %s\n", __FTDM_FUNC__); - ISDN_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; -} - -void sngisdn_rcv_q931_trace(InMngmt *trc, Buffer *mBuf) -{ - MsgLen mlen; - int16_t j; - Buffer *tmp; - Data *cptr; - uint8_t data; - ftdm_trace_dir_t dir; - uint8_t tdata[1000]; - - sngisdn_span_data_t *signal_data = g_sngisdn_data.spans[trc->t.trc.suId]; - - ftdm_assert(mBuf != NULLP, "Received a Q931 trace with no buffer"); - mlen = ((SsMsgInfo*)(mBuf->b_rptr))->len; - - if (trc->t.trc.evnt == TL3PKTTX) { - dir = FTDM_TRACE_DIR_OUTGOING; - } else { - dir = FTDM_TRACE_DIR_INCOMING; - } - - if (mlen) { - tmp = mBuf->b_cont; - cptr = tmp->b_rptr; - data = *cptr++; - - for(j=0;jb_wptr) { - tmp = tmp->b_cont; - if (tmp) cptr = tmp->b_rptr; - } - data = *cptr++; - } - if (signal_data->raw_trace_q931 == SNGISDN_OPT_TRUE) { - sngisdn_trace_raw_q931(signal_data, dir, tdata, mlen); - } else { - sngisdn_trace_interpreted_q931(signal_data, dir, tdata, mlen); - } - } - return; -} - - -void sngisdn_rcv_q921_trace(BdMngmt *trc, Buffer *mBuf) -{ - MsgLen mlen; - Buffer *tmp; - MsgLen i; - int16_t j; - Data *cptr; - uint8_t data; - ftdm_trace_dir_t dir; - uint8_t tdata[1000]; - - sngisdn_span_data_t *signal_data = g_sngisdn_data.spans[trc->t.trc.lnkNmb]; - - if (trc->t.trc.evnt == TL2TMR) { - return; - } - - if (trc->t.trc.evnt == TL2FRMTX) { - dir = FTDM_TRACE_DIR_OUTGOING; - } else { - dir = FTDM_TRACE_DIR_INCOMING; - } - - ftdm_assert(mBuf != NULLP, "Received a Q921 trace with no buffer"); - mlen = ((SsMsgInfo*)(mBuf->b_rptr))->len; - if (mlen != 0) { - tmp = mBuf->b_cont; - cptr = tmp->b_rptr; - data = *cptr++; - i = 0; - while (i < mlen) { - j = 0; - for(j=0;j<16;j++) { - if (ib_wptr) { - tmp = tmp->b_cont; - if (tmp) cptr = tmp->b_rptr; - } - i++; - if (iraw_trace_q921 == SNGISDN_OPT_TRUE) { - sngisdn_trace_raw_q921(signal_data, dir, tdata, mlen); - } else { - sngisdn_trace_interpreted_q921(signal_data, dir, tdata, mlen); - } - } - return; -} - -/* The stacks is wants to transmit a frame */ -int16_t sngisdn_rcv_l1_data_req(uint16_t spId, sng_l1_frame_t *l1_frame) -{ - ftdm_status_t status; - ftdm_wait_flag_t flags = FTDM_WRITE; - sngisdn_span_data_t *signal_data = g_sngisdn_data.spans[spId]; - ftdm_size_t length = l1_frame->len; - - ftdm_assert(signal_data, "Received Data request on unconfigured span\n"); - - do { - flags = FTDM_WRITE; - status = signal_data->dchan->fio->wait(signal_data->dchan, &flags, 1000); - switch(status) { - case FTDM_SUCCESS: - break; - case FTDM_TIMEOUT: - continue; - case FTDM_FAIL: - default: - ftdm_log_chan_msg(signal_data->dchan, FTDM_LOG_WARNING, "failed to poll for channel\n"); - return -1; - } - - - /* status = FTDM_SUCCESS */ - if ((flags & FTDM_WRITE)) { -#if 0 - int i; - char string [2000]; - unsigned string_len = 0; - for (i = 0; i < length; i++) { - string_len += sprintf(&string[string_len], "0x%02x ", l1_frame->data[i]); - } - - ftdm_log_chan(signal_data->dchan, FTDM_LOG_CRIT, "\nL1 TX [%s]\n", string); -#endif - - status = signal_data->dchan->fio->write(signal_data->dchan, l1_frame->data, (ftdm_size_t*)&length); - if (status != FTDM_SUCCESS) { - ftdm_log_chan_msg(signal_data->dchan, FTDM_LOG_CRIT, "Failed to transmit frame\n"); - return -1; - } - break; - /* On WIN32, it is possible for poll to return without FTDM_WRITE flag set, so we try to retransmit */ -#ifndef WIN32 - } else { - ftdm_log_chan_msg(signal_data->dchan, FTDM_LOG_WARNING, "Failed to poll for d-channel\n"); - return -1; -#endif - } - } while(1); - return 0; -} - -int16_t sngisdn_rcv_l1_cmd_req(uint16_t spId, sng_l1_cmd_t *l1_cmd) -{ - sngisdn_span_data_t *signal_data = g_sngisdn_data.spans[spId]; - ftdm_assert(signal_data, "Received Data request on unconfigured span\n"); - - switch(l1_cmd->type) { - case SNG_L1CMD_SET_LINK_STATUS: - { - ftdm_channel_hw_link_status_t status = FTDM_HW_LINK_CONNECTED; - ftdm_channel_command(signal_data->dchan, FTDM_COMMAND_SET_LINK_STATUS, &status); - } - break; - case SNG_L1CMD_GET_LINK_STATUS: - { - ftdm_channel_hw_link_status_t status = 0; - ftdm_channel_command(signal_data->dchan, FTDM_COMMAND_GET_LINK_STATUS, &status); - if (status == FTDM_HW_LINK_CONNECTED) { - l1_cmd->cmd.status = 1; - } else if (status == FTDM_HW_LINK_DISCONNECTED) { - l1_cmd->cmd.status = 0; - } else { - ftdm_log_chan(signal_data->dchan, FTDM_LOG_CRIT, "Invalid link status reported %d\n", status); - l1_cmd->cmd.status = 0; - } - } - break; - case SNG_L1CMD_FLUSH_STATS: - ftdm_channel_command(signal_data->dchan, FTDM_COMMAND_FLUSH_IOSTATS, NULL); - break; - case SNG_L1CMD_FLUSH_BUFFERS: - ftdm_channel_command(signal_data->dchan, FTDM_COMMAND_FLUSH_BUFFERS, NULL); - break; - default: - ftdm_log_chan(signal_data->dchan, FTDM_LOG_CRIT, "Unsupported channel command:%d\n", l1_cmd->type); - return -1; - } - return 0; -} - -void sngisdn_rcv_sng_assert(char *message) -{ - ftdm_assert(0, message); -} - -void sngisdn_rcv_sng_log(uint8_t level, char *fmt,...) -{ - char *data; - int ret; - va_list ap; - - va_start(ap, fmt); - ret = ftdm_vasprintf(&data, fmt, ap); - if (ret == -1) { - return; - } - - switch (level) { - case SNG_LOGLEVEL_DEBUG: - ftdm_log(FTDM_LOG_DEBUG, "sng_isdn->%s", data); - break; - case SNG_LOGLEVEL_WARN: - if ( strncmp(data, "Invalid Q.921/Q.931 frame", 25) ) { - ftdm_log(FTDM_LOG_INFO, "sng_isdn->%s", data); - } - break; - case SNG_LOGLEVEL_INFO: - ftdm_log(FTDM_LOG_INFO, "sng_isdn->%s\n", data); - break; - case SNG_LOGLEVEL_STATS: - ftdm_log(FTDM_LOG_INFO, "sng_isdn->%s\n", data); - break; - case SNG_LOGLEVEL_ERROR: - ftdm_log(FTDM_LOG_ERROR, "sng_isdn->%s\n", data); - /*ftdm_assert(0, "Got an error from stack");*/ - break; - case SNG_LOGLEVEL_CRIT: - ftdm_log(FTDM_LOG_CRIT, "sng_isdn->%s\n", data); - /* ftdm_assert(0, "Got an error from stack"); */ - break; - default: - ftdm_log(FTDM_LOG_INFO, "sng_isdn->%s\n", data); - break; - } - ftdm_safe_free(data); - return; -} - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ - -/******************************************************************************/ diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c deleted file mode 100644 index 83dd070387..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c +++ /dev/null @@ -1,1643 +0,0 @@ -/* - * Copyright (c) 2010, Sangoma Technologies - * David Yat Sin - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "ftmod_sangoma_isdn.h" -#define SNGISDN_Q931_FACILITY_IE_ID 0x1C - -/* ftmod_sangoma_isdn specific enum look-up functions */ - -SNGISDN_ENUM_NAMES(SNGISDN_PROGIND_DESCR_NAMES, SNGISDN_PROGIND_DESCR_STRINGS) -SNGISDN_STR2ENUM(ftdm_str2ftdm_sngisdn_progind_descr, ftdm_sngisdn_progind_descr2str, ftdm_sngisdn_progind_descr_t, SNGISDN_PROGIND_DESCR_NAMES, SNGISDN_PROGIND_DESCR_INVALID) - -SNGISDN_ENUM_NAMES(SNGISDN_PROGIND_LOC_NAMES, SNGISDN_PROGIND_LOC_STRINGS) -SNGISDN_STR2ENUM(ftdm_str2ftdm_sngisdn_progind_loc, ftdm_sngisdn_progind_loc2str, ftdm_sngisdn_progind_loc_t, SNGISDN_PROGIND_LOC_NAMES, SNGISDN_PROGIND_LOC_INVALID) - -SNGISDN_ENUM_NAMES(SNGISDN_NETSPECFAC_TYPE_NAMES, SNGISDN_NETSPECFAC_TYPE_STRINGS) -SNGISDN_STR2ENUM(ftdm_str2ftdm_sngisdn_netspecfac_type, ftdm_sngisdn_netspecfac_type2str, ftdm_sngisdn_netspecfac_type_t, SNGISDN_NETSPECFAC_TYPE_NAMES, SNGISDN_NETSPECFAC_TYPE_INVALID) - -SNGISDN_ENUM_NAMES(SNGISDN_NETSPECFAC_PLAN_NAMES, SNGISDN_NETSPECFAC_PLAN_STRINGS) -SNGISDN_STR2ENUM(ftdm_str2ftdm_sngisdn_netspecfac_plan, ftdm_sngisdn_netspecfac_plan2str, ftdm_sngisdn_netspecfac_plan_t, SNGISDN_NETSPECFAC_PLAN_NAMES, SNGISDN_NETSPECFAC_PLAN_INVALID) - -SNGISDN_ENUM_NAMES(SNGISDN_NETSPECFAC_SPEC_NAMES, SNGISDN_NETSPECFAC_SPEC_STRINGS) -SNGISDN_STR2ENUM(ftdm_str2ftdm_sngisdn_netspecfac_spec, ftdm_sngisdn_netspecfac_spec2str, ftdm_sngisdn_netspecfac_spec_t, SNGISDN_NETSPECFAC_SPEC_NAMES, SNGISDN_NETSPECFAC_SPEC_INVALID) - -static uint8_t _get_trillium_val(ftdm2trillium_t *vals, unsigned int num_vals, uint8_t ftdm_val, uint8_t default_val); -static uint8_t _get_ftdm_val(ftdm2trillium_t *vals, unsigned int num_vals, uint8_t trillium_val, uint8_t default_val); - -#define get_trillium_val(vals, ftdm_val, default_val) _get_trillium_val(vals, ftdm_array_len(vals), ftdm_val, default_val) -#define get_ftdm_val(vals, trillium_val, default_val) _get_ftdm_val(vals, ftdm_array_len(vals), trillium_val, default_val) - -ftdm_status_t get_calling_name_from_usr_usr(ftdm_channel_t *ftdmchan, UsrUsr *usrUsr); -ftdm_status_t get_calling_name_from_display(ftdm_channel_t *ftdmchan, Display *display); -ftdm_status_t get_calling_name_from_ntDisplay(ftdm_channel_t *ftdmchan, NtDisplay *display); - -extern ftdm_sngisdn_data_t g_sngisdn_data; - -ftdm2trillium_t npi_codes[] = { - {FTDM_NPI_UNKNOWN, IN_NP_UNK}, - {FTDM_NPI_ISDN, IN_NP_ISDN}, - {FTDM_NPI_DATA, IN_NP_DATA}, - {FTDM_NPI_TELEX, IN_NP_TELEX}, - {FTDM_NPI_NATIONAL, IN_NP_NATIONAL}, - {FTDM_NPI_PRIVATE, IN_NP_PRIVATE}, - {FTDM_NPI_RESERVED, IN_NP_EXT}, -}; - -ftdm2trillium_t ton_codes[] = { - {FTDM_TON_UNKNOWN, IN_TON_UNK}, - {FTDM_TON_INTERNATIONAL, IN_TON_INT}, - {FTDM_TON_NATIONAL, IN_TON_NAT}, - {FTDM_TON_NETWORK_SPECIFIC, IN_TON_NETSPEC}, - {FTDM_TON_SUBSCRIBER_NUMBER, IN_TON_SUB}, - {FTDM_TON_ABBREVIATED_NUMBER, IN_TON_ABB}, - {FTDM_TON_RESERVED, IN_TON_EXT}, -}; - -ftdm2trillium_t nsf_spec_codes[] = { - {SNGISDN_NETSPECFAC_SPEC_ACCUNET, 0xe6}, - {SNGISDN_NETSPECFAC_SPEC_MEGACOM, 0xe3}, - {SNGISDN_NETSPECFAC_SPEC_MEGACOM_800, 0xe2}, - {SNGISDN_NETSPECFAC_SPEC_SDDN, 0xe1}, - {SNGISDN_NETSPECFAC_SPEC_INVALID, 0x00}, -}; - -ftdm2trillium_t nsf_type_codes[] = { - {SNGISDN_NETSPECFAC_TYPE_USER_SPEC, 0x00}, - {SNGISDN_NETSPECFAC_TYPE_NATIONAL_NETWORK_IDENT, 0x02}, - {SNGISDN_NETSPECFAC_TYPE_INTERNATIONAL_NETWORK_IDENT, 0x03}, - {SNGISDN_NETSPECFAC_TYPE_INVALID, 0x00}, -}; - -ftdm2trillium_t nsf_plan_codes[] = { - {SNGISDN_NETSPECFAC_PLAN_UNKNOWN, 0x00}, - {SNGISDN_NETSPECFAC_PLAN_CARRIER_IDENT, 0x01}, - {SNGISDN_NETSPECFAC_PLAN_DATA_NETWORK_IDENT, 0x03}, - {SNGISDN_NETSPECFAC_PLAN_INVALID, 0x00}, -}; - -static uint8_t _get_trillium_val(ftdm2trillium_t *vals, unsigned int num_vals, uint8_t ftdm_val, uint8_t default_val) -{ - int i; - for (i = 0; i < num_vals; i++) { - if (vals[i].ftdm_val == ftdm_val) { - return vals[i].trillium_val; - } - } - - return default_val; -} - -static uint8_t _get_ftdm_val(ftdm2trillium_t *vals, unsigned int num_vals, uint8_t trillium_val, uint8_t default_val) -{ - int i; - for (i = 0; i < num_vals; i++) { - if (vals[i].trillium_val == trillium_val) { - return vals[i].ftdm_val; - } - } - return default_val; -} - -void clear_call_data(sngisdn_chan_data_t *sngisdn_info) -{ - uint32_t cc_id = ((sngisdn_span_data_t*)sngisdn_info->ftdmchan->span->signal_data)->cc_id; - - ftdm_log_chan(sngisdn_info->ftdmchan, FTDM_LOG_DEBUG, "Clearing call data (suId:%u suInstId:%u spInstId:%u)\n", cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId); - ftdm_mutex_lock(g_sngisdn_data.ccs[cc_id].mutex); - g_sngisdn_data.ccs[cc_id].active_spInstIds[sngisdn_info->spInstId]=NULL; - g_sngisdn_data.ccs[cc_id].active_suInstIds[sngisdn_info->suInstId]=NULL; - - sngisdn_info->suInstId = 0; - sngisdn_info->spInstId = 0; - sngisdn_info->globalFlg = 0; - sngisdn_info->flags = 0; - sngisdn_info->transfer_data.type = SNGISDN_TRANSFER_NONE; - - ftdm_mutex_unlock(g_sngisdn_data.ccs[cc_id].mutex); - return; -} - -void clear_call_glare_data(sngisdn_chan_data_t *sngisdn_info) -{ - ftdm_log_chan(sngisdn_info->ftdmchan, FTDM_LOG_DEBUG, "Clearing glare data (suId:%d suInstId:%u spInstId:%u actv-suInstId:%u actv-spInstId:%u)\n", - sngisdn_info->glare.suId, - sngisdn_info->glare.suInstId, sngisdn_info->glare.spInstId, - sngisdn_info->suInstId, sngisdn_info->spInstId); - - ftdm_mutex_lock(g_sngisdn_data.ccs[sngisdn_info->glare.suId].mutex); - if (sngisdn_info->glare.spInstId != sngisdn_info->spInstId) { - g_sngisdn_data.ccs[sngisdn_info->glare.suId].active_spInstIds[sngisdn_info->glare.spInstId]=NULL; - } - g_sngisdn_data.ccs[sngisdn_info->glare.suId].active_suInstIds[sngisdn_info->glare.suInstId]=NULL; - ftdm_mutex_unlock(g_sngisdn_data.ccs[sngisdn_info->glare.suId].mutex); - - ftdm_clear_flag(sngisdn_info, FLAG_GLARE); - memset(&sngisdn_info->glare.setup, 0, sizeof(ConEvnt)); - sngisdn_info->glare.suId = 0; - sngisdn_info->glare.suInstId = 0; - sngisdn_info->glare.spInstId = 0; - sngisdn_info->glare.dChan = 0; - sngisdn_info->glare.ces = 0; - return; -} - - -uint32_t get_unique_suInstId(int16_t cc_id) -{ - uint32_t suInstId; - ftdm_assert_return((cc_id > 0 && cc_id <=MAX_VARIANTS), FTDM_FAIL, "Invalid cc_id\n"); - ftdm_mutex_lock(g_sngisdn_data.ccs[cc_id].mutex); - suInstId = g_sngisdn_data.ccs[cc_id].last_suInstId; - - while(1) { - if (++suInstId == MAX_INSTID) { - suInstId = 1; - } - if (g_sngisdn_data.ccs[cc_id].active_suInstIds[suInstId] == NULL) { - g_sngisdn_data.ccs[cc_id].last_suInstId = suInstId; - ftdm_mutex_unlock(g_sngisdn_data.ccs[cc_id].mutex); - return suInstId; - } - } - /* Should never reach here */ - ftdm_mutex_unlock(g_sngisdn_data.ccs[cc_id].mutex); - return 0; -} - -ftdm_status_t get_ftdmchan_by_suInstId(int16_t cc_id, uint32_t suInstId, sngisdn_chan_data_t **sngisdn_data) -{ - ftdm_assert_return((cc_id > 0 && cc_id <=MAX_VARIANTS), FTDM_FAIL, "Invalid cc_id\n"); - ftdm_assert_return(g_sngisdn_data.ccs[cc_id].activation_done, FTDM_FAIL, "Trying to find call on unconfigured CC\n"); - - if (g_sngisdn_data.ccs[cc_id].active_suInstIds[suInstId] == NULL) { - return FTDM_FAIL; - } - *sngisdn_data = g_sngisdn_data.ccs[cc_id].active_suInstIds[suInstId]; - return FTDM_SUCCESS; -} - -ftdm_status_t get_ftdmchan_by_spInstId(int16_t cc_id, uint32_t spInstId, sngisdn_chan_data_t **sngisdn_data) -{ - ftdm_assert_return((cc_id > 0 && cc_id <=MAX_VARIANTS), FTDM_FAIL, "Invalid cc_id\n"); - ftdm_assert_return(g_sngisdn_data.ccs[cc_id].activation_done, FTDM_FAIL, "Trying to find call on unconfigured CC\n"); - - if (g_sngisdn_data.ccs[cc_id].active_spInstIds[spInstId] == NULL) { - return FTDM_FAIL; - } - *sngisdn_data = g_sngisdn_data.ccs[cc_id].active_spInstIds[spInstId]; - return FTDM_SUCCESS; -} - -ftdm_status_t sngisdn_set_chan_avail_rate(ftdm_channel_t *chan, sngisdn_avail_t avail) -{ - if (FTDM_SPAN_IS_BRI(chan->span)) { - ftdm_log_chan(chan, FTDM_LOG_DEBUG, "Setting availability rate to:%d\n", avail); - chan->availability_rate = avail; - } - return FTDM_SUCCESS; -} - -ftdm_status_t sngisdn_set_span_avail_rate(ftdm_span_t *span, sngisdn_avail_t avail) -{ - if (FTDM_SPAN_IS_BRI(span)) { - ftdm_iterator_t *chaniter = NULL; - ftdm_iterator_t *curr = NULL; - - chaniter = ftdm_span_get_chan_iterator(span, NULL); - for (curr = chaniter; curr; curr = ftdm_iterator_next(curr)) { - ftdm_log_chan(((ftdm_channel_t*)ftdm_iterator_current(curr)), FTDM_LOG_DEBUG, "Setting availability rate to:%d\n", avail); - sngisdn_set_chan_avail_rate(((ftdm_channel_t*)ftdm_iterator_current(curr)), avail); - } - ftdm_iterator_free(chaniter); - } - return FTDM_SUCCESS; -} - -#ifdef NETBORDER_CALL_REF -ftdm_status_t get_callref(ftdm_channel_t *ftdmchan, BCCallRef* callRef) -{ - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; - sngisdn_chan_data_t *sngisdn_info = ftdmchan->call_data; - - if (signal_data->raw_trace_q931) { - if (callRef->eh.pres != PRSNT_NODEF || callRef->reference.pres != PRSNT_NODEF) { - /* Netborder only supports BRI, so we only care for BRI for now */ - if (FTDM_SPAN_IS_BRI(ftdmchan->span) && !sngisdn_info->call_ref) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "Failed to obtain call reference\n"); - } - return FTDM_FAIL; - } - if (FTDM_SPAN_IS_BRI(ftdmchan->span)) { - sngisdn_info->call_ref = 0x7F & callRef->reference.val; - } else { - sngisdn_info->call_ref = 0x7FFF & callRef->reference.val; - } - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Call reference:%04x\n", sngisdn_info->call_ref); - } - return FTDM_SUCCESS; -} -#endif - -ftdm_status_t get_calling_num(ftdm_channel_t *ftdmchan, CgPtyNmb *cgPtyNmb) -{ - ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; - if (cgPtyNmb->eh.pres != PRSNT_NODEF) { - return FTDM_FAIL; - } - - if (cgPtyNmb->screenInd.pres == PRSNT_NODEF) { - caller_data->screen = cgPtyNmb->screenInd.val; - } - - if (cgPtyNmb->presInd0.pres == PRSNT_NODEF) { - caller_data->pres = cgPtyNmb->presInd0.val; - } - - if (cgPtyNmb->nmbPlanId.pres == PRSNT_NODEF) { - caller_data->cid_num.plan = cgPtyNmb->nmbPlanId.val; - } - - if (cgPtyNmb->typeNmb1.pres == PRSNT_NODEF) { - caller_data->cid_num.type = cgPtyNmb->typeNmb1.val; - } - - if (cgPtyNmb->nmbDigits.pres == PRSNT_NODEF) { - ftdm_copy_string(caller_data->cid_num.digits, (const char*)cgPtyNmb->nmbDigits.val, cgPtyNmb->nmbDigits.len+1); - } - memcpy(&caller_data->ani, &caller_data->cid_num, sizeof(caller_data->ani)); - return FTDM_SUCCESS; -} - -ftdm_status_t get_calling_num2(ftdm_channel_t *ftdmchan, CgPtyNmb *cgPtyNmb) -{ - ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; - if (cgPtyNmb->eh.pres != PRSNT_NODEF) { - return FTDM_FAIL; - } - - if (cgPtyNmb->screenInd.pres == PRSNT_NODEF) { - sngisdn_add_var((sngisdn_chan_data_t*)ftdmchan->call_data, "isdn.cg_pty2.screen_ind", ftdm_screening2str(cgPtyNmb->screenInd.val)); - } - - if (cgPtyNmb->presInd0.pres == PRSNT_NODEF) { - sngisdn_add_var((sngisdn_chan_data_t*)ftdmchan->call_data, "isdn.cg_pty2.presentation_ind", ftdm_presentation2str(cgPtyNmb->presInd0.val)); - } - - if (cgPtyNmb->nmbPlanId.pres == PRSNT_NODEF) { - sngisdn_add_var((sngisdn_chan_data_t*)ftdmchan->call_data, "isdn.cg_pty2.npi", ftdm_npi2str(cgPtyNmb->nmbPlanId.val)); - } - - if (cgPtyNmb->typeNmb1.pres == PRSNT_NODEF) { - sngisdn_add_var((sngisdn_chan_data_t*)ftdmchan->call_data, "isdn.cg_pty2.ton", ftdm_ton2str(cgPtyNmb->typeNmb1.val)); - } - - if (cgPtyNmb->nmbDigits.pres == PRSNT_NODEF) { - char digits_string [32]; - memcpy(digits_string, (const char*)cgPtyNmb->nmbDigits.val, cgPtyNmb->nmbDigits.len); - digits_string[cgPtyNmb->nmbDigits.len] = '\0'; - sngisdn_add_var((sngisdn_chan_data_t*)ftdmchan->call_data, "isdn.cg_pty2.digits", digits_string); - } - memcpy(&caller_data->ani, &caller_data->cid_num, sizeof(caller_data->ani)); - return FTDM_SUCCESS; -} - -ftdm_status_t get_called_num(ftdm_channel_t *ftdmchan, CdPtyNmb *cdPtyNmb) -{ - ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; - - if (cdPtyNmb->eh.pres != PRSNT_NODEF) { - return FTDM_FAIL; - } - - if (cdPtyNmb->nmbPlanId.pres == PRSNT_NODEF) { - caller_data->dnis.plan = get_ftdm_val(npi_codes, cdPtyNmb->nmbPlanId.val, IN_NP_UNK); - } - - if (cdPtyNmb->typeNmb0.pres == PRSNT_NODEF) { - caller_data->dnis.type = get_ftdm_val(ton_codes, cdPtyNmb->typeNmb0.val, IN_TON_UNK); - } - - if (cdPtyNmb->nmbDigits.pres == PRSNT_NODEF) { - /* In overlap receive mode, append the new digits to the existing dnis */ - unsigned i = strlen(caller_data->dnis.digits); - - ftdm_copy_string(&caller_data->dnis.digits[i], (const char*)cdPtyNmb->nmbDigits.val, cdPtyNmb->nmbDigits.len+1); - } - return FTDM_SUCCESS; -} - -ftdm_status_t get_redir_num(ftdm_channel_t *ftdmchan, RedirNmb *redirNmb) -{ - ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; - if (redirNmb->eh.pres != PRSNT_NODEF) { - return FTDM_FAIL; - } - - if (redirNmb->nmbPlanId.pres == PRSNT_NODEF) { - caller_data->rdnis.plan = get_ftdm_val(npi_codes, redirNmb->nmbPlanId.val, IN_NP_UNK); - } - - if (redirNmb->typeNmb.pres == PRSNT_NODEF) { - caller_data->rdnis.type = get_ftdm_val(ton_codes, redirNmb->typeNmb.val, IN_TON_UNK); - } - - if (redirNmb->nmbDigits.pres == PRSNT_NODEF) { - ftdm_copy_string(caller_data->rdnis.digits, (const char*)redirNmb->nmbDigits.val, redirNmb->nmbDigits.len+1); - } - return FTDM_SUCCESS; -} - -ftdm_status_t get_calling_name_from_display(ftdm_channel_t *ftdmchan, Display *display) -{ - ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; - if (display->eh.pres != PRSNT_NODEF) { - return FTDM_FAIL; - } - if (display->dispInfo.pres != PRSNT_NODEF) { - return FTDM_FAIL; - } - - ftdm_copy_string(caller_data->cid_name, (const char*)display->dispInfo.val, display->dispInfo.len+1); - return FTDM_SUCCESS; -} - -ftdm_status_t get_calling_name_from_ntDisplay(ftdm_channel_t *ftdmchan, NtDisplay *display) -{ - ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; - if (display->eh.pres != PRSNT_NODEF) { - return FTDM_FAIL; - } - if (display->dispInfo.pres != PRSNT_NODEF) { - return FTDM_FAIL; - } - - ftdm_copy_string(caller_data->cid_name, (const char*)display->dispInfo.val, display->dispInfo.len+1); - return FTDM_SUCCESS; -} - -ftdm_status_t get_calling_name_from_usr_usr(ftdm_channel_t *ftdmchan, UsrUsr *usrUsr) -{ - ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; - if (usrUsr->eh.pres != PRSNT_NODEF) { - return FTDM_FAIL; - } - - if (usrUsr->protocolDisc.val != PD_IA5) { - return FTDM_FAIL; - } - - if (usrUsr->usrInfo.pres != PRSNT_NODEF) { - return FTDM_FAIL; - } - - ftdm_copy_string(caller_data->cid_name, (const char*)usrUsr->usrInfo.val, usrUsr->usrInfo.len+1); - return FTDM_SUCCESS; -} - -ftdm_status_t get_calling_name(ftdm_channel_t *ftdmchan, ConEvnt *conEvnt) -{ - ftdm_status_t status = FTDM_FAIL; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; - - if (signal_data->switchtype == SNGISDN_SWITCH_DMS100) { - status = get_calling_name_from_ntDisplay(ftdmchan, &conEvnt->ntDisplay[0]); - } else { - status = get_calling_name_from_display(ftdmchan, &conEvnt->display); - - } - if (status != FTDM_SUCCESS) { - status = get_calling_name_from_usr_usr(ftdmchan, &conEvnt->usrUsr); - } - return status; -} - - -ftdm_status_t get_calling_subaddr(ftdm_channel_t *ftdmchan, CgPtySad *cgPtySad) -{ - char subaddress[100]; - - if (cgPtySad->eh.pres != PRSNT_NODEF) { - return FTDM_FAIL; - } - memset(subaddress, 0, sizeof(subaddress)); - if(cgPtySad->sadInfo.len >= sizeof(subaddress)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Calling Party Subaddress exceeds local size limit (len:%d max:%"FTDM_SIZE_FMT")\n", cgPtySad->sadInfo.len, sizeof(subaddress)); - cgPtySad->sadInfo.len = sizeof(subaddress)-1; - } - - memcpy(subaddress, (char*)cgPtySad->sadInfo.val, cgPtySad->sadInfo.len); - subaddress[cgPtySad->sadInfo.len] = '\0'; - sngisdn_add_var((sngisdn_chan_data_t*)ftdmchan->call_data, "isdn.calling_subaddr", subaddress); - return FTDM_SUCCESS; -} - -ftdm_status_t get_facility_ie(ftdm_channel_t *ftdmchan, FacilityStr *facilityStr) -{ - if (!facilityStr->eh.pres) { - return FTDM_FAIL; - } - - return get_facility_ie_str(ftdmchan, facilityStr->facilityStr.val, facilityStr->facilityStr.len); -} - -ftdm_status_t get_facility_ie_str(ftdm_channel_t *ftdmchan, uint8_t *data, uint8_t data_len) -{ - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; - - if (signal_data->facility_ie_decode == SNGISDN_OPT_FALSE) { - /* Max size of Facility IE is 255 */ - uint8_t my_data [255]; - - /* Always include Facility IE identifier + len so this can be used as a sanity check by the user */ - my_data[0] = SNGISDN_Q931_FACILITY_IE_ID; - my_data[1] = data_len; - memcpy(&my_data[2], data, data_len); - - sngisdn_add_raw_data((sngisdn_chan_data_t*)ftdmchan->call_data, my_data, data_len+2); - - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Raw Facility IE copied available\n"); - } else { - /* Call libsng_isdn to process facility IE's here */ - } - return FTDM_SUCCESS; -} - -ftdm_status_t get_prog_ind_ie(ftdm_channel_t *ftdmchan, ProgInd *progInd) -{ - uint8_t val; - - if (!progInd->eh.pres) { - return FTDM_FAIL; - } - - if (progInd->progDesc.pres) { - /* TODO: use get_ftdm_val function and table here */ - switch (progInd->progDesc.val) { - case IN_PD_NOTETEISDN: - val = SNGISDN_PROGIND_DESCR_NETE_ISDN; - break; - case IN_PD_DSTNOTISDN: - val = SNGISDN_PROGIND_DESCR_DEST_NISDN; - break; - case IN_PD_ORGNOTISDN: - val = SNGISDN_PROGIND_DESCR_ORIG_NISDN; - break; - case IN_PD_CALLRET: - val = SNGISDN_PROGIND_DESCR_RET_ISDN; - break; - case IN_PD_DELRESP: - val = SNGISDN_PROGIND_DESCR_SERV_CHANGE; - break; - case IN_PD_IBAVAIL: - val = SNGISDN_PROGIND_DESCR_IB_AVAIL; - break; - default: - ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Unknown Progress Indicator Description (%d)\n", progInd->progDesc.val); - val = SNGISDN_PROGIND_DESCR_INVALID; - break; - } - sngisdn_add_var((sngisdn_chan_data_t*)ftdmchan->call_data, "isdn.prog_ind.descr", ftdm_sngisdn_progind_descr2str(val)); - } - - if (progInd->location.pres) { - switch (progInd->location.val) { - case IN_LOC_USER: - val = SNGISDN_PROGIND_LOC_USER; - break; - case IN_LOC_PRIVNETLU: - val = SNGISDN_PROGIND_LOC_PRIV_NET_LOCAL_USR; - break; - case IN_LOC_PUBNETLU: - val = SNGISDN_PROGIND_LOC_PUB_NET_LOCAL_USR; - break; - case IN_LOC_TRANNET: - val = SNGISDN_PROGIND_LOC_TRANSIT_NET; - break; - case IN_LOC_PUBNETRU: - val = SNGISDN_PROGIND_LOC_PUB_NET_REMOTE_USR; - break; - case IN_LOC_PRIVNETRU: - val = SNGISDN_PROGIND_LOC_PRIV_NET_REMOTE_USR; - break; - case IN_LOC_NETINTER: - val = SNGISDN_PROGIND_LOC_NET_BEYOND_INTRW; - break; - default: - ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Unknown Progress Indicator Location (%d)", progInd->location.val); - val = SNGISDN_PROGIND_LOC_INVALID; - break; - } - sngisdn_add_var((sngisdn_chan_data_t*)ftdmchan->call_data, "isdn.prog_ind.loc", ftdm_sngisdn_progind_loc2str(val)); - } - return FTDM_SUCCESS; -} - - -ftdm_status_t get_network_specific_fac(ftdm_channel_t *ftdmchan, NetFac *netFac) -{ - if (!netFac->eh.pres) { - return FTDM_FAIL; - } - - if (netFac->netFacSpec.pres == PRSNT_NODEF) { - char digits_string [32]; - memcpy(digits_string, (const char*)netFac->netFacSpec.val, netFac->netFacSpec.len); - digits_string[netFac->netFacSpec.len] = '\0'; - sngisdn_add_var((sngisdn_chan_data_t*)ftdmchan->call_data, "isdn.netFac.spec", digits_string); - } - - if (netFac->typeNetId.pres == PRSNT_NODEF) { - sngisdn_add_var((sngisdn_chan_data_t*)ftdmchan->call_data, "isdn.netFac.type", ftdm_sngisdn_netspecfac_type2str(get_ftdm_val(nsf_type_codes, netFac->typeNetId.val, 0x00))); - } - - if (netFac->netIdPlan.pres == PRSNT_NODEF) { - sngisdn_add_var((sngisdn_chan_data_t*)ftdmchan->call_data, "isdn.netFac.plan", ftdm_sngisdn_netspecfac_type2str(get_ftdm_val(nsf_plan_codes, netFac->netIdPlan.val, 0x00))); - } - return FTDM_SUCCESS; -} - -ftdm_status_t set_calling_num(ftdm_channel_t *ftdmchan, CgPtyNmb *cgPtyNmb) -{ - ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; - uint8_t len = strlen(caller_data->cid_num.digits); - if (!len) { - return FTDM_SUCCESS; - } - - if (!strncasecmp(caller_data->cid_num.digits, "0000000000", strlen("0000000000"))) { - return FTDM_SUCCESS; - } - - cgPtyNmb->eh.pres = PRSNT_NODEF; - - cgPtyNmb->screenInd.pres = PRSNT_NODEF; - cgPtyNmb->screenInd.val = caller_data->screen; - - cgPtyNmb->presInd0.pres = PRSNT_NODEF; - cgPtyNmb->presInd0.val = caller_data->pres; - - cgPtyNmb->nmbPlanId.pres = PRSNT_NODEF; - cgPtyNmb->nmbPlanId.val = get_trillium_val(npi_codes, caller_data->cid_num.plan, IN_NP_UNK); - - cgPtyNmb->typeNmb1.pres = PRSNT_NODEF; - - cgPtyNmb->typeNmb1.val = get_trillium_val(ton_codes, caller_data->cid_num.type, IN_TON_UNK); - - cgPtyNmb->nmbDigits.pres = PRSNT_NODEF; - cgPtyNmb->nmbDigits.len = len; - - memcpy(cgPtyNmb->nmbDigits.val, caller_data->cid_num.digits, len); - - return FTDM_SUCCESS; -} - -ftdm_status_t set_calling_num2(ftdm_channel_t *ftdmchan, CgPtyNmb *cgPtyNmb) -{ - const char* string = NULL; - uint8_t len,val; - ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; - - string = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "isdn.cg_pty2.digits"); - if (ftdm_strlen_zero(string)) { - return FTDM_FAIL; - } - - cgPtyNmb->eh.pres = PRSNT_NODEF; - - len = strlen(string); - cgPtyNmb->nmbDigits.len = len; - - cgPtyNmb->nmbDigits.pres = PRSNT_NODEF; - memcpy(cgPtyNmb->nmbDigits.val, string, len); - - /* Screening Indicator */ - cgPtyNmb->screenInd.pres = PRSNT_NODEF; - - val = FTDM_SCREENING_INVALID; - string = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "isdn.cg_pty2.screening_ind"); - if (!ftdm_strlen_zero(string)) { - val = ftdm_str2ftdm_screening(string); - } - - /* isdn.cg_pty2.screen_ind does not exist or we could not parse its value */ - if (val == FTDM_SCREENING_INVALID) { - /* default to caller data screening ind */ - cgPtyNmb->screenInd.val = caller_data->screen; - } else { - cgPtyNmb->screenInd.val = val; - } - - /* Presentation Indicator */ - cgPtyNmb->presInd0.pres = PRSNT_NODEF; - - val = FTDM_PRES_INVALID; - string = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "isdn.cg_pty2.presentation_ind"); - if (!ftdm_strlen_zero(string)) { - val = ftdm_str2ftdm_presentation(string); - } - - if (val == FTDM_PRES_INVALID) { - cgPtyNmb->presInd0.val = caller_data->pres; - } else { - cgPtyNmb->presInd0.val = val; - } - - /* Numbering Plan Indicator */ - cgPtyNmb->nmbPlanId.pres = PRSNT_NODEF; - - val = FTDM_NPI_INVALID; - string = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "isdn.cg_pty2.npi"); - if (!ftdm_strlen_zero(string)) { - val = ftdm_str2ftdm_npi(string); - } - - if (val == FTDM_NPI_INVALID) { - cgPtyNmb->nmbPlanId.val = caller_data->cid_num.plan; - } else { - cgPtyNmb->nmbPlanId.val = get_trillium_val(npi_codes, val, IN_NP_UNK); - } - - cgPtyNmb->typeNmb1.pres = PRSNT_NODEF; - - /* Type of Number */ - val = FTDM_TON_INVALID; - string = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "isdn.cg_pty2.ton"); - if (!ftdm_strlen_zero(string)) { - val = ftdm_str2ftdm_ton(string); - } - - if (val == FTDM_TON_INVALID) { - cgPtyNmb->typeNmb1.val = caller_data->cid_num.type; - } else { - cgPtyNmb->typeNmb1.val = get_trillium_val(ton_codes, val, IN_TON_UNK); - } - return FTDM_SUCCESS; -} - -ftdm_status_t set_called_num(ftdm_channel_t *ftdmchan, CdPtyNmb *cdPtyNmb) -{ - ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; - uint8_t len = strlen(caller_data->dnis.digits); - - if (!len) { - return FTDM_SUCCESS; - } - - cdPtyNmb->eh.pres = PRSNT_NODEF; - - cdPtyNmb->nmbPlanId.pres = PRSNT_NODEF; - cdPtyNmb->nmbPlanId.val = get_trillium_val(npi_codes, caller_data->dnis.plan, IN_NP_UNK); - - cdPtyNmb->typeNmb0.pres = PRSNT_NODEF; - cdPtyNmb->typeNmb0.val = get_trillium_val(ton_codes, caller_data->dnis.type, IN_TON_UNK); - - cdPtyNmb->nmbDigits.pres = PRSNT_NODEF; - cdPtyNmb->nmbDigits.len = len; - - - memcpy(cdPtyNmb->nmbDigits.val, caller_data->dnis.digits, len); - return FTDM_SUCCESS; -} - -ftdm_status_t set_redir_num(ftdm_channel_t *ftdmchan, RedirNmb *redirNmb) -{ - ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; - uint8_t len = strlen(caller_data->rdnis.digits); - if (!len) { - return FTDM_SUCCESS; - } - - redirNmb->eh.pres = PRSNT_NODEF; - - redirNmb->nmbPlanId.pres = PRSNT_NODEF; - redirNmb->nmbPlanId.val = get_trillium_val(npi_codes, caller_data->rdnis.plan, IN_NP_UNK); - - redirNmb->typeNmb.pres = PRSNT_NODEF; - redirNmb->typeNmb.val = get_trillium_val(ton_codes, caller_data->rdnis.type, IN_TON_UNK); - - redirNmb->nmbDigits.pres = PRSNT_NODEF; - redirNmb->nmbDigits.len = len; - - memcpy(redirNmb->nmbDigits.val, caller_data->rdnis.digits, len); - - return FTDM_SUCCESS; -} - - -ftdm_status_t set_calling_name(ftdm_channel_t *ftdmchan, ConEvnt *conEvnt) -{ - uint8_t len; - const char *string = NULL; - ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; - ftdm_bool_t force_send_cid_name = FTDM_FALSE; - - len = strlen(caller_data->cid_name); - if (!len) { - return FTDM_SUCCESS; - } - - string = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "isdn.send_cid_name"); - if (!ftdm_strlen_zero(string)) { - if (!strcasecmp(string, "no")) { - return FTDM_SUCCESS; - } else if (!strcasecmp(string, "yes")) { - force_send_cid_name = FTDM_TRUE; - } - } - - if (force_send_cid_name == FTDM_FALSE && signal_data->send_cid_name == SNGISDN_OPT_FALSE) { - return FTDM_SUCCESS; - } - - switch(signal_data->cid_name_method) { - case SNGISDN_CID_NAME_FACILITY_IE: -#ifdef SNGISDN_SUPPORT_CALLING_NAME_IN_FACILITY - /* Note: The Facility IE will be overwritten if user chose to transmit a Raw Facility IE */ - sng_isdn_encode_facility_caller_name(caller_data->cid_name, conEvnt->facilityStr.facilityStr.val, &conEvnt->facilityStr.facilityStr.len); - conEvnt->facilityStr.eh.pres = PRSNT_NODEF; - conEvnt->facilityStr.facilityStr.pres = PRSNT_NODEF; -#endif - break; - case SNGISDN_CID_NAME_USR_USR_IE: - conEvnt->usrUsr.eh.pres = PRSNT_NODEF; - conEvnt->usrUsr.protocolDisc.pres = PRSNT_NODEF; - conEvnt->usrUsr.protocolDisc.val = PD_IA5; /* IA5 chars */ - conEvnt->usrUsr.usrInfo.pres = PRSNT_NODEF; - conEvnt->usrUsr.usrInfo.len = len; - /* in sangoma_brid we used to send usr-usr info as !, - change to previous style if current one does not work */ - memcpy(conEvnt->usrUsr.usrInfo.val, caller_data->cid_name, len); - break; - case SNGISDN_CID_NAME_DISPLAY_IE: - if (signal_data->switchtype == SNGISDN_SWITCH_DMS100) { - conEvnt->ntDisplay[0].eh.pres = PRSNT_NODEF; - conEvnt->ntDisplay[0].dispTypeNt.pres = PRSNT_NODEF; - conEvnt->ntDisplay[0].dispTypeNt.val = 0x01; /* Calling Party Name */ - conEvnt->ntDisplay[0].assocInfo.pres = PRSNT_NODEF; - conEvnt->ntDisplay[0].assocInfo.val = 0x03; /* Included */ - conEvnt->ntDisplay[0].eh.pres = PRSNT_NODEF; - conEvnt->ntDisplay[0].eh.pres = PRSNT_NODEF; - conEvnt->ntDisplay[0].dispInfo.pres = PRSNT_NODEF; - conEvnt->ntDisplay[0].dispInfo.len = len; - memcpy(conEvnt->ntDisplay[0].dispInfo.val, caller_data->cid_name, len); - } else { - conEvnt->display.eh.pres = PRSNT_NODEF; - conEvnt->display.dispInfo.pres = PRSNT_NODEF; - conEvnt->display.dispInfo.len = len; - memcpy(conEvnt->display.dispInfo.val, caller_data->cid_name, len); - } - break; - default: - break; - } - - return FTDM_SUCCESS; -} - -ftdm_status_t set_calling_subaddr(ftdm_channel_t *ftdmchan, CgPtySad *cgPtySad) -{ - const char* clg_subaddr = NULL; - clg_subaddr = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "isdn.calling_subaddr"); - if (!ftdm_strlen_zero(clg_subaddr)) { - unsigned len = strlen (clg_subaddr); - cgPtySad->eh.pres = PRSNT_NODEF; - cgPtySad->typeSad.pres = 1; - cgPtySad->typeSad.val = 0; /* NSAP */ - cgPtySad->oddEvenInd.pres = 1; - cgPtySad->oddEvenInd.val = 0; - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Sending Calling Party Subaddress:%s\n", clg_subaddr); - cgPtySad->sadInfo.pres = 1; - cgPtySad->sadInfo.len = len; - memcpy(cgPtySad->sadInfo.val, clg_subaddr, len); - } - return FTDM_SUCCESS; -} - -ftdm_status_t set_called_subaddr(ftdm_channel_t *ftdmchan, CdPtySad *cdPtySad) -{ - const char* cld_subaddr = NULL; - cld_subaddr = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "isdn.called_subaddr"); - if (!ftdm_strlen_zero(cld_subaddr)) { - unsigned len = strlen (cld_subaddr); - cdPtySad->eh.pres = PRSNT_NODEF; - cdPtySad->typeSad.pres = 1; - cdPtySad->typeSad.val = 0; /* NSAP */ - cdPtySad->oddEvenInd.pres = 1; - cdPtySad->oddEvenInd.val = 0; - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Sending Called Party Subaddress:%s\n", cld_subaddr); - cdPtySad->sadInfo.pres = 1; - cdPtySad->sadInfo.len = len; - memcpy(cdPtySad->sadInfo.val, cld_subaddr, len); - } - return FTDM_SUCCESS; -} - -ftdm_status_t set_facility_ie(ftdm_channel_t *ftdmchan, FacilityStr *facilityStr) -{ - ftdm_status_t status; - status = set_facility_ie_str(ftdmchan, facilityStr->facilityStr.val, (uint8_t*)&(facilityStr->facilityStr.len)); - if (status == FTDM_SUCCESS) { - facilityStr->eh.pres = PRSNT_NODEF; - facilityStr->facilityStr.pres = PRSNT_NODEF; - } - return status; -} - -ftdm_status_t set_facility_ie_str(ftdm_channel_t *ftdmchan, uint8_t *data, uint8_t *data_len) -{ - ftdm_size_t len; - uint8_t *mydata; - void *vdata; - - if (ftdm_usrmsg_get_raw_data(ftdmchan->usrmsg, &vdata, &len) == FTDM_SUCCESS) { - mydata = vdata; - if (len > 2 && mydata[0] == SNGISDN_Q931_FACILITY_IE_ID) { - len = mydata[1]; - memcpy(data, &mydata[2], len); - *data_len = len; - return FTDM_SUCCESS; - } - } - return FTDM_FAIL; -} - -ftdm_status_t set_prog_ind_ie(ftdm_channel_t *ftdmchan, ProgInd *progInd, ftdm_sngisdn_progind_t prog_ind) -{ - const char *str = NULL; - int descr = prog_ind.descr; - int loc = prog_ind.loc; - - str = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "isdn.prog_ind.descr"); - if (!ftdm_strlen_zero(str)) { - /* User wants to override progress indicator */ - descr = ftdm_str2ftdm_sngisdn_progind_descr(str); - } - - if (descr == SNGISDN_PROGIND_DESCR_INVALID) { - /* User does not want to send progress indicator */ - return FTDM_SUCCESS; - } - - str = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "isdn.prog_ind.loc"); - if (!ftdm_strlen_zero(str)) { - loc = ftdm_str2ftdm_sngisdn_progind_loc(str); - } - if (loc == SNGISDN_PROGIND_LOC_INVALID) { - loc = SNGISDN_PROGIND_LOC_USER; - } - - progInd->eh.pres = PRSNT_NODEF; - progInd->codeStand0.pres = PRSNT_NODEF; - progInd->codeStand0.val = IN_CSTD_CCITT; - - progInd->progDesc.pres = PRSNT_NODEF; - switch(descr) { - case SNGISDN_PROGIND_DESCR_NETE_ISDN: - progInd->progDesc.val = IN_PD_NOTETEISDN; - break; - case SNGISDN_PROGIND_DESCR_DEST_NISDN: - progInd->progDesc.val = IN_PD_DSTNOTISDN; - break; - case SNGISDN_PROGIND_DESCR_ORIG_NISDN: - progInd->progDesc.val = IN_PD_ORGNOTISDN; - break; - case SNGISDN_PROGIND_DESCR_RET_ISDN: - progInd->progDesc.val = IN_PD_CALLRET; - break; - case SNGISDN_PROGIND_DESCR_SERV_CHANGE: - /* Trillium defines do not match ITU-T Q931 Progress descriptions, - indicate a delayed response for now */ - progInd->progDesc.val = IN_PD_DELRESP; - break; - case SNGISDN_PROGIND_DESCR_IB_AVAIL: - progInd->progDesc.val = IN_PD_IBAVAIL; - break; - default: - ftdm_log(FTDM_LOG_WARNING, "Invalid prog_ind description:%d\n", descr); - progInd->progDesc.val = IN_PD_NOTETEISDN; - break; - } - - progInd->location.pres = PRSNT_NODEF; - switch (loc) { - case SNGISDN_PROGIND_LOC_USER: - progInd->location.val = IN_LOC_USER; - break; - case SNGISDN_PROGIND_LOC_PRIV_NET_LOCAL_USR: - progInd->location.val = IN_LOC_PRIVNETLU; - break; - case SNGISDN_PROGIND_LOC_PUB_NET_LOCAL_USR: - progInd->location.val = IN_LOC_PUBNETLU; - break; - case SNGISDN_PROGIND_LOC_TRANSIT_NET: - progInd->location.val = IN_LOC_TRANNET; - break; - case SNGISDN_PROGIND_LOC_PUB_NET_REMOTE_USR: - progInd->location.val = IN_LOC_PUBNETRU; - break; - case SNGISDN_PROGIND_LOC_PRIV_NET_REMOTE_USR: - progInd->location.val = IN_LOC_PRIVNETRU; - break; - case SNGISDN_PROGIND_LOC_NET_BEYOND_INTRW: - progInd->location.val = IN_LOC_NETINTER; - break; - default: - ftdm_log(FTDM_LOG_WARNING, "Invalid prog_ind location:%d\n", loc); - progInd->location.val = IN_LOC_USER; - } - return FTDM_SUCCESS; -} - -ftdm_status_t set_network_specific_fac(ftdm_channel_t *ftdmchan, NetFac *netFac) -{ - const char *str = NULL; - - str = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "isdn.netFac.spec"); - if (ftdm_strlen_zero(str)) { - /* Network-specific facility specification is mandatory, cannot send IE - without it */ - return FTDM_SUCCESS; - } else { - ftdm_sngisdn_netspecfac_spec_t spec = ftdm_str2ftdm_sngisdn_netspecfac_spec(str); - - netFac->eh.pres = PRSNT_NODEF; - netFac->netFacSpec.pres = PRSNT_NODEF; - - if (spec == SNGISDN_NETSPECFAC_SPEC_INVALID) { - int byte = 0; - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Non-standard NSF specified:%s\n", str); - - if (sscanf(str, "%x", &byte) == 1) { - netFac->netFacSpec.val[0] = byte & 0xFF; - } - - netFac->netFacSpec.len = 1; - } else { - /* User is using one of the pre-specified NSF's */ - netFac->netFacSpec.val[0] = get_trillium_val(nsf_spec_codes, spec, 0x00); - netFac->netFacSpec.len = 1; - } - } - - netFac->lenNetId.pres = PRSNT_NODEF; - netFac->lenNetId.val = 0; - - str = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "isdn.netFac.type"); - if (!ftdm_strlen_zero(str)) { - netFac->typeNetId.pres = PRSNT_NODEF; - netFac->typeNetId.val = ftdm_str2ftdm_sngisdn_netspecfac_type(str); - } - - str = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "isdn.netFac.plan"); - if (!ftdm_strlen_zero(str)) { - netFac->netIdPlan.pres = PRSNT_NODEF; - netFac->netIdPlan.val = ftdm_str2ftdm_sngisdn_netspecfac_plan(str); - } - - if (netFac->netIdPlan.pres == PRSNT_NODEF || netFac->typeNetId.pres == PRSNT_NODEF) { - netFac->lenNetId.val++; - } - - str = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "isdn.netFac.ident"); - if (!ftdm_strlen_zero(str)) { - netFac->lenNetId.val++; - - netFac->netId.pres = PRSNT_NODEF; - memcpy(netFac->netId.val, str, strlen(str)); - } - - return FTDM_SUCCESS; -} - -ftdm_status_t set_user_to_user_ie(ftdm_channel_t *ftdmchan, UsrUsr *usrUsr) -{ - sngisdn_chan_data_t *sngisdn_info = ftdmchan->call_data; - - if (sngisdn_info->transfer_data.type == SNGISDN_TRANSFER_ATT_COURTESY_VRU_DATA) { - usrUsr->eh.pres = PRSNT_NODEF; - - usrUsr->protocolDisc.pres = PRSNT_NODEF; - usrUsr->protocolDisc.val = 0x08; - usrUsr->usrInfo.pres = PRSNT_NODEF; - usrUsr->usrInfo.len = strlen(sngisdn_info->transfer_data.tdata.att_courtesy_vru.data); - memcpy(usrUsr->usrInfo.val, sngisdn_info->transfer_data.tdata.att_courtesy_vru.data, usrUsr->usrInfo.len); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Sending AT&T Transfer data len:%d\n", usrUsr->usrInfo.len); - - return FTDM_SUCCESS; - } - - return FTDM_SUCCESS; -} - -ftdm_status_t set_cause_ie(ftdm_channel_t *ftdmchan, CauseDgn *causeDgn) -{ - - causeDgn->eh.pres = PRSNT_NODEF; - causeDgn->location.pres = PRSNT_NODEF; - causeDgn->location.val = IN_LOC_PRIVNETLU; - causeDgn->codeStand3.pres = PRSNT_NODEF; - causeDgn->codeStand3.val = IN_CSTD_CCITT; - causeDgn->causeVal.pres = PRSNT_NODEF; - causeDgn->causeVal.val = ftdmchan->caller_data.hangup_cause; - causeDgn->recommend.pres = NOTPRSNT; - causeDgn->dgnVal.pres = NOTPRSNT; - return FTDM_SUCCESS; -} - -ftdm_status_t set_chan_id_ie(ftdm_channel_t *ftdmchan, ChanId *chanId) -{ - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; - sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*)ftdmchan->call_data; - if (!ftdmchan) { - return FTDM_SUCCESS; - } - - ftdm_set_flag(sngisdn_info, FLAG_SENT_CHAN_ID); - - chanId->eh.pres = PRSNT_NODEF; - chanId->prefExc.pres = PRSNT_NODEF; - chanId->prefExc.val = IN_PE_EXCLSVE; - chanId->dChanInd.pres = PRSNT_NODEF; - chanId->dChanInd.val = IN_DSI_NOTDCHAN; - chanId->intIdentPres.pres = PRSNT_NODEF; - chanId->intIdentPres.val = IN_IIP_IMPLICIT; - - if (FTDM_SPAN_IS_BRI(ftdmchan->span)) { - - /* BRI only params */ - chanId->intType.pres = PRSNT_NODEF; - chanId->intType.val = IN_IT_BASIC; - chanId->infoChanSel.pres = PRSNT_NODEF; - chanId->infoChanSel.val = ftdmchan->physical_chan_id; - } else { - if (signal_data->nfas.trunk) { - chanId->intIdentPres.val = IN_IIP_EXPLICIT; - chanId->intIdent.pres = PRSNT_NODEF; - chanId->intIdent.val = signal_data->nfas.interface_id; - } - - chanId->intType.pres = PRSNT_NODEF; - chanId->intType.val = IN_IT_OTHER; - chanId->infoChanSel.pres = PRSNT_NODEF; - chanId->infoChanSel.val = IN_ICS_B1CHAN; - chanId->chanMapType.pres = PRSNT_NODEF; - chanId->chanMapType.val = IN_CMT_BCHAN; - chanId->nmbMap.pres = PRSNT_NODEF; - chanId->nmbMap.val = IN_NM_CHNNMB; - chanId->codeStand1.pres = PRSNT_NODEF; - chanId->codeStand1.val = IN_CSTD_CCITT; - chanId->chanNmbSlotMap.pres = PRSNT_NODEF; - chanId->chanNmbSlotMap.len = 1; - chanId->chanNmbSlotMap.val[0] = ftdmchan->physical_chan_id; - } - - return FTDM_SUCCESS; -} - -ftdm_status_t set_bear_cap_ie(ftdm_channel_t *ftdmchan, BearCap *bearCap) -{ - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; - - bearCap->eh.pres = PRSNT_NODEF; - bearCap->infoTranCap.pres = PRSNT_NODEF; - bearCap->infoTranCap.val = sngisdn_get_infoTranCap_from_user(ftdmchan->caller_data.bearer_capability); - - bearCap->codeStand0.pres = PRSNT_NODEF; - bearCap->codeStand0.val = IN_CSTD_CCITT; - bearCap->infoTranRate0.pres = PRSNT_NODEF; - bearCap->infoTranRate0.val = IN_ITR_64KBIT; - bearCap->tranMode.pres = PRSNT_NODEF; - bearCap->tranMode.val = IN_TM_CIRCUIT; - - bearCap->usrInfoLyr1Prot.pres = PRSNT_NODEF; - bearCap->usrInfoLyr1Prot.val = sngisdn_get_usrInfoLyr1Prot_from_user(ftdmchan->caller_data.bearer_layer1); - - switch (signal_data->switchtype) { - case SNGISDN_SWITCH_NI2: - case SNGISDN_SWITCH_4ESS: - case SNGISDN_SWITCH_5ESS: - case SNGISDN_SWITCH_DMS100: - case SNGISDN_SWITCH_INSNET: - if (bearCap->usrInfoLyr1Prot.val == IN_UIL1_G711ALAW) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Overriding bearer cap to u-law\n"); - bearCap->usrInfoLyr1Prot.val = IN_UIL1_G711ULAW; - } - break; - case SNGISDN_SWITCH_EUROISDN: - case SNGISDN_SWITCH_QSIG: - if (bearCap->usrInfoLyr1Prot.val == IN_UIL1_G711ULAW) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Overriding bearer cap to a-law\n"); - bearCap->usrInfoLyr1Prot.val = IN_UIL1_G711ALAW; - } - break; - } - - bearCap->lyr1Ident.pres = PRSNT_NODEF; - bearCap->lyr1Ident.val = IN_L1_IDENT; - - return FTDM_SUCCESS; -} - -ftdm_status_t set_restart_ind_ie(ftdm_channel_t *ftdmchan, RstInd *rstInd) -{ - rstInd->eh.pres = PRSNT_NODEF; - rstInd->rstClass.pres = PRSNT_NODEF; - rstInd->rstClass.val = IN_CL_INDCHAN; - return FTDM_SUCCESS; -} - -ftdm_status_t set_not_ind_ie(ftdm_channel_t *ftdmchan, NotInd *notInd) -{ - notInd->eh.pres = PRSNT_NODEF; - notInd->notDesc.pres = PRSNT_NODEF; - notInd->notDesc.val = 0x71; /* Call information event */ - return FTDM_SUCCESS; -} - -void sngisdn_t3_timeout(void *p_sngisdn_info) -{ - sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*)p_sngisdn_info; - ftdm_channel_t *ftdmchan = sngisdn_info->ftdmchan; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Timer T3 expired (suId:%d suInstId:%u spInstId:%u)\n", - signal_data->cc_id, sngisdn_info->glare.spInstId, sngisdn_info->glare.suInstId); - ftdm_mutex_lock(ftdmchan->mutex); - if (ftdm_test_flag(sngisdn_info, FLAG_ACTIVATING)){ - /* PHY layer timed-out, need to clear the call */ - ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Failed to Wake-Up line (suId:%d suInstId:%u spInstId:%u)\n", - signal_data->cc_id, sngisdn_info->glare.spInstId, sngisdn_info->glare.suInstId); - - ftdmchan->caller_data.hangup_cause = FTDM_CAUSE_NO_ROUTE_DESTINATION; - ftdm_clear_flag(sngisdn_info, FLAG_ACTIVATING); - ftdm_set_flag(sngisdn_info, FLAG_LOCAL_ABORT); - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); - } - ftdm_mutex_unlock(ftdmchan->mutex); -} - - -void sngisdn_delayed_dl_req(void *p_signal_data) -{ - ftdm_signaling_status_t sigstatus = FTDM_SIG_STATE_DOWN; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t *)p_signal_data; - ftdm_span_t *span = signal_data->ftdm_span; - - if (!signal_data->dl_request_pending) { - return; - } - - ftdm_span_get_sig_status(span, &sigstatus); - if (sigstatus == FTDM_SIG_STATE_UP) { - signal_data->dl_request_pending = 0; - return; - } - - sngisdn_snd_dl_req(span->channels[1]); - ftdm_sched_timer(signal_data->sched, "delayed_dl_req", 4000, sngisdn_delayed_dl_req, (void*) signal_data, NULL); - - return; -} - -void sngisdn_restart_timeout(void *p_signal_data) -{ - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t *)p_signal_data; - ftdm_span_t *span = signal_data->ftdm_span; - ftdm_iterator_t *chaniter = NULL; - ftdm_iterator_t *curr = NULL; - - ftdm_log(FTDM_LOG_DEBUG, "s%s:Did not receive a RESTART from remote switch in %d ms - restarting\n", span->name, signal_data->restart_timeout); - - chaniter = ftdm_span_get_chan_iterator(span, NULL); - for (curr = chaniter; curr; curr = ftdm_iterator_next(curr)) { - ftdm_channel_t *ftdmchan = (ftdm_channel_t*)ftdm_iterator_current(curr); - if (FTDM_IS_VOICE_CHANNEL(ftdmchan)) { - ftdm_mutex_lock(ftdmchan->mutex); - if (ftdmchan->state == FTDM_CHANNEL_STATE_DOWN) { - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RESET); - } - ftdm_mutex_unlock(ftdmchan->mutex); - } - } - return; -} - -void sngisdn_delayed_setup(void *p_sngisdn_info) -{ - sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*)p_sngisdn_info; - ftdm_channel_t *ftdmchan = sngisdn_info->ftdmchan; - - ftdm_mutex_lock(ftdmchan->mutex); - sngisdn_snd_setup(ftdmchan); - ftdm_mutex_unlock(ftdmchan->mutex); - return; -} - -void sngisdn_delayed_release_nfas(void *p_sngisdn_info) -{ - sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*)p_sngisdn_info; - ftdm_channel_t *ftdmchan = sngisdn_info->ftdmchan; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; - - ftdm_mutex_lock(ftdmchan->mutex); - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Sending delayed RELEASE (suId:%d suInstId:%u spInstId:%u)\n", - signal_data->cc_id, sngisdn_info->spInstId, sngisdn_info->suInstId); - - sngisdn_snd_release(ftdmchan, 0); - - ftdm_mutex_unlock(ftdmchan->mutex); - return; -} - -void sngisdn_delayed_release(void *p_sngisdn_info) -{ - sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*)p_sngisdn_info; - ftdm_channel_t *ftdmchan = sngisdn_info->ftdmchan; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; - - ftdm_mutex_lock(ftdmchan->mutex); - - if (ftdm_test_flag(sngisdn_info, FLAG_DELAYED_REL)) { - ftdm_clear_flag(sngisdn_info, FLAG_DELAYED_REL); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Sending delayed RELEASE (suId:%d suInstId:%u spInstId:%u)\n", - signal_data->cc_id, sngisdn_info->glare.spInstId, sngisdn_info->glare.suInstId); - - sngisdn_snd_release(ftdmchan, 1); - clear_call_glare_data(sngisdn_info); - } else { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Call was already released (suId:%d suInstId:%u spInstId:%u)\n", - signal_data->cc_id, sngisdn_info->glare.spInstId, sngisdn_info->glare.suInstId); - } - ftdm_mutex_unlock(ftdmchan->mutex); - return; -} - -void sngisdn_delayed_connect(void *p_sngisdn_info) -{ - sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*)p_sngisdn_info; - ftdm_channel_t *ftdmchan = sngisdn_info->ftdmchan; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; - - ftdm_mutex_lock(ftdmchan->mutex); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Sending delayed CONNECT (suId:%d suInstId:%u spInstId:%u)\n", - signal_data->cc_id, sngisdn_info->glare.spInstId, sngisdn_info->glare.suInstId); - - sngisdn_snd_connect(ftdmchan); - ftdm_mutex_unlock(ftdmchan->mutex); - return; -} - -void sngisdn_delayed_disconnect(void *p_sngisdn_info) -{ - sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*)p_sngisdn_info; - ftdm_channel_t *ftdmchan = sngisdn_info->ftdmchan; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; - - ftdm_mutex_lock(ftdmchan->mutex); - if (ftdmchan->caller_data.hangup_cause == IN_CCNORTTODEST || ftdmchan->state != FTDM_CHANNEL_STATE_DOWN) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Sending delayed DISCONNECT (suId:%d suInstId:%u spInstId:%u)\n", - signal_data->cc_id, sngisdn_info->glare.spInstId, sngisdn_info->glare.suInstId); - - sngisdn_snd_disconnect(ftdmchan); - if (ftdmchan->caller_data.hangup_cause == IN_CCNORTTODEST) { - ftdm_channel_t *close_chan = ftdmchan; - ftdm_channel_close(&close_chan); - } - } - - ftdm_mutex_unlock(ftdmchan->mutex); - return; -} - -void sngisdn_facility_timeout(void *p_sngisdn_info) -{ - sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*)p_sngisdn_info; - ftdm_channel_t *ftdmchan = sngisdn_info->ftdmchan; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; - - ftdm_mutex_lock(ftdmchan->mutex); - if (ftdmchan->state == FTDM_CHANNEL_STATE_GET_CALLERID) { - ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Facility timeout reached proceeding with call (suId:%d suInstId:%u spInstId:%u)\n", - signal_data->cc_id, sngisdn_info->spInstId, sngisdn_info->suInstId); - - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RING); - } - - ftdm_mutex_unlock(ftdmchan->mutex); - return; -} - -ftdm_status_t sngisdn_check_free_ids(void) -{ - unsigned i; - unsigned j; - ftdm_log(FTDM_LOG_INFO, "Checking suInstId's\n"); - for(j=1;j<=MAX_VARIANTS;j++) { - if (g_sngisdn_data.ccs[j].config_done) { - for(i=1;isignal_data; - - memset(&sts, 0, sizeof(sts)); - sng_isdn_phy_stats(sngisdn_dchan(signal_data)->link_id , &sts); - - stream->write_function(stream, "\n---------------------------------------------------------------------\n"); - stream->write_function(stream, " Span:%s", span->name); - stream->write_function(stream, "\n---------------------------------------------------------------------\n"); - stream->write_function(stream, " Performance Counters"); - stream->write_function(stream, "\n---------------------------------------------------------------------\n"); - stream->write_function(stream, "RX Packets:\t%u\tTX Packets:\t%u\tEvents:%u\n", sts.t.sts.rx_packets, sts.t.sts.tx_packets, sts.t.sts.rx_events); - stream->write_function(stream, "RX Bytes:\t%u\tTX Bytes:\t%u\n\n", sts.t.sts.rx_bytes, sts.t.sts.tx_bytes); - stream->write_function(stream, "TX Queue:\t%u/%u\tRX Queue:\t%u/%u\tEvents Queue:\t%u/%u\n", - sts.t.sts.num_frames_in_tx_queue,sts.t.sts.tx_queue_len, - sts.t.sts.num_frames_in_rx_queue, sts.t.sts.rx_queue_len, - sts.t.sts.rx_events_in_queue, sts.t.sts.event_queue_len); - - stream->write_function(stream, "\n---------------------------------------------------------------------\n"); - stream->write_function(stream, " Errors"); - stream->write_function(stream, "\n---------------------------------------------------------------------\n"); - stream->write_function(stream, "RX Errors:\t%u\tTX Errors:\t%u\n", sts.t.sts.rx_errors, sts.t.sts.tx_errors); - stream->write_function(stream, "RX Dropped:\t%u\tTX Dropped:\t%u\tEvents Dropped:\t%u\n", sts.t.sts.rx_dropped, sts.t.sts.tx_dropped,sts.t.sts.rx_events_dropped); - - - stream->write_function(stream, "\n---------------------------------------------------------------------\n"); - stream->write_function(stream, " RX Errors Details"); - stream->write_function(stream, "\n---------------------------------------------------------------------\n"); - stream->write_function(stream, "CRC:\t\t%u\tFrame:\t\t%u\tOverruns:\t%u\n", sts.t.sts.rx_crc_errors, sts.t.sts.rx_frame_errors, sts.t.sts.rx_over_errors); - stream->write_function(stream, "Fifo:\t\t%u\tAborts:\t\t%u\tMissed:\t\t%u\n", sts.t.sts.rx_fifo_errors, sts.t.sts.rx_hdlc_abort_counter, sts.t.sts.rx_missed_errors); - stream->write_function(stream, "Length:\t\t%u\n", sts.t.sts.rx_length_errors); - - stream->write_function(stream, "\n---------------------------------------------------------------------\n"); - stream->write_function(stream, " TX Errors Details"); - stream->write_function(stream, "\n---------------------------------------------------------------------\n"); - stream->write_function(stream, "Aborted:\t%u\tFifo:\t\t%u\tCarrier:\t%u\n", sts.t.sts.tx_aborted_errors, sts.t.sts.tx_fifo_errors, sts.t.sts.tx_carrier_errors); - return FTDM_SUCCESS; -} - - -ftdm_status_t sngisdn_show_span(ftdm_stream_handle_t *stream, ftdm_span_t *span) -{ - ftdm_signaling_status_t sigstatus; - ftdm_alarm_flag_t alarmbits; - ftdm_channel_t *fchan; - alarmbits = FTDM_ALARM_NONE; - fchan = ftdm_span_get_channel(span, 1); - if (fchan) { - ftdm_channel_get_alarms(fchan, &alarmbits); - } - - ftdm_span_get_sig_status(span, &sigstatus); - stream->write_function(stream, "span:%s physical:%s signalling:%s\n", - span->name, alarmbits ? "ALARMED" : "OK", - ftdm_signaling_status2str(sigstatus)); - return FTDM_SUCCESS; -} - -ftdm_status_t sngisdn_show_spans(ftdm_stream_handle_t *stream) -{ - int i; - for(i=1;i<=MAX_L1_LINKS;i++) { - if (g_sngisdn_data.spans[i]) { - sngisdn_show_span(stream, g_sngisdn_data.spans[i]->ftdm_span); - } - } - return FTDM_SUCCESS; -} - -ftdm_status_t sngisdn_add_var(sngisdn_chan_data_t *sngisdn_info, const char* var, const char* val) -{ - char *t_name = 0, *t_val = 0; - if (!var || !val) { - return FTDM_FAIL; - } - if (!sngisdn_info->variables) { - /* initialize on first use */ - sngisdn_info->variables = create_hashtable(16, ftdm_hash_hashfromstring, ftdm_hash_equalkeys); - ftdm_assert_return(sngisdn_info->variables, FTDM_FAIL, "Failed to create hash table\n"); - } - t_name = ftdm_strdup(var); - t_val = ftdm_strdup(val); - hashtable_insert(sngisdn_info->variables, t_name, t_val, HASHTABLE_FLAG_FREE_KEY | HASHTABLE_FLAG_FREE_VALUE); - return FTDM_SUCCESS; -} - -ftdm_status_t sngisdn_add_raw_data(sngisdn_chan_data_t *sngisdn_info, uint8_t* data, ftdm_size_t data_len) -{ - ftdm_assert_return(!sngisdn_info->raw_data, FTDM_FAIL, "Overwriting existing raw data\n"); - - sngisdn_info->raw_data = ftdm_calloc(1, data_len); - ftdm_assert_return(sngisdn_info->raw_data, FTDM_FAIL, "Failed to allocate raw data\n"); - - memcpy(sngisdn_info->raw_data, data, data_len); - sngisdn_info->raw_data_len = data_len; - return FTDM_SUCCESS; -} - -void sngisdn_send_signal(sngisdn_chan_data_t *sngisdn_info, ftdm_signal_event_t event_id) -{ - ftdm_sigmsg_t sigev; - ftdm_channel_t *ftdmchan = sngisdn_info->ftdmchan; - - memset(&sigev, 0, sizeof(sigev)); - - sigev.chan_id = ftdmchan->chan_id; - sigev.span_id = ftdmchan->span_id; - sigev.channel = ftdmchan; - sigev.event_id = event_id; - - if (sngisdn_info->variables) { - /* - * variables now belongs to the ftdm core, and - * will be cleared after sigev is processed by user. Set - * local pointer to NULL so we do not attempt to - * destroy it */ - sigev.variables = sngisdn_info->variables; - sngisdn_info->variables = NULL; - } - - if (sngisdn_info->raw_data) { - /* - * raw_data now belongs to the ftdm core, and - * will be cleared after sigev is processed by user. Set - * local pointer to NULL so we do not attempt to - * destroy it */ - - sigev.raw.data = sngisdn_info->raw_data; - sigev.raw.len = sngisdn_info->raw_data_len; - - sngisdn_info->raw_data = NULL; - sngisdn_info->raw_data_len = 0; - } - if (event_id == FTDM_SIGEVENT_TRANSFER_COMPLETED) { - sigev.ev_data.transfer_completed.response = sngisdn_info->transfer_data.response; - } - ftdm_span_send_signal(ftdmchan->span, &sigev); -} - -sngisdn_span_data_t *sngisdn_dchan(sngisdn_span_data_t *signal_data) -{ - if (!signal_data) { - return NULL; - } - - if (!signal_data->nfas.trunk) { - return signal_data; - } - return signal_data->nfas.trunk->dchan; -} - - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ - -/******************************************************************************/ diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_trace.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_trace.c deleted file mode 100644 index 56797fbf9c..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_trace.c +++ /dev/null @@ -1,996 +0,0 @@ -/* - * Copyright (c) 2010, Sangoma Technologies - * David Yat Sin - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "ftmod_sangoma_isdn.h" -#include "ftmod_sangoma_isdn_trace.h" - -#define OCTET(x) (ieData[x-1] & 0xFF) -#define MAX_DECODE_STR_LEN 2000 - -typedef struct sngisdn_trace_info -{ - uint8_t call_ref_flag; - uint16_t call_ref; - uint8_t msgtype; - uint8_t bchan_no; - ftdm_trace_dir_t dir; -} sngisdn_frame_info_t; - -void print_hex_dump(char* str, uint32_t *str_len, uint8_t* data, uint32_t index_start, uint32_t index_end); -uint32_t sngisdn_decode_ie(char *str, uint32_t *str_len, uint8_t current_codeset, uint8_t *data, uint16_t index_start); -static ftdm_status_t sngisdn_map_call(sngisdn_span_data_t *signal_data, sngisdn_frame_info_t frame_info, ftdm_channel_t **found); -static ftdm_status_t sngisdn_get_frame_info(uint8_t *data, uint32_t data_len, ftdm_trace_dir_t dir, sngisdn_frame_info_t *frame_info); - -uint8_t get_bits(uint8_t octet, uint8_t bitLo, uint8_t bitHi); -char* get_code_2_str(int code, struct code2str *pCodeTable); -void sngisdn_decode_q921(char* str, uint8_t* data, uint32_t data_len); -void sngisdn_decode_q931(char* str, uint8_t* data, uint32_t data_len); - - -char* get_code_2_str(int code, struct code2str *pCodeTable) -{ - struct code2str* pCode2txt; - pCode2txt = pCodeTable; - while(pCode2txt) { - if(pCode2txt->code >= 0) { - if (pCode2txt->code == code) { - return pCode2txt->text; - } - pCode2txt++; - } else { - /* This is the default value from the table */ - return pCode2txt->text; - } - } - return (char*)"unknown"; -} - - -uint8_t get_bits(uint8_t octet, uint8_t bitLo, uint8_t bitHi) -{ - if (!bitLo || !bitHi) { - return 0; - } - if (bitLo > bitHi) { - return 0; - } - - bitLo--; - bitHi--; - - switch(bitHi - bitLo) { - case 0: - return (octet >> bitLo) & 0x01; - case 1: - return (octet >> bitLo) & 0x03; - case 2: - return (octet >> bitLo) & 0x07; - case 3: - return (octet >> bitLo) & 0x0F; - case 4: - return (octet >> bitLo) & 0x1F; - case 5: - return (octet >> bitLo) & 0x3F; - case 6: - return (octet >> bitLo) & 0x7F; - case 7: - return (octet >> bitLo) & 0xFF; - } - return 0; -} - -void sngisdn_trace_interpreted_q921(sngisdn_span_data_t *signal_data, ftdm_trace_dir_t dir, uint8_t *data, uint32_t data_len) -{ - char *data_str = ftdm_calloc(1,500); /* TODO Find a proper size */ - sngisdn_decode_q921(data_str, data, data_len); - ftdm_log(FTDM_LOG_DEBUG, "[SNGISDN Q921] %s FRAME %s:\n%s\n", signal_data->ftdm_span->name, ftdm_trace_dir2str(dir), data_str); - ftdm_safe_free(data_str); -} - -void sngisdn_trace_raw_q921(sngisdn_span_data_t *signal_data, ftdm_trace_dir_t dir, uint8_t *data, uint32_t data_len) -{ - uint8_t *raw_data; - ftdm_sigmsg_t sigev; - - memset(&sigev, 0, sizeof(sigev)); - - sigev.span_id = signal_data->ftdm_span->span_id; - sigev.chan_id = signal_data->dchan->chan_id; - sigev.channel = signal_data->dchan; - sigev.event_id = FTDM_SIGEVENT_TRACE_RAW; - - sigev.ev_data.trace.dir = dir; - sigev.ev_data.trace.type = FTDM_TRACE_TYPE_Q921; - - raw_data = ftdm_malloc(data_len); - ftdm_assert(raw_data, "Failed to malloc"); - - memcpy(raw_data, data, data_len); - sigev.raw.data = raw_data; - sigev.raw.len = data_len; - ftdm_span_send_signal(signal_data->ftdm_span, &sigev); -} - -void sngisdn_decode_q921(char* str, uint8_t* data, uint32_t data_len) -{ - uint32_t str_len; - uint32_t i; - uint8_t sapi, cr, ea, tei, ns, nr, pf, p, cmd; - uint8_t frame_format = 0; - - str_len = 0; - - if(data_len >= 2) { - switch ((int)data[2] & 0x03) { - case 0: case 2: - frame_format = I_FRAME; - break; - case 1: - frame_format = S_FRAME; - break; - case 3: - frame_format = U_FRAME; - break; - } - } - - str_len+= sprintf(&str[str_len], " format: %s\n", - get_code_2_str(frame_format, dcodQ921FrameFormatTable)); - - for(i=0; i < data_len; i++) { - switch(i) { - case 0: // Octet 2 - sapi = (uint8_t)((data[i]>>2) & 0x3F); - cr = (uint8_t)((data[i]>>1) & 0x1); - ea = (uint8_t)(data[i] & 0x1); - str_len+= sprintf(&str[str_len], " sapi: %03d c/r: %01d ea: %01d\n", sapi, cr, ea); - break; - case 1: - tei = (uint8_t)((data[i]>>1) & 0x7F); - ea = (uint8_t)(data[i] & 0x1); - str_len+= sprintf(&str[str_len], " tei: %03d ea: %01d\n", tei, ea); - break; - case 2: - switch(frame_format) { - case I_FRAME: - ns = (uint8_t)((data[i]>>1) & 0x7F); - nr = (uint8_t)((data[i+1]>>1) & 0x7F); - p = (uint8_t)(data[i+1] & 0x01); - str_len+= sprintf(&str[str_len], " n(s): %03d\n n(r): %03d p: %01d\n", ns, nr, p); - break; - case S_FRAME: - nr = (uint8_t)((data[i+1]>>1) & 0x7F); - pf = (uint8_t)(data[i+1] & 0x01); - str_len+= sprintf(&str[str_len], " n(r): %03d p/f: %01d\n", nr, pf); - - cmd = (uint8_t)((data[i]>>2) & 0x03); - str_len+= sprintf(&str[str_len], " cmd: %s\n", get_code_2_str(cmd, dcodQ921SupervisoryCmdTable)); - - break; - case U_FRAME: - pf = (uint8_t)((data[i]>>4) & 0x01); - str_len+= sprintf(&str[str_len], " p/f: %01d\n", pf); - - cmd = (uint8_t)((data[i]>>2) & 0x03); - cmd |= (uint8_t)((data[i]>>5) & 0x07); - - str_len+= sprintf(&str[str_len], " cmd: %s\n", get_code_2_str(cmd, dcodQ921UnnumberedCmdTable)); - break; - } - break; - } - } - - print_hex_dump(str, &str_len, (uint8_t*) data, 0, data_len); - return; -} - - -void sngisdn_trace_interpreted_q931(sngisdn_span_data_t *signal_data, ftdm_trace_dir_t dir, uint8_t *data, uint32_t data_len) -{ - char *data_str = ftdm_calloc(1,MAX_DECODE_STR_LEN); /* TODO Find a proper size */ - sngisdn_decode_q931(data_str, data, data_len); - ftdm_log(FTDM_LOG_DEBUG, "[SNGISDN Q931] %s FRAME %s:\n%s\n", signal_data->ftdm_span->name, ftdm_trace_dir2str(dir), data_str); - ftdm_safe_free(data_str); -} - -void sngisdn_trace_raw_q931(sngisdn_span_data_t *signal_data, ftdm_trace_dir_t dir, uint8_t *data, uint32_t data_len) -{ - uint8_t *raw_data; - ftdm_sigmsg_t sigev; - ftdm_channel_t *ftdmchan = NULL; - sngisdn_frame_info_t frame_info; - - memset(&sigev, 0, sizeof(sigev)); - - /* Note: Mapped raw trace assume only exclusive b-channel selection is used. i.e the b-channel selected on outgoing SETUP is always used for the call */ - - if (sngisdn_get_frame_info(data, data_len, dir, &frame_info) == FTDM_SUCCESS) { - if (sngisdn_map_call(signal_data, frame_info, &ftdmchan) == FTDM_SUCCESS) { - sigev.call_id = ftdmchan->caller_data.call_id; - sigev.span_id = ftdmchan->physical_span_id; - sigev.chan_id = ftdmchan->physical_chan_id; - sigev.channel = ftdmchan; - } else { - /* We could not map the channel, but at least set the span */ - if (signal_data->ftdm_span->channels[1]) { - sigev.span_id = signal_data->ftdm_span->channels[1]->physical_span_id; - } - } - sigev.event_id = FTDM_SIGEVENT_TRACE_RAW; - - sigev.ev_data.trace.dir = dir; - sigev.ev_data.trace.type = FTDM_TRACE_TYPE_Q931; - - raw_data = ftdm_malloc(data_len); - ftdm_assert(raw_data, "Failed to malloc"); - - memcpy(raw_data, data, data_len); - sigev.raw.data = raw_data; - sigev.raw.len = data_len; - ftdm_span_send_signal(signal_data->ftdm_span, &sigev); - } -} - -void sngisdn_decode_q931(char* str, uint8_t* data, uint32_t data_len) -{ - uint32_t str_len; - uint8_t prot_disc, callRefFlag; - uint16_t lenCallRef, c, i; - uint8_t current_codeset = 0; - - str_len = 0; - - /* Decode Protocol Discrimator */ - prot_disc = (uint8_t)data[0]; - str_len += sprintf(&str[str_len], " Prot Disc:%s (0x%02x)\n", get_code_2_str(prot_disc, dcodQ931ProtDiscTable), prot_disc); - - /* Decode Call Reference */ - lenCallRef = (uint8_t) (data[1] & 0x0F); - - str_len += sprintf(&str[str_len], " Call Ref:"); - c=2; - callRefFlag = get_bits(data[c], 8,8); - for(i=0; i<(2*lenCallRef);i++) { - if(i==0) { - str_len += sprintf(&str[str_len], "%s%s", - get_code_2_str((uint8_t)(data[c] & 0x70), dcodQ931CallRefHiTable), - get_code_2_str((uint8_t)(data[c] & 0x0F), dcodQ931CallRefLoTable)); - } else { - str_len += sprintf(&str[str_len], "%s%s", - get_code_2_str((uint8_t)(data[c] & 0xF0), dcodQ931CallRefHiTable), - get_code_2_str((uint8_t)(data[c] & 0x0F), dcodQ931CallRefLoTable)); - } - - i=i+1; - c=c+1; - } - str_len += sprintf(&str[str_len], " (%s side)\n", callRefFlag?"Destination":"Originating"); - - /* Decode message type */ - str_len+= sprintf(&str[str_len], " Type:%s (0x%x)\n", get_code_2_str((int)(data[2+lenCallRef] & 0xFF), dcodQ931MsgTypeTable), (int)(data[2+lenCallRef] & 0xFF)); - - /* go through rest of data and look for important info */ - for(i=3+lenCallRef; i < data_len; i++) { - switch (data[i] & 0xF8) { - case Q931_LOCKING_SHIFT: - current_codeset = (data[i] & 0x7); - str_len+= sprintf(&str[str_len], "Codeset shift to %d (locking)\n", current_codeset); - continue; - case Q931_NON_LOCKING_SHIFT: - current_codeset = (data[i] & 0x7); - str_len+= sprintf(&str[str_len], "Codeset shift to %d (non-locking)\n", current_codeset); - continue; - } - i+= sngisdn_decode_ie(str, &str_len, current_codeset, data, i); - } - print_hex_dump(str, &str_len, (uint8_t*) data, 0, data_len); - return; -} - -uint32_t sngisdn_decode_ie(char *str, uint32_t *str_len, uint8_t current_codeset, uint8_t *data, uint16_t index_start) -{ - unsigned char* ieData; - uint8_t ieId; - uint32_t len = 0; - int index_end; - - ieData = (unsigned char*) &data[index_start]; - - ieId = OCTET(1); - len = OCTET(2); - index_end = index_start+len+1; - - *str_len += sprintf(&str[*str_len], " %s:", get_code_2_str(data[index_start], dcodQ931IEIDTable)); - switch(ieId) { - case PROT_Q931_IE_BEARER_CAP: - { - uint8_t codingStandard, infTransferCap, infTransferRate, usrL1Prot; - /*uint8_t transferMode;*/ - - codingStandard = get_bits(OCTET(3),6,7); - infTransferCap = get_bits(OCTET(3),1,5); - /*transferMode = get_bits(OCTET(4),6,7);*/ - infTransferRate = get_bits(OCTET(4),1,5); - usrL1Prot = get_bits(OCTET(5),1,5); - - *str_len+= sprintf(&str[*str_len], "Coding:%s(%d) TransferCap:%s(%d) TransferRate:%s(%d) L1Prot:%s(%d)\n", - get_code_2_str(codingStandard, dcodQ931BcCodingStandardTable), codingStandard, - get_code_2_str(infTransferCap, dcodQ931BcInfTransferCapTable), infTransferCap, - get_code_2_str(infTransferRate, dcodQ931BcInfTransferRateTable), infTransferRate, - get_code_2_str(usrL1Prot, dcodQ931BcusrL1ProtTable), usrL1Prot); - } - break; - case PROT_Q931_IE_CAUSE: - { - uint8_t codingStandard, location, cause,diagOct = 5; - codingStandard = get_bits(OCTET(3),6,7); - location = get_bits(OCTET(3),1,4); - - cause = get_bits(OCTET(4),1,7); - - *str_len+= sprintf(&str[*str_len], "coding:%s(%d) location:%s(%d) val:%s(%d)\n", - get_code_2_str(codingStandard, dcodQ931BcCodingStandardTable), codingStandard, - get_code_2_str(location,dcodQ931IelocationTable), location, - get_code_2_str(cause, dcodQ931CauseCodeTable), - cause); - switch(cause) { - case PROT_Q931_RELEASE_CAUSE_IE_NOT_EXIST: - while(diagOct++ < len) { - *str_len+= sprintf(&str[*str_len], " %d:IE %s(0x%02x)\n", - diagOct, - get_code_2_str(OCTET(diagOct), dcodQ931IEIDTable), - OCTET(diagOct)); - } - break; - case PROT_Q931_RELEASE_CAUSE_WRONG_CALL_STATE: - while(diagOct++ < len) { - *str_len+= sprintf(&str[*str_len], " %d:Message %s(0x%02x)\n", - diagOct, - get_code_2_str(OCTET(diagOct), dcodQ931MsgTypeTable), - OCTET(diagOct)); - } - break; - case PROT_Q931_RECOVERY_ON_TIMER_EXPIRE: - *str_len+= sprintf(&str[*str_len], " Timer T\n"); - while(diagOct++ < len) { - if(OCTET(diagOct) >= ' ' && OCTET(diagOct) < 0x7f) { - *str_len+= sprintf(&str[*str_len], "%c", OCTET(diagOct)); - } else { - *str_len+= sprintf(&str[*str_len], "."); - } - } - break; - default: - while(diagOct++ < len) { - *str_len+= sprintf(&str[*str_len], " %d: 0x%02x\n", - diagOct, - OCTET(diagOct)); - } - break; - } - } - break; - case PROT_Q931_IE_CHANNEL_ID: - { - uint8_t infoChannelSelection=0; - uint8_t prefExclusive=0; - uint8_t ifaceIdPresent=0; - /* uint8_t ifaceIdentifier = 0; */ /* octet_3_1 */ - uint8_t chanType=0, numberMap=0; - /* uint8_t codingStandard=0; */ - uint8_t channelNo = 0; - - infoChannelSelection = get_bits(OCTET(3),1,2); - prefExclusive = get_bits(OCTET(3),4,4); - ifaceIdPresent = get_bits(OCTET(3),7,7); - - if (ifaceIdPresent) { - /*ifaceIdentifier= get_bits(OCTET(4),1,7);*/ - chanType = get_bits(OCTET(5),1,4); - numberMap = get_bits(OCTET(5),5,5); - /*codingStandard = get_bits(OCTET(5),6,7);*/ - channelNo = get_bits(OCTET(6),1,7); - } else { - chanType = get_bits(OCTET(4),1,4); - numberMap = get_bits(OCTET(4),5,5); - /*codingStandard = get_bits(OCTET(4),6,7);*/ - channelNo = get_bits(OCTET(5),1,7); - } - - if (numberMap) { - *str_len+= sprintf(&str[*str_len], " MAP:%s ", get_code_2_str(infoChannelSelection, dcodQ931InfoChannelSelTable)); - } else { - *str_len+= sprintf(&str[*str_len], "No:%d ", channelNo); - } - - *str_len+= sprintf(&str[*str_len], "Type:%s(%d) %s ", get_code_2_str(chanType,dcodQ931ChanTypeTable), chanType, (numberMap)? "Map":""); - *str_len+= sprintf(&str[*str_len], "%s/%s \n", - (prefExclusive)? "Exclusive":"Preferred", - (ifaceIdPresent)? "Explicit":"Implicit"); - } - break; - case PROT_Q931_IE_CALLING_PARTY_NUMBER: - { - uint8_t plan, type, screening = 0, presentation = 0, callingNumOct, j; - uint8_t screeningEnabled = 0, presentationEnabled = 0; - char callingNumDigits[32]; - memset(callingNumDigits, 0, sizeof(callingNumDigits)); - - plan = get_bits(OCTET(3),1,4); - type = get_bits(OCTET(3),5,7); - - if(!get_bits(OCTET(3),8,8)) { - screening = get_bits(OCTET(4),1,2); - presentation = get_bits(OCTET(4),6,7); - screeningEnabled = 1; - presentationEnabled = 1; - callingNumOct = 4; - } else { - callingNumOct = 3; - } - if(len >= sizeof(callingNumDigits)) { - len = sizeof(callingNumDigits)-1; - } - j = 0; - while(callingNumOct++ <= len+1) { - callingNumDigits[j++]=ia5[get_bits(OCTET(callingNumOct),1,4)][get_bits(OCTET(callingNumOct),5,8)]; - } - callingNumDigits[j]='\0'; - *str_len+= sprintf(&str[*str_len], "%s(l:%d) plan:%s(%d) type:%s(%d)", - - callingNumDigits, j, - get_code_2_str(plan, dcodQ931NumberingPlanTable), plan, - get_code_2_str(type, dcodQ931TypeofNumberTable), type); - - if (presentationEnabled||screeningEnabled) { - *str_len+= sprintf(&str[*str_len], "scr:%s(%d) pres:%s(%d)\n", - get_code_2_str(screening, dcodQ931ScreeningTable), screening, - get_code_2_str(presentation, dcodQ931PresentationTable), presentation); - } else { - *str_len+= sprintf(&str[*str_len], "\n"); - } - } - break; - - case PROT_Q931_IE_CALLED_PARTY_NUMBER: - { - uint8_t plan, type, calledNumOct,j; - char calledNumDigits[32]; - memset(calledNumDigits, 0, sizeof(calledNumDigits)); - plan = get_bits(OCTET(3),1,4); - type = get_bits(OCTET(3),5,7); - - if(len >= sizeof(calledNumDigits)) { - len = sizeof(calledNumDigits)-1; - } - calledNumOct = 3; - j = 0; - while(calledNumOct++ <= len+1) { - calledNumDigits[j++]=ia5[get_bits(OCTET(calledNumOct),1,4)][get_bits(OCTET(calledNumOct),5,8)]; - } - calledNumDigits[j]='\0'; - *str_len+= sprintf(&str[*str_len], "%s(l:%d) plan:%s(%d) type:%s(%d)\n", - calledNumDigits, j, - get_code_2_str(plan, dcodQ931NumberingPlanTable), plan, - get_code_2_str(type, dcodQ931TypeofNumberTable), type); - } - break; - case PROT_Q931_IE_REDIRECTING_NUMBER: //rdnis - { - uint8_t plan, type, screening = 0, presentation = 0, reason = 0, rdnisOct,j; - uint8_t screeningEnabled = 0, presentationEnabled = 0, reasonEnabled = 0; - char rdnis_string[32]; - memset(rdnis_string, 0, sizeof(rdnis_string)); - rdnisOct = 5; - plan = get_bits(OCTET(3),1,4); - type = get_bits(OCTET(3),5,7); - - if(!get_bits(OCTET(3),8,8)) { //Oct 3a exists - rdnisOct++; - screening = get_bits(OCTET(4),1,2); - presentation = get_bits(OCTET(4),6,7); - screeningEnabled = 1; - presentationEnabled = 1; - if (!get_bits(OCTET(4),8,8)) { //Oct 3b exists - rdnisOct++; - reason = get_bits(OCTET(5),1,4); - reasonEnabled = 1; - } - } - - if(len >= sizeof(rdnis_string)) { - len = sizeof(rdnis_string)-1; - } - - j = 0; - while(rdnisOct++ <= len+1) { - rdnis_string[j++]=ia5[get_bits(OCTET(rdnisOct),1,4)][get_bits(OCTET(rdnisOct),5,8)]; - } - - rdnis_string[j]='\0'; - *str_len+= sprintf(&str[*str_len], "%s(l:%d) plan:%s(%d) type:%s(%d)", - rdnis_string, j, - get_code_2_str(plan, dcodQ931NumberingPlanTable), plan, - get_code_2_str(type, dcodQ931TypeofNumberTable), type); - - if(presentationEnabled || screeningEnabled) { - *str_len+= sprintf(&str[*str_len], "scr:%s(%d) pres:%s(%d)", - get_code_2_str(screening, dcodQ931ScreeningTable), screening, - get_code_2_str(presentation, dcodQ931PresentationTable), presentation); - } - - if(reasonEnabled) { - *str_len+= sprintf(&str[*str_len], "reason:%s(%d)", - get_code_2_str(reason, dcodQ931ReasonTable), reason); - } - *str_len+= sprintf(&str[*str_len], "\n"); - } - break; - case PROT_Q931_IE_USER_USER: - { - uint8_t protDiscr = 0x00, j, uui_stringOct; - char uui_string[32]; - memset(uui_string, 0, sizeof(uui_string)); - protDiscr = OCTET(3); - uui_stringOct = 3; - if (protDiscr != 0x04) { /* Non-IA5 */ - *str_len+= sprintf(&str[*str_len], "%s (0x%02x)\n", - get_code_2_str(protDiscr, dcodQ931UuiProtDiscrTable), protDiscr); - } else { - j = 0; - - if(len >= sizeof(uui_string)) { - len = sizeof(uui_string)-1; - } - while(uui_stringOct++ <= len+1) { - uui_string[j++]=ia5[get_bits(OCTET(uui_stringOct),1,4)][get_bits(OCTET(uui_stringOct),5,8)]; - } - uui_string[j]='\0'; - *str_len+= sprintf(&str[*str_len], " %s (0x%02x) <%s>\n", - get_code_2_str(protDiscr, dcodQ931UuiProtDiscrTable), protDiscr, - uui_string); - } - } - break; - case PROT_Q931_IE_DISPLAY: - { - uint8_t j; - char displayStr[82]; - uint8_t displayNtEnabled = 0; - uint8_t displayStrOct = 2; - uint8_t displayType = 0; - uint8_t assocInfo = 0; - - memset(displayStr, 0, sizeof(displayStr)); - - if(get_bits(OCTET(3),8,8)) { - displayType = get_bits(OCTET(3),1,4); - assocInfo = get_bits(OCTET(3),5,7); - - displayNtEnabled = 1; - displayStrOct++; - } - j = 0; - if(len >= sizeof(displayStr)) { - len = sizeof(displayStr)-1; - } - while(displayStrOct++ <= len+1) { - displayStr[j++]=ia5[get_bits(OCTET(displayStrOct),1,4)][get_bits(OCTET(displayStrOct),5,8)]; - } - displayStr[j]='\0'; - if (displayNtEnabled) { - *str_len+= sprintf(&str[*str_len], "%s(l:%d) type:%s(%d) info:%s(%d)\n", - displayStr, len, - get_code_2_str(displayType, dcodQ931DisplayTypeTable), displayType, - get_code_2_str(assocInfo, dcodQ931AssocInfoTable), assocInfo); - } else { - *str_len+= sprintf(&str[*str_len], "%s(l:%d)\n", - displayStr, len); - } - } - break; - case PROT_Q931_IE_RESTART_IND: - { - uint8_t indClass; - indClass = get_bits(OCTET(3),1,3); - *str_len+= sprintf(&str[*str_len], "class:%s(%d)\n", - get_code_2_str(indClass,dcodQ931RestartIndClassTable), indClass); - } - break; - case PROT_Q931_IE_PROGRESS_IND: - { - uint8_t codingStandard, location, progressDescr; - codingStandard = get_bits(OCTET(3),6,7); - location = get_bits(OCTET(3),1,4); - progressDescr = get_bits(OCTET(4),1,7); - *str_len+= sprintf(&str[*str_len], "coding:%s(%d) location:%s(%d) descr:%s(%d)\n", - get_code_2_str(codingStandard,dcodQ931BcCodingStandardTable), codingStandard, - get_code_2_str(location,dcodQ931IelocationTable), location, - get_code_2_str(progressDescr,dcodQ931IeprogressDescrTable), progressDescr); - } - break; - case PROT_Q931_IE_KEYPAD_FACILITY: - { - uint8_t keypadFacilityStrOct = 3, j; - char keypadFacilityStr[82]; - memset(keypadFacilityStr, 0, sizeof(keypadFacilityStr)); - - j = 0; - if(len >= sizeof(keypadFacilityStr)) { - len = sizeof(keypadFacilityStr)-1; - } - while(keypadFacilityStrOct++ < len+1) { - keypadFacilityStr[j++]=ia5[get_bits(OCTET(keypadFacilityStrOct),1,4)][get_bits(OCTET(keypadFacilityStrOct),5,8)]; - } - keypadFacilityStr[j]='\0'; - *str_len+= sprintf(&str[*str_len], " digits:%s(l:%d)\n", - keypadFacilityStr, len); - } - break; - case PROT_Q931_IE_FACILITY: - { - uint8_t protProfile; - protProfile = get_bits(OCTET(3),1,5); - *str_len+= sprintf(&str[*str_len], "Prot profile:%s(%d)\n", - get_code_2_str(protProfile,dcodQ931IeFacilityProtProfileTable), protProfile); - } - break; - case PROT_Q931_IE_GENERIC_DIGITS: - { - uint8_t encoding,type; - int value = 0; - - encoding = get_bits(OCTET(3),6,8); - type = get_bits(OCTET(3),1,5); - - *str_len+= sprintf(&str[*str_len], "encoding:%s(%d) type:%s(%d) ", - get_code_2_str(encoding,dcodQ931GenDigitsEncodingTable), encoding, - get_code_2_str(encoding,dcodQ931GenDigitsTypeTable), type); - - if (len > 1) { - uint32_t j=0; - - while(++j < len) { - switch(encoding) { - case 0: /* BCD even */ - case 1: /* BCD odd */ - { - uint8_t byte = OCTET(j+3); - value = (get_bits(byte,1,4)*10) + get_bits(byte,5,8) + (value*10); - } - break; - case 2: /* IA 5 */ - value = value*10 + OCTET(j+3)-'0'; - *str_len+= sprintf(&str[*str_len], "%c", OCTET(j+3)); - break; - case 3: - /* Don't know how to decode binary encoding yet */ - *str_len+= sprintf(&str[*str_len], "Binary encoded"); - break; - } - } - *str_len+= sprintf(&str[*str_len], " "); - switch(type) { - case 4: /* info digits */ - *str_len+= sprintf(&str[*str_len], "ani2:%s(%d)", get_code_2_str(value,dcodQ931LineInfoTable), value); - break; - case 5: /* Callid */ - *str_len+= sprintf(&str[*str_len], "Caller ID not implemented\n"); - break; - } - } - *str_len+= sprintf(&str[*str_len], "\n"); - print_hex_dump(str, str_len, (uint8_t*) data, index_start, index_end); - } - break; - case PROT_Q931_IE_SENDING_COMPLETE: - /* No need to decode sending complete IE, as no additional info is available except that sending is done */ - /* This is a single octet IE */ - *str_len+= sprintf(&str[*str_len], "\n"); - return 0; - break; - case PROT_Q931_IE_CALLED_PARTY_SUBADDRESS: - { - uint8_t type; - uint8_t currentOct, j=0; - char calling_subaddr_string[82]; - memset(calling_subaddr_string, 0, sizeof(calling_subaddr_string)); - type = get_bits(OCTET(3),5,7); - currentOct = 3; - while(currentOct++ <= len+1) { - calling_subaddr_string[j++]=ia5[get_bits(OCTET(currentOct),1,4)][get_bits(OCTET(currentOct),5,8)]; - } - calling_subaddr_string[j++]='\0'; - *str_len += sprintf(&str[*str_len], "%s (l:%d) type:%s(%d) \n", - calling_subaddr_string, (j-1), get_code_2_str(type, dcodQ931TypeOfSubaddressTable), type); - } - break; - case PROT_Q931_IE_NOTIFICATION_IND: - { - uint8_t desc; - - desc = get_bits(OCTET(3),1,7); - *str_len += sprintf(&str[*str_len], "%s (%d)\n", - get_code_2_str(desc, dcodQ931NotificationIndTable), desc); - } - break; - case PROT_Q931_IE_REDIRECTION_NUMBER: - case PROT_Q931_IE_DATE_TIME: - case PROT_Q931_IE_INFORMATION_REQUEST: - case PROT_Q931_IE_SIGNAL: - case PROT_Q931_IE_SWITCHOOK: - case PROT_Q931_IE_FEATURE_ACT: - case PROT_Q931_IE_FEATURE_IND: - case PROT_Q931_IE_INFORMATION_RATE: - case PROT_Q931_IE_END_TO_END_TRANSIT_DELAY: - case PROT_Q931_IE_TRANSIT_DELAY_SELECT_IND: - case PROT_Q931_IE_PACKET_LAYER_BINARY_PARAMS: - case PROT_Q931_IE_PACKET_LAYER_WINDOW_SIZE: - case PROT_Q931_IE_PACKET_LAYER_SIZE: - case PROT_Q931_IE_TRANSIT_NETWORK_SELECTION: - case PROT_Q931_IE_LOW_LAYER_COMPAT: - case PROT_Q931_IE_HIGH_LAYER_COMPAT: - case PROT_Q931_IE_ESCAPE_FOR_EXTENSION: - case PROT_Q931_IE_CALL_IDENTITY: - case PROT_Q931_IE_CALL_STATE: - case PROT_Q931_IE_SEGMENTED_MESSAGE: - case PROT_Q931_IE_NETWORK_SPF_FACILITY: - case PROT_Q931_IE_CALLING_PARTY_SUBADDRESS: - default: - { - *str_len += sprintf(&str[*str_len], "Undecoded"); - print_hex_dump((char*)str, str_len, data, index_start, index_end + 1); - } - break; - } - - return len+1; -} - -void print_hex_dump(char* str, uint32_t *str_len, uint8_t* data, uint32_t index_start, uint32_t index_end) -{ - uint32_t k; - *str_len += sprintf(&str[*str_len], " [ "); - for(k=index_start; k < index_end; k++) { - if (k && !(k%32)) { - *str_len += sprintf(&str[*str_len], "\n "); - } - *str_len += sprintf(&str[*str_len], "%02x ", data[k]); - } - *str_len += sprintf(&str[*str_len], "]\n"); - return; -} - -static ftdm_status_t sngisdn_get_frame_info(uint8_t *data, uint32_t data_len, ftdm_trace_dir_t dir, sngisdn_frame_info_t *target) -{ - uint8_t pos = 0; - uint8_t flag; - uint16_t ref = 0; - uint8_t ref_len = 0; - uint8_t bchan_no = 0; - uint8_t msgtype; - - /* First octet is protocol discriminator */ - pos++; - /* Second octet contains length of call reference */ - ref_len = data[pos++] & 0x0F; - - /* third octet is call reference */ - flag = (data[pos] & 0x80) >> 7; - if (ref_len == 2) { - ref = (data[pos++] & 0x7F) << 8; - ref |= (data[pos++] & 0xFF) ; - } else { - ref = (data[pos++] & 0x7F); - } - - /* Next octet is the message type */ - msgtype = data[pos++] & 0x7F; - - /* - ftdm_log(FTDM_LOG_DEBUG, "Raw frame:call_ref:0x%04x flag:%d msgtype:%d\n", ref, flag, msgtype); - */ - if (!ref) { - /* This is not a call specific message (RESTART for example and we do not care about it) */ - return FTDM_FAIL; - } - - /* Look for the b-channel */ - if (msgtype == PROT_Q931_MSGTYPE_SETUP) { - /* Try to find the b-channel no*/ - - for(; pos < data_len; pos++) { - uint8_t ie_id = data[pos]; - uint8_t ie_len = data[pos+1]; - - switch(ie_id) { - case PROT_Q931_IE_SENDING_COMPLETE: - /* Single octet ie's do not have a length */ - ie_len = 0; - break; - case PROT_Q931_IE_CHANNEL_ID: - { - /* Try to obtain the b-channel */ - uint8_t ie_pos = pos+2; - //ifaceIdPresent = get_bits(OCTET(3),7,7); - if (data[ie_pos] & 0x20) { - /* Interface type is Primary Rate */ - ie_pos+=2; - bchan_no = data[ie_pos] & 0x7F; - } else { - /* Interface type is Basic Interface */ - /* Get the channel number from info channel selection */ - bchan_no = data[ie_pos] & 0x03; - } - ftdm_log(FTDM_LOG_DEBUG, "Found b-channel:%d\n", bchan_no); - goto parse_ies_done; - } - break; - default: - pos = pos+ie_len+1; - } - //ftdm_log(FTDM_LOG_DEBUG, "Decoded IE:%s\n", get_code_2_str(ie_id, dcodQ931IEIDTable)); - } - if (!bchan_no) { - uint32_t tmp_len = 0; - char tmp[1000]; - print_hex_dump(tmp, &tmp_len, data, 0, data_len); - ftdm_log(FTDM_LOG_DEBUG, "Failed to determine b-channel on SETUP message\n%s\n", tmp); - } - } - -parse_ies_done: - - target->call_ref = ref; - target->call_ref_flag = flag; - target->msgtype = msgtype; - target->bchan_no = bchan_no; - target->dir = dir; - - return FTDM_SUCCESS; -} - -static ftdm_status_t sngisdn_map_call(sngisdn_span_data_t *signal_data, sngisdn_frame_info_t frame_info, ftdm_channel_t **found) -{ - sngisdn_chan_data_t *sngisdn_info; - ftdm_channel_t *ftdmchan = NULL; - ftdm_iterator_t *chaniter = NULL; - ftdm_iterator_t *curr = NULL; - ftdm_status_t status = FTDM_FAIL; - uint8_t outbound_call = 0; - - if ((!frame_info.call_ref_flag && frame_info.dir == FTDM_TRACE_DIR_OUTGOING) || - (frame_info.call_ref_flag && frame_info.dir == FTDM_TRACE_DIR_INCOMING)) { - - /* If this is an outgoing frame and this frame was sent by the originating side - of the call (frame_info.call_ref_flag == 0), then this is an outbound call */ - outbound_call = 1; - } else { - outbound_call = 0; - } - - switch (frame_info.msgtype) { - case PROT_Q931_MSGTYPE_SETUP: - /* We initiated this outgoing call try to match the call reference with our internal call-id*/ - if (!frame_info.bchan_no) { - /* We were not able to determine the bchannel on this call, so we will not be able to match it anyway */ - status = FTDM_FAIL; - } - - chaniter = ftdm_span_get_chan_iterator(signal_data->ftdm_span, NULL); - for (curr = chaniter; curr; curr = ftdm_iterator_next(curr)) { - ftdmchan = (ftdm_channel_t*)(ftdm_iterator_current(curr)); - ftdm_channel_lock(ftdmchan); - - if (outbound_call) { - sngisdn_info = (sngisdn_chan_data_t*)ftdmchan->call_data; - if (sngisdn_info && ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { - if (ftdmchan->caller_data.call_id && ftdmchan->physical_chan_id == frame_info.bchan_no) { - - sngisdn_info->call_ref = frame_info.call_ref; - *found = ftdmchan; - status = FTDM_SUCCESS; - } - } - } else { - if (ftdmchan->physical_chan_id == frame_info.bchan_no) { - *found = ftdmchan; - status = FTDM_SUCCESS; - } - } - ftdm_channel_unlock(ftdmchan); - } - ftdm_iterator_free(chaniter); - break; - case PROT_Q931_MSGTYPE_ALERTING: - case PROT_Q931_MSGTYPE_PROCEEDING: - case PROT_Q931_MSGTYPE_PROGRESS: - case PROT_Q931_MSGTYPE_CONNECT: - case PROT_Q931_MSGTYPE_SETUP_ACK: - case PROT_Q931_MSGTYPE_CONNECT_ACK: - case PROT_Q931_MSGTYPE_USER_INFO: - case PROT_Q931_MSGTYPE_DISCONNECT: - case PROT_Q931_MSGTYPE_RELEASE: - case PROT_Q931_MSGTYPE_RESTART_ACK: - case PROT_Q931_MSGTYPE_RELEASE_COMPLETE: - case PROT_Q931_MSGTYPE_FACILITY: - case PROT_Q931_MSGTYPE_NOTIFY: - case PROT_Q931_MSGTYPE_STATUS_ENQUIRY: - case PROT_Q931_MSGTYPE_INFORMATION: - case PROT_Q931_MSGTYPE_STATUS: - /* Look for an outbound call on that span and and try to match the call-id */ - chaniter = ftdm_span_get_chan_iterator(signal_data->ftdm_span, NULL); - for (curr = chaniter; curr; curr = ftdm_iterator_next(curr)) { - ftdmchan = (ftdm_channel_t*)(ftdm_iterator_current(curr)); - ftdm_channel_lock(ftdmchan); - sngisdn_info = (sngisdn_chan_data_t*)ftdmchan->call_data; - if (outbound_call) { - if (sngisdn_info && ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { - if (sngisdn_info->call_ref == frame_info.call_ref) { - - *found = ftdmchan; - status = FTDM_SUCCESS; - } - } - } else { - if (sngisdn_info && !ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { - if (sngisdn_info->call_ref && sngisdn_info->call_ref == frame_info.call_ref) { - - *found = ftdmchan; - status = FTDM_SUCCESS; - } - } - } - ftdm_channel_unlock(ftdmchan); - } - ftdm_iterator_free(chaniter); - break; - default: - /* This frame is not call specific, ignore */ - break; - } - if (status == FTDM_SUCCESS) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Mapped %s with Call Ref:%04x to call-id:%d\n", get_code_2_str(frame_info.msgtype, dcodQ931MsgTypeTable), frame_info.call_ref, (*found)->caller_data.call_id); - } else { - /* We could not map this frame to a call-id */ - ftdm_log(FTDM_LOG_DEBUG, "Failed to map %s with Call Ref:%04x to local call\n", - get_code_2_str(frame_info.msgtype, dcodQ931MsgTypeTable), frame_info.call_ref); - } - - return status; -} - - - diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_trace.h b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_trace.h deleted file mode 100644 index b09bcbd33a..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_trace.h +++ /dev/null @@ -1,599 +0,0 @@ -/* - * Copyright (c) 2010, Sangoma Technologies - * David Yat Sin - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __FTMOD_SANGOMA_ISDN_TRACE_H__ -#define __FTMOD_SANGOMA_ISDN_TRACE_H__ - -#define MX_CODE_TXT_LEN 70 -#define Q931_LOCKING_SHIFT 0x90 -#define Q931_NON_LOCKING_SHIFT 0x98 - -#define PROT_Q931_RELEASE_CAUSE_MISDIALED_TRUNK_PREFIX 5 -#define PROT_Q931_RELEASE_CAUSE_INVALID_NUMBER_FORMAT 28 -#define PROT_Q931_RELEASE_CAUSE_NO_CHAN_AVAIL 34 -#define PROT_Q931_RELEASE_CAUSE_DEST_OUT_OF_ORDER 27 -#define PROT_Q931_RELEASE_CAUSE_IE_NOT_EXIST 99 -#define PROT_Q931_RECOVERY_ON_TIMER_EXPIRE 102 -#define PROT_Q931_RELEASE_CAUSE_WRONG_CALL_STATE 101 - - -#define PROT_Q931_IE_SEGMENTED_MESSAGE 0x00 -#define PROT_Q931_IE_BEARER_CAP 0x04 -#define PROT_Q931_IE_CAUSE 0x08 -#define PROT_Q931_IE_CALL_IDENTITY 0x10 -#define PROT_Q931_IE_CALL_STATE 0x14 -#define PROT_Q931_IE_CHANNEL_ID 0x18 -#define PROT_Q931_IE_FACILITY 0x1c -#define PROT_Q931_IE_PROGRESS_IND 0x1e -#define PROT_Q931_IE_NETWORK_SPF_FACILITY 0x20 -#define PROT_Q931_IE_NOTIFICATION_IND 0x27 -#define PROT_Q931_IE_DISPLAY 0x28 -#define PROT_Q931_IE_DATE_TIME 0x29 -#define PROT_Q931_IE_KEYPAD_FACILITY 0x2c -#define PROT_Q931_IE_INFORMATION_REQUEST 0x32 -#define PROT_Q931_IE_SIGNAL 0x34 -#define PROT_Q931_IE_SWITCHOOK 0x36 -#define PROT_Q931_IE_GENERIC_DIGITS 0x37 -#define PROT_Q931_IE_FEATURE_ACT 0x38 -#define PROT_Q931_IE_FEATURE_IND 0x39 -#define PROT_Q931_IE_INFORMATION_RATE 0x40 -#define PROT_Q931_IE_END_TO_END_TRANSIT_DELAY 0x42 -#define PROT_Q931_IE_TRANSIT_DELAY_SELECT_IND 0x43 -#define PROT_Q931_IE_PACKET_LAYER_BINARY_PARAMS 0x44 -#define PROT_Q931_IE_PACKET_LAYER_WINDOW_SIZE 0x45 -#define PROT_Q931_IE_PACKET_LAYER_SIZE 0x46 -#define PROT_Q931_IE_CALLING_PARTY_NUMBER 0x6c -#define PROT_Q931_IE_CALLING_PARTY_SUBADDRESS 0x6d -#define PROT_Q931_IE_CALLED_PARTY_NUMBER 0x70 -#define PROT_Q931_IE_CALLED_PARTY_SUBADDRESS 0x71 -#define PROT_Q931_IE_REDIRECTING_NUMBER 0x74 -#define PROT_Q931_IE_REDIRECTION_NUMBER 0x76 -#define PROT_Q931_IE_TRANSIT_NETWORK_SELECTION 0x78 -#define PROT_Q931_IE_RESTART_IND 0x79 -#define PROT_Q931_IE_LOW_LAYER_COMPAT 0x7c -#define PROT_Q931_IE_HIGH_LAYER_COMPAT 0x7d -#define PROT_Q931_IE_USER_USER 0x7e -#define PROT_Q931_IE_SENDING_COMPLETE 0xa1 -#define PROT_Q931_IE_ESCAPE_FOR_EXTENSION 0x7f -#define PROT_Q931_IE_SENDING_COMPLETE 0xa1 - -#define NULL_CHAR 0 - - -struct code2str -{ - int code; - char text[MX_CODE_TXT_LEN]; -}; - -enum { - I_FRAME = 1, /* Information frame */ - S_FRAME, /* Supervisory frame */ - U_FRAME, /* Unnumbered frame */ -}; - -char ia5[16][8]={{NULL_CHAR,NULL_CHAR,' ','0','@','P','`','p'}, - {NULL_CHAR,NULL_CHAR,'!','1','A','Q','a','q'}, - {NULL_CHAR,NULL_CHAR,'"','2','B','R','b','r'}, - {NULL_CHAR,NULL_CHAR,'#','3','C','S','c','s'}, - {NULL_CHAR,NULL_CHAR,'$','4','D','T','d','t'}, - {NULL_CHAR,NULL_CHAR,'%','5','E','U','e','u'}, - {NULL_CHAR,NULL_CHAR,'&','6','F','V','f','v'}, - {NULL_CHAR,NULL_CHAR,'\'','7','G','W','g','w'}, - {NULL_CHAR,NULL_CHAR,'(','8','H','X','h','x'}, - {NULL_CHAR,NULL_CHAR,')','9','I','Y','i','y'}, - {NULL_CHAR,NULL_CHAR,'*',':','J','Z','j','z'}, - {NULL_CHAR,NULL_CHAR,'+',';','K','[','k','{'}, - {NULL_CHAR,NULL_CHAR,',','<','L','\\','l','|'}, - {NULL_CHAR,NULL_CHAR,'-','=','M',']','m','}'}, - {NULL_CHAR,NULL_CHAR,'.','>','N','^','n','~'}, - {NULL_CHAR,NULL_CHAR,'/','?','O','_','o',NULL_CHAR}}; - -/* Based on Table 4 - pg 15 of Q.921 Recommendation */ -struct code2str dcodQ921FrameFormatTable[] = { - {I_FRAME, "Information"}, - {S_FRAME, "Supervisory"}, - {U_FRAME, "Unnumbered"}, - {-1, "?"}, -}; - - -/* Based on Table 5 - pg 15 of Q.921 Recommendation */ -struct code2str dcodQ921SupervisoryCmdTable[] = { - {0, "RR - receive ready"}, - {1, "RNR - receive not ready"}, - {2, "REJ - reject"}, - {-1, "Unknown"}, -}; - -/* Based on Table 5 - pg 15 of Q.921 Recommendation */ -struct code2str dcodQ921UnnumberedCmdTable[] = { - {0x0F, "SABME - set async balanced mode extended"}, - {0x03, "DM - disconnected mode"}, - {0x00, "UI - unnumbered information"}, - {0x08, "DISC - disconnect"}, - {0x0C, "UA - unnumbered acknowledgement"}, - {0x11, "FRMR - frame reject"}, - {0x17, "XID - Exchange Identification)"}, - {-1, "Unknown"}, -}; - -struct code2str dcodQ931ProtDiscTable[] = { - {0x08, "Q.931/I.451"}, - {0x09, "Q.2931"}, - {-1, "Unknown"}, -}; - -struct code2str dcodQ931CallRefHiTable[] = { - {0, "0"}, - {16, "1"}, - {32, "2"}, - {48, "3"}, - {64, "4"}, - {80, "5"}, - {96, "6"}, - {112, "7"}, - {128, "8"}, - {144, "9"}, - {160, "A"}, - {176, "B"}, - {192, "C"}, - {208, "D"}, - {224, "E"}, - {240, "F"}, - {-1,"?"}, -}; - -struct code2str dcodQ931CallRefLoTable[] = { - {0, "0"}, - {1, "1"}, - {2, "2"}, - {3, "3"}, - {4, "4"}, - {5, "5"}, - {6, "6"}, - {7, "7"}, - {8, "8"}, - {9, "9"}, - {10, "A"}, - {11, "B"}, - {12, "C"}, - {13, "D"}, - {14, "E"}, - {15, "F"}, - {-1, "?"}, -}; - -#define PROT_Q931_MSGTYPE_ALERTING 1 -#define PROT_Q931_MSGTYPE_PROCEEDING 2 -#define PROT_Q931_MSGTYPE_PROGRESS 3 -#define PROT_Q931_MSGTYPE_SETUP 5 -#define PROT_Q931_MSGTYPE_CONNECT 7 -#define PROT_Q931_MSGTYPE_SETUP_ACK 13 -#define PROT_Q931_MSGTYPE_CONNECT_ACK 15 -#define PROT_Q931_MSGTYPE_USER_INFO 32 -#define PROT_Q931_MSGTYPE_SUSPEND_REJ 33 -#define PROT_Q931_MSGTYPE_RESUME_REJ 34 -#define PROT_Q931_MSGTYPE_SUSPEND 37 -#define PROT_Q931_MSGTYPE_RESUME 38 -#define PROT_Q931_MSGTYPE_SUSPEND_ACK 45 -#define PROT_Q931_MSGTYPE_RESUME_ACK 46 -#define PROT_Q931_MSGTYPE_DISCONNECT 69 -#define PROT_Q931_MSGTYPE_RESTART 70 -#define PROT_Q931_MSGTYPE_RELEASE 77 -#define PROT_Q931_MSGTYPE_RESTART_ACK 78 -#define PROT_Q931_MSGTYPE_RELEASE_COMPLETE 90 -#define PROT_Q931_MSGTYPE_SEGMENT 96 -#define PROT_Q931_MSGTYPE_FACILITY 98 -#define PROT_Q931_MSGTYPE_NOTIFY 110 -#define PROT_Q931_MSGTYPE_STATUS_ENQUIRY 117 -#define PROT_Q931_MSGTYPE_CONGESTION_CNTRL 121 -#define PROT_Q931_MSGTYPE_INFORMATION 123 -#define PROT_Q931_MSGTYPE_STATUS 125 - - -struct code2str dcodQ931MsgTypeTable[] = { - {PROT_Q931_MSGTYPE_ALERTING, "ALERT"}, - {PROT_Q931_MSGTYPE_PROCEEDING, "PROCEED"}, - {PROT_Q931_MSGTYPE_PROGRESS, "PROGRESS"}, - {PROT_Q931_MSGTYPE_SETUP, "SETUP"}, - {PROT_Q931_MSGTYPE_CONNECT, "CONNECT"}, - {PROT_Q931_MSGTYPE_SETUP_ACK, "SETUP ACK"}, - {PROT_Q931_MSGTYPE_CONNECT_ACK, "CONNECT ACK"}, - {PROT_Q931_MSGTYPE_USER_INFO, "USER INFO"}, - {PROT_Q931_MSGTYPE_SUSPEND_REJ, "SUSPEND REJ"}, - {PROT_Q931_MSGTYPE_RESUME_REJ, "RESUME REJ"}, - {PROT_Q931_MSGTYPE_SUSPEND, "SUSPEND"}, - {PROT_Q931_MSGTYPE_RESUME, "RESUME"}, - {PROT_Q931_MSGTYPE_SUSPEND_ACK, "SUSPEND ACK"}, - {PROT_Q931_MSGTYPE_RESUME_ACK, "RESUME ACK"}, - {PROT_Q931_MSGTYPE_DISCONNECT, "DISCONNECT"}, - {PROT_Q931_MSGTYPE_RESTART, "RESTART"}, - {PROT_Q931_MSGTYPE_RELEASE, "RELEASE"}, - {PROT_Q931_MSGTYPE_RESTART_ACK, "RESTART ACK"}, - {PROT_Q931_MSGTYPE_RELEASE_COMPLETE, "RELEASE COMPLETE"}, - {PROT_Q931_MSGTYPE_SEGMENT, "SEGMENT"}, - {PROT_Q931_MSGTYPE_FACILITY, "FACILITY"}, - {PROT_Q931_MSGTYPE_NOTIFY, "NOTIFY"}, - {PROT_Q931_MSGTYPE_STATUS_ENQUIRY, "STATUS ENQ"}, - {PROT_Q931_MSGTYPE_CONGESTION_CNTRL, "CONGESTION CTRL"}, - {PROT_Q931_MSGTYPE_INFORMATION, "INFO"}, - {PROT_Q931_MSGTYPE_STATUS, "STATUS"}, - {-1, "UNKNOWN"}, -}; - -struct code2str dcodQ931CauseCodeTable[] = { - {1, "Unallocated (unassigned) number"}, - {2, "No route to specified network"}, - {3, "No route to destination"}, - {4, "Send special information tone"}, - {5, "Misdialed trunk prefix"}, - {6, "Channel Unacceptable"}, - {7, "Call awarded and channel established"}, - {8, "Pre-emption"}, - {9, "Pre-emption-circuit reserved"}, - {16, "Normal call clearing"}, - {17, "User Busy"}, - {18, "No User Responding"}, - {19, "No Answer from User"}, - {20, "Subscriber Absent"}, - {21, "Call Rejected"}, - {22, "Number Changed"}, - {26, "Non-Selected User Clearing"}, - {27, "Destination Out-of-Order"}, - {28, "Invalid Number Format"}, - {29, "Facility Rejected"}, - {30, "Response to Status Enquiry"}, - {31, "Normal, Unspecified"}, - {34, "No Circuit/Channel Available"}, - {38, "Network Out-of-Order"}, - {39, "Permanent Frame Mode OOS"}, - {40, "Permanent Frame Mode Operational"}, - {41, "Temporary Failure"}, - {42, "Switching Equipment Congestion"}, - {43, "Access Information Discarded"}, - {44, "Requested Circuit/Channel not available"}, - {47, "Resource Unavailable, Unspecified"}, - {49, "Quality of Service not available"}, - {50, "Requested facility not subscribed"}, - {53, "Outgoing calls barred within CUG"}, - {55, "Incoming calls barred within CUG"}, - {57, "Bearer capability not authorized"}, - {58, "Bearer capability not presently available"}, - {62, "Inconsistency in access inf and subscriber"}, - {63, "Service or Option not available"}, - {65, "Bearer capability not implemented"}, - {66, "Channel type not implemented"}, - {69, "Requested facility not implemented"}, - {70, "Only restricted digital BC available"}, - {79, "Service or option not implemented"}, - {81, "Invalid call reference value"}, - {82, "Identified channel does not exist"}, - {83, "Suspended call exists"}, - {84, "Call identity in use"}, - {85, "No call suspended"}, - {86, "Call already cleared"}, - {87, "User not member of CUG"}, - {88, "Incompatible destination"}, - {90, "Non existent CUG"}, - {91, "Invalid transit network selection"}, - {95, "Invalid message, unspecified"}, - {96, "Mandatory IE missing"}, - {97, "Message type non-existent, not implemented"}, - {98, "Message not compatible with call state"}, - {99, "An IE or parameter does not exist"}, - {100, "Invalid IE contents"}, - {101, "Message not compatible with call state"}, - {102, "Recovery on timer expired"}, - {103, "Parameter non-existent, not impl"}, - {110, "Message with unrecognized parameter"}, - {111, "Protocol error, unspecified"}, - {127, "Interworking, unspecified"}, - {-1, "Unknown"}, -}; - -struct code2str dcodQ931IEIDTable[] = { - {PROT_Q931_IE_SEGMENTED_MESSAGE, "Segmented Message"}, - {PROT_Q931_IE_BEARER_CAP, "Bearer Capability"}, - {PROT_Q931_IE_CAUSE, "Cause"}, - {PROT_Q931_IE_CALL_IDENTITY, "Call Identity"}, - {PROT_Q931_IE_CALL_STATE, "Call State"}, - {PROT_Q931_IE_CHANNEL_ID, "Channel Id"}, - {PROT_Q931_IE_FACILITY, "Facility"}, - {PROT_Q931_IE_PROGRESS_IND, "Progress Indicator"}, - {PROT_Q931_IE_NETWORK_SPF_FACILITY, "Network Specific Facilities"}, - {PROT_Q931_IE_NOTIFICATION_IND, "Notification Indicator"}, - {PROT_Q931_IE_DISPLAY, "Display"}, - {PROT_Q931_IE_DATE_TIME, "Date/Time"}, - {PROT_Q931_IE_KEYPAD_FACILITY, "Keypad Facility"}, - {PROT_Q931_IE_INFORMATION_REQUEST, "Information Request"}, - {PROT_Q931_IE_SIGNAL, "Signal"}, - {PROT_Q931_IE_SWITCHOOK, "Switchhook"}, - {PROT_Q931_IE_GENERIC_DIGITS, "Generic Digits"}, - {PROT_Q931_IE_FEATURE_ACT, "Feature Activation"}, - {PROT_Q931_IE_FEATURE_IND, "Feature Indication"}, - {PROT_Q931_IE_INFORMATION_RATE, "Information Rate"}, - {PROT_Q931_IE_END_TO_END_TRANSIT_DELAY, "End-to-end Transit Delay"}, - {PROT_Q931_IE_TRANSIT_DELAY_SELECT_IND, "Transit Delay Selection and Indication"}, - {PROT_Q931_IE_PACKET_LAYER_BINARY_PARAMS, "Packet layer binary parameters"}, - {PROT_Q931_IE_PACKET_LAYER_WINDOW_SIZE, "Packet layer Window Size"}, - {PROT_Q931_IE_PACKET_LAYER_SIZE, "Packet layer Size"}, - {PROT_Q931_IE_CALLING_PARTY_NUMBER, "Calling Party Number"}, - {PROT_Q931_IE_CALLING_PARTY_SUBADDRESS, "Calling Party Subaddress"}, - {PROT_Q931_IE_CALLED_PARTY_NUMBER, "Called Party Number"}, - {PROT_Q931_IE_CALLED_PARTY_SUBADDRESS, "Called Party Subaddress"}, - {PROT_Q931_IE_REDIRECTING_NUMBER, "Redirecting Number"}, - {PROT_Q931_IE_REDIRECTION_NUMBER, "Redirection Number"}, - {PROT_Q931_IE_TRANSIT_NETWORK_SELECTION, "Transit Network Selection"}, - {PROT_Q931_IE_RESTART_IND, "Restart Indicator"}, - {PROT_Q931_IE_LOW_LAYER_COMPAT, "Low-Layer Compatibility"}, - {PROT_Q931_IE_HIGH_LAYER_COMPAT, "High-Layer Compatibility"}, - {PROT_Q931_IE_USER_USER, "User-User"}, - {PROT_Q931_IE_SENDING_COMPLETE, "Sending complete"}, - {PROT_Q931_IE_ESCAPE_FOR_EXTENSION, "Escape for extension"}, - {-1,"Unknown"}, -}; - -struct code2str dcodQ931NumberingPlanTable[] = { - {0, "unknown"}, - {1, "isdn"}, - {3, "data"}, - {4, "telex"}, - {8, "national"}, - {9, "private"}, - {15, "reserved"}, - {-1, "invalid"}, -}; - -struct code2str dcodQ931TypeofNumberTable[] = { - {0, "unknown"}, - {1, "international"}, - {2, "national"}, - {3, "network spf"}, - {4, "subscriber"}, - {6, "abbreviated"}, - {7, "reserved"}, - {-1, "invalid" }, -}; - -struct code2str dcodQ931PresentationTable[] = { - {0, "allowed"}, - {1, "restricted"}, - {2, "not available"}, - {-1, "invalid" }, -}; - -struct code2str dcodQ931ScreeningTable[] = { - {0, "user, not screened"}, - {1, "user, passed"}, - {2, "user, failed"}, - {3, "network, provided"}, - {-1, "invalid" }, -}; - -struct code2str dcodQ931InfoChannelSelTable[] = { - {0, "No Chan"}, - {1, "B1"}, - {2, "B2"}, - {3, "Any Chan"}, - {-1, "invalid" }, -}; - -struct code2str dcodQ931ReasonTable[] = { - {0x0, "Unknown"}, - {0x1, "Call forwarding busy"}, - {0x2, "Call forwarding no reply"}, - {0x4, "Call deflection"}, - {0x9, "Called DTE out of order"}, - {0xA, "Call forwarding by the called DTE"}, - {0xF, "Call forwarding unconditional"}, - {-1, "reserved" }, -}; - -struct code2str dcodQ931BcCodingStandardTable[] = { - {0x0, "ITU-T"}, - {0x1, "ISO/IEC"}, - {0x2, "National"}, - {0x3, "Defined standard"}, - {-1, "unknown"}, -}; - -struct code2str dcodQ931BcInfTransferCapTable[] = { - {0x00, "Speech"}, - {0x08, "Unrestricted digital"}, - {0x09, "Restricted digital"}, - {0x10, "3.1Khz audio"}, - {0x11, "Unrestricted digital w/ tones"}, - {0x18, "Video"}, - {-1, "reserved"}, -}; - -struct code2str dcodQ931BcInfTransferRateTable[] = { - {0x00, "n/a"}, /* for packet-mode calls */ - {0x10, "64 Kbit/s"}, - {0x11, "2x64 Kbit/s"}, - {0x13, "384 Kbit/s"}, - {0x15, "1536 Kbit/s"}, - {0x17, "1920 Kbit/s"}, - {0x18, "Multirate"}, - {-1, "reserved"}, -}; - - -struct code2str dcodQ931BcusrL1ProtTable[] = { - {0x01, "ITU-T rate/V.110/I.460/X.30"}, - {0x02, "G.711 u-Law"}, - {0x03, "G.711 A-Law"}, - {0x04, "G.721/I.460"}, - {0x05, "H.221/H.242"}, - {0x06, "H.223/H.245"}, - {0x07, "Non-ITU-T rate"}, - {0x08, "V.120"}, - {0x09, "X.31 HDLC"}, - {-1, "reserved"}, -}; - -struct code2str dcodQ931UuiProtDiscrTable[] = { - {0x00, "User-specific"}, - {0x01, "OSI high layer prot"}, - {0x02, "Recommendation X.244"}, - {0x03, "System management"}, - {0x04, "IA5 Chars"}, - {0x05, "X.208/X.209"}, - {0x07, "V.120"}, - {0x08, "Q.931/I.451"}, - {0x10, "X.25"}, - {-1,"reserved"}, -}; - -struct code2str dcodQ931ChanTypeTable[] = { - {0x3,"B-chans"}, - {0x6,"H0-chans"}, - {0x8,"H11-chans"}, - {0x9,"H12-chans"}, - {-1,"reserved"}, -}; - -struct code2str dcodQ931RestartIndClassTable[] = { - {0x0 ,"Indicated in channel IE"}, - {0x6 ,"Single interface"}, - {0x7 ,"All interfaces"}, - {-1, "reserved"}, -}; - -struct code2str dcodQ931IelocationTable[] = { - {0x0, "User"}, - {0x1, "Private network, local user"}, - {0x2, "Public network, local user"}, - {0x3, "Transit network"}, - {0x4, "Public network, remote user"}, - {0x5, "Private network, remote user"}, - {0xA, "Beyond interworking point"}, - {-1, "reserved"}, -}; - -struct code2str dcodQ931IeprogressDescrTable[] = { - {0x01, "Further info maybe available"}, - {0x02, "Destination is non-ISDN"}, - {0x03, "Origination address is non-ISDN"}, - {0x04, "Call returned to ISDN"}, - {0x08, "In-band data ready"}, - {-1, "reserved"}, -}; - -struct code2str dcodQ931IeFacilityProtProfileTable[] = { - {0x11, "Remote Operations Protocol"}, - {0x12, "CMIP Protocol"}, - {0x13, "ACSE Protocol"}, - {0x16, "GAT Protocol"}, - {0x1F, "Networking Extensions"}, - {-1, "reserved"}, -}; - -//from www.voip-info.org/wiki/ANI2 - NANPA -struct code2str dcodQ931LineInfoTable[] = { - {0, "Plain Old Telephone Service(POTS)" }, - {1, "Multiparty line"}, - {2, "ANI Failure"}, - {6, "Station Level Rating"}, - {7, "Special Operator Handling Required"}, - {20, "Automatic Identified Outward Dialing (AIOD)"}, - {23, "Coin or Non-coin"}, - {24, "Toll free service, POTS originated for non-pay station"}, - {25, "Toll free service, POTS originated for pay station"}, - {27, "Pay station with coin control"}, - {29, "Prison-Inmate service"}, - {30, "Intercept - blank"}, - {31, "Intercept - trouble"}, - {32, "Intercept - regular"}, - {34, "Telco operator handled call"}, - {52, "Outward Wide Area Telecommunications Service(OUTWATS)"}, - {60, "TRS call - from unrestricted line"}, - {61, "Cellular-Wireless PCS Type 1"}, - {62, "Cellular-Wireless PCS Type 2"}, - {63, "Cellular-Wireless PCS Type Roaming"}, - {66, "TRS call - from hotel/motel"}, - {67, "TRS call - from restricted line"}, - {70, "Line connected to pay station"}, - {93, "Private virtual network call"}, - {-1, "Unassigned"}, -}; - - -struct code2str dcodQ931GenDigitsEncodingTable[] = { - {0, "BCD even"}, - {1, "BCD odd"}, - {2, "IA5"}, - {3, "Binary"}, - {-1, "Invalid"}, -}; - - -struct code2str dcodQ931GenDigitsTypeTable[] = { - { 0, "Account Code"}, - { 1, "Auth Code"}, - { 2, "Customer ID" }, - { 3, "Universal Access"}, - { 4, "Info Digits"}, - { 5, "Callid"}, - { 6, "Opart"}, - { 7, "TCN"}, - { 9, "Adin"}, - {-1, "Invalid"}, -}; - -struct code2str dcodQ931TypeOfSubaddressTable[] = { - { 0x00, "NSAP"}, - { 0x02, "User-specified"}, - { -1, "Invalid"}, -}; - -struct code2str dcodQ931DisplayTypeTable[] = { - { 0x00, "Calling Party Name"}, - { 0x01, "Connected Party Name"}, - { 0x05, "Original Called Party Name"}, - { -1, "Invalid"}, -}; - -struct code2str dcodQ931AssocInfoTable[] = { - { 0x00, "Requested"}, - { 0x03, "Included"}, - { -1, "Invalid"}, -}; - - -struct code2str dcodQ931NotificationIndTable[] = { - { 0x71, "Call Information/event"}, - { -1, "Invalid"}, -}; -#endif /* __FTMOD_SANGOMA_ISDN_TRACE_H__ */ diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_transfer.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_transfer.c deleted file mode 100644 index 5df54f48ea..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_transfer.c +++ /dev/null @@ -1,281 +0,0 @@ -/* - * Copyright (c) 2011, Sangoma Technologies - * David Yat Sin - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "ftmod_sangoma_isdn.h" - -#define TRANSFER_FUNC(name) ftdm_status_t (name)(ftdm_channel_t *ftdmchan, sngisdn_transfer_type_t type, char* target) - -#define SNGISDN_ATT_TRANSFER_RESPONSE_CP_DROP_OFF "**1" -#define SNGISDN_ATT_TRANSFER_RESPONSE_LIMITS_EXCEEDED "**5" -#define SNGISDN_ATT_TRANSFER_RESPONSE_OK "**6" -#define SNGISDN_ATT_TRANSFER_RESPONSE_INVALID_NUM "**7" -#define SNGISDN_ATT_TRANSFER_RESPONSE_INVALID_COMMAND "**8" - - -void att_courtesy_transfer_complete(sngisdn_chan_data_t *sngisdn_info, ftdm_transfer_response_t response); -void att_courtesy_transfer_timeout(void* p_sngisdn_info); -static ftdm_status_t att_courtesy_vru(ftdm_channel_t *ftdmchan, sngisdn_transfer_type_t type, char* target); - -typedef struct transfer_interfaces { - const char *name; - sngisdn_transfer_type_t type; - TRANSFER_FUNC(*func); -}transfer_interface_t; - -static transfer_interface_t transfer_interfaces[] = { - /* AT&T TR-50075 Courtesy Transfer - VRU -- No Data (Section 4.3) */ - { "ATT_COURTESY_TRANSFER_V", SNGISDN_TRANSFER_ATT_COURTESY_VRU, att_courtesy_vru}, - /* AT&T TR-50075 Courtesy Transfer - VRU --Data (Section 4.4) */ - { "ATT_COURTESY_TRANSFER_V_DATA", SNGISDN_TRANSFER_ATT_COURTESY_VRU_DATA, att_courtesy_vru}, -}; - -void att_courtesy_transfer_complete(sngisdn_chan_data_t *sngisdn_info, ftdm_transfer_response_t response) -{ - ftdm_channel_t *ftdmchan = sngisdn_info->ftdmchan; - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_RX_DISABLED); - ftdm_channel_command(ftdmchan, FTDM_COMMAND_DISABLE_DTMF_DETECT, NULL); - - sngisdn_info->transfer_data.type = SNGISDN_TRANSFER_NONE; - sngisdn_info->transfer_data.response = response; - - ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Transfer Complete:%s\n", ftdm_transfer_response2str(sngisdn_info->transfer_data.response)); - sngisdn_send_signal(sngisdn_info, FTDM_SIGEVENT_TRANSFER_COMPLETED); - - ftdm_channel_command(ftdmchan, FTDM_COMMAND_FLUSH_RX_BUFFERS, NULL); - return; -} - -void att_courtesy_transfer_timeout(void* p_sngisdn_info) -{ - sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*)p_sngisdn_info; - ftdm_channel_t *ftdmchan = sngisdn_info->ftdmchan; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; - - ftdm_mutex_lock(ftdmchan->mutex); - if (sngisdn_info->transfer_data.type == SNGISDN_TRANSFER_NONE) { - /* Call was already cleared */ - ftdm_mutex_unlock(ftdmchan->mutex); - return; - } - - ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "AT&T Courtesy Transfer timeout (%d)\n", signal_data->transfer_timeout); - att_courtesy_transfer_complete(sngisdn_info, FTDM_TRANSFER_RESPONSE_TIMEOUT); - ftdm_mutex_unlock(ftdmchan->mutex); - return; -} - -static ftdm_status_t att_courtesy_vru(ftdm_channel_t *ftdmchan, sngisdn_transfer_type_t type, char* args) -{ - char dtmf_digits[64]; - ftdm_status_t status = FTDM_FAIL; - sngisdn_chan_data_t *sngisdn_info = ftdmchan->call_data; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; - char *p = args; - uint8_t forced_answer = 0; - - switch (signal_data->switchtype) { - case SNGISDN_SWITCH_5ESS: - case SNGISDN_SWITCH_4ESS: - break; - default: - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "AT&T Courtesy Transfer not supported for switchtype\n"); - return FTDM_FAIL; - } - - while (!ftdm_strlen_zero(p)) { - if (!isdigit(*p) && *p != 'w' && *p != 'W') { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Cannot transfer to non-numeric number:%s\n", args); - return FTDM_FAIL; - } - p++; - } - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Performing AT&T Courtesy Transfer-VRU%s to %s\n", (type == SNGISDN_TRANSFER_ATT_COURTESY_VRU_DATA) ?"--data" : "", args); - sprintf(dtmf_digits, "*8w%s", args); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Sending digits %s\n", dtmf_digits); - - switch (ftdmchan->last_state) { - case FTDM_CHANNEL_STATE_PROCEED: - case FTDM_CHANNEL_STATE_PROGRESS: - case FTDM_CHANNEL_STATE_PROGRESS_MEDIA: - /* Call has to be in answered state - so send a CONNECT message if we did not answer this call yet */ - forced_answer++; - sngisdn_snd_connect(ftdmchan); - /* fall-through */ - case FTDM_CHANNEL_STATE_UP: - memset(&sngisdn_info->transfer_data.tdata.att_courtesy_vru.dtmf_digits, 0, sizeof(sngisdn_info->transfer_data.tdata.att_courtesy_vru.dtmf_digits)); - sngisdn_info->transfer_data.type = type; - - /* We will be polling the channel for IO so that we can receive the DTMF events, - * Disable user RX otherwise it is a race between who calls channel_read */ - ftdm_set_flag(ftdmchan, FTDM_CHANNEL_RX_DISABLED); - - ftdm_channel_command(ftdmchan, FTDM_COMMAND_ENABLE_DTMF_DETECT, NULL); - ftdm_channel_command(ftdmchan, FTDM_COMMAND_SEND_DTMF, dtmf_digits); - - if (type == SNGISDN_TRANSFER_ATT_COURTESY_VRU_DATA) { - /* We need to save transfer data, so we can send it in the disconnect msg */ - const char *val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "transfer_data"); - if (ftdm_strlen_zero(val)) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "Cannot perform data transfer because transfer_data variable is not set\n"); - goto done; - } - if (strlen(val) > COURTESY_TRANSFER_MAX_DATA_SIZE) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Data exceeds max size (len:%"FTDM_SIZE_FMT" max:%d), cannot perform transfer\n", strlen(val), COURTESY_TRANSFER_MAX_DATA_SIZE); - goto done; - } - memcpy(sngisdn_info->transfer_data.tdata.att_courtesy_vru.data, val, strlen(val)); - } - - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_UP); - if (forced_answer) { - /* Notify the user that we answered the call */ - sngisdn_send_signal(sngisdn_info, FTDM_SIGEVENT_UP); - } - if (signal_data->transfer_timeout) { - ftdm_sched_timer(((sngisdn_span_data_t*)ftdmchan->span->signal_data)->sched, "courtesy_transfer_timeout", signal_data->transfer_timeout, att_courtesy_transfer_timeout, (void*) sngisdn_info, &sngisdn_info->timers[SNGISDN_CHAN_TIMER_ATT_TRANSFER]); - } - - status = FTDM_SUCCESS; - break; - default: - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Cannot perform transfer in state %s\n", ftdm_channel_state2str(ftdmchan->state)); - break; - - } -done: - return status; -} - - -ftdm_status_t sngisdn_transfer(ftdm_channel_t *ftdmchan) -{ - const char* args; - char *p; - char *type = NULL; - char *target = NULL; - ftdm_status_t status = FTDM_FAIL; - sngisdn_chan_data_t *sngisdn_info = ftdmchan->call_data; - unsigned i; - - args = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "transfer_arg"); - if (ftdm_strlen_zero(args)) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "Cannot perform transfer because call_transfer_arg variable is not set\n"); - goto done; - } - - type = ftdm_strdup(args); - if ((p = strchr(type, '/'))) { - target = ftdm_strdup(p+1); - *p = '\0'; - } - - if (ftdm_strlen_zero(type) || ftdm_strlen_zero(target)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Invalid parameters for transfer %s, expected /\n", args); - goto done; - } - - if (sngisdn_info->transfer_data.type != SNGISDN_TRANSFER_NONE) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Cannot perform transfer because an existing transfer transfer is pending (%s)\n", sngisdn_transfer_type2str(sngisdn_info->transfer_data.type)); - goto done; - } - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Transfer requested type:%s target:%s\n", type, target); - for (i = 0; i < ftdm_array_len(transfer_interfaces); i++ ) { - if (!strcasecmp(transfer_interfaces[i].name, type)) { - /* Depending on the transfer type, the transfer function may change the - * channel state to UP, or last_state, but the transfer function will always result in - * an immediate state change if FTDM_SUCCESS is returned */ - - status = transfer_interfaces[i].func(ftdmchan, transfer_interfaces[i].type, target); - goto done; - } - } - - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Invalid transfer type:%s\n", type); - -done: - if (status != FTDM_SUCCESS) { - ftdm_set_state(ftdmchan, ftdmchan->last_state); - } - - ftdm_safe_free(type); - ftdm_safe_free(target); - return status; -} - -ftdm_status_t sngisdn_att_transfer_process_dtmf(ftdm_channel_t *ftdmchan, const char* dtmf) -{ - ftdm_status_t status = FTDM_SUCCESS; - sngisdn_chan_data_t *sngisdn_info = ftdmchan->call_data; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; - char *dtmf_digits = sngisdn_info->transfer_data.tdata.att_courtesy_vru.dtmf_digits; - ftdm_size_t dtmf_digits_len = strlen(dtmf_digits); - - dtmf_digits_len += sprintf(&dtmf_digits[dtmf_digits_len], "%s", dtmf); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Transfer response digits:%s\n", dtmf_digits); - if (dtmf_digits_len == 3) { - if (!strcmp(dtmf_digits, SNGISDN_ATT_TRANSFER_RESPONSE_CP_DROP_OFF)) { - sngisdn_info->transfer_data.response = FTDM_TRANSFER_RESPONSE_CP_DROP_OFF; - } else if (!strcmp(dtmf_digits, SNGISDN_ATT_TRANSFER_RESPONSE_LIMITS_EXCEEDED)) { - sngisdn_info->transfer_data.response = FTDM_TRANSFER_RESPONSE_LIMITS_EXCEEDED; - } else if (!strcmp(dtmf_digits, SNGISDN_ATT_TRANSFER_RESPONSE_OK)) { - sngisdn_info->transfer_data.response = FTDM_TRANSFER_RESPONSE_OK; - } else if (!strcmp(dtmf_digits, SNGISDN_ATT_TRANSFER_RESPONSE_INVALID_NUM)) { - sngisdn_info->transfer_data.response = FTDM_TRANSFER_RESPONSE_INVALID_NUM; - } else if (!strcmp(dtmf_digits, SNGISDN_ATT_TRANSFER_RESPONSE_INVALID_COMMAND)) { - sngisdn_info->transfer_data.response = FTDM_TRANSFER_RESPONSE_INVALID_COMMAND; - } else { - sngisdn_info->transfer_data.response = FTDM_TRANSFER_RESPONSE_INVALID; - } - if (signal_data->transfer_timeout) { - ftdm_sched_cancel_timer(signal_data->sched, sngisdn_info->timers[SNGISDN_CHAN_TIMER_ATT_TRANSFER]); - } - - if (sngisdn_info->transfer_data.response == FTDM_TRANSFER_RESPONSE_OK && - sngisdn_info->transfer_data.type == SNGISDN_TRANSFER_ATT_COURTESY_VRU_DATA) { - sngisdn_set_flag(sngisdn_info, FLAG_SEND_DISC); - ftdmchan->caller_data.hangup_cause = FTDM_CAUSE_NORMAL_CLEARING; - sngisdn_snd_disconnect(ftdmchan); - } - /* Network side will send disconnect in case of NO-DATA Transfer */ - att_courtesy_transfer_complete(sngisdn_info, sngisdn_info->transfer_data.response); - } - - if (signal_data->att_remove_dtmf != SNGISDN_OPT_FALSE) { - /* If we return FTDM_BREAK, dtmf event is not queue'ed to user */ - status = FTDM_BREAK; - } - return status; -} diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_user.h b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_user.h deleted file mode 100644 index 74abeef94c..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_user.h +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (c) 2010, Sangoma Technologies - * David Yat Sin - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __FTMOD_SANGOMA_ISDN_USER_H__ -#define __FTMOD_SANGOMA_ISDN_USER_H__ - - -#define SNGISDN_ENUM_NAMES(_NAME, _STRINGS) static const char * _NAME [] = { _STRINGS , NULL }; -#define SNGISDN_STR2ENUM_P(_FUNC1, _FUNC2, _TYPE) _TYPE _FUNC1 (const char *name); const char * _FUNC2 (_TYPE type); -#define SNGISDN_STR2ENUM(_FUNC1, _FUNC2, _TYPE, _STRINGS, _MAX) \ - _TYPE _FUNC1 (const char *name) \ - { \ - int i; \ - _TYPE t = _MAX ; \ - \ - for (i = 0; i < _MAX ; i++) { \ - if (!strcasecmp(name, _STRINGS[i])) { \ - t = (_TYPE) i; \ - break; \ - } \ - } \ - return t; \ - } \ - const char * _FUNC2 (_TYPE type) \ - { \ - if (type > _MAX) { \ - type = _MAX; \ - } \ - return _STRINGS[(int)type]; \ - } \ - - -typedef enum { - /* Call is not end-to-end ISDN */ - SNGISDN_PROGIND_DESCR_NETE_ISDN, - /* Destination address is non-ISDN */ - SNGISDN_PROGIND_DESCR_DEST_NISDN, - /* Origination address is non-ISDN */ - SNGISDN_PROGIND_DESCR_ORIG_NISDN, - /* Call has returned to the ISDN */ - SNGISDN_PROGIND_DESCR_RET_ISDN, - /* Interworking as occured and has resulted in a telecommunication service change */ - SNGISDN_PROGIND_DESCR_SERV_CHANGE, - /* In-band information or an appropriate pattern is now available */ - SNGISDN_PROGIND_DESCR_IB_AVAIL, - /* Invalid */ - SNGISDN_PROGIND_DESCR_INVALID, -} ftdm_sngisdn_progind_descr_t; -#define SNGISDN_PROGIND_DESCR_STRINGS "not-end-to-end-isdn", "destination-is-non-isdn", "origination-is-non-isdn", "call-returned-to-isdn", "service-change", "inband-info-available", "invalid" -SNGISDN_STR2ENUM_P(ftdm_str2ftdm_sngisdn_progind_descr, ftdm_sngisdn_progind_descr2str, ftdm_sngisdn_progind_descr_t); - - -typedef enum { - /* User */ - SNGISDN_PROGIND_LOC_USER, - /* Private network serving the local user */ - SNGISDN_PROGIND_LOC_PRIV_NET_LOCAL_USR, - /* Public network serving the local user */ - SNGISDN_PROGIND_LOC_PUB_NET_LOCAL_USR, - /* Transit network */ - SNGISDN_PROGIND_LOC_TRANSIT_NET, - /* Public network serving remote user */ - SNGISDN_PROGIND_LOC_PUB_NET_REMOTE_USR, - /* Private network serving remote user */ - SNGISDN_PROGIND_LOC_PRIV_NET_REMOTE_USR, - /* Network beyond the interworking point */ - SNGISDN_PROGIND_LOC_NET_BEYOND_INTRW, - /* Invalid */ - SNGISDN_PROGIND_LOC_INVALID, -} ftdm_sngisdn_progind_loc_t; -#define SNGISDN_PROGIND_LOC_STRINGS "user", "private-net-local-user", "public-net-local-user", "transit-network", "public-net-remote-user", "private-net-remote-user", "beyond-interworking", "invalid" -SNGISDN_STR2ENUM_P(ftdm_str2ftdm_sngisdn_progind_loc, ftdm_sngisdn_progind_loc2str, ftdm_sngisdn_progind_loc_t); - -typedef enum { - /* User Specified */ - SNGISDN_NETSPECFAC_TYPE_USER_SPEC, - /* National network identification */ - SNGISDN_NETSPECFAC_TYPE_NATIONAL_NETWORK_IDENT, - /* International network identification */ - SNGISDN_NETSPECFAC_TYPE_INTERNATIONAL_NETWORK_IDENT, - /* Invalid */ - SNGISDN_NETSPECFAC_TYPE_INVALID, -} ftdm_sngisdn_netspecfac_type_t; -#define SNGISDN_NETSPECFAC_TYPE_STRINGS "user-specified", "national-network-identification", "national-network-identification", "invalid" -SNGISDN_STR2ENUM_P(ftdm_str2ftdm_sngisdn_netspecfac_type, ftdm_sngisdn_netspecfac_type2str, ftdm_sngisdn_netspecfac_type_t); - -typedef enum { - /* Unknown */ - SNGISDN_NETSPECFAC_PLAN_UNKNOWN, - /* Carrier Identification Code */ - SNGISDN_NETSPECFAC_PLAN_CARRIER_IDENT, - /* Data network identification code */ - SNGISDN_NETSPECFAC_PLAN_DATA_NETWORK_IDENT, - /* Invalid */ - SNGISDN_NETSPECFAC_PLAN_INVALID, -} ftdm_sngisdn_netspecfac_plan_t; -#define SNGISDN_NETSPECFAC_PLAN_STRINGS "unknown", "carrier-identification", "data-network-identification", "invalid" -SNGISDN_STR2ENUM_P(ftdm_str2ftdm_sngisdn_netspecfac_plan, ftdm_sngisdn_netspecfac_plan2str, ftdm_sngisdn_netspecfac_plan_t); - -typedef enum { - /* Unknown */ - SNGISDN_NETSPECFAC_SPEC_ACCUNET, - SNGISDN_NETSPECFAC_SPEC_MEGACOM, - SNGISDN_NETSPECFAC_SPEC_MEGACOM_800, - SNGISDN_NETSPECFAC_SPEC_SDDN, - SNGISDN_NETSPECFAC_SPEC_INVALID, -} ftdm_sngisdn_netspecfac_spec_t; -#define SNGISDN_NETSPECFAC_SPEC_STRINGS "accunet", "megacom", "megacom-800", "sddn", "invalid" -SNGISDN_STR2ENUM_P(ftdm_str2ftdm_sngisdn_netspecfac_spec, ftdm_sngisdn_netspecfac_spec2str, ftdm_sngisdn_netspecfac_spec_t); - -#endif /* __FTMOD_SANGOMA_ISDN_USER_H__*/ - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ - -/******************************************************************************/ diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c deleted file mode 100644 index 1210e39bb0..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c +++ /dev/null @@ -1,1745 +0,0 @@ -/* - * Copyright (c) 2009|Konrad Hammel - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE|EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* INCLUDE ********************************************************************/ -#include "ftmod_sangoma_ss7_main.h" -/******************************************************************************/ - -/* DEFINES ********************************************************************/ -/******************************************************************************/ - -/* GLOBALS ********************************************************************/ -/******************************************************************************/ - -/* PROTOTYPES *****************************************************************/ -int ft_to_sngss7_cfg_all(void); - -int ftmod_ss7_relay_gen_config(void); -int ftmod_ss7_mtp1_gen_config(void); -int ftmod_ss7_mtp2_gen_config(void); -int ftmod_ss7_mtp3_gen_config(void); -int ftmod_ss7_isup_gen_config(void); -int ftmod_ss7_cc_gen_config(void); - -int ftmod_ss7_mtp1_psap_config(int id); - -int ftmod_ss7_mtp2_dlsap_config(int id); - -int ftmod_ss7_mtp3_dlsap_config(int id); -int ftmod_ss7_mtp3_nsap_config(int id); -int ftmod_ss7_mtp3_linkset_config(int id); -int ftmod_ss7_mtp3_route_config(int id); - -int ftmod_ss7_isup_nsap_config(int id); -int ftmod_ss7_isup_intf_config(int id); -int ftmod_ss7_isup_ckt_config(int id); -int ftmod_ss7_isup_isap_config(int id); - -int ftmod_ss7_cc_isap_config(int id); - -int ftmod_ss7_relay_chan_config(int id); -/******************************************************************************/ - -/* FUNCTIONS ******************************************************************/ -int ft_to_sngss7_cfg_all(void) -{ - int x = 0; - int ret = 0; - - /* check if we have done gen_config already */ - if (g_ftdm_sngss7_data.gen_config == SNG_GEN_CFG_STATUS_INIT) { - /* update the global gen_config so we don't do it again */ - g_ftdm_sngss7_data.gen_config = SNG_GEN_CFG_STATUS_PENDING; - - /* start of by checking if the license and sig file are valid */ - if (sng_validate_license(g_ftdm_sngss7_data.cfg.license, - g_ftdm_sngss7_data.cfg.signature)) { - - SS7_CRITICAL("License verification failed..ending!\n"); - return 1; - } - - /* if the procId is not 0 then we are using relay mode */ - if (g_ftdm_sngss7_data.cfg.procId != 0) { - /* set the desired procID value */ - sng_set_procId((uint16_t)g_ftdm_sngss7_data.cfg.procId); - } - - /* start up the stack manager */ - if (sng_isup_init_sm()) { - SS7_CRITICAL("Failed to start Stack Manager\n"); - return 1; - } else { - SS7_INFO("Started Stack Manager!\n"); - sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_SM_STARTED); - } - - /* check if the configuration had a Relay Channel */ - if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_RY_PRESENT)) { - /* start up the relay task */ - if (sng_isup_init_relay()) { - SS7_CRITICAL("Failed to start Relay\n"); - return 1; - } else { - SS7_INFO("Started Relay!\n"); - sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_RY_STARTED); - } - - /* run general configuration on the relay task */ - if (ftmod_ss7_relay_gen_config()) { - SS7_CRITICAL("Relay General configuration FAILED!\n"); - return 1; - } else { - SS7_INFO("Relay General configuration DONE\n"); - } - - } /* if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_RY)) */ - - if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_CC_PRESENT)) { - if (sng_isup_init_cc()) { - SS7_CRITICAL("Failed to start Call-Control\n"); - return 1; - } else { - SS7_INFO("Started Call-Control!\n"); - sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_CC_STARTED); - } - if (ftmod_ss7_cc_gen_config()) { - SS7_CRITICAL("CC General configuration FAILED!\n"); - return 1; - } else { - SS7_INFO("CC General configuration DONE\n"); - } - if (ftmod_ss7_cc_isap_config(1)) { - SS7_CRITICAL("CC ISAP configuration FAILED!\n"); - return 1; - } else { - SS7_INFO("CC ISAP configuration DONE!\n"); - } - } /* if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_CC)) */ - - if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_ISUP_PRESENT)) { - if (sng_isup_init_isup()) { - SS7_CRITICAL("Failed to start ISUP\n"); - return 1; - } else { - SS7_INFO("Started ISUP!\n"); - sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_ISUP_STARTED); - } - if (ftmod_ss7_isup_gen_config()) { - SS7_CRITICAL("ISUP General configuration FAILED!\n"); - return 1; - } else { - SS7_INFO("ISUP General configuration DONE\n"); - } - } /* if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_ISUP)) */ - - if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP3_PRESENT)) { - if (sng_isup_init_mtp3()) { - SS7_CRITICAL("Failed to start MTP3\n"); - return 1; - } else { - SS7_INFO("Started MTP3!\n"); - sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP3_STARTED); - } - - if (ftmod_ss7_mtp3_gen_config()) { - SS7_CRITICAL("MTP3 General configuration FAILED!\n"); - return 1; - } else { - SS7_INFO("MTP3 General configuration DONE\n"); - } - } /* if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP3)) */ - - if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP2_PRESENT)) { - if (sng_isup_init_mtp2()) { - SS7_CRITICAL("Failed to start MTP2\n"); - return 1; - } else { - SS7_INFO("Started MTP2!\n"); - sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP2_STARTED); - } - if (sng_isup_init_mtp1()) { - SS7_CRITICAL("Failed to start MTP1\n"); - return 1; - } else { - SS7_INFO("Started MTP1!\n"); - sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP1_STARTED); - } - if (ftmod_ss7_mtp1_gen_config()) { - SS7_CRITICAL("MTP1 General configuration FAILED!\n"); - return 1; - } else { - SS7_INFO("MTP1 General configuration DONE\n"); - } - if (ftmod_ss7_mtp2_gen_config()) { - SS7_CRITICAL("MTP2 General configuration FAILED!\n"); - return 1; - } else { - SS7_INFO("MTP2 General configuration DONE\n"); - } - } /* if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP2)) */ - - if(SNG_SS7_OPR_MODE_M2UA_SG == g_ftdm_operating_mode){ - if(FTDM_SUCCESS != ftmod_ss7_m2ua_init()){ - ftdm_log (FTDM_LOG_ERROR, "ftmod_ss7_m2ua_init FAILED \n"); - return FTDM_FAIL; - } - } - - g_ftdm_sngss7_data.gen_config = SNG_GEN_CFG_STATUS_DONE; - - } /* if (!(g_ftdm_sngss7_data.gen_config)) */ - - - if (g_ftdm_sngss7_data.gen_config != SNG_GEN_CFG_STATUS_DONE) { - SS7_CRITICAL("General configuration FAILED!\n"); - return 1; - } - - x = 1; - while (x < (MAX_MTP_LINKS)) { - /* check if this link has been configured already */ - if ((g_ftdm_sngss7_data.cfg.mtp1Link[x].id != 0) && - (!(g_ftdm_sngss7_data.cfg.mtp1Link[x].flags & SNGSS7_CONFIGURED))) { - - /* configure mtp1 */ - if (ftmod_ss7_mtp1_psap_config(x)) { - SS7_CRITICAL("MTP1 PSAP %d configuration FAILED!\n", x); - return 1;; - } else { - SS7_INFO("MTP1 PSAP %d configuration DONE!\n", x); - } - - /* set the SNGSS7_CONFIGURED flag */ - g_ftdm_sngss7_data.cfg.mtp1Link[x].flags |= SNGSS7_CONFIGURED; - } - x++; - } /* while (x < (MAX_MTP_LINKS+1)) */ - - x = 1; - while (x < (MAX_MTP_LINKS)) { - /* check if this link has been configured already */ - if ((g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) && - (!(g_ftdm_sngss7_data.cfg.mtp2Link[x].flags & SNGSS7_CONFIGURED))) { - - /* configure mtp2 */ - if (ftmod_ss7_mtp2_dlsap_config(x)) { - SS7_CRITICAL("MTP2 DLSAP %d configuration FAILED!\n",x); - return 1;; - } else { - SS7_INFO("MTP2 DLSAP %d configuration DONE!\n", x); - } - - /* set the SNGSS7_CONFIGURED flag */ - g_ftdm_sngss7_data.cfg.mtp2Link[x].flags |= SNGSS7_CONFIGURED; - } - x++; - } /* while (x < (MAX_MTP_LINKS+1)) */ - - /* no configs above mtp2 for relay */ - if (g_ftdm_sngss7_data.cfg.procId == 1) { - x = 1; - while (x < (MAX_MTP_LINKS)) { - /* check if this link has been configured already */ - if ((g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) && - (!(g_ftdm_sngss7_data.cfg.mtp3Link[x].flags & SNGSS7_CONFIGURED))) { - - /* configure mtp3 */ - if (ftmod_ss7_mtp3_dlsap_config(x)) { - SS7_CRITICAL("MTP3 DLSAP %d configuration FAILED!\n", x); - return 1;; - } else { - SS7_INFO("MTP3 DLSAP %d configuration DONE!\n", x); - } - - /* set the SNGSS7_CONFIGURED flag */ - g_ftdm_sngss7_data.cfg.mtp3Link[x].flags |= SNGSS7_CONFIGURED; - } - - x++; - } /* while (x < (MAX_MTP_LINKS+1)) */ - - /* in M2UA_SG mode there will not be any MTP3 layer */ - if(SNG_SS7_OPR_MODE_M2UA_SG != g_ftdm_operating_mode){ - x = 1; - while (x < (MAX_NSAPS)) { - /* check if this link has been configured already */ - if ((g_ftdm_sngss7_data.cfg.nsap[x].id != 0) && - (!(g_ftdm_sngss7_data.cfg.nsap[x].flags & SNGSS7_CONFIGURED))) { - - ret = ftmod_ss7_mtp3_nsap_config(x); - if (ret) { - SS7_CRITICAL("MTP3 NSAP %d configuration FAILED!(%s)\n", x, DECODE_LCM_REASON(ret)); - return 1; - } else { - SS7_INFO("MTP3 NSAP %d configuration DONE!\n", x); - } - - ret = ftmod_ss7_isup_nsap_config(x); - if (ret) { - SS7_CRITICAL("ISUP NSAP %d configuration FAILED!(%s)\n", x, DECODE_LCM_REASON(ret)); - return 1; - } else { - SS7_INFO("ISUP NSAP %d configuration DONE!\n", x); - } - - /* set the SNGSS7_CONFIGURED flag */ - g_ftdm_sngss7_data.cfg.nsap[x].flags |= SNGSS7_CONFIGURED; - } /* if !SNGSS7_CONFIGURED */ - - x++; - } /* while (x < (MAX_NSAPS)) */ - } - - /* in M2UA_SG mode there will not be any MTP3 layer */ - if(SNG_SS7_OPR_MODE_M2UA_SG != g_ftdm_operating_mode){ - x = 1; - while (x < (MAX_MTP_LINKSETS+1)) { - /* check if this link has been configured already */ - if ((g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) && - (!(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].flags & SNGSS7_CONFIGURED))) { - - if (ftmod_ss7_mtp3_linkset_config(x)) { - SS7_CRITICAL("MTP3 LINKSET %d configuration FAILED!\n", x); - return 1; - } else { - SS7_INFO("MTP3 LINKSET %d configuration DONE!\n", x); - } - - /* set the SNGSS7_CONFIGURED flag */ - g_ftdm_sngss7_data.cfg.mtpLinkSet[x].flags |= SNGSS7_CONFIGURED; - } /* if !SNGSS7_CONFIGURED */ - - x++; - } /* while (x < (MAX_MTP_LINKSETS+1)) */ - } - - /* in M2UA_SG mode there will not be any MTP3 layer */ - if(SNG_SS7_OPR_MODE_M2UA_SG != g_ftdm_operating_mode){ - x = 1; - while (x < (MAX_MTP_ROUTES+1)) { - /* check if this link has been configured already */ - if ((g_ftdm_sngss7_data.cfg.mtpRoute[x].id != 0) && - (!(g_ftdm_sngss7_data.cfg.mtpRoute[x].flags & SNGSS7_CONFIGURED))) { - - if (ftmod_ss7_mtp3_route_config(x)) { - SS7_CRITICAL("MTP3 ROUTE %d configuration FAILED!\n", x); - return 1; - } else { - SS7_INFO("MTP3 ROUTE %d configuration DONE!\n",x); - } - - /* set the SNGSS7_CONFIGURED flag */ - g_ftdm_sngss7_data.cfg.mtpRoute[x].flags |= SNGSS7_CONFIGURED; - } /* if !SNGSS7_CONFIGURED */ - - x++; - } /* while (x < (MAX_MTP_ROUTES+1)) */ - } - - x = 1; - while (x < (MAX_ISAPS)) { - /* check if this link has been configured already */ - if ((g_ftdm_sngss7_data.cfg.isap[x].id != 0) && - (!(g_ftdm_sngss7_data.cfg.isap[x].flags & SNGSS7_CONFIGURED))) { - - if (ftmod_ss7_isup_isap_config(x)) { - SS7_CRITICAL("ISUP ISAP %d configuration FAILED!\n", x); - return 1; - } else { - SS7_INFO("ISUP ISAP %d configuration DONE!\n", x); - } - - /* set the SNGSS7_CONFIGURED flag */ - g_ftdm_sngss7_data.cfg.isap[x].flags |= SNGSS7_CONFIGURED; - } /* if !SNGSS7_CONFIGURED */ - - x++; - } /* while (x < (MAX_ISAPS)) */ - - if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_ISUP_STARTED)) { - x = 1; - while (x < (MAX_ISUP_INFS)) { - /* check if this link has been configured already */ - if ((g_ftdm_sngss7_data.cfg.isupIntf[x].id != 0) && - (!(g_ftdm_sngss7_data.cfg.isupIntf[x].flags & SNGSS7_CONFIGURED))) { - - if (ftmod_ss7_isup_intf_config(x)) { - SS7_CRITICAL("ISUP INTF %d configuration FAILED!\n", x); - return 1; - } else { - SS7_INFO("ISUP INTF %d configuration DONE!\n", x); - /* set the interface to paused */ - sngss7_set_flag(&g_ftdm_sngss7_data.cfg.isupIntf[x], SNGSS7_PAUSED); - } - - /* set the SNGSS7_CONFIGURED flag */ - g_ftdm_sngss7_data.cfg.isupIntf[x].flags |= SNGSS7_CONFIGURED; - } /* if !SNGSS7_CONFIGURED */ - - x++; - } /* while (x < (MAX_ISUP_INFS)) */ - } /* if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_ISUP)) */ - - x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1; - while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) { - - if (g_ftdm_sngss7_data.cfg.procId > 1) { - break; - } - - /* check if this link has been configured already */ - if ((g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) && - (!(g_ftdm_sngss7_data.cfg.isupCkt[x].flags & SNGSS7_CONFIGURED))) { - - if (ftmod_ss7_isup_ckt_config(x)) { - SS7_CRITICAL("ISUP CKT %d configuration FAILED!\n", x); - return 1; - } else { - SS7_INFO("ISUP CKT %d configuration DONE!\n", x); - } - - /* set the SNGSS7_CONFIGURED flag */ - g_ftdm_sngss7_data.cfg.isupCkt[x].flags |= SNGSS7_CONFIGURED; - } /* if !SNGSS7_CONFIGURED */ - - x++; - } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) */ - } - - /* go through all the relays channels and configure it */ - x = 1; - while (x < (MAX_RELAY_CHANNELS)) { - /* check if this relay channel has been configured already */ - if ((g_ftdm_sngss7_data.cfg.relay[x].id != 0) && - (!(g_ftdm_sngss7_data.cfg.relay[x].flags & SNGSS7_CONFIGURED))) { - - /* send the specific configuration */ - if (ftmod_ss7_relay_chan_config(x)) { - SS7_CRITICAL("Relay Channel %d configuration FAILED!\n", x); - return 1; - } else { - SS7_INFO("Relay Channel %d configuration DONE!\n", x); - } - - /* set the SNGSS7_CONFIGURED flag */ - g_ftdm_sngss7_data.cfg.relay[x].flags |= SNGSS7_CONFIGURED; - } /* if !SNGSS7_CONFIGURED */ - x++; - } /* while (x < (MAX_RELAY_CHANNELS)) */ - - - if(SNG_SS7_OPR_MODE_M2UA_SG == g_ftdm_operating_mode){ - return ftmod_ss7_m2ua_cfg(); - } - - return 0; -} - -/******************************************************************************/ -int ftmod_ss7_relay_gen_config(void) -{ - RyMngmt cfg; /*configuration structure*/ - Pst pst; /*post structure*/ - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTRY; - - /* clear the configuration structure */ - memset(&cfg, 0x0, sizeof(RyMngmt)); - - /* fill in some general sections of the header */ - smHdrInit(&cfg.hdr); - - /* fill in the post structure */ - smPstInit( &cfg.t.cfg.s.ryGenCfg.lmPst ); - - /*fill in the specific fields of the header */ - cfg.hdr.msgType = TCFG; - cfg.hdr.entId.ent = ENTRY; - cfg.hdr.entId.inst = S_INST; - cfg.hdr.elmId.elmnt = STGEN; - - cfg.t.cfg.s.ryGenCfg.lmPst.srcEnt = ENTRY; - cfg.t.cfg.s.ryGenCfg.lmPst.dstEnt = ENTSM; - - cfg.t.cfg.s.ryGenCfg.nmbChan = 10; - cfg.t.cfg.s.ryGenCfg.tmrRes = RY_PERIOD; - cfg.t.cfg.s.ryGenCfg.usta = 1; - - - return(sng_cfg_relay(&pst, &cfg)); -} - -/******************************************************************************/ -int ftmod_ss7_mtp1_gen_config(void) -{ - L1Mngmt cfg; /*configuration structure*/ - Pst pst; /*post structure*/ - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTL1; - - /* clear the configuration structure */ - memset(&cfg, 0x0, sizeof(L1Mngmt)); - - /* fill in some general sections of the header */ - smHdrInit(&cfg.hdr); - - /* fill in the post structure */ - smPstInit( &cfg.t.cfg.s.l1Gen.sm ); - - /*fill in the specific fields of the header */ - cfg.hdr.msgType = TCFG; - cfg.hdr.entId.ent = ENTL1; - cfg.hdr.entId.inst = S_INST; - cfg.hdr.elmId.elmnt = STGEN; - - cfg.t.cfg.s.l1Gen.sm.srcEnt = ENTL1; - cfg.t.cfg.s.l1Gen.sm.dstEnt = ENTSM; - - cfg.t.cfg.s.l1Gen.nmbLnks = MAX_L1_LINKS; - cfg.t.cfg.s.l1Gen.poolTrUpper = POOL_UP_TR; /* upper pool threshold */ - cfg.t.cfg.s.l1Gen.poolTrLower = POOL_LW_TR; /* lower pool threshold */ - - return(sng_cfg_mtp1(&pst, &cfg)); -} - -/******************************************************************************/ -int ftmod_ss7_mtp2_gen_config(void) -{ - SdMngmt cfg; - Pst pst; - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSD; - - /* clear the configuration structure */ - memset(&cfg, 0x0, sizeof(SdMngmt)); - - /* fill in some general sections of the header */ - smHdrInit(&cfg.hdr); - - /* fill in the post structure */ - smPstInit( &cfg.t.cfg.s.sdGen.sm ); - - /* fill in the specific fields of the header */ - cfg.hdr.msgType = TCFG; - cfg.hdr.entId.ent = ENTSD; - cfg.hdr.entId.inst = S_INST; - cfg.hdr.elmId.elmnt = STGEN; - - cfg.t.cfg.s.sdGen.sm.srcEnt = ENTSD; - cfg.t.cfg.s.sdGen.sm.dstEnt = ENTSM; - - cfg.t.cfg.s.sdGen.nmbLnks = MAX_SD_LINKS; - cfg.t.cfg.s.sdGen.poolTrUpper = POOL_UP_TR; - cfg.t.cfg.s.sdGen.poolTrLower = POOL_LW_TR; - - return(sng_cfg_mtp2(&pst, &cfg)); -} - -/******************************************************************************/ -int ftmod_ss7_mtp3_gen_config(void) -{ - SnMngmt cfg; - Pst pst; - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSN; - - /*clear the configuration structure*/ - memset(&cfg, 0x0, sizeof(SnMngmt)); - - /*fill in some general sections of the header*/ - smHdrInit(&cfg.hdr); - - /* fill in the post structure */ - smPstInit(&cfg.t.cfg.s.snGen.sm); - - /*fill in the specific fields of the header*/ - cfg.hdr.msgType = TCFG; - cfg.hdr.entId.ent = ENTSN; - cfg.hdr.entId.inst = S_INST; - cfg.hdr.elmId.elmnt = STGEN; - - cfg.t.cfg.s.snGen.sm.srcEnt = ENTSN; - cfg.t.cfg.s.snGen.sm.dstEnt = ENTSM; - - - cfg.t.cfg.s.snGen.typeSP = LSN_TYPE_SP; /* type of signalling postatic int */ - cfg.t.cfg.s.snGen.spCode1 = 0; /* our DPC for CCITT version */ -#if (SS7_ANS92 || SS7_ANS88 || SS7_ANS96 || SS7_CHINA || defined(TDS_ROLL_UPGRADE_SUPPORT)) - cfg.t.cfg.s.snGen.spCode2 = 0; /* our DPC for ANSI or CHINA version */ -#endif - cfg.t.cfg.s.snGen.ssfValid = TRUE; /* ssf validation required */ - cfg.t.cfg.s.snGen.nmbDLSap = MAX_SN_LINKS; /* number of MTP Data Link SAPs */ - cfg.t.cfg.s.snGen.nmbNSap = MAX_SN_ROUTES; /* number of Upper Layer Saps */ - cfg.t.cfg.s.snGen.nmbRouts = MAX_SN_ROUTES; /* maximum number of routing entries */ - cfg.t.cfg.s.snGen.nmbLnkSets = MAX_SN_LINKSETS; /* number of link sets */ - cfg.t.cfg.s.snGen.nmbRteInst = MAX_SN_ROUTES*16; /* number of simultaneous Rte instances */ - cfg.t.cfg.s.snGen.cbTimeRes = SN_CB_PERIOD; /* link time resolution */ - cfg.t.cfg.s.snGen.spTimeRes = SN_SP_PERIOD; /* general time resolution */ - cfg.t.cfg.s.snGen.rteTimeRes = SN_RTE_PERIOD; /* route time resolution */ - cfg.t.cfg.s.snGen.extCmbndLnkst = FALSE; /* enbale extended combined linkset feature */ - -#if (defined(LSNV3) || defined(SN_MULTIPLE_NETWORK_RESTART)) - -#else - cfg.t.cfg.s.snGen.rstReq = LSN_NO_RST; /* restarting procedure required */ - cfg.t.cfg.s.snGen.tfrReq = FALSE; /* TFR procedure required or not */ - cfg.t.cfg.s.snGen.tmr.t15.enb = TRUE; /* t15 - waiting to start route set congestion test */ - cfg.t.cfg.s.snGen.tmr.t15.val = 30; - cfg.t.cfg.s.snGen.tmr.t16.enb = TRUE; /* t16 - waiting for route set congestion status update */ - cfg.t.cfg.s.snGen.tmr.t16.val = 20; - cfg.t.cfg.s.snGen.tmr.t18.enb = TRUE; /* t18 - waiting for links to become available */ - cfg.t.cfg.s.snGen.tmr.t18.val = 200; - cfg.t.cfg.s.snGen.tmr.t19.enb = TRUE; /* t19 - waiting to receive all traffic restart allowed */ - cfg.t.cfg.s.snGen.tmr.t19.val = 690; - cfg.t.cfg.s.snGen.tmr.t21.enb = TRUE; /* t21 - waiting to restart traffic routed through adjacent SP */ - cfg.t.cfg.s.snGen.tmr.t21.val = 650; -# if (SS7_ANS92 || SS7_ANS88 || SS7_ANS96 || defined(TDS_ROLL_UPGRADE_SUPPORT)) - cfg.t.cfg.s.snGen.tmr.t26.enb = TRUE; /* t26 - waiting to repeat traffic restart waiting message for ANSI */ - cfg.t.cfg.s.snGen.tmr.t26.val = 600; -# endif -#endif - -#if (SS7_ANS88 || SS7_ANS92 || SS7_ANS96) - cfg.t.cfg.s.snGen.mopc = FALSE; -#endif - - return(sng_cfg_mtp3(&pst, &cfg)); -} - -/******************************************************************************/ -int ftmod_ss7_isup_gen_config(void) -{ - SiMngmt cfg; - Pst pst; - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSI; - - /* clear the configuration structure */ - memset(&cfg, 0x0, sizeof(SiMngmt)); - - /* fill in some general sections of the header */ - smHdrInit(&cfg.hdr); - - /* fill in the post structure */ - smPstInit( &cfg.t.cfg.s.siGen.sm ); - - /*fill in the specific fields of the header */ - cfg.hdr.msgType = TCFG; - cfg.hdr.entId.ent = ENTSI; - cfg.hdr.entId.inst = S_INST; - cfg.hdr.elmId.elmnt = STGEN; - - cfg.t.cfg.s.siGen.sm.srcEnt = ENTSI; - cfg.t.cfg.s.siGen.sm.dstEnt = ENTSM; - - cfg.t.cfg.s.siGen.nmbSaps = MAX_CC_INTERFACE; /* Number of ISUP Saps */ - cfg.t.cfg.s.siGen.nmbNSaps = MAX_SN_INTERFACE; /* Number of Network Saps */ - cfg.t.cfg.s.siGen.nmbCir = MAX_SI_CIRCUITS; /* Number of circuits */ - cfg.t.cfg.s.siGen.nmbIntf = MAX_SI_INTERFACES; /* Number of interfaces */ - cfg.t.cfg.s.siGen.nmbCirGrp = MAX_SI_CIR_GRP; /* Max number of circuit groups */ - cfg.t.cfg.s.siGen.nmbCalRef = MAX_SI_CALL_REF; /* Number of Call References */ - cfg.t.cfg.s.siGen.timeRes = SI_PERIOD; /* time resolution */ - cfg.t.cfg.s.siGen.sccpSup = FALSE; /* SCCP support */ - cfg.t.cfg.s.siGen.handleTTBinCC = FALSE; /* Flag used for controlling TTB feature */ - cfg.t.cfg.s.siGen.mapCPCandFCI = TRUE; /* Flag used for controlling TTB feature */ -#if (LSIV3 || LSIV4 || LSIV5) - cfg.t.cfg.s.siGen.lnkSelOpt = SI_LINK_SELECTION; /* link selector option */ -#endif - cfg.t.cfg.s.siGen.poolTrUpper = POOL_UP_TR; /* upper pool threshold */ - cfg.t.cfg.s.siGen.poolTrLower = POOL_LW_TR; /* lower pool threshold */ - cfg.t.cfg.s.siGen.cirGrTmr.t18.enb = TRUE; /* t18 timer - group blocking sent */ - cfg.t.cfg.s.siGen.cirGrTmr.t18.val = 300; - cfg.t.cfg.s.siGen.cirGrTmr.t19.enb = TRUE; /* t19 timer - initial group blocking sent */ - cfg.t.cfg.s.siGen.cirGrTmr.t19.val = 3000; - cfg.t.cfg.s.siGen.cirGrTmr.t20.enb = TRUE; /* t20 timer - group unblocking sent */ - cfg.t.cfg.s.siGen.cirGrTmr.t20.val = 300; - cfg.t.cfg.s.siGen.cirGrTmr.t21.enb = TRUE; /* t21 timer - initial grp unblocking sent */ - cfg.t.cfg.s.siGen.cirGrTmr.t21.val = 3000; - cfg.t.cfg.s.siGen.cirGrTmr.t22.enb = TRUE; /* t22 timer - group reset sent */ - cfg.t.cfg.s.siGen.cirGrTmr.t22.val = 300; - cfg.t.cfg.s.siGen.cirGrTmr.t23.enb = TRUE; /* t23 timer - initial group reset sent */ - cfg.t.cfg.s.siGen.cirGrTmr.t23.val = 3000; -#ifndef SS7_UK - cfg.t.cfg.s.siGen.cirGrTmr.t28.enb = TRUE; /* t28 timer - circuit group query sent */ - cfg.t.cfg.s.siGen.cirGrTmr.t28.val = 100; -#endif -#if (SS7_ANS88 || SS7_ANS92 || SS7_ANS95 || SS7_BELL) - cfg.t.cfg.s.siGen.cirGrTmr.tFGR.enb = TRUE; /* first group received timer */ - cfg.t.cfg.s.siGen.cirGrTmr.tFGR.val = 50; -#endif -#if CGPN_CHK - cfg.t.cfg.s.siGen.cgPtyNumGenCfg = TRUE; /* Calling party number general config flag */ -#endif -#ifdef SI_SUPPRESS_CFN - cfg.t.cfg.s.siGen.suppressCfn = TRUE; /* Flag used for 'suppress CFN' feature */ -#endif - - return(sng_cfg_isup(&pst, &cfg)); - -} - -/******************************************************************************/ -int ftmod_ss7_cc_gen_config(void) -{ - CcMngmt cfg; - Pst pst; - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTCC; - - /*clear the configuration structure*/ - memset(&cfg, 0x0, sizeof(CcMngmt)); - - /*fill in some general sections of the header*/ - smHdrInit(&cfg.hdr); - - /* fill in the post structure */ - smPstInit( &cfg.t.cfg.s.ccGen.sm ); - - /*fill in the specific fields of the header*/ - cfg.hdr.msgType = TCFG; - cfg.hdr.entId.ent = ENTCC; - cfg.hdr.entId.inst = S_INST; - cfg.hdr.elmId.elmnt = STGEN; - - cfg.t.cfg.s.ccGen.sm.srcEnt = ENTCC; - cfg.t.cfg.s.ccGen.sm.dstEnt = ENTSM; - - cfg.t.cfg.s.ccGen.poolTrUpper = POOL_UP_TR; /* upper pool threshold */ - cfg.t.cfg.s.ccGen.poolTrLower = POOL_LW_TR; /* lower pool threshold */ - - return(sng_cfg_cc(&pst, &cfg)); -} - -/******************************************************************************/ -int ftmod_ss7_mtp1_psap_config(int id) -{ - L1Mngmt cfg; - Pst pst; - sng_mtp1_link_t *k = &g_ftdm_sngss7_data.cfg.mtp1Link[id]; - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTL1; - - /*clear the configuration structure*/ - memset(&cfg, 0x0, sizeof(L1Mngmt)); - - /*fill in some general sections of the header*/ - smHdrInit(&cfg.hdr); - - /*fill in the specific fields of the header*/ - cfg.hdr.msgType = TCFG; - cfg.hdr.entId.ent = ENTL1; - cfg.hdr.entId.inst = S_INST; - cfg.hdr.elmId.elmnt = STPSAP; - - cfg.hdr.elmId.elmntInst1 = k->id; - - cfg.t.cfg.s.l1PSAP.span = k->span; - cfg.t.cfg.s.l1PSAP.chan = k->chan; - cfg.t.cfg.s.l1PSAP.spId = k->id; - - return(sng_cfg_mtp1(&pst, &cfg)); -} - -/******************************************************************************/ -int ftmod_ss7_mtp2_dlsap_config(int id) -{ - SdMngmt cfg; - Pst pst; - sng_mtp2_link_t *k = &g_ftdm_sngss7_data.cfg.mtp2Link[id]; - - /* initalize the post structure */ - smPstInit( &pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSD; - - /*clear the configuration structure*/ - memset(&cfg, 0x0, sizeof(SdMngmt)); - - /*fill in some general sections of the header*/ - smHdrInit(&cfg.hdr); - - /*fill in the specific fields of the header*/ - cfg.hdr.msgType = TCFG; - cfg.hdr.entId.ent = ENTSD; - cfg.hdr.entId.inst = S_INST; - cfg.hdr.elmId.elmnt = STDLSAP; - - cfg.hdr.elmId.elmntInst1 = k->id; - - cfg.t.cfg.s.sdDLSAP.mem.region = S_REG; /* memory region */ - cfg.t.cfg.s.sdDLSAP.mem.pool = S_POOL; /* memory pool */ - cfg.t.cfg.s.sdDLSAP.swtch = k->linkType; /* protocol type */ - cfg.t.cfg.s.sdDLSAP.priorDl = PRIOR0; /* priority for data link layer */ - cfg.t.cfg.s.sdDLSAP.routeDl = RTESPEC; /* route for data link layer */ - cfg.t.cfg.s.sdDLSAP.selectorDl = 0; /* upper interface selector */ - if (k->mtp1ProcId > 0) { - cfg.t.cfg.s.sdDLSAP.dstProcId = k->mtp1ProcId; /* the procid of MAC/L1/MTP1 */ - } else { - cfg.t.cfg.s.sdDLSAP.dstProcId = SFndProcId(); /* the procid of MAC/L1/MTP1 */ - } - cfg.t.cfg.s.sdDLSAP.dstProcId = SFndProcId(); /* the procid of MAC/L1/MTP1 */ - cfg.t.cfg.s.sdDLSAP.entMac = ENTL1; /* entity for MAC */ - cfg.t.cfg.s.sdDLSAP.instMac = S_INST; /* instance for MAC */ - cfg.t.cfg.s.sdDLSAP.priorMac = PRIOR0; /* priority for MAC layer */ - cfg.t.cfg.s.sdDLSAP.routeMac = RTESPEC; /* route for MAC layer */ - cfg.t.cfg.s.sdDLSAP.selectorMac = 0; /* lower interface selector */ - cfg.t.cfg.s.sdDLSAP.memMac.region = S_REG; /* memory region and pool id for MAC */ - cfg.t.cfg.s.sdDLSAP.memMac.pool = S_POOL; - cfg.t.cfg.s.sdDLSAP.maxOutsFrms = MAX_SD_OUTSTANDING; /* maximum outstanding frames */ - cfg.t.cfg.s.sdDLSAP.errType = k->errorType; - cfg.t.cfg.s.sdDLSAP.t1.enb = TRUE; /* timer 1 - Alignment Ready Timer */ - cfg.t.cfg.s.sdDLSAP.t1.val = k->t1; - cfg.t.cfg.s.sdDLSAP.t2.enb = TRUE; /* timer 2 - Not Aligned Timer */ - cfg.t.cfg.s.sdDLSAP.t2.val = k->t2; - cfg.t.cfg.s.sdDLSAP.t3.enb = TRUE; /* timer 3 - Aligned Timer */ - cfg.t.cfg.s.sdDLSAP.t3.val = k->t3; - cfg.t.cfg.s.sdDLSAP.t5.enb = TRUE; /* timer 5 - Sending SIB timer */ - cfg.t.cfg.s.sdDLSAP.t5.val = k->t5; - cfg.t.cfg.s.sdDLSAP.t6.enb = TRUE; /* timer 6 - Remote Congestion Timer */ - cfg.t.cfg.s.sdDLSAP.t6.val = k->t6; - cfg.t.cfg.s.sdDLSAP.t7.enb = TRUE; /* timer 7 - Excessive delay of acknowledgement timer */ - cfg.t.cfg.s.sdDLSAP.t7.val = k->t7; - cfg.t.cfg.s.sdDLSAP.provEmrgcy = k->t4e; /* emergency proving period */ - cfg.t.cfg.s.sdDLSAP.provNormal = k->t4n; /* normal proving period */ - cfg.t.cfg.s.sdDLSAP.lssuLen = k->lssuLength; /* one or two byte LSSU length */ - cfg.t.cfg.s.sdDLSAP.maxFrmLen = MAX_SD_FRAME_LEN; /* max frame length for MSU */ - cfg.t.cfg.s.sdDLSAP.congDisc = FALSE; /* congestion discard TRUE or FALSE */ - cfg.t.cfg.s.sdDLSAP.sdT = MAX_SD_SUERM; /* SUERM error rate threshold */ - cfg.t.cfg.s.sdDLSAP.sdTie = MAX_SD_AERM_EMERGENCY; /* AERM emergency error rate threshold */ - cfg.t.cfg.s.sdDLSAP.sdTin = MAX_SD_AERM_NORMAL; /* AERM normal error rate threshold */ - cfg.t.cfg.s.sdDLSAP.sdN1 = MAX_SD_MSU_RETRANS; /* maximum number of MSUs for retransmission */ - cfg.t.cfg.s.sdDLSAP.sdN2 = MAX_SD_OCTETS_RETRANS; /* maximum number of MSU octets for retrans */ - cfg.t.cfg.s.sdDLSAP.sdCp = MAX_SD_ALIGN_ATTEMPTS; /* maximum number of alignment attempts */ - cfg.t.cfg.s.sdDLSAP.spIdSE = k->mtp1Id; /* service provider id */ - cfg.t.cfg.s.sdDLSAP.sdtFlcStartTr = 256; /* SDT interface flow control start thresh */ - cfg.t.cfg.s.sdDLSAP.sdtFlcEndTr = 512; /* SDT interface flow control end thresh */ - -#ifdef SD_HSL - cfg.t.cfg.s.sdDLSAP.sapType =; /* Indcates whether link is HSL or LSL */ - cfg.t.cfg.s.sdDLSAP.sapFormat =; /* The extened sequence no to be used or not */ - cfg.t.cfg.s.sdDLSAP.t8.enb =; /* timer 8 configuration structure */ - cfg.t.cfg.s.sdDLSAP.sdTe =; /* EIM threshold */ - cfg.t.cfg.s.sdDLSAP.sdUe =; /* increment constant */ - cfg.t.cfg.s.sdDLSAP.sdDe =; /* decrement constant */ -#endif /* HIGH_SPEED_SIGNALING_SUPPORT */ - -#if (SS7_TTC || SS7_NTT) - cfg.t.cfg.s.sdDLSAP.numRtb =; /* outstanding number of messages in RTB */ - cfg.t.cfg.s.sdDLSAP.tf =; /* FISU transmission interval */ - cfg.t.cfg.s.sdDLSAP.tfv =; /* FISU transmission interval during verification */ - cfg.t.cfg.s.sdDLSAP.to =; /* SIO transmission interval */ - cfg.t.cfg.s.sdDLSAP.ta =; /* SIE transmission interval */ - cfg.t.cfg.s.sdDLSAP.ts =; /* SIOS transmission interval */ - cfg.t.cfg.s.sdDLSAP.tso =; /* SIOS transmission duration when out of service */ - cfg.t.cfg.s.sdDLSAP.te =; /* SU normalization time */ -#endif /* (SS7_TTC || SS7_NTT) */ - -#if (SS7_NTT) /* NTTT - Q.703 */ - cfg.t.cfg.s.sdDLSAP.repMsuNack =; /* Nack on receipt of repeated MSU */ - cfg.t.cfg.s.sdDLSAP.invFibIgnore =; /* invalid FIB ignore or bring the link down */ - cfg.t.cfg.s.sdDLSAP.invBsnIgnore =; /* invalid BSN ignore or bring the link down */ - cfg.t.cfg.s.sdDLSAP.congAbatOnNack =; /* congestion abatement on nack or only on acks */ -#endif /* (SS7_NTT) */ - -#ifdef TDS_ROLL_UPGRADE_SUPPORT - cfg.t.cfg.s.sdDLSAP.hlremIntfValid = FALSE; /* Upper Sap Version number valid ? */ - cfg.t.cfg.s.sdDLSAP.remIntfVer = SDTIFVER; /* remote version info */ -#endif /*RUG*/ - - return(sng_cfg_mtp2(&pst, &cfg)); -} - -/******************************************************************************/ -int ftmod_ss7_mtp3_dlsap_config(int id) -{ - Pst pst; - SnMngmt cfg; - sng_mtp3_link_t *k = &g_ftdm_sngss7_data.cfg.mtp3Link[id]; - - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSN; - - /*clear the configuration structure*/ - memset(&cfg, 0x0, sizeof(SnMngmt)); - - /*fill in some general sections of the header*/ - smHdrInit(&cfg.hdr); - - /*fill in the specific fields of the header*/ - cfg.hdr.msgType = TCFG; - cfg.hdr.entId.ent = ENTSN; - cfg.hdr.entId.inst = S_INST; - cfg.hdr.elmId.elmnt = STDLSAP; - - cfg.hdr.elmId.elmntInst1 = k->id; - - cfg.t.cfg.s.snDLSAP.lnkSetId = k->linkSetId; /* link set ID */ - cfg.t.cfg.s.snDLSAP.opc = k->spc; /* Originating Postatic int Code */ - cfg.t.cfg.s.snDLSAP.adjDpc = k->apc; /* Adlacent Destination Postatic int Code */ - cfg.t.cfg.s.snDLSAP.lnkPrior = 0; /* link priority within the link set */ - cfg.t.cfg.s.snDLSAP.msgSize = MAX_SN_MSG_SIZE; /* message length */ - cfg.t.cfg.s.snDLSAP.msgPrior = 0; /* management message priority */ - cfg.t.cfg.s.snDLSAP.lnkType = k->linkType; /* link type ANSI, ITU, BICI or CHINA */ - cfg.t.cfg.s.snDLSAP.upSwtch = k->switchType; /* user part switch type */ - cfg.t.cfg.s.snDLSAP.maxSLTtry = MAX_SLTM_RETRIES; /* maximun times to retry SLTM */ - cfg.t.cfg.s.snDLSAP.p0QLen = 32; /* size of the priority 0 Q */ - cfg.t.cfg.s.snDLSAP.p1QLen = 32; /* size of the priority 1 Q */ - cfg.t.cfg.s.snDLSAP.p2QLen = 32; /* size of the priority 2 Q */ - cfg.t.cfg.s.snDLSAP.p3QLen = 32; /* size of the priority 3 Q */ - cfg.t.cfg.s.snDLSAP.discPrior = 0; /* discard priority */ -#ifndef SDT2 - cfg.t.cfg.s.snDLSAP.maxCredit = MAX_SN_CREDIT; /* max credit */ -#endif /* SDT2 */ - cfg.t.cfg.s.snDLSAP.lnkId = 0; /* signalling link allocation procedure identity */ - cfg.t.cfg.s.snDLSAP.lnkTstSLC = k->slc; /* link selection code for link test */ - cfg.t.cfg.s.snDLSAP.tstLen = 7; /* link test pattern length */ - cfg.t.cfg.s.snDLSAP.tst[0] = 'S'; /* link test pattern */ - cfg.t.cfg.s.snDLSAP.tst[1] = 'A'; /* link test pattern */ - cfg.t.cfg.s.snDLSAP.tst[2] = 'N'; /* link test pattern */ - cfg.t.cfg.s.snDLSAP.tst[3] = 'G'; /* link test pattern */ - cfg.t.cfg.s.snDLSAP.tst[4] = 'O'; /* link test pattern */ - cfg.t.cfg.s.snDLSAP.tst[5] = 'M'; /* link test pattern */ - cfg.t.cfg.s.snDLSAP.tst[6] = 'A'; /* link test pattern */ - cfg.t.cfg.s.snDLSAP.ssf = k->ssf; /* sub service field */ - cfg.t.cfg.s.snDLSAP.dstProcId = k->mtp2ProcId; /* destination processor id */ - cfg.t.cfg.s.snDLSAP.dstEnt = ENTSD; /* entity */ - cfg.t.cfg.s.snDLSAP.dstInst = S_INST; /* instance */ - cfg.t.cfg.s.snDLSAP.prior = PRIOR0; /* priority */ - cfg.t.cfg.s.snDLSAP.route = RTESPEC; /* route */ - cfg.t.cfg.s.snDLSAP.selector = 0; /* lower layer selector */ - cfg.t.cfg.s.snDLSAP.mem.region = S_REG; /* memory region id */ - cfg.t.cfg.s.snDLSAP.mem.pool = S_POOL; /* memory pool id */ - cfg.t.cfg.s.snDLSAP.spId = k->mtp2Id; /* service provider id */ - - switch (k->linkType) { - /**************************************************************************/ - case (LSN_SW_ANS): - case (LSN_SW_ANS96): - case (LSN_SW_CHINA): - cfg.t.cfg.s.snDLSAP.dpcLen = DPC24; /* dpc length 24 bits */ - cfg.t.cfg.s.snDLSAP.l2Type = LSN_MTP2_56KBPS; /* layer 2 type - 56kbps MTP2 link, 1.536Mbps MTP2 link or QSAAL link */ - cfg.t.cfg.s.snDLSAP.isCLink = FALSE; /* identifies if the link is a C type link.Required to check if sls has to be rotated.*/ - break; - /**************************************************************************/ - case (LSN_SW_ITU): - cfg.t.cfg.s.snDLSAP.dpcLen = DPC14; /* dpc length 14 bits */ - break; - /**************************************************************************/ - default: - cfg.t.cfg.s.snDLSAP.dpcLen = DPC14; /* dpc length 14 bits */ - break; - /**************************************************************************/ - } /* switch (k->linkType) */ - - switch (k->linkType) { - /**************************************************************************/ - case (LSN_SW_ANS): - case (LSN_SW_ANS96): - cfg.t.cfg.s.snDLSAP.flushContFlag = TRUE; /* flush continue handling */ - break; - /**************************************************************************/ - case (LSN_SW_ITU): - case (LSN_SW_CHINA): - cfg.t.cfg.s.snDLSAP.flushContFlag = FALSE; /* flush continue handling */ - break; - /**************************************************************************/ - default: - cfg.t.cfg.s.snDLSAP.flushContFlag = FALSE; /* flush continue handling */ - break; - /**************************************************************************/ - } /* switch (k->linkType) */ - - cfg.t.cfg.s.snDLSAP.tmr.t1.enb = TRUE; /* t1 - delay to avoid missequencing on changeover */ - cfg.t.cfg.s.snDLSAP.tmr.t1.val = k->t1; - cfg.t.cfg.s.snDLSAP.tmr.t2.enb = TRUE; /* t2 - waiting for changeover ack */ - cfg.t.cfg.s.snDLSAP.tmr.t2.val = k->t2; - cfg.t.cfg.s.snDLSAP.tmr.t3.enb = TRUE; /* t3 - delay to avoid missequencing on changeback */ - cfg.t.cfg.s.snDLSAP.tmr.t3.val = k->t3; - cfg.t.cfg.s.snDLSAP.tmr.t4.enb = TRUE; /* t4 - waiting for first changeback ack */ - cfg.t.cfg.s.snDLSAP.tmr.t4.val = k->t4; - cfg.t.cfg.s.snDLSAP.tmr.t5.enb = TRUE; /* t5 - waiting for second changeback ack */ - cfg.t.cfg.s.snDLSAP.tmr.t5.val = k->t5; - cfg.t.cfg.s.snDLSAP.tmr.t7.enb = TRUE; /* t7 - waiting for link connection ack */ - cfg.t.cfg.s.snDLSAP.tmr.t7.val = k->t7; - cfg.t.cfg.s.snDLSAP.tmr.t12.enb = TRUE; /* t12 - waiting for uninhibit ack */ - cfg.t.cfg.s.snDLSAP.tmr.t12.val = k->t12; - cfg.t.cfg.s.snDLSAP.tmr.t13.enb = TRUE; /* t13 - waiting for forced uninhibit */ - cfg.t.cfg.s.snDLSAP.tmr.t13.val = k->t13; - cfg.t.cfg.s.snDLSAP.tmr.t14.enb = TRUE; /* t14 - waiting for inhibition ack */ - cfg.t.cfg.s.snDLSAP.tmr.t14.val = k->t14; - cfg.t.cfg.s.snDLSAP.tmr.t17.enb = TRUE; /* t17 - delay to avoid oscillation of initial alignment failure */ - cfg.t.cfg.s.snDLSAP.tmr.t17.val = k->t17; - cfg.t.cfg.s.snDLSAP.tmr.t22.enb = TRUE; /* t22 - local inhibit test timer */ - cfg.t.cfg.s.snDLSAP.tmr.t22.val = k->t22; - cfg.t.cfg.s.snDLSAP.tmr.t23.enb = TRUE; /* t23 - remote inhibit test timer */ - cfg.t.cfg.s.snDLSAP.tmr.t23.val = k->t23; - cfg.t.cfg.s.snDLSAP.tmr.t24.enb = TRUE; /* t24 - stabilizing timer */ - cfg.t.cfg.s.snDLSAP.tmr.t24.val = k->t24; - cfg.t.cfg.s.snDLSAP.tmr.t31.enb = TRUE; /* t31 - BSN requested timer */ - cfg.t.cfg.s.snDLSAP.tmr.t31.val = k->t31; - cfg.t.cfg.s.snDLSAP.tmr.t32.enb = TRUE; /* t32 - SLT timer */ - cfg.t.cfg.s.snDLSAP.tmr.t32.val = k->t32; - cfg.t.cfg.s.snDLSAP.tmr.t33.enb = TRUE; /* t33 - connecting timer */ - cfg.t.cfg.s.snDLSAP.tmr.t33.val = k->t33; - cfg.t.cfg.s.snDLSAP.tmr.t34.enb = TRUE; /* t34 - periodic signalling link test timer */ - cfg.t.cfg.s.snDLSAP.tmr.t34.val = k->t34; -#if (SS7_ANS92 || SS7_ANS88 || SS7_ANS96 || defined(TDS_ROLL_UPGRADE_SUPPORT)) - cfg.t.cfg.s.snDLSAP.tmr.t35.enb = TRUE; /* t35 - false link congestion timer, same as t31 of ANSI'96*/ - cfg.t.cfg.s.snDLSAP.tmr.t35.val = k->t35; - cfg.t.cfg.s.snDLSAP.tmr.t36.enb = TRUE; /* t36 - false link congestion timer, same as t33 of ANSI'96*/ - cfg.t.cfg.s.snDLSAP.tmr.t36.val = k->t36; - cfg.t.cfg.s.snDLSAP.tmr.t37.enb = TRUE; /* t37 - false link congestion timer, same as t34 of ANSI'96*/ - cfg.t.cfg.s.snDLSAP.tmr.t37.val = k->t37; - cfg.t.cfg.s.snDLSAP.tmr.tCraft.enb = TRUE; /* link referral craft timer - T19 in ANSI */ - cfg.t.cfg.s.snDLSAP.tmr.tCraft.val = k->tcraft; -#endif -#ifdef SDT2 - cfg.t.cfg.s.snDLSAP.tmr.tFlc.enb = TRUE; /* flow control timer */ - cfg.t.cfg.s.snDLSAP.tmr.tFlc.val = 300; - cfg.t.cfg.s.snDLSAP.tmr.tBnd.enb = TRUE; /* bind request timer */ - cfg.t.cfg.s.snDLSAP.tmr.tBnd.val = 20; -#endif /* SDT2 */ -#ifdef TDS_ROLL_UPGRADE_SUPPORT - cfg.t.cfg.s.snDLSAP.remIntfValid = FALSE; /* remote interface version is valid */ - cfg.t.cfg.s.snDLSAP.remIntfVer = SNTIFVER; /* remote interface version */ -#endif - - return(sng_cfg_mtp3(&pst, &cfg)); -} - -/******************************************************************************/ -int ftmod_ss7_mtp3_nsap_config(int id) -{ - Pst pst; - SnMngmt cfg; - sng_nsap_t *k = &g_ftdm_sngss7_data.cfg.nsap[id]; - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSN; - - /*clear the configuration structure*/ - memset(&cfg, 0x0, sizeof(SnMngmt)); - - /*fill in some general sections of the header*/ - smHdrInit(&cfg.hdr); - - /*fill in the specific fields of the header*/ - cfg.hdr.msgType = TCFG; - cfg.hdr.entId.ent = ENTSN; - cfg.hdr.entId.inst = S_INST; - cfg.hdr.elmId.elmnt = STNSAP; - - cfg.hdr.elmId.elmntInst1 = k->spId; - - cfg.t.cfg.s.snNSAP.ssf = k->ssf; /* sub service field */ - cfg.t.cfg.s.snNSAP.lnkType = k->linkType; /* link type -ANSI, ITU, CHINA or BICI */ - cfg.t.cfg.s.snNSAP.upSwtch = k->switchType; /* user part switch type */ - cfg.t.cfg.s.snNSAP.selector = 0; /* upper layer selector */ - cfg.t.cfg.s.snNSAP.mem.region = S_REG; /* memory region id */ - cfg.t.cfg.s.snNSAP.mem.pool = S_POOL; /* memory pool id */ - cfg.t.cfg.s.snNSAP.prior = PRIOR0; /* priority */ - cfg.t.cfg.s.snNSAP.route = RTESPEC; /* route */ -#if( SS7_ANS92 || SS7_ANS88 || SS7_ANS96 || SS7_CHINA ) - cfg.t.cfg.s.snNSAP.dpcLen = DPC24; /* dpc length 14 or 24 bits */ -#else - cfg.t.cfg.s.snNSAP.dpcLen = DPC14; /* dpc length 14 or 24 bits */ -#endif -#if (defined(SN_SG) || defined(TDS_ROLL_UPGRADE_SUPPORT)) - cfg.t.cfg.s.snNSAP.usrParts = ; /* user parts configured on self postatic int code on IP side */ -#endif -#ifdef TDS_ROLL_UPGRADE_SUPPORT - cfg.t.cfg.s.snNSAP.remIntfValid = FALSE; /* remote interface version is valid */ - cfg.t.cfg.s.snNSAP.remIntfVer = SNTIFVER; /* remote interface version */ -#endif - - return(sng_cfg_mtp3(&pst, &cfg)); -} - -/******************************************************************************/ -int ftmod_ss7_mtp3_linkset_config(int id) -{ - Pst pst; - SnMngmt cfg; - int c; - sng_link_set_t *k = &g_ftdm_sngss7_data.cfg.mtpLinkSet[id]; - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSN; - - /*clear the configuration structure*/ - memset(&cfg, 0x0, sizeof(SnMngmt)); - - /*fill in some general sections of the header*/ - smHdrInit(&cfg.hdr); - - /*fill in the specific fields of the header*/ - cfg.hdr.msgType = TCFG; - cfg.hdr.entId.ent = ENTSN; - cfg.hdr.entId.inst = S_INST; - cfg.hdr.elmId.elmnt = STLNKSET; /* link set */ - - cfg.hdr.elmId.elmntInst1 = k->id; - - cfg.t.cfg.s.snLnkSet.lnkSetId = k->id; /* link set ID */ - cfg.t.cfg.s.snLnkSet.lnkSetType = k->linkType; /* link type */ - cfg.t.cfg.s.snLnkSet.adjDpc = k->apc; /* adjacent DPC */ - cfg.t.cfg.s.snLnkSet.nmbActLnkReqd = k->minActive; /* minimum number of active links */ - cfg.t.cfg.s.snLnkSet.nmbCmbLnkSet = k->numLinks; /* number of combined link sets */ - for(c = 0; c < k->numLinks;c++) { - cfg.t.cfg.s.snLnkSet.cmbLnkSet[c].cmbLnkSetId = k->links[c]; - cfg.t.cfg.s.snLnkSet.cmbLnkSet[c].lnkSetPrior = 0; - } - - - return(sng_cfg_mtp3(&pst, &cfg)); -} - -/******************************************************************************/ -int ftmod_ss7_mtp3_route_config(int id) -{ - Pst pst; - SnMngmt cfg; - sng_route_t *k = &g_ftdm_sngss7_data.cfg.mtpRoute[id]; - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSN; - - /*clear the configuration structure*/ - memset(&cfg, 0x0, sizeof(SnMngmt)); - - /*fill in some general sections of the header*/ - smHdrInit(&cfg.hdr); - - /*fill in the specific fields of the header*/ - cfg.hdr.msgType = TCFG; - cfg.hdr.entId.ent = ENTSN; - cfg.hdr.entId.inst = S_INST; - cfg.hdr.elmId.elmnt = STROUT; - - cfg.hdr.elmId.elmntInst1 = k->id; - - cfg.t.cfg.s.snRout.dpc = k->dpc; /* destination postatic int code */ - cfg.t.cfg.s.snRout.spType = LSN_TYPE_SP; /* signalling postatic int type */ - cfg.t.cfg.s.snRout.swtchType = k->linkType; /* switch type */ - cfg.t.cfg.s.snRout.upSwtch = k->switchType; /* user part switch type */ - cfg.t.cfg.s.snRout.cmbLnkSetId = k->cmbLinkSetId; /* combined link set ID */ - if (k->dir == SNG_RTE_UP) { - cfg.t.cfg.s.snRout.dir = LSN_RTE_UP; /* direction */ - } else { - cfg.t.cfg.s.snRout.dir = LSN_RTE_DN; /* direction */ - } - cfg.t.cfg.s.snRout.rteToAdjSp = 0; /* flag indicating this route to adjacent SP */ - cfg.t.cfg.s.snRout.ssf = k->ssf; /* sub service field */ - cfg.t.cfg.s.snRout.brdcastFlg = TRUE; /* flag indicating to have TFP broadcast */ - if (cfg.t.cfg.s.snRout.swtchType == LSN_SW_ITU) { - cfg.t.cfg.s.snRout.rstReq = LSN_ITU92_RST; /* Restart type supported by the node */ - } else if ((cfg.t.cfg.s.snRout.swtchType == LSN_SW_ANS) || - (cfg.t.cfg.s.snRout.swtchType == LSN_SW_ANS96)) { - cfg.t.cfg.s.snRout.rstReq = LSN_ANS_RST; /* Restart type supported by the node */ - } else { - cfg.t.cfg.s.snRout.rstReq = LSN_NO_RST; /* Restart type supported by the node */ - } - if ((cfg.t.cfg.s.snRout.swtchType == LSN_SW_ITU) || - (cfg.t.cfg.s.snRout.swtchType == LSN_SW_CHINA) || - (cfg.t.cfg.s.snRout.swtchType == LSN_SW_BICI)) { - cfg.t.cfg.s.snRout.slsRange = LSN_ITU_SLS_RANGE; /* max value of SLS for this DPC */ - } else { - cfg.t.cfg.s.snRout.slsRange = LSN_ANSI_5BIT_SLS_RANGE; /* max value of SLS for this DPC */ - } - cfg.t.cfg.s.snRout.lsetSel = 0x1; /* linkset selection bit in SLS for STP */ - cfg.t.cfg.s.snRout.multiMsgPrior = TRUE; /* TRUE if multiple cong priorities of messages */ - cfg.t.cfg.s.snRout.rctReq = TRUE; /* route set congestion test required or not */ - cfg.t.cfg.s.snRout.slsLnk = FALSE; -#ifdef LSNV2 -# if (SS7_NTT || defined(TDS_ROLL_UPGRADE_SUPPORT)) - cfg.t.cfg.s.snRout.destSpec =; /* destination specfication A or B*/ -# endif -#endif -#if (defined(LSNV3) || defined(SN_MULTIPLE_NETWORK_RESTART)) - cfg.t.cfg.s.snRout.tfrReq =; /* TFR procedure required or not */ -#endif - cfg.t.cfg.s.snRout.tmr.t6.enb = TRUE; - cfg.t.cfg.s.snRout.tmr.t6.val = k->t6; - cfg.t.cfg.s.snRout.tmr.t8.enb = TRUE; /* t8 - transfer prohibited inhibition timer */ - cfg.t.cfg.s.snRout.tmr.t8.val = k->t8; - cfg.t.cfg.s.snRout.tmr.t10.enb = TRUE; /* t10 - waiting to repeat route set test */ - cfg.t.cfg.s.snRout.tmr.t10.val = k->t10; - cfg.t.cfg.s.snRout.tmr.t11.enb = TRUE; /* t11 - transfer restrict timer */ - cfg.t.cfg.s.snRout.tmr.t11.val = k->t11; - cfg.t.cfg.s.snRout.tmr.t19.enb = TRUE; /* t19 - TRA sent timer */ - cfg.t.cfg.s.snRout.tmr.t19.val = k->t19; - cfg.t.cfg.s.snRout.tmr.t21.enb = TRUE; /* t21 - waiting to restart traffic routed through adjacent SP */ - cfg.t.cfg.s.snRout.tmr.t21.val = k->t21; - -#if (defined(LSNV3) || defined(SN_MULTIPLE_NETWORK_RESTART)) - cfg.t.cfg.s.snRout.tmr.t15.enb = TRUE; /* t15 - waiting to start route set congestion test */ - cfg.t.cfg.s.snRout.tmr.t15.val = k->t15; - cfg.t.cfg.s.snRout.tmr.t16.enb = TRUE; /* t16 - waiting for route set congestion status update */ - cfg.t.cfg.s.snRout.tmr.t16.val = k->t16; - cfg.t.cfg.s.snRout.tmr.t18.enb = TRUE; /* t18 - transfer prohibited inhibition timer */ - cfg.t.cfg.s.snRout.tmr.t18.val = k->t18; -# if (SS7_ANS92 || SS7_ANS88 || SS7_ANS96 || defined(TDS_ROLL_UPGRADE_SUPPORT)) - cfg.t.cfg.s.snRout.tmr.t25.enb = TRUE; /* t25 - waiting to traffic resatrt allowed message for ANSI */ - cfg.t.cfg.s.snRout.tmr.t25.val = k->t25; - cfg.t.cfg.s.snRout.tmr.t26.enb = TRUE; /* t26 - waiting to repeat traffic restart waiting message for ANSI */ - cfg.t.cfg.s.snRout.tmr.t26.val = k->t26; -# endif -#endif -#if (SS7_TTC || SS7_NTT || defined(TDS_ROLL_UPGRADE_SUPPORT)) - cfg.t.cfg.s.snRout.tmr.tc.enb = TRUE; /* tc - Waiting for congestion abatement */ - cfg.t.cfg.s.snRout.tmr.tc.val = k->tc; -#endif -#if (defined(SN_SG) || defined(TDS_ROLL_UPGRADE_SUPPORT)) - cfg.t.cfg.s.snRout.tmr.tQry.enb = TRUE; /* Periodic query timer over the NIF */ - cfg.t.cfg.s.snRout.tmr.tQry.val = k->tqry; -#endif - - return(sng_cfg_mtp3(&pst, &cfg)); -} - -/******************************************************************************/ -int ftmod_ss7_isup_nsap_config(int id) -{ - SiMngmt cfg; - Pst pst; - sng_nsap_t *k = &g_ftdm_sngss7_data.cfg.nsap[id]; - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSI; - - /*clear the configuration structure*/ - memset(&cfg, 0x0, sizeof(SiMngmt)); - - /*fill in some general sections of the header*/ - smHdrInit(&cfg.hdr); - - /*fill in the specific fields of the header*/ - cfg.hdr.msgType = TCFG; - cfg.hdr.entId.ent = ENTSI; - cfg.hdr.entId.inst = S_INST; - cfg.hdr.elmId.elmnt = STNSAP; - - cfg.hdr.elmId.elmntInst1 = k->id; - -#if (SI_LMINT3 || SMSI_LMINT3) - cfg.t.cfg.s.siNSap.nsapId = k->id; /* Id of the NSAP being configured */ -#endif - cfg.t.cfg.s.siNSap.nwId = k->nwId; /* Network Id */ - cfg.t.cfg.s.siNSap.spId = k->spId; /* service providor id */ - cfg.t.cfg.s.siNSap.ssf = k->ssf; /* sub service field */ - cfg.t.cfg.s.siNSap.dstEnt = ENTSN; /* entity */ - cfg.t.cfg.s.siNSap.dstInst = S_INST; /* instance */ - cfg.t.cfg.s.siNSap.prior = PRIOR0; /* priority */ - cfg.t.cfg.s.siNSap.route = RTESPEC; /* route */ - cfg.t.cfg.s.siNSap.dstProcId = SFndProcId(); /* destination processor id */ - cfg.t.cfg.s.siNSap.sapType = SAP_MTP; /* sap type */ - cfg.t.cfg.s.siNSap.selector = 0; /* selector */ - cfg.t.cfg.s.siNSap.tINT.enb = TRUE; /* interface (Bind Confirm) timer */ - cfg.t.cfg.s.siNSap.tINT.val = 50; - cfg.t.cfg.s.siNSap.mem.region = S_REG; /* memory region & pool id */ - cfg.t.cfg.s.siNSap.mem.pool = S_POOL; - -#ifdef TDS_ROLL_UPGRADE_SUPPORT - cfg.t.cfg.s.siNSap.remIntfValid = FALSE; /* remote interface version is valid */ - cfg.t.cfg.s.siNSap.remIntfVer; /* remote interface version */ -#endif - - return(sng_cfg_isup(&pst, &cfg)); -} - -/******************************************************************************/ -int ftmod_ss7_isup_intf_config(int id) -{ - SiMngmt cfg; - Pst pst; - sng_isup_inf_t *k = &g_ftdm_sngss7_data.cfg.isupIntf[id]; - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSI; - - /*clear the configuration structure*/ - memset(&cfg, 0x0, sizeof(SiMngmt)); - - /*fill in some general sections of the header*/ - smHdrInit(&cfg.hdr); - - /*fill in the specific fields of the header*/ - cfg.hdr.msgType = TCFG; - cfg.hdr.entId.ent = ENTSI; - cfg.hdr.entId.inst = S_INST; - cfg.hdr.elmId.elmnt = SI_STINTF; - - cfg.hdr.elmId.elmntInst1 = k->id; - - cfg.t.cfg.s.siIntfCb.intfId = k->id; /* Interface id */ - cfg.t.cfg.s.siIntfCb.nwId = k->nwId; /* Network Id */ - cfg.t.cfg.s.siIntfCb.sapId = k->isap; /* Id of the Upper ISUP SAP */ - cfg.t.cfg.s.siIntfCb.opc = k->spc; /* physical originating postatic int code */ - cfg.t.cfg.s.siIntfCb.phyDpc = k->dpc; /* physical destination postatic int code */ - cfg.t.cfg.s.siIntfCb.swtch = k->switchType; /* Protocol Switch */ - cfg.t.cfg.s.siIntfCb.ssf = k->ssf; /* subsystem service information */ - cfg.t.cfg.s.siIntfCb.pauseActn = SI_PAUSE_CLRTRAN; /* call clearing behavior upon rx. PAUSE */ - cfg.t.cfg.s.siIntfCb.dpcCbTmr.t4.enb = TRUE; /* t4 timer - user part test sent */ - cfg.t.cfg.s.siIntfCb.dpcCbTmr.t4.val = k->t4; - cfg.t.cfg.s.siIntfCb.dpcCbTmr.tPAUSE.enb = TRUE; /* waiting for PAUSE to be effective */ - cfg.t.cfg.s.siIntfCb.dpcCbTmr.tPAUSE.val = k->tpause; - cfg.t.cfg.s.siIntfCb.dpcCbTmr.tSTAENQ.enb = TRUE; /* status enquiry timer */ - cfg.t.cfg.s.siIntfCb.dpcCbTmr.tSTAENQ.val = k->tstaenq; -#if SS7_ANS95 - cfg.t.cfg.s.siIntfCb.availTest = FALSE; /* circuit validation test */ -#endif -#if (SS7_ITU97 || SS7_ETSIV3 || SS7_UK || SS7_NZL || SS7_ITU2000 || SS7_KZ) - cfg.t.cfg.s.siIntfCb.checkTable = LSI_CHKTBLE_MRATE; /* Validation flag for Table 3 p1/p2 Q.763 */ -#endif -#if (SS7_ANS95 || SS7_ITU97 || SS7_ETSIV3 || SS7_UK || SS7_NZL || SS7_ITU2000 || SS7_KZ) - switch (k->switchType) { - case LSI_SW_TST: - case LSI_SW_ITU: - case LSI_SW_ITU97: - case LSI_SW_ITU2000: - case LSI_SW_ETSI: - case LSI_SW_ETSIV3: - case LSI_SW_RUSSIA: - case LSI_SW_RUSS2000: - case LSI_SW_INDIA: - case LSI_SW_CHINA: - cfg.t.cfg.s.siIntfCb.trunkType = TRUE; /* truck type E1(TRUE)/T1(FALSE) at intf */ - break; - case LSI_SW_ANS88: - case LSI_SW_ANS92: - case LSI_SW_ANS95: - case LSI_SW_BELL: - cfg.t.cfg.s.siIntfCb.trunkType = FALSE; /* truck type E1(TRUE)/T1(FALSE) at intf */ - break; - } - -#endif -#if (LSIV4 || LSIV5) - cfg.t.cfg.s.siIntfCb.lnkSelOpt = LSI_LINSEK_CIC; /* link select option */ -# if (SS7_ANS88 || SS7_ANS92 || SS7_ANS95 || SS7_BELL) - cfg.t.cfg.s.siIntfCb.lnkSelBits = LSI_LNKSEL_8BITS; /* number of bits for link selection */ -# endif -#endif - - return(sng_cfg_isup(&pst, &cfg)); -} - -/******************************************************************************/ -int ftmod_ss7_isup_ckt_config(int id) -{ - SiMngmt cfg; - Pst pst; - U32 tmp_flag; - sng_isup_ckt_t *k = &g_ftdm_sngss7_data.cfg.isupCkt[id]; - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSI; - - /* check the for the correct ProcId and make sure it goes to the right system */ - if (g_ftdm_sngss7_data.cfg.procId != 1) { - pst.dstProcId = 1; - } - - /*clear the configuration structure*/ - memset(&cfg, 0x0, sizeof(SiMngmt)); - - /*fill in some general sections of the header*/ - smHdrInit(&cfg.hdr); - - /*fill in the specific fields of the header*/ - cfg.hdr.msgType = TCFG; - cfg.hdr.entId.ent = ENTSI; - cfg.hdr.entId.inst = S_INST; - cfg.hdr.elmId.elmnt = STICIR; - - cfg.hdr.elmId.elmntInst1 = k->id; - - cfg.t.cfg.s.siCir.cirId = k->id; /* circuit id code */ - cfg.t.cfg.s.siCir.cic = k->cic; /* cic */ - cfg.t.cfg.s.siCir.intfId = k->infId; /* interface id */ - cfg.t.cfg.s.siCir.typeCntrl = k->typeCntrl; /* type of control */ - cfg.t.cfg.s.siCir.contReq = FALSE; /* continuity check required */ -#if (SI_218_COMP || SS7_ANS88 || SS7_ANS92 || SS7_ANS95 || SS7_BELL) - cfg.t.cfg.s.siCir.firstCic = 1; /* First cic in the circuit group */ - cfg.t.cfg.s.siCir.numCir = 24; /* Number of circuits in the circuit group */ - cfg.t.cfg.s.siCir.nonSS7Con = TRUE; /* connecting to non SS7 network */ - cfg.t.cfg.s.siCir.outTrkGrpN.length = 0; /* outgoing trunk group number (For EXM) */ - cfg.t.cfg.s.siCir.cvrTrkClli.length = 0; /* Trunk Group number (For CVR validation) */ - cfg.t.cfg.s.siCir.clli.length = 0; /* common language location identifier */ -#endif - cfg.t.cfg.s.siCir.cirTmr.t3.enb = TRUE; /* t3 timer - overload received */ - cfg.t.cfg.s.siCir.cirTmr.t3.val = k->t3; - cfg.t.cfg.s.siCir.cirTmr.t12.enb = TRUE; /* t12 timer - blocking sent */ - cfg.t.cfg.s.siCir.cirTmr.t12.val = k->t12; - cfg.t.cfg.s.siCir.cirTmr.t13.enb = TRUE; /* t13 timer - initial blocking sent */ - cfg.t.cfg.s.siCir.cirTmr.t13.val = k->t13; - cfg.t.cfg.s.siCir.cirTmr.t14.enb = TRUE; /* t14 timer - unblocking sent */ - cfg.t.cfg.s.siCir.cirTmr.t14.val = k->t14; - cfg.t.cfg.s.siCir.cirTmr.t15.enb = TRUE; /* t15 timer - initial unblocking sent */ - cfg.t.cfg.s.siCir.cirTmr.t15.val = k->t15; - cfg.t.cfg.s.siCir.cirTmr.t16.enb = TRUE; /* t16 timer - reset sent */ - cfg.t.cfg.s.siCir.cirTmr.t16.val = k->t16; - cfg.t.cfg.s.siCir.cirTmr.t17.enb = TRUE; /* t17 timer - initial reset sent */ - cfg.t.cfg.s.siCir.cirTmr.t17.val = k->t17; -#if (SS7_ANS88 || SS7_ANS92 || SS7_ANS95 || SS7_BELL) - cfg.t.cfg.s.siCir.cirTmr.tVal.enb = TRUE; /* circuit validation timer */ - cfg.t.cfg.s.siCir.cirTmr.tVal.val = k->tval; -#endif -#if (SS7_ANS95 || SS7_ITU97 || SS7_ETSIV3 || SS7_UK) - tmp_flag = 0x0; - /* bit 0 - 4 is the timeslot on the span for this circuit */ - tmp_flag = ( 1 ); - - /* bit 5 -> can this timeslot be used for contigous M-rate call */ - tmp_flag |= !(0x20); - - /* bit 6 -> does this timeslot support contigous M-rate call */ - tmp_flag |= !(0x40); - - cfg.t.cfg.s.siCir.slotId = tmp_flag ; /* physical slot id bit wise flag */ - cfg.t.cfg.s.siCir.ctrlMult = 0; /* Controller for multirate calls */ -#endif - - tmp_flag = 0x0; - /* bit 0 -> ANSI international support or national support */ - tmp_flag = k->ssf; - - /* bit 1 -> confusion message on */ - tmp_flag |= LSI_CIRFLG_CFN_ON; - - /*bit 2-3 -> circuit group carrier information */ - tmp_flag |= LSI_CFCI_ANALDIG; - - /*bit 4-5 -> alarm carrier */ - tmp_flag |= LSI_CFAC_UNKNOWN; - - /*bit 6-7 -> continuity check requirement*/ - tmp_flag |= LSI_CFCO_NONE; - - cfg.t.cfg.s.siCir.cirFlg = tmp_flag; /* Flag indicating diff cfg options for ckt */ - - return(sng_cfg_isup(&pst, &cfg)); -} - -/******************************************************************************/ -int ftmod_ss7_isup_isap_config(int id) -{ - SiMngmt cfg; - Pst pst; - sng_isap_t *k = &g_ftdm_sngss7_data.cfg.isap[id]; - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSI; - - /*clear the configuration structure*/ - memset(&cfg, 0x0, sizeof(SiMngmt)); - - /*fill in some general sections of the header*/ - smHdrInit(&cfg.hdr); - - /*fill in the specific fields of the header*/ - cfg.hdr.msgType = TCFG; - cfg.hdr.entId.ent = ENTSI; - cfg.hdr.entId.inst = S_INST; - cfg.hdr.elmId.elmnt = STISAP; - - cfg.hdr.elmId.elmntInst1 = k->id; - -#if (SI_LMINT3 || SMSI_LMINT3) - cfg.t.cfg.s.siSap.sapId = k->id; /* Id of the SAP being configured */ -#endif - cfg.t.cfg.s.siSap.swtch = k->switchType; /* Protocol Switch */ - cfg.t.cfg.s.siSap.ssf = k->ssf; /* Sub service field */ - cfg.t.cfg.s.siSap.sidIns = FALSE; /* SID insertion Flag */ - cfg.t.cfg.s.siSap.sidVer = FALSE; /* SID verification Flag */ - if ( cfg.t.cfg.s.siSap.sidIns == TRUE ) { /* SID */ - #if 0 - cfg.t.cfg.s.siSap.sid =; - cfg.t.cfg.s.siSap.natAddrInd =; /* SID Nature of Addres Indicator */ - cfg.t.cfg.s.siSap.sidNPlan =; /* SID Numbering Plan */ - cfg.t.cfg.s.siSap.sidPresInd =; /* default presentation indicator */ - cfg.t.cfg.s.siSap.incSidPresRes =; /* Presentation Restriction of incoming SID */ - cfg.t.cfg.s.siSap.sidPresRes =; /* Presentation Restriction */ - #endif - } else { - cfg.t.cfg.s.siSap.sid.length = 0; - /*cfg.t.cfg.s.siSap.sid.strg[0] =*/ - cfg.t.cfg.s.siSap.natAddrInd = ADDR_NOTPRSNT; /* SID Nature of Addres Indicator */ - cfg.t.cfg.s.siSap.sidNPlan = NP_ISDN; /* SID Numbering Plan */ - cfg.t.cfg.s.siSap.sidPresInd = FALSE; /* default presentation indicator */ - cfg.t.cfg.s.siSap.incSidPresRes = FALSE; /* Presentation Restriction of incoming SID */ - cfg.t.cfg.s.siSap.sidPresRes = 0; /* Presentation Restriction */ - } - cfg.t.cfg.s.siSap.reqOpt = FALSE; /* Request option */ - cfg.t.cfg.s.siSap.allCallMod = TRUE; /* call modification allowed flag */ - cfg.t.cfg.s.siSap.maxLenU2U = MAX_SI_USER_2_USER_LEN; /* Max length of user to user messages */ - cfg.t.cfg.s.siSap.passOnFlag = TRUE; /* flag for passing unknown par/msg */ - cfg.t.cfg.s.siSap.relLocation = ILOC_PRIVNETLU; /* release location indicator in cause val */ - cfg.t.cfg.s.siSap.prior = PRIOR0; /* priority */ - cfg.t.cfg.s.siSap.route = RTESPEC; /* route */ - cfg.t.cfg.s.siSap.selector = 0; /* selector */ - cfg.t.cfg.s.siSap.mem.region = S_REG; /* memory region & pool id */ - cfg.t.cfg.s.siSap.mem.pool = S_POOL; /* memory region & pool id */ - - cfg.t.cfg.s.siSap.tmr.t1.enb = TRUE; /* t1 timer - release sent */ - cfg.t.cfg.s.siSap.tmr.t1.val = k->t1; - cfg.t.cfg.s.siSap.tmr.t2.enb = TRUE; /* t2 timer - suspend received */ - cfg.t.cfg.s.siSap.tmr.t2.val = k->t2; - cfg.t.cfg.s.siSap.tmr.t5.enb = TRUE; /* t5 timer - initial release sent */ - cfg.t.cfg.s.siSap.tmr.t5.val = k->t5; - cfg.t.cfg.s.siSap.tmr.t6.enb = TRUE; /* t6 timer - suspend received */ - cfg.t.cfg.s.siSap.tmr.t6.val = k->t6; - cfg.t.cfg.s.siSap.tmr.t7.enb = TRUE; /* t7 timer - latest address sent */ - cfg.t.cfg.s.siSap.tmr.t7.val = k->t7; - cfg.t.cfg.s.siSap.tmr.t8.enb = TRUE; /* t8 timer - initial address received */ - cfg.t.cfg.s.siSap.tmr.t8.val = k->t8; - cfg.t.cfg.s.siSap.tmr.t9.enb = TRUE; /* t9 timer - latest address sent after ACM */ - cfg.t.cfg.s.siSap.tmr.t9.val = k->t9; - cfg.t.cfg.s.siSap.tmr.t27.enb = TRUE; /* t27 timer - wait. for continuity recheck */ - cfg.t.cfg.s.siSap.tmr.t27.val = k->t27; - cfg.t.cfg.s.siSap.tmr.t31.enb = TRUE; /* t31 timer - call reference frozen period */ - cfg.t.cfg.s.siSap.tmr.t31.val = k->t31; - cfg.t.cfg.s.siSap.tmr.t33.enb = TRUE; /* t33 timer - INR sent */ - cfg.t.cfg.s.siSap.tmr.t33.val = k->t33; - cfg.t.cfg.s.siSap.tmr.t34.enb = TRUE; /* t34 timer - wait. for continuity after recheck */ - cfg.t.cfg.s.siSap.tmr.t34.val = k->t34; - cfg.t.cfg.s.siSap.tmr.t36.enb = TRUE; /* waiting SGM */ - cfg.t.cfg.s.siSap.tmr.t36.val = k->t36; - cfg.t.cfg.s.siSap.tmr.tCCR.enb = TRUE; /* tCCR timer - continuity recheck timer */ - cfg.t.cfg.s.siSap.tmr.tCCR.val = k->tccr; - cfg.t.cfg.s.siSap.tmr.tRELRSP.enb = TRUE; /* waiting for release response */ - cfg.t.cfg.s.siSap.tmr.tRELRSP.val = k->trelrsp; - cfg.t.cfg.s.siSap.tmr.tFNLRELRSP.enb = TRUE; /* waiting for final release response */ - cfg.t.cfg.s.siSap.tmr.tFNLRELRSP.val = k->tfnlrelrsp; -#if (SS7_ANS88 || SS7_ANS92 || SS7_ANS95 || SS7_BELL) - cfg.t.cfg.s.siSap.tmr.tEx.enb = TRUE; /* tEx timer - Exit to be sent */ - cfg.t.cfg.s.siSap.tmr.tEx.val = k->tex; - cfg.t.cfg.s.siSap.tmr.tCCRt.enb = TRUE; /* tCCR timer (o/g side) - continuity recheck timer */ - cfg.t.cfg.s.siSap.tmr.tCCRt.val = k->tccrt; -#endif -#if (SS7_ANS92 || SS7_ANS95 || SS7_BELL) - cfg.t.cfg.s.siSap.tmr.tCRM.enb = TRUE; /* circuit reservation message timer */ - cfg.t.cfg.s.siSap.tmr.tCRM.val = k->tcrm; - cfg.t.cfg.s.siSap.tmr.tCRA.enb = TRUE; /* circuit reservation ack. timer */ - cfg.t.cfg.s.siSap.tmr.tCRA.val = k->tcra; -#endif -#if (SS7_ETSI || SS7_ITU97 || SS7_ETSIV3 || SS7_UK || SS7_NZL || SS7_KZ) - cfg.t.cfg.s.siSap.tmr.tECT.enb = TRUE; /* Explicit Call Transfer - waiting for loop prvnt rsp */ - cfg.t.cfg.s.siSap.tmr.tECT.val = k->tect; -#endif - -#ifdef TDS_ROLL_UPGRADE_SUPPORT - cfg.t.cfg.s.siSap.remIntfValid = FALSE; /* remote interface version is valid */ - cfg.t.cfg.s.siSap.remIntfVer =; /* remote interface version */ -#endif - - return(sng_cfg_isup(&pst, &cfg)); -} - -/******************************************************************************/ -int ftmod_ss7_cc_isap_config(int dstProcId) -{ - CcMngmt cfg; - Pst pst; - - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTCC; - - /*clear the configuration structure*/ - memset(&cfg, 0x0, sizeof(CcMngmt)); - - /*fill in some general sections of the header*/ - smHdrInit(&cfg.hdr); - - /*fill in the specific fields of the header*/ - cfg.hdr.msgType = TCFG; - cfg.hdr.entId.ent = ENTCC; - cfg.hdr.entId.inst = S_INST; - cfg.hdr.elmId.elmnt = STISAP; - - cfg.hdr.elmId.elmntInst1 = 1; - - cfg.t.cfg.s.ccISAP.suId = 1; - cfg.t.cfg.s.ccISAP.spId = 1; - cfg.t.cfg.s.ccISAP.pst.dstProcId = dstProcId; - cfg.t.cfg.s.ccISAP.pst.dstEnt = ENTSI; - cfg.t.cfg.s.ccISAP.pst.dstInst = S_INST; - cfg.t.cfg.s.ccISAP.pst.srcProcId = SFndProcId(); - cfg.t.cfg.s.ccISAP.pst.srcEnt = ENTCC; - cfg.t.cfg.s.ccISAP.pst.srcInst = S_INST; - cfg.t.cfg.s.ccISAP.pst.prior = PRIOR0; - cfg.t.cfg.s.ccISAP.pst.route = RTESPEC; - cfg.t.cfg.s.ccISAP.pst.region = S_REG; - cfg.t.cfg.s.ccISAP.pst.pool = S_POOL; - cfg.t.cfg.s.ccISAP.pst.selector = 0; - - return(sng_cfg_cc(&pst, &cfg)); -} - -/******************************************************************************/ -int ftmod_ss7_relay_chan_config(int id) -{ - RyMngmt cfg; /*configuration structure*/ - Pst pst; /*post structure*/ - sng_relay_t *k = &g_ftdm_sngss7_data.cfg.relay[id]; - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTRY; - - /* clear the configuration structure */ - memset(&cfg, 0x0, sizeof(RyMngmt)); - - /* fill in some general sections of the header */ - smHdrInit(&cfg.hdr); - - /*fill in the specific fields of the header */ - cfg.hdr.msgType = TCFG; - cfg.hdr.entId.ent = ENTRY; - cfg.hdr.entId.inst = S_INST; - cfg.hdr.elmId.elmnt = STCHCFG; - - cfg.hdr.elmId.elmntInst1 = k->id; - - cfg.t.cfg.s.ryChanCfg.id = k->id; /* channel id */ - cfg.t.cfg.s.ryChanCfg.type = k->type; /* channel type */ -/* cfg.t.cfg.s.ryChanCfg.msInd =;*/ /* master/slave indicator */ - if (k->type == LRY_CT_TCP_LISTEN) { - cfg.t.cfg.s.ryChanCfg.low = 0; /* low proc id for channel */ - cfg.t.cfg.s.ryChanCfg.high = 0; /* high proc id for channel */ - } else { - cfg.t.cfg.s.ryChanCfg.low = k->procId; /* low proc id for channel */ - cfg.t.cfg.s.ryChanCfg.high = k->procId; /* high proc id for channel */ - } - cfg.t.cfg.s.ryChanCfg.nmbScanQ = MAX_RELAY_NMBSCAN; /* number of times to scan the queue */ - cfg.t.cfg.s.ryChanCfg.flags = LRY_FLG_INTR; /* flags */ - cfg.t.cfg.s.ryChanCfg.congThrsh = MAX_RELAY_CONGTHRSH; /* congestion threshold */ - cfg.t.cfg.s.ryChanCfg.dropThrsh = 0; /* drop threshold */ - cfg.t.cfg.s.ryChanCfg.contThrsh = MAX_RELAY_CONGTHRSH + 1; /* continue threshold */ - cfg.t.cfg.s.ryChanCfg.kaTxTmr.enb = 1; /* keep alive transmit timer config */ - cfg.t.cfg.s.ryChanCfg.kaTxTmr.val = RY_TX_KP_ALIVE_TMR; - cfg.t.cfg.s.ryChanCfg.kaRxTmr.enb = 1; /* keep alive receive timer config */ - cfg.t.cfg.s.ryChanCfg.kaRxTmr.val = RY_RX_KP_ALIVE_TMR; - cfg.t.cfg.s.ryChanCfg.btTmr.enb = 1; /* boot timer */ - cfg.t.cfg.s.ryChanCfg.btTmr.val = RY_BT_TMR; - cfg.t.cfg.s.ryChanCfg.region = S_REG; /* Relay region */ - cfg.t.cfg.s.ryChanCfg.pool = S_POOL; /* Relay pool */ -#if (RY_ENBUDPSOCK || RY_ENBTCPSOCK) - cfg.t.cfg.s.ryChanCfg.listenPortNo = k->port; /* Listen Port of Rx Relay Channel*/ - strncpy(cfg.t.cfg.s.ryChanCfg.transmittoHostName, k->hostname, (size_t)RY_REMHOSTNAME_SIZE); - cfg.t.cfg.s.ryChanCfg.transmittoPortNo = k->port; /* TransmitTo PortId for Tx Relay Channel */ - cfg.t.cfg.s.ryChanCfg.targetProcId = k->procId; /* procId of the node present in the other end of this channel */ -# ifdef LRY1 - cfg.t.cfg.s.ryChanCfg.sockParam =; /* Socket Parameters */ -# endif /* LRY1 */ -# ifdef LRYV2 - cfg.t.cfg.s.ryChanCfg.selfHostName[RY_REMHOSTNAME_SIZE]; -# endif /* LRY2 */ -#endif /* RY_ENBUDPSOCK || RY_ENBTCPSOCK */ - - return(sng_cfg_relay(&pst, &cfg)); -} - -/******************************************************************************/ -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ -/******************************************************************************/ diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c deleted file mode 100644 index 98a2398630..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c +++ /dev/null @@ -1,4007 +0,0 @@ -/* - * Copyright (c) 2009|Konrad Hammel - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE|EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Contributors: - * James Zhang - * - */ - -#if 0 -#define SMG_RELAY_DBG -#endif - -/* INCLUDE ********************************************************************/ -#include "ftmod_sangoma_ss7_main.h" -/******************************************************************************/ - -/* DEFINES ********************************************************************/ -/******************************************************************************/ - -/* GLOBALS ********************************************************************/ -/******************************************************************************/ - -/* PROTOTYPES *****************************************************************/ -ftdm_status_t ftdm_sngss7_handle_cli_cmd(ftdm_stream_handle_t *stream, const char *data); - -static ftdm_status_t handle_print_usage(ftdm_stream_handle_t *stream); - -static ftdm_status_t handle_show_procId(ftdm_stream_handle_t *stream); - -static ftdm_status_t handle_set_function_trace(ftdm_stream_handle_t *stream, int on, int level); -static ftdm_status_t handle_set_message_trace(ftdm_stream_handle_t *stream, int on, int level); -static ftdm_status_t handle_set_inhibit(ftdm_stream_handle_t *stream, char *name); -static ftdm_status_t handle_set_uninhibit(ftdm_stream_handle_t *stream, char *name); - -static ftdm_status_t handle_show_free(ftdm_stream_handle_t *stream, int span, int chan, int verbose); -static ftdm_status_t handle_show_inuse(ftdm_stream_handle_t *stream, int span, int chan, int verbose); -static ftdm_status_t handle_show_inreset(ftdm_stream_handle_t *stream, int span, int chan, int verbose); -static ftdm_status_t handle_show_flags(ftdm_stream_handle_t *stream, int span, int chan, int verbose); -static ftdm_status_t handle_show_blocks(ftdm_stream_handle_t *stream, int span, int chan, int verbose); -static ftdm_status_t handle_show_status(ftdm_stream_handle_t *stream, int span, int chan, int verbose); - -static ftdm_status_t handle_tx_rsc(ftdm_stream_handle_t *stream, int span, int chan, int verbose); -static ftdm_status_t handle_tx_grs(ftdm_stream_handle_t *stream, int span, int chan, int range, int verbose); - -static ftdm_status_t handle_tx_blo(ftdm_stream_handle_t *stream, int span, int chan, int verbose); -static ftdm_status_t handle_tx_ubl(ftdm_stream_handle_t *stream, int span, int chan, int verbose); - -static ftdm_status_t handle_tx_cgb(ftdm_stream_handle_t *stream, int span, int chan, int range, int verbose); -static ftdm_status_t handle_tx_cgu(ftdm_stream_handle_t *stream, int span, int chan, int range, int verbose); - -static ftdm_status_t handle_bind_link(ftdm_stream_handle_t *stream, char *name); -static ftdm_status_t handle_unbind_link(ftdm_stream_handle_t *stream, char *name); -static ftdm_status_t handle_activate_link(ftdm_stream_handle_t *stream, char *name); -static ftdm_status_t handle_deactivate_link(ftdm_stream_handle_t *stream, char *name); - -static ftdm_status_t handle_activate_linkset(ftdm_stream_handle_t *stream, char *name); -static ftdm_status_t handle_deactivate_linkset(ftdm_stream_handle_t *stream, char *name); - -static ftdm_status_t handle_tx_lpo(ftdm_stream_handle_t *stream, char *name); -static ftdm_status_t handle_tx_lpr(ftdm_stream_handle_t *stream, char *name); - -static ftdm_status_t handle_status_mtp3link(ftdm_stream_handle_t *stream, char *name); -static ftdm_status_t handle_status_mtp2link(ftdm_stream_handle_t *stream, char *name); -static ftdm_status_t handle_status_linkset(ftdm_stream_handle_t *stream, char *name); -static ftdm_status_t handle_status_relay(ftdm_stream_handle_t *stream, char *name); -static ftdm_status_t handle_status_isup_ckt(ftdm_stream_handle_t *stream, char *id_name); - -static ftdm_status_t extract_span_chan(char *argv[10], int pos, int *span, int *chan); -static ftdm_status_t check_arg_count(int args, int min); - - - -static ftdm_status_t cli_ss7_show_general(ftdm_stream_handle_t *stream); - -static ftdm_status_t cli_ss7_show_mtp2link_by_id(ftdm_stream_handle_t *stream, int rcId); -static ftdm_status_t cli_ss7_show_mtp2link_by_name(ftdm_stream_handle_t *stream, char *name); -static ftdm_status_t cli_ss7_show_all_mtp2link(ftdm_stream_handle_t *stream); - -static ftdm_status_t cli_ss7_show_mtp3link_by_id(ftdm_stream_handle_t *stream, int rcId); -static ftdm_status_t cli_ss7_show_mtp3link_by_name(ftdm_stream_handle_t *stream, char *name); -static ftdm_status_t cli_ss7_show_all_mtp3link(ftdm_stream_handle_t *stream); - -static ftdm_status_t cli_ss7_show_relay_by_id(ftdm_stream_handle_t *stream, int rcId); -static ftdm_status_t cli_ss7_show_relay_by_name(ftdm_stream_handle_t *stream, char *name); -static ftdm_status_t cli_ss7_show_all_relay(ftdm_stream_handle_t *stream); - -static ftdm_status_t cli_ss7_show_channel_detail_of_span(ftdm_stream_handle_t *stream, char *span_id, char *chan_id); -static ftdm_status_t cli_ss7_show_all_channels_of_span(ftdm_stream_handle_t *stream, char *span_id); - -static ftdm_status_t cli_ss7_show_span_by_id(ftdm_stream_handle_t *stream, char *span_id); -static ftdm_status_t cli_ss7_show_all_spans_general(ftdm_stream_handle_t *stream); -static ftdm_status_t cli_ss7_show_all_spans_detail(ftdm_stream_handle_t *stream); -static ftdm_status_t handle_show_sctp_profiles(ftdm_stream_handle_t *stream); -static ftdm_status_t handle_show_sctp_profile(ftdm_stream_handle_t *stream, char* sctp_profile_name); -static ftdm_status_t handle_show_m2ua_profiles(ftdm_stream_handle_t *stream); -static ftdm_status_t handle_show_m2ua_profile(ftdm_stream_handle_t *stream, char* m2ua_profile_name); -static ftdm_status_t handle_show_m2ua_peer_status(ftdm_stream_handle_t *stream, char* m2ua_profile_name); -static ftdm_status_t handle_show_m2ua_cluster_status(ftdm_stream_handle_t *stream, char* m2ua_profile_name); -static ftdm_status_t handle_show_nif_profiles(ftdm_stream_handle_t *stream); -static ftdm_status_t handle_show_nif_profile(ftdm_stream_handle_t *stream, char* profile_name); -int get_assoc_resp_buf(char* buf,SbMgmt* cfm); - -/******************************************************************************/ -/* FUNCTIONS ******************************************************************/ -ftdm_status_t ftdm_sngss7_handle_cli_cmd(ftdm_stream_handle_t *stream, const char *data) -{ - char *mycmd = NULL; - char *argv[10] = { 0 }; - int argc = 0; - int span = 0; - int chan = 0; - int range = 0; - int trace = 0; - int trace_level = 7; - int verbose = 1; - int c = 0; - - if (data) { - mycmd = ftdm_strdup(data); - argc = ftdm_separate_string(mycmd, ' ', argv, ftdm_array_len(argv)); - } - - if (check_arg_count(argc, 1)) { - goto handle_cli_error_argc; - } - - if (!strcasecmp(argv[c], "show")) { - /**************************************************************************/ - if (check_arg_count(argc, 2)) { - cli_ss7_show_general(stream); - return FTDM_SUCCESS; - } - c++; - - if (!strcasecmp(argv[c], "relay")) { - /**********************************************************************/ - c++; - handle_status_relay(stream, argv[c]); - - } else if (!strcasecmp(argv[c], "span")) { - /**********************************************************************/ - switch (argc) { - case 2: - { - /* > ftdm ss7 show span */ - cli_ss7_show_all_spans_general(stream); - } - break; - - case 3: - { - if (!strcasecmp(argv[2], "all")) { - /* > ftdm ss7 show span all */ - cli_ss7_show_all_spans_detail(stream); - } else { - /* > ftdm ss7 show span 1 */ - cli_ss7_show_span_by_id(stream, argv[2]); - } - } - break; - - case 4: - { - /* > ftdm ss7 show span 1 chan */ - cli_ss7_show_all_channels_of_span(stream, argv[2]); - } - break; - - case 5: - default: - { - if (!strcasecmp(argv[3], "chan")) { - /* > ftdm ss7 show span 1 chan 2 */ - cli_ss7_show_channel_detail_of_span(stream, argv[2], argv[4]); - } else { - /* > ftdm ss7 show span 1 bla bla bla*/ - cli_ss7_show_all_channels_of_span(stream, argv[2]); - } - } - break; - } - } else if (!strcasecmp(argv[c], "status")) { - /**********************************************************************/ - if (check_arg_count(argc, 3)) { - cli_ss7_show_general(stream); - return FTDM_SUCCESS; - } - - c++; - - if (!strcasecmp(argv[c], "mtp3")) { - /******************************************************************/ - c++; - handle_status_mtp3link(stream, argv[c]); - /******************************************************************/ - } else if (!strcasecmp(argv[c], "mtp2")) { - /******************************************************************/ - c++; - handle_status_mtp2link(stream, argv[c]); - /******************************************************************/ - } else if (!strcasecmp(argv[c], "linkset")) { - /******************************************************************/ - c++; - handle_status_linkset(stream, argv[c]); - /******************************************************************/ - } else if (!strcasecmp(argv[c], "relay")) { - /******************************************************************/ - c++; - handle_status_relay(stream, argv[c]); - /******************************************************************/ - } else if (!strcasecmp(argv[c], "span")) { - /******************************************************************/ - if (check_arg_count(argc, 6)) goto handle_cli_error_argc; - - if (extract_span_chan(argv, c, &span, &chan)) goto handle_cli_error_span_chan; - - handle_show_status(stream, span, chan, verbose); - /******************************************************************/ - } else if (!strcasecmp(argv[c], "isup")) { - /******************************************************************/ - if (check_arg_count(argc, 4)) goto handle_cli_error_argc; - c++; - - if (!strcasecmp(argv[c], "ckt")) { - /**************************************************************/ - if (check_arg_count(argc, 5)) goto handle_cli_error_argc; - c++; - - handle_status_isup_ckt(stream, argv[c]); - /**************************************************************/ - } else { - /**************************************************************/ - stream->write_function(stream, "Unknown \"status isup\" command\n"); - goto handle_cli_error; - /**************************************************************/ - } - /******************************************************************/ - } else { - /******************************************************************/ - stream->write_function(stream, "Unknown \"status\" command\n"); - goto handle_cli_error; - /******************************************************************/ - } - /**********************************************************************/ - } else if (!strcasecmp(argv[c], "inuse")) { - /**********************************************************************/ - if (check_arg_count(argc, 6)) goto handle_cli_error_argc; - c++; - - if (!strcasecmp(argv[c], "span")) { - /******************************************************************/ - if (check_arg_count(argc, 6)) goto handle_cli_error_argc; - - if (extract_span_chan(argv, c, &span, &chan)) goto handle_cli_error_span_chan; - - handle_show_inuse(stream, span, chan, verbose); - /******************************************************************/ - } else { - /******************************************************************/ - stream->write_function(stream, "Unknown \"inuse\" command\n"); - goto handle_cli_error; - /******************************************************************/ - } - /**********************************************************************/ - } else if (!strcasecmp(argv[c], "inreset")) { - /**********************************************************************/ - if (check_arg_count(argc, 6)) goto handle_cli_error_argc; - c++; - - if (!strcasecmp(argv[c], "span")) { - /******************************************************************/ - if (check_arg_count(argc, 6)) goto handle_cli_error_argc; - - if (extract_span_chan(argv, c, &span, &chan)) goto handle_cli_error_span_chan; - - handle_show_inreset(stream, span, chan, verbose); - /******************************************************************/ - } else { - /******************************************************************/ - stream->write_function(stream, "Unknown \"inreset\" command\n"); - goto handle_cli_error; - /******************************************************************/ - } - /**********************************************************************/ - } else if (!strcasecmp(argv[c], "free")) { - /**********************************************************************/ - if (check_arg_count(argc, 6)) goto handle_cli_error_argc; - c++; - - if (!strcasecmp(argv[c], "span")) { - /******************************************************************/ - if (check_arg_count(argc, 6)) goto handle_cli_error_argc; - - if (extract_span_chan(argv, c, &span, &chan)) goto handle_cli_error_span_chan; - - handle_show_free(stream, span, chan, verbose); - /******************************************************************/ - } else { - /******************************************************************/ - stream->write_function(stream, "Unknown \"free\" command\n"); - goto handle_cli_error; - /******************************************************************/ - } - /**********************************************************************/ - } else if (!strcasecmp(argv[c], "blocks")) { - /**********************************************************************/ - if (check_arg_count(argc, 6)) goto handle_cli_error_argc; - c++; - - if (!strcasecmp(argv[c], "span")) { - /******************************************************************/ - if (check_arg_count(argc, 6)) goto handle_cli_error_argc; - - if (extract_span_chan(argv, c, &span, &chan)) goto handle_cli_error_span_chan; - - handle_show_blocks(stream, span, chan, verbose); - /******************************************************************/ - } else { - /******************************************************************/ - stream->write_function(stream, "Unknown \"blocks\" command\n"); - goto handle_cli_error; - /******************************************************************/ - } - /**********************************************************************/ - } else if (!strcasecmp(argv[c], "flags")) { - /**********************************************************************/ - if (check_arg_count(argc, 6)) goto handle_cli_error_argc; - c++; - - if (!strcasecmp(argv[c], "span")) { - /******************************************************************/ - if (check_arg_count(argc, 6)) goto handle_cli_error_argc; - - if (extract_span_chan(argv, c, &span, &chan)) goto handle_cli_error_span_chan; - - handle_show_flags(stream, span, chan, verbose); - /******************************************************************/ - } else { - /******************************************************************/ - stream->write_function(stream, "Unknown \"flags\" command\n"); - goto handle_cli_error; - /******************************************************************/ - } - /**********************************************************************/ - } else if (!strcasecmp(argv[c], "mem")) { - /**********************************************************************/ - sng_isup_reg_info_show(); - /**********************************************************************/ - } else if (!strcasecmp(argv[c], "stats")) { - /**********************************************************************/ -/* sng_mtp1_sts_t sts; - - memset(&sts, 0x0, sizeof(sng_mtp1_sts_t)); - - sng_mtp1_sts(1, &sts); - - stream->write_function(stream,"MTP1 tx stats:|tx_frm=%d|tx_err=%d|tx_fisu=%d|tx_lssu=%d|tx_msu=%d|\n", - sts.tx_frm, sts.tx_err, sts.tx_fisu, sts.tx_lssu, sts.tx_msu); - stream->write_function(stream,"MTP1 rx stats:|rx_frm=%d|rx_err=%d|rx_fisu=%d|rx_lssu=%d|rx_msu=%d|\n", - sts.rx_frm, sts.rx_err, sts.rx_fisu, sts.rx_lssu, sts.rx_msu); -*/ - /**********************************************************************/ - } else if (!strcasecmp(argv[c], "procid")) { - /**********************************************************************/ - handle_show_procId(stream); - - /**********************************************************************/ - } else{ - /**********************************************************************/ - stream->write_function(stream, "Unknown \"show\" command\n"); - goto handle_cli_error; - } - /**************************************************************************/ - } else if (!strcasecmp(argv[c], "xmlshow")) { - /**************************************************************************/ - - if (check_arg_count(argc, 2)) { - stream->write_function(stream, "Unknown \"xmlshow\" command\n"); - goto handle_cli_error; - } - c++; - /**************************************************************************/ - if (!strcasecmp(argv[c], "m2ua")) { - /**************************************************************************/ - switch(argc) - { - case 2: /* show m2ua */ - { - handle_show_m2ua_profiles(stream); - break; - } - case 3: /* show m2ua */ - { - c++; - handle_show_m2ua_profile(stream, argv[c]); - break; - } - case 4: - { - char* profile_name = argv[++c]; - c++; - /***************************************************************/ - if(!strcasecmp(argv[c],"peerstatus")){ - /***************************************************************/ - handle_show_m2ua_peer_status(stream, profile_name); - /***************************************************************/ - }else if(!strcasecmp(argv[c],"clusterstatus")){ - /***************************************************************/ - handle_show_m2ua_cluster_status(stream, profile_name); - /***************************************************************/ - } else{ - /***************************************************************/ - stream->write_function(stream, "Unknown \"show m2ua \" command..\n"); - goto handle_cli_error_argc; - } - break; - } - default: - goto handle_cli_error_argc; - } - - /**********************************************************************/ - } else if (!strcasecmp(argv[c], "nif")) { - /**********************************************************************/ - if (check_arg_count(argc, 3)){ - handle_show_nif_profiles(stream); - }else{ - c++; - handle_show_nif_profile(stream, argv[c]); - } - /**********************************************************************/ - } else if (!strcasecmp(argv[c], "sctp")) { - /**********************************************************************/ - if (check_arg_count(argc, 3)){ - handle_show_sctp_profiles(stream); - }else{ - c++; - handle_show_sctp_profile(stream, argv[c]); - } - /**********************************************************************/ - } else { - /**********************************************************************/ - stream->write_function(stream, "Unknown \"xmlshow\" command\n"); - goto handle_cli_error; - } - /**********************************************************************/ - } else if (!strcasecmp(argv[c], "set")) { - /**************************************************************************/ - if (check_arg_count(argc, 4)) goto handle_cli_error_argc; - c++; - - if (!strcasecmp(argv[c], "ftrace")) { - /**********************************************************************/ - c++; - trace = atoi(argv[c]); - c++; - trace_level = atoi(argv[c]); - c++; - handle_set_function_trace(stream, trace, trace_level); - /**********************************************************************/ - } else if (!strcasecmp(argv[c], "mtrace")) { - /**********************************************************************/ - c++; - trace = atoi(argv[c]); - c++; - trace_level = atoi(argv[c]); - c++; - handle_set_message_trace(stream, trace, trace_level); - /**********************************************************************/ - } else { - /**********************************************************************/ - stream->write_function(stream, "Unknown \"set\" command\n"); - goto handle_cli_error; - /**********************************************************************/ - } - /**************************************************************************/ - } else if (!strcasecmp(argv[c], "inhibit")) { - /**************************************************************************/ - if (check_arg_count(argc, 2)) goto handle_cli_error_argc; - c++; - - if (!strcasecmp(argv[c], "link")) { - /**********************************************************************/ - if (check_arg_count(argc, 3)) goto handle_cli_error_argc; - c++; - - handle_set_inhibit(stream, argv[c]); - /**********************************************************************/ - } else { - /**********************************************************************/ - stream->write_function(stream, "Unknown \"block\" command\n"); - goto handle_cli_error; - /**********************************************************************/ - } - /**************************************************************************/ - } else if (!strcasecmp(argv[c], "uninhibit")) { - /**************************************************************************/ - if (check_arg_count(argc, 2)) goto handle_cli_error_argc; - c++; - - if (!strcasecmp(argv[c], "link")) { - /**********************************************************************/ - if (check_arg_count(argc, 3)) goto handle_cli_error_argc; - c++; - - handle_set_uninhibit(stream, argv[c]); - /**********************************************************************/ - } else { - /**********************************************************************/ - stream->write_function(stream, "Unknown \"unblock\" command\n"); - goto handle_cli_error; - /**********************************************************************/ - } - /**************************************************************************/ - } else if (!strcasecmp(argv[c], "blo")) { - if (check_arg_count(argc, 2)) goto handle_cli_error_argc; - c++; - - if (!strcasecmp(argv[c], "span")) { - /**********************************************************************/ - if (check_arg_count(argc, 5)) goto handle_cli_error_argc; - - if (extract_span_chan(argv, c, &span, &chan)) goto handle_cli_error_span_chan; - - handle_tx_blo(stream, span, chan, verbose); - /**********************************************************************/ - } else { - /**********************************************************************/ - stream->write_function(stream, "Unknown \"block\" command\n"); - goto handle_cli_error; - /**********************************************************************/ - } - /**************************************************************************/ - } else if (!strcasecmp(argv[c], "ubl")) { - /**************************************************************************/ - if (check_arg_count(argc, 2)) goto handle_cli_error_argc; - c++; - - if (!strcasecmp(argv[c], "span")) { - /**********************************************************************/ - if (check_arg_count(argc, 5)) goto handle_cli_error_argc; - - if (extract_span_chan(argv, c, &span, &chan)) goto handle_cli_error_span_chan; - - handle_tx_ubl(stream, span, chan, verbose); - /**********************************************************************/ - } else { - /**********************************************************************/ - stream->write_function(stream, "Unknown \"ubl\" command\n"); - goto handle_cli_error; - /**********************************************************************/ - } - /**************************************************************************/ - } else if (!strcasecmp(argv[c], "cgb")) { - /**************************************************************************/ - if (check_arg_count(argc, 2)) goto handle_cli_error_argc; - c++; - - if (!strcasecmp(argv[c], "span")) { - /**********************************************************************/ - if (check_arg_count(argc, 5)) goto handle_cli_error_argc; - - if (extract_span_chan(argv, c, &span, &chan)) goto handle_cli_error_span_chan; - c = c + 4; - - if (check_arg_count(argc, 7)) goto handle_cli_error_argc; - - if (!strcasecmp(argv[c], "range")) { - /******************************************************************/ - c++; - range = atoi(argv[c]); - /******************************************************************/ - } else { - /******************************************************************/ - stream->write_function(stream, "Unknown \"cgb range\" command\n"); - goto handle_cli_error; - /******************************************************************/ - } - - handle_tx_cgb(stream, span, chan, range, verbose); - /**********************************************************************/ - } else { - /**********************************************************************/ - stream->write_function(stream, "Unknown \"cgb\" command\n"); - goto handle_cli_error; - /**********************************************************************/ - } - /**************************************************************************/ - } else if (!strcasecmp(argv[c], "cgu")) { - /**************************************************************************/ - if (check_arg_count(argc, 2)) goto handle_cli_error_argc; - c++; - - if (!strcasecmp(argv[c], "span")) { - /**********************************************************************/ - if (check_arg_count(argc, 5)) goto handle_cli_error_argc; - - if (extract_span_chan(argv, c, &span, &chan)) goto handle_cli_error_span_chan; - c = c + 4; - - if (check_arg_count(argc, 7)) goto handle_cli_error_argc; - - if (!strcasecmp(argv[c], "range")) { - /******************************************************************/ - c++; - range = atoi(argv[c]); - /******************************************************************/ - } else { - /******************************************************************/ - stream->write_function(stream, "Unknown \"cgu range\" command\n"); - goto handle_cli_error; - /******************************************************************/ - } - - handle_tx_cgu(stream, span, chan, range, verbose); - /**********************************************************************/ - } else { - /**********************************************************************/ - stream->write_function(stream, "Unknown \"cgu\" command\n"); - goto handle_cli_error; - /**********************************************************************/ - } - /**************************************************************************/ - } else if (!strcasecmp(argv[c], "rsc")) { - /**************************************************************************/ - if (check_arg_count(argc, 2)) goto handle_cli_error_argc; - c++; - - if (!strcasecmp(argv[c], "span")) { - /**********************************************************************/ - if (check_arg_count(argc, 5)) goto handle_cli_error_argc; - - if (extract_span_chan(argv, c, &span, &chan)) goto handle_cli_error_span_chan; - - handle_tx_rsc(stream, span, chan, verbose); - /**********************************************************************/ - } else { - /**********************************************************************/ - stream->write_function(stream, "Unknown \"rsc\" command\n"); - goto handle_cli_error; - /**********************************************************************/ - } - /**************************************************************************/ - } else if (!strcasecmp(argv[c], "grs")) { - /**************************************************************************/ - if (check_arg_count(argc, 2)) goto handle_cli_error_argc; - c++; - - if (!strcasecmp(argv[c], "span")) { - /**********************************************************************/ - if (check_arg_count(argc, 5)) goto handle_cli_error_argc; - - if (extract_span_chan(argv, c, &span, &chan)) goto handle_cli_error_span_chan; - c = c + 4; - - if (check_arg_count(argc, 7)) goto handle_cli_error_argc; - - if (!strcasecmp(argv[c], "range")) { - /******************************************************************/ - c++; - range = atoi(argv[c]); - /******************************************************************/ - } else { - /******************************************************************/ - stream->write_function(stream, "Unknown \"grs range\" command\n"); - goto handle_cli_error; - /******************************************************************/ - } - - handle_tx_grs(stream, span, chan, range, verbose); - /**********************************************************************/ - } else { - /**********************************************************************/ - stream->write_function(stream, "Unknown \"grs\" command\n"); - goto handle_cli_error; - /**********************************************************************/ - } - /**************************************************************************/ - } else if (!strcasecmp(argv[c], "lpo")) { - /**************************************************************************/ - if (check_arg_count(argc, 2)) goto handle_cli_error_argc; - c++; - - if (!strcasecmp(argv[c], "link")) { - /**********************************************************************/ - if (check_arg_count(argc, 3)) goto handle_cli_error_argc; - c++; - - handle_tx_lpo(stream, argv[c]); - /**********************************************************************/ - } else { - /**********************************************************************/ - stream->write_function(stream, "Unknown \"lpo\" command\n"); - goto handle_cli_error; - /**********************************************************************/ - } - /**************************************************************************/ - } else if (!strcasecmp(argv[c], "lpr")) { - /**************************************************************************/ - if (check_arg_count(argc, 2)) goto handle_cli_error_argc; - c++; - - if (!strcasecmp(argv[c], "link")) { - /**********************************************************************/ - if (check_arg_count(argc, 3)) goto handle_cli_error_argc; - c++; - - handle_tx_lpr(stream, argv[c]); - /**********************************************************************/ - } else { - /**********************************************************************/ - stream->write_function(stream, "Unknown \"lpr\" command\n"); - goto handle_cli_error; - /**********************************************************************/ - } - /**************************************************************************/ - } else if (!strcasecmp(argv[c], "bind")) { - /**************************************************************************/ - if (check_arg_count(argc, 2)) goto handle_cli_error_argc; - c++; - - if (!strcasecmp(argv[c], "link")) { - /**********************************************************************/ - if (check_arg_count(argc, 3)) goto handle_cli_error_argc; - c++; - - handle_bind_link(stream, argv[c]); - /**********************************************************************/ - } else { - /**********************************************************************/ - stream->write_function(stream, "Unknown \"bind\" command\n"); - goto handle_cli_error; - /**********************************************************************/ - } - /**************************************************************************/ - } else if (!strcasecmp(argv[c], "unbind")) { - /**************************************************************************/ - if (check_arg_count(argc, 2)) goto handle_cli_error_argc; - c++; - - if (!strcasecmp(argv[c], "link")) { - /**********************************************************************/ - if (check_arg_count(argc, 3)) goto handle_cli_error_argc; - c++; - - handle_unbind_link(stream, argv[c]); - /**********************************************************************/ - } else { - /**********************************************************************/ - stream->write_function(stream, "Unknown \"bind\" command\n"); - goto handle_cli_error; - /**********************************************************************/ - } - /**************************************************************************/ - } else if (!strcasecmp(argv[c], "activate")) { - /**************************************************************************/ - if (check_arg_count(argc, 2)) goto handle_cli_error_argc; - c++; - - if (!strcasecmp(argv[c], "link")) { - /**********************************************************************/ - if (check_arg_count(argc, 3)) goto handle_cli_error_argc; - c++; - - handle_activate_link(stream, argv[c]); - /**********************************************************************/ - }else if (!strcasecmp(argv[c], "linkset")) { - /**********************************************************************/ - if (check_arg_count(argc, 3)) goto handle_cli_error_argc; - c++; - - handle_activate_linkset(stream, argv[c]); - /**********************************************************************/ - } else { - /**********************************************************************/ - stream->write_function(stream, "Unknown \"activate\" command\n"); - goto handle_cli_error; - /**********************************************************************/ - } - /**************************************************************************/ - } else if (!strcasecmp(argv[c], "deactivate")) { - /**************************************************************************/ - if (check_arg_count(argc, 2)) goto handle_cli_error_argc; - c++; - - if (!strcasecmp(argv[c], "link")) { - /**********************************************************************/ - if (check_arg_count(argc, 3)) goto handle_cli_error_argc; - c++; - - handle_deactivate_link(stream, argv[c]); - /**********************************************************************/ - }else if (!strcasecmp(argv[c], "linkset")) { - /**********************************************************************/ - if (check_arg_count(argc, 3)) goto handle_cli_error_argc; - c++; - - handle_deactivate_linkset(stream, argv[c]); - /**********************************************************************/ - } else { - /**********************************************************************/ - stream->write_function(stream, "Unknown \"deactivate\" command\n"); - goto handle_cli_error; - /**********************************************************************/ - } - /**************************************************************************/ - } else if (!strcasecmp(argv[c], "m2ua")) { - /**************************************************************************/ - if (check_arg_count(argc, 3)) { - stream->write_function(stream, "Invalid \"m2ua option\", please use \"m2ua logging [enable|disable] \n"); - goto handle_cli_error_argc; - } - c++; - if(!strcasecmp(argv[c],"logging")){ - c++; - if(!strcasecmp(argv[c],"enable")){ - ftmod_ss7_enable_m2ua_sg_logging(); - }else if(!strcasecmp(argv[c],"disable")){ - ftmod_ss7_disable_m2ua_sg_logging(); - } else{ - stream->write_function(stream, "Unknown \"m2ua logging %s option\", supported values enable/disable\n",argv[c]); - goto handle_cli_error_argc; - } - }else{ - stream->write_function(stream, "Unknown \"m2ua %s option\", supported values \"logging\"\n",argv[c]); - goto handle_cli_error_argc; - } - /**************************************************************************/ - } else { - /**************************************************************************/ - goto handle_cli_error; - /**************************************************************************/ - } - - return FTDM_SUCCESS; - -handle_cli_error_argc: - stream->write_function(stream, "Invalid # of arguments in command\n"); - handle_print_usage(stream); - return FTDM_SUCCESS; - -handle_cli_error_span_chan: - stream->write_function(stream, "Unknown \"span\\chan\" command\n"); - handle_print_usage(stream); - return FTDM_SUCCESS; - -handle_cli_error: - stream->write_function(stream, "Unknown command requested\n"); - handle_print_usage(stream); - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static ftdm_status_t handle_print_usage(ftdm_stream_handle_t *stream) -{ - stream->write_function(stream, "Sangoma SS7 CLI usage:\n\n"); - - stream->write_function(stream, "ftmod_sangoma_ss7 general control:\n"); - stream->write_function(stream, "ftdm ss7 set ftrace X Y\n"); - stream->write_function(stream, "ftdm ss7 set mtrace X Y\n"); - stream->write_function(stream, "\n"); - - stream->write_function(stream, "ftmod_sangoma_ss7 signaling information:\n"); - stream->write_function(stream, "ftdm ss7 show \n"); - stream->write_function(stream, "ftdm ss7 show status mtp2 X\n"); - stream->write_function(stream, "ftdm ss7 show status mtp3 X\n"); - stream->write_function(stream, "ftdm ss7 show status linkset X\n"); - stream->write_function(stream, "\n"); - - stream->write_function(stream, "ftmod_sangoma_ss7 circuit information:\n"); - stream->write_function(stream, "ftdm ss7 show span all\n"); - stream->write_function(stream, "ftdm ss7 show span X\n"); - stream->write_function(stream, "ftdm ss7 show status span X chan Y\n"); - stream->write_function(stream, "ftdm ss7 show free span X chan Y\n"); - stream->write_function(stream, "ftdm ss7 show blocks span X chan Y\n"); - stream->write_function(stream, "ftdm ss7 show inuse span X chan Y\n"); - stream->write_function(stream, "ftdm ss7 show inreset span X chan Y\n"); - stream->write_function(stream, "\n"); - - stream->write_function(stream, "ftmod_sangoma_ss7 circuit control:\n"); - stream->write_function(stream, "ftdm ss7 blo span X chan Y\n"); - stream->write_function(stream, "ftdm ss7 ubl span X chan Y\n"); - stream->write_function(stream, "ftdm ss7 rsc span X chan Y\n"); - stream->write_function(stream, "ftdm ss7 grs span X chan Y range Z\n"); - stream->write_function(stream, "ftdm ss7 cgb span X chan Y range Z\n"); - stream->write_function(stream, "ftdm ss7 cgu span X chan Y range Z\n"); - stream->write_function(stream, "\n"); - - stream->write_function(stream, "ftmod_sangoma_ss7 link control:\n"); - /* - stream->write_function(stream, "ftdm ss7 inhibit link X\n"); - stream->write_function(stream, "ftdm ss7 uninhibit link X\n"); - */ - stream->write_function(stream, "ftdm ss7 activate link X\n"); - stream->write_function(stream, "ftdm ss7 deactivate link X\n"); - stream->write_function(stream, "ftdm ss7 activate linkset X\n"); - stream->write_function(stream, "ftdm ss7 deactivate linkset X\n"); - stream->write_function(stream, "ftdm ss7 lpo link X\n"); - stream->write_function(stream, "ftdm ss7 lpr link X\n"); - stream->write_function(stream, "\n"); - - - stream->write_function(stream, "ftmod_sangoma_ss7 Relay status:\n"); - stream->write_function(stream, "ftdm ss7 show status relay X\n"); - stream->write_function(stream, "ftdm ss7 show relay X\n"); - stream->write_function(stream, "ftdm ss7 show relay\n"); - stream->write_function(stream, "\n"); - - stream->write_function(stream, "ftmod_sangoma_ss7 M2UA :\n"); - stream->write_function(stream, "ftdm ss7 xmlshow sctp \n"); - stream->write_function(stream, "ftdm ss7 xmlshow sctp \n"); - stream->write_function(stream, "ftdm ss7 xmlshow m2ua \n"); - stream->write_function(stream, "ftdm ss7 xmlshow m2ua \n"); - stream->write_function(stream, "ftdm ss7 xmlshow m2ua peerstatus\n"); - stream->write_function(stream, "ftdm ss7 xmlshow m2ua clusterstatus\n"); - stream->write_function(stream, "ftdm ss7 xmlshow nif \n"); - stream->write_function(stream, "ftdm ss7 xmlshow nif \n"); - stream->write_function(stream, "\n"); - - - stream->write_function(stream, "ftmod_sangoma_ss7 M2UA logging:\n"); - stream->write_function(stream, "ftdm ss7 m2ua logging [enable|disable] \n"); - - stream->write_function(stream, "\n"); - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static ftdm_status_t handle_show_procId(ftdm_stream_handle_t *stream) -{ - int procId = sng_get_procId(); - - stream->write_function(stream, "Local ProcId = %d\n", procId); - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static ftdm_status_t handle_set_function_trace(ftdm_stream_handle_t *stream, int on, int level) -{ - stream->write_function(stream, "ftmod_sangoma_ss7 Function Trace was %s, level = %d\n", - (g_ftdm_sngss7_data.function_trace == 1) ? "ON" : "OFF", - g_ftdm_sngss7_data.function_trace_level); - - g_ftdm_sngss7_data.function_trace = on; - g_ftdm_sngss7_data.function_trace_level = level; - - stream->write_function(stream, "ftmod_sangoma_ss7 Function Trace now is %s, level = %d\n", - (g_ftdm_sngss7_data.function_trace == 1) ? "ON" : "OFF", - g_ftdm_sngss7_data.function_trace_level); - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static ftdm_status_t handle_set_message_trace(ftdm_stream_handle_t *stream, int on, int level) -{ - stream->write_function(stream, "ftmod_sangoma_ss7 Message Trace was %s, level = %d\n", - (g_ftdm_sngss7_data.message_trace == 1) ? "ON" : "OFF", - g_ftdm_sngss7_data.message_trace_level); - - g_ftdm_sngss7_data.message_trace = on; - g_ftdm_sngss7_data.message_trace_level = level; - - stream->write_function(stream, "ftmod_sangoma_ss7 Message Trace now is %s, level = %d\n", - (g_ftdm_sngss7_data.message_trace == 1) ? "ON" : "OFF", - g_ftdm_sngss7_data.message_trace_level); - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static ftdm_status_t handle_show_free(ftdm_stream_handle_t *stream, int span, int chan, int verbose) -{ - int x; - int free; - sngss7_chan_data_t *ss7_info; - ftdm_channel_t *ftdmchan; - int lspan; - int lchan; - - x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1; - free = 0; - while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) { - if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == SNG_CKT_VOICE) { - ss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj; - ftdmchan = ss7_info->ftdmchan; - - /* if span == 0 then all spans should be printed */ - if (span == 0) { - lspan = ftdmchan->physical_span_id; - } else { - lspan = span; - } - - /* if chan == 0 then all chans should be printed */ - if (chan == 0) { - lchan = ftdmchan->physical_chan_id; - } else { - lchan = chan; - } - - if ((ftdmchan->physical_span_id == lspan) && (ftdmchan->physical_chan_id == lchan)) { - switch (ftdmchan->state) { - /******************************************************************/ - case (FTDM_CHANNEL_STATE_DOWN): - if (verbose) { - stream->write_function(stream, "span=%2d|chan=%2d|cic=%4d|state=%s\n", - ftdmchan->physical_span_id, - ftdmchan->physical_chan_id, - ss7_info->circuit->cic, - ftdm_channel_state2str(ftdmchan->state)); - } /* if (verbose) */ - - /*increment the count of circuits in reset */ - free++; - break; - /******************************************************************/ - default: - break; - /******************************************************************/ - } /* switch (ftdmchan->state) */ - } /* if ( span and chan) */ - } /* if ( cic != 0) */ - - /* go the next circuit */ - x++; - } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x]id != 0) */ - - stream->write_function(stream, "\nTotal # of CICs free = %d\n",free); - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static ftdm_status_t handle_show_inuse(ftdm_stream_handle_t *stream, int span, int chan, int verbose) -{ - int x; - int in_use; - sngss7_chan_data_t *ss7_info; - ftdm_channel_t *ftdmchan; - int lspan; - int lchan; - - x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1; - in_use = 0; - while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) { - if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == SNG_CKT_VOICE) { - ss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj; - ftdmchan = ss7_info->ftdmchan; - - /* if span == 0 then all spans should be printed */ - if (span == 0) { - lspan = ftdmchan->physical_span_id; - } else { - lspan = span; - } - - /* if chan == 0 then all chans should be printed */ - if (chan == 0) { - lchan = ftdmchan->physical_chan_id; - } else { - lchan = chan; - } - - if ((ftdmchan->physical_span_id == lspan) && (ftdmchan->physical_chan_id == lchan)) { - switch (ftdmchan->state) { - /******************************************************************/ - case (FTDM_CHANNEL_STATE_COLLECT): - case (FTDM_CHANNEL_STATE_RING): - case (FTDM_CHANNEL_STATE_DIALING): - case (FTDM_CHANNEL_STATE_PROGRESS): - case (FTDM_CHANNEL_STATE_PROGRESS_MEDIA): - case (FTDM_CHANNEL_STATE_UP): - case (FTDM_CHANNEL_STATE_TERMINATING): - case (FTDM_CHANNEL_STATE_HANGUP): - if (verbose) { - stream->write_function(stream, "span=%2d|chan=%2d|cic=%4d|state=%s\n", - ftdmchan->physical_span_id, - ftdmchan->physical_chan_id, - ss7_info->circuit->cic, - ftdm_channel_state2str(ftdmchan->state)); - } /* if (verbose) */ - - /*increment the count of circuits in reset */ - in_use++; - break; - /******************************************************************/ - default: - break; - /******************************************************************/ - } /* switch (ftdmchan->state) */ - } /* if ( span and chan) */ - } /* if ( cic != 0) */ - - /* go the next circuit */ - x++; - } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x]id != 0) */ - - stream->write_function(stream, "\nTotal # of CICs in use = %d\n",in_use); - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static ftdm_status_t handle_show_inreset(ftdm_stream_handle_t *stream, int span, int chan, int verbose) -{ - int x; - int in_reset; - sngss7_chan_data_t *ss7_info; - ftdm_channel_t *ftdmchan; - int lspan; - int lchan; - - x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1; - in_reset = 0; - while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) { - if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == SNG_CKT_VOICE) { - ss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj; - ftdmchan = ss7_info->ftdmchan; - - /* if span == 0 then all spans should be printed */ - if (span == 0) { - lspan = ftdmchan->physical_span_id; - } else { - lspan = span; - } - - /* if chan == 0 then all chans should be printed */ - if (chan == 0) { - lchan = ftdmchan->physical_chan_id; - } else { - lchan = chan; - } - - if ((ftdmchan->physical_span_id == lspan) && (ftdmchan->physical_chan_id == lchan)) { - if ((sngss7_test_ckt_flag(ss7_info, FLAG_RESET_RX)) || - (sngss7_test_ckt_flag(ss7_info, FLAG_RESET_TX)) || - (sngss7_test_ckt_flag(ss7_info, FLAG_GRP_RESET_RX)) || - (sngss7_test_ckt_flag(ss7_info, FLAG_GRP_RESET_TX))) { - - if (verbose) { - stream->write_function(stream, "span=%2d|chan=%2d|cic=%4d|in_reset=Y\n", - ftdmchan->physical_span_id, - ftdmchan->physical_chan_id, - ss7_info->circuit->cic); - } /* if (verbose) */ - - /*increment the count of circuits in reset */ - in_reset++; - } /* if ((sngss7_test_ckt_flag(ss7_info, FLAG_RESET_RX) ... */ - } /* if ( span and chan) */ - } /* if ( cic != 0) */ - - /* go the next circuit */ - x++; - } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x]id != 0) */ - - stream->write_function(stream, "\nTotal # of CICs in reset = %d\n",in_reset); - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static ftdm_status_t handle_show_flags(ftdm_stream_handle_t *stream, int span, int chan, int verbose) -{ - sngss7_chan_data_t *ss7_info; - ftdm_channel_t *ftdmchan; - int x; - int bit; - int lspan; - int lchan; - const char *text; - int flag; - - x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1; - while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) { - if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == SNG_CKT_VOICE) { - ss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj; - ftdmchan = ss7_info->ftdmchan; - - /* if span == 0 then all spans should be printed */ - if (span == 0) { - lspan = ftdmchan->physical_span_id; - } else { - lspan = span; - } - - /* if chan == 0 then all chans should be printed */ - if (chan == 0) { - lchan = ftdmchan->physical_chan_id; - } else { - lchan = chan; - } - - if ((ftdmchan->physical_span_id == lspan) && (ftdmchan->physical_chan_id == lchan)) { - stream->write_function(stream, "span=%2d|chan=%2d|cic=%4d", - ftdmchan->physical_span_id, - ftdmchan->physical_chan_id, - ss7_info->circuit->cic); - - for (bit = 0; bit < 33; bit++) { - if (ss7_info->ckt_flags & ( 0x1 << bit)) { - stream->write_function(stream, "|"); - flag = bit; - text = ftmod_ss7_ckt_flag2str(flag); - stream->write_function(stream, "%s",text); - } - } - - for (bit = 0; bit < 33; bit++) { - if (ss7_info->blk_flags & ( 0x1 << bit)) { - stream->write_function(stream, "|"); - flag = bit; - text = ftmod_ss7_blk_flag2str(flag); - stream->write_function(stream, "%s",text); - } - } - - stream->write_function(stream, "\n"); - } /* if ( span and chan) */ - - } /* if ( cic != 0) */ - - /* go the next circuit */ - x++; - } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x]id != 0) */ - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static ftdm_status_t handle_show_blocks(ftdm_stream_handle_t *stream, int span, int chan, int verbose) -{ - int x; - sngss7_chan_data_t *ss7_info; - ftdm_channel_t *ftdmchan; - int lspan; - int lchan; - - x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1; - while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) { - if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == SNG_CKT_VOICE) { - ss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj; - ftdmchan = ss7_info->ftdmchan; - - /* if span == 0 then all spans should be printed */ - if (span == 0) { - lspan = ftdmchan->physical_span_id; - } else { - lspan = span; - } - - /* if chan == 0 then all chans should be printed */ - if (chan == 0) { - lchan = ftdmchan->physical_chan_id; - } else { - lchan = chan; - } - - if ((ftdmchan->physical_span_id == lspan) && (ftdmchan->physical_chan_id == lchan)) { - stream->write_function(stream, "span=%2d|chan=%2d|cic=%4d|", - ftdmchan->physical_span_id, - ftdmchan->physical_chan_id, - ss7_info->circuit->cic); - - if((sngss7_test_ckt_blk_flag(ss7_info, FLAG_CKT_MN_BLOCK_TX)) || (sngss7_test_ckt_blk_flag(ss7_info, FLAG_GRP_MN_BLOCK_TX))) { - stream->write_function(stream, "l_mn=Y|"); - }else { - stream->write_function(stream, "l_mn=N|"); - } - - if((sngss7_test_ckt_blk_flag(ss7_info, FLAG_CKT_MN_BLOCK_RX)) || (sngss7_test_ckt_blk_flag(ss7_info, FLAG_GRP_MN_BLOCK_RX))) { - stream->write_function(stream, "r_mn=Y|"); - }else { - stream->write_function(stream, "r_mn=N|"); - } - - if(sngss7_test_ckt_blk_flag(ss7_info, FLAG_GRP_HW_BLOCK_TX)) { - stream->write_function(stream, "l_hw=Y|"); - }else { - stream->write_function(stream, "l_hw=N|"); - } - - if(sngss7_test_ckt_blk_flag(ss7_info, FLAG_GRP_HW_BLOCK_RX)) { - stream->write_function(stream, "r_hw=Y|"); - }else { - stream->write_function(stream, "r_hw=N|"); - } - - if(sngss7_test_ckt_blk_flag(ss7_info, FLAG_CKT_LC_BLOCK_RX)) { - stream->write_function(stream, "l_mngmt=Y|"); - }else { - stream->write_function(stream, "l_mngmt=N|"); - } - - if(sngss7_test_ckt_blk_flag(ss7_info, FLAG_CKT_UCIC_BLOCK)) { - stream->write_function(stream, "l_ucic=Y|"); - }else { - stream->write_function(stream, "l_ucic=N|"); - } - -#ifdef SMG_RELAY_DBG - stream->write_function(stream," blk_flag=%x | ckt_flag=%x | chan_flag=%x", ss7_info->blk_flags, ss7_info->ckt_flags, ftdmchan->flags); -#endif - stream->write_function(stream, "\n"); - } /* if ( span and chan) */ - - } /* if ( cic != 0) */ - - /* go the next circuit */ - x++; - } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x]id != 0) */ - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static ftdm_status_t handle_show_status(ftdm_stream_handle_t *stream, int span, int chan, int verbose) -{ - int x; - sngss7_chan_data_t *ss7_info; - ftdm_channel_t *ftdmchan; - int lspan; - int lchan; - ftdm_signaling_status_t sigstatus = FTDM_SIG_STATE_DOWN; - sng_isup_ckt_t *ckt; - - x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1; - while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) { - /* extract the circuit to make it easier to work with */ - ckt = &g_ftdm_sngss7_data.cfg.isupCkt[x]; - - /* if span == 0 then all spans should be printed */ - if (span == 0) { - lspan = ckt->span; - } else { - lspan = span; - } - - /* if chan == 0 then all chans should be printed */ - if (chan == 0) { - lchan = ckt->chan; - } else { - lchan = chan; - } - - /* check if this circuit is one of the circuits we're interested in */ - if ((ckt->span == lspan) && (ckt->chan == lchan)) { - if (ckt->type == SNG_CKT_HOLE) { - stream->write_function(stream, "span=%2d|chan=%2d|cic=%4d|NOT USED\n", - ckt->span, - ckt->chan, - ckt->cic); - } else if (ckt->type == SNG_CKT_SIG) { - stream->write_function(stream, "span=%2d|chan=%2d|cic=%4d|SIGNALING LINK\n", - ckt->span, - ckt->chan, - ckt->cic); - } else { - ss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj; - ftdmchan = ss7_info->ftdmchan; - - if (ftdmchan == NULL) { - /* this should never happen!!! */ - stream->write_function(stream, "span=%2d|chan=%2d|cic=%4d|FTDMCHAN DOES NOT EXISTS", - ckt->span, - ckt->chan, - ckt->cic); - - } else { - /* grab the signaling_status */ - ftdm_channel_get_sig_status(ftdmchan, &sigstatus); - - stream->write_function(stream, "span=%2d|chan=%2d|cic=%4d|ckt=%4d|sig_status=%4s|state=%s|", - ckt->span, - ckt->chan, - ckt->cic, - ckt->id, - ftdm_signaling_status2str(sigstatus), - ftdm_channel_state2str(ftdmchan->state)); - - if ((sngss7_test_ckt_blk_flag(ss7_info, FLAG_CKT_MN_BLOCK_TX)) || - (sngss7_test_ckt_blk_flag(ss7_info, FLAG_GRP_MN_BLOCK_TX)) || - (sngss7_test_ckt_blk_flag(ss7_info, FLAG_CKT_LC_BLOCK_RX))) { - stream->write_function(stream, "l_mn=Y|"); - }else { - stream->write_function(stream, "l_mn=N|"); - } - - if ((sngss7_test_ckt_blk_flag(ss7_info, FLAG_CKT_MN_BLOCK_RX)) || - (sngss7_test_ckt_blk_flag(ss7_info, FLAG_GRP_MN_BLOCK_RX))) { - stream->write_function(stream, "r_mn=Y|"); - }else { - stream->write_function(stream, "r_mn=N|"); - } - - if (sngss7_test_ckt_blk_flag(ss7_info, FLAG_GRP_HW_BLOCK_TX)) { - stream->write_function(stream, "l_hw=Y|"); - }else { - stream->write_function(stream, "l_hw=N|"); - } - - if (sngss7_test_ckt_blk_flag(ss7_info, FLAG_GRP_HW_BLOCK_RX)) { - stream->write_function(stream, "r_hw=Y|"); - }else { - stream->write_function(stream, "r_hw=N|"); - } - - - if (g_ftdm_sngss7_data.cfg.procId != 1) { - /* if (sngss7_test_ckt_blk_flag(ss7_info, FLAG_RELAY_DOWN)) { */ - stream->write_function(stream, "relay=Y|"); - }else { - stream->write_function(stream, "relay=N"); - } - -#ifdef SMG_RELAY_DBG - stream->write_function(stream, "| flag=0x%llx", ftdmchan->flags); -#endif - } - -#ifdef SMG_RELAY_DBG - stream->write_function(stream," | blk_flag=%x | ckt_flag=%x", ss7_info->blk_flags, ss7_info->ckt_flags); -#endif - stream->write_function(stream, "\n"); - } /* if ( hole, sig, voice) */ - } /* if ( span and chan) */ - /* go the next circuit */ - x++; - } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x]id != 0) */ - - /* Look spans that are being used by M2UA SG links */ - for (x = 1; x < ftdm_array_len(g_ftdm_sngss7_data.cfg.g_m2ua_cfg.nif); x++) { - if (g_ftdm_sngss7_data.cfg.g_m2ua_cfg.nif[x].id) { - if (g_ftdm_sngss7_data.cfg.mtp2Link[g_ftdm_sngss7_data.cfg.g_m2ua_cfg.nif[x].mtp2LnkNmb].id) { - uint32_t mtp1_id = g_ftdm_sngss7_data.cfg.mtp2Link[g_ftdm_sngss7_data.cfg.g_m2ua_cfg.nif[x].mtp2LnkNmb].id; - if (g_ftdm_sngss7_data.cfg.mtp1Link[mtp1_id].id) { - if (g_ftdm_sngss7_data.cfg.mtp1Link[mtp1_id].span == span) { - if (chan) { - if (chan == g_ftdm_sngss7_data.cfg.mtp1Link[mtp1_id].chan) { - stream->write_function(stream, "span=%2d|chan=%2d|cic=%4d|SIGNALING LINK\n", - g_ftdm_sngss7_data.cfg.mtp1Link[mtp1_id].span, - g_ftdm_sngss7_data.cfg.mtp1Link[mtp1_id].chan, - 0); - } - } else { - stream->write_function(stream, "span=%2d|chan=%2d|cic=%4d|SIGNALING LINK\n", - g_ftdm_sngss7_data.cfg.mtp1Link[mtp1_id].span, - g_ftdm_sngss7_data.cfg.mtp1Link[mtp1_id].chan, - 0); - } - } - } - - } - } - } - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static ftdm_status_t handle_tx_blo(ftdm_stream_handle_t *stream, int span, int chan, int verbose) -{ - int x; - sngss7_chan_data_t *ss7_info; - ftdm_channel_t *ftdmchan; - int lspan; - int lchan; - - x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1; - while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) { - if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == SNG_CKT_VOICE) { - ss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj; - ftdmchan = ss7_info->ftdmchan; - - /* if span == 0 then all spans should be printed */ - if (span == 0) { - lspan = ftdmchan->physical_span_id; - } else { - lspan = span; - } - - /* if chan == 0 then all chans should be printed */ - if (chan == 0) { - lchan = ftdmchan->physical_chan_id; - } else { - lchan = chan; - } - - if ((ftdmchan->physical_span_id == lspan) && (ftdmchan->physical_chan_id == lchan)) { - ftdm_mutex_lock(ftdmchan->mutex); - - /* check if there is a pending state change|give it a bit to clear */ - if (check_for_state_change(ftdmchan)) { - SS7_ERROR("Failed to wait for pending state change on CIC = %d\n", ss7_info->circuit->cic); - ftdm_assert(0, "State change not completed\n"); - ftdm_mutex_unlock(ftdmchan->mutex); - continue; - } else { - sngss7_set_ckt_blk_flag(ss7_info, FLAG_CKT_MN_BLOCK_TX); - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); - } - - ftdm_mutex_unlock(ftdmchan->mutex); - } - - } - - x++; - } - - handle_show_blocks(stream, span, chan, verbose); - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static ftdm_status_t handle_tx_ubl(ftdm_stream_handle_t *stream, int span, int chan, int verbose) -{ - int x; - sngss7_chan_data_t *ss7_info; - ftdm_channel_t *ftdmchan; - int lspan; - int lchan; - - x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1; - while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) { - if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == SNG_CKT_VOICE) { - ss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj; - ftdmchan = ss7_info->ftdmchan; - - /* if span == 0 then all spans should be printed */ - if (span == 0) { - lspan = ftdmchan->physical_span_id; - } else { - lspan = span; - } - - /* if chan == 0 then all chans should be printed */ - if (chan == 0) { - lchan = ftdmchan->physical_chan_id; - } else { - lchan = chan; - } - - if ((ftdmchan->physical_span_id == lspan) && (ftdmchan->physical_chan_id == lchan)) { - ftdm_mutex_lock(ftdmchan->mutex); - - /* check if there is a pending state change|give it a bit to clear */ - if (check_for_state_change(ftdmchan)) { - SS7_ERROR("Failed to wait for pending state change on CIC = %d\n", ss7_info->circuit->cic); - ftdm_assert(0, "State change not completed\n"); - ftdm_mutex_unlock(ftdmchan->mutex); - continue; - } else { - sngss7_set_ckt_blk_flag(ss7_info, FLAG_CKT_MN_UNBLK_TX); - sngss7_clear_ckt_blk_flag(ss7_info, FLAG_CKT_MN_BLOCK_TX); - sngss7_clear_ckt_blk_flag(ss7_info, FLAG_GRP_MN_BLOCK_TX); - - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); - } - - ftdm_mutex_unlock(ftdmchan->mutex); - - } - - } - - /* go the next circuit */ - x++; - } - - handle_show_blocks(stream, span, chan, verbose); - - return FTDM_SUCCESS; -} - - -/******************************************************************************/ -static ftdm_status_t handle_status_mtp3link(ftdm_stream_handle_t *stream, char *name) -{ - SS7_RELAY_DBG_FUN(handle_status_mtp3link); - - ftdm_assert_return(stream != NULL, FTDM_FAIL, "Invalid stream\n"); - - if (!name) { - return cli_ss7_show_all_mtp3link(stream); - } - - return cli_ss7_show_mtp3link_by_name(stream, name); -} - - -/******************************************************************************/ -static ftdm_status_t handle_status_mtp2link(ftdm_stream_handle_t *stream, char *name) -{ - SS7_RELAY_DBG_FUN(handle_status_mtp2link); - - ftdm_assert_return(stream != NULL, FTDM_FAIL, "Invalid stream\n"); - - if (!name) { - return cli_ss7_show_all_mtp2link(stream); - } - - return cli_ss7_show_mtp2link_by_name(stream, name); -} - -/******************************************************************************/ -static ftdm_status_t handle_status_linkset(ftdm_stream_handle_t *stream, char *name) -{ - int x = 0; - SnMngmt sta; - - /* find the linkset request by it's name */ - x = 1; - while(x < (MAX_MTP_LINKSETS+1)) { - if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name, name)) { - - /* send the status request */ - if (ftmod_ss7_mtplinkSet_sta(x, &sta)) { - stream->write_function(stream, "Failed to read linkset=%s status\n", name); - return FTDM_FAIL; - } - - /* print the results */ - stream->write_function(stream, "%s|state=%s|nmbActLnk=%d\n", - name, - DECODE_LSN_LINKSET_STATUS(sta.t.ssta.s.snLnkSet.state), - sta.t.ssta.s.snLnkSet.nmbActLnks); - - goto success; - } - - /* move to the next linkset */ - x++; - } /* while (id != 0) */ - - stream->write_function(stream, "Failed to find link=\"%s\"\n", name); - -success: - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static ftdm_status_t handle_set_inhibit(ftdm_stream_handle_t *stream, char *name) -{ - int x = 0; - - /* find the link request by it's name */ - x = 1; - while(x < (MAX_MTP_LINKS+1)) { - if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) { - - /* send the inhibit request */ - if (ftmod_ss7_inhibit_mtp3link(x)) { - stream->write_function(stream, "Failed to inhibit link=%s\n", name); - return FTDM_FAIL; - } - - /* print the new status of the link */ - handle_status_mtp3link(stream, &name[0]); - - goto success; - } - - /* move to the next linkset */ - x++; - } /* while (x < (MAX_MTP_LINKS+1)) */ - - stream->write_function(stream, "Failed to find link=\"%s\"\n", name); - -success: - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static ftdm_status_t handle_set_uninhibit(ftdm_stream_handle_t *stream, char *name) -{ - int x = 0; - - /* find the link request by it's name */ - x = 1; - while(x < (MAX_MTP_LINKS+1)) { - if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) { - - /* send the uninhibit request */ - if (ftmod_ss7_uninhibit_mtp3link(x)) { - stream->write_function(stream, "Failed to uninhibit link=%s\n", name); - return FTDM_FAIL; - } - - /* print the new status of the link */ - handle_status_mtp3link(stream, &name[0]); - - goto success; - } - - /* move to the next linkset */ - x++; - } /* while (x < (MAX_MTP_LINKS+1)) */ - - stream->write_function(stream, "Failed to find link=\"%s\"\n", name); - -success: - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static ftdm_status_t handle_tx_rsc(ftdm_stream_handle_t *stream, int span, int chan, int verbose) -{ - int x; - sngss7_chan_data_t *sngss7_info; - ftdm_channel_t *ftdmchan; - int lspan; - int lchan; - - x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1; - while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) { - if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == SNG_CKT_VOICE) { - sngss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj; - ftdmchan = sngss7_info->ftdmchan; - - /* if span == 0 then all spans should be printed */ - if (span == 0) { - lspan = ftdmchan->physical_span_id; - } else { - lspan = span; - } - - /* if chan == 0 then all chans should be printed */ - if (chan == 0) { - lchan = ftdmchan->physical_chan_id; - } else { - lchan = chan; - } - - if ((ftdmchan->physical_span_id == lspan) && (ftdmchan->physical_chan_id == lchan)) { - /* lock the channel */ - ftdm_mutex_lock(ftdmchan->mutex); - - /* throw the reset flag */ - sngss7_set_ckt_flag (sngss7_info, FLAG_LOCAL_REL); - sngss7_clear_ckt_flag (sngss7_info, FLAG_REMOTE_REL); - sngss7_tx_reset_restart(sngss7_info); - - switch (ftdmchan->state) { - /**************************************************************************/ - case FTDM_CHANNEL_STATE_RESTART: - /* go to idle so that we can redo the restart state*/ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_IDLE); - break; - /**************************************************************************/ - default: - /* set the state of the channel to restart...the rest is done by the chan monitor */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RESTART); - break; - /**************************************************************************/ - } - - /* unlock the channel again before we exit */ - ftdm_mutex_unlock(ftdmchan->mutex); - } /* if ( span and chan) */ - - } /* if ( cic == voice) */ - - /* go the next circuit */ - x++; - } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x]id != 0) */ - - /* print the status of channels */ - handle_show_status(stream, span, chan, verbose); - - - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static ftdm_status_t handle_tx_grs(ftdm_stream_handle_t *stream, int span, int chan, int range, int verbose) -{ - sngss7_chan_data_t *sngss7_info = NULL; - ftdm_channel_t *ftdmchan = NULL; - sngss7_span_data_t *sngss7_span = NULL; - int x = 0; - int basefound = 0; - - if (range > 31) { - stream->write_function(stream, "Range value %d is too big for a GRS", range); - return FTDM_SUCCESS; - } - - if (range < 2) { - stream->write_function(stream, "Range value %d is too small for a GRS", range); - return FTDM_SUCCESS; - } - - x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1; - while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) { - if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == SNG_CKT_VOICE) { - - sngss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj; - ftdmchan = sngss7_info->ftdmchan; - sngss7_span = ftdmchan->span->signal_data; - - if ((ftdmchan->physical_span_id == span) && - ((ftdmchan->physical_chan_id >= chan) && (ftdmchan->physical_chan_id < (chan+range)))) { - - /* now that we have the right channel...put a lock on it so no-one else can use it */ - ftdm_channel_lock(ftdmchan); - - /* if another reset is still in progress, skip this channel */ - if (sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_TX)) { - ftdm_channel_unlock(ftdmchan); - continue; - } - - /* check if there is a pending state change|give it a bit to clear */ - if (check_for_state_change(ftdmchan)) { - SS7_ERROR("Failed to wait for pending state change on CIC = %d\n", sngss7_info->circuit->cic); - ftdm_channel_unlock(ftdmchan); - continue; - } - - /* throw the grp reset flag */ - sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_RESET_TX); - if (!basefound) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Setting channel as GRS base\n"); - sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_RESET_BASE); - sngss7_info->tx_grs.circuit = sngss7_info->circuit->id; - sngss7_info->tx_grs.range = range - 1; - basefound = 1; - } - - /* set the channel to restart state */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RESTART); - - ftdm_channel_unlock(ftdmchan); - - } - - } - - /* go the next circuit */ - x++; - } - - x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1; - while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) { - if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == SNG_CKT_VOICE) { - - sngss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj; - ftdmchan = sngss7_info->ftdmchan; - sngss7_span = ftdmchan->span->signal_data; - - if ((ftdmchan->physical_span_id == span) && - ((ftdmchan->physical_chan_id >= chan) && (ftdmchan->physical_chan_id < (chan+range)))) { - - handle_show_status(stream, span, chan, verbose); - } - } /* if ( cic == voice) */ - - /* go the next circuit */ - x++; - } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x]id != 0) */ - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static ftdm_status_t handle_tx_cgb(ftdm_stream_handle_t *stream, int span, int chan, int range, int verbose) -{ - int x; - sngss7_chan_data_t *sngss7_info; - ftdm_channel_t *ftdmchan; - ftdm_channel_t *main_chan = NULL; - sngss7_span_data_t *sngss7_span; - int byte = 0; - int bit = 0; - ftdm_sigmsg_t sigev; - - memset (&sigev, 0, sizeof (sigev)); - - - if (range <= 1 || range > 31) { - stream->write_function(stream, "Invalid range value %d. Range value must be greater than 1 and less than 31. \n", range); - return FTDM_SUCCESS; - } - - x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1; - while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) { - if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == SNG_CKT_VOICE) { - - /* extract the channel and span info for this circuit */ - sngss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj; - ftdmchan = sngss7_info->ftdmchan; - sngss7_span = ftdmchan->span->signal_data; - - /* check if this circuit is part of the block */ - if ((ftdmchan->physical_span_id == span) && - ((ftdmchan->physical_chan_id >= chan) && (ftdmchan->physical_chan_id < (chan+range)))) { - - /* now that we have the right channel...put a lock on it so no-one else can use it */ - ftdm_channel_lock(ftdmchan); - - /* throw the grp maint. block flag */ - sngss7_set_ckt_blk_flag(sngss7_info, FLAG_GRP_MN_BLOCK_TX); - - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); - - /* bring the sig status down */ - sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_DOWN); - - /* if this is the first channel in the range */ - if (!main_chan) { - /* attach the cgb information */ - main_chan = ftdmchan; - sngss7_span->tx_cgb.circuit = sngss7_info->circuit->id; - sngss7_span->tx_cgb.range = 0; - sngss7_span->tx_cgb.type = 0; /* maintenace block */ - } else { - ((sngss7_span_data_t*)(main_chan->span->signal_data))->tx_cgb.range++; - } - - /* update the status field */ - sngss7_span->tx_cgb.status[byte] = (sngss7_span->tx_cgb.status[byte] | (1 << bit)); - - /* update the bit and byte counter*/ - bit ++; - if (bit == 8) { - byte++; - bit = 0; - } - - /* unlock the channel again before we exit */ - ftdm_channel_unlock(ftdmchan); - } - } - /* go the next circuit */ - x++; - } - - if (!main_chan) { - stream->write_function(stream, "Failed to find a voice cic in span %d chan %d range %d", span, chan, range); - return FTDM_SUCCESS; - } - - /* send the circuit group block */ - ft_to_sngss7_cgb(main_chan); - - x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1; - while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) { - if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == SNG_CKT_VOICE) { - - sngss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj; - ftdmchan = sngss7_info->ftdmchan; - sngss7_span = ftdmchan->span->signal_data; - - if ((ftdmchan->physical_span_id == span) && - ((ftdmchan->physical_chan_id >= chan) && (ftdmchan->physical_chan_id < (chan+range)))) { - - handle_show_status(stream, ftdmchan->physical_span_id, ftdmchan->physical_chan_id, verbose); - } - } /* if ( cic == voice) */ - - /* go the next circuit */ - x++; - } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x]id != 0) */ - - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static ftdm_status_t handle_tx_cgu(ftdm_stream_handle_t *stream, int span, int chan, int range, int verbose) -{ - sngss7_chan_data_t *sngss7_info = NULL; - ftdm_channel_t *ftdmchan = NULL; - ftdm_channel_t *main_chan = NULL; - sngss7_span_data_t *sngss7_span = NULL; - sngss7_chan_data_t *ubl_sng_info[MAX_CIC_MAP_LENGTH+1]; - int x = 0; - int byte = 0; - int bit = 0; - int ubl_sng_info_idx = 1; - ftdm_sigmsg_t sigev; - - memset(ubl_sng_info, 0, sizeof(ubl_sng_info)); - memset (&sigev, 0, sizeof (sigev)); - - if (range <= 1 || range > 31) { - stream->write_function(stream, "Invalid range value %d. Range value must be greater than 1 and less than 31.\n", range); - return FTDM_SUCCESS; - } - - /* verify that there is not hardware block in the range. - * if there is any channel within the group unblock range, do not execute the group unblock */ - x = (g_ftdm_sngss7_data.cfg.procId * MAX_CIC_MAP_LENGTH) + 1; - while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) { - if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == SNG_CKT_VOICE) { - sngss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj; - ftdmchan = sngss7_info->ftdmchan; - sngss7_span = ftdmchan->span->signal_data; - - if ( (ftdmchan->physical_span_id == span) - && (ftdmchan->physical_chan_id >= chan) - && (ftdmchan->physical_chan_id < (chan+range)) - && sngss7_test_ckt_blk_flag(sngss7_info, (FLAG_GRP_HW_BLOCK_TX | FLAG_GRP_HW_BLOCK_TX_DN)) - ) { - stream->write_function(stream, "There is at least one channel with hardware block. Group unblock operation not allowed at this time.\n"); - return FTDM_SUCCESS; - } - } - x++; - } - - - x = (g_ftdm_sngss7_data.cfg.procId * MAX_CIC_MAP_LENGTH) + 1; - while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) { - if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == SNG_CKT_VOICE) { - - /* extract the channel and span info for this circuit */ - sngss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj; - ftdmchan = sngss7_info->ftdmchan; - sngss7_span = ftdmchan->span->signal_data; - - /* check if this circuit is part of the block */ - if ((ftdmchan->physical_span_id == span) && - ((ftdmchan->physical_chan_id >= chan) && (ftdmchan->physical_chan_id < (chan+range)))) { - - /* now that we have the right channel...put a lock on it so no-one else can use it */ - ftdm_channel_lock(ftdmchan); - - /* throw the grp maint. block flag */ - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_GRP_MN_BLOCK_TX); - - if (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX_DN)) { - ubl_sng_info[ubl_sng_info_idx] = sngss7_info; - ubl_sng_info_idx++; - } - - /* bring the sig status up */ - sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_UP); - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); - - /* if this is the first channel in the range */ - if (!main_chan) { - /* attach the cgb information */ - main_chan = ftdmchan; - sngss7_span->tx_cgu.circuit = sngss7_info->circuit->id; - sngss7_span->tx_cgu.range = 0; - sngss7_span->tx_cgu.type = 0; /* maintenace block */ - } else { - ((sngss7_span_data_t*)(main_chan->span->signal_data))->tx_cgu.range++; - } - - /* update the status field */ - sngss7_span->tx_cgu.status[byte] = (sngss7_span->tx_cgu.status[byte] | (1 << bit)); - - /* update the bit and byte counter*/ - bit ++; - if (bit == 8) { - byte++; - bit = 0; - } - - /* unlock the channel again before we exit */ - ftdm_channel_unlock(ftdmchan); - } - } - /* go the next circuit */ - x++; - } - - if (!main_chan) { - stream->write_function(stream, "Failed to find a voice cic in span %d chan %d range %d", span, chan, range); - return FTDM_SUCCESS; - } - - /* send the circuit group block */ - ft_to_sngss7_cgu(main_chan); - - /* clearing blocking flags */ - for (x = 1; ubl_sng_info[x]; x++) { - sngss7_info = ubl_sng_info[x]; - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX); - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX_DN); - } - - x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1; - while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) { - if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == SNG_CKT_VOICE) { - - sngss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj; - ftdmchan = sngss7_info->ftdmchan; - sngss7_span = ftdmchan->span->signal_data; - - if ((ftdmchan->physical_span_id == span) && - ((ftdmchan->physical_chan_id >= chan) && (ftdmchan->physical_chan_id < (chan+range)))) { - - handle_show_status(stream, ftdmchan->physical_span_id, ftdmchan->physical_chan_id, verbose); - - } - } /* if ( cic == voice) */ - - /* go the next circuit */ - x++; - } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x]id != 0) */ - - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static ftdm_status_t handle_bind_link(ftdm_stream_handle_t *stream, char *name) -{ - int x = 0; - - /* find the link request by it's name */ - x = 1; - while(x < (MAX_MTP_LINKS+1)) { - if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) { - - /* send the uninhibit request */ - if (ftmod_ss7_bind_mtp3link(g_ftdm_sngss7_data.cfg.mtp3Link[x].mtp2Id)) { - stream->write_function(stream, "Failed to bind link=%s\n", name); - return FTDM_FAIL; - } - - /* print the new status of the link */ - handle_status_mtp3link(stream, &name[0]); - goto success; - } - - /* move to the next link */ - x++; - } /* while (x < (MAX_MTP_LINKS+1)) */ - - stream->write_function(stream, "Could not find link=%s\n", name); - -success: - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static ftdm_status_t handle_unbind_link(ftdm_stream_handle_t *stream, char *name) -{ - int x = 0; - - /* find the link request by it's name */ - x = 1; - while(x < (MAX_MTP_LINKS+1)) { - if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) { - - /* send the uninhibit request */ - if (ftmod_ss7_unbind_mtp3link(g_ftdm_sngss7_data.cfg.mtp3Link[x].mtp2Id)) { - stream->write_function(stream, "Failed to bind link=%s\n", name); - return FTDM_FAIL; - } - - /* print the new status of the link */ - handle_status_mtp3link(stream, &name[0]); - goto success; - } - - /* move to the next link */ - x++; - } /* while (x < (MAX_MTP_LINKS+1)) */ - - stream->write_function(stream, "Could not find link=%s\n", name); - -success: - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static ftdm_status_t handle_activate_link(ftdm_stream_handle_t *stream, char *name) -{ - int x = 0; - - /* find the link request by it's name */ - x = 1; - while(x < (MAX_MTP_LINKS+1)) { - if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) { - - /* send the uninhibit request */ - if (ftmod_ss7_activate_mtp3link(x)) { - stream->write_function(stream, "Failed to activate link=%s\n", name); - return FTDM_FAIL; - } - - /* print the new status of the link */ - handle_status_mtp3link(stream, &name[0]); - goto success; - } - - /* move to the next link */ - x++; - } /* while (x < (MAX_MTP_LINKS+1)) */ - - stream->write_function(stream, "Could not find link=%s\n", name); - -success: - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static ftdm_status_t handle_deactivate_link(ftdm_stream_handle_t *stream, char *name) -{ - int x = 0; - - /* find the link request by it's name */ - x = 1; - while(x < (MAX_MTP_LINKS+1)) { - if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) { - - /* send the deactivate request */ - if (ftmod_ss7_deactivate2_mtp3link(x)) { - stream->write_function(stream, "Failed to deactivate link=%s\n", name); - return FTDM_FAIL; - } - - /* print the new status of the link */ - handle_status_mtp3link(stream, &name[0]); - goto success; - } - - /* move to the next link */ - x++; - } /* while (x < (MAX_MTP_LINKS+1)) */ - - stream->write_function(stream, "Could not find link=%s\n", name); - -success: - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static ftdm_status_t handle_activate_linkset(ftdm_stream_handle_t *stream, char *name) -{ - int x = 0; - - /* find the linkset request by it's name */ - x = 1; - while(x < (MAX_MTP_LINKSETS+1)) { - if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name, name)) { - - /* send the activate request */ - if (ftmod_ss7_activate_mtplinkSet(x)) { - stream->write_function(stream, "Failed to activate linkset=%s\n", name); - return FTDM_FAIL; - } - - /* print the new status of the linkset */ - handle_status_linkset(stream, &name[0]); - goto success; - } - - /* move to the next linkset */ - x++; - } /* while (id != 0) */ - - stream->write_function(stream, "Could not find linkset=%s\n", name); - -success: - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static ftdm_status_t handle_deactivate_linkset(ftdm_stream_handle_t *stream, char *name) -{ - int x = 0; - - /* find the linkset request by it's name */ - x = 1; - while(x < (MAX_MTP_LINKSETS+1)) { - if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name, name)) { - - /* send the deactivate request */ - if (ftmod_ss7_deactivate2_mtplinkSet(x)) { - stream->write_function(stream, "Failed to deactivate linkset=%s\n", name); - return FTDM_FAIL; - } - - /* print the new status of the linkset */ - handle_status_linkset(stream, &name[0]); - goto success; - } - - /* move to the next linkset */ - x++; - } /* while (id != 0) */ - - stream->write_function(stream, "Could not find linkset=%s\n", name); - -success: - return FTDM_SUCCESS; -} - -/******************************************************************************/ - -static ftdm_status_t handle_tx_lpo(ftdm_stream_handle_t *stream, char *name) -{ - int x = 0; - - /* find the link request by it's name */ - x = 1; - while(x < (MAX_MTP_LINKS+1)) { - if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) { - - /* send the uninhibit request */ - if (ftmod_ss7_lpo_mtp3link(x)) { - stream->write_function(stream, "Failed set LPO link=%s\n", name); - return FTDM_FAIL; - } - - /* print the new status of the link */ - handle_status_mtp3link(stream, &name[0]); - goto success; - } - - /* move to the next link */ - x++; - } /* while (x < (MAX_MTP_LINKS+1)) */ - - stream->write_function(stream, "Could not find link=%s\n", name); - -success: - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static ftdm_status_t handle_tx_lpr(ftdm_stream_handle_t *stream, char *name) -{ - int x = 0; - - /* find the link request by it's name */ - x = 1; - while(x < (MAX_MTP_LINKS+1)) { - if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) { - - /* send the uninhibit request */ - if (ftmod_ss7_lpr_mtp3link(x)) { - stream->write_function(stream, "Failed set LPR link=%s\n", name); - return FTDM_FAIL; - } - - /* print the new status of the link */ - handle_status_mtp3link(stream, &name[0]); - goto success; - } - - /* move to the next link */ - x++; - } /* while (x < (MAX_MTP_LINKS+1)) */ - - stream->write_function(stream, "Could not find link=%s\n", name); - -success: - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static ftdm_status_t handle_status_relay(ftdm_stream_handle_t *stream, char *name) -{ - SS7_RELAY_DBG_FUN(handle_status_relay); - if (!name) { - return cli_ss7_show_all_relay(stream); - } - return cli_ss7_show_relay_by_name(stream, name); -} - -/******************************************************************************/ -static ftdm_status_t handle_status_isup_ckt(ftdm_stream_handle_t *stream, char *id_name) -{ - sng_isup_ckt_t *ckt; - sngss7_chan_data_t *ss7_info; - ftdm_channel_t *ftdmchan; - uint32_t id; - uint8_t state = 0; - uint8_t bits_ab = 0; - uint8_t bits_cd = 0; - uint8_t bits_ef = 0; - - /* extract the integer version of the id (ckt) */ - id = atoi(id_name); - - /* extract the global config circuit structure */ - ckt = &g_ftdm_sngss7_data.cfg.isupCkt[id]; - - /* confirm the ckt exists */ - if (ckt->id == 0) { - stream->write_function(stream, "Requested ckt does not exist (%d)\n", id); - return FTDM_FAIL; - } - - /* confirm the ckt is a voice channel */ - if (ckt->type != SNG_CKT_VOICE) { - stream->write_function(stream, "Requested ckt is a sig link/hole and can not be queried (%d)\n", id); - return FTDM_FAIL; - } - - /* extract the global structure */ - ss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[id].obj; - ftdmchan = ss7_info->ftdmchan; - - /* query the isup stack for the state of the ckt */ - if (ftmod_ss7_isup_ckt_sta(ckt->id, &state)) { - stream->write_function(stream, "Failed to read isup ckt =%d status\n", id); - return FTDM_FAIL; - } - - - stream->write_function(stream, "span=%2d|chan=%2d|cic=%4d|ckt=%4d|state=0x%02X|", - ckt->span, - ckt->chan, - ckt->cic, - ckt->id, - state); - - /* extract the bit sections */ - bits_ab = (state & (SNG_BIT_A + SNG_BIT_B)) >> 0; - - bits_cd = (state & (SNG_BIT_C + SNG_BIT_D)) >> 2; - - bits_ef = (state & (SNG_BIT_E + SNG_BIT_F)) >> 4; - - /* check bits C and D */ - switch (bits_cd) { - /**************************************************************************/ - case (0): - /* ckt is either un-equipped or transient, check bits A and B */ - switch (bits_ab) { - /**********************************************************************/ - case (0): - /* bit a and bit are cleared, transient */ - stream->write_function(stream, "transient\n"); - goto success; - break; - /**********************************************************************/ - case (1): - case (2): - /* bit a or bit b are set, spare ... shouldn't happen */ - stream->write_function(stream, "spare\n"); - goto success; - break; - /**********************************************************************/ - case (3): - /* bit a and bit b are set, unequipped */ - stream->write_function(stream, "unequipped\n"); - goto success; - break; - /**********************************************************************/ - default: - stream->write_function(stream, "invalid values for bits A and B (%d)\n", - bits_ab); - goto success; - break; - /**********************************************************************/ - } /* switch (bits_ab) */ - - /* shouldn't get here but have a break for properness */ - break; - /**************************************************************************/ - case (1): - /* circuit incoming busy */ - stream->write_function(stream, "incoming busy"); - break; - /**************************************************************************/ - case (2): - /* circuit outgoing busy */ - stream->write_function(stream, "outgoing busy"); - break; - /**************************************************************************/ - case (3): - /* circuit idle */ - stream->write_function(stream, "idle"); - break; - /**************************************************************************/ - default: - /* invalid */ - stream->write_function(stream, "bits C and D are invalid (%d)!\n", - bits_cd); - goto success; - /**************************************************************************/ - } /* switch (bits_cd) */ - - /* check the maintenance block status in bits A and B */ - switch (bits_ab) { - /**************************************************************************/ - case (0): - /* no maintenace block...do nothing */ - break; - /**************************************************************************/ - case (1): - /* locally blocked */ - stream->write_function(stream, "|l_mn"); - break; - /**************************************************************************/ - case (2): - /* remotely blocked */ - stream->write_function(stream, "|r_mn"); - break; - /**************************************************************************/ - case (3): - /* both locally and remotely blocked */ - stream->write_function(stream, "|l_mn|r_mn"); - break; - /**************************************************************************/ - default: - stream->write_function(stream, "bits A and B are invlaid (%d)!\n", - bits_ab); - goto success; - /**************************************************************************/ - } /* switch (bits_ab) */ - - /* check the hardware block status in bits e and f */ - switch (bits_ef) { - /**************************************************************************/ - case (0): - /* no maintenace block...do nothing */ - break; - /**************************************************************************/ - case (1): - /* locally blocked */ - stream->write_function(stream, "|l_hw"); - break; - /**************************************************************************/ - case (2): - /* remotely blocked */ - stream->write_function(stream, "|r_hw"); - break; - /**************************************************************************/ - case (3): - /* both locally and remotely blocked */ - stream->write_function(stream, "|l_hw|r_hw"); - break; - /**************************************************************************/ - default: - stream->write_function(stream, "bits E and F are invlaid (%d)!\n", - bits_ef); - goto success; - /**************************************************************************/ - } /* switch (bits_ef) */ - -success: - stream->write_function(stream, "\n"); - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static ftdm_status_t extract_span_chan(char *argv[10], int pos, int *span, int *chan) -{ - - if (!strcasecmp(argv[pos], "span")) { - /**************************************************************************/ - pos++; - *span = atoi(argv[pos]); - - pos++; - if (!strcasecmp(argv[pos], "chan")) { - /**********************************************************************/ - pos++; - *chan = atoi(argv[pos]); - /**********************************************************************/ - } else { - /**********************************************************************/ - return FTDM_FAIL; - /**********************************************************************/ - } - /**************************************************************************/ - } else { - /**************************************************************************/ - *span = atoi(argv[pos]); - - pos++; - if (!strcasecmp(argv[pos], "chan")) { - /**********************************************************************/ - pos++; - *chan = atoi(argv[pos]); - /**********************************************************************/ - } else { - /**********************************************************************/ - return FTDM_FAIL; - /**********************************************************************/ - } - /**************************************************************************/ - } - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static ftdm_status_t check_arg_count(int args, int min) -{ - if ( args < min ) { - return FTDM_FAIL; - } else { - return FTDM_SUCCESS; - } -} - - -/****************************************************************************** -* Fun: cli_ss7_show_mtp2link_by_id() -* Desc: display mtp3 link information with id -* Param: -* stream : output stream object -* rcId : mtp2 link's id -* Ret: FTDM_SUCCESS | FTDM_FAIL -* Note: -* author: James Zhang -*******************************************************************************/ -static ftdm_status_t cli_ss7_show_mtp2link_by_id(ftdm_stream_handle_t *stream, int rcId) -{ - SdMngmt sta; - - SS7_RELAY_DBG_FUN(cli_ss7_show_mtp2link_by_id); - - ftdm_assert_return(stream != NULL, FTDM_FAIL, "Null stream\n"); - - if (ftmod_ss7_mtp2link_sta(rcId, &sta)) { - stream->write_function(stream, "Failed to read status of MTP2 link, id=%d \n", rcId); - return FTDM_FAIL; - } - - stream->write_function(stream, "name=%s|span=%d|chan=%d|sap=%d|state=%s|outsFrm=%d|drpdFrm=%d|lclStatus=%s|rmtStatus=%s|fsn=%d|bsn=%d\n", - g_ftdm_sngss7_data.cfg.mtp2Link[rcId].name, - g_ftdm_sngss7_data.cfg.mtp1Link[rcId].span, - g_ftdm_sngss7_data.cfg.mtp1Link[rcId].chan, - g_ftdm_sngss7_data.cfg.mtp2Link[rcId].id, - DECODE_LSD_LINK_STATUS(sta.t.ssta.s.sdDLSAP.hlSt), - sta.t.ssta.s.sdDLSAP.psOutsFrm, - sta.t.ssta.s.sdDLSAP.cntMaDrop, - (sta.t.ssta.s.sdDLSAP.lclBsy) ? "Y":"N", - (sta.t.ssta.s.sdDLSAP.remBsy) ? "Y":"N", - sta.t.ssta.s.sdDLSAP.fsn, - sta.t.ssta.s.sdDLSAP.bsn - ); - - return FTDM_SUCCESS; -} - -/****************************************************************************** -* Fun: cli_ss7_show_mtp2link_by_name() -* Desc: display all relay channels information -* Param: -* stream : output stream object -* rcName: mtp2 link's name -* Ret: FTDM_SUCCESS | FTDM_FAIL -* Note: -* author: James Zhang -*******************************************************************************/ -static ftdm_status_t cli_ss7_show_mtp2link_by_name(ftdm_stream_handle_t *stream, char *name) -{ - int x = 0; - SS7_RELAY_DBG_FUN(cli_ss7_show_mtp2link_by_name); - - ftdm_assert_return(stream != NULL, FTDM_FAIL, "Null stream\n"); - ftdm_assert_return(!ftdm_strlen_zero(name), FTDM_FAIL, "Null MTP2 link name\n"); - - for (x = 0; x < (MAX_MTP_LINKS + 1); x++) { - if (0 == strcasecmp(g_ftdm_sngss7_data.cfg.mtp2Link[x].name, name)) { - return cli_ss7_show_mtp2link_by_id( stream, x ); - } - } - - stream->write_function (stream, "The MTP2 link with name \'%s\' is not found. \n", name); - return FTDM_FAIL; -} - -/****************************************************************************** -* Fun: cli_ss7_show_all_mtp2link() -* Desc: display all mtp2 links information -* Ret: FTDM_SUCCESS | FTDM_FAIL -* Note: -* author: James Zhang -*******************************************************************************/ -static ftdm_status_t cli_ss7_show_all_mtp2link(ftdm_stream_handle_t *stream) -{ - int x = 0; - - SS7_RELAY_DBG_FUN(cli_ss7_show_all_mtp2link); - - ftdm_assert_return(stream != NULL, FTDM_FAIL, "Null stream\n"); - - for (x = 0; x < (MAX_MTP_LINKS + 1); x++) { - if (!ftdm_strlen_zero( g_ftdm_sngss7_data.cfg.mtp2Link[x].name)) { - cli_ss7_show_mtp2link_by_id(stream, x ); - } - } - - return FTDM_SUCCESS; -} - -/****************************************************************************** -* Fun: cli_ss7_show_mtp3link_by_id() -* Desc: display mtp3 link information with id -* Param: -* stream : output stream object -* rcId : mtp3 link's id -* Ret: FTDM_SUCCESS | FTDM_FAIL -* Note: -* author: James Zhang -*******************************************************************************/ -static ftdm_status_t cli_ss7_show_mtp3link_by_id(ftdm_stream_handle_t *stream, int rcId) -{ - SnMngmt sta; - - SS7_RELAY_DBG_FUN(cli_ss7_show_mtp3link_by_id); - - ftdm_assert_return(stream != NULL, FTDM_FAIL, "Null stream\n"); - - memset(&sta, 0, sizeof(sta)); - if (ftmod_ss7_mtp3link_sta(rcId, &sta)) { - stream->write_function(stream, "Failed to read status of MTP3 link, id=%d \n", rcId); - return FTDM_FAIL; - } - - stream->write_function(stream, "name=%s|span=%d|chan=%d|sap=%d|state=%s|l_blk=%s|r_blk=%s|l_inhbt=%s|r_inhbt=%s\n", - g_ftdm_sngss7_data.cfg.mtp3Link[rcId].name, - g_ftdm_sngss7_data.cfg.mtp1Link[rcId].span, - g_ftdm_sngss7_data.cfg.mtp1Link[rcId].chan, - g_ftdm_sngss7_data.cfg.mtp3Link[rcId].id, - DECODE_LSN_LINK_STATUS(sta.t.ssta.s.snDLSAP.state), - (sta.t.ssta.s.snDLSAP.locBlkd) ? "Y":"N", - (sta.t.ssta.s.snDLSAP.remBlkd) ? "Y":"N", - (sta.t.ssta.s.snDLSAP.locInhbt) ? "Y":"N", - (sta.t.ssta.s.snDLSAP.rmtInhbt) ? "Y":"N" - ); - - return FTDM_SUCCESS; -} - -/****************************************************************************** -* Fun: cli_ss7_show_mtp3link_by_name() -* Desc: display all relay channels information -* Param: -* stream : output stream object -* rcName: mtp3 link's name -* Ret: FTDM_SUCCESS | FTDM_FAIL -* Note: -* author: James Zhang -*******************************************************************************/ -static ftdm_status_t cli_ss7_show_mtp3link_by_name(ftdm_stream_handle_t *stream, char *name) -{ - int x=0; - SS7_RELAY_DBG_FUN(cli_ss7_show_mtp3link_by_name); - - ftdm_assert_return(stream != NULL, FTDM_FAIL, "Null stream\n"); - ftdm_assert_return(!ftdm_strlen_zero(name), FTDM_FAIL, "Null MTP3 link name\n"); - - for (x = 0; x < (MAX_MTP_LINKS + 1); x++) { - if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) { - return cli_ss7_show_mtp3link_by_id(stream, x ); - } - } - - stream->write_function(stream, "The MTP3 link with name \'%s\' is not found. \n", name); - return FTDM_FAIL; -} -/****************************************************************************** -* Fun: cli_ss7_show_all_mtp3link() -* Desc: display all mtp3 links information -* Ret: FTDM_SUCCESS | FTDM_FAIL -* Note: -* author: James Zhang -*******************************************************************************/ -static ftdm_status_t cli_ss7_show_all_mtp3link(ftdm_stream_handle_t *stream) -{ - int x = 0; - - SS7_RELAY_DBG_FUN(cli_ss7_show_all_mtp3link); - ftdm_assert_return(stream != NULL, FTDM_FAIL, "Null stream\n"); - - for (x = 0; x < (MAX_MTP_LINKS + 1); x++) { - if (!ftdm_strlen_zero(g_ftdm_sngss7_data.cfg.mtp3Link[x].name)) { - cli_ss7_show_mtp3link_by_id(stream, x); - } - } - - return FTDM_SUCCESS; -} - - -/****************************************************************************** -* Fun: cli_ss7_show_all_linkset() -* Desc: display all mtp3 linksets information -* Ret: FTDM_SUCCESS | FTDM_FAIL -* Note: -* author: James Zhang -*******************************************************************************/ -static ftdm_status_t cli_ss7_show_all_linkset(ftdm_stream_handle_t *stream) -{ - int x = 0; - SnMngmt sta; - - SS7_RELAY_DBG_FUN(cli_ss7_show_all_linkset); - ftdm_assert_return(stream != NULL, FTDM_FAIL, "Null stream\n"); - - x = 1; - while(x < (MAX_MTP_LINKSETS+1)) { - if (!ftdm_strlen_zero(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name)) { - if (ftmod_ss7_mtplinkSet_sta(x, &sta)) { - stream->write_function(stream, "Failed to read linkset=%s status\n", g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name); - } else { - stream->write_function(stream, "name=%s|state=%s|nmbActLnk=%d\n", - g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name, - DECODE_LSN_LINKSET_STATUS(sta.t.ssta.s.snLnkSet.state), sta.t.ssta.s.snLnkSet.nmbActLnks - ); - } - } - x++; - } - return FTDM_SUCCESS; -} - - -/****************************************************************************** -* Fun: cli_ss7_show_general() -* Desc: display all general information about ss7 -* Ret: FTDM_SUCCESS | FTDM_FAIL -* Note: -* author: James Zhang -*******************************************************************************/ -static ftdm_status_t cli_ss7_show_general(ftdm_stream_handle_t *stream) -{ - SS7_RELAY_DBG_FUN(cli_ss7_show_general); - - ftdm_assert_return(stream != NULL, FTDM_FAIL, "Null stream\n"); - - stream->write_function(stream, "MTP2 status: \n"); - cli_ss7_show_all_mtp2link(stream); - - if(SNG_SS7_OPR_MODE_M2UA_SG != g_ftdm_operating_mode){ - stream->write_function(stream, "\nMTP3 status: \n"); - cli_ss7_show_all_mtp3link(stream); - - stream->write_function(stream, "\nMTP3 linkset status: \n"); - cli_ss7_show_all_linkset(stream); - -#if 0 - stream->write_function(stream, "\nMTP3 link route status: \n"); - - stream->write_function(stream, "\nISUP status: \n"); -#endif - - stream->write_function(stream, "\nRelay status: \n"); - cli_ss7_show_all_relay(stream); - } - - return FTDM_SUCCESS; -} - -/****************************************************************************** -* Fun: cli_ss7_show_relay_by_id() -* Desc: display all relay channels information -* Param: -* stream : output stream object -* rcId : channel's id -* Ret: FTDM_SUCCESS | FTDM_FAIL -* Note: -* author: James Zhang -*******************************************************************************/ -static ftdm_status_t cli_ss7_show_relay_by_id(ftdm_stream_handle_t *stream, int rcId) -{ - RyMngmt sta; - - SS7_RELAY_DBG_FUN(cli_ss7_show_relay_by_id); - ftdm_assert_return(stream != NULL, FTDM_FAIL, "Null stream\n"); - - memset(&sta, 0x0, sizeof(sta)); - if (ftmod_ss7_relay_status(g_ftdm_sngss7_data.cfg.relay[rcId].id, &sta)) { - stream->write_function(stream, "Failed to read relay =%s status\n", g_ftdm_sngss7_data.cfg.relay[rcId].name); - return FTDM_FAIL; - } - - stream->write_function(stream, "name=%s|sap=%d|type=%d|port=%d|hostname=%s|procId=%d|status=%s\n", - g_ftdm_sngss7_data.cfg.relay[rcId].name, - g_ftdm_sngss7_data.cfg.relay[rcId].id, - g_ftdm_sngss7_data.cfg.relay[rcId].type, - g_ftdm_sngss7_data.cfg.relay[rcId].port, - g_ftdm_sngss7_data.cfg.relay[rcId].hostname, - g_ftdm_sngss7_data.cfg.relay[rcId].procId, - DECODE_LRY_CHAN_STATUS(sta.t.ssta.rySta.cStatus) - ); - - return FTDM_SUCCESS; -} -/****************************************************************************** -* Fun: cli_ss7_show_relay_by_name() -* Desc: display all relay channels information -* Param: -* stream : output stream object -* rcName: channel's name -* Ret: FTDM_SUCCESS | FTDM_FAIL -* Note: -* author: James Zhang -*******************************************************************************/ -static ftdm_status_t cli_ss7_show_relay_by_name(ftdm_stream_handle_t *stream, char *name) -{ - int x = 0; - - SS7_RELAY_DBG_FUN(cli_ss7_show_relay_by_name); - - ftdm_assert_return(stream != NULL, FTDM_FAIL, "Null stream\n"); - ftdm_assert_return(!ftdm_strlen_zero(name), FTDM_FAIL, "Null relay link name\n"); - - for (x = 1; x < MAX_RELAY_CHANNELS; x++) { - if (!strcasecmp(g_ftdm_sngss7_data.cfg.relay[x].name, name)) { - return cli_ss7_show_relay_by_id(stream, x); - } - } - - stream->write_function( stream, "The relay channel with name \'%s\' is not found. \n", name); - return FTDM_FAIL; - -} -/****************************************************************************** -* Fun: cli_ss7_show_all_relay() -* Desc: display all relay channels information -* Ret: FTDM_SUCCESS | FTDM_FAIL -* Note: -* author: James Zhang -*******************************************************************************/ -static ftdm_status_t cli_ss7_show_all_relay(ftdm_stream_handle_t *stream) -{ - int x = 0; - SS7_RELAY_DBG_FUN(cli_ss7_show_relay_by_name); - - ftdm_assert_return(stream != NULL, FTDM_FAIL, "Null stream\n"); - - for (x = 1; x < MAX_RELAY_CHANNELS; x++) { - if (!ftdm_strlen_zero(g_ftdm_sngss7_data.cfg.relay[x].name)) { - cli_ss7_show_relay_by_id (stream, x); - } - } - - return FTDM_SUCCESS; -} - - -/****************************************************************************** -* Fun: cli_ss7_show_channel_detail_of_span() -* Desc: display span information of a given id -* Param: -* stream : output stream object -* span_id : span id string received from cli -* chan_id : channel id string received from cli -* Ret: FTDM_SUCCESS | FTDM_FAIL -* Note: -* author: James Zhang -*******************************************************************************/ -static ftdm_status_t cli_ss7_show_channel_detail_of_span(ftdm_stream_handle_t *stream, char *span_id, char *chan_id) -{ - int x, y; - - SS7_RELAY_DBG_FUN(cli_ss7_show_channel_detail_of_span); - - ftdm_assert_return(stream != NULL, FTDM_FAIL, "Null stream\n"); - ftdm_assert_return(span_id != 0, FTDM_FAIL, "Invalid span id\n"); - ftdm_assert_return(chan_id != 0, FTDM_FAIL, "Invalid chan id\n"); - - x = atoi(span_id); - y = atoi(chan_id); - if (!x) { - stream->write_function( stream, "Span \'%s\' does not exist. \n", span_id); - return FTDM_FAIL; - } - - return handle_show_status(stream, x, y, 1); -} - -/****************************************************************************** -* Fun: cli_ss7_show_all_channels_of_span() -* Desc: display span information of a given id -* Param: -* stream : output stream object -* span_id : span id string received from cli -* Ret: FTDM_SUCCESS | FTDM_FAIL -* Note: -* author: James Zhang -*******************************************************************************/ -static ftdm_status_t cli_ss7_show_all_channels_of_span(ftdm_stream_handle_t *stream, char *span_id) -{ - int x=-1; - SS7_RELAY_DBG_FUN(cli_ss7_show_all_channels_of_span); - - ftdm_assert_return(stream != NULL, FTDM_FAIL, "Null stream\n"); - ftdm_assert_return(span_id != 0, FTDM_FAIL, "Invalid span id\n"); - - x = atoi(span_id); - if (!x) { - stream->write_function( stream, "Span \'%s\' does not exist. \n", span_id); - return FTDM_FAIL; - } - return handle_show_status(stream, x, 0, 1); -} - -/****************************************************************************** -* Fun: cli_ss7_show_span_by_id() -* Desc: display span information of a given id -* Param: -* stream : output stream object -* span_id : span id string received from cli -* Ret: FTDM_SUCCESS | FTDM_FAIL -* Note: -* author: James Zhang -*******************************************************************************/ -static ftdm_status_t cli_ss7_show_span_by_id(ftdm_stream_handle_t *stream, char *span_id) -{ - int x = -1; - - SS7_RELAY_DBG_FUN(cli_ss7_show_span_by_id); - - ftdm_assert_return(stream != NULL, FTDM_FAIL, "Null stream\n"); - ftdm_assert_return(span_id != 0, FTDM_FAIL, "Invalid span id\n"); - - x = atoi(span_id); - if (!x) { - stream->write_function(stream, "Span \'%s\' does not exist. \n", span_id); - return FTDM_FAIL; - } - -#if 0 - stream->write_function( stream, "JZ: we should display span details here \n" ); -#endif - - cli_ss7_show_all_channels_of_span(stream, span_id); - - return FTDM_FAIL; -} - - -/****************************************************************************** -* Fun: cli_ss7_show_all_spans_detail() -* Desc: display all spans information in detail -* Param: -* stream : output stream object -* Ret: FTDM_SUCCESS | FTDM_FAIL -* Note: -* author: James Zhang -*******************************************************************************/ -static ftdm_status_t cli_ss7_show_all_spans_detail(ftdm_stream_handle_t *stream) -{ - SS7_RELAY_DBG_FUN(cli_ss7_show_all_spans_detail); - ftdm_assert_return(stream != NULL, FTDM_FAIL, "Null stream\n"); - return handle_show_status(stream, 0, 0, 1); -} - -/****************************************************************************** -* Fun: cli_ss7_show_all_spans_general() -* Desc: display all spans information in general -* Param: -* stream : output stream object -* Ret: FTDM_SUCCESS | FTDM_FAIL -* Note: -* author: James Zhang -*******************************************************************************/ -static ftdm_status_t cli_ss7_show_all_spans_general(ftdm_stream_handle_t *stream) -{ - SS7_RELAY_DBG_FUN(cli_ss7_show_all_spans_general); - ftdm_assert_return(stream != NULL, FTDM_FAIL, "Null stream\n"); - return FTDM_FAIL; -} - - -/****************************************************************************** -* Fun: handle_show_m2ua_profiles() -* Desc: display all m2ua profile information -* Ret: FTDM_SUCCESS | FTDM_FAIL -* Note: -* author: Kapil Gupta -*******************************************************************************/ - -static ftdm_status_t handle_show_m2ua_profiles(ftdm_stream_handle_t *stream) -{ - MwMgmt cfm; - MwMgmt rsp; - char buf[2048]; - char* xmlhdr = (char*)""; - int x = 0x00; - int idx = 0x00; - int len = 0x00; - - memset((U8 *)&cfm, 0, sizeof(MwMgmt)); - memset((U8 *)&rsp, 0, sizeof(MwMgmt)); - memset(&buf[0], 0, sizeof(buf)); - - len = len + sprintf(buf + len, "%s\n", xmlhdr); - len = len + sprintf(buf + len, "\n"); - - if(ftmod_m2ua_ssta_req(STMWGEN, 0x00, &cfm)) { - stream->write_function(stream," Request to layer failed \n"); - return FTDM_FAIL; - } else { - len = len + sprintf(buf + len, "\n"); -#ifdef BIT_64 - len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.genSta.memSize); - len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.genSta.memAlloc); -#else - len = len + sprintf(buf + len, " %ld \n", cfm.t.ssta.s.genSta.memSize); - len = len + sprintf(buf + len, " %ld \n", cfm.t.ssta.s.genSta.memAlloc); -#endif - len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.genSta.nmbClusters); - len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.genSta.nmbPeers); - len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.genSta.nmbIntf); - len = len + sprintf(buf + len, "\n"); - } - - /*iterate through all the m2ua links and prints all information */ - x = 1; - while(x\n"); - len = len + sprintf(buf + len, " %s \n", g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua[x].name); - - if(ftmod_m2ua_ssta_req(STMWDLSAP,x,&cfm)) { - stream->write_function(stream," Request to M2UA layer failed \n"); - return FTDM_FAIL; - } else { - len = len + sprintf(buf + len, "\n"); - len = len + sprintf(buf + len," %s \n", PRNT_M2UA_SAP_STATE(cfm.t.ssta.s.dlSapSta.state)); - len = len + sprintf(buf + len," %s \n", PRNT_M2UA_LINK_STATE(cfm.t.ssta.s.dlSapSta.lnkState)); - len = len + sprintf(buf + len," %d \n", cfm.t.ssta.s.dlSapSta.rpoEnable); - len = len + sprintf(buf + len," %d \n", cfm.t.ssta.s.dlSapSta.lpoEnable); - len = len + sprintf(buf + len," %d \n", cfm.t.ssta.s.dlSapSta.congLevel); - len = len + sprintf(buf + len, "\n"); - } - - memset((U8 *)&cfm, 0, sizeof(MwMgmt)); - if(ftmod_m2ua_ssta_req(STMWCLUSTER,g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua[x].clusterId,&cfm)) { - stream->write_function(stream," Request to M2UA layer failed \n"); - return FTDM_FAIL; - } else { - len = len + sprintf(buf + len, "\n"); - len = len + sprintf(buf + len," %s \n", PRNT_M2UA_CLUSTER_STATE(cfm.t.ssta.s.clusterSta.state)); - len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.clusterSta.nmbPeer); - len = len + sprintf(buf + len, "\n"); - for(idx = 0; idx < cfm.t.ssta.s.clusterSta.nmbPeer; idx++) - { - len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.clusterSta.peerSt[idx].peerId); - len = len + sprintf(buf + len, " %s \n", PRNT_M2UA_PEER_STATE(cfm.t.ssta.s.clusterSta.peerSt[idx].peerState)); - } - len = len + sprintf(buf + len, "\n"); - len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.clusterSta.nmbActPeer); - - len = len + sprintf(buf + len, "\n"); - - memset((U8 *)&rsp, 0, sizeof(MwMgmt)); - memcpy(&rsp, &cfm, sizeof(MwMgmt)); - - - /* loop through configured peers */ - for(idx = 0; idx < rsp.t.ssta.s.clusterSta.nmbPeer; idx++) - { - int peer_id = rsp.t.ssta.s.clusterSta.peerSt[idx].peerId; - - memset(&cfm, 0, sizeof(MwMgmt)); - - if(LMW_PEER_DOWN != rsp.t.ssta.s.clusterSta.peerSt[idx].peerState){ - - if(ftmod_m2ua_ssta_req(STMWPEER, peer_id, &cfm)) { - stream->write_function(stream," Request to M2UA layer failed \n"); - return FTDM_FAIL; - } else { - len = len + sprintf(buf + len, "\n"); - len = len + sprintf(buf + len, " %s \n",g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_peer[peer_id].name); - len = len + sprintf(buf + len," %s \n", PRNT_M2UA_PEER_STATE(cfm.t.ssta.s.peerSta.state)); - len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.retryCount); - len = len + sprintf(buf + len, " %d \n", (int)cfm.t.ssta.s.peerSta.assocSta.spAssocId); - len = len + sprintf(buf + len, " %s \n",(cfm.t.ssta.s.peerSta.assocSta.connected)?"CONNECTED":"NOT CONNECTED"); - len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.assocSta.flcInProg); - len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.assocSta.flcLevel); - len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.assocSta.sctpHBeatEnb); - len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.assocSta.locOutStrms); - - len = len + sprintf(buf + len, "\n"); - } - } else { - len = len + sprintf(buf + len, "\n"); - len = len + sprintf(buf + len, " %s \n",g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_peer[peer_id].name); - len = len + sprintf(buf + len," %s \n", PRNT_M2UA_PEER_STATE(rsp.t.ssta.s.clusterSta.peerSt[idx].peerState)); - len = len + sprintf(buf + len, "\n"); - } - } - } - - memset((U8 *)&cfm, 0, sizeof(MwMgmt)); - if(ftmod_m2ua_ssta_req(STMWSCTSAP,x,&cfm)) { - stream->write_function(stream," Request to M2UA layer failed \n"); - return FTDM_FAIL; - } else { - len = len + sprintf(buf + len, "\n"); - len = len + sprintf(buf + len," %s \n", PRNT_M2UA_SAP_STATE(cfm.t.ssta.s.sctSapSta.state)); - len = len + sprintf(buf + len," %s \n", (cfm.t.ssta.s.sctSapSta.endpOpen)?"END_POINT_OPENED_SUCCESSFULLY":"END_POINT_NOT_OPEN"); - len = len + sprintf(buf + len," %d \n", (int) cfm.t.ssta.s.sctSapSta.spEndpId); - len = len + sprintf(buf + len," %d \n", cfm.t.ssta.s.sctSapSta.nmbPrimRetry); - len = len + sprintf(buf + len, "\n"); - } - - len = len + sprintf(buf + len, "\n"); - } - x++; - } - - len = len + sprintf(buf + len, "\n"); - stream->write_function(stream,"\n%s\n",buf); - - return FTDM_SUCCESS; - -} - -/****************************************************************************** -* Fun: handle_show_m2ua_profile() -* Desc: display requested m2ua profile information -* Ret: FTDM_SUCCESS | FTDM_FAIL -* Note: -* author: Kapil Gupta -*******************************************************************************/ - -static ftdm_status_t handle_show_m2ua_profile(ftdm_stream_handle_t *stream, char* m2ua_profile_name) -{ - char* xmlhdr = (char*)""; - char buf[4096]; - int x = 0x00; - int idx = 0x00; - int found = 0x00; - int len = 0x00; - MwMgmt cfm; - MwMgmt rsp; - - memset((U8 *)&cfm, 0, sizeof(MwMgmt)); - memset((U8 *)&rsp, 0, sizeof(MwMgmt)); - memset(&buf[0], 0, sizeof(buf)); - - len = len + sprintf(buf + len, "%s\n", xmlhdr); - - /*iterate through all the m2ua links and get required profile */ - x = 1; - while(xwrite_function(stream,"Requested M2UA profile[%s] not configured\n", m2ua_profile_name); - return FTDM_FAIL; - } - - - len = len + sprintf(buf + len, "\n"); - len = len + sprintf(buf + len, " %s \n", m2ua_profile_name); - - if(ftmod_m2ua_ssta_req(STMWDLSAP,x,&cfm)) { - stream->write_function(stream," Request to M2UA layer failed \n"); - return FTDM_FAIL; - } else { - len = len + sprintf(buf + len, "\n"); - len = len + sprintf(buf + len," %s \n", PRNT_M2UA_SAP_STATE(cfm.t.ssta.s.dlSapSta.state)); - len = len + sprintf(buf + len," %s \n", PRNT_M2UA_LINK_STATE(cfm.t.ssta.s.dlSapSta.lnkState)); - len = len + sprintf(buf + len," %d \n", cfm.t.ssta.s.dlSapSta.rpoEnable); - len = len + sprintf(buf + len," %d \n", cfm.t.ssta.s.dlSapSta.lpoEnable); - len = len + sprintf(buf + len," %d \n", cfm.t.ssta.s.dlSapSta.congLevel); - len = len + sprintf(buf + len, "\n"); - } - - if(ftmod_m2ua_ssta_req(STMWCLUSTER, g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua[x].clusterId, &cfm)) { - stream->write_function(stream," Request to M2UA layer failed \n"); - return FTDM_FAIL; - } else { - len = len + sprintf(buf + len, "\n"); - len = len + sprintf(buf + len," %s \n", PRNT_M2UA_CLUSTER_STATE(cfm.t.ssta.s.clusterSta.state)); - len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.clusterSta.nmbPeer); - len = len + sprintf(buf + len, "\n"); - for(idx = 0; idx < cfm.t.ssta.s.clusterSta.nmbPeer; idx++) - { - len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.clusterSta.peerSt[idx].peerId); - len = len + sprintf(buf + len, " %s \n", PRNT_M2UA_PEER_STATE(cfm.t.ssta.s.clusterSta.peerSt[idx].peerState)); - } - len = len + sprintf(buf + len, "\n"); - len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.clusterSta.nmbActPeer); - - len = len + sprintf(buf + len, "\n"); - } - - memcpy((U8 *)&rsp, &cfm, sizeof(MwMgmt)); - - /* loop through configured peers */ - for(idx = 0; idx < rsp.t.ssta.s.clusterSta.nmbPeer; idx++) - { - memset((U8 *)&cfm, 0, sizeof(MwMgmt)); - - if(ftmod_m2ua_ssta_req(STMWPEER, rsp.t.ssta.s.clusterSta.peerSt[idx].peerId, &cfm)) { - stream->write_function(stream," Request to M2UA layer failed \n"); - return FTDM_FAIL; - } else { - len = len + sprintf(buf + len, "\n"); - len = len + sprintf(buf + len, " %s \n",g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_peer[rsp.t.ssta.s.clusterSta.peerSt[idx].peerId].name); - len = len + sprintf(buf + len," %s \n", PRNT_M2UA_PEER_STATE(cfm.t.ssta.s.peerSta.state)); - len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.retryCount); -#ifdef BIT_64 - len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.peerSta.assocSta.spAssocId); -#else - len = len + sprintf(buf + len, " %ld \n", cfm.t.ssta.s.peerSta.assocSta.spAssocId); -#endif - len = len + sprintf(buf + len, " %s \n",(cfm.t.ssta.s.peerSta.assocSta.connected)?"CONNECTED":"NOT CONNECTED"); - len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.assocSta.flcInProg); - len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.assocSta.flcLevel); - len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.assocSta.sctpHBeatEnb); - len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.assocSta.locOutStrms); - - len = len + sprintf(buf + len, "\n"); - } - } - - if(ftmod_m2ua_ssta_req(STMWSCTSAP,x,&cfm)) { - stream->write_function(stream," Request to M2UA layer failed \n"); - return FTDM_FAIL; - } else { - len = len + sprintf(buf + len, "\n"); - len = len + sprintf(buf + len," %s \n", PRNT_M2UA_SAP_STATE(cfm.t.ssta.s.sctSapSta.state)); - len = len + sprintf(buf + len," %s \n", (cfm.t.ssta.s.sctSapSta.endpOpen)?"END_POINT_OPENED_SUCCESSFULLY":"END_POINT_NOT_OPEN"); -#ifdef BIT_64 - len = len + sprintf(buf + len," %d \n", cfm.t.ssta.s.sctSapSta.spEndpId); -#else - len = len + sprintf(buf + len," %ld \n", cfm.t.ssta.s.sctSapSta.spEndpId); -#endif - len = len + sprintf(buf + len," %d \n", cfm.t.ssta.s.sctSapSta.nmbPrimRetry); - len = len + sprintf(buf + len, "\n"); - } - - len = len + sprintf(buf + len, "\n"); - - stream->write_function(stream,"\n%s\n",buf); - - return FTDM_SUCCESS; - -} - -/****************************************************************************** -* Fun: handle_show_sctp_profiles() -* Desc: display all sctp profile information -* Ret: FTDM_SUCCESS | FTDM_FAIL -* Note: -* author: Kapil Gupta -*******************************************************************************/ -static ftdm_status_t handle_show_sctp_profiles(ftdm_stream_handle_t *stream) -{ - char* xmlhdr = (char*)""; - char buf[4096]; - int x = 0x00; - int len = 0x00; - SbMgmt cfm; - - memset((U8 *)&cfm, 0, sizeof(SbMgmt)); - memset(&buf[0], 0, sizeof(buf)); - - len = len + sprintf(buf + len, "%s\n", xmlhdr); - len = len + sprintf(buf + len, "\n"); - - if(ftmod_sctp_ssta_req(STSBGEN, 0x00, &cfm)) { - stream->write_function(stream," Request to SCTP layer failed \n"); - return FTDM_FAIL; - } else { - len = len + sprintf(buf + len, "\n"); -#ifdef BIT_64 - len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.genSta.memSize); - len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.genSta.memAlloc); -#else - len = len + sprintf(buf + len, " %ld \n",cfm.t.ssta.s.genSta.memSize); - len = len + sprintf(buf + len, " %ld \n",cfm.t.ssta.s.genSta.memAlloc); -#endif - len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.genSta.nmbAssoc); - len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.genSta.nmbEndp); - len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.genSta.nmbLocalAddr); - len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.genSta.nmbPeerAddr); - len = len + sprintf(buf + len, "\n"); - } - -#ifdef LSB12 - if(ftmod_sctp_ssta_req(STSBTMR, 0x00, &cfm)) { - stream->write_function(stream," Request to SCTP layer failed \n"); - return FTDM_FAIL; - } else { - len = len + sprintf(buf + len, "\n"); - - len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.tmrSta.lifetimeTmr); - len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.tmrSta.ackDelayTmr); - len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.tmrSta.cookieTmr); - len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.tmrSta.keyTmr); - len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.tmrSta.freezeTmr); -#ifdef LSB4 - len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.tmrSta.bundleTmr); -#endif - len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.tmrSta.t1InitTmr); - len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.tmrSta.t2ShutdownTmr); - len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.tmrSta.hbeat); - len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.tmrSta.t3rtx); - len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.tmrSta.tIntTmr); - } - -#endif - - - /*iterate through all the sctp links and prints all information */ - x = 1; - while(x\n"); - - if(ftmod_sctp_ssta_req(STSBSCTSAP,x,&cfm)) { - stream->write_function(stream," Request to SCTP layer failed \n"); - return FTDM_FAIL; - } else { - len = len + sprintf(buf + len, "\n"); - len = len + sprintf(buf + len," %s \n", PRNT_SCTP_SAP_STATE(cfm.t.ssta.s.sapSta.hlSt)); - len = len + sprintf(buf + len," %s \n", PRNT_SCTP_PROTO_SWITCH(cfm.t.ssta.s.sapSta.swtch)); - len = len + sprintf(buf + len, "\n"); - } - - if(ftmod_sctp_ssta_req(STSBTSAP,x,&cfm)) { - stream->write_function(stream," Request to SCTP layer failed \n"); - return FTDM_FAIL; - } else { - len = len + sprintf(buf + len, "\n"); - len = len + sprintf(buf + len," %s \n", PRNT_SCTP_SAP_STATE(cfm.t.ssta.s.sapSta.hlSt)); - len = len + sprintf(buf + len," %s \n", PRNT_SCTP_PROTO_SWITCH(cfm.t.ssta.s.sapSta.swtch)); - len = len + sprintf(buf + len, "\n"); - } - - if(ftmod_sctp_ssta_req(STSBASSOC,x,&cfm)) { - if(LCM_REASON_INVALID_PAR_VAL == cfm.cfm.reason){ - len = len + sprintf(buf + len, "\n"); - len = len + sprintf(buf + len, " SCT_ASSOC_STATE_CLOSED \n"); - len = len + sprintf(buf + len, "\n"); - }else{ - stream->write_function(stream," Request to SCTP layer failed \n"); - return FTDM_FAIL; - } - } else { - len = len + sprintf(buf + len, "\n"); - len = len + get_assoc_resp_buf(buf + len, &cfm); - len = len + sprintf(buf + len, "\n"); - } - - /* TODO - STSBDTA */ - - len = len + sprintf(buf + len, "\n"); - } - x++; - } - - len = len + sprintf(buf + len, "\n"); - stream->write_function(stream,"\n%s\n",buf); - - return FTDM_SUCCESS; -} - -int get_assoc_resp_buf(char* buf,SbMgmt* cfm) -{ - int len = 0x00; - int idx = 0x00; - char *asciiAddr; - CmInetIpAddr ip; - -#ifdef BIT_64 - len = len + sprintf(buf + len, " %d \n", cfm->t.ssta.s.assocSta.assocId); -#else - len = len + sprintf(buf + len, " %ld \n", cfm->t.ssta.s.assocSta.assocId); -#endif - len = len + sprintf(buf + len, " %s \n", PRNT_SCTP_ASSOC_STATE(cfm->t.ssta.s.assocSta.assocState)); - len = len + sprintf(buf + len, " %d \n", cfm->t.ssta.s.assocSta.dstPort); - len = len + sprintf(buf + len, " %d \n", cfm->t.ssta.s.assocSta.srcPort); - len = len + sprintf(buf + len, " %d \n", cfm->t.ssta.s.assocSta.dstNAddrLst.nmb); - for(idx =0; idx < cfm->t.ssta.s.assocSta.dstNAddrLst.nmb; idx++) - { - len = len + sprintf(buf + len, " \n"); - len = len + sprintf(buf + len, " %s \n", PRNT_CM_ADDR_TYPE(cfm->t.ssta.s.assocSta.dstNAddrLst.nAddr[idx].type)); - if(cfm->t.ssta.s.assocSta.dstNAddrLst.nAddr[idx].type == CM_IPV4ADDR_TYPE) - { - ip = ntohl(cfm->t.ssta.s.assocSta.dstNAddrLst.nAddr[idx].u.ipv4NetAddr); - cmInetNtoa(ip, &asciiAddr); - len = len + sprintf(buf + len, " %s \n",asciiAddr); - } - else - { - len = len + sprintf(buf + len, " %s \n", cfm->t.ssta.s.assocSta.dstNAddrLst.nAddr[idx].u.ipv6NetAddr); - } - len = len + sprintf(buf + len, " \n"); - } - - len = len + sprintf(buf + len, " %d \n", cfm->t.ssta.s.assocSta.srcNAddrLst.nmb); - for(idx =0; idx < cfm->t.ssta.s.assocSta.srcNAddrLst.nmb; idx++) - { - len = len + sprintf(buf + len, " \n"); - len = len + sprintf(buf + len, " %s \n", PRNT_CM_ADDR_TYPE(cfm->t.ssta.s.assocSta.srcNAddrLst.nAddr[idx].type)); - if(cfm->t.ssta.s.assocSta.srcNAddrLst.nAddr[idx].type == CM_IPV4ADDR_TYPE) - { - ip = ntohl(cfm->t.ssta.s.assocSta.srcNAddrLst.nAddr[idx].u.ipv4NetAddr); - cmInetNtoa(ip, &asciiAddr); - len = len + sprintf(buf + len, " %s \n", asciiAddr); - } - else - { - len = len + sprintf(buf + len, " %s \n", cfm->t.ssta.s.assocSta.srcNAddrLst.nAddr[idx].u.ipv6NetAddr); - } - len = len + sprintf(buf + len, " \n"); - } - - len = len + sprintf(buf + len, "\n %s \n", PRNT_CM_ADDR_TYPE(cfm->t.ssta.s.assocSta.priNAddr.type)); - - if(cfm->t.ssta.s.assocSta.priNAddr.type == CM_IPV4ADDR_TYPE) - { - ip = ntohl(cfm->t.ssta.s.assocSta.priNAddr.u.ipv4NetAddr); - cmInetNtoa(ip, &asciiAddr); - len = len + sprintf(buf + len, " %s \n",asciiAddr); - } - else - { - len = len + sprintf(buf + len, " %s \n", cfm->t.ssta.s.assocSta.priNAddr.u.ipv6NetAddr); - } - -#ifdef LSB11 - /* TODO - this flag is not enable as of now.. so later on will convert below prints to XML tags */ - len = len + sprintf(buf + len, " The number of unsent datagrams : %d\n", cfm->t.ssta.s.assocSta.nmbUnsentDgms); - len = len + sprintf(buf + len, " The number of unack datagrams : %d\n", cfm->t.ssta.s.assocSta.nmbUnackDgms); - len = len + sprintf(buf + len, " The number of undelivered datagrams : %d\n", cfm->t.ssta.s.assocSta.nmbUndelDgms); - len = len + sprintf(buf + len, " The number of retransmissions count : %d\n", cfm->t.ssta.s.assocSta.rtxCnt); - len = len + sprintf(buf + len, " The receive window size is: %d\n\n", cfm->t.ssta.s.assocSta.SctWinSize); - for(idx =0; idx < LSB_MAX_TMRS ; idx++) - { - len = len + sprintf(buf + len, " %d) Timer state is %d\n", idx, cfm->t.ssta.s.assocSta.tmr[idx].state); - len = len + sprintf(buf + len, " %d) Timer value is %d\n", idx, cfm->t.ssta.s.assocSta.tmr[idx].tmrVal); - len = len + sprintf(buf + len, " %d) No of paths is %d\n", idx, cfm->t.ssta.s.assocSta.tmr[idx].numPaths); - for(idx1 =0; idx1 < cfm->t.ssta.s.assocSta.tmr[idx].numPaths; idx1++) - { - if( cfm->t.ssta.s.assocSta.tmr[idx].path[idx1].localAddr.type == CM_IPV4ADDR_TYPE) - { - len = len + sprintf(buf + len, " %d) the local Addr is %d\n", idx1, - cfm->t.ssta.s.assocSta.tmr[idx].path[idx1].localAddr.u.ipv4NetAddr); - } - else - { - len = len + sprintf(buf + len, " %d) the local Addr is %s\n", idx1, - cfm->t.ssta.s.assocSta.tmr[idx].path[idx1].localAddr.u.ipv6NetAddr); - } - - if( cfm->t.ssta.s.assocSta.tmr[idx].path[idx1].peerAddr.type == CM_IPV4ADDR_TYPE) - { - len = len + sprintf(buf + len, " %d) the peer Addr is %d\n", idx1, - cfm->t.ssta.s.assocSta.tmr[idx].path[idx1].peerAddr.u.ipv4NetAddr); - } - else - { - len = len + sprintf(buf + len, " %d) the peer Addr is %s\n", idx1, - cfm->t.ssta.s.assocSta.tmr[idx].path[idx1].peerAddr.u.ipv6NetAddr); - } - } /* Loop for paths */ - } /* Loop for timers */ -#endif - - return len; -} - -/****************************************************************************** -* Fun: handle_show_sctp_profile() -* Desc: display requested sctp profile information -* Ret: FTDM_SUCCESS | FTDM_FAIL -* Note: -* author: Kapil Gupta -*******************************************************************************/ -static ftdm_status_t handle_show_sctp_profile(ftdm_stream_handle_t *stream, char* sctp_profile_name) -{ - char* xmlhdr = (char*)""; - char buf[4096]; - int x = 0x00; - int len = 0x00; - SbMgmt cfm; - int found = 0x00; - - memset((U8 *)&cfm, 0, sizeof(SbMgmt)); - memset(&buf[0], 0, sizeof(buf)); - - len = len + sprintf(buf + len, "%s\n", xmlhdr); - - /*iterate through all the sctp links and prints all information */ - x = 1; - while(xwrite_function(stream,"Requested SCTP profile[%s] not configured\n", sctp_profile_name); - return FTDM_FAIL; - } - - len = len + sprintf(buf + len, "\n"); - - if(ftmod_sctp_ssta_req(STSBSCTSAP,x,&cfm)) { - stream->write_function(stream," Request to SCTP layer failed \n"); - return FTDM_FAIL; - } else { - len = len + sprintf(buf + len, "\n"); - len = len + sprintf(buf + len," %s \n", PRNT_SCTP_SAP_STATE(cfm.t.ssta.s.sapSta.hlSt)); - len = len + sprintf(buf + len," %s \n", PRNT_SCTP_PROTO_SWITCH(cfm.t.ssta.s.sapSta.swtch)); - len = len + sprintf(buf + len, "\n"); - } - - if(ftmod_sctp_ssta_req(STSBTSAP,x,&cfm)) { - stream->write_function(stream," Request to SCTP layer failed \n"); - return FTDM_FAIL; - } else { - len = len + sprintf(buf + len, "\n"); - len = len + sprintf(buf + len," %s \n", PRNT_SCTP_SAP_STATE(cfm.t.ssta.s.sapSta.hlSt)); - len = len + sprintf(buf + len," %s \n", PRNT_SCTP_PROTO_SWITCH(cfm.t.ssta.s.sapSta.swtch)); - len = len + sprintf(buf + len, "\n"); - } - - if(ftmod_sctp_ssta_req(STSBASSOC,x,&cfm)) { - /* it means assoc id not yet allocated */ - if(LCM_REASON_INVALID_PAR_VAL == cfm.cfm.reason){ - len = len + sprintf(buf + len, "\n"); - len = len + sprintf(buf + len, " SCT_ASSOC_STATE_CLOSED \n"); - len = len + sprintf(buf + len, "\n"); - }else{ - stream->write_function(stream," Request to SCTP layer failed \n"); - return FTDM_FAIL; - } - } else { - len = len + sprintf(buf + len, "\n"); - len = len + get_assoc_resp_buf(buf + len, &cfm); - len = len + sprintf(buf + len, "\n"); - } - - /* TODO - STSBDTA */ - - len = len + sprintf(buf + len, "\n"); - - stream->write_function(stream,"\n%s\n",buf); - - return FTDM_SUCCESS; -} - -/****************************************************************************** -* Fun: handle_show_nif_profiles() -* Desc: display all nif profile information -* Ret: FTDM_SUCCESS | FTDM_FAIL -* Note: -* author: Kapil Gupta -*******************************************************************************/ -static ftdm_status_t handle_show_nif_profiles(ftdm_stream_handle_t *stream) -{ - char* xmlhdr = (char*)""; - char buf[4096]; - int x = 0x00; - int len = 0x00; - NwMgmt cfm; - - memset((U8 *)&cfm, 0, sizeof(NwMgmt)); - memset(&buf[0], 0, sizeof(buf)); - - len = len + sprintf(buf + len, "%s\n", xmlhdr); - len = len + sprintf(buf + len, "\n"); - - if(ftmod_nif_ssta_req(STNWGEN, 0x00, &cfm)) { - stream->write_function(stream," Request to NIF layer failed \n"); - return FTDM_FAIL; - } else { - len = len + sprintf(buf + len, "\n"); -#ifdef BIT_64 - len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.genSta.memSize); - len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.genSta.memAlloc); -#else - len = len + sprintf(buf + len, " %ld \n",cfm.t.ssta.s.genSta.memSize); - len = len + sprintf(buf + len, " %ld \n",cfm.t.ssta.s.genSta.memAlloc); -#endif - len = len + sprintf(buf + len, "\n"); - } - - /*iterate through all the NIF links and prints all information */ - x = 1; - while(x\n"); - - if(ftmod_nif_ssta_req(STNWDLSAP,x,&cfm)) { - stream->write_function(stream," Request to NIF layer failed \n"); - return FTDM_FAIL; - } else { - len = len + sprintf(buf + len, "\n"); - len = len + sprintf(buf + len," %s \n", PRNT_NIF_SAP_STATE(cfm.t.ssta.s.dlSapSta.m2uaState)); - len = len + sprintf(buf + len," %s \n", PRNT_NIF_SAP_STATE(cfm.t.ssta.s.dlSapSta.mtp2State)); -#ifdef BIT_64 - len = len + sprintf(buf + len," %d \n", cfm.t.ssta.s.dlSapSta.nmbRetry); -#else - len = len + sprintf(buf + len," %ld \n", cfm.t.ssta.s.dlSapSta.nmbRetry); -#endif - len = len + sprintf(buf + len, "\n"); - } - - len = len + sprintf(buf + len, "\n"); - } - x++; - } - - len = len + sprintf(buf + len, "\n"); - stream->write_function(stream,"\n%s\n",buf); - - return FTDM_SUCCESS; -} - -/****************************************************************************** -* Fun: handle_show_nif_profile() -* Desc: display requested nif profile information -* Ret: FTDM_SUCCESS | FTDM_FAIL -* Note: -* author: Kapil Gupta -*******************************************************************************/ -static ftdm_status_t handle_show_nif_profile(ftdm_stream_handle_t *stream, char* nif_profile_name) -{ - char* xmlhdr = (char*)""; - char buf[4096]; - int x = 0x00; - int found = 0x00; - int len = 0x00; - NwMgmt cfm; - - memset((U8 *)&cfm, 0, sizeof(NwMgmt)); - memset(&buf[0], 0, sizeof(buf)); - - len = len + sprintf(buf + len, "%s\n", xmlhdr); - - /*iterate through all the m2ua links and get required profile */ - x = 1; - while(xwrite_function(stream,"Requested NIF profile[%s] not configured\n", nif_profile_name); - return FTDM_FAIL; - } - - - len = len + sprintf(buf + len, "\n"); - - if(ftmod_nif_ssta_req(STNWDLSAP,x,&cfm)) { - stream->write_function(stream," Request to NIF layer failed \n"); - return FTDM_FAIL; - } else { - len = len + sprintf(buf + len, "\n"); - len = len + sprintf(buf + len," %s \n", PRNT_NIF_SAP_STATE(cfm.t.ssta.s.dlSapSta.m2uaState)); - len = len + sprintf(buf + len," %s \n", PRNT_NIF_SAP_STATE(cfm.t.ssta.s.dlSapSta.mtp2State)); -#ifdef BIT_64 - len = len + sprintf(buf + len," %d \n", cfm.t.ssta.s.dlSapSta.nmbRetry); -#else - len = len + sprintf(buf + len," %ld \n", cfm.t.ssta.s.dlSapSta.nmbRetry); -#endif - len = len + sprintf(buf + len, "\n"); - } - - len = len + sprintf(buf + len, "\n"); - - stream->write_function(stream,"\n%s\n",buf); - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -/****************************************************************************** -* Fun: handle_show_m2ua_peer_status() -* Desc: display requested m2ua profile peer information -* Ret: FTDM_SUCCESS | FTDM_FAIL -* Note: -* author: Kapil Gupta -*******************************************************************************/ - -static ftdm_status_t handle_show_m2ua_peer_status(ftdm_stream_handle_t *stream, char* m2ua_profile_name) -{ - char* xmlhdr = (char*)""; - char buf[4096]; - int x = 0x00; - int found = 0x00; - int len = 0x00; - MwMgmt cfm; - SbMgmt sctp_cfm; - sng_m2ua_cluster_cfg_t* clust = NULL; - sng_m2ua_cfg_t* m2ua = NULL; - sng_m2ua_peer_cfg_t* peer = NULL; - int peer_id = 0; - int sctp_id = 0; - - memset((U8 *)&cfm, 0, sizeof(MwMgmt)); - memset((U8 *)&sctp_cfm, 0, sizeof(SbMgmt)); - memset(&buf[0], 0, sizeof(buf)); - - len = len + sprintf(buf + len, "%s\n", xmlhdr); - - /*iterate through all the m2ua links and get required profile */ - x = 1; - while(xwrite_function(stream,"Requested M2UA profile[%s] not configured\n", m2ua_profile_name); - return FTDM_FAIL; - } - - m2ua = &g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua[x]; - clust = &g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_clus[m2ua->clusterId]; - - for(x = 0; x < clust->numOfPeers;x++){ - peer_id = clust->peerIdLst[x]; - peer = &g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_peer[peer_id]; - - if(ftmod_m2ua_ssta_req(STMWPEER, peer_id, &cfm)) { - stream->write_function(stream," Request to M2UA layer failed \n"); - return FTDM_FAIL; - } else { - len = len + sprintf(buf + len, "\n"); - len = len + sprintf(buf + len, " %s \n",peer->name); - len = len + sprintf(buf + len," %s \n", PRNT_M2UA_PEER_STATE(cfm.t.ssta.s.peerSta.state)); - /*len = len + sprintf(buf + len, " %s \n",(cfm.t.ssta.s.peerSta.assocSta.connected)?"CONNECTED":"NOT CONNECTED");*/ - len = len + sprintf(buf + len, "\n"); - } - - sctp_id = peer->sctpId; - - if(ftmod_sctp_ssta_req(STSBASSOC, sctp_id, &sctp_cfm)) { - if(LMW_PEER_DOWN == cfm.t.ssta.s.peerSta.state){ - /* If there is no association established so far, it will return fail..*/ - len = len + sprintf(buf + len, "\n"); - len = len + sprintf(buf + len, " SCT_ASSOC_STATE_CLOSED \n"); - len = len + sprintf(buf + len, "\n"); - }else{ - stream->write_function(stream," Request to SCTP layer failed \n"); - return FTDM_FAIL; - } - } else { - len = len + sprintf(buf + len, "\n"); - len = len + sprintf(buf + len, " %s \n", PRNT_SCTP_ASSOC_STATE(sctp_cfm.t.ssta.s.assocSta.assocState)); - len = len + sprintf(buf + len, "\n"); - } - } - - stream->write_function(stream,"\n%s\n",buf); - - return FTDM_SUCCESS; -} - -/****************************************************************************** -* Fun: handle_show_m2ua_cluster_status() -* Desc: display requested m2ua profile cluster information -* Ret: FTDM_SUCCESS | FTDM_FAIL -* Note: -* author: Kapil Gupta -*******************************************************************************/ - -static ftdm_status_t handle_show_m2ua_cluster_status(ftdm_stream_handle_t *stream, char* m2ua_profile_name) -{ - char* xmlhdr = (char*)""; - char buf[4096]; - int x = 0x00; - int found = 0x00; - int len = 0x00; - int idx = 0x00; - MwMgmt cfm; - SbMgmt sctp_cfm; - sng_m2ua_cluster_cfg_t* clust = NULL; - sng_m2ua_cfg_t* m2ua = NULL; - - memset((U8 *)&cfm, 0, sizeof(MwMgmt)); - memset((U8 *)&sctp_cfm, 0, sizeof(SbMgmt)); - memset(&buf[0], 0, sizeof(buf)); - - len = len + sprintf(buf + len, "%s\n", xmlhdr); - - /*iterate through all the m2ua links and get required profile */ - x = 1; - while(xwrite_function(stream,"Requested M2UA profile[%s] not configured\n", m2ua_profile_name); - return FTDM_FAIL; - } - - m2ua = &g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua[x]; - clust = &g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_clus[m2ua->clusterId]; - - if(ftmod_m2ua_ssta_req(STMWCLUSTER,g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua[x].clusterId,&cfm)) { - stream->write_function(stream," Request to M2UA layer failed \n"); - return FTDM_FAIL; - } else { - len = len + sprintf(buf + len, "\n"); - len = len + sprintf(buf + len, " %s \n",clust->name); - len = len + sprintf(buf + len," %s \n", PRNT_M2UA_CLUSTER_STATE(cfm.t.ssta.s.clusterSta.state)); - len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.clusterSta.nmbPeer); - for(idx = 0; idx < cfm.t.ssta.s.clusterSta.nmbPeer; idx++) - { - len = len + sprintf(buf + len, "\n"); - len = len + sprintf(buf + len, " %s \n", g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_peer[cfm.t.ssta.s.clusterSta.peerSt[idx].peerId].name); - len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.clusterSta.peerSt[idx].peerId); - len = len + sprintf(buf + len, " %s \n", PRNT_M2UA_PEER_STATE(cfm.t.ssta.s.clusterSta.peerSt[idx].peerState)); - len = len + sprintf(buf + len, "\n"); - } - len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.clusterSta.nmbActPeer); - - len = len + sprintf(buf + len, "\n"); - } - - stream->write_function(stream,"\n%s\n",buf); - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ -/******************************************************************************/ diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cntrl.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cntrl.c deleted file mode 100644 index 6b12605c6a..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cntrl.c +++ /dev/null @@ -1,921 +0,0 @@ -/* - * Copyright (c) 2009, Konrad Hammel - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* INCLUDE ********************************************************************/ -#include "ftmod_sangoma_ss7_main.h" -/******************************************************************************/ - -/* DEFINES ********************************************************************/ -/******************************************************************************/ - -/* GLOBALS ********************************************************************/ -/******************************************************************************/ - -/* PROTOTYPES *****************************************************************/ -int ft_to_sngss7_activate_all(void); - -static int ftmod_ss7_enable_isap(int suId); -static int ftmod_ss7_enable_nsap(int suId); -static int ftmod_ss7_enable_mtpLinkSet(int lnkSetId); - - -/******************************************************************************/ - -/* FUNCTIONS ******************************************************************/ -int ft_to_sngss7_activate_all(void) -{ - int x; - - x = 1; - while (x < (MAX_ISAPS)) { - /* check if this link has already been actived */ - if ((g_ftdm_sngss7_data.cfg.isap[x].id != 0) && - (!(g_ftdm_sngss7_data.cfg.isap[x].flags & SNGSS7_ACTIVE))) { - - if (ftmod_ss7_enable_isap(x)) { - SS7_CRITICAL("ISAP %d Enable: NOT OK\n", x); - return 1; - } else { - SS7_INFO("ISAP %d Enable: OK\n", x); - } - - /* set the SNGSS7_ACTIVE flag */ - g_ftdm_sngss7_data.cfg.isap[x].flags |= SNGSS7_ACTIVE; - } /* if !SNGSS7_ACTIVE */ - - x++; - } /* while (x < (MAX_ISAPS)) */ - - if(SNG_SS7_OPR_MODE_M2UA_SG != g_ftdm_operating_mode){ - x = 1; - while (x < (MAX_NSAPS)) { - /* check if this link has already been actived */ - if ((g_ftdm_sngss7_data.cfg.nsap[x].id != 0) && - (!(g_ftdm_sngss7_data.cfg.nsap[x].flags & SNGSS7_ACTIVE))) { - - if (ftmod_ss7_enable_nsap(x)) { - SS7_CRITICAL("NSAP %d Enable: NOT OK\n", x); - return 1; - } else { - SS7_INFO("NSAP %d Enable: OK\n", x); - } - - /* set the SNGSS7_ACTIVE flag */ - g_ftdm_sngss7_data.cfg.nsap[x].flags |= SNGSS7_ACTIVE; - } /* if !SNGSS7_ACTIVE */ - - x++; - } /* while (x < (MAX_NSAPS)) */ - - if (g_ftdm_sngss7_data.cfg.mtpRoute[1].id != 0) { - x = 1; - while (x < (MAX_MTP_LINKSETS+1)) { - /* check if this link has already been actived */ - if ((g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) && - (!(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].flags & SNGSS7_ACTIVE))) { - - if (ftmod_ss7_enable_mtpLinkSet(x)) { - SS7_CRITICAL("LinkSet \"%s\" Enable: NOT OK\n", g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name); - return 1; - } else { - SS7_INFO("LinkSet \"%s\" Enable: OK\n", g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name); - } - - /* set the SNGSS7_ACTIVE flag */ - g_ftdm_sngss7_data.cfg.mtpLinkSet[x].flags |= SNGSS7_ACTIVE; - } /* if !SNGSS7_ACTIVE */ - - x++; - } /* while (x < (MAX_MTP_LINKSETS+1)) */ - } - } - - if(SNG_SS7_OPR_MODE_M2UA_SG == g_ftdm_operating_mode){ - return ftmod_ss7_m2ua_start(); - } - - return 0; -} - -/******************************************************************************/ -static int ftmod_ss7_enable_isap(int suId) -{ - CcMngmt cntrl; - Pst pst; - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTCC; - - /* initalize the control structure */ - memset(&cntrl, 0x0, sizeof(CcMngmt)); - - /* initalize the control header */ - smHdrInit(&cntrl.hdr); - - cntrl.hdr.msgType = TCNTRL; /* this is a control request */ - cntrl.hdr.entId.ent = ENTCC; - cntrl.hdr.entId.inst = S_INST; - cntrl.hdr.elmId.elmnt = STISAP; - - cntrl.hdr.elmId.elmntInst1 = suId; /* this is the SAP to bind */ - - cntrl.t.cntrl.action = ABND_ENA; /* bind and activate */ - cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */ - - return (sng_cntrl_cc(&pst, &cntrl)); -} - -/******************************************************************************/ -static int ftmod_ss7_enable_nsap(int suId) -{ - SiMngmt cntrl; - Pst pst; - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSI; - - /* initalize the control structure */ - memset(&cntrl, 0x0, sizeof(SiMngmt)); - - /* initalize the control header */ - smHdrInit(&cntrl.hdr); - - cntrl.hdr.msgType = TCNTRL; /* this is a control request */ - cntrl.hdr.entId.ent = ENTSI; - cntrl.hdr.entId.inst = S_INST; - cntrl.hdr.elmId.elmnt = STNSAP; - - cntrl.t.cntrl.s.siElmnt.elmntId.sapId = suId; - cntrl.t.cntrl.s.siElmnt.elmntParam.nsap.nsapType = SAP_MTP; - - - cntrl.t.cntrl.action = ABND_ENA; /* bind and activate */ - cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */ - - return (sng_cntrl_isup(&pst, &cntrl)); -} - -/******************************************************************************/ -static int ftmod_ss7_enable_mtpLinkSet(int lnkSetId) -{ - SnMngmt cntrl; - Pst pst; - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSN; - - /* initalize the control structure */ - memset(&cntrl, 0x0, sizeof(SnMngmt)); - - /* initalize the control header */ - smHdrInit(&cntrl.hdr); - - cntrl.hdr.msgType = TCNTRL; /* this is a control request */ - cntrl.hdr.entId.ent = ENTSN; - cntrl.hdr.entId.inst = S_INST; - cntrl.hdr.elmId.elmnt = STLNKSET; - cntrl.hdr.elmId.elmntInst1 = lnkSetId; /* this is the linkset to bind */ - - cntrl.t.cntrl.action = ABND_ENA; /* bind and activate */ - cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */ - - return (sng_cntrl_mtp3(&pst, &cntrl)); -} - -/******************************************************************************/ -int ftmod_ss7_inhibit_mtp3link(uint32_t id) -{ - SnMngmt cntrl; - Pst pst; - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSN; - - /* initalize the control structure */ - memset(&cntrl, 0x0, sizeof(SnMngmt)); - - /* initalize the control header */ - smHdrInit(&cntrl.hdr); - - cntrl.hdr.msgType = TCNTRL; /* this is a control request */ - cntrl.hdr.entId.ent = ENTSN; - cntrl.hdr.entId.inst = S_INST; - cntrl.hdr.elmId.elmnt = STDLSAP; - cntrl.hdr.elmId.elmntInst1 = id; /* the DSLAP to inhibit */ - - cntrl.t.cntrl.action = AINH; /* Inhibit */ - cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */ - - return (sng_cntrl_mtp3(&pst, &cntrl)); -} - -/******************************************************************************/ -int ftmod_ss7_uninhibit_mtp3link(uint32_t id) -{ - SnMngmt cntrl; - Pst pst; - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSN; - - /* initalize the control structure */ - memset(&cntrl, 0x0, sizeof(SnMngmt)); - - /* initalize the control header */ - smHdrInit(&cntrl.hdr); - - cntrl.hdr.msgType = TCNTRL; /* this is a control request */ - cntrl.hdr.entId.ent = ENTSN; - cntrl.hdr.entId.inst = S_INST; - cntrl.hdr.elmId.elmnt = STDLSAP; - cntrl.hdr.elmId.elmntInst1 = id; /* the DSLAP to inhibit */ - - cntrl.t.cntrl.action = AUNINH; /* Inhibit */ - cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */ - - return (sng_cntrl_mtp3(&pst, &cntrl)); -} - -/******************************************************************************/ -int ftmod_ss7_bind_mtp3link(uint32_t id) -{ - SnMngmt cntrl; - Pst pst; - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSN; - - /* initalize the control structure */ - memset(&cntrl, 0x0, sizeof(SnMngmt)); - - /* initalize the control header */ - smHdrInit(&cntrl.hdr); - - cntrl.hdr.msgType = TCNTRL; /* this is a control request */ - cntrl.hdr.entId.ent = ENTSN; - cntrl.hdr.entId.inst = S_INST; - cntrl.hdr.elmId.elmnt = STDLSAP; - cntrl.hdr.elmId.elmntInst1 = g_ftdm_sngss7_data.cfg.mtp3Link[id].id; - - cntrl.t.cntrl.action = ABND; /* Activate */ - cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */ - - return (sng_cntrl_mtp3(&pst, &cntrl)); -} - -/******************************************************************************/ -int ftmod_ss7_unbind_mtp3link(uint32_t id) -{ - SnMngmt cntrl; - Pst pst; - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSN; - - /* initalize the control structure */ - memset(&cntrl, 0x0, sizeof(SnMngmt)); - - /* initalize the control header */ - smHdrInit(&cntrl.hdr); - - cntrl.hdr.msgType = TCNTRL; /* this is a control request */ - cntrl.hdr.entId.ent = ENTSN; - cntrl.hdr.entId.inst = S_INST; - cntrl.hdr.elmId.elmnt = STDLSAP; - cntrl.hdr.elmId.elmntInst1 = g_ftdm_sngss7_data.cfg.mtp3Link[id].id; - - cntrl.t.cntrl.action = AUBND_DIS; /* unbind and disable */ - cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */ - - return (sng_cntrl_mtp3(&pst, &cntrl)); -} - -/******************************************************************************/ -int ftmod_ss7_activate_mtp3link(uint32_t id) -{ - SnMngmt cntrl; - Pst pst; - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSN; - - /* initalize the control structure */ - memset(&cntrl, 0x0, sizeof(SnMngmt)); - - /* initalize the control header */ - smHdrInit(&cntrl.hdr); - - cntrl.hdr.msgType = TCNTRL; /* this is a control request */ - cntrl.hdr.entId.ent = ENTSN; - cntrl.hdr.entId.inst = S_INST; - cntrl.hdr.elmId.elmnt = STDLSAP; - cntrl.hdr.elmId.elmntInst1 = g_ftdm_sngss7_data.cfg.mtp3Link[id].id; - - cntrl.t.cntrl.action = AENA; /* Activate */ - cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */ - - return (sng_cntrl_mtp3(&pst, &cntrl)); -} - -/******************************************************************************/ -int ftmod_ss7_deactivate_mtp3link(uint32_t id) -{ - SnMngmt cntrl; - Pst pst; - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSN; - - /* initalize the control structure */ - memset(&cntrl, 0x0, sizeof(SnMngmt)); - - /* initalize the control header */ - smHdrInit(&cntrl.hdr); - - cntrl.hdr.msgType = TCNTRL; /* this is a control request */ - cntrl.hdr.entId.ent = ENTSN; - cntrl.hdr.entId.inst = S_INST; - cntrl.hdr.elmId.elmnt = STDLSAP; - cntrl.hdr.elmId.elmntInst1 = g_ftdm_sngss7_data.cfg.mtp3Link[id].id; - - cntrl.t.cntrl.action = ADISIMM; /* Deactivate */ - cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */ - - return (sng_cntrl_mtp3(&pst, &cntrl)); -} - -/******************************************************************************/ -int ftmod_ss7_deactivate2_mtp3link(uint32_t id) -{ - SnMngmt cntrl; - Pst pst; - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSN; - - /* initalize the control structure */ - memset(&cntrl, 0x0, sizeof(SnMngmt)); - - /* initalize the control header */ - smHdrInit(&cntrl.hdr); - - cntrl.hdr.msgType = TCNTRL; /* this is a control request */ - cntrl.hdr.entId.ent = ENTSN; - cntrl.hdr.entId.inst = S_INST; - cntrl.hdr.elmId.elmnt = STDLSAP; - cntrl.hdr.elmId.elmntInst1 = g_ftdm_sngss7_data.cfg.mtp3Link[id].id; - - cntrl.t.cntrl.action = ADISIMM_L2; /* Deactivate...layer 2 only */ - cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */ - - return (sng_cntrl_mtp3(&pst, &cntrl)); -} - -/******************************************************************************/ -int ftmod_ss7_activate_mtplinkSet(uint32_t id) -{ - SnMngmt cntrl; - Pst pst; - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSN; - - /* initalize the control structure */ - memset(&cntrl, 0x0, sizeof(SnMngmt)); - - /* initalize the control header */ - smHdrInit(&cntrl.hdr); - - cntrl.hdr.msgType = TCNTRL; /* this is a control request */ - cntrl.hdr.entId.ent = ENTSN; - cntrl.hdr.entId.inst = S_INST; - cntrl.hdr.elmId.elmnt = STLNKSET; - cntrl.hdr.elmId.elmntInst1 = g_ftdm_sngss7_data.cfg.mtpLinkSet[id].id; - - cntrl.t.cntrl.action = AACTLNKSET; /* Activate */ - cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */ - - return (sng_cntrl_mtp3(&pst, &cntrl)); -} - -/******************************************************************************/ -int ftmod_ss7_deactivate_mtplinkSet(uint32_t id) -{ - SnMngmt cntrl; - Pst pst; - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSN; - - /* initalize the control structure */ - memset(&cntrl, 0x0, sizeof(SnMngmt)); - - /* initalize the control header */ - smHdrInit(&cntrl.hdr); - - cntrl.hdr.msgType = TCNTRL; /* this is a control request */ - cntrl.hdr.entId.ent = ENTSN; - cntrl.hdr.entId.inst = S_INST; - cntrl.hdr.elmId.elmnt = STLNKSET; - cntrl.hdr.elmId.elmntInst1 = g_ftdm_sngss7_data.cfg.mtpLinkSet[id].id; - - cntrl.t.cntrl.action = ADEACTLNKSET; /* Activate */ - cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */ - - return (sng_cntrl_mtp3(&pst, &cntrl)); -} - -/******************************************************************************/ -int ftmod_ss7_deactivate2_mtplinkSet(uint32_t id) -{ - SnMngmt cntrl; - Pst pst; - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSN; - - /* initalize the control structure */ - memset(&cntrl, 0x0, sizeof(SnMngmt)); - - /* initalize the control header */ - smHdrInit(&cntrl.hdr); - - cntrl.hdr.msgType = TCNTRL; /* this is a control request */ - cntrl.hdr.entId.ent = ENTSN; - cntrl.hdr.entId.inst = S_INST; - cntrl.hdr.elmId.elmnt = STLNKSET; - cntrl.hdr.elmId.elmntInst1 = g_ftdm_sngss7_data.cfg.mtpLinkSet[id].id; - - cntrl.t.cntrl.action = ADEACTLNKSET_L2; /* Activate */ - cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */ - - return (sng_cntrl_mtp3(&pst, &cntrl)); -} - -/******************************************************************************/ -int ftmod_ss7_lpo_mtp3link(uint32_t id) -{ - SnMngmt cntrl; - Pst pst; - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSN; - - /* initalize the control structure */ - memset(&cntrl, 0x0, sizeof(SnMngmt)); - - /* initalize the control header */ - smHdrInit(&cntrl.hdr); - - cntrl.hdr.msgType = TCNTRL; /* this is a control request */ - cntrl.hdr.entId.ent = ENTSN; - cntrl.hdr.entId.inst = S_INST; - cntrl.hdr.elmId.elmnt = STDLSAP; - cntrl.hdr.elmId.elmntInst1 = g_ftdm_sngss7_data.cfg.mtp3Link[id].id; - - cntrl.t.cntrl.action = ACTION_LPO; /* Activate */ - cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */ - - return (sng_cntrl_mtp3(&pst, &cntrl)); -} - -/******************************************************************************/ -int ftmod_ss7_lpr_mtp3link(uint32_t id) -{ - SnMngmt cntrl; - Pst pst; - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSN; - - /* initalize the control structure */ - memset(&cntrl, 0x0, sizeof(SnMngmt)); - - /* initalize the control header */ - smHdrInit(&cntrl.hdr); - - cntrl.hdr.msgType = TCNTRL; /* this is a control request */ - cntrl.hdr.entId.ent = ENTSN; - cntrl.hdr.entId.inst = S_INST; - cntrl.hdr.elmId.elmnt = STDLSAP; - cntrl.hdr.elmId.elmntInst1 = g_ftdm_sngss7_data.cfg.mtp3Link[id].id; - - cntrl.t.cntrl.action = ACTION_LPR; /* Activate */ - cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */ - - return (sng_cntrl_mtp3(&pst, &cntrl)); -} - -/******************************************************************************/ -int ftmod_ss7_shutdown_isup(void) -{ - SiMngmt cntrl; - Pst pst; - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSI; - - /* initalize the control structure */ - memset(&cntrl, 0x0, sizeof(SiMngmt)); - - /* initalize the control header */ - smHdrInit(&cntrl.hdr); - - cntrl.hdr.msgType = TCNTRL; /* this is a control request */ - cntrl.hdr.entId.ent = ENTSI; - cntrl.hdr.entId.inst = S_INST; - cntrl.hdr.elmId.elmnt = STGEN; - - cntrl.t.cntrl.action = ASHUTDOWN; /* shutdown */ - cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */ - - return (sng_cntrl_isup(&pst, &cntrl)); -} - -/******************************************************************************/ -int ftmod_ss7_shutdown_mtp3(void) -{ - SnMngmt cntrl; - Pst pst; - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSN; - - /* initalize the control structure */ - memset(&cntrl, 0x0, sizeof(SnMngmt)); - - /* initalize the control header */ - smHdrInit(&cntrl.hdr); - - cntrl.hdr.msgType = TCNTRL; /* this is a control request */ - cntrl.hdr.entId.ent = ENTSN; - cntrl.hdr.entId.inst = S_INST; - cntrl.hdr.elmId.elmnt = STGEN; - - cntrl.t.cntrl.action = ASHUTDOWN; /* Activate */ - cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */ - - return (sng_cntrl_mtp3(&pst, &cntrl)); -} - -/******************************************************************************/ -int ftmod_ss7_shutdown_mtp2(void) -{ - SdMngmt cntrl; - Pst pst; - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSD; - - /* initalize the control structure */ - memset(&cntrl, 0x0, sizeof(SdMngmt)); - - /* initalize the control header */ - smHdrInit(&cntrl.hdr); - - cntrl.hdr.msgType = TCNTRL; /* this is a control request */ - cntrl.hdr.entId.ent = ENTSD; - cntrl.hdr.entId.inst = S_INST; - cntrl.hdr.elmId.elmnt = STGEN; - - cntrl.t.cntrl.action = ASHUTDOWN; /* Activate */ - cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */ - - return (sng_cntrl_mtp2(&pst, &cntrl)); -} - -/******************************************************************************/ -int ftmod_ss7_shutdown_relay(void) -{ - RyMngmt cntrl; - Pst pst; - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTRY; - - /* initalize the control structure */ - memset(&cntrl, 0x0, sizeof(RyMngmt)); - - /* initalize the control header */ - smHdrInit(&cntrl.hdr); - - cntrl.hdr.msgType = TCNTRL; /* this is a control request */ - cntrl.hdr.entId.ent = ENTRY; - cntrl.hdr.entId.inst = S_INST; - cntrl.hdr.elmId.elmnt = STGEN; - - cntrl.t.cntrl.action = ASHUTDOWN; /* Activate */ - cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */ - - return (sng_cntrl_relay(&pst, &cntrl)); -} - -/******************************************************************************/ -int ftmod_ss7_disable_relay_channel(uint32_t chanId) -{ - RyMngmt cntrl; - Pst pst; - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTRY; - - /* initalize the control structure */ - memset(&cntrl, 0x0, sizeof(RyMngmt)); - - /* initalize the control header */ - smHdrInit(&cntrl.hdr); - - cntrl.hdr.msgType = TCNTRL; /* this is a control request */ - cntrl.hdr.entId.ent = ENTRY; - cntrl.hdr.entId.inst = S_INST; - cntrl.hdr.elmId.elmnt = STGEN; - - - cntrl.hdr.elmId.elmntInst1 = chanId; - - cntrl.t.cntrl.action = ADISIMM; /* Deactivate */ - cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */ - - return (sng_cntrl_relay(&pst, &cntrl)); -} - -/******************************************************************************/ -int ftmod_ss7_disable_grp_mtp3Link(uint32_t procId) -{ - SnMngmt cntrl; - Pst pst; - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSN; - - /* initalize the control structure */ - memset(&cntrl, 0x0, sizeof(SnMngmt)); - - /* initalize the control header */ - smHdrInit(&cntrl.hdr); - - cntrl.hdr.msgType = TCNTRL; /* this is a control request */ - cntrl.hdr.entId.ent = ENTSN; - cntrl.hdr.entId.inst = S_INST; - cntrl.hdr.elmId.elmnt = STGRDLSAP; /* group DLSAP */ - - cntrl.t.cntrl.ctlType.groupKey.dstProcId = procId; /* all SAPS to this ProcId */ - - cntrl.t.cntrl.action = AUBND_DIS; /* disable and unbind */ - cntrl.t.cntrl.subAction = SAGR_DSTPROCID; /* specificed element */ - - if (g_ftdm_sngss7_data.cfg.procId == procId) { - SS7_DEBUG("Executing MTP3 cntrl command local pid =%i\n",procId); - return (sng_cntrl_mtp3(&pst, &cntrl)); - } else { - SS7_WARN("Executing MTP3 cntrl command different local=%i target=%i\n", - g_ftdm_sngss7_data.cfg.procId,procId); - return (sng_cntrl_mtp3_nowait(&pst, &cntrl)); - } - -} - -/******************************************************************************/ -int ftmod_ss7_enable_grp_mtp3Link(uint32_t procId) -{ - SnMngmt cntrl; - Pst pst; - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSN; - - /* initalize the control structure */ - memset(&cntrl, 0x0, sizeof(SnMngmt)); - - /* initalize the control header */ - smHdrInit(&cntrl.hdr); - - cntrl.hdr.msgType = TCNTRL; /* this is a control request */ - cntrl.hdr.entId.ent = ENTSN; - cntrl.hdr.entId.inst = S_INST; - cntrl.hdr.elmId.elmnt = STGRDLSAP; /* group DLSAP */ - - cntrl.t.cntrl.ctlType.groupKey.dstProcId = procId; /* all SAPS to this ProcId */ - - cntrl.t.cntrl.action = ABND_ENA; /* bind and enable */ - cntrl.t.cntrl.subAction = SAGR_DSTPROCID; /* specificed element */ - - if (g_ftdm_sngss7_data.cfg.procId == procId) { - SS7_DEBUG("Executing MTP3 cntrl command local pid =%i\n",procId); - return (sng_cntrl_mtp3(&pst, &cntrl)); - } else { - SS7_WARN("Executing MTP3 cntrl command different local=%i target=%i\n", - g_ftdm_sngss7_data.cfg.procId,procId); - return (sng_cntrl_mtp3_nowait(&pst, &cntrl)); - } - -} - -/******************************************************************************/ -int ftmod_ss7_disable_grp_mtp2Link(uint32_t procId) -{ - SdMngmt cntrl; - Pst pst; - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSD; - - /* initalize the control structure */ - memset(&cntrl, 0x0, sizeof(cntrl)); - - /* initalize the control header */ - smHdrInit(&cntrl.hdr); - - cntrl.hdr.msgType = TCNTRL; /* this is a control request */ - cntrl.hdr.entId.ent = ENTSD; - cntrl.hdr.entId.inst = S_INST; - cntrl.hdr.elmId.elmnt = STGRNSAP; /* group NSAP */ - - cntrl.t.cntrl.par.dstProcId = procId; /* all SAPS to this ProcId */ - - cntrl.t.cntrl.action = AUBND_DIS; /* disable and unbind */ - cntrl.t.cntrl.subAction = SAGR_DSTPROCID; /* specificed element */ - - return (sng_cntrl_mtp2(&pst, &cntrl)); - -} - -/******************************************************************************/ -int __ftmod_ss7_block_isup_ckt(uint32_t cktId, ftdm_bool_t wait) -{ - SiMngmt cntrl; - Pst pst; - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSI; - - /* initalize the control structure */ - memset(&cntrl, 0x0, sizeof(SiMngmt)); - - /* initalize the control header */ - smHdrInit(&cntrl.hdr); - - cntrl.hdr.msgType = TCNTRL; /* this is a control request */ - cntrl.hdr.entId.ent = ENTSI; - cntrl.hdr.entId.inst = S_INST; - cntrl.hdr.elmId.elmnt = STICIR; - - cntrl.t.cntrl.s.siElmnt.elmntId.circuit = cktId; - cntrl.t.cntrl.s.siElmnt.elmntParam.cir.flag = LSI_CNTRL_CIR_FORCE; - - cntrl.t.cntrl.action = ADISIMM; /* block via BLO */ - cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */ - - if (wait == FTDM_TRUE) { - return (sng_cntrl_isup(&pst, &cntrl)); - } else { - return (sng_cntrl_isup_nowait(&pst, &cntrl)); - } -} - -/******************************************************************************/ -int ftmod_ss7_unblock_isup_ckt(uint32_t cktId) -{ - SiMngmt cntrl; - Pst pst; - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSI; - - /* initalize the control structure */ - memset(&cntrl, 0x0, sizeof(SiMngmt)); - - /* initalize the control header */ - smHdrInit(&cntrl.hdr); - - cntrl.hdr.msgType = TCNTRL; /* this is a control request */ - cntrl.hdr.entId.ent = ENTSI; - cntrl.hdr.entId.inst = S_INST; - cntrl.hdr.elmId.elmnt = STICIR; - - cntrl.t.cntrl.s.siElmnt.elmntId.circuit = cktId; - cntrl.t.cntrl.s.siElmnt.elmntParam.cir.flag = LSI_CNTRL_CIR_FORCE; - - cntrl.t.cntrl.action = AENA; /* unblock via UBL */ - cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */ - - return (sng_cntrl_isup(&pst, &cntrl)); -} -/******************************************************************************/ -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ -/******************************************************************************/ - diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c deleted file mode 100644 index f120114667..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c +++ /dev/null @@ -1,2750 +0,0 @@ -/* - * Copyright (c) 2009 Konrad Hammel - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE|EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Contributors: - * - * Ricardo Barroetaveña - * James Zhang - * - */ - -/* INCLUDE ********************************************************************/ -#include "ftmod_sangoma_ss7_main.h" - -/******************************************************************************/ - -/* DEFINES ********************************************************************/ -/******************************************************************************/ - -/* GLOBALS ********************************************************************/ - -/******************************************************************************/ - -/* PROTOTYPES *****************************************************************/ -ftdm_status_t handle_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiConEvnt *siConEvnt); -ftdm_status_t handle_con_sta(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiCnStEvnt *siCnStEvnt, uint8_t evntType); -ftdm_status_t handle_con_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiConEvnt *siConEvnt); -ftdm_status_t handle_rel_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiRelEvnt *siRelEvnt); -ftdm_status_t handle_rel_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiRelEvnt *siRelEvnt); -ftdm_status_t handle_dat_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiInfoEvnt *siInfoEvnt); -ftdm_status_t handle_fac_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t evntType, SiFacEvnt *siFacEvnt); -ftdm_status_t handle_fac_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t evntType, SiFacEvnt *siFacEvnt); -ftdm_status_t handle_umsg_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit); -ftdm_status_t handle_susp_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiSuspEvnt *siSuspEvnt); -ftdm_status_t handle_resm_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiResmEvnt *siResmEvnt); -ftdm_status_t handle_sta_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); - -ftdm_status_t handle_reattempt(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -ftdm_status_t handle_pause(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -ftdm_status_t handle_resume(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -ftdm_status_t handle_cot_start(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -ftdm_status_t handle_cot_stop(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -ftdm_status_t handle_cot(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -ftdm_status_t handle_rsc_req(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -ftdm_status_t handle_local_rsc_req(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -ftdm_status_t handle_rsc_rsp(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -ftdm_status_t handle_grs_req(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -ftdm_status_t handle_grs_rsp(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -ftdm_status_t handle_blo_req(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -ftdm_status_t handle_blo_rsp(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -ftdm_status_t handle_ubl_req(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -ftdm_status_t handle_ubl_rsp(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -ftdm_status_t handle_local_blk(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -ftdm_status_t handle_local_ubl(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -ftdm_status_t handle_ucic(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -ftdm_status_t handle_cgb_req(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -ftdm_status_t handle_cgu_req(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -ftdm_status_t handle_olm_msg(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -/******************************************************************************/ - -/* FUNCTIONS ******************************************************************/ - -#define ftdm_running_return(var) if (!ftdm_running()) { SS7_ERROR("Error: ftdm_running is not set! Ignoring\n"); return var; } - -ftdm_status_t handle_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiConEvnt *siConEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = NULL; - ftdm_channel_t *ftdmchan = NULL; - char var[FTDM_DIGITS_LIMIT]; - - memset(var, '\0', sizeof(var)); - - ftdm_running_return(FTDM_FAIL); - - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - /* lock the channel */ - ftdm_mutex_lock(ftdmchan->mutex); - - if (sngss7_test_ckt_flag(sngss7_info, FLAG_GLARE)) { - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx IAM (glare)\n", sngss7_info->circuit->cic); - } - - /* check if the circuit has a remote block */ - if ((sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX)) || - (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX)) || - (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX))) { - - /* as per Q.764, 2.8.2.3 xiv ... remove the block from this channel */ - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX); - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX_DN); - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX); - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX_DN); - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX); - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX_DN); - - /* KONRAD FIX ME : check in case there is a ckt and grp block */ - } - - sngss7_clear_ckt_flag(sngss7_info, FLAG_INR_TX); - sngss7_clear_ckt_flag(sngss7_info, FLAG_INR_SENT); - sngss7_clear_ckt_flag(sngss7_info, FLAG_INR_RX); - sngss7_clear_ckt_flag(sngss7_info, FLAG_INR_RX_DN); - sngss7_clear_ckt_flag(sngss7_info, FLAG_INF_TX); - sngss7_clear_ckt_flag(sngss7_info, FLAG_INF_SENT); - sngss7_clear_ckt_flag(sngss7_info, FLAG_INF_RX); - sngss7_clear_ckt_flag(sngss7_info, FLAG_INF_RX_DN); - sngss7_clear_ckt_flag(sngss7_info, FLAG_FULL_NUMBER); - - /* check whether the ftdm channel is in a state to accept a call */ - switch (ftdmchan->state) { - /**************************************************************************/ - case (FTDM_CHANNEL_STATE_DOWN): /* only state it is valid to get IAM (except if there is glare */ - - /* check if there is any reason why we can't use this channel */ - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_INUSE)) { - /* channel is already requested for use by the ftdm core */ - goto handle_glare; - } else if(ftdm_channel_open_chan(ftdmchan) != FTDM_SUCCESS) { - /* channel is not inuse but we can't open it...fail the call */ - SS7_ERROR("Failed to open span: %d, chan: %d\n", - ftdmchan->physical_span_id, - ftdmchan->physical_chan_id); - - /* set the flag to indicate this hangup is started from the local side */ - sngss7_set_ckt_flag(sngss7_info, FLAG_LOCAL_REL); - - ftdmchan->caller_data.hangup_cause = 41; - - /* move the state to CANCEL */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_CANCEL); - - } else { - - /* fill in the channels SS7 Stack information */ - sngss7_info->suInstId = get_unique_id(); - sngss7_info->spInstId = spInstId; - - /* fill in calling party information */ - if (siConEvnt->cgPtyNum.eh.pres) { - if (siConEvnt->cgPtyNum.addrSig.pres) { - /* fill in cid_num */ - copy_tknStr_from_sngss7(siConEvnt->cgPtyNum.addrSig, - ftdmchan->caller_data.cid_num.digits, - siConEvnt->cgPtyNum.oddEven); - - /* fill in cid Name */ - ftdm_set_string(ftdmchan->caller_data.cid_name, ftdmchan->caller_data.cid_num.digits); - - /* fill in ANI */ - ftdm_set_string(ftdmchan->caller_data.ani.digits, ftdmchan->caller_data.cid_num.digits); - } - else { - if (g_ftdm_sngss7_data.cfg.force_inr) { - sngss7_set_ckt_flag(sngss7_info, FLAG_INR_TX); - sngss7_clear_ckt_flag(sngss7_info, FLAG_INR_SENT); - } - } - - if (siConEvnt->cgPtyNum.scrnInd.pres) { - /* fill in the screening indication value */ - ftdmchan->caller_data.screen = siConEvnt->cgPtyNum.scrnInd.val; - } - - if (siConEvnt->cgPtyNum.presRest.pres) { - /* fill in the presentation value */ - ftdmchan->caller_data.pres = siConEvnt->cgPtyNum.presRest.val; - } - } else { - if (g_ftdm_sngss7_data.cfg.force_inr) { - sngss7_set_ckt_flag(sngss7_info, FLAG_INR_TX); - sngss7_clear_ckt_flag(sngss7_info, FLAG_INR_SENT); - } - - SS7_INFO_CHAN(ftdmchan,"No Calling party (ANI) information in IAM!%s\n", " "); - } - - /* fill in called party infomation */ - if (siConEvnt->cdPtyNum.eh.pres) { - if (siConEvnt->cdPtyNum.addrSig.pres) { - /* fill in the called number/dnis */ - copy_tknStr_from_sngss7(siConEvnt->cdPtyNum.addrSig, - ftdmchan->caller_data.dnis.digits, - siConEvnt->cdPtyNum.oddEven); - } - } else { - SS7_INFO_CHAN(ftdmchan,"No Called party (DNIS) information in IAM!%s\n", " "); - } - copy_NatureOfConnection_from_sngss7(ftdmchan, &siConEvnt->natConInd); - copy_fwdCallInd_hex_from_sngss7(ftdmchan, &siConEvnt->fwdCallInd); - copy_access_transport_from_sngss7(ftdmchan, &siConEvnt->accTrnspt); - copy_ocn_from_sngss7(ftdmchan, &siConEvnt->origCdNum); - copy_redirgNum_from_sngss7(ftdmchan, &siConEvnt->redirgNum); - copy_redirgInfo_from_sngss7(ftdmchan, &siConEvnt->redirInfo); - copy_genNmb_from_sngss7(ftdmchan, &siConEvnt->genNmb); - - copy_cgPtyCat_from_sngss7(ftdmchan, &siConEvnt->cgPtyCat); - copy_cdPtyNum_from_sngss7(ftdmchan, &siConEvnt->cdPtyNum); - - /* fill in the TMR/bearer capability */ - if (siConEvnt->txMedReq.eh.pres) { - if (siConEvnt->txMedReq.trMedReq.pres) { - /* fill in the bearer type */ - ftdmchan->caller_data.bearer_capability = siConEvnt->txMedReq.trMedReq.val; - } - } else { - SS7_DEBUG_CHAN(ftdmchan,"No TMR/Bearer Cap information in IAM!%s\n", " "); - } - - /* add any special variables for the dialplan */ - sprintf(var, "%d", siConEvnt->cgPtyNum.natAddrInd.val); - sngss7_add_var(sngss7_info, "ss7_clg_nadi", var); - - /* Retrieve the Location Number if present (see ITU Q.763, 3.30) */ - if (siConEvnt->cgPtyNum1.eh.pres) { - if (siConEvnt->cgPtyNum1.addrSig.pres) { - /* fill in the ss7 location address number */ - copy_tknStr_from_sngss7(siConEvnt->cgPtyNum1.addrSig, var, siConEvnt->cgPtyNum1.oddEven); - sngss7_add_var(sngss7_info, "ss7_loc_digits", var); - } - - if (siConEvnt->cgPtyNum1.scrnInd.pres) { - /* fill in the screening indication value */ - sprintf(var, "%d", siConEvnt->cgPtyNum1.scrnInd.val); - sngss7_add_var(sngss7_info, "ss7_loc_screen_ind", var); - } - - if (siConEvnt->cgPtyNum1.presRest.pres) { - /* fill in the presentation value */ - sprintf(var, "%d", siConEvnt->cgPtyNum1.presRest.val); - sngss7_add_var(sngss7_info, "ss7_loc_pres_ind", var); - } - - if (siConEvnt->cgPtyNum1.natAddrInd.pres) { - sprintf(var, "%d", siConEvnt->cgPtyNum1.natAddrInd.val); - sngss7_add_var(sngss7_info, "ss7_loc_nadi", var); - } - } else { - SS7_DEBUG_CHAN(ftdmchan, "No Location Number information in IAM%s\n", " "); - } - - sprintf(var, "%d", sngss7_info->circuit->cic); - sngss7_add_var(sngss7_info, "ss7_cic", var); - - - sprintf(var, "%d", g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info->circuit->infId].dpc ); - sngss7_add_var(sngss7_info, "ss7_opc", var); - - if (siConEvnt->callRef.callId.pres) { - ftdmchan->caller_data.call_reference = (unsigned int)siConEvnt->callRef.callId.val; - } else { - ftdmchan->caller_data.call_reference = 0; - } - - if (sngss7_info->circuit->transparent_iam) { - sngss7_save_iam(ftdmchan, siConEvnt); - } - - /* check if a COT test is requested */ - if ((siConEvnt->natConInd.eh.pres) && - (siConEvnt->natConInd.contChkInd.pres) && - (siConEvnt->natConInd.contChkInd.val)) { - - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Found COT Request\n", sngss7_info->circuit->cic); - - /* tell the core to loop the channel */ - ftdm_channel_command(ftdmchan, FTDM_COMMAND_ENABLE_LOOP, NULL); - - /* move to in loop state */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_IN_LOOP); - } else { - /* set the state of the channel to collecting...the rest is done by the chan monitor */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_COLLECT); - } - - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx IAM clg = \"%s\" (NADI=%d), cld = \"%s\" (NADI=%d)\n", - sngss7_info->circuit->cic, - ftdmchan->caller_data.cid_num.digits, - siConEvnt->cgPtyNum.natAddrInd.val, - ftdmchan->caller_data.dnis.digits, - siConEvnt->cdPtyNum.natAddrInd.val); - } /* if (channel is usable */ - - break; - /**************************************************************************/ - case (FTDM_CHANNEL_STATE_DIALING): - case (FTDM_CHANNEL_STATE_TERMINATING): - case (FTDM_CHANNEL_STATE_HANGUP): - case (FTDM_CHANNEL_STATE_HANGUP_COMPLETE): -handle_glare: - /* the core already has plans for this channel...glare */ - SS7_INFO_CHAN(ftdmchan, "Got IAM on channel that is already inuse (state=%s|inuse=%c)...glare!\n", - ftdm_channel_state2str (ftdmchan->state), - ftdm_test_flag(ftdmchan, FTDM_CHANNEL_INUSE) ? 'Y' : 'N'); - - /* save the info so that we can use it later on */ - sngss7_info->glare.spInstId = spInstId; - sngss7_info->glare.circuit = circuit; - memcpy(&sngss7_info->glare.iam, siConEvnt, sizeof(*siConEvnt)); - - if (!(sngss7_test_ckt_flag(sngss7_info, FLAG_GLARE))) { - /* glare, throw the flag */ - sngss7_set_ckt_flag(sngss7_info, FLAG_GLARE); - - /* setup the hangup cause */ - ftdmchan->caller_data.hangup_cause = 34; /* Circuit Congrestion */ - - /* move the state of the channel to Terminating to end the call - in TERMINATING state, the release cause is set to REMOTE_REL - in any means. So we don't have to set the release reason here. - */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); - } - break; - /**************************************************************************/ - default: /* should not have gotten an IAM while in this state */ - SS7_ERROR_CHAN(ftdmchan, "Got IAM on channel in invalid state(%s)...reset!\n", ftdm_channel_state2str (ftdmchan->state)); - - /* throw the TX reset flag */ - if (!sngss7_tx_reset_status_pending(sngss7_info)) { - sngss7_tx_reset_restart(sngss7_info); - sngss7_set_ckt_flag (sngss7_info, FLAG_REMOTE_REL); - - /* go to RESTART */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RESTART); - } - break; - /**************************************************************************/ - } /* switch (ftdmchan->state) */ - - /* unlock the channel */ - ftdm_mutex_unlock(ftdmchan->mutex); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t handle_con_sta(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiCnStEvnt *siCnStEvnt, uint8_t evntType) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info ; - ftdm_channel_t *ftdmchan; - - ftdm_running_return(FTDM_FAIL); - - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - /* lock the channel */ - ftdm_mutex_lock(ftdmchan->mutex); - - switch (evntType) { - /**************************************************************************/ - case (ADDRCMPLT): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx ACM\n", sngss7_info->circuit->cic); - - switch (ftdmchan->state) { - /**********************************************************************/ - case FTDM_CHANNEL_STATE_DIALING: - /* KONRAD: should we confirm the instance ids ? */ - - /* need to grab the sp instance id */ - sngss7_info->spInstId = spInstId; - - if ((siCnStEvnt->optBckCalInd.eh.pres) && - (siCnStEvnt->optBckCalInd.inbndInfoInd.pres)) { - - if (siCnStEvnt->optBckCalInd.inbndInfoInd.val) { - /* go to PROGRESS_MEDIA */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA); - } else { - /* go to PROGRESS */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_PROGRESS); - } /* if (inband) */ - } else { - /* go to PROGRESS_MEDIA */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA); - } - - break; - /**********************************************************************/ - default: /* incorrect state...reset the CIC */ - SS7_ERROR_CHAN(ftdmchan, "RX ACM in invalid state :%s...resetting CIC\n", - ftdm_channel_state2str (ftdmchan->state)); - - /* throw the TX reset flag */ - if (!sngss7_tx_reset_status_pending(sngss7_info)) { - sngss7_tx_reset_restart(sngss7_info); - sngss7_set_ckt_flag (sngss7_info, FLAG_REMOTE_REL); - - /* go to RESTART */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RESTART); - } - break; - /**********************************************************************/ - } /* switch (ftdmchan->state) */ - - break; - /**************************************************************************/ - case (MODIFY): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx MODIFY\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (MODCMPLT): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx MODIFY-COMPLETE\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (MODREJ): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx MODIFY-REJECT\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (PROGRESS): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx CPG\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (FRWDTRSFR): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx FOT\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (INFORMATION): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx INF\n", sngss7_info->circuit->cic); - - SS7_DEBUG_CHAN (ftdmchan, "Cancelling T.39 timer %s\n", " "); - /* check if t39 is active */ - if (sngss7_info->t39.hb_timer_id) { - ftdm_sched_cancel_timer (sngss7_info->t39.sched, sngss7_info->t39.hb_timer_id); - SS7_DEBUG_CHAN (ftdmchan, "T.39 timer has been cancelled upon receiving INF message %s\n", " "); - } - - sngss7_set_ckt_flag(sngss7_info, FLAG_INF_RX_DN); - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_IDLE); - - break; - /**************************************************************************/ - case (INFORMATREQ): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx INR\n", sngss7_info->circuit->cic); - - ft_to_sngss7_inf(ftdmchan, siCnStEvnt); - - sngss7_set_ckt_flag(sngss7_info, FLAG_INR_RX); - - break; - /**************************************************************************/ - case (SUBSADDR): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx SAM\n", sngss7_info->circuit->cic); - - /* check the channel state */ - switch (ftdmchan->state) { - /**********************************************************************/ - case (FTDM_CHANNEL_STATE_COLLECT): - - /* confirm that the event contains the subsquent number field */ - if (siCnStEvnt->subNum.eh.pres && siCnStEvnt->subNum.addrSig.pres) { - /* add the digits to the ftdm channel variable */ - append_tknStr_from_sngss7(siCnStEvnt->subNum.addrSig, - ftdmchan->caller_data.dnis.digits, - siCnStEvnt->subNum.oddEven); - SS7_DEBUG_CHAN(ftdmchan,"[CIC:%d]Rx SAM (digits = %s)\n", sngss7_info->circuit->cic, - ftdmchan->caller_data.dnis.digits); - } else { - SS7_INFO_CHAN(ftdmchan,"No Called party (DNIS) information in SAM!%s\n", " "); - } - - /* go to idle so that collect state is processed again */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_IDLE); - - break; - /**********************************************************************/ - default: - SS7_ERROR_CHAN(ftdmchan, "RX SAM in invalid state :%s...ignoring\n", - ftdm_channel_state2str (ftdmchan->state)); - break; - /**********************************************************************/ - } /* switch (ftdmchan->state) */ - - break; - /**************************************************************************/ - case (EXIT): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx EXIT\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (NETRESMGT): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx NRM\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (IDENTREQ): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx IDR\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (IDENTRSP): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx IRS\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (MALCLLPRNT): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx MALICIOUS CALL\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (CHARGE): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx CRG\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (TRFFCHGE): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx CRG-TARIFF\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (CHARGEACK): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx CRG-ACK\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (CALLOFFMSG): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx CALL-OFFER\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (LOOPPRVNT): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx LOP\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (TECT_TIMEOUT): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx ECT-Timeout\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (RINGSEND): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx RINGING-SEND\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (CALLCLEAR): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx CALL-LINE Clear\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (PRERELEASE): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx PRI\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (APPTRANSPORT): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx APM\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (OPERATOR): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx OPERATOR\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (METPULSE): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx METERING-PULSE\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (CLGPTCLR): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx CALLING_PARTY_CLEAR\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (SUBDIRNUM): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx SUB-DIR\n", sngss7_info->circuit->cic); - break; -#ifdef SANGOMA_SPIROU - case (CHARGE_ACK): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx TXA\n", sngss7_info->circuit->cic); - break; - case (CHARGE_UNIT): - { - uint32_t charging_unit = 0; - uint32_t msg_num = 0; - char val[3]; - - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx ITX\n", sngss7_info->circuit->cic); - - memset(val, '\0', sizeof(val)); - - if (siCnStEvnt->chargUnitNum.eh.pres == PRSNT_NODEF && - siCnStEvnt->chargUnitNum.chargUnitNum.pres == PRSNT_NODEF) { - - charging_unit = siCnStEvnt->chargUnitNum.chargUnitNum.val; - } - - if (siCnStEvnt->msgNum.eh.pres == PRSNT_NODEF && - siCnStEvnt->msgNum.msgNum.pres == PRSNT_NODEF) { - - msg_num = siCnStEvnt->msgNum.msgNum.val; - } - - ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Charging Unit:%d Msg Num:%d\n", charging_unit, msg_num); - - sprintf(val, "%d", charging_unit); - sngss7_add_var(sngss7_info, "ss7_itx_charge_unit", val); - - sprintf(val, "%d", msg_num); - sngss7_add_var(sngss7_info, "ss7_itx_msg_num", val); - - if (sngss7_info->circuit->itx_auto_reply) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_INFO, "Auto-reply with TXA msg\n"); - ft_to_sngss7_txa (ftdmchan); - } - } - break; -#endif - /**************************************************************************/ - default: - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx Unknown Msg\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - } - - /* unlock the channel */ - ftdm_mutex_unlock(ftdmchan->mutex); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t handle_con_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiConEvnt *siConEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info ; - ftdm_channel_t *ftdmchan; - - ftdm_running_return(FTDM_FAIL); - - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - /* lock the channel */ - ftdm_mutex_lock(ftdmchan->mutex); - - /* check whether the ftdm channel is in a state to accept a call */ - switch (ftdmchan->state) { - /**************************************************************************/ - case FTDM_CHANNEL_STATE_PROGRESS: - case FTDM_CHANNEL_STATE_PROGRESS_MEDIA: - - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx ANM\n", sngss7_info->circuit->cic); - - /* go to UP */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_UP); - - break; - /**************************************************************************/ - case FTDM_CHANNEL_STATE_DIALING: - - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx CON\n", sngss7_info->circuit->cic); - - /* go to UP */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_UP); - - break; - /**************************************************************************/ - case FTDM_CHANNEL_STATE_HANGUP_COMPLETE: - - /* already hangup complete, just ignore it */ - /* - * i.e. collision REL & ANM - * IAM -> - * <- ACM - * REL -> <- ANM (if REL gets processed first, ANM needs to be ignored) - * <- RLC - */ - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx ANM/CON Ignoring it because we already hung up\n", sngss7_info->circuit->cic); - - break; - /**************************************************************************/ - default: /* incorrect state...reset the CIC */ - - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx ANM/CON\n", sngss7_info->circuit->cic); - - /* throw the TX reset flag */ - if (!sngss7_tx_reset_status_pending(sngss7_info)) { - sngss7_tx_reset_restart(sngss7_info); - sngss7_set_ckt_flag (sngss7_info, FLAG_REMOTE_REL); - - /* go to RESTART */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RESTART); - } - - break; - /**************************************************************************/ - } - - /* unlock the channel */ - ftdm_mutex_unlock(ftdmchan->mutex); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t handle_rel_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiRelEvnt *siRelEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info ; - ftdm_channel_t *ftdmchan; - - ftdm_running_return(FTDM_FAIL); - - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - /* lock the channel */ - ftdm_mutex_lock(ftdmchan->mutex); - - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx REL cause=%d\n", - sngss7_info->circuit->cic, - siRelEvnt->causeDgn.causeVal.val); - - /* check whether the ftdm channel is in a state to release a call */ - switch (ftdmchan->state) { - /**************************************************************************/ - case FTDM_CHANNEL_STATE_DIALING: - - /* pass the release code up to FTDM */ - if (siRelEvnt->causeDgn.causeVal.pres) { - ftdmchan->caller_data.hangup_cause = siRelEvnt->causeDgn.causeVal.val; - } else { - SS7_ERROR("REL does not have a cause code!\n"); - ftdmchan->caller_data.hangup_cause = 0; - } - - /* this is a remote hangup request */ - sngss7_set_ckt_flag(sngss7_info, FLAG_REMOTE_REL); - ftdm_channel_command(ftdmchan, FTDM_COMMAND_DISABLE_LOOP, NULL); - /* move the state of the channel to CANCEL to end the call */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); - - break; - /**************************************************************************/ - case FTDM_CHANNEL_STATE_RING: - case FTDM_CHANNEL_STATE_RINGING: - case FTDM_CHANNEL_STATE_PROGRESS: - case FTDM_CHANNEL_STATE_PROGRESS_MEDIA: - case FTDM_CHANNEL_STATE_UP: - - /* pass the release code up to FTDM */ - if (siRelEvnt->causeDgn.causeVal.pres) { - ftdmchan->caller_data.hangup_cause = siRelEvnt->causeDgn.causeVal.val; - } else { - SS7_ERROR("REL does not have a cause ftdm_channel_command(ftdmchan, FTDM_COMMAND_DISABLE_LOOP, NULL);code!\n"); - ftdmchan->caller_data.hangup_cause = 0; - } - - /* this is a remote hangup request */ - sngss7_set_ckt_flag(sngss7_info, FLAG_REMOTE_REL); - - /* move the state of the channel to TERMINATING to end the call */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); - - break; - /**************************************************************************/ - case FTDM_CHANNEL_STATE_HANGUP_COMPLETE: - /* ITU Q.764 2.3.1 e) - * Collision of release messages - * - * ITU Q.784 Test Number 3.8 - * Collision of REL messages - */ - SS7_DEBUG_CHAN(ftdmchan, "Collision of REL messages. Rx REL while waiting for RLC.%s\n", " "); - if (sngss7_test_ckt_flag(sngss7_info, FLAG_LOCAL_REL) && - !sngss7_test_ckt_flag (sngss7_info, FLAG_REMOTE_REL)) { - /* locally requested hangup completed, wait for remote RLC */ - /* need to perform remote release */ - - /* this is also a remote hangup request */ - sngss7_set_ckt_flag(sngss7_info, FLAG_REMOTE_REL); - - /* send out the release complete */ - ft_to_sngss7_rlc (ftdmchan); - } else { - SS7_DEBUG_CHAN(ftdmchan, "Collision of REL messages - resetting state.%s\n", " "); - ft_to_sngss7_rlc (ftdmchan); - goto rel_ind_reset; - } - break; - /**************************************************************************/ - case FTDM_CHANNEL_STATE_IN_LOOP: - - /* inform the core to unloop the channel*/ - ftdm_channel_command(ftdmchan, FTDM_COMMAND_DISABLE_LOOP, NULL); - - /* since we need to acknowledge the hang up set the flag for remote release */ - sngss7_set_ckt_flag(sngss7_info, FLAG_REMOTE_REL); - - /* go to hangup complete to send the RLC */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_HANGUP_COMPLETE); - - /* save the call info for the RLC */ - sngss7_info->suInstId = get_unique_id(); - sngss7_info->spInstId = spInstId; - - break; - /**************************************************************************/ - default: - -rel_ind_reset: - /* throw the TX reset flag */ - if (!sngss7_tx_reset_status_pending(sngss7_info)) { - sngss7_set_ckt_flag (sngss7_info, FLAG_REMOTE_REL); - sngss7_tx_reset_restart(sngss7_info); - - /* go to RESTART */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RESTART); - } - break; - /**************************************************************************/ - } /* switch (ftdmchan->state) */ - - - /* unlock the channel */ - ftdm_mutex_unlock(ftdmchan->mutex); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t handle_rel_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiRelEvnt *siRelEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info ; - ftdm_channel_t *ftdmchan; - - ftdm_running_return(FTDM_FAIL); - - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - /* lock the channel */ - ftdm_mutex_lock(ftdmchan->mutex); - - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx RLC\n", sngss7_info->circuit->cic); - - /* check whether the ftdm channel is in a state to accept a call */ - switch (ftdmchan->state) { - /**************************************************************************/ - case FTDM_CHANNEL_STATE_HANGUP_COMPLETE: - - /* go to DOWN */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - - break; - /**************************************************************************/ - case FTDM_CHANNEL_STATE_DOWN: - /* do nothing, just drop the message */ - break; - /**************************************************************************/ - default: - /* KONRAD: should just stop the call...but a reset is easier for now (since it does hangup the call) */ - - /* go to RESTART */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RESTART); - - break; - /**************************************************************************/ - } - - /* unlock the channel */ - ftdm_mutex_unlock(ftdmchan->mutex); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t handle_dat_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiInfoEvnt *siInfoEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info ; - ftdm_channel_t *ftdmchan; - - ftdm_running_return(FTDM_FAIL); - - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - /* lock the channel */ - ftdm_mutex_lock(ftdmchan->mutex); - - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx DATA IND\n", sngss7_info->circuit->cic); - - /* unlock the channel */ - ftdm_mutex_unlock(ftdmchan->mutex); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t handle_fac_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t evntType, SiFacEvnt *siFacEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info ; - ftdm_channel_t *ftdmchan; - - ftdm_running_return(FTDM_FAIL); - - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - /* lock the channel */ - ftdm_mutex_lock(ftdmchan->mutex); - - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx FAC\n", sngss7_info->circuit->cic); - - /* unlock the channel */ - ftdm_mutex_unlock(ftdmchan->mutex); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t handle_fac_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t evntType, SiFacEvnt *siFacEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info ; - ftdm_channel_t *ftdmchan; - - ftdm_running_return(FTDM_FAIL); - - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - /* lock the channel */ - ftdm_mutex_lock(ftdmchan->mutex); - - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx FAC-CON\n", sngss7_info->circuit->cic); - - /* unlock the channel */ - ftdm_mutex_unlock(ftdmchan->mutex); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t handle_umsg_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info ; - ftdm_channel_t *ftdmchan; - - ftdm_running_return(FTDM_FAIL); - - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - /* lock the channel */ - ftdm_mutex_lock(ftdmchan->mutex); - - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx USER-USER msg\n", sngss7_info->circuit->cic); - - /* unlock the channel */ - ftdm_mutex_unlock(ftdmchan->mutex); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t handle_susp_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiSuspEvnt *siSuspEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info ; - ftdm_channel_t *ftdmchan; - - ftdm_running_return(FTDM_FAIL); - - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - /* lock the channel */ - ftdm_mutex_lock(ftdmchan->mutex); - - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx Call-Suspend msg\n", sngss7_info->circuit->cic); - - /* unlock the channel */ - ftdm_mutex_unlock(ftdmchan->mutex); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t handle_resm_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiResmEvnt *siResmEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info ; - ftdm_channel_t *ftdmchan; - - ftdm_running_return(FTDM_FAIL); - - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - /* lock the channel */ - ftdm_mutex_lock(ftdmchan->mutex); - - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx Call-Resume msg\n", sngss7_info->circuit->cic); - - /* unlock the channel */ - ftdm_mutex_unlock(ftdmchan->mutex); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t handle_sta_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - ftdm_running_return(FTDM_FAIL); - - /* confirm that the circuit is active on our side otherwise move to the next circuit */ - if (!sngss7_test_flag(&g_ftdm_sngss7_data.cfg.isupCkt[circuit], SNGSS7_ACTIVE)) { - SS7_ERROR("[CIC:%d]Rx %s but circuit is not active yet, skipping!\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - return FTDM_FAIL; - } - - switch (evntType) { - /**************************************************************************/ - case SIT_STA_REATTEMPT: /* reattempt indication */ - handle_reattempt(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt); - break; - /**************************************************************************/ - case SIT_STA_ERRORIND: /* error indication */ - SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType)); - break; - /**************************************************************************/ - case SIT_STA_CONTCHK: /* continuity check */ - handle_cot_start(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt); - break; - /**************************************************************************/ - case SIT_STA_CONTREP: /* continuity report */ - handle_cot(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt); - break; - /**************************************************************************/ - case SIT_STA_STPCONTIN: /* stop continuity */ - handle_cot_stop(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt); - break; - /**************************************************************************/ - case SIT_STA_CGQRYRSP: /* circuit grp query response from far end forwarded to upper layer by ISUP */ - SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType)); - break; - /**************************************************************************/ - case SIT_STA_CONFUSION: /* confusion */ - SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType)); - break; - /**************************************************************************/ - case SIT_STA_LOOPBACKACK: /* loop-back acknowledge */ - SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType)); - break; - /**************************************************************************/ - case SIT_STA_CIRRSRVREQ: /* circuit reservation request */ - SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType)); - break; - /**************************************************************************/ - case SIT_STA_CIRRSRVACK: /* circuit reservation acknowledgement */ - SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType)); - break; - /**************************************************************************/ - case SIT_STA_CIRBLOREQ: /* circuit blocking request */ - handle_blo_req(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt); - break; - /**************************************************************************/ - case SIT_STA_CIRBLORSP: /* circuit blocking response */ - handle_blo_rsp(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt); - break; - /**************************************************************************/ - case SIT_STA_CIRUBLREQ: /* circuit unblocking request */ - handle_ubl_req(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt); - break; - /**************************************************************************/ - case SIT_STA_CIRUBLRSP: /* circuit unblocking response */ - handle_ubl_rsp(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt); - break; - /**************************************************************************/ - case SIT_STA_CIRRESREQ: /* circuit reset request - RSC */ - handle_rsc_req(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt); - break; - /**************************************************************************/ - case SIT_STA_CIRLOCRES: /* reset initiated locally by the software */ - handle_local_rsc_req(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt); - break; - /**************************************************************************/ - case SIT_STA_CIRRESRSP: /* circuit reset response */ - handle_rsc_rsp(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt); - break; - /**************************************************************************/ - case SIT_STA_CGBREQ: /* CGB request */ - handle_cgb_req(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt); - break; - /**************************************************************************/ - case SIT_STA_CGUREQ: /* CGU request */ - handle_cgu_req(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt); - break; - /**************************************************************************/ - case SIT_STA_CGQRYREQ: /* circuit group query request */ - SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType)); - break; - /**************************************************************************/ - case SIT_STA_CGBRSP: /* mntc. oriented CGB response */ - SS7_INFO(" Rx CGBA \n"); - break; - /**************************************************************************/ - case SIT_STA_CGURSP: /* mntc. oriented CGU response */ - /*SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType));*/ - SS7_INFO(" Rx CGUA \n"); - break; - /**************************************************************************/ - case SIT_STA_GRSREQ: /* circuit group reset request */ - handle_grs_req(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt); - break; - /**************************************************************************/ - case SIT_STA_CIRUNEQPD: /* circuit unequipped indication */ - handle_ucic(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt); - break; - /**************************************************************************/ - case SIT_STA_GRSRSP: /* circuit group reset response */ - handle_grs_rsp(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt); - break; - /**************************************************************************/ - case SIT_STA_PAUSEIND: /* pause indication */ - handle_pause(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt); - break; - /**************************************************************************/ - case SIT_STA_RESUMEIND: /* resume indication */ - handle_resume(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt); - break; - /**************************************************************************/ - case SIT_STA_USRPARTA: /* user part available */ - SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType)); - break; - /**************************************************************************/ - case SIT_STA_RMTUSRUNAV: /* remote user not available */ - SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType)); - break; - /**************************************************************************/ - case SIT_STA_MTPCONG0: /* congestion indication level 0 */ - SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType)); - break; - /**************************************************************************/ - case SIT_STA_MTPCONG1: /* congestion indication level 1 */ - SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType)); - break; - /**************************************************************************/ - case SIT_STA_MTPCONG2: /* congestion indication level 2 */ - SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType)); - break; - /**************************************************************************/ - case SIT_STA_MTPCONG3: /* congestion indication level 3 */ - SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType)); - break; - /**************************************************************************/ - case SIT_STA_MTPSTPCONG: /* stop congestion indication level 0 */ - SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType)); - break; - /**************************************************************************/ - case SIT_STA_CIRLOCALBLOIND: /* Mngmt local blocking */ - handle_local_blk(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt); - break; - /**************************************************************************/ - case SIT_STA_CIRLOCALUBLIND: /* Mngmt local unblocking */ - handle_local_ubl(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt); - break; - /**************************************************************************/ - case SIT_STA_OVERLOAD: /* Overload */ - handle_olm_msg(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt); - break; - /**************************************************************************/ - case SIT_STA_LMCGBREQ: /* when LM requests ckt grp blocking */ - SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType)); - break; - /**************************************************************************/ - case SIT_STA_LMCGUREQ: /* when LM requests ckt grp unblocking */ - SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType)); - break; - /**************************************************************************/ - case SIT_STA_LMGRSREQ: /* when LM requests ckt grp reset */ - SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType)); - break; - /**************************************************************************/ - case SIT_STA_CGBINFOIND: /* circuit grp blking ind , no resp req */ -/* handle_cgb_req(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt);*/ - break; - /**************************************************************************/ - case SIT_STA_LMCQMINFOREQ: /* when LM requests ckt grp query */ -// SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType)); - break; - /**************************************************************************/ - case SIT_STA_CIRLOCGRS: /* group reset initiated locally by the software */ - SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType)); - break; - /**************************************************************************/ - default: - SS7_INFO("[SNG-CC] Received Unknown indication %d\n", evntType); - break; - } /* switch (evntType) */ - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_SUCCESS; - -} - -/******************************************************************************/ -ftdm_status_t handle_reattempt(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = NULL; - ftdm_channel_t *ftdmchan = NULL; - - ftdm_running_return(FTDM_FAIL); - - /* confirm that the circuit is voice channel */ - if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) { - SS7_ERROR("[CIC:%d]Rx %s on non-voice CIC\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } else { - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for ISUP circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Rx %s\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - } - - /* lock the channel */ - ftdm_mutex_lock(ftdmchan->mutex); - - if (sngss7_test_ckt_flag(sngss7_info, FLAG_GLARE)) { - /* the glare flag is already up so it was caught ... do nothing */ - SS7_DEBUG_CHAN(ftdmchan, "Glare flag is already up...nothing to do!%s\n", " "); - } else { - int bHangup = 0; - SS7_DEBUG_CHAN(ftdmchan, "Glare flag is not up yet...indicating glare from reattempt!%s\n", " "); - /* glare, throw the flag */ - sngss7_set_ckt_flag(sngss7_info, FLAG_GLARE); - - /* clear any existing glare data from the channel */ - memset(&sngss7_info->glare, 0x0, sizeof(sngss7_glare_data_t)); - - if (g_ftdm_sngss7_data.cfg.glareResolution == SNGSS7_GLARE_DOWN) { - /* If I'm in DOWN mode, I will always hangup my call. */ - bHangup = 1; - } - else if (g_ftdm_sngss7_data.cfg.glareResolution == SNGSS7_GLARE_PC) { - /* I'm in PointCode mode. - Case 1: My point code is higher than the other side. - If the CIC number is even, I'm trying to control. - If the CIC number is odd, I'll hangup my call and back off. - Case 2: My point code is lower than the other side. - If the CIC number is odd, I'm trying to control. - If the CIC number is even, I'll hangup my call and back off. - */ - if( g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info->circuit->infId].spc > g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info->circuit->infId].dpc ) - { - if ((sngss7_info->circuit->cic % 2) == 1 ) { - bHangup = 1; - } - } else { - if( (sngss7_info->circuit->cic % 2) == 0 ) { - bHangup = 1; - } - } - } - else { - /* If I'm in CONTROL mode, I will not hangup my call. */ - bHangup = 0; - } - - if (bHangup) { - /* setup the hangup cause */ - ftdmchan->caller_data.hangup_cause = 34; /* Circuit Congrestion */ - - /* move the state of the channel to Terminating to end the call - in TERMINATING state, the release cause is set to REMOTE_REL - in any means. So we don't have to set the release reason here. - */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); - } - } - - /* unlock the channel again before we exit */ - ftdm_mutex_unlock(ftdmchan->mutex); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t handle_pause(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = NULL; - ftdm_channel_t *ftdmchan = NULL; - int infId; - int i; - - ftdm_running_return(FTDM_FAIL); - - /* extract the affected infId from the circuit structure */ - infId = g_ftdm_sngss7_data.cfg.isupCkt[circuit].infId; - - /* set the interface to paused */ - sngss7_set_flag(&g_ftdm_sngss7_data.cfg.isupIntf[infId], SNGSS7_PAUSED); - - /* go through all the circuits now and find any other circuits on this infId */ - i = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1; - while (g_ftdm_sngss7_data.cfg.isupCkt[i].id != 0) { - - /* check that the infId matches and that this is not a siglink */ - if ((g_ftdm_sngss7_data.cfg.isupCkt[i].infId == infId) && - (g_ftdm_sngss7_data.cfg.isupCkt[i].type == SNG_CKT_VOICE)) { - - /* confirm that the circuit is active on our side otherwise move to the next circuit */ - if (!sngss7_test_flag(&g_ftdm_sngss7_data.cfg.isupCkt[i], SNGSS7_ACTIVE)) { - SS7_ERROR("[CIC:%d]Circuit is not active yet, skipping!\n",g_ftdm_sngss7_data.cfg.isupCkt[i].cic); - i++; - continue; - } - - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(i, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit); - i++; - continue; - } - - /* lock the channel */ - ftdm_mutex_lock(ftdmchan->mutex); - - /* check if the circuit is fully started */ - if (ftdm_test_flag(ftdmchan->span, FTDM_SPAN_IN_THREAD)) { - SS7_DEBUG_CHAN(ftdmchan, "Rx PAUSE%s\n", ""); - /* set the pause flag on the channel */ - sngss7_set_ckt_flag(sngss7_info, FLAG_INFID_PAUSED); - - /* clear the resume flag on the channel */ - sngss7_clear_ckt_flag(sngss7_info, FLAG_INFID_RESUME); - } - - /* unlock the channel again before we exit */ - ftdm_mutex_unlock(ftdmchan->mutex); - - } /* if (g_ftdm_sngss7_data.cfg.isupCkt[i].infId == infId) */ - - /* move to the next circuit */ - i++; - - } /* while (g_ftdm_sngss7_data.cfg.isupCkt[i].id != 0) */ - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t handle_resume(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = NULL; - ftdm_channel_t *ftdmchan = NULL; - int infId; - int i; - - ftdm_running_return(FTDM_FAIL); - - /* extract the affect infId from the circuit structure */ - infId = g_ftdm_sngss7_data.cfg.isupCkt[circuit].infId; - - /* set the interface to resumed */ - sngss7_clear_flag(&g_ftdm_sngss7_data.cfg.isupIntf[infId], SNGSS7_PAUSED); - - /* go through all the circuits now and find any other circuits on this infId */ - i = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1; - while (g_ftdm_sngss7_data.cfg.isupCkt[i].id != 0) { - - /* check that the infId matches and that this is not a siglink */ - if ((g_ftdm_sngss7_data.cfg.isupCkt[i].infId == infId) && - (g_ftdm_sngss7_data.cfg.isupCkt[i].type == SNG_CKT_VOICE)) { - - /* confirm that the circuit is active on our side otherwise move to the next circuit */ - if (!sngss7_test_flag(&g_ftdm_sngss7_data.cfg.isupCkt[i], SNGSS7_ACTIVE)) { - ftdm_log(FTDM_LOG_DEBUG, "[CIC:%d]Circuit is not active yet, skipping!\n",g_ftdm_sngss7_data.cfg.isupCkt[i].cic); - i++; - continue; - } - - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(i, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit); - i++; - continue; - } - - /* lock the channel */ - ftdm_mutex_lock(ftdmchan->mutex); - - /* only resume if we are paused */ - if (sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_PAUSED)) { - SS7_DEBUG_CHAN(ftdmchan, "Rx RESUME%s\n", ""); - - /* set the resume flag on the channel */ - sngss7_set_ckt_flag(sngss7_info, FLAG_INFID_RESUME); - - /* clear the paused flag */ - sngss7_clear_ckt_flag(sngss7_info, FLAG_INFID_PAUSED); - } - - /* unlock the channel again before we exit */ - ftdm_mutex_unlock(ftdmchan->mutex); - - } /* if (g_ftdm_sngss7_data.cfg.isupCkt[i].infId == infId) */ - - /* move to the next circuit */ - i++; - - } /* while (g_ftdm_sngss7_data.cfg.isupCkt[i].id != 0) */ - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t handle_cot_start(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = NULL; - ftdm_channel_t *ftdmchan = NULL; - - ftdm_running_return(FTDM_FAIL); - - /* confirm that the circuit is voice channel */ - if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) { - SS7_ERROR("[CIC:%d]Rx %s on non-voice CIC\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } else { - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for ISUP circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Rx %s\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - } - - /* lock the channel */ - ftdm_mutex_lock(ftdmchan->mutex); - - /* open the channel if it is not open */ - if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OPEN)) { - if (ftdm_channel_open_chan(ftdmchan) != FTDM_SUCCESS) { - SS7_ERROR("Failed to open CIC %d for CCR test!\n", sngss7_info->circuit->cic); - /* KONRAD FIX ME */ - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - } - - /* tell the core to loop the channel */ - ftdm_channel_command(ftdmchan, FTDM_COMMAND_ENABLE_LOOP, NULL); - - /* switch to the IN_LOOP state */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_IN_LOOP); - - /* unlock the channel again before we exit */ - ftdm_mutex_unlock(ftdmchan->mutex); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t handle_cot_stop(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = NULL; - ftdm_channel_t *ftdmchan = NULL; - - ftdm_running_return(FTDM_FAIL); - - /* confirm that the circuit is voice channel */ - if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) { - SS7_ERROR("[CIC:%d]Rx %s on non-voice CIC\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } else { - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for ISUP circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Rx %s\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - } - - /* lock the channel */ - ftdm_mutex_lock(ftdmchan->mutex); - - /* tell the core to stop looping the channel */ - ftdm_channel_command(ftdmchan, FTDM_COMMAND_DISABLE_LOOP, NULL); - - /* exit out of the LOOP state to the last state */ - ftdm_set_state(ftdmchan, ftdmchan->last_state); - - /* unlock the channel again before we exit */ - ftdm_mutex_unlock(ftdmchan->mutex); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t handle_cot(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = NULL; - ftdm_channel_t *ftdmchan = NULL; - - ftdm_running_return(FTDM_FAIL); - - /* confirm that the circuit is voice channel */ - if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) { - SS7_ERROR("[CIC:%d]Rx %s on non-voice CIC\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } else { - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for ISUP circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Rx %s\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - } - - /* lock the channel */ - ftdm_mutex_lock(ftdmchan->mutex); - - switch (ftdmchan->state) { - /**************************************************************************/ - case (FTDM_CHANNEL_STATE_IN_LOOP): - /* tell the core to stop looping the channel */ - ftdm_channel_command(ftdmchan, FTDM_COMMAND_DISABLE_LOOP, NULL); - - /* exit out of the LOOP state and go to collect */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_COLLECT); - - break; - /**************************************************************************/ - default: - /* exit out of the LOOP state to the last state */ - ftdm_set_state(ftdmchan, ftdmchan->last_state); - - break; - /**************************************************************************/ - } /* switch (ftdmchan->state) */ - - if ( (siStaEvnt->contInd.eh.pres > 0) && (siStaEvnt->contInd.contInd.pres > 0)) { - SS7_INFO("Continuity Test result for CIC = %d (span %d, chan %d) is: \"%s\"\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - g_ftdm_sngss7_data.cfg.isupCkt[circuit].span, - g_ftdm_sngss7_data.cfg.isupCkt[circuit].chan, - (siStaEvnt->contInd.contInd.val) ? "PASS" : "FAIL"); - } else { - SS7_ERROR("Recieved Continuity report containing no results!\n"); - } - - /* unlock the channel again before we exit */ - ftdm_mutex_unlock(ftdmchan->mutex); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t handle_blo_req(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = NULL; - ftdm_channel_t *ftdmchan = NULL; - - ftdm_running_return(FTDM_FAIL); - - /* confirm that the circuit is voice channel */ - if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) { - SS7_ERROR("[CIC:%d]Rx %s on non-voice CIC\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } else { - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for ISUP circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Rx %s\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - } - - /* lock the channel */ - ftdm_mutex_lock(ftdmchan->mutex); - - /* check if the circuit is already blocked or not */ - if (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX)) { - SS7_WARN("Received BLO on circuit that is already blocked!\n"); - } - - /* throw the ckt block flag */ - sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX); - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX_DN); - - /* set the channel to suspended state */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); - - /* unlock the channel again before we exit */ - ftdm_mutex_unlock(ftdmchan->mutex); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t handle_blo_rsp(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = NULL; - ftdm_channel_t *ftdmchan = NULL; - - ftdm_running_return(FTDM_FAIL); - - /* confirm that the circuit is voice channel */ - if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) { - SS7_ERROR("[CIC:%d]Rx %s on non-voice CIC\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } else { - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for ISUP circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Rx %s\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - } - - /* lock the channel */ - ftdm_mutex_lock(ftdmchan->mutex); - - /* KONRAD FIX ME */ - - /* unlock the channel again before we exit */ - ftdm_mutex_unlock(ftdmchan->mutex); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t handle_ubl_req(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = NULL; - ftdm_channel_t *ftdmchan = NULL; - - ftdm_running_return(FTDM_FAIL); - - /* confirm that the circuit is voice channel */ - if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) { - SS7_ERROR("[CIC:%d]Rx %s on non-voice CIC\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } else { - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for ISUP circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Rx %s\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - } - - /* lock the channel */ - ftdm_mutex_lock(ftdmchan->mutex); - - /* check if the channel is blocked */ - if (!(sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX)) && !sngss7_test_ckt_blk_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX)) { - SS7_WARN("Received UBL on circuit that is not blocked! span= %d, chan= %d , flag = %x \n", g_ftdm_sngss7_data.cfg.isupCkt[circuit].span, g_ftdm_sngss7_data.cfg.isupCkt[circuit].chan,sngss7_info->blk_flags ); - } - - /* throw the unblock flag */ - sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_UNBLK_RX); - - /* clear the block flag */ - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX); - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX); - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX_DN); - - /* set the channel to suspended state */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); - - /* unlock the channel again before we exit */ - ftdm_mutex_unlock(ftdmchan->mutex); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t handle_ubl_rsp(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = NULL; - ftdm_channel_t *ftdmchan = NULL; - - /* confirm that the circuit is voice channel */ - if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) { - SS7_ERROR("[CIC:%d]Rx %s on non-voice CIC\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } else { - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for ISUP circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Rx %s\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - } - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t handle_rsc_req(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = NULL; - ftdm_channel_t *ftdmchan = NULL; - - ftdm_running_return(FTDM_FAIL); - - /* confirm that the circuit is voice channel */ - if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) { - SS7_ERROR("[CIC:%d]Rx %s on non-voice CIC\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } else { - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for ISUP circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Rx %s\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - } - - /* lock the channel */ - ftdm_mutex_lock(ftdmchan->mutex); - - /* throw the reset flag */ - sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_RX); - - switch (ftdmchan->state) { - /**************************************************************************/ - case FTDM_CHANNEL_STATE_RESTART: - - /* go to idle so that we can redo the restart state*/ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_IDLE); - - break; - /**************************************************************************/ - default: - - /* set the state of the channel to restart...the rest is done by the chan monitor */ - sngss7_set_ckt_flag(sngss7_info, FLAG_REMOTE_REL); - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RESTART); - break; - /**************************************************************************/ - } - - /* unlock the channel again before we exit */ - ftdm_mutex_unlock(ftdmchan->mutex); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t handle_local_rsc_req(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = NULL; - ftdm_channel_t *ftdmchan = NULL; - - ftdm_running_return(FTDM_FAIL); - - /* confirm that the circuit is voice channel */ - if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) { - SS7_ERROR("[CIC:%d]Rx %s on non-voice CIC\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } else { - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for ISUP circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Rx %s\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - } - /* lock the channel */ - ftdm_mutex_lock(ftdmchan->mutex); - - /* throw the reset flag */ - sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_RX); - - switch (ftdmchan->state) { - /**************************************************************************/ - case FTDM_CHANNEL_STATE_RESTART: - - /* go to idle so that we can redo the restart state*/ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_IDLE); - - break; - /**************************************************************************/ - default: - - /* set the state of the channel to restart...the rest is done by the chan monitor */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RESTART); - break; - /**************************************************************************/ - } - - /* unlock the channel again before we exit */ - ftdm_mutex_unlock(ftdmchan->mutex); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t handle_rsc_rsp(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = NULL; - ftdm_channel_t *ftdmchan = NULL; - - ftdm_running_return(FTDM_FAIL); - - /* confirm that the circuit is voice channel */ - if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) { - SS7_ERROR("[CIC:%d]Rx %s on non-voice CIC\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } else { - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for ISUP circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Rx %s\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - } - - /* lock the channel */ - ftdm_mutex_lock(ftdmchan->mutex); - - switch (ftdmchan->state) { - /**********************************************************************/ - case FTDM_CHANNEL_STATE_RESTART: - - if ( sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_TX) ) { - /* throw the FLAG_RESET_TX_RSP to indicate we have acknowledgement from the remote side */ - sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_TX_RSP); - - /* go to DOWN */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - } else { - SS7_ERROR("Received RSC-RLC but we're not waiting on a RSC-RLC on CIC #%d, dropping\n", sngss7_info->circuit->cic); - } - - break; - /**********************************************************************/ - case FTDM_CHANNEL_STATE_DOWN: - - /* do nothing, just drop the message */ - SS7_DEBUG("Receveived RSC-RLC in down state, dropping\n"); - - break; - /**********************************************************************/ - case FTDM_CHANNEL_STATE_TERMINATING: - case FTDM_CHANNEL_STATE_HANGUP: - case FTDM_CHANNEL_STATE_HANGUP_COMPLETE: - - /* throw the FLAG_RESET_TX_RSP to indicate we have acknowledgement from the remote side */ - sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_TX_RSP); - - /* go to DOWN */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RESTART); - - break; - /**********************************************************************/ - default: - /* ITU Q764-2.9.5.1.c -> release the circuit */ - if ((siStaEvnt != NULL) && - (siStaEvnt->causeDgn.eh.pres ==PRSNT_NODEF) && - (siStaEvnt->causeDgn.causeVal.pres == PRSNT_NODEF)) { - ftdmchan->caller_data.hangup_cause = siStaEvnt->causeDgn.causeVal.val; - } else { - ftdmchan->caller_data.hangup_cause = 98; /* Message not compatiable with call state */ - } - - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); - break; - /**********************************************************************/ - } - - /* unlock the channel again before we exit */ - ftdm_mutex_unlock(ftdmchan->mutex); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_SUCCESS; -} -/******************************************************************************/ -ftdm_status_t handle_grs_req(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = NULL; - ftdm_channel_t *ftdmchan = NULL; - sngss7_span_data_t *sngss7_span = NULL; - int range = 0; - - ftdm_running_return(FTDM_FAIL); - - /* confirm that the circuit is voice channel */ - if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) { - SS7_ERROR("[CIC:%d]Rx %s on non-voice CIC\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } else { - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for ISUP circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Rx %s\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - } - - /* extract the range value from the event structure */ - if ((siStaEvnt->rangStat.eh.pres == PRSNT_NODEF) && (siStaEvnt->rangStat.range.pres == PRSNT_NODEF)) { - range = siStaEvnt->rangStat.range.val; - } else { - SS7_ERROR("Received GRS with no range value on CIC = %d\n", sngss7_info->circuit->cic); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - /* fill in the span structure for this circuit */ - sngss7_span = ftdmchan->span->signal_data; - if (sngss7_info->rx_grs.range) { - SS7_CRITICAL("Cannot handle another GRS on CIC = %d\n", sngss7_info->circuit->cic); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - sngss7_info->rx_grs.circuit = circuit; - sngss7_info->rx_grs.range = range; - - ftdm_set_flag(sngss7_span, SNGSS7_RX_GRS_PENDING); - /* the reset will be started in the main thread by "check_if_rx_grs_started" */ - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t handle_grs_rsp(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = NULL; - ftdm_channel_t *ftdmchan = NULL; - sngss7_span_data_t *sngss7_span = NULL; - int range = 0; - - ftdm_running_return(FTDM_FAIL); - - /* confirm that the circuit is voice channel */ - if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) { - SS7_ERROR("[CIC:%d]Rx %s on non-voice CIC\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } else { - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for ISUP circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Rx %s\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - } - - /* extract the range value from the event structure */ - if ((siStaEvnt->rangStat.eh.pres == PRSNT_NODEF) && (siStaEvnt->rangStat.range.pres == PRSNT_NODEF)) { - range = siStaEvnt->rangStat.range.val; - } else { - SS7_ERROR("Received GRA with no range value on CIC = %d\n", sngss7_info->circuit->cic); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - /* fill in the span structure for this circuit */ - sngss7_span = ftdmchan->span->signal_data; - if (sngss7_info->rx_gra.range) { - SS7_ERROR("Cannot handle another GRA on CIC = %d\n", sngss7_info->circuit->cic); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - sngss7_info->rx_gra.circuit = circuit; - sngss7_info->rx_gra.range = range; - - /* check if there is a cause value in the GRA */ - if ((siStaEvnt != NULL) && - (siStaEvnt->causeDgn.eh.pres == PRSNT_NODEF) && - (siStaEvnt->causeDgn.causeVal.pres == PRSNT_NODEF)) { - - sngss7_info->rx_gra.cause = siStaEvnt->causeDgn.causeVal.val; - } - - ftdm_set_flag(sngss7_span, SNGSS7_RX_GRA_PENDING); - - /* the reset will be started in the main thread by "check_if_rx_gra_started" */ - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t handle_local_blk(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = NULL; - ftdm_channel_t *ftdmchan = NULL; - - ftdm_running_return(FTDM_FAIL); - - /* confirm that the circuit is voice channel */ - if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) { - SS7_ERROR("[CIC:%d]Rx %s on non-voice CIC\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } else { - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for ISUP circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Rx %s\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - } - - /* lock the channel */ - ftdm_mutex_lock(ftdmchan->mutex); - - /* check if the circuit is already blocked or not */ - if (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX)) { - SS7_WARN("Received local BLO on circuit that is already blocked!\n"); - } - - /* throw the ckt block flag */ - sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX); - - /* set the channel to suspended state */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); - - /* unlock the channel again before we exit */ - ftdm_mutex_unlock(ftdmchan->mutex); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t handle_local_ubl(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = NULL; - ftdm_channel_t *ftdmchan = NULL; - - ftdm_running_return(FTDM_FAIL); - - /* confirm that the circuit is voice channel */ - if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) { - SS7_ERROR("[CIC:%d]Rx %s on non-voice CIC\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } else { - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for ISUP circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Rx %s\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - } - - /* lock the channel */ - ftdm_mutex_lock(ftdmchan->mutex); - - /* check if the circuit is blocked or not */ - if (!sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX)) { - SS7_WARN("Received local UBL on circuit that is not blocked!\n"); - } - - /* throw the ckt unblock flag */ - sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_UNBLK_RX); - - /* set the channel to suspended state */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); - - /* unlock the channel again before we exit */ - ftdm_mutex_unlock(ftdmchan->mutex); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t handle_ucic(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - ftdm_iterator_t *iter = NULL; - ftdm_iterator_t *curr = NULL; - sngss7_chan_data_t *sngss7_info = NULL; - sngss7_chan_data_t *cinfo = NULL; - sngss7_span_data_t *sngss7_span = NULL; - ftdm_channel_t *ftdmchan = NULL; - - ftdm_running_return(FTDM_FAIL); - - /* confirm that the circuit is voice channel */ - if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) { - SS7_ERROR("[CIC:%d]Rx %s on non-voice CIC\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } else { - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for ISUP circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Rx %s\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - } - - /* find out if the cic belongs to one of our GRS requests, if so, - * all circuits in the request must be blocked */ - sngss7_span = ftdmchan->span->signal_data; - iter = ftdm_span_get_chan_iterator(ftdmchan->span, NULL); - curr = iter; - for (curr = iter; curr; curr = ftdm_iterator_next(curr)) { - ftdm_channel_t *fchan = ftdm_iterator_current(curr); - - ftdm_channel_lock(fchan); - - cinfo = fchan->call_data; - if (circuit == cinfo->tx_grs.circuit) { - cinfo->ucic.circuit = cinfo->tx_grs.circuit; - cinfo->ucic.range = cinfo->tx_grs.range; - ftdm_set_flag(sngss7_span, SNGSS7_UCIC_PENDING); - - SS7_WARN("Set span SNGSS7_UCIC_PENDING for ISUP circuit = %d!\n", circuit); - - ftdm_channel_unlock(fchan); - - goto done; - } - - ftdm_channel_unlock(fchan); - } - - /* lock the channel */ - ftdm_mutex_lock(ftdmchan->mutex); - - /* throw the ckt block flag */ - SS7_DEBUG("Set FLAG_CKT_UCIC_BLOCK for ISUP circuit = %d!\n", circuit); - sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK); - - /* set the channel to suspended state */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); - - /* unlock the channel again before we exit */ - ftdm_mutex_unlock(ftdmchan->mutex); -done: - if (iter) { - ftdm_iterator_free(iter); - } - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t handle_cgb_req(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = NULL; - sngss7_span_data_t *sngss7_span = NULL; - ftdm_channel_t *ftdmchan = NULL; - int range; - uint8_t status[255]; - int blockType = 0; - int byte = 0; - int bit = 0; - int x; - int loop_range=0; - - ftdm_running_return(FTDM_FAIL); - - memset(&status[0], '\0', sizeof(status)); - - /* confirm that the circuit is voice channel */ - if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) { - SS7_ERROR("[CIC:%d]Rx %s on non-voice CIC\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } else { - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for ISUP circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Rx %s\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - } - /* grab the span info */ - sngss7_span = ftdmchan->span->signal_data; - - /* figure out what type of block needs to be applied */ - if ((siStaEvnt->cgsmti.eh.pres == PRSNT_NODEF) && (siStaEvnt->cgsmti.typeInd.pres == PRSNT_NODEF)) { - blockType = siStaEvnt->cgsmti.typeInd.val; - } else { - SS7_ERROR("Received CGB with no circuit group supervision value on CIC = %d\n", sngss7_info->circuit->cic); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - /* pull out the range value */ - if ((siStaEvnt->rangStat.eh.pres == PRSNT_NODEF) && (siStaEvnt->rangStat.range.pres == PRSNT_NODEF)) { - range = siStaEvnt->rangStat.range.val; - } else { - SS7_ERROR("Received CGB with no range value on CIC = %d\n", sngss7_info->circuit->cic); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - /* pull out the status field */ - if ((siStaEvnt->rangStat.eh.pres == PRSNT_NODEF) && (siStaEvnt->rangStat.status.pres == PRSNT_NODEF)) { - for (x = 0; x < siStaEvnt->rangStat.status.len; x++) { - status[x] = siStaEvnt->rangStat.status.val[x]; - } - } else { - SS7_ERROR("Received CGB with no status value on CIC = %d\n", sngss7_info->circuit->cic); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - /* save the circuit, range and status */ - sngss7_span->rx_cgb.circuit = circuit; - sngss7_span->rx_cgb.range = range; - sngss7_span->rx_cgb.type = blockType; - for (x = 0; x < siStaEvnt->rangStat.status.len; x++) { - sngss7_span->rx_cgb.status[x] = status[x]; - } - - /* loop over the cics starting from circuit until range+1 */ - loop_range = circuit + range + 1; - x = circuit; - while( x < loop_range ) { - if (g_ftdm_sngss7_data.cfg.isupCkt[x].type != SNG_CKT_VOICE) { - loop_range++; - } - else { - if (extract_chan_data(x, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", x); - } else { - ftdm_mutex_lock(ftdmchan->mutex); - if (status[byte] & (1 << bit)) { - switch (blockType) { - /**********************************************************************/ - case 0: /* maintenance oriented */ - sngss7_set_ckt_blk_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX); - break; - /**********************************************************************/ - case 1: /* hardware failure oriented */ - sngss7_set_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX); - break; - /**********************************************************************/ - case 2: /* reserved for national use */ - break; - /**********************************************************************/ - default: - break; - /**********************************************************************/ - } - } - - /* bring the sig status down */ - sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_DOWN); - - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); - - /* unlock the channel again before we exit */ - ftdm_mutex_unlock(ftdmchan->mutex); - - /* update the bit and byte counter*/ - bit ++; - if (bit == 8) { - byte++; - bit = 0; - } - } - } - x++; - } - - - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - ft_to_sngss7_cgba(ftdmchan); - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t handle_cgu_req(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = NULL; - sngss7_span_data_t *sngss7_span = NULL; - ftdm_channel_t *ftdmchan = NULL; - int range; - uint8_t status[255]; - int blockType = 0; - int byte = 0; - int bit = 0; - int x; - int loop_range=0; - ftdm_sigmsg_t sigev; - - ftdm_running_return(FTDM_FAIL); - - memset(&sigev, 0, sizeof (sigev)); - memset(&status[0], '\0', sizeof(status)); - - /* confirm that the circuit is voice channel */ - if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) { - SS7_ERROR("[CIC:%d]Rx %s on non-voice CIC\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } else { - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for ISUP circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Rx %s\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - } - - /* grab the span info */ - sngss7_span = ftdmchan->span->signal_data; - - /* figure out what type of block needs to be applied */ - if ((siStaEvnt->cgsmti.eh.pres == PRSNT_NODEF) && (siStaEvnt->cgsmti.typeInd.pres == PRSNT_NODEF)) { - blockType = siStaEvnt->cgsmti.typeInd.val; - } else { - SS7_ERROR("Received CGU with no circuit group supervision value on CIC = %d\n", sngss7_info->circuit->cic); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - /* pull out the range value */ - if ((siStaEvnt->rangStat.eh.pres == PRSNT_NODEF) && (siStaEvnt->rangStat.range.pres == PRSNT_NODEF)) { - range = siStaEvnt->rangStat.range.val; - } else { - SS7_ERROR("Received CGU with no range value on CIC = %d\n", sngss7_info->circuit->cic); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - /* pull out the status field */ - if ((siStaEvnt->rangStat.eh.pres == PRSNT_NODEF) && (siStaEvnt->rangStat.status.pres == PRSNT_NODEF)) { - for (x = 0; x < siStaEvnt->rangStat.status.len; x++) { - status[x] = siStaEvnt->rangStat.status.val[x]; - } - } else { - SS7_ERROR("Received CGU with no status value on CIC = %d\n", sngss7_info->circuit->cic); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - /* save the circuit, range and status */ - sngss7_span->rx_cgu.circuit = circuit; - sngss7_span->rx_cgu.range = range; - sngss7_span->rx_cgu.type = blockType; - for (x = 0; x < siStaEvnt->rangStat.status.len; x++) { - sngss7_span->rx_cgu.status[x] = status[x]; - } - - /* loop over the cics starting from circuit until range+1 */ - loop_range = circuit + range + 1; - x = circuit; - while( x < loop_range ) { - if (g_ftdm_sngss7_data.cfg.isupCkt[x].type != SNG_CKT_VOICE) { - loop_range++; - } else { - if (extract_chan_data(x, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", x); - } - else { - ftdm_mutex_lock(ftdmchan->mutex); - - if (status[byte] & (1 << bit)) { - switch (blockType) { - /**********************************************************************/ - case 0: /* maintenance oriented */ - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX); - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX); - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX_DN); - break; - /**********************************************************************/ - case 1: /* hardware failure oriented */ - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX); - break; - /**********************************************************************/ - case 2: /* reserved for national use */ - break; - /**********************************************************************/ - default: - break; - /**********************************************************************/ - } /* switch (blockType) */ - } /* if (status[byte] & (1 << bit)) */ - - sigev.chan_id = ftdmchan->chan_id; - sigev.span_id = ftdmchan->span_id; - sigev.channel = ftdmchan; - - /* bring the sig status down */ - if (sngss7_channel_status_clear(sngss7_info)) { - sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_UP); - } - - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); - ftdm_mutex_unlock(ftdmchan->mutex); - - /* update the bit and byte counter*/ - bit ++; - if (bit == 8) { - byte++; - bit = 0; - } - } - } - x++; - } - - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - ft_to_sngss7_cgua(ftdmchan); - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t handle_olm_msg(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = NULL; - ftdm_channel_t *ftdmchan = NULL; - - ftdm_running_return(FTDM_FAIL); - - /* confirm that the circuit is voice channel */ - if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) { - SS7_ERROR("[CIC:%d]Rx %s on non-voice CIC\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } else { - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for ISUP circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_FAIL; - } - - SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Rx %s\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - } - - /* handle overload */ - SS7_ERROR_CHAN(ftdmchan,"[CIC:%d]Rx Overload\n", sngss7_info->circuit->cic); - - sng_isup_reg_info_show(); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return FTDM_SUCCESS; -} - -/******************************************************************************/ -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ -/******************************************************************************/ diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_in.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_in.c deleted file mode 100644 index 95ff402ae8..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_in.c +++ /dev/null @@ -1,722 +0,0 @@ -/* - * Copyright (c) 2009, Konrad Hammel - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* INCLUDE ********************************************************************/ -#include "ftmod_sangoma_ss7_main.h" -/******************************************************************************/ - -/* DEFINES ********************************************************************/ -/******************************************************************************/ - -/* GLOBALS ********************************************************************/ -/******************************************************************************/ - -/* PROTOTYPES *****************************************************************/ -void sngss7_sta_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -void sngss7_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiConEvnt *siConEvnt); -void sngss7_con_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiConEvnt *siConEvnt); -void sngss7_con_sta(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiCnStEvnt *siCnStEvnt, uint8_t evntType); -void sngss7_rel_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiRelEvnt *siRelEvnt); -void sngss7_rel_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiRelEvnt *siRelEvnt); -void sngss7_dat_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiInfoEvnt *siInfoEvnt); -void sngss7_fac_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t evntType, SiFacEvnt *siFacEvnt); -void sngss7_fac_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t evntType, SiFacEvnt *siFacEvnt); -void sngss7_umsg_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit); -void sngss7_resm_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiResmEvnt *siResmEvnt); -void sngss7_susp_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiSuspEvnt *siSuspEvnt); -void sngss7_ssp_sta_cfm(uint32_t infId); -/******************************************************************************/ - -/* FUNCTIONS ******************************************************************/ -void sngss7_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiConEvnt *siConEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = NULL; - ftdm_channel_t *ftdmchan = NULL; - sngss7_event_data_t *sngss7_event = NULL; - - if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) { - SS7_ERROR("Rx sig event on circuit that is not a voice CIC (%d)\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - - /* initalize the sngss7_event */ - sngss7_event = ftdm_malloc(sizeof(*sngss7_event)); - - if (sngss7_event == NULL) { - SS7_ERROR("Failed to allocate memory for sngss7_event!\n"); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - memset(sngss7_event, 0x0, sizeof(*sngss7_event)); - - /* fill in the sngss7_event struct */ - sngss7_event->spInstId = spInstId; - sngss7_event->suInstId = suInstId; - sngss7_event->circuit = circuit; - sngss7_event->event_id = SNGSS7_CON_IND_EVENT; - memcpy(&sngss7_event->event.siConEvnt, siConEvnt, sizeof(*siConEvnt)); - - /* enqueue this event */ - ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->signal_data)->event_queue, sngss7_event); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); -} - -/******************************************************************************/ -void sngss7_con_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiConEvnt *siConEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = NULL; - ftdm_channel_t *ftdmchan = NULL; - sngss7_event_data_t *sngss7_event = NULL; - - if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) { - SS7_ERROR("Rx sig event on circuit that is not a voice CIC (%d)\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - - /* initalize the sngss7_event */ - sngss7_event = ftdm_malloc(sizeof(*sngss7_event)); - if (sngss7_event == NULL) { - SS7_ERROR("Failed to allocate memory for sngss7_event!\n"); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - memset(sngss7_event, 0x0, sizeof(*sngss7_event)); - - /* fill in the sngss7_event struct */ - sngss7_event->spInstId = spInstId; - sngss7_event->suInstId = suInstId; - sngss7_event->circuit = circuit; - sngss7_event->event_id = SNGSS7_CON_CFM_EVENT; - memcpy(&sngss7_event->event.siConEvnt, siConEvnt, sizeof(*siConEvnt)); - - /* enqueue this event */ - ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->signal_data)->event_queue, sngss7_event); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); -} - -/******************************************************************************/ -void sngss7_con_sta(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiCnStEvnt *siCnStEvnt, uint8_t evntType) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = NULL; - ftdm_channel_t *ftdmchan = NULL; - sngss7_event_data_t *sngss7_event = NULL; - - if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) { - SS7_ERROR("Rx sig event on circuit that is not a voice CIC (%d)\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - - /* initalize the sngss7_event */ - sngss7_event = ftdm_malloc(sizeof(*sngss7_event)); - if (sngss7_event == NULL) { - SS7_ERROR("Failed to allocate memory for sngss7_event!\n"); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - memset(sngss7_event, 0x0, sizeof(*sngss7_event)); - - /* fill in the sngss7_event struct */ - sngss7_event->spInstId = spInstId; - sngss7_event->suInstId = suInstId; - sngss7_event->circuit = circuit; - sngss7_event->evntType = evntType; - sngss7_event->event_id = SNGSS7_CON_STA_EVENT; - memcpy(&sngss7_event->event.siCnStEvnt, siCnStEvnt, sizeof(*siCnStEvnt)); - - /* enqueue this event */ - ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->signal_data)->event_queue, sngss7_event); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); -} - -/******************************************************************************/ -void sngss7_rel_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiRelEvnt *siRelEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = NULL; - ftdm_channel_t *ftdmchan = NULL; - sngss7_event_data_t *sngss7_event = NULL; - - if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) { - SS7_ERROR("Rx sig event on circuit that is not a voice CIC (%d)\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - - /* initalize the sngss7_event */ - sngss7_event = ftdm_malloc(sizeof(*sngss7_event)); - if (sngss7_event == NULL) { - SS7_ERROR("Failed to allocate memory for sngss7_event!\n"); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - memset(sngss7_event, 0x0, sizeof(*sngss7_event)); - - /* fill in the sngss7_event struct */ - sngss7_event->spInstId = spInstId; - sngss7_event->suInstId = suInstId; - sngss7_event->circuit = circuit; - sngss7_event->event_id = SNGSS7_REL_IND_EVENT; - memcpy(&sngss7_event->event.siRelEvnt, siRelEvnt, sizeof(*siRelEvnt)); - - /* enqueue this event */ - ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->signal_data)->event_queue, sngss7_event); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); -} - -/******************************************************************************/ -void sngss7_rel_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiRelEvnt *siRelEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = NULL; - ftdm_channel_t *ftdmchan = NULL; - sngss7_event_data_t *sngss7_event = NULL; - - if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) { - SS7_ERROR("Rx sig event on circuit that is not a voice CIC (%d)\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - - /* initalize the sngss7_event */ - sngss7_event = ftdm_malloc(sizeof(*sngss7_event)); - if (sngss7_event == NULL) { - SS7_ERROR("Failed to allocate memory for sngss7_event!\n"); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - memset(sngss7_event, 0x0, sizeof(*sngss7_event)); - - /* fill in the sngss7_event struct */ - sngss7_event->spInstId = spInstId; - sngss7_event->suInstId = suInstId; - sngss7_event->circuit = circuit; - sngss7_event->event_id = SNGSS7_REL_CFM_EVENT; - memcpy(&sngss7_event->event.siRelEvnt, siRelEvnt, sizeof(*siRelEvnt)); - - /* enqueue this event */ - ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->signal_data)->event_queue, sngss7_event); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); -} - -/******************************************************************************/ -void sngss7_dat_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiInfoEvnt *siInfoEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = NULL; - ftdm_channel_t *ftdmchan = NULL; - sngss7_event_data_t *sngss7_event = NULL; - - if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) { - SS7_ERROR("Rx sig event on circuit that is not a voice CIC (%d)\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - - /* initalize the sngss7_event */ - sngss7_event = ftdm_malloc(sizeof(*sngss7_event)); - if (sngss7_event == NULL) { - SS7_ERROR("Failed to allocate memory for sngss7_event!\n"); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - memset(sngss7_event, 0x0, sizeof(*sngss7_event)); - - /* fill in the sngss7_event struct */ - sngss7_event->spInstId = spInstId; - sngss7_event->suInstId = suInstId; - sngss7_event->circuit = circuit; - sngss7_event->event_id = SNGSS7_DAT_IND_EVENT; - memcpy(&sngss7_event->event.siInfoEvnt, siInfoEvnt, sizeof(*siInfoEvnt)); - - /* enqueue this event */ - ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->signal_data)->event_queue, sngss7_event); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); -} - -/******************************************************************************/ -void sngss7_fac_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t evntType, SiFacEvnt *siFacEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = NULL; - ftdm_channel_t *ftdmchan = NULL; - sngss7_event_data_t *sngss7_event = NULL; - - if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) { - SS7_ERROR("Rx sig event on circuit that is not a voice CIC (%d)\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - - /* initalize the sngss7_event */ - sngss7_event = ftdm_malloc(sizeof(*sngss7_event)); - if (sngss7_event == NULL) { - SS7_ERROR("Failed to allocate memory for sngss7_event!\n"); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - memset(sngss7_event, 0x0, sizeof(*sngss7_event)); - - /* fill in the sngss7_event struct */ - sngss7_event->spInstId = spInstId; - sngss7_event->suInstId = suInstId; - sngss7_event->circuit = circuit; - sngss7_event->evntType = evntType; - sngss7_event->event_id = SNGSS7_FAC_IND_EVENT; - memcpy(&sngss7_event->event.siFacEvnt, siFacEvnt, sizeof(*siFacEvnt)); - - /* enqueue this event */ - ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->signal_data)->event_queue, sngss7_event); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); -} - -/******************************************************************************/ -void sngss7_fac_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t evntType, SiFacEvnt *siFacEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = NULL; - ftdm_channel_t *ftdmchan = NULL; - sngss7_event_data_t *sngss7_event = NULL; - - if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) { - SS7_ERROR("Rx sig event on circuit that is not a voice CIC (%d)\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - - /* initalize the sngss7_event */ - sngss7_event = ftdm_malloc(sizeof(*sngss7_event)); - if (sngss7_event == NULL) { - SS7_ERROR("Failed to allocate memory for sngss7_event!\n"); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - memset(sngss7_event, 0x0, sizeof(*sngss7_event)); - - /* fill in the sngss7_event struct */ - sngss7_event->spInstId = spInstId; - sngss7_event->suInstId = suInstId; - sngss7_event->circuit = circuit; - sngss7_event->evntType = evntType; - sngss7_event->event_id = SNGSS7_FAC_CFM_EVENT; - memcpy(&sngss7_event->event.siFacEvnt, siFacEvnt, sizeof(*siFacEvnt)); - - /* enqueue this event */ - ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->signal_data)->event_queue, sngss7_event); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); -} - -/******************************************************************************/ -void sngss7_umsg_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = NULL; - ftdm_channel_t *ftdmchan = NULL; - sngss7_event_data_t *sngss7_event = NULL; - - if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) { - SS7_ERROR("Rx sig event on circuit that is not a voice CIC (%d)\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - - /* initalize the sngss7_event */ - sngss7_event = ftdm_malloc(sizeof(*sngss7_event)); - if (sngss7_event == NULL) { - SS7_ERROR("Failed to allocate memory for sngss7_event!\n"); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - memset(sngss7_event, 0x0, sizeof(*sngss7_event)); - - /* fill in the sngss7_event struct */ - sngss7_event->spInstId = spInstId; - sngss7_event->suInstId = suInstId; - sngss7_event->circuit = circuit; - sngss7_event->event_id = SNGSS7_UMSG_IND_EVENT; - - /* enqueue this event */ - ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->signal_data)->event_queue, sngss7_event); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - -} -/* GENERAL STATUS *************************************************************/ -void sngss7_sta_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = NULL; - ftdm_channel_t *ftdmchan = NULL; - sngss7_event_data_t *sngss7_event = NULL; - uint32_t intfId; - int x; - - - - /* check if the eventType is a pause/resume */ - switch (evntType) { - /**************************************************************************/ - case (SIT_STA_PAUSEIND): - case (SIT_STA_RESUMEIND): - /* the circuit may or may not be on the local system so we have to find - * circuit with the same intfId. The circuit specified might also be - * a non-voice cic so we also need to find the first voice cic on this - * system with the same intfId. - */ - intfId = g_ftdm_sngss7_data.cfg.isupCkt[circuit].infId; - - if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) { - SS7_DEBUG("Rx %s on circuit that is not a voice CIC (%d) finding a new circuit\n", - DECODE_LCC_EVENT(evntType), - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic); - } - - x = (g_ftdm_sngss7_data.cfg.procId * MAX_CIC_MAP_LENGTH) + 1; - while ((g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) && - (g_ftdm_sngss7_data.cfg.isupCkt[x].id < ((g_ftdm_sngss7_data.cfg.procId + 1) * MAX_CIC_MAP_LENGTH))) { - /**********************************************************************/ - /* confirm this is a voice channel and not a gap/sig (no ftdmchan there) */ - if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == SNG_CKT_VOICE) { - /* compare the intfIds */ - if (g_ftdm_sngss7_data.cfg.isupCkt[x].infId == intfId) { - /* we have a match, setup the pointers to the correct values */ - circuit = x; - - /* confirm that the circuit is active on our side otherwise move to the next circuit */ - if (!sngss7_test_flag(&g_ftdm_sngss7_data.cfg.isupCkt[circuit], SNGSS7_ACTIVE)) { - SS7_DEBUG("[CIC:%d]Rx %s but circuit is not active yet, skipping!\n", - g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, - DECODE_LCC_EVENT(evntType)); - x++; - continue; - } - - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - - /* bounce out of the loop */ - break; - } - } - - x++; - /**********************************************************************/ - } - - /* check if we found any circuits that are on the intfId, drop the message - * if none are found */ - if (!ftdmchan) { - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - - break; - /**************************************************************************/ - default: - if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) { - ftdm_log(FTDM_LOG_DEBUG, "Rx %s on circuit that is not a voice CIC (%d) (circuit:%d)\n", - DECODE_LCC_EVENT(evntType), g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic, circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - break; - /**************************************************************************/ - } /* switch (evntType) */ - - /* initalize the sngss7_event */ - sngss7_event = ftdm_malloc(sizeof(*sngss7_event)); - if (sngss7_event == NULL) { - SS7_ERROR("Failed to allocate memory for sngss7_event!\n"); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - memset(sngss7_event, 0x0, sizeof(*sngss7_event)); - - /* fill in the sngss7_event struct */ - sngss7_event->spInstId = spInstId; - sngss7_event->suInstId = suInstId; - sngss7_event->circuit = circuit; - sngss7_event->globalFlg = globalFlg; - sngss7_event->evntType = evntType; - sngss7_event->event_id = SNGSS7_STA_IND_EVENT; - if (siStaEvnt != NULL) { - memcpy(&sngss7_event->event.siStaEvnt, siStaEvnt, sizeof(*siStaEvnt)); - } - - /* enqueue this event */ - ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->signal_data)->event_queue, sngss7_event); -} - -/******************************************************************************/ -void sngss7_susp_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiSuspEvnt *siSuspEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = NULL; - ftdm_channel_t *ftdmchan = NULL; - sngss7_event_data_t *sngss7_event = NULL; - - if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) { - SS7_ERROR("Rx sig event on circuit that is not a voice CIC (%d)\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - - /* initalize the sngss7_event */ - sngss7_event = ftdm_malloc(sizeof(*sngss7_event)); - if (sngss7_event == NULL) { - SS7_ERROR("Failed to allocate memory for sngss7_event!\n"); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - memset(sngss7_event, 0x0, sizeof(*sngss7_event)); - - /* fill in the sngss7_event struct */ - sngss7_event->spInstId = spInstId; - sngss7_event->suInstId = suInstId; - sngss7_event->circuit = circuit; - sngss7_event->event_id = SNGSS7_SUSP_IND_EVENT; - if (siSuspEvnt != NULL) { - memcpy(&sngss7_event->event.siSuspEvnt, siSuspEvnt, sizeof(*siSuspEvnt)); - } - - /* enqueue this event */ - ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->signal_data)->event_queue, sngss7_event); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - -} - -/******************************************************************************/ -void sngss7_resm_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiResmEvnt *siResmEvnt) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = NULL; - ftdm_channel_t *ftdmchan = NULL; - sngss7_event_data_t *sngss7_event = NULL; - - if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) { - SS7_ERROR("Rx sig event on circuit that is not a voice CIC (%d)\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - - /* initalize the sngss7_event */ - sngss7_event = ftdm_malloc(sizeof(*sngss7_event)); - if (sngss7_event == NULL) { - SS7_ERROR("Failed to allocate memory for sngss7_event!\n"); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - memset(sngss7_event, 0x0, sizeof(*sngss7_event)); - - /* fill in the sngss7_event struct */ - sngss7_event->spInstId = spInstId; - sngss7_event->suInstId = suInstId; - sngss7_event->circuit = circuit; - sngss7_event->event_id = SNGSS7_RESM_IND_EVENT; - if (siResmEvnt != NULL) { - memcpy(&sngss7_event->event.siResmEvnt, siResmEvnt, sizeof(*siResmEvnt)); - } - - /* enqueue this event */ - ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->signal_data)->event_queue, sngss7_event); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - -} - -/******************************************************************************/ -void sngss7_ssp_sta_cfm(uint32_t infId) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); -#if 0 - sngss7_chan_data_t *sngss7_info = NULL; - ftdm_channel_t *ftdmchan = NULL; - sngss7_event_data_t *sngss7_event = NULL; - - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - - /* initalize the sngss7_event */ - sngss7_event = ftdm_malloc(sizeof(*sngss7_event)); - if (sngss7_event == NULL) { - SS7_ERROR("Failed to allocate memory for sngss7_event!\n"); - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; - } - memset(sngss7_event, 0x0, sizeof(*sngss7_event)); - - /* fill in the sngss7_event struct */ - sngss7_event->spInstId = spInstId; - sngss7_event->suInstId = suInstId; - sngss7_event->circuit = circuit; - sngss7_event->event_id = SNGSS7_RESM_IND_EVENT; - if (siSuspEvnt != NULL) { - memcpy(&sngss7_event->event.siResmEvnt, siResmEvnt, sizeof(*siResmEvnt)); - } - - /* enqueue this event */ - ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->signal_data)->event_queue, sngss7_event); -#endif - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - -} -/******************************************************************************/ -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ -/******************************************************************************/ - diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.c deleted file mode 100644 index a4c064a323..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.c +++ /dev/null @@ -1,1155 +0,0 @@ -/* - * Copyright (c) 2009|Konrad Hammel - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE|EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -/* INCLUDE ********************************************************************/ -#include "ftmod_sangoma_ss7_main.h" -/******************************************************************************/ - -/* DEFINES ********************************************************************/ -/******************************************************************************/ - -/* GLOBALS ********************************************************************/ -/******************************************************************************/ - -/* PROTOTYPES *****************************************************************/ -void handle_sng_log(uint8_t level, char *fmt,...); -void handle_sng_mtp1_alarm(Pst *pst, L1Mngmt *sta); -void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta); -void handle_sng_mtp3_alarm(Pst *pst, SnMngmt *sta); -void handle_sng_isup_alarm(Pst *pst, SiMngmt *sta); -void handle_sng_cc_alarm(Pst *pst, CcMngmt *sta); -void handle_sng_relay_alarm(Pst *pst, RyMngmt *sta); - -/******************************************************************************/ - -/* FUNCTIONS ******************************************************************/ -void handle_sng_log(uint8_t level, char *fmt,...) -{ - char *data; - int ret; - va_list ap; - - va_start(ap, fmt); - ret = vasprintf(&data, fmt, ap); - if (ret == -1) { - return; - } - - switch (level) { - /**************************************************************************/ - case SNG_LOGLEVEL_DEBUG: - ftdm_log(FTDM_LOG_DEBUG, "sng_ss7->%s", data); - break; - /**************************************************************************/ - case SNG_LOGLEVEL_WARN: - ftdm_log(FTDM_LOG_WARNING, "sng_ss7->%s", data); - break; - /**************************************************************************/ - case SNG_LOGLEVEL_INFO: - ftdm_log(FTDM_LOG_INFO, "sng_ss7->%s", data); - break; - /**************************************************************************/ - case SNG_LOGLEVEL_NOTICE: - ftdm_log(FTDM_LOG_NOTICE, "sng_ss7->%s", data); - break; - /**************************************************************************/ - case SNG_LOGLEVEL_ERROR: - ftdm_log(FTDM_LOG_ERROR, "sng_ss7->%s", data); - break; - /**************************************************************************/ - case SNG_LOGLEVEL_CRIT: - /*printf("%s",data);*/ - ftdm_log(FTDM_LOG_CRIT, "sng_ss7->%s", data); - break; - /**************************************************************************/ - default: - ftdm_log(FTDM_LOG_INFO, "sng_ss7->%s", data); - break; - /**************************************************************************/ - } - - return; -} - -/******************************************************************************/ -void handle_sng_mtp1_alarm(Pst *pst, L1Mngmt *sta) -{ - - -} /* handle_mtp1_alarm */ - -/******************************************************************************/ -void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta) -{ - char buf[50]; - int x = 1; - int log_level = FTDM_LOG_LEVEL_DEBUG; - - memset(buf, '\0', sizeof(buf)); - - switch (sta->t.usta.alarm.category) { - /**************************************************************************/ - case (LCM_CATEGORY_PROTOCOL): - case (LCM_CATEGORY_INTERFACE): - - switch (sta->t.usta.alarm.event) { - /**********************************************************************/ - case (LSD_EVENT_ENTR_CONG): - case (LSD_EVENT_EXIT_CONG): - case (LSD_EVENT_PROT_ST_UP): - case (LSD_EVENT_PROT_ST_DN): - case (LSD_EVENT_LINK_ALIGNED): - case (LSD_EVENT_REMOTE_CONG_START): - case (LSD_EVENT_REMOTE_CONG_END): - case (LSD_EVENT_RX_REMOTE_SIPO): - - /* find the name for the sap in question */ - x = 1; - while (x < (MAX_MTP_LINKS+1)) { - if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) { - break; - } - x++; - } - - if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == 0) { - sprintf(buf, "[SAPID:%d]", sta->t.usta.evntParm[0]); - } else { - sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtp2Link[x].name); - } - - - switch (sta->t.usta.alarm.cause) { - case (LCM_CAUSE_MGMT_INITIATED): - ftdm_log(FTDM_LOG_DEBUG,"[MTP2]%s[MGMT] cause:%s event:%s\n", - buf, - DECODE_LCM_CAUSE(sta->t.usta.alarm.cause), - DECODE_LSD_EVENT(sta->t.usta.alarm.event)); - break; - case (LCM_CAUSE_UNKNOWN): - default: - { - if ((LSD_EVENT_ALIGN_LOST == sta->t.usta.alarm.event) || - (LSD_EVENT_PROT_ST_DN == sta->t.usta.alarm.event)) { - log_level = FTDM_LOG_LEVEL_WARNING; - } else if ((LSD_EVENT_LINK_ALIGNED == sta->t.usta.alarm.event) || - (LSD_EVENT_PROT_ST_UP == sta->t.usta.alarm.event)){ - log_level = FTDM_LOG_LEVEL_INFO; - } else { - log_level = FTDM_LOG_LEVEL_WARNING; - } - ftdm_log(FTDM_PRE, log_level,"[MTP2]%s cause:%s event:%s\n", - buf, - DECODE_LCM_CAUSE(sta->t.usta.alarm.cause), - DECODE_LSD_EVENT(sta->t.usta.alarm.event)); - break; - } - /******************************************************************/ - } /* switch (sta->t.usta.alarm.cause) */ - break; - /**********************************************************************/ - case (LSD_EVENT_PROT_ERR): - - /* find the name for the sap in question */ - x = 1; - while (x < (MAX_MTP_LINKS+1)) { - if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) { - break; - } - x++; - } - - if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == 0) { - sprintf(buf, "[SAPID:%d]", sta->t.usta.evntParm[0]); - } else { - sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtp2Link[x].name); - } - - ftdm_log(FTDM_LOG_WARNING,"[MTP2]%s %s : %s\n", - buf, - DECODE_LSD_EVENT(sta->t.usta.alarm.event), - DECODE_LSD_CAUSE(sta->t.usta.alarm.cause)); - break; - /**********************************************************************/ - case (LSD_EVENT_ALIGN_LOST): - - /* find the name for the sap in question */ - x = 1; - while (x < (MAX_MTP_LINKS+1)) { - if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) { - break; - } - x++; - } - - if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == 0) { - sprintf(buf, "[SAPID:%d]", sta->t.usta.evntParm[0]); - } else { - sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtp2Link[x].name); - } - - ftdm_log(FTDM_LOG_WARNING,"[MTP2]%s %s : %s\n", - buf, - DECODE_LSD_EVENT(sta->t.usta.alarm.event), - DECODE_DISC_REASON(sta->t.usta.evntParm[1])); - break; - /**********************************************************************/ - case (LSD_EVENT_RTB_FULL): - case (LSD_EVENT_RTB_FULL_OVER): - - /* find the name for the sap in question */ - x = 1; - while (x < (MAX_MTP_LINKS+1)) { - if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) { - break; - } - x++; - } - - if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == 0) { - sprintf(buf, "[SAPID:%d]", sta->t.usta.evntParm[0]); - } else { - sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtp2Link[x].name); - } - - ftdm_log(FTDM_LOG_WARNING,"[MTP2]%s %s : RTB Queue Len(%d)|Oldest BSN(%d)|Tx Queue Len(%d)|Outstanding Frames(%d)\n", - buf, - DECODE_LSD_EVENT(sta->t.usta.alarm.event), - sta->t.usta.evntParm[1], - sta->t.usta.evntParm[2], - sta->t.usta.evntParm[3], - sta->t.usta.evntParm[4]); - break; - /**********************************************************************/ - case (LSD_EVENT_NEG_ACK): - - /* find the name for the sap in question */ - x = 1; - while (x < (MAX_MTP_LINKS+1)) { - if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) { - break; - } - x++; - } - - if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == 0) { - sprintf(buf, "[SAPID:%d]", sta->t.usta.evntParm[0]); - } else { - sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtp2Link[x].name); - } - - ftdm_log(FTDM_LOG_WARNING,"[MTP2]%s %s : RTB Queue Len(%d)\n", - buf, - DECODE_LSD_EVENT(sta->t.usta.alarm.event), - sta->t.usta.evntParm[1]); - break; - /**********************************************************************/ - case (LSD_EVENT_DAT_CFM_SDT): - - /* find the name for the sap in question */ - x = 1; - while (x < (MAX_MTP_LINKS+1)) { - if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) { - break; - } - x++; - } - - if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == 0) { - sprintf(buf, "[SAPID:%d]", sta->t.usta.evntParm[0]); - } else { - sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtp2Link[x].name); - } - - ftdm_log(FTDM_LOG_WARNING,"[MTP2]%s %s : %s\n", - buf, - DECODE_LSD_EVENT(sta->t.usta.alarm.event), - DECODE_DISC_REASON(sta->t.usta.evntParm[1])); - break; - /**********************************************************************/ - case (LCM_EVENT_UI_INV_EVT): - case (LCM_EVENT_LI_INV_EVT): - ftdm_log(FTDM_LOG_WARNING,"[MTP2] %s(%d) : %s(%d) : Primitive (%d)\n", - DECODE_LSD_EVENT(sta->t.usta.alarm.event), - sta->t.usta.alarm.event, - DECODE_LCM_CAUSE(sta->t.usta.alarm.cause), - sta->t.usta.alarm.cause, - sta->t.usta.evntParm[0]); - break; - /**********************************************************************/ - case (LCM_EVENT_INV_EVT): - - switch (sta->t.usta.alarm.cause) { - /******************************************************************/ - case (LCM_CAUSE_UNKNOWN): - case (LCM_CAUSE_SWVER_NAVAIL): - ftdm_log(FTDM_LOG_WARNING,"[MTP2] %s : %s : Event (%d)\n", - DECODE_LSD_EVENT(sta->t.usta.alarm.event), - DECODE_LCM_CAUSE(sta->t.usta.alarm.cause), - sta->t.usta.evntParm[0]); - break; - /******************************************************************/ - case (LCM_CAUSE_DECODE_ERR): - ftdm_log(FTDM_LOG_WARNING,"[MTP2] %s : %s : Primitive (%d)|Version (%d)\n", - DECODE_LSD_EVENT(sta->t.usta.alarm.event), - DECODE_LCM_CAUSE(sta->t.usta.alarm.cause), - sta->t.usta.evntParm[0], - sta->t.usta.evntParm[1]); - break; - /******************************************************************/ - default: - ftdm_log(FTDM_LOG_WARNING,"[MTP2] %s(%d) : %s(%d)\n", - DECODE_LSD_EVENT(sta->t.usta.alarm.event), - sta->t.usta.alarm.event, - DECODE_LSD_CAUSE(sta->t.usta.alarm.cause), - sta->t.usta.alarm.cause); - break; - /******************************************************************/ - } /* switch (sta->t.usta.alarm.cause) */ - break; - /**********************************************************************/ - default: - ftdm_log(FTDM_LOG_WARNING,"[MTP2] %s(%d) : %s(%d)\n", - DECODE_LSD_EVENT(sta->t.usta.alarm.event), - sta->t.usta.alarm.event, - DECODE_LSD_CAUSE(sta->t.usta.alarm.cause), - sta->t.usta.alarm.cause); - break; - /**********************************************************************/ - } /* switch (sta->t.usta.alarm.event) */ - break; - /**************************************************************************/ - default: - ftdm_log(FTDM_LOG_ERROR,"[MTP2] Unknown alarm category %d\n", - sta->t.usta.alarm.category); - break; - /**************************************************************************/ - } /* switch(sta->t.usta.alarm.category) */ - - return; -} /* handle_mtp2_alarm */ - -/******************************************************************************/ -void handle_sng_mtp3_alarm(Pst *pst, SnMngmt *sta) -{ - char buf[50]; - int x = 1; - - SS7_RELAY_DBG_FUN(handle_sng_mtp3_alarm); - - memset(buf, '\0', sizeof(buf)); - - switch (sta->hdr.elmId.elmnt) { - /**************************************************************************/ - case (STDLSAP): - - /* find the name for the sap in question */ - x = 1; - while (x < (MAX_MTP_LINKS+1)) { - if (g_ftdm_sngss7_data.cfg.mtp3Link[x].id == sta->hdr.elmId.elmntInst1) { - break; - } - x++; - } - - if (g_ftdm_sngss7_data.cfg.mtp3Link[x].id == 0) { - sprintf(buf, "[SAPID:%d]", sta->hdr.elmId.elmntInst1); - } else { - sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtp3Link[x].name); - } - - switch (sta->t.usta.alarm.event) { - /**********************************************************************/ - case (LSN_EVENT_INV_OPC_OTHER_END): - - ftdm_log(FTDM_LOG_WARNING,"[MTP3]%s %s : %s : OPC(0x%X%X%X%X)\n", - buf, - DECODE_LSN_EVENT(sta->t.usta.alarm.event), - DECODE_LSN_CAUSE(sta->t.usta.alarm.cause), - sta->t.usta.evntParm[3], - sta->t.usta.evntParm[2], - sta->t.usta.evntParm[1], - sta->t.usta.evntParm[0]); - break; - /**********************************************************************/ - case (LSN_EVENT_INV_SLC_OTHER_END): - ftdm_log(FTDM_LOG_WARNING,"[MTP3]%s %s : %s : SLC(%d)\n", - buf, - DECODE_LSN_EVENT(sta->t.usta.alarm.event), - DECODE_LSN_CAUSE(sta->t.usta.alarm.cause), - sta->t.usta.evntParm[0]); - break; - /**********************************************************************/ - default: - ftdm_log(FTDM_LOG_WARNING,"[MTP3]%s %s(%d) : %s(%d)\n", - buf, - DECODE_LSN_EVENT(sta->t.usta.alarm.event), - sta->t.usta.alarm.event, - DECODE_LSN_CAUSE(sta->t.usta.alarm.cause), - sta->t.usta.alarm.cause); - break; - /**********************************************************************/ - } /* sta->t.usta.alarm.event */ - break; - /**************************************************************************/ - case (STNSAP): - ftdm_log(FTDM_LOG_WARNING,"[MTP3][SAPID:%d] %s : %s\n", - sta->hdr.elmId.elmntInst1, - DECODE_LSN_EVENT(sta->t.usta.alarm.event), - DECODE_LSN_CAUSE(sta->t.usta.alarm.cause)); - break; - /**************************************************************************/ - case (STLNKSET): - ftdm_log(FTDM_LOG_DEBUG,"[MTP3][LNKSET:%d] %s : %s\n", - sta->hdr.elmId.elmntInst1, - DECODE_LSN_EVENT(sta->t.usta.alarm.event), - DECODE_LSN_CAUSE(sta->t.usta.alarm.cause)); - break; - /**************************************************************************/ - case (STROUT): - switch (sta->t.usta.alarm.event) { - /**********************************************************************/ - case (LSN_EVENT_RX_TRANSFER_MSG): - switch (sta->t.usta.evntParm[5]) { - /******************************************************************/ - case (0x23): - ftdm_log(FTDM_LOG_INFO,"[MTP3] Rx SNM TFC\n"); - break; - /******************************************************************/ - case (0x34): - ftdm_log(FTDM_LOG_INFO,"[MTP3] Rx SNM TFR\n"); - break; - /******************************************************************/ - case (0x54): - ftdm_log(FTDM_LOG_INFO,"[MTP3] Rx SNM TFA\n"); - break; - /******************************************************************/ - case (0x14): - ftdm_log(FTDM_LOG_INFO,"[MTP3] Rx SNM TFP\n"); - break; - /******************************************************************/ - case (0x24): - ftdm_log(FTDM_LOG_INFO,"[MTP3] Rx SNM TFP (cluster)\n"); - break; - /******************************************************************/ - case (0x64): - ftdm_log(FTDM_LOG_INFO,"[MTP3] Rx SNM TFA (cluster)\n"); - break; - /******************************************************************/ - case (0x44): - ftdm_log(FTDM_LOG_INFO,"[MTP3] Rx SNM TFR (cluster)\n"); - break; - /******************************************************************/ - } /* switch (sta->t.usta.evntParm[5]) */ - break; - /**********************************************************************/ - default: - ftdm_log(FTDM_LOG_WARNING,"[MTP3][DPC:0x%X%X%X%X] %s : %s\n", - sta->t.usta.evntParm[0], - sta->t.usta.evntParm[1], - sta->t.usta.evntParm[2], - sta->t.usta.evntParm[3], - DECODE_LSN_EVENT(sta->t.usta.alarm.event), - DECODE_LSN_CAUSE(sta->t.usta.alarm.cause)); - break; - /**********************************************************************/ - } /* switch (sta->t.usta.alarm.event) */ - break; - /**************************************************************************/ - default: - ftdm_log(FTDM_LOG_ERROR,"[MTP3] %s(%d) : %s(%d)\n", - DECODE_LSN_EVENT(sta->t.usta.alarm.event), - sta->t.usta.alarm.event, - DECODE_LSN_CAUSE(sta->t.usta.alarm.cause), - sta->t.usta.alarm.cause); - break; - /**************************************************************************/ - } /* switch (sta->hdr.elmId.elmnt) */ - - return; -} /* handle_mtp3_alarm */ - -/******************************************************************************/ -void handle_sng_isup_alarm(Pst *pst, SiMngmt *sta) -{ - char msg[250]; - char tmp[25]; - char *p = NULL; - int x = 0; - - SS7_RELAY_DBG_FUN(handle_sng_isup_alarm); - - /* initalize the msg variable to NULLs */ - memset(&msg[0], '\0', sizeof(&msg)); - - /* if the event is REMOTE/LOCAL we don't need to print these */ - if ((sta->t.usta.alarm.event == LSI_EVENT_REMOTE) || - (sta->t.usta.alarm.event == LSI_EVENT_LOCAL)) { - return; - } - - /* point p to the first spot in msg */ - p = &msg[0]; - - p = strcat(p, "[ISUP]"); - - /* go through the dgnVals */ - for (x = 0; x < 5; x++) { - switch (sta->t.usta.dgn.dgnVal[x].type) { - /**********************************************************************/ - case (LSI_USTA_DGNVAL_NONE): - break; - /**********************************************************************/ - case (LSI_USTA_DGNVAL_EVENT): - /* init tmp with NULLs */ - memset(&tmp[0], '\0', sizeof(&tmp)); - - /* fill in the dgn val to tmp */ - sprintf(&tmp[0], "[EVENT:%d]",sta->t.usta.dgn.dgnVal[x].t.event); - - /* concat tmp to msg */ - p = strcat(p, &tmp[0]); - break; - /**********************************************************************/ - case (LSI_USTA_DGNVAL_SPID): - /* init tmp with NULLs */ - memset(&tmp[0], '\0', sizeof(&tmp)); - - /* fill in the dgn val to tmp */ - sprintf(&tmp[0], "[SPID:%d]",sta->t.usta.dgn.dgnVal[x].t.spId); - - /* concat tmp to msg */ - p = strcat(p, &tmp[0]); - break; - /**********************************************************************/ - case (LSI_USTA_DGNVAL_SUID): - /* init tmp with NULLs */ - memset(&tmp[0], '\0', sizeof(&tmp)); - - /* fill in the dgn val to tmp */ - sprintf(&tmp[0], "[SUID:%d]",sta->t.usta.dgn.dgnVal[x].t.suId); - - /* concat tmp to msg */ - p = strcat(p, &tmp[0]); - break; - /**********************************************************************/ - case (LSI_USTA_DGNVAL_SPINSTID): - /* init tmp with NULLs */ - memset(&tmp[0], '\0', sizeof(&tmp)); - - /* fill in the dgn val to tmp */ - sprintf(&tmp[0], "[SPINSTID:%d]", (int)sta->t.usta.dgn.dgnVal[x].t.spInstId); - - /* concat tmp to msg */ - p = strcat(p, &tmp[0]); - break; - /**********************************************************************/ - case (LSI_USTA_DGNVAL_SUINSTID): - /* init tmp with NULLs */ - memset(&tmp[0], '\0', sizeof(&tmp)); - - /* fill in the dgn val to tmp */ - sprintf(&tmp[0], "[SUINSTID:%d]", (int)sta->t.usta.dgn.dgnVal[x].t.suInstId); - - /* concat tmp to msg */ - p = strcat(p, &tmp[0]); - break; - /**********************************************************************/ - case (LSI_USTA_DGNVAL_CIRCUIT): - /* init tmp with NULLs */ - memset(&tmp[0], '\0', sizeof(&tmp)); - - /* fill in the dgn val to tmp */ - sprintf(&tmp[0], "[CKT:%d]", (int)sta->t.usta.dgn.dgnVal[x].t.cirId); - - /* concat tmp to msg */ - p = strcat(p, &tmp[0]); - break; - /**********************************************************************/ - case (LSI_USTA_DGNVAL_CIC): - /* init tmp with NULLs */ - memset(&tmp[0], '\0', sizeof(&tmp)); - - /* fill in the dgn val to tmp */ - sprintf(&tmp[0], "[CIC:%d]", (int)sta->t.usta.dgn.dgnVal[x].t.cic); - - /* concat tmp to msg */ - p = strcat(p, &tmp[0]); - break; - /**********************************************************************/ - case (LSI_USTA_DGNVAL_INTF): - /* init tmp with NULLs */ - memset(&tmp[0], '\0', sizeof(&tmp)); - - /* fill in the dgn val to tmp */ - sprintf(&tmp[0], "[INTF:%d]", (int)sta->t.usta.dgn.dgnVal[x].t.intfId); - - /* concat tmp to msg */ - p = strcat(p, &tmp[0]); - break; - /**********************************************************************/ - case (LSI_USTA_DGNVAL_DPC): - /* init tmp with NULLs */ - memset(&tmp[0], '\0', sizeof(&tmp)); - - /* fill in the dgn val to tmp */ - sprintf(&tmp[0], "[DPC:%d]", (int)sta->t.usta.dgn.dgnVal[x].t.dpc); - - /* concat tmp to msg */ - p = strcat(p, &tmp[0]); - break; - /**********************************************************************/ - case (LSI_USTA_DGNVAL_ADDRS): -#if 0 - /* - *typedef struct addrs - *{ - *U8 length; - *U8 strg[ADRLEN]; - *} Addrs; - */ - /* init tmp with NULLs */ - memset(&tmp[0], '\0', sizeof(&tmp)); - - /* fill in the dgn val to tmp */ - sprintf(&tmp[0], "[ADDRS:%d]",sta->t.usta.dgn.dgnVal[x].t.); - - /* concat tmp to msg */ - p = strcat(p, &tmp[0]); -#endif - break; - /**********************************************************************/ - case (LSI_USTA_DGNVAL_SWTCH): - /* init tmp with NULLs */ - memset(&tmp[0], '\0', sizeof(&tmp)); - - /* fill in the dgn val to tmp */ - sprintf(&tmp[0], "[SWTCH:%d]",sta->t.usta.dgn.dgnVal[x].t.swtch); - - /* concat tmp to msg */ - p = strcat(p, &tmp[0]); - break; - /**********************************************************************/ - case (LSI_USTA_DGNVAL_RANGE): - /* init tmp with NULLs */ - memset(&tmp[0], '\0', sizeof(&tmp)); - - /* fill in the dgn val to tmp */ - sprintf(&tmp[0], "[RANGE:0x%X]",sta->t.usta.dgn.dgnVal[x].t.range); - - /* concat tmp to msg */ - p = strcat(p, &tmp[0]); - break; - /**********************************************************************/ - case (LSI_USTA_DGNVAL_STATUS_OCTS): -#if 0 - /* - *typedef struct addrs - *{ - *U8 length; - *U8 strg[ADRLEN]; - *} Addrs; - */ - /* init tmp with NULLs */ - /* init tmp with NULLs */ - memset(&tmp[0], '\0', sizeof(&tmp)); - - /* fill in the dgn val to tmp */ - sprintf(&tmp[0], "[STATUS_OCT:0x%X]",sta->t.usta.dgn.dgnVal[x].t.); - - /* concat tmp to msg */ - p = strcat(p, &tmp[0]); -#endif - break; - /**********************************************************************/ - case (LSI_USTA_DGNVAL_VER): -#ifdef SI_RUG - /* init tmp with NULLs */ - memset(&tmp[0], '\0', sizeof(&tmp)); - - /* fill in the dgn val to tmp */ - sprintf(&tmp[0], "[VER:%d]",sta->t.usta.dgn.dgnVal[x].t.intfVer); - - /* concat tmp to msg */ - p = strcat(p, &tmp[0]); -#endif - break; - /**********************************************************************/ - case (LSI_USTA_DGNVAL_TIMER): - /* init tmp with NULLs */ - memset(&tmp[0], '\0', sizeof(&tmp)); - - /* fill in the dgn val to tmp */ - sprintf(&tmp[0], "[TIMER:0x%X]",sta->t.usta.dgn.dgnVal[x].t.tmrInfo); - - /* concat tmp to msg */ - p = strcat(p, &tmp[0]); - break; - /**********************************************************************/ - case (LSI_USTA_DGNVAL_MSGTYPE): - /* init tmp with NULLs */ - memset(&tmp[0], '\0', sizeof(&tmp)); - - /* fill in the dgn val to tmp */ - sprintf(&tmp[0], "[MSGTYPE:%d]",sta->t.usta.dgn.dgnVal[x].t.msgType); - - /* concat tmp to msg */ - p = strcat(p, &tmp[0]); - break; - /**********************************************************************/ - case (LSI_USTA_DGNVAL_STATE): - /* init tmp with NULLs */ - memset(&tmp[0], '\0', sizeof(&tmp)); - - /* fill in the dgn val to tmp */ - sprintf(&tmp[0], "[STATE:%d]",sta->t.usta.dgn.dgnVal[x].t.state); - - /* concat tmp to msg */ - p = strcat(p, &tmp[0]); - break; - /**********************************************************************/ - default: - break; - /**********************************************************************/ - } /* switch (sta->t.usta.dgn.dgnVal[x].t.type) */ - } /* for (x = 0; x < 5; x++) */ - - ftdm_log(FTDM_LOG_WARNING,"%s %s : %s\n", - msg, - DECODE_LSI_EVENT(sta->t.usta.alarm.event), - DECODE_LSI_CAUSE(sta->t.usta.alarm.cause)); - - return; - -} /* handle_isup_alarm */ - -/******************************************************************************/ -void handle_sng_cc_alarm(Pst *pst, CcMngmt *sta) -{ - - SS7_RELAY_DBG_FUN(handle_sng_cc_alarm); - return; -} /* handle_cc_alarm */ - -/******************************************************************************/ -void handle_sng_relay_alarm(Pst *pst, RyMngmt *sta) -{ - - SS7_RELAY_DBG_FUN(handle_sng_relay_alarm); - - switch (sta->hdr.elmId.elmnt) { - /**************************************************************************/ - case (LRY_USTA_ERR): /* ERROR */ - ftdm_log(FTDM_LOG_WARNING,"[RELAY] Error: tx procId %d: err procId %d: channel %d: seq %s: reason %s\n", - sta->t.usta.s.ryErrUsta.sendPid, - sta->t.usta.s.ryErrUsta.errPid, - sta->t.usta.s.ryErrUsta.id, - DECODE_LRY_SEQ(sta->t.usta.s.ryErrUsta.sequence), - DECODE_LRY_REASON(sta->t.usta.s.ryErrUsta.reason)); - - /* process the event */ - switch (sta->t.usta.s.ryErrUsta.reason) { - /**********************************************************************/ - case (LRYRSNMGMTREQ): - /* do nothing since this is a shutdown */ - break; - /**********************************************************************/ - default: - /* handle the error */ - handle_relay_disconnect_on_error(sta); - break; - /**********************************************************************/ - } /* switch (sta->t.usta.s.ryErrUsta.reason) */ - - break; - /**************************************************************************/ - case (LRY_USTA_CNG): /* Congestion */ - ftdm_log(FTDM_LOG_WARNING,"[RELAY] Congestion: tx procId %d: rem procId %d: channel %d: %s\n", - sta->t.usta.s.ryCongUsta.sendPid, - sta->t.usta.s.ryCongUsta.remPid, - sta->t.usta.s.ryCongUsta.id, - DECODE_LRY_CONG_FLAGS(sta->t.usta.s.ryCongUsta.flags)); - break; - /**************************************************************************/ - case (LRY_USTA_UP): /* channel up */ - ftdm_log(FTDM_LOG_INFO,"[RELAY] Channel UP: tx procId %d: channel %d\n", - sta->t.usta.s.ryUpUsta.sendPid, - sta->t.usta.s.ryUpUsta.id); - - /* process the event */ - handle_relay_connect(sta); - - break; - /**************************************************************************/ - case (LRY_USTA_DN): /* channel down */ - ftdm_log(FTDM_LOG_WARNING,"[RELAY] Channel DOWN: tx procId %d: channel %d\n", - sta->t.usta.s.ryUpUsta.sendPid, - sta->t.usta.s.ryUpUsta.id); - - /* process the event */ - handle_relay_disconnect_on_down(sta); - - break; - /**************************************************************************/ - case (LRY_USTA_TCP_CONN_FAILED): - ftdm_log(FTDM_LOG_WARNING,"[RELAY] TCP connection failed \n" ); - - break; - /**************************************************************************/ - default: - ftdm_log(FTDM_LOG_ERROR,"Unknown Relay Alram\n"); - break; - /**************************************************************************/ - } /* switch (sta->hdr.elmId.elmnt) */ - - return; -} - -/******************************************************************************/ -void handle_sng_m2ua_alarm(Pst *pst, MwMgmt *sta) -{ - /* To print the general information */ - ftdm_log(FTDM_LOG_INFO, "Recieved a status indication from M2UA layer \n\n"); - ftdm_log(FTDM_LOG_INFO," Category = %d , event = %d , cause = %d\n", - sta->t.usta.alarm.category, sta->t.usta.alarm.event, sta->t.usta.alarm.cause); - - - /* To print the affected element value */ - switch(sta->hdr.elmId.elmnt) - { - case STMWDLSAP: - { - ftdm_log(FTDM_LOG_INFO," STMWDLSAP: with lnkNmb (%d) \n\n", - sta->t.usta.s.lnkNmb); - break; - } - case STMWSCTSAP: - { - ftdm_log(FTDM_LOG_INFO," STMWSCTSAP: suId (%d) \n\n", - sta->t.usta.s.suId); - break; - } - case STMWPEER: - { - ftdm_log(FTDM_LOG_INFO," STMWPEER: peerId (%d) \n\n", - sta->t.usta.s.peerId); - break; - } - case STMWCLUSTER: - { - ftdm_log(FTDM_LOG_INFO," STMWCLUSTER: clusterId (%d) \n\n", - sta->t.usta.s.peerId); - break; - } - default: - { - ftdm_log(FTDM_LOG_ERROR, "[MW_USTA]: Invalid element \n\n"); - break; - } - } - - /* To print the event specific information */ - switch(sta->t.usta.alarm.event) - { - case LMW_EVENT_TERM_OK: - { - ftdm_log(FTDM_LOG_INFO," M2UA : LMW_EVENT_TERM_OK: Association Terminated with PeerId[%d] \n",sta->t.usta.s.peerId); - break; - } - case LMW_EVENT_ENDPOPEN_OK: - { - ftdm_log(FTDM_LOG_INFO," M2UA : LMW_EVENT_ENDPOPEN_OK: \n"); - break; - } - case LMW_EVENT_ESTABLISH_OK: - { - ftdm_log(FTDM_LOG_INFO," M2UA : LMW_EVENT_ESTABLISH_OK Event raised on peerId[%d]\n",sta->t.usta.s.peerId); - break; - } - case LMW_EVENT_ESTABLISH_FAIL: - { - ftdm_log(FTDM_LOG_INFO," M2UA : LMW_EVENT_ESTABLISH_FAIL Event raised on peerId[%d]\n",sta->t.usta.s.peerId); - break; - } - case LMW_EVENT_ASPM: - { - ftdm_log(FTDM_LOG_INFO," M2UA : LMW_EVENT_ASPM Event raised with peerId (%d)," - " msgType (%d)\n\n",sta->t.usta.s.peerId, - sta->t.usta.t.aspm.msgType); - break; - } - case LMW_EVENT_CLUSTER: - { - ftdm_log(FTDM_LOG_INFO," M2UA : LMW_EVENT_CLUSTER Event raised on clusterId (%d), state (%d)\n\n", - sta->t.usta.s.clusterId, sta->t.usta.t.cluster.state); - - break; - } - case LMW_EVENT_NOTIFY: - { - ftdm_log(FTDM_LOG_INFO," M2UA : LMW_EVENT_NOTIFY: peerId (%d), aspId (%u), ntfy status type (%d)," - " ntfy status id (%d)\n\n", sta->t.usta.s.peerId, - (uint32_t) sta->t.usta.t.ntfy.aspId, sta->t.usta.t.ntfy.stType, - sta->t.usta.t.ntfy.stId); - - break; - } - - - case LMW_EVENT_M2UA_PROTO_ERROR: - { - ftdm_log(FTDM_LOG_ERROR, " M2UA : LMW_EVENT_M2UA_PROTO_ERROR with errorCode (%u)\n\n", - (uint32_t) sta->t.usta.t.error.errCode); - break; - } - default: - break; - } - -} /* handle_sng_m2ua_alarm */ - -/******************************************************************************/ -void handle_sng_nif_alarm(Pst *pst, NwMgmt *sta) -{ - /* To print the general information */ - ftdm_log(FTDM_LOG_INFO," Recieved a status indication from NIF layer\n"); - ftdm_log(FTDM_LOG_INFO," Category = %d , event = %d , cause = %d\n", sta->t.usta.alarm.category, - sta->t.usta.alarm.event, sta->t.usta.alarm.cause); - - switch(sta->hdr.elmId.elmnt) - { - case STNWDLSAP: - { - ftdm_log(FTDM_LOG_INFO," Recieved STNWDLSAP status indication for suId (%d) \n", sta->t.usta.suId); - switch(sta->t.usta.alarm.event) - { - case LCM_EVENT_LI_INV_EVT: - { - switch(sta->t.usta.alarm.cause) - { - case LCM_CAUSE_INV_SAP: - { - ftdm_log(FTDM_LOG_ERROR, " LCM_CAUSE_INV_SAP Alarm \n"); - break; - } - case LCM_CAUSE_INV_STATE: - { - ftdm_log(FTDM_LOG_ERROR, " LCM_CAUSE_INV_STATE Alarm \n"); - break; - } - default: - break; - } - break; - } - case LCM_EVENT_BND_OK: - { - ftdm_log(FTDM_LOG_INFO," NIF: LCM_EVENT_BND_OK Alarm \n"); - break; - } - case LCM_EVENT_BND_FAIL: - { - ftdm_log(FTDM_LOG_INFO," NIF: LCM_EVENT_BND_FAIL Alarm \n"); - break; - } - default: - break; - } - break; - } - default: - break; - } -} /* handle_sng_nif_alarm */ - -/******************************************************************************/ -void handle_sng_tucl_alarm(Pst *pst, HiMngmt *sta) -{ - /* To print the general information */ - ftdm_log(FTDM_LOG_INFO, "Recieved a status indication from TUCL layer \n\n"); - ftdm_log(FTDM_LOG_INFO, " Category = %d , event = %d , cause = %d\n", - sta->t.usta.alarm.category, - sta->t.usta.alarm.event, sta->t.usta.alarm.cause); - - switch(sta->t.usta.alarm.event) - { - case LCM_EVENT_INV_EVT: - { - ftdm_log(FTDM_LOG_INFO," [HI_USTA]: LCM_EVENT_INV_EVT with type (%d)\n\n", - sta->t.usta.info.type); - break; - } - case LHI_EVENT_BNDREQ: - { - ftdm_log(FTDM_LOG_INFO," [HI_USTA]: LHI_EVENT_BNDREQ with type (%d) spId (%d)\n\n", - sta->t.usta.info.type, sta->t.usta.info.spId); - break; - } - case LHI_EVENT_SERVOPENREQ: - case LHI_EVENT_DATREQ: - case LHI_EVENT_UDATREQ: - case LHI_EVENT_CONREQ: - case LHI_EVENT_DISCREQ: -#if(defined(HI_TLS) && defined(HI_TCP_TLS)) - case LHI_EVENT_TLS_ESTREQ: -#endif - { - ftdm_log(FTDM_LOG_INFO," [HI_USTA]: partype (%d) type(%d)\n\n", - sta->t.usta.info.inf.parType, sta->t.usta.info.type); - break; - } - case LCM_EVENT_DMEM_ALLOC_FAIL: - case LCM_EVENT_SMEM_ALLOC_FAIL: - { - ftdm_log(FTDM_LOG_ERROR," [HI_USTA]: MEM_ALLOC_FAIL with region(%d) pool (%d) type(%d)\n\n", - sta->t.usta.info.inf.mem.region, sta->t.usta.info.inf.mem.pool, - sta->t.usta.info.type); - break; - } - default: - break; - } - -} /* handle_sng_tucl_alarm */ - -/******************************************************************************/ -void handle_sng_sctp_alarm(Pst *pst, SbMgmt *sta) -{ - ftdm_log(FTDM_LOG_INFO, "Recieved a status indication from SCTP layer \n\n"); - ftdm_log(FTDM_LOG_INFO," Category = %d , event = %d , cause = %d " - " [SB_USTA]: sapId (%d) and swtch (%d)\n", - sta->t.usta.alarm.category, - sta->t.usta.alarm.event, sta->t.usta.alarm.cause, - sta->t.usta.sapId, sta->t.usta.swtch); - - switch(sta->t.usta.alarm.category) - { - case LCM_CATEGORY_INTERFACE: - { - switch(sta->t.usta.alarm.cause) - { - case LCM_CAUSE_INV_SPID: - { - ftdm_log(FTDM_LOG_ERROR, "SCTP : LCM_CAUSE_INV_SPID Alarm \n"); - break; - } - case LCM_CAUSE_SWVER_NAVAIL: - { - ftdm_log(FTDM_LOG_ERROR, "SCTP : LCM_CAUSE_SWVER_NAVAIL Alarm\n"); - break; - } - case LCM_CAUSE_INV_PAR_VAL: - { - ftdm_log(FTDM_LOG_ERROR, "SCTP : LCM_CAUSE_INV_PAR_VAL Alarm\n"); - break; - } - case LCM_CAUSE_INV_SUID: - { - ftdm_log(FTDM_LOG_ERROR, "SCTP : LCM_CAUSE_INV_SUID Alarm\n"); - break; - } - case LCM_CAUSE_INV_SAP: - { - ftdm_log(FTDM_LOG_ERROR, "SCTP : LCM_CAUSE_INV_SAP Alarm\n"); - break; - } - default: - break; - } - - break; - } - case LCM_CATEGORY_RESOURCE: - { - switch(sta->t.usta.alarm.cause) - { - case LCM_CAUSE_MEM_ALLOC_FAIL: - { - ftdm_log(FTDM_LOG_ERROR, "SCTP : LCM_CAUSE_MEM_ALLOC_FAIL Alarm \n"); - break; - } - case LSB_CAUSE_NUM_ADDR_EXCEED: - { - ftdm_log(FTDM_LOG_ERROR, "SCTP : LSB_CAUSE_NUM_ADDR_EXCEED Alarm\n"); - break; - } - default: - break; - } - break; - } - case LCM_CATEGORY_PROTOCOL: - { - switch(sta->t.usta.alarm.cause) - { - case LSB_CAUSE_PATH_FAILURE: - { - ftdm_log(FTDM_LOG_ERROR, "SCTP : LSB_CAUSE_PATH_FAILURE Alarm \n"); - break; - } - case LSB_CAUSE_PATH_ACTIVE: - { - ftdm_log(FTDM_LOG_ERROR, "SCTP : LSB_CAUSE_PATH_ACTIVE Alarm \n"); - break; - } - case LSB_CAUSE_UNRSLVD_ADDR: - { - ftdm_log(FTDM_LOG_ERROR, "SCTP : LSB_CAUSE_UNRSLVD_ADDR Alarm \n"); - break; - } - default: - break; - } - break; - } - default: - break; - } - -} /* handle_sng_sctp_alarm */ -/******************************************************************************/ - - -/******************************************************************************/ -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ -/******************************************************************************/ diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_m2ua.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_m2ua.c deleted file mode 100644 index 810c5a2902..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_m2ua.c +++ /dev/null @@ -1,1773 +0,0 @@ -/* - * Copyright (c) 2012, Kapil Gupta - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - * Contributors: - * - * - */ - -/* INCLUDE ********************************************************************/ -#include "ftmod_sangoma_ss7_main.h" -/******************************************************************************/ - -/* DEFINES ********************************************************************/ -/******************************************************************************/ -/* FUNCTION PROTOTYPES ********************************************************/ -static int ftmod_tucl_gen_config(void); -static int ftmod_tucl_sap_config(int id); -static int ftmod_sctp_gen_config(void); -static int ftmod_cfg_sctp(void); -static int ftmod_sctp_config(int id); -static ftdm_status_t ftmod_sctp_sap_config(int id); -static ftdm_status_t ftmod_sctp_tsap_config(int id); -static int ftmod_m2ua_gen_config(void); -static int ftmod_m2ua_sctsap_config(int sct_sap_id, int sctp_id); -static int ftmod_m2ua_peer_config(int id); -static int ftmod_m2ua_peer_config1(int m2ua_inf_id, int peer_id); -static int ftmod_m2ua_cluster_config(int idx); -static int ftmod_m2ua_dlsap_config(int idx); -static int ftmod_nif_gen_config(void); -static int ftmod_nif_dlsap_config(int idx); -static int ftmod_sctp_tucl_tsap_bind(int idx); -static int ftmod_m2ua_sctp_sctsap_bind(int idx); -static int ftmod_open_endpoint(int idx); -static int ftmod_init_sctp_assoc(int peer_id); -static int ftmod_nif_m2ua_dlsap_bind(int id); -static int ftmod_nif_mtp2_dlsap_bind(int id); -static int ftmod_m2ua_debug(int action); -static int ftmod_tucl_debug(int action); -static int ftmod_sctp_debug(int action); - -static int ftmod_ss7_sctp_shutdown(void); -static int ftmod_ss7_m2ua_shutdown(void); -static int ftmod_ss7_tucl_shutdown(void); - - -/******************************************************************************/ -ftdm_status_t ftmod_ss7_m2ua_init(void) -{ - /****************************************************************************************************/ - if (sng_isup_init_nif()) { - ftdm_log (FTDM_LOG_ERROR , "Failed to start NIF\n"); - return FTDM_FAIL; - } else { - ftdm_log (FTDM_LOG_INFO ,"Started NIF!\n"); - } - /****************************************************************************************************/ - - if (sng_isup_init_m2ua()) { - ftdm_log (FTDM_LOG_ERROR ,"Failed to start M2UA\n"); - return FTDM_FAIL; - } else { - ftdm_log (FTDM_LOG_INFO ,"Started M2UA!\n"); - } - /****************************************************************************************************/ - - if (sng_isup_init_sctp()) { - ftdm_log (FTDM_LOG_ERROR ,"Failed to start SCTP\n"); - return FTDM_FAIL; - } else { - ftdm_log (FTDM_LOG_INFO ,"Started SCTP!\n"); - } - /****************************************************************************************************/ - - if (sng_isup_init_tucl()) { - ftdm_log (FTDM_LOG_ERROR ,"Failed to start TUCL\n"); - return FTDM_FAIL; - } else { - ftdm_log (FTDM_LOG_INFO ,"Started TUCL!\n"); - sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_TUCL_PRESENT); - } - /****************************************************************************************************/ - - if(ftmod_tucl_gen_config()){ - ftdm_log (FTDM_LOG_ERROR ,"TUCL GEN configuration: NOT OK\n"); - return FTDM_FAIL; - } else { - ftdm_log (FTDM_LOG_INFO ,"TUCL GEN configuration: OK\n"); - } - /****************************************************************************************************/ - if(ftmod_sctp_gen_config()){ - ftdm_log (FTDM_LOG_ERROR ,"SCTP GEN configuration: NOT OK\n"); - return FTDM_FAIL; - } else { - ftdm_log (FTDM_LOG_INFO ,"SCTP GEN configuration: OK\n"); - } - /****************************************************************************************************/ - if(ftmod_m2ua_gen_config()) { - ftdm_log (FTDM_LOG_ERROR ,"M2UA General configuration: NOT OK\n"); - return FTDM_FAIL; - }else { - ftdm_log (FTDM_LOG_INFO ,"M2UA General configuration: OK\n"); - } - /****************************************************************************************************/ - if(ftmod_nif_gen_config()){ - ftdm_log (FTDM_LOG_ERROR ,"NIF General configuration: NOT OK\n"); - return FTDM_FAIL; - }else { - ftdm_log (FTDM_LOG_INFO ,"NIF General configuration: OK\n"); - } - /****************************************************************************************************/ - - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -void ftmod_ss7_m2ua_free() -{ - if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_M2UA_PRESENT)) { - ftmod_ss7_m2ua_shutdown(); - sng_isup_free_m2ua(); - } - if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_SCTP_PRESENT)) { - ftmod_ss7_sctp_shutdown(); - sng_isup_free_sctp(); - } - if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_TUCL_PRESENT)) { - ftmod_ss7_tucl_shutdown(); - sng_isup_free_tucl(); - } -} - -/******************************************************************************/ -static int ftmod_ss7_tucl_shutdown() -{ - Pst pst; - HiMngmt cntrl; - - memset((U8 *)&pst, 0, sizeof(Pst)); - memset((U8 *)&cntrl, 0, sizeof(HiMngmt)); - - smPstInit(&pst); - - pst.dstEnt = ENTHI; - - /* prepare header */ - cntrl.hdr.msgType = TCNTRL; /* message type */ - cntrl.hdr.entId.ent = ENTHI; /* entity */ - cntrl.hdr.entId.inst = 0; /* instance */ - cntrl.hdr.elmId.elmnt = STGEN; /* General */ - - cntrl.hdr.response.selector = 0; - cntrl.hdr.response.prior = PRIOR0; - cntrl.hdr.response.route = RTESPEC; - cntrl.hdr.response.mem.region = S_REG; - cntrl.hdr.response.mem.pool = S_POOL; - - cntrl.t.cntrl.action = ASHUTDOWN; - - return (sng_cntrl_tucl (&pst, &cntrl)); -} -/******************************************************************************/ -static int ftmod_ss7_m2ua_shutdown() -{ - Pst pst; - MwMgmt cntrl; - - memset((U8 *)&pst, 0, sizeof(Pst)); - memset((U8 *)&cntrl, 0, sizeof(MwMgmt)); - - smPstInit(&pst); - - pst.dstEnt = ENTMW; - - /* prepare header */ - cntrl.hdr.msgType = TCNTRL; /* message type */ - cntrl.hdr.entId.ent = ENTMW; /* entity */ - cntrl.hdr.entId.inst = 0; /* instance */ - cntrl.hdr.elmId.elmnt = STMWGEN; /* General */ - - cntrl.hdr.response.selector = 0; - cntrl.hdr.response.prior = PRIOR0; - cntrl.hdr.response.route = RTESPEC; - cntrl.hdr.response.mem.region = S_REG; - cntrl.hdr.response.mem.pool = S_POOL; - - cntrl.t.cntrl.action = ASHUTDOWN; - - return (sng_cntrl_m2ua (&pst, &cntrl)); -} -/***********************************************************************************************************************/ -static int ftmod_ss7_sctp_shutdown() -{ - Pst pst; - SbMgmt cntrl; - - memset((U8 *)&pst, 0, sizeof(Pst)); - memset((U8 *)&cntrl, 0, sizeof(SbMgmt)); - - smPstInit(&pst); - - pst.dstEnt = ENTSB; - - /* prepare header */ - cntrl.hdr.msgType = TCNTRL; /* message type */ - cntrl.hdr.entId.ent = ENTSB; /* entity */ - cntrl.hdr.entId.inst = 0; /* instance */ - cntrl.hdr.elmId.elmnt = STSBGEN; /* General */ - - cntrl.hdr.response.selector = 0; - cntrl.hdr.response.prior = PRIOR0; - cntrl.hdr.response.route = RTESPEC; - cntrl.hdr.response.mem.region = S_REG; - cntrl.hdr.response.mem.pool = S_POOL; - - cntrl.t.cntrl.action = ASHUTDOWN; - - return (sng_cntrl_sctp (&pst, &cntrl)); -} - -/******************************************************************************/ - - - -ftdm_status_t ftmod_ss7_m2ua_cfg(void) -{ - int x=0; - - /* SCTP configuration */ - if(ftmod_cfg_sctp()){ - ftdm_log (FTDM_LOG_ERROR ,"SCTP Configuration : NOT OK\n"); - return FTDM_FAIL; - } else { - ftdm_log (FTDM_LOG_INFO ,"SCTP Configuration : OK\n"); - } - - /****************************************************************************************************/ - /* M2UA SCTP SAP configurations */ - x = 1; - while(xspId = k->id ; /* each SCTP link there will be one tucl sap */ - pCfg->uiSel = 0x00; /*loosley coupled */ - pCfg->flcEnb = TRUE; - pCfg->txqCongStrtLim = HI_SAP_TXN_QUEUE_CONG_START_LIMIT; - pCfg->txqCongDropLim = HI_SAP_TXN_QUEUE_CONG_DROP_LIMIT; - pCfg->txqCongStopLim = HI_SAP_TXN_QUEUE_CONG_STOP_LIMIT; - pCfg->numBins = 10; - - pCfg->uiMemId.region = S_REG; - pCfg->uiMemId.pool = S_POOL; - pCfg->uiPrior = PRIOR0; - pCfg->uiRoute = RTESPEC; - - return(sng_cfg_tucl(&pst, &cfg)); -} - -/****************************************************************************************************/ - -static int ftmod_sctp_gen_config(void) -{ - SbMgmt cfg; - Pst pst; - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSB; - - /* clear the configuration structure */ - memset(&cfg, 0, sizeof(cfg)); - - /* fill in the post structure */ - smPstInit(&cfg.t.cfg.s.genCfg.smPst); - /*fill in the specific fields of the header */ - cfg.hdr.msgType = TCFG; - cfg.hdr.entId.ent = ENTSB; - cfg.hdr.entId.inst = S_INST; - cfg.hdr.elmId.elmnt = STSBGEN; - -#ifdef SB_IPV6_SUPPORTED - /* U8 ipv6SrvcReqdFlg; */ /* IPV6 service required for sctp */ -#endif - - cfg.t.cfg.s.genCfg.serviceType = HI_SRVC_RAW_SCTP; /* Usr packetized TCP Data */ /* TUCL transport protocol (IP/UDP) */ - cfg.t.cfg.s.genCfg.maxNmbSctSaps = SB_MAX_SCT_SAPS; /* max no. SCT SAPS */ - cfg.t.cfg.s.genCfg.maxNmbTSaps = SB_MAX_T_SAPS; /* max no. Transport SAPS */ - cfg.t.cfg.s.genCfg.maxNmbEndp = SB_MAX_NUM_OF_ENDPOINTS; /* max no. endpoints */ - cfg.t.cfg.s.genCfg.maxNmbAssoc = SB_MAX_NUM_OF_ASSOC; /* max no. associations */ - cfg.t.cfg.s.genCfg.maxNmbDstAddr = SB_MAX_NUM_OF_DST_ADDR; /* max no. dest. addresses */ - cfg.t.cfg.s.genCfg.maxNmbSrcAddr = SB_MAX_NUM_OF_SRC_ADDR; /* max no. src. addresses */ - cfg.t.cfg.s.genCfg.maxNmbTxChunks = SB_MAX_NUM_OF_TX_CHUNKS; - cfg.t.cfg.s.genCfg.maxNmbRxChunks = SB_MAX_NUM_OF_RX_CHUNKS; - cfg.t.cfg.s.genCfg.maxNmbInStrms = SB_MAX_INC_STREAMS; - cfg.t.cfg.s.genCfg.maxNmbOutStrms = SB_MAX_OUT_STREAMS; - cfg.t.cfg.s.genCfg.initARwnd = SB_MAX_RWND_SIZE; - cfg.t.cfg.s.genCfg.mtuInitial = SB_MTU_INITIAL; - cfg.t.cfg.s.genCfg.mtuMinInitial = SB_MTU_MIN_INITIAL; - cfg.t.cfg.s.genCfg.mtuMaxInitial = SB_MTU_MAX_INITIAL; - cfg.t.cfg.s.genCfg.performMtu = FALSE; - cfg.t.cfg.s.genCfg.timeRes = 1; - sprintf((char*)cfg.t.cfg.s.genCfg.hostname, "www.sangoma.com"); /* DAVIDY - Fix this later, probably ignored */ - cfg.t.cfg.s.genCfg.useHstName = FALSE; /* Flag whether hostname is to be used in INIT and INITACK msg */ - cfg.t.cfg.s.genCfg.reConfig.maxInitReTx = 8; - cfg.t.cfg.s.genCfg.reConfig.maxAssocReTx = 10; - cfg.t.cfg.s.genCfg.reConfig.maxPathReTx = 10; - cfg.t.cfg.s.genCfg.reConfig.altAcceptFlg = TRUE; - cfg.t.cfg.s.genCfg.reConfig.keyTm = 600; /* initial value for MD5 Key expiry timer */ - cfg.t.cfg.s.genCfg.reConfig.alpha = 12; - cfg.t.cfg.s.genCfg.reConfig.beta = 25; -#ifdef SB_ECN - cfg.t.cfg.s.genCfg.reConfig.ecnFlg = TRUE; -#endif - - return(sng_cfg_sctp(&pst, &cfg)); -} - -/****************************************************************************************************/ -static int ftmod_cfg_sctp(void) -{ - int x=0; - - x = 1; - while(xid; - - c = &cfg.t.cfg.s.tSapCfg; - c->swtch = LSB_SW_RFC_REL0; - c->suId = k->id; - c->sel = 0; - c->ent = ENTHI; - c->inst = S_INST; - c->procId = g_ftdm_sngss7_data.cfg.procId; - c->memId.region = S_REG; - c->memId.pool = S_POOL; - c->prior = PRIOR1; - c->route = RTESPEC; - c->srcNAddrLst.nmb = k->numSrcAddr; - for (i=0; i <= (k->numSrcAddr-1); i++) { - c->srcNAddrLst.nAddr[i].type = CM_NETADDR_IPV4; - c->srcNAddrLst.nAddr[i].u.ipv4NetAddr = k->srcAddrList[i+1]; - } - - c->reConfig.spId = k->id; - c->reConfig.maxBndRetry = 3; - c->reConfig.tIntTmr = 200; - - ret = sng_cfg_sctp(&pst, &cfg); - if (0 == ret) { - SS7_INFO("SCTP TSAP [%d] configuration DONE!\n", id); - return FTDM_SUCCESS; - } else { - SS7_CRITICAL("SCTP TSAP [%d] configuration FAILED!\n", id); - return FTDM_FAIL; - } -} - -/****************************************************************************************************/ - -ftdm_status_t ftmod_sctp_sap_config(int id) -{ - Pst pst; - SbMgmt cfg; - SbSctSapCfg *c; - - int ret = -1; - sng_sctp_link_t *k = &g_ftdm_sngss7_data.cfg.sctpCfg.linkCfg[id]; - - smPstInit(&pst); - pst.dstEnt = ENTSB; - - memset(&cfg, 0x0, sizeof(cfg)); - smHdrInit(&cfg.hdr); - - cfg.hdr.msgType = TCFG; - cfg.hdr.entId.ent = ENTSB; - cfg.hdr.entId.inst = S_INST; - cfg.hdr.elmId.elmnt = STSBSCTSAP; - cfg.hdr.elmId.elmntInst1 = k->id; - - c = &cfg.t.cfg.s.sctSapCfg; - c->swtch = LSB_SW_RFC_REL0; - c->spId = k->id; /* Service Provider SAP Id */ - c->sel = 0; - c->memId.region = S_REG; - c->memId.pool = S_POOL; - c->prior = PRIOR1; - c->route = RTESPEC; - - /* Maximum time to wait before the SCTP layer must send a Selective Acknowledgement (SACK) message. Valid range is 1 -165535. */ - c->reConfig.maxAckDelayTm = 200; - /* Maximum number of messages to receive before the SCTP layer must send a SACK message. Valid range is 1 - 165535. */ - c->reConfig.maxAckDelayDg = 2; - /* Initial value of the retransmission timer (RTO). The SCTP layer retransmits data after waiting for feedback during this time period. Valid range is 1 - 65535. */ - c->reConfig.rtoInitial = 3000; - /* Minimum value used for the RTO. If the computed value of RTO is less than rtoMin, the computed value is rounded up to this value. */ - c->reConfig.rtoMin = 1000; - /* Maxiumum value used for RTO. If the computed value of RTO is greater than rtoMax, the computed value is rounded down to this value. */ - c->reConfig.rtoMax = 10000; - /* Default Freeze timer value */ - c->reConfig.freezeTm = 3000; - /* Base cookie lifetime for the cookie in the Initiation Acknowledgement (INIT ACK) message. */ - c->reConfig.cookieLife = 60000; - /* Default heartbeat interval timer. Valid range is 1 - 65535. */ - c->reConfig.intervalTm = 3000; - /* Maximum burst value. Valid range is 1 - 65535. */ - c->reConfig.maxBurst = 4; - /*Maximum number of heartbeats sent at each retransmission timeout (RTO). Valid range is 1 - 65535. */ - c->reConfig.maxHbBurst = 1; - /*Shutdown guard timer value for graceful shutdowns. */ - c->reConfig.t5SdownGrdTm = 15000; - /* Action to take when the receiver's number of incoming streams is less than the sender's number of outgoing streams. Valid values are: - TRUE = Accept incoming stream and continue association. - FALSE = Abort the association. - */ - c->reConfig.negAbrtFlg = FALSE; - /* Whether to enable or disable heartbeat by default. Valid values are: - TRUE = Enable heartbeat. - FALSE = Disable heartbeat. - */ - c->reConfig.hBeatEnable = TRUE; - /* Flow control start threshold. When the number of messages in SCTP’s message queue reaches this value, flow control starts. */ - c->reConfig.flcUpThr = 8; - /* Flow control stop threshold. When the number of messages in SCTP’s message queue reaches this value, flow control stops. */ - c->reConfig.flcLowThr = 6; - - c->reConfig.handleInitFlg = FALSE; - - ret = sng_cfg_sctp(&pst, &cfg); - if (0 == ret) { - SS7_INFO("SCTP SAP [%d] configuration DONE!\n", id); - return FTDM_SUCCESS; - } else { - SS7_CRITICAL("SCTP SAP [%d] configuration FAILED!\n", id); - return FTDM_FAIL; - } -} - -/**********************************************************************************************/ -/* M2UA - General configuration */ -static int ftmod_m2ua_gen_config(void) -{ - Pst pst; - MwMgmt cfg; - - memset((U8 *)&cfg, 0, sizeof(MwMgmt)); - memset((U8 *)&pst, 0, sizeof(Pst)); - - smPstInit(&pst); - - pst.dstEnt = ENTMW; - - /* prepare header */ - cfg.hdr.msgType = TCFG; /* message type */ - cfg.hdr.entId.ent = ENTMW; /* entity */ - cfg.hdr.entId.inst = 0; /* instance */ - cfg.hdr.elmId.elmnt = STMWGEN; /* General */ - cfg.hdr.transId = 0; /* transaction identifier */ - - cfg.hdr.response.selector = 0; - cfg.hdr.response.prior = PRIOR0; - cfg.hdr.response.route = RTESPEC; - cfg.hdr.response.mem.region = S_REG; - cfg.hdr.response.mem.pool = S_POOL; - - - - cfg.t.cfg.s.genCfg.nodeType = LMW_TYPE_SGP; /* NodeType == SGP or ASP */ - cfg.t.cfg.s.genCfg.maxNmbIntf = MW_MAX_NUM_OF_INTF; - cfg.t.cfg.s.genCfg.maxNmbCluster = MW_MAX_NUM_OF_CLUSTER; - cfg.t.cfg.s.genCfg.maxNmbPeer = MW_MAX_NUM_OF_PEER; - cfg.t.cfg.s.genCfg.maxNmbSctSap = MW_MAX_NUM_OF_SCT_SAPS; - cfg.t.cfg.s.genCfg.timeRes = 1; /* timer resolution */ - cfg.t.cfg.s.genCfg.maxClusterQSize = MW_MAX_CLUSTER_Q_SIZE; - cfg.t.cfg.s.genCfg.maxIntfQSize = MW_MAX_INTF_Q_SIZE; - -#ifdef LCMWMILMW - cfg.t.cfg.s.genCfg.reConfig.smPst.selector = 0; /* selector */ -#else /* LCSBMILSB */ - cfg.t.cfg.s.genCfg.reConfig.smPst.selector = 1; /* selector */ -#endif /* LCSBMILSB */ - - cfg.t.cfg.s.genCfg.reConfig.smPst.region = S_REG; /* region */ - cfg.t.cfg.s.genCfg.reConfig.smPst.pool = S_POOL; /* pool */ - cfg.t.cfg.s.genCfg.reConfig.smPst.prior = PRIOR0; /* priority */ - cfg.t.cfg.s.genCfg.reConfig.smPst.route = RTESPEC; /* route */ - - cfg.t.cfg.s.genCfg.reConfig.smPst.dstEnt = ENTSM; /* dst entity */ - cfg.t.cfg.s.genCfg.reConfig.smPst.dstInst = S_INST; /* dst inst */ - cfg.t.cfg.s.genCfg.reConfig.smPst.dstProcId = SFndProcId(); /* src proc id */ - - cfg.t.cfg.s.genCfg.reConfig.smPst.srcEnt = ENTMW; /* src entity */ - cfg.t.cfg.s.genCfg.reConfig.smPst.srcInst = S_INST; /* src inst */ - cfg.t.cfg.s.genCfg.reConfig.smPst.srcProcId = SFndProcId(); /* src proc id */ - - cfg.t.cfg.s.genCfg.reConfig.tmrFlcPoll.enb = TRUE; /* SCTP Flc Poll timer */ - cfg.t.cfg.s.genCfg.reConfig.tmrFlcPoll.val = 10; - -#ifdef MWASP - cfg.t.cfg.s.genCfg.reConfig.tmrAspm.enb = TRUE; /* ASPM timer */ - cfg.t.cfg.s.genCfg.reConfig.tmrAspm.val = 10; - cfg.t.cfg.s.genCfg.reConfig.tmrHeartBeat.enb = TRUE; /* Heartbeat timer */ - cfg.t.cfg.s.genCfg.reConfig.tmrHeartBeat.val = 10; -#endif - -#ifdef MWSG - cfg.t.cfg.s.genCfg.reConfig.tmrAsPend.enb = TRUE; /* AS-PENDING timer */ - cfg.t.cfg.s.genCfg.reConfig.tmrAsPend.val = 10; - cfg.t.cfg.s.genCfg.reConfig.tmrCongPoll.enb = TRUE; /* SS7 Congestion poll timer */ - cfg.t.cfg.s.genCfg.reConfig.tmrCongPoll.val = 10; - cfg.t.cfg.s.genCfg.reConfig.tmrHeartBeat.enb = FALSE; /* HBtimer only at ASP */ -#endif - cfg.t.cfg.s.genCfg.reConfig.aspmRetry = 5; - - return (sng_cfg_m2ua (&pst, &cfg)); -} - -/**********************************************************************************************/ -static int ftmod_m2ua_peer_config(int id) -{ - int x = 0; - int peer_id = 0; - sng_m2ua_cfg_t* m2ua = &g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua[id]; - sng_m2ua_cluster_cfg_t* clust = &g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_clus[m2ua->clusterId]; - sng_m2ua_peer_cfg_t* peer = NULL; - - if((clust->flags & SNGSS7_CONFIGURED)){ - ftdm_log (FTDM_LOG_INFO, " ftmod_m2ua_peer_config: Cluster [%s] is already configured \n", clust->name); - return 0x00; - } - - /*NOTE : SCTSAP is based on per source address , so if we have same Cluster / peer shared across many then - * we dont have do configuration for each time */ - - /* loop through peer list from cluster to configure SCTSAP */ - - for(x = 0; x < clust->numOfPeers;x++){ - peer_id = clust->peerIdLst[x]; - peer = &g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_peer[peer_id]; - if(ftmod_m2ua_sctsap_config(id, peer->sctpId)){ - ftdm_log (FTDM_LOG_ERROR, " ftmod_m2ua_sctsap_config: M2UA SCTSAP for M2UA Intf Id[%d] config FAILED \n", id); - return 0x01; - }else{ - ftdm_log (FTDM_LOG_INFO, " ftmod_m2ua_sctsap_config: M2UA SCTSAP for M2UA Intf Id[%d] config SUCCESS \n", id); - } - if(ftmod_m2ua_peer_config1(id, peer_id)){ - ftdm_log (FTDM_LOG_ERROR, " ftmod_m2ua_peer_config1: M2UA Peer[%d] configuration for M2UA Intf Id[%d] config FAILED \n", peer_id, id); - return 0x01; - }else{ - ftdm_log (FTDM_LOG_INFO, " ftmod_m2ua_peer_config1: M2UA Peer[%d] configuration for M2UA Intf Id[%d] config SUCCESS \n", peer_id, id); - } - - clust->sct_sap_id = id; - - /* set configured flag for cluster and peer */ - clust->flags |= SNGSS7_CONFIGURED; - peer->flags |= SNGSS7_CONFIGURED; - } - - return 0x0;; -} - - -static int ftmod_m2ua_sctsap_config(int sct_sap_id, int sctp_id) -{ - int i; - int ret; - Pst pst; - MwMgmt cfg; - MwMgmt cfm; - sng_sctp_link_t *sctp = &g_ftdm_sngss7_data.cfg.sctpCfg.linkCfg[sctp_id]; - - - - memset((U8 *)&cfg, 0, sizeof(MwMgmt)); - memset((U8 *)&cfm, 0, sizeof(MwMgmt)); - memset((U8 *)&pst, 0, sizeof(Pst)); - - /* check is sct_sap is already configured */ - if(!ftmod_m2ua_ssta_req(STMWSCTSAP, sct_sap_id, &cfm )){ - ftdm_log (FTDM_LOG_INFO, " ftmod_m2ua_sctsap_config: SCT SAP [%s] is already configured \n", sctp->name); - return 0x00; - } - - if(LCM_REASON_INVALID_SAP == cfm.cfm.reason){ - ftdm_log (FTDM_LOG_INFO, " ftmod_m2ua_sctsap_config: SCT SAP [%s] is not configured..configuring now \n", sctp->name); - } - - smPstInit(&pst); - - pst.dstEnt = ENTMW; - - /* prepare header */ - cfg.hdr.msgType = TCFG; /* message type */ - cfg.hdr.entId.ent = ENTMW; /* entity */ - cfg.hdr.entId.inst = 0; /* instance */ - cfg.hdr.elmId.elmnt = STMWSCTSAP; /* SCTSAP */ - cfg.hdr.transId = 0; /* transaction identifier */ - - cfg.hdr.response.selector = 0; - cfg.hdr.response.prior = PRIOR0; - cfg.hdr.response.route = RTESPEC; - cfg.hdr.response.mem.region = S_REG; - cfg.hdr.response.mem.pool = S_POOL; - - cfg.t.cfg.s.sctSapCfg.reConfig.selector = 0; - - /* service user SAP ID */ - cfg.t.cfg.s.sctSapCfg.suId = sct_sap_id; - /* service provider ID */ - cfg.t.cfg.s.sctSapCfg.spId = sctp_id; - /* source port number */ - cfg.t.cfg.s.sctSapCfg.srcPort = sctp->port; - /* interface address */ - /*For multiple IP address support */ -#ifdef SCT_ENDP_MULTI_IPADDR - cfg.t.cfg.s.sctSapCfg.srcAddrLst.nmb = sctp->numSrcAddr; - for (i=0; i <= (sctp->numSrcAddr-1); i++) { - cfg.t.cfg.s.sctSapCfg.srcAddrLst.nAddr[i].type = CM_NETADDR_IPV4; - cfg.t.cfg.s.sctSapCfg.srcAddrLst.nAddr[i].u.ipv4NetAddr = sctp->srcAddrList[i+1]; - } -#else - /* for single ip support ,src address will always be one */ - cfg.t.cfg.s.sctSapCfg.intfAddr.type = CM_NETADDR_IPV4; - cfg.t.cfg.s.sctSapCfg.intfAddr.u.ipv4NetAddr = sctp->srcAddrList[1]; -#endif - - /* lower SAP primitive timer */ - cfg.t.cfg.s.sctSapCfg.reConfig.tmrPrim.enb = TRUE; - cfg.t.cfg.s.sctSapCfg.reConfig.tmrPrim.val = 10; - /* Association primitive timer */ - cfg.t.cfg.s.sctSapCfg.reConfig.tmrAssoc.enb = TRUE; - cfg.t.cfg.s.sctSapCfg.reConfig.tmrAssoc.val = 10; - /* maxnumber of retries */ - cfg.t.cfg.s.sctSapCfg.reConfig.nmbMaxPrimRetry = 5; - /* Life Time of Packets */ - cfg.t.cfg.s.sctSapCfg.reConfig.lifeTime = 200; - /* priority */ - cfg.t.cfg.s.sctSapCfg.reConfig.prior = PRIOR0; - /* route */ - cfg.t.cfg.s.sctSapCfg.reConfig.route = RTESPEC; - cfg.t.cfg.s.sctSapCfg.reConfig.ent = ENTSB; - cfg.t.cfg.s.sctSapCfg.reConfig.inst = 0; - cfg.t.cfg.s.sctSapCfg.reConfig.procId = SFndProcId(); - /* memory region and pool ID */ - cfg.t.cfg.s.sctSapCfg.reConfig.mem.region = S_REG; - cfg.t.cfg.s.sctSapCfg.reConfig.mem.pool = S_POOL; - - if (0 == (ret = sng_cfg_m2ua (&pst, &cfg))){ - sctp->flags |= SNGSS7_CONFIGURED; - } - - return ret; -} - -/****************************************************************************************************/ - -/* M2UA - Peer configuration */ -static int ftmod_m2ua_peer_config1(int m2ua_inf_id, int peer_id) -{ - int i; - Pst pst; - MwMgmt cfg; - sng_m2ua_peer_cfg_t* peer = &g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_peer[peer_id]; - sng_sctp_link_t *sctp = &g_ftdm_sngss7_data.cfg.sctpCfg.linkCfg[peer->sctpId]; - - memset((U8 *)&cfg, 0, sizeof(MwMgmt)); - memset((U8 *)&pst, 0, sizeof(Pst)); - - smPstInit(&pst); - - pst.dstEnt = ENTMW; - - /* prepare header */ - cfg.hdr.msgType = TCFG; /* message type */ - cfg.hdr.entId.ent = ENTMW; /* entity */ - cfg.hdr.entId.inst = 0; /* instance */ - cfg.hdr.elmId.elmnt = STMWPEER; /* Peer */ - cfg.hdr.transId = 0; /* transaction identifier */ - - cfg.hdr.response.selector = 0; - cfg.hdr.response.prior = PRIOR0; - cfg.hdr.response.route = RTESPEC; - cfg.hdr.response.mem.region = S_REG; - cfg.hdr.response.mem.pool = S_POOL; - - - - cfg.t.cfg.s.peerCfg.peerId = peer->id; /* peer id */ - cfg.t.cfg.s.peerCfg.aspIdFlag = peer->aspIdFlag; /* aspId flag */ -#ifdef MWASP - cfg.t.cfg.s.peerCfg.selfAspId = peer->selfAspId; /* aspId */ -#endif - cfg.t.cfg.s.peerCfg.assocCfg.suId = peer->sctpId; /* SCTSAP ID */ - cfg.t.cfg.s.peerCfg.assocCfg.dstAddrLst.nmb = peer->numDestAddr; - for (i=0; i <= (peer->numDestAddr); i++) { - cfg.t.cfg.s.peerCfg.assocCfg.dstAddrLst.nAddr[i].type = CM_NETADDR_IPV4; - cfg.t.cfg.s.peerCfg.assocCfg.dstAddrLst.nAddr[i].u.ipv4NetAddr = peer->destAddrList[i]; - } -#ifdef MW_CFG_DSTPORT - cfg.t.cfg.s.peerCfg.assocCfg.dstPort = peer->port; /* Port on which M2UA runs */ -#endif - cfg.t.cfg.s.peerCfg.assocCfg.srcAddrLst.nmb = sctp->numSrcAddr; /* source address list */ - for (i=0; i <= (sctp->numSrcAddr-1); i++) { - cfg.t.cfg.s.peerCfg.assocCfg.srcAddrLst.nAddr[i].type = CM_NETADDR_IPV4; - cfg.t.cfg.s.peerCfg.assocCfg.srcAddrLst.nAddr[i].u.ipv4NetAddr = sctp->srcAddrList[i+1]; - } - - cfg.t.cfg.s.peerCfg.assocCfg.priDstAddr.type = CM_NETADDR_IPV4; - cfg.t.cfg.s.peerCfg.assocCfg.priDstAddr.u.ipv4NetAddr = cfg.t.cfg.s.peerCfg.assocCfg.dstAddrLst.nAddr[0].u.ipv4NetAddr; - - cfg.t.cfg.s.peerCfg.assocCfg.locOutStrms = peer->locOutStrms; -#ifdef SCT3 - cfg.t.cfg.s.peerCfg.assocCfg.tos = 0; -#endif - - return (sng_cfg_m2ua (&pst, &cfg)); -} -/**********************************************************************************************/ -/* M2UA - Cluster configuration */ -static int ftmod_m2ua_cluster_config(int id) -{ - int i; - Pst pst; - MwMgmt cfg; - sng_m2ua_cfg_t* m2ua = &g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua[id]; - sng_m2ua_cluster_cfg_t* clust = &g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_clus[m2ua->clusterId]; - - memset((U8 *)&cfg, 0, sizeof(MwMgmt)); - memset((U8 *)&pst, 0, sizeof(Pst)); - - smPstInit(&pst); - - pst.dstEnt = ENTMW; - - /* prepare header */ - cfg.hdr.msgType = TCFG; /* message type */ - cfg.hdr.entId.ent = ENTMW; /* entity */ - cfg.hdr.entId.inst = 0; /* instance */ - cfg.hdr.elmId.elmnt = STMWCLUSTER; /* Cluster */ - cfg.hdr.transId = 0; /* transaction identifier */ - - cfg.hdr.response.selector = 0; - cfg.hdr.response.prior = PRIOR0; - cfg.hdr.response.route = RTESPEC; - cfg.hdr.response.mem.region = S_REG; - cfg.hdr.response.mem.pool = S_POOL; - - - cfg.t.cfg.s.clusterCfg.clusterId = clust->id; - cfg.t.cfg.s.clusterCfg.trfMode = clust->trfMode; - cfg.t.cfg.s.clusterCfg.loadshareMode = clust->loadShareAlgo; - cfg.t.cfg.s.clusterCfg.reConfig.nmbPeer = clust->numOfPeers; - for(i=0; i<(clust->numOfPeers);i++) { - cfg.t.cfg.s.clusterCfg.reConfig.peer[i] = clust->peerIdLst[i]; - } - - return (sng_cfg_m2ua (&pst, &cfg)); -} - -/**********************************************************************************************/ - -/* M2UA - DLSAP configuration */ -static int ftmod_m2ua_dlsap_config(int id) -{ - Pst pst; - MwMgmt cfg; - sng_m2ua_cfg_t* m2ua = &g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua[id]; - - memset((U8 *)&cfg, 0, sizeof(MwMgmt)); - memset((U8 *)&pst, 0, sizeof(Pst)); - - smPstInit(&pst); - - pst.dstEnt = ENTMW; - - /* prepare header */ - cfg.hdr.msgType = TCFG; /* message type */ - cfg.hdr.entId.ent = ENTMW; /* entity */ - cfg.hdr.entId.inst = 0; /* instance */ - cfg.hdr.elmId.elmnt = STMWDLSAP; /* DLSAP */ - cfg.hdr.transId = 0; /* transaction identifier */ - - cfg.hdr.response.selector = 0; - cfg.hdr.response.prior = PRIOR0; - cfg.hdr.response.route = RTESPEC; - cfg.hdr.response.mem.region = S_REG; - cfg.hdr.response.mem.pool = S_POOL; - - - cfg.t.cfg.s.dlSapCfg.lnkNmb = id; /* SapId */ - cfg.t.cfg.s.dlSapCfg.intfId.type = LMW_INTFID_INT; - cfg.t.cfg.s.dlSapCfg.intfId.id.intId = m2ua->iid; - - cfg.t.cfg.s.dlSapCfg.swtch = LMW_SAP_ITU; - - cfg.t.cfg.s.dlSapCfg.reConfig.clusterId = m2ua->clusterId; - cfg.t.cfg.s.dlSapCfg.reConfig.selector = 0; /* Loosely couple mode */ - /* memory region and pool id*/ - cfg.t.cfg.s.dlSapCfg.reConfig.mem.region = S_REG; - cfg.t.cfg.s.dlSapCfg.reConfig.mem.pool = S_POOL; - /* priority */ - cfg.t.cfg.s.dlSapCfg.reConfig.prior = PRIOR0; - /* route */ - cfg.t.cfg.s.dlSapCfg.reConfig.route = RTESPEC; - - return (sng_cfg_m2ua (&pst, &cfg)); - -} -/*****************************************************************************/ -/* NIF - General configuration */ -static int ftmod_nif_gen_config(void) -{ - Pst pst; - NwMgmt cfg; - - memset((U8 *)&cfg, 0, sizeof(NwMgmt)); - memset((U8 *)&pst, 0, sizeof(Pst)); - - smPstInit(&pst); - - pst.dstEnt = ENTNW; - - /* prepare header */ - cfg.hdr.msgType = TCFG; /* message type */ - cfg.hdr.entId.ent = ENTNW; /* entity */ - cfg.hdr.entId.inst = 0; /* instance */ - cfg.hdr.elmId.elmnt = STNWGEN; /* DLSAP */ - cfg.hdr.transId = 0; /* transaction identifier */ - - cfg.hdr.response.selector = 0; - cfg.hdr.response.prior = PRIOR0; - cfg.hdr.response.route = RTESPEC; - cfg.hdr.response.mem.region = S_REG; - cfg.hdr.response.mem.pool = S_POOL; - - cfg.t.cfg.s.genCfg.maxNmbDlSap = NW_MAX_NUM_OF_DLSAPS; - cfg.t.cfg.s.genCfg.timeRes = 1; /* timer resolution */ - - cfg.t.cfg.s.genCfg.reConfig.maxNmbRetry = NW_MAX_NUM_OF_RETRY; - cfg.t.cfg.s.genCfg.reConfig.tmrRetry.enb = TRUE; /* SS7 Congestion poll timer */ - cfg.t.cfg.s.genCfg.reConfig.tmrRetry.val = NW_RETRY_TMR_VALUE; - -#ifdef LCNWMILNW - cfg.t.cfg.s.genCfg.reConfig.smPst.selector = 0; /* selector */ -#else /* LCSBMILSB */ - cfg.t.cfg.s.genCfg.reConfig.smPst.selector = 1; /* selector */ -#endif /* LCSBMILSB */ - - cfg.t.cfg.s.genCfg.reConfig.smPst.region = S_REG; /* region */ - cfg.t.cfg.s.genCfg.reConfig.smPst.pool = S_POOL; /* pool */ - cfg.t.cfg.s.genCfg.reConfig.smPst.prior = PRIOR0; /* priority */ - cfg.t.cfg.s.genCfg.reConfig.smPst.route = RTESPEC; /* route */ - - cfg.t.cfg.s.genCfg.reConfig.smPst.dstEnt = ENTSM; /* dst entity */ - cfg.t.cfg.s.genCfg.reConfig.smPst.dstInst = 0; /* dst inst */ - cfg.t.cfg.s.genCfg.reConfig.smPst.dstProcId = SFndProcId(); /* src proc id */ - - cfg.t.cfg.s.genCfg.reConfig.smPst.srcEnt = ENTNW; /* src entity */ - cfg.t.cfg.s.genCfg.reConfig.smPst.srcInst = 0; /* src inst */ - cfg.t.cfg.s.genCfg.reConfig.smPst.srcProcId = SFndProcId(); /* src proc id */ - - return (sng_cfg_nif (&pst, &cfg)); - -} - -/*****************************************************************************/ - -/* NIF - DLSAP configuration */ -static int ftmod_nif_dlsap_config(int id) -{ - Pst pst; - NwMgmt cfg; - sng_nif_cfg_t* nif = &g_ftdm_sngss7_data.cfg.g_m2ua_cfg.nif[id]; - - memset((U8 *)&cfg, 0, sizeof(NwMgmt)); - memset((U8 *)&pst, 0, sizeof(Pst)); - - smPstInit(&pst); - - pst.dstEnt = ENTNW; - - /* prepare header */ - cfg.hdr.msgType = TCFG; /* message type */ - cfg.hdr.entId.ent = ENTNW; /* entity */ - cfg.hdr.entId.inst = 0; /* instance */ - cfg.hdr.elmId.elmnt = STNWDLSAP; /* DLSAP */ - cfg.hdr.transId = 0; /* transaction identifier */ - - cfg.hdr.response.selector = 0; - cfg.hdr.response.prior = PRIOR0; - cfg.hdr.response.route = RTESPEC; - cfg.hdr.response.mem.region = S_REG; - cfg.hdr.response.mem.pool = S_POOL; - cfg.t.cfg.s.dlSapCfg.suId = nif->id; - cfg.t.cfg.s.dlSapCfg.m2uaLnkNmb = nif->m2uaLnkNmb; - cfg.t.cfg.s.dlSapCfg.mtp2LnkNmb = nif->mtp2LnkNmb; - - cfg.t.cfg.s.dlSapCfg.reConfig.m2uaPst.selector = 0; - cfg.t.cfg.s.dlSapCfg.reConfig.m2uaPst.region = S_REG; - cfg.t.cfg.s.dlSapCfg.reConfig.m2uaPst.pool = S_POOL; - cfg.t.cfg.s.dlSapCfg.reConfig.m2uaPst.route = RTESPEC; - cfg.t.cfg.s.dlSapCfg.reConfig.m2uaPst.prior = PRIOR0; - cfg.t.cfg.s.dlSapCfg.reConfig.m2uaPst.srcEnt = ENTNW; - cfg.t.cfg.s.dlSapCfg.reConfig.m2uaPst.srcInst = 0; - cfg.t.cfg.s.dlSapCfg.reConfig.m2uaPst.srcProcId = SFndProcId(); - cfg.t.cfg.s.dlSapCfg.reConfig.m2uaPst.dstEnt = ENTMW; - cfg.t.cfg.s.dlSapCfg.reConfig.m2uaPst.dstInst = 0; - cfg.t.cfg.s.dlSapCfg.reConfig.m2uaPst.dstProcId = SFndProcId(); - - cfg.t.cfg.s.dlSapCfg.reConfig.mtp2Pst.selector = 0; - cfg.t.cfg.s.dlSapCfg.reConfig.mtp2Pst.region = S_REG; - cfg.t.cfg.s.dlSapCfg.reConfig.mtp2Pst.pool = S_POOL; - cfg.t.cfg.s.dlSapCfg.reConfig.mtp2Pst.route = RTESPEC; - cfg.t.cfg.s.dlSapCfg.reConfig.mtp2Pst.prior = PRIOR0; - cfg.t.cfg.s.dlSapCfg.reConfig.mtp2Pst.srcEnt = ENTNW; - cfg.t.cfg.s.dlSapCfg.reConfig.mtp2Pst.srcInst = 0; - cfg.t.cfg.s.dlSapCfg.reConfig.mtp2Pst.srcProcId = SFndProcId(); - cfg.t.cfg.s.dlSapCfg.reConfig.mtp2Pst.dstEnt = ENTSD; - cfg.t.cfg.s.dlSapCfg.reConfig.mtp2Pst.dstInst = 0; - cfg.t.cfg.s.dlSapCfg.reConfig.mtp2Pst.dstProcId = SFndProcId(); - - return (sng_cfg_nif (&pst, &cfg)); -} - -/*****************************************************************************/ -uint32_t iptoul(const char *ip) -{ - char i,*tmp; - int strl; - char strIp[16]; - unsigned long val=0, cvt; - if (!ip) - return 0; - - memset(strIp, 0, sizeof(char)*16); - strl = strlen(ip); - strncpy(strIp, ip, strl>=15?15:strl); - - - tmp=strtok(strIp, "."); - for (i=0;i<4;i++) - { - sscanf(tmp, "%lu", &cvt); - val <<= 8; - val |= (unsigned char)cvt; - tmp=strtok(NULL,"."); - } - return (uint32_t)val; -} -/***********************************************************************************************************************/ -void ftmod_ss7_enable_m2ua_sg_logging(void){ - - /* Enable DEBUGs*/ - ftmod_sctp_debug(AENA); - ftmod_m2ua_debug(AENA); - ftmod_tucl_debug(AENA); -} - -/***********************************************************************************************************************/ -void ftmod_ss7_disable_m2ua_sg_logging(void){ - - /* DISABLE DEBUGs*/ - ftmod_sctp_debug(ADISIMM); - ftmod_m2ua_debug(ADISIMM); - ftmod_tucl_debug(ADISIMM); -} - -/***********************************************************************************************************************/ -int ftmod_ss7_m2ua_start(void){ - int x=0; - -/***********************************************************************************************************************/ - x = 1; - while(xclusterId]; - - if(clust->flags & SNGSS7_M2UA_EP_OPENED) { - ftdm_log (FTDM_LOG_INFO ," END-POINT already opened\n"); - return ret; - } - - memset((U8 *)&pst, 0, sizeof(Pst)); - memset((U8 *)&cntrl, 0, sizeof(MwMgmt)); - - smPstInit(&pst); - - pst.dstEnt = ENTMW; - - /* prepare header */ - cntrl.hdr.msgType = TCNTRL; /* message type */ - cntrl.hdr.entId.ent = ENTMW; /* entity */ - cntrl.hdr.entId.inst = 0; /* instance */ - cntrl.hdr.elmId.elmnt = STMWSCTSAP; /* General */ - cntrl.hdr.transId = 1; /* transaction identifier */ - - cntrl.hdr.response.selector = 0; - cntrl.hdr.response.prior = PRIOR0; - cntrl.hdr.response.route = RTESPEC; - cntrl.hdr.response.mem.region = S_REG; - cntrl.hdr.response.mem.pool = S_POOL; - - - cntrl.t.cntrl.action = AMWENDPOPEN; - cntrl.t.cntrl.s.suId = m2ua->id; /* M2UA sct sap Id */ - - - if(0 == (ret = sng_cntrl_m2ua (&pst, &cntrl))){ - clust->flags |= SNGSS7_M2UA_EP_OPENED; - } - return ret; - -} - -/***********************************************************************************************************************/ -static int ftmod_init_sctp_assoc(int peer_id) -{ - - Pst pst; - MwMgmt cntrl; - - memset((U8 *)&pst, 0, sizeof(Pst)); - memset((U8 *)&cntrl, 0, sizeof(MwMgmt)); - - smPstInit(&pst); - - pst.dstEnt = ENTMW; - - /* prepare header */ - cntrl.hdr.msgType = TCNTRL; /* message type */ - cntrl.hdr.entId.ent = ENTMW; /* entity */ - cntrl.hdr.entId.inst = 0; /* instance */ - cntrl.hdr.elmId.elmnt = STMWPEER; /* General */ - cntrl.hdr.transId = 1; /* transaction identifier */ - - cntrl.hdr.response.selector = 0; - cntrl.hdr.response.prior = PRIOR0; - cntrl.hdr.response.route = RTESPEC; - cntrl.hdr.response.mem.region = S_REG; - cntrl.hdr.response.mem.pool = S_POOL; - - - cntrl.t.cntrl.action = AMWESTABLISH; - /*cntrl.t.cntrl.s.suId = 1;*/ - - cntrl.t.cntrl.s.peerId = (MwPeerId) peer_id; - - return (sng_cntrl_m2ua (&pst, &cntrl)); -} - -/***********************************************************************************************************************/ -static int ftmod_sctp_tucl_tsap_bind(int id) -{ - Pst pst; - SbMgmt cntrl; - sng_sctp_link_t *k = &g_ftdm_sngss7_data.cfg.sctpCfg.linkCfg[id]; - - memset((U8 *)&pst, 0, sizeof(Pst)); - memset((U8 *)&cntrl, 0, sizeof(SbMgmt)); - - smPstInit(&pst); - - pst.dstEnt = ENTSB; - - /* prepare header */ - cntrl.hdr.msgType = TCNTRL; /* message type */ - cntrl.hdr.entId.ent = ENTSB; /* entity */ - cntrl.hdr.entId.inst = 0; /* instance */ - cntrl.hdr.elmId.elmnt = STSBTSAP; /* General */ - cntrl.hdr.transId = 1; /* transaction identifier */ - - cntrl.hdr.response.selector = 0; - - cntrl.hdr.response.prior = PRIOR0; - cntrl.hdr.response.route = RTESPEC; - cntrl.hdr.response.mem.region = S_REG; - cntrl.hdr.response.mem.pool = S_POOL; - - cntrl.t.cntrl.action = ABND_ENA; - cntrl.t.cntrl.sapId = k->id; /* SCT sap id configured at SCTP layer */ - - return (sng_cntrl_sctp (&pst, &cntrl)); -} -/***********************************************************************************************************************/ - -static int ftmod_m2ua_sctp_sctsap_bind(int id) -{ - int ret = 0x00; - Pst pst; - MwMgmt cntrl; - sng_m2ua_cfg_t* m2ua = &g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua[id]; - sng_m2ua_cluster_cfg_t* clust = &g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_clus[m2ua->clusterId]; - - if(clust->flags & SNGSS7_ACTIVE) { - ftdm_log (FTDM_LOG_INFO ," SCT-SAP is already enabled\n"); - return ret; - } - - - memset((U8 *)&pst, 0, sizeof(Pst)); - memset((U8 *)&cntrl, 0, sizeof(MwMgmt)); - - smPstInit(&pst); - - pst.dstEnt = ENTMW; - - /* prepare header */ - cntrl.hdr.msgType = TCNTRL; /* message type */ - cntrl.hdr.entId.ent = ENTMW; /* entity */ - cntrl.hdr.entId.inst = 0; /* instance */ - cntrl.hdr.elmId.elmnt = STMWSCTSAP; /* General */ - cntrl.hdr.transId = 1; /* transaction identifier */ - - cntrl.hdr.response.selector = 0; - cntrl.hdr.response.prior = PRIOR0; - cntrl.hdr.response.route = RTESPEC; - cntrl.hdr.response.mem.region = S_REG; - cntrl.hdr.response.mem.pool = S_POOL; - - cntrl.t.cntrl.action = ABND; - cntrl.t.cntrl.s.suId = m2ua->id; - - if(0 == (ret = sng_cntrl_m2ua (&pst, &cntrl))){ - clust->flags |= SNGSS7_ACTIVE; - } - return ret; -} -/***********************************************************************************************************************/ -static int ftmod_nif_m2ua_dlsap_bind(int id) -{ - Pst pst; - NwMgmt cntrl; - sng_nif_cfg_t* nif = &g_ftdm_sngss7_data.cfg.g_m2ua_cfg.nif[id]; - - memset((U8 *)&pst, 0, sizeof(Pst)); - memset((U8 *)&cntrl, 0, sizeof(NwMgmt)); - - smPstInit(&pst); - - pst.dstEnt = ENTNW; - - /* prepare header */ - cntrl.hdr.msgType = TCNTRL; /* message type */ - cntrl.hdr.entId.ent = ENTNW; /* entity */ - cntrl.hdr.entId.inst = 0; /* instance */ - cntrl.hdr.elmId.elmnt = STNWDLSAP; /* General */ - cntrl.hdr.transId = 1; /* transaction identifier */ - - cntrl.hdr.response.selector = 0; - cntrl.hdr.response.prior = PRIOR0; - cntrl.hdr.response.route = RTESPEC; - cntrl.hdr.response.mem.region = S_REG; - cntrl.hdr.response.mem.pool = S_POOL; - - cntrl.t.cntrl.action = ABND; - cntrl.t.cntrl.suId = nif->id; /* NIF DL sap Id */ - cntrl.t.cntrl.entity = ENTMW; /* M2UA */ - - return (sng_cntrl_nif (&pst, &cntrl)); - -} - -/***********************************************************************************************************************/ -static int ftmod_nif_mtp2_dlsap_bind(int id) -{ - Pst pst; - NwMgmt cntrl; - sng_nif_cfg_t* nif = &g_ftdm_sngss7_data.cfg.g_m2ua_cfg.nif[id]; - - memset((U8 *)&pst, 0, sizeof(Pst)); - memset((U8 *)&cntrl, 0, sizeof(NwMgmt)); - - smPstInit(&pst); - - pst.dstEnt = ENTNW; - - /* prepare header */ - cntrl.hdr.msgType = TCNTRL; /* message type */ - cntrl.hdr.entId.ent = ENTNW; /* entity */ - cntrl.hdr.entId.inst = 0; /* instance */ - cntrl.hdr.elmId.elmnt = STNWDLSAP; /* General */ - cntrl.hdr.transId = 1; /* transaction identifier */ - - cntrl.hdr.response.selector = 0; - cntrl.hdr.response.prior = PRIOR0; - cntrl.hdr.response.route = RTESPEC; - cntrl.hdr.response.mem.region = S_REG; - cntrl.hdr.response.mem.pool = S_POOL; - - cntrl.t.cntrl.action = ABND; - cntrl.t.cntrl.suId = nif->id; /* NIF DL sap Id */ - cntrl.t.cntrl.entity = ENTSD; /* MTP2 */ - - return (sng_cntrl_nif (&pst, &cntrl)); - -} - -/***********************************************************************************************************************/ -static int ftmod_sctp_debug(int action) -{ - Pst pst; - SbMgmt cntrl; - - memset((U8 *)&pst, 0, sizeof(Pst)); - memset((U8 *)&cntrl, 0, sizeof(SbMgmt)); - - smPstInit(&pst); - - pst.dstEnt = ENTSB; - - /* prepare header */ - cntrl.hdr.msgType = TCNTRL; /* message type */ - cntrl.hdr.entId.ent = ENTSB; /* entity */ - cntrl.hdr.entId.inst = 0; /* instance */ - cntrl.hdr.elmId.elmnt = STSBGEN; /* General */ - - cntrl.hdr.response.selector = 0; - cntrl.hdr.response.prior = PRIOR0; - cntrl.hdr.response.route = RTESPEC; - cntrl.hdr.response.mem.region = S_REG; - cntrl.hdr.response.mem.pool = S_POOL; - - cntrl.t.cntrl.action = action; - cntrl.t.cntrl.subAction = SADBG; - cntrl.t.cntrl.dbgMask = 0xFFFF; - - return (sng_cntrl_sctp (&pst, &cntrl)); -} -/***********************************************************************************************************************/ - -static int ftmod_m2ua_debug(int action) -{ - Pst pst; - MwMgmt cntrl; - - memset((U8 *)&pst, 0, sizeof(Pst)); - memset((U8 *)&cntrl, 0, sizeof(MwMgmt)); - - smPstInit(&pst); - - pst.dstEnt = ENTMW; - - /* prepare header */ - cntrl.hdr.msgType = TCNTRL; /* message type */ - cntrl.hdr.entId.ent = ENTMW; /* entity */ - cntrl.hdr.entId.inst = 0; /* instance */ - cntrl.hdr.elmId.elmnt = STMWGEN; /* General */ - - cntrl.hdr.response.selector = 0; - cntrl.hdr.response.prior = PRIOR0; - cntrl.hdr.response.route = RTESPEC; - cntrl.hdr.response.mem.region = S_REG; - cntrl.hdr.response.mem.pool = S_POOL; - - cntrl.t.cntrl.action = action; - cntrl.t.cntrl.subAction = SADBG; - cntrl.t.cntrl.s.dbgMask = 0xFFFF; - - return (sng_cntrl_m2ua (&pst, &cntrl)); -} -/***********************************************************************************************************************/ -static int ftmod_tucl_debug(int action) -{ - Pst pst; - HiMngmt cntrl; - - memset((U8 *)&pst, 0, sizeof(Pst)); - memset((U8 *)&cntrl, 0, sizeof(HiMngmt)); - - smPstInit(&pst); - - pst.dstEnt = ENTHI; - - /* prepare header */ - cntrl.hdr.msgType = TCNTRL; /* message type */ - cntrl.hdr.entId.ent = ENTHI; /* entity */ - cntrl.hdr.entId.inst = 0; /* instance */ - cntrl.hdr.elmId.elmnt = STGEN; /* General */ - - cntrl.hdr.response.selector = 0; - cntrl.hdr.response.prior = PRIOR0; - cntrl.hdr.response.route = RTESPEC; - cntrl.hdr.response.mem.region = S_REG; - cntrl.hdr.response.mem.pool = S_POOL; - - cntrl.t.cntrl.action = action; - cntrl.t.cntrl.subAction = SADBG; - cntrl.t.cntrl.ctlType.hiDbg.dbgMask = 0xFFFF; - - return (sng_cntrl_tucl (&pst, &cntrl)); -} -/***********************************************************************************************************************/ - -/***********************************************************************************************************************/ -int ftmod_sctp_ssta_req(int elemt, int id, SbMgmt* cfm) -{ - SbMgmt ssta; - Pst pst; - sng_sctp_link_t *k = &g_ftdm_sngss7_data.cfg.sctpCfg.linkCfg[id]; - - memset((U8 *)&pst, 0, sizeof(Pst)); - memset((U8 *)&ssta, 0, sizeof(SbMgmt)); - - smPstInit(&pst); - - pst.dstEnt = ENTSB; - - /* prepare header */ - ssta.hdr.msgType = TSSTA; /* message type */ - ssta.hdr.entId.ent = ENTSB; /* entity */ - ssta.hdr.entId.inst = 0; /* instance */ - ssta.hdr.elmId.elmnt = elemt; /* STSBGEN */ /* Others are STSBTSAP, STSBSCTSAP, STSBASSOC, STSBDTA, STSBTMR */ - ssta.hdr.transId = 1; /* transaction identifier */ - - ssta.hdr.response.selector = 0; - ssta.hdr.response.prior = PRIOR0; - ssta.hdr.response.route = RTESPEC; - ssta.hdr.response.mem.region = S_REG; - ssta.hdr.response.mem.pool = S_POOL; - - if((ssta.hdr.elmId.elmnt == STSBSCTSAP) || (ssta.hdr.elmId.elmnt == STSBTSAP)) - { - ssta.t.ssta.sapId = k->id; /* SapId */ - } - if(ssta.hdr.elmId.elmnt == STSBASSOC) - { - /*TODO - how to get assoc Id*/ - ssta.t.ssta.s.assocSta.assocId = 0; /* association id */ - } - return(sng_sta_sctp(&pst,&ssta,cfm)); -} - -int ftmod_m2ua_ssta_req(int elemt, int id, MwMgmt* cfm) -{ - MwMgmt ssta; - Pst pst; - sng_m2ua_cfg_t* m2ua = NULL; - sng_m2ua_cluster_cfg_t* clust = NULL; - - memset((U8 *)&pst, 0, sizeof(Pst)); - memset((U8 *)&ssta, 0, sizeof(MwMgmt)); - - smPstInit(&pst); - - pst.dstEnt = ENTMW; - - /* prepare header */ - ssta.hdr.msgType = TSSTA; /* message type */ - ssta.hdr.entId.ent = ENTMW; /* entity */ - ssta.hdr.entId.inst = 0; /* instance */ - ssta.hdr.elmId.elmnt = elemt; /*STMWGEN */ /* Others are STMWSCTSAP, STMWCLUSTER, STMWPEER,STMWSID, STMWDLSAP */ - ssta.hdr.transId = 1; /* transaction identifier */ - - ssta.hdr.response.selector = 0; - ssta.hdr.response.prior = PRIOR0; - ssta.hdr.response.route = RTESPEC; - ssta.hdr.response.mem.region = S_REG; - ssta.hdr.response.mem.pool = S_POOL; - - switch(ssta.hdr.elmId.elmnt) - { - case STMWSCTSAP: - { - m2ua = &g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua[id]; - clust = &g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_clus[m2ua->clusterId]; - ssta.t.ssta.id.suId = clust->sct_sap_id ; /* lower sap Id */ - break; - } - case STMWDLSAP: - { - ssta.t.ssta.id.lnkNmb = id ; /* upper sap Id */ - break; - } - case STMWPEER: - { - ssta.t.ssta.id.peerId = id ; /* peer Id */ - break; - } - case STMWCLUSTER: - { - clust = &g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_clus[id]; - ssta.t.ssta.id.clusterId = clust->id ; /* cluster Id */ - break; - } - default: - break; - } - - return(sng_sta_m2ua(&pst,&ssta,cfm)); -} - -int ftmod_nif_ssta_req(int elemt, int id, NwMgmt* cfm) -{ - NwMgmt ssta; - Pst pst; - sng_nif_cfg_t* nif = &g_ftdm_sngss7_data.cfg.g_m2ua_cfg.nif[id]; - - memset((U8 *)&pst, 0, sizeof(Pst)); - memset((U8 *)&ssta, 0, sizeof(NwMgmt)); - - smPstInit(&pst); - - pst.dstEnt = ENTNW; - - /* prepare header */ - ssta.hdr.msgType = TSSTA; /* message type */ - ssta.hdr.entId.ent = ENTNW; /* entity */ - ssta.hdr.entId.inst = 0; /* instance */ - ssta.hdr.elmId.elmnt = elemt; - - ssta.hdr.response.selector = 0; - ssta.hdr.response.prior = PRIOR0; - ssta.hdr.response.route = RTESPEC; - ssta.hdr.response.mem.region = S_REG; - ssta.hdr.response.mem.pool = S_POOL; - ssta.t.ssta.suId = nif->id; /* Lower sapId */ - - return(sng_sta_nif(&pst,&ssta,cfm)); -} diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_m2ua.h b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_m2ua.h deleted file mode 100644 index 8bb564d284..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_m2ua.h +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (c) 2012, Kapil Gupta - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - * Contributors: - * - */ -/******************************************************************************/ -#ifndef __FTMOD_SNG_SS7_M2UA_H__ -#define __FTMOD_SNG_SS7_M2UA_H__ -/******************************************************************************/ -#include "private/ftdm_core.h" - -#define MAX_NAME_LEN 25 - -typedef struct sng_nif_cfg{ - char name[MAX_NAME_LEN]; - uint32_t flags; - uint32_t id; - uint32_t m2uaLnkNmb; - uint32_t mtp2LnkNmb; -}sng_nif_cfg_t; - -typedef enum{ - SNG_M2UA_NODE_TYPE_SGP = 1, /* type SG */ - SNG_M2UA_NODE_TYPE_ASP = 2, /* type ASP */ -}sng_m2ua_node_types_e; - -typedef struct sng_m2ua_cfg{ - char name[MAX_NAME_LEN]; - uint32_t flags; - uint32_t id; /* ID */ - uint32_t iid; /* ID */ - uint8_t nodeType; /*Node Type SG/ASP */ - uint8_t end_point_opened; /* flag to check is end-point already opened */ - uint16_t clusterId; /* idx to m2ua_cluster profile */ -}sng_m2ua_cfg_t; - -typedef struct sng_m2ua_peer_cfg{ - char name[MAX_NAME_LEN]; - uint32_t flags; - uint32_t id; /* ID */ - uint8_t aspIdFlag; /* Flag used to indicate whether include the ASP ID in the ASP UP message */ - uint16_t selfAspId; /* Self ASP ID. ASP identifier for this ASP node if the aspIdFlag is TRUE. */ - uint32_t numDestAddr; /* Number of destination address defined */ - uint16_t sctpId; /* idx to sctp profile */ - uint16_t port; - uint32_t destAddrList[SCT_MAX_NET_ADDRS+1]; /* Destination adddress list */ - uint16_t locOutStrms; /*Number of outgoing streams supported by this association*/ - int init_sctp_assoc; /* flag to tell if we need to initiate SCTP association */ -}sng_m2ua_peer_cfg_t; - -typedef enum{ - SNG_M2UA_LOAD_SHARE_ALGO_RR = 0x1, /* Round Robin Mode*/ - SNG_M2UA_LOAD_SHARE_ALGO_LS = 0x2, /* Link Specified */ - SNG_M2UA_LOAD_SHARE_ALGO_CS = 0x3, /* Customer Specified */ -}sng_m2ua_load_share_algo_types_e; - - -/* Possible values of Traffic mode */ -typedef enum{ - SNG_M2UA_TRF_MODE_OVERRIDE = 0x1, /* Override Mode */ - SNG_M2UA_TRF_MODE_LOADSHARE = 0x2, /* Loadshare Mode */ - SNG_M2UA_TRF_MODE_BROADCAST = 0x3, /* Broadcast Mode */ - SNG_M2UA_TRF_MODE_ANY = 0x0, /* ANY Mode */ -}sng_m2ua_traffic_mode_types_e; - -typedef struct sng_m2ua_cluster_cfg{ - char name[MAX_NAME_LEN]; - uint32_t flags; - uint32_t id; /* ID */ - uint32_t sct_sap_id; /* Internal - sct_sap_id */ - uint8_t trfMode; /* Traffic mode. This parameter defines the mode in which this m2ua cluster is supposed to work */ - uint8_t loadShareAlgo; /* This parameter defines the M2UA load share algorithm which is used to distribute the traffic */ - uint16_t numOfPeers; /* idx to m2ua_peer profile */ - uint16_t peerIdLst[MW_MAX_NUM_OF_PEER]; /* idx to m2ua_peer profile */ -}sng_m2ua_cluster_cfg_t; - -typedef struct sng_m2ua_gbl_cfg{ - sng_nif_cfg_t nif[MW_MAX_NUM_OF_INTF+1]; - sng_m2ua_cfg_t m2ua[MW_MAX_NUM_OF_INTF+1]; - sng_m2ua_peer_cfg_t m2ua_peer[MW_MAX_NUM_OF_PEER+1]; - sng_m2ua_cluster_cfg_t m2ua_clus[MW_MAX_NUM_OF_CLUSTER+1]; -}sng_m2ua_gbl_cfg_t; - -/* m2ua xml parsing APIs */ -int ftmod_ss7_parse_nif_interfaces(ftdm_conf_node_t *nif_interfaces); -int ftmod_ss7_parse_m2ua_interfaces(ftdm_conf_node_t *m2ua_interfaces); -int ftmod_ss7_parse_m2ua_peer_interfaces(ftdm_conf_node_t *m2ua_peer_interfaces); -int ftmod_ss7_parse_m2ua_clust_interfaces(ftdm_conf_node_t *m2ua_clust_interfaces); -int ftmod_ss7_parse_sctp_links(ftdm_conf_node_t *node); -uint32_t iptoul(const char *ip); - -int ftmod_ss7_m2ua_start(void); -void ftmod_ss7_m2ua_free(void); - -ftdm_status_t ftmod_ss7_m2ua_cfg(void); -ftdm_status_t ftmod_ss7_m2ua_init(void); - -int ftmod_sctp_ssta_req(int elemt, int id, SbMgmt* cfm); -int ftmod_m2ua_ssta_req(int elemt, int id, MwMgmt* cfm); -int ftmod_nif_ssta_req(int elemt, int id, NwMgmt* cfm); -void ftmod_ss7_enable_m2ua_sg_logging(void); -void ftmod_ss7_disable_m2ua_sg_logging(void); - - -#endif /*__FTMOD_SNG_SS7_M2UA_H__*/ diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_m2ua_xml.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_m2ua_xml.c deleted file mode 100644 index bb011c364e..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_m2ua_xml.c +++ /dev/null @@ -1,690 +0,0 @@ -/* - * Copyright (c) 2012, Kapil Gupta - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - * Contributors: - * - * - */ - -/* INCLUDE ********************************************************************/ -#include "ftmod_sangoma_ss7_main.h" -/******************************************************************************/ - -/* DEFINES ********************************************************************/ -/******************************************************************************/ - -static int ftmod_ss7_parse_nif_interface(ftdm_conf_node_t *nif_interface); -static int ftmod_ss7_parse_m2ua_interface(ftdm_conf_node_t *m2ua_interface); -static int ftmod_ss7_parse_m2ua_peer_interface(ftdm_conf_node_t *m2ua_peer_interface); -static int ftmod_ss7_parse_m2ua_clust_interface(ftdm_conf_node_t *m2ua_clust_interface); -static int ftmod_ss7_fill_in_nif_interface(sng_nif_cfg_t *nif_iface); -static int ftmod_ss7_fill_in_m2ua_interface(sng_m2ua_cfg_t *m2ua_iface); -static int ftmod_ss7_fill_in_m2ua_peer_interface(sng_m2ua_peer_cfg_t *m2ua_peer_face); -static int ftmod_ss7_fill_in_m2ua_clust_interface(sng_m2ua_cluster_cfg_t *m2ua_cluster_face); - -static int ftmod_ss7_parse_sctp_link(ftdm_conf_node_t *node); - -/******************************************************************************/ -int ftmod_ss7_parse_nif_interfaces(ftdm_conf_node_t *nif_interfaces) -{ - ftdm_conf_node_t *nif_interface = NULL; - - /* confirm that we are looking at sng_nif_interfaces */ - if (strcasecmp(nif_interfaces->name, "sng_nif_interfaces")) { - SS7_ERROR("We're looking at \"%s\"...but we're supposed to be looking at \"sng_nif_interfaces\"!\n",nif_interfaces->name); - return FTDM_FAIL; - } else { - SS7_DEBUG("Parsing \"nif_interfaces\"...\n"); - } - - /* extract the isup_interfaces */ - nif_interface = nif_interfaces->child; - - while (nif_interface != NULL) { - /* parse the found mtp_route */ - if (ftmod_ss7_parse_nif_interface(nif_interface)) { - SS7_ERROR("Failed to parse \"nif_interface\"\n"); - return FTDM_FAIL; - } - - /* go to the next nif_interface */ - nif_interface = nif_interface->next; - } - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static int ftmod_ss7_parse_nif_interface(ftdm_conf_node_t *nif_interface) -{ - sng_nif_cfg_t sng_nif; - ftdm_conf_parameter_t *parm = nif_interface->parameters; - int num_parms = nif_interface->n_parameters; - int i; - - /* initalize the nif intf and isap structure */ - memset(&sng_nif, 0x0, sizeof(sng_nif)); - - if(!nif_interface){ - SS7_ERROR("ftmod_ss7_parse_nif_interface: Null XML Node pointer \n"); - return FTDM_FAIL; - } - - /* confirm that we are looking at an nif_interface */ - if (strcasecmp(nif_interface->name, "sng_nif_interface")) { - SS7_ERROR("We're looking at \"%s\"...but we're supposed to be looking at \"nif_interface\"!\n",nif_interface->name); - return FTDM_FAIL; - } else { - SS7_DEBUG("Parsing \"nif_interface\"...\n"); - } - - - for (i = 0; i < num_parms; i++) { - /**************************************************************************/ - - /* try to match the parameter to what we expect */ - if (!strcasecmp(parm->var, "name")) { - /**********************************************************************/ - strcpy((char *)sng_nif.name, parm->val); - SS7_DEBUG("Found an nif_interface named = %s\n", sng_nif.name); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "id")) { - /**********************************************************************/ - sng_nif.id = atoi(parm->val); - SS7_DEBUG("Found an nif id = %d\n", sng_nif.id); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "m2ua-interface-id")) { - /**********************************************************************/ - sng_nif.m2uaLnkNmb = atoi(parm->val); - SS7_DEBUG("Found an nif m2ua-interface-id = %d\n", sng_nif.m2uaLnkNmb); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "mtp2-interface-id")) { - /**********************************************************************/ - sng_nif.mtp2LnkNmb=atoi(parm->val); - - SS7_DEBUG("Found an nif mtp2-interface-id = %d\n", sng_nif.mtp2LnkNmb); - /**********************************************************************/ - } else { - /**********************************************************************/ - SS7_ERROR("Found an invalid parameter %s!\n", parm->var); - return FTDM_FAIL; - /**********************************************************************/ - } - - /* move to the next parameter */ - parm = parm + 1; - /**************************************************************************/ - } /* for (i = 0; i < num_parms; i++) */ - - /* fill in the nif interface */ - ftmod_ss7_fill_in_nif_interface(&sng_nif); - - return FTDM_SUCCESS; -} -/******************************************************************************/ -static int ftmod_ss7_fill_in_nif_interface(sng_nif_cfg_t *nif_iface) -{ - int i = nif_iface->id; - - strncpy((char *)g_ftdm_sngss7_data.cfg.g_m2ua_cfg.nif[i].name, (char *)nif_iface->name, MAX_NAME_LEN-1); - - g_ftdm_sngss7_data.cfg.g_m2ua_cfg.nif[i].id = nif_iface->id; - g_ftdm_sngss7_data.cfg.g_m2ua_cfg.nif[i].m2uaLnkNmb = nif_iface->m2uaLnkNmb; - g_ftdm_sngss7_data.cfg.g_m2ua_cfg.nif[i].mtp2LnkNmb = nif_iface->mtp2LnkNmb; - - sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_NIF_PRESENT); - - return 0; -} - -/******************************************************************************/ -int ftmod_ss7_parse_m2ua_interfaces(ftdm_conf_node_t *m2ua_interfaces) -{ - ftdm_conf_node_t *m2ua_interface = NULL; - - /* confirm that we are looking at sng_m2ua_interfaces */ - if (strcasecmp(m2ua_interfaces->name, "sng_m2ua_interfaces")) { - SS7_ERROR("We're looking at \"%s\"...but we're supposed to be looking at \"m2ua_nif_interfaces\"!\n",m2ua_interfaces->name); - return FTDM_FAIL; - } else { - SS7_DEBUG("Parsing \"m2ua_interfaces\"...\n"); - } - - /* extract the isup_interfaces */ - m2ua_interface = m2ua_interfaces->child; - - while (m2ua_interface != NULL) { - /* parse the found mtp_route */ - if (ftmod_ss7_parse_m2ua_interface(m2ua_interface)) { - SS7_ERROR("Failed to parse \"m2ua_interface\"\n"); - return FTDM_FAIL; - } - - /* go to the next m2ua_interface */ - m2ua_interface = m2ua_interface->next; - } - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static int ftmod_ss7_parse_m2ua_interface(ftdm_conf_node_t *m2ua_interface) -{ - sng_m2ua_cfg_t sng_m2ua; - ftdm_conf_parameter_t *parm = m2ua_interface->parameters; - int num_parms = m2ua_interface->n_parameters; - int i; - - /* initalize the m2ua intf */ - memset(&sng_m2ua, 0x0, sizeof(sng_m2ua)); - - if(!m2ua_interface){ - SS7_ERROR("ftmod_ss7_parse_m2ua_interface: Null XML Node pointer \n"); - return FTDM_FAIL; - } - - /* confirm that we are looking at an nif_interface */ - if (strcasecmp(m2ua_interface->name, "sng_m2ua_interface")) { - SS7_ERROR("We're looking at \"%s\"...but we're supposed to be looking at \"m2ua_interface\"!\n",m2ua_interface->name); - return FTDM_FAIL; - } else { - SS7_DEBUG("Parsing \"m2ua_interface\"...\n"); - } - - - for (i = 0; i < num_parms; i++) { - /**************************************************************************/ - - /* try to match the parameter to what we expect */ - if (!strcasecmp(parm->var, "name")) { - /**********************************************************************/ - strcpy((char *)sng_m2ua.name, parm->val); - SS7_DEBUG("Found an m2ua_interface named = %s\n", sng_m2ua.name); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "id")) { - /**********************************************************************/ - sng_m2ua.id = atoi(parm->val); - SS7_DEBUG("Found an m2ua id = %d\n", sng_m2ua.id); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "m2ua-cluster-interface-id")) { - /**********************************************************************/ - sng_m2ua.clusterId=atoi(parm->val); - - SS7_DEBUG("Found an m2ua cluster_id = %d\n", sng_m2ua.clusterId); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "interface-identifier")) { - /**********************************************************************/ - sng_m2ua.iid=atoi(parm->val); - - SS7_DEBUG("Found an m2ua interface-identifier = %d\n", sng_m2ua.iid); - /**********************************************************************/ - } else { - /**********************************************************************/ - SS7_ERROR("Found an invalid parameter %s!\n", parm->var); - return FTDM_FAIL; - /**********************************************************************/ - } - - /* move to the next parameter */ - parm = parm + 1; - /**************************************************************************/ - } /* for (i = 0; i < num_parms; i++) */ - - sng_m2ua.nodeType = SNG_M2UA_NODE_TYPE_SGP; - - /* fill in the nif interface */ - ftmod_ss7_fill_in_m2ua_interface(&sng_m2ua); - - return FTDM_SUCCESS; -} -/******************************************************************************/ -static int ftmod_ss7_fill_in_m2ua_interface(sng_m2ua_cfg_t *m2ua_iface) -{ - int i = m2ua_iface->id; - - strncpy((char *)g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua[i].name, (char *)m2ua_iface->name, MAX_NAME_LEN-1); - - g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua[i].id = m2ua_iface->id; - g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua[i].nodeType = m2ua_iface->nodeType; - g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua[i].clusterId = m2ua_iface->clusterId; - g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua[i].iid = m2ua_iface->iid; - sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_M2UA_PRESENT); - - return 0; -} - -/******************************************************************************/ -int ftmod_ss7_parse_m2ua_peer_interfaces(ftdm_conf_node_t *m2ua_peer_interfaces) -{ - ftdm_conf_node_t *m2ua_peer_interface = NULL; - - /* confirm that we are looking at m2ua_peer_interfaces */ - if (strcasecmp(m2ua_peer_interfaces->name, "sng_m2ua_peer_interfaces")) { - SS7_ERROR("We're looking at \"%s\"...but we're supposed to be looking at \"m2ua_peer_interfaces\"!\n",m2ua_peer_interfaces->name); - return FTDM_FAIL; - } else { - SS7_DEBUG("Parsing \"m2ua_peer_interfaces\"...\n"); - } - - /* extract the m2ua_peer_interfaces */ - m2ua_peer_interface = m2ua_peer_interfaces->child; - - while (m2ua_peer_interface != NULL) { - /* parse the found mtp_route */ - if (ftmod_ss7_parse_m2ua_peer_interface(m2ua_peer_interface)) { - SS7_ERROR("Failed to parse \"m2ua_peer_interface\"\n"); - return FTDM_FAIL; - } - - /* go to the next m2ua_peer_interface */ - m2ua_peer_interface = m2ua_peer_interface->next; - } - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static int ftmod_ss7_parse_m2ua_peer_interface(ftdm_conf_node_t *m2ua_peer_interface) -{ - sng_m2ua_peer_cfg_t sng_m2ua_peer; - ftdm_conf_parameter_t *parm = m2ua_peer_interface->parameters; - int num_parms = m2ua_peer_interface->n_parameters; - int i; - - /* initalize the m2ua intf */ - memset(&sng_m2ua_peer, 0x0, sizeof(sng_m2ua_peer)); - - if(!m2ua_peer_interface){ - SS7_ERROR("ftmod_ss7_parse_m2ua_peer_interface: Null XML Node pointer \n"); - return FTDM_FAIL; - } - - /* confirm that we are looking at an m2ua_peer_interface */ - if (strcasecmp(m2ua_peer_interface->name, "sng_m2ua_peer_interface")) { - SS7_ERROR("We're looking at \"%s\"...but we're supposed to be looking at \"m2ua_peer_interface\"!\n",m2ua_peer_interface->name); - return FTDM_FAIL; - } else { - SS7_DEBUG("Parsing \"m2ua_peer_interface\"...\n"); - } - - for (i = 0; i < num_parms; i++) { - /**************************************************************************/ - - /* try to match the parameter to what we expect */ - if (!strcasecmp(parm->var, "name")) { - /**********************************************************************/ - strcpy((char *)sng_m2ua_peer.name, parm->val); - SS7_DEBUG("Found an sng_m2ua_peer named = %s\n", sng_m2ua_peer.name); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "id")) { - /**********************************************************************/ - sng_m2ua_peer.id = atoi(parm->val); - SS7_DEBUG("Found an sng_m2ua_peer id = %d\n", sng_m2ua_peer.id); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "include-asp-identifier")) { - /**********************************************************************/ - if(!strcasecmp(parm->val, "TRUE")){ - sng_m2ua_peer.aspIdFlag = 0x01; - } else if(!strcasecmp(parm->val, "FALSE")){ - sng_m2ua_peer.aspIdFlag = 0x00; - } else { - SS7_ERROR("Found an invalid aspIdFlag Parameter Value[%s]\n", parm->val); - return FTDM_FAIL; - } - SS7_DEBUG("Found an sng_m2ua_peer aspIdFlag = %d\n", sng_m2ua_peer.aspIdFlag); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "asp-identifier")) { - /**********************************************************************/ - sng_m2ua_peer.selfAspId=atoi(parm->val); - - SS7_DEBUG("Found an sng_m2ua_peer self_asp_id = %d\n", sng_m2ua_peer.selfAspId); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "sctp-interface-id")) { - /**********************************************************************/ - sng_m2ua_peer.sctpId = atoi(parm->val); - - SS7_DEBUG("Found an sng_m2ua_peer sctp_id = %d\n", sng_m2ua_peer.sctpId); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "destination-port")) { - /**********************************************************************/ - sng_m2ua_peer.port = atoi(parm->val); - - SS7_DEBUG("Found an sng_m2ua_peer port = %d\n", sng_m2ua_peer.port); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "address")) { - /**********************************************************************/ - if (sng_m2ua_peer.numDestAddr < SCT_MAX_NET_ADDRS) { - sng_m2ua_peer.destAddrList[sng_m2ua_peer.numDestAddr] = iptoul (parm->val); - sng_m2ua_peer.numDestAddr++; - SS7_DEBUG("sng_m2ua_peer - Parsing with dest IP Address = %s \n", parm->val); - } else { - SS7_ERROR("sng_m2ua_peer - too many dest address configured. dropping %s \n", parm->val); - } - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "number-of-outgoing-streams")) { - /**********************************************************************/ - sng_m2ua_peer.locOutStrms=atoi(parm->val); - - SS7_DEBUG("Found an sng_m2ua_peer number-of-outgoing-streams = %d\n", sng_m2ua_peer.locOutStrms); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "init-sctp-association")) { - /**********************************************************************/ - if(!strcasecmp(parm->val, "TRUE")){ - sng_m2ua_peer.init_sctp_assoc = 0x01; - } else if(!strcasecmp(parm->val, "FALSE")){ - sng_m2ua_peer.init_sctp_assoc = 0x00; - } else { - SS7_ERROR("Found an invalid init_sctp_assoc Parameter Value[%s]\n", parm->val); - return FTDM_FAIL; - } - - SS7_DEBUG("Found an sng_m2ua_peer init_sctp_assoc = %d\n", sng_m2ua_peer.init_sctp_assoc); - /**********************************************************************/ - } else { - /**********************************************************************/ - SS7_ERROR("Found an invalid parameter %s!\n", parm->var); - return FTDM_FAIL; - /**********************************************************************/ - } - - /* move to the next parameter */ - parm = parm + 1; - /**************************************************************************/ - } /* for (i = 0; i < num_parms; i++) */ - - /* fill in the sng_m2ua_peer interface */ - ftmod_ss7_fill_in_m2ua_peer_interface(&sng_m2ua_peer); - - return FTDM_SUCCESS; -} -/******************************************************************************/ -static int ftmod_ss7_fill_in_m2ua_peer_interface(sng_m2ua_peer_cfg_t *m2ua_peer_iface) -{ - int k = 0x00; - int i = m2ua_peer_iface->id; - - strncpy((char *)g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_peer[i].name, (char *)m2ua_peer_iface->name, MAX_NAME_LEN-1); - - g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_peer[i].id = m2ua_peer_iface->id; - g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_peer[i].aspIdFlag = m2ua_peer_iface->aspIdFlag; - g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_peer[i].selfAspId = m2ua_peer_iface->selfAspId; - g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_peer[i].locOutStrms = m2ua_peer_iface->locOutStrms; - g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_peer[i].numDestAddr = m2ua_peer_iface->numDestAddr; - g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_peer[i].sctpId = m2ua_peer_iface->sctpId; - g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_peer[i].port = m2ua_peer_iface->port; - g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_peer[i].init_sctp_assoc = m2ua_peer_iface->init_sctp_assoc; - for (k=0; knumDestAddr; k++) { - g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_peer[i].destAddrList[k] = m2ua_peer_iface->destAddrList[k]; - } - - - return 0; -} - -/******************************************************************************/ -int ftmod_ss7_parse_m2ua_clust_interfaces(ftdm_conf_node_t *m2ua_cluster_interfaces) -{ - ftdm_conf_node_t *m2ua_cluster_interface = NULL; - - /* confirm that we are looking at m2ua_cluster_interfaces */ - if (strcasecmp(m2ua_cluster_interfaces->name, "sng_m2ua_cluster_interfaces")) { - SS7_ERROR("We're looking at \"%s\"...but we're supposed to be looking at \"m2ua_cluster_interfaces\"!\n",m2ua_cluster_interfaces->name); - return FTDM_FAIL; - } else { - SS7_DEBUG("Parsing \"m2ua_cluster_interfaces\"...\n"); - } - - /* extract the m2ua_cluster_interfaces */ - m2ua_cluster_interface = m2ua_cluster_interfaces->child; - - while (m2ua_cluster_interface != NULL) { - /* parse the found m2ua_cluster_interface */ - if (ftmod_ss7_parse_m2ua_clust_interface(m2ua_cluster_interface)) { - SS7_ERROR("Failed to parse \"m2ua_cluster_interface\"\n"); - return FTDM_FAIL; - } - - /* go to the next m2ua_cluster_interface */ - m2ua_cluster_interface = m2ua_cluster_interface->next; - } - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static int ftmod_ss7_parse_m2ua_clust_interface(ftdm_conf_node_t *m2ua_cluster_interface) -{ - sng_m2ua_cluster_cfg_t sng_m2ua_cluster; - ftdm_conf_parameter_t *parm = m2ua_cluster_interface->parameters; - int num_parms = m2ua_cluster_interface->n_parameters; - int i; - - /* initalize the m2ua_cluster_interface */ - memset(&sng_m2ua_cluster, 0x0, sizeof(sng_m2ua_cluster)); - - if (!m2ua_cluster_interface){ - SS7_ERROR("ftmod_ss7_parse_m2ua_clust_interface - NULL XML Node pointer \n"); - return FTDM_FAIL; - } - - /* confirm that we are looking at an m2ua_cluster_interface */ - if (strcasecmp(m2ua_cluster_interface->name, "sng_m2ua_cluster_interface")) { - SS7_ERROR("We're looking at \"%s\"...but we're supposed to be looking at \"m2ua_cluster_interface\"!\n",m2ua_cluster_interface->name); - return FTDM_FAIL; - } else { - SS7_DEBUG("Parsing \"m2ua_cluster_interface\"...\n"); - } - - - for (i = 0; i < num_parms; i++) { - /**************************************************************************/ - - /* try to match the parameter to what we expect */ - if (!strcasecmp(parm->var, "name")) { - /**********************************************************************/ - strcpy((char *)sng_m2ua_cluster.name, parm->val); - SS7_DEBUG("Found an sng_m2ua_cluster named = %s\n", sng_m2ua_cluster.name); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "id")) { - /**********************************************************************/ - sng_m2ua_cluster.id = atoi(parm->val); - SS7_DEBUG("Found an sng_m2ua_cluster id = %d\n", sng_m2ua_cluster.id); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "traffic-mode")) { - /**********************************************************************/ - if(!strcasecmp(parm->val, "loadshare")){ - sng_m2ua_cluster.trfMode = SNG_M2UA_TRF_MODE_LOADSHARE; - } else if(!strcasecmp(parm->val, "override")){ - sng_m2ua_cluster.trfMode = SNG_M2UA_TRF_MODE_OVERRIDE; - } else if(!strcasecmp(parm->val, "broadcast")){ - sng_m2ua_cluster.trfMode = SNG_M2UA_TRF_MODE_BROADCAST; - } else { - SS7_ERROR("Found an invalid trfMode Parameter Value[%s]..adding default one[ANY]\n", parm->val); - sng_m2ua_cluster.trfMode = SNG_M2UA_TRF_MODE_ANY; - } - SS7_DEBUG("Found an sng_m2ua_cluster.trfMode = %d\n", sng_m2ua_cluster.trfMode); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "load-share-algorithm")) { - /**********************************************************************/ - if(!strcasecmp(parm->val, "roundrobin")){ - sng_m2ua_cluster.loadShareAlgo = SNG_M2UA_LOAD_SHARE_ALGO_RR; - } else if(!strcasecmp(parm->val, "linkspecified")){ - sng_m2ua_cluster.loadShareAlgo = SNG_M2UA_LOAD_SHARE_ALGO_LS; - } else if(!strcasecmp(parm->val, "customerspecified")){ - sng_m2ua_cluster.loadShareAlgo = SNG_M2UA_LOAD_SHARE_ALGO_CS; - } else { - SS7_ERROR("Found an invalid loadShareAlgo Parameter Value[%s]\n", parm->val); - return FTDM_FAIL; - } - - SS7_DEBUG("Found an sng_m2ua_cluster.loadShareAlgo = %d\n", sng_m2ua_cluster.loadShareAlgo); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "m2ua-peer-interface-id")) { - /**********************************************************************/ - if(sng_m2ua_cluster.numOfPeers < MW_MAX_NUM_OF_PEER) { - sng_m2ua_cluster.peerIdLst[sng_m2ua_cluster.numOfPeers] = atoi(parm->val); - SS7_DEBUG("Found an sng_m2ua_cluster peerId[%d], Total numOfPeers[%d] \n", - sng_m2ua_cluster.peerIdLst[sng_m2ua_cluster.numOfPeers], - sng_m2ua_cluster.numOfPeers+1); - sng_m2ua_cluster.numOfPeers++; - }else{ - SS7_ERROR("Peer List excedding max[%d] limit \n", MW_MAX_NUM_OF_PEER); - return FTDM_FAIL; - } - /**********************************************************************/ - } else { - /**********************************************************************/ - SS7_ERROR("Found an invalid parameter %s!\n", parm->var); - return FTDM_FAIL; - /**********************************************************************/ - } - - /* move to the next parameter */ - parm = parm + 1; - /**************************************************************************/ - } /* for (i = 0; i < num_parms; i++) */ - - /* fill in the sng_m2ua_peer interface */ - ftmod_ss7_fill_in_m2ua_clust_interface(&sng_m2ua_cluster); - - return FTDM_SUCCESS; -} -/******************************************************************************/ -static int ftmod_ss7_fill_in_m2ua_clust_interface(sng_m2ua_cluster_cfg_t *m2ua_cluster_iface) -{ - int k = 0x00; - int i = m2ua_cluster_iface->id; - - strncpy((char *)g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_clus[i].name, (char *)m2ua_cluster_iface->name, MAX_NAME_LEN-1); - - g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_clus[i].id = m2ua_cluster_iface->id; - g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_clus[i].trfMode = m2ua_cluster_iface->trfMode; - g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_clus[i].loadShareAlgo = m2ua_cluster_iface->loadShareAlgo; - g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_clus[i].numOfPeers = m2ua_cluster_iface->numOfPeers; - for(k=0;knumOfPeers;k++){ - g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_clus[i].peerIdLst[k] = m2ua_cluster_iface->peerIdLst[k]; - } - - return 0; -} - -/******************************************************************************/ -int ftmod_ss7_parse_sctp_links(ftdm_conf_node_t *node) -{ - ftdm_conf_node_t *node_sctp_link = NULL; - - if (!node) - return FTDM_FAIL; - - if (strcasecmp(node->name, "sng_sctp_interfaces")) { - SS7_ERROR("SCTP - We're looking at <%s>...but we're supposed to be looking at !\n", node->name); - return FTDM_FAIL; - } else { - SS7_DEBUG("SCTP - Parsing configurations\n"); - } - - for (node_sctp_link = node->child; node_sctp_link != NULL; node_sctp_link = node_sctp_link->next) { - if (ftmod_ss7_parse_sctp_link(node_sctp_link) != FTDM_SUCCESS) { - SS7_ERROR("SCTP - Failed to parse . \n"); - return FTDM_FAIL; - } - } - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static int ftmod_ss7_parse_sctp_link(ftdm_conf_node_t *node) -{ - ftdm_conf_parameter_t *param = NULL; - int num_params = 0; - int i=0; - - if (!node){ - SS7_ERROR("SCTP - NULL XML Node pointer \n"); - return FTDM_FAIL; - } - - param = node->parameters; - num_params = node->n_parameters; - - sng_sctp_link_t t_link; - memset (&t_link, 0, sizeof(sng_sctp_link_t)); - - if (strcasecmp(node->name, "sng_sctp_interface")) { - SS7_ERROR("SCTP - We're looking at <%s>...but we're supposed to be looking at !\n", node->name); - return FTDM_FAIL; - } else { - SS7_DEBUG("SCTP - Parsing configurations\n"); - } - - for (i=0; ivar, "name")) { - int n_strlen = strlen(param->val); - strncpy((char*)t_link.name, param->val, (n_strlen>MAX_NAME_LEN)?MAX_NAME_LEN:n_strlen); - SS7_DEBUG("SCTP - Parsing with name = %s\n", param->val); - } - else if (!strcasecmp(param->var, "id")) { - t_link.id = atoi(param->val); - SS7_DEBUG("SCTP - Parsing with id = %s\n", param->val); - } - else if (!strcasecmp(param->var, "address")) { - if (t_link.numSrcAddr < SCT_MAX_NET_ADDRS) { - t_link.srcAddrList[t_link.numSrcAddr+1] = iptoul (param->val); - t_link.numSrcAddr++; - SS7_DEBUG("SCTP - Parsing with source IP Address = %s\n", param->val); - } else { - SS7_ERROR("SCTP - too many source address configured. dropping %s \n", param->val); - } - } else if (!strcasecmp(param->var, "source-port")) { - t_link.port = atoi(param->val); - SS7_DEBUG("SCTP - Parsing with port = %s\n", param->val); - } - else { - SS7_ERROR("SCTP - Found an unknown parameter <%s>. Skipping it.\n", param->var); - } - } - - g_ftdm_sngss7_data.cfg.sctpCfg.linkCfg[t_link.id].id = t_link.id; - g_ftdm_sngss7_data.cfg.sctpCfg.linkCfg[t_link.id].port = t_link.port; - strncpy((char*)g_ftdm_sngss7_data.cfg.sctpCfg.linkCfg[t_link.id].name, t_link.name, strlen(t_link.name) ); - g_ftdm_sngss7_data.cfg.sctpCfg.linkCfg[t_link.id].numSrcAddr = t_link.numSrcAddr; - for (i=1; i<=t_link.numSrcAddr; i++) { - g_ftdm_sngss7_data.cfg.sctpCfg.linkCfg[t_link.id].srcAddrList[i] = t_link.srcAddrList[i]; - } - - sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_SCTP_PRESENT); - - return FTDM_SUCCESS; -} -/******************************************************************************/ diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c deleted file mode 100644 index 47c88c29c5..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c +++ /dev/null @@ -1,2766 +0,0 @@ -/* - * Copyright (c) 2009, Sangoma Technologies - * Konrad Hammel - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Contributors: - * - * Moises Silva - * David Yat Sin - * James Zhang - * - */ - -/* INCLUDE ********************************************************************/ -#include "ftmod_sangoma_ss7_main.h" -/******************************************************************************/ - -/* DEFINES ********************************************************************/ -/******************************************************************************/ - -/* GLOBALS ********************************************************************/ -static sng_isup_event_interface_t sng_event; -static ftdm_io_interface_t g_ftdm_sngss7_interface; -ftdm_sngss7_data_t g_ftdm_sngss7_data; -ftdm_sngss7_opr_mode g_ftdm_operating_mode; - -/******************************************************************************/ - -/* PROTOTYPES *****************************************************************/ -static void *ftdm_sangoma_ss7_run (ftdm_thread_t * me, void *obj); -static void ftdm_sangoma_ss7_process_stack_event (sngss7_event_data_t *sngss7_event); -static void ftdm_sangoma_ss7_process_peer_stack_event (ftdm_channel_t *ftdmchan, sngss7_event_data_t *sngss7_event); - -static ftdm_status_t ftdm_sangoma_ss7_stop (ftdm_span_t * span); -static ftdm_status_t ftdm_sangoma_ss7_start (ftdm_span_t * span); -/******************************************************************************/ - - -/* STATE MAP ******************************************************************/ -ftdm_state_map_t sangoma_ss7_state_map = { - { - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_SUSPENDED, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_RESTART, FTDM_CHANNEL_STATE_DOWN, - FTDM_CHANNEL_STATE_IN_LOOP, FTDM_CHANNEL_STATE_COLLECT, - FTDM_CHANNEL_STATE_RING, FTDM_CHANNEL_STATE_PROGRESS, - FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_UP, - FTDM_CHANNEL_STATE_CANCEL, FTDM_CHANNEL_STATE_TERMINATING, - FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_HANGUP_COMPLETE, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_RESTART, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_SUSPENDED, FTDM_CHANNEL_STATE_TERMINATING, - FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_HANGUP_COMPLETE, - FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_IDLE, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_IDLE, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_RESTART, FTDM_CHANNEL_STATE_COLLECT, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_SUSPENDED, FTDM_CHANNEL_STATE_RESTART, - FTDM_CHANNEL_STATE_COLLECT, FTDM_CHANNEL_STATE_IN_LOOP, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_IN_LOOP, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_SUSPENDED, FTDM_CHANNEL_STATE_RESTART, - FTDM_CHANNEL_STATE_COLLECT, FTDM_CHANNEL_STATE_DOWN, - FTDM_CHANNEL_STATE_HANGUP_COMPLETE, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_COLLECT, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_SUSPENDED, FTDM_CHANNEL_STATE_RESTART, - FTDM_CHANNEL_STATE_CANCEL, FTDM_CHANNEL_STATE_RING, - FTDM_CHANNEL_STATE_IDLE, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_RING, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_SUSPENDED, FTDM_CHANNEL_STATE_RESTART, - FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, - FTDM_CHANNEL_STATE_RINGING, FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_RINGING, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, - FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, - FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END}, - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_SUSPENDED, FTDM_CHANNEL_STATE_RESTART, - FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, - FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_SUSPENDED, FTDM_CHANNEL_STATE_RESTART, - FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, - FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_SUSPENDED, FTDM_CHANNEL_STATE_RESTART, - FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_CANCEL, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_SUSPENDED, FTDM_CHANNEL_STATE_RESTART, - FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_SUSPENDED, FTDM_CHANNEL_STATE_RESTART, - FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_SUSPENDED, FTDM_CHANNEL_STATE_RESTART, - FTDM_CHANNEL_STATE_HANGUP_COMPLETE, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_INBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_HANGUP_COMPLETE, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_SUSPENDED, FTDM_CHANNEL_STATE_RESTART, - FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END} - }, - /**************************************************************************/ - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_SUSPENDED, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_RESTART, FTDM_CHANNEL_STATE_DOWN, - FTDM_CHANNEL_STATE_IN_LOOP, FTDM_CHANNEL_STATE_DIALING, - FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, - FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_CANCEL, - FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, - FTDM_CHANNEL_STATE_HANGUP_COMPLETE, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_RESTART, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_SUSPENDED, FTDM_CHANNEL_STATE_TERMINATING, - FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_HANGUP_COMPLETE, - FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_IDLE, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_IDLE, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_RESTART, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_SUSPENDED, FTDM_CHANNEL_STATE_RESTART, - FTDM_CHANNEL_STATE_DIALING, FTDM_CHANNEL_STATE_IN_LOOP, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_IN_LOOP, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_SUSPENDED, FTDM_CHANNEL_STATE_RESTART, - FTDM_CHANNEL_STATE_DIALING, FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_DIALING, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_SUSPENDED, FTDM_CHANNEL_STATE_RESTART, - FTDM_CHANNEL_STATE_CANCEL, FTDM_CHANNEL_STATE_TERMINATING, - FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_PROGRESS, - FTDM_CHANNEL_STATE_PROGRESS_MEDIA ,FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_SUSPENDED, FTDM_CHANNEL_STATE_RESTART, - FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, - FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_SUSPENDED, FTDM_CHANNEL_STATE_RESTART, - FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, - FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_SUSPENDED, FTDM_CHANNEL_STATE_RESTART, - FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_CANCEL, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_SUSPENDED, FTDM_CHANNEL_STATE_RESTART, - FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_SUSPENDED, FTDM_CHANNEL_STATE_RESTART, - FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_SUSPENDED, FTDM_CHANNEL_STATE_RESTART, - FTDM_CHANNEL_STATE_HANGUP_COMPLETE, FTDM_CHANNEL_STATE_END} - }, - { - ZSD_OUTBOUND, - ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_HANGUP_COMPLETE, FTDM_CHANNEL_STATE_END}, - {FTDM_CHANNEL_STATE_SUSPENDED, FTDM_CHANNEL_STATE_RESTART, - FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_END} - }, - } -}; - -static void handle_hw_alarm(ftdm_event_t *e) -{ - sngss7_chan_data_t *ss7_info = NULL; - ftdm_channel_t *ftdmchan = NULL; - int x = 0; - - ftdm_assert(e != NULL, "Null event!\n"); - - SS7_DEBUG("handle_hw_alarm event [%d/%d]\n",e->channel->physical_span_id,e->channel->physical_chan_id); - - for (x = (g_ftdm_sngss7_data.cfg.procId * MAX_CIC_MAP_LENGTH) + 1; g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0; x++) { - if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == SNG_CKT_VOICE) { - ss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj; - - /* NC. Its possible for alarms to come in the middle of configuration - especially on large systems */ - if (!ss7_info || !ss7_info->ftdmchan) { - SS7_DEBUG("handle_hw_alarm: span=%i chan=%i ckt=%i x=%i - ss7_info=%p ftdmchan=%p\n", - ftdmchan->physical_span_id,ftdmchan->physical_chan_id, - g_ftdm_sngss7_data.cfg.isupCkt[x].id,x, - ss7_info,ss7_info?ss7_info->ftdmchan:NULL); - continue; - } - - ftdmchan = ss7_info->ftdmchan; - - if (e->channel->physical_span_id == ftdmchan->physical_span_id && - e->channel->physical_chan_id == ftdmchan->physical_chan_id) { - SS7_DEBUG_CHAN(ftdmchan,"handle_hw_alarm: span=%i chan=%i ckt=%i x=%i\n", - ftdmchan->physical_span_id,ftdmchan->physical_chan_id,g_ftdm_sngss7_data.cfg.isupCkt[x].id,x); - if (e->enum_id == FTDM_OOB_ALARM_TRAP) { - SS7_DEBUG_CHAN(ftdmchan,"handle_hw_alarm: Set FLAG_GRP_HW_BLOCK_TX %s\n", " "); - sngss7_set_ckt_blk_flag(ss7_info, FLAG_GRP_HW_BLOCK_TX); - if (ftdmchan->state != FTDM_CHANNEL_STATE_SUSPENDED) { - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); - } - } else if (e->enum_id == FTDM_OOB_ALARM_CLEAR) { - SS7_DEBUG_CHAN(ftdmchan,"handle_hw_alarm: Clear %s \n", " "); - sngss7_clear_ckt_blk_flag(ss7_info, FLAG_GRP_HW_BLOCK_TX); - sngss7_clear_ckt_blk_flag(ss7_info, FLAG_GRP_HW_UNBLK_TX); - if (sngss7_test_ckt_blk_flag(ss7_info, FLAG_GRP_HW_BLOCK_TX_DN)) { - sngss7_set_ckt_blk_flag(ss7_info, FLAG_GRP_HW_UNBLK_TX); - SS7_DEBUG_CHAN(ftdmchan,"handle_hw_alarm: Setting FLAG_GRP_HW_UNBLK_TX %s\n"," "); - if (ftdmchan->state != FTDM_CHANNEL_STATE_SUSPENDED) { - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); - } - } - } - } - } - } -} - - -static void check_span_oob_events(ftdm_span_t *ftdmspan) -{ - ftdm_event_t *event = NULL; - /* Poll for events, e.g HW DTMF */ - switch (ftdm_span_poll_event(ftdmspan, 0, NULL)) { - /**********************************************************************/ - case FTDM_SUCCESS: - while (ftdm_span_next_event(ftdmspan, &event) == FTDM_SUCCESS) { - if (event->e_type == FTDM_EVENT_OOB) { - handle_hw_alarm(event); - } - } - break; - /**********************************************************************/ - case FTDM_TIMEOUT: - /* No events pending */ - break; - /**********************************************************************/ - default: - SS7_ERROR("%s:Failed to poll span event\n", ftdmspan->name); - /**********************************************************************/ - } -} - -/* MONITIOR THREADS ***********************************************************/ -static void *ftdm_sangoma_ss7_run(ftdm_thread_t * me, void *obj) -{ - ftdm_interrupt_t *ftdm_sangoma_ss7_int[2]; - ftdm_span_t *ftdmspan = (ftdm_span_t *) obj; - ftdm_channel_t *ftdmchan = NULL; - sngss7_event_data_t *sngss7_event = NULL; - sngss7_span_data_t *sngss7_span = (sngss7_span_data_t *)ftdmspan->signal_data; - - int b_alarm_test = 1; - sngss7_chan_data_t *ss7_info=NULL; - - ftdm_log (FTDM_LOG_INFO, "ftmod_sangoma_ss7 monitor thread for span=%u started.\n", ftdmspan->span_id); - - /* set IN_THREAD flag so that we know this thread is running */ - ftdm_set_flag (ftdmspan, FTDM_SPAN_IN_THREAD); - - - - /* get an interrupt queue for this span for channel state changes */ - if (ftdm_queue_get_interrupt (ftdmspan->pendingchans, &ftdm_sangoma_ss7_int[0]) != FTDM_SUCCESS) { - SS7_CRITICAL ("Failed to get a ftdm_interrupt for span = %d for channel state changes!\n", ftdmspan->span_id); - goto ftdm_sangoma_ss7_run_exit; - } - - /* get an interrupt queue for this span for Trillium events */ - if (ftdm_queue_get_interrupt (sngss7_span->event_queue, &ftdm_sangoma_ss7_int[1]) != FTDM_SUCCESS) { - SS7_CRITICAL ("Failed to get a ftdm_interrupt for span = %d for Trillium event queue!\n", ftdmspan->span_id); - goto ftdm_sangoma_ss7_run_exit; - } - - if(SNG_SS7_OPR_MODE_M2UA_SG == g_ftdm_operating_mode){ - ftdm_log (FTDM_LOG_INFO, "FreeTDM running as M2UA_SG mode, freetdm dont have to do anything \n"); - - while (ftdm_running () && !(ftdm_test_flag (ftdmspan, FTDM_SPAN_STOP_THREAD))) { - - switch ((ftdm_interrupt_multiple_wait(ftdm_sangoma_ss7_int, ftdm_array_len(ftdm_sangoma_ss7_int), 100))) { - - case FTDM_SUCCESS: /* process all pending state changes */ - - SS7_DEVEL_DEBUG ("ftdm_interrupt_wait FTDM_SUCCESS on span = %d\n",ftdmspan->span_id); - - /**********************************************************************/ - case FTDM_TIMEOUT: - SS7_DEVEL_DEBUG ("ftdm_interrupt_wait timed-out on span = %d\n",ftdmspan->span_id); - - break; - /**********************************************************************/ - case FTDM_FAIL: - SS7_ERROR ("ftdm_interrupt_wait returned error!\non span = %d\n", ftdmspan->span_id); - - break; - /**********************************************************************/ - default: - SS7_ERROR("ftdm_interrupt_wait returned with unknown code on span = %d\n",ftdmspan->span_id); - - break; - /**********************************************************************/ - } - check_span_oob_events(ftdmspan); - - /* signal the core that sig events are queued for processing */ - ftdm_span_trigger_signals(ftdmspan); - } - goto ftdm_sangoma_ss7_stop; - } - - while (ftdm_running () && !(ftdm_test_flag (ftdmspan, FTDM_SPAN_STOP_THREAD))) { - int x = 0; - if (b_alarm_test) { - b_alarm_test = 0; - for (x = (g_ftdm_sngss7_data.cfg.procId * MAX_CIC_MAP_LENGTH) + 1; - g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0; x++) { - if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == SNG_CKT_VOICE) { - ss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj; - ftdmchan = ss7_info->ftdmchan; - if (!ftdmchan) { - continue; - } - - if (ftdmchan->alarm_flags != 0) { /* we'll send out block */ - sngss7_set_ckt_blk_flag(ss7_info, FLAG_GRP_HW_BLOCK_TX ); - } else { /* we'll send out reset */ - if (sngss7_test_ckt_blk_flag(ss7_info, FLAG_GRP_HW_BLOCK_TX )) { - sngss7_clear_ckt_blk_flag( ss7_info, FLAG_GRP_HW_BLOCK_TX ); - sngss7_clear_ckt_blk_flag( ss7_info, FLAG_GRP_HW_BLOCK_TX_DN ); - sngss7_set_ckt_blk_flag (ss7_info, FLAG_GRP_HW_UNBLK_TX); - SS7_DEBUG("b_alarm_test FLAG_GRP_HW_UNBLK_TX\n"); - } - } - } - usleep(50); - } - ftdmchan = NULL; - } - - /* check the channel state queue for an event*/ - switch ((ftdm_interrupt_multiple_wait(ftdm_sangoma_ss7_int, ftdm_array_len(ftdm_sangoma_ss7_int), 100))) { - /**********************************************************************/ - case FTDM_SUCCESS: /* process all pending state changes */ - - /* clean out all pending channel state changes */ - while ((ftdmchan = ftdm_queue_dequeue (ftdmspan->pendingchans))) { - sngss7_chan_data_t *chan_info = ftdmchan->call_data; - - /*first lock the channel */ - ftdm_mutex_lock(ftdmchan->mutex); - - /* process state changes for this channel until they are all done */ - ftdm_channel_advance_states(ftdmchan); - - if (chan_info->peer_data) { - /* clean out all pending stack events in the peer channel */ - while ((sngss7_event = ftdm_queue_dequeue(chan_info->event_queue))) { - ftdm_sangoma_ss7_process_peer_stack_event(ftdmchan, sngss7_event); - ftdm_safe_free(sngss7_event); - } - } - - /* unlock the channel */ - ftdm_mutex_unlock (ftdmchan->mutex); - } - - /* clean out all pending stack events */ - while ((sngss7_event = ftdm_queue_dequeue(sngss7_span->event_queue))) { - ftdm_sangoma_ss7_process_stack_event(sngss7_event); - ftdm_safe_free(sngss7_event); - } - - /* signal the core that sig events are queued for processing */ - ftdm_span_trigger_signals(ftdmspan); - - break; - /**********************************************************************/ - case FTDM_TIMEOUT: - SS7_DEVEL_DEBUG ("ftdm_interrupt_wait timed-out on span = %d\n",ftdmspan->span_id); - - break; - /**********************************************************************/ - case FTDM_FAIL: - SS7_ERROR ("ftdm_interrupt_wait returned error!\non span = %d\n", ftdmspan->span_id); - - break; - /**********************************************************************/ - default: - SS7_ERROR("ftdm_interrupt_wait returned with unknown code on span = %d\n",ftdmspan->span_id); - - break; - /**********************************************************************/ - } - - /* check if there is a GRA to proccess on the span */ - if (ftdm_test_flag(sngss7_span, SNGSS7_RX_GRA_PENDING)) { - check_if_rx_gra_started(ftdmspan); - } - - /* check if there is a GRS being processed on the span */ - if (ftdm_test_flag(sngss7_span, SNGSS7_RX_GRS_PENDING)) { - /* check if the rx_grs has started */ - check_if_rx_grs_started(ftdmspan); - - /* check if the rx_grs has cleared */ - check_if_rx_grs_processed(ftdmspan); - } - - /* check if there is a UCIC to be processed on the span */ - if (ftdm_test_flag(sngss7_span, SNGSS7_UCIC_PENDING)) { - /* process the span wide UCIC */ - process_span_ucic(ftdmspan); - } - - /* check each channel on the span to see if there is an un-procressed SUS/RES flag */ - check_for_res_sus_flag(ftdmspan); - - /* check each channel on the span to see if it needs to be reconfigured */ - check_for_reconfig_flag(ftdmspan); - - check_span_oob_events(ftdmspan); - } -ftdm_sangoma_ss7_stop: - - /* clear the IN_THREAD flag so that we know the thread is done */ - ftdm_clear_flag (ftdmspan, FTDM_SPAN_IN_THREAD); - - - ftdm_log (FTDM_LOG_INFO,"ftmod_sangoma_ss7 monitor thread for span=%u stopping.\n",ftdmspan->span_id); - - return NULL; - -ftdm_sangoma_ss7_run_exit: - - /* clear the IN_THREAD flag so that we know the thread is done */ - ftdm_clear_flag (ftdmspan, FTDM_SPAN_IN_THREAD); - - ftdm_log (FTDM_LOG_INFO,"ftmod_sangoma_ss7 monitor thread for span=%u stopping due to error.\n",ftdmspan->span_id); - - ftdm_sangoma_ss7_stop (ftdmspan); - - return NULL; -} - -/******************************************************************************/ -static void ftdm_sangoma_ss7_process_stack_event (sngss7_event_data_t *sngss7_event) -{ - sngss7_chan_data_t *sngss7_info = NULL; - ftdm_channel_t *ftdmchan = NULL; - sngss7_event_data_t *event_clone = NULL; - int clone_event = 0; - - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(sngss7_event->circuit, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", sngss7_event->circuit); - return; - } - - /* now that we have the right channel ... put a lock on it so no-one else can use it */ - ftdm_channel_lock(ftdmchan); - - /* while there's a state change present on this channel process it */ - ftdm_channel_advance_states(ftdmchan); - - if (sngss7_event->event_id == SNGSS7_CON_IND_EVENT) { - clone_event++; - } - - /* If the call has already started (we only bridge events related to calls) - * and the event is not a release confirmation, then clone the event. - * We do not clone release cfm events because that is the only event (final event) that is not - * bridged to the other leg, the first Spirou customer we had explicitly requested to send - * release confirm as soon as the release is received and therefore not wait for the other leg - * to send release confirm (hence, not need to clone and enqueue in the other leg) */ - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_CALL_STARTED) && sngss7_event->event_id != SNGSS7_REL_CFM_EVENT) { - clone_event++; - } - - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_NATIVE_SIGBRIDGE)) { - - if (sngss7_event->event_id == SNGSS7_SUSP_IND_EVENT) { - sngss7_set_ckt_flag(sngss7_info, FLAG_SUS_RECVD); - sngss7_clear_ckt_flag(sngss7_info, FLAG_T6_CANCELED); - } - - if (sngss7_test_ckt_flag(sngss7_info, FLAG_SUS_RECVD) && - !sngss7_test_ckt_flag(sngss7_info, FLAG_T6_CANCELED)) { - if (sng_cancel_isup_tmr(sngss7_info->suInstId, ISUP_T6i) == RFAILED ) { - SS7_ERROR_CHAN(ftdmchan,"[CIC:%d]could not stop timer T6 \n", sngss7_info->circuit->cic); - } else { - sngss7_set_ckt_flag(sngss7_info, FLAG_T6_CANCELED); - SS7_ERROR_CHAN(ftdmchan,"[CIC:%d] isup timer T6 has been cancelled. \n", sngss7_info->circuit->cic); - } - } - } - - /* clone the event and save it for later usage, we do not clone RLC messages */ - if (clone_event) { - event_clone = ftdm_calloc(1, sizeof(*sngss7_event)); - if (event_clone) { - memcpy(event_clone, sngss7_event, sizeof(*sngss7_event)); - /* if we have already a peer channel then enqueue the event in their queue */ - if (sngss7_info->peer_data) { - ftdm_span_t *peer_span = sngss7_info->peer_data->ftdmchan->span; - if (sngss7_info->peer_event_transfer_cnt) { - sngss7_event_data_t *peer_event = NULL; - int qi = 0; - /* looks like for the first time we found our peer, transfer any messages we enqueued */ - for (qi = 0; qi < sngss7_info->peer_event_transfer_cnt; qi++) { - peer_event = ftdm_queue_dequeue(sngss7_info->event_queue); - if (peer_event) { - ftdm_queue_enqueue(sngss7_info->peer_data->event_queue, peer_event); - } else { - /* This should never happen! */ - SS7_CRIT_CHAN(ftdmchan,"[CIC:%d]What!? someone stole my messages!\n", sngss7_info->circuit->cic); - } - } - SS7_DEBUG_CHAN(ftdmchan,"[CIC:%d]Transferred %d messages into my peer's queue\n", - sngss7_info->circuit->cic, sngss7_info->peer_event_transfer_cnt); - sngss7_info->peer_event_transfer_cnt = 0; - } - /* we already have a peer attached, wake him up */ - ftdm_queue_enqueue(sngss7_info->peer_data->event_queue, event_clone); - ftdm_queue_enqueue(peer_span->pendingchans, sngss7_info->peer_data->ftdmchan); - } else { - /* we don't have a peer yet, save the event on our own queue for later - * only the first event in this queue is directly consumed by our peer (IAM), subsequent events - * must be transferred by us to their queue as soon as we find our peer */ - ftdm_queue_enqueue(sngss7_info->event_queue, event_clone); - if (sngss7_event->event_id != SNGSS7_CON_IND_EVENT) { - /* This could be an SAM, save it for transfer once we know who our peer is (if we ever find that) */ - sngss7_info->peer_event_transfer_cnt++; - } - } - } - } - - /* we could test for sngss7_info->peer_data too, bit this flag is set earlier, the earlier we know the better */ - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_NATIVE_SIGBRIDGE)) { - /* most messages are simply relayed in sig bridge mode, except for hangup which requires state changing */ - switch (sngss7_event->event_id) { - case SNGSS7_REL_IND_EVENT: - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); - break; - case SNGSS7_REL_CFM_EVENT: - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - break; - default: - break; - } - goto done; - } - - /* figure out the type of event and send it to the right handler */ - switch (sngss7_event->event_id) { - /**************************************************************************/ - case (SNGSS7_CON_IND_EVENT): - handle_con_ind(sngss7_event->suInstId, sngss7_event->spInstId, sngss7_event->circuit, &sngss7_event->event.siConEvnt); - break; - /**************************************************************************/ - case (SNGSS7_CON_CFM_EVENT): - handle_con_cfm(sngss7_event->suInstId, sngss7_event->spInstId, sngss7_event->circuit, &sngss7_event->event.siConEvnt); - break; - /**************************************************************************/ - case (SNGSS7_CON_STA_EVENT): - handle_con_sta(sngss7_event->suInstId, sngss7_event->spInstId, sngss7_event->circuit, &sngss7_event->event.siCnStEvnt, sngss7_event->evntType); - break; - /**************************************************************************/ - case (SNGSS7_REL_IND_EVENT): - handle_rel_ind(sngss7_event->suInstId, sngss7_event->spInstId, sngss7_event->circuit, &sngss7_event->event.siRelEvnt); - break; - /**************************************************************************/ - case (SNGSS7_REL_CFM_EVENT): - handle_rel_cfm(sngss7_event->suInstId, sngss7_event->spInstId, sngss7_event->circuit, &sngss7_event->event.siRelEvnt); - break; - /**************************************************************************/ - case (SNGSS7_DAT_IND_EVENT): - handle_dat_ind(sngss7_event->suInstId, sngss7_event->spInstId, sngss7_event->circuit, &sngss7_event->event.siInfoEvnt); - break; - /**************************************************************************/ - case (SNGSS7_FAC_IND_EVENT): - handle_fac_ind(sngss7_event->suInstId, sngss7_event->spInstId, sngss7_event->circuit, sngss7_event->evntType, &sngss7_event->event.siFacEvnt); - break; - /**************************************************************************/ - case (SNGSS7_FAC_CFM_EVENT): - handle_fac_cfm(sngss7_event->suInstId, sngss7_event->spInstId, sngss7_event->circuit, sngss7_event->evntType, &sngss7_event->event.siFacEvnt); - break; - /**************************************************************************/ - case (SNGSS7_UMSG_IND_EVENT): - handle_umsg_ind(sngss7_event->suInstId, sngss7_event->spInstId, sngss7_event->circuit); - break; - /**************************************************************************/ - case (SNGSS7_STA_IND_EVENT): - handle_sta_ind(sngss7_event->suInstId, sngss7_event->spInstId, sngss7_event->circuit, sngss7_event->globalFlg, sngss7_event->evntType, &sngss7_event->event.siStaEvnt); - break; - /**************************************************************************/ - case (SNGSS7_SUSP_IND_EVENT): - handle_susp_ind(sngss7_event->suInstId, sngss7_event->spInstId, sngss7_event->circuit, &sngss7_event->event.siSuspEvnt); - break; - /**************************************************************************/ - case (SNGSS7_RESM_IND_EVENT): - handle_resm_ind(sngss7_event->suInstId, sngss7_event->spInstId, sngss7_event->circuit, &sngss7_event->event.siResmEvnt); - break; - /**************************************************************************/ - case (SNGSS7_SSP_STA_CFM_EVENT): - SS7_ERROR("dazed and confused ... hu?!\n"); - break; - /**************************************************************************/ - default: - SS7_ERROR("Unknown Event Id!\n"); - break; - /**************************************************************************/ - } - -done: - /* while there's a state change present on this channel process it */ - ftdm_channel_advance_states(ftdmchan); - - /* unlock the channel */ - ftdm_channel_unlock(ftdmchan); - -} - -FTDM_ENUM_NAMES(SNG_EVENT_TYPE_NAMES, SNG_EVENT_TYPE_STRINGS) -FTDM_STR2ENUM(ftdm_str2sngss7_event, ftdm_sngss7_event2str, sng_event_type_t, SNG_EVENT_TYPE_NAMES, SNGSS7_INVALID_EVENT) -static void ftdm_sangoma_ss7_process_peer_stack_event (ftdm_channel_t *ftdmchan, sngss7_event_data_t *sngss7_event) -{ - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - - if (ftdmchan->state < FTDM_CHANNEL_STATE_UP && ftdmchan->state != FTDM_CHANNEL_STATE_DOWN) { - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_UP); - ftdm_channel_advance_states(ftdmchan); - } - - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Receiving message %s from bridged peer (our state = %s)\n", - sngss7_info->circuit->cic, ftdm_sngss7_event2str(sngss7_event->event_id), ftdm_channel_state2str(ftdmchan->state)); - - switch (sngss7_event->event_id) { - - case (SNGSS7_CON_IND_EVENT): - SS7_ERROR_CHAN(ftdmchan,"[CIC:%d]Rx IAM while bridged??\n", sngss7_info->circuit->cic); - break; - - case (SNGSS7_CON_CFM_EVENT): - /* send the ANM request to LibSngSS7 */ - sng_cc_con_response(1, - sngss7_info->suInstId, - sngss7_info->spInstId, - sngss7_info->circuit->id, - &sngss7_event->event.siConEvnt, - 5); - - SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Tx peer ANM\n", sngss7_info->circuit->cic); - break; - - case (SNGSS7_CON_STA_EVENT): - switch (sngss7_event->evntType) { - /**************************************************************************/ - case (ADDRCMPLT): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx peer ACM\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (MODIFY): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx peer MODIFY\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (MODCMPLT): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx peer MODIFY-COMPLETE\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (MODREJ): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx peer MODIFY-REJECT\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (PROGRESS): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx peer CPG\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (FRWDTRSFR): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx peer FOT\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (INFORMATION): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx peer INF\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (INFORMATREQ): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx peer INR\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (SUBSADDR): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx peer SAM\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (EXIT): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx peer EXIT\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (NETRESMGT): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx peer NRM\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (IDENTREQ): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx peer IDR\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (IDENTRSP): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx peer IRS\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (MALCLLPRNT): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx peer MALICIOUS CALL\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (CHARGE): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx peer CRG\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (TRFFCHGE): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx peer CRG-TARIFF\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (CHARGEACK): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx peer CRG-ACK\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (CALLOFFMSG): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx peer CALL-OFFER\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (LOOPPRVNT): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx peer LOP\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (TECT_TIMEOUT): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx peer ECT-Timeout\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (RINGSEND): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx peer RINGING-SEND\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (CALLCLEAR): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx peer CALL-LINE Clear\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (PRERELEASE): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx peer PRI\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (APPTRANSPORT): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx peer APM\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (OPERATOR): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx peer OPERATOR\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (METPULSE): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx peer METERING-PULSE\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (CLGPTCLR): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx peer CALLING_PARTY_CLEAR\n", sngss7_info->circuit->cic); - break; - /**************************************************************************/ - case (SUBDIRNUM): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx peer SUB-DIR\n", sngss7_info->circuit->cic); - break; -#ifdef SANGOMA_SPIROU - case (CHARGE_ACK): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx peer TXA\n", sngss7_info->circuit->cic); - break; - case (CHARGE_UNIT): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx peer ITX\n", sngss7_info->circuit->cic); - break; -#endif - /**************************************************************************/ - default: - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx peer Unknown Msg %d\n", sngss7_info->circuit->cic, sngss7_event->evntType); - break; - /**************************************************************************/ - } - sng_cc_con_status (1, - sngss7_info->suInstId, - sngss7_info->spInstId, - sngss7_info->circuit->id, - &sngss7_event->event.siCnStEvnt, - sngss7_event->evntType); - - break; - /**************************************************************************/ - case (SNGSS7_REL_IND_EVENT): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx peer REL cause=%d\n", sngss7_info->circuit->cic, sngss7_event->event.siRelEvnt.causeDgn.causeVal.val); - - //handle_rel_ind(sngss7_event->suInstId, sngss7_event->spInstId, sngss7_event->circuit, &sngss7_event->event.siRelEvnt); - sng_cc_rel_request (1, - sngss7_info->suInstId, - sngss7_info->spInstId, - sngss7_info->circuit->id, - &sngss7_event->event.siRelEvnt); - break; - - /**************************************************************************/ - case (SNGSS7_REL_CFM_EVENT): - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx peer RLC\n", sngss7_info->circuit->cic); - sng_cc_rel_response (1, - sngss7_info->suInstId, - sngss7_info->spInstId, - sngss7_info->circuit->id, - &sngss7_event->event.siRelEvnt); - //handle_rel_cfm(sngss7_event->suInstId, sngss7_event->spInstId, sngss7_event->circuit, &sngss7_event->event.siRelEvnt); - break; - - /**************************************************************************/ - case (SNGSS7_DAT_IND_EVENT): - //handle_dat_ind(sngss7_event->suInstId, sngss7_event->spInstId, sngss7_event->circuit, &sngss7_event->event.siInfoEvnt); - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx peer %s\n", sngss7_info->circuit->cic, ftdm_sngss7_event2str(sngss7_event->event_id)); - sng_cc_dat_request(1, - sngss7_info->suInstId, - sngss7_info->spInstId, - sngss7_info->circuit->id, - &sngss7_event->event.siInfoEvnt); - break; - /**************************************************************************/ - case (SNGSS7_FAC_IND_EVENT): - //handle_fac_ind(sngss7_event->suInstId, sngss7_event->spInstId, sngss7_event->circuit, sngss7_event->evntType, - //&sngss7_event->event.siFacEvnt); - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx peer %s -> %d\n", sngss7_info->circuit->cic, - ftdm_sngss7_event2str(sngss7_event->event_id), sngss7_event->evntType); - sng_cc_fac_request(1, - sngss7_info->suInstId, - sngss7_info->spInstId, - sngss7_info->circuit->id, - sngss7_event->evntType, - &sngss7_event->event.siFacEvnt); - - break; - /**************************************************************************/ - case (SNGSS7_FAC_CFM_EVENT): - //handle_fac_cfm(sngss7_event->suInstId, sngss7_event->spInstId, sngss7_event->circuit, - //sngss7_event->evntType, &sngss7_event->event.siFacEvnt); - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx peer %s -> %d\n", sngss7_info->circuit->cic, - ftdm_sngss7_event2str(sngss7_event->event_id), sngss7_event->evntType); - sng_cc_fac_response(1, - sngss7_info->suInstId, - sngss7_info->spInstId, - sngss7_info->circuit->id, - sngss7_event->evntType, - &sngss7_event->event.siFacEvnt); - break; - /**************************************************************************/ - case (SNGSS7_UMSG_IND_EVENT): - //handle_umsg_ind(sngss7_event->suInstId, sngss7_event->spInstId, sngss7_event->circuit); - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx peer %s\n", sngss7_info->circuit->cic, ftdm_sngss7_event2str(sngss7_event->event_id)); - sng_cc_umsg_request (1, - sngss7_info->suInstId, - sngss7_info->spInstId, - sngss7_info->circuit->id); - break; - /**************************************************************************/ - case (SNGSS7_STA_IND_EVENT): - //handle_sta_ind(sngss7_event->suInstId, sngss7_event->spInstId, sngss7_event->circuit, sngss7_event->globalFlg, sngss7_event->evntType, &sngss7_event->event.siStaEvnt); - break; - /**************************************************************************/ - case (SNGSS7_SUSP_IND_EVENT): - //handle_susp_ind(sngss7_event->suInstId, sngss7_event->spInstId, sngss7_event->circuit, &sngss7_event->event.siSuspEvnt); - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx peer %s\n", sngss7_info->circuit->cic, ftdm_sngss7_event2str(sngss7_event->event_id)); - sng_cc_susp_request (1, - sngss7_info->suInstId, - sngss7_info->spInstId, - sngss7_info->circuit->id, - &sngss7_event->event.siSuspEvnt); - break; - /**************************************************************************/ - case (SNGSS7_RESM_IND_EVENT): - //handle_resm_ind(sngss7_event->suInstId, sngss7_event->spInstId, sngss7_event->circuit, &sngss7_event->event.siResmEvnt); - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx peer %s\n", sngss7_info->circuit->cic, ftdm_sngss7_event2str(sngss7_event->event_id)); - sng_cc_resm_request(1, - sngss7_info->suInstId, - sngss7_info->spInstId, - sngss7_info->circuit->id, - &sngss7_event->event.siResmEvnt); - break; - /**************************************************************************/ - case (SNGSS7_SSP_STA_CFM_EVENT): - SS7_CRITICAL("dazed and confused ... hu?!\n"); - break; - /**************************************************************************/ - default: - SS7_ERROR("Failed to relay unknown event id %d!\n", sngss7_event->event_id); - break; - /**************************************************************************/ - } - - if ((sngss7_event->event_id == SNGSS7_SUSP_IND_EVENT)) { - sngss7_set_ckt_flag(sngss7_info, FLAG_SUS_RECVD); - } - - if (sngss7_test_ckt_flag(sngss7_info, FLAG_SUS_RECVD) && - !sngss7_test_ckt_flag(sngss7_info, FLAG_T6_CANCELED)) { - if (sng_cancel_isup_tmr(sngss7_info->suInstId, ISUP_T6i) == RFAILED ) { - SS7_ERROR_CHAN(ftdmchan,"[CIC:%d]could not stop timer T6 \n", sngss7_info->circuit->cic); - } else { - sngss7_set_ckt_flag(sngss7_info, FLAG_T6_CANCELED); - SS7_ERROR_CHAN(ftdmchan,"[CIC:%d] isup timer T6 has been cancelled. \n", sngss7_info->circuit->cic); - } - } -} - -static ftdm_status_t ftdm_sangoma_ss7_native_bridge_state_change(ftdm_channel_t *ftdmchan); -static ftdm_status_t ftdm_sangoma_ss7_native_bridge_state_change(ftdm_channel_t *ftdmchan) -{ - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - - ftdm_channel_complete_state(ftdmchan); - - switch (ftdmchan->state) { - - case FTDM_CHANNEL_STATE_DOWN: - { - ftdm_channel_t *close_chan = ftdmchan; - sngss7_clear_ckt_flag(sngss7_info, FLAG_SUS_RECVD); - sngss7_clear_ckt_flag(sngss7_info, FLAG_T6_CANCELED); - sngss7_clear_ckt_flag (sngss7_info, FLAG_SENT_ACM); - sngss7_clear_ckt_flag (sngss7_info, FLAG_SENT_CPG); - - sngss7_flush_queue(sngss7_info->event_queue); - sngss7_info->peer_data = NULL; - ftdm_channel_close (&close_chan); - } - break; - - case FTDM_CHANNEL_STATE_UP: - { - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { - sngss7_send_signal(sngss7_info, FTDM_SIGEVENT_UP); - } - } - break; - - case FTDM_CHANNEL_STATE_TERMINATING: - { - /* Release confirm is sent immediately, since Spirou customer asked us not to wait for the second call leg - * to come back with a release confirm ... */ - /* when receiving REL we move to TERMINATING and notify the user that the bridge is ending */ - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_USER_HANGUP)) { - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_HANGUP); - } else { - /* Notify the user and wait for their ack before sending RLC */ - sngss7_send_signal(sngss7_info, FTDM_SIGEVENT_STOP); - } - } - break; - - case FTDM_CHANNEL_STATE_HANGUP: - { - ft_to_sngss7_rlc(ftdmchan); - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - } - break; - - default: - break; - } - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t *ftdmchan) -{ - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - sng_isup_inf_t *isup_intf = NULL; - int state_flag = 1; - int i = 0; - - SS7_DEBUG_CHAN(ftdmchan, "ftmod_sangoma_ss7 processing state %s: ckt=0x%X, blk=0x%X\n", - ftdm_channel_state2str (ftdmchan->state), - sngss7_info->ckt_flags, - sngss7_info->blk_flags); - - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_NATIVE_SIGBRIDGE)) { - /* DIALING is the only state we process normally when doing an outgoing call that is natively bridged, - * all other states are run by a different state machine (and the freetdm core does not do any checking) */ - if (ftdmchan->state != FTDM_CHANNEL_STATE_DIALING) { - return ftdm_sangoma_ss7_native_bridge_state_change(ftdmchan); - } - } - - /*check what state we are supposed to be in */ - switch (ftdmchan->state) { - /**************************************************************************/ - case FTDM_CHANNEL_STATE_COLLECT: /* IAM received but wating on digits */ - - if (ftdmchan->last_state == FTDM_CHANNEL_STATE_SUSPENDED) { - SS7_DEBUG("re-entering state from processing block/unblock request ... do nothing\n"); - break; - } - - while (ftdmchan->caller_data.dnis.digits[i] != '\0'){ - i++; - } - - /* kill t10 if active */ - if (sngss7_info->t10.hb_timer_id) { - ftdm_sched_cancel_timer (sngss7_info->t10.sched, sngss7_info->t10.hb_timer_id); - } - - /* check if the end of pulsing (ST) character has arrived or the right number of digits */ - if (ftdmchan->caller_data.dnis.digits[i-1] == 'F' - || sngss7_test_ckt_flag(sngss7_info, FLAG_FULL_NUMBER) ) - { - SS7_DEBUG_CHAN(ftdmchan, "Received the end of pulsing character %s\n", ""); - - if (!sngss7_test_ckt_flag(sngss7_info, FLAG_FULL_NUMBER)) { - /* remove the ST */ - ftdmchan->caller_data.dnis.digits[i-1] = '\0'; - sngss7_set_ckt_flag(sngss7_info, FLAG_FULL_NUMBER); - } - - if (sngss7_test_ckt_flag(sngss7_info, FLAG_INR_TX)) { - if (!sngss7_test_ckt_flag(sngss7_info, FLAG_INR_SENT) ) { - ft_to_sngss7_inr(ftdmchan); - sngss7_set_ckt_flag(sngss7_info, FLAG_INR_SENT); - - SS7_DEBUG_CHAN (ftdmchan, "Scheduling T.39 timer %s \n", " "); - - /* start ISUP t39 */ - if (ftdm_sched_timer (sngss7_info->t39.sched, - "t39", - sngss7_info->t39.beat, - sngss7_info->t39.callback, - &sngss7_info->t39, - &sngss7_info->t39.hb_timer_id)) - { - - SS7_ERROR ("Unable to schedule timer T39, hanging up call!\n"); - - ftdmchan->caller_data.hangup_cause = FTDM_CAUSE_NORMAL_TEMPORARY_FAILURE; - sngss7_set_ckt_flag (sngss7_info, FLAG_LOCAL_REL); - - /* end the call */ - state_flag = 0; - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_CANCEL); - } - }else { - state_flag = 0; - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RING); - } - } else { - state_flag = 0; - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RING); - } - } else if (i >= sngss7_info->circuit->min_digits) { - SS7_DEBUG_CHAN(ftdmchan, "Received %d digits (min digits = %d)\n", i, sngss7_info->circuit->min_digits); - - if (sngss7_test_ckt_flag(sngss7_info, FLAG_INR_TX)) { - if (!sngss7_test_ckt_flag(sngss7_info, FLAG_INR_SENT) ) { - ft_to_sngss7_inr(ftdmchan); - sngss7_set_ckt_flag(sngss7_info, FLAG_INR_SENT); - - SS7_DEBUG_CHAN (ftdmchan, "Scheduling T.39 timer %s\n", " " ); - - /* start ISUP t39 */ - if (ftdm_sched_timer (sngss7_info->t39.sched, - "t39", - sngss7_info->t39.beat, - sngss7_info->t39.callback, - &sngss7_info->t39, - &sngss7_info->t39.hb_timer_id)) - { - - SS7_ERROR ("Unable to schedule timer T39, hanging up call!\n"); - - ftdmchan->caller_data.hangup_cause = FTDM_CAUSE_NORMAL_TEMPORARY_FAILURE; - sngss7_set_ckt_flag (sngss7_info, FLAG_LOCAL_REL); - - /* end the call */ - state_flag = 0; - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_CANCEL); - } - - state_flag = 0; - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_IDLE); - }else { - if (sngss7_test_ckt_flag(sngss7_info, FLAG_INF_RX_DN) ) { - state_flag = 0; - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RING); - } - } - } else { - state_flag = 0; - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RING); - } - } else { - /* if we are coming from idle state then we have already been here once before */ - if (ftdmchan->last_state != FTDM_CHANNEL_STATE_IDLE) { - SS7_INFO_CHAN(ftdmchan, "Received %d out of %d so far: %s...starting T35\n", - i, - sngss7_info->circuit->min_digits, - ftdmchan->caller_data.dnis.digits); - - /* start ISUP t35 */ - if (ftdm_sched_timer (sngss7_info->t35.sched, - "t35", - sngss7_info->t35.beat, - sngss7_info->t35.callback, - &sngss7_info->t35, - &sngss7_info->t35.hb_timer_id)) { - - SS7_ERROR ("Unable to schedule timer, hanging up call!\n"); - - ftdmchan->caller_data.hangup_cause = FTDM_CAUSE_NORMAL_TEMPORARY_FAILURE; - - /* set the flag to indicate this hangup is started from the local side */ - sngss7_set_ckt_flag (sngss7_info, FLAG_LOCAL_REL); - - /* end the call */ - state_flag = 0; - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_CANCEL); - } - } - - /* start ISUP t10 */ - if (ftdm_sched_timer (sngss7_info->t10.sched, - "t10", - sngss7_info->t10.beat, - sngss7_info->t10.callback, - &sngss7_info->t10, - &sngss7_info->t10.hb_timer_id)) { - - SS7_ERROR ("Unable to schedule timer, hanging up call!\n"); - - ftdmchan->caller_data.hangup_cause = FTDM_CAUSE_NORMAL_TEMPORARY_FAILURE; - - /* set the flag to indicate this hangup is started from the local side */ - sngss7_set_ckt_flag (sngss7_info, FLAG_LOCAL_REL); - - /* end the call */ - state_flag = 0; - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_CANCEL); - } - } - - break; - - /**************************************************************************/ - case FTDM_CHANNEL_STATE_RING: /*incoming call request */ - - sngss7_clear_ckt_flag(sngss7_info, FLAG_INR_TX); - sngss7_clear_ckt_flag(sngss7_info, FLAG_INR_SENT); - sngss7_clear_ckt_flag(sngss7_info, FLAG_INR_RX); - sngss7_clear_ckt_flag(sngss7_info, FLAG_INR_RX_DN); - sngss7_clear_ckt_flag(sngss7_info, FLAG_INF_TX); - sngss7_clear_ckt_flag(sngss7_info, FLAG_INF_SENT); - sngss7_clear_ckt_flag(sngss7_info, FLAG_INF_RX); - sngss7_clear_ckt_flag(sngss7_info, FLAG_INF_RX_DN); - - if (ftdmchan->last_state == FTDM_CHANNEL_STATE_SUSPENDED) { - SS7_DEBUG("re-entering state from processing block/unblock request ... do nothing\n"); - break; - } - - /* kill t35 if active */ - if (sngss7_info->t35.hb_timer_id) { - ftdm_sched_cancel_timer (sngss7_info->t35.sched, sngss7_info->t35.hb_timer_id); - } - - /* cancel t39 timer */ - if (sngss7_info->t39.hb_timer_id) { - ftdm_sched_cancel_timer (sngss7_info->t39.sched, sngss7_info->t39.hb_timer_id); - } - - SS7_DEBUG_CHAN(ftdmchan, "Sending incoming call from %s to %s to FTDM core\n", - ftdmchan->caller_data.ani.digits, - ftdmchan->caller_data.dnis.digits); - - - /* we have enough information to inform FTDM of the call */ - sngss7_send_signal(sngss7_info, FTDM_SIGEVENT_START); - - break; - /**************************************************************************/ - case FTDM_CHANNEL_STATE_DIALING: /*outgoing call request */ - - if (ftdmchan->last_state == FTDM_CHANNEL_STATE_SUSPENDED) { - SS7_DEBUG("re-entering state from processing block/unblock request ... do nothing\n"); - break; - } - - SS7_DEBUG_CHAN(ftdmchan, "Sending outgoing call from \"%s\" to \"%s\" to LibSngSS7\n", - ftdmchan->caller_data.ani.digits, - ftdmchan->caller_data.dnis.digits); - - /*call sangoma_ss7_dial to make outgoing call */ - ft_to_sngss7_iam(ftdmchan); - - break; - /**************************************************************************/ - /* We handle RING indication the same way we would indicate PROGRESS */ - case FTDM_CHANNEL_STATE_RINGING: - case FTDM_CHANNEL_STATE_PROGRESS: - - if (ftdmchan->last_state == FTDM_CHANNEL_STATE_SUSPENDED) { - SS7_DEBUG("re-entering state from processing block/unblock request ... do nothing\n"); - break; - } - - /*check if the channel is inbound or outbound */ - if (ftdm_test_flag (ftdmchan, FTDM_CHANNEL_OUTBOUND)) { - /*OUTBOUND...so we were told by the line of this so noifiy the user */ - sngss7_send_signal(sngss7_info, FTDM_SIGEVENT_PROGRESS); - - /* move to progress media */ - state_flag = 0; - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA); - } else { - /* inbound call so we need to send out ACM */ - if (!sngss7_test_ckt_flag(sngss7_info, FLAG_SENT_ACM)) { - sngss7_set_ckt_flag(sngss7_info, FLAG_SENT_ACM); - ft_to_sngss7_acm(ftdmchan); - } - if (g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].cpg_on_progress == FTDM_TRUE) { - if (!sngss7_test_ckt_flag(sngss7_info, FLAG_SENT_CPG)) { - sngss7_set_ckt_flag(sngss7_info, FLAG_SENT_CPG); - ft_to_sngss7_cpg(ftdmchan); - } - } - } - - break; - /**************************************************************************/ - case FTDM_CHANNEL_STATE_PROGRESS_MEDIA: - - if (ftdmchan->last_state == FTDM_CHANNEL_STATE_SUSPENDED) { - SS7_DEBUG("re-entering state from processing block/unblock request ... do nothing\n"); - break; - } - - if (ftdm_test_flag (ftdmchan, FTDM_CHANNEL_OUTBOUND)) { - /* inform the user there is media avai */ - sngss7_send_signal(sngss7_info, FTDM_SIGEVENT_PROGRESS_MEDIA); - } else { - if (!sngss7_test_ckt_flag(sngss7_info, FLAG_SENT_ACM)) { - sngss7_set_ckt_flag(sngss7_info, FLAG_SENT_ACM); - ft_to_sngss7_acm(ftdmchan); - } - if (g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].cpg_on_progress_media == FTDM_TRUE) { - if (!sngss7_test_ckt_flag(sngss7_info, FLAG_SENT_CPG)) { - sngss7_set_ckt_flag(sngss7_info, FLAG_SENT_CPG); - ft_to_sngss7_cpg(ftdmchan); - } - } - } - - break; - /**************************************************************************/ - case FTDM_CHANNEL_STATE_UP: /*call is accpeted...both incoming and outgoing */ - - if (ftdmchan->last_state == FTDM_CHANNEL_STATE_SUSPENDED) { - SS7_DEBUG("re-entering state from processing block/unblock request ... do nothing\n"); - break; - } - - /*check if the channel is inbound or outbound */ - if (ftdm_test_flag (ftdmchan, FTDM_CHANNEL_OUTBOUND)) { - /*OUTBOUND...so we were told by the line that the other side answered */ - sngss7_send_signal(sngss7_info, FTDM_SIGEVENT_UP); - } else { - /*INBOUND...so FS told us it was going to answer...tell the stack */ - ft_to_sngss7_anm(ftdmchan); - } - - break; - /**************************************************************************/ - case FTDM_CHANNEL_STATE_CANCEL: - - if (ftdmchan->last_state == FTDM_CHANNEL_STATE_SUSPENDED) { - SS7_DEBUG("re-entering state from processing block/unblock request ... do nothing\n"); - break; - } - - SS7_ERROR_CHAN(ftdmchan,"Hanging up call before informing user%s\n", " "); - - /*now go to the HANGUP complete state */ - state_flag = 0; - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_HANGUP); - - break; - /**************************************************************************/ - case FTDM_CHANNEL_STATE_TERMINATING: /*call is hung up remotely */ - - if (ftdmchan->last_state == FTDM_CHANNEL_STATE_SUSPENDED) { - SS7_DEBUG("re-entering state from processing block/unblock request ... do nothing\n"); - break; - } - - /* set the flag to indicate this hangup is started from the remote side */ - sngss7_set_ckt_flag (sngss7_info, FLAG_REMOTE_REL); - - /*this state is set when the line is hanging up */ - sngss7_send_signal(sngss7_info, FTDM_SIGEVENT_STOP); - - /* If the RESET flag is set, do not say in TERMINATING state. - Go back to RESTART state and wait for RESET Confirmation */ - if (sngss7_tx_reset_status_pending(sngss7_info)) { - SS7_DEBUG_CHAN(ftdmchan,"Reset pending in Terminating state!%s\n", ""); - state_flag = 0; - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RESTART); - } - - break; - /**************************************************************************/ - case FTDM_CHANNEL_STATE_HANGUP: /*call is hung up locally */ - - if (ftdmchan->last_state == FTDM_CHANNEL_STATE_SUSPENDED) { - SS7_DEBUG("re-entering state from processing block/unblock request ... do nothing\n"); - break; - } - - /* check for remote hangup flag */ - if (sngss7_test_ckt_flag (sngss7_info, FLAG_REMOTE_REL)) { - /* remote release ...do nothing here */ - SS7_DEBUG_CHAN(ftdmchan,"Hanging up remotely requested call!%s\n", ""); - } else if (sngss7_test_ckt_flag (sngss7_info, FLAG_GLARE)) { - /* release due to glare */ - SS7_DEBUG_CHAN(ftdmchan,"Hanging up requested call do to glare%s\n", ""); - } else { - /* set the flag to indicate this hangup is started from the local side */ - sngss7_set_ckt_flag (sngss7_info, FLAG_LOCAL_REL); - - /*this state is set when FS is hanging up...so tell the stack */ - ft_to_sngss7_rel (ftdmchan); - - SS7_DEBUG_CHAN(ftdmchan,"Hanging up locally requested call!%s\n", ""); - } - - /*now go to the HANGUP complete state */ - state_flag = 0; - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_HANGUP_COMPLETE); - - break; - - /**************************************************************************/ - case FTDM_CHANNEL_STATE_HANGUP_COMPLETE: - - if (ftdmchan->last_state == FTDM_CHANNEL_STATE_SUSPENDED) { - SS7_DEBUG("re-entering state from processing block/unblock request ... do nothing\n"); - break; - } - - if (sngss7_test_ckt_flag (sngss7_info, FLAG_REMOTE_REL)) { - - sngss7_clear_ckt_flag (sngss7_info, FLAG_LOCAL_REL); - - /* check if this hangup is from a tx RSC */ - if (sngss7_test_ckt_flag (sngss7_info, FLAG_RESET_TX)) { - if (!sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_SENT)) { - ft_to_sngss7_rsc (ftdmchan); - sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_SENT); - - /* Wait for Reset in HANGUP Complete nothing to do until we - get reset response back */ - } else if (sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_TX_RSP)) { - state_flag = 0; - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - } else { - /* Stay in hangup complete until RSC is received */ - /* Channel is in use if we go to RESTART we will - restart will just come back to HANGUP_COMPLETE */ - } - } else { - /* if the hangup is from a rx RSC, rx GRS, or glare don't sent RLC */ - if (!(sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_RX)) && - !(sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX)) && - !(sngss7_test_ckt_flag(sngss7_info, FLAG_GLARE))) { - - /* send out the release complete */ - ft_to_sngss7_rlc (ftdmchan); - } - - /*now go to the DOWN state */ - state_flag = 0; - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - } - - SS7_DEBUG_CHAN(ftdmchan,"Completing remotely requested hangup!%s\n", ""); - } else if (sngss7_test_ckt_flag (sngss7_info, FLAG_LOCAL_REL)) { - - /* if this hang up is do to a rx RESET we need to sit here till the RSP arrives */ - if (sngss7_test_ckt_flag (sngss7_info, FLAG_RESET_TX_RSP)) { - /* go to the down state as we have already received RSC-RLC */ - state_flag = 0; - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - } - - /* if it's a local release the user sends us to down */ - SS7_DEBUG_CHAN(ftdmchan,"Completing locally requested hangup!%s\n", ""); - } else if (sngss7_test_ckt_flag (sngss7_info, FLAG_GLARE)) { - SS7_DEBUG_CHAN(ftdmchan,"Completing requested hangup due to glare!%s\n", ""); - state_flag = 0; - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - } else { - SS7_DEBUG_CHAN(ftdmchan,"Completing requested hangup for unknown reason!%s\n", ""); - if (sngss7_channel_status_clear(sngss7_info)) { - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - } - } - - break; - - /**************************************************************************/ - case FTDM_CHANNEL_STATE_DOWN: /*the call is finished and removed */ - - if (ftdmchan->last_state == FTDM_CHANNEL_STATE_SUSPENDED) { - if (!ftdm_test_flag (ftdmchan, FTDM_CHANNEL_OPEN)) { - SS7_DEBUG_CHAN(ftdmchan,"Down came from SUSPEND - break %s\n", ""); - break; - } - } - - /* check if there is a reset response that needs to be sent */ - if (sngss7_test_ckt_flag (sngss7_info, FLAG_RESET_RX)) { - /* send a RSC-RLC */ - ft_to_sngss7_rsca (ftdmchan); - - /* clear the reset flag */ - clear_rx_rsc_flags(sngss7_info); - } - - /* check if there was a GRS that needs a GRA */ - if ((sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX)) && - (sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX_DN)) && - (sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX_CMPLT))) { - - /* check if this is the base circuit and send out the GRA - * we insure that this is the last circuit to have the state change queued */ - if (sngss7_info->rx_grs.range) { - /* send out the GRA */ - ft_to_sngss7_gra(ftdmchan); - - /* clean out the spans GRS structure */ - clear_rx_grs_data(sngss7_info); - } - - /* clear the grp reset flag */ - clear_rx_grs_flags(sngss7_info); - } - - /* check if we got the reset response */ - if (sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_TX_RSP)) { - /* clear the reset flag */ - clear_tx_rsc_flags(sngss7_info); - } - - if (sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_TX_RSP)) { - /* clear the reset flag */ - clear_tx_grs_flags(sngss7_info); - if (sngss7_info->rx_gra.range) { - /* clean out the spans GRA structure */ - clear_rx_gra_data(sngss7_info); - } - } - - /* check if we came from reset (aka we just processed a reset) */ - if ((ftdmchan->last_state == FTDM_CHANNEL_STATE_RESTART) || - (ftdmchan->last_state == FTDM_CHANNEL_STATE_SUSPENDED) || - (ftdmchan->last_state == FTDM_CHANNEL_STATE_HANGUP_COMPLETE)) { - - - /* check if reset flags are up indicating there is more processing to do yet */ - if (!(sngss7_test_ckt_flag (sngss7_info, FLAG_RESET_TX)) && - !(sngss7_test_ckt_flag (sngss7_info, FLAG_RESET_RX)) && - !(sngss7_test_ckt_flag (sngss7_info, FLAG_GRP_RESET_TX)) && - !(sngss7_test_ckt_flag (sngss7_info, FLAG_GRP_RESET_RX))) { - - SS7_DEBUG_CHAN(ftdmchan,"Current flags: ckt=0x%X, blk=0x%X\n", - sngss7_info->ckt_flags, - sngss7_info->blk_flags); - - if (sngss7_channel_status_clear(sngss7_info)) { - /* check if the sig status is down, and bring it up if it isn't */ - if (!ftdm_test_flag (ftdmchan, FTDM_CHANNEL_SIG_UP)) { - SS7_DEBUG_CHAN(ftdmchan,"All reset flags cleared %s\n", ""); - /* all flags are down so we can bring up the sig status */ - sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_UP); - } - } else { - state_flag = 0; - SS7_DEBUG_CHAN(ftdmchan,"Down detected blocked flags go to SUSPEND %s\n", " "); - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); - break; - - } - } else { - SS7_DEBUG_CHAN(ftdmchan,"Reset flags present (0x%X)\n", sngss7_info->ckt_flags); - - /* there is still another reset pending so go back to reset*/ - state_flag = 0; - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RESTART); - } - } - - /* check if t35 is active */ - if (sngss7_info->t35.hb_timer_id) { - ftdm_sched_cancel_timer (sngss7_info->t35.sched, sngss7_info->t35.hb_timer_id); - } - - /* clear all of the call specific data store in the channel structure */ - sngss7_info->suInstId = 0; - sngss7_info->spInstId = 0; - sngss7_info->globalFlg = 0; - sngss7_info->spId = 0; - - /* clear any call related flags */ - sngss7_clear_ckt_flag (sngss7_info, FLAG_REMOTE_REL); - sngss7_clear_ckt_flag (sngss7_info, FLAG_LOCAL_REL); - sngss7_clear_ckt_flag (sngss7_info, FLAG_SENT_ACM); - sngss7_clear_ckt_flag (sngss7_info, FLAG_SENT_CPG); - - - if (ftdm_test_flag (ftdmchan, FTDM_CHANNEL_OPEN)) { - ftdm_channel_t *close_chan = ftdmchan; - /* close the channel */ - SS7_DEBUG_CHAN(ftdmchan,"FTDM Channel Close %s\n", ""); - sngss7_flush_queue(sngss7_info->event_queue); - ftdm_channel_close (&close_chan); - } - - /* check if there is a glared call that needs to be processed */ - if (sngss7_test_ckt_flag(sngss7_info, FLAG_GLARE)) { - sngss7_clear_ckt_flag (sngss7_info, FLAG_GLARE); - - if (sngss7_info->glare.circuit != 0) { - int bHandle=0; - switch (g_ftdm_sngss7_data.cfg.glareResolution) { - case SNGSS7_GLARE_DOWN: - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Giving control to the other side, handling copied IAM from glare. \n", sngss7_info->circuit->cic); - bHandle = 1; - break; - - case SNGSS7_GLARE_PC: - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Trying to handle IAM copied from glare. \n", sngss7_info->circuit->cic); - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]My PC = %d, incoming PC = %d. \n", sngss7_info->circuit->cic, - g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info->circuit->infId].spc, - g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info->circuit->infId].dpc ); - - if( g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info->circuit->infId].spc > g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info->circuit->infId].dpc ) - { - if ((sngss7_info->circuit->cic % 2) == 1 ) { - bHandle = 1; - } - } else { - if( (sngss7_info->circuit->cic % 2) == 0 ) { - bHandle = 1; - } - } - - break; - default: /* if configured as SNGSS7_GLARE_CONTROL, always abandon incoming glared IAM. */ - bHandle = 0; - break; - } - - if (!bHandle) { - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Handling glare IAM. \n", sngss7_info->circuit->cic); - handle_con_ind (0, sngss7_info->glare.spInstId, sngss7_info->glare.circuit, &sngss7_info->glare.iam); - } - - /* clear the glare info */ - memset(&sngss7_info->glare, 0x0, sizeof(sngss7_glare_data_t)); - state_flag = 0; - } - } - - break; - /**************************************************************************/ - case FTDM_CHANNEL_STATE_RESTART: /* CICs needs a Reset */ - - SS7_DEBUG_CHAN(ftdmchan,"RESTART: Current flags: ckt=0x%X, blk=0x%X\n", - sngss7_info->ckt_flags, - sngss7_info->blk_flags); - - if (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK)) { - if ((sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_RX)) || - (sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX))) { - - SS7_DEBUG_CHAN(ftdmchan,"Incoming Reset request on CIC in UCIC block, removing UCIC block%s\n", ""); - - /* set the unblk flag */ - sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_UCIC_UNBLK); - - /* clear the block flag */ - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK); - - /* process the flag */ - state_flag = 0; - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); - - /* break out of the processing for now */ - break; - } - } - - - /* check if this is an outgoing RSC */ - if ((sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_TX)) && - !(sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_SENT))) { - - /* don't send out reset before finished hanging up if I'm in-use. */ - if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_INUSE)) { - /* send a reset request */ - ft_to_sngss7_rsc (ftdmchan); - sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_SENT); - } - - } /* if (sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_TX)) */ - - /* check if this is the first channel of a GRS (this flag is thrown when requesting reset) */ - if ( (sngss7_test_ckt_flag (sngss7_info, FLAG_GRP_RESET_TX)) && - !(sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_SENT)) && - (sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_BASE))) { - - /* send out the grs */ - ft_to_sngss7_grs (ftdmchan); - - } - - /* if the sig_status is up...bring it down */ - if (ftdm_test_flag (ftdmchan, FTDM_CHANNEL_SIG_UP)) { - sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_DOWN); - } - - if (sngss7_test_ckt_flag (sngss7_info, FLAG_GRP_RESET_RX)) { - /* set the grp reset done flag so we know we have finished this reset */ - sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX_DN); - } /* if (sngss7_test_ckt_flag (sngss7_info, FLAG_GRP_RESET_RX)) */ - - - if (ftdm_test_flag (ftdmchan, FTDM_CHANNEL_INUSE)) { - /* bring the call down first...then process the rest of the reset */ - switch (ftdmchan->last_state){ - /******************************************************************/ - case (FTDM_CHANNEL_STATE_TERMINATING): - state_flag = 0; - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_HANGUP); - break; - /******************************************************************/ - case (FTDM_CHANNEL_STATE_HANGUP): - case (FTDM_CHANNEL_STATE_HANGUP_COMPLETE): - /* go back to the last state after taking care of the rest of the restart state */ - state_flag = 0; - ftdm_set_state(ftdmchan, ftdmchan->last_state); - break; - /******************************************************************/ - case (FTDM_CHANNEL_STATE_IN_LOOP): - /* we screwed up in a COT/CCR, remove the loop */ - ftdm_channel_command(ftdmchan, FTDM_COMMAND_DISABLE_LOOP, NULL); - - /* go to down */ - state_flag = 0; - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - break; - /******************************************************************/ - default: - /* KONRAD: find out what the cause code should be */ - ftdmchan->caller_data.hangup_cause = 41; - - /* change the state to terminatting, it will throw us back here - * once the call is done - */ - state_flag = 0; - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); - break; - /******************************************************************/ - } /* switch (ftdmchan->last_state) */ - } else { - /* check if this an incoming RSC or we have a response already */ - if (sngss7_test_ckt_flag (sngss7_info, FLAG_RESET_RX) || - sngss7_test_ckt_flag (sngss7_info, FLAG_RESET_TX_RSP) || - sngss7_test_ckt_flag (sngss7_info, FLAG_GRP_RESET_TX_RSP) || - sngss7_test_ckt_flag (sngss7_info, FLAG_GRP_RESET_RX_CMPLT)) { - - SS7_DEBUG_CHAN(ftdmchan, "Reset processed moving to DOWN (0x%X)\n", sngss7_info->ckt_flags); - - /* go to a down state to clear the channel and send the response */ - state_flag = 0; - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - } else { - - SS7_DEBUG_CHAN(ftdmchan, "Waiting on Reset Rsp/Grp Reset to move to DOWN (0x%X)\n", sngss7_info->ckt_flags); - } - } - - break; - /**************************************************************************/ - case FTDM_CHANNEL_STATE_SUSPENDED: /* circuit has been blocked */ - - SS7_DEBUG_CHAN(ftdmchan,"SUSPEND: Current flags: ckt=0x%X, blk=0x%X, circuit->flag=0x%X\n", - sngss7_info->ckt_flags, sngss7_info->blk_flags, - sngss7_info->circuit->flags ); - - if (!(sngss7_info->circuit->flags & SNGSS7_CONFIGURED)) { - /* Configure the circuit if RESUME and PAUSED are not set. - And also in a case when RESUME is set */ - if (!sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_PAUSED) || - sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_RESUME)) { - if (ftmod_ss7_isup_ckt_config(sngss7_info->circuit->id)) { - SS7_CRITICAL("ISUP CKT %d configuration FAILED!\n", sngss7_info->circuit->id); - sngss7_set_ckt_flag(sngss7_info, FLAG_INFID_PAUSED); - sngss7_clear_ckt_flag(sngss7_info, FLAG_INFID_RESUME); - } else { - SS7_INFO("ISUP CKT %d configuration DONE!\n", sngss7_info->circuit->id); - sngss7_info->circuit->flags |= SNGSS7_CONFIGURED; - sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_TX); - } - } - } - - /**********************************************************************/ - if (sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_RESUME)) { - - SS7_DEBUG_CHAN(ftdmchan, "Processing RESUME%s\n", ""); - - /* clear the RESUME flag */ - sngss7_clear_ckt_flag(sngss7_info, FLAG_INFID_RESUME); - - /* clear the PAUSE flag */ - sngss7_clear_ckt_flag(sngss7_info, FLAG_INFID_PAUSED); - - /* We tried to hangup the call while in PAUSED state. - We must send a RESET to clear this circuit */ - if (sngss7_test_ckt_flag (sngss7_info, FLAG_LOCAL_REL)) { - SS7_DEBUG_CHAN(ftdmchan, "Channel local release on RESUME, restart Reset procedure%s\n", ""); - /* By setting RESET_TX flag the check below sngss7_tx_reset_status_pending() will - be true, and will restart the RESET TX procedure */ - sngss7_set_ckt_flag (sngss7_info, FLAG_REMOTE_REL); - sngss7_set_ckt_flag (sngss7_info, FLAG_RESET_TX); - } - - /* We have transmitted Reset/GRS but have not gotten a - * Response. In mean time we got a RESUME. We cannot be sure - * that our reset has been trasmitted, thus restart reset procedure. */ - if (sngss7_tx_reset_status_pending(sngss7_info)) { - SS7_DEBUG_CHAN(ftdmchan, "Channel transmitted RSC/GRS before RESUME, restart Reset procedure%s\n", ""); - clear_rx_grs_flags(sngss7_info); - clear_rx_grs_data(sngss7_info); - clear_tx_grs_flags(sngss7_info); - clear_tx_grs_data(sngss7_info); - clear_rx_rsc_flags(sngss7_info); - clear_tx_rsc_flags(sngss7_info); - - clear_tx_rsc_flags(sngss7_info); - sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_TX); - } - - /* if there are any resets present */ - if (!sngss7_channel_status_clear(sngss7_info)) { - /* don't bring up the sig status but also move to reset */ - if (!sngss7_reset_status_clear(sngss7_info)) { - goto suspend_goto_restart; - } else if (!sngss7_block_status_clear(sngss7_info)) { - /* Do nothing just go through and handle blocks below */ - } else { - /* This should not happen as above function tests - * for reset and blocks */ - SS7_ERROR_CHAN(ftdmchan, "Invalid code path: sngss7_channel_status_clear reset and block are both cleared%s\n", ""); - goto suspend_goto_restart; - } - } else { - /* bring the sig status back up */ - sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_UP); - } - } /* if (sngss7_test_flag(sngss7_info, FLAG_INFID_RESUME)) */ - - if (sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_PAUSED)) { - - SS7_DEBUG_CHAN(ftdmchan, "Processing PAUSE%s\n", ""); - - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_SIG_UP)) { - /* bring the sig status down */ - sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_DOWN); - } - - /* Wait for RESUME */ - goto suspend_goto_last; - } /* if (sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_PAUSED)) { */ - - /**********************************************************************/ - if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_MN_BLOCK_RX) && - !sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX_DN)) { - - SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_MN_BLOCK_RX flag %s\n", ""); - - /* bring the sig status down */ - sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_DOWN); - - /* send a BLA */ - ft_to_sngss7_bla (ftdmchan); - - /* throw the done flag */ - sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX_DN); - - } - - if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_MN_UNBLK_RX)){ - SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_MN_UNBLK_RX flag %s\n", ""); - - /* clear the block flags */ - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX); - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX_DN); - - /* clear the unblock flag */ - sngss7_clear_ckt_blk_flag (sngss7_info, FLAG_CKT_MN_UNBLK_RX); - - SS7_DEBUG_CHAN(ftdmchan,"Current flags: ckt=0x%X, blk=0x%X\n", - sngss7_info->ckt_flags, - sngss7_info->blk_flags); - /* not bring the cic up if there is a hardware block */ - if (sngss7_channel_status_clear(sngss7_info)) { - /* bring the sig status up */ - sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_UP); - - } - /* send a uba */ - ft_to_sngss7_uba (ftdmchan); - - } - - - /**********************************************************************/ - /* hardware block/unblock tx */ - if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_GRP_HW_BLOCK_TX ) && - !sngss7_test_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_TX_DN )) { - - SS7_DEBUG_CHAN(ftdmchan, "Processing FLAG_GRP_HW_BLOCK_TX flag %s\n", ""); - sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_DOWN); - - /* dont send block again if the channel is already blocked by maintenance */ - if( !sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX) && - !sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX_DN) - ) { - ft_to_sngss7_blo(ftdmchan); - } - sngss7_set_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_TX_DN); - - } - - if (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_UNBLK_TX)) { - int skip_unblock=0; - SS7_DEBUG_CHAN(ftdmchan, "Processing FLAG_GRP_HW_UNBLK_TX flag %s\n", ""); - - if (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_TX) || - sngss7_test_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_TX_DN)) { - /* Real unblock */ - } else { - SS7_ERROR_CHAN(ftdmchan, "FLAG_GRP_HW_UNBLK_TX set while FLAG_GRP_HW_BLOCK_TX is not %s\n", ""); - skip_unblock=1; - } - - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_TX); - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_TX_DN); - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_UNBLK_TX); - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_UNBLK_TX_DN); - - if (sngss7_channel_status_clear(sngss7_info)) { - sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_UP); - } - - if (sngss7_tx_block_status_clear(sngss7_info) && !skip_unblock) { - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX_DN); - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX); - ft_to_sngss7_ubl(ftdmchan); - } - - } - - /**********************************************************************/ -#if 0 - /* This logic is handled in the handle_cgu_req and handle_cgb_req */ - - if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_GRP_HW_BLOCK_RX ) && - !sngss7_test_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX_DN )) { - - SS7_DEBUG_CHAN(ftdmchan, "Processing FLAG_GRP_HW_BLOCK_RX flag %s\n", ""); - - sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_DOWN); - - /* FIXME: Transmit CRG Ack */ - - sngss7_set_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX_DN); - - goto suspend_goto_last; - } - - if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_GRP_HW_UNBLK_RX )){ - SS7_DEBUG_CHAN(ftdmchan, "Processing FLAG_GRP_HW_UNBLK_RX flag %s\n", ""); - - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX); - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX_DN); - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_UNBLK_RX); - - if (sngss7_channel_status_clear(sngs7_info)) { - sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_UP); - } - - /* Transmit CRU Ack */ - - goto suspend_goto_last; - } -#endif - - - /**********************************************************************/ - if (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX) && - !sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX_DN)) { - - SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_MN_BLOCK_TX flag %s\n", ""); - - /* bring the sig status down */ - sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_DOWN); - - /* send a blo */ - ft_to_sngss7_blo (ftdmchan); - - /* throw the done flag */ - sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX_DN); - - } - - if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_MN_UNBLK_TX)) { - - SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_MN_UNBLK_TX flag %s\n", ""); - - /* clear the block flags */ - sngss7_clear_ckt_blk_flag (sngss7_info, FLAG_CKT_MN_BLOCK_TX); - sngss7_clear_ckt_blk_flag (sngss7_info, FLAG_CKT_MN_BLOCK_TX_DN); - - /* clear the unblock flag */ - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_UNBLK_TX); - - if (sngss7_channel_status_clear(sngss7_info)) { - /* bring the sig status up */ - sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_UP); - } - - if (sngss7_tx_block_status_clear(sngss7_info)) { - /* send a ubl */ - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX_DN); - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX); - ft_to_sngss7_ubl(ftdmchan); - } - - } - - /**********************************************************************/ - if (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX) && - !sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX_DN)) { - - SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_LC_BLOCK_RX flag %s\n", ""); - - /* send a BLA */ - ft_to_sngss7_bla(ftdmchan); - - /* throw the done flag */ - sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX_DN); - - if (sngss7_tx_block_status_clear(sngss7_info)) { - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX_DN); - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX); - ft_to_sngss7_ubl(ftdmchan); - } else { - /* bring the sig status down */ - sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_DOWN); - } - - } - - if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_LC_UNBLK_RX)) { - - SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_LC_UNBLK_RX flag %s\n", ""); - - /* clear the block flags */ - sngss7_clear_ckt_blk_flag (sngss7_info, FLAG_CKT_LC_BLOCK_RX); - sngss7_clear_ckt_blk_flag (sngss7_info, FLAG_CKT_LC_BLOCK_RX_DN); - - /* clear the unblock flag */ - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_UNBLK_RX); - - /* send a uba */ - ft_to_sngss7_uba(ftdmchan); - - if (sngss7_channel_status_clear(sngss7_info)) { - sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_UP); - } - - - } - /**********************************************************************/ - if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_UCIC_BLOCK) && - !sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_UCIC_BLOCK_DN)) { - - SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_UCIC_BLOCK flag %s\n", ""); - - /* bring the channel signaling status to down */ - sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_DOWN); - - /* remove any reset flags */ - clear_rx_grs_flags(sngss7_info); - clear_rx_grs_data(sngss7_info); - clear_tx_grs_flags(sngss7_info); - clear_tx_grs_data(sngss7_info); - clear_rx_rsc_flags(sngss7_info); - clear_tx_rsc_flags(sngss7_info); - - /* throw the done flag */ - sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK_DN); - - } - - if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_UCIC_UNBLK)) { - SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_UCIC_UNBLK flag %s\n", ""); - - /* remove the UCIC block flag */ - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK); - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK_DN); - - /* remove the UCIC unblock flag */ - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_UCIC_UNBLK); - - /* throw the channel into reset to sync states */ - - clear_rx_grs_flags(sngss7_info); - clear_rx_grs_data(sngss7_info); - clear_tx_grs_flags(sngss7_info); - clear_tx_grs_data(sngss7_info); - clear_rx_rsc_flags(sngss7_info); - clear_tx_rsc_flags(sngss7_info); - - clear_tx_rsc_flags(sngss7_info); - sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_TX); - - /* bring the channel into restart again */ - goto suspend_goto_restart; - } - - SS7_DEBUG_CHAN(ftdmchan,"No block flag processed!%s\n", ""); - -suspend_goto_last: - if (ftdmchan->last_state == FTDM_CHANNEL_STATE_UP) { - /* proceed to UP */ - } else if (!sngss7_reset_status_clear(sngss7_info) || - sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_PAUSED)) { - - /* At this point the circuit is in reset, if the call is - in use make sure that at least REMOTE REL flag is set - in order to drop the call on the sip side */ - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_INUSE)) { - if (!sngss7_test_ckt_flag (sngss7_info, FLAG_LOCAL_REL) && - !sngss7_test_ckt_flag (sngss7_info, FLAG_REMOTE_REL)) { - sngss7_set_ckt_flag (sngss7_info, FLAG_REMOTE_REL); - } - } - SS7_DEBUG_CHAN(ftdmchan,"Channel opted to stay in RESTART due to reset!%s\n", ""); - SS7_DEBUG_CHAN(ftdmchan,"Current flags: ckt=0x%X, blk=0x%X, circuit->flag=0x%X\n", - sngss7_info->ckt_flags, sngss7_info->blk_flags, - sngss7_info->circuit->flags ); - - goto suspend_goto_restart; - - } else if (sngss7_channel_status_clear(sngss7_info)) { - - /* In this case all resets and blocks are clear sig state is up, thus go to DOWN */ - if (ftdmchan->last_state == FTDM_CHANNEL_STATE_RESTART || - ftdmchan->last_state == FTDM_CHANNEL_STATE_TERMINATING) { - ftdmchan->last_state = FTDM_CHANNEL_STATE_DOWN; - } - - SS7_DEBUG_CHAN(ftdmchan,"Channel signallig is UP: proceed to State %s!\n", - ftdm_channel_state2str(ftdmchan->last_state)); - SS7_DEBUG_CHAN(ftdmchan,"Current flags: ckt=0x%X, blk=0x%X, circuit->flag=0x%X\n", - sngss7_info->ckt_flags, sngss7_info->blk_flags, - sngss7_info->circuit->flags ); - - } else { - - if (ftdmchan->last_state == FTDM_CHANNEL_STATE_DOWN) { - ftdmchan->last_state = FTDM_CHANNEL_STATE_RESTART; - } - SS7_DEBUG_CHAN(ftdmchan,"Channel signaling is in block state: proceed to State=%s]\n", - ftdm_channel_state2str(ftdmchan->last_state)); - SS7_DEBUG_CHAN(ftdmchan,"Current flags: ckt=0x%X, blk=0x%X, circuit->flag=0x%X\n", - sngss7_info->ckt_flags, sngss7_info->blk_flags, - sngss7_info->circuit->flags); - } - - state_flag = 0; - ftdm_set_state(ftdmchan, ftdmchan->last_state); - break; - -suspend_goto_restart: - state_flag = 0; - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RESTART); - break; - - /**************************************************************************/ - case FTDM_CHANNEL_STATE_IN_LOOP: /* COT test */ - - isup_intf = &g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info->circuit->infId]; - - if (sngss7_test_options(isup_intf, SNGSS7_LPA_FOR_COT)) { - /* send the lpa */ - ft_to_sngss7_lpa (ftdmchan); - } - - break; - /**************************************************************************/ - case FTDM_CHANNEL_STATE_IDLE: - state_flag = 0; - ftdm_set_state(ftdmchan, ftdmchan->last_state); - break; - /**************************************************************************/ - default: - /* we don't handle any of the other states */ - SS7_ERROR_CHAN(ftdmchan, "ftmod_sangoma_ss7 does not support %s state\n", ftdm_channel_state2str (ftdmchan->state)); - - break; - /**************************************************************************/ - } - - if (state_flag) { - /* clear the state change flag...since we might be setting a new state */ - ftdm_channel_complete_state(ftdmchan); - } - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static FIO_CHANNEL_OUTGOING_CALL_FUNCTION(ftdm_sangoma_ss7_outgoing_call) -{ - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - - /* the core has this channel already locked so need to lock again */ - - /* check if the channel sig state is UP */ - if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_SIG_UP)) { - SS7_ERROR_CHAN(ftdmchan, "Requested channel sig state is down, skipping channell!%s\n", " "); - /* Sig state will be down due to a block. - Right action is to hunt for another call */ - goto outgoing_break; - } - - /* check if there is a remote block */ - if ((sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX)) || - (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX)) || - (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX))) { - - /* the channel is blocked...can't send any calls here */ - SS7_ERROR_CHAN(ftdmchan, "Requested channel is remotely blocked, re-hunt channel!%s\n", " "); - goto outgoing_break; - } - - /* check if there is a local block */ - if ((sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX)) || - (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_TX)) || - (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_GRP_MN_BLOCK_TX))) { - - /* KONRAD FIX ME : we should check if this is a TEST call and allow it */ - - /* the channel is blocked...can't send any calls here */ - SS7_ERROR_CHAN(ftdmchan, "Requested channel is locally blocked, re-hunt channel!%s\n", " "); - goto outgoing_break; - } - - - /* This is a gracefull stack resource check. - Removing this function will cause unpredictable - ungracefule errors. */ - if (sng_cc_resource_check()) { - goto outgoing_fail; - } - - /* check the state of the channel */ - switch (ftdmchan->state){ - /**************************************************************************/ - case FTDM_CHANNEL_STATE_DOWN: - /* inform the monitor thread that we want to make a call by returning FTDM_SUCCESS */ - - goto outgoing_successful; - break; - /**************************************************************************/ - default: - /* the channel is already used...this can't be, end the request */ - SS7_ERROR("Outgoing call requested channel in already in use...indicating glare on span=%d,chan=%d\n", - ftdmchan->physical_span_id, - ftdmchan->physical_chan_id); - - goto outgoing_break; - break; - /**************************************************************************/ - } /* switch (ftdmchan->state) (original call) */ - -outgoing_fail: - SS7_DEBUG_CHAN(ftdmchan, "Call Request failed%s\n", " "); - return FTDM_FAIL; - -outgoing_break: - SS7_DEBUG_CHAN(ftdmchan, "Call Request re-hunt%s\n", " "); - return FTDM_BREAK; - -outgoing_successful: - SS7_DEBUG_CHAN(ftdmchan, "Call Request successful%s\n", " "); - return FTDM_SUCCESS; -} - -/******************************************************************************/ -#if 0 - static FIO_CHANNEL_REQUEST_FUNCTION (ftdm_sangoma_ss7_request_chan) - { - SS7_INFO ("KONRAD-> I got called %s\n", __FTDM_FUNC__); - return FTDM_SUCCESS; - } - -#endif - -/******************************************************************************/ - -/* FT-CORE SIG STATUS FUNCTIONS ********************************************** */ -static FIO_CHANNEL_GET_SIG_STATUS_FUNCTION(ftdm_sangoma_ss7_get_sig_status) -{ - if (ftdm_test_flag (ftdmchan, FTDM_CHANNEL_SIG_UP)) { - *status = FTDM_SIG_STATE_UP; - } else { - *status = FTDM_SIG_STATE_DOWN; - } - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static FIO_CHANNEL_SET_SIG_STATUS_FUNCTION(ftdm_sangoma_ss7_set_sig_status) -{ - SS7_ERROR ("Cannot set channel status in this module\n"); - return FTDM_NOTIMPL; -} - -/* FT-CORE SIG FUNCTIONS ******************************************************/ -static ftdm_status_t ftdm_sangoma_ss7_start(ftdm_span_t * span) -{ - ftdm_channel_t *ftdmchan = NULL; - sngss7_chan_data_t *sngss7_info = NULL; - sngss7_span_data_t *sngss7_span = NULL; - sng_isup_inf_t *sngss7_intf = NULL; - int x; - int first_channel; - - first_channel=0; - - - SS7_INFO ("Starting span %s:%u.\n", span->name, span->span_id); - - /* clear the monitor thread stop flag */ - ftdm_clear_flag (span, FTDM_SPAN_STOP_THREAD); - ftdm_clear_flag (span, FTDM_SPAN_IN_THREAD); - - /* check the status of all isup interfaces */ - check_status_of_all_isup_intf(); - - /* throw the channels in pause */ - for (x = 1; x < (span->chan_count + 1); x++) { - /* extract the channel structure and sngss7 channel data */ - ftdmchan = span->channels[x]; - - /* if there is no sig mod data move along */ - if (ftdmchan->call_data == NULL) continue; - - sngss7_info = ftdmchan->call_data; - sngss7_span = ftdmchan->span->signal_data; - sngss7_intf = &g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info->circuit->infId]; - - /* flag the circuit as active so we can receieve events on it */ - sngss7_set_flag(sngss7_info->circuit, SNGSS7_ACTIVE); - - /* if this is a non-voice channel, move along cause we're done with it */ - if (sngss7_info->circuit->type != SNG_CKT_VOICE) continue; - - /* lock the channel */ - ftdm_mutex_lock(ftdmchan->mutex); - - /* check if the interface is paused or resumed */ - if (sngss7_test_flag(sngss7_intf, SNGSS7_PAUSED)) { - SS7_DEBUG_CHAN(ftdmchan, "ISUP intf %d is PAUSED\n", sngss7_intf->id); - /* throw the pause flag */ - sngss7_clear_ckt_flag(sngss7_info, FLAG_INFID_RESUME); - sngss7_set_ckt_flag(sngss7_info, FLAG_INFID_PAUSED); - } else { - SS7_DEBUG_CHAN(ftdmchan, "ISUP intf %d is RESUMED\n", sngss7_intf->id); - /* throw the resume flag */ - sngss7_clear_ckt_flag(sngss7_info, FLAG_INFID_PAUSED); - sngss7_set_ckt_flag(sngss7_info, FLAG_INFID_RESUME); - } -#if 0 - /* throw the grp reset flag */ - sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_RESET_TX); - if (first_channel == 0) { - sngss7_chan_data_t *cinfo = ftdmchan->call_data; - sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_RESET_BASE); - cinfo->tx_grs.circuit = sngss7_info->circuit->id; - cinfo->tx_grs.range = span->chan_count -1; - first_channel=1; - } -#else - /* throw the channel into reset */ - sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_TX); -#endif - /* throw the channel to suspend */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); - - /* unlock the channel */ - ftdm_mutex_unlock(ftdmchan->mutex); - } - - /* activate all the configured ss7 links */ - if (ft_to_sngss7_activate_all()) { - SS7_CRITICAL ("Failed to activate LibSngSS7!\n"); - return FTDM_FAIL; - } - - /*start the span monitor thread */ - if (ftdm_thread_create_detached (ftdm_sangoma_ss7_run, span) != FTDM_SUCCESS) { - SS7_CRITICAL ("Failed to start Span Monitor Thread!\n"); - return FTDM_FAIL; - } - - SS7_DEBUG ("Finished starting span %s:%u.\n", span->name, span->span_id); - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static ftdm_status_t ftdm_sangoma_ss7_stop(ftdm_span_t * span) -{ - /*this function is called by the FT-Core to stop this span */ - int timeout=0; - - ftdm_log (FTDM_LOG_INFO, "Stopping span %s:%u.\n", span->name,span->span_id); - - /* throw the STOP_THREAD flag to signal monitor thread stop */ - ftdm_set_flag (span, FTDM_SPAN_STOP_THREAD); - - /* wait for the thread to stop */ - while (ftdm_test_flag (span, FTDM_SPAN_IN_THREAD)) { - ftdm_set_flag (span, FTDM_SPAN_STOP_THREAD); - ftdm_log (FTDM_LOG_DEBUG,"Waiting for monitor thread to end for %s:%u. [flags=0x%08X]\n", - span->name, - span->span_id, - span->flags); - /* Wait 50ms */ - ftdm_sleep (50); - timeout++; - - /* timeout after 5 sec, better to crash than hang */ - ftdm_assert_return(timeout < 100, FTDM_FALSE, "SS7 Span stop timeout!\n"); - } - - /* KONRAD FIX ME - deconfigure any circuits, links, attached to this span */ - - ftdm_log (FTDM_LOG_DEBUG, "Finished stopping span %s:%u.\n", span->name, span->span_id); - - return FTDM_SUCCESS; -} - -/* SIG_FUNCTIONS ***************************************************************/ -static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_sangoma_ss7_span_config) -{ - sngss7_span_data_t *ss7_span_info; - - ftdm_log (FTDM_LOG_INFO, "Configuring ftmod_sangoma_ss7 span = %s(%d)...\n", - span->name, - span->span_id); - - /* initalize the span's data structure */ - ss7_span_info = ftdm_calloc (1, sizeof (sngss7_span_data_t)); - - /* create a timer schedule */ - if (ftdm_sched_create(&ss7_span_info->sched, "SngSS7_Schedule")) { - SS7_CRITICAL("Unable to create timer schedule!\n"); - return FTDM_FAIL; - } - - /* start the free run thread for the schedule */ - if (ftdm_sched_free_run(ss7_span_info->sched)) { - SS7_CRITICAL("Unable to schedule free run!\n"); - return FTDM_FAIL; - } - - /* create an event queue for this span */ - if ((ftdm_queue_create(&(ss7_span_info)->event_queue, SNGSS7_EVENT_QUEUE_SIZE)) != FTDM_SUCCESS) { - SS7_CRITICAL("Unable to create event queue!\n"); - return FTDM_FAIL; - } - - /*setup the span structure with the info so far */ - g_ftdm_sngss7_data.sig_cb = sig_cb; - span->start = ftdm_sangoma_ss7_start; - span->stop = ftdm_sangoma_ss7_stop; - span->signal_type = FTDM_SIGTYPE_SS7; - span->signal_data = NULL; - span->outgoing_call = ftdm_sangoma_ss7_outgoing_call; - span->channel_request = NULL; - span->signal_cb = sig_cb; - span->get_channel_sig_status = ftdm_sangoma_ss7_get_sig_status; - span->set_channel_sig_status = ftdm_sangoma_ss7_set_sig_status; - span->state_map = &sangoma_ss7_state_map; - span->state_processor = ftdm_sangoma_ss7_process_state_change; - span->signal_data = ss7_span_info; - - /* set the flag to indicate that this span uses channel state change queues */ - ftdm_set_flag (span, FTDM_SPAN_USE_CHAN_QUEUE); - /* set the flag to indicate that this span uses sig event queues */ - ftdm_set_flag (span, FTDM_SPAN_USE_SIGNALS_QUEUE); - - - - /* parse the configuration and apply to the global config structure */ - if (ftmod_ss7_parse_xml(ftdm_parameters, span)) { - ftdm_log (FTDM_LOG_CRIT, "Failed to parse configuration!\n"); - ftdm_sleep (100); - return FTDM_FAIL; - } - - if(SNG_SS7_OPR_MODE_M2UA_SG == g_ftdm_operating_mode){ - ftdm_log (FTDM_LOG_INFO, "FreeTDM running as M2UA_SG mode, Setting Span type to FTDM_SIGTYPE_M2UA\n"); - span->signal_type = FTDM_SIGTYPE_M2UA; - } - - if (ft_to_sngss7_cfg_all()) { /* configure libsngss7 */ - ftdm_log (FTDM_LOG_CRIT, "Failed to configure LibSngSS7!\n"); - ftdm_sleep (100); - return FTDM_FAIL; - } - - ftdm_log (FTDM_LOG_INFO, "Finished configuring ftmod_sangoma_ss7 span = %s(%d)...\n", - span->name, - span->span_id); - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static FIO_SIG_LOAD_FUNCTION(ftdm_sangoma_ss7_init) -{ - /*this function is called by the FT-core to load the signaling module */ - uint32_t major = 0; - uint32_t minor = 0; - uint32_t build = 0; - - ftdm_log (FTDM_LOG_INFO, "Loading ftmod_sangoma_ss7...\n"); - - /* default the global structure */ - memset (&g_ftdm_sngss7_data, 0x0, sizeof (ftdm_sngss7_data_t)); - - sngss7_id = 0; - - cmbLinkSetId = 0; - - /* initalize the global gen_config flag */ - g_ftdm_sngss7_data.gen_config = 0; - - /* function trace initizalation */ - g_ftdm_sngss7_data.function_trace = 1; - g_ftdm_sngss7_data.function_trace_level = 7; - - /* message (IAM, ACM, ANM, etc) trace initizalation */ - g_ftdm_sngss7_data.message_trace = 1; - g_ftdm_sngss7_data.message_trace_level = 6; - - /* setup the call backs needed by Sangoma_SS7 library */ - sng_event.cc.sng_con_ind = sngss7_con_ind; - sng_event.cc.sng_con_cfm = sngss7_con_cfm; - sng_event.cc.sng_con_sta = sngss7_con_sta; - sng_event.cc.sng_rel_ind = sngss7_rel_ind; - sng_event.cc.sng_rel_cfm = sngss7_rel_cfm; - sng_event.cc.sng_dat_ind = sngss7_dat_ind; - sng_event.cc.sng_fac_ind = sngss7_fac_ind; - sng_event.cc.sng_fac_cfm = sngss7_fac_cfm; - sng_event.cc.sng_sta_ind = sngss7_sta_ind; - sng_event.cc.sng_umsg_ind = sngss7_umsg_ind; - sng_event.cc.sng_susp_ind = sngss7_susp_ind; - sng_event.cc.sng_resm_ind = sngss7_resm_ind; - - sng_event.sm.sng_log = handle_sng_log; - sng_event.sm.sng_mtp1_alarm = handle_sng_mtp1_alarm; - sng_event.sm.sng_mtp2_alarm = handle_sng_mtp2_alarm; - sng_event.sm.sng_mtp3_alarm = handle_sng_mtp3_alarm; - sng_event.sm.sng_isup_alarm = handle_sng_isup_alarm; - sng_event.sm.sng_cc_alarm = handle_sng_cc_alarm; - sng_event.sm.sng_relay_alarm = handle_sng_relay_alarm; - sng_event.sm.sng_m2ua_alarm = handle_sng_m2ua_alarm; - sng_event.sm.sng_nif_alarm = handle_sng_nif_alarm; - sng_event.sm.sng_tucl_alarm = handle_sng_tucl_alarm; - sng_event.sm.sng_sctp_alarm = handle_sng_sctp_alarm; - - /* initalize sng_ss7 library */ - sng_isup_init_gen(&sng_event); - - /* print the version of the library being used */ - sng_isup_version(&major, &minor, &build); - SS7_INFO("Loaded LibSng-SS7 %d.%d.%d\n", major, minor, build); - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static FIO_SIG_UNLOAD_FUNCTION(ftdm_sangoma_ss7_unload) -{ - /*this function is called by the FT-core to unload the signaling module */ - - int x; - - ftdm_log (FTDM_LOG_INFO, "Starting ftmod_sangoma_ss7 unload...\n"); - - - if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_CC_STARTED)) { - sng_isup_free_cc(); - sngss7_clear_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_CC_STARTED); - } - - if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_ISUP_STARTED)) { - ftmod_ss7_shutdown_isup(); - sng_isup_free_isup(); - sngss7_clear_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_ISUP_STARTED); - } - - if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP3_STARTED)) { - ftmod_ss7_shutdown_mtp3(); - sng_isup_free_mtp3(); - sngss7_clear_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP3_STARTED); - } - - if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP2_STARTED)) { - ftmod_ss7_shutdown_mtp2(); - sng_isup_free_mtp2(); - sngss7_clear_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP2_STARTED); - } - - if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP1_STARTED)) { - sng_isup_free_mtp1(); - sngss7_clear_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP1_STARTED); - } - - if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_RY_STARTED)) { - /* go through all the relays channels and disable them */ - x = 1; - while (x < (MAX_RELAY_CHANNELS)) { - /* check if this relay channel has been configured already */ - if ((g_ftdm_sngss7_data.cfg.relay[x].flags & SNGSS7_CONFIGURED)) { - - /* send the specific configuration */ - if (ftmod_ss7_disable_relay_channel(x)) { - SS7_CRITICAL("Relay Channel %d disable failed!\n", x); - /* jz: dont leave like this - * return 1; - * */ - } else { - SS7_INFO("Relay Channel %d disable DONE!\n", x); - } - - /* set the SNGSS7_CONFIGURED flag */ - g_ftdm_sngss7_data.cfg.relay[x].flags &= ~(SNGSS7_CONFIGURED); - } /* if !SNGSS7_CONFIGURED */ - x++; - } /* while (x < (MAX_RELAY_CHANNELS)) */ - - ftmod_ss7_shutdown_relay(); - sng_isup_free_relay(); - sngss7_clear_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_RY_STARTED); - } - - if(SNG_SS7_OPR_MODE_ISUP != g_ftdm_operating_mode){ - ftmod_ss7_m2ua_free(); - } - - - if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_SM_STARTED)) { - sng_isup_free_sm(); - sngss7_clear_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_SM_STARTED); - } - - sng_isup_free_gen(); - - ftdm_log (FTDM_LOG_INFO, "Finished ftmod_sangoma_ss7 unload!\n"); - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static FIO_API_FUNCTION(ftdm_sangoma_ss7_api) -{ - /* handle this in it's own file....so much to do */ - return (ftdm_sngss7_handle_cli_cmd (stream, data)); -} - -/******************************************************************************/ -static FIO_IO_LOAD_FUNCTION(ftdm_sangoma_ss7_io_init) -{ - assert (fio != NULL); - memset (&g_ftdm_sngss7_interface, 0, sizeof (g_ftdm_sngss7_interface)); - - g_ftdm_sngss7_interface.name = "ss7"; - g_ftdm_sngss7_interface.api = ftdm_sangoma_ss7_api; - - *fio = &g_ftdm_sngss7_interface; - - return FTDM_SUCCESS; -} - -/******************************************************************************/ - - -/* START **********************************************************************/ -ftdm_module_t ftdm_module = { - "sangoma_ss7", /*char name[256]; */ - ftdm_sangoma_ss7_io_init, /*fio_io_load_t */ - NULL, /*fio_io_unload_t */ - ftdm_sangoma_ss7_init, /*fio_sig_load_t */ - NULL, /*fio_sig_configure_t */ - ftdm_sangoma_ss7_unload, /*fio_sig_unload_t */ - ftdm_sangoma_ss7_span_config /*fio_configure_span_signaling_t */ -}; -/******************************************************************************/ - -/******************************************************************************/ -/* For Emacs: -* Local Variables: -* mode:c -* indent-tabs-mode:t -* tab-width:4 -* c-basic-offset:4 -* End: -* For VIM: -* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: -*/ -/******************************************************************************/ diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h deleted file mode 100644 index 6dabf727cd..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h +++ /dev/null @@ -1,1246 +0,0 @@ -/* - * Copyright (c) 2009, Konrad Hammel - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - * Contributors: - * - * James Zhang - * - */ -/******************************************************************************/ -#ifndef __FTMOD_SNG_SS7_H__ -#define __FTMOD_SNG_SS7_H__ -/******************************************************************************/ - -/* INCLUDE ********************************************************************/ -#include -#include -#include -#include -#include -#include - -#include "private/ftdm_core.h" - -#include "sng_ss7/sng_ss7.h" -#include "ftmod_sangoma_ss7_m2ua.h" - -/******************************************************************************/ - -/* DEFINES ********************************************************************/ -#define MAX_NAME_LEN 25 - -#define MAX_CIC_LENGTH 5 -#define MAX_CIC_MAP_LENGTH 1000 -#define MAX_SCTP_LINK 100 - -#define SNGSS7_EVENT_QUEUE_SIZE 100 -#define SNGSS7_PEER_CHANS_QUEUE_SIZE 100 -#define SNGSS7_CHAN_EVENT_QUEUE_SIZE 100 - -#define MAX_SIZEOF_SUBADDR_IE 24 /* as per Q931 4.5.9 */ - -#define SNGSS7_SWITCHTYPE_ANSI(switchtype) (switchtype == LSI_SW_ANS88) || \ - (switchtype == LSI_SW_ANS92) || \ - (switchtype == LSI_SW_ANS95) - -#define sngss7_flush_queue(queue) \ - do { \ - void *__queue_data = NULL; \ - while ((__queue_data = ftdm_queue_dequeue(queue))) { \ - ftdm_safe_free(__queue_data); \ - } \ - } while (0) - -typedef struct ftdm2trillium { - uint8_t ftdm_val; - uint8_t trillium_val; -} ftdm2trillium_t; - -typedef enum { - SNGSS7_CON_IND_EVENT = 0, - SNGSS7_CON_CFM_EVENT, - SNGSS7_CON_STA_EVENT, - SNGSS7_REL_IND_EVENT, - SNGSS7_REL_CFM_EVENT, - SNGSS7_DAT_IND_EVENT, - SNGSS7_FAC_IND_EVENT, - SNGSS7_FAC_CFM_EVENT, - SNGSS7_UMSG_IND_EVENT, - SNGSS7_STA_IND_EVENT, - SNGSS7_SUSP_IND_EVENT, - SNGSS7_RESM_IND_EVENT, - SNGSS7_SSP_STA_CFM_EVENT, - SNGSS7_INVALID_EVENT, -} sng_event_type_t; -#define SNG_EVENT_TYPE_STRINGS "CON_IND", "CON_CFM", "CON_STA", "REL_IND", "REL_CFM", "DAT_IND", "FAC_IND", \ - "FAC_CFM", "UMSG_IND", "STA_IND", "SUSP_IND", "RESM_IND", "SSP_STA_CFM", "INVALID" -FTDM_STR2ENUM_P(ftdm_str2sngss7_event, ftdm_sngss7_event2str, sng_event_type_t) - -typedef enum { - SNG_BIT_A = (1 << 0), - SNG_BIT_B = (1 << 1), - SNG_BIT_C = (1 << 2), - SNG_BIT_D = (1 << 3), - SNG_BIT_E = (1 << 4), - SNG_BIT_F = (1 << 5), - SNG_BIT_G = (1 << 6), - SNG_BIT_H = (1 << 7) -} sng_bit_enums_t; - -typedef enum { - SNG_CKT_VOICE = 0, - SNG_CKT_SIG, - SNG_CKT_HOLE -} sng_ckt_type_t; - -typedef enum { - SNG_RTE_UP = 0, - SNG_RTE_DN -} sng_route_direction_t; - -typedef enum { - SNGSS7_LPA_FOR_COT = (1 << 0), /* send LPA when COT arrives */ - SNGSS7_ACM_OBCI_BITA = (1 << 10) /* in-band indication */ -} sng_intf_options_t; - -typedef enum { - SNG_CALLED = 1, - SNG_CALLING = 2 -} sng_addr_type_t; - -typedef enum { - SNG_GEN_CFG_STATUS_INIT = 0, - SNG_GEN_CFG_STATUS_PENDING = 1, - SNG_GEN_CFG_STATUS_DONE = 2 -} nsg_gen_cfg_type_t; - -typedef struct sng_mtp2_error_type { - int init; - char sng_type[MAX_NAME_LEN]; - uint32_t tril_type; -} sng_mtp2_error_type_t; - -typedef struct sng_link_type { - int init; - char sng_type[MAX_NAME_LEN]; - uint32_t tril_mtp2_type; - uint32_t tril_mtp3_type; -} sng_link_type_t; - -typedef struct sng_switch_type { - int init; - char sng_type[MAX_NAME_LEN]; - uint32_t tril_mtp3_type; - uint32_t tril_isup_type; -} sng_switch_type_t; - -typedef struct sng_ssf_type { - int init; - char sng_type[MAX_NAME_LEN]; - uint32_t tril_type; -} sng_ssf_type_t; - -typedef struct sng_cic_cntrl_type { - int init; - char sng_type[MAX_NAME_LEN]; - uint32_t tril_type; -} sng_cic_cntrl_type_t; - -typedef struct sng_mtp1_link { - char name[MAX_NAME_LEN]; - uint32_t flags; - uint32_t id; - uint32_t span; - uint32_t chan; -} sng_mtp1_link_t; - -typedef struct sng_mtp2_link { - char name[MAX_NAME_LEN]; - uint32_t flags; - uint32_t id; - uint32_t lssuLength; - uint32_t errorType; - uint32_t linkType; - uint32_t mtp1Id; - uint32_t mtp1ProcId; - uint32_t t1; - uint32_t t2; - uint32_t t3; - uint32_t t4n; - uint32_t t4e; - uint32_t t5; - uint32_t t6; - uint32_t t7; -} sng_mtp2_link_t; - -/* defining glare handling methods: - SNGSS7_GLARE_PC: - higher PointCode controls even number CIC - lower PointCode controls odd number CIC - SNGSS7_GLARE_DOWN: - always give control to the other side - SNGSS7_GLARE_CONTROL: - always trying to control -*/ -typedef enum { - SNGSS7_GLARE_PC = 0, - SNGSS7_GLARE_DOWN, - SNGSS7_GLARE_CONTROL -} sng_glare_resolution; - -typedef struct sng_mtp3_link { - char name[MAX_NAME_LEN]; - uint32_t flags; - uint32_t id; - uint32_t priority; - uint32_t linkType; - uint32_t switchType; - uint32_t apc; - uint32_t spc; - uint32_t ssf; - uint32_t slc; - uint32_t linkSetId; - uint32_t mtp2Id; - uint32_t mtp2ProcId; - uint32_t t1; - uint32_t t2; - uint32_t t3; - uint32_t t4; - uint32_t t5; - uint32_t t6; - uint32_t t7; - uint32_t t8; - uint32_t t9; - uint32_t t10; - uint32_t t11; - uint32_t t12; - uint32_t t13; - uint32_t t14; - uint32_t t15; - uint32_t t16; - uint32_t t17; - uint32_t t18; - uint32_t t19; - uint32_t t20; - uint32_t t21; - uint32_t t22; - uint32_t t23; - uint32_t t24; - uint32_t t25; - uint32_t t27; - uint32_t t28; - uint32_t t29; - uint32_t t30; - uint32_t t31; - uint32_t t32; - uint32_t t33; - uint32_t t34; - uint32_t t35; - uint32_t t36; - uint32_t t37; - uint32_t tcraft; - uint32_t tflc; - uint32_t tbnd; -} sng_mtp3_link_t; - -typedef struct sng_link_set { - char name[MAX_NAME_LEN]; - uint32_t flags; - uint32_t id; - uint32_t apc; - uint32_t linkType; - uint32_t switchType; - uint32_t ssf; - uint32_t minActive; - uint32_t numLinks; - uint32_t links[16]; -} sng_link_set_t; - -typedef struct sng_link_set_list { - uint32_t lsId; - struct sng_link_set_list *next; -} sng_link_set_list_t; - -typedef struct sng_route { - char name[MAX_NAME_LEN]; - uint32_t flags; - uint32_t id; - uint32_t dpc; - uint32_t cmbLinkSetId; - struct sng_link_set_list lnkSets; - uint32_t linkType; - uint32_t switchType; - uint32_t ssf; - uint32_t nwId; - uint32_t isSTP; - uint32_t dir; - uint32_t t6; - uint32_t t8; - uint32_t t10; - uint32_t t11; - uint32_t t15; - uint32_t t16; - uint32_t t18; - uint32_t t19; - uint32_t t21; - uint32_t t25; - uint32_t t26; -} sng_route_t; - -typedef struct sng_isup_intf { - char name[MAX_NAME_LEN]; - uint32_t options; - uint32_t flags; - uint32_t id; - uint32_t spc; - uint32_t dpc; - uint32_t switchType; - uint32_t nwId; - uint32_t mtpRouteId; - uint32_t ssf; - uint32_t isap; - uint16_t t4; - uint32_t t11; - uint32_t t18; - uint32_t t19; - uint32_t t20; - uint32_t t21; - uint32_t t22; - uint32_t t23; - uint32_t t24; - uint32_t t25; - uint32_t t26; - uint32_t t28; - uint32_t t29; - uint32_t t30; - uint32_t t32; - uint32_t t37; - uint32_t t38; - uint32_t t39; - uint32_t tfgr; - uint32_t tpause; - uint32_t tstaenq; -} sng_isup_inf_t; - -typedef struct sng_isup_ckt { - uint32_t options; - uint32_t flags; - uint32_t procId; - uint32_t id; - uint32_t ccSpanId; - uint32_t span; - uint32_t chan; - uint32_t type; /* VOICE/SIG/HOLE */ - uint32_t cic; - uint32_t infId; - uint32_t typeCntrl; - uint32_t ssf; - uint32_t switchType; - - uint32_t clg_nadi; - uint32_t cld_nadi; - uint8_t rdnis_nadi; - uint32_t loc_nadi; - - /* Generic Number defaults */ - uint8_t gn_nmbqual; /* Number Qualifier */ - uint8_t gn_nadi; /* Nature of Address indicator */ - uint8_t gn_screen_ind; /* Screening Indicator */ - uint8_t gn_pres_ind; /* Presentation Indicator */ - uint8_t gn_npi; /* Numbering Plan Indicator */ - uint8_t gn_num_inc_ind; /* Number Incomplete Indicator */ - /* END - Generic Number defaults */ - - uint32_t min_digits; - uint32_t transparent_iam_max_size; - uint8_t transparent_iam; - uint8_t cpg_on_progress_media; - uint8_t cpg_on_progress; - uint8_t itx_auto_reply; - void *obj; - uint16_t t3; - uint32_t t10; - uint16_t t12; - uint16_t t13; - uint16_t t14; - uint16_t t15; - uint16_t t16; - uint16_t t17; - uint32_t t35; - uint32_t t39; - uint16_t tval; -} sng_isup_ckt_t; - -typedef struct sng_nsap { - uint32_t flags; - uint32_t id; - uint32_t suId; - uint32_t spId; - uint32_t nwId; - uint32_t linkType; - uint32_t switchType; - uint32_t ssf; -} sng_nsap_t; - -typedef struct sng_isap { - uint32_t id; - uint32_t suId; - uint32_t spId; - uint32_t switchType; - uint32_t ssf; - uint32_t flags; - uint32_t t1; - uint32_t t2; - uint32_t t5; - uint32_t t6; - uint32_t t7; - uint32_t t8; - uint32_t t9; - uint32_t t27; - uint32_t t31; - uint32_t t33; - uint32_t t34; - uint32_t t36; - uint32_t tccr; - uint32_t tccrt; - uint32_t tex; - uint32_t tcrm; - uint32_t tcra; - uint32_t tect; - uint32_t trelrsp; - uint32_t tfnlrelrsp; -} sng_isap_t; - -typedef struct sng_relay { - uint32_t id; - char name[MAX_NAME_LEN]; - uint32_t flags; - uint32_t type; - uint32_t port; - char hostname[RY_REMHOSTNAME_SIZE]; - uint32_t procId; -} sng_relay_t; - -/********************************************** -sctp structures and data definitions -**********************************************/ - -typedef struct sng_sctp_gen_cfg { -} sng_sctp_gen_cfg_t; - -typedef struct sng_sctp_link { - char name[MAX_NAME_LEN]; - uint32_t flags; - uint32_t id; - uint32_t port; - uint32_t numSrcAddr; - uint32_t srcAddrList[SCT_MAX_NET_ADDRS+1]; -} sng_sctp_link_t; - -typedef struct sng_sctp_cfg { - sng_sctp_gen_cfg_t genCfg; - sng_sctp_link_t linkCfg[MAX_SCTP_LINK+1]; -} sng_sctp_cfg_t; - - - -typedef struct sng_ss7_cfg { - uint32_t spc; - uint32_t procId; - char license[MAX_SNGSS7_PATH]; - char signature[MAX_SNGSS7_PATH]; - uint32_t transparent_iam_max_size; - uint32_t flags; - sng_relay_t relay[MAX_RELAY_CHANNELS+1]; - sng_mtp1_link_t mtp1Link[MAX_MTP_LINKS+1]; - sng_mtp2_link_t mtp2Link[MAX_MTP_LINKS+1]; - sng_mtp3_link_t mtp3Link[MAX_MTP_LINKS+1]; - sng_link_set_t mtpLinkSet[MAX_MTP_LINKSETS+1]; - sng_route_t mtpRoute[MAX_MTP_ROUTES+1]; - sng_isup_inf_t isupIntf[MAX_ISUP_INFS+1]; - sng_isup_ckt_t isupCkt[10000]; /* KONRAD - only need 2000 ( and 0-1000 aren't used) since other servers are registerd else where */ - sng_nsap_t nsap[MAX_NSAPS+1]; - sng_isap_t isap[MAX_ISAPS+1]; - sng_glare_resolution glareResolution; - uint32_t force_inr; - sng_m2ua_gbl_cfg_t g_m2ua_cfg; - sng_sctp_cfg_t sctpCfg; -} sng_ss7_cfg_t; - -typedef struct ftdm_sngss7_data { - sng_ss7_cfg_t cfg; - int gen_config; - int function_trace; - int function_trace_level; - int message_trace; - int message_trace_level; - fio_signal_cb_t sig_cb; -} ftdm_sngss7_data_t; - -typedef enum{ - SNG_SS7_OPR_MODE_NONE, - SNG_SS7_OPR_MODE_M2UA_SG, - SNG_SS7_OPR_MODE_ISUP, -}ftdm_sngss7_operating_modes_e; - -typedef ftdm_sngss7_operating_modes_e ftdm_sngss7_opr_mode; - -typedef struct sngss7_timer_data { - ftdm_timer_id_t hb_timer_id; - int beat; - int counter; - ftdm_sched_callback_t callback; - ftdm_sched_t *sched; - void *sngss7_info; -} sngss7_timer_data_t; - -typedef struct sngss7_glare_data { - uint32_t spInstId; - uint32_t circuit; - SiConEvnt iam; -} sngss7_glare_data_t; - -typedef struct sngss7_group_data { - uint32_t circuit; - uint32_t range; - uint8_t status[255]; - uint8_t type; - uint8_t cause; -} sngss7_group_data_t; - -typedef struct sngss7_chan_data { - ftdm_channel_t *ftdmchan; - sng_isup_ckt_t *circuit; - uint32_t base_chan; - uint32_t suInstId; - uint32_t spInstId; - uint32_t spId; - uint8_t globalFlg; - uint32_t ckt_flags; - uint32_t blk_flags; - ftdm_hash_t* variables; /* send on next sigevent */ - ftdm_size_t raw_data_len; - void *raw_data; /* send on next sigevent */ - sngss7_glare_data_t glare; - sngss7_timer_data_t t35; - sngss7_timer_data_t t10; - sngss7_timer_data_t t39; - sngss7_group_data_t rx_grs; - sngss7_group_data_t rx_gra; - sngss7_group_data_t tx_grs; - sngss7_group_data_t ucic; - ftdm_queue_t *event_queue; - struct sngss7_chan_data *peer_data; - uint8_t peer_event_transfer_cnt; -} sngss7_chan_data_t; - -#define SNGSS7_RX_GRS_PENDING (1 << 0) -#define SNGSS7_UCIC_PENDING (1 << 1) -#define SNGSS7_RX_GRA_PENDING (1 << 2) -typedef struct sngss7_span_data { - ftdm_sched_t *sched; - uint32_t flags; - sngss7_group_data_t rx_cgb; - sngss7_group_data_t tx_cgb; - sngss7_group_data_t rx_cgu; - sngss7_group_data_t tx_cgu; - ftdm_queue_t *event_queue; -} sngss7_span_data_t; - -typedef struct sngss7_event_data -{ - uint32_t event_id; - uint32_t spId; - uint32_t suId; - uint32_t spInstId; - uint32_t suInstId; - uint32_t circuit; - uint8_t globalFlg; - uint8_t evntType; - union - { - SiConEvnt siConEvnt; - SiCnStEvnt siCnStEvnt; - SiRelEvnt siRelEvnt; - SiInfoEvnt siInfoEvnt; - SiFacEvnt siFacEvnt; - SiStaEvnt siStaEvnt; - SiSuspEvnt siSuspEvnt; - SiResmEvnt siResmEvnt; - } event; -} sngss7_event_data_t; - - -typedef enum { - FLAG_RESET_RX = (1 << 0), - FLAG_RESET_TX = (1 << 1), - FLAG_RESET_SENT = (1 << 2), - FLAG_RESET_TX_RSP = (1 << 3), - FLAG_GRP_RESET_RX = (1 << 4), - FLAG_GRP_RESET_RX_DN = (1 << 5), - FLAG_GRP_RESET_RX_CMPLT = (1 << 6), - FLAG_GRP_RESET_BASE = (1 << 7), - FLAG_GRP_RESET_TX = (1 << 8), - FLAG_GRP_RESET_SENT = (1 << 9), - FLAG_GRP_RESET_TX_RSP = (1 << 10), - FLAG_REMOTE_REL = (1 << 11), - FLAG_LOCAL_REL = (1 << 12), - FLAG_GLARE = (1 << 13), - FLAG_INFID_RESUME = (1 << 14), - FLAG_INFID_PAUSED = (1 << 15), - FLAG_SENT_ACM = (1 << 16), - FLAG_SENT_CPG = (1 << 17), - FLAG_SUS_RECVD = (1 << 18), - FLAG_T6_CANCELED = (1 << 19), - FLAG_INR_TX = (1 << 20), - FLAG_INR_SENT = (1 << 21), - FLAG_INR_RX = (1 << 22), - FLAG_INR_RX_DN = (1 << 23), - FLAG_INF_TX = (1 << 24), - FLAG_INF_SENT = (1 << 25), - FLAG_INF_RX = (1 << 26), - FLAG_INF_RX_DN = (1 << 27), - FLAG_FULL_NUMBER = (1 << 28), - FLAG_RELAY_DOWN = (1 << 30), - FLAG_CKT_RECONFIG = (1 << 31) -} sng_ckt_flag_t; - -#define CKT_FLAGS_STRING \ - "RX_RSC", \ - "TX_RSC", \ - "TX_RSC_REQ_SENT", \ - "TX_RSC_RSP_RECEIVED", \ - "RX_GRS", \ - "RX_GRS_DONE", \ - "RX_GRS_CMPLT", \ - "GRS_BASE", \ - "TX_GRS", \ - "TX_GRS_REQ_SENT", \ - "TX_GRS_RSP_RECEIVED", \ - "REMOTE_REL", \ - "LOCAL_REL", \ - "GLARE", \ - "INF_RESUME", \ - "INF_PAUSED", \ - "TX_ACM_SENT" \ - "TX_INR" \ - "INR_SENT" \ - "RX_INR" \ - "RX_INR_DN" \ - "TX_INF" \ - "INF SENT" \ - "RX_INF" \ - "RX_INF_DN" \ - "RELAY_DOWN", \ - "CKT_RECONFIG" -FTDM_STR2ENUM_P(ftmod_ss7_ckt_state2flag, ftmod_ss7_ckt_flag2str, sng_ckt_flag_t) - -/* ckt blocking flags */ -typedef enum { - FLAG_CKT_UCIC_BLOCK = (1 << 0), - FLAG_CKT_UCIC_BLOCK_DN = (1 << 1), - FLAG_CKT_UCIC_UNBLK = (1 << 2), - FLAG_CKT_UCIC_UNBLK_DN = (1 << 3), - FLAG_CKT_LC_BLOCK_RX = (1 << 4), - FLAG_CKT_LC_BLOCK_RX_DN = (1 << 5), - FLAG_CKT_LC_UNBLK_RX = (1 << 6), - FLAG_CKT_LC_UNBLK_RX_DN = (1 << 7), - FLAG_CKT_MN_BLOCK_RX = (1 << 8), - FLAG_CKT_MN_BLOCK_RX_DN = (1 << 9), - FLAG_CKT_MN_UNBLK_RX = (1 << 10), - FLAG_CKT_MN_UNBLK_RX_DN = (1 << 11), - FLAG_CKT_MN_BLOCK_TX = (1 << 12), - FLAG_CKT_MN_BLOCK_TX_DN = (1 << 13), - FLAG_CKT_MN_UNBLK_TX = (1 << 14), - FLAG_CKT_MN_UNBLK_TX_DN = (1 << 15), - FLAG_GRP_HW_BLOCK_RX = (1 << 16), - FLAG_GRP_HW_BLOCK_RX_DN = (1 << 17), - FLAG_GRP_HW_BLOCK_TX = (1 << 18), - FLAG_GRP_HW_BLOCK_TX_DN = (1 << 19), - FLAG_GRP_MN_BLOCK_RX = (1 << 20), - FLAG_GRP_MN_BLOCK_RX_DN = (1 << 21), - FLAG_GRP_MN_BLOCK_TX = (1 << 22), - FLAG_GRP_MN_BLOCK_TX_DN = (1 << 23), - FLAG_GRP_HW_UNBLK_TX = (1 << 24), - FLAG_GRP_HW_UNBLK_TX_DN = (1 << 25), - FLAG_GRP_MN_UNBLK_TX = (1 << 26), - FLAG_GRP_MN_UNBLK_TX_DN = (1 << 27), -} sng_ckt_block_flag_t; - -#define BLK_FLAGS_STRING \ - "UCIC BLK", \ - "UCIC BLK DN", \ - "UCIC UNBLK", \ - "UCIC UNBLK DN", \ - "RX LC BLK", \ - "RX LC BLK DN", \ - "RX LC UNBLK", \ - "RX LC UNBLK DN", \ - "RX CKT BLK", \ - "RX CKT BLK DN", \ - "RX CKT UNBLK", \ - "RX CKT UNBLK DN", \ - "TX CKT BLK", \ - "TX CKT BLK DN", \ - "TX CKT UNBLK", \ - "TX CKT UNBLK DN", \ - "RX GRP HW BLK", \ - "RX GRP HW BLK DN", \ - "TX GRP HW BLK", \ - "TX GRP HW BLK DN", \ - "RX GRP MN BLK", \ - "RX GRP MN BLK DN", \ - "TX GRP MN BLK", \ - "TX GRP MN BLK DN", \ - "TX GRP HW UNBLK", \ - "TX GRP HW UNBLK DN", \ - "TX GRP MN UNBLK", \ - "TX GRP MN UNBLK DN", \ - "RX GRP HW UNBLK", \ - "RX GRP HW UNBLK DN" -FTDM_STR2ENUM_P(ftmod_ss7_blk_state2flag, ftmod_ss7_blk_flag2str, sng_ckt_block_flag_t) - -/* valid for every cfg array except circuits */ -typedef enum { - SNGSS7_CONFIGURED = (1 << 0), - SNGSS7_ACTIVE = (1 << 1), - SNGSS7_RELAY_INIT = (1 << 3), - SNGSS7_PAUSED = (1 << 7) /* for isup interfaces */ -} sng_cfg_flag_t; - -typedef enum { - SNGSS7_SM_STARTED = (1 << 0), - - SNGSS7_RY_PRESENT = (1 << 2), - SNGSS7_RY_STARTED = (1 << 3), - - SNGSS7_MTP1_PRESENT = (1 << 4), - SNGSS7_MTP1_STARTED = (1 << 5), - - SNGSS7_MTP2_PRESENT = (1 << 6), - SNGSS7_MTP2_STARTED = (1 << 7), - - SNGSS7_MTP3_PRESENT = (1 << 8), - SNGSS7_MTP3_STARTED = (1 << 9), - - SNGSS7_ISUP_PRESENT = (1 << 10), - SNGSS7_ISUP_STARTED = (1 << 11), - - SNGSS7_CC_PRESENT = (1 << 12), - SNGSS7_CC_STARTED = (1 << 13), - - SNGSS7_TUCL_PRESENT = (1 << 14), - SNGSS7_TUCL_STARTED = (1 << 15), - - SNGSS7_SCTP_PRESENT = (1 << 16), - SNGSS7_SCTP_STARTED = (1 << 17), - - SNGSS7_M2UA_PRESENT = (1 << 18), - SNGSS7_M2UA_STARTED = (1 << 19), - SNGSS7_M2UA_EP_OPENED = (1 << 20), - SNGSS7_M2UA_INIT_ASSOC_DONE = (1 << 21), - - SNGSS7_NIF_PRESENT = (1 << 22), - SNGSS7_NIF_STARTED = (1 << 23), - -} sng_task_flag_t; -/******************************************************************************/ - -/* GLOBALS ********************************************************************/ -extern ftdm_sngss7_data_t g_ftdm_sngss7_data; -extern ftdm_sngss7_opr_mode g_ftdm_operating_mode; -extern sng_ssf_type_t sng_ssf_type_map[]; -extern sng_switch_type_t sng_switch_type_map[]; -extern sng_link_type_t sng_link_type_map[]; -extern sng_mtp2_error_type_t sng_mtp2_error_type_map[]; -extern sng_cic_cntrl_type_t sng_cic_cntrl_type_map[]; -extern uint32_t sngss7_id; -extern ftdm_sched_t *sngss7_sched; -extern int cmbLinkSetId; -/******************************************************************************/ - -/* PROTOTYPES *****************************************************************/ -/* in ftmod_sangoma_ss7_main.c */ -ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t *ftdmchan); - -/* in ftmod_sangoma_ss7_logger.c */ -void handle_sng_log(uint8_t level, char *fmt,...); -void handle_sng_mtp1_alarm(Pst *pst, L1Mngmt *sta); -void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta); -void handle_sng_mtp3_alarm(Pst *pst, SnMngmt *sta); -void handle_sng_isup_alarm(Pst *pst, SiMngmt *sta); -void handle_sng_cc_alarm(Pst *pst, CcMngmt *sta); -void handle_sng_relay_alarm(Pst *pst, RyMngmt *sta); -void handle_sng_m2ua_alarm(Pst *pst, MwMgmt *sta); -void handle_sng_nif_alarm(Pst *pst, NwMgmt *sta); -void handle_sng_tucl_alarm(Pst *pst, HiMngmt *sta); -void handle_sng_sctp_alarm(Pst *pst, SbMgmt *sta); - -/* in ftmod_sangoma_ss7_relay.c */ -ftdm_status_t handle_relay_connect(RyMngmt *sta); -ftdm_status_t handle_relay_disconnect_on_down(RyMngmt *sta); -ftdm_status_t handle_relay_disconnect_on_error(RyMngmt *sta); - -/* in ftmod_sangoma_ss7_cfg.c */ -int ft_to_sngss7_cfg_all(void); -int ftmod_ss7_mtp1_gen_config(void); -int ftmod_ss7_mtp2_gen_config(void); -int ftmod_ss7_mtp3_gen_config(void); -int ftmod_ss7_isup_gen_config(void); -int ftmod_ss7_cc_gen_config(void); -int ftmod_ss7_mtp1_psap_config(int id); -int ftmod_ss7_mtp2_dlsap_config(int id); -int ftmod_ss7_mtp3_dlsap_config(int id); -int ftmod_ss7_mtp3_nsap_config(int id); -int ftmod_ss7_mtp3_linkset_config(int id); -int ftmod_ss7_mtp3_route_config(int id); -int ftmod_ss7_isup_nsap_config(int id); -int ftmod_ss7_isup_intf_config(int id); -int ftmod_ss7_isup_ckt_config(int id); -int ftmod_ss7_isup_isap_config(int id); -int ftmod_ss7_cc_isap_config(int id); - -/* in ftmod_sangoma_ss7_cntrl.c */ -int ft_to_sngss7_activate_all(void); - -int ftmod_ss7_inhibit_mtp3link(uint32_t id); -int ftmod_ss7_uninhibit_mtp3link(uint32_t id); -int ftmod_ss7_bind_mtp3link(uint32_t id); -int ftmod_ss7_unbind_mtp3link(uint32_t id); -int ftmod_ss7_activate_mtp3link(uint32_t id); -int ftmod_ss7_deactivate_mtp3link(uint32_t id); -int ftmod_ss7_deactivate2_mtp3link(uint32_t id); -int ftmod_ss7_activate_mtplinkSet(uint32_t id); -int ftmod_ss7_deactivate_mtplinkSet(uint32_t id); -int ftmod_ss7_deactivate2_mtplinkSet(uint32_t id); -int ftmod_ss7_lpo_mtp3link(uint32_t id); -int ftmod_ss7_lpr_mtp3link(uint32_t id); - -int ftmod_ss7_shutdown_isup(void); -int ftmod_ss7_shutdown_mtp3(void); -int ftmod_ss7_shutdown_mtp2(void); -int ftmod_ss7_shutdown_relay(void); -int ftmod_ss7_disable_relay_channel(uint32_t chanId); - -int ftmod_ss7_disable_grp_mtp3Link(uint32_t procId); -int ftmod_ss7_enable_grp_mtp3Link(uint32_t procId); - -int ftmod_ss7_disable_grp_mtp2Link(uint32_t procId); - -#define ftmod_ss7_block_isup_ckt(x) __ftmod_ss7_block_isup_ckt(x,FTDM_TRUE) -#define ftmod_ss7_block_isup_ckt_nowait(x) __ftmod_ss7_block_isup_ckt(x,FTDM_FALSE) -int __ftmod_ss7_block_isup_ckt(uint32_t cktId, ftdm_bool_t wait); -int ftmod_ss7_unblock_isup_ckt(uint32_t cktId); - - -/* in ftmod_sangoma_ss7_sta.c */ -int ftmod_ss7_mtp1link_sta(uint32_t id, L1Mngmt *cfm); -int ftmod_ss7_mtp2link_sta(uint32_t id, SdMngmt *cfm); -int ftmod_ss7_mtp3link_sta(uint32_t id, SnMngmt *cfm); -int ftmod_ss7_mtplinkSet_sta(uint32_t id, SnMngmt *cfm); -int ftmod_ss7_isup_intf_sta(uint32_t id, uint8_t *status); -int ftmod_ss7_relay_status(uint32_t id, RyMngmt *cfm); -int ftmod_ss7_isup_ckt_sta(uint32_t id, unsigned char *state); - - -/* in ftmod_sangoma_ss7_out.c */ -void ft_to_sngss7_iam(ftdm_channel_t *ftdmchan); -void ft_to_sngss7_acm(ftdm_channel_t *ftdmchan); -void ft_to_sngss7_cpg (ftdm_channel_t *ftdmchan); -void ft_to_sngss7_anm(ftdm_channel_t *ftdmchan); -void ft_to_sngss7_rel(ftdm_channel_t *ftdmchan); -void ft_to_sngss7_rlc(ftdm_channel_t *ftdmchan); -void ft_to_sngss7_rsc(ftdm_channel_t *ftdmchan); -void ft_to_sngss7_rsca(ftdm_channel_t *ftdmchan); -void ft_to_sngss7_blo(ftdm_channel_t *ftdmchan); -void ft_to_sngss7_bla(ftdm_channel_t *ftdmchan); -void ft_to_sngss7_ubl(ftdm_channel_t *ftdmchan); -void ft_to_sngss7_uba(ftdm_channel_t *ftdmchan); -void ft_to_sngss7_lpa(ftdm_channel_t *ftdmchan); -void ft_to_sngss7_gra(ftdm_channel_t *ftdmchan); -void ft_to_sngss7_grs(ftdm_channel_t *ftdmchan); -void ft_to_sngss7_cgba(ftdm_channel_t * ftdmchan); -void ft_to_sngss7_cgua(ftdm_channel_t * ftdmchan); -void ft_to_sngss7_cgb(ftdm_channel_t * ftdmchan); -void ft_to_sngss7_cgu(ftdm_channel_t * ftdmchan); -void ft_to_sngss7_itx (ftdm_channel_t * ftdmchan); -void ft_to_sngss7_txa (ftdm_channel_t * ftdmchan); -void ft_to_sngss7_inr(ftdm_channel_t * ftdmchan); -void ft_to_sngss7_inf(ftdm_channel_t *ftdmchan, SiCnStEvnt *inr); - - - -/* in ftmod_sangoma_ss7_in.c */ -void sngss7_sta_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -void sngss7_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiConEvnt *siConEvnt); -void sngss7_con_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiConEvnt *siConEvnt); -void sngss7_con_sta(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiCnStEvnt *siCnStEvnt, uint8_t evntType); -void sngss7_rel_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiRelEvnt *siRelEvnt); -void sngss7_rel_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiRelEvnt *siRelEvnt); -void sngss7_dat_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiInfoEvnt *siInfoEvnt); -void sngss7_fac_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t evntType, SiFacEvnt *siFacEvnt); -void sngss7_fac_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t evntType, SiFacEvnt *siFacEvnt); -void sngss7_sta_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -void sngss7_umsg_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit); -void sngss7_resm_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiResmEvnt *siResmEvnt); -void sngss7_susp_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiSuspEvnt *siSuspEvnt); -void sngss7_ssp_sta_cfm(uint32_t infId); - -ftdm_status_t sngss7_bufferzero_iam(SiConEvnt *siConEvnt); -ftdm_status_t sngss7_retrieve_iam(ftdm_channel_t *ftdmchan, SiConEvnt *siConEvnt); -ftdm_status_t sngss7_save_iam(ftdm_channel_t *ftdmchan, SiConEvnt *siConEvnt); - -/* in ftmod_sangoma_ss7_handle.c */ -ftdm_status_t handle_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiConEvnt *siConEvnt); -ftdm_status_t handle_con_sta(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiCnStEvnt *siCnStEvnt, uint8_t evntType); -ftdm_status_t handle_con_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiConEvnt *siConEvnt); -ftdm_status_t handle_rel_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiRelEvnt *siRelEvnt); -ftdm_status_t handle_rel_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiRelEvnt *siRelEvnt); -ftdm_status_t handle_dat_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiInfoEvnt *siInfoEvnt); -ftdm_status_t handle_fac_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t evntType, SiFacEvnt *siFacEvnt); -ftdm_status_t handle_fac_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t evntType, SiFacEvnt *siFacEvnt); -ftdm_status_t handle_umsg_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit); -ftdm_status_t handle_susp_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiSuspEvnt *siSuspEvnt); -ftdm_status_t handle_resm_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiResmEvnt *siResmEvnt); -ftdm_status_t handle_sta_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); - -ftdm_status_t handle_reattempt(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -ftdm_status_t handle_pause(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -ftdm_status_t handle_resume(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -ftdm_status_t handle_cot_start(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -ftdm_status_t handle_cot_stop(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -ftdm_status_t handle_cot(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -ftdm_status_t handle_rsc_req(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -ftdm_status_t handle_local_rsc_req(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -ftdm_status_t handle_rsc_rsp(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -ftdm_status_t handle_grs_req(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -ftdm_status_t handle_grs_rsp(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -ftdm_status_t handle_blo_req(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -ftdm_status_t handle_blo_rsp(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -ftdm_status_t handle_ubl_req(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -ftdm_status_t handle_ubl_rsp(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -ftdm_status_t handle_local_blk(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -ftdm_status_t handle_local_ubl(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); -ftdm_status_t handle_ucic(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt); - -/* in ftmod_sangoma_ss7_xml.c */ -int ftmod_ss7_parse_xml(ftdm_conf_parameter_t *ftdm_parameters, ftdm_span_t *span); - -/* in ftmod_sangoma_ss7_cli.c */ -ftdm_status_t ftdm_sngss7_handle_cli_cmd(ftdm_stream_handle_t *stream, const char *data); - -/* in ftmod_sangoma_ss7_support.c */ -ftdm_status_t copy_cgPtyNum_from_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyNum *cgPtyNum); -ftdm_status_t copy_cgPtyNum_to_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyNum *cgPtyNum); -ftdm_status_t copy_cdPtyNum_from_sngss7(ftdm_channel_t *ftdmchan, SiCdPtyNum *cdPtyNum); -ftdm_status_t copy_cdPtyNum_to_sngss7(ftdm_channel_t *ftdmchan, SiCdPtyNum *cdPtyNum); -ftdm_status_t copy_redirgNum_to_sngss7(ftdm_channel_t *ftdmchan, SiRedirNum *redirgNum); -ftdm_status_t copy_redirgNum_from_sngss7(ftdm_channel_t *ftdmchan, SiRedirNum *redirgNum); -ftdm_status_t copy_redirgInfo_from_sngss7(ftdm_channel_t *ftdmchan, SiRedirInfo *redirInfo); -ftdm_status_t copy_redirgInfo_to_sngss7(ftdm_channel_t *ftdmchan, SiRedirInfo *redirInfo); -ftdm_status_t copy_ocn_to_sngss7(ftdm_channel_t *ftdmchan, SiOrigCdNum *origCdNum); -ftdm_status_t copy_ocn_from_sngss7(ftdm_channel_t *ftdmchan, SiOrigCdNum *origCdNum); - -ftdm_status_t copy_access_transport_from_sngss7(ftdm_channel_t *ftdmchan, SiAccTrnspt *accTrnspt); -ftdm_status_t copy_access_transport_to_sngss7(ftdm_channel_t *ftdmchan, SiAccTrnspt *accTrnspt); -ftdm_status_t copy_locPtyNum_to_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyNum *locPtyNum); -ftdm_status_t copy_locPtyNum_from_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyNum *locPtyNum); -ftdm_status_t copy_genNmb_to_sngss7(ftdm_channel_t *ftdmchan, SiGenNum *genNmb); -ftdm_status_t copy_genNmb_from_sngss7(ftdm_channel_t *ftdmchan, SiGenNum *genNmb); -ftdm_status_t copy_cgPtyCat_to_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyCat *cgPtyCat); -ftdm_status_t copy_cgPtyCat_from_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyCat *cgPtyCat); -ftdm_status_t copy_accTrnspt_to_sngss7(ftdm_channel_t *ftdmchan, SiAccTrnspt *accTrnspt); -ftdm_status_t copy_natConInd_to_sngss7(ftdm_channel_t *ftdmchan, SiNatConInd *natConInd); -ftdm_status_t copy_fwdCallInd_hex_from_sngss7(ftdm_channel_t *ftdmchan, SiFwdCallInd *fwdCallInd); -ftdm_status_t copy_fwdCallInd_to_sngss7(ftdm_channel_t *ftdmchan, SiFwdCallInd *fwdCallInd); -ftdm_status_t copy_txMedReq_to_sngss7(ftdm_channel_t *ftdmchan, SiTxMedReq *txMedReq); -ftdm_status_t copy_usrServInfoA_to_sngss7(ftdm_channel_t *ftdmchan, SiUsrServInfo *usrServInfoA); -ftdm_status_t copy_NatureOfConnection_from_sngss7(ftdm_channel_t *ftdmchan, SiNatConInd *natConInd ); -ftdm_status_t copy_NatureOfConnection_to_sngss7(ftdm_channel_t *ftdmchan, SiNatConInd *natConInd); - -ftdm_status_t copy_tknStr_from_sngss7(TknStr str, char *ftdm, TknU8 oddEven); -ftdm_status_t append_tknStr_from_sngss7(TknStr str, char *ftdm, TknU8 oddEven); -ftdm_status_t copy_tknStr_to_sngss7(char* str, TknStr *tknStr, TknU8 *oddEven); - -int check_for_state_change(ftdm_channel_t *ftdmchan); -int check_for_reset(sngss7_chan_data_t *sngss7_info); -ftdm_status_t extract_chan_data(uint32_t circuit, sngss7_chan_data_t **sngss7_info, ftdm_channel_t **ftdmchan); -unsigned long get_unique_id(void); - -ftdm_status_t check_if_rx_grs_started(ftdm_span_t *ftdmspan); -ftdm_status_t check_if_rx_grs_processed(ftdm_span_t *ftdmspan); -ftdm_status_t check_if_rx_gra_started(ftdm_span_t *ftdmspan); -ftdm_status_t check_for_res_sus_flag(ftdm_span_t *ftdmspan); - -ftdm_status_t process_span_ucic(ftdm_span_t *ftdmspan); - -ftdm_status_t clear_rx_grs_flags(sngss7_chan_data_t *sngss7_info); -ftdm_status_t clear_tx_grs_flags(sngss7_chan_data_t *sngss7_info); -ftdm_status_t clear_rx_rsc_flags(sngss7_chan_data_t *sngss7_info); -ftdm_status_t clear_tx_rsc_flags(sngss7_chan_data_t *sngss7_info); -ftdm_status_t clear_rx_grs_data(sngss7_chan_data_t *sngss7_info); -ftdm_status_t clear_rx_gra_data(sngss7_chan_data_t *sngss7_info); -ftdm_status_t clear_tx_grs_data(sngss7_chan_data_t *sngss7_info); - -ftdm_status_t encode_subAddrIE_nsap(const char *subAddr, char *subAddrIE, int type); -ftdm_status_t encode_subAddrIE_nat(const char *subAddr, char *subAddrIE, int type); - -int find_mtp2_error_type_in_map(const char *err_type); -int find_link_type_in_map(const char *linkType); -int find_switch_type_in_map(const char *switchType); -int find_ssf_type_in_map(const char *ssfType); -int find_cic_cntrl_in_map(const char *cntrlType); - -ftdm_status_t check_status_of_all_isup_intf(void); -ftdm_status_t check_for_reconfig_flag(ftdm_span_t *ftdmspan); - -void sngss7_send_signal(sngss7_chan_data_t *sngss7_info, ftdm_signal_event_t event_id); -void sngss7_set_sig_status(sngss7_chan_data_t *sngss7_info, ftdm_signaling_status_t status); -ftdm_status_t sngss7_add_var(sngss7_chan_data_t *ss7_info, const char* var, const char* val); -ftdm_status_t sngss7_add_raw_data(sngss7_chan_data_t *sngss7_info, uint8_t* data, ftdm_size_t data_len); - -/* in ftmod_sangoma_ss7_timers.c */ -void handle_isup_t35(void *userdata); -void handle_isup_t10(void *userdata); -void handle_isup_t39(void *userdata); - - -/******************************************************************************/ - -/* MACROS *********************************************************************/ -#define SS7_STATE_CHANGE(ftdmchan, new_state) \ -if (ftdmchan->state == new_state) { \ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_IDLE); \ -} else { \ - ftdm_set_state(ftdmchan, new_state); \ -} - -#define SS7_DEBUG(a,...) ftdm_log(FTDM_LOG_DEBUG,a , ##__VA_ARGS__ ); -#define SS7_INFO(a,...) ftdm_log(FTDM_LOG_INFO,a , ##__VA_ARGS__ ); -#define SS7_WARN(a,...) ftdm_log(FTDM_LOG_WARNING,a , ##__VA_ARGS__ ); -#define SS7_ERROR(a,...) ftdm_log(FTDM_LOG_ERROR,a , ##__VA_ARGS__ ); -#define SS7_CRITICAL(a,...) ftdm_log(FTDM_LOG_CRIT,a , ##__VA_ARGS__ ); - -#define SS7_DEBUG_CHAN(fchan, msg, args...) ftdm_log_chan(fchan, FTDM_LOG_DEBUG, msg , ##args) -#define SS7_INFO_CHAN(fchan, msg, args...) ftdm_log_chan(fchan, FTDM_LOG_INFO, msg , ##args) -#define SS7_WARN_CHAN(fchan, msg, args...) ftdm_log_chan(fchan, FTDM_LOG_WARNING, msg , ##args) -#define SS7_ERROR_CHAN(fchan, msg, args...) ftdm_log_chan(fchan, FTDM_LOG_ERROR, msg , ##args) -#define SS7_CRIT_CHAN(fchan, msg, args...) ftdm_log_chan(fchan, FTDM_LOG_CRIT, msg , ##args) - -#ifdef SS7_CODE_DEVEL -#define SS7_DEVEL_DEBUG(a,...) ftdm_log(FTDM_LOG_DEBUG,a,##__VA_ARGS__ ); -#else -#define SS7_DEVEL_DEBUG(a,...) -#endif - -#define SS7_FUNC_TRACE_ENTER(a) if (g_ftdm_sngss7_data.function_trace) { \ - switch (g_ftdm_sngss7_data.function_trace_level) { \ - case 0: \ - ftdm_log(FTDM_LOG_EMERG,"Entering %s\n", a); \ - break; \ - case 1: \ - ftdm_log(FTDM_LOG_ALERT,"Entering %s\n", a); \ - break; \ - case 2: \ - ftdm_log(FTDM_LOG_CRIT,"Entering %s\n", a); \ - break; \ - case 3: \ - ftdm_log(FTDM_LOG_ERROR,"Entering %s\n", a); \ - break; \ - case 4: \ - ftdm_log(FTDM_LOG_WARNING,"Entering %s\n", a); \ - break; \ - case 5: \ - ftdm_log(FTDM_LOG_NOTICE,"Entering %s\n", a); \ - break; \ - case 6: \ - ftdm_log(FTDM_LOG_INFO,"Entering %s\n", a); \ - break; \ - case 7: \ - ftdm_log(FTDM_LOG_DEBUG,"Entering %s\n", a); \ - break; \ - default: \ - ftdm_log(FTDM_LOG_INFO,"Entering %s\n", a); \ - break; \ - } /* switch (g_ftdm_sngss7_data.function_trace_level) */ \ - } /* if(g_ftdm_sngss7_data.function_trace) */ - -#define SS7_FUNC_TRACE_EXIT(a) if (g_ftdm_sngss7_data.function_trace) { \ - switch (g_ftdm_sngss7_data.function_trace_level) { \ - case 0: \ - ftdm_log(FTDM_LOG_EMERG,"Exiting %s\n", a); \ - break; \ - case 1: \ - ftdm_log(FTDM_LOG_ALERT,"Exiting %s\n", a); \ - break; \ - case 2: \ - ftdm_log(FTDM_LOG_CRIT,"Exiting %s\n", a); \ - break; \ - case 3: \ - ftdm_log(FTDM_LOG_ERROR,"Exiting %s\n", a); \ - break; \ - case 4: \ - ftdm_log(FTDM_LOG_WARNING,"Exiting %s\n", a); \ - break; \ - case 5: \ - ftdm_log(FTDM_LOG_NOTICE,"Exiting %s\n", a); \ - break; \ - case 6: \ - ftdm_log(FTDM_LOG_INFO,"Exiting %s\n", a); \ - break; \ - case 7: \ - ftdm_log(FTDM_LOG_DEBUG,"Exiting %s\n", a); \ - break; \ - default: \ - ftdm_log(FTDM_LOG_INFO,"Exiting %s\n", a); \ - break; \ - } /* switch (g_ftdm_sngss7_data.function_trace_level) */ \ - } /* if(g_ftdm_sngss7_data.function_trace) */ - -#define SS7_MSG_TRACE(fchan, sngss7info ,msg) if (g_ftdm_sngss7_data.message_trace) { \ - switch (g_ftdm_sngss7_data.message_trace_level) { \ - case 0: \ - ftdm_log_chan(fchan, FTDM_LOG_DEBUG, "[CIC:%d][SPINSTID:%d][SUINSTID:%d]%s", \ - sngss7info->circuit->cic,sngss7info->spInstId,sngss7info->suInstId, msg); \ - break; \ - case 1: \ - ftdm_log_chan(fchan, FTDM_LOG_ALERT, "[CIC:%d][SPINSTID:%d][SUINSTID:%d]%s", \ - sngss7info->circuit->cic,sngss7info->spInstId,sngss7info->suInstId, msg); \ - break; \ - case 2: \ - ftdm_log_chan(fchan, FTDM_LOG_CRIT, "[CIC:%d][SPINSTID:%d][SUINSTID:%d]%s", \ - sngss7info->circuit->cic,sngss7info->spInstId,sngss7info->suInstId, msg); \ - break; \ - case 3: \ - ftdm_log_chan(fchan, FTDM_LOG_ERROR, "[CIC:%d][SPINSTID:%d][SUINSTID:%d]%s", \ - sngss7info->circuit->cic,sngss7info->spInstId,sngss7info->suInstId, msg); \ - break; \ - case 4: \ - ftdm_log_chan(fchan, FTDM_LOG_WARNING, "[CIC:%d][SPINSTID:%d][SUINSTID:%d]%s", \ - sngss7info->circuit->cic,sngss7info->spInstId,sngss7info->suInstId, msg); \ - break; \ - case 5: \ - ftdm_log_chan(fchan, FTDM_LOG_NOTICE, "[CIC:%d][SPINSTID:%d][SUINSTID:%d]%s", \ - sngss7info->circuit->cic,sngss7info->spInstId,sngss7info->suInstId, msg); \ - break; \ - case 6: \ - ftdm_log_chan(fchan, FTDM_LOG_INFO, "[CIC:%d][SPINSTID:%d][SUINSTID:%d]%s", \ - sngss7info->circuit->cic,sngss7info->spInstId,sngss7info->suInstId, msg); \ - break; \ - case 7: \ - ftdm_log_chan(fchan, FTDM_LOG_DEBUG, "[CIC:%d][SPINSTID:%d][SUINSTID:%d]%s", \ - sngss7info->circuit->cic,sngss7info->spInstId,sngss7info->suInstId, msg); \ - break; \ - default: \ - ftdm_log_chan(fchan, FTDM_LOG_INFO, "[CIC:%d][SPINSTID:%d][SUINSTID:%d]%s", \ - sngss7info->circuit->cic,sngss7info->spInstId,sngss7info->suInstId, msg); \ - break; \ - } /* switch (g_ftdm_sngss7_data.message_trace_level) */ \ - } /* if(g_ftdm_sngss7_data.message_trace) */ - -#define sngss7_test_flag(obj, flag) ((obj)->flags & flag) -#define sngss7_clear_flag(obj, flag) ((obj)->flags &= ~(flag)) -#define sngss7_set_flag(obj, flag) ((obj)->flags |= (flag)) - -#define sngss7_test_ckt_flag(obj, flag) ((obj)->ckt_flags & flag) -#define sngss7_clear_ckt_flag(obj, flag) ((obj)->ckt_flags &= ~(flag)) -#define sngss7_set_ckt_flag(obj, flag) ((obj)->ckt_flags |= (flag)) - -#define sngss7_test_ckt_blk_flag(obj, flag) ((obj)->blk_flags & flag) -#define sngss7_clear_ckt_blk_flag(obj, flag) ((obj)->blk_flags &= ~(flag)) -#define sngss7_set_ckt_blk_flag(obj, flag) ((obj)->blk_flags |= (flag)) - -#define sngss7_test_options(obj, option) ((obj)->options & option) -#define sngss7_clear_options(obj, option) ((obj)->options &= ~(option)) -#define sngss7_set_options(obj, option) ((obj)->options |= (option)) - -#define sngss7_tx_block_status_clear(obj) (!sngss7_test_ckt_blk_flag(obj, (FLAG_CKT_MN_BLOCK_TX | \ - FLAG_CKT_MN_BLOCK_TX_DN | \ - FLAG_GRP_MN_BLOCK_TX | \ - FLAG_GRP_MN_BLOCK_TX_DN | \ - FLAG_GRP_HW_BLOCK_TX | \ - FLAG_GRP_HW_BLOCK_TX_DN | \ - FLAG_GRP_HW_UNBLK_TX | \ - FLAG_CKT_MN_UNBLK_TX ))) - -#define sngss7_block_status_clear(obj) (obj->blk_flags == 0) - -#define sngss7_reset_status_clear(obj) (!sngss7_test_ckt_flag(obj, (FLAG_RESET_TX | \ - FLAG_RESET_RX | \ - FLAG_GRP_RESET_TX | \ - FLAG_GRP_RESET_RX ))) - -#define sngss7_tx_reset_sent(obj) ((sngss7_test_ckt_flag(obj, (FLAG_RESET_TX)) && \ - sngss7_test_ckt_flag(obj, (FLAG_RESET_SENT))) || \ - (sngss7_test_ckt_flag(obj, (FLAG_GRP_RESET_TX)) && \ - sngss7_test_ckt_flag(obj, (FLAG_GRP_RESET_SENT)))) - -#define sngss7_tx_reset_status_pending(obj) (sngss7_test_ckt_flag(obj, (FLAG_RESET_TX)) || sngss7_test_ckt_flag(obj, (FLAG_GRP_RESET_TX))) - -#define sngss7_channel_status_clear(obj) ((sngss7_block_status_clear(obj)) && \ - (sngss7_reset_status_clear(obj)) && \ - (!sngss7_test_ckt_flag((obj),FLAG_INFID_PAUSED))) - -#define sngss7_tx_reset_restart(obj) do { clear_tx_grs_flags((obj)); \ - clear_tx_grs_data((obj)); \ - clear_tx_rsc_flags((obj)); \ - sngss7_set_ckt_flag((obj), (FLAG_RESET_TX)); \ - } while (0); - - - -#ifdef SMG_RELAY_DBG -#define SS7_RELAY_DBG(a,...) printf(a"\n", ##__VA_ARGS__) -#define SS7_RELAY_DBG_FUN(a) printf(#a"\n") -#else -#define SS7_RELAY_DBG(a, ...) -#define SS7_RELAY_DBG_FUN(a) -#endif -/******************************************************************************/ - -/******************************************************************************/ -#endif /* __FTMOD_SNG_SS7_H__ */ -/******************************************************************************/ - -/******************************************************************************/ -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ -/******************************************************************************/ diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c deleted file mode 100644 index 7c567ab6ea..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c +++ /dev/null @@ -1,1052 +0,0 @@ -/* - * Copyright (c) 2009, Konrad Hammel - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* INCLUDE ********************************************************************/ -#include "ftmod_sangoma_ss7_main.h" -/******************************************************************************/ - -/* DEFINES ********************************************************************/ -#define SNGSS7_EVNTINFO_IND_INBAND_AVAIL 0x03 -/******************************************************************************/ - -/* GLOBALS ********************************************************************/ - -/* FUNCTIONS ******************************************************************/ -void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan) -{ - const char *var = NULL; - SiConEvnt iam; - ftdm_bool_t native_going_up = FTDM_FALSE; - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;; - sngss7_event_data_t *event_clone = NULL; - - SS7_FUNC_TRACE_ENTER (__FTDM_FUNC__); - - sngss7_info->suInstId = get_unique_id (); - sngss7_info->spInstId = 0; - sngss7_info->spId = 1; - - memset (&iam, 0x0, sizeof (iam)); - - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_NATIVE_SIGBRIDGE)) { - ftdm_span_t *peer_span = NULL; - ftdm_channel_t *peer_chan = NULL; - sngss7_chan_data_t *peer_info = NULL; - - var = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "sigbridge_peer"); - ftdm_get_channel_from_string(var, &peer_span, &peer_chan); - if (!peer_chan) { - SS7_ERROR_CHAN(ftdmchan, "Failed to find sigbridge peer from string '%s'\n", var); - } else { - if (peer_span->signal_type != FTDM_SIGTYPE_SS7) { - SS7_ERROR_CHAN(ftdmchan, "Peer channel '%s' has different signaling type %d'\n", - var, peer_span->signal_type); - } else { - peer_info = peer_chan->call_data; - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Starting native bridge with peer CIC %d\n", - sngss7_info->circuit->cic, peer_info->circuit->cic); - - /* retrieve only first message from the others guys queue (must be IAM) */ - event_clone = ftdm_queue_dequeue(peer_info->event_queue); - - /* make each one of us aware of the native bridge */ - peer_info->peer_data = sngss7_info; - sngss7_info->peer_data = peer_info; - - /* Go to up until release comes, note that state processing is done different and much simpler when there is a peer, - We can't go to UP state right away yet though, so do not set the state to UP here, wait until the end of this function - because moving from one state to another causes the ftdmchan->usrmsg structure to be wiped - and we still need those variables for further IAM processing */ - native_going_up = FTDM_TRUE; - } - } - } - - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_NATIVE_SIGBRIDGE)) { - if (!event_clone) { - SS7_ERROR_CHAN(ftdmchan, "No IAM event clone in peer queue!%s\n", ""); - } else if (event_clone->event_id != SNGSS7_CON_IND_EVENT) { - /* first message in the queue should ALWAYS be an IAM */ - SS7_ERROR_CHAN(ftdmchan, "Invalid initial peer message type '%d'\n", event_clone->event_id); - } else { - ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; - - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx IAM (Bridged, dialing %s)\n", sngss7_info->circuit->cic, caller_data->dnis.digits); - - /* copy original incoming IAM */ - memcpy(&iam, &event_clone->event.siConEvnt, sizeof(iam)); - - /* Change DNIS to whatever was specified, do not change NADI or anything else! */ - copy_tknStr_to_sngss7(caller_data->dnis.digits, &iam.cdPtyNum.addrSig, &iam.cdPtyNum.oddEven); - - /* SPIROU certification hack - If the IAM already contain RDINF, just increment the count and set the RDNIS digits - otherwise, honor RDNIS and RDINF stuff coming from the user */ - if (iam.redirInfo.eh.pres == PRSNT_NODEF) { - const char *val = NULL; - if (iam.redirInfo.redirCnt.pres) { - iam.redirInfo.redirCnt.val++; - SS7_DEBUG_CHAN(ftdmchan,"[CIC:%d]Tx IAM (Bridged), redirect count incremented = %d\n", sngss7_info->circuit->cic, iam.redirInfo.redirCnt.val); - } - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_rdnis_digits"); - if (!ftdm_strlen_zero(val)) { - SS7_DEBUG_CHAN(ftdmchan,"[CIC:%d]Tx IAM (Bridged), found user supplied RDNIS digits = %s\n", sngss7_info->circuit->cic, val); - copy_tknStr_to_sngss7((char*)val, &iam.redirgNum.addrSig, &iam.redirgNum.oddEven); - } else { - SS7_DEBUG_CHAN(ftdmchan,"[CIC:%d]Tx IAM (Bridged), not found user supplied RDNIS digits\n", sngss7_info->circuit->cic); - } - } else { - SS7_DEBUG_CHAN(ftdmchan,"[CIC:%d]Tx IAM (Bridged), redirect info not present, attempting to copy user supplied values\n", sngss7_info->circuit->cic); - /* Redirecting Number */ - copy_redirgNum_to_sngss7(ftdmchan, &iam.redirgNum); - - /* Redirecting Information */ - copy_redirgInfo_to_sngss7(ftdmchan, &iam.redirInfo); - } - - if (iam.origCdNum.eh.pres != PRSNT_NODEF) { - /* Original Called Number */ - copy_ocn_to_sngss7(ftdmchan, &iam.origCdNum); - } - copy_access_transport_to_sngss7(ftdmchan, &iam.accTrnspt); - } - } else if (sngss7_info->circuit->transparent_iam && - sngss7_retrieve_iam(ftdmchan, &iam) == FTDM_SUCCESS) { - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx IAM (Transparent)\n", sngss7_info->circuit->cic); - - /* Called Number information */ - copy_cdPtyNum_to_sngss7(ftdmchan, &iam.cdPtyNum); - - /* Redirecting Number */ - copy_redirgNum_to_sngss7(ftdmchan, &iam.redirgNum); - - /* Redirecting Information */ - copy_redirgInfo_to_sngss7(ftdmchan, &iam.redirInfo); - - /* Location Number information */ - copy_locPtyNum_to_sngss7(ftdmchan, &iam.cgPtyNum1); - - /* Forward Call Indicators */ - copy_fwdCallInd_to_sngss7(ftdmchan, &iam.fwdCallInd); - - /* Original Called Number */ - copy_ocn_to_sngss7(ftdmchan, &iam.origCdNum); - - copy_access_transport_to_sngss7(ftdmchan, &iam.accTrnspt); - - copy_NatureOfConnection_to_sngss7(ftdmchan, &iam.natConInd); - } else { - /* Nature of Connection Indicators */ - copy_natConInd_to_sngss7(ftdmchan, &iam.natConInd); - - /* Forward Call Indicators */ - copy_fwdCallInd_to_sngss7(ftdmchan, &iam.fwdCallInd); - - /* Transmission medium requirements */ - copy_txMedReq_to_sngss7(ftdmchan, &iam.txMedReq); - - if (SNGSS7_SWITCHTYPE_ANSI(g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].switchType)) { - /* User Service Info A */ - copy_usrServInfoA_to_sngss7(ftdmchan, &iam.usrServInfoA); - } - - /* Called Number information */ - copy_cdPtyNum_to_sngss7(ftdmchan, &iam.cdPtyNum); - - /* Calling Number information */ - copy_cgPtyNum_to_sngss7(ftdmchan, &iam.cgPtyNum); - - /* Location Number information */ - copy_locPtyNum_to_sngss7(ftdmchan, &iam.cgPtyNum1); - - /* Generic Number information */ - copy_genNmb_to_sngss7(ftdmchan, &iam.genNmb); - - /* Calling Party's Category */ - copy_cgPtyCat_to_sngss7(ftdmchan, &iam.cgPtyCat); - - /* Redirecting Number */ - copy_redirgNum_to_sngss7(ftdmchan, &iam.redirgNum); - - /* Redirecting Information */ - copy_redirgInfo_to_sngss7(ftdmchan, &iam.redirInfo); - - /* Original Called Number */ - copy_ocn_to_sngss7(ftdmchan, &iam.origCdNum); - - /* Access Transport - old implementation, taking from channel variable of ss7_clg_subaddr */ - copy_accTrnspt_to_sngss7(ftdmchan, &iam.accTrnspt); - - /* Access Transport - taking from channel variable of ss7_access_transport_urlenc. - This will overwirte the IE value set be above old implementation. - */ - copy_access_transport_to_sngss7(ftdmchan, &iam.accTrnspt); - - copy_NatureOfConnection_to_sngss7(ftdmchan, &iam.natConInd); - - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx IAM clg = \"%s\" (NADI=%d), cld = \"%s\" (NADI=%d), loc = %s (NADI=%d)\n", - sngss7_info->circuit->cic, - ftdmchan->caller_data.cid_num.digits, - iam.cgPtyNum.natAddrInd.val, - ftdmchan->caller_data.dnis.digits, - iam.cdPtyNum.natAddrInd.val, - ftdmchan->caller_data.loc.digits, - iam.cgPtyNum1.natAddrInd.val); - } - - sng_cc_con_request (sngss7_info->spId, - sngss7_info->suInstId, - sngss7_info->spInstId, - sngss7_info->circuit->id, - &iam, - 0); - - if (native_going_up) { - /* - Note that this function (ft_to_sngss7_iam) is run within the main SS7 processing loop in - response to the DIALING state handler, we can set the state to UP here and that will - implicitly complete the DIALING state, but we *MUST* also advance the state handler - right away for a native bridge, otherwise, the processing state function (ftdm_sangoma_ss7_process_state_change) - will complete the state without having executed the handler for FTDM_CHANNEL_STATE_UP, and we won't notify - the user sending FTDM_SIGEVENT_UP which can cause the application to misbehave (ie, no audio) */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_UP); - ftdm_channel_advance_states(ftdmchan); - } - - ftdm_safe_free(event_clone); - - SS7_FUNC_TRACE_EXIT (__FTDM_FUNC__); - return; -} - -void ft_to_sngss7_inf(ftdm_channel_t *ftdmchan, SiCnStEvnt *inr) -{ - SiCnStEvnt evnt; - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - - memset (&evnt, 0x0, sizeof (evnt)); - - evnt.infoInd.eh.pres = PRSNT_NODEF; - evnt.infoInd.cgPtyAddrRespInd.pres = PRSNT_NODEF; - evnt.infoInd.cgPtyCatRespInd.pres = PRSNT_NODEF; - - evnt.infoInd.chrgInfoRespInd.pres = PRSNT_NODEF; - evnt.infoInd.chrgInfoRespInd.val = 0; - evnt.infoInd.solInfoInd.pres = PRSNT_NODEF; - evnt.infoInd.solInfoInd.val = 0; - evnt.infoInd.holdProvInd.pres = PRSNT_NODEF; - evnt.infoInd.holdProvInd.val = 0; - evnt.infoInd.spare.pres = PRSNT_NODEF; - evnt.infoInd.spare.val = 0; - - if (inr->infoReqInd.eh.pres == PRSNT_NODEF) { - if ((inr->infoReqInd.holdingInd.pres == PRSNT_NODEF) && (inr->infoReqInd.holdingInd.val == HOLD_REQ)) { - SS7_DEBUG_CHAN(ftdmchan,"[CIC:%d]Received INR requesting holding information. Holding is not supported in INF.\n", sngss7_info->circuit->cic); - } - if ((inr->infoReqInd.chrgInfoReqInd.pres == PRSNT_NODEF) && (inr->infoReqInd.chrgInfoReqInd.val == CHRGINFO_REQ)) { - SS7_DEBUG_CHAN(ftdmchan,"[CIC:%d]Received INR requesting charging information. Charging is not supported in INF.\n", sngss7_info->circuit->cic); - } - if ((inr->infoReqInd.malCaIdReqInd.pres == PRSNT_NODEF) && (inr->infoReqInd.malCaIdReqInd.val == CHRGINFO_REQ)) { - SS7_DEBUG_CHAN(ftdmchan,"[CIC:%d]Received INR requesting malicious call id. Malicious call id is not supported in INF.\n", sngss7_info->circuit->cic); - } - - if ((inr->infoReqInd.cgPtyAdReqInd.pres == PRSNT_NODEF) && (inr->infoReqInd.cgPtyAdReqInd.val == CGPRTYADDREQ_REQ)) { - evnt.infoInd.cgPtyAddrRespInd.val=CGPRTYADDRESP_INCL; - copy_cgPtyNum_to_sngss7 (ftdmchan, &evnt.cgPtyNum); - } else { - evnt.infoInd.cgPtyAddrRespInd.val=CGPRTYADDRESP_NOTINCL; - } - - if ((inr->infoReqInd.cgPtyCatReqInd.pres == PRSNT_NODEF) && (inr->infoReqInd.cgPtyCatReqInd.val == CGPRTYCATREQ_REQ)) { - evnt.infoInd.cgPtyCatRespInd.val = CGPRTYCATRESP_INCL; - copy_cgPtyCat_to_sngss7 (ftdmchan, &evnt.cgPtyCat); - } else { - evnt.infoInd.cgPtyCatRespInd.val = CGPRTYCATRESP_NOTINCL; - } - } - else { - SS7_DEBUG_CHAN(ftdmchan,"[CIC:%d]Received INR with no information request. Sending back default INF.\n", sngss7_info->circuit->cic); - } - - sng_cc_inf(1, - sngss7_info->suInstId, - sngss7_info->spInstId, - sngss7_info->circuit->id, - &evnt, - INFORMATION); - - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx INF\n", sngss7_info->circuit->cic); - -} - -void ft_to_sngss7_inr(ftdm_channel_t *ftdmchan) -{ - SiCnStEvnt evnt; - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - - memset (&evnt, 0x0, sizeof (evnt)); - - evnt.infoReqInd.eh.pres = PRSNT_NODEF; - evnt.infoReqInd.cgPtyAdReqInd.pres = PRSNT_NODEF; - evnt.infoReqInd.cgPtyAdReqInd.val=CGPRTYADDREQ_REQ; - - evnt.infoReqInd.holdingInd.pres = PRSNT_NODEF; - evnt.infoReqInd.holdingInd.val = HOLD_REQ; - - evnt.infoReqInd.cgPtyCatReqInd.pres = PRSNT_NODEF; - evnt.infoReqInd.cgPtyCatReqInd.val = CGPRTYCATREQ_REQ; - - evnt.infoReqInd.chrgInfoReqInd.pres = PRSNT_NODEF; - evnt.infoReqInd.chrgInfoReqInd.val = CHRGINFO_REQ; - - evnt.infoReqInd.malCaIdReqInd.pres = PRSNT_NODEF; - evnt.infoReqInd.malCaIdReqInd.val = MLBG_INFOREQ; - - sng_cc_inr(1, - sngss7_info->suInstId, - sngss7_info->spInstId, - sngss7_info->circuit->id, - &evnt, - INFORMATREQ); - - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx INR\n", sngss7_info->circuit->cic); -} - -void ft_to_sngss7_acm (ftdm_channel_t * ftdmchan) -{ - SS7_FUNC_TRACE_ENTER (__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - SiCnStEvnt acm; - const char *backwardInd = NULL; - - memset (&acm, 0x0, sizeof (acm)); - - /* fill in the needed information for the ACM */ - acm.bckCallInd.eh.pres = PRSNT_NODEF; - acm.bckCallInd.chrgInd.pres = PRSNT_NODEF; - acm.bckCallInd.chrgInd.val = CHRG_CHRG; - acm.bckCallInd.cadPtyStatInd.pres = PRSNT_NODEF; - acm.bckCallInd.cadPtyStatInd.val = 0x01; - acm.bckCallInd.cadPtyCatInd.pres = PRSNT_NODEF; - acm.bckCallInd.cadPtyCatInd.val = CADCAT_ORDSUBS; - acm.bckCallInd.end2EndMethInd.pres = PRSNT_NODEF; - acm.bckCallInd.end2EndMethInd.val = E2EMTH_NOMETH; - acm.bckCallInd.intInd.pres = PRSNT_NODEF; - acm.bckCallInd.intInd.val = INTIND_NOINTW; - acm.bckCallInd.end2EndInfoInd.pres = PRSNT_NODEF; - acm.bckCallInd.end2EndInfoInd.val = E2EINF_NOINFO; - - acm.bckCallInd.isdnUsrPrtInd.pres = PRSNT_NODEF; - acm.bckCallInd.isdnUsrPrtInd.val = ISUP_NOTUSED; - backwardInd = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "acm_bi_iup"); - if (!ftdm_strlen_zero(backwardInd)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied backward indicator ISDN user part indicator ACM, value \"%s\"\n", backwardInd); - if (atoi(backwardInd) != 0 ) { - acm.bckCallInd.isdnUsrPrtInd.val = ISUP_USED; - } - } - acm.bckCallInd.holdInd.pres = PRSNT_NODEF; - acm.bckCallInd.holdInd.val = HOLD_NOTREQD; - acm.bckCallInd.isdnAccInd.pres = PRSNT_NODEF; - acm.bckCallInd.isdnAccInd.val = ISDNACC_NONISDN; - acm.bckCallInd.echoCtrlDevInd.pres = PRSNT_NODEF; - switch (ftdmchan->caller_data.bearer_capability) { - /**********************************************************************/ - case (FTDM_BEARER_CAP_SPEECH): - acm.bckCallInd.echoCtrlDevInd.val = 0x1; - break; - /**********************************************************************/ - case (FTDM_BEARER_CAP_UNRESTRICTED): - acm.bckCallInd.echoCtrlDevInd.val = 0x0; - break; - /**********************************************************************/ - case (FTDM_BEARER_CAP_3_1KHZ_AUDIO): - acm.bckCallInd.echoCtrlDevInd.val = 0x1; - break; - /**********************************************************************/ - default: - SS7_ERROR_CHAN(ftdmchan, "Unknown Bearer capability falling back to speech%s\n", " "); - acm.bckCallInd.echoCtrlDevInd.val = 0x1; - break; - /**********************************************************************/ - } /* switch (ftdmchan->caller_data.bearer_capability) */ - acm.bckCallInd.sccpMethInd.pres = PRSNT_NODEF; - acm.bckCallInd.sccpMethInd.val = SCCPMTH_NOIND; - - /* fill in any optional parameters */ - if (sngss7_test_options(&g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id], SNGSS7_ACM_OBCI_BITA)) { - SS7_DEBUG_CHAN(ftdmchan, "Found ACM_OBCI_BITA flag:0x%X\n", g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].options); - acm.optBckCalInd.eh.pres = PRSNT_NODEF; - acm.optBckCalInd.inbndInfoInd.pres = PRSNT_NODEF; - acm.optBckCalInd.inbndInfoInd.val = 0x1; - acm.optBckCalInd.caFwdMayOcc.pres = PRSNT_DEF; - acm.optBckCalInd.simpleSegmInd.pres = PRSNT_DEF; - acm.optBckCalInd.mlppUserInd.pres = PRSNT_DEF; - acm.optBckCalInd.usrNetIneractInd.pres = PRSNT_DEF; - acm.optBckCalInd.netExcDelInd.pres = PRSNT_DEF; - } /* if (sngss7_test_options(isup_intf, SNGSS7_ACM_OBCI_BITA)) */ - - /* send the ACM request to LibSngSS7 */ - sng_cc_con_status (1, - sngss7_info->suInstId, - sngss7_info->spInstId, - sngss7_info->circuit->id, - &acm, - ADDRCMPLT); - - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx ACM\n", sngss7_info->circuit->cic); - - SS7_FUNC_TRACE_EXIT (__FTDM_FUNC__); - return; -} - -void ft_to_sngss7_cpg (ftdm_channel_t *ftdmchan) -{ - SiCnStEvnt cpg; - SS7_FUNC_TRACE_ENTER (__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - - - memset (&cpg, 0, sizeof (cpg)); - - cpg.evntInfo.eh.pres = PRSNT_NODEF; - - cpg.evntInfo.evntInd.pres = PRSNT_NODEF; - cpg.evntInfo.evntInd.val = SNGSS7_EVNTINFO_IND_INBAND_AVAIL; /* Event Indicator = In-band info is now available */ - - cpg.evntInfo.evntPresResInd.pres = PRSNT_NODEF; - cpg.evntInfo.evntPresResInd.val = 0; /* Event presentation restricted indicator = no indication */ - - /* send the CPG request to LibSngSS7 */ - sng_cc_con_status (1, sngss7_info->suInstId, sngss7_info->spInstId, sngss7_info->circuit->id, &cpg, PROGRESS); - - ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "[CIC:%d]Tx CPG\n", sngss7_info->circuit->cic); - SS7_FUNC_TRACE_EXIT (__FTDM_FUNC__); - return; -} -void ft_to_sngss7_anm (ftdm_channel_t * ftdmchan) -{ - SS7_FUNC_TRACE_ENTER (__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - SiConEvnt anm; - - memset (&anm, 0x0, sizeof (anm)); - - /* send the ANM request to LibSngSS7 */ - sng_cc_con_response(1, - sngss7_info->suInstId, - sngss7_info->spInstId, - sngss7_info->circuit->id, - &anm, - 5); - - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx ANM\n", sngss7_info->circuit->cic); - - SS7_FUNC_TRACE_EXIT (__FTDM_FUNC__); - return; -} - -/******************************************************************************/ -void ft_to_sngss7_rel (ftdm_channel_t * ftdmchan) -{ - const char *loc_ind = NULL; - SS7_FUNC_TRACE_ENTER (__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - SiRelEvnt rel; - - memset (&rel, 0x0, sizeof (rel)); - - rel.causeDgn.eh.pres = PRSNT_NODEF; - rel.causeDgn.location.pres = PRSNT_NODEF; - - loc_ind = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_rel_loc"); - if (!ftdm_strlen_zero(loc_ind)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied location indicator in REL, value \"%s\"\n", loc_ind); - rel.causeDgn.location.val = atoi(loc_ind); - } else { - rel.causeDgn.location.val = 0x01; - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "No user supplied location indicator in REL, using 0x01\"%s\"\n", ""); - } - rel.causeDgn.cdeStand.pres = PRSNT_NODEF; - rel.causeDgn.cdeStand.val = 0x00; - rel.causeDgn.recommend.pres = NOTPRSNT; - rel.causeDgn.causeVal.pres = PRSNT_NODEF; - rel.causeDgn.causeVal.val = (uint8_t) ftdmchan->caller_data.hangup_cause; - rel.causeDgn.dgnVal.pres = NOTPRSNT; - - /* send the REL request to LibSngSS7 */ - sng_cc_rel_request (1, - sngss7_info->suInstId, - sngss7_info->spInstId, - sngss7_info->circuit->id, - &rel); - - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx REL cause=%d \n", - sngss7_info->circuit->cic, - ftdmchan->caller_data.hangup_cause ); - - SS7_FUNC_TRACE_EXIT (__FTDM_FUNC__); - return; -} - -/******************************************************************************/ -void ft_to_sngss7_rlc (ftdm_channel_t * ftdmchan) -{ - SS7_FUNC_TRACE_ENTER (__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - SiRelEvnt rlc; - - memset (&rlc, 0x0, sizeof (rlc)); - - /* send the RLC request to LibSngSS7 */ - sng_cc_rel_response (1, - sngss7_info->suInstId, - sngss7_info->spInstId, - sngss7_info->circuit->id, - &rlc); - - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx RLC\n", sngss7_info->circuit->cic); - - SS7_FUNC_TRACE_EXIT (__FTDM_FUNC__); - return; -} - -/******************************************************************************/ -void ft_to_sngss7_rsc (ftdm_channel_t * ftdmchan) -{ - SS7_FUNC_TRACE_ENTER (__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - - sng_cc_sta_request (1, - sngss7_info->suInstId, - sngss7_info->spInstId, - sngss7_info->circuit->id, - sngss7_info->globalFlg, - SIT_STA_CIRRESREQ, - NULL); - - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx RSC\n", sngss7_info->circuit->cic); - - SS7_FUNC_TRACE_EXIT (__FTDM_FUNC__); - return; -} - -/******************************************************************************/ -void ft_to_sngss7_rsca (ftdm_channel_t * ftdmchan) -{ - SS7_FUNC_TRACE_ENTER (__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - - sng_cc_sta_request (1, - sngss7_info->suInstId, - sngss7_info->spInstId, - sngss7_info->circuit->id, - sngss7_info->globalFlg, - SIT_STA_CIRRESRSP, - NULL); - - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx RSC-RLC\n", sngss7_info->circuit->cic); - - SS7_FUNC_TRACE_EXIT (__FTDM_FUNC__); - return; -} - -/******************************************************************************/ -void ft_to_sngss7_blo (ftdm_channel_t * ftdmchan) -{ - SS7_FUNC_TRACE_ENTER (__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - - sng_cc_sta_request (1, - 0, - 0, - sngss7_info->circuit->id, - sngss7_info->globalFlg, - SIT_STA_CIRBLOREQ, - NULL); - - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx BLO\n", sngss7_info->circuit->cic); - - SS7_FUNC_TRACE_EXIT (__FTDM_FUNC__); - return; -} - -/******************************************************************************/ -void ft_to_sngss7_bla (ftdm_channel_t * ftdmchan) -{ - SS7_FUNC_TRACE_ENTER (__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - - sng_cc_sta_request (1, - 0, - 0, - sngss7_info->circuit->id, - sngss7_info->globalFlg, - SIT_STA_CIRBLORSP, - NULL); - - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx BLA\n", sngss7_info->circuit->cic); - - SS7_FUNC_TRACE_EXIT (__FTDM_FUNC__); - return; -} - -/******************************************************************************/ -void -ft_to_sngss7_ubl (ftdm_channel_t * ftdmchan) -{ - SS7_FUNC_TRACE_ENTER (__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - - sng_cc_sta_request (1, - 0, - 0, - sngss7_info->circuit->id, - sngss7_info->globalFlg, - SIT_STA_CIRUBLREQ, - NULL); - - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx UBL\n", sngss7_info->circuit->cic); - - SS7_FUNC_TRACE_EXIT (__FTDM_FUNC__); - return; -} - -/******************************************************************************/ -void ft_to_sngss7_uba (ftdm_channel_t * ftdmchan) -{ - SS7_FUNC_TRACE_ENTER (__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - - sng_cc_sta_request (1, - 0, - 0, - sngss7_info->circuit->id, - sngss7_info->globalFlg, - SIT_STA_CIRUBLRSP, - NULL); - - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx UBA\n", sngss7_info->circuit->cic); - - SS7_FUNC_TRACE_EXIT (__FTDM_FUNC__); - return; -} - -/******************************************************************************/ -void ft_to_sngss7_lpa (ftdm_channel_t * ftdmchan) -{ - SS7_FUNC_TRACE_ENTER (__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - - sng_cc_sta_request (1, - sngss7_info->suInstId, - sngss7_info->spInstId, - sngss7_info->circuit->id, - sngss7_info->globalFlg, - SIT_STA_LOOPBACKACK, - NULL); - - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx LPA\n", sngss7_info->circuit->cic); - - SS7_FUNC_TRACE_EXIT (__FTDM_FUNC__); -return; -} - -/******************************************************************************/ -void ft_to_sngss7_gra (ftdm_channel_t * ftdmchan) -{ - SS7_FUNC_TRACE_ENTER (__FTDM_FUNC__); - - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - SiStaEvnt gra; - - /* clean out the gra struct */ - memset (&gra, 0x0, sizeof (gra)); - - gra.rangStat.eh.pres = PRSNT_NODEF; - - /* fill in the range */ - gra.rangStat.range.pres = PRSNT_NODEF; - gra.rangStat.range.val = sngss7_info->rx_grs.range; - - /* fill in the status */ - gra.rangStat.status.pres = PRSNT_NODEF; - gra.rangStat.status.len = ((sngss7_info->rx_grs.range + 1) >> 3) + (((sngss7_info->rx_grs.range + 1) & 0x07) ? 1 : 0); - - /* the status field should be 1 if blocked for maintenace reasons - * and 0 is not blocked....since we memset the struct nothing to do - */ - - /* send the GRA to LibSng-SS7 */ - sng_cc_sta_request (1, - 0, - 0, - sngss7_info->rx_grs.circuit, - 0, - SIT_STA_GRSRSP, - &gra); - - SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Tx GRA (%d:%d)\n", - sngss7_info->circuit->cic, - sngss7_info->circuit->cic, - (sngss7_info->circuit->cic + sngss7_info->rx_grs.range)); - - - SS7_FUNC_TRACE_EXIT (__FTDM_FUNC__); - return; -} - -/******************************************************************************/ -void ft_to_sngss7_grs (ftdm_channel_t *fchan) -{ - SS7_FUNC_TRACE_ENTER (__FTDM_FUNC__); - - sngss7_chan_data_t *cinfo = fchan->call_data; - - SiStaEvnt grs; - - ftdm_assert(sngss7_test_ckt_flag(cinfo, FLAG_GRP_RESET_TX) && - !sngss7_test_ckt_flag(cinfo, FLAG_GRP_RESET_SENT), "Incorrect flags\n"); - - memset (&grs, 0x0, sizeof(grs)); - grs.rangStat.eh.pres = PRSNT_NODEF; - grs.rangStat.range.pres = PRSNT_NODEF; - grs.rangStat.range.val = cinfo->tx_grs.range; - - sng_cc_sta_request (1, - 0, - 0, - cinfo->tx_grs.circuit, - 0, - SIT_STA_GRSREQ, - &grs); - - SS7_INFO_CHAN(fchan, "[CIC:%d]Tx GRS (%d:%d)\n", - cinfo->circuit->cic, - cinfo->circuit->cic, - (cinfo->circuit->cic + cinfo->tx_grs.range)); - - sngss7_set_ckt_flag(cinfo, FLAG_GRP_RESET_SENT); - - SS7_FUNC_TRACE_EXIT (__FTDM_FUNC__); -} - -/******************************************************************************/ -void ft_to_sngss7_cgba(ftdm_channel_t * ftdmchan) -{ - SS7_FUNC_TRACE_ENTER (__FTDM_FUNC__); - - sngss7_span_data_t *sngss7_span = ftdmchan->span->signal_data; - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - int x = 0; - - SiStaEvnt cgba; - - memset (&cgba, 0x0, sizeof(cgba)); - - /* fill in the circuit group supervisory message */ - cgba.cgsmti.eh.pres = PRSNT_NODEF; - cgba.cgsmti.typeInd.pres = PRSNT_NODEF; - cgba.cgsmti.typeInd.val = sngss7_span->rx_cgb.type; - - cgba.rangStat.eh.pres = PRSNT_NODEF; - /* fill in the range */ - cgba.rangStat.range.pres = PRSNT_NODEF; - cgba.rangStat.range.val = sngss7_span->rx_cgb.range; - /* fill in the status */ - cgba.rangStat.status.pres = PRSNT_NODEF; - cgba.rangStat.status.len = ((sngss7_span->rx_cgb.range + 1) >> 3) + (((sngss7_span->rx_cgb.range + 1) & 0x07) ? 1 : 0); - for(x = 0; x < cgba.rangStat.status.len; x++){ - cgba.rangStat.status.val[x] = sngss7_span->rx_cgb.status[x]; - } - - sng_cc_sta_request (1, - 0, - 0, - sngss7_span->rx_cgb.circuit, - 0, - SIT_STA_CGBRSP, - &cgba); - - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx CGBA (%d:%d)\n", - sngss7_info->circuit->cic, - sngss7_info->circuit->cic, - (sngss7_info->circuit->cic + sngss7_span->rx_cgb.range)); - - /* clean out the saved data */ - memset(&sngss7_span->rx_cgb, 0x0, sizeof(sngss7_group_data_t)); - - SS7_FUNC_TRACE_EXIT (__FTDM_FUNC__); - return; -} - -/******************************************************************************/ -void ft_to_sngss7_cgua(ftdm_channel_t * ftdmchan) -{ - SS7_FUNC_TRACE_ENTER (__FTDM_FUNC__); - - sngss7_span_data_t *sngss7_span = ftdmchan->span->signal_data; - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - int x = 0; - - SiStaEvnt cgua; - - memset (&cgua, 0x0, sizeof(cgua)); - - /* fill in the circuit group supervisory message */ - cgua.cgsmti.eh.pres = PRSNT_NODEF; - cgua.cgsmti.typeInd.pres = PRSNT_NODEF; - cgua.cgsmti.typeInd.val = sngss7_span->rx_cgu.type; - - cgua.rangStat.eh.pres = PRSNT_NODEF; - /* fill in the range */ - cgua.rangStat.range.pres = PRSNT_NODEF; - cgua.rangStat.range.val = sngss7_span->rx_cgu.range; - /* fill in the status */ - cgua.rangStat.status.pres = PRSNT_NODEF; - cgua.rangStat.status.len = ((sngss7_span->rx_cgu.range + 1) >> 3) + (((sngss7_span->rx_cgu.range + 1) & 0x07) ? 1 : 0); - for(x = 0; x < cgua.rangStat.status.len; x++){ - cgua.rangStat.status.val[x] = sngss7_span->rx_cgu.status[x]; - } - - sng_cc_sta_request (1, - 0, - 0, - sngss7_span->rx_cgu.circuit, - 0, - SIT_STA_CGURSP, - &cgua); - - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx CGUA (%d:%d)\n", - sngss7_info->circuit->cic, - sngss7_info->circuit->cic, - (sngss7_info->circuit->cic + sngss7_span->rx_cgu.range)); - - /* clean out the saved data */ - memset(&sngss7_span->rx_cgu, 0x0, sizeof(sngss7_group_data_t)); - - - SS7_FUNC_TRACE_EXIT (__FTDM_FUNC__); - return; -} - -/******************************************************************************/ -void ft_to_sngss7_cgb(ftdm_channel_t * ftdmchan) -{ - SS7_FUNC_TRACE_ENTER (__FTDM_FUNC__); - - sngss7_span_data_t *sngss7_span = ftdmchan->span->signal_data; - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - SiStaEvnt cgb; - int x = 0; - - - memset (&cgb, 0x0, sizeof(cgb)); - - /* fill in the circuit group supervisory message */ - cgb.cgsmti.eh.pres = PRSNT_NODEF; - cgb.cgsmti.typeInd.pres = PRSNT_NODEF; - cgb.cgsmti.typeInd.val = sngss7_span->tx_cgb.type; - - /* fill in the range */ - cgb.rangStat.eh.pres = PRSNT_NODEF; - cgb.rangStat.range.pres = PRSNT_NODEF; - cgb.rangStat.range.val = sngss7_span->tx_cgb.range; - - /* fill in the status */ - cgb.rangStat.status.pres = PRSNT_NODEF; - cgb.rangStat.status.len = ((sngss7_span->tx_cgb.range + 1) >> 3) + (((sngss7_span->tx_cgb.range + 1) & 0x07) ? 1 : 0); - for(x = 0; x < cgb.rangStat.status.len; x++){ - cgb.rangStat.status.val[x] = sngss7_span->tx_cgb.status[x]; - } - - sng_cc_sta_request (1, - 0, - 0, - sngss7_span->tx_cgb.circuit, - 0, - SIT_STA_CGBREQ, - &cgb); - - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx CGB (%d:%d)\n", - sngss7_info->circuit->cic, - sngss7_info->circuit->cic, - (sngss7_info->circuit->cic + sngss7_span->tx_cgb.range)); - - /* clean out the saved data */ - memset(&sngss7_span->tx_cgb, 0x0, sizeof(sngss7_group_data_t)); - - - SS7_FUNC_TRACE_EXIT (__FTDM_FUNC__); - return; -} - -/******************************************************************************/ -void ft_to_sngss7_cgu(ftdm_channel_t * ftdmchan) -{ - SS7_FUNC_TRACE_ENTER (__FTDM_FUNC__); - - sngss7_span_data_t *sngss7_span = ftdmchan->span->signal_data; - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - SiStaEvnt cgu; - int x = 0; - - - memset (&cgu, 0x0, sizeof(cgu)); - - /* fill in the circuit group supervisory message */ - cgu.cgsmti.eh.pres = PRSNT_NODEF; - cgu.cgsmti.typeInd.pres = PRSNT_NODEF; - cgu.cgsmti.typeInd.val = sngss7_span->tx_cgu.type; - - /* fill in the range */ - cgu.rangStat.eh.pres = PRSNT_NODEF; - cgu.rangStat.range.pres = PRSNT_NODEF; - cgu.rangStat.range.val = sngss7_span->tx_cgu.range; - - /* fill in the status */ - cgu.rangStat.status.pres = PRSNT_NODEF; - cgu.rangStat.status.len = ((sngss7_span->tx_cgu.range + 1) >> 3) + (((sngss7_span->tx_cgu.range + 1) & 0x07) ? 1 : 0); - for(x = 0; x < cgu.rangStat.status.len; x++){ - cgu.rangStat.status.val[x] = sngss7_span->tx_cgu.status[x]; - } - - sng_cc_sta_request (1, - 0, - 0, - sngss7_span->tx_cgu.circuit, - 0, - SIT_STA_CGUREQ, - &cgu); - - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx CGU (%d:%d)\n", - sngss7_info->circuit->cic, - sngss7_info->circuit->cic, - (sngss7_info->circuit->cic + sngss7_span->tx_cgu.range)); - - /* clean out the saved data */ - memset(&sngss7_span->tx_cgu, 0x0, sizeof(sngss7_group_data_t)); - - - SS7_FUNC_TRACE_EXIT (__FTDM_FUNC__); - return; -} - -/* French SPIROU send Charge Unit */ -/* No one calls this function yet, but it has been implemented to complement TXA messages */ -void ft_to_sngss7_itx (ftdm_channel_t * ftdmchan) -{ -#ifndef SANGOMA_SPIROU - SS7_FUNC_TRACE_ENTER (__FTDM_FUNC__); - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "ITX message not supported!, please update your libsng_ss7\n"); -#else - const char* var = NULL; - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - SiCnStEvnt itx; - - SS7_FUNC_TRACE_ENTER (__FTDM_FUNC__); - - memset (&itx, 0x0, sizeof (itx)); - - itx.msgNum.eh.pres = PRSNT_NODEF; - itx.msgNum.msgNum.pres = PRSNT_NODEF; - var = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_itx_msg_num"); - if (!ftdm_strlen_zero(var)) { - itx.msgNum.msgNum.val = atoi(var); - } else { - itx.msgNum.msgNum.val = 0x1; - } - - itx.chargUnitNum.eh.pres = PRSNT_NODEF; - itx.chargUnitNum.chargUnitNum.pres = PRSNT_NODEF; - var = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_itx_charge_unit"); - if (!ftdm_strlen_zero(var)) { - itx.chargUnitNum.chargUnitNum.val = atoi(var); - } else { - itx.chargUnitNum.chargUnitNum.val = 0x1; - } - - ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "ITX Charging Unit:%d Msg Num:%d\n", itx.chargUnitNum.chargUnitNum.val, itx.msgNum.msgNum.val); - sng_cc_con_status (1, sngss7_info->suInstId, sngss7_info->spInstId, sngss7_info->circuit->id, &itx, CHARGE_UNIT); - - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx ITX\n", sngss7_info->circuit->cic); -#endif - SS7_FUNC_TRACE_EXIT (__FTDM_FUNC__); - return; -} - -/* French SPIROU send Charging Acknowledgement */ -void ft_to_sngss7_txa (ftdm_channel_t * ftdmchan) -{ -#ifndef SANGOMA_SPIROU - SS7_FUNC_TRACE_ENTER (__FTDM_FUNC__); - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "TXA message not supported!, please update your libsng_ss7\n"); -#else - SiCnStEvnt txa; - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - SS7_FUNC_TRACE_ENTER (__FTDM_FUNC__); - - memset (&txa, 0x0, sizeof(txa)); - - sng_cc_con_status(1, sngss7_info->suInstId, sngss7_info->spInstId, sngss7_info->circuit->id, &txa, CHARGE_ACK); - - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx TXA\n", sngss7_info->circuit->cic); -#endif - SS7_FUNC_TRACE_EXIT (__FTDM_FUNC__); - return; -} - -/******************************************************************************/ -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ -/******************************************************************************/ diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_relay.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_relay.c deleted file mode 100644 index 8389e56950..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_relay.c +++ /dev/null @@ -1,345 +0,0 @@ -/* - * Copyright (c) 2009|Konrad Hammel - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE|EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* INCLUDE ********************************************************************/ -#include "ftmod_sangoma_ss7_main.h" -/******************************************************************************/ - -/* DEFINES ********************************************************************/ -/******************************************************************************/ - -/* GLOBALS ********************************************************************/ -/******************************************************************************/ - -/* PROTOTYPES *****************************************************************/ - -/*static ftdm_status_t enable_all_ckts_for_relay(void);*/ -static ftdm_status_t reconfig_all_ckts_for_relay(void); -static ftdm_status_t disable_all_ckts_for_relay(void); -static ftdm_status_t block_all_ckts_for_relay(uint32_t procId); -/* static ftdm_status_t unblock_all_ckts_for_relay(uint32_t procId); */ -static ftdm_status_t disable_all_sigs_for_relay(uint32_t procId); -static ftdm_status_t disble_all_mtp2_sigs_for_relay(void); -/******************************************************************************/ - -/* FUNCTIONS ******************************************************************/ -ftdm_status_t handle_relay_connect(RyMngmt *sta) -{ - sng_relay_t *sng_relay = &g_ftdm_sngss7_data.cfg.relay[sta->t.usta.s.ryUpUsta.id]; - - if (!sngss7_test_flag(sng_relay, SNGSS7_RELAY_INIT)) { - /* SS7_INFO("Relay Channel %d initial connection UP\n", sng_relay->id); */ - sngss7_set_flag(sng_relay, SNGSS7_RELAY_INIT); - } - - SS7_INFO("Relay Channel %d connection UP\n", sng_relay->id); - if (sng_relay->type == LRY_CT_TCP_CLIENT) { - if (reconfig_all_ckts_for_relay()) { - SS7_ERROR("Failed to reconfigure ISUP Ckts!\n"); - /* we're done....this is very bad! */ - } - return FTDM_SUCCESS; - } else if (sng_relay->type == LRY_CT_TCP_SERVER) { - ftmod_ss7_enable_grp_mtp3Link(sta->t.usta.s.ryUpUsta.id); - /* unbloock the ckts on the client system */ - return FTDM_SUCCESS; - } - return FTDM_FAIL; -} - -/******************************************************************************/ -ftdm_status_t handle_relay_disconnect_on_error(RyMngmt *sta) -{ - SS7_DEBUG("SS7 relay disconnect on error\n"); - - /* check which procId is in error, if it is 1, disable the ckts */ - if (sta->t.usta.s.ryErrUsta.errPid == 1 ) { - /* we've lost the server, bring the sig status down on all ckts */ - disable_all_ckts_for_relay(); - - /* we've lost the server, bring down the mtp2 links */ - disble_all_mtp2_sigs_for_relay(); - } - - /* check if the channel is a server, means we just lost a MGW */ - if (g_ftdm_sngss7_data.cfg.relay[sta->t.usta.s.ryErrUsta.errPid].type == LRY_CT_TCP_SERVER) { - /* we've lost the client, bring down all the ckts for this procId */ - block_all_ckts_for_relay(sta->t.usta.s.ryErrUsta.errPid); - - /* we've lost the client, bring down all mtp3 links for this procId */ - disable_all_sigs_for_relay(sta->t.usta.s.ryErrUsta.errPid); - } - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t handle_relay_disconnect_on_down(RyMngmt *sta) -{ - - SS7_DEBUG("SS7 relay disconnect on down\n"); - - /* check if the channel is a server, means we just lost a MGW */ - if (g_ftdm_sngss7_data.cfg.relay[sta->t.usta.s.ryUpUsta.id].type == LRY_CT_TCP_SERVER) { - block_all_ckts_for_relay(sta->t.usta.s.ryUpUsta.id); - - disable_all_sigs_for_relay(sta->t.usta.s.ryUpUsta.id); - } - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t disable_all_ckts_for_relay(void) -{ - sngss7_chan_data_t *sngss7_info = NULL; - ftdm_channel_t *ftdmchan = NULL; - int x; - - SS7_INFO("Disabling all ckts becuase of Relay loss\n"); - - x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1; - while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) { - /**********************************************************************/ - /* make sure this is voice channel */ - if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == SNG_CKT_VOICE) { - - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(g_ftdm_sngss7_data.cfg.isupCkt[x].id, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", g_ftdm_sngss7_data.cfg.isupCkt[x].id); - x++; - continue; - } - - /* throw the relay_down flag */ - sngss7_set_ckt_flag(sngss7_info, FLAG_RELAY_DOWN); - - /* throw the channel infId status flags to PAUSED ... they will be executed next process cycle */ - sngss7_clear_ckt_flag(sngss7_info, FLAG_INFID_RESUME); - sngss7_set_ckt_flag(sngss7_info, FLAG_INFID_PAUSED); - } /* if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == SNG_CKT_VOICE) */ - - /* move along */ - x++; - /**********************************************************************/ - } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) */ - - return FTDM_SUCCESS; -} -#if 0 -/******************************************************************************/ -ftdm_status_t enable_all_ckts_for_relay(void) -{ - sngss7_chan_data_t *sngss7_info = NULL; - sng_isup_inf_t *sngIntf = NULL; - ftdm_channel_t *ftdmchan = NULL; - int x; - - SS7_INFO("Enabling all ckts becuase of Relay connection\n"); - - x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1; - while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) { - /**********************************************************************/ - /* make sure this is voice channel */ - if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == SNG_CKT_VOICE) { - - /* get the ftdmchan and ss7_chan_data from the circuit */ - if (extract_chan_data(g_ftdm_sngss7_data.cfg.isupCkt[x].id, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", g_ftdm_sngss7_data.cfg.isupCkt[x].id); - x++; - continue; - } - - /* bring the relay_down flag down */ - sngss7_clear_ckt_flag(sngss7_info, FLAG_RELAY_DOWN); - - sngIntf = &g_ftdm_sngss7_data.cfg.isupIntf[g_ftdm_sngss7_data.cfg.isupCkt[x].infId]; - - /* check if the interface is paused or resumed */ - if (sngss7_test_flag(sngIntf, SNGSS7_PAUSED)) { - /* don't bring the channel resume flag up...the interface is down */ - SS7_DEBUG_CHAN(ftdmchan, "ISUP interface (%d) set to paused, not resuming channel\n", sngIntf->id); - } else { - SS7_DEBUG_CHAN(ftdmchan, "ISUP interface (%d) set to resume, resuming channel\n", sngIntf->id); - /* throw the channel infId status flags to PAUSED ... they will be executed next process cycle */ - sngss7_set_ckt_flag(sngss7_info, FLAG_INFID_RESUME); - sngss7_clear_ckt_flag(sngss7_info, FLAG_INFID_PAUSED); - } - } /* if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == SNG_CKT_VOICE) */ - - /* move along */ - x++; - /**********************************************************************/ - } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) */ - - return FTDM_SUCCESS; -} -#endif -/******************************************************************************/ -ftdm_status_t reconfig_all_ckts_for_relay(void) -{ - int x; - sngss7_chan_data_t *sngss7_info = NULL; - - /* go through all the circuits on our ProcId */ - x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1; - while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) { - /**************************************************************************/ - if ( g_ftdm_sngss7_data.cfg.isupCkt[x].type == SNG_CKT_VOICE) { - /* grab the private data structure */ - sngss7_info = g_ftdm_sngss7_data.cfg.isupCkt[x].obj; - - /* mark the circuit for re-configuration */ - sngss7_set_ckt_flag(sngss7_info, FLAG_CKT_RECONFIG); - - /* clear the relay flag */ - sngss7_clear_ckt_flag(sngss7_info, FLAG_RELAY_DOWN); - } - - /* move to the next circuit */ - x++; - /**************************************************************************/ - } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) */ - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t block_all_ckts_for_relay(uint32_t procId) -{ - int x; - int ret; - - /* we just lost connection to this procId, send out a block for all these circuits */ - x = (procId * 1000) + 1; - while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) { - /**************************************************************************/ - if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == SNG_CKT_VOICE) { - - /* send a block request via stack manager */ - ret = ftmod_ss7_block_isup_ckt_nowait(g_ftdm_sngss7_data.cfg.isupCkt[x].id); - if (ret) { - SS7_INFO("Successfully BLOcked CIC:%d(ckt:%d) due to Relay failure\n", - g_ftdm_sngss7_data.cfg.isupCkt[x].cic, - g_ftdm_sngss7_data.cfg.isupCkt[x].id); - } else { - SS7_ERROR("Failed to BLOck CIC:%d(ckt:%d) due to Relay failure\n", - g_ftdm_sngss7_data.cfg.isupCkt[x].cic, - g_ftdm_sngss7_data.cfg.isupCkt[x].id); - } - - } /* if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == SNG_CKT_VOICE) */ - - /* move along */ - x++; - /**************************************************************************/ - } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) */ - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t disable_all_sigs_for_relay(uint32_t procId) -{ - SS7_INFO("Disalbing all sig links on ProcID = %d\n", procId); - - ftmod_ss7_disable_grp_mtp3Link(procId); - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t disble_all_mtp2_sigs_for_relay(void) -{ - /* check if there is a local mtp2 link*/ - if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP2_STARTED)) { - SS7_INFO("Disalbing all mtp2 sig links on local system\n"); - - ftmod_ss7_disable_grp_mtp2Link(1); - } - - return FTDM_SUCCESS; - -} - -#if 0 -/******************************************************************************/ -static ftdm_status_t unblock_all_ckts_for_relay(uint32_t procId) -{ - int x; - int ret; - - /* we just got connection to this procId, send out a unblock for all these circuits - * since we blocked them when we lost the connection - */ - x = (procId * 1000) + 1; - while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) { - /**************************************************************************/ - if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == SNG_CKT_VOICE) { - - /* send a block request via stack manager */ - ret = ftmod_ss7_unblock_isup_ckt(g_ftdm_sngss7_data.cfg.isupCkt[x].id); - if (ret) { - SS7_INFO("Successfully unblocked CIC:%d(ckt:%d) due to Relay connection\n", - g_ftdm_sngss7_data.cfg.isupCkt[x].cic, - g_ftdm_sngss7_data.cfg.isupCkt[x].id); - } else { - SS7_ERROR("Failed to unblock CIC:%d(ckt:%d) due to Relay connection\n", - g_ftdm_sngss7_data.cfg.isupCkt[x].cic, - g_ftdm_sngss7_data.cfg.isupCkt[x].id); - } - - } /* if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == SNG_CKT_VOICE) */ - - /* move along */ - x++; - /**************************************************************************/ - } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) */ - - return FTDM_SUCCESS; -} -#endif - - -/******************************************************************************/ -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ -/******************************************************************************/ diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_sta.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_sta.c deleted file mode 100644 index d9e1790da0..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_sta.c +++ /dev/null @@ -1,240 +0,0 @@ -/* - * Copyright (c) 2009 Konrad Hammel - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE|EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* INCLUDE ********************************************************************/ -#include "ftmod_sangoma_ss7_main.h" -/******************************************************************************/ - -/* DEFINES ********************************************************************/ -/******************************************************************************/ - -/* GLOBALS ********************************************************************/ -/******************************************************************************/ - -/* PROTOTYPES *****************************************************************/ -int ftmod_ss7_mtp1link_sta(uint32_t id, L1Mngmt *cfm); -int ftmod_ss7_mtp2link_sta(uint32_t id, SdMngmt *cfm); -int ftmod_ss7_mtp3link_sta(uint32_t id, SnMngmt *cfm); -int ftmod_ss7_mtplinkSet_sta(uint32_t id, SnMngmt *cfm); -int ftmod_ss7_isup_intf_sta(uint32_t id, uint8_t *status); -int ftmod_ss7_relay_status(uint32_t id, RyMngmt *cfm); -int ftmod_ss7_isup_ckt_sta(uint32_t id, unsigned char *state); -/******************************************************************************/ - -/* FUNCTIONS ******************************************************************/ -int ftmod_ss7_mtp1link_sta(uint32_t id, L1Mngmt *cfm) -{ - - return 1; -} - -/******************************************************************************/ -int ftmod_ss7_mtp2link_sta(uint32_t id, SdMngmt *cfm) -{ - SdMngmt sta; - Pst pst; - - memset(&sta, 0x0, sizeof(sta)); - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSD; - - sta.hdr.elmId.elmnt = STDLSAP; - sta.hdr.elmId.elmntInst1 = g_ftdm_sngss7_data.cfg.mtp2Link[id].id; - - return(sng_sta_mtp2(&pst, &sta, cfm)); -} - -/******************************************************************************/ -int ftmod_ss7_mtp3link_sta(uint32_t id, SnMngmt *cfm) -{ - SnMngmt sta; - Pst pst; - - memset(&sta, 0x0, sizeof(sta)); - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSN; - - /* check the for the correct ProcId and make sure it goes to the right system */ - if (g_ftdm_sngss7_data.cfg.procId != 1) { - pst.dstProcId = 1; - } - - sta.hdr.elmId.elmnt = STDLSAP; - sta.hdr.elmId.elmntInst1 = g_ftdm_sngss7_data.cfg.mtp3Link[id].id; - - return(sng_sta_mtp3(&pst, &sta, cfm)); -} - -/******************************************************************************/ -int ftmod_ss7_mtplinkSet_sta(uint32_t id, SnMngmt *cfm) -{ - SnMngmt sta; - Pst pst; - - memset(&sta, 0x0, sizeof(sta)); - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSN; - - /* check the for the correct ProcId and make sure it goes to the right system */ - if (g_ftdm_sngss7_data.cfg.procId != 1) { - pst.dstProcId = 1; - } - - sta.hdr.elmId.elmnt = STLNKSET; - sta.hdr.elmId.elmntInst1 = g_ftdm_sngss7_data.cfg.mtpLinkSet[id].id; - sta.hdr.elmId.elmntInst2 = g_ftdm_sngss7_data.cfg.mtpLinkSet[id].links[0]; - - return(sng_sta_mtp3(&pst, &sta, cfm)); -} - -/******************************************************************************/ -int ftmod_ss7_isup_intf_sta(uint32_t id, uint8_t *status) -{ - SiMngmt sta; - SiMngmt cfm; - Pst pst; - int ret; - - memset(&sta, 0x0, sizeof(sta)); - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSI; - - /* check the for the correct ProcId and make sure it goes to the right system */ - if (g_ftdm_sngss7_data.cfg.procId != 1) { - pst.dstProcId = 1; - } - - /* request the status of an inftId */ - sta.hdr.entId.ent = ENTSI; - sta.hdr.entId.inst = S_INST; - sta.hdr.msgType = TSSTA; - sta.hdr.elmId.elmnt = SI_STINTF; - - sta.t.ssta.elmntId.intfId = id; - - ret = sng_sta_isup(&pst, &sta, &cfm); - - *status = cfm.t.ssta.cfm.s.intf.state; - - return(ret); -} - -/******************************************************************************/ -int ftmod_ss7_relay_status(uint32_t id, RyMngmt *cfm) -{ - RyMngmt sta; - Pst pst; - - memset(&sta, 0x0, sizeof(sta)); - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTRY; - - sta.hdr.entId.ent = ENTRY; - sta.hdr.entId.inst = S_INST; - sta.hdr.msgType = TSSTA; - sta.hdr.elmId.elmnt = STCHSTA; - sta.hdr.elmId.elmntInst1 = id; - - - return(sng_sta_relay(&pst, &sta, cfm)); -} - -/******************************************************************************/ -int ftmod_ss7_isup_ckt_sta(uint32_t id, unsigned char *state) -{ - SiMngmt sta; - SiMngmt cfm; - Pst pst; - int ret; - - memset(&sta, 0x0, sizeof(sta)); - - /* initalize the post structure */ - smPstInit(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTSI; - - /* check the for the correct ProcId and make sure it goes to the right system */ - if (g_ftdm_sngss7_data.cfg.procId != 1) { - pst.dstProcId = 1; - } - - /* request the status of an inftId */ - sta.hdr.entId.ent = ENTSI; - sta.hdr.entId.inst = S_INST; - sta.hdr.msgType = TSSTA; - sta.hdr.elmId.elmnt = SI_STCIRGRP; - - sta.t.ssta.elmntId.circuit = id; - sta.t.ssta.param.cirgr.range = 1; - - ret = sng_sta_isup(&pst, &sta, &cfm); - - *state = cfm.t.ssta.cfm.s.cir.state[0]; - - return(ret); -} - -/******************************************************************************/ -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ -/******************************************************************************/ diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_sts.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_sts.c deleted file mode 100644 index 257ccd943a..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_sts.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2009 Konrad Hammel - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE|EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* INCLUDE ********************************************************************/ -#include "ftmod_sangoma_ss7_main.h" -/******************************************************************************/ - -/* DEFINES ********************************************************************/ -/******************************************************************************/ - -/* GLOBALS ********************************************************************/ -/******************************************************************************/ - -/* PROTOTYPES *****************************************************************/ -/******************************************************************************/ - -/* FUNCTIONS ******************************************************************/ -/******************************************************************************/ - -/******************************************************************************/ -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ -/******************************************************************************/ diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c deleted file mode 100644 index 42f1ca82da..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c +++ /dev/null @@ -1,3415 +0,0 @@ -/* - * Copyright (c) 2009, Konrad Hammel - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* INCLUDE ********************************************************************/ -#include "ftmod_sangoma_ss7_main.h" -#ifdef HAVE_ZLIB -#include -#endif -/******************************************************************************/ - -/* DEFINES ********************************************************************/ -/******************************************************************************/ - -/* GLOBALS ********************************************************************/ -uint32_t sngss7_id; -/******************************************************************************/ - -/* PROTOTYPES *****************************************************************/ -int check_for_state_change(ftdm_channel_t *ftdmchan); -int check_for_reset(sngss7_chan_data_t *sngss7_info); - -unsigned long get_unique_id(void); - -ftdm_status_t extract_chan_data(uint32_t circuit, sngss7_chan_data_t **sngss7_info, ftdm_channel_t **ftdmchan); - -ftdm_status_t check_if_rx_grs_started(ftdm_span_t *ftdmspan); -ftdm_status_t check_if_rx_grs_processed(ftdm_span_t *ftdmspan); -ftdm_status_t check_if_rx_gra_started(ftdm_span_t *ftdmspan); -ftdm_status_t check_for_res_sus_flag(ftdm_span_t *ftdmspan); - -ftdm_status_t process_span_ucic(ftdm_span_t *ftdmspan); - -ftdm_status_t encode_subAddrIE_nsap(const char *subAddr, char *subAddrIE, int type); -ftdm_status_t encode_subAddrIE_nat(const char *subAddr, char *subAddrIE, int type); - -int find_mtp2_error_type_in_map(const char *err_type); -int find_link_type_in_map(const char *linkType); -int find_switch_type_in_map(const char *switchType); -int find_ssf_type_in_map(const char *ssfType); -int find_cic_cntrl_in_map(const char *cntrlType); - -ftdm_status_t check_status_of_all_isup_intf(void); -ftdm_status_t check_for_reconfig_flag(ftdm_span_t *ftdmspan); - -void sngss7_send_signal(sngss7_chan_data_t *sngss7_info, ftdm_signal_event_t event_id); -void sngss7_set_sig_status(sngss7_chan_data_t *sngss7_info, ftdm_signaling_status_t status); -ftdm_status_t sngss7_add_var(sngss7_chan_data_t *ss7_info, const char* var, const char* val); -ftdm_status_t sngss7_add_raw_data(sngss7_chan_data_t *sngss7_info, uint8_t* data, ftdm_size_t data_len); -/******************************************************************************/ - -FTDM_ENUM_NAMES(CKT_FLAGS_NAMES, CKT_FLAGS_STRING) -FTDM_STR2ENUM(ftmod_ss7_ckt_state2flag, ftmod_ss7_ckt_flag2str, sng_ckt_flag_t, CKT_FLAGS_NAMES, 31) - -FTDM_ENUM_NAMES(BLK_FLAGS_NAMES, BLK_FLAGS_STRING) -FTDM_STR2ENUM(ftmod_ss7_blk_state2flag, ftmod_ss7_blk_flag2str, sng_ckt_block_flag_t, BLK_FLAGS_NAMES, 31) - -/* FUNCTIONS ******************************************************************/ -static uint8_t get_trillium_val(ftdm2trillium_t *vals, uint8_t ftdm_val, uint8_t default_val); -static uint8_t get_ftdm_val(ftdm2trillium_t *vals, uint8_t trillium_val, uint8_t default_val); -ftdm_status_t four_char_to_hex(const char* in, uint16_t* out) ; -ftdm_status_t hex_to_four_char(uint16_t in, char* out); - - -ftdm_status_t hex_to_char(uint16_t in, char* out, int len); -ftdm_status_t char_to_hex(const char* in, uint16_t* out, int len); - -/* Maps generic FreeTDM CPC codes to SS7 CPC codes */ -ftdm2trillium_t cpc_codes[] = { - {FTDM_CPC_UNKNOWN, CAT_UNKNOWN}, - {FTDM_CPC_OPERATOR_FRENCH, CAT_OPLANGFR}, - {FTDM_CPC_OPERATOR_ENGLISH, CAT_OPLANGENG}, - {FTDM_CPC_OPERATOR_GERMAN, CAT_OPLANGGER}, - {FTDM_CPC_OPERATOR_RUSSIAN, CAT_OPLANGRUS}, - {FTDM_CPC_OPERATOR_SPANISH, CAT_OPLANGSP}, - {FTDM_CPC_ORDINARY, CAT_ORD}, - {FTDM_CPC_PRIORITY, CAT_PRIOR}, - {FTDM_CPC_DATA, CAT_DATA}, - {FTDM_CPC_TEST, CAT_TEST}, - {FTDM_CPC_PAYPHONE, CAT_PAYPHONE}, -}; - -ftdm2trillium_t bc_cap_codes[] = { - {FTDM_BEARER_CAP_SPEECH, ITC_SPEECH}, /* speech as per ATIS-1000113.3.2005 */ - {FTDM_BEARER_CAP_UNRESTRICTED, ITC_UNRDIG}, /* unrestricted digital as per ATIS-1000113.3.2005 */ - {FTDM_BEARER_CAP_RESTRICTED, ITC_UNRDIG}, /* Restricted Digital */ - {FTDM_BEARER_CAP_3_1KHZ_AUDIO, ITC_A31KHZ}, /* 3.1kHz audio as per ATIS-1000113.3.2005 */ - {FTDM_BEARER_CAP_7KHZ_AUDIO, ITC_A7KHZ}, /* 7Khz audio */ - {FTDM_BEARER_CAP_15KHZ_AUDIO, ITC_A15KHZ}, /* 15Khz audio */ - {FTDM_BEARER_CAP_VIDEO, ITC_VIDEO}, /* Video */ -}; - -static uint8_t get_trillium_val(ftdm2trillium_t *vals, uint8_t ftdm_val, uint8_t default_val) -{ - ftdm2trillium_t *val = vals; - while(val++) { - if (val->ftdm_val == ftdm_val) { - return val->trillium_val; - } - } - return default_val; -} - -static uint8_t get_ftdm_val(ftdm2trillium_t *vals, uint8_t trillium_val, uint8_t default_val) -{ - ftdm2trillium_t *val = vals; - while(val++) { - if (val->trillium_val == trillium_val) { - return val->ftdm_val; - } - } - return default_val; -} - -ftdm_status_t copy_cgPtyNum_from_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyNum *cgPtyNum) -{ - return FTDM_SUCCESS; -} - -ftdm_status_t copy_cgPtyNum_to_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyNum *cgPtyNum) -{ - const char *val = NULL; - const char *clg_nadi = NULL; - - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; - - cgPtyNum->eh.pres = PRSNT_NODEF; - - cgPtyNum->natAddrInd.pres = PRSNT_NODEF; - cgPtyNum->natAddrInd.val = g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].clg_nadi; - - - cgPtyNum->scrnInd.pres = PRSNT_NODEF; - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_screen_ind"); - if (!ftdm_strlen_zero(val)) { - cgPtyNum->scrnInd.val = atoi(val); - } else { - cgPtyNum->scrnInd.val = caller_data->screen; - } - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Calling Party Number Screening Ind %d\n", cgPtyNum->scrnInd.val); - - cgPtyNum->presRest.pres = PRSNT_NODEF; - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_pres_ind"); - if (!ftdm_strlen_zero(val)) { - cgPtyNum->presRest.val = atoi(val); - } else { - cgPtyNum->presRest.val = caller_data->pres; - } - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Calling Party Number Presentation Ind %d\n", cgPtyNum->presRest.val); - - cgPtyNum->numPlan.pres = PRSNT_NODEF; - cgPtyNum->numPlan.val = 0x01; - - cgPtyNum->niInd.pres = PRSNT_NODEF; - cgPtyNum->niInd.val = 0x00; - - /* check if the user would like a custom NADI value for the calling Pty Num */ - clg_nadi = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_clg_nadi"); - if (!ftdm_strlen_zero(clg_nadi)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Calling NADI value \"%s\"\n", clg_nadi); - cgPtyNum->natAddrInd.val = atoi(clg_nadi); - } - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Calling Party Number NADI value %d\n", cgPtyNum->natAddrInd.val); - - return copy_tknStr_to_sngss7(caller_data->cid_num.digits, &cgPtyNum->addrSig, &cgPtyNum->oddEven); -} - -ftdm_status_t copy_cdPtyNum_from_sngss7(ftdm_channel_t *ftdmchan, SiCdPtyNum *cdPtyNum) -{ - char var[FTDM_DIGITS_LIMIT]; - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - - if (cdPtyNum->eh.pres == PRSNT_NODEF && - cdPtyNum->natAddrInd.pres == PRSNT_NODEF) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Called Party Number NADI %d\n", cdPtyNum->natAddrInd.val); - sprintf(var, "%d", cdPtyNum->natAddrInd.val); - sngss7_add_var(sngss7_info, "ss7_cld_nadi", var); - } - - return FTDM_SUCCESS; -} - - -ftdm_status_t copy_cdPtyNum_to_sngss7(ftdm_channel_t *ftdmchan, SiCdPtyNum *cdPtyNum) -{ - const char *val = NULL; - ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - - cdPtyNum->eh.pres = PRSNT_NODEF; - - cdPtyNum->natAddrInd.pres = PRSNT_NODEF; - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_cld_nadi"); - if (!ftdm_strlen_zero(val)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Called NADI value \"%s\"\n", val); - cdPtyNum->natAddrInd.val = atoi(val); - } else { - cdPtyNum->natAddrInd.val = g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].cld_nadi; - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "No user supplied NADI value found for CLD, using \"%d\"\n", cdPtyNum->natAddrInd.val); - } - - cdPtyNum->numPlan.pres = PRSNT_NODEF; - cdPtyNum->numPlan.val = 0x01; - - cdPtyNum->innInd.pres = PRSNT_NODEF; - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_cld_inn"); - if (!ftdm_strlen_zero(val)) { - cdPtyNum->innInd.val = atoi(val); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Called INN value \"%s\"\n", val); - } else { - cdPtyNum->innInd.val = 0x01; - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "No user supplied Called INN value, set to default value 0x01\n"); - } - - return copy_tknStr_to_sngss7(caller_data->dnis.digits, &cdPtyNum->addrSig, &cdPtyNum->oddEven); -} - -ftdm_status_t copy_locPtyNum_from_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyNum *locPtyNum) -{ - return FTDM_SUCCESS; -} - -ftdm_status_t copy_locPtyNum_to_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyNum *locPtyNum) -{ - const char *val = NULL; - const char *loc_nadi = NULL; - int pres_val = PRSNT_NODEF; - - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; - - if (!strcasecmp(caller_data->loc.digits, "NULL")) { - pres_val = NOTPRSNT; - return FTDM_SUCCESS; - } - - locPtyNum->eh.pres = pres_val; - locPtyNum->natAddrInd.pres = pres_val; - locPtyNum->natAddrInd.val = g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].loc_nadi; - - locPtyNum->scrnInd.pres = pres_val; - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_loc_screen_ind"); - if (!ftdm_strlen_zero(val)) { - locPtyNum->scrnInd.val = atoi(val); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Location Screening Ind %d\n", locPtyNum->scrnInd.val); - } else { - locPtyNum->scrnInd.val = caller_data->screen; - } - - locPtyNum->presRest.pres = pres_val; - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_loc_pres_ind"); - if (!ftdm_strlen_zero(val)) { - locPtyNum->presRest.val = atoi(val); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Location Presentation Ind %d\n", locPtyNum->presRest.val); - } else { - locPtyNum->presRest.val = caller_data->pres; - } - - locPtyNum->numPlan.pres = pres_val; - locPtyNum->numPlan.val = 0x01; - - locPtyNum->niInd.pres = pres_val; - locPtyNum->niInd.val = 0x00; - - /* check if the user would like a custom NADI value for the Location Reference */ - loc_nadi = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_loc_nadi"); - if (!ftdm_strlen_zero(loc_nadi)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Location Reference NADI value \"%s\"\n", loc_nadi); - locPtyNum->natAddrInd.val = atoi(loc_nadi); - } else { - locPtyNum->natAddrInd.val = g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].loc_nadi; - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "No user supplied NADI value found for LOC, using \"%d\"\n", locPtyNum->natAddrInd.val); - } - - return copy_tknStr_to_sngss7(caller_data->loc.digits, &locPtyNum->addrSig, &locPtyNum->oddEven); -} - -ftdm_status_t copy_genNmb_to_sngss7(ftdm_channel_t *ftdmchan, SiGenNum *genNmb) -{ - const char *val = NULL; - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_gn_digits"); - if (!ftdm_strlen_zero(val)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Generic Number qualifier \"%s\"\n", val); - if (copy_tknStr_to_sngss7((char*)val, &genNmb->addrSig, &genNmb->oddEven) != FTDM_SUCCESS) { - return FTDM_FAIL; - } - } else { - return FTDM_SUCCESS; - } - - genNmb->eh.pres = PRSNT_NODEF; - genNmb->addrSig.pres = PRSNT_NODEF; - - genNmb->nmbQual.pres = PRSNT_NODEF; - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_gn_numqual"); - if (!ftdm_strlen_zero(val)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Generic Number \"%s\"\n", val); - genNmb->nmbQual.val = atoi(val); - } else { - genNmb->nmbQual.val = g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].gn_nmbqual; - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "No user supplied Generic Number \n"); - } - genNmb->natAddrInd.pres = PRSNT_NODEF; - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_gn_nadi"); - if (!ftdm_strlen_zero(val)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Generic Number \"nature of address\" \"%s\"\n", val); - genNmb->natAddrInd.val = atoi(val); - } else { - genNmb->natAddrInd.val = g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].gn_nadi; - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "No user supplied Generic Number \"nature of address\" \"%d\"\n", genNmb->natAddrInd.val); - } - genNmb->scrnInd.pres = PRSNT_NODEF; - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_gn_screen_ind"); - if (!ftdm_strlen_zero(val)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Generic Number \"screening indicator\" \"%s\"\n", val); - genNmb->scrnInd.val = atoi(val); - } else { - genNmb->natAddrInd.val = g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].gn_screen_ind; - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "No user supplied Generic Number \"screening indicator\" \"%d\"\n", genNmb->natAddrInd.val); - } - genNmb->presRest.pres = PRSNT_NODEF; - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_gn_pres_ind"); - if (!ftdm_strlen_zero(val)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Generic Number \"presentation indicator\" \"%s\"\n", val); - genNmb->presRest.val = atoi(val); - } else { - genNmb->presRest.val = g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].gn_pres_ind; - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "No user supplied Generic Number \"presentation indicator\" \"%d\"\n", genNmb->presRest.val); - } - genNmb->numPlan.pres = PRSNT_NODEF; - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_gn_npi"); - if (!ftdm_strlen_zero(val)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Generic Number \"numbering plan\" \"%s\"\n", val); - genNmb->numPlan.val = atoi(val); - } else { - genNmb->numPlan.val = g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].gn_npi; - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "No user supplied Generic Number \"numbering plan\" \"%d\"\n", genNmb->numPlan.val); - } - genNmb->niInd.pres = PRSNT_NODEF; - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_gn_num_inc_ind"); - if (!ftdm_strlen_zero(val)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Generic Number \"number incomplete indicator\" \"%s\"\n", val); - genNmb->niInd.val = atoi(val); - } else { - genNmb->niInd.val = g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].gn_num_inc_ind; - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "No user supplied Generic Number \"number incomplete indicator\" \"%d\"\n", genNmb->niInd.val); - } - return FTDM_SUCCESS; -} - -ftdm_status_t copy_genNmb_from_sngss7(ftdm_channel_t *ftdmchan, SiGenNum *genNmb) -{ - char val[64]; - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - - memset(val, 0, sizeof(val)); - - if (genNmb->eh.pres != PRSNT_NODEF || genNmb->addrSig.pres != PRSNT_NODEF) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "No Generic Number available\n"); - return FTDM_SUCCESS; - } - - copy_tknStr_from_sngss7(genNmb->addrSig, val, genNmb->oddEven); - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Generic Number:%s\n", val); - sngss7_add_var(sngss7_info, "ss7_gn_digits", val); - - if (genNmb->nmbQual.pres == PRSNT_NODEF) { - snprintf(val, sizeof(val), "%d", genNmb->nmbQual.val); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Generic Number \"number qualifier\" \"%s\"\n", val); - sngss7_add_var(sngss7_info, "ss7_gn_numqual", val); - } - - if (genNmb->natAddrInd.pres == PRSNT_NODEF) { - snprintf(val, sizeof(val), "%d", genNmb->natAddrInd.val); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Generic Number \"nature of address\" \"%s\"\n", val); - sngss7_add_var(sngss7_info, "ss7_gn_nadi", val); - } - - if (genNmb->scrnInd.pres == PRSNT_NODEF) { - snprintf(val, sizeof(val), "%d", genNmb->scrnInd.val); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Generic Number \"screening indicator\" \"%s\"\n", val); - sngss7_add_var(sngss7_info, "ss7_gn_screen_ind", val); - } - - if (genNmb->presRest.pres == PRSNT_NODEF) { - snprintf(val, sizeof(val), "%d", genNmb->presRest.val); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Generic Number \"presentation indicator\" \"%s\"\n", val); - sngss7_add_var(sngss7_info, "ss7_gn_pres_ind", val); - } - - if (genNmb->numPlan.pres == PRSNT_NODEF) { - snprintf(val, sizeof(val), "%d", genNmb->numPlan.val); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Generic Number \"numbering plan\" \"%s\"\n", val); - sngss7_add_var(sngss7_info, "ss7_gn_npi", val); - } - - if (genNmb->niInd.pres == PRSNT_NODEF) { - snprintf(val, sizeof(val), "%d", genNmb->niInd.val); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Generic Number \"number incomplete indicator\" \"%s\"\n", val); - sngss7_add_var(sngss7_info, "ss7_gn_num_inc_ind", val); - } - - return FTDM_SUCCESS; -} - -ftdm_status_t copy_redirgNum_to_sngss7(ftdm_channel_t *ftdmchan, SiRedirNum *redirgNum) -{ - const char* val = NULL; - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; - - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_rdnis_digits"); - if (!ftdm_strlen_zero(val)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Redirection Number\"%s\"\n", val); - if (copy_tknStr_to_sngss7((char*)val, &redirgNum->addrSig, &redirgNum->oddEven) != FTDM_SUCCESS) { - return FTDM_FAIL; - } - } else if (!ftdm_strlen_zero(caller_data->rdnis.digits)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Redirection Number\"%s\"\n", caller_data->rdnis.digits); - if (copy_tknStr_to_sngss7(caller_data->rdnis.digits, &redirgNum->addrSig, &redirgNum->oddEven) != FTDM_SUCCESS) { - return FTDM_FAIL; - } - } else { - - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_rdnis_pres_ind"); - if (!ftdm_strlen_zero(val)) { - redirgNum->presRest.val = atoi(val); - } - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Redirecting Number Address Presentation Restricted Ind:%d\n", redirgNum->presRest.val); - - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "No user supplied Redirection Number\n"); - return FTDM_SUCCESS; - } - - redirgNum->eh.pres = PRSNT_NODEF; - - /* Nature of address indicator */ - redirgNum->natAddr.pres = PRSNT_NODEF; - - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_rdnis_nadi"); - if (!ftdm_strlen_zero(val)) { - redirgNum->natAddr.val = atoi(val); - } else { - redirgNum->natAddr.val = g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].rdnis_nadi; - } - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Redirecting Number NADI:%d\n", redirgNum->natAddr.val); - - /* Screening indicator */ - redirgNum->scrInd.pres = PRSNT_NODEF; - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_rdnis_screen_ind"); - if (!ftdm_strlen_zero(val)) { - redirgNum->scrInd.val = atoi(val); - } else { - redirgNum->scrInd.val = FTDM_SCREENING_VERIFIED_PASSED; - } - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Redirecting Number Screening Ind:%d\n", redirgNum->scrInd.val); - - /* Address presentation restricted ind */ - redirgNum->presRest.pres = PRSNT_NODEF; - - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_rdnis_pres_ind"); - if (!ftdm_strlen_zero(val)) { - redirgNum->presRest.val = atoi(val); - } else { - redirgNum->presRest.val = FTDM_PRES_ALLOWED; - } - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Redirecting Number Address Presentation Restricted Ind:%d\n", redirgNum->presRest.val); - - /* Numbering plan */ - redirgNum->numPlan.pres = PRSNT_NODEF; - - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_rdnis_plan"); - if (!ftdm_strlen_zero(val)) { - redirgNum->numPlan.val = atoi(val); - } else { - redirgNum->numPlan.val = caller_data->rdnis.plan; - } - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Redirecting Number Numbering plan:%d\n", redirgNum->numPlan.val); - - return copy_tknStr_to_sngss7(caller_data->rdnis.digits, &redirgNum->addrSig, &redirgNum->oddEven); -} - -ftdm_status_t copy_redirgNum_from_sngss7(ftdm_channel_t *ftdmchan, SiRedirNum *redirgNum) -{ - char val[20]; - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; - - if (redirgNum->eh.pres != PRSNT_NODEF || redirgNum->addrSig.pres != PRSNT_NODEF) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "No Redirecting Number available\n"); - return FTDM_SUCCESS; - } - - copy_tknStr_from_sngss7(redirgNum->addrSig, ftdmchan->caller_data.rdnis.digits, redirgNum->oddEven); - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Redirecting Number:%s\n", ftdmchan->caller_data.rdnis.digits); - snprintf(val, sizeof(val), "%s", ftdmchan->caller_data.rdnis.digits); - sngss7_add_var(sngss7_info, "ss7_rdnis_digits", val); - - - if (redirgNum->natAddr.pres == PRSNT_NODEF) { - snprintf(val, sizeof(val), "%d", redirgNum->natAddr.val); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Redirecting Number NADI:%s\n", val); - sngss7_add_var(sngss7_info, "ss7_rdnis_nadi", val); - caller_data->rdnis.type = redirgNum->natAddr.val; - } - - if (redirgNum->scrInd.pres == PRSNT_NODEF) { - snprintf(val, sizeof(val), "%d", redirgNum->scrInd.val); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Redirecting Number Screening Ind:%s\n", val); - sngss7_add_var(sngss7_info, "ss7_rdnis_screen_ind", val); - } - - if (redirgNum->presRest.pres == PRSNT_NODEF) { - snprintf(val, sizeof(val), "%d", redirgNum->presRest.val); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Redirecting Number Presentation Ind:%s\n", val); - sngss7_add_var(sngss7_info, "ss7_rdnis_pres_ind", val); - } - - if (redirgNum->numPlan.pres == PRSNT_NODEF) { - snprintf(val, sizeof(val), "%d", redirgNum->numPlan.val); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Redirecting Number Numbering plan:%s\n", val); - sngss7_add_var(sngss7_info, "ss7_rdnis_plan", val); - caller_data->rdnis.plan = redirgNum->numPlan.val; - } - - return FTDM_SUCCESS; -} - -ftdm_status_t copy_redirgInfo_from_sngss7(ftdm_channel_t *ftdmchan, SiRedirInfo *redirInfo) -{ - char val[20]; - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - - if (redirInfo->eh.pres != PRSNT_NODEF ) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "No Redirecting Information available\n"); - return FTDM_SUCCESS; - } - - - if (redirInfo->redirInd.pres == PRSNT_NODEF) { - snprintf(val, sizeof(val), "%d", redirInfo->redirInd.val); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Redirection Information - redirection indicator:%s\n", val); - sngss7_add_var(sngss7_info, "ss7_rdinfo_indicator", val); - } - - if (redirInfo->origRedirReas.pres == PRSNT_NODEF) { - snprintf(val, sizeof(val), "%d", redirInfo->origRedirReas.val); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Redirection Information - original redirection reason:%s\n", val); - sngss7_add_var(sngss7_info, "ss7_rdinfo_orig", val); - } - - if (redirInfo->redirCnt.pres == PRSNT_NODEF) { - snprintf(val, sizeof(val), "%d", redirInfo->redirCnt.val); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Redirection Information - redirection count:%s\n", val); - sngss7_add_var(sngss7_info, "ss7_rdinfo_count", val); - } - - if (redirInfo->redirReas.pres == PRSNT_NODEF) { - snprintf(val, sizeof(val), "%d", redirInfo->redirReas.val); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Redirection Information - redirection reason:%s\n", val); - sngss7_add_var(sngss7_info, "ss7_rdinfo_reason", val); - } - - return FTDM_SUCCESS; -} - -ftdm_status_t copy_redirgInfo_to_sngss7(ftdm_channel_t *ftdmchan, SiRedirInfo *redirInfo) -{ - const char* val = NULL; - int bProceed = 0; - - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_rdinfo_indicator"); - if (!ftdm_strlen_zero(val)) { - redirInfo->redirInd.val = atoi(val); - redirInfo->redirInd.pres = 1; - bProceed = 1; - } else { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "No user supplied Redirection Information on Redirection Indicator\n"); - } - - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_rdinfo_orig"); - if (!ftdm_strlen_zero(val)) { - redirInfo->origRedirReas.val = atoi(val); - redirInfo->origRedirReas.pres = 1; - bProceed = 1; - } else { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "No user supplied Redirection Information on Original Reasons\n"); - } - - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_rdinfo_count"); - if (!ftdm_strlen_zero(val)) { - redirInfo->redirCnt.val = atoi(val); - redirInfo->redirCnt.pres= 1; - bProceed = 1; - } else { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "No user supplied Redirection Information on Redirection Count\n"); - } - - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_rdinfo_reason"); - if (!ftdm_strlen_zero(val)) { - redirInfo->redirReas.val = atoi(val); - redirInfo->redirReas.pres = 1; - bProceed = 1; - } else { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "No user supplied Redirection Information on Redirection Reasons\n"); - } - - if( bProceed == 1 ) { - redirInfo->eh.pres = PRSNT_NODEF; - } else { - redirInfo->eh.pres = NOTPRSNT; - } - - return FTDM_SUCCESS; -} - -ftdm_status_t copy_access_transport_from_sngss7(ftdm_channel_t *ftdmchan, SiAccTrnspt *accTrnspt) -{ - char val[3*((MF_SIZE_TKNSTRE + 7) & 0xff8)]; - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - - if (accTrnspt->eh.pres != PRSNT_NODEF || accTrnspt->infoElmts.pres !=PRSNT_NODEF) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "No Access Transport IE available\n"); - return FTDM_SUCCESS; - } - - ftdm_url_encode((const char*)accTrnspt->infoElmts.val, val, accTrnspt->infoElmts.len); - sngss7_add_var (sngss7_info, "ss7_access_transport_urlenc", val); - - return FTDM_SUCCESS; -} -ftdm_status_t copy_access_transport_to_sngss7(ftdm_channel_t *ftdmchan, SiAccTrnspt *accTrnspt) -{ - const char *val = NULL; - - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_access_transport_urlenc"); - if (ftdm_strlen_zero(val)) { - accTrnspt->eh.pres = NOTPRSNT; - accTrnspt->infoElmts.pres = NOTPRSNT; - } - else { - char *val_dec = NULL; - int val_len = strlen (val); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found Access Transport IE encoded : %s\n", val); - - accTrnspt->eh.pres = PRSNT_NODEF; - accTrnspt->infoElmts.pres = PRSNT_NODEF; - - val_dec = ftdm_strdup(val); - ftdm_url_decode(val_dec, (ftdm_size_t*)&val_len); - memcpy (accTrnspt->infoElmts.val, val_dec, val_len); - accTrnspt->infoElmts.len = val_len; - ftdm_safe_free(val_dec); - } - return FTDM_SUCCESS; -} - -ftdm_status_t copy_ocn_from_sngss7(ftdm_channel_t *ftdmchan, SiOrigCdNum *origCdNum) -{ - char val[20]; - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - - if (origCdNum->eh.pres != PRSNT_NODEF ) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "No Original Called Number available\n"); - return FTDM_SUCCESS; - } - - if (origCdNum->addrSig.pres == PRSNT_NODEF) { - copy_tknStr_from_sngss7(origCdNum->addrSig, val, origCdNum->oddEven); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Original Called Number - Digits: %s\n", val); - sngss7_add_var(sngss7_info, "ss7_ocn", val); - } - - if (origCdNum->natAddr.pres == PRSNT_NODEF) { - snprintf(val, sizeof(val), "%d", origCdNum->natAddr.val); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Original Called Number - NADI: %s\n", val); - sngss7_add_var(sngss7_info, "ss7_ocn_nadi", val); - } - - if (origCdNum->numPlan.pres == PRSNT_NODEF) { - snprintf(val, sizeof(val), "%d", origCdNum->numPlan.val); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Original Called Number - Plan: %s\n", val); - sngss7_add_var(sngss7_info, "ss7_ocn_plan", val); - } - - if (origCdNum->presRest.pres == PRSNT_NODEF) { - snprintf(val, sizeof(val), "%d", origCdNum->presRest.val); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Original Called Number - Presentation: %s\n", val); - sngss7_add_var(sngss7_info, "ss7_ocn_pres", val); - } - - return FTDM_SUCCESS; -} - -ftdm_status_t copy_ocn_to_sngss7(ftdm_channel_t *ftdmchan, SiOrigCdNum *origCdNum) -{ - const char *val = NULL; - int bProceed = 0; - - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_ocn"); - if (!ftdm_strlen_zero(val)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Original Called Number - Digits: %s\n", val); - if (copy_tknStr_to_sngss7((char*)val, &origCdNum->addrSig, &origCdNum->oddEven) != FTDM_SUCCESS) { - return FTDM_FAIL; - } - origCdNum->addrSig.pres = 1; - } else { - return FTDM_SUCCESS; - } - - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_ocn_nadi"); - if (!ftdm_strlen_zero(val)) { - origCdNum->natAddr.val = atoi(val); - origCdNum->natAddr.pres = 1; - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Original Called Number - NADI: %s\n", val); - bProceed = 1; - } else { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "No user supplied Original Called Number NADI value\n"); - } - - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_ocn_plan"); - if (!ftdm_strlen_zero(val)) { - origCdNum->numPlan.val = atoi(val); - origCdNum->numPlan.pres = 1; - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Original Called Number - Plan: %s\n", val); - bProceed = 1; - } else { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "No user supplied Original Called Number Plan value\n"); - } - - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_ocn_pres"); - if (!ftdm_strlen_zero(val)) { - origCdNum->presRest.val = atoi(val); - origCdNum->presRest.pres = 1; - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Original Called Number - Presentation: %s\n", val); - bProceed = 1; - } else { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "No user supplied Original Called Number Presentation value\n"); - } - - if( bProceed == 1 ) { - origCdNum->eh.pres = PRSNT_NODEF; - } else { - origCdNum->eh.pres = NOTPRSNT; - } - - return FTDM_SUCCESS; -} - -ftdm_status_t copy_cgPtyCat_to_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyCat *cgPtyCat) -{ - ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; - - cgPtyCat->eh.pres = PRSNT_NODEF; - cgPtyCat->cgPtyCat.pres = PRSNT_NODEF; - - cgPtyCat->cgPtyCat.val = get_trillium_val(cpc_codes, caller_data->cpc, CAT_ORD); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Calling Party Category:0x%x\n",cgPtyCat->cgPtyCat.val); - return FTDM_SUCCESS; -} - -ftdm_status_t copy_cgPtyCat_from_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyCat *cgPtyCat) -{ - ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; - - if (cgPtyCat->eh.pres == PRSNT_NODEF && - cgPtyCat->cgPtyCat.pres == PRSNT_NODEF) { - - caller_data->cpc = get_ftdm_val(cpc_codes, cgPtyCat->cgPtyCat.val, FTDM_CPC_UNKNOWN); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Calling Party Category:0x%x\n", cgPtyCat->cgPtyCat.val); - } - return FTDM_SUCCESS; -} - - -ftdm_status_t copy_accTrnspt_to_sngss7(ftdm_channel_t *ftdmchan, SiAccTrnspt *accTrnspt) -{ - const char *clg_subAddr = NULL; - const char *cld_subAddr = NULL; - char subAddrIE[MAX_SIZEOF_SUBADDR_IE]; - - /* check if the user would like us to send a clg_sub-address */ - clg_subAddr = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_clg_subaddr"); - if (!ftdm_strlen_zero(clg_subAddr)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Calling Sub-Address value \"%s\"\n", clg_subAddr); - - /* clean out the subAddrIE */ - memset(subAddrIE, 0x0, sizeof(subAddrIE)); - - /* check the first character in the sub-address to see what type of encoding to use */ - switch (clg_subAddr[0]) { - case '0': /* NSAP */ - encode_subAddrIE_nsap(&clg_subAddr[1], subAddrIE, SNG_CALLING); - break; - case '1': /* national variant */ - encode_subAddrIE_nat(&clg_subAddr[1], subAddrIE, SNG_CALLING); - break; - default: - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Invalid Calling Sub-Address encoding requested: %c\n", clg_subAddr[0]); - break; - } /* switch (cld_subAddr[0]) */ - - - /* if subaddIE is still empty don't copy it in */ - if (subAddrIE[0] != '0') { - /* check if the clg_subAddr has already been added */ - if (accTrnspt->eh.pres == PRSNT_NODEF) { - /* append the subAddrIE */ - memcpy(&accTrnspt->infoElmts.val[accTrnspt->infoElmts.len], subAddrIE, (subAddrIE[1] + 2)); - accTrnspt->infoElmts.len = accTrnspt->infoElmts.len +subAddrIE[1] + 2; - } else { - /* fill in from the beginning */ - accTrnspt->eh.pres = PRSNT_NODEF; - accTrnspt->infoElmts.pres = PRSNT_NODEF; - memcpy(accTrnspt->infoElmts.val, subAddrIE, (subAddrIE[1] + 2)); - accTrnspt->infoElmts.len = subAddrIE[1] + 2; - } - } - } - - /* check if the user would like us to send a cld_sub-address */ - cld_subAddr = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_cld_subaddr"); - if ((cld_subAddr != NULL) && (*cld_subAddr)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Called Sub-Address value \"%s\"\n", cld_subAddr); - - /* clean out the subAddrIE */ - memset(subAddrIE, 0x0, sizeof(subAddrIE)); - - /* check the first character in the sub-address to see what type of encoding to use */ - switch (cld_subAddr[0]) { - case '0': /* NSAP */ - encode_subAddrIE_nsap(&cld_subAddr[1], subAddrIE, SNG_CALLED); - break; - case '1': /* national variant */ - encode_subAddrIE_nat(&cld_subAddr[1], subAddrIE, SNG_CALLED); - break; - default: - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Invalid Called Sub-Address encoding requested: %c\n", cld_subAddr[0]); - break; - } /* switch (cld_subAddr[0]) */ - - /* if subaddIE is still empty don't copy it in */ - if (subAddrIE[0] != '0') { - /* check if the cld_subAddr has already been added */ - if (accTrnspt->eh.pres == PRSNT_NODEF) { - /* append the subAddrIE */ - memcpy(&accTrnspt->infoElmts.val[accTrnspt->infoElmts.len], subAddrIE, (subAddrIE[1] + 2)); - accTrnspt->infoElmts.len = accTrnspt->infoElmts.len +subAddrIE[1] + 2; - } else { - /* fill in from the beginning */ - accTrnspt->eh.pres = PRSNT_NODEF; - accTrnspt->infoElmts.pres = PRSNT_NODEF; - memcpy(accTrnspt->infoElmts.val, subAddrIE, (subAddrIE[1] + 2)); - accTrnspt->infoElmts.len = subAddrIE[1] + 2; - } - } - } /* if ((cld_subAddr != NULL) && (*cld_subAddr)) */ - return FTDM_SUCCESS; -} - -ftdm_status_t copy_natConInd_to_sngss7(ftdm_channel_t *ftdmchan, SiNatConInd *natConInd) -{ - /* copy down the nature of connection indicators */ - natConInd->eh.pres = PRSNT_NODEF; - natConInd->satInd.pres = PRSNT_NODEF; - natConInd->satInd.val = 0; /* no satellite circuit */ - natConInd->contChkInd.pres = PRSNT_NODEF; - natConInd->contChkInd.val = CONTCHK_NOTREQ; - natConInd->echoCntrlDevInd.pres = PRSNT_NODEF; - natConInd->echoCntrlDevInd.val = ECHOCDEV_INCL; - return FTDM_SUCCESS; -} - -ftdm_status_t four_char_to_hex(const char* in, uint16_t* out) -{ - int i= 4; - char a, b, c, d; - if (!in || 4>strlen(in)) { - return FTDM_FAIL; - } - while(i) - { - switch((char)*(in+(4-i))) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (i==4) { - d = *(in+(4-i)) - 48; - } else if (i==3) { - c = *(in+(4-i)) - 48; - } else if (i==2) { - b = *(in+(4-i)) - 48; - } else { - a = *(in+(4-i)) - 48; - } - break; - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - if (i==4) { - d = *(in+(4-i)) - 55; - } else if (i==3) { - c = *(in+(4-i)) - 55; - } else if (i==2) { - b = *(in+(4-i)) - 55; - } else { - a = *(in+(4-i)) - 55; - } - break; - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - if (i==4) { - d = *(in+(4-i)) - 87; - } else if (i==3) { - c = *(in+(4-i)) - 87; - } else if (i==2) { - b = *(in+(4-i)) - 87; - } else { - a = *(in+(4-i)) - 87; - } - break; - default: - SS7_ERROR("Invalid character found when decoding hex string, %c!\n", *(in+(4-i)) ); - break; - } - i--; - }; - - *out |= d; - *out = *out<<4; - *out |= c; - *out = *out<<4; - *out |= b; - *out = *out<<4; - *out |= a; - - return FTDM_SUCCESS; -} - -ftdm_status_t char_to_hex(const char* in, uint16_t* out, int len) -{ - int i= len; - char *val = ftdm_malloc(len*sizeof(char)); - - if (!val ||!in || len>strlen(in)) { - return FTDM_FAIL; - } - - while(i) - { - switch((char)*(in+(len-i))) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - *(val+(len-i)) = *(in+(len-i)) - 48; - break; - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - *(val+(len-i)) = *(in+(len-i)) - 55; - break; - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - *(val+(len-i)) = *(in+(len-i)) - 87; - break; - default: - SS7_ERROR("Invalid character found when decoding hex string, %c!\n", *(in+(len-i)) ); - break; - } - i--; - }; - - for (i=0; i<=len-1; i++) { - *out = *out << 4; - *out |= *(val+i); - } - - return FTDM_SUCCESS; -} - - - -ftdm_status_t hex_to_char(uint16_t in, char* out, int len) -{ - char val=0; - int mask = 0xf; - int i=0; - if (!out) { - return FTDM_SUCCESS; - } - - for (i=len-1; i>=0; i--) { - val = (in & (mask<<(4*i))) >> (4*i); - sprintf (out+(len-1-i), "%x", val); - } - - return FTDM_SUCCESS; -} -ftdm_status_t hex_to_four_char(uint16_t in, char* out) -{ - char val=0; - int mask = 0xf; - int i=0; - if (!out) { - return FTDM_SUCCESS; - } - - for (i=3; i>=0; i--) { - val = (in & (mask<<(4*i))) >> (4*i); - sprintf (out+(3-i), "%x", val); - } - - return FTDM_SUCCESS; -} - -ftdm_status_t copy_NatureOfConnection_to_sngss7(ftdm_channel_t *ftdmchan, SiNatConInd *natConInd) -{ - const char *val = NULL; - - natConInd->eh.pres = PRSNT_NODEF; - natConInd->satInd.pres = PRSNT_NODEF; - natConInd->contChkInd.pres = PRSNT_NODEF;; - natConInd->echoCntrlDevInd.pres = PRSNT_NODEF; - - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam_nature_connection_hex"); - if (!ftdm_strlen_zero(val)) { - uint16_t val_hex = 0; - if (char_to_hex (val, &val_hex, 2) == FTDM_FAIL) { - SS7_ERROR ("Wrong value set in ss7_iam_nature_connection_hex variable. Please correct the error. Setting to default values.\n" ); - } else { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "hex = 0x%x\n", val_hex); - natConInd->satInd.val = (val_hex & 0x3); - natConInd->contChkInd.val = (val_hex & 0xc)>>2; - natConInd->echoCntrlDevInd.val = (val_hex & 0x10) >> 4; - - return FTDM_SUCCESS; - } - } - - natConInd->satInd.val = 0; - natConInd->contChkInd.val = 0; - natConInd->echoCntrlDevInd.val = 0; - - return FTDM_SUCCESS; -} - -ftdm_status_t copy_NatureOfConnection_from_sngss7(ftdm_channel_t *ftdmchan, SiNatConInd *natConInd ) -{ - char val[3]; - uint16_t val_hex = 0; - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - - memset (val, 0, 3*sizeof(char)); - if (natConInd->eh.pres != PRSNT_NODEF ) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "No nature of connection indicator IE available\n"); - return FTDM_SUCCESS; - } - - val_hex |= natConInd->satInd.val; - val_hex |= natConInd->contChkInd.val << 2; - val_hex |= natConInd->echoCntrlDevInd.val <<4; - hex_to_char(val_hex, val, 2) ; - - sngss7_add_var(sngss7_info, "ss7_iam_nature_connection_hex", val); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Nature of connection indicator Hex: 0x%s\n", val); - - return FTDM_SUCCESS; -} - -ftdm_status_t copy_fwdCallInd_hex_from_sngss7(ftdm_channel_t *ftdmchan, SiFwdCallInd *fwdCallInd) -{ - char val[5]; - uint16_t val_hex = 0; - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - - memset (val, 0, 5*sizeof(char)); - if (fwdCallInd->eh.pres != PRSNT_NODEF ) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "No forward call indicator IE available\n"); - return FTDM_SUCCESS; - } - - val_hex |= fwdCallInd->natIntCallInd.val << 8; - val_hex |= (fwdCallInd->end2EndMethInd.val & 0x1) << 9; - val_hex |= ((fwdCallInd->end2EndMethInd.val & 0x2)>>1) << 10; - val_hex |= fwdCallInd->intInd.val << 11; - val_hex |= fwdCallInd->end2EndInfoInd.val << 12; - val_hex |= fwdCallInd->isdnUsrPrtInd.val << 13; - val_hex |= (fwdCallInd->isdnUsrPrtPrfInd.val & 0x1) << 14; - val_hex |= ((fwdCallInd->isdnUsrPrtPrfInd.val & 0x2)>>1) << 15; - - val_hex |= fwdCallInd->isdnAccInd.val; - hex_to_four_char(val_hex, val) ; - - sngss7_add_var(sngss7_info, "ss7_iam_fwd_ind_hex", val); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Forwad Call Indicator Hex: 0x%s\n", val); - - return FTDM_SUCCESS; -} - -ftdm_status_t copy_fwdCallInd_to_sngss7(ftdm_channel_t *ftdmchan, SiFwdCallInd *fwdCallInd) -{ - const char *val = NULL; - int acc_val = ISDNACC_ISDN; - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - - fwdCallInd->eh.pres = PRSNT_NODEF; - fwdCallInd->natIntCallInd.pres = PRSNT_NODEF; - fwdCallInd->end2EndMethInd.pres = PRSNT_NODEF; - fwdCallInd->intInd.pres = PRSNT_NODEF; - fwdCallInd->end2EndInfoInd.pres = PRSNT_NODEF; - fwdCallInd->isdnUsrPrtInd.pres = PRSNT_NODEF; - fwdCallInd->isdnUsrPrtPrfInd.pres = PRSNT_NODEF; - fwdCallInd->isdnAccInd.pres = PRSNT_NODEF; - fwdCallInd->sccpMethInd.pres = PRSNT_NODEF; - fwdCallInd->sccpMethInd.val = SCCPMTH_NOIND; - - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam_fwd_ind_hex"); - if (!ftdm_strlen_zero(val)) { - uint16_t val_hex = 0; - if (four_char_to_hex (val, &val_hex) == FTDM_FAIL) { - SS7_ERROR ("Wrong value set in iam_fwd_ind_HEX variable. Please correct the error. Setting to default values.\n" ); - } else { - fwdCallInd->natIntCallInd.val = (val_hex & 0x100)>>8; - fwdCallInd->end2EndMethInd.val = (val_hex & 0x600)>>9; - fwdCallInd->intInd.val = (val_hex & 0x800)>>11; - fwdCallInd->end2EndInfoInd.val = (val_hex & 0x1000)>>12; - fwdCallInd->isdnUsrPrtInd.val = (val_hex & 0x2000)>>13; - fwdCallInd->isdnUsrPrtPrfInd.val = (val_hex & 0xC000)>>14; - fwdCallInd->isdnUsrPrtPrfInd.val = (fwdCallInd->isdnUsrPrtPrfInd.val==0x03)?0x0:fwdCallInd->isdnUsrPrtPrfInd.val; - fwdCallInd->isdnAccInd.val = val_hex & 0x1; - - if ((g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].switchType == LSI_SW_ANS88) || - (g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].switchType == LSI_SW_ANS92) || - (g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].switchType == LSI_SW_ANS95)) { - - /* include only if we're running ANSI */ - fwdCallInd->transCallNInd.pres = PRSNT_NODEF; - fwdCallInd->transCallNInd.val = 0x0; - } - - return FTDM_SUCCESS; - } - } - - fwdCallInd->natIntCallInd.val = 0x00; - fwdCallInd->end2EndMethInd.val = E2EMTH_NOMETH; - fwdCallInd->intInd.val = INTIND_NOINTW; - fwdCallInd->end2EndInfoInd.val = E2EINF_NOINFO; - fwdCallInd->isdnUsrPrtInd.val = ISUP_USED; - fwdCallInd->isdnUsrPrtPrfInd.val = PREF_PREFAW; - - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam_fwd_ind_isdn_access_ind"); - if (ftdm_strlen_zero(val)) { - /* Kept for backward compatibility */ - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "iam_fwd_ind_isdn_access_ind"); - } - - if (!ftdm_strlen_zero(val)) { - acc_val = (int)atoi(val); - } - - fwdCallInd->isdnAccInd.val = acc_val; - - if ((g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].switchType == LSI_SW_ANS88) || - (g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].switchType == LSI_SW_ANS92) || - (g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].switchType == LSI_SW_ANS95)) { - - /* include only if we're running ANSI */ - fwdCallInd->transCallNInd.pres = PRSNT_NODEF; - fwdCallInd->transCallNInd.val = 0x0; - } - - return FTDM_SUCCESS; -} - -ftdm_status_t copy_txMedReq_to_sngss7(ftdm_channel_t *ftdmchan, SiTxMedReq *txMedReq) -{ - txMedReq->eh.pres = PRSNT_NODEF; - txMedReq->trMedReq.pres = PRSNT_NODEF; - txMedReq->trMedReq.val = ftdmchan->caller_data.bearer_capability; - - return FTDM_SUCCESS; -} - -ftdm_status_t copy_usrServInfoA_to_sngss7(ftdm_channel_t *ftdmchan, SiUsrServInfo *usrServInfoA) -{ - int bProceed = 0; - const char *val = NULL; - - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam_usi_trans_cap"); - if (!ftdm_strlen_zero(val)) { - int itc_type = 0; - if (!strcasecmp(val, "SPEECH")) { - itc_type = ITC_SPEECH; - } else if (!strcasecmp(val, "UNRESTRICTED")) { - itc_type = ITC_UNRDIG; - } else if (!strcasecmp(val, "RESTRICTED")) { - itc_type = ITC_RESDIG; - } else if (!strcasecmp(val, "31KHZ")) { - itc_type = ITC_A31KHZ; - } else if (!strcasecmp(val, "7KHZ")) { - itc_type = ITC_A7KHZ; - } else if (!strcasecmp(val, "15KHZ")) { - itc_type = ITC_A15KHZ; - } else if (!strcasecmp(val, "VIDEO")) { - itc_type = ITC_VIDEO; - } else { - itc_type = ITC_SPEECH; - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "USI transmission capability parameter is wrong : %s. Setting to default SPEECH. \n", val ); - } - - usrServInfoA->infoTranCap.pres = PRSNT_NODEF; - usrServInfoA->infoTranCap.val = get_trillium_val(bc_cap_codes, ftdmchan->caller_data.bearer_capability, itc_type); - bProceed = 1; - } else { - usrServInfoA->infoTranCap.pres = NOTPRSNT; - } - - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam_usi_code_standard"); - if (!ftdm_strlen_zero(val)) { - usrServInfoA->cdeStand.pres = PRSNT_NODEF; - usrServInfoA->cdeStand.val = (int)atoi(val); /* default is 0x0 */ - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "USI coding standard = %d\n", usrServInfoA->cdeStand.val ); - bProceed = 1; - } else { - usrServInfoA->cdeStand.pres = NOTPRSNT; - } - - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam_usi_trans_mode"); - if (!ftdm_strlen_zero(val)) { - usrServInfoA->tranMode.pres = PRSNT_NODEF; - usrServInfoA->tranMode.val = (int)atoi(val); /* transfer mode, default is 0x0*/ - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "USI transfer mode = %d\n", usrServInfoA->tranMode.val ); - bProceed = 1; - } else { - usrServInfoA->tranMode.pres = NOTPRSNT; - } - - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam_usi_trans_rate_0"); - if (!ftdm_strlen_zero(val)) { - usrServInfoA->infoTranRate0.pres = PRSNT_NODEF; - usrServInfoA->infoTranRate0.val = (int)atoi(val); /* default is 0x10, 64kbps origination to destination*/ - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "USI trans rate 0 = %d\n", usrServInfoA->infoTranRate0.val ); - bProceed = 1; - } else { - usrServInfoA->infoTranRate0.pres = NOTPRSNT; - } - - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam_usi_trans_rate_1"); - if (!ftdm_strlen_zero(val)) { - usrServInfoA->infoTranRate1.pres = PRSNT_NODEF; - usrServInfoA->infoTranRate1.val = (int)atoi(val); /* 64kbps destination to origination, default is 0x10 */ - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "USI trans rate 1 = %d\n", usrServInfoA->infoTranRate1.val ); - bProceed = 1; - } else { - usrServInfoA->infoTranRate1.pres = NOTPRSNT; - } - - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam_usi_layer1_ident"); - if (!ftdm_strlen_zero(val)) { - usrServInfoA->lyr1Ident.pres = PRSNT_NODEF; - usrServInfoA->lyr1Ident.val = (int)atoi(val); /*default value is 0x01 */ - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "USI layer 1 indentification = %d\n", usrServInfoA->lyr1Ident.val ); - bProceed = 1; - } else { - usrServInfoA->lyr1Ident.pres = NOTPRSNT; - } - - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam_usi_layer1_prot"); - if (!ftdm_strlen_zero(val)) { - usrServInfoA->usrInfLyr1Prot.pres = PRSNT_NODEF; - usrServInfoA->usrInfLyr1Prot.val = (int)atoi(val); /*default value is 0x02 */ - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "USI layer 1 protocol = %d\n", usrServInfoA->usrInfLyr1Prot.val ); - bProceed = 1; - } else { - usrServInfoA->usrInfLyr1Prot.pres = NOTPRSNT; - } - - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam_usi_layer2_ident"); - if (!ftdm_strlen_zero(val)) { - usrServInfoA->lyr2Ident.pres = PRSNT_NODEF; - usrServInfoA->lyr2Ident.val = (int)atoi(val); /*default value is 0x01 */ - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "USI layer 2 indentification = %d\n", usrServInfoA->lyr2Ident.val ); - bProceed = 1; - } else { - usrServInfoA->lyr2Ident.pres = NOTPRSNT; - } - - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam_usi_layer2_prot"); - if (!ftdm_strlen_zero(val)) { - usrServInfoA->usrInfLyr2Prot.pres = PRSNT_NODEF; - usrServInfoA->usrInfLyr2Prot.val = (int)atoi(val); /*default value is 0x02 */ - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "USI layer 2 protocol = %d\n", usrServInfoA->usrInfLyr2Prot.val ); - bProceed = 1; - } else { - usrServInfoA->usrInfLyr2Prot.pres = NOTPRSNT; - } - - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam_usi_layer3_ident"); - if (!ftdm_strlen_zero(val)) { - usrServInfoA->lyr3Ident.pres = PRSNT_NODEF; - usrServInfoA->lyr3Ident.val = (int)atoi(val); /*default value is 0x01 */ - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "USI layer 3 indentification = %d\n", usrServInfoA->lyr3Ident.val ); - bProceed = 1; - } else { - usrServInfoA->lyr3Ident.pres = NOTPRSNT; - } - - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam_usi_layer3_prot"); - if (!ftdm_strlen_zero(val)) { - usrServInfoA->usrInfLyr3Prot.pres = PRSNT_NODEF; - usrServInfoA->usrInfLyr3Prot.val = (int)atoi(val); /*default value is 0x02 */ - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "USI layer 3 protocol = %d\n", usrServInfoA->usrInfLyr3Prot.val ); - bProceed = 1; - } else { - usrServInfoA->usrInfLyr3Prot.pres = NOTPRSNT; - } - - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam_usi_chan_struct"); - if (!ftdm_strlen_zero(val)) { - usrServInfoA->chanStruct.pres = PRSNT_NODEF; - usrServInfoA->chanStruct.val = (int)atoi(val); /* default value is 0x1, 8kHz integrity */ - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "USI channel structure = %d\n", usrServInfoA->chanStruct.val ); - bProceed = 1; - } else { - usrServInfoA->chanStruct.pres = NOTPRSNT; - } - - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam_usi_config"); - if (!ftdm_strlen_zero(val)) { - usrServInfoA->config.pres = PRSNT_NODEF; - usrServInfoA->config.val = (int)atoi(val); /* default value is 0x0, point to point configuration */ - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "USI configuration = %d\n", usrServInfoA->config.val ); - bProceed = 1; - } else { - usrServInfoA->config.pres = NOTPRSNT; - } - - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam_usi_establish"); - if (!ftdm_strlen_zero(val)) { - usrServInfoA->establish.pres = PRSNT_NODEF; - usrServInfoA->establish.val = (int)atoi(val); /* default value is 0x0, on demand */ - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "USI establishment = %d\n", usrServInfoA->establish.val ); - bProceed = 1; - } else { - usrServInfoA->establish.pres = NOTPRSNT; - } - - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam_usi_symmetry"); - if (!ftdm_strlen_zero(val)) { - usrServInfoA->symmetry.pres = PRSNT_NODEF; - usrServInfoA->symmetry.val = (int)atoi(val); /* default value is 0x0, bi-directional symmetric */ - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "USI symmetry = %d\n", usrServInfoA->symmetry.val ); - bProceed = 1; - } else { - usrServInfoA->symmetry.pres = NOTPRSNT; - } - - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam_usi_rate_multiplier"); - if (!ftdm_strlen_zero(val)) { - usrServInfoA->rateMultiplier.pres = PRSNT_NODEF; - usrServInfoA->rateMultiplier.val = (int)atoi(val); /* default value is 0x1, 1x rate multipler */ - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "USI rate multipier = %d\n", usrServInfoA->rateMultiplier.val ); - bProceed = 1; - } else { - usrServInfoA->rateMultiplier.pres = NOTPRSNT; - } - - if (bProceed) { - usrServInfoA->eh.pres = PRSNT_NODEF; - } else { - usrServInfoA->eh.pres = NOTPRSNT; - } - - return FTDM_SUCCESS; -} - - - -ftdm_status_t copy_tknStr_from_sngss7(TknStr str, char *ftdm, TknU8 oddEven) -{ - uint8_t i; - uint8_t j; - - /* check if the token string is present */ - if (str.pres == 1) { - j = 0; - - for (i = 0; i < str.len; i++) { - sprintf(&ftdm[j], "%X", (str.val[i] & 0x0F)); - j++; - sprintf(&ftdm[j], "%X", ((str.val[i] & 0xF0) >> 4)); - j++; - } - - /* if the odd flag is up the last digit is a fake "0" */ - if ((oddEven.pres == 1) && (oddEven.val == 1)) { - ftdm[j-1] = '\0'; - } else { - ftdm[j] = '\0'; - } - - - } else { - SS7_ERROR("Asked to copy tknStr that is not present!\n"); - return FTDM_FAIL; - } - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t append_tknStr_from_sngss7(TknStr str, char *ftdm, TknU8 oddEven) -{ - int i = 0; - int j = 0; - - /* check if the token string is present */ - if (str.pres == 1) { - /* find the length of the digits so far */ - j = strlen(ftdm); - - /* confirm that we found an acceptable length */ - if ( j > 25 ) { - SS7_ERROR("string length exceeds maxium value...aborting append!\n"); - return FTDM_FAIL; - } /* if ( j > 25 ) */ - - /* copy in digits */ - for (i = 0; i < str.len; i++) { - /* convert 4 bit integer to char and copy into lower nibblet*/ - sprintf(&ftdm[j], "%X", (str.val[i] & 0x0F)); - /* move along */ - j++; - /* convert 4 bit integer to char and copy into upper nibblet */ - sprintf(&ftdm[j], "%X", ((str.val[i] & 0xF0) >> 4)); - /* move along */ - j++; - } /* for (i = 0; i < str.len; i++) */ - - /* if the odd flag is up the last digit is a fake "0" */ - if ((oddEven.pres == 1) && (oddEven.val == 1)) { - ftdm[j-1] = '\0'; - } else { - ftdm[j] = '\0'; - } /* if ((oddEven.pres == 1) && (oddEven.val == 1)) */ - } else { - SS7_ERROR("Asked to copy tknStr that is not present!\n"); - return FTDM_FAIL; - } /* if (str.pres == 1) */ - - return FTDM_SUCCESS; -} - - -ftdm_status_t copy_tknStr_to_sngss7(char* val, TknStr *tknStr, TknU8 *oddEven) -{ - char tmp[2]; - int k = 0; - int j = 0; - uint8_t flag = 0; - uint8_t odd = 0; - - uint8_t lower = 0x0; - uint8_t upper = 0x0; - - tknStr->pres = PRSNT_NODEF; - - /* atoi will search through memory starting from the pointer it is given until - * it finds the \0...since tmp is on the stack it will start going through the - * possibly causing corruption. Hard code a \0 to prevent this - */ - tmp[1] = '\0'; - - while (1) { - /* grab a digit from the ftdm digits */ - tmp[0] = val[k]; - - /* check if the digit is a number and that is not null */ - while (!(isxdigit(tmp[0])) && (tmp[0] != '\0')) { - if (tmp[0] == '*') { - /* Could not find a spec that specifies this , but on customer system, * was transmitted as 0x0b */ - SS7_DEBUG("Replacing * with 0x0b"); - k++; - tmp[0] = 0x0b; - } else { - SS7_INFO("Dropping invalid digit: %c\n", tmp[0]); - /* move on to the next value */ - k++; - tmp[0] = val[k]; - } - } /* while(!(isdigit(tmp))) */ - - /* check if tmp is null or a digit */ - if (tmp[0] != '\0') { - /* push it into the lower nibble */ - lower = strtol(&tmp[0], (char **)NULL, 16); - /* move to the next digit */ - k++; - /* grab a digit from the ftdm digits */ - tmp[0] = val[k]; - - /* check if the digit is a number and that is not null */ - while (!(isxdigit(tmp[0])) && (tmp[0] != '\0')) { - SS7_INFO("Dropping invalid digit: %c\n", tmp[0]); - k++; - tmp[0] = val[k]; - } /* while(!(isdigit(tmp))) */ - - /* check if tmp is null or a digit */ - if (tmp[0] != '\0') { - /* push the digit into the upper nibble */ - upper = (strtol(&tmp[0], (char **)NULL, 16)) << 4; - } else { - /* there is no upper ... fill in 0 */ - upper = 0x0; - /* throw the odd flag */ - odd = 1; - /* throw the end flag */ - flag = 1; - } /* if (tmp != '\0') */ - } else { - /* keep the odd flag down */ - odd = 0; - /* break right away since we don't need to write the digits */ - break; - } - - /* push the digits into the trillium structure */ - tknStr->val[j] = upper | lower; - - /* increment the trillium pointer */ - j++; - - /* if the flag is up we're through all the digits */ - if (flag) break; - - /* move to the next digit */ - k++; - } /* while(1) */ - - tknStr->len = j; - oddEven->pres = PRSNT_NODEF; - oddEven->val = odd; - return FTDM_SUCCESS; -} - - - -/******************************************************************************/ -int check_for_state_change(ftdm_channel_t *ftdmchan) -{ - - /* check to see if there are any pending state changes on the channel and give them a sec to happen*/ - ftdm_wait_for_flag_cleared(ftdmchan, FTDM_CHANNEL_STATE_CHANGE, 500); - - /* check the flag to confirm it is clear now */ - - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_STATE_CHANGE)) { - /* the flag is still up...so we have a problem */ - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "FTDM_CHANNEL_STATE_CHANGE flag set for over 500ms, channel state = %s\n", - ftdm_channel_state2str (ftdmchan->state)); - - return 1; - } - - return 0; -} - -/******************************************************************************/ -ftdm_status_t extract_chan_data(uint32_t circuit, sngss7_chan_data_t **sngss7_info, ftdm_channel_t **ftdmchan) -{ - if (!g_ftdm_sngss7_data.cfg.isupCkt[circuit].obj) { - SS7_ERROR("No ss7 info for circuit #%d\n", circuit); - return FTDM_FAIL; - } - - *sngss7_info = g_ftdm_sngss7_data.cfg.isupCkt[circuit].obj; - - if (!(*sngss7_info)->ftdmchan) { - SS7_ERROR("No ftdmchan for circuit #%d\n", circuit); - return FTDM_FAIL; - } - - if (!(*sngss7_info)->ftdmchan->span) { - SS7_CRITICAL("ftdmchan->span = NULL for circuit #%d\n",circuit); - return FTDM_FAIL; - - } - if (!(*sngss7_info)->ftdmchan->span->signal_data) { - SS7_CRITICAL("ftdmchan->span->signal_data = NULL for circuit #%d\n",circuit); - return FTDM_FAIL; - - } - - *ftdmchan = (*sngss7_info)->ftdmchan; - return FTDM_SUCCESS; -} - -/******************************************************************************/ -int check_for_reset(sngss7_chan_data_t *sngss7_info) -{ - - if (sngss7_test_ckt_flag(sngss7_info,FLAG_RESET_RX)) { - return 1; - } - - if (sngss7_test_ckt_flag(sngss7_info,FLAG_RESET_TX)) { - return 1; - } - - if (sngss7_test_ckt_flag(sngss7_info,FLAG_GRP_RESET_RX)) { - return 1; - } - - if (sngss7_test_ckt_flag(sngss7_info,FLAG_GRP_RESET_TX)) { - return 1; - } - - return 0; - -} - -/******************************************************************************/ -unsigned long get_unique_id(void) -{ - int procId = sng_get_procId(); - - /* id values are between (procId * 1,000,000) and ((procId + 1) * 1,000,000) */ - if (sngss7_id < ((procId + 1) * 1000000) ) { - sngss7_id++; - } else { - sngss7_id = procId * 1000000; - } - - return(sngss7_id); -} - -/******************************************************************************/ -ftdm_status_t check_if_rx_grs_started(ftdm_span_t *ftdmspan) -{ - ftdm_iterator_t *iter = NULL; - ftdm_iterator_t *curr = NULL; - ftdm_channel_t *ftdmchan = NULL; - sngss7_chan_data_t *sngss7_info = NULL; - sngss7_chan_data_t *cinfo = NULL; - int i = 0; - - iter = ftdm_span_get_chan_iterator(ftdmspan, NULL); - for (curr = iter; curr; curr = ftdm_iterator_next(curr)) { - ftdm_channel_t *fchan = ftdm_iterator_current(curr); - - ftdm_channel_lock(fchan); - - cinfo = fchan->call_data; - - if (!cinfo->rx_grs.range) { - ftdm_channel_unlock(fchan); - continue; - } - - SS7_INFO("Rx GRS (%d:%d)\n", - g_ftdm_sngss7_data.cfg.isupCkt[cinfo->rx_grs.circuit].cic, - (g_ftdm_sngss7_data.cfg.isupCkt[cinfo->rx_grs.circuit].cic + cinfo->rx_grs.range)); - - for (i = cinfo->rx_grs.circuit; i < (cinfo->rx_grs.circuit + cinfo->rx_grs.range + 1); i++) { - - /* confirm this is a voice channel, otherwise we do nothing */ - if (g_ftdm_sngss7_data.cfg.isupCkt[i].type != SNG_CKT_VOICE) { - continue; - } - - /* extract the channel in question */ - if (extract_chan_data(i, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", i); - continue; - } - - /* check if the GRP_RESET_RX flag is already up */ - if (sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX)) { - /* we have already processed this channel...move along */ - continue; - } - - /* lock the channel */ - ftdm_channel_lock(ftdmchan); - - /* clear up any pending state changes */ - while (ftdm_test_flag (ftdmchan, FTDM_CHANNEL_STATE_CHANGE)) { - ftdm_sangoma_ss7_process_state_change (ftdmchan); - } - - /* flag the channel as having received a reset */ - sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX); - - switch (ftdmchan->state) { - /**************************************************************************/ - case FTDM_CHANNEL_STATE_RESTART: - - /* go to idle so that we can redo the restart state*/ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_IDLE); - - break; - /**************************************************************************/ - default: - - /* set the state of the channel to restart...the rest is done by the chan monitor */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RESTART); - break; - /**************************************************************************/ - } - - /* unlock the channel again before we exit */ - ftdm_channel_unlock(ftdmchan); - - } - - ftdm_channel_unlock(fchan); - } - - ftdm_iterator_free(iter); - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t check_if_rx_grs_processed(ftdm_span_t *ftdmspan) -{ - ftdm_iterator_t *iter = NULL; - ftdm_iterator_t *curr = NULL; - ftdm_channel_t *ftdmchan = NULL; - sngss7_chan_data_t *sngss7_info = NULL; - sngss7_chan_data_t *cinfo = NULL; - int i = 0, bn = 0; - int byte = 0, bit = 0; - int cic_start = 0, cic_end = 0, num_cics = 0; - ftdm_bitmap_t *lockmap = 0; - ftdm_size_t mapsize = 0; - - iter = ftdm_span_get_chan_iterator(ftdmspan, NULL); - for (curr = iter; curr; curr = ftdm_iterator_next(curr)) { - ftdm_channel_t *fchan = ftdm_iterator_current(curr); - - ftdm_channel_lock(fchan); - - cinfo = fchan->call_data; - - if (!cinfo->rx_grs.range) { - - ftdm_channel_unlock(fchan); - - continue; - } - - cic_start = cinfo->rx_grs.circuit; - cic_end = cinfo->rx_grs.circuit + cinfo->rx_grs.range; - num_cics = cinfo->rx_grs.range + 1; - mapsize = (num_cics / FTDM_BITMAP_NBITS) + 1; - - lockmap = ftdm_calloc(mapsize, sizeof(*lockmap)); - if (!lockmap) { - ftdm_channel_unlock(fchan); - return FTDM_ENOMEM; - } - - /* check all the circuits in the range to see if they are done resetting */ - for (i = cic_start, bn = 0; i <= cic_end; i++, bn++) { - - /* confirm this is a voice channel, otherwise we do nothing */ - if (g_ftdm_sngss7_data.cfg.isupCkt[i].type != SNG_CKT_VOICE) { - continue; - } - - /* extract the channel in question */ - if (extract_chan_data(i, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", i); - ftdm_assert(FTDM_FALSE, "Failed to extract channel data during GRS\n"); - continue; - } - - /* lock the channel */ - ftdm_channel_lock(ftdmchan); - ftdm_map_set_bit(lockmap, bn); - - /* check if there is a state change pending on the channel */ - if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_STATE_CHANGE)) { - /* check the state to the GRP_RESET_RX_DN flag */ - if (!sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX_DN)) { - /* this channel is still resetting...do nothing */ - goto GRS_UNLOCK_ALL; - } /* if (!sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX_DN)) */ - } else { - /* state change pending */ - goto GRS_UNLOCK_ALL; - } - - } - - SS7_DEBUG("All circuits out of reset for GRS: circuit=%d, range=%d\n", cinfo->rx_grs.circuit, cinfo->rx_grs.range); - for (i = cic_start; i <= cic_end; i++) { - - /* confirm this is a voice channel, otherwise we do nothing */ - if (g_ftdm_sngss7_data.cfg.isupCkt[i].type != SNG_CKT_VOICE) { - continue; - } - - /* extract the channel in question */ - if (extract_chan_data(i, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n",i); - ftdm_assert(FTDM_FALSE, "Failed to extract channel data during GRS\n"); - continue; - } - - /* throw the GRP reset flag complete flag */ - sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX_CMPLT); - - /* move the channel to the down state */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - - /* update the status map if the ckt is in blocked state */ - if ((sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX)) || - (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX)) || - (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX)) || - (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX))) { - - cinfo->rx_grs.status[byte] = (cinfo->rx_grs.status[byte] | (1 << bit)); - } - - /* update the bit and byte counter*/ - bit ++; - if (bit == 8) { - byte++; - bit = 0; - } - - } -GRS_UNLOCK_ALL: - for (i = cic_start, bn = 0; i <= cic_end; i++, bn++) { - /* confirm this is a voice channel, otherwise we do nothing */ - if (g_ftdm_sngss7_data.cfg.isupCkt[i].type != SNG_CKT_VOICE) { - continue; - } - - /* extract the channel in question */ - if (extract_chan_data(i, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", i); - ftdm_assert(FTDM_FALSE, "Failed to extract channel data during GRS\n"); - continue; - } - if (ftdm_map_test_bit(lockmap, bn)) { - /* unlock the channel */ - ftdm_channel_unlock(ftdmchan); - ftdm_map_clear_bit(lockmap, bn); - } - } - - ftdm_safe_free(lockmap); - - ftdm_channel_unlock(fchan); - } - - ftdm_iterator_free(iter); - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t check_if_rx_gra_started(ftdm_span_t *ftdmspan) -{ - ftdm_iterator_t *iter = NULL; - ftdm_iterator_t *curr = NULL; - ftdm_channel_t *ftdmchan = NULL; - sngss7_chan_data_t *sngss7_info = NULL; - sngss7_chan_data_t *cinfo = NULL; - int i = 0; - - iter = ftdm_span_get_chan_iterator(ftdmspan, NULL); - - for (curr = iter; curr; curr = ftdm_iterator_next(curr)) { - ftdm_channel_t *fchan = ftdm_iterator_current(curr); - ftdm_channel_lock(fchan); - - cinfo = fchan->call_data; - - if (!cinfo->rx_gra.range) { - - ftdm_channel_unlock(fchan); - - continue; - } - - SS7_INFO("Rx GRA (%d:%d)\n", - g_ftdm_sngss7_data.cfg.isupCkt[cinfo->rx_gra.circuit].cic, - (g_ftdm_sngss7_data.cfg.isupCkt[cinfo->rx_gra.circuit].cic + cinfo->rx_gra.range)); - - for (i = cinfo->rx_gra.circuit; i < (cinfo->rx_gra.circuit + cinfo->rx_gra.range + 1); i++) { - - /* confirm this is a voice channel, otherwise we do nothing */ - if (g_ftdm_sngss7_data.cfg.isupCkt[i].type != SNG_CKT_VOICE) { - continue; - } - - /* extract the channel in question */ - if (extract_chan_data(i, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", i); - continue; - } - - /* check if the channel is already processing the GRA */ - if (sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_TX_RSP)) { - /* move along */ - continue; - } - - /* lock the channel */ - ftdm_channel_lock(ftdmchan); - - /* clear up any pending state changes */ - while (ftdm_test_flag (ftdmchan, FTDM_CHANNEL_STATE_CHANGE)) { - ftdm_sangoma_ss7_process_state_change (ftdmchan); - } - - switch (ftdmchan->state) { - /**********************************************************************/ - case FTDM_CHANNEL_STATE_RESTART: - - /* throw the FLAG_RESET_TX_RSP to indicate we have acknowledgement from the remote side */ - sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_RESET_TX_RSP); - - /* go to DOWN */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - - break; - /**********************************************************************/ - case FTDM_CHANNEL_STATE_DOWN: - - /* do nothing, just drop the message */ - SS7_DEBUG("Receveived GRA in down state, dropping\n"); - - break; - /**********************************************************************/ - case FTDM_CHANNEL_STATE_TERMINATING: - case FTDM_CHANNEL_STATE_HANGUP: - case FTDM_CHANNEL_STATE_HANGUP_COMPLETE: - - /* throw the FLAG_RESET_TX_RSP to indicate we have acknowledgement from the remote side */ - sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_RESET_TX_RSP); - - break; - /**********************************************************************/ - default: - /* ITU Q764-2.9.5.1.c -> release the circuit */ - if (cinfo->rx_gra.cause != 0) { - ftdmchan->caller_data.hangup_cause = cinfo->rx_gra.cause; - } else { - ftdmchan->caller_data.hangup_cause = 98; /* Message not compatiable with call state */ - } - - /* go to terminating to hang up the call */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); - break; - /**********************************************************************/ - } - - ftdm_channel_unlock(ftdmchan); - } - - ftdm_channel_unlock(fchan); - } - - ftdm_iterator_free(iter); - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t check_for_res_sus_flag(ftdm_span_t *ftdmspan) -{ - ftdm_channel_t *ftdmchan = NULL; - sngss7_chan_data_t *sngss7_info = NULL; - ftdm_sigmsg_t sigev; - int x; - - for (x = 1; x < (ftdmspan->chan_count + 1); x++) { - - /* extract the channel structure and sngss7 channel data */ - ftdmchan = ftdmspan->channels[x]; - - /* if the call data is NULL move on */ - if (ftdmchan->call_data == NULL) continue; - - sngss7_info = ftdmchan->call_data; - - /* lock the channel */ - ftdm_mutex_lock(ftdmchan->mutex); - - memset (&sigev, 0, sizeof (sigev)); - - sigev.chan_id = ftdmchan->chan_id; - sigev.span_id = ftdmchan->span_id; - sigev.channel = ftdmchan; - - /* if we have the PAUSED flag and the sig status is still UP */ - if ((sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_PAUSED)) && - (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_SIG_UP))) { - - /* clear up any pending state changes */ - while (ftdm_test_flag (ftdmchan, FTDM_CHANNEL_STATE_CHANGE)) { - ftdm_sangoma_ss7_process_state_change (ftdmchan); - } - - /* throw the channel into SUSPENDED to process the flag */ - /* after doing this once the sig status will be down */ - ftdm_set_state (ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); - } - - /* if the RESUME flag is up go to SUSPENDED to process the flag */ - /* after doing this the flag will be cleared */ - if (sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_RESUME)) { - - /* clear up any pending state changes */ - while (ftdm_test_flag (ftdmchan, FTDM_CHANNEL_STATE_CHANGE)) { - ftdm_sangoma_ss7_process_state_change (ftdmchan); - } - - /* got SUSPENDED state to clear the flag */ - ftdm_set_state (ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); - } - - /* unlock the channel */ - ftdm_mutex_unlock(ftdmchan->mutex); - - } /* for (x = 1; x < (span->chan_count + 1); x++) */ - - /* signal the core that sig events are queued for processing */ - ftdm_span_trigger_signals(ftdmspan); - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t process_span_ucic(ftdm_span_t *ftdmspan) -{ - ftdm_iterator_t *iter = NULL; - ftdm_iterator_t *curr = NULL; - ftdm_channel_t *ftdmchan = NULL; - sngss7_chan_data_t *sngss7_info = NULL; - sngss7_chan_data_t *cinfo = NULL; - sngss7_span_data_t *sngss7_span = (sngss7_span_data_t *)ftdmspan->signal_data; - int i = 0; - - iter = ftdm_span_get_chan_iterator(ftdmspan, NULL); - curr = iter; - for (curr = iter; curr; curr = ftdm_iterator_next(curr)) { - ftdm_channel_t *fchan = ftdm_iterator_current(curr); - - ftdm_channel_lock(fchan); - - cinfo = fchan->call_data; - - if (!cinfo->ucic.range) { - - ftdm_channel_unlock(fchan); - - continue; - } - - for (i = cinfo->ucic.circuit; i < (cinfo->ucic.circuit + cinfo->ucic.range + 1); i++) { - - /* extract the channel in question */ - if (extract_chan_data(i, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", i); - continue; - } - - /* lock the channel */ - ftdm_channel_lock(ftdmchan); - - SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Rx Span UCIC\n", sngss7_info->circuit->cic); - - /* clear up any pending state changes */ - while (ftdm_test_flag (ftdmchan, FTDM_CHANNEL_STATE_CHANGE)) { - ftdm_sangoma_ss7_process_state_change (ftdmchan); - } - - /* throw the ckt block flag */ - sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK); - - /* set the channel to suspended state */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); - - /* unlock the channel again before we exit */ - ftdm_channel_unlock(ftdmchan); - } - /* clear out the ucic data since we're done with it */ - memset(&cinfo->ucic, 0, sizeof(cinfo->ucic)); - - ftdm_channel_unlock(fchan); - } - - ftdm_clear_flag(sngss7_span, SNGSS7_UCIC_PENDING); - - ftdm_iterator_free(iter); - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t clear_rx_grs_flags(sngss7_chan_data_t *sngss7_info) -{ - /* clear all the flags related to an incoming GRS */ - sngss7_clear_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX); - sngss7_clear_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX_DN); - sngss7_clear_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX_CMPLT); - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t clear_rx_grs_data(sngss7_chan_data_t *sngss7_info) -{ - ftdm_iterator_t *iter = NULL; - ftdm_iterator_t *curr = NULL; - sngss7_chan_data_t *cinfo = NULL; - ftdm_channel_t *ftdmchan = sngss7_info->ftdmchan; - sngss7_span_data_t *sngss7_span = (sngss7_span_data_t *)ftdmchan->span->signal_data; - - memset(&sngss7_info->rx_grs, 0, sizeof(sngss7_info->rx_grs)); - - iter = ftdm_span_get_chan_iterator(ftdmchan->span, NULL); - curr = iter; - for (curr = iter; curr; curr = ftdm_iterator_next(curr)) { - ftdm_channel_t *fchan = ftdm_iterator_current(curr); - - ftdm_channel_lock(fchan); - - cinfo = fchan->call_data; - if (cinfo->rx_grs.range) { - /* there is still another grs pending, do not clear the SNGSS7_RX_GRS_PENDING flag yet */ - ftdm_channel_unlock(fchan); - goto done; - } - - ftdm_channel_unlock(fchan); - } - - /* if we're here is because there is no other grs going on now in this span */ - ftdm_clear_flag(sngss7_span, SNGSS7_RX_GRS_PENDING); - -done: - ftdm_iterator_free(iter); - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t clear_rx_gra_data(sngss7_chan_data_t *sngss7_info) -{ - ftdm_iterator_t *iter = NULL; - ftdm_iterator_t *curr = NULL; - sngss7_chan_data_t *cinfo = NULL; - ftdm_channel_t *ftdmchan = sngss7_info->ftdmchan; - sngss7_span_data_t *sngss7_span = ftdmchan->span->signal_data; - - /* clear the rx_grs data fields */ - memset(&sngss7_info->rx_gra, 0, sizeof(sngss7_info->rx_gra)); - - iter = ftdm_span_get_chan_iterator(ftdmchan->span, NULL); - curr = iter; - for (curr = iter; curr; curr = ftdm_iterator_next(curr)) { - ftdm_channel_t *fchan = ftdm_iterator_current(curr); - - ftdm_channel_lock(fchan); - - cinfo = fchan->call_data; - if (cinfo->rx_gra.range) { - /* there is still another gra pending, do not clear the SNGSS7_RX_GRA_PENDING flag yet */ - ftdm_channel_unlock(fchan); - goto done; - } - - ftdm_channel_unlock(fchan); - } - - /* if we're here is because there is no other gra pending in this span */ - ftdm_clear_flag(sngss7_span, SNGSS7_RX_GRA_PENDING); - -done: - - ftdm_iterator_free(iter); - - return FTDM_SUCCESS; -} -/******************************************************************************/ -ftdm_status_t clear_tx_grs_flags(sngss7_chan_data_t *sngss7_info) -{ - /* clear all the flags related to an outgoing GRS */ - sngss7_clear_ckt_flag(sngss7_info, FLAG_GRP_RESET_BASE); - sngss7_clear_ckt_flag(sngss7_info, FLAG_GRP_RESET_TX); - sngss7_clear_ckt_flag(sngss7_info, FLAG_GRP_RESET_SENT); - sngss7_clear_ckt_flag(sngss7_info, FLAG_GRP_RESET_TX_RSP); - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t clear_tx_grs_data(sngss7_chan_data_t *sngss7_info) -{ - /* clear everything up */ - memset(&sngss7_info->tx_grs, 0, sizeof(sngss7_info->tx_grs)); - return FTDM_SUCCESS; -} - -/******************************************************************************/ - -/******************************************************************************/ -ftdm_status_t clear_rx_rsc_flags(sngss7_chan_data_t *sngss7_info) -{ - /* clear all the flags related to an incoming RSC */ - sngss7_clear_ckt_flag(sngss7_info, FLAG_RESET_RX); - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t clear_tx_rsc_flags(sngss7_chan_data_t *sngss7_info) -{ - /* clear all the flags related to an outgoing RSC */ - sngss7_clear_ckt_flag(sngss7_info, FLAG_RESET_TX); - sngss7_clear_ckt_flag(sngss7_info, FLAG_RESET_SENT); - sngss7_clear_ckt_flag(sngss7_info, FLAG_RESET_TX_RSP); - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t encode_subAddrIE_nsap(const char *subAddr, char *subAddrIE, int type) -{ - /* Q931 4.5.9 - * 8 7 6 5 4 3 2 1 (octet) - * - * 0 1 1 1 0 0 0 1 (spare 8) ( IE id 1-7) - * X X X X X X X X (length of IE contents) - * 1 0 0 0 Z 0 0 0 (ext 8) (NSAP type 5-7) (odd/even 4) (spare 1-3) - * X X X X X X X X (sub address encoded in ia5) - */ - - int x = 0; - int p = 0; - int len = 0; - char tmp[2]; - - /* initalize the second element of tmp to \0 so that atoi doesn't go to far */ - tmp[1]='\0'; - - /* set octet 1 aka IE id */ - p = 0; - switch(type) { - /**************************************************************************/ - case SNG_CALLED: /* called party sub address */ - subAddrIE[p] = 0x71; - break; - /**************************************************************************/ - case SNG_CALLING: /* calling party sub address */ - subAddrIE[p] = 0x6d; - break; - /**************************************************************************/ - default: /* not good */ - SS7_ERROR("Sub-Address type is invalid: %d\n", type); - return FTDM_FAIL; - break; - /**************************************************************************/ - } /* switch(type) */ - - /* set octet 3 aka type and o/e */ - p = 2; - subAddrIE[p] = 0x80; - - /* set the subAddrIE pointer octet 4 */ - p = 3; - - /* loop through all digits in subAddr and insert them into subAddrIE */ - while (subAddr[x] != '\0') { - - /* grab a character */ - tmp[0] = subAddr[x]; - - /* confirm it is a digit */ - if (!isdigit(tmp[0])) { - SS7_INFO("Dropping invalid digit: %c\n", tmp[0]); - /* move to the next character in subAddr */ - x++; - - /* restart the loop */ - continue; - } - - /* convert the character to IA5 encoding and write into subAddrIE */ - subAddrIE[p] = atoi(&tmp[0]); /* lower nibble is the digit */ - subAddrIE[p] |= 0x3 << 4; /* upper nibble is 0x3 */ - - /* increment address length counter */ - len++; - - /* increment the subAddrIE pointer */ - p++; - - /* move to the next character in subAddr */ - x++; - - } /* while (subAddr[x] != '\0') */ - - /* set octet 2 aka length of subaddr */ - p = 1; - subAddrIE[p] = len + 1; - - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t encode_subAddrIE_nat(const char *subAddr, char *subAddrIE, int type) -{ - /* Q931 4.5.9 - * 8 7 6 5 4 3 2 1 (octet) - * - * 0 1 1 1 0 0 0 1 (spare 8) ( IE id 1-7) - * X X X X X X X X (length of IE contents) - * 1 0 0 0 Z 0 0 0 (ext 8) (NSAP type 5-7) (odd/even 4) (spare 1-3) - * X X X X X X X X (sub address encoded in ia5) - */ - - int x = 0; - int p = 0; - int len = 0; - char tmp[2]; - int flag = 0; - int odd = 0; - uint8_t lower = 0x0; - uint8_t upper = 0x0; - - /* initalize the second element of tmp to \0 so that atoi doesn't go to far */ - tmp[1]='\0'; - - /* set octet 1 aka IE id */ - p = 0; - switch(type) { - /**************************************************************************/ - case SNG_CALLED: /* called party sub address */ - subAddrIE[p] = 0x71; - break; - /**************************************************************************/ - case SNG_CALLING: /* calling party sub address */ - subAddrIE[p] = 0x6d; - break; - /**************************************************************************/ - default: /* not good */ - SS7_ERROR("Sub-Address type is invalid: %d\n", type); - return FTDM_FAIL; - break; - /**************************************************************************/ - } /* switch(type) */ - - /* set the subAddrIE pointer octet 4 */ - p = 3; - - /* loop through all digits in subAddr and insert them into subAddrIE */ - while (1) { - - /* grab a character */ - tmp[0] = subAddr[x]; - - /* confirm it is a hex digit */ - while ((!isxdigit(tmp[0])) && (tmp[0] != '\0')) { - if (tmp[0] == '*') { - /* Could not find a spec that specifies this, but on customer system, * was transmitted as 0x0b */ - SS7_DEBUG("Replacing * with 0x0b"); - x++; - tmp[0] = 0x0b; - } else { - SS7_INFO("Dropping invalid digit: %c\n", tmp[0]); - /* move to the next character in subAddr */ - x++; - tmp[0] = subAddr[x]; - } - } - - /* check if tmp is null or a digit */ - if (tmp[0] != '\0') { - /* push it into the lower nibble using strtol to allow a-f chars */ - lower = strtol(&tmp[0], (char **)NULL, 16); - /* move to the next digit */ - x++; - /* grab a digit from the ftdm digits */ - tmp[0] = subAddr[x]; - - /* check if the digit is a hex digit and that is not null */ - while (!(isxdigit(tmp[0])) && (tmp[0] != '\0')) { - SS7_INFO("Dropping invalid digit: %c\n", tmp[0]); - x++; - tmp[0] = subAddr[x]; - } /* while(!(isdigit(tmp))) */ - - /* check if tmp is null or a digit */ - if (tmp[0] != '\0') { - /* push the digit into the upper nibble using strtol to allow a-f chars */ - upper = (strtol(&tmp[0], (char **)NULL, 16)) << 4; - } else { - /* there is no upper ... fill in spare */ - upper = 0x00; - /* throw the odd flag since we need to buffer */ - odd = 1; - /* throw the end flag */ - flag = 1; - } /* if (tmp != '\0') */ - } else { - /* keep the odd flag down */ - odd = 0; - - /* throw the flag */ - flag = 1; - - /* bounce out right away */ - break; - } - - /* fill in the octet */ - subAddrIE[p] = upper | lower; - - /* increment address length counter */ - len++; - - /* if the flag is we're through all the digits */ - if (flag) break; - - /* increment the subAddrIE pointer */ - p++; - - /* move to the next character in subAddr */ - x++; - - } /* while (subAddr[x] != '\0') */ - - /* set octet 2 aka length of subaddr */ - p = 1; - subAddrIE[p] = len + 1; - - /* set octet 3 aka type and o/e */ - p = 2; - subAddrIE[p] = 0xa0 | (odd << 3); - - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -int find_mtp2_error_type_in_map(const char *err_type) -{ - int i = 0; - - while (sng_mtp2_error_type_map[i].init == 1) { - /* check if string matches the sng_type name */ - if (!strcasecmp(err_type, sng_mtp2_error_type_map[i].sng_type)) { - /* we've found a match break from the loop */ - break; - } else { - /* move on to the next on */ - i++; - } - } /* while (sng_mtp2_error_type_map[i].init == 1) */ - - /* check how we exited the loop */ - if (sng_mtp2_error_type_map[i].init == 0) { - return -1; - } else { - return i; - } /* if (sng_mtp2_error_type_map[i].init == 0) */ -} - -/******************************************************************************/ -int find_link_type_in_map(const char *linkType) -{ - int i = 0; - - while (sng_link_type_map[i].init == 1) { - /* check if string matches the sng_type name */ - if (!strcasecmp(linkType, sng_link_type_map[i].sng_type)) { - /* we've found a match break from the loop */ - break; - } else { - /* move on to the next on */ - i++; - } - } /* while (sng_link_type_map[i].init == 1) */ - - /* check how we exited the loop */ - if (sng_link_type_map[i].init == 0) { - return -1; - } else { - return i; - } /* if (sng_link_type_map[i].init == 0) */ -} - -/******************************************************************************/ -int find_switch_type_in_map(const char *switchType) -{ - int i = 0; - - while (sng_switch_type_map[i].init == 1) { - /* check if string matches the sng_type name */ - if (!strcasecmp(switchType, sng_switch_type_map[i].sng_type)) { - /* we've found a match break from the loop */ - break; - } else { - /* move on to the next on */ - i++; - } - } /* while (sng_switch_type_map[i].init == 1) */ - - /* check how we exited the loop */ - if (sng_switch_type_map[i].init == 0) { - return -1; - } else { - return i; - } /* if (sng_switch_type_map[i].init == 0) */ -} - -/******************************************************************************/ -int find_ssf_type_in_map(const char *ssfType) -{ - int i = 0; - - while (sng_ssf_type_map[i].init == 1) { - /* check if string matches the sng_type name */ - if (!strcasecmp(ssfType, sng_ssf_type_map[i].sng_type)) { - /* we've found a match break from the loop */ - break; - } else { - /* move on to the next on */ - i++; - } - } /* while (sng_ssf_type_map[i].init == 1) */ - - /* check how we exited the loop */ - if (sng_ssf_type_map[i].init == 0) { - return -1; - } else { - return i; - } /* if (sng_ssf_type_map[i].init == 0) */ -} - -/******************************************************************************/ -int find_cic_cntrl_in_map(const char *cntrlType) -{ - int i = 0; - - while (sng_cic_cntrl_type_map[i].init == 1) { - /* check if string matches the sng_type name */ - if (!strcasecmp(cntrlType, sng_cic_cntrl_type_map[i].sng_type)) { - /* we've found a match break from the loop */ - break; - } else { - /* move on to the next on */ - i++; - } - } /* while (sng_cic_cntrl_type_map[i].init == 1) */ - - /* check how we exited the loop */ - if (sng_cic_cntrl_type_map[i].init == 0) { - return -1; - } else { - return i; - } /* if (sng_cic_cntrl_type_map[i].init == 0) */ -} - -/******************************************************************************/ -ftdm_status_t check_status_of_all_isup_intf(void) -{ - sng_isup_inf_t *sngss7_intf = NULL; - uint8_t status = 0xff; - int x; - - /* go through all the isupIntfs and ask the stack to give their current state */ - x = 1; - for (x = 1; x < (MAX_ISUP_INFS); x++) { - /**************************************************************************/ - - if (g_ftdm_sngss7_data.cfg.isupIntf[x].id == 0) continue; - - sngss7_intf = &g_ftdm_sngss7_data.cfg.isupIntf[x]; - - if (ftmod_ss7_isup_intf_sta(sngss7_intf->id, &status)) { - SS7_ERROR("Failed to get status of ISUP intf %d\n", sngss7_intf->id); - sngss7_set_flag(sngss7_intf, SNGSS7_PAUSED); - continue; - } - - switch (status){ - /**********************************************************************/ - case (SI_INTF_AVAIL): - SS7_DEBUG("State of ISUP intf %d = AVAIL\n", sngss7_intf->id); - - /* check the current state for interface that we know */ - if (sngss7_test_flag(sngss7_intf, SNGSS7_PAUSED)) { - /* we thing the intf is paused...put into resume */ - sngss7_clear_flag(sngss7_intf, SNGSS7_PAUSED); - } else { - /* nothing to since we already know that interface is active */ - } - break; - /**********************************************************************/ - case (SI_INTF_UNAVAIL): - SS7_DEBUG("State of ISUP intf %d = UNAVAIL\n", sngss7_intf->id); - /* check the current state for interface that we know */ - if (sngss7_test_flag(sngss7_intf, SNGSS7_PAUSED)) { - /* nothing to since we already know that interface is active */ - } else { - /* put the interface into pause */ - sngss7_set_flag(sngss7_intf, SNGSS7_PAUSED); - } - break; - /**********************************************************************/ - case (SI_INTF_CONG1): - SS7_DEBUG("State of ISUP intf %d = Congestion 1\n", sngss7_intf->id); - break; - /**********************************************************************/ - case (SI_INTF_CONG2): - SS7_DEBUG("State of ISUP intf %d = Congestion 2\n", sngss7_intf->id); - break; - /**********************************************************************/ - case (SI_INTF_CONG3): - SS7_DEBUG("State of ISUP intf %d = Congestion 3\n", sngss7_intf->id); - break; - /**********************************************************************/ - default: - /* should do something here to handle the possiblity of an unknown case */ - SS7_ERROR("Unknown ISUP intf Status code (%d) for Intf = %d\n", status, sngss7_intf->id); - break; - /**********************************************************************/ - } /* switch (status) */ - - /**************************************************************************/ - } /* for (x = 1; x < MAX_ISUP_INFS); i++) */ - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t sngss7_add_var(sngss7_chan_data_t *sngss7_info, const char* var, const char* val) -{ - char *t_name = 0; - char *t_val = 0; - - /* confirm the user has sent us a value */ - if (!var || !val) { - return FTDM_FAIL; - } - - if (!sngss7_info->variables) { - /* initialize on first use */ - sngss7_info->variables = create_hashtable(16, ftdm_hash_hashfromstring, ftdm_hash_equalkeys); - ftdm_assert_return(sngss7_info->variables, FTDM_FAIL, "Failed to create hash table\n"); - } - - t_name = ftdm_strdup(var); - t_val = ftdm_strdup(val); - - hashtable_insert(sngss7_info->variables, t_name, t_val, HASHTABLE_FLAG_FREE_KEY | HASHTABLE_FLAG_FREE_VALUE); - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -ftdm_status_t sngss7_add_raw_data(sngss7_chan_data_t *sngss7_info, uint8_t* data, ftdm_size_t data_len) -{ - ftdm_assert_return(!sngss7_info->raw_data, FTDM_FAIL, "Overwriting existing raw data\n"); - - sngss7_info->raw_data = ftdm_calloc(1, data_len); - ftdm_assert_return(sngss7_info->raw_data, FTDM_FAIL, "Failed to allocate raw data\n"); - - memcpy(sngss7_info->raw_data, data, data_len); - sngss7_info->raw_data_len = data_len; - return FTDM_SUCCESS; -} - -/******************************************************************************/ -void sngss7_send_signal(sngss7_chan_data_t *sngss7_info, ftdm_signal_event_t event_id) -{ - ftdm_sigmsg_t sigev; - ftdm_channel_t *ftdmchan = sngss7_info->ftdmchan; - - memset(&sigev, 0, sizeof(sigev)); - - sigev.chan_id = ftdmchan->chan_id; - sigev.span_id = ftdmchan->span_id; - sigev.channel = ftdmchan; - sigev.event_id = event_id; - - if (sngss7_info->variables) { - /* - * variables now belongs to the ftdm core, and - * will be cleared after sigev is processed by user. Set - * local pointer to NULL so we do not attempt to - * destroy it */ - sigev.variables = sngss7_info->variables; - sngss7_info->variables = NULL; - } - - if (sngss7_info->raw_data) { - /* - * raw_data now belongs to the ftdm core, and - * will be cleared after sigev is processed by user. Set - * local pointer to NULL so we do not attempt to - * destroy it */ - - sigev.raw.data = sngss7_info->raw_data; - sigev.raw.len = sngss7_info->raw_data_len; - - sngss7_info->raw_data = NULL; - sngss7_info->raw_data_len = 0; - } - ftdm_span_send_signal(ftdmchan->span, &sigev); -} - -/******************************************************************************/ -void sngss7_set_sig_status(sngss7_chan_data_t *sngss7_info, ftdm_signaling_status_t status) -{ - ftdm_sigmsg_t sig; - ftdm_channel_t *ftdmchan = sngss7_info->ftdmchan; - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Signalling link status changed to %s\n", - ftdm_signaling_status2str(status)); - - memset(&sig, 0, sizeof(sig)); - - sig.chan_id = ftdmchan->chan_id; - sig.span_id = ftdmchan->span_id; - sig.channel = ftdmchan; - sig.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED; - sig.ev_data.sigstatus.status = status; - - if (ftdm_span_send_signal(ftdmchan->span, &sig) != FTDM_SUCCESS) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Failed to change channel status to %s\n", - ftdm_signaling_status2str(status)); - } - return; -} - -#if 0 -ftdm_status_t check_for_invalid_states(ftdm_channel_t *ftmchan) -{ - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - - if (!sngss7_info) { - SS7_WARN_CHAN(ftdmchan, "Found ftdmchan with no sig module data!%s\n", " "); - return FTDM_FAIL; - } - - if (sngss7_test_flag(sngss7_intf, SNGSS7_PAUSED)) { - return FTDM_SUCCESS; - } - - switch (ftdmchan->state) { - case UP: - case DOWN: - return FTDM_SUCCESS; - - default: - if ((ftdm_current_time_in_ms() - ftdmchan->last_state_change_time) > 30000) { - SS7_WARN_CHAN(ftdmchan, "Circuite in state=%s too long - resetting!%s\n", - ftdm_channel_state2str(ftdmchan->state)); - - ftdm_channel_lock(ftdmchan); - - if (sngss7_channel_status_clear(sngss7_info)) { - sngss7_tx_reset_restart(sngss7_info); - - if (ftdmchan->state == FTDM_CHANNEL_STATE_RESTART) { - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); - } else { - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RESTART); - } - } else { - - } - - - - ftdm_channel_unlock(ftdmchan); - } - } - - return FTDM_SUCCESS; -} -#endif - - -/******************************************************************************/ -ftdm_status_t check_for_reconfig_flag(ftdm_span_t *ftdmspan) -{ - ftdm_channel_t *ftdmchan = NULL; - sngss7_chan_data_t *sngss7_info = NULL; - sng_isup_inf_t *sngss7_intf = NULL; - uint8_t state; - uint8_t bits_ab = 0; - uint8_t bits_cd = 0; - uint8_t bits_ef = 0; - int x; - int ret; - ret=0; - - for (x = 1; x < (ftdmspan->chan_count + 1); x++) { - /**************************************************************************/ - /* extract the channel structure and sngss7 channel data */ - ftdmchan = ftdmspan->channels[x]; - - /* if the call data is NULL move on */ - if (ftdmchan->call_data == NULL) { - SS7_WARN_CHAN(ftdmchan, "Found ftdmchan with no sig module data!%s\n", " "); - continue; - } - - /* grab the private data */ - sngss7_info = ftdmchan->call_data; - - /* check the reconfig flag */ - if (sngss7_test_ckt_flag(sngss7_info, FLAG_CKT_RECONFIG)) { - /* confirm the state of all isup interfaces*/ - check_status_of_all_isup_intf(); - - sngss7_intf = &g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info->circuit->infId]; - - /* check if the interface is paused or resumed */ - if (sngss7_test_flag(sngss7_intf, SNGSS7_PAUSED)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Circuit set to PAUSED %s\n"," "); - /* throw the pause flag */ - sngss7_clear_ckt_flag(sngss7_info, FLAG_INFID_RESUME); - sngss7_set_ckt_flag(sngss7_info, FLAG_INFID_PAUSED); - } else { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Circuit set to RESUMED %s\n"," "); - /* throw the resume flag */ - sngss7_clear_ckt_flag(sngss7_info, FLAG_INFID_PAUSED); - sngss7_set_ckt_flag(sngss7_info, FLAG_INFID_RESUME); - } - - /* query for the status of the ckt */ - if (ftmod_ss7_isup_ckt_sta(sngss7_info->circuit->id, &state)) { - /* NC: Circuit statistic failed: does not exist. Must re-configure circuit - Reset the circuit CONFIGURED flag so that RESUME will reconfigure - this circuit. */ - sngss7_info->circuit->flags &= ~SNGSS7_CONFIGURED; - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR,"Failed to read isup ckt = %d status\n", sngss7_info->circuit->id); - continue; - } - - /* extract the bit sections */ - bits_ab = (state & (SNG_BIT_A + SNG_BIT_B)) >> 0; - bits_cd = (state & (SNG_BIT_C + SNG_BIT_D)) >> 2; - bits_ef = (state & (SNG_BIT_E + SNG_BIT_F)) >> 4; - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Circuit state=0x%X ab=0x%X cd=0x%X ef=0x%X\n",state,bits_ab,bits_cd,bits_ef); - - if (bits_cd == 0x0) { - /* check if circuit is UCIC or transient */ - if (bits_ab == 0x3) { - SS7_INFO("ISUP CKT %d re-configuration pending!\n", x); - sngss7_info->circuit->flags &= ~SNGSS7_CONFIGURED; - SS7_STATE_CHANGE(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); - - /* NC: The code below should be deleted. Its here for hitorical - reason. The RESUME code will reconfigure the channel since - the CONFIGURED flag has been reset */ -#if 0 - /* bit a and bit b are set, unequipped */ - ret = ftmod_ss7_isup_ckt_config(sngss7_info->circuit->id); - if (ret) { - SS7_CRITICAL("ISUP CKT %d re-configuration FAILED!\n",x); - } else { - SS7_INFO("ISUP CKT %d re-configuration DONE!\n", x); - } - - /* reset the circuit to sync states */ - ftdm_mutex_lock(ftdmchan->mutex); - - /* flag the circuit as active */ - sngss7_set_flag(sngss7_info->circuit, SNGSS7_ACTIVE); - - /* throw the channel into reset */ - sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_TX); - - /* throw the channel to suspend */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); - - /* unlock the channel */ - ftdm_mutex_unlock(ftdmchan->mutex); -#endif - - } else { /* if (bits_ab == 0x3) */ - /* The stack status is not blocked. However this is possible if - the circuit state was UP. So even though Master sent out the BLO - the status command is not showing it. - - As a kudge. We will try to send out an UBL even though the status - indicates that there is no BLO. */ - if (!sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX)) { - sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_UNBLK_TX); - - /* set the channel to suspended state */ - SS7_STATE_CHANGE(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); - } - } - } else { - /* check the maintenance block status in bits A and B */ - switch (bits_ab) { - /**************************************************************************/ - case (0): - /* no maintenace block...do nothing */ - break; - /**************************************************************************/ - case (1): - /* The stack status is Blocked. Check if the block was sent - by user via console. If the block was not sent by user then, it - was sent out by Master due to relay down. - Therefore send out the unblock to clear it */ - if (!sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX)) { - sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_UNBLK_TX); - - /* set the channel to suspended state */ - SS7_STATE_CHANGE(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); - } - - /* Only locally blocked, thus remove a remote block */ - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX); - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX_DN); - - break; - /**************************************************************************/ - case (2): - /* remotely blocked */ - sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX); - sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX_DN); - - /* set the channel to suspended state */ - SS7_STATE_CHANGE(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); - break; - /**************************************************************************/ - case (3): - /* both locally and remotely blocked */ - if (!sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX)) { - sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_UNBLK_TX); - } - sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX); - sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX_DN); - - /* set the channel to suspended state */ - SS7_STATE_CHANGE(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); - break; - /**************************************************************************/ - default: - break; - /**************************************************************************/ - } /* switch (bits_ab) */ - - /* check the hardware block status in bits e and f */ - switch (bits_ef) { - /**************************************************************************/ - case (0): - /* no maintenace block...do nothing */ - break; - /**************************************************************************/ - case (1): - /* locally blocked */ - sngss7_set_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_TX); - - /* set the channel to suspended state */ - SS7_STATE_CHANGE(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); - break; - /**************************************************************************/ - case (2): - /* remotely blocked */ - sngss7_set_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX); - - /* set the channel to suspended state */ - SS7_STATE_CHANGE(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); - break; - /**************************************************************************/ - case (3): - /* both locally and remotely blocked */ - sngss7_set_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_TX); - sngss7_set_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX); - - /* set the channel to suspended state */ - SS7_STATE_CHANGE(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); - break; - /**************************************************************************/ - default: - break; - /**************************************************************************/ - } /* switch (bits_ef) */ - } - - /* clear the re-config flag ... no matter what */ - sngss7_clear_ckt_flag(sngss7_info, FLAG_CKT_RECONFIG); - - } - } /* for (x = 1; x < (span->chan_count + 1); x++) */ - - return FTDM_SUCCESS; -} - -ftdm_status_t sngss7_bufferzero_iam(SiConEvnt *siConEvnt) -{ - if (siConEvnt->natConInd.eh.pres != PRSNT_NODEF) memset(&siConEvnt->natConInd, 0, sizeof(siConEvnt->natConInd)); - if (siConEvnt->fwdCallInd.eh.pres != PRSNT_NODEF) memset(&siConEvnt->fwdCallInd, 0, sizeof(siConEvnt->fwdCallInd)); - if (siConEvnt->cgPtyCat.eh.pres != PRSNT_NODEF) memset(&siConEvnt->cgPtyCat, 0, sizeof(siConEvnt->cgPtyCat)); - if (siConEvnt->txMedReq.eh.pres != PRSNT_NODEF) memset(&siConEvnt->txMedReq, 0, sizeof(siConEvnt->txMedReq)); -#if (SS7_ANS88 || SS7_ANS92 || SS7_ANS95 || SS7_BELL) - if (siConEvnt->usrServInfoA.eh.pres != PRSNT_NODEF) memset(&siConEvnt->usrServInfoA, 0, sizeof(siConEvnt->usrServInfoA)); -#endif - if (siConEvnt->cdPtyNum.eh.pres != PRSNT_NODEF) memset(&siConEvnt->cdPtyNum, 0, sizeof(siConEvnt->cdPtyNum)); -#if TNS_ANSI -#if (SS7_ANS92 || SS7_ANS95 || SS7_BELL) - if (siConEvnt->tranNetSel1.eh.pres != PRSNT_NODEF) memset(&siConEvnt->tranNetSel1, 0, sizeof(siConEvnt->tranNetSel1)); -#endif -#endif - if (siConEvnt->tranNetSel.eh.pres != PRSNT_NODEF) memset(&siConEvnt->tranNetSel, 0, sizeof(siConEvnt->tranNetSel)); -#if (SS7_ANS88 || SS7_ANS92 || SS7_ANS95 || SS7_BELL || SS7_CHINA) - if (siConEvnt->callRefA.eh.pres != PRSNT_NODEF) memset(&siConEvnt->callRefA, 0, sizeof(siConEvnt->callRefA)); -#endif - if (siConEvnt->callRef.eh.pres != PRSNT_NODEF) memset(&siConEvnt->callRef, 0, sizeof(siConEvnt->callRef)); - if (siConEvnt->cgPtyNum.eh.pres != PRSNT_NODEF) memset(&siConEvnt->cgPtyNum, 0, sizeof(siConEvnt->cgPtyNum)); -#if SS7_BELL - if (siConEvnt->cgPtyNumB.eh.pres != PRSNT_NODEF) memset(&siConEvnt->cgPtyNumB, 0, sizeof(siConEvnt->cgPtyNumB)); -#endif - if (siConEvnt->opFwdCalInd.eh.pres != PRSNT_NODEF) memset(&siConEvnt->opFwdCalInd, 0, sizeof(siConEvnt->opFwdCalInd)); -#if (SS7_Q767 || SS7_RUSSIA || SS7_NTT) - if (siConEvnt->opFwdCalIndQ.eh.pres != PRSNT_NODEF) memset(&siConEvnt->opFwdCalIndQ, 0, sizeof(siConEvnt->opFwdCalIndQ)); -#endif -#if SS7_Q767IT - if (siConEvnt->fwdVad.eh.pres != PRSNT_NODEF) memset(&siConEvnt->fwdVad, 0, sizeof(siConEvnt->fwdVad)); -#endif -#if SS7_ANS88 - if (siConEvnt->opFwdCalIndA.eh.pres != PRSNT_NODEF) memset(&siConEvnt->opFwdCalIndA, 0, sizeof(siConEvnt->opFwdCalIndA)); -#endif - if (siConEvnt->redirgNum.eh.pres != PRSNT_NODEF) memset(&siConEvnt->redirgNum, 0, sizeof(siConEvnt->redirgNum)); - if (siConEvnt->redirInfo.eh.pres != PRSNT_NODEF) memset(&siConEvnt->redirInfo, 0, sizeof(siConEvnt->redirInfo)); - if (siConEvnt->cugIntCode.eh.pres != PRSNT_NODEF) memset(&siConEvnt->cugIntCode, 0, sizeof(siConEvnt->cugIntCode)); -#if SS7_ANS88 - if (siConEvnt->cugIntCodeA.eh.pres != PRSNT_NODEF) memset(&siConEvnt->cugIntCodeA, 0, sizeof(siConEvnt->cugIntCodeA)); -#endif -#if (SS7_ANS88 || SS7_ANS92 || SS7_ANS95 || SS7_BELL || SS7_CHINA) - if (siConEvnt->connReqA.eh.pres != PRSNT_NODEF) memset(&siConEvnt->connReqA, 0, sizeof(siConEvnt->connReqA)); -#endif -#if SS7_ANS88 - if (siConEvnt->usr2UsrInfoA.eh.pres != PRSNT_NODEF) memset(&siConEvnt->usr2UsrInfoA, 0, sizeof(siConEvnt->usr2UsrInfoA)); -#endif - if (siConEvnt->connReq.eh.pres != PRSNT_NODEF) memset(&siConEvnt->connReq, 0, sizeof(siConEvnt->connReq)); - if (siConEvnt->origCdNum.eh.pres != PRSNT_NODEF) memset(&siConEvnt->origCdNum, 0, sizeof(siConEvnt->origCdNum)); - if (siConEvnt->usr2UsrInfo.eh.pres != PRSNT_NODEF) memset(&siConEvnt->usr2UsrInfo, 0, sizeof(siConEvnt->usr2UsrInfo)); - if (siConEvnt->accTrnspt.eh.pres != PRSNT_NODEF) memset(&siConEvnt->accTrnspt, 0, sizeof(siConEvnt->accTrnspt)); - if (siConEvnt->echoControl.eh.pres != PRSNT_NODEF) memset(&siConEvnt->echoControl, 0, sizeof(siConEvnt->echoControl)); -#if SS7_ANS88 - if (siConEvnt->redirInfoA.eh.pres != PRSNT_NODEF) memset(&siConEvnt->redirInfoA, 0, sizeof(siConEvnt->redirInfoA)); -#endif -#if (SS7_ANS88 || SS7_ANS92 || SS7_ANS95 || SS7_BELL) - if (siConEvnt->chargeNum.eh.pres != PRSNT_NODEF) memset(&siConEvnt->chargeNum, 0, sizeof(siConEvnt->chargeNum)); - if (siConEvnt->origLineInf.eh.pres != PRSNT_NODEF) memset(&siConEvnt->origLineInf, 0, sizeof(siConEvnt->origLineInf)); -#endif - if (siConEvnt->usrServInfo.eh.pres != PRSNT_NODEF) memset(&siConEvnt->usrServInfo, 0, sizeof(siConEvnt->usrServInfo)); - if (siConEvnt->usr2UsrInd.eh.pres != PRSNT_NODEF) memset(&siConEvnt->usr2UsrInd, 0, sizeof(siConEvnt->usr2UsrInd)); - if (siConEvnt->propDly.eh.pres != PRSNT_NODEF) memset(&siConEvnt->propDly, 0, sizeof(siConEvnt->propDly)); - if (siConEvnt->usrServInfo1.eh.pres != PRSNT_NODEF) memset(&siConEvnt->usrServInfo1, 0, sizeof(siConEvnt->usrServInfo1)); - if (siConEvnt->netFac.eh.pres != PRSNT_NODEF) memset(&siConEvnt->netFac, 0, sizeof(siConEvnt->netFac)); -#ifdef SS7_CHINA - if (siConEvnt->orgPteCdeA.eh.pres != PRSNT_NODEF) memset(&siConEvnt->orgPteCdeA, 0, sizeof(siConEvnt->orgPteCdeA)); -#endif - if (siConEvnt->orgPteCde.eh.pres != PRSNT_NODEF) memset(&siConEvnt->orgPteCde, 0, sizeof(siConEvnt->orgPteCde)); - if (siConEvnt->genDigits.eh.pres != PRSNT_NODEF) memset(&siConEvnt->genDigits, 0, sizeof(siConEvnt->genDigits)); - if (siConEvnt->genDigitsR.eh.pres != PRSNT_NODEF) memset(&siConEvnt->genDigitsR, 0, sizeof(siConEvnt->genDigitsR)); - if (siConEvnt->usrTSrvInfo.eh.pres != PRSNT_NODEF) memset(&siConEvnt->usrTSrvInfo, 0, sizeof(siConEvnt->usrTSrvInfo)); - if (siConEvnt->remotOper.eh.pres != PRSNT_NODEF) memset(&siConEvnt->remotOper, 0, sizeof(siConEvnt->remotOper)); - if (siConEvnt->parmCom.eh.pres != PRSNT_NODEF) memset(&siConEvnt->parmCom, 0, sizeof(siConEvnt->parmCom)); -#if (SS7_ANS92 || SS7_ANS95) - if (siConEvnt->servCode.eh.pres != PRSNT_NODEF) memset(&siConEvnt->servCode, 0, sizeof(siConEvnt->servCode)); -#endif -#if SS7_ANS92 - if (siConEvnt->serviceAct1.eh.pres != PRSNT_NODEF) memset(&siConEvnt->serviceAct1, 0, sizeof(siConEvnt->serviceAct1)); -#endif -#if SS7_CHINA - if (siConEvnt->serviceAct2.eh.pres != PRSNT_NODEF) memset(&siConEvnt->serviceAct2, 0, sizeof(siConEvnt->serviceAct2)); -#endif - if (siConEvnt->serviceAct2.eh.pres != PRSNT_NODEF) memset(&siConEvnt->serviceAct2, 0, sizeof(siConEvnt->serviceAct2)); - if (siConEvnt->serviceAct.eh.pres != PRSNT_NODEF) memset(&siConEvnt->serviceAct, 0, sizeof(siConEvnt->serviceAct)); - if (siConEvnt->mlppPrec.eh.pres != PRSNT_NODEF) memset(&siConEvnt->mlppPrec, 0, sizeof(siConEvnt->mlppPrec)); -#if (defined(SIT_PARAMETER) || defined(TDS_ROLL_UPGRADE_SUPPORT)) - if (siConEvnt->txMedUsPr.eh.pres != PRSNT_NODEF) memset(&siConEvnt->txMedUsPr, 0, sizeof(siConEvnt->txMedUsPr)); -#endif - if (siConEvnt->bckCallInd.eh.pres != PRSNT_NODEF) memset(&siConEvnt->bckCallInd, 0, sizeof(siConEvnt->bckCallInd)); - if (siConEvnt->cgPtyNum1.eh.pres != PRSNT_NODEF) memset(&siConEvnt->cgPtyNum1, 0, sizeof(siConEvnt->cgPtyNum1)); - if (siConEvnt->optBckCalInd.eh.pres != PRSNT_NODEF) memset(&siConEvnt->optBckCalInd, 0, sizeof(siConEvnt->optBckCalInd)); -#if (SS7_Q767 || SS7_RUSSIA || SS7_NTT) - if (siConEvnt->optBckCalIndQ.eh.pres != PRSNT_NODEF) memset(&siConEvnt->optBckCalIndQ, 0, sizeof(siConEvnt->optBckCalIndQ)); -#endif - if (siConEvnt->connNum.eh.pres != PRSNT_NODEF) memset(&siConEvnt->connNum, 0, sizeof(siConEvnt->connNum)); -#if (defined(SIT_PARAMETER) || defined(TDS_ROLL_UPGRADE_SUPPORT)) - if (siConEvnt->connNum2.eh.pres != PRSNT_NODEF) memset(&siConEvnt->connNum2, 0, sizeof(siConEvnt->connNum2)); -#endif - if (siConEvnt->accDelInfo.eh.pres != PRSNT_NODEF) memset(&siConEvnt->accDelInfo, 0, sizeof(siConEvnt->accDelInfo)); - if (siConEvnt->notifInd.eh.pres != PRSNT_NODEF) memset(&siConEvnt->notifInd, 0, sizeof(siConEvnt->notifInd)); - if (siConEvnt->notifIndR2.eh.pres != PRSNT_NODEF) memset(&siConEvnt->notifIndR2, 0, sizeof(siConEvnt->notifIndR2)); - if (siConEvnt->cllHstry.eh.pres != PRSNT_NODEF) memset(&siConEvnt->cllHstry, 0, sizeof(siConEvnt->cllHstry)); - if (siConEvnt->genNmb.eh.pres != PRSNT_NODEF) memset(&siConEvnt->genNmb, 0, sizeof(siConEvnt->genNmb)); - if (siConEvnt->genNmbR.eh.pres != PRSNT_NODEF) memset(&siConEvnt->genNmbR, 0, sizeof(siConEvnt->genNmbR)); - if (siConEvnt->redirNum.eh.pres != PRSNT_NODEF) memset(&siConEvnt->redirNum, 0, sizeof(siConEvnt->redirNum)); - if (siConEvnt->redirRstr.eh.pres != PRSNT_NODEF) memset(&siConEvnt->redirRstr, 0, sizeof(siConEvnt->redirRstr)); - -#if SS7_Q767IT - if (siConEvnt->backVad.eh.pres != PRSNT_NODEF) memset(&siConEvnt->backVad, 0, sizeof(siConEvnt->backVad)); -#endif -#if SS7_SINGTEL - if (siConEvnt->cgPtyNumS.eh.pres != PRSNT_NODEF) memset(&siConEvnt->cgPtyNumS, 0, sizeof(siConEvnt->cgPtyNumS)); -#endif -#if (SS7_ANS92 || SS7_ANS95 || SS7_BELL) - if (siConEvnt->businessGrp.eh.pres != PRSNT_NODEF) memset(&siConEvnt->businessGrp, 0, sizeof(siConEvnt->businessGrp)); - if (siConEvnt->infoInd.eh.pres != PRSNT_NODEF) memset(&siConEvnt->infoInd, 0, sizeof(siConEvnt->infoInd)); - if (siConEvnt->carrierId.eh.pres != PRSNT_NODEF) memset(&siConEvnt->carrierId, 0, sizeof(siConEvnt->carrierId)); - if (siConEvnt->carSelInf.eh.pres != PRSNT_NODEF) memset(&siConEvnt->carSelInf, 0, sizeof(siConEvnt->carSelInf)); - if (siConEvnt->egress.eh.pres != PRSNT_NODEF) memset(&siConEvnt->egress, 0, sizeof(siConEvnt->egress)); - if (siConEvnt->genAddr.eh.pres != PRSNT_NODEF) memset(&siConEvnt->genAddr, 0, sizeof(siConEvnt->genAddr)); - if (siConEvnt->genAddrR.eh.pres != PRSNT_NODEF) memset(&siConEvnt->genAddrR, 0, sizeof(siConEvnt->genAddrR)); - if (siConEvnt->infoReqInd.eh.pres != PRSNT_NODEF) memset(&siConEvnt->infoReqInd, 0, sizeof(siConEvnt->infoReqInd)); - if (siConEvnt->jurisInf.eh.pres != PRSNT_NODEF) memset(&siConEvnt->jurisInf, 0, sizeof(siConEvnt->jurisInf)); - if (siConEvnt->netTransport.eh.pres != PRSNT_NODEF) memset(&siConEvnt->netTransport, 0, sizeof(siConEvnt->netTransport)); - if (siConEvnt->specProcReq.eh.pres != PRSNT_NODEF) memset(&siConEvnt->specProcReq, 0, sizeof(siConEvnt->specProcReq)); - if (siConEvnt->transReq.eh.pres != PRSNT_NODEF) memset(&siConEvnt->transReq, 0, sizeof(siConEvnt->transReq)); -#endif -#if (defined(SIT_PARAMETER) || defined(TDS_ROLL_UPGRADE_SUPPORT)) -#if (SS7_ANS92 || SS7_ANS95) - if (siConEvnt->notifInd1.eh.pres != PRSNT_NODEF) memset(&siConEvnt->notifInd1, 0, sizeof(siConEvnt->notifInd1)); - if (siConEvnt->notifIndR1.eh.pres != PRSNT_NODEF) memset(&siConEvnt->notifIndR1, 0, sizeof(siConEvnt->notifIndR1)); -#endif /* SS7_ANS92 */ -#endif /* SIT_PARAMETER || TDS_ROLL_UPGRADE_SUPPORT */ -#if (SS7_BELL || SS7_ANS95) - if (siConEvnt->genName.eh.pres != PRSNT_NODEF) memset(&siConEvnt->genName, 0, sizeof(siConEvnt->genName)); -#endif -#if (SS7_ITU97 || SS7_RUSS2000 || SS7_ITU2000 || SS7_ETSIV3 || \ - SS7_BELL || SS7_ANS95 || SS7_INDIA || SS7_UK || SS7_NZL || SS7_KZ) - if (siConEvnt->hopCounter.eh.pres != PRSNT_NODEF) memset(&siConEvnt->hopCounter, 0, sizeof(siConEvnt->hopCounter)); -#endif -#if (SS7_BELL || SS7_ITU2000 || SS7_KZ) - if (siConEvnt->redirCap.eh.pres != PRSNT_NODEF) memset(&siConEvnt->redirCap, 0, sizeof(siConEvnt->redirCap)); - if (siConEvnt->redirCntr.eh.pres != PRSNT_NODEF) memset(&siConEvnt->redirCntr, 0, sizeof(siConEvnt->redirCntr)); -#endif -#if (SS7_ETSI || SS7_FTZ) - if (siConEvnt->ccbsParam.eh.pres != PRSNT_NODEF) memset(&siConEvnt->ccbsParam, 0, sizeof(siConEvnt->ccbsParam)); - if (siConEvnt->freePhParam.eh.pres != PRSNT_NODEF) memset(&siConEvnt->freePhParam, 0, sizeof(siConEvnt->freePhParam)); -#endif -#ifdef SS7_FTZ - if (siConEvnt->naPaFF.eh.pres != PRSNT_NODEF) memset(&siConEvnt->naPaFF, 0, sizeof(siConEvnt->naPaFF)); - if (siConEvnt->naPaFE.eh.pres != PRSNT_NODEF) memset(&siConEvnt->naPaFE, 0, sizeof(siConEvnt->naPaFE)); - if (siConEvnt->naPaSSP.eh.pres != PRSNT_NODEF) memset(&siConEvnt->naPaSSP, 0, sizeof(siConEvnt->naPaSSP)); - if (siConEvnt->naPaCdPNO.eh.pres != PRSNT_NODEF) memset(&siConEvnt->naPaCdPNO, 0, sizeof(siConEvnt->naPaCdPNO)); - if (siConEvnt->naPaSPV.eh.pres != PRSNT_NODEF) memset(&siConEvnt->naPaSPV, 0, sizeof(siConEvnt->naPaSPV)); - if (siConEvnt->naPaUKK.eh.pres != PRSNT_NODEF) memset(&siConEvnt->naPaUKK, 0, sizeof(siConEvnt->naPaUKK)); -#endif -#if SS7_NTT - if (siConEvnt->msgAreaInfo.eh.pres != PRSNT_NODEF) memset(&siConEvnt->msgAreaInfo, 0, sizeof(siConEvnt->msgAreaInfo)); - if (siConEvnt->subsNumber.eh.pres != PRSNT_NODEF) memset(&siConEvnt->subsNumber, 0, sizeof(siConEvnt->subsNumber)); - if (siConEvnt->rpCllngNo.eh.pres != PRSNT_NODEF) memset(&siConEvnt->rpCllngNo, 0, sizeof(siConEvnt->rpCllngNo)); - if (siConEvnt->supplUserType.eh.pres != PRSNT_NODEF) memset(&siConEvnt->supplUserType, 0, sizeof(siConEvnt->supplUserType)); - if (siConEvnt->carrierInfoTrans.eh.pres != PRSNT_NODEF) memset(&siConEvnt->carrierInfoTrans, 0, sizeof(siConEvnt->carrierInfoTrans)); - if (siConEvnt->nwFuncType.eh.pres != PRSNT_NODEF) memset(&siConEvnt->nwFuncType, 0, sizeof(siConEvnt->nwFuncType)); -#endif -#if SS7_ANS95 - if (siConEvnt->optrServicesInfo.eh.pres != PRSNT_NODEF) memset(&siConEvnt->optrServicesInfo, 0, sizeof(siConEvnt->optrServicesInfo)); -#endif -#if (SS7_ANS95 || SS7_ITU97 || SS7_RUSS2000|| SS7_ITU2000 || SS7_NZL || SS7_KZ) - if (siConEvnt->cirAsgnMap.eh.pres != PRSNT_NODEF) memset(&siConEvnt->cirAsgnMap, 0, sizeof(siConEvnt->cirAsgnMap)); -#endif -#if (SS7_ITU97 || SS7_RUSS2000 || SS7_ITU2000 || SS7_ETSIV3 || \ - SS7_INDIA || SS7_UK || SS7_NZL || SS7_KZ) - if (siConEvnt->displayInfo.eh.pres != PRSNT_NODEF) memset(&siConEvnt->displayInfo, 0, sizeof(siConEvnt->displayInfo)); - if (siConEvnt->confTrtInd.eh.pres != PRSNT_NODEF) memset(&siConEvnt->confTrtInd, 0, sizeof(siConEvnt->confTrtInd)); - if (siConEvnt->netMgmtControls.eh.pres != PRSNT_NODEF) memset(&siConEvnt->netMgmtControls, 0, sizeof(siConEvnt->netMgmtControls)); - if (siConEvnt->correlationId.eh.pres != PRSNT_NODEF) memset(&siConEvnt->correlationId, 0, sizeof(siConEvnt->correlationId)); - if (siConEvnt->callDivTrtInd.eh.pres != PRSNT_NODEF) memset(&siConEvnt->callDivTrtInd, 0, sizeof(siConEvnt->callDivTrtInd)); - if (siConEvnt->callInNmb.eh.pres != PRSNT_NODEF) memset(&siConEvnt->callInNmb, 0, sizeof(siConEvnt->callInNmb)); - if (siConEvnt->callOfferTrtInd.eh.pres != PRSNT_NODEF) memset(&siConEvnt->callOfferTrtInd, 0, sizeof(siConEvnt->callOfferTrtInd)); - if (siConEvnt->scfId.eh.pres != PRSNT_NODEF) memset(&siConEvnt->scfId, 0, sizeof(siConEvnt->scfId)); - if (siConEvnt->uidCapInd.eh.pres != PRSNT_NODEF) memset(&siConEvnt->uidCapInd, 0, sizeof(siConEvnt->uidCapInd)); - if (siConEvnt->collCallReq.eh.pres != PRSNT_NODEF) memset(&siConEvnt->collCallReq, 0, sizeof(siConEvnt->collCallReq)); - if (siConEvnt->ccss.eh.pres != PRSNT_NODEF) memset(&siConEvnt->ccss, 0, sizeof(siConEvnt->ccss)); -#endif -#if (SS7_ITU97 || SS7_RUSS2000 || SS7_ITU2000 || SS7_UK || SS7_NZL || SS7_KZ) - if (siConEvnt->backGVNS.eh.pres != PRSNT_NODEF) memset(&siConEvnt->backGVNS, 0, sizeof(siConEvnt->backGVNS)); - if (siConEvnt->forwardGVNS.eh.pres != PRSNT_NODEF) memset(&siConEvnt->forwardGVNS, 0, sizeof(siConEvnt->forwardGVNS)); -#endif -#if (SS7_ETSIV3 || SS7_ITU97 || SS7_RUSS2000 || SS7_ITU2000 || \ - SS7_INDIA || SS7_UK || SS7_NZL || SS7_KZ) - if (siConEvnt->appTransParam.eh.pres != PRSNT_NODEF) memset(&siConEvnt->appTransParam, 0, sizeof(siConEvnt->appTransParam)); -#endif -#if (SS7_ITU2000 || SS7_UK || SS7_NZL || SS7_KZ) - if (siConEvnt->htrInfo.eh.pres != PRSNT_NODEF) memset(&siConEvnt->htrInfo, 0, sizeof(siConEvnt->htrInfo)); - if (siConEvnt->pivotCap.eh.pres != PRSNT_NODEF) memset(&siConEvnt->pivotCap, 0, sizeof(siConEvnt->pivotCap)); - if (siConEvnt->cadDirNmb.eh.pres != PRSNT_NODEF) memset(&siConEvnt->cadDirNmb, 0, sizeof(siConEvnt->cadDirNmb)); - if (siConEvnt->origCallInNum.eh.pres != PRSNT_NODEF) memset(&siConEvnt->origCallInNum, 0, sizeof(siConEvnt->origCallInNum)); - if (siConEvnt->calgGeoLoc.eh.pres != PRSNT_NODEF) memset(&siConEvnt->calgGeoLoc, 0, sizeof(siConEvnt->calgGeoLoc)); - if (siConEvnt->netRoutNum.eh.pres != PRSNT_NODEF) memset(&siConEvnt->netRoutNum, 0, sizeof(siConEvnt->netRoutNum)); - if (siConEvnt->qonRelCap.eh.pres != PRSNT_NODEF) memset(&siConEvnt->qonRelCap, 0, sizeof(siConEvnt->qonRelCap)); - if (siConEvnt->pivotCntr.eh.pres != PRSNT_NODEF) memset(&siConEvnt->pivotCntr, 0, sizeof(siConEvnt->pivotCntr)); - if (siConEvnt->pivotRtgFwInfo.eh.pres != PRSNT_NODEF) memset(&siConEvnt->pivotRtgFwInfo, 0, sizeof(siConEvnt->pivotRtgFwInfo)); - if (siConEvnt->pivotRtgBkInfo.eh.pres != PRSNT_NODEF) memset(&siConEvnt->pivotRtgBkInfo, 0, sizeof(siConEvnt->pivotRtgBkInfo)); - if (siConEvnt->numPortFwdInfo.eh.pres != PRSNT_NODEF) memset(&siConEvnt->numPortFwdInfo, 0, sizeof(siConEvnt->numPortFwdInfo)); -#endif -#ifdef SS7_UK - if (siConEvnt->natFwdCalInd.eh.pres != PRSNT_NODEF) memset(&siConEvnt->natFwdCalInd, 0, sizeof(siConEvnt->natFwdCalInd)); - if (siConEvnt->presntNum.eh.pres != PRSNT_NODEF) memset(&siConEvnt->presntNum, 0, sizeof(siConEvnt->presntNum)); - if (siConEvnt->lstDvrtLineId.eh.pres != PRSNT_NODEF) memset(&siConEvnt->lstDvrtLineId, 0, sizeof(siConEvnt->lstDvrtLineId)); - if (siConEvnt->pcgLineId.eh.pres != PRSNT_NODEF) memset(&siConEvnt->pcgLineId, 0, sizeof(siConEvnt->pcgLineId)); - if (siConEvnt->natFwdCalIndLnk.eh.pres != PRSNT_NODEF) memset(&siConEvnt->natFwdCalIndLnk, 0, sizeof(siConEvnt->natFwdCalIndLnk)); - if (siConEvnt->cdBascSrvcMrk.eh.pres != PRSNT_NODEF) memset(&siConEvnt->cdBascSrvcMrk, 0, sizeof(siConEvnt->cdBascSrvcMrk)); -#endif /* SS7_UK */ -#if (defined(CGPN_CHK)) - if (siConEvnt->causeDgnCgPnChk.eh.pres != PRSNT_NODEF) memset(&siConEvnt->causeDgnCgPnChk, 0, sizeof(siConEvnt->causeDgnCgPnChk)); -#endif - return FTDM_SUCCESS; -} - -ftdm_status_t sngss7_save_iam(ftdm_channel_t *ftdmchan, SiConEvnt *siConEvnt) -{ -#ifndef HAVE_ZLIB - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "Cannot perform transparent IAM because zlib is missing\n"); - return FTDM_FAIL; -#else - unsigned ret_val = FTDM_FAIL; - char *compressed_iam = NULL; - char *url_encoded_iam = NULL; - uLongf len = sizeof(*siConEvnt); - sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - - /* By default, Trillium does not memset their whole structure to zero for - * performance. But we want to memset all the IE's that are not present to - * optimize compressed size */ - sngss7_bufferzero_iam(siConEvnt); - - compressed_iam = ftdm_malloc(sizeof(*siConEvnt)); - if (!compressed_iam) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "Failed to allocate buffer for compressed_iam\n"); - goto done; - } - - /* Compress IAM structure to minimize buffer size */ - ret_val = compress((Bytef *)compressed_iam, &len, (const Bytef *)siConEvnt, (uLong)sizeof(*siConEvnt)); - if (ret_val != Z_OK) { - ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Failed to compress IAM (error:%d)\n", ret_val); - ret_val = FTDM_FAIL; - goto done; - } - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Compressed IAM size:%lu\n", len); - - /* Worst case: size will triple after url encode */ - url_encoded_iam = ftdm_malloc(3*sizeof(*siConEvnt)); - if (!url_encoded_iam) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "Failed to allocated buffer for url_encoded_iam\n"); - ret_val = FTDM_FAIL; - goto done; - } - memset(url_encoded_iam, 0, 2*sizeof(*siConEvnt)); - - /* URL encode buffer to that its safe to store it in a string */ - ftdm_url_encode((const char*)compressed_iam, url_encoded_iam, len); - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "IAM variable length:%"FTDM_SIZE_FMT"\n", strlen(url_encoded_iam)); - - if (strlen(url_encoded_iam) > sngss7_info->circuit->transparent_iam_max_size) { - ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "IAM variable length exceeds max size (len:%d max:%d) \n", - strlen(url_encoded_iam), sngss7_info->circuit->transparent_iam_max_size); - ret_val = FTDM_FAIL; - goto done; - } - - sngss7_add_var(sngss7_info, "ss7_iam", url_encoded_iam); -done: - ftdm_safe_free(compressed_iam); - ftdm_safe_free(url_encoded_iam); - return ret_val; -#endif -} - -ftdm_status_t sngss7_retrieve_iam(ftdm_channel_t *ftdmchan, SiConEvnt *siConEvnt) -{ -#ifndef HAVE_ZLIB - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "Cannot perform transparent IAM because zlib is missing\n"); - return FTDM_FAIL; -#else - uLongf len = 3*sizeof(*siConEvnt); /* worst case: URL encoded buffer is 3x length of buffer */ - char *val = NULL; - unsigned ret_val = FTDM_FAIL; - void *uncompressed_buffer = NULL; - char *url_encoded_iam = NULL; - ftdm_size_t url_encoded_iam_len; - - val = (char*)ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam"); - if (ftdm_strlen_zero(val)) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "No Transparent IAM info available\n"); - return FTDM_FAIL; - } - - url_encoded_iam = ftdm_strdup(val); - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "IAM variable length:%"FTDM_SIZE_FMT"\n", strlen(val)); - ftdm_url_decode(url_encoded_iam, &url_encoded_iam_len); - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Compressed IAM size:%"FTDM_SIZE_FMT"\n", url_encoded_iam_len); - - uncompressed_buffer = ftdm_malloc(sizeof(*siConEvnt)); - ftdm_assert_return(uncompressed_buffer, FTDM_FAIL, "Failed to allocate buffer for uncompressed buffer\n"); - - ret_val = uncompress(uncompressed_buffer, &len, (const Bytef *)url_encoded_iam, (uLong)url_encoded_iam_len); - if (ret_val != Z_OK) { - ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Failed to uncompress IAM (error:%d)\n", ret_val); - goto done; - } - - if (len != sizeof(*siConEvnt)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Incompatible IAM structure size (expected:%"FTDM_SIZE_FMT" size:%"FTDM_SIZE_FMT")\n", sizeof(*siConEvnt), strlen(uncompressed_buffer)); - goto done; - } - - memcpy(siConEvnt, uncompressed_buffer, sizeof(*siConEvnt)); - ret_val = FTDM_SUCCESS; - -done: - ftdm_safe_free(uncompressed_buffer); - ftdm_safe_free(url_encoded_iam); - return ret_val; -#endif -} - -/******************************************************************************/ -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ -/******************************************************************************/ diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_timers.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_timers.c deleted file mode 100644 index 541f107704..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_timers.c +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) 2009, Sangoma Technologies - * Konrad Hammel - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Contributors: - * - * Moises Silva - * - */ - -/* INCLUDE ********************************************************************/ -#include "ftmod_sangoma_ss7_main.h" -/******************************************************************************/ - -/* DEFINES ********************************************************************/ -/******************************************************************************/ - -/* GLOBALS ********************************************************************/ - -/******************************************************************************/ - -/* PROTOTYPES *****************************************************************/ - -/******************************************************************************/ - -/* FUNCTIONS ******************************************************************/ -void handle_isup_t35(void *userdata) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_timer_data_t *timer = userdata; - sngss7_chan_data_t *sngss7_info = timer->sngss7_info; - ftdm_channel_t *ftdmchan = sngss7_info->ftdmchan; - - /* now that we have the right channel...put a lock on it so no-one else can use it */ - ftdm_channel_lock(ftdmchan); - - /* Q.764 2.2.5 Address incomplete (T35 expiry action is hangup with cause 28 according to Table A.1/Q.764) */ - SS7_ERROR("[Call-Control] Timer 35 expired on CIC = %d\n", sngss7_info->circuit->cic); - - /* set the flag to indicate this hangup is started from the local side */ - sngss7_set_ckt_flag(sngss7_info, FLAG_LOCAL_REL); - - /* hang up on timer expiry */ - ftdmchan->caller_data.hangup_cause = FTDM_CAUSE_INVALID_NUMBER_FORMAT; - - /* end the call */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_CANCEL); - - /* kill t10 t39 if active */ - if (sngss7_info->t10.hb_timer_id) { - ftdm_sched_cancel_timer (sngss7_info->t10.sched, sngss7_info->t10.hb_timer_id); - } - if (sngss7_info->t39.hb_timer_id) { - ftdm_sched_cancel_timer (sngss7_info->t39.sched, sngss7_info->t39.hb_timer_id); - } - - /*unlock*/ - ftdm_channel_unlock(ftdmchan); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); - return; -} - - -void handle_isup_t10(void *userdata) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_timer_data_t *timer = userdata; - sngss7_chan_data_t *sngss7_info = timer->sngss7_info; - ftdm_channel_t *ftdmchan = sngss7_info->ftdmchan; - - ftdm_channel_lock(ftdmchan); - - SS7_DEBUG("[Call-Control] Timer 10 expired on CIC = %d\n", sngss7_info->circuit->cic); - - /* send the call to the user */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RING); - - ftdm_channel_unlock(ftdmchan); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); -} - -void handle_isup_t39(void *userdata) -{ - SS7_FUNC_TRACE_ENTER(__FTDM_FUNC__); - - sngss7_timer_data_t *timer = userdata; - sngss7_chan_data_t *sngss7_info = timer->sngss7_info; - ftdm_channel_t *ftdmchan = sngss7_info->ftdmchan; - - /* now that we have the right channel...put a lock on it so no-one else can use it */ - ftdm_channel_lock(ftdmchan); - - /* Q.764 2.2.5 Address incomplete (T35 expiry action is hangup with cause 28 according to Table A.1/Q.764) */ - SS7_ERROR("[Call-Control] Timer 39 expired on CIC = %d\n", sngss7_info->circuit->cic); - - /* set the flag to indicate this hangup is started from the local side */ - sngss7_set_ckt_flag(sngss7_info, FLAG_LOCAL_REL); - - /* hang up on timer expiry */ - ftdmchan->caller_data.hangup_cause = FTDM_CAUSE_INVALID_NUMBER_FORMAT; - - /* end the call */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_CANCEL); - - /* kill t10 t35 if active */ - if (sngss7_info->t10.hb_timer_id) { - ftdm_sched_cancel_timer (sngss7_info->t10.sched, sngss7_info->t10.hb_timer_id); - } - if (sngss7_info->t35.hb_timer_id) { - ftdm_sched_cancel_timer (sngss7_info->t35.sched, sngss7_info->t35.hb_timer_id); - } - - /*unlock*/ - ftdm_channel_unlock(ftdmchan); - - SS7_FUNC_TRACE_EXIT(__FTDM_FUNC__); -} -/******************************************************************************/ -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ -/******************************************************************************/ - diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c deleted file mode 100644 index ad504b14b0..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c +++ /dev/null @@ -1,3454 +0,0 @@ -/* - * Copyright (c) 2009, Konrad Hammel - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - * Contributors: - * - * James Zhang - * - */ - -/* INCLUDE ********************************************************************/ -#include "ftmod_sangoma_ss7_main.h" -/******************************************************************************/ - -/* DEFINES ********************************************************************/ -/******************************************************************************/ - -/* GLOBALS ********************************************************************/ -sng_ssf_type_t sng_ssf_type_map[] = -{ - { 1, "nat" , SSF_NAT }, - { 1, "int" , SSF_INTL }, - { 1, "spare" , SSF_SPARE }, - { 1, "res" , SSF_RES }, - { 0, "", 0 }, -}; - -sng_switch_type_t sng_switch_type_map[] = -{ - { 1, "itu88" , LSI_SW_ITU , LSI_SW_ITU }, - { 1, "itu92" , LSI_SW_ITU , LSI_SW_ITU }, - { 1, "itu97" , LSI_SW_ITU97 , LSI_SW_ITU97 }, - { 1, "itu00" , LSI_SW_ITU2000 , LSI_SW_ITU2000 }, - { 1, "ansi88" , LSI_SW_ANS88 , LSI_SW_ANS88 }, - { 1, "ansi92" , LSI_SW_ANS92 , LSI_SW_ANS92 }, - { 1, "ansi95" , LSI_SW_ANS92 , LSI_SW_ANS92 }, - { 1, "etsiv2" , LSI_SW_ETSI , LSI_SW_ETSI }, - { 1, "etsiv3" , LSI_SW_ETSIV3 , LSI_SW_ETSIV3 }, - { 1, "india" , LSI_SW_INDIA , LSI_SW_INDIA }, - { 1, "uk" , LSI_SW_UK , LSI_SW_UK }, - { 1, "russia" , LSI_SW_RUSSIA , LSI_SW_RUSSIA }, - { 1, "china" , LSI_SW_CHINA , LSI_SW_CHINA }, - { 0, "", 0, 0 }, -}; - -sng_link_type_t sng_link_type_map[] = -{ - { 1, "itu88" , LSD_SW_ITU88 , LSN_SW_ITU }, - { 1, "itu92" , LSD_SW_ITU92 , LSN_SW_ITU }, - { 1, "etsi" , LSD_SW_ITU92 , LSN_SW_ITU }, - { 1, "ansi88" , LSD_SW_ANSI88, LSN_SW_ANS }, - { 1, "ansi92" , LSD_SW_ANSI92, LSN_SW_ANS }, - { 1, "ansi96" , LSD_SW_ANSI92, LSN_SW_ANS96 }, - { 0, "", 0, 0 }, -}; - -sng_mtp2_error_type_t sng_mtp2_error_type_map[] = -{ - { 1, "basic", SD_ERR_NRM }, - { 1, "pcr" , SD_ERR_CYC }, - { 0, "", 0 }, -}; - -sng_cic_cntrl_type_t sng_cic_cntrl_type_map[] = -{ - { 1, "bothway" , BOTHWAY }, - { 1, "incoming" , INCOMING }, - { 1, "outgoing" , OUTGOING }, - { 1, "controlling" , CONTROLLING }, - { 1, "controlled" , CONTROLLED }, - { 0, "", 0 }, -}; - -typedef struct sng_timeslot -{ - int channel; - int siglink; - int gap; - int hole; -}sng_timeslot_t; - -typedef struct sng_span -{ - char name[MAX_NAME_LEN]; - ftdm_span_t *span; - uint32_t ccSpanId; -} sng_span_t; - -typedef struct sng_ccSpan -{ - char name[MAX_NAME_LEN]; - uint32_t options; - uint32_t id; - uint32_t procId; - uint32_t isupInf; - uint32_t cicbase; - char ch_map[MAX_CIC_MAP_LENGTH]; - uint32_t typeCntrl; - uint32_t switchType; - uint32_t ssf; - uint32_t clg_nadi; - uint32_t cld_nadi; - uint32_t rdnis_nadi; - uint32_t loc_nadi; - uint32_t min_digits; - uint32_t transparent_iam_max_size; - uint8_t transparent_iam; - uint8_t cpg_on_progress_media; - uint8_t cpg_on_progress; - uint8_t itx_auto_reply; - uint32_t t3; - uint32_t t10; - uint32_t t12; - uint32_t t13; - uint32_t t14; - uint32_t t15; - uint32_t t16; - uint32_t t17; - uint32_t t35; - uint32_t t39; - uint32_t tval; -} sng_ccSpan_t; - -int cmbLinkSetId; -/******************************************************************************/ - -/* PROTOTYPES *****************************************************************/ -int ftmod_ss7_parse_xml(ftdm_conf_parameter_t *ftdm_parameters, ftdm_span_t *span); - -static int ftmod_ss7_parse_sng_isup(ftdm_conf_node_t *sng_isup); - -static int ftmod_ss7_parse_sng_gen(ftdm_conf_node_t *sng_gen); - -static int ftmod_ss7_parse_sng_relay(ftdm_conf_node_t *sng_relay); -static int ftmod_ss7_parse_relay_channel(ftdm_conf_node_t *relay_chan); - -static int ftmod_ss7_parse_mtp1_links(ftdm_conf_node_t *mtp1_links); -static int ftmod_ss7_parse_mtp1_link(ftdm_conf_node_t *mtp1_link); - -static int ftmod_ss7_parse_mtp2_links(ftdm_conf_node_t *mtp2_links); -static int ftmod_ss7_parse_mtp2_link(ftdm_conf_node_t *mtp2_link); - -static int ftmod_ss7_parse_mtp3_links(ftdm_conf_node_t *mtp3_links); -static int ftmod_ss7_parse_mtp3_link(ftdm_conf_node_t *mtp3_link); - -static int ftmod_ss7_parse_mtp_linksets(ftdm_conf_node_t *mtp_linksets); -static int ftmod_ss7_parse_mtp_linkset(ftdm_conf_node_t *mtp_linkset); - -static int ftmod_ss7_parse_mtp_routes(ftdm_conf_node_t *mtp_routes); -static int ftmod_ss7_parse_mtp_route(ftdm_conf_node_t *mtp_route); - -static int ftmod_ss7_parse_isup_interfaces(ftdm_conf_node_t *isup_interfaces); -static int ftmod_ss7_parse_isup_interface(ftdm_conf_node_t *isup_interface); - -static int ftmod_ss7_parse_cc_spans(ftdm_conf_node_t *cc_spans); -static int ftmod_ss7_parse_cc_span(ftdm_conf_node_t *cc_span); - -static int ftmod_ss7_fill_in_relay_channel(sng_relay_t *relay_channel); -static int ftmod_ss7_fill_in_mtp1_link(sng_mtp1_link_t *mtp1Link); -static int ftmod_ss7_fill_in_mtp2_link(sng_mtp2_link_t *mtp1Link); -static int ftmod_ss7_fill_in_mtp3_link(sng_mtp3_link_t *mtp1Link); -static int ftmod_ss7_fill_in_mtpLinkSet(sng_link_set_t *mtpLinkSet); -static int ftmod_ss7_fill_in_mtp3_route(sng_route_t *mtp3_route); -static int ftmod_ss7_fill_in_nsap(sng_route_t *mtp3_route); -static int ftmod_ss7_fill_in_isup_interface(sng_isup_inf_t *sng_isup); -static int ftmod_ss7_fill_in_isap(sng_isap_t *sng_isap); -static int ftmod_ss7_fill_in_ccSpan(sng_ccSpan_t *ccSpan); -static int ftmod_ss7_fill_in_self_route(int spc, int linkType, int switchType, int ssf); -static int ftmod_ss7_fill_in_circuits(sng_span_t *sngSpan); - -static int ftmod_ss7_next_timeslot(char *ch_map, sng_timeslot_t *timeslot); -static void ftmod_ss7_set_glare_resolution (const char *method); - -/******************************************************************************/ - -/* FUNCTIONS ******************************************************************/ - -int ftmod_ss7_parse_xml(ftdm_conf_parameter_t *ftdm_parameters, ftdm_span_t *span) -{ - sng_route_t self_route; - sng_span_t sngSpan; - int i = 0; - const char *var = NULL; - const char *val = NULL; - ftdm_conf_node_t *ptr = NULL; - - /* clean out the isup ckt */ - memset(&sngSpan, 0x0, sizeof(sngSpan)); - - /* clean out the self route */ - memset(&self_route, 0x0, sizeof(self_route)); - - var = ftdm_parameters[i].var; - val = ftdm_parameters[i].val; - - g_ftdm_operating_mode = SNG_SS7_OPR_MODE_ISUP; - - /* confirm that the first parameter is the "operating-mode" */ - if(!strcasecmp(var, "operating-mode")){ - if(!strcasecmp(val, "ISUP")) { - g_ftdm_operating_mode = SNG_SS7_OPR_MODE_ISUP; - } - else if(!strcasecmp(val, "M2UA_SG")) { - g_ftdm_operating_mode = SNG_SS7_OPR_MODE_M2UA_SG; - } else { - SS7_DEBUG("Operating mode not specified, defaulting to ISUP\n"); - } - i++; - } - - - - var = ftdm_parameters[i].var; - val = ftdm_parameters[i].val; - ptr = (ftdm_conf_node_t *)ftdm_parameters[i].ptr; - - /* confirm that the 2nd parameter is the "confnode" */ - if (!strcasecmp(var, "confnode")) { - /* parse the confnode and fill in the global libsng_ss7 config structure */ - if (ftmod_ss7_parse_sng_isup(ptr)) { - SS7_ERROR("Failed to parse the \"confnode\"!\n"); - goto ftmod_ss7_parse_xml_error; - } - } else { - /* ERROR...exit */ - SS7_ERROR("The \"confnode\" configuration was not the first parameter!\n"); - SS7_ERROR("\tFound \"%s\" in the first slot\n", var); - goto ftmod_ss7_parse_xml_error; - } - - i++; - - while (ftdm_parameters[i].var != NULL) { - var = ftdm_parameters[i].var; - val = ftdm_parameters[i].val; - - if (!strcasecmp(var, "dialplan")) { - /* don't care for now */ - } else if (!strcasecmp(var, "context")) { - /* don't care for now */ - } else if (!strcasecmp(var, "span-id") || !strcasecmp(var, "ccSpanId")) { - sngSpan.ccSpanId = atoi(val); - SS7_DEBUG("Found an ccSpanId = %d\n",sngSpan.ccSpanId); - } else { - SS7_ERROR("Unknown parameter found =\"%s\"...ignoring it!\n", var); - } - - i++; - } /* while (ftdm_parameters[i].var != NULL) */ - - /* fill the pointer to span into isupCkt */ - sngSpan.span = span; - - if(SNG_SS7_OPR_MODE_ISUP == g_ftdm_operating_mode){ - /* setup the circuits structure */ - if(ftmod_ss7_fill_in_circuits(&sngSpan)) { - SS7_ERROR("Failed to fill in circuits structure!\n"); - goto ftmod_ss7_parse_xml_error; - } - } - - return FTDM_SUCCESS; - -ftmod_ss7_parse_xml_error: - return FTDM_FAIL; -} - -/******************************************************************************/ -static int ftmod_ss7_parse_sng_isup(ftdm_conf_node_t *sng_isup) -{ - ftdm_conf_node_t *gen_config = NULL; - ftdm_conf_node_t *relay_channels = NULL; - ftdm_conf_node_t *mtp1_links = NULL; - ftdm_conf_node_t *mtp2_links = NULL; - ftdm_conf_node_t *mtp3_links = NULL; - ftdm_conf_node_t *mtp_linksets = NULL; - ftdm_conf_node_t *mtp_routes = NULL; - ftdm_conf_node_t *isup_interfaces = NULL; - ftdm_conf_node_t *cc_spans = NULL; - ftdm_conf_node_t *tmp_node = NULL; - ftdm_conf_node_t *nif_ifaces = NULL; - ftdm_conf_node_t *m2ua_ifaces = NULL; - ftdm_conf_node_t *m2ua_peer_ifaces = NULL; - ftdm_conf_node_t *m2ua_clust_ifaces = NULL; - ftdm_conf_node_t *sctp_ifaces = NULL; - - /* confirm that we are looking at sng_isup */ - if (strcasecmp(sng_isup->name, "sng_isup")) { - SS7_ERROR("We're looking at \"%s\"...but we're supposed to be looking at \"sng_isup\"!\n",sng_isup->name); - return FTDM_FAIL; - } else { - SS7_DEBUG("Parsing \"sng_isup\"...\n"); - } - - /* extract the main sections of the sng_isup block */ - tmp_node = sng_isup->child; - - while (tmp_node != NULL) { - /**************************************************************************/ - /* check the type of structure */ - if (!strcasecmp(tmp_node->name, "sng_gen")) { - /**********************************************************************/ - if (gen_config == NULL) { - gen_config = tmp_node; - SS7_DEBUG("Found a \"sng_gen\" section!\n"); - } else { - SS7_ERROR("Found a second \"sng_gen\" section\n!"); - return FTDM_FAIL; - } - /**********************************************************************/ - } else if (!strcasecmp(tmp_node->name, "sng_relay")) { - /**********************************************************************/ - if (relay_channels == NULL) { - relay_channels = tmp_node; - SS7_DEBUG("Found a \"sng_relay\" section!\n"); - } else { - SS7_ERROR("Found a second \"sng_relay\" section\n!"); - return FTDM_FAIL; - } - /**********************************************************************/ - }else if (!strcasecmp(tmp_node->name, "mtp1_links")) { - /**********************************************************************/ - if (mtp1_links == NULL) { - mtp1_links = tmp_node; - SS7_DEBUG("Found a \"mtp1_links\" section!\n"); - } else { - SS7_ERROR("Found a second \"mtp1_links\" section!\n"); - return FTDM_FAIL; - } - /**********************************************************************/ - } else if (!strcasecmp(tmp_node->name, "mtp2_links")) { - /**********************************************************************/ - if (mtp2_links == NULL) { - mtp2_links = tmp_node; - SS7_DEBUG("Found a \"mtp2_links\" section!\n"); - } else { - SS7_ERROR("Found a second \"mtp2_links\" section!\n"); - return FTDM_FAIL; - } - /**********************************************************************/ - } else if (!strcasecmp(tmp_node->name, "mtp3_links")) { - /**********************************************************************/ - if (mtp3_links == NULL) { - mtp3_links = tmp_node; - SS7_DEBUG("Found a \"mtp3_links\" section!\n"); - } else { - SS7_ERROR("Found a second \"mtp3_links\" section!\n"); - return FTDM_FAIL; - } - /**********************************************************************/ - } else if (!strcasecmp(tmp_node->name, "mtp_linksets")) { - /**********************************************************************/ - if (mtp_linksets == NULL) { - mtp_linksets = tmp_node; - SS7_DEBUG("Found a \"mtp_linksets\" section!\n"); - } else { - SS7_ERROR("Found a second \"mtp_linksets\" section!\n"); - return FTDM_FAIL; - } - /**********************************************************************/ - } else if (!strcasecmp(tmp_node->name, "mtp_routes")) { - /**********************************************************************/ - if (mtp_routes == NULL) { - mtp_routes = tmp_node; - SS7_DEBUG("Found a \"mtp_routes\" section!\n"); - } else { - SS7_ERROR("Found a second \"mtp_routes\" section!\n"); - return FTDM_FAIL; - } - /**********************************************************************/ - } else if (!strcasecmp(tmp_node->name, "isup_interfaces")) { - /**********************************************************************/ - if (isup_interfaces == NULL) { - isup_interfaces = tmp_node; - SS7_DEBUG("Found a \"isup_interfaces\" section!\n"); - } else { - SS7_ERROR("Found a second \"isup_interfaces\" section\n!"); - return FTDM_FAIL; - } - /**********************************************************************/ - } else if (!strcasecmp(tmp_node->name, "cc_spans")) { - /**********************************************************************/ - if (cc_spans == NULL) { - cc_spans = tmp_node; - SS7_DEBUG("Found a \"cc_spans\" section!\n"); - } else { - SS7_ERROR("Found a second \"cc_spans\" section\n!"); - return FTDM_FAIL; - } - /**********************************************************************/ - } else if (!strcasecmp(tmp_node->name, "sng_nif_interfaces")) { - /**********************************************************************/ - if (nif_ifaces == NULL) { - nif_ifaces = tmp_node; - SS7_DEBUG("Found a \"sng_nif_interfaces\" section!\n"); - } else { - SS7_ERROR("Found a second \"sng_nif_interfaces\" section\n!"); - return FTDM_FAIL; - } - /**********************************************************************/ - } else if (!strcasecmp(tmp_node->name, "sng_m2ua_interfaces")) { - /**********************************************************************/ - if (m2ua_ifaces == NULL) { - m2ua_ifaces = tmp_node; - SS7_DEBUG("Found a \"sng_m2ua_interfaces\" section!\n"); - } else { - SS7_ERROR("Found a second \"sng_m2ua_interfaces\" section\n!"); - return FTDM_FAIL; - } - /**********************************************************************/ - } else if (!strcasecmp(tmp_node->name, "sng_m2ua_peer_interfaces")) { - /**********************************************************************/ - if (m2ua_peer_ifaces == NULL) { - m2ua_peer_ifaces = tmp_node; - SS7_DEBUG("Found a \"sng_m2ua_peer_interfaces\" section!\n"); - } else { - SS7_ERROR("Found a second \"sng_m2ua_peer_interfaces\" section\n!"); - return FTDM_FAIL; - } - /**********************************************************************/ - } else if (!strcasecmp(tmp_node->name, "sng_m2ua_cluster_interfaces")) { - /**********************************************************************/ - if (m2ua_clust_ifaces == NULL) { - m2ua_clust_ifaces = tmp_node; - SS7_DEBUG("Found a \"sng_m2ua_cluster_interfaces\" section!\n"); - } else { - SS7_ERROR("Found a second \"sng_m2ua_peer_interfaces\" section\n!"); - return FTDM_FAIL; - } - /**********************************************************************/ - } else if (!strcasecmp(tmp_node->name, "sng_sctp_interfaces")) { - /**********************************************************************/ - if (sctp_ifaces == NULL) { - sctp_ifaces = tmp_node; - SS7_DEBUG("Found a section!\n"); - } else { - SS7_ERROR("Found a second section!\n"); - return FTDM_FAIL; - } - /**********************************************************************/ - } else { - /**********************************************************************/ - SS7_ERROR("\tFound an unknown section \"%s\"!\n", tmp_node->name); - return FTDM_FAIL; - /**********************************************************************/ - } - - /* go to the next sibling */ - tmp_node = tmp_node->next; - } /* while (tmp_node != NULL) */ - - /* now try to parse the sections */ - if (ftmod_ss7_parse_sng_gen(gen_config)) { - SS7_ERROR("Failed to parse \"gen_config\"!\n"); - return FTDM_FAIL; - } - - if (ftmod_ss7_parse_sng_relay(relay_channels)) { - SS7_ERROR("Failed to parse \"relay_channels\"!\n"); - return FTDM_FAIL; - } - - if (ftmod_ss7_parse_mtp1_links(mtp1_links)) { - SS7_ERROR("Failed to parse \"mtp1_links\"!\n"); - return FTDM_FAIL; - } - - if (ftmod_ss7_parse_mtp2_links(mtp2_links)) { - SS7_ERROR("Failed to parse \"mtp2_links\"!\n"); - return FTDM_FAIL; - } - - - switch(g_ftdm_operating_mode) - { - case SNG_SS7_OPR_MODE_ISUP: - { - if (mtp3_links && ftmod_ss7_parse_mtp3_links(mtp3_links)) { - SS7_ERROR("Failed to parse \"mtp3_links\"!\n"); - return FTDM_FAIL; - } - - if (ftmod_ss7_parse_mtp_linksets(mtp_linksets)) { - SS7_ERROR("Failed to parse \"mtp_linksets\"!\n"); - return FTDM_FAIL; - } - - if (ftmod_ss7_parse_mtp_routes(mtp_routes)) { - SS7_ERROR("Failed to parse \"mtp_routes\"!\n"); - return FTDM_FAIL; - } - - if (isup_interfaces && ftmod_ss7_parse_isup_interfaces(isup_interfaces)) { - SS7_ERROR("Failed to parse \"isup_interfaces\"!\n"); - return FTDM_FAIL; - } - - if (cc_spans && ftmod_ss7_parse_cc_spans(cc_spans)) { - SS7_ERROR("Failed to parse \"cc_spans\"!\n"); - return FTDM_FAIL; - } - break; - } - case SNG_SS7_OPR_MODE_M2UA_SG: - { - if (ftmod_ss7_parse_sctp_links(sctp_ifaces) != FTDM_SUCCESS) { - SS7_ERROR("Failed to parse !\n"); - return FTDM_FAIL; - } - - if (nif_ifaces && ftmod_ss7_parse_nif_interfaces(nif_ifaces)) { - SS7_ERROR("Failed to parse \"nif_ifaces\"!\n"); - return FTDM_FAIL; - } - - if (m2ua_ifaces && ftmod_ss7_parse_m2ua_interfaces(m2ua_ifaces)) { - SS7_ERROR("Failed to parse \"m2ua_ifaces\"!\n"); - return FTDM_FAIL; - } - if (m2ua_peer_ifaces && ftmod_ss7_parse_m2ua_peer_interfaces(m2ua_peer_ifaces)) { - SS7_ERROR("Failed to parse \"m2ua_peer_ifaces\"!\n"); - return FTDM_FAIL; - } - if (m2ua_clust_ifaces && ftmod_ss7_parse_m2ua_clust_interfaces(m2ua_clust_ifaces)) { - SS7_ERROR("Failed to parse \"m2ua_clust_ifaces\"!\n"); - return FTDM_FAIL; - } - break; - } - default: - SS7_ERROR("Invalid operating mode[%d]\n",g_ftdm_operating_mode); - break; - - } - - return FTDM_SUCCESS; -} - -static void ftmod_ss7_set_glare_resolution (const char *method) -{ - sng_glare_resolution iMethod=SNGSS7_GLARE_PC; - if (!method || (strlen (method) <=0) ) { - SS7_ERROR( "Wrong glare resolution parameter, using default. \n" ); - } else { - if (!strcasecmp( method, "PointCode")) { - iMethod = SNGSS7_GLARE_PC; - } else if (!strcasecmp( method, "Down")) { - iMethod = SNGSS7_GLARE_DOWN; - } else if (!strcasecmp( method, "Control")) { - iMethod = SNGSS7_GLARE_CONTROL; - } else { - SS7_ERROR( "Wrong glare resolution parameter, using default. \n" ); - iMethod = SNGSS7_GLARE_PC; - } - } - g_ftdm_sngss7_data.cfg.glareResolution = iMethod; -} - -/******************************************************************************/ -static int ftmod_ss7_parse_sng_gen(ftdm_conf_node_t *sng_gen) -{ - ftdm_conf_parameter_t *parm = sng_gen->parameters; - int num_parms = sng_gen->n_parameters; - int i = 0; - - /* Set the transparent_iam_max_size to default value */ - g_ftdm_sngss7_data.cfg.transparent_iam_max_size=800; - g_ftdm_sngss7_data.cfg.force_inr = 0; - - /* extract all the information from the parameters */ - for (i = 0; i < num_parms; i++) { - if (!strcasecmp(parm->var, "procId")) { - g_ftdm_sngss7_data.cfg.procId = atoi(parm->val); - SS7_DEBUG("Found a procId = %d\n", g_ftdm_sngss7_data.cfg.procId); - } - else if (!strcasecmp(parm->var, "license")) { - ftdm_set_string(g_ftdm_sngss7_data.cfg.license, parm->val); - snprintf(g_ftdm_sngss7_data.cfg.signature, sizeof(g_ftdm_sngss7_data.cfg.signature), "%s.sig", parm->val); - SS7_DEBUG("Found license file = %s\n", g_ftdm_sngss7_data.cfg.license); - SS7_DEBUG("Found signature file = %s\n", g_ftdm_sngss7_data.cfg.signature); - } - else if (!strcasecmp(parm->var, "transparent_iam_max_size")) { - g_ftdm_sngss7_data.cfg.transparent_iam_max_size = atoi(parm->val); - SS7_DEBUG("Found a transparent_iam max size = %d\n", g_ftdm_sngss7_data.cfg.transparent_iam_max_size); - } - else if (!strcasecmp(parm->var, "glare-reso")) { - ftmod_ss7_set_glare_resolution (parm->val); - SS7_DEBUG("Found glare resolution configuration = %d %s\n", g_ftdm_sngss7_data.cfg.glareResolution, parm->val ); - } - else if (!strcasecmp(parm->var, "force-inr")) { - if (ftdm_true(parm->val)) { - g_ftdm_sngss7_data.cfg.force_inr = 1; - } else { - g_ftdm_sngss7_data.cfg.force_inr = 0; - } - SS7_DEBUG("Found INR force configuration = %s\n", parm->val ); - } - else { - SS7_ERROR("Found an invalid parameter \"%s\"!\n", parm->val); - return FTDM_FAIL; - } - - /* move to the next parmeter */ - parm = parm + 1; - } /* for (i = 0; i < num_parms; i++) */ - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static int ftmod_ss7_parse_sng_relay(ftdm_conf_node_t *sng_relay) -{ - ftdm_conf_node_t *relay_chan = NULL; - - /* confirm that we are looking at sng_relay */ - if (strcasecmp(sng_relay->name, "sng_relay")) { - SS7_ERROR("We're looking at \"%s\"...but we're supposed to be looking at \"sng_relay\"!\n",sng_relay->name); - return FTDM_FAIL; - } else { - SS7_DEBUG("Parsing \"sng_relay\"...\n"); - } - - relay_chan = sng_relay->child; - - if (relay_chan != NULL) { - while (relay_chan != NULL) { - /* try to the parse relay_channel */ - if (ftmod_ss7_parse_relay_channel(relay_chan)) { - SS7_ERROR("Failed to parse \"relay_channels\"!\n"); - return FTDM_FAIL; - } - - /* move on to the next linkset */ - relay_chan = relay_chan->next; - } /* while (relay_chan != NULL) */ - } /* if (relay_chan != NULL) */ - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static int ftmod_ss7_parse_relay_channel(ftdm_conf_node_t *relay_chan) -{ - sng_relay_t tmp_chan; - ftdm_conf_parameter_t *parm = relay_chan->parameters; - int num_parms = relay_chan->n_parameters; - int i = 0; - - /* confirm that we are looking at relay_channel */ - if (strcasecmp(relay_chan->name, "relay_channel")) { - SS7_ERROR("We're looking at \"%s\"...but we're supposed to be looking at \"relay_channel\"!\n",relay_chan->name); - return FTDM_FAIL; - } else { - SS7_DEBUG("Parsing \"relay_channel\"...\n"); - } - - /* initalize the tmp_chan structure */ - memset(&tmp_chan, 0x0, sizeof(tmp_chan)); - - /* extract all the information from the parameters */ - for (i = 0; i < num_parms; i++) { - /**************************************************************************/ - - if (!strcasecmp(parm->var, "name")) { - /**********************************************************************/ - strcpy((char *)tmp_chan.name, parm->val); - SS7_DEBUG("Found an relay_channel named = %s\n", tmp_chan.name); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "type")) { - /**********************************************************************/ - if (!strcasecmp(parm->val, "listen")) { - tmp_chan.type = LRY_CT_TCP_LISTEN; - SS7_DEBUG("Found a type = LISTEN\n"); - } else if (!strcasecmp(parm->val, "server")) { - tmp_chan.type = LRY_CT_TCP_SERVER; - SS7_DEBUG("Found a type = SERVER\n"); - } else if (!strcasecmp(parm->val, "client")) { - tmp_chan.type = LRY_CT_TCP_CLIENT; - SS7_DEBUG("Found a type = CLIENT\n"); - } else { - SS7_ERROR("Found an invalid \"type\" = %s\n", parm->var); - return FTDM_FAIL; - } - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "hostname")) { - /**********************************************************************/ - strcpy((char *)tmp_chan.hostname, parm->val); - SS7_DEBUG("Found a hostname = %s\n", tmp_chan.hostname); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "port")) { - /**********************************************************************/ - tmp_chan.port = atoi(parm->val); - SS7_DEBUG("Found a port = %d\n", tmp_chan.port); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "procId")) { - /**********************************************************************/ - tmp_chan.procId = atoi(parm->val); - SS7_DEBUG("Found a procId = %d\n", tmp_chan.procId); - /**********************************************************************/ - } else { - /**********************************************************************/ - SS7_ERROR("Found an invalid parameter \"%s\"!\n", parm->val); - return FTDM_FAIL; - /**********************************************************************/ - } - - /* move to the next parmeter */ - parm = parm + 1; - } /* for (i = 0; i < num_parms; i++) */ - - /* store the channel in the global structure */ - ftmod_ss7_fill_in_relay_channel(&tmp_chan); - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static int ftmod_ss7_parse_mtp1_links(ftdm_conf_node_t *mtp1_links) -{ - ftdm_conf_node_t *mtp1_link = NULL; - - /* confirm that we are looking at mtp1_links */ - if (strcasecmp(mtp1_links->name, "mtp1_links")) { - SS7_ERROR("We're looking at \"%s\"...but we're supposed to be looking at \"mtp1_links\"!\n",mtp1_links->name); - return FTDM_FAIL; - } else { - SS7_DEBUG("Parsing \"mtp1_links\"...\n"); - } - - /* extract the mtp_links */ - mtp1_link = mtp1_links->child; - - /* run through all of the links found */ - while (mtp1_link != NULL) { - /* try to the parse mtp_link */ - if (ftmod_ss7_parse_mtp1_link(mtp1_link)) { - SS7_ERROR("Failed to parse \"mtp1_link\"!\n"); - return FTDM_FAIL; - } - - /* move on to the next link */ - mtp1_link = mtp1_link->next; - - } /* while (mtp_linkset != NULL) */ - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static int ftmod_ss7_parse_mtp1_link(ftdm_conf_node_t *mtp1_link) -{ - sng_mtp1_link_t mtp1Link; - ftdm_conf_parameter_t *parm = mtp1_link->parameters; - int num_parms = mtp1_link->n_parameters; - int i; - - /* initalize the mtp1Link structure */ - memset(&mtp1Link, 0x0, sizeof(mtp1Link)); - - /* confirm that we are looking at an mtp_link */ - if (strcasecmp(mtp1_link->name, "mtp1_link")) { - SS7_ERROR("We're looking at \"%s\"...but we're supposed to be looking at \"mtp1_link\"!\n",mtp1_link->name); - return FTDM_FAIL; - } else { - SS7_DEBUG("Parsing \"mtp1_link\"...\n"); - } - - for (i = 0; i < num_parms; i++) { - /**************************************************************************/ - - if (!strcasecmp(parm->var, "name")) { - /**********************************************************************/ - strcpy((char *)mtp1Link.name, parm->val); - SS7_DEBUG("Found an mtp1_link named = %s\n", mtp1Link.name); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "id")) { - /**********************************************************************/ - mtp1Link.id = atoi(parm->val); - SS7_DEBUG("Found an mtp1_link id = %d\n", mtp1Link.id); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "span")) { - /**********************************************************************/ - mtp1Link.span = atoi(parm->val); - SS7_DEBUG("Found an mtp1_link span = %d\n", mtp1Link.span); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "chan")) { - /**********************************************************************/ - mtp1Link.chan = atoi(parm->val); - SS7_DEBUG("Found an mtp1_link chan = %d\n", mtp1Link.chan); - /**********************************************************************/ - } else { - /**********************************************************************/ - SS7_ERROR("\tFound an invalid parameter \"%s\"!\n", parm->val); - return FTDM_FAIL; - /**********************************************************************/ - } - - /* move to the next parmeter */ - parm = parm + 1; - - /**************************************************************************/ - } /* for (i = 0; i < num_parms; i++) */ - - /* store the link in global structure */ - ftmod_ss7_fill_in_mtp1_link(&mtp1Link); - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static int ftmod_ss7_parse_mtp2_links(ftdm_conf_node_t *mtp2_links) -{ - ftdm_conf_node_t *mtp2_link = NULL; - - /* confirm that we are looking at mtp2_links */ - if (strcasecmp(mtp2_links->name, "mtp2_links")) { - SS7_ERROR("We're looking at \"%s\"...but we're supposed to be looking at \"mtp2_links\"!\n",mtp2_links->name); - return FTDM_FAIL; - } else { - SS7_DEBUG("Parsing \"mtp2_links\"...\n"); - } - - /* extract the mtp_links */ - mtp2_link = mtp2_links->child; - - /* run through all of the links found */ - while (mtp2_link != NULL) { - /* try to the parse mtp_linkset */ - if (ftmod_ss7_parse_mtp2_link(mtp2_link)) { - SS7_ERROR("Failed to parse \"mtp2_link\"!\n"); - return FTDM_FAIL; - } - - /* move on to the next link */ - mtp2_link = mtp2_link->next; - - } /* while (mtp_linkset != NULL) */ - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static int ftmod_ss7_parse_mtp2_link(ftdm_conf_node_t *mtp2_link) -{ - sng_mtp2_link_t mtp2Link; - ftdm_conf_parameter_t *parm = mtp2_link->parameters; - int num_parms = mtp2_link->n_parameters; - int i; - int ret; - - /* initalize the mtp1Link structure */ - memset(&mtp2Link, 0x0, sizeof(mtp2Link)); - - /* confirm that we are looking at an mtp2_link */ - if (strcasecmp(mtp2_link->name, "mtp2_link")) { - SS7_ERROR("We're looking at \"%s\"...but we're supposed to be looking at \"mtp2_link\"!\n",mtp2_link->name); - return FTDM_FAIL; - } else { - SS7_DEBUG("Parsing \"mtp2_link\"...\n"); - } - - for (i = 0; i < num_parms; i++) { - /**************************************************************************/ - - if (!strcasecmp(parm->var, "name")) { - /**********************************************************************/ - strcpy((char *)mtp2Link.name, parm->val); - SS7_DEBUG("Found an mtp2_link named = %s\n", mtp2Link.name); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "id")) { - /**********************************************************************/ - mtp2Link.id = atoi(parm->val); - SS7_DEBUG("Found an mtp2_link id = %d\n", mtp2Link.id); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "mtp1Id")) { - /**********************************************************************/ - mtp2Link.mtp1Id = atoi(parm->val); - SS7_DEBUG("Found an mtp2_link mtp1Id = %d\n", mtp2Link.mtp1Id); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "errorType")) { - /**********************************************************************/ - ret = find_mtp2_error_type_in_map(parm->val); - if (ret == -1) { - SS7_ERROR("Found an invalid mtp2_link errorType = %s\n", parm->var); - return FTDM_FAIL; - } else { - mtp2Link.errorType = sng_mtp2_error_type_map[ret].tril_type; - SS7_DEBUG("Found an mtp2_link errorType = %s\n", sng_mtp2_error_type_map[ret].sng_type); - } - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "lssuLength")) { - /**********************************************************************/ - mtp2Link.lssuLength = atoi(parm->val); - SS7_DEBUG("Found an mtp2_link lssuLength = %d\n", mtp2Link.lssuLength); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "linkType")) { - /**********************************************************************/ - ret = find_link_type_in_map(parm->val); - if (ret == -1) { - SS7_ERROR("Found an invalid mtp2_link linkType = %s\n", parm->var); - return FTDM_FAIL; - } else { - mtp2Link.linkType = sng_link_type_map[ret].tril_mtp2_type; - SS7_DEBUG("Found an mtp2_link linkType = %s\n", sng_link_type_map[ret].sng_type); - } - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "t1")) { - /**********************************************************************/ - mtp2Link.t1 = atoi(parm->val); - SS7_DEBUG("Found an mtp2 t1 = \"%d\"\n",mtp2Link.t1); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "t2")) { - /**********************************************************************/ - mtp2Link.t2 = atoi(parm->val); - SS7_DEBUG("Found an mtp2 t2 = \"%d\"\n",mtp2Link.t2); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "t3")) { - /**********************************************************************/ - mtp2Link.t3 = atoi(parm->val); - SS7_DEBUG("Found an mtp2 t3 = \"%d\"\n",mtp2Link.t3); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "t4n")) { - /**********************************************************************/ - mtp2Link.t4n = atoi(parm->val); - SS7_DEBUG("Found an mtp2 t4n = \"%d\"\n",mtp2Link.t4n); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "t4e")) { - /**********************************************************************/ - mtp2Link.t4e = atoi(parm->val); - SS7_DEBUG("Found an mtp2 t4e = \"%d\"\n",mtp2Link.t4e); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "t5")) { - /**********************************************************************/ - mtp2Link.t5 = atoi(parm->val); - SS7_DEBUG("Found an mtp2 t5 = \"%d\"\n",mtp2Link.t5); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "t6")) { - /**********************************************************************/ - mtp2Link.t6 = atoi(parm->val); - SS7_DEBUG("Found an mtp2 t6 = \"%d\"\n",mtp2Link.t6); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "t7")) { - /**********************************************************************/ - mtp2Link.t7 = atoi(parm->val); - SS7_DEBUG("Found an mtp2 t7 = \"%d\"\n",mtp2Link.t7); - /**********************************************************************/ - } else { - /**********************************************************************/ - SS7_ERROR("Found an invalid parameter \"%s\"!\n", parm->val); - return FTDM_FAIL; - /**********************************************************************/ - } - - /* move to the next parmeter */ - parm = parm + 1; - - /**************************************************************************/ - } /* for (i = 0; i < num_parms; i++) */ - - /* store the link in global structure */ - ftmod_ss7_fill_in_mtp2_link(&mtp2Link); - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static int ftmod_ss7_parse_mtp3_links(ftdm_conf_node_t *mtp3_links) -{ - ftdm_conf_node_t *mtp3_link = NULL; - - /* confirm that we are looking at mtp3_links */ - if (strcasecmp(mtp3_links->name, "mtp3_links")) { - SS7_ERROR("We're looking at \"%s\"...but we're supposed to be looking at \"mtp3_links\"!\n",mtp3_links->name); - return FTDM_FAIL; - } else { - SS7_DEBUG("Parsing \"mtp3_links\"...\n"); - } - - /* extract the mtp_links */ - mtp3_link = mtp3_links->child; - - /* run through all of the links found */ - while (mtp3_link != NULL) { - /* try to the parse mtp_linkset */ - if (ftmod_ss7_parse_mtp3_link(mtp3_link)) { - SS7_ERROR("Failed to parse \"mtp3_link\"!\n"); - return FTDM_FAIL; - } - - /* move on to the next link */ - mtp3_link = mtp3_link->next; - - } /* while (mtp_linkset != NULL) */ - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static int ftmod_ss7_parse_mtp3_link(ftdm_conf_node_t *mtp3_link) -{ - sng_mtp3_link_t mtp3Link; - ftdm_conf_parameter_t *parm = mtp3_link->parameters; - int num_parms = mtp3_link->n_parameters; - int i; - int ret; - - /* initalize the mtp3Link structure */ - memset(&mtp3Link, 0x0, sizeof(mtp3Link)); - - /* confirm that we are looking at an mtp_link */ - if (strcasecmp(mtp3_link->name, "mtp3_link")) { - SS7_ERROR("We're looking at \"%s\"...but we're supposed to be looking at \"mtp3_link\"!\n",mtp3_link->name); - return FTDM_FAIL; - } else { - SS7_DEBUG("Parsing \"mtp3_link\"...\n"); - } - - for (i = 0; i < num_parms; i++) { - /**************************************************************************/ - if (!strcasecmp(parm->var, "name")) { - /**********************************************************************/ - strcpy((char *)mtp3Link.name, parm->val); - SS7_DEBUG("Found an mtp3_link named = %s\n", mtp3Link.name); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "id")) { - /**********************************************************************/ - mtp3Link.id = atoi(parm->val); - SS7_DEBUG("Found an mtp3_link id = %d\n", mtp3Link.id); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "mtp2Id")) { - /**********************************************************************/ - mtp3Link.mtp2Id = atoi(parm->val); - SS7_DEBUG("Found an mtp3_link mtp2Id = %d\n", mtp3Link.mtp2Id); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "mtp2ProcId")) { - /**********************************************************************/ - mtp3Link.mtp2ProcId = atoi(parm->val); - SS7_DEBUG("Found an mtp3_link mtp2ProcId = %d\n", mtp3Link.mtp2ProcId); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "priority")) { - /**********************************************************************/ - mtp3Link.priority = atoi(parm->val); - SS7_DEBUG("Found an mtp3 Link priority = %d\n",mtp3Link.priority); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "linkType")) { - /**********************************************************************/ - ret = find_link_type_in_map(parm->val); - if (ret == -1) { - SS7_ERROR("Found an invalid mtp3_link linkType = %s\n", parm->var); - return FTDM_FAIL; - } else { - mtp3Link.linkType = sng_link_type_map[ret].tril_mtp3_type; - SS7_DEBUG("Found an mtp3_link linkType = %s\n", sng_link_type_map[ret].sng_type); - } - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "switchType")) { - /**********************************************************************/ - ret = find_switch_type_in_map(parm->val); - if (ret == -1) { - SS7_ERROR("Found an invalid mtp3_link switchType = %s\n", parm->var); - return FTDM_FAIL; - } else { - mtp3Link.switchType = sng_switch_type_map[ret].tril_mtp3_type; - SS7_DEBUG("Found an mtp3_link switchType = %s\n", sng_switch_type_map[ret].sng_type); - } - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "ssf")) { - /**********************************************************************/ - ret = find_ssf_type_in_map(parm->val); - if (ret == -1) { - SS7_ERROR("Found an invalid mtp3_link ssf = %s\n", parm->var); - return FTDM_FAIL; - } else { - mtp3Link.ssf = sng_ssf_type_map[ret].tril_type; - SS7_DEBUG("Found an mtp3_link ssf = %s\n", sng_ssf_type_map[ret].sng_type); - } - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "slc")) { - /**********************************************************************/ - mtp3Link.slc = atoi(parm->val); - SS7_DEBUG("Found an mtp3 Link slc = %d\n",mtp3Link.slc); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "linkset")) { - /**********************************************************************/ - mtp3Link.linkSetId = atoi(parm->val); - SS7_DEBUG("Found an mtp3 Link linkset = %d\n",mtp3Link.linkSetId); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "t1")) { - /**********************************************************************/ - mtp3Link.t1 = atoi(parm->val); - SS7_DEBUG("Found an mtp3 t1 = %d\n",mtp3Link.t1); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "t2")) { - /**********************************************************************/ - mtp3Link.t2 = atoi(parm->val); - SS7_DEBUG("Found an mtp3 t2 = %d\n",mtp3Link.t2); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "t3")) { - /**********************************************************************/ - mtp3Link.t3 = atoi(parm->val); - SS7_DEBUG("Found an mtp3 t3 = %d\n",mtp3Link.t3); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "t4")) { - /**********************************************************************/ - mtp3Link.t4 = atoi(parm->val); - SS7_DEBUG("Found an mtp3 t4 = %d\n",mtp3Link.t4); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "t5")) { - /**********************************************************************/ - mtp3Link.t5 = atoi(parm->val); - SS7_DEBUG("Found an mtp3 t5 = %d\n",mtp3Link.t5); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "t7")) { - /**********************************************************************/ - mtp3Link.t7 = atoi(parm->val); - SS7_DEBUG("Found an mtp3 t7 = %d\n",mtp3Link.t7); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "t12")) { - /**********************************************************************/ - mtp3Link.t12 = atoi(parm->val); - SS7_DEBUG("Found an mtp3 t12 = %d\n",mtp3Link.t12); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "t13")) { - /**********************************************************************/ - mtp3Link.t13 = atoi(parm->val); - SS7_DEBUG("Found an mtp3 t13 = %d\n",mtp3Link.t13); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "t14")) { - /**********************************************************************/ - mtp3Link.t14 = atoi(parm->val); - SS7_DEBUG("Found an mtp3 t14 = %d\n",mtp3Link.t14); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "t17")) { - /**********************************************************************/ - mtp3Link.t17 = atoi(parm->val); - SS7_DEBUG("Found an mtp3 t17 = %d\n",mtp3Link.t17); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "t22")) { - /**********************************************************************/ - mtp3Link.t22 = atoi(parm->val); - SS7_DEBUG("Found an mtp3 t22 = %d\n",mtp3Link.t22); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "t23")) { - /**********************************************************************/ - mtp3Link.t23 = atoi(parm->val); - SS7_DEBUG("Found an mtp3 t23 = %d\n",mtp3Link.t23); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "t24")) { - /**********************************************************************/ - mtp3Link.t24 = atoi(parm->val); - SS7_DEBUG("Found an mtp3 t24 = %d\n",mtp3Link.t24); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "t31")) { - mtp3Link.t31 = atoi(parm->val); - SS7_DEBUG("Found an mtp3 t31 = %d\n",mtp3Link.t31); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "t32")) { - /**********************************************************************/ - mtp3Link.t32 = atoi(parm->val); - SS7_DEBUG("Found an mtp3 t32 = %d\n",mtp3Link.t32); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "t33")) { - /**********************************************************************/ - mtp3Link.t33 = atoi(parm->val); - SS7_DEBUG("Found an mtp3 t33 = %d\n",mtp3Link.t33); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "t34")) { - /**********************************************************************/ - mtp3Link.t34 = atoi(parm->val); - SS7_DEBUG("Found an mtp3 t34 = %d\n",mtp3Link.t34); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "t35")) { - /**********************************************************************/ - mtp3Link.t35 = atoi(parm->val); - SS7_DEBUG("Found an mtp3 t35 = %d\n",mtp3Link.t35); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "t36")) { - /**********************************************************************/ - mtp3Link.t36 = atoi(parm->val); - SS7_DEBUG("Found an mtp3 t36 = %d\n",mtp3Link.t36); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "t37")) { - /**********************************************************************/ - mtp3Link.t37 = atoi(parm->val); - SS7_DEBUG("Found an mtp3 t37 = %d\n",mtp3Link.t37); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "tcraft")) { - /**********************************************************************/ - mtp3Link.tcraft = atoi(parm->val); - SS7_DEBUG("Found an mtp3 tcraft = %d\n",mtp3Link.tcraft); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "tflc")) { - /**********************************************************************/ - mtp3Link.tflc = atoi(parm->val); - SS7_DEBUG("Found an mtp3 tflc = %d\n",mtp3Link.tflc); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "tbnd")) { - /**********************************************************************/ - mtp3Link.tbnd = atoi(parm->val); - SS7_DEBUG("Found an mtp3 tbnd = %d\n",mtp3Link.tbnd); - /**********************************************************************/ - } else { - /**********************************************************************/ - SS7_ERROR("Found an invalid parameter %s!\n", parm->val); - return FTDM_FAIL; - /**********************************************************************/ - } - - /* move to the next parmeter */ - parm = parm + 1; - - /**************************************************************************/ - } /* for (i = 0; i < num_parms; i++) */ - - /* store the link in global structure */ - ftmod_ss7_fill_in_mtp3_link(&mtp3Link); - - /* move the linktype, switchtype and ssf to the linkset */ - if (g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].linkType == 0) { - g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].linkType = mtp3Link.linkType; - } else if (g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].linkType != mtp3Link.linkType) { - SS7_ERROR("Trying to add an MTP3 Link to a Linkset with a different linkType: mtp3.id=%d, mtp3.name=%s, mtp3.linktype=%d, linkset.id=%d, linkset.linktype=%d\n", - mtp3Link.id, mtp3Link.name, mtp3Link.linkType, - g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].id, g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].linkType); - return FTDM_FAIL; - } else { - /* should print that all is ok...*/ - } - - if (g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].switchType == 0) { - g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].switchType = mtp3Link.switchType; - } else if (g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].switchType != mtp3Link.switchType) { - SS7_ERROR("Trying to add an MTP3 Link to a Linkset with a different switchType: mtp3.id=%d, mtp3.name=%s, mtp3.switchtype=%d, linkset.id=%d, linkset.switchtype=%d\n", - mtp3Link.id, mtp3Link.name, mtp3Link.switchType, - g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].id, g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].switchType); - return FTDM_FAIL; - } else { - /* should print that all is ok...*/ - } - - if (g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].ssf == 0) { - g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].ssf = mtp3Link.ssf; - } else if (g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].ssf != mtp3Link.ssf) { - SS7_ERROR("Trying to add an MTP3 Link to a Linkset with a different ssf: mtp3.id=%d, mtp3.name=%s, mtp3.ssf=%d, linkset.id=%d, linkset.ssf=%d\n", - mtp3Link.id, mtp3Link.name, mtp3Link.ssf, - g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].id, g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].ssf); - return FTDM_FAIL; - } else { - /* should print that all is ok...*/ - } - - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static int ftmod_ss7_parse_mtp_linksets(ftdm_conf_node_t *mtp_linksets) -{ - ftdm_conf_node_t *mtp_linkset = NULL; - - /* confirm that we are looking at mtp_linksets */ - if (strcasecmp(mtp_linksets->name, "mtp_linksets")) { - SS7_ERROR("We're looking at \"%s\"...but we're supposed to be looking at \"mtp_linksets\"!\n",mtp_linksets->name); - return FTDM_FAIL; - } else { - SS7_DEBUG("Parsing \"mtp_linksets\"...\n"); - } - - /* extract the mtp_links */ - mtp_linkset = mtp_linksets->child; - - /* run through all of the mtp_linksets found */ - while (mtp_linkset != NULL) { - /* try to the parse mtp_linkset */ - if (ftmod_ss7_parse_mtp_linkset(mtp_linkset)) { - SS7_ERROR("Failed to parse \"mtp_linkset\"!\n"); - return FTDM_FAIL; - } - - /* move on to the next linkset */ - mtp_linkset = mtp_linkset->next; - - } /* while (mtp_linkset != NULL) */ - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static int ftmod_ss7_parse_mtp_linkset(ftdm_conf_node_t *mtp_linkset) -{ - sng_link_set_t mtpLinkSet; - ftdm_conf_parameter_t *parm = mtp_linkset->parameters; - int num_parms = mtp_linkset->n_parameters; - int i; - - /* initalize the mtpLinkSet structure */ - memset(&mtpLinkSet, 0x0, sizeof(mtpLinkSet)); - - /* confirm that we are looking at mtp_linkset */ - if (strcasecmp(mtp_linkset->name, "mtp_linkset")) { - SS7_ERROR("We're looking at \"%s\"...but we're supposed to be looking at \"mtp_linkset\"!\n",mtp_linkset->name); - return FTDM_FAIL; - } else { - SS7_DEBUG("Parsing \"mtp_linkset\"...\n"); - } - - /* extract all the information from the parameters */ - for (i = 0; i < num_parms; i++) { - /**************************************************************************/ - - if (!strcasecmp(parm->var, "name")) { - /**********************************************************************/ - strcpy((char *)mtpLinkSet.name, parm->val); - SS7_DEBUG("Found an mtpLinkSet named = %s\n", mtpLinkSet.name); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "id")) { - /**********************************************************************/ - mtpLinkSet.id = atoi(parm->val); - SS7_DEBUG("Found mtpLinkSet id = %d\n", mtpLinkSet.id); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "apc")) { - /**********************************************************************/ - mtpLinkSet.apc = atoi(parm->val); - SS7_DEBUG("Found mtpLinkSet apc = %d\n", mtpLinkSet.apc); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "minActive")) { - /**********************************************************************/ - mtpLinkSet.minActive = atoi(parm->val); - SS7_DEBUG("Found mtpLinkSet minActive = %d\n", mtpLinkSet.minActive); - /**********************************************************************/ - } else { - /**********************************************************************/ - SS7_ERROR("Found an invalid parameter \"%s\"!\n", parm->val); - return FTDM_FAIL; - /**********************************************************************/ - } - - /* move to the next parmeter */ - parm = parm + 1; - /**************************************************************************/ - } /* for (i = 0; i < num_parms; i++) */ - - ftmod_ss7_fill_in_mtpLinkSet(&mtpLinkSet); - - /* go through all the mtp3 links and fill in the apc */ - i = 1; - while (i < (MAX_MTP_LINKS)) { - if (g_ftdm_sngss7_data.cfg.mtp3Link[i].linkSetId == mtpLinkSet.id) { - g_ftdm_sngss7_data.cfg.mtp3Link[i].apc = mtpLinkSet.apc; - } - - i++; - } - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static int ftmod_ss7_parse_mtp_routes(ftdm_conf_node_t *mtp_routes) -{ - ftdm_conf_node_t *mtp_route = NULL; - - /* confirm that we are looking at an mtp_routes */ - if (strcasecmp(mtp_routes->name, "mtp_routes")) { - SS7_ERROR("We're looking at \"%s\"...but we're supposed to be looking at \"mtp_routes\"!\n",mtp_routes->name); - return FTDM_FAIL; - } else { - SS7_DEBUG("Parsing \"mtp_routes\"...\n"); - } - - /* extract the mtp_routes */ - mtp_route = mtp_routes->child; - - while (mtp_route != NULL) { - /* parse the found mtp_route */ - if (ftmod_ss7_parse_mtp_route(mtp_route)) { - SS7_ERROR("Failed to parse \"mtp_route\"\n"); - return FTDM_FAIL; - } - - /* go to the next mtp_route */ - mtp_route = mtp_route->next; - } - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static int ftmod_ss7_parse_mtp_route(ftdm_conf_node_t *mtp_route) -{ - sng_route_t mtpRoute; - ftdm_conf_parameter_t *parm = mtp_route->parameters; - int num_parms = mtp_route->n_parameters; - int i; - sng_link_set_list_t *lnkSet; - - ftdm_conf_node_t *linkset; - int numLinks; - - /* initalize the mtpRoute structure */ - memset(&mtpRoute, 0x0, sizeof(mtpRoute)); - - /* confirm that we are looking at an mtp_link */ - if (strcasecmp(mtp_route->name, "mtp_route")) { - SS7_ERROR("We're looking at \"%s\"...but we're supposed to be looking at \"mtp_route\"!\n",mtp_route->name); - return FTDM_FAIL; - } else { - SS7_DEBUG("Parsing \"mtp_route\"...\n"); - } - - for (i = 0; i < num_parms; i++) { - /**************************************************************************/ - - /* try to match the parameter to what we expect */ - if (!strcasecmp(parm->var, "name")) { - /**********************************************************************/ - strcpy((char *)mtpRoute.name, parm->val); - SS7_DEBUG("Found an mtpRoute named = %s\n", mtpRoute.name); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "id")) { - /**********************************************************************/ - mtpRoute.id = atoi(parm->val); - SS7_DEBUG("Found an mtpRoute id = %d\n", mtpRoute.id); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "dpc")) { - /**********************************************************************/ - mtpRoute.dpc = atoi(parm->val); - SS7_DEBUG("Found an mtpRoute dpc = %d\n", mtpRoute.dpc); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isSTP")) { - /**********************************************************************/ - if (!strcasecmp(parm->val, "no")) { - mtpRoute.isSTP = 0; - SS7_DEBUG("Found an mtpRoute isSTP = no\n"); - } else if (!strcasecmp(parm->val, "yes")) { - mtpRoute.isSTP = 1; - SS7_DEBUG("Found an mtpRoute isSTP = yes\n"); - } else { - SS7_ERROR("Found an invalid parameter for isSTP %s!\n", parm->val); - return FTDM_FAIL; - } - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "mtp3.t6")) { - /**********************************************************************/ - mtpRoute.t6 = atoi(parm->val); - SS7_DEBUG("Found an mtp3 t6 = %d\n",mtpRoute.t6); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "mtp3.t8")) { - /**********************************************************************/ - mtpRoute.t8 = atoi(parm->val); - SS7_DEBUG("Found an mtp3 t8 = %d\n",mtpRoute.t8); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "mtp3.t10")) { - /**********************************************************************/ - mtpRoute.t10 = atoi(parm->val); - SS7_DEBUG("Found an mtp3 t10 = %d\n",mtpRoute.t10); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "mtp3.t11")) { - /**********************************************************************/ - mtpRoute.t11 = atoi(parm->val); - SS7_DEBUG("Found an mtp3 t11 = %d\n",mtpRoute.t11); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "mtp3.t15")) { - /**********************************************************************/ - mtpRoute.t15 = atoi(parm->val); - SS7_DEBUG("Found an mtp3 t15 = %d\n",mtpRoute.t15); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "mtp3.t16")) { - /**********************************************************************/ - mtpRoute.t16 = atoi(parm->val); - SS7_DEBUG("Found an mtp3 t16 = %d\n",mtpRoute.t16); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "mtp3.t18")) { - /**********************************************************************/ - mtpRoute.t18 = atoi(parm->val); - SS7_DEBUG("Found an mtp3 t18 = %d\n",mtpRoute.t18); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "mtp3.t19")) { - /**********************************************************************/ - mtpRoute.t19 = atoi(parm->val); - SS7_DEBUG("Found an mtp3 t19 = %d\n",mtpRoute.t19); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "mtp3.t21")) { - /**********************************************************************/ - mtpRoute.t21 = atoi(parm->val); - SS7_DEBUG("Found an mtp3 t21 = %d\n",mtpRoute.t21); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "mtp3.t25")) { - /**********************************************************************/ - mtpRoute.t25 = atoi(parm->val); - SS7_DEBUG("Found an mtp3 t25 = %d\n",mtpRoute.t25); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "mtp3.t26")) { - /**********************************************************************/ - mtpRoute.t26 = atoi(parm->val); - SS7_DEBUG("Found an mtp3 t26 = %d\n",mtpRoute.t26); - /**********************************************************************/ - } else { - /**********************************************************************/ - SS7_ERROR("Found an invalid parameter \"%s\"!\n", parm->val); - return FTDM_FAIL; - /**********************************************************************/ - } - - /* move to the next parameter */ - parm = parm + 1; - } - - /* fill in the rest of the values in the mtpRoute struct */ - mtpRoute.nwId = 0; - mtpRoute.cmbLinkSetId = mtpRoute.id; - - /* parse in the list of linksets this route is reachable by */ - linkset = mtp_route->child->child; - - /* initalize the link-list of linkSet Ids */ - lnkSet = &mtpRoute.lnkSets; - - while (linkset != NULL) { - /**************************************************************************/ - /* extract the linkset Id */ - lnkSet->lsId = atoi(linkset->parameters->val); - - if (g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet->lsId].id != 0) { - SS7_DEBUG("Found mtpRoute linkset id = %d that is valid\n",lnkSet->lsId); - } else { - SS7_ERROR("Found mtpRoute linkset id = %d that is invalid\n",lnkSet->lsId); - goto move_along; - } - - /* pull up the linktype, switchtype, and SSF from the linkset */ - mtpRoute.linkType = g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet->lsId].linkType; - mtpRoute.switchType = g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet->lsId].switchType; - mtpRoute.ssf = g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet->lsId].ssf; - - /* extract the number of cmbLinkSetId aleady on this linkset */ - numLinks = g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet->lsId].numLinks; - - /* add this routes cmbLinkSetId to the list */ - g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet->lsId].links[numLinks] = mtpRoute.cmbLinkSetId; - - /* increment the number of cmbLinkSets on this linkset */ - g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet->lsId].numLinks++; - - /* update the linked list */ - lnkSet->next = ftdm_malloc(sizeof(sng_link_set_list_t)); - lnkSet = lnkSet->next; - lnkSet->lsId = 0; - lnkSet->next = NULL; - -move_along: - /* move to the next linkset element */ - linkset = linkset->next; - /**************************************************************************/ - } /* while (linkset != null) */ - - - ftmod_ss7_fill_in_mtp3_route(&mtpRoute); - - ftmod_ss7_fill_in_nsap(&mtpRoute); - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static int ftmod_ss7_parse_isup_interfaces(ftdm_conf_node_t *isup_interfaces) -{ - ftdm_conf_node_t *isup_interface = NULL; - - /* confirm that we are looking at isup_interfaces */ - if (strcasecmp(isup_interfaces->name, "isup_interfaces")) { - SS7_ERROR("We're looking at \"%s\"...but we're supposed to be looking at \"isup_interfaces\"!\n",isup_interfaces->name); - return FTDM_FAIL; - } else { - SS7_DEBUG("Parsing \"isup_interfaces\"...\n"); - } - - /* extract the isup_interfaces */ - isup_interface = isup_interfaces->child; - - while (isup_interface != NULL) { - /* parse the found mtp_route */ - if (ftmod_ss7_parse_isup_interface(isup_interface)) { - SS7_ERROR("Failed to parse \"isup_interface\"\n"); - return FTDM_FAIL; - } - - /* go to the next mtp_route */ - isup_interface = isup_interface->next; - } - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static int ftmod_ss7_parse_isup_interface(ftdm_conf_node_t *isup_interface) -{ - sng_isup_inf_t sng_isup; - sng_isap_t sng_isap; - sng_link_set_list_t *lnkSet; - ftdm_conf_parameter_t *parm = isup_interface->parameters; - int num_parms = isup_interface->n_parameters; - int i; - int ret; - - /* initalize the isup intf and isap structure */ - memset(&sng_isup, 0x0, sizeof(sng_isup)); - memset(&sng_isap, 0x0, sizeof(sng_isap)); - - /* confirm that we are looking at an mtp_link */ - if (strcasecmp(isup_interface->name, "isup_interface")) { - SS7_ERROR("We're looking at \"%s\"...but we're supposed to be looking at \"isup_interface\"!\n",isup_interface->name); - return FTDM_FAIL; - } else { - SS7_DEBUG("Parsing \"isup_interface\"...\n"); - } - - - for (i = 0; i < num_parms; i++) { - /**************************************************************************/ - - /* try to match the parameter to what we expect */ - if (!strcasecmp(parm->var, "name")) { - /**********************************************************************/ - strcpy((char *)sng_isup.name, parm->val); - SS7_DEBUG("Found an isup_interface named = %s\n", sng_isup.name); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "id")) { - /**********************************************************************/ - sng_isup.id = atoi(parm->val); - SS7_DEBUG("Found an isup id = %d\n", sng_isup.id); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "spc")) { - /**********************************************************************/ - sng_isup.spc = atoi(parm->val); - SS7_DEBUG("Found an isup SPC = %d\n", sng_isup.spc); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "mtprouteId")) { - /**********************************************************************/ - sng_isup.mtpRouteId=atoi(parm->val); - - SS7_DEBUG("Found an isup mptRouteId = %d\n", sng_isup.mtpRouteId); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "ssf")) { - /**********************************************************************/ - ret = find_ssf_type_in_map(parm->val); - if (ret == -1) { - SS7_ERROR("Found an invalid isup ssf = %s\n", parm->var); - return FTDM_FAIL; - } else { - sng_isup.ssf = sng_ssf_type_map[ret].tril_type; - sng_isap.ssf = sng_ssf_type_map[ret].tril_type; - SS7_DEBUG("Found an isup ssf = %s\n", sng_ssf_type_map[ret].sng_type); - } - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.t1")) { - /**********************************************************************/ - sng_isap.t1 = atoi(parm->val); - SS7_DEBUG("Found isup t1 = %d\n",sng_isap.t1); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.t2")) { - /**********************************************************************/ - sng_isap.t2 = atoi(parm->val); - SS7_DEBUG("Found isup t2 = %d\n",sng_isap.t2); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.t4")) { - /**********************************************************************/ - sng_isup.t4 = atoi(parm->val); - SS7_DEBUG("Found isup t4 = %d\n",sng_isup.t4); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.t5")) { - /**********************************************************************/ - sng_isap.t5 = atoi(parm->val); - SS7_DEBUG("Found isup t5 = %d\n",sng_isap.t5); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.t6")) { - /**********************************************************************/ - sng_isap.t6 = atoi(parm->val); - SS7_DEBUG("Found isup t6 = %d\n",sng_isap.t6); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.t7")) { - /**********************************************************************/ - sng_isap.t7 = atoi(parm->val); - SS7_DEBUG("Found isup t7 = %d\n",sng_isap.t7); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.t8")) { - /**********************************************************************/ - sng_isap.t8 = atoi(parm->val); - SS7_DEBUG("Found isup t8 = %d\n",sng_isap.t8); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.t9")) { - /**********************************************************************/ - sng_isap.t9 = atoi(parm->val); - SS7_DEBUG("Found isup t9 = %d\n",sng_isap.t9); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.t11")) { - /**********************************************************************/ - sng_isup.t11 = atoi(parm->val); - SS7_DEBUG("Found isup t11 = %d\n",sng_isup.t11); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.t18")) { - /**********************************************************************/ - sng_isup.t18 = atoi(parm->val); - SS7_DEBUG("Found isup t18 = %d\n",sng_isup.t18); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.t19")) { - /**********************************************************************/ - sng_isup.t19 = atoi(parm->val); - SS7_DEBUG("Found isup t19 = %d\n",sng_isup.t19); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.t20")) { - /**********************************************************************/ - sng_isup.t20 = atoi(parm->val); - SS7_DEBUG("Found isup t20 = %d\n",sng_isup.t20); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.t21")) { - /**********************************************************************/ - sng_isup.t21 = atoi(parm->val); - SS7_DEBUG("Found isup t21 = %d\n",sng_isup.t21); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.t22")) { - /**********************************************************************/ - sng_isup.t22 = atoi(parm->val); - SS7_DEBUG("Found isup t22 = %d\n",sng_isup.t22); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.t23")) { - /**********************************************************************/ - sng_isup.t23 = atoi(parm->val); - SS7_DEBUG("Found isup t23 = %d\n",sng_isup.t23); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.t24")) { - /**********************************************************************/ - sng_isup.t24 = atoi(parm->val); - SS7_DEBUG("Found isup t24 = %d\n",sng_isup.t24); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.t25")) { - /**********************************************************************/ - sng_isup.t25 = atoi(parm->val); - SS7_DEBUG("Found isup t25 = %d\n",sng_isup.t25); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.t26")) { - /**********************************************************************/ - sng_isup.t26 = atoi(parm->val); - SS7_DEBUG("Found isup t26 = %d\n",sng_isup.t26); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.t28")) { - /**********************************************************************/ - sng_isup.t28 = atoi(parm->val); - SS7_DEBUG("Found isup t28 = %d\n",sng_isup.t28); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.t29")) { - /**********************************************************************/ - sng_isup.t29 = atoi(parm->val); - SS7_DEBUG("Found isup t29 = %d\n",sng_isup.t29); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.t30")) { - /**********************************************************************/ - sng_isup.t30 = atoi(parm->val); - SS7_DEBUG("Found isup t30 = %d\n",sng_isup.t30); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.t31")) { - /**********************************************************************/ - sng_isap.t31 = atoi(parm->val); - SS7_DEBUG("Found isup t31 = %d\n",sng_isap.t31); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.t32")) { - /**********************************************************************/ - sng_isup.t32 = atoi(parm->val); - SS7_DEBUG("Found isup t32 = %d\n",sng_isup.t32); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.t33")) { - /**********************************************************************/ - sng_isap.t33 = atoi(parm->val); - SS7_DEBUG("Found isup t33 = %d\n",sng_isap.t33); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.t34")) { - /**********************************************************************/ - sng_isap.t34 = atoi(parm->val); - SS7_DEBUG("Found isup t34 = %d\n",sng_isap.t34); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.t36")) { - /**********************************************************************/ - sng_isap.t36 = atoi(parm->val); - SS7_DEBUG("Found isup t36 = %d\n",sng_isap.t36); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.t37")) { - /**********************************************************************/ - sng_isup.t37 = atoi(parm->val); - SS7_DEBUG("Found isup t37 = %d\n",sng_isup.t37); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.t38")) { - /**********************************************************************/ - sng_isup.t38 = atoi(parm->val); - SS7_DEBUG("Found isup t38 = %d\n",sng_isup.t38); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.t39")) { - /**********************************************************************/ - sng_isup.t39 = atoi(parm->val); - SS7_DEBUG("Found isup t39 = %d\n",sng_isup.t39); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.tccr")) { - /**********************************************************************/ - sng_isap.tccr = atoi(parm->val); - SS7_DEBUG("Found isup tccr = %d\n",sng_isap.tccr); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.tccrt")) { - /**********************************************************************/ - sng_isap.tccrt = atoi(parm->val); - SS7_DEBUG("Found isup tccrt = %d\n",sng_isap.tccrt); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.tex")) { - /**********************************************************************/ - sng_isap.tex = atoi(parm->val); - SS7_DEBUG("Found isup tex = %d\n",sng_isap.tex); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.tect")) { - /**********************************************************************/ - sng_isap.tect = atoi(parm->val); - SS7_DEBUG("Found isup tect = %d\n",sng_isap.tect); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.tcrm")) { - /**********************************************************************/ - sng_isap.tcrm = atoi(parm->val); - SS7_DEBUG("Found isup tcrm = %d\n",sng_isap.tcrm); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.tcra")) { - /**********************************************************************/ - sng_isap.tcra = atoi(parm->val); - SS7_DEBUG("Found isup tcra = %d\n",sng_isap.tcra); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.tfgr")) { - /**********************************************************************/ - sng_isup.tfgr = atoi(parm->val); - SS7_DEBUG("Found isup tfgr = %d\n",sng_isup.tfgr); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.trelrsp")) { - /**********************************************************************/ - sng_isap.trelrsp = atoi(parm->val); - SS7_DEBUG("Found isup trelrsp = %d\n",sng_isap.trelrsp); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.tfnlrelrsp")) { - /**********************************************************************/ - sng_isap.tfnlrelrsp = atoi(parm->val); - SS7_DEBUG("Found isup tfnlrelrsp = %d\n",sng_isap.tfnlrelrsp); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.tfnlrelrsp")) { - /**********************************************************************/ - sng_isap.tfnlrelrsp = atoi(parm->val); - SS7_DEBUG("Found isup tfnlrelrsp = %d\n",sng_isap.tfnlrelrsp); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.tpause")) { - /**********************************************************************/ - sng_isup.tpause = atoi(parm->val); - SS7_DEBUG("Found isup tpause = %d\n",sng_isup.tpause); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.tstaenq")) { - /**********************************************************************/ - sng_isup.tstaenq = atoi(parm->val); - SS7_DEBUG("Found isup tstaenq = %d\n",sng_isup.tstaenq); - /**********************************************************************/ - } else { - /**********************************************************************/ - SS7_ERROR("Found an invalid parameter %s!\n", parm->val); - return FTDM_FAIL; - /**********************************************************************/ - } - - /* move to the next parameter */ - parm = parm + 1; - /**************************************************************************/ - } /* for (i = 0; i < num_parms; i++) */ - - /* default the interface to paused state */ - sngss7_set_flag(&sng_isup, SNGSS7_PAUSED); - - - - /* trickle down the SPC to all sub entities */ - lnkSet = &g_ftdm_sngss7_data.cfg.mtpRoute[sng_isup.mtpRouteId].lnkSets; - while (lnkSet->next != NULL) { - /**************************************************************************/ - /* go through all the links and check if they belong to this linkset*/ - i = 1; - while (i < (MAX_MTP_LINKS)) { - /* check if this link is in the linkset */ - if (g_ftdm_sngss7_data.cfg.mtp3Link[i].linkSetId == lnkSet->lsId) { - /* fill in the spc */ - g_ftdm_sngss7_data.cfg.mtp3Link[i].spc = sng_isup.spc; - } - - i++; - } - - /* move to the next lnkSet */ - lnkSet = lnkSet->next; - /**************************************************************************/ - } /* while (lnkSet->next != NULL) */ - - /* pull values from the lower levels */ - sng_isap.switchType = g_ftdm_sngss7_data.cfg.mtpRoute[sng_isup.mtpRouteId].switchType; - - /* fill in the isap */ - ftmod_ss7_fill_in_isap(&sng_isap); - - /* pull values from the lower levels */ - sng_isup.isap = sng_isap.id; - sng_isup.dpc = g_ftdm_sngss7_data.cfg.mtpRoute[sng_isup.mtpRouteId].dpc; - sng_isup.switchType = g_ftdm_sngss7_data.cfg.mtpRoute[sng_isup.mtpRouteId].switchType; - sng_isup.nwId = g_ftdm_sngss7_data.cfg.mtpRoute[sng_isup.mtpRouteId].nwId; - - /* fill in the isup interface */ - ftmod_ss7_fill_in_isup_interface(&sng_isup); - - /* setup the self mtp3 route */ - i = sng_isup.mtpRouteId; - if(ftmod_ss7_fill_in_self_route(sng_isup.spc, - g_ftdm_sngss7_data.cfg.mtpRoute[i].linkType, - g_ftdm_sngss7_data.cfg.mtpRoute[i].switchType, - g_ftdm_sngss7_data.cfg.mtpRoute[i].ssf)) { - - SS7_ERROR("Failed to fill in self route structure!\n"); - return FTDM_FAIL; - - } - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static int ftmod_ss7_parse_cc_spans(ftdm_conf_node_t *cc_spans) -{ - ftdm_conf_node_t *cc_span = NULL; - - /* confirm that we are looking at cc_spans */ - if (strcasecmp(cc_spans->name, "cc_spans")) { - SS7_ERROR("We're looking at \"%s\"...but we're supposed to be looking at \"cc_spans\"!\n",cc_spans->name); - return FTDM_FAIL; - } else { - SS7_DEBUG("Parsing \"cc_spans\"...\n"); - } - - /* extract the cc_spans */ - cc_span = cc_spans->child; - - while (cc_span != NULL) { - /* parse the found cc_span */ - if (ftmod_ss7_parse_cc_span(cc_span)) { - SS7_ERROR("Failed to parse \"cc_span\"\n"); - return FTDM_FAIL; - } - - /* go to the next cc_span */ - cc_span = cc_span->next; - } - - return FTDM_SUCCESS; - -} - -/******************************************************************************/ -static int ftmod_ss7_parse_cc_span(ftdm_conf_node_t *cc_span) -{ - sng_ccSpan_t sng_ccSpan; - ftdm_conf_parameter_t *parm = cc_span->parameters; - int num_parms = cc_span->n_parameters; - int flag_clg_nadi = 0; - int flag_cld_nadi = 0; - int flag_rdnis_nadi = 0; - int flag_loc_nadi = 0; - int i; - int ret; - - /* initalize the ccSpan structure */ - memset(&sng_ccSpan, 0x0, sizeof(sng_ccSpan)); - - - /* confirm that we are looking at an mtp_link */ - if (strcasecmp(cc_span->name, "cc_span")) { - SS7_ERROR("We're looking at \"%s\"...but we're supposed to be looking at \"cc_span\"!\n",cc_span->name); - return FTDM_FAIL; - } else { - SS7_DEBUG("Parsing \"cc_span\"...\n"); - } - - /* Backward compatible. - * If cpg_on_progress_media is not in the config file - * default the cpg on progress_media to TRUE */ - sng_ccSpan.cpg_on_progress_media=FTDM_TRUE; - /* If transparent_iam_max_size is not set in cc spans - * use the global value */ - sng_ccSpan.transparent_iam_max_size=g_ftdm_sngss7_data.cfg.transparent_iam_max_size; - - - for (i = 0; i < num_parms; i++) { - /**************************************************************************/ - - /* try to match the parameter to what we expect */ - if (!strcasecmp(parm->var, "name")) { - /**********************************************************************/ - strcpy((char *)sng_ccSpan.name, parm->val); - SS7_DEBUG("Found an ccSpan named = %s\n", sng_ccSpan.name); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "id")) { - /**********************************************************************/ - sng_ccSpan.id = atoi(parm->val); - SS7_DEBUG("Found an ccSpan id = %d\n", sng_ccSpan.id); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "procid")) { - /**********************************************************************/ - sng_ccSpan.procId = atoi(parm->val); - SS7_DEBUG("Found an ccSpan procId = %d\n", sng_ccSpan.procId); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "ch_map")) { - /**********************************************************************/ - strcpy(sng_ccSpan.ch_map, parm->val); - SS7_DEBUG("Found channel map %s\n", sng_ccSpan.ch_map); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "typeCntrl")) { - /**********************************************************************/ - ret = find_cic_cntrl_in_map(parm->val); - if (ret == -1) { - SS7_ERROR("Found an invalid ccSpan typeCntrl = %s\n", parm->var); - return FTDM_FAIL; - } else { - sng_ccSpan.typeCntrl = sng_cic_cntrl_type_map[ret].tril_type; - SS7_DEBUG("Found an ccSpan typeCntrl = %s\n", sng_cic_cntrl_type_map[ret].sng_type); - } - } else if (!strcasecmp(parm->var, "itx_auto_reply")) { - sng_ccSpan.itx_auto_reply = ftdm_true(parm->val); - SS7_DEBUG("Found itx_auto_reply %d\n", sng_ccSpan.itx_auto_reply); - } else if (!strcasecmp(parm->var, "transparent_iam")) { -#ifndef HAVE_ZLIB - SS7_CRIT("Cannot enable transparent IAM becauze zlib not installed\n"); -#else - sng_ccSpan.transparent_iam = ftdm_true(parm->val); - SS7_DEBUG("Found transparent_iam %d\n", sng_ccSpan.transparent_iam); -#endif - } else if (!strcasecmp(parm->var, "transparent_iam_max_size")) { - sng_ccSpan.transparent_iam_max_size = atoi(parm->val); - SS7_DEBUG("Found transparent_iam_max_size %d\n", sng_ccSpan.transparent_iam_max_size); - } else if (!strcasecmp(parm->var, "cpg_on_progress_media")) { - sng_ccSpan.cpg_on_progress_media = ftdm_true(parm->val); - SS7_DEBUG("Found cpg_on_progress_media %d\n", sng_ccSpan.cpg_on_progress_media); - } else if (!strcasecmp(parm->var, "cpg_on_progress")) { - sng_ccSpan.cpg_on_progress = ftdm_true(parm->val); - SS7_DEBUG("Found cpg_on_progress %d\n", sng_ccSpan.cpg_on_progress); - } else if (!strcasecmp(parm->var, "cicbase")) { - /**********************************************************************/ - sng_ccSpan.cicbase = atoi(parm->val); - SS7_DEBUG("Found a cicbase = %d\n", sng_ccSpan.cicbase); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup_interface")) { - /**********************************************************************/ - sng_ccSpan.isupInf = atoi(parm->val); - SS7_DEBUG("Found an isup_interface = %d\n",sng_ccSpan.isupInf); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "min_digits")) { - /**********************************************************************/ - sng_ccSpan.min_digits = atoi(parm->val); - SS7_DEBUG("Found a min_digits = %d\n",sng_ccSpan.min_digits); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "clg_nadi")) { - /**********************************************************************/ - /* throw the flag so that we know we got this optional parameter */ - flag_clg_nadi = 1; - sng_ccSpan.clg_nadi = atoi(parm->val); - SS7_DEBUG("Found default CLG_NADI parm->value = %d\n", sng_ccSpan.clg_nadi); - } else if (!strcasecmp(parm->var, "cld_nadi")) { - /* throw the flag so that we know we got this optional parameter */ - flag_cld_nadi = 1; - sng_ccSpan.cld_nadi = atoi(parm->val); - SS7_DEBUG("Found default CLD_NADI parm->value = %d\n", sng_ccSpan.cld_nadi); - } else if (!strcasecmp(parm->var, "rdnis_nadi")) { - /* throw the flag so that we know we got this optional parameter */ - flag_rdnis_nadi = 1; - sng_ccSpan.rdnis_nadi = atoi(parm->val); - SS7_DEBUG("Found default RDNIS_NADI parm->value = %d\n", sng_ccSpan.rdnis_nadi); - } else if (!strcasecmp(parm->var, "obci_bita")) { - if (*parm->val == '1') { - sngss7_set_options(&sng_ccSpan, SNGSS7_ACM_OBCI_BITA); - SS7_DEBUG("Found Optional Backwards Indicator: Bit A (early media) enable option\n"); - } else if (*parm->val == '0') { - sngss7_clear_options(&sng_ccSpan, SNGSS7_ACM_OBCI_BITA); - SS7_DEBUG("Found Optional Backwards Indicator: Bit A (early media) disable option\n"); - } else { - SS7_DEBUG("Invalid parm->value for obci_bita option\n"); - } - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "loc_nadi")) { - /* add location reference number */ - flag_loc_nadi = 1; - sng_ccSpan.loc_nadi = atoi(parm->val); - SS7_DEBUG("Found default LOC_NADI parm->value = %d\n", sng_ccSpan.loc_nadi); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "lpa_on_cot")) { - /**********************************************************************/ - if (*parm->val == '1') { - sngss7_set_options(&sng_ccSpan, SNGSS7_LPA_FOR_COT); - SS7_DEBUG("Found Tx LPA on COT enable option\n"); - } else if (*parm->val == '0') { - sngss7_clear_options(&sng_ccSpan, SNGSS7_LPA_FOR_COT); - SS7_DEBUG("Found Tx LPA on COT disable option\n"); - } else { - SS7_DEBUG("Invalid parm->value for lpa_on_cot option\n"); - } - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.t3")) { - /**********************************************************************/ - sng_ccSpan.t3 = atoi(parm->val); - SS7_DEBUG("Found isup t3 = %d\n", sng_ccSpan.t3); - } else if (!strcasecmp(parm->var, "isup.t10")) { - /**********************************************************************/ - sng_ccSpan.t10 = atoi(parm->val); - SS7_DEBUG("Found isup t10 = %d\n", sng_ccSpan.t10); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.t12")) { - /**********************************************************************/ - sng_ccSpan.t12 = atoi(parm->val); - SS7_DEBUG("Found isup t12 = %d\n", sng_ccSpan.t12); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.t13")) { - /**********************************************************************/ - sng_ccSpan.t13 = atoi(parm->val); - SS7_DEBUG("Found isup t13 = %d\n", sng_ccSpan.t13); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.t14")) { - /**********************************************************************/ - sng_ccSpan.t14 = atoi(parm->val); - SS7_DEBUG("Found isup t14 = %d\n", sng_ccSpan.t14); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.t15")) { - /**********************************************************************/ - sng_ccSpan.t15 = atoi(parm->val); - SS7_DEBUG("Found isup t15 = %d\n", sng_ccSpan.t15); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.t16")) { - /**********************************************************************/ - sng_ccSpan.t16 = atoi(parm->val); - SS7_DEBUG("Found isup t16 = %d\n", sng_ccSpan.t16); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.t17")) { - /**********************************************************************/ - sng_ccSpan.t17 = atoi(parm->val); - SS7_DEBUG("Found isup t17 = %d\n", sng_ccSpan.t17); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.t35")) { - /**********************************************************************/ - sng_ccSpan.t35 = atoi(parm->val); - SS7_DEBUG("Found isup t35 = %d\n",sng_ccSpan.t35); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.t39")) { - /**********************************************************************/ - sng_ccSpan.t39 = atoi(parm->val); - SS7_DEBUG("Found isup t39 = %d\n",sng_ccSpan.t39); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "isup.tval")) { - /**********************************************************************/ - sng_ccSpan.tval = atoi(parm->val); - SS7_DEBUG("Found isup tval = %d\n", sng_ccSpan.tval); - /**********************************************************************/ - } else { - /**********************************************************************/ - SS7_ERROR("Found an invalid parameter %s!\n", parm->var); - return FTDM_FAIL; - /**********************************************************************/ - } - - /* move to the next parameter */ - parm = parm + 1; - /**************************************************************************/ - } /* for (i = 0; i < num_parms; i++) */ - - /* check if the user filled in a nadi value by looking at flag */ - if (!flag_cld_nadi) { - /* default the nadi value to national */ - sng_ccSpan.cld_nadi = 0x03; - } - - if (!flag_clg_nadi) { - /* default the nadi value to national */ - sng_ccSpan.clg_nadi = 0x03; - } - - if (!flag_rdnis_nadi) { - /* default the nadi value to national */ - sng_ccSpan.rdnis_nadi = 0x03; - } - - if (!flag_loc_nadi) { - /* default the nadi value to national */ - sng_ccSpan.loc_nadi = 0x03; - } - - /* pull up the SSF and Switchtype from the isup interface */ - sng_ccSpan.ssf = g_ftdm_sngss7_data.cfg.isupIntf[sng_ccSpan.isupInf].ssf; - sng_ccSpan.switchType = g_ftdm_sngss7_data.cfg.isupIntf[sng_ccSpan.isupInf].switchType; - - /* add this span to our global listing */ - ftmod_ss7_fill_in_ccSpan(&sng_ccSpan); - - /* make sure the isup interface structure has something in it */ - if (g_ftdm_sngss7_data.cfg.isupIntf[sng_ccSpan.isupInf].id == 0) { - /* fill in the id, so that we know it exists */ - g_ftdm_sngss7_data.cfg.isupIntf[sng_ccSpan.isupInf].id = sng_ccSpan.isupInf; - - /* default the status to PAUSED */ - sngss7_set_flag(&g_ftdm_sngss7_data.cfg.isupIntf[sng_ccSpan.isupInf], SNGSS7_PAUSED); - } - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static int ftmod_ss7_fill_in_relay_channel(sng_relay_t *relay_channel) -{ - int i; - - /* go through all the existing channels and see if we find a match */ - i = 1; - while (g_ftdm_sngss7_data.cfg.relay[i].id != 0) { - if ((g_ftdm_sngss7_data.cfg.relay[i].type == relay_channel->type) && - (g_ftdm_sngss7_data.cfg.relay[i].port == relay_channel->port) && - (g_ftdm_sngss7_data.cfg.relay[i].procId == relay_channel->procId) && - (!strcasecmp(g_ftdm_sngss7_data.cfg.relay[i].hostname, relay_channel->hostname))) { - - /* we have a match so break out of this loop */ - break; - } - /* move on to the next one */ - i++; - } - - /* if the id value is 0 that means we didn't find the relay channel */ - if (g_ftdm_sngss7_data.cfg.relay[i].id == 0) { - relay_channel->id = i; - SS7_DEBUG("found new relay channel on type:%d, hostname:%s, port:%d, procId:%d, id = %d\n", - relay_channel->type, - relay_channel->hostname, - relay_channel->port, - relay_channel->procId, - relay_channel->id); - sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_RY_PRESENT); - } else { - relay_channel->id = i; - SS7_DEBUG("found existing relay channel on type:%d, hostname:%s, port:%d, procId:%d, id = %d\n", - relay_channel->type, - relay_channel->hostname, - relay_channel->port, - relay_channel->procId, - relay_channel->id); - } - - g_ftdm_sngss7_data.cfg.relay[i].id = relay_channel->id; - g_ftdm_sngss7_data.cfg.relay[i].type = relay_channel->type; - g_ftdm_sngss7_data.cfg.relay[i].port = relay_channel->port; - g_ftdm_sngss7_data.cfg.relay[i].procId = relay_channel->procId; - strcpy(g_ftdm_sngss7_data.cfg.relay[i].hostname, relay_channel->hostname); - strcpy(g_ftdm_sngss7_data.cfg.relay[i].name, relay_channel->name); - - /* if this is THE listen channel grab the procId and use it */ - if (relay_channel->type == LRY_CT_TCP_LISTEN) { - g_ftdm_sngss7_data.cfg.procId = relay_channel->procId; - } - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static int ftmod_ss7_fill_in_mtp1_link(sng_mtp1_link_t *mtp1Link) -{ - int i = mtp1Link->id; - - /* check if this id value has been used already */ - if (g_ftdm_sngss7_data.cfg.mtp1Link[i].id == 0) { - SS7_DEBUG("Found new MTP1 Link: id=%d, name=%s\n", mtp1Link->id, mtp1Link->name); - sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP1_PRESENT); - } else { - SS7_DEBUG("Found an existing MTP1 Link: id=%d, name=%s (old name=%s)\n", - mtp1Link->id, - mtp1Link->name, - g_ftdm_sngss7_data.cfg.mtp1Link[i].name); - } - - /* copy over the values */ - strcpy((char *)g_ftdm_sngss7_data.cfg.mtp1Link[i].name, (char *)mtp1Link->name); - - g_ftdm_sngss7_data.cfg.mtp1Link[i].id = mtp1Link->id; - g_ftdm_sngss7_data.cfg.mtp1Link[i].span = mtp1Link->span; - g_ftdm_sngss7_data.cfg.mtp1Link[i].chan = mtp1Link->chan; - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static int ftmod_ss7_fill_in_mtp2_link(sng_mtp2_link_t *mtp2Link) -{ - int i = mtp2Link->id; - - /* check if this id value has been used already */ - if (g_ftdm_sngss7_data.cfg.mtp2Link[i].id == 0) { - SS7_DEBUG("Found new MTP2 Link: id=%d, name=%s\n", mtp2Link->id, mtp2Link->name); - sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP2_PRESENT); - } else { - SS7_DEBUG("Found an existing MTP2 Link: id=%d, name=%s (old name=%s)\n", - mtp2Link->id, - mtp2Link->name, - g_ftdm_sngss7_data.cfg.mtp2Link[i].name); - } - - /* copy over the values */ - strcpy((char *)g_ftdm_sngss7_data.cfg.mtp2Link[i].name, (char *)mtp2Link->name); - - g_ftdm_sngss7_data.cfg.mtp2Link[i].id = mtp2Link->id; - g_ftdm_sngss7_data.cfg.mtp2Link[i].lssuLength = mtp2Link->lssuLength; - g_ftdm_sngss7_data.cfg.mtp2Link[i].errorType = mtp2Link->errorType; - g_ftdm_sngss7_data.cfg.mtp2Link[i].linkType = mtp2Link->linkType; - g_ftdm_sngss7_data.cfg.mtp2Link[i].mtp1Id = mtp2Link->mtp1Id; - g_ftdm_sngss7_data.cfg.mtp2Link[i].mtp1ProcId = mtp2Link->mtp1ProcId; - - if ( mtp2Link->t1 != 0 ) { - g_ftdm_sngss7_data.cfg.mtp2Link[i].t1 = mtp2Link->t1; - }else { - g_ftdm_sngss7_data.cfg.mtp2Link[i].t1 = 500; - } - - if ( mtp2Link->t2 != 0 ) { - g_ftdm_sngss7_data.cfg.mtp2Link[i].t2 = mtp2Link->t2; - }else { - g_ftdm_sngss7_data.cfg.mtp2Link[i].t2 = 250; - } - - if ( mtp2Link->t3 != 0 ) { - g_ftdm_sngss7_data.cfg.mtp2Link[i].t3 = mtp2Link->t3; - }else { - g_ftdm_sngss7_data.cfg.mtp2Link[i].t3 = 20; - } - - if ( mtp2Link->t4n != 0 ) { - g_ftdm_sngss7_data.cfg.mtp2Link[i].t4n = mtp2Link->t4n; - }else { - g_ftdm_sngss7_data.cfg.mtp2Link[i].t4n = 80; - } - - if ( mtp2Link->t4e != 0 ) { - g_ftdm_sngss7_data.cfg.mtp2Link[i].t4e = mtp2Link->t4e; - }else { - g_ftdm_sngss7_data.cfg.mtp2Link[i].t4e = 5; - } - - if ( mtp2Link->t5 != 0 ) { - g_ftdm_sngss7_data.cfg.mtp2Link[i].t5 = mtp2Link->t5; - }else { - g_ftdm_sngss7_data.cfg.mtp2Link[i].t5 = 1; - } - - if ( mtp2Link->t6 != 0 ) { - g_ftdm_sngss7_data.cfg.mtp2Link[i].t6 = mtp2Link->t6; - }else { - g_ftdm_sngss7_data.cfg.mtp2Link[i].t6 = 60; - } - - if ( mtp2Link->t7 != 0 ) { - g_ftdm_sngss7_data.cfg.mtp2Link[i].t7 = mtp2Link->t7; - }else { - g_ftdm_sngss7_data.cfg.mtp2Link[i].t7 = 20; - } - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static int ftmod_ss7_fill_in_mtp3_link(sng_mtp3_link_t *mtp3Link) -{ - int i = mtp3Link->id; - - /* check if this id value has been used already */ - if (g_ftdm_sngss7_data.cfg.mtp3Link[i].id == 0) { - SS7_DEBUG("Found new MTP3 Link: id=%d, name=%s\n", mtp3Link->id, mtp3Link->name); - sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP3_PRESENT); - } else { - SS7_DEBUG("Found an existing MTP3 Link: id=%d, name=%s (old name=%s)\n", - mtp3Link->id, - mtp3Link->name, - g_ftdm_sngss7_data.cfg.mtp3Link[i].name); - } - - /* copy over the values */ - strcpy((char *)g_ftdm_sngss7_data.cfg.mtp3Link[i].name, (char *)mtp3Link->name); - - g_ftdm_sngss7_data.cfg.mtp3Link[i].id = mtp3Link->id; - g_ftdm_sngss7_data.cfg.mtp3Link[i].priority = mtp3Link->priority; - g_ftdm_sngss7_data.cfg.mtp3Link[i].linkType = mtp3Link->linkType; - g_ftdm_sngss7_data.cfg.mtp3Link[i].switchType = mtp3Link->switchType; - g_ftdm_sngss7_data.cfg.mtp3Link[i].apc = mtp3Link->apc; - g_ftdm_sngss7_data.cfg.mtp3Link[i].spc = mtp3Link->spc; /* unknown at this time */ - g_ftdm_sngss7_data.cfg.mtp3Link[i].ssf = mtp3Link->ssf; - g_ftdm_sngss7_data.cfg.mtp3Link[i].slc = mtp3Link->slc; - g_ftdm_sngss7_data.cfg.mtp3Link[i].linkSetId = mtp3Link->linkSetId; - g_ftdm_sngss7_data.cfg.mtp3Link[i].mtp2Id = mtp3Link->mtp2Id; - g_ftdm_sngss7_data.cfg.mtp3Link[i].mtp2ProcId = mtp3Link->mtp2ProcId; - - if (mtp3Link->t1 != 0) { - g_ftdm_sngss7_data.cfg.mtp3Link[i].t1 = mtp3Link->t1; - } else { - g_ftdm_sngss7_data.cfg.mtp3Link[i].t1 = 8; - } - if (mtp3Link->t2 != 0) { - g_ftdm_sngss7_data.cfg.mtp3Link[i].t2 = mtp3Link->t2; - } else { - g_ftdm_sngss7_data.cfg.mtp3Link[i].t2 = 14; - } - if (mtp3Link->t3 != 0) { - g_ftdm_sngss7_data.cfg.mtp3Link[i].t3 = mtp3Link->t3; - } else { - g_ftdm_sngss7_data.cfg.mtp3Link[i].t3 = 8; - } - if (mtp3Link->t4 != 0) { - g_ftdm_sngss7_data.cfg.mtp3Link[i].t4 = mtp3Link->t4; - } else { - g_ftdm_sngss7_data.cfg.mtp3Link[i].t4 = 8; - } - if (mtp3Link->t5 != 0) { - g_ftdm_sngss7_data.cfg.mtp3Link[i].t5 = mtp3Link->t5; - } else { - g_ftdm_sngss7_data.cfg.mtp3Link[i].t5 = 8; - } - if (mtp3Link->t7 != 0) { - g_ftdm_sngss7_data.cfg.mtp3Link[i].t7 = mtp3Link->t7; - } else { - g_ftdm_sngss7_data.cfg.mtp3Link[i].t7 = 15; - } - if (mtp3Link->t12 != 0) { - g_ftdm_sngss7_data.cfg.mtp3Link[i].t12 = mtp3Link->t12; - } else { - g_ftdm_sngss7_data.cfg.mtp3Link[i].t12 = 15; - } - if (mtp3Link->t13 != 0) { - g_ftdm_sngss7_data.cfg.mtp3Link[i].t13 = mtp3Link->t13; - } else { - g_ftdm_sngss7_data.cfg.mtp3Link[i].t13 = 15; - } - if (mtp3Link->t14 != 0) { - g_ftdm_sngss7_data.cfg.mtp3Link[i].t14 = mtp3Link->t14; - } else { - g_ftdm_sngss7_data.cfg.mtp3Link[i].t14 = 30; - } - if (mtp3Link->t17 != 0) { - g_ftdm_sngss7_data.cfg.mtp3Link[i].t17 = mtp3Link->t17; - } else { - g_ftdm_sngss7_data.cfg.mtp3Link[i].t17 = 15; - } - if (mtp3Link->t22 != 0) { - g_ftdm_sngss7_data.cfg.mtp3Link[i].t22 = mtp3Link->t22; - } else { - g_ftdm_sngss7_data.cfg.mtp3Link[i].t22 = 1800; - } - if (mtp3Link->t23 != 0) { - g_ftdm_sngss7_data.cfg.mtp3Link[i].t23 = mtp3Link->t23; - } else { - g_ftdm_sngss7_data.cfg.mtp3Link[i].t23 = 1800; - } - if (mtp3Link->t24 != 0) { - g_ftdm_sngss7_data.cfg.mtp3Link[i].t24 = mtp3Link->t24; - } else { - g_ftdm_sngss7_data.cfg.mtp3Link[i].t24 = 5; - } - if (mtp3Link->t31 != 0) { - g_ftdm_sngss7_data.cfg.mtp3Link[i].t31 = mtp3Link->t31; - } else { - g_ftdm_sngss7_data.cfg.mtp3Link[i].t31 = 50; - } - if (mtp3Link->t32 != 0) { - g_ftdm_sngss7_data.cfg.mtp3Link[i].t32 = mtp3Link->t32; - } else { - g_ftdm_sngss7_data.cfg.mtp3Link[i].t32 = 120; - } - if (mtp3Link->t33 != 0) { - g_ftdm_sngss7_data.cfg.mtp3Link[i].t33 = mtp3Link->t33; - } else { - g_ftdm_sngss7_data.cfg.mtp3Link[i].t33 = 3000; - } - if (mtp3Link->t34 != 0) { - g_ftdm_sngss7_data.cfg.mtp3Link[i].t34 = mtp3Link->t34; - } else { - g_ftdm_sngss7_data.cfg.mtp3Link[i].t34 = 600; - } - if (mtp3Link->tbnd != 0) { - g_ftdm_sngss7_data.cfg.mtp3Link[i].tbnd = mtp3Link->tbnd; - } else { - g_ftdm_sngss7_data.cfg.mtp3Link[i].tbnd = 30000; - } - if (mtp3Link->tflc != 0) { - g_ftdm_sngss7_data.cfg.mtp3Link[i].tflc = mtp3Link->tflc; - } else { - g_ftdm_sngss7_data.cfg.mtp3Link[i].tflc = 300; - } - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static int ftmod_ss7_fill_in_mtpLinkSet(sng_link_set_t *mtpLinkSet) -{ - int i = mtpLinkSet->id; - - strncpy((char *)g_ftdm_sngss7_data.cfg.mtpLinkSet[i].name, (char *)mtpLinkSet->name, MAX_NAME_LEN-1); - - g_ftdm_sngss7_data.cfg.mtpLinkSet[i].id = mtpLinkSet->id; - g_ftdm_sngss7_data.cfg.mtpLinkSet[i].apc = mtpLinkSet->apc; - - /* these values are filled in as we find routes and start allocating cmbLinkSetIds */ - g_ftdm_sngss7_data.cfg.mtpLinkSet[i].minActive = mtpLinkSet->minActive; - g_ftdm_sngss7_data.cfg.mtpLinkSet[i].numLinks = 0; - return 0; -} - -/******************************************************************************/ -static int ftmod_ss7_fill_in_mtp3_route(sng_route_t *mtp3_route) -{ - sng_link_set_list_t *lnkSet = NULL; - int i = mtp3_route->id; - int tmp = 0; - - - /* check if this id value has been used already */ - if (g_ftdm_sngss7_data.cfg.mtpRoute[i].id == 0) { - SS7_DEBUG("Found new MTP3 Link: id=%d, name=%s\n", mtp3_route->id, mtp3_route->name); - } else { - SS7_DEBUG("Found an existing MTP3 Link: id=%d, name=%s (old name=%s)\n", - mtp3_route->id, - mtp3_route->name, - g_ftdm_sngss7_data.cfg.mtpRoute[i].name); - } - - /* fill in the cmbLinkSet in the linkset structure */ - lnkSet = &mtp3_route->lnkSets; - - tmp = g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet->lsId].numLinks; - g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet->lsId].links[tmp] = mtp3_route->cmbLinkSetId; - g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet->lsId].numLinks++; - - while (lnkSet->next != NULL) { - tmp = g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet->lsId].numLinks; - g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet->lsId].links[tmp] = mtp3_route->cmbLinkSetId; - g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet->lsId].numLinks++; - - lnkSet = lnkSet->next; - } - - strcpy((char *)g_ftdm_sngss7_data.cfg.mtpRoute[i].name, (char *)mtp3_route->name); - - g_ftdm_sngss7_data.cfg.mtpRoute[i].id = mtp3_route->id; - g_ftdm_sngss7_data.cfg.mtpRoute[i].dpc = mtp3_route->dpc; - g_ftdm_sngss7_data.cfg.mtpRoute[i].linkType = mtp3_route->linkType; - g_ftdm_sngss7_data.cfg.mtpRoute[i].switchType = mtp3_route->switchType; - g_ftdm_sngss7_data.cfg.mtpRoute[i].cmbLinkSetId = mtp3_route->cmbLinkSetId; - g_ftdm_sngss7_data.cfg.mtpRoute[i].isSTP = mtp3_route->isSTP; - g_ftdm_sngss7_data.cfg.mtpRoute[i].nwId = mtp3_route->nwId; - g_ftdm_sngss7_data.cfg.mtpRoute[i].lnkSets = mtp3_route->lnkSets; - g_ftdm_sngss7_data.cfg.mtpRoute[i].ssf = mtp3_route->ssf; - g_ftdm_sngss7_data.cfg.mtpRoute[i].dir = SNG_RTE_DN; - if (mtp3_route->t6 != 0) { - g_ftdm_sngss7_data.cfg.mtpRoute[i].t6 = mtp3_route->t6; - } else { - g_ftdm_sngss7_data.cfg.mtpRoute[i].t6 = 8; - } - if (mtp3_route->t8 != 0) { - g_ftdm_sngss7_data.cfg.mtpRoute[i].t8 = mtp3_route->t8; - } else { - g_ftdm_sngss7_data.cfg.mtpRoute[i].t8 = 12; - } - if (mtp3_route->t10 != 0) { - g_ftdm_sngss7_data.cfg.mtpRoute[i].t10 = mtp3_route->t10; - } else { - g_ftdm_sngss7_data.cfg.mtpRoute[i].t10 = 300; - } - if (mtp3_route->t11 != 0) { - g_ftdm_sngss7_data.cfg.mtpRoute[i].t11 = mtp3_route->t11; - } else { - g_ftdm_sngss7_data.cfg.mtpRoute[i].t11 = 300; - } - if (mtp3_route->t15 != 0) { - g_ftdm_sngss7_data.cfg.mtpRoute[i].t15 = mtp3_route->t15; - } else { - g_ftdm_sngss7_data.cfg.mtpRoute[i].t15 = 30; - } - if (mtp3_route->t16 != 0) { - g_ftdm_sngss7_data.cfg.mtpRoute[i].t16 = mtp3_route->t16; - } else { - g_ftdm_sngss7_data.cfg.mtpRoute[i].t16 = 20; - } - if (mtp3_route->t18 != 0) { - g_ftdm_sngss7_data.cfg.mtpRoute[i].t18 = mtp3_route->t18; - } else { - g_ftdm_sngss7_data.cfg.mtpRoute[i].t18 = 200; - } - if (mtp3_route->t19 != 0) { - g_ftdm_sngss7_data.cfg.mtpRoute[i].t19 = mtp3_route->t19; - } else { - g_ftdm_sngss7_data.cfg.mtpRoute[i].t19 = 690; - } - if (mtp3_route->t21 != 0) { - g_ftdm_sngss7_data.cfg.mtpRoute[i].t21 = mtp3_route->t21; - } else { - g_ftdm_sngss7_data.cfg.mtpRoute[i].t21 = 650; - } - if (mtp3_route->t25 != 0) { - g_ftdm_sngss7_data.cfg.mtpRoute[i].t25 = mtp3_route->t25; - } else { - g_ftdm_sngss7_data.cfg.mtpRoute[i].t25 = 100; - } - if (mtp3_route->t26 != 0) { - g_ftdm_sngss7_data.cfg.mtpRoute[i].t26 = mtp3_route->t26; - } else { - g_ftdm_sngss7_data.cfg.mtpRoute[i].t26 = 100; - } - - return 0; -} - -/******************************************************************************/ -static int ftmod_ss7_fill_in_self_route(int spc, int linkType, int switchType, int ssf) -{ - int i = 1; - - while (i < (MAX_MTP_ROUTES)) { - if (g_ftdm_sngss7_data.cfg.mtpRoute[i].dpc == spc) { - /* we have a match so break out of this loop */ - break; - } - /* move on to the next one */ - i++; - } - - if (g_ftdm_sngss7_data.cfg.mtpRoute[i].id == 0) { - /* this is a new route...find the first free spot */ - i = 1; - while (i < (MAX_MTP_ROUTES)) { - if (g_ftdm_sngss7_data.cfg.mtpRoute[i].id == 0) { - /* we have a match so break out of this loop */ - break; - } - /* move on to the next one */ - i++; - } - g_ftdm_sngss7_data.cfg.mtpRoute[i].id = i; - SS7_DEBUG("found new mtp3 self route\n"); - } else { - g_ftdm_sngss7_data.cfg.mtpRoute[i].id = i; - SS7_DEBUG("found existing mtp3 self route\n"); - } - - strncpy((char *)g_ftdm_sngss7_data.cfg.mtpRoute[i].name, "self-route", MAX_NAME_LEN-1); - - g_ftdm_sngss7_data.cfg.mtpRoute[i].id = i; - g_ftdm_sngss7_data.cfg.mtpRoute[i].dpc = spc; - g_ftdm_sngss7_data.cfg.mtpRoute[i].linkType = linkType; - g_ftdm_sngss7_data.cfg.mtpRoute[i].switchType = switchType; - g_ftdm_sngss7_data.cfg.mtpRoute[i].cmbLinkSetId = i; - g_ftdm_sngss7_data.cfg.mtpRoute[i].isSTP = 0; - g_ftdm_sngss7_data.cfg.mtpRoute[i].ssf = ssf; - g_ftdm_sngss7_data.cfg.mtpRoute[i].dir = SNG_RTE_UP; - g_ftdm_sngss7_data.cfg.mtpRoute[i].t6 = 8; - g_ftdm_sngss7_data.cfg.mtpRoute[i].t8 = 12; - g_ftdm_sngss7_data.cfg.mtpRoute[i].t10 = 300; - g_ftdm_sngss7_data.cfg.mtpRoute[i].t11 = 300; - g_ftdm_sngss7_data.cfg.mtpRoute[i].t15 = 30; - g_ftdm_sngss7_data.cfg.mtpRoute[i].t16 = 20; - g_ftdm_sngss7_data.cfg.mtpRoute[i].t18 = 200; - g_ftdm_sngss7_data.cfg.mtpRoute[i].t19 = 690; - g_ftdm_sngss7_data.cfg.mtpRoute[i].t21 = 650; - g_ftdm_sngss7_data.cfg.mtpRoute[i].t25 = 100; - - return 0; -} - -/******************************************************************************/ -static int ftmod_ss7_fill_in_nsap(sng_route_t *mtp3_route) -{ - int i; - - /* go through all the existing interfaces and see if we find a match */ - i = 1; - while (g_ftdm_sngss7_data.cfg.nsap[i].id != 0) { - if ((g_ftdm_sngss7_data.cfg.nsap[i].linkType == mtp3_route->linkType) && - (g_ftdm_sngss7_data.cfg.nsap[i].switchType == mtp3_route->switchType)) { - - /* we have a match so break out of this loop */ - break; - } - /* move on to the next one */ - i++; - } - - if (g_ftdm_sngss7_data.cfg.nsap[i].id == 0) { - g_ftdm_sngss7_data.cfg.nsap[i].id = i; - SS7_DEBUG("found new mtp3_isup interface, id is = %d\n", g_ftdm_sngss7_data.cfg.nsap[i].id); - } else { - g_ftdm_sngss7_data.cfg.nsap[i].id = i; - SS7_DEBUG("found existing mtp3_isup interface, id is = %d\n", g_ftdm_sngss7_data.cfg.nsap[i].id); - } - - g_ftdm_sngss7_data.cfg.nsap[i].spId = g_ftdm_sngss7_data.cfg.nsap[i].id; - g_ftdm_sngss7_data.cfg.nsap[i].suId = g_ftdm_sngss7_data.cfg.nsap[i].id; - g_ftdm_sngss7_data.cfg.nsap[i].nwId = mtp3_route->nwId; - g_ftdm_sngss7_data.cfg.nsap[i].linkType = mtp3_route->linkType; - g_ftdm_sngss7_data.cfg.nsap[i].switchType = mtp3_route->switchType; - g_ftdm_sngss7_data.cfg.nsap[i].ssf = mtp3_route->ssf; - - return 0; -} - -/******************************************************************************/ -static int ftmod_ss7_fill_in_isup_interface(sng_isup_inf_t *sng_isup) -{ - int i = sng_isup->id; - - /* check if this id value has been used already */ - if (g_ftdm_sngss7_data.cfg.isupIntf[i].id == 0) { - SS7_DEBUG("Found new ISUP Interface: id=%d, name=%s\n", sng_isup->id, sng_isup->name); - sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_ISUP_PRESENT); - } else { - SS7_DEBUG("Found an existing ISUP Interface: id=%d, name=%s (old name=%s)\n", - sng_isup->id, - sng_isup->name, - g_ftdm_sngss7_data.cfg.isupIntf[i].name); - } - - strncpy((char *)g_ftdm_sngss7_data.cfg.isupIntf[i].name, (char *)sng_isup->name, MAX_NAME_LEN-1); - - g_ftdm_sngss7_data.cfg.isupIntf[i].id = sng_isup->id; - g_ftdm_sngss7_data.cfg.isupIntf[i].mtpRouteId = sng_isup->mtpRouteId; - g_ftdm_sngss7_data.cfg.isupIntf[i].nwId = sng_isup->nwId; - g_ftdm_sngss7_data.cfg.isupIntf[i].dpc = sng_isup->dpc; - g_ftdm_sngss7_data.cfg.isupIntf[i].spc = sng_isup->spc; - g_ftdm_sngss7_data.cfg.isupIntf[i].switchType = sng_isup->switchType; - g_ftdm_sngss7_data.cfg.isupIntf[i].ssf = sng_isup->ssf; - g_ftdm_sngss7_data.cfg.isupIntf[i].isap = sng_isup->isap; - g_ftdm_sngss7_data.cfg.isupIntf[i].options = sng_isup->options; - if (sng_isup->t4 != 0) { - g_ftdm_sngss7_data.cfg.isupIntf[i].t4 = sng_isup->t4; - } else { - g_ftdm_sngss7_data.cfg.isupIntf[i].t4 = 3000; - } - if (sng_isup->t11 != 0) { - g_ftdm_sngss7_data.cfg.isupIntf[i].t11 = sng_isup->t11; - } else { - g_ftdm_sngss7_data.cfg.isupIntf[i].t11 = 170; - } - if (sng_isup->t18 != 0) { - g_ftdm_sngss7_data.cfg.isupIntf[i].t18 = sng_isup->t18; - } else { - g_ftdm_sngss7_data.cfg.isupIntf[i].t18 = 300; - } - if (sng_isup->t19 != 0) { - g_ftdm_sngss7_data.cfg.isupIntf[i].t19 = sng_isup->t19; - } else { - g_ftdm_sngss7_data.cfg.isupIntf[i].t19 = 3000; - } - if (sng_isup->t20 != 0) { - g_ftdm_sngss7_data.cfg.isupIntf[i].t20 = sng_isup->t20; - } else { - g_ftdm_sngss7_data.cfg.isupIntf[i].t20 = 300; - } - if (sng_isup->t21 != 0) { - g_ftdm_sngss7_data.cfg.isupIntf[i].t21 = sng_isup->t21; - } else { - g_ftdm_sngss7_data.cfg.isupIntf[i].t21 = 3000; - } - if (sng_isup->t22 != 0) { - g_ftdm_sngss7_data.cfg.isupIntf[i].t22 = sng_isup->t22; - } else { - g_ftdm_sngss7_data.cfg.isupIntf[i].t22 = 300; - } - if (sng_isup->t23 != 0) { - g_ftdm_sngss7_data.cfg.isupIntf[i].t23 = sng_isup->t23; - } else { - g_ftdm_sngss7_data.cfg.isupIntf[i].t23 = 3000; - } - if (sng_isup->t24 != 0) { - g_ftdm_sngss7_data.cfg.isupIntf[i].t24 = sng_isup->t24; - } else { - g_ftdm_sngss7_data.cfg.isupIntf[i].t24 = 10; - } - if (sng_isup->t25 != 0) { - g_ftdm_sngss7_data.cfg.isupIntf[i].t25 = sng_isup->t25; - } else { - g_ftdm_sngss7_data.cfg.isupIntf[i].t25 = 20; - } - if (sng_isup->t26 != 0) { - g_ftdm_sngss7_data.cfg.isupIntf[i].t26 = sng_isup->t26; - } else { - g_ftdm_sngss7_data.cfg.isupIntf[i].t26 = 600; - } - if (sng_isup->t28 != 0) { - g_ftdm_sngss7_data.cfg.isupIntf[i].t28 = sng_isup->t28; - } else { - g_ftdm_sngss7_data.cfg.isupIntf[i].t28 = 100; - } - if (sng_isup->t29 != 0) { - g_ftdm_sngss7_data.cfg.isupIntf[i].t29 = sng_isup->t29; - } else { - g_ftdm_sngss7_data.cfg.isupIntf[i].t29 = 6; - } - if (sng_isup->t30 != 0) { - g_ftdm_sngss7_data.cfg.isupIntf[i].t30 = sng_isup->t30; - } else { - g_ftdm_sngss7_data.cfg.isupIntf[i].t30 = 50; - } - if (sng_isup->t32 != 0) { - g_ftdm_sngss7_data.cfg.isupIntf[i].t32 = sng_isup->t32; - } else { - g_ftdm_sngss7_data.cfg.isupIntf[i].t32 = 30; - } - if (sng_isup->t37 != 0) { - g_ftdm_sngss7_data.cfg.isupIntf[i].t37 = sng_isup->t37; - } else { - g_ftdm_sngss7_data.cfg.isupIntf[i].t37 = 20; - } - if (sng_isup->t38 != 0) { - g_ftdm_sngss7_data.cfg.isupIntf[i].t38 = sng_isup->t38; - } else { - g_ftdm_sngss7_data.cfg.isupIntf[i].t38 = 1200; - } - if (sng_isup->t39 != 0) { - g_ftdm_sngss7_data.cfg.isupIntf[i].t39 = sng_isup->t39; - } else { - g_ftdm_sngss7_data.cfg.isupIntf[i].t39 = 300; - } - if (sng_isup->tfgr != 0) { - g_ftdm_sngss7_data.cfg.isupIntf[i].tfgr = sng_isup->tfgr; - } else { - g_ftdm_sngss7_data.cfg.isupIntf[i].tfgr = 50; - } - if (sng_isup->tpause != 0) { - g_ftdm_sngss7_data.cfg.isupIntf[i].tpause = sng_isup->tpause; - } else { - g_ftdm_sngss7_data.cfg.isupIntf[i].tpause = 3000; - } - if (sng_isup->tstaenq != 0) { - g_ftdm_sngss7_data.cfg.isupIntf[i].tstaenq = sng_isup->tstaenq; - } else { - g_ftdm_sngss7_data.cfg.isupIntf[i].tstaenq = 5000; - } - - return 0; -} - -/******************************************************************************/ -static int ftmod_ss7_fill_in_isap(sng_isap_t *sng_isap) -{ - int i; - - /* go through all the existing interfaces and see if we find a match */ - i = 1; - while (g_ftdm_sngss7_data.cfg.isap[i].id != 0) { - if (g_ftdm_sngss7_data.cfg.isap[i].switchType == sng_isap->switchType) { - - /* we have a match so break out of this loop */ - break; - } - /* move on to the next one */ - i++; - } - - if (g_ftdm_sngss7_data.cfg.isap[i].id == 0) { - sng_isap->id = i; - SS7_DEBUG("found new isup to cc interface, id is = %d\n", sng_isap->id); - } else { - sng_isap->id = i; - SS7_DEBUG("found existing isup to cc interface, id is = %d\n", sng_isap->id); - } - - g_ftdm_sngss7_data.cfg.isap[i].id = sng_isap->id; - g_ftdm_sngss7_data.cfg.isap[i].suId = sng_isap->id; - g_ftdm_sngss7_data.cfg.isap[i].spId = sng_isap->id; - g_ftdm_sngss7_data.cfg.isap[i].switchType = sng_isap->switchType; - g_ftdm_sngss7_data.cfg.isap[i].ssf = sng_isap->ssf; - - if (sng_isap->t1 != 0) { - g_ftdm_sngss7_data.cfg.isap[i].t1 = sng_isap->t1; - } else { - g_ftdm_sngss7_data.cfg.isap[i].t1 = 150; - } - if (sng_isap->t2 != 0) { - g_ftdm_sngss7_data.cfg.isap[i].t2 = sng_isap->t2; - } else { - g_ftdm_sngss7_data.cfg.isap[i].t2 = 1800; - } - if (sng_isap->t5 != 0) { - g_ftdm_sngss7_data.cfg.isap[i].t5 = sng_isap->t5; - } else { - g_ftdm_sngss7_data.cfg.isap[i].t5 = 3000; - } - if (sng_isap->t6 != 0) { - g_ftdm_sngss7_data.cfg.isap[i].t6 = sng_isap->t6; - } else { - g_ftdm_sngss7_data.cfg.isap[i].t6 = 600; - } - if (sng_isap->t7 != 0) { - g_ftdm_sngss7_data.cfg.isap[i].t7 = sng_isap->t7; - } else { - g_ftdm_sngss7_data.cfg.isap[i].t7 = 200; - } - if (sng_isap->t8 != 0) { - g_ftdm_sngss7_data.cfg.isap[i].t8 = sng_isap->t8; - } else { - g_ftdm_sngss7_data.cfg.isap[i].t8 = 100; - } - if (sng_isap->t9 != 0) { - g_ftdm_sngss7_data.cfg.isap[i].t9 = sng_isap->t9; - } else { - g_ftdm_sngss7_data.cfg.isap[i].t9 = 1800; - } - if (sng_isap->t27 != 0) { - g_ftdm_sngss7_data.cfg.isap[i].t27 = sng_isap->t27; - } else { - g_ftdm_sngss7_data.cfg.isap[i].t27 = 2400; - } - if (sng_isap->t31 != 0) { - g_ftdm_sngss7_data.cfg.isap[i].t31 = sng_isap->t31; - } else { - g_ftdm_sngss7_data.cfg.isap[i].t31 = 3650; - } - if (sng_isap->t33 != 0) { - g_ftdm_sngss7_data.cfg.isap[i].t33 = sng_isap->t33; - } else { - g_ftdm_sngss7_data.cfg.isap[i].t33 = 120; - } - if (sng_isap->t34 != 0) { - g_ftdm_sngss7_data.cfg.isap[i].t34 = sng_isap->t34; - } else { - g_ftdm_sngss7_data.cfg.isap[i].t34 = 40; - } - if (sng_isap->t36 != 0) { - g_ftdm_sngss7_data.cfg.isap[i].t36 = sng_isap->t36; - } else { - g_ftdm_sngss7_data.cfg.isap[i].t36 = 120; - } - if (sng_isap->tccr != 0) { - g_ftdm_sngss7_data.cfg.isap[i].tccr = sng_isap->tccr; - } else { - g_ftdm_sngss7_data.cfg.isap[i].tccr = 200; - } - if (sng_isap->tccrt != 0) { - g_ftdm_sngss7_data.cfg.isap[i].tccrt = sng_isap->tccrt; - } else { - g_ftdm_sngss7_data.cfg.isap[i].tccrt = 20; - } - if (sng_isap->tex != 0) { - g_ftdm_sngss7_data.cfg.isap[i].tex = sng_isap->tex; - } else { - g_ftdm_sngss7_data.cfg.isap[i].tex = 1000; - } - if (sng_isap->tcrm != 0) { - g_ftdm_sngss7_data.cfg.isap[i].tcrm = sng_isap->tcrm; - } else { - g_ftdm_sngss7_data.cfg.isap[i].tcrm = 30; - } - if (sng_isap->tcra != 0) { - g_ftdm_sngss7_data.cfg.isap[i].tcra = sng_isap->tcra; - } else { - g_ftdm_sngss7_data.cfg.isap[i].tcra = 100; - } - if (sng_isap->tect != 0) { - g_ftdm_sngss7_data.cfg.isap[i].tect = sng_isap->tect; - } else { - g_ftdm_sngss7_data.cfg.isap[i].tect = 10; - } - if (sng_isap->trelrsp != 0) { - g_ftdm_sngss7_data.cfg.isap[i].trelrsp = sng_isap->trelrsp; - } else { - g_ftdm_sngss7_data.cfg.isap[i].trelrsp = 10; - } - if (sng_isap->tfnlrelrsp != 0) { - g_ftdm_sngss7_data.cfg.isap[i].tfnlrelrsp = sng_isap->tfnlrelrsp; - } else { - g_ftdm_sngss7_data.cfg.isap[i].tfnlrelrsp = 10; - } - - return 0; -} - -/******************************************************************************/ -static int ftmod_ss7_fill_in_ccSpan(sng_ccSpan_t *ccSpan) -{ - sng_timeslot_t timeslot; - sngss7_chan_data_t *ss7_info = NULL; - int x; - int count = 1; - int flag; - - while (ccSpan->ch_map[0] != '\0') { - /**************************************************************************/ - - /* pull out the next timeslot */ - if (ftmod_ss7_next_timeslot(ccSpan->ch_map, ×lot)) { - SS7_ERROR("Failed to parse the channel map!\n"); - return FTDM_FAIL; - } - - /* find a spot for this circuit in the global structure */ - x = (ccSpan->procId * 1000) + 1; - flag = 0; - while (flag == 0) { - /**********************************************************************/ - /* check the id value ( 0 = new, 0 > circuit can be existing) */ - if (g_ftdm_sngss7_data.cfg.isupCkt[x].id == 0) { - /* we're at the end of the list of circuitsl aka this is new */ - SS7_DEBUG("Found a new circuit %d, ccSpanId=%d, chan=%d\n", - x, - ccSpan->id, - count); - - /* throw the flag to end the loop */ - flag = 1; - } else { - /* check the ccspan.id and chan to see if the circuit already exists */ - if ((g_ftdm_sngss7_data.cfg.isupCkt[x].ccSpanId == ccSpan->id) && - (g_ftdm_sngss7_data.cfg.isupCkt[x].chan == count)) { - - /* we are processing a circuit that already exists */ - SS7_DEVEL_DEBUG("Found an existing circuit %d, ccSpanId=%d, chan%d\n", - x, - ccSpan->id, - count); - - /* throw the flag to end the loop */ - flag = 1; - - /* not supporting reconfig at this time */ - SS7_DEVEL_DEBUG("Not supporting ckt reconfig at this time!\n"); - goto move_along; - } else { - /* this is not the droid you are looking for */ - x++; - } - } - /**********************************************************************/ - } /* while (flag == 0) */ - - /* prepare the global info sturcture */ - ss7_info = ftdm_calloc(1, sizeof(sngss7_chan_data_t)); - ss7_info->ftdmchan = NULL; - if (ftdm_queue_create(&ss7_info->event_queue, SNGSS7_CHAN_EVENT_QUEUE_SIZE) != FTDM_SUCCESS) { - SS7_CRITICAL("Failed to create ss7 cic event queue\n"); - } - ss7_info->circuit = &g_ftdm_sngss7_data.cfg.isupCkt[x]; - - g_ftdm_sngss7_data.cfg.isupCkt[x].obj = ss7_info; - - /* fill in the rest of the global structure */ - g_ftdm_sngss7_data.cfg.isupCkt[x].procId = ccSpan->procId; - g_ftdm_sngss7_data.cfg.isupCkt[x].id = x; - g_ftdm_sngss7_data.cfg.isupCkt[x].ccSpanId = ccSpan->id; - g_ftdm_sngss7_data.cfg.isupCkt[x].span = 0; - g_ftdm_sngss7_data.cfg.isupCkt[x].chan = count; - - if (timeslot.siglink) { - g_ftdm_sngss7_data.cfg.isupCkt[x].type = SNG_CKT_SIG; - } else if (timeslot.gap) { - g_ftdm_sngss7_data.cfg.isupCkt[x].type = SNG_CKT_HOLE; - } else { - g_ftdm_sngss7_data.cfg.isupCkt[x].type = SNG_CKT_VOICE; - - /* throw the flag to indicate that we need to start call control */ - sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_CC_PRESENT); - } - - if (timeslot.channel) { - g_ftdm_sngss7_data.cfg.isupCkt[x].cic = ccSpan->cicbase; - ccSpan->cicbase++; - } else { - g_ftdm_sngss7_data.cfg.isupCkt[x].cic = 0; - } - - g_ftdm_sngss7_data.cfg.isupCkt[x].infId = ccSpan->isupInf; - g_ftdm_sngss7_data.cfg.isupCkt[x].typeCntrl = ccSpan->typeCntrl; - g_ftdm_sngss7_data.cfg.isupCkt[x].ssf = ccSpan->ssf; - g_ftdm_sngss7_data.cfg.isupCkt[x].cld_nadi = ccSpan->cld_nadi; - g_ftdm_sngss7_data.cfg.isupCkt[x].clg_nadi = ccSpan->clg_nadi; - g_ftdm_sngss7_data.cfg.isupCkt[x].rdnis_nadi = ccSpan->rdnis_nadi; - g_ftdm_sngss7_data.cfg.isupCkt[x].loc_nadi = ccSpan->loc_nadi; - g_ftdm_sngss7_data.cfg.isupCkt[x].options = ccSpan->options; - g_ftdm_sngss7_data.cfg.isupCkt[x].switchType = ccSpan->switchType; - g_ftdm_sngss7_data.cfg.isupCkt[x].min_digits = ccSpan->min_digits; - g_ftdm_sngss7_data.cfg.isupCkt[x].itx_auto_reply = ccSpan->itx_auto_reply; - g_ftdm_sngss7_data.cfg.isupCkt[x].transparent_iam = ccSpan->transparent_iam; - g_ftdm_sngss7_data.cfg.isupCkt[x].transparent_iam_max_size = ccSpan->transparent_iam_max_size; - g_ftdm_sngss7_data.cfg.isupCkt[x].cpg_on_progress_media = ccSpan->cpg_on_progress_media; - g_ftdm_sngss7_data.cfg.isupCkt[x].cpg_on_progress = ccSpan->cpg_on_progress; - - if (ccSpan->t3 == 0) { - g_ftdm_sngss7_data.cfg.isupCkt[x].t3 = 1200; - } else { - g_ftdm_sngss7_data.cfg.isupCkt[x].t3 = ccSpan->t3; - } - if (ccSpan->t10 == 0) { - g_ftdm_sngss7_data.cfg.isupCkt[x].t10 = 50; - } else { - g_ftdm_sngss7_data.cfg.isupCkt[x].t10 = ccSpan->t10; - } - if (ccSpan->t12 == 0) { - g_ftdm_sngss7_data.cfg.isupCkt[x].t12 = 300; - } else { - g_ftdm_sngss7_data.cfg.isupCkt[x].t12 = ccSpan->t12; - } - if (ccSpan->t13 == 0) { - g_ftdm_sngss7_data.cfg.isupCkt[x].t13 = 3000; - } else { - g_ftdm_sngss7_data.cfg.isupCkt[x].t13 = ccSpan->t13; - } - if (ccSpan->t14 == 0) { - g_ftdm_sngss7_data.cfg.isupCkt[x].t14 = 300; - } else { - g_ftdm_sngss7_data.cfg.isupCkt[x].t14 = ccSpan->t14; - } - if (ccSpan->t15 == 0) { - g_ftdm_sngss7_data.cfg.isupCkt[x].t15 = 3000; - } else { - g_ftdm_sngss7_data.cfg.isupCkt[x].t15 = ccSpan->t15; - } - if (ccSpan->t16 == 0) { - g_ftdm_sngss7_data.cfg.isupCkt[x].t16 = 300; - } else { - g_ftdm_sngss7_data.cfg.isupCkt[x].t16 = ccSpan->t16; - } - if (ccSpan->t17 == 0) { - g_ftdm_sngss7_data.cfg.isupCkt[x].t17 = 3000; - } else { - g_ftdm_sngss7_data.cfg.isupCkt[x].t17 = ccSpan->t17; - } - if (ccSpan->t35 == 0) { - /* Q.764 2.2.5 Address incomplete (T35 is 15-20 seconds according to Table A.1/Q.764) */ - g_ftdm_sngss7_data.cfg.isupCkt[x].t35 = 170; - } else { - g_ftdm_sngss7_data.cfg.isupCkt[x].t35 = ccSpan->t35; - } - if (ccSpan->t39 == 0) { - g_ftdm_sngss7_data.cfg.isupCkt[x].t39 = 120; - } else { - g_ftdm_sngss7_data.cfg.isupCkt[x].t39 = ccSpan->t39; - } - - if (ccSpan->tval == 0) { - g_ftdm_sngss7_data.cfg.isupCkt[x].tval = 10; - } else { - g_ftdm_sngss7_data.cfg.isupCkt[x].tval = ccSpan->tval; - } - - SS7_INFO("Added procId=%d, spanId = %d, chan = %d, cic = %d, ISUP cirId = %d\n", - g_ftdm_sngss7_data.cfg.isupCkt[x].procId, - g_ftdm_sngss7_data.cfg.isupCkt[x].ccSpanId, - g_ftdm_sngss7_data.cfg.isupCkt[x].chan, - g_ftdm_sngss7_data.cfg.isupCkt[x].cic, - g_ftdm_sngss7_data.cfg.isupCkt[x].id); - -move_along: - /* increment the span channel count */ - count++; - - /**************************************************************************/ - } /* while (ccSpan->ch_map[0] != '\0') */ - - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static int ftmod_ss7_fill_in_circuits(sng_span_t *sngSpan) -{ - ftdm_channel_t *ftdmchan = NULL; - ftdm_span_t *ftdmspan = sngSpan->span; - sng_isup_ckt_t *isupCkt = NULL; - sngss7_chan_data_t *ss7_info = NULL; - int flag; - int i; - int x; - - /* go through all the channels on ftdm span */ - for (i = 1; i < (ftdmspan->chan_count+1); i++) { - /**************************************************************************/ - - /* extract the ftdmchan pointer */ - ftdmchan = ftdmspan->channels[i]; - - /* find the equivalent channel in the global structure */ - x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1; - flag = 0; - while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) { - /**********************************************************************/ - /* pull out the circuit to make it easier to work with */ - isupCkt = &g_ftdm_sngss7_data.cfg.isupCkt[x]; - - /* if the ccSpanId's match fill in the span value...this is for sigs - * because they will never have a channel that matches since they - * have a ftdmchan at this time */ - if (sngSpan->ccSpanId == isupCkt->ccSpanId) { - isupCkt->span = ftdmchan->physical_span_id; - } - - /* check if the ccSpanId matches and the physical channel # match */ - if ((sngSpan->ccSpanId == isupCkt->ccSpanId) && - (ftdmchan->physical_chan_id == isupCkt->chan)) { - - /* we've found the channel in the ckt structure...raise the flag */ - flag = 1; - - /* now get out of the loop */ - break; - } - - /* move to the next ckt */ - x++; - - /* check if we are outside of the range of possible indexes */ - if (x == ((g_ftdm_sngss7_data.cfg.procId + 1) * 1000)) { - break; - } - /**********************************************************************/ - } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) */ - - /* check we found the ckt or not */ - if (!flag) { - SS7_ERROR_CHAN(ftdmchan, "Failed to find this channel in the global ckts!%s\n",""); - return FTDM_FAIL; - } - - /* fill in the rest of the global sngss7_chan_data_t structure */ - ss7_info = (sngss7_chan_data_t *)isupCkt->obj; - ss7_info->ftdmchan = ftdmchan; - - /* attach the sngss7_chan_data_t to the freetdm channel structure */ - ftdmchan->call_data = ss7_info; - - /* prepare the timer structures */ - ss7_info->t35.sched = ((sngss7_span_data_t *)(ftdmspan->signal_data))->sched; - ss7_info->t35.counter = 1; - ss7_info->t35.beat = (isupCkt->t35) * 100; /* beat is in ms, t35 is in 100ms */ - ss7_info->t35.callback = handle_isup_t35; - ss7_info->t35.sngss7_info = ss7_info; - - ss7_info->t10.sched = ((sngss7_span_data_t *)(ftdmspan->signal_data))->sched; - ss7_info->t10.counter = 1; - ss7_info->t10.beat = (isupCkt->t10) * 100; /* beat is in ms, t10 is in 100ms */ - ss7_info->t10.callback = handle_isup_t10; - ss7_info->t10.sngss7_info = ss7_info; - - /* prepare the timer structures */ - ss7_info->t39.sched = ((sngss7_span_data_t *)(ftdmspan->signal_data))->sched; - ss7_info->t39.counter = 1; - ss7_info->t39.beat = (isupCkt->t39) * 100; /* beat is in ms, t39 is in 100ms */ - ss7_info->t39.callback = handle_isup_t39; - ss7_info->t39.sngss7_info = ss7_info; - - - /**************************************************************************/ - } /* for (i == 1; i < ftdmspan->chan_count; i++) */ - - return FTDM_SUCCESS; -} - -/******************************************************************************/ -static int ftmod_ss7_next_timeslot(char *ch_map, sng_timeslot_t *timeslot) -{ - int i; - int x; - int lower; - int upper; - char tmp[5]; /*KONRAD FIX ME*/ - char new_ch_map[MAX_CIC_MAP_LENGTH]; - - memset(&tmp[0], '\0', sizeof(tmp)); - memset(&new_ch_map[0], '\0', sizeof(new_ch_map)); - memset(timeslot, 0x0, sizeof(sng_timeslot_t)); - - SS7_DEVEL_DEBUG("Old channel map = \"%s\"\n", ch_map); - - /* start at the beginning of the ch_map */ - x = 0; - - switch (ch_map[x]) { - /**************************************************************************/ - case 'S': - case 's': /* we have a sig link */ - timeslot->siglink = 1; - - /* check what comes next either a comma or a number */ - x++; - if (ch_map[x] == ',') { - timeslot->hole = 1; - SS7_DEVEL_DEBUG(" Found a siglink in the channel map with a hole in the cic map\n"); - } else if (isdigit(ch_map[x])) { - /* consume all digits until a comma as this is the channel */ - SS7_DEVEL_DEBUG(" Found a siglink in the channel map with out a hole in the cic map\n"); - } else { - SS7_ERROR("Found an illegal channel map character after signal link flag = \"%c\"!\n", ch_map[x]); - return FTDM_FAIL; - } - break; - /**************************************************************************/ - case 'G': - case 'g': /* we have a channel gap */ - timeslot->gap = 1; - - /* check what comes next either a comma or a number */ - x++; - if (ch_map[x] == ',') { - timeslot->hole = 1; - SS7_DEVEL_DEBUG(" Found a gap in the channel map with a hole in the cic map\n"); - } else if (isdigit(ch_map[x])) { - SS7_DEVEL_DEBUG(" Found a gap in the channel map with out a hole in the cic map\n"); - /* consume all digits until a comma as this is the channel */ - } else { - SS7_ERROR("Found an illegal channel map character after signal link flag = \"%c\"!\n", ch_map[x]); - return FTDM_FAIL; - } - break; - /**************************************************************************/ - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': /* we have a channel */ - /* consume all digits until a comma or a dash */ - SS7_DEVEL_DEBUG("Found a starting channel in the channel map\n"); - break; - /**************************************************************************/ - default: - SS7_ERROR("Found an illegal channel map character = \"%c\"!\n", ch_map[x]); - return FTDM_FAIL; - /**************************************************************************/ - } /* switch (ch_map[x]) */ - - /* grab the first number in the string */ - i = 0; - while ((ch_map[x] != '\0') && (ch_map[x] != '-') && (ch_map[x] != ',')) { - tmp[i] = ch_map[x]; - i++; - x++; - } - tmp[i] = '\0'; - timeslot->channel = atoi(tmp); - lower = timeslot->channel + 1; - - /* check the next value in the list */ - if (ch_map[x] == '-') { - /* consume the number after the dash */ - x++; - i = 0; - while ((ch_map[x] != '\0') && (ch_map[x] != '-') && (ch_map[x] != ',')) { - tmp[i] = ch_map[x]; - i++; - x++; - } - tmp[i] = '\0'; - upper = atoi(tmp); - - /* check if the upper end of the range is the same as the lower end of the range */ - if (upper == lower) { - /* the range is completed, eat the next comma or \0 and write it */ - sprintf(new_ch_map, "%d", lower); - } else if ( upper > lower) { - /* the list continues, add 1 from the channel map value and re-insert it to the list */ - sprintf(new_ch_map, "%d-%d", lower, upper); - } else { - SS7_ERROR("The upper is less then the lower end of the range...should not happen!\n"); - return FTDM_FAIL; - } - - /* the the rest of ch_map to new_ch_map */ - strncat(new_ch_map, &ch_map[x], strlen(&ch_map[x])); - - - /* set the new cic map to ch_map*/ - memset(ch_map, '\0', sizeof(ch_map)); - strcpy(ch_map, new_ch_map); - - } else if (ch_map[x] == ',') { - /* move past the comma */ - x++; - - /* copy the rest of the list to new_ch_map */ - memset(new_ch_map, '\0', sizeof(new_ch_map)); - strcpy(new_ch_map, &ch_map[x]); - - /* copy the new_ch_map over the old one */ - memset(ch_map, '\0', sizeof(ch_map)); - strcpy(ch_map, new_ch_map); - - } else if (ch_map[x] == '\0') { - - /* we're at the end of the string...copy the rest of the list to new_ch_map */ - memset(new_ch_map, '\0', sizeof(new_ch_map)); - strcpy(new_ch_map, &ch_map[x]); - - /* set the new cic map to ch_map*/ - memset(ch_map, '\0', sizeof(ch_map)); - strcpy(ch_map, new_ch_map); - } else { - /* nothing to do */ - } - - SS7_DEVEL_DEBUG("New channel map = \"%s\"\n", ch_map); - - return FTDM_SUCCESS; -} - -/******************************************************************************/ - -/******************************************************************************/ -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ -/******************************************************************************/ diff --git a/libs/freetdm/src/ftmod/ftmod_skel/ftmod_skel.c b/libs/freetdm/src/ftmod/ftmod_skel/ftmod_skel.c deleted file mode 100644 index 7d8a9b7393..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_skel/ftmod_skel.c +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (c) 2007-2014, Anthony Minessale II - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -#include "private/ftdm_core.h" -//#include "ftdm_skel.h" - -static FIO_CONFIGURE_FUNCTION(skel_configure) -{ - ftdm_unused_arg(category); - ftdm_unused_arg(var); - ftdm_unused_arg(val); - ftdm_unused_arg(lineno); - return FTDM_FAIL; -} - -static FIO_CONFIGURE_SPAN_FUNCTION(skel_configure_span) -{ - ftdm_unused_arg(span); - ftdm_unused_arg(str); - ftdm_unused_arg(type); - ftdm_unused_arg(name); - ftdm_unused_arg(number); - return FTDM_FAIL; -} - -static FIO_OPEN_FUNCTION(skel_open) -{ - ftdm_unused_arg(ftdmchan); - return FTDM_FAIL; -} - -static FIO_CLOSE_FUNCTION(skel_close) -{ - ftdm_unused_arg(ftdmchan); - return FTDM_FAIL; -} - -static FIO_WAIT_FUNCTION(skel_wait) -{ - ftdm_unused_arg(ftdmchan); - ftdm_unused_arg(flags); - ftdm_unused_arg(to); - return FTDM_FAIL; -} - -static FIO_READ_FUNCTION(skel_read) -{ - ftdm_unused_arg(ftdmchan); - ftdm_unused_arg(data); - ftdm_unused_arg(datalen); - return FTDM_FAIL; -} - -static FIO_WRITE_FUNCTION(skel_write) -{ - ftdm_unused_arg(ftdmchan); - ftdm_unused_arg(data); - ftdm_unused_arg(datalen); - return FTDM_FAIL; -} - -static FIO_COMMAND_FUNCTION(skel_command) -{ - ftdm_unused_arg(ftdmchan); - ftdm_unused_arg(command); - ftdm_unused_arg(obj); - return FTDM_FAIL; -} - -static FIO_SPAN_POLL_EVENT_FUNCTION(skel_poll_event) -{ - ftdm_unused_arg(span); - ftdm_unused_arg(ms); - ftdm_unused_arg(poll_events); - return FTDM_FAIL; -} - -static FIO_SPAN_NEXT_EVENT_FUNCTION(skel_next_event) -{ - ftdm_unused_arg(span); - ftdm_unused_arg(event); - return FTDM_FAIL; -} - -static FIO_CHANNEL_DESTROY_FUNCTION(skel_channel_destroy) -{ - ftdm_unused_arg(ftdmchan); - return FTDM_FAIL; -} - -static FIO_SPAN_DESTROY_FUNCTION(skel_span_destroy) -{ - ftdm_unused_arg(span); - return FTDM_FAIL; -} - -static FIO_GET_ALARMS_FUNCTION(skel_get_alarms) -{ - ftdm_unused_arg(ftdmchan); - return FTDM_FAIL; -} - -static ftdm_io_interface_t skel_interface; - -static FIO_IO_LOAD_FUNCTION(skel_init) -{ - assert(fio != NULL); - memset(&skel_interface, 0, sizeof(skel_interface)); - - skel_interface.name = "skel"; - skel_interface.configure = skel_configure; - skel_interface.configure_span = skel_configure_span; - skel_interface.open = skel_open; - skel_interface.close = skel_close; - skel_interface.wait = skel_wait; - skel_interface.read = skel_read; - skel_interface.write = skel_write; - skel_interface.command = skel_command; - skel_interface.poll_event = skel_poll_event; - skel_interface.next_event = skel_next_event; - skel_interface.channel_destroy = skel_channel_destroy; - skel_interface.span_destroy = skel_span_destroy; - skel_interface.get_alarms = skel_get_alarms; - *fio = &skel_interface; - - return FTDM_SUCCESS; -} - -static FIO_IO_UNLOAD_FUNCTION(skel_destroy) -{ - return FTDM_SUCCESS; -} - - -ftdm_module_t ftdm_module = { - "skel", - skel_init, - skel_destroy, -}; - - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ - diff --git a/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.2008.vcproj b/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.2008.vcproj deleted file mode 100644 index 7fdb0ff592..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.2008.vcproj +++ /dev/null @@ -1,355 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.2010.vcxproj.filters b/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.2010.vcxproj.filters deleted file mode 100644 index 15a8bc3d35..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.2010.vcxproj.filters +++ /dev/null @@ -1,18 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - - - Source Files - - - \ No newline at end of file diff --git a/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c b/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c deleted file mode 100755 index 58b5c9ca0e..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c +++ /dev/null @@ -1,1807 +0,0 @@ -/* - * Copyright (c) 2007-2014, Anthony Minessale II - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Contributors: - * - * Moises Silva - * David Yat Sin - * Nenad Corbic - * Arnaldo Pereira - * Gideon Sadan - * - */ -#ifdef WP_DEBUG_IO -#ifndef _DEFAULT_SOURCE -#define _DEFAULT_SOURCE -#endif -#define _BSD_SOURCE -#include -#endif - -#ifdef __sun -#include -#include -#endif -#include "private/ftdm_core.h" -#ifndef __WINDOWS__ -#include -#include -#endif -#include "libsangoma.h" - -#if defined(__WINDOWS__) -/*! Backward compatible defines - current code is all using the old names*/ -#define sangoma_open_tdmapi_span_chan sangoma_open_api_span_chan -#define sangoma_open_tdmapi_span sangoma_open_api_span -#define sangoma_open_tdmapi_ctrl sangoma_open_api_ctrl -#define sangoma_tdm_get_fe_status sangoma_get_fe_status -#define sangoma_socket_close sangoma_close -#define sangoma_tdm_get_hw_coding sangoma_get_hw_coding -#define sangoma_tdm_set_fe_status sangoma_set_fe_status -#define sangoma_tdm_get_link_status sangoma_get_link_status -#define sangoma_tdm_flush_bufs sangoma_flush_bufs -#define sangoma_tdm_cmd_exec sangoma_cmd_exec -#define sangoma_tdm_read_event sangoma_read_event -#define sangoma_readmsg_tdm sangoma_readmsg -#define sangoma_readmsg_socket sangoma_readmsg -#define sangoma_sendmsg_socket sangoma_writemsg -#define sangoma_writemsg_tdm sangoma_writemsg -#define sangoma_create_socket_intr sangoma_open_api_span_chan -#endif - -/*! Starting with libsangoma 3 we can use the new libsangoma waitable API, the poor souls of those using a release where LIBSANGOMA version - * is defined but the version is not higher or equal to 3.0.0 will be forced to upgrade - * */ -#ifdef LIBSANGOMA_VERSION -#if LIBSANGOMA_VERSION_CODE < LIBSANGOMA_VERSION(3,0,0) -#undef LIBSANGOMA_VERSION -#endif -#endif - -/** - * \brief Wanpipe flags - */ -typedef enum { - WP_RINGING = (1 << 0) -} wp_flag_t; - -/** - * \brief Wanpipe globals - */ -static struct { - uint32_t codec_ms; - uint32_t rxqueue_size; - uint32_t txqueue_size; - uint32_t wink_ms; - uint32_t flash_ms; - uint32_t ring_on_ms; - uint32_t ring_off_ms; -} wp_globals; - -typedef struct { - sangoma_wait_obj_t *waitobj; -#ifdef WP_DEBUG_IO - /* record the last reader threads */ - pid_t readers[10]; - int rindex; - ftdm_time_t last_read; -#endif -} wp_channel_t; -#define WP_GET_WAITABLE(fchan) ((wp_channel_t *)((fchan)->io_data))->waitobj - -/* a bunch of this stuff should go into the wanpipe_tdm_api_iface.h */ - -FIO_SPAN_POLL_EVENT_FUNCTION(wanpipe_poll_event); -FIO_SPAN_NEXT_EVENT_FUNCTION(wanpipe_span_next_event); -FIO_CHANNEL_NEXT_EVENT_FUNCTION(wanpipe_channel_next_event); - -static void wp_swap16(char *data, int datalen) -{ - int i = 0; - uint16_t *samples = (uint16_t *)data; - for (i = 0; i < datalen/2; i++) { - uint16_t sample = ((samples[i] & 0x00FF) << 8) | ((samples[i] & 0xFF00) >> 8); - samples[i] = sample; - } -} - -/** - * \brief Poll for event on a wanpipe socket - * \param fd Wanpipe socket descriptor - * \param timeout Time to wait for event - * \param flags Sangoma event flags - * \return -1 on failure, wanpipe event flags on success - * - * a cross platform way to poll on an actual pollset (span and/or list of spans) will probably also be needed for analog - * so we can have one analong handler thread that will deal with all the idle analog channels for events - * the alternative would be for the driver to provide one socket for all of the oob events for all analog channels - */ -static __inline__ int tdmv_api_wait_socket(ftdm_channel_t *ftdmchan, int timeout, int *flags) -{ - -#ifdef LIBSANGOMA_VERSION - int err; - uint32_t inflags = *flags; - uint32_t outflags = 0; - sangoma_wait_obj_t *sangoma_wait_obj = WP_GET_WAITABLE(ftdmchan); - - if (timeout == -1) { - timeout = SANGOMA_WAIT_INFINITE; - } - - err = sangoma_waitfor(sangoma_wait_obj, inflags, &outflags, timeout); - *flags = 0; - if (err == SANG_STATUS_SUCCESS) { - *flags = outflags; - err = 1; /* ideally should be the number of file descriptors with something to read */ - } - if (err == SANG_STATUS_APIPOLL_TIMEOUT) { - err = 0; - } - return err; -#else - struct pollfd pfds[1]; - int res; - - memset(&pfds[0], 0, sizeof(pfds[0])); - pfds[0].fd = ftdmchan->sockfd; - pfds[0].events = *flags; - res = poll(pfds, 1, timeout); - *flags = 0; - - if (pfds[0].revents & POLLERR) { - res = -1; - } - - if (res > 0) { - *flags = pfds[0].revents; - } - - return res; -#endif - -} - -/** - * \brief Opens a sangoma channel socket (TDM API) - * \param span Span number - * \param chan Channel number - * \return 0 on success, wanpipe error code on failure - */ -static __inline__ sng_fd_t tdmv_api_open_span_chan(int span, int chan) -{ - return sangoma_open_tdmapi_span_chan(span, chan); -} - -#ifdef LIBSANGOMA_VERSION -static __inline__ sng_fd_t __tdmv_api_open_span_chan(int span, int chan) -{ - return __sangoma_open_tdmapi_span_chan(span, chan); -} -#endif - -static ftdm_io_interface_t wanpipe_interface; - -/** - * \brief Inverts bit string - * \param cas_bits CAS bit string - * \return Swapped bits - */ -static unsigned char wanpipe_swap_bits(unsigned char cas_bits) -{ - unsigned char swapped_bits = 0x0; - if (cas_bits & 0x8) { - swapped_bits |= 0x1; - } - if (cas_bits & 0x4) { - swapped_bits |= 0x2; - } - if (cas_bits & 0x2) { - swapped_bits |= 0x4; - } - if (cas_bits & 0x1) { - swapped_bits |= 0x8; - } - return swapped_bits; -} - -/** - * \brief Initialises a range of wanpipe channels - * \param span FreeTDM span - * \param spanno Wanpipe span number - * \param start Initial wanpipe channel number - * \param end Final wanpipe channel number - * \param type FreeTDM channel type - * \param name FreeTDM span name - * \param number FreeTDM span number - * \param cas_bits CAS bits - * \return number of spans configured - */ -static unsigned wp_open_range(ftdm_span_t *span, unsigned spanno, unsigned start, unsigned end, ftdm_chan_type_t type, char *name, char *number, unsigned char cas_bits) -{ - unsigned configured = 0, x; -#ifdef LIBSANGOMA_VERSION - sangoma_status_t sangstatus; - sangoma_wait_obj_t *sangoma_wait_obj; -#endif - - if (type == FTDM_CHAN_TYPE_CAS) { - ftdm_log(FTDM_LOG_DEBUG, "Configuring Wanpipe CAS channels with abcd == 0x%X\n", cas_bits); - } - for(x = start; x < end; x++) { - ftdm_channel_t *chan; - ftdm_socket_t sockfd = FTDM_INVALID_SOCKET; - const char *dtmf = "none"; - const char *hwec_str = "none"; - const char *hwec_idle = "none"; - if (!strncasecmp(span->name, "smg_prid_nfas", 8) && span->trunk_type == FTDM_TRUNK_T1 && x == 24) { -#ifdef LIBSANGOMA_VERSION - sockfd = __tdmv_api_open_span_chan(spanno, x); -#else - ftdm_log(FTDM_LOG_ERROR, "span %d channel %d cannot be configured as smg_prid_nfas, you need to compile freetdm with newer libsangoma\n", spanno, x); -#endif - } else { -#ifdef LIBSANGOMA_VERSION - sockfd = __tdmv_api_open_span_chan(spanno, x); -#else - sockfd = tdmv_api_open_span_chan(spanno, x); -#endif - } - - if (sockfd == FTDM_INVALID_SOCKET) { - ftdm_log(FTDM_LOG_ERROR, "Failed to open wanpipe device span %d channel %d\n", spanno, x); - continue; - } - - if (ftdm_span_add_channel(span, sockfd, type, &chan) == FTDM_SUCCESS) { - wp_channel_t *wpchan = NULL; - wanpipe_tdm_api_t tdm_api; - memset(&tdm_api, 0, sizeof(tdm_api)); -#ifdef LIBSANGOMA_VERSION - wpchan = ftdm_calloc(1, sizeof(*wpchan)); - ftdm_assert(wpchan != NULL, "wpchan alloc failed\n"); - chan->io_data = wpchan; - /* we need SANGOMA_DEVICE_WAIT_OBJ_SIG and not SANGOMA_DEVICE_WAIT_OBJ alone because we need to call - * sangoma_wait_obj_sig to wake up any I/O waiters when closing the channel (typically on ftdm shutdown) - * this adds an extra pair of file descriptors to the waitable object - * */ - sangstatus = sangoma_wait_obj_create(&sangoma_wait_obj, sockfd, SANGOMA_DEVICE_WAIT_OBJ_SIG); - if (sangstatus != SANG_STATUS_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "failure create waitable object for s%dc%d\n", spanno, x); - continue; - } - WP_GET_WAITABLE(chan) = sangoma_wait_obj; -#endif - - chan->physical_span_id = spanno; - chan->physical_chan_id = x; - chan->rate = 8000; - - if (type == FTDM_CHAN_TYPE_FXS - || type == FTDM_CHAN_TYPE_FXO - || type == FTDM_CHAN_TYPE_CAS - || type == FTDM_CHAN_TYPE_B) { - int err; - - hwec_str = "unavailable"; - hwec_idle = "enabled"; - dtmf = "software"; - - err = sangoma_tdm_get_hw_coding(chan->sockfd, &tdm_api); - - - - if (tdm_api.wp_tdm_cmd.hw_tdm_coding) { - chan->native_codec = chan->effective_codec = FTDM_CODEC_ALAW; - } else { - chan->native_codec = chan->effective_codec = FTDM_CODEC_ULAW; - } - - - if ((span->trunk_type == FTDM_TRUNK_GSM) && (chan->type == FTDM_CHAN_TYPE_B)) { - chan->native_codec = FTDM_CODEC_SLIN; - chan->native_interval = 20; - chan->packet_len = 320; - } - - err = sangoma_tdm_get_hw_dtmf(chan->sockfd, &tdm_api); - if (err > 0) { - ftdm_channel_set_feature(chan, FTDM_CHANNEL_FEATURE_DTMF_DETECT); - dtmf = "hardware"; - } - - err = sangoma_tdm_get_hw_ec(chan->sockfd, &tdm_api); - if (err > 0) { - hwec_str = "available"; - ftdm_channel_set_feature(chan, FTDM_CHANNEL_FEATURE_HWEC); - } - -#ifdef WP_API_FEATURE_HWEC_PERSIST - err = sangoma_tdm_get_hwec_persist_status(chan->sockfd, &tdm_api); - if (err == 0) { - ftdm_channel_set_feature(chan, FTDM_CHANNEL_FEATURE_HWEC_DISABLED_ON_IDLE); - hwec_idle = "disabled"; - } -#else - if (span->trunk_type == FTDM_TRUNK_BRI || span->trunk_type == FTDM_TRUNK_BRI_PTMP) { - ftdm_log(FTDM_LOG_WARNING, "WP_API_FEATURE_HWEC_PERSIST feature is not supported \ - with your version of libsangoma, you should update your Wanpipe drivers\n"); - - } -#endif - - } - -#ifdef LIBSANGOMA_VERSION - if (type == FTDM_CHAN_TYPE_FXS) { - if (sangoma_tdm_disable_ring_trip_detect_events(chan->sockfd, &tdm_api)) { - /* we had problems of on-hook/off-hook detection due to how ring trip events were handled - * if this fails, I believe we will still work ok as long as we dont handle them incorrectly */ - ftdm_log(FTDM_LOG_WARNING, "Failed to disable ring trip events in channel s%dc%d\n", spanno, x); - } - } -#endif -#if 0 - if (type == FTDM_CHAN_TYPE_FXS || type == FTDM_CHAN_TYPE_FXO) { - /* Enable FLASH/Wink Events */ - int err=sangoma_set_rm_rxflashtime(chan->sockfd, &tdm_api, wp_globals.flash_ms); - if (err == 0) { - ftdm_log(FTDM_LOG_ERROR, "flash enabled s%dc%d\n", spanno, x); - } else { - ftdm_log(FTDM_LOG_ERROR, "flash disabled s%dc%d\n", spanno, x); - } - } -#endif - - if (type == FTDM_CHAN_TYPE_CAS || type == FTDM_CHAN_TYPE_EM) { -#ifdef LIBSANGOMA_VERSION - sangoma_tdm_write_rbs(chan->sockfd,&tdm_api,chan->physical_chan_id, wanpipe_swap_bits(cas_bits)); - - /* this should probably be done for old libsangoma but I am not sure if the API is available and I'm lazy to check, - The poll rate is hard coded to 100 per second (done in the driver, is the max rate of polling allowed by wanpipe) - */ - if (sangoma_tdm_enable_rbs_events(chan->sockfd, &tdm_api, 100)) { - ftdm_log(FTDM_LOG_ERROR, "Failed to enable RBS/CAS events in device %d:%d fd:%d\n", chan->span_id, chan->chan_id, sockfd); - continue; - } - sangoma_flush_bufs(chan->sockfd, &tdm_api); - sangoma_flush_event_bufs(chan->sockfd, &tdm_api); -#else - /* - * With wanpipe 3.4.4.2 I get failure even though the events are enabled, /var/log/messages said: - * wanpipe4: WARNING: Event type 9 is already pending! - * wanpipe4: Failed to add new fe event 09 ch_map=FFFFFFFF! - * may be we should not send an error until that is fixed in the driver - */ - if (sangoma_tdm_enable_rbs_events(chan->sockfd, &tdm_api, 100)) { - ftdm_log(FTDM_LOG_ERROR, "Failed to enable RBS/CAS events in device %d:%d fd:%d\n", chan->span_id, chan->chan_id, sockfd); - } - /* probably done by the driver but lets write defensive code this time */ - sangoma_tdm_flush_bufs(chan->sockfd, &tdm_api); - sangoma_tdm_write_rbs(chan->sockfd,&tdm_api, wanpipe_swap_bits(cas_bits)); -#endif - } - - if (!ftdm_strlen_zero(name)) { - ftdm_copy_string(chan->chan_name, name, sizeof(chan->chan_name)); - } - - if (!ftdm_strlen_zero(number)) { - ftdm_copy_string(chan->chan_number, number, sizeof(chan->chan_number)); - } - configured++; - ftdm_log_chan(chan, FTDM_LOG_INFO, "Configured wanpipe device FD: %d, DTMF: %s, HWEC: %s, HWEC_IDLE: %s\n", - sockfd, dtmf, hwec_str, hwec_idle); - - } else { - ftdm_log(FTDM_LOG_ERROR, "ftdm_span_add_channel failed for wanpipe span %d channel %d\n", spanno, x); - } - } - - return configured; -} - -/** - * \brief Process configuration variable for a Wanpipe profile - * \param category Wanpipe profile name - * \param var Variable name - * \param val Variable value - * \param lineno Line number from configuration file - * \return Success - */ -static FIO_CONFIGURE_FUNCTION(wanpipe_configure) -{ - int num; - - if (!strcasecmp(category, "defaults")) { - if (!strcasecmp(var, "codec_ms")) { - num = atoi(val); - if (num < 10 || num > 60) { - ftdm_log(FTDM_LOG_WARNING, "invalid codec ms at line %d\n", lineno); - } else { - wp_globals.codec_ms = num; - } - } else if (!strcasecmp(var, "rxqueue_size")) { - num = atoi(val); - if (num < 1 || num > 1000) { - ftdm_log(FTDM_LOG_WARNING, "invalid rx queue size at line %d\n", lineno); - } else { - wp_globals.rxqueue_size = num; - } - } else if (!strcasecmp(var, "txqueue_size")) { - num = atoi(val); - if (num < 1 || num > 1000) { - ftdm_log(FTDM_LOG_WARNING, "invalid tx queue size at line %d\n", lineno); - } else { - wp_globals.txqueue_size = num; - } - } else if (!strcasecmp(var, "wink_ms")) { - num = atoi(val); - if (num < 50 || num > 3000) { - ftdm_log(FTDM_LOG_WARNING, "invalid wink ms at line %d\n", lineno); - } else { - wp_globals.wink_ms = num; - } - } else if (!strcasecmp(var, "flash_ms")) { - num = atoi(val); - if (num < 50 || num > 3000) { - ftdm_log(FTDM_LOG_WARNING, "invalid flash ms at line %d\n", lineno); - } else { - wp_globals.flash_ms = num; - } - } else if (!strcasecmp(var, "ring_on_ms")) { - num = atoi(val); - if (num < 500 || num > 5000) { - ftdm_log(FTDM_LOG_WARNING, "invalid ring_on_ms at line %d (valid range 500 to 5000)\n", lineno); - } else { - wp_globals.ring_on_ms = num; - } - } else if (!strcasecmp(var, "ring_off_ms")) { - num = atoi(val); - if (num < 500 || num > 5000) { - ftdm_log(FTDM_LOG_WARNING, "invalid ring_off_ms at line %d (valid range 500 to 5000)\n", lineno); - } else { - wp_globals.ring_off_ms = num; - } - } - - } - - return FTDM_SUCCESS; -} - -/** - * \brief Initialises an freetdm Wanpipe span from a configuration string - * \param span FreeTDM span - * \param str Configuration string - * \param type FreeTDM span type - * \param name FreeTDM span name - * \param number FreeTDM span number - * \return Success or failure - */ -static FIO_CONFIGURE_SPAN_FUNCTION(wanpipe_configure_span) -{ - int items, i; - char *mydata, *item_list[10]; - char *sp, *ch, *mx; - unsigned char cas_bits = 0; - int channo; - int spanno; - int top = 0; - unsigned configured = 0; - - assert(str != NULL); - - - mydata = ftdm_strdup(str); - assert(mydata != NULL); - - - items = ftdm_separate_string(mydata, ',', item_list, (sizeof(item_list) / sizeof(item_list[0]))); - - for(i = 0; i < items; i++) { - sp = item_list[i]; - if ((ch = strchr(sp, ':'))) { - *ch++ = '\0'; - } - - if (!(sp && ch)) { - ftdm_log(FTDM_LOG_ERROR, "No valid wanpipe span and channel was specified\n"); - continue; - } - - channo = atoi(ch); - spanno = atoi(sp); - - if (channo < 0) { - ftdm_log(FTDM_LOG_ERROR, "Invalid channel number %d\n", channo); - continue; - } - - if (spanno < 0) { - ftdm_log(FTDM_LOG_ERROR, "Invalid span number %d\n", channo); - continue; - } - - if ((mx = strchr(ch, '-'))) { - mx++; - top = atoi(mx) + 1; - } else { - top = channo + 1; - } - - - if (top < 0) { - ftdm_log(FTDM_LOG_ERROR, "Invalid range number %d\n", top); - continue; - } - if (FTDM_CHAN_TYPE_CAS == type && ftdm_config_get_cas_bits(ch, &cas_bits)) { - ftdm_log(FTDM_LOG_ERROR, "Failed to get CAS bits in CAS channel\n"); - continue; - } - configured += wp_open_range(span, spanno, channo, top, type, name, number, cas_bits); - - } - - ftdm_safe_free(mydata); - - return configured; -} - -/** - * \brief Opens Wanpipe channel - * \param ftdmchan Channel to open - * \return Success or failure - */ -static FIO_OPEN_FUNCTION(wanpipe_open) -{ - - wanpipe_tdm_api_t tdm_api; - - memset(&tdm_api,0,sizeof(tdm_api)); - - sangoma_tdm_flush_bufs(ftdmchan->sockfd, &tdm_api); - sangoma_flush_stats(ftdmchan->sockfd, &tdm_api); - memset(&ftdmchan->iostats, 0, sizeof(ftdmchan->iostats)); - - if (ftdmchan->type == FTDM_CHAN_TYPE_DQ921 || ftdmchan->type == FTDM_CHAN_TYPE_DQ931) { - ftdmchan->native_codec = ftdmchan->effective_codec = FTDM_CODEC_NONE; - } else { - ftdmchan->effective_codec = ftdmchan->native_codec; - - sangoma_tdm_set_usr_period(ftdmchan->sockfd, &tdm_api, wp_globals.codec_ms); - - ftdm_channel_set_feature(ftdmchan, FTDM_CHANNEL_FEATURE_INTERVAL); - ftdmchan->effective_interval = ftdmchan->native_interval = wp_globals.codec_ms; - - /* The packet len will depend on the codec and interval */ - ftdmchan->packet_len = ftdmchan->native_interval * ((ftdmchan->native_codec==FTDM_CODEC_SLIN) ? 16 : 8); - if (wp_globals.txqueue_size > 0) { - ftdm_channel_command(ftdmchan, FTDM_COMMAND_SET_TX_QUEUE_SIZE, &wp_globals.txqueue_size); - } - if (wp_globals.rxqueue_size > 0) { - ftdm_channel_command(ftdmchan, FTDM_COMMAND_SET_RX_QUEUE_SIZE, &wp_globals.rxqueue_size); - } - } - - return FTDM_SUCCESS; -} - -/** - * \brief Closes Wanpipe channel - * \param ftdmchan Channel to close - * \return Success - */ -static FIO_CLOSE_FUNCTION(wanpipe_close) -{ -#ifdef LIBSANGOMA_VERSION - sangoma_wait_obj_t *waitobj = WP_GET_WAITABLE(ftdmchan); - /* kick any I/O waiters */ - sangoma_wait_obj_signal(waitobj); -#ifdef WP_DEBUG_IO - { - wp_channel_t *wchan = ftdmchan->io_data; - memset(wchan->readers, 0, sizeof(wchan->readers)); - wchan->rindex = 0; - } -#endif -#endif - return FTDM_SUCCESS; -} - -/** - * \brief Executes an FreeTDM command on a Wanpipe channel - * \param ftdmchan Channel to execute command on - * \param command FreeTDM command to execute - * \param obj Object (unused) - * \return Success or failure - */ -static FIO_COMMAND_FUNCTION(wanpipe_command) -{ - wanpipe_tdm_api_t tdm_api; - int err = 0; - - memset(&tdm_api, 0, sizeof(tdm_api)); - - switch(command) { - case FTDM_COMMAND_OFFHOOK: - { - err=sangoma_tdm_txsig_offhook(ftdmchan->sockfd,&tdm_api); - if (err) { - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "OFFHOOK Failed"); - return FTDM_FAIL; - } - ftdm_set_flag_locked(ftdmchan, FTDM_CHANNEL_OFFHOOK); - } - break; - case FTDM_COMMAND_ONHOOK: - { - err=sangoma_tdm_txsig_onhook(ftdmchan->sockfd,&tdm_api); - if (err) { - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "ONHOOK Failed"); - return FTDM_FAIL; - } - ftdm_clear_flag_locked(ftdmchan, FTDM_CHANNEL_OFFHOOK); - } - break; - case FTDM_COMMAND_GENERATE_RING_ON: - { - err=sangoma_tdm_txsig_start(ftdmchan->sockfd,&tdm_api); - if (err) { - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "Ring Failed"); - return FTDM_FAIL; - } - ftdm_set_flag_locked(ftdmchan, FTDM_CHANNEL_RINGING); - ftdm_set_pflag_locked(ftdmchan, WP_RINGING); - ftdmchan->ring_time = ftdm_current_time_in_ms() + wp_globals.ring_on_ms; - } - break; - case FTDM_COMMAND_GENERATE_RING_OFF: - { - err=sangoma_tdm_txsig_offhook(ftdmchan->sockfd,&tdm_api); - if (err) { - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "Ring-off Failed"); - return FTDM_FAIL; - } - ftdm_clear_pflag_locked(ftdmchan, WP_RINGING); - ftdm_clear_flag_locked(ftdmchan, FTDM_CHANNEL_RINGING); - } - break; - case FTDM_COMMAND_GET_INTERVAL: - { - err=sangoma_tdm_get_usr_period(ftdmchan->sockfd, &tdm_api); - if (err > 0 ) { - FTDM_COMMAND_OBJ_INT = err; - err=0; - } - } - break; - case FTDM_COMMAND_ENABLE_ECHOCANCEL: - { -#ifdef WP_API_FEATURE_EC_CHAN_STAT - err=sangoma_tdm_get_hwec_chan_status(ftdmchan->sockfd, &tdm_api); - if (err > 0) { - /* Hardware echo canceller already enabled */ - err = 0; - break; - } -#endif - err=sangoma_tdm_enable_hwec(ftdmchan->sockfd, &tdm_api); - if (err) { - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "HWEC Enable Failed"); - return FTDM_FAIL; - } - } - break; - case FTDM_COMMAND_DISABLE_ECHOCANCEL: - { -#ifdef WP_API_FEATURE_EC_CHAN_STAT - err=sangoma_tdm_get_hwec_chan_status(ftdmchan->sockfd, &tdm_api); - if (!err) { - /* Hardware echo canceller already disabled */ - break; - } -#endif - err=sangoma_tdm_disable_hwec(ftdmchan->sockfd, &tdm_api); - if (err) { - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "HWEC Disable Failed"); - return FTDM_FAIL; - } - } - break; - case FTDM_COMMAND_DISABLE_ECHOTRAIN: { err = 0; } - break; - case FTDM_COMMAND_ENABLE_DTMF_DETECT: - { -#ifdef WP_API_FEATURE_DTMF_EVENTS - err = sangoma_tdm_enable_dtmf_events(ftdmchan->sockfd, &tdm_api); - if (err) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "Enabling of Sangoma HW DTMF failed\n"); - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "HW DTMF Enable Failed"); - return FTDM_FAIL; - } - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Enabled DTMF events\n"); -#else - return FTDM_NOTIMPL; -#endif - } - break; - case FTDM_COMMAND_DISABLE_DTMF_DETECT: - { -#ifdef WP_API_FEATURE_DTMF_EVENTS - err = sangoma_tdm_disable_dtmf_events(ftdmchan->sockfd, &tdm_api); - if (err) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "Disabling of Sangoma HW DTMF failed\n"); - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "HW DTMF Disable Failed"); - return FTDM_FAIL; - } - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Disabled DTMF events\n"); -#else - return FTDM_NOTIMPL; -#endif - } - break; - case FTDM_COMMAND_ENABLE_DTMF_REMOVAL: - { -#ifdef WP_API_FEATURE_DTMF_REMOVAL - int return_code = 0; - err = sangoma_hwec_set_hwdtmf_removal(ftdmchan->sockfd, ftdmchan->physical_chan_id, &return_code, 1, 0); - if (return_code) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "Wanpipe failed to Enable HW-DTMF removal\n"); - } -#endif - } - break; - case FTDM_COMMAND_DISABLE_DTMF_REMOVAL: - { -#ifdef WP_API_FEATURE_DTMF_REMOVAL - int return_code = 0; - err = sangoma_hwec_set_hwdtmf_removal(ftdmchan->sockfd, ftdmchan->physical_chan_id, &return_code, 0, 0); - if (return_code) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "Wanpipe failed to Disable HW-DTMF removal\n"); - } -#endif - } - break; - case FTDM_COMMAND_ENABLE_LOOP: - { -#ifdef WP_API_FEATURE_LOOP - err=sangoma_tdm_enable_loop(ftdmchan->sockfd, &tdm_api); - if (err) { - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "Loop Enable Failed"); - return FTDM_FAIL; - } -#endif - } - break; - case FTDM_COMMAND_DISABLE_LOOP: - { -#ifdef WP_API_FEATURE_LOOP - err=sangoma_tdm_disable_loop(ftdmchan->sockfd, &tdm_api); - if (err) { - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "Loop Disable Failed"); - return FTDM_FAIL; - } -#endif - } - break; - case FTDM_COMMAND_SET_INTERVAL: - { - err=sangoma_tdm_set_usr_period(ftdmchan->sockfd, &tdm_api, FTDM_COMMAND_OBJ_INT); - - ftdmchan->packet_len = ftdmchan->native_interval * (ftdmchan->effective_codec == FTDM_CODEC_SLIN ? 16 : 8); - } - break; - case FTDM_COMMAND_SET_CAS_BITS: - { -#ifdef LIBSANGOMA_VERSION - err = sangoma_tdm_write_rbs(ftdmchan->sockfd,&tdm_api, ftdmchan->physical_chan_id, wanpipe_swap_bits(FTDM_COMMAND_OBJ_INT)); -#else - err = sangoma_tdm_write_rbs(ftdmchan->sockfd, &tdm_api, wanpipe_swap_bits(FTDM_COMMAND_OBJ_INT)); -#endif - } - break; - case FTDM_COMMAND_GET_CAS_BITS: - { -#ifdef LIBSANGOMA_VERSION - unsigned char rbsbits; - err = sangoma_tdm_read_rbs(ftdmchan->sockfd, &tdm_api, ftdmchan->physical_chan_id, &rbsbits); - if (!err) { - FTDM_COMMAND_OBJ_INT = wanpipe_swap_bits(rbsbits); - } -#else - /* is sangoma_tdm_read_rbs available here? */ - FTDM_COMMAND_OBJ_INT = ftdmchan->rx_cas_bits; -#endif - } - break; - case FTDM_COMMAND_SET_LINK_STATUS: - { - ftdm_channel_hw_link_status_t status = FTDM_COMMAND_OBJ_INT; - char sangoma_status = status == FTDM_HW_LINK_CONNECTED ? FE_CONNECTED : FE_DISCONNECTED; - err = sangoma_tdm_set_fe_status(ftdmchan->sockfd, &tdm_api, sangoma_status); - } - break; - case FTDM_COMMAND_GET_LINK_STATUS: - { - unsigned char sangoma_status = 0; - err = sangoma_tdm_get_fe_status(ftdmchan->sockfd, &tdm_api, &sangoma_status); - if (!err) { - FTDM_COMMAND_OBJ_INT = sangoma_status == FE_CONNECTED ? FTDM_HW_LINK_CONNECTED : FTDM_HW_LINK_DISCONNECTED; - } - } - break; - case FTDM_COMMAND_FLUSH_BUFFERS: - { - err = sangoma_flush_bufs(ftdmchan->sockfd, &tdm_api); - } - break; - case FTDM_COMMAND_FLUSH_RX_BUFFERS: - { - err = sangoma_flush_rx_bufs(ftdmchan->sockfd, &tdm_api); - } - break; - case FTDM_COMMAND_FLUSH_TX_BUFFERS: - { - err = sangoma_flush_tx_bufs(ftdmchan->sockfd, &tdm_api); - } - break; - case FTDM_COMMAND_FLUSH_IOSTATS: - { - err = sangoma_flush_stats(ftdmchan->sockfd, &tdm_api); - memset(&ftdmchan->iostats, 0, sizeof(ftdmchan->iostats)); - } - break; - case FTDM_COMMAND_SET_RX_QUEUE_SIZE: - { - uint32_t queue_size = FTDM_COMMAND_OBJ_INT; - err = sangoma_set_rx_queue_sz(ftdmchan->sockfd, &tdm_api, queue_size); - } - break; - case FTDM_COMMAND_SET_TX_QUEUE_SIZE: - { - uint32_t queue_size = FTDM_COMMAND_OBJ_INT; - err = sangoma_set_tx_queue_sz(ftdmchan->sockfd, &tdm_api, queue_size); - } - break; - case FTDM_COMMAND_SET_POLARITY: - { - ftdm_polarity_t polarity = FTDM_COMMAND_OBJ_INT; - err = sangoma_tdm_set_polarity(ftdmchan->sockfd, &tdm_api, polarity); - if (!err) { - ftdmchan->polarity = polarity; - } - } - break; - default: - err = FTDM_NOTIMPL; - break; - }; - - if (err) { - int myerrno = errno; - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Wanpipe failed to execute command %d: %s\n", command, strerror(myerrno)); - errno = myerrno; - return err; - } - - return FTDM_SUCCESS; -} - -static void wanpipe_write_stats(ftdm_channel_t *ftdmchan, wp_tdm_api_tx_hdr_t *tx_stats) -{ - ftdmchan->iostats.tx.errors = tx_stats->wp_api_tx_hdr_errors; - ftdmchan->iostats.tx.queue_size = tx_stats->wp_api_tx_hdr_max_queue_length; - ftdmchan->iostats.tx.queue_len = tx_stats->wp_api_tx_hdr_number_of_frames_in_queue; - - /* we don't test for 80% full in tx since is typically full for voice channels, should we test tx 80% full for D-channels? */ - if (ftdmchan->iostats.tx.queue_len >= ftdmchan->iostats.tx.queue_size) { - ftdm_set_flag(&(ftdmchan->iostats.tx), FTDM_IOSTATS_ERROR_QUEUE_FULL); - } else if (ftdm_test_flag(&(ftdmchan->iostats.tx), FTDM_IOSTATS_ERROR_QUEUE_FULL)){ - ftdm_clear_flag(&(ftdmchan->iostats.tx), FTDM_IOSTATS_ERROR_QUEUE_FULL); - } - - if (ftdmchan->iostats.tx.idle_packets < tx_stats->wp_api_tx_hdr_tx_idle_packets) { - ftdmchan->iostats.tx.idle_packets = tx_stats->wp_api_tx_hdr_tx_idle_packets; - } - - if (!ftdmchan->iostats.tx.packets) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "First packet write stats: Tx queue len: %d, Tx queue size: %d, Tx idle: %"FTDM_UINT64_FMT"\n", - ftdmchan->iostats.tx.queue_len, - ftdmchan->iostats.tx.queue_size, - ftdmchan->iostats.tx.idle_packets); - } - - ftdmchan->iostats.tx.packets++; -} - -static void wanpipe_read_stats(ftdm_channel_t *ftdmchan, wp_tdm_api_rx_hdr_t *rx_stats) -{ - ftdmchan->iostats.rx.errors = rx_stats->wp_api_rx_hdr_errors; - ftdmchan->iostats.rx.queue_size = rx_stats->wp_api_rx_hdr_max_queue_length; - ftdmchan->iostats.rx.queue_len = rx_stats->wp_api_rx_hdr_number_of_frames_in_queue; - - if ((rx_stats->wp_api_rx_hdr_error_map & (1 << WP_ABORT_ERROR_BIT))) { - ftdm_set_flag(&(ftdmchan->iostats.rx), FTDM_IOSTATS_ERROR_ABORT); - } else { - ftdm_clear_flag(&(ftdmchan->iostats.rx), FTDM_IOSTATS_ERROR_ABORT); - } - - if ((rx_stats->wp_api_rx_hdr_error_map & (1 << WP_DMA_ERROR_BIT))) { - ftdm_set_flag(&(ftdmchan->iostats.rx), FTDM_IOSTATS_ERROR_DMA); - } else { - ftdm_clear_flag(&(ftdmchan->iostats.rx), FTDM_IOSTATS_ERROR_DMA); - } - - if ((rx_stats->wp_api_rx_hdr_error_map & (1 << WP_FIFO_ERROR_BIT))) { - ftdm_set_flag(&(ftdmchan->iostats.rx), FTDM_IOSTATS_ERROR_FIFO); - } else { - ftdm_clear_flag(&(ftdmchan->iostats.rx), FTDM_IOSTATS_ERROR_FIFO); - } - - if ((rx_stats->wp_api_rx_hdr_error_map & (1 << WP_CRC_ERROR_BIT))) { - ftdm_set_flag(&(ftdmchan->iostats.rx), FTDM_IOSTATS_ERROR_CRC); - } else { - ftdm_clear_flag(&(ftdmchan->iostats.rx), FTDM_IOSTATS_ERROR_CRC); - } - - if ((rx_stats->wp_api_rx_hdr_error_map & (1 << WP_FRAME_ERROR_BIT))) { - ftdm_set_flag(&(ftdmchan->iostats.rx), FTDM_IOSTATS_ERROR_FRAME); - } else { - ftdm_clear_flag(&(ftdmchan->iostats.rx), FTDM_IOSTATS_ERROR_FRAME); - } - - if (ftdmchan->iostats.rx.queue_len >= (0.8 * ftdmchan->iostats.rx.queue_size)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Rx Queue length exceeded 80%% threshold (%d/%d)\n", - ftdmchan->iostats.rx.queue_len, ftdmchan->iostats.rx.queue_size); - ftdm_set_flag(&(ftdmchan->iostats.rx), FTDM_IOSTATS_ERROR_QUEUE_THRES); - } else if (ftdm_test_flag(&(ftdmchan->iostats.rx), FTDM_IOSTATS_ERROR_QUEUE_THRES)){ - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Rx Queue length reduced 80%% threshold (%d/%d)\n", - ftdmchan->iostats.rx.queue_len, ftdmchan->iostats.rx.queue_size); - ftdm_clear_flag(&(ftdmchan->iostats.rx), FTDM_IOSTATS_ERROR_QUEUE_THRES); - } - - if (ftdmchan->iostats.rx.queue_len >= ftdmchan->iostats.rx.queue_size) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Rx Queue Full (%d/%d)\n", - ftdmchan->iostats.rx.queue_len, ftdmchan->iostats.rx.queue_size); - ftdm_set_flag(&(ftdmchan->iostats.rx), FTDM_IOSTATS_ERROR_QUEUE_FULL); - } else if (ftdm_test_flag(&(ftdmchan->iostats.rx), FTDM_IOSTATS_ERROR_QUEUE_FULL)){ - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Rx Queue no longer full (%d/%d)\n", - ftdmchan->iostats.rx.queue_len, ftdmchan->iostats.rx.queue_size); - ftdm_clear_flag(&(ftdmchan->iostats.rx), FTDM_IOSTATS_ERROR_QUEUE_FULL); - } - - if (!ftdmchan->iostats.rx.packets) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "First packet read stats: Rx queue len: %d, Rx queue size: %d\n", - ftdmchan->iostats.rx.queue_len, ftdmchan->iostats.rx.queue_size); - } - - ftdmchan->iostats.rx.packets++; -} - -/** - * \brief Reads data from a Wanpipe channel - * \param ftdmchan Channel to read from - * \param data Data buffer - * \param datalen Size of data buffer - * \return Success, failure or timeout - */ - - -static FIO_READ_FUNCTION(wanpipe_read) -{ - int rx_len = 0; - int rq_len = (int)*datalen; - wp_tdm_api_rx_hdr_t hdrframe; - - -#ifdef WP_DEBUG_IO - wp_channel_t *wchan = ftdmchan->io_data; - ftdm_time_t time_diff = 0; - pid_t previous_thread = 1; - pid_t current_thread = 0; - int previous_thread_index = 0; - - previous_thread_index = wchan->rindex == 0 ? (ftdm_array_len(wchan->readers) - 1) : wchan->rindex - 1; - previous_thread = wchan->readers[previous_thread_index]; - current_thread = syscall(SYS_gettid); - if (current_thread && current_thread != wchan->readers[wchan->rindex]) { - if (!wchan->readers[wchan->rindex]) { - wchan->readers[wchan->rindex] = current_thread; - /* first read */ - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Initial reader thread is %d\n", current_thread); - previous_thread = current_thread; - } else { - previous_thread = wchan->readers[wchan->rindex]; - ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Changed reader thread from %d to %d (rindex = %d)\n", - previous_thread, current_thread, wchan->rindex); - if (wchan->rindex == (ftdm_array_len(wchan->readers) - 1)) { - wchan->rindex = 0; - } else { - wchan->rindex++; - } - wchan->readers[wchan->rindex] = current_thread; - } - } - ftdm_time_t curr = ftdm_current_time_in_ms(); - if (wchan->last_read) { - time_diff = curr - wchan->last_read; - } -#endif - - memset(&hdrframe, 0, sizeof(hdrframe)); - rx_len = sangoma_readmsg_tdm(ftdmchan->sockfd, &hdrframe, (int)sizeof(hdrframe), data, (int)*datalen, 0); - *datalen = 0; - - if (rx_len == 0) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "Read 0 bytes\n"); - return FTDM_TIMEOUT; - } - - if (rx_len < 0) { -#ifdef WP_DEBUG_IO - ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Failed to read %d bytes from sangoma device: %s (%d) " - "(read time diff = %llums, prev thread = %d, curr thread = %d)\n", rq_len, strerror(errno), rx_len, - time_diff, previous_thread, current_thread); -#else - ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Failed to read %d bytes from sangoma device: %s (%d)\n", rq_len, strerror(errno), rx_len); -#endif - return FTDM_FAIL; - } - *datalen = rx_len; - - if (ftdm_channel_test_feature(ftdmchan, FTDM_CHANNEL_FEATURE_IO_STATS)) { - wanpipe_read_stats(ftdmchan, &hdrframe); - } - - if ((ftdmchan->type == FTDM_CHAN_TYPE_B) && (ftdmchan->span->trunk_type == FTDM_TRUNK_GSM)) { - wp_swap16(data, *datalen); - } - - return FTDM_SUCCESS; -} - -/** - * \brief Writes data to a Wanpipe channel - * \param ftdmchan Channel to write to - * \param data Data buffer - * \param datalen Size of data buffer - * \return Success or failure - */ -static FIO_WRITE_FUNCTION(wanpipe_write) -{ - int bsent = 0; - int err = 0; - wp_tdm_api_tx_hdr_t hdrframe; - - if ((ftdmchan->type == FTDM_CHAN_TYPE_B) && (ftdmchan->span->trunk_type == FTDM_TRUNK_GSM)) { - wp_swap16(data, *datalen); - } - - /* Do we even need the headerframe here? on windows, we don't even pass it to the driver */ - memset(&hdrframe, 0, sizeof(hdrframe)); - if (*datalen == 0) { - return FTDM_SUCCESS; - } - - if (ftdm_channel_test_feature(ftdmchan, FTDM_CHANNEL_FEATURE_IO_STATS) && !ftdmchan->iostats.tx.packets) { - wanpipe_tdm_api_t tdm_api; - memset(&tdm_api, 0, sizeof(tdm_api)); - /* if this is the first write ever, flush the tx first to have clean stats */ - err = sangoma_flush_tx_bufs(ftdmchan->sockfd, &tdm_api); - if (err) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "Failed to flush on first write\n"); - } - } - - bsent = sangoma_writemsg_tdm(ftdmchan->sockfd, &hdrframe, (int)sizeof(hdrframe), data, (unsigned short)(*datalen),0); - - /* should we be checking if bsent == *datalen here? */ - if (bsent > 0) { - *datalen = bsent; - if (ftdm_channel_test_feature(ftdmchan, FTDM_CHANNEL_FEATURE_IO_STATS)) { - /* BRI cards do not support TX queues for now */ - if(!FTDM_SPAN_IS_BRI(ftdmchan->span)) { - wanpipe_write_stats(ftdmchan, &hdrframe); - } - } - return FTDM_SUCCESS; - } - - return FTDM_FAIL; -} - -/** - * \brief Waits for an event on a Wanpipe channel - * \param ftdmchan Channel to open - * \param flags Type of event to wait for - * \param to Time to wait (in ms) - * \return Success, failure or timeout - */ - -static FIO_WAIT_FUNCTION(wanpipe_wait) -{ - int32_t inflags = 0; - int result; - - if (*flags & FTDM_READ) { - inflags |= POLLIN; - } - - if (*flags & FTDM_WRITE) { - inflags |= POLLOUT; - } - - if (*flags & FTDM_EVENTS) { - inflags |= POLLPRI; - } - - result = tdmv_api_wait_socket(ftdmchan, to, &inflags); - - *flags = FTDM_NO_FLAGS; - - if (result < 0){ - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "Poll failed"); - return FTDM_FAIL; - } - - if (result == 0) { - return FTDM_TIMEOUT; - } - - if (inflags & POLLIN) { - *flags |= FTDM_READ; - } - - if (inflags & POLLOUT) { - *flags |= FTDM_WRITE; - } - - if (inflags & POLLPRI) { - *flags |= FTDM_EVENTS; - } - - return FTDM_SUCCESS; -} - -/** - * \brief Checks for events on a Wanpipe span - * \param span Span to check for events - * \param ms Time to wait for event - * \return Success if event is waiting or failure if not - */ -FIO_SPAN_POLL_EVENT_FUNCTION(wanpipe_poll_event) -{ -#ifdef LIBSANGOMA_VERSION - sangoma_status_t sangstatus; - sangoma_wait_obj_t *pfds[FTDM_MAX_CHANNELS_SPAN] = { 0 }; - uint32_t inflags[FTDM_MAX_CHANNELS_SPAN]; - uint32_t outflags[FTDM_MAX_CHANNELS_SPAN]; -#else - struct pollfd pfds[FTDM_MAX_CHANNELS_SPAN]; -#endif - uint32_t i, j = 0, k = 0, l = 0; - int r; - - for(i = 1; i <= span->chan_count; i++) { - ftdm_channel_t *ftdmchan = span->channels[i]; - uint32_t chan_events = 0; - - /* translate events from ftdm to libsnagoma. if the user don't specify which events to poll the - * channel for, we just use SANG_WAIT_OBJ_HAS_EVENTS */ - if (poll_events) { - if (poll_events[j] & FTDM_READ) { - chan_events = SANG_WAIT_OBJ_HAS_INPUT; - } - if (poll_events[j] & FTDM_WRITE) { - chan_events |= SANG_WAIT_OBJ_HAS_OUTPUT; - } - if (poll_events[j] & FTDM_EVENTS) { - chan_events |= SANG_WAIT_OBJ_HAS_EVENTS; - } - } else { - chan_events = SANG_WAIT_OBJ_HAS_EVENTS; - } - -#ifdef LIBSANGOMA_VERSION - if (!ftdmchan->io_data) { - continue; /* should never happen but happens when shutting down */ - } - pfds[j] = WP_GET_WAITABLE(ftdmchan); - inflags[j] = chan_events; -#else - memset(&pfds[j], 0, sizeof(pfds[j])); - pfds[j].fd = span->channels[i]->sockfd; - pfds[j].events = chan_events; -#endif - - /* The driver probably should be able to do this wink/flash/ringing by itself this is sort of a hack to make it work! */ - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_WINK) || ftdm_test_flag(ftdmchan, FTDM_CHANNEL_FLASH)) { - l = 5; - } - - j++; - - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_RINGING)) { - l = 5; - } - - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_RINGING) && ftdm_current_time_in_ms() >= ftdmchan->ring_time) { - wanpipe_tdm_api_t tdm_api; - int err; - memset(&tdm_api, 0, sizeof(tdm_api)); - if (ftdm_test_pflag(ftdmchan, WP_RINGING)) { - err = sangoma_tdm_txsig_offhook(ftdmchan->sockfd,&tdm_api); - if (err) { - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "Ring-off Failed"); - ftdm_log(FTDM_LOG_ERROR, "sangoma_tdm_txsig_offhook failed\n"); - return FTDM_FAIL; - } - ftdm_clear_pflag_locked(ftdmchan, WP_RINGING); - ftdmchan->ring_time = ftdm_current_time_in_ms() + wp_globals.ring_off_ms; - } else { - err=sangoma_tdm_txsig_start(ftdmchan->sockfd,&tdm_api); - if (err) { - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "Ring Failed"); - ftdm_log(FTDM_LOG_ERROR, "sangoma_tdm_txsig_start failed\n"); - return FTDM_FAIL; - } - ftdm_set_pflag_locked(ftdmchan, WP_RINGING); - ftdmchan->ring_time = ftdm_current_time_in_ms() + wp_globals.ring_on_ms; - } - } - } - - if (l) { - ms = l; - } -#ifdef LIBSANGOMA_VERSION - sangstatus = sangoma_waitfor_many(pfds, inflags, outflags, j, ms); - if (SANG_STATUS_APIPOLL_TIMEOUT == sangstatus) { - r = 0; - } else if (SANG_STATUS_SUCCESS == sangstatus) { - r = 1; /* hopefully we never need how many changed -_- */ - } else { - ftdm_log(FTDM_LOG_ERROR, "sangoma_waitfor_many failed: %d, %s\n", sangstatus, strerror(errno)); - r = -1; - } -#else - r = poll(pfds, j, ms); -#endif - - if (r == 0) { - return l ? FTDM_SUCCESS : FTDM_TIMEOUT; - } else if (r < 0) { - snprintf(span->last_error, sizeof(span->last_error), "%s", strerror(errno)); - return FTDM_FAIL; - } - - for(i = 1; i <= span->chan_count; i++) { - ftdm_channel_t *ftdmchan = span->channels[i]; - -#ifdef LIBSANGOMA_VERSION - if (outflags[i-1] & POLLPRI) { -#else - if (pfds[i-1].revents & POLLPRI) { -#endif - ftdm_set_io_flag(ftdmchan, FTDM_CHANNEL_IO_EVENT); - ftdmchan->last_event_time = ftdm_current_time_in_ms(); - k++; - } -#ifdef LIBSANGOMA_VERSION - if (outflags[i-1] & POLLIN) { -#else - if (pfds[i-1].revents & POLLIN) { -#endif - ftdm_set_io_flag(ftdmchan, FTDM_CHANNEL_IO_READ); - } -#ifdef LIBSANGOMA_VERSION - if (outflags[i-1] & POLLOUT) { -#else - if (pfds[i-1].revents & POLLOUT) { -#endif - ftdm_set_io_flag(ftdmchan, FTDM_CHANNEL_IO_WRITE); - } - } - /* when k is 0 it might be that an async wanpipe device signal was delivered */ - return FTDM_SUCCESS; -} - -/** - * \brief Gets alarms from a Wanpipe Channel - * \param ftdmchan Channel to get alarms from - * \return Success or failure - */ -static FIO_GET_ALARMS_FUNCTION(wanpipe_get_alarms) -{ - wanpipe_tdm_api_t tdm_api; - unsigned int alarms = 0; - int err; - - memset(&tdm_api, 0, sizeof(tdm_api)); - -#ifdef LIBSANGOMA_VERSION - if ((err = sangoma_tdm_get_fe_alarms(ftdmchan->sockfd, &tdm_api, &alarms))) { - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "ioctl failed (%s)", strerror(errno)); - snprintf(ftdmchan->span->last_error, sizeof(ftdmchan->span->last_error), "ioctl failed (%s)", strerror(errno)); - return FTDM_FAIL; - } -#else - if ((err = sangoma_tdm_get_fe_alarms(ftdmchan->sockfd, &tdm_api)) < 0){ - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "ioctl failed (%s)", strerror(errno)); - snprintf(ftdmchan->span->last_error, sizeof(ftdmchan->span->last_error), "ioctl failed (%s)", strerror(errno)); - return FTDM_FAIL; - } - alarms = tdm_api.wp_tdm_cmd.fe_alarms; -#endif -#ifdef WIN32 - /* Temporary fix: in the current trunk of libsangoma, for BRI, - WAN_TE_BIT_ALARM_RED bit is set if the card is in disconnected state, but this has - not been ported to Windows-libsangoma yet */ - if (FTDM_SPAN_IS_BRI(ftdmchan->span)) { - if (alarms) { - ftdmchan->alarm_flags |= FTDM_ALARM_RED; - alarms = 0; - } - } -#endif - - ftdmchan->alarm_flags = FTDM_ALARM_NONE; - - if (alarms & WAN_TE_BIT_ALARM_RED) { - ftdmchan->alarm_flags |= FTDM_ALARM_RED; - alarms &= ~WAN_TE_BIT_ALARM_RED; - } - - - if (alarms & WAN_TE_BIT_ALARM_AIS) { - ftdmchan->alarm_flags |= FTDM_ALARM_BLUE; - alarms &= ~WAN_TE_BIT_ALARM_AIS; - } - - if (alarms & WAN_TE_BIT_ALARM_RAI) { - ftdmchan->alarm_flags |= FTDM_ALARM_YELLOW; - alarms &= ~WAN_TE_BIT_ALARM_RAI; - } - - if (!ftdmchan->alarm_flags) { - /* there is a bug in wanpipe where alarms were not properly set when they should be - * on at application startup, until that is fixed we check the link status here too */ - ftdm_channel_hw_link_status_t sangoma_status = 0; - ftdm_channel_command(ftdmchan, FTDM_COMMAND_GET_LINK_STATUS, &sangoma_status); - ftdmchan->alarm_flags = sangoma_status == FTDM_HW_LINK_DISCONNECTED ? FTDM_ALARM_RED : FTDM_ALARM_NONE; - } - - if (alarms) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Unmapped wanpipe alarms: %d\n", alarms); - } - - return FTDM_SUCCESS; -} - -/** - * \brief Process an event in a channel and set it's OOB event id. The channel must be locked. - * \param fchan Channel in which event occured - * \param event_id Pointer where we save the OOB event id - * \param tdm_api Wanpipe tdm struct that contain the event - * \return FTDM_SUCCESS or FTDM_FAIL - */ -static __inline__ ftdm_status_t wanpipe_channel_process_event(ftdm_channel_t *fchan, ftdm_oob_event_t *event_id, wanpipe_tdm_api_t *tdm_api) -{ - ftdm_status_t status = FTDM_SUCCESS; - - switch(tdm_api->wp_tdm_cmd.event.wp_tdm_api_event_type) { - case WP_API_EVENT_LINK_STATUS: - { - if (FTDM_IS_DIGITAL_CHANNEL(fchan)) { - switch(tdm_api->wp_tdm_cmd.event.wp_tdm_api_event_link_status) { - case WP_TDMAPI_EVENT_LINK_STATUS_CONNECTED: - /* *event_id = FTDM_OOB_ALARM_CLEAR; */ - ftdm_log_chan_msg(fchan, FTDM_LOG_DEBUG, "Ignoring wanpipe link connected event\n"); - break; - default: - /* *event_id = FTDM_OOB_ALARM_TRAP; */ - ftdm_log_chan_msg(fchan, FTDM_LOG_DEBUG, "Ignoring wanpipe link disconnected event\n"); - break; - } - /* The WP_API_EVENT_ALARM event should be used to clear alarms */ - *event_id = FTDM_OOB_NOOP; - } else { - switch(tdm_api->wp_tdm_cmd.event.wp_tdm_api_event_link_status) { - case WP_TDMAPI_EVENT_LINK_STATUS_CONNECTED: - /* *event_id = FTDM_OOB_ALARM_CLEAR; */ - ftdm_log_chan_msg(fchan, FTDM_LOG_DEBUG, "Using analog link connected event as alarm clear\n"); - *event_id = FTDM_OOB_ALARM_CLEAR; - fchan->alarm_flags = FTDM_ALARM_NONE; - break; - default: - /* *event_id = FTDM_OOB_ALARM_TRAP; */ - ftdm_log_chan_msg(fchan, FTDM_LOG_DEBUG, "Using analog link disconnected event as alarm trap\n"); - *event_id = FTDM_OOB_ALARM_TRAP; - fchan->alarm_flags = FTDM_ALARM_RED; - break; - } - } - } - break; - - case WP_API_EVENT_RXHOOK: - { - if (fchan->type == FTDM_CHAN_TYPE_FXS) { - *event_id = tdm_api->wp_tdm_cmd.event.wp_tdm_api_event_hook_state - & WP_TDMAPI_EVENT_RXHOOK_OFF ? FTDM_OOB_OFFHOOK : FTDM_OOB_ONHOOK; - ftdm_log_chan(fchan, FTDM_LOG_DEBUG, "Got wanpipe %s\n", ftdm_oob_event2str(*event_id)); - if (*event_id == FTDM_OOB_OFFHOOK) { - if (ftdm_test_flag(fchan, FTDM_CHANNEL_FLASH)) { - ftdm_clear_flag(fchan, FTDM_CHANNEL_FLASH); - ftdm_clear_flag(fchan, FTDM_CHANNEL_WINK); - *event_id = FTDM_OOB_FLASH; - goto done; - } else { - ftdm_set_flag(fchan, FTDM_CHANNEL_WINK); - } - } else { - if (ftdm_test_flag(fchan, FTDM_CHANNEL_WINK)) { - ftdm_clear_flag(fchan, FTDM_CHANNEL_WINK); - ftdm_clear_flag(fchan, FTDM_CHANNEL_FLASH); - *event_id = FTDM_OOB_WINK; - ftdm_log_chan(fchan, FTDM_LOG_DEBUG, "Wink flag is set, delivering %s\n", - ftdm_oob_event2str(*event_id)); - goto done; - } else { - ftdm_set_flag(fchan, FTDM_CHANNEL_FLASH); - } - } - status = FTDM_BREAK; - } else { - ftdm_status_t status; - status = sangoma_tdm_txsig_onhook(fchan->sockfd, tdm_api); - if (status) { - snprintf(fchan->last_error, sizeof(fchan->last_error), "ONHOOK Failed"); - return FTDM_FAIL; - } - *event_id = tdm_api->wp_tdm_cmd.event.wp_tdm_api_event_hook_state & WP_TDMAPI_EVENT_RXHOOK_OFF ? FTDM_OOB_ONHOOK : FTDM_OOB_NOOP; - } - } - break; - case WP_API_EVENT_RING_DETECT: - { - *event_id = tdm_api->wp_tdm_cmd.event.wp_tdm_api_event_ring_state == WP_TDMAPI_EVENT_RING_PRESENT ? FTDM_OOB_RING_START : FTDM_OOB_RING_STOP; - } - break; - /* - disabled this ones when configuring, we don't need them, do we? - case WP_API_EVENT_RING_TRIP_DETECT: - { - *event_id = tdm_api->wp_tdm_cmd.event.wp_tdm_api_event_ring_state == WP_TDMAPI_EVENT_RING_PRESENT ? FTDM_OOB_ONHOOK : FTDM_OOB_OFFHOOK; - } - break; - */ - case WP_API_EVENT_RBS: - { - *event_id = FTDM_OOB_CAS_BITS_CHANGE; - fchan->rx_cas_bits = wanpipe_swap_bits(tdm_api->wp_tdm_cmd.event.wp_tdm_api_event_rbs_bits); - } - break; - case WP_API_EVENT_DTMF: - { - char tmp_dtmf[2] = { tdm_api->wp_tdm_cmd.event.wp_tdm_api_event_dtmf_digit, 0 }; - *event_id = FTDM_OOB_NOOP; - - if (tmp_dtmf[0] == 'f') { - ftdm_log_chan(fchan, FTDM_LOG_DEBUG, "Ignoring wanpipe DTMF: %c, fax tones will be passed through!\n", tmp_dtmf[0]); - break; - } - - if (tdm_api->wp_tdm_cmd.event.wp_tdm_api_event_dtmf_type == WAN_EC_TONE_PRESENT) { - ftdm_set_flag(fchan, FTDM_CHANNEL_MUTE); - if (fchan->dtmfdetect.duration_ms) { - fchan->dtmfdetect.start_time = ftdm_current_time_in_ms(); - } else if (fchan->dtmfdetect.trigger_on_start) { - ftdm_log_chan(fchan, FTDM_LOG_DEBUG, "Queuing wanpipe DTMF: %c\n", tmp_dtmf[0]); - ftdm_channel_queue_dtmf(fchan, tmp_dtmf); - } - } - - if (tdm_api->wp_tdm_cmd.event.wp_tdm_api_event_dtmf_type == WAN_EC_TONE_STOP) { - ftdm_clear_flag(fchan, FTDM_CHANNEL_MUTE); - if (ftdm_test_flag(fchan, FTDM_CHANNEL_INUSE)) { - if (fchan->dtmfdetect.duration_ms) { - ftdm_time_t diff = ftdm_current_time_in_ms() - fchan->dtmfdetect.start_time; - if (diff > fchan->dtmfdetect.duration_ms) { - ftdm_log_chan(fchan, FTDM_LOG_DEBUG, "Queuing wanpipe DTMF: %c (duration:%"FTDM_TIME_FMT" min:%d)\n", tmp_dtmf[0], diff, fchan->dtmfdetect.duration_ms); - ftdm_channel_queue_dtmf(fchan, tmp_dtmf); - } else { - ftdm_log_chan(fchan, FTDM_LOG_DEBUG, "Ignoring wanpipe DTMF: %c (duration:%"FTDM_TIME_FMT" min:%d)\n", tmp_dtmf[0], diff, fchan->dtmfdetect.duration_ms); - } - } else if (!fchan->dtmfdetect.trigger_on_start) { - ftdm_log_chan(fchan, FTDM_LOG_DEBUG, "Queuing wanpipe DTMF: %c\n", tmp_dtmf[0]); - ftdm_channel_queue_dtmf(fchan, tmp_dtmf); - } - } - } - } - break; - case WP_API_EVENT_ALARM: - { - if (tdm_api->wp_tdm_cmd.event.wp_api_event_alarm) { - ftdm_log_chan(fchan, FTDM_LOG_DEBUG, "Got Wanpipe alarms %d\n", tdm_api->wp_tdm_cmd.event.wp_api_event_alarm); - *event_id = FTDM_OOB_ALARM_TRAP; - } else { - ftdm_log_chan_msg(fchan, FTDM_LOG_DEBUG, "Wanpipe alarms cleared\n"); - *event_id = FTDM_OOB_ALARM_CLEAR; - } - } - break; - case WP_API_EVENT_POLARITY_REVERSE: - { - ftdm_log_chan_msg(fchan, FTDM_LOG_DEBUG, "Got polarity reverse\n"); - *event_id = FTDM_OOB_POLARITY_REVERSE; - } - break; - default: - { - ftdm_log_chan(fchan, FTDM_LOG_WARNING, "Unhandled wanpipe event %d\n", tdm_api->wp_tdm_cmd.event.wp_tdm_api_event_type); - *event_id = FTDM_OOB_INVALID; - } - break; - } -done: - return status; -} - -/** - * \brief Retrieves an event from a wanpipe channel - * \param channel Channel to retrieve event from - * \param event FreeTDM event to return - * \return Success or failure - */ -FIO_CHANNEL_NEXT_EVENT_FUNCTION(wanpipe_channel_next_event) -{ - ftdm_status_t status; - ftdm_oob_event_t event_id; - wanpipe_tdm_api_t tdm_api; - ftdm_span_t *span = ftdmchan->span; - - memset(&tdm_api, 0, sizeof(tdm_api)); - status = sangoma_tdm_read_event(ftdmchan->sockfd, &tdm_api); - if (status != FTDM_SUCCESS) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Failed to read event from channel: %s\n", strerror(errno)); - return FTDM_FAIL; - } - - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "read wanpipe event %d\n", tdm_api.wp_tdm_cmd.event.wp_tdm_api_event_type); - status = wanpipe_channel_process_event(ftdmchan, &event_id, &tdm_api); - if (status == FTDM_BREAK) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "Ignoring event for now\n"); - } else if (status != FTDM_SUCCESS) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "Failed to process event from channel\n"); - return FTDM_FAIL; - } else { - ftdmchan->last_event_time = 0; - } - - span->event_header.e_type = FTDM_EVENT_OOB; - span->event_header.enum_id = event_id; - span->event_header.channel = ftdmchan; - *event = &span->event_header; - return FTDM_SUCCESS; -} - -/** - * \brief Retrieves an event from a wanpipe span - * \param span Span to retrieve event from - * \param event FreeTDM event to return - * \return Success or failure - */ -FIO_SPAN_NEXT_EVENT_FUNCTION(wanpipe_span_next_event) -{ - uint32_t i,err; - ftdm_oob_event_t event_id; - for(i = 1; i <= span->chan_count; i++) { - /* as a hack for wink/flash detection, wanpipe_poll_event overrides the timeout parameter - * to force the user to call this function each 5ms or so to detect the timeout of our wink/flash */ - if (span->channels[i]->last_event_time && !ftdm_test_io_flag(span->channels[i], FTDM_CHANNEL_IO_EVENT)) { - ftdm_time_t diff = ftdm_current_time_in_ms() - span->channels[i]->last_event_time; - /* XX printf("%u %u %u\n", diff, (unsigned)ftdm_current_time_in_ms(), (unsigned)span->channels[i]->last_event_time); */ - if (ftdm_test_flag(span->channels[i], FTDM_CHANNEL_WINK)) { - if (diff > wp_globals.wink_ms) { - ftdm_clear_flag_locked(span->channels[i], FTDM_CHANNEL_WINK); - ftdm_clear_flag_locked(span->channels[i], FTDM_CHANNEL_FLASH); - ftdm_set_flag_locked(span->channels[i], FTDM_CHANNEL_OFFHOOK); - event_id = FTDM_OOB_OFFHOOK; - ftdm_log_chan(span->channels[i], FTDM_LOG_DEBUG, "Diff since last event = %"FTDM_TIME_FMT" ms, delivering %s now\n", diff, ftdm_oob_event2str(event_id)); - goto event; - } - } - - if (ftdm_test_flag(span->channels[i], FTDM_CHANNEL_FLASH)) { - if (diff > wp_globals.flash_ms) { - ftdm_clear_flag_locked(span->channels[i], FTDM_CHANNEL_FLASH); - ftdm_clear_flag_locked(span->channels[i], FTDM_CHANNEL_WINK); - ftdm_clear_flag_locked(span->channels[i], FTDM_CHANNEL_OFFHOOK); - event_id = FTDM_OOB_ONHOOK; - - if (span->channels[i]->type == FTDM_CHAN_TYPE_FXO) { - ftdm_channel_t *ftdmchan = span->channels[i]; - wanpipe_tdm_api_t tdm_api; - memset(&tdm_api, 0, sizeof(tdm_api)); - - sangoma_tdm_txsig_onhook(ftdmchan->sockfd,&tdm_api); - } - ftdm_log_chan(span->channels[i], FTDM_LOG_DEBUG, "Diff since last event = %"FTDM_TIME_FMT" ms, delivering %s now\n", diff, ftdm_oob_event2str(event_id)); - goto event; - } - } - } - if (ftdm_test_io_flag(span->channels[i], FTDM_CHANNEL_IO_EVENT)) { - ftdm_status_t status; - wanpipe_tdm_api_t tdm_api; - ftdm_channel_t *ftdmchan = span->channels[i]; - memset(&tdm_api, 0, sizeof(tdm_api)); - ftdm_clear_io_flag(span->channels[i], FTDM_CHANNEL_IO_EVENT); - - err = sangoma_tdm_read_event(ftdmchan->sockfd, &tdm_api); - if (err != FTDM_SUCCESS) { - ftdm_log_chan(span->channels[i], FTDM_LOG_ERROR, "read wanpipe event got error: %s\n", strerror(errno)); - return FTDM_FAIL; - } - ftdm_log_chan(span->channels[i], FTDM_LOG_DEBUG, "read wanpipe event %d\n", tdm_api.wp_tdm_cmd.event.wp_tdm_api_event_type); - - ftdm_channel_lock(ftdmchan); - status = wanpipe_channel_process_event(ftdmchan, &event_id, &tdm_api); - ftdm_channel_unlock(ftdmchan); - - if (status == FTDM_BREAK) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Ignoring event for now\n"); - continue; - } else if (status != FTDM_SUCCESS) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "Failed to process event from channel\n"); - return FTDM_FAIL; - } - - event: - - span->channels[i]->last_event_time = 0; - span->event_header.e_type = FTDM_EVENT_OOB; - span->event_header.enum_id = event_id; - span->event_header.channel = span->channels[i]; - *event = &span->event_header; - return FTDM_SUCCESS; - } - } - return FTDM_BREAK; -} - -/** - * \brief Destroys a Wanpipe Channel - * \param ftdmchan Channel to destroy - * \return Success - */ -static FIO_CHANNEL_DESTROY_FUNCTION(wanpipe_channel_destroy) -{ -#ifdef LIBSANGOMA_VERSION - if (ftdmchan->io_data) { - sangoma_wait_obj_t *sangoma_wait_obj = WP_GET_WAITABLE(ftdmchan); - sangoma_wait_obj_delete(&sangoma_wait_obj); - ftdm_safe_free(ftdmchan->io_data); - ftdmchan->io_data = NULL; - } -#endif - - if (ftdmchan->sockfd != FTDM_INVALID_SOCKET) { - /* enable HW DTMF. As odd as it seems. Why enable when the channel is being destroyed and won't be used anymore? - * because that way we can transfer the DTMF state back to the driver, if we're being restarted we will set again - * the FEATURE_DTMF flag and use HW DTMF, if we don't enable here, then on module restart we won't see - * HW DTMF available and will use software */ - if (ftdm_channel_test_feature(ftdmchan, FTDM_CHANNEL_FEATURE_DTMF_DETECT)) { - wanpipe_tdm_api_t tdm_api; - int err; - memset(&tdm_api, 0, sizeof(tdm_api)); - err = sangoma_tdm_enable_dtmf_events(ftdmchan->sockfd, &tdm_api); - if (err) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "Failed enabling Sangoma HW DTMF failed on channel destroy\n"); - } - } - sangoma_close(&ftdmchan->sockfd); - } - - return FTDM_SUCCESS; -} - -/** - * \brief Loads wanpipe IO module - * \param fio FreeTDM IO interface - * \return Success - */ -static FIO_IO_LOAD_FUNCTION(wanpipe_init) -{ - ftdm_assert(fio != NULL, "fio should not be null\n"); - - memset(&wanpipe_interface, 0, sizeof(wanpipe_interface)); - - wp_globals.codec_ms = 20; - wp_globals.wink_ms = 150; - wp_globals.flash_ms = 750; - wp_globals.ring_on_ms = 2000; - wp_globals.ring_off_ms = 4000; - /* 0 for queue size will leave driver defaults */ - wp_globals.txqueue_size = 0; - wp_globals.rxqueue_size = 0; - wanpipe_interface.name = "wanpipe"; - wanpipe_interface.configure_span = wanpipe_configure_span; - wanpipe_interface.configure = wanpipe_configure; - wanpipe_interface.open = wanpipe_open; - wanpipe_interface.close = wanpipe_close; - wanpipe_interface.command = wanpipe_command; - wanpipe_interface.wait = wanpipe_wait; - wanpipe_interface.read = wanpipe_read; - wanpipe_interface.write = wanpipe_write; - wanpipe_interface.poll_event = wanpipe_poll_event; - wanpipe_interface.next_event = wanpipe_span_next_event; - wanpipe_interface.channel_next_event = wanpipe_channel_next_event; - wanpipe_interface.channel_destroy = wanpipe_channel_destroy; - wanpipe_interface.get_alarms = wanpipe_get_alarms; - *fio = &wanpipe_interface; - - return FTDM_SUCCESS; -} - -/** - * \brief Unloads wanpipe IO module - * \return Success - */ -static FIO_IO_UNLOAD_FUNCTION(wanpipe_destroy) -{ - memset(&wanpipe_interface, 0, sizeof(wanpipe_interface)); - return FTDM_SUCCESS; -} - -/** - * \brief FreeTDM wanpipe IO module definition - */ -EX_DECLARE_DATA ftdm_module_t ftdm_module = { - "wanpipe", - wanpipe_init, - wanpipe_destroy, -}; - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet - */ diff --git a/libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.c b/libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.c deleted file mode 100644 index 369a05d1d0..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.c +++ /dev/null @@ -1,1571 +0,0 @@ -/* - * Copyright (c) 2007-2014, Anthony Minessale II - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Contributors: - * - * Moises Silva - * W McRoberts - * Puskás Zsolt - * - */ - -#include "private/ftdm_core.h" -#include "ftmod_zt.h" - -/* used by dahdi to indicate there is no data available, but events to read */ -#ifndef ELAST -#define ELAST 500 -#endif - -/** - * \brief Zaptel globals - */ -static struct { - uint32_t codec_ms; - uint32_t wink_ms; - uint32_t flash_ms; - uint32_t eclevel; - uint32_t etlevel; - float rxgain; - float txgain; -} zt_globals; - -#if defined(__FreeBSD__) -typedef unsigned long ioctlcmd; -#else -typedef int ioctlcmd; -#endif - -/** - * \brief General IOCTL codes - */ -struct ioctl_codes { - ioctlcmd GET_BLOCKSIZE; - ioctlcmd SET_BLOCKSIZE; - ioctlcmd FLUSH; - ioctlcmd SYNC; - ioctlcmd GET_PARAMS; - ioctlcmd SET_PARAMS; - ioctlcmd HOOK; - ioctlcmd GETEVENT; - ioctlcmd IOMUX; - ioctlcmd SPANSTAT; - ioctlcmd MAINT; - ioctlcmd GETCONF; - ioctlcmd SETCONF; - ioctlcmd CONFLINK; - ioctlcmd CONFDIAG; - ioctlcmd GETGAINS; - ioctlcmd SETGAINS; - ioctlcmd SPANCONFIG; - ioctlcmd CHANCONFIG; - ioctlcmd SET_BUFINFO; - ioctlcmd GET_BUFINFO; - ioctlcmd AUDIOMODE; - ioctlcmd ECHOCANCEL; - ioctlcmd HDLCRAWMODE; - ioctlcmd HDLCFCSMODE; - ioctlcmd SPECIFY; - ioctlcmd SETLAW; - ioctlcmd SETLINEAR; - ioctlcmd GETCONFMUTE; - ioctlcmd ECHOTRAIN; - ioctlcmd SETTXBITS; - ioctlcmd GETRXBITS; - ioctlcmd SETPOLARITY; - ioctlcmd TONEDETECT; -}; - -/** - * \brief Zaptel IOCTL codes - */ -static struct ioctl_codes zt_ioctl_codes = { - .GET_BLOCKSIZE = ZT_GET_BLOCKSIZE, - .SET_BLOCKSIZE = ZT_SET_BLOCKSIZE, - .FLUSH = ZT_FLUSH, - .SYNC = ZT_SYNC, - .GET_PARAMS = ZT_GET_PARAMS, - .SET_PARAMS = ZT_SET_PARAMS, - .HOOK = ZT_HOOK, - .GETEVENT = ZT_GETEVENT, - .IOMUX = ZT_IOMUX, - .SPANSTAT = ZT_SPANSTAT, - .MAINT = ZT_MAINT, - .GETCONF = ZT_GETCONF, - .SETCONF = ZT_SETCONF, - .CONFLINK = ZT_CONFLINK, - .CONFDIAG = ZT_CONFDIAG, - .GETGAINS = ZT_GETGAINS, - .SETGAINS = ZT_SETGAINS, - .SPANCONFIG = ZT_SPANCONFIG, - .CHANCONFIG = ZT_CHANCONFIG, - .SET_BUFINFO = ZT_SET_BUFINFO, - .GET_BUFINFO = ZT_GET_BUFINFO, - .AUDIOMODE = ZT_AUDIOMODE, - .ECHOCANCEL = ZT_ECHOCANCEL, - .HDLCRAWMODE = ZT_HDLCRAWMODE, - .HDLCFCSMODE = ZT_HDLCFCSMODE, - .SPECIFY = ZT_SPECIFY, - .SETLAW = ZT_SETLAW, - .SETLINEAR = ZT_SETLINEAR, - .GETCONFMUTE = ZT_GETCONFMUTE, - .ECHOTRAIN = ZT_ECHOTRAIN, - .SETTXBITS = ZT_SETTXBITS, - .GETRXBITS = ZT_GETRXBITS, - .TONEDETECT = ZT_TONEDETECT, -}; - -/** - * \brief Dahdi IOCTL codes - */ -static struct ioctl_codes dahdi_ioctl_codes = { - .GET_BLOCKSIZE = DAHDI_GET_BLOCKSIZE, - .SET_BLOCKSIZE = DAHDI_SET_BLOCKSIZE, - .FLUSH = DAHDI_FLUSH, - .SYNC = DAHDI_SYNC, - .GET_PARAMS = DAHDI_GET_PARAMS, - .SET_PARAMS = DAHDI_SET_PARAMS, - .HOOK = DAHDI_HOOK, - .GETEVENT = DAHDI_GETEVENT, - .IOMUX = DAHDI_IOMUX, - .SPANSTAT = DAHDI_SPANSTAT, - .MAINT = DAHDI_MAINT, - .GETCONF = DAHDI_GETCONF, - .SETCONF = DAHDI_SETCONF, - .CONFLINK = DAHDI_CONFLINK, - .CONFDIAG = DAHDI_CONFDIAG, - .GETGAINS = DAHDI_GETGAINS, - .SETGAINS = DAHDI_SETGAINS, - .SPANCONFIG = DAHDI_SPANCONFIG, - .CHANCONFIG = DAHDI_CHANCONFIG, - .SET_BUFINFO = DAHDI_SET_BUFINFO, - .GET_BUFINFO = DAHDI_GET_BUFINFO, - .AUDIOMODE = DAHDI_AUDIOMODE, - .ECHOCANCEL = DAHDI_ECHOCANCEL, - .HDLCRAWMODE = DAHDI_HDLCRAWMODE, - .HDLCFCSMODE = DAHDI_HDLCFCSMODE, - .SPECIFY = DAHDI_SPECIFY, - .SETLAW = DAHDI_SETLAW, - .SETLINEAR = DAHDI_SETLINEAR, - .GETCONFMUTE = DAHDI_GETCONFMUTE, - .ECHOTRAIN = DAHDI_ECHOTRAIN, - .SETTXBITS = DAHDI_SETTXBITS, - .GETRXBITS = DAHDI_GETRXBITS, - .SETPOLARITY = DAHDI_SETPOLARITY, - .TONEDETECT = DAHDI_TONEDETECT, -}; - -#define ZT_INVALID_SOCKET -1 -static struct ioctl_codes codes; -static const char *ctlpath = NULL; -static const char *chanpath = NULL; - -static const char dahdi_ctlpath[] = "/dev/dahdi/ctl"; -static const char dahdi_chanpath[] = "/dev/dahdi/channel"; - -static const char zt_ctlpath[] = "/dev/zap/ctl"; -static const char zt_chanpath[] = "/dev/zap/channel"; - -static ftdm_socket_t CONTROL_FD = ZT_INVALID_SOCKET; - -FIO_SPAN_NEXT_EVENT_FUNCTION(zt_next_event); -FIO_SPAN_POLL_EVENT_FUNCTION(zt_poll_event); -FIO_CHANNEL_NEXT_EVENT_FUNCTION(zt_channel_next_event); - -/** - * \brief Initialises codec, and rx/tx gains - * \param g Structure for gains to be initialised - * \param rxgain RX gain value - * \param txgain TX gain value - * \param codec Codec - */ -static void zt_build_gains(struct zt_gains *g, float rxgain, float txgain, int codec) -{ - int j; - int k; - float linear_rxgain = pow(10.0, rxgain / 20.0); - float linear_txgain = pow(10.0, txgain / 20.0); - - switch (codec) { - case FTDM_CODEC_ALAW: - for (j = 0; j < (sizeof(g->receive_gain) / sizeof(g->receive_gain[0])); j++) { - if (rxgain) { - k = (int) (((float) alaw_to_linear(j)) * linear_rxgain); - if (k > 32767) k = 32767; - if (k < -32767) k = -32767; - g->receive_gain[j] = linear_to_alaw(k); - } else { - g->receive_gain[j] = j; - } - if (txgain) { - k = (int) (((float) alaw_to_linear(j)) * linear_txgain); - if (k > 32767) k = 32767; - if (k < -32767) k = -32767; - g->transmit_gain[j] = linear_to_alaw(k); - } else { - g->transmit_gain[j] = j; - } - } - break; - case FTDM_CODEC_ULAW: - for (j = 0; j < (sizeof(g->receive_gain) / sizeof(g->receive_gain[0])); j++) { - if (rxgain) { - k = (int) (((float) ulaw_to_linear(j)) * linear_rxgain); - if (k > 32767) k = 32767; - if (k < -32767) k = -32767; - g->receive_gain[j] = linear_to_ulaw(k); - } else { - g->receive_gain[j] = j; - } - if (txgain) { - k = (int) (((float) ulaw_to_linear(j)) * linear_txgain); - if (k > 32767) k = 32767; - if (k < -32767) k = -32767; - g->transmit_gain[j] = linear_to_ulaw(k); - } else { - g->transmit_gain[j] = j; - } - } - break; - } -} - -/** - * \brief Initialises a range of Zaptel/DAHDI channels - * \param span FreeTDM span - * \param start Initial wanpipe channel number - * \param end Final wanpipe channel number - * \param type FreeTDM channel type - * \param name FreeTDM span name - * \param number FreeTDM span number - * \param cas_bits CAS bits - * \return number of spans configured - */ -static unsigned zt_open_range(ftdm_span_t *span, unsigned start, unsigned end, ftdm_chan_type_t type, char *name, char *number, unsigned char cas_bits) -{ - unsigned configured = 0, x; - zt_params_t ztp; - zt_tone_mode_t mode = 0; - - memset(&ztp, 0, sizeof(ztp)); - - if (type == FTDM_CHAN_TYPE_CAS) { - ftdm_log(FTDM_LOG_DEBUG, "Configuring CAS channels with abcd == 0x%X\n", cas_bits); - } - for(x = start; x < end; x++) { - ftdm_channel_t *ftdmchan; - ftdm_socket_t sockfd = ZT_INVALID_SOCKET; - int len; - - sockfd = open(chanpath, O_RDWR); - if (sockfd != ZT_INVALID_SOCKET && ftdm_span_add_channel(span, sockfd, type, &ftdmchan) == FTDM_SUCCESS) { - - if (ioctl(sockfd, codes.SPECIFY, &x)) { - ftdm_log(FTDM_LOG_ERROR, "failure configuring device %s chan %d fd %d (%s)\n", chanpath, x, sockfd, strerror(errno)); - close(sockfd); - continue; - } - - if (ftdmchan->type == FTDM_CHAN_TYPE_DQ921) { - struct zt_bufferinfo binfo; - memset(&binfo, 0, sizeof(binfo)); - binfo.txbufpolicy = 0; - binfo.rxbufpolicy = 0; - binfo.numbufs = 32; - binfo.bufsize = 1024; - if (ioctl(sockfd, codes.SET_BUFINFO, &binfo)) { - ftdm_log(FTDM_LOG_ERROR, "failure configuring device %s as FreeTDM device %d:%d fd:%d\n", chanpath, ftdmchan->span_id, ftdmchan->chan_id, sockfd); - close(sockfd); - continue; - } - } - - if (type == FTDM_CHAN_TYPE_FXS || type == FTDM_CHAN_TYPE_FXO) { - struct zt_chanconfig cc; - memset(&cc, 0, sizeof(cc)); - cc.chan = cc.master = x; - - switch(type) { - case FTDM_CHAN_TYPE_FXS: - { - switch(span->start_type) { - case FTDM_ANALOG_START_KEWL: - cc.sigtype = ZT_SIG_FXOKS; - break; - case FTDM_ANALOG_START_LOOP: - cc.sigtype = ZT_SIG_FXOLS; - break; - case FTDM_ANALOG_START_GROUND: - cc.sigtype = ZT_SIG_FXOGS; - break; - default: - break; - } - } - break; - case FTDM_CHAN_TYPE_FXO: - { - switch(span->start_type) { - case FTDM_ANALOG_START_KEWL: - cc.sigtype = ZT_SIG_FXSKS; - break; - case FTDM_ANALOG_START_LOOP: - cc.sigtype = ZT_SIG_FXSLS; - break; - case FTDM_ANALOG_START_GROUND: - cc.sigtype = ZT_SIG_FXSGS; - break; - default: - break; - } - } - break; - default: - break; - } - - if (ioctl(CONTROL_FD, codes.CHANCONFIG, &cc)) { - ftdm_log(FTDM_LOG_WARNING, "this ioctl fails in older zaptel but is harmless if you used ztcfg\n[device %s chan %d fd %d (%s)]\n", chanpath, x, CONTROL_FD, strerror(errno)); - } - } - - if (type == FTDM_CHAN_TYPE_CAS) { - struct zt_chanconfig cc; - memset(&cc, 0, sizeof(cc)); - cc.chan = cc.master = x; - cc.sigtype = ZT_SIG_CAS; - cc.idlebits = cas_bits; - if (ioctl(CONTROL_FD, codes.CHANCONFIG, &cc)) { - ftdm_log(FTDM_LOG_ERROR, "failure configuring device %s as FreeTDM device %d:%d fd:%d err:%s\n", chanpath, ftdmchan->span_id, ftdmchan->chan_id, sockfd, strerror(errno)); - close(sockfd); - continue; - } - } - - if (ftdmchan->type != FTDM_CHAN_TYPE_DQ921 && ftdmchan->type != FTDM_CHAN_TYPE_DQ931) { - len = zt_globals.codec_ms * 8; - if (ioctl(ftdmchan->sockfd, codes.SET_BLOCKSIZE, &len)) { - ftdm_log(FTDM_LOG_ERROR, "failure configuring device %s as FreeTDM device %d:%d fd:%d err:%s\n", - chanpath, ftdmchan->span_id, ftdmchan->chan_id, sockfd, strerror(errno)); - close(sockfd); - continue; - } - - ftdmchan->packet_len = len; - ftdmchan->effective_interval = ftdmchan->native_interval = ftdmchan->packet_len / 8; - - if (ftdmchan->effective_codec == FTDM_CODEC_SLIN) { - ftdmchan->packet_len *= 2; - } - } - - if (ioctl(sockfd, codes.GET_PARAMS, &ztp) < 0) { - ftdm_log(FTDM_LOG_ERROR, "failure configuring device %s as FreeTDM device %d:%d fd:%d\n", chanpath, ftdmchan->span_id, ftdmchan->chan_id, sockfd); - close(sockfd); - continue; - } - - if (ftdmchan->type == FTDM_CHAN_TYPE_DQ921) { - if ( - (ztp.sig_type != ZT_SIG_HDLCRAW) && - (ztp.sig_type != ZT_SIG_HDLCFCS) && - (ztp.sig_type != ZT_SIG_HARDHDLC) - ) { - ftdm_log(FTDM_LOG_ERROR, "Failure configuring device %s as FreeTDM device %d:%d fd:%d, hardware signaling is not HDLC, fix your Zap/DAHDI configuration!\n", chanpath, ftdmchan->span_id, ftdmchan->chan_id, sockfd); - close(sockfd); - continue; - } - } - - ftdm_log(FTDM_LOG_INFO, "configuring device %s channel %d as FreeTDM device %d:%d fd:%d\n", chanpath, x, ftdmchan->span_id, ftdmchan->chan_id, sockfd); - - ftdmchan->rate = 8000; - ftdmchan->physical_span_id = ztp.span_no; - ftdmchan->physical_chan_id = ztp.chan_no; - - if (type == FTDM_CHAN_TYPE_FXS || type == FTDM_CHAN_TYPE_FXO || type == FTDM_CHAN_TYPE_EM || type == FTDM_CHAN_TYPE_B) { - if (ztp.g711_type == ZT_G711_ALAW) { - ftdmchan->native_codec = ftdmchan->effective_codec = FTDM_CODEC_ALAW; - } else if (ztp.g711_type == ZT_G711_MULAW) { - ftdmchan->native_codec = ftdmchan->effective_codec = FTDM_CODEC_ULAW; - } else { - int type; - - if (ftdmchan->span->trunk_type == FTDM_TRUNK_E1) { - type = FTDM_CODEC_ALAW; - } else { - type = FTDM_CODEC_ULAW; - } - - ftdmchan->native_codec = ftdmchan->effective_codec = type; - - } - } - - ztp.wink_time = zt_globals.wink_ms; - ztp.flash_time = zt_globals.flash_ms; - - if (ioctl(sockfd, codes.SET_PARAMS, &ztp) < 0) { - ftdm_log(FTDM_LOG_ERROR, "failure configuring device %s as FreeTDM device %d:%d fd:%d\n", chanpath, ftdmchan->span_id, ftdmchan->chan_id, sockfd); - close(sockfd); - continue; - } - - mode = ZT_TONEDETECT_ON | ZT_TONEDETECT_MUTE; - if (ioctl(sockfd, codes.TONEDETECT, &mode)) { - ftdm_log(FTDM_LOG_DEBUG, "HW DTMF not available on FreeTDM device %d:%d fd:%d\n", ftdmchan->span_id, ftdmchan->chan_id, sockfd); - } else { - ftdm_log(FTDM_LOG_DEBUG, "HW DTMF available on FreeTDM device %d:%d fd:%d\n", ftdmchan->span_id, ftdmchan->chan_id, sockfd); - ftdm_channel_set_feature(ftdmchan, FTDM_CHANNEL_FEATURE_DTMF_DETECT); - mode = 0; - ioctl(sockfd, codes.TONEDETECT, &mode); - } - - if (!ftdm_strlen_zero(name)) { - ftdm_copy_string(ftdmchan->chan_name, name, sizeof(ftdmchan->chan_name)); - } - if (!ftdm_strlen_zero(number)) { - ftdm_copy_string(ftdmchan->chan_number, number, sizeof(ftdmchan->chan_number)); - } - - configured++; - } else { - ftdm_log(FTDM_LOG_ERROR, "failure configuring device %s\n", chanpath); - } - } - - - - return configured; -} - -/** - * \brief Initialises a freetdm Zaptel/DAHDI span from a configuration string - * \param span FreeTDM span - * \param str Configuration string - * \param type FreeTDM span type - * \param name FreeTDM span name - * \param number FreeTDM span number - * \return Success or failure - */ -static FIO_CONFIGURE_SPAN_FUNCTION(zt_configure_span) -{ - - int items, i; - char *mydata, *item_list[10]; - char *ch, *mx; - unsigned char cas_bits = 0; - int channo; - int top = 0; - unsigned configured = 0; - - assert(str != NULL); - - - mydata = ftdm_strdup(str); - assert(mydata != NULL); - - - items = ftdm_separate_string(mydata, ',', item_list, (sizeof(item_list) / sizeof(item_list[0]))); - - for(i = 0; i < items; i++) { - ch = item_list[i]; - - if (!(ch)) { - ftdm_log(FTDM_LOG_ERROR, "Invalid input\n"); - continue; - } - - channo = atoi(ch); - - if (channo < 0) { - ftdm_log(FTDM_LOG_ERROR, "Invalid channel number %d\n", channo); - continue; - } - - if ((mx = strchr(ch, '-'))) { - mx++; - top = atoi(mx) + 1; - } else { - top = channo + 1; - } - - - if (top < 0) { - ftdm_log(FTDM_LOG_ERROR, "Invalid range number %d\n", top); - continue; - } - if (FTDM_CHAN_TYPE_CAS == type && ftdm_config_get_cas_bits(ch, &cas_bits)) { - ftdm_log(FTDM_LOG_ERROR, "Failed to get CAS bits in CAS channel\n"); - continue; - } - configured += zt_open_range(span, channo, top, type, name, number, cas_bits); - - } - - ftdm_safe_free(mydata); - - return configured; - -} - -/** - * \brief Process configuration variable for a Zaptel/DAHDI profile - * \param category Wanpipe profile name - * \param var Variable name - * \param val Variable value - * \param lineno Line number from configuration file - * \return Success - */ -static FIO_CONFIGURE_FUNCTION(zt_configure) -{ - - int num; - float fnum; - - if (!strcasecmp(category, "defaults")) { - if (!strcasecmp(var, "codec_ms")) { - num = atoi(val); - if (num < 10 || num > 60) { - ftdm_log(FTDM_LOG_WARNING, "invalid codec ms at line %d\n", lineno); - } else { - zt_globals.codec_ms = num; - } - } else if (!strcasecmp(var, "wink_ms")) { - num = atoi(val); - if (num < 50 || num > 3000) { - ftdm_log(FTDM_LOG_WARNING, "invalid wink ms at line %d\n", lineno); - } else { - zt_globals.wink_ms = num; - } - } else if (!strcasecmp(var, "flash_ms")) { - num = atoi(val); - if (num < 50 || num > 3000) { - ftdm_log(FTDM_LOG_WARNING, "invalid flash ms at line %d\n", lineno); - } else { - zt_globals.flash_ms = num; - } - } else if (!strcasecmp(var, "echo_cancel_level")) { - num = atoi(val); - if (num < 0 || num > 1024) { - ftdm_log(FTDM_LOG_WARNING, "invalid echo can val at line %d\n", lineno); - } else { - zt_globals.eclevel = num; - } - } else if (!strcasecmp(var, "echo_train_level")) { - if (zt_globals.eclevel < 1) { - ftdm_log(FTDM_LOG_WARNING, "can't set echo train level without setting echo cancel level first at line %d\n", lineno); - } else { - num = atoi(val); - if (num < 0 || num > 256) { - ftdm_log(FTDM_LOG_WARNING, "invalid echo train val at line %d\n", lineno); - } else { - zt_globals.etlevel = num; - } - } - } else if (!strcasecmp(var, "rxgain")) { - fnum = (float)atof(val); - if (fnum < -100.0 || fnum > 100.0) { - ftdm_log(FTDM_LOG_WARNING, "invalid rxgain val at line %d\n", lineno); - } else { - zt_globals.rxgain = fnum; - ftdm_log(FTDM_LOG_INFO, "Setting rxgain val to %f\n", fnum); - } - } else if (!strcasecmp(var, "txgain")) { - fnum = (float)atof(val); - if (fnum < -100.0 || fnum > 100.0) { - ftdm_log(FTDM_LOG_WARNING, "invalid txgain val at line %d\n", lineno); - } else { - zt_globals.txgain = fnum; - ftdm_log(FTDM_LOG_INFO, "Setting txgain val to %f\n", fnum); - } - } else { - ftdm_log(FTDM_LOG_WARNING, "Ignoring unknown setting '%s'\n", var); - } - } - - return FTDM_SUCCESS; -} - -/** - * \brief Opens a Zaptel/DAHDI channel - * \param ftdmchan Channel to open - * \return Success or failure - */ -static FIO_OPEN_FUNCTION(zt_open) -{ - ftdm_channel_set_feature(ftdmchan, FTDM_CHANNEL_FEATURE_INTERVAL); - - if (ftdmchan->type == FTDM_CHAN_TYPE_DQ921 || ftdmchan->type == FTDM_CHAN_TYPE_DQ931) { - ftdmchan->native_codec = ftdmchan->effective_codec = FTDM_CODEC_NONE; - } else { - int blocksize = zt_globals.codec_ms * (ftdmchan->rate / 1000); - int err; - if ((err = ioctl(ftdmchan->sockfd, codes.SET_BLOCKSIZE, &blocksize))) { - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "%s", strerror(errno)); - return FTDM_FAIL; - } else { - ftdmchan->effective_interval = ftdmchan->native_interval; - ftdmchan->packet_len = blocksize; - ftdmchan->native_codec = ftdmchan->effective_codec; - } - - if (ftdmchan->type == FTDM_CHAN_TYPE_B) { - int one = 1; - if (ioctl(ftdmchan->sockfd, codes.AUDIOMODE, &one)) { - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "%s", strerror(errno)); - ftdm_log(FTDM_LOG_ERROR, "%s\n", ftdmchan->last_error); - return FTDM_FAIL; - } - } - if (zt_globals.rxgain || zt_globals.txgain) { - struct zt_gains gains; - memset(&gains, 0, sizeof(gains)); - - gains.chan_no = ftdmchan->physical_chan_id; - zt_build_gains(&gains, zt_globals.rxgain, zt_globals.txgain, ftdmchan->native_codec); - - if (zt_globals.rxgain) - ftdm_log(FTDM_LOG_INFO, "Setting rxgain to %f on channel %d\n", zt_globals.rxgain, gains.chan_no); - - if (zt_globals.txgain) - ftdm_log(FTDM_LOG_INFO, "Setting txgain to %f on channel %d\n", zt_globals.txgain, gains.chan_no); - - if (ioctl(ftdmchan->sockfd, codes.SETGAINS, &gains) < 0) { - ftdm_log(FTDM_LOG_ERROR, "failure configuring device %s as FreeTDM device %d:%d fd:%d\n", chanpath, ftdmchan->span_id, ftdmchan->chan_id, ftdmchan->sockfd); - } - } - - if (1) { - int len = zt_globals.eclevel; - if (len) { - ftdm_log(FTDM_LOG_INFO, "Setting echo cancel to %d taps for %d:%d\n", len, ftdmchan->span_id, ftdmchan->chan_id); - } else { - ftdm_log(FTDM_LOG_INFO, "Disable echo cancel for %d:%d\n", ftdmchan->span_id, ftdmchan->chan_id); - } - if (ioctl(ftdmchan->sockfd, codes.ECHOCANCEL, &len)) { - ftdm_log(FTDM_LOG_WARNING, "Echo cancel not available for %d:%d\n", ftdmchan->span_id, ftdmchan->chan_id); - } else if (zt_globals.etlevel > 0) { - len = zt_globals.etlevel; - if (ioctl(ftdmchan->sockfd, codes.ECHOTRAIN, &len)) { - ftdm_log(FTDM_LOG_WARNING, "Echo training not available for %d:%d\n", ftdmchan->span_id, ftdmchan->chan_id); - } - } - } - } - return FTDM_SUCCESS; -} - -/** - * \brief Closes Zaptel/DAHDI channel - * \param ftdmchan Channel to close - * \return Success - */ -static FIO_CLOSE_FUNCTION(zt_close) -{ - if (ftdmchan->type == FTDM_CHAN_TYPE_B) { - int value = 0; /* disable audio mode */ - if (ioctl(ftdmchan->sockfd, codes.AUDIOMODE, &value)) { - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "%s", strerror(errno)); - ftdm_log(FTDM_LOG_ERROR, "%s\n", ftdmchan->last_error); - return FTDM_FAIL; - } - } - return FTDM_SUCCESS; -} - -/** - * \brief Executes a FreeTDM command on a Zaptel/DAHDI channel - * \param ftdmchan Channel to execute command on - * \param command FreeTDM command to execute - * \param obj Object (unused) - * \return Success or failure - */ -static FIO_COMMAND_FUNCTION(zt_command) -{ - zt_params_t ztp; - int err = 0; - - memset(&ztp, 0, sizeof(ztp)); - - switch(command) { - case FTDM_COMMAND_ENABLE_ECHOCANCEL: - { - int level = FTDM_COMMAND_OBJ_INT; - err = ioctl(ftdmchan->sockfd, codes.ECHOCANCEL, &level); - FTDM_COMMAND_OBJ_INT = level; - } - case FTDM_COMMAND_DISABLE_ECHOCANCEL: - { - int level = 0; - err = ioctl(ftdmchan->sockfd, codes.ECHOCANCEL, &level); - FTDM_COMMAND_OBJ_INT = level; - } - break; - case FTDM_COMMAND_ENABLE_ECHOTRAIN: - { - int level = FTDM_COMMAND_OBJ_INT; - err = ioctl(ftdmchan->sockfd, codes.ECHOTRAIN, &level); - FTDM_COMMAND_OBJ_INT = level; - } - case FTDM_COMMAND_DISABLE_ECHOTRAIN: - { - int level = 0; - err = ioctl(ftdmchan->sockfd, codes.ECHOTRAIN, &level); - FTDM_COMMAND_OBJ_INT = level; - } - break; - case FTDM_COMMAND_OFFHOOK: - { - int command = ZT_OFFHOOK; - if (ioctl(ftdmchan->sockfd, codes.HOOK, &command)) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "OFFHOOK Failed"); - return FTDM_FAIL; - } - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Channel is now offhook\n"); - ftdm_set_flag_locked(ftdmchan, FTDM_CHANNEL_OFFHOOK); - } - break; - case FTDM_COMMAND_ONHOOK: - { - int command = ZT_ONHOOK; - if (ioctl(ftdmchan->sockfd, codes.HOOK, &command)) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "ONHOOK Failed"); - return FTDM_FAIL; - } - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Channel is now onhook\n"); - ftdm_clear_flag_locked(ftdmchan, FTDM_CHANNEL_OFFHOOK); - } - break; - case FTDM_COMMAND_FLASH: - { - int command = ZT_FLASH; - if (ioctl(ftdmchan->sockfd, codes.HOOK, &command)) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "FLASH Failed"); - return FTDM_FAIL; - } - } - break; - case FTDM_COMMAND_WINK: - { - int command = ZT_WINK; - if (ioctl(ftdmchan->sockfd, codes.HOOK, &command)) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "WINK Failed"); - return FTDM_FAIL; - } - } - break; - case FTDM_COMMAND_GENERATE_RING_ON: - { - int command = ZT_RING; - if (ioctl(ftdmchan->sockfd, codes.HOOK, &command)) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "RING Failed"); - return FTDM_FAIL; - } - ftdm_set_flag_locked(ftdmchan, FTDM_CHANNEL_RINGING); - } - break; - case FTDM_COMMAND_GENERATE_RING_OFF: - { - int command = ZT_RINGOFF; - if (ioctl(ftdmchan->sockfd, codes.HOOK, &command)) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "Ring-off Failed"); - return FTDM_FAIL; - } - ftdm_clear_flag_locked(ftdmchan, FTDM_CHANNEL_RINGING); - } - break; - case FTDM_COMMAND_GET_INTERVAL: - { - - if (!(err = ioctl(ftdmchan->sockfd, codes.GET_BLOCKSIZE, &ftdmchan->packet_len))) { - ftdmchan->native_interval = ftdmchan->packet_len / 8; - if (ftdmchan->effective_codec == FTDM_CODEC_SLIN) { - ftdmchan->packet_len *= 2; - } - FTDM_COMMAND_OBJ_INT = ftdmchan->native_interval; - } - } - break; - case FTDM_COMMAND_SET_INTERVAL: - { - int interval = FTDM_COMMAND_OBJ_INT; - int len = interval * 8; - - if (!(err = ioctl(ftdmchan->sockfd, codes.SET_BLOCKSIZE, &len))) { - ftdmchan->packet_len = len; - ftdmchan->effective_interval = ftdmchan->native_interval = ftdmchan->packet_len / 8; - - if (ftdmchan->effective_codec == FTDM_CODEC_SLIN) { - ftdmchan->packet_len *= 2; - } - } - } - break; - case FTDM_COMMAND_SET_CAS_BITS: - { - int bits = FTDM_COMMAND_OBJ_INT; - err = ioctl(ftdmchan->sockfd, codes.SETTXBITS, &bits); - } - break; - case FTDM_COMMAND_GET_CAS_BITS: - { - err = ioctl(ftdmchan->sockfd, codes.GETRXBITS, &ftdmchan->rx_cas_bits); - if (!err) { - FTDM_COMMAND_OBJ_INT = ftdmchan->rx_cas_bits; - } - } - break; - case FTDM_COMMAND_FLUSH_TX_BUFFERS: - { - int flushmode = ZT_FLUSH_WRITE; - err = ioctl(ftdmchan->sockfd, codes.FLUSH, &flushmode); - } - break; - case FTDM_COMMAND_SET_POLARITY: - { - ftdm_polarity_t polarity = FTDM_COMMAND_OBJ_INT; - err = ioctl(ftdmchan->sockfd, codes.SETPOLARITY, polarity); - if (!err) { - ftdmchan->polarity = polarity; - } - } - break; - case FTDM_COMMAND_FLUSH_RX_BUFFERS: - { - int flushmode = ZT_FLUSH_READ; - err = ioctl(ftdmchan->sockfd, codes.FLUSH, &flushmode); - } - break; - case FTDM_COMMAND_FLUSH_BUFFERS: - { - int flushmode = ZT_FLUSH_BOTH; - err = ioctl(ftdmchan->sockfd, codes.FLUSH, &flushmode); - } - break; - case FTDM_COMMAND_SET_RX_QUEUE_SIZE: - case FTDM_COMMAND_SET_TX_QUEUE_SIZE: - /* little white lie ... eventually we can implement this, in the meantime, not worth the effort - and this is only used by some sig modules such as ftmod_r2 to behave bettter under load */ - err = 0; - break; - case FTDM_COMMAND_ENABLE_DTMF_DETECT: - { - zt_tone_mode_t mode = ZT_TONEDETECT_ON | ZT_TONEDETECT_MUTE; - err = ioctl(ftdmchan->sockfd, codes.TONEDETECT, &mode); - } - break; - case FTDM_COMMAND_DISABLE_DTMF_DETECT: - { - zt_tone_mode_t mode = 0; - err = ioctl(ftdmchan->sockfd, codes.TONEDETECT, &mode); - } - break; - default: - err = FTDM_NOTIMPL; - break; - }; - - if (err && err != FTDM_NOTIMPL) { - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "%s", strerror(errno)); - return FTDM_FAIL; - } - - - return err == 0 ? FTDM_SUCCESS : err; -} - -/** - * \brief Gets alarms from a Zaptel/DAHDI channel - * \param ftdmchan Channel to get alarms from - * \return Success or failure - */ -static FIO_GET_ALARMS_FUNCTION(zt_get_alarms) -{ - struct zt_spaninfo info; - zt_params_t params; - - memset(&info, 0, sizeof(info)); - info.span_no = ftdmchan->physical_span_id; - - memset(¶ms, 0, sizeof(params)); - - if (ioctl(CONTROL_FD, codes.SPANSTAT, &info)) { - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "ioctl failed (%s)", strerror(errno)); - snprintf(ftdmchan->span->last_error, sizeof(ftdmchan->span->last_error), "ioctl failed (%s)", strerror(errno)); - return FTDM_FAIL; - } - - ftdmchan->alarm_flags = info.alarms; - - /* get channel alarms if span has no alarms */ - if (info.alarms == FTDM_ALARM_NONE) { - if (ioctl(ftdmchan->sockfd, codes.GET_PARAMS, ¶ms)) { - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "ioctl failed (%s)", strerror(errno)); - snprintf(ftdmchan->span->last_error, sizeof(ftdmchan->span->last_error), "ioctl failed (%s)", strerror(errno)); - return FTDM_FAIL; - } - - if (params.chan_alarms > 0) { - if (params.chan_alarms == DAHDI_ALARM_YELLOW) { - ftdmchan->alarm_flags = FTDM_ALARM_YELLOW; - } - else if (params.chan_alarms == DAHDI_ALARM_BLUE) { - ftdmchan->alarm_flags = FTDM_ALARM_BLUE; - } - else { - ftdmchan->alarm_flags = FTDM_ALARM_RED; - } - } - } - - return FTDM_SUCCESS; -} - -#define ftdm_zt_set_event_pending(fchan) \ - do { \ - ftdm_set_io_flag(fchan, FTDM_CHANNEL_IO_EVENT); \ - fchan->last_event_time = ftdm_current_time_in_ms(); \ - } while (0); - -#define ftdm_zt_store_chan_event(fchan, revent) \ - do { \ - if (fchan->io_data) { \ - ftdm_log_chan(fchan, FTDM_LOG_WARNING, "Dropping event %d, not retrieved on time\n", revent); \ - } \ - fchan->io_data = (void *)zt_event_id; \ - ftdm_zt_set_event_pending(fchan); \ - } while (0); - -/** - * \brief Waits for an event on a Zaptel/DAHDI channel - * \param ftdmchan Channel to open - * \param flags Type of event to wait for - * \param to Time to wait (in ms) - * \return Success, failure or timeout - */ -static FIO_WAIT_FUNCTION(zt_wait) -{ - int32_t inflags = 0; - int result; - struct pollfd pfds[1]; - - if (*flags & FTDM_READ) { - inflags |= POLLIN; - } - - if (*flags & FTDM_WRITE) { - inflags |= POLLOUT; - } - - if (*flags & FTDM_EVENTS) { - inflags |= POLLPRI; - } - -pollagain: - memset(&pfds[0], 0, sizeof(pfds[0])); - pfds[0].fd = ftdmchan->sockfd; - pfds[0].events = inflags; - result = poll(pfds, 1, to); - *flags = FTDM_NO_FLAGS; - - if (result < 0 && errno == EINTR) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "DAHDI wait got interrupted, trying again\n"); - goto pollagain; - } - - if (pfds[0].revents & POLLERR) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "DAHDI device got POLLERR\n"); - result = -1; - } - - if (result > 0) { - inflags = pfds[0].revents; - } - - if (result < 0){ - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "Poll failed"); - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Failed to poll DAHDI device: %s\n", strerror(errno)); - return FTDM_FAIL; - } - - if (result == 0) { - return FTDM_TIMEOUT; - } - - if (inflags & POLLIN) { - *flags |= FTDM_READ; - } - - if (inflags & POLLOUT) { - *flags |= FTDM_WRITE; - } - - if ((inflags & POLLPRI) || (ftdmchan->io_data && (*flags & FTDM_EVENTS))) { - *flags |= FTDM_EVENTS; - } - - return FTDM_SUCCESS; - -} - -/** - * \brief Checks for events on a Zaptel/DAHDI span - * \param span Span to check for events - * \param ms Time to wait for event - * \return Success if event is waiting or failure if not - */ -FIO_SPAN_POLL_EVENT_FUNCTION(zt_poll_event) -{ - struct pollfd pfds[FTDM_MAX_CHANNELS_SPAN]; - uint32_t i, j = 0, k = 0; - int r; - - ftdm_unused_arg(poll_events); - - for(i = 1; i <= span->chan_count; i++) { - memset(&pfds[j], 0, sizeof(pfds[j])); - pfds[j].fd = span->channels[i]->sockfd; - pfds[j].events = POLLPRI; - j++; - } - - r = poll(pfds, j, ms); - - if (r == 0) { - return FTDM_TIMEOUT; - } else if (r < 0) { - snprintf(span->last_error, sizeof(span->last_error), "%s", strerror(errno)); - return FTDM_FAIL; - } - - for(i = 1; i <= span->chan_count; i++) { - - ftdm_channel_lock(span->channels[i]); - - if (pfds[i-1].revents & POLLERR) { - ftdm_log_chan(span->channels[i], FTDM_LOG_ERROR, "POLLERR, flags=%d\n", pfds[i-1].events); - - ftdm_channel_unlock(span->channels[i]); - - continue; - } - if ((pfds[i-1].revents & POLLPRI) || (span->channels[i]->io_data)) { - ftdm_zt_set_event_pending(span->channels[i]); - k++; - } - if (pfds[i-1].revents & POLLIN) { - ftdm_set_io_flag(span->channels[i], FTDM_CHANNEL_IO_READ); - } - if (pfds[i-1].revents & POLLOUT) { - ftdm_set_io_flag(span->channels[i], FTDM_CHANNEL_IO_WRITE); - } - - ftdm_channel_unlock(span->channels[i]); - - } - - if (!k) { - snprintf(span->last_error, sizeof(span->last_error), "no matching descriptor"); - } - - return k ? FTDM_SUCCESS : FTDM_FAIL; -} - -static __inline__ int handle_dtmf_event(ftdm_channel_t *fchan, zt_event_t zt_event_id) -{ - if ((zt_event_id & ZT_EVENT_DTMFUP)) { - int digit = (zt_event_id & (~ZT_EVENT_DTMFUP)); - char tmp_dtmf[2] = { digit, 0 }; - ftdm_log_chan(fchan, FTDM_LOG_DEBUG, "DTMF UP [%d]\n", digit); - ftdm_channel_queue_dtmf(fchan, tmp_dtmf); - return 0; - } else if ((zt_event_id & ZT_EVENT_DTMFDOWN)) { - int digit = (zt_event_id & (~ZT_EVENT_DTMFDOWN)); - ftdm_log_chan(fchan, FTDM_LOG_DEBUG, "DTMF DOWN [%d]\n", digit); - return 0; - } else { - return -1; - } -} - -/** - * \brief Process an event from a ftdmchan and set the proper OOB event_id. The channel must be locked. - * \param fchan Channel to retrieve event from - * \param event_id Pointer to OOB event id - * \param zt_event_id Zaptel event id - * \return FTDM_SUCCESS or FTDM_FAIL - */ -static __inline__ ftdm_status_t zt_channel_process_event(ftdm_channel_t *fchan, ftdm_oob_event_t *event_id, zt_event_t zt_event_id) -{ - ftdm_log_chan(fchan, FTDM_LOG_DEBUG, "Processing zap hardware event %d\n", zt_event_id); - switch(zt_event_id) { - case ZT_EVENT_RINGEROFF: - { - ftdm_log_chan_msg(fchan, FTDM_LOG_DEBUG, "ZT RINGER OFF\n"); - *event_id = FTDM_OOB_NOOP; - } - break; - case ZT_EVENT_RINGERON: - { - ftdm_log_chan_msg(fchan, FTDM_LOG_DEBUG, "ZT RINGER ON\n"); - *event_id = FTDM_OOB_NOOP; - } - break; - case ZT_EVENT_RINGBEGIN: - { - *event_id = FTDM_OOB_RING_START; - } - break; - case ZT_EVENT_ONHOOK: - { - *event_id = FTDM_OOB_ONHOOK; - } - break; - case ZT_EVENT_WINKFLASH: - { - if (fchan->state == FTDM_CHANNEL_STATE_DOWN || fchan->state == FTDM_CHANNEL_STATE_DIALING) { - *event_id = FTDM_OOB_WINK; - } else { - *event_id = FTDM_OOB_FLASH; - } - } - break; - case ZT_EVENT_RINGOFFHOOK: - { - *event_id = FTDM_OOB_NOOP; - if (fchan->type == FTDM_CHAN_TYPE_FXS || (fchan->type == FTDM_CHAN_TYPE_EM && fchan->state != FTDM_CHANNEL_STATE_UP)) { - if (fchan->type != FTDM_CHAN_TYPE_EM) { - /* In E&M we're supposed to set this flag only when the local side goes offhook, not the remote */ - ftdm_set_flag_locked(fchan, FTDM_CHANNEL_OFFHOOK); - } - - /* For E&M let's count the ring count (it seems sometimes we receive RINGOFFHOOK once before the other end - * answers, then another RINGOFFHOOK when the other end answers?? anyways, now we count rings before delivering the - * offhook event ... the E&M signaling code in ftmod_analog_em also polls the RBS bits looking for answer, just to - * be safe and not rely on this event, so even if this event does not arrive, when there is answer supervision - * the analog signaling code should detect the cas persistance pattern and answer */ - if (fchan->type == FTDM_CHAN_TYPE_EM && ftdm_test_flag(fchan, FTDM_CHANNEL_OUTBOUND)) { - fchan->ring_count++; - /* perhaps some day we'll make this configurable, but since I am not even sure what the hell is going on - * no point in making a configuration option for something that may not be technically correct */ - if (fchan->ring_count == 2) { - *event_id = FTDM_OOB_OFFHOOK; - } - } else { - *event_id = FTDM_OOB_OFFHOOK; - } - } else if (fchan->type == FTDM_CHAN_TYPE_FXO) { - *event_id = FTDM_OOB_RING_START; - } - } - break; - case ZT_EVENT_ALARM: - { - *event_id = FTDM_OOB_ALARM_TRAP; - } - break; - case ZT_EVENT_NOALARM: - { - *event_id = FTDM_OOB_ALARM_CLEAR; - } - break; - case ZT_EVENT_BITSCHANGED: - { - *event_id = FTDM_OOB_CAS_BITS_CHANGE; - int bits = 0; - int err = ioctl(fchan->sockfd, codes.GETRXBITS, &bits); - if (err) { - return FTDM_FAIL; - } - fchan->rx_cas_bits = bits; - } - break; - case ZT_EVENT_BADFCS: - { - ftdm_log_chan_msg(fchan, FTDM_LOG_ERROR, "Bad frame checksum (ZT_EVENT_BADFCS)\n"); - *event_id = FTDM_OOB_NOOP; /* What else could we do? */ - } - break; - case ZT_EVENT_OVERRUN: - { - ftdm_log_chan_msg(fchan, FTDM_LOG_ERROR, "HDLC frame overrun (ZT_EVENT_OVERRUN)\n"); - *event_id = FTDM_OOB_NOOP; /* What else could we do? */ - } - break; - case ZT_EVENT_ABORT: - { - ftdm_log_chan_msg(fchan, FTDM_LOG_ERROR, "HDLC abort frame received (ZT_EVENT_ABORT)\n"); - *event_id = FTDM_OOB_NOOP; /* What else could we do? */ - } - break; - case ZT_EVENT_POLARITY: - { - ftdm_log_chan_msg(fchan, FTDM_LOG_ERROR, "Got polarity reverse (ZT_EVENT_POLARITY)\n"); - *event_id = FTDM_OOB_POLARITY_REVERSE; - } - break; - case ZT_EVENT_NONE: - { - ftdm_log_chan_msg(fchan, FTDM_LOG_DEBUG, "No event\n"); - *event_id = FTDM_OOB_NOOP; - } - break; - default: - { - if (handle_dtmf_event(fchan, zt_event_id)) { - ftdm_log_chan(fchan, FTDM_LOG_WARNING, "Unhandled event %d\n", zt_event_id); - *event_id = FTDM_OOB_INVALID; - } else { - *event_id = FTDM_OOB_NOOP; - } - } - break; - } - return FTDM_SUCCESS; -} - -/** - * \brief Retrieves an event from a ftdm channel - * \param ftdmchan Channel to retrieve event from - * \param event FreeTDM event to return - * \return Success or failure - */ -FIO_CHANNEL_NEXT_EVENT_FUNCTION(zt_channel_next_event) -{ - uint32_t event_id = FTDM_OOB_INVALID; - zt_event_t zt_event_id = 0; - ftdm_span_t *span = ftdmchan->span; - - if (ftdm_test_io_flag(ftdmchan, FTDM_CHANNEL_IO_EVENT)) { - ftdm_clear_io_flag(ftdmchan, FTDM_CHANNEL_IO_EVENT); - } - - if (ftdmchan->io_data) { - zt_event_id = (zt_event_t)ftdmchan->io_data; - ftdmchan->io_data = NULL; - } else if (ioctl(ftdmchan->sockfd, codes.GETEVENT, &zt_event_id) == -1) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Failed retrieving event from channel: %s\n", - strerror(errno)); - return FTDM_FAIL; - } - - /* the core already locked the channel for us, so it's safe to call zt_channel_process_event() here */ - if ((zt_channel_process_event(ftdmchan, &event_id, zt_event_id)) != FTDM_SUCCESS) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Failed to process DAHDI event %d from channel\n", zt_event_id); - return FTDM_FAIL; - } - - ftdmchan->last_event_time = 0; - span->event_header.e_type = FTDM_EVENT_OOB; - span->event_header.enum_id = event_id; - span->event_header.channel = ftdmchan; - *event = &span->event_header; - return FTDM_SUCCESS; -} - -/** - * \brief Retrieves an event from a Zaptel/DAHDI span - * \param span Span to retrieve event from - * \param event FreeTDM event to return - * \return Success or failure - */ -FIO_SPAN_NEXT_EVENT_FUNCTION(zt_next_event) -{ - uint32_t i, event_id = FTDM_OOB_INVALID; - zt_event_t zt_event_id = 0; - - for (i = 1; i <= span->chan_count; i++) { - ftdm_channel_t *fchan = span->channels[i]; - - ftdm_channel_lock(fchan); - - if (!ftdm_test_io_flag(fchan, FTDM_CHANNEL_IO_EVENT)) { - - ftdm_channel_unlock(fchan); - - continue; - } - - ftdm_clear_io_flag(fchan, FTDM_CHANNEL_IO_EVENT); - - if (fchan->io_data) { - zt_event_id = (zt_event_t)fchan->io_data; - fchan->io_data = NULL; - } else if (ioctl(fchan->sockfd, codes.GETEVENT, &zt_event_id) == -1) { - ftdm_log_chan(fchan, FTDM_LOG_ERROR, "Failed to retrieve DAHDI event from channel: %s\n", strerror(errno)); - - ftdm_channel_unlock(fchan); - - continue; - } - - if ((zt_channel_process_event(fchan, &event_id, zt_event_id)) != FTDM_SUCCESS) { - ftdm_log_chan(fchan, FTDM_LOG_ERROR, "Failed to process DAHDI event %d from channel\n", zt_event_id); - - ftdm_channel_unlock(fchan); - - return FTDM_FAIL; - } - - fchan->last_event_time = 0; - span->event_header.e_type = FTDM_EVENT_OOB; - span->event_header.enum_id = event_id; - span->event_header.channel = fchan; - *event = &span->event_header; - - ftdm_channel_unlock(fchan); - - return FTDM_SUCCESS; - } - - return FTDM_FAIL; -} - -/** - * \brief Reads data from a Zaptel/DAHDI channel - * \param ftdmchan Channel to read from - * \param data Data buffer - * \param datalen Size of data buffer - * \return Success, failure or timeout - */ -static FIO_READ_FUNCTION(zt_read) -{ - ftdm_ssize_t r = 0; - int read_errno = 0; - int errs = 0; - - while (errs++ < 30) { - r = read(ftdmchan->sockfd, data, *datalen); - if (r > 0) { - /* successful read, bail out now ... */ - break; - } - - /* Timeout ... retry after a bit */ - if (r == 0) { - ftdm_sleep(10); - if (errs) errs--; - continue; - } - - /* This gotta be an error, save errno in case we do printf(), ioctl() or other operations which may reset it */ - read_errno = errno; - if (read_errno == EAGAIN || read_errno == EINTR) { - /* Reasonable to retry under those errors */ - continue; - } - - /* When ELAST is returned, it means DAHDI has an out of band event ready and we won't be able to read anything until - * we retrieve the event using an ioctl(), so we try to retrieve it here ... */ - if (read_errno == ELAST) { - zt_event_t zt_event_id = 0; - if (ioctl(ftdmchan->sockfd, codes.GETEVENT, &zt_event_id) == -1) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Failed retrieving event after ELAST on read: %s\n", strerror(errno)); - r = -1; - break; - } - - if (handle_dtmf_event(ftdmchan, zt_event_id)) { - /* Enqueue this event for later */ - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Deferring event %d to be able to read data\n", zt_event_id); - ftdm_zt_store_chan_event(ftdmchan, zt_event_id); - } else { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Skipping one IO read cycle due to DTMF event processing\n"); - } - break; - } - - /* Read error, keep going unless to many errors force us to abort ...*/ - ftdm_log(FTDM_LOG_ERROR, "IO read failed: %s\n", strerror(read_errno)); - } - - if (r > 0) { - *datalen = r; - if (ftdmchan->type == FTDM_CHAN_TYPE_DQ921) { - *datalen -= 2; - } - return FTDM_SUCCESS; - } - else if (read_errno == ELAST) { - return FTDM_SUCCESS; - } - return r == 0 ? FTDM_TIMEOUT : FTDM_FAIL; -} - -/** - * \brief Writes data to a Zaptel/DAHDI channel - * \param ftdmchan Channel to write to - * \param data Data buffer - * \param datalen Size of data buffer - * \return Success or failure - */ -static FIO_WRITE_FUNCTION(zt_write) -{ - ftdm_ssize_t w = 0; - ftdm_size_t bytes = *datalen; - - if (ftdmchan->type == FTDM_CHAN_TYPE_DQ921) { - memset(data+bytes, 0, 2); - bytes += 2; - } - -tryagain: - w = write(ftdmchan->sockfd, data, bytes); - - if (w >= 0) { - *datalen = w; - return FTDM_SUCCESS; - } - - if (errno == ELAST) { - zt_event_t zt_event_id = 0; - if (ioctl(ftdmchan->sockfd, codes.GETEVENT, &zt_event_id) == -1) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Failed retrieving event after ELAST on write: %s\n", strerror(errno)); - return FTDM_FAIL; - } - - if (handle_dtmf_event(ftdmchan, zt_event_id)) { - /* Enqueue this event for later */ - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Deferring event %d to be able to write data\n", zt_event_id); - ftdm_zt_store_chan_event(ftdmchan, zt_event_id); - } - - goto tryagain; - } - - return FTDM_FAIL; -} - -/** - * \brief Destroys a Zaptel/DAHDI Channel - * \param ftdmchan Channel to destroy - * \return Success - */ -static FIO_CHANNEL_DESTROY_FUNCTION(zt_channel_destroy) -{ - close(ftdmchan->sockfd); - ftdmchan->sockfd = ZT_INVALID_SOCKET; - return FTDM_SUCCESS; -} - -/** - * \brief Global FreeTDM IO interface for Zaptel/DAHDI - */ -static ftdm_io_interface_t zt_interface; - -/** - * \brief Loads Zaptel/DAHDI IO module - * \param fio FreeTDM IO interface - * \return Success or failure - */ -static FIO_IO_LOAD_FUNCTION(zt_init) -{ - assert(fio != NULL); - struct stat statbuf; - memset(&zt_interface, 0, sizeof(zt_interface)); - memset(&zt_globals, 0, sizeof(zt_globals)); - - if (!stat(zt_ctlpath, &statbuf)) { - ftdm_log(FTDM_LOG_NOTICE, "Using Zaptel control device\n"); - ctlpath = zt_ctlpath; - chanpath = zt_chanpath; - memcpy(&codes, &zt_ioctl_codes, sizeof(codes)); - } else if (!stat(dahdi_ctlpath, &statbuf)) { - ftdm_log(FTDM_LOG_NOTICE, "Using DAHDI control device\n"); - ctlpath = dahdi_ctlpath; - chanpath = dahdi_chanpath; - memcpy(&codes, &dahdi_ioctl_codes, sizeof(codes)); - } else { - ftdm_log(FTDM_LOG_ERROR, "No DAHDI or Zap control device found in /dev/\n"); - return FTDM_FAIL; - } - if ((CONTROL_FD = open(ctlpath, O_RDWR)) < 0) { - ftdm_log(FTDM_LOG_ERROR, "Cannot open control device %s: %s\n", ctlpath, strerror(errno)); - return FTDM_FAIL; - } - - zt_globals.codec_ms = 20; - zt_globals.wink_ms = 150; - zt_globals.flash_ms = 750; - zt_globals.eclevel = 0; - zt_globals.etlevel = 0; - - zt_interface.name = "zt"; - zt_interface.configure = zt_configure; - zt_interface.configure_span = zt_configure_span; - zt_interface.open = zt_open; - zt_interface.close = zt_close; - zt_interface.command = zt_command; - zt_interface.wait = zt_wait; - zt_interface.read = zt_read; - zt_interface.write = zt_write; - zt_interface.poll_event = zt_poll_event; - zt_interface.next_event = zt_next_event; - zt_interface.channel_next_event = zt_channel_next_event; - zt_interface.channel_destroy = zt_channel_destroy; - zt_interface.get_alarms = zt_get_alarms; - *fio = &zt_interface; - - return FTDM_SUCCESS; -} - -/** - * \brief Unloads Zaptel/DAHDI IO module - * \return Success - */ -static FIO_IO_UNLOAD_FUNCTION(zt_destroy) -{ - close(CONTROL_FD); - memset(&zt_interface, 0, sizeof(zt_interface)); - return FTDM_SUCCESS; -} - -/** - * \brief FreeTDM Zaptel/DAHDI IO module definition - */ -ftdm_module_t ftdm_module = { - "zt", - zt_init, - zt_destroy, -}; - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.h b/libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.h deleted file mode 100644 index 99c7ef451f..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.h +++ /dev/null @@ -1,393 +0,0 @@ -/* - * Copyright (c) 2007-2014, Anthony Minessale II - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Contributors: - * - * Moises Silva - * W McRoberts - * - */ - -#ifndef FTDM_ZT_H -#define FTDM_ZT_H -#include "freetdm.h" -#include -#include - -#ifdef __sun -#include -#include -#include -#endif - -/* Hardware interface structures and defines */ -/* Based on documentation of the structures required for the hardware interface */ -/* from http://wiki.freeswitch.org/wiki/Zapata_ftdmtel_interface */ - -/* Structures */ - -/* Used with ioctl: ZT_GET_PARAMS and ZT_SET_PARAMS */ -struct zt_params { - int chan_no; /* Channel Number */ - int span_no; /* Span Number */ - int chan_position; /* Channel Position */ - int sig_type; /* Signal Type (read-only) */ - int sig_cap; /* Signal Cap (read-only) */ - int receive_offhook; /* Receive is offhook (read-only) */ - int receive_bits; /* Number of bits in receive (read-only) */ - int transmit_bits; /* Number of bits in transmit (read-only) */ - int transmit_hook_sig; /* Transmit Hook Signal (read-only) */ - int receive_hook_sig; /* Receive Hook Signal (read-only) */ - int g711_type; /* Member of zt_g711_t (read-only) */ - int idlebits; /* bits for the idle state (read-only) */ - char chan_name[40]; /* Channel Name */ - int prewink_time; - int preflash_time; - int wink_time; - int flash_time; - int start_time; - int receive_wink_time; - int receive_flash_time; - int debounce_time; - int pulse_break_time; - int pulse_make_time; - int pulse_after_time; - /* latest version of this struct include chan_alarms field */ - uint32_t chan_alarms; -}; - -typedef struct zt_params zt_params_t; - -/* Used with ioctl: ZT_CONFLINK, ZT_GETCONF and ZT_SETCONF */ -struct zt_confinfo { - int chan_no; /* Channel Number, 0 for current */ - int conference_number; - int conference_mode; -}; - -/* Used with ioctl: ZT_GETGAINS and ZT_SETGAINS */ -struct zt_gains { - int chan_no; /* Channel Number, 0 for current */ - unsigned char receive_gain[256]; /* Receive gain table */ - unsigned char transmit_gain[256]; /* Transmit gain table */ -}; - -/* Used with ioctl: ZT_SPANSTAT */ -struct zt_spaninfo { - int span_no; /* span number (-1 to use name) */ - char name[20]; /* Name of span */ - char description[40]; /* Description of span */ - int alarms; /* alarms status */ - int transmit_level; /* Transmit level */ - int receive_level; /* Receive level */ - int bpv_count; /* Current BPV count */ - int crc4_count; /* Current CRC4 error count */ - int ebit_count; /* Current E-bit error count */ - int fas_count; /* Current FAS error count */ - int irq_misses; /* Current IRQ misses */ - int sync_src; /* Span # of sync source (0 = free run) */ - int configured_chan_count; /* Count of channels configured on the span */ - int channel_count; /* Total count of channels on the span */ - int span_count; /* Total count of ftdmtel spans on the system*/ - /* end v1 of the struct */ - /* as long as we don't use the fields below we should be ok regardless of the ftdmtel/dahdi version */ - int lbo; /* Line Build Out */ - int lineconfig; /* framing/coding */ - /* end of v2 of the struct */ - char lboname[40]; /* Line Build Out in text form */ - char location[40]; /* span's device location in system */ - char manufacturer[40]; /* manufacturer of span's device */ - char devicetype[40]; /* span's device type */ - int irq; /* span's device IRQ */ - int linecompat; /* signaling modes possible on this span */ - char spantype[6]; /* type of span in text form */ -}; - -struct zt_maintinfo { - int span_no; /* span number */ - int command; /* Maintenance mode to set (from zt_maintenance_mode_t) */ -}; - -struct zt_lineconfig { -/* Used in ZT_SPANCONFIG */ - int span; /* Which span number (0 to use name) */ - char name[20]; /* Name of span to use */ - int lbo; /* line build-outs */ - int lineconfig; /* line config parameters (framing, coding) */ - int sync; /* what level of sync source we are */ -}; - -struct zt_chanconfig { -/* Used in ZT_CHANCONFIG */ - int chan; /* Channel we're applying this to (0 to use name) */ - char name[40]; /* Name of channel to use */ - int sigtype; /* Signal type */ - int deflaw; /* Default law (ZT_LAW_DEFAULT, ZT_LAW_MULAW, or ZT_LAW_ALAW */ - int master; /* Master channel if sigtype is ZT_SLAVE */ - int idlebits; /* Idle bits (if this is a CAS channel) or channel to monitor (if this is DACS channel) */ - char netdev_name[16]; /* name for the hdlc network device */ -}; - -struct zt_bufferinfo { -/* used in ZT_SET_BUFINFO and ZT_GET_BUFINFO */ - int txbufpolicy; /* Policy for handling receive buffers */ - int rxbufpolicy; /* Policy for handling receive buffers */ - int numbufs; /* How many buffers to use */ - int bufsize; /* How big each buffer is */ - int readbufs; /* How many read buffers are full (read-only) */ - int writebufs; /* How many write buffers are full (read-only) */ -}; - -/* Enumerations */ - -/* Values in zt_params structure for member g711_type */ -typedef enum { - ZT_G711_DEFAULT = 0, /* Default mulaw/alaw from the span */ - ZT_G711_MULAW = 1, - ZT_G711_ALAW = 2 -} zt_g711_t; - -typedef enum { - ZT_EVENT_NONE = 0, - ZT_EVENT_ONHOOK = 1, - ZT_EVENT_RINGOFFHOOK = 2, - ZT_EVENT_WINKFLASH = 3, - ZT_EVENT_ALARM = 4, - ZT_EVENT_NOALARM = 5, - ZT_EVENT_ABORT = 6, - ZT_EVENT_OVERRUN = 7, - ZT_EVENT_BADFCS = 8, - ZT_EVENT_DIALCOMPLETE = 9, - ZT_EVENT_RINGERON = 10, - ZT_EVENT_RINGEROFF = 11, - ZT_EVENT_HOOKCOMPLETE = 12, - ZT_EVENT_BITSCHANGED = 13, - ZT_EVENT_PULSE_START = 14, - ZT_EVENT_TIMER_EXPIRED = 15, - ZT_EVENT_TIMER_PING = 16, - ZT_EVENT_POLARITY = 17, - ZT_EVENT_RINGBEGIN = 18, - ZT_EVENT_DTMFDOWN = (1 << 17), - ZT_EVENT_DTMFUP = (1 << 18), -} zt_event_t; - -typedef enum { - ZT_FLUSH_READ = 1, - ZT_FLUSH_WRITE = 2, - ZT_FLUSH_BOTH = (ZT_FLUSH_READ | ZT_FLUSH_WRITE), - ZT_FLUSH_EVENT = 4, - ZT_FLUSH_ALL = (ZT_FLUSH_READ | ZT_FLUSH_WRITE | ZT_FLUSH_EVENT) -} zt_flush_t; - -typedef enum { - ZT_IOMUX_READ = 1, - ZT_IOMUX_WRITE = 2, - ZT_IOMUX_WRITEEMPTY = 4, - ZT_IOMUX_SIGEVENT = 8, - ZT_IOMUX_NOWAIT = 256 -} zt_iomux_t; - -typedef enum { - ZT_ONHOOK = 0, - ZT_OFFHOOK = 1, - ZT_WINK = 2, - ZT_FLASH = 3, - ZT_START = 4, - ZT_RING = 5, - ZT_RINGOFF = 6 -} zt_hookstate_t; - -typedef enum { - ZT_MAINT_NONE = 0, /* Normal Mode */ - ZT_MAINT_LOCALLOOP = 1, /* Local Loopback */ - ZT_MAINT_REMOTELOOP = 2, /* Remote Loopback */ - ZT_MAINT_LOOPUP = 3, /* Send Loopup Code */ - ZT_MAINT_LOOPDOWN = 4, /* Send Loopdown Code */ - ZT_MAINT_LOOPSTOP = 5 /* Stop Sending Loop Codes */ -} zt_maintenance_mode_t; - -typedef enum { -/* Signalling type */ -ZT_SIG_NONE = 0, /* chan not configured. */ - -ZT_SIG_FXSLS = ((1 << 0) | (1 << 13)), /* FXS, Loopstart */ -ZT_SIG_FXSGS = ((1 << 1) | (1 << 13)), /* FXS, Groundstart */ -ZT_SIG_FXSKS = ((1 << 2) | (1 << 13)), /* FXS, Kewlstart */ -ZT_SIG_FXOLS = ((1 << 3) | (1 << 12)), /* FXO, Loopstart */ -ZT_SIG_FXOGS = ((1 << 4) | (1 << 12)), /* FXO, Groupstart */ -ZT_SIG_FXOKS = ((1 << 5) | (1 << 12)), /* FXO, Kewlstart */ -ZT_SIG_EM = (1 << 6), /* E&M */ -ZT_SIG_CLEAR = (1 << 7), -ZT_SIG_HDLCRAW = ((1 << 8) | ZT_SIG_CLEAR), -ZT_SIG_HDLCFCS = ((1 << 9) | ZT_SIG_HDLCRAW), -ZT_SIG_CAS = (1 << 15), -ZT_SIG_HARDHDLC = ((1 << 19) | ZT_SIG_CLEAR), -} zt_sigtype_t; - -typedef enum { -ZT_DBIT = 1, -ZT_CBIT = 2, -ZT_BBIT = 4, -ZT_ABIT = 8 -} zt_cas_bit_t; - -typedef enum { -/* Tone Detection */ -ZT_TONEDETECT_ON = (1 << 0), /* Detect tones */ -ZT_TONEDETECT_MUTE = (1 << 1) /* Mute audio in received channel */ -} zt_tone_mode_t; - -/* Defines */ - -#define ZT_MAX_BLOCKSIZE 8192 -#define ZT_DEFAULT_MTU_MRU 2048 - -/* ioctl defines */ - -#define ZT_CODE 'J' -#define DAHDI_CODE 0xDA - - -#define ZT_GET_BLOCKSIZE _IOR (ZT_CODE, 1, int) /* Get Transfer Block Size. */ -#define ZT_SET_BLOCKSIZE _IOW (ZT_CODE, 2, int) /* Set Transfer Block Size. */ -#define ZT_FLUSH _IOW (ZT_CODE, 3, int) /* Flush Buffer(s) and stop I/O */ -#define ZT_SYNC _IOW (ZT_CODE, 4, int) /* Wait for Write to Finish */ -#define ZT_GET_PARAMS _IOR (ZT_CODE, 5, struct zt_params) /* Get channel parameters */ -#define ZT_SET_PARAMS _IOW (ZT_CODE, 6, struct zt_params) /* Set channel parameters */ -#define ZT_HOOK _IOW (ZT_CODE, 7, int) /* Set Hookswitch Status */ -#define ZT_GETEVENT _IOR (ZT_CODE, 8, int) /* Get Signalling Event */ -#define ZT_IOMUX _IOWR (ZT_CODE, 9, int) /* Wait for something to happen (IO Mux) */ -#define ZT_SPANSTAT _IOWR (ZT_CODE, 10, struct zt_spaninfo) /* Get Span Status */ -#define ZT_MAINT _IOW (ZT_CODE, 11, struct zt_maintinfo)/* Set Maintenance Mode for a span */ -#define ZT_GETCONF _IOWR (ZT_CODE, 12, struct zt_confinfo) /* Get Conference Mode */ -#define ZT_SETCONF _IOWR (ZT_CODE, 13, struct zt_confinfo) /* Set Conference Mode */ -#define ZT_CONFLINK _IOW (ZT_CODE, 14, struct zt_confinfo) /* Setup or Remove Conference Link */ -#define ZT_CONFDIAG _IOR (ZT_CODE, 15, int) /* Display Conference Diagnostic Information on Console */ - -#define ZT_GETGAINS _IOWR (ZT_CODE, 16, struct zt_gains) /* Get Channel audio gains */ -#define ZT_SETGAINS _IOWR (ZT_CODE, 17, struct zt_gains) /* Set Channel audio gains */ -#define ZT_SPANCONFIG _IOW (ZT_CODE, 18, struct zt_lineconfig)/* Set Line (T1) Configurations and start system */ -#define ZT_CHANCONFIG _IOW (ZT_CODE, 19, struct zt_chanconfig)/* Set Channel Configuration */ -#define ZT_SET_BUFINFO _IOW (ZT_CODE, 27, struct zt_bufferinfo)/* Set buffer policy */ -#define ZT_GET_BUFINFO _IOR (ZT_CODE, 28, struct zt_bufferinfo)/* Get current buffer info */ -#define ZT_AUDIOMODE _IOW (ZT_CODE, 32, int) /* Set a clear channel into audio mode */ -#define ZT_ECHOCANCEL _IOW (ZT_CODE, 33, int) /* Control Echo Canceller */ -#define ZT_HDLCRAWMODE _IOW (ZT_CODE, 36, int) /* Set a clear channel into HDLC w/out FCS checking/calculation mode */ -#define ZT_HDLCFCSMODE _IOW (ZT_CODE, 37, int) /* Set a clear channel into HDLC w/ FCS mode */ - -/* Specify a channel on /dev/ftdm/chan -- must be done before any other ioctl's and is only valid on /dev/ftdm/chan */ -#define ZT_SPECIFY _IOW (ZT_CODE, 38, int) - -/* Temporarily set the law on a channel to ZT_LAW_DEFAULT, ZT_LAW_ALAW, or ZT_LAW_MULAW. Is reset on close. */ -#define ZT_SETLAW _IOW (ZT_CODE, 39, int) - -/* Temporarily set the channel to operate in linear mode when non-zero or default law if 0 */ -#define ZT_SETLINEAR _IOW (ZT_CODE, 40, int) - -#define ZT_GETCONFMUTE _IOR (ZT_CODE, 49, int) /* Get Conference to mute mode */ -#define ZT_ECHOTRAIN _IOW (ZT_CODE, 50, int) /* Control Echo Trainer */ - -/* Set/Get CAS bits */ -#define ZT_SETTXBITS _IOW (ZT_CODE, 43, int) -#define ZT_GETRXBITS _IOR (ZT_CODE, 45, int) - -/* - * Enable tone detection -- implemented by low level driver - */ -#define ZT_TONEDETECT _IOW(ZT_CODE, 91, int) - -#define DAHDI_GET_BLOCKSIZE _IOR (DAHDI_CODE, 1, int) /* Get Transfer Block Size. */ -#define DAHDI_SET_BLOCKSIZE _IOW (DAHDI_CODE, 1, int) /* Set Transfer Block Size. */ -#define DAHDI_FLUSH _IOW (DAHDI_CODE, 3, int) /* Flush Buffer(s) and stop I/O */ -#define DAHDI_SYNC _IO (DAHDI_CODE, 4) /* Wait for Write to Finish */ -#define DAHDI_GET_PARAMS _IOR (DAHDI_CODE, 5, struct zt_params) /* Get channel parameters */ -#define DAHDI_SET_PARAMS _IOW (DAHDI_CODE, 5, struct zt_params) /* Set channel parameters */ -#define DAHDI_HOOK _IOW (DAHDI_CODE, 7, int) /* Set Hookswitch Status */ -#define DAHDI_GETEVENT _IOR (DAHDI_CODE, 8, int) /* Get Signalling Event */ -#define DAHDI_IOMUX _IOWR (DAHDI_CODE, 9, int) /* Wait for something to happen (IO Mux) */ -#define DAHDI_SPANSTAT _IOWR (DAHDI_CODE, 10, struct zt_spaninfo) /* Get Span Status */ -#define DAHDI_MAINT _IOW (DAHDI_CODE, 11, struct zt_maintinfo) /* Set Maintenance Mode for a span */ -#define DAHDI_GETCONF _IOR (DAHDI_CODE, 12, struct zt_confinfo) /* Get Conference Mode */ -#define DAHDI_SETCONF _IOW (DAHDI_CODE, 12, struct zt_confinfo) /* Set Conference Mode */ -#define DAHDI_CONFLINK _IOW (DAHDI_CODE, 14, struct zt_confinfo) /* Setup or Remove Conference Link */ -#define DAHDI_CONFDIAG _IOR (DAHDI_CODE, 15, int) /* Display Conference Diagnostic Information on Console */ - -#define DAHDI_GETGAINS _IOR (DAHDI_CODE, 16, struct zt_gains) /* Get Channel audio gains */ -#define DAHDI_SETGAINS _IOW (DAHDI_CODE, 16, struct zt_gains) /* Set Channel audio gains */ -#define DAHDI_SPANCONFIG _IOW (DAHDI_CODE, 18, struct zt_lineconfig)/* Set Line (T1) Configurations and start system */ -#define DAHDI_CHANCONFIG _IOW (DAHDI_CODE, 19, struct zt_chanconfig)/* Set Channel Configuration */ -#define DAHDI_SET_BUFINFO _IOW (DAHDI_CODE, 27, struct zt_bufferinfo)/* Set buffer policy */ -#define DAHDI_GET_BUFINFO _IOR (DAHDI_CODE, 27, struct zt_bufferinfo)/* Get current buffer info */ -#define DAHDI_AUDIOMODE _IOW (DAHDI_CODE, 32, int) /* Set a clear channel into audio mode */ -#define DAHDI_ECHOCANCEL _IOW (DAHDI_CODE, 33, int) /* Control Echo Canceller */ -#define DAHDI_HDLCRAWMODE _IOW (DAHDI_CODE, 36, int) /* Set a clear channel into HDLC w/out FCS checking/calculation mode */ -#define DAHDI_HDLCFCSMODE _IOW (DAHDI_CODE, 37, int) /* Set a clear channel into HDLC w/ FCS mode */ - -/* Dahdi channel alarms */ -#define DAHDI_ALARM_YELLOW (1 << 2) /* Yellow Alarm */ -#define DAHDI_ALARM_BLUE (1 << 4) /* Blue Alarm */ - -/* Specify a channel on /dev/dahdi/chan -- must be done before any other ioctl's and is only valid on /dev/dahdi/chan */ -#define DAHDI_SPECIFY _IOW (DAHDI_CODE, 38, int) - -/* Temporarily set the law on a channel to DAHDI_LAW_DEFAULT, DAHDI_LAW_ALAW, or DAHDI_LAW_MULAW. Is reset on close. */ -#define DAHDI_SETLAW _IOW (DAHDI_CODE, 39, int) - -/* Temporarily set the channel to operate in linear mode when non-zero or default law if 0 */ -#define DAHDI_SETLINEAR _IOW (DAHDI_CODE, 40, int) - -#define DAHDI_GETCONFMUTE _IOR (DAHDI_CODE, 49, int) /* Get Conference to mute mode */ -#define DAHDI_ECHOTRAIN _IOW (DAHDI_CODE, 50, int) /* Control Echo Trainer */ - -/* Set/Get CAS bits */ -#define DAHDI_SETTXBITS _IOW (DAHDI_CODE, 43, int) -#define DAHDI_GETRXBITS _IOR (DAHDI_CODE, 43, int) - -#define DAHDI_SETPOLARITY _IOW (DAHDI_CODE, 92, int) /* Polarity setting for FXO lines */ - -/* - * Enable tone detection -- implemented by low level driver - */ -#define DAHDI_TONEDETECT _IOW(DAHDI_CODE, 91, int) - -#endif - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/g711.c b/libs/freetdm/src/g711.c deleted file mode 100644 index e113db5811..0000000000 --- a/libs/freetdm/src/g711.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - * SpanDSP - a series of DSP components for telephony - * - * g711.c - A-law and u-law transcoding routines - * - * Written by Steve Underwood - * - * Copyright (C) 2006 Steve Underwood - * - * Despite my general liking of the GPL, I place this code in the - * public domain for the benefit of all mankind - even the slimy - * ones who might try to proprietize my work and use it to my - * detriment. - * - * $Id: g711.c,v 1.1 2006/06/07 15:46:39 steveu Exp $ - */ - -/*! \file */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#ifndef _MSC_VER -#include -#ifdef HAVE_TGMATH_H -#include -#endif -#endif - -#include "g711.h" - -/* Copied from the CCITT G.711 specification */ -static const uint8_t ulaw_to_alaw_table[256] = - { - 42, 43, 40, 41, 46, 47, 44, 45, 34, 35, 32, 33, 38, 39, 36, 37, - 58, 59, 56, 57, 62, 63, 60, 61, 50, 51, 48, 49, 54, 55, 52, 53, - 10, 11, 8, 9, 14, 15, 12, 13, 2, 3, 0, 1, 6, 7, 4, 26, - 27, 24, 25, 30, 31, 28, 29, 18, 19, 16, 17, 22, 23, 20, 21, 106, - 104, 105, 110, 111, 108, 109, 98, 99, 96, 97, 102, 103, 100, 101, 122, 120, - 126, 127, 124, 125, 114, 115, 112, 113, 118, 119, 116, 117, 75, 73, 79, 77, - 66, 67, 64, 65, 70, 71, 68, 69, 90, 91, 88, 89, 94, 95, 92, 93, - 82, 82, 83, 83, 80, 80, 81, 81, 86, 86, 87, 87, 84, 84, 85, 85, - 170, 171, 168, 169, 174, 175, 172, 173, 162, 163, 160, 161, 166, 167, 164, 165, - 186, 187, 184, 185, 190, 191, 188, 189, 178, 179, 176, 177, 182, 183, 180, 181, - 138, 139, 136, 137, 142, 143, 140, 141, 130, 131, 128, 129, 134, 135, 132, 154, - 155, 152, 153, 158, 159, 156, 157, 146, 147, 144, 145, 150, 151, 148, 149, 234, - 232, 233, 238, 239, 236, 237, 226, 227, 224, 225, 230, 231, 228, 229, 250, 248, - 254, 255, 252, 253, 242, 243, 240, 241, 246, 247, 244, 245, 203, 201, 207, 205, - 194, 195, 192, 193, 198, 199, 196, 197, 218, 219, 216, 217, 222, 223, 220, 221, - 210, 210, 211, 211, 208, 208, 209, 209, 214, 214, 215, 215, 212, 212, 213, 213 - }; - -/* These transcoding tables are copied from the CCITT G.711 specification. To achieve - optimal results, do not change them. */ - -static const uint8_t alaw_to_ulaw_table[256] = - { - 42, 43, 40, 41, 46, 47, 44, 45, 34, 35, 32, 33, 38, 39, 36, 37, - 57, 58, 55, 56, 61, 62, 59, 60, 49, 50, 47, 48, 53, 54, 51, 52, - 10, 11, 8, 9, 14, 15, 12, 13, 2, 3, 0, 1, 6, 7, 4, 5, - 26, 27, 24, 25, 30, 31, 28, 29, 18, 19, 16, 17, 22, 23, 20, 21, - 98, 99, 96, 97, 102, 103, 100, 101, 93, 93, 92, 92, 95, 95, 94, 94, - 116, 118, 112, 114, 124, 126, 120, 122, 106, 107, 104, 105, 110, 111, 108, 109, - 72, 73, 70, 71, 76, 77, 74, 75, 64, 65, 63, 63, 68, 69, 66, 67, - 86, 87, 84, 85, 90, 91, 88, 89, 79, 79, 78, 78, 82, 83, 80, 81, - 170, 171, 168, 169, 174, 175, 172, 173, 162, 163, 160, 161, 166, 167, 164, 165, - 185, 186, 183, 184, 189, 190, 187, 188, 177, 178, 175, 176, 181, 182, 179, 180, - 138, 139, 136, 137, 142, 143, 140, 141, 130, 131, 128, 129, 134, 135, 132, 133, - 154, 155, 152, 153, 158, 159, 156, 157, 146, 147, 144, 145, 150, 151, 148, 149, - 226, 227, 224, 225, 230, 231, 228, 229, 221, 221, 220, 220, 223, 223, 222, 222, - 244, 246, 240, 242, 252, 254, 248, 250, 234, 235, 232, 233, 238, 239, 236, 237, - 200, 201, 198, 199, 204, 205, 202, 203, 192, 193, 191, 191, 196, 197, 194, 195, - 214, 215, 212, 213, 218, 219, 216, 217, 207, 207, 206, 206, 210, 211, 208, 209 - }; - -uint8_t alaw_to_ulaw(uint8_t alaw) -{ - return alaw_to_ulaw_table[alaw]; -} -/*- End of function --------------------------------------------------------*/ - -uint8_t ulaw_to_alaw(uint8_t ulaw) -{ - return ulaw_to_alaw_table[ulaw]; -} -/*- End of function --------------------------------------------------------*/ -/*- End of file ------------------------------------------------------------*/ - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ - diff --git a/libs/freetdm/src/hashtable.c b/libs/freetdm/src/hashtable.c deleted file mode 100644 index 4b39e8599a..0000000000 --- a/libs/freetdm/src/hashtable.c +++ /dev/null @@ -1,340 +0,0 @@ -/* - * Copyright (c) 2002, Christopher Clark - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "private/ftdm_core.h" -#include "hashtable.h" -#include "hashtable_private.h" -#include -#include -#include -#include - -/* - Credit for primes table: Aaron Krowne - http://br.endernet.org/~akrowne/ - http://planetmath.org/encyclopedia/GoodHashTablePrimes.html -*/ -static const unsigned int primes[] = { - 53, 97, 193, 389, - 769, 1543, 3079, 6151, - 12289, 24593, 49157, 98317, - 196613, 393241, 786433, 1572869, - 3145739, 6291469, 12582917, 25165843, - 50331653, 100663319, 201326611, 402653189, - 805306457, 1610612741 -}; -const unsigned int prime_table_length = sizeof(primes)/sizeof(primes[0]); -const float max_load_factor = 0.65f; - -/*****************************************************************************/ -FT_DECLARE(struct hashtable *) -create_hashtable(unsigned int minsize, - unsigned int (*hashf) (void*), - int (*eqf) (void*,void*)) -{ - struct hashtable *h; - unsigned int pindex, size = primes[0]; - /* Check requested hashtable isn't too large */ - if (minsize > (1u << 30)) return NULL; - /* Enforce size as prime */ - for (pindex=0; pindex < prime_table_length; pindex++) { - if (primes[pindex] > minsize) { size = primes[pindex]; break; } - } - h = (struct hashtable *)ftdm_malloc(sizeof(struct hashtable)); - if (NULL == h) return NULL; /*oom*/ - h->table = (struct entry **)ftdm_malloc(sizeof(struct entry*) * size); - if (NULL == h->table) { ftdm_safe_free(h); return NULL; } /*oom*/ - memset(h->table, 0, size * sizeof(struct entry *)); - h->tablelength = size; - h->primeindex = pindex; - h->entrycount = 0; - h->hashfn = hashf; - h->eqfn = eqf; - h->loadlimit = (unsigned int) ceil(size * max_load_factor); - return h; -} - -/*****************************************************************************/ -unsigned int -hash(struct hashtable *h, void *k) -{ - /* Aim to protect against poor hash functions by adding logic here - * - logic taken from java 1.4 hashtable source */ - unsigned int i = h->hashfn(k); - i += ~(i << 9); - i ^= ((i >> 14) | (i << 18)); /* >>> */ - i += (i << 4); - i ^= ((i >> 10) | (i << 22)); /* >>> */ - return i; -} - -/*****************************************************************************/ -static int -hashtable_expand(struct hashtable *h) -{ - /* Double the size of the table to accomodate more entries */ - struct entry **newtable; - struct entry *e; - struct entry **pE; - unsigned int newsize, i, index; - /* Check we're not hitting max capacity */ - if (h->primeindex == (prime_table_length - 1)) return 0; - newsize = primes[++(h->primeindex)]; - - newtable = (struct entry **)ftdm_malloc(sizeof(struct entry*) * newsize); - if (NULL != newtable) - { - memset(newtable, 0, newsize * sizeof(struct entry *)); - /* This algorithm is not 'stable'. ie. it reverses the list - * when it transfers entries between the tables */ - for (i = 0; i < h->tablelength; i++) { - while (NULL != (e = h->table[i])) { - h->table[i] = e->next; - index = indexFor(newsize,e->h); - e->next = newtable[index]; - newtable[index] = e; - } - } - ftdm_safe_free(h->table); - h->table = newtable; - } - /* Plan B: realloc instead */ - else - { - newtable = (struct entry **) - realloc(h->table, newsize * sizeof(struct entry *)); - if (NULL == newtable) { (h->primeindex)--; return 0; } - h->table = newtable; - memset(newtable[h->tablelength], 0, newsize - h->tablelength); - for (i = 0; i < h->tablelength; i++) { - for (pE = &(newtable[i]), e = *pE; e != NULL; e = *pE) { - index = indexFor(newsize,e->h); - if (index == i) - { - pE = &(e->next); - } - else - { - *pE = e->next; - e->next = newtable[index]; - newtable[index] = e; - } - } - } - } - h->tablelength = newsize; - h->loadlimit = (unsigned int) ceil(newsize * max_load_factor); - return -1; -} - -/*****************************************************************************/ -FT_DECLARE(unsigned int) -hashtable_count(struct hashtable *h) -{ - return h->entrycount; -} - -/*****************************************************************************/ -FT_DECLARE(int) -hashtable_insert(struct hashtable *h, void *k, void *v, hashtable_flag_t flags) -{ - /* This method allows duplicate keys - but they shouldn't be used */ - unsigned int index; - struct entry *e; - if (++(h->entrycount) > h->loadlimit) - { - /* Ignore the return value. If expand fails, we should - * still try cramming just this value into the existing table - * -- we may not have memory for a larger table, but one more - * element may be ok. Next time we insert, we'll try expanding again.*/ - hashtable_expand(h); - } - e = (struct entry *)ftdm_malloc(sizeof(struct entry)); - if (NULL == e) { --(h->entrycount); return 0; } /*oom*/ - e->h = hash(h,k); - index = indexFor(h->tablelength,e->h); - e->k = k; - e->v = v; - e->flags = flags; - e->next = h->table[index]; - h->table[index] = e; - return -1; -} - -/*****************************************************************************/ -FT_DECLARE(void *) /* returns value associated with key */ -hashtable_search(struct hashtable *h, void *k) -{ - struct entry *e; - unsigned int hashvalue, index; - hashvalue = hash(h,k); - index = indexFor(h->tablelength,hashvalue); - e = h->table[index]; - while (NULL != e) - { - /* Check hash value to short circuit heavier comparison */ - if ((hashvalue == e->h) && (h->eqfn(k, e->k))) return e->v; - e = e->next; - } - return NULL; -} - -/*****************************************************************************/ -FT_DECLARE(void *) /* returns value associated with key */ -hashtable_remove(struct hashtable *h, void *k) -{ - /* TODO: consider compacting the table when the load factor drops enough, - * or provide a 'compact' method. */ - - struct entry *e; - struct entry **pE; - void *v; - unsigned int hashvalue, index; - - hashvalue = hash(h,k); - index = indexFor(h->tablelength,hash(h,k)); - pE = &(h->table[index]); - e = *pE; - while (NULL != e) - { - /* Check hash value to short circuit heavier comparison */ - if ((hashvalue == e->h) && (h->eqfn(k, e->k))) - { - *pE = e->next; - h->entrycount--; - v = e->v; - if (e->flags & HASHTABLE_FLAG_FREE_KEY) { - freekey(e->k); - } - ftdm_safe_free(e); - return v; - } - pE = &(e->next); - e = e->next; - } - return NULL; -} - -/*****************************************************************************/ -/* destroy */ -FT_DECLARE(void) -hashtable_destroy(struct hashtable *h) -{ - unsigned int i; - struct entry *e, *f; - struct entry **table = h->table; - - for (i = 0; i < h->tablelength; i++) - { - e = table[i]; - while (NULL != e) - { f = e; e = e->next; if (f->flags & HASHTABLE_FLAG_FREE_KEY) freekey(f->k); if (f->flags & HASHTABLE_FLAG_FREE_VALUE) ftdm_safe_free(f->v); ftdm_safe_free(f); } - } - - ftdm_safe_free(h->table); - ftdm_safe_free(h); -} - -FT_DECLARE(struct hashtable_iterator *) hashtable_next(struct hashtable_iterator *i) -{ - - if (i->e) { - if ((i->e = i->e->next) != 0) { - return i; - } else { - i->pos++; - } - } - - while(i->pos < i->h->tablelength && !i->h->table[i->pos]) { - i->pos++; - } - - if (i->pos >= i->h->tablelength) { - return NULL; - } - - if ((i->e = i->h->table[i->pos]) != 0) { - return i; - } - - return NULL; -} - -FT_DECLARE(struct hashtable_iterator *) hashtable_first(struct hashtable *h) -{ - h->iterator.pos = 0; - h->iterator.e = NULL; - h->iterator.h = h; - return hashtable_next(&h->iterator); -} - - - -FT_DECLARE(void) hashtable_this(struct hashtable_iterator *i, const void **key, int *klen, void **val) -{ - if (i->e) { - if (key) { - *key = i->e->k; - } - if (klen) { - *klen = (int)strlen(i->e->k); - } - if (val) { - *val = i->e->v; - } - } else { - if (key) { - *key = NULL; - } - if (klen) { - *klen = 0; - } - if (val) { - *val = NULL; - } - } -} - - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ - diff --git a/libs/freetdm/src/hashtable_itr.c b/libs/freetdm/src/hashtable_itr.c deleted file mode 100644 index 113d1ea503..0000000000 --- a/libs/freetdm/src/hashtable_itr.c +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright (c) 2002, 2004, Christopher Clark - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "private/ftdm_core.h" -#include "hashtable.h" -#include "hashtable_private.h" -#include "hashtable_itr.h" -#include /* defines NULL */ - -/*****************************************************************************/ -/* hashtable_iterator - iterator constructor */ - -struct hashtable_itr * -hashtable_iterator(struct hashtable *h) -{ - unsigned int i, tablelength; - struct hashtable_itr *itr = ftdm_malloc(sizeof(struct hashtable_itr)); - if (NULL == itr) return NULL; - itr->h = h; - itr->e = NULL; - itr->parent = NULL; - tablelength = h->tablelength; - itr->index = tablelength; - if (0 == h->entrycount) return itr; - - for (i = 0; i < tablelength; i++) - { - if (NULL != h->table[i]) - { - itr->e = h->table[i]; - itr->index = i; - break; - } - } - return itr; -} - -/*****************************************************************************/ -/* advance - advance the iterator to the next element - * returns zero if advanced to end of table */ - -int -hashtable_iterator_advance(struct hashtable_itr *itr) -{ - unsigned int j,tablelength; - struct entry **table; - struct entry *next; - if (NULL == itr->e) return 0; /* stupidity check */ - - next = itr->e->next; - if (NULL != next) - { - itr->parent = itr->e; - itr->e = next; - return -1; - } - tablelength = itr->h->tablelength; - itr->parent = NULL; - if (tablelength <= (j = ++(itr->index))) - { - itr->e = NULL; - return 0; - } - table = itr->h->table; - while (NULL == (next = table[j])) - { - if (++j >= tablelength) - { - itr->index = tablelength; - itr->e = NULL; - return 0; - } - } - itr->index = j; - itr->e = next; - return -1; -} - -/*****************************************************************************/ -/* remove - remove the entry at the current iterator position - * and advance the iterator, if there is a successive - * element. - * If you want the value, read it before you remove: - * beware memory leaks if you don't. - * Returns zero if end of iteration. */ - -int -hashtable_iterator_remove(struct hashtable_itr *itr) -{ - struct entry *remember_e, *remember_parent; - int ret; - - /* Do the removal */ - if (NULL == (itr->parent)) - { - /* element is head of a chain */ - itr->h->table[itr->index] = itr->e->next; - } else { - /* element is mid-chain */ - itr->parent->next = itr->e->next; - } - /* itr->e is now outside the hashtable */ - remember_e = itr->e; - itr->h->entrycount--; - freekey(remember_e->k); - - /* Advance the iterator, correcting the parent */ - remember_parent = itr->parent; - ret = hashtable_iterator_advance(itr); - if (itr->parent == remember_e) { itr->parent = remember_parent; } - ftdm_safe_free(remember_e); - return ret; -} - -/*****************************************************************************/ -int /* returns zero if not found */ -hashtable_iterator_search(struct hashtable_itr *itr, - struct hashtable *h, void *k) -{ - struct entry *e, *parent; - unsigned int hashvalue, index; - - hashvalue = hash(h,k); - index = indexFor(h->tablelength,hashvalue); - - e = h->table[index]; - parent = NULL; - while (NULL != e) - { - /* Check hash value to short circuit heavier comparison */ - if ((hashvalue == e->h) && (h->eqfn(k, e->k))) - { - itr->index = index; - itr->e = e; - itr->parent = parent; - itr->h = h; - return -1; - } - parent = e; - e = e->next; - } - return 0; -} - - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ - diff --git a/libs/freetdm/src/include/freetdm.h b/libs/freetdm/src/include/freetdm.h deleted file mode 100755 index f90744df8d..0000000000 --- a/libs/freetdm/src/include/freetdm.h +++ /dev/null @@ -1,2023 +0,0 @@ -/* - * Copyright (c) 2007-2014, Anthony Minessale II - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Contributors: - * - * Moises Silva - * David Yat Sin - * - */ - -#ifndef FREETDM_H -#define FREETDM_H - -#include "ftdm_declare.h" -#include "ftdm_call_utils.h" - -/*! \brief Max number of channels per physical span */ -#define FTDM_MAX_CHANNELS_PHYSICAL_SPAN 32 - -/*! \brief Max number of physical spans per logical span */ -#define FTDM_MAX_PHYSICAL_SPANS_PER_LOGICAL_SPAN 128 - -/*! \brief Max number of channels a logical span can contain */ -#define FTDM_MAX_CHANNELS_SPAN FTDM_MAX_CHANNELS_PHYSICAL_SPAN * FTDM_MAX_PHYSICAL_SPANS_PER_LOGICAL_SPAN - -/*! \brief Max number of logical spans */ -#define FTDM_MAX_SPANS_INTERFACE 128 - -/*! \brief Max number of channels per hunting group */ -#define FTDM_MAX_CHANNELS_GROUP 2048 - -/*! \brief Max number of groups */ -#define FTDM_MAX_GROUPS_INTERFACE FTDM_MAX_SPANS_INTERFACE - -/*! \brief Max number of key=value pairs to be sent as signaling stack parameters */ -#define FTDM_MAX_SIG_PARAMETERS 30 - -#define FTDM_INVALID_INT_PARM 0xFF - -/*! \brief Thread/Mutex OS abstraction API. */ -#include "ftdm_os.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/*! \brief Limit to span names */ -#define FTDM_MAX_NAME_STR_SZ 128 - -/*! \brief Limit to channel number strings */ -#define FTDM_MAX_NUMBER_STR_SZ 32 - -/*! \brief Hangup cause codes */ -typedef enum { - FTDM_CAUSE_NONE = 0, - FTDM_CAUSE_UNALLOCATED = 1, - FTDM_CAUSE_NO_ROUTE_TRANSIT_NET = 2, - FTDM_CAUSE_NO_ROUTE_DESTINATION = 3, - FTDM_CAUSE_SEND_SPECIAL_INFO_TONE = 4, - FTDM_CAUSE_MISDIALED_TRUNK_PREFIX = 5, - FTDM_CAUSE_CHANNEL_UNACCEPTABLE = 6, - FTDM_CAUSE_CALL_AWARDED_DELIVERED = 7, - FTDM_CAUSE_PREEMPTION = 8, - FTDM_CAUSE_PREEMPTION_CIRCUIT_RESERVED = 9, - FTDM_CAUSE_NORMAL_CLEARING = 16, - FTDM_CAUSE_USER_BUSY = 17, - FTDM_CAUSE_NO_USER_RESPONSE = 18, - FTDM_CAUSE_NO_ANSWER = 19, - FTDM_CAUSE_SUBSCRIBER_ABSENT = 20, - FTDM_CAUSE_CALL_REJECTED = 21, - FTDM_CAUSE_NUMBER_CHANGED = 22, - FTDM_CAUSE_REDIRECTION_TO_NEW_DESTINATION = 23, - FTDM_CAUSE_EXCHANGE_ROUTING_ERROR = 25, - FTDM_CAUSE_DESTINATION_OUT_OF_ORDER = 27, - FTDM_CAUSE_INVALID_NUMBER_FORMAT = 28, - FTDM_CAUSE_FACILITY_REJECTED = 29, - FTDM_CAUSE_RESPONSE_TO_STATUS_ENQUIRY = 30, - FTDM_CAUSE_NORMAL_UNSPECIFIED = 31, - FTDM_CAUSE_NORMAL_CIRCUIT_CONGESTION = 34, - FTDM_CAUSE_NETWORK_OUT_OF_ORDER = 38, - FTDM_CAUSE_PERMANENT_FRAME_MODE_CONNECTION_OOS = 39, - FTDM_CAUSE_PERMANENT_FRAME_MODE_OPERATIONAL = 40, - FTDM_CAUSE_NORMAL_TEMPORARY_FAILURE = 41, - FTDM_CAUSE_SWITCH_CONGESTION = 42, - FTDM_CAUSE_ACCESS_INFO_DISCARDED = 43, - FTDM_CAUSE_REQUESTED_CHAN_UNAVAIL = 44, - FTDM_CAUSE_PRE_EMPTED = 45, - FTDM_CAUSE_PRECEDENCE_CALL_BLOCKED = 46, - FTDM_CAUSE_RESOURCE_UNAVAILABLE_UNSPECIFIED = 47, - FTDM_CAUSE_QOS_NOT_AVAILABLE = 49, - FTDM_CAUSE_FACILITY_NOT_SUBSCRIBED = 50, - FTDM_CAUSE_OUTGOING_CALL_BARRED = 53, - FTDM_CAUSE_INCOMING_CALL_BARRED = 55, - FTDM_CAUSE_BEARERCAPABILITY_NOTAUTH = 57, - FTDM_CAUSE_BEARERCAPABILITY_NOTAVAIL = 58, - FTDM_CAUSE_INCONSISTENCY_IN_INFO = 62, - FTDM_CAUSE_SERVICE_UNAVAILABLE = 63, - FTDM_CAUSE_BEARERCAPABILITY_NOTIMPL = 65, - FTDM_CAUSE_CHAN_NOT_IMPLEMENTED = 66, - FTDM_CAUSE_FACILITY_NOT_IMPLEMENTED = 69, - FTDM_CAUSE_ONLY_DIGITAL_INFO_BC_AVAIL = 70, - FTDM_CAUSE_SERVICE_NOT_IMPLEMENTED = 79, - FTDM_CAUSE_INVALID_CALL_REFERENCE = 81, - FTDM_CAUSE_IDENTIFIED_CHAN_NOT_EXIST = 82, - FTDM_CAUSE_SUSPENDED_CALL_EXISTS_BUT_CALL_ID_DOES_NOT = 83, - FTDM_CAUSE_CALL_ID_IN_USE = 84, - FTDM_CAUSE_NO_CALL_SUSPENDED = 85, - FTDM_CAUSE_CALL_WITH_CALL_ID_CLEARED = 86, - FTDM_CAUSE_USER_NOT_CUG = 87, - FTDM_CAUSE_INCOMPATIBLE_DESTINATION = 88, - FTDM_CAUSE_NON_EXISTENT_CUG = 90, - FTDM_CAUSE_INVALID_TRANSIT_NETWORK_SELECTION = 91, - FTDM_CAUSE_INVALID_MSG_UNSPECIFIED = 95, - FTDM_CAUSE_MANDATORY_IE_MISSING = 96, - FTDM_CAUSE_MESSAGE_TYPE_NONEXIST = 97, - FTDM_CAUSE_WRONG_MESSAGE = 98, - FTDM_CAUSE_IE_NONEXIST = 99, - FTDM_CAUSE_INVALID_IE_CONTENTS = 100, - FTDM_CAUSE_WRONG_CALL_STATE = 101, - FTDM_CAUSE_RECOVERY_ON_TIMER_EXPIRE = 102, - FTDM_CAUSE_MANDATORY_IE_LENGTH_ERROR = 103, - FTDM_CAUSE_MSG_WITH_UNRECOGNIZED_PARAM_DISCARDED = 110, - FTDM_CAUSE_PROTOCOL_ERROR = 111, - FTDM_CAUSE_INTERWORKING = 127, - FTDM_CAUSE_SUCCESS = 142, - FTDM_CAUSE_ORIGINATOR_CANCEL = 487, - FTDM_CAUSE_CRASH = 500, - FTDM_CAUSE_SYSTEM_SHUTDOWN = 501, - FTDM_CAUSE_LOSE_RACE = 502, - FTDM_CAUSE_MANAGER_REQUEST = 503, - FTDM_CAUSE_BLIND_TRANSFER = 600, - FTDM_CAUSE_ATTENDED_TRANSFER = 601, - FTDM_CAUSE_ALLOTTED_TIMEOUT = 602, - FTDM_CAUSE_USER_CHALLENGE = 603, - FTDM_CAUSE_MEDIA_TIMEOUT = 604 -} ftdm_call_cause_t; - -/*! \brief Hunting direction (when hunting for free channels) */ -typedef enum { - FTDM_HUNT_TOP_DOWN, - FTDM_HUNT_BOTTOM_UP, - FTDM_HUNT_RR_DOWN, - FTDM_HUNT_RR_UP, -} ftdm_hunt_direction_t; - -/*! \brief Legacy Hunting direction (Top down and Bottom up were reversed), keep for source backwards compatibility of freetdm user applications - * \deprecated - * \see ftdm_hunt_direction_t - */ -typedef enum { - FTDM_BOTTOM_UP, - FTDM_TOP_DOWN, - FTDM_RR_UP, - FTDM_RR_DOWN, -} ftdm_direction_t; - -/*! \brief I/O channel type */ -typedef enum { - FTDM_CHAN_TYPE_B, /*!< Bearer channel */ - FTDM_CHAN_TYPE_DQ921, /*!< DQ921 channel (D-channel) */ - FTDM_CHAN_TYPE_DQ931, /*!< DQ931 channel */ - FTDM_CHAN_TYPE_FXS, /*!< FXS analog channel */ - FTDM_CHAN_TYPE_FXO, /*!< FXO analog channel */ - FTDM_CHAN_TYPE_EM, /*!< E & M channel */ - FTDM_CHAN_TYPE_CAS, /*!< CAS channel */ - FTDM_CHAN_TYPE_COUNT /*!< Count of channel types */ -} ftdm_chan_type_t; -#define CHAN_TYPE_STRINGS "B", "DQ921", "DQ931", "FXS", "FXO", "EM", "CAS", "INVALID" -/*! \brief transform from channel type to string and from string to channel type - * ftdm_str2ftdm_chan_type transforms a channel string (ie: "FXO" to FTDM_CHAN_TYPE_FXO) - * ftdm_chan_type2str transforms a channel type to string (ie: FTDM_CHAN_TYPE_B to "B") - */ -FTDM_STR2ENUM_P(ftdm_str2ftdm_chan_type, ftdm_chan_type2str, ftdm_chan_type_t) - -/*! \brief Test if a channel is a voice channel */ -#define FTDM_IS_VOICE_CHANNEL(fchan) ((fchan)->type != FTDM_CHAN_TYPE_DQ921 && (fchan)->type != FTDM_CHAN_TYPE_DQ931) - -/*! \brief Test if a channel is a D-channel */ -#define FTDM_IS_DCHAN(fchan) ((fchan)->type == FTDM_CHAN_TYPE_DQ921 || (fchan)->type == FTDM_CHAN_TYPE_DQ931) - -/*! \brief Test if a channel is digital channel */ -#define FTDM_IS_DIGITAL_CHANNEL(fchan) ((fchan)->span->trunk_type == FTDM_TRUNK_E1 || \ - (fchan)->span->trunk_type == FTDM_TRUNK_T1 || \ - (fchan)->span->trunk_type == FTDM_TRUNK_J1 || \ - (fchan)->span->trunk_type == FTDM_TRUNK_BRI || \ - (fchan)->span->trunk_type == FTDM_TRUNK_BRI_PTMP) - -/*! \brief Test if a span is digital */ -#define FTDM_SPAN_IS_DIGITAL(span) \ - ((span)->trunk_type == FTDM_TRUNK_E1 || \ - (span)->trunk_type == FTDM_TRUNK_T1 || \ - (span)->trunk_type == FTDM_TRUNK_J1 || \ - (span)->trunk_type == FTDM_TRUNK_GSM || \ - (span)->trunk_type == FTDM_TRUNK_BRI || \ - (span)->trunk_type == FTDM_TRUNK_BRI_PTMP) - - -/*! \brief Logging function prototype to be used for all FreeTDM logs - * you should use ftdm_global_set_logger to set your own logger - */ -typedef void (*ftdm_logger_t)(const char *file, const char *func, int line, int level, const char *fmt, ...) __ftdm_check_printf(5, 6); - -/*! \brief Data queue operation functions - * you can use ftdm_global_set_queue_handler if you want to override the default implementation (not recommended) - */ -typedef ftdm_status_t (*ftdm_queue_create_func_t)(ftdm_queue_t **queue, ftdm_size_t capacity); -typedef ftdm_status_t (*ftdm_queue_enqueue_func_t)(ftdm_queue_t *queue, void *obj); -typedef void *(*ftdm_queue_dequeue_func_t)(ftdm_queue_t *queue); -typedef ftdm_status_t (*ftdm_queue_wait_func_t)(ftdm_queue_t *queue, int ms); -typedef ftdm_status_t (*ftdm_queue_get_interrupt_func_t)(ftdm_queue_t *queue, ftdm_interrupt_t **interrupt); -typedef ftdm_status_t (*ftdm_queue_destroy_func_t)(ftdm_queue_t **queue); - -typedef struct ftdm_queue_handler { - ftdm_queue_create_func_t create; - ftdm_queue_enqueue_func_t enqueue; - ftdm_queue_dequeue_func_t dequeue; - ftdm_queue_wait_func_t wait; - ftdm_queue_get_interrupt_func_t get_interrupt; - ftdm_queue_destroy_func_t destroy; -} ftdm_queue_handler_t; - -/*! \brief Type Of Number (TON) */ -typedef enum { - FTDM_TON_UNKNOWN = 0, - FTDM_TON_INTERNATIONAL, - FTDM_TON_NATIONAL, - FTDM_TON_NETWORK_SPECIFIC, - FTDM_TON_SUBSCRIBER_NUMBER, - FTDM_TON_ABBREVIATED_NUMBER, - FTDM_TON_RESERVED, - FTDM_TON_INVALID -} ftdm_ton_t; -#define TON_STRINGS "unknown", "international", "national", "network-specific", "subscriber-number", "abbreviated-number", "reserved", "invalid" -FTDM_STR2ENUM_P(ftdm_str2ftdm_ton, ftdm_ton2str, ftdm_ton_t) - -/*! Numbering Plan Identification (NPI) */ -typedef enum { - FTDM_NPI_UNKNOWN = 0, - FTDM_NPI_ISDN, - FTDM_NPI_DATA, - FTDM_NPI_TELEX, - FTDM_NPI_NATIONAL, - FTDM_NPI_PRIVATE, - FTDM_NPI_RESERVED, - FTDM_NPI_INVALID -} ftdm_npi_t; -#define NPI_STRINGS "unknown", "ISDN", "data", "telex", "national", "private", "reserved", "invalid" -FTDM_STR2ENUM_P(ftdm_str2ftdm_npi, ftdm_npi2str, ftdm_npi_t) - -/*! Presentation Ind */ -typedef enum { - FTDM_PRES_ALLOWED, - FTDM_PRES_RESTRICTED, - FTDM_PRES_NOT_AVAILABLE, - FTDM_PRES_RESERVED, - FTDM_PRES_INVALID -} ftdm_presentation_t; -#define PRESENTATION_STRINGS "presentation-allowed", "presentation-restricted", "number-not-available", "reserved", "Invalid" -FTDM_STR2ENUM_P(ftdm_str2ftdm_presentation, ftdm_presentation2str, ftdm_presentation_t) - -/*! Screening Ind */ -typedef enum { - FTDM_SCREENING_NOT_SCREENED, - FTDM_SCREENING_VERIFIED_PASSED, - FTDM_SCREENING_VERIFIED_FAILED, - FTDM_SCREENING_NETWORK_PROVIDED, - FTDM_SCREENING_INVALID -} ftdm_screening_t; -#define SCREENING_STRINGS "user-provided-not-screened", "user-provided-verified-and-passed", "user-provided-verified-and-failed", "network-provided", "invalid" -FTDM_STR2ENUM_P(ftdm_str2ftdm_screening, ftdm_screening2str, ftdm_screening_t) - -/*! \brief bearer capability */ -typedef enum { - FTDM_BEARER_CAP_SPEECH = 0x00, /* Speech */ - FTDM_BEARER_CAP_UNRESTRICTED, /* Unrestricted Digital */ - FTDM_BEARER_CAP_RESTRICTED, /* Restricted Digital */ - FTDM_BEARER_CAP_3_1KHZ_AUDIO, /* 3.1 Khz Audio */ - FTDM_BEARER_CAP_7KHZ_AUDIO, /* 7 Khz Audio or Unrestricted digital w tones */ - FTDM_BEARER_CAP_15KHZ_AUDIO, /* 15 Khz Audio */ - FTDM_BEARER_CAP_VIDEO, /* Video */ - FTDM_BEARER_CAP_INVALID -} ftdm_bearer_cap_t; -#define BEARER_CAP_STRINGS "speech", "unrestricted-digital-information", "restricted-digital-information", "3.1-Khz-audio", "7-Khz-audio", "15-Khz-audio", "video", "invalid" -FTDM_STR2ENUM_P(ftdm_str2ftdm_bearer_cap, ftdm_bearer_cap2str, ftdm_bearer_cap_t) - -/*! \brief user information layer 1 protocol */ -typedef enum { - FTDM_USER_LAYER1_PROT_V110 = 0x01, - FTDM_USER_LAYER1_PROT_ULAW = 0x02, - FTDM_USER_LAYER1_PROT_ALAW = 0x03, - FTDM_USER_LAYER1_PROT_INVALID -} ftdm_user_layer1_prot_t; -#define USER_LAYER1_PROT_STRINGS "V.110", "ulaw", "alaw", "Invalid" -FTDM_STR2ENUM_P(ftdm_str2ftdm_usr_layer1_prot, ftdm_user_layer1_prot2str, ftdm_user_layer1_prot_t) - -/*! Calling Party Category */ -typedef enum { - FTDM_CPC_UNKNOWN, - FTDM_CPC_OPERATOR, - FTDM_CPC_OPERATOR_FRENCH, - FTDM_CPC_OPERATOR_ENGLISH, - FTDM_CPC_OPERATOR_GERMAN, - FTDM_CPC_OPERATOR_RUSSIAN, - FTDM_CPC_OPERATOR_SPANISH, - FTDM_CPC_ORDINARY, - FTDM_CPC_PRIORITY, - FTDM_CPC_DATA, - FTDM_CPC_TEST, - FTDM_CPC_PAYPHONE, - FTDM_CPC_INVALID -} ftdm_calling_party_category_t; -#define CALLING_PARTY_CATEGORY_STRINGS "unknown", "operator", "operator-french", "operator-english", "operator-german", "operator-russian", "operator-spanish", "ordinary", "priority", "data-call", "test-call", "payphone", "invalid" -FTDM_STR2ENUM_P(ftdm_str2ftdm_calling_party_category, ftdm_calling_party_category2str, ftdm_calling_party_category_t) - -/*! Network responses to transfer requests */ -typedef enum { - FTDM_TRANSFER_RESPONSE_OK, /* Call is being transferred */ - FTDM_TRANSFER_RESPONSE_CP_DROP_OFF, /* Calling Party drop off */ - FTDM_TRANSFER_RESPONSE_LIMITS_EXCEEDED, /* Cannot redirect, limits exceeded */ - FTDM_TRANSFER_RESPONSE_INVALID_NUM, /* Network did not receive or recognize dialed number */ - FTDM_TRANSFER_RESPONSE_INVALID_COMMAND, /* Network received an invalid command */ - FTDM_TRANSFER_RESPONSE_TIMEOUT, /* We did not receive a response from Network */ - FTDM_TRANSFER_RESPONSE_INVALID, -} ftdm_transfer_response_t; -#define TRANSFER_RESPONSE_STRINGS "transfer-ok", "cp-drop-off", "limits-exceeded", "invalid-num", "invalid-command", "timeout", "invalid" -FTDM_STR2ENUM_P(ftdm_str2ftdm_transfer_response, ftdm_transfer_response2str, ftdm_transfer_response_t) - -/*! \brief Digit limit used in DNIS/ANI */ -#define FTDM_DIGITS_LIMIT 64 - -#define FTDM_SILENCE_VALUE(fchan) (fchan)->native_codec == FTDM_CODEC_ULAW ? 255 : (fchan)->native_codec == FTDM_CODEC_ALAW ? 0xD5 : 0x00 - -/*! \brief Number abstraction */ -typedef struct { - char digits[FTDM_DIGITS_LIMIT]; - uint8_t type; - uint8_t plan; -} ftdm_number_t; - -typedef struct { - char from[FTDM_MAX_NUMBER_STR_SZ]; - char body[FTDM_MAX_NAME_STR_SZ]; -} ftdm_sms_data_t; - -/*! \brief Caller information */ -typedef struct ftdm_caller_data { - char cid_date[8]; /*!< Caller ID date */ - char cid_name[80]; /*!< Caller ID name */ - ftdm_number_t cid_num; /*!< Caller ID number */ - ftdm_number_t ani; /*!< ANI (Automatic Number Identification) */ - ftdm_number_t dnis; /*!< DNIS (Dialed Number Identification Service) */ - ftdm_number_t rdnis; /*!< RDNIS (Redirected Dialed Number Identification Service) */ - ftdm_number_t loc; /*!< LOC (Location Reference Code) */ - char aniII[FTDM_DIGITS_LIMIT]; /*! ANI II */ - uint8_t screen; /*!< Screening */ - uint8_t pres; /*!< Presentation*/ - char collected[FTDM_DIGITS_LIMIT]; /*!< Collected digits so far */ - int hangup_cause; /*!< Hangup cause */ - /* these 2 are undocumented right now, only used by boost: */ - /* bearer capability */ - ftdm_bearer_cap_t bearer_capability; - /* user information layer 1 protocol */ - ftdm_user_layer1_prot_t bearer_layer1; - ftdm_calling_party_category_t cpc; /*!< Calling party category */ - uint32_t call_reference; - - ftdm_channel_t *fchan; /*!< FreeTDM channel associated (can be NULL) */ - - /* - * We need call_id inside caller_data for the user to be able to retrieve - * the call_id when ftdm_channel_call_place is called. This is the only time - * that the user can use caller_data.call_id to obtain the call_id. The user - * should use the call_id from sigmsg otherwise - */ - uint32_t call_id; /*!< Unique call ID for this call */ - - void *priv; /*!< Private data for the FreeTDM user */ -} ftdm_caller_data_t; - -/*! \brief Hunting mode */ -typedef enum { - FTDM_HUNT_SPAN, /*!< Hunt channels in a given span */ - FTDM_HUNT_GROUP, /*!< Hunt channels in a given group */ - FTDM_HUNT_CHAN, /*!< Hunt for a specific channel */ -} ftdm_hunt_mode_t; - -/*! \brief Structure used for FTDM_HUNT_SPAN mode */ -typedef struct { - uint32_t span_id; - ftdm_hunt_direction_t direction; -} ftdm_span_hunt_t; - -/*! \brief Structure used for FTDM_HUNT_GROUP mode */ -typedef struct { - uint32_t group_id; - ftdm_hunt_direction_t direction; -} ftdm_group_hunt_t; - -/*! \brief Structure used for FTDM_HUNT_CHAN mode */ -typedef struct { - uint32_t span_id; - uint32_t chan_id; -} ftdm_chan_hunt_t; - -/*! \brief Function called before placing the call in the hunted channel - * The user can have a last saying in whether to proceed or abort - * the call attempt. Be aware that this callback will be called with - * the channel lock and you must not do any blocking operations during - * its execution. - * \param fchan The channel that will be used to place the call - * \param caller_data The caller data provided to ftdm_call_place - * \return FTDM_SUCCESS to proceed or FTDM_BREAK to abort the hunting - */ -typedef ftdm_status_t (*ftdm_hunt_result_cb_t)(ftdm_channel_t *fchan, ftdm_caller_data_t *caller_data); - -/*! \brief Channel Hunting provided to ftdm_call_place() */ -typedef struct { - ftdm_hunt_mode_t mode; - union { - ftdm_span_hunt_t span; - ftdm_group_hunt_t group; - ftdm_chan_hunt_t chan; - } mode_data; - ftdm_hunt_result_cb_t result_cb; -} ftdm_hunting_scheme_t; - - -/*! \brief Tone type */ -typedef enum { - FTDM_TONE_DTMF = (1 << 0) -} ftdm_tone_type_t; - -/*! \brief Signaling messages sent by the stacks */ -typedef enum { - FTDM_SIGEVENT_START,/*!< Incoming call (ie: incoming SETUP msg or Ring) */ - FTDM_SIGEVENT_STOP, /*!< Hangup */ - FTDM_SIGEVENT_RELEASED, /*!< Channel is completely released and available */ - FTDM_SIGEVENT_UP, /*!< Outgoing call has been answered */ - FTDM_SIGEVENT_FLASH, /*!< Flash event (typically on-hook/off-hook for analog devices) */ - FTDM_SIGEVENT_PROCEED, /*!< Outgoing call got an initial positive response from the other end */ - FTDM_SIGEVENT_RINGING, /*!< Remote side is in ringing state */ - FTDM_SIGEVENT_PROGRESS, /*!< Outgoing call is making progress */ - FTDM_SIGEVENT_PROGRESS_MEDIA, /*!< Outgoing call is making progress and there is media available */ - FTDM_SIGEVENT_ALARM_TRAP, /*!< Hardware alarm ON */ - FTDM_SIGEVENT_ALARM_CLEAR, /*!< Hardware alarm OFF */ - FTDM_SIGEVENT_COLLECTED_DIGIT, /*!< Digit collected (in signalings where digits are collected one by one) */ - FTDM_SIGEVENT_ADD_CALL, /*!< New call should be added to the channel */ - FTDM_SIGEVENT_RESTART, /*!< Restart has been requested. Typically you hangup your call resources here */ - FTDM_SIGEVENT_SIGSTATUS_CHANGED, /*!< Signaling protocol status changed (ie: D-chan up), see new status in raw_data ftdm_sigmsg_t member */ - FTDM_SIGEVENT_FACILITY, /*!< In call facility event */ - FTDM_SIGEVENT_TRACE, /*!priv */ - ftdm_variable_container_t variables; - union { - ftdm_event_sigstatus_t sigstatus; /*!< valid if event_id is FTDM_SIGEVENT_SIGSTATUS_CHANGED */ - ftdm_event_trace_t trace; /*!< valid if event_id is FTDM_SIGEVENT_TRACE or FTDM_SIGEVENT_TRACE_RAW */ - ftdm_event_collected_t collected; /*!< valid if event_id is FTDM_SIGEVENT_COLLECTED_DIGIT */ - ftdm_event_indication_completed_t indication_completed; /*!< valid if the event_id is FTDM_SIGEVENT_INDICATION_COMPLETED */ - ftdm_event_transfer_completed_t transfer_completed; - } ev_data; - ftdm_raw_data_t raw; -}; - -/*! \brief Generic user message sent to the stack */ -struct ftdm_usrmsg { - ftdm_variable_container_t variables; - ftdm_raw_data_t raw; -}; - -/*! \brief Crash policy - * Useful for debugging only, default policy is never, if you wish to crash on asserts then use ftdm_global_set_crash_policy */ -typedef enum { - FTDM_CRASH_NEVER = 0, - FTDM_CRASH_ON_ASSERT -} ftdm_crash_policy_t; - -/*! \brief Signaling configuration parameter for the stacks (variable=value pair) */ -typedef struct ftdm_conf_parameter { - const char *var; - const char *val; - void *ptr; -} ftdm_conf_parameter_t; - -/*! \brief Opaque general purpose iterator */ -typedef struct ftdm_iterator ftdm_iterator_t; - -/*! \brief Channel commands that can be executed through ftdm_channel_command() */ -typedef enum { - FTDM_COMMAND_NOOP = 0, - FTDM_COMMAND_SET_INTERVAL = 1, - FTDM_COMMAND_GET_INTERVAL = 2, - FTDM_COMMAND_SET_CODEC = 3, - FTDM_COMMAND_GET_CODEC = 4, - FTDM_COMMAND_SET_NATIVE_CODEC = 5, - FTDM_COMMAND_GET_NATIVE_CODEC = 6, - FTDM_COMMAND_ENABLE_DTMF_DETECT = 7, - FTDM_COMMAND_DISABLE_DTMF_DETECT = 8, - FTDM_COMMAND_SEND_DTMF = 9, - FTDM_COMMAND_SET_DTMF_ON_PERIOD = 10, - FTDM_COMMAND_GET_DTMF_ON_PERIOD = 11, - FTDM_COMMAND_SET_DTMF_OFF_PERIOD = 12, - FTDM_COMMAND_GET_DTMF_OFF_PERIOD = 13, - FTDM_COMMAND_GENERATE_RING_ON = 14, - FTDM_COMMAND_GENERATE_RING_OFF = 15, - FTDM_COMMAND_OFFHOOK = 16, - FTDM_COMMAND_ONHOOK = 17, - FTDM_COMMAND_FLASH = 18, - FTDM_COMMAND_WINK = 19, - FTDM_COMMAND_ENABLE_PROGRESS_DETECT = 20, - FTDM_COMMAND_DISABLE_PROGRESS_DETECT = 21, - - /*!< Start tracing input and output from channel to the given file */ - FTDM_COMMAND_TRACE_INPUT = 22, - FTDM_COMMAND_TRACE_OUTPUT = 23, - - /*!< Stop both Input and Output trace, closing the files */ - FTDM_COMMAND_TRACE_END_ALL = 24, - - /*!< Enable DTMF debugging */ - FTDM_COMMAND_ENABLE_DEBUG_DTMF = 25, - - /*!< Disable DTMF debugging (if not disabled explicitly, it is disabled automatically when calls hangup) */ - FTDM_COMMAND_DISABLE_DEBUG_DTMF = 26, - - /*!< Start dumping all input to a circular buffer. The size of the circular buffer can be specified, default used otherwise */ - FTDM_COMMAND_ENABLE_INPUT_DUMP = 27, - - /*!< Stop dumping all input to a circular buffer. */ - FTDM_COMMAND_DISABLE_INPUT_DUMP = 28, - - /*!< Start dumping all output to a circular buffer. The size of the circular buffer can be specified, default used otherwise */ - FTDM_COMMAND_ENABLE_OUTPUT_DUMP = 29, - - /*!< Stop dumping all output to a circular buffer. */ - FTDM_COMMAND_DISABLE_OUTPUT_DUMP = 30, - - /*!< Dump the current input circular buffer to the specified FILE* structure */ - FTDM_COMMAND_DUMP_INPUT = 31, - - /*!< Dump the current output circular buffer to the specified FILE* structure */ - FTDM_COMMAND_DUMP_OUTPUT = 32, - - FTDM_COMMAND_ENABLE_CALLERID_DETECT = 33, - FTDM_COMMAND_DISABLE_CALLERID_DETECT = 34, - FTDM_COMMAND_ENABLE_ECHOCANCEL = 35, - FTDM_COMMAND_DISABLE_ECHOCANCEL = 36, - FTDM_COMMAND_ENABLE_ECHOTRAIN = 37, - FTDM_COMMAND_DISABLE_ECHOTRAIN = 38, - FTDM_COMMAND_SET_CAS_BITS = 39, - FTDM_COMMAND_GET_CAS_BITS = 40, - FTDM_COMMAND_SET_RX_GAIN = 41, - FTDM_COMMAND_GET_RX_GAIN = 42, - FTDM_COMMAND_SET_TX_GAIN = 43, - FTDM_COMMAND_GET_TX_GAIN = 44, - FTDM_COMMAND_FLUSH_TX_BUFFERS = 45, - FTDM_COMMAND_FLUSH_RX_BUFFERS = 46, - FTDM_COMMAND_FLUSH_BUFFERS = 47, - - /*!< Flush IO statistics */ - FTDM_COMMAND_FLUSH_IOSTATS = 48, - - FTDM_COMMAND_SET_PRE_BUFFER_SIZE = 49, - FTDM_COMMAND_SET_LINK_STATUS = 50, - FTDM_COMMAND_GET_LINK_STATUS = 51, - FTDM_COMMAND_ENABLE_LOOP = 52, - FTDM_COMMAND_DISABLE_LOOP = 53, - FTDM_COMMAND_SET_RX_QUEUE_SIZE = 54, - FTDM_COMMAND_SET_TX_QUEUE_SIZE = 55, - FTDM_COMMAND_SET_POLARITY = 56, - FTDM_COMMAND_START_MF_PLAYBACK = 57, - FTDM_COMMAND_STOP_MF_PLAYBACK = 58, - - /*!< Get a copy of the current IO stats */ - FTDM_COMMAND_GET_IOSTATS = 59, - /*!< Enable/disable IO stats in the channel */ - FTDM_COMMAND_SWITCH_IOSTATS = 60, - - /*!< Enable/disable DTMF removal */ - FTDM_COMMAND_ENABLE_DTMF_REMOVAL = 61, - FTDM_COMMAND_DISABLE_DTMF_REMOVAL = 62, - - FTDM_COMMAND_COUNT, -} ftdm_command_t; - -typedef enum { - FTDM_POLARITY_FORWARD = 0, - FTDM_POLARITY_REVERSE = 1 -} ftdm_polarity_t; - -/*! \brief Custom memory handler hooks. Not recommended to use unless you need memory allocation customizations */ -typedef void *(*ftdm_malloc_func_t)(void *pool, ftdm_size_t len); -typedef void *(*ftdm_calloc_func_t)(void *pool, ftdm_size_t elements, ftdm_size_t len); -typedef void *(*ftdm_realloc_func_t)(void *pool, void *buff, ftdm_size_t len); -typedef void (*ftdm_free_func_t)(void *pool, void *ptr); -struct ftdm_memory_handler { - void *pool; - ftdm_malloc_func_t malloc; - ftdm_calloc_func_t calloc; - ftdm_realloc_func_t realloc; - ftdm_free_func_t free; -}; - -/*! \brief FreeTDM I/O layer interface argument macros - * You don't need these unless your implementing an I/O interface module (most users don't) */ -#define FIO_CHANNEL_REQUEST_ARGS (ftdm_span_t *span, uint32_t chan_id, ftdm_hunt_direction_t direction, ftdm_caller_data_t *caller_data, ftdm_channel_t **ftdmchan) -#define FIO_CHANNEL_OUTGOING_CALL_ARGS (ftdm_channel_t *ftdmchan) -#define FIO_CHANNEL_INDICATE_ARGS (ftdm_channel_t *ftdmchan, ftdm_channel_indication_t indication) -#define FIO_CHANNEL_SET_SIG_STATUS_ARGS (ftdm_channel_t *ftdmchan, ftdm_signaling_status_t status) -#define FIO_CHANNEL_GET_SIG_STATUS_ARGS (ftdm_channel_t *ftdmchan, ftdm_signaling_status_t *status) -#define FIO_SPAN_SET_SIG_STATUS_ARGS (ftdm_span_t *span, ftdm_signaling_status_t status) -#define FIO_SPAN_GET_SIG_STATUS_ARGS (ftdm_span_t *span, ftdm_signaling_status_t *status) -#define FIO_SPAN_POLL_EVENT_ARGS (ftdm_span_t *span, uint32_t ms, short *poll_events) -#define FIO_SPAN_NEXT_EVENT_ARGS (ftdm_span_t *span, ftdm_event_t **event) -#define FIO_CHANNEL_NEXT_EVENT_ARGS (ftdm_channel_t *ftdmchan, ftdm_event_t **event) -#define FIO_SIGNAL_CB_ARGS (ftdm_sigmsg_t *sigmsg) -#define FIO_EVENT_CB_ARGS (ftdm_channel_t *ftdmchan, ftdm_event_t *event) -#define FIO_CONFIGURE_SPAN_ARGS (ftdm_span_t *span, const char *str, ftdm_chan_type_t type, char *name, char *number) -#define FIO_CONFIGURE_ARGS (const char *category, const char *var, const char *val, int lineno) -#define FIO_OPEN_ARGS (ftdm_channel_t *ftdmchan) -#define FIO_CLOSE_ARGS (ftdm_channel_t *ftdmchan) -#define FIO_CHANNEL_DESTROY_ARGS (ftdm_channel_t *ftdmchan) -#define FIO_SPAN_DESTROY_ARGS (ftdm_span_t *span) -#define FIO_COMMAND_ARGS (ftdm_channel_t *ftdmchan, ftdm_command_t command, void *obj) -#define FIO_WAIT_ARGS (ftdm_channel_t *ftdmchan, ftdm_wait_flag_t *flags, int32_t to) -#define FIO_GET_ALARMS_ARGS (ftdm_channel_t *ftdmchan) -#define FIO_READ_ARGS (ftdm_channel_t *ftdmchan, void *data, ftdm_size_t *datalen) -#define FIO_WRITE_ARGS (ftdm_channel_t *ftdmchan, void *data, ftdm_size_t *datalen) -#define FIO_IO_LOAD_ARGS (ftdm_io_interface_t **fio) -#define FIO_IO_UNLOAD_ARGS (void) -#define FIO_SIG_LOAD_ARGS (void) -#define FIO_SIG_CONFIGURE_ARGS (ftdm_span_t *span, fio_signal_cb_t sig_cb, va_list ap) -#define FIO_CONFIGURE_SPAN_SIGNALING_ARGS (ftdm_span_t *span, fio_signal_cb_t sig_cb, ftdm_conf_parameter_t *ftdm_parameters) -#define FIO_SIG_UNLOAD_ARGS (void) -#define FIO_API_ARGS (ftdm_stream_handle_t *stream, const char *data) -#define FIO_SPAN_START_ARGS (ftdm_span_t *span) -#define FIO_SPAN_STOP_ARGS (ftdm_span_t *span) - -/*! \brief FreeTDM I/O layer interface function typedefs - * You don't need these unless your implementing an I/O interface module (most users don't) */ -typedef ftdm_status_t (*fio_channel_request_t) FIO_CHANNEL_REQUEST_ARGS ; -typedef ftdm_status_t (*fio_channel_outgoing_call_t) FIO_CHANNEL_OUTGOING_CALL_ARGS ; -typedef ftdm_status_t (*fio_channel_indicate_t) FIO_CHANNEL_INDICATE_ARGS; -typedef ftdm_status_t (*fio_channel_set_sig_status_t) FIO_CHANNEL_SET_SIG_STATUS_ARGS; -typedef ftdm_status_t (*fio_channel_get_sig_status_t) FIO_CHANNEL_GET_SIG_STATUS_ARGS; -typedef ftdm_status_t (*fio_span_set_sig_status_t) FIO_SPAN_SET_SIG_STATUS_ARGS; -typedef ftdm_status_t (*fio_span_get_sig_status_t) FIO_SPAN_GET_SIG_STATUS_ARGS; -typedef ftdm_status_t (*fio_span_poll_event_t) FIO_SPAN_POLL_EVENT_ARGS ; -typedef ftdm_status_t (*fio_span_next_event_t) FIO_SPAN_NEXT_EVENT_ARGS ; -typedef ftdm_status_t (*fio_channel_next_event_t) FIO_CHANNEL_NEXT_EVENT_ARGS ; - -/*! \brief Callback for signal delivery (FTDM_SIGEVENT_START and friends) - * \note This callback is provided by the user during ftdm_configure_span_signaling - * - * \note You must NOT do any blocking during this callback since this function is - * most likely called in an internal signaling thread that can potentially be - * shared for all the channels in a span and blocking will delay processing - * (sometimes even audio processing) for other channels - * - * \note Although some simple FreeTDM APIs can work (ie: ftdm_span_get_id etc), the - * use of any FreeTDM call API (ie ftdm_channel_call_answer) is discouraged - */ -typedef ftdm_status_t (*fio_signal_cb_t) FIO_SIGNAL_CB_ARGS ; - -typedef ftdm_status_t (*fio_event_cb_t) FIO_EVENT_CB_ARGS ; -typedef ftdm_status_t (*fio_configure_span_t) FIO_CONFIGURE_SPAN_ARGS ; -typedef ftdm_status_t (*fio_configure_t) FIO_CONFIGURE_ARGS ; -typedef ftdm_status_t (*fio_open_t) FIO_OPEN_ARGS ; -typedef ftdm_status_t (*fio_close_t) FIO_CLOSE_ARGS ; -typedef ftdm_status_t (*fio_channel_destroy_t) FIO_CHANNEL_DESTROY_ARGS ; -typedef ftdm_status_t (*fio_span_destroy_t) FIO_SPAN_DESTROY_ARGS ; -typedef ftdm_status_t (*fio_get_alarms_t) FIO_GET_ALARMS_ARGS ; -typedef ftdm_status_t (*fio_command_t) FIO_COMMAND_ARGS ; -typedef ftdm_status_t (*fio_wait_t) FIO_WAIT_ARGS ; -typedef ftdm_status_t (*fio_read_t) FIO_READ_ARGS ; -typedef ftdm_status_t (*fio_write_t) FIO_WRITE_ARGS ; -typedef ftdm_status_t (*fio_io_load_t) FIO_IO_LOAD_ARGS ; -typedef ftdm_status_t (*fio_sig_load_t) FIO_SIG_LOAD_ARGS ; -typedef ftdm_status_t (*fio_sig_configure_t) FIO_SIG_CONFIGURE_ARGS ; -typedef ftdm_status_t (*fio_configure_span_signaling_t) FIO_CONFIGURE_SPAN_SIGNALING_ARGS ; -typedef ftdm_status_t (*fio_io_unload_t) FIO_IO_UNLOAD_ARGS ; -typedef ftdm_status_t (*fio_sig_unload_t) FIO_SIG_UNLOAD_ARGS ; -typedef ftdm_status_t (*fio_api_t) FIO_API_ARGS ; -typedef ftdm_status_t (*fio_span_start_t) FIO_SPAN_START_ARGS ; -typedef ftdm_status_t (*fio_span_stop_t) FIO_SPAN_STOP_ARGS ; - - -/*! \brief FreeTDM I/O layer interface function prototype wrapper macros - * You don't need these unless your implementing an I/O interface module (most users don't) */ -#define FIO_CHANNEL_REQUEST_FUNCTION(name) ftdm_status_t name FIO_CHANNEL_REQUEST_ARGS -#define FIO_CHANNEL_OUTGOING_CALL_FUNCTION(name) ftdm_status_t name FIO_CHANNEL_OUTGOING_CALL_ARGS -#define FIO_CHANNEL_INDICATE_FUNCTION(name) ftdm_status_t name FIO_CHANNEL_INDICATE_ARGS -#define FIO_CHANNEL_SET_SIG_STATUS_FUNCTION(name) ftdm_status_t name FIO_CHANNEL_SET_SIG_STATUS_ARGS -#define FIO_CHANNEL_GET_SIG_STATUS_FUNCTION(name) ftdm_status_t name FIO_CHANNEL_GET_SIG_STATUS_ARGS -#define FIO_SPAN_SET_SIG_STATUS_FUNCTION(name) ftdm_status_t name FIO_SPAN_SET_SIG_STATUS_ARGS -#define FIO_SPAN_GET_SIG_STATUS_FUNCTION(name) ftdm_status_t name FIO_SPAN_GET_SIG_STATUS_ARGS -#define FIO_SPAN_POLL_EVENT_FUNCTION(name) ftdm_status_t name FIO_SPAN_POLL_EVENT_ARGS -#define FIO_SPAN_NEXT_EVENT_FUNCTION(name) ftdm_status_t name FIO_SPAN_NEXT_EVENT_ARGS -#define FIO_CHANNEL_NEXT_EVENT_FUNCTION(name) ftdm_status_t name FIO_CHANNEL_NEXT_EVENT_ARGS -#define FIO_SIGNAL_CB_FUNCTION(name) ftdm_status_t name FIO_SIGNAL_CB_ARGS -#define FIO_EVENT_CB_FUNCTION(name) ftdm_status_t name FIO_EVENT_CB_ARGS -#define FIO_CONFIGURE_SPAN_FUNCTION(name) ftdm_status_t name FIO_CONFIGURE_SPAN_ARGS -#define FIO_CONFIGURE_FUNCTION(name) ftdm_status_t name FIO_CONFIGURE_ARGS -#define FIO_OPEN_FUNCTION(name) ftdm_status_t name FIO_OPEN_ARGS -#define FIO_CLOSE_FUNCTION(name) ftdm_status_t name FIO_CLOSE_ARGS -#define FIO_CHANNEL_DESTROY_FUNCTION(name) ftdm_status_t name FIO_CHANNEL_DESTROY_ARGS -#define FIO_SPAN_DESTROY_FUNCTION(name) ftdm_status_t name FIO_SPAN_DESTROY_ARGS -#define FIO_GET_ALARMS_FUNCTION(name) ftdm_status_t name FIO_GET_ALARMS_ARGS -#define FIO_COMMAND_FUNCTION(name) ftdm_status_t name FIO_COMMAND_ARGS -#define FIO_WAIT_FUNCTION(name) ftdm_status_t name FIO_WAIT_ARGS -#define FIO_READ_FUNCTION(name) ftdm_status_t name FIO_READ_ARGS -#define FIO_WRITE_FUNCTION(name) ftdm_status_t name FIO_WRITE_ARGS -#define FIO_IO_LOAD_FUNCTION(name) ftdm_status_t name FIO_IO_LOAD_ARGS -#define FIO_SIG_LOAD_FUNCTION(name) ftdm_status_t name FIO_SIG_LOAD_ARGS -#define FIO_SIG_CONFIGURE_FUNCTION(name) ftdm_status_t name FIO_SIG_CONFIGURE_ARGS -#define FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(name) ftdm_status_t name FIO_CONFIGURE_SPAN_SIGNALING_ARGS -#define FIO_IO_UNLOAD_FUNCTION(name) ftdm_status_t name FIO_IO_UNLOAD_ARGS -#define FIO_SIG_UNLOAD_FUNCTION(name) ftdm_status_t name FIO_SIG_UNLOAD_ARGS -#define FIO_API_FUNCTION(name) ftdm_status_t name FIO_API_ARGS -#define FIO_SPAN_START_FUNCTION(name) ftdm_status_t name FIO_SPAN_START_ARGS -#define FIO_SPAN_STOP_FUNCTION(name) ftdm_status_t name FIO_SPAN_STOP_ARGS - -/*! \brief FreeTDM I/O layer function prototype wrapper macros - * You don't need these unless your implementing an I/O interface module (most users don't) */ -struct ftdm_io_interface { - const char *name; /*!< I/O module name */ - fio_configure_span_t configure_span; /*!< Configure span I/O */ - fio_configure_t configure; /*!< Configure the module */ - fio_open_t open; /*!< Open I/O channel */ - fio_close_t close; /*!< Close I/O channel */ - fio_channel_destroy_t channel_destroy; /*!< Destroy I/O channel */ - fio_span_destroy_t span_destroy; /*!< Destroy span I/O */ - fio_get_alarms_t get_alarms; /*!< Get hardware alarms */ - fio_command_t command; /*!< Execute an I/O command on the channel */ - fio_wait_t wait; /*!< Wait for events on the channel */ - fio_read_t read; /*!< Read data from the channel */ - fio_write_t write; /*!< Write data to the channel */ - fio_span_poll_event_t poll_event; /*!< Poll for events on the whole span */ - fio_span_next_event_t next_event; /*!< Retrieve an event from the span */ - fio_channel_next_event_t channel_next_event; /*!< Retrieve an event from channel */ - fio_api_t api; /*!< Execute a text command */ - fio_span_start_t span_start; /*!< Start span I/O */ - fio_span_stop_t span_stop; /*!< Stop span I/O */ -}; - -/*! \brief FreeTDM supported I/O codecs */ -typedef enum { - FTDM_CODEC_ULAW = 0, - FTDM_CODEC_ALAW = 8, - FTDM_CODEC_SLIN = 10, - FTDM_CODEC_NONE = (1 << 30) -} ftdm_codec_t; - -/*! \brief FreeTDM supported hardware alarms. */ -typedef enum { - FTDM_ALARM_NONE = 0, - FTDM_ALARM_RED = (1 << 0), - FTDM_ALARM_YELLOW = (1 << 1), - FTDM_ALARM_RAI = (1 << 2), - FTDM_ALARM_BLUE = (1 << 3), - FTDM_ALARM_AIS = (1 << 4), - FTDM_ALARM_GENERAL = (1 << 30) -} ftdm_alarm_flag_t; - -/*! \brief MF generation direction flags - * \note Used in bitwise OR with channel ID as argument to MF_PLAYBACK I/O command, so value must be higher that 255 - * \see FTDM_COMMAND_START_MF_PLAYBACK - * */ - -typedef enum { - FTDM_MF_DIRECTION_FORWARD = (1 << 8), - FTDM_MF_DIRECTION_BACKWARD = (1 << 9) -} ftdm_mf_direction_flag_t; - -/*! \brief IO Error statistics */ -typedef enum { - FTDM_IOSTATS_ERROR_CRC = (1 << 0), - FTDM_IOSTATS_ERROR_FRAME = (1 << 1), - FTDM_IOSTATS_ERROR_ABORT = (1 << 2), - FTDM_IOSTATS_ERROR_FIFO = (1 << 3), - FTDM_IOSTATS_ERROR_DMA = (1 << 4), - FTDM_IOSTATS_ERROR_QUEUE_THRES = (1 << 5), /* Queue reached high threshold */ - FTDM_IOSTATS_ERROR_QUEUE_FULL = (1 << 6), /* Queue is full */ -} ftdm_iostats_error_type_t; - -/*! \brief IO statistics */ -typedef struct { - struct { - uint64_t packets; - uint32_t errors; - uint16_t flags; - uint8_t queue_size; /*!< max queue size configured */ - uint8_t queue_len; /*!< Current number of elements in queue */ - } rx; - - struct { - uint64_t idle_packets; - uint64_t packets; - uint32_t errors; - uint16_t flags; - uint8_t queue_size; /*!< max queue size configured */ - uint8_t queue_len; /*!< Current number of elements in queue */ - } tx; -} ftdm_channel_iostats_t; - -/*! \brief Override the default queue handler */ -FT_DECLARE(ftdm_status_t) ftdm_global_set_queue_handler(ftdm_queue_handler_t *handler); - -/*! \brief Return the availability rate for a channel - * \param ftdmchan Channel to get the availability from - * - * \retval > 0 if availability is supported - * \retval -1 if availability is not supported - */ -FT_DECLARE(int) ftdm_channel_get_availability(ftdm_channel_t *ftdmchan); - -/*! \brief Answer call. This can also be accomplished by ftdm_channel_call_indicate with FTDM_CHANNEL_INDICATE_ANSWER, in both - * cases you will get a FTDM_SIGEVENT_INDICATION_COMPLETED when the indication is sent (or an error occurs). - * Just as with ftdm_channel_call_indicate you won't receive FTDM_SIGEVENT_INDICATION_COMPLETED when this function - * returns anything else than FTDM_SUCCESS - * \note Although this API may result in FTDM_SIGEVENT_INDICATION_COMPLETED event being delivered, - * there is no guarantee of whether the event will arrive after or before your execution thread returns - * from ftdm_channel_call_answer - */ -#define ftdm_channel_call_answer(ftdmchan) _ftdm_channel_call_answer(__FILE__, __FTDM_FUNC__, __LINE__, (ftdmchan), NULL) -#define ftdm_channel_call_answer_ex(ftdmchan, usrmsg) _ftdm_channel_call_answer(__FILE__, __FTDM_FUNC__, __LINE__, (ftdmchan), (usrmsg)) - -/*! \brief Answer call recording the source code point where the it was called (see ftdm_channel_call_answer for an easy to use macro) */ -FT_DECLARE(ftdm_status_t) _ftdm_channel_call_answer(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_usrmsg_t *usrmsg); - -/*! \brief Place an outgoing call in the given channel - * \deprecated This macro is deprecated since leaves the door open to glare issues, use ftdm_call_place instead - */ -#define ftdm_channel_call_place(ftdmchan) _ftdm_channel_call_place(__FILE__, __FTDM_FUNC__, __LINE__, (ftdmchan), NULL) -#define ftdm_channel_call_place_ex(ftdmchan, usrmsg) _ftdm_channel_call_place_ex(__FILE__, __FTDM_FUNC__, __LINE__, (ftdmchan), (usrmsg)) - -/*! \brief Place an outgoing call recording the source code point where it was called (see ftdm_channel_call_place for an easy to use macro) - * \deprecated This function is deprecated since leaves the door open to glare issues, use ftdm_call_place instead - */ -FT_DECLARE(ftdm_status_t) _ftdm_channel_call_place(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_usrmsg_t *usrmsg); - -/*! \brief Place an outgoing call with the given caller data in a channel according to the hunting scheme provided */ -#define ftdm_call_place(callerdata, hunting) _ftdm_call_place(__FILE__, __FTDM_FUNC__, __LINE__, (callerdata), (hunting), NULL) -#define ftdm_call_place_ex(callerdata, hunting, usrmsg) _ftdm_call_place(__FILE__, __FTDM_FUNC__, __LINE__, (callerdata), (hunting), (usrmsg)) - -/*! \brief Place an outgoing call with the given caller data in a channel according to the hunting scheme provided and records - * the place where it was called. See ftdm_call_place for an easy to use macro - * \return FTDM_SUCCESS if the call attempt was successful - * FTDM_FAIL if there was an unspecified error - * FTDM_EBUSY if the channel was busy - * FTDM_BREAK if glare was detected and you must try again - * \note Even when FTDM_SUCCESS is returned, the call may still fail later on due to glare, in such case FTDM_SIGEVENT_STOP - * will be sent with the hangup cause field set to FTDM_CAUSE_REQUESTED_CHAN_UNAVAIL - * - * \note When this function returns FTDM_SUCCESS, the member .fchan from caller_data will be set to the channel used to place the call - * and .call_id to the generated call id for that call - * - * \note When this function is successful you are guaranteed to receive FTDM_SIGEVENT_DIALING, this event could even be delivered - * before your execution thread returns from this function - */ -FT_DECLARE(ftdm_status_t) _ftdm_call_place(const char *file, const char *func, int line, ftdm_caller_data_t *caller_data, ftdm_hunting_scheme_t *hunting, ftdm_usrmsg_t *usrmsg); - -/*! \brief Indicate a new condition in an incoming call - * - * \note Every indication request will result in FTDM_SIGEVENT_INDICATION_COMPLETED event being delivered with - * the proper status that will inform you if the request was successful or not. The exception is if this - * function returns something different to FTDM_SUCCESS, in which case the request failed right away and no - * further FTDM_SIGEVENT_INDICATION_COMPLETED will be delivered - * Be aware there is no guarantee of whether the completion event will arrive after or before your execution - * thread returns from ftdm_channel_call_indicate. This means you could get FTDM_SIGEVENT_INDICATION_COMPLETED - * even before your execution thread returns from the ftdm_channel_call_indicate() API - * - * \note You cannot send more than one indication at the time. You must wait for the completed event before - * calling this function again (unless the return code was different than FTDM_SUCCESS) - */ -#define ftdm_channel_call_indicate(ftdmchan, indication) _ftdm_channel_call_indicate(__FILE__, __FTDM_FUNC__, __LINE__, (ftdmchan), (indication), NULL) -#define ftdm_channel_call_indicate_ex(ftdmchan, indication, usrmsg) _ftdm_channel_call_indicate(__FILE__, __FTDM_FUNC__, __LINE__, (ftdmchan), (indication), (usrmsg)) - -/*! \brief Indicate a new condition in an incoming call recording the source code point where it was called (see ftdm_channel_call_indicate for an easy to use macro) */ -FT_DECLARE(ftdm_status_t) _ftdm_channel_call_indicate(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_channel_indication_t indication, ftdm_usrmsg_t *usrmsg); - -/*! \brief Hangup the call without cause */ -#define ftdm_channel_call_hangup(ftdmchan) _ftdm_channel_call_hangup(__FILE__, __FTDM_FUNC__, __LINE__, (ftdmchan), NULL) -#define ftdm_channel_call_hangup_ex(ftdmchan, usrmsg) _ftdm_channel_call_hangup(__FILE__, __FTDM_FUNC__, __LINE__, (ftdmchan), (usrmsg)) - -/*! \brief Hangup the call without cause recording the source code point where it was called (see ftdm_channel_call_hangup for an easy to use macro)*/ -FT_DECLARE(ftdm_status_t) _ftdm_channel_call_hangup(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_usrmsg_t *usrmsg); - -/*! \brief Hangup the call with cause */ -#define ftdm_channel_call_hangup_with_cause(ftdmchan, cause) _ftdm_channel_call_hangup_with_cause(__FILE__, __FTDM_FUNC__, __LINE__, (ftdmchan), (cause), NULL) -#define ftdm_channel_call_hangup_with_cause_ex(ftdmchan, cause, usrmsg) _ftdm_channel_call_hangup_with_cause(__FILE__, __FTDM_FUNC__, __LINE__, (ftdmchan), (cause), (usrmsg)) - -/*! \brief Hangup the call with cause recording the source code point where it was called (see ftdm_channel_call_hangup_with_cause for an easy to use macro) */ -FT_DECLARE(ftdm_status_t) _ftdm_channel_call_hangup_with_cause(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_call_cause_t, ftdm_usrmsg_t *usrmsg); - -/*! \brief Transfer call. This can also be accomplished by ftdm_channel_call_indicate with FTDM_CHANNEL_INDICATE_TRANSFER, in both - * cases you will get a FTDM_SIGEVENT_INDICATION_COMPLETED when the indication is sent (or an error occurs). - * Just as with ftdm_channel_call_indicate you won't receive FTDM_SIGEVENT_INDICATION_COMPLETED when this function - * returns anything else than FTDM_SUCCESS - * \note Although this API may result in FTDM_SIGEVENT_INDICATION_COMPLETED event being delivered, - * there is no guarantee of whether the event will arrive after or before your execution thread returns - * from ftdm_channel_call_transfer - */ -#define ftdm_channel_call_transfer(ftdmchan, arg) _ftdm_channel_call_transfer(__FILE__, __FTDM_FUNC__, __LINE__, (ftdmchan), (arg), NULL) -#define ftdm_channel_call_transfer_ex(ftdmchan, arg, usrmsg) _ftdm_channel_call_transfer(__FILE__, __FTDM_FUNC__, __LINE__, (ftdmchan), (arg), (usrmsg)) - -/*! \brief Answer call recording the source code point where the it was called (see ftdm_channel_call_tranasfer for an easy to use macro) */ -FT_DECLARE(ftdm_status_t) _ftdm_channel_call_transfer(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, const char* arg, ftdm_usrmsg_t *usrmsg); - -/*! \brief Reset the channel */ -#define ftdm_channel_reset(ftdmchan) _ftdm_channel_reset(__FILE__, __FTDM_FUNC__, __LINE__, (ftdmchan), NULL) -#define ftdm_channel_reset_ex(ftdmchan, usrmsg) _ftdm_channel_reset(__FILE__, __FTDM_FUNC__, __LINE__, (ftdmchan), usrmsg) - -/*! \brief Reset the channel (see _ftdm_channel_reset for an easy to use macro) - * \note if there was a call on this channel, call will be cleared without any notifications to the user - */ -FT_DECLARE(ftdm_status_t) _ftdm_channel_reset(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_usrmsg_t *usrmsg); - -/*! \brief Put a call on hold (if supported by the signaling stack) */ -#define ftdm_channel_call_hold(ftdmchan) _ftdm_channel_call_hold(__FILE__, __FTDM_FUNC__, __LINE__, (ftdmchan), NULL) -#define ftdm_channel_call_hold_ex(ftdmchan, usrmsg) _ftdm_channel_call_hold(__FILE__, __FTDM_FUNC__, __LINE__, (ftdmchan), (usrmsg)) - -/*! \brief Put a call on hold recording the source code point where it was called (see ftdm_channel_call_hold for an easy to use macro) */ -FT_DECLARE(ftdm_status_t) _ftdm_channel_call_hold(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_usrmsg_t *usrmsg); - -/*! \brief Unhold a call */ -#define ftdm_channel_call_unhold(ftdmchan) _ftdm_channel_call_unhold(__FILE__, __FTDM_FUNC__, __LINE__, (ftdmchan), NULL) -#define ftdm_channel_call_unhold_ex(ftdmchan, usrmsg) _ftdm_channel_call_unhold(__FILE__, __FTDM_FUNC__, __LINE__, (ftdmchan), (usrmsg)) - -/*! \brief Unhold a call recording the source code point where it was called (see ftdm_channel_call_unhold for an easy to use macro) */ -FT_DECLARE(ftdm_status_t) _ftdm_channel_call_unhold(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_usrmsg_t *usrmsg); - -/*! \brief Check if the call is answered already */ -FT_DECLARE(ftdm_bool_t) ftdm_channel_call_check_answered(const ftdm_channel_t *ftdmchan); - -/*! \brief Check if the call is busy */ -FT_DECLARE(ftdm_bool_t) ftdm_channel_call_check_busy(const ftdm_channel_t *ftdmchan); - -/*! \brief Check if the call is hangup */ -FT_DECLARE(ftdm_bool_t) ftdm_channel_call_check_hangup(const ftdm_channel_t *ftdmchan); - -/*! \brief Check if the call is done (final state for a call, just after hangup) */ -FT_DECLARE(ftdm_bool_t) ftdm_channel_call_check_done(const ftdm_channel_t *ftdmchan); - -/*! \brief Check if the call is in hold */ -FT_DECLARE(ftdm_bool_t) ftdm_channel_call_check_hold(const ftdm_channel_t *ftdmchan); - -/*! \brief Set channel signaling status (ie: put specific circuit down) only if supported by the signaling */ -FT_DECLARE(ftdm_status_t) ftdm_channel_set_sig_status(ftdm_channel_t *ftdmchan, ftdm_signaling_status_t status); - -/*! \brief Get channel signaling status (ie: whether protocol layer is up or down) */ -FT_DECLARE(ftdm_status_t) ftdm_channel_get_sig_status(ftdm_channel_t *ftdmchan, ftdm_signaling_status_t *status); - -/*! \brief Set span signaling status (ie: put the whole span protocol layer down) only if supported by the signaling */ -FT_DECLARE(ftdm_status_t) ftdm_span_set_sig_status(ftdm_span_t *span, ftdm_signaling_status_t status); - -/*! \brief Get span signaling status (ie: whether protocol layer is up or down) */ -FT_DECLARE(ftdm_status_t) ftdm_span_get_sig_status(ftdm_span_t *span, ftdm_signaling_status_t *status); - - -/*! - * \brief Set user private data in the channel - * - * \param ftdmchan The channel where the private data will be stored - * \param pvt The private pointer to store - * - */ -FT_DECLARE(void) ftdm_channel_set_private(ftdm_channel_t *ftdmchan, void *pvt); - -/*! - * \brief Get user private data in the channel - * - * \param ftdmchan The channel to retrieve the private data - * \retval The private data (if any or NULL if no data has been stored) - * - */ -FT_DECLARE(void *) ftdm_channel_get_private(const ftdm_channel_t *ftdmchan); - -/*! - * \brief Remove the given token from the channel - * - * \param ftdmchan The channel where the token is - * \param token The token string. If NULL, all tokens in the channel are cleared - * - * \retval FTDM_SUCCESS success - * \retval FTDM_FAIL failure - */ -FT_DECLARE(ftdm_status_t) ftdm_channel_clear_token(ftdm_channel_t *ftdmchan, const char *token); - -/*! - * \brief Replace the given token with the new token - * - * \param ftdmchan The channel where the token is - * \param old_token The token to replace - * \param new_token The token to put in place - */ -FT_DECLARE(void) ftdm_channel_replace_token(ftdm_channel_t *ftdmchan, const char *old_token, const char *new_token); - -/*! - * \brief Add a new token to the channel - * - * \param ftdmchan The channel where the token will be added - * \param token The token string to add - * \param end if 0, the token will be added at the beginning of the token list, to the end otherwise - * - * \retval FTDM_SUCCESS success - * \retval FTDM_FAIL failure - */ -FT_DECLARE(ftdm_status_t) ftdm_channel_add_token(ftdm_channel_t *ftdmchan, char *token, int end); - -/*! - * \brief Get the requested token - * - * \param ftdmchan The channel where the token is - * \param tokenid The id of the token - * - * \retval The token character string - * \retval NULL token not found - */ -FT_DECLARE(const char *) ftdm_channel_get_token(const ftdm_channel_t *ftdmchan, uint32_t tokenid); - -/*! - * \brief Get the token count - * - * \param ftdmchan The channel to get the token count from - * - * \retval The token count - */ -FT_DECLARE(uint32_t) ftdm_channel_get_token_count(const ftdm_channel_t *ftdmchan); - -/*! - * \brief Get the I/O read/write interval - * - * \param ftdmchan The channel to get the interval from - * - * \retval The interval in milliseconds - */ -FT_DECLARE(uint32_t) ftdm_channel_get_io_interval(const ftdm_channel_t *ftdmchan); - -/*! - * \brief Get the I/O read/write packet length per interval - * - * \param ftdmchan The channel to get the packet length from - * - * \retval The packet length interval in bytes - */ -FT_DECLARE(uint32_t) ftdm_channel_get_io_packet_len(const ftdm_channel_t *ftdmchan); - -/*! - * \brief Get the I/O read/write codec - * - * \param ftdmchan The channel to get the codec from - * - * \retval The codec type - */ -FT_DECLARE(ftdm_codec_t) ftdm_channel_get_codec(const ftdm_channel_t *ftdmchan); - -/*! - * \brief Get the last error string for the channel - * - * \deprecated This API will disappear in the future and not every - * FreeTDM API set the last error value - * - * \param ftdmchan The channel to get the error from - * - * \retval The error string (not thread-safe, the string is per channel, not per thread) - */ -FT_DECLARE(const char *) ftdm_channel_get_last_error(const ftdm_channel_t *ftdmchan); - -/*! - * \brief Get the current alarm bitmask for the channel - * - * \param ftdmchan The channel to get the alarm bitmask from - * \param alarmbits The alarm bitmask pointer to store the current alarms (you are responsible for allocation/deallocation) - * - * \retval FTDM_SUCCESS success - * \retval FTDM_FAIL failure - */ -FT_DECLARE(ftdm_status_t) ftdm_channel_get_alarms(ftdm_channel_t *ftdmchan, ftdm_alarm_flag_t *alarmbits); - -/*! - * \brief Get the channel type - * - * \param ftdmchan The channel to get the type from - * - * \retval channel type (FXO, FXS, B-channel, D-channel, etc) - */ -FT_DECLARE(ftdm_chan_type_t) ftdm_channel_get_type(const ftdm_channel_t *ftdmchan); - -/*! - * \brief Dequeue DTMF from the given channel - * \note To transmit DTMF use ftdm_channel_command with command FTDM_COMMAND_SEND_DTMF - * - * \param ftdmchan The channel to dequeue DTMF from - * \param dtmf DTMF buffer to store the dtmf (you are responsible for its allocation and deallocation) - * \param len The size of the provided DTMF buffer - * - * \retval The size of the dequeued DTMF (it might be zero if there is no DTMF in the queue) - */ -FT_DECLARE(ftdm_size_t) ftdm_channel_dequeue_dtmf(ftdm_channel_t *ftdmchan, char *dtmf, ftdm_size_t len); - -/*! - * \brief Flush the DTMF queue - * - * \param ftdmchan The channel to flush the dtmf queue of - */ -FT_DECLARE(void) ftdm_channel_flush_dtmf(ftdm_channel_t *ftdmchan); - -/*! - * \brief Wait for an event in the span - * - * \param span The span to wait events for - * \param ms Milliseconds timeout - * \param poll_events Array of events to poll for, for each channel on the span - * - * \retval FTDM_SUCCESS success (at least one event available) - * \retval FTDM_TIMEOUT Timed out waiting for events - * \retval FTDM_FAIL failure - */ -FT_DECLARE(ftdm_status_t) ftdm_span_poll_event(ftdm_span_t *span, uint32_t ms, short *poll_events); - -/*! - * \brief Find a span by its id - * - * \param id The span id - * \param span Pointer to store the span if found - * - * \retval FTDM_SUCCESS success (span is valid) - * \retval FTDM_FAIL failure (span is not valid) - */ -FT_DECLARE(ftdm_status_t) ftdm_span_find(uint32_t id, ftdm_span_t **span); - -/*! - * \brief Get the last error string for the given span - * - * \deprecated This API will disappear in the future and not every - * FreeTDM API set the last error value - * - * \param span The span to get the last error from - * - * \retval character string for the last error - */ -FT_DECLARE(const char *) ftdm_span_get_last_error(const ftdm_span_t *span); - -/*! - * \brief Create a new span (not needed if you are using freetdm.conf) - * - * \param iotype The I/O interface type this span will use. - * This depends on the available I/O modules - * ftmod_wanpipe = "wanpipe" (Sangoma) - * ftmod_zt = "zt" (DAHDI or Zaptel) - * ftmod_pika "pika" (this one is most likely broken) - * \param name Name for the span - * \param span Pointer to store the create span - * - * \retval FTDM_SUCCESS success (the span was created) - * \retval FTDM_FAIL failure (span was not created) - */ -FT_DECLARE(ftdm_status_t) ftdm_span_create(const char *iotype, const char *name, ftdm_span_t **span); - -/*! - * \brief Add a new channel to a span - * - * \param span Where to add the new channel - * \param sockfd The socket device associated to the channel (ie: sangoma device, dahdi device etc) - * \param type Channel type - * \param chan Pointer to store the newly allocated channel - * - * \retval FTDM_SUCCESS success (the channel was created) - * \retval FTDM_FAIL failure (span was not created) - */ -FT_DECLARE(ftdm_status_t) ftdm_span_add_channel(ftdm_span_t *span, ftdm_socket_t sockfd, ftdm_chan_type_t type, ftdm_channel_t **chan); - -/*! \brief Add the channel to a hunt group */ -FT_DECLARE(ftdm_status_t) ftdm_channel_add_to_group(const char* name, ftdm_channel_t* ftdmchan); - -/*! \brief Remove the channel from a hunt group */ -FT_DECLARE(ftdm_status_t) ftdm_channel_remove_from_group(ftdm_group_t* group, ftdm_channel_t* ftdmchan); - -/*! - * \brief Retrieves an event from the span - * - * \note - * This function is non-reentrant and not thread-safe. - * The event returned may be modified if the function is called again - * from a different thread or even the same. It is recommended to - * handle events from the same span in a single thread. - * - * \param ftdmchan The channel to retrieve the event from - * \param event Pointer to store the pointer to the event - * - * \retval FTDM_SUCCESS success (at least one event available) - * \retval FTDM_FAIL failure - */ -FT_DECLARE(ftdm_status_t) ftdm_channel_read_event(ftdm_channel_t *ftdmchan, ftdm_event_t **event); - -/*! \brief Find a hunt group by id */ -FT_DECLARE(ftdm_status_t) ftdm_group_find(uint32_t id, ftdm_group_t **group); - -/*! \brief Find a hunt group by name */ -FT_DECLARE(ftdm_status_t) ftdm_group_find_by_name(const char *name, ftdm_group_t **group); - -/*! \brief Create a group with the given name */ -FT_DECLARE(ftdm_status_t) ftdm_group_create(ftdm_group_t **group, const char *name); - -/*! \brief Get the number of channels in use on a span */ -FT_DECLARE(ftdm_status_t) ftdm_span_channel_use_count(ftdm_span_t *span, uint32_t *count); - -/*! \brief Get the number of channels in use on a group */ -FT_DECLARE(ftdm_status_t) ftdm_group_channel_use_count(ftdm_group_t *group, uint32_t *count); - -/*! \brief Get the id of a group */ -FT_DECLARE(uint32_t) ftdm_group_get_id(const ftdm_group_t *group); - -/*! - * \brief Open a channel specifying the span id and chan id (required before placing a call on the channel) - * - * \warning Try using ftdm_call_place instead if you plan to place a call after opening the channel - * - * \note You must call ftdm_channel_close() or ftdm_channel_call_hangup() to release the channel afterwards - * Only use ftdm_channel_close if there is no call (incoming or outgoing) in the channel - * - * \param span_id The span id the channel belongs to - * \param chan_id Logical channel id of the channel you want to open - * \param ftdmchan Pointer to store the channel once is open - * - * \retval FTDM_SUCCESS success (the channel was found and is available) - * \retval FTDM_FAIL failure (channel was not found or not available) - */ -FT_DECLARE(ftdm_status_t) ftdm_channel_open(uint32_t span_id, uint32_t chan_id, ftdm_channel_t **ftdmchan); - -/*! - * \brief Open a channel specifying the span id and physical chan id (required before placing a call on the channel) - * - * \warning Try using ftdm_call_place instead if you plan to place a call after opening the channel - * - * \note You must call ftdm_channel_close() or ftdm_channel_call_hangup() to release the channel afterwards - * Only use ftdm_channel_close if there is no call (incoming or outgoing) in the channel - * - * \param span_id The span id the channel belongs to - * \param chan_id Physical channel id of the channel you want to open - * \param ftdmchan Pointer to store the channel once is open - * - * \retval FTDM_SUCCESS success (the channel was found and is available) - * \retval FTDM_FAIL failure (channel was not found or not available) - */ -FT_DECLARE(ftdm_status_t) ftdm_channel_open_ph(uint32_t span_id, uint32_t chan_id, ftdm_channel_t **ftdmchan); - -/*! - * \brief Hunts and opens a channel specifying the span id only - * - * \warning Try using ftdm_call_place instead if you plan to place a call after opening the channel - * - * \note You must call ftdm_channel_close() or ftdm_channel_call_hangup() to release the channel afterwards - * Only use ftdm_channel_close if there is no call (incoming or outgoing) in the channel - * - * \param span_id The span id to hunt for a channel - * \param direction The hunting direction - * \param caller_data The calling party information - * \param ftdmchan The channel pointer to store the available channel - * - * \retval FTDM_SUCCESS success (a suitable channel was found available) - * \retval FTDM_FAIL failure (no suitable channel was found available) - */ -FT_DECLARE(ftdm_status_t) ftdm_channel_open_by_span(uint32_t span_id, ftdm_hunt_direction_t direction, ftdm_caller_data_t *caller_data, ftdm_channel_t **ftdmchan); - -/*! - * \brief Hunts and opens a channel specifying group id - * - * \warning Try using ftdm_call_place instead if you plan to place a call after opening the channel - * - * \note You must call ftdm_channel_close() or ftdm_channel_call_hangup() to release the channel afterwards - * Only use ftdm_channel_close if there is no call (incoming or outgoing) in the channel - * - * \param group_id The group id to hunt for a channel - * \param direction The hunting direction - * \param caller_data The calling party information - * \param ftdmchan The channel pointer to store the available channel - * - * \retval FTDM_SUCCESS success (a suitable channel was found available) - * \retval FTDM_FAIL failure (no suitable channel was found available) - */ -FT_DECLARE(ftdm_status_t) ftdm_channel_open_by_group(uint32_t group_id, ftdm_hunt_direction_t direction, ftdm_caller_data_t *caller_data, ftdm_channel_t **ftdmchan); - -/*! - * \brief Close a previously open channel - * - * \warning FreeTDM is more and more a signaling API rather than just a plane IO API, unless you are using - * FreeTDM as a pure IO API without its signaling modules, you should not use this function - * - * \note If you placed a call in this channel use ftdm_channel_call_hangup(), you MUST NOT call this function, - * the signaling stack will close the channel when the call is done. - * - * \param ftdmchan pointer to the channel to close - * - * \retval FTDM_SUCCESS success (a suitable channel was found available) - * \retval FTDM_FAIL failure (no suitable channel was found available) - */ -FT_DECLARE(ftdm_status_t) ftdm_channel_close(ftdm_channel_t **ftdmchan); - -/*! - * \brief Execute a command in a channel (same semantics as the ioctl() unix system call) - * - * \param ftdmchan The channel to execute the command - * \param command The command to execute - * \param arg The argument for the command - * - * \retval FTDM_SUCCESS success (a suitable channel was found available) - * \retval FTDM_FAIL failure (no suitable channel was found available) - */ -FT_DECLARE(ftdm_status_t) ftdm_channel_command(ftdm_channel_t *ftdmchan, ftdm_command_t command, void *arg); - -/*! - * \brief Wait for I/O events in a channel - * - * \param ftdmchan The channel to wait I/O for - * \param flags The wait I/O flags - * \param timeout The timeout in milliseconds - * - * \retval FTDM_SUCCESS success (a suitable channel was found available) - * \retval FTDM_FAIL failure (no suitable channel was found available) - */ -FT_DECLARE(ftdm_status_t) ftdm_channel_wait(ftdm_channel_t *ftdmchan, ftdm_wait_flag_t *flags, int32_t timeout); - -/*! - * \brief Read data from a channel - * - * \param ftdmchan The channel to read data from - * \param data The pointer to the buffer to store the read data - * \param datalen The size in bytes of the provided buffer - * - * \retval FTDM_SUCCESS success (a suitable channel was found available) - * \retval FTDM_FAIL failure (no suitable channel was found available) - */ -FT_DECLARE(ftdm_status_t) ftdm_channel_read(ftdm_channel_t *ftdmchan, void *data, ftdm_size_t *datalen); - -/*! - * \brief Write data to a channel - * - * \note The difference between data and datasize is subtle but important. - * - * datalen is a pointer to the size of the actual data that you want to write. This pointer - * will be updated with the number of bytes actually written. - * - * datasize on the other hand is the size of the entire buffer provided in data, whether - * all of that buffer is in use or not is a different matter. The difference becomes - * important only if you are using FreeTDM doing transcoding, for example, providing - * a ulaw frame of 160 bytes but where the I/O device accepts input in signed linear, - * the data to write will be 320 bytes, therefore datasize is expected to be at least - * 320 where datalen would be just 160. - * - * \param ftdmchan The channel to write data to - * \param data The pointer to the buffer to write - * \param datasize The maximum number of bytes in data that can be used (in case transcoding is necessary) - * \param datalen The size of the actual data - * - * \retval FTDM_SUCCESS success (a suitable channel was found available) - * \retval FTDM_FAIL failure (no suitable channel was found available) - */ -FT_DECLARE(ftdm_status_t) ftdm_channel_write(ftdm_channel_t *ftdmchan, void *data, ftdm_size_t datasize, ftdm_size_t *datalen); - -/*! \brief Get a custom variable from the sigmsg - * \note The variable pointer returned is only valid while the before the event is processed and it'll be destroyed once the event is processed. */ -FT_DECLARE(const char *) ftdm_sigmsg_get_var(ftdm_sigmsg_t *sigmsg, const char *var_name); - -/*! \brief Get an iterator to iterate over the sigmsg variables - * \param sigmsg The message structure containing the variables - * \param iter Optional iterator. You can reuse an old iterator (not previously freed) to avoid the extra allocation of a new iterator. - * \note The iterator pointer returned is only valid while the channel is open and it'll be destroyed when the channel is closed. - * This iterator is completely non-thread safe, if you are adding variables or removing variables while iterating - * results are unpredictable - */ -FT_DECLARE(ftdm_iterator_t *) ftdm_sigmsg_get_var_iterator(const ftdm_sigmsg_t *sigmsg, ftdm_iterator_t *iter); - -/*! \brief Get raw data from sigmsg - * \param sigmsg The message structure containing the variables - * \param data data will point to available data pointer if available - * \param datalen datalen will be set to length of data available - * \retval FTDM_SUCCESS data is available - * \retval FTDM_FAIL no data available - * \note data is only valid within the duration of the callback, to receive a data pointer that does not get - * \note destroyed when callback returns, see ftdm_sigmsg_get_raw_data_detached - */ -FT_DECLARE(ftdm_status_t) ftdm_sigmsg_get_raw_data(ftdm_sigmsg_t *sigmsg, void **data, ftdm_size_t *datalen); - -/*! \brief Get raw data from event - * \param sigmsg The message structure containing the variables - * \param data data will point to available data pointer if available - * \param datalen datalen will be set to length of data available - * \retval FTDM_SUCCESS data is available - * \retval FTDM_FAIL no data available - * \note Once this function returns, User owns data, and is responsible to free data using ftdm_safe_free(); - */ -FT_DECLARE(ftdm_status_t) ftdm_sigmsg_get_raw_data_detached(ftdm_sigmsg_t *sigmsg, void **data, ftdm_size_t *datalen); - -/*! \brief Add a custom variable to the user message - * \note This variables may be used by signaling modules to override signaling parameters - * \todo Document which signaling variables are available - * */ -FT_DECLARE(ftdm_status_t) ftdm_usrmsg_add_var(ftdm_usrmsg_t *usrmsg, const char *var_name, const char *value); - -/*! \brief Attach raw data to usrmsg - * \param usrmsg The message structure containing the variables - * \param data pointer to data - * \param datalen datalen length of data - * \retval FTDM_SUCCESS success, data was successfully saved - * \retval FTDM_FAIL failed, event already had data attached to it. - * \note data must have been allocated using ftdm_calloc, FreeTDM will free data once the usrmsg is processed. - */ -FT_DECLARE(ftdm_status_t) ftdm_usrmsg_set_raw_data(ftdm_usrmsg_t *usrmsg, void *data, ftdm_size_t datalen); - -/*! \brief Get iterator current value (depends on the iterator type) - * \note Channel iterators return a pointer to ftdm_channel_t - * Span iterators return a pointer to ftdm_span_t - * Variable iterators return a pointer to the variable name (not the variable value) - */ -FT_DECLARE(void *) ftdm_iterator_current(ftdm_iterator_t *iter); - -/*! \brief Get variable name and value for the current iterator position */ -FT_DECLARE(ftdm_status_t) ftdm_get_current_var(ftdm_iterator_t *iter, const char **var_name, const char **var_val); - -/*! \brief Advance iterator */ -FT_DECLARE(ftdm_iterator_t *) ftdm_iterator_next(ftdm_iterator_t *iter); - -/*! \brief Free iterator - * \note You must free an iterator after using it unless you plan to reuse it - */ -FT_DECLARE(ftdm_status_t) ftdm_iterator_free(ftdm_iterator_t *iter); - -/*! \brief Get the span pointer associated to the channel */ -FT_DECLARE(ftdm_span_t *) ftdm_channel_get_span(const ftdm_channel_t *ftdmchan); - -/*! \brief Get the span pointer associated to the channel */ -FT_DECLARE(uint32_t) ftdm_channel_get_span_id(const ftdm_channel_t *ftdmchan); - -/*! \brief Get the physical span id associated to the channel */ -FT_DECLARE(uint32_t) ftdm_channel_get_ph_span_id(const ftdm_channel_t *ftdmchan); - -/*! \brief Get the span name associated to the channel */ -FT_DECLARE(const char *) ftdm_channel_get_span_name(const ftdm_channel_t *ftdmchan); - -/*! \brief Get the id associated to the channel */ -FT_DECLARE(uint32_t) ftdm_channel_get_id(const ftdm_channel_t *ftdmchan); - -/*! \brief Get the name associated to the channel */ -FT_DECLARE(const char *) ftdm_channel_get_name(const ftdm_channel_t *ftdmchan); - -/*! \brief Get the number associated to the channel */ -FT_DECLARE(const char *) ftdm_channel_get_number(const ftdm_channel_t *ftdmchan); - -/*! \brief Get the number physical id associated to the channel */ -FT_DECLARE(uint32_t) ftdm_channel_get_ph_id(const ftdm_channel_t *ftdmchan); - -/*! - * \brief Configure span with a signaling type - * - * \deprecated use ftdm_configure_span_signaling instead - * - * \note This function does the same as ftdm_configure_span_signaling - * - * \param span The span to configure - * \param type The signaling type ("boost", "isdn" and others, this depends on the available signaling modules) - * \param sig_cb The callback that the signaling stack will use to notify about events - * \param ... variable argument list with "var", value sequence, the variable and values are signaling type dependant - * the last argument must be FTDM_TAG_END - * - * \retval FTDM_SUCCESS success - * \retval FTDM_FAIL failure - */ -FT_DECLARE(ftdm_status_t) ftdm_configure_span(ftdm_span_t *span, const char *type, fio_signal_cb_t sig_cb, ...); -#define FTDM_TAG_END NULL - - -/*! - * \brief Configure span with a signaling type - * - * \param span The span to configure - * \param type The signaling type ("boost", "isdn" and others, this depends on the available signaling modules) - * \param sig_cb The callback that the signaling stack will use to notify about events - * \param parameters The array if signaling-specific parameters (the last member of the array MUST have its var member set to NULL, ie: .var = NULL) - * - * \retval FTDM_SUCCESS success - * \retval FTDM_FAIL failure - */ -FT_DECLARE(ftdm_status_t) ftdm_configure_span_signaling(ftdm_span_t *span, const char *type, fio_signal_cb_t sig_cb, ftdm_conf_parameter_t *parameters); - -/*! - * \brief Register callback to listen for incoming events - * \note This function should only be used when there is no signalling module - * \param span The span to register to - * \param sig_cb The callback that the signaling stack will use to notify about events - * - * \retval FTDM_SUCCESS success - * \retval FTDM_FAIL failure - */ -FT_DECLARE(ftdm_status_t) ftdm_span_register_signal_cb(ftdm_span_t *span, fio_signal_cb_t sig_cb); - -/*! - * \brief Start the span signaling (must call ftdm_configure_span_signaling first) - * - * \note Even before this function returns you may receive signaling events! - * Never block in the signaling callback since it might be called in a thread - * that handles more than 1 call and therefore you would be blocking all the - * calls handled by that thread! - * - * \param span The span to start - * - * \retval FTDM_SUCCESS success - * \retval FTDM_FAIL failure - */ -FT_DECLARE(ftdm_status_t) ftdm_span_start(ftdm_span_t *span); - -/*! - * \brief Stop the span signaling (must call ftdm_span_start first) - * \note certain signalings (boost signaling) does not support granular span start/stop - * so it is recommended to always configure all spans and then starting them all and finally - * stop them all (or call ftdm_global_destroy which takes care of stopping and destroying the spans at once). - * - * \param span The span to stop - * - * \retval FTDM_SUCCESS success - * \retval FTDM_FAIL failure - */ -FT_DECLARE(ftdm_status_t) ftdm_span_stop(ftdm_span_t *span); - -/*! - * \brief Register a custom I/O interface with the FreeTDM core - * - * \param io_interface the Interface to register - * - * \retval FTDM_SUCCESS success - * \retval FTDM_FAIL failure - */ -FT_DECLARE(ftdm_status_t) ftdm_global_add_io_interface(ftdm_io_interface_t *io_interface); - -/** - * Get I/O interface by name - * - * \param iotype Name of interface - * \param autoload Try to load missing plugins - * \retval I/O interface handle on success - * \retval NULL on failure - */ -FT_DECLARE(ftdm_io_interface_t *) ftdm_global_get_io_interface(const char *iotype, ftdm_bool_t autoload); - -/*! \brief Find a span by name */ -FT_DECLARE(ftdm_status_t) ftdm_span_find_by_name(const char *name, ftdm_span_t **span); - -/*! \brief Get the span id */ -FT_DECLARE(uint32_t) ftdm_span_get_id(const ftdm_span_t *span); - -/*! \brief Get the span name */ -FT_DECLARE(const char *) ftdm_span_get_name(const ftdm_span_t *span); - -/*! \brief Get iterator for the span channels - * \param span The span containing the channels - * \param iter Optional iterator. You can reuse an old iterator (not previously freed) to avoid the extra allocation of a new iterator. - */ -FT_DECLARE(ftdm_iterator_t *) ftdm_span_get_chan_iterator(const ftdm_span_t *span, ftdm_iterator_t *iter); - -/*! \brief Get iterator for spans - * \param iter Optional iterator. You can reuse an old iterator (not previously freed) to avoid the extra allocation of a new iterator. - */ -FT_DECLARE(ftdm_iterator_t *) ftdm_get_span_iterator(ftdm_iterator_t *iter); - -/*! - * \brief Execute a text command. The text command output will be returned and must be free'd - * - * \param cmd The command to execute - * - * \retval FTDM_SUCCESS success - * \retval FTDM_FAIL failure - */ -FT_DECLARE(char *) ftdm_api_execute(const char *cmd); - -/*! - * \brief Create a configuration node - * - * \param name The name of the configuration node - * \param node The node pointer to store the new node - * \param parent The parent node if any, or NULL if no parent - * - * \return FTDM_SUCCESS success - * \return FTDM_FAIL failure - */ -FT_DECLARE(ftdm_status_t) ftdm_conf_node_create(const char *name, ftdm_conf_node_t **node, ftdm_conf_node_t *parent); - -/*! - * \brief Adds a new parameter to the specified configuration node - * - * \param node The configuration node to add the param-val pair to - * \param param The parameter name - * \param val The parameter value - * - * \return FTDM_SUCCESS success - * \return FTDM_FAIL failure - */ -FT_DECLARE(ftdm_status_t) ftdm_conf_node_add_param(ftdm_conf_node_t *node, const char *param, const char *val); - -/*! - * \brief Destroy the memory allocated for a configuration node (and all of its descendance) - * - * \param node The node to destroy - * - * \return FTDM_SUCCESS success - * \return FTDM_FAIL failure - */ -FT_DECLARE(ftdm_status_t) ftdm_conf_node_destroy(ftdm_conf_node_t *node); - -/*! - * \brief Create and configure channels in the given span - * - * \param span The span container - * \param str The channel range null terminated string. "1-10", "24" etc - * \param chan_config The basic channel configuration for each channel within the range - * \param configured Pointer where the number of channels configured will be stored - * - * \return FTDM_SUCCESS success - * \return FTDM_FAIL failure - */ -FT_DECLARE(ftdm_status_t) ftdm_configure_span_channels(ftdm_span_t *span, const char *str, ftdm_channel_config_t *chan_config, unsigned *configured); - -/*! - * \brief Set the trunk type for a span - * This must be called before configuring any channels within the span - * - * \param span The span - * \param type The trunk type - * - */ -FT_DECLARE(void) ftdm_span_set_trunk_type(ftdm_span_t *span, ftdm_trunk_type_t type); - -/*! - * \brief Get the trunk type for a span - * - * \param span The span - * - * \return The span trunk type - */ -FT_DECLARE(ftdm_trunk_type_t) ftdm_span_get_trunk_type(const ftdm_span_t *span); - -/*! \brief For display debugging purposes you can display this string which describes the trunk type of a span */ -FT_DECLARE(const char *) ftdm_span_get_trunk_type_str(const ftdm_span_t *span); - -/*! - * Set the trunk mode for a span - * \note This must be called before configuring any channels within the span! - * \param[in] span The span - * \param[in] type The trunk mode - */ -FT_DECLARE(void) ftdm_span_set_trunk_mode(ftdm_span_t *span, ftdm_trunk_mode_t mode); - -/*! - * Get the trunk mode for a span - * \param[in] span The span - * \return Span trunk mode - */ -FT_DECLARE(ftdm_trunk_mode_t) ftdm_span_get_trunk_mode(const ftdm_span_t *span); - -/*! - * Get the trunk mode of a span in textual form - * \param[in] span The span - * \return Span mode name as a string - */ -FT_DECLARE(const char *) ftdm_span_get_trunk_mode_str(const ftdm_span_t *span); - -/*! - * \brief Return the channel identified by the provided logical id - * - * \param span The span where the channel belongs - * \param chanid The logical channel id within the span - * - * \return The channel pointer if found, NULL otherwise - */ -FT_DECLARE(ftdm_channel_t *) ftdm_span_get_channel(const ftdm_span_t *span, uint32_t chanid); - -/*! - * \brief Return the channel identified by the provided physical id - * - * \param span The span where the channel belongs - * \param chanid The physical channel id within the span - * - * \return The channel pointer if found, NULL otherwise - */ -FT_DECLARE(ftdm_channel_t *) ftdm_span_get_channel_ph(const ftdm_span_t *span, uint32_t chanid); - -/*! \brief Return the channel count number for the given span */ -FT_DECLARE(uint32_t) ftdm_span_get_chan_count(const ftdm_span_t *span); - -/*! \brief Set the caller data for a channel. Be sure to call this before ftdm_channel_call_place() */ -FT_DECLARE(ftdm_status_t) ftdm_channel_set_caller_data(ftdm_channel_t *ftdmchan, ftdm_caller_data_t *caller_data); - -/*! \brief Get the caller data for a channel, typically you need this when receiving FTDM_SIGEVENT_START */ -FT_DECLARE(ftdm_caller_data_t *) ftdm_channel_get_caller_data(ftdm_channel_t *channel); - -/*! \brief Get current state of a channel */ -FT_DECLARE(int) ftdm_channel_get_state(const ftdm_channel_t *ftdmchan); - -/*! \brief Get last state of a channel */ -FT_DECLARE(int) ftdm_channel_get_last_state(const ftdm_channel_t *ftdmchan); - -/*! \brief For display debugging purposes you can display this string which describes the current channel internal state */ -FT_DECLARE(const char *) ftdm_channel_get_state_str(const ftdm_channel_t *channel); - -/*! \brief For display debugging purposes you can display this string which describes the last channel internal state */ -FT_DECLARE(const char *) ftdm_channel_get_last_state_str(const ftdm_channel_t *channel); - -/*! \brief For display debugging purposes you can display this string which describes the history of the channel - * \param channel The channel to get the history from - * \return History string for the channel. You must free the string with ftdm_free - */ -FT_DECLARE(char *) ftdm_channel_get_history_str(const ftdm_channel_t *channel); - -/*! \brief Enable/disable blocking mode in the channels for this span */ -FT_DECLARE(ftdm_status_t) ftdm_span_set_blocking_mode(const ftdm_span_t *span, ftdm_bool_t enabled); - -/*! \brief Initialize the library */ -FT_DECLARE(ftdm_status_t) ftdm_global_init(void); - -/*! \brief Create spans and channels reading the freetdm.conf file */ -FT_DECLARE(ftdm_status_t) ftdm_global_configuration(void); - -/*! \brief Shutdown the library */ -FT_DECLARE(ftdm_status_t) ftdm_global_destroy(void); - -/*! \brief Set memory handler for the library */ -FT_DECLARE(ftdm_status_t) ftdm_global_set_memory_handler(ftdm_memory_handler_t *handler); - -/*! \brief Set the crash policy for the library */ -FT_DECLARE(void) ftdm_global_set_crash_policy(ftdm_crash_policy_t policy); - -/*! \brief Set the logger handler for the library */ -FT_DECLARE(void) ftdm_global_set_logger(ftdm_logger_t logger); - -/*! \brief Set the default logger level */ -FT_DECLARE(void) ftdm_global_set_default_logger(int level); - -/*! \brief Set the directory to look for modules */ -FT_DECLARE(void) ftdm_global_set_mod_directory(const char *path); - -/*! \brief Set the directory to look for configs */ -FT_DECLARE(void) ftdm_global_set_config_directory(const char *path); - -/*! \brief Check if the FTDM library is initialized and running */ -FT_DECLARE(ftdm_bool_t) ftdm_running(void); - -/** - * Generate a stack trace and invoke a callback function for each entry - * \param[in] callback Callback function, that is invoked for each stack symbol - * \param[in] priv (User-)Private data passed to the callback - * \retval - * FTDM_SUCCESS On success - * FTDM_NOTIMPL Backtraces are not available - * FTDM_EINVAL Invalid arguments (callback was NULL) - */ -FT_DECLARE(ftdm_status_t) ftdm_backtrace_walk(void (* callback)(const int tid, const void *addr, const char *symbol, void *priv), void *priv); - -/** - * Convenience function to print a backtrace for a span. - * \note The backtrace is generated with FTDM_LOG_DEBUG log level. - * \param[in] span Span object - * \retval - * FTDM_SUCCESS On success - * FTDM_NOTIMPL Backtraces are not available - * FTDM_EINVAL Invalid arguments (e.g. span was NULL) - */ -FT_DECLARE(ftdm_status_t) ftdm_backtrace_span(ftdm_span_t *span); - -/** - * Convenience function to print a backtrace for a channel. - * \note The backtrace is generated with FTDM_LOG_DEBUG log level. - * \param[in] chan Channel object - * \retval - * FTDM_SUCCESS On success - * FTDM_NOTIMPL Backtraces are not available - * FTDM_EINVAL Invalid arguments (e.g. chan was NULL) - */ -FT_DECLARE(ftdm_status_t) ftdm_backtrace_chan(ftdm_channel_t *chan); - - -FT_DECLARE_DATA extern ftdm_logger_t ftdm_log; - -/*! \brief Basic transcoding function prototype */ -#define FIO_CODEC_ARGS (void *data, ftdm_size_t max, ftdm_size_t *datalen) -#define FIO_CODEC_FUNCTION(name) FT_DECLARE_NONSTD(ftdm_status_t) name FIO_CODEC_ARGS -typedef ftdm_status_t (*fio_codec_t) FIO_CODEC_ARGS ; - -/*! \brief Basic transcoding functions */ -FIO_CODEC_FUNCTION(fio_slin2ulaw); -FIO_CODEC_FUNCTION(fio_ulaw2slin); -FIO_CODEC_FUNCTION(fio_slin2alaw); -FIO_CODEC_FUNCTION(fio_alaw2slin); -FIO_CODEC_FUNCTION(fio_ulaw2alaw); -FIO_CODEC_FUNCTION(fio_alaw2ulaw); - -#define FTDM_PRE __FILE__, __func__, __LINE__ -#define FTDM_LOG_LEVEL_DEBUG 7 -#define FTDM_LOG_LEVEL_INFO 6 -#define FTDM_LOG_LEVEL_NOTICE 5 -#define FTDM_LOG_LEVEL_WARNING 4 -#define FTDM_LOG_LEVEL_ERROR 3 -#define FTDM_LOG_LEVEL_CRIT 2 -#define FTDM_LOG_LEVEL_ALERT 1 -#define FTDM_LOG_LEVEL_EMERG 0 - -/*! \brief Log levels */ -#define FTDM_LOG_DEBUG FTDM_PRE, FTDM_LOG_LEVEL_DEBUG -#define FTDM_LOG_INFO FTDM_PRE, FTDM_LOG_LEVEL_INFO -#define FTDM_LOG_NOTICE FTDM_PRE, FTDM_LOG_LEVEL_NOTICE -#define FTDM_LOG_WARNING FTDM_PRE, FTDM_LOG_LEVEL_WARNING -#define FTDM_LOG_ERROR FTDM_PRE, FTDM_LOG_LEVEL_ERROR -#define FTDM_LOG_CRIT FTDM_PRE, FTDM_LOG_LEVEL_CRIT -#define FTDM_LOG_ALERT FTDM_PRE, FTDM_LOG_LEVEL_ALERT -#define FTDM_LOG_EMERG FTDM_PRE, FTDM_LOG_LEVEL_EMERG - -#ifdef __cplusplus -} /* extern C */ -#endif - -#endif - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/include/ftdm_call_utils.h b/libs/freetdm/src/include/ftdm_call_utils.h deleted file mode 100644 index 975e73e729..0000000000 --- a/libs/freetdm/src/include/ftdm_call_utils.h +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (c) 2010, Sangoma Technologies - * David Yat Sin - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Contributors: - * - * Moises Silva - * Ricardo Barroetaveña - * - */ - -#ifndef __FTDM_CALL_UTILS_H__ -#define __FTDM_CALL_UTILS_H__ - -/*! - * \brief Set the Numbering Plan Identification from a string - * - * \param npi_string string value - * \param target the target to set value to - * - * \retval FTDM_SUCCESS success - * \retval FTDM_FAIL failure - */ -FT_DECLARE(ftdm_status_t) ftdm_set_npi(const char *npi_string, uint8_t *target); - - -/*! - * \brief Set the Type of number from a string - * - * \param ton_string string value - * \param target the target to set value to - * - * \retval FTDM_SUCCESS success - * \retval FTDM_FAIL failure - */ -FT_DECLARE(ftdm_status_t) ftdm_set_ton(const char *ton_string, uint8_t *target); - -/*! - * \brief Set the Bearer Capability from a string - * - * \param bc_string string value - * \param target the target to set value to - * - * \retval FTDM_SUCCESS success - * \retval FTDM_FAIL failure - */ -FT_DECLARE(ftdm_status_t) ftdm_set_bearer_capability(const char *bc_string, uint8_t *target); - -/*! - * \brief Set the Bearer Capability - Layer 1 from a string - * - * \param bc_string string value - * \param target the target to set value to - * - * \retval FTDM_SUCCESS success - * \retval FTDM_FAIL failure - */ -FT_DECLARE(ftdm_status_t) ftdm_set_bearer_layer1(const char *bc_string, uint8_t *target); - -/*! - * \brief Set the Screening Ind from a string - * - * \param screen_string string value - * \param target the target to set value to - * - * \retval FTDM_SUCCESS success - * \retval FTDM_FAIL failure - */ -FT_DECLARE(ftdm_status_t) ftdm_set_screening_ind(const char *string, uint8_t *target); - - -/*! - * \brief Set the Presentation Ind from an enum - * - * \param screen_string string value - * \param target the target to set value to - * - * \retval FTDM_SUCCESS success - * \retval FTDM_FAIL failure - */ -FT_DECLARE(ftdm_status_t) ftdm_set_presentation_ind(const char *string, uint8_t *target); - - -/*! - * \brief Checks whether a string contains only numbers - * - * \param number string value - * - * \retval FTDM_SUCCESS success - * \retval FTDM_FAIL failure - */ -FT_DECLARE(ftdm_status_t) ftdm_is_number(const char *number); - -/*! - * \brief Set the Calling Party Category from an enum - * - * \param cpc_string string value - * \param target the target to set value to - * - * \retval FTDM_SUCCESS success - * \retval FTDM_FAIL failure - */ -FT_DECLARE(ftdm_status_t) ftdm_set_calling_party_category(const char *string, uint8_t *target); - -/*! - * \brief URL encode a buffer - * - * \param url buffer to convert - * \param buf target to save converted string to - * \param len size of buffer - * - * \retval pointer to converted string - */ -FT_DECLARE(char *) ftdm_url_encode(const char *url, char *buf, ftdm_size_t len); - -/*! - * \param s buffer to convert - * \param len size of buffer - * - * \retval pointer to converted string - */ -FT_DECLARE(char *) ftdm_url_decode(char *s, ftdm_size_t *len); - -#endif /* __FTDM_CALL_UTILS_H__ */ - diff --git a/libs/freetdm/src/include/ftdm_declare.h b/libs/freetdm/src/include/ftdm_declare.h deleted file mode 100644 index 410944e7d3..0000000000 --- a/libs/freetdm/src/include/ftdm_declare.h +++ /dev/null @@ -1,299 +0,0 @@ -/* - * Copyright (c) 2010, Sangoma Technologies - * Moises Silva - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __FTDM_DECLARE_H__ -#define __FTDM_DECLARE_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#if !defined(_XOPEN_SOURCE) && !defined(__FreeBSD__) -#define _XOPEN_SOURCE 600 -#endif - -#ifndef HAVE_STRINGS_H -#define HAVE_STRINGS_H 1 -#endif -#ifndef HAVE_SYS_SOCKET_H -#define HAVE_SYS_SOCKET_H 1 -#endif - -#ifndef __WINDOWS__ -#if defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32) || defined(_WIN64) -#define __WINDOWS__ -#endif -#endif - -#ifdef _MSC_VER -#define __FTDM_FUNC__ __FUNCTION__ -#if defined(FT_DECLARE_STATIC) -#define FT_DECLARE(type) type __stdcall -#define FT_DECLARE_NONSTD(type) type __cdecl -#define FT_DECLARE_DATA -#elif defined(FREETDM_EXPORTS) -#define FT_DECLARE(type) __declspec(dllexport) type __stdcall -#define FT_DECLARE_NONSTD(type) __declspec(dllexport) type __cdecl -#define FT_DECLARE_DATA __declspec(dllexport) -#else -#define FT_DECLARE(type) __declspec(dllimport) type __stdcall -#define FT_DECLARE_NONSTD(type) __declspec(dllimport) type __cdecl -#define FT_DECLARE_DATA __declspec(dllimport) -#endif -#define FT_DECLARE_INLINE(type) extern __inline__ type /* why extern? see http://support.microsoft.com/kb/123768 */ -#define EX_DECLARE_DATA __declspec(dllexport) -#else -#define __FTDM_FUNC__ (const char *)__func__ -#if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(HAVE_VISIBILITY) -#define FT_DECLARE(type) __attribute__((visibility("default"))) type -#define FT_DECLARE_NONSTD(type) __attribute__((visibility("default"))) type -#define FT_DECLARE_DATA __attribute__((visibility("default"))) -#else -#define FT_DECLARE(type) type -#define FT_DECLARE_NONSTD(type) type -#define FT_DECLARE_DATA -#endif -#define FT_DECLARE_INLINE(type) __inline__ type -#define EX_DECLARE_DATA -#endif - -#ifdef _MSC_VER -#ifndef __inline__ -#define __inline__ __inline -#endif -#if (_MSC_VER >= 1400) /* VC8+ */ -#ifndef _CRT_SECURE_NO_DEPRECATE -#define _CRT_SECURE_NO_DEPRECATE -#endif -#ifndef _CRT_NONSTDC_NO_DEPRECATE -#define _CRT_NONSTDC_NO_DEPRECATE -#endif -#endif -#ifndef strcasecmp -#define strcasecmp(s1, s2) _stricmp(s1, s2) -#endif -#ifndef strncasecmp -#define strncasecmp(s1, s2, n) _strnicmp(s1, s2, n) -#endif -#if _MSC_VER < 1900 -#define snprintf _snprintf -#endif -#ifndef S_IRUSR -#define S_IRUSR _S_IREAD -#endif -#ifndef S_IWUSR -#define S_IWUSR _S_IWRITE -#endif -#undef HAVE_STRINGS_H -#undef HAVE_SYS_SOCKET_H -/* disable warning for zero length array in a struct */ -/* this will cause errors on c99 and ansi compliant compilers and will need to be fixed in the wanpipe header files */ -#pragma warning(disable:4706) -#pragma comment(lib, "Winmm") -#endif - -/* - * Compiler-specific format checking attributes - * use these on custom functions that use printf/scanf-style - * format strings (e.g. ftdm_log()) - */ -#if defined(__GNUC__) -/** - * Enable compiler-specific printf()-style format and argument checks on a function - * @param fmtp Position of printf()-style format string parameter - * @param argp Position of variable argument list ("...") parameter - * @code - * void log(const int level, const char *fmt, ...) __ftdm_check_printf(2, 3); - * @endcode - */ -#define __ftdm_check_printf(fmtp, argp) __attribute__((format (printf, fmtp, argp))) -/** - * Enable compiler-specific scanf()-style format and argument checks on a function - * @param fmtp Position of scanf()-style format string parameter - * @param argp Position of variable argument list ("...") parameter - * @code - * void parse(struct foo *ctx, const char *fmt, ...) __ftdm_check_scanf(2, 3); - * @endcode - */ -#define __ftdm_check_scanf(fmtp, argp) __attribute__((format (scanf, fmtp, argp))) -#else -#define __ftdm_check_printf(fmtp, argp) -#define __ftdm_check_scanf(fmtp, argp) -#endif - - -#define FTDM_STR2ENUM_P(_FUNC1, _FUNC2, _TYPE) FT_DECLARE(_TYPE) _FUNC1 (const char *name); FT_DECLARE(const char *) _FUNC2 (_TYPE type); -#define FTDM_STR2ENUM(_FUNC1, _FUNC2, _TYPE, _STRINGS, _MAX) \ - FT_DECLARE(_TYPE) _FUNC1 (const char *name) \ - { \ - int i; \ - _TYPE t = _MAX ; \ - \ - for (i = 0; i < _MAX ; i++) { \ - if (!strcasecmp(name, _STRINGS[i])) { \ - t = (_TYPE) i; \ - break; \ - } \ - } \ - \ - return t; \ - } \ - FT_DECLARE(const char *) _FUNC2 (_TYPE type) \ - { \ - if (type > _MAX) { \ - type = _MAX; \ - } \ - return _STRINGS[(int)type]; \ - } \ - -#ifdef __WINDOWS__ -#include -#include -#define FTDM_INVALID_SOCKET INVALID_HANDLE_VALUE -typedef HANDLE ftdm_socket_t; -typedef unsigned __int64 uint64_t; -typedef unsigned __int32 uint32_t; -typedef unsigned __int16 uint16_t; -typedef unsigned __int8 uint8_t; -typedef __int64 int64_t; -typedef __int32 int32_t; -typedef __int16 int16_t; -typedef __int8 int8_t; -#define FTDM_O_BINARY O_BINARY -#define FTDM_SIZE_FMT "Id" -#define FTDM_INT64_FMT "lld" -#define FTDM_UINT64_FMT "llu" -#define FTDM_XINT64_FMT "llx" -#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS) -#define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64 -#else -#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL -#endif /* _MSC_VER */ -#else /* __WINDOWS__ */ -#define FTDM_O_BINARY 0 -#define FTDM_SIZE_FMT "zd" -#if (defined(__SIZEOF_LONG__) && (__SIZEOF_LONG__ == 8)) || defined(__LP64__) || defined(__LLP64__) -#define FTDM_INT64_FMT "ld" -#define FTDM_UINT64_FMT "lu" -#define FTDM_XINT64_FMT "lx" -#else -#define FTDM_INT64_FMT "lld" -#define FTDM_UINT64_FMT "llu" -#define FTDM_XINT64_FMT "llx" -#endif -#define FTDM_INVALID_SOCKET -1 -typedef int ftdm_socket_t; -#include -#include -#include -#endif - -/*! \brief FreeTDM APIs possible return codes */ -typedef enum { - FTDM_SUCCESS, /*!< Success */ - FTDM_FAIL, /*!< Failure, generic error return code when no more specific return code can be used */ - - FTDM_MEMERR, /*!< Allocation failure */ - FTDM_ENOMEM = FTDM_MEMERR, - - FTDM_TIMEOUT, /*!< Operation timed out (ie: polling on a device)*/ - FTDM_ETIMEDOUT = FTDM_TIMEOUT, - - FTDM_NOTIMPL, /*!< Operation not implemented */ - FTDM_ENOSYS = FTDM_NOTIMPL, /*!< The function is not implemented */ - - FTDM_BREAK, /*!< Request the caller to perform a break (context-dependant, ie: stop getting DNIS/ANI) */ - - /*!< Any new return codes should try to mimc unix style error codes, no need to reinvent */ - FTDM_EINVAL, /*!< Invalid argument */ - FTDM_ECANCELED, /*!< Operation cancelled */ - FTDM_EBUSY, /*!< Device busy */ -} ftdm_status_t; - -/*! \brief FreeTDM bool type. */ -typedef enum { - FTDM_FALSE, - FTDM_TRUE -} ftdm_bool_t; - -/*! \brief I/O waiting flags */ -typedef enum { - FTDM_NO_FLAGS = 0, - FTDM_READ = (1 << 0), - FTDM_WRITE = (1 << 1), - FTDM_EVENTS = (1 << 2) -} ftdm_wait_flag_t; - -/*! - * \brief FreeTDM channel. - * This is the basic data structure used to place calls and I/O operations - */ -typedef struct ftdm_channel ftdm_channel_t; - -/*! - * \brief FreeTDM span. - * Channel and signaling configuration container. - * This is a logical span structure, a span may ( or may note ) contain channels - * of other physical spans, depending on configuration (freetdm.conf) or if you - * are not using configuration depends on how you call ftdm_span_add_channel - */ -typedef struct ftdm_span ftdm_span_t; - -typedef struct ftdm_event ftdm_event_t; -typedef struct ftdm_conf_node ftdm_conf_node_t; -typedef struct ftdm_group ftdm_group_t; -typedef size_t ftdm_size_t; -typedef struct ftdm_sigmsg ftdm_sigmsg_t; -typedef struct ftdm_usrmsg ftdm_usrmsg_t; -typedef struct ftdm_io_interface ftdm_io_interface_t; -typedef struct ftdm_stream_handle ftdm_stream_handle_t; -typedef struct ftdm_queue ftdm_queue_t; -typedef struct ftdm_memory_handler ftdm_memory_handler_t; - -#ifdef __cplusplus -} /* extern C */ -#endif - -#endif - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/include/ftdm_dso.h b/libs/freetdm/src/include/ftdm_dso.h deleted file mode 100755 index b2d3c21999..0000000000 --- a/libs/freetdm/src/include/ftdm_dso.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Cross Platform dso/dll load abstraction - * Copyright(C) 2008 Michael Jerris - * - * You may opt to use, copy, modify, merge, publish, distribute and/or sell - * copies of the Software, and permit persons to whom the Software is - * furnished to do so. - * - * This work is provided under this license on an "as is" basis, without warranty of any kind, - * either expressed or implied, including, without limitation, warranties that the covered code - * is free of defects, merchantable, fit for a particular purpose or non-infringing. The entire - * risk as to the quality and performance of the covered code is with you. Should any covered - * code prove defective in any respect, you (not the initial developer or any other contributor) - * assume the cost of any necessary servicing, repair or correction. This disclaimer of warranty - * constitutes an essential part of this license. No use of any covered code is authorized hereunder - * except under this disclaimer. - * - */ - -#include "freetdm.h" - -#ifndef _FTDM_DSO_H -#define _FTDM_DSO_H - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void (*ftdm_func_ptr_t) (void); -typedef void * ftdm_dso_lib_t; - -FT_DECLARE(ftdm_status_t) ftdm_dso_destroy(ftdm_dso_lib_t *lib); -FT_DECLARE(ftdm_dso_lib_t) ftdm_dso_open(const char *path, char **err); -FT_DECLARE(void *) ftdm_dso_func_sym(ftdm_dso_lib_t lib, const char *sym, char **err); -FT_DECLARE(char *) ftdm_build_dso_path(const char *name, char *path, ftdm_size_t len); - - -#ifdef __cplusplus -} -#endif - -#endif - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ - diff --git a/libs/freetdm/src/include/ftdm_os.h b/libs/freetdm/src/include/ftdm_os.h deleted file mode 100644 index 913debcd52..0000000000 --- a/libs/freetdm/src/include/ftdm_os.h +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright (c) 2010, Sangoma Technologies - * Moises Silva - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __FTDM_OS_H__ -#define __FTDM_OS_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#if defined(__linux__) && !defined(__USE_BSD) -#define __USE_BSD -#endif - -#include "ftdm_declare.h" -#include "ftdm_threadmutex.h" -#include - -#ifndef __WINDOWS__ -#include -#endif - -/*! \brief time data type */ -typedef uint64_t ftdm_time_t; -/*! format string for ftdm_time_t */ -#define FTDM_TIME_FMT FTDM_UINT64_FMT - -/*! \brief sleep x amount of milliseconds */ -#ifdef __WINDOWS__ -#define ftdm_sleep(x) Sleep(x) -#else -#define ftdm_sleep(x) usleep(x * 1000) -#endif - -/*! \brief strncpy replacement */ -#define ftdm_copy_string(x,y,z) strncpy(x, y, z - 1) - -/*! \brief strncpy into a fixed-length buffer */ -#define ftdm_set_string(x,y) strncpy(x, y, sizeof(x)-1) - -/*! \brief check for null or zero length string buffer */ -#define ftdm_strlen_zero(s) (!s || *s == '\0') - -/*! \brief check for zero length string buffer */ -#define ftdm_strlen_zero_buf(s) (*s == '\0') - -/*! \brief array len helper */ -#define ftdm_array_len(array) sizeof(array)/sizeof(array[0]) - -/*! \brief Get smaller value */ -#define ftdm_min(x,y) ((x) < (y) ? (x) : (y)) - -/*! \brief Get larger value */ -#define ftdm_max(x,y) ((x) > (y) ? (x) : (y)) - -/*! \brief Get value that is in range [vmin,vmax] */ -#define ftdm_clamp(val,vmin,vmax) ftdm_max(vmin,ftdm_min(val,vmax)) - -/*!< \brief Safer version of ftdm_clamp(), that swaps vmin/vmax parameters if vmin > vmax */ -#define ftdm_clamp_safe(val,vmin,vmax) \ - ftdm_clamp(val, ftdm_min(vmin,vmax), ftdm_max(vmin,vmax)) - -/*! - * \brief Get offset of member in structure - * \param[in] type Type of struct - * \param[in] member Name of struct member - * \code - * struct a { - * int foo; - * int bar; - * }; - * - * int offset_a_bar = ftdm_offset_of(struct a, bar); // 4 byte offset - * \endcode - */ -#define ftdm_offset_of(type,member) (uintptr_t)&(((type *)0)->member) - -/*! - * \brief Get pointer to enclosing structrure from pointer to embedded member - * \param[in] ptr Pointer to embedded member - * \param[in] type Type of parent/container structure - * \param[in] member Name of embedded member in parent/container struct - * \code - * struct engine { - * int nr_cyl; - * }; - * - * struct car { - * char model[10]; - * struct engine eng; // struct engine embedded in car(!) - * }; - * - * int somefunc(struct engine *e) { - * struct car *c = ftdm_container_of(e, struct car, eng); - * - * ... do something with car ... - * } - * \endcode - */ -#define ftdm_container_of(ptr,type,member) (type *)((uintptr_t)(ptr) - ftdm_offset_of(type, member)) - -/*! - * \brief Silence "unused parameter" compiler warnings - * \note Tested with VS 2010, GCC 4.8, clang 3.1 and suncc - * \code - * int example(char *a) { - * ftdm_unused_arg(a); - * return 0; - * } - * \endcode - */ -#define ftdm_unused_arg(x) (void)(x) - - -/*! \brief The memory handler. - Do not use directly this variable, use the memory macros and ftdm_global_set_memory_handler to override */ -FT_DECLARE_DATA extern ftdm_memory_handler_t g_ftdm_mem_handler; - -/*! - \brief Allocate uninitialized memory - \param chunksize the chunk size -*/ -#define ftdm_malloc(chunksize) g_ftdm_mem_handler.malloc(g_ftdm_mem_handler.pool, chunksize) - -/*! - \brief Reallocates memory - \param buff the buffer - \param chunksize the chunk size -*/ -#define ftdm_realloc(buff, chunksize) g_ftdm_mem_handler.realloc(g_ftdm_mem_handler.pool, buff, chunksize) - -/*! - \brief Allocate initialized memory - \param chunksize the chunk size -*/ -#define ftdm_calloc(elements, chunksize) g_ftdm_mem_handler.calloc(g_ftdm_mem_handler.pool, elements, chunksize) - -/*! - \brief Free chunk of memory - \param chunksize the chunk size -*/ -#define ftdm_free(chunk) g_ftdm_mem_handler.free(g_ftdm_mem_handler.pool, chunk) - -/*! - \brief Free a pointer and set it to NULL unless it already is NULL - \param it the pointer -*/ -#define ftdm_safe_free(it) if (it) { ftdm_free(it); it = NULL; } - -/*! \brief Duplicate string */ -FT_DECLARE(char *) ftdm_strdup(const char *str); - -/*! \brief Duplicate string with limit */ -FT_DECLARE(char *) ftdm_strndup(const char *str, ftdm_size_t inlen); - -/*! \brief Get the current time in milliseconds */ -FT_DECLARE(ftdm_time_t) ftdm_current_time_in_ms(void); - -#ifdef __cplusplus -} /* extern C */ -#endif - -#endif - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/include/ftdm_threadmutex.h b/libs/freetdm/src/include/ftdm_threadmutex.h deleted file mode 100644 index 45eb87d441..0000000000 --- a/libs/freetdm/src/include/ftdm_threadmutex.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Cross Platform Thread/Mutex abstraction - * Copyright(C) 2007 Michael Jerris - * - * You may opt to use, copy, modify, merge, publish, distribute and/or sell - * copies of the Software, and permit persons to whom the Software is - * furnished to do so. - * - * This work is provided under this license on an "as is" basis, without warranty of any kind, - * either expressed or implied, including, without limitation, warranties that the covered code - * is free of defects, merchantable, fit for a particular purpose or non-infringing. The entire - * risk as to the quality and performance of the covered code is with you. Should any covered - * code prove defective in any respect, you (not the initial developer or any other contributor) - * assume the cost of any necessary servicing, repair or correction. This disclaimer of warranty - * constitutes an essential part of this license. No use of any covered code is authorized hereunder - * except under this disclaimer. - * - * Contributors: - * - * Moises Silva - * - */ - - -#ifndef _FTDM_THREADMUTEX_H -#define _FTDM_THREADMUTEX_H - -#include "freetdm.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct ftdm_mutex ftdm_mutex_t; -typedef struct ftdm_thread ftdm_thread_t; -typedef struct ftdm_interrupt ftdm_interrupt_t; -typedef void *(*ftdm_thread_function_t) (ftdm_thread_t *, void *); - -FT_DECLARE(ftdm_status_t) ftdm_thread_create_detached(ftdm_thread_function_t func, void *data); -FT_DECLARE(ftdm_status_t) ftdm_thread_create_detached_ex(ftdm_thread_function_t func, void *data, ftdm_size_t stack_size); -FT_DECLARE(void) ftdm_thread_override_default_stacksize(ftdm_size_t size); - -FT_DECLARE(ftdm_status_t) ftdm_mutex_create(ftdm_mutex_t **mutex); -FT_DECLARE(ftdm_status_t) ftdm_mutex_destroy(ftdm_mutex_t **mutex); - -#define ftdm_mutex_lock(_x) _ftdm_mutex_lock(__FILE__, __LINE__, __FTDM_FUNC__, _x) -FT_DECLARE(ftdm_status_t) _ftdm_mutex_lock(const char *file, int line, const char *func, ftdm_mutex_t *mutex); - -#define ftdm_mutex_trylock(_x) _ftdm_mutex_trylock(__FILE__, __LINE__, __FTDM_FUNC__, _x) -FT_DECLARE(ftdm_status_t) _ftdm_mutex_trylock(const char *file, int line, const char *func, ftdm_mutex_t *mutex); - -#define ftdm_mutex_unlock(_x) _ftdm_mutex_unlock(__FILE__, __LINE__, __FTDM_FUNC__, _x) -FT_DECLARE(ftdm_status_t) _ftdm_mutex_unlock(const char *file, int line, const char *func, ftdm_mutex_t *mutex); - -FT_DECLARE(ftdm_status_t) ftdm_interrupt_create(ftdm_interrupt_t **cond, ftdm_socket_t device, ftdm_wait_flag_t device_flags); -FT_DECLARE(ftdm_status_t) ftdm_interrupt_destroy(ftdm_interrupt_t **cond); -FT_DECLARE(ftdm_status_t) ftdm_interrupt_signal(ftdm_interrupt_t *cond); -FT_DECLARE(ftdm_status_t) ftdm_interrupt_wait(ftdm_interrupt_t *cond, int ms); -FT_DECLARE(ftdm_status_t) ftdm_interrupt_multiple_wait(ftdm_interrupt_t *interrupts[], ftdm_size_t size, int ms); -FT_DECLARE(ftdm_wait_flag_t) ftdm_interrupt_device_ready(ftdm_interrupt_t *interrupt); - -#ifdef __cplusplus -} -#endif - -#endif - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ - diff --git a/libs/freetdm/src/include/private/fsk.h b/libs/freetdm/src/include/private/fsk.h deleted file mode 100644 index 66da140df9..0000000000 --- a/libs/freetdm/src/include/private/fsk.h +++ /dev/null @@ -1,121 +0,0 @@ -/* - * bell202.h - * - * Copyright (c) 2005 Robert Krten. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This module contains the manifest constants and declarations for - * the Bell-202 1200 baud FSK modem. - * - * 2005 03 20 R. Krten created -*/ - -#ifndef __FSK_H__ -#define __FSK_H__ -#include "uart.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - int freq_space; /* Frequency of the 0 bit */ - int freq_mark; /* Frequency of the 1 bit */ - int baud_rate; /* baud rate for the modem */ -} fsk_modem_definition_t; - -/* Must be kept in sync with fsk_modem_definitions array in fsk.c */ -/* V.23 definitions: http://www.itu.int/rec/recommendation.asp?type=folders&lang=e&parent=T-REC-V.23 */ -typedef enum { - FSK_V23_FORWARD_MODE1 = 0, /* Maximum 600 bps for long haul */ - FSK_V23_FORWARD_MODE2, /* Standard 1200 bps V.23 */ - FSK_V23_BACKWARD, /* 75 bps return path for V.23 */ - FSK_BELL202 /* Bell 202 half-duplex 1200 bps */ -} fsk_modem_types_t; - -typedef enum { - FSK_STATE_CHANSEIZE = 0, - FSK_STATE_CARRIERSIG, - FSK_STATE_DATA -} fsk_state_t; - -typedef struct dsp_fsk_attr_s -{ - int sample_rate; /* sample rate in HZ */ - bithandler_func_t bithandler; /* bit handler */ - void *bithandler_arg; /* arbitrary ID passed to bithandler as first argument */ - bytehandler_func_t bytehandler; /* byte handler */ - void *bytehandler_arg; /* arbitrary ID passed to bytehandler as first argument */ -} dsp_fsk_attr_t; - -typedef struct -{ - fsk_state_t state; - dsp_fsk_attr_t attr; /* attributes structure */ - double *correlates[4]; /* one for each of sin/cos for mark/space */ - int corrsize; /* correlate size (also number of samples in ring buffer) */ - double *buffer; /* sample ring buffer */ - int ringstart; /* ring buffer start offset */ - double cellpos; /* bit cell position */ - double celladj; /* bit cell adjustment for each sample */ - int previous_bit; /* previous bit (for detecting a transition to sync-up cell position) */ - int current_bit; /* current bit */ - int last_bit; - int downsampling_count; /* number of samples to skip */ - int current_downsample; /* current skip count */ - int conscutive_state_bits; /* number of bits in a row that matches the pattern for the current state */ -} dsp_fsk_handle_t; - -/* - * Function prototypes - * - * General calling order is: - * a) create the attributes structure (dsp_fsk_attr_init) - * b) initialize fields in the attributes structure (dsp_fsk_attr_set_*) - * c) create a Bell-202 handle (dsp_fsk_create) - * d) feed samples through the handler (dsp_fsk_sample) -*/ - -void dsp_fsk_attr_init(dsp_fsk_attr_t *attributes); - -bithandler_func_t dsp_fsk_attr_get_bithandler(dsp_fsk_attr_t *attributes, void **bithandler_arg); -void dsp_fsk_attr_set_bithandler(dsp_fsk_attr_t *attributes, bithandler_func_t bithandler, void *bithandler_arg); -bytehandler_func_t dsp_fsk_attr_get_bytehandler(dsp_fsk_attr_t *attributes, void **bytehandler_arg); -void dsp_fsk_attr_set_bytehandler(dsp_fsk_attr_t *attributes, bytehandler_func_t bytehandler, void *bytehandler_arg); -int dsp_fsk_attr_get_samplerate(dsp_fsk_attr_t *attributes); -int dsp_fsk_attr_set_samplerate(dsp_fsk_attr_t *attributes, int samplerate); - -dsp_fsk_handle_t * dsp_fsk_create(dsp_fsk_attr_t *attributes); -void dsp_fsk_destroy(dsp_fsk_handle_t **handle); - -void dsp_fsk_sample(dsp_fsk_handle_t *handle, double normalized_sample); - -extern fsk_modem_definition_t fsk_modem_definitions[]; - -#ifdef __cplusplus -} /* extern C */ -#endif - -#endif - diff --git a/libs/freetdm/src/include/private/ftdm_buffer.h b/libs/freetdm/src/include/private/ftdm_buffer.h deleted file mode 100644 index fd5628c905..0000000000 --- a/libs/freetdm/src/include/private/ftdm_buffer.h +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (c) 2007-2014, Anthony Minessale II - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef FTDM_BUFFER_H -#define FTDM_BUFFER_H - -#include "freetdm.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ftdm_buffer Buffer Routines - * @ingroup buffer - * The purpose of this module is to make a plain buffering interface that can be used for read/write buffers - * throughout the application. - * @{ - */ -struct ftdm_buffer; -typedef struct ftdm_buffer ftdm_buffer_t; - -/*! \brief Allocate a new dynamic ftdm_buffer - * \param buffer returned pointer to the new buffer - * \param blocksize length to realloc by as data is added - * \param start_len ammount of memory to reserve initially - * \param max_len length the buffer is allowed to grow to - * \return status - */ -FT_DECLARE(ftdm_status_t) ftdm_buffer_create(ftdm_buffer_t **buffer, ftdm_size_t blocksize, ftdm_size_t start_len, ftdm_size_t max_len); - -/*! \brief Get the length of a ftdm_buffer_t - * \param buffer any buffer of type ftdm_buffer_t - * \return int size of the buffer. - */ -FT_DECLARE(ftdm_size_t) ftdm_buffer_len(ftdm_buffer_t *buffer); - -/*! \brief Get the freespace of a ftdm_buffer_t - * \param buffer any buffer of type ftdm_buffer_t - * \return int freespace in the buffer. - */ -FT_DECLARE(ftdm_size_t) ftdm_buffer_freespace(ftdm_buffer_t *buffer); - -/*! \brief Get the in use amount of a ftdm_buffer_t - * \param buffer any buffer of type ftdm_buffer_t - * \return int ammount of buffer curently in use - */ -FT_DECLARE(ftdm_size_t) ftdm_buffer_inuse(ftdm_buffer_t *buffer); - -/*! \brief Read data from a ftdm_buffer_t up to the ammount of datalen if it is available. Remove read data from buffer. - * \param buffer any buffer of type ftdm_buffer_t - * \param data pointer to the read data to be returned - * \param datalen amount of data to be returned - * \return int ammount of data actually read - */ -FT_DECLARE(ftdm_size_t) ftdm_buffer_read(ftdm_buffer_t *buffer, void *data, ftdm_size_t datalen); - -/*! \brief Read data endlessly from a ftdm_buffer_t - * \param buffer any buffer of type ftdm_buffer_t - * \param data pointer to the read data to be returned - * \param datalen amount of data to be returned - * \return int ammount of data actually read - * \note Once you have read all the data from the buffer it will loop around. - */ -FT_DECLARE(ftdm_size_t) ftdm_buffer_read_loop(ftdm_buffer_t *buffer, void *data, ftdm_size_t datalen); - -/*! \brief Assign a number of loops to read - * \param buffer any buffer of type ftdm_buffer_t - * \param loops the number of loops (-1 for infinite) - */ -FT_DECLARE(void) ftdm_buffer_set_loops(ftdm_buffer_t *buffer, int32_t loops); - -/*! \brief Write data into a ftdm_buffer_t up to the length of datalen - * \param buffer any buffer of type ftdm_buffer_t - * \param data pointer to the data to be written - * \param datalen amount of data to be written - * \return int amount of buffer used after the write, or 0 if no space available - */ -FT_DECLARE(ftdm_size_t) ftdm_buffer_write(ftdm_buffer_t *buffer, const void *data, ftdm_size_t datalen); - -/*! \brief Remove data from the buffer - * \param buffer any buffer of type ftdm_buffer_t - * \param datalen amount of data to be removed - * \return int size of buffer, or 0 if unable to toss that much data - */ -FT_DECLARE(ftdm_size_t) ftdm_buffer_toss(ftdm_buffer_t *buffer, ftdm_size_t datalen); - -/*! \brief Remove all data from the buffer - * \param buffer any buffer of type ftdm_buffer_t - */ -FT_DECLARE(void) ftdm_buffer_zero(ftdm_buffer_t *buffer); - -/*! \brief Destroy the buffer - * \param buffer buffer to destroy - * \note only neccessary on dynamic buffers (noop on pooled ones) - */ -FT_DECLARE(void) ftdm_buffer_destroy(ftdm_buffer_t **buffer); - -/*! \brief Seek to offset from the beginning of the buffer - * \param buffer buffer to seek - * \param datalen offset in bytes - * \return new position - */ -FT_DECLARE(ftdm_size_t) ftdm_buffer_seek(ftdm_buffer_t *buffer, ftdm_size_t datalen); - -/** @} */ - -FT_DECLARE(ftdm_size_t) ftdm_buffer_zwrite(ftdm_buffer_t *buffer, const void *data, ftdm_size_t datalen); - -#ifdef __cplusplus -} -#endif - -#endif -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/include/private/ftdm_config.h b/libs/freetdm/src/include/private/ftdm_config.h deleted file mode 100644 index f55261fcc9..0000000000 --- a/libs/freetdm/src/include/private/ftdm_config.h +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) 2007-2014, Anthony Minessale II - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @defgroup config Config File Parser - * @ingroup config - * This module implements a basic interface and file format parser - * - *
    - *
    - * EXAMPLE 
    - * 
    - * [category1]
    - * var1 => val1
    - * var2 => val2
    - * \# lines that begin with \# are comments
    - * \#var3 => val3
    - * 
    - * @{ - */ - -#ifndef FTDM_CONFIG_H -#define FTDM_CONFIG_H - -#include "freetdm.h" -#define FTDM_URL_SEPARATOR "://" - - -#ifdef WIN32 -#define FTDM_PATH_SEPARATOR "\\" -#ifndef FTDM_CONFIG_DIR -#define FTDM_CONFIG_DIR "c:\\freetdm" -#endif -#define ftdm_is_file_path(file) (*(file +1) == ':' || *file == '/' || strstr(file, SWITCH_URL_SEPARATOR)) -#else -#define FTDM_PATH_SEPARATOR "/" -#ifndef FTDM_CONFIG_DIR -#define FTDM_CONFIG_DIR "/etc/freetdm" -#endif -#define ftdm_is_file_path(file) ((*file == '/') || strstr(file, SWITCH_URL_SEPARATOR)) -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct ftdm_config ftdm_config_t; - -/*! \brief A simple file handle representing an open configuration file **/ -struct ftdm_config { - /*! FILE stream buffer to the opened file */ - FILE *file; - /*! path to the file */ - char path[512]; - /*! current category */ - char category[256]; - /*! current section */ - char section[256]; - /*! buffer of current line being read */ - char buf[1024]; - /*! current line number in file */ - int lineno; - /*! current category number in file */ - int catno; - /*! current section number in file */ - int sectno; - - int lockto; -}; - -/*! - \brief Open a configuration file - \param cfg (ftdm_config_t *) config handle to use - \param file_path path to the file - \return 1 (true) on success 0 (false) on failure -*/ -int ftdm_config_open_file(ftdm_config_t * cfg, const char *file_path); - -/*! - \brief Close a previously opened configuration file - \param cfg (ftdm_config_t *) config handle to use -*/ -void ftdm_config_close_file(ftdm_config_t * cfg); - -/*! - \brief Retrieve next name/value pair from configuration file - \param cfg (ftdm_config_t *) config handle to use - \param var pointer to aim at the new variable name - \param val pointer to aim at the new value -*/ -int ftdm_config_next_pair(ftdm_config_t * cfg, char **var, char **val); - -/*! - \brief Retrieve the CAS bits from a configuration string value - \param strvalue pointer to the configuration string value (expected to be in format whatever:xxxx) - \param outbits pointer to aim at the CAS bits -*/ -FT_DECLARE (int) ftdm_config_get_cas_bits(char *strvalue, unsigned char *outbits); - -#ifdef __cplusplus -} -#endif - -/** @} */ -#endif -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/include/private/ftdm_core.h b/libs/freetdm/src/include/private/ftdm_core.h deleted file mode 100644 index 935cd50078..0000000000 --- a/libs/freetdm/src/include/private/ftdm_core.h +++ /dev/null @@ -1,803 +0,0 @@ -/* - * Copyright (c) 2010, Sangoma Technologies - * Moises Silva - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "freetdm.h" - -#ifndef __PRIVATE_FTDM_CORE__ -#define __PRIVATE_FTDM_CORE__ - -#if !defined(_XOPEN_SOURCE) && !defined(__FreeBSD__) -#define _XOPEN_SOURCE 600 -#endif - -#ifndef HAVE_STRINGS_H -#define HAVE_STRINGS_H 1 -#endif -#ifndef HAVE_SYS_SOCKET_H -#define HAVE_SYS_SOCKET_H 1 -#endif - -#ifdef _MSC_VER -#ifndef __inline__ -#define __inline__ __inline -#endif -#if (_MSC_VER >= 1400) /* VC8+ */ -#ifndef _CRT_SECURE_NO_DEPRECATE -#define _CRT_SECURE_NO_DEPRECATE -#endif -#ifndef _CRT_NONSTDC_NO_DEPRECATE -#define _CRT_NONSTDC_NO_DEPRECATE -#endif -#endif -#ifndef strcasecmp -#define strcasecmp(s1, s2) _stricmp(s1, s2) -#endif -#ifndef strncasecmp -#define strncasecmp(s1, s2, n) _strnicmp(s1, s2, n) -#endif -#ifndef snprintf -#define snprintf _snprintf -#endif -#ifndef S_IRUSR -#define S_IRUSR _S_IREAD -#endif -#ifndef S_IWUSR -#define S_IWUSR _S_IWRITE -#endif -#undef HAVE_STRINGS_H -#undef HAVE_SYS_SOCKET_H -/* disable warning for zero length array in a struct */ -/* this will cause errors on c99 and ansi compliant compilers and will need to be fixed in the wanpipe header files */ -#pragma warning(disable:4706) -#pragma comment(lib, "Winmm") -#endif - -#define FTDM_THREAD_STACKSIZE 240 * 1024 -#define FTDM_ENUM_NAMES(_NAME, _STRINGS) static const char * _NAME [] = { _STRINGS , NULL }; - -#define ftdm_true(expr) \ - (expr && ( !strcasecmp(expr, "yes") || \ - !strcasecmp(expr, "on") || \ - !strcasecmp(expr, "true") || \ - !strcasecmp(expr, "enabled") || \ - !strcasecmp(expr, "active") || \ - atoi(expr))) ? FTDM_TRUE : FTDM_FALSE - -#ifdef WIN32_LEAN_AND_MEAN -#include -#include -#endif - -#include -#ifndef __WINDOWS__ -#include -#endif - -#include -#include -#include -#ifdef HAVE_STRINGS_H -#include -#endif -#include - -#include "ftdm_types.h" -#include "hashtable.h" -#include "ftdm_config.h" -#include "g711.h" -#include "libteletone.h" -#include "ftdm_buffer.h" -#include "ftdm_threadmutex.h" -#include "ftdm_sched.h" -#include "ftdm_call_utils.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define SPAN_PENDING_CHANS_QUEUE_SIZE 1000 -#define SPAN_PENDING_SIGNALS_QUEUE_SIZE 1000 - -#define GOTO_STATUS(label,st) status = st; goto label ; - -#define ftdm_copy_string(x,y,z) strncpy(x, y, z - 1) -#define ftdm_set_string(x,y) strncpy(x, y, sizeof(x)-1) -#define ftdm_strlen_zero(s) (!s || *s == '\0') -#define ftdm_strlen_zero_buf(s) (*s == '\0') - - -#define ftdm_channel_test_feature(obj, flag) ((obj)->features & flag) -#define ftdm_channel_set_feature(obj, flag) (obj)->features = (ftdm_channel_feature_t)((obj)->features | flag) -#define ftdm_channel_clear_feature(obj, flag) (obj)->features = (ftdm_channel_feature_t)((obj)->features & ( ~(flag) )) -#define ftdm_channel_set_member_locked(obj, _m, _v) ftdm_mutex_lock(obj->mutex); obj->_m = _v; ftdm_mutex_unlock(obj->mutex) - -/*! - \brief Test for the existance of a flag on an arbitary object - \command obj the object to test - \command flag the or'd list of flags to test - \return true value if the object has the flags defined -*/ -#define ftdm_test_flag(obj, flag) ((obj)->flags & flag) -/*!< Physical (IO) module specific flags */ -#define ftdm_test_pflag(obj, flag) ((obj)->pflags & flag) -/*!< signaling module specific flags */ -#define ftdm_test_sflag(obj, flag) ((obj)->sflags & flag) - -#define ftdm_set_alarm_flag(obj, flag) (obj)->alarm_flags |= (flag) -#define ftdm_clear_alarm_flag(obj, flag) (obj)->alarm_flags &= ~(flag) -#define ftdm_test_alarm_flag(obj, flag) ((obj)->alarm_flags & flag) - -#define ftdm_set_io_flag(obj, flag) (obj)->io_flags |= (flag) -#define ftdm_clear_io_flag(obj, flag) (obj)->io_flags &= ~(flag) -#define ftdm_test_io_flag(obj, flag) ((obj)->io_flags & flag) - -/*! - \brief Set a flag on an arbitrary object - \command obj the object to set the flags on - \command flag the or'd list of flags to set -*/ -#define ftdm_set_flag(obj, flag) (obj)->flags |= (flag) -#define ftdm_set_flag_locked(obj, flag) assert(obj->mutex != NULL); \ - ftdm_mutex_lock(obj->mutex); \ - (obj)->flags |= (flag); \ - ftdm_mutex_unlock(obj->mutex); - -#define ftdm_set_pflag(obj, flag) (obj)->pflags |= (flag) -#define ftdm_set_pflag_locked(obj, flag) assert(obj->mutex != NULL); \ - ftdm_mutex_lock(obj->mutex); \ - (obj)->pflags |= (flag); \ - ftdm_mutex_unlock(obj->mutex); - -#define ftdm_set_sflag(obj, flag) (obj)->sflags |= (flag) -#define ftdm_set_sflag_locked(obj, flag) assert(obj->mutex != NULL); \ - ftdm_mutex_lock(obj->mutex); \ - (obj)->sflags |= (flag); \ - ftdm_mutex_unlock(obj->mutex); - -/*! - \brief Clear a flag on an arbitrary object while locked - \command obj the object to test - \command flag the or'd list of flags to clear -*/ -#define ftdm_clear_flag(obj, flag) (obj)->flags &= ~(flag) - -#define ftdm_clear_flag_locked(obj, flag) assert(obj->mutex != NULL); ftdm_mutex_lock(obj->mutex); (obj)->flags &= ~(flag); ftdm_mutex_unlock(obj->mutex); - -#define ftdm_clear_pflag(obj, flag) (obj)->pflags &= ~(flag) - -#define ftdm_clear_pflag_locked(obj, flag) assert(obj->mutex != NULL); ftdm_mutex_lock(obj->mutex); (obj)->pflags &= ~(flag); ftdm_mutex_unlock(obj->mutex); - -#define ftdm_clear_sflag(obj, flag) (obj)->sflags &= ~(flag) - -#define ftdm_clear_sflag_locked(obj, flag) assert(obj->mutex != NULL); ftdm_mutex_lock(obj->mutex); (obj)->sflags &= ~(flag); ftdm_mutex_unlock(obj->mutex); - -#ifdef _MSC_VER -/* The while(0) below throws a conditional expression is constant warning */ -#pragma warning(disable:4127) -#endif - -/* this macro assumes obj is locked! */ -#define ftdm_wait_for_flag_cleared(obj, flag, time) \ - do { \ - int __safety = time; \ - while(__safety-- && ftdm_test_flag(obj, flag)) { \ - ftdm_mutex_unlock(obj->mutex); \ - ftdm_sleep(10); \ - ftdm_mutex_lock(obj->mutex); \ - } \ - if(!__safety) { \ - ftdm_log(FTDM_LOG_CRIT, "flag %"FTDM_UINT64_FMT" was never cleared\n", (uint64_t)flag); \ - } \ - } while(0); - -#define ftdm_is_dtmf(key) ((key > 47 && key < 58) || (key > 64 && key < 69) || (key > 96 && key < 101) || key == 35 || key == 42 || key == 87 || key == 119) - -#ifdef __linux__ -#define ftdm_print_stack(level) \ - do { \ - void *__stacktrace[100] = { 0 }; \ - char **__symbols = NULL; \ - int __size = 0; \ - int __i = 0; \ - __size = backtrace(__stacktrace, ftdm_array_len(__stacktrace)); \ - __symbols = backtrace_symbols(__stacktrace, __size); \ - if (__symbols) { \ - for (__i = 0; __i < __size; __i++) { \ - ftdm_log(__level, "%s\n", __symbols[i]); \ - } \ - free(__symbols); \ - } \ - } while (0); -#else -#define ftdm_print_stack(level) ftdm_log(level, "FTDM_PRINT_STACK is not implemented in this operating system!\n"); -#endif - - -#define FTDM_SPAN_IS_BRI(x) ((x)->trunk_type == FTDM_TRUNK_BRI || (x)->trunk_type == FTDM_TRUNK_BRI_PTMP) -/*! - \brief Copy flags from one arbitrary object to another - \command dest the object to copy the flags to - \command src the object to copy the flags from - \command flags the flags to copy -*/ -#define ftdm_copy_flags(dest, src, flags) (dest)->flags &= ~(flags); (dest)->flags |= ((src)->flags & (flags)) - -struct ftdm_stream_handle { - ftdm_stream_handle_write_function_t write_function; - ftdm_stream_handle_raw_write_function_t raw_write_function; - void *data; - void *end; - ftdm_size_t data_size; - ftdm_size_t data_len; - ftdm_size_t alloc_len; - ftdm_size_t alloc_chunk; -}; - -FT_DECLARE_NONSTD(ftdm_status_t) ftdm_console_stream_raw_write(ftdm_stream_handle_t *handle, uint8_t *data, ftdm_size_t datalen); -FT_DECLARE_NONSTD(ftdm_status_t) ftdm_console_stream_write(ftdm_stream_handle_t *handle, const char *fmt, ...); - -#define FTDM_CMD_CHUNK_LEN 1024 -#define FTDM_STANDARD_STREAM(s) memset(&s, 0, sizeof(s)); s.data = ftdm_malloc(FTDM_CMD_CHUNK_LEN); \ - assert(s.data); \ - memset(s.data, 0, FTDM_CMD_CHUNK_LEN); \ - s.end = s.data; \ - s.data_size = FTDM_CMD_CHUNK_LEN; \ - s.write_function = ftdm_console_stream_write; \ - s.raw_write_function = ftdm_console_stream_raw_write; \ - s.alloc_len = FTDM_CMD_CHUNK_LEN; \ - s.alloc_chunk = FTDM_CMD_CHUNK_LEN - -/*! brief create a new queue */ -#define ftdm_queue_create(queue, capacity) g_ftdm_queue_handler.create(queue, capacity) - -/*! Enqueue an object */ -#define ftdm_queue_enqueue(queue, obj) g_ftdm_queue_handler.enqueue(queue, obj) - -/*! dequeue an object from the queue */ -#define ftdm_queue_dequeue(queue) g_ftdm_queue_handler.dequeue(queue) - -/*! wait ms milliseconds for a queue to have available objects, -1 to wait forever */ -#define ftdm_queue_wait(queue, ms) g_ftdm_queue_handler.wait(queue, ms) - -/*! get the internal interrupt object (to wait for elements to be added from the outside bypassing ftdm_queue_wait) */ -#define ftdm_queue_get_interrupt(queue, ms) g_ftdm_queue_handler.get_interrupt(queue, ms) - -/*! destroy the queue */ -#define ftdm_queue_destroy(queue) g_ftdm_queue_handler.destroy(queue) - -FT_DECLARE_DATA extern ftdm_queue_handler_t g_ftdm_queue_handler; - -#define FTDM_TOKEN_STRLEN 128 -#define FTDM_MAX_TOKENS 10 - -static __inline__ char *ftdm_clean_string(char *s) -{ - char *p; - - for (p = s; p && *p; p++) { - uint8_t x = (uint8_t) *p; - if (x < 32 || x > 127) { - *p = ' '; - } - } - - return s; -} - -struct ftdm_bitstream { - uint8_t *data; - uint32_t datalen; - uint32_t byte_index; - uint8_t bit_index; - int8_t endian; - uint8_t top; - uint8_t bot; - uint8_t ss; - uint8_t ssv; -}; - -struct ftdm_fsk_data_state { - dsp_fsk_handle_t *fsk1200_handle; - uint8_t init; - uint8_t *buf; - size_t bufsize; - ftdm_size_t blen; - ftdm_size_t bpos; - ftdm_size_t dlen; - ftdm_size_t ppos; - int checksum; -}; - -struct ftdm_fsk_modulator { - teletone_dds_state_t dds; - ftdm_bitstream_t bs; - uint32_t carrier_bits_start; - uint32_t carrier_bits_stop; - uint32_t chan_sieze_bits; - uint32_t bit_factor; - uint32_t bit_accum; - uint32_t sample_counter; - int32_t samples_per_bit; - int32_t est_bytes; - fsk_modem_types_t modem_type; - ftdm_fsk_data_state_t *fsk_data; - ftdm_fsk_write_sample_t write_sample_callback; - void *user_data; - int16_t sample_buffer[64]; -}; - - -typedef enum { - FTDM_TYPE_NONE, - FTDM_TYPE_SPAN = 0xFF, - FTDM_TYPE_CHANNEL -} ftdm_data_type_t; - -/* number of bytes for the IO dump circular buffer (5 seconds worth of audio by default) */ -#define FTDM_IO_DUMP_DEFAULT_BUFF_SIZE 8 * 5000 -typedef struct { - char *buffer; - ftdm_size_t size; - int windex; - int wrapped; -} ftdm_io_dump_t; - -/* number of interval cycles before timeout and close the debug dtmf file (5 seconds if interval is 20) */ -#define DTMF_DEBUG_TIMEOUT 250 -typedef struct { - uint8_t enabled; - uint8_t requested; - FILE *file; - int32_t closetimeout; - ftdm_mutex_t *mutex; -} ftdm_dtmf_debug_t; - -typedef struct { - uint32_t duration_ms; - ftdm_time_t start_time; - /* If set to 1, we will send DTMF event the the tone starts, instead of waiting for end */ - uint8_t trigger_on_start; -} ftdm_dtmf_detect_t; - -/* 2^8 table size, one for each byte (sample) value */ -#define FTDM_GAINS_TABLE_SIZE 256 -struct ftdm_channel { - ftdm_data_type_t data_type; - uint32_t span_id; - uint32_t chan_id; - uint32_t physical_span_id; - uint32_t physical_chan_id; - uint32_t rate; - uint32_t extra_id; - ftdm_chan_type_t type; - ftdm_socket_t sockfd; - uint64_t flags; - uint32_t pflags; - uint32_t sflags; - uint8_t io_flags; - ftdm_alarm_flag_t alarm_flags; - ftdm_channel_feature_t features; - ftdm_codec_t effective_codec; - ftdm_codec_t native_codec; - uint32_t effective_interval; - uint32_t native_interval; - uint32_t packet_len; - ftdm_channel_state_t state; - ftdm_state_status_t state_status; - ftdm_channel_state_t last_state; - ftdm_channel_state_t init_state; - ftdm_channel_indication_t indication; - ftdm_state_history_entry_t history[10]; - uint8_t hindex; - ftdm_mutex_t *mutex; - teletone_dtmf_detect_state_t dtmf_detect; - uint32_t buffer_delay; - ftdm_event_t event_header; - char last_error[256]; - fio_event_cb_t event_callback; - uint32_t skip_read_frames; - ftdm_buffer_t *dtmf_buffer; - ftdm_buffer_t *gen_dtmf_buffer; - ftdm_buffer_t *pre_buffer; - ftdm_buffer_t *digit_buffer; - ftdm_buffer_t *fsk_buffer; - ftdm_mutex_t *pre_buffer_mutex; - uint32_t dtmf_on; - uint32_t dtmf_off; - char *dtmf_hangup_buf; - teletone_generation_session_t tone_session; - ftdm_time_t last_event_time; - ftdm_time_t ring_time; - char tokens[FTDM_MAX_TOKENS+1][FTDM_TOKEN_STRLEN]; - uint8_t needed_tones[FTDM_TONEMAP_INVALID]; - uint8_t detected_tones[FTDM_TONEMAP_INVALID]; - ftdm_tonemap_t last_detected_tone; - uint32_t token_count; - char chan_name[128]; - char chan_number[32]; - ftdm_filehandle_t fds[2]; - ftdm_fsk_data_state_t fsk; - uint8_t fsk_buf[80]; - uint32_t ring_count; - ftdm_polarity_t polarity; - /* Private I/O data. Do not touch unless you are an I/O module */ - void *io_data; - /* Private signaling data. Do not touch unless you are a signaling module */ - void *call_data; - struct ftdm_caller_data caller_data; - struct ftdm_span *span; - struct ftdm_io_interface *fio; - unsigned char rx_cas_bits; - uint32_t pre_buffer_size; - uint8_t rxgain_table[FTDM_GAINS_TABLE_SIZE]; - uint8_t txgain_table[FTDM_GAINS_TABLE_SIZE]; - float rxgain; - float txgain; - int availability_rate; - void *user_private; - ftdm_timer_id_t hangup_timer; - ftdm_channel_iostats_t iostats; - ftdm_dtmf_debug_t dtmfdbg; - ftdm_dtmf_detect_t dtmfdetect; - ftdm_io_dump_t rxdump; - ftdm_io_dump_t txdump; - ftdm_interrupt_t *state_completed_interrupt; /*!< Notify when a state change is completed */ - int32_t txdrops; - int32_t rxdrops; - ftdm_usrmsg_t *usrmsg; - ftdm_time_t last_state_change_time; - ftdm_time_t last_release_time; -}; - -struct ftdm_span { - ftdm_data_type_t data_type; - char *name; - uint32_t span_id; - uint32_t chan_count; - ftdm_span_flag_t flags; - struct ftdm_io_interface *fio; - fio_event_cb_t event_callback; - ftdm_mutex_t *mutex; - ftdm_trunk_type_t trunk_type; - ftdm_trunk_mode_t trunk_mode; - ftdm_analog_start_type_t start_type; - ftdm_signal_type_t signal_type; - uint32_t last_used_index; - /* Private signaling data. Do not touch unless you are a signaling module */ - void *signal_data; - fio_signal_cb_t signal_cb; - ftdm_event_t event_header; - char last_error[256]; - char tone_map[FTDM_TONEMAP_INVALID+1][FTDM_TONEMAP_LEN]; - teletone_tone_map_t tone_detect_map[FTDM_TONEMAP_INVALID+1]; - teletone_multi_tone_t tone_finder[FTDM_TONEMAP_INVALID+1]; - ftdm_channel_t *channels[FTDM_MAX_CHANNELS_SPAN+1]; - fio_channel_outgoing_call_t outgoing_call; - fio_channel_indicate_t indicate; - fio_channel_set_sig_status_t set_channel_sig_status; - fio_channel_get_sig_status_t get_channel_sig_status; - fio_span_set_sig_status_t set_span_sig_status; - fio_span_get_sig_status_t get_span_sig_status; - fio_channel_request_t channel_request; - ftdm_span_start_t start; - ftdm_span_stop_t stop; - ftdm_span_destroy_t destroy; - ftdm_channel_sig_read_t sig_read; - ftdm_channel_sig_write_t sig_write; - ftdm_channel_sig_dtmf_t sig_queue_dtmf; - ftdm_channel_sig_dtmf_t sig_send_dtmf; - uint32_t sig_release_guard_time_ms; - ftdm_channel_state_processor_t state_processor; /*!< This guy is called whenever state processing is required */ - void *io_data; /*!< Private I/O data per span. Do not touch unless you are an I/O module */ - char *type; - char *dtmf_hangup; - size_t dtmf_hangup_len; - ftdm_state_map_t *state_map; - ftdm_caller_data_t default_caller_data; - ftdm_queue_t *pendingchans; /*!< Channels pending of state processing */ - ftdm_queue_t *pendingsignals; /*!< Signals pending from being delivered to the user */ - struct ftdm_span *next; -}; - -struct ftdm_group { - char *name; - uint32_t group_id; - uint32_t chan_count; - ftdm_channel_t *channels[FTDM_MAX_CHANNELS_GROUP]; - uint32_t last_used_index; - ftdm_mutex_t *mutex; - struct ftdm_group *next; -}; - -FT_DECLARE_DATA extern ftdm_crash_policy_t g_ftdm_crash_policy; - -FT_DECLARE(ftdm_size_t) ftdm_fsk_modulator_generate_bit(ftdm_fsk_modulator_t *fsk_trans, int8_t bit, int16_t *buf, ftdm_size_t buflen); -FT_DECLARE(int32_t) ftdm_fsk_modulator_generate_carrier_bits(ftdm_fsk_modulator_t *fsk_trans, uint32_t bits); -FT_DECLARE(void) ftdm_fsk_modulator_generate_chan_sieze(ftdm_fsk_modulator_t *fsk_trans); -FT_DECLARE(void) ftdm_fsk_modulator_send_data(ftdm_fsk_modulator_t *fsk_trans); -#define ftdm_fsk_modulator_send_all(_it) ftdm_fsk_modulator_generate_chan_sieze(_it); \ - ftdm_fsk_modulator_generate_carrier_bits(_it, _it->carrier_bits_start); \ - ftdm_fsk_modulator_send_data(_it); \ - ftdm_fsk_modulator_generate_carrier_bits(_it, _it->carrier_bits_stop) - -FT_DECLARE(ftdm_status_t) ftdm_fsk_modulator_init(ftdm_fsk_modulator_t *fsk_trans, - fsk_modem_types_t modem_type, - uint32_t sample_rate, - ftdm_fsk_data_state_t *fsk_data, - float db_level, - uint32_t carrier_bits_start, - uint32_t carrier_bits_stop, - uint32_t chan_sieze_bits, - ftdm_fsk_write_sample_t write_sample_callback, - void *user_data); -FT_DECLARE(int8_t) ftdm_bitstream_get_bit(ftdm_bitstream_t *bsp); -FT_DECLARE(void) ftdm_bitstream_init(ftdm_bitstream_t *bsp, uint8_t *data, uint32_t datalen, ftdm_endian_t endian, uint8_t ss); -FT_DECLARE(ftdm_status_t) ftdm_fsk_data_parse(ftdm_fsk_data_state_t *state, ftdm_size_t *type, char **data, ftdm_size_t *len); -FT_DECLARE(ftdm_status_t) ftdm_fsk_demod_feed(ftdm_fsk_data_state_t *state, int16_t *data, size_t samples); -FT_DECLARE(ftdm_status_t) ftdm_fsk_demod_destroy(ftdm_fsk_data_state_t *state); -FT_DECLARE(int) ftdm_fsk_demod_init(ftdm_fsk_data_state_t *state, int rate, uint8_t *buf, size_t bufsize); -FT_DECLARE(ftdm_status_t) ftdm_fsk_data_init(ftdm_fsk_data_state_t *state, uint8_t *data, uint32_t datalen); -FT_DECLARE(ftdm_status_t) ftdm_fsk_data_add_mdmf(ftdm_fsk_data_state_t *state, ftdm_mdmf_type_t type, const uint8_t *data, uint32_t datalen); -FT_DECLARE(ftdm_status_t) ftdm_fsk_data_add_checksum(ftdm_fsk_data_state_t *state); -FT_DECLARE(ftdm_status_t) ftdm_fsk_data_add_sdmf(ftdm_fsk_data_state_t *state, const char *date, char *number); -FT_DECLARE(ftdm_status_t) ftdm_channel_send_fsk_data(ftdm_channel_t *ftdmchan, ftdm_fsk_data_state_t *fsk_data, float db_level); - -FT_DECLARE(ftdm_status_t) ftdm_span_load_tones(ftdm_span_t *span, const char *mapname); - -FT_DECLARE(ftdm_status_t) ftdm_channel_use(ftdm_channel_t *ftdmchan); - -FT_DECLARE(void) ftdm_generate_sln_silence(int16_t *data, uint32_t samples, uint32_t divisor); - -FT_DECLARE(uint32_t) ftdm_separate_string(char *buf, char delim, char **array, int arraylen); -FT_DECLARE(void) print_bits(uint8_t *b, int bl, char *buf, int blen, int e, uint8_t ss); -FT_DECLARE(void) print_hex_bytes(uint8_t *data, ftdm_size_t dlen, char *buf, ftdm_size_t blen); - -FT_DECLARE_NONSTD(int) ftdm_hash_equalkeys(void *k1, void *k2); -FT_DECLARE_NONSTD(uint32_t) ftdm_hash_hashfromstring(void *ky); - -FT_DECLARE(int) ftdm_load_modules(void); - -FT_DECLARE(ftdm_status_t) ftdm_unload_modules(void); - -FT_DECLARE(ftdm_status_t) ftdm_span_send_signal(ftdm_span_t *span, ftdm_sigmsg_t *sigmsg); - -FT_DECLARE(void) ftdm_channel_clear_needed_tones(ftdm_channel_t *ftdmchan); -FT_DECLARE(void) ftdm_channel_rotate_tokens(ftdm_channel_t *ftdmchan); - -FT_DECLARE(int) ftdm_load_module(const char *name); -FT_DECLARE(int) ftdm_load_module_assume(const char *name); -FT_DECLARE(int) ftdm_vasprintf(char **ret, const char *fmt, va_list ap); - -FT_DECLARE(ftdm_status_t) ftdm_span_close_all(void); -FT_DECLARE(ftdm_status_t) ftdm_channel_open_chan(ftdm_channel_t *ftdmchan); -FT_DECLARE(void) ftdm_ack_indication(ftdm_channel_t *ftdmchan, ftdm_channel_indication_t indication, ftdm_status_t status); - - -FT_DECLARE(ftdm_iterator_t *) ftdm_get_iterator(ftdm_iterator_type_t type, ftdm_iterator_t *iter); - -FT_DECLARE(ftdm_status_t) ftdm_channel_process_media(ftdm_channel_t *ftdmchan, void *data, ftdm_size_t *datalen); - -FT_DECLARE(ftdm_status_t) ftdm_raw_read (ftdm_channel_t *ftdmchan, void *data, ftdm_size_t *datalen); -FT_DECLARE(ftdm_status_t) ftdm_raw_write (ftdm_channel_t *ftdmchan, void *data, ftdm_size_t *datalen); - -/*! - * \brief Retrieves an event from the span - * - * \note - * This function is non-reentrant and not thread-safe. - * The event returned may be modified if the function is called again - * from a different thread or even the same. It is recommended to - * handle events from the same span in a single thread. - * WARNING: this function used to be public ( in freetdm.h ) - * but since is really of no use to users better keep it here - * - * \param span The span to retrieve the event from - * \param event Pointer to store the pointer to the event - * - * \retval FTDM_SUCCESS success (at least one event available) - * \retval FTDM_TIMEOUT Timed out waiting for events - * \retval FTDM_FAIL failure - */ -FT_DECLARE(ftdm_status_t) ftdm_span_next_event(ftdm_span_t *span, ftdm_event_t **event); - -/*! - * \brief Enqueue a DTMF string into the channel - * - * \param ftdmchan The channel to enqueue the dtmf string to - * \param dtmf null-terminated DTMF string - * - * \retval FTDM_SUCCESS success - * \retval FTDM_FAIL failure - */ -FT_DECLARE(ftdm_status_t) ftdm_channel_queue_dtmf(ftdm_channel_t *ftdmchan, const char *dtmf); - -/* dequeue pending signals and notify the user via the span signal callback */ -FT_DECLARE(ftdm_status_t) ftdm_span_trigger_signals(const ftdm_span_t *span); - -/*! \brief clear the tone detector state */ -FT_DECLARE(void) ftdm_channel_clear_detected_tones(ftdm_channel_t *ftdmchan); - -/*! \brief adjust echocanceller for beginning of call */ -FT_DECLARE(void) ftdm_set_echocancel_call_begin(ftdm_channel_t *chan); - -/*! \brief adjust echocanceller for end of call */ -FT_DECLARE(void) ftdm_set_echocancel_call_end(ftdm_channel_t *chan); - -/*! \brief save data from user */ -FT_DECLARE(ftdm_status_t) ftdm_channel_save_usrmsg(ftdm_channel_t *ftdmchan, ftdm_usrmsg_t *usrmsg); - -/*! \brief free usrmsg and variables/raw data attached to it */ -FT_DECLARE(ftdm_status_t) ftdm_usrmsg_free(ftdm_usrmsg_t **usrmsg); - -/*! \brief Get a custom variable from the user message - * \note The variable pointer returned is only valid while the before the event is processed and it'll be destroyed once the event is processed. */ -FT_DECLARE(const char *) ftdm_usrmsg_get_var(ftdm_usrmsg_t *usrmsg, const char *var_name); - -/*! \brief Get raw data from user message - * \param usrmsg The message structure containing the variables - * \param data data will point to available data pointer if available - * \param datalen datalen will be set to length of data available - * \retval FTDM_SUCCESS data is available - * \retval FTDM_FAIL no data available - * \note data is only valid within the duration of the callback, to receive a data pointer that does not get - * \note destroyed when callback returns, see ftdm_sigmsg_get_raw_data_detached - */ -FT_DECLARE(ftdm_status_t) ftdm_usrmsg_get_raw_data(ftdm_usrmsg_t *usrmsg, void **data, ftdm_size_t *datalen); - -/*! \brief free sigmsg and variables/raw data attached to it */ -FT_DECLARE(ftdm_status_t) ftdm_sigmsg_free(ftdm_sigmsg_t **sigmsg); - -/*! \brief Add a custom variable to the event - * \note This variables may be used by signaling modules to override signaling parameters - * \todo Document which signaling variables are available - * */ -FT_DECLARE(ftdm_status_t) ftdm_sigmsg_add_var(ftdm_sigmsg_t *sigmsg, const char *var_name, const char *value); - -/*! \brief Remove a custom variable from the event - * \note The variable pointer returned is only valid while the before the event is processed and it'll be destroyed once the event is processed. */ -FT_DECLARE(ftdm_status_t) ftdm_sigmsg_remove_var(ftdm_sigmsg_t *sigmsg, const char *var_name); - -/*! \brief Attach raw data to sigmsg - * \param sigmsg The message structure containing the variables - * \param data pointer to data - * \param datalen datalen length of data - * \retval FTDM_SUCCESS success, data was successfully saved - * \retval FTDM_FAIL failed, event already had data attached to it. - * \note data must have been allocated using ftdm_calloc, FreeTDM will free data once the usrmsg is processed. - */ -FT_DECLARE(ftdm_status_t) ftdm_sigmsg_set_raw_data(ftdm_sigmsg_t *sigmsg, void *data, ftdm_size_t datalen); - -/*! \brief Retrieve a span and channel data structure from a string in the format 'span_id:chan_id'*/ -FT_DECLARE(ftdm_status_t) ftdm_get_channel_from_string(const char *string_id, ftdm_span_t **out_span, ftdm_channel_t **out_channel); - -/*! - \brief Assert condition -*/ -#define ftdm_assert(assertion, msg) \ - if (!(assertion)) { \ - ftdm_log(FTDM_LOG_CRIT, "%s", msg); \ - if (g_ftdm_crash_policy & FTDM_CRASH_ON_ASSERT) { \ - ftdm_abort(); \ - } \ - } - -/*! - \brief Assert condition and return -*/ -#define ftdm_assert_return(assertion, retval, msg) \ - if (!(assertion)) { \ - ftdm_log(FTDM_LOG_CRIT, "%s", msg); \ - if (g_ftdm_crash_policy & FTDM_CRASH_ON_ASSERT) { \ - ftdm_abort(); \ - } else { \ - return retval; \ - } \ - } - -/*! - \brief Socket the given socket - \command it the socket -*/ -#define ftdm_socket_close(it) if (it > -1) { close(it); it = -1;} - -#define ftdm_channel_lock(chan) ftdm_mutex_lock((chan)->mutex) -#define ftdm_channel_unlock(chan) ftdm_mutex_unlock((chan)->mutex) - -#define ftdm_log_throttle(level, ...) \ - time_current_throttle_log = ftdm_current_time_in_ms(); \ - if (time_current_throttle_log - time_last_throttle_log > FTDM_THROTTLE_LOG_INTERVAL) {\ - ftdm_log(level, __VA_ARGS__); \ - time_last_throttle_log = time_current_throttle_log; \ - } - -#define ftdm_log_chan_ex(fchan, file, func, line, level, format, ...) ftdm_log(file, func, line, level, "[s%dc%d][%d:%d] " format, fchan->span_id, fchan->chan_id, fchan->physical_span_id, fchan->physical_chan_id, __VA_ARGS__) - -#define ftdm_log_chan_ex_msg(fchan, file, func, line, level, msg) ftdm_log(file, func, line, level, "[s%dc%d][%d:%d] " msg, fchan->span_id, fchan->chan_id, fchan->physical_span_id, fchan->physical_chan_id) - -#define ftdm_log_chan(fchan, level, format, ...) ftdm_log(level, "[s%dc%d][%d:%d] " format, fchan->span_id, fchan->chan_id, fchan->physical_span_id, fchan->physical_chan_id, __VA_ARGS__) - -#define ftdm_log_chan_msg(fchan, level, msg) ftdm_log(level, "[s%dc%d][%d:%d] " msg, fchan->span_id, fchan->chan_id, fchan->physical_span_id, fchan->physical_chan_id) - -#define ftdm_log_chan_throttle(fchan, level, format, ...) ftdm_log_throttle(level, "[s%dc%d][%d:%d] " format, fchan->span_id, fchan->chan_id, fchan->physical_span_id, fchan->physical_chan_id, __VA_ARGS__) -#define ftdm_log_chan_msg_throttle(fchan, level, format, ...) ftdm_log_throttle(level, "[s%dc%d][%d:%d] " format, fchan->span_id, fchan->chan_id, fchan->physical_span_id, fchan->physical_chan_id, __VA_ARGS__) - -#define ftdm_span_lock(span) ftdm_mutex_lock(span->mutex) -#define ftdm_span_unlock(span) ftdm_mutex_unlock(span->mutex) - -#define ftdm_test_and_set_media(fchan) \ - do { \ - if (!ftdm_test_flag((fchan), FTDM_CHANNEL_MEDIA)) { \ - ftdm_set_flag((fchan), FTDM_CHANNEL_MEDIA); \ - ftdm_set_echocancel_call_begin((fchan)); \ - if ((fchan)->dtmfdbg.requested) { \ - ftdm_channel_command((fchan), FTDM_COMMAND_ENABLE_DEBUG_DTMF, NULL); \ - } \ - } \ - } while (0); - -FT_DECLARE_DATA extern const char *FTDM_LEVEL_NAMES[9]; - -static __inline__ void ftdm_abort(void) -{ -#ifdef __cplusplus - ::abort(); -#else - abort(); -#endif -} - -static __inline__ int16_t ftdm_saturated_add(int16_t sample1, int16_t sample2) -{ - int addres; - - addres = sample1 + sample2; - if (addres > 32767) - addres = 32767; - else if (addres < -32767) - addres = -32767; - return (int16_t)addres; -} - -/* Bitmap helper functions */ -typedef long ftdm_bitmap_t; -#define FTDM_BITMAP_NBITS (sizeof(ftdm_bitmap_t) * 8) -#define ftdm_map_set_bit(map, bit) (map[(bit/FTDM_BITMAP_NBITS)] |= ((ftdm_bitmap_t)1 << (bit % FTDM_BITMAP_NBITS))) -#define ftdm_map_clear_bit(map, bit) (map[(bit/FTDM_BITMAP_NBITS)] &= ~((ftdm_bitmap_t)1 << (bit % FTDM_BITMAP_NBITS))) -#define ftdm_map_test_bit(map, bit) (map[(bit/FTDM_BITMAP_NBITS)] & ((ftdm_bitmap_t)1 << (bit % FTDM_BITMAP_NBITS))) - -#ifdef __cplusplus -} -#endif - -#endif /* endif __PRIVATE_FTDM_CORE__ */ diff --git a/libs/freetdm/src/include/private/ftdm_cpu_monitor.h b/libs/freetdm/src/include/private/ftdm_cpu_monitor.h deleted file mode 100644 index 249a5233c7..0000000000 --- a/libs/freetdm/src/include/private/ftdm_cpu_monitor.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2010, Sangoma Technologies - * Moises Silva - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - * Contributors: - * David Yat Sin - * - */ - -/*! \brief opaque cpu stats structure */ -struct ftdm_cpu_monitor_stats; - -/*! - * \brief create a new cpu monitor - * \return profile timer structure previously created with new_profile_timer, NULL on error - */ -FT_DECLARE(struct ftdm_cpu_monitor_stats*) ftdm_new_cpu_monitor(void); - -/*! - * \brief Deletes cpu_monitor - */ -FT_DECLARE(void) ftdm_delete_cpu_monitor(struct ftdm_cpu_monitor_stats *p); - -/*! - * \brief provides the percentage of idle system time - * \param p cpu_stats structure previously created with ftdm_new_cpu_monitor - * \param pointer to store the percentage of idle time - * \return -1 on error 0 for success - */ -FT_DECLARE(ftdm_status_t) ftdm_cpu_get_system_idle_time (struct ftdm_cpu_monitor_stats *p, double *idle_percentage); - - - - - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/include/private/ftdm_sched.h b/libs/freetdm/src/include/private/ftdm_sched.h deleted file mode 100644 index 020da9fb3b..0000000000 --- a/libs/freetdm/src/include/private/ftdm_sched.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 2010, Sangoma Technologies - * Moises Silva - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __FTDM_SCHED_H__ -#define __FTDM_SCHED_H__ - -#include "freetdm.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define FTDM_MICROSECONDS_PER_SECOND 1000000 - -typedef struct ftdm_sched ftdm_sched_t; -typedef void (*ftdm_sched_callback_t)(void *data); -typedef uint64_t ftdm_timer_id_t; - -/*! \brief Create a new scheduling context */ -FT_DECLARE(ftdm_status_t) ftdm_sched_create(ftdm_sched_t **sched, const char *name); - -/*! \brief Run the schedule to find timers that are expired and run its callbacks */ -FT_DECLARE(ftdm_status_t) ftdm_sched_run(ftdm_sched_t *sched); - -/*! \brief Run the schedule in its own thread. Callbacks will be called in a core thread. You *must* not block there! */ -FT_DECLARE(ftdm_status_t) ftdm_sched_free_run(ftdm_sched_t *sched); - -/*! - * \brief Schedule a new timer - * \param sched The scheduling context (required) - * \param name Timer name, typically unique but is not required to be unique, any null terminated string is fine (required) - * \param callback The callback to call upon timer expiration (required) - * \param data Optional data to pass to the callback - * \param timer Timer id pointer to store the id of the newly created timer. It can be null - * if you do not need to know the id, but you need this if you want to be able - * to cancel the timer with ftdm_sched_cancel_timer - */ -FT_DECLARE(ftdm_status_t) ftdm_sched_timer(ftdm_sched_t *sched, const char *name, - int ms, ftdm_sched_callback_t callback, void *data, ftdm_timer_id_t *timer); - -/*! - * \brief Cancel the timer - * Note that there is a race between cancelling and triggering a timer. - * By the time you call this function the timer may be about to be triggered. - * This is specially true with timers in free run schedule. - * \param sched The scheduling context (required) - * \param timer The timer to cancel (required) - */ -FT_DECLARE(ftdm_status_t) ftdm_sched_cancel_timer(ftdm_sched_t *sched, ftdm_timer_id_t timer); - -/*! \brief Destroy the context and all of the scheduled timers in it */ -FT_DECLARE(ftdm_status_t) ftdm_sched_destroy(ftdm_sched_t **sched); - -/*! - * \brief Calculate the time to the next timer and return it - * \param sched The sched context - * \param timeto The pointer to store the next timer time in milliseconds - */ -FT_DECLARE(ftdm_status_t) ftdm_sched_get_time_to_next_timer(const ftdm_sched_t *sched, int32_t *timeto); - -/*! \brief Global initialization, called just once, this is called by FreeTDM core, other users MUST not call it */ -FT_DECLARE(ftdm_status_t) ftdm_sched_global_init(void); - -/*! \brief Global destroy, called just once, this is called by FreeTDM core, other users MUST not call it */ -FT_DECLARE(ftdm_status_t) ftdm_sched_global_destroy(void); - -/*! \brief Checks if the main scheduling thread is running */ -FT_DECLARE(ftdm_bool_t) ftdm_free_sched_running(void); - -/*! \brief Stop the main scheduling thread (if running) */ -FT_DECLARE(ftdm_bool_t) ftdm_free_sched_stop(void); - -#ifdef __cplusplus -} -#endif - -#endif - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/include/private/ftdm_state.h b/libs/freetdm/src/include/private/ftdm_state.h deleted file mode 100644 index 733a561dcc..0000000000 --- a/libs/freetdm/src/include/private/ftdm_state.h +++ /dev/null @@ -1,247 +0,0 @@ -/* - * Copyright (c) 2010, Sangoma Technologies - * Moises Silva - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __FTDM_STATE_H__ -#define __FTDM_STATE_H__ - -/*! \file - * \brief State handling definitions - * \note Most, if not all of the state handling functions assume you have a lock acquired. Touching the channel - * state is a sensitive matter that requires checks and careful thought and is typically a process that - * is not encapsulated within a single function, therefore the lock must be explicitly acquired by the - * caller (most of the time, signaling modules), process states, set a new state and process it, and - * finally unlock the channel. See docs/locking.txt fore more info - */ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum { - FTDM_CHANNEL_STATE_ANY = -1, - FTDM_CHANNEL_STATE_END = -1, - FTDM_CHANNEL_STATE_DOWN, - FTDM_CHANNEL_STATE_HOLD, - FTDM_CHANNEL_STATE_SUSPENDED, - FTDM_CHANNEL_STATE_DIALTONE, - FTDM_CHANNEL_STATE_COLLECT, - FTDM_CHANNEL_STATE_RING, - FTDM_CHANNEL_STATE_RINGING, - FTDM_CHANNEL_STATE_BUSY, - FTDM_CHANNEL_STATE_ATTN, - FTDM_CHANNEL_STATE_GENRING, - FTDM_CHANNEL_STATE_DIALING, - FTDM_CHANNEL_STATE_GET_CALLERID, - FTDM_CHANNEL_STATE_CALLWAITING, - FTDM_CHANNEL_STATE_RESTART, - FTDM_CHANNEL_STATE_PROCEED, - FTDM_CHANNEL_STATE_PROGRESS, - FTDM_CHANNEL_STATE_PROGRESS_MEDIA, - FTDM_CHANNEL_STATE_UP, - FTDM_CHANNEL_STATE_TRANSFER, - FTDM_CHANNEL_STATE_IDLE, - FTDM_CHANNEL_STATE_TERMINATING, - FTDM_CHANNEL_STATE_CANCEL, - FTDM_CHANNEL_STATE_HANGUP, - FTDM_CHANNEL_STATE_HANGUP_COMPLETE, - FTDM_CHANNEL_STATE_IN_LOOP, - FTDM_CHANNEL_STATE_RESET, - FTDM_CHANNEL_STATE_INVALID -} ftdm_channel_state_t; -/* Purposely not adding ANY (-1) and END (-1) since FTDM_STR2ENUM_P works only on enums starting at zero */ -#define CHANNEL_STATE_STRINGS "DOWN", "HOLD", "SUSPENDED", "DIALTONE", "COLLECT", \ - "RING", "RINGING", "BUSY", "ATTN", "GENRING", "DIALING", "GET_CALLERID", "CALLWAITING", \ - "RESTART", "PROCEED", "PROGRESS", "PROGRESS_MEDIA", "UP", "TRANSFER", "IDLE", "TERMINATING", "CANCEL", \ - "HANGUP", "HANGUP_COMPLETE", "IN_LOOP", "RESET", "INVALID" -FTDM_STR2ENUM_P(ftdm_str2ftdm_channel_state, ftdm_channel_state2str, ftdm_channel_state_t) - -typedef struct { - const char *file; - const char *func; - int line; - ftdm_channel_state_t state; /*!< Current state (processed or not) */ - ftdm_channel_state_t last_state; /*!< Previous state */ - ftdm_time_t time; /*!< Time the state was set */ - ftdm_time_t end_time; /*!< Time the state processing was completed */ -} ftdm_state_history_entry_t; - -typedef ftdm_status_t (*ftdm_channel_state_processor_t)(ftdm_channel_t *fchan); - -/*! - * \brief Process channel states by invoking the channel state processing routine - * it will keep calling the processing routine while the state status - * is FTDM_STATE_STATUS_NEW, it will not do anything otherwise - */ -FT_DECLARE(ftdm_status_t) ftdm_channel_advance_states(ftdm_channel_t *fchan); - -FT_DECLARE(ftdm_status_t) _ftdm_channel_complete_state(const char *file, const char *function, int line, ftdm_channel_t *fchan); -#define ftdm_channel_complete_state(obj) _ftdm_channel_complete_state(__FILE__, __FTDM_FUNC__, __LINE__, obj) -FT_DECLARE(int) ftdm_check_state_all(ftdm_span_t *span, ftdm_channel_state_t state); - -/*! - * \brief Status of the current channel state - * \note A given state goes thru several status (yes, states for the state!) - * The order is always FTDM_STATE_STATUS_NEW -> FTDM_STATE_STATUS_PROCESSED -> FTDM_STATUS_COMPLETED - * However, is possible to go from NEW -> COMPLETED directly when the signaling module explicitly changes - * the state of the channel in the middle of processing the current state by calling the ftdm_set_state() API - * - * FTDM_STATE_STATUS_NEW - - * Someone just set the state of the channel, either the signaling module or the user (implicitly through a call API). - * This is accomplished by calling ftdm_channel_set_state() which changes the 'state' and 'last_state' memebers of - * the ftdm_channel_t structure. - * - * FTDM_STATE_STATUS_PROCESSED - - * The signaling module did something based on the new state. - * - * This is accomplished via ftdm_channel_advance_states() - * - * When ftdm_channel_advance_states(), at the very least, if the channel has its state in FTDM_STATE_STATUS_NEW, it - * will move to FTDM_STATE_STATUS_PROCESSED, depending on what the signaling module does during the processing - * the state may move to FTDM_STATE_STATUS_COMPLETED right after or wait for a signaling specific event to complete it. - * It is also possible that more state transitions occur during the execution of ftdm_channel_advance_states() if one - * state processing/completion leads to another state change, the function will not return until the chain of events - * lead to a state that is not in FTDM_STATE_STATUS_NEW - * - * FTDM_STATE_STATUS_COMPLETED - - * The signaling module completed the processing of the state and there is nothing further to be done for this state. - * - * This is accomplished either explicitly by the signaling module by calling ftdm_channel_complete_state() or by - * the signaling module implicitly by trying to set the state of the channel to a new state via ftdm_set_state() - * - * When working with blocking channels (FTDM_CHANNEL_NONBLOCK flag not set), the user thread is signaled and unblocked - * so it can continue. - * - * When a state moves to this status is also possible for a signal FTDM_SIGEVENT_INDICATION_COMPLETED to be delivered - * by the core if the state change was associated to an indication requested by the user, - */ -typedef enum { - FTDM_STATE_STATUS_NEW, - FTDM_STATE_STATUS_PROCESSED, - FTDM_STATE_STATUS_COMPLETED, - FTDM_STATE_STATUS_INVALID -} ftdm_state_status_t; -#define CHANNEL_STATE_STATUS_STRINGS "NEW", "PROCESSED", "COMPLETED", "INVALID" -FTDM_STR2ENUM_P(ftdm_str2ftdm_state_status, ftdm_state_status2str, ftdm_state_status_t) - -typedef enum { - ZSM_NONE, - ZSM_UNACCEPTABLE, - ZSM_ACCEPTABLE -} ftdm_state_map_type_t; - -typedef enum { - ZSD_INBOUND, - ZSD_OUTBOUND, -} ftdm_state_direction_t; - -#define FTDM_MAP_NODE_SIZE 512 -#define FTDM_MAP_MAX FTDM_CHANNEL_STATE_INVALID+2 - -struct ftdm_state_map_node { - ftdm_state_direction_t direction; - ftdm_state_map_type_t type; - ftdm_channel_state_t check_states[FTDM_MAP_MAX]; - ftdm_channel_state_t states[FTDM_MAP_MAX]; -}; -typedef struct ftdm_state_map_node ftdm_state_map_node_t; - -struct ftdm_state_map { - ftdm_state_map_node_t nodes[FTDM_MAP_NODE_SIZE]; -}; -typedef struct ftdm_state_map ftdm_state_map_t; - -/*!\brief Cancel the state processing for a channel (the channel must be locked when calling this function) - * \note Only the core should use this function - */ -FT_DECLARE(ftdm_status_t) ftdm_channel_cancel_state(const char *file, const char *func, int line, - ftdm_channel_t *ftdmchan); - -/*!\brief Set the state for a channel (the channel must be locked when calling this function) - * \note Signaling modules should use ftdm_set_state macro instead - * \note If this function is called with the wait parameter set to a non-zero value, the recursivity - * of the channel lock must be == 1 because the channel will be unlocked/locked when waiting */ -FT_DECLARE(ftdm_status_t) ftdm_channel_set_state(const char *file, const char *func, int line, - ftdm_channel_t *ftdmchan, ftdm_channel_state_t state, int wait, ftdm_usrmsg_t *usrmsg); - -/*!\brief Set the state of a channel immediately and implicitly complete the previous state if needed - * \note FTDM_SIGEVENT_INDICATION_COMPLETED will be sent if the state change - * is associated to some indication (ie FTDM_CHANNEL_INDICATE_PROCEED) - * \note The channel must be locked when calling this function - * */ -FT_DECLARE(ftdm_status_t) _ftdm_set_state(const char *file, const char *func, int line, - ftdm_channel_t *fchan, ftdm_channel_state_t state); -#define ftdm_set_state(obj, s) _ftdm_set_state(__FILE__, __FTDM_FUNC__, __LINE__, obj, s); \ - -/*!\brief This macro is deprecated, signaling modules should always lock the channel themselves anyways since they must - * process first the user pending state changes then set a new state before releasing the lock - * this macro is here for backwards compatibility, DO NOT USE IT in new code since it is *always* wrong to set - * a state in a signaling module without checking and processing the current state first (and for that you must lock the channel) - */ -#define ftdm_set_state_locked(obj, s) \ - do { \ - ftdm_channel_lock(obj); \ - ftdm_channel_set_state(__FILE__, __FTDM_FUNC__, __LINE__, obj, s, 0, NULL); \ - ftdm_channel_unlock(obj); \ - } while(0); - -#define ftdm_set_state_r(obj, s, r) r = ftdm_channel_set_state(__FILE__, __FTDM_FUNC__, __LINE__, obj, s, 0); - -#define ftdm_set_state_all(span, state) \ - do { \ - uint32_t _j; \ - ftdm_mutex_lock((span)->mutex); \ - for(_j = 1; _j <= (span)->chan_count; _j++) { \ - if (!FTDM_IS_DCHAN(span->channels[_j])) { \ - ftdm_set_state_locked((span->channels[_j]), state); \ - } \ - } \ - ftdm_mutex_unlock((span)->mutex); \ - } while (0); - -#ifdef __cplusplus -} -#endif - -#endif - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/include/private/ftdm_types.h b/libs/freetdm/src/include/private/ftdm_types.h deleted file mode 100755 index a498489af1..0000000000 --- a/libs/freetdm/src/include/private/ftdm_types.h +++ /dev/null @@ -1,390 +0,0 @@ -/* - * Copyright (c) 2007-2014, Anthony Minessale II - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Contributors: - * - * Moises Silva - * - */ - -#ifndef FTDM_TYPES_H -#define FTDM_TYPES_H - -#include "freetdm.h" - -#include "fsk.h" - -#ifdef WIN32 -typedef intptr_t ftdm_ssize_t; -typedef int ftdm_filehandle_t; -#else -#include -#include -#include -typedef ssize_t ftdm_ssize_t; -typedef int ftdm_filehandle_t; -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#define FTDM_COMMAND_OBJ_SIZE *((ftdm_size_t *)obj) -#define FTDM_COMMAND_OBJ_INT *((int *)obj) -#define FTDM_COMMAND_OBJ_CHAR_P (char *)obj -#define FTDM_COMMAND_OBJ_FLOAT *(float *)obj -#define FTDM_FSK_MOD_FACTOR 0x10000 -#define FTDM_DEFAULT_DTMF_ON 250 -#define FTDM_DEFAULT_DTMF_OFF 50 - -typedef enum { - FTDM_ENDIAN_BIG = 1, - FTDM_ENDIAN_LITTLE = -1 -} ftdm_endian_t; - -typedef enum { - FTDM_CID_TYPE_SDMF = 0x04, - FTDM_CID_TYPE_MDMF = 0x80 -} ftdm_cid_type_t; - -typedef enum { - MDMF_DATETIME = 1, - MDMF_PHONE_NUM = 2, - MDMF_DDN = 3, - MDMF_NO_NUM = 4, - MDMF_PHONE_NAME = 7, - MDMF_NO_NAME = 8, - MDMF_ALT_ROUTE = 9, - MDMF_INVALID = 10 -} ftdm_mdmf_type_t; -#define MDMF_STRINGS "X", "DATETIME", "PHONE_NUM", "DDN", "NO_NUM", "X", "X", "PHONE_NAME", "NO_NAME", "ALT_ROUTE", "INVALID" -FTDM_STR2ENUM_P(ftdm_str2ftdm_mdmf_type, ftdm_mdmf_type2str, ftdm_mdmf_type_t) - -#define FTDM_TONEMAP_LEN 128 -typedef enum { - FTDM_TONEMAP_NONE, - FTDM_TONEMAP_DIAL, - FTDM_TONEMAP_RING, - FTDM_TONEMAP_BUSY, - FTDM_TONEMAP_FAIL1, - FTDM_TONEMAP_FAIL2, - FTDM_TONEMAP_FAIL3, - FTDM_TONEMAP_ATTN, - FTDM_TONEMAP_CALLWAITING_CAS, - FTDM_TONEMAP_CALLWAITING_SAS, - FTDM_TONEMAP_CALLWAITING_ACK, - FTDM_TONEMAP_INVALID -} ftdm_tonemap_t; -#define TONEMAP_STRINGS "NONE", "DIAL", "RING", "BUSY", "FAIL1", "FAIL2", "FAIL3", "ATTN", "CALLWAITING-CAS", "CALLWAITING-SAS", "CALLWAITING-ACK", "INVALID" -FTDM_STR2ENUM_P(ftdm_str2ftdm_tonemap, ftdm_tonemap2str, ftdm_tonemap_t) - -typedef enum { - FTDM_ANALOG_START_KEWL, - FTDM_ANALOG_START_LOOP, - FTDM_ANALOG_START_GROUND, - FTDM_ANALOG_START_WINK, - FTDM_ANALOG_START_NA -} ftdm_analog_start_type_t; -#define START_TYPE_STRINGS "KEWL", "LOOP", "GROUND", "WINK", "NA" -FTDM_STR2ENUM_P(ftdm_str2ftdm_analog_start_type, ftdm_analog_start_type2str, ftdm_analog_start_type_t) - -typedef enum { - FTDM_OOB_NOOP, - FTDM_OOB_ONHOOK, - FTDM_OOB_OFFHOOK, - FTDM_OOB_WINK, - FTDM_OOB_FLASH, - FTDM_OOB_RING_START, - FTDM_OOB_RING_STOP, - FTDM_OOB_ALARM_TRAP, - FTDM_OOB_ALARM_CLEAR, - FTDM_OOB_CAS_BITS_CHANGE, - FTDM_OOB_POLARITY_REVERSE, - FTDM_OOB_INVALID -} ftdm_oob_event_t; -#define OOB_STRINGS "NOOP", "ONHOOK", "OFFHOOK", "WINK", "FLASH", "RING_START", "RING_STOP", "ALARM_TRAP", "ALARM_CLEAR", "CAS_BITS_CHANGE", "POLARITY_REVERSE", "INVALID" -FTDM_STR2ENUM_P(ftdm_str2ftdm_oob_event, ftdm_oob_event2str, ftdm_oob_event_t) - -/*! \brief Event types */ -typedef enum { - FTDM_EVENT_NONE, - /* DTMF digit was just detected */ - FTDM_EVENT_DTMF, - /* Out of band event */ - FTDM_EVENT_OOB, - FTDM_EVENT_COUNT -} ftdm_event_type_t; - -/*! \brief Generic event data type */ -struct ftdm_event { - ftdm_event_type_t e_type; - uint32_t enum_id; - ftdm_channel_t *channel; - void *data; -}; - -typedef enum { - FTDM_SIGTYPE_NONE, - FTDM_SIGTYPE_ISDN, - FTDM_SIGTYPE_RBS, - FTDM_SIGTYPE_ANALOG, - FTDM_SIGTYPE_SANGOMABOOST, - FTDM_SIGTYPE_M3UA, - FTDM_SIGTYPE_M2UA, - FTDM_SIGTYPE_R2, - FTDM_SIGTYPE_SS7, - FTDM_SIGTYPE_GSM -} ftdm_signal_type_t; - -typedef enum { - FTDM_SPAN_CONFIGURED = (1 << 0), - FTDM_SPAN_STARTED = (1 << 1), - FTDM_SPAN_STATE_CHANGE = (1 << 2), - FTDM_SPAN_SUSPENDED = (1 << 3), - FTDM_SPAN_IN_THREAD = (1 << 4), - FTDM_SPAN_STOP_THREAD = (1 << 5), - /*! Signaling modules set this flag to use fchan->pendingchans queue instead - * of the FTDM_SPAN_STATE_CHANGE flag to detect when there is channels with - * a state change pending in the span. If you set this member you can't rely - * on FTDM_SPAN_STATE_CHANGE anymore and must use the queue only instead. This - * is the new way of detecting state changes, new modules should always set this - * flag, the old modules still relying on FTDM_SPAN_STATE_CHANGE should be updated */ - FTDM_SPAN_USE_CHAN_QUEUE = (1 << 6), - FTDM_SPAN_SUGGEST_CHAN_ID = (1 << 7), - FTDM_SPAN_USE_AV_RATE = (1 << 8), - FTDM_SPAN_PWR_SAVING = (1 << 9), - /* If you use this flag, you MUST call ftdm_span_trigger_signals to deliver the user signals - * after having called ftdm_send_span_signal(), which with this flag it will just enqueue the signal - * for later delivery */ - FTDM_SPAN_USE_SIGNALS_QUEUE = (1 << 10), - /* If this flag is set, channel will be moved to proceed state when calls goes to routing */ - FTDM_SPAN_USE_PROCEED_STATE = (1 << 11), - /* If this flag is set, the signalling module supports jumping directly to state up, without - going through PROGRESS/PROGRESS_MEDIA */ - FTDM_SPAN_USE_SKIP_STATES = (1 << 12), - /* If this flag is set, then this span cannot be stopped individually, it can only be stopped - on freetdm unload */ - FTDM_SPAN_NON_STOPPABLE = (1 << 13), - /* If this flag is set, then this span supports TRANSFER state */ - FTDM_SPAN_USE_TRANSFER = (1 << 14), - /* This is the last flag, no more flags bigger than this */ - FTDM_SPAN_MAX_FLAG = (1 << 15), -} ftdm_span_flag_t; - -/*! \brief Channel supported features */ -typedef enum { - FTDM_CHANNEL_FEATURE_DTMF_DETECT = (1 << 0), /*!< Channel can detect DTMF (read-only) */ - FTDM_CHANNEL_FEATURE_DTMF_GENERATE = (1 << 1), /*!< Channel can generate DTMF (read-only) */ - FTDM_CHANNEL_FEATURE_CODECS = (1 << 2), /*!< Channel can do transcoding (read-only) */ - FTDM_CHANNEL_FEATURE_INTERVAL = (1 << 3), /*!< Channel support i/o interval configuration (read-only) */ - FTDM_CHANNEL_FEATURE_CALLERID = (1 << 4), /*!< Channel can detect caller id (read-only) */ - FTDM_CHANNEL_FEATURE_PROGRESS = (1 << 5), /*!< Channel can detect inband progress (read-only) */ - FTDM_CHANNEL_FEATURE_CALLWAITING = (1 << 6), /*!< Channel will allow call waiting (ie: FXS devices) (read/write) */ - FTDM_CHANNEL_FEATURE_HWEC = (1<<7), /*!< Channel has a hardware echo canceller */ - FTDM_CHANNEL_FEATURE_HWEC_DISABLED_ON_IDLE = (1<<8), /*!< hardware echo canceller is disabled when there are no calls on this channel */ - FTDM_CHANNEL_FEATURE_IO_STATS = (1<<9), /*!< Channel supports IO statistics (HDLC channels only) */ - FTDM_CHANNEL_FEATURE_MF_GENERATE = (1<<10), /*!< Channel can generate R2 MF tones (read-only) */ -} ftdm_channel_feature_t; - -/*! \brief Channel IO pending flags */ -typedef enum { - FTDM_CHANNEL_IO_EVENT = (1 << 0), - FTDM_CHANNEL_IO_READ = (1 << 1), - FTDM_CHANNEL_IO_WRITE = (1 << 2), -} ftdm_channel_io_flags_t; - -/*!< Channel flags. This used to be an enum but we reached the 32bit limit for enums, is safer this way */ -#define FTDM_CHANNEL_CONFIGURED (1ULL << 0) -#define FTDM_CHANNEL_READY (1ULL << 1) -#define FTDM_CHANNEL_OPEN (1ULL << 2) -#define FTDM_CHANNEL_DTMF_DETECT (1ULL << 3) -#define FTDM_CHANNEL_SUPRESS_DTMF (1ULL << 4) -#define FTDM_CHANNEL_TRANSCODE (1ULL << 5) -#define FTDM_CHANNEL_BUFFER (1ULL << 6) -#define FTDM_CHANNEL_INTHREAD (1ULL << 8) -#define FTDM_CHANNEL_WINK (1ULL << 9) -#define FTDM_CHANNEL_FLASH (1ULL << 10) -#define FTDM_CHANNEL_STATE_CHANGE (1ULL << 11) -#define FTDM_CHANNEL_HOLD (1ULL << 12) -#define FTDM_CHANNEL_INUSE (1ULL << 13) -#define FTDM_CHANNEL_OFFHOOK (1ULL << 14) -#define FTDM_CHANNEL_RINGING (1ULL << 15) -#define FTDM_CHANNEL_PROGRESS_DETECT (1ULL << 16) -#define FTDM_CHANNEL_CALLERID_DETECT (1ULL << 17) -#define FTDM_CHANNEL_OUTBOUND (1ULL << 18) -#define FTDM_CHANNEL_SUSPENDED (1ULL << 19) -#define FTDM_CHANNEL_3WAY (1ULL << 20) -#define FTDM_CHANNEL_PROGRESS (1ULL << 21) -/*!< There is media on the channel already */ -#define FTDM_CHANNEL_MEDIA (1ULL << 22) -/*!< The channel was answered */ -#define FTDM_CHANNEL_ANSWERED (1ULL << 23) -#define FTDM_CHANNEL_MUTE (1ULL << 24) -#define FTDM_CHANNEL_USE_RX_GAIN (1ULL << 25) -#define FTDM_CHANNEL_USE_TX_GAIN (1ULL << 26) -#define FTDM_CHANNEL_IN_ALARM (1ULL << 27) -#define FTDM_CHANNEL_SIG_UP (1ULL << 28) -#define FTDM_CHANNEL_USER_HANGUP (1ULL << 29) -#define FTDM_CHANNEL_RX_DISABLED (1ULL << 30) -#define FTDM_CHANNEL_TX_DISABLED (1ULL << 31) -/*!< The user knows about a call in this channel */ -#define FTDM_CHANNEL_CALL_STARTED (1ULL << 32) -/*!< The user wants non-blocking operations in the channel */ -#define FTDM_CHANNEL_NONBLOCK (1ULL << 33) -/*!< There is a pending acknowledge for an indication */ -#define FTDM_CHANNEL_IND_ACK_PENDING (1ULL << 34) -/*!< There is someone blocking in the channel waiting for state completion */ -#define FTDM_CHANNEL_BLOCKING (1ULL << 35) -/*!< Media is digital */ -#define FTDM_CHANNEL_DIGITAL_MEDIA (1ULL << 36) -/*!< Native signaling bridge is enabled */ -#define FTDM_CHANNEL_NATIVE_SIGBRIDGE (1ULL << 37) -/*!< Native signaling DTMF detection */ -#define FTDM_CHANNEL_SIG_DTMF_DETECTION (1ULL << 38) - -/*!< This no more flags after this flag */ -#define FTDM_CHANNEL_MAX_FLAG (1ULL << 39) -/*! - * - * Copyright (C) 2001 Steve Underwood - * - * Despite my general liking of the GPL, I place this code in the - * public domain for the benefit of all mankind - even the slimy - * ones who might try to proprietize my work and use it to my - * detriment. - * - * $Id: g711.h,v 1.1 2006/06/07 15:46:39 steveu Exp $ - */ - -/*! \file */ - -/*! \page g711_page A-law and mu-law handling - Lookup tables for A-law and u-law look attractive, until you consider the impact - on the CPU cache. If it causes a substantial area of your processor cache to get - hit too often, cache sloshing will severely slow things down. The main reason - these routines are slow in C, is the lack of direct access to the CPU's "find - the first 1" instruction. A little in-line assembler fixes that, and the - conversion routines can be faster than lookup tables, in most real world usage. - A "find the first 1" instruction is available on most modern CPUs, and is a - much underused feature. - - If an assembly language method of bit searching is not available, these routines - revert to a method that can be a little slow, so the cache thrashing might not - seem so bad :( - - Feel free to submit patches to add fast "find the first 1" support for your own - favourite processor. - - Look up tables are used for transcoding between A-law and u-law, since it is - difficult to achieve the precise transcoding procedure laid down in the G.711 - specification by other means. -*/ - -#if !defined(_G711_H_) -#define _G711_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef _MSC_VER -#ifndef __inline__ -#define __inline__ __inline -#endif - typedef unsigned __int8 uint8_t; - typedef __int16 int16_t; - typedef __int32 int32_t; - typedef unsigned __int16 uint16_t; -#else -#include -#endif - -#if defined(__i386__) - /*! \brief Find the bit position of the highest set bit in a word - \param bits The word to be searched - \return The bit number of the highest set bit, or -1 if the word is zero. */ - static __inline__ int top_bit(unsigned int bits) - { - int res; - - __asm__ __volatile__(" movl $-1,%%edx;\n" - " bsrl %%eax,%%edx;\n" - : "=d" (res) - : "a" (bits)); - return res; - } - /*- End of function --------------------------------------------------------*/ - - /*! \brief Find the bit position of the lowest set bit in a word - \param bits The word to be searched - \return The bit number of the lowest set bit, or -1 if the word is zero. */ - static __inline__ int bottom_bit(unsigned int bits) - { - int res; - - __asm__ __volatile__(" movl $-1,%%edx;\n" - " bsfl %%eax,%%edx;\n" - : "=d" (res) - : "a" (bits)); - return res; - } - /*- End of function --------------------------------------------------------*/ -#elif defined(__x86_64__) - static __inline__ int top_bit(unsigned int bits) - { - int res; - - __asm__ __volatile__(" movq $-1,%%rdx;\n" - " bsrq %%rax,%%rdx;\n" - : "=d" (res) - : "a" (bits)); - return res; - } - /*- End of function --------------------------------------------------------*/ - - static __inline__ int bottom_bit(unsigned int bits) - { - int res; - - __asm__ __volatile__(" movq $-1,%%rdx;\n" - " bsfq %%rax,%%rdx;\n" - : "=d" (res) - : "a" (bits)); - return res; - } - /*- End of function --------------------------------------------------------*/ -#else - static __inline__ int top_bit(unsigned int bits) - { - int i; - - if (bits == 0) - return -1; - i = 0; - if (bits & 0xFFFF0000) - { - bits &= 0xFFFF0000; - i += 16; - } - if (bits & 0xFF00FF00) - { - bits &= 0xFF00FF00; - i += 8; - } - if (bits & 0xF0F0F0F0) - { - bits &= 0xF0F0F0F0; - i += 4; - } - if (bits & 0xCCCCCCCC) - { - bits &= 0xCCCCCCCC; - i += 2; - } - if (bits & 0xAAAAAAAA) - { - bits &= 0xAAAAAAAA; - i += 1; - } - return i; - } - /*- End of function --------------------------------------------------------*/ - - static __inline__ int bottom_bit(unsigned int bits) - { - int i; - - if (bits == 0) - return -1; - i = 32; - if (bits & 0x0000FFFF) - { - bits &= 0x0000FFFF; - i -= 16; - } - if (bits & 0x00FF00FF) - { - bits &= 0x00FF00FF; - i -= 8; - } - if (bits & 0x0F0F0F0F) - { - bits &= 0x0F0F0F0F; - i -= 4; - } - if (bits & 0x33333333) - { - bits &= 0x33333333; - i -= 2; - } - if (bits & 0x55555555) - { - bits &= 0x55555555; - i -= 1; - } - return i; - } - /*- End of function --------------------------------------------------------*/ -#endif - - /* N.B. It is tempting to use look-up tables for A-law and u-law conversion. - * However, you should consider the cache footprint. - * - * A 64K byte table for linear to x-law and a 512 byte table for x-law to - * linear sound like peanuts these days, and shouldn't an array lookup be - * real fast? No! When the cache sloshes as badly as this one will, a tight - * calculation may be better. The messiest part is normally finding the - * segment, but a little inline assembly can fix that on an i386, x86_64 and - * many other modern processors. - */ - - /* - * Mu-law is basically as follows: - * - * Biased Linear Input Code Compressed Code - * ------------------------ --------------- - * 00000001wxyza 000wxyz - * 0000001wxyzab 001wxyz - * 000001wxyzabc 010wxyz - * 00001wxyzabcd 011wxyz - * 0001wxyzabcde 100wxyz - * 001wxyzabcdef 101wxyz - * 01wxyzabcdefg 110wxyz - * 1wxyzabcdefgh 111wxyz - * - * Each biased linear code has a leading 1 which identifies the segment - * number. The value of the segment number is equal to 7 minus the number - * of leading 0's. The quantization interval is directly available as the - * four bits wxyz. * The trailing bits (a - h) are ignored. - * - * Ordinarily the complement of the resulting code word is used for - * transmission, and so the code word is complemented before it is returned. - * - * For further information see John C. Bellamy's Digital Telephony, 1982, - * John Wiley & Sons, pps 98-111 and 472-476. - */ - - /*#define ULAW_ZEROTRAP*/ /* turn on the trap as per the MIL-STD */ -#define ULAW_BIAS 0x84 /* Bias for linear code. */ - - /*! \brief Encode a linear sample to u-law - \param linear The sample to encode. - \return The u-law value. - */ - static __inline__ uint8_t linear_to_ulaw(int linear) - { - uint8_t u_val; - int mask; - int seg; - - /* Get the sign and the magnitude of the value. */ - if (linear < 0) - { - linear = ULAW_BIAS - linear; - mask = 0x7F; - } - else - { - linear = ULAW_BIAS + linear; - mask = 0xFF; - } - - seg = top_bit(linear | 0xFF) - 7; - - /* - * Combine the sign, segment, quantization bits, - * and complement the code word. - */ - if (seg >= 8) - u_val = (uint8_t) (0x7F ^ mask); - else - u_val = (uint8_t) (((seg << 4) | ((linear >> (seg + 3)) & 0xF)) ^ mask); -#ifdef ULAW_ZEROTRAP - /* Optional ITU trap */ - if (u_val == 0) - u_val = 0x02; -#endif - return u_val; - } - /*- End of function --------------------------------------------------------*/ - - /*! \brief Decode an u-law sample to a linear value. - \param ulaw The u-law sample to decode. - \return The linear value. - */ - static __inline__ int16_t ulaw_to_linear(uint8_t ulaw) - { - int t; - - /* Complement to obtain normal u-law value. */ - ulaw = ~ulaw; - /* - * Extract and bias the quantization bits. Then - * shift up by the segment number and subtract out the bias. - */ - t = (((ulaw & 0x0F) << 3) + ULAW_BIAS) << (((int) ulaw & 0x70) >> 4); - return (int16_t) ((ulaw & 0x80) ? (ULAW_BIAS - t) : (t - ULAW_BIAS)); - } - /*- End of function --------------------------------------------------------*/ - - /* - * A-law is basically as follows: - * - * Linear Input Code Compressed Code - * ----------------- --------------- - * 0000000wxyza 000wxyz - * 0000001wxyza 001wxyz - * 000001wxyzab 010wxyz - * 00001wxyzabc 011wxyz - * 0001wxyzabcd 100wxyz - * 001wxyzabcde 101wxyz - * 01wxyzabcdef 110wxyz - * 1wxyzabcdefg 111wxyz - * - * For further information see John C. Bellamy's Digital Telephony, 1982, - * John Wiley & Sons, pps 98-111 and 472-476. - */ - -#define ALAW_AMI_MASK 0x55 - - /*! \brief Encode a linear sample to A-law - \param linear The sample to encode. - \return The A-law value. - */ - static __inline__ uint8_t linear_to_alaw(int linear) - { - int mask; - int seg; - - if (linear >= 0) - { - /* Sign (bit 7) bit = 1 */ - mask = ALAW_AMI_MASK | 0x80; - } - else - { - /* Sign (bit 7) bit = 0 */ - mask = ALAW_AMI_MASK; - linear = -linear - 8; - } - - /* Convert the scaled magnitude to segment number. */ - seg = top_bit(linear | 0xFF) - 7; - if (seg >= 8) - { - if (linear >= 0) - { - /* Out of range. Return maximum value. */ - return (uint8_t) (0x7F ^ mask); - } - /* We must be just a tiny step below zero */ - return (uint8_t) (0x00 ^ mask); - } - /* Combine the sign, segment, and quantization bits. */ - return (uint8_t) (((seg << 4) | ((linear >> ((seg) ? (seg + 3) : 4)) & 0x0F)) ^ mask); - } - /*- End of function --------------------------------------------------------*/ - - /*! \brief Decode an A-law sample to a linear value. - \param alaw The A-law sample to decode. - \return The linear value. - */ - static __inline__ int16_t alaw_to_linear(uint8_t alaw) - { - int i; - int seg; - - alaw ^= ALAW_AMI_MASK; - i = ((alaw & 0x0F) << 4); - seg = (((int) alaw & 0x70) >> 4); - if (seg) - i = (i + 0x108) << (seg - 1); - else - i += 8; - return (int16_t) ((alaw & 0x80) ? i : -i); - } - /*- End of function --------------------------------------------------------*/ - - /*! \brief Transcode from A-law to u-law, using the procedure defined in G.711. - \param alaw The A-law sample to transcode. - \return The best matching u-law value. - */ - uint8_t alaw_to_ulaw(uint8_t alaw); - - /*! \brief Transcode from u-law to A-law, using the procedure defined in G.711. - \param alaw The u-law sample to transcode. - \return The best matching A-law value. - */ - uint8_t ulaw_to_alaw(uint8_t ulaw); - -#ifdef __cplusplus -} -#endif - -#endif -/*- End of file ------------------------------------------------------------*/ - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/include/private/hashtable.h b/libs/freetdm/src/include/private/hashtable.h deleted file mode 100644 index 5d029b5b85..0000000000 --- a/libs/freetdm/src/include/private/hashtable.h +++ /dev/null @@ -1,235 +0,0 @@ -/* Copyright (C) 2002 Christopher Clark */ - -#ifndef __HASHTABLE_CWC22_H__ -#define __HASHTABLE_CWC22_H__ -#ifdef _MSC_VER -#ifndef __inline__ -#define __inline__ __inline -#endif -#endif -#include "freetdm.h" - -#ifdef __cplusplus -extern "C" { -#endif -struct hashtable; -struct hashtable_iterator; - -/* Example of use: - * - * struct hashtable *h; - * struct some_key *k; - * struct some_value *v; - * - * static unsigned int hash_from_key_fn( void *k ); - * static int keys_equal_fn ( void *key1, void *key2 ); - * - * h = create_hashtable(16, hash_from_key_fn, keys_equal_fn); - * k = (struct some_key *) malloc(sizeof(struct some_key)); - * v = (struct some_value *) malloc(sizeof(struct some_value)); - * - * (initialise k and v to suitable values) - * - * if (! hashtable_insert(h,k,v) ) - * { exit(-1); } - * - * if (NULL == (found = hashtable_search(h,k) )) - * { printf("not found!"); } - * - * if (NULL == (found = hashtable_remove(h,k) )) - * { printf("Not found\n"); } - * - */ - -/* Macros may be used to define type-safe(r) hashtable access functions, with - * methods specialized to take known key and value types as parameters. - * - * Example: - * - * Insert this at the start of your file: - * - * DEFINE_HASHTABLE_INSERT(insert_some, struct some_key, struct some_value); - * DEFINE_HASHTABLE_SEARCH(search_some, struct some_key, struct some_value); - * DEFINE_HASHTABLE_REMOVE(remove_some, struct some_key, struct some_value); - * - * This defines the functions 'insert_some', 'search_some' and 'remove_some'. - * These operate just like hashtable_insert etc., with the same parameters, - * but their function signatures have 'struct some_key *' rather than - * 'void *', and hence can generate compile time errors if your program is - * supplying incorrect data as a key (and similarly for value). - * - * Note that the hash and key equality functions passed to create_hashtable - * still take 'void *' parameters instead of 'some key *'. This shouldn't be - * a difficult issue as they're only defined and passed once, and the other - * functions will ensure that only valid keys are supplied to them. - * - * The cost for this checking is increased code size and runtime overhead - * - if performance is important, it may be worth switching back to the - * unsafe methods once your program has been debugged with the safe methods. - * This just requires switching to some simple alternative defines - eg: - * #define insert_some hashtable_insert - * - */ - -/***************************************************************************** - * create_hashtable - - * @name create_hashtable - * @param minsize minimum initial size of hashtable - * @param hashfunction function for hashing keys - * @param key_eq_fn function for determining key equality - * @return newly created hashtable or NULL on failure - */ - -FT_DECLARE(struct hashtable *) -create_hashtable(unsigned int minsize, - unsigned int (*hashfunction) (void*), - int (*key_eq_fn) (void*,void*)); - -/***************************************************************************** - * hashtable_insert - - * @name hashtable_insert - * @param h the hashtable to insert into - * @param k the key - hashtable claims ownership and will free on removal - * @param v the value - does not claim ownership - * @return non-zero for successful insertion - * - * This function will cause the table to expand if the insertion would take - * the ratio of entries to table size over the maximum load factor. - * - * This function does not check for repeated insertions with a duplicate key. - * The value returned when using a duplicate key is undefined -- when - * the hashtable changes size, the order of retrieval of duplicate key - * entries is reversed. - * If in doubt, remove before insert. - */ - - -typedef enum { - HASHTABLE_FLAG_NONE = 0, - HASHTABLE_FLAG_FREE_KEY = (1 << 0), - HASHTABLE_FLAG_FREE_VALUE = (1 << 1) -} hashtable_flag_t; - -FT_DECLARE(int) -hashtable_insert(struct hashtable *h, void *k, void *v, hashtable_flag_t flags); - -#define DEFINE_HASHTABLE_INSERT(fnname, keytype, valuetype) \ - int fnname (struct hashtable *h, keytype *k, valuetype *v) \ - { \ - return hashtable_insert(h,k,v); \ - } - -/***************************************************************************** - * hashtable_search - - * @name hashtable_search - * @param h the hashtable to search - * @param k the key to search for - does not claim ownership - * @return the value associated with the key, or NULL if none found - */ - -FT_DECLARE(void *) -hashtable_search(struct hashtable *h, void *k); - -#define DEFINE_HASHTABLE_SEARCH(fnname, keytype, valuetype) \ - valuetype * fnname (struct hashtable *h, keytype *k) \ - { \ - return (valuetype *) (hashtable_search(h,k)); \ - } - -/***************************************************************************** - * hashtable_remove - - * @name hashtable_remove - * @param h the hashtable to remove the item from - * @param k the key to search for - does not claim ownership - * @return the value associated with the key, or NULL if none found - */ - -FT_DECLARE(void *) /* returns value */ -hashtable_remove(struct hashtable *h, void *k); - -#define DEFINE_HASHTABLE_REMOVE(fnname, keytype, valuetype) \ - valuetype * fnname (struct hashtable *h, keytype *k) \ - { \ - return (valuetype *) (hashtable_remove(h,k)); \ - } - - -/***************************************************************************** - * hashtable_count - - * @name hashtable_count - * @param h the hashtable - * @return the number of items stored in the hashtable - */ -FT_DECLARE(unsigned int) -hashtable_count(struct hashtable *h); - - -/***************************************************************************** - * hashtable_destroy - - * @name hashtable_destroy - * @param h the hashtable - * @param free_values whether to call 'free' on the remaining values - */ - -FT_DECLARE(void) -hashtable_destroy(struct hashtable *h); - -FT_DECLARE(struct hashtable_iterator*) hashtable_first(struct hashtable *h); -FT_DECLARE(struct hashtable_iterator*) hashtable_next(struct hashtable_iterator *i); -FT_DECLARE(void) hashtable_this(struct hashtable_iterator *i, const void **key, int *klen, void **val); - -#ifdef __cplusplus -} /* extern C */ -#endif - -#endif /* __HASHTABLE_CWC22_H__ */ - -/* - * Copyright (c) 2002, Christopher Clark - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/include/private/hashtable_itr.h b/libs/freetdm/src/include/private/hashtable_itr.h deleted file mode 100644 index bf0a6e19d0..0000000000 --- a/libs/freetdm/src/include/private/hashtable_itr.h +++ /dev/null @@ -1,134 +0,0 @@ -/* Copyright (C) 2002, 2004 Christopher Clark */ - -#ifndef __HASHTABLE_ITR_CWC22__ -#define __HASHTABLE_ITR_CWC22__ -#include "hashtable.h" -#include "hashtable_private.h" /* needed to enable inlining */ - -#ifdef __cplusplus -extern "C" { -#endif -/*****************************************************************************/ -/* This struct is only concrete here to allow the inlining of two of the - * accessor functions. */ -struct hashtable_itr -{ - struct hashtable *h; - struct entry *e; - struct entry *parent; - unsigned int index; -}; - - -/*****************************************************************************/ -/* hashtable_iterator - */ - -struct hashtable_itr * -hashtable_iterator(struct hashtable *h); - -/*****************************************************************************/ -/* hashtable_iterator_key - * - return the value of the (key,value) pair at the current position */ -extern __inline__ void * -hashtable_iterator_key(struct hashtable_itr *i); - -extern __inline__ void * -hashtable_iterator_key(struct hashtable_itr *i) -{ - return i->e->k; -} - -/*****************************************************************************/ -/* value - return the value of the (key,value) pair at the current position */ - -extern __inline__ void * -hashtable_iterator_value(struct hashtable_itr *i); - -extern __inline__ void * -hashtable_iterator_value(struct hashtable_itr *i) -{ - return i->e->v; -} - -/*****************************************************************************/ -/* advance - advance the iterator to the next element - * returns zero if advanced to end of table */ - -int -hashtable_iterator_advance(struct hashtable_itr *itr); - -/*****************************************************************************/ -/* remove - remove current element and advance the iterator to the next element - * NB: if you need the value to free it, read it before - * removing. ie: beware memory leaks! - * returns zero if advanced to end of table */ - -int -hashtable_iterator_remove(struct hashtable_itr *itr); - -/*****************************************************************************/ -/* search - overwrite the supplied iterator, to point to the entry - * matching the supplied key. - h points to the hashtable to be searched. - * returns zero if not found. */ -int -hashtable_iterator_search(struct hashtable_itr *itr, - struct hashtable *h, void *k); - -#define DEFINE_HASHTABLE_ITERATOR_SEARCH(fnname, keytype) \ - int fnname (struct hashtable_itr *i, struct hashtable *h, keytype *k) \ - { \ - return (hashtable_iterator_search(i,h,k)); \ - } - -#ifdef __cplusplus -} -#endif - -#endif /* __HASHTABLE_ITR_CWC22__*/ - -/* - * Copyright (c) 2002, 2004, Christopher Clark - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ - diff --git a/libs/freetdm/src/include/private/hashtable_private.h b/libs/freetdm/src/include/private/hashtable_private.h deleted file mode 100644 index 35f22091ef..0000000000 --- a/libs/freetdm/src/include/private/hashtable_private.h +++ /dev/null @@ -1,110 +0,0 @@ -/* Copyright (C) 2002, 2004 Christopher Clark */ - -#ifndef __HASHTABLE_PRIVATE_CWC22_H__ -#define __HASHTABLE_PRIVATE_CWC22_H__ - -#include "hashtable.h" - -#ifdef __cplusplus -extern "C" { -#endif -/*****************************************************************************/ - -struct entry -{ - void *k, *v; - unsigned int h; - hashtable_flag_t flags; - struct entry *next; -}; - -struct hashtable_iterator { - unsigned int pos; - struct entry *e; - struct hashtable *h; -}; - -struct hashtable { - unsigned int tablelength; - struct entry **table; - unsigned int entrycount; - unsigned int loadlimit; - unsigned int primeindex; - unsigned int (*hashfn) (void *k); - int (*eqfn) (void *k1, void *k2); - struct hashtable_iterator iterator; -}; - -/*****************************************************************************/ -unsigned int -hash(struct hashtable *h, void *k); - -/*****************************************************************************/ -/* indexFor */ -static __inline__ unsigned int -indexFor(unsigned int tablelength, unsigned int hashvalue) { - return (hashvalue % tablelength); -} - -/* Only works if tablelength == 2^N */ -/*static inline unsigned int - indexFor(unsigned int tablelength, unsigned int hashvalue) - { - return (hashvalue & (tablelength - 1u)); - } -*/ - -/*****************************************************************************/ -#define freekey(X) free(X) -/*define freekey(X) ; */ - -#ifdef __cplusplus -} -#endif - -/*****************************************************************************/ - -#endif /* __HASHTABLE_PRIVATE_CWC22_H__*/ - -/* - * Copyright (c) 2002, Christopher Clark - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/include/private/libteletone.h b/libs/freetdm/src/include/private/libteletone.h deleted file mode 100644 index 060a226032..0000000000 --- a/libs/freetdm/src/include/private/libteletone.h +++ /dev/null @@ -1,161 +0,0 @@ -/* - * libteletone - * Copyright (C) 2005-2014, Anthony Minessale II - * - * Version: MPL 1.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is libteletone - * - * The Initial Developer of the Original Code is - * Anthony Minessale II - * Portions created by the Initial Developer are Copyright (C) - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Anthony Minessale II - * - * - * libteletone.h -- Tone Generator/Detector - * - * - * - * Exception: - * The author hereby grants the use of this source code under the - * following license if and only if the source code is distributed - * as part of the OpenZAP or FreeTDM library. Any use or distribution of this - * source code outside the scope of the OpenZAP or FreeTDM library will nullify the - * following license and reinact the MPL 1.1 as stated above. - * - * Copyright (c) 2007, Anthony Minessale II - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef LIBTELETONE_H -#define LIBTELETONE_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#define TELETONE_MAX_DTMF_DIGITS 128 -#define TELETONE_MAX_TONES 18 -#define TELETONE_TONE_RANGE 127 - -typedef double teletone_process_t; - -/*! \file libteletone.h - \brief Top level include file - - This file should be included by applications using the library -*/ - -/*! \brief An abstraction to store a tone mapping */ -typedef struct { - /*! An array of tone frequencies */ - teletone_process_t freqs[TELETONE_MAX_TONES]; -} teletone_tone_map_t; - -#if !defined(M_PI) -/* C99 systems may not define M_PI */ -#define M_PI 3.14159265358979323846264338327 -#endif - -#ifdef _MSC_VER -typedef __int16 int16_t; -#endif - -#if (_MSC_VER >= 1400) // VC8+ -#define teletone_assert(expr) assert(expr);__analysis_assume( expr ) -#else -#define teletone_assert(expr) assert(expr) -#endif - -#ifdef _MSC_VER -#if defined(TT_DECLARE_STATIC) -#define TELETONE_API(type) type __stdcall -#define TELETONE_API_NONSTD(type) type __cdecl -#define TELETONE_API_DATA -#elif defined(TELETONE_EXPORTS) -#define TELETONE_API(type) __declspec(dllexport) type __stdcall -#define TELETONE_API_NONSTD(type) __declspec(dllexport) type __cdecl -#define TELETONE_API_DATA __declspec(dllexport) -#else -#define TELETONE_API(type) __declspec(dllimport) type __stdcall -#define TELETONE_API_NONSTD(type) __declspec(dllimport) type __cdecl -#define TELETONE_API_DATA __declspec(dllimport) -#endif -#else -#if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(HAVE_VISIBILITY) -#define TELETONE_API(type) __attribute__((visibility("default"))) type -#define TELETONE_API_NONSTD(type) __attribute__((visibility("default"))) type -#define TELETONE_API_DATA __attribute__((visibility("default"))) -#else -#define TELETONE_API(type) type -#define TELETONE_API_NONSTD(type) type -#define TELETONE_API_DATA -#endif -#endif - -#include "libteletone_generate.h" -#include "libteletone_detect.h" - -#ifdef HAVE_STRING_H -#include -#endif - -#ifdef __cplusplus -} -#endif - -#endif - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/include/private/libteletone_detect.h b/libs/freetdm/src/include/private/libteletone_detect.h deleted file mode 100644 index 646b03e1be..0000000000 --- a/libs/freetdm/src/include/private/libteletone_detect.h +++ /dev/null @@ -1,282 +0,0 @@ -/* - * libteletone - * Copyright (C) 2005-2014, Anthony Minessale II - * - * Version: MPL 1.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is tone_detect.c - General telephony tone detection, and specific detection of DTMF. - * - * - * The Initial Developer of the Original Code is - * Stephen Underwood - * Portions created by the Initial Developer are Copyright (C) - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * The the original interface designed by Steve Underwood was preserved to retain - *the optimizations when considering DTMF tones though the names were changed in the interest - * of namespace. - * - * Much less efficient expansion interface was added to allow for the detection of - * a single arbitrary tone combination which may also exceed 2 simultaneous tones. - * (controlled by compile time constant TELETONE_MAX_TONES) - * - * Copyright (C) 2006 Anthony Minessale II - * - * - * libteletone_detect.c Tone Detection Code - * - * - ********************************************************************************* - * - * Derived from tone_detect.h - General telephony tone detection, and specific - * detection of DTMF. - * - * Copyright (C) 2001 Steve Underwood - * - * Despite my general liking of the GPL, I place this code in the - * public domain for the benefit of all mankind - even the slimy - * ones who might try to proprietize my work and use it to my - * detriment. - * - * - * Exception: - * The author hereby grants the use of this source code under the - * following license if and only if the source code is distributed - * as part of the OpenZAP or FreeTDM library. Any use or distribution of this - * source code outside the scope of the OpenZAP or FreeTDM library will nullify the - * following license and reinact the MPL 1.1 as stated above. - * - * Copyright (c) 2007, Anthony Minessale II - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef LIBTELETONE_DETECT_H -#define LIBTELETONE_DETECT_H - -#ifdef __cplusplus -extern "C" { -#endif -#include "libteletone.h" - - /*! \file libteletone_detect.h - \brief Tone Detection Routines - - This module is responsible for tone detection specifics - */ - -#ifndef FALSE -#define FALSE 0 -#ifndef TRUE -#define TRUE (!FALSE) -#endif -#endif - - /* Basic DTMF specs: - * - * Minimum tone on = 40ms - * Minimum tone off = 50ms - * Maximum digit rate = 10 per second - * Normal twist <= 8dB accepted - * Reverse twist <= 4dB accepted - * S/N >= 15dB will detect OK - * Attenuation <= 26dB will detect OK - * Frequency tolerance +- 1.5% will detect, +-3.5% will reject - */ - -#define DTMF_THRESHOLD 8.0e7 -#define DTMF_NORMAL_TWIST 6.3 /* 8dB */ -#define DTMF_REVERSE_TWIST 2.5 /* 4dB */ -#define DTMF_RELATIVE_PEAK_ROW 6.3 /* 8dB */ -#define DTMF_RELATIVE_PEAK_COL 6.3 /* 8dB */ -#define DTMF_2ND_HARMONIC_ROW 2.5 /* 4dB */ -#define DTMF_2ND_HARMONIC_COL 63.1 /* 18dB */ -#define GRID_FACTOR 4 -#define BLOCK_LEN 102 -#define M_TWO_PI 2.0*M_PI - - typedef enum { - TT_HIT_NONE = 0, - TT_HIT_BEGIN = 1, - TT_HIT_MIDDLE = 2, - TT_HIT_END = 3 - } teletone_hit_type_t; - - - /*! \brief A continer for the elements of a Goertzel Algorithm (The names are from his formula) */ - typedef struct { - float v2; - float v3; - double fac; - } teletone_goertzel_state_t; - - /*! \brief A container for a DTMF detection state.*/ - typedef struct { - int hit1; - int hit2; - int hit3; - int hit4; - int dur; - int zc; - - - teletone_goertzel_state_t row_out[GRID_FACTOR]; - teletone_goertzel_state_t col_out[GRID_FACTOR]; - teletone_goertzel_state_t row_out2nd[GRID_FACTOR]; - teletone_goertzel_state_t col_out2nd[GRID_FACTOR]; - float energy; - float lenergy; - - int current_sample; - char digit; - int current_digits; - int detected_digits; - int lost_digits; - int digit_hits[16]; - } teletone_dtmf_detect_state_t; - - /*! \brief An abstraction to store the coefficient of a tone frequency */ - typedef struct { - float fac; - } teletone_detection_descriptor_t; - - /*! \brief A container for a single multi-tone detection - TELETONE_MAX_TONES dictates the maximum simultaneous tones that can be present - in a multi-tone representation. - */ - typedef struct { - int sample_rate; - - teletone_detection_descriptor_t tdd[TELETONE_MAX_TONES]; - teletone_goertzel_state_t gs[TELETONE_MAX_TONES]; - teletone_goertzel_state_t gs2[TELETONE_MAX_TONES]; - int tone_count; - - float energy; - int current_sample; - - int min_samples; - int total_samples; - - int positives; - int negatives; - int hits; - - int positive_factor; - int negative_factor; - int hit_factor; - - } teletone_multi_tone_t; - - - /*! - \brief Initilize a multi-frequency tone detector - \param mt the multi-frequency tone descriptor - \param map a representation of the multi-frequency tone - */ -TELETONE_API(void) teletone_multi_tone_init(teletone_multi_tone_t *mt, teletone_tone_map_t *map); - - /*! - \brief Check a sample buffer for the presence of the mulit-frequency tone described by mt - \param mt the multi-frequency tone descriptor - \param sample_buffer an array aof 16 bit signed linear samples - \param samples the number of samples present in sample_buffer - \return true when the tone was detected or false when it is not - */ -TELETONE_API(int) teletone_multi_tone_detect (teletone_multi_tone_t *mt, - int16_t sample_buffer[], - int samples); - - /*! - \brief Initilize a DTMF detection state object - \param dtmf_detect_state the DTMF detection state to initilize - \param sample_rate the desired sample rate - */ -TELETONE_API(void) teletone_dtmf_detect_init (teletone_dtmf_detect_state_t *dtmf_detect_state, int sample_rate); - - /*! - \brief Check a sample buffer for the presence of DTMF digits - \param dtmf_detect_state the detection state object to check - \param sample_buffer an array aof 16 bit signed linear samples - \param samples the number of samples present in sample_buffer - \return true when DTMF was detected or false when it is not - */ -TELETONE_API(teletone_hit_type_t) teletone_dtmf_detect (teletone_dtmf_detect_state_t *dtmf_detect_state, - int16_t sample_buffer[], - int samples); - /*! - \brief retrieve any collected digits into a string buffer - \param dtmf_detect_state the detection state object to check - \param buf the string buffer to write to - \param max the maximum length of buf - \return the number of characters written to buf - */ -TELETONE_API(int) teletone_dtmf_get (teletone_dtmf_detect_state_t *dtmf_detect_state, char *buf, unsigned int *dur); - - /*! - \brief Step through the Goertzel Algorithm for each sample in a buffer - \param goertzel_state the goertzel state to step the samples through - \param sample_buffer an array aof 16 bit signed linear samples - \param samples the number of samples present in sample_buffer - */ -TELETONE_API(void) teletone_goertzel_update(teletone_goertzel_state_t *goertzel_state, - int16_t sample_buffer[], - int samples); - - - -#ifdef __cplusplus -} -#endif - -#endif - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/include/private/libteletone_generate.h b/libs/freetdm/src/include/private/libteletone_generate.h deleted file mode 100644 index d5f0bf2e48..0000000000 --- a/libs/freetdm/src/include/private/libteletone_generate.h +++ /dev/null @@ -1,316 +0,0 @@ -/* - * libteletone - * Copyright (C) 2005-2014, Anthony Minessale II - * - * Version: MPL 1.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is libteletone - * - * The Initial Developer of the Original Code is - * Anthony Minessale II - * Portions created by the Initial Developer are Copyright (C) - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Anthony Minessale II - * - * - * libteletone.h -- Tone Generator - * - * - * - * Exception: - * The author hereby grants the use of this source code under the - * following license if and only if the source code is distributed - * as part of the OpenZAP or FreeTDM library. Any use or distribution of this - * source code outside the scope of the OpenZAP or FreeTDM library will nullify the - * following license and reinact the MPL 1.1 as stated above. - * - * Copyright (c) 2007, Anthony Minessale II - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef LIBTELETONE_GENERATE_H -#define LIBTELETONE_GENERATE_H -#ifdef __cplusplus -extern "C" { -#ifdef _doh -} -#endif -#endif - -#include -#include - -#if defined(__SUNPRO_C) || defined(__SUNPRO_CC) -#ifndef __inline__ -#define __inline__ inline -#endif -#endif - -#ifdef _MSC_VER -#ifndef __inline__ -#define __inline__ __inline -#endif - -typedef unsigned __int64 uint64_t; -typedef unsigned __int32 uint32_t; -typedef unsigned __int16 uint16_t; -typedef unsigned __int8 uint8_t; -typedef __int64 int64_t; -typedef __int32 int32_t; -typedef __int16 int16_t; -typedef __int8 int8_t; -#else -#include -#endif -#include -#include -#include -#include -#if !defined(powf) && !defined(_WIN64) -extern float powf (float, float); -#endif -#include -#include -#ifndef _MSC_VER -#include -#endif -#include -#include -#include "libteletone.h" - -#define TELETONE_VOL_DB_MAX 0 -#define TELETONE_VOL_DB_MIN -63 -#define MAX_PHASE_TONES 4 - -struct teletone_dds_state { - uint32_t phase_rate[MAX_PHASE_TONES]; - uint32_t scale_factor; - uint32_t phase_accumulator; - teletone_process_t tx_level; -}; -typedef struct teletone_dds_state teletone_dds_state_t; - -#define SINE_TABLE_MAX 128 -#define SINE_TABLE_LEN (SINE_TABLE_MAX - 1) -#define MAX_PHASE_ACCUMULATOR 0x10000 * 0x10000 -/* 3.14 == the max power on ulaw (alaw is 3.17) */ -/* 3.02 represents twice the power */ -#define DBM0_MAX_POWER (3.14f + 3.02f) - -TELETONE_API_DATA extern int16_t TELETONE_SINES[SINE_TABLE_MAX]; - -static __inline__ int32_t teletone_dds_phase_rate(teletone_process_t tone, uint32_t rate) -{ - return (int32_t) ((tone * MAX_PHASE_ACCUMULATOR) / rate); -} - -static __inline__ int16_t teletone_dds_state_modulate_sample(teletone_dds_state_t *dds, uint32_t pindex) -{ - int32_t bitmask = dds->phase_accumulator, sine_index = (bitmask >>= 23) & SINE_TABLE_LEN; - int16_t sample; - - if (pindex >= MAX_PHASE_TONES) { - pindex = 0; - } - - if (bitmask & SINE_TABLE_MAX) { - sine_index = SINE_TABLE_LEN - sine_index; - } - - sample = TELETONE_SINES[sine_index]; - - if (bitmask & (SINE_TABLE_MAX * 2)) { - sample *= -1; - } - - dds->phase_accumulator += dds->phase_rate[pindex]; - return (int16_t) (sample * dds->scale_factor >> 15); -} - -static __inline__ void teletone_dds_state_set_tx_level(teletone_dds_state_t *dds, float tx_level) -{ - dds->scale_factor = (int) (powf(10.0f, (tx_level - DBM0_MAX_POWER) / 20.0f) * (32767.0f * 1.414214f)); - dds->tx_level = tx_level; -} - -static __inline__ void teletone_dds_state_reset_accum(teletone_dds_state_t *dds) -{ - dds->phase_accumulator = 0; -} - -static __inline__ int teletone_dds_state_set_tone(teletone_dds_state_t *dds, teletone_process_t tone, uint32_t rate, uint32_t pindex) -{ - if (pindex < MAX_PHASE_TONES) { - dds->phase_rate[pindex] = teletone_dds_phase_rate(tone, rate); - return 0; - } - - return -1; -} - - - -/*! \file libteletone_generate.h - \brief Tone Generation Routines - - This module is responsible for tone generation specifics -*/ - -typedef int16_t teletone_audio_t; -struct teletone_generation_session; -typedef int (*tone_handler)(struct teletone_generation_session *ts, teletone_tone_map_t *map); - -/*! \brief An abstraction to store a tone generation session */ -struct teletone_generation_session { - /*! An array of tone mappings to character mappings */ - teletone_tone_map_t TONES[TELETONE_TONE_RANGE]; - /*! The number of channels the output audio should be in */ - int channels; - /*! The Rate in hz of the output audio */ - int rate; - /*! The duration (in samples) of the output audio */ - int duration; - /*! The duration of silence to append after the initial audio is generated */ - int wait; - /*! The duration (in samples) of the output audio (takes prescedence over actual duration value) */ - int tmp_duration; - /*! The duration of silence to append after the initial audio is generated (takes prescedence over actual wait value)*/ - int tmp_wait; - /*! Number of loops to repeat a single instruction*/ - int loops; - /*! Number of loops to repeat the entire set of instructions*/ - int LOOPS; - /*! Number to mutiply total samples by to determine when to begin ascent or decent e.g. 0=beginning 4=(last 25%) */ - float decay_factor; - /*! Direction to perform volume increase/decrease 1/-1*/ - int decay_direction; - /*! Number of samples between increase/decrease of volume */ - int decay_step; - /*! Volume factor of the tone */ - float volume; - /*! Debug on/off */ - int debug; - /*! FILE stream to write debug data to */ - FILE *debug_stream; - /*! Extra user data to attach to the session*/ - void *user_data; - /*! Buffer for storing sample data (dynamic) */ - teletone_audio_t *buffer; - /*! Size of the buffer */ - int datalen; - /*! In-Use size of the buffer */ - int samples; - /*! Callback function called during generation */ - int dynamic; - tone_handler handler; -}; - -typedef struct teletone_generation_session teletone_generation_session_t; - - -/*! - \brief Assign a set of tones to a tone_session indexed by a paticular index/character - \param ts the tone generation session - \param index the index to map the tone to - \param ... up to TELETONE_MAX_TONES frequencies terminated by 0.0 - \return 0 -*/ -TELETONE_API(int) teletone_set_tone(teletone_generation_session_t *ts, int index, ...); - -/*! - \brief Assign a set of tones to a single tone map - \param map the map to assign the tones to - \param ... up to TELETONE_MAX_TONES frequencies terminated by 0.0 - \return 0 -*/ -TELETONE_API(int) teletone_set_map(teletone_tone_map_t *map, ...); - -/*! - \brief Initilize a tone generation session - \param ts the tone generation session to initilize - \param buflen the size of the buffer(in samples) to dynamically allocate - \param handler a callback function to execute when a tone generation instruction is complete - \param user_data optional user data to send - \return 0 -*/ -TELETONE_API(int) teletone_init_session(teletone_generation_session_t *ts, int buflen, tone_handler handler, void *user_data); - -/*! - \brief Free the buffer allocated by a tone generation session - \param ts the tone generation session to destroy - \return 0 -*/ -TELETONE_API(int) teletone_destroy_session(teletone_generation_session_t *ts); - -/*! - \brief Execute a single tone generation instruction - \param ts the tone generation session to consult for parameters - \param map the tone mapping to use for the frequencies - \return 0 -*/ -TELETONE_API(int) teletone_mux_tones(teletone_generation_session_t *ts, teletone_tone_map_t *map); - -/*! - \brief Execute a tone generation script and call callbacks after each instruction - \param ts the tone generation session to execute on - \param cmd the script to execute - \return 0 -*/ -TELETONE_API(int) teletone_run(teletone_generation_session_t *ts, const char *cmd); - -#ifdef __cplusplus -} -#endif - -#endif - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/include/private/sangoma_tdm_api.h b/libs/freetdm/src/include/private/sangoma_tdm_api.h deleted file mode 100644 index 6880199110..0000000000 --- a/libs/freetdm/src/include/private/sangoma_tdm_api.h +++ /dev/null @@ -1,321 +0,0 @@ -/***************************************************************************** - * sangoma_tdm_api.h Sangoma TDM API Portability functions - * - * Author(s): Anthony Minessale II - * Nenad Corbic - * Michael Jerris - * David Rokhvarg - * - * Copyright: (c) 2006 Nenad Corbic - * Anthony Minessale II - * (c) 1984-2007 Sangoma Technologies Inc. - * - * ============================================================================ - */ - -#ifndef _SANGOMA_TDM_API_H -#define _SANGOMA_TDM_API_H - -/* This entire block of defines and includes from this line, through #define FNAME_LEN probably dont belong here */ -/* most of them probably belong in wanpipe_defines.h, then each header file listed included below properly included */ -/* in the header files that depend on them, leaving only the include for wanpipe_tdm_api.h left in this file or */ -/* possibly integrating the rest of this file diretly into wanpipe_tdm_api.h */ -#ifndef __WINDOWS__ -#if defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32) -#define __WINDOWS__ -#endif /* defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32) */ -#endif /* ndef __WINDOWS__ */ - -#if defined(__WINDOWS__) -#if defined(_MSC_VER) -/* disable some warnings caused by wanpipe headers that will need to be fixed in those headers */ -#pragma warning(disable:4201 4214) - -/* sang_api.h(74) : warning C4201: nonstandard extension used : nameless struct/union */ - -/* wanpipe_defines.h(219) : warning C4214: nonstandard extension used : bit field types other than int */ -/* wanpipe_defines.h(220) : warning C4214: nonstandard extension used : bit field types other than int */ -/* this will break for any compilers that are strict ansi or strict c99 */ - -/* The following definition for that struct should resolve this warning and work for 32 and 64 bit */ -#if 0 -struct iphdr { - -#if defined(__LITTLE_ENDIAN_BITFIELD) - unsigned ihl:4, - version:4; -#elif defined (__BIG_ENDIAN_BITFIELD) - unsigned version:4, - ihl:4; -#else -# error "unknown byteorder!" -#endif - unsigned tos:8; - unsigned tot_len:16; - unsigned id:16; - unsigned frag_off:16; - __u8 ttl; - __u8 protocol; - __u16 check; - __u32 saddr; - __u32 daddr; - /*The options start here. */ -}; -#endif /* #if 0 */ - -#define __inline__ __inline -#endif /* defined(_MSC_VER) */ -#include -/* do we like the name WP_INVALID_SOCKET or should it be changed? */ -#define WP_INVALID_SOCKET INVALID_HANDLE_VALUE -#else /* defined(__WINDOWS__) */ -#define WP_INVALID_SOCKET -1 -#include -#include -#include -#endif - -#include -#include -#include -#include -#ifdef __WINDOWS__ -#include -#include -#endif -#include - -#define FNAME_LEN 50 - - -#if defined(__WINDOWS__) -/* This might be broken on windows, as POLL_EVENT_TELEPHONY seems to be commented out in sang_api.h.. it should be added to POLLPRI */ -#define POLLPRI (POLL_EVENT_LINK_STATE | POLL_EVENT_LINK_CONNECT | POLL_EVENT_LINK_DISCONNECT) -#endif - -/* return -1 for error, 0 for timeout or 1 for success. *flags is set to the poll evetns POLLIN | POLLOUT | POLLPRI based on the result of the poll */ -/* on windows we actually have POLLPRI defined with several events, so we could theoretically poll */ -/* for specific events. Is there any way to do this on *nix as well? */ - -/* a cross platform way to poll on an actual pollset (span and/or list of spans) will probably also be needed for analog */ -/* so we can have one analong handler thread that will deal with all the idle analog channels for events */ -/* the alternative would be for the driver to provide one socket for all of the oob events for all analog channels */ -static __inline__ int tdmv_api_wait_socket(sng_fd_t fd, int timeout, int *flags) -{ -#if defined(__WINDOWS__) - DWORD ln; - API_POLL_STRUCT api_poll; - - memset(&api_poll, 0x00, sizeof(API_POLL_STRUCT)); - - api_poll.user_flags_bitmap = *flags; - api_poll.timeout = timeout; - - if (!DeviceIoControl( - fd, - IoctlApiPoll, - (LPVOID)NULL, - 0L, - (LPVOID)&api_poll, - sizeof(API_POLL_STRUCT), - (LPDWORD)(&ln), - (LPOVERLAPPED)NULL)) { - return -1; - } - - *flags = 0; - - switch(api_poll.operation_status) - { - case SANG_STATUS_RX_DATA_AVAILABLE: - break; - - case SANG_STATUS_RX_DATA_TIMEOUT: - return 0; - - default: - return -1; - } - - if (api_poll.poll_events_bitmap == 0){ - return -1; - } - - if (api_poll.poll_events_bitmap & POLL_EVENT_TIMEOUT) { - return 0; - } - - *flags = api_poll.poll_events_bitmap; - - return 1; -#else - struct pollfd pfds[1]; - int res; - - memset(&pfds[0], 0, sizeof(pfds[0])); - pfds[0].fd = fd; - pfds[0].events = *flags; - res = poll(pfds, 1, timeout); - *flags = 0; - - if (pfds[0].revents & POLLERR) { - res = -1; - } - - if (res > 0) { - *flags = pfds[0].revents; - } - - return res; -#endif -} - -/* on windows right now, there is no way to specify if we want to read events here or not, we allways get them here */ -/* we need some what to select if we are reading regular tdm msgs or events */ -/* need to either have 2 functions, 1 for events, 1 for regural read, or a flag on this function to choose */ -/* 2 functions preferred. Need implementation for the event function for both nix and windows that is threadsafe */ -static __inline__ int tdmv_api_readmsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen, void *databuf, int datalen) -{ - /* What do we need to do here to avoid having to do all */ - /* the memcpy's on windows and still maintain api compat with nix */ - int rx_len=0; -#if defined(__WINDOWS__) - static RX_DATA_STRUCT rx_data; - api_header_t *pri; - wp_tdm_api_rx_hdr_t *tdm_api_rx_hdr; - wp_tdm_api_rx_hdr_t *user_buf = (wp_tdm_api_rx_hdr_t*)hdrbuf; - DWORD ln; - - if (hdrlen != sizeof(wp_tdm_api_rx_hdr_t)){ - return -1; - } - - if (!DeviceIoControl( - fd, - IoctlReadCommand, - (LPVOID)NULL, - 0L, - (LPVOID)&rx_data, - sizeof(RX_DATA_STRUCT), - (LPDWORD)(&ln), - (LPOVERLAPPED)NULL - )){ - return -1; - } - - pri = &rx_data.api_header; - tdm_api_rx_hdr = (wp_tdm_api_rx_hdr_t*)rx_data.data; - - user_buf->wp_tdm_api_event_type = pri->operation_status; - - switch(pri->operation_status) - { - case SANG_STATUS_RX_DATA_AVAILABLE: - if (pri->data_length > datalen){ - break; - } - memcpy(databuf, rx_data.data, pri->data_length); - rx_len = pri->data_length; - break; - - default: - break; - } - -#else - struct msghdr msg; - struct iovec iov[2]; - - memset(&msg,0,sizeof(struct msghdr)); - - iov[0].iov_len=hdrlen; - iov[0].iov_base=hdrbuf; - - iov[1].iov_len=datalen; - iov[1].iov_base=databuf; - - msg.msg_iovlen=2; - msg.msg_iov=iov; - - rx_len = read(fd,&msg,datalen+hdrlen); - - if (rx_len <= sizeof(wp_tdm_api_rx_hdr_t)){ - return -EINVAL; - } - - rx_len-=sizeof(wp_tdm_api_rx_hdr_t); -#endif - return rx_len; -} - -static __inline__ int tdmv_api_writemsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen, void *databuf, unsigned short datalen) -{ - /* What do we need to do here to avoid having to do all */ - /* the memcpy's on windows and still maintain api compat with nix */ - int bsent = 0; -#if defined(__WINDOWS__) - static TX_DATA_STRUCT local_tx_data; - api_header_t *pri; - DWORD ln; - - /* Are these really not needed or used??? What about for nix?? */ - (void)hdrbuf; - (void)hdrlen; - - pri = &local_tx_data.api_header; - - pri->data_length = datalen; - memcpy(local_tx_data.data, databuf, pri->data_length); - - if (!DeviceIoControl( - fd, - IoctlWriteCommand, - (LPVOID)&local_tx_data, - (ULONG)sizeof(TX_DATA_STRUCT), - (LPVOID)&local_tx_data, - sizeof(TX_DATA_STRUCT), - (LPDWORD)(&ln), - (LPOVERLAPPED)NULL - )){ - return -1; - } - - if (local_tx_data.api_header.operation_status == SANG_STATUS_SUCCESS) { - bsent = datalen; - } -#else - struct msghdr msg; - struct iovec iov[2]; - - memset(&msg,0,sizeof(struct msghdr)); - - iov[0].iov_len = hdrlen; - iov[0].iov_base = hdrbuf; - - iov[1].iov_len = datalen; - iov[1].iov_base = databuf; - - msg.msg_iovlen = 2; - msg.msg_iov = iov; - - bsent = write(fd, &msg, datalen + hdrlen); - if (bsent > 0){ - bsent -= sizeof(wp_tdm_api_tx_hdr_t); - } -#endif - return bsent; -} - -#endif /* _SANGOMA_TDM_API_H */ - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ - diff --git a/libs/freetdm/src/include/private/uart.h b/libs/freetdm/src/include/private/uart.h deleted file mode 100644 index b1b04c09a4..0000000000 --- a/libs/freetdm/src/include/private/uart.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * uart.h - * - * Copyright (c) 2005 Robert Krten. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This module contains the manifest constants and declarations for - * the UART module. - * - * 2005 06 19 R. Krten created -*/ - -#ifndef __UART_H__ -#define __UART_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void (*bytehandler_func_t) (void *, int); -typedef void (*bithandler_func_t) (void *, int); - - -typedef struct dsp_uart_attr_s -{ - bytehandler_func_t bytehandler; /* byte handler */ - void *bytehandler_arg; /* arbitrary ID passed to bytehandler as first argument */ -} dsp_uart_attr_t; - -typedef struct -{ - dsp_uart_attr_t attr; - int have_start; /* wait for start bit to show up */ - int data; /* data buffer */ - int nbits; /* number of bits accumulated so far */ -} dsp_uart_handle_t; - -/* - * Function prototypes - * - * General calling order is: - * a) create the attributes structure (dsp_uart_attr_init) - * b) initialize fields in the attributes structure (dsp_uart_attr_set_*) - * c) create a Bell-202 handle (dsp_uart_create) - * d) feed bits through dsp_uart_bit_handler -*/ - -void dsp_uart_attr_init(dsp_uart_attr_t *attributes); - -bytehandler_func_t dsp_uart_attr_get_bytehandler(dsp_uart_attr_t *attributes, void **bytehandler_arg); -void dsp_uart_attr_set_bytehandler(dsp_uart_attr_t *attributes, bytehandler_func_t bytehandler, void *bytehandler_arg); - -dsp_uart_handle_t * dsp_uart_create(dsp_uart_attr_t *attributes); -void dsp_uart_destroy(dsp_uart_handle_t **handle); - -void dsp_uart_bit_handler(void *handle, int bit); - -#ifdef __cplusplus -} -#endif -#endif - diff --git a/libs/freetdm/src/isdn/5ESSStateNT.c b/libs/freetdm/src/isdn/5ESSStateNT.c deleted file mode 100644 index 6d38f4582e..0000000000 --- a/libs/freetdm/src/isdn/5ESSStateNT.c +++ /dev/null @@ -1,132 +0,0 @@ -/***************************************************************************** - - FileName: 5ESSStateNT.c - - Contents: AT&T 5ESS ISDN State Engine for NT (Network Mode). - - The controlling state engine for Q.931 is the state engine - on the NT side. The state engine on the TE side is a slave - of this. The TE side maintain it's own states as described in - ITU-T Q931, but will in raise conditions be overridden by - the NT side. - - License/Copyright: - - Copyright (c) 2007, Jan Vidar Berger, Case Labs, Ltd. All rights reserved. - email:janvb@caselaboratories.com - - Copyright (c) 2007, Michael Jerris. All rights reserved. - email:mike@jerris.com - - Copyright (c) 2007, Michael S. Collins, All rights reserved. - email:mcollins@fcnetwork.com - - 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 Case Labs, Ltd 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT OWNER OR CONTRIBUTORS 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 SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*****************************************************************************/ - -#include "5ESS.h" - -/***************************************************************************** - Function: ATT5ESSCreateNT - - Description: Will create the AT&T 5ESS ISDN NT as a Dialect in the stack. The first - bulk set up the message handlers, the second bulk the IE - encoders/coders, and the last bulk set up the state table. - - Parameters: i Dialect index -*****************************************************************************/ -void ATT5ESSCreateNT(L3UCHAR i) -{ - Q931SetMesProc(Q931mes_ALERTING, i, Q931ProcAlertingNT, Q931Umes_Alerting, Q931Pmes_Alerting); - Q931SetMesProc(Q931mes_CALL_PROCEEDING, i, Q931ProcCallProceedingNT, Q931Umes_CallProceeding, Q931Pmes_CallProceeding); - Q931SetMesProc(Q931mes_CONNECT, i, Q931ProcConnectNT, Q931Umes_Connect, Q931Pmes_Connect); - Q931SetMesProc(Q931mes_CONNECT_ACKNOWLEDGE, i, Q931ProcConnectAckNT, Q931Umes_ConnectAck, Q931Pmes_ConnectAck); - Q931SetMesProc(Q931mes_PROGRESS, i, Q931ProcProgressNT, Q931Umes_Progress, Q931Pmes_Progress); - Q931SetMesProc(Q931mes_SETUP, i, Q931ProcSetupNT, Q931Umes_Setup, Q931Pmes_Setup); - Q931SetMesProc(Q931mes_SETUP_ACKNOWLEDGE, i, Q931ProcSetupAckNT, Q931Umes_SetupAck, Q931Pmes_SetupAck); - Q931SetMesProc(Q931mes_RESUME, i, Q931ProcResumeNT, Q931Umes_Resume, Q931Pmes_Resume); - Q931SetMesProc(Q931mes_RESUME_ACKNOWLEDGE, i, Q931ProcResumeAckNT, Q931Umes_ResumeAck, Q931Pmes_ResumeAck); - Q931SetMesProc(Q931mes_RESUME_REJECT, i, Q931ProcResumeRejectNT, Q931Umes_ResumeReject, Q931Pmes_ResumeReject); - Q931SetMesProc(Q931mes_SUSPEND, i, Q931ProcSuspendNT, Q931Umes_Suspend, Q931Pmes_Suspend); - Q931SetMesProc(Q931mes_SUSPEND_ACKNOWLEDGE, i, Q931ProcSuspendAckNT, Q931Umes_SuspendAck, Q931Pmes_SuspendAck); - Q931SetMesProc(Q931mes_SUSPEND_REJECT, i, Q931ProcSuspendRejectNT, Q931Umes_SuspendReject, Q931Pmes_SuspendReject); - Q931SetMesProc(Q931mes_USER_INFORMATION, i, Q931ProcUserInformationNT, Q931Umes_UserInformation, Q931Pmes_UserInformation); - Q931SetMesProc(Q931mes_DISCONNECT, i, Q931ProcDisconnectNT, Q931Umes_Disconnect, Q931Pmes_Disconnect); - Q931SetMesProc(Q931mes_RELEASE, i, Q931ProcReleaseNT, Q931Umes_Release, Q931Pmes_Release); - Q931SetMesProc(Q931mes_RELEASE_COMPLETE, i, Q931ProcReleaseCompleteNT, Q931Umes_ReleaseComplete, Q931Pmes_ReleaseComplete); - Q931SetMesProc(Q931mes_RESTART, i, Q931ProcRestartNT, Q931Umes_Restart, Q931Pmes_Restart); - Q931SetMesProc(Q931mes_RESTART_ACKNOWLEDGE, i, Q931ProcRestartAckNT, Q931Umes_RestartAck, Q931Pmes_RestartAck); - Q931SetMesProc(Q931mes_CONGESTION_CONTROL, i, Q931ProcCongestionControlNT, Q931Umes_CongestionControl, Q931Pmes_CongestionControl); - Q931SetMesProc(Q931mes_INFORMATION, i, Q931ProcInformationNT, Q931Umes_Information, Q931Pmes_Information); - Q931SetMesProc(Q931mes_NOTIFY, i, Q931ProcNotifyNT, Q931Umes_Notify, Q931Pmes_Notify); - Q931SetMesProc(Q931mes_STATUS, i, Q931ProcStatusNT, Q931Umes_Status, Q931Pmes_Status); - Q931SetMesProc(Q931mes_STATUS_ENQUIRY, i, Q931ProcStatusEnquiryNT, Q931Umes_StatusEnquiry, Q931Pmes_StatusEnquiry); - Q931SetMesProc(Q931mes_SEGMENT, i, Q931ProcSegmentNT, Q931Umes_Segment, Q931Pmes_Segment); - - Q931SetMesProc(Q932mes_FACILITY, i, Q932ProcFacilityNT, Q932Umes_Facility, Q932Pmes_Facility); - Q931SetMesProc(Q932mes_HOLD, i, Q932ProcHoldNT, Q932Umes_Hold, Q932Pmes_Hold); - Q931SetMesProc(Q932mes_HOLD_ACKNOWLEDGE, i, Q932ProcHoldAckNT, Q932Umes_HoldAck, Q932Pmes_HoldAck); - Q931SetMesProc(Q932mes_HOLD_REJECT, i, Q932ProcHoldRejectNT, Q932Umes_HoldReject, Q932Pmes_HoldReject); - Q931SetMesProc(Q932mes_REGISTER, i, Q932ProcRegisterNT, Q932Umes_Register, Q932Pmes_Register); - Q931SetMesProc(Q932mes_RETRIEVE, i, Q932ProcRetrieveNT, Q932Umes_Retrieve, Q932Pmes_Retrieve); - Q931SetMesProc(Q932mes_RETRIEVE_ACKNOWLEDGE, i, Q932ProcRetrieveAckNT, Q932Umes_RetrieveAck, Q932Pmes_RetrieveAck); - Q931SetMesProc(Q932mes_RETRIEVE_REJECT, i, Q932ProcRetrieveRejectNT, Q932Umes_RetrieveReject, Q932Pmes_RetrieveReject); - - /* Set up the IE encoder/decoder handle table.*/ - Q931SetIEProc(Q931ie_SEGMENTED_MESSAGE, i, Q931Pie_Segment, Q931Uie_Segment); - Q931SetIEProc(Q931ie_BEARER_CAPABILITY, i, Q931Pie_BearerCap, Q931Uie_BearerCap); - Q931SetIEProc(Q931ie_CAUSE, i, Q931Pie_Cause, Q931Uie_Cause); - Q931SetIEProc(Q931ie_CALL_IDENTITY, i, Q931Pie_CallID, Q931Uie_CallID); - Q931SetIEProc(Q931ie_CALL_STATE, i, Q931Pie_CallState, Q931Uie_CallState); - Q931SetIEProc(Q931ie_CHANNEL_IDENTIFICATION, i, Q931Pie_ChanID, Q931Uie_ChanID); - Q931SetIEProc(Q931ie_PROGRESS_INDICATOR, i, Q931Pie_ProgInd, Q931Uie_ProgInd); - Q931SetIEProc(Q931ie_NETWORK_SPECIFIC_FACILITIES, i, Q931Pie_NetFac, Q931Uie_NetFac); - Q931SetIEProc(Q931ie_NOTIFICATION_INDICATOR, i, Q931Pie_NotifInd, Q931Uie_NotifInd); - Q931SetIEProc(Q931ie_DISPLAY, i, Q931Pie_Display, Q931Uie_Display); - Q931SetIEProc(Q931ie_DATETIME, i, Q931Pie_DateTime, Q931Uie_DateTime); - Q931SetIEProc(Q931ie_KEYPAD_FACILITY, i, Q931Pie_KeypadFac, Q931Uie_KeypadFac); - Q931SetIEProc(Q931ie_SIGNAL, i, Q931Pie_Signal, Q931Uie_Signal); - Q931SetIEProc(Q931ie_TRANSIT_DELAY_SELECTION_AND_IND, i, Q931Pie_TransNetSel, Q931Uie_TransNetSel); - Q931SetIEProc(Q931ie_CALLING_PARTY_NUMBER, i, Q931Pie_CallingNum, Q931Uie_CallingNum); - Q931SetIEProc(Q931ie_CALLING_PARTY_SUBADDRESS, i, Q931Pie_CallingSub, Q931Uie_CallingSub); - Q931SetIEProc(Q931ie_CALLED_PARTY_NUMBER, i, Q931Pie_CalledNum, Q931Uie_CalledNum); - Q931SetIEProc(Q931ie_CALLED_PARTY_SUBADDRESS, i, Q931Pie_CalledSub, Q931Uie_CalledSub); - Q931SetIEProc(Q931ie_TRANSIT_NETWORK_SELECTION, i, Q931Pie_TransNetSel, Q931Uie_TransNetSel); - Q931SetIEProc(Q931ie_RESTART_INDICATOR, i, Q931Pie_RestartInd, Q931Uie_RestartInd); - Q931SetIEProc(Q931ie_LOW_LAYER_COMPATIBILITY, i, Q931Pie_LLComp, Q931Uie_LLComp); - Q931SetIEProc(Q931ie_HIGH_LAYER_COMPATIBILITY, i, Q931Pie_HLComp, Q931Uie_HLComp); - Q931SetIEProc(Q931ie_USER_USER, i, Q931Pie_UserUser, Q931Uie_UserUser); - Q931SetIEProc(Q931ie_GENERIC_DIGITS, i, Q931Pie_GenericDigits, Q931Uie_GenericDigits); - - Q931SetIEProc(Q931ie_CONNECTED_NUMBER, i, Q931Pie_Generic, Q931Uie_Generic); - Q931SetIEProc(Q931ie_FACILITY, i, Q931Pie_Generic, Q931Uie_Generic); - - /* The following define a state machine. The point is that the Message */ - /* procs can when search this to find out if the message/state */ - /* combination is legale. If not, the proc for unexpected message apply.*/ - - /* TODO define state table here */ -} diff --git a/libs/freetdm/src/isdn/5ESSStateTE.c b/libs/freetdm/src/isdn/5ESSStateTE.c deleted file mode 100644 index 6c31df88c7..0000000000 --- a/libs/freetdm/src/isdn/5ESSStateTE.c +++ /dev/null @@ -1,291 +0,0 @@ -/***************************************************************************** - - FileName: 5ESSStateTE.c - - Contents: AT&T 5ESS ISDN State Engine for TE (User Mode). - - The controlling state engine for Q.931 is the state engine - on the NT side. The state engine on the TE side is a slave - of this. The TE side maintain it's own states as described in - ITU-T Q931, but will in raise conditions be overridden by - the NT side. - - This reference implementation uses a process per message, - meaning that each message must check call states. This - is easier for dialect maintenance as each message proc - can be replaced individually. A new TE variant only - need to copy the Q931CreateTE and replace those procs or - need to override. - - License/Copyright: - - Copyright (c) 2007, Jan Vidar Berger, Case Labs, Ltd. All rights reserved. - email:janvb@caselaboratories.com - - Copyright (c) 2007, Michael Jerris. All rights reserved. - email:mike@jerris.com - - Copyright (c) 2007, Michael S. Collins, All rights reserved. - email:mcollins@fcnetwork.com - - 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 Case Labs, Ltd 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT OWNER OR CONTRIBUTORS 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 SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*****************************************************************************/ - -#include "5ESS.h" -extern L3INT Q931L4HeaderSpace; - -/***************************************************************************** - Function: ATT5ESSCreateTE - - Description: Will create the AT&T 5ESS TE as a Dialect in the stack. The first - bulk set up the message handlers, the second bulk the IE - encoders/coders, and the last bulk set up the state table. - - Parameters: i Dialect index -*****************************************************************************/ -void ATT5ESSCreateTE(L3UCHAR i) -{ - Q931SetMesProc(Q931mes_ALERTING, i, Q931ProcAlertingTE, Q931Umes_Alerting, Q931Pmes_Alerting); - Q931SetMesProc(Q931mes_CALL_PROCEEDING, i, Q931ProcCallProceedingTE, Q931Umes_CallProceeding, Q931Pmes_CallProceeding); - Q931SetMesProc(Q931mes_CONNECT, i, ATT5ESSProc0x07TE, ATT5ESSUmes_0x07, ATT5ESSPmes_0x07); - Q931SetMesProc(Q931mes_CONNECT_ACKNOWLEDGE, i, ATT5ESSProc0x0fTE, ATT5ESSUmes_0x0f, ATT5ESSPmes_0x0f); - Q931SetMesProc(Q931mes_PROGRESS, i, Q931ProcProgressTE, Q931Umes_Progress, Q931Pmes_Progress); - Q931SetMesProc(Q931mes_SETUP, i, Q931ProcSetupTE, ATT5ESSUmes_Setup, ATT5ESSPmes_Setup); - Q931SetMesProc(Q931mes_SETUP_ACKNOWLEDGE, i, Q931ProcSetupAckTE, Q931Umes_SetupAck, Q931Pmes_SetupAck); - Q931SetMesProc(Q931mes_RESUME, i, Q931ProcResumeTE, Q931Umes_Resume, Q931Pmes_Resume); - Q931SetMesProc(Q931mes_RESUME_ACKNOWLEDGE, i, Q931ProcResumeAckTE, Q931Umes_ResumeAck, Q931Pmes_ResumeAck); - Q931SetMesProc(Q931mes_RESUME_REJECT, i, Q931ProcResumeRejectTE, Q931Umes_ResumeReject, Q931Pmes_ResumeReject); - Q931SetMesProc(Q931mes_SUSPEND, i, Q931ProcSuspendTE, Q931Umes_Suspend, Q931Pmes_Suspend); - Q931SetMesProc(Q931mes_SUSPEND_ACKNOWLEDGE, i, Q931ProcSuspendAckTE, Q931Umes_SuspendAck, Q931Pmes_SuspendAck); - Q931SetMesProc(Q931mes_SUSPEND_REJECT, i, Q931ProcSuspendRejectTE, Q931Umes_SuspendReject, Q931Pmes_SuspendReject); - Q931SetMesProc(Q931mes_USER_INFORMATION, i, Q931ProcUserInformationTE, Q931Umes_UserInformation, Q931Pmes_UserInformation); - Q931SetMesProc(Q931mes_DISCONNECT, i, Q931ProcDisconnectTE, Q931Umes_Disconnect, Q931Pmes_Disconnect); - Q931SetMesProc(Q931mes_RELEASE, i, Q931ProcReleaseTE, Q931Umes_Release, Q931Pmes_Release); - Q931SetMesProc(Q931mes_RELEASE_COMPLETE, i, Q931ProcReleaseCompleteTE, Q931Umes_ReleaseComplete, Q931Pmes_ReleaseComplete); - Q931SetMesProc(Q931mes_RESTART, i, Q931ProcRestartTE, Q931Umes_Restart, Q931Pmes_Restart); - Q931SetMesProc(Q931mes_RESTART_ACKNOWLEDGE, i, Q931ProcRestartAckTE, Q931Umes_RestartAck, Q931Pmes_RestartAck); - Q931SetMesProc(Q931mes_CONGESTION_CONTROL, i, Q931ProcCongestionControlTE, Q931Umes_CongestionControl, Q931Pmes_CongestionControl); - Q931SetMesProc(Q931mes_INFORMATION, i, Q931ProcInformationTE, Q931Umes_Information, Q931Pmes_Information); - Q931SetMesProc(Q931mes_NOTIFY, i, Q931ProcNotifyTE, Q931Umes_Notify, Q931Pmes_Notify); - Q931SetMesProc(Q931mes_STATUS, i, Q931ProcStatusTE, Q931Umes_Status, Q931Pmes_Status); - Q931SetMesProc(Q931mes_STATUS_ENQUIRY, i, Q931ProcStatusEnquiryTE, Q931Umes_StatusEnquiry, Q931Pmes_StatusEnquiry); - Q931SetMesProc(Q931mes_SEGMENT, i, Q931ProcSegmentTE, Q931Umes_Segment, Q931Pmes_Segment); - - Q931SetMesProc(Q932mes_FACILITY, i, Q932ProcFacilityTE, Q932Umes_Facility, Q932Pmes_Facility); - Q931SetMesProc(Q932mes_HOLD, i, Q932ProcHoldTE, Q932Umes_Hold, Q932Pmes_Hold); - Q931SetMesProc(Q932mes_HOLD_ACKNOWLEDGE, i, Q932ProcHoldAckTE, Q932Umes_HoldAck, Q932Pmes_HoldAck); - Q931SetMesProc(Q932mes_HOLD_REJECT, i, Q932ProcHoldRejectTE, Q932Umes_HoldReject, Q932Pmes_HoldReject); - Q931SetMesProc(Q932mes_REGISTER, i, Q932ProcRegisterTE, Q932Umes_Register, Q932Pmes_Register); - Q931SetMesProc(Q932mes_RETRIEVE, i, Q932ProcRetrieveTE, Q932Umes_Retrieve, Q932Pmes_Retrieve); - Q931SetMesProc(Q932mes_RETRIEVE_ACKNOWLEDGE, i, Q932ProcRetrieveAckTE, Q932Umes_RetrieveAck, Q932Pmes_RetrieveAck); - Q931SetMesProc(Q932mes_RETRIEVE_REJECT, i, Q932ProcRetrieveRejectTE, Q932Umes_RetrieveReject, Q932Pmes_RetrieveReject); - - /* Set up the IE encoder/decoder handle table.*/ - Q931SetIEProc(Q931ie_SEGMENTED_MESSAGE, i, Q931Pie_Segment, Q931Uie_Segment); - Q931SetIEProc(Q931ie_BEARER_CAPABILITY, i, Q931Pie_BearerCap, Q931Uie_BearerCap); - Q931SetIEProc(Q931ie_CAUSE, i, Q931Pie_Cause, Q931Uie_Cause); - Q931SetIEProc(Q931ie_CALL_IDENTITY, i, Q931Pie_CallID, Q931Uie_CallID); - Q931SetIEProc(Q931ie_CALL_STATE, i, Q931Pie_CallState, Q931Uie_CallState); - Q931SetIEProc(Q931ie_CHANGE_STATUS, i, Q931Pie_ChangeStatus, Q931Uie_ChangeStatus); - Q931SetIEProc(Q931ie_CHANNEL_IDENTIFICATION, i, Q931Pie_ChanID, Q931Uie_ChanID); - Q931SetIEProc(Q931ie_PROGRESS_INDICATOR, i, Q931Pie_ProgInd, Q931Uie_ProgInd); - Q931SetIEProc(Q931ie_NETWORK_SPECIFIC_FACILITIES, i, Q931Pie_NetFac, Q931Uie_NetFac); - Q931SetIEProc(Q931ie_NOTIFICATION_INDICATOR, i, Q931Pie_NotifInd, Q931Uie_NotifInd); - Q931SetIEProc(Q931ie_DISPLAY, i, Q931Pie_Display, Q931Uie_Display); - Q931SetIEProc(Q931ie_DATETIME, i, Q931Pie_DateTime, Q931Uie_DateTime); - Q931SetIEProc(Q931ie_KEYPAD_FACILITY, i, Q931Pie_KeypadFac, Q931Uie_KeypadFac); - Q931SetIEProc(Q931ie_SIGNAL, i, Q931Pie_Signal, Q931Uie_Signal); - Q931SetIEProc(Q931ie_TRANSIT_DELAY_SELECTION_AND_IND, i, Q931Pie_TransNetSel, Q931Uie_TransNetSel); - Q931SetIEProc(Q931ie_CALLING_PARTY_NUMBER, i, Q931Pie_CallingNum, Q931Uie_CallingNum); - Q931SetIEProc(Q931ie_CALLING_PARTY_SUBADDRESS, i, Q931Pie_CallingSub, Q931Uie_CallingSub); - Q931SetIEProc(Q931ie_CALLED_PARTY_NUMBER, i, Q931Pie_CalledNum, Q931Uie_CalledNum); - Q931SetIEProc(Q931ie_CALLED_PARTY_SUBADDRESS, i, Q931Pie_CalledSub, Q931Uie_CalledSub); - Q931SetIEProc(Q931ie_TRANSIT_NETWORK_SELECTION, i, Q931Pie_TransNetSel, Q931Uie_TransNetSel); - Q931SetIEProc(Q931ie_RESTART_INDICATOR, i, Q931Pie_RestartInd, Q931Uie_RestartInd); - Q931SetIEProc(Q931ie_LOW_LAYER_COMPATIBILITY, i, Q931Pie_LLComp, Q931Uie_LLComp); - Q931SetIEProc(Q931ie_HIGH_LAYER_COMPATIBILITY, i, Q931Pie_HLComp, Q931Uie_HLComp); - Q931SetIEProc(Q931ie_USER_USER, i, Q931Pie_UserUser, Q931Uie_UserUser); - Q931SetIEProc(Q931ie_GENERIC_DIGITS, i, Q931Pie_GenericDigits, Q931Uie_GenericDigits); - - Q931SetIEProc(Q931ie_CONNECTED_NUMBER, i, Q931Pie_Generic, Q931Uie_Generic); - Q931SetIEProc(Q931ie_FACILITY, i, Q931Pie_Generic, Q931Uie_Generic); - - /* The following define a state machine. The point is that the Message */ - /* procs can when search this to find out if the message/state */ - /* combination is legale. If not, the proc for unexpected message apply.*/ - - /* State 0 Idle */ - Q931AddStateEntry(i, Q931_U0, Q931mes_RESUME, 2); - Q931AddStateEntry(i, Q931_U0, Q931mes_SETUP, 4); - Q931AddStateEntry(i, Q931_U0, Q931mes_SETUP, 2); - Q931AddStateEntry(i, Q931_U0, Q931mes_STATUS, 4); - Q931AddStateEntry(i, Q931_U0, Q931mes_RELEASE, 4); - Q931AddStateEntry(i, Q931_U0, Q931mes_RELEASE_COMPLETE, 4); - - /* State 1 Call Initiating */ - Q931AddStateEntry(i, Q931_U1, Q931mes_DISCONNECT, 2); - Q931AddStateEntry(i, Q931_U1, Q931mes_SETUP_ACKNOWLEDGE, 4); - Q931AddStateEntry(i, Q931_U1, Q931mes_RELEASE_COMPLETE, 4); - Q931AddStateEntry(i, Q931_U1, Q931mes_CALL_PROCEEDING, 4); - Q931AddStateEntry(i, Q931_U1, Q931mes_ALERTING, 4); - Q931AddStateEntry(i, Q931_U1, Q931mes_CONNECT, 4); - - /* State 2 Overlap Sending */ - Q931AddStateEntry(i, Q931_U2, Q931mes_INFORMATION, 2); - Q931AddStateEntry(i, Q931_U2, Q931mes_CALL_PROCEEDING, 4); - Q931AddStateEntry(i, Q931_U2, Q931mes_ALERTING, 4); - Q931AddStateEntry(i, Q931_U2, Q931mes_PROGRESS, 4); - Q931AddStateEntry(i, Q931_U2, Q931mes_CONNECT, 4); - Q931AddStateEntry(i, Q931_U2, Q931mes_RELEASE, 2); - - /* State 3 Outgoing Call Proceeding */ - Q931AddStateEntry(i, Q931_U3, Q931mes_PROGRESS, 4); - Q931AddStateEntry(i, Q931_U3, Q931mes_ALERTING, 4); - Q931AddStateEntry(i, Q931_U3, Q931mes_CONNECT, 4); - Q931AddStateEntry(i, Q931_U3, Q931mes_RELEASE, 2); - - /* State 4 Call Delivered */ - Q931AddStateEntry(i, Q931_U4, Q931mes_CONNECT, 4); - - /* State 6 Call Precent */ - Q931AddStateEntry(i, Q931_U6, Q931mes_INFORMATION, 2); - Q931AddStateEntry(i, Q931_U6, Q931mes_ALERTING, 2); - Q931AddStateEntry(i, Q931_U6, Q931mes_CALL_PROCEEDING, 2); - Q931AddStateEntry(i, Q931_U6, Q931mes_CONNECT, 2); - Q931AddStateEntry(i, Q931_U6, Q931mes_RELEASE_COMPLETE, 2); - Q931AddStateEntry(i, Q931_U6, Q931mes_RELEASE, 4); - Q931AddStateEntry(i, Q931_U6, Q931mes_DISCONNECT, 4); - - /* State 7 Call Received */ - Q931AddStateEntry(i, Q931_U7, Q931mes_CONNECT, 2); - - /* State 8 Connect request */ - Q931AddStateEntry(i, Q931_U8, Q931mes_CONNECT_ACKNOWLEDGE, 4); - - /* State 9 Incoming Call Proceeding */ - Q931AddStateEntry(i, Q931_U9, Q931mes_CONNECT, 2); - Q931AddStateEntry(i, Q931_U9, Q931mes_ALERTING, 2); - Q931AddStateEntry(i, Q931_U9, Q931mes_PROGRESS, 2); - - /* State 10 Active */ - Q931AddStateEntry(i, Q931_U10, Q931mes_SUSPEND, 2); - Q931AddStateEntry(i, Q931_U10, Q931mes_NOTIFY, 4); - Q931AddStateEntry(i, Q931_U10, Q931mes_NOTIFY, 2); - - /* State 11 Disconnect Request */ - Q931AddStateEntry(i, Q931_U11, Q931mes_RELEASE, 4); - Q931AddStateEntry(i, Q931_U11, Q931mes_DISCONNECT, 4); - Q931AddStateEntry(i, Q931_U11, Q931mes_NOTIFY, 4); - - /* State 12 Disconnect Ind */ - Q931AddStateEntry(i, Q931_U12, Q931mes_RELEASE, 4); - Q931AddStateEntry(i, Q931_U12, Q931mes_RELEASE, 2); - - /* State 15 Suspend Request */ - Q931AddStateEntry(i, Q931_U15, Q931mes_SUSPEND_ACKNOWLEDGE, 4); - Q931AddStateEntry(i, Q931_U15, Q931mes_SUSPEND_REJECT, 4); - Q931AddStateEntry(i, Q931_U15, Q931mes_DISCONNECT, 4); - Q931AddStateEntry(i, Q931_U15, Q931mes_RELEASE, 4); - -/* TODO - Q931AddStateEntry(i, Q931_U17, - Q931AddStateEntry(i, Q931_U19, - Q931AddStateEntry(i, Q931_U25, -*/ -} - -/***************************************************************************** - - Function: ATT5ESSProc0x0fTE - -*****************************************************************************/ -L3INT ATT5ESSProc0x0fTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - if (pMes->ProtDisc == 8) { - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here*/ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - } - if (iFrom == 4) { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom ==2) { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - - if (pMes->ProtDisc == 3 && pTrunk->autoServiceAck) { - printf("autoServiceAck is on, responding to Service Req from network...\n"); - Q931AckService(pTrunk, buf); - } - } - return ret; - -} - -/***************************************************************************** - - Function: ATT5ESSProc0x07TE - -*****************************************************************************/ -L3INT ATT5ESSProc0x07TE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - if (pMes->ProtDisc == 8) { - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here*/ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - } - if (iFrom == 4) { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; - -} diff --git a/libs/freetdm/src/isdn/5ESSmes.c b/libs/freetdm/src/isdn/5ESSmes.c deleted file mode 100644 index 9d7e3b9030..0000000000 --- a/libs/freetdm/src/isdn/5ESSmes.c +++ /dev/null @@ -1,361 +0,0 @@ -/***************************************************************************** - - FileName: 5ESSmes.c - - Contents: Pack/Unpack functions. These functions will unpack a 5ESS ISDN - message from the bit packed original format into structs - that contains variables sized by the user. It will also pack - the struct back into a Q.931 message as required. - - See 5ESS.h for description. - - License/Copyright: - - Copyright (c) 2007, Jan Vidar Berger, Case Labs, Ltd. All rights reserved. - email:janvb@caselaboratories.com - - Copyright (c) 2007, Michael Jerris. All rights reserved. - email:mike@jerris.com - - Copyright (c) 2007, Michael S. Collins, All rights reserved. - email:mcollins@fcnetwork.com - - 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 Case Labs, Ltd 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT OWNER OR CONTRIBUTORS 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 SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - -*****************************************************************************/ - -#include "5ESS.h" - -/***************************************************************************** - - Function: ATT5ESSUmes_Setup - -*****************************************************************************/ -L3INT ATT5ESSUmes_Setup(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3INT ir = 0; - L3INT OOff = 0; - L3INT rc = Q931E_NO_ERROR; - L3UCHAR last_codeset = 0, codeset = 0; - L3UCHAR shift_nolock = 1; - - while (IOff < Size) { - - if (shift_nolock) { - codeset = last_codeset; - } - - if ((IBuf[IOff] & 0xF0) == Q931ie_SHIFT) { - shift_nolock = (IBuf[IOff] & 0x08); - if (shift_nolock) { - last_codeset = codeset; - } - codeset = ((IBuf[IOff] & 0x07)); - IOff++; - } - - if (codeset == 0) { - switch (IBuf[IOff]) - { - case Q931ie_SENDING_COMPLETE: - case Q931ie_BEARER_CAPABILITY: - case Q931ie_CHANNEL_IDENTIFICATION: - case Q931ie_PROGRESS_INDICATOR: - case Q931ie_NETWORK_SPECIFIC_FACILITIES: - case Q931ie_DISPLAY: - case Q931ie_DATETIME: - case Q931ie_KEYPAD_FACILITY: - case Q931ie_SIGNAL: - case Q931ie_CALLING_PARTY_NUMBER: - case Q931ie_CALLING_PARTY_SUBADDRESS: - case Q931ie_CALLED_PARTY_NUMBER: - case Q931ie_CALLED_PARTY_SUBADDRESS: - case Q931ie_TRANSIT_NETWORK_SELECTION: - case Q931ie_LOW_LAYER_COMPATIBILITY: - case Q931ie_HIGH_LAYER_COMPATIBILITY: - case Q931ie_FACILITY: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if (rc != Q931E_NO_ERROR) - return rc; - break; - case Q931ie_REPEAT_INDICATOR: - if (ir < 2) { - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - ir++; - } else { - return Q931E_ILLEGAL_IE; - } - break; - default: - return Q931E_ILLEGAL_IE; - break; - } - } else if (codeset == 6) { - switch (IBuf[IOff]) - { - case Q931ie_GENERIC_DIGITS: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if (rc != Q931E_NO_ERROR) - return rc; - break; - default: - return Q931E_ILLEGAL_IE; - break; - } - } else if (codeset == 7) { - switch (IBuf[IOff]) - { - case Q931ie_DISPLAY: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if (rc != Q931E_NO_ERROR) - return rc; - break; - default: - return Q931E_ILLEGAL_IE; - break; - } - } else { - return Q931E_ILLEGAL_IE; - } - } - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: ATT5ESSPmes_Setup - - Decription: Pack a Q931mes_Generic into a real Q.931 message. The user will - set up a SETUP message and issue this to the stack where it - is processed by Q931ProcSetup that processes and validates - it before it actually sends it out. This function is called - to compute the real Q.931 message. - - Parameters: IBuf[IN] Ptr to un-packed struct - ISize[IN] Size of input buffer (unpacked message). - OBuf[OUT] Ptr to packed 'octet' wise message. - OSize[OUT] Size of packed message. - - Called By: Q931ProcSetup - -*****************************************************************************/ -L3INT ATT5ESSPmes_Setup(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - L3INT rc = Q931E_NO_ERROR; - Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; - L3INT Octet = 0; - - /* Q931 Message Header */ - Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); - - /* Sending Complete */ - if (Q931IsIEPresent(pMes->SendComplete)) { - OBuf[Octet++] = (L3UCHAR)(pMes->SendComplete & 0x00ff); - } - - /* Repeat Indicator */ - if (Q931IsIEPresent(pMes->RepeatInd)) { - OBuf[Octet++] = (L3UCHAR)(pMes->RepeatInd & 0x00ff); - } - - /* Bearer capability */ - if (Q931IsIEPresent(pMes->BearerCap)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_BEARER_CAPABILITY](pTrunk, Q931GetIEPtr(pMes->BearerCap,pMes->buf), OBuf, &Octet))!=0) - return rc; - } else { - rc = Q931E_BEARERCAP; - } - - /* Channel Identification */ - if (Q931IsIEPresent(pMes->ChanID)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CHANNEL_IDENTIFICATION](pTrunk, Q931GetIEPtr(pMes->ChanID,pMes->buf), OBuf, &Octet))!=0) - return rc; - } - - /* Progress indicator */ - if (Q931IsIEPresent(pMes->ProgInd)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_PROGRESS_INDICATOR](pTrunk, Q931GetIEPtr(pMes->ProgInd,pMes->buf), OBuf, &Octet))!=0) - return rc; - } - - /* Network specific facilities */ - if (Q931IsIEPresent(pMes->NetFac)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_NETWORK_SPECIFIC_FACILITIES](pTrunk, Q931GetIEPtr(pMes->NetFac,pMes->buf), OBuf, &Octet))!=0) - return rc; - } - - /* Display */ - if (Q931IsIEPresent(pMes->Display)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet))!=0) - return rc; - } - - /* Date/Time */ - if (Q931IsIEPresent(pMes->DateTime)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DATETIME](pTrunk, Q931GetIEPtr(pMes->DateTime,pMes->buf), OBuf, &Octet))!=0) - return rc; - } - - /* Keypad Facility */ - if (Q931IsIEPresent(pMes->KeypadFac)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_KEYPAD_FACILITY](pTrunk, Q931GetIEPtr(pMes->KeypadFac,pMes->buf), OBuf, &Octet))!=0) - return rc; - } - - /* Signal */ - if (Q931IsIEPresent(pMes->Signal)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_SIGNAL](pTrunk, Q931GetIEPtr(pMes->Signal,pMes->buf), OBuf, &Octet))!=0) - return rc; - } - - /* Calling Party Number */ - if (Q931IsIEPresent(pMes->CallingNum)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALLING_PARTY_NUMBER](pTrunk, Q931GetIEPtr(pMes->CallingNum,pMes->buf), OBuf, &Octet))!=0) - return rc; - } - - /* Calling Party Subaddress */ - if (Q931IsIEPresent(pMes->CallingSub)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALLING_PARTY_SUBADDRESS](pTrunk, Q931GetIEPtr(pMes->CallingSub,pMes->buf), OBuf, &Octet))!=0) - return rc; - } - - /* Called Party number */ - if (Q931IsIEPresent(pMes->CalledNum)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALLED_PARTY_NUMBER](pTrunk, Q931GetIEPtr(pMes->CalledNum,pMes->buf), OBuf, &Octet))!=0) - return rc; - } - - /* Called party subaddress */ - if (Q931IsIEPresent(pMes->CalledSub)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALLED_PARTY_SUBADDRESS](pTrunk, Q931GetIEPtr(pMes->CalledSub,pMes->buf), OBuf, &Octet))!=0) - return rc; - } - - /* Transit network selection */ - if (Q931IsIEPresent(pMes->TransNetSel)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_TRANSIT_NETWORK_SELECTION](pTrunk, Q931GetIEPtr(pMes->TransNetSel,pMes->buf), OBuf, &Octet))!=0) - return rc; - } - - /* Repeat Indicator */ - if (Q931IsIEPresent(pMes->LLRepeatInd)) { - rc = Q931E_UNKNOWN_IE;/* TODO */ - } - - /* Low Layer Compatibility */ - if (Q931IsIEPresent(pMes->LLComp)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_LOW_LAYER_COMPATIBILITY](pTrunk, Q931GetIEPtr(pMes->LLComp,pMes->buf), OBuf, &Octet))!=0) - return rc; - } - - /* High Layer Compatibility */ - if (Q931IsIEPresent(pMes->HLComp)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_HIGH_LAYER_COMPATIBILITY](pTrunk, Q931GetIEPtr(pMes->HLComp,pMes->buf), OBuf, &Octet))!=0) - return rc; - } - - *OSize = Octet; - return rc; -} - - -/***************************************************************************** - - Function: ATT5ESSUmes_0x0f - -*****************************************************************************/ -L3INT ATT5ESSUmes_0x0f(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - if (mes->ProtDisc == 8) { - return Q931Umes_ConnectAck(pTrunk, IBuf, mes, IOff, Size); - } - - if (mes->ProtDisc == 3) { - return Q931Umes_Service(pTrunk, IBuf, mes, IOff, Size); - } - - return Q931E_UNKNOWN_MESSAGE; -} - -/***************************************************************************** - - Function: ATT5ESSPmes_0x0f - -*****************************************************************************/ -L3INT ATT5ESSPmes_0x0f(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - Q931mes_Generic *mes = (Q931mes_Generic *)IBuf; - - if (mes->ProtDisc == 8) { - return Q931Pmes_ConnectAck(pTrunk, IBuf, ISize, OBuf, OSize); - } - - if (mes->ProtDisc == 3) { - return Q931Pmes_Service(pTrunk, IBuf, ISize, OBuf, OSize); - } - - return Q931E_UNKNOWN_MESSAGE; -} - -/***************************************************************************** - - Function: ATT5ESSUmes_0x07 - -*****************************************************************************/ -L3INT ATT5ESSUmes_0x07(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - if (mes->ProtDisc == 8) { - return Q931Umes_Connect(pTrunk, IBuf, mes, IOff, Size); - } - - if (mes->ProtDisc == 3) { - return Q931Umes_ServiceAck(pTrunk, IBuf, mes, IOff, Size); - } - - return Q931E_UNKNOWN_MESSAGE; -} - -/***************************************************************************** - - Function: ATT5ESSPmes_0x07 - -*****************************************************************************/ -L3INT ATT5ESSPmes_0x07(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - Q931mes_Generic *mes = (Q931mes_Generic *)IBuf; - - if (mes->ProtDisc == 8) { - return Q931Pmes_Connect(pTrunk, IBuf, ISize, OBuf, OSize); - } - - if (mes->ProtDisc == 3) { - return Q931Pmes_ServiceAck(pTrunk, IBuf, ISize, OBuf, OSize); - } - - return Q931E_UNKNOWN_MESSAGE; -} diff --git a/libs/freetdm/src/isdn/DMSStateNT.c b/libs/freetdm/src/isdn/DMSStateNT.c deleted file mode 100644 index e8814ba8ef..0000000000 --- a/libs/freetdm/src/isdn/DMSStateNT.c +++ /dev/null @@ -1,126 +0,0 @@ -/***************************************************************************** - - FileName: DMSStateNT.c - - Contents: DMS-100 ISDN State Engine for NT (Network Mode). - - The controlling state engine for Q.931 is the state engine - on the NT side. The state engine on the TE side is a slave - of this. The TE side maintain it's own states as described in - ITU-T Q931, but will in raise conditions be overridden by - the NT side. - - License/Copyright: - - Copyright (c) 2007, Jan Vidar Berger, Case Labs, Ltd. All rights reserved. - email:janvb@caselaboratories.com - - Copyright (c) 2007, Michael Jerris. All rights reserved. - email:mike@jerris.com - - 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 Case Labs, Ltd 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT OWNER OR CONTRIBUTORS 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 SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*****************************************************************************/ - -#include "DMS.h" - -/***************************************************************************** - Function: DMSCreateNT - - Description: Will create the National ISDN NT as a Dialect in the stack. The first - bulk set up the message handlers, the second bulk the IE - encoders/coders, and the last bulk set up the state table. - - Parameters: i Dialect index -*****************************************************************************/ -void DMSCreateNT(L3UCHAR i) -{ - Q931SetMesProc(Q931mes_ALERTING, i, Q931ProcAlertingNT, Q931Umes_Alerting, Q931Pmes_Alerting); - Q931SetMesProc(Q931mes_CALL_PROCEEDING, i, Q931ProcCallProceedingNT, Q931Umes_CallProceeding, Q931Pmes_CallProceeding); - Q931SetMesProc(Q931mes_CONNECT, i, Q931ProcConnectNT, Q931Umes_Connect, Q931Pmes_Connect); - Q931SetMesProc(Q931mes_CONNECT_ACKNOWLEDGE, i, Q931ProcConnectAckNT, Q931Umes_ConnectAck, Q931Pmes_ConnectAck); - Q931SetMesProc(Q931mes_PROGRESS, i, Q931ProcProgressNT, Q931Umes_Progress, Q931Pmes_Progress); - Q931SetMesProc(Q931mes_SETUP, i, Q931ProcSetupNT, DMSUmes_Setup, DMSPmes_Setup); - Q931SetMesProc(Q931mes_SETUP_ACKNOWLEDGE, i, Q931ProcSetupAckNT, Q931Umes_SetupAck, Q931Pmes_SetupAck); - Q931SetMesProc(Q931mes_RESUME, i, Q931ProcResumeNT, Q931Umes_Resume, Q931Pmes_Resume); - Q931SetMesProc(Q931mes_RESUME_ACKNOWLEDGE, i, Q931ProcResumeAckNT, Q931Umes_ResumeAck, Q931Pmes_ResumeAck); - Q931SetMesProc(Q931mes_RESUME_REJECT, i, Q931ProcResumeRejectNT, Q931Umes_ResumeReject, Q931Pmes_ResumeReject); - Q931SetMesProc(Q931mes_SUSPEND, i, Q931ProcSuspendNT, Q931Umes_Suspend, Q931Pmes_Suspend); - Q931SetMesProc(Q931mes_SUSPEND_ACKNOWLEDGE, i, Q931ProcSuspendAckNT, Q931Umes_SuspendAck, Q931Pmes_SuspendAck); - Q931SetMesProc(Q931mes_SUSPEND_REJECT, i, Q931ProcSuspendRejectNT, Q931Umes_SuspendReject, Q931Pmes_SuspendReject); - Q931SetMesProc(Q931mes_USER_INFORMATION, i, Q931ProcUserInformationNT, Q931Umes_UserInformation, Q931Pmes_UserInformation); - Q931SetMesProc(Q931mes_DISCONNECT, i, Q931ProcDisconnectNT, Q931Umes_Disconnect, Q931Pmes_Disconnect); - Q931SetMesProc(Q931mes_RELEASE, i, Q931ProcReleaseNT, Q931Umes_Release, Q931Pmes_Release); - Q931SetMesProc(Q931mes_RELEASE_COMPLETE, i, Q931ProcReleaseCompleteNT, Q931Umes_ReleaseComplete, Q931Pmes_ReleaseComplete); - Q931SetMesProc(Q931mes_RESTART, i, Q931ProcRestartNT, Q931Umes_Restart, Q931Pmes_Restart); - Q931SetMesProc(Q931mes_RESTART_ACKNOWLEDGE, i, Q931ProcRestartAckNT, Q931Umes_RestartAck, Q931Pmes_RestartAck); - Q931SetMesProc(Q931mes_CONGESTION_CONTROL, i, Q931ProcCongestionControlNT, Q931Umes_CongestionControl, Q931Pmes_CongestionControl); - Q931SetMesProc(Q931mes_INFORMATION, i, Q931ProcInformationNT, Q931Umes_Information, Q931Pmes_Information); - Q931SetMesProc(Q931mes_NOTIFY, i, Q931ProcNotifyNT, Q931Umes_Notify, Q931Pmes_Notify); - Q931SetMesProc(Q931mes_STATUS, i, Q931ProcStatusNT, Q931Umes_Status, Q931Pmes_Status); - Q931SetMesProc(Q931mes_STATUS_ENQUIRY, i, Q931ProcStatusEnquiryNT, Q931Umes_StatusEnquiry, Q931Pmes_StatusEnquiry); - Q931SetMesProc(Q931mes_SEGMENT, i, Q931ProcSegmentNT, Q931Umes_Segment, Q931Pmes_Segment); - - Q931SetMesProc(Q932mes_FACILITY, i, Q932ProcFacilityNT, Q932Umes_Facility, Q932Pmes_Facility); - Q931SetMesProc(Q932mes_HOLD, i, Q932ProcHoldNT, Q932Umes_Hold, Q932Pmes_Hold); - Q931SetMesProc(Q932mes_HOLD_ACKNOWLEDGE, i, Q932ProcHoldAckNT, Q932Umes_HoldAck, Q932Pmes_HoldAck); - Q931SetMesProc(Q932mes_HOLD_REJECT, i, Q932ProcHoldRejectNT, Q932Umes_HoldReject, Q932Pmes_HoldReject); - Q931SetMesProc(Q932mes_REGISTER, i, Q932ProcRegisterNT, Q932Umes_Register, Q932Pmes_Register); - Q931SetMesProc(Q932mes_RETRIEVE, i, Q932ProcRetrieveNT, Q932Umes_Retrieve, Q932Pmes_Retrieve); - Q931SetMesProc(Q932mes_RETRIEVE_ACKNOWLEDGE, i, Q932ProcRetrieveAckNT, Q932Umes_RetrieveAck, Q932Pmes_RetrieveAck); - Q931SetMesProc(Q932mes_RETRIEVE_REJECT, i, Q932ProcRetrieveRejectNT, Q932Umes_RetrieveReject, Q932Pmes_RetrieveReject); - - /* Set up the IE encoder/decoder handle table.*/ - Q931SetIEProc(Q931ie_SEGMENTED_MESSAGE, i, Q931Pie_Segment, Q931Uie_Segment); - Q931SetIEProc(Q931ie_BEARER_CAPABILITY, i, Q931Pie_BearerCap, Q931Uie_BearerCap); - Q931SetIEProc(Q931ie_CAUSE, i, Q931Pie_Cause, Q931Uie_Cause); - Q931SetIEProc(Q931ie_CALL_IDENTITY, i, Q931Pie_CallID, Q931Uie_CallID); - Q931SetIEProc(Q931ie_CALL_STATE, i, Q931Pie_CallState, Q931Uie_CallState); - Q931SetIEProc(Q931ie_CHANNEL_IDENTIFICATION, i, Q931Pie_ChanID, Q931Uie_ChanID); - Q931SetIEProc(Q931ie_PROGRESS_INDICATOR, i, Q931Pie_ProgInd, Q931Uie_ProgInd); - Q931SetIEProc(Q931ie_NETWORK_SPECIFIC_FACILITIES, i, Q931Pie_NetFac, Q931Uie_NetFac); - Q931SetIEProc(Q931ie_NOTIFICATION_INDICATOR, i, Q931Pie_NotifInd, Q931Uie_NotifInd); - Q931SetIEProc(Q931ie_DISPLAY, i, Q931Pie_Display, Q931Uie_Display); - Q931SetIEProc(Q931ie_DATETIME, i, Q931Pie_DateTime, Q931Uie_DateTime); - Q931SetIEProc(Q931ie_KEYPAD_FACILITY, i, Q931Pie_KeypadFac, Q931Uie_KeypadFac); - Q931SetIEProc(Q931ie_SIGNAL, i, Q931Pie_Signal, Q931Uie_Signal); - Q931SetIEProc(Q931ie_TRANSIT_DELAY_SELECTION_AND_IND, i, Q931Pie_TransNetSel, Q931Uie_TransNetSel); - Q931SetIEProc(Q931ie_CALLING_PARTY_NUMBER, i, Q931Pie_CallingNum, Q931Uie_CallingNum); - Q931SetIEProc(Q931ie_CALLING_PARTY_SUBADDRESS, i, Q931Pie_CallingSub, Q931Uie_CallingSub); - Q931SetIEProc(Q931ie_CALLED_PARTY_NUMBER, i, Q931Pie_CalledNum, Q931Uie_CalledNum); - Q931SetIEProc(Q931ie_CALLED_PARTY_SUBADDRESS, i, Q931Pie_CalledSub, Q931Uie_CalledSub); - Q931SetIEProc(Q931ie_TRANSIT_NETWORK_SELECTION, i, Q931Pie_TransNetSel, Q931Uie_TransNetSel); - Q931SetIEProc(Q931ie_RESTART_INDICATOR, i, Q931Pie_RestartInd, Q931Uie_RestartInd); - Q931SetIEProc(Q931ie_LOW_LAYER_COMPATIBILITY, i, Q931Pie_LLComp, Q931Uie_LLComp); - Q931SetIEProc(Q931ie_HIGH_LAYER_COMPATIBILITY, i, Q931Pie_HLComp, Q931Uie_HLComp); - Q931SetIEProc(Q931ie_USER_USER, i, Q931Pie_UserUser, Q931Uie_UserUser); - Q931SetIEProc(Q931ie_GENERIC_DIGITS, i, Q931Pie_GenericDigits, Q931Uie_GenericDigits); - - /* The following define a state machine. The point is that the Message */ - /* procs can when search this to find out if the message/state */ - /* combination is legale. If not, the proc for unexpected message apply.*/ - - /* TODO define state table here */ -} diff --git a/libs/freetdm/src/isdn/DMSStateTE.c b/libs/freetdm/src/isdn/DMSStateTE.c deleted file mode 100644 index cb740d3c2f..0000000000 --- a/libs/freetdm/src/isdn/DMSStateTE.c +++ /dev/null @@ -1,284 +0,0 @@ -/***************************************************************************** - - FileName: DMSStateTE.c - - Contents: DMS-100 ISDN State Engine for TE (User Mode). - - The controlling state engine for Q.931 is the state engine - on the NT side. The state engine on the TE side is a slave - of this. The TE side maintain it's own states as described in - ITU-T Q931, but will in raise conditions be overridden by - the NT side. - - This reference implementation uses a process per message, - meaning that each message must check call states. This - is easier for dialect maintenance as each message proc - can be replaced individually. A new TE variant only - need to copy the Q931CreateTE and replace those procs or - need to override. - - License/Copyright: - - Copyright (c) 2007, Jan Vidar Berger, Case Labs, Ltd. All rights reserved. - email:janvb@caselaboratories.com - - Copyright (c) 2007, Michael Jerris. All rights reserved. - email:mike@jerris.com - - 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 Case Labs, Ltd 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT OWNER OR CONTRIBUTORS 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 SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*****************************************************************************/ - -#include "DMS.h" -extern L3INT Q931L4HeaderSpace; - -/***************************************************************************** - Function: DMSCreateTE - - Description: Will create the National TE as a Dialect in the stack. The first - bulk set up the message handlers, the second bulk the IE - encoders/coders, and the last bulk set up the state table. - - Parameters: i Dialect index -*****************************************************************************/ -void DMSCreateTE(L3UCHAR i) -{ - Q931SetMesProc(Q931mes_ALERTING, i, Q931ProcAlertingTE, Q931Umes_Alerting, Q931Pmes_Alerting); - Q931SetMesProc(Q931mes_CALL_PROCEEDING, i, Q931ProcCallProceedingTE, Q931Umes_CallProceeding, Q931Pmes_CallProceeding); - Q931SetMesProc(Q931mes_CONNECT, i, DMSProc0x07TE, DMSUmes_0x07, DMSPmes_0x07); - Q931SetMesProc(Q931mes_CONNECT_ACKNOWLEDGE, i, DMSProc0x0fTE, DMSUmes_0x0f, DMSPmes_0x0f); - Q931SetMesProc(Q931mes_PROGRESS, i, Q931ProcProgressTE, Q931Umes_Progress, Q931Pmes_Progress); - Q931SetMesProc(Q931mes_SETUP, i, Q931ProcSetupTE, DMSUmes_Setup, DMSPmes_Setup); - Q931SetMesProc(Q931mes_SETUP_ACKNOWLEDGE, i, Q931ProcSetupAckTE, Q931Umes_SetupAck, Q931Pmes_SetupAck); - Q931SetMesProc(Q931mes_RESUME, i, Q931ProcResumeTE, Q931Umes_Resume, Q931Pmes_Resume); - Q931SetMesProc(Q931mes_RESUME_ACKNOWLEDGE, i, Q931ProcResumeAckTE, Q931Umes_ResumeAck, Q931Pmes_ResumeAck); - Q931SetMesProc(Q931mes_RESUME_REJECT, i, Q931ProcResumeRejectTE, Q931Umes_ResumeReject, Q931Pmes_ResumeReject); - Q931SetMesProc(Q931mes_SUSPEND, i, Q931ProcSuspendTE, Q931Umes_Suspend, Q931Pmes_Suspend); - Q931SetMesProc(Q931mes_SUSPEND_ACKNOWLEDGE, i, Q931ProcSuspendAckTE, Q931Umes_SuspendAck, Q931Pmes_SuspendAck); - Q931SetMesProc(Q931mes_SUSPEND_REJECT, i, Q931ProcSuspendRejectTE, Q931Umes_SuspendReject, Q931Pmes_SuspendReject); - Q931SetMesProc(Q931mes_USER_INFORMATION, i, Q931ProcUserInformationTE, Q931Umes_UserInformation, Q931Pmes_UserInformation); - Q931SetMesProc(Q931mes_DISCONNECT, i, Q931ProcDisconnectTE, Q931Umes_Disconnect, Q931Pmes_Disconnect); - Q931SetMesProc(Q931mes_RELEASE, i, Q931ProcReleaseTE, Q931Umes_Release, Q931Pmes_Release); - Q931SetMesProc(Q931mes_RELEASE_COMPLETE, i, Q931ProcReleaseCompleteTE, Q931Umes_ReleaseComplete, Q931Pmes_ReleaseComplete); - Q931SetMesProc(Q931mes_RESTART, i, Q931ProcRestartTE, Q931Umes_Restart, Q931Pmes_Restart); - Q931SetMesProc(Q931mes_RESTART_ACKNOWLEDGE, i, Q931ProcRestartAckTE, Q931Umes_RestartAck, Q931Pmes_RestartAck); - Q931SetMesProc(Q931mes_CONGESTION_CONTROL, i, Q931ProcCongestionControlTE, Q931Umes_CongestionControl, Q931Pmes_CongestionControl); - Q931SetMesProc(Q931mes_INFORMATION, i, Q931ProcInformationTE, Q931Umes_Information, Q931Pmes_Information); - Q931SetMesProc(Q931mes_NOTIFY, i, Q931ProcNotifyTE, Q931Umes_Notify, Q931Pmes_Notify); - Q931SetMesProc(Q931mes_STATUS, i, Q931ProcStatusTE, Q931Umes_Status, Q931Pmes_Status); - Q931SetMesProc(Q931mes_STATUS_ENQUIRY, i, Q931ProcStatusEnquiryTE, Q931Umes_StatusEnquiry, Q931Pmes_StatusEnquiry); - Q931SetMesProc(Q931mes_SEGMENT, i, Q931ProcSegmentTE, Q931Umes_Segment, Q931Pmes_Segment); - - Q931SetMesProc(Q932mes_FACILITY, i, Q932ProcFacilityTE, Q932Umes_Facility, Q932Pmes_Facility); - Q931SetMesProc(Q932mes_HOLD, i, Q932ProcHoldTE, Q932Umes_Hold, Q932Pmes_Hold); - Q931SetMesProc(Q932mes_HOLD_ACKNOWLEDGE, i, Q932ProcHoldAckTE, Q932Umes_HoldAck, Q932Pmes_HoldAck); - Q931SetMesProc(Q932mes_HOLD_REJECT, i, Q932ProcHoldRejectTE, Q932Umes_HoldReject, Q932Pmes_HoldReject); - Q931SetMesProc(Q932mes_REGISTER, i, Q932ProcRegisterTE, Q932Umes_Register, Q932Pmes_Register); - Q931SetMesProc(Q932mes_RETRIEVE, i, Q932ProcRetrieveTE, Q932Umes_Retrieve, Q932Pmes_Retrieve); - Q931SetMesProc(Q932mes_RETRIEVE_ACKNOWLEDGE, i, Q932ProcRetrieveAckTE, Q932Umes_RetrieveAck, Q932Pmes_RetrieveAck); - Q931SetMesProc(Q932mes_RETRIEVE_REJECT, i, Q932ProcRetrieveRejectTE, Q932Umes_RetrieveReject, Q932Pmes_RetrieveReject); - - /* Set up the IE encoder/decoder handle table.*/ - Q931SetIEProc(Q931ie_SEGMENTED_MESSAGE, i, Q931Pie_Segment, Q931Uie_Segment); - Q931SetIEProc(Q931ie_BEARER_CAPABILITY, i, Q931Pie_BearerCap, Q931Uie_BearerCap); - Q931SetIEProc(Q931ie_CAUSE, i, Q931Pie_Cause, Q931Uie_Cause); - Q931SetIEProc(Q931ie_CALL_IDENTITY, i, Q931Pie_CallID, Q931Uie_CallID); - Q931SetIEProc(Q931ie_CALL_STATE, i, Q931Pie_CallState, Q931Uie_CallState); - Q931SetIEProc(Q931ie_CHANGE_STATUS, i, Q931Pie_ChangeStatus, Q931Uie_ChangeStatus); - Q931SetIEProc(Q931ie_CHANNEL_IDENTIFICATION, i, Q931Pie_ChanID, Q931Uie_ChanID); - Q931SetIEProc(Q931ie_PROGRESS_INDICATOR, i, Q931Pie_ProgInd, Q931Uie_ProgInd); - Q931SetIEProc(Q931ie_NETWORK_SPECIFIC_FACILITIES, i, Q931Pie_NetFac, Q931Uie_NetFac); - Q931SetIEProc(Q931ie_NOTIFICATION_INDICATOR, i, Q931Pie_NotifInd, Q931Uie_NotifInd); - Q931SetIEProc(Q931ie_DISPLAY, i, Q931Pie_Display, Q931Uie_Display); - Q931SetIEProc(Q931ie_DATETIME, i, Q931Pie_DateTime, Q931Uie_DateTime); - Q931SetIEProc(Q931ie_KEYPAD_FACILITY, i, Q931Pie_KeypadFac, Q931Uie_KeypadFac); - Q931SetIEProc(Q931ie_SIGNAL, i, Q931Pie_Signal, Q931Uie_Signal); - Q931SetIEProc(Q931ie_TRANSIT_DELAY_SELECTION_AND_IND, i, Q931Pie_TransNetSel, Q931Uie_TransNetSel); - Q931SetIEProc(Q931ie_CALLING_PARTY_NUMBER, i, Q931Pie_CallingNum, Q931Uie_CallingNum); - Q931SetIEProc(Q931ie_CALLING_PARTY_SUBADDRESS, i, Q931Pie_CallingSub, Q931Uie_CallingSub); - Q931SetIEProc(Q931ie_CALLED_PARTY_NUMBER, i, Q931Pie_CalledNum, Q931Uie_CalledNum); - Q931SetIEProc(Q931ie_CALLED_PARTY_SUBADDRESS, i, Q931Pie_CalledSub, Q931Uie_CalledSub); - Q931SetIEProc(Q931ie_TRANSIT_NETWORK_SELECTION, i, Q931Pie_TransNetSel, Q931Uie_TransNetSel); - Q931SetIEProc(Q931ie_RESTART_INDICATOR, i, Q931Pie_RestartInd, Q931Uie_RestartInd); - Q931SetIEProc(Q931ie_LOW_LAYER_COMPATIBILITY, i, Q931Pie_LLComp, Q931Uie_LLComp); - Q931SetIEProc(Q931ie_HIGH_LAYER_COMPATIBILITY, i, Q931Pie_HLComp, Q931Uie_HLComp); - Q931SetIEProc(Q931ie_USER_USER, i, Q931Pie_UserUser, Q931Uie_UserUser); - Q931SetIEProc(Q931ie_GENERIC_DIGITS, i, Q931Pie_GenericDigits, Q931Uie_GenericDigits); - - /* The following define a state machine. The point is that the Message */ - /* procs can when search this to find out if the message/state */ - /* combination is legale. If not, the proc for unexpected message apply.*/ - - /* State 0 Idle */ - Q931AddStateEntry(i, Q931_U0, Q931mes_RESUME, 2); - Q931AddStateEntry(i, Q931_U0, Q931mes_SETUP, 4); - Q931AddStateEntry(i, Q931_U0, Q931mes_SETUP, 2); - Q931AddStateEntry(i, Q931_U0, Q931mes_STATUS, 4); - Q931AddStateEntry(i, Q931_U0, Q931mes_RELEASE, 4); - Q931AddStateEntry(i, Q931_U0, Q931mes_RELEASE_COMPLETE, 4); - - /* State 1 Call Initiating */ - Q931AddStateEntry(i, Q931_U1, Q931mes_DISCONNECT, 2); - Q931AddStateEntry(i, Q931_U1, Q931mes_SETUP_ACKNOWLEDGE, 4); - Q931AddStateEntry(i, Q931_U1, Q931mes_RELEASE_COMPLETE, 4); - Q931AddStateEntry(i, Q931_U1, Q931mes_CALL_PROCEEDING, 4); - Q931AddStateEntry(i, Q931_U1, Q931mes_ALERTING, 4); - Q931AddStateEntry(i, Q931_U1, Q931mes_CONNECT, 4); - - /* State 2 Overlap Sending */ - Q931AddStateEntry(i, Q931_U2, Q931mes_INFORMATION, 2); - Q931AddStateEntry(i, Q931_U2, Q931mes_CALL_PROCEEDING, 4); - Q931AddStateEntry(i, Q931_U2, Q931mes_ALERTING, 4); - Q931AddStateEntry(i, Q931_U2, Q931mes_PROGRESS, 4); - Q931AddStateEntry(i, Q931_U2, Q931mes_CONNECT, 4); - Q931AddStateEntry(i, Q931_U2, Q931mes_RELEASE, 2); - - /* State 3 Outgoing Call Proceeding */ - Q931AddStateEntry(i, Q931_U3, Q931mes_PROGRESS, 4); - Q931AddStateEntry(i, Q931_U3, Q931mes_ALERTING, 4); - Q931AddStateEntry(i, Q931_U3, Q931mes_CONNECT, 4); - Q931AddStateEntry(i, Q931_U3, Q931mes_RELEASE, 2); - - /* State 4 Call Delivered */ - Q931AddStateEntry(i, Q931_U4, Q931mes_CONNECT, 4); - - /* State 6 Call Precent */ - Q931AddStateEntry(i, Q931_U6, Q931mes_INFORMATION, 2); - Q931AddStateEntry(i, Q931_U6, Q931mes_ALERTING, 2); - Q931AddStateEntry(i, Q931_U6, Q931mes_CALL_PROCEEDING, 2); - Q931AddStateEntry(i, Q931_U6, Q931mes_CONNECT, 2); - Q931AddStateEntry(i, Q931_U6, Q931mes_RELEASE_COMPLETE, 2); - Q931AddStateEntry(i, Q931_U6, Q931mes_RELEASE, 4); - Q931AddStateEntry(i, Q931_U6, Q931mes_DISCONNECT, 4); - - /* State 7 Call Received */ - Q931AddStateEntry(i, Q931_U7, Q931mes_CONNECT, 2); - - /* State 8 Connect request */ - Q931AddStateEntry(i, Q931_U8, Q931mes_CONNECT_ACKNOWLEDGE, 4); - - /* State 9 Incoming Call Proceeding */ - Q931AddStateEntry(i, Q931_U9, Q931mes_CONNECT, 2); - Q931AddStateEntry(i, Q931_U9, Q931mes_ALERTING, 2); - Q931AddStateEntry(i, Q931_U9, Q931mes_PROGRESS, 2); - - /* State 10 Active */ - Q931AddStateEntry(i, Q931_U10, Q931mes_SUSPEND, 2); - Q931AddStateEntry(i, Q931_U10, Q931mes_NOTIFY, 4); - Q931AddStateEntry(i, Q931_U10, Q931mes_NOTIFY, 2); - - /* State 11 Disconnect Request */ - Q931AddStateEntry(i, Q931_U11, Q931mes_RELEASE, 4); - Q931AddStateEntry(i, Q931_U11, Q931mes_DISCONNECT, 4); - Q931AddStateEntry(i, Q931_U11, Q931mes_NOTIFY, 4); - - /* State 12 Disconnect Ind */ - Q931AddStateEntry(i, Q931_U12, Q931mes_RELEASE, 4); - Q931AddStateEntry(i, Q931_U12, Q931mes_RELEASE, 2); - - /* State 15 Suspend Request */ - Q931AddStateEntry(i, Q931_U15, Q931mes_SUSPEND_ACKNOWLEDGE, 4); - Q931AddStateEntry(i, Q931_U15, Q931mes_SUSPEND_REJECT, 4); - Q931AddStateEntry(i, Q931_U15, Q931mes_DISCONNECT, 4); - Q931AddStateEntry(i, Q931_U15, Q931mes_RELEASE, 4); - -/* TODO - Q931AddStateEntry(i, Q931_U17, - Q931AddStateEntry(i, Q931_U19, - Q931AddStateEntry(i, Q931_U25, -*/ -} - -/***************************************************************************** - - Function: DMSProc0x0fTE - -*****************************************************************************/ -L3INT DMSProc0x0fTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - if (pMes->ProtDisc == 8) { - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here*/ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - } - if (iFrom == 4) { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - - if (pMes->ProtDisc == 3 && pTrunk->autoServiceAck) { - Q931AckService(pTrunk, buf); - } - } - return ret; - -} - -/***************************************************************************** - - Function: DMSProc0x07TE - -*****************************************************************************/ -L3INT DMSProc0x07TE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - if (pMes->ProtDisc == 8) { - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here*/ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - } - if (iFrom == 4) { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; - -} diff --git a/libs/freetdm/src/isdn/DMSmes.c b/libs/freetdm/src/isdn/DMSmes.c deleted file mode 100644 index 3ce82f2ded..0000000000 --- a/libs/freetdm/src/isdn/DMSmes.c +++ /dev/null @@ -1,344 +0,0 @@ -/***************************************************************************** - - FileName: DMSmes.c - - Contents: Pack/Unpack functions. These functions will unpack a DMS-100 ISDN - message from the bit packed original format into structs - that contains variables sized by the user. It will also pack - the struct back into a Q.931 message as required. - - See national.h for description. - - License/Copyright: - - Copyright (c) 2007, Jan Vidar Berger, Case Labs, Ltd. All rights reserved. - email:janvb@caselaboratories.com - - Copyright (c) 2007, Michael Jerris. All rights reserved. - email:mike@jerris.com - - 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 Case Labs, Ltd 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT OWNER OR CONTRIBUTORS 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 SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - -*****************************************************************************/ - -#include "DMS.h" - -/***************************************************************************** - - Function: DMSUmes_Setup - -*****************************************************************************/ -L3INT DMSUmes_Setup(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3INT ir = 0; - L3INT OOff = 0; - L3INT rc = Q931E_NO_ERROR; - L3UCHAR last_codeset = 0, codeset = 0; - L3UCHAR shift_lock = 1; - - while (IOff < Size) { - if (!shift_lock) { - codeset = last_codeset; - } - - if ((IBuf[IOff] & 0xF0) == Q931ie_SHIFT ) { - shift_lock = (IBuf[IOff] & 0x08); - if (shift_lock) { - last_codeset = codeset; - } - codeset = ((IBuf[IOff] & 0x07)); - IOff++; - } - - if (codeset == 0) { - switch (IBuf[IOff]) { - case Q931ie_SENDING_COMPLETE: - case Q931ie_BEARER_CAPABILITY: - case Q931ie_CHANNEL_IDENTIFICATION: - case Q931ie_PROGRESS_INDICATOR: - case Q931ie_NETWORK_SPECIFIC_FACILITIES: - case Q931ie_DISPLAY: - case Q931ie_DATETIME: - case Q931ie_KEYPAD_FACILITY: - case Q931ie_SIGNAL: - case Q931ie_CALLING_PARTY_NUMBER: - case Q931ie_CALLING_PARTY_SUBADDRESS: - case Q931ie_CALLED_PARTY_NUMBER: - case Q931ie_CALLED_PARTY_SUBADDRESS: - case Q931ie_TRANSIT_NETWORK_SELECTION: - case Q931ie_LOW_LAYER_COMPATIBILITY: - case Q931ie_HIGH_LAYER_COMPATIBILITY: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if (rc != Q931E_NO_ERROR) - return rc; - break; - case Q931ie_REPEAT_INDICATOR: - if (ir < 2) { - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - ir++; - } else { - return Q931E_ILLEGAL_IE; - } - break; - default: - return Q931E_ILLEGAL_IE; - break; - } - } else if (codeset == 6) { - switch (IBuf[IOff]) { - case Q931ie_GENERIC_DIGITS: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if (rc != Q931E_NO_ERROR) - return rc; - break; - default: - return Q931E_ILLEGAL_IE; - break; - } - - } else { - return Q931E_ILLEGAL_IE; - } - } - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: DMSPmes_Setup - - Decription: Pack a Q931mes_Generic into a real Q.931 message. The user will - set up a SETUP message and issue this to the stack where it - is processed by Q931ProcSetup that processes and validates - it before it actually sends it out. This function is called - to compute the real Q.931 message. - - Parameters: IBuf[IN] Ptr to un-packed struct - ISize[IN] Size of input buffer (unpacked message). - OBuf[OUT] Ptr to packed 'octet' wise message. - OSize[OUT] Size of packed message. - - Called By: Q931ProcSetup - -*****************************************************************************/ -L3INT DMSPmes_Setup(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - L3INT rc = Q931E_NO_ERROR; - Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; - L3INT Octet = 0; - - /* Q931 Message Header */ - Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); - - /* Sending Complete */ - if (Q931IsIEPresent(pMes->SendComplete)) { - OBuf[Octet++] = (L3UCHAR)(pMes->SendComplete & 0x00ff); - } - - /* Repeat Indicator */ - if (Q931IsIEPresent(pMes->RepeatInd)) { - OBuf[Octet++] = (L3UCHAR)(pMes->RepeatInd & 0x00ff); - } - - /* Bearer capability */ - if (Q931IsIEPresent(pMes->BearerCap)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_BEARER_CAPABILITY](pTrunk, Q931GetIEPtr(pMes->BearerCap,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } else { - rc = Q931E_BEARERCAP; - } - - /* Channel Identification */ - if (Q931IsIEPresent(pMes->ChanID)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CHANNEL_IDENTIFICATION](pTrunk, Q931GetIEPtr(pMes->ChanID,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Progress indicator */ - if (Q931IsIEPresent(pMes->ProgInd)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_PROGRESS_INDICATOR](pTrunk, Q931GetIEPtr(pMes->ProgInd,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Network spesific facilities */ - if (Q931IsIEPresent(pMes->NetFac)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_NETWORK_SPECIFIC_FACILITIES](pTrunk, Q931GetIEPtr(pMes->NetFac,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Display */ - if (Q931IsIEPresent(pMes->Display)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Date/Time */ - if (Q931IsIEPresent(pMes->DateTime)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DATETIME](pTrunk, Q931GetIEPtr(pMes->DateTime,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Keypad Facility */ - if (Q931IsIEPresent(pMes->KeypadFac)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_KEYPAD_FACILITY](pTrunk, Q931GetIEPtr(pMes->KeypadFac,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Signal */ - if (Q931IsIEPresent(pMes->Signal)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_SIGNAL](pTrunk, Q931GetIEPtr(pMes->Signal,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Calling Party Number */ - if (Q931IsIEPresent(pMes->CallingNum)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALLING_PARTY_NUMBER](pTrunk, Q931GetIEPtr(pMes->CallingNum,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Calling Party Subaddress */ - if (Q931IsIEPresent(pMes->CallingSub)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALLING_PARTY_SUBADDRESS](pTrunk, Q931GetIEPtr(pMes->CallingSub,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Called Party number */ - if (Q931IsIEPresent(pMes->CalledNum)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALLED_PARTY_NUMBER](pTrunk, Q931GetIEPtr(pMes->CalledNum,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - - /* Called party subaddress */ - if (Q931IsIEPresent(pMes->CalledSub)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALLED_PARTY_SUBADDRESS](pTrunk, Q931GetIEPtr(pMes->CalledSub,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Transit network selection */ - if (Q931IsIEPresent(pMes->TransNetSel)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_TRANSIT_NETWORK_SELECTION](pTrunk, Q931GetIEPtr(pMes->TransNetSel,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Repeat Indicator */ - if (Q931IsIEPresent(pMes->LLRepeatInd)) { - rc = Q931E_UNKNOWN_IE;/* TODO */ - } - - /* Low Layer Compatibility */ - if (Q931IsIEPresent(pMes->LLComp)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_LOW_LAYER_COMPATIBILITY](pTrunk, Q931GetIEPtr(pMes->LLComp,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* High Layer Compatibility */ - if (Q931IsIEPresent(pMes->HLComp)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_HIGH_LAYER_COMPATIBILITY](pTrunk, Q931GetIEPtr(pMes->HLComp,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - *OSize = Octet; - return rc; -} - - -/***************************************************************************** - - Function: DMSUmes_0x0f - -*****************************************************************************/ -L3INT DMSUmes_0x0f(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - if (mes->ProtDisc == 8) { - return Q931Umes_ConnectAck(pTrunk, IBuf, mes, IOff, Size); - } - - if (mes->ProtDisc == 3) { - return Q931Umes_Service(pTrunk, IBuf, mes, IOff, Size); - } - - return Q931E_UNKNOWN_MESSAGE; -} - -/***************************************************************************** - - Function: DMSPmes_0x0f - -*****************************************************************************/ -L3INT DMSPmes_0x0f(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - Q931mes_Generic *mes = (Q931mes_Generic *)IBuf; - - if (mes->ProtDisc == 8) { - return Q931Pmes_ConnectAck(pTrunk, IBuf, ISize, OBuf, OSize); - } - - if (mes->ProtDisc == 3) { - return Q931Pmes_Service(pTrunk, IBuf, ISize, OBuf, OSize); - } - - return Q931E_UNKNOWN_MESSAGE; -} - -/***************************************************************************** - - Function: DMSUmes_0x07 - -*****************************************************************************/ -L3INT DMSUmes_0x07(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - if (mes->ProtDisc == 8) { - return Q931Umes_Connect(pTrunk, IBuf, mes, IOff, Size); - } - - if (mes->ProtDisc == 3) { - return Q931Umes_ServiceAck(pTrunk, IBuf, mes, IOff, Size); - } - - return Q931E_UNKNOWN_MESSAGE; -} - -/***************************************************************************** - - Function: DMSPmes_0x07 - -*****************************************************************************/ -L3INT DMSPmes_0x07(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - Q931mes_Generic *mes = (Q931mes_Generic *)IBuf; - - if (mes->ProtDisc == 8) { - return Q931Pmes_Connect(pTrunk, IBuf, ISize, OBuf, OSize); - } - - if (mes->ProtDisc == 3) { - return Q931Pmes_ServiceAck(pTrunk, IBuf, ISize, OBuf, OSize); - } - - return Q931E_UNKNOWN_MESSAGE; -} diff --git a/libs/freetdm/src/isdn/EuroISDNStateNT.c b/libs/freetdm/src/isdn/EuroISDNStateNT.c deleted file mode 100644 index 6b26c91e04..0000000000 --- a/libs/freetdm/src/isdn/EuroISDNStateNT.c +++ /dev/null @@ -1,44 +0,0 @@ -/***************************************************************************** - - FileName: EuroISDNStateNT.c - - Contents: EuroISDN State Engine for NT (Network Mode). - - The controlling state engine for Q.931 is the state engine - on the NT side. The state engine on the TE side is a slave - of this. The TE side maintain it's own states as described in - ITU-T Q931, but will in raise conditions be overridden by - the NT side. - - License/Copyright: - - Copyright (c) 2007, Jan Vidar Berger, Case Labs, Ltd. All rights reserved. - email:janvb@caselaboratories.com - - 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 Case Labs, Ltd 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT OWNER OR CONTRIBUTORS 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 SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*****************************************************************************/ - -#include "Q931.h" diff --git a/libs/freetdm/src/isdn/EuroISDNStateTE.c b/libs/freetdm/src/isdn/EuroISDNStateTE.c deleted file mode 100644 index ef6b39e8e5..0000000000 --- a/libs/freetdm/src/isdn/EuroISDNStateTE.c +++ /dev/null @@ -1,58 +0,0 @@ -/***************************************************************************** - - FileName: EuroISDNStateTE.c - - Contents: EuroISDN State Engine for TE (User Mode). - - The controlling state engine for Q.931 is the state engine - on the NT side. The state engine on the TE side is a slave - of this. The TE side maintain it's own states as described in - ITU-T Q931, but will in raise conditions be overridden by - the NT side. - - License/Copyright: - - Copyright (c) 2007, Jan Vidar Berger, Case Labs, Ltd. All rights reserved. - email:janvb@caselaboratories.com - - 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 Case Labs, Ltd 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT OWNER OR CONTRIBUTORS 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 SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*****************************************************************************/ - -#include "Q931.h" - -/* - EuroISDN is a sub-set of Q.931. Q.931 is very generic as it embrase a lot, - while EuroISDN is more exact and make decitions on some of the - 'implementation options' in the original standard. EuroISDN will - however run smoothly under the generic space, so these functions are more - for show -*/ -#if 0 -static void EuroISDNCreateTE(L3UCHAR i) -{ - Q931CreateTE(i); -} -#endif diff --git a/libs/freetdm/src/isdn/Q921.c b/libs/freetdm/src/isdn/Q921.c deleted file mode 100644 index d1cbab6e6f..0000000000 --- a/libs/freetdm/src/isdn/Q921.c +++ /dev/null @@ -1,3518 +0,0 @@ -/***************************************************************************** - - FileName: q921.c - - Description: Contains the implementation of a Q.921 protocol - - Created: 27.dec.2000/JVB - - License/Copyright: - - Copyright (c) 2007, Jan Vidar Berger, Case Labs, Ltd. All rights reserved. - email:janvb@caselaboratories.com - - 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 Case Labs, Ltd 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT OWNER OR CONTRIBUTORS 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 SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - -*****************************************************************************/ - -/**************************************************************************** - * Changes: - * - * - June-August 2008: Stefan Knoblich : - * Add PTMP TEI management (NT + TE mode) - * Add timers - * Add retransmit counters - * Add logging - * Various cleanups - * Queues, retransmission of I frames - * PTMP NT mode - * - * - * TODO: - * - * - Cleanup queueing, test retransmission - * - * - Q921Start() /-Stop() TEI acquire + release - * (move everything related into these functions) - * - * - Q.921 '97 Appendix I (and maybe III, IV) - * - * - More complete Appendix II - * - * - Test PTP mode - * - * - PTMP NT mode (in progress) - * - * - NT mode TEI management: (ab)use T202 for TEI Check Request retransmission - * - * - General cleanup (move all non-public declarations into private header file) - * - * - Statistics, per-Frame type debug message filter - * - ****************************************************************************/ - -#include -#include -#include -#include - -#include "freetdm.h" -#include "Q921.h" -#include "Q921priv.h" -#include "mfifo.h" - -#ifdef WIN32 -#pragma warning(disable:4100 4244) -#endif - -/****************************************************************************************************** - * Actual code below this line - ******************************************************************************************************/ - - -/** - * Q921StateNames - * \brief Static array of state name / value mappings - */ -static struct Q921StateName { - Q921State_t value; - const char *name; -} Q921StateNames[10] = { - { Q921_STATE_STOPPED, "Stopped" }, - { Q921_STATE_TEI_UNASSIGNED, "TEI Unassigned" }, - { Q921_STATE_TEI_AWAITING, "TEI Awaiting Assignment" }, - { Q921_STATE_TEI_ESTABLISH, "TEI Awaiting Establishment" }, - { Q921_STATE_TEI_ASSIGNED, "TEI Assigned" }, - { Q921_STATE_AWAITING_ESTABLISHMENT, "Awaiting Establishment" }, - { Q921_STATE_AWAITING_RELEASE, "Awaiting Release" }, - { Q921_STATE_MULTIPLE_FRAME_ESTABLISHED, "Multiple Frame Mode Established" }, - { Q921_STATE_TIMER_RECOVERY, "Timer Recovery" }, - { 0, 0 } -}; - -/** - * Q921State2Name - * \brief Convert state value to name - * \param[in] state the state value - * \return the state name or "Unknown" - * - * \author Stefan Knoblich - */ -static const char *Q921State2Name(Q921State_t state) -{ - struct Q921StateName *p = Q921StateNames; - - while(p->name) { - if(p->value == state) - return p->name; - p++; - } - - return "Unknown"; -} - - -/** - * Q921SendEnquiry - */ -static int Q921SendEnquiry(L2TRUNK trunk, L2UCHAR tei) -{ - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, tei); - - /* send enquiry: begin */ - if(Q921_CHECK_FLAG(link, Q921_FLAG_RECV_BUSY)) { - - Q921SendRNR(trunk, trunk->sapi, Q921_COMMAND(trunk), tei, 1); - } - else { - Q921SendRR(trunk, trunk->sapi, Q921_COMMAND(trunk), tei, 1); - } - - /* clear acknowledge pending */ - Q921_CLEAR_FLAG(link, Q921_FLAG_ACK_PENDING); - - /* "Start" T200 */ - Q921T200TimerReset(trunk, tei); - - /* send enquiry: end */ - return 1; -} - -/** - * Q921SendEnquiryResponse - */ -static int Q921SendEnquiryResponse(L2TRUNK trunk, L2UCHAR tei) -{ - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, tei); - - /* send enquiry: begin */ - if(Q921_CHECK_FLAG(link, Q921_FLAG_RECV_BUSY)) { - - Q921SendRNR(trunk, trunk->sapi, Q921_RESPONSE(trunk), tei, 1); - } - else { - Q921SendRR(trunk, trunk->sapi, Q921_RESPONSE(trunk), tei, 1); - - /* clear acknowledge pending */ - Q921_CLEAR_FLAG(link, Q921_FLAG_ACK_PENDING); - } - /* send enquiry: end */ - return 1; -} - -/** - * Q921ResetExceptionConditions - * \brief Reset Q.921 Exception conditions procedure - * \param trunk Q.921 data structure - * \param tei TEI - * \todo Do something - */ -static void Q921ResetExceptionConditions(L2TRUNK trunk, L2UCHAR tei) -{ - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, tei); - - /* Clear peer receiver busy */ - Q921_CLEAR_FLAG(link, Q921_FLAG_PEER_RECV_BUSY); - - /* Clear reject exception */ - Q921_CLEAR_FLAG(link, Q921_FLAG_REJECT); - - /* Clear own receiver busy */ - Q921_CLEAR_FLAG(link, Q921_FLAG_RECV_BUSY); - - /* Clear acknowledge pending */ - Q921_CLEAR_FLAG(link, Q921_FLAG_ACK_PENDING); - - return; -} - -/** - * Q921EstablishDataLink - * \brief Q.921 Establish data link procedure - * \param trunk Q.921 data structure - * \param tei TEI - * \return always 1 (success) - */ -static int Q921EstablishDataLink(L2TRUNK trunk, L2UCHAR tei) -{ - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, tei); - - /* reset exception conditions */ - Q921ResetExceptionConditions(trunk, tei); - - /* RC = 0 */ - link->N200 = 0; - - /* Send SABME */ - Q921SendSABME(trunk, trunk->sapi, Q921_COMMAND(trunk), tei, 1); - - /* Restart T200, stop T203 */ - Q921T200TimerReset(trunk, tei); - Q921T203TimerStop(trunk, tei); - - return 1; -} - -/** - * Q921NrErrorRecovery - * \brief NR(R) Error recovery procedure - * \param trunk Q.921 data structure - * \param tei TEI - * \return always 1 (success) - */ -static int Q921NrErrorRecovery(L2TRUNK trunk, L2UCHAR tei) -{ - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, tei); - - /* MDL Error indication (J) */ - - /* Establish datalink */ - Q921EstablishDataLink(trunk, tei); - - /* Clear L3 initiated */ - Q921_CLEAR_FLAG(link, Q921_FLAG_L3_INITIATED); - - return 1; -} - - -/** - * Q921InvokeRetransmission - * \brief I Frame retransmission procedure - * \param trunk Q.921 data structure - * \param tei TEI - * \param nr N(R) for retransmission - * \return always 1 (success) - */ -static int Q921InvokeRetransmission(L2TRUNK trunk, L2UCHAR tei, L2UCHAR nr) -{ - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, tei); - L2UCHAR *mes; - L2INT qpos, qnum, size = 0; - - qnum = MFIFOGetMesCount(link->IFrameResendQueue); - qpos = qnum - 1; - - /* - * slightly different than what is shown in the spec - * (Q.921 '97 Annex B, Figure B.9, page 104) - * - * what the above mentioned figure probably means is: - * "as long as V(S) != N(R), move the pointer marking - * the first frame to start resending at to the previous - * frame" - * - * if we actually implemented it as shown in the figure, we'd be - * resending frames in the wrong order (moving backwards in time) - * meaning we'd have to add an incoming queue to reorder the frames - * - */ - /* - * TODO: There's a "traditional" off-by-one error hidden in the original - * mfifo implementation + it's late, i'm tired and being lazy, - * so i'll probably have added another one :P - * - * wow, the first while loop sucks and can be removed - */ - while(link->vs != nr && qpos > 0) { /* ???? */ - /* V(S) = V(S) - 1 */ - Q921_DEC_COUNTER(link->vs); /* huh? backwards? */ - - /* next frame in queue (backtrack along I queue) ??? */ - qpos--; - } - - /* - * being lazy and trying to avoid mod 128 math this way... - */ - if(link->vs != nr && !qpos) { - /* fatal, we don't have enough history to resend all missing frames */ - /* TODO: how to handle this? */ - } - - /* - * resend frames in correct order (oldest missing frame first, - * contrary to what the spec figure shows) - */ - while(qpos < qnum) { - /* Grab frame's buffer ptr and size from queue */ - mes = MFIFOGetMesPtrOffset(link->IFrameResendQueue, &size, qpos); - if(mes) { - /* requeue frame (TODO: check queue full condition) */ - MFIFOWriteMes(link->IFrameQueue, mes, size); - - /* set I frame queued */ - } - - qpos++; - } - - return 1; -} - - -static int Q921AcknowledgePending(L2TRUNK trunk, L2UCHAR tei) -{ - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, tei); - - switch(link->state) { - case Q921_STATE_MULTIPLE_FRAME_ESTABLISHED: - case Q921_STATE_TIMER_RECOVERY: - if(Q921_CHECK_FLAG(link, Q921_FLAG_ACK_PENDING)) { - /* clear acknowledge pending */ - Q921_CLEAR_FLAG(link, Q921_FLAG_ACK_PENDING); - - /* send RR */ - Q921SendRR(trunk, trunk->sapi, Q921_COMMAND(trunk), tei, 0); - - return 1; - } - break; - - default: - break; - } - - return 0; -} - -/***************************************************************************** - - Function: Q921_InitTrunk - - Decription: Initialize a Q.921 trunk so it is ready for use. This - function MUST be called before you call any other functions. - -*****************************************************************************/ -int Q921_InitTrunk(L2TRUNK trunk, - L2UCHAR sapi, - L2UCHAR tei, - Q921NetUser_t NetUser, - Q921NetType_t NetType, - L2INT hsize, - Q921Tx21CB_t cb21, - Q921Tx23CB_t cb23, - void *priv21, - void *priv23) -{ - int numlinks = 0; - - trunk->sapi = sapi; - trunk->tei = tei; - trunk->NetUser = NetUser; - trunk->NetType = NetType; - trunk->Q921Tx21Proc = cb21; - trunk->Q921Tx23Proc = cb23; - trunk->PrivateData21 = priv21; - trunk->PrivateData23 = priv23; - trunk->Q921HeaderSpace = hsize; - - numlinks = Q921_IS_PTMP_NT(trunk) ? Q921_TEI_MAX : 1; - - if (trunk->initialized != INITIALIZED_MAGIC) { - MFIFOCreate(trunk->HDLCInQueue, Q921MAXHDLCSPACE, 10); - - /* - * Allocate space for per-link context(s) - */ - trunk->context = ftdm_malloc(numlinks * sizeof(struct Q921_Link)); - if(!trunk->context) - return -1; - - trunk->initialized = INITIALIZED_MAGIC; - } - - /* timeout default values */ - trunk->T200Timeout = 1000; /* 1 second */ - trunk->T203Timeout = 10000; /* 10 seconds */ - trunk->T202Timeout = 2000; /* 2 seconds */ - trunk->T201Timeout = 200000; /* 200 seconds */ - trunk->TM01Timeout = 10000; /* 10 seconds */ - - /* octet / retransmit counter default limits */ - trunk->N200Limit = 3; /* 3 retransmits */ - trunk->N201Limit = 260; /* 260 octets */ - trunk->N202Limit = 3; /* 3 retransmits */ - trunk->k = 7; /* 7 outstanding ACKs */ - - /* reset counters, timers, etc. */ - trunk->T202 = 0; - trunk->N202 = 0; - - /* Reset per-link contexts */ - memset(trunk->context, 0, numlinks * sizeof(struct Q921_Link)); - - /* clear tei map */ - memset(trunk->tei_map, 0, Q921_TEI_MAX + 1); - - if(Q921_IS_PTMP(trunk)) { - /* - * We're either the Network side (NT, TEI = 0) - * or user-side equipment (TE) which will get it's TEI via - * dynamic assignment - */ - trunk->tei = 0; - } - - return 0; -} - - -/** - * Q921Tx21Proc - * \brief Submit frame to layer 1 (for sending) - * \param[in] trunk Pointer to trunk struct - * \param[in] mes pointer to message buffer - * \param[in] size size of message - * \return > 0 on success; <= 0 on error - */ -static int Q921Tx21Proc(L2TRUNK trunk, L2UCHAR *Msg, L2INT size) -{ - Q921LogMesg(trunk, Q921_LOG_DEBUG, 0, Msg, size, "Sending frame"); - - return trunk->Q921Tx21Proc(trunk->PrivateData21, Msg, size); -} - - -/** - * Q921Tx23Proc - * \brief Submit frame to layer 3 - * \param[in] trunk Pointer to trunk struct - * \param[in] mes pointer to message buffer - * \param[in] size size of message - * \return > 0 on success; <= 0 on error - */ -static int Q921Tx23Proc(L2TRUNK trunk, Q921DLMsg_t ind, L2UCHAR tei, L2UCHAR *Msg, L2INT size) -{ - return trunk->Q921Tx23Proc(trunk->PrivateData23, ind, tei, Msg, size); -} - - -/** - * Q921LogProc - * \brief Used for logging, converts to string and submits to higher level log function via callback - * \param[in] trunk Pointer to trunk struct - * \param[in] level Q921 Loglevel - * \param[in] fmt format of logmessage - * \return >= 0 on success, < 0 on error - * - * \author Stefan Knoblich - */ -static int Q921Log(L2TRUNK trunk, Q921LogLevel_t level, const char *fmt, ...) -{ - char buf[Q921_LOGBUFSIZE]; - L2INT len; - va_list ap; - - if(!trunk->Q921LogProc) - return 0; - - if(trunk->loglevel < level) - return 0; - - va_start(ap, fmt); - - len = vsnprintf(buf, sizeof(buf)-1, fmt, ap); - if(len <= 0) { - /* TODO: error handling */ - return -1; - } - if(len >= sizeof(buf)) - len = sizeof(buf) - 1; - - buf[len] = '\0'; - - va_end(ap); - - return trunk->Q921LogProc(trunk->PrivateDataLog, level, buf, len); -} - - -static int print_hex(char *buf, int bsize, const unsigned char *in, const int len) -{ - static const char hex[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; - int offset = 0; - int pos = 0; - int nr = 0; - - buf[pos++] = '['; - bsize -= 3; - - while((bsize - pos) > 0 && offset < len) { - buf[pos++] = hex[(in[offset] & 0xF0) >> 4]; - buf[pos++] = hex[(in[offset++] & 0x0F)]; - - if(++nr == 32 && offset < len && (bsize - pos) > 3) { - nr = 0; - buf[pos++] = ']'; - buf[pos++] = '\n'; - buf[pos++] = '['; - } - else if(offset < len) { - buf[pos++] = ' '; - } - } - - buf[pos++] = ']'; - buf[pos++] = '\n'; - buf[pos] = '\0'; - - return pos; -} - -#define APPEND_MSG(buf, off, lef, fmt, ...) \ - len = snprintf(buf + off, lef, fmt, ##__VA_ARGS__); \ - if(len > 0) { \ - off += len; \ - lef -= len; \ - } else { \ - goto out; \ - } - -/** - * Q921LogProcMesg - * \brief Used for logging, converts to string and submits to higher level log function via callback - * \param[in] trunk Pointer to trunk struct - * \param[in] level Q921 Loglevel - * \param[in] received direction of the message (received = 1, sending = 0) - * \param[in] mes pointer to message buffer - * \param[in] size size of message - * \param[in] fmt format of logmessage - * \return >= 0 on success, < 0 on error - * - * \author Stefan Knoblich - */ -static int Q921LogMesg(L2TRUNK trunk, Q921LogLevel_t level, L2UCHAR received, L2UCHAR *mes, L2INT size, const char *fmt, ...) -{ - char buf[Q921_LOGBUFSIZE]; - size_t len, left; - va_list ap; - - if(!trunk->Q921LogProc) - return 0; - - if(trunk->loglevel < level) - return 0; - - if(!mes) - return 0; - - memset(buf, 0, sizeof(buf)); - - left = sizeof(buf) - 1; - - va_start(ap, fmt); - - len = vsnprintf(buf, left, fmt, ap); - if(len > 0) - left -= len; - else { - /* TODO: error handling */ - return -1; - } - - va_end(ap); - - if(trunk->loglevel == Q921_LOG_DEBUG) { - char pbuf[1024]; - size_t pleft, poffset; - L2UCHAR sapi, tei, cr; - L2UCHAR *pmes = mes + trunk->Q921HeaderSpace; - struct Q921_Link *link; - - memset(pbuf, 0, sizeof(pbuf)); - - pleft = sizeof(pbuf); - poffset = 0; - - /* - * Decode packet - */ - sapi = (pmes[0] & 0xfc) >> 2; - cr = (pmes[0] & 0x02) >> 1; - tei = (pmes[1] & 0xfe) >> 1; - link = Q921_LINK_CONTEXT(trunk, tei); - - /* make cr actually useful */ - cr = (received) ? Q921_IS_COMMAND(trunk, cr) : Q921_IS_RESPONSE(trunk, cr); - - /* filter */ - if((pmes[2] & 0x01) == 0x00) { - ; - } - else if((pmes[2] & 0x03) == 0x01) { - ; //return 0; - } - else if((pmes[2] & 0x03) == 0x03) { - ; - } - - APPEND_MSG(pbuf, poffset, pleft, "\n----------------- Q.921 Packet [%s%s] ---------------\n", received ? "Incoming" : "Outgoing", - (tei == link->tei || tei == Q921_TEI_BCAST) ? "" : ", Ignored" ); - - /* common header */ - APPEND_MSG(pbuf, poffset, pleft, " SAPI: %u, TEI: %u, C/R: %s (%d)\n\n", sapi, tei, (cr) ? "Command" : "Response", (mes[0] & 0x02) >> 1 ); - - /* - * message specific - */ - if((pmes[2] & 0x01) == 0x00) { - /* - * I frame - */ - L2UCHAR pf = pmes[3] & 0x01; /* poll / final flag */ - L2UCHAR nr = pmes[3] >> 1; /* receive sequence number */ - L2UCHAR ns = pmes[2] >> 1; /* send sequence number */ - - APPEND_MSG(pbuf, poffset, pleft, " Type: I Frame\n P/F: %d, N(S): %d, N(R): %d [V(A): %d, V(R): %d, V(S): %d]\n", pf, ns, nr, - link->va, link->vr, link->vs); - - /* Dump content of I Frames for foreign TEIs */ - if(tei != link->tei) { - APPEND_MSG(pbuf, poffset, pleft, " CONTENT:\n"); - - len = print_hex(pbuf + poffset, (int)pleft, &pmes[4], size - (trunk->Q921HeaderSpace + 4)); - poffset += len; - pleft -= len; - } - } - else if((pmes[2] & 0x03) == 0x01) { - /* - * S frame - */ - L2UCHAR sv = (pmes[2] & 0x0c) >> 2; /* supervisory format id */ - L2UCHAR pf = pmes[3] & 0x01; /* poll / final flag */ - L2UCHAR nr = pmes[3] >> 1; /* receive sequence number */ - const char *type; - - switch(sv) { - case 0x00: /* RR : Receive Ready */ - type = "RR (Receive Ready)"; - break; - - case 0x02: /* RNR : Receive Not Ready */ - type = "RNR (Receiver Not Ready)"; - break; - - case 0x04: /* REJ : Reject */ - type = "REJ (Reject)"; - break; - - default: /* Invalid / Unknown */ - type = "Unknown"; - break; - } - - APPEND_MSG(pbuf, poffset, pleft, " Type: S Frame, SV: %s\n P/F: %d, N(R): %d [V(A): %d, V(R): %d, V(S): %d]\n", type, pf, nr, - link->va, link->vr, link->vs); - } - else if((pmes[2] & 0x03) == 0x03) { - /* - * U frame - */ - L2UCHAR m = (pmes[2] & 0xe0) >> 3 | (pmes[2] & 0x0c) >> 2; /* modifier function id */ - L2UCHAR pf = (pmes[2] & 0x10) >> 4; /* poll / final flag */ - const char *type; - - switch(m) { - case 0x00: - type = "UI (Unnumbered Information)"; - break; - - case 0x03: - type = "DM (Disconnected Mode)"; - break; - - case 0x08: - type = "DISC (Disconnect)"; - break; - - case 0x0c: - type = "UA (Unnumbered Acknowledgement)"; - break; - - case 0x0f: - type = "SABME"; - break; - - case 0x11: - type = "FRMR (Frame Reject)"; - break; - - case 0x17: - type = "XID (Exchange Identification)"; - break; - - default: - type = "Unknown"; - } - - - APPEND_MSG(pbuf, poffset, pleft, " Type: U Frame (%s)\n P/F: %d\n", type, pf); - - if(m == 0x00) { - switch(pmes[3]) { - case Q921_LAYER_ENT_ID_TEI: - type = "TEI Mgmt"; - break; - - case Q921_LAYER_ENT_ID_Q931: - type = "Q.931"; - break; - - default: - type = "Unknown"; - } - - if(pmes[3] == Q921_LAYER_ENT_ID_TEI) { - const char *command = ""; - - switch(pmes[6]) { - case Q921_TEI_ID_REQUEST: - command = "Request"; - break; - case Q921_TEI_ID_VERIFY: - command = "Verify"; - break; - case Q921_TEI_ID_CHECKREQ: - command = "Check req"; - break; - case Q921_TEI_ID_CHECKRESP: - command = "Check resp"; - break; - case Q921_TEI_ID_REMOVE: - command = "Remove"; - break; - case Q921_TEI_ID_ASSIGNED: - command = "Assign"; - break; - case Q921_TEI_ID_DENIED: - command = "Denied"; - break; - } - APPEND_MSG(pbuf, poffset, pleft, " ENT ID: %d (%s), COMMAND: %d (%s), RI: %#x, AI: %d\n", - pmes[3], type, pmes[6], command, (int)((pmes[4] << 8) | pmes[5]), pmes[7] >> 1); - } - else { - APPEND_MSG(pbuf, poffset, pleft, " ENT ID: %d (%s), MESSAGE CONTENT:\n", pmes[3], type); - - len = print_hex(pbuf + poffset, (int)pleft, &pmes[3], size - (trunk->Q921HeaderSpace + 3)); - poffset += len; - pleft -= len; - } - } - } - else { - /* - * Unknown - */ - strncat(pbuf + poffset, " -- unknown frame type --\n", pleft); - - len = (sizeof(pbuf) - poffset) - strlen(pbuf + poffset); - if(len > 0) { - poffset += len; - pleft -= len; - } else - goto out; - } - - APPEND_MSG(pbuf, poffset, pleft, "\n Q.921 state: \"%s\" (%d) [flags: %c%c%c%c]\n", Q921State2Name(link->state), link->state, - Q921_CHECK_FLAG(link, Q921_FLAG_ACK_PENDING) ? 'A' : '-', - Q921_CHECK_FLAG(link, Q921_FLAG_REJECT) ? 'R' : '-', - Q921_CHECK_FLAG(link, Q921_FLAG_PEER_RECV_BUSY) ? 'P' : '-', - Q921_CHECK_FLAG(link, Q921_FLAG_RECV_BUSY) ? 'B' : '-'); - - strncat(pbuf + poffset, "----------------------------------------------\n\n", pleft); - - len = (sizeof(pbuf) - poffset) - strlen(pbuf + poffset); - if(len > 0) { - poffset += len; - pleft -= len; - } else - goto out; - - - /* concat buffers together */ - len = strlen(pbuf); - if(len <= left) - strncat(buf, pbuf, left); - else - strncat(buf, "-- packet truncated --\n", left); - } - -out: - buf[sizeof(buf) - 1] = '\0'; - - return trunk->Q921LogProc(trunk->PrivateDataLog, level, buf, (int)strlen(buf)); -} - -/***************************************************************************** - - Function: Q921TimeTick - - Description: Called periodically from an external source to allow the - stack to process and maintain it's own timers. - - Return Value: none - -*****************************************************************************/ -static L2ULONG (*Q921GetTimeProc) (void) = NULL; /* callback for func reading time in ms */ -static L2ULONG tLast = {0}; - -static L2ULONG Q921GetTime(void) -{ - L2ULONG tNow = 0; - - if(Q921GetTimeProc) - { - tNow = Q921GetTimeProc(); - if(tNow < tLast) /* wrapped */ - { - /* TODO */ - } - tLast = tNow; - } - return tNow; -} - -/* - * T200 handling (per-TEI in PTMP NT mode, tei=0 otherwise) - */ -static void Q921T200TimerStart(L2TRUNK trunk, L2UCHAR tei) -{ - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, tei); - - if (!link->T200) { - link->T200 = Q921GetTime() + trunk->T200Timeout; - - Q921Log(trunk, Q921_LOG_DEBUG, "T200 (timeout: %d msecs) started for TEI %d\n", trunk->T200Timeout, tei); - } -} - -static void Q921T200TimerStop(L2TRUNK trunk, L2UCHAR tei) -{ - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, tei); - - link->T200 = 0; - - Q921Log(trunk, Q921_LOG_DEBUG, "T200 stopped for TEI %d\n", tei); -} - -static void Q921T200TimerReset(L2TRUNK trunk, L2UCHAR tei) -{ - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, tei); - - link->T200 = Q921GetTime() + trunk->T200Timeout; - - Q921Log(trunk, Q921_LOG_DEBUG, "T200 (timeout: %d msecs) restarted for TEI %d\n", trunk->T200Timeout, tei); -} - -/* - * T203 handling (per-TEI in PTMP NT mode, tei=0 otherwise) - */ -static void Q921T203TimerStart(L2TRUNK trunk, L2UCHAR tei) -{ - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, tei); - - if (!link->T203) { - link->T203 = Q921GetTime() + trunk->T203Timeout; - - Q921Log(trunk, Q921_LOG_DEBUG, "T203 (timeout: %d msecs) started for TEI %d\n", trunk->T203Timeout, tei); - } -} - -static void Q921T203TimerStop(L2TRUNK trunk, L2UCHAR tei) -{ - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, tei); - - link->T203 = 0; - - Q921Log(trunk, Q921_LOG_DEBUG, "T203 stopped for TEI %d\n", tei); -} - -static void Q921T203TimerReset(L2TRUNK trunk, L2UCHAR tei) -{ - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, tei); - - link->T203 = Q921GetTime() + trunk->T203Timeout; - - Q921Log(trunk, Q921_LOG_DEBUG, "T203 (timeout: %d msecs) restarted for TEI %d\n", trunk->T203Timeout, tei); -} - -/* - * T202 handling (TEI message timeout, TE mode only) - */ -static void Q921T202TimerStart(L2TRUNK trunk) -{ - if (!trunk->T202) { - trunk->T202 = Q921GetTime() + trunk->T202Timeout; - - Q921Log(trunk, Q921_LOG_DEBUG, "T202 (timeout: %d msecs) started\n", trunk->T202Timeout); - } -} - -static void Q921T202TimerStop(L2TRUNK trunk) -{ - trunk->T202 = 0; - - Q921Log(trunk, Q921_LOG_DEBUG, "T202 stopped\n"); -} - -static void Q921T202TimerReset(L2TRUNK trunk) -{ - trunk->T202 = Q921GetTime() + trunk->T202Timeout; - - Q921Log(trunk, Q921_LOG_DEBUG, "T202 (timeout: %d msecs) restarted\n", trunk->T202Timeout); -} - -/* - * T201 handling (TEI management (NT side), per-TEI) - */ -static void Q921T201TimerStart(L2TRUNK trunk, L2UCHAR tei) -{ - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, tei); - - if (!link->T201) { - link->T201 = Q921GetTime() + trunk->T201Timeout; - - Q921Log(trunk, Q921_LOG_DEBUG, "T201 (timeout: %d msecs) started for TEI %d\n", trunk->T201Timeout, tei); - } -} - -static void Q921T201TimerStop(L2TRUNK trunk, L2UCHAR tei) -{ - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, tei); - - link->T201 = 0; - - Q921Log(trunk, Q921_LOG_DEBUG, "T201 stopped for TEI %d\n", tei); -} - -#ifdef __UNUSED_FOR_NOW__ -static void Q921T201TimerReset(L2TRUNK trunk, L2UCHAR tei) -{ - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, tei); - - link->T201 = Q921GetTime() + trunk->T201Timeout; - - Q921Log(trunk, Q921_LOG_DEBUG, "T201 (timeout: %d msecs) restarted for TEI %d\n", trunk->T201Timeout, tei); -} -#endif - -/* - * TM01 handling (Datalink inactivity shutdown timer) - */ -static void Q921TM01TimerStart(L2TRUNK trunk, L2UCHAR tei) -{ - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, tei); - - if (!link->TM01) { - link->TM01 = Q921GetTime() + trunk->TM01Timeout; - - Q921Log(trunk, Q921_LOG_DEBUG, "TM01 (timeout: %d msecs) started for TEI %d\n", trunk->TM01Timeout, tei); - } -} - -#ifdef __UNUSED_FOR_NOW__ -static void Q921TM01TimerStop(L2TRUNK trunk, L2UCHAR tei) -{ - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, tei); - - link->TM01 = 0; - - Q921Log(trunk, Q921_LOG_DEBUG, "TM01 stopped for TEI %d\n", tei); -} -#endif - -static void Q921TM01TimerReset(L2TRUNK trunk, L2UCHAR tei) -{ - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, tei); - - link->TM01 = Q921GetTime() + trunk->TM01Timeout; - - Q921Log(trunk, Q921_LOG_DEBUG, "TM01 (timeout: %d msecs) restarted for TEI %d\n", trunk->TM01Timeout, tei); -} - -/* - * Expiry callbacks - */ -static void Q921T200TimerExpire(L2TRUNK trunk, L2UCHAR tei) -{ - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, tei); - struct Q921_Link *trlink = Q921_TRUNK_CONTEXT(trunk); - - Q921Log(trunk, Q921_LOG_DEBUG, "T200 expired for TEI %d (trunk TEI %d)\n", tei, trlink->tei); - - /* Stop timer first */ - Q921T200TimerStop(trunk, tei); - - switch(link->state) { - case Q921_STATE_AWAITING_ESTABLISHMENT: - if(link->N200 >= trunk->N200Limit) { - /* Discard I queue */ - MFIFOClear(link->IFrameQueue); - - /* MDL-Error indication (G) */ - Q921Log(trunk, Q921_LOG_ERROR, "Failed to establish Q.921 link in %d retries\n", link->N200); - - /* DL-Release indication */ - Q921Tx23Proc(trunk, Q921_DL_RELEASE, tei, NULL, 0); - - /* change state (no action) */ - Q921ChangeState(trunk, Q921_STATE_TEI_ASSIGNED, tei); - } else { - /* Increment retry counter */ - link->N200++; - - /* Send SABME */ - Q921SendSABME(trunk, - trunk->sapi, - Q921_COMMAND(trunk), - tei, - 1); - - /* Start T200 */ - Q921T200TimerStart(trunk, tei); - } - break; - - case Q921_STATE_MULTIPLE_FRAME_ESTABLISHED: - link->N200 = 0; - - if(!Q921_CHECK_FLAG(link, Q921_FLAG_PEER_RECV_BUSY)) { - /* get last transmitted I frame */ - - /* V(S) = V(S) - 1 */ - Q921_DEC_COUNTER(link->vs); - - /* retransmit I frame */ - - /* V(S) = V(S) + 1 (done by Q921SendI() ) */ - //Q921_INC_COUNTER(link->vs); - - /* clear acknowledge pending */ - Q921_CLEAR_FLAG(link, Q921_FLAG_ACK_PENDING); - - /* Start T200 */ - Q921T200TimerStart(trunk, tei); - } else { - /* transmit enquiry */ - Q921SendEnquiry(trunk, tei); - } - - /* increment counter */ - link->N200++; - - /* change state (no action) */ - Q921ChangeState(trunk, Q921_STATE_TIMER_RECOVERY, tei); - break; - - case Q921_STATE_TIMER_RECOVERY: - if(link->N200 == trunk->N200Limit) { - /* MDL Error indication (I) */ - - /* Establish data link */ - Q921EstablishDataLink(trunk, tei); - - /* Clear L3 initiated */ - Q921_CLEAR_FLAG(link, Q921_FLAG_L3_INITIATED); - - /* change state (no action) */ - Q921ChangeState(trunk, Q921_STATE_AWAITING_ESTABLISHMENT, tei); - } else { - if(link->vs == link->va) { - /* transmit enquiry */ - Q921SendEnquiry(trunk, tei); - - } else if(!Q921_CHECK_FLAG(link, Q921_FLAG_PEER_RECV_BUSY)) { - /* get last transmitted frame */ - - /* V(S) = V(S) - 1 */ - Q921_DEC_COUNTER(link->vs); - - /* retrans frame */ - - /* V(S) = V(S) + 1 (done by Q921SendI() ) */ - //Q921_INC_COUNTER(link->vs); - - /* clear acknowledge pending */ - Q921_CLEAR_FLAG(link, Q921_FLAG_ACK_PENDING); - - /* Start T200 */ - Q921T200TimerStart(trunk, tei); - } - - /* increment counter */ - link->N200++; - - /* no state change */ - } - break; - - default: - break; - } -} - -static void Q921T203TimerExpire(L2TRUNK trunk, L2UCHAR tei) -{ - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, tei); - struct Q921_Link *trlink = Q921_TRUNK_CONTEXT(trunk); - - Q921Log(trunk, Q921_LOG_DEBUG, "T203 expired for TEI %d (trunk TEI %d)\n", tei, trlink->tei); - - /* Stop Timer first */ - Q921T203TimerStop(trunk, tei); - - switch(link->state) { - case Q921_STATE_MULTIPLE_FRAME_ESTABLISHED: - /* Send Enquiry */ - Q921SendEnquiry(trunk, tei); - - /* RC = 0 */ - link->N200 = 0; - - /* no state change */ - break; - - default: - break; - } -} - -static void Q921T202TimerExpire(L2TRUNK trunk) -{ - struct Q921_Link *link = Q921_TRUNK_CONTEXT(trunk); - - Q921T202TimerReset(trunk); - - Q921Log(trunk, Q921_LOG_DEBUG, "T202 expired for Q.921 trunk with TEI %d\n", link->tei); - - /* todo: implement resend counter */ - - switch(link->state) { - case Q921_STATE_TEI_ASSIGNED: /* Tei identity verify timeout */ - Q921TeiSendVerifyRequest(trunk); - break; - - default: /* Tei assignment request timeout (TODO: refine) */ - - if(trunk->N202 >= trunk->N202Limit) { - /* Too many retransmits, reset counter, stop timer and handle case (TODO) */ - trunk->N202 = 0; - - Q921T202TimerStop(trunk); - - return; - } - Q921TeiSendAssignRequest(trunk); - - trunk->N202++; - } -} - -static void Q921T201TimerExpire(L2TRUNK trunk, L2UCHAR tei) -{ - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, tei); - struct Q921_Link *trlink = Q921_TRUNK_CONTEXT(trunk); - - Q921Log(trunk, Q921_LOG_DEBUG, "T201 expired for TEI %d (trunk TEI: %d)\n", tei, trlink->tei); - - Q921T201TimerStop(trunk, tei); - - /* NOTE: abusing N202 for this */ - if(link->N202 < trunk->N202Limit) { - /* send check request */ - Q921TeiSendCheckRequest(trunk, tei); - - /* increment counter */ - link->N202++; - } else { - /* put context in STOPPED state */ - Q921ChangeState(trunk, Q921_STATE_STOPPED, tei); - - /* NOTE: should we clear the link too? */ - memset(link, 0, sizeof(struct Q921_Link)); - - /* mark TEI free */ - trunk->tei_map[tei] = 0; - } -} - -#ifdef __UNUSED_FOR_NOW__ -static void Q921TM01TimerExpire(L2TRUNK trunk, L2UCHAR tei) -{ - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, tei); - struct Q921_Link *trlink = Q921_TRUNK_CONTEXT(trunk); - - Q921Log(trunk, Q921_LOG_DEBUG, "TM01 expired for TEI %d (trunk TEI: %d)\n", tei, trlink->tei); - - /* Restart TM01 */ - Q921TM01TimerReset(trunk, tei); - - switch(link->state) { - case Q921_STATE_MULTIPLE_FRAME_ESTABLISHED: - case Q921_STATE_TIMER_RECOVERY: -/* - * NT-only, needs more support from L3 - */ -#if 0 - /* No activity, shutdown link */ - Q921SendDISC(trunk, trunk->sapi, Q921_COMMAND(trunk), tei, 1); - - /* clear I queue */ - MFIFOClear(link->IFrameQueue); - - /* change state */ - Q921ChangeState(trunk, Q921_STATE_AWAITING_RELEASE, tei); -#endif - break; - - default: - break; - } -} -#endif - -/* - * Timer Tick function - */ -void Q921TimerTick(L2TRUNK trunk) -{ - struct Q921_Link *link; - L2ULONG tNow = Q921GetTime(); - int numlinks = Q921_IS_PTMP_NT(trunk) ? Q921_TEI_MAX : 1; - int x; - - for(x = 0; x <= numlinks; x++) { - link = Q921_LINK_CONTEXT(trunk, x); - - /* TODO: check if TEI is assigned and skip check if not (speedup!) */ - if(link->state == Q921_STATE_STOPPED) - continue; - - if (link->T200 && tNow > link->T200) { - Q921T200TimerExpire(trunk, link->tei); - } - if (link->T203 && tNow > link->T203) { - Q921T203TimerExpire(trunk, link->tei); - } - - if(Q921_IS_PTMP_NT(trunk) && link->tei) { - if (link->T201 && tNow > link->T201) { - Q921T201TimerExpire(trunk, link->tei); - } - } - - if(!Q921_IS_PTMP_NT(trunk)) { - if (trunk->T202 && tNow > trunk->T202) { - Q921T202TimerExpire(trunk); - } - } - - /* Send enqueued I frame, if available */ - Q921SendQueuedIFrame(trunk, link->tei); - - /* Send ack if pending */ - Q921AcknowledgePending(trunk, link->tei); - } - -} - -void Q921SetGetTimeCB(L2ULONG (*callback)(void)) -{ - Q921GetTimeProc = callback; -} - -/***************************************************************************** - - Function: Q921QueueHDLCFrame - - Description: Called to receive and queue an incoming HDLC frame. Will - queue this in Q921HDLCInQueue. The called must either call - Q921Rx12 directly afterwards or signal Q921Rx12 to be called - later. Q921Rx12 will read from the same queue and process - the frame. - - This function assumes that the message contains header - space. This is removed for internal Q921 processing, but - must be keept for I frames. - - Parameters: trunk trunk # - b ptr to frame; - size size of frame in bytes - -*****************************************************************************/ -int Q921QueueHDLCFrame(L2TRUNK trunk, L2UCHAR *b, L2INT size) -{ - return MFIFOWriteMes(trunk->HDLCInQueue, b, size); -} - -/** - * Q921EnqueueI - * \brief Put I frame into transmit queue - * - */ -static int Q921EnqueueI(L2TRUNK trunk, L2UCHAR Sapi, char cr, L2UCHAR Tei, char pf, L2UCHAR *mes, L2INT size) -{ - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, Tei); - - /* I frame header */ - mes[trunk->Q921HeaderSpace+0] = ((Sapi << 2) & 0xfc) | ((cr << 1) & 0x02); - mes[trunk->Q921HeaderSpace+1] = (Tei << 1) | 0x01; - mes[trunk->Q921HeaderSpace+2] = 0x00; - mes[trunk->Q921HeaderSpace+3] = (pf & 0x01); - - Q921Log(trunk, Q921_LOG_DEBUG, "Enqueueing I frame for TEI %d [%d]\n", link->tei, Tei); - - /* transmit queue, (TODO: check for full condition!) */ - MFIFOWriteMes(link->IFrameQueue, mes, size); - - /* try to send queued frame */ - Q921SendQueuedIFrame(trunk, link->tei); - - return 1; -} - -/** - * Q921SendQueuedIFrame - * \brief Try to transmit queued I frame (if available) - */ -static int Q921SendQueuedIFrame(L2TRUNK trunk, L2UCHAR tei) -{ - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, tei); - - L2INT size = 0; - L2UCHAR *mes; - - if(MFIFOGetMesCount(link->IFrameQueue) == 0) { - return 0; - } - - /* Link ready? */ - if(link->state != Q921_STATE_MULTIPLE_FRAME_ESTABLISHED) { - return 0; - } - - /* peer receiver busy? */ - if(Q921_CHECK_FLAG(link, Q921_FLAG_PEER_RECV_BUSY)) { - return 0; - } - - /* V(S) = V(A) + k? */ - if(link->vs == ((link->va + trunk->k) % 128)) { - Q921Log(trunk, Q921_LOG_WARNING, "Maximum number (%d) of outstanding I frames reached for TEI %d\n", trunk->k, tei); - return 0; - } - - mes = MFIFOGetMesPtr(link->IFrameQueue, &size); - if(mes) { - /* Fill in + update counter values */ - mes[trunk->Q921HeaderSpace+2] = link->vs << 1; - mes[trunk->Q921HeaderSpace+3] |= link->vr << 1; - - if(MFIFOGetMesCount(link->IFrameQueue) == 0) { - /* clear I frame queued */ - } - - /* Send I frame */ - Q921Tx21Proc(trunk, mes, size); - - /* V(S) = V(S) + 1 */ - Q921_INC_COUNTER(link->vs); - - /* clear acknowledge pending */ - Q921_CLEAR_FLAG(link, Q921_FLAG_ACK_PENDING); - - /* T200 running? */ - if(!link->T200) { - /* Stop T203, Start T200 */ - Q921T200TimerStart(trunk, tei); - Q921T203TimerStop(trunk, tei); - } - - /* put frame into resend queue */ - MFIFOWriteMesOverwrite(link->IFrameResendQueue, mes, size); - - /* dequeue frame */ - MFIFOKillNext(link->IFrameQueue); - - /* Restart TM01 */ - if(Q921_IS_NT(trunk)) { - Q921TM01TimerReset(trunk, tei); - } - - /* no state change */ - return 1; - } - - return 0; -} - -/** - * Q921SendS - * \brief Prepare and send S frame - */ -static int Q921SendS(L2TRUNK trunk, L2UCHAR Sapi, char cr, L2UCHAR Tei, char pf, L2UCHAR sv, L2UCHAR *mes, L2INT size) -{ - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, Tei); - - if(!Q921_IS_READY(link)) { - /* don't even bother trying */ - Q921Log(trunk, Q921_LOG_DEBUG, "Link not ready, discarding S frame for TEI %d\n", Tei); - return 0; - } - - /* S frame header */ - mes[trunk->Q921HeaderSpace+0] = ((Sapi << 2) & 0xfc) | ((cr << 1) & 0x02); - mes[trunk->Q921HeaderSpace+1] = (Tei << 1) | 0x01; - mes[trunk->Q921HeaderSpace+2] = ((sv << 2) & 0x0c) | 0x01; - mes[trunk->Q921HeaderSpace+3] = (link->vr << 1) | (pf & 0x01); - - return Q921Tx21Proc(trunk, mes, size); -} - - -/** - * Q921SendU - * \brief Prepare and send U frame - */ -static int Q921SendU(L2TRUNK trunk, L2UCHAR Sapi, char cr, L2UCHAR Tei, char pf, L2UCHAR m, L2UCHAR *mes, L2INT size) -{ - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, Tei); - - /* U frame header */ - mes[trunk->Q921HeaderSpace+0] = ((Sapi << 2) & 0xfc) | ((cr << 1) & 0x02); - mes[trunk->Q921HeaderSpace+1] = (Tei << 1) | 0x01; - mes[trunk->Q921HeaderSpace+2] = ((m << 3) & 0xe0) | ((pf << 4) & 0x10) | ((m << 2) & 0x0c) | 0x03; - - /* link not ready? enqueue non-TEI-mgmt UI (DL-UNIT DATA) frames */ - if(m == 0x00 && Sapi != Q921_SAPI_TEI && link->state < Q921_STATE_TEI_ASSIGNED) { - - /* write frame to queue */ - MFIFOWriteMes(link->UIFrameQueue, mes, size); - - Q921Log(trunk, Q921_LOG_DEBUG, "Link not ready, UI Frame of size %d bytes queued for TEI %d\n", size, Tei); - return 1; - } - - return Q921Tx21Proc(trunk, mes, size); -} - -/** - * TODO: NT mode handling? Need a way to get Link context from Q.931 - */ -int Q921Rx32(L2TRUNK trunk, Q921DLMsg_t ind, L2UCHAR tei, L2UCHAR * Mes, L2INT Size) -{ - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, tei); /* TODO: need real link tei for NT mode */ - L2INT res = 0; - - Q921Log(trunk, Q921_LOG_DEBUG, "Got frame from Q.931, type: %d, tei: %d, size: %d\n", ind, tei, Size); - - switch(ind) { - case Q921_DL_ESTABLISH: - /* - * Hmm... - */ - switch(link->state) { - case Q921_STATE_TEI_ASSIGNED: - if(!Q921_IS_NT(trunk)) { - /* establish data link */ - Q921EstablishDataLink(trunk, link->tei); - - /* Set layer 3 initiated */ - Q921_SET_FLAG(link, Q921_FLAG_L3_INITIATED); - - /* change state (no action) */ - Q921ChangeState(trunk, Q921_STATE_AWAITING_ESTABLISHMENT, link->tei); - } - break; - - case Q921_STATE_AWAITING_ESTABLISHMENT: - if(!Q921_IS_NT(trunk)) { - /* Discard I queue */ - MFIFOClear(link->IFrameQueue); - - /* Set layer 3 initiated */ - Q921_SET_FLAG(link, Q921_FLAG_L3_INITIATED); - } - break; - - case Q921_STATE_MULTIPLE_FRAME_ESTABLISHED: - case Q921_STATE_TIMER_RECOVERY: - if(!Q921_IS_NT(trunk)) { - /* Discard I queue */ - MFIFOClear(link->IFrameQueue); - - /* establish data link */ - Q921EstablishDataLink(trunk, link->tei); - - /* Set layer 3 initiated */ - Q921_SET_FLAG(link, Q921_FLAG_L3_INITIATED); - - /* change state (no action) */ - Q921ChangeState(trunk, Q921_STATE_AWAITING_ESTABLISHMENT, link->tei); - } - break; - - default: - break; - } - break; - - case Q921_DL_RELEASE: - switch(link->state) { - case Q921_STATE_TEI_ASSIGNED: - /* send DL-RELEASE confirm */ - Q921Tx23Proc(trunk, Q921_DL_RELEASE, tei, NULL, 0); - break; - - case Q921_STATE_MULTIPLE_FRAME_ESTABLISHED: - case Q921_STATE_TIMER_RECOVERY: - if(!Q921_IS_NT(trunk)) { - /* Discard I queue */ - MFIFOClear(link->IFrameQueue); - - /* RC = 0 */ - link->N200 = 0; - - /* send DISC command */ - Q921SendDISC(trunk, trunk->sapi, Q921_COMMAND(trunk), link->tei, 1); - - /* Stop T203, restart T200 */ - if(link->state == Q921_STATE_MULTIPLE_FRAME_ESTABLISHED) { - Q921T203TimerStop(trunk, link->tei); - } - Q921T200TimerReset(trunk, link->tei); - - /* change state */ - Q921ChangeState(trunk, Q921_STATE_AWAITING_RELEASE, link->tei); - } - break; - - default: - break; - } - break; - - case Q921_DL_DATA: /* DL-DATA request */ - res = Q921EnqueueI(trunk, - trunk->sapi, - Q921_COMMAND(trunk), - link->tei, - 0, - Mes, - Size); - - if(link->state < Q921_STATE_MULTIPLE_FRAME_ESTABLISHED) { - /* Treat as implicit DL-ESTABLISH request */ - - /* establish data link */ - Q921EstablishDataLink(trunk, link->tei); - - /* Set layer 3 initiated */ - Q921_SET_FLAG(link, Q921_FLAG_L3_INITIATED); - - /* change state (no action) */ - Q921ChangeState(trunk, Q921_STATE_AWAITING_ESTABLISHMENT, link->tei); - } - break; - - case Q921_DL_UNIT_DATA: /* DL-UNIT DATA request */ - res = Q921SendUN(trunk, - trunk->sapi, - Q921_COMMAND(trunk), - Q921_TEI_BCAST, - 0, - Mes, - Size); - /* NOTE: Let the other side initiate link establishment */ - break; - - default: - break; - } - - return res; -} -/***************************************************************************** - - Function: Q921SendRR - - Description: Compose and send Receive Ready. - - Parameters: trunk trunk # - Sapi Sapi - cr C/R field. - Tei Tei. - pf P/F fiels octet 5 - - Return Value: 0 if failed, 1 if Send. - -*****************************************************************************/ - -static int Q921SendRR(L2TRUNK trunk, int Sapi, int cr, int Tei, int pf) -{ - L2UCHAR mes[25]; - - return Q921SendS(trunk, Sapi, cr, Tei, pf, 0x00, mes, trunk->Q921HeaderSpace+4); -} - -/***************************************************************************** - - Function: Q921SendRNR - - Description: Compose and send Receive Nor Ready - - Parameters: trunk trunk # - Sapi Sapi - cr C/R field. - Tei Tei. - pf P/F fiels octet 5 - - Return Value: 0 if failed, 1 if Send. - -*****************************************************************************/ -static int Q921SendRNR(L2TRUNK trunk, int Sapi, int cr, int Tei, int pf) -{ - L2UCHAR mes[25]; - - return Q921SendS(trunk, Sapi, cr, Tei, pf, 0x01, mes, trunk->Q921HeaderSpace+4); -} - -/***************************************************************************** - - Function: Q921SendREJ - - Description: Compose and Send Reject. - - Parameters: trunk trunk # - Sapi Sapi - cr C/R field. - Tei Tei. - pf P/F fiels octet 5 - - Return Value: 0 if failed, 1 if Send. - -*****************************************************************************/ -static int Q921SendREJ(L2TRUNK trunk, int Sapi, int cr, int Tei, int pf) -{ - L2UCHAR mes[25]; - - return Q921SendS(trunk, Sapi, cr, Tei, pf, 0x03, mes, trunk->Q921HeaderSpace+4); -} - -/***************************************************************************** - - Function: Q921SendSABME - - Description: Compose and send SABME - - Parameters: trunk trunk # - Sapi Sapi - cr C/R field. - Tei Tei. - pf P fiels octet 4 - - Return Value: 0 if failed, 1 if Send. - -*****************************************************************************/ -static int Q921SendSABME(L2TRUNK trunk, int Sapi, int cr, int Tei, int pf) -{ - L2UCHAR mes[25]; - - return Q921SendU(trunk, Sapi, cr, Tei, pf, 0x0f, mes, trunk->Q921HeaderSpace+3); -} - - -/** - * Q921Start - * \brief Start trunk - * \param[in] trunk pointer to Q921 data struct - * \return > 0 on success; <= 0 on error - */ -int Q921Start(L2TRUNK trunk) -{ - int x, numlinks = Q921_IS_PTMP_NT(trunk) ? Q921_TEI_MAX : 1; - struct Q921_Link *link = Q921_TRUNK_CONTEXT(trunk); - - if(trunk->initialized != INITIALIZED_MAGIC) - return 0; - - memset(trunk->context, 0, numlinks * sizeof(struct Q921_Link)); - - /* Common init part */ - for(x = 0; x <= numlinks; x++) { - link = Q921_LINK_CONTEXT(trunk, x); - - link->state = Q921_STATE_TEI_UNASSIGNED; - link->tei = 0; - - /* Initialize per-TEI I + UI queues */ - MFIFOCreate(link->UIFrameQueue, Q921MAXHDLCSPACE, 10); - MFIFOCreate(link->IFrameQueue, Q921MAXHDLCSPACE, 10); - MFIFOCreate(link->IFrameResendQueue, Q921MAXHDLCSPACE, 10); - } - - if(Q921_IS_PTMP_TE(trunk)) { - link->state = Q921_STATE_TEI_UNASSIGNED; - link->tei = 0; - } - else if(Q921_IS_PTMP_NT(trunk)) { - link = Q921_TRUNK_CONTEXT(trunk); - - link->state = Q921_STATE_TEI_ASSIGNED; - link->tei = trunk->tei; - - /* clear tei map */ - memset(trunk->tei_map, 0, Q921_TEI_MAX + 1); - } - else { - link->state = Q921_STATE_TEI_ASSIGNED; - link->tei = trunk->tei; - } - - Q921Log(trunk, Q921_LOG_DEBUG, "Starting trunk %p (sapi: %d, tei: %d, mode: %s %s)\n", - trunk, - trunk->sapi, - link->tei, - Q921_IS_PTMP(trunk) ? "PTMP" : "PTP", - Q921_IS_TE(trunk) ? "TE" : "NT"); - - if(Q921_IS_PTP(trunk)) { - Q921Log(trunk, Q921_LOG_DEBUG, "Sending SABME\n"); - - return Q921SendSABME(trunk, - trunk->sapi, - Q921_COMMAND(trunk), - link->tei, - 1); - - } else if(Q921_IS_PTMP_NT(trunk)) { - - Q921Log(trunk, Q921_LOG_DEBUG, "Revoking all TEIs\n"); - - return Q921TeiSendRemoveRequest(trunk, Q921_TEI_BCAST); /* Revoke all TEIs in use */ - } else { - - Q921Log(trunk, Q921_LOG_DEBUG, "Requesting TEI\n"); - - return Q921TeiSendAssignRequest(trunk); - } -} - - -/** - * Q921Stop - * \brief Stop trunk - * \param[in] trunk pointer to Q921 data struct - * \return > 0 on success; <= 0 on error - * - * \author Stefan Knoblich - */ -int Q921Stop(L2TRUNK trunk) -{ - struct Q921_Link *link; - int x, numlinks; - - if(!trunk) - return -1; - - link = Q921_TRUNK_CONTEXT(trunk); - numlinks = Q921_IS_PTMP_NT(trunk) ? Q921_TEI_MAX : 1; - - if(Q921_IS_STOPPED(link)) - return 0; - - /* Release TEI */ - if(Q921_IS_PTMP_TE(trunk)) { - /* send verify request */ - Q921TeiSendVerifyRequest(trunk); - - /* drop TEI */ - link->tei = 0; - } - - /* Stop timers, stop link, flush queues */ - for(x = 0; x <= numlinks; x++) { - Q921T200TimerStop(trunk, x); - Q921T203TimerStop(trunk, x); - Q921T201TimerStop(trunk, x); - - /* Change state (no action) */ - Q921ChangeState(trunk, Q921_STATE_STOPPED, x); - - /* Flush per-tei I/UI queues */ - MFIFOClear(link->UIFrameQueue); - MFIFOClear(link->IFrameQueue); - MFIFOClear(link->IFrameResendQueue); - } - Q921T202TimerStop(trunk); - - /* Flush HDLC queue */ - MFIFOClear(trunk->HDLCInQueue); - - return 0; -} - - -/***************************************************************************** - - Function: Q921SendDM - - Description: Compose and Send DM (Disconnected Mode) - - Parameters: trunk trunk # - Sapi Sapi - cr C/R field. - Tei Tei. - pf F fiels octet 4 - - Return Value: 0 if failed, 1 if Send. - -*****************************************************************************/ -static int Q921SendDM(L2TRUNK trunk, int Sapi, int cr, int Tei, int pf) -{ - L2UCHAR mes[25]; - - return Q921SendU(trunk, Sapi, cr, Tei, pf, 0x03, mes, trunk->Q921HeaderSpace+3); -} - -/***************************************************************************** - - Function: Q921SendDISC - - Description: Compose and Send Disconnect - - Parameters: trunk trunk # - Sapi Sapi - cr C/R field. - Tei Tei. - pf P fiels octet 4 - - Return Value: 0 if failed, 1 if Send. - -*****************************************************************************/ -static int Q921SendDISC(L2TRUNK trunk, int Sapi, int cr, int Tei, int pf) -{ - L2UCHAR mes[25]; - - return Q921SendU(trunk, Sapi, cr, Tei, pf, 0x08, mes, trunk->Q921HeaderSpace+3); -} - -/***************************************************************************** - - Function: Q921SendUA - - Description: Compose and Send UA - - Parameters: trunk trunk # - Sapi Sapi - cr C/R field. - Tei Tei. - pf F fiels octet 4 - - Return Value: 0 if failed, 1 if Send. - -*****************************************************************************/ -static int Q921SendUA(L2TRUNK trunk, int Sapi, int cr, int Tei, int pf) -{ - L2UCHAR mes[25]; - - return Q921SendU(trunk, Sapi, cr, Tei, pf, 0x0c, mes, trunk->Q921HeaderSpace+3); -} - -static int Q921SendUN(L2TRUNK trunk, int Sapi, int cr, int Tei, int pf, L2UCHAR *mes, L2INT size) -{ - return Q921SendU(trunk, Sapi, cr, Tei, pf, 0x00, mes, size+trunk->Q921HeaderSpace+3); -} - - -/** - * Q921ProcSABME - * \brief Handle incoming SABME - * \param[in] trunk pointer to Q921 data struct - * \param[in] mes pointer to message buffer - * \param[in] size size of message - * \return > 0 on success, <= 0 on error - */ -static int Q921ProcSABME(L2TRUNK trunk, L2UCHAR *mes, L2INT size) -{ - L2UCHAR pf = (mes[2] & 0x10) >> 4; /* poll / final flag */ - L2UCHAR tei = (mes[1] & 0xfe) >> 1; - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, tei); - - switch(link->state) { - case Q921_STATE_TEI_ASSIGNED: - /* send UA */ - Q921SendUA(trunk, - trunk->sapi, - Q921_RESPONSE(trunk), /* or command? */ - tei, pf); - - /* clear counters */ - link->vr=0; - link->vs=0; - link->va=0; - - /* TODO: send DL-Establish indication to Q.931 */ - Q921Tx23Proc(trunk, Q921_DL_ESTABLISH, tei, NULL, 0); - - /* start T203 */ - Q921T203TimerStart(trunk, tei); - - /* change state (no action) */ - Q921ChangeState(trunk, Q921_STATE_MULTIPLE_FRAME_ESTABLISHED, tei); - break; - - case Q921_STATE_AWAITING_ESTABLISHMENT: - /* send UA */ - Q921SendUA(trunk, - trunk->sapi, - Q921_RESPONSE(trunk), - tei, pf); - - /* no state change */ - break; - - case Q921_STATE_AWAITING_RELEASE: - /* send DM */ - Q921SendDM(trunk, - trunk->sapi, - Q921_RESPONSE(trunk), - tei, pf); - - /* no state change */ - break; - - case Q921_STATE_MULTIPLE_FRAME_ESTABLISHED: - case Q921_STATE_TIMER_RECOVERY: - /* send UA */ - Q921SendUA(trunk, - trunk->sapi, - Q921_RESPONSE(trunk), - tei, pf); - - /* clear exception conditions */ - Q921ResetExceptionConditions(trunk, tei); - - /* send MDL-Error indication */ - - /* V(S) == V(A) ? */ - if(link->vs != link->va) { - /* clear I queue */ - MFIFOClear(link->IFrameQueue); - - /* DL-Establish indication */ - Q921Tx23Proc(trunk, Q921_DL_ESTABLISH, tei, NULL, 0); - } - - /* clear counters */ - link->vr=0; - link->vs=0; - link->va=0; - - /* Stop T200, start T203 */ - Q921T200TimerStop(trunk, tei); - Q921T203TimerStart(trunk, tei); - - /* state change only if in TIMER_RECOVERY state */ - if(link->state == Q921_STATE_TIMER_RECOVERY) - Q921ChangeState(trunk, Q921_STATE_MULTIPLE_FRAME_ESTABLISHED, tei); - break; - - default: - break; - } - - return 1; -} - - -/** - * Q921ProcDM - * \brief Handle incoming DM - * \param[in] trunk pointer to Q921 data struct - * \param[in] mes pointer to message buffer - * \param[in] size size of message - * \return > 0 on success, <= 0 on error - */ -static int Q921ProcDM(L2TRUNK trunk, L2UCHAR *mes, L2INT size) -{ - L2UCHAR pf = (mes[2] & 0x10) >> 4; /* poll / final flag */ - L2UCHAR tei = (mes[1] & 0xfe) >> 1; - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, tei); - - switch(link->state) { - case Q921_STATE_TEI_ASSIGNED: - if(!pf) { - /* to next state (no action) */ - Q921ChangeState(trunk, Q921_STATE_AWAITING_ESTABLISHMENT, tei); - } - break; - - case Q921_STATE_AWAITING_ESTABLISHMENT: - case Q921_STATE_AWAITING_RELEASE: - if(pf) { - if(link->state == Q921_STATE_AWAITING_ESTABLISHMENT) { - /* Discard I queue */ - MFIFOClear(link->IFrameQueue); - } - - /* Send DL-Release indication to Q.931 */ - Q921Tx23Proc(trunk, Q921_DL_RELEASE, tei, NULL, 0); - - /* Stop T200 */ - Q921T200TimerStop(trunk, tei); - - /* Change state (no action) */ - Q921ChangeState(trunk, Q921_STATE_TEI_ASSIGNED, tei); - } - break; - - case Q921_STATE_MULTIPLE_FRAME_ESTABLISHED: - if(pf) { - /* MDL-Error indication (B) */ - - /* no state change */ - } else { - /* MDL-Error indication (E) */ - - /* establish data link */ - Q921EstablishDataLink(trunk, tei); - - /* clear L3 initiated */ - Q921_CLEAR_FLAG(link, Q921_FLAG_L3_INITIATED); - - /* change state (no action?) */ - Q921ChangeState(trunk, Q921_STATE_AWAITING_ESTABLISHMENT, tei); - } - break; - - case Q921_STATE_TIMER_RECOVERY: - if(pf) { - /* MDL Error indication (B) */ - } else { - /* MDL Error indication (E) */ - } - - /* establish data link */ - Q921EstablishDataLink(trunk, tei); - - /* clear layer 3 initiated */ - Q921_CLEAR_FLAG(link, Q921_FLAG_L3_INITIATED); - - /* change state */ - Q921ChangeState(trunk, Q921_STATE_AWAITING_ESTABLISHMENT, tei); - break; - - default: - break; - } - - return 1; -} - -/** - * Q921ProcUA - * \brief Handle incoming UA - * \param[in] trunk pointer to Q921 data struct - * \param[in] mes pointer to message buffer - * \param[in] size size of message - * \return > 0 on success, <= 0 on error - */ -static int Q921ProcUA(L2TRUNK trunk, L2UCHAR *mes, L2INT size) -{ - L2UCHAR pf = (mes[2] & 0x10) >> 4; /* poll / final flag */ - L2UCHAR tei = (mes[1] & 0xfe) >> 1; - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, tei); - - switch(link->state) { - case Q921_STATE_TEI_ASSIGNED: - case Q921_STATE_TIMER_RECOVERY: - /* MDL Error indication (C, D) */ - Q921Log(trunk, Q921_LOG_ERROR, "Received UA frame in invalid state\n"); - break; - - case Q921_STATE_AWAITING_ESTABLISHMENT: - if(pf) { - /* TODO: other fancy stuff (see docs) */ - if(Q921_CHECK_FLAG(link, Q921_FLAG_L3_INITIATED)) { /* layer3 initiated */ - link->vr = 0; - - /* DL-Establish confirm */ - Q921Tx23Proc(trunk, Q921_DL_ESTABLISH_CONFIRM, tei, NULL, 0); - - } else if(link->vs != link->va) { - - /* discard I queue */ - MFIFOClear(link->IFrameQueue); - - /* DL-Establish indication */ - Q921Tx23Proc(trunk, Q921_DL_ESTABLISH, tei, NULL, 0); - } - - /* Stop T200, start T203 */ - Q921T200TimerStop(trunk, tei); - Q921T203TimerStart(trunk, tei); - - link->vs = 0; - link->va = 0; - - /* change state (no action) */ - Q921ChangeState(trunk, Q921_STATE_MULTIPLE_FRAME_ESTABLISHED, tei); - } else { - /* MDL Error indication (C, D) */ - Q921Log(trunk, Q921_LOG_ERROR, "Received UA frame is not a response to a request\n"); - - /* no state change */ - } - break; - - case Q921_STATE_AWAITING_RELEASE: - if(pf) { - /* DL Release confirm */ - Q921Tx23Proc(trunk, Q921_DL_RELEASE_CONFIRM, tei, NULL, 0); - - /* Stop T200 */ - Q921T200TimerStop(trunk, tei); - - /* change state (no action) */ - Q921ChangeState(trunk, Q921_STATE_TEI_ASSIGNED, tei); - } else { - /* MDL Error indication (D) */ - Q921Log(trunk, Q921_LOG_ERROR, "Received UA frame is not a response to a request\n"); - - /* no state change */ - } - break; - - case Q921_STATE_MULTIPLE_FRAME_ESTABLISHED: - /* MDL Error indication (C, D) */ - Q921Log(trunk, Q921_LOG_ERROR, "Received UA frame in invalid state\n"); - - /* no state change */ - break; - - default: - break; - } - - return 1; -} - - -/** - * Q921ProcDISC - * \brief Handle incoming DISC - * \param[in] trunk pointer to Q921 data struct - * \param[in] mes pointer to message buffer - * \param[in] size size of message - * \return > 0 on success, <= 0 on error - */ -static int Q921ProcDISC(L2TRUNK trunk, L2UCHAR *mes, L2INT size) -{ - L2UCHAR pf = (mes[2] & 0x10) >> 4; /* poll / final flag */ - L2UCHAR tei = (mes[1] & 0xfe) >> 1; - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, tei); - - switch(link->state) { - case Q921_STATE_TEI_ASSIGNED: - case Q921_STATE_AWAITING_ESTABLISHMENT: - /* Send DM */ - Q921SendDM(trunk, - trunk->sapi, - Q921_RESPONSE(trunk), - tei, pf); - - /* no state change */ - break; - - case Q921_STATE_AWAITING_RELEASE: - Q921SendUA(trunk, - trunk->sapi, - Q921_RESPONSE(trunk), - tei, pf); - - /* no state change */ - break; - - case Q921_STATE_MULTIPLE_FRAME_ESTABLISHED: - case Q921_STATE_TIMER_RECOVERY: - /* Discard I queue */ - MFIFOClear(link->IFrameQueue); - - /* send UA */ - Q921SendUA(trunk, - trunk->sapi, - Q921_RESPONSE(trunk), - tei, pf); - - /* DL Release indication */ - Q921Tx23Proc(trunk, Q921_DL_RELEASE, tei, NULL, 0); - - /* Stop T200 */ - Q921T200TimerStop(trunk, tei); - - if(link->state == Q921_STATE_MULTIPLE_FRAME_ESTABLISHED) { - /* Stop T203 */ - Q921T203TimerStop(trunk, tei); - } - - /* change state (no action) */ - Q921ChangeState(trunk, Q921_STATE_TEI_ASSIGNED, tei); - break; - - default: - Q921Log(trunk, Q921_LOG_ERROR, "Invalid DISC received in state \"%s\" (%d)", Q921State2Name(link->state), link->state); - break; - } - - return 1; -} - - -/** - * Q921ProcRR - * \brief Handle incoming RR - * \param[in] trunk pointer to Q921 data struct - * \param[in] mes pointer to message buffer - * \param[in] size size of message - * \return > 0 on success, <= 0 on error - */ -static int Q921ProcRR(L2TRUNK trunk, L2UCHAR *mes, L2INT size) -{ - L2UCHAR cr = (mes[0] & 0x02) >> 1; - L2UCHAR pf = mes[3] & 0x01; /* poll / final flag */ - L2UCHAR nr = (mes[3] >> 1); -// L2UCHAR sapi = (mes[0] & 0xfc) >> 2; - L2UCHAR tei = (mes[1] & 0xfe) >> 1; - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, tei); - - switch(link->state) { - case Q921_STATE_MULTIPLE_FRAME_ESTABLISHED: - /* clear receiver peer busy */ - Q921_CLEAR_FLAG(link, Q921_FLAG_PEER_RECV_BUSY); - - if (Q921_IS_COMMAND(trunk, cr)) { /* if this is a command */ - if(pf) { - /* Enquiry response */ - Q921SendEnquiryResponse(trunk, tei); - } - } else { - if(pf) { - /* MDL Error indication */ - } - } - - /* */ - if(link->va <= nr && nr <= link->vs) { - - if(nr == link->vs) { - /* V(A) = N(R) */ - link->va = nr; - - /* Stop T200, restart T203 */ - Q921T200TimerStop(trunk, tei); - Q921T203TimerReset(trunk, tei); - - } else if(nr == link->va) { - - /* do nothing */ - - } else { - /* V(A) = N(R) */ - link->va = nr; - - /* Restart T200 */ - Q921T200TimerReset(trunk, tei); - } - /* no state change */ - - } else { - /* N(R) Error recovery */ - Q921NrErrorRecovery(trunk, tei); - - /* change state (no action) */ - Q921ChangeState(trunk, Q921_STATE_AWAITING_ESTABLISHMENT, tei); - } - break; - - case Q921_STATE_TIMER_RECOVERY: - /* clear receiver peer busy */ - Q921_CLEAR_FLAG(link, Q921_FLAG_PEER_RECV_BUSY); - - /* command + P? */ - if(Q921_IS_COMMAND(trunk, cr) && pf) { - /* Enquiry response */ - Q921SendEnquiryResponse(trunk, tei); - } - - /* */ - if(link->va <= nr && nr <= link->vs) { - /* V(A) = N(R) */ - link->va = nr; - - if(!Q921_IS_COMMAND(trunk, cr) && pf) { - /* Stop T200, start T203 */ - Q921T200TimerStop(trunk, tei); - Q921T203TimerStart(trunk, tei); - - /* Invoke retransmission */ - Q921InvokeRetransmission(trunk, tei, nr); - - /* change state (no action) */ - Q921ChangeState(trunk, Q921_STATE_MULTIPLE_FRAME_ESTABLISHED, tei); - } - /* no state change otherwise */ - } else { - /* N(R) Error recovery */ - Q921NrErrorRecovery(trunk, tei); - - /* change state (no action) */ - Q921ChangeState(trunk, Q921_STATE_AWAITING_ESTABLISHMENT, tei); - } - break; - - default: - break; - } - return 1; -} - - -/** - * Q921ProcREJ - * \brief Handle incoming REJ - * \param[in] trunk pointer to Q921 data struct - * \param[in] mes pointer to message buffer - * \param[in] size size of message - * \return > 0 on success, <= 0 on error - */ -static int Q921ProcREJ(L2TRUNK trunk, L2UCHAR *mes, L2INT size) -{ - L2UCHAR cr = (mes[0] & 0x02) >> 1; - L2UCHAR pf = mes[3] & 0x01; /* poll / final flag */ - L2UCHAR nr = (mes[3] >> 1); -// L2UCHAR sapi = (mes[0] & 0xfc) >> 2; - L2UCHAR tei = (mes[1] & 0xfe) >> 1; - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, tei); - - switch(link->state) { - case Q921_STATE_MULTIPLE_FRAME_ESTABLISHED: - /* clear receiver peer busy */ - Q921_CLEAR_FLAG(link, Q921_FLAG_PEER_RECV_BUSY); - - /* command? */ - if(Q921_IS_COMMAND(trunk, cr)) { - if(pf) { - /* Enquiry response */ - Q921SendEnquiryResponse(trunk, tei); - } - } else { - if(pf) { - /* MDL Error indication (A) */ - } - } - - /* */ - if(link->va <= nr && nr <= link->vs) { - - /* V(A) = N(R) */ - link->va = nr; - - /* Stop T200, start T203 */ - Q921T200TimerStop(trunk, tei); - Q921T203TimerStart(trunk, tei); - - /* Invoke retransmission of frame >N(R) (?) */ - Q921InvokeRetransmission(trunk, tei, nr); - - /* no state change */ - } else { - /* N(R) Error recovery */ - Q921NrErrorRecovery(trunk, tei); - - /* change state (no action) */ - Q921ChangeState(trunk, Q921_STATE_AWAITING_ESTABLISHMENT, tei); - } - break; - - case Q921_STATE_TIMER_RECOVERY: - /* clear receiver peer busy */ - Q921_CLEAR_FLAG(link, Q921_FLAG_PEER_RECV_BUSY); - - /* command + P ? */ - if(Q921_IS_COMMAND(trunk, cr) && pf) { - /* Enquiry response */ - Q921SendEnquiryResponse(trunk, tei); - } - - /* */ - if(link->va <= nr && nr <= link->vs) { - - /* V(A) = N(R) */ - link->va = nr; - - if(!Q921_IS_COMMAND(trunk, cr) && pf) { - /* Stop T200, start T203 */ - Q921T200TimerStop(trunk, tei); - Q921T203TimerStart(trunk, tei); - - /* Invoke retransmission */ - Q921InvokeRetransmission(trunk, tei, nr); - - /* change state (no action) */ - Q921ChangeState(trunk, Q921_STATE_MULTIPLE_FRAME_ESTABLISHED, tei); - } - /* no state change otherwise */ - } else { - /* N(R) Error recovery */ - Q921NrErrorRecovery(trunk, tei); - - /* change state (no action) */ - Q921ChangeState(trunk, Q921_STATE_AWAITING_ESTABLISHMENT, tei); - } - break; - - default: - break; - } - - return 1; -} - - -/** - * Q921ProcRNR - * \brief Handle incoming RNR - * \param[in] trunk pointer to Q921 data struct - * \param[in] mes pointer to message buffer - * \param[in] size size of message - * \return > 0 on success, <= 0 on error - */ -static int Q921ProcRNR(L2TRUNK trunk, L2UCHAR *mes, L2INT size) -{ - L2UCHAR cr = (mes[0] & 0x02) >> 1; - L2UCHAR pf = mes[3] & 0x01; /* poll / final flag */ - L2UCHAR nr = (mes[3] >> 1); -// L2UCHAR sapi = (mes[0] & 0xfc) >> 2; - L2UCHAR tei = (mes[1] & 0xfe) >> 1; - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, tei); - - switch(link->state) { - case Q921_STATE_MULTIPLE_FRAME_ESTABLISHED: - /* set peer receiver busy */ - Q921_SET_FLAG(link, Q921_FLAG_PEER_RECV_BUSY); - - /* command? */ - if(Q921_IS_COMMAND(trunk, cr)) { - if(pf) { - /* Enquiry response */ - Q921SendEnquiryResponse(trunk, tei); - } - } else { - if(pf) { - /* MDL Error indication (A) */ - } - } - - /* */ - if(link->va <= nr && nr <= link->vs) { - - /* V(A) = N(R) */ - link->va = nr; - - /* Stop T203, restart T200 */ - Q921T200TimerReset(trunk, tei); - Q921T203TimerStop(trunk, tei); - - /* no state change */ - } else { - /* N(R) Error recovery */ - Q921NrErrorRecovery(trunk, tei); - - /* change state (no action) */ - Q921ChangeState(trunk, Q921_STATE_AWAITING_ESTABLISHMENT, tei); - } - break; - - case Q921_STATE_TIMER_RECOVERY: - /* set peer receiver busy */ - Q921_SET_FLAG(link, Q921_FLAG_PEER_RECV_BUSY); - - /* command + P? */ - if(Q921_IS_COMMAND(trunk, cr) && pf) { - /* Enquiry response */ - Q921SendEnquiryResponse(trunk, tei); - } - - /* */ - if(link->va <= nr && nr <= link->vs) { - - /* V(A) = N(R) */ - link->va = nr; - - if(!Q921_IS_COMMAND(trunk, cr) && pf) { - /* Restart T200 */ - Q921T200TimerReset(trunk, tei); - - /* Invoke retransmission */ - Q921InvokeRetransmission(trunk, tei, nr); - - /* change state (no action) */ - Q921ChangeState(trunk, Q921_STATE_MULTIPLE_FRAME_ESTABLISHED, tei); - } - /* no state change otherwise */ - } else { - /* N(R) Error recovery */ - Q921NrErrorRecovery(trunk, tei); - - /* change state (no action) */ - Q921ChangeState(trunk, Q921_STATE_AWAITING_ESTABLISHMENT, tei); - } - break; - - default: - break; - } - - return 1; -} - -#if 0 -static int Q921SetReceiverBusy(L2TRUNK trunk) -{ - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, tei); - - switch(link->state) { - case Q921_STATE_MULTIPLE_FRAME_ESTABLISHED: - if(!Q921_CHECK_FLAG(link, Q921_FLAG_RECV_BUSY)) { - /* set own receiver busy */ - Q921_SET_FLAG(link, Q921_FLAG_RECV_BUSY); - - /* send RR response */ - Q921SendRR(trunk, trunk->sapi, Q921_RESPONSE(trunk), link->tei, 0); - - /* clear ack pending */ - Q921_CLEAR_FLAG(link, Q921_FLAG_ACK_PENDING); - } - break; - - case Q921_STATE_TIMER_RECOVERY: - if(!Q921_CHECK_FLAG(link, Q921_FLAG_RECV_BUSY)) { - /* set own receiver busy */ - Q921_SET_FLAG(link, Q921_FLAG_RECV_BUSY); - - /* send RNR response */ - Q921SendRNR(trunk, trunk->sapi, Q921_RESPONSE(trunk), link->tei, 0); - - /* clear ack pending */ - Q921_CLEAR_FLAG(link, Q921_FLAG_ACK_PENDING); - } - break; - - default: - break; - } - - return 0; -} - -static int Q921ClearReceiverBusy(L2TRUNK trunk) -{ - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, tei); - - switch(link->state) { - case Q921_STATE_MULTIPLE_FRAME_ESTABLISHED: - case Q921_STATE_TIMER_RECOVERY: - if(Q921_CHECK_FLAG(link, Q921_FLAG_RECV_BUSY)) { - /* clear own receiver busy */ - Q921_CLEAR_FLAG(link, Q921_FLAG_RECV_BUSY); - - /* send RNR response */ - Q921SendRNR(trunk, trunk->sapi, Q921_RESPONSE(trunk), link->tei, 0); - - /* clear ack pending */ - Q921_CLEAR_FLAG(link, Q921_FLAG_ACK_PENDING); - } - break; - - default: - break; - } - - return 0; -} -#endif - -static int Q921ProcIFrame(L2TRUNK trunk, L2UCHAR *mes, L2INT size) -{ - /* common fields: get sapi, tei and cr */ -// L2UCHAR sapi = (mes[0] & 0xfc) >> 2; -// L2UCHAR cr = (mes[0] & 0x02) >> 1; - L2UCHAR tei = (mes[1] & 0xfe) >> 1; - L2UCHAR pf = mes[3] & 0x01; /* poll / final flag */ - L2UCHAR nr = mes[3] >> 1; /* receive sequence number */ - L2UCHAR ns = mes[2] >> 1; /* send sequence number */ - L2UCHAR discard = 0; - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, tei); - - /* Ignore I frames in earlier states */ - if(link->state < Q921_STATE_MULTIPLE_FRAME_ESTABLISHED) { - Q921Log(trunk, Q921_LOG_NOTICE, "I frame in invalid state ignored\n"); - return 0; - } - - /* Receiver busy? */ - if(Q921_CHECK_FLAG(link, Q921_FLAG_RECV_BUSY)) { - /* discard information */ - discard = 1; - - if(pf) { - /* send RNR Response */ - Q921SendRNR(trunk, trunk->sapi, Q921_RESPONSE(trunk), tei, 1); - - /* Clear ack pending */ - Q921_CLEAR_FLAG(link, Q921_FLAG_ACK_PENDING); - } - } - else { - if(ns != link->vr) { - /* discard information */ - discard = 1; - - if(Q921_CHECK_FLAG(link, Q921_FLAG_REJECT) && pf) { - - /* Send RR response */ - Q921SendRR(trunk, trunk->sapi, Q921_RESPONSE(trunk), tei, 1); - - /* clear ack pending */ - Q921_CLEAR_FLAG(link, Q921_FLAG_ACK_PENDING); - } - else if(!Q921_CHECK_FLAG(link, Q921_FLAG_REJECT)){ - - /* set reject exception */ - Q921_SET_FLAG(link, Q921_FLAG_REJECT); - - /* Send REJ response */ - Q921SendREJ(trunk, trunk->sapi, Q921_RESPONSE(trunk), tei, pf); - - /* clear ack pending */ - Q921_CLEAR_FLAG(link, Q921_FLAG_ACK_PENDING); - } - } - else { - /* V(R) = V(R) + 1 */ - Q921_INC_COUNTER(link->vr); - - /* clear reject exception */ - Q921_CLEAR_FLAG(link, Q921_FLAG_REJECT); - - /* DL-Data indication */ - Q921Tx23Proc(trunk, Q921_DL_DATA, tei, mes, size); - - if(pf) { - /* Send RR response */ - Q921SendRR(trunk, trunk->sapi, Q921_RESPONSE(trunk), tei, 1); - - /* clear ack pending */ - Q921_CLEAR_FLAG(link, Q921_FLAG_ACK_PENDING); - } - else if(!Q921_CHECK_FLAG(link, Q921_FLAG_ACK_PENDING)) { - /* ack pending */ - - /* Send RR response */ - Q921SendRR(trunk, trunk->sapi, Q921_RESPONSE(trunk), tei, 0); - - /* set ack pending*/ - Q921_SET_FLAG(link, Q921_FLAG_ACK_PENDING); - } - } - } - - - switch(link->state) { - case Q921_STATE_MULTIPLE_FRAME_ESTABLISHED: - if(link->va <= nr && nr <= link->vs) { - if(Q921_CHECK_FLAG(link, Q921_FLAG_PEER_RECV_BUSY)) { - link->va = nr; - } - else if(nr == link->vs) { - /* V(A) = N(R) */ - link->va = nr; - - /* stop t200, restart t203 */ - Q921T200TimerStop(trunk, tei); - Q921T203TimerReset(trunk, tei); - } - else if(nr != link->va) { - /* V(A) = N(R) */ - link->va = nr; - - /* restart T200 */ - Q921T200TimerReset(trunk, tei); - } - - /* Restart TM01 */ - if(Q921_IS_NT(trunk)) { - Q921TM01TimerReset(trunk, tei); - } - } - else { - /* N(R) error recovery */ - Q921NrErrorRecovery(trunk, tei); - - /* change state (no action) */ - Q921ChangeState(trunk, Q921_STATE_AWAITING_ESTABLISHMENT, tei); - } - break; - - case Q921_STATE_TIMER_RECOVERY: - if(link->va <= nr && nr <= link->vs) { - /* V(A) = N(R) */ - link->va = nr; - - /* Restart TM01 */ - if(Q921_IS_NT(trunk)) { - Q921TM01TimerReset(trunk, tei); - } - } - else { - /* N(R) error recovery */ - Q921NrErrorRecovery(trunk, tei); - - /* change state (no action) */ - Q921ChangeState(trunk, Q921_STATE_AWAITING_ESTABLISHMENT, tei); - } - break; - - default: - break; - } - - return 0; -} - - -static int Q921ProcSFrame(L2TRUNK trunk, L2UCHAR *mes, L2INT size) -{ - L2UCHAR sv = (mes[2] & 0x0c) >> 2; /* supervisory format id */ - //L2UCHAR pf = mes[3] & 0x01; /* poll / final flag */ - //L2UCHAR nr = mes[3] >> 1; /* receive sequence number */ - L2INT res = -1; - - switch(sv) { - case 0x00: /* RR : Receive Ready */ - res = Q921ProcRR(trunk, mes, size); - break; - - case 0x02: /* RNR : Receive Not Ready */ - res = Q921ProcRNR(trunk, mes, size); - break; - - case 0x04: /* REJ : Reject */ - res = Q921ProcREJ(trunk, mes, size); - break; - - default: /* Invalid / Unknown */ - Q921Log(trunk, Q921_LOG_ERROR, "Invalid S frame type %d\n", sv); - break; - } - - return res; -} - - - -static int Q921ProcUFrame(L2TRUNK trunk, L2UCHAR *mes, L2INT size) -{ - L2UCHAR m = (mes[2] & 0xe0) >> 3 | (mes[2] & 0x0c) >> 2; /* modifier function id */ -// L2UCHAR pf = (mes[2] & 0x10) >> 4; /* poll / final flag */ - L2INT res = -1; - - switch(m) { - case 0x00: /* UN : Unnumbered Information */ - if(mes[3] == Q921_LAYER_ENT_ID_TEI) - { - if(!Q921_IS_PTMP(trunk)) { - /* wtf? nice try */ - return res; - } - - switch(mes[6]) { - case Q921_TEI_ID_REQUEST: /* (TE ->) NT */ - res = Q921TeiProcAssignRequest(trunk, mes, size); - break; - - case Q921_TEI_ID_ASSIGNED: /* (NT ->) TE */ - case Q921_TEI_ID_DENIED: - res = Q921TeiProcAssignResponse(trunk, mes, size); - break; - - case Q921_TEI_ID_CHECKREQ: /* (NT ->) TE */ - res = Q921TeiProcCheckRequest(trunk, mes, size); - break; - - case Q921_TEI_ID_CHECKRESP: /* (TE ->) NT */ - res = Q921TeiProcCheckResponse(trunk, mes, size); - break; - - case Q921_TEI_ID_REMOVE: /* (NT ->) TE */ - res = Q921TeiProcRemoveRequest(trunk, mes, size); - break; - - case Q921_TEI_ID_VERIFY: /* (TE ->) NT */ - res = Q921TeiProcVerifyRequest(trunk, mes, size); - break; - - default: /* Invalid / Unknown */ - Q921Log(trunk, Q921_LOG_ERROR, "Invalid UN message from TEI management/endpoint\n"); - break; - } - } - else if(mes[3] == Q921_LAYER_ENT_ID_Q931) { - - Q921Log(trunk, Q921_LOG_DEBUG, "UI Frame for Layer 3 received\n"); - - res = Q921Tx23Proc(trunk, Q921_DL_UNIT_DATA, 0, mes, size); - } - break; - - case 0x03: /* DM : Disconnect Mode */ - res = Q921ProcDM(trunk, mes, size); - break; - - case 0x08: /* DISC : Disconnect */ - res = Q921ProcDISC(trunk, mes, size); - break; - - case 0x0c: /* UA : Unnumbered Acknowledgement */ - res = Q921ProcUA(trunk, mes, size); - break; - - case 0x0f: /* SABME : Set Asynchronous Balanced Mode Extend */ - res = Q921ProcSABME(trunk, mes, size); - break; - - case 0x11: /* FRMR : Frame Reject */ - case 0x17: /* XID : Exchange Identification */ - res = 0; - break; - - default: /* Unknown / Invalid */ - Q921Log(trunk, Q921_LOG_ERROR, "Invalid U frame type: %d\n", m); - break; - } - - return res; -} - - -/***************************************************************************** - - Function: Q921Rx12 - - Description: Called to process a message frame from layer 1. Will - identify the message and call the proper 'processor' for - layer 2 messages and forward I frames to the layer 3 entity. - - Q921Rx12 will check the input fifo for a message, and if a - message exist process one message before it exits. The caller - must either call Q921Rx12 polling or keep track on # - messages in the queue. - - Parameters: trunk trunk #. - - Return Value: # messages processed (always 1 or 0). - -*****************************************************************************/ -int Q921Rx12(L2TRUNK trunk) -{ - L2INT size; /* receive size & Q921 frame size*/ - L2UCHAR *smes = MFIFOGetMesPtr(trunk->HDLCInQueue, &size); - - if(smes) - { - struct Q921_Link *link; - L2UCHAR sapi, tei; - L2UCHAR *mes; - L2INT rs; - - rs = size - trunk->Q921HeaderSpace; - mes = &smes[trunk->Q921HeaderSpace]; - - Q921LogMesg(trunk, Q921_LOG_DEBUG, 1, mes, rs, "New packet received (%d bytes)", rs); - - /* common fields: get sapi, tei and cr */ - sapi = (mes[0] & 0xfc) >> 2; - tei = (mes[1] & 0xfe) >> 1; - link = Q921_LINK_CONTEXT(trunk, tei); - - if(Q921_IS_PTMP_TE(trunk) && ( - (link->state >= Q921_STATE_TEI_ASSIGNED && tei != link->tei && tei != Q921_TEI_BCAST) || /* Assigned TEI: Only BCAST and directed */ - (link->state == Q921_STATE_TEI_UNASSIGNED && tei != Q921_TEI_BCAST))) /* No assigned TEI: Only BCAST */ - { - /* Ignore Messages with foreign TEIs */ - goto out; - } - - if((mes[2] & 0x01) == 0x00) { /* I frame */ - Q921ProcIFrame(trunk, mes, rs); - } - else if((mes[2] & 0x03) == 0x01) { /* S frame */ - Q921ProcSFrame(trunk, mes, rs); - } - else if((mes[2] & 0x03) == 0x03) { /* U frame */ - Q921ProcUFrame(trunk, mes, rs); - } - else { - Q921Log(trunk, Q921_LOG_ERROR, "Invalid frame type: %d\n", (int)(mes[2] & 0x03)); - /* TODO: send FRMR or REJ */ - } - -out: - MFIFOKillNext(trunk->HDLCInQueue); - - return 1; - } - - return 0; -} - -/* - * Misc - */ -/** - * Q921SetLogCB - * \brief Set logging callback - * \param[in] trunk pointer to Q921 data struct - * \param[in] func pointer to logging callback function - * \param[in] priv pointer to private data - * - * \author Stefan Knoblich - */ -void Q921SetLogCB(L2TRUNK trunk, Q921LogCB_t func, void *priv) -{ - if(!trunk) - return; - - trunk->Q921LogProc = func; - trunk->PrivateDataLog = priv; -} - -/** - * Q921SetLogLevel - * \brief Set loglevel of Q.921 logging functions - * \param[in] trunk pointer to Q921 data struct - * \param[in] level new loglevel - * - * \author Stefan Knoblich - */ -void Q921SetLogLevel(L2TRUNK trunk, Q921LogLevel_t level) -{ - if(!trunk) - return; - - if (level < Q921_LOG_NONE) { - level = Q921_LOG_NONE; - } else if (level > Q921_LOG_DEBUG) { - level = Q921_LOG_DEBUG; - } - - trunk->loglevel = level; -} - - -/** - * Q921ChangeState - * \brief Change state, invoke neccessary actions - * \param[in] trunk pointer to Q921 data struct - * \param[in] state state to change to - * \return > 0 on success; <= 0 on error - * - * \author Stefan Knoblich - */ -static int Q921ChangeState(L2TRUNK trunk, Q921State_t state, L2UCHAR tei) -{ - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, tei); - Q921State_t oldstate = link->state; - int res = 0; - - Q921Log(trunk, Q921_LOG_DEBUG, "Changing state from \"%s\" (%d) to \"%s\" (%d) for TEI %d\n", - Q921State2Name(oldstate), oldstate, - Q921State2Name(state), state, - tei); - - /* - * generic actions (depending on the target state only) - */ - switch(state) { - case Q921_STATE_MULTIPLE_FRAME_ESTABLISHED: - /* Start TM01 */ - if(Q921_IS_NT(trunk)) { - Q921TM01TimerStart(trunk, tei); - } - break; - - default: - break; - } - - /* - * actions that depend on type of the old -> new state transition - */ - switch(oldstate) { - case Q921_STATE_STOPPED: - - switch(state) { - case Q921_STATE_TEI_UNASSIGNED: - if(Q921_IS_PTMP_TE(trunk)) { - res = Q921TeiSendAssignRequest(trunk); - } - break; - - case Q921_STATE_TEI_ASSIGNED: - if(Q921_IS_PTMP_NT(trunk)) { - res = Q921TeiSendRemoveRequest(trunk, Q921_TEI_BCAST); - } - break; - - default: - break; - } - break; - - default: - break; - } - - link->state = state; - - Q921Log(trunk, Q921_LOG_DEBUG, "Q921ChangeState() returns %d, new state is \"%s\" (%d) for TEI %d\n", res, Q921State2Name(state), state, tei); - - return res; -} - -/* - * TEI Management functions - * \note All TEI-mgmt UN frames are sent with cr = command! - */ -static int Q921TeiSend(L2TRUNK trunk, L2UCHAR type, L2USHORT ri, L2UCHAR ai) -{ - L2UCHAR mes[10]; - L2UCHAR offset = Q921_UFRAME_DATA_OFFSET(trunk); - - mes[offset++] = Q921_LAYER_ENT_ID_TEI; /* layer management entity identifier */ - mes[offset++] = (ri & 0xff00) >> 8; /* reference number upper part */ - mes[offset++] = ri & 0xff; /* reference number lower part */ - mes[offset++] = type; /* message type: Identity Request */ - mes[offset++] = ai << 1 | 0x01; /* action indicator: TEI */ - - return Q921SendU(trunk, Q921_SAPI_TEI, Q921_COMMAND(trunk), Q921_TEI_BCAST, 0, 0x00, mes, offset); -} - - -/** - * Q921TeiSendAssignRequest - * \brief Ask for new TEI (TE mode only) - * \param[in] trunk pointer to Q921 data struct - * \return > 0 on success, <= 0 on error - * - * \author Stefan Knoblich - */ -static int Q921TeiSendAssignRequest(L2TRUNK trunk) -{ - struct Q921_Link *link = Q921_TRUNK_CONTEXT(trunk); - L2INT res; - - if (!Q921_IS_PTMP_TE(trunk)) /* only ptmp te mode*/ - return 0; - -#ifndef WIN32 - link->ri = (L2USHORT)(random() % 0xffff); -#else - link->ri = (L2USHORT)(rand() % 0xffff); //todo -#endif - - /* send TEI assign request */ - res = Q921TeiSend(trunk, Q921_TEI_ID_REQUEST, link->ri, Q921_TEI_BCAST); - - /* start T202 */ - Q921T202TimerStart(trunk); - - return res; -} - - -/** - * Q921TeiProcessAssignResponse - * \brief Process assign response (TE mode only) - * \param[in] trunk pointer to Q921 data struct - * \param[in] mes pointer to message buffer - * \param[in] size size of message - * \return > 0 on success; <= 0 on error - * - * \author Stefan Knoblich - */ -static int Q921TeiProcAssignResponse(L2TRUNK trunk, L2UCHAR *mes, L2INT size) -{ - struct Q921_Link *link = Q921_TRUNK_CONTEXT(trunk); - L2UCHAR offset = Q921_UFRAME_DATA_OFFSET(trunk); - L2USHORT ri = 0; - - if (!Q921_IS_PTMP_TE(trunk)) /* PTMP TE only */ - return 0; - - ri = (mes[offset + 1] << 8) | mes[offset + 2]; - - if(ri != link->ri) { - /* hmmm ..., not our response i guess */ - return 0; - } - - switch(mes[offset + 3]) { - case Q921_TEI_ID_ASSIGNED: - /* Yay, use the new TEI and change state to assigned */ - link->tei = mes[offset + 4] >> 1; - - Q921Log(trunk, Q921_LOG_DEBUG, "Assigned TEI %d, setting state to TEI_ASSIGNED\n", link->tei); - - Q921ChangeState(trunk, Q921_STATE_TEI_ASSIGNED, link->tei); - break; - - case Q921_TEI_ID_DENIED: - /* oops, what to do now? */ - if ((mes[offset + 4] >> 1) == Q921_TEI_BCAST) { - /* No more free TEIs? this is bad */ - - //Q921TeiSendVerifyRequest(trunk, Q921_TEI_BCAST); /* TODO: does this work ?? */ - } else { - /* other reason, this is fatal, shutdown link */ - } - - Q921Log(trunk, Q921_LOG_DEBUG, "TEI assignment has been denied, reason: %s\n", - ((mes[offset +4] >> 1) == Q921_TEI_BCAST) ? "No free TEIs available" : "Unknown"); - - Q921ChangeState(trunk, Q921_STATE_TEI_UNASSIGNED, link->tei); - break; - - default: - return 0; - } - - /* stop T202 */ - Q921T202TimerStop(trunk); - - return 1; -} - - -/** - * Q921TeiSendVerifyRequest - * \brief Verify TEI (TE mode only) - * \param[in] trunk pointer to Q921 data struct - * \return > 0 on success; <= 0 on error - * - * \author Stefan Knoblich - */ -static int Q921TeiSendVerifyRequest(L2TRUNK trunk) -{ - struct Q921_Link *link = Q921_TRUNK_CONTEXT(trunk); - L2INT res; - - if (!Q921_IS_PTMP_TE(trunk)) /* only ptmp te mode*/ - return 0; - - /* Request running? */ - if (trunk->T202) - return 0; - - /* Send TEI verify request */ - res = Q921TeiSend(trunk, Q921_TEI_ID_VERIFY, link->ri, link->tei); - - /* start T202 */ - Q921T202TimerStart(trunk); - - return res; -} - - -/** - * Q921TeiProcCheckRequest - * \brief Process Check Request (TE mode only) - * \param[in] trunk pointer to Q921 data struct - * \param[in] mes pointer to message buffer - * \param[in] size size of message - * \return > 0 on success; <= 0 on error - * - * \author Stefan Knoblich - */ -static int Q921TeiProcCheckRequest(L2TRUNK trunk, L2UCHAR *mes, L2INT size) -{ - struct Q921_Link *link = Q921_TRUNK_CONTEXT(trunk); - L2UCHAR offset = Q921_UFRAME_DATA_OFFSET(trunk); - L2UCHAR tei = (mes[offset + 4] >> 1); /* action indicator => tei */ - L2INT res = 0; - - if (!Q921_IS_PTMP_TE(trunk)) /* ptmp te mode only */ - return 0; - - Q921Log(trunk, Q921_LOG_DEBUG, "Received TEI Check request for TEI %d\n", tei); - - if (tei == Q921_TEI_BCAST || tei == link->tei) { - /* - * Broadcast TEI check or for our assigned TEI - */ - - /* send TEI check reponse */ - res = Q921TeiSend(trunk, Q921_TEI_ID_CHECKRESP, link->ri, link->tei); - - Q921T202TimerStop(trunk); - } - - return res; -} - - -/** - * Q921TeiProcRemoveRequest - * \brief Process remove Request (TE mode only) - * \param[in] trunk pointer to Q921 data struct - * \param[in] mes pointer to message buffer - * \param[in] size size of message - * \return > 0 on success; <= 0 on error - * - * \author Stefan Knoblich - */ -static int Q921TeiProcRemoveRequest(L2TRUNK trunk, L2UCHAR *mes, L2INT size) -{ - struct Q921_Link *link = Q921_TRUNK_CONTEXT(trunk); - L2UCHAR offset = Q921_UFRAME_DATA_OFFSET(trunk); - L2UCHAR tei = (mes[offset + 4] >> 1); /* action indicator => tei */ - L2INT res = 0; - - if (!Q921_IS_PTMP_TE(trunk)) /* ptmp te mode only */ - return 0; - - Q921Log(trunk, Q921_LOG_DEBUG, "Received TEI Remove request for TEI %d\n", tei); - - if (tei == Q921_TEI_BCAST || tei == link->tei) { - /* - * Broadcast TEI remove or for our assigned TEI - */ - - /* reset tei */ - link->tei = 0; - - /* change state (no action) */ - Q921ChangeState(trunk, Q921_STATE_TEI_UNASSIGNED, link->tei); - - /* TODO: hmm, request new one ? */ - res = Q921TeiSendAssignRequest(trunk); - } - return res; -} - - -/** - * Q921TeiProcAssignRequest - * \brief Process assign request from peer (NT mode only) - * \param[in] trunk pointer to Q921 data struct - * \param[in] mes pointer to message buffer - * \param[in] size size of message - * \return > 0 on success; <= 0 on error - * - * \author Stefan Knoblich - */ -static int Q921TeiProcAssignRequest(L2TRUNK trunk, L2UCHAR *mes, L2INT size) -{ - L2UCHAR offset = Q921_UFRAME_DATA_OFFSET(trunk); - L2USHORT ri = 0; - L2UCHAR tei = 0; - - if (!Q921_IS_PTMP_NT(trunk)) /* PTMP NT only */ - return 0; - - ri = (mes[offset + 1] << 8) | mes[offset + 2]; - tei = mes[offset + 4] >> 1; - - if(tei == Q921_TEI_BCAST) { - int x; - - /* dynamically allocate TEI */ - for(x = Q921_TEI_DYN_MIN, tei = 0; x <= Q921_TEI_MAX; x++) { - if(!trunk->tei_map[x]) { - tei = x; - break; - } - } - } - else if(!(tei > 0 && tei < Q921_TEI_DYN_MIN)) { - /* reject TEIs that are not in the static area */ - Q921TeiSendDenyResponse(trunk, 0, ri); - - return 0; - } - - if(!tei) { - /* no free TEI found */ - Q921TeiSendDenyResponse(trunk, Q921_TEI_BCAST, ri); - } - else { - struct Q921_Link *link = Q921_LINK_CONTEXT(trunk, tei); - - /* mark used */ - trunk->tei_map[tei] = 1; - - /* assign tei */ - link->tei = tei; - - /* put context in TEI ASSIGNED state */ - Q921ChangeState(trunk, Q921_STATE_TEI_ASSIGNED, tei); - - /* send assign response */ - Q921TeiSendAssignedResponse(trunk, tei, ri); - - /* Start T201 */ - Q921T201TimerStart(trunk, tei); - } - return 0; -} - -/** - * Q921TeiSendCheckRequest - * \brief Send check request (NT mode only) - * \param[in] trunk pointer to Q921 data struct - * \param[in] tei TEI to check - * \return > 0 on success; <= 0 on error - * - * \author Stefan Knoblich - */ -static int Q921TeiSendCheckRequest(L2TRUNK trunk, L2UCHAR tei) -{ - L2INT res = 0; - - if (!Q921_IS_PTMP_NT(trunk)) /* PTMP NT only */ - return 0; - - /* send TEI check request */ - res = Q921TeiSend(trunk, Q921_TEI_ID_CHECKREQ, 0, tei); - - /* (Re-)Start T201 timer */ - Q921T201TimerStart(trunk, tei); - - return res; -} - -/** - * Q921TeiProcCheckResponse - * \brief Process Check Response (NT mode only) - * \param[in] trunk pointer to Q921 data struct - * \param[in] mes pointer to message buffer - * \param[in] size size of message - * \return > 0 on success; <= 0 on error - * - * \author Stefan Knoblich - */ -static int Q921TeiProcCheckResponse(L2TRUNK trunk, L2UCHAR *mes, L2INT size) -{ - struct Q921_Link *link; - L2UCHAR offset = Q921_UFRAME_DATA_OFFSET(trunk); - L2USHORT ri = 0; - L2UCHAR tei = 0; - - if (!Q921_IS_PTMP_NT(trunk)) /* PTMP NT mode only */ - return 0; - - ri = (mes[offset + 1] << 8) | mes[offset + 2]; - tei = mes[offset + 4] >> 1; - - /* restart T201 */ - Q921T201TimerStop(trunk, tei); - - /* reset counter */ - link = Q921_LINK_CONTEXT(trunk, tei); - link->N202 = 0; - - if(!(tei > 0 && tei < Q921_TEI_MAX) || !trunk->tei_map[tei]) { - /* TODO: Should we send a DISC first? */ - - /* TEI not assigned? Invalid TEI? */ - Q921TeiSendRemoveRequest(trunk, tei); - - /* change state */ - Q921ChangeState(trunk, Q921_STATE_STOPPED, tei); - - /* clear */ - memset(link, 0, sizeof(struct Q921_Link)); - } else { - /* Start T201 */ - Q921T201TimerStart(trunk, tei); - } - - return 0; -} - - -/** - * Q921TeiProcVerifyRequest - * \brief Process Verify Request (NT mode only) - * \param[in] trunk pointer to Q921 data struct - * \param[in] mes pointer to message buffer - * \param[in] size size of message - * \return > 0 on success; <= 0 on error - * - * \author Stefan Knoblich - */ -static int Q921TeiProcVerifyRequest(L2TRUNK trunk, L2UCHAR *mes, L2INT size) -{ - L2UCHAR resp[25]; - L2UCHAR offset = Q921_UFRAME_DATA_OFFSET(trunk); - L2UCHAR tei = 0; - - if (!Q921_IS_PTMP_NT(trunk)) /* PTMP NT mode only */ - return 0; - - tei = mes[offset + 4] >> 1; - - /* todo: handle response... verify assigned TEI */ - resp[offset + 0] = 0; - - return 0; -} - -/** - * Q921TeiSendDenyResponse - * \brief Send Deny Response (NT mode only) - * \param[in] trunk pointer to Q921 data struct - * \return > 0 on success; <= 0 on error - * - * \author Stefan Knoblich - */ -static int Q921TeiSendDenyResponse(L2TRUNK trunk, L2UCHAR tei, L2USHORT ri) -{ - if (!Q921_IS_PTMP_NT(trunk)) /* PTMP NT only */ - return 0; - - return Q921TeiSend(trunk, Q921_TEI_ID_DENIED, ri, tei); -} - - -/** - * Q921TeiSendAssignedResponse - * \brief Send Assigned Response (NT mode only) - * \param[in] trunk pointer to Q921 data struct - * \param[in] tei TEI to assign - * \param[in] ri RI of request - * \return > 0 on success; <= 0 on error - * - * \author Stefan Knoblich - */ -static int Q921TeiSendAssignedResponse(L2TRUNK trunk, L2UCHAR tei, L2USHORT ri) -{ - if (!Q921_IS_PTMP_NT(trunk)) /* PTMP NT only */ - return 0; - - return Q921TeiSend(trunk, Q921_TEI_ID_ASSIGNED, ri, tei); -} - -/** - * Q921TeiSendRemoveRequest - * \brief Send Remove Request (NT mode only) - * \param[in] trunk pointer to Q921 data struct - * \param[in] tei TEI to remove - * \return > 0 on success; <= 0 on error - * - * \author Stefan Knoblich - */ -static int Q921TeiSendRemoveRequest(L2TRUNK trunk, L2UCHAR tei) -{ - if (!Q921_IS_PTMP_NT(trunk)) /* PTMP NT only */ - return 0; - - return Q921TeiSend(trunk, Q921_TEI_ID_REMOVE, 0, tei); -} diff --git a/libs/freetdm/src/isdn/Q931.c b/libs/freetdm/src/isdn/Q931.c deleted file mode 100644 index b245c144d8..0000000000 --- a/libs/freetdm/src/isdn/Q931.c +++ /dev/null @@ -1,888 +0,0 @@ -/***************************************************************************** - - FileName: Q931.c - - Contents: Implementation of Q.931 stack main interface functions. - See q931.h for description. - - License/Copyright: - - Copyright (c) 2007, Jan Vidar Berger, Case Labs, Ltd. All rights reserved. - email:janvb@caselaboratories.com - - 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 Case Labs, Ltd 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT OWNER OR CONTRIBUTORS 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 SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*****************************************************************************/ - -#include "Q921.h" -#include "Q931.h" -#include "national.h" -#include "DMS.h" -#include "5ESS.h" - - -/***************************************************************************** - - Dialect function pointers tables. - - The following function pointer arrays define pack/unpack functions and - processing furnctions for the different Q.931 based dialects. - - The arrays are initialized with pointers to dummy functions and later - overrided with pointers to actual functions as new dialects are added. - - The initial Q.931 will as an example define 2 dialects as it treats User - and Network mode as separate ISDN dialects. - - The API messages Q931AddProc, Q931AddMes, Q931AddIE are used to initialize - these table entries during system inititialization of a stack. - -*****************************************************************************/ -q931proc_func_t *Q931Proc[Q931MAXDLCT][Q931MAXMES]; - -q931umes_func_t *Q931Umes[Q931MAXDLCT][Q931MAXMES]; -q931pmes_func_t *Q931Pmes[Q931MAXDLCT][Q931MAXMES]; - -q931uie_func_t *Q931Uie[Q931MAXDLCT][Q931MAXIE]; -q931pie_func_t *Q931Pie[Q931MAXDLCT][Q931MAXIE]; - -q931timeout_func_t *Q931Timeout[Q931MAXDLCT][Q931MAXTIMER]; -q931timer_t Q931Timer[Q931MAXDLCT][Q931MAXTIMER]; - -void (*Q931CreateDialectCB[Q931MAXDLCT])(L3UCHAR iDialect) = { NULL, NULL }; - -Q931State Q931st[Q931MAXSTATE]; - -/***************************************************************************** - - Core system tables and variables. - -*****************************************************************************/ - -L3INT Q931L4HeaderSpace = {0}; /* header space to be ignoder/inserted */ - /* at head of each message. */ - -L3INT Q931L2HeaderSpace = {4}; /* Q921 header space, sapi, tei etc */ - -/***************************************************************************** - - Main interface callback functions. - -*****************************************************************************/ - -Q931ErrorCB_t Q931ErrorProc; /* callback for error messages. */ -L3ULONG (*Q931GetTimeProc) (void) = NULL; /* callback for func reading time in ms */ - -/***************************************************************************** - - Function: Q931SetL4HeaderSpace - - Description: Set the # of bytes to be inserted/ignored at the head of - each message. Q931 will issue a message with space for header - and the user will use this to fill in whatever header info - is required to support the architecture used. - -*****************************************************************************/ -void Q931SetL4HeaderSpace(L3INT space) -{ - Q931L4HeaderSpace = space; -} - -/***************************************************************************** - - Function: Q931SetL2HeaderSpace - - Description: Set the # of bytes to be inserted/ignored at the head of - each message. Q931 will issue a message with space for header - and the user will use this to fill in whatever header info - is required to support the architecture used. - -*****************************************************************************/ -void Q931SetL2HeaderSpace(L3INT space) -{ - Q931L2HeaderSpace = space; -} - -/***************************************************************************** - - Function: Q931ProcDummy - - Description: Dummy function for message processing. - -*****************************************************************************/ -L3INT Q931ProcDummy(Q931_TrunkInfo_t *pTrunk, L3UCHAR * b,L3INT c) -{ - return Q931E_INTERNAL; -} - -/***************************************************************************** - - Function: Q931UmesDummy - - Description: Dummy function for message processing - -*****************************************************************************/ -L3INT Q931UmesDummy(Q931_TrunkInfo_t *pTrunk,L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT IOff, L3INT Size) -{ - return Q931E_UNKNOWN_MESSAGE; -} - -/***************************************************************************** - - Function: Q931UieDummy - - Description: Dummy function for message processing - -*****************************************************************************/ -L3INT Q931UieDummy(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) -{ - return Q931E_UNKNOWN_IE; -} - -/***************************************************************************** - - Function: Q931PmesDummy - - Description: Dummy function for message processing - -*****************************************************************************/ -L3INT Q931PmesDummy(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - return Q931E_UNKNOWN_MESSAGE; -} - -/***************************************************************************** - - Function: Q931PieDummy - - Description: Dummy function for message processing - -*****************************************************************************/ -L3INT Q931PieDummy(Q931_TrunkInfo_t *pTrunk,L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) -{ - return Q931E_UNKNOWN_IE; -} - -/***************************************************************************** - - Function: Q931TxDummy - - Description: Dummy function for message processing - -*****************************************************************************/ -L3INT Q931TxDummy(Q931_TrunkInfo_t *pTrunk, L3UCHAR * b, L3INT n) -{ - return Q931E_MISSING_CB; -} - -/***************************************************************************** - - Function: Q931ErrorDummy - - Description: Dummy function for error processing - -*****************************************************************************/ -L3INT Q931ErrorDummy(void *priv, L3INT a, L3INT b, L3INT c) -{ - return 0; -} - -/***************************************************************************** - - Function: Q931Initialize - - Description: This function Initialize the stack. - - Will set up the trunk array, channel - arrays and initialize Q931 function arrays before it finally - set up EuroISDN processing with User as dialect 0 and - Network as dialect 1. - - Note: Initialization of other stacks should be inserted after - the initialization of EuroISDN. - -*****************************************************************************/ -void Q931Initialize() -{ - L3INT x,y; - - /* Secure the callbacks to default procs */ - Q931ErrorProc = Q931ErrorDummy; - - /* The user will only add the message handlers and IE handlers he need, - * so we need to initialize every single entry to a default function - * that will throw an appropriate error if they are ever called. - */ - for (x = 0; x < Q931MAXDLCT; x++) { - for (y = 0; y < Q931MAXMES; y++) { - Q931Proc[x][y] = Q931ProcDummy; - Q931Umes[x][y] = Q931UmesDummy; - Q931Pmes[x][y] = Q931PmesDummy; - } - for (y = 0; y < Q931MAXIE; y++) { - Q931Pie[x][y] = Q931PieDummy; - Q931Uie[x][y] = Q931UieDummy; - } - for (y = 0; y < Q931MAXTIMER; y++) { - Q931Timeout[x][y] = Q931TimeoutDummy; - Q931Timer[x][y] = 0; - } - } - - if (Q931CreateDialectCB[Q931_Dialect_Q931 + Q931_TE] == NULL) - Q931AddDialect(Q931_Dialect_Q931 + Q931_TE, Q931CreateTE); - - if (Q931CreateDialectCB[Q931_Dialect_Q931 + Q931_NT] == NULL) - Q931AddDialect(Q931_Dialect_Q931 + Q931_NT, Q931CreateNT); - - if (Q931CreateDialectCB[Q931_Dialect_National + Q931_TE] == NULL) - Q931AddDialect(Q931_Dialect_National + Q931_TE, nationalCreateTE); - - if (Q931CreateDialectCB[Q931_Dialect_National + Q931_NT] == NULL) - Q931AddDialect(Q931_Dialect_National + Q931_NT, nationalCreateNT); - - if (Q931CreateDialectCB[Q931_Dialect_DMS + Q931_TE] == NULL) - Q931AddDialect(Q931_Dialect_DMS + Q931_TE, DMSCreateTE); - - if (Q931CreateDialectCB[Q931_Dialect_DMS + Q931_NT] == NULL) - Q931AddDialect(Q931_Dialect_DMS + Q931_NT, DMSCreateNT); - - if (Q931CreateDialectCB[Q931_Dialect_5ESS + Q931_TE] == NULL) - Q931AddDialect(Q931_Dialect_5ESS + Q931_TE, ATT5ESSCreateTE); - - if (Q931CreateDialectCB[Q931_Dialect_5ESS + Q931_NT] == NULL) - Q931AddDialect(Q931_Dialect_5ESS + Q931_NT, ATT5ESSCreateNT); - - /* The last step we do is to call the callbacks to create the dialects */ - for (x = 0; x < Q931MAXDLCT; x++) { - if (Q931CreateDialectCB[x] != NULL) { - Q931CreateDialectCB[x]((L3UCHAR)x); - } - } -} - -/** - * Q931TimerTick - * \brief Periodically called to update and check for expired timers - * \param pTrunk Q.931 trunk - */ -void Q931TimerTick(Q931_TrunkInfo_t *pTrunk) -{ - struct Q931_Call *call = NULL; - L3ULONG now = 0; - L3INT x; - - /* TODO: Loop through all active calls, check timers and call timout procs - * if timers are expired. - * Implement a function array so each dialect can deal with their own - * timeouts. - */ - now = Q931GetTime(); - - for (x = 0; x < Q931MAXCALLPERTRUNK; x++) { - call = &pTrunk->call[x]; - - if (!call->InUse || !call->Timer || !call->TimerID) - continue; - - if (call->Timer <= now) { - /* Stop Timer */ - Q931StopTimer(pTrunk, x, call->TimerID); - - /* Invoke dialect timeout callback */ - Q931Timeout[pTrunk->Dialect][call->TimerID](pTrunk, x); - } - } -} - -/***************************************************************************** - - Function: Q931Rx23 - - Description: Receive message from layer 2 (LAPD). Receiving a message - is always done in 2 steps. First the message must be - interpreted and translated to a static struct. Secondly - the message is processed and responded to. - - The Q.931 message contains a static header that is - interpreted in this function. The rest is interpreted - in a sub function according to mestype. - - Parameters: pTrunk [IN] Ptr to trunk info. - buf [IN] Ptr to buffer containing message. - Size [IN] Size of message. - - Return Value: Error Code. 0 = No Error, < 0 :error, > 0 : Warning - see q931errors.h for details. - -*****************************************************************************/ -L3INT Q931Rx23(Q931_TrunkInfo_t *pTrunk, L3INT ind, L3UCHAR tei, L3UCHAR * buf, L3INT Size) -{ - L3UCHAR *Mes = NULL; - L3INT RetCode = Q931E_NO_ERROR; - Q931mes_Generic *m = (Q931mes_Generic *) pTrunk->L3Buf; - L3INT ISize; - L3INT IOff = 0; - L3INT L2HSize = Q931L2HeaderSpace; - - switch (ind) { - case Q921_DL_UNIT_DATA: /* DL-UNITDATA indication (UI frame, 3 byte header) */ - L2HSize = 3; - - case Q921_DL_DATA: /* DL-DATA indication (I frame, 4 byte header) */ - /* Reset our decode buffer */ - memset(pTrunk->L3Buf, 0, sizeof(pTrunk->L3Buf)); - - /* L2 Header Offset */ - Mes = &buf[L2HSize]; - - /* Protocol Discriminator */ - m->ProtDisc = Mes[IOff++]; - - /* CRV */ - m->CRVFlag = (Mes[IOff + 1] >> 7) & 0x01; - m->CRV = Q931Uie_CRV(pTrunk, Mes, m->buf, &IOff, &ISize); - - /* Message Type */ - m->MesType = Mes[IOff++]; - - /* Store tei */ - m->Tei = tei; - - /* d'oh a little ugly but this saves us from: - * a) doing Q.921 work in the lower levels (extracting the TEI ourselves) - * b) adding a tei parameter to _all_ Proc functions - */ - if (tei) { - L3INT callIndex = 0; - - /* Find the call using CRV */ - RetCode = Q931FindCRV(pTrunk, m->CRV, &callIndex); - if (RetCode == Q931E_NO_ERROR && !pTrunk->call[callIndex].Tei) { - pTrunk->call[callIndex].Tei = tei; - } - } - - Q931Log(pTrunk, Q931_LOG_DEBUG, "Received message from Q.921 (ind %d, tei %d, size %d)\nMesType: %d, CRVFlag %d (%s), CRV %d (Dialect: %d)\n", ind, m->Tei, Size, - m->MesType, m->CRVFlag, m->CRVFlag ? "Terminator" : "Originator", m->CRV, pTrunk->Dialect); - - RetCode = Q931Umes[pTrunk->Dialect][m->MesType](pTrunk, Mes, (Q931mes_Generic *)pTrunk->L3Buf, IOff, Size - L2HSize); - if (RetCode >= Q931E_NO_ERROR) { - RetCode = Q931Proc[pTrunk->Dialect][m->MesType](pTrunk, pTrunk->L3Buf, 2); - } - break; - - default: - break; - } - - return RetCode; -} - -/***************************************************************************** - - Function: Q931Tx34 - - Description: Called from the stack to send a message to layer 4. - - Parameters: Mes[IN] Ptr to message buffer. - Size[IN] Message size in bytes. - - Return Value: Error Code. 0 = No Error, < 0 :error, > 0 : Warning - see q931errors.h for details. - -*****************************************************************************/ -L3INT Q931Tx34(Q931_TrunkInfo_t *pTrunk, L3UCHAR * Mes, L3INT Size) -{ - Q931Log(pTrunk, Q931_LOG_DEBUG, "Sending message to Layer4 (size: %d)\n", Size); - - if (pTrunk->Q931Tx34CBProc) { - return pTrunk->Q931Tx34CBProc(pTrunk->PrivateData34, Mes, Size); - } - return Q931E_MISSING_CB; -} - -/***************************************************************************** - - Function: Q931Rx43 - - Description: Receive message from Layer 4 (application). - - Parameters: pTrunk[IN] Trunk #. - buf[IN] Message Pointer. - Size[IN] Message size in bytes. - - Return Value: Error Code. 0 = No Error, < 0 :error, > 0 : Warning - see q931errors.h for details. - -*****************************************************************************/ -L3INT Q931Rx43(Q931_TrunkInfo_t *pTrunk,L3UCHAR * buf, L3INT Size) -{ - Q931mes_Header *ptr = (Q931mes_Header*)&buf[Q931L4HeaderSpace]; - L3INT RetCode = Q931E_NO_ERROR; - - Q931Log(pTrunk, Q931_LOG_DEBUG, "Receiving message from Layer4 (size: %d, type: %d)\n", Size, ptr->MesType); - - RetCode = Q931Proc[pTrunk->Dialect][ptr->MesType](pTrunk, buf, 4); - - Q931Log(pTrunk, Q931_LOG_DEBUG, "Q931Rx43 return code: %d\n", RetCode); - - return RetCode; -} - -/***************************************************************************** - - Function: Q931Tx32 - - Description: Called from the stack to send a message to L2. The input is - always a non-packed message so it will first make a proper - call to create a packed message before it transmits that - message to layer 2. - - Parameters: pTrunk[IN] Trunk # - buf[IN] Ptr to message buffer. - Size[IN] Message size in bytes. - - Return Value: Error Code. 0 = No Error, < 0 :error, > 0 : Warning - see q931errors.h for details. - -*****************************************************************************/ -L3INT Q931Tx32Data(Q931_TrunkInfo_t *pTrunk, L3UCHAR bcast, L3UCHAR * Mes, L3INT Size) -{ - Q931mes_Generic *ptr = (Q931mes_Generic*)Mes; - L3INT RetCode = Q931E_NO_ERROR; - L3INT iDialect = pTrunk->Dialect; - L3INT Offset = bcast ? (Q931L2HeaderSpace - 1) : Q931L2HeaderSpace; - L3INT OSize; - - Q931Log(pTrunk, Q931_LOG_DEBUG, "Sending message to Q.921 (size: %d)\n", Size); - - memset(pTrunk->L2Buf, 0, sizeof(pTrunk->L2Buf)); - - /* Call pack function through table. */ - RetCode = Q931Pmes[iDialect][ptr->MesType](pTrunk, (Q931mes_Generic *)Mes, Size, &pTrunk->L2Buf[Offset], &OSize); - if (RetCode >= Q931E_NO_ERROR) { - L3INT callIndex; - L3UCHAR tei = 0; - - if (ptr->CRV) { - /* Find the call using CRV */ - RetCode = Q931FindCRV(pTrunk, ptr->CRV, &callIndex); - if (RetCode != Q931E_NO_ERROR) - return RetCode; - - tei = pTrunk->call[callIndex].Tei; - } - - if (pTrunk->Q931Tx32CBProc) { - RetCode = pTrunk->Q931Tx32CBProc(pTrunk->PrivateData32, bcast ? Q921_DL_UNIT_DATA : Q921_DL_DATA, tei, pTrunk->L2Buf, OSize + Offset); - } else { - RetCode = Q931E_MISSING_CB; - } - } - - return RetCode; -} - - -/***************************************************************************** - - Function: Q931SetError - - Description: Called from the stack to indicate an error. - - Parameters: ErrID ID of ie or message causing error. - ErrPar1 Error parameter 1 - ErrPar2 Error parameter 2. - - -*****************************************************************************/ -void Q931SetError(Q931_TrunkInfo_t *pTrunk,L3INT ErrID, L3INT ErrPar1, L3INT ErrPar2) -{ - if (pTrunk->Q931ErrorCBProc) { - pTrunk->Q931ErrorCBProc(pTrunk->PrivateData34, ErrID, ErrPar1, ErrPar2); - } else { - Q931ErrorProc(pTrunk->PrivateData34, ErrID, ErrPar1, ErrPar2); - } -} - -void Q931SetDefaultErrorCB(Q931ErrorCB_t Q931ErrorPar) -{ - Q931ErrorProc = Q931ErrorPar; -} - -/***************************************************************************** - - Function: Q931CreateCRV - - Description: Create a CRV entry and return it's index. The function will - locate a free entry in the call tables allocate it and - allocate a unique CRV value attached to it. - - Parameters: pTrunk [IN] Trunk number - callindex [OUT] return call table index. - - Return Value: Error Code. 0 = No Error, < 0 :error, > 0 : Warning - see q931errors.h for details. -****************************************************************************/ -L3INT Q931CreateCRV(Q931_TrunkInfo_t *pTrunk, L3INT * callIndex) -{ - L3INT CRV = Q931GetUniqueCRV(pTrunk); - - return Q931AllocateCRV(pTrunk, CRV, callIndex); -} - - -L3INT Q931ReleaseCRV(Q931_TrunkInfo_t *pTrunk, L3INT CRV) -{ - int callIndex; - - if ((Q931FindCRV(pTrunk, CRV, &callIndex)) == Q931E_NO_ERROR) { - pTrunk->call[callIndex].InUse = 0; - return Q931E_NO_ERROR; - } - - return Q931E_INVALID_CRV; -} - -/***************************************************************************** - - Function: Q931AllocateCRV - - Description: Allocate a call table entry and assigns the given CRV value - to it. - - Parameters: pTrunk [IN] Trunk number - iCRV [IN] Call Reference Value. - callindex [OUT] return call table index. - - Return Value: Error Code. 0 = No Error, < 0 :error, > 0 : Warning - see q931errors.h for details. - -*****************************************************************************/ -L3INT Q931AllocateCRV(Q931_TrunkInfo_t *pTrunk, L3INT iCRV, L3INT * callIndex) -{ - L3INT x; - for (x = 0; x < Q931MAXCALLPERTRUNK; x++) { - if (!pTrunk->call[x].InUse) { - pTrunk->call[x].CRV = iCRV; - pTrunk->call[x].BChan = 255; - pTrunk->call[x].State = 0; /* null state - idle */ - pTrunk->call[x].TimerID = 0; /* no timer running */ - pTrunk->call[x].Timer = 0; - pTrunk->call[x].InUse = 1; /* mark as used */ - *callIndex = x; - return Q931E_NO_ERROR; - } - } - return Q931E_TOMANYCALLS; -} - -/***************************************************************************** - - Function: Q931GetCallState - - Description: Look up CRV and return current call state. A non existing - CRV is the same as state zero (0). - - Parameters: pTrunk [IN] Trunk number. - iCRV [IN] CRV - - Return Value: Call State. - -*****************************************************************************/ -L3INT Q931GetCallState(Q931_TrunkInfo_t *pTrunk, L3INT iCRV) -{ - L3INT x; - for (x = 0; x < Q931MAXCALLPERTRUNK; x++) { - if (pTrunk->call[x].InUse) { - if (pTrunk->call[x].CRV == iCRV) { - return pTrunk->call[x].State; - } - } - } - return 0; /* assume state zero for non existing CRV's */ -} - -/** - * Q931StartTimer - * \brief Start a timer - * \param pTrunk Q.931 trunk - * \param callindex Index of the call - * \param iTimerID ID of timer - * \return always 0 - */ -L3INT Q931StartTimer(Q931_TrunkInfo_t *pTrunk, L3INT callIndex, L3USHORT iTimerID) -{ -#if 0 - L3ULONG duration = Q931Timer[pTrunk->Dialect][iTimerID]; - - if (duration) { - pTrunk->call[callIndex].Timer = Q931GetTime() + duration; - pTrunk->call[callIndex].TimerID = iTimerID; - } -#endif - return 0; -} - -/** - * Q931StopTimer - * \brief Stop a timer - * \param pTrunk Q.931 trunk - * \param callindex Index of the call - * \param iTimerID ID of timer - * \return always 0 - */ -L3INT Q931StopTimer(Q931_TrunkInfo_t *pTrunk, L3INT callindex, L3USHORT iTimerID) -{ - if (pTrunk->call[callindex].TimerID == iTimerID) - pTrunk->call[callindex].TimerID = 0; - - return 0; -} - -L3INT Q931SetState(Q931_TrunkInfo_t *pTrunk, L3INT callIndex, L3INT iState) -{ - pTrunk->call[callIndex].State = iState; - - return 0; -} - -L3ULONG Q931GetTime() -{ - L3ULONG tNow = 0; - static L3ULONG tLast = 0; - - if (Q931GetTimeProc != NULL) { - tNow = Q931GetTimeProc(); - if (tNow < tLast) { /* wrapped */ - /* TODO */ - } - tLast = tNow; - } - return tNow; -} - -void Q931SetGetTimeCB(L3ULONG (*callback)(void)) -{ - Q931GetTimeProc = callback; -} - -L3INT Q931FindCRV(Q931_TrunkInfo_t *pTrunk, L3INT crv, L3INT *callindex) -{ - L3INT x; - for (x = 0; x < Q931MAXCALLPERTRUNK; x++) { - if (pTrunk->call[x].InUse) { - if (pTrunk->call[x].CRV == crv) { - *callindex = x; - return Q931E_NO_ERROR; - } - } - } - return Q931E_INVALID_CRV; -} - - -void Q931AddDialect(L3UCHAR i, void (*callback)(L3UCHAR iD )) -{ - if (i < Q931MAXDLCT) { - Q931CreateDialectCB[i] = callback; - } -} - -/***************************************************************************** - Function: Q931AddStateEntry - - Description: Find an empty entry in the dialects state table and add this - entry. -*****************************************************************************/ -void Q931AddStateEntry(L3UCHAR iD, L3INT iState, L3INT iMes, L3UCHAR cDir) -{ - int x; - for (x = 0; x < Q931MAXSTATE; x++) { - if (Q931st[x].Message == 0) { - Q931st[x].State = iState; - Q931st[x].Message = iMes; - Q931st[x].Direction = cDir; - /* TODO Sort table and use bsearch */ - return; - } - } -} - -/***************************************************************************** - Function: Q931IsEventLegal - - Description: Check state table for matching criteria to indicate if this - Message is legal in this state or not. - - Note: Someone write a bsearch or invent something smart here - please - sequential is ok for now. -*****************************************************************************/ -L3BOOL Q931IsEventLegal(L3UCHAR iD, L3INT iState, L3INT iMes, L3UCHAR cDir) -{ - int x; - /* TODO Sort table and use bsearch */ - for (x = 0; x < Q931MAXSTATE; x++) { - if (Q931st[x].State == iState && Q931st[x].Message == iMes && - Q931st[x].Direction == cDir) { - return L3TRUE; - } - } - return L3FALSE; -} - -/***************************************************************************** - Function: q931_error_to_name() - - Description: Check state table for matching criteria to indicate if this - Message is legal in this state or not. - - Note: Someone write a bsearch or invent something smart here - please - sequential is ok for now. -*****************************************************************************/ -static const char *q931_error_names[] = { - "Q931E_NO_ERROR", /* 0 */ - - "Q931E_UNKNOWN_MESSAGE", /* -3001 */ - "Q931E_ILLEGAL_IE", /* -3002 */ - "Q931E_UNKNOWN_IE", /* -3003 */ - "Q931E_BEARERCAP", /* -3004 */ - "Q931E_HLCOMP", /* -3005 */ - "Q931E_LLCOMP", /* -3006 */ - "Q931E_INTERNAL", /* -3007 */ - "Q931E_MISSING_CB", /* -3008 */ - "Q931E_UNEXPECTED_MESSAGE", /* -3009 */ - "Q931E_ILLEGAL_MESSAGE", /* -3010 */ - "Q931E_TOMANYCALLS", /* -3011 */ - "Q931E_INVALID_CRV", /* -3012 */ - "Q931E_CALLID", /* -3013 */ - "Q931E_CALLSTATE", /* -3014 */ - "Q931E_CALLEDSUB", /* -3015 */ - "Q931E_CALLEDNUM", /* -3016 */ - "Q931E_CALLINGNUM", /* -3017 */ - "Q931E_CALLINGSUB", /* -3018 */ - "Q931E_CAUSE", /* -3019 */ - "Q931E_CHANID", /* -3020 */ - "Q931E_DATETIME", /* -3021 */ - "Q931E_DISPLAY", /* -3022 */ - "Q931E_KEYPADFAC", /* -3023 */ - "Q931E_NETFAC", /* -3024 */ - "Q931E_NOTIFIND", /* -3025 */ - "Q931E_PROGIND", /* -3026 */ - "Q931E_RESTARTIND", /* -3027 */ - "Q931E_SEGMENT", /* -3028 */ - "Q931E_SIGNAL", /* -3029 */ - "Q931E_GENERIC_DIGITS" /* -3030 */ - -}; - -#define Q931_MAX_ERROR 30 - -const char *q931_error_to_name(q931_error_t error) -{ - int index = 0; - if ((int)error < 0) { - index = (((int)error * -1) -3000); - } - if (index < 0 || index > Q931_MAX_ERROR) { - return ""; - } - return q931_error_names[index]; -} -/* - * Logging - */ -#include - -L3INT Q931Log(Q931_TrunkInfo_t *trunk, Q931LogLevel_t level, const char *fmt, ...) -{ - char buf[Q931_LOGBUFSIZE]; - L3INT len; - va_list ap; - - if (!trunk->Q931LogCBProc) - return 0; - - if (trunk->loglevel < level) - return 0; - - va_start(ap, fmt); - - len = vsnprintf(buf, sizeof(buf)-1, fmt, ap); - if (len <= 0) { - /* TODO: error handling */ - return -1; - } - if (len >= sizeof(buf)) - len = sizeof(buf) - 1; - - buf[len] = '\0'; - - va_end(ap); - - return trunk->Q931LogCBProc(trunk->PrivateDataLog, level, buf, len); -} - -/** - * Q921SetLogCB - * \brief Set Logging callback function and private data - */ -void Q931SetLogCB(Q931_TrunkInfo_t *trunk, Q931LogCB_t func, void *priv) -{ - trunk->Q931LogCBProc = func; - trunk->PrivateDataLog = priv; -} - -/** - * Q921SetLogLevel - * \brief Set Loglevel - */ -void Q931SetLogLevel(Q931_TrunkInfo_t *trunk, Q931LogLevel_t level) -{ - if(!trunk) - return; - - if (level < Q931_LOG_NONE) { - level = Q931_LOG_NONE; - } else if (level > Q931_LOG_DEBUG) { - level = Q931_LOG_DEBUG; - } - - trunk->loglevel = level; -} - -/** - * Q931TimeoutDummy - * \brief Dummy handler for timeouts - * \param pTrunk Q.931 trunk - * \param callIndex Index of call - */ -L3INT Q931TimeoutDummy(Q931_TrunkInfo_t *pTrunk, L3INT callIndex) -{ - Q931Log(pTrunk, Q931_LOG_DEBUG, "Timer %d of call %d (CRV: %d) timed out\n", pTrunk->call[callIndex].TimerID, callIndex, pTrunk->call[callIndex].CRV); - - return 0; -} diff --git a/libs/freetdm/src/isdn/Q931StateNT.c b/libs/freetdm/src/isdn/Q931StateNT.c deleted file mode 100644 index 8d05fb6d03..0000000000 --- a/libs/freetdm/src/isdn/Q931StateNT.c +++ /dev/null @@ -1,1218 +0,0 @@ -/***************************************************************************** - - FileName: q931StateNT.c - - Contents: Q.931 State Engine for NT (Network Mode). - - The controlling state engine for Q.931 is the state engine - on the NT side. The state engine on the TE side is a slave - of this. The TE side maintain it's own states as described in - ITU-T Q931, but will in raise conditions be overridden by - the NT side. - - License/Copyright: - - Copyright (c) 2007, Jan Vidar Berger, Case Labs, Ltd. All rights reserved. - email:janvb@caselaboratories.com - - 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 Case Labs, Ltd 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT OWNER OR CONTRIBUTORS 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 SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*****************************************************************************/ - -#include "Q931.h" - -extern L3INT Q931L4HeaderSpace; - -/***************************************************************************** - Function: Q931CreateNT - - Description: Will create the Q931 NT as a Dialect in the stack. The first - bulk set up the message handlers, the second bulk the IE - encoders/coders, and the last bulk set up the state table. - - Parameters: i Dialect index -*****************************************************************************/ -void Q931CreateNT(L3UCHAR i) -{ - Q931SetMesProc(Q931mes_ALERTING, i, Q931ProcAlertingNT, Q931Umes_Alerting, Q931Pmes_Alerting); - Q931SetMesProc(Q931mes_CALL_PROCEEDING, i, Q931ProcCallProceedingNT, Q931Umes_CallProceeding, Q931Pmes_CallProceeding); - Q931SetMesProc(Q931mes_CONNECT, i, Q931ProcConnectNT, Q931Umes_Connect, Q931Pmes_Connect); - Q931SetMesProc(Q931mes_CONNECT_ACKNOWLEDGE, i, Q931ProcConnectAckNT, Q931Umes_ConnectAck, Q931Pmes_ConnectAck); - Q931SetMesProc(Q931mes_PROGRESS, i, Q931ProcProgressNT, Q931Umes_Progress, Q931Pmes_Progress); - Q931SetMesProc(Q931mes_SETUP, i, Q931ProcSetupNT, Q931Umes_Setup, Q931Pmes_Setup); - Q931SetMesProc(Q931mes_SETUP_ACKNOWLEDGE, i, Q931ProcSetupAckNT, Q931Umes_SetupAck, Q931Pmes_SetupAck); - Q931SetMesProc(Q931mes_RESUME, i, Q931ProcResumeNT, Q931Umes_Resume, Q931Pmes_Resume); - Q931SetMesProc(Q931mes_RESUME_ACKNOWLEDGE, i, Q931ProcResumeAckNT, Q931Umes_ResumeAck, Q931Pmes_ResumeAck); - Q931SetMesProc(Q931mes_RESUME_REJECT, i, Q931ProcResumeRejectNT, Q931Umes_ResumeReject, Q931Pmes_ResumeReject); - Q931SetMesProc(Q931mes_SUSPEND, i, Q931ProcSuspendNT, Q931Umes_Suspend, Q931Pmes_Suspend); - Q931SetMesProc(Q931mes_SUSPEND_ACKNOWLEDGE, i, Q931ProcSuspendAckNT, Q931Umes_SuspendAck, Q931Pmes_SuspendAck); - Q931SetMesProc(Q931mes_SUSPEND_REJECT, i, Q931ProcSuspendRejectNT, Q931Umes_SuspendReject, Q931Pmes_SuspendReject); - Q931SetMesProc(Q931mes_USER_INFORMATION, i, Q931ProcUserInformationNT, Q931Umes_UserInformation, Q931Pmes_UserInformation); - Q931SetMesProc(Q931mes_DISCONNECT, i, Q931ProcDisconnectNT, Q931Umes_Disconnect, Q931Pmes_Disconnect); - Q931SetMesProc(Q931mes_RELEASE, i, Q931ProcReleaseNT, Q931Umes_Release, Q931Pmes_Release); - Q931SetMesProc(Q931mes_RELEASE_COMPLETE, i, Q931ProcReleaseCompleteNT, Q931Umes_ReleaseComplete, Q931Pmes_ReleaseComplete); - Q931SetMesProc(Q931mes_RESTART, i, Q931ProcRestartNT, Q931Umes_Restart, Q931Pmes_Restart); - Q931SetMesProc(Q931mes_RESTART_ACKNOWLEDGE, i, Q931ProcRestartAckNT, Q931Umes_RestartAck, Q931Pmes_RestartAck); - Q931SetMesProc(Q931mes_CONGESTION_CONTROL, i, Q931ProcCongestionControlNT, Q931Umes_CongestionControl, Q931Pmes_CongestionControl); - Q931SetMesProc(Q931mes_INFORMATION, i, Q931ProcInformationNT, Q931Umes_Information, Q931Pmes_Information); - Q931SetMesProc(Q931mes_NOTIFY, i, Q931ProcNotifyNT, Q931Umes_Notify, Q931Pmes_Notify); - Q931SetMesProc(Q931mes_STATUS, i, Q931ProcStatusNT, Q931Umes_Status, Q931Pmes_Status); - Q931SetMesProc(Q931mes_STATUS_ENQUIRY, i, Q931ProcStatusEnquiryNT, Q931Umes_StatusEnquiry, Q931Pmes_StatusEnquiry); - Q931SetMesProc(Q931mes_SEGMENT, i, Q931ProcSegmentNT, Q931Umes_Segment, Q931Pmes_Segment); - - Q931SetMesProc(Q932mes_FACILITY, i, Q932ProcFacilityNT, Q932Umes_Facility, Q932Pmes_Facility); - Q931SetMesProc(Q932mes_HOLD, i, Q932ProcHoldNT, Q932Umes_Hold, Q932Pmes_Hold); - Q931SetMesProc(Q932mes_HOLD_ACKNOWLEDGE, i, Q932ProcHoldAckNT, Q932Umes_HoldAck, Q932Pmes_HoldAck); - Q931SetMesProc(Q932mes_HOLD_REJECT, i, Q932ProcHoldRejectNT, Q932Umes_HoldReject, Q932Pmes_HoldReject); - Q931SetMesProc(Q932mes_REGISTER, i, Q932ProcRegisterNT, Q932Umes_Register, Q932Pmes_Register); - Q931SetMesProc(Q932mes_RETRIEVE, i, Q932ProcRetrieveNT, Q932Umes_Retrieve, Q932Pmes_Retrieve); - Q931SetMesProc(Q932mes_RETRIEVE_ACKNOWLEDGE, i, Q932ProcRetrieveAckNT, Q932Umes_RetrieveAck, Q932Pmes_RetrieveAck); - Q931SetMesProc(Q932mes_RETRIEVE_REJECT, i, Q932ProcRetrieveRejectNT, Q932Umes_RetrieveReject, Q932Pmes_RetrieveReject); - - /* Set up the IE encoder/decoder handle table.*/ - Q931SetIEProc(Q931ie_SEGMENTED_MESSAGE, i, Q931Pie_Segment, Q931Uie_Segment); - Q931SetIEProc(Q931ie_BEARER_CAPABILITY, i, Q931Pie_BearerCap, Q931Uie_BearerCap); - Q931SetIEProc(Q931ie_CAUSE, i, Q931Pie_Cause, Q931Uie_Cause); - Q931SetIEProc(Q931ie_CALL_IDENTITY, i, Q931Pie_CallID, Q931Uie_CallID); - Q931SetIEProc(Q931ie_CALL_STATE, i, Q931Pie_CallState, Q931Uie_CallState); - Q931SetIEProc(Q931ie_CHANNEL_IDENTIFICATION, i, Q931Pie_ChanID, Q931Uie_ChanID); - Q931SetIEProc(Q931ie_PROGRESS_INDICATOR, i, Q931Pie_ProgInd, Q931Uie_ProgInd); - Q931SetIEProc(Q931ie_NETWORK_SPECIFIC_FACILITIES, i, Q931Pie_NetFac, Q931Uie_NetFac); - Q931SetIEProc(Q931ie_NOTIFICATION_INDICATOR, i, Q931Pie_NotifInd, Q931Uie_NotifInd); - Q931SetIEProc(Q931ie_DISPLAY, i, Q931Pie_Display, Q931Uie_Display); - Q931SetIEProc(Q931ie_DATETIME, i, Q931Pie_DateTime, Q931Uie_DateTime); - Q931SetIEProc(Q931ie_KEYPAD_FACILITY, i, Q931Pie_KeypadFac, Q931Uie_KeypadFac); - Q931SetIEProc(Q931ie_SIGNAL, i, Q931Pie_Signal, Q931Uie_Signal); - Q931SetIEProc(Q931ie_TRANSIT_DELAY_SELECTION_AND_IND, i, Q931Pie_TransNetSel, Q931Uie_TransNetSel); - Q931SetIEProc(Q931ie_CALLING_PARTY_NUMBER, i, Q931Pie_CallingNum, Q931Uie_CallingNum); - Q931SetIEProc(Q931ie_CALLING_PARTY_SUBADDRESS, i, Q931Pie_CallingSub, Q931Uie_CallingSub); - Q931SetIEProc(Q931ie_CALLED_PARTY_NUMBER, i, Q931Pie_CalledNum, Q931Uie_CalledNum); - Q931SetIEProc(Q931ie_CALLED_PARTY_SUBADDRESS, i, Q931Pie_CalledSub, Q931Uie_CalledSub); - Q931SetIEProc(Q931ie_TRANSIT_NETWORK_SELECTION, i, Q931Pie_TransNetSel, Q931Uie_TransNetSel); - Q931SetIEProc(Q931ie_RESTART_INDICATOR, i, Q931Pie_RestartInd, Q931Uie_RestartInd); - Q931SetIEProc(Q931ie_LOW_LAYER_COMPATIBILITY, i, Q931Pie_LLComp, Q931Uie_LLComp); - Q931SetIEProc(Q931ie_HIGH_LAYER_COMPATIBILITY, i, Q931Pie_HLComp, Q931Uie_HLComp); - Q931SetIEProc(Q931ie_USER_USER, i, Q931Pie_UserUser, Q931Uie_UserUser); - - Q931SetIEProc(Q931ie_CONNECTED_NUMBER, i, Q931Pie_Generic, Q931Uie_Generic); - Q931SetIEProc(Q931ie_FACILITY, i, Q931Pie_Generic, Q931Uie_Generic); - Q931SetIEProc(Q931ie_REDIRECTING_NUMBER, i, Q931Pie_Generic, Q931Uie_Generic); - - /* The following define a state machine. The point is that the Message - * procs can when search this to find out if the message/state - * combination is legale. If not, the proc for unexpected message apply. - */ - - /* TODO define state table here */ - - /* Timer default values */ - Q931SetTimerDefault(i, Q931_TIMER_T301, 180000); /* T301: 180s */ - Q931SetTimerDefault(i, Q931_TIMER_T302, 15000); /* T302: 15s */ - Q931SetTimerDefault(i, Q931_TIMER_T303, 4000); /* T303: 4s */ - Q931SetTimerDefault(i, Q931_TIMER_T304, 20000); /* T304: 20s */ - Q931SetTimerDefault(i, Q931_TIMER_T305, 30000); /* T305: 30s */ - Q931SetTimerDefault(i, Q931_TIMER_T306, 30000); /* T306: 30s */ - Q931SetTimerDefault(i, Q931_TIMER_T307, 180000); /* T307: 180s */ - Q931SetTimerDefault(i, Q931_TIMER_T308, 4000); /* T308: 4s */ - Q931SetTimerDefault(i, Q931_TIMER_T309, 60000); /* T309: 60s */ - Q931SetTimerDefault(i, Q931_TIMER_T310, 10000); /* T310: 10s */ - Q931SetTimerDefault(i, Q931_TIMER_T312, 12000); /* T312: 12s */ - Q931SetTimerDefault(i, Q931_TIMER_T314, 4000); /* T314: 4s */ - Q931SetTimerDefault(i, Q931_TIMER_T316, 120000); /* T316: 120s */ - Q931SetTimerDefault(i, Q931_TIMER_T317, 90000); /* T317: 90s */ - Q931SetTimerDefault(i, Q931_TIMER_T320, 30000); /* T320: 30s */ - Q931SetTimerDefault(i, Q931_TIMER_T321, 30000); /* T321: 30s */ - Q931SetTimerDefault(i, Q931_TIMER_T322, 4000); /* T322: 4s */ -} - -/***************************************************************************** - - Function: Q931ProcAlertingNT - -*****************************************************************************/ -L3INT Q931ProcAlertingNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* Reset 4 sec timer. */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom == 4) { - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcCallProceedingNT - -*****************************************************************************/ -L3INT Q931ProcCallProceedingNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here*/ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom == 4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcConnectNT - -*****************************************************************************/ -L3INT Q931ProcConnectNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here*/ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom == 4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcConnectAckNT - -*****************************************************************************/ -L3INT Q931ProcConnectAckNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here*/ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom == 4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcProgressNT - -*****************************************************************************/ -L3INT Q931ProcProgressNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here*/ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom == 4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcSetupNT - - Description: Process a SETUP message. - - *****************************************************************************/ -L3INT Q931ProcSetupNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Generic *pMes = (Q931mes_Generic *)&buf[Q931L4HeaderSpace]; - L3INT rc = 0; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Reject SETUP on existing calls */ - if (Q931GetCallState(pTrunk, pMes->CRV) != Q931_U0) { - Q931Disconnect(pTrunk, iFrom, pMes->CRV, 81); - return Q931E_UNEXPECTED_MESSAGE; - } - - /* outgoing call */ - if (iFrom == 4) { - ret = Q931CreateCRV(pTrunk, &callIndex); - if (ret) - return ret; - - pMes->CRV = pTrunk->call[callIndex].CRV; - - /* - * Outgoing SETUP message will be broadcasted in PTMP mode - */ - ret = Q931Tx32Data(pTrunk, Q931_IS_PTP(pTrunk) ? 0 : 1, buf, pMes->Size); - if (ret) - return ret; - - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - Q931SetState(pTrunk, callIndex, Q931_U1); - } - /* incoming call */ - else { - /* Locate free CRV entry and store info */ - ret = Q931AllocateCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) { - /* Not possible to allocate CRV entry, so must reject call */ - Q931Disconnect(pTrunk, iFrom, pMes->CRV, 42); - return ret; - } - - /* store TEI in call */ - pTrunk->call[callIndex].Tei = pMes->Tei; - - /* Send setup indication to user */ - ret = Q931Tx34(pTrunk, (L3UCHAR*)pMes, pMes->Size); - if (ret != Q931E_NO_ERROR) { - return ret; - } else { - /* Must be full queue, meaning we can't process the call */ - /* so we must disconnect */ - Q931Disconnect(pTrunk, iFrom, pMes->CRV, 81); - return ret; - } -#if 0 - /* TODO: Unreachable code??? */ - /* Set state U6 */ - Q931SetState(pTrunk, callIndex, Q931_U6); - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); -#endif - } - - return rc; -} - -/***************************************************************************** - - Function: Q931ProcSetupAckNT - - Description: Used to acknowedge a SETUP. Usually the first initial - response recevide back used to buy some time. - - Note that ChanID (B Channel Assignment) might come here from - NT side. - -*****************************************************************************/ -L3INT Q931ProcSetupAckNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here*/ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom == 4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcResumeNT - -*****************************************************************************/ -L3INT Q931ProcResumeNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here */ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom == 4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcResumeAckNT - -*****************************************************************************/ -L3INT Q931ProcResumeAckNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here*/ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom == 4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcResumeRejectNT - -*****************************************************************************/ -L3INT Q931ProcResumeRejectNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here*/ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom == 4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcSuspendNT - -*****************************************************************************/ -L3INT Q931ProcSuspendNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here*/ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom == 4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcSuspendAckNT - -*****************************************************************************/ -L3INT Q931ProcSuspendAckNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here*/ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom == 4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcSuspendRejectNT - -*****************************************************************************/ -L3INT Q931ProcSuspendRejectNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here*/ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom == 4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcInformationNT - -*****************************************************************************/ -L3INT Q931ProcUserInformationNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here*/ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom == 4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcDisconnectNT - -*****************************************************************************/ -L3INT Q931ProcDisconnectNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here*/ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom == 4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcReleaseNT - -*****************************************************************************/ -L3INT Q931ProcReleaseNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here*/ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom == 4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcReleaseCompleteNT - -*****************************************************************************/ -L3INT Q931ProcReleaseCompleteNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here*/ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom == 4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcRestartNT - -*****************************************************************************/ -L3INT Q931ProcRestartNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here*/ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom == 4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcRestartAckNT - -*****************************************************************************/ -L3INT Q931ProcRestartAckNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here*/ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom == 4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcCongestionControlNT - -*****************************************************************************/ -L3INT Q931ProcCongestionControlNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here*/ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom == 4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcInformationNT - -*****************************************************************************/ -L3INT Q931ProcInformationNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here*/ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom == 4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcNotifyNT - -*****************************************************************************/ -L3INT Q931ProcNotifyNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here*/ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom == 4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcStatusNT - -*****************************************************************************/ -L3INT Q931ProcStatusNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here*/ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom == 4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcStatusEnquiryNT - -*****************************************************************************/ -L3INT Q931ProcStatusEnquiryNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here*/ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom == 4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcSegmentNT - -*****************************************************************************/ -L3INT Q931ProcSegmentNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here*/ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom == 4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/****************************************************************************/ -/******************* Q.932 - Supplementary Services *************************/ -/****************************************************************************/ - -/***************************************************************************** - - Function: Q932ProcFacilityNT - -*****************************************************************************/ -L3INT Q932ProcFacilityNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here*/ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom == 4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q932ProcHoldNT - -*****************************************************************************/ -L3INT Q932ProcHoldNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here*/ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom == 4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q932ProcHoldAckNT - -*****************************************************************************/ -L3INT Q932ProcHoldAckNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here*/ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom == 4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q932ProcHoldRejectNT - -*****************************************************************************/ -L3INT Q932ProcHoldRejectNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here*/ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom == 4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q932ProcRegisterTE - -*****************************************************************************/ -L3INT Q932ProcRegisterNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here*/ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom == 4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q932ProcRetrieveNT - -*****************************************************************************/ -L3INT Q932ProcRetrieveNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here*/ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom == 4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcRetrieveAckNT - -*****************************************************************************/ -L3INT Q932ProcRetrieveAckNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here*/ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom == 4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcRetrieveRejectNT - -*****************************************************************************/ -L3INT Q932ProcRetrieveRejectNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here*/ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom == 4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} diff --git a/libs/freetdm/src/isdn/Q931StateTE.c b/libs/freetdm/src/isdn/Q931StateTE.c deleted file mode 100644 index 562dd0b458..0000000000 --- a/libs/freetdm/src/isdn/Q931StateTE.c +++ /dev/null @@ -1,1310 +0,0 @@ -/***************************************************************************** - - FileName: q931StateTE.c - - Contents: Q.931 State Engine for TE (User Mode). - - The controlling state engine for Q.931 is the state engine - on the NT side. The state engine on the TE side is a slave - of this. The TE side maintain it's own states as described in - ITU-T Q931, but will in raise conditions be overridden by - the NT side. - - This reference implementation uses a process per message, - meaning that each message must check call states. This - is easier for dialect maintenance as each message proc - can be replaced individually. A new TE variant only - need to copy the Q931CreateTE and replace those procs or - need to override. - - License/Copyright: - - Copyright (c) 2007, Jan Vidar Berger, Case Labs, Ltd. All rights reserved. - email:janvb@caselaboratories.com - - 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 Case Labs, Ltd 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT OWNER OR CONTRIBUTORS 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 SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*****************************************************************************/ - -#include "Q931.h" - -extern L3INT Q931L4HeaderSpace; - -/***************************************************************************** - Function: Q931CreateTE - - Description: Will create the Q931 TE as a Dialect in the stack. The first - bulk set up the message handlers, the second bulk the IE - encoders/coders, and the last bulk set up the state table. - - Parameters: i Dialect index -*****************************************************************************/ -void Q931CreateTE(L3UCHAR i) -{ - Q931SetMesProc(Q931mes_ALERTING, i, Q931ProcAlertingTE, Q931Umes_Alerting, Q931Pmes_Alerting); - Q931SetMesProc(Q931mes_CALL_PROCEEDING, i, Q931ProcCallProceedingTE, Q931Umes_CallProceeding, Q931Pmes_CallProceeding); - Q931SetMesProc(Q931mes_CONNECT, i, Q931ProcConnectTE, Q931Umes_Connect, Q931Pmes_Connect); - Q931SetMesProc(Q931mes_CONNECT_ACKNOWLEDGE, i, Q931ProcConnectAckTE, Q931Umes_ConnectAck, Q931Pmes_ConnectAck); - Q931SetMesProc(Q931mes_PROGRESS, i, Q931ProcProgressTE, Q931Umes_Progress, Q931Pmes_Progress); - Q931SetMesProc(Q931mes_SETUP, i, Q931ProcSetupTE, Q931Umes_Setup, Q931Pmes_Setup); - Q931SetMesProc(Q931mes_SETUP_ACKNOWLEDGE, i, Q931ProcSetupAckTE, Q931Umes_SetupAck, Q931Pmes_SetupAck); - Q931SetMesProc(Q931mes_RESUME, i, Q931ProcResumeTE, Q931Umes_Resume, Q931Pmes_Resume); - Q931SetMesProc(Q931mes_RESUME_ACKNOWLEDGE, i, Q931ProcResumeAckTE, Q931Umes_ResumeAck, Q931Pmes_ResumeAck); - Q931SetMesProc(Q931mes_RESUME_REJECT, i, Q931ProcResumeRejectTE, Q931Umes_ResumeReject, Q931Pmes_ResumeReject); - Q931SetMesProc(Q931mes_SUSPEND, i, Q931ProcSuspendTE, Q931Umes_Suspend, Q931Pmes_Suspend); - Q931SetMesProc(Q931mes_SUSPEND_ACKNOWLEDGE, i, Q931ProcSuspendAckTE, Q931Umes_SuspendAck, Q931Pmes_SuspendAck); - Q931SetMesProc(Q931mes_SUSPEND_REJECT, i, Q931ProcSuspendRejectTE, Q931Umes_SuspendReject, Q931Pmes_SuspendReject); - Q931SetMesProc(Q931mes_USER_INFORMATION, i, Q931ProcUserInformationTE, Q931Umes_UserInformation, Q931Pmes_UserInformation); - Q931SetMesProc(Q931mes_DISCONNECT, i, Q931ProcDisconnectTE, Q931Umes_Disconnect, Q931Pmes_Disconnect); - Q931SetMesProc(Q931mes_RELEASE, i, Q931ProcReleaseTE, Q931Umes_Release, Q931Pmes_Release); - Q931SetMesProc(Q931mes_RELEASE_COMPLETE, i, Q931ProcReleaseCompleteTE, Q931Umes_ReleaseComplete, Q931Pmes_ReleaseComplete); - Q931SetMesProc(Q931mes_RESTART, i, Q931ProcRestartTE, Q931Umes_Restart, Q931Pmes_Restart); - Q931SetMesProc(Q931mes_RESTART_ACKNOWLEDGE, i, Q931ProcRestartAckTE, Q931Umes_RestartAck, Q931Pmes_RestartAck); - Q931SetMesProc(Q931mes_CONGESTION_CONTROL, i, Q931ProcCongestionControlTE, Q931Umes_CongestionControl, Q931Pmes_CongestionControl); - Q931SetMesProc(Q931mes_INFORMATION, i, Q931ProcInformationTE, Q931Umes_Information, Q931Pmes_Information); - Q931SetMesProc(Q931mes_NOTIFY, i, Q931ProcNotifyTE, Q931Umes_Notify, Q931Pmes_Notify); - Q931SetMesProc(Q931mes_STATUS, i, Q931ProcStatusTE, Q931Umes_Status, Q931Pmes_Status); - Q931SetMesProc(Q931mes_STATUS_ENQUIRY, i, Q931ProcStatusEnquiryTE, Q931Umes_StatusEnquiry, Q931Pmes_StatusEnquiry); - Q931SetMesProc(Q931mes_SEGMENT, i, Q931ProcSegmentTE, Q931Umes_Segment, Q931Pmes_Segment); - - Q931SetMesProc(Q932mes_FACILITY, i, Q932ProcFacilityTE, Q932Umes_Facility, Q932Pmes_Facility); - Q931SetMesProc(Q932mes_HOLD, i, Q932ProcHoldTE, Q932Umes_Hold, Q932Pmes_Hold); - Q931SetMesProc(Q932mes_HOLD_ACKNOWLEDGE, i, Q932ProcHoldAckTE, Q932Umes_HoldAck, Q932Pmes_HoldAck); - Q931SetMesProc(Q932mes_HOLD_REJECT, i, Q932ProcHoldRejectTE, Q932Umes_HoldReject, Q932Pmes_HoldReject); - Q931SetMesProc(Q932mes_REGISTER, i, Q932ProcRegisterTE, Q932Umes_Register, Q932Pmes_Register); - Q931SetMesProc(Q932mes_RETRIEVE, i, Q932ProcRetrieveTE, Q932Umes_Retrieve, Q932Pmes_Retrieve); - Q931SetMesProc(Q932mes_RETRIEVE_ACKNOWLEDGE, i, Q932ProcRetrieveAckTE, Q932Umes_RetrieveAck, Q932Pmes_RetrieveAck); - Q931SetMesProc(Q932mes_RETRIEVE_REJECT, i, Q932ProcRetrieveRejectTE, Q932Umes_RetrieveReject, Q932Pmes_RetrieveReject); - - /* Set up the IE encoder/decoder handle table.*/ - Q931SetIEProc(Q931ie_SEGMENTED_MESSAGE, i, Q931Pie_Segment, Q931Uie_Segment); - Q931SetIEProc(Q931ie_BEARER_CAPABILITY, i, Q931Pie_BearerCap, Q931Uie_BearerCap); - Q931SetIEProc(Q931ie_CAUSE, i, Q931Pie_Cause, Q931Uie_Cause); - Q931SetIEProc(Q931ie_CALL_IDENTITY, i, Q931Pie_CallID, Q931Uie_CallID); - Q931SetIEProc(Q931ie_CALL_STATE, i, Q931Pie_CallState, Q931Uie_CallState); - Q931SetIEProc(Q931ie_CHANNEL_IDENTIFICATION, i, Q931Pie_ChanID, Q931Uie_ChanID); - Q931SetIEProc(Q931ie_PROGRESS_INDICATOR, i, Q931Pie_ProgInd, Q931Uie_ProgInd); - Q931SetIEProc(Q931ie_NETWORK_SPECIFIC_FACILITIES, i, Q931Pie_NetFac, Q931Uie_NetFac); - Q931SetIEProc(Q931ie_NOTIFICATION_INDICATOR, i, Q931Pie_NotifInd, Q931Uie_NotifInd); - Q931SetIEProc(Q931ie_DISPLAY, i, Q931Pie_Display, Q931Uie_Display); - Q931SetIEProc(Q931ie_DATETIME, i, Q931Pie_DateTime, Q931Uie_DateTime); - Q931SetIEProc(Q931ie_KEYPAD_FACILITY, i, Q931Pie_KeypadFac, Q931Uie_KeypadFac); - Q931SetIEProc(Q931ie_SIGNAL, i, Q931Pie_Signal, Q931Uie_Signal); - Q931SetIEProc(Q931ie_TRANSIT_DELAY_SELECTION_AND_IND, i, Q931Pie_TransNetSel, Q931Uie_TransNetSel); - Q931SetIEProc(Q931ie_CALLING_PARTY_NUMBER, i, Q931Pie_CallingNum, Q931Uie_CallingNum); - Q931SetIEProc(Q931ie_CALLING_PARTY_SUBADDRESS, i, Q931Pie_CallingSub, Q931Uie_CallingSub); - Q931SetIEProc(Q931ie_CALLED_PARTY_NUMBER, i, Q931Pie_CalledNum, Q931Uie_CalledNum); - Q931SetIEProc(Q931ie_CALLED_PARTY_SUBADDRESS, i, Q931Pie_CalledSub, Q931Uie_CalledSub); - Q931SetIEProc(Q931ie_TRANSIT_NETWORK_SELECTION, i, Q931Pie_TransNetSel, Q931Uie_TransNetSel); - Q931SetIEProc(Q931ie_RESTART_INDICATOR, i, Q931Pie_RestartInd, Q931Uie_RestartInd); - Q931SetIEProc(Q931ie_LOW_LAYER_COMPATIBILITY, i, Q931Pie_LLComp, Q931Uie_LLComp); - Q931SetIEProc(Q931ie_HIGH_LAYER_COMPATIBILITY, i, Q931Pie_HLComp, Q931Uie_HLComp); - Q931SetIEProc(Q931ie_USER_USER, i, Q931Pie_UserUser, Q931Uie_UserUser); - - Q931SetIEProc(Q931ie_CONNECTED_NUMBER, i, Q931Pie_Generic, Q931Uie_Generic); - Q931SetIEProc(Q931ie_FACILITY, i, Q931Pie_Generic, Q931Uie_Generic); - Q931SetIEProc(Q931ie_REDIRECTING_NUMBER, i, Q931Pie_Generic, Q931Uie_Generic); - - /* The following define a state machine. The point is that the Message - * procs can when search this to find out if the message/state - * combination is legale. If not, the proc for unexpected message apply. - */ - - /* State 0 Idle */ - Q931AddStateEntry(i, Q931_U0, Q931mes_RESUME, 2); - Q931AddStateEntry(i, Q931_U0, Q931mes_SETUP, 4); - Q931AddStateEntry(i, Q931_U0, Q931mes_SETUP, 2); - Q931AddStateEntry(i, Q931_U0, Q931mes_STATUS, 4); - Q931AddStateEntry(i, Q931_U0, Q931mes_RELEASE, 4); - Q931AddStateEntry(i, Q931_U0, Q931mes_RELEASE_COMPLETE, 4); - - /* State 1 Call Initiating */ - Q931AddStateEntry(i, Q931_U1, Q931mes_DISCONNECT, 2); - Q931AddStateEntry(i, Q931_U1, Q931mes_SETUP_ACKNOWLEDGE, 4); - Q931AddStateEntry(i, Q931_U1, Q931mes_RELEASE_COMPLETE, 4); - Q931AddStateEntry(i, Q931_U1, Q931mes_CALL_PROCEEDING, 4); - Q931AddStateEntry(i, Q931_U1, Q931mes_ALERTING, 4); - Q931AddStateEntry(i, Q931_U1, Q931mes_CONNECT, 4); - - /* State 2 Overlap Sending */ - Q931AddStateEntry(i, Q931_U2, Q931mes_INFORMATION, 2); - Q931AddStateEntry(i, Q931_U2, Q931mes_CALL_PROCEEDING, 4); - Q931AddStateEntry(i, Q931_U2, Q931mes_ALERTING, 4); - Q931AddStateEntry(i, Q931_U2, Q931mes_PROGRESS, 4); - Q931AddStateEntry(i, Q931_U2, Q931mes_CONNECT, 4); - Q931AddStateEntry(i, Q931_U2, Q931mes_RELEASE, 2); - - /* State 3 Outgoing Call Proceeding */ - Q931AddStateEntry(i, Q931_U3, Q931mes_PROGRESS, 4); - Q931AddStateEntry(i, Q931_U3, Q931mes_ALERTING, 4); - Q931AddStateEntry(i, Q931_U3, Q931mes_CONNECT, 4); - Q931AddStateEntry(i, Q931_U3, Q931mes_RELEASE, 2); - - /* State 4 Call Delivered */ - Q931AddStateEntry(i, Q931_U4, Q931mes_CONNECT, 4); - - /* State 6 Call Precent */ - Q931AddStateEntry(i, Q931_U6, Q931mes_INFORMATION, 2); - Q931AddStateEntry(i, Q931_U6, Q931mes_ALERTING, 2); - Q931AddStateEntry(i, Q931_U6, Q931mes_CALL_PROCEEDING, 2); - Q931AddStateEntry(i, Q931_U6, Q931mes_CONNECT, 2); - Q931AddStateEntry(i, Q931_U6, Q931mes_RELEASE_COMPLETE, 2); - Q931AddStateEntry(i, Q931_U6, Q931mes_RELEASE, 4); - Q931AddStateEntry(i, Q931_U6, Q931mes_DISCONNECT, 4); - - /* State 7 Call Received */ - Q931AddStateEntry(i, Q931_U7, Q931mes_CONNECT, 2); - - /* State 8 Connect request */ - Q931AddStateEntry(i, Q931_U8, Q931mes_CONNECT_ACKNOWLEDGE, 4); - - /* State 9 Incoming Call Proceeding */ - Q931AddStateEntry(i, Q931_U9, Q931mes_CONNECT, 2); - Q931AddStateEntry(i, Q931_U9, Q931mes_ALERTING, 2); - Q931AddStateEntry(i, Q931_U9, Q931mes_PROGRESS, 2); - - /* State 10 Active */ - Q931AddStateEntry(i, Q931_U10, Q931mes_SUSPEND, 2); - Q931AddStateEntry(i, Q931_U10, Q931mes_NOTIFY, 4); - Q931AddStateEntry(i, Q931_U10, Q931mes_NOTIFY, 2); - - /* State 11 Disconnect Request */ - Q931AddStateEntry(i, Q931_U11, Q931mes_RELEASE, 4); - Q931AddStateEntry(i, Q931_U11, Q931mes_DISCONNECT, 4); - Q931AddStateEntry(i, Q931_U11, Q931mes_NOTIFY, 4); - - /* State 12 Disconnect Ind */ - Q931AddStateEntry(i, Q931_U12, Q931mes_RELEASE, 4); - Q931AddStateEntry(i, Q931_U12, Q931mes_RELEASE, 2); - - /* State 15 Suspend Request */ - Q931AddStateEntry(i, Q931_U15, Q931mes_SUSPEND_ACKNOWLEDGE, 4); - Q931AddStateEntry(i, Q931_U15, Q931mes_SUSPEND_REJECT, 4); - Q931AddStateEntry(i, Q931_U15, Q931mes_DISCONNECT, 4); - Q931AddStateEntry(i, Q931_U15, Q931mes_RELEASE, 4); - -/* TODO - Q931AddStateEntry(i, Q931_U17, - Q931AddStateEntry(i, Q931_U19, - Q931AddStateEntry(i, Q931_U25, -*/ - - /* Timer default values */ - Q931SetTimerDefault(i, Q931_TIMER_T301, 180000); /* T301: 180s */ - Q931SetTimerDefault(i, Q931_TIMER_T302, 15000); /* T302: 15s */ - Q931SetTimerDefault(i, Q931_TIMER_T303, 4000); /* T303: 4s */ - Q931SetTimerDefault(i, Q931_TIMER_T304, 30000); /* T304: 30s */ - Q931SetTimerDefault(i, Q931_TIMER_T305, 30000); /* T305: 30s */ - Q931SetTimerDefault(i, Q931_TIMER_T308, 4000); /* T308: 4s */ - Q931SetTimerDefault(i, Q931_TIMER_T309, 60000); /* T309: 60s */ - Q931SetTimerDefault(i, Q931_TIMER_T310, 60000); /* T310: 60s */ - Q931SetTimerDefault(i, Q931_TIMER_T313, 4000); /* T313: 4s */ - Q931SetTimerDefault(i, Q931_TIMER_T314, 4000); /* T314: 4s */ - Q931SetTimerDefault(i, Q931_TIMER_T316, 120000); /* T316: 120s */ - Q931SetTimerDefault(i, Q931_TIMER_T317, 90000); /* T317: 90s */ - Q931SetTimerDefault(i, Q931_TIMER_T318, 4000); /* T318: 4s */ - Q931SetTimerDefault(i, Q931_TIMER_T319, 4000); /* T319: 4s */ - Q931SetTimerDefault(i, Q931_TIMER_T321, 30000); /* T321: 30s */ - Q931SetTimerDefault(i, Q931_TIMER_T322, 4000); /* T322: 4s */ -} - -/***************************************************************************** - - Function: Q931ProcAlertingTE - -*****************************************************************************/ -L3INT Q931ProcAlertingTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* Reset 4 sec timer. */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom == 4) { - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcCallProceedingTE - -*****************************************************************************/ -L3INT Q931ProcCallProceedingTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here */ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom == 4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcConnectTE - -*****************************************************************************/ -L3INT Q931ProcConnectTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here */ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom ==4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - if (pTrunk->autoConnectAck) { - Q931AckConnect(pTrunk, buf); - } - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcConnectAckTE - -*****************************************************************************/ -L3INT Q931ProcConnectAckTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here */ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom ==4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcProgressTE - -*****************************************************************************/ -L3INT Q931ProcProgressTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here */ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom ==4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcSetupTE - -*****************************************************************************/ -L3INT Q931ProcSetupTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Generic *pMes = (Q931mes_Generic *)&buf[Q931L4HeaderSpace]; - L3INT rc = 0; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Reject SETUP on existing calls */ - if (Q931GetCallState(pTrunk, pMes->CRV) != Q931_U0) { - Q931Disconnect(pTrunk, iFrom, pMes->CRV, 81); - return Q931E_UNEXPECTED_MESSAGE; - } - - /* outgoing call */ - if (iFrom == 4) { - ret = Q931CreateCRV(pTrunk, &callIndex); - if (ret) - return ret; - pMes->CRV = pTrunk->call[callIndex].CRV; - - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - if (ret) - return ret; - - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - - /* TODO: Add this back when we get the state stuff more filled out */ - /*Q931SetState(pTrunk, callIndex, Q931_U1);*/ - } - /* incoming call */ - else { - /* Locate free CRV entry and store info */ - ret = Q931AllocateCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) { - /* Not possible to allocate CRV entry, so must reject call */ - Q931Disconnect(pTrunk, iFrom, pMes->CRV, 42); - return ret; - } - - /* Send setup indication to user */ - ret = Q931Tx34(pTrunk, (L3UCHAR*)pMes, pMes->Size); - if (ret != Q931E_NO_ERROR) { - if (pTrunk->autoSetupAck) { - Q931AckSetup(pTrunk, buf); - } - return ret; - } else { - /* Must be full queue, meaning we can't process the call */ - /* so we must disconnect */ - Q931Disconnect(pTrunk, iFrom, pMes->CRV, 81); - return ret; - } -#if 0 - /* TODO: Unreachable code??? */ - /* Set state U6 */ - Q931SetState(pTrunk, callIndex, Q931_U6); - - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); -#endif - } - return rc; -} - -/***************************************************************************** - - Function: Q931ProcSetupAckTE - - Description: Used to acknowedge a SETUP. Usually the first initial - response recevide back used to buy some time. L4 sending this - should only be passed on. L2 sending this means that we set - a new timer (and pass it to L4). - - Note that ChanID (B Channel Assignment) might come here from - NT side. - -*****************************************************************************/ -L3INT Q931ProcSetupAckTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom ==4) { - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcResumeTE - -*****************************************************************************/ -L3INT Q931ProcResumeTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Generic * pMes = (Q931mes_Generic *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - if (Q931GetCallState(pTrunk, pMes->CRV) == Q931_U0 && iFrom ==4) { - /* Call reference selection */ - ret = Q931CreateCRV(pTrunk, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - pMes->CRV = pTrunk->call[callIndex].CRV; - - /* Send RESUME to network */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - if (ret != Q931E_NO_ERROR) - return ret; - - /* Start timer T318 */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T318); - - /* set state U17 */ - Q931SetState(pTrunk, callIndex, Q931_U17); - } else { - return Q931E_ILLEGAL_MESSAGE; - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcResumeAckTE - -*****************************************************************************/ -L3INT Q931ProcResumeAckTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here */ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom ==4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcResumeRejectTE - -*****************************************************************************/ -L3INT Q931ProcResumeRejectTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here */ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom ==4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcSuspendTE - -*****************************************************************************/ -L3INT Q931ProcSuspendTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here */ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom ==4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcSuspendAckTE - -*****************************************************************************/ -L3INT Q931ProcSuspendAckTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here */ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom ==4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcSuspendRejectTE - -*****************************************************************************/ -L3INT Q931ProcSuspendRejectTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here */ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom ==4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcInformationTE - -*****************************************************************************/ -L3INT Q931ProcUserInformationTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here */ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom ==4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcDisconnectTE - -*****************************************************************************/ -L3INT Q931ProcDisconnectTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - Q931Log(pTrunk, Q931_LOG_DEBUG, "Processing DISCONNECT message from %s for CRV: %d (%#hx)\n", - iFrom == 4 ? "Local" : "Remote", pMes->CRV, pMes->CRV); - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here */ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom ==4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcReleaseTE - -*****************************************************************************/ -L3INT Q931ProcReleaseTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Generic *pMes = (Q931mes_Generic *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT state = Q931GetCallState(pTrunk, pMes->CRV); - L3INT ret = Q931E_NO_ERROR; - - if (iFrom == 4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (state == Q931_U0 && iFrom == 2) { - Q931Tx34(pTrunk, buf, pMes->Size); - ret = Q931ReleaseComplete(pTrunk, buf); - } else { - ret = Q931ProcUnexpectedMessage(pTrunk, buf, iFrom); - } - if (pMes->CRV && iFrom == 2) { - /* Find the call using CRV */ - if ((Q931FindCRV(pTrunk, pMes->CRV, &callIndex)) != Q931E_NO_ERROR) - return ret; - pTrunk->call[callIndex].InUse = 0; - } - - return ret; -} - -/***************************************************************************** - - Function: Q931ProcReleaseCompleteTE - -*****************************************************************************/ -L3INT Q931ProcReleaseCompleteTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Generic *pMes = (Q931mes_Generic *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } else { - if (pMes->CRV) { - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - pTrunk->call[callIndex].InUse = 0; - - /* TODO: experimental, send RELEASE_COMPLETE message */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcRestartTE - -*****************************************************************************/ -L3INT Q931ProcRestartTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - if (pMes->CRV) { - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - } - - /* TODO chack against state table for illegal or unexpected message here */ - - if (iFrom ==4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - - if (pTrunk->autoRestartAck) { - Q931AckRestart(pTrunk, buf); - } - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcRestartAckTE - -*****************************************************************************/ -L3INT Q931ProcRestartAckTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - if (pMes->CRV) { - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - } - - /* TODO chack against state table for illegal or unexpected message here */ - - if (iFrom ==4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcCongestionControlTE - -*****************************************************************************/ -L3INT Q931ProcCongestionControlTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here */ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom ==4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcInformationTE - -*****************************************************************************/ -L3INT Q931ProcInformationTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here */ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom ==4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcNotifyTE - -*****************************************************************************/ -L3INT Q931ProcNotifyTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here */ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom ==4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcStatusTE - -*****************************************************************************/ -L3INT Q931ProcStatusTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here */ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom ==4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcStatusEnquiryTE - -*****************************************************************************/ -L3INT Q931ProcStatusEnquiryTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here */ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom ==4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcSegmentTE - -*****************************************************************************/ -L3INT Q931ProcSegmentTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here */ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom ==4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/****************************************************************************/ -/******************* Q.932 - Supplementary Services *************************/ -/****************************************************************************/ - -/***************************************************************************** - - Function: Q932ProcRetrieveTE - -*****************************************************************************/ -L3INT Q932ProcFacilityTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here */ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom ==4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q932ProcRetrieveTE - -*****************************************************************************/ -L3INT Q932ProcHoldTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here */ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom ==4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q932ProcRetrieveTE - -*****************************************************************************/ -L3INT Q932ProcHoldAckTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here */ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom ==4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q932ProcRetrieveTE - -*****************************************************************************/ -L3INT Q932ProcHoldRejectTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here */ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom ==4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q932ProcRegisterTE - -*****************************************************************************/ -L3INT Q932ProcRegisterTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here */ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom ==4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q932ProcRetrieveTE - -*****************************************************************************/ -L3INT Q932ProcRetrieveTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here */ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom ==4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcRetrieveAckTE - -*****************************************************************************/ -L3INT Q932ProcRetrieveAckTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here */ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom ==4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} - -/***************************************************************************** - - Function: Q931ProcRetrieveRejectTE - -*****************************************************************************/ -L3INT Q932ProcRetrieveRejectTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) -{ - Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; - - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if (ret != Q931E_NO_ERROR) - return ret; - - /* TODO chack against state table for illegal or unexpected message here */ - - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303); - if (iFrom ==4) { - /* TODO Add proc here */ - ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); - } - else if (iFrom == 2) { - /* TODO Add proc here */ - ret = Q931Tx34(pTrunk, buf, pMes->Size); - } - return ret; -} diff --git a/libs/freetdm/src/isdn/Q931api.c b/libs/freetdm/src/isdn/Q931api.c deleted file mode 100644 index ed0d13836b..0000000000 --- a/libs/freetdm/src/isdn/Q931api.c +++ /dev/null @@ -1,598 +0,0 @@ -/***************************************************************************** - - FileName: Q931api.c - - Contents: api (Application Programming Interface) functions. - See q931.h for description. - - License/Copyright: - - Copyright (c) 2007, Jan Vidar Berger, Case Labs, Ltd. All rights reserved. - email:janvb@caselaboratories.com - - 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 Case Labs, Ltd 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT OWNER OR CONTRIBUTORS 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 SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*****************************************************************************/ - -#include "Q931.h" -#include "memory.h" - -extern L3INT Q931L4HeaderSpace; - -/* -L3INT Q931CreateMesIndex(L3INT mc) -{ - if(mc < 0 || mc > 127 ) - return Q931E_INTERNAL; - - if(Q931MesCount >127) - return Q931E_INTERNAL; - - Q931MesIndex[mc] = Q931MesCount ++; - - return Q931E_NO_ERROR; -} -*/ -/* -L3INT Q931CreateIEIndex(L3INT iec) -{ - if(iec < 0 || iec > 127 ) - return Q931E_INTERNAL; - - if(Q931IECount > 127) - return Q931E_INTERNAL; - - Q931IEIndex[iec] = Q931IECount ++; - - return Q931E_NO_ERROR; -} -*/ - -L3INT Q931Api_InitTrunk(Q931_TrunkInfo_t *pTrunk, - Q931Dialect_t Dialect, - Q931NetUser_t NetUser, - Q931_TrunkType_t TrunkType, - Q931Tx34CB_t Q931Tx34CBProc, - Q931Tx32CB_t Q931Tx32CBProc, - Q931ErrorCB_t Q931ErrorCBProc, - void *PrivateData32, - void *PrivateData34) -{ - int y, dchannel, maxchans, has_sync = 0; - - switch(TrunkType) - { - case Q931_TrType_E1: - dchannel = 16; - maxchans = 31; - has_sync = 1; - break; - - case Q931_TrType_T1: - case Q931_TrType_J1: - dchannel = 24; - maxchans = 24; - break; - - case Q931_TrType_BRI: - case Q931_TrType_BRI_PTMP: - dchannel = 3; - maxchans = 3; - break; - - default: - return 0; - } - - pTrunk->Q931Tx34CBProc = Q931Tx34CBProc; - pTrunk->Q931Tx32CBProc = Q931Tx32CBProc; - pTrunk->Q931ErrorCBProc = Q931ErrorCBProc; - pTrunk->PrivateData32 = PrivateData32; - pTrunk->PrivateData34 = PrivateData34; - - pTrunk->LastCRV = 0; - pTrunk->Dialect = Dialect + NetUser; - pTrunk->Enabled = 0; - pTrunk->TrunkType = TrunkType; - pTrunk->NetUser = NetUser; - pTrunk->TrunkState = 0; - pTrunk->autoRestartAck = 0; - for(y=0; y < Q931MAXCHPERTRUNK; y++) - { - pTrunk->ch[y].Available = 1; - - if(has_sync && y == 0) - { - pTrunk->ch[y].ChanType = Q931_ChType_Sync; - } - else if(y == dchannel) - { - pTrunk->ch[y].ChanType = Q931_ChType_D; - } - else if(y > maxchans) - { - pTrunk->ch[y].ChanType = Q931_ChType_NotUsed; - } - else - { - pTrunk->ch[y].ChanType = Q931_ChType_B; - } - } - - for(y=0; y < Q931MAXCALLPERTRUNK; y++) - { - pTrunk->call[y].InUse = 0; - - } - return 1; -} - -void Q931SetMesProc(L3UCHAR mes, L3UCHAR dialect, q931proc_func_t *Q931ProcFunc, q931umes_func_t *Q931UmesFunc, q931pmes_func_t *Q931PmesFunc) -{ - if(Q931ProcFunc != NULL) - Q931Proc[dialect][mes] = Q931ProcFunc; - if(Q931UmesFunc != NULL) - Q931Umes[dialect][mes] = Q931UmesFunc; - if(Q931PmesFunc != NULL) - Q931Pmes[dialect][mes] = Q931PmesFunc; -} - -void Q931SetIEProc(L3UCHAR iec, L3UCHAR dialect, q931pie_func_t *Q931PieProc, q931uie_func_t *Q931UieProc) -{ - if(Q931PieProc != NULL) - Q931Pie[dialect][iec] = Q931PieProc; - if(Q931UieProc != NULL) - Q931Uie[dialect][iec] = Q931UieProc; -} - -void Q931SetTimeoutProc(L3UCHAR dialect, L3UCHAR timer, q931timeout_func_t *Q931TimeoutProc) -{ - if(Q931Timeout != NULL) - Q931Timeout[dialect][timer] = Q931TimeoutProc; -} - -void Q931SetTimerDefault(L3UCHAR dialect, L3UCHAR timer, q931timer_t timeout) -{ - Q931Timer[dialect][timer] = timeout; -} - -L3INT Q931GetMesSize(Q931mes_Generic *pMes) -{ - - L3UCHAR *p = &pMes->buf[0]; - L3INT Size = (L3INT)(p - (L3UCHAR *)pMes); - return Size; -} - -/***************************************************************************** - - Function: q931AppendIE - - Description: Append IE to the message. - - Parameters: pm Ptr to message. - pi Ptr to information element - - Return Value ie setting - -*****************************************************************************/ - -ie Q931AppendIE( L3UCHAR *pm, L3UCHAR *pi) -{ - ie IE = 0; - Q931mes_Generic * pMes= (Q931mes_Generic *)pm; - Q931ie_BearerCap * pIE= (Q931ie_BearerCap *)pi; - L3INT iISize = pIE->Size; - - L3UCHAR *pBuf = &pMes->buf[0]; - L3INT Off = (L3INT)(pMes->Size - (pBuf - pm)); - IE = (ie)(Off | 0x8000); - - memcpy(&pm[pMes->Size], pi, iISize); - - pMes->Size += iISize; - - return IE; -} - -/***************************************************************************** -*****************************************************************************/ -static L3INT crv={1}; - -L3INT Q931GetUniqueCRV(Q931_TrunkInfo_t *pTrunk) -{ - L3INT max = (Q931_IS_BRI(pTrunk)) ? Q931_BRI_MAX_CRV : Q931_PRI_MAX_CRV; - - crv++; - crv = (crv <= max) ? crv : 1; - - return crv; -} - -L3INT Q931InitMesGeneric(Q931mes_Generic *pMes) -{ - memset(pMes, 0, sizeof(*pMes)); - pMes->ProtDisc = 0x08; - pMes->Size = Q931GetMesSize(pMes); - - return 0; -} - -L3INT Q931InitMesResume(Q931mes_Generic * pMes) -{ - pMes->ProtDisc = 0x08; - pMes->CRV = 0; /* CRV to be allocated, might be receive*/ - pMes->MesType = Q931mes_RESUME; - - pMes->Size = Q931GetMesSize(pMes); - pMes->CallID = 0; /* Channel Identification */ - return 0; -} - -L3INT Q931InitMesRestartAck(Q931mes_Generic * pMes) -{ - pMes->ProtDisc = 0x08; - pMes->CRV = 0; /* CRV to be allocated, might be receive*/ - pMes->MesType = Q931mes_RESTART_ACKNOWLEDGE; - - pMes->Size = Q931GetMesSize(pMes); - pMes->ChanID = 0; /* Channel Identification */ - pMes->Display = 0; - pMes->RestartInd = 0; - pMes->RestartWin = 0; - return 0; -} - -L3INT Q931InitIEBearerCap(Q931ie_BearerCap *pIE) -{ - pIE->IEId = Q931ie_BEARER_CAPABILITY; - pIE->Size = sizeof(Q931ie_BearerCap); - pIE->CodStand = 0; - pIE->ITC = 0; - pIE->TransMode = 0; - pIE->ITR = 0x10; - pIE->RateMul = 0; - - pIE->Layer1Ident = 0; - pIE->UIL1Prot = 0; /* User Information Layer 1 Protocol */ - pIE->SyncAsync = 0; /* Sync/Async */ - pIE->Negot = 0; - pIE->UserRate = 0; - pIE->InterRate = 0; /* Intermediate Rate */ - pIE->NIConTx = 0; - pIE->NIConRx = 0; - pIE->FlowCtlTx = 0; /* Flow control on Tx */ - pIE->FlowCtlRx = 0; /* Flow control on Rx */ - pIE->HDR = 0; - pIE->MultiFrame = 0; /* Multi frame support */ - pIE->Mode = 0; - pIE->LLInegot = 0; - pIE->Assignor = 0; /* Assignor/assignee */ - pIE->InBandNeg = 0; /* In-band/out-band negot. */ - pIE->NumStopBits = 0; /* Number of stop bits */ - pIE->NumDataBits = 0; /* Number of data bits. */ - pIE->Parity = 0; - pIE->DuplexMode = 0; - pIE->ModemType = 0; - pIE->Layer2Ident = 0; - pIE->UIL2Prot = 0; /* User Information Layer 2 Protocol */ - pIE->Layer3Ident = 0; - pIE->UIL3Prot = 0; /* User Information Layer 3 Protocol */ - pIE->AL3Info1 = 0; - pIE->AL3Info2 = 0; - - return 0; -} - -L3INT Q931InitIEChanID(Q931ie_ChanID *pIE) -{ - pIE->IEId = Q931ie_CHANNEL_IDENTIFICATION; - pIE->Size = sizeof(Q931ie_ChanID); - pIE->IntIDPresent = 0; /* Int. id. present */ - pIE->IntType = 0; /* Int. type */ - pIE->PrefExcl = 0; /* Pref./Excl. */ - pIE->DChanInd = 0; /* D-channel ind. */ - pIE->InfoChanSel = 0; /* Info. channel selection */ - pIE->InterfaceID = 0; /* Interface identifier */ - pIE->CodStand = 0; /* Code standard */ - pIE->NumMap = 0; /* Number/Map */ - pIE->ChanMapType = 0; /* Channel type/Map element type */ - pIE->ChanSlot = 0; /* Channel number/Slot map */ - - return 0; -} - -L3INT Q931InitIEProgInd(Q931ie_ProgInd * pIE) -{ - pIE->IEId = Q931ie_PROGRESS_INDICATOR; - pIE->Size = sizeof(Q931ie_ProgInd); - pIE->CodStand = 0; /* Coding standard */ - pIE->Location = 0; /* Location */ - pIE->ProgDesc = 0; /* Progress description */ - - return 0; -} - -L3INT Q931InitIENetFac(Q931ie_NetFac * pIE) -{ - pIE->IEId = Q931ie_NETWORK_SPECIFIC_FACILITIES; - pIE->Size = sizeof(Q931ie_NetFac); - pIE->LenNetID = 0; /* Length of network facilities id. */ - pIE->TypeNetID = 0; /* Type of network identification */ - pIE->NetIDPlan = 0; /* Network identification plan. */ - pIE->NetFac = 0; /* Network specific facility spec. */ - pIE->NetID[0] = 0; - return 0; -} - -L3INT Q931InitIEDisplay(Q931ie_Display * pIE) -{ - pIE->IEId = Q931ie_DISPLAY; - pIE->Size = sizeof(Q931ie_Display); - pIE->Display[0] = 0; - return 0; -} - -L3INT Q931InitIEDateTime(Q931ie_DateTime * pIE) -{ - pIE->IEId = Q931ie_DATETIME; - pIE->Size = sizeof(Q931ie_DateTime); - pIE->Year = 0; /* Year */ - pIE->Month = 0; /* Month */ - pIE->Day = 0; /* Day */ - pIE->Hour = 0; /* Hour */ - pIE->Minute = 0; /* Minute */ - pIE->Second = 0; /* Second */ - - return 0; -} - -L3INT Q931InitIEKeypadFac(Q931ie_KeypadFac * pIE) -{ - pIE->IEId = Q931ie_KEYPAD_FACILITY; - pIE->Size = sizeof(Q931ie_KeypadFac); - pIE->KeypadFac[0] = 0; - return 0; -} - -L3INT Q931InitIESignal(Q931ie_Signal * pIE) -{ - pIE->IEId = Q931ie_SIGNAL; - pIE->Size = sizeof(Q931ie_Signal); - pIE->Signal = 0; - return 0; -} - -L3INT Q931InitIECallingNum(Q931ie_CallingNum * pIE) -{ - pIE->IEId = Q931ie_CALLING_PARTY_NUMBER; - pIE->Size = sizeof(Q931ie_CallingNum); - pIE->TypNum = 0; /* Type of number */ - pIE->NumPlanID = 0; /* Numbering plan identification */ - pIE->PresInd = 0; /* Presentation indicator */ - pIE->ScreenInd = 0; /* Screening indicator */ - pIE->Digit[0] = 0; /* Number digits (IA5) */ - - return 0; -} - -L3INT Q931InitIECallingSub(Q931ie_CallingSub * pIE) -{ - pIE->IEId = Q931ie_CALLING_PARTY_SUBADDRESS; - pIE->Size = sizeof(Q931ie_CallingSub); - pIE->TypNum = 0; /* Type of subaddress */ - pIE->OddEvenInd = 0; /* Odd/Even indicator */ - pIE->Digit[0] = 0; /* Digits */ - - return 0; -} - -L3INT Q931InitIECalledNum(Q931ie_CalledNum * pIE) -{ - pIE->IEId = Q931ie_CALLED_PARTY_NUMBER; - pIE->Size = sizeof(Q931ie_CalledNum); - pIE->TypNum = 0; /* Type of Number */ - pIE->NumPlanID = 0; /* Numbering plan identification */ - pIE->Digit[0] = 0; /* Digit (IA5) */ - - return 0; -} - -L3INT Q931InitIECalledSub(Q931ie_CalledSub * pIE) -{ - pIE->IEId = Q931ie_CALLED_PARTY_SUBADDRESS; - pIE->Size = sizeof(Q931ie_CalledSub); - pIE->TypNum = 0; /* Type of subaddress */ - pIE->OddEvenInd = 0; /* Odd/Even indicator */ - pIE->Digit[0] = 0; /* Digits */ - - return 0; -} - -L3INT Q931InitIETransNetSel(Q931ie_TransNetSel * pIE) -{ - pIE->IEId = Q931ie_TRANSIT_NETWORK_SELECTION; - pIE->Size = sizeof(Q931ie_TransNetSel); - pIE->Type = 0; /* Type of network identifier */ - pIE->NetIDPlan = 0; /* Network idetification plan */ - pIE->NetID[0] = 0; /* Network identification(IA5) */ - - return 0; -} - -L3INT Q931InitIELLComp(Q931ie_LLComp * pIE) -{ - pIE->IEId = Q931ie_LOW_LAYER_COMPATIBILITY; - pIE->Size = sizeof(Q931ie_LLComp); - - pIE->CodStand = 0; /* Coding standard */ - pIE->ITransCap = 0; /* Information transfer capability */ - pIE->NegotInd = 0; /* Negot indic. */ - pIE->TransMode = 0; /* Transfer Mode */ - pIE->InfoRate = 0; /* Information transfer rate */ - pIE->RateMul = 0; /* Rate multiplier */ - pIE->Layer1Ident = 0; /* Layer 1 ident. */ - pIE->UIL1Prot = 0; /* User information layer 1 protocol */ - pIE->SyncAsync = 0; /* Synch/asynch */ - pIE->Negot = 0; /* Negot */ - pIE->UserRate = 0; /* User rate */ - pIE->InterRate = 0; /* Intermediate rate */ - pIE->NIConTx = 0; /* NIC on Tx */ - pIE->NIConRx = 0; /* NIC on Rx */ - pIE->FlowCtlTx = 0; /* Flow control on Tx */ - pIE->FlowCtlRx = 0; /* Flow control on Rx */ - pIE->HDR = 0; /* Hdr/no hdr */ - pIE->MultiFrame = 0; /* Multiframe */ - pIE->ModeL1 = 0; /* Mode L1 */ - pIE->NegotLLI = 0; /* Negot. LLI */ - pIE->Assignor = 0; /* Assignor/Assignor ee */ - pIE->InBandNeg = 0; /* In-band negot. */ - pIE->NumStopBits = 0; /* Number of stop bits */ - pIE->NumDataBits = 0; /* Number of data bits */ - pIE->Parity = 0; /* Parity */ - pIE->DuplexMode = 0; /* Duplex Mode */ - pIE->ModemType = 0; /* Modem type */ - pIE->Layer2Ident = 0; /* Layer 2 ident. */ - pIE->UIL2Prot = 0; /* User information layer 2 protocol */ - pIE->ModeL2 = 0; /* ModeL2 */ - pIE->Q933use = 0; /* Q.9333 use */ - pIE->UsrSpcL2Prot = 0; /* User specified layer 2 protocol info */ - pIE->WindowSize = 0; /* Window size (k) */ - pIE->Layer3Ident = 0; /* Layer 3 ident */ - pIE->OptL3Info = 0; /* Optional layer 3 protocol info. */ - pIE->ModeL3 = 0; /* Mode of operation */ -#if 0 - pIE->ModeX25op = 0; /* Mode of operation X.25 */ -#endif - pIE->DefPackSize = 0; /* Default packet size */ - pIE->PackWinSize = 0; /* Packet window size */ - pIE->AddL3Info = 0; /* Additional Layer 3 protocol info */ - - return 0; -} - -L3INT Q931InitIEHLComp(Q931ie_HLComp * pIE) -{ - pIE->IEId = Q931ie_HIGH_LAYER_COMPATIBILITY; - pIE->Size = sizeof(Q931ie_HLComp); - - return 0; -} - -L3INT Q931ProcUnknownMessage(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom) -{ - /* TODO: Unhandled paramaters */ - (void)pTrunk; - (void)b; - (void)iFrom; - - return 0; -} - -L3INT Q931ProcUnexpectedMessage(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom) -{ - /* TODO: Unhandled paramaters */ - (void)pTrunk; - (void)b; - (void)iFrom; - - return 0; -} - -L3INT Q931Disconnect(Q931_TrunkInfo_t *pTrunk, L3INT iTo, L3INT iCRV, L3INT iCause) -{ - /* TODO: Unhandled paramaters */ - (void)pTrunk; - (void)iTo; - (void)iCRV; - (void)iCause; - - return 0; -} - -L3INT Q931ReleaseComplete(Q931_TrunkInfo_t *pTrunk, L3UCHAR *buf) -{ - Q931mes_Header *ptr = (Q931mes_Header*)&buf[Q931L4HeaderSpace]; - ptr->MesType = Q931mes_RELEASE_COMPLETE; - ptr->CRVFlag = !(ptr->CRVFlag); - return Q931Tx32Data(pTrunk,0,buf,ptr->Size); -} - -L3INT Q931AckRestart(Q931_TrunkInfo_t *pTrunk, L3UCHAR *buf) -{ - L3INT RetCode; - - Q931mes_Header *ptr = (Q931mes_Header*)&buf[Q931L4HeaderSpace]; - ptr->MesType = Q931mes_RESTART_ACKNOWLEDGE; - //if (ptr->CRV) { - ptr->CRVFlag = !(ptr->CRVFlag); - //} - - RetCode = Q931Proc[pTrunk->Dialect][ptr->MesType](pTrunk, buf, 4); - - return RetCode; -} - -L3INT Q931AckSetup(Q931_TrunkInfo_t *pTrunk, L3UCHAR *buf) -{ - L3INT RetCode; - - Q931mes_Header *ptr = (Q931mes_Header*)&buf[Q931L4HeaderSpace]; - ptr->MesType = Q931mes_SETUP_ACKNOWLEDGE; - - RetCode = Q931Proc[pTrunk->Dialect][ptr->MesType](pTrunk, buf, 4); - - return RetCode; -} - -L3INT Q931AckConnect(Q931_TrunkInfo_t *pTrunk, L3UCHAR *buf) -{ - L3INT RetCode; - - Q931mes_Header *ptr = (Q931mes_Header*)&buf[Q931L4HeaderSpace]; - ptr->MesType = Q931mes_CONNECT_ACKNOWLEDGE; - - RetCode = Q931Proc[pTrunk->Dialect][ptr->MesType](pTrunk, buf, 4); - - return RetCode; -} - -L3INT Q931AckService(Q931_TrunkInfo_t *pTrunk, L3UCHAR *buf) -{ - L3INT RetCode; - - Q931mes_Header *ptr = (Q931mes_Header*)&buf[Q931L4HeaderSpace]; - ptr->MesType = Q931mes_SERVICE_ACKNOWLEDGE; - if (ptr->CRV) { - ptr->CRVFlag = !(ptr->CRVFlag); - } - - RetCode = Q931Proc[pTrunk->Dialect][ptr->MesType](pTrunk, buf, 4); - - return RetCode; -} - -Q931_ENUM_NAMES(DIALECT_TYPE_NAMES, DIALECT_STRINGS) -Q931_STR2ENUM(q931_str2Q931Dialect_type, q931_Q931Dialect_type2str, Q931Dialect_t, DIALECT_TYPE_NAMES, Q931_Dialect_Count) diff --git a/libs/freetdm/src/isdn/Q931ie.c b/libs/freetdm/src/isdn/Q931ie.c deleted file mode 100644 index 62312ee654..0000000000 --- a/libs/freetdm/src/isdn/Q931ie.c +++ /dev/null @@ -1,3074 +0,0 @@ -/***************************************************************************** - - FileName: Q931ie.c - - Contents: Information Element Pack/Unpack functions. - - These functions will pack out a Q931 message from the bit - packed original format into structs that are easier to process - and pack the same structs back into bit fields when sending - messages out. - - The messages contains a short for each possible IE. The MSB - bit flags the precense of an IE, while the remaining bits - are the offset into a buffer to find the actual IE. - - Each IE are supported by 3 functions: - - Q931Pie_XXX Pack struct into Q.931 IE - Q931Uie_XXX Unpack Q.931 IE into struct - Q931InitIEXXX Initialize IE (see Q931api.c). - - Dialect Note: This file will only contain standard DSS1 IE. Other IE as - used in QSIG, NI2, Q.932 etc are located in separate files. - - See q931.h for description. - - License/Copyright: - - Copyright (c) 2007, Jan Vidar Berger, Case Labs, Ltd. All rights reserved. - email:janvb@caselaboratories.com - - 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 Case Labs, Ltd 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT OWNER OR CONTRIBUTORS 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 SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*****************************************************************************/ - -#include "Q931.h" - -#ifdef _MSC_VER -#ifndef __inline__ -#define __inline__ __inline -#endif -#if (_MSC_VER >= 1400) /* VC8+ */ -#ifndef _CRT_SECURE_NO_DEPRECATE -#define _CRT_SECURE_NO_DEPRECATE -#endif -#ifndef _CRT_NONSTDC_NO_DEPRECATE -#define _CRT_NONSTDC_NO_DEPRECATE -#endif -#endif -#ifndef strcasecmp -#define strcasecmp(s1, s2) _stricmp(s1, s2) -#endif -#ifndef strncasecmp -#define strncasecmp(s1, s2, n) _strnicmp(s1, s2, n) -#endif -#ifndef snprintf -#define snprintf _snprintf -#endif -#endif - -/***************************************************************************** - - Macro: Q931MoreIE - - Description: Local helper macro detecting if there is more IE space left - based on the 3 standard parameters Octet, Off and IESpace. - This can be used to test if the IE is completed to avoid - that the header of the next IE is interpreted as a part of - the current IE. - -*****************************************************************************/ -#define Q931MoreIE() (Octet + Off - 2 < IESize) - -#define Q931IESizeTest(x) {\ - if (Octet + Off - 2 != IESize) {\ - Q931SetError(pTrunk, x, Octet, Off);\ - return x;\ - }\ -} - -/***************************************************************************** - - Function: Q931ReadExt - - Description: Many of the octets in the standard have an MSB 'ext.1'. This - means that the octet usually is the latest octet, but that a - futhure standard may extend the octet. A stack must be able - to handle such extensions by skipping the extension octets. - - This function will increase the offset counter with 1 for - each octet with an MSB of zero. This will allow the stack to - skip extensions wihout knowing anything about them. - - Parameters: IBuf ptr to octet array. - Off Starting offset counter - - Return Value: New offset value. - -*****************************************************************************/ - -L3INT Q931ReadExt(L3UCHAR * IBuf, L3INT Off) -{ - L3INT c = 0; - while ((IBuf[c] & 0x80) == 0) { - c++; - } - return Off + c; -} - -/***************************************************************************** - - Function: Q931Uie_BearerCap - - Description: Unpack a bearer capability ie. - - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset - - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. - - Return Value: Error Message - -*****************************************************************************/ - -L3INT Q931Uie_BearerCap(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) -{ - Q931ie_BearerCap *pie = (Q931ie_BearerCap*)OBuf; - ie *pIE = &pMsg->BearerCap; - L3INT Off = 0; - L3INT Octet = 0; - L3INT IESize; - *pIE = 0; - - /* Octet 1 */ - pie->IEId = IBuf[Octet++]; - - /* Octet 2 */ - IESize = IBuf[Octet++]; - - /* Octet 3 */ - pie->CodStand = ieGetOctet((IBuf[Octet] & 0x60) >> 5); - pie->ITC = ieGetOctet(IBuf[Octet] & 0x1f); - Off = Q931ReadExt(&IBuf[Octet], Off); - Octet++; - - /* Octet 4 */ - pie->TransMode = ieGetOctet((IBuf[Octet + Off] & 0x60) >> 5); - pie->ITR = ieGetOctet(IBuf[Octet + Off] & 0x1f); - Off = Q931ReadExt(&IBuf[Octet + Off], Off); - Octet++; - - /* Octet 4.1. Rate multiplier is only present if ITR = Multirate */ - if (pie->ITR == 0x18) { - pie->RateMul = ieGetOctet(IBuf[Octet + Off] & 0x7f); - Off = Q931ReadExt(&IBuf[Octet + Off], Off); - Off ++; - } - - /* Octet 5 */ - if ((IBuf[Octet + Off] & 0x60) == 0x20 && Q931MoreIE()) { - pie->Layer1Ident = ieGetOctet((IBuf[Octet + Off] & 0x60) >> 5); - pie->UIL1Prot = ieGetOctet(IBuf[Octet + Off] & 0x1f); - Octet++; - - /* Octet 5a. The octet may be present if ITC is unrestrictd digital info - * and UIL1Prot is either V.110, I.460 and X.30 or V.120. It may also - * be present if ITC = 3.1 kHz audio and UIL1Prot is G.711. - * Bit 8 of Octet 5 = 0 indicates that 5a is present. - */ - - if (IsQ931Ext(IBuf[Octet + Off - 1])) { - if (((pie->ITC == 0x08) && (pie->UIL1Prot == 0x01 || pie->UIL1Prot == 0x08)) - || ((pie->ITC == 0x10) && (pie->UIL1Prot == 0x02 || pie->UIL1Prot == 0x03))) { - pie->SyncAsync = ieGetOctet((IBuf[Octet + Off] & 0x40) >> 6); - pie->Negot = ieGetOctet((IBuf[Octet + Off] & 0x20) >> 5); - pie->UserRate = ieGetOctet(IBuf[Octet + Off] & 0x1f); - Off ++; - } - else { - /* We have detected bit 8 = 0, but no setting that require the */ - /* additional octets ??? */ - Q931SetError(pTrunk, Q931E_BEARERCAP, 5,Off); - return Q931E_BEARERCAP; - } - - /* Octet 5b. Two different structures used. */ - if (IsQ931Ext(IBuf[Octet + Off - 1])) { - if (pie->UIL1Prot == 0x01) { /* ITU V.110, I.460 and X.30 */ - pie->InterRate = ieGetOctet((IBuf[Octet + Off] & 0x60) >> 5); - pie->NIConTx = ieGetOctet((IBuf[Octet + Off] & 0x10) >> 4); - pie->NIConRx = ieGetOctet((IBuf[Octet + Off] & 0x08) >> 3); - pie->FlowCtlTx = ieGetOctet((IBuf[Octet + Off] & 0x04) >> 2); - pie->FlowCtlRx = ieGetOctet((IBuf[Octet + Off] & 0x20) >> 1); - Off++; - } - else if (pie->UIL1Prot == 0x08) { /* ITU V.120 */ - pie->HDR = ieGetOctet((IBuf[Octet + Off] & 0x40) >> 6); - pie->MultiFrame = ieGetOctet((IBuf[Octet + Off] & 0x20) >> 5); - pie->Mode = ieGetOctet((IBuf[Octet + Off] & 0x10) >> 4); - pie->LLInegot = ieGetOctet((IBuf[Octet + Off] & 0x08) >> 3); - pie->Assignor = ieGetOctet((IBuf[Octet + Off] & 0x04) >> 2); - pie->InBandNeg = ieGetOctet((IBuf[Octet + Off] & 0x02) >> 1); - Off++; - } - else { - Q931SetError(pTrunk,Q931E_BEARERCAP, 5,Off); - return Q931E_BEARERCAP; - } - - /* Octet 5c */ - if (IsQ931Ext(IBuf[Octet + Off - 1])) { - pie->NumStopBits = ieGetOctet((IBuf[Octet + Off] & 0x60) >> 5); - pie->NumDataBits = ieGetOctet((IBuf[Octet + Off] & 0x18) >> 3); - pie->Parity = ieGetOctet(IBuf[Octet + Off] & 0x07); - Off++; - - /* Octet 5d */ - if (IsQ931Ext(IBuf[Octet + Off - 1])) { - pie->DuplexMode = ieGetOctet((IBuf[Octet + Off] & 0x40) >> 6); - pie->ModemType = ieGetOctet(IBuf[Octet + Off] & 0x3f); - Off ++; - } - } - } - } - } - - /* Octet 6 */ - if ((IBuf[Octet + Off] & 0x60) == 0x40 && Q931MoreIE()) { - pie->Layer2Ident = ieGetOctet((IBuf[Octet + Off] & 0x60) >> 5); - pie->UIL2Prot = ieGetOctet(IBuf[Octet + Off] & 0x1f); - - Off = Q931ReadExt(&IBuf[Octet + Off], Off); - Octet ++; - } - - /* Octet 7 */ - if ((IBuf[Octet + Off] & 0x60) == 0x60 && Q931MoreIE()) { - pie->Layer3Ident = ieGetOctet((IBuf[Octet + Off] & 0x60) >> 5); - pie->UIL3Prot = ieGetOctet(IBuf[Octet + Off] & 0x1f); - Octet++; - - /* Octet 7a */ - if (IsQ931Ext(IBuf[Octet + Off - 1])) { - if (pie->UIL3Prot == 0x0c) { - pie->AL3Info1 = ieGetOctet(IBuf[Octet + Off] & 0x0f); - Off++; - - /* Octet 7b */ - if (IsQ931Ext(IBuf[Octet + Off])) { - pie->AL3Info2 = ieGetOctet(IBuf[Octet + Off] & 0x0f); - Off++; - } - } - else { - Q931SetError(pTrunk,Q931E_BEARERCAP, 7, Off); - return Q931E_BEARERCAP; - - } - } - } - - Q931IESizeTest(Q931E_BEARERCAP); - Q931SetIE(*pIE, *OOff); - - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_BearerCap); - pie->Size = sizeof(Q931ie_BearerCap); - - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pie_BearerCap - - Description: Packing a Q.931 Bearer Capability element from a generic - struct into a packed octet structure in accordance with the - standard. - - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. - - Return Value: Error code, 0 = OK - -*****************************************************************************/ - -L3INT Q931Pie_BearerCap(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) -{ - Q931ie_BearerCap *pIE = (Q931ie_BearerCap*)IBuf; - L3INT rc = 0; - L3INT Beg = *Octet; /* remember current offset */ - L3INT li; - - Q931Log(pTrunk, Q931_LOG_DEBUG, "Encoding Bearer Capability IE\n"); - - OBuf[(*Octet)++] = Q931ie_BEARER_CAPABILITY ; - li = (*Octet)++; /* remember length position */ - - /* Octet 3 - Coding standard / Information transfer capability */ - OBuf[(*Octet)++] = 0x80 | ((pIE->CodStand << 5) & 0x60) | (pIE->ITC & 0x1f); - - /* Octet 4 - Transfer mode / Information transfer rate */ - OBuf[(*Octet)++] = 0x80 | ((pIE->TransMode << 5) & 0x60) | (pIE->ITR & 0x1f); - - if (pIE->ITR == 0x18) { - /* Octet 4.1 - Rate Multiplier */ - OBuf[(*Octet)++] = 0x80 | (pIE->RateMul & 0x7f); - } - - /* Octet 5 - Layer 1 Ident / User information layer 1 protocol */ - if (pIE->Layer1Ident == 0x01) { - if (((pIE->ITC == 0x08) && (pIE->UIL1Prot == 0x01 || pIE->UIL1Prot == 0x08)) || - ((pIE->ITC == 0x10) && (pIE->UIL1Prot == 0x02 || pIE->UIL1Prot == 0x03))) { - OBuf[(*Octet)++] = 0x00 | ((pIE->Layer1Ident << 5) & 0x60) | (pIE->UIL1Prot & 0x15); - - /* Octet 5a - SyncAsync/Negot/UserRate */ - OBuf[(*Octet)++] = 0x00 | ((pIE->SyncAsync << 6) & 0x40) | ((pIE->Negot << 5) & 0x20) | (pIE->UserRate & 0x1f); - - /* Octet 5b - one of two types */ - if (pIE->UIL1Prot == 0x01) { /* ITU V.110, I.460 and X.30 */ - /* Octet 5b - Intermed rate/ Nic on Tx/Nix on Rx/FlowCtlTx/FlowCtlRx */ - OBuf[(*Octet)++] = 0x00 - | ((pIE->InterRate << 6) & 0x60) - | ((pIE->NIConTx << 4) & 0x10) - | ((pIE->NIConRx << 3) & 0x08) - | ((pIE->FlowCtlTx << 2) & 0x04) - | ((pIE->FlowCtlRx << 1) & 0x02); - } - else if (pIE->UIL1Prot == 0x08) { /* ITU V.120 */ - /* Octet 5b - HDR/Multiframe/Mode/LLINegot/Assignor/Inbandneg*/ - OBuf[(*Octet)++] = 0x00 - | ((pIE->InterRate << 6) & 0x60) - | ((pIE->MultiFrame << 5) & 0x20) - | ((pIE->Mode << 4) & 0x10) - | ((pIE->LLInegot << 3) & 0x08) - | ((pIE->Assignor << 2) & 0x04) - | ((pIE->InBandNeg << 1) & 0x02); - } - - /* Octet 5c - NumStopBits/NumStartBits/Parity */ - OBuf[(*Octet)++] = 0x00 - | ((pIE->NumStopBits << 5) & 0x60) - | ((pIE->NumDataBits << 3) & 0x18) - | (pIE->Parity & 0x07); - - /* Octet 5d - Duplex Mode/Modem Type */ - OBuf[(*Octet)++] = 0x80 | ((pIE->DuplexMode << 6) & 0x40) | (pIE->ModemType & 0x3f); - } - else { - OBuf[(*Octet)++] = 0x80 | ((pIE->Layer1Ident << 5) & 0x60) | (pIE->UIL1Prot & 0x1f); - } - } - - /* Octet 6 - Layer2Ident/User information layer 2 prtocol */ - if (pIE->Layer2Ident == 0x02) { - OBuf[(*Octet)++] = 0x80 | ((pIE->Layer2Ident << 5) & 0x60) | (pIE->UIL2Prot & 0x1f); - } - - /* Octet 7 - Layer 3 Ident/ User information layer 3 protocol */ - if (pIE->Layer3Ident == 0x03) { - if (pIE->UIL3Prot == 0x0c) { - OBuf[(*Octet)++] = 0x00 | ((pIE->Layer3Ident << 5) & 0x60) | (pIE->UIL3Prot & 0x1f); - - /* Octet 7a - Additional information layer 3 msb */ - OBuf[(*Octet)++] = 0x00 | (pIE->AL3Info1 & 0x0f); - - /* Octet 7b - Additional information layer 3 lsb */ - OBuf[(*Octet)++] = 0x80 | (pIE->AL3Info2 & 0x0f); - } - else { - OBuf[(*Octet)++] = 0x80 | ((pIE->Layer3Ident << 5) & 0x60) | (pIE->UIL3Prot & 0x1f); - } - } - - OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; - return rc; -} - -/***************************************************************************** - - Function: Q931Uie_CallID - - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset - - - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. - - Return Value: Error Message - -*****************************************************************************/ -L3INT Q931Uie_CallID(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) -{ - Q931ie_CallID *pie = (Q931ie_CallID*)OBuf; - ie *pIE = &pMsg->CallID; - L3INT Off = 0; - L3INT Octet = 0; - L3INT x = 0; - L3INT IESize; - - *pIE = 0; - - /* Octet 1 */ - pie->IEId = IBuf[Octet++]; - - /* Octet 2 */ - IESize = IBuf[Octet++]; - - /* Octet 3 */ - do { - pie->CallId[x] = IBuf[Octet + Off] & 0x7f; - Off++; - x++; - } while (Q931MoreIE()); - - Q931IESizeTest(Q931E_CALLID); - Q931SetIE(*pIE, *OOff); - - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_CallID) + x - 1; - pie->Size = (L3UCHAR)(sizeof(Q931ie_CallID) + x - 1); - - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pie_CallID - - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. - - Return Value: Error code, 0 = OK - -*****************************************************************************/ - -L3INT Q931Pie_CallID(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) -{ - Q931ie_CallID *pIE = (Q931ie_CallID*)IBuf; - L3INT rc = 0; - L3INT Beg = *Octet;/* remember current offset */ - L3INT li; - L3INT sCI = pIE->Size - sizeof(Q931ie_CallID) + 1; - L3INT x; - - OBuf[(*Octet)++] = Q931ie_CALL_IDENTITY ; - li = (*Octet)++; /* remember length position */ - - for (x = 0; x < sCI; x++) { - OBuf[(*Octet)++] = pIE->CallId[x]; - } - - OBuf[(*Octet) - 1] |= 0x80; /* set complete flag at last octet*/ - - OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; - return rc; -} - -/***************************************************************************** - - Function: Q931Uie_CallState - - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset - - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. - - Return Value: Error Message - -*****************************************************************************/ -L3INT Q931Uie_CallState(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) -{ - Q931ie_CallState *pie = (Q931ie_CallState*)OBuf; - ie *pIE = &pMsg->CallState; - L3INT Off = 0; - L3INT Octet = 0; - L3INT IESize; - - *pIE = 0; - - /* Octet 1 */ - pie->IEId = IBuf[Octet++]; - - /* Octet 2 */ - IESize = IBuf[Octet++]; - - /* Octet 3 */ - pie->CodStand = (IBuf[Octet + Off] >> 6) & 0x03; - pie->CallState = IBuf[Octet + Off] & 0x3f; - Octet++; - - Q931IESizeTest(Q931E_CALLSTATE); - Q931SetIE(*pIE, *OOff); - - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_CallState); - pie->Size = sizeof(Q931ie_CallState); - - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pie_CallState - - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. - - Return Value: Error code, 0 = OK - -*****************************************************************************/ -L3INT Q931Pie_CallState(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) -{ - Q931ie_CallState *pIE = (Q931ie_CallState*)IBuf; - L3INT rc = 0; - L3INT Beg = *Octet; /* remember current offset */ - L3INT li; - - OBuf[(*Octet)++] = Q931ie_CALL_STATE; - li = (*Octet)++; /* remember length position */ - - OBuf[(*Octet)++] = (pIE->CodStand << 6) | (pIE->CallState & 0x3f); - - OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; - return rc; -} - -/***************************************************************************** - - Function: Q931Uie_CalledSub - - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset - - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. - - Return Value: Error Message - -*****************************************************************************/ -L3INT Q931Uie_CalledSub(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) -{ - Q931ie_CalledSub *pie = (Q931ie_CalledSub*)OBuf; - ie *pIE = &pMsg->CalledSub; - L3INT Off = 0; - L3INT Octet = 0; - L3INT x; - L3INT IESize; - - *pIE = 0; - - /* Octet 1 */ - pie->IEId = IBuf[Octet++]; - - /* Octet 2 */ - IESize = IBuf[Octet++]; - - /* Octet 3 */ - pie->TypNum = (IBuf[Octet + Off] >> 4) & 0x07; - pie->OddEvenInd = (IBuf[Octet + Off] >> 3) & 0x01; - Octet++; - - /* Octet 4 */ - x = 0; - do { - pie->Digit[x] = IBuf[Octet + Off] & 0x7f; - Off++; - x++; - } while (Q931MoreIE() && x < 20); - - Q931IESizeTest(Q931E_CALLEDSUB); - Q931SetIE(*pIE, *OOff); - - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_CalledSub) + x - 1; - pie->Size = (L3UCHAR)(sizeof(Q931ie_CalledSub) + x - 1); - - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pie_CalledSub - - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. - - Return Value: Error code, 0 = OK - -*****************************************************************************/ -L3INT Q931Pie_CalledSub(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) -{ - Q931ie_CalledSub *pIE = (Q931ie_CalledSub*)IBuf; - L3INT rc = 0; - L3INT Beg = *Octet; - L3INT li; - L3INT sN = pIE->Size - sizeof(Q931ie_CalledSub) + 1; - L3INT x; - - /* Octet 1 */ - OBuf[(*Octet)++] = Q931ie_CALLED_PARTY_SUBADDRESS; - li = (*Octet)++; - - /* Octet 3 */ - OBuf[(*Octet)++] = 0x80 | (pIE->TypNum << 4) | (pIE->OddEvenInd << 3); - - /* Octet 4 */ - for (x = 0; xDigit[x]; - } - - OBuf[(*Octet) - 1] |= 0x80; /* Terminate bit */ - - OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; - return rc; -} - -/***************************************************************************** - - Function: Q931Uie_CalledNum - - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset - - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. - - Return Value: Error Message - -*****************************************************************************/ -L3INT Q931Uie_CalledNum(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) -{ - Q931ie_CalledNum *pie = (Q931ie_CalledNum*)OBuf; - ie *pIE = &pMsg->CalledNum; - L3INT Off = 0; - L3INT Octet = 0; - L3INT x; - L3INT IESize; /* # digits in this case */ - - *pIE = 0; - - /* Octet 1 */ - pie->IEId = IBuf[Octet++]; - - /* Octet 2 */ - IESize = IBuf[Octet++]; - - /* Octet 3 */ - pie->TypNum = (IBuf[Octet + Off] >> 4) & 0x07; - pie->NumPlanID = IBuf[Octet + Off] & 0x0f; - Octet++; - - /* Octet 4*/ - x = 0; - do { - pie->Digit[x] = IBuf[Octet + Off] & 0x7f; - Off++; - x++; - } while ((IBuf[Octet + Off]&0x80) == 0 && Q931MoreIE()); - - pie->Digit[x] = '\0'; - - Q931SetIE(*pIE, *OOff); - - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_CalledNum) + x; - pie->Size = (L3UCHAR)(sizeof(Q931ie_CalledNum) + x); - - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pie_CalledNum - - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. - - Return Value: Error code, 0 = OK - -*****************************************************************************/ -L3INT Q931Pie_CalledNum(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) -{ - Q931ie_CalledNum *pIE = (Q931ie_CalledNum*)IBuf; - L3INT rc = 0; - L3INT Beg = *Octet; - L3INT li; - L3INT sN = pIE->Size - sizeof(Q931ie_CalledNum); - L3INT x; - - /* Octet 1 */ - OBuf[(*Octet)++] = Q931ie_CALLED_PARTY_NUMBER; - - /* Octet 2 */ - li = (*Octet)++; - - /* Octet 3 */ - OBuf[(*Octet)++] = 0x80 | (pIE->TypNum << 4) | (pIE->NumPlanID); - - /* Octet 4 */ - for (x = 0; xDigit[x]; - } - - OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; - return rc; -} - -/***************************************************************************** - - Function: Q931Uie_CallingNum - - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset - - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. - - Return Value: Error Message - -*****************************************************************************/ -L3INT Q931Uie_CallingNum(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) -{ - Q931ie_CallingNum *pie = (Q931ie_CallingNum*)OBuf; - ie *pIE = &pMsg->CallingNum; - L3INT Off = 0; - L3INT Octet = 0; - L3INT x; - L3INT IESize; - - *pIE = 0; - - /* Octet 1 */ - pie->IEId = IBuf[Octet++]; - - /* Octet 2 */ - IESize = IBuf[Octet++]; - - /* Octet 3 */ - pie->TypNum = (IBuf[Octet + Off] >> 4) & 0x07; - pie->NumPlanID = IBuf[Octet + Off] & 0x0f; - - /* Octet 3a */ - if ((IBuf[Octet + Off] & 0x80) == 0) { - Off++; - pie->PresInd = (IBuf[Octet + Off] >> 5) & 0x03; - pie->ScreenInd = IBuf[Octet + Off] & 0x03; - } - Octet++; - - /* Octet 4 */ - x = 0; - while (Q931MoreIE()) { - pie->Digit[x++] = IBuf[Octet + Off] & 0x7f; - - if ((IBuf[Octet + Off] & 0x80) != 0) { - break; - } - Off++; - } - pie->Digit[x] = '\0'; - - Q931IESizeTest(Q931E_CALLINGNUM); - Q931SetIE(*pIE, *OOff); - - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_CallingNum) + x; - pie->Size = (L3UCHAR)(sizeof(Q931ie_CallingNum) + x); - - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pie_CallingNum - - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. - - Return Value: Error code, 0 = OK - -*****************************************************************************/ -L3INT Q931Pie_CallingNum(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) -{ - Q931ie_CallingNum *pIE = (Q931ie_CallingNum*)IBuf; - L3INT rc = 0; - L3INT Beg = *Octet; - L3INT li; - L3INT sN = pIE->Size - sizeof(Q931ie_CallingNum); - L3INT x; - - /* Octet 1 */ - OBuf[(*Octet)++] = Q931ie_CALLING_PARTY_NUMBER; - - /* Octet 2 */ - li = (*Octet)++; - - /* Octet 3 */ - OBuf[(*Octet)++] = 0x00 | (pIE->TypNum << 4) | (pIE->NumPlanID); - - /* Octet 4 */ - OBuf[(*Octet)++] = 0x80; - - /* Octet 5 */ - for (x = 0; xDigit[x]; - } - - OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; - return rc; -} - -/***************************************************************************** - - Function: Q931Uie_CallingSub - - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset - - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. - - Return Value: Error Message - -*****************************************************************************/ -L3INT Q931Uie_CallingSub(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) -{ - Q931ie_CallingSub *pie = (Q931ie_CallingSub*)OBuf; - ie *pIE = &pMsg->CallingSub; - L3INT Off = 0; - L3INT Octet = 0; - L3INT x; - L3INT IESize; - - *pIE = 0; - - /* Octet 1 */ - pie->IEId = IBuf[Octet++]; - - /* Octet 2 */ - IESize = IBuf[Octet++]; - - /* Octet 3 */ - pie->TypNum = (IBuf[Octet + Off] >> 4) & 0x07; - pie->OddEvenInd = (IBuf[Octet + Off] >> 3) & 0x01; - Octet++; - - /* Octet 4*/ - x = 0; - do { - pie->Digit[x] = IBuf[Octet + Off] & 0x7f; - Off++; - x++; - } while (Q931MoreIE() && x < 20); - - Q931IESizeTest(Q931E_CALLINGSUB); - Q931SetIE(*pIE, *OOff); - - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_CallingSub) + x -1; - pie->Size = (L3UCHAR)(sizeof(Q931ie_CallingSub) + x -1); - - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pie_CallingSub - - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. - - Return Value: Error code, 0 = OK - -*****************************************************************************/ -L3INT Q931Pie_CallingSub(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) -{ - Q931ie_CallingSub *pIE = (Q931ie_CallingSub*)IBuf; - L3INT rc = 0; - L3INT Beg = *Octet; - L3INT li; - L3INT sN = pIE->Size - sizeof(Q931ie_CallingSub) + 1; - L3INT x; - - /* Octet 1 */ - OBuf[(*Octet)++] = Q931ie_CALLING_PARTY_SUBADDRESS; - li = (*Octet)++; - - /* Octet 3 */ - OBuf[(*Octet)++] = 0x80 | (pIE->TypNum << 4) | (pIE->OddEvenInd << 3); - - /* Octet 4 */ - for (x = 0; xDigit[x]; - } - - OBuf[(*Octet) - 1] |= 0x80; /* Terminate bit */ - - OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; - return rc; -} - -/***************************************************************************** - - Function: Q931Uie_Cause - - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset - - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. - - Return Value: Error Message - -*****************************************************************************/ -L3INT Q931Uie_Cause(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) -{ - Q931ie_Cause *pie = (Q931ie_Cause*)OBuf; - ie *pIE = &pMsg->Cause; - L3INT Off = 0; - L3INT Octet = 0; - L3INT IESize; - - *pIE = 0; - - pie->IEId = IBuf[Octet++]; - - /* Octet 2*/ - IESize = IBuf[Octet++]; - - /* Octet 3*/ - pie->CodStand = (IBuf[Octet + Off]>>5) & 0x03; - pie->Location = IBuf[Octet + Off] & 0x0f; - - /* Octet 3a */ - if ((IBuf[Octet + Off] & 0x80) == 0) { - Off++; - pie->Recom = IBuf[Octet + Off] & 0x7f; - } - Octet++; - - /* Octet 4 */ - pie->Value = IBuf[Octet + Off] & 0x7f; - Octet++; - - /* Consume optional Diagnostic bytes */ - while (Q931MoreIE()) { - Off++; - }; - - Q931IESizeTest(Q931E_CAUSE); - Q931SetIE(*pIE, *OOff); - - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_Cause); - pie->Size = sizeof(Q931ie_Cause); - - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pie_Cause - - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. - - Return Value: Error code, 0 = OK - -*****************************************************************************/ -L3INT Q931Pie_Cause(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) -{ - Q931ie_Cause *pIE = (Q931ie_Cause*)IBuf; - L3INT rc = 0; - L3INT Beg = *Octet; - L3INT li; - - OBuf[(*Octet)++] = Q931ie_CAUSE; - li = (*Octet)++; - - /* Octet 3 */ - OBuf[(*Octet)++] = 0x80 | (pIE->CodStand<<5) | pIE->Location; - - /* Octet 3a - currently not supported in send */ - - /* Octet 4 */ - OBuf[(*Octet)++] = 0x80 | pIE->Value; - - /* Octet 5 - diagnostics not supported in send */ - - OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; - return rc; -} - -/***************************************************************************** - - Function: Q931Uie_CongLevel - - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset - - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. - - Return Value: Error Message - -*****************************************************************************/ -L3INT Q931Uie_CongLevel(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) -{ - Q931ie_CongLevel *pie = (Q931ie_CongLevel*)OBuf; - ie *pIE = &pMsg->CongestionLevel; - L3INT Off = 0; - L3INT Octet = 0; - - *pIE = 0; - - pie->IEId = IBuf[Octet] & 0xf0; - pie->CongLevel = IBuf[Octet] & 0x0f; - Octet ++; - - Q931SetIE(*pIE, *OOff); - - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_CongLevel); - pie->Size = sizeof(Q931ie_CongLevel); - - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pie_CongLevel - - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. - - Return Value: Error code, 0 = OK - -*****************************************************************************/ -L3INT Q931Pie_CongLevel(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) -{ - Q931ie_CongLevel *pIE = (Q931ie_CongLevel*)IBuf; - L3INT rc = 0; - /* L3INT Beg = *Octet; */ - - OBuf[(*Octet)++] = Q931ie_CONGESTION_LEVEL | pIE->CongLevel; - - return rc; -} - -/***************************************************************************** - - Function: Q931Uie_ChanID - - Parameters: IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset - - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. - - Return Value: Error code, 0 = OK - -*****************************************************************************/ -L3INT Q931Uie_ChanID(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR *OBuf, L3INT *IOff, L3INT *OOff) -{ - Q931ie_ChanID *pie = (Q931ie_ChanID*)OBuf; - ie *pIE = &pMsg->ChanID; - L3INT Off = 0; - L3INT Octet = 0; - L3INT IESize; -//18 04 e1 80 83 01 - *pIE = 0; - - Q931Log(pTrunk, Q931_LOG_DEBUG, "Decoding ChanID IE\n"); - - /* Octet 1 */ - pie->IEId = IBuf[Octet++]; - - /* Octet 2 */ - IESize = IBuf[Octet++]; - - /* Octet 3 */ - pie->IntIDPresent = (IBuf[Octet] >> 6) & 0x01; - pie->IntType = (IBuf[Octet] >> 5) & 0x01; - pie->PrefExcl = (IBuf[Octet] >> 3) & 0x01; - pie->DChanInd = (IBuf[Octet] >> 2) & 0x01; - pie->InfoChanSel = IBuf[Octet] & 0x03; - - Off = Q931ReadExt(&IBuf[Octet++], Off); - - /* Octet 3.1 */ - if (pie->IntIDPresent) { - pie->InterfaceID = IBuf[Octet + Off] & 0x7f; - - /* Temp fix. Interface id can be extended using the extension bit */ - /* this will read the octets, but do nothing with them. this is done */ - /* because the usage of this field is a little unclear */ - /* 30.jan.2001/JVB */ - Off = Q931ReadExt(&IBuf[Octet + Off], Off); - Off++; - } - - if ((Octet + Off - 2) != IESize) { - /* Octet 3.2 */ - if (pie->IntType == 1) { /* PRI etc */ - pie->CodStand = (IBuf[Octet + Off] >> 5) & 0x03; - pie->NumMap = (IBuf[Octet + Off] >> 4) & 0x01; - pie->ChanMapType = IBuf[Octet + Off] & 0x0f; - Off++; - - /* Octet 3.3 */ - /* Temp fix. Assume B channel. H channels not supported */ - pie->ChanSlot = IBuf[Octet + Off] & 0x7f; - - /* Some dialects don't follow the extension coding properly for this, but this should be safe for all */ - if ((Octet + Off - 1) != IESize) { - Off = Q931ReadExt(&IBuf[Octet + Off], Off); - } - Off++; - } - } - - Q931IESizeTest(Q931E_CHANID); - Q931SetIE(*pIE, *OOff); - - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_ChanID); - pie->Size = sizeof(Q931ie_ChanID); - - if (pTrunk->loglevel == Q931_LOG_DEBUG) { - const char *iface; - char tmp[100] = ""; - - if (!pie->IntType) { - switch (pie->InfoChanSel) { - case 0x0: - iface = "None"; - break; - case 0x1: - iface = "B1"; - break; - case 0x2: - iface = "B2"; - break; - default: - iface = "Any Channel"; - } - - snprintf(tmp, sizeof(tmp)-1, "InfoChanSel: %d (%s)", pie->InfoChanSel, iface); - } - - Q931Log(pTrunk, Q931_LOG_DEBUG, - "\n-------------------------- Q.931 Channel ID ------------------------\n" - " Pref/Excl: %s, Interface Type: %s\n" - " %s\n" - "--------------------------------------------------------------------\n\n", - ((pie->PrefExcl) ? "Preferred" : "Exclusive"), - ((pie->IntType) ? "PRI/Other" : "BRI"), - tmp); - } - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pie_ChanID - - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. - - Return Value: Error code, 0 = OK - -*****************************************************************************/ -L3INT Q931Pie_ChanID(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) -{ - Q931ie_ChanID *pIE = (Q931ie_ChanID*)IBuf; - L3INT rc = Q931E_NO_ERROR; - L3INT Beg = *Octet; /* remember current offset */ - L3INT li; - - OBuf[(*Octet)++] = Q931ie_CHANNEL_IDENTIFICATION; - li = (*Octet)++; /* remember length position */ - - /* Octet 3 flags & BRI chan # */ - OBuf[(*Octet)++] = 0x80 - | ((pIE->IntIDPresent << 6) & 0x40) - | ((pIE->IntType << 5) & 0x20) - | ((pIE->PrefExcl << 3) & 0x08) - | (pIE->InfoChanSel & 0x03); - - /* Octet 3.1 - Interface Identifier */ - if (pIE->IntIDPresent) { - OBuf[(*Octet)++] = 0x80 | (pIE->InterfaceID & 0x7f); - } - - /* Octet 3.2 & 3.3 - PRI */ - if (pIE->IntType) { - OBuf[(*Octet)++] = 0x80 - | ((pIE->CodStand << 5) & 0x60) - | ((pIE->NumMap << 4) & 0x10) - | (pIE->ChanMapType & 0x0f); /* TODO: support all possible channel map types */ - - /* Octet 3.3 Channel number */ - switch (pIE->ChanMapType) { - case 0x6: /* Slot map: H0 Channel Units */ /* unsupported, Octets 3.3.1 - 3.3.3 */ - return Q931E_CHANID; - - case 0x8: /* Slot map: H11 Channel Units */ - case 0x9: /* Slot map: H12 Channel Units */ - default: /* Channel number */ - OBuf[(*Octet)++] = 0x80 | (pIE->ChanSlot & 0x7f); - break; - } - } - - OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; - return rc; -} - - -/***************************************************************************** - - Function: Q931Uie_CRV - - Description: Reading CRV. - - The CRV is currently returned in the return value that - Q921Rx23 will assign to the CRV field in the unpacked - message. CRV is basically 2 bytes etc, but the spec allows - the use of longer CRV values. - - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset - - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. - - Return Value: CRV - -*****************************************************************************/ -L3USHORT Q931Uie_CRV(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *IOff, L3INT *OOff) -{ - L3USHORT CRV = 0; - L3INT Octet = *IOff; - L3INT l = IBuf[Octet++]; - - if (l == 1) { /* One octet CRV */ - CRV = IBuf[Octet++] & 0x7F; - } - else if (l == 2) { /* two octet CRV */ - CRV = (IBuf[Octet++] & 0x7f) << 8; - CRV |= IBuf[Octet++]; - } - else { - /* Long CRV is not used, so we skip this */ - /* TODO: is it right to set to 0 here? */ - CRV = 0; - Octet += l; - } - - *IOff = Octet; - return CRV; -} - -/***************************************************************************** - - Function: Q931Uie_DateTime - - Parameters: pTrunk [IN] Ptr to trunk information. - pIE [OUT] ptr to Information Element id. - IBuf [IN] ptr to a packed ie. - OBuf [OUT] ptr to buffer for Unpacked ie. - IOff [IN\OUT] Input buffer offset - OOff [IN\OUT] Output buffer offset - - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. - - Return Value: Error Message - -*****************************************************************************/ -L3INT Q931Uie_DateTime(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *IOff, L3INT *OOff) -{ - Q931ie_DateTime * pie = (Q931ie_DateTime*)OBuf; - ie *pIE = &pMsg->DateTime; - L3INT Off = 0; - L3INT Octet = 0; - L3INT IESize = 0; - - *pIE = 0; - - pie->IEId = IBuf[Octet++]; - - /* Octet 2 */ - IESize = IBuf[Octet++]; - - /* Octet 3 - Year */ - pie->Year = IBuf[Octet++]; - - /* Octet 4 - Month */ - pie->Month = IBuf[Octet++]; - - /* Octet 5 - Day */ - pie->Day = IBuf[Octet++]; - - /******************************************************************* - The remaining part of the IE are optioinal, but only the length - can now tell us wherever these fields are present or not - (always remember: IESize does not include ID and Size octet) - ********************************************************************/ - pie->Format = 0; - - /* Octet 6 - Hour (optional)*/ - if (IESize >= 4) { - pie->Format = 1; - pie->Hour = IBuf[Octet++]; - - /* Octet 7 - Minute (optional)*/ - if (IESize >= 5) { - pie->Format = 2; - pie->Minute = IBuf[Octet++]; - - /* Octet 8 - Second (optional)*/ - if (IESize >= 6) { - pie->Format = 3; - pie->Second = IBuf[Octet++]; - } - } - } - - Q931IESizeTest(Q931E_DATETIME); - Q931SetIE(*pIE, *OOff); - - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_DateTime); - pie->Size = sizeof(Q931ie_DateTime); - - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pie_DateTime - - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. - - Return Value: Error code, 0 = OK - -*****************************************************************************/ -L3INT Q931Pie_DateTime(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) -{ - Q931ie_DateTime *pIE = (Q931ie_DateTime*)IBuf; - L3INT rc = 0; - L3INT Beg = *Octet; - L3INT li; - - OBuf[(*Octet)++] = Q931ie_DATETIME; - li = (*Octet)++; - - OBuf[(*Octet)++] = pIE->Year; - OBuf[(*Octet)++] = pIE->Month; - OBuf[(*Octet)++] = pIE->Day; - if (pIE->Format >= 1) { - OBuf[(*Octet)++] = pIE->Hour; - - if (pIE->Format >= 2) { - OBuf[(*Octet)++] = pIE->Minute; - - if (pIE->Format >= 3) { - OBuf[(*Octet)++] = pIE->Second; - } - } - } - - OBuf[li] = (L3UCHAR)((*Octet)-Beg) - 2; - return rc; -} - -/***************************************************************************** - - Function: Q931Uie_Display - - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset - - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. - - Return Value: Error Message - -*****************************************************************************/ -L3INT Q931Uie_Display(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) -{ - Q931ie_Display *pie = (Q931ie_Display*)OBuf; - ie *pIE = &pMsg->Display; - L3INT Off = 0; - L3INT Octet = 0; - L3INT IESize; - L3INT x; - - *pIE = 0; - - pie->IEId = IBuf[Octet++]; - IESize = IBuf[Octet++]; - - for (x = 0; xDisplay[x] = IBuf[Octet + Off] & 0x7f; - Off++; - } - - Q931IESizeTest(Q931E_DISPLAY); - Q931SetIE(*pIE, *OOff); - - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_Display) + x - 1; - pie->Size = (L3UCHAR)(sizeof(Q931ie_Display) + x - 1); - - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pie_Display - - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. - - Return Value: Error code, 0 = OK - -*****************************************************************************/ -L3INT Q931Pie_Display(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) -{ - Q931ie_Display *pIE = (Q931ie_Display*)IBuf; - L3INT rc = 0; - L3INT Beg = *Octet; - L3INT li; - L3INT DSize; - L3INT x; - - OBuf[(*Octet)++] = Q931ie_DISPLAY; - li = (*Octet)++; - - DSize = pIE->Size - sizeof(Q931ie_Display); - - for (x = 0; x< DSize; x++) { - - OBuf[(*Octet)++] = pIE->Display[x]; - } - - OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; - return rc; -} - -/***************************************************************************** - - Function: Q931Uie_HLComp - - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset - - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. - - Return Value: Error Message - -*****************************************************************************/ -L3INT Q931Uie_HLComp(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) -{ - Q931ie_HLComp * pie = (Q931ie_HLComp*)OBuf; - ie *pIE = &pMsg->HLComp; - L3INT Off = 0; - L3INT Octet = 0; - L3INT IESize; - - *pIE = 0; - - pie->IEId = IBuf[Octet++]; - - /* Octet */ - IESize = IBuf[Octet++]; - - /* Octet 3*/ - pie->CodStand = (IBuf[Octet + Off] >>5) & 0x03; - pie->Interpret = (IBuf[Octet + Off] >>2) & 0x07; - pie->PresMeth = IBuf[Octet + Off] & 0x03; - Octet++; - - /* Octet 4 */ - pie->HLCharID = IBuf[Octet + Off] & 0x7f; - Octet++; - - /* Octet 4a*/ - if ((IBuf[Octet + Off - 1] & 0x80) == 0 && Q931MoreIE()) { - if (pie->HLCharID == 0x5e || pie->HLCharID == 0x5f) { - pie->EHLCharID = IBuf[Octet + Off] & 0x7f; - Off++; - } - else if ( pie->HLCharID >= 0xc3 && pie->HLCharID <= 0xcf) { - pie->EVideoTlfCharID = IBuf[Octet + Off] & 0x7f; - Off++; - } - else { - /* error Octet 4a indicated, but invalid value in Octet 4. */ - Q931SetError(pTrunk,Q931E_HLCOMP, 4, Off); - return Q931E_HLCOMP; - } - Off = Q931ReadExt(&IBuf[Octet + Off], Off); - } - - Q931IESizeTest(Q931E_HLCOMP); - Q931SetIE(*pIE, *OOff); - - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_HLComp); - pie->Size = sizeof(Q931ie_HLComp); - - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pie_HLComp - - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. - - Return Value: Error code, 0 = OK - -*****************************************************************************/ -L3INT Q931Pie_HLComp(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) -{ - Q931ie_HLComp *pIE = (Q931ie_HLComp*)IBuf; - L3INT rc = 0; - L3INT Beg = *Octet; - L3INT li; - - OBuf[(*Octet)++] = Q931ie_HIGH_LAYER_COMPATIBILITY; - li = (*Octet)++; - - /* Octet 3 */ - OBuf[(*Octet)++] = 0x80 | ((pIE->CodStand << 5) & 0x60) | ((pIE->Interpret << 2) & 0x1c) | (pIE->PresMeth & 0x03); - - /* Octet 4 */ - OBuf[(*Octet)++] = pIE->HLCharID; - - /* Octet 4a */ - if (pIE->HLCharID == 0x5e || pIE->HLCharID == 0x5f) { - OBuf[(*Octet)++] = 0x80 | (pIE->EHLCharID & 0x7f); - } - else if ( pIE->HLCharID >= 0xc3 && pIE->HLCharID <= 0xcf) { - OBuf[(*Octet)++] = 0x80 | (pIE->EVideoTlfCharID & 0x7f); - } - else { - OBuf[(*Octet) - 1] |= 0x80; - } - - OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; - return rc; -} - -/***************************************************************************** - - Function: Q931Uie_KeypadFac - - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset - - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. - - Return Value: Error Message - -*****************************************************************************/ -L3INT Q931Uie_KeypadFac(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) -{ - Q931ie_KeypadFac *pie = (Q931ie_KeypadFac*)OBuf; - ie *pIE = &pMsg->KeypadFac; - L3INT Off = 0; - L3INT Octet = 0; - L3INT IESize; - L3INT x; - - *pIE = 0; - - pie->IEId = IBuf[Octet++]; - IESize = IBuf[Octet++]; - - for (x = 0; xKeypadFac[x] = IBuf[Octet + Off] & 0x7f; - Off++; - } - - Q931IESizeTest(Q931E_KEYPADFAC); - Q931SetIE(*pIE, *OOff); - - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_KeypadFac) + x - 1; - pie->Size = (L3UCHAR)(sizeof(Q931ie_KeypadFac) + x - 1); - - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pie_KeypadFac - - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. - - Return Value: Error code, 0 = OK - -*****************************************************************************/ -L3INT Q931Pie_KeypadFac(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) -{ - Q931ie_KeypadFac *pIE = (Q931ie_KeypadFac*)IBuf; - L3INT rc = 0; - L3INT Beg = *Octet; - L3INT li; - L3INT DSize; - L3INT x; - - OBuf[(*Octet)++] = Q931ie_KEYPAD_FACILITY; - li = (*Octet)++; - - DSize = pIE->Size - sizeof(Q931ie_KeypadFac) + 1; - - for (x = 0; x< DSize; x++) { - OBuf[(*Octet)++] = pIE->KeypadFac[x]; - } - - OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; - return rc; -} - -/***************************************************************************** - - Function: Q931Uie_LLComp - - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset - - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. - - Return Value: Error Message - -*****************************************************************************/ -L3INT Q931Uie_LLComp(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) -{ - Q931ie_LLComp *pie = (Q931ie_LLComp*)OBuf; - ie *pIE = &pMsg->LLComp; - L3INT Off = 0; - L3INT Octet = 0; - L3INT IESize; - - *pIE = 0; - - pie->IEId = IBuf[Octet++]; - - /* Octet 2 */ - IESize = IBuf[Octet++]; - - /* Octet 3 */ - pie->CodStand = (IBuf[Octet + Off] >> 5) & 0x03; - pie->ITransCap = IBuf[Octet + Off] & 0x1f; - Octet++; - - /* Octet 3a*/ - if (IsQ931Ext(IBuf[Octet + Off - 1])) { - pie->NegotInd = (IBuf[Octet + Off] >> 6) & 0x01; - Off++; - } - - /* Octet 4 */ - pie->TransMode = (IBuf[Octet + Off] >> 5) & 0x03; - pie->InfoRate = IBuf[Octet + Off] & 0x1f; - - Octet++; - - /* Octet 4.1 */ - if (pie->InfoRate == 0x14) { /* Mutirate */ - pie->RateMul = IBuf[Octet + Off] & 0x7f; - Off++; - } - - /* Octet 5 - Layer 1 Ident */ - if ((IBuf[Octet + Off] & 0x60) == 0x20) { /* Layer 1 Ident ? */ - pie->Layer1Ident = (IBuf[Octet + Off] >> 5) & 0x03; - pie->UIL1Prot = IBuf[Octet + Off] & 0x1f; - Octet++; - - /* Octet 5a */ - if (IsQ931Ext(IBuf[Octet + Off - 1])) { - pie->SyncAsync = (IBuf[Octet + Off] >> 6) & 0x01; - pie->Negot = (IBuf[Octet + Off] >> 5) & 0x01; - pie->UserRate = IBuf[Octet + Off] & 0x1f; - Off++; - - /* Octet 5b - 2 options */ - if (IsQ931Ext(IBuf[Octet + Off - 1])) { - if (pie->UIL1Prot == 0x01) { /* V.110, I.460 and X.30*/ - pie->InterRate = (IBuf[Octet + Off] >> 5) & 0x03; - pie->NIConTx = (IBuf[Octet + Off] >> 4) & 0x01; - pie->NIConRx = (IBuf[Octet + Off] >> 3) & 0x01; - pie->FlowCtlTx = (IBuf[Octet + Off] >> 2) & 0x01; - pie->FlowCtlRx = (IBuf[Octet + Off] >> 1) & 0x01; - Off++; - } - else if (pie->UIL1Prot == 0x80) { /* V.120 */ - pie->HDR = (IBuf[Octet + Off] >> 6) & 0x01; - pie->MultiFrame = (IBuf[Octet + Off] >> 5) & 0x01; - pie->ModeL1 = (IBuf[Octet + Off] >> 4) & 0x01; - pie->NegotLLI = (IBuf[Octet + Off] >> 3) & 0x01; - pie->Assignor = (IBuf[Octet + Off] >> 2) & 0x01; - pie->InBandNeg = (IBuf[Octet + Off] >> 1) & 0x01; - Off++; - } - else if (pie->UIL1Prot == 0x07) { /* non standard */ - Off = Q931ReadExt(&IBuf[Octet + Off], Off); - Off++; - } - else { - Q931SetError(pTrunk,Q931E_LLCOMP, 5,2); - return Q931E_LLCOMP; - } - - /* Octet 5c */ - if (IsQ931Ext(IBuf[Octet + Off - 1])) { - pie->NumStopBits = (IBuf[Octet + Off] >> 5) & 0x03; - pie->NumDataBits = (IBuf[Octet + Off] >> 3) & 0x03; - pie->Parity = IBuf[Octet + Off] & 0x07; - Off++; - - /* Octet 5d */ - if (IsQ931Ext(IBuf[Octet + Off - 1])) { - pie->DuplexMode = (IBuf[Octet + Off] >> 6) & 0x01; - pie->ModemType = IBuf[Octet + Off] & 0x3f; - Off = Q931ReadExt(&IBuf[Octet + Off], Off); - Off++; - } - } - } - } - } - - /* Octet 6 - Layer 2 Ident */ - if ((IBuf[Octet + Off] & 0x60) == 0x40) { /* Layer 1 Ident ? */ - pie->Layer2Ident = (IBuf[Octet + Off] >>5) & 0x03; - pie->UIL2Prot = IBuf[Octet + Off] & 0x1f; - Octet++; - - /* Octet 6a */ - if (IsQ931Ext(IBuf[Octet + Off - 1])) { - if (pie->UIL2Prot == 0x10) { /* 2nd 6a */ - pie->UsrSpcL2Prot = IBuf[Octet + Off] & 0x7f; - Off++; - } - else { /* assume 1st 6a */ - pie->ModeL2 = (IBuf[Octet + Off] >> 5) & 0x03; - pie->Q933use = IBuf[Octet + Off] & 0x03; - Off++; - } - /* Octet 6b */ - if (IsQ931Ext(IBuf[Octet + Off - 1])) { - pie->WindowSize = IBuf[Octet + Off] & 0x7f; - Off++; - } - } - } - - /* Octet 7 - layer 3 Ident */ - if ((IBuf[Octet + Off] & 0x60) == 0x60) { /* Layer 3 Ident ? */ - pie->Layer3Ident = (IBuf[Octet + Off] >> 5) & 0x03; - pie->UIL3Prot = IBuf[Octet + Off] & 0x1f; - Octet++; - - /* Octet 7a */ - if (IsQ931Ext(IBuf[Octet + Off - 1])) { - if (pie->UIL3Prot == 0x0b) { - /* Octet 7a + 7b AddL3Info */ - pie->AddL3Info = ((IBuf[Octet + Off] << 4) & 0xf0) - | (IBuf[Octet + Off + 1] & 0x0f); - Off += 2; - } - else { - if (pie->UIL3Prot == 0x1f) { - pie->ModeL3 = (IBuf[Octet + Off] >> 5) & 0x03; - Off++; - } - else { - pie->OptL3Info = IBuf[Octet + Off] & 0x7f; - Off++; - } - - /* Octet 7b*/ - if (IsQ931Ext(IBuf[Octet + Off - 1])) { - pie->DefPackSize = IBuf[Octet + Off] & 0x0f; - Off++; - - /* Octet 7c */ - if (IsQ931Ext(IBuf[Octet + Off - 1])) { - pie->PackWinSize= IBuf[Octet + Off] & 0x7f; - } - } - } - } - } - - Q931IESizeTest(Q931E_LLCOMP); - Q931SetIE(*pIE, *OOff); - - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_LLComp); - pie->Size = sizeof(Q931ie_LLComp); - - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pie_LLComp - - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. - - Return Value: Error code, 0 = OK - -*****************************************************************************/ -L3INT Q931Pie_LLComp(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) -{ - Q931ie_LLComp *pIE = (Q931ie_LLComp*)IBuf; - L3INT rc = 0; - L3INT Beg = *Octet; - L3INT li; - - OBuf[(*Octet)++] = Q931ie_LOW_LAYER_COMPATIBILITY; - li = (*Octet)++; - - /* Octet 3 */ - OBuf[(*Octet)++] = (pIE->CodStand << 6) | pIE->ITransCap; - - /* Octet 3a */ - OBuf[(*Octet)++] = 0x80 | (pIE->NegotInd << 6); - - /* Octet 4 */ - OBuf[(*Octet)++] = 0x80 | (pIE->TransMode << 5) | pIE->InfoRate; - - /* Octet 4.1 */ - if (pIE->InfoRate == 0x18) { - OBuf[(*Octet)++] = 0x80 | pIE->RateMul; - } - - /* Octet 5 */ - if (pIE->Layer1Ident == 0x01) { - OBuf[(*Octet)++] = (pIE->Layer1Ident << 5) | pIE->UIL1Prot; - - /* Octet 5a */ - if ((pIE->ITransCap == 0x08 && (pIE->UIL1Prot == 0x01 || pIE->UIL1Prot == 0x08)) - || (pIE->ITransCap == 0x10 && (pIE->UIL1Prot == 0x02 || pIE->UIL1Prot == 0x03))) { - OBuf[(*Octet)++] = (pIE->SyncAsync<<6) | (pIE->Negot<<5) | pIE->UserRate; - - /* Octet 5b*/ - if (pIE->UIL1Prot == 0x01) { - OBuf[(*Octet)++] = (pIE->InterRate << 5) - | (pIE->NIConTx << 4) - | (pIE->NIConTx << 3) - | (pIE->FlowCtlTx << 2) - | (pIE->FlowCtlRx << 1); - } - else if (pIE->UIL1Prot == 0x08) { - OBuf[(*Octet)++] = (pIE->HDR << 6) - | (pIE->MultiFrame << 5) - | (pIE->ModeL1 << 4) - | (pIE->NegotLLI << 3) - | (pIE->Assignor << 2) - | (pIE->InBandNeg << 1); - } - else { - OBuf[(*Octet) - 1] |= 0x80; - } - - /* How to detect wherever 5c and 5d is to present is not clear - * but they have been inculded as 'standard' - * Octet 5c - */ - if (pIE->UIL1Prot == 0x01 || pIE->UIL1Prot == 0x08) { - OBuf[(*Octet)++] = (pIE->NumStopBits << 5) | (pIE->NumDataBits << 3) | pIE->Parity ; - - /* Octet 5d */ - OBuf[(*Octet)++] = 0x80 | (pIE->DuplexMode << 6) | pIE->ModemType; - } - } - else { - OBuf[(*Octet) - 1] |= 0x80; - } - } - - /* Octet 6 */ - if (pIE->Layer2Ident == 0x02) { - OBuf[(*Octet)++] = (pIE->Layer2Ident << 5) | pIE->UIL2Prot; - - /* Octet 6a*/ - if (pIE->UIL2Prot == 0x02 /* Q.921/I.441 */ - || pIE->UIL2Prot == 0x06 /* X.25 link layer */ - || pIE->UIL2Prot == 0x07 /* X.25 multilink */ - || pIE->UIL2Prot == 0x09 /* HDLC ARM */ - || pIE->UIL2Prot == 0x0a /* HDLC NRM */ - || pIE->UIL2Prot == 0x0b /* HDLC ABM */ - || pIE->UIL2Prot == 0x0d /* X.75 SLP */ - || pIE->UIL2Prot == 0x0e /* Q.922 */ - || pIE->UIL2Prot == 0x11) { /* ISO/ECE 7776 DTE-DCE */ - OBuf[(*Octet)++] = (pIE->ModeL2 << 5) | pIE->Q933use; - - /* Octet 6b */ - OBuf[(*Octet)++] = 0x80 | pIE->WindowSize; - } - else if (pIE->UIL2Prot == 0x10) { /* User Specific */ - OBuf[(*Octet)++] = 0x80 | pIE->UsrSpcL2Prot; - } - else { - OBuf[(*Octet) - 1] |= 0x80; - } - } - - /* Octet 7 */ - if (pIE->Layer3Ident == 0x03) { - OBuf[(*Octet)++] = (pIE->Layer3Ident << 5) | pIE->UIL3Prot; - - /* Octet 7a - 3 different ones */ - if (pIE->UIL3Prot == 0x10) { - OBuf[(*Octet++)] = 0x80 | pIE->OptL3Info; - } - else if (pIE->UIL3Prot == 0x06 - || pIE->UIL3Prot == 0x07 - || pIE->UIL3Prot == 0x08) { - OBuf[(*Octet)++] = pIE->ModeL3 << 5; - - /* Octet 7b note 7 */ - OBuf[(*Octet)++] = pIE->DefPackSize; - - /* Octet 7c note 7 */ - OBuf[(*Octet)++] = 0x80 | pIE->PackWinSize; - } - else if (pIE->UIL3Prot == 0x0b) { - OBuf[(*Octet)++] = (pIE->AddL3Info >> 4) & 0x0f; - OBuf[(*Octet)++] = 0x80 | (pIE->AddL3Info & 0x0f); - } - else { - OBuf[(*Octet) - 1] |= 0x80; - } - } - else { - Q931SetError(pTrunk,Q931E_LLCOMP, 7,0); - rc = Q931E_LLCOMP; - } - - OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; - return rc; -} - -/***************************************************************************** - - Function: Q931Uie_NetFac - - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset - - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. - - Return Value: Error Message - -*****************************************************************************/ -L3INT Q931Uie_NetFac(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) -{ - Q931ie_NetFac *pie = (Q931ie_NetFac*)OBuf; - ie *pIE = &pMsg->NetFac; - L3INT Off = 0; - L3INT Octet = 0; - L3INT x = 0; - L3INT IESize; - - *pIE = 0; - - pie->IEId = IBuf[Octet++]; - - /* Octet 2 */ - IESize = IBuf[Octet++]; - - pie->LenNetID = IBuf[Octet + Off]; /* full octet is used */ - Octet++; - - if (pie->LenNetID > 0) { - /* Octet 3.1 */ - pie->TypeNetID = (IBuf[Octet + Off] >> 4) & 0x0f; - pie->NetIDPlan = IBuf[Octet + Off] & 0x0f; - Off = Q931ReadExt(&IBuf[Octet], Off); - Off++; - - /* Octet 3.2*/ - for (x = 0; x < pie->LenNetID; x++) { - pie->NetID[x] = IBuf[Octet + Off] & 0x7f; - Off++; - } - } - - /* Octet 4*/ - pie->NetFac = IBuf[Octet + Off]; /* Full Octet is used */ - Octet++; - - Q931IESizeTest(Q931E_NETFAC); - Q931SetIE(*pIE, *OOff); - - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_NetFac) + x - 1; - pie->Size = (L3UCHAR)(sizeof(Q931ie_NetFac) + x - 1); - - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pie_NetFac - - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. - - Return Value: Error code, 0 = OK - -*****************************************************************************/ -L3INT Q931Pie_NetFac(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) -{ - Q931ie_NetFac *pIE = (Q931ie_NetFac*)IBuf; - L3INT rc = Q931E_NO_ERROR; - L3INT Beg = *Octet; - L3INT li; - L3INT x; - - OBuf[(*Octet)++] = Q931ie_NETWORK_SPECIFIC_FACILITIES; - li = (*Octet)++; - - /* Octet 3 */ - OBuf[(*Octet)++] = pIE->LenNetID; - - if (pIE->LenNetID > 0) { - /* Octet 3.1 */ - OBuf[(*Octet)++] = 0x80 | (pIE->TypeNetID << 4) | pIE->NetIDPlan; - - /* Octet 3.2 */ - for (x = 0; x LenNetID; x++) { - OBuf[(*Octet)++] = pIE->NetID[x]; - } - } - - /* Octet 4 */ - OBuf[(*Octet)++] = pIE->NetFac; - - OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; - return rc; -} - -/***************************************************************************** - - Function: Q931Uie_NotifInd - - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset - - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. - - Return Value: Error Message - -*****************************************************************************/ -L3INT Q931Uie_NotifInd(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) -{ - Q931ie_NotifInd *pie = (Q931ie_NotifInd*)OBuf; - ie *pIE = &pMsg->NotifInd; - L3INT Off = 0; - L3INT Octet = 0; - L3INT IESize; - - *pIE = 0; - - pie->IEId = IBuf[Octet++]; - - /* Octet 2*/ - IESize = IBuf[Octet++]; - - /* Octet 3 */ - pie->Notification = IBuf[Octet + Off] & 0x7f; - - Off = Q931ReadExt(&IBuf[Octet], Off); - Octet++; - - Q931IESizeTest(Q931E_NOTIFIND); - Q931SetIE(*pIE, *OOff); - - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_NotifInd); - pie->Size = sizeof(Q931ie_NotifInd); - - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pie_NotifInd - - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. - - Return Value: Error code, 0 = OK - -*****************************************************************************/ -L3INT Q931Pie_NotifInd(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) -{ - Q931ie_NotifInd *pIE = (Q931ie_NotifInd*)IBuf; - L3INT rc = Q931E_NO_ERROR; - L3INT Beg = *Octet; - L3INT li; - - OBuf[(*Octet)++] = Q931ie_NOTIFICATION_INDICATOR; - li = (*Octet)++; - - /* Octet 3 */ - OBuf[(*Octet)++] = pIE->Notification; - - OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; - return rc; -} - -/***************************************************************************** - - Function: Q931Uie_ProgInd - - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset - - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. - - Return Value: Error Message - -*****************************************************************************/ -L3INT Q931Uie_ProgInd(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) -{ - Q931ie_ProgInd *pie = (Q931ie_ProgInd*)OBuf; - ie *pIE = &pMsg->ProgInd; - L3INT Off = 0; - L3INT Octet = 0; - L3INT IESize; - - *pIE = 0; - - pie->IEId = IBuf[Octet++]; - - /* Octet 2 */ - IESize = IBuf[Octet++]; - - /* Octet 3 */ - pie->CodStand = (IBuf[Octet + Off] >> 5) & 0x03; - pie->Location = IBuf[Octet + Off] & 0x0f; - - Off = Q931ReadExt(&IBuf[Octet], Off); - Octet++; - - /* Octet 4 */ - pie->ProgDesc = IBuf[Octet + Off] & 0x7f; - Off = Q931ReadExt(&IBuf[Octet], Off); - Octet++; - - Q931IESizeTest(Q931E_PROGIND); - Q931SetIE(*pIE, *OOff); - - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_ProgInd); - pie->Size = sizeof(Q931ie_ProgInd); - - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pie_ProgInd - - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset L3INTo OBuf. - - Return Value: Error code, 0 = OK - -*****************************************************************************/ -L3INT Q931Pie_ProgInd(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) -{ - Q931ie_ProgInd *pIE = (Q931ie_ProgInd*)IBuf; - L3INT rc = Q931E_NO_ERROR; - L3INT Beg = *Octet; - L3INT li; - - OBuf[(*Octet)++] = Q931ie_PROGRESS_INDICATOR; - li = (*Octet)++; - - /* Octet 3 */ - OBuf[(*Octet)++] = 0x80 | (pIE->CodStand << 5) | pIE->Location; - - /* Octet 4 */ - OBuf[(*Octet)++] = 0x80 | pIE->ProgDesc; - - OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; - return rc; -} - -/***************************************************************************** - - Function: Q931Uie_RepeatInd - - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset - - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. - - Return Value: Error Message - -*****************************************************************************/ -L3INT Q931Uie_RepeatInd(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) -{ - Q931ie_RepeatInd *pie = (Q931ie_RepeatInd*)OBuf; - ie *pIE = &pMsg->RepeatInd; - L3INT Off = 0; - L3INT Octet = 0; - - *pIE = 0; - - pie->IEId = IBuf[Octet] & 0xf0; - pie->RepeatInd = IBuf[Octet] & 0x0f; - Octet ++; - - Q931SetIE(*pIE, *OOff); - - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_RepeatInd); - pie->Size = sizeof(Q931ie_RepeatInd); - - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pie_RepeatInd - - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. - - Return Value: Error code, 0 = OK - -*****************************************************************************/ -L3INT Q931Pie_RepeatInd(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) -{ - Q931ie_RepeatInd *pIE = (Q931ie_RepeatInd*)IBuf; - L3INT rc = 0; - /* L3INT Beg = *Octet; */ - - OBuf[(*Octet)++] = Q931ie_REPEAT_INDICATOR | pIE->RepeatInd; - - return rc; -} - -/***************************************************************************** - - Function: Q931Uie_RevChargeInd - - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset - - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. - - Return Value: Error Message - -*****************************************************************************/ -L3INT Q931Uie_RevChargeInd(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) -{ - ie iE; - /* ie *pIE = &pMsg->RevChargeInd; */ - Q931SetIE(iE, *OOff); - - return iE; -} - -/***************************************************************************** - - Function: Q931Pie_RevChargeInd - - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. - - Return Value: Error code, 0 = OK - -*****************************************************************************/ -L3INT Q931Pie_RevChargeInd(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) -{ - L3BOOL RetCode = L3FALSE; - - NoWarning(OBuf); - NoWarning(IBuf); - - return RetCode; -} - -/***************************************************************************** - - Function: Q931Uie_RestartInd - - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset - - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. - - Return Value: Error Message - -*****************************************************************************/ -L3INT Q931Uie_RestartInd(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) -{ - Q931ie_RestartInd *pie = (Q931ie_RestartInd*)OBuf; - ie *pIE = &pMsg->RestartInd; - L3INT Off = 0; - L3INT Octet = 0; - L3INT IESize; - - *pIE = 0; - - pie->IEId = IBuf[Octet++]; - - /* Octet 2 */ - IESize = IBuf[Octet++]; - - /* Octet 3 */ - pie->Class = IBuf[Octet + Off] & 0x07; - pie->Spare = IBuf[Octet + Off] & 0x78; - - Off = Q931ReadExt(&IBuf[Octet], Off); - Octet++; - - Q931IESizeTest(Q931E_RESTARTIND); - Q931SetIE(*pIE, *OOff); - - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_RestartInd); - pie->Size = sizeof(Q931ie_RestartInd); - - - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pie_RestartInd - - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. - - Return Value: Error code, 0 = OK - -*****************************************************************************/ -L3INT Q931Pie_RestartInd(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) -{ - Q931ie_RestartInd *pIE = (Q931ie_RestartInd*)IBuf; - L3INT rc = Q931E_NO_ERROR; - L3INT Beg = *Octet; - L3INT li; - - OBuf[(*Octet)++] = Q931ie_RESTART_INDICATOR; - li = (*Octet)++; - - /* Octet 3*/ - OBuf[(*Octet)++] = 0x80 | pIE->Class ; - - OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; - return rc; -} - -/***************************************************************************** - - Function: Q931Uie_Segment - - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset - - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. - - Return Value: Error Message - -*****************************************************************************/ -L3INT Q931Uie_Segment(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) -{ - Q931ie_Segment *pie = (Q931ie_Segment*)OBuf; - ie *pIE = &pMsg->Segment; - L3INT Off = 0; - L3INT Octet = 0; - L3INT IESize; - - *pIE = 0; - - pie->IEId = IBuf[Octet++]; - Octet++; - - /* Octet 2*/ - IESize = IBuf[Octet++]; - - /* Octet 3 */ - pie->FSI = (IBuf[Octet + Off] & 0x80) >> 7; - pie->NumSegRem = IBuf[Octet + Off] & 0x7f; - Octet++; - - /* Octet 4 */ - pie->SegType = IBuf[Octet + Off] & 0x7f; - Octet++; - - Q931IESizeTest(Q931E_SEGMENT); - Q931SetIE(*pIE, *OOff); - - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_Segment); - pie->Size = sizeof(Q931ie_Segment); - - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pie_Segment - - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. - - Return Value: Error code, 0 = OK - -*****************************************************************************/ -L3INT Q931Pie_Segment(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) -{ - Q931ie_Segment *pIE = (Q931ie_Segment*)IBuf; - L3INT rc = Q931E_NO_ERROR; - L3INT Beg = *Octet; - L3INT li; - - OBuf[(*Octet)++] = Q931ie_SEGMENTED_MESSAGE; - li = (*Octet)++; - - /* Octet 3 */ - OBuf[(*Octet)++] = (pIE->FSI << 7) | pIE->NumSegRem; - - /* Octet 4 */ - OBuf[(*Octet)++] = pIE->SegType; - - OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; - return rc; -} - -/***************************************************************************** - - Function: Q931Uie_SendComplete - - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset - - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. - - Return Value: Error Message - -*****************************************************************************/ -L3INT Q931Uie_SendComplete(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) -{ - Q931ie_SendComplete *pie = (Q931ie_SendComplete*)OBuf; - ie *pIE = &pMsg->SendComplete; - L3INT Off = 0; - L3INT Octet = 0; - - *pIE = 0; - Octet++; - - Q931SetIE(*pIE, *OOff); - - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_SendComplete); - pie->Size = sizeof(Q931ie_SendComplete); - - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pie_ProgInd - - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. - - Return Value: Error code, 0 = OK - -*****************************************************************************/ -L3INT Q931Pie_SendComplete(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) -{ - /* Q931ie_SendComplete * pIE = (Q931ie_SendComplete*)IBuf; */ - L3INT rc = Q931E_NO_ERROR; - /* L3INT Beg = *Octet; */ - - OBuf[(*Octet)++] = 0x80 | (L3UCHAR)Q931ie_SENDING_COMPLETE; - - return rc; -} - -/***************************************************************************** - - Function: Q931Uie_Signal - - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset - - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. - - Return Value: Error Message - -*****************************************************************************/ -L3INT Q931Uie_Signal(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) -{ - Q931ie_Signal *pie = (Q931ie_Signal*)OBuf; - ie *pIE = &pMsg->Signal; - L3INT Off = 0; - L3INT Octet = 0; - L3INT IESize; - - *pIE = 0; - - pie->IEId = IBuf[Octet++]; - - /* Octet 2 */ - IESize = IBuf[Octet++]; - - /* Octet 3 */ - pie->Signal = IBuf[Octet + Off]; - Octet++; - - Q931IESizeTest(Q931E_SIGNAL); - Q931SetIE(*pIE, *OOff); - - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_Signal); - pie->Size = sizeof(Q931ie_Signal); - - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pie_Signal - - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. - - Return Value: Error code, 0 = OK - -*****************************************************************************/ -L3INT Q931Pie_Signal(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) -{ - Q931ie_Signal *pIE = (Q931ie_Signal*)IBuf; - L3INT rc = Q931E_NO_ERROR; - L3INT Beg = *Octet; - L3INT li; - - OBuf[(*Octet)++] = Q931ie_SIGNAL; - li = (*Octet)++; - - /* Octet 3 */ - OBuf[(*Octet)++] = pIE->Signal; - - OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; - return rc; -} - -/***************************************************************************** - - Function: Q931Uie_TransNetSel - - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset - - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. - - Return Value: Error Message - -*****************************************************************************/ -L3INT Q931Uie_TransNetSel(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) -{ - Q931ie_TransNetSel *pie = (Q931ie_TransNetSel*)OBuf; - ie *pIE = &pMsg->TransNetSel; - L3INT Off = 0; - L3INT Octet = 0; - L3INT x = 0; - L3INT l; - - *pIE = 0; - - pie->IEId = IBuf[Octet++]; - - /* Octet 2 */ - l = IBuf[Octet++] - 3; - - /* Octet 3 */ - pie->Type = (IBuf[Octet + Off] >> 4) & 0x07; - - Off = Q931ReadExt(&IBuf[Octet], Off); - Octet++; - - for (x = 0; x < l; x++) { - pie->NetID[x] = IBuf[Octet + Off] & 0x7f; - Off++; - } - - Q931SetIE(*pIE, *OOff); - - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_TransNetSel) + x - 1; - pie->Size = (L3UCHAR)(sizeof(Q931ie_TransNetSel) + x - 1); - - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pie_TransNetSel - - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. - - Return Value: Error code, 0 = OK - -*****************************************************************************/ -L3INT Q931Pie_TransNetSel(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) -{ - Q931ie_TransNetSel *pIE = (Q931ie_TransNetSel*)IBuf; - L3INT rc = Q931E_NO_ERROR; - L3INT Beg = *Octet; - L3INT li; - L3INT x; - L3INT l; - - OBuf[(*Octet)++] = Q931ie_TRANSIT_NETWORK_SELECTION; - li = (*Octet)++; - - /* Octet 3 */ - OBuf[(*Octet)++] = 0x80 | (pIE->Type << 4) | pIE->NetIDPlan; - - /* Octet 4 */ - l = pIE->Size - sizeof(Q931ie_TransNetSel) + 1; - for (x = 0; x < l; x++) { - OBuf[(*Octet)++] = pIE->NetID[x]; - } - - OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; - return rc; -} - -/***************************************************************************** - - Function: Q931Uie_UserUser - - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset - - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. - - Return Value: Error Message - -*****************************************************************************/ -L3INT Q931Uie_UserUser(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) -{ - Q931ie_UserUser *pie = (Q931ie_UserUser*)OBuf; - ie *pIE = &pMsg->UserUser; - L3INT Off = 0; - L3INT Octet = 0; - L3INT l; - - *pIE = 0; - - pie->IEId = IBuf[Octet++]; - - /* Octet 2 */ - l = IBuf[Octet++] - 1; - - /* Octet 3 */ - pie->ProtDisc = IBuf[Octet++]; - - for (Off = 0; Off < l; Off++) { - pie->User[Off] = IBuf[Octet + Off]; - } - - Q931SetIE(*pIE, *OOff); - - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_UserUser) + Off - 1; - pie->Size = (L3UCHAR)(sizeof(Q931ie_UserUser) + Off - 1); - - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pie_UserUser - - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. - - Return Value: Error code, 0 = OK - -*****************************************************************************/ -L3INT Q931Pie_UserUser(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) -{ - Q931ie_UserUser *pIE = (Q931ie_UserUser*)IBuf; - L3INT rc = Q931E_NO_ERROR; - L3INT Beg = *Octet; - L3INT li; - L3INT x; - L3INT l; - - OBuf[(*Octet)++] = Q931ie_USER_USER; - li = (*Octet)++; - - /* Octet 3 */ - OBuf[(*Octet)++] = pIE->ProtDisc; - - /* Octet 4 */ - l = pIE->Size - sizeof(Q931ie_UserUser) + 1; - for (x = 0; x < l; x++) { - OBuf[(*Octet)++] = pIE->User[x]; - } - - OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; - return rc; -} - -/***************************************************************************** - - Function: Q931Uie_GenericDigits - - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset - - - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. - - Return Value: Error Message - -*****************************************************************************/ -L3INT Q931Uie_GenericDigits(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) -{ - Q931ie_GenericDigits *pie = (Q931ie_GenericDigits*)OBuf; - ie *pIE = &pMsg->GenericDigits; - L3INT Off = 0; - L3INT Octet = 0; - L3INT x; - L3INT IESize; - - *pIE = 0; - - /* Octet 1 */ - pie->IEId = IBuf[Octet++]; - - /* Octet 2 */ - IESize = IBuf[Octet++]; - - /* Octet 3 */ - pie->Type = (IBuf[Octet]) & 0x1F; - pie->Encoding = (IBuf[Octet] >> 5) & 0x07; - Octet++; - - /* Octet 4*/ - if (pie->Encoding == 0) { /* BCD Even */ - x = 0; - do { - pie->Digit[x++] = IBuf[Octet + Off] & 0x0f; - pie->Digit[x++] = (IBuf[Octet + Off] >> 4) & 0x0f; - Off++; - } while (Q931MoreIE()); - } else if (pie->Encoding == 1) { /* BCD Odd */ - x = 0; - do { - pie->Digit[x++] = IBuf[Octet + Off] & 0x0f; - if (Q931MoreIE()) { - pie->Digit[x] = (IBuf[Octet + Off] >> 4) & 0x0f; - } - x++; - Off++; - } while (Q931MoreIE()); - } else if (pie->Encoding == 2) { /* IA5 */ - x = 0; - do { - pie->Digit[x++] = IBuf[Octet + Off] & 0x7f; - Off++; - } while (Q931MoreIE()); - } else { - /* Binary encoding type unkown */ - Q931SetError(pTrunk, Q931E_GENERIC_DIGITS, Octet, Off); - return Q931E_GENERIC_DIGITS; - } - - Q931IESizeTest(Q931E_GENERIC_DIGITS); - Q931SetIE(*pIE, *OOff); - - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_CallingSub) + x - 1; - pie->Size = (L3UCHAR)(sizeof(Q931ie_CallingSub) + x - 1); - - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pie_GenericDigits - - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. - - Return Value: Error code, 0 = OK - -*****************************************************************************/ - -L3INT Q931Pie_GenericDigits(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) -{ - OBuf[(*Octet)++] = (Q931ie_GENERIC_DIGITS & 0xFF); - OBuf[(*Octet)++] = 0; - - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Uie_ChangeStatus - - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset - - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. - - Return Value: Error Message - -*****************************************************************************/ -L3INT Q931Uie_ChangeStatus(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) -{ - Q931ie_ChangeStatus *pie = (Q931ie_ChangeStatus*)OBuf; - ie *pIE = &pMsg->ChangeStatus; - L3INT Off = 0; - L3INT Octet = 0; - L3INT IESize; - - *pIE = 0; - - pie->IEId = IBuf[Octet++]; - - /* Octet 2 */ - IESize = IBuf[Octet++]; - - /* Octet 3 */ - pie->Preference = (IBuf[Octet + Off] >> 6) & 0x01; - pie->Spare = IBuf[Octet + Off] & 0x38; - pie->NewStatus = IBuf[Octet + Off] & 0x07; - Octet++; - - Q931SetIE(*pIE, *OOff); - - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_ChangeStatus); - pie->Size = sizeof(Q931ie_ChangeStatus); - - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pie_ChangeStatus - - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. - - Return Value: Error code, 0 = OK - -*****************************************************************************/ -L3INT Q931Pie_ChangeStatus(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) -{ - Q931ie_ChangeStatus *pIE = (Q931ie_ChangeStatus*)IBuf; - L3INT rc = Q931E_NO_ERROR; - L3INT Beg = *Octet; - L3INT li; - - OBuf[(*Octet)++] = Q931ie_CHANGE_STATUS; - li = (*Octet)++; - - /* Octet 3 */ - OBuf[(*Octet)++] = 0x80 | pIE->NewStatus | ((pIE->Preference & 0x01) << 6); - - OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; - return rc; -} - - - -L3INT Q931Uie_Generic(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *IOff, L3INT *OOff) -{ - L3INT Octet = 0; - L3UCHAR id = 0; - - /* id */ - id = IBuf[Octet++]; - - /* Length */ - Octet += IBuf[Octet]; - Octet++; - - Q931Log(pTrunk, Q931_LOG_DEBUG, "Discarding IE %#hhx with length %d\n", id, Octet - 2); - - *IOff += Octet; - return Q931E_NO_ERROR; -} - -L3INT Q931Pie_Generic(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) -{ - /* do nothing */ - return Q931E_NO_ERROR; -} diff --git a/libs/freetdm/src/isdn/Q931mes.c b/libs/freetdm/src/isdn/Q931mes.c deleted file mode 100644 index 8e34a170e1..0000000000 --- a/libs/freetdm/src/isdn/Q931mes.c +++ /dev/null @@ -1,1870 +0,0 @@ -/***************************************************************************** - - FileName: Q931mes.c - - Contents: Pack/Unpack functions. These functions will unpack a Q931 - message from the bit packed original format into structs - that contains variables sized by the user. It will also pack - the struct back into a Q.931 message as required. - - See q931.h for description. - - License/Copyright: - - Copyright (c) 2007, Jan Vidar Berger, Case Labs, Ltd. All rights reserved. - email:janvb@caselaboratories.com - - 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 Case Labs, Ltd 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT OWNER OR CONTRIBUTORS 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 SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - -*****************************************************************************/ - -#include "Q931.h" - -/** - * Q931MesgHeader - * \brief Create Q.931 Message header - */ -L3INT Q931MesgHeader(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *mes, L3UCHAR *OBuf, L3INT Size, L3INT *IOff) -{ - L3INT Octet = *IOff; - - Q931Log(pTrunk, Q931_LOG_DEBUG, "Creating Q.931 Message Header:\n ProtDisc %d (%#x), CRV %d (%#x), CRVflag: %d (%#x), MesType: %d (%#x)\n", - mes->ProtDisc, mes->ProtDisc, mes->CRV, mes->CRV, mes->CRVFlag, mes->CRVFlag, mes->MesType, mes->MesType); - - OBuf[Octet++] = mes->ProtDisc; /* Protocol discriminator */ - if (!Q931_IS_BRI(pTrunk)) { - OBuf[Octet++] = 2; /* length is 2 octets */ - OBuf[Octet++] = (L3UCHAR)((mes->CRV >> 8) & 0x7f) | ((mes->CRVFlag << 7) & 0x80); /* msb */ - OBuf[Octet++] = (L3UCHAR) (mes->CRV & 0xff); /* lsb */ - } else { - OBuf[Octet++] = 1; /* length is 1 octet */ - OBuf[Octet++] = (L3UCHAR) (mes->CRV & 0x7f) | ((mes->CRVFlag << 7) & 0x80); /* CRV & flag */ - } - OBuf[Octet++] = mes->MesType; /* message header */ - - *IOff = Octet; - return 0; -} - - -/***************************************************************************** - - Function: Q931Umes_Alerting - -*****************************************************************************/ - -L3INT Q931Umes_Alerting(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3INT OOff = 0; - L3INT rc = Q931E_NO_ERROR; - - while (IOff < Size) { - switch (IBuf[IOff]) { - case Q931ie_BEARER_CAPABILITY: - case Q931ie_CHANNEL_IDENTIFICATION: - case Q931ie_PROGRESS_INDICATOR: - case Q931ie_DISPLAY: - case Q931ie_SIGNAL: - case Q931ie_HIGH_LAYER_COMPATIBILITY: - case Q931ie_USER_USER: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if (rc != Q931E_NO_ERROR) - return rc; - break; - default: - return Q931E_ILLEGAL_IE; - break; - } - } - - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pmes_Alerting - -*****************************************************************************/ -L3INT Q931Pmes_Alerting(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; - L3INT rc = Q931E_NO_ERROR; - L3INT Octet = 0; - - /* Q931 Message Header */ - Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); - - /* Bearer capability */ - if (Q931IsIEPresent(pMes->BearerCap)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_BEARER_CAPABILITY](pTrunk, Q931GetIEPtr(pMes->BearerCap,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Channel Identification */ - if (Q931IsIEPresent(pMes->ChanID)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CHANNEL_IDENTIFICATION](pTrunk, Q931GetIEPtr(pMes->ChanID,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Progress indicator */ - if (Q931IsIEPresent(pMes->ProgInd)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_PROGRESS_INDICATOR](pTrunk, Q931GetIEPtr(pMes->ProgInd,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Display */ - if (Q931IsIEPresent(pMes->Display)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Signal */ - if (Q931IsIEPresent(pMes->Signal)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_SIGNAL](pTrunk, Q931GetIEPtr(pMes->Signal,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* High Layer Compatibility */ - if (Q931IsIEPresent(pMes->HLComp)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_HIGH_LAYER_COMPATIBILITY](pTrunk, Q931GetIEPtr(pMes->HLComp,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - *OSize = Octet; - return rc; -} - -/***************************************************************************** - - Function: Q931Umes_CallProceeding - -*****************************************************************************/ -L3INT Q931Umes_CallProceeding(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3INT OOff = 0; - L3INT rc = Q931E_NO_ERROR; - - while (IOff < Size) { - switch (IBuf[IOff]) { - case Q931ie_BEARER_CAPABILITY: - case Q931ie_CHANNEL_IDENTIFICATION: - case Q931ie_PROGRESS_INDICATOR: - case Q931ie_DISPLAY: - case Q931ie_HIGH_LAYER_COMPATIBILITY: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if (rc != Q931E_NO_ERROR) - return rc; - break; - default: - return Q931E_ILLEGAL_IE; - break; - } - } - - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pmes_CallProceeding - -*****************************************************************************/ -L3INT Q931Pmes_CallProceeding(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; - L3INT rc = Q931E_NO_ERROR; - L3INT Octet = 0; - - /* Q931 Message Header */ - Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); - - /* Bearer capability */ - if (Q931IsIEPresent(pMes->BearerCap)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_BEARER_CAPABILITY](pTrunk, Q931GetIEPtr(pMes->BearerCap,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Channel Identification */ - if (Q931IsIEPresent(pMes->ChanID)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CHANNEL_IDENTIFICATION](pTrunk, Q931GetIEPtr(pMes->ChanID,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Progress indicator */ - if (Q931IsIEPresent(pMes->ProgInd)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_PROGRESS_INDICATOR](pTrunk, Q931GetIEPtr(pMes->ProgInd,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Display */ - if (Q931IsIEPresent(pMes->Display)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* High Layer Compatibility */ - if (Q931IsIEPresent(pMes->HLComp)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_HIGH_LAYER_COMPATIBILITY](pTrunk, Q931GetIEPtr(pMes->HLComp,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - *OSize = Octet; - return rc; -} - -/***************************************************************************** - - Function: Q931Umes_CongestionControl - -*****************************************************************************/ -L3INT Q931Umes_CongestionControl(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3BOOL RetCode = L3FALSE; - - NoWarning(mes); - NoWarning(IBuf); - - return RetCode; -} - - -/***************************************************************************** - - Function: Q931Pmes_CongestionControl - -*****************************************************************************/ -L3INT Q931Pmes_CongestionControl(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - L3BOOL RetCode = L3FALSE; - - NoWarning(OBuf); - NoWarning(IBuf); - - *OSize = 0; - return RetCode; -} - -/***************************************************************************** - - Function: Q931Umes_Connect - -*****************************************************************************/ -L3INT Q931Umes_Connect(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3INT OOff = 0; - L3INT rc = Q931E_NO_ERROR; - - while (IOff < Size) { - switch (IBuf[IOff]) { - case Q931ie_BEARER_CAPABILITY: - case Q931ie_CHANNEL_IDENTIFICATION: - case Q931ie_PROGRESS_INDICATOR: - case Q931ie_DISPLAY: - case Q931ie_DATETIME: - case Q931ie_SIGNAL: - case Q931ie_LOW_LAYER_COMPATIBILITY: - case Q931ie_HIGH_LAYER_COMPATIBILITY: - case Q931ie_CONNECTED_NUMBER: /* not actually used, seen while testing BRI PTMP TE */ - case Q931ie_USER_USER: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if (rc != Q931E_NO_ERROR) - return rc; - break; - - default: - Q931Log(pTrunk, Q931_LOG_ERROR, "Illegal IE %#hhx in Connect Message\n", IBuf[IOff]); - - return Q931E_ILLEGAL_IE; - break; - } - } - - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pmes_Connect - -*****************************************************************************/ -L3INT Q931Pmes_Connect(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; - L3INT rc = Q931E_NO_ERROR; - L3INT Octet = 0; - - /* Q931 Message Header */ - Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); - - /* Bearer capability */ - if (Q931IsIEPresent(pMes->BearerCap)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_BEARER_CAPABILITY](pTrunk, Q931GetIEPtr(pMes->BearerCap,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Channel Identification */ - if (Q931IsIEPresent(pMes->ChanID)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CHANNEL_IDENTIFICATION](pTrunk, Q931GetIEPtr(pMes->ChanID,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Progress indicator */ - if (Q931IsIEPresent(pMes->ProgInd)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_PROGRESS_INDICATOR](pTrunk, Q931GetIEPtr(pMes->ProgInd,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Display */ - if (Q931IsIEPresent(pMes->Display)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Date/Time */ - if (Q931IsIEPresent(pMes->DateTime)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DATETIME](pTrunk, Q931GetIEPtr(pMes->DateTime,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Signal */ - if (Q931IsIEPresent(pMes->Signal)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_SIGNAL](pTrunk, Q931GetIEPtr(pMes->Signal,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Low Layer Compatibility */ - if (Q931IsIEPresent(pMes->LLComp)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_LOW_LAYER_COMPATIBILITY](pTrunk, Q931GetIEPtr(pMes->LLComp,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* High Layer Compatibility */ - if (Q931IsIEPresent(pMes->HLComp)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_HIGH_LAYER_COMPATIBILITY](pTrunk, Q931GetIEPtr(pMes->HLComp,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - *OSize = Octet; - return rc; -} - -/***************************************************************************** - - Function: Q931Umes_ConnectAck - -*****************************************************************************/ -L3INT Q931Umes_ConnectAck(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3INT OOff = 0; - L3INT rc = Q931E_NO_ERROR; - - while (IOff < Size) { - switch (IBuf[IOff]) { - case Q931ie_DISPLAY: - case Q931ie_SIGNAL: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if (rc != Q931E_NO_ERROR) - return rc; - break; - default: - return Q931E_ILLEGAL_IE; - break; - } - } - - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} - - -/***************************************************************************** - - Function: Q931Pmes_ConnectAck - -*****************************************************************************/ -L3INT Q931Pmes_ConnectAck(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; - L3INT rc = Q931E_NO_ERROR; - L3INT Octet = 0; - - /* Q931 Message Header */ - Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); - - /* Display */ - if (Q931IsIEPresent(pMes->Display)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Signal */ - if (Q931IsIEPresent(pMes->Signal)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_SIGNAL](pTrunk, Q931GetIEPtr(pMes->Signal,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - *OSize = Octet; - return rc; -} - -/***************************************************************************** - - Function: Q931Umes_Disconnect - -*****************************************************************************/ -L3INT Q931Umes_Disconnect(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3INT OOff = 0; - L3INT rc = Q931E_NO_ERROR; - - while (IOff < Size) { - switch (IBuf[IOff]) { - case Q931ie_CAUSE: - case Q931ie_PROGRESS_INDICATOR: - case Q931ie_DISPLAY: - case Q931ie_SIGNAL: - case Q931ie_FACILITY: - case Q931ie_USER_USER: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if (rc != Q931E_NO_ERROR) - return rc; - break; - default: - return Q931E_ILLEGAL_IE; - break; - } - } - - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pmes_Disconnect - -*****************************************************************************/ -L3INT Q931Pmes_Disconnect(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; - L3INT rc = Q931E_NO_ERROR; - L3INT Octet = 0; - - /* Q931 Message Header */ - Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); - - /* Cause */ - if (Q931IsIEPresent(pMes->Cause)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CAUSE](pTrunk, Q931GetIEPtr(pMes->Cause,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Progress indicator */ - if (Q931IsIEPresent(pMes->ProgInd)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_PROGRESS_INDICATOR](pTrunk, Q931GetIEPtr(pMes->ProgInd,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Display */ - if (Q931IsIEPresent(pMes->Display)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Signal */ - if (Q931IsIEPresent(pMes->Signal)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_SIGNAL](pTrunk, Q931GetIEPtr(pMes->Signal,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - *OSize = Octet; - return rc; -} - -/***************************************************************************** - - Function: Q931Umes_Information - -*****************************************************************************/ -L3INT Q931Umes_Information(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3INT OOff = 0; - L3INT rc = Q931E_NO_ERROR; - - while (IOff < Size) { - switch (IBuf[IOff]) { - case Q931ie_SENDING_COMPLETE: - case Q931ie_DISPLAY: - case Q931ie_KEYPAD_FACILITY: - case Q931ie_CALLED_PARTY_NUMBER: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if (rc != Q931E_NO_ERROR) - return rc; - break; - default: - return Q931E_ILLEGAL_IE; - break; - } - } - - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pmes_Information - -*****************************************************************************/ -L3INT Q931Pmes_Information(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; - L3INT rc = Q931E_NO_ERROR; - L3INT Octet = 0; - - /* Q931 Message Header */ - Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); - - /* Sending Complete */ - if (Q931IsIEPresent(pMes->SendComplete)) { - OBuf[Octet++] = (L3UCHAR)(pMes->SendComplete & 0x00ff); - } - - /* Display */ - if (Q931IsIEPresent(pMes->Display)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Keypad Facility */ - if (Q931IsIEPresent(pMes->KeypadFac)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_KEYPAD_FACILITY](pTrunk, Q931GetIEPtr(pMes->KeypadFac,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Signal */ - if (Q931IsIEPresent(pMes->Signal)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_SIGNAL](pTrunk, Q931GetIEPtr(pMes->Signal,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Called Party number */ - if (Q931IsIEPresent(pMes->CalledNum)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALLED_PARTY_NUMBER](pTrunk, Q931GetIEPtr(pMes->CalledNum,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - *OSize = Octet; - return rc; -} - -/***************************************************************************** - - Function: Q931Umes_Notify - -*****************************************************************************/ -L3INT Q931Umes_Notify(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3INT OOff = 0; - L3INT rc = Q931E_NO_ERROR; - - while (IOff < Size) { - switch (IBuf[IOff]) { - case Q931ie_BEARER_CAPABILITY: - case Q931ie_NOTIFICATION_INDICATOR: - case Q931ie_DISPLAY: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if (rc != Q931E_NO_ERROR) - return rc; - break; - default: - return Q931E_ILLEGAL_IE; - break; - } - } - - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pmes_Notify - -*****************************************************************************/ -L3INT Q931Pmes_Notify(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; - L3INT rc = Q931E_NO_ERROR; - L3INT Octet = 0; - - /* Q931 Message Header */ - Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); - - /* Bearer capability */ - if (Q931IsIEPresent(pMes->BearerCap)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_BEARER_CAPABILITY](pTrunk, Q931GetIEPtr(pMes->BearerCap,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Display */ - if (Q931IsIEPresent(pMes->Display)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - *OSize = Octet; - return rc; -} - -/***************************************************************************** - - Function: Q931Umes_Progress - -*****************************************************************************/ -L3INT Q931Umes_Progress(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3INT OOff = 0; - L3INT rc = Q931E_NO_ERROR; - - while (IOff < Size) { - switch (IBuf[IOff]) { - case Q931ie_BEARER_CAPABILITY: - case Q931ie_CAUSE: - case Q931ie_PROGRESS_INDICATOR: - case Q931ie_DISPLAY: - case Q931ie_HIGH_LAYER_COMPATIBILITY: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if (rc != Q931E_NO_ERROR) - return rc; - break; - default: - return Q931E_ILLEGAL_IE; - break; - } - } - - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pmes_Progress - -*****************************************************************************/ -L3INT Q931Pmes_Progress(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; - L3INT rc = Q931E_NO_ERROR; - L3INT Octet = 0; - - /* Q931 Message Header */ - Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); - - /* Bearer capability */ - if (Q931IsIEPresent(pMes->BearerCap)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_BEARER_CAPABILITY](pTrunk, Q931GetIEPtr(pMes->BearerCap,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Cause */ - if (Q931IsIEPresent(pMes->Cause)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CAUSE](pTrunk, Q931GetIEPtr(pMes->Cause,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Progress indicator */ - if (Q931IsIEPresent(pMes->ProgInd)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_PROGRESS_INDICATOR](pTrunk, Q931GetIEPtr(pMes->ProgInd,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Display */ - if (Q931IsIEPresent(pMes->Display)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* High Layer Compatibility */ - if (Q931IsIEPresent(pMes->HLComp)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_HIGH_LAYER_COMPATIBILITY](pTrunk, Q931GetIEPtr(pMes->HLComp,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - *OSize = Octet; - return rc; -} - -/***************************************************************************** - - Function: Q931Umes_Release - -*****************************************************************************/ -L3INT Q931Umes_Release(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3INT OOff = 0; - L3INT rc = Q931E_NO_ERROR; - - while (IOff < Size) { - switch (IBuf[IOff]) { - case Q931ie_CAUSE: - case Q931ie_DISPLAY: - case Q931ie_SIGNAL: - case Q931ie_USER_USER: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if (rc != Q931E_NO_ERROR) - return rc; - break; - default: - return Q931E_ILLEGAL_IE; - break; - } - } - - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pmes_Release - -*****************************************************************************/ -L3INT Q931Pmes_Release(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; - L3INT rc = Q931E_NO_ERROR; - L3INT Octet = 0; - - /* Q931 Message Header */ - Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); - - /* Cause */ - if (Q931IsIEPresent(pMes->Cause)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CAUSE](pTrunk, Q931GetIEPtr(pMes->Cause,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Display */ - if (Q931IsIEPresent(pMes->Display)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Signal */ - if (Q931IsIEPresent(pMes->Signal)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_SIGNAL](pTrunk, Q931GetIEPtr(pMes->Signal,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - *OSize = Octet; - return rc; -} - -/***************************************************************************** - - Function: Q931Umes_ReleaseComplete - -*****************************************************************************/ -L3INT Q931Umes_ReleaseComplete(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3INT OOff = 0; - L3INT rc = Q931E_NO_ERROR; - - while (IOff < Size) { - switch (IBuf[IOff]) { - case Q931ie_CAUSE: - case Q931ie_DISPLAY: - case Q931ie_SIGNAL: - case Q931ie_USER_USER: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if (rc != Q931E_NO_ERROR) - return rc; - break; - default: - return Q931E_ILLEGAL_IE; - break; - } - } - - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pmes_ReleaseComplete - -*****************************************************************************/ -L3INT Q931Pmes_ReleaseComplete(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; - L3INT rc = Q931E_NO_ERROR; - L3INT Octet = 0; - - /* Q931 Message Header */ - Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); - - /* Cause */ - if (Q931IsIEPresent(pMes->Cause)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CAUSE](pTrunk, Q931GetIEPtr(pMes->Cause,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Display */ - if (Q931IsIEPresent(pMes->Display)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Signal */ - if (Q931IsIEPresent(pMes->Signal)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_SIGNAL](pTrunk, Q931GetIEPtr(pMes->Signal,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - *OSize = Octet; - return rc; -} - -/***************************************************************************** - - Function: Q931Umes_Restart - -*****************************************************************************/ -L3INT Q931Umes_Restart(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3INT OOff = 0; - L3INT rc = Q931E_NO_ERROR; - - while (IOff < Size) { - switch (IBuf[IOff]) { - case Q931ie_CHANNEL_IDENTIFICATION: - case Q931ie_DISPLAY: - case Q931ie_RESTART_INDICATOR: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if (rc != Q931E_NO_ERROR) - return rc; - break; - default: - return Q931E_ILLEGAL_IE; - break; - } - } - - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pmes_Restart - -*****************************************************************************/ -L3INT Q931Pmes_Restart(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; - L3INT rc = Q931E_NO_ERROR; - L3INT Octet = 0; - - /* Q931 Message Header */ - Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); - - /* ChanID */ - if (Q931IsIEPresent(pMes->ChanID)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CHANNEL_IDENTIFICATION](pTrunk, Q931GetIEPtr(pMes->ChanID,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Display */ - if (Q931IsIEPresent(pMes->Display)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* RestartInd */ - if (Q931IsIEPresent(pMes->RestartInd)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_RESTART_INDICATOR](pTrunk, Q931GetIEPtr(pMes->RestartInd,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - *OSize = Octet; - return rc; -} - -/***************************************************************************** - - Function: Q931Umes_RestartAck - -*****************************************************************************/ -L3INT Q931Umes_RestartAck(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT IOff, L3INT Size) -{ - Q931mes_Generic *mes = (Q931mes_Generic*)OBuf; - L3INT OOff = 0; - L3INT rc = Q931E_NO_ERROR; - - while (IOff < Size) { - switch (IBuf[IOff]) { - case Q931ie_CHANNEL_IDENTIFICATION: - case Q931ie_DISPLAY: - case Q931ie_RESTART_INDICATOR: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if (rc != Q931E_NO_ERROR) - return rc; - break; - default: - return Q931E_ILLEGAL_IE; - break; - } - } - - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pmes_RestartAck - -*****************************************************************************/ -L3INT Q931Pmes_RestartAck(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; - L3INT rc = Q931E_NO_ERROR; - L3INT Octet = 0; - - /* Q931 Message Header */ - Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); - - /* ChanID */ - if (Q931IsIEPresent(pMes->ChanID)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CHANNEL_IDENTIFICATION](pTrunk, Q931GetIEPtr(pMes->ChanID,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Display */ - if (Q931IsIEPresent(pMes->Display)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* RestartInd */ - if (Q931IsIEPresent(pMes->RestartInd)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_RESTART_INDICATOR](pTrunk, Q931GetIEPtr(pMes->RestartInd,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - *OSize = Octet; - return rc; -} - -/***************************************************************************** - - Function: Q931Umes_Resume - -*****************************************************************************/ -L3INT Q931Umes_Resume(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3INT OOff = 0; - L3INT rc = Q931E_NO_ERROR; - - while (IOff < Size) { - switch (IBuf[IOff]) { - case Q931ie_CALL_IDENTITY: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if (rc != Q931E_NO_ERROR) - return rc; - break; - default: - return Q931E_ILLEGAL_IE; - break; - } - } - - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pmes_Resume - -*****************************************************************************/ -L3INT Q931Pmes_Resume(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; - L3INT rc = Q931E_NO_ERROR; - L3INT Octet = 0; - - /* Q931 Message Header */ - Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); - - /* Call Identity */ - if (Q931IsIEPresent(pMes->CallID)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALL_IDENTITY](pTrunk, Q931GetIEPtr(pMes->CallID,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - *OSize = Octet; - return rc; -} - -/***************************************************************************** - - Function: Q931Umes_ResumeAck - -*****************************************************************************/ -L3INT Q931Umes_ResumeAck(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3INT OOff = 0; - L3INT rc = Q931E_NO_ERROR; - - while (IOff < Size) { - switch (IBuf[IOff]) { - case Q931ie_CHANNEL_IDENTIFICATION: - case Q931ie_DISPLAY: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if (rc != Q931E_NO_ERROR) - return rc; - break; - default: - return Q931E_ILLEGAL_IE; - break; - } - } - - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} - - -/***************************************************************************** - - Function: Q931Pmes_ResumeAck - -*****************************************************************************/ -L3INT Q931Pmes_ResumeAck(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; - L3INT rc = Q931E_NO_ERROR; - L3INT Octet = 0; - - /* Q931 Message Header */ - Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); - - /* Channel Identification */ - if (Q931IsIEPresent(pMes->ChanID)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CHANNEL_IDENTIFICATION](pTrunk, Q931GetIEPtr(pMes->ChanID,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Display */ - if (Q931IsIEPresent(pMes->Display)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - *OSize = Octet; - return rc; -} - -/***************************************************************************** - - Function: Q931Umes_ResumeReject - -*****************************************************************************/ -L3INT Q931Umes_ResumeReject(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3INT OOff = 0; - L3INT rc = Q931E_NO_ERROR; - - while (IOff < Size) { - switch (IBuf[IOff]) { - case Q931ie_CAUSE: - case Q931ie_DISPLAY: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if (rc != Q931E_NO_ERROR) - return rc; - break; - default: - return Q931E_ILLEGAL_IE; - break; - } - } - - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} - - -/***************************************************************************** - - Function: Q931Pmes_ResumeReject - -*****************************************************************************/ -L3INT Q931Pmes_ResumeReject(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; - L3INT rc = Q931E_NO_ERROR; - L3INT Octet = 0; - - /* Q931 Message Header */ - Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); - - /* Cause */ - if (Q931IsIEPresent(pMes->Cause)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CAUSE](pTrunk, Q931GetIEPtr(pMes->Cause,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Display */ - if (Q931IsIEPresent(pMes->Display)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - *OSize = Octet; - return rc; -} - -L3INT Q931Umes_Segment(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT OOff) -{ - L3INT i = IOff; - - return IOff - i; -} - -L3INT Q931Pmes_Segment(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - L3BOOL RetCode = L3FALSE; - - *OSize = 0; - return RetCode; -} - -/***************************************************************************** - - Function: Q931Umes_Setup - -*****************************************************************************/ -L3INT Q931Umes_Setup(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3INT ir = 0; - L3INT OOff = 0; - L3INT rc = Q931E_NO_ERROR; - - while (IOff < Size) { - switch (IBuf[IOff]) { - case Q931ie_SENDING_COMPLETE: - IOff++; - break; - - case Q931ie_BEARER_CAPABILITY: - case Q931ie_CHANNEL_IDENTIFICATION: - case Q931ie_PROGRESS_INDICATOR: - case Q931ie_NETWORK_SPECIFIC_FACILITIES: - case Q931ie_DISPLAY: - case Q931ie_DATETIME: - case Q931ie_KEYPAD_FACILITY: - case Q931ie_SIGNAL: - case Q931ie_CALLING_PARTY_NUMBER: - case Q931ie_CALLING_PARTY_SUBADDRESS: - case Q931ie_CALLED_PARTY_NUMBER: - case Q931ie_CALLED_PARTY_SUBADDRESS: - case Q931ie_TRANSIT_NETWORK_SELECTION: - case Q931ie_LOW_LAYER_COMPATIBILITY: - case Q931ie_HIGH_LAYER_COMPATIBILITY: - case Q931ie_FACILITY: - case Q931ie_USER_USER: - case Q931ie_REDIRECTING_NUMBER: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if (rc != Q931E_NO_ERROR) - return rc; - break; - - case Q931ie_REPEAT_INDICATOR: - if (ir < 2) { - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - ir++; - } else { - return Q931E_ILLEGAL_IE; - } - break; - - default: - return Q931E_ILLEGAL_IE; - break; - } - } - - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pmes_Setup - - Decription: Pack a Q931mes_Generic into a real Q.931 message. The user will - set up a SETUP message and issue this to the stack where it - is processed by Q931ProcSetup that processes and validates - it before it actually sends it out. This function is called - to compute the real Q.931 message. - - Parameters: IBuf[IN] Ptr to un-packed struct - ISize[IN] Size of input buffer (unpacked message). - OBuf[OUT] Ptr to packed 'octet' wise message. - OSize[OUT] Size of packed message. - - Called By: Q931ProcSetup - -*****************************************************************************/ -L3INT Q931Pmes_Setup(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; - L3INT rc = Q931E_NO_ERROR; - L3INT Octet = 0; - - /* Q931 Message Header */ - Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); - - /* Sending Complete */ - if (Q931IsIEPresent(pMes->SendComplete)) { - OBuf[Octet++] = (L3UCHAR)Q931ie_SENDING_COMPLETE & 0xff; - } - - /* Repeat Indicator */ - if (Q931IsIEPresent(pMes->RepeatInd)) { - OBuf[Octet++] = (L3UCHAR)Q931ie_REPEAT_INDICATOR & 0xff; - } - - /* Bearer capability */ - if (Q931IsIEPresent(pMes->BearerCap)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_BEARER_CAPABILITY](pTrunk, Q931GetIEPtr(pMes->BearerCap,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } else { - rc = Q931E_BEARERCAP; - } - - /* Channel Identification */ - if (Q931IsIEPresent(pMes->ChanID)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CHANNEL_IDENTIFICATION](pTrunk, Q931GetIEPtr(pMes->ChanID,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Progress indicator */ - if (Q931IsIEPresent(pMes->ProgInd)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_PROGRESS_INDICATOR](pTrunk, Q931GetIEPtr(pMes->ProgInd,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Network spesific facilities */ - if (Q931IsIEPresent(pMes->NetFac)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_NETWORK_SPECIFIC_FACILITIES](pTrunk, Q931GetIEPtr(pMes->NetFac,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Display */ - if (Q931IsIEPresent(pMes->Display)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Date/Time */ - if (Q931IsIEPresent(pMes->DateTime)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DATETIME](pTrunk, Q931GetIEPtr(pMes->DateTime,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Keypad Facility */ - if (Q931IsIEPresent(pMes->KeypadFac)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_KEYPAD_FACILITY](pTrunk, Q931GetIEPtr(pMes->KeypadFac,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Signal */ - if (Q931IsIEPresent(pMes->Signal)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_SIGNAL](pTrunk, Q931GetIEPtr(pMes->Signal,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Calling Party Number */ - if (Q931IsIEPresent(pMes->CallingNum)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALLING_PARTY_NUMBER](pTrunk, Q931GetIEPtr(pMes->CallingNum,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Calling Party Subaddress */ - if (Q931IsIEPresent(pMes->CallingSub)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALLING_PARTY_SUBADDRESS](pTrunk, Q931GetIEPtr(pMes->CallingSub,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Called Party number */ - if (Q931IsIEPresent(pMes->CalledNum)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALLED_PARTY_NUMBER](pTrunk, Q931GetIEPtr(pMes->CalledNum,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Called party subaddress */ - if (Q931IsIEPresent(pMes->CalledSub)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALLED_PARTY_SUBADDRESS](pTrunk, Q931GetIEPtr(pMes->CalledSub,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Transit network selection */ - if (Q931IsIEPresent(pMes->TransNetSel)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_TRANSIT_NETWORK_SELECTION](pTrunk, Q931GetIEPtr(pMes->TransNetSel,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Repeat Indicator */ - if (Q931IsIEPresent(pMes->LLRepeatInd)) { - rc = Q931E_UNKNOWN_IE;/* TODO */ - } - - /* Low Layer Compatibility */ - if (Q931IsIEPresent(pMes->LLComp)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_LOW_LAYER_COMPATIBILITY](pTrunk, Q931GetIEPtr(pMes->LLComp,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* High Layer Compatibility */ - if (Q931IsIEPresent(pMes->HLComp)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_HIGH_LAYER_COMPATIBILITY](pTrunk, Q931GetIEPtr(pMes->HLComp,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - *OSize = Octet; - return rc; -} - -/***************************************************************************** - - Function: Q931Umes_SetupAck - -*****************************************************************************/ -L3INT Q931Umes_SetupAck(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3INT OOff = 0; - L3INT rc = Q931E_NO_ERROR; - - while (IOff < Size) { - switch (IBuf[IOff]) { - case Q931ie_CHANNEL_IDENTIFICATION: - case Q931ie_PROGRESS_INDICATOR: - case Q931ie_DISPLAY: - case Q931ie_SIGNAL: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if (rc != Q931E_NO_ERROR) - return rc; - break; - default: - return Q931E_ILLEGAL_IE; - break; - } - } - - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pmes_SetupAck - -*****************************************************************************/ -L3INT Q931Pmes_SetupAck(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; - L3INT rc = Q931E_NO_ERROR; - L3INT Octet = 0; - - /* Q931 Message Header */ - Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); - - /* Channel Identification */ - if (Q931IsIEPresent(pMes->ChanID)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CHANNEL_IDENTIFICATION](pTrunk, Q931GetIEPtr(pMes->ChanID,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Progress indicator */ - if (Q931IsIEPresent(pMes->ProgInd)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_PROGRESS_INDICATOR](pTrunk, Q931GetIEPtr(pMes->ProgInd,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Display */ - if (Q931IsIEPresent(pMes->Display)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Signal */ - if (Q931IsIEPresent(pMes->Signal)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_SIGNAL](pTrunk, Q931GetIEPtr(pMes->Signal,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - *OSize = Octet; - return rc; -} - -/***************************************************************************** - - Function: Q931Umes_Status - -*****************************************************************************/ -L3INT Q931Umes_Status(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3INT OOff = 0; - L3INT rc = Q931E_NO_ERROR; - - while (IOff < Size) { - switch (IBuf[IOff]) { - case Q931ie_CAUSE: - case Q931ie_CALL_STATE: - case Q931ie_DISPLAY: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if (rc != Q931E_NO_ERROR) - return rc; - break; - default: - return Q931E_ILLEGAL_IE; - break; - } - } - - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} - - -/***************************************************************************** - - Function: Q931Pmes_Status - -*****************************************************************************/ -L3INT Q931Pmes_Status(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; - L3INT rc = Q931E_NO_ERROR; - L3INT Octet = 0; - - /* Q931 Message Header */ - Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); - - /* Cause */ - if (Q931IsIEPresent(pMes->Cause)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CAUSE](pTrunk, Q931GetIEPtr(pMes->Cause,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Call State */ - if (Q931IsIEPresent(pMes->CallState)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALL_STATE](pTrunk, Q931GetIEPtr(pMes->CallState,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Display */ - if (Q931IsIEPresent(pMes->Display)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - *OSize = Octet; - return rc; -} - -/***************************************************************************** - - Function: Q931Umes_StatusEnquiry - -*****************************************************************************/ -L3INT Q931Umes_StatusEnquiry(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3INT OOff = 0; - L3INT rc = Q931E_NO_ERROR; - - while (IOff < Size) { - switch (IBuf[IOff]) { - case Q931ie_DISPLAY: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if (rc != Q931E_NO_ERROR) - return rc; - break; - default: - return Q931E_ILLEGAL_IE; - break; - } - } - - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pmes_StatusEnquiry - -*****************************************************************************/ -L3INT Q931Pmes_StatusEnquiry(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; - L3INT rc = Q931E_NO_ERROR; - L3INT Octet = 0; - - /* Q931 Message Header */ - Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); - - /* Display */ - if (Q931IsIEPresent(pMes->Display)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - *OSize = Octet; - - return rc; -} - -/***************************************************************************** - - Function: Q931Umes_Suspend - -*****************************************************************************/ -L3INT Q931Umes_Suspend(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3INT OOff = 0; - L3INT rc = Q931E_NO_ERROR; - - while (IOff < Size) { - switch (IBuf[IOff]) { - case Q931ie_CALL_IDENTITY: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if (rc != Q931E_NO_ERROR) - return rc; - break; - default: - return Q931E_ILLEGAL_IE; - break; - } - } - - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pmes_Suspend - -*****************************************************************************/ -L3INT Q931Pmes_Suspend(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; - L3INT rc = Q931E_NO_ERROR; - L3INT Octet = 0; - - /* Q931 Message Header */ - Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); - - /* Call Identity */ - if (Q931IsIEPresent(pMes->CallID)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALL_IDENTITY](pTrunk, Q931GetIEPtr(pMes->CallID,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - *OSize = Octet; - return rc; -} - -/***************************************************************************** - - Function: Q931Umes_SuspendAck - -*****************************************************************************/ -L3INT Q931Umes_SuspendAck(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3INT OOff = 0; - L3INT rc = Q931E_NO_ERROR; - - while (IOff < Size) { - switch (IBuf[IOff]) { - case Q931ie_DISPLAY: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if (rc != Q931E_NO_ERROR) - return rc; - break; - default: - return Q931E_ILLEGAL_IE; - break; - } - } - - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pmes_SuspendAck - -*****************************************************************************/ -L3INT Q931Pmes_SuspendAck(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; - L3INT rc = Q931E_NO_ERROR; - L3INT Octet = 0; - - /* Q931 Message Header */ - Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); - - /* Display */ - if (Q931IsIEPresent(pMes->Display)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - *OSize = Octet; - return rc; -} - -/***************************************************************************** - - Function: Q931Umes_SuspendReject - -*****************************************************************************/ -L3INT Q931Umes_SuspendReject(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3INT OOff = 0; - L3INT rc = Q931E_NO_ERROR; - - while (IOff < Size) { - switch (IBuf[IOff]) { - case Q931ie_CAUSE: - case Q931ie_DISPLAY: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if (rc != Q931E_NO_ERROR) - return rc; - break; - default: - return Q931E_ILLEGAL_IE; - break; - } - } - - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pmes_SuspendReject - -*****************************************************************************/ -L3INT Q931Pmes_SuspendReject(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; - L3INT rc = Q931E_NO_ERROR; - L3INT Octet = 0; - - /* Q931 Message Header */ - Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); - - /* Cause */ - if (Q931IsIEPresent(pMes->Cause)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CAUSE](pTrunk, Q931GetIEPtr(pMes->Cause,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Display */ - if (Q931IsIEPresent(pMes->Display)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - *OSize = Octet; - return rc; -} - -/***************************************************************************** - - Function: Q931Umes_UserInformation - -*****************************************************************************/ -L3INT Q931Umes_UserInformation(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT I, L3INT O) -{ - L3BOOL RetCode = L3FALSE; - - NoWarning(mes); - NoWarning(IBuf); - - return RetCode; -} - -/***************************************************************************** - - Function: Q931Pmes_UserInformation - -*****************************************************************************/ -L3INT Q931Pmes_UserInformation(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - L3BOOL RetCode = L3FALSE; - - NoWarning(OBuf); - NoWarning(IBuf); - - *OSize = 0; - - return RetCode; -} - -/***************************************************************************** - - Function: Q931Umes_Service - -*****************************************************************************/ -L3INT Q931Umes_Service(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3INT OOff = 0; - L3INT rc = Q931E_NO_ERROR; - - while (IOff < Size) { - switch (IBuf[IOff]) { - case Q931ie_CHANNEL_IDENTIFICATION: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if (rc != Q931E_NO_ERROR) - return rc; - break; - case Q931ie_CHANGE_STATUS: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if (rc != Q931E_NO_ERROR) - return rc; - break; - default: - return Q931E_ILLEGAL_IE; - break; - } - } - - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pmes_Service - -*****************************************************************************/ -L3INT Q931Pmes_Service(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; - L3INT rc = Q931E_NO_ERROR; - L3INT Octet = 0; - - /* Q931 Message Header */ - Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); - - /* Display */ - if (Q931IsIEPresent(pMes->ChanID)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CHANNEL_IDENTIFICATION](pTrunk, Q931GetIEPtr(pMes->ChanID,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - if (Q931IsIEPresent(pMes->ChangeStatus)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CHANGE_STATUS](pTrunk, Q931GetIEPtr(pMes->ChangeStatus,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - *OSize = Octet; - return rc; -} - -/***************************************************************************** - - Function: Q931Umes_ServiceAck - -*****************************************************************************/ -L3INT Q931Umes_ServiceAck(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3INT OOff = 0; - L3INT rc = Q931E_NO_ERROR; - - while (IOff < Size) { - switch (IBuf[IOff]) { - case Q931ie_CHANNEL_IDENTIFICATION: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if (rc != Q931E_NO_ERROR) - return rc; - break; - case Q931ie_CHANGE_STATUS: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if (rc != Q931E_NO_ERROR) - return rc; - break; - default: - return Q931E_ILLEGAL_IE; - break; - } - } - - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pmes_ServiceAck - -*****************************************************************************/ -L3INT Q931Pmes_ServiceAck(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; - L3INT rc = Q931E_NO_ERROR; - L3INT Octet = 0; - - /* Q931 Message Header */ - Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); - - if (Q931IsIEPresent(pMes->ChangeStatus)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CHANGE_STATUS](pTrunk, Q931GetIEPtr(pMes->ChangeStatus,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - if (Q931IsIEPresent(pMes->ChanID)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CHANNEL_IDENTIFICATION](pTrunk, Q931GetIEPtr(pMes->ChanID,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - *OSize = Octet; - return rc; -} diff --git a/libs/freetdm/src/isdn/Q932mes.c b/libs/freetdm/src/isdn/Q932mes.c deleted file mode 100644 index 574499a241..0000000000 --- a/libs/freetdm/src/isdn/Q932mes.c +++ /dev/null @@ -1,286 +0,0 @@ -/***************************************************************************** - - FileName: Q932mes.c - - Contents: Q.932 Message Encoders/Decoders - - License/Copyright: - - Copyright (c) 2007, Jan Vidar Berger, Case Labs, Ltd. All rights reserved. - email:janvb@caselaboratories.com - - 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 Case Labs, Ltd 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT OWNER OR CONTRIBUTORS 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 SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*****************************************************************************/ - -#include "Q931.h" - -/***************************************************************************** - - Function: Q932Umes_Facility - -*****************************************************************************/ - -L3INT Q932Umes_Facility(Q931_TrunkInfo_t *pTrunk,L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3INT OOff = 0; - - /* TODO */ - - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pmes_Facility - -*****************************************************************************/ -L3INT Q932Pmes_Facility(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - L3BOOL RetCode = L3FALSE; - - NoWarning(OBuf); - NoWarning(IBuf); - - return RetCode; -} - -/***************************************************************************** - - Function: Q932Umes_Hold - -*****************************************************************************/ - -L3INT Q932Umes_Hold(Q931_TrunkInfo_t *pTrunk,L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3INT OOff = 0; - - /* TODO */ - - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pmes_Hold - -*****************************************************************************/ -L3INT Q932Pmes_Hold(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - L3BOOL RetCode = L3FALSE; - - NoWarning(OBuf); - NoWarning(IBuf); - - return RetCode; -} - -/***************************************************************************** - - Function: Q932Umes_HoldAck - -*****************************************************************************/ - -L3INT Q932Umes_HoldAck(Q931_TrunkInfo_t *pTrunk,L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3INT OOff = 0; - - /* TODO */ - - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pmes_HoldAck - -*****************************************************************************/ -L3INT Q932Pmes_HoldAck(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - L3BOOL RetCode = L3FALSE; - - NoWarning(OBuf); - NoWarning(IBuf); - - return RetCode; -} - -/***************************************************************************** - - Function: Q932Umes_HoldReject - -*****************************************************************************/ - -L3INT Q932Umes_HoldReject(Q931_TrunkInfo_t *pTrunk,L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3INT OOff = 0; - - /* TODO */ - - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pmes_HoldReject - -*****************************************************************************/ -L3INT Q932Pmes_HoldReject(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - L3BOOL RetCode = L3FALSE; - - NoWarning(OBuf); - NoWarning(IBuf); - - return RetCode; -} - -/***************************************************************************** - - Function: Q932Umes_Register - -*****************************************************************************/ - -L3INT Q932Umes_Register(Q931_TrunkInfo_t *pTrunk,L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3INT OOff = 0; - - /* TODO */ - - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pmes_Register - -*****************************************************************************/ -L3INT Q932Pmes_Register(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - L3BOOL RetCode = L3FALSE; - - NoWarning(OBuf); - NoWarning(IBuf); - - return RetCode; -} - -/***************************************************************************** - - Function: Q932Umes_Retrieve - -*****************************************************************************/ - -L3INT Q932Umes_Retrieve(Q931_TrunkInfo_t *pTrunk,L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3INT OOff = 0; - - /* TODO */ - - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pmes_Retrieve - -*****************************************************************************/ -L3INT Q932Pmes_Retrieve(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - L3BOOL RetCode = L3FALSE; - - NoWarning(OBuf); - NoWarning(IBuf); - - return RetCode; -} - -/***************************************************************************** - - Function: Q932Umes_RetrieveAck - -*****************************************************************************/ - -L3INT Q932Umes_RetrieveAck(Q931_TrunkInfo_t *pTrunk,L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3INT OOff = 0; - - /* TODO */ - - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pmes_RetrieveAck - -*****************************************************************************/ -L3INT Q932Pmes_RetrieveAck(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - L3BOOL RetCode = L3FALSE; - - NoWarning(OBuf); - NoWarning(IBuf); - - return RetCode; -} - -/***************************************************************************** - - Function: Q932Umes_RetrieveReject - -*****************************************************************************/ - -L3INT Q932Umes_RetrieveReject(Q931_TrunkInfo_t *pTrunk,L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3INT OOff = 0; - - /* TODO */ - - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pmes_RetrieveReject - -*****************************************************************************/ -L3INT Q932Pmes_RetrieveReject(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - L3BOOL RetCode = L3FALSE; - - NoWarning(OBuf); - NoWarning(IBuf); - - return RetCode; -} diff --git a/libs/freetdm/src/isdn/include/5ESS.h b/libs/freetdm/src/isdn/include/5ESS.h deleted file mode 100644 index 882b257395..0000000000 --- a/libs/freetdm/src/isdn/include/5ESS.h +++ /dev/null @@ -1,103 +0,0 @@ -/****************************************************************************** - - FileName: 5ESS.h - - Contents: Header and definition for the AT&T 5ESS ISDN dialect. The - header contains the following parts: - - - Definition of codes - - Definition of information elements (5ESSie_). - - Definition of messages (5ESSmes_). - - Function prototypes. - - Description: The AT&T 5ESS ISDN dialect here covers ???? - - Related Files: 5ESS.h AT&T 5ESS ISDN Definitions - 5ESSie.c AT&T 5ESS ISDN IE encoders/coders (not extant yet) - See Q931ie.c for IE encoders/coders - 5ESSStateTE.c AT&T 5ESS ISDN TE State Engine - 5ESSStateNT.c AT&T 5ESS ISDN NT State Engine - - License/Copyright: - - Copyright (c) 2007, Jan Vidar Berger, Case Labs, Ltd. All rights reserved. - email:janvb@caselaboratories.com - - Copyright (c) 2007, Michael Jerris. All rights reserved. - email:mike@jerris.com - - Copyright (c) 2007, Michael S. Collins, All rights reserved. - email:mcollins@fcnetwork.com - - 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 Case Labs, Ltd 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT OWNER OR CONTRIBUTORS 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 SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -******************************************************************************/ - -#ifndef _5ESS_NL -#define _5ESS_NL - -#include "Q931.h" - -/***************************************************************************** - - Q.931 Message codes - Only 5ESS specific message and ie types - here the rest are inherited from Q931.h - -*****************************************************************************/ - - -/***************************************************************************** - - Q.931 Message Pack/Unpack functions. Implemented in 5ESSmes.c - Note: Because C variables may not begin with numeric digit, all identifiers - are prefixed with "ATT5ESS" instead of a bare "5ESS" - -*****************************************************************************/ -L3INT ATT5ESSUmes_Setup(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT IOff, L3INT Size); -L3INT ATT5ESSPmes_Setup(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); -L3INT ATT5ESSUmes_SetupAck(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT IOff, L3INT Size); -L3INT ATT5ESSPmes_SetupAck(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); - -L3INT ATT5ESSUmes_0x07(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size); -L3INT ATT5ESSPmes_0x07(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); -L3INT ATT5ESSUmes_0x0f(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size); -L3INT ATT5ESSPmes_0x0f(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); - - - -/***************************************************************************** - - Q.931 Process Function Prototyping. Implemented in 5ESSStateTE.c - -*****************************************************************************/ -L3INT ATT5ESSProc0x0fTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom); -L3INT ATT5ESSProc0x07TE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom); - - -void ATT5ESSCreateTE(L3UCHAR i); -void ATT5ESSCreateNT(L3UCHAR i); - -#endif /* _5ESS_NL */ diff --git a/libs/freetdm/src/isdn/include/DMS.h b/libs/freetdm/src/isdn/include/DMS.h deleted file mode 100644 index 605a61aa6e..0000000000 --- a/libs/freetdm/src/isdn/include/DMS.h +++ /dev/null @@ -1,91 +0,0 @@ -/****************************************************************************** - - FileName: national.h - - Contents: Header and definition for the National ISDN dialect. The - header contents the following parts: - - Definition of codes - - Definition of information elements (nationalie_). - - Definition of messages (nationalmes_). - - Function prototypes. - - Description: The National ISDN dialect here covers ???? - - Related Files: national.h National ISDN Definitions - nationalie.c National ISDN IE encoders/coders - nationalStateTE.c National ISDN TE State Engine - nationalStateNT.c National ISDN NT State Engine - - License/Copyright: - - Copyright (c) 2007, Jan Vidar Berger, Case Labs, Ltd. All rights reserved. - email:janvb@caselaboratories.com - - Copyright (c) 2007, Michael Jerris. All rights reserved. - email:mike@jerris.com - - 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 Case Labs, Ltd 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT OWNER OR CONTRIBUTORS 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 SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -******************************************************************************/ - -#ifndef _DMS_NL -#define _DMS_NL - -#include "Q931.h" - -/***************************************************************************** - - Q.931 Message codes - Only National specific message and ie types - here the rest are inherited from national.h - -*****************************************************************************/ - - -/***************************************************************************** - - Q.931 Message Pack/Unpack functions. Implemented in nationalmes.c - -*****************************************************************************/ -L3INT DMSUmes_Setup(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT IOff, L3INT Size); -L3INT DMSPmes_Setup(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); -L3INT DMSUmes_0x07(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size); -L3INT DMSPmes_0x07(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); -L3INT DMSUmes_0x0f(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size); -L3INT DMSPmes_0x0f(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); - -/***************************************************************************** - - Q.931 Process Function Prototyping. Implemented in nationalStateTE.c - -*****************************************************************************/ - -L3INT DMSProc0x0fTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom); -L3INT DMSProc0x07TE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom); - -void DMSCreateTE(L3UCHAR i); -void DMSCreateNT(L3UCHAR i); - -#endif /* _DMS_NL */ diff --git a/libs/freetdm/src/isdn/include/Q921.h b/libs/freetdm/src/isdn/include/Q921.h deleted file mode 100644 index cb21a157ea..0000000000 --- a/libs/freetdm/src/isdn/include/Q921.h +++ /dev/null @@ -1,227 +0,0 @@ -/***************************************************************************** - - FileName: q921.h - - Description: Contains headers of a Q.921 protocol. - - Note: This header file is the only include file that should be - acessed by users of the Q.921 stack. - - Interface: The Q.921 stack contains 2 layers. - - - One interface layer. - - One driver layer. - - The interface layer contains the interface functions required - for a layer 2 stack to be able to send and receive messages. - - The driver layer will simply feed bytes into the ship as - required and queue messages received out from the ship. - - Q921TimeTick The Q.921 like any other blackbox - modules contains no thread by it's own - and must therefore be called regularly - by an external 'thread' to do maintenance - etc. - - Q921Rx32 Receive message from layer 3. Called by - the layer 3 stack to send a message. - - - NOTE: The following are not yet implemented - - OnQ921Error Function called every if an error is - detected. - - OnQ921Log Function called if logging is active. - - - Maintenance/Configuration interface - Logging - DL_ message passing to layer 3 - Timers - Api commands to tell 921 to stop and start for a trunk - - Created: 27.dec.2000/JVB - - License/Copyright: - - Copyright (c) 2007, Jan Vidar Berger, Case Labs, Ltd. All rights reserved. - email:janvb@caselaboratories.com - - 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 Case Labs, Ltd 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT OWNER OR CONTRIBUTORS 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 SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - -*****************************************************************************/ - -/**************************************************************************** - * Changes: - * - * - June,July 2008: Stefan Knoblich : - * Add PTMP TEI management - * Add timers - * Add retransmit counters - * Add logging - * Various cleanups - * - ****************************************************************************/ - -#ifndef _Q921 -#define _Q921 - -#define Q921MAXHDLCSPACE 3000 -#define L2UCHAR unsigned char /* Min 8 bit */ -#define L2USHORT unsigned short /* 16 bit */ -#define L2INT int /* Min 16 bit signed */ -#define L2ULONG unsigned long /* Min 32 bit */ -#define L2TRUNK Q921Data_t * - -#define Q921_TEI_BCAST 127 -#define Q921_TEI_MAX Q921_TEI_BCAST - -#define Q921_TEI_DYN_MIN 64 -#define Q921_TEI_DYN_MAX 126 - - -typedef enum /* Network/User Mode */ -{ - Q921_TE=0, /* 0 : User Mode */ - Q921_NT=1 /* 1 : Network Mode */ -} Q921NetUser_t; - -typedef enum /* Type of connection */ -{ - Q921_PTP=0, /* 0 : Point-To-Point */ - Q921_PTMP=1 /* 1 : Point-To-Multipoint */ -} Q921NetType_t; - -typedef enum -{ - Q921_LOG_NONE = -1, - Q921_LOG_EMERG = 0, - Q921_LOG_ALERT, - Q921_LOG_CRIT, - Q921_LOG_ERROR, - Q921_LOG_WARNING, - Q921_LOG_NOTICE, - Q921_LOG_INFO, - Q921_LOG_DEBUG -} Q921LogLevel_t; - - -/* - * Messages for L2 <-> L3 communication - */ -typedef enum { - Q921_DL_ESTABLISH = 0, - Q921_DL_ESTABLISH_CONFIRM, - Q921_DL_RELEASE, - Q921_DL_RELEASE_CONFIRM, - Q921_DL_DATA, - Q921_DL_UNIT_DATA -} Q921DLMsg_t; - -typedef int (*Q921Tx21CB_t) (void *, L2UCHAR *, L2INT); -typedef int (*Q921Tx23CB_t) (void *, Q921DLMsg_t ind, L2UCHAR tei, L2UCHAR *, L2INT); -typedef int (*Q921LogCB_t) (void *, Q921LogLevel_t, char *, L2INT); - -struct Q921_Link; - -typedef struct Q921Data -{ - L2INT initialized; - - L2UCHAR sapi; /*!< User assigned SAPI */ - L2UCHAR tei; /*!< User assigned TEI value */ - - L2INT Q921HeaderSpace; - Q921NetUser_t NetUser; - Q921NetType_t NetType; - - struct Q921_Link *context; /*!< per-TEI / link context space */ - - /* timers */ - L2ULONG T202; /*!< PTMP TE mode TEI retransmit timer */ - L2ULONG T200Timeout; - L2ULONG T201Timeout; - L2ULONG T202Timeout; - L2ULONG T203Timeout; - - L2ULONG TM01Timeout; - - /* counters */ - L2ULONG N200Limit; /*!< max retransmit */ - - L2ULONG N202; /*!< PTMP TE mode retransmit counter */ - L2ULONG N202Limit; /*!< PTMP TE mode max retransmit */ - - L2ULONG N201Limit; /*!< max number of octets */ - L2ULONG k; /*!< max number of unacknowledged I frames */ - - /* callbacks and callback data pointers */ - Q921Tx21CB_t Q921Tx21Proc; - Q921Tx23CB_t Q921Tx23Proc; - void *PrivateData21; - void *PrivateData23; - - /* logging */ - Q921LogLevel_t loglevel; /*!< trunk loglevel */ - Q921LogCB_t Q921LogProc; /*!< log callback procedure */ - void *PrivateDataLog; /*!< private data pointer for log proc */ - - /* tei mgmt */ - L2UCHAR tei_map[Q921_TEI_MAX]; /*!< */ - - L2UCHAR HDLCInQueue[Q921MAXHDLCSPACE]; /*!< HDLC input queue */ -} Q921Data_t; - -/* - * Public functions - */ -int Q921_InitTrunk(L2TRUNK trunk, - L2UCHAR sapi, - L2UCHAR tei, - Q921NetUser_t NetUser, - Q921NetType_t NetType, - L2INT hsize, - Q921Tx21CB_t cb21, - Q921Tx23CB_t cb23, - void *priv21, - void *priv23); -int Q921Start(L2TRUNK trunk); -int Q921Stop(L2TRUNK trunk); - -void Q921SetLogCB(L2TRUNK trunk, Q921LogCB_t func, void *priv); -void Q921SetLogLevel(L2TRUNK trunk, Q921LogLevel_t level); - -int Q921Rx12(L2TRUNK trunk); -int Q921Rx32(L2TRUNK trunk, Q921DLMsg_t ind, L2UCHAR tei, L2UCHAR * Mes, L2INT Size); - -int Q921QueueHDLCFrame(L2TRUNK trunk, L2UCHAR *b, L2INT size); - -void Q921SetGetTimeCB(L2ULONG (*callback)(void)); -void Q921TimerTick(L2TRUNK trunk); - -#endif diff --git a/libs/freetdm/src/isdn/include/Q921priv.h b/libs/freetdm/src/isdn/include/Q921priv.h deleted file mode 100644 index d2d838c399..0000000000 --- a/libs/freetdm/src/isdn/include/Q921priv.h +++ /dev/null @@ -1,321 +0,0 @@ -/***************************************************************************** - - FileName: Q921priv.h - - Description: Private declarations - - Created: 08.Aug.2008/STKN - - License/Copyright: - - Copyright (c) 2007, Jan Vidar Berger, Case Labs, Ltd. All rights reserved. - email:janvb@caselaboratories.com - - Copyright (c) 2008, Stefan Knoblich, axsentis GmbH. All rights reserved. - email:s.knoblich@axsentis.de - - 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 Case Labs, Ltd 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT OWNER OR CONTRIBUTORS 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 SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - -*****************************************************************************/ -#ifndef _Q921_PRIV_H_ -#define _Q921_PRIV_H_ - -#ifdef _MSC_VER -#ifndef __inline__ -#define __inline__ __inline -#endif -#if (_MSC_VER >= 1400) /* VC8+ */ -#ifndef _CRT_SECURE_NO_DEPRECATE -#define _CRT_SECURE_NO_DEPRECATE -#endif -#ifndef _CRT_NONSTDC_NO_DEPRECATE -#define _CRT_NONSTDC_NO_DEPRECATE -#endif -#endif -#ifndef strcasecmp -#define strcasecmp(s1, s2) _stricmp(s1, s2) -#endif -#ifndef strncasecmp -#define strncasecmp(s1, s2, n) _strnicmp(s1, s2, n) -#endif -#ifndef snprintf -#define snprintf _snprintf -#endif -#endif - -typedef enum /* Q.921 States */ -{ - Q921_STATE_STOPPED = 0, /* Trunk stopped */ - Q921_STATE_TEI_UNASSIGNED = 1, /* TEI unassigned */ - Q921_STATE_TEI_AWAITING, /* Assign awaiting TEI */ - Q921_STATE_TEI_ESTABLISH, /* Establish awaiting TEI */ - Q921_STATE_TEI_ASSIGNED, /* TEI assigned */ - Q921_STATE_AWAITING_ESTABLISHMENT, /* Awaiting establishment */ - Q921_STATE_AWAITING_RELEASE, /* Awaiting release */ - Q921_STATE_MULTIPLE_FRAME_ESTABLISHED, /* Multiple frame established */ - Q921_STATE_TIMER_RECOVERY /* Timer recovery */ -} Q921State_t; - -/* - * Flags - */ -enum Q921_Flags { - Q921_FLAG_L3_INITIATED = (1 << 0), - - Q921_FLAG_UI_FRAME_QUEUED = (1 << 1), - Q921_FLAG_I_FRAME_QUEUED = (1 << 2), - - Q921_FLAG_ACK_PENDING = (1 << 3), - Q921_FLAG_REJECT = (1 << 4), - - Q921_FLAG_RECV_BUSY = (1 << 5), - Q921_FLAG_PEER_RECV_BUSY = (1 << 6) -}; - -#define Q921_SET_FLAG(x, f) ((x)->flags |= f) -#define Q921_CHECK_FLAG(x, f) ((x)->flags & f) -#define Q921_CLEAR_FLAG(x, f) ((x)->flags &= ~f) - - -/* - * dynamic TEI handling - */ -#define Q921_SAPI_TEI 63 /* SAPI for all TEI Messages */ -#define Q921_LAYER_ENT_ID_TEI 0x0f /* UN Layer Management Entity ID for TEI Mgmt */ -#define Q921_LAYER_ENT_ID_Q931 0x08 /* Q.931 Layer Management Entity ID */ - - -typedef enum { - Q921_TEI_ID_REQUEST = 1, - Q921_TEI_ID_ASSIGNED, - Q921_TEI_ID_DENIED, - Q921_TEI_ID_CHECKREQ, - Q921_TEI_ID_CHECKRESP, - Q921_TEI_ID_REMOVE, - Q921_TEI_ID_VERIFY -} Q921TeiMessageType_t; - - -/** - * Per-Datalink context - */ -struct Q921_Link { - L2UCHAR tei; /*!< This endpoint's TEI */ - - L2UCHAR va; - L2UCHAR vs; - L2UCHAR vr; - - L2INT flags; - Q921State_t state; - - L2ULONG N202; /*!< PTMP TE mode retransmit counter */ - L2ULONG N200; /*!< retransmit counter (per-TEI in PTMP NT mode) */ - - L2ULONG TM01; /*!< Datalink inactivity disconnect timer */ - - L2ULONG T200; - L2ULONG T201; /*!< PTMP NT mode timer */ - L2ULONG T203; - - L2USHORT ri; /*!< random id for TEI request mgmt */ - - /* I + UI Frame queue */ - L2UCHAR UIFrameQueue[Q921MAXHDLCSPACE]; - L2UCHAR IFrameQueue[Q921MAXHDLCSPACE]; - L2UCHAR IFrameResendQueue[Q921MAXHDLCSPACE]; -}; - - -#define Q921_LINK_CONTEXT(tr, tei) \ - (Q921_IS_PTMP_NT(tr) && tei != Q921_TEI_BCAST) ? ((struct Q921_Link *)&(tr)->context[tei]) : (tr)->context - -#define Q921_TRUNK_CONTEXT(tr) \ - (tr)->context - -#define Q921_LOGBUFSIZE 2000 -#define INITIALIZED_MAGIC 42 - -/* - * Helper macros - */ -#define Q921_INC_COUNTER(x) (x = (x + 1) % 128) -#define Q921_DEC_COUNTER(x) (x = (x) ? (x - 1) : 127) - -#define Q921_UFRAME_HEADER_SIZE 3 -#define Q921_UFRAME_DATA_OFFSET(tr) ((tr)->Q921HeaderSpace + Q921_UFRAME_HEADER_SIZE) - -#define Q921_SFRAME_HEADER_SIZE 4 -#define Q921_SFRAME_DATA_OFFSET(tr) ((tr)->Q921HeaderSpace + Q921_SFRAME_HEADER_SIZE) - -#define Q921_IFRAME_HEADER_SIZE 4 -#define Q921_IFRAME_DATA_OFFSET(tr) ((tr)->Q921HeaderSpace + Q921_IFRAME_HEADER_SIZE) - -#define Q921_IS_TE(x) ((x)->NetUser == Q921_TE) -#define Q921_IS_NT(x) ((x)->NetUser == Q921_NT) - -#define Q921_IS_STOPPED(tr) ((tr)->state == Q921_STATE_STOPPED) - -/* TODO: rework this one */ -#define Q921_IS_READY(tr) ((tr)->state >= Q921_STATE_TEI_ASSIGNED) - -#define Q921_IS_PTMP(x) ((x)->NetType == Q921_PTMP) -#define Q921_IS_PTMP_TE(x) ((x)->NetType == Q921_PTMP && (x)->NetUser == Q921_TE) -#define Q921_IS_PTMP_NT(x) ((x)->NetType == Q921_PTMP && (x)->NetUser == Q921_NT) - -#define Q921_IS_PTP(x) ((x)->NetType == Q921_PTP) -#define Q921_IS_PTP_TE(x) ((x)->NetType == Q921_PTP && (x)->NetUser == Q921_TE) -#define Q921_IS_PTP_NT(x) ((x)->NetType == Q921_PTP && (x)->NetUser == Q921_NT) - -/* Make life a little easier */ -#define Q921_COMMAND(x) ((x)->NetUser == Q921_TE ? 0 : 1) -#define Q921_RESPONSE(x) ((x)->NetUser == Q921_TE ? 1 : 0) - -#define Q921_IS_COMMAND(tr, x) ((x) == (Q921_IS_TE(tr) ? 1 : 0)) -#define Q921_IS_RESPONSE(tr, x) ((x) == (Q921_IS_TE(tr) ? 0 : 1)) - - -/******************************************************************************* - * Private functions - *******************************************************************************/ - -/* - * L1 / L2 Interface - */ -static int Q921Tx21Proc(L2TRUNK trunk, L2UCHAR *Msg, L2INT size); -static int Q921Tx23Proc(L2TRUNK trunk, Q921DLMsg_t ind, L2UCHAR tei, L2UCHAR *Msg, L2INT size); - - -/* - * Timers - */ -static L2ULONG Q921GetTime(void); - -static void Q921T200TimerStart(L2TRUNK trunk, L2UCHAR tei); -static void Q921T200TimerStop(L2TRUNK trunk, L2UCHAR tei); -static void Q921T200TimerReset(L2TRUNK trunk, L2UCHAR tei); -static void Q921T200TimerExpire(L2TRUNK trunk, L2UCHAR tei); - -static void Q921T201TimerStart(L2TRUNK trunk, L2UCHAR tei); -static void Q921T201TimerStop(L2TRUNK trunk, L2UCHAR tei); -/* static void Q921T201TimerReset(L2TRUNK trunk, L2UCHAR tei); - Unused for now */ -static void Q921T201TimerExpire(L2TRUNK trunk, L2UCHAR tei); - -static void Q921T202TimerStart(L2TRUNK trunk); -static void Q921T202TimerStop(L2TRUNK trunk); -static void Q921T202TimerReset(L2TRUNK trunk); -static void Q921T202TimerExpire(L2TRUNK trunk); - -static void Q921T203TimerStart(L2TRUNK trunk, L2UCHAR tei); -static void Q921T203TimerStop(L2TRUNK trunk, L2UCHAR tei); -static void Q921T203TimerReset(L2TRUNK trunk, L2UCHAR tei); -static void Q921T203TimerExpire(L2TRUNK trunk, L2UCHAR tei); - -static void Q921TM01TimerStart(L2TRUNK trunk, L2UCHAR tei); -/* static void Q921TM01TimerStop(L2TRUNK trunk, L2UCHAR tei); - Unused for now */ -static void Q921TM01TimerReset(L2TRUNK trunk, L2UCHAR tei); -/* static void Q921TM01TimerExpire(L2TRUNK trunk, L2UCHAR tei); - Unused for now */ - -/* - * Frame encoding - */ -static int Q921SendS(L2TRUNK trunk, L2UCHAR Sapi, char cr, L2UCHAR Tei, char pf, L2UCHAR sv, L2UCHAR *mes, L2INT size); -static int Q921SendU(L2TRUNK trunk, L2UCHAR Sapi, char cr, L2UCHAR Tei, char pf, L2UCHAR m, L2UCHAR *mes, L2INT size); - -static int Q921SendRNR(L2TRUNK trunk, int Sapi, int cr, int Tei, int pf); -static int Q921SendREJ(L2TRUNK trunk, int Sapi, int cr, int Tei, int pf); -static int Q921SendSABME(L2TRUNK trunk, int Sapi, int cr, int Tei, int pf); -static int Q921SendDM(L2TRUNK trunk, int Sapi, int cr, int Tei, int pf); -static int Q921SendDISC(L2TRUNK trunk, int Sapi, int cr, int Tei, int pf); -static int Q921SendUA(L2TRUNK trunk, int Sapi, int cr, int Tei, int pf); -static int Q921SendUN(L2TRUNK trunk, int Sapi, int cr, int Tei, int pf, L2UCHAR *mes, L2INT size); -static int Q921SendRR(L2TRUNK trunk, int Sapi, int cr, int Tei, int pf); - -/* - * Frame decoding - */ -static int Q921ProcIFrame(L2TRUNK trunk, L2UCHAR *mes, L2INT size); -static int Q921ProcSFrame(L2TRUNK trunk, L2UCHAR *mes, L2INT size); -static int Q921ProcUFrame(L2TRUNK trunk, L2UCHAR *mes, L2INT size); - -static int Q921ProcSABME(L2TRUNK trunk, L2UCHAR *mes, L2INT size); -static int Q921ProcDM(L2TRUNK trunk, L2UCHAR *mes, L2INT size); -static int Q921ProcUA(L2TRUNK trunk, L2UCHAR *mes, L2INT size); -static int Q921ProcDISC(L2TRUNK trunk, L2UCHAR *mes, L2INT size); -static int Q921ProcRR(L2TRUNK trunk, L2UCHAR *mes, L2INT size); -static int Q921ProcRNR(L2TRUNK trunk, L2UCHAR *mes, L2INT size); -static int Q921ProcREJ(L2TRUNK trunk, L2UCHAR *mes, L2INT size); - - -/* - * (Common) procedures defined in the Q.921 SDL - */ -static int Q921SendEnquiry(L2TRUNK trunk, L2UCHAR tei); -static int Q921SendEnquiryResponse(L2TRUNK trunk, L2UCHAR tei); -static void Q921ResetExceptionConditions(L2TRUNK trunk, L2UCHAR tei); -static int Q921EstablishDataLink(L2TRUNK trunk, L2UCHAR tei); -static int Q921NrErrorRecovery(L2TRUNK trunk, L2UCHAR tei); -static int Q921InvokeRetransmission(L2TRUNK trunk, L2UCHAR tei, L2UCHAR nr); -static int Q921AcknowledgePending(L2TRUNK trunk, L2UCHAR tei); -/* -static int Q921SetReceiverBusy(L2TRUNK trunk); -static int Q921ClearReceiverBusy(L2TRUNK trunk); -*/ - -/* - * Queueing - */ -static int Q921SendQueuedIFrame(L2TRUNK trunk, L2UCHAR tei); -static int Q921EnqueueI(L2TRUNK trunk, L2UCHAR Sapi, char cr, L2UCHAR Tei, char pf, L2UCHAR *mes, L2INT size); - -/* - * TEI management - */ -static int Q921TeiSendAssignRequest(L2TRUNK trunk); -static int Q921TeiProcAssignResponse(L2TRUNK trunk, L2UCHAR *mes, L2INT size); -static int Q921TeiSendVerifyRequest(L2TRUNK trunk); -static int Q921TeiProcCheckRequest(L2TRUNK trunk, L2UCHAR *mes, L2INT size); -static int Q921TeiProcRemoveRequest(L2TRUNK trunk, L2UCHAR *mes, L2INT size); -static int Q921TeiProcAssignRequest(L2TRUNK trunk, L2UCHAR *mes, L2INT size); -static int Q921TeiProcCheckResponse(L2TRUNK trunk, L2UCHAR *mes, L2INT size); -static int Q921TeiProcVerifyRequest(L2TRUNK trunk, L2UCHAR *mes, L2INT size); -static int Q921TeiSendRemoveRequest(L2TRUNK trunk, L2UCHAR tei); -static int Q921TeiSendDenyResponse(L2TRUNK trunk, L2UCHAR tei, L2USHORT ri); -static int Q921TeiSendAssignedResponse(L2TRUNK trunk, L2UCHAR tei, L2USHORT ri); -static int Q921TeiSendCheckRequest(L2TRUNK trunk, L2UCHAR tei); - -/* - * Logging - */ -static int Q921Log(L2TRUNK trunk, Q921LogLevel_t level, const char *fmt, ...); -static int Q921LogMesg(L2TRUNK trunk, Q921LogLevel_t level, L2UCHAR received, L2UCHAR *mes, L2INT size, const char *fmt, ...); - -/* - * State handling - */ -static int Q921ChangeState(L2TRUNK trunk, Q921State_t state, L2UCHAR tei); - -#endif diff --git a/libs/freetdm/src/isdn/include/Q931.h b/libs/freetdm/src/isdn/include/Q931.h deleted file mode 100644 index 0dbafd9f11..0000000000 --- a/libs/freetdm/src/isdn/include/Q931.h +++ /dev/null @@ -1,1175 +0,0 @@ -/****************************************************************************** - - FileName: Q931.h - - Contents: Header and definition for the ITU-T Q.931 stack. The - header contents the following parts: - - - Definition of codes - - Definition of information elements (Q931ie_). - - Definition of messages (Q931mes_). - - Definitian of variables (var_). - - Function prototypes. - - Description: The Q.931 stack provided here covers ITU-T Q.931 w/Q.932 - supplementary services for both PRI, BRI and variants. - The stack is generic and designed to deal with variants as - needed. - - The stack uses the following interface functions: - - - Q931Initialize Initialize the Q.931 stack. - - Q931Rx23 Receive a message from layer 2 - - Q931Tx32 Send a message to layer 2 - - Q931Rx43 Receive a message from layer 4 or above. - - Q931Tx34 Send a message to layer 4 or above. - - Q931TimeTick Periodical timer processing. - - Q931ErrorProc Callback for stack error message. - - The protocol is a module with no external dependencies and - can easely be ported to any operating system like Windows, - Linux, rtos and others. - - Related Files: Q931.h Q.931 Definitions - Q931.c Q.931 Interface Functions. - Q931api.c Low level L4 API functions. - - Q932.h Q.932 Suplementary Services - Q932mes.c Q.932 encoders/coders - - Q931mes.c Q.931 Message encoders/coders - Q931ie.c Q.931 IE encoders/coders - Q931StateTE.c Generic Q.931 TE State Engine - Q931StateNT.c Generic Q.931 NT State Engine - - Design Note 1: For each variant please add separate files starting with - the variant short-name as follows: - - .h Spesific headers needed. - mes.c Message encoders/decores. - ie.c IE encoders/decoders. - StateTE.c TE side state engine. - StateNT.c NT side state engine. - - Design Note 2: The stack is deliberatly made non-threading. Use 1 - thread per Trunk, but lock access from the timertick - and rx, tx functions. And make sure the callbacks only - dump messages to a queue, no time-consuming processing - inside stack processing. - - All stack processing is async 'fire and forget', meaning - that there are not, and should not be any time-consuming - processing within the stack-time. The best way to thread - a stack is to use one single thread that signal 5 queues. - - - Incoming L2 queue. - - Incoming L4 queue. - - Outgoing L2 queue. - - Outgoing L4 queue. - - Error/Trace queue. - - Design Note 3: DSP optimization. The L3 (Rx23) can be called directly - from a HDLC receiver without usage of queues for optimized - processing. But keep in mind that Q.931 calls Tx34 or Tx32 - as part of receiving a message from Layer 2. - - License/Copyright: - - Copyright (c) 2007, Jan Vidar Berger, Case Labs, Ltd. All rights reserved. - email:janvb@caselaboratories.com - - 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 Case Labs, Ltd 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT OWNER OR CONTRIBUTORS 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 SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -******************************************************************************/ - -#ifndef _Q931_NL -#define _Q931_NL - -/* uncomment the #define below to add x.25 support to the Q.931 */ -/* #define Q931_X25_SUPPORT */ - -#include "stdio.h" - -#ifdef _MSC_VER -#pragma warning(disable:4100) -#ifndef strcasecmp -#define strcasecmp(s1, s2) _stricmp(s1, s2) -#endif -#endif -#include - - -/***************************************************************************** - - Enum helper macros - -*****************************************************************************/ -#define Q931_ENUM_NAMES(_NAME, _STRINGS) static const char * _NAME [] = { _STRINGS , NULL }; -#define Q931_STR2ENUM_P(_FUNC1, _FUNC2, _TYPE) _TYPE _FUNC1 (const char *name); const char * _FUNC2 (_TYPE type); -#define Q931_STR2ENUM(_FUNC1, _FUNC2, _TYPE, _STRINGS, _MAX) \ - _TYPE _FUNC1 (const char *name) \ - { \ - int i; \ - _TYPE t = _MAX ; \ - \ - for (i = 0; i < _MAX ; i++) { \ - if (!strcasecmp(name, _STRINGS[i])) { \ - t = (_TYPE) i; \ - break; \ - } \ - } \ - \ - return t; \ - } \ - const char * _FUNC2 (_TYPE type) \ - { \ - if (type > _MAX) { \ - type = _MAX; \ - } \ - return _STRINGS[(int)type]; \ - } \ - -/***************************************************************************** - - Error Codes - -*****************************************************************************/ -typedef enum { - Q931E_NO_ERROR = 0, - - Q931E_UNKNOWN_MESSAGE = -3001, - Q931E_ILLEGAL_IE = -3002, - Q931E_UNKNOWN_IE = -3003, - Q931E_BEARERCAP = -3004, - Q931E_HLCOMP = -3005, - Q931E_LLCOMP = -3006, - Q931E_INTERNAL = -3007, - Q931E_MISSING_CB = -3008, - Q931E_UNEXPECTED_MESSAGE = -3009, - Q931E_ILLEGAL_MESSAGE = -3010, - Q931E_TOMANYCALLS = -3011, - Q931E_INVALID_CRV = -3012, - Q931E_CALLID = -3013, - Q931E_CALLSTATE = -3014, - Q931E_CALLEDSUB = -3015, - Q931E_CALLEDNUM = -3016, - Q931E_CALLINGNUM = -3017, - Q931E_CALLINGSUB = -3018, - Q931E_CAUSE = -3019, - Q931E_CHANID = -3020, - Q931E_DATETIME = -3021, - Q931E_DISPLAY = -3022, - Q931E_KEYPADFAC = -3023, - Q931E_NETFAC = -3024, - Q931E_NOTIFIND = -3025, - Q931E_PROGIND = -3026, - Q931E_RESTARTIND = -3027, - Q931E_SEGMENT = -3028, - Q931E_SIGNAL = -3029, - Q931E_GENERIC_DIGITS = -3030 -} q931_error_t; - -/* The q931_error_t enum should be kept in sync with the q931_error_names array in Q931.c */ - -const char *q931_error_to_name(q931_error_t error); - -/***************************************************************************** - - Some speed optimization can be achieved by changing all variables to the - word size of your processor. A 32 bit processor has to do a lot of extra - work to read a packed 8 bit integer. Changing all fields to 32 bit integer - will result in usage of some extra space, but will speed up the stack. - - The stack has been designed to allow L3UCHAR etc. to be any size of 8 bit - or larger. - -*****************************************************************************/ - -#define L3UCHAR unsigned char /* Min 8 bit */ -#define L3USHORT unsigned short /* Min 16 bit unsigned */ -#define L3UINT unsigned int /* Min 16 bit unsigned */ -#define L3INT int /* Min 16 bit signed */ -#define L3ULONG unsigned long /* Min 32 bit */ -#define L3BOOL char /* Min 1 bit, valuse 0 & 1 only */ - -#define L3TRUE 1 -#define L3FALSE 0 - -/***************************************************************************** - - Global defines. - -*****************************************************************************/ - -typedef L3USHORT ie; /* Special data type to hold a dynamic */ - /* or optional information element as */ - /* part of a message struct. MSB = 1 */ - /* indicate that the ie is present, the */ - /* last 15 bits is an offset ( or the */ - /* value for single octet ) to the */ - /* struct holding the ie. Offset = 0 */ - /* is buf[1] etc. */ - /* ie == 0xffff indicates error */ - -/***************************************************************************** - - MAXTRUNKS sets how many physical trunks this system might have. This - number should be keept at a minimum since it will use global space. - - It is recommended that you leave MAXCHPERTRUNK as is - -*****************************************************************************/ - -#define Q931_LOGBUFSIZE 1024 /* size of logging buffer */ - -#define Q931L4BUF 1000 /* size of message buffer */ - -#define Q931L2BUF 300 /* size of message buffer */ - -#define Q931MAXTRUNKS 4 /* Total number of trunks that will be */ - /* processed by this instance of the */ - /* stack */ - -#define Q931MAXCHPERTRUNK 32 /* Number of channels per trunk. The */ - /* stack uses a static set of 32 */ - /* channels regardless if it is E1, T1 */ - /* or BRI that actually is used. */ - -#define Q931MAXCALLPERTRUNK (Q931MAXCHPERTRUNK * 2) - /* Number of max active CRV per trunk. */ - /* Q.931 can have more calls than there */ - /* are channels. */ - - -#define Q931_IS_BRI(x) ((x)->TrunkType == Q931_TrType_BRI || (x)->TrunkType == Q931_TrType_BRI_PTMP) -#define Q931_IS_PRI(x) (!Q931_IS_BRI(x)) - -#define Q931_IS_PTP(x) ((x)->TrunkType != Q931_TrType_BRI_PTMP) -#define Q931_IS_PTMP(X) ((x)->TrunkType == Q931_TrType_BRI_PTMP) - -#define Q931_BRI_MAX_CRV 127 -#define Q931_PRI_MAX_CRV 32767 - -/***************************************************************************** - - The following defines control the dialect switch tables and should only be - changed when a new dialect needs to be inserted into the stack. - - This stack uses an array of functions to know which function to call as - it receives a SETUP message etc. A new dialect can when choose to use - the proc etc. for standard Q.931 or insert a modified proc. - - This technique has also been used to distinguish between user and network - mode to make the code as easy to read and maintainable as possible. - - A message and IE index have been used to save space. These indexes allowes - the message or IE code to be used directly and will give back a new index - into the table. - -*****************************************************************************/ - -/* WARNING! Initialize Q931CreateDialectCB[] will NULL when increasing the */ -/* Q931MAXDLCT value to avoid Q931Initialize from crashing if one entry is */ -/* not used. */ -#define Q931MAXDLCT 8 /* Max dialects included in this */ - /* compile. User and Network count as */ - /* one dialect each. */ - -#define Q931MAXMES 128 /* Number of messages */ -#define Q931MAXIE 255 /* Number of IE */ -#define Q931MAXUSEDIE 50 /* Maximum number of ie types per Dialect */ -#define Q931MAXCODESETS 7 /* Maximum number of codests (by spec, 0-7) */ -#define Q931MAXSTATE 100 /* Size of state tables */ -#define Q931MAXTIMER 25 /* Maximum number of timers */ - -/***************************************************************************** - - Call States for ITU-T Q.931 TE (User Mode) - -*****************************************************************************/ - -#define Q931_U0 0 -#define Q931_U1 1 -#define Q931_U2 2 -#define Q931_U3 3 -#define Q931_U4 4 -#define Q931_U6 6 -#define Q931_U7 7 -#define Q931_U8 8 -#define Q931_U9 9 -#define Q931_U10 10 -#define Q931_U11 11 -#define Q931_U12 12 -#define Q931_U15 15 -#define Q931_U17 17 -#define Q931_U19 19 -#define Q931_U25 25 - -/***************************************************************************** - - Call States for ITU-T Q.931 NT (Network Mode) - -*****************************************************************************/ -#define Q931_N0 (0x0100 | 0) -#define Q931_N1 (0x0100 | 1) -#define Q931_N2 (0x0100 | 2) -#define Q931_N3 (0x0100 | 3) -#define Q931_N4 (0x0100 | 4) -#define Q931_N6 (0x0100 | 6) -#define Q931_N7 (0x0100 | 7) -#define Q931_N8 (0x0100 | 8) -#define Q931_N9 (0x0100 | 9) -#define Q931_N10 (0x0100 | 11) -#define Q931_N11 (0x0100 | 11) -#define Q931_N12 (0x0100 | 12) -#define Q931_N15 (0x0100 | 15) -#define Q931_N17 (0x0100 | 17) -#define Q931_N19 (0x0100 | 19) -#define Q931_N22 (0x0100 | 22) -#define Q931_N25 (0x0100 | 25) - -/***************************************************************************** - - Q.931 Message codes - -*****************************************************************************/ - -#define Q931mes_ALERTING 0x01 /* 0000 0001 */ -#define Q931mes_CALL_PROCEEDING 0x02 /* 0000 0010 */ -#define Q931mes_CONNECT 0x07 /* 0000 0111 */ -#define Q931mes_CONNECT_ACKNOWLEDGE 0x0f /* 0000 1111 */ -#define Q931mes_PROGRESS 0x03 /* 0000 0011 */ -#define Q931mes_SETUP 0x05 /* 0000 0101 */ -#define Q931mes_SETUP_ACKNOWLEDGE 0x0d /* 0000 1101 */ -#define Q931mes_RESUME 0x26 /* 0010 0110 */ -#define Q931mes_RESUME_ACKNOWLEDGE 0x2e /* 0010 1110 */ -#define Q931mes_RESUME_REJECT 0x22 /* 0010 0010 */ -#define Q931mes_SUSPEND 0x25 /* 0010 0101 */ -#define Q931mes_SUSPEND_ACKNOWLEDGE 0x2d /* 0010 1101 */ -#define Q931mes_SUSPEND_REJECT 0x21 /* 0010 0001 */ -#define Q931mes_USER_INFORMATION 0x20 /* 0010 0000 */ -#define Q931mes_DISCONNECT 0x45 /* 0100 0101 */ -#define Q931mes_RELEASE 0x4d /* 0100 1101 */ -#define Q931mes_RELEASE_COMPLETE 0x5a /* 0101 1010 */ -#define Q931mes_RESTART 0x46 /* 0100 0110 */ -#define Q931mes_RESTART_ACKNOWLEDGE 0x4e /* 0100 1110 */ -#define Q931mes_CONGESTION_CONTROL 0x79 /* 0111 1001 */ -#define Q931mes_INFORMATION 0x7b /* 0111 1011 */ -#define Q931mes_NOTIFY 0x6e /* 0110 1110 */ -#define Q931mes_STATUS 0x7d /* 0111 1101 */ -#define Q931mes_STATUS_ENQUIRY 0x75 /* 0111 0101 */ -#define Q931mes_SEGMENT 0x60 /* 0110 0000 */ - -#define Q931mes_SERVICE 0x0f /* 0000 1111 */ -#define Q931mes_SERVICE_ACKNOWLEDGE 0x07 /* 0000 0111 */ - - -/** - * Generic Q.931 Timers - */ -enum { - Q931_TIMER_T300 = 1, /* */ - Q931_TIMER_T301, - Q931_TIMER_T302, - Q931_TIMER_T303, - Q931_TIMER_T304, - Q931_TIMER_T305, - Q931_TIMER_T306, - Q931_TIMER_T307, - Q931_TIMER_T308, - Q931_TIMER_T309, - Q931_TIMER_T310, - Q931_TIMER_T311, - Q931_TIMER_T312, - Q931_TIMER_T313, - Q931_TIMER_T314, - Q931_TIMER_T315, - Q931_TIMER_T316, - Q931_TIMER_T317, - Q931_TIMER_T318, - Q931_TIMER_T319, - Q931_TIMER_T320, - Q931_TIMER_T321, - Q931_TIMER_T322, -}; - -/** - * Q.931 ToN - */ -enum { - Q931_TON_UNKNOWN = 0x00, - Q931_TON_INTERNATIONAL = 0x01, - Q931_TON_NATIONAL = 0x02, - Q931_TON_NETWORK_SPECIFIC = 0x03, - Q931_TON_SUBSCRIBER_NUMBER = 0x04, - Q931_TON_ABBREVIATED_NUMBER = 0x06, - Q931_TON_RESERVED = 0x07 -}; - -/** - * Q.931 Numbering Plan - */ -enum { - Q931_NUMPLAN_UNKNOWN = 0x00, - Q931_NUMPLAN_E164 = 0x01, - Q931_NUMPLAN_X121 = 0x03, - Q931_NUMPLAN_F69 = 0x04, - Q931_NUMPLAN_NATIONAL = 0x08, - Q931_NUMPLAN_PRIVATE = 0x09, - Q931_NUMPLAN_RESERVED = 0x0e -}; - -/** - * Q.931 Presentation Indicator - */ -enum { - Q931_PRES_ALLOWED = 0x00, - Q931_PRES_RESTRICTED = 0x01, - Q931_PRES_NOT_AVAILABLE = 0x02, - Q931_PRES_RESERVED = 0x03 -}; - -/** - * Q.931 Screening Indicator - */ -enum { - Q931_SCREEN_USER_NOT_SCREENED = 0x00, - Q931_SCREEN_USER_VERIFIED_PASSED = 0x01, - Q931_SCREEN_USER_VERIFIED_FAILED = 0x02, - Q931_SCREEN_NETWORK = 0x03 -}; - -/** - * Q.931 Coding Standard - */ -enum { - Q931_CODING_ITU = 0x00, - Q931_CODING_ISO = 0x01, - Q931_CODING_NATIONAL = 0x02, - Q931_CODING_NETWORK = 0x03 -}; - -/** - * Q.931 High layer characteristik id - */ -enum { - Q931_HLCHAR_TELEPHONY = 0x01, - Q931_HLCHAR_FAX_G23 = 0x04, - Q931_HLCHAR_FAX_G4 = 0x21, - Q931_HLCHAR_FAX_G4II = 0x24, - Q931_HLCHAR_T102 = 0x32, - Q931_HLCHAR_T101 = 0x33, - Q931_HLCHAR_F60 = 0x35, - Q931_HLCHAR_X400 = 0x38, - Q931_HLCHAR_X200 = 0x41 -}; - -/** - * Q.931 User information layer 1 protocol - */ -enum { - Q931_UIL1P_V110 = 0x01, - Q931_UIL1P_I460 = 0x01, - Q931_UIL1P_X30 = 0x01, - - Q931_UIL1P_G711U = 0x02, - Q931_UIL1P_G711A = 0x03, - Q931_UIL1P_G721 = 0x04, - - Q931_UIL1P_H221 = 0x05, - Q931_UIL1P_H242 = 0x05, - - Q931_UIL1P_H223 = 0x06, - Q931_UIL1P_H245 = 0x06, - - Q931_UIL1P_RATE_ADAP = 0x07, - - Q931_UIL1P_V120 = 0x08, - Q931_UIL1P_X31 = 0x09 -}; - -/** - * Q.931 Information Transfer Capability - */ -enum { - Q931_ITC_SPEECH = 0x00, - Q931_ITC_UNRESTRICTED = 0x08, - Q931_ITC_RESTRICTED = 0x09, - Q931_ITC_3K1_AUDIO = 0x10, - Q931_ITC_UNRESTRICTED_TONES = 0x11, - Q931_ITC_VIDEO = 0x18 -}; - -/** - * Q.931 Information transfer rate - */ -enum { - Q931_ITR_PACKET = 0x00, - Q931_ITR_64K = 0x10, - Q931_ITR_128K = 0x11, - Q931_ITR_384K = 0x13, - Q931_ITR_1536K = 0x15, - Q931_ITR_1920K = 0x17, - Q931_ITR_MULTI = 0x18 -}; - -/***************************************************************************** - - Struct: Q931mes_Header - - Description: Used to read the header & message code. - -*****************************************************************************/ -typedef struct { - L3UINT Size; /* Size of message in bytes */ - L3UCHAR ProtDisc; /* Protocol Discriminator */ - L3UCHAR MesType; /* Message type */ - L3UCHAR CRVFlag; /* Call reference value flag */ - L3INT CRV; /* Call reference value */ - -} Q931mes_Header; - -/***************************************************************************** - - Struct: Q931mes_Generic - - Description: Generic header containing all IE's. This is not used, but is - provided in case a proprietary variant needs it. - -*****************************************************************************/ -typedef struct { - L3UINT Size; /* Size of message in bytes */ - L3UCHAR ProtDisc; /* Protocol Discriminator */ - L3UCHAR MesType; /* Message type */ - L3UCHAR CRVFlag; /* Call reference value flag */ - L3INT CRV; /* Call reference value */ - - /* WARNING: don't touch anything above this line (TODO: use Q931mes_Header directly to make sure it's the same) */ - - L3UCHAR Tei; /* TEI */ - - ie Shift; - ie MoreData; - ie SendComplete; - ie CongestionLevel; - ie RepeatInd; - - ie Segment; /* Segmented message */ - ie BearerCap; /* Bearer Capability */ - ie Cause; /* Cause */ - ie CallState; /* Call State */ - ie CallID; /* Call Identity */ - ie ChanID; /* Channel Identification */ - ie ChangeStatus; /* Change Staus */ - ie ProgInd; /* Progress Indicator */ - ie NetFac; /* Network Spesific Facilities */ - ie NotifInd; /* Notification Indicator */ - ie Display; /* Display */ - ie DateTime; /* Date/Time */ - ie KeypadFac; /* Keypad Facility */ - ie Signal; /* Signal */ - ie InfoRate; /* Information rate */ - ie EndEndTxDelay; /* End to End Transmit Delay */ - ie TransDelSelInd; /* Transmit Delay Sel. and Ind. */ - ie PackParam; /* Packed Layer Binary parameters */ - ie PackWinSize; /* Packet Layer Window Size */ - ie PackSize; /* Packed Size */ - ie ClosedUserGrp; /* Closed User Group */ - ie RevChargeInd; /* Reverse Charging Indicator */ - ie CalledNum; /* Called Party Number */ - ie CalledSub; /* Called Party subaddress */ - ie CallingNum; /* Calling Party Number */ - ie CallingSub; /* Calling Party Subaddress */ - ie RedirNum; /* Redirection Number */ - ie TransNetSel; /* Transmit Network Selection */ - ie LLRepeatInd; /* Repeat Indicator 2 LLComp */ - ie RestartWin; /* Restart Window */ - ie RestartInd; /* Restart Indicator */ - ie LLComp; /* Low Layer Compatibility */ - ie HLComp; /* High Layer Compatibility */ - ie UserUser; /* User-user */ - ie Escape; /* Escape for extension */ - ie Switchhook; - ie FeatAct; - ie FeatInd; - ie GenericDigits; - - L3UCHAR buf[1]; /* Buffer for IE's */ - -} Q931mes_Generic; - - -/***************************************************************************** - - Struct: Q931_TrunkInfo - - Description: TrunkInfo is the struct entry used to store Q.931 related - information and state for E1/T1/J1 trunks and associated - channels in the system. - - The user should store this information outside this stack - and needs to feed the interface functions with a pointer to - the TrunkInfo entry. - -*****************************************************************************/ -typedef struct Q931_TrunkInfo Q931_TrunkInfo_t; - -typedef enum { - Q931_LOG_NONE = -1, - Q931_LOG_EMERG, - Q931_LOG_ALERT, - Q931_LOG_CRIT, - Q931_LOG_ERROR, - Q931_LOG_WARNING, - Q931_LOG_NOTICE, - Q931_LOG_INFO, - Q931_LOG_DEBUG -} Q931LogLevel_t; - -typedef L3INT (*Q931Tx34CB_t) (void *,L3UCHAR *, L3INT); -typedef L3INT (*Q931Tx32CB_t) (void *, L3INT, L3UCHAR, L3UCHAR *, L3INT); -typedef L3INT (*Q931ErrorCB_t) (void *,L3INT,L3INT,L3INT); -typedef L3INT (*Q931LogCB_t) (void *, Q931LogLevel_t, char *, L3INT); - -typedef enum { /* Network/User Mode. */ - Q931_TE=0, /* 0 : User Mode */ - Q931_NT=1 /* 1 : Network Mode */ -} Q931NetUser_t; - -typedef enum { /* Dialect enum */ - Q931_Dialect_Q931 = 0, - Q931_Dialect_National = 2, - Q931_Dialect_DMS = 4, - Q931_Dialect_5ESS = 6, /* Coming soon to a PRI stack near you! */ - - Q931_Dialect_Count -} Q931Dialect_t; -#define DIALECT_STRINGS "q931", "", "national", "", "dms", "", "5ess", "" -Q931_STR2ENUM_P(q931_str2Q931Dialect_type, q931_Q931Dialect_type2str, Q931Dialect_t) - -typedef enum { /* Trunk Line Type. */ - Q931_TrType_E1 = 0, /* 0 : E1 Trunk */ - Q931_TrType_T1 = 1, /* 1 : T1 Trunk */ - Q931_TrType_J1 = 2, /* 2 : J1 Trunk */ - Q931_TrType_BRI = 3, /* 3 : BRI Trunk */ - Q931_TrType_BRI_PTMP = 4 /* 4 : BRI PTMP Trunk */ -} Q931_TrunkType_t; - -typedef enum { /* Trunk State */ - Q931_TrState_NoAlignment=0, /* Trunk not aligned */ - Q931_TrState_Aligning=1, /* Aligning in progress */ - Q931_TrState_Aligned=2 /* Trunk Aligned */ -} Q931_TrunkState_t; - -typedef enum { - Q931_ChType_NotUsed=0, /* Unused Channel */ - Q931_ChType_B=1, /* B Channel (Voice) */ - Q931_ChType_D=2, /* D Channel (Signalling) */ - Q931_ChType_Sync=3 /* Sync Channel */ -} Q931_ChanType_t; - -struct Q931_Call -{ - L3UCHAR InUse; /* Indicate if entry is in use. */ - /* 0 = Not in Use */ - /* 1 = Active Call. */ - - L3UCHAR Tei; /* Associated TEI */ - - L3UCHAR BChan; /* Associated B Channel. */ - /* 0 - 31 valid B chan */ - /* 255 = Not allocated */ - - L3INT CRV; /* Associated CRV. */ - - L3UINT State; /* Call State. */ - /* 0 is Idle, but other values are */ - /* defined per dialect. */ - /* Default usage is 1-99 for TE and */ - /* 101 - 199 for NT. */ - - L3ULONG Timer; /* Timer in ms. The TimeTick will check */ - /* if this has exceeded the timeout, and */ - /* if so call the timers timeout proc. */ - - L3USHORT TimerID; /* Timer Identification/State */ - /* actual values defined by dialect */ - /* 0 : No timer running */ - /* ITU-T Q.931:301 - 322 Timer running */ -}; - -struct Q931_TrunkInfo -{ - Q931NetUser_t NetUser; /* Network/User Mode. */ - Q931_TrunkType_t TrunkType; /* Trunk Line Type. */ - Q931Dialect_t Dialect; /* Q.931 Based dialect index. */ - - Q931Tx34CB_t Q931Tx34CBProc; - Q931Tx32CB_t Q931Tx32CBProc; - Q931ErrorCB_t Q931ErrorCBProc; - Q931LogCB_t Q931LogCBProc; - void *PrivateData32; - void *PrivateData34; - void *PrivateDataLog; - - Q931LogLevel_t loglevel; - - L3UCHAR Enabled; /* Enabled/Disabled */ - /* 0 = Disabled */ - /* 1 = Enabled */ - - Q931_TrunkState_t TrunkState; - - L3INT LastCRV; /* Last used crv for the trunk. */ - - L3UCHAR L3Buf[Q931L4BUF]; /* message buffer for messages to be */ - /* send from Q.931 L4. */ - - L3UCHAR L2Buf[Q931L2BUF]; /* buffer for messages send to L2. */ - - /* The auto flags below switch on/off automatic Ack messages. SETUP ACK */ - /* as an example can be sent by the stack in response to SETUP to buy */ - /* time in processing on L4. Setting this to true will cause the stack */ - /* to automatically send this. */ - - L3BOOL autoSetupAck; /* Indicate if the stack should send */ - /* SETUP ACK or not. 0=No, 1 = Yes. */ - - L3BOOL autoConnectAck; /* Indicate if the stack should send */ - /* CONNECT ACT or not. 0=No, 1=Yes. */ - - L3BOOL autoRestartAck; /* Indicate if the stack should send */ - /* RESTART ACK or not. 0=No, 1=Yes. */ - - L3BOOL autoServiceAck; /* Indicate if the stack should send */ - /* SERVICE ACK or not. 0=No, 1=Yes. */ - - /* channel array holding info per channel. Usually defined to 32 */ - /* channels to fit an E1 since T1/J1 and BRI will fit inside a E1. */ - struct _charray - { - Q931_ChanType_t ChanType; /* Unused, B, D, Sync */ - - L3UCHAR Available; /* Channel Available Flag */ - /* 0 : Avaiabled */ - /* 1 : Used */ - - L3INT CRV; /* Associated CRV */ - - } ch[Q931MAXCHPERTRUNK]; - - /* Active Call information indentified by CRV. See Q931AllocateCRV for */ - /* initialization of call table. */ - struct Q931_Call call[Q931MAXCALLPERTRUNK]; -}; - -/***************************************************************************** - - Struct: Q931State - - Description: Define a Q931 State, legal events and next state for each - event. Used to simplify the state engine logic. Each state - engine defines its own state table and the logic need only - call a helper function to check if the message is legal - at this stage. - -*****************************************************************************/ -typedef struct -{ - L3INT State; - L3INT Message; - L3UCHAR Direction; -} Q931State; - -/***************************************************************************** - - Proc table external references. - - The proc tables are defined in Q931.c and initialized in Q931Initialize. - -*****************************************************************************/ -typedef L3INT (q931proc_func_t) (Q931_TrunkInfo_t *pTrunk, L3UCHAR *, L3INT); - -typedef L3INT (q931umes_func_t) (Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT IOff, L3INT Size); -typedef L3INT (q931pmes_func_t) (Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); - -typedef L3INT (q931uie_func_t) (Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff); -typedef L3INT (q931pie_func_t) (Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet); - -typedef L3INT (q931timeout_func_t) (Q931_TrunkInfo_t *pTrunk, L3INT callIndex); -typedef L3ULONG q931timer_t; - -extern q931proc_func_t *Q931Proc[Q931MAXDLCT][Q931MAXMES]; - -extern q931umes_func_t *Q931Umes[Q931MAXDLCT][Q931MAXMES]; -extern q931pmes_func_t *Q931Pmes[Q931MAXDLCT][Q931MAXMES]; - -extern q931uie_func_t *Q931Uie[Q931MAXDLCT][Q931MAXIE]; -extern q931pie_func_t *Q931Pie[Q931MAXDLCT][Q931MAXIE]; - -extern q931timeout_func_t *Q931Timeout[Q931MAXDLCT][Q931MAXTIMER]; -extern q931timer_t Q931Timer[Q931MAXDLCT][Q931MAXTIMER]; - - -/***************************************************************************** - - Macro: GetIETotoSize - - Syntax: L3INT GetIETotSize(InfoElem ie); - - Description: Compute the total size in bytes of an info element including - size of 'header'. - -*****************************************************************************/ -#define Q931GetIETotSize(ie) (((ie.InfoID & 0x80) != 0) ? 1 : ie.LenIE) + 2) - -/***************************************************************************** - - Macro: IsIEPresent - - Syntax: BOOL IsIEPresent(ie InfoElement); - - Description: Return TRUE if the Information Element is included. - -*****************************************************************************/ -#define Q931IsIEPresent(x) ((x & 0x8000) != 0) - -/***************************************************************************** - - Macro: GetIEOffset and GetIEValue - - Syntax: L3INT GetIEOffset(ie InfoElement) - L3INT GetIEValue(ie InfoElement) - - Description: Returns the offset (or the value )to the Information Element. - - Note: GetIEValue assumes that the 15 lsb bit is the value of a - single octet information element. This macro can not be used - on a variable information element. - -*****************************************************************************/ -#define Q931GetIEOffset(x) (x & 0x7fff) -#define Q931GetIEValue(x) (x & 0x7fff) - -/***************************************************************************** - - Macro: Q931GetIEPtr - - Syntax: void * Q931GetIEPtr(ie InfoElement, L3UCHAR * Buf); - - Description: Compute a Ptr to the information element. - -*****************************************************************************/ -#define Q931GetIEPtr(ie,buf) ((void *)&buf[Q931GetIEOffset(ie)]) - -/***************************************************************************** - - Macro: SetIE - - Syntax: void SetIE(ie InfoElement, L3INT Offset); - - Description: Set an information element. - -*****************************************************************************/ -#define Q931SetIE(x,o) { x = (ie)(o) | 0x8000; } - -/***************************************************************************** - - Macro: IsQ931Ext - - Syntax BOOL IsQ931Ext(L3UCHAR c) - - Description: Return true Check if the msb (bit 8) is 0. This indicate - that the octet is extended. - -*****************************************************************************/ -#define IsQ931Ext(x) ((x & 0x80) == 0) - -/***************************************************************************** - - Macro: ieGetOctet - - Syntax: unsigned L3UCHAR ieGetOctet(L3INT e) - - Description: Macro to fetch one byte from an integer. Mostly used to - avoid warnings. - -*****************************************************************************/ -#define ieGetOctet(x) ((L3UCHAR)(x)) - -/***************************************************************************** - - Macro: NoWarning - - Syntax: void NoWarning(x) - - Description: Macro to suppress unreferenced formal parameter warnings - - Used during creation of the stack since the stack is - developed for Warning Level 4 and this creates a lot of - warning for the initial empty functions. - -*****************************************************************************/ -#define NoWarning(x) (x = x) - -/***************************************************************************** - - External references. See Q931.c for details. - -*****************************************************************************/ - -#include "Q931ie.h" - -#include "Q932.h" - -/***************************************************************************** - - Q.931 Message Pack/Unpack functions. Implemented in Q931mes.c - -*****************************************************************************/ -L3INT Q931Pmes_Alerting(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); -L3INT Q931Pmes_CallProceeding(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); -L3INT Q931Pmes_Connect(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); -L3INT Q931Pmes_ConnectAck(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); -L3INT Q931Pmes_Progress(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); -L3INT Q931Pmes_Setup(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); -L3INT Q931Pmes_SetupAck(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); -L3INT Q931Pmes_Resume(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); -L3INT Q931Pmes_ResumeAck(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); -L3INT Q931Pmes_ResumeReject(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); -L3INT Q931Pmes_Suspend(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); -L3INT Q931Pmes_SuspendAck(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); -L3INT Q931Pmes_SuspendReject(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); -L3INT Q931Pmes_UserInformation(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); -L3INT Q931Pmes_Disconnect(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); -L3INT Q931Pmes_Release(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); -L3INT Q931Pmes_ReleaseComplete(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); -L3INT Q931Pmes_Restart(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); -L3INT Q931Pmes_RestartAck(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); -L3INT Q931Pmes_CongestionControl(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); -L3INT Q931Pmes_Information(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); -L3INT Q931Pmes_Notify(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); -L3INT Q931Pmes_Segment(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); -L3INT Q931Pmes_Status(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); -L3INT Q931Pmes_StatusEnquiry(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); -L3INT Q931Pmes_Service(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); -L3INT Q931Pmes_ServiceAck(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); - - -L3INT Q931Umes_Alerting(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT I, L3INT O); -L3INT Q931Umes_CallProceeding(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT I, L3INT O); -L3INT Q931Umes_Connect(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT I, L3INT O); -L3INT Q931Umes_ConnectAck(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT I, L3INT O); -L3INT Q931Umes_Progress(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT I, L3INT O); -L3INT Q931Umes_Setup(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT I, L3INT O); -L3INT Q931Umes_SetupAck(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT I, L3INT O); -L3INT Q931Umes_Resume(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT I, L3INT O); -L3INT Q931Umes_ResumeAck(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT I, L3INT O); -L3INT Q931Umes_ResumeReject(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT I, L3INT O); -L3INT Q931Umes_Suspend(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT I, L3INT O); -L3INT Q931Umes_SuspendAck(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT I, L3INT O); -L3INT Q931Umes_SuspendReject(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT I, L3INT O); -L3INT Q931Umes_UserInformation(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT I, L3INT O); -L3INT Q931Umes_Disconnect(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT I, L3INT O); -L3INT Q931Umes_Release(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT I, L3INT O); -L3INT Q931Umes_ReleaseComplete(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT I, L3INT O); -L3INT Q931Umes_Restart(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT I, L3INT O); -L3INT Q931Umes_RestartAck(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT I, L3INT O); -L3INT Q931Umes_CongestionControl(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT I, L3INT O); -L3INT Q931Umes_Information(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT I, L3INT O); -L3INT Q931Umes_Notify(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT I, L3INT O); -L3INT Q931Umes_Segment(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT I, L3INT O); -L3INT Q931Umes_Status(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT I, L3INT O); -L3INT Q931Umes_StatusEnquiry(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT I, L3INT O); -L3INT Q931Umes_Service(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size); -L3INT Q931Umes_ServiceAck(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size); - - -/***************************************************************************** - - Q.931 Process Function Prototyping. Implemented in Q931StateTE.c - -*****************************************************************************/ -L3INT Q931ProcAlertingTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcCallProceedingTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcConnectTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcConnectAckTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcProgressTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcSetupTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcSetupAckTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcResumeTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcResumeAckTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcResumeRejectTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcSuspendTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcSuspendAckTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcSuspendRejectTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcUserInformationTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcDisconnectTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcReleaseTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcReleaseCompleteTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcRestartTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcRestartAckTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcCongestionControlTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcInformationTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcNotifyTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcStatusTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcStatusEnquiryTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcSegmentTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); - -L3INT Q931ProcAlertingNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcCallProceedingNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcConnectNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcConnectAckNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcProgressNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcSetupNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcSetupAckNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcResumeNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcResumeAckNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcResumeRejectNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcSuspendNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcSuspendAckNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcSuspendRejectNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcUserInformationNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcDisconnectNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcReleaseNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcReleaseCompleteNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcRestartNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcRestartAckNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcCongestionControlNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcInformationNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcNotifyNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcStatusNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcStatusEnquiryNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcSegmentNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); - -L3INT Q931ProcUnknownMessage(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); -L3INT Q931ProcUnexpectedMessage(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom); - -/***************************************************************************** - - Interface Function Prototypes. Implemented in Q931.c - -*****************************************************************************/ -void Q931TimerTick(Q931_TrunkInfo_t *pTrunk); -L3INT Q931Rx23(Q931_TrunkInfo_t *pTrunk, L3INT ind, L3UCHAR tei, L3UCHAR * Mes, L3INT Size); -L3INT Q931Tx32Data(Q931_TrunkInfo_t *pTrunk, L3UCHAR bcast, L3UCHAR * Mes, L3INT Size); -L3INT Q931Rx43(Q931_TrunkInfo_t *pTrunk, L3UCHAR * Mes, L3INT Size); -L3INT Q931Tx34(Q931_TrunkInfo_t *pTrunk, L3UCHAR * Mes, L3INT Size); -void Q931SetError(Q931_TrunkInfo_t *pTrunk,L3INT ErrID, L3INT ErrPar1, L3INT ErrPar2); - -void Q931SetDefaultErrorCB(Q931ErrorCB_t Q931ErrorPar); - -void Q931CreateTE(L3UCHAR i); -void Q931CreateNT(L3UCHAR i); -void Q931SetMesCreateCB(L3INT (*callback)(void)); -void Q931SetDialectCreateCB(L3INT (*callback)(L3INT)); -void Q931SetHeaderSpace(L3INT space); - -void Q931SetMesProc(L3UCHAR mes, L3UCHAR dialect, q931proc_func_t *Q931ProcFunc, q931umes_func_t *Q931UmesFunc, q931pmes_func_t *Q931PmesFunc); -void Q931SetIEProc(L3UCHAR iec, L3UCHAR dialect, q931pie_func_t *Q931PieProc, q931uie_func_t *Q931UieProc); -void Q931SetTimeoutProc(L3UCHAR dialect, L3UCHAR timer, q931timeout_func_t *Q931TimeoutProc); -void Q931SetTimerDefault(L3UCHAR dialect, L3UCHAR timer, q931timer_t timeout); - -void Q931Initialize(void); -void Q931AddDialect(L3UCHAR iDialect, void (*Q931CreateDialectCB)(L3UCHAR iDialect)); -L3INT Q931InitMesSetup(Q931mes_Generic *p); -L3INT Q931InitMesRestartAck(Q931mes_Generic * pMes); -L3INT Q931InitMesGeneric(Q931mes_Generic *pMes); - -L3INT Q931CreateCRV(Q931_TrunkInfo_t *pTrunk, L3INT * callIndex); -L3INT Q931ReleaseCRV(Q931_TrunkInfo_t *pTrunk, L3INT CRV); -L3INT Q931AllocateCRV(Q931_TrunkInfo_t *pTrunk, L3INT iCRV, L3INT * callIndex); -L3INT Q931FindCRV(Q931_TrunkInfo_t *pTrunk, L3INT crv, L3INT *callindex); -L3INT Q931GetCallState(Q931_TrunkInfo_t *pTrunk, L3INT iCRV); -L3INT Q931StartTimer(Q931_TrunkInfo_t *pTrunk, L3INT callIndex, L3USHORT iTimer); -L3INT Q931StopTimer(Q931_TrunkInfo_t *pTrunk, L3INT callindex, L3USHORT iTimer); -L3INT Q931SetState(Q931_TrunkInfo_t *pTrunk, L3INT callIndex, L3INT iState); -L3ULONG Q931GetTime(void); -void Q931SetGetTimeCB(L3ULONG (*callback)(void)); -void Q931AddStateEntry(L3UCHAR iD, L3INT iState, L3INT iMes, L3UCHAR cDir); -L3BOOL Q931IsEventLegal(L3UCHAR iD, L3INT iState, L3INT iMes, L3UCHAR cDir); - -/***************************************************************************** - - Q.931 Low Level API Function Prototyping. Implemented in Q931API.c - -*****************************************************************************/ -ie Q931AppendIE(L3UCHAR *pm, L3UCHAR *pi); -L3INT Q931GetUniqueCRV(Q931_TrunkInfo_t *pTrunk); - -L3INT Q931InitIEBearerCap(Q931ie_BearerCap *p); -L3INT Q931InitIEChanID(Q931ie_ChanID *p); -L3INT Q931InitIEProgInd(Q931ie_ProgInd *p); -L3INT Q931InitIENetFac(Q931ie_NetFac * pIE); -L3INT Q931InitIEDisplay(Q931ie_Display * pIE); -L3INT Q931InitIEDateTime(Q931ie_DateTime * pIE); -L3INT Q931InitIEKeypadFac(Q931ie_KeypadFac * pIE); -L3INT Q931InitIESignal(Q931ie_Signal * pIE); -L3INT Q931InitIECallingNum(Q931ie_CallingNum * pIE); -L3INT Q931InitIECallingSub(Q931ie_CallingSub * pIE); -L3INT Q931InitIECalledNum(Q931ie_CalledNum * pIE); -L3INT Q931InitIECalledSub(Q931ie_CalledSub * pIE); -L3INT Q931InitIETransNetSel(Q931ie_TransNetSel * pIE); -L3INT Q931InitIELLComp(Q931ie_LLComp * pIE); -L3INT Q931InitIEHLComp(Q931ie_HLComp * pIE); - -L3INT Q931Disconnect(Q931_TrunkInfo_t *pTrunk, L3INT iTo, L3INT iCRV, L3INT iCause); -L3INT Q931ReleaseComplete(Q931_TrunkInfo_t *pTrunk, L3UCHAR *buf); -L3INT Q931AckRestart(Q931_TrunkInfo_t *pTrunk, L3UCHAR *buf); -L3INT Q931AckConnect(Q931_TrunkInfo_t *pTrunk, L3UCHAR *buf); -L3INT Q931AckSetup(Q931_TrunkInfo_t *pTrunk, L3UCHAR *buf); -L3INT Q931AckService(Q931_TrunkInfo_t *pTrunk, L3UCHAR *buf); - -L3INT Q931Api_InitTrunk(Q931_TrunkInfo_t *pTrunk, - Q931Dialect_t Dialect, - Q931NetUser_t NetUser, - Q931_TrunkType_t TrunkType, - Q931Tx34CB_t Q931Tx34CBProc, - Q931Tx32CB_t Q931Tx32CBProc, - Q931ErrorCB_t Q931ErrorCBProc, - void *PrivateData32, - void *PrivateData34); - -L3INT Q931GetMesSize(Q931mes_Generic *pMes); -L3INT Q931InitMesResume(Q931mes_Generic * pMes); - -L3INT Q931Log(Q931_TrunkInfo_t *trunk, Q931LogLevel_t level, const char *fmt, ...); -void Q931SetLogCB(Q931_TrunkInfo_t *trunk, Q931LogCB_t func, void *priv); -void Q931SetLogLevel(Q931_TrunkInfo_t *trunk, Q931LogLevel_t level); - -void Q931SetL4HeaderSpace(L3INT space); -void Q931SetL2HeaderSpace(L3INT space); -L3INT Q931ProcDummy(Q931_TrunkInfo_t *pTrunk, L3UCHAR * b,L3INT c); -L3INT Q931UmesDummy(Q931_TrunkInfo_t *pTrunk,L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT IOff, L3INT Size); -L3INT Q931UieDummy(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff); -L3INT Q931PmesDummy(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); -L3INT Q931PieDummy(Q931_TrunkInfo_t *pTrunk,L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet); -L3INT Q931TxDummy(Q931_TrunkInfo_t *pTrunk, L3UCHAR * b, L3INT n); -L3INT Q931ErrorDummy(void *priv, L3INT a, L3INT b, L3INT c); -L3INT Q931TimeoutDummy(Q931_TrunkInfo_t *pTrunk, L3INT callIndex); - -L3INT Q931MesgHeader(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *mes, L3UCHAR *OBuf, L3INT Size, L3INT *IOff); - -#endif /* _Q931_NL */ diff --git a/libs/freetdm/src/isdn/include/Q931ie.h b/libs/freetdm/src/isdn/include/Q931ie.h deleted file mode 100644 index 65dba4e261..0000000000 --- a/libs/freetdm/src/isdn/include/Q931ie.h +++ /dev/null @@ -1,1205 +0,0 @@ -/****************************************************************************** - - FileName: Q931ie.h - - Contents: Header and definition for the ITU-T Q.931 ie - structures and functions - - License/Copyright: - - Copyright (c) 2007, Jan Vidar Berger, Case Labs, Ltd. All rights reserved. - email:janvb@caselaboratories.com - - 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 Case Labs, Ltd 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT OWNER OR CONTRIBUTORS 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 SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -******************************************************************************/ - -#ifndef _Q931IE_NL -#define _Q931IE_NL - -/* Codesets */ - -typedef enum { - - Q931_CODESET_0 = ( 0 ), - Q931_CODESET_1 = ( 1 << 8 ), - Q931_CODESET_2 = ( 2 << 8 ), - Q931_CODESET_3 = ( 3 << 8 ), - Q931_CODESET_4 = ( 4 << 8 ), - Q931_CODESET_5 = ( 5 << 8 ), - Q931_CODESET_6 = ( 6 << 8 ), - Q931_CODESET_7 = ( 7 << 8 ) - -} q931_codeset_t; - -/* Single octet information elements */ -#define Q931ie_SHIFT 0x90 /* 1001 ---- */ -#define Q931ie_MORE_DATA 0xa0 /* 1010 ---- */ -#define Q931ie_SENDING_COMPLETE 0xa1 /* 1010 0001 */ -#define Q931ie_CONGESTION_LEVEL 0xb0 /* 1011 ---- */ -#define Q931ie_REPEAT_INDICATOR 0xd0 /* 1101 ---- */ - -/* Variable Length Information Elements */ -#define Q931ie_SEGMENTED_MESSAGE 0x00 /* 0000 0000 */ -#define Q931ie_CHANGE_STATUS 0x01 /* 0000 0001 */ -#define Q931ie_BEARER_CAPABILITY 0x04 /* 0000 0100 */ -#define Q931ie_CAUSE 0x08 /* 0000 1000 */ -#define Q931ie_CALL_IDENTITY 0x10 /* 0001 0000 */ -#define Q931ie_CALL_STATE 0x14 /* 0001 0100 */ -#define Q931ie_CHANNEL_IDENTIFICATION 0x18 /* 0001 1000 */ -#define Q931ie_PROGRESS_INDICATOR 0x1e /* 0001 1110 */ -#define Q931ie_NETWORK_SPECIFIC_FACILITIES 0x20 /* 0010 0000 */ -#define Q931ie_NOTIFICATION_INDICATOR 0x27 /* 0010 0111 */ -#define Q931ie_DISPLAY 0x28 /* 0010 1000 */ -#define Q931ie_DATETIME 0x29 /* 0010 1001 */ -#define Q931ie_KEYPAD_FACILITY 0x2c /* 0010 1100 */ -#define Q931ie_SIGNAL 0x34 /* 0011 0100 */ -#define Q931ie_SWITCHOOK 0x36 /* 0011 0110 */ -#define Q931ie_FEATURE_ACTIVATION 0x38 /* 0011 1000 */ -#define Q931ie_FEATURE_INDICATION 0x39 /* 0011 1001 */ -#define Q931ie_INFORMATION_RATE 0x40 /* 0100 0000 */ -#define Q931ie_END_TO_END_TRANSIT_DELAY 0x42 /* 0100 0010 */ -#define Q931ie_TRANSIT_DELAY_SELECTION_AND_IND 0x43 /* 0100 0011 */ -#define Q931ie_PACKED_LAYER_BIMARY_PARAMETERS 0x44 /* 0100 0100 */ -#define Q931ie_PACKED_LAYER_WINDOW_SIZE 0x45 /* 0100 0101 */ -#define Q931ie_PACKED_SIZE 0x46 /* 0100 0110 */ -#define Q931ie_CALLING_PARTY_NUMBER 0x6c /* 0110 1100 */ -#define Q931ie_CALLING_PARTY_SUBADDRESS 0x6d /* 0110 1101 */ -#define Q931ie_CALLED_PARTY_NUMBER 0x70 /* 0111 0000 */ -#define Q931ie_CALLED_PARTY_SUBADDRESS 0x71 /* 0111 0001 */ -#define Q931ie_REDIRECTING_NUMBER 0x74 /* 0111 0100 */ -#define Q931ie_TRANSIT_NETWORK_SELECTION 0x78 /* 0111 1000 */ -#define Q931ie_RESTART_INDICATOR 0x79 /* 0111 1001 */ -#define Q931ie_LOW_LAYER_COMPATIBILITY 0x7c /* 0111 1100 */ -#define Q931ie_HIGH_LAYER_COMPATIBILITY 0x7d /* 0111 1101 */ -#define Q931ie_USER_USER 0x7e /* 0111 1110 */ -#define Q931ie_ESCAPE_FOR_EX 0x7f /* 0111 1111 */ - -/* Variable Length Codeset 6 Information Elements */ -#define Q931ie_GENERIC_DIGITS 0x37 /* 0011 0111 */ - -/* Variable Length Information Element to shut up BRI testing */ -#define Q931ie_CONNECTED_NUMBER 0x4c /* 0100 1101 */ -#define Q931ie_FACILITY 0x1c /* 0001 1101 */ - - -/***************************************************************************** - - Struct: Q931ie_BearerCap - - Description: Bearer Capability Information Element. - -*****************************************************************************/ - -typedef struct { - - L3UCHAR IEId; /* 00000100 for Bearer Capability */ - L3UCHAR Size; /* Length of Information Element */ - - L3UCHAR CodStand; /* Coding Standard. */ - /* 00 - ITU-T */ - /* 01 - ISO/IEC */ - /* 10 - National standard */ - /* 11 - Network side spesific */ - - L3UCHAR ITC; /* Information Transfer Capability */ - /* 00000 - Speech */ - /* 01000 - Unrestricted digital info */ - /* 01001 - Restricted digital info */ - /* 10000 - 3.1 kHz audio */ - /* 10001 - Unrestricted with tones */ - /* 11000 - Video */ - - L3UCHAR TransMode; /* Transfer Mode. */ - /* 00 - Circuit mode */ - /* 10 - Packet mode */ - - L3UCHAR ITR; /* Information Transfer Rate. */ - /* 00000 - Packed mode */ - /* 10000 - 64 kbit/s */ - /* 10001 - 2 x 64 kbit/s */ - /* 10011 - 384 kbit/s */ - /* 10101 - 1536 kbit/s */ - /* 10111 - 1920 kbit/s */ - /* 11000 - Multirat (64 kbit/s base) */ - - L3UCHAR RateMul; /* Rate Multiplier */ - - L3UCHAR Layer1Ident; /* Layer 1 Ident. */ - - L3UCHAR UIL1Prot; /* User Information Layer 1 Protocol */ - /* 00001 : ITU-T V.110, I.460 and X.30 */ - /* 00010 : G.711 my-law */ - /* 00011 : G.711 A-law */ - /* 00100 : G.721 */ - /* 00101 : H.221 and H.242 */ - /* 00110 : H.223 and H.245 */ - /* 00111 : Non ITU-T Standard */ - /* 01000 : ITU-T V.120 */ - /* 01001 : ITU-T X.31 HDLC flag stuff. */ - - L3UCHAR SyncAsync; /* Sync/Async */ - /* 0 : Syncronous data */ - /* 1 : Asyncronous data */ - - L3UCHAR Negot; /* Negotiation */ - /* 0 : In-band negotiation not possib. */ - /* 1 : In-band negotiation possible */ - - L3UCHAR UserRate; /* User rate */ - /* 00000 : I.460, V.110, X,30 */ - /* 00001 : 0.6 kbit/s x.1 */ - /* 00010 : 1.2 kbit/s */ - /* 00011 : 2.4 kbit/s */ - /* 00100 : 3.6 kbit/s */ - /* 00101 : 4.8 kbit/s */ - /* 00110 : 7.2 kbit/s */ - /* 00111 : 8 kbit/s I.460 */ - /* 01000 : 9.6 kbit/s */ - /* 01001 : 14.4 kbit/s */ - /* 01010 : 16 kbit/s */ - /* 01011 : 19.2 kbit/s */ - /* 01100 : 32 kbit/s */ - /* 01101 : 38.4 kbit/s */ - /* 01110 : 48 kbit/s */ - /* 01111 : 56 kbit/s */ - /* 10000 : 57.6 kbit/s */ - /* 10010 : 28.8 kbit/s */ - /* 10100 : 24 kbit/s */ - /* 10101 : 0.1345 kbit/s */ - /* 10110 : 0.100 kbit/s */ - /* 10111 : 0.075/1.2 kbit/s */ - /* 11000 : 1.2/0.075/kbit/s */ - /* 11001 : 0.050 kbit/s */ - /* 11010 : 0.075 kbit/s */ - /* 11011 : 0.110 kbit/s */ - /* 11100 : 0.150 kbit/s */ - /* 11101 : 0.200 kbit/s */ - /* 11110 : 0.300 kbit/s */ - /* 11111 : 12 kbit/s */ - - L3UCHAR InterRate; /* Intermediate Rate */ - /* 00 : Not used */ - /* 01 : 8 kbit/s */ - /* 10 : 16 kbit/s */ - /* 11 : 32 kbit/s */ - - L3UCHAR NIConTx; /* Network Indepentend Clock on transmit*/ - /* 0 : Not required to send data clc */ - /* 1 : Send data w/NIC clc */ - - L3UCHAR NIConRx; /* NIC on Rx */ - /* 0 : Cannot accept indep. clc */ - /* 1 : data with indep. clc accepted */ - - L3UCHAR FlowCtlTx; /* Flow control on Tx */ - /* 0 : Send Flow ctrl not required */ - /* 1 : Send flow ctrl required */ - - L3UCHAR FlowCtlRx; /* Flow control on Rx */ - /* 0 : cannot use receive flow ctrl */ - /* 1 : Receive flow ctrl accepted */ - L3UCHAR HDR; /* HDR/No HDR */ - L3UCHAR MultiFrame; /* Multi frame support */ - /* 0 : multiframe not supported */ - /* 1 : multiframe supported */ - - L3UCHAR Mode; /* Mode of operation */ - /* 0 : bit transparent mode of operat. */ - /* 1 : protocol sesitive mode of op. */ - - L3UCHAR LLInegot; /* Logical link id negotiation (oct. 5b)*/ - /* 0 : default LLI=256 only */ - /* 1 : Full protocol negotiation */ - - L3UCHAR Assignor; /* Assignor/assignee */ - /* 0 : Default Asignee */ - /* 1 : Assignor only */ - - L3UCHAR InBandNeg; /* In-band/out-band negot. */ - /* 0 : negot done w/ USER INFO mes */ - /* 1 : negot done in-band w/link zero */ - - L3UCHAR NumStopBits; /* Number of stop bits */ - /* 00 : Not used */ - /* 01 : 1 bit */ - /* 10 : 1.5 bits */ - /* 11 : 2 bits */ - - L3UCHAR NumDataBits; /* Number of data bits. */ - /* 00 : not used */ - /* 01 : 5 bits */ - /* 10 : 7 bits */ - /* 11 : 8 bits */ - - L3UCHAR Parity; /* Parity Information */ - /* 000 : Odd */ - /* 010 : Even */ - /* 011 : None */ - /* 100 : Forced to 0 */ - /* 101 : Forced to 1 */ - - L3UCHAR DuplexMode; /* Mode duplex */ - /* 0 : Half duplex */ - /* 1 : Full duplex */ - - L3UCHAR ModemType; /* Modem type, see Q.931 p 64 */ - - L3UCHAR Layer2Ident; /* Layer 2 Ident */ - - L3UCHAR UIL2Prot; /* User Information Layer 2 Protocol */ - /* 00010 : Q.921/I.441 */ - /* 00110 : X.25 */ - /* 01100 : LAN logical link */ - - L3UCHAR Layer3Ident; /* Layer 3 ident. */ - - L3UCHAR UIL3Prot; /* User Information Layer 3 Protocol */ - /* 00010 : Q.931 */ - /* 00110 : X.25 */ - /* 01011 : ISO/IEC TR 9577 */ - - L3UCHAR AL3Info1; /* additional layer 3 info 1 */ - - L3UCHAR AL3Info2; /* additional layer 3 info 2 */ - -} Q931ie_BearerCap; - -/***************************************************************************** - - Struct: Q931ie_CallID - - -*****************************************************************************/ - -typedef struct { - - L3UCHAR IEId; /* 00010000 */ - L3UCHAR Size; /* Length of Information Element */ - L3UCHAR CallId[1]; /* Call identity */ - -} Q931ie_CallID; - -/***************************************************************************** - - Struct: Q931ie_CallState - - -*****************************************************************************/ - -typedef struct { - - L3UCHAR IEId; /* 00010100 */ - L3UCHAR Size; /* Length of Information Element */ - L3UCHAR CodStand; /* Coding Standard */ - L3UCHAR CallState; /* Call State Value */ - -} Q931ie_CallState; - -/***************************************************************************** - - Struct: Q931ie_Cause - - Description: Cause IE as described in Q.850 - -*****************************************************************************/ -typedef struct { - - L3UCHAR IEId; /* 00010100 */ - L3UCHAR Size; /* Length of Information Element */ - L3UCHAR CodStand; /* Coding Standard */ - L3UCHAR Location; /* Location */ - L3UCHAR Recom; /* Recommendation */ - L3UCHAR Value; /* Cause Value */ - L3UCHAR Diag[1]; /* Optional Diagnostics Field */ - -} Q931ie_Cause; - -/***************************************************************************** - - Struct: Q931ie_CalledNum - -*****************************************************************************/ -typedef struct { - - L3UCHAR IEId; /* 01110000 */ - L3UCHAR Size; /* Length of Information Element */ - L3UCHAR TypNum; /* Type of Number */ - L3UCHAR NumPlanID; /* Numbering plan identification */ - L3UCHAR Digit[1]; /* Digit (IA5) */ - -} Q931ie_CalledNum; - -/***************************************************************************** - - Struct: Q931ie_CalledSub - - Description: Called party subaddress - -*****************************************************************************/ - -typedef struct { - - L3UCHAR IEId; /* 01110001 */ - L3UCHAR Size; /* Length of Information Element */ - L3UCHAR TypNum; /* Type of subaddress */ - L3UCHAR OddEvenInd; /* Odd/Even indicator */ - L3UCHAR Digit[1]; /* digits */ - -} Q931ie_CalledSub; - -/***************************************************************************** - - Struct: Q931ie_CallingNum - - Description: Calling party number - -*****************************************************************************/ - -typedef struct { - - L3UCHAR IEId; /* 01101100 */ - L3UCHAR Size; /* Length of Information Element */ - L3UCHAR TypNum; /* Type of number */ - L3UCHAR NumPlanID; /* Numbering plan identification */ - L3UCHAR PresInd; /* Presentation indicator */ - L3UCHAR ScreenInd; /* Screening indicator */ - L3UCHAR Digit[1]; /* Number digits (IA5) */ - -} Q931ie_CallingNum; - -/***************************************************************************** - - Struct: Q931ie_CallingSub - - Description: Calling party subaddress - -*****************************************************************************/ - -typedef struct { - - L3UCHAR IEId; /* 01101101 */ - L3UCHAR Size; /* Length of Information Element */ - L3UCHAR TypNum; /* Type of subaddress */ - L3UCHAR OddEvenInd; /* Odd/Even indicator */ - L3UCHAR Digit[1]; /* digits */ - -} Q931ie_CallingSub; - -/***************************************************************************** - - Struct: Q931ie_ChanID - - Description: Channel identification - - Channel Identificationis one of the IE elements that differ - between BRI and PRI. IntType = 1 = BRI and ChanSlot is used - for channel number, while InfoChanSel is used for BRI. - - ChanID is one of the most important IE as it is passed - either though SETUP or CALL PROCEEDING to select the channel - to be used. - -*****************************************************************************/ - -typedef struct { - - L3UCHAR IEId; /* 00011000 */ - L3UCHAR Size; /* Length of Information Element */ - L3UCHAR IntIDPresent; /* Int. id. present */ - L3UCHAR IntType; /* Interface Type */ - /* 0 : Basic Interface (BRI) */ - /* 1 : Other interfaces, PRI etc. */ - - L3UCHAR PrefExcl; /* Pref./Excl. */ - /* 0 : Indicated channel is preffered */ - /* 1 : Exclusive, no other accepted */ - - L3UCHAR DChanInd; /* D-channel ind. */ - /* 0 : chan is NOT D chan. */ - /* 1 : chan is D chan */ - - L3UCHAR InfoChanSel; /* Info. channel selection */ - /* 00 : No channel */ - /* 01 : B1 channel */ - /* 10 : B2 channel */ - /* 11 : Any channel */ - - L3UCHAR InterfaceID; /* Interface identifier */ - - L3UCHAR CodStand; /* Code standard */ - /* 00 : ITU-T standardization coding */ - /* 01 : ISO/IEC Standard */ - /* 10 : National Standard */ - /* 11 : Standard def. by network. */ - - L3UCHAR NumMap; /* Number/Map */ - /* 0 : chan is in following octet */ - /* 1 : chan is indicated by slot map */ - - L3UCHAR ChanMapType; /* Channel type/Map element type */ - /* 0011 : B Channel units */ - /* 0110 : H0 channel units */ - /* 1000 : H11 channel units */ - /* 1001 : H12 channel units */ - - L3UCHAR ChanSlot; /* Channel number */ - -} Q931ie_ChanID; - -/***************************************************************************** - - Struct: Q931ie_DateTime - - Description: Date/time - -*****************************************************************************/ - -typedef struct { - - L3UCHAR IEId; /* 00101001 */ - L3UCHAR Size; /* Length of Information Element */ - L3UCHAR Year; /* Year */ - L3UCHAR Month; /* Month */ - L3UCHAR Day; /* Day */ - L3UCHAR Hour; /* Hour */ - L3UCHAR Minute; /* Minute */ - L3UCHAR Second; /* Second */ - L3UCHAR Format; /* Indicate presense of Hour, Min & sec */ - /* 0 : Only Date */ - /* 1 : Hour present */ - /* 2 : Hour and Minute present */ - /* 3 : Hour, Minute and Second present */ -} Q931ie_DateTime; - -/***************************************************************************** - - Struct: Q931ie_Display - - Description: Display - -*****************************************************************************/ - -typedef struct { - - L3UCHAR IEId; /* 00101000 */ - L3UCHAR Size; /* Length of Information Element */ - L3UCHAR Display[1]; /* Display information (IA5) */ - -} Q931ie_Display; - -/***************************************************************************** - - Struct: Q931ie_HLComp - - Description: High layer compatibility - -*****************************************************************************/ - -typedef struct { - - L3UCHAR IEId; /* 01111101 */ - L3UCHAR Size; /* Length of Information Element */ - L3UCHAR CodStand; /* Coding standard */ - L3UCHAR Interpret; /* Interpretation */ - L3UCHAR PresMeth; /* Presentation methor of prot. profile */ - L3UCHAR HLCharID; /* High layer characteristics id. */ - L3UCHAR EHLCharID; /* Extended high layer character. id. */ - L3UCHAR EVideoTlfCharID; /* Ext. videotelephony char. id. */ - -} Q931ie_HLComp; - -/***************************************************************************** - - Struct: Q931ie_KeypadFac - - Description: Keypad facility - -*****************************************************************************/ - -typedef struct { - L3UCHAR IEId; /* 00101100 */ - L3UCHAR Size; /* Length of Information Element */ - L3UCHAR KeypadFac[1]; /* dynamic buffer */ - -} Q931ie_KeypadFac; - -/***************************************************************************** - - Struct: Q931ie_LLComp - - Description: Low layer compatibility - -*****************************************************************************/ - -typedef struct { - - L3UCHAR IEId; /* 01111100 */ - L3UCHAR Size; /* Length of Information Element */ - L3UCHAR CodStand; /* Coding standard */ - /* 00 - ITU-T */ - /* 01 - ISO/IEC */ - /* 10 - National standard */ - /* 11 - Network side spesific */ - - L3UCHAR ITransCap; /* Information transfer capability */ - /* 00000 - Speech */ - /* 01000 - Unrestricted digital info */ - /* 01001 - Restricted digital info */ - /* 10000 - 3.1 kHz audio */ - /* 10001 - Unrestricted with tones */ - /* 11000 - Video */ - - L3UCHAR NegotInd; /* Negot indic. */ - /* 0 : Out-band neg. not possib. */ - /* 1 : Out-band neg. possible */ - - L3UCHAR TransMode; /* Transfer Mode */ - /* 00 : Circuit Mode */ - /* 10 : Packed Mode */ - - L3UCHAR InfoRate; /* Information transfer rate */ - /* 00000 - Packed mode */ - /* 10000 - 64 kbit/s */ - /* 10001 - 2 x 64 kbit/s */ - /* 10011 - 384 kbit/s */ - /* 10101 - 1536 kbit/s */ - /* 10111 - 1920 kbit/s */ - /* 11000 - Multirat (64 kbit/s base) */ - - L3UCHAR RateMul; /* Rate multiplier */ - L3UCHAR Layer1Ident; /* Layer 1 ident. */ - L3UCHAR UIL1Prot; /* User information layer 1 protocol */ - /* 00001 : ITU-T V.110, I.460 and X.30 */ - /* 00010 : G.711 my-law */ - /* 00011 : G.711 A-law */ - /* 00100 : G.721 */ - /* 00101 : H.221 and H.242 */ - /* 00110 : H.223 and H.245 */ - /* 00111 : Non ITU-T Standard */ - /* 01000 : ITU-T V.120 */ - /* 01001 : ITU-T X.31 HDLC flag stuff. */ - - L3UCHAR SyncAsync; /* Synch/asynch */ - /* 0 : Syncronous data */ - /* 1 : Asyncronous data */ - - L3UCHAR Negot; /* Negot */ - /* 0 : In-band negotiation not possib. */ - /* 1 : In-band negotiation possible */ - - L3UCHAR UserRate; /* User rate */ - /* 00000 : I.460, V.110, X,30 */ - /* 00001 : 0.6 kbit/s x.1 */ - /* 00010 : 1.2 kbit/s */ - /* 00011 : 2.4 kbit/s */ - /* 00100 : 3.6 kbit/s */ - /* 00101 : 4.8 kbit/s */ - /* 00110 : 7.2 kbit/s */ - /* 00111 : 8 kbit/s I.460 */ - /* 01000 : 9.6 kbit/s */ - /* 01001 : 14.4 kbit/s */ - /* 01010 : 16 kbit/s */ - /* 01011 : 19.2 kbit/s */ - /* 01100 : 32 kbit/s */ - /* 01101 : 38.4 kbit/s */ - /* 01110 : 48 kbit/s */ - /* 01111 : 56 kbit/s */ - /* 10000 : 57.6 kbit/s */ - /* 10010 : 28.8 kbit/s */ - /* 10100 : 24 kbit/s */ - /* 10101 : 0.1345 kbit/s */ - /* 10110 : 0.100 kbit/s */ - /* 10111 : 0.075/1.2 kbit/s */ - /* 11000 : 1.2/0.075/kbit/s */ - /* 11001 : 0.050 kbit/s */ - /* 11010 : 0.075 kbit/s */ - /* 11011 : 0.110 kbit/s */ - /* 11100 : 0.150 kbit/s */ - /* 11101 : 0.200 kbit/s */ - /* 11110 : 0.300 kbit/s */ - /* 11111 : 12 kbit/s */ - - L3UCHAR InterRate; /* Intermediate rate */ - /* 00 : Not used */ - /* 01 : 8 kbit/s */ - /* 10 : 16 kbit/s */ - /* 11 : 32 kbit/s */ - - L3UCHAR NIConTx; /* Network Indepentend Clock on transmit*/ - /* 0 : Not required to send data clc */ - /* 1 : Send data w/NIC clc */ - - L3UCHAR NIConRx; /* NIC on Rx */ - /* 0 : Cannot accept indep. clc */ - /* 1 : data with indep. clc accepted */ - - L3UCHAR FlowCtlTx; /* Flow control on Tx */ - /* 0 : Send Flow ctrl not required */ - /* 1 : Send flow ctrl required */ - - L3UCHAR FlowCtlRx; /* Flow control on Rx */ - /* 0 : cannot use receive flow ctrl */ - /* 1 : Receive flow ctrl accepted */ - L3UCHAR HDR; /* HDR/No HDR */ - L3UCHAR MultiFrame; /* Multi frame support */ - /* 0 : multiframe not supported */ - /* 1 : multiframe supported */ - - L3UCHAR ModeL1; /* Mode L1 */ - /* 0 : bit transparent mode of operat. */ - /* 1 : protocol sesitive mode of op. */ - - L3UCHAR NegotLLI; /* Negot. LLI */ - /* 0 : default LLI=256 only */ - /* 1 : Full protocol negotiation */ - - L3UCHAR Assignor; /* Assignor/Assignor ee */ - /* 0 : Default Asignee */ - /* 1 : Assignor only */ - - L3UCHAR InBandNeg; /* In-band negot. */ - /* 0 : negot done w/ USER INFO mes */ - /* 1 : negot done in-band w/link zero */ - - L3UCHAR NumStopBits; /* Number of stop bits */ - /* 00 : Not used */ - /* 01 : 1 bit */ - /* 10 : 1.5 bits */ - /* 11 : 2 bits */ - - L3UCHAR NumDataBits; /* Number of data bits. */ - /* 00 : not used */ - /* 01 : 5 bits */ - /* 10 : 7 bits */ - /* 11 : 8 bits */ - - L3UCHAR Parity; /* Parity Information */ - /* 000 : Odd */ - /* 010 : Even */ - /* 011 : None */ - /* 100 : Forced to 0 */ - /* 101 : Forced to 1 */ - - L3UCHAR DuplexMode; /* Mode duplex */ - /* 0 : Half duplex */ - /* 1 : Full duplex */ - - L3UCHAR ModemType; /* Modem type, see Q.931 p 89 */ - - L3UCHAR Layer2Ident; /* Layer 2 ident. */ - - L3UCHAR UIL2Prot; /* User information layer 2 protocol */ - /* 00001 : Basic mode ISO 1745 */ - /* 00010 : Q.921/I.441 */ - /* 00110 : X.25 single link */ - /* 00111 : X.25 multilink */ - /* 01000 : Extended LAPB T.71 */ - /* 01001 : HDLC ARM */ - /* 01010 : HDLC NRM */ - /* 01011 : HDLC ABM */ - /* 01100 : LAN logical link */ - /* 01101 : X.75 SLP */ - /* 01110 : Q.922 */ - /* 01111 : Q.922 core aspect */ - /* 10000 : User specified */ - /* 10001 : ISO/IEC 7776 DTE-DCE */ - - L3UCHAR ModeL2; /* Mode */ - /* 01 : Normal Mode of operation */ - /* 10 : Extended mode of operation */ - - L3UCHAR Q933use; /* Q.9333 use */ - - L3UCHAR UsrSpcL2Prot; /* User specified layer 2 protocol info */ - - L3UCHAR WindowSize; /* Window size (k) */ - - L3UCHAR Layer3Ident; /* Layer 3 ident */ - - L3UCHAR UIL3Prot; /* User Information Layer 3 protocol */ - /* 00010 : Q.931 */ - /* 00110 : X.25 */ - /* 00111 : 8208 */ - /* 01000 : X.233 ... */ - /* 01001 : 6473 */ - /* 01010 : T.70 */ - /* 01011 : ISO/IEC TR 9577 */ - /* 10000 : User specified */ - L3UCHAR OptL3Info; /* Optional Leyer 3 info */ - - L3UCHAR ModeL3; /* Mode of operation */ - /* 01 : Normal packed seq. numbering */ - /* 10 : Extended packed seq. numbering */ - - L3UCHAR DefPackSize; /* Default packet size */ - - L3UCHAR PackWinSize; /* Packet window size */ - - L3UCHAR AddL3Info; /* Additional Layer 3 protocol info */ - -} Q931ie_LLComp; - -/***************************************************************************** - - Struct: Q931ie_NetFac; - - Description: Network-specific facilities - -*****************************************************************************/ - -typedef struct { - - L3UCHAR IEId; /* 00100000 */ - L3UCHAR Size; /* Length of Information Element */ - L3UCHAR LenNetID; /* Length of network facilities id. */ - L3UCHAR TypeNetID; /* Type of network identification */ - L3UCHAR NetIDPlan; /* Network identification plan. */ - L3UCHAR NetFac; /* Network specific facility spec. */ - L3UCHAR NetID[1]; /* Network id. (IA5) */ - -} Q931ie_NetFac; - -/***************************************************************************** - - Struct: Q931ie_NotifInd; - - Description: Notification Indicator - -*****************************************************************************/ - -typedef struct { - - L3UCHAR IEId; /* 00100000 */ - L3UCHAR Size; /* Length of Information Element */ - L3UCHAR Notification; /* Notification descriptor */ - -} Q931ie_NotifInd; - -/***************************************************************************** - - Struct: Q931ie_ProgInd - - Description: Progress indicator - -*****************************************************************************/ - -typedef struct { - - L3UCHAR IEId; /* 00011110 */ - L3UCHAR Size; /* Length of Information Element */ - L3UCHAR CodStand; /* Coding standard */ - L3UCHAR Location; /* Location */ - L3UCHAR ProgDesc; /* Progress description */ - -} Q931ie_ProgInd; - -/***************************************************************************** - - Struct; Q931ie_Segment - - Description: Segmented message - -*****************************************************************************/ - -typedef struct { - - L3UCHAR IEId; /* 00000000 */ - L3UCHAR Size; /* Length of Information Element */ - L3UCHAR FSI; /* First segment indicator */ - L3UCHAR NumSegRem; /* Number of segments remaining */ - L3UCHAR SegType; /* Segment message type */ - -} Q931ie_Segment; - - -typedef struct { - - L3UCHAR IEId; /* 00000000 */ - L3UCHAR Size; /* Length of Information Element */ - -} Q931ie_SendComplete; - -/***************************************************************************** - - Struct: Q931ie_Signal - - Description: Signal - -*****************************************************************************/ - -typedef struct { - - L3UCHAR IEId; /* 00000000 */ - L3UCHAR Size; /* Length of Information Element */ - L3UCHAR Signal; /* Signal value */ - /* 00000000 Dial tone on */ - /* 00000001 Ring back tone on */ - /* 00000010 Intercept tone on */ - /* 00000011 Network congestion on */ - /* 00000100 Busy tone on */ - /* 00000101 Confirm tone on */ - /* 00000110 Answer tone on */ - /* 00000111 Call waiting tone */ - /* 00001000 Off-hook warning tone */ - /* 00001001 Pre-emption tone on */ - /* 00111111 Tones off */ - /* 01000000 Alerting on - pattern 0 */ - /* 01000001 Alerting on - pattern 1 */ - /* 01000010 Alerting on - pattern 2 */ - /* 01000011 Alerting on - pattern 3 */ - /* 01000100 Alerting on - pattern 4 */ - /* 01000101 Alerting on - pattern 5 */ - /* 01000110 Alerting on - pattern 6 */ - /* 01000111 Alerting on - pattern 7 */ - /* 01001111 Alerting off */ -} Q931ie_Signal; - -/***************************************************************************** - - Struct: Q931ie_TransDelSelInd - - description: Transit delay selection and indication - -*****************************************************************************/ -#ifdef Q931_X25_SUPPORT -typedef struct { - - L3UCHAR IEId; /* 00000000 */ - L3UCHAR Size; /* Length of Information Element */ - L3ULONG TxDSIValue; /* Trans. delay sel. & ind. value */ - -} Q931ie_TransDelSelInd; -#endif - -/***************************************************************************** - - Struct: Q931ie_TransNetSel - - Description: Transit network selection - -*****************************************************************************/ - -typedef struct { - - L3UCHAR IEId; /* 01111000 */ - L3UCHAR Size; /* Length of Information Element */ - L3UCHAR Type; /* Type of network identifier */ - L3UCHAR NetIDPlan; /* Network idetification plan */ - L3UCHAR NetID[1]; /* Network identification(IA5) */ - -} Q931ie_TransNetSel; - -/***************************************************************************** - - Struct: Q931ie_UserUser - - Description: User-user - -*****************************************************************************/ - -typedef struct { - - L3UCHAR IEId; /* 01111110 */ - L3UCHAR Size; /* Length of Information Element */ - L3UCHAR ProtDisc; /* Protocol discriminator */ - L3UCHAR User[1]; /* User information */ - -} Q931ie_UserUser; - -/***************************************************************************** - - Struct: Q931ie_ClosedUserGrp - - Description: Closed user group - -*****************************************************************************/ -#ifdef Q931_X25_SUPPORT -typedef struct { - - L3UCHAR IEId; /* 01000111 */ - L3UCHAR Size; /* Length of Information Element */ - L3UCHAR CUGInd; /* CUG indication */ - L3UCHAR CUG[1]; /* CUG index code (IA5) */ - -} Q931ie_ClosedUserGrp; -#endif - -/***************************************************************************** - - Struct: Q931ie_CongLevel - - Description: Congestion Level - -*****************************************************************************/ -typedef struct { - - L3UCHAR IEId; /* 01000111 */ - L3UCHAR Size; /* Length of Information Element */ - L3UCHAR CongLevel; /* Conguestion Level */ - -} Q931ie_CongLevel; - -/***************************************************************************** - - Struct: Q931ie_EndEndTxDelay - - Description: End to end transit delay - -*****************************************************************************/ -#ifdef Q931_X25_SUPPORT -typedef struct { - - L3UCHAR IEId; /* 01000010 */ - L3UCHAR Size; /* Length of Information Element */ - L3ULONG CumTxDelay; /* Cumulative transit delay value */ - L3ULONG ReqTxDelay; /* Requested end to end transit delay */ - L3ULONG MaxTxDelay; /* Maximum transit delay */ - -} Q931ie_EndEndTxDelay; -#endif - -/***************************************************************************** - - Struct: Q931ie_InfoRate - - Description: Information Rate - -*****************************************************************************/ -#ifdef Q931_X25_SUPPORT -typedef struct { - - L3UCHAR IEId; /* 01100000 */ - L3UCHAR Size; /* Length of Information Element */ - L3UCHAR InInfoRate; /* Incoming information rate */ - L3UCHAR OutInfoRate; /* Outgoing information rate */ - L3UCHAR MinInInfoRate; /* Minimum incoming information rate */ - L3UCHAR MinOutInfoRate; /* Minimum outgoing information rate */ - -} Q931ie_InfoRate; -#endif - -/***************************************************************************** - - Struct: Q931ie_PackParam - - Description: Packed layer binary parameters - -*****************************************************************************/ -#ifdef Q931_X25_SUPPORT -typedef struct { - - L3UCHAR IEId; /* 01000100 */ - L3UCHAR Size; /* Length of Information Element */ - L3UCHAR FastSel; /* Fast selected */ - L3UCHAR ExpData; /* Exp. data */ - L3UCHAR DelConf; /* Delivery conf */ - L3UCHAR Modulus; /* Modulus */ - -} Q931ie_PackParam; -#endif - -/***************************************************************************** - - Struct: Q931ie_PackWinSize - - Description: Packed window size - -*****************************************************************************/ -#ifdef Q931_X25_SUPPORT -typedef struct { - - L3UCHAR IEId; /* 01000101 */ - L3UCHAR Size; /* Length of Information Element */ - L3UCHAR ForwardValue; /* Forward value */ - L3UCHAR BackwardValue; /* Backward value */ - -} Q931ie_PackWinSize; -#endif - -/***************************************************************************** - - Struct: Q931ie_PackSize - - Description: Packet size - -*****************************************************************************/ -#ifdef Q931_X25_SUPPORT -typedef struct { - - L3UCHAR IEId; /* 01000110 */ - L3UCHAR Size; /* Length of Information Element */ - L3UCHAR ForwardValue; /* Forward value */ - L3UCHAR BackwardValue; /* Backward value */ - -} Q931ie_PackSize; -#endif - -/***************************************************************************** - - Struct: Q931ie_RedirNum - - Description: Redirecting number - -*****************************************************************************/ -#ifdef Q931_X25_SUPPORT -typedef struct { - - L3UCHAR IEId; /* 01110100 */ - L3UCHAR Size; /* Length of Information Element */ - L3UCHAR TypeNum; /* Type of number */ - L3UCHAR NumPlanID; /* Number plan identification */ - L3UCHAR PresInd; /* Presentation indicator */ - L3UCHAR ScreenInd; /* Screening indicator */ - L3UCHAR Reason; /* Reason for redirection */ - L3UCHAR Digit[1]; /* Number digits (IA5) */ - -} Q931ie_RedirNum; -#endif - -typedef struct { - - L3UCHAR IEId; /* 01110100 */ - L3UCHAR Size; /* Length of Information Element */ - L3UCHAR RepeatInd; /* 0010 Prioritized list for selecting */ - /* one possible. */ -} Q931ie_RepeatInd; - -typedef struct { - - L3UCHAR IEId; /* 01110100 */ - L3UCHAR Size; /* Length of Information Element */ - L3UCHAR Spare; /* Spare */ - L3UCHAR Class; /* Class */ - /* 000 Indicate channels */ - /* 110 Single interface */ - /* 111 All interfaces */ -} Q931ie_RestartInd; - -typedef struct { - - L3UCHAR IEId; /* 01110100 */ - L3UCHAR Size; /* Length of Information Element */ - L3UCHAR Preference; /* Preference 0 = reserved, 1 = channel */ - L3UCHAR Spare; /* Spare */ - L3UCHAR NewStatus; /* NewStatus */ - /* 000 In service */ - /* 001 Maintenance */ - /* 010 Out of service */ -} Q931ie_ChangeStatus; - -/***************************************************************************** - - Struct: Q931ie_GenericDigits - - -*****************************************************************************/ - -typedef struct { - - L3UCHAR IEId; /* 00110111 */ - L3UCHAR Size; /* Length of Information Element */ - L3UCHAR Type; /* Type of number */ - L3UCHAR Encoding; /* Encoding of number */ - L3UCHAR Digit[1]; /* Number digits (IA5) */ - -} Q931ie_GenericDigits; - - -/***************************************************************************** - - Q.931 Information Element Pack/Unpack functions. Implemented in Q931ie.c - -*****************************************************************************/ -q931pie_func_t Q931Pie_ChangeStatus; -q931pie_func_t Q931Pie_BearerCap; -q931pie_func_t Q931Pie_ChanID; -q931pie_func_t Q931Pie_ProgInd; -q931pie_func_t Q931Pie_Display; -q931pie_func_t Q931Pie_Signal; -q931pie_func_t Q931Pie_HLComp; -q931pie_func_t Q931Pie_Segment; -q931pie_func_t Q931Pie_DateTime; -q931pie_func_t Q931Pie_Cause; -q931pie_func_t Q931Pie_SendComplete; -q931pie_func_t Q931Pie_KeypadFac; -q931pie_func_t Q931Pie_NotifInd; -q931pie_func_t Q931Pie_CallID; -q931pie_func_t Q931Pie_RepeatInd; -q931pie_func_t Q931Pie_NetFac; -q931pie_func_t Q931Pie_CallingNum; -q931pie_func_t Q931Pie_CallingSub; -q931pie_func_t Q931Pie_CalledNum; -q931pie_func_t Q931Pie_CalledSub; -q931pie_func_t Q931Pie_CalledNum; -q931pie_func_t Q931Pie_TransNetSel; -q931pie_func_t Q931Pie_LLComp; -q931pie_func_t Q931Pie_CallState; -q931pie_func_t Q931Pie_RestartInd; -q931pie_func_t Q931Pie_UserUser; - -q931pie_func_t Q931Pie_GenericDigits; - -L3USHORT Q931Uie_CRV(Q931_TrunkInfo_t *pTrunk,L3UCHAR * IBuf, L3UCHAR *OBuf, L3INT *IOff, L3INT *OOff); - -q931uie_func_t Q931Uie_ChangeStatus; -q931uie_func_t Q931Uie_BearerCap; -q931uie_func_t Q931Uie_ChanID; -q931uie_func_t Q931Uie_ProgInd; -q931uie_func_t Q931Uie_Display; -q931uie_func_t Q931Uie_Signal; -q931uie_func_t Q931Uie_HLComp; -q931uie_func_t Q931Uie_Segment; -q931uie_func_t Q931Uie_DateTime; -q931uie_func_t Q931Uie_Cause; -q931uie_func_t Q931Uie_SendComplete; -q931uie_func_t Q931Uie_KeypadFac; -q931uie_func_t Q931Uie_NotifInd; -q931uie_func_t Q931Uie_CallID; -q931uie_func_t Q931Uie_RepeatInd; -q931uie_func_t Q931Uie_NetFac; -q931uie_func_t Q931Uie_CallingNum; -q931uie_func_t Q931Uie_CallingSub; -q931uie_func_t Q931Uie_CalledNum; -q931uie_func_t Q931Uie_CalledSub; -q931uie_func_t Q931Uie_TransNetSel; -q931uie_func_t Q931Uie_LLComp; -q931uie_func_t Q931Uie_CallState; -q931uie_func_t Q931Uie_RestartInd; -q931uie_func_t Q931Uie_UserUser; - -q931uie_func_t Q931Uie_GenericDigits; - - -L3INT Q931ReadExt(L3UCHAR * IBuf, L3INT Off); -L3INT Q931Uie_CongLevel(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff); -L3INT Q931Pie_CongLevel(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet); -L3INT Q931Uie_RevChargeInd(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff); -L3INT Q931Pie_RevChargeInd(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet); - -L3INT Q931Uie_Generic(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *IOff, L3INT *OOff); -L3INT Q931Pie_Generic(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet); - -#endif /* _Q931IE_NL */ diff --git a/libs/freetdm/src/isdn/include/Q932.h b/libs/freetdm/src/isdn/include/Q932.h deleted file mode 100644 index 9b69a34a02..0000000000 --- a/libs/freetdm/src/isdn/include/Q932.h +++ /dev/null @@ -1,95 +0,0 @@ -/***************************************************************************** - - FileName: Q932.h - - Contents: Header w/structs for Q932 Suplementary Services. - - NB: Do NOT include this header directly, include Q931.h - - License/Copyright: - - Copyright (c) 2007, Jan Vidar Berger, Case Labs, Ltd. All rights reserved. - email:janvb@caselaboratories.com - - 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 Case Labs, Ltd 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT OWNER OR CONTRIBUTORS 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 SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*****************************************************************************/ - -/***************************************************************************** - Q.932 Additional Message codes -*****************************************************************************/ - -#define Q932mes_HOLD 0x24 /* 0010 0100 */ -#define Q932mes_HOLD_ACKNOWLEDGE 0x28 /* 0010 1000 */ -#define Q932mes_HOLD_REJECT 0x30 /* 0011 0000 */ -#define Q932mes_RETRIEVE 0x31 /* 0011 0001 */ -#define Q932mes_RETRIEVE_ACKNOWLEDGE 0x33 /* 0011 0011 */ -#define Q932mes_RETRIEVE_REJECT 0x37 /* 0011 0111 */ -#define Q932mes_FACILITY 0x62 /* 0110 0010 */ -#define Q932mes_REGISTER 0x64 /* 0110 0100 */ - -/***************************************************************************** - Q.932 Additional EI Codes -*****************************************************************************/ -#define Q932ie_FACILITY 0x1c /* 0001 1100 */ - -/***************************************************************************** - Function Prototypes. -*****************************************************************************/ -L3INT Q932ProcFacilityTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * b, L3INT iFrom); -L3INT Q932ProcHoldTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * b, L3INT iFrom); -L3INT Q932ProcHoldAckTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * b, L3INT iFrom); -L3INT Q932ProcHoldRejectTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * b, L3INT iFrom); -L3INT Q932ProcRegisterTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * b, L3INT iFrom); -L3INT Q932ProcRetrieveTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * b, L3INT iFrom); -L3INT Q932ProcRetrieveAckTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * b, L3INT iFrom); -L3INT Q932ProcRetrieveRejectTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * b, L3INT iFrom); - -L3INT Q932ProcFacilityNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * b, L3INT iFrom); -L3INT Q932ProcHoldNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * b, L3INT iFrom); -L3INT Q932ProcHoldAckNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * b, L3INT iFrom); -L3INT Q932ProcHoldRejectNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * b, L3INT iFrom); -L3INT Q932ProcRegisterNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * b, L3INT iFrom); -L3INT Q932ProcRetrieveNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * b, L3INT iFrom); -L3INT Q932ProcRetrieveAckNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * b, L3INT iFrom); -L3INT Q932ProcRetrieveRejectNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * b, L3INT iFrom); - -L3INT Q932Pmes_Facility(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); -L3INT Q932Pmes_Hold(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); -L3INT Q932Pmes_HoldAck(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); -L3INT Q932Pmes_HoldReject(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); -L3INT Q932Pmes_Register(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); -L3INT Q932Pmes_Retrieve(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); -L3INT Q932Pmes_RetrieveAck(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); -L3INT Q932Pmes_RetrieveReject(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); - -L3INT Q932Umes_Facility(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic * OBuf, L3INT I, L3INT O); -L3INT Q932Umes_Hold(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic * OBuf, L3INT I, L3INT O); -L3INT Q932Umes_HoldAck(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic * OBuf, L3INT I, L3INT O); -L3INT Q932Umes_HoldReject(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic * OBuf, L3INT I, L3INT O); -L3INT Q932Umes_Register(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic * OBuf, L3INT I, L3INT O); -L3INT Q932Umes_Retrieve(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic * OBuf, L3INT I, L3INT O); -L3INT Q932Umes_RetrieveAck(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic * OBuf, L3INT I, L3INT O); -L3INT Q932Umes_RetrieveReject(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic * OBuf, L3INT I, L3INT O); diff --git a/libs/freetdm/src/isdn/include/mfifo.h b/libs/freetdm/src/isdn/include/mfifo.h deleted file mode 100644 index 4c1d850d81..0000000000 --- a/libs/freetdm/src/isdn/include/mfifo.h +++ /dev/null @@ -1,85 +0,0 @@ -/***************************************************************************** - - Filename: mfifo.h - - Contents: header for MFIFO - - License/Copyright: - - Copyright (c) 2007, Jan Vidar Berger, Case Labs, Ltd. All rights reserved. - email:janvb@caselaboratories.com - - 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 Case Labs, Ltd 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT OWNER OR CONTRIBUTORS 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 SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*****************************************************************************/ -#ifndef _MFIFO -#define _MFIFO - -/***************************************************************************** - - Struct: MINDEX - - Description: Message Index used to index a dynamic size Message FIFO. - -*****************************************************************************/ -typedef struct _mindex { - int offset; /* offset to message in buf */ - int size; /* size of message in bytes */ -} MINDEX; - -/***************************************************************************** - - Struct: MFIFO - - Description: Message FIFO. Provides a dynamic sized message based FIFO - queue. - -*****************************************************************************/ -typedef struct { - int first; /* first out */ - int last; /* last in + 1 */ - int bsize; /* buffer size */ - unsigned char *buf; /* ptr to start of buffer */ - int ixsize; /* index size */ - MINDEX ix[1]; /* message index */ -} MFIFO; - -/***************************************************************************** - Function prototypes. -*****************************************************************************/ -int MFIFOCreate(unsigned char *buf, int size, int index); -void MFIFOClear(unsigned char * buf); -int MFIFOGetLBOffset(unsigned char *buf); -int MFIFOGetFBOffset(unsigned char *buf); -void MFIFOWriteIX(unsigned char *buf, unsigned char *mes, int size, int ix, int off); -int MFIFOWriteMes(unsigned char *buf, unsigned char *mes, int size); -unsigned char * MFIFOGetMesPtr(unsigned char *buf, int *size); -void MFIFOKillNext(unsigned char *buf); - -unsigned char * MFIFOGetMesPtrOffset(unsigned char *buf, int *size, const int pos); -int MFIFOGetMesCount(unsigned char *buf); -int MFIFOWriteMesOverwrite(unsigned char *buf, unsigned char *mes, int size); - -#endif diff --git a/libs/freetdm/src/isdn/include/national.h b/libs/freetdm/src/isdn/include/national.h deleted file mode 100644 index cff26aa4a4..0000000000 --- a/libs/freetdm/src/isdn/include/national.h +++ /dev/null @@ -1,86 +0,0 @@ -/****************************************************************************** - - FileName: national.h - - Contents: Header and definition for the National ISDN dialect. The - header contents the following parts: - - Definition of codes - - Definition of information elements (nationalie_). - - Definition of messages (nationalmes_). - - Function prototypes. - - Description: The National ISDN dialect here covers ???? - - Related Files: national.h National ISDN Definitions - nationalie.c National ISDN IE encoders/coders - nationalStateTE.c National ISDN TE State Engine - nationalStateNT.c National ISDN NT State Engine - - License/Copyright: - - Copyright (c) 2007, Jan Vidar Berger, Case Labs, Ltd. All rights reserved. - email:janvb@caselaboratories.com - - Copyright (c) 2007, Michael Jerris. All rights reserved. - email:mike@jerris.com - - 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 Case Labs, Ltd 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT OWNER OR CONTRIBUTORS 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 SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -******************************************************************************/ - -#ifndef _national_NATIONAL_NL -#define _national_NATIONAL_NL - -#include "Q931.h" - -/***************************************************************************** - - Q.931 Message codes - Only National specific message and ie types - here the rest are inherited from national.h - -*****************************************************************************/ - - -/***************************************************************************** - - Q.931 Message Pack/Unpack functions. Implemented in nationalmes.c - -*****************************************************************************/ -L3INT nationalUmes_Setup(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT IOff, L3INT Size); -L3INT nationalPmes_Setup(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); - -#include "DMS.h" - -/***************************************************************************** - - Q.931 Process Function Prototyping. Implemented in nationalStateTE.c - -*****************************************************************************/ - -void nationalCreateTE(L3UCHAR i); -void nationalCreateNT(L3UCHAR i); - -#endif /* _national_NATIONAL_NL */ diff --git a/libs/freetdm/src/isdn/mfifo.c b/libs/freetdm/src/isdn/mfifo.c deleted file mode 100644 index 28528f9b64..0000000000 --- a/libs/freetdm/src/isdn/mfifo.c +++ /dev/null @@ -1,399 +0,0 @@ -/***************************************************************************** - - Filename: mfifo.c - - Description: mfifo is a message orriented fifo system with support of - both message and byte per byte retriaval of messages. - - The fifo has been designed with two usages in mind: - - - Queueing of frames for hdlc and feeding out byte per byte - with the possibility of re-sending of frames etc. - - - fifo for messages of dynamic size. - - The fifo is allocated on top of any buffer and creates an - index of message in the queue. The user can write/read - messages or write messages and read the message one byte - at the time. - - Interface: - MFIFOCreate Create/reset/initialize fifo. - MFIFOClear Clear FIFO. - MFIFOWriteMes Write message into fifo - * MFIFOReadMes Read message from fifo. - MFIFOGetMesPtr Get ptr to next message. - MFIFOKillNext Kill next message. - - * currently not implemented. - - Note: The message will always be saved continuously. If there is not - sufficient space at the end of the buffer, the fifo will skip - the last bytes and save the message at the top of the buffer. - - This is required to allow direct ptr access to messages - stored in the queue. - - License/Copyright: - - Copyright (c) 2007, Jan Vidar Berger, Case Labs, Ltd. All rights reserved. - email:janvb@caselaboratories.com - - 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 Case Labs, Ltd 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT OWNER OR CONTRIBUTORS 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 SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*****************************************************************************/ - -#include "mfifo.h" -#include -#include - -/***************************************************************************** - - Function: MFIFOCreate - - Description: Creates a fifo on top of an existing buffer. - - Parameters: buf ptr to buffer. - size size of buffer in bytes. - index size of index entries (max no messages). - - Return value: 0 if failure, 1 if ok. - -*****************************************************************************/ -int MFIFOCreate(unsigned char *buf, int size, int index) -{ - MFIFO *mf = (MFIFO *)buf; - - mf->first = mf->last = 0; - mf->ixsize = index; - mf->buf = &buf[sizeof(MFIFO) + (sizeof(MINDEX) * index)]; - - if (mf->buf > &buf[size]) - return 0; - - mf->bsize = size - sizeof(MFIFO) - (sizeof(MINDEX) * index); - - return 1; -} - -/***************************************************************************** - - Function: MFIFOClear - - Description: Clear the FIFO - - Paremeters: buf ptr to fifo - - Return Value: none - -*****************************************************************************/ -void MFIFOClear(unsigned char * buf) -{ - MFIFO *mf = (MFIFO *)buf; - - mf->first = mf->last = 0; -} - -/***************************************************************************** - - Function: MFIFOGetLBOffset - - Description: Helper function caclulating offset to the 'first out' byte. - - Paremeters: buf ptr to fifo - - Return Value: offset. - -*****************************************************************************/ -int MFIFOGetLBOffset(unsigned char *buf) -{ - MFIFO *mf = (MFIFO *)buf; - - if (mf->last != mf->first) - return mf->ix[mf->last].offset; - - return 0; -} - -/***************************************************************************** - - Function: MFIFOGetFBOffset - - Description: Helper function calculating the offset to the 'first in' - byte in the buffer. This is the position the next byte - entering the fifo will occupy. - - Paremeters: buf ptr to fifo - - Return Value: offset - -*****************************************************************************/ -int MFIFOGetFBOffset(unsigned char *buf) -{ - MFIFO *mf = (MFIFO *)buf; - int x; - - if (mf->last == mf->first) - return 0; - - x = mf->first - 1; - - if (x < 0) - x = mf->ixsize - 1; - - return mf->ix[x].offset + mf->ix[x].size; -} - -/***************************************************************************** - - Function: MFIFOWriteIX - - Description: Helper function writing a calculated entry. The function - will perform a memcpy to move the message and set the index - values as well as increase the 'first in' index. - - Paremeters: buf ptr to fifo - mes ptr to message - size size of message in bytes. - ix index to index entry. - off offset to position to receive the message - - Return Value: none - -*****************************************************************************/ -void MFIFOWriteIX(unsigned char *buf, unsigned char *mes, int size, int ix, int off) -{ - MFIFO *mf = (MFIFO *)buf; - int x; - - memcpy(&mf->buf[off], mes, size); - mf->ix[ix].offset = off; - mf->ix[ix].size = size; - - x = mf->first + 1; - - if (x >= mf->ixsize) - x = 0; - - mf->first = x; -} - -/***************************************************************************** - - Function: MFIFOWriteMes - - Description: - - Paremeters: - - Return Value: - -*****************************************************************************/ -int MFIFOWriteMes(unsigned char *buf, unsigned char *mes, int size) -{ - MFIFO *mf = (MFIFO *)buf; - int of, ol, x; - - x = mf->first + 1; - - if (x >= mf->ixsize) - x = 0; - - if (x == mf->last) - return 0; /* full queue */ - - of = MFIFOGetFBOffset(buf); - ol = MFIFOGetLBOffset(buf); - if (mf->last == mf->first) { /* empty queue */ - mf->first = mf->last = 0; /* optimize */ - - MFIFOWriteIX(buf, mes, size, mf->first, 0); - return 1; - } - else if (of > ol) { - if (mf->bsize - of >= size) { - MFIFOWriteIX(buf, mes, size, mf->first, of); - return 1; - } - else if (ol > size) { - MFIFOWriteIX(buf, mes, size, mf->first, ol); - return 1; - } - } - else if (ol - of > size) { - MFIFOWriteIX(buf, mes, size, mf->first, of); - return 1; - } - - return 0; -} - -/***************************************************************************** - - Function: MFIFOGetMesPtr - - Description: - - Paremeters: - - Return Value: - -*****************************************************************************/ -unsigned char * MFIFOGetMesPtr(unsigned char *buf, int *size) -{ - MFIFO *mf = (MFIFO *)buf; - - if (mf->first == mf->last) { - return NULL; - } - - *size = mf->ix[mf->last].size; - return &mf->buf[mf->ix[mf->last].offset]; -} - -/***************************************************************************** - - Function: MFIFOKillNext - - Description: - - Paremeters: - - Return Value: - -*****************************************************************************/ -void MFIFOKillNext(unsigned char *buf) -{ - MFIFO *mf = (MFIFO *)buf; - int x; - - if (mf->first != mf->last) { - x = mf->last + 1; - if (x >= mf->ixsize) { - x = 0; - } - - mf->last = x; - } -} - - -/* - * Queue-style accessor functions - */ - -/** - * MFIFOGetMesPtrOffset - * \brief Get pointer to and size of message at position x - */ -unsigned char * MFIFOGetMesPtrOffset(unsigned char *buf, int *size, const int pos) -{ - MFIFO *mf = (MFIFO *)buf; - int x; - - if (mf->first == mf->last) { - return NULL; - } - - if (pos < 0 || pos >= mf->ixsize) { - return NULL; - } - - x = pos - mf->last; - if (x < 0) { - x += (mf->ixsize - 1); - } - - *size = mf->ix[x].size; - return &mf->buf[mf->ix[x].offset]; -} - - -/** - * MFIFOGetMesCount - * \brief How many messages are currently in the buffer? - */ -int MFIFOGetMesCount(unsigned char *buf) -{ - MFIFO *mf = (MFIFO *)buf; - - if (mf->first == mf->last) { - return 0; - } - else if (mf->first > mf->last) { - return mf->first - mf->last; - } - else { - return (mf->ixsize - mf->last) + mf->first; - } -} - -/** - * MFIFOWriteMesOverwrite - * \brief Same as MFIFOWriteMes but old frames will be overwritten if the fifo is full - */ -int MFIFOWriteMesOverwrite(unsigned char *buf, unsigned char *mes, int size) -{ - MFIFO *mf = (MFIFO *)buf; - int of, ol, x; - - x = mf->first + 1; - - if (x >= mf->ixsize) - x = 0; - - if (x == mf->last) { - /* advance last pointer */ - mf->last++; - - if (mf->last >= mf->ixsize) - mf->last = 0; - } - - of = MFIFOGetFBOffset(buf); - ol = MFIFOGetLBOffset(buf); - - if (mf->last == mf->first) { /* empty queue */ - mf->first = mf->last = 0; /* optimize */ - - MFIFOWriteIX(buf, mes, size, mf->first, 0); - return 1; - } - else if (of > ol) { - if (mf->bsize - of >= size) { - MFIFOWriteIX(buf, mes, size, mf->first, of); - return 1; - } - else if (ol > size) { - MFIFOWriteIX(buf, mes, size, mf->first, ol); - return 1; - } - } - else if (ol - of > size) { - MFIFOWriteIX(buf, mes, size, mf->first, of); - return 1; - } - return 0; -} diff --git a/libs/freetdm/src/isdn/nationalStateNT.c b/libs/freetdm/src/isdn/nationalStateNT.c deleted file mode 100644 index b150999650..0000000000 --- a/libs/freetdm/src/isdn/nationalStateNT.c +++ /dev/null @@ -1,130 +0,0 @@ -/***************************************************************************** - - FileName: nationalStateNT.c - - Contents: National ISDN State Engine for NT (Network Mode). - - The controlling state engine for Q.931 is the state engine - on the NT side. The state engine on the TE side is a slave - of this. The TE side maintain it's own states as described in - ITU-T Q931, but will in raise conditions be overridden by - the NT side. - - License/Copyright: - - Copyright (c) 2007, Jan Vidar Berger, Case Labs, Ltd. All rights reserved. - email:janvb@caselaboratories.com - - Copyright (c) 2007, Michael Jerris. All rights reserved. - email:mike@jerris.com - - 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 Case Labs, Ltd 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT OWNER OR CONTRIBUTORS 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 SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*****************************************************************************/ - -#include "national.h" - -/***************************************************************************** - Function: nationalCreateNT - - Description: Will create the National ISDN NT as a Dialect in the stack. The first - bulk set up the message handlers, the second bulk the IE - encoders/coders, and the last bulk set up the state table. - - Parameters: i Dialect index -*****************************************************************************/ -void nationalCreateNT(L3UCHAR i) -{ - Q931SetMesProc(Q931mes_ALERTING, i, Q931ProcAlertingNT, Q931Umes_Alerting, Q931Pmes_Alerting); - Q931SetMesProc(Q931mes_CALL_PROCEEDING, i, Q931ProcCallProceedingNT, Q931Umes_CallProceeding, Q931Pmes_CallProceeding); - Q931SetMesProc(Q931mes_CONNECT, i, Q931ProcConnectNT, Q931Umes_Connect, Q931Pmes_Connect); - Q931SetMesProc(Q931mes_CONNECT_ACKNOWLEDGE, i, Q931ProcConnectAckNT, Q931Umes_ConnectAck, Q931Pmes_ConnectAck); - Q931SetMesProc(Q931mes_PROGRESS, i, Q931ProcProgressNT, Q931Umes_Progress, Q931Pmes_Progress); - Q931SetMesProc(Q931mes_SETUP, i, Q931ProcSetupNT, nationalUmes_Setup, nationalPmes_Setup); - Q931SetMesProc(Q931mes_SETUP_ACKNOWLEDGE, i, Q931ProcSetupAckNT, Q931Umes_SetupAck, Q931Pmes_SetupAck); - Q931SetMesProc(Q931mes_RESUME, i, Q931ProcResumeNT, Q931Umes_Resume, Q931Pmes_Resume); - Q931SetMesProc(Q931mes_RESUME_ACKNOWLEDGE, i, Q931ProcResumeAckNT, Q931Umes_ResumeAck, Q931Pmes_ResumeAck); - Q931SetMesProc(Q931mes_RESUME_REJECT, i, Q931ProcResumeRejectNT, Q931Umes_ResumeReject, Q931Pmes_ResumeReject); - Q931SetMesProc(Q931mes_SUSPEND, i, Q931ProcSuspendNT, Q931Umes_Suspend, Q931Pmes_Suspend); - Q931SetMesProc(Q931mes_SUSPEND_ACKNOWLEDGE, i, Q931ProcSuspendAckNT, Q931Umes_SuspendAck, Q931Pmes_SuspendAck); - Q931SetMesProc(Q931mes_SUSPEND_REJECT, i, Q931ProcSuspendRejectNT, Q931Umes_SuspendReject, Q931Pmes_SuspendReject); - Q931SetMesProc(Q931mes_USER_INFORMATION, i, Q931ProcUserInformationNT, Q931Umes_UserInformation, Q931Pmes_UserInformation); - Q931SetMesProc(Q931mes_DISCONNECT, i, Q931ProcDisconnectNT, Q931Umes_Disconnect, Q931Pmes_Disconnect); - Q931SetMesProc(Q931mes_RELEASE, i, Q931ProcReleaseNT, Q931Umes_Release, Q931Pmes_Release); - Q931SetMesProc(Q931mes_RELEASE_COMPLETE, i, Q931ProcReleaseCompleteNT, Q931Umes_ReleaseComplete, Q931Pmes_ReleaseComplete); - Q931SetMesProc(Q931mes_RESTART, i, Q931ProcRestartNT, Q931Umes_Restart, Q931Pmes_Restart); - Q931SetMesProc(Q931mes_RESTART_ACKNOWLEDGE, i, Q931ProcRestartAckNT, Q931Umes_RestartAck, Q931Pmes_RestartAck); - Q931SetMesProc(Q931mes_CONGESTION_CONTROL, i, Q931ProcCongestionControlNT, Q931Umes_CongestionControl, Q931Pmes_CongestionControl); - Q931SetMesProc(Q931mes_INFORMATION, i, Q931ProcInformationNT, Q931Umes_Information, Q931Pmes_Information); - Q931SetMesProc(Q931mes_NOTIFY, i, Q931ProcNotifyNT, Q931Umes_Notify, Q931Pmes_Notify); - Q931SetMesProc(Q931mes_STATUS, i, Q931ProcStatusNT, Q931Umes_Status, Q931Pmes_Status); - Q931SetMesProc(Q931mes_STATUS_ENQUIRY, i, Q931ProcStatusEnquiryNT, Q931Umes_StatusEnquiry, Q931Pmes_StatusEnquiry); - Q931SetMesProc(Q931mes_SEGMENT, i, Q931ProcSegmentNT, Q931Umes_Segment, Q931Pmes_Segment); - - Q931SetMesProc(Q932mes_FACILITY, i, Q932ProcFacilityNT, Q932Umes_Facility, Q932Pmes_Facility); - Q931SetMesProc(Q932mes_HOLD, i, Q932ProcHoldNT, Q932Umes_Hold, Q932Pmes_Hold); - Q931SetMesProc(Q932mes_HOLD_ACKNOWLEDGE, i, Q932ProcHoldAckNT, Q932Umes_HoldAck, Q932Pmes_HoldAck); - Q931SetMesProc(Q932mes_HOLD_REJECT, i, Q932ProcHoldRejectNT, Q932Umes_HoldReject, Q932Pmes_HoldReject); - Q931SetMesProc(Q932mes_REGISTER, i, Q932ProcRegisterNT, Q932Umes_Register, Q932Pmes_Register); - Q931SetMesProc(Q932mes_RETRIEVE, i, Q932ProcRetrieveNT, Q932Umes_Retrieve, Q932Pmes_Retrieve); - Q931SetMesProc(Q932mes_RETRIEVE_ACKNOWLEDGE, i, Q932ProcRetrieveAckNT, Q932Umes_RetrieveAck, Q932Pmes_RetrieveAck); - Q931SetMesProc(Q932mes_RETRIEVE_REJECT, i, Q932ProcRetrieveRejectNT, Q932Umes_RetrieveReject, Q932Pmes_RetrieveReject); - - /* Set up the IE encoder/decoder handle table.*/ - Q931SetIEProc(Q931ie_SEGMENTED_MESSAGE, i, Q931Pie_Segment, Q931Uie_Segment); - Q931SetIEProc(Q931ie_BEARER_CAPABILITY, i, Q931Pie_BearerCap, Q931Uie_BearerCap); - Q931SetIEProc(Q931ie_CAUSE, i, Q931Pie_Cause, Q931Uie_Cause); - Q931SetIEProc(Q931ie_CALL_IDENTITY, i, Q931Pie_CallID, Q931Uie_CallID); - Q931SetIEProc(Q931ie_CALL_STATE, i, Q931Pie_CallState, Q931Uie_CallState); - Q931SetIEProc(Q931ie_CHANNEL_IDENTIFICATION, i, Q931Pie_ChanID, Q931Uie_ChanID); - Q931SetIEProc(Q931ie_PROGRESS_INDICATOR, i, Q931Pie_ProgInd, Q931Uie_ProgInd); - Q931SetIEProc(Q931ie_NETWORK_SPECIFIC_FACILITIES, i, Q931Pie_NetFac, Q931Uie_NetFac); - Q931SetIEProc(Q931ie_NOTIFICATION_INDICATOR, i, Q931Pie_NotifInd, Q931Uie_NotifInd); - Q931SetIEProc(Q931ie_DISPLAY, i, Q931Pie_Display, Q931Uie_Display); - Q931SetIEProc(Q931ie_DATETIME, i, Q931Pie_DateTime, Q931Uie_DateTime); - Q931SetIEProc(Q931ie_KEYPAD_FACILITY, i, Q931Pie_KeypadFac, Q931Uie_KeypadFac); - Q931SetIEProc(Q931ie_SIGNAL, i, Q931Pie_Signal, Q931Uie_Signal); - Q931SetIEProc(Q931ie_TRANSIT_DELAY_SELECTION_AND_IND, i, Q931Pie_TransNetSel, Q931Uie_TransNetSel); - Q931SetIEProc(Q931ie_CALLING_PARTY_NUMBER, i, Q931Pie_CallingNum, Q931Uie_CallingNum); - Q931SetIEProc(Q931ie_CALLING_PARTY_SUBADDRESS, i, Q931Pie_CallingSub, Q931Uie_CallingSub); - Q931SetIEProc(Q931ie_CALLED_PARTY_NUMBER, i, Q931Pie_CalledNum, Q931Uie_CalledNum); - Q931SetIEProc(Q931ie_CALLED_PARTY_SUBADDRESS, i, Q931Pie_CalledSub, Q931Uie_CalledSub); - Q931SetIEProc(Q931ie_TRANSIT_NETWORK_SELECTION, i, Q931Pie_TransNetSel, Q931Uie_TransNetSel); - Q931SetIEProc(Q931ie_RESTART_INDICATOR, i, Q931Pie_RestartInd, Q931Uie_RestartInd); - Q931SetIEProc(Q931ie_LOW_LAYER_COMPATIBILITY, i, Q931Pie_LLComp, Q931Uie_LLComp); - Q931SetIEProc(Q931ie_HIGH_LAYER_COMPATIBILITY, i, Q931Pie_HLComp, Q931Uie_HLComp); - Q931SetIEProc(Q931ie_USER_USER, i, Q931Pie_UserUser, Q931Uie_UserUser); - Q931SetIEProc(Q931ie_GENERIC_DIGITS, i, Q931Pie_GenericDigits, Q931Uie_GenericDigits); - - Q931SetIEProc(Q931ie_CONNECTED_NUMBER, i, Q931Pie_Generic, Q931Uie_Generic); - Q931SetIEProc(Q931ie_FACILITY, i, Q931Pie_Generic, Q931Uie_Generic); - Q931SetIEProc(Q931ie_REDIRECTING_NUMBER, i, Q931Pie_Generic, Q931Uie_Generic); - - /* The following define a state machine. The point is that the Message */ - /* procs can when search this to find out if the message/state */ - /* combination is legale. If not, the proc for unexpected message apply.*/ - - /* TODO define state table here */ -} diff --git a/libs/freetdm/src/isdn/nationalStateTE.c b/libs/freetdm/src/isdn/nationalStateTE.c deleted file mode 100644 index 46731d0910..0000000000 --- a/libs/freetdm/src/isdn/nationalStateTE.c +++ /dev/null @@ -1,217 +0,0 @@ -/***************************************************************************** - - FileName: nationalStateTE.c - - Contents: National ISDN State Engine for TE (User Mode). - - The controlling state engine for Q.931 is the state engine - on the NT side. The state engine on the TE side is a slave - of this. The TE side maintain it's own states as described in - ITU-T Q931, but will in raise conditions be overridden by - the NT side. - - This reference implementation uses a process per message, - meaning that each message must check call states. This - is easier for dialect maintenance as each message proc - can be replaced individually. A new TE variant only - need to copy the Q931CreateTE and replace those procs or - need to override. - - License/Copyright: - - Copyright (c) 2007, Jan Vidar Berger, Case Labs, Ltd. All rights reserved. - email:janvb@caselaboratories.com - - Copyright (c) 2007, Michael Jerris. All rights reserved. - email:mike@jerris.com - - 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 Case Labs, Ltd 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT OWNER OR CONTRIBUTORS 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 SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*****************************************************************************/ - -#include "national.h" -extern L3INT Q931L4HeaderSpace; - -/***************************************************************************** - Function: nationalCreateTE - - Description: Will create the National TE as a Dialect in the stack. The first - bulk set up the message handlers, the second bulk the IE - encoders/coders, and the last bulk set up the state table. - - Parameters: i Dialect index -*****************************************************************************/ -void nationalCreateTE(L3UCHAR i) -{ - Q931SetMesProc(Q931mes_ALERTING, i, Q931ProcAlertingTE, Q931Umes_Alerting, Q931Pmes_Alerting); - Q931SetMesProc(Q931mes_CALL_PROCEEDING, i, Q931ProcCallProceedingTE, Q931Umes_CallProceeding, Q931Pmes_CallProceeding); - Q931SetMesProc(Q931mes_CONNECT, i, DMSProc0x07TE, DMSUmes_0x07, DMSPmes_0x07); - Q931SetMesProc(Q931mes_CONNECT_ACKNOWLEDGE, i, DMSProc0x0fTE, DMSUmes_0x0f, DMSPmes_0x0f); - Q931SetMesProc(Q931mes_PROGRESS, i, Q931ProcProgressTE, Q931Umes_Progress, Q931Pmes_Progress); - Q931SetMesProc(Q931mes_SETUP, i, Q931ProcSetupTE, nationalUmes_Setup, nationalPmes_Setup); - Q931SetMesProc(Q931mes_SETUP_ACKNOWLEDGE, i, Q931ProcSetupAckTE, Q931Umes_SetupAck, Q931Pmes_SetupAck); - Q931SetMesProc(Q931mes_RESUME, i, Q931ProcResumeTE, Q931Umes_Resume, Q931Pmes_Resume); - Q931SetMesProc(Q931mes_RESUME_ACKNOWLEDGE, i, Q931ProcResumeAckTE, Q931Umes_ResumeAck, Q931Pmes_ResumeAck); - Q931SetMesProc(Q931mes_RESUME_REJECT, i, Q931ProcResumeRejectTE, Q931Umes_ResumeReject, Q931Pmes_ResumeReject); - Q931SetMesProc(Q931mes_SUSPEND, i, Q931ProcSuspendTE, Q931Umes_Suspend, Q931Pmes_Suspend); - Q931SetMesProc(Q931mes_SUSPEND_ACKNOWLEDGE, i, Q931ProcSuspendAckTE, Q931Umes_SuspendAck, Q931Pmes_SuspendAck); - Q931SetMesProc(Q931mes_SUSPEND_REJECT, i, Q931ProcSuspendRejectTE, Q931Umes_SuspendReject, Q931Pmes_SuspendReject); - Q931SetMesProc(Q931mes_USER_INFORMATION, i, Q931ProcUserInformationTE, Q931Umes_UserInformation, Q931Pmes_UserInformation); - Q931SetMesProc(Q931mes_DISCONNECT, i, Q931ProcDisconnectTE, Q931Umes_Disconnect, Q931Pmes_Disconnect); - Q931SetMesProc(Q931mes_RELEASE, i, Q931ProcReleaseTE, Q931Umes_Release, Q931Pmes_Release); - Q931SetMesProc(Q931mes_RELEASE_COMPLETE, i, Q931ProcReleaseCompleteTE, Q931Umes_ReleaseComplete, Q931Pmes_ReleaseComplete); - Q931SetMesProc(Q931mes_RESTART, i, Q931ProcRestartTE, Q931Umes_Restart, Q931Pmes_Restart); - Q931SetMesProc(Q931mes_RESTART_ACKNOWLEDGE, i, Q931ProcRestartAckTE, Q931Umes_RestartAck, Q931Pmes_RestartAck); - Q931SetMesProc(Q931mes_CONGESTION_CONTROL, i, Q931ProcCongestionControlTE, Q931Umes_CongestionControl, Q931Pmes_CongestionControl); - Q931SetMesProc(Q931mes_INFORMATION, i, Q931ProcInformationTE, Q931Umes_Information, Q931Pmes_Information); - Q931SetMesProc(Q931mes_NOTIFY, i, Q931ProcNotifyTE, Q931Umes_Notify, Q931Pmes_Notify); - Q931SetMesProc(Q931mes_STATUS, i, Q931ProcStatusTE, Q931Umes_Status, Q931Pmes_Status); - Q931SetMesProc(Q931mes_STATUS_ENQUIRY, i, Q931ProcStatusEnquiryTE, Q931Umes_StatusEnquiry, Q931Pmes_StatusEnquiry); - Q931SetMesProc(Q931mes_SEGMENT, i, Q931ProcSegmentTE, Q931Umes_Segment, Q931Pmes_Segment); - - Q931SetMesProc(Q932mes_FACILITY, i, Q932ProcFacilityTE, Q932Umes_Facility, Q932Pmes_Facility); - Q931SetMesProc(Q932mes_HOLD, i, Q932ProcHoldTE, Q932Umes_Hold, Q932Pmes_Hold); - Q931SetMesProc(Q932mes_HOLD_ACKNOWLEDGE, i, Q932ProcHoldAckTE, Q932Umes_HoldAck, Q932Pmes_HoldAck); - Q931SetMesProc(Q932mes_HOLD_REJECT, i, Q932ProcHoldRejectTE, Q932Umes_HoldReject, Q932Pmes_HoldReject); - Q931SetMesProc(Q932mes_REGISTER, i, Q932ProcRegisterTE, Q932Umes_Register, Q932Pmes_Register); - Q931SetMesProc(Q932mes_RETRIEVE, i, Q932ProcRetrieveTE, Q932Umes_Retrieve, Q932Pmes_Retrieve); - Q931SetMesProc(Q932mes_RETRIEVE_ACKNOWLEDGE, i, Q932ProcRetrieveAckTE, Q932Umes_RetrieveAck, Q932Pmes_RetrieveAck); - Q931SetMesProc(Q932mes_RETRIEVE_REJECT, i, Q932ProcRetrieveRejectTE, Q932Umes_RetrieveReject, Q932Pmes_RetrieveReject); - - /* Set up the IE encoder/decoder handle table.*/ - Q931SetIEProc(Q931ie_SEGMENTED_MESSAGE, i, Q931Pie_Segment, Q931Uie_Segment); - Q931SetIEProc(Q931ie_BEARER_CAPABILITY, i, Q931Pie_BearerCap, Q931Uie_BearerCap); - Q931SetIEProc(Q931ie_CAUSE, i, Q931Pie_Cause, Q931Uie_Cause); - Q931SetIEProc(Q931ie_CALL_IDENTITY, i, Q931Pie_CallID, Q931Uie_CallID); - Q931SetIEProc(Q931ie_CALL_STATE, i, Q931Pie_CallState, Q931Uie_CallState); - Q931SetIEProc(Q931ie_CHANGE_STATUS, i, Q931Pie_ChangeStatus, Q931Uie_ChangeStatus); - Q931SetIEProc(Q931ie_CHANNEL_IDENTIFICATION, i, Q931Pie_ChanID, Q931Uie_ChanID); - Q931SetIEProc(Q931ie_PROGRESS_INDICATOR, i, Q931Pie_ProgInd, Q931Uie_ProgInd); - Q931SetIEProc(Q931ie_NETWORK_SPECIFIC_FACILITIES, i, Q931Pie_NetFac, Q931Uie_NetFac); - Q931SetIEProc(Q931ie_NOTIFICATION_INDICATOR, i, Q931Pie_NotifInd, Q931Uie_NotifInd); - Q931SetIEProc(Q931ie_DISPLAY, i, Q931Pie_Display, Q931Uie_Display); - Q931SetIEProc(Q931ie_DATETIME, i, Q931Pie_DateTime, Q931Uie_DateTime); - Q931SetIEProc(Q931ie_KEYPAD_FACILITY, i, Q931Pie_KeypadFac, Q931Uie_KeypadFac); - Q931SetIEProc(Q931ie_SIGNAL, i, Q931Pie_Signal, Q931Uie_Signal); - Q931SetIEProc(Q931ie_TRANSIT_DELAY_SELECTION_AND_IND, i, Q931Pie_TransNetSel, Q931Uie_TransNetSel); - Q931SetIEProc(Q931ie_CALLING_PARTY_NUMBER, i, Q931Pie_CallingNum, Q931Uie_CallingNum); - Q931SetIEProc(Q931ie_CALLING_PARTY_SUBADDRESS, i, Q931Pie_CallingSub, Q931Uie_CallingSub); - Q931SetIEProc(Q931ie_CALLED_PARTY_NUMBER, i, Q931Pie_CalledNum, Q931Uie_CalledNum); - Q931SetIEProc(Q931ie_CALLED_PARTY_SUBADDRESS, i, Q931Pie_CalledSub, Q931Uie_CalledSub); - Q931SetIEProc(Q931ie_TRANSIT_NETWORK_SELECTION, i, Q931Pie_TransNetSel, Q931Uie_TransNetSel); - Q931SetIEProc(Q931ie_RESTART_INDICATOR, i, Q931Pie_RestartInd, Q931Uie_RestartInd); - Q931SetIEProc(Q931ie_LOW_LAYER_COMPATIBILITY, i, Q931Pie_LLComp, Q931Uie_LLComp); - Q931SetIEProc(Q931ie_HIGH_LAYER_COMPATIBILITY, i, Q931Pie_HLComp, Q931Uie_HLComp); - Q931SetIEProc(Q931ie_USER_USER, i, Q931Pie_UserUser, Q931Uie_UserUser); - Q931SetIEProc(Q931ie_GENERIC_DIGITS, i, Q931Pie_GenericDigits, Q931Uie_GenericDigits); - - Q931SetIEProc(Q931ie_CONNECTED_NUMBER, i, Q931Pie_Generic, Q931Uie_Generic); - Q931SetIEProc(Q931ie_FACILITY, i, Q931Pie_Generic, Q931Uie_Generic); - Q931SetIEProc(Q931ie_REDIRECTING_NUMBER, i, Q931Pie_Generic, Q931Uie_Generic); - - /* The following define a state machine. The point is that the Message - * procs can when search this to find out if the message/state - * combination is legale. If not, the proc for unexpected message apply. - */ - - /* State 0 Idle */ - Q931AddStateEntry(i, Q931_U0, Q931mes_RESUME, 2); - Q931AddStateEntry(i, Q931_U0, Q931mes_SETUP, 4); - Q931AddStateEntry(i, Q931_U0, Q931mes_SETUP, 2); - Q931AddStateEntry(i, Q931_U0, Q931mes_STATUS, 4); - Q931AddStateEntry(i, Q931_U0, Q931mes_RELEASE, 4); - Q931AddStateEntry(i, Q931_U0, Q931mes_RELEASE_COMPLETE, 4); - - /* State 1 Call Initiating */ - Q931AddStateEntry(i, Q931_U1, Q931mes_DISCONNECT, 2); - Q931AddStateEntry(i, Q931_U1, Q931mes_SETUP_ACKNOWLEDGE, 4); - Q931AddStateEntry(i, Q931_U1, Q931mes_RELEASE_COMPLETE, 4); - Q931AddStateEntry(i, Q931_U1, Q931mes_CALL_PROCEEDING, 4); - Q931AddStateEntry(i, Q931_U1, Q931mes_ALERTING, 4); - Q931AddStateEntry(i, Q931_U1, Q931mes_CONNECT, 4); - - /* State 2 Overlap Sending */ - Q931AddStateEntry(i, Q931_U2, Q931mes_INFORMATION, 2); - Q931AddStateEntry(i, Q931_U2, Q931mes_CALL_PROCEEDING, 4); - Q931AddStateEntry(i, Q931_U2, Q931mes_ALERTING, 4); - Q931AddStateEntry(i, Q931_U2, Q931mes_PROGRESS, 4); - Q931AddStateEntry(i, Q931_U2, Q931mes_CONNECT, 4); - Q931AddStateEntry(i, Q931_U2, Q931mes_RELEASE, 2); - - /* State 3 Outgoing Call Proceeding */ - Q931AddStateEntry(i, Q931_U3, Q931mes_PROGRESS, 4); - Q931AddStateEntry(i, Q931_U3, Q931mes_ALERTING, 4); - Q931AddStateEntry(i, Q931_U3, Q931mes_CONNECT, 4); - Q931AddStateEntry(i, Q931_U3, Q931mes_RELEASE, 2); - - /* State 4 Call Delivered */ - Q931AddStateEntry(i, Q931_U4, Q931mes_CONNECT, 4); - - /* State 6 Call Precent */ - Q931AddStateEntry(i, Q931_U6, Q931mes_INFORMATION, 2); - Q931AddStateEntry(i, Q931_U6, Q931mes_ALERTING, 2); - Q931AddStateEntry(i, Q931_U6, Q931mes_CALL_PROCEEDING, 2); - Q931AddStateEntry(i, Q931_U6, Q931mes_CONNECT, 2); - Q931AddStateEntry(i, Q931_U6, Q931mes_RELEASE_COMPLETE, 2); - Q931AddStateEntry(i, Q931_U6, Q931mes_RELEASE, 4); - Q931AddStateEntry(i, Q931_U6, Q931mes_DISCONNECT, 4); - - /* State 7 Call Received */ - Q931AddStateEntry(i, Q931_U7, Q931mes_CONNECT, 2); - - /* State 8 Connect request */ - Q931AddStateEntry(i, Q931_U8, Q931mes_CONNECT_ACKNOWLEDGE, 4); - - /* State 9 Incoming Call Proceeding */ - Q931AddStateEntry(i, Q931_U9, Q931mes_CONNECT, 2); - Q931AddStateEntry(i, Q931_U9, Q931mes_ALERTING, 2); - Q931AddStateEntry(i, Q931_U9, Q931mes_PROGRESS, 2); - - /* State 10 Active */ - Q931AddStateEntry(i, Q931_U10, Q931mes_SUSPEND, 2); - Q931AddStateEntry(i, Q931_U10, Q931mes_NOTIFY, 4); - Q931AddStateEntry(i, Q931_U10, Q931mes_NOTIFY, 2); - - /* State 11 Disconnect Request */ - Q931AddStateEntry(i, Q931_U11, Q931mes_RELEASE, 4); - Q931AddStateEntry(i, Q931_U11, Q931mes_DISCONNECT, 4); - Q931AddStateEntry(i, Q931_U11, Q931mes_NOTIFY, 4); - - /* State 12 Disconnect Ind */ - Q931AddStateEntry(i, Q931_U12, Q931mes_RELEASE, 4); - Q931AddStateEntry(i, Q931_U12, Q931mes_RELEASE, 2); - - /* State 15 Suspend Request */ - Q931AddStateEntry(i, Q931_U15, Q931mes_SUSPEND_ACKNOWLEDGE, 4); - Q931AddStateEntry(i, Q931_U15, Q931mes_SUSPEND_REJECT, 4); - Q931AddStateEntry(i, Q931_U15, Q931mes_DISCONNECT, 4); - Q931AddStateEntry(i, Q931_U15, Q931mes_RELEASE, 4); - -/* TODO - Q931AddStateEntry(i, Q931_U17, - Q931AddStateEntry(i, Q931_U19, - Q931AddStateEntry(i, Q931_U25, -*/ -} diff --git a/libs/freetdm/src/isdn/nationalmes.c b/libs/freetdm/src/isdn/nationalmes.c deleted file mode 100644 index 6d8350fbcd..0000000000 --- a/libs/freetdm/src/isdn/nationalmes.c +++ /dev/null @@ -1,269 +0,0 @@ -/***************************************************************************** - - FileName: nationalmes.c - - Contents: Pack/Unpack functions. These functions will unpack a National ISDN - message from the bit packed original format into structs - that contains variables sized by the user. It will also pack - the struct back into a Q.931 message as required. - - See national.h for description. - - License/Copyright: - - Copyright (c) 2007, Jan Vidar Berger, Case Labs, Ltd. All rights reserved. - email:janvb@caselaboratories.com - - Copyright (c) 2007, Michael Jerris. All rights reserved. - email:mike@jerris.com - - 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 Case Labs, Ltd 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT OWNER OR CONTRIBUTORS 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 SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - -*****************************************************************************/ - -#include "national.h" - -/***************************************************************************** - - Function: nationalUmes_Setup - -*****************************************************************************/ -L3INT nationalUmes_Setup(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3INT ir = 0; - L3INT OOff = 0; - L3INT rc = Q931E_NO_ERROR; - L3UCHAR last_codeset = 0, codeset = 0; - L3UCHAR shift_lock = 1; - - while (IOff < Size) { - if (!shift_lock) { - codeset = last_codeset; - } - - if ((IBuf[IOff] & 0xF0) == Q931ie_SHIFT ) { - shift_lock = (IBuf[IOff] & 0x08); - if (shift_lock) { - last_codeset = codeset; - } - codeset = ((IBuf[IOff] & 0x07)); - IOff++; - } - - if (codeset == 0) { - switch (IBuf[IOff]) { - case Q931ie_SENDING_COMPLETE: - case Q931ie_BEARER_CAPABILITY: - case Q931ie_CHANNEL_IDENTIFICATION: - case Q931ie_PROGRESS_INDICATOR: - case Q931ie_NETWORK_SPECIFIC_FACILITIES: - case Q931ie_DISPLAY: - case Q931ie_DATETIME: - case Q931ie_KEYPAD_FACILITY: - case Q931ie_SIGNAL: - case Q931ie_CALLING_PARTY_NUMBER: - case Q931ie_CALLING_PARTY_SUBADDRESS: - case Q931ie_CALLED_PARTY_NUMBER: - case Q931ie_CALLED_PARTY_SUBADDRESS: - case Q931ie_TRANSIT_NETWORK_SELECTION: - case Q931ie_LOW_LAYER_COMPATIBILITY: - case Q931ie_HIGH_LAYER_COMPATIBILITY: - case Q931ie_FACILITY: - case Q931ie_REDIRECTING_NUMBER: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if (rc != Q931E_NO_ERROR) - return rc; - break; - case Q931ie_REPEAT_INDICATOR: - if (ir < 2) { - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - ir++; - } else { - return Q931E_ILLEGAL_IE; - } - break; - default: - return Q931E_ILLEGAL_IE; - break; - } - } else if (codeset == 6) { - switch (IBuf[IOff]) { - case Q931ie_GENERIC_DIGITS: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if (rc != Q931E_NO_ERROR) - return rc; - break; - default: - return Q931E_ILLEGAL_IE; - break; - } - - } else { - return Q931E_ILLEGAL_IE; - } - } - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: nationalPmes_Setup - - Decription: Pack a Q931mes_Generic into a real Q.931 message. The user will - set up a SETUP message and issue this to the stack where it - is processed by Q931ProcSetup that processes and validates - it before it actually sends it out. This function is called - to compute the real Q.931 message. - - Parameters: IBuf[IN] Ptr to un-packed struct - ISize[IN] Size of input buffer (unpacked message). - OBuf[OUT] Ptr to packed 'octet' wise message. - OSize[OUT] Size of packed message. - - Called By: Q931ProcSetup - -*****************************************************************************/ -L3INT nationalPmes_Setup(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - L3INT rc = Q931E_NO_ERROR; - Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; - L3INT Octet = 0; - - /* Q931 Message Header */ - Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); - - /* Sending Complete */ - if (Q931IsIEPresent(pMes->SendComplete)) { - OBuf[Octet++] = (L3UCHAR)(pMes->SendComplete & 0x00ff); - } - - /* Repeat Indicator */ - if (Q931IsIEPresent(pMes->RepeatInd)) { - OBuf[Octet++] = (L3UCHAR)(pMes->RepeatInd & 0x00ff); - } - - /* Bearer capability */ - if (Q931IsIEPresent(pMes->BearerCap)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_BEARER_CAPABILITY](pTrunk, Q931GetIEPtr(pMes->BearerCap,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - else { - rc = Q931E_BEARERCAP; - } - - /* Channel Identification */ - if (Q931IsIEPresent(pMes->ChanID)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CHANNEL_IDENTIFICATION](pTrunk, Q931GetIEPtr(pMes->ChanID,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Progress indicator */ - if (Q931IsIEPresent(pMes->ProgInd)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_PROGRESS_INDICATOR](pTrunk, Q931GetIEPtr(pMes->ProgInd,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Network spesific facilities */ - if (Q931IsIEPresent(pMes->NetFac)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_NETWORK_SPECIFIC_FACILITIES](pTrunk, Q931GetIEPtr(pMes->NetFac,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Display */ - if (Q931IsIEPresent(pMes->Display)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Date/Time */ - if (Q931IsIEPresent(pMes->DateTime)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DATETIME](pTrunk, Q931GetIEPtr(pMes->DateTime,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Keypad Facility */ - if (Q931IsIEPresent(pMes->KeypadFac)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_KEYPAD_FACILITY](pTrunk, Q931GetIEPtr(pMes->KeypadFac,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Signal */ - if (Q931IsIEPresent(pMes->Signal)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_SIGNAL](pTrunk, Q931GetIEPtr(pMes->Signal,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Calling Party Number */ - if (Q931IsIEPresent(pMes->CallingNum)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALLING_PARTY_NUMBER](pTrunk, Q931GetIEPtr(pMes->CallingNum,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Calling Party Subaddress */ - if (Q931IsIEPresent(pMes->CallingSub)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALLING_PARTY_SUBADDRESS](pTrunk, Q931GetIEPtr(pMes->CallingSub,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Called Party number */ - if (Q931IsIEPresent(pMes->CalledNum)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALLED_PARTY_NUMBER](pTrunk, Q931GetIEPtr(pMes->CalledNum,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Called party subaddress */ - if (Q931IsIEPresent(pMes->CalledSub)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALLED_PARTY_SUBADDRESS](pTrunk, Q931GetIEPtr(pMes->CalledSub,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Transit network selection */ - if (Q931IsIEPresent(pMes->TransNetSel)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_TRANSIT_NETWORK_SELECTION](pTrunk, Q931GetIEPtr(pMes->TransNetSel,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* Repeat Indicator */ - if (Q931IsIEPresent(pMes->LLRepeatInd)) { - rc = Q931E_UNKNOWN_IE;/* TODO */ - } - - /* Low Layer Compatibility */ - if (Q931IsIEPresent(pMes->LLComp)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_LOW_LAYER_COMPATIBILITY](pTrunk, Q931GetIEPtr(pMes->LLComp,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - /* High Layer Compatibility */ - if (Q931IsIEPresent(pMes->HLComp)) { - if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_HIGH_LAYER_COMPATIBILITY](pTrunk, Q931GetIEPtr(pMes->HLComp,pMes->buf), OBuf, &Octet)) != 0) - return rc; - } - - *OSize = Octet; - return rc; -} diff --git a/libs/freetdm/src/libteletone_detect.c b/libs/freetdm/src/libteletone_detect.c deleted file mode 100644 index b89ea11645..0000000000 --- a/libs/freetdm/src/libteletone_detect.c +++ /dev/null @@ -1,485 +0,0 @@ -/* - * libteletone - * Copyright (C) 2005-2014, Anthony Minessale II - * - * Version: MPL 1.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is tone_detect.c - General telephony tone detection, and specific detection of DTMF. - * - * - * The Initial Developer of the Original Code is - * Stephen Underwood - * Portions created by the Initial Developer are Copyright (C) - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * The the original interface designed by Steve Underwood was preserved to retain - *the optimizations when considering DTMF tones though the names were changed in the interest - * of namespace. - * - * Much less efficient expansion interface was added to allow for the detection of - * a single arbitrary tone combination which may also exceed 2 simultaneous tones. - * (controlled by compile time constant TELETONE_MAX_TONES) - * - * Copyright (C) 2006 Anthony Minessale II - * - * - * libteletone_detect.c Tone Detection Code - * - * - ********************************************************************************* - * - * Derived from tone_detect.c - General telephony tone detection, and specific - * detection of DTMF. - * - * Copyright (C) 2001 Steve Underwood - * - * Despite my general liking of the GPL, I place this code in the - * public domain for the benefit of all mankind - even the slimy - * ones who might try to proprietize my work and use it to my - * detriment. - * - * - * Exception: - * The author hereby grants the use of this source code under the - * following license if and only if the source code is distributed - * as part of the OpenZAP or FreeTDM library. Any use or distribution of this - * source code outside the scope of the OpenZAP or FreeTDM library will nullify the - * following license and reinact the MPL 1.1 as stated above. - * - * Copyright (c) 2007, Anthony Minessale II - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#ifndef _MSC_VER -#include -#endif -#include -#include -#include -#include - -#define LOW_ENG 10000000 -#define ZC 2 -static teletone_detection_descriptor_t dtmf_detect_row[GRID_FACTOR]; -static teletone_detection_descriptor_t dtmf_detect_col[GRID_FACTOR]; -static teletone_detection_descriptor_t dtmf_detect_row_2nd[GRID_FACTOR]; -static teletone_detection_descriptor_t dtmf_detect_col_2nd[GRID_FACTOR]; - -static float dtmf_row[] = {697.0f, 770.0f, 852.0f, 941.0f}; -static float dtmf_col[] = {1209.0f, 1336.0f, 1477.0f, 1633.0f}; - -static char dtmf_positions[] = "123A" "456B" "789C" "*0#D"; - -static void goertzel_init(teletone_goertzel_state_t *goertzel_state, teletone_detection_descriptor_t *tdesc) { - goertzel_state->v2 = goertzel_state->v3 = 0.0; - goertzel_state->fac = tdesc->fac; -} - -TELETONE_API(void) teletone_goertzel_update(teletone_goertzel_state_t *goertzel_state, - int16_t sample_buffer[], - int samples) -{ - int i; - float v1; - - for (i = 0; i < samples; i++) { - v1 = goertzel_state->v2; - goertzel_state->v2 = goertzel_state->v3; - goertzel_state->v3 = (float)(goertzel_state->fac*goertzel_state->v2 - v1 + sample_buffer[i]); - } -} -#ifdef _MSC_VER -#pragma warning(disable:4244) -#endif - -#define teletone_goertzel_result(gs) (double)(((gs)->v3 * (gs)->v3 + (gs)->v2 * (gs)->v2 - (gs)->v2 * (gs)->v3 * (gs)->fac)) - -TELETONE_API(void) teletone_dtmf_detect_init (teletone_dtmf_detect_state_t *dtmf_detect_state, int sample_rate) -{ - int i; - float theta; - - dtmf_detect_state->hit1 = dtmf_detect_state->hit2 = 0; - - for (i = 0; i < GRID_FACTOR; i++) { - theta = (float)(M_TWO_PI*(dtmf_row[i]/(float)sample_rate)); - dtmf_detect_row[i].fac = (float)(2.0*cos(theta)); - - theta = (float)(M_TWO_PI*(dtmf_col[i]/(float)sample_rate)); - dtmf_detect_col[i].fac = (float)(2.0*cos(theta)); - - theta = (float)(M_TWO_PI*(dtmf_row[i]*2.0/(float)sample_rate)); - dtmf_detect_row_2nd[i].fac = (float)(2.0*cos(theta)); - - theta = (float)(M_TWO_PI*(dtmf_col[i]*2.0/(float)sample_rate)); - dtmf_detect_col_2nd[i].fac = (float)(2.0*cos(theta)); - - goertzel_init (&dtmf_detect_state->row_out[i], &dtmf_detect_row[i]); - goertzel_init (&dtmf_detect_state->col_out[i], &dtmf_detect_col[i]); - goertzel_init (&dtmf_detect_state->row_out2nd[i], &dtmf_detect_row_2nd[i]); - goertzel_init (&dtmf_detect_state->col_out2nd[i], &dtmf_detect_col_2nd[i]); - - dtmf_detect_state->energy = 0.0; - } - dtmf_detect_state->current_sample = 0; - dtmf_detect_state->detected_digits = 0; - dtmf_detect_state->lost_digits = 0; - dtmf_detect_state->digit = 0; - dtmf_detect_state->dur = 0; -} - -TELETONE_API(void) teletone_multi_tone_init(teletone_multi_tone_t *mt, teletone_tone_map_t *map) -{ - float theta = 0; - int x = 0; - - if (!mt->sample_rate) { - mt->sample_rate = 8000; - } - - if (!mt->min_samples) { - mt->min_samples = 102; - } - - mt->min_samples *= (mt->sample_rate / 8000); - - if (!mt->positive_factor) { - mt->positive_factor = 2; - } - - if(!mt->negative_factor) { - mt->negative_factor = 10; - } - - if (!mt->hit_factor) { - mt->hit_factor = 2; - } - - for(x = 0; x < TELETONE_MAX_TONES; x++) { - if ((int) map->freqs[x] == 0) { - break; - } - mt->tone_count++; - theta = (float)(M_TWO_PI*(map->freqs[x]/(float)mt->sample_rate)); - mt->tdd[x].fac = (float)(2.0 * cos(theta)); - goertzel_init (&mt->gs[x], &mt->tdd[x]); - goertzel_init (&mt->gs2[x], &mt->tdd[x]); - } - -} - -TELETONE_API(int) teletone_multi_tone_detect (teletone_multi_tone_t *mt, - int16_t sample_buffer[], - int samples) -{ - int sample, limit = 0, j, x = 0; - float v1, famp; - float eng_sum = 0, eng_all[TELETONE_MAX_TONES] = {0.0}; - int gtest = 0, see_hit = 0; - - for (sample = 0; sample >= 0 && sample < samples; sample = limit) { - mt->total_samples++; - - if ((samples - sample) >= (mt->min_samples - mt->current_sample)) { - limit = sample + (mt->min_samples - mt->current_sample); - } else { - limit = samples; - } - if (limit < 0 || limit > samples) { - limit = samples; - } - - for (j = sample; j < limit; j++) { - famp = sample_buffer[j]; - - mt->energy += famp*famp; - - for(x = 0; x < TELETONE_MAX_TONES && x < mt->tone_count; x++) { - v1 = mt->gs[x].v2; - mt->gs[x].v2 = mt->gs[x].v3; - mt->gs[x].v3 = (float)(mt->gs[x].fac * mt->gs[x].v2 - v1 + famp); - - v1 = mt->gs2[x].v2; - mt->gs2[x].v2 = mt->gs2[x].v3; - mt->gs2[x].v3 = (float)(mt->gs2[x].fac*mt->gs2[x].v2 - v1 + famp); - } - } - - mt->current_sample += (limit - sample); - if (mt->current_sample < mt->min_samples) { - continue; - } - - eng_sum = 0; - for(x = 0; x < TELETONE_MAX_TONES && x < mt->tone_count; x++) { - eng_all[x] = (float)(teletone_goertzel_result (&mt->gs[x])); - eng_sum += eng_all[x]; - } - - gtest = 0; - for(x = 0; x < TELETONE_MAX_TONES && x < mt->tone_count; x++) { - gtest += teletone_goertzel_result (&mt->gs2[x]) < eng_all[x] ? 1 : 0; - } - - if ((gtest >= 2 || gtest == mt->tone_count) && eng_sum > 42.0 * mt->energy) { - if(mt->negatives) { - mt->negatives--; - } - mt->positives++; - - if(mt->positives >= mt->positive_factor) { - mt->hits++; - } - if (mt->hits >= mt->hit_factor) { - see_hit++; - mt->positives = mt->negatives = mt->hits = 0; - } - } else { - mt->negatives++; - if(mt->positives) { - mt->positives--; - } - if(mt->negatives > mt->negative_factor) { - mt->positives = mt->hits = 0; - } - } - - /* Reinitialise the detector for the next block */ - for(x = 0; x < TELETONE_MAX_TONES && x < mt->tone_count; x++) { - goertzel_init (&mt->gs[x], &mt->tdd[x]); - goertzel_init (&mt->gs2[x], &mt->tdd[x]); - } - - mt->energy = 0.0; - mt->current_sample = 0; - } - - return see_hit; -} - - -TELETONE_API(teletone_hit_type_t) teletone_dtmf_detect (teletone_dtmf_detect_state_t *dtmf_detect_state, - int16_t sample_buffer[], - int samples) -{ - float row_energy[GRID_FACTOR]; - float col_energy[GRID_FACTOR]; - float famp; - float v1; - int i; - int j; - int sample; - int best_row; - int best_col; - char hit; - int limit; - teletone_hit_type_t r = 0; - - hit = 0; - for (sample = 0; sample < samples; sample = limit) { - /* BLOCK_LEN is optimised to meet the DTMF specs. */ - if ((samples - sample) >= (BLOCK_LEN - dtmf_detect_state->current_sample)) { - limit = sample + (BLOCK_LEN - dtmf_detect_state->current_sample); - } else { - limit = samples; - } - - for (j = sample; j < limit; j++) { - int x = 0; - famp = sample_buffer[j]; - - dtmf_detect_state->energy += famp*famp; - - for(x = 0; x < GRID_FACTOR; x++) { - v1 = dtmf_detect_state->row_out[x].v2; - dtmf_detect_state->row_out[x].v2 = dtmf_detect_state->row_out[x].v3; - dtmf_detect_state->row_out[x].v3 = (float)(dtmf_detect_state->row_out[x].fac*dtmf_detect_state->row_out[x].v2 - v1 + famp); - - v1 = dtmf_detect_state->col_out[x].v2; - dtmf_detect_state->col_out[x].v2 = dtmf_detect_state->col_out[x].v3; - dtmf_detect_state->col_out[x].v3 = (float)(dtmf_detect_state->col_out[x].fac*dtmf_detect_state->col_out[x].v2 - v1 + famp); - - v1 = dtmf_detect_state->col_out2nd[x].v2; - dtmf_detect_state->col_out2nd[x].v2 = dtmf_detect_state->col_out2nd[x].v3; - dtmf_detect_state->col_out2nd[x].v3 = (float)(dtmf_detect_state->col_out2nd[x].fac*dtmf_detect_state->col_out2nd[x].v2 - v1 + famp); - - v1 = dtmf_detect_state->row_out2nd[x].v2; - dtmf_detect_state->row_out2nd[x].v2 = dtmf_detect_state->row_out2nd[x].v3; - dtmf_detect_state->row_out2nd[x].v3 = (float)(dtmf_detect_state->row_out2nd[x].fac*dtmf_detect_state->row_out2nd[x].v2 - v1 + famp); - } - - } - - if (dtmf_detect_state->zc > 0) { - if (dtmf_detect_state->energy < LOW_ENG && dtmf_detect_state->lenergy < LOW_ENG) { - if (!--dtmf_detect_state->zc) { - /* Reinitialise the detector for the next block */ - dtmf_detect_state->hit1 = dtmf_detect_state->hit2 = 0; - for (i = 0; i < GRID_FACTOR; i++) { - goertzel_init (&dtmf_detect_state->row_out[i], &dtmf_detect_row[i]); - goertzel_init (&dtmf_detect_state->col_out[i], &dtmf_detect_col[i]); - goertzel_init (&dtmf_detect_state->row_out2nd[i], &dtmf_detect_row_2nd[i]); - goertzel_init (&dtmf_detect_state->col_out2nd[i], &dtmf_detect_col_2nd[i]); - } - dtmf_detect_state->dur -= samples; - return TT_HIT_END; - } - } - - dtmf_detect_state->dur += samples; - dtmf_detect_state->lenergy = dtmf_detect_state->energy; - dtmf_detect_state->energy = 0.0; - dtmf_detect_state->current_sample = 0; - return TT_HIT_MIDDLE; - } else if (dtmf_detect_state->digit) { - return TT_HIT_END; - } - - - dtmf_detect_state->current_sample += (limit - sample); - if (dtmf_detect_state->current_sample < BLOCK_LEN) { - continue; - } - /* We are at the end of a DTMF detection block */ - /* Find the peak row and the peak column */ - row_energy[0] = teletone_goertzel_result (&dtmf_detect_state->row_out[0]); - col_energy[0] = teletone_goertzel_result (&dtmf_detect_state->col_out[0]); - - for (best_row = best_col = 0, i = 1; i < GRID_FACTOR; i++) { - row_energy[i] = teletone_goertzel_result (&dtmf_detect_state->row_out[i]); - if (row_energy[i] > row_energy[best_row]) { - best_row = i; - } - col_energy[i] = teletone_goertzel_result (&dtmf_detect_state->col_out[i]); - if (col_energy[i] > col_energy[best_col]) { - best_col = i; - } - } - hit = 0; - /* Basic signal level test and the twist test */ - if (row_energy[best_row] >= DTMF_THRESHOLD && - col_energy[best_col] >= DTMF_THRESHOLD && - col_energy[best_col] < row_energy[best_row]*DTMF_REVERSE_TWIST && - col_energy[best_col]*DTMF_NORMAL_TWIST > row_energy[best_row]) { - /* Relative peak test */ - for (i = 0; i < GRID_FACTOR; i++) { - if ((i != best_col && col_energy[i]*DTMF_RELATIVE_PEAK_COL > col_energy[best_col]) || - (i != best_row && row_energy[i]*DTMF_RELATIVE_PEAK_ROW > row_energy[best_row])) { - break; - } - } - /* ... and second harmonic test */ - if (i >= GRID_FACTOR && (row_energy[best_row] + col_energy[best_col]) > 42.0*dtmf_detect_state->energy && - teletone_goertzel_result (&dtmf_detect_state->col_out2nd[best_col])*DTMF_2ND_HARMONIC_COL < col_energy[best_col] && - teletone_goertzel_result (&dtmf_detect_state->row_out2nd[best_row])*DTMF_2ND_HARMONIC_ROW < row_energy[best_row]) { - hit = dtmf_positions[(best_row << 2) + best_col]; - /* Look for two successive similar results */ - /* The logic in the next test is: - We need two successive identical clean detects, with - something different preceeding it. This can work with - back to back differing digits. More importantly, it - can work with nasty phones that give a very wobbly start - to a digit. */ - if (! r && hit == dtmf_detect_state->hit3 && dtmf_detect_state->hit3 != dtmf_detect_state->hit2) { - dtmf_detect_state->digit_hits[(best_row << 2) + best_col]++; - dtmf_detect_state->detected_digits++; - if (dtmf_detect_state->current_digits < TELETONE_MAX_DTMF_DIGITS) { - dtmf_detect_state->digit = hit; - } else { - dtmf_detect_state->lost_digits++; - } - - if (!dtmf_detect_state->zc) { - dtmf_detect_state->zc = ZC; - dtmf_detect_state->dur = 0; - r = TT_HIT_BEGIN; - break; - } - - } - } - } - - dtmf_detect_state->hit1 = dtmf_detect_state->hit2; - dtmf_detect_state->hit2 = dtmf_detect_state->hit3; - dtmf_detect_state->hit3 = hit; - - dtmf_detect_state->energy = 0.0; - dtmf_detect_state->current_sample = 0; - - } - - return r; -} - - -TELETONE_API(int) teletone_dtmf_get (teletone_dtmf_detect_state_t *dtmf_detect_state, char *buf, unsigned int *dur) -{ - if (!dtmf_detect_state->digit) { - return 0; - } - - *buf = dtmf_detect_state->digit; - - *dur = dtmf_detect_state->dur; - - if (!dtmf_detect_state->zc) { - dtmf_detect_state->dur = 0; - dtmf_detect_state->digit = 0; - } - - return 1; -} - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/libteletone_generate.c b/libs/freetdm/src/libteletone_generate.c deleted file mode 100644 index 3638d94989..0000000000 --- a/libs/freetdm/src/libteletone_generate.c +++ /dev/null @@ -1,505 +0,0 @@ -/* - * libteletone - * Copyright (C) 2005-2014, Anthony Minessale II - * - * Version: MPL 1.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is libteletone - * - * The Initial Developer of the Original Code is - * Anthony Minessale II - * Portions created by the Initial Developer are Copyright (C) - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Anthony Minessale II - * - * - * libteletone.c -- Tone Generator - * - * - * - * Exception: - * The author hereby grants the use of this source code under the - * following license if and only if the source code is distributed - * as part of the OpenZAP or FreeTDM library. Any use or distribution of this - * source code outside the scope of the OpenZAP or FreeTDM library will nullify the - * following license and reinact the MPL 1.1 as stated above. - * - * Copyright (c) 2007, Anthony Minessale II - * All rights reserved. - * - * 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 original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT OWNER - * OR CONTRIBUTORS 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#define SMAX 32767 -#define SMIN -32768 -#define normalize_to_16bit(n) if (n > SMAX) n = SMAX; else if (n < SMIN) n = SMIN; - -#ifdef _MSC_VER -#pragma warning(disable:4706) -#endif - -TELETONE_API_DATA int16_t TELETONE_SINES[SINE_TABLE_MAX] = { - 0x00c9, 0x025b, 0x03ed, 0x057f, 0x0711, 0x08a2, 0x0a33, 0x0bc4, - 0x0d54, 0x0ee4, 0x1073, 0x1201, 0x138f, 0x151c, 0x16a8, 0x1833, - 0x19be, 0x1b47, 0x1cd0, 0x1e57, 0x1fdd, 0x2162, 0x22e5, 0x2467, - 0x25e8, 0x2768, 0x28e5, 0x2a62, 0x2bdc, 0x2d55, 0x2ecc, 0x3042, - 0x31b5, 0x3327, 0x3497, 0x3604, 0x3770, 0x38d9, 0x3a40, 0x3ba5, - 0x3d08, 0x3e68, 0x3fc6, 0x4121, 0x427a, 0x43d1, 0x4524, 0x4675, - 0x47c4, 0x490f, 0x4a58, 0x4b9e, 0x4ce1, 0x4e21, 0x4f5e, 0x5098, - 0x51cf, 0x5303, 0x5433, 0x5560, 0x568a, 0x57b1, 0x58d4, 0x59f4, - 0x5b10, 0x5c29, 0x5d3e, 0x5e50, 0x5f5e, 0x6068, 0x616f, 0x6272, - 0x6371, 0x646c, 0x6564, 0x6657, 0x6747, 0x6832, 0x691a, 0x69fd, - 0x6add, 0x6bb8, 0x6c8f, 0x6d62, 0x6e31, 0x6efb, 0x6fc2, 0x7083, - 0x7141, 0x71fa, 0x72af, 0x735f, 0x740b, 0x74b3, 0x7556, 0x75f4, - 0x768e, 0x7723, 0x77b4, 0x7840, 0x78c8, 0x794a, 0x79c9, 0x7a42, - 0x7ab7, 0x7b27, 0x7b92, 0x7bf9, 0x7c5a, 0x7cb7, 0x7d0f, 0x7d63, - 0x7db1, 0x7dfb, 0x7e3f, 0x7e7f, 0x7eba, 0x7ef0, 0x7f22, 0x7f4e, - 0x7f75, 0x7f98, 0x7fb5, 0x7fce, 0x7fe2, 0x7ff1, 0x7ffa, 0x7fff -}; - - -TELETONE_API(int) teletone_set_tone(teletone_generation_session_t *ts, int index, ...) -{ - va_list ap; - int i = 0; - teletone_process_t x = 0; - - va_start(ap, index); - while (i < TELETONE_MAX_TONES && (x = va_arg(ap, teletone_process_t))) { - ts->TONES[index].freqs[i++] = x; - } - va_end(ap); - - return (i > TELETONE_MAX_TONES) ? -1 : 0; - -} - -TELETONE_API(int) teletone_set_map(teletone_tone_map_t *map, ...) -{ - va_list ap; - int i = 0; - teletone_process_t x = 0; - - va_start(ap, map); - while (i < TELETONE_MAX_TONES && (x = va_arg(ap, teletone_process_t))) { - map->freqs[i++] = x; - } - va_end(ap); - - return (i > TELETONE_MAX_TONES) ? -1 : 0; - -} - -TELETONE_API(int) teletone_init_session(teletone_generation_session_t *ts, int buflen, tone_handler handler, void *user_data) -{ - memset(ts, 0, sizeof(*ts)); - ts->rate = 8000; - ts->channels = 1; - ts->duration = 2000; - ts->wait = 500; - ts->tmp_duration = -1; - ts->tmp_wait = -1; - ts->handler = handler; - ts->user_data = user_data; - ts->volume = -7; - ts->decay_step = 0; - ts->decay_factor = 1; - if (buflen) { - if ((ts->buffer = calloc(buflen, sizeof(teletone_audio_t))) == 0) { - return -1; - } - ts->datalen = buflen; - } else { - ts->dynamic = 1024; - } - /* Add Standard DTMF Tones */ - teletone_set_tone(ts, '1', 697.0, 1209.0, 0.0); - teletone_set_tone(ts, '2', 697.0, 1336.0, 0.0); - teletone_set_tone(ts, '3', 697.0, 1477.0, 0.0); - teletone_set_tone(ts, 'A', 697.0, 1633.0, 0.0); - teletone_set_tone(ts, '4', 770.0, 1209.0, 0.0); - teletone_set_tone(ts, '5', 770.0, 1336.0, 0.0); - teletone_set_tone(ts, '6', 770.0, 1477.0, 0.0); - teletone_set_tone(ts, 'B', 770.0, 1633.0, 0.0); - teletone_set_tone(ts, '7', 859.0, 1209.0, 0.0); - teletone_set_tone(ts, '8', 859.0, 1336.0, 0.0); - teletone_set_tone(ts, '9', 859.0, 1477.0, 0.0); - teletone_set_tone(ts, 'C', 859.0, 1633.0, 0.0); - teletone_set_tone(ts, '*', 941.0, 1209.0, 0.0); - teletone_set_tone(ts, '0', 941.0, 1336.0, 0.0); - teletone_set_tone(ts, '#', 941.0, 1477.0, 0.0); - teletone_set_tone(ts, 'D', 941.0, 1633.0, 0.0); - - return 0; -} - -TELETONE_API(int) teletone_destroy_session(teletone_generation_session_t *ts) -{ - if (ts->buffer) { - free(ts->buffer); - ts->buffer = NULL; - ts->samples = 0; - } - return 0; -} - -static int ensure_buffer(teletone_generation_session_t *ts, int need) -{ - need += ts->samples; - need *= sizeof(teletone_audio_t); - need *= ts->channels; - - if (need > ts->datalen) { - teletone_audio_t *tmp; - ts->datalen = need + ts->dynamic; - tmp = realloc(ts->buffer, ts->datalen); - if (!tmp) { - return -1; - } - ts->buffer = tmp; - } - - return 0; -} - -TELETONE_API(int) teletone_mux_tones(teletone_generation_session_t *ts, teletone_tone_map_t *map) -{ - /*teletone_process_t period = (1.0 / ts->rate) / ts->channels;*/ - int i, c; - int freqlen = 0; - teletone_dds_state_t tones[TELETONE_MAX_TONES+1]; - //int decay = 0; - int duration; - int wait = 0; - int32_t sample; - int32_t dc = 0; - float vol = ts->volume; - ts->samples = 0; - memset(tones, 0, sizeof(tones[0]) * TELETONE_MAX_TONES); - duration = (ts->tmp_duration > -1) ? ts->tmp_duration : ts->duration; - wait = (ts->tmp_wait > -1) ? ts->tmp_wait : ts->wait; - - if (map->freqs[0] > 0) { - for (freqlen = 0; freqlen < TELETONE_MAX_TONES && map->freqs[freqlen]; freqlen++) { - teletone_dds_state_set_tone(&tones[freqlen], map->freqs[freqlen], ts->rate, 0); - teletone_dds_state_set_tx_level(&tones[freqlen], vol); - } - - if (ts->channels > 1) { - duration *= ts->channels; - } - - if (ts->dynamic) { - if (ensure_buffer(ts, duration)) { - return -1; - } - } - - for (ts->samples = 0; ts->samples < ts->datalen && ts->samples < duration; ts->samples++) { - if (ts->decay_direction && ++dc >= ts->decay_step) { - float nvol = vol + ts->decay_direction * ts->decay_factor; - int j; - - if (nvol <= TELETONE_VOL_DB_MAX && nvol >= TELETONE_VOL_DB_MIN) { - vol = nvol; - for (j = 0; j < TELETONE_MAX_TONES && map->freqs[j]; j++) { - teletone_dds_state_set_tx_level(&tones[j], vol); - } - dc = 0; - } - } - - sample = 128; - - for (i = 0; i < freqlen; i++) { - int32_t s = teletone_dds_state_modulate_sample(&tones[i], 0); - sample += s; - } - sample /= freqlen; - ts->buffer[ts->samples] = (teletone_audio_t)sample; - - for (c = 1; c < ts->channels; c++) { - ts->buffer[ts->samples+1] = ts->buffer[ts->samples]; - ts->samples++; - } - - } - } - if (ts->dynamic) { - if (ensure_buffer(ts, wait)) { - return -1; - } - } - for (c = 0; c < ts->channels; c++) { - for (i = 0; i < wait && ts->samples < ts->datalen; i++) { - ts->buffer[ts->samples++] = 0; - } - } - - if (ts->debug && ts->debug_stream) { - if (map->freqs[0] <= 0) { - fprintf(ts->debug_stream, "wait %d (%dms)\n", wait, wait / (ts->rate / 1000)); - } else { - fprintf(ts->debug_stream, "Generate: ("); - - for (i = 0; i < TELETONE_MAX_TONES && map->freqs[i]; i++) { - fprintf(ts->debug_stream, "%s%0.2f", i == 0 ? "" : "+",map->freqs[i]); - } - - fprintf(ts->debug_stream, - ") [volume %0.2fdB; samples %d(%dms) x %d channel%s; wait %d(%dms); decay_factor %0.2fdB; decay_step %d(%dms); wrote %d bytes]\n", - ts->volume, - duration, - duration / (ts->rate / 1000), - ts->channels, - ts->channels == 1 ? "" : "s", - wait, - wait / (ts->rate / 1000), - ts->decay_factor, - ts->decay_step, - ts->decay_step / (ts->rate / 1000), - ts->samples * 2); - } - } - return ts->samples / ts->channels; -} - -/* don't ask */ -static char *my_strdup (const char *s) -{ - size_t len = strlen (s) + 1; - void *new = malloc (len); - - if (new == NULL) { - return NULL; - } - - return (char *) memcpy (new, s, len); -} - -TELETONE_API(int) teletone_run(teletone_generation_session_t *ts, const char *cmd) -{ - char *data = NULL, *cur = NULL, *end = NULL; - int LOOPING = 0; - - if (!cmd) { - return -1; - } - - do { - if (!(data = my_strdup(cmd))) { - return -1; - } - - cur = data; - - while (*cur) { - if (*cur == ' ' || *cur == '\r' || *cur == '\n') { - cur++; - continue; - } - - if ((end = strchr(cur, ';')) != 0) { - *end++ = '\0'; - } - - if (*(cur + 1) == '=') { - switch(*cur) { - case 'c': - ts->channels = atoi(cur + 2); - break; - case 'r': - ts->rate = atoi(cur + 2); - break; - case 'd': - ts->duration = atoi(cur + 2) * (ts->rate / 1000); - break; - case 'v': - { - float vol = (float)atof(cur + 2); - if (vol <= TELETONE_VOL_DB_MAX && vol >= TELETONE_VOL_DB_MIN) { - ts->volume = vol; - } - } - break; - case '>': - ts->decay_step = atoi(cur + 2) * (ts->rate / 1000); - ts->decay_direction = -1; - break; - case '<': - ts->decay_step = atoi(cur + 2) * (ts->rate / 1000); - ts->decay_direction = 1; - break; - case '+': - ts->decay_factor = (float)atof(cur + 2); - break; - case 'w': - ts->wait = atoi(cur + 2) * (ts->rate / 1000); - break; - case 'l': - ts->loops = atoi(cur + 2); - break; - case 'L': - if (!LOOPING) { - int L; - if ((L = atoi(cur + 2)) > 0) { - ts->LOOPS = L; - LOOPING++; - } - } - break; - } - } else { - while (*cur) { - char *p = NULL, *e = NULL; - teletone_tone_map_t mymap, *mapp = NULL; - - if (*cur == ' ' || *cur == '\r' || *cur == '\n') { - cur++; - continue; - } - - ts->tmp_duration = -1; - ts->tmp_wait = -1; - - memset(&mymap, 0, sizeof(mymap)); - - if (*(cur + 1) == '(') { - p = cur + 2; - if (*cur) { - char *next; - int i = 0; - if ((e = strchr(p, ')')) != 0) { - *e++ = '\0'; - } - do { - if (!p) { - break; - } - if ((next = strchr(p, ',')) != 0) { - *next++ = '\0'; - } - if (i == 0) { - ts->tmp_duration = atoi(p) * (ts->rate / 1000); - i++; - } else if (i == 1) { - ts->tmp_wait = atoi(p) * (ts->rate / 1000); - i++; - } else { - mymap.freqs[i++ - 2] = atof(p); - } - p = next; - - } while (next && (i-2) < TELETONE_MAX_TONES); - if (i > 2 && *cur == '%') { - mapp = &mymap; - } else if ((i != 2 || *cur == '%')) { - if (ts->debug && ts->debug_stream) { - fprintf(ts->debug_stream, "Syntax Error!\n"); - } - goto bottom; - } - } - } - - if (*cur && !mapp) { - if (*cur > 0 && *cur < TELETONE_TONE_RANGE) { - mapp = &ts->TONES[(int)*cur]; - } else if (ts->debug && ts->debug_stream) { - fprintf(ts->debug_stream, "Map [%c] Out Of Range!\n", *cur); - } - } - - if (mapp) { - if (mapp->freqs[0]) { - if (ts->handler) { - do { - ts->handler(ts, mapp); - if (ts->loops > 0) { - ts->loops--; - } - } while (ts->loops); - } - } else if (ts->debug && ts->debug_stream) { - fprintf(ts->debug_stream, "Ignoring Empty Map [%c]!\n", *cur); - } - } - - if (e) { - cur = e; - } else { - cur++; - } - } - } - - if (end) { - cur = end; - } else if (*cur){ - cur++; - } - } - bottom: - free(data); - data = NULL; - - if (ts->LOOPS > 0) { - ts->LOOPS--; - } - - } while (ts->LOOPS); - - return 0; -} - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/priserver.c b/libs/freetdm/src/priserver.c deleted file mode 100644 index bbc1f2236e..0000000000 --- a/libs/freetdm/src/priserver.c +++ /dev/null @@ -1,328 +0,0 @@ -/***************************************************************************** - * priserver.c Refactoring of pritest.c - * - * Author(s): Anthony Minessale II - * Nenad Corbic - * - * Copyright: (c) 2005-2014 Anthony Minessale II - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version - * 2 of the License, or (at your option) any later version. - * ============================================================================ - */ - -#include "freetdm.h" -#include -#include -#include -#include -#include -#include - -typedef struct { - int pid; - q931_call call; - void *pri; - int ready; -}call_info_t; - - -#define SANGOMA_MAX_CHAN_PER_SPAN 32 - -static call_info_t pidmap[SANGOMA_MAX_CHAN_PER_SPAN]; - -FIO_EVENT_CB_FUNCTION(my_ftdm_event_handler) -{ - if (event->e_type = FTDM_EVENT_DTMF) { - char *dtmf = event->data; - printf("DTMF %s\n", dtmf); - } -} - -/* Stupid runtime process to play a file to a b channel*/ -#define BYTES 320 -#define MAX_BYTES 1000 - -static int ready = 1; - -static void handle_SIGINT(int sig) -{ - if (sig) { - ready = 0; - } - - return; -} - -static void launch_channel(struct sangoma_pri *spri, int channo) -{ - pid_t pid; - int fd = 0, file = 0, inlen = 0, outlen = 0; - unsigned char inframe[MAX_BYTES], outframe[MAX_BYTES]; - fd_set readfds; - int mtu_mru=BYTES / 2; - int err; - ftdm_channel_t *chan; - ftdm_codec_t codec = FTDM_CODEC_SLIN; - unsigned ms = 20; - unsigned int lead = 50; - int ifd = -1; - ftdm_tone_type_t tt = FTDM_TONE_DTMF; - char dtmf[] = "1234567890"; - int loops = 0; - - pid = fork(); - - if (pid) { - pidmap[channo-1].pid = pid; - printf("-- Launching process %d to handle channel %d\n", pid, channo); - return; - } - - signal(SIGINT, handle_SIGINT); - - //ifd = open("/nfs/sounds/ptest.raw", O_WRONLY|O_CREAT|O_TRUNC, 777); - - memset(inframe, 0, MAX_BYTES); - memset(outframe, 0, MAX_BYTES); - - if (ftdm_channel_open(spri->span, channo, &chan) != FTDM_SUCCESS) { - printf("DEBUG cant open fd!\n"); - } - - - -#if 1 - if (ftdm_channel_command(chan, FTDM_COMMAND_SET_CODEC, &codec) != FTDM_SUCCESS) { - printf("Critical Error: Failed to set driver codec!\n"); - ftdm_channel_close(&chan); - exit(-1); - } -#endif - -#if 1 - if (ftdm_channel_command(chan, FTDM_COMMAND_ENABLE_DTMF_DETECT, &tt) != FTDM_SUCCESS) { - printf("Critical Error: Failed to set dtmf detect!\n"); - ftdm_channel_close(&chan); - exit(-1); - } - ftdm_channel_set_event_callback(chan, my_ftdm_event_handler); -#endif - - - if (ftdm_channel_command(chan, FTDM_COMMAND_SET_INTERVAL, &ms) != FTDM_SUCCESS) { - printf("Critical Error: Failed to set codec interval!\n"); - ftdm_channel_close(&chan); - exit(-1); - } - - file = open("sound.raw", O_RDONLY); - if (file < 0){ - printf("Critical Error: Failed to open sound file!\n"); - ftdm_channel_close(&chan); - exit(-1); - } - - - while(ready) { - ftdm_wait_flag_t flags = FTDM_READ; - ftdm_size_t len; - loops++; - - if (lead) { - lead--; - } - - if (!lead && loops == 300) { -#if 1 - if (ftdm_channel_command(chan, FTDM_COMMAND_SEND_DTMF, dtmf) != FTDM_SUCCESS) { - printf("Critical Error: Failed to send dtmf\n"); - ftdm_channel_close(&chan); - exit(-1); - } -#endif - - } - - if (ftdm_channel_wait(chan, &flags, 2000) != FTDM_SUCCESS) { - printf("wait FAIL! [%s]\n", chan->last_error); - break; - } - - if (flags & FTDM_READ) { - len = MAX_BYTES; - if (ftdm_channel_read(chan, inframe, &len) == FTDM_SUCCESS) { - //printf("READ: %d\n", len); - //write(ifd, inframe, len); - if(!lead && (outlen = read(file, outframe, len)) <= 0) { - break; - } - - } else { - printf("READ FAIL! %d [%s]\n", len, chan->last_error); - break; - } - if (lead) { - continue; - } - ftdm_channel_write(chan, outframe, sizeof(outframe), &len); - } else { - printf("BREAK"); - break; - } - } - - printf("loop done\n"); - - //sangoma_get_full_cfg(fd, &tdm_api); - close(file); - //close(ifd); - - pri_hangup(spri->pri, channo, 16); - if (ftdm_channel_close(&chan) != FTDM_SUCCESS) { - printf("Critical Error: Failed to close channel [%s]\n", chan->last_error); - } - - printf("Call Handler: Process Finished\n"); - exit(0); -} - - -/* Event Handlers */ - -static int on_info(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *event) -{ - printf( "number is: %s\n", event->ring.callednum); - if(strlen(event->ring.callednum) > 3) { - printf( "final number is: %s\n", event->ring.callednum); - pri_answer(spri->pri, event->ring.call, 0, 1); - } - return 0; -} - -static int on_hangup(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *event) -{ - //pri_hangup(spri->pri, event->hangup.call, event->hangup.cause); - printf("-- Hanging up channel %d\n", event->hangup.channel); - if(pidmap[event->hangup.channel-1].pid) { - pri_hangup(spri->pri, event->hangup.call, 16); - pri_destroycall(spri->pri, event->hangup.call); - kill(pidmap[event->hangup.channel-1].pid, SIGINT); - pidmap[event->hangup.channel-1].pid = 0; - } - return 0; -} - -static int on_ring(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *event) -{ - printf("-- Ring on channel %d (from %s to %s), answering...\n", event->ring.channel, event->ring.callingnum, event->ring.callednum); - pri_answer(spri->pri, event->ring.call, event->ring.channel, 1); - memcpy(&pidmap[event->ring.channel-1].call, event->ring.call, sizeof(q931_call)); - pidmap[event->ring.channel-1].pri=spri->pri; - pidmap[event->ring.channel-1].call = *event->ring.call; - launch_channel(spri, event->ring.channel); - return 0; -} - -static int on_restart(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *event) -{ - printf("-- Restarting channel %d\n", event->restart.channel); - return 0; -} - -static int on_anything(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *event) -{ - printf("%s: Caught Event %d (%s)\n", __FTDM_FUNC__, event_type, sangoma_pri_event_str(event_type)); - return 0; -} - -/* Generic Reaper */ -static void chan_ended(int sig) -{ - int status; - int x; - struct rusage rusage; - pid_t pid; - pid = wait4(-1, &status, WNOHANG, &rusage); - - printf("-- PID %d ended\n", pid); - - for (x=0;x -1) { - fprintf(stderr, "--!! Unknown PID %d exited\n", pid); - signal(SIGCHLD, chan_ended); - return; - } -} - -/* Our Program */ -int main(int argc, char *argv[]) -{ - struct sangoma_pri spri; - int debug = 0; - if (argv[1]) { - debug = atoi(argv[1]); - } - - ftdm_global_set_default_logger(FTDM_LOG_LEVEL_DEBUG); - if (ftdm_global_init() != FTDM_SUCCESS) { - fprintf(stderr, "Error loading FreeTDM\n"); - exit(-1); - } - - printf("FreeTDM loaded\n"); - - - debug = PRI_DEBUG_Q931_DUMP | PRI_DEBUG_Q931_STATE; - printf("WTF %d\n", debug); - - if (sangoma_init_pri(&spri, - 1, // span - 24, // dchan - SANGOMA_PRI_SWITCH_DMS100, - SANGOMA_PRI_CPE, - debug) < 0) { - return -1; - } - //spri.pri->debug = (PRI_DEBUG_Q931_DUMP | PRI_DEBUG_Q921_DUMP | PRI_DEBUG_Q921_RAW | PRI_DEBUG_Q921_STATE); - - //pri_set_debug(&spri.pri, (PRI_DEBUG_Q931_DUMP | PRI_DEBUG_Q921_DUMP | PRI_DEBUG_Q921_RAW | PRI_DEBUG_Q921_STATE)); - - SANGOMA_MAP_PRI_EVENT(spri, SANGOMA_PRI_EVENT_ANY, on_anything); - SANGOMA_MAP_PRI_EVENT(spri, SANGOMA_PRI_EVENT_RING, on_ring); - SANGOMA_MAP_PRI_EVENT(spri, SANGOMA_PRI_EVENT_HANGUP, on_hangup); - SANGOMA_MAP_PRI_EVENT(spri, SANGOMA_PRI_EVENT_HANGUP_REQ, on_hangup); - SANGOMA_MAP_PRI_EVENT(spri, SANGOMA_PRI_EVENT_INFO_RECEIVED, on_info); - SANGOMA_MAP_PRI_EVENT(spri, SANGOMA_PRI_EVENT_RESTART, on_restart); - - signal(SIGCHLD, chan_ended); - sangoma_run_pri(&spri); - return 0; -} - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/sangoma_pri.c b/libs/freetdm/src/sangoma_pri.c deleted file mode 100644 index a6e79c9682..0000000000 --- a/libs/freetdm/src/sangoma_pri.c +++ /dev/null @@ -1,251 +0,0 @@ -/***************************************************************************** - * sangoma_pri.c libpri Sangoma integration - * - * Author(s): Anthony Minessale II - * Nenad Corbic - * - * Copyright: (c) 2005-2014 Anthony Minessale II - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version - * 2 of the License, or (at your option) any later version. - * ============================================================================ - */ - -#include "freetdm.h" -#include -#ifndef HAVE_GETTIMEOFDAY - -#ifdef WIN32 -#include - -static __inline int gettimeofday(struct timeval *tp, void *nothing) -{ -#ifdef WITHOUT_MM_LIB - SYSTEMTIME st; - time_t tt; - struct tm tmtm; - /* mktime converts local to UTC */ - GetLocalTime (&st); - tmtm.tm_sec = st.wSecond; - tmtm.tm_min = st.wMinute; - tmtm.tm_hour = st.wHour; - tmtm.tm_mday = st.wDay; - tmtm.tm_mon = st.wMonth - 1; - tmtm.tm_year = st.wYear - 1900; tmtm.tm_isdst = -1; - tt = mktime (&tmtm); - tp->tv_sec = tt; - tp->tv_usec = st.wMilliseconds * 1000; -#else - /** - ** The earlier time calculations using GetLocalTime - ** had a time resolution of 10ms.The timeGetTime, part - ** of multimedia apis offer a better time resolution - ** of 1ms.Need to link against winmm.lib for this - **/ - unsigned long Ticks = 0; - unsigned long Sec =0; - unsigned long Usec = 0; - Ticks = timeGetTime(); - - Sec = Ticks/1000; - Usec = (Ticks - (Sec*1000))*1000; - tp->tv_sec = Sec; - tp->tv_usec = Usec; -#endif /* WITHOUT_MM_LIB */ - (void)nothing; - return 0; -} -#endif /* WIN32 */ -#endif /* HAVE_GETTIMEOFDAY */ - -static struct sangoma_pri_event_list SANGOMA_PRI_EVENT_LIST[] = { - {0, SANGOMA_PRI_EVENT_ANY, "ANY"}, - {1, SANGOMA_PRI_EVENT_DCHAN_UP, "DCHAN_UP"}, - {2, SANGOMA_PRI_EVENT_DCHAN_DOWN, "DCHAN_DOWN"}, - {3, SANGOMA_PRI_EVENT_RESTART, "RESTART"}, - {4, SANGOMA_PRI_EVENT_CONFIG_ERR, "CONFIG_ERR"}, - {5, SANGOMA_PRI_EVENT_RING, "RING"}, - {6, SANGOMA_PRI_EVENT_HANGUP, "HANGUP"}, - {7, SANGOMA_PRI_EVENT_RINGING, "RINGING"}, - {8, SANGOMA_PRI_EVENT_ANSWER, "ANSWER"}, - {9, SANGOMA_PRI_EVENT_HANGUP_ACK, "HANGUP_ACK"}, - {10, SANGOMA_PRI_EVENT_RESTART_ACK, "RESTART_ACK"}, - {11, SANGOMA_PRI_EVENT_FACNAME, "FACNAME"}, - {12, SANGOMA_PRI_EVENT_INFO_RECEIVED, "INFO_RECEIVED"}, - {13, SANGOMA_PRI_EVENT_PROCEEDING, "PROCEEDING"}, - {14, SANGOMA_PRI_EVENT_SETUP_ACK, "SETUP_ACK"}, - {15, SANGOMA_PRI_EVENT_HANGUP_REQ, "HANGUP_REQ"}, - {16, SANGOMA_PRI_EVENT_NOTIFY, "NOTIFY"}, - {17, SANGOMA_PRI_EVENT_PROGRESS, "PROGRESS"}, - {18, SANGOMA_PRI_EVENT_KEYPAD_DIGIT, "KEYPAD_DIGIT"} -}; - -#define LINE "--------------------------------------------------------------------------------" - -char *sangoma_pri_event_str(sangoma_pri_event_t event_id) -{ - return SANGOMA_PRI_EVENT_LIST[event_id].name; -} - -static int __pri_sangoma_read(struct pri *pri, void *buf, int buflen) -{ - struct sangoma_pri *spri = (struct sangoma_pri *) pri->userdata; - ftdm_size_t len = buflen; - int res; - char bb[4096] = ""; - - - if (ftdm_channel_read(spri->zdchan, buf, &len) != FTDM_SUCCESS) { - printf("D-READ FAIL! [%s]\n", spri->zdchan->last_error); - return 0; - } - res = (int)len; - memset(&((unsigned char*)buf)[res],0,2); - res+=2; - - //print_bits(buf, res-2, bb, sizeof(bb), 1, 0); - //ftdm_log(FTDM_LOG_DEBUG, "READ %d\n%s\n%s\n\n", res-2, LINE, bb); - - return res; -} - -static int __pri_sangoma_write(struct pri *pri, void *buf, int buflen) -{ - struct sangoma_pri *spri = (struct sangoma_pri *) pri->userdata; - int res; - ftdm_size_t len = buflen -2; - char bb[4096] = ""; - - if (ftdm_channel_write(spri->zdchan, buf, buflen, &len) != FTDM_SUCCESS) { - printf("D-WRITE FAIL! [%s]\n", spri->zdchan->last_error); - return 0; - } - - //print_bits(buf, (int)buflen-2, bb, sizeof(bb), 1, 0); - //ftdm_log(FTDM_LOG_DEBUG, "WRITE %d\n%s\n%s\n\n", (int)buflen-2, LINE, bb); - - return (int) buflen; -} - -int sangoma_init_pri(struct sangoma_pri *spri, int span, int dchan, int swtype, int node, int debug) -{ - int ret = -1; - ftdm_socket_t dfd = 0; - - memset(spri, 0, sizeof(struct sangoma_pri)); - - if (ftdm_channel_open(span, dchan, &spri->zdchan) != FTDM_SUCCESS) { - fprintf(stderr, "Unable to open DCHAN %d for span %d (%s)\n", dchan, span, strerror(errno)); - } else { - if ((spri->pri = pri_new_cb(spri->zdchan->sockfd, node, swtype, __pri_sangoma_read, __pri_sangoma_write, spri))){ - spri->span = span; - pri_set_debug(spri->pri, debug); - ret = 0; - } else { - fprintf(stderr, "Unable to create PRI\n"); - } - } - return ret; -} - - -int sangoma_one_loop(struct sangoma_pri *spri) -{ - fd_set rfds, efds; - struct timeval now = {0,0}, *next; - pri_event *event; - int sel; - - if (spri->on_loop) { - spri->on_loop(spri); - } - - FD_ZERO(&rfds); - FD_ZERO(&efds); - -#ifdef _MSC_VER - //Windows macro for FD_SET includes a warning C4127: conditional expression is constant -#pragma warning(push) -#pragma warning(disable:4127) -#endif - - FD_SET(spri->pri->fd, &rfds); - FD_SET(spri->pri->fd, &efds); - -#ifdef _MSC_VER -#pragma warning(pop) -#endif - - if ((next = pri_schedule_next(spri->pri))) { - gettimeofday(&now, NULL); - now.tv_sec = next->tv_sec - now.tv_sec; - now.tv_usec = next->tv_usec - now.tv_usec; - if (now.tv_usec < 0) { - now.tv_usec += 1000000; - now.tv_sec -= 1; - } - if (now.tv_sec < 0) { - now.tv_sec = 0; - now.tv_usec = 0; - } - } - - sel = select(spri->pri->fd + 1, &rfds, NULL, &efds, next ? &now : NULL); - event = NULL; - - if (!sel) { - event = pri_schedule_run(spri->pri); - } else if (sel > 0) { - event = pri_check_event(spri->pri); - } - - if (event) { - event_handler handler; - /* 0 is catchall event handler */ - if ((handler = spri->eventmap[event->e] ? spri->eventmap[event->e] : spri->eventmap[0] ? spri->eventmap[0] : NULL)) { - handler(spri, event->e, event); - } else { - fprintf(stderr,"No event handler found for event %d.\n", event->e); - } - } - - return sel; -} - -int sangoma_run_pri(struct sangoma_pri *spri) -{ - int ret = 0; - - for (;;){ - ret=sangoma_one_loop(spri); - if (ret < 0){ - -#ifndef WIN32 //This needs to be adressed fror WIN32 still - if (errno == EINTR){ - /* Igonore an interrupted system call */ - continue; - } -#endif - printf("Error = %i\n",ret); - perror("Sangoma Run Pri: "); - break; - } - } - - return ret; - -} - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ - diff --git a/libs/freetdm/src/sangoma_pri.h b/libs/freetdm/src/sangoma_pri.h deleted file mode 100644 index 873aab8a27..0000000000 --- a/libs/freetdm/src/sangoma_pri.h +++ /dev/null @@ -1,100 +0,0 @@ -/***************************************************************************** - * libsangoma.c AFT T1/E1: HDLC API Code Library - * - * Author(s): Anthony Minessale II - * Nenad Corbic - * - * Copyright: (c) 2005-2014 Anthony Minessale II - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version - * 2 of the License, or (at your option) any later version. - * ============================================================================ - */ - -#ifndef _SANGOMA_PRI_H -#define _SANGOMA_PRI_H -#include -#include - - -#define SANGOMA_MAX_CHAN_PER_SPAN 32 - -typedef enum { - SANGOMA_PRI_EVENT_ANY = 0, - SANGOMA_PRI_EVENT_DCHAN_UP = PRI_EVENT_DCHAN_UP, - SANGOMA_PRI_EVENT_DCHAN_DOWN = PRI_EVENT_DCHAN_DOWN, - SANGOMA_PRI_EVENT_RESTART = PRI_EVENT_RESTART, - SANGOMA_PRI_EVENT_CONFIG_ERR = PRI_EVENT_CONFIG_ERR, - SANGOMA_PRI_EVENT_RING = PRI_EVENT_RING, - SANGOMA_PRI_EVENT_HANGUP = PRI_EVENT_HANGUP, - SANGOMA_PRI_EVENT_RINGING = PRI_EVENT_RINGING, - SANGOMA_PRI_EVENT_ANSWER = PRI_EVENT_ANSWER, - SANGOMA_PRI_EVENT_HANGUP_ACK = PRI_EVENT_HANGUP_ACK, - SANGOMA_PRI_EVENT_RESTART_ACK = PRI_EVENT_RESTART_ACK, - SANGOMA_PRI_EVENT_FACNAME = PRI_EVENT_FACNAME, - SANGOMA_PRI_EVENT_INFO_RECEIVED = PRI_EVENT_INFO_RECEIVED, - SANGOMA_PRI_EVENT_PROCEEDING = PRI_EVENT_PROCEEDING, - SANGOMA_PRI_EVENT_SETUP_ACK = PRI_EVENT_SETUP_ACK, - SANGOMA_PRI_EVENT_HANGUP_REQ = PRI_EVENT_HANGUP_REQ, - SANGOMA_PRI_EVENT_NOTIFY = PRI_EVENT_NOTIFY, - SANGOMA_PRI_EVENT_PROGRESS = PRI_EVENT_PROGRESS, - SANGOMA_PRI_EVENT_KEYPAD_DIGIT = PRI_EVENT_KEYPAD_DIGIT -} sangoma_pri_event_t; - -typedef enum { - SANGOMA_PRI_NETWORK = PRI_NETWORK, - SANGOMA_PRI_CPE = PRI_CPE -} sangoma_pri_node_t; - -typedef enum { - SANGOMA_PRI_SWITCH_UNKNOWN = PRI_SWITCH_UNKNOWN, - SANGOMA_PRI_SWITCH_NI2 = PRI_SWITCH_NI2, - SANGOMA_PRI_SWITCH_DMS100 = PRI_SWITCH_DMS100, - SANGOMA_PRI_SWITCH_LUCENT5E = PRI_SWITCH_LUCENT5E, - SANGOMA_PRI_SWITCH_ATT4ESS = PRI_SWITCH_ATT4ESS, - SANGOMA_PRI_SWITCH_EUROISDN_E1 = PRI_SWITCH_EUROISDN_E1, - SANGOMA_PRI_SWITCH_EUROISDN_T1 = PRI_SWITCH_EUROISDN_T1, - SANGOMA_PRI_SWITCH_NI1 = PRI_SWITCH_NI1, - SANGOMA_PRI_SWITCH_GR303_EOC = PRI_SWITCH_GR303_EOC, - SANGOMA_PRI_SWITCH_GR303_TMC = PRI_SWITCH_GR303_TMC, - SANGOMA_PRI_SWITCH_QSIG = PRI_SWITCH_QSIG -} sangoma_pri_switch_t; - -typedef enum { - SANGOMA_PRI_READY = (1 << 0) -} sangoma_pri_flag_t; - -struct sangoma_pri; -typedef int (*event_handler)(struct sangoma_pri *, sangoma_pri_event_t, pri_event *); -typedef int (*loop_handler)(struct sangoma_pri *); -#define MAX_EVENT 18 - -struct sangoma_pri { - struct pri *pri; - int span; - int dchan; - unsigned int flags; - void *private_info; - event_handler eventmap[MAX_EVENT+1]; - loop_handler on_loop; - ftdm_channel_t *zdchan; -}; - -struct sangoma_pri_event_list { - int event_id; - int pri_event; - char *name; -}; - - - -#define SANGOMA_MAP_PRI_EVENT(spri, event, func) spri.eventmap[event] = func; - -char *sangoma_pri_event_str(sangoma_pri_event_t event_id); -int sangoma_one_loop(struct sangoma_pri *spri); -int sangoma_init_pri(struct sangoma_pri *spri, int span, int dchan, int swtype, int node, int debug); -int sangoma_run_pri(struct sangoma_pri *spri); - -#endif diff --git a/libs/freetdm/src/ss7/README b/libs/freetdm/src/ss7/README deleted file mode 100644 index 0efe94c94a..0000000000 --- a/libs/freetdm/src/ss7/README +++ /dev/null @@ -1,3 +0,0 @@ -SS7 Coming soon - --Shane Burrell- diff --git a/libs/freetdm/src/testanalog.c b/libs/freetdm/src/testanalog.c deleted file mode 100644 index 764c5d81d5..0000000000 --- a/libs/freetdm/src/testanalog.c +++ /dev/null @@ -1,138 +0,0 @@ -#include -#include -#include -#include "freetdm.h" - - -static void *test_call(ftdm_thread_t *me, void *obj) -{ - ftdm_channel_t *chan = (ftdm_channel_t *) obj; - uint8_t frame[1024]; - ftdm_size_t len; - char *number = ftdm_strdup("5551212"); - - ftdm_unused_arg(me); - - ftdm_sleep(10 * 1000); - - ftdm_log(FTDM_LOG_DEBUG, "answer call and start echo test\n"); - - ftdm_channel_call_answer(chan); - ftdm_channel_command(chan, FTDM_COMMAND_SEND_DTMF, number); - - while (ftdm_channel_call_check_answered(chan)) { - ftdm_wait_flag_t flags = FTDM_READ; - - if (ftdm_channel_wait(chan, &flags, -1) == FTDM_FAIL) { - break; - } - len = sizeof(frame); - if (flags & FTDM_READ) { - if (ftdm_channel_read(chan, frame, &len) == FTDM_SUCCESS) { - //ftdm_log(FTDM_LOG_DEBUG, "WRITE %d\n", len); - ftdm_channel_write(chan, frame, sizeof(frame), &len); - } else { - break; - } - } - } - - if (ftdm_channel_call_check_answered(chan)) { - ftdm_channel_call_indicate(chan, FTDM_CHANNEL_INDICATE_BUSY); - } - - ftdm_log(FTDM_LOG_DEBUG, "call over\n"); - ftdm_safe_free(number); - return NULL; -} - -static FIO_SIGNAL_CB_FUNCTION(on_signal) -{ - ftdm_log(FTDM_LOG_DEBUG, "got sig [%s]\n", ftdm_signal_event2str(sigmsg->event_id)); - - switch(sigmsg->event_id) { - case FTDM_SIGEVENT_START: - ftdm_channel_call_indicate(sigmsg->channel, FTDM_CHANNEL_INDICATE_RINGING); - ftdm_log(FTDM_LOG_DEBUG, "launching thread and indicating ring\n"); - ftdm_thread_create_detached(test_call, sigmsg->channel); - break; - default: - break; - } - - return FTDM_SUCCESS; -} - -static int R = 0; -#if 0 -static void handle_SIGINT(int sig) -{ - if (sig); - R = 0; - return; -} -#endif - -int main(int argc, char *argv[]) -{ - ftdm_span_t *span; - int span_id; - int digit_timeout = 2000; - int max_dialstr = 11; - - if (argc < 2) { - printf("usage %s \n", argv[0]); - exit(-1); - } - - span_id = atoi(argv[1]); - - ftdm_global_set_default_logger(FTDM_LOG_LEVEL_DEBUG); - - if (ftdm_global_init() != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "Error loading FreeTDM\n"); - exit(-1); - } - - ftdm_log(FTDM_LOG_DEBUG, "FreeTDM loaded\n"); - - if (ftdm_span_find(span_id, &span) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "Error finding FreeTDM span\n"); - goto done; - } - - - if (ftdm_configure_span(span, "analog", on_signal, - "tonemap", "us", - "digit_timeout", &digit_timeout, - "max_dialstr", &max_dialstr, - FTDM_TAG_END - ) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "Error configuring FreeTDM span\n"); - goto done; - } - ftdm_span_start(span); - - R = 1; - - while(ftdm_running() && R) { - ftdm_sleep(1 * 1000); - } - -done: - - ftdm_global_destroy(); - return 0; -} - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ - diff --git a/libs/freetdm/src/testapp.c b/libs/freetdm/src/testapp.c deleted file mode 100644 index 1d7a2cb8cb..0000000000 --- a/libs/freetdm/src/testapp.c +++ /dev/null @@ -1,89 +0,0 @@ -#include "freetdm.h" -#include - -int main(int argc, char *argv[]) -{ - ftdm_global_set_default_logger(FTDM_LOG_LEVEL_DEBUG); - ftdm_channel_t *chan; - unsigned ms = 20; - ftdm_codec_t codec = FTDM_CODEC_SLIN; - unsigned runs = 1; - int spanid, chanid; - - ftdm_unused_arg(argc); - ftdm_unused_arg(argv); - - if (ftdm_global_init() != FTDM_SUCCESS) { - fprintf(stderr, "Error loading FreeTDM\n"); - exit(-1); - } - - printf("FreeTDM loaded\n"); - - top: - //if (ftdm_channel_open_any("wanpipe", 0, FTDM_HUNT_BOTTOM_UP, &chan) == FTDM_SUCCESS) { - if (ftdm_channel_open(1, 1, &chan) == FTDM_SUCCESS) { - int x = 0; - spanid = ftdm_channel_get_span_id(chan); - chanid = ftdm_channel_get_id(chan); - printf("opened channel %d:%d\n", spanid, chanid); - -#if 1 - if (ftdm_channel_command(chan, FTDM_COMMAND_SET_INTERVAL, &ms) == FTDM_SUCCESS) { - ms = 0; - ftdm_channel_command(chan, FTDM_COMMAND_GET_INTERVAL, &ms); - printf("interval set to %u\n", ms); - } else { - printf("set interval failed [%s]\n", ftdm_channel_get_last_error(chan)); - } -#endif - if (ftdm_channel_command(chan, FTDM_COMMAND_SET_CODEC, &codec) == FTDM_SUCCESS) { - codec = 1; - ftdm_channel_command(chan, FTDM_COMMAND_GET_CODEC, &codec); - printf("codec set to %u\n", codec); - } else { - printf("set codec failed [%s]\n", ftdm_channel_get_last_error(chan)); - } - - for(x = 0; x < 25; x++) { - unsigned char buf[2048]; - ftdm_size_t len = sizeof(buf); - ftdm_wait_flag_t flags = FTDM_READ; - - if (ftdm_channel_wait(chan, &flags, -1) == FTDM_FAIL) { - printf("wait FAIL! %u [%s]\n", (unsigned)len, ftdm_channel_get_last_error(chan)); - } - if (flags & FTDM_READ) { - if (ftdm_channel_read(chan, buf, &len) == FTDM_SUCCESS) { - printf("READ: %u\n", (unsigned)len); - } else { - printf("READ FAIL! %u [%s]\n", (unsigned)len, ftdm_channel_get_last_error(chan)); - break; - } - } else { - printf("wait fail [%s]\n", ftdm_channel_get_last_error(chan)); - } - } - ftdm_channel_close(&chan); - } else { - printf("open fail [%s]\n", ftdm_channel_get_last_error(chan)); - } - - if(--runs) { - goto top; - } - - ftdm_global_destroy(); - return 0; -} - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/testcid.c b/libs/freetdm/src/testcid.c deleted file mode 100644 index e6a0116d4a..0000000000 --- a/libs/freetdm/src/testcid.c +++ /dev/null @@ -1,109 +0,0 @@ -#include "private/ftdm_core.h" - -ftdm_status_t my_write_sample(int16_t *buf, ftdm_size_t buflen, void *user_data); - -struct helper { - int fd; - int wrote; -}; - -ftdm_status_t my_write_sample(int16_t *buf, ftdm_size_t buflen, void *user_data) -{ - struct helper *foo = (struct helper *) user_data; - size_t len; - len = write(foo->fd, buf, buflen * 2); - if (!len) return FTDM_FAIL; - foo->wrote += buflen * 2; - return FTDM_SUCCESS; -} - -int main(int argc, char *argv[]) -{ - struct ftdm_fsk_modulator fsk_trans; - ftdm_fsk_data_state_t fsk_data = {0}; - int fd = -1; - int16_t buf[160] = {0}; - ssize_t len = 0; - size_t type, mlen; - char *sp; - char str[128] = ""; - char fbuf[256]; - uint8_t databuf[1024] = ""; - struct helper foo = {0}; - // int x, bytes, start_bits = 180, stop_bits = 5, sbits = 300; - char time_str[9]; - struct tm tm; - time_t now; - - if (argc < 2) { - int x; - const char *url = "sip:cool@rad.com"; - - if ((fd = open("tone.raw", O_WRONLY | O_TRUNC | O_CREAT, S_IRUSR | S_IWUSR)) < 0) { - fprintf(stderr, "File Error! [%s]\n", strerror(errno)); - exit(-1); - } - - - time(&now); - localtime_r(&now, &tm); - strftime(time_str, sizeof(time_str), "%m%d%H%M", &tm); - - ftdm_fsk_data_init(&fsk_data, databuf, sizeof(databuf)); -#if 1 - - ftdm_fsk_data_add_mdmf(&fsk_data, MDMF_DATETIME, (uint8_t *)time_str, strlen(time_str)); - //ftdm_fsk_data_add_mdmf(&fsk_data, MDMF_DATETIME, "06091213", 8); - ftdm_fsk_data_add_mdmf(&fsk_data, MDMF_PHONE_NUM, (uint8_t *)"14149361212", 7); - ftdm_fsk_data_add_mdmf(&fsk_data, MDMF_PHONE_NAME, (uint8_t *)"Fred Smith", 10); - for(x = 0; x < 0; x++) - ftdm_fsk_data_add_mdmf(&fsk_data, MDMF_ALT_ROUTE, (uint8_t *)url, strlen(url)); -#else - ftdm_fsk_data_add_sdmf(&fsk_data, "06061234", "0"); - //ftdm_fsk_data_add_sdmf(&state, "06061234", "5551212"); -#endif - ftdm_fsk_data_add_checksum(&fsk_data); - - foo.fd = fd; - - - ftdm_fsk_modulator_init(&fsk_trans, FSK_BELL202, 8000, &fsk_data, -14, 180, 5, 300, my_write_sample, &foo); - ftdm_fsk_modulator_send_all((&fsk_trans)); - - printf("%u %d %d\n", (unsigned) fsk_data.dlen, foo.wrote, fsk_trans.est_bytes); - - if (fd > -1) { - close (fd); - } - - return 0; - } - - if (ftdm_fsk_demod_init(&fsk_data, 8000, (uint8_t *)fbuf, sizeof(fbuf))) { - printf("wtf\n"); - return 0; - } - - if ((fd = open(argv[1], O_RDONLY)) < 0) { - fprintf(stderr, "cant open file %s\n", argv[1]); - exit (-1); - } - - while((len = read(fd, buf, sizeof(buf))) > 0) { - if (ftdm_fsk_demod_feed(&fsk_data, buf, len / 2) != FTDM_SUCCESS) { - break; - } - } - - while(ftdm_fsk_data_parse(&fsk_data, &type, &sp, &mlen) == FTDM_SUCCESS) { - ftdm_copy_string(str, sp, mlen+1); - *(str+mlen) = '\0'; - ftdm_clean_string(str); - printf("TYPE %u (%s) LEN %u VAL [%s]\n", (unsigned)type, ftdm_mdmf_type2str(type), (unsigned)mlen, str); - } - - ftdm_fsk_demod_destroy(&fsk_data); - - close(fd); - return 0; -} diff --git a/libs/freetdm/src/testisdn.c b/libs/freetdm/src/testisdn.c deleted file mode 100644 index 13e14aedd2..0000000000 --- a/libs/freetdm/src/testisdn.c +++ /dev/null @@ -1,74 +0,0 @@ -#include "freetdm.h" -#include - - -static FIO_SIGNAL_CB_FUNCTION(on_signal) -{ - return FTDM_FAIL; -} - -static int R = 0; -static void handle_SIGINT(int sig) -{ - if (sig); - R = 0; - return; -} - -int main(int argc, char *argv[]) -{ - ftdm_span_t *span; - - ftdm_global_set_default_logger(FTDM_LOG_LEVEL_DEBUG); - - if (argc < 2) { - printf("umm no\n"); - exit(-1); - } - - if (ftdm_global_init() != FTDM_SUCCESS) { - fprintf(stderr, "Error loading FreeTDM\n"); - exit(-1); - } - - printf("FreeTDM loaded\n"); - - if (ftdm_span_find(atoi(argv[1]), &span) != FTDM_SUCCESS) { - fprintf(stderr, "Error finding FreeTDM span\n"); - goto done; - } - - if (ftdm_configure_span("isdn", span, on_signal, - "mode", "te", - "dialect", "national", - TAG_END) == FTDM_SUCCESS) { - ftdm_span_start(span); - } else { - fprintf(stderr, "Error starting ISDN D-Channel\n"); - goto done; - } - - signal(SIGINT, handle_SIGINT); - R = 1; - while(R) { - ftdm_sleep(1 * 1000); - } - - done: - - ftdm_global_destroy(); - - return 1; - -} - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/testpri.c b/libs/freetdm/src/testpri.c deleted file mode 100644 index fb7c0bdd38..0000000000 --- a/libs/freetdm/src/testpri.c +++ /dev/null @@ -1,174 +0,0 @@ -#include "freetdm.h" -#include -#include -#include -#include -#include -#include -#include - -static int THREADS[4][31] = { {0} }; -static int R = 0; -static int T = 0; -static ftdm_mutex_t *mutex = NULL; - - -static void *channel_run(ftdm_thread_t *me, void *obj) -{ - ftdm_channel_t *ftdmchan = obj; - int fd = -1; - short buf[160]; - int spanid = ftdm_channel_get_span_id(ftdmchan); - int chanid = ftdm_channel_get_id(ftdmchan); - - ftdm_unused_arg(me); - - ftdm_mutex_lock(mutex); - T++; - ftdm_mutex_unlock(mutex); - - ftdm_channel_call_answer(ftdmchan); - - if ((fd = open("test.raw", O_RDONLY, 0)) < 0) { - goto end; - } - - while(R == 1 && THREADS[spanid][chanid] == 1) { - ssize_t bytes = read(fd, buf, sizeof(buf)); - size_t bbytes; - - if (bytes <= 0) { - break; - } - - bbytes = (size_t) bytes; - - fio_slin2alaw(buf, sizeof(buf), &bbytes); - - if (ftdm_channel_write(ftdmchan, buf, sizeof(buf), &bbytes) != FTDM_SUCCESS) { - break; - } - } - - close(fd); - - end: - - ftdm_channel_call_hangup(ftdmchan); - - THREADS[spanid][chanid] = 0; - - ftdm_mutex_lock(mutex); - T = 0; - ftdm_mutex_unlock(mutex); - - return NULL; -} - -static FIO_SIGNAL_CB_FUNCTION(on_signal) -{ - int spanid = ftdm_channel_get_span_id(sigmsg->channel); - int chanid = ftdm_channel_get_id(sigmsg->channel); - ftdm_log(FTDM_LOG_DEBUG, "got sig %d:%d [%s]\n", spanid, chanid, ftdm_signal_event2str(sigmsg->event_id)); - - switch(sigmsg->event_id) { - - case FTDM_SIGEVENT_STOP: - THREADS[spanid][chanid] = -1; - break; - - case FTDM_SIGEVENT_START: - if (!THREADS[spanid][chanid]) { - THREADS[spanid][chanid] = 1; - ftdm_thread_create_detached(channel_run, sigmsg->channel); - } - - break; - default: - break; - } - - return FTDM_SUCCESS; -} - - -static void handle_SIGINT(int sig) -{ - ftdm_unused_arg(sig); - - ftdm_mutex_lock(mutex); - R = 0; - ftdm_mutex_unlock(mutex); - - return; -} - -int main(int argc, char *argv[]) -{ - ftdm_span_t *span; - ftdm_mutex_create(&mutex); - - ftdm_global_set_default_logger(FTDM_LOG_LEVEL_DEBUG); - - if (argc < 2) { - printf("umm no\n"); - exit(-1); - } - - if (ftdm_global_init() != FTDM_SUCCESS) { - fprintf(stderr, "Error loading FreeTDM\n"); - exit(-1); - } - - printf("FreeTDM loaded\n"); - - if (ftdm_span_find(atoi(argv[1]), &span) != FTDM_SUCCESS) { - fprintf(stderr, "Error finding FreeTDM span\n"); - goto done; - } - - - - if (ftdm_configure_span( - span, "libpri", on_signal, - "node", "cpe", - "switch", "euroisdn", - "dp", "unknown", - "l1", "alaw", - "debug", NULL, - "opts", 0, - FTDM_TAG_END) == FTDM_SUCCESS) { - - - ftdm_span_start(span); - } else { - fprintf(stderr, "Error starting ISDN D-Channel\n"); - goto done; - } - - signal(SIGINT, handle_SIGINT); - ftdm_mutex_lock(mutex); - R = 1; - ftdm_mutex_unlock(mutex); - while(R || T) { - ftdm_sleep(1 * 1000); - } - - done: - - ftdm_global_destroy(); - - return 1; - -} - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/testr2.c b/libs/freetdm/src/testr2.c deleted file mode 100644 index ef6897fc29..0000000000 --- a/libs/freetdm/src/testr2.c +++ /dev/null @@ -1,169 +0,0 @@ -#include "freetdm.h" -#include -#include - -static volatile int running = 0; -static ftdm_mutex_t *the_mutex = NULL; -static ftdm_channel_t *fchan = NULL; -static ftdm_channel_indication_t indication = FTDM_CHANNEL_INDICATE_NONE; - -static FIO_SIGNAL_CB_FUNCTION(on_r2_signal) -{ - int chanid = ftdm_channel_get_ph_id(sigmsg->channel); - ftdm_log(FTDM_LOG_DEBUG, "Got R2 channel sig [%s] in channel %d\n", ftdm_signal_event2str(sigmsg->event_id), chanid); - switch (sigmsg->event_id) { - case FTDM_SIGEVENT_START: - { - ftdm_mutex_lock(the_mutex); - if (!fchan) { - fchan = sigmsg->channel; - indication = FTDM_CHANNEL_INDICATE_PROCEED; - } - ftdm_mutex_unlock(the_mutex); - } - break; - case FTDM_SIGEVENT_INDICATION_COMPLETED: - { - ftdm_channel_indication_t ind = FTDM_CHANNEL_INDICATE_NONE; - if (sigmsg->ev_data.indication_completed.indication == FTDM_CHANNEL_INDICATE_PROCEED) { - ftdm_log(FTDM_LOG_DEBUG, "Proceed indication result = %d\n", sigmsg->ev_data.indication_completed.status); - ind = FTDM_CHANNEL_INDICATE_PROGRESS; - } else if (sigmsg->ev_data.indication_completed.indication == FTDM_CHANNEL_INDICATE_PROGRESS) { - ftdm_log(FTDM_LOG_DEBUG, "Progress indication result = %d\n", sigmsg->ev_data.indication_completed.status); - ind = FTDM_CHANNEL_INDICATE_PROGRESS_MEDIA; - } else if (sigmsg->ev_data.indication_completed.indication == FTDM_CHANNEL_INDICATE_PROGRESS_MEDIA) { - ftdm_log(FTDM_LOG_DEBUG, "Progress media indication result = %d\n", sigmsg->ev_data.indication_completed.status); - ind = FTDM_CHANNEL_INDICATE_ANSWER; - } else if (sigmsg->ev_data.indication_completed.indication == FTDM_CHANNEL_INDICATE_ANSWER) { - ftdm_log(FTDM_LOG_DEBUG, "Answer indication result = %d\n", sigmsg->ev_data.indication_completed.status); - } else { - ftdm_log(FTDM_LOG_DEBUG, "Unexpected indication, result = %d\n", sigmsg->ev_data.indication_completed.status); - exit(1); - } - ftdm_mutex_lock(the_mutex); - if (fchan) { - indication = ind; - } - ftdm_mutex_unlock(the_mutex); - } - break; - case FTDM_SIGEVENT_STOP: - { - ftdm_channel_call_hangup(sigmsg->channel); - } - break; - case FTDM_SIGEVENT_RELEASED: - { - ftdm_mutex_lock(the_mutex); - if (fchan && fchan == sigmsg->channel) { - fchan = NULL; - } - ftdm_mutex_unlock(the_mutex); - } - break; - default: - break; - } - return FTDM_SUCCESS; -} - -static void stop_test(int sig) -{ - ftdm_unused_arg(sig); - running = 0; -} - -int main(int argc, char *argv[]) -{ - ftdm_span_t *span; - ftdm_conf_parameter_t parameters[20]; - - ftdm_mutex_create(&the_mutex); - - if (argc < 2) { - printf("umm no\n"); - exit(1); - } - - ftdm_global_set_default_logger(FTDM_LOG_LEVEL_DEBUG); - - if (ftdm_global_init() != FTDM_SUCCESS) { - fprintf(stderr, "Error loading FreeTDM\n"); - exit(1); - } - - ftdm_global_configuration(); - - printf("FreeTDM loaded\n"); - - if (ftdm_span_find_by_name(argv[1], &span) != FTDM_SUCCESS) { - fprintf(stderr, "Error finding FreeTDM span %s\n", argv[1]); - goto done; - } - - /* testing non-blocking operation */ - //ftdm_span_set_blocking_mode(span, FTDM_FALSE); - - parameters[0].var = "variant"; - parameters[0].val = "br"; - - parameters[1].var = "max_ani"; - parameters[1].val = "4"; - - parameters[2].var = "max_dnis"; - parameters[2].val = "4"; - - parameters[3].var = "logging"; - parameters[3].val = "all"; - - parameters[4].var = NULL; - parameters[4].val = NULL; - - if (ftdm_configure_span_signaling(span, "r2", on_r2_signal, parameters) == FTDM_SUCCESS) { - ftdm_span_start(span); - } else { - fprintf(stderr, "Error starting R2 span\n"); - goto done; - } - - running = 1; - signal(SIGINT, stop_test); - while(running) { - ftdm_sleep(20); - if (fchan && indication != FTDM_CHANNEL_INDICATE_NONE) { - ftdm_channel_t *lchan = NULL; - ftdm_channel_indication_t ind = FTDM_CHANNEL_INDICATE_NONE; - ftdm_time_t start, stop, diff; - - ftdm_mutex_lock(the_mutex); - ind = indication; - indication = FTDM_CHANNEL_INDICATE_NONE; - lchan = fchan; - ftdm_mutex_unlock(the_mutex); - - start = ftdm_current_time_in_ms(); - ftdm_channel_call_indicate(lchan, ind); - stop = ftdm_current_time_in_ms(); - diff = stop - start; - ftdm_log(FTDM_LOG_DEBUG, "Setting indication %s took %"FTDM_TIME_FMT" ms\n", - ftdm_channel_indication2str(ind), diff); - } - } - -done: - - ftdm_global_destroy(); - - return 0; -} - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/freetdm/src/testtones.c b/libs/freetdm/src/testtones.c deleted file mode 100644 index d5d5d548bf..0000000000 --- a/libs/freetdm/src/testtones.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "private/ftdm_core.h" - -struct ttmp { - int fd; -}; - -static int teletone_handler(teletone_generation_session_t *ts, teletone_tone_map_t *map) -{ - struct ttmp *tmp = ts->user_data; - int wrote; - size_t len; - - wrote = teletone_mux_tones(ts, map); - len = write(tmp->fd, ts->buffer, wrote * 2); - - if (!len) return -1; - - return 0; -} - -#if 1 -int main(int argc, char *argv[]) -{ - teletone_generation_session_t ts; - struct ttmp tmp; - - if (argc < 3) { - fprintf(stderr, "Arg Error! \n"); - exit(-1); - } - - if ((tmp.fd = open(argv[1], O_WRONLY | O_TRUNC | O_CREAT, S_IRUSR | S_IWUSR)) < 0) { - fprintf(stderr, "File Error! [%s]\n", strerror(errno)); - exit(-1); - } - - teletone_init_session(&ts, 0, teletone_handler, &tmp); - ts.rate = 8000; - ts.debug = 1; - ts.debug_stream = stdout; - teletone_run(&ts, argv[2]); - close(tmp.fd); - - return 0; -} -#else -int32_t main(int argc, char *argv[]) -{ - int32_t j, i, fd = -1; - int32_t rate = 8000; - /* SIT tones and durations */ - float tones[] = { 913.8, 1370.6, 1776.7, 0 }; - int32_t durations[] = {274, 274, 380, 0}; - teletone_dds_state_t dds = {0}; - int16_t sample; - size_t len = 1; - - if (argc < 2 || (fd = open(argv[1], O_WRONLY | O_TRUNC | O_CREAT, S_IRUSR | S_IWUSR)) < 0) { - fprintf(stderr, "File Error!\n", strerror(errno)); - exit(-1); - } - - for (j = 0; tones[j] && durations[j]; j++) { - - teletone_dds_state_set_tone(&dds, tones[j], rate, -50); - - for(i = 0; (i < durations[j] * rate / 1000) && len != 0; i++) { - sample = teletone_dds_modulate_sample(&dds) * 20; - len = write(fd, &sample, sizeof(sample)); - } - - } - - close(fd); -} -#endif diff --git a/libs/freetdm/src/uart.c b/libs/freetdm/src/uart.c deleted file mode 100644 index 7211d9c643..0000000000 --- a/libs/freetdm/src/uart.c +++ /dev/null @@ -1,125 +0,0 @@ - -/* - * uart.c - * - * Copyright (c) 2005 Robert Krten. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This module contains a simple 8-bit UART, which performs a callback - * with the decoded byte value. - * - * 2005 06 11 R. Krten created -*/ - -#include -#include -#include -#include -#include - -#include "uart.h" - -/* - * dsp_uart_attr_init - * - * Initializes the attributes structure; this must be done before the - * attributes structure is used. -*/ - -void dsp_uart_attr_init (dsp_uart_attr_t *attr) -{ - memset (attr, 0, sizeof (*attr)); -} - -/* - * dsp_uart_attr_get_bytehandler - * dsp_uart_attr_set_bytehandler - * - * These functions get and set their respective elements from the - * attributes structure. If an error code is returned, it is just - * zero == ok, -1 == fail. -*/ - -bytehandler_func_t dsp_uart_attr_get_bytehandler(dsp_uart_attr_t *attr, void **bytehandler_arg) -{ - *bytehandler_arg = attr->bytehandler_arg; - return attr->bytehandler; -} - -void dsp_uart_attr_set_bytehandler(dsp_uart_attr_t *attr, bytehandler_func_t bytehandler, void *bytehandler_arg) -{ - attr->bytehandler = bytehandler; - attr->bytehandler_arg = bytehandler_arg; -} - -dsp_uart_handle_t *dsp_uart_create(dsp_uart_attr_t *attr) -{ - dsp_uart_handle_t *handle; - - handle = ftdm_malloc(sizeof (*handle)); - if (handle) { - memset(handle, 0, sizeof (*handle)); - - /* fill the attributes member */ - memcpy(&handle->attr, attr, sizeof (*attr)); - } - return handle; -} - -void dsp_uart_destroy(dsp_uart_handle_t **handle) -{ - if (*handle) { - ftdm_safe_free(*handle); - *handle = NULL; - } -} - - -void dsp_uart_bit_handler(void *x, int bit) -{ - dsp_uart_handle_t *handle = (dsp_uart_handle_t *) x; - - if (!handle->have_start) { - if (bit) { - return; /* waiting for start bit (0) */ - } - handle->have_start = 1; - handle->data = 0; - handle->nbits = 0; - return; - } - - handle->data >>= 1; - handle->data |= 0x80 * !!bit; - handle->nbits++; - - if (handle->nbits == 8) { - handle->attr.bytehandler(handle->attr.bytehandler_arg, handle->data); - handle->nbits = 0; - handle->data = 0; - handle->have_start = 0; - } -/* might consider handling errors in the future... */ -} - diff --git a/libs/iksemel/src/stream.c b/libs/iksemel/src/stream.c index a35f29223a..f304f67c64 100644 --- a/libs/iksemel/src/stream.c +++ b/libs/iksemel/src/stream.c @@ -23,6 +23,7 @@ #include #include #ifdef WIN32 +#include "Winsock2.h" typedef unsigned __int32 uint32_t; #else #ifdef HAVE_SYS_SELECT_H @@ -878,11 +879,11 @@ iks_send_raw (iksparser *prs, const char *xmlstr) } else #elif HAVE_SSL if (data->flags & SF_SECURE) { - int r, err; + int r; do { r = SSL_write(data->ssl, xmlstr, strlen (xmlstr)); - } while (r == -1 && (err = SSL_get_error(data->ssl, r)) == SSL_ERROR_WANT_WRITE); + } while (r == -1 && SSL_get_error(data->ssl, r) == SSL_ERROR_WANT_WRITE); if (r < 0) { return IKS_NET_RWERR; diff --git a/libs/iksemel/tools/iksroster.c b/libs/iksemel/tools/iksroster.c index 144f3de189..71237972b3 100644 --- a/libs/iksemel/tools/iksroster.c +++ b/libs/iksemel/tools/iksroster.c @@ -299,6 +299,7 @@ main (int argc, char *argv[]) strtok (to_pw, "\r\n"); break; case 'f': + if (file) free(file); file = strdup (optarg); break; case 't': @@ -374,6 +375,6 @@ main (int argc, char *argv[]) #ifdef _WIN32 WSACleanup (); #endif - + if (file) free(file); return 0; } diff --git a/libs/libdingaling/.update b/libs/libdingaling/.update deleted file mode 100644 index 84faa7df3c..0000000000 --- a/libs/libdingaling/.update +++ /dev/null @@ -1 +0,0 @@ -Fri Mar 9 17:53:09 CST 2007 diff --git a/libs/libdingaling/AUTHORS b/libs/libdingaling/AUTHORS deleted file mode 100644 index 3d05d943aa..0000000000 --- a/libs/libdingaling/AUTHORS +++ /dev/null @@ -1,18 +0,0 @@ -The Initial Developer of the Original Code is -Anthony Minessale II -Portions created by the Initial Developer are Copyright (C) -the Initial Developer. All Rights Reserved. - -The PRIMARY AUTHORS are (and/or have been): - - Anthony Minessale II - Primary developer of all core components - and many of the included modules. Much of freeswitch is based on his work. - - Michael Jerris - Windows porter and responsible for the - windows\msvc build system. - - -And here is an inevitably incomplete list of MUCH-APPRECIATED CONTRIBUTORS -- -people who have submitted patches, reported bugs, and generally made Freeswitch -that much better: - diff --git a/libs/libdingaling/COPYING b/libs/libdingaling/COPYING deleted file mode 100644 index 1bf2b1279d..0000000000 --- a/libs/libdingaling/COPYING +++ /dev/null @@ -1,471 +0,0 @@ - MOZILLA PUBLIC LICENSE - Version 1.1 - - --------------- - -1. Definitions. - - 1.0.1. "Commercial Use" means distribution or otherwise making the - Covered Code available to a third party. - - 1.1. "Contributor" means each entity that creates or contributes to - the creation of Modifications. - - 1.2. "Contributor Version" means the combination of the Original - Code, prior Modifications used by a Contributor, and the Modifications - made by that particular Contributor. - - 1.3. "Covered Code" means the Original Code or Modifications or the - combination of the Original Code and Modifications, in each case - including portions thereof. - - 1.4. "Electronic Distribution Mechanism" means a mechanism generally - accepted in the software development community for the electronic - transfer of data. - - 1.5. "Executable" means Covered Code in any form other than Source - Code. - - 1.6. "Initial Developer" means the individual or entity identified - as the Initial Developer in the Source Code notice required by Exhibit - A. - - 1.7. "Larger Work" means a work which combines Covered Code or - portions thereof with code not governed by the terms of this License. - - 1.8. "License" means this document. - - 1.8.1. "Licensable" means having the right to grant, to the maximum - extent possible, whether at the time of the initial grant or - subsequently acquired, any and all of the rights conveyed herein. - - 1.9. "Modifications" means any addition to or deletion from the - substance or structure of either the Original Code or any previous - Modifications. When Covered Code is released as a series of files, a - Modification is: - A. Any addition to or deletion from the contents of a file - containing Original Code or previous Modifications. - - B. Any new file that contains any part of the Original Code or - previous Modifications. - - 1.10. "Original Code" means Source Code of computer software code - which is described in the Source Code notice required by Exhibit A as - Original Code, and which, at the time of its release under this - License is not already Covered Code governed by this License. - - 1.10.1. "Patent Claims" means any patent claim(s), now owned or - hereafter acquired, including without limitation, method, process, - and apparatus claims, in any patent Licensable by grantor. - - 1.11. "Source Code" means the preferred form of the Covered Code for - making modifications to it, including all modules it contains, plus - any associated interface definition files, scripts used to control - compilation and installation of an Executable, or source code - differential comparisons against either the Original Code or another - well known, available Covered Code of the Contributor's choice. The - Source Code can be in a compressed or archival form, provided the - appropriate decompression or de-archiving software is widely available - for no charge. - - 1.12. "You" (or "Your") means an individual or a legal entity - exercising rights under, and complying with all of the terms of, this - License or a future version of this License issued under Section 6.1. - For legal entities, "You" includes any entity which controls, is - controlled by, or is under common control with You. For purposes of - this definition, "control" means (a) the power, direct or indirect, - to cause the direction or management of such entity, whether by - contract or otherwise, or (b) ownership of more than fifty percent - (50%) of the outstanding shares or beneficial ownership of such - entity. - -2. Source Code License. - - 2.1. The Initial Developer Grant. - The Initial Developer hereby grants You a world-wide, royalty-free, - non-exclusive license, subject to third party intellectual property - claims: - (a) under intellectual property rights (other than patent or - trademark) Licensable by Initial Developer to use, reproduce, - modify, display, perform, sublicense and distribute the Original - Code (or portions thereof) with or without Modifications, and/or - as part of a Larger Work; and - - (b) under Patents Claims infringed by the making, using or - selling of Original Code, to make, have made, use, practice, - sell, and offer for sale, and/or otherwise dispose of the - Original Code (or portions thereof). - - (c) the licenses granted in this Section 2.1(a) and (b) are - effective on the date Initial Developer first distributes - Original Code under the terms of this License. - - (d) Notwithstanding Section 2.1(b) above, no patent license is - granted: 1) for code that You delete from the Original Code; 2) - separate from the Original Code; or 3) for infringements caused - by: i) the modification of the Original Code or ii) the - combination of the Original Code with other software or devices. - - 2.2. Contributor Grant. - Subject to third party intellectual property claims, each Contributor - hereby grants You a world-wide, royalty-free, non-exclusive license - - (a) under intellectual property rights (other than patent or - trademark) Licensable by Contributor, to use, reproduce, modify, - display, perform, sublicense and distribute the Modifications - created by such Contributor (or portions thereof) either on an - unmodified basis, with other Modifications, as Covered Code - and/or as part of a Larger Work; and - - (b) under Patent Claims infringed by the making, using, or - selling of Modifications made by that Contributor either alone - and/or in combination with its Contributor Version (or portions - of such combination), to make, use, sell, offer for sale, have - made, and/or otherwise dispose of: 1) Modifications made by that - Contributor (or portions thereof); and 2) the combination of - Modifications made by that Contributor with its Contributor - Version (or portions of such combination). - - (c) the licenses granted in Sections 2.2(a) and 2.2(b) are - effective on the date Contributor first makes Commercial Use of - the Covered Code. - - (d) Notwithstanding Section 2.2(b) above, no patent license is - granted: 1) for any code that Contributor has deleted from the - Contributor Version; 2) separate from the Contributor Version; - 3) for infringements caused by: i) third party modifications of - Contributor Version or ii) the combination of Modifications made - by that Contributor with other software (except as part of the - Contributor Version) or other devices; or 4) under Patent Claims - infringed by Covered Code in the absence of Modifications made by - that Contributor. - -3. Distribution Obligations. - - 3.1. Application of License. - The Modifications which You create or to which You contribute are - governed by the terms of this License, including without limitation - Section 2.2. The Source Code version of Covered Code may be - distributed only under the terms of this License or a future version - of this License released under Section 6.1, and You must include a - copy of this License with every copy of the Source Code You - distribute. You may not offer or impose any terms on any Source Code - version that alters or restricts the applicable version of this - License or the recipients' rights hereunder. However, You may include - an additional document offering the additional rights described in - Section 3.5. - - 3.2. Availability of Source Code. - Any Modification which You create or to which You contribute must be - made available in Source Code form under the terms of this License - either on the same media as an Executable version or via an accepted - Electronic Distribution Mechanism to anyone to whom you made an - Executable version available; and if made available via Electronic - Distribution Mechanism, must remain available for at least twelve (12) - months after the date it initially became available, or at least six - (6) months after a subsequent version of that particular Modification - has been made available to such recipients. You are responsible for - ensuring that the Source Code version remains available even if the - Electronic Distribution Mechanism is maintained by a third party. - - 3.3. Description of Modifications. - You must cause all Covered Code to which You contribute to contain a - file documenting the changes You made to create that Covered Code and - the date of any change. You must include a prominent statement that - the Modification is derived, directly or indirectly, from Original - Code provided by the Initial Developer and including the name of the - Initial Developer in (a) the Source Code, and (b) in any notice in an - Executable version or related documentation in which You describe the - origin or ownership of the Covered Code. - - 3.4. Intellectual Property Matters - (a) Third Party Claims. - If Contributor has knowledge that a license under a third party's - intellectual property rights is required to exercise the rights - granted by such Contributor under Sections 2.1 or 2.2, - Contributor must include a text file with the Source Code - distribution titled "LEGAL" which describes the claim and the - party making the claim in sufficient detail that a recipient will - know whom to contact. If Contributor obtains such knowledge after - the Modification is made available as described in Section 3.2, - Contributor shall promptly modify the LEGAL file in all copies - Contributor makes available thereafter and shall take other steps - (such as notifying appropriate mailing lists or newsgroups) - reasonably calculated to inform those who received the Covered - Code that new knowledge has been obtained. - - (b) Contributor APIs. - If Contributor's Modifications include an application programming - interface and Contributor has knowledge of patent licenses which - are reasonably necessary to implement that API, Contributor must - also include this information in the LEGAL file. - - (c) Representations. - Contributor represents that, except as disclosed pursuant to - Section 3.4(a) above, Contributor believes that Contributor's - Modifications are Contributor's original creation(s) and/or - Contributor has sufficient rights to grant the rights conveyed by - this License. - - 3.5. Required Notices. - You must duplicate the notice in Exhibit A in each file of the Source - Code. If it is not possible to put such notice in a particular Source - Code file due to its structure, then You must include such notice in a - location (such as a relevant directory) where a user would be likely - to look for such a notice. If You created one or more Modification(s) - You may add your name as a Contributor to the notice described in - Exhibit A. You must also duplicate this License in any documentation - for the Source Code where You describe recipients' rights or ownership - rights relating to Covered Code. You may choose to offer, and to - charge a fee for, warranty, support, indemnity or liability - obligations to one or more recipients of Covered Code. However, You - may do so only on Your own behalf, and not on behalf of the Initial - Developer or any Contributor. You must make it absolutely clear than - any such warranty, support, indemnity or liability obligation is - offered by You alone, and You hereby agree to indemnify the Initial - Developer and every Contributor for any liability incurred by the - Initial Developer or such Contributor as a result of warranty, - support, indemnity or liability terms You offer. - - 3.6. Distribution of Executable Versions. - You may distribute Covered Code in Executable form only if the - requirements of Section 3.1-3.5 have been met for that Covered Code, - and if You include a notice stating that the Source Code version of - the Covered Code is available under the terms of this License, - including a description of how and where You have fulfilled the - obligations of Section 3.2. The notice must be conspicuously included - in any notice in an Executable version, related documentation or - collateral in which You describe recipients' rights relating to the - Covered Code. You may distribute the Executable version of Covered - Code or ownership rights under a license of Your choice, which may - contain terms different from this License, provided that You are in - compliance with the terms of this License and that the license for the - Executable version does not attempt to limit or alter the recipient's - rights in the Source Code version from the rights set forth in this - License. If You distribute the Executable version under a different - license You must make it absolutely clear that any terms which differ - from this License are offered by You alone, not by the Initial - Developer or any Contributor. You hereby agree to indemnify the - Initial Developer and every Contributor for any liability incurred by - the Initial Developer or such Contributor as a result of any such - terms You offer. - - 3.7. Larger Works. - You may create a Larger Work by combining Covered Code with other code - not governed by the terms of this License and distribute the Larger - Work as a single product. In such a case, You must make sure the - requirements of this License are fulfilled for the Covered Code. - -4. Inability to Comply Due to Statute or Regulation. - - If it is impossible for You to comply with any of the terms of this - License with respect to some or all of the Covered Code due to - statute, judicial order, or regulation then You must: (a) comply with - the terms of this License to the maximum extent possible; and (b) - describe the limitations and the code they affect. Such description - must be included in the LEGAL file described in Section 3.4 and must - be included with all distributions of the Source Code. Except to the - extent prohibited by statute or regulation, such description must be - sufficiently detailed for a recipient of ordinary skill to be able to - understand it. - -5. Application of this License. - - This License applies to code to which the Initial Developer has - attached the notice in Exhibit A and to related Covered Code. - -6. Versions of the License. - - 6.1. New Versions. - Netscape Communications Corporation ("Netscape") may publish revised - and/or new versions of the License from time to time. Each version - will be given a distinguishing version number. - - 6.2. Effect of New Versions. - Once Covered Code has been published under a particular version of the - License, You may always continue to use it under the terms of that - version. You may also choose to use such Covered Code under the terms - of any subsequent version of the License published by Netscape. No one - other than Netscape has the right to modify the terms applicable to - Covered Code created under this License. - - 6.3. Derivative Works. - If You create or use a modified version of this License (which you may - only do in order to apply it to code which is not already Covered Code - governed by this License), You must (a) rename Your license so that - the phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape", - "MPL", "NPL" or any confusingly similar phrase do not appear in your - license (except to note that your license differs from this License) - and (b) otherwise make it clear that Your version of the license - contains terms which differ from the Mozilla Public License and - Netscape Public License. (Filling in the name of the Initial - Developer, Original Code or Contributor in the notice described in - Exhibit A shall not of themselves be deemed to be modifications of - this License.) - -7. DISCLAIMER OF WARRANTY. - - COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, - WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF - DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. - THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE - IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, - YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE - COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER - OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF - ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER. - -8. TERMINATION. - - 8.1. This License and the rights granted hereunder will terminate - automatically if You fail to comply with terms herein and fail to cure - such breach within 30 days of becoming aware of the breach. All - sublicenses to the Covered Code which are properly granted shall - survive any termination of this License. Provisions which, by their - nature, must remain in effect beyond the termination of this License - shall survive. - - 8.2. If You initiate litigation by asserting a patent infringement - claim (excluding declatory judgment actions) against Initial Developer - or a Contributor (the Initial Developer or Contributor against whom - You file such action is referred to as "Participant") alleging that: - - (a) such Participant's Contributor Version directly or indirectly - infringes any patent, then any and all rights granted by such - Participant to You under Sections 2.1 and/or 2.2 of this License - shall, upon 60 days notice from Participant terminate prospectively, - unless if within 60 days after receipt of notice You either: (i) - agree in writing to pay Participant a mutually agreeable reasonable - royalty for Your past and future use of Modifications made by such - Participant, or (ii) withdraw Your litigation claim with respect to - the Contributor Version against such Participant. If within 60 days - of notice, a reasonable royalty and payment arrangement are not - mutually agreed upon in writing by the parties or the litigation claim - is not withdrawn, the rights granted by Participant to You under - Sections 2.1 and/or 2.2 automatically terminate at the expiration of - the 60 day notice period specified above. - - (b) any software, hardware, or device, other than such Participant's - Contributor Version, directly or indirectly infringes any patent, then - any rights granted to You by such Participant under Sections 2.1(b) - and 2.2(b) are revoked effective as of the date You first made, used, - sold, distributed, or had made, Modifications made by that - Participant. - - 8.3. If You assert a patent infringement claim against Participant - alleging that such Participant's Contributor Version directly or - indirectly infringes any patent where such claim is resolved (such as - by license or settlement) prior to the initiation of patent - infringement litigation, then the reasonable value of the licenses - granted by such Participant under Sections 2.1 or 2.2 shall be taken - into account in determining the amount or value of any payment or - license. - - 8.4. In the event of termination under Sections 8.1 or 8.2 above, - all end user license agreements (excluding distributors and resellers) - which have been validly granted by You or any distributor hereunder - prior to termination shall survive termination. - -9. LIMITATION OF LIABILITY. - - UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT - (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL - DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, - OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR - ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY - CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, - WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER - COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN - INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF - LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY - RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW - PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE - EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO - THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. - -10. U.S. GOVERNMENT END USERS. - - The Covered Code is a "commercial item," as that term is defined in - 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer - software" and "commercial computer software documentation," as such - terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 - C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), - all U.S. Government End Users acquire Covered Code with only those - rights set forth herein. - -11. MISCELLANEOUS. - - This License represents the complete agreement concerning subject - matter hereof. If any provision of this License is held to be - unenforceable, such provision shall be reformed only to the extent - necessary to make it enforceable. This License shall be governed by - California law provisions (except to the extent applicable law, if - any, provides otherwise), excluding its conflict-of-law provisions. - With respect to disputes in which at least one party is a citizen of, - or an entity chartered or registered to do business in the United - States of America, any litigation relating to this License shall be - subject to the jurisdiction of the Federal Courts of the Northern - District of California, with venue lying in Santa Clara County, - California, with the losing party responsible for costs, including - without limitation, court costs and reasonable attorneys' fees and - expenses. The application of the United Nations Convention on - Contracts for the International Sale of Goods is expressly excluded. - Any law or regulation which provides that the language of a contract - shall be construed against the drafter shall not apply to this - License. - -12. RESPONSIBILITY FOR CLAIMS. - - As between Initial Developer and the Contributors, each party is - responsible for claims and damages arising, directly or indirectly, - out of its utilization of rights under this License and You agree to - work with Initial Developer and Contributors to distribute such - responsibility on an equitable basis. Nothing herein is intended or - shall be deemed to constitute any admission of liability. - -13. MULTIPLE-LICENSED CODE. - - Initial Developer may designate portions of the Covered Code as - "Multiple-Licensed". "Multiple-Licensed" means that the Initial - Developer permits you to utilize portions of the Covered Code under - Your choice of the NPL or the alternative licenses, if any, specified - by the Initial Developer in the file described in Exhibit A. - -EXHIBIT A -Mozilla Public License. - - ``The contents of this file are subject to the Mozilla Public License - Version 1.1 (the "License"); you may not use this file except in - compliance with the License. You may obtain a copy of the License at - http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the - License for the specific language governing rights and limitations - under the License. - - The Original Code is ______________________________________. - - The Initial Developer of the Original Code is ________________________. - Portions created by ______________________ are Copyright (C) ______ - _______________________. All Rights Reserved. - - Contributor(s): ______________________________________. - - Alternatively, the contents of this file may be used under the terms - of the _____ license (the "[___] License"), in which case the - provisions of [______] License are applicable instead of those - above. If you wish to allow use of your version of this file only - under the terms of the [____] License and not to allow others to use - your version of this file under the MPL, indicate your decision by - deleting the provisions above and replace them with the notice and - other provisions required by the [___] License. If you do not delete - the provisions above, a recipient may use your version of this file - under either the MPL or the [___] License." - - [NOTE: The text of this Exhibit A may differ slightly from the text of - the notices in the Source Code files of the Original Code. You should - use the text of this Exhibit A rather than the text found in the - Original Code Source Code for Your Modifications.] - - diff --git a/libs/libdingaling/ChangeLog b/libs/libdingaling/ChangeLog deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/libs/libdingaling/INSTALL b/libs/libdingaling/INSTALL deleted file mode 100644 index 095b1eb406..0000000000 --- a/libs/libdingaling/INSTALL +++ /dev/null @@ -1,231 +0,0 @@ -Installation Instructions -************************* - -Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004 Free -Software Foundation, Inc. - -This file is free documentation; the Free Software Foundation gives -unlimited permission to copy, distribute and modify it. - -Basic Installation -================== - -These are generic installation instructions. - - The `configure' shell script attempts to guess correct values for -various system-dependent variables used during compilation. It uses -those values to create a `Makefile' in each directory of the package. -It may also create one or more `.h' files containing system-dependent -definitions. Finally, it creates a shell script `config.status' that -you can run in the future to recreate the current configuration, and a -file `config.log' containing compiler output (useful mainly for -debugging `configure'). - - It can also use an optional file (typically called `config.cache' -and enabled with `--cache-file=config.cache' or simply `-C') that saves -the results of its tests to speed up reconfiguring. (Caching is -disabled by default to prevent problems with accidental use of stale -cache files.) - - If you need to do unusual things to compile the package, please try -to figure out how `configure' could check whether to do them, and mail -diffs or instructions to the address given in the `README' so they can -be considered for the next release. If you are using the cache, and at -some point `config.cache' contains results you don't want to keep, you -may remove or edit it. - - The file `configure.ac' (or `configure.in') is used to create -`configure' by a program called `autoconf'. You only need -`configure.ac' if you want to change it or regenerate `configure' using -a newer version of `autoconf'. - -The simplest way to compile this package is: - - 1. `cd' to the directory containing the package's source code and type - `./configure' to configure the package for your system. If you're - using `csh' on an old version of System V, you might need to type - `sh ./configure' instead to prevent `csh' from trying to execute - `configure' itself. - - Running `configure' takes awhile. While running, it prints some - messages telling which features it is checking for. - - 2. Type `make' to compile the package. - - 3. Optionally, type `make check' to run any self-tests that come with - the package. - - 4. Type `make install' to install the programs and any data files and - documentation. - - 5. You can remove the program binaries and object files from the - source code directory by typing `make clean'. To also remove the - files that `configure' created (so you can compile the package for - a different kind of computer), type `make distclean'. There is - also a `make maintainer-clean' target, but that is intended mainly - for the package's developers. If you use it, you may have to get - all sorts of other programs in order to regenerate files that came - with the distribution. - -Compilers and Options -===================== - -Some systems require unusual options for compilation or linking that the -`configure' script does not know about. Run `./configure --help' for -details on some of the pertinent environment variables. - - You can give `configure' initial values for configuration parameters -by setting variables in the command line or in the environment. Here -is an example: - - ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix - - *Note Defining Variables::, for more details. - -Compiling For Multiple Architectures -==================================== - -You can compile the package for more than one kind of computer at the -same time, by placing the object files for each architecture in their -own directory. To do this, you must use a version of `make' that -supports the `VPATH' variable, such as GNU `make'. `cd' to the -directory where you want the object files and executables to go and run -the `configure' script. `configure' automatically checks for the -source code in the directory that `configure' is in and in `..'. - - If you have to use a `make' that does not support the `VPATH' -variable, you have to compile the package for one architecture at a -time in the source code directory. After you have installed the -package for one architecture, use `make distclean' before reconfiguring -for another architecture. - -Installation Names -================== - -By default, `make install' will install the package's files in -`/usr/local/bin', `/usr/local/man', etc. You can specify an -installation prefix other than `/usr/local' by giving `configure' the -option `--prefix=PREFIX'. - - You can specify separate installation prefixes for -architecture-specific files and architecture-independent files. If you -give `configure' the option `--exec-prefix=PREFIX', the package will -use PREFIX as the prefix for installing programs and libraries. -Documentation and other data files will still use the regular prefix. - - In addition, if you use an unusual directory layout you can give -options like `--bindir=DIR' to specify different values for particular -kinds of files. Run `configure --help' for a list of the directories -you can set and what kinds of files go in them. - - If the package supports it, you can cause programs to be installed -with an extra prefix or suffix on their names by giving `configure' the -option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. - -Optional Features -================= - -Some packages pay attention to `--enable-FEATURE' options to -`configure', where FEATURE indicates an optional part of the package. -They may also pay attention to `--with-PACKAGE' options, where PACKAGE -is something like `gnu-as' or `x' (for the X Window System). The -`README' should mention any `--enable-' and `--with-' options that the -package recognizes. - - For packages that use the X Window System, `configure' can usually -find the X include and library files automatically, but if it doesn't, -you can use the `configure' options `--x-includes=DIR' and -`--x-libraries=DIR' to specify their locations. - -Specifying the System Type -========================== - -There may be some features `configure' cannot figure out automatically, -but needs to determine by the type of machine the package will run on. -Usually, assuming the package is built to be run on the _same_ -architectures, `configure' can figure that out, but if it prints a -message saying it cannot guess the machine type, give it the -`--build=TYPE' option. TYPE can either be a short name for the system -type, such as `sun4', or a canonical name which has the form: - - CPU-COMPANY-SYSTEM - -where SYSTEM can have one of these forms: - - OS KERNEL-OS - - See the file `config.sub' for the possible values of each field. If -`config.sub' isn't included in this package, then this package doesn't -need to know the machine type. - - If you are _building_ compiler tools for cross-compiling, you should -use the `--target=TYPE' option to select the type of system they will -produce code for. - - If you want to _use_ a cross compiler, that generates code for a -platform different from the build platform, you should specify the -"host" platform (i.e., that on which the generated programs will -eventually be run) with `--host=TYPE'. - -Sharing Defaults -================ - -If you want to set default values for `configure' scripts to share, you -can create a site shell script called `config.site' that gives default -values for variables like `CC', `cache_file', and `prefix'. -`configure' looks for `PREFIX/share/config.site' if it exists, then -`PREFIX/etc/config.site' if it exists. Or, you can set the -`CONFIG_SITE' environment variable to the location of the site script. -A warning: not all `configure' scripts look for a site script. - -Defining Variables -================== - -Variables not defined in a site shell script can be set in the -environment passed to `configure'. However, some packages may run -configure again during the build, and the customized values of these -variables may be lost. In order to avoid this problem, you should set -them in the `configure' command line, using `VAR=value'. For example: - - ./configure CC=/usr/local2/bin/gcc - -will cause the specified gcc to be used as the C compiler (unless it is -overridden in the site shell script). - -`configure' Invocation -====================== - -`configure' recognizes the following options to control how it operates. - -`--help' -`-h' - Print a summary of the options to `configure', and exit. - -`--version' -`-V' - Print the version of Autoconf used to generate the `configure' - script, and exit. - -`--cache-file=FILE' - Enable the cache: use and save the results of the tests in FILE, - traditionally `config.cache'. FILE defaults to `/dev/null' to - disable caching. - -`--config-cache' -`-C' - Alias for `--cache-file=config.cache'. - -`--quiet' -`--silent' -`-q' - Do not print messages saying which checks are being made. To - suppress all normal output, redirect it to `/dev/null' (any error - messages will still be shown). - -`--srcdir=DIR' - Look for the package's source code in directory DIR. Usually - `configure' can determine that directory automatically. - -`configure' also accepts some other, not widely useful, options. Run -`configure --help' for more details. - diff --git a/libs/libdingaling/Makefile.am b/libs/libdingaling/Makefile.am deleted file mode 100644 index 37bf42cb31..0000000000 --- a/libs/libdingaling/Makefile.am +++ /dev/null @@ -1,42 +0,0 @@ -EXTRA_DIST = -SUBDIRS = -AUTOMAKE_OPTIONS = foreign -NAME=dingaling -PREFIX=$(prefix) -TOUCH_TARGET=@if test -f "$@" ; then touch "$@" ; fi ; - -AM_CFLAGS = $(new_AM_CFLAGS) -I./src -I$(prefix)/include -AM_CPPFLAGS = $(AM_CFLAGS) -AM_LDFLAGS = $(new_AM_LDFLAGS) - -AM_CFLAGS += `../apr/apr-1-config --cflags --cppflags --includes || $(prefix)/bin/apr-1-config --cflags --cppflags --includes` -AM_CFLAGS += `../apr-util/apu-1-config --includes || $(prefix)/bin/apu-1-config --includes` -AM_CFLAGS += -I../iksemel/include - -lib_LTLIBRARIES = libdingaling.la -libdingaling_la_SOURCES = src/libdingaling.c src/sha1.c -libdingaling_la_CFLAGS = $(AM_CFLAGS) -libdingaling_la_LDFLAGS = $(AM_LDFLAGS) -libdingaling_la_LIBADD = ../iksemel/src/libiksemel.la ../apr/libapr-1.la ../apr-util/libaprutil-1.la -library_includedir = $(prefix)/include -library_include_HEADERS = src/libdingaling.h - -$(libdingaling_la_SOURCES): $(libdingaling_la_LIBADD) - -../apr/libapr-1.la: ../apr ../apr/.update - cd ../apr && $(MAKE) - $(TOUCH_TARGET) - -../apr-util/libaprutil-1.la: ../apr-util ../apr-util/.update - cd ../apr-util && $(MAKE) - $(TOUCH_TARGET) - -../iksemel/src/libiksemel.la: ../iksemel ../iksemel/.update - cd ../iksemel && $(MAKE) - $(TOUCH_TARGET) - -dox: - cd docs && doxygen $(PWD)/docs/Doxygen.conf - -doxclean: - rm -fr docs/html/ docs/man/ docs/perlmod/ docs/xml/ diff --git a/libs/libdingaling/NEWS b/libs/libdingaling/NEWS deleted file mode 100644 index eef3e09d2b..0000000000 --- a/libs/libdingaling/NEWS +++ /dev/null @@ -1 +0,0 @@ -Developed on UNIX where the motto is "no news is good news!". diff --git a/libs/libdingaling/README b/libs/libdingaling/README deleted file mode 100644 index 95e0a39bcf..0000000000 --- a/libs/libdingaling/README +++ /dev/null @@ -1,8 +0,0 @@ -Install is common: - -./configure --with-prefix= -make -make install - - - diff --git a/libs/libdingaling/acsite.m4 b/libs/libdingaling/acsite.m4 deleted file mode 100644 index 80f8cf4138..0000000000 --- a/libs/libdingaling/acsite.m4 +++ /dev/null @@ -1,6 +0,0 @@ -m4_include([build/config/ax_compiler_vendor.m4]) -m4_include([build/config/ax_cflags_warn_all_ansi.m4]) -m4_include([build/config/ax_cc_maxopt.m4]) -m4_include([build/config/ax_check_compiler_flags.m4]) -m4_include([build/config/ac_gcc_archflag.m4]) -m4_include([build/config/ac_gcc_x86_cpuid.m4]) diff --git a/libs/libdingaling/build/config/ac_cflags_gcc_option.m4 b/libs/libdingaling/build/config/ac_cflags_gcc_option.m4 deleted file mode 100644 index e651a5e6c5..0000000000 --- a/libs/libdingaling/build/config/ac_cflags_gcc_option.m4 +++ /dev/null @@ -1,142 +0,0 @@ -AC_DEFUN([AX_CFLAGS_GCC_OPTION_OLD], [dnl -AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl -AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_gcc_option_$2])dnl -AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for gcc m4_ifval($2,$2,-option)], -VAR,[VAR="no, unknown" - AC_LANG_SAVE - AC_LANG_C - ac_save_[]FLAGS="$[]FLAGS" -for ac_arg dnl -in "-pedantic % m4_ifval($2,$2,-option)" dnl GCC - # -do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` - AC_TRY_COMPILE([],[return 0;], - [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) -done - FLAGS="$ac_save_[]FLAGS" - AC_LANG_RESTORE -]) -case ".$VAR" in - .ok|.ok,*) m4_ifvaln($3,$3) ;; - .|.no|.no,*) m4_ifvaln($4,$4) ;; - *) m4_ifvaln($3,$3,[ - if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null - then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR]) - else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"]) - m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR" - fi ]) ;; -esac -AS_VAR_POPDEF([VAR])dnl -AS_VAR_POPDEF([FLAGS])dnl -]) - - -dnl the only difference - the LANG selection... and the default FLAGS - -AC_DEFUN([AX_CXXFLAGS_GCC_OPTION_OLD], [dnl -AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl -AS_VAR_PUSHDEF([VAR],[ac_cv_cxxflags_gcc_option_$2])dnl -AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for gcc m4_ifval($2,$2,-option)], -VAR,[VAR="no, unknown" - AC_LANG_SAVE - AC_LANG_CXX - ac_save_[]FLAGS="$[]FLAGS" -for ac_arg dnl -in "-pedantic % m4_ifval($2,$2,-option)" dnl GCC - # -do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` - AC_TRY_COMPILE([],[return 0;], - [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) -done - FLAGS="$ac_save_[]FLAGS" - AC_LANG_RESTORE -]) -case ".$VAR" in - .ok|.ok,*) m4_ifvaln($3,$3) ;; - .|.no|.no,*) m4_ifvaln($4,$4) ;; - *) m4_ifvaln($3,$3,[ - if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null - then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR]) - else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"]) - m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR" - fi ]) ;; -esac -AS_VAR_POPDEF([VAR])dnl -AS_VAR_POPDEF([FLAGS])dnl -]) - -dnl ------------------------------------------------------------------------- - -AC_DEFUN([AX_CFLAGS_GCC_OPTION_NEW], [dnl -AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl -AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_gcc_option_$1])dnl -AC_CACHE_CHECK([m4_ifval($2,$2,FLAGS) for gcc m4_ifval($1,$1,-option)], -VAR,[VAR="no, unknown" - AC_LANG_SAVE - AC_LANG_C - ac_save_[]FLAGS="$[]FLAGS" -for ac_arg dnl -in "-pedantic % m4_ifval($1,$1,-option)" dnl GCC - # -do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` - AC_TRY_COMPILE([],[return 0;], - [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) -done - FLAGS="$ac_save_[]FLAGS" - AC_LANG_RESTORE -]) -case ".$VAR" in - .ok|.ok,*) m4_ifvaln($3,$3) ;; - .|.no|.no,*) m4_ifvaln($4,$4) ;; - *) m4_ifvaln($3,$3,[ - if echo " $[]m4_ifval($2,$2,FLAGS) " | grep " $VAR " 2>&1 >/dev/null - then AC_RUN_LOG([: m4_ifval($2,$2,FLAGS) does contain $VAR]) - else AC_RUN_LOG([: m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"]) - m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR" - fi ]) ;; -esac -AS_VAR_POPDEF([VAR])dnl -AS_VAR_POPDEF([FLAGS])dnl -]) - - -dnl the only difference - the LANG selection... and the default FLAGS - -AC_DEFUN([AX_CXXFLAGS_GCC_OPTION_NEW], [dnl -AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl -AS_VAR_PUSHDEF([VAR],[ac_cv_cxxflags_gcc_option_$1])dnl -AC_CACHE_CHECK([m4_ifval($2,$2,FLAGS) for gcc m4_ifval($1,$1,-option)], -VAR,[VAR="no, unknown" - AC_LANG_SAVE - AC_LANG_CXX - ac_save_[]FLAGS="$[]FLAGS" -for ac_arg dnl -in "-pedantic % m4_ifval($1,$1,-option)" dnl GCC - # -do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` - AC_TRY_COMPILE([],[return 0;], - [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) -done - FLAGS="$ac_save_[]FLAGS" - AC_LANG_RESTORE -]) -case ".$VAR" in - .ok|.ok,*) m4_ifvaln($3,$3) ;; - .|.no|.no,*) m4_ifvaln($4,$4) ;; - *) m4_ifvaln($3,$3,[ - if echo " $[]m4_ifval($2,$2,FLAGS) " | grep " $VAR " 2>&1 >/dev/null - then AC_RUN_LOG([: m4_ifval($2,$2,FLAGS) does contain $VAR]) - else AC_RUN_LOG([: m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"]) - m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR" - fi ]) ;; -esac -AS_VAR_POPDEF([VAR])dnl -AS_VAR_POPDEF([FLAGS])dnl -]) - -AC_DEFUN([AX_CFLAGS_GCC_OPTION],[ifelse(m4_bregexp([$2],[-]),-1, -[AX_CFLAGS_GCC_OPTION_NEW($@)],[AX_CFLAGS_GCC_OPTION_OLD($@)])]) - -AC_DEFUN([AX_CXXFLAGS_GCC_OPTION],[ifelse(m4_bregexp([$2],[-]),-1, -[AX_CXXFLAGS_GCC_OPTION_NEW($@)],[AX_CXXFLAGS_GCC_OPTION_OLD($@)])]) - diff --git a/libs/libdingaling/build/config/ac_cflags_sun_option.m4 b/libs/libdingaling/build/config/ac_cflags_sun_option.m4 deleted file mode 100644 index a09e6fb695..0000000000 --- a/libs/libdingaling/build/config/ac_cflags_sun_option.m4 +++ /dev/null @@ -1,140 +0,0 @@ -AC_DEFUN([AX_CFLAGS_SUN_OPTION_OLD], [dnl -AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl -AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_sun_option_$2])dnl -AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for sun/cc m4_ifval($2,$2,-option)], -VAR,[VAR="no, unknown" - AC_LANG_SAVE - AC_LANG_C - ac_save_[]FLAGS="$[]FLAGS" -for ac_arg dnl -in "+xstrconst % -xc99=all m4_ifval($2,$2,-option)" dnl Solaris C - # -do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` - AC_TRY_COMPILE([],[return 0;], - [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) -done - FLAGS="$ac_save_[]FLAGS" - AC_LANG_RESTORE -]) -case ".$VAR" in - .ok|.ok,*) m4_ifvaln($3,$3) ;; - .|.no|.no,*) m4_ifvaln($4,$4) ;; - *) m4_ifvaln($3,$3,[ - if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null - then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR]) - else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"]) - m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR" - fi ]) ;; -esac -AS_VAR_POPDEF([VAR])dnl -AS_VAR_POPDEF([FLAGS])dnl -]) - -dnl the only difference - the LANG selection... and the default FLAGS - -AC_DEFUN([AX_CXXFLAGS_SUN_OPTION_OLD], [dnl -AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl -AS_VAR_PUSHDEF([VAR],[ac_cv_cxxflags_sun_option_$2])dnl -AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for sun/cc m4_ifval($2,$2,-option)], -VAR,[VAR="no, unknown" - AC_LANG_SAVE - AC_LANG_CXX - ac_save_[]FLAGS="$[]FLAGS" -for ac_arg dnl -in "+xstrconst % -xc99=all m4_ifval($2,$2,-option)" dnl Solaris C - # -do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` - AC_TRY_COMPILE([],[return 0;], - [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) -done - FLAGS="$ac_save_[]FLAGS" - AC_LANG_RESTORE -]) -case ".$VAR" in - .ok|.ok,*) m4_ifvaln($3,$3) ;; - .|.no|.no,*) m4_ifvaln($4,$4) ;; - *) m4_ifvaln($3,$3,[ - if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null - then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR]) - else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"]) - m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR" - fi ]) ;; -esac -AS_VAR_POPDEF([VAR])dnl -AS_VAR_POPDEF([FLAGS])dnl -]) - -dnl ----------------------------------------------------------------------- - -AC_DEFUN([AX_CFLAGS_SUN_OPTION_NEW], [dnl -AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl -AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_sun_option_$1])dnl -AC_CACHE_CHECK([m4_ifval($2,$2,FLAGS) for sun/cc m4_ifval($1,$1,-option)], -VAR,[VAR="no, unknown" - AC_LANG_SAVE - AC_LANG_C - ac_save_[]FLAGS="$[]FLAGS" -for ac_arg dnl -in "+xstrconst % -xc99=all m4_ifval($1,$1,-option)" dnl Solaris C - # -do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` - AC_TRY_COMPILE([],[return 0;], - [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) -done - FLAGS="$ac_save_[]FLAGS" - AC_LANG_RESTORE -]) -case ".$VAR" in - .ok|.ok,*) m4_ifvaln($3,$3) ;; - .|.no|.no,*) m4_ifvaln($4,$4) ;; - *) m4_ifvaln($3,$3,[ - if echo " $[]m4_ifval($2,$2,FLAGS) " | grep " $VAR " 2>&1 >/dev/null - then AC_RUN_LOG([: m4_ifval($2,$2,FLAGS) does contain $VAR]) - else AC_RUN_LOG([: m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"]) - m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR" - fi ]) ;; -esac -AS_VAR_POPDEF([VAR])dnl -AS_VAR_POPDEF([FLAGS])dnl -]) - -dnl the only difference - the LANG selection... and the default FLAGS - -AC_DEFUN([AX_CXXFLAGS_SUN_OPTION_NEW], [dnl -AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl -AS_VAR_PUSHDEF([VAR],[ac_cv_cxxflags_sun_option_$1])dnl -AC_CACHE_CHECK([m4_ifval($2,$2,FLAGS) for sun/cc m4_ifval($1,$1,-option)], -VAR,[VAR="no, unknown" - AC_LANG_SAVE - AC_LANG_CXX - ac_save_[]FLAGS="$[]FLAGS" -for ac_arg dnl -in "+xstrconst % -xc99=all m4_ifval($1,$1,-option)" dnl Solaris C - # -do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` - AC_TRY_COMPILE([],[return 0;], - [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) -done - FLAGS="$ac_save_[]FLAGS" - AC_LANG_RESTORE -]) -case ".$VAR" in - .ok|.ok,*) m4_ifvaln($3,$3) ;; - .|.no|.no,*) m4_ifvaln($4,$4) ;; - *) m4_ifvaln($3,$3,[ - if echo " $[]m4_ifval($2,$2,FLAGS) " | grep " $VAR " 2>&1 >/dev/null - then AC_RUN_LOG([: m4_ifval($2,$2,FLAGS) does contain $VAR]) - else AC_RUN_LOG([: m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"]) - m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR" - fi ]) ;; -esac -AS_VAR_POPDEF([VAR])dnl -AS_VAR_POPDEF([FLAGS])dnl -]) - -AC_DEFUN([AX_CFLAGS_SUN_OPTION],[ifelse(m4_regexp([$2],[-]),-1, -[AX_CFLAGS_SUN_OPTION_NEW($@)],[AX_CFLAGS_SUN_OPTION_OLD($@)])]) - -AC_DEFUN([AX_CXXFLAGS_SUN_OPTION],[ifelse(m4_regexp([$2],[-]),-1, -[AX_CXXFLAGS_SUN_OPTION_NEW($@)],[AX_CXXFLAGS_SUN_OPTION_OLD($@)])]) - diff --git a/libs/libdingaling/build/config/ac_gcc_archflag.m4 b/libs/libdingaling/build/config/ac_gcc_archflag.m4 deleted file mode 100644 index b38a564902..0000000000 --- a/libs/libdingaling/build/config/ac_gcc_archflag.m4 +++ /dev/null @@ -1,148 +0,0 @@ -AC_DEFUN([AX_GCC_ARCHFLAG], -[AC_REQUIRE([AC_PROG_CC]) - -AC_ARG_WITH(gcc-arch, [AC_HELP_STRING([--with-gcc-arch=], [use architecture for gcc -march/-mtune, instead of guessing])], - ax_gcc_arch=$withval, ax_gcc_arch=yes) - -AC_MSG_CHECKING([for gcc architecture flag]) -AC_MSG_RESULT([]) -AC_CACHE_VAL(ax_cv_gcc_archflag, -[ -ax_cv_gcc_archflag="unknown" - -if test "$GCC" = yes; then - -if test "x$ax_gcc_arch" = xyes; then -ax_gcc_arch="" -if test "$cross_compiling" = no; then -case $host_cpu in - i[[3456]]86*|x86_64*) # use cpuid codes, in part from x86info-1.7 by D. Jones - AX_GCC_X86_CPUID(0) - AX_GCC_X86_CPUID(1) - case $ax_cv_gcc_x86_cpuid_0 in - *:756e6547:*:*) # Intel - case $ax_cv_gcc_x86_cpuid_1 in - *5[[48]]?:*:*:*) ax_gcc_arch="pentium-mmx pentium" ;; - *5??:*:*:*) ax_gcc_arch=pentium ;; - *6[[3456]]?:*:*:*) ax_gcc_arch="pentium2 pentiumpro" ;; - *6a?:*[[01]]:*:*) ax_gcc_arch="pentium2 pentiumpro" ;; - *6a?:*[[234]]:*:*) ax_gcc_arch="pentium3 pentiumpro" ;; - *6[[9d]]?:*:*:*) ax_gcc_arch="pentium-m pentium3 pentiumpro" ;; - *6[[78b]]?:*:*:*) ax_gcc_arch="pentium3 pentiumpro" ;; - *6??:*:*:*) ax_gcc_arch=pentiumpro ;; - *f3[[347]]:*:*:*|*f4[1347]:*:*:*) - case $host_cpu in - x86_64*) ax_gcc_arch="nocona pentium4 pentiumpro" ;; - *) ax_gcc_arch="prescott pentium4 pentiumpro" ;; - esac ;; - *f??:*:*:*) ax_gcc_arch="pentium4 pentiumpro";; - esac ;; - *:68747541:*:*) # AMD - case $ax_cv_gcc_x86_cpuid_1 in - *5[[67]]?:*:*:*) ax_gcc_arch=k6 ;; - *5[[8d]]?:*:*:*) ax_gcc_arch="k6-2 k6" ;; - *5[[9]]?:*:*:*) ax_gcc_arch="k6-3 k6" ;; - *60?:*:*:*) ax_gcc_arch=k7 ;; - *6[[12]]?:*:*:*) ax_gcc_arch="athlon k7" ;; - *6[[34]]?:*:*:*) ax_gcc_arch="athlon-tbird k7" ;; - *67?:*:*:*) ax_gcc_arch="athlon-4 athlon k7" ;; - *6[[68a]]?:*:*:*) - AX_GCC_X86_CPUID(0x80000006) # L2 cache size - case $ax_cv_gcc_x86_cpuid_0x80000006 in - *:*:*[[1-9a-f]]??????:*) # (L2 = ecx >> 16) >= 256 - ax_gcc_arch="athlon-xp athlon-4 athlon k7" ;; - *) ax_gcc_arch="athlon-4 athlon k7" ;; - esac ;; - *f[[4cef8b]]?:*:*:*) ax_gcc_arch="athlon64 k8" ;; - *f5?:*:*:*) ax_gcc_arch="opteron k8" ;; - *f7?:*:*:*) ax_gcc_arch="athlon-fx opteron k8" ;; - *f??:*:*:*) ax_gcc_arch="k8" ;; - esac ;; - *:746e6543:*:*) # IDT - case $ax_cv_gcc_x86_cpuid_1 in - *54?:*:*:*) ax_gcc_arch=winchip-c6 ;; - *58?:*:*:*) ax_gcc_arch=winchip2 ;; - *6[[78]]?:*:*:*) ax_gcc_arch=c3 ;; - *69?:*:*:*) ax_gcc_arch="c3-2 c3" ;; - esac ;; - esac - if test x"$ax_gcc_arch" = x; then # fallback - case $host_cpu in - i586*) ax_gcc_arch=pentium ;; - i686*) ax_gcc_arch=pentiumpro ;; - esac - fi - ;; - - sparc*) - AC_PATH_PROG([PRTDIAG], [prtdiag], [prtdiag], [$PATH:/usr/platform/`uname -i`/sbin/:/usr/platform/`uname -m`/sbin/]) - cputype=`(((grep cpu /proc/cpuinfo | cut -d: -f2) ; ($PRTDIAG -v |grep -i sparc) ; grep -i cpu /var/run/dmesg.boot ) | head -n 1) 2> /dev/null` - cputype=`echo "$cputype" | tr -d ' -' |tr $as_cr_LETTERS $as_cr_letters` - case $cputype in - *ultrasparciv*) ax_gcc_arch="ultrasparc4 ultrasparc3 ultrasparc v9" ;; - *ultrasparciii*) ax_gcc_arch="ultrasparc3 ultrasparc v9" ;; - *ultrasparc*) ax_gcc_arch="ultrasparc v9" ;; - *supersparc*|*tms390z5[[05]]*) ax_gcc_arch="supersparc v8" ;; - *hypersparc*|*rt62[[056]]*) ax_gcc_arch="hypersparc v8" ;; - *cypress*) ax_gcc_arch=cypress ;; - esac ;; - - alphaev5) ax_gcc_arch=ev5 ;; - alphaev56) ax_gcc_arch=ev56 ;; - alphapca56) ax_gcc_arch="pca56 ev56" ;; - alphapca57) ax_gcc_arch="pca57 pca56 ev56" ;; - alphaev6) ax_gcc_arch=ev6 ;; - alphaev67) ax_gcc_arch=ev67 ;; - alphaev68) ax_gcc_arch="ev68 ev67" ;; - alphaev69) ax_gcc_arch="ev69 ev68 ev67" ;; - alphaev7) ax_gcc_arch="ev7 ev69 ev68 ev67" ;; - alphaev79) ax_gcc_arch="ev79 ev7 ev69 ev68 ev67" ;; - - powerpc*) - cputype=`((grep cpu /proc/cpuinfo | head -n 1 | cut -d: -f2 | cut -d, -f1 | sed 's/ //g') ; /usr/bin/machine ; /bin/machine; grep CPU /var/run/dmesg.boot | head -n 1 | cut -d" " -f2) 2> /dev/null` - cputype=`echo $cputype | sed -e 's/ppc//g;s/ *//g'` - case $cputype in - *750*) ax_gcc_arch="750 G3" ;; - *740[[0-9]]*) ax_gcc_arch="$cputype 7400 G4" ;; - *74[[4-5]][[0-9]]*) ax_gcc_arch="$cputype 7450 G4" ;; - *74[[0-9]][[0-9]]*) ax_gcc_arch="$cputype G4" ;; - *970*) ax_gcc_arch="970 G5 power4";; - *POWER4*|*power4*|*gq*) ax_gcc_arch="power4 970";; - *POWER5*|*power5*|*gr*|*gs*) ax_gcc_arch="power5 power4 970";; - 603ev|8240) ax_gcc_arch="$cputype 603e 603";; - *) ax_gcc_arch=$cputype ;; - esac - ax_gcc_arch="$ax_gcc_arch powerpc" - ;; -esac -fi # not cross-compiling -fi # guess arch - -if test "x$ax_gcc_arch" != x -a "x$ax_gcc_arch" != xno; then -for arch in $ax_gcc_arch; do - if test "x[]m4_default([$1],yes)" = xyes; then # if we require portable code - flags="-mtune=$arch" - # -mcpu=$arch and m$arch generate nonportable code on every arch except - # x86. And some other arches (e.g. Alpha) don't accept -mtune. Grrr. - case $host_cpu in i*86|x86_64*) flags="$flags -mcpu=$arch -m$arch";; esac - else - flags="-march=$arch -mcpu=$arch -m$arch" - fi - for flag in $flags; do - AX_CHECK_COMPILER_FLAGS($flag, [ax_cv_gcc_archflag=$flag; break]) - done - test "x$ax_cv_gcc_archflag" = xunknown || break -done -fi - -fi # $GCC=yes -]) -AC_MSG_CHECKING([for gcc architecture flag]) -AC_MSG_RESULT($ax_cv_gcc_archflag) -if test "x$ax_cv_gcc_archflag" = xunknown; then - m4_default([$3],:) -else - m4_default([$2], [CFLAGS="$CFLAGS $ax_cv_gcc_archflag"]) -fi -]) - diff --git a/libs/libdingaling/build/config/ac_gcc_x86_cpuid.m4 b/libs/libdingaling/build/config/ac_gcc_x86_cpuid.m4 deleted file mode 100644 index 3cf22d0dde..0000000000 --- a/libs/libdingaling/build/config/ac_gcc_x86_cpuid.m4 +++ /dev/null @@ -1,21 +0,0 @@ -AC_DEFUN([AX_GCC_X86_CPUID], -[AC_REQUIRE([AC_PROG_CC]) -AC_LANG_PUSH([C]) -AC_CACHE_CHECK(for x86 cpuid $1 output, ax_cv_gcc_x86_cpuid_$1, - [AC_RUN_IFELSE([AC_LANG_PROGRAM([#include ], [ - int op = $1, eax, ebx, ecx, edx; - FILE *f; - __asm__("cpuid" - : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx) - : "a" (op)); - f = fopen("conftest_cpuid", "w"); if (!f) return 1; - fprintf(f, "%x:%x:%x:%x\n", eax, ebx, ecx, edx); - fclose(f); - return 0; -])], - [ax_cv_gcc_x86_cpuid_$1=`cat conftest_cpuid`; rm -f conftest_cpuid], - [ax_cv_gcc_x86_cpuid_$1=unknown; rm -f conftest_cpuid], - [ax_cv_gcc_x86_cpuid_$1=unknown])]) -AC_LANG_POP([C]) -]) - diff --git a/libs/libdingaling/build/config/ac_prog_gzip.m4 b/libs/libdingaling/build/config/ac_prog_gzip.m4 deleted file mode 100644 index f37a4cc9ce..0000000000 --- a/libs/libdingaling/build/config/ac_prog_gzip.m4 +++ /dev/null @@ -1,9 +0,0 @@ -AC_DEFUN([AC_PROG_GZIP],[ -AC_CHECK_PROGS(gzip,[gzip],no) -export gzip; -if test $gzip = "no" ; -then - AC_MSG_ERROR([Unable to find the gzip application]); -fi -AC_SUBST(gzip) -]) diff --git a/libs/libdingaling/build/config/ac_prog_wget.m4 b/libs/libdingaling/build/config/ac_prog_wget.m4 deleted file mode 100644 index 56b6b8334f..0000000000 --- a/libs/libdingaling/build/config/ac_prog_wget.m4 +++ /dev/null @@ -1,9 +0,0 @@ -AC_DEFUN([AC_PROG_WGET],[ -AC_CHECK_PROGS(wget,[wget],no) -export wget; -if test $wget = "no" ; -then - AC_MSG_ERROR([Unable to find the wget application]); -fi -AC_SUBST(wget) -]) diff --git a/libs/libdingaling/build/config/ax_cc_maxopt.m4 b/libs/libdingaling/build/config/ax_cc_maxopt.m4 deleted file mode 100644 index 6205ee84c8..0000000000 --- a/libs/libdingaling/build/config/ax_cc_maxopt.m4 +++ /dev/null @@ -1,120 +0,0 @@ -AC_DEFUN([AX_CC_MAXOPT], -[ -AC_REQUIRE([AC_PROG_CC]) -AC_REQUIRE([AX_COMPILER_VENDOR]) - -AC_ARG_ENABLE(portable-binary, [AC_HELP_STRING([--enable-portable-binary], [disable compiler optimizations that would produce unportable binaries])], - acx_maxopt_portable=$withval, acx_maxopt_portable=no) - -# Try to determine "good" native compiler flags if none specified via CFLAGS -if test "$ac_test_CFLAGS" != "set"; then - CFLAGS="" - case $ax_cv_c_compiler_vendor in - dec) CFLAGS="-newc -w0 -O5 -ansi_alias -ansi_args -fp_reorder -tune host" - if test "x$acx_maxopt_portable" = xno; then - CFLAGS="$CFLAGS -arch host" - fi;; - - sun) CFLAGS="-native -fast -xO5 -dalign -xc99=all" - if test "x$acx_maxopt_portable" = xyes; then - CFLAGS="$CFLAGS -xarch=generic" - fi;; - - hp) CFLAGS="+Oall +Optrs_ansi +DSnative" - if test "x$acx_maxopt_portable" = xyes; then - CFLAGS="$CFLAGS +DAportable" - fi;; - - ibm) if test "x$acx_maxopt_portable" = xno; then - xlc_opt="-qarch=auto -qtune=auto" - else - xlc_opt="-qtune=auto" - fi - AX_CHECK_COMPILER_FLAGS($xlc_opt, - CFLAGS="-O3 -qansialias -w $xlc_opt", - [CFLAGS="-O3 -qansialias -w" - echo "******************************************************" - echo "* You seem to have the IBM C compiler. It is *" - echo "* recommended for best performance that you use: *" - echo "* *" - echo "* CFLAGS=-O3 -qarch=xxx -qtune=xxx -qansialias -w *" - echo "* ^^^ ^^^ *" - echo "* where xxx is pwr2, pwr3, 604, or whatever kind of *" - echo "* CPU you have. (Set the CFLAGS environment var. *" - echo "* and re-run configure.) For more info, man cc. *" - echo "******************************************************"]) - ;; - - intel) CFLAGS="-O3 -ansi_alias" - if test "x$acx_maxopt_portable" = xno; then - icc_archflag=unknown - icc_flags="" - case $host_cpu in - i686*|x86_64*) - # icc accepts gcc assembly syntax, so these should work: - AX_GCC_X86_CPUID(0) - AX_GCC_X86_CPUID(1) - case $ax_cv_gcc_x86_cpuid_0 in # see AX_GCC_ARCHFLAG - *:756e6547:*:*) # Intel - case $ax_cv_gcc_x86_cpuid_1 in - *6a?:*[[234]]:*:*|*6[[789b]]?:*:*:*) icc_flags="-xK";; - *f3[[347]]:*:*:*|*f4[1347]:*:*:*) icc_flags="-xP -xN -xW -xK";; - *f??:*:*:*) icc_flags="-xN -xW -xK";; - esac ;; - esac ;; - esac - if test "x$icc_flags" != x; then - for flag in $icc_flags; do - AX_CHECK_COMPILER_FLAGS($flag, [icc_archflag=$flag; break]) - done - fi - AC_MSG_CHECKING([for icc architecture flag]) - AC_MSG_RESULT($icc_archflag) - if test "x$icc_archflag" != xunknown; then - CFLAGS="$CFLAGS $icc_archflag" - fi - fi - ;; - - gnu) - # default optimization flags for gcc on all systems - CFLAGS="-O3 -fomit-frame-pointer" - - # -malign-double for x86 systems - AX_CHECK_COMPILER_FLAGS(-malign-double, CFLAGS="$CFLAGS -malign-double") - - # -fstrict-aliasing for gcc-2.95+ - AX_CHECK_COMPILER_FLAGS(-fstrict-aliasing, - CFLAGS="$CFLAGS -fstrict-aliasing") - - # note that we enable "unsafe" fp optimization with other compilers, too - AX_CHECK_COMPILER_FLAGS(-ffast-math, CFLAGS="$CFLAGS -ffast-math") - - AX_GCC_ARCHFLAG($acx_maxopt_portable) - ;; - esac - - if test -z "$CFLAGS"; then - echo "" - echo "********************************************************" - echo "* WARNING: Don't know the best CFLAGS for this system *" - echo "* Use ./configure CFLAGS=... to specify your own flags *" - echo "* (otherwise, a default of CFLAGS=-O3 will be used) *" - echo "********************************************************" - echo "" - CFLAGS="-O3" - fi - - AX_CHECK_COMPILER_FLAGS($CFLAGS, [], [ - echo "" - echo "********************************************************" - echo "* WARNING: The guessed CFLAGS don't seem to work with *" - echo "* your compiler. *" - echo "* Use ./configure CFLAGS=... to specify your own flags *" - echo "********************************************************" - echo "" - CFLAGS="" - ]) - -fi -]) diff --git a/libs/libdingaling/build/config/ax_cflags_warn_all_ansi.m4 b/libs/libdingaling/build/config/ax_cflags_warn_all_ansi.m4 deleted file mode 100644 index 5b35464457..0000000000 --- a/libs/libdingaling/build/config/ax_cflags_warn_all_ansi.m4 +++ /dev/null @@ -1,94 +0,0 @@ -AC_DEFUN([AX_CFLAGS_WARN_ALL_ANSI],[dnl -AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl -AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_warn_all_ansi])dnl -AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum ansi warnings], -VAR,[VAR="no, unknown" - AC_LANG_SAVE - AC_LANG_C - ac_save_[]FLAGS="$[]FLAGS" -# IRIX C compiler: -# -use_readonly_const is the default for IRIX C, -# puts them into .rodata, but they are copied later. -# need to be "-G0 -rdatashared" for strictmode but -# I am not sure what effect that has really. - guidod -for ac_arg dnl -in "-pedantic % -Wall -std=c99 -pedantic" dnl GCC - "-xstrconst % -v -xc99=all" dnl Solaris C - "-std1 % -verbose -w0 -warnprotos -std1" dnl Digital Unix - " % -qlanglvl=ansi -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX - " % -ansi -ansiE -fullwarn" dnl IRIX - "+ESlit % +w1 -Aa" dnl HP-UX C - "-Xc % -pvctl[,]fullmsg -Xc" dnl NEC SX-5 (Super-UX 10) - "-h conform % -h msglevel 2 -h conform" dnl Cray C (Unicos) - # -do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` - AC_TRY_COMPILE([],[return 0;], - [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) -done - FLAGS="$ac_save_[]FLAGS" - AC_LANG_RESTORE -]) -case ".$VAR" in - .ok|.ok,*) m4_ifvaln($3,$3) ;; - .|.no|.no,*) m4_ifvaln($4,$4,[m4_ifval($2,[ - AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"]) - m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])]) ;; - *) m4_ifvaln($3,$3,[ - if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null - then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR]) - else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"]) - m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR" - fi ]) ;; -esac -AS_VAR_POPDEF([VAR])dnl -AS_VAR_POPDEF([FLAGS])dnl -]) - -dnl the only difference - the LANG selection... and the default FLAGS - -AC_DEFUN([AX_CXXFLAGS_WARN_ALL_ANSI],[dnl -AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl -AS_VAR_PUSHDEF([VAR],[ac_cv_cxxflags_warn_all_ansi])dnl -AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum ansi warnings], -VAR,[VAR="no, unknown" - AC_LANG_SAVE - AC_LANG_CXX - ac_save_[]FLAGS="$[]FLAGS" -# IRIX C compiler: -# -use_readonly_const is the default for IRIX C, -# puts them into .rodata, but they are copied later. -# need to be "-G0 -rdatashared" for strictmode but -# I am not sure what effect that has really. - guidod -for ac_arg dnl -in "-pedantic % -Wall -ansi -pedantic" dnl GCC - "-xstrconst % -v -Xc" dnl Solaris C - "-std1 % -verbose -w0 -warnprotos -std1" dnl Digital Unix - " % -qlanglvl=ansi -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX - " % -ansi -ansiE -fullwarn" dnl IRIX - "+ESlit % +w1 -Aa" dnl HP-UX C - "-Xc % -pvctl[,]fullmsg -Xc" dnl NEC SX-5 (Super-UX 10) - "-h conform % -h msglevel 2 -h conform" dnl Cray C (Unicos) - # -do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` - AC_TRY_COMPILE([],[return 0;], - [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) -done - FLAGS="$ac_save_[]FLAGS" - AC_LANG_RESTORE -]) -case ".$VAR" in - .ok|.ok,*) m4_ifvaln($3,$3) ;; - .|.no|.no,*) m4_ifvaln($4,$4,[m4_ifval($2,[ - AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"]) - m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])]) ;; - *) m4_ifvaln($3,$3,[ - if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null - then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR]) - else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"]) - m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR" - fi ]) ;; -esac -AS_VAR_POPDEF([VAR])dnl -AS_VAR_POPDEF([FLAGS])dnl -]) - diff --git a/libs/libdingaling/build/config/ax_check_compiler_flags.m4 b/libs/libdingaling/build/config/ax_check_compiler_flags.m4 deleted file mode 100644 index 73377b7c59..0000000000 --- a/libs/libdingaling/build/config/ax_check_compiler_flags.m4 +++ /dev/null @@ -1,26 +0,0 @@ -AC_DEFUN([AX_CHECK_COMPILER_FLAGS], -[AC_PREREQ(2.59) dnl for _AC_LANG_PREFIX -AC_MSG_CHECKING([whether _AC_LANG compiler accepts $1]) -dnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname: -AS_LITERAL_IF([$1], - [AC_CACHE_VAL(AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1), [ - ax_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS - _AC_LANG_PREFIX[]FLAGS="$1" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], - AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=yes, - AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=no) - _AC_LANG_PREFIX[]FLAGS=$ax_save_FLAGS])], - [ax_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS - _AC_LANG_PREFIX[]FLAGS="$1" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], - eval AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=yes, - eval AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=no) - _AC_LANG_PREFIX[]FLAGS=$ax_save_FLAGS]) -eval ax_check_compiler_flags=$AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1) -AC_MSG_RESULT($ax_check_compiler_flags) -if test "x$ax_check_compiler_flags" = xyes; then - m4_default([$2], :) -else - m4_default([$3], :) -fi -])dnl AX_CHECK_COMPILER_FLAG diff --git a/libs/libdingaling/build/config/ax_compiler_vendor.m4 b/libs/libdingaling/build/config/ax_compiler_vendor.m4 deleted file mode 100644 index a24a58da0f..0000000000 --- a/libs/libdingaling/build/config/ax_compiler_vendor.m4 +++ /dev/null @@ -1,15 +0,0 @@ -AC_DEFUN([AX_COMPILER_VENDOR], -[ -AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor, - [ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=unknown - # note: don't check for gcc first since some other compilers define __GNUC__ - for ventest in intel:__ICC,__ECC,__INTEL_COMPILER ibm:__xlc__,__xlC__,__IBMC__,__IBMCPP__ gnu:__GNUC__ sun:__SUNPRO_C,__SUNPRO_CC hp:__HP_cc,__HP_aCC dec:__DECC,__DECCXX,__DECC_VER,__DECCXX_VER borland:__BORLANDC__,__TURBOC__ comeau:__COMO__ cray:_CRAYC kai:__KCC lcc:__LCC__ metrowerks:__MWERKS__ sgi:__sgi,sgi microsoft:_MSC_VER watcom:__WATCOMC__ portland:__PGI; do - vencpp="defined("`echo $ventest | cut -d: -f2 | sed 's/,/) || defined(/g'`")" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ -#if !($vencpp) - thisisanerror; -#endif -])], [ax_cv_]_AC_LANG_ABBREV[_compiler_vendor=`echo $ventest | cut -d: -f1`; break]) - done - ]) -]) diff --git a/libs/libdingaling/compile b/libs/libdingaling/compile deleted file mode 100755 index 1b1d232169..0000000000 --- a/libs/libdingaling/compile +++ /dev/null @@ -1,142 +0,0 @@ -#! /bin/sh -# Wrapper for compilers which do not understand `-c -o'. - -scriptversion=2005-05-14.22 - -# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. -# Written by Tom Tromey . -# -# 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, or (at your option) -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# This file is maintained in Automake, please report -# bugs to or send patches to -# . - -case $1 in - '') - echo "$0: No command. Try \`$0 --help' for more information." 1>&2 - exit 1; - ;; - -h | --h*) - cat <<\EOF -Usage: compile [--help] [--version] PROGRAM [ARGS] - -Wrapper for compilers which do not understand `-c -o'. -Remove `-o dest.o' from ARGS, run PROGRAM with the remaining -arguments, and rename the output as expected. - -If you are trying to build a whole package this is not the -right script to run: please start by reading the file `INSTALL'. - -Report bugs to . -EOF - exit $? - ;; - -v | --v*) - echo "compile $scriptversion" - exit $? - ;; -esac - -ofile= -cfile= -eat= - -for arg -do - if test -n "$eat"; then - eat= - else - case $1 in - -o) - # configure might choose to run compile as `compile cc -o foo foo.c'. - # So we strip `-o arg' only if arg is an object. - eat=1 - case $2 in - *.o | *.obj) - ofile=$2 - ;; - *) - set x "$@" -o "$2" - shift - ;; - esac - ;; - *.c) - cfile=$1 - set x "$@" "$1" - shift - ;; - *) - set x "$@" "$1" - shift - ;; - esac - fi - shift -done - -if test -z "$ofile" || test -z "$cfile"; then - # If no `-o' option was seen then we might have been invoked from a - # pattern rule where we don't need one. That is ok -- this is a - # normal compilation that the losing compiler can handle. If no - # `.c' file was seen then we are probably linking. That is also - # ok. - exec "$@" -fi - -# Name of file we expect compiler to create. -cofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'` - -# Create the lock directory. -# Note: use `[/.-]' here to ensure that we don't use the same name -# that we are using for the .o file. Also, base the name on the expected -# object file name, since that is what matters with a parallel build. -lockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d -while true; do - if mkdir "$lockdir" >/dev/null 2>&1; then - break - fi - sleep 1 -done -# FIXME: race condition here if user kills between mkdir and trap. -trap "rmdir '$lockdir'; exit 1" 1 2 15 - -# Run the compile. -"$@" -ret=$? - -if test -f "$cofile"; then - mv "$cofile" "$ofile" -elif test -f "${cofile}bj"; then - mv "${cofile}bj" "$ofile" -fi - -rmdir "$lockdir" -exit $ret - -# Local Variables: -# mode: shell-script -# sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-end: "$" -# End: diff --git a/libs/libdingaling/config.guess b/libs/libdingaling/config.guess deleted file mode 100644 index 1f5c50c0d1..0000000000 --- a/libs/libdingaling/config.guess +++ /dev/null @@ -1,1420 +0,0 @@ -#! /bin/sh -# Attempt to guess a canonical system name. -# Copyright 1992-2014 Free Software Foundation, Inc. - -timestamp='2014-03-23' - -# This file 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 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, see . -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that -# program. This Exception is an additional permission under section 7 -# of the GNU General Public License, version 3 ("GPLv3"). -# -# Originally written by Per Bothner. -# -# You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD -# -# Please send patches with a ChangeLog entry to config-patches@gnu.org. - - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] - -Output the configuration name of the system \`$me' is run on. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.guess ($timestamp) - -Originally written by Per Bothner. -Copyright 1992-2014 Free Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit ;; - --version | -v ) - echo "$version" ; exit ;; - --help | --h* | -h ) - echo "$usage"; exit ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" >&2 - exit 1 ;; - * ) - break ;; - esac -done - -if test $# != 0; then - echo "$me: too many arguments$help" >&2 - exit 1 -fi - -trap 'exit 1' 1 2 15 - -# CC_FOR_BUILD -- compiler used by this script. Note that the use of a -# compiler to aid in system detection is discouraged as it requires -# temporary files to be created and, as you can see below, it is a -# headache to deal with in a portable fashion. - -# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still -# use `HOST_CC' if defined, but it is deprecated. - -# Portable tmp directory creation inspired by the Autoconf team. - -set_cc_for_build=' -trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; -trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; -: ${TMPDIR=/tmp} ; - { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || - { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || - { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || - { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; -dummy=$tmp/dummy ; -tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; -case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int x;" > $dummy.c ; - for c in cc gcc c89 c99 ; do - if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then - CC_FOR_BUILD="$c"; break ; - fi ; - done ; - if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found ; - fi - ;; - ,,*) CC_FOR_BUILD=$CC ;; - ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac ; set_cc_for_build= ;' - -# This is needed to find uname on a Pyramid OSx when run in the BSD universe. -# (ghazi@noc.rutgers.edu 1994-08-24) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then - PATH=$PATH:/.attbin ; export PATH -fi - -UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown -UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown -UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown -UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown - -case "${UNAME_SYSTEM}" in -Linux|GNU|GNU/*) - # If the system lacks a compiler, then just pick glibc. - # We could probably try harder. - LIBC=gnu - - eval $set_cc_for_build - cat <<-EOF > $dummy.c - #include - #if defined(__UCLIBC__) - LIBC=uclibc - #elif defined(__dietlibc__) - LIBC=dietlibc - #else - LIBC=gnu - #endif - EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` - ;; -esac - -# Note: order is significant - the case branches are not exclusive. - -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in - *:NetBSD:*:*) - # NetBSD (nbsd) targets should (where applicable) match one or - # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, - # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently - # switched to ELF, *-*-netbsd* would select the old - # object file format. This provides both forward - # compatibility and a consistent mechanism for selecting the - # object file format. - # - # Note: NetBSD doesn't particularly care about the vendor - # portion of the name. We always set it to "unknown". - sysctl="sysctl -n hw.machine_arch" - UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || echo unknown)` - case "${UNAME_MACHINE_ARCH}" in - armeb) machine=armeb-unknown ;; - arm*) machine=arm-unknown ;; - sh3el) machine=shl-unknown ;; - sh3eb) machine=sh-unknown ;; - sh5el) machine=sh5le-unknown ;; - *) machine=${UNAME_MACHINE_ARCH}-unknown ;; - esac - # The Operating System including object format, if it has switched - # to ELF recently, or will in the future. - case "${UNAME_MACHINE_ARCH}" in - arm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build - if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep -q __ELF__ - then - # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). - # Return netbsd for either. FIX? - os=netbsd - else - os=netbsdelf - fi - ;; - *) - os=netbsd - ;; - esac - # The OS release - # Debian GNU/NetBSD machines have a different userland, and - # thus, need a distinct triplet. However, they do not need - # kernel version information, so it can be replaced with a - # suitable tag, in the style of linux-gnu. - case "${UNAME_VERSION}" in - Debian*) - release='-gnu' - ;; - *) - release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` - ;; - esac - # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: - # contains redundant information, the shorter form: - # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}" - exit ;; - *:Bitrig:*:*) - UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} - exit ;; - *:OpenBSD:*:*) - UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} - exit ;; - *:ekkoBSD:*:*) - echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} - exit ;; - *:SolidBSD:*:*) - echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} - exit ;; - macppc:MirBSD:*:*) - echo powerpc-unknown-mirbsd${UNAME_RELEASE} - exit ;; - *:MirBSD:*:*) - echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} - exit ;; - alpha:OSF1:*:*) - case $UNAME_RELEASE in - *4.0) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` - ;; - *5.*) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` - ;; - esac - # According to Compaq, /usr/sbin/psrinfo has been available on - # OSF/1 and Tru64 systems produced since 1995. I hope that - # covers most systems running today. This code pipes the CPU - # types through head -n 1, so we only detect the type of CPU 0. - ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` - case "$ALPHA_CPU_TYPE" in - "EV4 (21064)") - UNAME_MACHINE="alpha" ;; - "EV4.5 (21064)") - UNAME_MACHINE="alpha" ;; - "LCA4 (21066/21068)") - UNAME_MACHINE="alpha" ;; - "EV5 (21164)") - UNAME_MACHINE="alphaev5" ;; - "EV5.6 (21164A)") - UNAME_MACHINE="alphaev56" ;; - "EV5.6 (21164PC)") - UNAME_MACHINE="alphapca56" ;; - "EV5.7 (21164PC)") - UNAME_MACHINE="alphapca57" ;; - "EV6 (21264)") - UNAME_MACHINE="alphaev6" ;; - "EV6.7 (21264A)") - UNAME_MACHINE="alphaev67" ;; - "EV6.8CB (21264C)") - UNAME_MACHINE="alphaev68" ;; - "EV6.8AL (21264B)") - UNAME_MACHINE="alphaev68" ;; - "EV6.8CX (21264D)") - UNAME_MACHINE="alphaev68" ;; - "EV6.9A (21264/EV69A)") - UNAME_MACHINE="alphaev69" ;; - "EV7 (21364)") - UNAME_MACHINE="alphaev7" ;; - "EV7.9 (21364A)") - UNAME_MACHINE="alphaev79" ;; - esac - # A Pn.n version is a patched version. - # A Vn.n version is a released version. - # A Tn.n version is a released field test version. - # A Xn.n version is an unreleased experimental baselevel. - # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - # Reset EXIT trap before exiting to avoid spurious non-zero exit code. - exitcode=$? - trap '' 0 - exit $exitcode ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit ;; - Amiga*:UNIX_System_V:4.0:*) - echo m68k-unknown-sysv4 - exit ;; - *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos - exit ;; - *:[Mm]orph[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-morphos - exit ;; - *:OS/390:*:*) - echo i370-ibm-openedition - exit ;; - *:z/VM:*:*) - echo s390-ibm-zvmoe - exit ;; - *:OS400:*:*) - echo powerpc-ibm-os400 - exit ;; - arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} - exit ;; - arm*:riscos:*:*|arm*:RISCOS:*:*) - echo arm-unknown-riscos - exit ;; - SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) - echo hppa1.1-hitachi-hiuxmpp - exit ;; - Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) - # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. - if test "`(/bin/universe) 2>/dev/null`" = att ; then - echo pyramid-pyramid-sysv3 - else - echo pyramid-pyramid-bsd - fi - exit ;; - NILE*:*:*:dcosx) - echo pyramid-pyramid-svr4 - exit ;; - DRS?6000:unix:4.0:6*) - echo sparc-icl-nx6 - exit ;; - DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) - case `/usr/bin/uname -p` in - sparc) echo sparc-icl-nx7; exit ;; - esac ;; - s390x:SunOS:*:*) - echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) - echo i386-pc-auroraux${UNAME_RELEASE} - exit ;; - i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) - eval $set_cc_for_build - SUN_ARCH="i386" - # If there is a compiler, see if it is configured for 64-bit objects. - # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. - # This test works for both compilers. - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then - if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null - then - SUN_ARCH="x86_64" - fi - fi - echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:6*:*) - # According to config.sub, this is the proper way to canonicalize - # SunOS6. Hard to guess exactly what SunOS6 will be like, but - # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:*:*) - case "`/usr/bin/arch -k`" in - Series*|S4*) - UNAME_RELEASE=`uname -v` - ;; - esac - # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` - exit ;; - sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} - exit ;; - sun*:*:4.2BSD:*) - UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 - case "`/bin/arch`" in - sun3) - echo m68k-sun-sunos${UNAME_RELEASE} - ;; - sun4) - echo sparc-sun-sunos${UNAME_RELEASE} - ;; - esac - exit ;; - aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} - exit ;; - # The situation for MiNT is a little confusing. The machine name - # can be virtually everything (everything which is not - # "atarist" or "atariste" at least should have a processor - # > m68000). The system name ranges from "MiNT" over "FreeMiNT" - # to the lowercase version "mint" (or "freemint"). Finally - # the system name "TOS" denotes a system which is actually not - # MiNT. But MiNT is downward compatible to TOS, so this should - # be no problem. - atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit ;; - hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit ;; - *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit ;; - m68k:machten:*:*) - echo m68k-apple-machten${UNAME_RELEASE} - exit ;; - powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} - exit ;; - RISC*:Mach:*:*) - echo mips-dec-mach_bsd4.3 - exit ;; - RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} - exit ;; - VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} - exit ;; - 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} - exit ;; - mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c -#ifdef __cplusplus -#include /* for printf() prototype */ - int main (int argc, char *argv[]) { -#else - int main (argc, argv) int argc; char *argv[]; { -#endif - #if defined (host_mips) && defined (MIPSEB) - #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); - #endif - #endif - exit (-1); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c && - dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && - SYSTEM_NAME=`$dummy $dummyarg` && - { echo "$SYSTEM_NAME"; exit; } - echo mips-mips-riscos${UNAME_RELEASE} - exit ;; - Motorola:PowerMAX_OS:*:*) - echo powerpc-motorola-powermax - exit ;; - Motorola:*:4.3:PL8-*) - echo powerpc-harris-powermax - exit ;; - Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) - echo powerpc-harris-powermax - exit ;; - Night_Hawk:Power_UNIX:*:*) - echo powerpc-harris-powerunix - exit ;; - m88k:CX/UX:7*:*) - echo m88k-harris-cxux7 - exit ;; - m88k:*:4*:R4*) - echo m88k-motorola-sysv4 - exit ;; - m88k:*:3*:R3*) - echo m88k-motorola-sysv3 - exit ;; - AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] - then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] - then - echo m88k-dg-dgux${UNAME_RELEASE} - else - echo m88k-dg-dguxbcs${UNAME_RELEASE} - fi - else - echo i586-dg-dgux${UNAME_RELEASE} - fi - exit ;; - M88*:DolphinOS:*:*) # DolphinOS (SVR3) - echo m88k-dolphin-sysv3 - exit ;; - M88*:*:R3*:*) - # Delta 88k system running SVR3 - echo m88k-motorola-sysv3 - exit ;; - XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) - echo m88k-tektronix-sysv3 - exit ;; - Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) - echo m68k-tektronix-bsd - exit ;; - *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` - exit ;; - ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' - i*86:AIX:*:*) - echo i386-ibm-aix - exit ;; - ia64:AIX:*:*) - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} - exit ;; - *:AIX:2:3) - if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - - main() - { - if (!__power_pc()) - exit(1); - puts("powerpc-ibm-aix3.2.5"); - exit(0); - } -EOF - if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` - then - echo "$SYSTEM_NAME" - else - echo rs6000-ibm-aix3.2.5 - fi - elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then - echo rs6000-ibm-aix3.2.4 - else - echo rs6000-ibm-aix3.2 - fi - exit ;; - *:AIX:*:[4567]) - IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` - if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then - IBM_ARCH=rs6000 - else - IBM_ARCH=powerpc - fi - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} - exit ;; - *:AIX:*:*) - echo rs6000-ibm-aix - exit ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) - echo romp-ibm-bsd4.4 - exit ;; - ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to - exit ;; # report: romp-ibm BSD 4.3 - *:BOSX:*:*) - echo rs6000-bull-bosx - exit ;; - DPX/2?00:B.O.S.:*:*) - echo m68k-bull-sysv3 - exit ;; - 9000/[34]??:4.3bsd:1.*:*) - echo m68k-hp-bsd - exit ;; - hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) - echo m68k-hp-bsd4.4 - exit ;; - 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; - 9000/[678][0-9][0-9]) - if [ -x /usr/bin/getconf ]; then - sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` - sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 - 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; - '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 - esac ;; - esac - fi - if [ "${HP_ARCH}" = "" ]; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - - #define _HPUX_SOURCE - #include - #include - - int main () - { - #if defined(_SC_KERNEL_BITS) - long bits = sysconf(_SC_KERNEL_BITS); - #endif - long cpu = sysconf (_SC_CPU_VERSION); - - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1"); break; - case CPU_PA_RISC2_0: - #if defined(_SC_KERNEL_BITS) - switch (bits) - { - case 64: puts ("hppa2.0w"); break; - case 32: puts ("hppa2.0n"); break; - default: puts ("hppa2.0"); break; - } break; - #else /* !defined(_SC_KERNEL_BITS) */ - puts ("hppa2.0"); break; - #endif - default: puts ("hppa1.0"); break; - } - exit (0); - } -EOF - (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` - test -z "$HP_ARCH" && HP_ARCH=hppa - fi ;; - esac - if [ ${HP_ARCH} = "hppa2.0w" ] - then - eval $set_cc_for_build - - # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating - # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler - # generating 64-bit code. GNU and HP use different nomenclature: - # - # $ CC_FOR_BUILD=cc ./config.guess - # => hppa2.0w-hp-hpux11.23 - # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess - # => hppa64-hp-hpux11.23 - - if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | - grep -q __LP64__ - then - HP_ARCH="hppa2.0w" - else - HP_ARCH="hppa64" - fi - fi - echo ${HP_ARCH}-hp-hpux${HPUX_REV} - exit ;; - ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} - exit ;; - 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - int - main () - { - long cpu = sysconf (_SC_CPU_VERSION); - /* The order matters, because CPU_IS_HP_MC68K erroneously returns - true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct - results, however. */ - if (CPU_IS_PA_RISC (cpu)) - { - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; - case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; - default: puts ("hppa-hitachi-hiuxwe2"); break; - } - } - else if (CPU_IS_HP_MC68K (cpu)) - puts ("m68k-hitachi-hiuxwe2"); - else puts ("unknown-hitachi-hiuxwe2"); - exit (0); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && - { echo "$SYSTEM_NAME"; exit; } - echo unknown-hitachi-hiuxwe2 - exit ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) - echo hppa1.1-hp-bsd - exit ;; - 9000/8??:4.3bsd:*:*) - echo hppa1.0-hp-bsd - exit ;; - *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) - echo hppa1.0-hp-mpeix - exit ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) - echo hppa1.1-hp-osf - exit ;; - hp8??:OSF1:*:*) - echo hppa1.0-hp-osf - exit ;; - i*86:OSF1:*:*) - if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk - else - echo ${UNAME_MACHINE}-unknown-osf1 - fi - exit ;; - parisc*:Lites*:*:*) - echo hppa1.1-hp-lites - exit ;; - C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) - echo c1-convex-bsd - exit ;; - C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit ;; - C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) - echo c34-convex-bsd - exit ;; - C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) - echo c38-convex-bsd - exit ;; - C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) - echo c4-convex-bsd - exit ;; - CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ - | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ - -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ - -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - *:UNICOS/mp:*:*) - echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) - FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; - 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` - echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; - i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} - exit ;; - sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} - exit ;; - *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} - exit ;; - *:FreeBSD:*:*) - UNAME_PROCESSOR=`/usr/bin/uname -p` - case ${UNAME_PROCESSOR} in - amd64) - echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - *) - echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - esac - exit ;; - i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin - exit ;; - *:MINGW64*:*) - echo ${UNAME_MACHINE}-pc-mingw64 - exit ;; - *:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 - exit ;; - *:MSYS*:*) - echo ${UNAME_MACHINE}-pc-msys - exit ;; - i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 - exit ;; - i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 - exit ;; - *:Interix*:*) - case ${UNAME_MACHINE} in - x86) - echo i586-pc-interix${UNAME_RELEASE} - exit ;; - authenticamd | genuineintel | EM64T) - echo x86_64-unknown-interix${UNAME_RELEASE} - exit ;; - IA64) - echo ia64-unknown-interix${UNAME_RELEASE} - exit ;; - esac ;; - [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) - echo i${UNAME_MACHINE}-pc-mks - exit ;; - 8664:Windows_NT:*) - echo x86_64-pc-mks - exit ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i586-pc-interix - exit ;; - i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin - exit ;; - amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) - echo x86_64-unknown-cygwin - exit ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin - exit ;; - prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - *:GNU:*:*) - # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` - exit ;; - *:GNU/*:*:*) - # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} - exit ;; - i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix - exit ;; - aarch64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - aarch64_be:Linux:*:*) - UNAME_MACHINE=aarch64_be - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in - EV5) UNAME_MACHINE=alphaev5 ;; - EV56) UNAME_MACHINE=alphaev56 ;; - PCA56) UNAME_MACHINE=alphapca56 ;; - PCA57) UNAME_MACHINE=alphapca56 ;; - EV6) UNAME_MACHINE=alphaev6 ;; - EV67) UNAME_MACHINE=alphaev67 ;; - EV68*) UNAME_MACHINE=alphaev68 ;; - esac - objdump --private-headers /bin/sh | grep -q ld.so.1 - if test "$?" = 0 ; then LIBC="gnulibc1" ; fi - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - arc:Linux:*:* | arceb:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - arm*:Linux:*:*) - eval $set_cc_for_build - if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep -q __ARM_EABI__ - then - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - else - if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep -q __ARM_PCS_VFP - then - echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi - else - echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf - fi - fi - exit ;; - avr32*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - cris:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} - exit ;; - crisv32:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} - exit ;; - frv:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - hexagon:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - i*86:Linux:*:*) - echo ${UNAME_MACHINE}-pc-linux-${LIBC} - exit ;; - ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - mips:Linux:*:* | mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #undef CPU - #undef ${UNAME_MACHINE} - #undef ${UNAME_MACHINE}el - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=${UNAME_MACHINE}el - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=${UNAME_MACHINE} - #else - CPU= - #endif - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } - ;; - openrisc*:Linux:*:*) - echo or1k-unknown-linux-${LIBC} - exit ;; - or32:Linux:*:* | or1k*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - padre:Linux:*:*) - echo sparc-unknown-linux-${LIBC} - exit ;; - parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-${LIBC} - exit ;; - parisc:Linux:*:* | hppa:Linux:*:*) - # Look for CPU level - case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; - PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; - *) echo hppa-unknown-linux-${LIBC} ;; - esac - exit ;; - ppc64:Linux:*:*) - echo powerpc64-unknown-linux-${LIBC} - exit ;; - ppc:Linux:*:*) - echo powerpc-unknown-linux-${LIBC} - exit ;; - ppc64le:Linux:*:*) - echo powerpc64le-unknown-linux-${LIBC} - exit ;; - ppcle:Linux:*:*) - echo powerpcle-unknown-linux-${LIBC} - exit ;; - s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux-${LIBC} - exit ;; - sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - tile*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - vax:Linux:*:*) - echo ${UNAME_MACHINE}-dec-linux-${LIBC} - exit ;; - x86_64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - i*86:DYNIX/ptx:4*:*) - # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. - # earlier versions are messed up and put the nodename in both - # sysname and nodename. - echo i386-sequent-sysv4 - exit ;; - i*86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... - # I am not positive that other SVR4 systems won't match this, - # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} - exit ;; - i*86:OS/2:*:*) - # If we were able to find `uname', then EMX Unix compatibility - # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx - exit ;; - i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop - exit ;; - i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos - exit ;; - i*86:syllable:*:*) - echo ${UNAME_MACHINE}-pc-syllable - exit ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} - exit ;; - i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp - exit ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` - if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} - else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} - fi - exit ;; - i*86:*:5:[678]*) - # UnixWare 7.x, OpenUNIX and OpenServer 6. - case `/bin/uname -X | grep "^Machine"` in - *486*) UNAME_MACHINE=i486 ;; - *Pentium) UNAME_MACHINE=i586 ;; - *Pent*|*Celeron) UNAME_MACHINE=i686 ;; - esac - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} - exit ;; - i*86:*:3.2:*) - if test -f /usr/options/cb.name; then - UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then - UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` - (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 - (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ - && UNAME_MACHINE=i586 - (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ - && UNAME_MACHINE=i686 - (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ - && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL - else - echo ${UNAME_MACHINE}-pc-sysv32 - fi - exit ;; - pc:*:*:*) - # Left here for compatibility: - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i586. - # Note: whatever this is, it MUST be the same as what config.sub - # prints for the "djgpp" host, or else GDB configury will decide that - # this is a cross-build. - echo i586-pc-msdosdjgpp - exit ;; - Intel:Mach:3*:*) - echo i386-pc-mach3 - exit ;; - paragon:*:*:*) - echo i860-intel-osf1 - exit ;; - i860:*:4.*:*) # i860-SVR4 - if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 - else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 - fi - exit ;; - mini*:CTIX:SYS*5:*) - # "miniframe" - echo m68010-convergent-sysv - exit ;; - mc68k:UNIX:SYSTEM5:3.51m) - echo m68k-convergent-sysv - exit ;; - M680?0:D-NIX:5.3:*) - echo m68k-diab-dnix - exit ;; - M68*:*:R3V[5678]*:*) - test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; - 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) - OS_REL='' - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; - 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4; exit; } ;; - NCR*:*:4.2:* | MPRAS*:*:4.2:*) - OS_REL='.3' - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } - /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; - m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} - exit ;; - mc68030:UNIX_System_V:4.*:*) - echo m68k-atari-sysv4 - exit ;; - TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} - exit ;; - rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} - exit ;; - PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} - exit ;; - SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} - exit ;; - RM*:ReliantUNIX-*:*:*) - echo mips-sni-sysv4 - exit ;; - RM*:SINIX-*:*:*) - echo mips-sni-sysv4 - exit ;; - *:SINIX-*:*:*) - if uname -p 2>/dev/null >/dev/null ; then - UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 - else - echo ns32k-sni-sysv - fi - exit ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says - echo i586-unisys-sysv4 - exit ;; - *:UNIX_System_V:4*:FTX*) - # From Gerald Hewes . - # How about differentiating between stratus architectures? -djm - echo hppa1.1-stratus-sysv4 - exit ;; - *:*:*:FTX*) - # From seanf@swdc.stratus.com. - echo i860-stratus-sysv4 - exit ;; - i*86:VOS:*:*) - # From Paul.Green@stratus.com. - echo ${UNAME_MACHINE}-stratus-vos - exit ;; - *:VOS:*:*) - # From Paul.Green@stratus.com. - echo hppa1.1-stratus-vos - exit ;; - mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} - exit ;; - news*:NEWS-OS:6*:*) - echo mips-sony-newsos6 - exit ;; - R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) - if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} - else - echo mips-unknown-sysv${UNAME_RELEASE} - fi - exit ;; - BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. - echo powerpc-be-beos - exit ;; - BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. - echo powerpc-apple-beos - exit ;; - BePC:BeOS:*:*) # BeOS running on Intel PC compatible. - echo i586-pc-beos - exit ;; - BePC:Haiku:*:*) # Haiku running on Intel PC compatible. - echo i586-pc-haiku - exit ;; - x86_64:Haiku:*:*) - echo x86_64-unknown-haiku - exit ;; - SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} - exit ;; - SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} - exit ;; - SX-6:SUPER-UX:*:*) - echo sx6-nec-superux${UNAME_RELEASE} - exit ;; - SX-7:SUPER-UX:*:*) - echo sx7-nec-superux${UNAME_RELEASE} - exit ;; - SX-8:SUPER-UX:*:*) - echo sx8-nec-superux${UNAME_RELEASE} - exit ;; - SX-8R:SUPER-UX:*:*) - echo sx8r-nec-superux${UNAME_RELEASE} - exit ;; - Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} - exit ;; - *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} - exit ;; - *:Darwin:*:*) - UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - eval $set_cc_for_build - if test "$UNAME_PROCESSOR" = unknown ; then - UNAME_PROCESSOR=powerpc - fi - if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then - if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null - then - case $UNAME_PROCESSOR in - i386) UNAME_PROCESSOR=x86_64 ;; - powerpc) UNAME_PROCESSOR=powerpc64 ;; - esac - fi - fi - elif test "$UNAME_PROCESSOR" = i386 ; then - # Avoid executing cc on OS X 10.9, as it ships with a stub - # that puts up a graphical alert prompting to install - # developer tools. Any system running Mac OS X 10.7 or - # later (Darwin 11 and later) is required to have a 64-bit - # processor. This is not true of the ARM version of Darwin - # that Apple uses in portable devices. - UNAME_PROCESSOR=x86_64 - fi - echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} - exit ;; - *:procnto*:*:* | *:QNX:[0123456789]*:*) - UNAME_PROCESSOR=`uname -p` - if test "$UNAME_PROCESSOR" = "x86"; then - UNAME_PROCESSOR=i386 - UNAME_MACHINE=pc - fi - echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} - exit ;; - *:QNX:*:4*) - echo i386-pc-qnx - exit ;; - NEO-?:NONSTOP_KERNEL:*:*) - echo neo-tandem-nsk${UNAME_RELEASE} - exit ;; - NSE-*:NONSTOP_KERNEL:*:*) - echo nse-tandem-nsk${UNAME_RELEASE} - exit ;; - NSR-?:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} - exit ;; - *:NonStop-UX:*:*) - echo mips-compaq-nonstopux - exit ;; - BS2000:POSIX*:*:*) - echo bs2000-siemens-sysv - exit ;; - DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} - exit ;; - *:Plan9:*:*) - # "uname -m" is not consistent, so use $cputype instead. 386 - # is converted to i386 for consistency with other x86 - # operating systems. - if test "$cputype" = "386"; then - UNAME_MACHINE=i386 - else - UNAME_MACHINE="$cputype" - fi - echo ${UNAME_MACHINE}-unknown-plan9 - exit ;; - *:TOPS-10:*:*) - echo pdp10-unknown-tops10 - exit ;; - *:TENEX:*:*) - echo pdp10-unknown-tenex - exit ;; - KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) - echo pdp10-dec-tops20 - exit ;; - XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) - echo pdp10-xkl-tops20 - exit ;; - *:TOPS-20:*:*) - echo pdp10-unknown-tops20 - exit ;; - *:ITS:*:*) - echo pdp10-unknown-its - exit ;; - SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} - exit ;; - *:DragonFly:*:*) - echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit ;; - *:*VMS:*:*) - UNAME_MACHINE=`(uname -p) 2>/dev/null` - case "${UNAME_MACHINE}" in - A*) echo alpha-dec-vms ; exit ;; - I*) echo ia64-dec-vms ; exit ;; - V*) echo vax-dec-vms ; exit ;; - esac ;; - *:XENIX:*:SysV) - echo i386-pc-xenix - exit ;; - i*86:skyos:*:*) - echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' - exit ;; - i*86:rdos:*:*) - echo ${UNAME_MACHINE}-pc-rdos - exit ;; - i*86:AROS:*:*) - echo ${UNAME_MACHINE}-pc-aros - exit ;; - x86_64:VMkernel:*:*) - echo ${UNAME_MACHINE}-unknown-esx - exit ;; -esac - -cat >&2 < in order to provide the needed -information to handle your system. - -config.guess timestamp = $timestamp - -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null` - -hostinfo = `(hostinfo) 2>/dev/null` -/bin/universe = `(/bin/universe) 2>/dev/null` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` -/bin/arch = `(/bin/arch) 2>/dev/null` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` - -UNAME_MACHINE = ${UNAME_MACHINE} -UNAME_RELEASE = ${UNAME_RELEASE} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} -EOF - -exit 1 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/libs/libdingaling/config.sub b/libs/libdingaling/config.sub deleted file mode 100644 index bba4efb805..0000000000 --- a/libs/libdingaling/config.sub +++ /dev/null @@ -1,1799 +0,0 @@ -#! /bin/sh -# Configuration validation subroutine script. -# Copyright 1992-2014 Free Software Foundation, Inc. - -timestamp='2014-09-11' - -# This file 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 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, see . -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that -# program. This Exception is an additional permission under section 7 -# of the GNU General Public License, version 3 ("GPLv3"). - - -# Please send patches with a ChangeLog entry to config-patches@gnu.org. -# -# Configuration subroutine to validate and canonicalize a configuration type. -# Supply the specified configuration type as an argument. -# If it is invalid, we print an error message on stderr and exit with code 1. -# Otherwise, we print the canonical config type on stdout and succeed. - -# You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD - -# This file is supposed to be the same for all GNU packages -# and recognize all the CPU types, system types and aliases -# that are meaningful with *any* GNU software. -# Each package is responsible for reporting which valid configurations -# it does not support. The user should be able to distinguish -# a failure to support a valid configuration from a meaningless -# configuration. - -# The goal of this file is to map all the various variations of a given -# machine specification into a single specification in the form: -# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM -# or in some cases, the newer four-part form: -# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM -# It is wrong to echo any other type of specification. - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] CPU-MFR-OPSYS - $0 [OPTION] ALIAS - -Canonicalize a configuration name. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.sub ($timestamp) - -Copyright 1992-2014 Free Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit ;; - --version | -v ) - echo "$version" ; exit ;; - --help | --h* | -h ) - echo "$usage"; exit ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" - exit 1 ;; - - *local*) - # First pass through any local machine types. - echo $1 - exit ;; - - * ) - break ;; - esac -done - -case $# in - 0) echo "$me: missing argument$help" >&2 - exit 1;; - 1) ;; - *) echo "$me: too many arguments$help" >&2 - exit 1;; -esac - -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ - linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ - knetbsd*-gnu* | netbsd*-gnu* | \ - kopensolaris*-gnu* | \ - storm-chaos* | os2-emx* | rtmk-nova*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - android-linux) - os=-linux-android - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac - -### Let's recognize common machines as not being operating systems so -### that things like config.sub decstation-3100 work. We also -### recognize some manufacturers as not being operating systems, so we -### can provide default operating systems below. -case $os in - -sun*os*) - # Prevent following clause from handling this invalid input. - ;; - -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ - -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ - -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ - -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ - -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis | -knuth | -cray | -microblaze*) - os= - basic_machine=$1 - ;; - -bluegene*) - os=-cnk - ;; - -sim | -cisco | -oki | -wec | -winbond) - os= - basic_machine=$1 - ;; - -scout) - ;; - -wrs) - os=-vxworks - basic_machine=$1 - ;; - -chorusos*) - os=-chorusos - basic_machine=$1 - ;; - -chorusrdb) - os=-chorusrdb - basic_machine=$1 - ;; - -hiux*) - os=-hiuxwe2 - ;; - -sco6) - os=-sco5v6 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5) - os=-sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco4) - os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2.[4-9]*) - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2v[4-9]*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5v6*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco*) - os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -udk*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -isc) - os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -clix*) - basic_machine=clipper-intergraph - ;; - -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -lynx*178) - os=-lynxos178 - ;; - -lynx*5) - os=-lynxos5 - ;; - -lynx*) - os=-lynxos - ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` - ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` - ;; - -psos*) - os=-psos - ;; - -mint | -mint[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; -esac - -# Decode aliases for certain CPU-COMPANY combinations. -case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - 1750a | 580 \ - | a29k \ - | aarch64 | aarch64_be \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ - | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ - | am33_2.0 \ - | arc | arceb \ - | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ - | avr | avr32 \ - | be32 | be64 \ - | bfin \ - | c4x | c8051 | clipper \ - | d10v | d30v | dlx | dsp16xx \ - | epiphany \ - | fido | fr30 | frv \ - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | hexagon \ - | i370 | i860 | i960 | ia64 \ - | ip2k | iq2000 \ - | k1om \ - | le32 | le64 \ - | lm32 \ - | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ - | mips | mipsbe | mipseb | mipsel | mipsle \ - | mips16 \ - | mips64 | mips64el \ - | mips64octeon | mips64octeonel \ - | mips64orion | mips64orionel \ - | mips64r5900 | mips64r5900el \ - | mips64vr | mips64vrel \ - | mips64vr4100 | mips64vr4100el \ - | mips64vr4300 | mips64vr4300el \ - | mips64vr5000 | mips64vr5000el \ - | mips64vr5900 | mips64vr5900el \ - | mipsisa32 | mipsisa32el \ - | mipsisa32r2 | mipsisa32r2el \ - | mipsisa32r6 | mipsisa32r6el \ - | mipsisa64 | mipsisa64el \ - | mipsisa64r2 | mipsisa64r2el \ - | mipsisa64r6 | mipsisa64r6el \ - | mipsisa64sb1 | mipsisa64sb1el \ - | mipsisa64sr71k | mipsisa64sr71kel \ - | mipsr5900 | mipsr5900el \ - | mipstx39 | mipstx39el \ - | mn10200 | mn10300 \ - | moxie \ - | mt \ - | msp430 \ - | nds32 | nds32le | nds32be \ - | nios | nios2 | nios2eb | nios2el \ - | ns16k | ns32k \ - | open8 | or1k | or1knd | or32 \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle \ - | pyramid \ - | riscv32 | riscv64 \ - | rl78 | rx \ - | score \ - | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ - | sh64 | sh64le \ - | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ - | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ - | spu \ - | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ - | ubicom32 \ - | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ - | we32k \ - | x86 | xc16x | xstormy16 | xtensa \ - | z8k | z80) - basic_machine=$basic_machine-unknown - ;; - c54x) - basic_machine=tic54x-unknown - ;; - c55x) - basic_machine=tic55x-unknown - ;; - c6x) - basic_machine=tic6x-unknown - ;; - m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) - basic_machine=$basic_machine-unknown - os=-none - ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) - ;; - ms1) - basic_machine=mt-unknown - ;; - - strongarm | thumb | xscale) - basic_machine=arm-unknown - ;; - xgate) - basic_machine=$basic_machine-unknown - os=-none - ;; - xscaleeb) - basic_machine=armeb-unknown - ;; - - xscaleel) - basic_machine=armel-unknown - ;; - - # We use `pc' rather than `unknown' - # because (1) that's what they normally are, and - # (2) the word "unknown" tends to confuse beginning users. - i*86 | x86_64) - basic_machine=$basic_machine-pc - ;; - # Object if more than one company name word. - *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; - # Recognize the basic CPU types with company name. - 580-* \ - | a29k-* \ - | aarch64-* | aarch64_be-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ - | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ - | avr-* | avr32-* \ - | be32-* | be64-* \ - | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* \ - | c8051-* | clipper-* | craynv-* | cydra-* \ - | d10v-* | d30v-* | dlx-* \ - | elxsi-* \ - | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ - | h8300-* | h8500-* \ - | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | hexagon-* \ - | i*86-* | i860-* | i960-* | ia64-* \ - | ip2k-* | iq2000-* \ - | k1om-* \ - | le32-* | le64-* \ - | lm32-* \ - | m32c-* | m32r-* | m32rle-* \ - | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ - | microblaze-* | microblazeel-* \ - | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ - | mips16-* \ - | mips64-* | mips64el-* \ - | mips64octeon-* | mips64octeonel-* \ - | mips64orion-* | mips64orionel-* \ - | mips64r5900-* | mips64r5900el-* \ - | mips64vr-* | mips64vrel-* \ - | mips64vr4100-* | mips64vr4100el-* \ - | mips64vr4300-* | mips64vr4300el-* \ - | mips64vr5000-* | mips64vr5000el-* \ - | mips64vr5900-* | mips64vr5900el-* \ - | mipsisa32-* | mipsisa32el-* \ - | mipsisa32r2-* | mipsisa32r2el-* \ - | mipsisa32r6-* | mipsisa32r6el-* \ - | mipsisa64-* | mipsisa64el-* \ - | mipsisa64r2-* | mipsisa64r2el-* \ - | mipsisa64r6-* | mipsisa64r6el-* \ - | mipsisa64sb1-* | mipsisa64sb1el-* \ - | mipsisa64sr71k-* | mipsisa64sr71kel-* \ - | mipsr5900-* | mipsr5900el-* \ - | mipstx39-* | mipstx39el-* \ - | mmix-* \ - | mt-* \ - | msp430-* \ - | nds32-* | nds32le-* | nds32be-* \ - | nios-* | nios2-* | nios2eb-* | nios2el-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ - | open8-* \ - | or1k*-* \ - | orion-* \ - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ - | pyramid-* \ - | rl78-* | romp-* | rs6000-* | rx-* \ - | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ - | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ - | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ - | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ - | tahoe-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ - | tile*-* \ - | tron-* \ - | ubicom32-* \ - | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ - | vax-* \ - | we32k-* \ - | x86-* | x86_64-* | xc16x-* | xps100-* \ - | xstormy16-* | xtensa*-* \ - | ymp-* \ - | z8k-* | z80-*) - ;; - # Recognize the basic CPU types without company name, with glob match. - xtensa*) - basic_machine=$basic_machine-unknown - ;; - # Recognize the various machine names and aliases which stand - # for a CPU type and a company and sometimes even an OS. - 386bsd) - basic_machine=i386-unknown - os=-bsd - ;; - 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att - ;; - 3b*) - basic_machine=we32k-att - ;; - a29khif) - basic_machine=a29k-amd - os=-udi - ;; - abacus) - basic_machine=abacus-unknown - ;; - adobe68k) - basic_machine=m68010-adobe - os=-scout - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; - amd64) - basic_machine=x86_64-pc - ;; - amd64-*) - basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; - amiga | amiga-*) - basic_machine=m68k-unknown - ;; - amigaos | amigados) - basic_machine=m68k-unknown - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-unknown - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - apollo68bsd) - basic_machine=m68k-apollo - os=-bsd - ;; - aros) - basic_machine=i386-pc - os=-aros - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - blackfin) - basic_machine=bfin-unknown - os=-linux - ;; - blackfin-*) - basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - bluegene*) - basic_machine=powerpc-ibm - os=-cnk - ;; - c54x-*) - basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c55x-*) - basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c6x-*) - basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c90) - basic_machine=c90-cray - os=-unicos - ;; - cegcc) - basic_machine=arm-unknown - os=-cegcc - ;; - convex-c1) - basic_machine=c1-convex - os=-bsd - ;; - convex-c2) - basic_machine=c2-convex - os=-bsd - ;; - convex-c32) - basic_machine=c32-convex - os=-bsd - ;; - convex-c34) - basic_machine=c34-convex - os=-bsd - ;; - convex-c38) - basic_machine=c38-convex - os=-bsd - ;; - cray | j90) - basic_machine=j90-cray - os=-unicos - ;; - craynv) - basic_machine=craynv-cray - os=-unicosmp - ;; - cr16 | cr16-*) - basic_machine=cr16-unknown - os=-elf - ;; - crds | unos) - basic_machine=m68k-crds - ;; - crisv32 | crisv32-* | etraxfs*) - basic_machine=crisv32-axis - ;; - cris | cris-* | etrax*) - basic_machine=cris-axis - ;; - crx) - basic_machine=crx-unknown - os=-elf - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec - ;; - decsystem10* | dec10*) - basic_machine=pdp10-dec - os=-tops10 - ;; - decsystem20* | dec20*) - basic_machine=pdp10-dec - os=-tops20 - ;; - delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - dicos) - basic_machine=i686-pc - os=-dicos - ;; - djgpp) - basic_machine=i586-pc - os=-msdosdjgpp - ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx - ;; - dpx2* | dpx2*-bull) - basic_machine=m68k-bull - os=-sysv3 - ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon - ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd - ;; - encore | umax | mmax) - basic_machine=ns32k-encore - ;; - es1800 | OSE68k | ose68k | ose | OSE) - basic_machine=m68k-ericsson - os=-ose - ;; - fx2800) - basic_machine=i860-alliant - ;; - genix) - basic_machine=ns32k-ns - ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - go32) - basic_machine=i386-pc - os=-go32 - ;; - h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - h8300xray) - basic_machine=h8300-hitachi - os=-xray - ;; - h8500hms) - basic_machine=h8500-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; - hp300-*) - basic_machine=m68k-hp - ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux - ;; - hp3k9[0-9][0-9] | hp9[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp - ;; - hp9k3[2-9][0-9]) - basic_machine=m68k-hp - ;; - hp9k6[0-9][0-9] | hp6[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k7[0-79][0-9] | hp7[0-79][0-9]) - basic_machine=hppa1.1-hp - ;; - hp9k78[0-9] | hp78[0-9]) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][13679] | hp8[0-9][13679]) - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hppa-next) - os=-nextstep3 - ;; - hppaosf) - basic_machine=hppa1.1-hp - os=-osf - ;; - hppro) - basic_machine=hppa1.1-hp - os=-proelf - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm - ;; - i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 - ;; - i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 - ;; - i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv - ;; - i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 - ;; - i386mach) - basic_machine=i386-mach - os=-mach - ;; - i386-vsta | vsta) - basic_machine=i386-unknown - os=-vsta - ;; - iris | iris4d) - basic_machine=mips-sgi - case $os in - -irix*) - ;; - *) - os=-irix4 - ;; - esac - ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - m68knommu) - basic_machine=m68k-unknown - os=-linux - ;; - m68knommu-*) - basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - microblaze*) - basic_machine=microblaze-xilinx - ;; - mingw64) - basic_machine=x86_64-pc - os=-mingw64 - ;; - mingw32) - basic_machine=i686-pc - os=-mingw32 - ;; - mingw32ce) - basic_machine=arm-unknown - os=-mingw32ce - ;; - miniframe) - basic_machine=m68000-convergent - ;; - *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; - mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; - monitor) - basic_machine=m68k-rom68k - os=-coff - ;; - morphos) - basic_machine=powerpc-unknown - os=-morphos - ;; - moxiebox) - basic_machine=moxie-unknown - os=-moxiebox - ;; - msdos) - basic_machine=i386-pc - os=-msdos - ;; - ms1-*) - basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` - ;; - msys) - basic_machine=i686-pc - os=-msys - ;; - mvs) - basic_machine=i370-ibm - os=-mvs - ;; - nacl) - basic_machine=le32-unknown - os=-nacl - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - netbsd386) - basic_machine=i386-unknown - os=-netbsd - ;; - netwinder) - basic_machine=armv4l-rebel - os=-linux - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos - ;; - news-3600 | risc-news) - basic_machine=mips-sony - os=-newsos - ;; - necv70) - basic_machine=v70-nec - os=-sysv - ;; - next | m*-next ) - basic_machine=m68k-next - case $os in - -nextstep* ) - ;; - -ns2*) - os=-nextstep2 - ;; - *) - os=-nextstep3 - ;; - esac - ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - mon960) - basic_machine=i960-intel - os=-mon960 - ;; - nonstopux) - basic_machine=mips-compaq - os=-nonstopux - ;; - np1) - basic_machine=np1-gould - ;; - neo-tandem) - basic_machine=neo-tandem - ;; - nse-tandem) - basic_machine=nse-tandem - ;; - nsr-tandem) - basic_machine=nsr-tandem - ;; - op50n-* | op60c-*) - basic_machine=hppa1.1-oki - os=-proelf - ;; - openrisc | openrisc-*) - basic_machine=or32-unknown - ;; - os400) - basic_machine=powerpc-ibm - os=-os400 - ;; - OSE68000 | ose68000) - basic_machine=m68000-ericsson - os=-ose - ;; - os68k) - basic_machine=m68k-none - os=-os68k - ;; - pa-hitachi) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - parisc) - basic_machine=hppa-unknown - os=-linux - ;; - parisc-*) - basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - pbd) - basic_machine=sparc-tti - ;; - pbb) - basic_machine=m68k-tti - ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 - ;; - pc98) - basic_machine=i386-pc - ;; - pc98-*) - basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium | p5 | k5 | k6 | nexgen | viac3) - basic_machine=i586-pc - ;; - pentiumpro | p6 | 6x86 | athlon | athlon_*) - basic_machine=i686-pc - ;; - pentiumii | pentium2 | pentiumiii | pentium3) - basic_machine=i686-pc - ;; - pentium4) - basic_machine=i786-pc - ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium4-*) - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pn) - basic_machine=pn-gould - ;; - power) basic_machine=power-ibm - ;; - ppc | ppcbe) basic_machine=powerpc-unknown - ;; - ppc-* | ppcbe-*) - basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppcle | powerpclittle | ppc-le | powerpc-little) - basic_machine=powerpcle-unknown - ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64) basic_machine=powerpc64-unknown - ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) - basic_machine=powerpc64le-unknown - ;; - ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ps2) - basic_machine=i386-ibm - ;; - pw32) - basic_machine=i586-unknown - os=-pw32 - ;; - rdos | rdos64) - basic_machine=x86_64-pc - os=-rdos - ;; - rdos32) - basic_machine=i386-pc - os=-rdos - ;; - rom68k) - basic_machine=m68k-rom68k - os=-coff - ;; - rm[46]00) - basic_machine=mips-siemens - ;; - rtpc | rtpc-*) - basic_machine=romp-ibm - ;; - s390 | s390-*) - basic_machine=s390-ibm - ;; - s390x | s390x-*) - basic_machine=s390x-ibm - ;; - sa29200) - basic_machine=a29k-amd - os=-udi - ;; - sb1) - basic_machine=mipsisa64sb1-unknown - ;; - sb1el) - basic_machine=mipsisa64sb1el-unknown - ;; - sde) - basic_machine=mipsisa32-sde - os=-elf - ;; - sei) - basic_machine=mips-sei - os=-seiux - ;; - sequent) - basic_machine=i386-sequent - ;; - sh) - basic_machine=sh-hitachi - os=-hms - ;; - sh5el) - basic_machine=sh5le-unknown - ;; - sh64) - basic_machine=sh64-unknown - ;; - sparclite-wrs | simso-wrs) - basic_machine=sparclite-wrs - os=-vxworks - ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 - ;; - spur) - basic_machine=spur-unknown - ;; - st2000) - basic_machine=m68k-tandem - ;; - stratus) - basic_machine=i860-stratus - os=-sysv4 - ;; - strongarm-* | thumb-*) - basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - sun2) - basic_machine=m68000-sun - ;; - sun2os3) - basic_machine=m68000-sun - os=-sunos3 - ;; - sun2os4) - basic_machine=m68000-sun - os=-sunos4 - ;; - sun3os3) - basic_machine=m68k-sun - os=-sunos3 - ;; - sun3os4) - basic_machine=m68k-sun - os=-sunos4 - ;; - sun4os3) - basic_machine=sparc-sun - os=-sunos3 - ;; - sun4os4) - basic_machine=sparc-sun - os=-sunos4 - ;; - sun4sol2) - basic_machine=sparc-sun - os=-solaris2 - ;; - sun3 | sun3-*) - basic_machine=m68k-sun - ;; - sun4) - basic_machine=sparc-sun - ;; - sun386 | sun386i | roadrunner) - basic_machine=i386-sun - ;; - sv1) - basic_machine=sv1-cray - os=-unicos - ;; - symmetry) - basic_machine=i386-sequent - os=-dynix - ;; - t3e) - basic_machine=alphaev5-cray - os=-unicos - ;; - t90) - basic_machine=t90-cray - os=-unicos - ;; - tile*) - basic_machine=$basic_machine-unknown - os=-linux-gnu - ;; - tx39) - basic_machine=mipstx39-unknown - ;; - tx39el) - basic_machine=mipstx39el-unknown - ;; - toad1) - basic_machine=pdp10-xkl - os=-tops20 - ;; - tower | tower-32) - basic_machine=m68k-ncr - ;; - tpf) - basic_machine=s390x-ibm - os=-tpf - ;; - udi29k) - basic_machine=a29k-amd - os=-udi - ;; - ultra3) - basic_machine=a29k-nyu - os=-sym1 - ;; - v810 | necv810) - basic_machine=v810-nec - os=-none - ;; - vaxv) - basic_machine=vax-dec - os=-sysv - ;; - vms) - basic_machine=vax-dec - os=-vms - ;; - vpp*|vx|vx-*) - basic_machine=f301-fujitsu - ;; - vxworks960) - basic_machine=i960-wrs - os=-vxworks - ;; - vxworks68) - basic_machine=m68k-wrs - os=-vxworks - ;; - vxworks29k) - basic_machine=a29k-wrs - os=-vxworks - ;; - w65*) - basic_machine=w65-wdc - os=-none - ;; - w89k-*) - basic_machine=hppa1.1-winbond - os=-proelf - ;; - xbox) - basic_machine=i686-pc - os=-mingw32 - ;; - xps | xps100) - basic_machine=xps100-honeywell - ;; - xscale-* | xscalee[bl]-*) - basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` - ;; - ymp) - basic_machine=ymp-cray - os=-unicos - ;; - z8k-*-coff) - basic_machine=z8k-unknown - os=-sim - ;; - z80-*-coff) - basic_machine=z80-unknown - os=-sim - ;; - none) - basic_machine=none-none - os=-none - ;; - -# Here we handle the default manufacturer of certain CPU types. It is in -# some cases the only manufacturer, in others, it is the most popular. - w89k) - basic_machine=hppa1.1-winbond - ;; - op50n) - basic_machine=hppa1.1-oki - ;; - op60c) - basic_machine=hppa1.1-oki - ;; - romp) - basic_machine=romp-ibm - ;; - mmix) - basic_machine=mmix-knuth - ;; - rs6000) - basic_machine=rs6000-ibm - ;; - vax) - basic_machine=vax-dec - ;; - pdp10) - # there are many clones, so DEC is not a safe bet - basic_machine=pdp10-unknown - ;; - pdp11) - basic_machine=pdp11-dec - ;; - we32k) - basic_machine=we32k-att - ;; - sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) - basic_machine=sh-unknown - ;; - sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) - basic_machine=sparc-sun - ;; - cydra) - basic_machine=cydra-cydrome - ;; - orion) - basic_machine=orion-highlevel - ;; - orion105) - basic_machine=clipper-highlevel - ;; - mac | mpw | mac-mpw) - basic_machine=m68k-apple - ;; - pmac | pmac-mpw) - basic_machine=powerpc-apple - ;; - *-unknown) - # Make sure to match an already-canonicalized machine name. - ;; - *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; -esac - -# Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` - ;; - *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` - ;; - *) - ;; -esac - -# Decode manufacturer-specific aliases for certain operating systems. - -if [ x"$os" != x"" ] -then -case $os in - # First match some system type aliases - # that might get confused with valid system types. - # -solaris* is a basic system type, with this one exception. - -auroraux) - os=-auroraux - ;; - -solaris1 | -solaris1.*) - os=`echo $os | sed -e 's|solaris1|sunos4|'` - ;; - -solaris) - os=-solaris2 - ;; - -svr4*) - os=-sysv4 - ;; - -unixware*) - os=-sysv4.2uw - ;; - -gnu/linux*) - os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` - ;; - # First accept the basic system types. - # The portable systems comes first. - # Each alternative MUST END IN A *, to match a version number. - # -sysv* is not here because it comes later, after sysvr4. - -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ - | -sym* | -kopensolaris* | -plan9* \ - | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* | -aros* \ - | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ - | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ - | -bitrig* | -openbsd* | -solidbsd* \ - | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ - | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ - | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* | -cegcc* \ - | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ - | -linux-newlib* | -linux-musl* | -linux-uclibc* \ - | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ - | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ - | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ - | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ - | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ - | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ - | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; - -qnx*) - case $basic_machine in - x86-* | i*86-*) - ;; - *) - os=-nto$os - ;; - esac - ;; - -nto-qnx*) - ;; - -nto*) - os=`echo $os | sed -e 's|nto|nto-qnx|'` - ;; - -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ - | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) - ;; - -mac*) - os=`echo $os | sed -e 's|mac|macos|'` - ;; - -linux-dietlibc) - os=-linux-dietlibc - ;; - -linux*) - os=`echo $os | sed -e 's|linux|linux-gnu|'` - ;; - -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` - ;; - -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` - ;; - -opened*) - os=-openedition - ;; - -os400*) - os=-os400 - ;; - -wince*) - os=-wince - ;; - -osfrose*) - os=-osfrose - ;; - -osf*) - os=-osf - ;; - -utek*) - os=-bsd - ;; - -dynix*) - os=-bsd - ;; - -acis*) - os=-aos - ;; - -atheos*) - os=-atheos - ;; - -syllable*) - os=-syllable - ;; - -386bsd) - os=-bsd - ;; - -ctix* | -uts*) - os=-sysv - ;; - -nova*) - os=-rtmk-nova - ;; - -ns2 ) - os=-nextstep2 - ;; - -nsk*) - os=-nsk - ;; - # Preserve the version number of sinix5. - -sinix5.*) - os=`echo $os | sed -e 's|sinix|sysv|'` - ;; - -sinix*) - os=-sysv4 - ;; - -tpf*) - os=-tpf - ;; - -triton*) - os=-sysv3 - ;; - -oss*) - os=-sysv3 - ;; - -svr4) - os=-sysv4 - ;; - -svr3) - os=-sysv3 - ;; - -sysvr4) - os=-sysv4 - ;; - # This must come after -sysvr4. - -sysv*) - ;; - -ose*) - os=-ose - ;; - -es1800*) - os=-ose - ;; - -xenix) - os=-xenix - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - os=-mint - ;; - -aros*) - os=-aros - ;; - -zvmoe) - os=-zvmoe - ;; - -dicos*) - os=-dicos - ;; - -nacl*) - ;; - -none) - ;; - *) - # Get rid of the `-' at the beginning of $os. - os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 - exit 1 - ;; -esac -else - -# Here we handle the default operating systems that come with various machines. -# The value should be what the vendor currently ships out the door with their -# machine or put another way, the most popular os provided with the machine. - -# Note that if you're going to try to match "-MANUFACTURER" here (say, -# "-sun"), then you have to tell the case statement up towards the top -# that MANUFACTURER isn't an operating system. Otherwise, code above -# will signal an error saying that MANUFACTURER isn't an operating -# system, and we'll never get to this point. - -case $basic_machine in - score-*) - os=-elf - ;; - spu-*) - os=-elf - ;; - *-acorn) - os=-riscix1.2 - ;; - arm*-rebel) - os=-linux - ;; - arm*-semi) - os=-aout - ;; - c4x-* | tic4x-*) - os=-coff - ;; - c8051-*) - os=-elf - ;; - hexagon-*) - os=-elf - ;; - tic54x-*) - os=-coff - ;; - tic55x-*) - os=-coff - ;; - tic6x-*) - os=-coff - ;; - # This must come before the *-dec entry. - pdp10-*) - os=-tops20 - ;; - pdp11-*) - os=-none - ;; - *-dec | vax-*) - os=-ultrix4.2 - ;; - m68*-apollo) - os=-domain - ;; - i386-sun) - os=-sunos4.0.2 - ;; - m68000-sun) - os=-sunos3 - ;; - m68*-cisco) - os=-aout - ;; - mep-*) - os=-elf - ;; - mips*-cisco) - os=-elf - ;; - mips*-*) - os=-elf - ;; - or32-*) - os=-coff - ;; - *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 - ;; - sparc-* | *-sun) - os=-sunos4.1.1 - ;; - *-be) - os=-beos - ;; - *-haiku) - os=-haiku - ;; - *-ibm) - os=-aix - ;; - *-knuth) - os=-mmixware - ;; - *-wec) - os=-proelf - ;; - *-winbond) - os=-proelf - ;; - *-oki) - os=-proelf - ;; - *-hp) - os=-hpux - ;; - *-hitachi) - os=-hiux - ;; - i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv - ;; - *-cbm) - os=-amigaos - ;; - *-dg) - os=-dgux - ;; - *-dolphin) - os=-sysv3 - ;; - m68k-ccur) - os=-rtu - ;; - m88k-omron*) - os=-luna - ;; - *-next ) - os=-nextstep - ;; - *-sequent) - os=-ptx - ;; - *-crds) - os=-unos - ;; - *-ns) - os=-genix - ;; - i370-*) - os=-mvs - ;; - *-next) - os=-nextstep3 - ;; - *-gould) - os=-sysv - ;; - *-highlevel) - os=-bsd - ;; - *-encore) - os=-bsd - ;; - *-sgi) - os=-irix - ;; - *-siemens) - os=-sysv4 - ;; - *-masscomp) - os=-rtu - ;; - f30[01]-fujitsu | f700-fujitsu) - os=-uxpv - ;; - *-rom68k) - os=-coff - ;; - *-*bug) - os=-coff - ;; - *-apple) - os=-macos - ;; - *-atari*) - os=-mint - ;; - *) - os=-none - ;; -esac -fi - -# Here we handle the case where we know the os, and the CPU type, but not the -# manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) - case $os in - -riscix*) - vendor=acorn - ;; - -sunos*) - vendor=sun - ;; - -cnk*|-aix*) - vendor=ibm - ;; - -beos*) - vendor=be - ;; - -hpux*) - vendor=hp - ;; - -mpeix*) - vendor=hp - ;; - -hiux*) - vendor=hitachi - ;; - -unos*) - vendor=crds - ;; - -dgux*) - vendor=dg - ;; - -luna*) - vendor=omron - ;; - -genix*) - vendor=ns - ;; - -mvs* | -opened*) - vendor=ibm - ;; - -os400*) - vendor=ibm - ;; - -ptx*) - vendor=sequent - ;; - -tpf*) - vendor=ibm - ;; - -vxsim* | -vxworks* | -windiss*) - vendor=wrs - ;; - -aux*) - vendor=apple - ;; - -hms*) - vendor=hitachi - ;; - -mpw* | -macos*) - vendor=apple - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - vendor=atari - ;; - -vos*) - vendor=stratus - ;; - esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` - ;; -esac - -echo $basic_machine$os -exit - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/libs/libdingaling/configure.ac b/libs/libdingaling/configure.ac deleted file mode 100755 index 0d7e832fa1..0000000000 --- a/libs/libdingaling/configure.ac +++ /dev/null @@ -1,149 +0,0 @@ -# -*- Autoconf -*- -# Process this file with autoconf to produce a configure script. - - -AC_INIT(libdingaling, 0.1) -AC_CONFIG_AUX_DIR(build) -AM_INIT_AUTOMAKE -AC_CONFIG_SRCDIR([src]) -AC_CONFIG_HEADERS([src/config.h]) - -CFLAGS="$CFLAGS $CONFIGURE_CFLAGS" -CXXFLAGS="$CXXFLAGS $CONFIGURE_CXXFLAGS" -LDFLAGS="$LDFLAGS $CONFIGURE_LDFLAGS" - -#Set default language -AC_LANG_C -# Checks for programs. -AC_PROG_CC -AC_PROG_MAKE_SET -AC_PROG_LIBTOOL -AC_PROG_INSTALL - -#Check for compiler vendor -AX_COMPILER_VENDOR - -# Optimize -AC_ARG_ENABLE(optimization, -[AC_HELP_STRING([--enable-optimization],[Set if you want us to add max optimising compiler flags])],[enable_optimizer="$enableval"],[enable_optimizer="no"]) - -if test "${enable_optimizer}" = "yes" ; then - AC_DEFINE([OPTIMZER],[],[Enable Optimization.]) - AX_CC_MAXOPT -fi - -# Enable debugging -AC_ARG_ENABLE(debug, -[AC_HELP_STRING([--enable-debug],[build with debug information])],[enable_debug="$enable_debug"],[enable_debug="yes"]) - -if test "${enable_debug}" = "yes"; then - AC_DEFINE([DEBUG],[],[Enable extra debugging.]) - AX_CFLAGS_WARN_ALL_ANSI -fi - -AM_CONDITIONAL([WANT_DEBUG],[test "${enable_debug}" = "yes"]) - - -case "$host" in - *-solaris2*) - if test "x${ax_cv_c_compiler_vendor}" = "xsun" ; then - SOLINK="-Bdynamic -dy -G" - new_AM_CFLAGS="-KPIC -DPIC" - new_AM_LDFLAGS="-R${prefix}/lib" - FUNC_DEF=__func__ - IN_LINE="" - elif test "x${ax_cv_c_compiler_vendor}" = "xgnu" ; then - SOLINK="-Bdynamic -dy -G" - new_AM_CFLAGS="-fPIC" - new_AM_LDFLAGS="" - IN_LINE=inline - fi - ;; - *-darwin*) - if test "x${ax_cv_c_compiler_vendor}"="xgnu" ; then - SOLINK="-dynamic -bundle -force-flat-namespace" - new_AM_CFLAGS="-DMACOSX" - new_AM_LDFLAGS="" - fi - IN_LINE=inline - ;; - x86_64-*-linux-gnu) - if test "x${ax_cv_c_compiler_vendor}" = "xsun" ; then - SOLINK="-Bdynamic -dy -G" - new_AM_CFLAGS="-KPIC -DPIC" - new_AM_LDFLAGS="-R${prefix}/lib" - FUNC_DEF=__func__ - elif test "x${ax_cv_c_compiler_vendor}"="xgnu" ; then - SOLINK="-shared -Xlinker -x" - new_AM_CFLAGS="-fPIC" - new_AM_LDFLAGS="" - fi - IN_LINE=inline - ;; - i*6-*-linux-gnu) - if test "x${ax_cv_c_compiler_vendor}" = "xsun" ; then - SOLINK="-Bdynamic -dy -G" - new_AM_CFLAGS="-KPIC -DPIC" - new_AM_LDFLAGS="-R${prefix}/lib" - FUNC_DEF=__func__ - elif test "x${ax_cv_c_compiler_vendor}"="xgnu" ; then - SOLINK="-shared -Xlinker -x" - new_AM_CFLAGS="-fpic" - new_AM_LDFLAGS="" - fi - IN_LINE=inline - ;; - *) - if test "x${ax_cv_c_compiler_vendor}" = "xsun" ; then - SOLINK="-Bdynamic -dy -G" - new_AM_CFLAGS="-KPIC -DPIC" - new_AM_LDFLAGS="-R${prefix}/lib" - FUNC_DEF=__func__ - elif test "x${ax_cv_c_compiler_vendor}"="xgnu" ; then - SOLINK="-shared -Xlinker -x" - new_AM_CFLAGS="-fPIC" - new_AM_LDFLAGS="" - fi - IN_LINE=inline -esac - -# Enable 64 bit build -AC_ARG_ENABLE(64, -[AC_HELP_STRING([--enable-64],[build with 64 bit support])],[enable_64="$enable_64"],[enable_64="no"]) - -if test "x${ax_cv_c_compiler_vendor}" = "xsun" ; then - if test "${enable_64}" = "yes"; then - new_AM_CFLAGS="$new_AM_CFLAGS -m64" - fi -fi - -AC_SUBST(new_AM_CFLAGS) -AC_SUBST(new_AM_LDFLAGS) -AC_SUBST(SOLINK) -AC_DEFINE_UNQUOTED([__inline__],[$IN_LINE],[sunpro is bad at inline]) - -# Checks for header files. -AC_HEADER_DIRENT -AC_HEADER_STDC -#AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h stdlib.h string.h sys/ioctl.h sys/socket.h sys/time.h unistd.h]) - -# Checks for typedefs, structures, and compiler characteristics. -AC_C_CONST -AC_C_INLINE -AC_TYPE_SIZE_T -AC_HEADER_TIME -AC_STRUCT_TM - -# Checks for library functions. -AC_PROG_GCC_TRADITIONAL -AC_TYPE_SIGNAL -AC_FUNC_STRFTIME -#AC_CHECK_FUNCS([gethostname gettimeofday localtime_r memmove memset socket strcasecmp strchr strdup strncasecmp strstr]) - -AC_C_BIGENDIAN(AC_DEFINE([__BYTE_ORDER],__BIG_ENDIAN,[Big Endian]),AC_DEFINE([__BYTE_ORDER],__LITTLE_ENDIAN,[Little Endian])) -AC_DEFINE([__LITTLE_ENDIAN],1234,[for the places where it is not defined]) -AC_DEFINE([__BIG_ENDIAN],4321,[for the places where it is not defined]) - -AC_CONFIG_FILES([Makefile]) - -AC_OUTPUT diff --git a/libs/libdingaling/configure.gnu b/libs/libdingaling/configure.gnu deleted file mode 100644 index 53c204581f..0000000000 --- a/libs/libdingaling/configure.gnu +++ /dev/null @@ -1,4 +0,0 @@ -#! /bin/sh -srcpath=$(dirname $0 2>/dev/null ) || srcpath="." -$srcpath/configure "$@" --disable-shared - diff --git a/libs/libdingaling/depcomp b/libs/libdingaling/depcomp deleted file mode 100644 index 04701da536..0000000000 --- a/libs/libdingaling/depcomp +++ /dev/null @@ -1,530 +0,0 @@ -#! /bin/sh -# depcomp - compile a program generating dependencies as side-effects - -scriptversion=2005-07-09.11 - -# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, 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, or (at your option) -# any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -# 02110-1301, USA. - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Originally written by Alexandre Oliva . - -case $1 in - '') - echo "$0: No command. Try \`$0 --help' for more information." 1>&2 - exit 1; - ;; - -h | --h*) - cat <<\EOF -Usage: depcomp [--help] [--version] PROGRAM [ARGS] - -Run PROGRAMS ARGS to compile a file, generating dependencies -as side-effects. - -Environment variables: - depmode Dependency tracking mode. - source Source file read by `PROGRAMS ARGS'. - object Object file output by `PROGRAMS ARGS'. - DEPDIR directory where to store dependencies. - depfile Dependency file to output. - tmpdepfile Temporary file to use when outputing dependencies. - libtool Whether libtool is used (yes/no). - -Report bugs to . -EOF - exit $? - ;; - -v | --v*) - echo "depcomp $scriptversion" - exit $? - ;; -esac - -if test -z "$depmode" || test -z "$source" || test -z "$object"; then - echo "depcomp: Variables source, object and depmode must be set" 1>&2 - exit 1 -fi - -# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. -depfile=${depfile-`echo "$object" | - sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} -tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} - -rm -f "$tmpdepfile" - -# Some modes work just like other modes, but use different flags. We -# parameterize here, but still list the modes in the big case below, -# to make depend.m4 easier to write. Note that we *cannot* use a case -# here, because this file can only contain one case statement. -if test "$depmode" = hp; then - # HP compiler uses -M and no extra arg. - gccflag=-M - depmode=gcc -fi - -if test "$depmode" = dashXmstdout; then - # This is just like dashmstdout with a different argument. - dashmflag=-xM - depmode=dashmstdout -fi - -case "$depmode" in -gcc3) -## gcc 3 implements dependency tracking that does exactly what -## we want. Yay! Note: for some reason libtool 1.4 doesn't like -## it if -MD -MP comes after the -MF stuff. Hmm. - "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - mv "$tmpdepfile" "$depfile" - ;; - -gcc) -## There are various ways to get dependency output from gcc. Here's -## why we pick this rather obscure method: -## - Don't want to use -MD because we'd like the dependencies to end -## up in a subdir. Having to rename by hand is ugly. -## (We might end up doing this anyway to support other compilers.) -## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like -## -MM, not -M (despite what the docs say). -## - Using -M directly means running the compiler twice (even worse -## than renaming). - if test -z "$gccflag"; then - gccflag=-MD, - fi - "$@" -Wp,"$gccflag$tmpdepfile" - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - echo "$object : \\" > "$depfile" - alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz -## The second -e expression handles DOS-style file names with drive letters. - sed -e 's/^[^:]*: / /' \ - -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" -## This next piece of magic avoids the `deleted header file' problem. -## The problem is that when a header file which appears in a .P file -## is deleted, the dependency causes make to die (because there is -## typically no way to rebuild the header). We avoid this by adding -## dummy dependencies for each header file. Too bad gcc doesn't do -## this for us directly. - tr ' ' ' -' < "$tmpdepfile" | -## Some versions of gcc put a space before the `:'. On the theory -## that the space means something, we add a space to the output as -## well. -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -hp) - # This case exists only to let depend.m4 do its work. It works by - # looking at the text of this script. This case will never be run, - # since it is checked for above. - exit 1 - ;; - -sgi) - if test "$libtool" = yes; then - "$@" "-Wp,-MDupdate,$tmpdepfile" - else - "$@" -MDupdate "$tmpdepfile" - fi - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - - if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files - echo "$object : \\" > "$depfile" - - # Clip off the initial element (the dependent). Don't try to be - # clever and replace this with sed code, as IRIX sed won't handle - # lines with more than a fixed number of characters (4096 in - # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; - # the IRIX cc adds comments like `#:fec' to the end of the - # dependency line. - tr ' ' ' -' < "$tmpdepfile" \ - | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ - tr ' -' ' ' >> $depfile - echo >> $depfile - - # The second pass generates a dummy entry for each header file. - tr ' ' ' -' < "$tmpdepfile" \ - | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ - >> $depfile - else - # The sourcefile does not contain any dependencies, so just - # store a dummy comment line, to avoid errors with the Makefile - # "include basename.Plo" scheme. - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; - -aix) - # The C for AIX Compiler uses -M and outputs the dependencies - # in a .u file. In older versions, this file always lives in the - # current directory. Also, the AIX compiler puts `$object:' at the - # start of each line; $object doesn't have directory information. - # Version 6 uses the directory in both cases. - stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'` - tmpdepfile="$stripped.u" - if test "$libtool" = yes; then - "$@" -Wc,-M - else - "$@" -M - fi - stat=$? - - if test -f "$tmpdepfile"; then : - else - stripped=`echo "$stripped" | sed 's,^.*/,,'` - tmpdepfile="$stripped.u" - fi - - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - - if test -f "$tmpdepfile"; then - outname="$stripped.o" - # Each line is of the form `foo.o: dependent.h'. - # Do two passes, one to just change these to - # `$object: dependent.h' and one to simply `dependent.h:'. - sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" - sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" - else - # The sourcefile does not contain any dependencies, so just - # store a dummy comment line, to avoid errors with the Makefile - # "include basename.Plo" scheme. - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; - -icc) - # Intel's C compiler understands `-MD -MF file'. However on - # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c - # ICC 7.0 will fill foo.d with something like - # foo.o: sub/foo.c - # foo.o: sub/foo.h - # which is wrong. We want: - # sub/foo.o: sub/foo.c - # sub/foo.o: sub/foo.h - # sub/foo.c: - # sub/foo.h: - # ICC 7.1 will output - # foo.o: sub/foo.c sub/foo.h - # and will wrap long lines using \ : - # foo.o: sub/foo.c ... \ - # sub/foo.h ... \ - # ... - - "$@" -MD -MF "$tmpdepfile" - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - # Each line is of the form `foo.o: dependent.h', - # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. - # Do two passes, one to just change these to - # `$object: dependent.h' and one to simply `dependent.h:'. - sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" - # Some versions of the HPUX 10.20 sed can't process this invocation - # correctly. Breaking it into two sed invocations is a workaround. - sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | - sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -tru64) - # The Tru64 compiler uses -MD to generate dependencies as a side - # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. - # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put - # dependencies in `foo.d' instead, so we check for that too. - # Subdirectories are respected. - dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` - test "x$dir" = "x$object" && dir= - base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` - - if test "$libtool" = yes; then - # With Tru64 cc, shared objects can also be used to make a - # static library. This mecanism is used in libtool 1.4 series to - # handle both shared and static libraries in a single compilation. - # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. - # - # With libtool 1.5 this exception was removed, and libtool now - # generates 2 separate objects for the 2 libraries. These two - # compilations output dependencies in in $dir.libs/$base.o.d and - # in $dir$base.o.d. We have to check for both files, because - # one of the two compilations can be disabled. We should prefer - # $dir$base.o.d over $dir.libs/$base.o.d because the latter is - # automatically cleaned when .libs/ is deleted, while ignoring - # the former would cause a distcleancheck panic. - tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 - tmpdepfile2=$dir$base.o.d # libtool 1.5 - tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 - tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 - "$@" -Wc,-MD - else - tmpdepfile1=$dir$base.o.d - tmpdepfile2=$dir$base.d - tmpdepfile3=$dir$base.d - tmpdepfile4=$dir$base.d - "$@" -MD - fi - - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" - exit $stat - fi - - for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" - do - test -f "$tmpdepfile" && break - done - if test -f "$tmpdepfile"; then - sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" - # That's a tab and a space in the []. - sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" - else - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; - -#nosideeffect) - # This comment above is used by automake to tell side-effect - # dependency tracking mechanisms from slower ones. - -dashmstdout) - # Important note: in order to support this mode, a compiler *must* - # always write the preprocessed file to stdout, regardless of -o. - "$@" || exit $? - - # Remove the call to Libtool. - if test "$libtool" = yes; then - while test $1 != '--mode=compile'; do - shift - done - shift - fi - - # Remove `-o $object'. - IFS=" " - for arg - do - case $arg in - -o) - shift - ;; - $object) - shift - ;; - *) - set fnord "$@" "$arg" - shift # fnord - shift # $arg - ;; - esac - done - - test -z "$dashmflag" && dashmflag=-M - # Require at least two characters before searching for `:' - # in the target name. This is to cope with DOS-style filenames: - # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. - "$@" $dashmflag | - sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" - rm -f "$depfile" - cat < "$tmpdepfile" > "$depfile" - tr ' ' ' -' < "$tmpdepfile" | \ -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -dashXmstdout) - # This case only exists to satisfy depend.m4. It is never actually - # run, as this mode is specially recognized in the preamble. - exit 1 - ;; - -makedepend) - "$@" || exit $? - # Remove any Libtool call - if test "$libtool" = yes; then - while test $1 != '--mode=compile'; do - shift - done - shift - fi - # X makedepend - shift - cleared=no - for arg in "$@"; do - case $cleared in - no) - set ""; shift - cleared=yes ;; - esac - case "$arg" in - -D*|-I*) - set fnord "$@" "$arg"; shift ;; - # Strip any option that makedepend may not understand. Remove - # the object too, otherwise makedepend will parse it as a source file. - -*|$object) - ;; - *) - set fnord "$@" "$arg"; shift ;; - esac - done - obj_suffix="`echo $object | sed 's/^.*\././'`" - touch "$tmpdepfile" - ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" - rm -f "$depfile" - cat < "$tmpdepfile" > "$depfile" - sed '1,2d' "$tmpdepfile" | tr ' ' ' -' | \ -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" "$tmpdepfile".bak - ;; - -cpp) - # Important note: in order to support this mode, a compiler *must* - # always write the preprocessed file to stdout. - "$@" || exit $? - - # Remove the call to Libtool. - if test "$libtool" = yes; then - while test $1 != '--mode=compile'; do - shift - done - shift - fi - - # Remove `-o $object'. - IFS=" " - for arg - do - case $arg in - -o) - shift - ;; - $object) - shift - ;; - *) - set fnord "$@" "$arg" - shift # fnord - shift # $arg - ;; - esac - done - - "$@" -E | - sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ - -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | - sed '$ s: \\$::' > "$tmpdepfile" - rm -f "$depfile" - echo "$object : \\" > "$depfile" - cat < "$tmpdepfile" >> "$depfile" - sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -msvisualcpp) - # Important note: in order to support this mode, a compiler *must* - # always write the preprocessed file to stdout, regardless of -o, - # because we must use -o when running libtool. - "$@" || exit $? - IFS=" " - for arg - do - case "$arg" in - "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") - set fnord "$@" - shift - shift - ;; - *) - set fnord "$@" "$arg" - shift - shift - ;; - esac - done - "$@" -E | - sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" - rm -f "$depfile" - echo "$object : \\" > "$depfile" - . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" - echo " " >> "$depfile" - . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -none) - exec "$@" - ;; - -*) - echo "Unknown depmode $depmode" 1>&2 - exit 1 - ;; -esac - -exit 0 - -# Local Variables: -# mode: shell-script -# sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-end: "$" -# End: diff --git a/libs/libdingaling/doc b/libs/libdingaling/doc deleted file mode 100644 index ab09daa627..0000000000 --- a/libs/libdingaling/doc +++ /dev/null @@ -1 +0,0 @@ -http://iksemel.jabberstudio.org/iksemel.html diff --git a/libs/libdingaling/docs/Doxygen.conf b/libs/libdingaling/docs/Doxygen.conf deleted file mode 100644 index 8b5886ff4f..0000000000 --- a/libs/libdingaling/docs/Doxygen.conf +++ /dev/null @@ -1,264 +0,0 @@ -# Doxyfile 1.4.6 - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- -PROJECT_NAME = LibDingaLing -PROJECT_NUMBER = -OUTPUT_DIRECTORY = . -CREATE_SUBDIRS = NO -OUTPUT_LANGUAGE = English -USE_WINDOWS_ENCODING = YES -BRIEF_MEMBER_DESC = YES -REPEAT_BRIEF = YES -ABBREVIATE_BRIEF = "The $name class" \ - "The $name widget" \ - "The $name file" \ - is \ - provides \ - specifies \ - contains \ - represents \ - a \ - an \ - the -ALWAYS_DETAILED_SEC = NO -INLINE_INHERITED_MEMB = NO -FULL_PATH_NAMES = NO -STRIP_FROM_PATH = -STRIP_FROM_INC_PATH = -SHORT_NAMES = NO -JAVADOC_AUTOBRIEF = NO -MULTILINE_CPP_IS_BRIEF = NO -DETAILS_AT_TOP = NO -INHERIT_DOCS = YES -SEPARATE_MEMBER_PAGES = NO -TAB_SIZE = 8 -ALIASES = -OPTIMIZE_OUTPUT_FOR_C = YES -OPTIMIZE_OUTPUT_JAVA = NO -DISTRIBUTE_GROUP_DOC = NO -SUBGROUPING = YES -IGNORE_PREFIX = ldl_ - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- -EXTRACT_ALL = NO -EXTRACT_PRIVATE = NO -EXTRACT_STATIC = NO -EXTRACT_LOCAL_CLASSES = YES -EXTRACT_LOCAL_METHODS = NO -HIDE_UNDOC_MEMBERS = YES -HIDE_UNDOC_CLASSES = YES -HIDE_FRIEND_COMPOUNDS = NO -HIDE_IN_BODY_DOCS = NO -INTERNAL_DOCS = NO -CASE_SENSE_NAMES = NO -HIDE_SCOPE_NAMES = NO -SHOW_INCLUDE_FILES = YES -INLINE_INFO = YES -SORT_MEMBER_DOCS = YES -SORT_BRIEF_DOCS = NO -SORT_BY_SCOPE_NAME = NO -GENERATE_TODOLIST = YES -GENERATE_TESTLIST = YES -GENERATE_BUGLIST = YES -GENERATE_DEPRECATEDLIST= YES -ENABLED_SECTIONS = -MAX_INITIALIZER_LINES = 30 -SHOW_USED_FILES = YES -SHOW_DIRECTORIES = NO -FILE_VERSION_FILTER = -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- -QUIET = NO -WARNINGS = YES -WARN_IF_UNDOCUMENTED = YES -WARN_IF_DOC_ERROR = YES -WARN_NO_PARAMDOC = NO -WARN_FORMAT = "$file:$line: $text" -WARN_LOGFILE = -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- -INPUT = ../src -FILE_PATTERNS = *.c \ - *.cc \ - *.cxx \ - *.cpp \ - *.c++ \ - *.d \ - *.java \ - *.ii \ - *.ixx \ - *.ipp \ - *.i++ \ - *.inl \ - *.h \ - *.hh \ - *.hxx \ - *.hpp \ - *.h++ \ - *.idl \ - *.odl \ - *.cs \ - *.php \ - *.php3 \ - *.inc \ - *.m \ - *.mm \ - *.dox \ - *.py -RECURSIVE = NO -EXCLUDE = -EXCLUDE_SYMLINKS = NO -EXCLUDE_PATTERNS = -EXAMPLE_PATH = -EXAMPLE_PATTERNS = -EXAMPLE_RECURSIVE = NO -IMAGE_PATH = -INPUT_FILTER = -FILTER_PATTERNS = -FILTER_SOURCE_FILES = NO -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- -SOURCE_BROWSER = NO -INLINE_SOURCES = YES -STRIP_CODE_COMMENTS = YES -REFERENCED_BY_RELATION = YES -REFERENCES_RELATION = YES -USE_HTAGS = YES -VERBATIM_HEADERS = NO -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- -ALPHABETICAL_INDEX = YES -COLS_IN_ALPHA_INDEX = 1 -IGNORE_PREFIX = ldl_ -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- -GENERATE_HTML = YES -HTML_OUTPUT = html -HTML_FILE_EXTENSION = .html -HTML_HEADER = -HTML_FOOTER = -HTML_STYLESHEET = -HTML_ALIGN_MEMBERS = YES -GENERATE_HTMLHELP = NO -CHM_FILE = libDingaLing.chm -HHC_LOCATION = -GENERATE_CHI = YES -BINARY_TOC = NO -TOC_EXPAND = NO -DISABLE_INDEX = NO -ENUM_VALUES_PER_LINE = 4 -GENERATE_TREEVIEW = YES -TREEVIEW_WIDTH = 250 - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- -GENERATE_LATEX = NO -LATEX_OUTPUT = latex -LATEX_CMD_NAME = latex -MAKEINDEX_CMD_NAME = makeindex -COMPACT_LATEX = NO -PAPER_TYPE = a4wide -EXTRA_PACKAGES = -LATEX_HEADER = -PDF_HYPERLINKS = NO -USE_PDFLATEX = NO -LATEX_BATCHMODE = NO -LATEX_HIDE_INDICES = NO -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- -GENERATE_RTF = NO -RTF_OUTPUT = rtf -COMPACT_RTF = NO -RTF_HYPERLINKS = NO -RTF_STYLESHEET_FILE = -RTF_EXTENSIONS_FILE = -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- -GENERATE_MAN = YES -MAN_OUTPUT = man -MAN_EXTENSION = .3 -MAN_LINKS = NO -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- -GENERATE_XML = YES -XML_OUTPUT = xml -XML_SCHEMA = -XML_DTD = -XML_PROGRAMLISTING = YES -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- -GENERATE_AUTOGEN_DEF = NO -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- -GENERATE_PERLMOD = YES -PERLMOD_LATEX = NO -PERLMOD_PRETTY = YES -PERLMOD_MAKEVAR_PREFIX = -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- -ENABLE_PREPROCESSING = YES -MACRO_EXPANSION = YES -EXPAND_ONLY_PREDEF = NO -SEARCH_INCLUDES = NO -INCLUDE_PATH = -INCLUDE_FILE_PATTERNS = *.h -PREDEFINED = SWITCH_DECLARE(x)=x \ - APR_DECLARE(x)=x \ - DoxyDefine(x)=x - -EXPAND_AS_DEFINED = NO -SKIP_FUNCTION_MACROS = NO -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- -TAGFILES = -GENERATE_TAGFILE = -ALLEXTERNALS = NO -EXTERNAL_GROUPS = YES -PERL_PATH = /usr/bin/perl -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- -CLASS_DIAGRAMS = YES -HIDE_UNDOC_RELATIONS = YES -HAVE_DOT = YES -CLASS_GRAPH = YES -COLLABORATION_GRAPH = YES -GROUP_GRAPHS = YES -UML_LOOK = YES -TEMPLATE_RELATIONS = YES -INCLUDE_GRAPH = YES -INCLUDED_BY_GRAPH = YES -CALL_GRAPH = YES -GRAPHICAL_HIERARCHY = YES -DIRECTORY_GRAPH = YES -DOT_IMAGE_FORMAT = jpg -DOT_PATH = -DOTFILE_DIRS = -MAX_DOT_GRAPH_WIDTH = 1024 -MAX_DOT_GRAPH_HEIGHT = 1024 -MAX_DOT_GRAPH_DEPTH = 1000 -DOT_TRANSPARENT = NO -DOT_MULTI_TARGETS = NO -GENERATE_LEGEND = YES -DOT_CLEANUP = YES -#--------------------------------------------------------------------------- -# Configuration::additions related to the search engine -#--------------------------------------------------------------------------- -SEARCHENGINE = NO diff --git a/libs/libdingaling/docs/docs.vcproj b/libs/libdingaling/docs/docs.vcproj deleted file mode 100644 index be9173ec07..0000000000 --- a/libs/libdingaling/docs/docs.vcproj +++ /dev/null @@ -1,178 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/libdingaling/install-sh b/libs/libdingaling/install-sh deleted file mode 100644 index 4d4a9519ea..0000000000 --- a/libs/libdingaling/install-sh +++ /dev/null @@ -1,323 +0,0 @@ -#!/bin/sh -# install - install a program, script, or datafile - -scriptversion=2005-05-14.22 - -# This originates from X11R5 (mit/util/scripts/install.sh), which was -# later released in X11R6 (xc/config/util/install.sh) with the -# following copyright and license. -# -# Copyright (C) 1994 X Consortium -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- -# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -# Except as contained in this notice, the name of the X Consortium shall not -# be used in advertising or otherwise to promote the sale, use or other deal- -# ings in this Software without prior written authorization from the X Consor- -# tium. -# -# -# FSF changes to this file are in the public domain. -# -# Calling this script install-sh is preferred over install.sh, to prevent -# `make' implicit rules from creating a file called install from it -# when there is no Makefile. -# -# This script is compatible with the BSD install script, but was written -# from scratch. It can only install one file at a time, a restriction -# shared with many OS's install programs. - -# set DOITPROG to echo to test this script - -# Don't use :- since 4.3BSD and earlier shells don't like it. -doit="${DOITPROG-}" - -# put in absolute paths if you don't have them in your path; or use env. vars. - -mvprog="${MVPROG-mv}" -cpprog="${CPPROG-cp}" -chmodprog="${CHMODPROG-chmod}" -chownprog="${CHOWNPROG-chown}" -chgrpprog="${CHGRPPROG-chgrp}" -stripprog="${STRIPPROG-strip}" -rmprog="${RMPROG-rm}" -mkdirprog="${MKDIRPROG-mkdir}" - -chmodcmd="$chmodprog 0755" -chowncmd= -chgrpcmd= -stripcmd= -rmcmd="$rmprog -f" -mvcmd="$mvprog" -src= -dst= -dir_arg= -dstarg= -no_target_directory= - -usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE - or: $0 [OPTION]... SRCFILES... DIRECTORY - or: $0 [OPTION]... -t DIRECTORY SRCFILES... - or: $0 [OPTION]... -d DIRECTORIES... - -In the 1st form, copy SRCFILE to DSTFILE. -In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. -In the 4th, create DIRECTORIES. - -Options: --c (ignored) --d create directories instead of installing files. --g GROUP $chgrpprog installed files to GROUP. --m MODE $chmodprog installed files to MODE. --o USER $chownprog installed files to USER. --s $stripprog installed files. --t DIRECTORY install into DIRECTORY. --T report an error if DSTFILE is a directory. ---help display this help and exit. ---version display version info and exit. - -Environment variables override the default commands: - CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG -" - -while test -n "$1"; do - case $1 in - -c) shift - continue;; - - -d) dir_arg=true - shift - continue;; - - -g) chgrpcmd="$chgrpprog $2" - shift - shift - continue;; - - --help) echo "$usage"; exit $?;; - - -m) chmodcmd="$chmodprog $2" - shift - shift - continue;; - - -o) chowncmd="$chownprog $2" - shift - shift - continue;; - - -s) stripcmd=$stripprog - shift - continue;; - - -t) dstarg=$2 - shift - shift - continue;; - - -T) no_target_directory=true - shift - continue;; - - --version) echo "$0 $scriptversion"; exit $?;; - - *) # When -d is used, all remaining arguments are directories to create. - # When -t is used, the destination is already specified. - test -n "$dir_arg$dstarg" && break - # Otherwise, the last argument is the destination. Remove it from $@. - for arg - do - if test -n "$dstarg"; then - # $@ is not empty: it contains at least $arg. - set fnord "$@" "$dstarg" - shift # fnord - fi - shift # arg - dstarg=$arg - done - break;; - esac -done - -if test -z "$1"; then - if test -z "$dir_arg"; then - echo "$0: no input file specified." >&2 - exit 1 - fi - # It's OK to call `install-sh -d' without argument. - # This can happen when creating conditional directories. - exit 0 -fi - -for src -do - # Protect names starting with `-'. - case $src in - -*) src=./$src ;; - esac - - if test -n "$dir_arg"; then - dst=$src - src= - - if test -d "$dst"; then - mkdircmd=: - chmodcmd= - else - mkdircmd=$mkdirprog - fi - else - # Waiting for this to be detected by the "$cpprog $src $dsttmp" command - # might cause directories to be created, which would be especially bad - # if $src (and thus $dsttmp) contains '*'. - if test ! -f "$src" && test ! -d "$src"; then - echo "$0: $src does not exist." >&2 - exit 1 - fi - - if test -z "$dstarg"; then - echo "$0: no destination specified." >&2 - exit 1 - fi - - dst=$dstarg - # Protect names starting with `-'. - case $dst in - -*) dst=./$dst ;; - esac - - # If destination is a directory, append the input filename; won't work - # if double slashes aren't ignored. - if test -d "$dst"; then - if test -n "$no_target_directory"; then - echo "$0: $dstarg: Is a directory" >&2 - exit 1 - fi - dst=$dst/`basename "$src"` - fi - fi - - # This sed command emulates the dirname command. - dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'` - - # Make sure that the destination directory exists. - - # Skip lots of stat calls in the usual case. - if test ! -d "$dstdir"; then - defaultIFS=' - ' - IFS="${IFS-$defaultIFS}" - - oIFS=$IFS - # Some sh's can't handle IFS=/ for some reason. - IFS='%' - set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'` - shift - IFS=$oIFS - - pathcomp= - - while test $# -ne 0 ; do - pathcomp=$pathcomp$1 - shift - if test ! -d "$pathcomp"; then - $mkdirprog "$pathcomp" - # mkdir can fail with a `File exist' error in case several - # install-sh are creating the directory concurrently. This - # is OK. - test -d "$pathcomp" || exit - fi - pathcomp=$pathcomp/ - done - fi - - if test -n "$dir_arg"; then - $doit $mkdircmd "$dst" \ - && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \ - && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \ - && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \ - && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; } - - else - dstfile=`basename "$dst"` - - # Make a couple of temp file names in the proper directory. - dsttmp=$dstdir/_inst.$$_ - rmtmp=$dstdir/_rm.$$_ - - # Trap to clean up those temp files at exit. - trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 - trap '(exit $?); exit' 1 2 13 15 - - # Copy the file name to the temp name. - $doit $cpprog "$src" "$dsttmp" && - - # and set any options; do chmod last to preserve setuid bits. - # - # If any of these fail, we abort the whole thing. If we want to - # ignore errors from any of these, just make sure not to ignore - # errors from the above "$doit $cpprog $src $dsttmp" command. - # - { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \ - && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \ - && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \ - && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } && - - # Now rename the file to the real destination. - { $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \ - || { - # The rename failed, perhaps because mv can't rename something else - # to itself, or perhaps because mv is so ancient that it does not - # support -f. - - # Now remove or move aside any old file at destination location. - # We try this two ways since rm can't unlink itself on some - # systems and the destination file might be busy for other - # reasons. In this case, the final cleanup might fail but the new - # file should still install successfully. - { - if test -f "$dstdir/$dstfile"; then - $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \ - || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \ - || { - echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2 - (exit 1); exit 1 - } - else - : - fi - } && - - # Now rename the file to the real destination. - $doit $mvcmd "$dsttmp" "$dstdir/$dstfile" - } - } - fi || { (exit 1); exit 1; } -done - -# The final little trick to "correctly" pass the exit status to the exit trap. -{ - (exit 0); exit 0 -} - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-end: "$" -# End: diff --git a/libs/libdingaling/libdingaling.2008.vcproj b/libs/libdingaling/libdingaling.2008.vcproj deleted file mode 100644 index bf22a7e5e6..0000000000 --- a/libs/libdingaling/libdingaling.2008.vcproj +++ /dev/null @@ -1,621 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/libdingaling/libdingaling.2010.vcxproj.filters b/libs/libdingaling/libdingaling.2010.vcxproj.filters deleted file mode 100644 index 18ef8e8b1a..0000000000 --- a/libs/libdingaling/libdingaling.2010.vcxproj.filters +++ /dev/null @@ -1,38 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - Source Files - - - \ No newline at end of file diff --git a/libs/libdingaling/libdingaling.2017.vcxproj b/libs/libdingaling/libdingaling.2017.vcxproj deleted file mode 100644 index 899855def1..0000000000 --- a/libs/libdingaling/libdingaling.2017.vcxproj +++ /dev/null @@ -1,303 +0,0 @@ - - - - - Debug DLL - Win32 - - - Debug DLL - x64 - - - Debug - Win32 - - - Debug - x64 - - - Release DLL - Win32 - - - Release DLL - x64 - - - Release - Win32 - - - Release - x64 - - - - libdingaling - {1906D736-08BD-4EE1-924F-B536249B9A54} - libdingaling - Win32Proj - - - - DynamicLibrary - Unicode - true - $(DefaultPlatformToolset) - - - DynamicLibrary - Unicode - $(DefaultPlatformToolset) - - - StaticLibrary - Unicode - true - $(DefaultPlatformToolset) - - - StaticLibrary - Unicode - $(DefaultPlatformToolset) - - - DynamicLibrary - Unicode - true - $(DefaultPlatformToolset) - - - DynamicLibrary - Unicode - $(DefaultPlatformToolset) - - - StaticLibrary - Unicode - true - $(DefaultPlatformToolset) - - - StaticLibrary - Unicode - $(DefaultPlatformToolset) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)Debug\ - $(Configuration)\ - $(SolutionDir)Release\ - $(Configuration)\ - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - - - - Disabled - .;.\src;..\iksemel\include;..\include;..\apr\include;..\iksemel-1.2\include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Level4 - 4718;4456;4457;4701;4702;4703;4100;4706;%(DisableSpecificWarnings) - - - - - .;.\src;..\iksemel\include;..\include;..\apr\include;..\iksemel-1.2\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) - MultiThreadedDLL - Level4 - 4718;4456;4457;4701;4702;4703;4100;%(DisableSpecificWarnings) - - - - - Disabled - .;.\src;..\iksemel\include;..\include;..\apr\include;..\iksemel-1.2\include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;APR_DECLARE_STATIC;APU_DECLARE_STATIC;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level4 - EditAndContinue - 4718;4456;4457;4701;4702;4703;4100;%(DisableSpecificWarnings) - - - libapr-1.lib;libaprutil-1.lib;iksemel.lib;Ws2_32.lib;%(AdditionalDependencies) - ..\apr\Debug;..\apr-util\Debug;..\iksemel\Debug;%(AdditionalLibraryDirectories) - .\src\dingaling.def - true - false - false - false - - - - - - - .;.\src;..\iksemel\include;..\include;..\apr\include;..\iksemel-1.2\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;APR_DECLARE_STATIC;APU_DECLARE_STATIC;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level4 - ProgramDatabase - 4718;4456;4457;4701;4702;4703;4100;%(DisableSpecificWarnings) - - - libapr-1.lib;libaprutil-1.lib;iksemel.lib;Ws2_32.lib;%(AdditionalDependencies) - ..\apr\Release;..\apr-util\Release;..\iksemel\Release;%(AdditionalLibraryDirectories) - .\src\dingaling.def - false - - - - - - - X64 - - - Disabled - .;.\src;..\iksemel\include;..\include;..\apr\include;..\iksemel-1.2\include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Level4 - 4718;4456;4457;4701;4702;4703;4100;4706;%(DisableSpecificWarnings) - - - - - X64 - - - .;.\src;..\iksemel\include;..\include;..\apr\include;..\iksemel-1.2\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) - MultiThreadedDLL - Level4 - 4718;4456;4457;4701;4702;4703;4100;%(DisableSpecificWarnings) - - - - - X64 - - - Disabled - .;.\src;..\iksemel\include;..\include;..\apr\include;..\iksemel-1.2\include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;APR_DECLARE_STATIC;APU_DECLARE_STATIC;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level4 - ProgramDatabase - 4718;4456;4457;4701;4702;4703;4100;%(DisableSpecificWarnings) - - - libapr-1.lib;libaprutil-1.lib;iksemel.lib;Ws2_32.lib;%(AdditionalDependencies) - ..\apr\Debug;..\apr-util\Debug;..\iksemel\Debug;%(AdditionalLibraryDirectories) - .\src\dingaling.def - true - false - false - false - - - MachineX64 - - - - - X64 - - - .;.\src;..\iksemel\include;..\include;..\apr\include;..\iksemel-1.2\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;APR_DECLARE_STATIC;APU_DECLARE_STATIC;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level4 - ProgramDatabase - 4718;4456;4457;4701;4702;4703;4100;%(DisableSpecificWarnings) - - - libapr-1.lib;libaprutil-1.lib;iksemel.lib;Ws2_32.lib;%(AdditionalDependencies) - ..\apr\Release;..\apr-util\Release;..\iksemel\Release;%(AdditionalLibraryDirectories) - .\src\dingaling.def - false - - - MachineX64 - - - - - - - - - - - - - - - - {f057da7f-79e5-4b00-845c-ef446ef055e3} - false - - - {e727e8f6-935d-46fe-8b0e-37834748a0e3} - false - - - - - - \ No newline at end of file diff --git a/libs/libdingaling/libdingaling.vcproj b/libs/libdingaling/libdingaling.vcproj deleted file mode 100644 index 3cb660b406..0000000000 --- a/libs/libdingaling/libdingaling.vcproj +++ /dev/null @@ -1,343 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/libdingaling/ltmain.sh b/libs/libdingaling/ltmain.sh deleted file mode 100755 index 9e71d27d86..0000000000 --- a/libs/libdingaling/ltmain.sh +++ /dev/null @@ -1,6530 +0,0 @@ -# ltmain.sh - Provide generalized library-building support services. -# NOTE: Changing this file will not affect anything until you rerun configure. -# -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005 -# Free Software Foundation, Inc. -# Originally by Gordon Matzigkeit , 1996 -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -basename="s,^.*/,,g" - -# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh -# is ksh but when the shell is invoked as "sh" and the current value of -# the _XPG environment variable is not equal to 1 (one), the special -# positional parameter $0, within a function call, is the name of the -# function. -progpath="$0" - -# The name of this program: -progname=`echo "$progpath" | $SED $basename` -modename="$progname" - -# Global variables: -EXIT_SUCCESS=0 -EXIT_FAILURE=1 - -PROGRAM=ltmain.sh -PACKAGE=libtool -VERSION=1.5.20 -TIMESTAMP=" (1.1220.2.287 2005/08/31 18:54:15)" - -# See if we are running on zsh, and set the options which allow our -# commands through without removal of \ escapes. -if test -n "${ZSH_VERSION+set}" ; then - setopt NO_GLOB_SUBST -fi - -# Check that we have a working $echo. -if test "X$1" = X--no-reexec; then - # Discard the --no-reexec flag, and continue. - shift -elif test "X$1" = X--fallback-echo; then - # Avoid inline document here, it may be left over - : -elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then - # Yippee, $echo works! - : -else - # Restart under the correct shell, and then maybe $echo will work. - exec $SHELL "$progpath" --no-reexec ${1+"$@"} -fi - -if test "X$1" = X--fallback-echo; then - # used as fallback echo - shift - cat <&2 - $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 - exit $EXIT_FAILURE -fi - -# Global variables. -mode=$default_mode -nonopt= -prev= -prevopt= -run= -show="$echo" -show_help= -execute_dlfiles= -lo2o="s/\\.lo\$/.${objext}/" -o2lo="s/\\.${objext}\$/.lo/" - -##################################### -# Shell function definitions: -# This seems to be the best place for them - -# func_win32_libid arg -# return the library type of file 'arg' -# -# Need a lot of goo to handle *both* DLLs and import libs -# Has to be a shell function in order to 'eat' the argument -# that is supplied when $file_magic_command is called. -func_win32_libid () -{ - win32_libid_type="unknown" - win32_fileres=`file -L $1 2>/dev/null` - case $win32_fileres in - *ar\ archive\ import\ library*) # definitely import - win32_libid_type="x86 archive import" - ;; - *ar\ archive*) # could be an import, or static - if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \ - $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then - win32_nmres=`eval $NM -f posix -A $1 | \ - sed -n -e '1,100{/ I /{x;/import/!{s/^/import/;h;p;};x;};}'` - if test "X$win32_nmres" = "Ximport" ; then - win32_libid_type="x86 archive import" - else - win32_libid_type="x86 archive static" - fi - fi - ;; - *DLL*) - win32_libid_type="x86 DLL" - ;; - *executable*) # but shell scripts are "executable" too... - case $win32_fileres in - *MS\ Windows\ PE\ Intel*) - win32_libid_type="x86 DLL" - ;; - esac - ;; - esac - $echo $win32_libid_type -} - - -# func_infer_tag arg -# Infer tagged configuration to use if any are available and -# if one wasn't chosen via the "--tag" command line option. -# Only attempt this if the compiler in the base compile -# command doesn't match the default compiler. -# arg is usually of the form 'gcc ...' -func_infer_tag () -{ - if test -n "$available_tags" && test -z "$tagname"; then - CC_quoted= - for arg in $CC; do - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - arg="\"$arg\"" - ;; - esac - CC_quoted="$CC_quoted $arg" - done - case $@ in - # Blanks in the command may have been stripped by the calling shell, - # but not from the CC environment variable when configure was run. - " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;; - # Blanks at the start of $base_compile will cause this to fail - # if we don't check for them as well. - *) - for z in $available_tags; do - if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then - # Evaluate the configuration. - eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" - CC_quoted= - for arg in $CC; do - # Double-quote args containing other shell metacharacters. - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - arg="\"$arg\"" - ;; - esac - CC_quoted="$CC_quoted $arg" - done - case "$@ " in - " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) - # The compiler in the base compile command matches - # the one in the tagged configuration. - # Assume this is the tagged configuration we want. - tagname=$z - break - ;; - esac - fi - done - # If $tagname still isn't set, then no tagged configuration - # was found and let the user know that the "--tag" command - # line option must be used. - if test -z "$tagname"; then - $echo "$modename: unable to infer tagged configuration" - $echo "$modename: specify a tag with \`--tag'" 1>&2 - exit $EXIT_FAILURE -# else -# $echo "$modename: using $tagname tagged configuration" - fi - ;; - esac - fi -} - - -# func_extract_an_archive dir oldlib -func_extract_an_archive () -{ - f_ex_an_ar_dir="$1"; shift - f_ex_an_ar_oldlib="$1" - - $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)" - $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $? - if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then - : - else - $echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2 - exit $EXIT_FAILURE - fi -} - -# func_extract_archives gentop oldlib ... -func_extract_archives () -{ - my_gentop="$1"; shift - my_oldlibs=${1+"$@"} - my_oldobjs="" - my_xlib="" - my_xabs="" - my_xdir="" - my_status="" - - $show "${rm}r $my_gentop" - $run ${rm}r "$my_gentop" - $show "$mkdir $my_gentop" - $run $mkdir "$my_gentop" - my_status=$? - if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then - exit $my_status - fi - - for my_xlib in $my_oldlibs; do - # Extract the objects. - case $my_xlib in - [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; - *) my_xabs=`pwd`"/$my_xlib" ;; - esac - my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'` - my_xdir="$my_gentop/$my_xlib" - - $show "${rm}r $my_xdir" - $run ${rm}r "$my_xdir" - $show "$mkdir $my_xdir" - $run $mkdir "$my_xdir" - status=$? - if test "$status" -ne 0 && test ! -d "$my_xdir"; then - exit $status - fi - case $host in - *-darwin*) - $show "Extracting $my_xabs" - # Do not bother doing anything if just a dry run - if test -z "$run"; then - darwin_orig_dir=`pwd` - cd $my_xdir || exit $? - darwin_archive=$my_xabs - darwin_curdir=`pwd` - darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'` - darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null` - if test -n "$darwin_arches"; then - darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'` - darwin_arch= - $show "$darwin_base_archive has multiple architectures $darwin_arches" - for darwin_arch in $darwin_arches ; do - mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}" - lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" - cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" - func_extract_an_archive "`pwd`" "${darwin_base_archive}" - cd "$darwin_curdir" - $rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" - done # $darwin_arches - ## Okay now we have a bunch of thin objects, gotta fatten them up :) - darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP` - darwin_file= - darwin_files= - for darwin_file in $darwin_filelist; do - darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP` - lipo -create -output "$darwin_file" $darwin_files - done # $darwin_filelist - ${rm}r unfat-$$ - cd "$darwin_orig_dir" - else - cd "$darwin_orig_dir" - func_extract_an_archive "$my_xdir" "$my_xabs" - fi # $darwin_arches - fi # $run - ;; - *) - func_extract_an_archive "$my_xdir" "$my_xabs" - ;; - esac - my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP` - done - func_extract_archives_result="$my_oldobjs" -} -# End of Shell function definitions -##################################### - -# Darwin sucks -eval std_shrext=\"$shrext_cmds\" - -# Parse our command line options once, thoroughly. -while test "$#" -gt 0 -do - arg="$1" - shift - - case $arg in - -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;; - *) optarg= ;; - esac - - # If the previous option needs an argument, assign it. - if test -n "$prev"; then - case $prev in - execute_dlfiles) - execute_dlfiles="$execute_dlfiles $arg" - ;; - tag) - tagname="$arg" - preserve_args="${preserve_args}=$arg" - - # Check whether tagname contains only valid characters - case $tagname in - *[!-_A-Za-z0-9,/]*) - $echo "$progname: invalid tag name: $tagname" 1>&2 - exit $EXIT_FAILURE - ;; - esac - - case $tagname in - CC) - # Don't test for the "default" C tag, as we know, it's there, but - # not specially marked. - ;; - *) - if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then - taglist="$taglist $tagname" - # Evaluate the configuration. - eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`" - else - $echo "$progname: ignoring unknown tag $tagname" 1>&2 - fi - ;; - esac - ;; - *) - eval "$prev=\$arg" - ;; - esac - - prev= - prevopt= - continue - fi - - # Have we seen a non-optional argument yet? - case $arg in - --help) - show_help=yes - ;; - - --version) - $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP" - $echo - $echo "Copyright (C) 2005 Free Software Foundation, Inc." - $echo "This is free software; see the source for copying conditions. There is NO" - $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - exit $? - ;; - - --config) - ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath - # Now print the configurations for the tags. - for tagname in $taglist; do - ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath" - done - exit $? - ;; - - --debug) - $echo "$progname: enabling shell trace mode" - set -x - preserve_args="$preserve_args $arg" - ;; - - --dry-run | -n) - run=: - ;; - - --features) - $echo "host: $host" - if test "$build_libtool_libs" = yes; then - $echo "enable shared libraries" - else - $echo "disable shared libraries" - fi - if test "$build_old_libs" = yes; then - $echo "enable static libraries" - else - $echo "disable static libraries" - fi - exit $? - ;; - - --finish) mode="finish" ;; - - --mode) prevopt="--mode" prev=mode ;; - --mode=*) mode="$optarg" ;; - - --preserve-dup-deps) duplicate_deps="yes" ;; - - --quiet | --silent) - show=: - preserve_args="$preserve_args $arg" - ;; - - --tag) prevopt="--tag" prev=tag ;; - --tag=*) - set tag "$optarg" ${1+"$@"} - shift - prev=tag - preserve_args="$preserve_args --tag" - ;; - - -dlopen) - prevopt="-dlopen" - prev=execute_dlfiles - ;; - - -*) - $echo "$modename: unrecognized option \`$arg'" 1>&2 - $echo "$help" 1>&2 - exit $EXIT_FAILURE - ;; - - *) - nonopt="$arg" - break - ;; - esac -done - -if test -n "$prevopt"; then - $echo "$modename: option \`$prevopt' requires an argument" 1>&2 - $echo "$help" 1>&2 - exit $EXIT_FAILURE -fi - -# If this variable is set in any of the actions, the command in it -# will be execed at the end. This prevents here-documents from being -# left over by shells. -exec_cmd= - -if test -z "$show_help"; then - - # Infer the operation mode. - if test -z "$mode"; then - $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2 - $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2 - case $nonopt in - *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*) - mode=link - for arg - do - case $arg in - -c) - mode=compile - break - ;; - esac - done - ;; - *db | *dbx | *strace | *truss) - mode=execute - ;; - *install*|cp|mv) - mode=install - ;; - *rm) - mode=uninstall - ;; - *) - # If we have no mode, but dlfiles were specified, then do execute mode. - test -n "$execute_dlfiles" && mode=execute - - # Just use the default operation mode. - if test -z "$mode"; then - if test -n "$nonopt"; then - $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2 - else - $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2 - fi - fi - ;; - esac - fi - - # Only execute mode is allowed to have -dlopen flags. - if test -n "$execute_dlfiles" && test "$mode" != execute; then - $echo "$modename: unrecognized option \`-dlopen'" 1>&2 - $echo "$help" 1>&2 - exit $EXIT_FAILURE - fi - - # Change the help message to a mode-specific one. - generic_help="$help" - help="Try \`$modename --help --mode=$mode' for more information." - - # These modes are in order of execution frequency so that they run quickly. - case $mode in - # libtool compile mode - compile) - modename="$modename: compile" - # Get the compilation command and the source file. - base_compile= - srcfile="$nonopt" # always keep a non-empty value in "srcfile" - suppress_opt=yes - suppress_output= - arg_mode=normal - libobj= - later= - - for arg - do - case $arg_mode in - arg ) - # do not "continue". Instead, add this to base_compile - lastarg="$arg" - arg_mode=normal - ;; - - target ) - libobj="$arg" - arg_mode=normal - continue - ;; - - normal ) - # Accept any command-line options. - case $arg in - -o) - if test -n "$libobj" ; then - $echo "$modename: you cannot specify \`-o' more than once" 1>&2 - exit $EXIT_FAILURE - fi - arg_mode=target - continue - ;; - - -static | -prefer-pic | -prefer-non-pic) - later="$later $arg" - continue - ;; - - -no-suppress) - suppress_opt=no - continue - ;; - - -Xcompiler) - arg_mode=arg # the next one goes into the "base_compile" arg list - continue # The current "srcfile" will either be retained or - ;; # replaced later. I would guess that would be a bug. - - -Wc,*) - args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"` - lastarg= - save_ifs="$IFS"; IFS=',' - for arg in $args; do - IFS="$save_ifs" - - # Double-quote args containing other shell metacharacters. - # Many Bourne shells cannot handle close brackets correctly - # in scan sets, so we specify it separately. - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - arg="\"$arg\"" - ;; - esac - lastarg="$lastarg $arg" - done - IFS="$save_ifs" - lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"` - - # Add the arguments to base_compile. - base_compile="$base_compile $lastarg" - continue - ;; - - * ) - # Accept the current argument as the source file. - # The previous "srcfile" becomes the current argument. - # - lastarg="$srcfile" - srcfile="$arg" - ;; - esac # case $arg - ;; - esac # case $arg_mode - - # Aesthetically quote the previous argument. - lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"` - - case $lastarg in - # Double-quote args containing other shell metacharacters. - # Many Bourne shells cannot handle close brackets correctly - # in scan sets, and some SunOS ksh mistreat backslash-escaping - # in scan sets (worked around with variable expansion), - # and furthermore cannot handle '|' '&' '(' ')' in scan sets - # at all, so we specify them separately. - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - lastarg="\"$lastarg\"" - ;; - esac - - base_compile="$base_compile $lastarg" - done # for arg - - case $arg_mode in - arg) - $echo "$modename: you must specify an argument for -Xcompile" - exit $EXIT_FAILURE - ;; - target) - $echo "$modename: you must specify a target with \`-o'" 1>&2 - exit $EXIT_FAILURE - ;; - *) - # Get the name of the library object. - [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'` - ;; - esac - - # Recognize several different file suffixes. - # If the user specifies -o file.o, it is replaced with file.lo - xform='[cCFSifmso]' - case $libobj in - *.ada) xform=ada ;; - *.adb) xform=adb ;; - *.ads) xform=ads ;; - *.asm) xform=asm ;; - *.c++) xform=c++ ;; - *.cc) xform=cc ;; - *.ii) xform=ii ;; - *.class) xform=class ;; - *.cpp) xform=cpp ;; - *.cxx) xform=cxx ;; - *.f90) xform=f90 ;; - *.for) xform=for ;; - *.java) xform=java ;; - esac - - libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"` - - case $libobj in - *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;; - *) - $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2 - exit $EXIT_FAILURE - ;; - esac - - func_infer_tag $base_compile - - for arg in $later; do - case $arg in - -static) - build_old_libs=yes - continue - ;; - - -prefer-pic) - pic_mode=yes - continue - ;; - - -prefer-non-pic) - pic_mode=no - continue - ;; - esac - done - - qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"` - case $qlibobj in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - qlibobj="\"$qlibobj\"" ;; - esac - test "X$libobj" != "X$qlibobj" \ - && $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"' &()|`$[]' \ - && $echo "$modename: libobj name \`$libobj' may not contain shell special characters." - objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'` - xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'` - if test "X$xdir" = "X$obj"; then - xdir= - else - xdir=$xdir/ - fi - lobj=${xdir}$objdir/$objname - - if test -z "$base_compile"; then - $echo "$modename: you must specify a compilation command" 1>&2 - $echo "$help" 1>&2 - exit $EXIT_FAILURE - fi - - # Delete any leftover library objects. - if test "$build_old_libs" = yes; then - removelist="$obj $lobj $libobj ${libobj}T" - else - removelist="$lobj $libobj ${libobj}T" - fi - - $run $rm $removelist - trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15 - - # On Cygwin there's no "real" PIC flag so we must build both object types - case $host_os in - cygwin* | mingw* | pw32* | os2*) - pic_mode=default - ;; - esac - if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then - # non-PIC code in shared libraries is not supported - pic_mode=default - fi - - # Calculate the filename of the output object if compiler does - # not support -o with -c - if test "$compiler_c_o" = no; then - output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext} - lockfile="$output_obj.lock" - removelist="$removelist $output_obj $lockfile" - trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15 - else - output_obj= - need_locks=no - lockfile= - fi - - # Lock this critical section if it is needed - # We use this script file to make the link, it avoids creating a new file - if test "$need_locks" = yes; then - until $run ln "$progpath" "$lockfile" 2>/dev/null; do - $show "Waiting for $lockfile to be removed" - sleep 2 - done - elif test "$need_locks" = warn; then - if test -f "$lockfile"; then - $echo "\ -*** ERROR, $lockfile exists and contains: -`cat $lockfile 2>/dev/null` - -This indicates that another process is trying to use the same -temporary object file, and libtool could not work around it because -your compiler does not support \`-c' and \`-o' together. If you -repeat this compilation, it may succeed, by chance, but you had better -avoid parallel builds (make -j) in this platform, or get a better -compiler." - - $run $rm $removelist - exit $EXIT_FAILURE - fi - $echo "$srcfile" > "$lockfile" - fi - - if test -n "$fix_srcfile_path"; then - eval srcfile=\"$fix_srcfile_path\" - fi - qsrcfile=`$echo "X$srcfile" | $Xsed -e "$sed_quote_subst"` - case $qsrcfile in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - qsrcfile="\"$qsrcfile\"" ;; - esac - - $run $rm "$libobj" "${libobj}T" - - # Create a libtool object file (analogous to a ".la" file), - # but don't create it if we're doing a dry run. - test -z "$run" && cat > ${libobj}T </dev/null`" != "X$srcfile"; then - $echo "\ -*** ERROR, $lockfile contains: -`cat $lockfile 2>/dev/null` - -but it should contain: -$srcfile - -This indicates that another process is trying to use the same -temporary object file, and libtool could not work around it because -your compiler does not support \`-c' and \`-o' together. If you -repeat this compilation, it may succeed, by chance, but you had better -avoid parallel builds (make -j) in this platform, or get a better -compiler." - - $run $rm $removelist - exit $EXIT_FAILURE - fi - - # Just move the object if needed, then go on to compile the next one - if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then - $show "$mv $output_obj $lobj" - if $run $mv $output_obj $lobj; then : - else - error=$? - $run $rm $removelist - exit $error - fi - fi - - # Append the name of the PIC object to the libtool object file. - test -z "$run" && cat >> ${libobj}T <> ${libobj}T </dev/null`" != "X$srcfile"; then - $echo "\ -*** ERROR, $lockfile contains: -`cat $lockfile 2>/dev/null` - -but it should contain: -$srcfile - -This indicates that another process is trying to use the same -temporary object file, and libtool could not work around it because -your compiler does not support \`-c' and \`-o' together. If you -repeat this compilation, it may succeed, by chance, but you had better -avoid parallel builds (make -j) in this platform, or get a better -compiler." - - $run $rm $removelist - exit $EXIT_FAILURE - fi - - # Just move the object if needed - if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then - $show "$mv $output_obj $obj" - if $run $mv $output_obj $obj; then : - else - error=$? - $run $rm $removelist - exit $error - fi - fi - - # Append the name of the non-PIC object the libtool object file. - # Only append if the libtool object file exists. - test -z "$run" && cat >> ${libobj}T <> ${libobj}T <&2 - fi - if test -n "$link_static_flag"; then - dlopen_self=$dlopen_self_static - fi - else - if test -z "$pic_flag" && test -n "$link_static_flag"; then - dlopen_self=$dlopen_self_static - fi - fi - build_libtool_libs=no - build_old_libs=yes - prefer_static_libs=yes - break - ;; - esac - done - - # See if our shared archives depend on static archives. - test -n "$old_archive_from_new_cmds" && build_old_libs=yes - - # Go through the arguments, transforming them on the way. - while test "$#" -gt 0; do - arg="$1" - shift - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test - ;; - *) qarg=$arg ;; - esac - libtool_args="$libtool_args $qarg" - - # If the previous option needs an argument, assign it. - if test -n "$prev"; then - case $prev in - output) - compile_command="$compile_command @OUTPUT@" - finalize_command="$finalize_command @OUTPUT@" - ;; - esac - - case $prev in - dlfiles|dlprefiles) - if test "$preload" = no; then - # Add the symbol object into the linking commands. - compile_command="$compile_command @SYMFILE@" - finalize_command="$finalize_command @SYMFILE@" - preload=yes - fi - case $arg in - *.la | *.lo) ;; # We handle these cases below. - force) - if test "$dlself" = no; then - dlself=needless - export_dynamic=yes - fi - prev= - continue - ;; - self) - if test "$prev" = dlprefiles; then - dlself=yes - elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then - dlself=yes - else - dlself=needless - export_dynamic=yes - fi - prev= - continue - ;; - *) - if test "$prev" = dlfiles; then - dlfiles="$dlfiles $arg" - else - dlprefiles="$dlprefiles $arg" - fi - prev= - continue - ;; - esac - ;; - expsyms) - export_symbols="$arg" - if test ! -f "$arg"; then - $echo "$modename: symbol file \`$arg' does not exist" - exit $EXIT_FAILURE - fi - prev= - continue - ;; - expsyms_regex) - export_symbols_regex="$arg" - prev= - continue - ;; - inst_prefix) - inst_prefix_dir="$arg" - prev= - continue - ;; - precious_regex) - precious_files_regex="$arg" - prev= - continue - ;; - release) - release="-$arg" - prev= - continue - ;; - objectlist) - if test -f "$arg"; then - save_arg=$arg - moreargs= - for fil in `cat $save_arg` - do -# moreargs="$moreargs $fil" - arg=$fil - # A libtool-controlled object. - - # Check to see that this really is a libtool object. - if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then - pic_object= - non_pic_object= - - # Read the .lo file - # If there is no directory component, then add one. - case $arg in - */* | *\\*) . $arg ;; - *) . ./$arg ;; - esac - - if test -z "$pic_object" || \ - test -z "$non_pic_object" || - test "$pic_object" = none && \ - test "$non_pic_object" = none; then - $echo "$modename: cannot find name of object for \`$arg'" 1>&2 - exit $EXIT_FAILURE - fi - - # Extract subdirectory from the argument. - xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` - if test "X$xdir" = "X$arg"; then - xdir= - else - xdir="$xdir/" - fi - - if test "$pic_object" != none; then - # Prepend the subdirectory the object is found in. - pic_object="$xdir$pic_object" - - if test "$prev" = dlfiles; then - if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then - dlfiles="$dlfiles $pic_object" - prev= - continue - else - # If libtool objects are unsupported, then we need to preload. - prev=dlprefiles - fi - fi - - # CHECK ME: I think I busted this. -Ossama - if test "$prev" = dlprefiles; then - # Preload the old-style object. - dlprefiles="$dlprefiles $pic_object" - prev= - fi - - # A PIC object. - libobjs="$libobjs $pic_object" - arg="$pic_object" - fi - - # Non-PIC object. - if test "$non_pic_object" != none; then - # Prepend the subdirectory the object is found in. - non_pic_object="$xdir$non_pic_object" - - # A standard non-PIC object - non_pic_objects="$non_pic_objects $non_pic_object" - if test -z "$pic_object" || test "$pic_object" = none ; then - arg="$non_pic_object" - fi - fi - else - # Only an error if not doing a dry-run. - if test -z "$run"; then - $echo "$modename: \`$arg' is not a valid libtool object" 1>&2 - exit $EXIT_FAILURE - else - # Dry-run case. - - # Extract subdirectory from the argument. - xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` - if test "X$xdir" = "X$arg"; then - xdir= - else - xdir="$xdir/" - fi - - pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"` - non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"` - libobjs="$libobjs $pic_object" - non_pic_objects="$non_pic_objects $non_pic_object" - fi - fi - done - else - $echo "$modename: link input file \`$save_arg' does not exist" - exit $EXIT_FAILURE - fi - arg=$save_arg - prev= - continue - ;; - rpath | xrpath) - # We need an absolute path. - case $arg in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - $echo "$modename: only absolute run-paths are allowed" 1>&2 - exit $EXIT_FAILURE - ;; - esac - if test "$prev" = rpath; then - case "$rpath " in - *" $arg "*) ;; - *) rpath="$rpath $arg" ;; - esac - else - case "$xrpath " in - *" $arg "*) ;; - *) xrpath="$xrpath $arg" ;; - esac - fi - prev= - continue - ;; - xcompiler) - compiler_flags="$compiler_flags $qarg" - prev= - compile_command="$compile_command $qarg" - finalize_command="$finalize_command $qarg" - continue - ;; - xlinker) - linker_flags="$linker_flags $qarg" - compiler_flags="$compiler_flags $wl$qarg" - prev= - compile_command="$compile_command $wl$qarg" - finalize_command="$finalize_command $wl$qarg" - continue - ;; - xcclinker) - linker_flags="$linker_flags $qarg" - compiler_flags="$compiler_flags $qarg" - prev= - compile_command="$compile_command $qarg" - finalize_command="$finalize_command $qarg" - continue - ;; - shrext) - shrext_cmds="$arg" - prev= - continue - ;; - darwin_framework) - compiler_flags="$compiler_flags $arg" - compile_command="$compile_command $arg" - finalize_command="$finalize_command $arg" - prev= - continue - ;; - *) - eval "$prev=\"\$arg\"" - prev= - continue - ;; - esac - fi # test -n "$prev" - - prevarg="$arg" - - case $arg in - -all-static) - if test -n "$link_static_flag"; then - compile_command="$compile_command $link_static_flag" - finalize_command="$finalize_command $link_static_flag" - fi - continue - ;; - - -allow-undefined) - # FIXME: remove this flag sometime in the future. - $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2 - continue - ;; - - -avoid-version) - avoid_version=yes - continue - ;; - - -dlopen) - prev=dlfiles - continue - ;; - - -dlpreopen) - prev=dlprefiles - continue - ;; - - -export-dynamic) - export_dynamic=yes - continue - ;; - - -export-symbols | -export-symbols-regex) - if test -n "$export_symbols" || test -n "$export_symbols_regex"; then - $echo "$modename: more than one -exported-symbols argument is not allowed" - exit $EXIT_FAILURE - fi - if test "X$arg" = "X-export-symbols"; then - prev=expsyms - else - prev=expsyms_regex - fi - continue - ;; - - -framework|-arch) - prev=darwin_framework - compiler_flags="$compiler_flags $arg" - compile_command="$compile_command $arg" - finalize_command="$finalize_command $arg" - continue - ;; - - -inst-prefix-dir) - prev=inst_prefix - continue - ;; - - # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* - # so, if we see these flags be careful not to treat them like -L - -L[A-Z][A-Z]*:*) - case $with_gcc/$host in - no/*-*-irix* | /*-*-irix*) - compile_command="$compile_command $arg" - finalize_command="$finalize_command $arg" - ;; - esac - continue - ;; - - -L*) - dir=`$echo "X$arg" | $Xsed -e 's/^-L//'` - # We need an absolute path. - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - absdir=`cd "$dir" && pwd` - if test -z "$absdir"; then - $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2 - exit $EXIT_FAILURE - fi - dir="$absdir" - ;; - esac - case "$deplibs " in - *" -L$dir "*) ;; - *) - deplibs="$deplibs -L$dir" - lib_search_path="$lib_search_path $dir" - ;; - esac - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) - case :$dllsearchpath: in - *":$dir:"*) ;; - *) dllsearchpath="$dllsearchpath:$dir";; - esac - ;; - esac - continue - ;; - - -l*) - if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then - case $host in - *-*-cygwin* | *-*-pw32* | *-*-beos*) - # These systems don't actually have a C or math library (as such) - continue - ;; - *-*-mingw* | *-*-os2*) - # These systems don't actually have a C library (as such) - test "X$arg" = "X-lc" && continue - ;; - *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) - # Do not include libc due to us having libc/libc_r. - test "X$arg" = "X-lc" && continue - ;; - *-*-rhapsody* | *-*-darwin1.[012]) - # Rhapsody C and math libraries are in the System framework - deplibs="$deplibs -framework System" - continue - esac - elif test "X$arg" = "X-lc_r"; then - case $host in - *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) - # Do not include libc_r directly, use -pthread flag. - continue - ;; - esac - fi - deplibs="$deplibs $arg" - continue - ;; - - # Tru64 UNIX uses -model [arg] to determine the layout of C++ - # classes, name mangling, and exception handling. - -model) - compile_command="$compile_command $arg" - compiler_flags="$compiler_flags $arg" - finalize_command="$finalize_command $arg" - prev=xcompiler - continue - ;; - - -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe) - compiler_flags="$compiler_flags $arg" - compile_command="$compile_command $arg" - finalize_command="$finalize_command $arg" - continue - ;; - - -module) - module=yes - continue - ;; - - # -64, -mips[0-9] enable 64-bit mode on the SGI compiler - # -r[0-9][0-9]* specifies the processor on the SGI compiler - # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler - # +DA*, +DD* enable 64-bit mode on the HP compiler - # -q* pass through compiler args for the IBM compiler - # -m* pass through architecture-specific compiler args for GCC - -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*) - - # Unknown arguments in both finalize_command and compile_command need - # to be aesthetically quoted because they are evaled later. - arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - arg="\"$arg\"" - ;; - esac - compile_command="$compile_command $arg" - finalize_command="$finalize_command $arg" - if test "$with_gcc" = "yes" ; then - compiler_flags="$compiler_flags $arg" - fi - continue - ;; - - -shrext) - prev=shrext - continue - ;; - - -no-fast-install) - fast_install=no - continue - ;; - - -no-install) - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) - # The PATH hackery in wrapper scripts is required on Windows - # in order for the loader to find any dlls it needs. - $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2 - $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2 - fast_install=no - ;; - *) no_install=yes ;; - esac - continue - ;; - - -no-undefined) - allow_undefined=no - continue - ;; - - -objectlist) - prev=objectlist - continue - ;; - - -o) prev=output ;; - - -precious-files-regex) - prev=precious_regex - continue - ;; - - -release) - prev=release - continue - ;; - - -rpath) - prev=rpath - continue - ;; - - -R) - prev=xrpath - continue - ;; - - -R*) - dir=`$echo "X$arg" | $Xsed -e 's/^-R//'` - # We need an absolute path. - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - $echo "$modename: only absolute run-paths are allowed" 1>&2 - exit $EXIT_FAILURE - ;; - esac - case "$xrpath " in - *" $dir "*) ;; - *) xrpath="$xrpath $dir" ;; - esac - continue - ;; - - -static) - # The effects of -static are defined in a previous loop. - # We used to do the same as -all-static on platforms that - # didn't have a PIC flag, but the assumption that the effects - # would be equivalent was wrong. It would break on at least - # Digital Unix and AIX. - continue - ;; - - -thread-safe) - thread_safe=yes - continue - ;; - - -version-info) - prev=vinfo - continue - ;; - -version-number) - prev=vinfo - vinfo_number=yes - continue - ;; - - -Wc,*) - args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'` - arg= - save_ifs="$IFS"; IFS=',' - for flag in $args; do - IFS="$save_ifs" - case $flag in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - flag="\"$flag\"" - ;; - esac - arg="$arg $wl$flag" - compiler_flags="$compiler_flags $flag" - done - IFS="$save_ifs" - arg=`$echo "X$arg" | $Xsed -e "s/^ //"` - ;; - - -Wl,*) - args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'` - arg= - save_ifs="$IFS"; IFS=',' - for flag in $args; do - IFS="$save_ifs" - case $flag in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - flag="\"$flag\"" - ;; - esac - arg="$arg $wl$flag" - compiler_flags="$compiler_flags $wl$flag" - linker_flags="$linker_flags $flag" - done - IFS="$save_ifs" - arg=`$echo "X$arg" | $Xsed -e "s/^ //"` - ;; - - -Xcompiler) - prev=xcompiler - continue - ;; - - -Xlinker) - prev=xlinker - continue - ;; - - -XCClinker) - prev=xcclinker - continue - ;; - - # Some other compiler flag. - -* | +*) - # Unknown arguments in both finalize_command and compile_command need - # to be aesthetically quoted because they are evaled later. - arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - arg="\"$arg\"" - ;; - esac - ;; - - *.$objext) - # A standard object. - objs="$objs $arg" - ;; - - *.lo) - # A libtool-controlled object. - - # Check to see that this really is a libtool object. - if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then - pic_object= - non_pic_object= - - # Read the .lo file - # If there is no directory component, then add one. - case $arg in - */* | *\\*) . $arg ;; - *) . ./$arg ;; - esac - - if test -z "$pic_object" || \ - test -z "$non_pic_object" || - test "$pic_object" = none && \ - test "$non_pic_object" = none; then - $echo "$modename: cannot find name of object for \`$arg'" 1>&2 - exit $EXIT_FAILURE - fi - - # Extract subdirectory from the argument. - xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` - if test "X$xdir" = "X$arg"; then - xdir= - else - xdir="$xdir/" - fi - - if test "$pic_object" != none; then - # Prepend the subdirectory the object is found in. - pic_object="$xdir$pic_object" - - if test "$prev" = dlfiles; then - if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then - dlfiles="$dlfiles $pic_object" - prev= - continue - else - # If libtool objects are unsupported, then we need to preload. - prev=dlprefiles - fi - fi - - # CHECK ME: I think I busted this. -Ossama - if test "$prev" = dlprefiles; then - # Preload the old-style object. - dlprefiles="$dlprefiles $pic_object" - prev= - fi - - # A PIC object. - libobjs="$libobjs $pic_object" - arg="$pic_object" - fi - - # Non-PIC object. - if test "$non_pic_object" != none; then - # Prepend the subdirectory the object is found in. - non_pic_object="$xdir$non_pic_object" - - # A standard non-PIC object - non_pic_objects="$non_pic_objects $non_pic_object" - if test -z "$pic_object" || test "$pic_object" = none ; then - arg="$non_pic_object" - fi - fi - else - # Only an error if not doing a dry-run. - if test -z "$run"; then - $echo "$modename: \`$arg' is not a valid libtool object" 1>&2 - exit $EXIT_FAILURE - else - # Dry-run case. - - # Extract subdirectory from the argument. - xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` - if test "X$xdir" = "X$arg"; then - xdir= - else - xdir="$xdir/" - fi - - pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"` - non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"` - libobjs="$libobjs $pic_object" - non_pic_objects="$non_pic_objects $non_pic_object" - fi - fi - ;; - - *.$libext) - # An archive. - deplibs="$deplibs $arg" - old_deplibs="$old_deplibs $arg" - continue - ;; - - *.la) - # A libtool-controlled library. - - if test "$prev" = dlfiles; then - # This library was specified with -dlopen. - dlfiles="$dlfiles $arg" - prev= - elif test "$prev" = dlprefiles; then - # The library was specified with -dlpreopen. - dlprefiles="$dlprefiles $arg" - prev= - else - deplibs="$deplibs $arg" - fi - continue - ;; - - # Some other compiler argument. - *) - # Unknown arguments in both finalize_command and compile_command need - # to be aesthetically quoted because they are evaled later. - arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - arg="\"$arg\"" - ;; - esac - ;; - esac # arg - - # Now actually substitute the argument into the commands. - if test -n "$arg"; then - compile_command="$compile_command $arg" - finalize_command="$finalize_command $arg" - fi - done # argument parsing loop - - if test -n "$prev"; then - $echo "$modename: the \`$prevarg' option requires an argument" 1>&2 - $echo "$help" 1>&2 - exit $EXIT_FAILURE - fi - - if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then - eval arg=\"$export_dynamic_flag_spec\" - compile_command="$compile_command $arg" - finalize_command="$finalize_command $arg" - fi - - oldlibs= - # calculate the name of the file, without its directory - outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'` - libobjs_save="$libobjs" - - if test -n "$shlibpath_var"; then - # get the directories listed in $shlibpath_var - eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\` - else - shlib_search_path= - fi - eval sys_lib_search_path=\"$sys_lib_search_path_spec\" - eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" - - output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'` - if test "X$output_objdir" = "X$output"; then - output_objdir="$objdir" - else - output_objdir="$output_objdir/$objdir" - fi - # Create the object directory. - if test ! -d "$output_objdir"; then - $show "$mkdir $output_objdir" - $run $mkdir $output_objdir - status=$? - if test "$status" -ne 0 && test ! -d "$output_objdir"; then - exit $status - fi - fi - - # Determine the type of output - case $output in - "") - $echo "$modename: you must specify an output file" 1>&2 - $echo "$help" 1>&2 - exit $EXIT_FAILURE - ;; - *.$libext) linkmode=oldlib ;; - *.lo | *.$objext) linkmode=obj ;; - *.la) linkmode=lib ;; - *) linkmode=prog ;; # Anything else should be a program. - esac - - case $host in - *cygwin* | *mingw* | *pw32*) - # don't eliminate duplications in $postdeps and $predeps - duplicate_compiler_generated_deps=yes - ;; - *) - duplicate_compiler_generated_deps=$duplicate_deps - ;; - esac - specialdeplibs= - - libs= - # Find all interdependent deplibs by searching for libraries - # that are linked more than once (e.g. -la -lb -la) - for deplib in $deplibs; do - if test "X$duplicate_deps" = "Xyes" ; then - case "$libs " in - *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; - esac - fi - libs="$libs $deplib" - done - - if test "$linkmode" = lib; then - libs="$predeps $libs $compiler_lib_search_path $postdeps" - - # Compute libraries that are listed more than once in $predeps - # $postdeps and mark them as special (i.e., whose duplicates are - # not to be eliminated). - pre_post_deps= - if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then - for pre_post_dep in $predeps $postdeps; do - case "$pre_post_deps " in - *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;; - esac - pre_post_deps="$pre_post_deps $pre_post_dep" - done - fi - pre_post_deps= - fi - - deplibs= - newdependency_libs= - newlib_search_path= - need_relink=no # whether we're linking any uninstalled libtool libraries - notinst_deplibs= # not-installed libtool libraries - notinst_path= # paths that contain not-installed libtool libraries - case $linkmode in - lib) - passes="conv link" - for file in $dlfiles $dlprefiles; do - case $file in - *.la) ;; - *) - $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2 - exit $EXIT_FAILURE - ;; - esac - done - ;; - prog) - compile_deplibs= - finalize_deplibs= - alldeplibs=no - newdlfiles= - newdlprefiles= - passes="conv scan dlopen dlpreopen link" - ;; - *) passes="conv" - ;; - esac - for pass in $passes; do - if test "$linkmode,$pass" = "lib,link" || - test "$linkmode,$pass" = "prog,scan"; then - libs="$deplibs" - deplibs= - fi - if test "$linkmode" = prog; then - case $pass in - dlopen) libs="$dlfiles" ;; - dlpreopen) libs="$dlprefiles" ;; - link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; - esac - fi - if test "$pass" = dlopen; then - # Collect dlpreopened libraries - save_deplibs="$deplibs" - deplibs= - fi - for deplib in $libs; do - lib= - found=no - case $deplib in - -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe) - if test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - compiler_flags="$compiler_flags $deplib" - fi - continue - ;; - -l*) - if test "$linkmode" != lib && test "$linkmode" != prog; then - $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2 - continue - fi - name=`$echo "X$deplib" | $Xsed -e 's/^-l//'` - for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do - for search_ext in .la $std_shrext .so .a; do - # Search the libtool library - lib="$searchdir/lib${name}${search_ext}" - if test -f "$lib"; then - if test "$search_ext" = ".la"; then - found=yes - else - found=no - fi - break 2 - fi - done - done - if test "$found" != yes; then - # deplib doesn't seem to be a libtool library - if test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - deplibs="$deplib $deplibs" - test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" - fi - continue - else # deplib is a libtool library - # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, - # We need to do some special things here, and not later. - if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then - case " $predeps $postdeps " in - *" $deplib "*) - if (${SED} -e '2q' $lib | - grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then - library_names= - old_library= - case $lib in - */* | *\\*) . $lib ;; - *) . ./$lib ;; - esac - for l in $old_library $library_names; do - ll="$l" - done - if test "X$ll" = "X$old_library" ; then # only static version available - found=no - ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'` - test "X$ladir" = "X$lib" && ladir="." - lib=$ladir/$old_library - if test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - deplibs="$deplib $deplibs" - test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" - fi - continue - fi - fi - ;; - *) ;; - esac - fi - fi - ;; # -l - -L*) - case $linkmode in - lib) - deplibs="$deplib $deplibs" - test "$pass" = conv && continue - newdependency_libs="$deplib $newdependency_libs" - newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` - ;; - prog) - if test "$pass" = conv; then - deplibs="$deplib $deplibs" - continue - fi - if test "$pass" = scan; then - deplibs="$deplib $deplibs" - else - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - fi - newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` - ;; - *) - $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2 - ;; - esac # linkmode - continue - ;; # -L - -R*) - if test "$pass" = link; then - dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'` - # Make sure the xrpath contains only unique directories. - case "$xrpath " in - *" $dir "*) ;; - *) xrpath="$xrpath $dir" ;; - esac - fi - deplibs="$deplib $deplibs" - continue - ;; - *.la) lib="$deplib" ;; - *.$libext) - if test "$pass" = conv; then - deplibs="$deplib $deplibs" - continue - fi - case $linkmode in - lib) - valid_a_lib=no - case $deplibs_check_method in - match_pattern*) - set dummy $deplibs_check_method - match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"` - if eval $echo \"$deplib\" 2>/dev/null \ - | $SED 10q \ - | $EGREP "$match_pattern_regex" > /dev/null; then - valid_a_lib=yes - fi - ;; - pass_all) - valid_a_lib=yes - ;; - esac - if test "$valid_a_lib" != yes; then - $echo - $echo "*** Warning: Trying to link with static lib archive $deplib." - $echo "*** I have the capability to make that library automatically link in when" - $echo "*** you link to this library. But I can only do this if you have a" - $echo "*** shared version of the library, which you do not appear to have" - $echo "*** because the file extensions .$libext of this argument makes me believe" - $echo "*** that it is just a static archive that I should not used here." - else - $echo - $echo "*** Warning: Linking the shared library $output against the" - $echo "*** static library $deplib is not portable!" - deplibs="$deplib $deplibs" - fi - continue - ;; - prog) - if test "$pass" != link; then - deplibs="$deplib $deplibs" - else - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - fi - continue - ;; - esac # linkmode - ;; # *.$libext - *.lo | *.$objext) - if test "$pass" = conv; then - deplibs="$deplib $deplibs" - elif test "$linkmode" = prog; then - if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then - # If there is no dlopen support or we're linking statically, - # we need to preload. - newdlprefiles="$newdlprefiles $deplib" - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - newdlfiles="$newdlfiles $deplib" - fi - fi - continue - ;; - %DEPLIBS%) - alldeplibs=yes - continue - ;; - esac # case $deplib - if test "$found" = yes || test -f "$lib"; then : - else - $echo "$modename: cannot find the library \`$lib'" 1>&2 - exit $EXIT_FAILURE - fi - - # Check to see that this really is a libtool archive. - if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : - else - $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 - exit $EXIT_FAILURE - fi - - ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'` - test "X$ladir" = "X$lib" && ladir="." - - dlname= - dlopen= - dlpreopen= - libdir= - library_names= - old_library= - # If the library was installed with an old release of libtool, - # it will not redefine variables installed, or shouldnotlink - installed=yes - shouldnotlink=no - avoidtemprpath= - - - # Read the .la file - case $lib in - */* | *\\*) . $lib ;; - *) . ./$lib ;; - esac - - if test "$linkmode,$pass" = "lib,link" || - test "$linkmode,$pass" = "prog,scan" || - { test "$linkmode" != prog && test "$linkmode" != lib; }; then - test -n "$dlopen" && dlfiles="$dlfiles $dlopen" - test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen" - fi - - if test "$pass" = conv; then - # Only check for convenience libraries - deplibs="$lib $deplibs" - if test -z "$libdir"; then - if test -z "$old_library"; then - $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 - exit $EXIT_FAILURE - fi - # It is a libtool convenience library, so add in its objects. - convenience="$convenience $ladir/$objdir/$old_library" - old_convenience="$old_convenience $ladir/$objdir/$old_library" - tmp_libs= - for deplib in $dependency_libs; do - deplibs="$deplib $deplibs" - if test "X$duplicate_deps" = "Xyes" ; then - case "$tmp_libs " in - *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; - esac - fi - tmp_libs="$tmp_libs $deplib" - done - elif test "$linkmode" != prog && test "$linkmode" != lib; then - $echo "$modename: \`$lib' is not a convenience library" 1>&2 - exit $EXIT_FAILURE - fi - continue - fi # $pass = conv - - - # Get the name of the library we link against. - linklib= - for l in $old_library $library_names; do - linklib="$l" - done - if test -z "$linklib"; then - $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 - exit $EXIT_FAILURE - fi - - # This library was specified with -dlopen. - if test "$pass" = dlopen; then - if test -z "$libdir"; then - $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2 - exit $EXIT_FAILURE - fi - if test -z "$dlname" || - test "$dlopen_support" != yes || - test "$build_libtool_libs" = no; then - # If there is no dlname, no dlopen support or we're linking - # statically, we need to preload. We also need to preload any - # dependent libraries so libltdl's deplib preloader doesn't - # bomb out in the load deplibs phase. - dlprefiles="$dlprefiles $lib $dependency_libs" - else - newdlfiles="$newdlfiles $lib" - fi - continue - fi # $pass = dlopen - - # We need an absolute path. - case $ladir in - [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; - *) - abs_ladir=`cd "$ladir" && pwd` - if test -z "$abs_ladir"; then - $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2 - $echo "$modename: passing it literally to the linker, although it might fail" 1>&2 - abs_ladir="$ladir" - fi - ;; - esac - laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` - - # Find the relevant object directory and library name. - if test "X$installed" = Xyes; then - if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then - $echo "$modename: warning: library \`$lib' was moved." 1>&2 - dir="$ladir" - absdir="$abs_ladir" - libdir="$abs_ladir" - else - dir="$libdir" - absdir="$libdir" - fi - test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes - else - if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then - dir="$ladir" - absdir="$abs_ladir" - # Remove this search path later - notinst_path="$notinst_path $abs_ladir" - else - dir="$ladir/$objdir" - absdir="$abs_ladir/$objdir" - # Remove this search path later - notinst_path="$notinst_path $abs_ladir" - fi - fi # $installed = yes - name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` - - # This library was specified with -dlpreopen. - if test "$pass" = dlpreopen; then - if test -z "$libdir"; then - $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2 - exit $EXIT_FAILURE - fi - # Prefer using a static library (so that no silly _DYNAMIC symbols - # are required to link). - if test -n "$old_library"; then - newdlprefiles="$newdlprefiles $dir/$old_library" - # Otherwise, use the dlname, so that lt_dlopen finds it. - elif test -n "$dlname"; then - newdlprefiles="$newdlprefiles $dir/$dlname" - else - newdlprefiles="$newdlprefiles $dir/$linklib" - fi - fi # $pass = dlpreopen - - if test -z "$libdir"; then - # Link the convenience library - if test "$linkmode" = lib; then - deplibs="$dir/$old_library $deplibs" - elif test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$dir/$old_library $compile_deplibs" - finalize_deplibs="$dir/$old_library $finalize_deplibs" - else - deplibs="$lib $deplibs" # used for prog,scan pass - fi - continue - fi - - - if test "$linkmode" = prog && test "$pass" != link; then - newlib_search_path="$newlib_search_path $ladir" - deplibs="$lib $deplibs" - - linkalldeplibs=no - if test "$link_all_deplibs" != no || test -z "$library_names" || - test "$build_libtool_libs" = no; then - linkalldeplibs=yes - fi - - tmp_libs= - for deplib in $dependency_libs; do - case $deplib in - -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test - esac - # Need to link against all dependency_libs? - if test "$linkalldeplibs" = yes; then - deplibs="$deplib $deplibs" - else - # Need to hardcode shared library paths - # or/and link against static libraries - newdependency_libs="$deplib $newdependency_libs" - fi - if test "X$duplicate_deps" = "Xyes" ; then - case "$tmp_libs " in - *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; - esac - fi - tmp_libs="$tmp_libs $deplib" - done # for deplib - continue - fi # $linkmode = prog... - - if test "$linkmode,$pass" = "prog,link"; then - if test -n "$library_names" && - { test "$prefer_static_libs" = no || test -z "$old_library"; }; then - # We need to hardcode the library path - if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then - # Make sure the rpath contains only unique directories. - case "$temp_rpath " in - *" $dir "*) ;; - *" $absdir "*) ;; - *) temp_rpath="$temp_rpath $absdir" ;; - esac - fi - - # Hardcode the library path. - # Skip directories that are in the system default run-time - # search path. - case " $sys_lib_dlsearch_path " in - *" $absdir "*) ;; - *) - case "$compile_rpath " in - *" $absdir "*) ;; - *) compile_rpath="$compile_rpath $absdir" - esac - ;; - esac - case " $sys_lib_dlsearch_path " in - *" $libdir "*) ;; - *) - case "$finalize_rpath " in - *" $libdir "*) ;; - *) finalize_rpath="$finalize_rpath $libdir" - esac - ;; - esac - fi # $linkmode,$pass = prog,link... - - if test "$alldeplibs" = yes && - { test "$deplibs_check_method" = pass_all || - { test "$build_libtool_libs" = yes && - test -n "$library_names"; }; }; then - # We only need to search for static libraries - continue - fi - fi - - link_static=no # Whether the deplib will be linked statically - if test -n "$library_names" && - { test "$prefer_static_libs" = no || test -z "$old_library"; }; then - if test "$installed" = no; then - notinst_deplibs="$notinst_deplibs $lib" - need_relink=yes - fi - # This is a shared library - - # Warn about portability, can't link against -module's on - # some systems (darwin) - if test "$shouldnotlink" = yes && test "$pass" = link ; then - $echo - if test "$linkmode" = prog; then - $echo "*** Warning: Linking the executable $output against the loadable module" - else - $echo "*** Warning: Linking the shared library $output against the loadable module" - fi - $echo "*** $linklib is not portable!" - fi - if test "$linkmode" = lib && - test "$hardcode_into_libs" = yes; then - # Hardcode the library path. - # Skip directories that are in the system default run-time - # search path. - case " $sys_lib_dlsearch_path " in - *" $absdir "*) ;; - *) - case "$compile_rpath " in - *" $absdir "*) ;; - *) compile_rpath="$compile_rpath $absdir" - esac - ;; - esac - case " $sys_lib_dlsearch_path " in - *" $libdir "*) ;; - *) - case "$finalize_rpath " in - *" $libdir "*) ;; - *) finalize_rpath="$finalize_rpath $libdir" - esac - ;; - esac - fi - - if test -n "$old_archive_from_expsyms_cmds"; then - # figure out the soname - set dummy $library_names - realname="$2" - shift; shift - libname=`eval \\$echo \"$libname_spec\"` - # use dlname if we got it. it's perfectly good, no? - if test -n "$dlname"; then - soname="$dlname" - elif test -n "$soname_spec"; then - # bleh windows - case $host in - *cygwin* | mingw*) - major=`expr $current - $age` - versuffix="-$major" - ;; - esac - eval soname=\"$soname_spec\" - else - soname="$realname" - fi - - # Make a new name for the extract_expsyms_cmds to use - soroot="$soname" - soname=`$echo $soroot | ${SED} -e 's/^.*\///'` - newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a" - - # If the library has no export list, then create one now - if test -f "$output_objdir/$soname-def"; then : - else - $show "extracting exported symbol list from \`$soname'" - save_ifs="$IFS"; IFS='~' - cmds=$extract_expsyms_cmds - for cmd in $cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - fi - - # Create $newlib - if test -f "$output_objdir/$newlib"; then :; else - $show "generating import library for \`$soname'" - save_ifs="$IFS"; IFS='~' - cmds=$old_archive_from_expsyms_cmds - for cmd in $cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - fi - # make sure the library variables are pointing to the new library - dir=$output_objdir - linklib=$newlib - fi # test -n "$old_archive_from_expsyms_cmds" - - if test "$linkmode" = prog || test "$mode" != relink; then - add_shlibpath= - add_dir= - add= - lib_linked=yes - case $hardcode_action in - immediate | unsupported) - if test "$hardcode_direct" = no; then - add="$dir/$linklib" - case $host in - *-*-sco3.2v5* ) add_dir="-L$dir" ;; - *-*-darwin* ) - # if the lib is a module then we can not link against - # it, someone is ignoring the new warnings I added - if /usr/bin/file -L $add 2> /dev/null | $EGREP "bundle" >/dev/null ; then - $echo "** Warning, lib $linklib is a module, not a shared library" - if test -z "$old_library" ; then - $echo - $echo "** And there doesn't seem to be a static archive available" - $echo "** The link will probably fail, sorry" - else - add="$dir/$old_library" - fi - fi - esac - elif test "$hardcode_minus_L" = no; then - case $host in - *-*-sunos*) add_shlibpath="$dir" ;; - esac - add_dir="-L$dir" - add="-l$name" - elif test "$hardcode_shlibpath_var" = no; then - add_shlibpath="$dir" - add="-l$name" - else - lib_linked=no - fi - ;; - relink) - if test "$hardcode_direct" = yes; then - add="$dir/$linklib" - elif test "$hardcode_minus_L" = yes; then - add_dir="-L$dir" - # Try looking first in the location we're being installed to. - if test -n "$inst_prefix_dir"; then - case $libdir in - [\\/]*) - add_dir="$add_dir -L$inst_prefix_dir$libdir" - ;; - esac - fi - add="-l$name" - elif test "$hardcode_shlibpath_var" = yes; then - add_shlibpath="$dir" - add="-l$name" - else - lib_linked=no - fi - ;; - *) lib_linked=no ;; - esac - - if test "$lib_linked" != yes; then - $echo "$modename: configuration error: unsupported hardcode properties" - exit $EXIT_FAILURE - fi - - if test -n "$add_shlibpath"; then - case :$compile_shlibpath: in - *":$add_shlibpath:"*) ;; - *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;; - esac - fi - if test "$linkmode" = prog; then - test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" - test -n "$add" && compile_deplibs="$add $compile_deplibs" - else - test -n "$add_dir" && deplibs="$add_dir $deplibs" - test -n "$add" && deplibs="$add $deplibs" - if test "$hardcode_direct" != yes && \ - test "$hardcode_minus_L" != yes && \ - test "$hardcode_shlibpath_var" = yes; then - case :$finalize_shlibpath: in - *":$libdir:"*) ;; - *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; - esac - fi - fi - fi - - if test "$linkmode" = prog || test "$mode" = relink; then - add_shlibpath= - add_dir= - add= - # Finalize command for both is simple: just hardcode it. - if test "$hardcode_direct" = yes; then - add="$libdir/$linklib" - elif test "$hardcode_minus_L" = yes; then - add_dir="-L$libdir" - add="-l$name" - elif test "$hardcode_shlibpath_var" = yes; then - case :$finalize_shlibpath: in - *":$libdir:"*) ;; - *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; - esac - add="-l$name" - elif test "$hardcode_automatic" = yes; then - if test -n "$inst_prefix_dir" && - test -f "$inst_prefix_dir$libdir/$linklib" ; then - add="$inst_prefix_dir$libdir/$linklib" - else - add="$libdir/$linklib" - fi - else - # We cannot seem to hardcode it, guess we'll fake it. - add_dir="-L$libdir" - # Try looking first in the location we're being installed to. - if test -n "$inst_prefix_dir"; then - case $libdir in - [\\/]*) - add_dir="$add_dir -L$inst_prefix_dir$libdir" - ;; - esac - fi - add="-l$name" - fi - - if test "$linkmode" = prog; then - test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" - test -n "$add" && finalize_deplibs="$add $finalize_deplibs" - else - test -n "$add_dir" && deplibs="$add_dir $deplibs" - test -n "$add" && deplibs="$add $deplibs" - fi - fi - elif test "$linkmode" = prog; then - # Here we assume that one of hardcode_direct or hardcode_minus_L - # is not unsupported. This is valid on all known static and - # shared platforms. - if test "$hardcode_direct" != unsupported; then - test -n "$old_library" && linklib="$old_library" - compile_deplibs="$dir/$linklib $compile_deplibs" - finalize_deplibs="$dir/$linklib $finalize_deplibs" - else - compile_deplibs="-l$name -L$dir $compile_deplibs" - finalize_deplibs="-l$name -L$dir $finalize_deplibs" - fi - elif test "$build_libtool_libs" = yes; then - # Not a shared library - if test "$deplibs_check_method" != pass_all; then - # We're trying link a shared library against a static one - # but the system doesn't support it. - - # Just print a warning and add the library to dependency_libs so - # that the program can be linked against the static library. - $echo - $echo "*** Warning: This system can not link to static lib archive $lib." - $echo "*** I have the capability to make that library automatically link in when" - $echo "*** you link to this library. But I can only do this if you have a" - $echo "*** shared version of the library, which you do not appear to have." - if test "$module" = yes; then - $echo "*** But as you try to build a module library, libtool will still create " - $echo "*** a static module, that should work as long as the dlopening application" - $echo "*** is linked with the -dlopen flag to resolve symbols at runtime." - if test -z "$global_symbol_pipe"; then - $echo - $echo "*** However, this would only work if libtool was able to extract symbol" - $echo "*** lists from a program, using \`nm' or equivalent, but libtool could" - $echo "*** not find such a program. So, this module is probably useless." - $echo "*** \`nm' from GNU binutils and a full rebuild may help." - fi - if test "$build_old_libs" = no; then - build_libtool_libs=module - build_old_libs=yes - else - build_libtool_libs=no - fi - fi - else - deplibs="$dir/$old_library $deplibs" - link_static=yes - fi - fi # link shared/static library? - - if test "$linkmode" = lib; then - if test -n "$dependency_libs" && - { test "$hardcode_into_libs" != yes || - test "$build_old_libs" = yes || - test "$link_static" = yes; }; then - # Extract -R from dependency_libs - temp_deplibs= - for libdir in $dependency_libs; do - case $libdir in - -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'` - case " $xrpath " in - *" $temp_xrpath "*) ;; - *) xrpath="$xrpath $temp_xrpath";; - esac;; - *) temp_deplibs="$temp_deplibs $libdir";; - esac - done - dependency_libs="$temp_deplibs" - fi - - newlib_search_path="$newlib_search_path $absdir" - # Link against this library - test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" - # ... and its dependency_libs - tmp_libs= - for deplib in $dependency_libs; do - newdependency_libs="$deplib $newdependency_libs" - if test "X$duplicate_deps" = "Xyes" ; then - case "$tmp_libs " in - *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; - esac - fi - tmp_libs="$tmp_libs $deplib" - done - - if test "$link_all_deplibs" != no; then - # Add the search paths of all dependency libraries - for deplib in $dependency_libs; do - case $deplib in - -L*) path="$deplib" ;; - *.la) - dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'` - test "X$dir" = "X$deplib" && dir="." - # We need an absolute path. - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; - *) - absdir=`cd "$dir" && pwd` - if test -z "$absdir"; then - $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2 - absdir="$dir" - fi - ;; - esac - if grep "^installed=no" $deplib > /dev/null; then - path="$absdir/$objdir" - else - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` - if test -z "$libdir"; then - $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 - exit $EXIT_FAILURE - fi - if test "$absdir" != "$libdir"; then - $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2 - fi - path="$absdir" - fi - depdepl= - case $host in - *-*-darwin*) - # we do not want to link against static libs, - # but need to link against shared - eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` - if test -n "$deplibrary_names" ; then - for tmp in $deplibrary_names ; do - depdepl=$tmp - done - if test -f "$path/$depdepl" ; then - depdepl="$path/$depdepl" - fi - # do not add paths which are already there - case " $newlib_search_path " in - *" $path "*) ;; - *) newlib_search_path="$newlib_search_path $path";; - esac - fi - path="" - ;; - *) - path="-L$path" - ;; - esac - ;; - -l*) - case $host in - *-*-darwin*) - # Again, we only want to link against shared libraries - eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"` - for tmp in $newlib_search_path ; do - if test -f "$tmp/lib$tmp_libs.dylib" ; then - eval depdepl="$tmp/lib$tmp_libs.dylib" - break - fi - done - path="" - ;; - *) continue ;; - esac - ;; - *) continue ;; - esac - case " $deplibs " in - *" $path "*) ;; - *) deplibs="$path $deplibs" ;; - esac - case " $deplibs " in - *" $depdepl "*) ;; - *) deplibs="$depdepl $deplibs" ;; - esac - done - fi # link_all_deplibs != no - fi # linkmode = lib - done # for deplib in $libs - dependency_libs="$newdependency_libs" - if test "$pass" = dlpreopen; then - # Link the dlpreopened libraries before other libraries - for deplib in $save_deplibs; do - deplibs="$deplib $deplibs" - done - fi - if test "$pass" != dlopen; then - if test "$pass" != conv; then - # Make sure lib_search_path contains only unique directories. - lib_search_path= - for dir in $newlib_search_path; do - case "$lib_search_path " in - *" $dir "*) ;; - *) lib_search_path="$lib_search_path $dir" ;; - esac - done - newlib_search_path= - fi - - if test "$linkmode,$pass" != "prog,link"; then - vars="deplibs" - else - vars="compile_deplibs finalize_deplibs" - fi - for var in $vars dependency_libs; do - # Add libraries to $var in reverse order - eval tmp_libs=\"\$$var\" - new_libs= - for deplib in $tmp_libs; do - # FIXME: Pedantically, this is the right thing to do, so - # that some nasty dependency loop isn't accidentally - # broken: - #new_libs="$deplib $new_libs" - # Pragmatically, this seems to cause very few problems in - # practice: - case $deplib in - -L*) new_libs="$deplib $new_libs" ;; - -R*) ;; - *) - # And here is the reason: when a library appears more - # than once as an explicit dependence of a library, or - # is implicitly linked in more than once by the - # compiler, it is considered special, and multiple - # occurrences thereof are not removed. Compare this - # with having the same library being listed as a - # dependency of multiple other libraries: in this case, - # we know (pedantically, we assume) the library does not - # need to be listed more than once, so we keep only the - # last copy. This is not always right, but it is rare - # enough that we require users that really mean to play - # such unportable linking tricks to link the library - # using -Wl,-lname, so that libtool does not consider it - # for duplicate removal. - case " $specialdeplibs " in - *" $deplib "*) new_libs="$deplib $new_libs" ;; - *) - case " $new_libs " in - *" $deplib "*) ;; - *) new_libs="$deplib $new_libs" ;; - esac - ;; - esac - ;; - esac - done - tmp_libs= - for deplib in $new_libs; do - case $deplib in - -L*) - case " $tmp_libs " in - *" $deplib "*) ;; - *) tmp_libs="$tmp_libs $deplib" ;; - esac - ;; - *) tmp_libs="$tmp_libs $deplib" ;; - esac - done - eval $var=\"$tmp_libs\" - done # for var - fi - # Last step: remove runtime libs from dependency_libs - # (they stay in deplibs) - tmp_libs= - for i in $dependency_libs ; do - case " $predeps $postdeps $compiler_lib_search_path " in - *" $i "*) - i="" - ;; - esac - if test -n "$i" ; then - tmp_libs="$tmp_libs $i" - fi - done - dependency_libs=$tmp_libs - done # for pass - if test "$linkmode" = prog; then - dlfiles="$newdlfiles" - dlprefiles="$newdlprefiles" - fi - - case $linkmode in - oldlib) - if test -n "$deplibs"; then - $echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2 - fi - - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then - $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2 - fi - - if test -n "$rpath"; then - $echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2 - fi - - if test -n "$xrpath"; then - $echo "$modename: warning: \`-R' is ignored for archives" 1>&2 - fi - - if test -n "$vinfo"; then - $echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2 - fi - - if test -n "$release"; then - $echo "$modename: warning: \`-release' is ignored for archives" 1>&2 - fi - - if test -n "$export_symbols" || test -n "$export_symbols_regex"; then - $echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2 - fi - - # Now set the variables for building old libraries. - build_libtool_libs=no - oldlibs="$output" - objs="$objs$old_deplibs" - ;; - - lib) - # Make sure we only generate libraries of the form `libNAME.la'. - case $outputname in - lib*) - name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` - eval shared_ext=\"$shrext_cmds\" - eval libname=\"$libname_spec\" - ;; - *) - if test "$module" = no; then - $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2 - $echo "$help" 1>&2 - exit $EXIT_FAILURE - fi - if test "$need_lib_prefix" != no; then - # Add the "lib" prefix for modules if required - name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` - eval shared_ext=\"$shrext_cmds\" - eval libname=\"$libname_spec\" - else - libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` - fi - ;; - esac - - if test -n "$objs"; then - if test "$deplibs_check_method" != pass_all; then - $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1 - exit $EXIT_FAILURE - else - $echo - $echo "*** Warning: Linking the shared library $output against the non-libtool" - $echo "*** objects $objs is not portable!" - libobjs="$libobjs $objs" - fi - fi - - if test "$dlself" != no; then - $echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2 - fi - - set dummy $rpath - if test "$#" -gt 2; then - $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2 - fi - install_libdir="$2" - - oldlibs= - if test -z "$rpath"; then - if test "$build_libtool_libs" = yes; then - # Building a libtool convenience library. - # Some compilers have problems with a `.al' extension so - # convenience libraries should have the same extension an - # archive normally would. - oldlibs="$output_objdir/$libname.$libext $oldlibs" - build_libtool_libs=convenience - build_old_libs=yes - fi - - if test -n "$vinfo"; then - $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2 - fi - - if test -n "$release"; then - $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2 - fi - else - - # Parse the version information argument. - save_ifs="$IFS"; IFS=':' - set dummy $vinfo 0 0 0 - IFS="$save_ifs" - - if test -n "$8"; then - $echo "$modename: too many parameters to \`-version-info'" 1>&2 - $echo "$help" 1>&2 - exit $EXIT_FAILURE - fi - - # convert absolute version numbers to libtool ages - # this retains compatibility with .la files and attempts - # to make the code below a bit more comprehensible - - case $vinfo_number in - yes) - number_major="$2" - number_minor="$3" - number_revision="$4" - # - # There are really only two kinds -- those that - # use the current revision as the major version - # and those that subtract age and use age as - # a minor version. But, then there is irix - # which has an extra 1 added just for fun - # - case $version_type in - darwin|linux|osf|windows) - current=`expr $number_major + $number_minor` - age="$number_minor" - revision="$number_revision" - ;; - freebsd-aout|freebsd-elf|sunos) - current="$number_major" - revision="$number_minor" - age="0" - ;; - irix|nonstopux) - current=`expr $number_major + $number_minor - 1` - age="$number_minor" - revision="$number_minor" - ;; - esac - ;; - no) - current="$2" - revision="$3" - age="$4" - ;; - esac - - # Check that each of the things are valid numbers. - case $current in - 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; - *) - $echo "$modename: CURRENT \`$current' must be a nonnegative integer" 1>&2 - $echo "$modename: \`$vinfo' is not valid version information" 1>&2 - exit $EXIT_FAILURE - ;; - esac - - case $revision in - 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; - *) - $echo "$modename: REVISION \`$revision' must be a nonnegative integer" 1>&2 - $echo "$modename: \`$vinfo' is not valid version information" 1>&2 - exit $EXIT_FAILURE - ;; - esac - - case $age in - 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; - *) - $echo "$modename: AGE \`$age' must be a nonnegative integer" 1>&2 - $echo "$modename: \`$vinfo' is not valid version information" 1>&2 - exit $EXIT_FAILURE - ;; - esac - - if test "$age" -gt "$current"; then - $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2 - $echo "$modename: \`$vinfo' is not valid version information" 1>&2 - exit $EXIT_FAILURE - fi - - # Calculate the version variables. - major= - versuffix= - verstring= - case $version_type in - none) ;; - - darwin) - # Like Linux, but with the current version available in - # verstring for coding it into the library header - major=.`expr $current - $age` - versuffix="$major.$age.$revision" - # Darwin ld doesn't like 0 for these options... - minor_current=`expr $current + 1` - verstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" - ;; - - freebsd-aout) - major=".$current" - versuffix=".$current.$revision"; - ;; - - freebsd-elf) - major=".$current" - versuffix=".$current"; - ;; - - irix | nonstopux) - major=`expr $current - $age + 1` - - case $version_type in - nonstopux) verstring_prefix=nonstopux ;; - *) verstring_prefix=sgi ;; - esac - verstring="$verstring_prefix$major.$revision" - - # Add in all the interfaces that we are compatible with. - loop=$revision - while test "$loop" -ne 0; do - iface=`expr $revision - $loop` - loop=`expr $loop - 1` - verstring="$verstring_prefix$major.$iface:$verstring" - done - - # Before this point, $major must not contain `.'. - major=.$major - versuffix="$major.$revision" - ;; - - linux) - major=.`expr $current - $age` - versuffix="$major.$age.$revision" - ;; - - osf) - major=.`expr $current - $age` - versuffix=".$current.$age.$revision" - verstring="$current.$age.$revision" - - # Add in all the interfaces that we are compatible with. - loop=$age - while test "$loop" -ne 0; do - iface=`expr $current - $loop` - loop=`expr $loop - 1` - verstring="$verstring:${iface}.0" - done - - # Make executables depend on our current version. - verstring="$verstring:${current}.0" - ;; - - sunos) - major=".$current" - versuffix=".$current.$revision" - ;; - - windows) - # Use '-' rather than '.', since we only want one - # extension on DOS 8.3 filesystems. - major=`expr $current - $age` - versuffix="-$major" - ;; - - *) - $echo "$modename: unknown library version type \`$version_type'" 1>&2 - $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 - exit $EXIT_FAILURE - ;; - esac - - # Clear the version info if we defaulted, and they specified a release. - if test -z "$vinfo" && test -n "$release"; then - major= - case $version_type in - darwin) - # we can't check for "0.0" in archive_cmds due to quoting - # problems, so we reset it completely - verstring= - ;; - *) - verstring="0.0" - ;; - esac - if test "$need_version" = no; then - versuffix= - else - versuffix=".0.0" - fi - fi - - # Remove version info from name if versioning should be avoided - if test "$avoid_version" = yes && test "$need_version" = no; then - major= - versuffix= - verstring="" - fi - - # Check to see if the archive will have undefined symbols. - if test "$allow_undefined" = yes; then - if test "$allow_undefined_flag" = unsupported; then - $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2 - build_libtool_libs=no - build_old_libs=yes - fi - else - # Don't allow undefined symbols. - allow_undefined_flag="$no_undefined_flag" - fi - fi - - if test "$mode" != relink; then - # Remove our outputs, but don't remove object files since they - # may have been created when compiling PIC objects. - removelist= - tempremovelist=`$echo "$output_objdir/*"` - for p in $tempremovelist; do - case $p in - *.$objext) - ;; - $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) - if test "X$precious_files_regex" != "X"; then - if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 - then - continue - fi - fi - removelist="$removelist $p" - ;; - *) ;; - esac - done - if test -n "$removelist"; then - $show "${rm}r $removelist" - $run ${rm}r $removelist - fi - fi - - # Now set the variables for building old libraries. - if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then - oldlibs="$oldlibs $output_objdir/$libname.$libext" - - # Transform .lo files to .o files. - oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP` - fi - - # Eliminate all temporary directories. - for path in $notinst_path; do - lib_search_path=`$echo "$lib_search_path " | ${SED} -e 's% $path % %g'` - deplibs=`$echo "$deplibs " | ${SED} -e 's% -L$path % %g'` - dependency_libs=`$echo "$dependency_libs " | ${SED} -e 's% -L$path % %g'` - done - - if test -n "$xrpath"; then - # If the user specified any rpath flags, then add them. - temp_xrpath= - for libdir in $xrpath; do - temp_xrpath="$temp_xrpath -R$libdir" - case "$finalize_rpath " in - *" $libdir "*) ;; - *) finalize_rpath="$finalize_rpath $libdir" ;; - esac - done - if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then - dependency_libs="$temp_xrpath $dependency_libs" - fi - fi - - # Make sure dlfiles contains only unique files that won't be dlpreopened - old_dlfiles="$dlfiles" - dlfiles= - for lib in $old_dlfiles; do - case " $dlprefiles $dlfiles " in - *" $lib "*) ;; - *) dlfiles="$dlfiles $lib" ;; - esac - done - - # Make sure dlprefiles contains only unique files - old_dlprefiles="$dlprefiles" - dlprefiles= - for lib in $old_dlprefiles; do - case "$dlprefiles " in - *" $lib "*) ;; - *) dlprefiles="$dlprefiles $lib" ;; - esac - done - - if test "$build_libtool_libs" = yes; then - if test -n "$rpath"; then - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*) - # these systems don't actually have a c library (as such)! - ;; - *-*-rhapsody* | *-*-darwin1.[012]) - # Rhapsody C library is in the System framework - deplibs="$deplibs -framework System" - ;; - *-*-netbsd*) - # Don't link with libc until the a.out ld.so is fixed. - ;; - *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) - # Do not include libc due to us having libc/libc_r. - test "X$arg" = "X-lc" && continue - ;; - *) - # Add libc to deplibs on all other systems if necessary. - if test "$build_libtool_need_lc" = "yes"; then - deplibs="$deplibs -lc" - fi - ;; - esac - fi - - # Transform deplibs into only deplibs that can be linked in shared. - name_save=$name - libname_save=$libname - release_save=$release - versuffix_save=$versuffix - major_save=$major - # I'm not sure if I'm treating the release correctly. I think - # release should show up in the -l (ie -lgmp5) so we don't want to - # add it in twice. Is that correct? - release="" - versuffix="" - major="" - newdeplibs= - droppeddeps=no - case $deplibs_check_method in - pass_all) - # Don't check for shared/static. Everything works. - # This might be a little naive. We might want to check - # whether the library exists or not. But this is on - # osf3 & osf4 and I'm not really sure... Just - # implementing what was already the behavior. - newdeplibs=$deplibs - ;; - test_compile) - # This code stresses the "libraries are programs" paradigm to its - # limits. Maybe even breaks it. We compile a program, linking it - # against the deplibs as a proxy for the library. Then we can check - # whether they linked in statically or dynamically with ldd. - $rm conftest.c - cat > conftest.c </dev/null` - for potent_lib in $potential_libs; do - # Follow soft links. - if ls -lLd "$potent_lib" 2>/dev/null \ - | grep " -> " >/dev/null; then - continue - fi - # The statement above tries to avoid entering an - # endless loop below, in case of cyclic links. - # We might still enter an endless loop, since a link - # loop can be closed while we follow links, - # but so what? - potlib="$potent_lib" - while test -h "$potlib" 2>/dev/null; do - potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` - case $potliblink in - [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; - *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";; - esac - done - if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \ - | ${SED} 10q \ - | $EGREP "$file_magic_regex" > /dev/null; then - newdeplibs="$newdeplibs $a_deplib" - a_deplib="" - break 2 - fi - done - done - fi - if test -n "$a_deplib" ; then - droppeddeps=yes - $echo - $echo "*** Warning: linker path does not have real file for library $a_deplib." - $echo "*** I have the capability to make that library automatically link in when" - $echo "*** you link to this library. But I can only do this if you have a" - $echo "*** shared version of the library, which you do not appear to have" - $echo "*** because I did check the linker path looking for a file starting" - if test -z "$potlib" ; then - $echo "*** with $libname but no candidates were found. (...for file magic test)" - else - $echo "*** with $libname and none of the candidates passed a file format test" - $echo "*** using a file magic. Last file checked: $potlib" - fi - fi - else - # Add a -L argument. - newdeplibs="$newdeplibs $a_deplib" - fi - done # Gone through all deplibs. - ;; - match_pattern*) - set dummy $deplibs_check_method - match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"` - for a_deplib in $deplibs; do - name=`expr $a_deplib : '-l\(.*\)'` - # If $name is empty we are operating on a -L argument. - if test -n "$name" && test "$name" != "0"; then - if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then - case " $predeps $postdeps " in - *" $a_deplib "*) - newdeplibs="$newdeplibs $a_deplib" - a_deplib="" - ;; - esac - fi - if test -n "$a_deplib" ; then - libname=`eval \\$echo \"$libname_spec\"` - for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do - potential_libs=`ls $i/$libname[.-]* 2>/dev/null` - for potent_lib in $potential_libs; do - potlib="$potent_lib" # see symlink-check above in file_magic test - if eval $echo \"$potent_lib\" 2>/dev/null \ - | ${SED} 10q \ - | $EGREP "$match_pattern_regex" > /dev/null; then - newdeplibs="$newdeplibs $a_deplib" - a_deplib="" - break 2 - fi - done - done - fi - if test -n "$a_deplib" ; then - droppeddeps=yes - $echo - $echo "*** Warning: linker path does not have real file for library $a_deplib." - $echo "*** I have the capability to make that library automatically link in when" - $echo "*** you link to this library. But I can only do this if you have a" - $echo "*** shared version of the library, which you do not appear to have" - $echo "*** because I did check the linker path looking for a file starting" - if test -z "$potlib" ; then - $echo "*** with $libname but no candidates were found. (...for regex pattern test)" - else - $echo "*** with $libname and none of the candidates passed a file format test" - $echo "*** using a regex pattern. Last file checked: $potlib" - fi - fi - else - # Add a -L argument. - newdeplibs="$newdeplibs $a_deplib" - fi - done # Gone through all deplibs. - ;; - none | unknown | *) - newdeplibs="" - tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \ - -e 's/ -[LR][^ ]*//g'` - if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then - for i in $predeps $postdeps ; do - # can't use Xsed below, because $i might contain '/' - tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"` - done - fi - if $echo "X $tmp_deplibs" | $Xsed -e 's/[ ]//g' \ - | grep . >/dev/null; then - $echo - if test "X$deplibs_check_method" = "Xnone"; then - $echo "*** Warning: inter-library dependencies are not supported in this platform." - else - $echo "*** Warning: inter-library dependencies are not known to be supported." - fi - $echo "*** All declared inter-library dependencies are being dropped." - droppeddeps=yes - fi - ;; - esac - versuffix=$versuffix_save - major=$major_save - release=$release_save - libname=$libname_save - name=$name_save - - case $host in - *-*-rhapsody* | *-*-darwin1.[012]) - # On Rhapsody replace the C library is the System framework - newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'` - ;; - esac - - if test "$droppeddeps" = yes; then - if test "$module" = yes; then - $echo - $echo "*** Warning: libtool could not satisfy all declared inter-library" - $echo "*** dependencies of module $libname. Therefore, libtool will create" - $echo "*** a static module, that should work as long as the dlopening" - $echo "*** application is linked with the -dlopen flag." - if test -z "$global_symbol_pipe"; then - $echo - $echo "*** However, this would only work if libtool was able to extract symbol" - $echo "*** lists from a program, using \`nm' or equivalent, but libtool could" - $echo "*** not find such a program. So, this module is probably useless." - $echo "*** \`nm' from GNU binutils and a full rebuild may help." - fi - if test "$build_old_libs" = no; then - oldlibs="$output_objdir/$libname.$libext" - build_libtool_libs=module - build_old_libs=yes - else - build_libtool_libs=no - fi - else - $echo "*** The inter-library dependencies that have been dropped here will be" - $echo "*** automatically added whenever a program is linked with this library" - $echo "*** or is declared to -dlopen it." - - if test "$allow_undefined" = no; then - $echo - $echo "*** Since this library must not contain undefined symbols," - $echo "*** because either the platform does not support them or" - $echo "*** it was explicitly requested with -no-undefined," - $echo "*** libtool will only create a static version of it." - if test "$build_old_libs" = no; then - oldlibs="$output_objdir/$libname.$libext" - build_libtool_libs=module - build_old_libs=yes - else - build_libtool_libs=no - fi - fi - fi - fi - # Done checking deplibs! - deplibs=$newdeplibs - fi - - # All the library-specific variables (install_libdir is set above). - library_names= - old_library= - dlname= - - # Test again, we may have decided not to build it any more - if test "$build_libtool_libs" = yes; then - if test "$hardcode_into_libs" = yes; then - # Hardcode the library paths - hardcode_libdirs= - dep_rpath= - rpath="$finalize_rpath" - test "$mode" != relink && rpath="$compile_rpath$rpath" - for libdir in $rpath; do - if test -n "$hardcode_libdir_flag_spec"; then - if test -n "$hardcode_libdir_separator"; then - if test -z "$hardcode_libdirs"; then - hardcode_libdirs="$libdir" - else - # Just accumulate the unique libdirs. - case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) - ;; - *) - hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" - ;; - esac - fi - else - eval flag=\"$hardcode_libdir_flag_spec\" - dep_rpath="$dep_rpath $flag" - fi - elif test -n "$runpath_var"; then - case "$perm_rpath " in - *" $libdir "*) ;; - *) perm_rpath="$perm_rpath $libdir" ;; - esac - fi - done - # Substitute the hardcoded libdirs into the rpath. - if test -n "$hardcode_libdir_separator" && - test -n "$hardcode_libdirs"; then - libdir="$hardcode_libdirs" - if test -n "$hardcode_libdir_flag_spec_ld"; then - eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" - else - eval dep_rpath=\"$hardcode_libdir_flag_spec\" - fi - fi - if test -n "$runpath_var" && test -n "$perm_rpath"; then - # We should set the runpath_var. - rpath= - for dir in $perm_rpath; do - rpath="$rpath$dir:" - done - eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" - fi - test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" - fi - - shlibpath="$finalize_shlibpath" - test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath" - if test -n "$shlibpath"; then - eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" - fi - - # Get the real and link names of the library. - eval shared_ext=\"$shrext_cmds\" - eval library_names=\"$library_names_spec\" - set dummy $library_names - realname="$2" - shift; shift - - if test -n "$soname_spec"; then - eval soname=\"$soname_spec\" - else - soname="$realname" - fi - if test -z "$dlname"; then - dlname=$soname - fi - - lib="$output_objdir/$realname" - for link - do - linknames="$linknames $link" - done - - # Use standard objects if they are pic - test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` - - # Prepare the list of exported symbols - if test -z "$export_symbols"; then - if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then - $show "generating symbol list for \`$libname.la'" - export_symbols="$output_objdir/$libname.exp" - $run $rm $export_symbols - cmds=$export_symbols_cmds - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - if len=`expr "X$cmd" : ".*"` && - test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then - $show "$cmd" - $run eval "$cmd" || exit $? - skipped_export=false - else - # The command line is too long to execute in one step. - $show "using reloadable object file for export list..." - skipped_export=: - # Break out early, otherwise skipped_export may be - # set to false by a later but shorter cmd. - break - fi - done - IFS="$save_ifs" - if test -n "$export_symbols_regex"; then - $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\"" - $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' - $show "$mv \"${export_symbols}T\" \"$export_symbols\"" - $run eval '$mv "${export_symbols}T" "$export_symbols"' - fi - fi - fi - - if test -n "$export_symbols" && test -n "$include_expsyms"; then - $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"' - fi - - tmp_deplibs= - for test_deplib in $deplibs; do - case " $convenience " in - *" $test_deplib "*) ;; - *) - tmp_deplibs="$tmp_deplibs $test_deplib" - ;; - esac - done - deplibs="$tmp_deplibs" - - if test -n "$convenience"; then - if test -n "$whole_archive_flag_spec"; then - save_libobjs=$libobjs - eval libobjs=\"\$libobjs $whole_archive_flag_spec\" - else - gentop="$output_objdir/${outputname}x" - generated="$generated $gentop" - - func_extract_archives $gentop $convenience - libobjs="$libobjs $func_extract_archives_result" - fi - fi - - if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then - eval flag=\"$thread_safe_flag_spec\" - linker_flags="$linker_flags $flag" - fi - - # Make a backup of the uninstalled library when relinking - if test "$mode" = relink; then - $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $? - fi - - # Do each of the archive commands. - if test "$module" = yes && test -n "$module_cmds" ; then - if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then - eval test_cmds=\"$module_expsym_cmds\" - cmds=$module_expsym_cmds - else - eval test_cmds=\"$module_cmds\" - cmds=$module_cmds - fi - else - if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then - eval test_cmds=\"$archive_expsym_cmds\" - cmds=$archive_expsym_cmds - else - eval test_cmds=\"$archive_cmds\" - cmds=$archive_cmds - fi - fi - - if test "X$skipped_export" != "X:" && - len=`expr "X$test_cmds" : ".*" 2>/dev/null` && - test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then - : - else - # The command line is too long to link in one step, link piecewise. - $echo "creating reloadable object files..." - - # Save the value of $output and $libobjs because we want to - # use them later. If we have whole_archive_flag_spec, we - # want to use save_libobjs as it was before - # whole_archive_flag_spec was expanded, because we can't - # assume the linker understands whole_archive_flag_spec. - # This may have to be revisited, in case too many - # convenience libraries get linked in and end up exceeding - # the spec. - if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then - save_libobjs=$libobjs - fi - save_output=$output - output_la=`$echo "X$output" | $Xsed -e "$basename"` - - # Clear the reloadable object creation command queue and - # initialize k to one. - test_cmds= - concat_cmds= - objlist= - delfiles= - last_robj= - k=1 - output=$output_objdir/$output_la-${k}.$objext - # Loop over the list of objects to be linked. - for obj in $save_libobjs - do - eval test_cmds=\"$reload_cmds $objlist $last_robj\" - if test "X$objlist" = X || - { len=`expr "X$test_cmds" : ".*" 2>/dev/null` && - test "$len" -le "$max_cmd_len"; }; then - objlist="$objlist $obj" - else - # The command $test_cmds is almost too long, add a - # command to the queue. - if test "$k" -eq 1 ; then - # The first file doesn't have a previous command to add. - eval concat_cmds=\"$reload_cmds $objlist $last_robj\" - else - # All subsequent reloadable object files will link in - # the last one created. - eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\" - fi - last_robj=$output_objdir/$output_la-${k}.$objext - k=`expr $k + 1` - output=$output_objdir/$output_la-${k}.$objext - objlist=$obj - len=1 - fi - done - # Handle the remaining objects by creating one last - # reloadable object file. All subsequent reloadable object - # files will link in the last one created. - test -z "$concat_cmds" || concat_cmds=$concat_cmds~ - eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\" - - if ${skipped_export-false}; then - $show "generating symbol list for \`$libname.la'" - export_symbols="$output_objdir/$libname.exp" - $run $rm $export_symbols - libobjs=$output - # Append the command to create the export file. - eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\" - fi - - # Set up a command to remove the reloadable object files - # after they are used. - i=0 - while test "$i" -lt "$k" - do - i=`expr $i + 1` - delfiles="$delfiles $output_objdir/$output_la-${i}.$objext" - done - - $echo "creating a temporary reloadable object file: $output" - - # Loop through the commands generated above and execute them. - save_ifs="$IFS"; IFS='~' - for cmd in $concat_cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - - libobjs=$output - # Restore the value of output. - output=$save_output - - if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then - eval libobjs=\"\$libobjs $whole_archive_flag_spec\" - fi - # Expand the library linking commands again to reset the - # value of $libobjs for piecewise linking. - - # Do each of the archive commands. - if test "$module" = yes && test -n "$module_cmds" ; then - if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then - cmds=$module_expsym_cmds - else - cmds=$module_cmds - fi - else - if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then - cmds=$archive_expsym_cmds - else - cmds=$archive_cmds - fi - fi - - # Append the command to remove the reloadable object files - # to the just-reset $cmds. - eval cmds=\"\$cmds~\$rm $delfiles\" - fi - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - $show "$cmd" - $run eval "$cmd" || { - lt_exit=$? - - # Restore the uninstalled library and exit - if test "$mode" = relink; then - $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)' - fi - - exit $lt_exit - } - done - IFS="$save_ifs" - - # Restore the uninstalled library and exit - if test "$mode" = relink; then - $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $? - - if test -n "$convenience"; then - if test -z "$whole_archive_flag_spec"; then - $show "${rm}r $gentop" - $run ${rm}r "$gentop" - fi - fi - - exit $EXIT_SUCCESS - fi - - # Create links to the real library. - for linkname in $linknames; do - if test "$realname" != "$linkname"; then - $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)" - $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $? - fi - done - - # If -module or -export-dynamic was specified, set the dlname. - if test "$module" = yes || test "$export_dynamic" = yes; then - # On all known operating systems, these are identical. - dlname="$soname" - fi - fi - ;; - - obj) - if test -n "$deplibs"; then - $echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2 - fi - - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then - $echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2 - fi - - if test -n "$rpath"; then - $echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2 - fi - - if test -n "$xrpath"; then - $echo "$modename: warning: \`-R' is ignored for objects" 1>&2 - fi - - if test -n "$vinfo"; then - $echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2 - fi - - if test -n "$release"; then - $echo "$modename: warning: \`-release' is ignored for objects" 1>&2 - fi - - case $output in - *.lo) - if test -n "$objs$old_deplibs"; then - $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2 - exit $EXIT_FAILURE - fi - libobj="$output" - obj=`$echo "X$output" | $Xsed -e "$lo2o"` - ;; - *) - libobj= - obj="$output" - ;; - esac - - # Delete the old objects. - $run $rm $obj $libobj - - # Objects from convenience libraries. This assumes - # single-version convenience libraries. Whenever we create - # different ones for PIC/non-PIC, this we'll have to duplicate - # the extraction. - reload_conv_objs= - gentop= - # reload_cmds runs $LD directly, so let us get rid of - # -Wl from whole_archive_flag_spec - wl= - - if test -n "$convenience"; then - if test -n "$whole_archive_flag_spec"; then - eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\" - else - gentop="$output_objdir/${obj}x" - generated="$generated $gentop" - - func_extract_archives $gentop $convenience - reload_conv_objs="$reload_objs $func_extract_archives_result" - fi - fi - - # Create the old-style object. - reload_objs="$objs$old_deplibs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test - - output="$obj" - cmds=$reload_cmds - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - - # Exit if we aren't doing a library object file. - if test -z "$libobj"; then - if test -n "$gentop"; then - $show "${rm}r $gentop" - $run ${rm}r $gentop - fi - - exit $EXIT_SUCCESS - fi - - if test "$build_libtool_libs" != yes; then - if test -n "$gentop"; then - $show "${rm}r $gentop" - $run ${rm}r $gentop - fi - - # Create an invalid libtool object if no PIC, so that we don't - # accidentally link it into a program. - # $show "echo timestamp > $libobj" - # $run eval "echo timestamp > $libobj" || exit $? - exit $EXIT_SUCCESS - fi - - if test -n "$pic_flag" || test "$pic_mode" != default; then - # Only do commands if we really have different PIC objects. - reload_objs="$libobjs $reload_conv_objs" - output="$libobj" - cmds=$reload_cmds - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - fi - - if test -n "$gentop"; then - $show "${rm}r $gentop" - $run ${rm}r $gentop - fi - - exit $EXIT_SUCCESS - ;; - - prog) - case $host in - *cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;; - esac - if test -n "$vinfo"; then - $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2 - fi - - if test -n "$release"; then - $echo "$modename: warning: \`-release' is ignored for programs" 1>&2 - fi - - if test "$preload" = yes; then - if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown && - test "$dlopen_self_static" = unknown; then - $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support." - fi - fi - - case $host in - *-*-rhapsody* | *-*-darwin1.[012]) - # On Rhapsody replace the C library is the System framework - compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'` - finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'` - ;; - esac - - case $host in - *darwin*) - # Don't allow lazy linking, it breaks C++ global constructors - if test "$tagname" = CXX ; then - compile_command="$compile_command ${wl}-bind_at_load" - finalize_command="$finalize_command ${wl}-bind_at_load" - fi - ;; - esac - - compile_command="$compile_command $compile_deplibs" - finalize_command="$finalize_command $finalize_deplibs" - - if test -n "$rpath$xrpath"; then - # If the user specified any rpath flags, then add them. - for libdir in $rpath $xrpath; do - # This is the magic to use -rpath. - case "$finalize_rpath " in - *" $libdir "*) ;; - *) finalize_rpath="$finalize_rpath $libdir" ;; - esac - done - fi - - # Now hardcode the library paths - rpath= - hardcode_libdirs= - for libdir in $compile_rpath $finalize_rpath; do - if test -n "$hardcode_libdir_flag_spec"; then - if test -n "$hardcode_libdir_separator"; then - if test -z "$hardcode_libdirs"; then - hardcode_libdirs="$libdir" - else - # Just accumulate the unique libdirs. - case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) - ;; - *) - hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" - ;; - esac - fi - else - eval flag=\"$hardcode_libdir_flag_spec\" - rpath="$rpath $flag" - fi - elif test -n "$runpath_var"; then - case "$perm_rpath " in - *" $libdir "*) ;; - *) perm_rpath="$perm_rpath $libdir" ;; - esac - fi - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) - case :$dllsearchpath: in - *":$libdir:"*) ;; - *) dllsearchpath="$dllsearchpath:$libdir";; - esac - ;; - esac - done - # Substitute the hardcoded libdirs into the rpath. - if test -n "$hardcode_libdir_separator" && - test -n "$hardcode_libdirs"; then - libdir="$hardcode_libdirs" - eval rpath=\" $hardcode_libdir_flag_spec\" - fi - compile_rpath="$rpath" - - rpath= - hardcode_libdirs= - for libdir in $finalize_rpath; do - if test -n "$hardcode_libdir_flag_spec"; then - if test -n "$hardcode_libdir_separator"; then - if test -z "$hardcode_libdirs"; then - hardcode_libdirs="$libdir" - else - # Just accumulate the unique libdirs. - case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) - ;; - *) - hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" - ;; - esac - fi - else - eval flag=\"$hardcode_libdir_flag_spec\" - rpath="$rpath $flag" - fi - elif test -n "$runpath_var"; then - case "$finalize_perm_rpath " in - *" $libdir "*) ;; - *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;; - esac - fi - done - # Substitute the hardcoded libdirs into the rpath. - if test -n "$hardcode_libdir_separator" && - test -n "$hardcode_libdirs"; then - libdir="$hardcode_libdirs" - eval rpath=\" $hardcode_libdir_flag_spec\" - fi - finalize_rpath="$rpath" - - if test -n "$libobjs" && test "$build_old_libs" = yes; then - # Transform all the library objects into standard objects. - compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` - finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` - fi - - dlsyms= - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then - if test -n "$NM" && test -n "$global_symbol_pipe"; then - dlsyms="${outputname}S.c" - else - $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2 - fi - fi - - if test -n "$dlsyms"; then - case $dlsyms in - "") ;; - *.c) - # Discover the nlist of each of the dlfiles. - nlist="$output_objdir/${outputname}.nm" - - $show "$rm $nlist ${nlist}S ${nlist}T" - $run $rm "$nlist" "${nlist}S" "${nlist}T" - - # Parse the name list into a source file. - $show "creating $output_objdir/$dlsyms" - - test -z "$run" && $echo > "$output_objdir/$dlsyms" "\ -/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */ -/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */ - -#ifdef __cplusplus -extern \"C\" { -#endif - -/* Prevent the only kind of declaration conflicts we can make. */ -#define lt_preloaded_symbols some_other_symbol - -/* External symbol declarations for the compiler. */\ -" - - if test "$dlself" = yes; then - $show "generating symbol list for \`$output'" - - test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist" - - # Add our own program objects to the symbol list. - progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` - for arg in $progfiles; do - $show "extracting global C symbols from \`$arg'" - $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" - done - - if test -n "$exclude_expsyms"; then - $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' - $run eval '$mv "$nlist"T "$nlist"' - fi - - if test -n "$export_symbols_regex"; then - $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' - $run eval '$mv "$nlist"T "$nlist"' - fi - - # Prepare the list of exported symbols - if test -z "$export_symbols"; then - export_symbols="$output_objdir/$outputname.exp" - $run $rm $export_symbols - $run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' - else - $run eval "${SED} -e 's/\([ ][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' - $run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' - $run eval 'mv "$nlist"T "$nlist"' - fi - fi - - for arg in $dlprefiles; do - $show "extracting global C symbols from \`$arg'" - name=`$echo "$arg" | ${SED} -e 's%^.*/%%'` - $run eval '$echo ": $name " >> "$nlist"' - $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" - done - - if test -z "$run"; then - # Make sure we have at least an empty file. - test -f "$nlist" || : > "$nlist" - - if test -n "$exclude_expsyms"; then - $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T - $mv "$nlist"T "$nlist" - fi - - # Try sorting and uniquifying the output. - if grep -v "^: " < "$nlist" | - if sort -k 3 /dev/null 2>&1; then - sort -k 3 - else - sort +2 - fi | - uniq > "$nlist"S; then - : - else - grep -v "^: " < "$nlist" > "$nlist"S - fi - - if test -f "$nlist"S; then - eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"' - else - $echo '/* NONE */' >> "$output_objdir/$dlsyms" - fi - - $echo >> "$output_objdir/$dlsyms" "\ - -#undef lt_preloaded_symbols - -#if defined (__STDC__) && __STDC__ -# define lt_ptr void * -#else -# define lt_ptr char * -# define const -#endif - -/* The mapping between symbol names and symbols. */ -" - - case $host in - *cygwin* | *mingw* ) - $echo >> "$output_objdir/$dlsyms" "\ -/* DATA imports from DLLs on WIN32 can't be const, because - runtime relocations are performed -- see ld's documentation - on pseudo-relocs */ -struct { -" - ;; - * ) - $echo >> "$output_objdir/$dlsyms" "\ -const struct { -" - ;; - esac - - - $echo >> "$output_objdir/$dlsyms" "\ - const char *name; - lt_ptr address; -} -lt_preloaded_symbols[] = -{\ -" - - eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms" - - $echo >> "$output_objdir/$dlsyms" "\ - {0, (lt_ptr) 0} -}; - -/* This works around a problem in FreeBSD linker */ -#ifdef FREEBSD_WORKAROUND -static const void *lt_preloaded_setup() { - return lt_preloaded_symbols; -} -#endif - -#ifdef __cplusplus -} -#endif\ -" - fi - - pic_flag_for_symtable= - case $host in - # compiling the symbol table file with pic_flag works around - # a FreeBSD bug that causes programs to crash when -lm is - # linked before any other PIC object. But we must not use - # pic_flag when linking with -static. The problem exists in - # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. - *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) - case "$compile_command " in - *" -static "*) ;; - *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";; - esac;; - *-*-hpux*) - case "$compile_command " in - *" -static "*) ;; - *) pic_flag_for_symtable=" $pic_flag";; - esac - esac - - # Now compile the dynamic symbol file. - $show "(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")" - $run eval '(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $? - - # Clean up the generated files. - $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T" - $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T" - - # Transform the symbol file into the correct name. - compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` - finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` - ;; - *) - $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2 - exit $EXIT_FAILURE - ;; - esac - else - # We keep going just in case the user didn't refer to - # lt_preloaded_symbols. The linker will fail if global_symbol_pipe - # really was required. - - # Nullify the symbol file. - compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"` - finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` - fi - - if test "$need_relink" = no || test "$build_libtool_libs" != yes; then - # Replace the output file specification. - compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` - link_command="$compile_command$compile_rpath" - - # We have no uninstalled library dependencies, so finalize right now. - $show "$link_command" - $run eval "$link_command" - status=$? - - # Delete the generated files. - if test -n "$dlsyms"; then - $show "$rm $output_objdir/${outputname}S.${objext}" - $run $rm "$output_objdir/${outputname}S.${objext}" - fi - - exit $status - fi - - if test -n "$shlibpath_var"; then - # We should set the shlibpath_var - rpath= - for dir in $temp_rpath; do - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) - # Absolute path. - rpath="$rpath$dir:" - ;; - *) - # Relative path: add a thisdir entry. - rpath="$rpath\$thisdir/$dir:" - ;; - esac - done - temp_rpath="$rpath" - fi - - if test -n "$compile_shlibpath$finalize_shlibpath"; then - compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" - fi - if test -n "$finalize_shlibpath"; then - finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" - fi - - compile_var= - finalize_var= - if test -n "$runpath_var"; then - if test -n "$perm_rpath"; then - # We should set the runpath_var. - rpath= - for dir in $perm_rpath; do - rpath="$rpath$dir:" - done - compile_var="$runpath_var=\"$rpath\$$runpath_var\" " - fi - if test -n "$finalize_perm_rpath"; then - # We should set the runpath_var. - rpath= - for dir in $finalize_perm_rpath; do - rpath="$rpath$dir:" - done - finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " - fi - fi - - if test "$no_install" = yes; then - # We don't need to create a wrapper script. - link_command="$compile_var$compile_command$compile_rpath" - # Replace the output file specification. - link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` - # Delete the old output file. - $run $rm $output - # Link the executable and exit - $show "$link_command" - $run eval "$link_command" || exit $? - exit $EXIT_SUCCESS - fi - - if test "$hardcode_action" = relink; then - # Fast installation is not supported - link_command="$compile_var$compile_command$compile_rpath" - relink_command="$finalize_var$finalize_command$finalize_rpath" - - $echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2 - $echo "$modename: \`$output' will be relinked during installation" 1>&2 - else - if test "$fast_install" != no; then - link_command="$finalize_var$compile_command$finalize_rpath" - if test "$fast_install" = yes; then - relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'` - else - # fast_install is set to needless - relink_command= - fi - else - link_command="$compile_var$compile_command$compile_rpath" - relink_command="$finalize_var$finalize_command$finalize_rpath" - fi - fi - - # Replace the output file specification. - link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` - - # Delete the old output files. - $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname - - $show "$link_command" - $run eval "$link_command" || exit $? - - # Now create the wrapper script. - $show "creating $output" - - # Quote the relink command for shipping. - if test -n "$relink_command"; then - # Preserve any variables that may affect compiler behavior - for var in $variables_saved_for_relink; do - if eval test -z \"\${$var+set}\"; then - relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command" - elif eval var_value=\$$var; test -z "$var_value"; then - relink_command="$var=; export $var; $relink_command" - else - var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"` - relink_command="$var=\"$var_value\"; export $var; $relink_command" - fi - done - relink_command="(cd `pwd`; $relink_command)" - relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` - fi - - # Quote $echo for shipping. - if test "X$echo" = "X$SHELL $progpath --fallback-echo"; then - case $progpath in - [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";; - *) qecho="$SHELL `pwd`/$progpath --fallback-echo";; - esac - qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"` - else - qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"` - fi - - # Only actually do things if our run command is non-null. - if test -z "$run"; then - # win32 will think the script is a binary if it has - # a .exe suffix, so we strip it off here. - case $output in - *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;; - esac - # test for cygwin because mv fails w/o .exe extensions - case $host in - *cygwin*) - exeext=.exe - outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;; - *) exeext= ;; - esac - case $host in - *cygwin* | *mingw* ) - cwrappersource=`$echo ${objdir}/lt-${outputname}.c` - cwrapper=`$echo ${output}.exe` - $rm $cwrappersource $cwrapper - trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 - - cat > $cwrappersource <> $cwrappersource<<"EOF" -#include -#include -#include -#include -#include -#include - -#if defined(PATH_MAX) -# define LT_PATHMAX PATH_MAX -#elif defined(MAXPATHLEN) -# define LT_PATHMAX MAXPATHLEN -#else -# define LT_PATHMAX 1024 -#endif - -#ifndef DIR_SEPARATOR -#define DIR_SEPARATOR '/' -#endif - -#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ - defined (__OS2__) -#define HAVE_DOS_BASED_FILE_SYSTEM -#ifndef DIR_SEPARATOR_2 -#define DIR_SEPARATOR_2 '\\' -#endif -#endif - -#ifndef DIR_SEPARATOR_2 -# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) -#else /* DIR_SEPARATOR_2 */ -# define IS_DIR_SEPARATOR(ch) \ - (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) -#endif /* DIR_SEPARATOR_2 */ - -#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) -#define XFREE(stale) do { \ - if (stale) { free ((void *) stale); stale = 0; } \ -} while (0) - -const char *program_name = NULL; - -void * xmalloc (size_t num); -char * xstrdup (const char *string); -char * basename (const char *name); -char * fnqualify(const char *path); -char * strendzap(char *str, const char *pat); -void lt_fatal (const char *message, ...); - -int -main (int argc, char *argv[]) -{ - char **newargz; - int i; - - program_name = (char *) xstrdup ((char *) basename (argv[0])); - newargz = XMALLOC(char *, argc+2); -EOF - - cat >> $cwrappersource <> $cwrappersource <<"EOF" - newargz[1] = fnqualify(argv[0]); - /* we know the script has the same name, without the .exe */ - /* so make sure newargz[1] doesn't end in .exe */ - strendzap(newargz[1],".exe"); - for (i = 1; i < argc; i++) - newargz[i+1] = xstrdup(argv[i]); - newargz[argc+1] = NULL; -EOF - - cat >> $cwrappersource <> $cwrappersource <<"EOF" - return 127; -} - -void * -xmalloc (size_t num) -{ - void * p = (void *) malloc (num); - if (!p) - lt_fatal ("Memory exhausted"); - - return p; -} - -char * -xstrdup (const char *string) -{ - return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL -; -} - -char * -basename (const char *name) -{ - const char *base; - -#if defined (HAVE_DOS_BASED_FILE_SYSTEM) - /* Skip over the disk name in MSDOS pathnames. */ - if (isalpha (name[0]) && name[1] == ':') - name += 2; -#endif - - for (base = name; *name; name++) - if (IS_DIR_SEPARATOR (*name)) - base = name + 1; - return (char *) base; -} - -char * -fnqualify(const char *path) -{ - size_t size; - char *p; - char tmp[LT_PATHMAX + 1]; - - assert(path != NULL); - - /* Is it qualified already? */ -#if defined (HAVE_DOS_BASED_FILE_SYSTEM) - if (isalpha (path[0]) && path[1] == ':') - return xstrdup (path); -#endif - if (IS_DIR_SEPARATOR (path[0])) - return xstrdup (path); - - /* prepend the current directory */ - /* doesn't handle '~' */ - if (getcwd (tmp, LT_PATHMAX) == NULL) - lt_fatal ("getcwd failed"); - size = strlen(tmp) + 1 + strlen(path) + 1; /* +2 for '/' and '\0' */ - p = XMALLOC(char, size); - sprintf(p, "%s%c%s", tmp, DIR_SEPARATOR, path); - return p; -} - -char * -strendzap(char *str, const char *pat) -{ - size_t len, patlen; - - assert(str != NULL); - assert(pat != NULL); - - len = strlen(str); - patlen = strlen(pat); - - if (patlen <= len) - { - str += len - patlen; - if (strcmp(str, pat) == 0) - *str = '\0'; - } - return str; -} - -static void -lt_error_core (int exit_status, const char * mode, - const char * message, va_list ap) -{ - fprintf (stderr, "%s: %s: ", program_name, mode); - vfprintf (stderr, message, ap); - fprintf (stderr, ".\n"); - - if (exit_status >= 0) - exit (exit_status); -} - -void -lt_fatal (const char *message, ...) -{ - va_list ap; - va_start (ap, message); - lt_error_core (EXIT_FAILURE, "FATAL", message, ap); - va_end (ap); -} -EOF - # we should really use a build-platform specific compiler - # here, but OTOH, the wrappers (shell script and this C one) - # are only useful if you want to execute the "real" binary. - # Since the "real" binary is built for $host, then this - # wrapper might as well be built for $host, too. - $run $LTCC -s -o $cwrapper $cwrappersource - ;; - esac - $rm $output - trap "$rm $output; exit $EXIT_FAILURE" 1 2 15 - - $echo > $output "\ -#! $SHELL - -# $output - temporary wrapper script for $objdir/$outputname -# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP -# -# The $output program cannot be directly executed until all the libtool -# libraries that it depends on are installed. -# -# This wrapper script should never be moved out of the build directory. -# If it is, it will not operate correctly. - -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -Xsed='${SED} -e 1s/^X//' -sed_quote_subst='$sed_quote_subst' - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -relink_command=\"$relink_command\" - -# This environment variable determines our operation mode. -if test \"\$libtool_install_magic\" = \"$magic\"; then - # install mode needs the following variable: - notinst_deplibs='$notinst_deplibs' -else - # When we are sourced in execute mode, \$file and \$echo are already set. - if test \"\$libtool_execute_magic\" != \"$magic\"; then - echo=\"$qecho\" - file=\"\$0\" - # Make sure echo works. - if test \"X\$1\" = X--no-reexec; then - # Discard the --no-reexec flag, and continue. - shift - elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then - # Yippee, \$echo works! - : - else - # Restart under the correct shell, and then maybe \$echo will work. - exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"} - fi - fi\ -" - $echo >> $output "\ - - # Find the directory that this script lives in. - thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\` - test \"x\$thisdir\" = \"x\$file\" && thisdir=. - - # Follow symbolic links until we get to the real thisdir. - file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\` - while test -n \"\$file\"; do - destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\` - - # If there was a directory component, then change thisdir. - if test \"x\$destdir\" != \"x\$file\"; then - case \"\$destdir\" in - [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; - *) thisdir=\"\$thisdir/\$destdir\" ;; - esac - fi - - file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\` - file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\` - done - - # Try to get the absolute directory name. - absdir=\`cd \"\$thisdir\" && pwd\` - test -n \"\$absdir\" && thisdir=\"\$absdir\" -" - - if test "$fast_install" = yes; then - $echo >> $output "\ - program=lt-'$outputname'$exeext - progdir=\"\$thisdir/$objdir\" - - if test ! -f \"\$progdir/\$program\" || \\ - { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ - test \"X\$file\" != \"X\$progdir/\$program\"; }; then - - file=\"\$\$-\$program\" - - if test ! -d \"\$progdir\"; then - $mkdir \"\$progdir\" - else - $rm \"\$progdir/\$file\" - fi" - - $echo >> $output "\ - - # relink executable if necessary - if test -n \"\$relink_command\"; then - if relink_command_output=\`eval \$relink_command 2>&1\`; then : - else - $echo \"\$relink_command_output\" >&2 - $rm \"\$progdir/\$file\" - exit $EXIT_FAILURE - fi - fi - - $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || - { $rm \"\$progdir/\$program\"; - $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; } - $rm \"\$progdir/\$file\" - fi" - else - $echo >> $output "\ - program='$outputname' - progdir=\"\$thisdir/$objdir\" -" - fi - - $echo >> $output "\ - - if test -f \"\$progdir/\$program\"; then" - - # Export our shlibpath_var if we have one. - if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then - $echo >> $output "\ - # Add our own library path to $shlibpath_var - $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" - - # Some systems cannot cope with colon-terminated $shlibpath_var - # The second colon is a workaround for a bug in BeOS R4 sed - $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\` - - export $shlibpath_var -" - fi - - # fixup the dll searchpath if we need to. - if test -n "$dllsearchpath"; then - $echo >> $output "\ - # Add the dll search path components to the executable PATH - PATH=$dllsearchpath:\$PATH -" - fi - - $echo >> $output "\ - if test \"\$libtool_execute_magic\" != \"$magic\"; then - # Run the actual program with our arguments. -" - case $host in - # Backslashes separate directories on plain windows - *-*-mingw | *-*-os2*) - $echo >> $output "\ - exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} -" - ;; - - *) - $echo >> $output "\ - exec \"\$progdir/\$program\" \${1+\"\$@\"} -" - ;; - esac - $echo >> $output "\ - \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\" - exit $EXIT_FAILURE - fi - else - # The program doesn't exist. - \$echo \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 - \$echo \"This script is just a wrapper for \$program.\" 1>&2 - $echo \"See the $PACKAGE documentation for more information.\" 1>&2 - exit $EXIT_FAILURE - fi -fi\ -" - chmod +x $output - fi - exit $EXIT_SUCCESS - ;; - esac - - # See if we need to build an old-fashioned archive. - for oldlib in $oldlibs; do - - if test "$build_libtool_libs" = convenience; then - oldobjs="$libobjs_save" - addlibs="$convenience" - build_libtool_libs=no - else - if test "$build_libtool_libs" = module; then - oldobjs="$libobjs_save" - build_libtool_libs=no - else - oldobjs="$old_deplibs $non_pic_objects" - fi - addlibs="$old_convenience" - fi - - if test -n "$addlibs"; then - gentop="$output_objdir/${outputname}x" - generated="$generated $gentop" - - func_extract_archives $gentop $addlibs - oldobjs="$oldobjs $func_extract_archives_result" - fi - - # Do each command in the archive commands. - if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then - cmds=$old_archive_from_new_cmds - else - # POSIX demands no paths to be encoded in archives. We have - # to avoid creating archives with duplicate basenames if we - # might have to extract them afterwards, e.g., when creating a - # static archive out of a convenience library, or when linking - # the entirety of a libtool archive into another (currently - # not supported by libtool). - if (for obj in $oldobjs - do - $echo "X$obj" | $Xsed -e 's%^.*/%%' - done | sort | sort -uc >/dev/null 2>&1); then - : - else - $echo "copying selected object files to avoid basename conflicts..." - - if test -z "$gentop"; then - gentop="$output_objdir/${outputname}x" - generated="$generated $gentop" - - $show "${rm}r $gentop" - $run ${rm}r "$gentop" - $show "$mkdir $gentop" - $run $mkdir "$gentop" - status=$? - if test "$status" -ne 0 && test ! -d "$gentop"; then - exit $status - fi - fi - - save_oldobjs=$oldobjs - oldobjs= - counter=1 - for obj in $save_oldobjs - do - objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'` - case " $oldobjs " in - " ") oldobjs=$obj ;; - *[\ /]"$objbase "*) - while :; do - # Make sure we don't pick an alternate name that also - # overlaps. - newobj=lt$counter-$objbase - counter=`expr $counter + 1` - case " $oldobjs " in - *[\ /]"$newobj "*) ;; - *) if test ! -f "$gentop/$newobj"; then break; fi ;; - esac - done - $show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" - $run ln "$obj" "$gentop/$newobj" || - $run cp "$obj" "$gentop/$newobj" - oldobjs="$oldobjs $gentop/$newobj" - ;; - *) oldobjs="$oldobjs $obj" ;; - esac - done - fi - - eval cmds=\"$old_archive_cmds\" - - if len=`expr "X$cmds" : ".*"` && - test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then - cmds=$old_archive_cmds - else - # the command line is too long to link in one step, link in parts - $echo "using piecewise archive linking..." - save_RANLIB=$RANLIB - RANLIB=: - objlist= - concat_cmds= - save_oldobjs=$oldobjs - - # Is there a better way of finding the last object in the list? - for obj in $save_oldobjs - do - last_oldobj=$obj - done - for obj in $save_oldobjs - do - oldobjs="$objlist $obj" - objlist="$objlist $obj" - eval test_cmds=\"$old_archive_cmds\" - if len=`expr "X$test_cmds" : ".*" 2>/dev/null` && - test "$len" -le "$max_cmd_len"; then - : - else - # the above command should be used before it gets too long - oldobjs=$objlist - if test "$obj" = "$last_oldobj" ; then - RANLIB=$save_RANLIB - fi - test -z "$concat_cmds" || concat_cmds=$concat_cmds~ - eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" - objlist= - fi - done - RANLIB=$save_RANLIB - oldobjs=$objlist - if test "X$oldobjs" = "X" ; then - eval cmds=\"\$concat_cmds\" - else - eval cmds=\"\$concat_cmds~\$old_archive_cmds\" - fi - fi - fi - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - eval cmd=\"$cmd\" - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - done - - if test -n "$generated"; then - $show "${rm}r$generated" - $run ${rm}r$generated - fi - - # Now create the libtool archive. - case $output in - *.la) - old_library= - test "$build_old_libs" = yes && old_library="$libname.$libext" - $show "creating $output" - - # Preserve any variables that may affect compiler behavior - for var in $variables_saved_for_relink; do - if eval test -z \"\${$var+set}\"; then - relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command" - elif eval var_value=\$$var; test -z "$var_value"; then - relink_command="$var=; export $var; $relink_command" - else - var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"` - relink_command="$var=\"$var_value\"; export $var; $relink_command" - fi - done - # Quote the link command for shipping. - relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" - relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` - if test "$hardcode_automatic" = yes ; then - relink_command= - fi - - - # Only create the output if not a dry run. - if test -z "$run"; then - for installed in no yes; do - if test "$installed" = yes; then - if test -z "$install_libdir"; then - break - fi - output="$output_objdir/$outputname"i - # Replace all uninstalled libtool libraries with the installed ones - newdependency_libs= - for deplib in $dependency_libs; do - case $deplib in - *.la) - name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'` - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` - if test -z "$libdir"; then - $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 - exit $EXIT_FAILURE - fi - newdependency_libs="$newdependency_libs $libdir/$name" - ;; - *) newdependency_libs="$newdependency_libs $deplib" ;; - esac - done - dependency_libs="$newdependency_libs" - newdlfiles= - for lib in $dlfiles; do - name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` - if test -z "$libdir"; then - $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 - exit $EXIT_FAILURE - fi - newdlfiles="$newdlfiles $libdir/$name" - done - dlfiles="$newdlfiles" - newdlprefiles= - for lib in $dlprefiles; do - name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` - if test -z "$libdir"; then - $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 - exit $EXIT_FAILURE - fi - newdlprefiles="$newdlprefiles $libdir/$name" - done - dlprefiles="$newdlprefiles" - else - newdlfiles= - for lib in $dlfiles; do - case $lib in - [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; - *) abs=`pwd`"/$lib" ;; - esac - newdlfiles="$newdlfiles $abs" - done - dlfiles="$newdlfiles" - newdlprefiles= - for lib in $dlprefiles; do - case $lib in - [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; - *) abs=`pwd`"/$lib" ;; - esac - newdlprefiles="$newdlprefiles $abs" - done - dlprefiles="$newdlprefiles" - fi - $rm $output - # place dlname in correct position for cygwin - tdlname=$dlname - case $host,$output,$installed,$module,$dlname in - *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;; - esac - $echo > $output "\ -# $outputname - a libtool library file -# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP -# -# Please DO NOT delete this file! -# It is necessary for linking the library. - -# The name that we can dlopen(3). -dlname='$tdlname' - -# Names of this library. -library_names='$library_names' - -# The name of the static archive. -old_library='$old_library' - -# Libraries that this one depends upon. -dependency_libs='$dependency_libs' - -# Version information for $libname. -current=$current -age=$age -revision=$revision - -# Is this an already installed library? -installed=$installed - -# Should we warn about portability when linking against -modules? -shouldnotlink=$module - -# Files to dlopen/dlpreopen -dlopen='$dlfiles' -dlpreopen='$dlprefiles' - -# Directory that this library needs to be installed in: -libdir='$install_libdir'" - if test "$installed" = no && test "$need_relink" = yes; then - $echo >> $output "\ -relink_command=\"$relink_command\"" - fi - done - fi - - # Do a symbolic link so that the libtool archive can be found in - # LD_LIBRARY_PATH before the program is installed. - $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)" - $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $? - ;; - esac - exit $EXIT_SUCCESS - ;; - - # libtool install mode - install) - modename="$modename: install" - - # There may be an optional sh(1) argument at the beginning of - # install_prog (especially on Windows NT). - if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || - # Allow the use of GNU shtool's install command. - $echo "X$nonopt" | grep shtool > /dev/null; then - # Aesthetically quote it. - arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"` - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - arg="\"$arg\"" - ;; - esac - install_prog="$arg " - arg="$1" - shift - else - install_prog= - arg=$nonopt - fi - - # The real first argument should be the name of the installation program. - # Aesthetically quote it. - arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - arg="\"$arg\"" - ;; - esac - install_prog="$install_prog$arg" - - # We need to accept at least all the BSD install flags. - dest= - files= - opts= - prev= - install_type= - isdir=no - stripme= - for arg - do - if test -n "$dest"; then - files="$files $dest" - dest=$arg - continue - fi - - case $arg in - -d) isdir=yes ;; - -f) - case " $install_prog " in - *[\\\ /]cp\ *) ;; - *) prev=$arg ;; - esac - ;; - -g | -m | -o) prev=$arg ;; - -s) - stripme=" -s" - continue - ;; - -*) - ;; - *) - # If the previous option needed an argument, then skip it. - if test -n "$prev"; then - prev= - else - dest=$arg - continue - fi - ;; - esac - - # Aesthetically quote the argument. - arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - arg="\"$arg\"" - ;; - esac - install_prog="$install_prog $arg" - done - - if test -z "$install_prog"; then - $echo "$modename: you must specify an install program" 1>&2 - $echo "$help" 1>&2 - exit $EXIT_FAILURE - fi - - if test -n "$prev"; then - $echo "$modename: the \`$prev' option requires an argument" 1>&2 - $echo "$help" 1>&2 - exit $EXIT_FAILURE - fi - - if test -z "$files"; then - if test -z "$dest"; then - $echo "$modename: no file or destination specified" 1>&2 - else - $echo "$modename: you must specify a destination" 1>&2 - fi - $echo "$help" 1>&2 - exit $EXIT_FAILURE - fi - - # Strip any trailing slash from the destination. - dest=`$echo "X$dest" | $Xsed -e 's%/$%%'` - - # Check to see that the destination is a directory. - test -d "$dest" && isdir=yes - if test "$isdir" = yes; then - destdir="$dest" - destname= - else - destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'` - test "X$destdir" = "X$dest" && destdir=. - destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'` - - # Not a directory, so check to see that there is only one file specified. - set dummy $files - if test "$#" -gt 2; then - $echo "$modename: \`$dest' is not a directory" 1>&2 - $echo "$help" 1>&2 - exit $EXIT_FAILURE - fi - fi - case $destdir in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - for file in $files; do - case $file in - *.lo) ;; - *) - $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2 - $echo "$help" 1>&2 - exit $EXIT_FAILURE - ;; - esac - done - ;; - esac - - # This variable tells wrapper scripts just to set variables rather - # than running their programs. - libtool_install_magic="$magic" - - staticlibs= - future_libdirs= - current_libdirs= - for file in $files; do - - # Do each installation. - case $file in - *.$libext) - # Do the static libraries later. - staticlibs="$staticlibs $file" - ;; - - *.la) - # Check to see that this really is a libtool archive. - if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : - else - $echo "$modename: \`$file' is not a valid libtool archive" 1>&2 - $echo "$help" 1>&2 - exit $EXIT_FAILURE - fi - - library_names= - old_library= - relink_command= - # If there is no directory component, then add one. - case $file in - */* | *\\*) . $file ;; - *) . ./$file ;; - esac - - # Add the libdir to current_libdirs if it is the destination. - if test "X$destdir" = "X$libdir"; then - case "$current_libdirs " in - *" $libdir "*) ;; - *) current_libdirs="$current_libdirs $libdir" ;; - esac - else - # Note the libdir as a future libdir. - case "$future_libdirs " in - *" $libdir "*) ;; - *) future_libdirs="$future_libdirs $libdir" ;; - esac - fi - - dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/ - test "X$dir" = "X$file/" && dir= - dir="$dir$objdir" - - if test -n "$relink_command"; then - # Determine the prefix the user has applied to our future dir. - inst_prefix_dir=`$echo "$destdir" | $SED "s%$libdir\$%%"` - - # Don't allow the user to place us outside of our expected - # location b/c this prevents finding dependent libraries that - # are installed to the same prefix. - # At present, this check doesn't affect windows .dll's that - # are installed into $libdir/../bin (currently, that works fine) - # but it's something to keep an eye on. - if test "$inst_prefix_dir" = "$destdir"; then - $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2 - exit $EXIT_FAILURE - fi - - if test -n "$inst_prefix_dir"; then - # Stick the inst_prefix_dir data into the link command. - relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` - else - relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%%"` - fi - - $echo "$modename: warning: relinking \`$file'" 1>&2 - $show "$relink_command" - if $run eval "$relink_command"; then : - else - $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 - exit $EXIT_FAILURE - fi - fi - - # See the names of the shared library. - set dummy $library_names - if test -n "$2"; then - realname="$2" - shift - shift - - srcname="$realname" - test -n "$relink_command" && srcname="$realname"T - - # Install the shared library and build the symlinks. - $show "$install_prog $dir/$srcname $destdir/$realname" - $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $? - if test -n "$stripme" && test -n "$striplib"; then - $show "$striplib $destdir/$realname" - $run eval "$striplib $destdir/$realname" || exit $? - fi - - if test "$#" -gt 0; then - # Delete the old symlinks, and create new ones. - # Try `ln -sf' first, because the `ln' binary might depend on - # the symlink we replace! Solaris /bin/ln does not understand -f, - # so we also need to try rm && ln -s. - for linkname - do - if test "$linkname" != "$realname"; then - $show "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })" - $run eval "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })" - fi - done - fi - - # Do each command in the postinstall commands. - lib="$destdir/$realname" - cmds=$postinstall_cmds - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - $show "$cmd" - $run eval "$cmd" || { - lt_exit=$? - - # Restore the uninstalled library and exit - if test "$mode" = relink; then - $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)' - fi - - exit $lt_exit - } - done - IFS="$save_ifs" - fi - - # Install the pseudo-library for information purposes. - name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - instname="$dir/$name"i - $show "$install_prog $instname $destdir/$name" - $run eval "$install_prog $instname $destdir/$name" || exit $? - - # Maybe install the static library, too. - test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" - ;; - - *.lo) - # Install (i.e. copy) a libtool object. - - # Figure out destination file name, if it wasn't already specified. - if test -n "$destname"; then - destfile="$destdir/$destname" - else - destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - destfile="$destdir/$destfile" - fi - - # Deduce the name of the destination old-style object file. - case $destfile in - *.lo) - staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"` - ;; - *.$objext) - staticdest="$destfile" - destfile= - ;; - *) - $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2 - $echo "$help" 1>&2 - exit $EXIT_FAILURE - ;; - esac - - # Install the libtool object if requested. - if test -n "$destfile"; then - $show "$install_prog $file $destfile" - $run eval "$install_prog $file $destfile" || exit $? - fi - - # Install the old object if enabled. - if test "$build_old_libs" = yes; then - # Deduce the name of the old-style object file. - staticobj=`$echo "X$file" | $Xsed -e "$lo2o"` - - $show "$install_prog $staticobj $staticdest" - $run eval "$install_prog \$staticobj \$staticdest" || exit $? - fi - exit $EXIT_SUCCESS - ;; - - *) - # Figure out destination file name, if it wasn't already specified. - if test -n "$destname"; then - destfile="$destdir/$destname" - else - destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - destfile="$destdir/$destfile" - fi - - # If the file is missing, and there is a .exe on the end, strip it - # because it is most likely a libtool script we actually want to - # install - stripped_ext="" - case $file in - *.exe) - if test ! -f "$file"; then - file=`$echo $file|${SED} 's,.exe$,,'` - stripped_ext=".exe" - fi - ;; - esac - - # Do a test to see if this is really a libtool program. - case $host in - *cygwin*|*mingw*) - wrapper=`$echo $file | ${SED} -e 's,.exe$,,'` - ;; - *) - wrapper=$file - ;; - esac - if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then - notinst_deplibs= - relink_command= - - # Note that it is not necessary on cygwin/mingw to append a dot to - # foo even if both foo and FILE.exe exist: automatic-append-.exe - # behavior happens only for exec(3), not for open(2)! Also, sourcing - # `FILE.' does not work on cygwin managed mounts. - # - # If there is no directory component, then add one. - case $wrapper in - */* | *\\*) . ${wrapper} ;; - *) . ./${wrapper} ;; - esac - - # Check the variables that should have been set. - if test -z "$notinst_deplibs"; then - $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2 - exit $EXIT_FAILURE - fi - - finalize=yes - for lib in $notinst_deplibs; do - # Check to see that each library is installed. - libdir= - if test -f "$lib"; then - # If there is no directory component, then add one. - case $lib in - */* | *\\*) . $lib ;; - *) . ./$lib ;; - esac - fi - libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test - if test -n "$libdir" && test ! -f "$libfile"; then - $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2 - finalize=no - fi - done - - relink_command= - # Note that it is not necessary on cygwin/mingw to append a dot to - # foo even if both foo and FILE.exe exist: automatic-append-.exe - # behavior happens only for exec(3), not for open(2)! Also, sourcing - # `FILE.' does not work on cygwin managed mounts. - # - # If there is no directory component, then add one. - case $wrapper in - */* | *\\*) . ${wrapper} ;; - *) . ./${wrapper} ;; - esac - - outputname= - if test "$fast_install" = no && test -n "$relink_command"; then - if test "$finalize" = yes && test -z "$run"; then - tmpdir="/tmp" - test -n "$TMPDIR" && tmpdir="$TMPDIR" - tmpdir="$tmpdir/libtool-$$" - save_umask=`umask` - umask 0077 - if $mkdir "$tmpdir"; then - umask $save_umask - else - umask $save_umask - $echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2 - continue - fi - file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'` - outputname="$tmpdir/$file" - # Replace the output file specification. - relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'` - - $show "$relink_command" - if $run eval "$relink_command"; then : - else - $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 - ${rm}r "$tmpdir" - continue - fi - file="$outputname" - else - $echo "$modename: warning: cannot relink \`$file'" 1>&2 - fi - else - # Install the binary that we compiled earlier. - file=`$echo "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"` - fi - fi - - # remove .exe since cygwin /usr/bin/install will append another - # one anyway - case $install_prog,$host in - */usr/bin/install*,*cygwin*) - case $file:$destfile in - *.exe:*.exe) - # this is ok - ;; - *.exe:*) - destfile=$destfile.exe - ;; - *:*.exe) - destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'` - ;; - esac - ;; - esac - $show "$install_prog$stripme $file $destfile" - $run eval "$install_prog\$stripme \$file \$destfile" || exit $? - test -n "$outputname" && ${rm}r "$tmpdir" - ;; - esac - done - - for file in $staticlibs; do - name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - - # Set up the ranlib parameters. - oldlib="$destdir/$name" - - $show "$install_prog $file $oldlib" - $run eval "$install_prog \$file \$oldlib" || exit $? - - if test -n "$stripme" && test -n "$old_striplib"; then - $show "$old_striplib $oldlib" - $run eval "$old_striplib $oldlib" || exit $? - fi - - # Do each command in the postinstall commands. - cmds=$old_postinstall_cmds - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - done - - if test -n "$future_libdirs"; then - $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2 - fi - - if test -n "$current_libdirs"; then - # Maybe just do a dry run. - test -n "$run" && current_libdirs=" -n$current_libdirs" - exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' - else - exit $EXIT_SUCCESS - fi - ;; - - # libtool finish mode - finish) - modename="$modename: finish" - libdirs="$nonopt" - admincmds= - - if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then - for dir - do - libdirs="$libdirs $dir" - done - - for libdir in $libdirs; do - if test -n "$finish_cmds"; then - # Do each command in the finish commands. - cmds=$finish_cmds - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - $show "$cmd" - $run eval "$cmd" || admincmds="$admincmds - $cmd" - done - IFS="$save_ifs" - fi - if test -n "$finish_eval"; then - # Do the single finish_eval. - eval cmds=\"$finish_eval\" - $run eval "$cmds" || admincmds="$admincmds - $cmds" - fi - done - fi - - # Exit here if they wanted silent mode. - test "$show" = : && exit $EXIT_SUCCESS - - $echo "----------------------------------------------------------------------" - $echo "Libraries have been installed in:" - for libdir in $libdirs; do - $echo " $libdir" - done - $echo - $echo "If you ever happen to want to link against installed libraries" - $echo "in a given directory, LIBDIR, you must either use libtool, and" - $echo "specify the full pathname of the library, or use the \`-LLIBDIR'" - $echo "flag during linking and do at least one of the following:" - if test -n "$shlibpath_var"; then - $echo " - add LIBDIR to the \`$shlibpath_var' environment variable" - $echo " during execution" - fi - if test -n "$runpath_var"; then - $echo " - add LIBDIR to the \`$runpath_var' environment variable" - $echo " during linking" - fi - if test -n "$hardcode_libdir_flag_spec"; then - libdir=LIBDIR - eval flag=\"$hardcode_libdir_flag_spec\" - - $echo " - use the \`$flag' linker flag" - fi - if test -n "$admincmds"; then - $echo " - have your system administrator run these commands:$admincmds" - fi - if test -f /etc/ld.so.conf; then - $echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" - fi - $echo - $echo "See any operating system documentation about shared libraries for" - $echo "more information, such as the ld(1) and ld.so(8) manual pages." - $echo "----------------------------------------------------------------------" - exit $EXIT_SUCCESS - ;; - - # libtool execute mode - execute) - modename="$modename: execute" - - # The first argument is the command name. - cmd="$nonopt" - if test -z "$cmd"; then - $echo "$modename: you must specify a COMMAND" 1>&2 - $echo "$help" - exit $EXIT_FAILURE - fi - - # Handle -dlopen flags immediately. - for file in $execute_dlfiles; do - if test ! -f "$file"; then - $echo "$modename: \`$file' is not a file" 1>&2 - $echo "$help" 1>&2 - exit $EXIT_FAILURE - fi - - dir= - case $file in - *.la) - # Check to see that this really is a libtool archive. - if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : - else - $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 - $echo "$help" 1>&2 - exit $EXIT_FAILURE - fi - - # Read the libtool library. - dlname= - library_names= - - # If there is no directory component, then add one. - case $file in - */* | *\\*) . $file ;; - *) . ./$file ;; - esac - - # Skip this library if it cannot be dlopened. - if test -z "$dlname"; then - # Warn if it was a shared library. - test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'" - continue - fi - - dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` - test "X$dir" = "X$file" && dir=. - - if test -f "$dir/$objdir/$dlname"; then - dir="$dir/$objdir" - else - $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2 - exit $EXIT_FAILURE - fi - ;; - - *.lo) - # Just add the directory containing the .lo file. - dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` - test "X$dir" = "X$file" && dir=. - ;; - - *) - $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2 - continue - ;; - esac - - # Get the absolute pathname. - absdir=`cd "$dir" && pwd` - test -n "$absdir" && dir="$absdir" - - # Now add the directory to shlibpath_var. - if eval "test -z \"\$$shlibpath_var\""; then - eval "$shlibpath_var=\"\$dir\"" - else - eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" - fi - done - - # This variable tells wrapper scripts just to set shlibpath_var - # rather than running their programs. - libtool_execute_magic="$magic" - - # Check if any of the arguments is a wrapper script. - args= - for file - do - case $file in - -*) ;; - *) - # Do a test to see if this is really a libtool program. - if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then - # If there is no directory component, then add one. - case $file in - */* | *\\*) . $file ;; - *) . ./$file ;; - esac - - # Transform arg to wrapped name. - file="$progdir/$program" - fi - ;; - esac - # Quote arguments (to preserve shell metacharacters). - file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"` - args="$args \"$file\"" - done - - if test -z "$run"; then - if test -n "$shlibpath_var"; then - # Export the shlibpath_var. - eval "export $shlibpath_var" - fi - - # Restore saved environment variables - if test "${save_LC_ALL+set}" = set; then - LC_ALL="$save_LC_ALL"; export LC_ALL - fi - if test "${save_LANG+set}" = set; then - LANG="$save_LANG"; export LANG - fi - - # Now prepare to actually exec the command. - exec_cmd="\$cmd$args" - else - # Display what would be done. - if test -n "$shlibpath_var"; then - eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\"" - $echo "export $shlibpath_var" - fi - $echo "$cmd$args" - exit $EXIT_SUCCESS - fi - ;; - - # libtool clean and uninstall mode - clean | uninstall) - modename="$modename: $mode" - rm="$nonopt" - files= - rmforce= - exit_status=0 - - # This variable tells wrapper scripts just to set variables rather - # than running their programs. - libtool_install_magic="$magic" - - for arg - do - case $arg in - -f) rm="$rm $arg"; rmforce=yes ;; - -*) rm="$rm $arg" ;; - *) files="$files $arg" ;; - esac - done - - if test -z "$rm"; then - $echo "$modename: you must specify an RM program" 1>&2 - $echo "$help" 1>&2 - exit $EXIT_FAILURE - fi - - rmdirs= - - origobjdir="$objdir" - for file in $files; do - dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` - if test "X$dir" = "X$file"; then - dir=. - objdir="$origobjdir" - else - objdir="$dir/$origobjdir" - fi - name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - test "$mode" = uninstall && objdir="$dir" - - # Remember objdir for removal later, being careful to avoid duplicates - if test "$mode" = clean; then - case " $rmdirs " in - *" $objdir "*) ;; - *) rmdirs="$rmdirs $objdir" ;; - esac - fi - - # Don't error if the file doesn't exist and rm -f was used. - if (test -L "$file") >/dev/null 2>&1 \ - || (test -h "$file") >/dev/null 2>&1 \ - || test -f "$file"; then - : - elif test -d "$file"; then - exit_status=1 - continue - elif test "$rmforce" = yes; then - continue - fi - - rmfiles="$file" - - case $name in - *.la) - # Possibly a libtool archive, so verify it. - if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then - . $dir/$name - - # Delete the libtool libraries and symlinks. - for n in $library_names; do - rmfiles="$rmfiles $objdir/$n" - done - test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library" - test "$mode" = clean && rmfiles="$rmfiles $objdir/$name $objdir/${name}i" - - if test "$mode" = uninstall; then - if test -n "$library_names"; then - # Do each command in the postuninstall commands. - cmds=$postuninstall_cmds - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - $show "$cmd" - $run eval "$cmd" - if test "$?" -ne 0 && test "$rmforce" != yes; then - exit_status=1 - fi - done - IFS="$save_ifs" - fi - - if test -n "$old_library"; then - # Do each command in the old_postuninstall commands. - cmds=$old_postuninstall_cmds - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - $show "$cmd" - $run eval "$cmd" - if test "$?" -ne 0 && test "$rmforce" != yes; then - exit_status=1 - fi - done - IFS="$save_ifs" - fi - # FIXME: should reinstall the best remaining shared library. - fi - fi - ;; - - *.lo) - # Possibly a libtool object, so verify it. - if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then - - # Read the .lo file - . $dir/$name - - # Add PIC object to the list of files to remove. - if test -n "$pic_object" \ - && test "$pic_object" != none; then - rmfiles="$rmfiles $dir/$pic_object" - fi - - # Add non-PIC object to the list of files to remove. - if test -n "$non_pic_object" \ - && test "$non_pic_object" != none; then - rmfiles="$rmfiles $dir/$non_pic_object" - fi - fi - ;; - - *) - if test "$mode" = clean ; then - noexename=$name - case $file in - *.exe) - file=`$echo $file|${SED} 's,.exe$,,'` - noexename=`$echo $name|${SED} 's,.exe$,,'` - # $file with .exe has already been added to rmfiles, - # add $file without .exe - rmfiles="$rmfiles $file" - ;; - esac - # Do a test to see if this is a libtool program. - if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then - relink_command= - . $dir/$noexename - - # note $name still contains .exe if it was in $file originally - # as does the version of $file that was added into $rmfiles - rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}" - if test "$fast_install" = yes && test -n "$relink_command"; then - rmfiles="$rmfiles $objdir/lt-$name" - fi - if test "X$noexename" != "X$name" ; then - rmfiles="$rmfiles $objdir/lt-${noexename}.c" - fi - fi - fi - ;; - esac - $show "$rm $rmfiles" - $run $rm $rmfiles || exit_status=1 - done - objdir="$origobjdir" - - # Try to remove the ${objdir}s in the directories where we deleted files - for dir in $rmdirs; do - if test -d "$dir"; then - $show "rmdir $dir" - $run rmdir $dir >/dev/null 2>&1 - fi - done - - exit $exit_status - ;; - - "") - $echo "$modename: you must specify a MODE" 1>&2 - $echo "$generic_help" 1>&2 - exit $EXIT_FAILURE - ;; - esac - - if test -z "$exec_cmd"; then - $echo "$modename: invalid operation mode \`$mode'" 1>&2 - $echo "$generic_help" 1>&2 - exit $EXIT_FAILURE - fi -fi # test -z "$show_help" - -if test -n "$exec_cmd"; then - eval exec $exec_cmd - exit $EXIT_FAILURE -fi - -# We need to display help for each of the modes. -case $mode in -"") $echo \ -"Usage: $modename [OPTION]... [MODE-ARG]... - -Provide generalized library-building support services. - - --config show all configuration variables - --debug enable verbose shell tracing --n, --dry-run display commands without modifying any files - --features display basic configuration information and exit - --finish same as \`--mode=finish' - --help display this help message and exit - --mode=MODE use operation mode MODE [default=inferred from MODE-ARGS] - --quiet same as \`--silent' - --silent don't print informational messages - --tag=TAG use configuration variables from tag TAG - --version print version information - -MODE must be one of the following: - - clean remove files from the build directory - compile compile a source file into a libtool object - execute automatically set library path, then run a program - finish complete the installation of libtool libraries - install install libraries or executables - link create a library or an executable - uninstall remove libraries from an installed directory - -MODE-ARGS vary depending on the MODE. Try \`$modename --help --mode=MODE' for -a more detailed description of MODE. - -Report bugs to ." - exit $EXIT_SUCCESS - ;; - -clean) - $echo \ -"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE... - -Remove files from the build directory. - -RM is the name of the program to use to delete files associated with each FILE -(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed -to RM. - -If FILE is a libtool library, object or program, all the files associated -with it are deleted. Otherwise, only FILE itself is deleted using RM." - ;; - -compile) - $echo \ -"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE - -Compile a source file into a libtool library object. - -This mode accepts the following additional options: - - -o OUTPUT-FILE set the output file name to OUTPUT-FILE - -prefer-pic try to building PIC objects only - -prefer-non-pic try to building non-PIC objects only - -static always build a \`.o' file suitable for static linking - -COMPILE-COMMAND is a command to be used in creating a \`standard' object file -from the given SOURCEFILE. - -The output file name is determined by removing the directory component from -SOURCEFILE, then substituting the C source code suffix \`.c' with the -library object suffix, \`.lo'." - ;; - -execute) - $echo \ -"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]... - -Automatically set library path, then run a program. - -This mode accepts the following additional options: - - -dlopen FILE add the directory containing FILE to the library path - -This mode sets the library path environment variable according to \`-dlopen' -flags. - -If any of the ARGS are libtool executable wrappers, then they are translated -into their corresponding uninstalled binary, and any of their required library -directories are added to the library path. - -Then, COMMAND is executed, with ARGS as arguments." - ;; - -finish) - $echo \ -"Usage: $modename [OPTION]... --mode=finish [LIBDIR]... - -Complete the installation of libtool libraries. - -Each LIBDIR is a directory that contains libtool libraries. - -The commands that this mode executes may require superuser privileges. Use -the \`--dry-run' option if you just want to see what would be executed." - ;; - -install) - $echo \ -"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND... - -Install executables or libraries. - -INSTALL-COMMAND is the installation command. The first component should be -either the \`install' or \`cp' program. - -The rest of the components are interpreted as arguments to that command (only -BSD-compatible install options are recognized)." - ;; - -link) - $echo \ -"Usage: $modename [OPTION]... --mode=link LINK-COMMAND... - -Link object files or libraries together to form another library, or to -create an executable program. - -LINK-COMMAND is a command using the C compiler that you would use to create -a program from several object files. - -The following components of LINK-COMMAND are treated specially: - - -all-static do not do any dynamic linking at all - -avoid-version do not add a version suffix if possible - -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime - -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols - -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) - -export-symbols SYMFILE - try to export only the symbols listed in SYMFILE - -export-symbols-regex REGEX - try to export only the symbols matching REGEX - -LLIBDIR search LIBDIR for required installed libraries - -lNAME OUTPUT-FILE requires the installed library libNAME - -module build a library that can dlopened - -no-fast-install disable the fast-install mode - -no-install link a not-installable executable - -no-undefined declare that a library does not refer to external symbols - -o OUTPUT-FILE create OUTPUT-FILE from the specified objects - -objectlist FILE Use a list of object files found in FILE to specify objects - -precious-files-regex REGEX - don't remove output files matching REGEX - -release RELEASE specify package release information - -rpath LIBDIR the created library will eventually be installed in LIBDIR - -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries - -static do not do any dynamic linking of libtool libraries - -version-info CURRENT[:REVISION[:AGE]] - specify library version info [each variable defaults to 0] - -All other options (arguments beginning with \`-') are ignored. - -Every other argument is treated as a filename. Files ending in \`.la' are -treated as uninstalled libtool libraries, other files are standard or library -object files. - -If the OUTPUT-FILE ends in \`.la', then a libtool library is created, -only library objects (\`.lo' files) may be specified, and \`-rpath' is -required, except when creating a convenience library. - -If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created -using \`ar' and \`ranlib', or on Windows using \`lib'. - -If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file -is created, otherwise an executable program is created." - ;; - -uninstall) - $echo \ -"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... - -Remove libraries from an installation directory. - -RM is the name of the program to use to delete files associated with each FILE -(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed -to RM. - -If FILE is a libtool library, all the files associated with it are deleted. -Otherwise, only FILE itself is deleted using RM." - ;; - -*) - $echo "$modename: invalid operation mode \`$mode'" 1>&2 - $echo "$help" 1>&2 - exit $EXIT_FAILURE - ;; -esac - -$echo -$echo "Try \`$modename --help' for more information about other modes." - -exit $? - -# The TAGs below are defined such that we never get into a situation -# in which we disable both kinds of libraries. Given conflicting -# choices, we go for a static library, that is the most portable, -# since we can't tell whether shared libraries were disabled because -# the user asked for that or because the platform doesn't support -# them. This is particularly important on AIX, because we don't -# support having both static and shared libraries enabled at the same -# time on that platform, so we default to a shared-only configuration. -# If a disable-shared tag is given, we'll fallback to a static-only -# configuration. But we'll never go from static-only to shared-only. - -# ### BEGIN LIBTOOL TAG CONFIG: disable-shared -build_libtool_libs=no -build_old_libs=yes -# ### END LIBTOOL TAG CONFIG: disable-shared - -# ### BEGIN LIBTOOL TAG CONFIG: disable-static -build_old_libs=`case $build_libtool_libs in yes) $echo no;; *) $echo yes;; esac` -# ### END LIBTOOL TAG CONFIG: disable-static - -# Local Variables: -# mode:shell-script -# sh-indentation:2 -# End: diff --git a/libs/libdingaling/missing b/libs/libdingaling/missing deleted file mode 100644 index 894e786e16..0000000000 --- a/libs/libdingaling/missing +++ /dev/null @@ -1,360 +0,0 @@ -#! /bin/sh -# Common stub for a few missing GNU programs while installing. - -scriptversion=2005-06-08.21 - -# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005 -# Free Software Foundation, Inc. -# Originally by Fran,cois Pinard , 1996. - -# 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, or (at your option) -# any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -# 02110-1301, USA. - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -if test $# -eq 0; then - echo 1>&2 "Try \`$0 --help' for more information" - exit 1 -fi - -run=: - -# In the cases where this matters, `missing' is being run in the -# srcdir already. -if test -f configure.ac; then - configure_ac=configure.ac -else - configure_ac=configure.in -fi - -msg="missing on your system" - -case "$1" in ---run) - # Try to run requested program, and just exit if it succeeds. - run= - shift - "$@" && exit 0 - # Exit code 63 means version mismatch. This often happens - # when the user try to use an ancient version of a tool on - # a file that requires a minimum version. In this case we - # we should proceed has if the program had been absent, or - # if --run hadn't been passed. - if test $? = 63; then - run=: - msg="probably too old" - fi - ;; - - -h|--h|--he|--hel|--help) - echo "\ -$0 [OPTION]... PROGRAM [ARGUMENT]... - -Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an -error status if there is no known handling for PROGRAM. - -Options: - -h, --help display this help and exit - -v, --version output version information and exit - --run try to run the given command, and emulate it if it fails - -Supported PROGRAM values: - aclocal touch file \`aclocal.m4' - autoconf touch file \`configure' - autoheader touch file \`config.h.in' - automake touch all \`Makefile.in' files - bison create \`y.tab.[ch]', if possible, from existing .[ch] - flex create \`lex.yy.c', if possible, from existing .c - help2man touch the output file - lex create \`lex.yy.c', if possible, from existing .c - makeinfo touch the output file - tar try tar, gnutar, gtar, then tar without non-portable flags - yacc create \`y.tab.[ch]', if possible, from existing .[ch] - -Send bug reports to ." - exit $? - ;; - - -v|--v|--ve|--ver|--vers|--versi|--versio|--version) - echo "missing $scriptversion (GNU Automake)" - exit $? - ;; - - -*) - echo 1>&2 "$0: Unknown \`$1' option" - echo 1>&2 "Try \`$0 --help' for more information" - exit 1 - ;; - -esac - -# Now exit if we have it, but it failed. Also exit now if we -# don't have it and --version was passed (most likely to detect -# the program). -case "$1" in - lex|yacc) - # Not GNU programs, they don't have --version. - ;; - - tar) - if test -n "$run"; then - echo 1>&2 "ERROR: \`tar' requires --run" - exit 1 - elif test "x$2" = "x--version" || test "x$2" = "x--help"; then - exit 1 - fi - ;; - - *) - if test -z "$run" && ($1 --version) > /dev/null 2>&1; then - # We have it, but it failed. - exit 1 - elif test "x$2" = "x--version" || test "x$2" = "x--help"; then - # Could not run --version or --help. This is probably someone - # running `$TOOL --version' or `$TOOL --help' to check whether - # $TOOL exists and not knowing $TOOL uses missing. - exit 1 - fi - ;; -esac - -# If it does not exist, or fails to run (possibly an outdated version), -# try to emulate it. -case "$1" in - aclocal*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`acinclude.m4' or \`${configure_ac}'. You might want - to install the \`Automake' and \`Perl' packages. Grab them from - any GNU archive site." - touch aclocal.m4 - ;; - - autoconf) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`${configure_ac}'. You might want to install the - \`Autoconf' and \`GNU m4' packages. Grab them from any GNU - archive site." - touch configure - ;; - - autoheader) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`acconfig.h' or \`${configure_ac}'. You might want - to install the \`Autoconf' and \`GNU m4' packages. Grab them - from any GNU archive site." - files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` - test -z "$files" && files="config.h" - touch_files= - for f in $files; do - case "$f" in - *:*) touch_files="$touch_files "`echo "$f" | - sed -e 's/^[^:]*://' -e 's/:.*//'`;; - *) touch_files="$touch_files $f.in";; - esac - done - touch $touch_files - ;; - - automake*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. - You might want to install the \`Automake' and \`Perl' packages. - Grab them from any GNU archive site." - find . -type f -name Makefile.am -print | - sed 's/\.am$/.in/' | - while read f; do touch "$f"; done - ;; - - autom4te) - echo 1>&2 "\ -WARNING: \`$1' is needed, but is $msg. - You might have modified some files without having the - proper tools for further handling them. - You can get \`$1' as part of \`Autoconf' from any GNU - archive site." - - file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'` - test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'` - if test -f "$file"; then - touch $file - else - test -z "$file" || exec >$file - echo "#! /bin/sh" - echo "# Created by GNU Automake missing as a replacement of" - echo "# $ $@" - echo "exit 0" - chmod +x $file - exit 1 - fi - ;; - - bison|yacc) - echo 1>&2 "\ -WARNING: \`$1' $msg. You should only need it if - you modified a \`.y' file. You may need the \`Bison' package - in order for those modifications to take effect. You can get - \`Bison' from any GNU archive site." - rm -f y.tab.c y.tab.h - if [ $# -ne 1 ]; then - eval LASTARG="\${$#}" - case "$LASTARG" in - *.y) - SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` - if [ -f "$SRCFILE" ]; then - cp "$SRCFILE" y.tab.c - fi - SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` - if [ -f "$SRCFILE" ]; then - cp "$SRCFILE" y.tab.h - fi - ;; - esac - fi - if [ ! -f y.tab.h ]; then - echo >y.tab.h - fi - if [ ! -f y.tab.c ]; then - echo 'main() { return 0; }' >y.tab.c - fi - ;; - - lex|flex) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified a \`.l' file. You may need the \`Flex' package - in order for those modifications to take effect. You can get - \`Flex' from any GNU archive site." - rm -f lex.yy.c - if [ $# -ne 1 ]; then - eval LASTARG="\${$#}" - case "$LASTARG" in - *.l) - SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` - if [ -f "$SRCFILE" ]; then - cp "$SRCFILE" lex.yy.c - fi - ;; - esac - fi - if [ ! -f lex.yy.c ]; then - echo 'main() { return 0; }' >lex.yy.c - fi - ;; - - help2man) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified a dependency of a manual page. You may need the - \`Help2man' package in order for those modifications to take - effect. You can get \`Help2man' from any GNU archive site." - - file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` - if test -z "$file"; then - file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'` - fi - if [ -f "$file" ]; then - touch $file - else - test -z "$file" || exec >$file - echo ".ab help2man is required to generate this page" - exit 1 - fi - ;; - - makeinfo) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified a \`.texi' or \`.texinfo' file, or any other file - indirectly affecting the aspect of the manual. The spurious - call might also be the consequence of using a buggy \`make' (AIX, - DU, IRIX). You might want to install the \`Texinfo' package or - the \`GNU make' package. Grab either from any GNU archive site." - # The file to touch is that specified with -o ... - file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` - if test -z "$file"; then - # ... or it is the one specified with @setfilename ... - infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` - file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile` - # ... or it is derived from the source name (dir/f.texi becomes f.info) - test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info - fi - # If the file does not exist, the user really needs makeinfo; - # let's fail without touching anything. - test -f $file || exit 1 - touch $file - ;; - - tar) - shift - - # We have already tried tar in the generic part. - # Look for gnutar/gtar before invocation to avoid ugly error - # messages. - if (gnutar --version > /dev/null 2>&1); then - gnutar "$@" && exit 0 - fi - if (gtar --version > /dev/null 2>&1); then - gtar "$@" && exit 0 - fi - firstarg="$1" - if shift; then - case "$firstarg" in - *o*) - firstarg=`echo "$firstarg" | sed s/o//` - tar "$firstarg" "$@" && exit 0 - ;; - esac - case "$firstarg" in - *h*) - firstarg=`echo "$firstarg" | sed s/h//` - tar "$firstarg" "$@" && exit 0 - ;; - esac - fi - - echo 1>&2 "\ -WARNING: I can't seem to be able to run \`tar' with the given arguments. - You may want to install GNU tar or Free paxutils, or check the - command line arguments." - exit 1 - ;; - - *) - echo 1>&2 "\ -WARNING: \`$1' is needed, and is $msg. - You might have modified some files without having the - proper tools for further handling them. Check the \`README' file, - it often tells you about the needed prerequisites for installing - this package. You may also peek at any GNU archive site, in case - some other package would contain this missing \`$1' program." - exit 1 - ;; -esac - -exit 0 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-end: "$" -# End: diff --git a/libs/libdingaling/mkinstalldirs b/libs/libdingaling/mkinstalldirs deleted file mode 100644 index 259dbfcd35..0000000000 --- a/libs/libdingaling/mkinstalldirs +++ /dev/null @@ -1,158 +0,0 @@ -#! /bin/sh -# mkinstalldirs --- make directory hierarchy - -scriptversion=2005-06-29.22 - -# Original author: Noah Friedman -# Created: 1993-05-16 -# Public domain. -# -# This file is maintained in Automake, please report -# bugs to or send patches to -# . - -errstatus=0 -dirmode= - -usage="\ -Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ... - -Create each directory DIR (with mode MODE, if specified), including all -leading file name components. - -Report bugs to ." - -# process command line arguments -while test $# -gt 0 ; do - case $1 in - -h | --help | --h*) # -h for help - echo "$usage" - exit $? - ;; - -m) # -m PERM arg - shift - test $# -eq 0 && { echo "$usage" 1>&2; exit 1; } - dirmode=$1 - shift - ;; - --version) - echo "$0 $scriptversion" - exit $? - ;; - --) # stop option processing - shift - break - ;; - -*) # unknown option - echo "$usage" 1>&2 - exit 1 - ;; - *) # first non-opt arg - break - ;; - esac -done - -for file -do - if test -d "$file"; then - shift - else - break - fi -done - -case $# in - 0) exit 0 ;; -esac - -# Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and -# mkdir -p a/c at the same time, both will detect that a is missing, -# one will create a, then the other will try to create a and die with -# a "File exists" error. This is a problem when calling mkinstalldirs -# from a parallel make. We use --version in the probe to restrict -# ourselves to GNU mkdir, which is thread-safe. -case $dirmode in - '') - if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then - echo "mkdir -p -- $*" - exec mkdir -p -- "$@" - else - # On NextStep and OpenStep, the `mkdir' command does not - # recognize any option. It will interpret all options as - # directories to create, and then abort because `.' already - # exists. - test -d ./-p && rmdir ./-p - test -d ./--version && rmdir ./--version - fi - ;; - *) - if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 && - test ! -d ./--version; then - echo "mkdir -m $dirmode -p -- $*" - exec mkdir -m "$dirmode" -p -- "$@" - else - # Clean up after NextStep and OpenStep mkdir. - for d in ./-m ./-p ./--version "./$dirmode"; - do - test -d $d && rmdir $d - done - fi - ;; -esac - -for file -do - case $file in - /*) pathcomp=/ ;; - *) pathcomp= ;; - esac - oIFS=$IFS - IFS=/ - set fnord $file - shift - IFS=$oIFS - - for d - do - test "x$d" = x && continue - - pathcomp=$pathcomp$d - case $pathcomp in - -*) pathcomp=./$pathcomp ;; - esac - - if test ! -d "$pathcomp"; then - echo "mkdir $pathcomp" - - mkdir "$pathcomp" || lasterr=$? - - if test ! -d "$pathcomp"; then - errstatus=$lasterr - else - if test ! -z "$dirmode"; then - echo "chmod $dirmode $pathcomp" - lasterr= - chmod "$dirmode" "$pathcomp" || lasterr=$? - - if test ! -z "$lasterr"; then - errstatus=$lasterr - fi - fi - fi - fi - - pathcomp=$pathcomp/ - done -done - -exit $errstatus - -# Local Variables: -# mode: shell-script -# sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-end: "$" -# End: diff --git a/libs/libdingaling/src/dingaling.def b/libs/libdingaling/src/dingaling.def deleted file mode 100644 index 16102267e1..0000000000 --- a/libs/libdingaling/src/dingaling.def +++ /dev/null @@ -1,30 +0,0 @@ -EXPORTS -ldl_session_get_caller -ldl_session_get_ip -ldl_session_set_private -ldl_session_get_private -ldl_session_terminate -ldl_handle_get_private -ldl_session_candidates -ldl_session_describe -ldl_session_get_state -ldl_session_get_candidates -ldl_session_get_payloads -ldl_global_init -ldl_global_destroy -ldl_global_set_log_stream -ldl_handle_init -ldl_handle_run -ldl_handle_destroy -ldl_handle_set_log_stream -ldl_session_create -ldl_handle_probe -ldl_handle_ready -ldl_session_get_id -ldl_session_set_ip -ldl_global_set_logger -ldl_handle_send_msg -ldl_session_get_value -ldl_session_set_value -ldl_session_accept_candidate -ldl_session_send_msg \ No newline at end of file diff --git a/libs/libdingaling/src/libdingaling.c b/libs/libdingaling/src/libdingaling.c deleted file mode 100644 index 6fbedfda6e..0000000000 --- a/libs/libdingaling/src/libdingaling.c +++ /dev/null @@ -1,3296 +0,0 @@ -/* - * libDingaLing XMPP Jingle Library - * Copyright (C) 2005-2014, Anthony Minessale II - * - * Version: MPL 1.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is libDingaLing XMPP Jingle Library - * - * The Initial Developer of the Original Code is - * Anthony Minessale II - * Portions created by the Initial Developer are Copyright (C) - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Anthony Minessale II - * - * libdingaling.c -- Main Library Code - * - * QMOD: XMPP Video Signaling + Presentation (video-v1 & camera-v1) - * - */ - - -#ifndef _MSC_VER -#include -#include -#include -#include -#include -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#define APR_WANT_STDIO -#define APR_WANT_STRFUNC -#include -#include - -#include "ldl_compat.h" -#include "libdingaling.h" -#include "sha1.h" - -#ifdef _MSC_VER -#include -#pragma warning(disable:4127 4706) -#endif - -#define microsleep(x) apr_sleep(x * 1000) -#define LDL_CAPS_VER "1.0.0.1" - -static int opt_timeout = 30; - -static void sha1_hash(char *out, unsigned char *in, unsigned int len); -static int b64encode(unsigned char *in, size_t ilen, unsigned char *out, size_t olen); -static void ldl_random_string(char *buf, uint16_t len, char *set); - -static struct { - unsigned int flags; - FILE *log_stream; - int debug; - apr_pool_t *memory_pool; - unsigned int id; - ldl_logger_t logger; - apr_hash_t *avatar_hash; - apr_thread_mutex_t *flag_mutex; -} globals; - -struct packet_node { - char id[80]; - iks *xml; - unsigned int retries; - apr_time_t next; -}; - -struct ldl_buffer { - char *buf; - unsigned int len; - int hit; -}; - -typedef enum { - CS_NEW, - CS_START, - CS_CONNECTED -} ldl_handle_state_t; - -struct ldl_handle { - iksparser *parser; - iksid *acc; - iksfilter *filter; - char *login; - char *password; - char *server; - char *status_msg; - char *priority; - uint16_t port; - int features; - int counter; - int job_done; - unsigned int flags; - apr_queue_t *queue; - apr_queue_t *retry_queue; - apr_hash_t *sessions; - apr_hash_t *retry_hash; - apr_hash_t *probe_hash; - apr_hash_t *sub_hash; - apr_thread_mutex_t *lock; - apr_thread_mutex_t *flag_mutex; - ldl_loop_callback_t loop_callback; - ldl_session_callback_t session_callback; - ldl_response_callback_t response_callback; - apr_pool_t *pool; - void *private_info; - FILE *log_stream; - ldl_handle_state_t state; - int fail_count; -}; - -struct ldl_session { - ldl_state_t state; - ldl_handle_t *handle; - char *id; - char *initiator; - char *them; - char *ip; - char *login; - ldl_payload_t payloads[LDL_MAX_PAYLOADS]; - unsigned int payload_len; - /*! \brief Transport candidates, organized per type */ - ldl_candidate_t candidates[LDL_TPORT_MAX][LDL_MAX_CANDIDATES]; - /*! \brief Length of the candidate list, per transport type */ - unsigned int candidate_len[LDL_TPORT_MAX]; - apr_pool_t *pool; - apr_hash_t *variables; - apr_time_t created; - void *private_data; - ldl_user_flag_t flags; -}; - -static int on_disco_default(void *user_data, ikspak *pak); -static int on_vcard(void *user_data, ikspak *pak); -typedef int (*iks_filter_callback_t)(void *user_data, ikspak *pak); - -struct ldl_feature { - const char *name; - iks_filter_callback_t callback; -}; -typedef struct ldl_feature ldl_feature_t; - -#define FEATURE_DISCO "http://jabber.org/protocol/disco" -#define FEATURE_DISCO_INFO "http://jabber.org/protocol/disco#info" -#define FEATURE_VERSION "jabber:iq:version" -#define FEATURE_VCARD "vcard-temp" -#define FEATURE_VOICE "http://www.google.com/xmpp/protocol/voice/v1" -#define FEATURE_VIDEO "http://www.google.com/xmpp/protocol/video/v1" -#define FEATURE_CAMERA "http://www.google.com/xmpp/protocol/camera/v1" -#define FEATURE_LAST "jabber:iq:last" - -static ldl_feature_t FEATURES[] = { - { FEATURE_DISCO, on_disco_default }, - { FEATURE_DISCO_INFO, on_disco_default }, - { FEATURE_VERSION, on_disco_default }, - { FEATURE_VCARD, on_vcard}, - { FEATURE_VOICE, on_disco_default }, - { FEATURE_VIDEO, on_disco_default }, - { FEATURE_CAMERA, on_disco_default }, - { FEATURE_LAST, on_disco_default }, - { NULL, NULL} -}; - - -struct ldl_avatar { - char *path; - char *base64; - char hash[256]; -}; - -typedef struct ldl_avatar ldl_avatar_t; - - -static void lowercase(char *str) -{ - size_t x = 0; - - if (str) { - for (x = 0; x < strlen(str); x++) { - str[x] = (char)tolower((int)str[x]); - } - } -} - -static char *cut_path(char *in) -{ - char *p, *ret = in; - char delims[] = "/\\"; - char *i; - - for (i = delims; *i; i++) { - p = in; - while ((p = strchr(p, *i)) != 0) { - ret = ++p; - } - } - return ret; -} - -static void default_logger(char *file, const char *func, int line, int level, char *fmt, ...) -{ - char *fp; - char data[1024]; - - va_list ap; - - fp = cut_path(file); - - va_start(ap, fmt); - - vsnprintf(data, sizeof(data), fmt, ap); - - fprintf(globals.log_stream, "%s:%d %s() %s", fp, line, func, data); - - va_end(ap); - -} - -static unsigned int next_id(void) -{ - return globals.id++; -} - -static char *iks_name_nons(iks *x) -{ - char *r = iks_name(x); - char *p; - - if (r && (p = strchr(r, ':'))) { - r = p + 1; - } - - return r; -} - - -char *ldl_session_get_value(ldl_session_t *session, char *key) -{ - return apr_hash_get(session->variables, key, APR_HASH_KEY_STRING); -} - -void ldl_session_set_value(ldl_session_t *session, const char *key, const char *val) -{ - apr_hash_set(session->variables, apr_pstrdup(session->pool, key), APR_HASH_KEY_STRING, apr_pstrdup(session->pool, val)); -} - -char *ldl_session_get_id(ldl_session_t *session) -{ - return session->id; -} - -void ldl_session_send_msg(ldl_session_t *session, char *subject, char *body) -{ - ldl_handle_send_msg(session->handle, session->login, session->them, subject, body); -} - -ldl_status ldl_session_destroy(ldl_session_t **session_p) -{ - ldl_session_t *session = *session_p; - - if (session) { - apr_pool_t *pool = session->pool; - apr_hash_t *hash = session->handle->sessions; - - if (globals.debug) { - globals.logger(DL_LOG_CRIT, "Destroyed Session %s\n", session->id); - } - - if (session->id) { - apr_hash_set(hash, session->id, APR_HASH_KEY_STRING, NULL); - } - - if (session->them) { - apr_hash_set(hash, session->them, APR_HASH_KEY_STRING, NULL); - } - - apr_pool_destroy(pool); - pool = NULL; - *session_p = NULL; - return LDL_STATUS_SUCCESS; - } - - return LDL_STATUS_FALSE; -} - - -ldl_status ldl_session_create(ldl_session_t **session_p, ldl_handle_t *handle, char *id, char *them, char *me, ldl_user_flag_t flags) -{ - ldl_session_t *session = NULL; - - if (!(session = apr_palloc(handle->pool, sizeof(ldl_session_t)))) { - globals.logger(DL_LOG_CRIT, "Memory ERROR!\n"); - *session_p = NULL; - return LDL_STATUS_MEMERR; - } - memset(session, 0, sizeof(ldl_session_t)); - apr_pool_create(&session->pool, globals.memory_pool); - session->id = apr_pstrdup(session->pool, id); - session->them = apr_pstrdup(session->pool, them); - - if (flags & LDL_FLAG_OUTBOUND) { - session->initiator = apr_pstrdup(session->pool, me); - } - - if (ldl_test_flag(handle, LDL_FLAG_COMPONENT)) { - session->login = apr_pstrdup(session->pool, me); - } else { - session->login = apr_pstrdup(session->pool, handle->login); - } - - apr_hash_set(handle->sessions, session->id, APR_HASH_KEY_STRING, session); - apr_hash_set(handle->sessions, session->them, APR_HASH_KEY_STRING, session); - session->handle = handle; - session->created = apr_time_now(); - session->state = LDL_STATE_NEW; - session->variables = apr_hash_make(session->pool); - session->flags = flags; - *session_p = session; - - - if (globals.debug) { - globals.logger(DL_LOG_CRIT, "Created Session %s\n", id); - } - - return LDL_STATUS_SUCCESS; -} - -static ldl_status parse_session_code(ldl_handle_t *handle, char *id, char *from, char *to, iks *xml, char *xtype) -{ - ldl_session_t *session = NULL; - ldl_signal_t dl_signal = LDL_SIGNAL_NONE; - char *initiator = iks_find_attrib(xml, "initiator"); - char *msg = NULL; - - if (!(session = apr_hash_get(handle->sessions, id, APR_HASH_KEY_STRING))) { - ldl_session_create(&session, handle, id, from, to, LDL_FLAG_NONE); - if (!session) { - return LDL_STATUS_MEMERR; - } - } - - if (!session) { - if (globals.debug) { - globals.logger(DL_LOG_CRIT, "Non-Existent Session %s!\n", id); - } - return LDL_STATUS_MEMERR; - } - - if (globals.debug) { - globals.logger(DL_LOG_CRIT, "Message for Session %s\n", id); - } - - while(xml) { - char *type = NULL; - iks *tag; - - if (iks_type(xml) != IKS_CDATA) { - type = xtype ? xtype : iks_find_attrib(xml, "type"); - } - - if (type) { - - if (!strcasecmp(type, "redirect")) { - apr_hash_t *hash = session->handle->sessions; - char *p = to; - if ((p = strchr(to, ':'))) { - p++; - } else { - p = to; - } - - - apr_hash_set(hash, session->them, APR_HASH_KEY_STRING, NULL); - apr_hash_set(hash, session->id, APR_HASH_KEY_STRING, NULL); - session->them = apr_pstrdup(session->pool, p); - apr_hash_set(handle->sessions, session->them, APR_HASH_KEY_STRING, session); - apr_hash_set(handle->sessions, session->id, APR_HASH_KEY_STRING, session); - - dl_signal = LDL_SIGNAL_REDIRECT; - } else if (!strcasecmp(type, "initiate") || !strcasecmp(type, "accept")) { - - dl_signal = LDL_SIGNAL_INITIATE; - - if (!strcasecmp(type, "accept")) { - msg = "accept"; - } - if (!session->initiator && initiator) { - session->initiator = apr_pstrdup(session->pool, initiator); - } - tag = iks_child (xml); - - while(tag) { - if (!strcasecmp(iks_name_nons(tag), "description")) { - iks * itag = iks_child (tag); - while(itag) { - if (!strcasecmp(iks_name_nons(itag), "payload-type") && session->payload_len < LDL_MAX_PAYLOADS) { - char *name = iks_find_attrib(itag, "name"); - char *id = iks_find_attrib(itag, "id"); - char *rate = iks_find_attrib(itag, "clockrate"); - char *ptime = iks_find_attrib(itag, "ptime"); - if (name && id) { - session->payloads[session->payload_len].name = apr_pstrdup(session->pool, name); - session->payloads[session->payload_len].id = atoi(id); - if (ptime) { - session->payloads[session->payload_len].ptime = atoi(ptime); - } else { - session->payloads[session->payload_len].ptime = 20; - } - if (rate) { - session->payloads[session->payload_len].rate = atoi(rate); - } else { - if (!strncasecmp(iks_name(itag), "vid", 3)) { - session->payloads[session->payload_len].rate = 90000; - } else { - session->payloads[session->payload_len].rate = 8000; - } - } - session->payload_len++; - - if (globals.debug) { - globals.logger(DL_LOG_CRIT, "Add Payload [%s] id='%s'\n", name, id); - } - } - } - itag = iks_next_tag(itag); - } - } - tag = iks_next_tag(tag); - } - } else if (!strcasecmp(type, "transport-accept")) { - dl_signal = LDL_SIGNAL_TRANSPORT_ACCEPT; - } else if (!strcasecmp(type, "reject")) { - dl_signal = LDL_SIGNAL_REJECT; - } else if (!strcasecmp(type, "transport-info") || !strcasecmp(type, "candidates")) { - char *tid = iks_find_attrib(xml, "id"); - dl_signal = LDL_SIGNAL_CANDIDATES; - tag = iks_child (xml); - id = type; - if (tag && !strcasecmp(iks_name_nons(tag), "transport")) { - tag = iks_child(tag); - } - - for (;tag;tag = iks_next_tag(tag)) { - if (!strcasecmp(iks_name_nons(tag), "info_element")) { - char *name = iks_find_attrib(tag, "name"); - char *value = iks_find_attrib(tag, "value"); - if (globals.debug) { - globals.logger(DL_LOG_CRIT, "Info Element [%s]=[%s]\n", name, value); - } - ldl_session_set_value(session, name, value); - - } else if (!strcasecmp(iks_name_nons(tag), "candidate") /*&& session->candidate_len < LDL_MAX_CANDIDATES*/) { - char *key; - double pref = 0.0; - int index = -1; - ldl_transport_type_t tport; - unsigned int *candidate_len = NULL; - ldl_candidate_t (*candidates)[LDL_MAX_CANDIDATES] = NULL; - - if (!(key = iks_find_attrib(tag, "preference"))) { - globals.logger(DL_LOG_WARNING, "Field preference was not set\n"); - continue; - } else { - unsigned int x; - - pref = strtod(key, NULL); - - /* Check what kind of candidate this is */ - if ((key = iks_find_attrib(tag, "name")) && ((tport = ldl_transport_type_parse(key)) != LDL_TPORT_MAX)) { - candidates = &(session->candidates[tport]); - candidate_len = &(session->candidate_len[tport]); - } else { - globals.logger(DL_LOG_WARNING, "No such transport type: %s\n", key); - continue; - } - - if (*candidate_len >= LDL_MAX_CANDIDATES) { - globals.logger(DL_LOG_WARNING, "Too many %s candidates\n", key); - continue; - } - - for (x = 0; x < *candidate_len; x++) { - if ((*candidates)[x].pref == pref) { - if (globals.debug) { - globals.logger(DL_LOG_CRIT, "Duplicate Pref! Updating...\n"); - } - index = x; - break; - } - } - } - - if (index < 0) { - index = (*candidate_len)++; - } - - (*candidates)[index].pref = pref; - - if (tid) { - (*candidates)[index].tid = apr_pstrdup(session->pool, tid); - } - - if ((key = iks_find_attrib(tag, "name"))) { - (*candidates)[index].name = apr_pstrdup(session->pool, key); - } - if ((key = iks_find_attrib(tag, "type"))) { - (*candidates)[index].type = apr_pstrdup(session->pool, key); - } - if ((key = iks_find_attrib(tag, "protocol"))) { - (*candidates)[index].protocol = apr_pstrdup(session->pool, key); - } - if ((key = iks_find_attrib(tag, "username"))) { - (*candidates)[index].username = apr_pstrdup(session->pool, key); - } - if ((key = iks_find_attrib(tag, "password"))) { - (*candidates)[index].password = apr_pstrdup(session->pool, key); - } - if ((key = iks_find_attrib(tag, "address"))) { - (*candidates)[index].address = apr_pstrdup(session->pool, key); - } - if ((key = iks_find_attrib(tag, "port"))) { - (*candidates)[index].port = (uint16_t)atoi(key); - } - - if (!(*candidates)[index].type) { - (*candidates)[index].type = apr_pstrdup(session->pool, "stun"); - } - - - if (globals.debug) { - globals.logger(DL_LOG_CRIT, - "New Candidate %d\n" - "name=%s\n" - "type=%s\n" - "protocol=%s\n" - "username=%s\n" - "password=%s\n" - "address=%s\n" - "port=%d\n" - "pref=%0.2f\n", - *candidate_len, - (*candidates)[index].name, - (*candidates)[index].type, - (*candidates)[index].protocol, - (*candidates)[index].username, - (*candidates)[index].password, - (*candidates)[index].address, - (*candidates)[index].port, - (*candidates)[index].pref - ); - } - } - } - } else if (!strcasecmp(type, "terminate")) { - dl_signal = LDL_SIGNAL_TERMINATE; - } else if (!strcasecmp(type, "error")) { - dl_signal = LDL_SIGNAL_ERROR; - } - } - - xml = iks_child(xml); - } - - if (handle->session_callback && dl_signal) { - handle->session_callback(handle, session, dl_signal, to, from, id, msg); - } - - return LDL_STATUS_SUCCESS; -} - - -static ldl_status parse_jingle_code(ldl_handle_t *handle, iks *xml, char *to, char *from, char *type) -{ - ldl_session_t *session = NULL; - ldl_signal_t dl_signal = LDL_SIGNAL_NONE; - char *initiator = iks_find_attrib(xml, "initiator"); - char *msg = NULL; - char *id = iks_find_attrib(xml, "sid"); - char *action = iks_find_attrib(xml, "action"); - iks *tag; - - - if (!strcasecmp(type, "error")) { - action = type; - } - - - if (!(id && action && from)) { - globals.logger(DL_LOG_CRIT, "missing required params\n"); - return LDL_STATUS_FALSE; - } - - if (!(session = apr_hash_get(handle->sessions, id, APR_HASH_KEY_STRING))) { - ldl_session_create(&session, handle, id, from, to, LDL_FLAG_NONE); - if (!session) { - return LDL_STATUS_MEMERR; - } - } - - if (!session) { - if (globals.debug) { - globals.logger(DL_LOG_CRIT, "Non-Existent Session %s!\n", id); - } - return LDL_STATUS_MEMERR; - } - - if (globals.debug) { - globals.logger(DL_LOG_CRIT, "Message for Session %s\n", id); - } - - - if (action) { - - if (!strcasecmp(action, "redirect")) { - apr_hash_t *hash = session->handle->sessions; - char *p = to; - if ((p = strchr(to, ':'))) { - p++; - } else { - p = to; - } - - - apr_hash_set(hash, session->them, APR_HASH_KEY_STRING, NULL); - apr_hash_set(hash, session->id, APR_HASH_KEY_STRING, NULL); - session->them = apr_pstrdup(session->pool, p); - apr_hash_set(handle->sessions, session->them, APR_HASH_KEY_STRING, session); - apr_hash_set(handle->sessions, session->id, APR_HASH_KEY_STRING, session); - - dl_signal = LDL_SIGNAL_REDIRECT; - } else if (!strcasecmp(action, "session-initiate") || !strcasecmp(action, "session-accept")) { - - dl_signal = LDL_SIGNAL_INITIATE; - - if (!strcasecmp(action, "session-accept")) { - msg = "accept"; - } - - if (!session->initiator && initiator) { - session->initiator = apr_pstrdup(session->pool, initiator); - } - tag = iks_child (xml); - - while(tag) { - - if (!strcasecmp(iks_name_nons(tag), "content")) { - iks *dtag = iks_child (tag); - char key[512]; - - if (!strcasecmp(iks_name_nons(dtag), "description")) { - iks *itag = iks_child (dtag); - char *name = iks_find_attrib(tag, "name"); - char *media = iks_find_attrib(dtag, "media"); - - if (globals.debug) { - globals.logger(DL_LOG_CRIT, "Found description of type '%s' media type '%s'\n", name, media); - - } - - while(itag) { - if (!strcasecmp(iks_name_nons(itag), "rtcp-mux")) { - snprintf(key, sizeof(key), "%s:rtcp-mux", media); - ldl_session_set_value(session, key, "true"); - } - - if (!strcasecmp(iks_name_nons(itag), "encryption")) { - iks *etag = iks_child (itag); - - while(etag) { - char *suite = iks_find_attrib(etag, "crypto-suite"); - char *params = iks_find_attrib(etag, "key-params"); - char *tag = iks_find_attrib(etag, "tag"); - char val[512]; - - if (suite && params && tag) { - snprintf(key, sizeof(key), "%s:crypto:%s", media, tag); - snprintf(val, sizeof(val), "%s %s %s", tag, suite, params); - - ldl_session_set_value(session, key, val); - } - - etag = iks_next_tag(etag); - } - } - - - if (!strcasecmp(iks_name_nons(itag), "payload-type") && session->payload_len < LDL_MAX_PAYLOADS) { - char *name = iks_find_attrib(itag, "name"); - char *id = iks_find_attrib(itag, "id"); - char *rate = iks_find_attrib(itag, "clockrate"); - - if (name && id) { - session->payloads[session->payload_len].name = apr_pstrdup(session->pool, name); - session->payloads[session->payload_len].id = atoi(id); - if (rate) { - session->payloads[session->payload_len].rate = atoi(rate); - } else { - if (!strcasecmp(media, "video")) { - session->payloads[session->payload_len].rate = 90000; - } else { - session->payloads[session->payload_len].rate = 8000; - } - } - session->payload_len++; - - if (globals.debug) { - globals.logger(DL_LOG_CRIT, "Add Payload [%s] id='%s'\n", name, id); - } - } - } - itag = iks_next_tag(itag); - } - - } - } - - tag = iks_next_tag(tag); - } - } else if (!strcasecmp(action, "transport-accept")) { - dl_signal = LDL_SIGNAL_TRANSPORT_ACCEPT; - } else if (!strcasecmp(action, "reject")) { - dl_signal = LDL_SIGNAL_REJECT; - } else if (!strcasecmp(action, "transport-info")) { - - tag = iks_child (xml); - - while(tag) { - - if (!strcasecmp(iks_name_nons(tag), "content")) { - iks *ttag = iks_child (tag); - - dl_signal = LDL_SIGNAL_CANDIDATES; - - id = action; - - if (ttag && !strcasecmp(iks_name_nons(ttag), "transport")) { - ttag = iks_child(ttag); - } - - for (;ttag;ttag = iks_next_tag(ttag)) { - if (!strcasecmp(iks_name_nons(ttag), "info_element")) { - char *name = iks_find_attrib(ttag, "name"); - char *value = iks_find_attrib(ttag, "value"); - if (globals.debug) { - globals.logger(DL_LOG_CRIT, "Info Element [%s]=[%s]\n", name, value); - } - ldl_session_set_value(session, name, value); - - } else if (!strcasecmp(iks_name_nons(ttag), "candidate")) { - char *key; - double pref = 0.0; - int index = -1; - ldl_transport_type_t tport; - unsigned int *candidate_len = NULL; - ldl_candidate_t (*candidates)[LDL_MAX_CANDIDATES] = NULL; - - if ((key = iks_find_attrib(ttag, "preference"))) { - unsigned int x; - - pref = strtod(key, NULL); - - /* Check what kind of candidate this is */ - if ((key = iks_find_attrib(ttag, "name")) && ((tport = ldl_transport_type_parse(key)) != LDL_TPORT_MAX)) { - candidates = &(session->candidates[tport]); - candidate_len = &(session->candidate_len[tport]); - } else { - globals.logger(DL_LOG_WARNING, "No such transport type: %s\n", key); - continue; - } - - if (*candidate_len >= LDL_MAX_CANDIDATES) { - globals.logger(DL_LOG_WARNING, "Too many %s candidates\n", key); - continue; - } - - for (x = 0; x < *candidate_len; x++) { - if ((*candidates)[x].pref == pref) { - if (globals.debug) { - globals.logger(DL_LOG_CRIT, "Duplicate Pref!\n"); - } - index = x; - break; - } - } - } else { - globals.logger(DL_LOG_WARNING, "No preference specified"); - continue; - } - - if (index < 0) { - index = (*candidate_len)++; - } - - (*candidates)[index].pref = pref; - - if ((key = iks_find_attrib(ttag, "name"))) { - (*candidates)[index].name = apr_pstrdup(session->pool, key); - } - if ((key = iks_find_attrib(ttag, "type"))) { - (*candidates)[index].type = apr_pstrdup(session->pool, key); - } - if ((key = iks_find_attrib(ttag, "protocol"))) { - (*candidates)[index].protocol = apr_pstrdup(session->pool, key); - } - if ((key = iks_find_attrib(ttag, "username"))) { - (*candidates)[index].username = apr_pstrdup(session->pool, key); - } - if ((key = iks_find_attrib(ttag, "password"))) { - (*candidates)[index].password = apr_pstrdup(session->pool, key); - } - if ((key = iks_find_attrib(ttag, "address"))) { - (*candidates)[index].address = apr_pstrdup(session->pool, key); - } - if ((key = iks_find_attrib(ttag, "port"))) { - (*candidates)[index].port = (uint16_t)atoi(key); - } - - if (!(*candidates)[index].type) { - (*candidates)[index].type = apr_pstrdup(session->pool, "stun"); - } - - - if (globals.debug) { - globals.logger(DL_LOG_CRIT, - "New Candidate %d\n" - "name=%s\n" - "type=%s\n" - "protocol=%s\n" - "username=%s\n" - "password=%s\n" - "address=%s\n" - "port=%d\n" - "pref=%0.2f\n", - *candidate_len, - (*candidates)[index].name, - (*candidates)[index].type, - (*candidates)[index].protocol, - (*candidates)[index].username, - (*candidates)[index].password, - (*candidates)[index].address, - (*candidates)[index].port, - (*candidates)[index].pref - ); - } - } - } - } - - tag = iks_next_tag(tag); - } - } else if (!strcasecmp(action, "session-terminate")) { - dl_signal = LDL_SIGNAL_TERMINATE; - } else if (!strcasecmp(action, "error")) { - dl_signal = LDL_SIGNAL_ERROR; - } - } - - - - if (handle->session_callback && dl_signal) { - handle->session_callback(handle, session, dl_signal, to, from, id, msg); - } - - return LDL_STATUS_SUCCESS; -} - - - -const char *marker = "TRUE"; - - -static int on_vcard(void *user_data, ikspak *pak) -{ - ldl_handle_t *handle = user_data; - char *from = iks_find_attrib(pak->x, "from"); - char *to = iks_find_attrib(pak->x, "to"); - - if (handle->session_callback) { - handle->session_callback(handle, NULL, LDL_SIGNAL_VCARD, to, from, pak->id, NULL); - } - - return IKS_FILTER_EAT; -} - - -static int on_disco_default(void *user_data, ikspak *pak) -{ - char *node = NULL; - char *ns = NULL; - ldl_handle_t *handle = user_data; - iks *iq = NULL, *query, *tag; - uint8_t send = 0; - int x; - - if (pak && pak->query) { - ns = iks_find_attrib(pak->query, "xmlns"); - node = iks_find_attrib(pak->query, "node"); - } - - if (pak && pak->subtype == IKS_TYPE_RESULT) { - globals.logger(DL_LOG_CRIT, "FixME!!! node=[%s]\n", node?node:""); - } else if (pak && pak->subtype == IKS_TYPE_GET) { - if (ns && (iq = iks_new("iq"))) { - int all = 0; - - iks_insert_attrib(iq, "from", handle->login); - if (pak->from) { - iks_insert_attrib(iq, "to", pak->from->full); - } - iks_insert_attrib(iq, "id", pak->id); - iks_insert_attrib(iq, "type", "result"); - - if (!(query = iks_insert (iq, "query"))) { - goto fail; - } - iks_insert_attrib(query, "xmlns", ns); - - if (!strcasecmp(ns, FEATURE_LAST)) { - iks_insert_attrib(query, "seconds", "1"); - } - - if (!(tag = iks_insert (query, "identity"))) { - goto fail; - } - - iks_insert_attrib(tag, "category", "gateway"); - //iks_insert_attrib(tag, "type", "voice"); - iks_insert_attrib(tag, "name", "LibDingaLing"); - - if (!strcasecmp(ns, FEATURE_DISCO_INFO)) { - if (!node) { - all++; - } else { - char *p; - - if ((p = strstr(node, "caps#"))) { - char *what = p + 5; - - if (!strcasecmp(what, "voice-v1")) { - if (!(tag = iks_insert (query, "feature"))) { - goto fail; - } - iks_insert_attrib(tag, "var", FEATURE_VOICE); - goto done; - } - - } - } - } - - for (x = 0; FEATURES[x].name; x++) { - if (all || !ns || !strcasecmp(ns, FEATURES[x].name)) { - if (!(tag = iks_insert (query, "feature"))) { - goto fail; - } - iks_insert_attrib(tag, "var", FEATURES[x].name); - } - } - - done: - - apr_queue_push(handle->queue, iq); - iq = NULL; - send = 1; - } - fail: - - if (iq) { - iks_delete(iq); - } - - if (!send) { - globals.logger(DL_LOG_CRIT, "Memory Error!\n"); - } - } - - return IKS_FILTER_EAT; -} - -static int on_presence(void *user_data, ikspak *pak) -{ - ldl_handle_t *handle = user_data; - char *from = iks_find_attrib(pak->x, "from"); - char *to = iks_find_attrib(pak->x, "to"); - char *type = iks_find_attrib(pak->x, "type"); - char *show = iks_find_cdata(pak->x, "show"); - char *status = iks_find_cdata(pak->x, "status"); - char id[1024]; - char *resource; - struct ldl_buffer *buffer; - ldl_signal_t dl_signal = LDL_SIGNAL_PRESENCE_IN; - int done = 0; - - - if (type && *type) { - if (!strcasecmp(type, "unavailable")) { - dl_signal = LDL_SIGNAL_PRESENCE_OUT; - } else if (!strcasecmp(type, "probe")) { - dl_signal = LDL_SIGNAL_PRESENCE_PROBE; - } - if (!status) { - status = type; - } - } else { - if (!status) { - status = "Available"; - } - } - - - apr_cpystrn(id, from, sizeof(id)); - lowercase(id); - - if ((resource = strchr(id, '/'))) { - *resource++ = '\0'; - } - - - if (!apr_hash_get(handle->sub_hash, from, APR_HASH_KEY_STRING)) { - iks *msg; - apr_hash_set(handle->sub_hash, apr_pstrdup(handle->pool, from), APR_HASH_KEY_STRING, &marker); - if ((msg = iks_make_s10n (IKS_TYPE_SUBSCRIBED, id, "Ding A Ling...."))) { - apr_queue_push(handle->queue, msg); - msg = NULL; - } - } - - if (resource && (strstr(resource, "talk") || strstr(resource, "telepathy")) && (buffer = apr_hash_get(handle->probe_hash, id, APR_HASH_KEY_STRING))) { - apr_cpystrn(buffer->buf, from, buffer->len); - buffer->hit = 1; - done = 1; - } - - if (!done) { - iks *xml = iks_find(pak->x, "c"); - if (!xml) { - xml = iks_find(pak->x, "caps:c"); - } - - if (xml) { - char *ext = iks_find_attrib(xml, "ext");; - if (ext && strstr(ext, "voice-v1") && (buffer = apr_hash_get(handle->probe_hash, id, APR_HASH_KEY_STRING))) { - apr_cpystrn(buffer->buf, from, buffer->len); - buffer->hit = 1; - } - } - } - - - if (handle->session_callback) { - handle->session_callback(handle, NULL, dl_signal, to, id, status ? status : "n/a", show ? show : "n/a"); - } - - return IKS_FILTER_EAT; -} - -static char *ldl_handle_strdup(ldl_handle_t *handle, char *str) -{ - char *dup; - apr_size_t len; - - len = strlen(str) + 1; - dup = apr_palloc(handle->pool, len); - assert(dup != NULL); - strncpy(dup, str, len); - return dup; -} - -static void ldl_strip_resource(char *in) -{ - char *p; - - if ((p = strchr(in, '/'))) { - *p = '\0'; - } -} - -static ldl_avatar_t *ldl_get_avatar(ldl_handle_t *handle, char *path, char *from) -{ - ldl_avatar_t *ap; - uint8_t image[8192]; - unsigned char base64[9216] = ""; - int fd = -1; - size_t bytes; - char *key; - //char hash[128] = ""; - - if (from && (ap = (ldl_avatar_t *) apr_hash_get(globals.avatar_hash, from, APR_HASH_KEY_STRING))) { - return ap; - } - - if (path && from) { - if ((ap = (ldl_avatar_t *) apr_hash_get(globals.avatar_hash, path, APR_HASH_KEY_STRING))) { - key = ldl_handle_strdup(handle, from); - ldl_strip_resource(key); - apr_hash_set(globals.avatar_hash, key, APR_HASH_KEY_STRING, ap); - return ap; - } - } - - if (!(path && from)) { - return NULL; - } - - if ((fd = open(path, O_RDONLY, 0)) < 0) { - globals.logger(DL_LOG_ERR, "File %s does not exist!\n", path); - return NULL; - } - - bytes = read(fd, image, sizeof(image)); - close(fd); - - ap = malloc(sizeof(*ap)); - assert(ap != NULL); - memset(ap, 0, sizeof(*ap)); - sha1_hash(ap->hash, (unsigned char *) image, (unsigned int)bytes); - ap->path = strdup(path); - - key = ldl_handle_strdup(handle, from); - ldl_strip_resource(key); - - b64encode((unsigned char *)image, bytes, base64, sizeof(base64)); - ap->base64 = strdup((const char *)base64); - apr_hash_set(globals.avatar_hash, ap->path, APR_HASH_KEY_STRING, ap); - apr_hash_set(globals.avatar_hash, key, APR_HASH_KEY_STRING, ap); - return ap; -} - - -static void do_presence(ldl_handle_t *handle, char *from, char *to, char *type, char *rpid, char *message, char *avatar) -{ - iks *pres; - char buf[512]; - iks *tag; - - if (from && !strchr(from, '/')) { - snprintf(buf, sizeof(buf), "%s/talk", from); - from = buf; - } - - if (ldl_test_flag(handle, LDL_FLAG_COMPONENT) && from && to && ldl_jid_domcmp(from, to)) { - globals.logger(DL_LOG_ERR, "Refusal to send presence from and to the same domain in component mode [%s][%s]\n", from, to); - return; - } - - if ((pres = iks_new("presence"))) { - iks_insert_attrib(pres, "xmlns", "jabber:client"); - if (from) { - iks_insert_attrib(pres, "from", from); - } - if (to) { - iks_insert_attrib(pres, "to", to); - } - if (type) { - iks_insert_attrib(pres, "type", type); - } - - if (rpid) { - if ((tag = iks_insert (pres, "show"))) { - iks_insert_cdata(tag, rpid, 0); - } - } - - if (message) { - if ((tag = iks_insert (pres, "status"))) { - iks_insert_cdata(tag, message, 0); - } - } - - if (message || rpid) { - ldl_avatar_t *ap; - - if (avatar) { - if ((ap = ldl_get_avatar(handle, avatar, from))) { - if ((tag = iks_insert(pres, "x"))) { - iks *hash; - iks_insert_attrib(tag, "xmlns", "vcard-temp:x:update"); - if ((hash = iks_insert(tag, "photo"))) { - iks_insert_cdata(hash, ap->hash, 0); - } - } - } - } - - if ((tag = iks_insert(pres, "c"))) { - iks_insert_attrib(tag, "node", "http://www.freeswitch.org/xmpp/client/caps"); - iks_insert_attrib(tag, "ver", LDL_CAPS_VER); - iks_insert_attrib(tag, "ext", "sidebar voice-v1 video-v1 camera-v1"); - iks_insert_attrib(tag, "client", "libdingaling"); - iks_insert_attrib(tag, "xmlns", "http://jabber.org/protocol/caps"); - } - } - - apr_queue_push(handle->queue, pres); - pres = NULL; - } -} - -static void do_roster(ldl_handle_t *handle) -{ - if (handle->session_callback) { - handle->session_callback(handle, NULL, LDL_SIGNAL_ROSTER, NULL, handle->login, NULL, NULL); - } -} - -static int on_unsubscribe(void *user_data, ikspak *pak) -{ - ldl_handle_t *handle = user_data; - char *from = iks_find_attrib(pak->x, "from"); - char *to = iks_find_attrib(pak->x, "to"); - - if (handle->session_callback) { - handle->session_callback(handle, NULL, LDL_SIGNAL_UNSUBSCRIBE, to, from, NULL, NULL); - } - - return IKS_FILTER_EAT; -} - -static int on_subscribe(void *user_data, ikspak *pak) -{ - ldl_handle_t *handle = user_data; - char *from = iks_find_attrib(pak->x, "from"); - char *to = iks_find_attrib(pak->x, "to"); - iks *msg = NULL; - char *id = strdup(from); - char *r; - - if (!id) { - return -1; - } - if ((r = strchr(from, '/'))) { - *r++ = '\0'; - } - - if ((msg = iks_make_s10n (IKS_TYPE_SUBSCRIBED, id, "Ding A Ling...."))) { - if (to && ldl_test_flag(handle, LDL_FLAG_COMPONENT)) { - iks_insert_attrib(msg, "from", to); - } - - apr_queue_push(handle->queue, msg); - msg = NULL; - } - - if ((msg = iks_make_s10n (IKS_TYPE_SUBSCRIBE, id, "Ding A Ling...."))) { - - if (to && ldl_test_flag(handle, LDL_FLAG_COMPONENT)) { - iks_insert_attrib(msg, "from", to); - } - - apr_queue_push(handle->queue, msg); - msg = NULL; - } - - if (handle->session_callback) { - handle->session_callback(handle, NULL, LDL_SIGNAL_SUBSCRIBE, to, from, NULL, NULL); - } - - return IKS_FILTER_EAT; -} - -static void cancel_retry(ldl_handle_t *handle, char *id) -{ - struct packet_node *packet_node; - - apr_thread_mutex_lock(handle->lock); - if ((packet_node = apr_hash_get(handle->retry_hash, id, APR_HASH_KEY_STRING))) { - if (globals.debug) { - globals.logger(DL_LOG_CRIT, "Cancel packet %s\n", packet_node->id); - } - packet_node->retries = 0; - } - apr_thread_mutex_unlock(handle->lock); -} - -static iks* working_find(iks *tag, const char *name) -{ - while(tag) { - if (!strcasecmp(iks_name(tag), name)) { - return tag; - } - tag = iks_next_tag(tag); - } - - return NULL; -} - -static iks* working_find_nons(iks *tag, const char *name) -{ - while(tag) { - char *a = iks_name(tag); - char *b = (char *)name; - char *p; - - if ((p = strchr(a, ':'))) { - a = p+1; - } - - if ((p = strchr(b, ':'))) { - b = p+1; - } - - if (!strcasecmp(a,b)) { - return tag; - } - tag = iks_next_tag(tag); - } - - return NULL; -} - -static int on_commands(void *user_data, ikspak *pak) -{ - ldl_handle_t *handle = user_data; - char *from = iks_find_attrib(pak->x, "from"); - char *to = iks_find_attrib(pak->x, "to"); - char *iqid = iks_find_attrib(pak->x, "id"); - char *type = iks_find_attrib(pak->x, "type"); - uint8_t is_result = strcasecmp(type, "result") ? 0 : 1; - uint8_t is_error = strcasecmp(type, "error") ? 0 : 1; - iks *xml, *xsession, *xerror = NULL, *xredir = NULL; - iks *xjingle; - - - xml = iks_child (pak->x); - - if (is_error) { - if ((xerror = working_find(xml, "error"))) { - char *code = iks_find_attrib(xerror, "code"); - if (code && !strcmp(code, "302") && - ((xredir = iks_find(xerror, "ses:redirect")) || (xredir = iks_find(xerror, "redirect")))) { - is_result = 0; - is_error = 0; - cancel_retry(handle, iqid); - } - } - } - - - if (is_result) { - iks *tag = iks_child (pak->x); - while(tag) { - if (!strcasecmp(iks_name_nons(tag), "bind")) { - char *jid = iks_find_cdata(tag, "jid"); - char *resource = strchr(jid, '/'); - if (resource) { - resource++; - handle->acc->resource = apr_pstrdup(handle->pool, resource); - } - handle->login = apr_pstrdup(handle->pool, jid); -#if 0 - if ((iq = iks_new("iq"))) { - iks_insert_attrib(iq, "type", "get"); - iks_insert_attrib(iq, "id", "roster"); - x = iks_insert(iq, "query"); - iks_insert_attrib(x, "xmlns", "jabber:iq:roster"); - iks_insert_attrib(x, "xmlns:gr", "google:roster"); - iks_insert_attrib(x, "gr:ext", "2"); - iks_insert_attrib(x, "gr:include", "all"); - apr_queue_push(handle->queue, iq); - iq = NULL; - break; - } -#endif - } - tag = iks_next_tag(tag); - } - } - - - - if ((is_result || is_error) && iqid && from) { - - cancel_retry(handle, iqid); - - if (is_result) { - if (handle->response_callback) { - handle->response_callback(handle, iqid); - } - return IKS_FILTER_EAT; - } else if (is_error) { - return IKS_FILTER_EAT; - - } - } - - - - if ((handle->flags & LDL_FLAG_JINGLE) && (xjingle = working_find_nons(xml, "jin:jingle"))) { - if (parse_jingle_code(handle, xjingle, to, from, type) == LDL_STATUS_SUCCESS) { - iks *reply; - if ((reply = iks_make_iq(IKS_TYPE_RESULT, NULL))) { - iks_insert_attrib(reply, "to", from); - iks_insert_attrib(reply, "from", to); - iks_insert_attrib(reply, "id", iqid); - apr_queue_push(handle->queue, reply); - reply = NULL; - } - } - - } else if ((xsession = working_find_nons(xml, "ses:session"))) { - char *id; - - id = iks_find_attrib(xsession, "id"); - - if (xredir) { - to = iks_cdata(iks_child(xredir)); - type = "redirect"; - } - - if (strcasecmp(type, "error") && strcasecmp(type, "redirect")) { - type = NULL; - } - - if (parse_session_code(handle, id, from, to, xsession, type) == LDL_STATUS_SUCCESS) { - iks *reply; - if ((reply = iks_make_iq(IKS_TYPE_RESULT, NULL))) { - iks_insert_attrib(reply, "to", from); - iks_insert_attrib(reply, "from", to); - iks_insert_attrib(reply, "id", iqid); - apr_queue_push(handle->queue, reply); - reply = NULL; - } - } - } - - return IKS_FILTER_EAT; -} - - -static int on_result(void *user_data, ikspak *pak) -{ - ldl_handle_t *handle = user_data; - iks *msg, *ctag, *tag; - - if ((msg = iks_make_pres (IKS_SHOW_AVAILABLE, handle->status_msg))) { - ctag = iks_insert(msg, "c"); - iks_insert_attrib(ctag, "node", "http://www.freeswitch.org/xmpp/client/caps"); - iks_insert_attrib(ctag, "ver", "1.0.0.1"); - iks_insert_attrib(ctag, "ext", "sidebar voice-v1 video-v1"); - iks_insert_attrib(ctag, "client", "libdingaling"); - iks_insert_attrib(ctag, "xmlns", "http://jabber.org/protocol/caps"); - - if (handle->priority && strlen(handle->priority)) { - tag = iks_insert (msg, "priority"); - iks_insert_cdata(tag, handle->priority, 0); - } - - apr_queue_push(handle->queue, msg); - msg = NULL; - } - return IKS_FILTER_EAT; -} - -static const char c64[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; -#define B64BUFFLEN 1024 - -static int b64encode(unsigned char *in, size_t ilen, unsigned char *out, size_t olen) -{ - int y=0,bytes=0; - size_t x=0; - unsigned int b=0,l=0; - - for(x=0;x= 6) { - out[bytes++] = c64[(b>>(l-=6))%64]; - if(++y!=72) { - continue; - } - //out[bytes++] = '\n'; - y=0; - } - } - - if (l > 0) { - out[bytes++] = c64[((b%16)<<(6-l))%64]; - } - if (l != 0) while (l < 6) { - out[bytes++] = '=', l += 2; - } - - return 0; -} - -static void sha1_hash(char *out, unsigned char *in, unsigned int len) -{ - SHA1Context sha; - char *p; - int x; - unsigned char digest[SHA1_HASH_SIZE] = ""; - - SHA1Init(&sha); - - SHA1Update(&sha, in, len); - - SHA1Final(&sha, digest); - - p = out; - for (x = 0; x < SHA1_HASH_SIZE; x++) { - p += sprintf(p, "%2.2x", digest[x]); - } -} - - -static int on_stream_component(ldl_handle_t *handle, int type, iks *node) -{ - ikspak *pak = NULL; - - if (node) { - pak = iks_packet(node); - } - - switch (type) { - case IKS_NODE_START: - if (pak && handle->state == CS_NEW) { - char secret[256] = ""; - char hash[256] = ""; - char handshake[512] = ""; - - snprintf(secret, sizeof(secret), "%s%s", pak->id, handle->password); - sha1_hash(hash, (unsigned char *) secret, (unsigned int)strlen(secret)); - snprintf(handshake, sizeof(handshake), "%s", hash); - iks_send_raw(handle->parser, handshake); - handle->state = CS_START; - if (iks_recv(handle->parser, 1) == 2) { - handle->state = CS_CONNECTED; - if (!ldl_test_flag(handle, LDL_FLAG_AUTHORIZED)) { - do_roster(handle); - if (handle->session_callback) { - handle->session_callback(handle, NULL, LDL_SIGNAL_LOGIN_SUCCESS, "user", "core", "Login Success", handle->login); - } - globals.logger(DL_LOG_DEBUG, "XMPP authenticated\n"); - ldl_set_flag_locked(handle, LDL_FLAG_AUTHORIZED); - ldl_set_flag_locked(handle, LDL_FLAG_CONNECTED); - handle->fail_count = 0; - } - } else { - globals.logger(DL_LOG_ERR, "LOGIN ERROR!\n"); - handle->state = CS_NEW; - } - break; - } - break; - - case IKS_NODE_NORMAL: - break; - - case IKS_NODE_ERROR: - globals.logger(DL_LOG_ERR, "NODE ERROR!\n"); - return IKS_HOOK; - - case IKS_NODE_STOP: - globals.logger(DL_LOG_ERR, "DISCONNECTED!\n"); - return IKS_HOOK; - } - - iks_filter_packet(handle->filter, pak); - - if (handle->job_done == 1) { - return IKS_HOOK; - } - - if (node) { - iks_delete(node); - } - - return IKS_OK; -} - -static int on_stream(ldl_handle_t *handle, int type, iks *node) -{ - handle->counter = opt_timeout; - - - switch (type) { - case IKS_NODE_START: - if (ldl_test_flag(handle, LDL_FLAG_TLS) && !iks_is_secure(handle->parser)) { - if (iks_has_tls()) { - iks_start_tls(handle->parser); - } else { - globals.logger(DL_LOG_WARNING, "TLS NOT SUPPORTED IN THIS BUILD!\n"); - } - } - break; - case IKS_NODE_NORMAL: - if (node && strcmp("stream:features", iks_name(node)) == 0) { - handle->features = iks_stream_features(node); - if (ldl_test_flag(handle, LDL_FLAG_TLS) && !iks_is_secure(handle->parser)) - break; - if (ldl_test_flag(handle, LDL_FLAG_CONNECTED)) { - iks *t; - if (handle->features & IKS_STREAM_BIND) { - if ((t = iks_make_resource_bind(handle->acc))) { - apr_queue_push(handle->queue, t); - t = NULL; - } - } - if (handle->features & IKS_STREAM_SESSION) { - if ((t = iks_make_session())) { - iks_insert_attrib(t, "id", "auth"); - apr_queue_push(handle->queue, t); - t = NULL; - } - } - } else { - if (handle->features & IKS_STREAM_SASL_MD5) { - iks_start_sasl(handle->parser, IKS_SASL_DIGEST_MD5, handle->acc->user, handle->password); - } else if (handle->features & IKS_STREAM_SASL_PLAIN) { - iks *x = NULL; - - if ((x = iks_new("auth"))) { - char s[512] = ""; - char base64[1024] = ""; - uint32_t slen; - - iks_insert_attrib(x, "xmlns", IKS_NS_XMPP_SASL); - iks_insert_attrib(x, "mechanism", "PLAIN"); - iks_insert_attrib(x, "encoding", "UTF-8"); - snprintf(s, sizeof(s), "%c%s%c%s", 0, handle->acc->user, 0, handle->password); - slen = (uint32_t)(strlen(handle->acc->user) + strlen(handle->password) + 2); - b64encode((unsigned char *)s, slen, (unsigned char *) base64, sizeof(base64)); - iks_insert_cdata(x, base64, 0); - apr_queue_push(handle->queue, x); - x = NULL; - } else { - globals.logger(DL_LOG_CRIT, "Memory ERROR!\n"); - break; - } - - } - } - } else if (node && strcmp("failure", iks_name_nons(node)) == 0) { - globals.logger(DL_LOG_CRIT, "sasl authentication failed\n"); - if (handle->session_callback) { - handle->session_callback(handle, NULL, LDL_SIGNAL_LOGIN_FAILURE, "user", "core", "Login Failure", handle->login); - } - } else if (node && strcmp("success", iks_name_nons(node)) == 0) { - globals.logger(DL_LOG_NOTICE, "XMPP server connected\n"); - iks_send_header(handle->parser, handle->acc->server); - ldl_set_flag_locked(handle, LDL_FLAG_CONNECTED); - if (handle->session_callback) { - handle->session_callback(handle, NULL, LDL_SIGNAL_CONNECTED, "user", "core", "Server Connected", handle->login); - } - } else { - ikspak *pak; - if (!ldl_test_flag(handle, LDL_FLAG_AUTHORIZED)) { - if (handle->session_callback) { - handle->session_callback(handle, NULL, LDL_SIGNAL_LOGIN_SUCCESS, "user", "core", "Login Success", handle->login); - } - globals.logger(DL_LOG_NOTICE, "XMPP authenticated\n"); - ldl_set_flag_locked(handle, LDL_FLAG_AUTHORIZED); - } - if (node) { - pak = iks_packet(node); - iks_filter_packet(handle->filter, pak); - } - if (handle->job_done == 1) { - return IKS_HOOK; - } - } - break; -#if 0 - case IKS_NODE_STOP: - globals.logger(DL_LOG_DEBUG, "server disconnected\n"); - break; - - case IKS_NODE_ERROR: - globals.logger(DL_LOG_DEBUG, "stream error\n"); - break; -#endif - - } - - if (node) { - iks_delete(node); - } - return IKS_OK; -} - -static int on_msg(void *user_data, ikspak *pak) -{ - char *cmd = iks_find_cdata(pak->x, "body"); - char *to = iks_find_attrib(pak->x, "to"); - char *from = iks_find_attrib(pak->x, "from"); - char *subject = iks_find_attrib(pak->x, "subject"); - ldl_handle_t *handle = user_data; - ldl_session_t *session = NULL; - - if (from) { - session = apr_hash_get(handle->sessions, from, APR_HASH_KEY_STRING); - } - - if (handle->session_callback) { - handle->session_callback(handle, session, LDL_SIGNAL_MSG, to, from, subject ? subject : "N/A", cmd); - } - - return 0; -} - -static int on_error(void *user_data, ikspak * pak) -{ - globals.logger(DL_LOG_ERR, "authorization failed\n"); - return IKS_FILTER_EAT; -} - -static void on_log(ldl_handle_t *handle, const char *data, size_t size, int is_incoming) -{ - - if (globals.debug) { - if (is_incoming) { - globals.logger(DL_LOG_INFO, "+xml:%s%s:%s", iks_is_secure(handle->parser) ? "Sec" : "", is_incoming ? "RECV" : "SEND", data); - } else { - globals.logger(DL_LOG_NOTICE, "+xml:%s%s:%s", iks_is_secure(handle->parser) ? "Sec" : "", is_incoming ? "RECV" : "SEND", data); - } - } -} - -static void j_setup_filter(ldl_handle_t *handle) -{ - int x = 0; - - if (handle->filter) { - iks_filter_delete(handle->filter); - } - handle->filter = iks_filter_new(); - - iks_filter_add_rule(handle->filter, on_msg, handle, IKS_RULE_TYPE, IKS_PAK_MESSAGE, IKS_RULE_SUBTYPE, IKS_TYPE_CHAT, IKS_RULE_DONE); - - iks_filter_add_rule(handle->filter, on_result, handle, - IKS_RULE_TYPE, IKS_PAK_IQ, - IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, IKS_RULE_ID, "auth", IKS_RULE_DONE); - - iks_filter_add_rule(handle->filter, on_presence, handle, - IKS_RULE_TYPE, IKS_PAK_PRESENCE, - //IKS_RULE_SUBTYPE, IKS_TYPE_SET, - IKS_RULE_DONE); - - iks_filter_add_rule(handle->filter, on_commands, handle, - IKS_RULE_TYPE, IKS_PAK_IQ, - IKS_RULE_SUBTYPE, IKS_TYPE_SET, - IKS_RULE_DONE); - - iks_filter_add_rule(handle->filter, on_commands, handle, - IKS_RULE_TYPE, IKS_PAK_IQ, - IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, - IKS_RULE_DONE); - - iks_filter_add_rule(handle->filter, on_commands, handle, - IKS_RULE_TYPE, IKS_PAK_IQ, - IKS_RULE_SUBTYPE, IKS_TYPE_ERROR, - IKS_RULE_DONE); - - iks_filter_add_rule(handle->filter, on_subscribe, handle, - IKS_RULE_TYPE, IKS_PAK_S10N, - IKS_RULE_SUBTYPE, IKS_TYPE_SUBSCRIBE, - IKS_RULE_DONE); - - iks_filter_add_rule(handle->filter, on_unsubscribe, handle, - IKS_RULE_TYPE, IKS_PAK_S10N, - IKS_RULE_SUBTYPE, IKS_TYPE_UNSUBSCRIBE, - IKS_RULE_DONE); - - iks_filter_add_rule(handle->filter, on_error, handle, - IKS_RULE_TYPE, IKS_PAK_IQ, - IKS_RULE_SUBTYPE, IKS_TYPE_ERROR, IKS_RULE_ID, "auth", IKS_RULE_DONE); - - for (x = 0; FEATURES[x].name; x++) { - iks_filter_add_rule(handle->filter, FEATURES[x].callback, handle, - IKS_RULE_NS, FEATURES[x].name, IKS_RULE_DONE); - } -} - -static ldl_queue_t ldl_flush_queue(ldl_handle_t *handle, int done) -{ - iks *msg; - void *pop = NULL; - unsigned int len = 0, x = 0; - - ldl_queue_t sent_data = LDL_QUEUE_NONE; - - apr_thread_mutex_lock(handle->lock); - - while(apr_queue_trypop(handle->queue, &pop) == APR_SUCCESS) { - if (pop) { - msg = (iks *) pop; - if (!done) { - if (iks_send(handle->parser, msg) != IKS_OK) { - globals.logger(DL_LOG_DEBUG, "Failed sending data!\n"); - }; - }; - iks_delete(msg); - pop = NULL; - sent_data = LDL_QUEUE_SENT; - } else { - break; - } - } - - len = apr_queue_size(handle->retry_queue); - if (globals.debug && len) { - globals.logger(DL_LOG_CRIT, "Processing %u packets in retry queue\n", len); - } - - pop = NULL; - - while(x < len && apr_queue_trypop(handle->retry_queue, &pop) == APR_SUCCESS) { - if (!pop) { - break; - } else { - struct packet_node *packet_node = (struct packet_node *) pop; - apr_time_t now = apr_time_now(); - x++; - - if (packet_node->next <= now) { - if (packet_node->retries > 0) { - packet_node->retries--; - if (globals.debug) { - globals.logger(DL_LOG_CRIT, "Sending packet %s (%d left)\n", packet_node->id, packet_node->retries); - } - if (iks_send(handle->parser, packet_node->xml) != IKS_OK) { - globals.logger(DL_LOG_DEBUG, "Failed trying re-sending data!\n"); - }; - packet_node->next = now + 5000000; - sent_data = LDL_QUEUE_SENT; - } - } - if (packet_node->retries == 0 || done) { - if (globals.debug) { - globals.logger(DL_LOG_CRIT, "Discarding packet %s\n", packet_node->id); - } - apr_hash_set(handle->retry_hash, packet_node->id, APR_HASH_KEY_STRING, NULL); - iks_delete(packet_node->xml); - free(packet_node); - } else { - apr_queue_push(handle->retry_queue, packet_node); - packet_node = NULL; - } - pop = NULL; - } - } - apr_thread_mutex_unlock(handle->lock); - return sent_data; -} - - -static void xmpp_connect(ldl_handle_t *handle, char *jabber_id, char *pass) -{ - int count_ka = LDL_KEEPALIVE_TIMEOUT; - time_t tstart, tnow; - - while (ldl_test_flag((&globals), LDL_FLAG_READY) && ldl_test_flag(handle, LDL_FLAG_RUNNING)) { - int e; - char tmp[512], *sl; - int fd; - - handle->parser = iks_stream_new(ldl_test_flag(handle, LDL_FLAG_COMPONENT) ? IKS_NS_COMPONENT : IKS_NS_CLIENT, - handle, - (iksStreamHook *) (ldl_test_flag(handle, LDL_FLAG_COMPONENT) ? on_stream_component : on_stream)); - - - iks_set_log_hook(handle->parser, (iksLogHook *) on_log); - - - strncpy(tmp, jabber_id, sizeof(tmp)-1); - sl = strchr(tmp, '/'); - - if (!sl && !ldl_test_flag(handle, LDL_FLAG_COMPONENT)) { - /* user gave no resource name, use the default */ - snprintf(tmp + strlen(tmp), sizeof(tmp) - strlen(tmp), "/%s", "talk"); - } else if (sl && ldl_test_flag(handle, LDL_FLAG_COMPONENT)) { - *sl = '\0'; - } - - handle->acc = iks_id_new(iks_parser_stack(handle->parser), tmp); - - handle->password = pass; - - j_setup_filter(handle); - - globals.logger(DL_LOG_DEBUG, "xmpp connecting\n"); - - e = iks_connect_via(handle->parser, - handle->server ? handle->server : handle->acc->server, - handle->port ? handle->port : IKS_JABBER_PORT, - handle->acc->server); - - switch (e) { - case IKS_OK: - break; - case IKS_NET_NODNS: - globals.logger(DL_LOG_CRIT, "hostname lookup failed\n"); - microsleep(1000); - goto fail; - case IKS_NET_NOCONN: - globals.logger(DL_LOG_CRIT, "connection failed\n"); - microsleep(1000); - goto fail; - default: - globals.logger(DL_LOG_CRIT, "io error 1 %d\n", e); - microsleep(1000); - goto fail; - } - - handle->counter = opt_timeout; - if ((tstart = time(NULL)) == -1) { - globals.logger(DL_LOG_DEBUG, "error determining connection time"); - } - - while (ldl_test_flag((&globals), LDL_FLAG_READY) && ldl_test_flag(handle, LDL_FLAG_RUNNING)) { - e = iks_recv(handle->parser, 1); - - if (handle->loop_callback) { - if (handle->loop_callback(handle) != LDL_STATUS_SUCCESS) { - ldl_clear_flag_locked(handle, LDL_FLAG_RUNNING); - break; - } - } - - if (handle->job_done) { - break; - } - - if (IKS_HOOK == e) { - break; - } - - if (IKS_OK != e || ldl_test_flag(handle, LDL_FLAG_BREAK)) { - globals.logger(DL_LOG_DEBUG, "io error 2 %d retry in %d second(s)", e, ++handle->fail_count); - if ((tnow = time(NULL)) == -1) { - globals.logger(DL_LOG_DEBUG, "error deterniming io error time"); - } - if (difftime(tnow, tstart) > 30) { - /* this is a new error situation: reset counter */ - globals.logger(DL_LOG_DEBUG, "resetting fail count"); - handle->fail_count = 1; - } - microsleep(1000 * handle->fail_count); - goto fail; - } - - if (ldl_test_flag(handle, LDL_FLAG_RUNNING)) { - if (ldl_flush_queue(handle, 0) == LDL_QUEUE_SENT) { - count_ka = LDL_KEEPALIVE_TIMEOUT; - } - } - - if (!ldl_test_flag(handle, LDL_FLAG_CONNECTED)) { - handle->counter--; - - if (IKS_NET_TLSFAIL == e) { - globals.logger(DL_LOG_CRIT, "tls handshake failed\n"); - microsleep(500); - break; - } - - if (handle->counter == 0) { - globals.logger(DL_LOG_CRIT, "network timeout\n"); - microsleep(500); - break; - } - } - - if (count_ka-- <= 0) { - if( iks_send_raw(handle->parser, " ") == IKS_OK) { - globals.logger(DL_LOG_DEBUG, "Sent keep alive signal"); - count_ka = LDL_KEEPALIVE_TIMEOUT; - } else { - globals.logger(DL_LOG_DEBUG, "Failed sending keep alive signal"); - microsleep(500); - break; - } - } - - } - - fail: - - ldl_clear_flag_locked(handle, LDL_FLAG_CONNECTED); - ldl_clear_flag_locked(handle, LDL_FLAG_AUTHORIZED); - ldl_clear_flag_locked(handle, LDL_FLAG_BREAK); - handle->state = CS_NEW; - - if ((fd = iks_fd(handle->parser)) > -1) { - shutdown(fd, 0x02); - } - - iks_disconnect(handle->parser); - iks_parser_delete(handle->parser); - } - ldl_clear_flag_locked(handle, LDL_FLAG_RUNNING); - - ldl_flush_queue(handle, 1); - - ldl_set_flag_locked(handle, LDL_FLAG_STOPPED); - -} - -static void add_elements(ldl_session_t *session, iks *tag) -{ - apr_hash_index_t *hi; - return; - for (hi = apr_hash_first(session->pool, session->variables); hi; hi = apr_hash_next(hi)) { - void *val = NULL; - const void *key = NULL; - - apr_hash_this(hi, &key, NULL, &val); - if (val) { - iks *var = iks_insert(tag, "info_element"); - iks_insert_attrib(var, "xmlns", "http://www.freeswitch.org/jie"); - iks_insert_attrib(var, "name", (char *) key); - iks_insert_attrib(var, "value", (char *) val); - } - } -} - - -static iks *ldl_set_jingle_tag(ldl_session_t *session, iks *iq, char *action) -{ - iks *jin = iks_insert (iq, "jin:jingle"); - iks_insert_attrib(jin, "xmlns:jin", "urn:xmpp:jingle:1"); - iks_insert_attrib(jin, "action", action); - iks_insert_attrib(jin, "sid", session->id); - //iks_insert_attrib(jin, "initiator", session->initiator ? session->initiator : session->them); - - return jin; -} - -static ldl_status new_jingle_iq(ldl_session_t *session, iks **iqp, iks **jinp, unsigned int *id, char *action) -{ - iks *iq , *jin; - unsigned int myid; - char idbuf[80]; - - myid = next_id(); - snprintf(idbuf, sizeof(idbuf), "%u", myid); - iq = iks_new("iq"); - iks_insert_attrib(iq, "xmlns", "jabber:client"); - iks_insert_attrib(iq, "from", session->login); - iks_insert_attrib(iq, "to", session->them); - iks_insert_attrib(iq, "type", "set"); - iks_insert_attrib(iq, "id", idbuf); - - jin = ldl_set_jingle_tag(session, iq, action); - - *jinp = jin; - *iqp = iq; - *id = myid; - return LDL_STATUS_SUCCESS; -} - - -static ldl_status new_session_iq(ldl_session_t *session, iks **iqp, iks **sessp, unsigned int *id, char *type) -{ - iks *iq, *sess; - unsigned int myid; - char idbuf[80]; - - myid = next_id(); - snprintf(idbuf, sizeof(idbuf), "%u", myid); - iq = iks_new("iq"); - iks_insert_attrib(iq, "xmlns", "jabber:client"); - iks_insert_attrib(iq, "from", session->login); - iks_insert_attrib(iq, "to", session->them); - iks_insert_attrib(iq, "type", "set"); - iks_insert_attrib(iq, "id", idbuf); - sess = iks_insert (iq, "ses:session"); - iks_insert_attrib(sess, "xmlns:ses", "http://www.google.com/session"); - - iks_insert_attrib(sess, "type", type); - iks_insert_attrib(sess, "id", session->id); - iks_insert_attrib(sess, "initiator", session->initiator ? session->initiator : session->them); - - *sessp = sess; - *iqp = iq; - *id = myid; - return LDL_STATUS_SUCCESS; -} - -static void schedule_packet(ldl_handle_t *handle, unsigned int id, iks *xml, unsigned int retries) -{ - struct packet_node *packet_node; - - apr_thread_mutex_lock(handle->lock); - if ((packet_node = malloc(sizeof(*packet_node)))) { - memset(packet_node, 0, sizeof(*packet_node)); - snprintf(packet_node->id, sizeof(packet_node->id), "%u", id); - packet_node->xml = xml; - packet_node->retries = retries; - packet_node->next = apr_time_now(); - apr_hash_set(handle->retry_hash, packet_node->id, APR_HASH_KEY_STRING, packet_node); - apr_queue_push(handle->retry_queue, packet_node); - packet_node = NULL; - } - apr_thread_mutex_unlock(handle->lock); - -} - -char *ldl_session_get_caller(ldl_session_t *session) -{ - return session->them; -} - -char *ldl_session_get_callee(ldl_session_t *session) -{ - return session->login; -} - -void ldl_session_set_ip(ldl_session_t *session, char *ip) -{ - session->ip = apr_pstrdup(session->pool, ip); -} - -char *ldl_session_get_ip(ldl_session_t *session) -{ - return session->ip; -} - -void ldl_session_set_private(ldl_session_t *session, void *private_data) -{ - session->private_data = private_data; -} - -void *ldl_session_get_private(ldl_session_t *session) -{ - return session->private_data; -} - -void ldl_session_accept_candidate(ldl_session_t *session, ldl_candidate_t *candidate) -{ - iks *iq, *sess, *tp; - unsigned int myid; - char idbuf[80]; - myid = next_id(); - snprintf(idbuf, sizeof(idbuf), "%u", myid); - - if ((iq = iks_new("iq"))) { - if (!iks_insert_attrib(iq, "type", "set")) goto fail; - if (!iks_insert_attrib(iq, "id", idbuf)) goto fail; - if (!iks_insert_attrib(iq, "from", session->login)) goto fail; - if (!iks_insert_attrib(iq, "to", session->them)) goto fail; - if (!(sess = iks_insert (iq, "ses:session"))) goto fail; - if (!iks_insert_attrib(sess, "xmlns:ses", "http://www.google.com/session")) goto fail; - if (!iks_insert_attrib(sess, "type", "transport-accept")) goto fail; - if (!iks_insert_attrib(sess, "id", candidate->tid)) goto fail; - if (!iks_insert_attrib(sess, "xmlns", "http://www.google.com/session")) goto fail; - if (!iks_insert_attrib(sess, "initiator", session->initiator ? session->initiator : session->them)) goto fail; - if (!(tp = iks_insert (sess, "transport"))) goto fail; - if (!iks_insert_attrib(tp, "xmlns", "http://www.google.com/transport/p2p")) goto fail; - apr_queue_push(session->handle->queue, iq); - iq = NULL; - } - - fail: - if (iq) { - iks_delete(iq); - } - -} - -void *ldl_handle_get_private(ldl_handle_t *handle) -{ - return handle->private_info; -} - -char *ldl_handle_get_login(ldl_handle_t *handle) -{ - return handle->login; -} - -void ldl_handle_send_presence(ldl_handle_t *handle, char *from, char *to, char *type, char *rpid, char *message, char *avatar) -{ - do_presence(handle, from, to, type, rpid, message, avatar); -} - -static void ldl_random_string(char *buf, uint16_t len, char *set) -{ - char chars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; - int max; - uint16_t x; - - if (!set) { - set = chars; - } - - max = (int) strlen(set); - - srand((unsigned int) time(NULL)); - - for (x = 0; x < len; x++) { - int j = (int) (max * 1.0 * rand() / (RAND_MAX + 1.0)); - buf[x] = set[j]; - } -} - -#define TLEN 8192 -void ldl_handle_send_vcard(ldl_handle_t *handle, char *from, char *to, char *id, char *vcard) -{ - iks *vxml = NULL, *iq = NULL; - int e = 0; - ldl_avatar_t *ap = NULL; - char *text = NULL; - - ap = ldl_get_avatar(handle, NULL, from); - - if (!vcard) { - char *ext; - - if (!ap) { - return; - } - - if ((ext = strrchr(ap->path, '.'))) { - ext++; - } else { - ext = "png"; - } - text = malloc(TLEN); - snprintf(text, TLEN, - "image/%s%s", - ext, - ap->base64 - ); - vcard = text; - } else { - if (ap && (strstr(vcard, "photo") || strstr(vcard, "PHOTO"))) { - ldl_random_string(ap->hash, sizeof(ap->hash) -1, NULL); - } - } - - - if (!(vxml = iks_tree(vcard, 0, &e))) { - globals.logger(DL_LOG_ERR, "Parse returned error [%d]\n", e); - goto fail; - } - - if (!(iq = iks_new("iq"))) { - globals.logger(DL_LOG_ERR, "Memory Error\n"); - goto fail; - } - - if (!iks_insert_attrib(iq, "to", to)) goto fail; - if (!iks_insert_attrib(iq, "xmlns", "jabber:client")) goto fail; - if (!iks_insert_attrib(iq,"from", from)) goto fail; - if (!iks_insert_attrib(iq, "type", "result")) goto fail; - if (!iks_insert_attrib(iq, "id", id)) goto fail; - if (!iks_insert_node(iq, vxml)) goto fail; - - apr_queue_push(handle->queue, iq); - - iq = NULL; - vxml = NULL; - - fail: - - if (iq) { - iks_delete(iq); - } - - if (vxml) { - iks_delete(vxml); - } - - if (text) { - free(text); - } - -} - -void ldl_handle_send_msg(ldl_handle_t *handle, char *from, char *to, const char *subject, const char *body) -{ - iks *msg; - char *t, *e; - char *bdup = NULL; - int on = 0; - int len = 0; - char *my_body = strdup(body); - char *my_body_base = my_body; - - assert(handle != NULL); - assert(body != NULL); - - if (strchr(my_body, '<')) { - len = (int) strlen(my_body); - if (!(bdup = malloc(len))) { - return; - } - - memset(bdup, 0, len); - - e = bdup; - for(t = my_body; *t; t++) { - if (*t == '<') { - on = 1; - } else if (*t == '>') { - t++; - on = 0; - } - - if (!on) { - *e++ = *t; - } - } - my_body = bdup; - } - - msg = iks_make_msg(IKS_TYPE_NONE, to, my_body); - iks_insert_attrib(msg, "type", "chat"); - - if (!from) { - from = handle->login; - } - - iks_insert_attrib(msg, "from", from); - - if (subject) { - iks_insert_attrib(msg, "subject", subject); - } - - if (bdup) { - free(bdup); - } - - if (my_body_base) { - free(my_body_base); - } - - apr_queue_push(handle->queue, msg); - msg = NULL; - -} - -int ldl_global_debug(int on) -{ - if (on > -1) { - globals.debug = on ? 1 : 0; - } - - return globals.debug ? 1 : 0; -} - -void ldl_global_set_logger(ldl_logger_t logger) -{ - globals.logger = logger; -} - -unsigned int ldl_session_terminate(ldl_session_t *session) -{ - iks *iq, *sess; - unsigned int id; - apr_hash_t *hash = session->handle->sessions; - - new_session_iq(session, &iq, &sess, &id, "terminate"); - - if ((session->handle->flags & LDL_FLAG_JINGLE)) { - ldl_set_jingle_tag(session, iq, "session-terminate"); - } - - schedule_packet(session->handle, id, iq, LDL_RETRY); - - if (session->id) { - apr_hash_set(hash, session->id, APR_HASH_KEY_STRING, NULL); - } - - if (session->them) { - apr_hash_set(hash, session->them, APR_HASH_KEY_STRING, NULL); - } - - return id; - -} - - - -unsigned int ldl_session_transport(ldl_session_t *session, - ldl_candidate_t *candidates, - unsigned int clen) - -{ - iks *iq, *sess, *tag; - unsigned int x, id = 0; - - - if ((session->handle->flags & LDL_FLAG_JINGLE)) { - return ldl_session_candidates(session, candidates, clen); - } - - - - for (x = 0; x < clen; x++) { - char buf[512]; - iq = NULL; - sess = NULL; - id = 0; - - new_session_iq(session, &iq, &sess, &id, "transport-info"); - - tag = sess; - - //if (0) add_elements(session, tag); - tag = iks_insert(tag, "transport"); - iks_insert_attrib(tag, "xmlns", "http://www.google.com/transport/p2p"); - //iks_insert_attrib(tag, "xmlns", "urn:xmpp:jingle:transports:raw-udp:1"); - - tag = iks_insert(tag, "candidate"); - - if (candidates[x].name) { - iks_insert_attrib(tag, "name", candidates[x].name); - } - if (candidates[x].address) { - iks_insert_attrib(tag, "address", candidates[x].address); - } - if (candidates[x].port) { - snprintf(buf, sizeof(buf), "%u", candidates[x].port); - iks_insert_attrib(tag, "port", buf); - } - if (candidates[x].username) { - iks_insert_attrib(tag, "username", candidates[x].username); - } - if (candidates[x].password) { - iks_insert_attrib(tag, "password", candidates[x].password); - } - if (candidates[x].pref) { - snprintf(buf, sizeof(buf), "%0.1f", candidates[x].pref); - iks_insert_attrib(tag, "preference", buf); - } - if (candidates[x].protocol) { - iks_insert_attrib(tag, "protocol", candidates[x].protocol); - } - if (candidates[x].type) { - iks_insert_attrib(tag, "type", candidates[x].type); - } - - iks_insert_attrib(tag, "network", "0"); - iks_insert_attrib(tag, "generation", "0"); - schedule_packet(session->handle, id, iq, LDL_RETRY); - } - - return id; -} - -unsigned int ldl_session_candidates(ldl_session_t *session, - ldl_candidate_t *candidates, - unsigned int clen) - -{ - iks *iq = NULL, *sess = NULL, *tag = NULL; - unsigned int x = 0, id = 0; - - - unsigned int pass = 0; - iks *jingle = NULL, *jin_content = NULL, *p_trans = NULL; - const char *tname = ""; - const char *type = ""; - - if ((session->handle->flags & LDL_FLAG_JINGLE)) { - - - new_jingle_iq(session, &iq, &jingle, &id, "transport-info"); - - for (pass = 0; pass < 2; pass++) { - - if (pass == 0) { - type = "rtp"; - tname = "audio"; - } else { - type = "video_rtp"; - tname = "video"; - } - - jin_content = iks_insert(jingle, "jin:content"); - iks_insert_attrib(jin_content, "name", tname); - iks_insert_attrib(jin_content, "creator", "initiator"); - - for (x = 0; x < clen; x++) { - char buf[512]; - - if (strcasecmp(candidates[x].name, type)) { - continue; - } - - p_trans = iks_insert(jin_content, "p:transport"); - iks_insert_attrib(p_trans, "xmlns:p", "http://www.google.com/transport/p2p"); - - - - tag = iks_insert(p_trans, "candidate"); - - if (candidates[x].name) { - iks_insert_attrib(tag, "name", candidates[x].name); - } - if (candidates[x].address) { - iks_insert_attrib(tag, "address", candidates[x].address); - } - if (candidates[x].port) { - snprintf(buf, sizeof(buf), "%u", candidates[x].port); - iks_insert_attrib(tag, "port", buf); - } - if (candidates[x].username) { - iks_insert_attrib(tag, "username", candidates[x].username); - } - if (candidates[x].password) { - iks_insert_attrib(tag, "password", candidates[x].password); - } - if (candidates[x].pref) { - snprintf(buf, sizeof(buf), "%0.1f", candidates[x].pref); - iks_insert_attrib(tag, "preference", buf); - } - if (candidates[x].protocol) { - iks_insert_attrib(tag, "protocol", candidates[x].protocol); - } - if (candidates[x].type) { - iks_insert_attrib(tag, "type", candidates[x].type); - } - - iks_insert_attrib(tag, "network", "0"); - iks_insert_attrib(tag, "generation", "0"); - } - } - - - schedule_packet(session->handle, id, iq, LDL_RETRY); - - iq = NULL; - sess = NULL; - tag = NULL; - id = 0; - } - - - new_session_iq(session, &iq, &sess, &id, "candidates"); - add_elements(session, sess); - - for (x = 0; x < clen; x++) { - char buf[512]; - //iq = NULL; - //sess = NULL; - //id = 0; - - tag = iks_insert(sess, "ses:candidate"); - - - - if (candidates[x].name) { - iks_insert_attrib(tag, "name", candidates[x].name); - } - if (candidates[x].address) { - iks_insert_attrib(tag, "address", candidates[x].address); - } - if (candidates[x].port) { - snprintf(buf, sizeof(buf), "%u", candidates[x].port); - iks_insert_attrib(tag, "port", buf); - } - if (candidates[x].username) { - iks_insert_attrib(tag, "username", candidates[x].username); - } - if (candidates[x].password) { - iks_insert_attrib(tag, "password", candidates[x].password); - } - if (candidates[x].pref) { - snprintf(buf, sizeof(buf), "%0.1f", candidates[x].pref); - iks_insert_attrib(tag, "preference", buf); - } - if (candidates[x].protocol) { - iks_insert_attrib(tag, "protocol", candidates[x].protocol); - } - if (candidates[x].type) { - iks_insert_attrib(tag, "type", candidates[x].type); - } - - iks_insert_attrib(tag, "network", "0"); - iks_insert_attrib(tag, "generation", "0"); - - } - - schedule_packet(session->handle, id, iq, LDL_RETRY); - - return id; -} - - - -char *ldl_handle_probe(ldl_handle_t *handle, char *id, char *from, char *buf, unsigned int len) -{ - iks *pres, *msg; - char *lid = NULL, *low_id = NULL; - struct ldl_buffer buffer; - time_t started, elapsed, next = 0; - char *notice = "Call Me!"; - - buffer.buf = buf; - buffer.len = len; - buffer.hit = 0; - - apr_hash_set(handle->probe_hash, id, APR_HASH_KEY_STRING, &buffer); - - started = time(NULL); - for(;;) { - elapsed = time(NULL) - started; - if (elapsed == next) { - msg = iks_make_s10n (IKS_TYPE_SUBSCRIBE, id, notice); - iks_insert_attrib(msg, "from", from); - apr_queue_push(handle->queue, msg); - msg = NULL; - - pres = iks_new("presence"); - iks_insert_attrib(pres, "xmlns", "jabber:client"); - iks_insert_attrib(pres, "type", "probe"); - iks_insert_attrib(pres, "to", id); - iks_insert_attrib(pres, "from", from); - apr_queue_push(handle->queue, pres); - pres = NULL; - next += 5; - } - if (elapsed >= 17) { - break; - } - if (buffer.hit) { - lid = buffer.buf; - break; - } - ldl_yield(1000); - } - - if ((low_id = strdup(id))) { - lowercase(id); - apr_hash_set(handle->probe_hash, low_id, APR_HASH_KEY_STRING, NULL); - free(low_id); - } - - return lid; -} - - -char *ldl_handle_disco(ldl_handle_t *handle, char *id, char *from, char *buf, unsigned int len) -{ - iks *iq, *query, *msg; - char *lid = NULL; - struct ldl_buffer buffer; - apr_time_t started; - unsigned int elapsed; - char *notice = "Call Me!"; - int again = 0; - unsigned int myid; - char idbuf[80]; - - myid = next_id(); - snprintf(idbuf, sizeof(idbuf), "%u", myid); - - buffer.buf = buf; - buffer.len = len; - buffer.hit = 0; - - if ((iq = iks_new("iq"))) { - if ((query = iks_insert(iq, "query"))) { - iks_insert_attrib(iq, "type", "get"); - iks_insert_attrib(iq, "to", id); - iks_insert_attrib(iq,"from", from); - iks_insert_attrib(iq, "id", idbuf); - iks_insert_attrib(query, "xmlns", "http://jabber.org/protocol/disco#info"); - } else { - iks_delete(iq); - globals.logger(DL_LOG_CRIT, "Memory ERROR!\n"); - return NULL; - } - } else { - globals.logger(DL_LOG_CRIT, "Memory ERROR!\n"); - return NULL; - } - - apr_hash_set(handle->probe_hash, id, APR_HASH_KEY_STRING, &buffer); - msg = iks_make_s10n (IKS_TYPE_SUBSCRIBE, id, notice); - apr_queue_push(handle->queue, msg); - msg = NULL; - msg = iks_make_s10n (IKS_TYPE_SUBSCRIBED, id, notice); - apr_queue_push(handle->queue, msg); - msg = NULL; - apr_queue_push(handle->queue, iq); - iq = NULL; - - //schedule_packet(handle, next_id(), pres, LDL_RETRY); - - started = apr_time_now(); - for(;;) { - elapsed = (unsigned int)((apr_time_now() - started) / 1000); - if (elapsed > 5000 && ! again) { - msg = iks_make_s10n (IKS_TYPE_SUBSCRIBE, id, notice); - apr_queue_push(handle->queue, msg); - msg = NULL; - again++; - } - if (elapsed > 10000) { - break; - } - if (buffer.hit) { - lid = buffer.buf; - break; - } - ldl_yield(1000); - } - - apr_hash_set(handle->probe_hash, id, APR_HASH_KEY_STRING, NULL); - return lid; -} - - - -unsigned int ldl_session_describe(ldl_session_t *session, - ldl_payload_t *payloads, - unsigned int plen, - ldl_description_t description, unsigned int *audio_ssrc, unsigned int *video_ssrc, - ldl_crypto_data_t *audio_crypto_data, ldl_crypto_data_t *video_crypto_data) -{ - iks *iq; - iks *sess, *payload = NULL, *tag = NULL;//, *u = NULL; - - unsigned int x, id; - int video_call = 0; - int compat = 1; - //char *vid_mux = ldl_session_get_value(session, "video:rtcp-mux"); - //char *aud_mux = ldl_session_get_value(session, "audio:rtcp-mux"); - char tmp[80]; - iks *jpayload = NULL, *tp = NULL; - iks *jingle, *jin_audio, *jin_audio_desc = NULL, *jin_video = NULL, *jin_video_desc = NULL, *crypto; - - - if (!*audio_ssrc) { - *audio_ssrc = (uint32_t) ((intptr_t) session + (uint32_t) time(NULL)); - } - - if (!*video_ssrc) { - *video_ssrc = (uint32_t) ((intptr_t) payloads + (uint32_t) time(NULL)); - } - - if ((session->handle->flags & LDL_FLAG_JINGLE)) { - new_jingle_iq(session, &iq, &jingle, &id, description == LDL_DESCRIPTION_ACCEPT ? "session-accept" : "session-initiate"); - iks_insert_attrib(jingle, "initiator", session->initiator ? session->initiator : session->them); - - if (compat) { - sess = iks_insert (iq, "ses:session"); - iks_insert_attrib(sess, "xmlns:ses", "http://www.google.com/session"); - - iks_insert_attrib(sess, "type", description == LDL_DESCRIPTION_ACCEPT ? "accept" : "initiate"); - iks_insert_attrib(sess, "id", session->id); - iks_insert_attrib(sess, "initiator", session->initiator ? session->initiator : session->them); - } - - } else { - new_session_iq(session, &iq, &sess, &id, description == LDL_DESCRIPTION_ACCEPT ? "accept" : "initiate"); - } - - - /* Check if this is a video call */ - for (x = 0; x < plen; x++) { - if (payloads[x].type == LDL_PAYLOAD_VIDEO) { - video_call = 1; - if ((session->handle->flags & LDL_FLAG_JINGLE)) { - jin_video = iks_insert(jingle, "jin:content"); - iks_insert_attrib(jin_video, "name", "video"); - iks_insert_attrib(jin_video, "creator", "initiator"); - //iks_insert_attrib(jin_video, "senders", "both"); - jin_video_desc = iks_insert(jin_video, "rtp:description"); - iks_insert_attrib(jin_video_desc, "xmlns:rtp", "urn:xmpp:jingle:apps:rtp:1"); - iks_insert_attrib(jin_video_desc, "media", "video"); - snprintf(tmp, sizeof(tmp), "%u", *video_ssrc); - iks_insert_attrib(jin_video_desc, "ssrc", tmp); - tp = iks_insert(jin_video, "p:transport"); - iks_insert_attrib(tp, "xmlns:p", "http://www.google.com/transport/p2p"); - - } - - break; - } - } - - - if ((session->handle->flags & LDL_FLAG_JINGLE)) { - jin_audio = iks_insert(jingle, "jin:content"); - iks_insert_attrib(jin_audio, "name", "audio"); - iks_insert_attrib(jin_audio, "creator", "initiator"); - //iks_insert_attrib(jin_audio, "senders", "both"); - jin_audio_desc = iks_insert(jin_audio, "rtp:description"); - iks_insert_attrib(jin_audio_desc, "xmlns:rtp", "urn:xmpp:jingle:apps:rtp:1"); - iks_insert_attrib(jin_audio_desc, "media", "audio"); - snprintf(tmp, sizeof(tmp), "%u", *audio_ssrc); - iks_insert_attrib(jin_audio_desc, "ssrc", tmp); - tp = iks_insert(jin_audio, "p:transport"); - iks_insert_attrib(tp, "xmlns:p", "http://www.google.com/transport/p2p"); - } - - if (compat) { - - if (video_call) { - tag = iks_insert(sess, "vid:description"); - iks_insert_attrib(tag, "xmlns:vid", "http://www.google.com/session/video"); - } else { - tag = iks_insert(sess, "pho:description"); - iks_insert_attrib(tag, "xmlns:pho", "http://www.google.com/session/phone"); - } - - if (video_call) { - - for (x = 0; x < plen; x++) { - char idbuf[80]; - - if (payloads[x].type != LDL_PAYLOAD_VIDEO) { - continue; - } - - sprintf(idbuf, "%d", payloads[x].id); - - - payload = iks_insert(tag, "vid:payload-type"); - - iks_insert_attrib(payload, "id", idbuf); - iks_insert_attrib(payload, "name", payloads[x].name); - - if (payloads[x].type == LDL_PAYLOAD_VIDEO && video_call) { - if (payloads[x].width) { - sprintf(idbuf, "%d", payloads[x].width); - iks_insert_attrib(payload, "width", idbuf); - } - if (payloads[x].height) { - sprintf(idbuf, "%d", payloads[x].height); - iks_insert_attrib(payload, "height", idbuf); - } - if (payloads[x].framerate) { - sprintf(idbuf, "%d", payloads[x].framerate); - iks_insert_attrib(payload, "framerate", idbuf); - } - } - - } - - - //if (vid_mux) { - // iks_insert(tag, "rtcp-mux"); - //} - - //payload = iks_insert(tag, "vid:src-id"); - //iks_insert_cdata(payload, "123456789", 0); - - - //iks_insert_attrib(payload, "xmlns:rtp", "urn:xmpp:jingle:apps:rtp:1"); - //iks_insert(payload, "vid:usage"); - } - } - - for (x = 0; x < plen; x++) { - char idbuf[80]; - - if (payloads[x].type == LDL_PAYLOAD_VIDEO && !video_call) { - continue; - } - - sprintf(idbuf, "%d", payloads[x].id); - - if (payloads[x].type == LDL_PAYLOAD_AUDIO) { - - if ((session->handle->flags & LDL_FLAG_JINGLE)) { - char ratebuf[80]; - char buf[80]; - iks *param; - - jpayload = iks_insert(jin_audio_desc, "rtp:payload-type"); - iks_insert_attrib(jpayload, "id", idbuf); - sprintf(ratebuf, "%d", payloads[x].rate); - iks_insert_attrib(jpayload, "name", payloads[x].name); - iks_insert_attrib(jpayload, "clockrate", ratebuf); - param = iks_insert(jpayload, "rtp:parameter"); - iks_insert_attrib(param, "name", "bitrate"); - sprintf(buf, "%d", payloads[x].bps); - iks_insert_attrib(param, "value", buf); - - sprintf(buf, "%d", payloads[x].ptime); - iks_insert_attrib(jpayload, "ptime", ratebuf); - iks_insert_attrib(jpayload, "maxptime", ratebuf); - - } - - } else if (payloads[x].type == LDL_PAYLOAD_VIDEO && video_call) { - - if ((session->handle->flags & LDL_FLAG_JINGLE)) { - char buf[80]; - iks *param; - - jpayload = iks_insert(jin_video_desc, "rtp:payload-type"); - iks_insert_attrib(jpayload, "id", idbuf); - iks_insert_attrib(jpayload, "name", payloads[x].name); - param = iks_insert(jpayload, "rtp:parameter"); - iks_insert_attrib(param, "name", "width"); - sprintf(buf, "%d", payloads[x].width); - iks_insert_attrib(param, "value", buf); - - - param = iks_insert(jpayload, "rtp:parameter"); - iks_insert_attrib(param, "name", "height"); - sprintf(buf, "%d", payloads[x].height); - iks_insert_attrib(param, "value", buf); - - param = iks_insert(jpayload, "rtp:parameter"); - iks_insert_attrib(param, "name", "framerate"); - sprintf(buf, "%d", payloads[x].framerate); - iks_insert_attrib(param, "value", buf); - - } - } - - if (compat) { - - if (payloads[x].type == LDL_PAYLOAD_AUDIO) { - - payload = iks_insert(tag, "pho:payload-type"); - - iks_insert_attrib(payload, "id", idbuf); - iks_insert_attrib(payload, "name", payloads[x].name); - - if (payloads[x].rate) { - sprintf(idbuf, "%d", payloads[x].rate); - iks_insert_attrib(payload, "clockrate", idbuf); - } - - if (payloads[x].bps) { - sprintf(idbuf, "%d", payloads[x].bps); - iks_insert_attrib(payload, "bitrate", idbuf); - } - - iks_insert_attrib(payload, "xmlns:pho", "http://www.google.com/session/phone"); - } - } - //if (payloads[x].id == 34) payloads[x].id = 98; /* XXX */ - - } - - if ((session->handle->flags & LDL_FLAG_JINGLE)) { - if (jin_video_desc && video_crypto_data) { - payload = iks_insert(jin_video_desc, "rtp:encryption"); - crypto = iks_insert(payload, "rtp:crypto"); - iks_insert_attrib(crypto, "crypto-suite", video_crypto_data->suite); - iks_insert_attrib(crypto, "key-params", video_crypto_data->key); - iks_insert_attrib(crypto, "tag", video_crypto_data->tag); - } - - - if (jin_audio_desc && audio_crypto_data) { - payload = iks_insert(jin_audio_desc, "rtp:encryption"); - crypto = iks_insert(payload, "rtp:crypto"); - iks_insert_attrib(crypto, "crypto-suite", audio_crypto_data->suite); - iks_insert_attrib(crypto, "key-params", audio_crypto_data->key); - iks_insert_attrib(crypto, "tag", audio_crypto_data->tag); - } - } - - //if (aud_mux) { - // iks_insert(tag, "rtcp-mux"); - //} - - //payload = iks_insert(tag, "pho:src-id"); - //iks_insert_cdata(payload, "987654321", 0); - //iks_insert_attrib(payload, "xmlns:pho", "http://www.google.com/session/phone"); - - //payload = iks_insert(tag, "rtp:encryption"); - //iks_insert_attrib(payload, "xmlns:rtp", "urn:xmpp:jingle:apps:rtp:1"); - //u = iks_insert(payload, "pho:usage"); - //iks_insert_attrib(u, "xmlns:pho", "http://www.google.com/session/phone"); - -#if 0 - if (description == LDL_DESCRIPTION_INITIATE) { - tp = iks_insert (sess, "transport"); - iks_insert_attrib(tp, "xmlns", "http://www.google.com/transport/p2p"); - } -#endif - - - schedule_packet(session->handle, id, iq, LDL_RETRY); - - return id; -} - -ldl_state_t ldl_session_get_state(ldl_session_t *session) -{ - return session->state; -} - -ldl_status ldl_session_get_candidates(ldl_session_t *session, ldl_transport_type_t tport, ldl_candidate_t **candidates, unsigned int *len) -{ - assert(tport < LDL_TPORT_MAX); - - if (session->candidate_len[tport]) { - *candidates = session->candidates[tport]; - *len = session->candidate_len[tport]; - return LDL_STATUS_SUCCESS; - } else { - *candidates = NULL; - *len = 0; - return LDL_STATUS_FALSE; - } -} - -ldl_status ldl_session_get_payloads(ldl_session_t *session, ldl_payload_t **payloads, unsigned int *len) -{ - if (session->payload_len) { - *payloads = session->payloads; - *len = session->payload_len; - return LDL_STATUS_SUCCESS; - } else { - *payloads = NULL; - *len = 0; - return LDL_STATUS_FALSE; - } -} - -ldl_status ldl_global_terminate(void) -{ - if (globals.flag_mutex) { - ldl_clear_flag_locked((&globals), LDL_FLAG_READY); - } else { - ldl_clear_flag((&globals), LDL_FLAG_READY); - } - return LDL_STATUS_SUCCESS; -} - -ldl_status ldl_global_init(int debug) -{ - if (ldl_test_flag((&globals), LDL_FLAG_INIT)) { - return LDL_STATUS_FALSE; - } - - if (apr_initialize() != LDL_STATUS_SUCCESS) { - apr_terminate(); - return LDL_STATUS_MEMERR; - } - - memset(&globals, 0, sizeof(globals)); - - if (apr_pool_create(&globals.memory_pool, NULL) != LDL_STATUS_SUCCESS) { - globals.logger(DL_LOG_CRIT, "Could not allocate memory pool\n"); - return LDL_STATUS_MEMERR; - } - - apr_thread_mutex_create(&globals.flag_mutex, APR_THREAD_MUTEX_NESTED, globals.memory_pool); - globals.log_stream = stdout; - globals.debug = debug; - globals.id = 300; - globals.logger = default_logger; - globals.avatar_hash = apr_hash_make(globals.memory_pool); - ldl_set_flag_locked((&globals), LDL_FLAG_INIT); - ldl_set_flag_locked((&globals), LDL_FLAG_READY); - - return LDL_STATUS_SUCCESS; -} - -ldl_status ldl_global_destroy(void) -{ - if (!ldl_test_flag(&globals, LDL_FLAG_INIT)) { - return LDL_STATUS_FALSE; - } - - apr_pool_destroy(globals.memory_pool); - ldl_clear_flag(&globals, LDL_FLAG_INIT); - apr_terminate(); - - return LDL_STATUS_SUCCESS; -} - -void ldl_global_set_log_stream(FILE *log_stream) -{ - assert(ldl_test_flag(&globals, LDL_FLAG_INIT)); - - globals.log_stream = log_stream; -} - -int8_t ldl_handle_ready(ldl_handle_t *handle) -{ - return (int8_t) (ldl_test_flag(handle, LDL_FLAG_RUNNING) && ldl_test_flag((&globals), LDL_FLAG_READY)); -} - -ldl_status ldl_handle_init(ldl_handle_t **handle, - char *login, - char *password, - char *server, - ldl_user_flag_t flags, - char *status_msg, - char *priority, - ldl_loop_callback_t loop_callback, - ldl_session_callback_t session_callback, - ldl_response_callback_t response_callback, - void *private_info) -{ - apr_pool_t *pool; - assert(ldl_test_flag(&globals, LDL_FLAG_INIT)); - *handle = NULL; - - if ((apr_pool_create(&pool, globals.memory_pool)) != LDL_STATUS_SUCCESS) { - return LDL_STATUS_MEMERR; - } - - if (!login) { - globals.logger(DL_LOG_ERR, "No login supplied!\n"); - return LDL_STATUS_FALSE; - } - - if (!password) { - globals.logger(DL_LOG_ERR, "No password supplied!\n"); - return LDL_STATUS_FALSE; - } - - - if ((*handle = apr_palloc(pool, sizeof(ldl_handle_t)))) { - ldl_handle_t *new_handle = *handle; - memset(new_handle, 0, sizeof(ldl_handle_t)); - new_handle->log_stream = globals.log_stream; - new_handle->login = apr_pstrdup(pool, login); - new_handle->password = apr_pstrdup(pool, password); - - if (server) { - char *p; - - new_handle->server = apr_pstrdup(pool, server); - if ((p = strchr(new_handle->server, ':'))) { - *p++ = '\0'; - new_handle->port = (uint16_t)atoi(p); - } - } - - if (status_msg) { - new_handle->status_msg = apr_pstrdup(pool, status_msg); - } - - if (priority) { - new_handle->priority = apr_pstrdup(pool, priority); - } - - if (loop_callback) { - new_handle->loop_callback = loop_callback; - } - - if (session_callback) { - new_handle->session_callback = session_callback; - } - - if (response_callback) { - new_handle->response_callback = response_callback; - } - - new_handle->private_info = private_info; - new_handle->pool = pool; - new_handle->flags |= flags; - apr_queue_create(&new_handle->queue, LDL_HANDLE_QLEN, new_handle->pool); - apr_queue_create(&new_handle->retry_queue, LDL_HANDLE_QLEN, new_handle->pool); - new_handle->features |= IKS_STREAM_BIND|IKS_STREAM_SESSION; - - if (new_handle->flags & LDL_FLAG_SASL_PLAIN) { - new_handle->features |= IKS_STREAM_SASL_PLAIN; - } else if (new_handle->flags & LDL_FLAG_SASL_MD5) { - new_handle->features |= IKS_STREAM_SASL_MD5; - } - - new_handle->sessions = apr_hash_make(new_handle->pool); - new_handle->retry_hash = apr_hash_make(new_handle->pool); - new_handle->probe_hash = apr_hash_make(new_handle->pool); - new_handle->sub_hash = apr_hash_make(new_handle->pool); - apr_thread_mutex_create(&new_handle->lock, APR_THREAD_MUTEX_NESTED, new_handle->pool); - apr_thread_mutex_create(&new_handle->flag_mutex, APR_THREAD_MUTEX_NESTED, new_handle->pool); - - return LDL_STATUS_SUCCESS; - } - - return LDL_STATUS_FALSE; -} - -void ldl_handle_run(ldl_handle_t *handle) -{ - ldl_clear_flag_locked(handle, LDL_FLAG_STOPPED); - ldl_set_flag_locked(handle, LDL_FLAG_RUNNING); - xmpp_connect(handle, handle->login, handle->password); - ldl_clear_flag_locked(handle, LDL_FLAG_RUNNING); -} - -int ldl_handle_running(ldl_handle_t *handle) -{ - return ldl_test_flag(handle, LDL_FLAG_RUNNING) ? 1 : 0; -} - - -void ldl_session_set_gateway(ldl_session_t *session) -{ - ldl_set_flag(session, LDL_FLAG_GATEWAY); -} - -int ldl_session_gateway(ldl_session_t *session) -{ - return ldl_test_flag(session, LDL_FLAG_GATEWAY) ? 1 : 0; -} - -int ldl_handle_connected(ldl_handle_t *handle) -{ - return ldl_test_flag(handle, LDL_FLAG_CONNECTED) ? 1 : 0; -} - -int ldl_handle_authorized(ldl_handle_t *handle) -{ - return ldl_test_flag(handle, LDL_FLAG_AUTHORIZED) ? 1 : 0; -} - -void ldl_handle_stop(ldl_handle_t *handle) -{ - ldl_clear_flag_locked(handle, LDL_FLAG_RUNNING); -#if 0 - if (ldl_test_flag(handle, LDL_FLAG_TLS)) { - int fd; - if ((fd = iks_fd(handle->parser)) > -1) { - shutdown(fd, 0x02); - } - } -#endif - - while(!ldl_test_flag(handle, LDL_FLAG_STOPPED)) { - microsleep(100); - } - -} - -ldl_status ldl_handle_destroy(ldl_handle_t **handle) -{ - apr_pool_t *pool = (*handle)->pool; - - ldl_handle_stop(*handle); - ldl_flush_queue(*handle, 1); - - - apr_pool_destroy(pool); - *handle = NULL; - return LDL_STATUS_SUCCESS; -} - - -void ldl_handle_set_log_stream(ldl_handle_t *handle, FILE *log_stream) -{ - assert(ldl_test_flag(&globals, LDL_FLAG_INIT)); - - handle->log_stream = log_stream; -} - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/libdingaling/src/libdingaling.h b/libs/libdingaling/src/libdingaling.h deleted file mode 100644 index 05fafc6da9..0000000000 --- a/libs/libdingaling/src/libdingaling.h +++ /dev/null @@ -1,751 +0,0 @@ -/* - * libDingaLing XMPP Jingle Library - * Copyright (C) 2005-2014, Anthony Minessale II - * - * Version: MPL 1.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is libDingaLing XMPP Jingle Library - * - * The Initial Developer of the Original Code is - * Anthony Minessale II - * Portions created by the Initial Developer are Copyright (C) - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Anthony Minessale II - * - * libdingaling.h -- Main Header File - * - */ - -/*! \file libdingaling.h - \brief Main Header File -*/ - -/*! - \defgroup core1 libDingaLing Library - \ingroup LIBDINGALING - \{ -*/ -/* OMG */ -#ifdef _MSC_VER -#define __LDL_FUNC__ __FUNCTION__ -#define inline __inline -#else -#define __LDL_FUNC__ (const char *)__func__ -#endif - -#ifndef LIBDINGALING_H -#define LIBDINGALING_H -#ifdef __cplusplus -extern "C" { -#endif -#ifdef __STUPIDFORMATBUG__ -} -#endif - -#if defined (__SVR4) && defined (__sun) -#define __EXTENSIONS__ 1 -#include -#endif - -#define LDL_HANDLE_QLEN 2000 -#define LDL_MAX_CANDIDATES 25 -#define LDL_MAX_PAYLOADS 50 -#define LDL_RETRY 3 -#define IKS_NS_COMPONENT "jabber:component:accept" -/* period between keep alive signals in 1sec units*/ -#define LDL_KEEPALIVE_TIMEOUT 300 - -typedef struct ldl_crypto_data_s { - char *tag; - char *suite; - char *key; -} ldl_crypto_data_t; - -/*! \brief A structure to store a jingle candidate */ -struct ldl_candidate { - /*! the transport id of the candidate */ - char *tid; - /*! the name of the candidate */ - char *name; - /*! the type of the candidate */ - char *type; - /*! the protocol of the candidate */ - char *protocol; - /*! the STUN username of the candidate */ - char *username; - /*! the STUN password of the candidate */ - char *password; - /*! the ip address of the candidate */ - char *address; - /*! the stun/rtp port of the candidate */ - uint16_t port; - /*! the preference level of the candidate */ - double pref; -}; -typedef struct ldl_candidate ldl_candidate_t; - -typedef enum { - LDL_PAYLOAD_AUDIO, - LDL_PAYLOAD_VIDEO -} ldl_payload_type_t; - -/*! \brief A structure to store a jingle audio payload */ -struct ldl_payload { - /*! the type of the payload */ - ldl_payload_type_t type; - /*! the iana name of the payload type */ - char *name; - /*! the iana id of the payload type */ - unsigned int id; - - /* Audio */ - - /*! the transfer rate of the payload type */ - unsigned int rate; - /*! the bits per second of the payload type */ - unsigned int bps; - - /* Video */ - - /*! the width of the video payload type */ - unsigned int width; - /*! the width of the video payload type */ - unsigned int height; - /*! the framerate of the video payload type */ - unsigned int framerate; - - unsigned int ptime; -}; -typedef struct ldl_payload ldl_payload_t; - - -enum ldl_transport_type { - LDL_TPORT_RTP, - LDL_TPORT_VIDEO_RTP, - LDL_TPORT_RTCP, - LDL_TPORT_VIDEO_RTCP, - - /* Nothing below that line */ - LDL_TPORT_MAX -}; -typedef enum ldl_transport_type ldl_transport_type_t; - -static inline const char *ldl_transport_type_str(ldl_transport_type_t type) -{ - static const char *name[] = { "rtp", "video_rtp", "rtcp", "video_rtcp" }; - return type >= LDL_TPORT_MAX ? NULL : name[type]; -} - -static inline ldl_transport_type_t ldl_transport_type_parse(const char *type) { - if (!strcasecmp(type, "rtp")) { - return LDL_TPORT_RTP; - } else if (!strcasecmp(type, "rtcp")) { - return LDL_TPORT_RTCP; - } else if (!strcasecmp(type, "video_rtp")) { - return LDL_TPORT_VIDEO_RTP; - } else if (!strcasecmp(type, "video_rtcp")) { - return LDL_TPORT_VIDEO_RTCP; - } else { - return LDL_TPORT_MAX; - } -} - -#if 0 -/*! \brief A structure to store a jingle video payload */ -struct ldl_vpayload { - /*! the iana name of the video payload type */ - char *name; - /*! the iana id of the video payload type */ - unsigned int id; - /*! the width of the video payload type */ - unsigned int width; - /*! the width of the video payload type */ - unsigned int height; - /*! the framerate of the video payload type */ - unsigned int framerate; -}; -typedef struct ldl_vpayload ldl_vpayload_t; -#endif - -struct ldl_handle; -typedef struct ldl_handle ldl_handle_t; - -struct ldl_session; -typedef struct ldl_session ldl_session_t; - -typedef enum { - LDL_STATUS_SUCCESS, - LDL_STATUS_FALSE, - LDL_STATUS_MEMERR, -} ldl_status; - -typedef enum { - LDL_FLAG_INIT = (1 << 0), - LDL_FLAG_RUNNING = (1 << 1), - LDL_FLAG_AUTHORIZED = (1 << 2), - LDL_FLAG_READY = (1 << 3), - LDL_FLAG_CONNECTED = (1 << 4), - LDL_FLAG_STOPPED = (1 << 5), - LDL_FLAG_BREAK = (1 << 6) -} ldl_flag_t; - -typedef enum { - LDL_FLAG_NONE = 0, - LDL_FLAG_TLS = (1 << 10), - LDL_FLAG_SASL_PLAIN = (1 << 11), - LDL_FLAG_SASL_MD5 = (1 << 12), - LDL_FLAG_COMPONENT = (1 << 13), - LDL_FLAG_OUTBOUND = (1 << 14), - LDL_FLAG_GATEWAY = (1 << 15), - LDL_FLAG_JINGLE = (1 << 16) -} ldl_user_flag_t; - -typedef enum { - LDL_SIGNAL_NONE, - LDL_SIGNAL_INITIATE, - LDL_SIGNAL_CANDIDATES, - LDL_SIGNAL_MSG, - LDL_SIGNAL_PRESENCE_IN, - LDL_SIGNAL_PRESENCE_OUT, - LDL_SIGNAL_PRESENCE_PROBE, - LDL_SIGNAL_ROSTER, - LDL_SIGNAL_SUBSCRIBE, - LDL_SIGNAL_UNSUBSCRIBE, - LDL_SIGNAL_VCARD, - LDL_SIGNAL_TERMINATE, - LDL_SIGNAL_ERROR, - LDL_SIGNAL_LOGIN_SUCCESS, - LDL_SIGNAL_LOGIN_FAILURE, - LDL_SIGNAL_CONNECTED, - LDL_SIGNAL_TRANSPORT_ACCEPT, - LDL_SIGNAL_REJECT, - LDL_SIGNAL_REDIRECT -} ldl_signal_t; - -typedef enum { - LDL_REPLY_ACK, - LDL_REPLY_NACK, -} ldl_reply_t; - -typedef enum { - LDL_STATE_NEW, - LDL_STATE_ANSWERED, - LDL_STATE_DESTROYED, -} ldl_state_t; - -typedef enum { - LDL_DESCRIPTION_INITIATE, - LDL_DESCRIPTION_ACCEPT -} ldl_description_t; - -typedef enum { - LDL_QUEUE_NONE, - LDL_QUEUE_SENT -} ldl_queue_t; - -#define DL_PRE __FILE__, __LDL_FUNC__, __LINE__ -#define DL_LOG_DEBUG DL_PRE, 7 -#define DL_LOG_INFO DL_PRE, 6 -#define DL_LOG_NOTICE DL_PRE, 5 -#define DL_LOG_WARNING DL_PRE, 4 -#define DL_LOG_ERR DL_PRE, 3 -#define DL_LOG_CRIT DL_PRE, 2 -#define DL_LOG_ALERT DL_PRE, 1 -#define DL_LOG_EMERG DL_PRE, 0 - -typedef ldl_status (*ldl_loop_callback_t)(ldl_handle_t *); -typedef ldl_status (*ldl_session_callback_t)(ldl_handle_t *, ldl_session_t *, ldl_signal_t, char *, char *, char *, char *); -typedef ldl_status (*ldl_response_callback_t)(ldl_handle_t *, char *); -typedef void (*ldl_logger_t)(char *file, const char *func, int line, int level, char *fmt, ...); - -#define ldl_yield(ms) apr_sleep(ms * 10); apr_thread_yield(); - -/*! - \brief Test for a common domain in 2 jid - \param id_a the first id - \param id_b the second id - \return 1 if the domains match 0 if they dont or -1 if either id is invalid - \note the id may or may not contain a user and/or resource -*/ -static inline int ldl_jid_domcmp(char *id_a, char *id_b) -{ - char *id_a_host, *id_b_host, *id_a_r, *id_b_r; - - id_a_host = strchr(id_a, '@'); - if (id_a_host) { - id_a_host++; - } else { - id_a_host = id_a; - } - - id_b_host = strchr(id_b, '@'); - if (id_b_host) { - id_b_host++; - } else { - id_b_host = id_b; - } - - if (id_a_host && id_b_host) { - size_t id_a_len = 0, id_b_len = 0, len = 0; - - id_a_r = strchr(id_a_host, '/'); - if (id_a_r) { - id_a_len = id_a_r - id_a_host; - } else { - id_a_len = strlen(id_a_host); - } - - id_b_r = strchr(id_b_host, '/'); - if (id_b_r) { - id_b_len = id_b_r - id_b_host; - } else { - id_b_len = strlen(id_b_host); - } - - if (id_a_len > id_b_len) { - len = id_b_len; - } else { - len = id_a_len; - } - - return strncasecmp(id_a_host, id_b_host, len) ? 0 : 1; - } - return -1; -} - -/*! - \brief Test for the existance of a flag on an arbitary object - \param obj the object to test - \param flag the or'd list of flags to test - \return true value if the object has the flags defined -*/ -#define ldl_test_flag(obj, flag) ((obj)->flags & flag) - - -/*! - \brief Set a flag on an arbitrary object - \param obj the object to set the flags on - \param flag the or'd list of flags to set -*/ -#define ldl_set_flag(obj, flag) (obj)->flags |= (flag) - -/*! - \brief Clear a flag on an arbitrary object - \param obj the object to test - \param flag the or'd list of flags to clear -*/ -#define ldl_clear_flag(obj, flag) (obj)->flags &= ~(flag) - -/*! - \brief Set a flag on an arbitrary object while locked - \param obj the object to set the flags on - \param flag the or'd list of flags to set -*/ -#define ldl_set_flag_locked(obj, flag) assert(obj->flag_mutex != NULL);\ -apr_thread_mutex_lock(obj->flag_mutex);\ -(obj)->flags |= (flag);\ -apr_thread_mutex_unlock(obj->flag_mutex); - -/*! - \brief Clear a flag on an arbitrary object - \param obj the object to test - \param flag the or'd list of flags to clear -*/ -#define ldl_clear_flag_locked(obj, flag) apr_thread_mutex_lock(obj->flag_mutex); (obj)->flags &= ~(flag); apr_thread_mutex_unlock(obj->flag_mutex); - -/*! - \brief Copy flags from one arbitrary object to another - \param dest the object to copy the flags to - \param src the object to copy the flags from - \param flags the flags to copy -*/ -#define ldl_copy_flags(dest, src, flags) (dest)->flags &= ~(flags); (dest)->flags |= ((src)->flags & (flags)) - -/*! - \brief Test for NULL or zero length string - \param s the string to test - \return true value if the string is NULL or zero length -*/ -#define ldl_strlen_zero(s) (s && *s != '\0') ? 0 : 1 - -/*! - \brief Destroy a Jingle Session - \param session_p the session to destroy - \return SUCCESS OR FAILURE -*/ -ldl_status ldl_session_destroy(ldl_session_t **session_p); - -/*! - \brief Get a value from a session - \param session the session - \param key the key to look up - \return the value -*/ -char *ldl_session_get_value(ldl_session_t *session, char *key); - -/*! - \brief Set a value on a session - \param session the session - \param key the key to set - \param val the value of the key -*/ -void ldl_session_set_value(ldl_session_t *session, const char *key, const char *val); - -/*! - \brief Create a Jingle Session - \param session_p pointer to reference the session - \param handle handle to associate the session with - \param id the id to use for the session - \param them the id of the other end of the call - \param me the id of our end of the call - \param flags user flags - \return SUCCESS OR FAILURE -*/ -ldl_status ldl_session_create(ldl_session_t **session_p, ldl_handle_t *handle, char *id, char *them, char *me, ldl_user_flag_t flags); - -/*! - \brief get the id of a session - \param session the session to get the id of - \return the requested id -*/ -char *ldl_session_get_id(ldl_session_t *session); - -/*! - \brief Get the caller name of a session - \param session the session to get the caller from - \return the caller name -*/ -char *ldl_session_get_caller(ldl_session_t *session); - -/*! - \brief Get the callee name of a session - \param session the session to get the callee from - \return the callee name -*/ -char *ldl_session_get_callee(ldl_session_t *session); - -/*! - \brief Set the ip of a session - \param session the session to set the ip on - \param ip the ip -*/ -void ldl_session_set_ip(ldl_session_t *session, char *ip); - -/*! - \brief Get the ip of a session - \param session the session to get the ip from - \return the ip -*/ -char *ldl_session_get_ip(ldl_session_t *session); - -/*! - \brief Set a private pointer to associate with the session - \param session the session to set the data pointer to - \param private_data the data to associate -*/ -void ldl_session_set_private(ldl_session_t *session, void *private_data); - -/*! - \brief Get a private pointer from a session - \param session the session to get the data from - \return the data -*/ -void *ldl_session_get_private(ldl_session_t *session); - -/*! - \brief Accept a candidate - \param session the session to accept on - \param candidate the candidate to accept -*/ -void ldl_session_accept_candidate(ldl_session_t *session, ldl_candidate_t *candidate); - -/*! - \brief turn logging on/off - \param on (TRUE or FALSE) - \return current state -*/ -int ldl_global_debug(int on); - -/*! - \brief Set a custom logger - \param logger the logger function -*/ -void ldl_global_set_logger(ldl_logger_t logger); - -/*! - \brief Perform a probe on a given id to resolve the proper Jingle Resource - \param handle the connection handle to use. - \param id the id to probe - \param from the from string - \param buf a string to store the result - \param len the size in bytes of the string - \return a pointer to buf if a successful lookup was made otherwise NULL -*/ -char *ldl_handle_probe(ldl_handle_t *handle, char *id, char *from, char *buf, unsigned int len); - -/*! - \brief Perform a discovery on a given id to resolve the proper Jingle Resource - \param handle the connection handle to use. - \param id the id to probe - \param from the from string - \param buf a string to store the result - \param len the size in bytes of the string - \return a pointer to buf if a successful lookup was made otherwise NULL -*/ -char *ldl_handle_disco(ldl_handle_t *handle, char *id, char *from, char *buf, unsigned int len); - -/*! - \brief Signal a termination request on a given session - \param session the session to terminate - \return TRUE if the signal was sent. -*/ -unsigned int ldl_session_terminate(ldl_session_t *session); - -/*! - \brief Get the private data of a connection handle - \param handle the conection handle - \return the requested data -*/ -void *ldl_handle_get_private(ldl_handle_t *handle); - -/*! - \brief Get the full login of a connection handle - \param handle the conection handle - \return the requested data -*/ -char *ldl_handle_get_login(ldl_handle_t *handle); - -/*! - \brief Send a message to a session - \param session the session handle - \param subject optional subject - \param body body of the message -*/ -void ldl_session_send_msg(ldl_session_t *session, char *subject, char *body); - -/*! - \brief Send a presence notification to a target - \param handle the handle to send with - \param from the from address - \param to the to address - \param type the type of presence - \param rpid data for the icon - \param message a status message - \param avatar the path to an avatar image -*/ -void ldl_handle_send_presence(ldl_handle_t *handle, char *from, char *to, char *type, char *rpid, char *message, char *avatar); - -/*! - \brief Send a vcard - \param handle the handle to send with - \param from the from address - \param to the to address - \param id the request id - \param vcard the text xml of the vcard -*/ -void ldl_handle_send_vcard(ldl_handle_t *handle, char *from, char *to, char *id, char *vcard); - -/*! - \brief Send a message - \param handle the conection handle - \param from the message sender - \param to the message recipiant - \param subject optional subject - \param body body of the message -*/ -void ldl_handle_send_msg(ldl_handle_t *handle, char *from, char *to, const char *subject, const char *body); - -/*! - \brief Offer candidates to a potential session - \param session the session to send candidates on - \param candidates an array of candidate description objects - \param clen the number of elements in the candidates array - \return the message_id of the generated xmpp request -*/ -unsigned int ldl_session_candidates(ldl_session_t *session, - ldl_candidate_t *candidates, - unsigned int clen); - -unsigned int ldl_session_transport(ldl_session_t *session, - ldl_candidate_t *candidates, - unsigned int clen); - -/*! - \brief Initiate or Accept a new session and provide transport options - \param session the session to initiate or accept - \param payloads an array of payload description objects - \param plen the number of elements in the payloads array - \param description the type of description LDL_DESCRIPTION_INITIATE or LDL_DESCRIPTION_ACCEPT - \return the message_id of the generated xmpp request -*/ -unsigned int ldl_session_describe(ldl_session_t *session, - ldl_payload_t *payloads, - unsigned int plen, - ldl_description_t description, unsigned int *audio_ssrc, unsigned int *video_ssrc, - ldl_crypto_data_t *audio_crypto_data, ldl_crypto_data_t *video_crypto_data); - - -/*! - \brief get a session's state - \param session a session to get the state from - \return the state -*/ -ldl_state_t ldl_session_get_state(ldl_session_t *session); - - -/*! - \brief get the candidates - \param session the session - \param tport type of transport (rtp,rtcp,video_rtp,video_rtcp,etc.) - \param candidates pointer to point at array of the candidates - \param len the resulting len of the array pointer - \return success or failure -*/ -ldl_status ldl_session_get_candidates(ldl_session_t *session, ldl_transport_type_t tport, ldl_candidate_t **candidates, unsigned int *len); - -/*! - \brief get the payloads - \param session the session - \param payloads pointer to point at array of the payloads - \param len the resulting len of the array pointer - \return success or failure -*/ -ldl_status ldl_session_get_payloads(ldl_session_t *session, ldl_payload_t **payloads, unsigned int *len); - -/*! - \brief Initilize libDingaLing - \param debug debug level - \return success or failure -*/ -ldl_status ldl_global_init(int debug); - -/*! - \brief Destroy libDingaLing - \return success or failure -*/ -ldl_status ldl_global_destroy(void); - -/*! - \brief Set the log stream - \param log_stream the new log stream -*/ -void ldl_global_set_log_stream(FILE *log_stream); - -int8_t ldl_handle_ready(ldl_handle_t *handle); - -/*! - \brief Initilize a new libDingaLing handle - \param handle the Dingaling handle to initialize - \param login the xmpp login - \param password the password - \param server the server address - \param flags user flags - \param status_msg status message to advertise - \param loop_callback optional loop callback - \param session_callback function to call on session signalling - \param response_callback function to call on responses - \param private_info optional pointer to private data - \return success or failure -*/ -ldl_status ldl_handle_init(ldl_handle_t **handle, - char *login, - char *password, - char *server, - ldl_user_flag_t flags, - char *status_msg, - char *priority, - ldl_loop_callback_t loop_callback, - ldl_session_callback_t session_callback, - ldl_response_callback_t response_callback, - void *private_info); - -/*! - \brief Run a libDingaLing handle - \param handle the Dingaling handle to run -*/ -void ldl_handle_run(ldl_handle_t *handle); - -int ldl_session_gateway(ldl_session_t *handle); -void ldl_session_set_gateway(ldl_session_t *session); - -/*! - \brief Stop a libDingaLing handle - \param handle the Dingaling handle to stop -*/ -void ldl_handle_stop(ldl_handle_t *handle); - -int ldl_handle_running(ldl_handle_t *handle); -int ldl_handle_connected(ldl_handle_t *handle); -int ldl_handle_authorized(ldl_handle_t *handle); - - -/*! - \brief Destroy a libDingaLing handle - \param handle the Dingaling handle to destroy - \return success or failure -*/ -ldl_status ldl_handle_destroy(ldl_handle_t **handle); - -/*! - \brief Set the log stream on a handle - \param handle the Dingaling handle - \param log_stream the new log stream -*/ -void ldl_handle_set_log_stream(ldl_handle_t *handle, FILE *log_stream); - -ldl_status ldl_global_terminate(void); - -///\} - - -#ifdef __cplusplus -} -#endif -/** \mainpage libDingaling - * libDingaling - Cross Platform Jingle (Google Talk) voip signaling library - - * \section intro Introduction - * - * \section supports Supported Platforms - * libDingaling has been built on the following platforms: - * - * - Linux (x86, x86_64) - * - Windows (MSVC 2005) - * - Mac OS X (intel & ppc ) - * - * \section depends Dependencies - * libDingaling makes use of the following external libraries. - * - * - APR (http://apr.apache.org) - * - iksemel (http://iksemel.jabberstudio.org/) - * - * \section license Licensing - * - * libDingaling is licensed under the terms of the MPL 1.1 - * - */ -#endif - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/libs/libdingaling/src/sha1.c b/libs/libdingaling/src/sha1.c deleted file mode 100644 index 100ab0e513..0000000000 --- a/libs/libdingaling/src/sha1.c +++ /dev/null @@ -1,639 +0,0 @@ -/*- - * Copyright (c) 2001-2003 Allan Saddi - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * - * THIS SOFTWARE IS PROVIDED BY ALLAN SADDI AND HIS CONTRIBUTORS ``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 ALLAN SADDI OR HIS CONTRIBUTORS 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 SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * $Id: sha1.c 680 2003-07-25 21:57:38Z asaddi $ - */ - -/* - * Define WORDS_BIGENDIAN if compiling on a big-endian architecture. - * - * Define SHA1_TEST to test the implementation using the NIST's - * sample messages. The output should be: - * - * a9993e36 4706816a ba3e2571 7850c26c 9cd0d89d - * 84983e44 1c3bd26e baae4aa1 f95129e5 e54670f1 - * 34aa973c d4c4daa4 f61eeb2b dbad2731 6534016f - */ - -#ifdef HAVE_CONFIG_H -#include -#endif /* HAVE_CONFIG_H */ - -#if HAVE_INTTYPES_H -# include -#else -# if HAVE_STDINT_H -# include -# endif -#endif - -#ifdef _MSC_VER -#define inline __inline -#endif - -#include - -#include "sha1.h" - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wunused-const-variable" -#endif - -#if 0 -static const char rcsid[] = - "$Id: sha1.c 680 2003-07-25 21:57:38Z asaddi $"; -#endif /* !lint */ - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - -#define ROTL(x, n) (((x) << (n)) | ((x) >> (32 - (n)))) -#define ROTR(x, n) (((x) >> (n)) | ((x) << (32 - (n)))) - -#define F_0_19(x, y, z) ((z) ^ ((x) & ((y) ^ (z)))) -#define F_20_39(x, y, z) ((x) ^ (y) ^ (z)) -#define F_40_59(x, y, z) (((x) & ((y) | (z))) | ((y) & (z))) -#define F_60_79(x, y, z) ((x) ^ (y) ^ (z)) - -#define DO_ROUND(F, K) { \ - temp = ROTL(a, 5) + F(b, c, d) + e + *(W++) + K; \ - e = d; \ - d = c; \ - c = ROTL(b, 30); \ - b = a; \ - a = temp; \ -} - -#define K_0_19 0x5a827999L -#define K_20_39 0x6ed9eba1L -#define K_40_59 0x8f1bbcdcL -#define K_60_79 0xca62c1d6L - -#ifndef RUNTIME_ENDIAN - -#ifdef WORDS_BIGENDIAN - -#define BYTESWAP(x) (x) -#define BYTESWAP64(x) (x) - -#else /* WORDS_BIGENDIAN */ - -#define BYTESWAP(x) ((ROTR((x), 8) & 0xff00ff00L) | \ - (ROTL((x), 8) & 0x00ff00ffL)) -#define BYTESWAP64(x) _byteswap64(x) - -static inline uint64_t _byteswap64(uint64_t x) -{ - uint32_t a = (uint32_t)(x >> 32); - uint32_t b = (uint32_t) x; - return ((uint64_t) BYTESWAP(b) << 32) | (uint64_t) BYTESWAP(a); -} - -#endif /* WORDS_BIGENDIAN */ - -#else /* !RUNTIME_ENDIAN */ - -#define BYTESWAP(x) _byteswap(sc->littleEndian, x) -#define BYTESWAP64(x) _byteswap64(sc->littleEndian, x) - -#define _BYTESWAP(x) ((ROTR((x), 8) & 0xff00ff00L) | \ - (ROTL((x), 8) & 0x00ff00ffL)) -#define _BYTESWAP64(x) __byteswap64(x) - -static inline uint64_t __byteswap64(uint64_t x) -{ - uint32_t a = x >> 32; - uint32_t b = (uint32_t) x; - return ((uint64_t) _BYTESWAP(b) << 32) | (uint64_t) _BYTESWAP(a); -} - -static inline uint32_t _byteswap(int littleEndian, uint32_t x) -{ - if (!littleEndian) - return x; - else - return _BYTESWAP(x); -} - -static inline uint64_t _byteswap64(int littleEndian, uint64_t x) -{ - if (!littleEndian) - return x; - else - return _BYTESWAP64(x); -} - -static inline void setEndian(int *littleEndianp) -{ - union { - uint32_t w; - uint8_t b[4]; - } endian; - - endian.w = 1L; - *littleEndianp = endian.b[0] != 0; -} - -#endif /* !RUNTIME_ENDIAN */ - -static const uint8_t padding[64] = { - 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - -void -SHA1Init (SHA1Context *sc) -{ -#ifdef RUNTIME_ENDIAN - setEndian (&sc->littleEndian); -#endif /* RUNTIME_ENDIAN */ - - sc->totalLength = 0LL; - sc->hash[0] = 0x67452301L; - sc->hash[1] = 0xefcdab89L; - sc->hash[2] = 0x98badcfeL; - sc->hash[3] = 0x10325476L; - sc->hash[4] = 0xc3d2e1f0L; - sc->bufferLength = 0L; -} - -static void -burnStack (int size) -{ - char buf[128]; - - memset (buf, 0, sizeof (buf)); - size -= sizeof (buf); - if (size > 0) - burnStack (size); -} - -static void -SHA1Guts (SHA1Context *sc, const uint32_t *cbuf) -{ - uint32_t buf[80]; - uint32_t *W, *W3, *W8, *W14, *W16; - uint32_t a, b, c, d, e, temp; - int i; - - W = buf; - - for (i = 15; i >= 0; i--) { - *(W++) = BYTESWAP(*cbuf); - cbuf++; - } - - W16 = &buf[0]; - W14 = &buf[2]; - W8 = &buf[8]; - W3 = &buf[13]; - - for (i = 63; i >= 0; i--) { - *W = *(W3++) ^ *(W8++) ^ *(W14++) ^ *(W16++); - *W = ROTL(*W, 1); - W++; - } - - a = sc->hash[0]; - b = sc->hash[1]; - c = sc->hash[2]; - d = sc->hash[3]; - e = sc->hash[4]; - - W = buf; - -#ifndef SHA1_UNROLL -#define SHA1_UNROLL 20 -#endif /* !SHA1_UNROLL */ - -#if SHA1_UNROLL == 1 - for (i = 19; i >= 0; i--) - DO_ROUND(F_0_19, K_0_19); - - for (i = 19; i >= 0; i--) - DO_ROUND(F_20_39, K_20_39); - - for (i = 19; i >= 0; i--) - DO_ROUND(F_40_59, K_40_59); - - for (i = 19; i >= 0; i--) - DO_ROUND(F_60_79, K_60_79); -#elif SHA1_UNROLL == 2 - for (i = 9; i >= 0; i--) { - DO_ROUND(F_0_19, K_0_19); - DO_ROUND(F_0_19, K_0_19); - } - - for (i = 9; i >= 0; i--) { - DO_ROUND(F_20_39, K_20_39); - DO_ROUND(F_20_39, K_20_39); - } - - for (i = 9; i >= 0; i--) { - DO_ROUND(F_40_59, K_40_59); - DO_ROUND(F_40_59, K_40_59); - } - - for (i = 9; i >= 0; i--) { - DO_ROUND(F_60_79, K_60_79); - DO_ROUND(F_60_79, K_60_79); - } -#elif SHA1_UNROLL == 4 - for (i = 4; i >= 0; i--) { - DO_ROUND(F_0_19, K_0_19); - DO_ROUND(F_0_19, K_0_19); - DO_ROUND(F_0_19, K_0_19); - DO_ROUND(F_0_19, K_0_19); - } - - for (i = 4; i >= 0; i--) { - DO_ROUND(F_20_39, K_20_39); - DO_ROUND(F_20_39, K_20_39); - DO_ROUND(F_20_39, K_20_39); - DO_ROUND(F_20_39, K_20_39); - } - - for (i = 4; i >= 0; i--) { - DO_ROUND(F_40_59, K_40_59); - DO_ROUND(F_40_59, K_40_59); - DO_ROUND(F_40_59, K_40_59); - DO_ROUND(F_40_59, K_40_59); - } - - for (i = 4; i >= 0; i--) { - DO_ROUND(F_60_79, K_60_79); - DO_ROUND(F_60_79, K_60_79); - DO_ROUND(F_60_79, K_60_79); - DO_ROUND(F_60_79, K_60_79); - } -#elif SHA1_UNROLL == 5 - for (i = 3; i >= 0; i--) { - DO_ROUND(F_0_19, K_0_19); - DO_ROUND(F_0_19, K_0_19); - DO_ROUND(F_0_19, K_0_19); - DO_ROUND(F_0_19, K_0_19); - DO_ROUND(F_0_19, K_0_19); - } - - for (i = 3; i >= 0; i--) { - DO_ROUND(F_20_39, K_20_39); - DO_ROUND(F_20_39, K_20_39); - DO_ROUND(F_20_39, K_20_39); - DO_ROUND(F_20_39, K_20_39); - DO_ROUND(F_20_39, K_20_39); - } - - for (i = 3; i >= 0; i--) { - DO_ROUND(F_40_59, K_40_59); - DO_ROUND(F_40_59, K_40_59); - DO_ROUND(F_40_59, K_40_59); - DO_ROUND(F_40_59, K_40_59); - DO_ROUND(F_40_59, K_40_59); - } - - for (i = 3; i >= 0; i--) { - DO_ROUND(F_60_79, K_60_79); - DO_ROUND(F_60_79, K_60_79); - DO_ROUND(F_60_79, K_60_79); - DO_ROUND(F_60_79, K_60_79); - DO_ROUND(F_60_79, K_60_79); - } -#elif SHA1_UNROLL == 10 - for (i = 1; i >= 0; i--) { - DO_ROUND(F_0_19, K_0_19); - DO_ROUND(F_0_19, K_0_19); - DO_ROUND(F_0_19, K_0_19); - DO_ROUND(F_0_19, K_0_19); - DO_ROUND(F_0_19, K_0_19); - DO_ROUND(F_0_19, K_0_19); - DO_ROUND(F_0_19, K_0_19); - DO_ROUND(F_0_19, K_0_19); - DO_ROUND(F_0_19, K_0_19); - DO_ROUND(F_0_19, K_0_19); - } - - for (i = 1; i >= 0; i--) { - DO_ROUND(F_20_39, K_20_39); - DO_ROUND(F_20_39, K_20_39); - DO_ROUND(F_20_39, K_20_39); - DO_ROUND(F_20_39, K_20_39); - DO_ROUND(F_20_39, K_20_39); - DO_ROUND(F_20_39, K_20_39); - DO_ROUND(F_20_39, K_20_39); - DO_ROUND(F_20_39, K_20_39); - DO_ROUND(F_20_39, K_20_39); - DO_ROUND(F_20_39, K_20_39); - } - - for (i = 1; i >= 0; i--) { - DO_ROUND(F_40_59, K_40_59); - DO_ROUND(F_40_59, K_40_59); - DO_ROUND(F_40_59, K_40_59); - DO_ROUND(F_40_59, K_40_59); - DO_ROUND(F_40_59, K_40_59); - DO_ROUND(F_40_59, K_40_59); - DO_ROUND(F_40_59, K_40_59); - DO_ROUND(F_40_59, K_40_59); - DO_ROUND(F_40_59, K_40_59); - DO_ROUND(F_40_59, K_40_59); - } - - for (i = 1; i >= 0; i--) { - DO_ROUND(F_60_79, K_60_79); - DO_ROUND(F_60_79, K_60_79); - DO_ROUND(F_60_79, K_60_79); - DO_ROUND(F_60_79, K_60_79); - DO_ROUND(F_60_79, K_60_79); - DO_ROUND(F_60_79, K_60_79); - DO_ROUND(F_60_79, K_60_79); - DO_ROUND(F_60_79, K_60_79); - DO_ROUND(F_60_79, K_60_79); - DO_ROUND(F_60_79, K_60_79); - } -#elif SHA1_UNROLL == 20 - DO_ROUND(F_0_19, K_0_19); - DO_ROUND(F_0_19, K_0_19); - DO_ROUND(F_0_19, K_0_19); - DO_ROUND(F_0_19, K_0_19); - DO_ROUND(F_0_19, K_0_19); - DO_ROUND(F_0_19, K_0_19); - DO_ROUND(F_0_19, K_0_19); - DO_ROUND(F_0_19, K_0_19); - DO_ROUND(F_0_19, K_0_19); - DO_ROUND(F_0_19, K_0_19); - DO_ROUND(F_0_19, K_0_19); - DO_ROUND(F_0_19, K_0_19); - DO_ROUND(F_0_19, K_0_19); - DO_ROUND(F_0_19, K_0_19); - DO_ROUND(F_0_19, K_0_19); - DO_ROUND(F_0_19, K_0_19); - DO_ROUND(F_0_19, K_0_19); - DO_ROUND(F_0_19, K_0_19); - DO_ROUND(F_0_19, K_0_19); - DO_ROUND(F_0_19, K_0_19); - - DO_ROUND(F_20_39, K_20_39); - DO_ROUND(F_20_39, K_20_39); - DO_ROUND(F_20_39, K_20_39); - DO_ROUND(F_20_39, K_20_39); - DO_ROUND(F_20_39, K_20_39); - DO_ROUND(F_20_39, K_20_39); - DO_ROUND(F_20_39, K_20_39); - DO_ROUND(F_20_39, K_20_39); - DO_ROUND(F_20_39, K_20_39); - DO_ROUND(F_20_39, K_20_39); - DO_ROUND(F_20_39, K_20_39); - DO_ROUND(F_20_39, K_20_39); - DO_ROUND(F_20_39, K_20_39); - DO_ROUND(F_20_39, K_20_39); - DO_ROUND(F_20_39, K_20_39); - DO_ROUND(F_20_39, K_20_39); - DO_ROUND(F_20_39, K_20_39); - DO_ROUND(F_20_39, K_20_39); - DO_ROUND(F_20_39, K_20_39); - DO_ROUND(F_20_39, K_20_39); - - DO_ROUND(F_40_59, K_40_59); - DO_ROUND(F_40_59, K_40_59); - DO_ROUND(F_40_59, K_40_59); - DO_ROUND(F_40_59, K_40_59); - DO_ROUND(F_40_59, K_40_59); - DO_ROUND(F_40_59, K_40_59); - DO_ROUND(F_40_59, K_40_59); - DO_ROUND(F_40_59, K_40_59); - DO_ROUND(F_40_59, K_40_59); - DO_ROUND(F_40_59, K_40_59); - DO_ROUND(F_40_59, K_40_59); - DO_ROUND(F_40_59, K_40_59); - DO_ROUND(F_40_59, K_40_59); - DO_ROUND(F_40_59, K_40_59); - DO_ROUND(F_40_59, K_40_59); - DO_ROUND(F_40_59, K_40_59); - DO_ROUND(F_40_59, K_40_59); - DO_ROUND(F_40_59, K_40_59); - DO_ROUND(F_40_59, K_40_59); - DO_ROUND(F_40_59, K_40_59); - - DO_ROUND(F_60_79, K_60_79); - DO_ROUND(F_60_79, K_60_79); - DO_ROUND(F_60_79, K_60_79); - DO_ROUND(F_60_79, K_60_79); - DO_ROUND(F_60_79, K_60_79); - DO_ROUND(F_60_79, K_60_79); - DO_ROUND(F_60_79, K_60_79); - DO_ROUND(F_60_79, K_60_79); - DO_ROUND(F_60_79, K_60_79); - DO_ROUND(F_60_79, K_60_79); - DO_ROUND(F_60_79, K_60_79); - DO_ROUND(F_60_79, K_60_79); - DO_ROUND(F_60_79, K_60_79); - DO_ROUND(F_60_79, K_60_79); - DO_ROUND(F_60_79, K_60_79); - DO_ROUND(F_60_79, K_60_79); - DO_ROUND(F_60_79, K_60_79); - DO_ROUND(F_60_79, K_60_79); - DO_ROUND(F_60_79, K_60_79); - DO_ROUND(F_60_79, K_60_79); -#else /* SHA1_UNROLL */ -#error SHA1_UNROLL must be 1, 2, 4, 5, 10 or 20! -#endif - - sc->hash[0] += a; - sc->hash[1] += b; - sc->hash[2] += c; - sc->hash[3] += d; - sc->hash[4] += e; -} - -void -SHA1Update (SHA1Context *sc, const void *vdata, uint32_t len) -{ - const uint8_t *data = vdata; - uint32_t bufferBytesLeft; - uint32_t bytesToCopy; - int needBurn = 0; - -#ifdef SHA1_FAST_COPY - if (sc->bufferLength) { - bufferBytesLeft = 64L - sc->bufferLength; - - bytesToCopy = bufferBytesLeft; - if (bytesToCopy > len) - bytesToCopy = len; - - memcpy (&sc->buffer.bytes[sc->bufferLength], data, bytesToCopy); - - sc->totalLength += bytesToCopy * 8L; - - sc->bufferLength += bytesToCopy; - data += bytesToCopy; - len -= bytesToCopy; - - if (sc->bufferLength == 64L) { - SHA1Guts (sc, sc->buffer.words); - needBurn = 1; - sc->bufferLength = 0L; - } - } - - while (len > 63) { - sc->totalLength += 512L; - - SHA1Guts (sc, data); - needBurn = 1; - - data += 64L; - len -= 64L; - } - - if (len) { - memcpy (&sc->buffer.bytes[sc->bufferLength], data, len); - - sc->totalLength += len * 8L; - - sc->bufferLength += len; - } -#else /* SHA1_FAST_COPY */ - while (len) { - bufferBytesLeft = 64L - sc->bufferLength; - - bytesToCopy = bufferBytesLeft; - if (bytesToCopy > len) - bytesToCopy = len; - - memcpy (&sc->buffer.bytes[sc->bufferLength], data, bytesToCopy); - - sc->totalLength += bytesToCopy * 8L; - - sc->bufferLength += bytesToCopy; - data += bytesToCopy; - len -= bytesToCopy; - - if (sc->bufferLength == 64L) { - SHA1Guts (sc, sc->buffer.words); - needBurn = 1; - sc->bufferLength = 0L; - } - } -#endif /* SHA1_FAST_COPY */ - - if (needBurn) - burnStack (sizeof (uint32_t[86]) + sizeof (uint32_t *[5]) + sizeof (int)); -} - -void -SHA1Final (SHA1Context *sc, uint8_t hash[SHA1_HASH_SIZE]) -{ - uint32_t bytesToPad; - uint64_t lengthPad; - int i; - - bytesToPad = 120L - sc->bufferLength; - if (bytesToPad > 64L) - bytesToPad -= 64L; - - lengthPad = BYTESWAP64(sc->totalLength); - - SHA1Update (sc, padding, bytesToPad); - SHA1Update (sc, &lengthPad, 8L); - - if (hash) { - for (i = 0; i < SHA1_HASH_WORDS; i++) { -#ifdef SHA1_FAST_COPY - *((uint32_t *) hash) = BYTESWAP(sc->hash[i]); -#else /* SHA1_FAST_COPY */ - hash[0] = (uint8_t) (sc->hash[i] >> 24); - hash[1] = (uint8_t) (sc->hash[i] >> 16); - hash[2] = (uint8_t) (sc->hash[i] >> 8); - hash[3] = (uint8_t) sc->hash[i]; -#endif /* SHA1_FAST_COPY */ - hash += 4; - } - } -} - -#ifdef SHA1_TEST - -#include -#include -#include - -int -main (int argc, char *argv[]) -{ - SHA1Context foo; - uint8_t hash[SHA1_HASH_SIZE]; - char buf[1000]; - int i; - - SHA1Init (&foo); - SHA1Update (&foo, "abc", 3); - SHA1Final (&foo, hash); - - for (i = 0; i < SHA1_HASH_SIZE;) { - printf ("%02x", hash[i++]); - if (!(i % 4)) - printf (" "); - } - printf ("\n"); - - SHA1Init (&foo); - SHA1Update (&foo, - "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", - 56); - SHA1Final (&foo, hash); - - for (i = 0; i < SHA1_HASH_SIZE;) { - printf ("%02x", hash[i++]); - if (!(i % 4)) - printf (" "); - } - printf ("\n"); - - SHA1Init (&foo); - memset (buf, 'a', sizeof (buf)); - for (i = 0; i < 1000; i++) - SHA1Update (&foo, buf, sizeof (buf)); - SHA1Final (&foo, hash); - - for (i = 0; i < SHA1_HASH_SIZE;) { - printf ("%02x", hash[i++]); - if (!(i % 4)) - printf (" "); - } - printf ("\n"); - - exit (0); -} - -#endif /* SHA1_TEST */ diff --git a/libs/libdingaling/src/sha1.h b/libs/libdingaling/src/sha1.h deleted file mode 100644 index 9283165c76..0000000000 --- a/libs/libdingaling/src/sha1.h +++ /dev/null @@ -1,86 +0,0 @@ -/*- - * Copyright (c) 2001-2003 Allan Saddi - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * - * THIS SOFTWARE IS PROVIDED BY ALLAN SADDI AND HIS CONTRIBUTORS ``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 ALLAN SADDI OR HIS CONTRIBUTORS 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 SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * $Id: sha1.h 347 2003-02-23 22:11:49Z asaddi $ - */ - -#ifndef _SHA1_H -#define _SHA1_H - -#if HAVE_INTTYPES_H -# include -#else -# if HAVE_STDINT_H -# include -# else -# ifndef uint32_t -# ifdef WIN32 -typedef unsigned __int8 uint8_t; -typedef unsigned __int16 uint16_t; -typedef unsigned __int32 uint32_t; -typedef unsigned __int64 uint64_t; -typedef __int8 int8_t; -typedef __int16 int16_t; -typedef __int32 int32_t; -typedef __int64 int64_t; -typedef unsigned long in_addr_t; -# endif -# endif -# endif -#endif - -#define SHA1_HASH_SIZE 20 - -/* Hash size in 32-bit words */ -#define SHA1_HASH_WORDS 5 - -struct _SHA1Context { - uint64_t totalLength; - uint32_t hash[SHA1_HASH_WORDS]; - uint32_t bufferLength; - union { - uint32_t words[16]; - uint8_t bytes[64]; - } buffer; -#ifdef RUNTIME_ENDIAN - int littleEndian; -#endif /* RUNTIME_ENDIAN */ -}; - -typedef struct _SHA1Context SHA1Context; - -#ifdef __cplusplus -extern "C" { -#endif - -void SHA1Init (SHA1Context *sc); -void SHA1Update (SHA1Context *sc, const void *data, uint32_t len); -void SHA1Final (SHA1Context *sc, uint8_t hash[SHA1_HASH_SIZE]); - -#ifdef __cplusplus -} -#endif - -#endif /* _SHA1_H */ diff --git a/libs/libvpx/.update b/libs/libvpx/.update index 09e6d8ef57..815a0a77a8 100644 --- a/libs/libvpx/.update +++ b/libs/libvpx/.update @@ -1 +1 @@ -Wed Feb 27 11:26:31 MST 2019 +Thu Mar 19 03:08:11 UTC 2020 diff --git a/libs/libvpx/build/make/configure.sh b/libs/libvpx/build/make/configure.sh index 1b52c053c1..b1f7804a59 100644 --- a/libs/libvpx/build/make/configure.sh +++ b/libs/libvpx/build/make/configure.sh @@ -767,49 +767,9 @@ process_common_toolchain() { # detect tgt_os case "$gcctarget" in - *darwin10*) + *darwin*) tgt_isa=x86_64 - tgt_os=darwin10 - ;; - *darwin11*) - tgt_isa=x86_64 - tgt_os=darwin11 - ;; - *darwin12*) - tgt_isa=x86_64 - tgt_os=darwin12 - ;; - *darwin13*) - tgt_isa=x86_64 - tgt_os=darwin13 - ;; - *darwin14*) - tgt_isa=x86_64 - tgt_os=darwin14 - ;; - *darwin15*) - tgt_isa=x86_64 - tgt_os=darwin15 - ;; - *darwin16*) - tgt_isa=x86_64 - tgt_os=darwin16 - ;; - *darwin17*) - tgt_isa=x86_64 - tgt_os=darwin17 - ;; - *darwin18*) - tgt_isa=x86_64 - tgt_os=darwin18 - ;; - *darwin19*) - tgt_isa=x86_64 - tgt_os=darwin19 - ;; - *darwin20*) - tgt_isa=x86_64 - tgt_os=darwin20 + tgt_os=darwin ;; x86_64*mingw32*) tgt_os=win64 @@ -903,53 +863,15 @@ process_common_toolchain() { esac case ${toolchain} in - *-darwin8-*) - add_cflags "-mmacosx-version-min=10.4" - add_ldflags "-mmacosx-version-min=10.4" - ;; - *-darwin9-*) - add_cflags "-mmacosx-version-min=10.5" - add_ldflags "-mmacosx-version-min=10.5" - ;; - *-darwin10-*) - add_cflags "-mmacosx-version-min=10.6" - add_ldflags "-mmacosx-version-min=10.6" - ;; - *-darwin11-*) - add_cflags "-mmacosx-version-min=10.7" - add_ldflags "-mmacosx-version-min=10.7" - ;; - *-darwin12-*) - add_cflags "-mmacosx-version-min=10.8" - add_ldflags "-mmacosx-version-min=10.8" - ;; - *-darwin13-*) - add_cflags "-mmacosx-version-min=10.9" - add_ldflags "-mmacosx-version-min=10.9" - ;; - *-darwin14-*) - add_cflags "-mmacosx-version-min=10.10" - add_ldflags "-mmacosx-version-min=10.10" - ;; - *-darwin15-*) - add_cflags "-mmacosx-version-min=10.11" - add_ldflags "-mmacosx-version-min=10.11" - ;; - *-darwin16-*) - add_cflags "-mmacosx-version-min=10.12" - add_ldflags "-mmacosx-version-min=10.12" - ;; - *-darwin17-*) - add_cflags "-mmacosx-version-min=10.13" - add_ldflags "-mmacosx-version-min=10.13" - ;; - *-darwin18-*) - add_cflags "-mmacosx-version-min=10.14" - add_ldflags "-mmacosx-version-min=10.14" - ;; - *-darwin19-*) - add_cflags "-mmacosx-version-min=10.15" - add_ldflags "-mmacosx-version-min=10.15" + *-darwin-*) + mvmin=$(sw_vers -productVersion) + if [[ $mvmin == 10.* ]]; then + mvmin="-mmacosx-version-min=""${mvmin%.*}" + else + mvmin="-mmacosx-version-min=""${mvmin%%.*}" + fi + add_cflags $mvmin + add_ldflags $mvmin ;; *-iphonesimulator-*) add_cflags "-miphoneos-version-min=${IOS_VERSION_MIN}" diff --git a/libs/libvpx/configure b/libs/libvpx/configure index 731bcb5bc8..354f03d525 100755 --- a/libs/libvpx/configure +++ b/libs/libvpx/configure @@ -117,19 +117,7 @@ all_platforms="${all_platforms} mips64-linux-gcc" all_platforms="${all_platforms} ppc64le-linux-gcc" all_platforms="${all_platforms} sparc-solaris-gcc" all_platforms="${all_platforms} x86-android-gcc" -all_platforms="${all_platforms} x86-darwin8-gcc" -all_platforms="${all_platforms} x86-darwin8-icc" -all_platforms="${all_platforms} x86-darwin9-gcc" -all_platforms="${all_platforms} x86-darwin9-icc" -all_platforms="${all_platforms} x86-darwin10-gcc" -all_platforms="${all_platforms} x86-darwin11-gcc" -all_platforms="${all_platforms} x86-darwin12-gcc" -all_platforms="${all_platforms} x86-darwin13-gcc" -all_platforms="${all_platforms} x86-darwin14-gcc" -all_platforms="${all_platforms} x86-darwin15-gcc" -all_platforms="${all_platforms} x86-darwin16-gcc" -all_platforms="${all_platforms} x86-darwin17-gcc" -all_platforms="${all_platforms} x86-darwin18-gcc" +all_platforms="${all_platforms} x86-darwin-gcc" all_platforms="${all_platforms} x86-iphonesimulator-gcc" all_platforms="${all_platforms} x86-linux-gcc" all_platforms="${all_platforms} x86-linux-icc" @@ -139,18 +127,7 @@ all_platforms="${all_platforms} x86-win32-gcc" all_platforms="${all_platforms} x86-win32-vs14" all_platforms="${all_platforms} x86-win32-vs15" all_platforms="${all_platforms} x86_64-android-gcc" -all_platforms="${all_platforms} x86_64-darwin9-gcc" -all_platforms="${all_platforms} x86_64-darwin10-gcc" -all_platforms="${all_platforms} x86_64-darwin11-gcc" -all_platforms="${all_platforms} x86_64-darwin12-gcc" -all_platforms="${all_platforms} x86_64-darwin13-gcc" -all_platforms="${all_platforms} x86_64-darwin14-gcc" -all_platforms="${all_platforms} x86_64-darwin15-gcc" -all_platforms="${all_platforms} x86_64-darwin16-gcc" -all_platforms="${all_platforms} x86_64-darwin17-gcc" -all_platforms="${all_platforms} x86_64-darwin18-gcc" -all_platforms="${all_platforms} x86_64-darwin19-gcc" -all_platforms="${all_platforms} x86_64-darwin20-gcc" +all_platforms="${all_platforms} x86_64-darwin-gcc" all_platforms="${all_platforms} x86_64-iphonesimulator-gcc" all_platforms="${all_platforms} x86_64-linux-gcc" all_platforms="${all_platforms} x86_64-linux-icc" diff --git a/libs/libvpx/vp8/common/threading.h b/libs/libvpx/vp8/common/threading.h index 7a637cdff2..f2e5e8c54f 100644 --- a/libs/libvpx/vp8/common/threading.h +++ b/libs/libvpx/vp8/common/threading.h @@ -171,11 +171,11 @@ static inline int sem_destroy(sem_t *sem) { #define sem_wait(sem) (semaphore_wait(*sem)) #define sem_post(sem) semaphore_signal(*sem) #define sem_destroy(sem) semaphore_destroy(mach_task_self(), *sem) -#define thread_sleep(nms) { struct timespec ts;ts.tv_sec=0; ts.tv_nsec = 1000*nms;nanosleep(&ts, NULL);} +#define thread_sleep(nms) { struct timespec ts;ts.tv_sec=0; ts.tv_nsec = 1000*nms;sched_yield();nanosleep(&ts, NULL);} #else #include #include -#define thread_sleep(nms) {struct timespec ts;ts.tv_sec=0; ts.tv_nsec = 1000*nms;nanosleep(&ts, NULL);} +#define thread_sleep(nms) {struct timespec ts;ts.tv_sec=0; ts.tv_nsec = 1000*nms;sched_yield();clock_nanosleep(CLOCK_MONOTONIC, 0, &ts, NULL);} #endif /* Not Windows. Assume pthreads */ diff --git a/libs/libvpx/vp8/encoder/pickinter.c b/libs/libvpx/vp8/encoder/pickinter.c index dc72eed88c..6f8a173582 100644 --- a/libs/libvpx/vp8/encoder/pickinter.c +++ b/libs/libvpx/vp8/encoder/pickinter.c @@ -631,16 +631,16 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, } #endif assert(plane[LAST_FRAME][0] != NULL); - dot_artifact_candidate = check_dot_artifact_candidate( + if (plane[LAST_FRAME][0]) dot_artifact_candidate = check_dot_artifact_candidate( cpi, x, target_y, stride, plane[LAST_FRAME][0], mb_row, mb_col, 0); // If not found in Y channel, check UV channel. if (!dot_artifact_candidate) { assert(plane[LAST_FRAME][1] != NULL); - dot_artifact_candidate = check_dot_artifact_candidate( + if (plane[LAST_FRAME][1]) dot_artifact_candidate = check_dot_artifact_candidate( cpi, x, target_u, stride_uv, plane[LAST_FRAME][1], mb_row, mb_col, 1); if (!dot_artifact_candidate) { assert(plane[LAST_FRAME][2] != NULL); - dot_artifact_candidate = check_dot_artifact_candidate( + if (plane[LAST_FRAME][2]) dot_artifact_candidate = check_dot_artifact_candidate( cpi, x, target_v, stride_uv, plane[LAST_FRAME][2], mb_row, mb_col, 2); } diff --git a/libs/libvpx/vp9/common/vp9_onyxc_int.h b/libs/libvpx/vp9/common/vp9_onyxc_int.h index 662b8ef5e1..c5b98c0021 100644 --- a/libs/libvpx/vp9/common/vp9_onyxc_int.h +++ b/libs/libvpx/vp9/common/vp9_onyxc_int.h @@ -299,6 +299,8 @@ static INLINE int get_free_fb(VP9_COMMON *cm) { static INLINE void ref_cnt_fb(RefCntBuffer *bufs, int *idx, int new_idx) { const int ref_index = *idx; + if (!bufs) return; + if (ref_index >= 0 && bufs[ref_index].ref_count > 0) bufs[ref_index].ref_count--; diff --git a/libs/libvpx/vp9/encoder/vp9_subexp.c b/libs/libvpx/vp9/encoder/vp9_subexp.c index 19bbd5373f..cf17fcdfce 100644 --- a/libs/libvpx/vp9/encoder/vp9_subexp.c +++ b/libs/libvpx/vp9/encoder/vp9_subexp.c @@ -72,7 +72,7 @@ static int remap_prob(int v, int m) { i = recenter_nonneg(MAX_PROB - 1 - v, MAX_PROB - 1 - m) - 1; assert(i >= 0 && (size_t)i < sizeof(map_table)); - i = map_table[i]; + if (i >= 0 && (size_t)i < sizeof(map_table)) i = map_table[i]; return i; } diff --git a/libs/libvpx/vpx_dsp/avg.c b/libs/libvpx/vpx_dsp/avg.c index 1c45e8a73d..576d683fef 100644 --- a/libs/libvpx/vpx_dsp/avg.c +++ b/libs/libvpx/vpx_dsp/avg.c @@ -344,6 +344,7 @@ void vpx_int_pro_row_c(int16_t hbuf[16], const uint8_t *ref, const int ref_stride, const int height) { int idx; const int norm_factor = height >> 1; + if (height == 1) return; for (idx = 0; idx < 16; ++idx) { int i; hbuf[idx] = 0; diff --git a/libs/libvpx/vpx_dsp/x86/avg_intrin_avx2.c b/libs/libvpx/vpx_dsp/x86/avg_intrin_avx2.c index 3f4f577a21..ac33e160b9 100644 --- a/libs/libvpx/vpx_dsp/x86/avg_intrin_avx2.c +++ b/libs/libvpx/vpx_dsp/x86/avg_intrin_avx2.c @@ -305,6 +305,7 @@ static void hadamard_8x8x2_avx2(const int16_t *src_diff, ptrdiff_t src_stride, src[5] = _mm256_loadu_si256((const __m256i *)(src_diff += src_stride)); src[6] = _mm256_loadu_si256((const __m256i *)(src_diff += src_stride)); src[7] = _mm256_loadu_si256((const __m256i *)(src_diff += src_stride)); + (void)src_diff; hadamard_col8x2_avx2(src, 0); hadamard_col8x2_avx2(src, 1); diff --git a/libs/libvpx/vpx_dsp/x86/avg_intrin_sse2.c b/libs/libvpx/vpx_dsp/x86/avg_intrin_sse2.c index 5aba903a2d..45bfefe08a 100644 --- a/libs/libvpx/vpx_dsp/x86/avg_intrin_sse2.c +++ b/libs/libvpx/vpx_dsp/x86/avg_intrin_sse2.c @@ -276,6 +276,7 @@ static INLINE void hadamard_8x8_sse2(const int16_t *src_diff, src[5] = _mm_load_si128((const __m128i *)(src_diff += src_stride)); src[6] = _mm_load_si128((const __m128i *)(src_diff += src_stride)); src[7] = _mm_load_si128((const __m128i *)(src_diff += src_stride)); + (void)src_diff; hadamard_col8_sse2(src, 0); hadamard_col8_sse2(src, 1); diff --git a/libs/libyuv/source/scale.cc b/libs/libyuv/source/scale.cc index ab08549637..30066d5b34 100644 --- a/libs/libyuv/source/scale.cc +++ b/libs/libyuv/source/scale.cc @@ -736,6 +736,9 @@ static void ScaleAddCols2_C(int dst_width, int dx, const uint16_t* src_ptr, uint8_t* dst_ptr) { +#ifdef __clang_analyzer__ + *dst_ptr = 0; +#else int i; int scaletbl[2]; int minboxwidth = dx >> 16; @@ -750,6 +753,7 @@ static void ScaleAddCols2_C(int dst_width, SumPixels(boxwidth, src_ptr + ix) * scaletbl[boxwidth - minboxwidth] >> 16; } +#endif } static void ScaleAddCols2_16_C(int dst_width, @@ -758,6 +762,9 @@ static void ScaleAddCols2_16_C(int dst_width, int dx, const uint32_t* src_ptr, uint16_t* dst_ptr) { +#ifdef __clang_analyzer__ + * dst_ptr = 0; +#else int i; int scaletbl[2]; int minboxwidth = dx >> 16; @@ -772,6 +779,7 @@ static void ScaleAddCols2_16_C(int dst_width, scaletbl[boxwidth - minboxwidth] >> 16; } +#endif } static void ScaleAddCols0_C(int dst_width, diff --git a/libs/libzrtp/.gitignore b/libs/libzrtp/.gitignore deleted file mode 100644 index 9f4002095f..0000000000 --- a/libs/libzrtp/.gitignore +++ /dev/null @@ -1,22 +0,0 @@ -# -*- mode:conf -*- -/*.a -/*.dat -/*.o -/.cproject -/.deps -/.project -/.stamp-doc -/Makefile -/Makefile.in -/_configs.sed -/aclocal.m4 -/autom4te.cache/* -/cache_test -/config.* -/config/* -/configure -/doc/Doxyfile -/doc/out -/include/zrtp_config_unix.h -!/build/Makefile.am -!/build/test/Makefile.am diff --git a/libs/libzrtp/AUTHORS b/libs/libzrtp/AUTHORS deleted file mode 100644 index f948f2f08e..0000000000 --- a/libs/libzrtp/AUTHORS +++ /dev/null @@ -1,30 +0,0 @@ -# -# Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. -# Contact: http://philzimmermann.com -# For licensing and other legal details, see the file zrtp_legal.c. -# -# Viktor Krikun - -Created by Phil Zimmermann. - -Developers: - Viktor Krikun - Nikolay Popok - Vitaly Rozhkov - Andrey Rozinko - Bryce Wilcox-O'Hearn - -Thanks to: - Alan Johnston - Jon Callas - Hal Finney - Colin Plumb - Sagar Pai - Werner Dittmann - Travis Cross - L. Amber Wilcox-O'Hearn - Ariel Boston - Donovan Preston - -Portions of this software are available under open source licenses from other authors. -Notably, Brian Gladman's AES implementation, and David McGrew's libSRTP package. diff --git a/libs/libzrtp/COPYING b/libs/libzrtp/COPYING deleted file mode 100644 index ac0efbec90..0000000000 --- a/libs/libzrtp/COPYING +++ /dev/null @@ -1,7 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - */ - \ No newline at end of file diff --git a/libs/libzrtp/ChangeLog b/libs/libzrtp/ChangeLog deleted file mode 100644 index 6fdf46638c..0000000000 --- a/libs/libzrtp/ChangeLog +++ /dev/null @@ -1,556 +0,0 @@ - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -SINCE LIBZRTP v0.80 CHANGELOG IS A PART OF HTML DOCUMENTATION. -Check generated html or doc/manuals/changelog.dox doxygen sources -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - - -libzrtp 0.7.1 18.11.2008 --------------------------------------------------------------------------------- -1. Fixed bug with hardcoded AES128 cipher for generating SRTP keys. In this - version is selected according to ZRTP discovery. - -2. Added initialization/deinitalization functions to zrtp helper functions. - -libzrtp 0.7.0 04.11.2008 --------------------------------------------------------------------------------- -1. Changes in libzrtp sources tree. - -2. Improvements in libzrtp initialization routine: - - all global zrtp options were combined in zrtp_config_t structure; - - zrtp_init() allocates memory for zrtp global context; - - zrtp_config_defaults() - -3. Improvements for Passive/Active mode support. - a) A passive endpoint never sends a commit message, period. Also, it - declares itself as a passive endpoint by setting the P flag it its own - Hello message; - b) A active endpoint does not send a commit to a passive endpoint, which it - recognizes by detecting the P flag; - c) A passive phone, if acting as a SIP initiator (meaning it initiated the - call), rejects all commit packets from everyone; - d) A passive phone rejects all commit messages from a PBX, which is easily - recognized by the M flag. - Passive mode support is built into the library logic and will be used - automatically if the developer specifies signaling role by setting - is_initiator flag in zrtp_init_session_ctx(). - -4. Improvements in ZRTP feedback interface and system-dependent functions. - There are two types of interface functions in libzrtp: system dependent API - and realization of helper functions and events. System dependent API in - defined in zrtp_iface_system.h as set of extern functions. System - functions are already implemented for several basic platforms in - zrtp_iface.sys.c libzrtp feedback and helper functions were re-factored - and implemented as set of callbacks. If the developer doesn't want to - handle one or another event it may just leave necessary pointer empty. - See zrtp_init() and zrtp_callback_t, zrtp_iface.h for more details. - -5. ZRTP configuration approach was improved: zrtp_config_xxx.h contains - adjustments for necessary target platform. libzrtp contains default - configs for Linux, OS X, Windows, Window CE and Symbian platforms. - All ZRTP protocol and behavior related adjustments are collected in - zrtp_config_user.h. Edit this file to configure libzrtp for your - needs. - -6. Implemented new functions in protocol according to the Internet Draft v 10. - -7. Improved realization of built-in libzrtp scheduler. Fixed bug with crashing - on performing delay call when zrtp session have been already deleted. - -8. Logging function was improved. Use ZRTP_LOG macro to print log messages. See - zrtp_log.h for more information. - - -libzrtp 0.6.8 03.09.2008 --------------------------------------------------------------------------------- -ZRTP -1. Fixed bug with incorrect maximum value for T1 retry interval timer which - increased delay between LOOKING_FOR_ZRTP and NO_ZRTP_SUPPORT states. - Internal fix, no API changes required; -2. Implemented version negotiation according to the latest specification. - libzrtp v 0.6.8 supports ZRTP v0.90 only. No changes required in - applications that use the SDK. -3. Compilation flag WITH_ZFONE was removed. The developer, who wants to use - built-in ZRTP cache, has to set name of the ZRTP cache explicitly, - implementing zrtp_get_cache_path() function. -4. New libzrtp licensing scheme was implemented. It allows the licensing policy - to be changed at run time. See zrtp_license_mode_t doc. for more details. - Affected API - zrtp_init(). -5. ZRTP Protocol version was changed to 0.90 according to ZRTP Internet Draft. -6. Some changes in Linux config files: surplus configuration flags were removed - from ./cfg.XXX templates. -7. Added experimental ZRTP messages retries scheduler for slow channels. As - ex ample for GSM CSD channel with average bandwidth 6Kb/s. To use this - option build library with BUILD_FOR_CSD flag. - - -libzrtp 0.6.6 27.06.2008 --------------------------------------------------------------------------------- -ZRTP -1. Small bug was fixed in S0 calculation: when RS1 is corrupted the library uses - RS2 instead; -2. Some changes in Makefile and building process: unused header were eliminated - from the installation process. -3. -DBUILD_WITH_ZRTP_MUTEXES was replaced with --enable_mutexes option passed to - ./configure script. This change allows not to specify any libzrtp compilation - flags during user application compilation. --enable-mutexes adds - BUILD_ZRTP_MUTEXES definition to the ./config/zrtp_unix_config.h so if you - build libzrtp on other platforms - define this flag manually (windows - configuration file already includes this option). -4. Clean-up in .h and .c comments was made. - - -libzrtp 0.6.5 04.06.2008 --------------------------------------------------------------------------------- -ZRTP -1. New names for: other_secret - pbxs; srtps - auxs. In bits and secrets storages; -2. RS2 secret was eliminated form DH s0 calculation; -3. Protocol version number was increased to 0.85 - - -libzrtp 0.6.4 19.05.2008 --------------------------------------------------------------------------------- -ZRTP -1. According to the new version of the Internet Draft Signaling shared secret was - removed from the protocol and from the sources. It was not used by interface - functions and developers may change nothing in libzrtp based applications. - -2. DH4K Key echange was eleminated from the specification and from the sources. - Now ECDH is used for all larger AES key sizes. - - -libzrtp 0.6.2 04.02.2008 --------------------------------------------------------------------------------- -ZRTP -1. New behaviour for Secure --> Clear --> Secure scenario was implemnted. According - to ZRTP ID 06 section 5.7.2.1 new value of ZRTPSess computed as hash(ZRTPSess). - -DOC: - Libzrtp documentation was updated up to version 0.6.2. - - -libzrtp 0.6.1 03.14.2008 --------------------------------------------------------------------------------- -ZRTP -1. Multistream mode was implemented according to ZRTP Internet Draft 05.n: - - new stream mode zrtp_stream_mode_t:: ZRTP_STREAM_MODE_MULT; - - Multistream key exchange component was added with ID zrtp_pktype_id_t:: - ZRTP_PKTYPE_MULT and symbolic name ZRTP_MULT. To allow libzrtp use Multistream - mode - ZRTP_PKTYPE_MULT have to be added to the stream profile in the first - position; - - According to the new draft SAS and ZRTPSess key are Session option and - were moved to the zrtp_conn_ctx_t structure. New specification defines - single SAS values for all streams within the session; - - ZRTP state-machine was changed to handle Multistream mode. In .Fast. mode - DH exchange is omitted and stream skips ZRTP_STATE_WAIT_CONFIRM1 and - ZRTP_STATE_PENDINGSECURE for the Initiator and Responder state-machines, - respectively; - -2. Hash preimages were added to prevent DOS attacks. See ZRTP ID sec 9.0 for detail - information. This option is available using zrtp_set_signaling_hash() and - zrtp_get_signaling_hash() functions. - -3. Hmac values were added to every packet to allow eliminate SAS validation - if SIP is protected; - -4. Autosave. of the default realization of the ZRTP cache to the hard drive was - implemented; - -5. Lot of other internal changes and improvements according to the latest ZRTP - specification v06. - - -libzrtp 0.4.5-6 --------------------------------------------------------------------------------- - 1. Full PBX support. Tested on GS-Labs Asterisk - API: - DOC: - - 2. Resolved problem with BG ciphers compilation: initialization of AES hash tables. - - 3. Fixed bug in SRTP replay protection. (Undeleted nodes for mulsy-stream encryption) - (May resulted in a error zrtp_protocol_error_t::zrtp_status_rp_fail) - - 4. Vrification is a session option. Input parameter of zrtp_set_verified() was - changed from stream to ZRTP session structure. - - 5. Fixed bug with malformed ZRTP Hello packet. - - 5. fast video - -libzrtp 0.4.4 31.07.2007 --------------------------------------------------------------------------------- - 1. New extra error code for replay protection was added. - See zrtp_status_t::zrtp_status_rp_fail. - - 2. Fixed bug which may resulted in a dammage with decrypt failed 7 error. It - was happen when libzrtp passed RTP alerts packet to the replay protection - engine and ROC was broken. - - 3. Fixed RTCP encryption/decryption. - - 4. Fixed bug with RS1 and RS2 swapping when one of the sides lost RS1. - (May resulted in a error zrtp_protocol_error_t::zrtp_error_auth_decrypt ) - - -libzrtp 0.4.3 06.07.2007 --------------------------------------------------------------------------------- - 1. Beta version of API for PBX support according to the latest ZRTP draft. - Not tested. For internal development only. Follow // PBX comments; - - secret's cache format was changed. - - 2. S0 calculation according to NIST recommendations; Internal change - - ZRTP protocol version was increased to 0.07. - - 3. All libzrtp sources was audited with coverity code analyzer. http://coverity.com/ - -libzrtp (0.3.9 - 0.4.2) 27.06.2008 --------------------------------------------------------------------------------- - 1. Changes according to new draft 04a. All changes are internal. - a) new DH packets: pvi/pvr, nonce field is at the end of the DH packet. - In "Preshared" mode both DH packets contain nonce value instead of pvi/r; - b) new hvi value the same for all modes (DH and Preshared) - hvi = hash(initiator's DHPart2 message | responder's Hello message); - c) new algorithm of SAS computing: sasvalue = HMAC(hmackeyi,"SAS"); - - 2. New GUI based test-unite forSymbian platform - - 3. Default implementation of the packet retries unite for Symbian was added - to the libzrtp package. Except besides scheduler, libzrtp includes - realization of some synchronization and threading routines. These - components written in C++ and can't be linked with the library. One should - add them to own Symbian project project. - - 4. Compilation of default realization of ZRTP mutexes was separated from - the other system interfaces. To build library with default mutexes - BUILD_ZRTP_MUTEXES flag should be used; - - 5. New clearing logic. Goals: - API: - - state-machine states were changed - - goclear reason was eliminated. Now we can switch to CLEAR just on - user action. - - ZRTP_EVENT_IS_INITIATINGCLEAR was removed as a uperfluous event. As a - result all event codes were changed. - - new clear_hmac = HMAC(hmakkeyi/r, "Clear Hmac") - 6. New Errors handling logic. See updated state-macine diagram and "developers - guide". - API: - - ZRTP_STATE_ERROR was added to handle error requests. Libzrtp switches - to this state after the Error exchange. From ZRTP_STATE_ERROR stream - cxan be started again or destroyed, depending on application strategy. - - ZRTP_ERRORACK and ZRTP_ERROR packets were added - - new event ZRTP_ENEVT_NO_ZRTP inform's user that other side doesn't - support ZRTP encryption. - - 7. -D WITH_STACK_MINIM compilation flag allows to minimize coasts for the - system stack. In the most critical places dynamic allocation will be used - instead of static variables. This option can be useful on mobile platforms - in kernel mode, etc. - - 8. Several bug fixes in scheduler. Improved built-in realization of Symbian - platform. If you use our default realization on Symbian - please update. - - 9. David A. McGrew's srtp was replaced with our own. We did it to get control - over all crypto functions, generalize interface of crypto component. It - allows us to port libsrtp to any platforms more smoothly. We have one - configuration file, all platform-dependent function and definitions are - concentrated at one place. We eliminated superfluous functionality from - libsrtp, made it crossplatform and thread-safe. In SRTP engine we use our - own crypto-components based on by Dr. Brian Gladman's sources. Each component - has strong self-test function allows it to be tested on any platform and - in any environment. - - project structure was changed; - - bgaes folder includes AES and SHA routines by Dr. Brian Gladman. For details - see dgaes/howto and bg2zrtp.h files; - - libzrtp supports external realizations of SRTP (Use zrtp_srtp.h API and flag - -D WITHOUT_BUILTIN_SRTP ); - - 10. Header files were refactored: one can add just single zrtp.h include to use - any libzrtp function or data type; - - 11. Solved problem with deadlock during Video conferences. (One side starts - negotioation with Video and another one with Audio stream) - - 12. Some changes in test-unite: - - test vectores and test-cases for all cryptio components are available; - - zrtp_system_test.h checks environment and compilation flags - - use ZRTP_ENABLE_TEST flag to build library with all tests - 13. Full documentation review and updating. - - 14. Sources clean up and some refactoring; - - 15. Fixing in "break the tie" logic. See diagrams and zrtp_preparse_commit(), - zrtp_preparse_init_commit(); - - 16. Some changes according to the lates ZRTP specification: - - sasvalue was trancated to 32 bits and used mostleft parts of the hashvalue. - - 17. Small bug fixes (zrtp_can_start_dh and zrtp_can_start_preshared() mixed into - zrtp_can_start_stream); - - 18. New key derivation mechanism according to NIST standarts. See ZRTP Draft - 5.4.4 and 5.5.4. - -libzrtp (0.3.7) --------------------------------------------------------------------------------- - 1. New, more clear and useful test-unite - 2. Eliminated zrtp_stop_protocol(). Now zrtp_done_session_ctx() includes - protocol stopping. - 3. Some simplifications in project structure: removed zrtp_inet.h and bnase32.h, - zrtp_iface.c was removed to src\iface folder; - 4. ZSTR_GET_VALUE should be used to convert zrtp_stringxx_t to zrtp_stringn_t; - 5. Some changes for windows CE; - 6. Changed default options: SAS base256 enabled by defauld and "staysecure" is on. - -libzrtp (0.3.6) --------------------------------------------------------------------------------- - FIXES: - a) CRC now covers the whole ZRTP packet, not just a body - b) improved names of some crypto-components in HELLO/COMMIT packets - c) improved messages hash: hash function covers all ZRTP message with - magic number and length fields; - d) fixed DHPart1 and DHPart2 packets format according to last version - of ZRTP Internet draft. - e) fixed retain secrets sorting algorithm according to the last version - of the internet draft. - - 1. Windows CE support. Now library is fully compatible with Windows CE. - - .\libzrtp\projects\libzrtp_wince_vc8.sln project file for MS VS 2005 - - .\libzrtp\test\WinCE contains sources of simple test-unite ( We have - just started working in this direction and more intelligent test unite - will be available soon. Tested on HTC S620 with Windows CE 2005 ) - - 2. Added previous state field to ZRTP stream structure. It can be used to - analyze conditions of switching from one state to another. (For libzrtp - developers only) - API: - - zrtp_stream_ctx_t#_prev_state was added - - _zrtp_change_state() MUST be used to switch from one state to another - - 3. Some changes in PENDING_CLEAR state handler. In case of error during - transition from CLEAR to SECURE state-machine will switch back to CLEAR - without the confirmation by user. - - -libzrtp (0.3.5) --------------------------------------------------------------------------------- - Full description is in progress - - 1. Support of all crypto futures according to the new ZRTP draft v 0.3. Lots - of internal changes were provided in ZRTP kernel. - - 2. Symbian support. Now you can build libzrtp and test unites on Symbian - platforms. There are .inf and .mmp files in corresponded directories. - (Symbian project files are a little bit row and we will appreciate any - suggestions and advices.) - - 3. ZRTP stream became more independent. You can use different configurations - for different streams. So - ZRTP profile: profile; - "staysecure" flag: staysecure; - SAS values: sas_values; - cache TTL: cache_ttl; - and all used crypto components were removed from session context - (zrtp_conn_ctx_t) to stream context (zrtp_stream_ctx_t). - API: - - you should configure every stream in the same way as the whole session in - previous version has been done. See zrtp_init_session_ctx() - and zrtp_attach_stream() - - 4. "Multistream" mode was replaced by "Preshared" (based on retain secrets - from previous call. See http://zfoneproject.com/docs/ietf/draft-zimmermann-avt-zrtp-03.html#anchor19 . - Preshared mode is available as a normal ZRTP crypto component e.g."DH3K" - or "DH4K". If you enable Preshared mode in profile and libzrtp finds - secrets in your cache - "Preshared" mode will be used for all next calls - API: - - the choice of stream mode was removed from zrtp_start_stream() and - from zrtp_secure_stream(). - - 5. Integer enumerations for all crypto components e.g. Hash type, cipher type - etc. You should use these values instead of character values for optional - profile configuration. (as an example for enabling "preshared" mode) - API: - - enumerations types zrtp_hash_id, zrtp_cipher_idzrtp_atl_id, - zrtp_pktype_id, zrtp_sas_id in zrtp_crypto.h - - all crypto components structures now have id field and libzrtp - operates with this field to find, register or delete crypto - components. - - ZRTP profile: zrtp_profile_t uses this integer values too. (list of - crypto-components is a zero terminated array of values of necessary - type) - - zrtp_find_in_profile() and zrtp_find_comp() operate with component - integer identifiers - - there are two special functions to convert component ID to ZRTP - character name: zrtp_comp_id2type(), zrtp_comp_type2id. - - 6. Integer error codes were provided instead of 4-character values. One should - use them to analyze zrtp_stream_ctx_t#last_error value in your ZRTP - errors handlers. - API: - - zrtp_protocol_error_t was added to zrtp_error.h. - - zrtp_stream_ctx_t#last_error now is an integer value from - zrtp_protocol_error_t space. - - 7. Special function for verification of SAS value was added. One should use - this function to set/unset SAS verification flag from his own - application. - API: - - zrtp_set_verified() was added to zrtp.h - - 8. Some optimization of types was provided. Here are some possible changes which you - need to make in your product: - - libzrtp uses it own strings (zrtp_stringXX_t group) to operate with - binary and character strings. In this version we made attempt to - minimize memory coasts and replaced zrtp_string_t with zrtp_stringXX_t - group, where XX - maximum length in bytes. zrtp_stringxx_t contains - its length and as a result all functions for work with strings are - type independent. So one should use one of these types to store binary - strings and zrtp_stringn_t as a type of operand in all global functions. - - all retain secrets holders and flags were removed to zrtp_secrets - structure in zrtp_conn_ctx_t#secrets. - - zrtp_packet_string4_t was replaced by zrtp_ucharXX_t group where XX - - type length in bytes. These types are used in library for packets - construction instead of char arrays. - - 9. Packets retries synchronization was added. zrtp_retry_task_t structure - from zrtp_types_t is used for all operations with scheduler. One should - use #callback and #timeout fields from this structure. - API: - - zrtp_send_packet_later(), zrtp_cancel_send_packet_later() - -libzrtp (0.3.4) --------------------------------------------------------------------------------- - 1. ZRTP state-macine was fully refactored. All transitions between states - are absolutely identical to diagram attached to documentation. - DOC: - - See doc/img/png/state_mach_ext.png - - 2. ZRTP uses new packets format according to draft-zimmermann-avt-zrtp-03i - - 3. Improved some mistakes in libbn make-files for windows. Unused - functions were omitted. - - 4. Provided types optimization to decrease RAM memory costs. - - 5. Packets retries were synchronized. - - 6. zrtp_voip_proto_t was removed from the library - API: - - if you need this enumeration see zfone_types.h in zfone project - - 7. "GoClear reasons" support - - 8. Some internal changes according to draft-zimmermann-avt-zrtp-03i - a) Commit hash covers the whole Hello body - b) GoClear hmac includes "Reason string" - c) Confirm body encrypted by AES CDB cipher - d) Confirm hmac covers whole encrypted part of the packet - - 9. Use BUILD_ZRTP_DEBUG_LOG flag instead of BUILD_DEBUG_LOG to build the - library with debug logs. - -libzrtp (0.3.3) 21.02.2007 --------------------------------------------------------------------------------- - 1. libzrtp test application refactored for better performance and usability. - For addition information see test application README file and - "libzrtp test suite" chapter in main documentation page. - - 2. Some changes in documentation for better English - - 3. Use microseconds in zrtp_time_t instead of milliseconds. - API changes: - - change zrtp_get_time() function realization if needed - - 4. Fixed several small mistakes - - -libzrtp (0.3.2) 09.02.2007 --------------------------------------------------------------------------------- - 1. Global context allocation removed to user space. - This was made to able RNG using before library initialization. - API changes: - - zrtp_init(), zrtp_down() - - zrtp_randstr(), zrtp_add_system_state() - - 2. Fixed bug in srtp SHA1 calculation for Windows. - - 3. Confirm and GoClear HMAC was truncated to 64 bits. - - 4. Calls stack minimized for library using in kernel mode - - 5. Default realization of secrets' cache is available. Cache was implemented - as a simple binary file and can be built using -DBUILD_DEFAULT_CACHE file. - API: - - realization at src\iface\zrtp_cache.c - DOC: - - 1.4 libZRTP setup and building - - 2.2 System-dependent functions - - 6. Default cross-platform realization of time-out sending unite is available. - This unite is available for Linux, MacOS and Windows. It can be built using - -DBUILD_DEFAULT_TIMER flag. - API: - - realization at src\iface\zrtp_scheduler.c - DOC: - - 1.4 libZRTP setup and building - - 2.2 System-dependent functions - - 7. "HOWTO libzrtp" was added to the library documentation - -libzrtp (0.3.1) 06.12.2006 --------------------------------------------------------------------------------- - 1. Global variables were removed from c-files. Added global context - zrtp_global_ctx_t for necessary data storing. This was made to allow - to build library in some special environment as Symbian OS ed2. - DOC changes: - - 2.1.2 data structure - API changes: - - zrtp_global_ctx_t added - - zrtp_init(), zrtp_down(), zrtp_init_session(), zrtp_down_session() - - 2. Added multithreading support. Now libzrtp is thread-safe. About all - conditions of usage in multithreading application and synchronization - schemes see section "2.3.3 Multithreading and concurrent streams" in - developers guide. - DOC changes: - - 2.2.3 Multithreading and concurrent streams - API changes: - - mutex were added to main data structures - - mutex interface section at zrtp_iface.c, default realization at - zrtp_iface.c - - 3. Session configuration routine was simplified. ZRTP profile is applied on - session initialization. Some configuration functions were removed and - changed. - DOC changes: - - 2.3.1 Setup, initialization and deinitialization - API: - - zrtp_profile_autoload() removed - - zrtp_init_session(), zrtp_check_profile() - - 4. Default realizations of system interfaces was added (for Windows, Linux - and MacOS). - API: - - zrtp_iface.c added - - 5. Test suit developed. - Simple test-unite created. It runs several ZRTP sessions, enters SECURE - mode, shows statistics and is closed. To build test-suite on Unix - use C - flags -DBUILD_DEBUG_LOG -DBUILD_WITH_CFUNC -DBUILD_EMPTY_CACHE - -DBUILD_EMPTY_TIMER and configure param. --enable-test. To run tests: - make check. To build test-suite on Windows use necessary project files. - DOC changes: - - 1.4 libZRTP setup and building - API: - - Sources can be found at /test directory - - 6. Some changes in project structure, configuration and make files according - to new functionality. - DOC changes: - - 1.4 libZRTP setup and building - \ No newline at end of file diff --git a/libs/libzrtp/INSTALL b/libs/libzrtp/INSTALL deleted file mode 100644 index 16a3c821ff..0000000000 --- a/libs/libzrtp/INSTALL +++ /dev/null @@ -1,255 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - -Basic Installation -================================================================================ - - To start playing with Zfone and libzrtp you should install few developers -packages on your machine: gcc and g++ compilers, automake and autoconf tools. - - To install library as a Zfone component for Linux the following flags -should be used: BUILD_DEBUG_LOG, BUILD_WITH_CFUNC, BUILD_DEFAULT_CACHE, -BUILD_DEFAULT_TIMER and WITH_ZFONE. - The following instructions are for experienced users and developers only. -If you just want to install Zfone use the command as follows: -./configure CFLAGS="-O0 -g3 -W -Wall -DBUILD_DEBUG_LOG -DBUILD_WITH_CFUNC --DBUILD_DEFAULT_CACHE -DBUILD_DEFAULT_TIMER -DWITH_ZFONE" - -Library distribution contains installation and configuration files, project files -for several Operation Systems. To install Library on Unix-like systems the -autotools tool set is used. To install on Windows - Microsoft Visual Studio. -Except standard for your system compile flags the following are available for -your system: --# -DBUILD_DEBUG_LOG - enables debug and logging information - This flag is recommended to be used at design stages for testing. Logs make - debug process much easier and are to be included into bugreport. --# -DBUILD_WITH_CFUNC - assign to the library to gather standard for this - platform system interface functions realizations. This option simplifies the - library use and make code more compact. You can have a look at realizations - in src/zrtp-iface.c. file. And if they suit you use this flag. --# -DBUILD_EMPTY_CACHE this flag assigns to the library to use empty stubs - instead of operations with cache. This checkbox may be used in test - applications or in systems where cache secrets storing is impossible. Be - careful with this flag! Use it if it is really necessary. --# -DBUILD_EMPTY_TIMER this flag assigns to the library to use empty stubs - instead of delayed tasks processing. This checkbox may be used in test - applications or in systems with the reliable communication channel (the - package loss is impossible). Be careful with this flag! Use it if it is - really necessary. - -Except library itself, the set of utilities for the all components workability -check on the basis of a certain platform is provided. libzrtp test creates -several parallel ZRTP sessions, initiates transfer to the protected mode, -displays statistics, after which the application is stopped. If application test -was completed successfully the library is configured correctly, all components -work correctly. Note! Installation of test application is carried out with --DBUILD_EMPTY_CACHE -DBUILD_EMPTY_TIMER flags. After fulfilling tests reinstall -library without use of these flags. - -Further instructions must be followed in order to build and set up the library in -any Unix-like operation system (Linux, FreeBSD, MacOS): - -# Download source codes from zfoneproject.com - -# Decompress the archive libzrtp-0.3.X.tzr.gz : tar -zxf ./libzrtp-0.3.X.tzr.gz - and open cd libzrtp-0.3.X directory - -# Configure the library: ./configure (use necessary compollation flags) - -# Build the library: make - -# If you get the errors during, please send a full log of configuration - and building process to zfone-bugs@philzimmermann.com. Please specify - the operation system, hardware platform, compiler version and other - environmental parameters. Any proposals will be taken into account when - developing new versions. - -# After te library successful building, run setup (installation): ./make install - -# to build test unites run ./configure with CFLAGS="-DBUILD_DEBUG_LOG - -DBUILD_WITH_CFUNC -DBUILD_EMPTY_CACHE -DBUILD_EMPTY_TIMER and parameter - --enable-test. After successful configuration start test: "make check". - This command will build and run all test (bnlib test, srtp tests and - libzrtp tests) Don't forget to rebuild library without -DBUILD_EMPTY_CACHE - -DBUILD_EMPTY_TIMER. - -For library configuration and installation on Windows platform the followinf -files should be used: - -# For installation with the Microsoft Visual Studio v6 use: - - libzrtp.dsw - - libzrtp.dsp - - test\libzrtp_test.dsp - -# For installation with the Microsoft Visual Studio v7 use: - - libzrtp.sln - - libzrtp.vcproj - - test\libzrtp_test.vcproj - -# If you want to build libzrtp in Windows kernel mode you mast use MAKEFILE.WIN32 - -For 32-bit machines bnlib contains assemble file lbn80386.asm. The assembler is -needed to install it. The compiler ml is in the stracture of VS7, if you use VS6 -you can use Microsoft Macro Assembler (http://www.masm32.com/masmdl.htm). To -compile this file you have define in properties: Commands: \ml /c /Cx -/coff /Fo $(TargetDir)\$(InputName).obj $(InputPath) Outputs: $(TargetDir)\$(InputName).obj - where is a complete path to the compiler. - -Possible problems and methods of the solution: - -# Some environment problems with automatic definition of architecture - and byte-order are possible at library building. We recommend before building - of libZRTP on a new program or hardware platform uncomment the test-unite at - the end of the file \c zrtp_syste.h. If there is a mistakes in definition of - architecture or byte-order use zrtp_system.h manual configuration following - the comments. - -Please take into account the fact that libzrtp developers are not responsible for -external modules of the library. In other words, the functionality of the library -was tested under majority of widespread Linux and Windows systems, but warnings -can still occur during these modules compilation. - -If you have faced with some problems during configuration or installing of the -library - send a report to the Support Service. If you installed library on the -platform not described here, please contact the Support Service. We are -interested very much to get know the results of testing on new platforms. We -will carefully examine all proposals and will do our best to realize them in new -library versions. - - -Compilers and Options -================= - - Some systems require unusual options for compilation or linking that -the `configure' script does not know about. You can give `configure' -initial values for variables by setting them in the environment. Using -a Bourne-compatible shell, you can do that on the command line like -this: - CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure - -Or on systems that have the `env' program, you can do it like this: - env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure - -Compiling For Multiple Architectures -================= - - You can compile the package for more than one kind of computer at the -same time, by placing the object files for each architecture in their -own directory. To do this, you must use a version of `make' that -supports the `VPATH' variable, such as GNU `make'. `cd' to the -directory where you want the object files and executables to go and run -the `configure' script. `configure' automatically checks for the -source code in the directory that `configure' is in and in `..'. - - If you have to use a `make' that does not supports the `VPATH' -variable, you have to compile the package for one architecture at a time -in the source code directory. After you have installed the package for -one architecture, use `make distclean' before reconfiguring for another -architecture. - -Installation Names -================== - - By default, `make install' will install the package's files in -`/usr/local/include', `/usr/local/lib', etc. You can specify an -installation prefix other than `/usr/local' by giving `configure' the -option `--prefix=PATH'. - - You can specify separate installation prefixes for -architecture-specific files and architecture-independent files. If you -give `configure' the option `--exec-prefix=PATH', the package will use -PATH as the prefix for installing programs and libraries. -Documentation and other data files will still use the regular prefix. - - If the package supports it, you can cause programs to be installed -with an extra prefix or suffix on their names by giving `configure' the -option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. - -Optional Features -================= - - Some packages pay attention to `--enable-FEATURE' options to -`configure', where FEATURE indicates an optional part of the package. -They may also pay attention to `--with-PACKAGE' options, where PACKAGE -is something like `gnu-as' or `x' (for the X Window System). The -`README' should mention any `--enable-' and `--with-' options that the -package recognizes. - - For packages that use the X Window System, `configure' can usually -find the X include and library files automatically, but if it doesn't, -you can use the `configure' options `--x-includes=DIR' and -`--x-libraries=DIR' to specify their locations. - -Specifying the System Type -========================== - - There may be some features `configure' can not figure out -automatically, but needs to determine by the type of host the package -will run on. Usually `configure' can figure that out, but if it prints -a message saying it can not guess the host type, give it the -`--host=TYPE' option. TYPE can either be a short name for the system -type, such as `sun4', or a canonical name with three fields: - CPU-COMPANY-SYSTEM - -See the file `config.sub' for the possible values of each field. If -`config.sub' isn't included in this package, then this package doesn't -need to know the host type. - - If you are building compiler tools for cross-compiling, you can also -use the `--target=TYPE' option to select the type of system they will -produce code for and the `--build=TYPE' option to select the type of -system on which you are compiling the package. - -Sharing Defaults -================ - - If you want to set default values for `configure' scripts to share, -you can create a site shell script called `config.site' that gives -default values for variables like `CC', `cache_file', and `prefix'. -`configure' looks for `PREFIX/share/config.site' if it exists, then -`PREFIX/etc/config.site' if it exists. Or, you can set the -`CONFIG_SITE' environment variable to the location of the site script. -A warning: not all `configure' scripts look for a site script. - -Defining Variables -================== - - Variables not defined in a site shell script can be set in the -environment passed to `configure'. However, some packages may run -configure again during the build, and the customized values of these -variables may be lost. In order to avoid this problem, you should set -them in the `configure' command line, using `VAR=value'. For example: - - ./configure CC=/usr/local2/bin/gcc - -will cause the specified gcc to be used as the C compiler (unless it is -overridden in the site shell script). - -Operation Controls -================== - - `configure' recognizes the following options to control how it -operates. - -`--version' -`-V' - Print the version of Autoconf used to generate the `configure' - script, and exit. - -`--cache-file=FILE' - Use and save the results of the tests in FILE instead of - `./config.cache'. Set FILE to `/dev/null' to disable caching, for - debugging `configure'. - -`--help' - Print a summary of the options to `configure', and exit. - -`--quiet' -`--silent' -`-q' - Do not print messages saying which checks are being made. - -`--srcdir=DIR' - Look for the package's source code in directory DIR. Usually - `configure' can determine that directory automatically. - -`--version' - Print the version of Autoconf used to generate the `configure' - script, and exit. - -`configure' also accepts some other, not widely useful, options. diff --git a/libs/libzrtp/Makefile.am b/libs/libzrtp/Makefile.am deleted file mode 100644 index 2d3b82421d..0000000000 --- a/libs/libzrtp/Makefile.am +++ /dev/null @@ -1,115 +0,0 @@ -# -# Copyright (c) 2006-2007 Philip R. Zimmermann. All rights reserved. -# Contact: http://philzimmermann.com -# -# Viktor Krikun -# - -libzrtp_includedir=$(includedir)/libzrtp -libzrtp_include_HEADERS = \ - $(top_srcdir)/include/zrtp.h \ - $(top_srcdir)/include/zrtp_base.h \ - $(top_srcdir)/include/zrtp_config.h \ - $(top_srcdir)/include/zrtp_config_user.h \ - $(top_srcdir)/include/zrtp_config_unix.h \ - $(top_srcdir)/include/zrtp_crypto.h \ - $(top_srcdir)/include/zrtp_ec.h \ - $(top_srcdir)/include/zrtp_engine.h \ - $(top_srcdir)/include/zrtp_error.h \ - $(top_srcdir)/include/zrtp_iface.h \ - $(top_srcdir)/include/zrtp_iface_scheduler.h \ - $(top_srcdir)/include/zrtp_iface_cache.h \ - $(top_srcdir)/include/zrtp_iface_system.h \ - $(top_srcdir)/include/zrtp_legal.h \ - $(top_srcdir)/include/zrtp_list.h \ - $(top_srcdir)/include/zrtp_log.h \ - $(top_srcdir)/include/zrtp_pbx.h \ - $(top_srcdir)/include/zrtp_protocol.h \ - $(top_srcdir)/include/zrtp_srtp.h \ - $(top_srcdir)/include/zrtp_srtp_builtin.h \ - $(top_srcdir)/include/zrtp_string.h \ - $(top_srcdir)/include/zrtp_types.h \ - $(top_srcdir)/include/zrtp_version.h \ - \ - $(top_srcdir)/third_party/bnlib/bn.h \ - \ - $(top_srcdir)/third_party/bgaes/aes.h \ - $(top_srcdir)/third_party/bgaes/aesopt.h \ - $(top_srcdir)/third_party/bgaes/aestab.h \ - $(top_srcdir)/third_party/bgaes/bg2zrtp.h \ - $(top_srcdir)/third_party/bgaes/brg_types.h \ - $(top_srcdir)/third_party/bgaes/sha1.h \ - $(top_srcdir)/third_party/bgaes/sha2.h - -lib_LIBRARIES = libzrtp.a - -libzrtp_a_CPPFLAGS = \ - -I$(top_srcdir)/include \ - -I$(top_srcdir)/. \ - -I$(top_srcdir)/third_party/bgaes \ - -I$(top_srcdir)/third_party/bnlib - -libzrtp_a_LIBADD = $(top_srcdir)/third_party/bnlib/libbn.a - -libzrtp_a_SOURCES = $(top_srcdir)/src/zrtp.c \ - $(top_srcdir)/src/zrtp_crc.c \ - $(top_srcdir)/src/zrtp_crypto_aes.c \ - $(top_srcdir)/src/zrtp_crypto_atl.c \ - $(top_srcdir)/src/zrtp_crypto_ec.c \ - $(top_srcdir)/src/zrtp_crypto_ecdh.c \ - $(top_srcdir)/src/zrtp_crypto_hash.c \ - $(top_srcdir)/src/zrtp_crypto_pk.c \ - $(top_srcdir)/src/zrtp_crypto_sas.c \ - $(top_srcdir)/src/zrtp_datatypes.c \ - $(top_srcdir)/src/zrtp_engine.c \ - $(top_srcdir)/src/zrtp_iface_scheduler.c \ - $(top_srcdir)/src/zrtp_iface_sys.c \ - $(top_srcdir)/src/zrtp_initiator.c \ - $(top_srcdir)/src/zrtp_legal.c \ - $(top_srcdir)/src/zrtp_list.c \ - $(top_srcdir)/src/zrtp_log.c \ - $(top_srcdir)/src/zrtp_pbx.c \ - $(top_srcdir)/src/zrtp_protocol.c \ - $(top_srcdir)/src/zrtp_responder.c \ - $(top_srcdir)/src/zrtp_rng.c \ - $(top_srcdir)/src/zrtp_srtp_builtin.c \ - $(top_srcdir)/src/zrtp_string.c \ - $(top_srcdir)/src/zrtp_utils.c \ - $(top_srcdir)/src/zrtp_utils_proto.c \ - \ - $(top_srcdir)/third_party/bgaes/aes_modes.c \ - $(top_srcdir)/third_party/bgaes/aescrypt.c \ - $(top_srcdir)/third_party/bgaes/aeskey.c \ - $(top_srcdir)/third_party/bgaes/aestab.c \ - $(top_srcdir)/third_party/bgaes/sha1.c \ - $(top_srcdir)/third_party/bgaes/sha2.c\ - \ - $(top_srcdir)/src/zrtp_iface_cache.c - $(top_srcdir)/src/zrtp_engine_driven.c - -check_PROGRAMS = cache_test - -cache_test_CPPFLAGS = -I$(top_srcdir)/include \ - -I$(top_srcdir)/. \ - -I$(top_srcdir)/test \ - -I$(top_srcdir)/test/cmockery \ - -I$(top_srcdir)/third_party/bgaes \ - -I$(top_srcdir)/third_party/bnlib - -cache_test_SOURCES = $(top_srcdir)/test/cmockery/cmockery.c \ - $(top_srcdir)/test/cache_test.c -cache_test_LDADD = libzrtp.a $(top_srcdir)/third_party/bnlib/libbn.a -lpthread - -SUBDIRS = third_party/bnlib - -if HAVE_DOXYGEN -doc: .stamp-doc -.stamp-doc: - (cd doc && $(DOXYGEN) Doxyfile) - touch $@ -endif - -uninstall: - rm -rf $(prefix)/include/libzrtp - rm -f $(prefix)/lib/libzrtp.a - diff --git a/libs/libzrtp/NEWS b/libs/libzrtp/NEWS deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/libs/libzrtp/README b/libs/libzrtp/README deleted file mode 100644 index c6d90aae2e..0000000000 --- a/libs/libzrtp/README +++ /dev/null @@ -1,10 +0,0 @@ -# -# libZRTP SDK library, implements the ZRTP secure VoIP protocol. -# Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. -# Contact: http://philzimmermann.com -# For licensing and other legal details, see the file zrtp_legal.c. -# - -- Check HTML Documentation ./doc -- Visit the Zfone Project Home Page http://zfoneproject.com/ -- Report bugs via the Zfone Bugs Page http://zfoneproject.com/bugs.html diff --git a/libs/libzrtp/acinclude.m4 b/libs/libzrtp/acinclude.m4 deleted file mode 100644 index f5879955c2..0000000000 --- a/libs/libzrtp/acinclude.m4 +++ /dev/null @@ -1,94 +0,0 @@ -AC_DEFUN([AX_PREFIX_CONFIG_H],[dnl -AC_BEFORE([AC_CONFIG_HEADERS],[$0])dnl -AC_CONFIG_COMMANDS([ifelse($1,,$PACKAGE-config.h,$1)],[dnl -AS_VAR_PUSHDEF([_OUT],[ac_prefix_conf_OUT])dnl -AS_VAR_PUSHDEF([_DEF],[ac_prefix_conf_DEF])dnl -AS_VAR_PUSHDEF([_PKG],[ac_prefix_conf_PKG])dnl -AS_VAR_PUSHDEF([_LOW],[ac_prefix_conf_LOW])dnl -AS_VAR_PUSHDEF([_UPP],[ac_prefix_conf_UPP])dnl -AS_VAR_PUSHDEF([_INP],[ac_prefix_conf_INP])dnl -m4_pushdef([_script],[conftest.prefix])dnl -m4_pushdef([_symbol],[m4_cr_Letters[]m4_cr_digits[]_])dnl -_OUT=`echo ifelse($1, , $PACKAGE-config.h, $1)` -_DEF=`echo _$_OUT | sed -e "y:m4_cr_letters:m4_cr_LETTERS[]:" -e "s/@<:@^m4_cr_Letters@:>@/_/g"` -_PKG=`echo ifelse($2, , $PACKAGE, $2)` -_LOW=`echo _$_PKG | sed -e "y:m4_cr_LETTERS-:m4_cr_letters[]_:"` -_UPP=`echo $_PKG | sed -e "y:m4_cr_letters-:m4_cr_LETTERS[]_:" -e "/^@<:@m4_cr_digits@:>@/s/^/_/"` -_INP=`echo "ifelse($3,,,$3)" | sed -e 's/ *//'` -if test ".$_INP" = "."; then - for ac_file in : $CONFIG_HEADERS; do test "_$ac_file" = _: && continue - case "$ac_file" in - *.h) _INP=$ac_file ;; - *) - esac - test ".$_INP" != "." && break - done -fi -if test ".$_INP" = "."; then - case "$_OUT" in - */*) _INP=`basename "$_OUT"` - ;; - *-*) _INP=`echo "$_OUT" | sed -e "s/@<:@_symbol@:>@*-//"` - ;; - *) _INP=config.h - ;; - esac -fi -if test -z "$_PKG" ; then - AC_MSG_ERROR([no prefix for _PREFIX_PKG_CONFIG_H]) -else - if test ! -f "$_INP" ; then if test -f "$srcdir/$_INP" ; then - _INP="$srcdir/$_INP" - fi fi - AC_MSG_NOTICE(creating $_OUT - prefix $_UPP for $_INP defines) - if test -f $_INP ; then - echo "s/^@%:@undef *\\(@<:@m4_cr_LETTERS[]_@:>@\\)/@%:@undef $_UPP""_\\1/" > _script - echo "s/^@%:@undef *\\(@<:@m4_cr_letters@:>@\\)/@%:@undef $_LOW""_\\1/" >> _script - echo "s/^@%:@def[]ine *\\(@<:@m4_cr_LETTERS[]_@:>@@<:@_symbol@:>@*\\)\\(.*\\)/@%:@ifndef $_UPP""_\\1 \\" >> _script - echo "@%:@def[]ine $_UPP""_\\1 \\2 \\" >> _script - echo "@%:@endif/" >>_script - echo "s/^@%:@def[]ine *\\(@<:@m4_cr_letters@:>@@<:@_symbol@:>@*\\)\\(.*\\)/@%:@ifndef $_LOW""_\\1 \\" >> _script - echo "@%:@define $_LOW""_\\1 \\2 \\" >> _script - echo "@%:@endif/" >> _script - # now executing _script on _DEF input to create _OUT output file - echo "@%:@ifndef $_DEF" >$tmp/pconfig.h - echo "@%:@def[]ine $_DEF 1" >>$tmp/pconfig.h - echo ' ' >>$tmp/pconfig.h - echo /'*' $_OUT. Generated automatically at end of configure. '*'/ >>$tmp/pconfig.h - - sed -f _script $_INP >>$tmp/pconfig.h - echo ' ' >>$tmp/pconfig.h - echo '/* once:' $_DEF '*/' >>$tmp/pconfig.h - echo "@%:@endif" >>$tmp/pconfig.h - if cmp -s $_OUT $tmp/pconfig.h 2>/dev/null; then - AC_MSG_NOTICE([$_OUT is unchanged]) - else - ac_dir=`AS_DIRNAME(["$_OUT"])` - AS_MKDIR_P(["$ac_dir"]) - rm -f "$_OUT" - mv $tmp/pconfig.h "$_OUT" - fi - cp _script _configs.sed - else - AC_MSG_ERROR([input file $_INP does not exist - skip generating $_OUT]) - fi - rm -f conftest.* -fi -m4_popdef([_symbol])dnl -m4_popdef([_script])dnl -AS_VAR_POPDEF([_INP])dnl -AS_VAR_POPDEF([_UPP])dnl -AS_VAR_POPDEF([_LOW])dnl -AS_VAR_POPDEF([_PKG])dnl -AS_VAR_POPDEF([_DEF])dnl -AS_VAR_POPDEF([_OUT])dnl -],[PACKAGE="$PACKAGE"])]) - -dnl implementation note: a bug report (31.5.2005) from Marten Svantesson points -dnl out a problem where `echo "\1"` results in a Control-A. The unix standard -dnl http://www.opengroup.org/onlinepubs/000095399/utilities/echo.html -dnl defines all backslash-sequences to be inherently non-portable asking -dnl for replacement mit printf. Some old systems had problems with that -dnl one either. However, the latest libtool (!) release does export an $ECHO -dnl (and $echo) that does the right thing - just one question is left: what -dnl was the first version to have it? Is it greater 2.58 ? diff --git a/libs/libzrtp/bootstrap.sh b/libs/libzrtp/bootstrap.sh deleted file mode 100755 index dfa3cc3652..0000000000 --- a/libs/libzrtp/bootstrap.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -reconf () { - aclocal - mkdir -p config - libtoolize --copy --automake - autoconf - autoheader - automake --no-force --add-missing --copy -} - -(cd third_party/bnlib && ./bootstrap.sh) -reconf - diff --git a/libs/libzrtp/configure.ac b/libs/libzrtp/configure.ac deleted file mode 100644 index 5ac158109c..0000000000 --- a/libs/libzrtp/configure.ac +++ /dev/null @@ -1,97 +0,0 @@ -# -# Copyright (c) 2006-2011 Philip R. Zimmermann. All rights reserved. -# Contact: http://philzimmermann.com -# For licensing and other legal details, see the file zrtp_legal.c. -# -# Viktor Krikun -# - -AC_INIT([libzrtp], [1.2.0]) - -AC_CONFIG_AUX_DIR(config) -AC_CONFIG_HEADER(config/config.h) - -# Checks for target OS -AC_CANONICAL_TARGET - -case $target_os in - aix*) ;; - *mingw* | *cygw* | *win32* | *w32* ) - echo "------- START libzrtp configuration for Windows platform ------------" - ;; - *darwin*) - echo "------- START libzrtp configuration for Darwin platform ------------" - ;; - *freebsd2* | *freebsd* | *netbsd* | *openbsd* | *osf[12]*) - echo "------- START libzrtp configuration for BSD platform ------------" - ;; - hpux* | irix* | linuxaout* | linux* | osf* | solaris2* | sunos4*) - echo "------- START libzrtp configuration for Linux platform ------------" - ;; -esac - - -AM_INIT_AUTOMAKE -AX_PREFIX_CONFIG_H(include/zrtp_config_unix.h,ZRTP,config/config.h) - -CFLAGS="$CFLAGS -std=c99 -O2 -g3 -Wall -Wextra -Wno-unused-parameter -fno-strict-aliasing -fPIC -DZRTP_AUTOMAKE=1" - -# Configuring external libraries -echo "========================= configuring bnlib ==============================" -cd third_party/bnlib -./configure CFLAGS="$CFLAGS" -cd ../.. -echo "================================ done ===================================" - -# Checks for programs. -AC_PROG_CC -AC_PROG_CXX -AC_PROG_RANLIB -AM_PROG_CC_C_O - -# Checks for header files. -AC_HEADER_STDC -AC_CHECK_HEADERS([linux/version.h endian.h]) -AC_CHECK_HEADERS([errno.h]) -AC_CHECK_HEADERS([asm/types.h]) -AC_CHECK_HEADERS([stdlib.h stdint.h stdarg.h]) -AC_CHECK_HEADERS([string.h strings.h]) -AC_CHECK_HEADERS([stdio.h unistd.h]) -AC_CHECK_HEADERS([inttypes.h sys/inttypes.h sys/types.h machine/types.h]) -AC_CHECK_HEADERS([pthread.h semaphore.h sys/time.h fcntl.h]) - -AC_CHECK_TYPES([int8_t,uint8_t,int16_t,uint16_t,int32_t,uint32_t,uint64_t,int64_t]) - -# Checks for typedefs, structures, and compiler characteristics. -AC_C_CONST - -# Checks for library functions. -AC_CHECK_FUNCS([memset memcpy malloc free]) -AC_CHECK_FUNCS([usleep nanosleep]) -AC_CHECK_FUNCS([fopen fread]) -AC_CHECK_FUNCS([pthread_mutex_lock pthread_mutex_unlock pthread_mutex_init pthread_mutex_destroy]) -AC_CHECK_FUNCS([pthread_attr_init pthread_attr_setdetachstate pthread_create]) -AC_CHECK_FUNCS([sem_wait sem_trywait sem_post sem_unlink sem_destroy sem_open sem_init]) - -AC_CHECK_LIB([pthread], [main], [LIBS="-lpthread $LIBS"], [echo " Couldn't find library pthread";]) - -# Other -AC_DEFINE(PRAGMA_PACK_PUSH,[#pragma pack(push, 1)],[Define pragma pack(push) for your platform]) -AC_DEFINE(PRAGMA_PACK_POP,[#pragma pack(pop)],[Define pragma pack(pop) for your platform]) -AC_DEFINE(INLINE,[static inline],[Define inline construction for your platform]) - -# -# Documentation -# -AM_CONDITIONAL([HAVE_DOXYGEN], [false]) -AC_CHECK_PROGS([DOXYGEN], [doxygen]) -if test -z "$DOXYGEN"; then - AC_MSG_WARN([Doxygen not found - continuing without Doxygen support]) -else - AM_CONDITIONAL([HAVE_DOXYGEN], [true]) - AC_CONFIG_FILES([doc/Doxyfile]) -fi - -# -# Generate Makefiles -AC_OUTPUT([Makefile]) diff --git a/libs/libzrtp/create_docs.sh b/libs/libzrtp/create_docs.sh deleted file mode 100755 index a30c7c256b..0000000000 --- a/libs/libzrtp/create_docs.sh +++ /dev/null @@ -1,9 +0,0 @@ -cd ../../doc -rm -f docs.tar.gz -rm -rf libzrtp-doc -echo "=================> start doxygen." -doxygen > /dev/null 2>&1 -mkdir libzrtp-doc -cp -Rf ./out/html/* ./libzrtp-doc -tar -zcvf ./libzrtp-doc.tar.gz ./libzrtp-doc >> /dev/null -rm -rf libzrtp-doc diff --git a/libs/libzrtp/create_pack.pl b/libs/libzrtp/create_pack.pl deleted file mode 100755 index e43b63ece3..0000000000 --- a/libs/libzrtp/create_pack.pl +++ /dev/null @@ -1,421 +0,0 @@ -#!/usr/bin/perl - -use Getopt::Std; - -getopts("l:ehs", \%args); - -if ($args{h}) -{ - print "Usage: create_pack.pl [OPTION]...\n\n"; - print " -l file write down list of files\n"; - print " -e enterprise version\n"; - print " -s dont add version suffix to package name\n"; - print " -h this help\n\n"; - exit 1; -} - -#to create list of files: -if ($args{l}) -{ - create_files_list($args{l}); - exit 1; -} - -$enterprise = 0; -if ($args{e}) -{ - $enterprise = 1; -} - -if ($args{s}) -{ - $packdir="libzrtp"; -} -else -{ - $LIBZRTP_VERSION=`cat ../../include/zrtp_version.h | grep 'LIBZRTP_VERSION_STR' | awk '{print \$3, \$4}' | sed 's/"v\\(.*\\) \\(.*\\)"/\\1.\\2/'`; - chomp($LIBZRTP_VERSION); - $packdir="libzrtp-$LIBZRTP_VERSION"; -} - -if (-d $packdir) -{ - `rm -rf $packdir` -} - -mkdir $packdir; -create_array(); - -foreach $file(@array) -{ - if (!$enterprise && - (($file =~ m/\/enterprise/i) || - ($file =~ m/_ec.*(proj|sln)/i) || - ($file =~ m/_EC.*(WIN)/i) || - ($file =~ m/\/xcode/i))) - { - print "$file skipped\n"; - next; - } - - $path = "../../" . $file; - if (!-e $path) - { - print "[ERROR]: file $file doesn't exist!\n"; - `rm -rf $packdir`; - exit -1; - } - if (-d $path) - { - mkdir "$packdir/$file"; - } - else - { -# print "copying $path file\n"; - `cp $path $packdir/$file` - } -} - -if (!$enterprise) -{ - `cp -f ../../projects/win/libzrtp_not_ec.vcproj $packdir/projects/win/libzrtp.vcproj`; - `cp -f ../../projects/win_ce/libzrtp_wince_not_ec.vcproj $packdir/projects/win_ce/libzrtp_wince.vcproj`; - `cp -f ../../projects/win_kernel/MAKEFILE_NOT_EC.WIN64 $packdir/projects/win_kernel/MAKEFILE.WIN64`; - `cp -f ../../projects/win_kernel/MAKEFILE_NOT_EC.WIN32 $packdir/projects/win_kernel/MAKEFILE.WIN32`; - - `rm $packdir/include/zrtp_ec.h`; -# `rm $packdir/include/zrtp_iface_cache.h`; - `rm $packdir/src/zrtp_crypto_ecdsa.c`; - `rm $packdir/src/zrtp_crypto_ec.c`; -# `rm $packdir/src/zrtp_engine_driven.c`; - `rm $packdir/src/zrtp_crypto_ecdh.c`; -# `rm $packdir/src/zrtp_iface_cache.c`; -} - - -`find $packdir -name "._*" -delete`; - -$pack_name = $packdir; -if ($enterprise) -{ - $pack_name = $pack_name . "-ec"; -} - -$system = `uname -a`; -if ($system =~ m/darwin/i) -{ - `rm -rf $pack_name.zip`; - `zip -r $pack_name.zip $packdir`; -} -else -{ - `rm -rf $pack_name.tar.gz`; - `tar -zcvf $pack_name.tar.gz $packdir`; -} -`rm -rf $packdir`; -print "package was created\n"; - -#for item in $array; do -# echo "item:"$'\t'"$item" - -sub create_files_list() -{ - $path = `pwd`; - chop($path); - `cd ../..;find . -not -path *svn* -print | awk '{printf \"\\t\\t\\"%s\\",\\n\", \$1} ' > $path/$_[0];cd $path`; -} - - -sub create_array() -{ - @array = - ( - "./ChangeLog", - "./README", - "./AUTHORS", - "./projects", - "./projects/gnu", - "./projects/gnu/Makefile.am", - "./projects/gnu/Makefile.in", - "./projects/gnu/COPYING", - "./projects/gnu/aclocal.m4", - "./projects/gnu/configure", - "./projects/gnu/README", - "./projects/gnu/AUTHORS", - "./projects/gnu/configure.in", - "./projects/gnu/INSTALL", - "./projects/gnu/autoreconf.sh", - "./projects/gnu/config", - "./projects/gnu/config/config.guess", - "./projects/gnu/config/config.sub", - "./projects/gnu/config/config.h.in", - "./projects/gnu/config/install-sh", - "./projects/gnu/config/missing", - "./projects/gnu/config/prefix_config.m4", - "./projects/gnu/config/depcomp", - "./projects/gnu/NEWS", - "./projects/gnu/Makefile.in", - "./projects/gnu/build", - "./projects/gnu/build/Makefile.am", - "./projects/gnu/build/Makefile.in", - "./projects/gnu/build/test", - "./projects/gnu/build/test/Makefile.am", - "./projects/gnu/build/test/Makefile.in", - "./projects/gnu/ChangeLog", - "./projects/xcode", - "./projects/xcode/libzrtp.xcodeproj", - "./projects/xcode/libzrtp.xcodeproj/project.pbxproj", - "./projects/xcode/libzrtp_test.xcodeproj", - "./projects/xcode/libzrtp_test.xcodeproj/project.pbxproj", - "./projects/win_kernel", - "./projects/win_kernel/MAKEFILE.WIN64", - "./projects/win_kernel/MAKEFILE.WIN32", - "./projects/win", - "./projects/win/libzrtp.vcproj", - "./projects/win/libzrtp.sln", - "./projects/win/libzrtp_test.vcproj", - "./projects/win_ce", - "./projects/win_ce/libzrtp_test_wince.vcproj", - "./projects/win_ce/libzrtp_wince.sln", - "./projects/win_ce/libzrtp_wince.vcproj", - "./projects/symbian", - "./projects/symbian/bld.bat", - "./projects/symbian/bld.inf", - "./projects/symbian/bldgcce.bat", - "./projects/symbian/libzrtp.mmp", - "./projects/symbian/zrtp_iface_symb.cpp", - "./src", - "./src/zrtp.c", - "./src/zrtp_crc.c", - "./src/zrtp_crypto_aes.c", - "./src/zrtp_crypto_atl.c", - "./src/zrtp_crypto_hash.c", - "./src/zrtp_crypto_pk.c", - "./src/zrtp_crypto_sas.c", - "./src/zrtp_datatypes.c", - "./src/zrtp_engine.c", - "./src/zrtp_iface_scheduler.c", - "./src/zrtp_iface_sys.c", - "./src/zrtp_initiator.c", - "./src/zrtp_legal.c", - "./src/zrtp_list.c", - "./src/zrtp_log.c", - "./src/zrtp_pbx.c", - "./src/zrtp_protocol.c", - "./src/zrtp_responder.c", - "./src/zrtp_rng.c", - "./src/zrtp_srtp_builtin.c", - "./src/zrtp_srtp_dm.c", - "./src/zrtp_string.c", - "./src/zrtp_utils.c", - "./src/zrtp_utils_proto.c", - "./src/zrtp_crypto_ecdsa.c", - "./src/zrtp_crypto_ec.c", - "./src/zrtp_engine_driven.c", - "./src/zrtp_crypto_ecdh.c", - "./src/zrtp_iface_cache.c", - "./doc", - "./include", - "./include/zrtp.h", - "./include/zrtp_base.h", - "./include/zrtp_config.h", - "./include/zrtp_config_user.h", - "./include/zrtp_config_win.h", - "./include/zrtp_config_symbian.h", - "./include/zrtp_crypto.h", - "./include/zrtp_engine.h", - "./include/zrtp_error.h", - "./include/zrtp_ec.h", - "./include/zrtp_iface.h", - "./include/zrtp_iface_cache.h", - "./include/zrtp_iface_system.h", - "./include/zrtp_iface_scheduler.h", - "./include/zrtp_legal.h", - "./include/zrtp_list.h", - "./include/zrtp_log.h", - "./include/zrtp_pbx.h", - "./include/zrtp_protocol.h", - "./include/zrtp_srtp.h", - "./include/zrtp_srtp_builtin.h", - "./include/zrtp_string.h", - "./include/zrtp_types.h", - "./include/zrtp_version.h", - "./third_party", - "./third_party/bnlib", - "./third_party/bnlib/lbnmem.c", - "./third_party/bnlib/lbn00.c", - "./third_party/bnlib/bn16.c", - "./third_party/bnlib/bn32.c", - "./third_party/bnlib/bn.c", - "./third_party/bnlib/lbnppc.h", - "./third_party/bnlib/bnsize00.h", - "./third_party/bnlib/lbn32.h", - "./third_party/bnlib/lbn80386.h", - "./third_party/bnlib/lbn68020.h", - "./third_party/bnlib/germtest", - "./third_party/bnlib/jacobi.h", - "./third_party/bnlib/bn00.c", - "./third_party/bnlib/bnconfig.h", - "./third_party/bnlib/lbn8086.h", - "./third_party/bnlib/bntest00.c", - "./third_party/bnlib/germain.c", - "./third_party/bnlib/lbn960jx.h", - "./third_party/bnlib/sizetest.c", - "./third_party/bnlib/config.cache", - "./third_party/bnlib/bn68000.c", - "./third_party/bnlib/lbnalpha.h", - "./third_party/bnlib/cputime.h", - "./third_party/bnlib/legal.c", - "./third_party/bnlib/configure.lineno", - "./third_party/bnlib/configure", - "./third_party/bnlib/bnprint.c", - "./third_party/bnlib/bn8086.c", - "./third_party/bnlib/lbn68020.c", - "./third_party/bnlib/README.bntest", - "./third_party/bnlib/lbn8086.asm", - "./third_party/bnlib/lbn16.c", - "./third_party/bnlib/lbn32.c", - "./third_party/bnlib/legal.h", - "./third_party/bnlib/configure.in", - "./third_party/bnlib/lbn960jx.s", - "./third_party/bnlib/prime.h", - "./third_party/bnlib/bninit16.c", - "./third_party/bnlib/bninit32.c", - "./third_party/bnlib/files", - "./third_party/bnlib/ppcasm.h", - "./third_party/bnlib/lbn.h", - "./third_party/bnlib/README.bn", - "./third_party/bnlib/bnintern.doc", - "./third_party/bnlib/sieve.c", - "./third_party/bnlib/bn16.h", - "./third_party/bnlib/bn32.h", - "./third_party/bnlib/bnprint.h", - "./third_party/bnlib/sieve.h", - "./third_party/bnlib/cfg", - "./third_party/bnlib/lbn68000.h", - "./third_party/bnlib/lbnalpha.s", - "./third_party/bnlib/bntest16.c", - "./third_party/bnlib/bntest32.c", - "./third_party/bnlib/cfg.debug", - "./third_party/bnlib/lbnmem.h", - "./third_party/bnlib/germtest.c", - "./third_party/bnlib/prime.c", - "./third_party/bnlib/lbn68000.c", - "./third_party/bnlib/config.log", - "./third_party/bnlib/germain.h", - "./third_party/bnlib/kludge.h", - "./third_party/bnlib/Makefile.in", - "./third_party/bnlib/test", - "./third_party/bnlib/test/primetest.c", - "./third_party/bnlib/test/rsaglue.h", - "./third_party/bnlib/test/randpool.c", - "./third_party/bnlib/test/keys.c", - "./third_party/bnlib/test/primes.doc", - "./third_party/bnlib/test/rsatest.c", - "./third_party/bnlib/test/posix.h", - "./third_party/bnlib/test/legal.c", - "./third_party/bnlib/test/README.rsatest", - "./third_party/bnlib/test/rsaglue.c", - "./third_party/bnlib/test/kbmsdos.c", - "./third_party/bnlib/test/keygen.c", - "./third_party/bnlib/test/README.dsatest", - "./third_party/bnlib/test/types.h", - "./third_party/bnlib/test/random.c", - "./third_party/bnlib/test/md5.c", - "./third_party/bnlib/test/userio.h", - "./third_party/bnlib/test/md5.h", - "./third_party/bnlib/test/dsatest.c", - "./third_party/bnlib/test/pt.c", - "./third_party/bnlib/test/dhtest.c", - "./third_party/bnlib/test/sha.h", - "./third_party/bnlib/test/keygen.h", - "./third_party/bnlib/test/noise.h", - "./third_party/bnlib/test/first.h", - "./third_party/bnlib/test/README.dhtest", - "./third_party/bnlib/test/randtest.c", - "./third_party/bnlib/test/randpool.h", - "./third_party/bnlib/test/random.h", - "./third_party/bnlib/test/sha.c", - "./third_party/bnlib/test/noise.c", - "./third_party/bnlib/test/kbunix.c", - "./third_party/bnlib/test/kludge.h", - "./third_party/bnlib/test/keys.h", - "./third_party/bnlib/test/usuals.h", - "./third_party/bnlib/test/kb.h", - "./third_party/bnlib/CHANGES", - "./third_party/bnlib/bnconfig.hin", - "./third_party/bnlib/lbn80386.asm", - "./third_party/bnlib/jacobi.c", - "./third_party/bnlib/config.status", - "./third_party/bnlib/lbn16.h", - "./third_party/bnlib/lbn80386.s", - "./third_party/bnlib/lbn68360.s", - "./third_party/bnlib/bignum-ARM", - "./third_party/bnlib/bignum-ARM/lbnmem.c", - "./third_party/bnlib/bignum-ARM/sha256_core.s", - "./third_party/bnlib/bignum-ARM/lbnarm.h", - "./third_party/bnlib/bignum-ARM/config.h", - "./third_party/bnlib/bignum-ARM/cputime.h", - "./third_party/bnlib/bignum-ARM/lbn16.c", - "./third_party/bnlib/bignum-ARM/lbnarm.s", - "./third_party/bnlib/bignum-ARM/README-small-memory", - "./third_party/bnlib/bignum-ARM/sha256_arm.c", - "./third_party/bnlib/bignum-ARM/lbn.h", - "./third_party/bnlib/bignum-ARM/bntest16.c", - "./third_party/bnlib/bignum-ARM/lbnmem.h", - "./third_party/bnlib/bignum-ARM/kludge.h", - "./third_party/bnlib/bignum-ARM/lbn16.h", - "./third_party/bnlib/bn.doc", - "./third_party/bnlib/lbnppc.c", - "./third_party/bnlib/bn.h", - "./third_party/bgaes", - "./third_party/bgaes/sha1.h", - "./third_party/bgaes/sha1.c", - "./third_party/bgaes/brg_types.h", - "./third_party/bgaes/aestab.c", - "./third_party/bgaes/aestab.h", - "./third_party/bgaes/sha2.h", - "./third_party/bgaes/aes_modes.c", - "./third_party/bgaes/aescrypt.c", - "./third_party/bgaes/bg2zrtp.h", - "./third_party/bgaes/aeskey.c", - "./third_party/bgaes/sha2.c", - "./third_party/bgaes/aes.h", - "./third_party/bgaes/aesopt.h", - "./test", - "./test/README", - "./test/pc", - "./test/pc/zrtp_test_core.c", - "./test/pc/zrtp_test_core.h", - "./test/pc/zrtp_test_crypto.c", - "./test/pc/zrtp_test_queue.c", - "./test/pc/zrtp_test_queue.h", - "./test/pc/zrtp_test_ui.c", - "./test/win_ce", - "./test/win_ce/libzrtp_test_GUI.cpp", - "./test/win_ce/libzrtp_test_GUI.h", - "./test/win_ce/libzrtp_test_GUI.ico", - "./test/win_ce/libzrtp_test_GUIppc.rc", - "./test/win_ce/libzrtp_test_GUIppc.rc2", - "./test/win_ce/libzrtp_test_GUIsp.rc", - "./test/win_ce/libzrtp_test_GUIsp.rc2", - "./test/win_ce/ReadMe.txt", - "./test/win_ce/resourceppc.h", - "./test/win_ce/resourcesp.h", - "./test/win_ce/stdafx.cpp", - "./test/win_ce/stdafx.h", - "./doc", - "./doc/img", - "./doc/manuals", - "./doc/manuals/howto.dox", - "./doc/manuals/main.dox", - "./doc/manuals/rng.dox", - "./doc/out", - "./doc/out/html", - "./doc/out/html/zfone.jpg", - "./doc/Doxyfile", - "./doc/doxygen.css", - "./doc/footer.html", - "./doc/header.html" - ) -} diff --git a/libs/libzrtp/doc/Doxyfile.in b/libs/libzrtp/doc/Doxyfile.in deleted file mode 100644 index ae1f390756..0000000000 --- a/libs/libzrtp/doc/Doxyfile.in +++ /dev/null @@ -1,1813 +0,0 @@ -# Doxyfile 1.8.0 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project. -# -# All text after a hash (#) is considered a comment and will be ignored. -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" "). - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all -# text before the first occurrence of this tag. Doxygen uses libiconv (or the -# iconv built into libc) for the transcoding. See -# http://www.gnu.org/software/libiconv for the list of possible encodings. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or sequence of words) that should -# identify the project. Note that if you do not use Doxywizard you need -# to put quotes around the project name if it contains spaces. - -PROJECT_NAME = @PACKAGE_NAME@ - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = @PACKAGE_VERSION@ - -# Using the PROJECT_BRIEF tag one can provide an optional one line description -# for a project that appears at the top of each page and should give viewer -# a quick idea about the purpose of the project. Keep the description short. - -PROJECT_BRIEF = "ZRTP VoIP security" - -# With the PROJECT_LOGO tag one can specify an logo or icon that is -# included in the documentation. The maximum height of the logo should not -# exceed 55 pixels and the maximum width should not exceed 200 pixels. -# Doxygen will copy the logo to the output directory. - -PROJECT_LOGO = - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = @top_srcdir@/doc/out - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would -# otherwise cause performance problems for the file system. - -CREATE_SUBDIRS = NO - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, -# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English -# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, -# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, -# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" - -ABBREVIATE_BRIEF = - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = YES - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful if your file system -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like regular Qt-style comments -# (thus requiring an explicit @brief command for a brief description.) - -JAVADOC_AUTOBRIEF = NO - -# If the QT_AUTOBRIEF tag is set to YES then Doxygen will -# interpret the first line (until the first dot) of a Qt-style -# comment as the brief description. If set to NO, the comments -# will behave just like regular Qt-style comments (thus requiring -# an explicit \brief command for a brief description.) - -QT_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 4 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# This tag can be used to specify a number of word-keyword mappings (TCL only). -# A mapping has the form "name=value". For example adding -# "class=itcl::class" will allow you to use the command class in the -# itcl::class meaning. - -TCL_SUBST = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = YES - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for -# Java. For instance, namespaces will be presented as packages, qualified -# scopes will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources only. Doxygen will then generate output that is more tailored for -# Fortran. - -OPTIMIZE_FOR_FORTRAN = NO - -# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for -# VHDL. - -OPTIMIZE_OUTPUT_VHDL = NO - -# Doxygen selects the parser to use depending on the extension of the files it -# parses. With this tag you can assign which parser to use for a given extension. -# Doxygen has a built-in mapping, but you can override or extend it using this -# tag. The format is ext=language, where ext is a file extension, and language -# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, -# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make -# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C -# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions -# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. - -EXTENSION_MAPPING = - -# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all -# comments according to the Markdown format, which allows for more readable -# documentation. See http://daringfireball.net/projects/markdown/ for details. -# The output of markdown processing is further processed by doxygen, so you -# can mix doxygen, HTML, and XML commands with Markdown formatting. -# Disable only in case of backward compatibilities issues. - -MARKDOWN_SUPPORT = YES - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also makes the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. - -BUILTIN_STL_SUPPORT = NO - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. - -CPP_CLI_SUPPORT = NO - -# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. -# Doxygen will parse them like normal C++ but will assume all classes use public -# instead of private inheritance when no explicit protection keyword is present. - -SIP_SUPPORT = NO - -# For Microsoft's IDL there are propget and propput attributes to indicate getter -# and setter methods for a property. Setting this option to YES (the default) -# will make doxygen replace the get and set methods by a property in the -# documentation. This will only work if the methods are indeed getting or -# setting a simple type. If this is not the case, or you want to show the -# methods anyway, you should set this option to NO. - -IDL_PROPERTY_SUPPORT = YES - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and -# unions are shown inside the group in which they are included (e.g. using -# @ingroup) instead of on a separate page (for HTML and Man pages) or -# section (for LaTeX and RTF). - -INLINE_GROUPED_CLASSES = NO - -# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and -# unions with only public data fields will be shown inline in the documentation -# of the scope in which they are defined (i.e. file, namespace, or group -# documentation), provided this scope is documented. If set to NO (the default), -# structs, classes, and unions are shown on a separate page (for HTML and Man -# pages) or section (for LaTeX and RTF). - -INLINE_SIMPLE_STRUCTS = NO - -# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum -# is documented as struct, union, or enum with the name of the typedef. So -# typedef struct TypeS {} TypeT, will appear in the documentation as a struct -# with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically -# be useful for C code in case the coding convention dictates that all compound -# types are typedef'ed and only the typedef is referenced, never the tag name. - -TYPEDEF_HIDES_STRUCT = NO - -# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to -# determine which symbols to keep in memory and which to flush to disk. -# When the cache is full, less often used symbols will be written to disk. -# For small to medium size projects (<1000 input files) the default value is -# probably good enough. For larger projects a too small cache size can cause -# doxygen to be busy swapping symbols to and from disk most of the time -# causing a significant performance penalty. -# If the system has enough physical memory increasing the cache will improve the -# performance by keeping more symbols in memory. Note that the value works on -# a logarithmic scale so increasing the size by one will roughly double the -# memory usage. The cache size is given by this formula: -# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, -# corresponding to a cache size of 2^16 = 65536 symbols. - -SYMBOL_CACHE_SIZE = 0 - -# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be -# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given -# their name and scope. Since this can be an expensive process and often the -# same symbol appear multiple times in the code, doxygen keeps a cache of -# pre-resolved symbols. If the cache is too small doxygen will become slower. -# If the cache is too large, memory is wasted. The cache size is given by this -# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, -# corresponding to a cache size of 2^16 = 65536 symbols. - -LOOKUP_CACHE_SIZE = 0 - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = NO - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal scope will be included in the documentation. - -EXTRACT_PACKAGE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = NO - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = NO - -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base -# name of the file that contains the anonymous namespace. By default -# anonymous namespaces are hidden. - -EXTRACT_ANON_NSPACES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. - -CASE_SENSE_NAMES = NO - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = YES - -# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen -# will list include files with double quotes in the documentation -# rather than with sharp brackets. - -FORCE_LOCAL_INCLUDES = NO - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - -SORT_BRIEF_DOCS = NO - -# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen -# will sort the (brief and detailed) documentation of class members so that -# constructors and destructors are listed first. If set to NO (the default) -# the constructors will appear in the respective orders defined by -# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. -# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO -# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. - -SORT_MEMBERS_CTORS_1ST = NO - -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the -# hierarchy of group names into alphabetical order. If set to NO (the default) -# the group names will appear in their defined order. - -SORT_GROUP_NAMES = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - -SORT_BY_SCOPE_NAME = NO - -# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to -# do proper type resolution of all parameters of a function it will reject a -# match between the prototype and the implementation of a member function even -# if there is only one candidate or it is obvious which candidate to choose -# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen -# will still accept a match between prototype and implementation in such cases. - -STRICT_PROTO_MATCHING = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or macro consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and macros in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy -# in the documentation. The default is NO. - -SHOW_DIRECTORIES = NO - -# Set the SHOW_FILES tag to NO to disable the generation of the Files page. -# This will remove the Files entry from the Quick Index and from the -# Folder Tree View (if specified). The default is YES. - -SHOW_FILES = YES - -# Set the SHOW_NAMESPACES tag to NO to disable the generation of the -# Namespaces page. -# This will remove the Namespaces entry from the Quick Index -# and from the Folder Tree View (if specified). The default is YES. - -SHOW_NAMESPACES = YES - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from -# the version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output -# is used as the file version. See the manual for examples. - -FILE_VERSION_FILTER = - -# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed -# by doxygen. The layout file controls the global structure of the generated -# output files in an output format independent way. The create the layout file -# that represents doxygen's defaults, run doxygen with the -l option. -# You can optionally specify a file name after the option, if omitted -# DoxygenLayout.xml will be used as the name of the layout file. - -LAYOUT_FILE = - -# The CITE_BIB_FILES tag can be used to specify one or more bib files -# containing the references data. This must be a list of .bib files. The -# .bib extension is automatically appended if omitted. Using this command -# requires the bibtex tool to be installed. See also -# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style -# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this -# feature you need bibtex and perl available in the search path. - -CITE_BIB_FILES = - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# The WARN_NO_PARAMDOC option can be enabled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. - -WARN_NO_PARAMDOC = NO - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = @top_srcdir@ -INPUT = @top_srcdir@/doc/manuals/main.dox \ - @top_srcdir@/doc/manuals/howto.dox \ - @top_srcdir@/doc/manuals/changelog.dox \ - @top_srcdir@/doc/manuals/rng.dox \ - @top_srcdir@/include/zrtp_config_user.h \ - @top_srcdir@/include/zrtp.h \ - @top_srcdir@/include/zrtp_iface_system.h \ - @top_srcdir@/include/zrtp_iface.h \ - @top_srcdir@/include/zrtp_error.h \ - @top_srcdir@/include/zrtp_types.h \ - @top_srcdir@/include/zrtp_string.h \ - @top_srcdir@/include/zrtp_pbx.h - - -# This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is -# also the default input encoding. Doxygen uses libiconv (or the iconv built -# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for -# the list of possible encodings. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh -# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py -# *.f90 *.f *.for *.vhd *.vhdl - -FILE_PATTERNS = - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = NO - -# The EXCLUDE tag can be used to specify files and/or directories that should be -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. -# Note that relative paths are relative to the directory from which doxygen is -# run. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or -# directories that are symbolic links (a Unix file system feature) are excluded -# from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* - -EXCLUDE_PATTERNS = - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the -# output. The symbol name can be a fully qualified name, a word, or if the -# wildcard * is used, a substring. Examples: ANamespace, AClass, -# AClass::ANamespace, ANamespace::*Test - -EXCLUDE_SYMBOLS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. -# If FILTER_PATTERNS is specified, this tag will be -# ignored. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. -# Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. -# The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty or if -# non of the patterns match the file name, INPUT_FILTER is applied. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file -# pattern. A pattern will override the setting for FILTER_PATTERN (if any) -# and it is also possible to disable source filtering for a specific pattern -# using *.ext= (so without naming a filter). This option only has effect when -# FILTER_SOURCE_FILES is enabled. - -FILTER_SOURCE_PATTERNS = - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = NO - -# If the REFERENCES_RELATION tag is set to YES -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = NO - -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. -# Otherwise they will link to the documentation. - -REFERENCES_LINK_SOURCE = YES - -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = YES - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. Note that when using a custom header you are responsible -# for the proper inclusion of any scripts and style sheets that doxygen -# needs, which is dependent on the configuration options used. -# It is advised to generate a default header using "doxygen -w html -# header.html footer.html stylesheet.css YourConfigFile" and then modify -# that header. Note that the header is subject to change so you typically -# have to redo this when upgrading to a newer version of doxygen or when -# changing the value of configuration settings such as GENERATE_TREEVIEW! - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# style sheet in the HTML output directory as well, or it will be erased! - -HTML_STYLESHEET = - -# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or -# other source files which should be copied to the HTML output directory. Note -# that these files will be copied to the base HTML output directory. Use the -# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these -# files. In the HTML_STYLESHEET file, use the file name only. Also note that -# the files will be copied as-is; there are no commands or markers available. - -HTML_EXTRA_FILES = - -# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. -# Doxygen will adjust the colors in the style sheet and background images -# according to this color. Hue is specified as an angle on a colorwheel, -# see http://en.wikipedia.org/wiki/Hue for more information. -# For instance the value 0 represents red, 60 is yellow, 120 is green, -# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. -# The allowed range is 0 to 359. - -HTML_COLORSTYLE_HUE = 220 - -# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of -# the colors in the HTML output. For a value of 0 the output will use -# grayscales only. A value of 255 will produce the most vivid colors. - -HTML_COLORSTYLE_SAT = 100 - -# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to -# the luminance component of the colors in the HTML output. Values below -# 100 gradually make the output lighter, whereas values above 100 make -# the output darker. The value divided by 100 is the actual gamma applied, -# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, -# and 100 does not change the gamma. - -HTML_COLORSTYLE_GAMMA = 80 - -# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML -# page will contain the date and time when the page was generated. Setting -# this to NO can help when comparing the output of multiple runs. - -HTML_TIMESTAMP = YES - -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. For this to work a browser that supports -# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox -# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). - -HTML_DYNAMIC_SECTIONS = NO - -# If the GENERATE_DOCSET tag is set to YES, additional index files -# will be generated that can be used as input for Apple's Xcode 3 -# integrated development environment, introduced with OSX 10.5 (Leopard). -# To create a documentation set, doxygen will generate a Makefile in the -# HTML output directory. Running make will produce the docset in that -# directory and running "make install" will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find -# it at startup. -# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html -# for more information. - -GENERATE_DOCSET = NO - -# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the -# feed. A documentation feed provides an umbrella under which multiple -# documentation sets from a single provider (such as a company or product suite) -# can be grouped. - -DOCSET_FEEDNAME = "Doxygen generated docs" - -# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that -# should uniquely identify the documentation set bundle. This should be a -# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen -# will append .docset to the name. - -DOCSET_BUNDLE_ID = org.doxygen.Project - -# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify -# the documentation publisher. This should be a reverse domain-name style -# string, e.g. com.mycompany.MyDocSet.documentation. - -DOCSET_PUBLISHER_ID = org.doxygen.Publisher - -# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. - -DOCSET_PUBLISHER_NAME = Publisher - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING -# is used to encode HtmlHelp index (hhk), content (hhc) and project file -# content. - -CHM_INDEX_ENCODING = - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = NO - -# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and -# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated -# that can be used as input for Qt's qhelpgenerator to generate a -# Qt Compressed Help (.qch) of the generated HTML documentation. - -GENERATE_QHP = NO - -# If the QHG_LOCATION tag is specified, the QCH_FILE tag can -# be used to specify the file name of the resulting .qch file. -# The path specified is relative to the HTML output folder. - -QCH_FILE = - -# The QHP_NAMESPACE tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#namespace - -QHP_NAMESPACE = org.doxygen.Project - -# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#virtual-folders - -QHP_VIRTUAL_FOLDER = doc - -# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to -# add. For more information please see -# http://doc.trolltech.com/qthelpproject.html#custom-filters - -QHP_CUST_FILTER_NAME = - -# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the -# custom filter to add. For more information please see -# -# Qt Help Project / Custom Filters. - -QHP_CUST_FILTER_ATTRS = - -# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this -# project's -# filter section matches. -# -# Qt Help Project / Filter Attributes. - -QHP_SECT_FILTER_ATTRS = - -# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can -# be used to specify the location of Qt's qhelpgenerator. -# If non-empty doxygen will try to run qhelpgenerator on the generated -# .qhp file. - -QHG_LOCATION = - -# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files -# will be generated, which together with the HTML files, form an Eclipse help -# plugin. To install this plugin and make it available under the help contents -# menu in Eclipse, the contents of the directory containing the HTML and XML -# files needs to be copied into the plugins directory of eclipse. The name of -# the directory within the plugins directory should be the same as -# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before -# the help appears. - -GENERATE_ECLIPSEHELP = NO - -# A unique identifier for the eclipse help plugin. When installing the plugin -# the directory name containing the HTML and XML files should also have -# this name. - -ECLIPSE_DOC_ID = org.doxygen.Project - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) -# at top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. Since the tabs have the same information as the -# navigation tree you can set this option to NO if you already set -# GENERATE_TREEVIEW to YES. - -DISABLE_INDEX = NO - -# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index -# structure should be generated to display hierarchical information. -# If the tag value is set to YES, a side panel will be generated -# containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). -# Windows users are probably better off using the HTML help feature. -# Since the tree basically has the same information as the tab index you -# could consider to set DISABLE_INDEX to NO when enabling this option. - -GENERATE_TREEVIEW = NO - -# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values -# (range [0,1..20]) that doxygen will group on one line in the generated HTML -# documentation. Note that a value of 0 will completely suppress the enum -# values from appearing in the overview section. - -ENUM_VALUES_PER_LINE = 4 - -# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, -# and Class Hierarchy pages using a tree view instead of an ordered list. - -USE_INLINE_TREES = NO - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open -# links to external symbols imported via tag files in a separate window. - -EXT_LINKS_IN_WINDOW = NO - -# Use this tag to change the font size of Latex formulas included -# as images in the HTML documentation. The default is 10. Note that -# when you change the font size after a successful doxygen run you need -# to manually remove any form_*.png images from the HTML output directory -# to force them to be regenerated. - -FORMULA_FONTSIZE = 10 - -# Use the FORMULA_TRANPARENT tag to determine whether or not the images -# generated for formulas are transparent PNGs. Transparent PNGs are -# not supported properly for IE 6.0, but are supported on all modern browsers. -# Note that when changing this option you need to delete any form_*.png files -# in the HTML output before the changes have effect. - -FORMULA_TRANSPARENT = YES - -# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax -# (see http://www.mathjax.org) which uses client side Javascript for the -# rendering instead of using prerendered bitmaps. Use this if you do not -# have LaTeX installed or if you want to formulas look prettier in the HTML -# output. When enabled you may also need to install MathJax separately and -# configure the path to it using the MATHJAX_RELPATH option. - -USE_MATHJAX = NO - -# When MathJax is enabled you need to specify the location relative to the -# HTML output directory using the MATHJAX_RELPATH option. The destination -# directory should contain the MathJax.js script. For instance, if the mathjax -# directory is located at the same level as the HTML output directory, then -# MATHJAX_RELPATH should be ../mathjax. The default value points to -# the MathJax Content Delivery Network so you can quickly see the result without -# installing MathJax. -# However, it is strongly recommended to install a local -# copy of MathJax from http://www.mathjax.org before deployment. - -MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest - -# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension -# names that should be enabled during MathJax rendering. - -MATHJAX_EXTENSIONS = - -# When the SEARCHENGINE tag is enabled doxygen will generate a search box -# for the HTML output. The underlying search engine uses javascript -# and DHTML and should work on any modern browser. Note that when using -# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets -# (GENERATE_DOCSET) there is already a search function so this one should -# typically be disabled. For large projects the javascript based search engine -# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. - -SEARCHENGINE = YES - -# When the SERVER_BASED_SEARCH tag is enabled the search engine will be -# implemented using a PHP enabled web server instead of at the web client -# using Javascript. Doxygen will generate the search PHP script and index -# file to put on the web server. The advantage of the server -# based approach is that it scales better to large projects and allows -# full text search. The disadvantages are that it is more difficult to setup -# and does not have live searching capabilities. - -SERVER_BASED_SEARCH = NO - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = NO - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. -# Note that when enabling USE_PDFLATEX this option is only used for -# generating bitmaps for formulas in the HTML output, but not in the -# Makefile that is written to the output directory. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4 - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for -# the generated latex document. The footer should contain everything after -# the last chapter. If it is left blank doxygen will generate a -# standard footer. Notice: only use this tag if you know what you are doing! - -LATEX_FOOTER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = YES - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = YES - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -# If LATEX_SOURCE_CODE is set to YES then doxygen will include -# source code with syntax highlighting in the LaTeX output. -# Note that which sources are shown also depends on other settings -# such as SOURCE_BROWSER. - -LATEX_SOURCE_CODE = NO - -# The LATEX_BIB_STYLE tag can be used to specify the style to use for the -# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See -# http://en.wikipedia.org/wiki/BibTeX for more info. - -LATEX_BIB_STYLE = plain - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load style sheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = YES - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. -# This is useful -# if you want to understand what is going on. -# On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = NO - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_DEFINED tags. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# pointed to by INCLUDE_PATH will be searched when a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator -# instead of the = operator. - -PREDEFINED = - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition that -# overrules the definition found in the source code. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all references to function-like macros -# that are alone on a line, have an all uppercase name, and do not end with a -# semicolon, because these will confuse the parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. For each -# tag file the location of the external documentation should be added. The -# format of a tag file without this location is as follows: -# -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths -# or URLs. Note that each tag file must have a unique name (where the name does -# NOT include the path). If a tag file is not located in the directory in which -# doxygen is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option also works with HAVE_DOT disabled, but it is recommended to -# install and use dot, since it yields more powerful graphs. - -CLASS_DIAGRAMS = YES - -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see -# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the -# documentation. The MSCGEN_PATH tag allows you to specify the directory where -# the mscgen tool resides. If left empty the tool is assumed to be found in the -# default search path. - -MSCGEN_PATH = - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = NO - -# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is -# allowed to run in parallel. When set to 0 (the default) doxygen will -# base this on the number of processors available in the system. You can set it -# explicitly to a value larger than 0 to get control over the balance -# between CPU load and processing speed. - -DOT_NUM_THREADS = 0 - -# By default doxygen will use the Helvetica font for all dot files that -# doxygen generates. When you want a differently looking font you can specify -# the font name using DOT_FONTNAME. You need to make sure dot is able to find -# the font, which can be done by putting it in a standard location or by setting -# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the -# directory containing the font. - -DOT_FONTNAME = Helvetica - -# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. -# The default size is 10pt. - -DOT_FONTSIZE = 10 - -# By default doxygen will tell dot to use the Helvetica font. -# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to -# set the path where dot can find it. - -DOT_FONTPATH = - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for groups, showing the direct groups dependencies - -GROUP_GRAPHS = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If the UML_LOOK tag is enabled, the fields and methods are shown inside -# the class node. If there are many fields or methods and many nodes the -# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS -# threshold limits the number of items for each type to make the size more -# managable. Set this to 0 for no limit. Note that the threshold may be -# exceeded by 50% before the limit is enforced. - -UML_LIMIT_NUM_FIELDS = 10 - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH and HAVE_DOT options are set to YES then -# doxygen will generate a call dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable call graphs -# for selected functions only using the \callgraph command. - -CALL_GRAPH = NO - -# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then -# doxygen will generate a caller dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable caller -# graphs for selected functions only using the \callergraph command. - -CALLER_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will generate a graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include -# relations between the files in the directories. - -DIRECTORY_GRAPH = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are svg, png, jpg, or gif. -# If left blank png will be used. If you choose svg you need to set -# HTML_FILE_EXTENSION to xhtml in order to make the SVG files -# visible in IE 9+ (other browsers do not have this requirement). - -DOT_IMAGE_FORMAT = png - -# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to -# enable generation of interactive SVG images that allow zooming and panning. -# Note that this requires a modern browser other than Internet Explorer. -# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you -# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files -# visible. Older versions of IE do not have SVG support. - -INTERACTIVE_SVG = NO - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found in the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The MSCFILE_DIRS tag can be used to specify one or more directories that -# contain msc files that are included in the documentation (see the -# \mscfile command). - -MSCFILE_DIRS = - -# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen if the -# number of direct children of the root node in a graph is already larger than -# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note -# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. - -DOT_GRAPH_MAX_NODES = 50 - -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes -# that lay further from the root node will be omitted. Note that setting this -# option to 1 or 2 may greatly reduce the computation time needed for large -# code bases. Also note that the size of a graph can be further restricted by -# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. - -MAX_DOT_GRAPH_DEPTH = 0 - -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, because dot on Windows does not -# seem to support this out of the box. Warning: Depending on the platform used, -# enabling this option may lead to badly anti-aliased labels on the edges of -# a graph (i.e. they become hard to read). - -DOT_TRANSPARENT = NO - -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) -# support this, this feature is disabled by default. - -DOT_MULTI_TARGETS = NO - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES diff --git a/libs/libzrtp/doc/manuals/changelog.dox b/libs/libzrtp/doc/manuals/changelog.dox deleted file mode 100644 index 42fdae34d0..0000000000 --- a/libs/libzrtp/doc/manuals/changelog.dox +++ /dev/null @@ -1,223 +0,0 @@ -# -# Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. -# Contact: http://philzimmermann.com -# For licensing and other legal details, see the file zrtp_legal.c. -# -# Viktor Krykun - -/** - * \file changelog.dox - * \brief libzrtp ChangeLog - */ - -/*! -\page changelog ChangeLog - -**************************************************************************************************** -\section v120 libzrtp v1.20 build XXX (ZRTP RFC 6189, protocol 1.1) -**************************************************************************************************** - -This release is focused on better ZRTP cache management. - -***\subsection v120_changes API changes and Upgrade Instructions: - *- Starting from v120 libzrtp uses global ZID for all outgoing connections. Local ZID should be - specified in zrtp_global_t#zid and provided to zrtp_init(). App doesn't need to pass local ZID - each time it creates new session via zrtp_session_init(). - *- Added zrtp_randstr2() which allow to generate random string before libzrtp being initialized. - Can be handy to generate initial ZID. In normal circumstances, use zrtp_randstr() whenever possible. - *- ZRTP cache API was completely redesigned. Look at zrtp_cache.h for more details. - - -***\subsection v120_feature New features and improvements. - *- new better cache management API. - -***\subsection v120_bugs Bug fixes - *- fixed bug when ZRTP forces enrolled endpoints to re-render SAS when sashash is empty. - *- other minor bug fixes and improvements - *- fixed bug when zrtp_signaling_hash_set() silently not accepted imported zrtp-hash-value with - "buffer too small" debug output. - - -**************************************************************************************************** -\section v091 DEVELOPERS BUILD Release Notes - libzrtp - Version 0.91 build XXX (ZRTP ID v16x, protocol 1.X) -**************************************************************************************************** -\note To build Libzrtp Enterprise with Elliptic Cure Diffie-Hellman support on Unix platform, use - "./configure --enable-enterprise". By default libzrtp will be build with no ECDH support. - -
    -***\subsection v091_feature New features and improvements. - -***\subsection v091_bugs Bug fixes - *- [LZRTP-179] Fixed bug in build scripts when commercial version of libzrtp v0.90 was built - with ZRTP_ENABLE_EC set to 1 by default. - *- [LZRTP-181] Fixed zrtp_init() crash on Mac OSX 10.6 - *- [LZRTP-182] Fixed libzrtp build issue on Free-BSD - - -**************************************************************************************************** -\section v090 Release Notes - libzrtp - Version 0.90 build 577 (ZRTP ID v15x, protocol 1.1) -**************************************************************************************************** -
    -***\subsection v090_feature New features and improvements. - *- [LZRTP-178] After the cache mismatch don't update the cache automatically, wait for the SAS verification. More details at this feature could be found in ZRTP ID section 4.6.1.1 - *- [LZRTP-151] Add secrets flags to \ref zrtp_info_t to allow user monitor secrets state - *- [LZRTP-169] Check and optimize build process on Windows mingw and msys. - -***\subsection v090_bugs Bug fixes - *- [LZRTP-176] Added -fPIC flag to Linux and Mac builds to be able to link the library into 64bit applications. - *- [LZRTP-175] Change SHA1 definition name to SRTP_SHA1 and move to private part of the API to eliminate ambiguity. - *- [LZRTP-155] Session info should display current, updated value of the TTL, not the old one from previous negotiation. - *- [LZRTP-177] Diffie-Hellman secret exponent for DH2K should be 256bits instead of 128. - - -**************************************************************************************************** -\section v082 Release Notes - libzrtp - Version 0.82 build 540 (ZRTP ID v15, protocol 1.1) -**************************************************************************************************** -
    -Minor improvements. Zfone and libZRTP projects moved to public bug-tracking and wiki system. - -***\subsection v082_feature New features and improvements. - *- Improved libzrtp resistance to long delays during DH calculations on slow hardware. - *- Structures Members alignment in Microsoft Visual Studio projects was changed from 1 byte to "Default". - *- Implemented entropy collection from dropped RTP messages. Don't forget to store RNG seed when you done with libzrtp and upload it agan on next session. - *- Implement default entropy collector for Win32 platform. RtlGenRandom() system call is used. Together with the entropy collection from dropped RTP message, it should guaranty good enough entropy. - *- zrtp_def_cache_reset_since() was implemented as call-back, similar to the rest of ZRTP cache interfaces. - *- Eliminated secure logs from the public build. - *- Public bug-tracker and wiki launched (in addition to our internal tools) - *- libzrtp API documentation is available at developers.zfoneproject.com - - -**************************************************************************************************** -\section v081 Release Notes - libzrtp - Version 0.81 build 514 (ZRTP ID v15, protocol 1.1) -**************************************************************************************************** -
    -***\subsection v081_bugs Bug - *- [LZRTP-161] Improvement in ZRTP state-machine\n - libzrtp state-machine didn't process incoming Hello message in StartInitiatingSecure state. - In some situations this issue could cause libzrtp not responding on incoming HELLO messages and freeze the protocol. - - *- [LZRTP-166] Fixed "Secure Since" logic.\n - Previous version of libzrtp computed secure since in a wrong way. libzrtp 0.81 remembers secure since date when new RS1 secret is generated and keep it unchanged while RS secrets are matched for all next calls. - \n - Use zrtp_def_cache_get_since() to get secure since for the particular pair of ZIDs. - \warning Secure since function is available for the build-in implementation of ZRTP cache. - -***\subsection v081_feature New Feature - *- [LZRTP-157] Implement algorithms negotiation according to ZRTP ID v15 section 4.1.2\n - This method is provided to allow the two parties to mutually and deterministically choose the same DH key size and algorithm before a Commit message is sent. No API changes required. - - *- [LZRTP-158] Zfone Ping response implemented.\n - New Zfone3 software uses specific VoIp calls detection algorithms and uses ZRTP Ping to discover the call topology. Each ZRTP endpoint may response with PingAck to be compatible with Zfone3. libzrtp based products don't need to do anything more to support Zfone3. The library handles this automatically. Ping-Response doesn't affect res of ZRTP logic. - \n - \sa Check ZRTP RFC sec 5.16 for more information. - -***\subsection v081_improv Improvement - *- [LZRTP-164] New ZRTP security event was added.\n - Libzrtp rises special event when after switching to secure state, the secrets are not expired, cached, but don't match. In other words: it is typical condition for the MitM attacks. Developer should use this event to notify user about the situation. Check zrtp_security_event_t#ZRTP_EVENT_MITM_WARNING for more detail information. - - *- [LZRTP-153] New Project files to build libzrtp on Windows CE.\n - Check ./projects/win_ce directory to find appropriate Microsoft Visual Studio projects. - - - -**************************************************************************************************** -\section v080 Release Notes - libzrtp - Version 0.80 -**************************************************************************************************** -
    -***\subsection v080_bugs Bug - - [LZRTP-97] zrtp_hex2str and zrtp_st2hex don't work correct.\n - Fixed bug in str2hex() providing wrong converting. Previous versions of libzrtp were affect, - but str2hex wasn't used in crypto logic and there was no security weakness. - - [LZRTP-154] zrtp_register_with_trusted_mitm() on storing MiTM secret didn't set the "matches" flag for ZRTP_BIT_PBX. In result, zrtp_is_user_enrolled() returned false right after ZRTP_STATE_SECURE event. This issue affected ZRTP MitM endpoints only and for the very first enrollment stream with the endpoint. In all next calls with the endpoint zrtp_is_user_enrolled() worked correct. - -***\subsection v080_improv Improvement - *- [LZRTP-26] Refactoring in the test-unite\n - Test-unite was redesigned: platform independent test-core and UI parts, specific for every - target platform. test-core has cleaner API and internal structure. UI part allow to simplify - application and separate business logic from UI routine. - - *- [LZRTP-46] Change zrtp_time_t to literal integer type.\n - zrtp_tim_now() just returns current time in milliseconds instead of zrtp_time_t structure. - - *- [LZRTP-83] Refactoring in libzrtp debug logging.\n - Made logs easy to read and analyze. Used indention. - - *- [LZRTP-84] Refactoring in libzrtp terms.\n - Following changes in functions names and data structures were made: - zrtp_stream_ctx_t - zrtp_stream_t\n - zrtp_conn_ctx_t - zrtp_session_t\n - zrtp_global_ctx_t - zrtp_global_t\n - (in zrtp.h more explicitly reflect meaning of data types)\n - \n - ZSTR_GET_VALUE/P - ZRTP_GV/P\n - SET_EMPTY_ZRTP_STRING - ZSTR_SET_EMPTY\n - (in zrtp_string.h just cleaner and shorter names)\n - \n - zrtp_init() (Allocates memory)\n - zrtp_init_session_ctx() - zrtp_session_init(). (Allocates memory)\n - zrtp_add_entropy() - zrtp_entropy_add() \n - zrtp_secure_stream() - zrtp_stream_secure()\n - zrtp_clear_stream() - zrtp_stream_clear()\n - zrtp_done_session_ctx - zrtp_session_down()\n - zrtp_attach_stream - zrtp_stream_attach()\n - zrtp_start_stream() - zrtp_stream_start()\n - zrtp_stop_stream() - zrtp_stream_stop()\n - zrtp_set_verified - zrtp_verified_set()\n - zrtp_check_profile - zrtp_profile_check()\n - (in zrtp.h used following approach: zrtp prefix; module name; action name) - - *- [LZRTP-85] Hide private fields in zrtp_session_ctx and zrtp_stream_ctx.\n - zrtp_stream_t and zrtp_session_t structures were hidden inside libzrtp internal data-types. General libzrtp-based application shouldn't use these structures directly. zrtp_stream_info_t and zrtp_session_info_t structures should be used instead. To implement data encapsulation, libzrtp provides following functions: - zrtp_stream_get(), zrtp_session_get()\n - zrtp_stream_set_userdata(), zrtp_stream_get_userdata()\n - zrtp_session_set_userdata(), zrtp_session_get_userdata()\n - \n - Advanced zrtp products may access zrtp_stream_t and zrtp_session_t directly but implementer can avoid this in most of the cases. - - *- [LZRTP-88] Create a macro for UNALIGNED constructions on mobile platforms.\n - - *- [LZRTP-89] Code style for crypto components sources.\n - Public API not affected. Internal changes: - - more compact code because fo using more general crypto functions - - code stayle and comments - - test-vectors were moved inside c-files fof appropriate crypto components. - - *- [LZRTP-99] zrtp_session_init should allocate memory for zrtp_session_t.\n - - *- [LZRTP-112] Modify zrtp logger to be able write \\n and NON \\n logs.\n - ZRTP_LOG by default doesn't add \\n at the end of the log string. ZRTP_LOGC print plain log message without header and any formatting. - - *- [LZRTP-116] Review synchronization objects in libzrtp.\n - - zrtp_global_t#comp_protector was removed. This mutex protected crypto components list. Since v0.80 libzrtp doesn't allow users to manage list of crypto components. libzrtp loads all available components at zrtp_init() and destroys them on zrtp_down(). Any modification with the list performed between these two call - don't need mutex. - - zrtp_secrets_t#protector was removed, just unused in the code - - zrtp_global_t#cache_protector was removed. Third-party ZRTP cache implementation should be thread-safe. It was made because it is simpler and more flexible solution. - - *- [LZRTP-120] Add file with version number to identify builds.\n - zrtp_version.h have been added to the project. - - *- [LZRTP-128] Eliminate Sound event from libzrtp.\n - zrtp_callback_misc_t::on_sound_event() was eliminated. This message was originally deigned for early versions of ZFone project. Event is supernumerary and duplicated other protocol and security events. Users, who need such event may perform the same actions using zrtp_callback_event_t events. - - *- [LZRTP-133] Move ssrc parameter from stream_create() to stream_start()\n - SSRC parameter was moved from zrtp_stream_attach() to zrtp_stream_start(). Such improvement should allow users to create zrtp streams before media starts and ssrc is unknown. It may be useful for proxy products: ZFone, UM-Lab software and other. - - *- [LZRTP-143] Speedup DH key exchange procedure.\n - DH crypto context data was moved directly to zrtp_stream_t and statically allocated. On creating protocol routine, libzrtp checks is DH context have been already initialized with the same type of key exchange scheme. If so - new DH value will not be recalculated. - -***\subsection v080_feature New Feature - - [LZRTP-14] Add DH2K public key exchange scheme\n - DH2K public key exchange scheme was implemented and available for developers the same way as rest of crypto components. - -***\subsection v080_tasks Task - *- [LZRTP-24] Implement Self-tests for DH and ECDH components.\n - Test cases for DH components were implemented and added to the libzrtp test-unite routine. DH checks algorithm correctness and performance as well. Besides test-vectors, it emulates DH exchange computing public and secret values for both endpoints. - - *- [LZRTP-122] Print out all zrtp configuration settings and adjustments on initialization. - - *- [LZRTP-123] Create standard error codes and error text descriptions.\n - New functions zrtp_log_error2str() and zrtp_log_status2str() were added to convert status codes to text description. Some clean-up in zrtp_status_t was made, removed unused or ambiguous status codes. - - *- [LZRTP-132] Replace HMAC with KDF function call.\n - Since ZRTP draft 12b defines ZRTP KDF to be in compliance with the recommendations in NIST SP 800-108. KDF function implemented as _zrtp_kdf() in zrtp_utils_proto.c. All KDF operations were replaced with from hmac to kdf function. - -*/ diff --git a/libs/libzrtp/doc/manuals/howto.dox b/libs/libzrtp/doc/manuals/howto.dox deleted file mode 100644 index 8792b6bed7..0000000000 --- a/libs/libzrtp/doc/manuals/howto.dox +++ /dev/null @@ -1,489 +0,0 @@ -# -# Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. -# Contact: http://philzimmermann.com -# For licensing and other legal details, see the file zrtp_legal.c. -# -# Viktor Krykun - - -/** - * \file howto.dox - * \brief How to Get Up and Running Quickly with libZRTP - */ - -/** -\page howto How to Get Up and Running Quickly with libZRTP - -**************************************************************************************************** -\section howto_about 1. About -**************************************************************************************************** -
    -The libzrtp library is a cross-platform implementation of ZRTP, a VoIP encryption protocol developed by Phil Zimmermann. libzrtp is suitable for inclusion in software VoIP clients, firmware for hardware VoIP phones, VoIP PBX servers, mobile VoIP clients, and SIP border control servers, enabling a VoIP application to interoperate and make secure calls with the rest of the ZRTP -community. - -The libzrtp library consists of three main components: the protocol module responsible for the safe connection of a call, the encryption module, and a set of interfaces. ZRTP works by assuming control of the VoIP traffic and initiating an encrypted connection between two ZRTP endpoints after a safe mode is achieved. To integrate the library, please review our documentation on the -ZRTP interfaces, connections management, and integration plan. - - -**************************************************************************************************** -\section howto_quick 2. Quick Info -**************************************************************************************************** -
    - ***

    Building with GNU tools (Linux, *BSD, MacOS X, mingw, etc.)

    - - Generally these should be all that are needed to build the libraries, applications, and samples: - -# go to ./projects/gnu and run -\code -$ ./configure -$ make clean && make -\endcode - - **

    Building Win32 Target with Microsoft Visual Studio

    - Generally we can just do these steps: - -# Visual Studio 8: open projects/win/libzrtp_vc8.sln solution, - -# build the libzrtp_test application. - - **

    Building for Windows Mobile

    - Generally these are all that are needed: - -# Visual Studio 8: open projects/win/libzrtp_wince_vc8.sln solution, - -# build the libzrtp_test application. - - **

    Locating Output Binaries/Libraries

    - For GNU targets, library files will be placed to ./projects/gnu/build and ./third_party/bnlib. - - **

    Running the Applications

    - After successful build, you can try running libzrtp_test application on projects/gnu/build/test directory. - -**************************************************************************************************** -\section howto_getting_source 3. Getting the Source Distribution -**************************************************************************************************** -
    -***\subsection howto_getting_source_tar 3.1 Getting the Release tarball - - Getting the released tarball is the best way to obtain stable version of libzrtp. The tarball may not contain the latest features or bug-fixes, but normally it is considered more stable, tested and well documented. - - The latest released tarball can be downloaded from the http://zfoneproject.com/prod_sdk.html - -***\subsection howto_getting_source_svn 3.2 Getting from Subversion trunk - At the moment, SVN repository is available for libzrtp developers only. It will be opened for public soon. - -***\subsection howto_getting_source_layout 3.3 Source Directories Layout - - The top-level directories (denoted as $TOP here) in the source distribution contains the following sub-directories: - - \c $TOP/doc - documentation folder; - - \c $TOP/include - header files: - - \c zrtp_config_user.h - user defined ZRTP configuration options; - - \c zrtp_config_win.h - Windows related configuration options; - - \c zrtp_config.h - libzrtp automatic configuration routine. - - \c zrtp_crypto.h - contains definitions of the data types and functions necessary to - strengthen the crypto-segment of the library. These functions are used only by libzrtp - developers only. Typical projects based on libzrtp do not use these functions; - - \c zrtp_engine.h - contains types and functions needed by the ZRTP state-machine For - internal use only; - - \c zrtp_error.h - contains error codes returned by the libzrtp functions; - - \c zrtp_iface_system.h - contains a set of OS-related interface functions which must be - implemented in order to use the library; - - \c zrtp_iface.h - contains a set of ZRTP utility interface functions which must be - implemented in order to use the library; - - \c zrtp_legal.h - libzrtp license agreement; - - \c zrtp_list.h - contains functions and macros for safe operations with linked lists. All - lists in libzrtp are based on these functions. They can be used to avoid mistakes in list operations; - - \c zrtp_log.h - contains functions to track bugs and store the error log.; - - \c zrtp_pbx.h - conatins declarations of the main PBX related functions. Use this header if you are the implementor of some VoIP-server solutions; - - \c zrtp_srtp.h - SRTP crypto types and interfaces. Used to integrate libzrtp with third - party SRTP implementations; - - \c zrtp_srtp_builtin.h - data structures for built-in realization of SRTP. - - \c zrtp_string.h - contains functions for the use of the special, safe strings, - zrtp_stringn_t, used by libzrtp. - - \c zrtp_types.h - contains the definitions of the internal data types which are used by - libzrtp developers and experienced users. - - \c zrtp.h - conatins declarations of the main dataypes and function - functions necessary to operate libzrtp. This file header is only must to - be included in each module using the libzrt functions; - - \c $TOP/projects - - \c gnu - make files for Unix-like systems using autotools; - - \c symbian - configuration and make files for Symbian platform; - - \c win - Set of Microsoft Visual Studio project files for Windows and Windows CE. - - \c win_kernel - makefiles for Windows Kernel mode. - - \c xcode - project files for Apple Xcode. - - \c $TOP/src - libzrtp source files;\n - - \c $TOP/test - test suite for libZRTP kernel logic. Includes versions for Unix, Windows, - Windows CE and Symbian. - - \c $TOP/third_party - - \c bnlib - libbn files which are not intended for external use; - - \c bgaes - AES encryption library and hash functions by Brian Gladman; - - -**************************************************************************************************** -\section howto_praparations 4. Build Preparation -**************************************************************************************************** -
    -***\subsection howto_praparations_config 4.1 zrtp_cinfig_user.h - - Before building libzrtp, some adjustments may be performed according to developers needs. In order to do this, \c include/zrtp_cinfig_user.h should be used. Most of configuration parameters are optional and libzrtp can be build without any modifications. - - Check \ref zrtp_config for more information. - -***\subsection howto_praparations_iface 4.2 libzrtp platform-dependent interfaces - - The library requires external implementation of some system-dependent functions to enable cross-platform operation. The libzrtp distribution contains almost all interface implementations for the following platforms: Windows, Linux, Mac OSX, Symbian, Windows CE. The Quick Start allows a fast integration of the library. Built-in implementations are used by default and developer don't need to anything more. - - In order to start using libzrtp, developer should implement just few feedback interfaces. Libzrtp uses callbacks to notify application about some events in ZRTP protocol, such as: - - zrtp_callback_event_t#on_zrtp_secure - notify user about switching to secure; - - zrtp_callback_event_t#on_zrtp_not_secure - notify about ZRTP security issues. - - Another callback which must be implemented - transport routine: - - zrtp_callback_misc_t#on_send_packet - libzrtp uses this function to deliver ZRTP protocol message to the remote party. - - These only two callbacks which must be implemented to start using libzrtp. Example can be found at the end of this article. - - For more detail information about libzrtp platform-dependent interfaces check \ref XXX. - -**************************************************************************************************** -\section howto_unix 5. Building Linux, *nix, *BSD, and MacOS X Targets with GNU Build Systems -**************************************************************************************************** -
    -***\subsection howto_unix_targets Supported Targets - - The new, autoconf based GNU build system can be used to build the libraries/applications for the following targets: - - Linux (i386, Opteron, Itanium, MIPS, PowerPC, etc.), - - MacOS X (Intel, PowerPC), - - mingw (i386), - - FreeBSD (i386, Opteron, etc.), - - etc. - -***\subsection howto_unix_requir 5.1 Requirements - - In order to use libzrtp's GNU build system, these typical GNU tools are needed: - - GNU make, - - GNU binutils for the target, and - - GNU gcc for the target. - - In addition, the appropriate libraries must be installed for platform-dependent interfaces implementation. This could just be a libc and the appropriate system abstraction library such as Posix. - - The build system is known to work on the following hosts: - - Linux, many types of distributions. - - MacOS X 10.4 and higher - -***\subsection howto_unix_build 5.2 Running configure and make - - Run "./configure" without any options to let the script detect the appropriate settings for the host: -\code - $ cd libzrtp - $ ./configure - ... -\endcode - - Once the configure script completes successfully, libzrtp is ready to be built. Use following commands: -\code - $ cd libzrtp - $ make clean - $ make -\endcode - - Description of all make targets supported by the Makefile's: - - \c all. The default (or first) target to build the library binary; - - \c clean. Clean the object files and libzrtp binary; - - \c check. Build test cases and start libzrtp_test application; - - \c distclean. Remove all generated files (object, libraries, binaries, and - dependency files). - - \c install. Make install of libzrtp headers and binaries; - - \c uninstall. Remove installed headers and binaries. - -**************************************************************************************************** -\section howto_osx 6. Building MacOS X Targets with Xcode -**************************************************************************************************** -
    -***\subsection howto_osx_requir 6.1 Requirements - - To build libzrtp on OS X using Xcode you need following: - - Mac OSX 10.4 or later. - - Apple developers Tools installed. - - Xcode 3.1 or higher. - -***\subsection howto_osx_build 6.2 Building the Projects - - Follow the steps below to build libzrtp using Apple Xcode: - -# For Apple Xcode: open \c projects/xcode/libzrtp.xcodeproj project file. - -# Set "libzrtp" or "libzrtp_ec" as Active Target. - -# Select Debug or Release build as appropriate. - -# Build "configure" target. - -# Build the project. This will build libzrtp with all dependencies. - -# After successful build, libzrtp will be placed in \c projects/xcode/build/Debug or Release. - - Use \c projects/xcode/libzrtp_test.xcodeproj by analogy to build the test application. - -**************************************************************************************************** -\section howto_win 7. Building for Windows Targets with Microsoft Visual Studio -**************************************************************************************************** -
    -***\subsection howto_win_requir 7.1 Requirements - - The Microsoft Visual Studio based project files can be used with one of the following: - - Microsoft Visual C++ 2005 (including Express edition), - - For the host platform, the following are required: - - Windows NT, 2000, XP, 2003, or later , - - Sufficient amount of RAM for the build process (at least 256MB). - -***\subsection howto_win_build 7.2 Building the Projects - - Follow the steps below to build libzrtp using Visual Studio: - -# For Visual Studio 8 (VS 2005): open libzrtp_vs8.sln solution file. - -# Set "libzrtp" or "libzrtp_ec" as StartUp Project. - -# Select Debug or Release build as appropriate. - -# Build the project. This will build libzrtp and all dependencies. - -# After successful build, libzrtp will be placed in \c projects/win/Debug or Release. - - To build libzrtp test-cases use "libzrtp_test" as StartUp Project and perform steps listed above. - -**************************************************************************************************** -\section howto_wince 8. Building for Windows Mobile Targets (Windows CE/WinCE/PDA/SmartPhone) -**************************************************************************************************** -
    -***\subsection howto_wince_requir 8.1 Requirements - - The Microsoft Visual Studio based project files can be used with one of the following: - - Microsoft Visual C++ 2005 - - For the host platform, the following are required: - - Windows NT, 2000, XP, 2003, or later , - - Sufficient amount of RAM for the build process (at least 256MB). - -***\subsection howto_wince_build 8.2 Building the Projects - - Follow the steps below to build libzrtp using Visual Studio: - -# For Visual Studio 8 (VS 2005): open libzrtp_wince_vs8.sln solution file. - -# Set "libzrtp" or "libzrtp_ec" as StartUp Project. - -# Select Debug or Release build as appropriate. - -# Build the project. This will build libzrtp and all dependencies. - -# After successful build, libzrtp will be placed in \c projects/win/Debug or Release. - -\note - The Test Application is not available for Windows Mobile platform at the moment. We will fix this in next version of libzrtp. - -**************************************************************************************************** -\section howto_symbian 9. Building for Symbian -**************************************************************************************************** -
    - -**************************************************************************************************** -\section howto_using 10. Using libzrtp with Applications -**************************************************************************************************** -
    - Regardless of the build system being used, the following tasks are normally needed to be done in order to build application to use libzrtp: - -# Add following include directories in the include search path: - - \c libzrtp/include - - \c libzrtp/include/enterprise (if you are using Enterprise version of libzrtp) - - \c libzrtp/third_party/bgaes - - \c libzrtp/third_party/bnlib - - \c libzrtp/projects/gnu/config (for GNU Autoconf targets) - -# Put these library directories in the library search path: - - \c libzrtp/third_party/bnlib - - \c libzrtp/projects/gnu/build (for GNU Autoconf targets) - - \c libzrtp/projects/xcode/build/Release (when building with Xcode) - - \c libzrtp/projects/win/Release (when building with Visual Studio) - -# Include \c libzrtp.h header file to the application. - -# Link with \c libzrtp and \c bnlib. - -# Link with system spesific libraries: - - Windows: Add (among other things): ws2_32.lib. - - Linux, *nix, *BSD: Add (among other things): '-lpthread'. - - MacOS X: Add (among other things): '-lpthread'. - -**************************************************************************************************** -\section howto_example 11. Quick Start Example -**************************************************************************************************** -
    - -An overview for creating an encrypted channel using libzrtp: - -*** \subsection howto_example_init 11.1 Initialization - - The library supports profiling and dictating different channel parameters, though the initialization can be performed by one function call with default parameters. - -\code -typedef struct testcon_t -{ - zrtp_session_t *zrtp_session; // ZRTP Session structure - zrtp_stream_t *zrtp_audio; // ZRTP stream for voice encryption - zrtp_stream__t *zrtp_video; // ZRTP stream for video encryption -} testcon_t; - -testcon_t safe_connection; // Secure channel instance -zrtp_global_t zrtp_global; // Persistent storage for libzrtp data -\endcode - -\code -zrtp_status_t s = zrtp_status_ok; -zrtp_config_t zrtp_config; - -// Initialize zrtp config with default values -zrtp_config_defaults(&zrtp_config); - -// Make some adjustments: -// - Set Client ID to identify ourself -// - Set appropriate license mode -// - We going to use default zrtp cache implementation, so let's specify cache file path -strcpy(zrtp_config.client_id, TEST_CLIENT_ID); -zrtp_config.lic_mode = ZRTP_LICENSE_MODE_ACTIVE; -zrtp_zstrcpyc( ZSTR_GV(zrtp_config.def_cache_path), TEST_CACHE_PATH); - -// Define interface callback functions -zrtp_config.cb.misc_cb.on_send_packet = on_send_packet; -zrtp_config.cb.event_cb.on_zrtp_secure = on_zrtp_secure; -zrtp_config.cb.event_cb.on_zrtp_security_event = on_zrtp_event; - -// Everything is ready - initialize libzrtp. -s = zrtp_init(&zrtp_config, &zrtp_global); -if (zrtp_status_ok != s) { - // Check error code and debug logs -} - -// The library has been initialized and is ready to use -. . . -\endcode - -*** \subsection howto_example_sessions 11.2 Sessions/Streams - - The library operates with the ZRTP streams concept, where each packet is encrypted within this stream. The streams are created before the start of the encryption process. - -\code -// -// Allocate zrtp session with default parameters -// -z = zrtp_session_init( zrtp_global, - NULL, - zid, - is_initator, - &safe_connection->zrtp_session); -if (zrtp_status_ok != s) { - // Check error code and debug logs -} - -// Set call-back pointer to our parent structure -zrtp_session_set_userdata(safe_connection->zrtp_session, &safe_connection); - -// -// Attach Audio and Video Streams -// -s = zrtp_stream_attach(safe_connection->zrtp_session, &safe_connection->zrtp_audio); -if (zrtp_status_ok != s) { - // Check error code and debug logs -} -zrtp_stream_set_userdata(safe_connection->zrtp_audio, &safe_connection); - -s = zrtp_stream_attach(safe_connection->zrtp_session, &safe_connection->zrtp_video); -if (zrtp_status_ok != s) { - // Check error code and debug logs -} -zrtp_stream_set_userdata(safe_connection->zrtp_video, &safe_connection); -\endcode - - -*** \subsection howto_example_protocol 11.3 Protocol Handling - - To create an encrypted channel, run the ZRTP engine for each stream added to the session. In our case we have two streams. The library will notify when achieving safe mode through the feedback path interface. - -\code -// -// Streams are ready - initiate ZRTP protocol -// -zrtp_stream_start(safe_connection->zrtp_audio, assrc); -zrtp_stream_start(safe_connection->zrtp_video, vssrc); -\endcode - -The three steps above create the encrypted channel. After entering the "Secure" state, you provide a plain packet to the library and receive an encrypted packet ready to be sent. Decryption works in the analogous way. - -\code -zrtp_status_t s = zrtp_status_fail; -char packet[MAX_RTP_SIZE]; -int size = 0; - -// Some abstract function for packets receiving -size = get_packet(packet); - - // - // Processing incoming packets. - // You must determine media type and choose corresponding ZRTP stream - // -s = zrtp_process_srtp(safe_connection->zrtp_audio, packet, &size); -switch (s) { - case zrtp_status_ok: - // - // Packet was successfully decrypted. Dont forget that packet - // size was changed during decryption. New size now in size - // - - case zrtp_status_drop: - // - // This is a protocol ZRTP packet or masked RTP media. - // In either case the packet must be dropped to protect your - // private data and media codec - - case zrtp_status_fail: - // - // This is some kind of error - see logs for more information. - // Don't put such packet to the network. It is not secure. - // -} -\endcode - -*** \subsection howto_example_callbacks 11.4 Callbacks - - libzrtp informs the user application about all changes in protocol state through a system of callback functions. The developer's guide considers this question in detail in \ref XXX. In most cases we need to display the SAS string and some other stream options after switching to the Secure state. An example of doing this is follow: - -\code -static void on_zrtp_secure(zrtp_stream_t *stream, unsigned event) -{ - test_options_t* info; // some user-defined stream options - - switch (event) { - case ZRTP_EVENT_IS_SECURE: - { - safe_connection_t* safe_connection = zrtp_stream_get_userdata(stream); - zrtp_session_info_t zrtp_session_info; - - zrtp_session_get(safe_connection->zrtp_session, &zrtp_session_info); - // - // Print out SAS there. - // - } break; - - // ... - // handle other events there - - default: - break; - } -} -\endcode - -An overview for closing an secure channel using libzrtp: - -*** \subsection howto_example_utilization 11.5 Utilization - - The uninstall session permits libzrtp to dispose of all engaged resources and release memory for session context storage. ZRTP streams will be also released, so you don't need to call separate functions. - -\code -zrtp_session_down(safe_connection->zrtp_session); -\endcode - - When you no longer need the library, dispose of all resources allocated before the beginning of the operation. - -\code -zrtp_down(&zrtp_global); -\endcode - -**************************************************************************************************** -\section howto_summary 12. Summary -**************************************************************************************************** -
    -Integration of libzrtp requires familiarity with the protocol and the library operation features. While the encryption of VoIP is not a trivial task, we have attempted to simplify as much as possible the work required to integrate libzrtp. - -*/ diff --git a/libs/libzrtp/doc/manuals/main.dox b/libs/libzrtp/doc/manuals/main.dox deleted file mode 100644 index e36cffd489..0000000000 --- a/libs/libzrtp/doc/manuals/main.dox +++ /dev/null @@ -1,38 +0,0 @@ -# -# Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. -# Contact: http://philzimmermann.com -# For licensing and other legal details, see the file zrtp_legal.c. -# -# Viktor Krykun - -/** -\mainpage ZRTP VoIP security - -**************************************************************************************************** -\section intro Intro -**************************************************************************************************** - - ZRTP Protocol finally goes RFC and we going to stabilize SDK as well. Libzrtp series 0.9X builds - will contain bug-fixes, performance and stability improvements only. - - So, please, be a patient with new API changes. We hope you will find them useful. - -**************************************************************************************************** -\section aboutdoc About this Documentation -**************************************************************************************************** - - Libzrtp, since v0.80 includes new, documentation. We have updated "How to Get Up and Running Quickly with libZRTP" and Public API documentation. - - We working on new "Libzrtp Developers Guide" which will give more detail information about ZRTP protocol and libzrtp architecture. This document will be available in next versions of libzrtp. But even now, libzrtp contains enough documentation to start using it comfortable. - - \note - libzrtp private API may have outdated information from previous version (links like this: \ref XXX). We working hard on that part of the documentation and it will be published in next versions of libzrtp. - -**************************************************************************************************** -\section zrtp Libzrtp Documents -**************************************************************************************************** --# \ref changelog --# \ref howto --# \ref rng - -*/ diff --git a/libs/libzrtp/doc/manuals/rng.dox b/libs/libzrtp/doc/manuals/rng.dox deleted file mode 100644 index 60d10646cc..0000000000 --- a/libs/libzrtp/doc/manuals/rng.dox +++ /dev/null @@ -1,74 +0,0 @@ -# -# Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. -# Contact: http://philzimmermann.com -# For licensing and other legal details, see the file zrtp_legal.c. -# -# Viktor Krykun - - -/** - * \file rng.dox - * \brief Random Number Generation in libzrtp - */ - -/** -\page rng Random Number Generation in libzrtp - -\section rng Random number generation - - The generation of cryptographic key material is a highly sensitive process. To do this, you need high entropy random numbers that an attacker cannot predict. This section discusses the random number generator used by libzrtp, and how suitable entropy can be collected on different hardware platforms. - - Failure to use true entropy from the physical environment as a basis for generating random cryptographic key material would lead to a disastrous loss of security. - -**************************************************************************************************** -\subsection rng_algorithm Deterministic Random Bit Generator -**************************************************************************************************** -
    - Libzrtp uses a cryptographically strong Deterministic Random Bit Generator (DRBG), based on running the AES-256 block cipher in counter mode. The output of this DRBG is used for key material by libzrtp for the Diffie-Hellman private keys, and other random protocol components such as nonces. The 256-bit AES key and 128-bit initialization vector for the DRBG are drawn from an entropy pool - created by a SHA-512 hash of raw entropy sources. These raw entropy sources are highly platform dependent and thus are not included in libzrtp. The library provides only a set of interfaces for adding the entropy to the entropy pool. We will discuss the entropy collection in the next section. - - When a random number is required by the ZRTP protocol, the library kernel calls the Deterministic Random Bit Generator interface function zrtp_randstr(). That function requires the existance of an entropy pool that has already been seeded with sufficient entropy. This entropy pool must be seeded by calling zrtp_entropy_add(). - - The zrtp_entropy_add() function takes a buffer of raw unprocessed entropy provided by the caller and adds it to the entropy pool via the SHA-512 hash function. - -**************************************************************************************************** -\subsection rng_accumulation Entropy accumulation -**************************************************************************************************** -
    - Random numbers for cryptographic key material must be derived from a physical entropy source, such as RF noise, acoustic noise, thermal noise, high resolution timings of environmental events, or other unpredictable physical sources of entropy. For a detailed explanation of cryptographic grade random numbers and guidance for collecting suitable entropy, see RFC 4086 and Chapter 10 of "Practical Cryptography" by Ferguson and Schneier. The raw entropy must be distilled and processed through a Deterministic Random Bit Generator (DRBG). We supply a suitable DRBG in libzrtp, which is accessed through the zrtp_randstr() function. - - To add entropy to the entropy pool maintained by the libzrtp random number generator, the application calls the zrtp_entropy_add() function. This entropy accumulation function may be called whenever new entropy becomes available. - - \warning - The entropy pool builds up more precious entropy each time you call zrtp_entropy_add(). Once in a while, it is a good idea to save the entropy in nonvolatile storage, by calling zrtp_randstr() and writing the output to a file, or to flash memory, or to some nonvolatile system storage area. This can be done whenever the VoIP application shuts down, or perhaps at the end of each secure VoIP call. A minimum of 512 bits (64 bytes) of output from zrtp_randstr() should be stored this way, but there is no need to store more than 256 bytes. When the VoIP application starts back up again, the contents of this nonvolatile entropy file should be added back into the active entropy pool by passing it to the zrtp_entropy_add() function. - -**************************************************************************************************** -\subsection rng_default Libzrtp built-in entropy sources -**************************************************************************************************** -
    - The SDK library provides a default implementation of entropy accumulation for Windows Kernel and Unix based platforms. - - For the Windows kernel mode it gathers current system state information as an entropy source. Among them are the performance counter, the current value of the system interrupt-time count, the count of the interval timer interrupts, and the values of some CPU registers. - - For Unix platforms, libzrtp calls \c /dev/urandom. - - If you are running libzrtp on a Windows Kernel or a full-blown desktop *nix-like system - you need not do anything more to implement the RNG. If you are using some other platform - carefully read the next section. - -**************************************************************************************************** -\subsection rng_guidelines Entropy sources for your platform. -**************************************************************************************************** -
    - On a desktop or laptop PC running Linux, FreeBSD, NetBSD, or OpenBSD, a good source of entropy may be found by reading from \c /dev/random or \c /dev/urandom. This is because \c /dev/random is seeded by entropy from keyboard timings, mouse movements, disk latency measurements, or other physical noise sources, some of them involving unpredictable human interaction. - - However, some low cost embedded Linux systems have no keyboard, no mouse or trackpad, no disk drive, and are starving for high quality entropy. There are some low cost Asterisk PBX boxes that are built this way. Or hardware Analog Telephone Adapters. Or low cost consumer routers. Many of them have no \c /dev/random implemented, or worse, have only a stub for /dev/random that does not actually collect any environmental entropy. This creates a dangerous illusion that entropy is available, because \c /dev/urandom appears to work, but is not backed by true entropy. This is bad, and not only for ZRTP. Platforms like these might not be able to generate strong cryptographic key material for SSH or SSL. - - If you are an OEM that builds hardware like this, and you wish to implement the ZRTP protocol with our libzrtp SDK, you really should provide a properly implemented \c /dev/random and \c /dev/urandom, properly supplied with true environmental entropy. If you are building a telephone, you can easily collect entropy from raw audio samples from the microphone. If the phone includes a video camera, you can collect entropy by sampling a few raw uncompressed video frames. If it's a mobile phone or a cordless phone, you can collect entropy from the RF noise in your wireless circuitry. If it's an embedded box like a router or low cost PBX, you can do high resolution timings of packet arrivals and use the timer readings as entropy sources. A PBX might include an analog interface to PSTN phone lines, and those interfaces usually include registers that measure analog voltage levels, which can serve as a source of entropy. The entropy sources do not need to produce much entropy, just a few bits at a time, but it can build up slowly until you have accumulated a few hundred bits of entropy. That's enough to generate cryptographically useful keys. Even if it takes some seconds or even minutes to accumulate this much entropy the first time your product is activated, it can be stored in nonvolatile storage so that it will be ready to reseed the entropy pool instantly the next time your product is powered up. - - In the ideal case, if you are designing the embedded hardware yourself, you could provide a good source of entropy by including a simple ring oscillator in the hardware. A ring oscillator is a circular chain (a ring) of NOT gates, and has nothing whatsoever to do with a telephone ring generator. The oscillation frequency drifts from thermal noise, and sampling the output at some low sampling rate is a good way to get some entropy. However, most designers have to work with existing hardware designs, and don't have the luxury of adding special hardware to generate entropy, which means you have to improvise with whatever you can collect from the environment, using any of the methods described above. - - If the library is used on another platform, the potential entropy sources should be thoroughly analyzed and a custom implementation must be developed for that platform. You can get your entropy collection ideas by looking at the default implementation of \c zrtp_add_system_state() provided in \c zrtp_rng.c. Again, microphone noise can be a good entropy source for VoIP clients. Raw, uncompressed, unfiltered audio samples should be used. - - If you have entropy gathering schemes for platforms not already supported in libzrtp, or if you doubt the correctness of your entropy collection approach, contact us to discuss how it may be done. We will do our best to provide you with technical assistance. - -*/ diff --git a/libs/libzrtp/include/zrtp.h b/libs/libzrtp/include/zrtp.h deleted file mode 100644 index c2ff1c2c78..0000000000 --- a/libs/libzrtp/include/zrtp.h +++ /dev/null @@ -1,968 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - -/** - * \file zrtp.h - * \brief Defines basic libzrtp functions and data types - */ - -#ifndef __ZRTP_H__ -#define __ZRTP_H__ - -#include "zrtp_config.h" -#include "zrtp_base.h" -#include "zrtp_error.h" -#include "zrtp_types.h" -#include "zrtp_protocol.h" -#include "zrtp_engine.h" -#include "zrtp_crypto.h" -#include "zrtp_iface.h" -#include "zrtp_iface_system.h" -#include "zrtp_iface_scheduler.h" -#include "zrtp_list.h" -#include "zrtp_legal.h" -#include "zrtp_log.h" -#include "zrtp_srtp.h" -#include "zrtp_srtp_builtin.h" -#include "zrtp_string.h" -#include "zrtp_pbx.h" -#include "zrtp_legal.h" -#include "zrtp_version.h" -#include "zrtp_iface_cache.h" -#include "zrtp_ec.h" - - - -/** - * \defgroup zrtp_api API - * - * In this section the basic functions for using the library are defined. They include - * initialization and deinitialization functions, functions for session and stream management and - * functions for RTP traffic management. - * - * In most cases this section is all you need to start working with libzrtp. The typical simplified - * order of operations in using libzrtp is the following: - * -# library configuration - * -# library initialization; - * -# ZRTP session creation and configuration; - * -# ZRTP stream attaching and Protocol initiation; - * -# RTP stream processing; - * -# ZRTP protocol stopping and releasing resources. - * For each of these actions there is a set of corresponding functions. - * \sa - * - \ref howto - * - \ref XXX_GUIDE - */ - - - -/*======================================================================*/ -/* Public ZRTP libzrtp datatypes */ -/*======================================================================*/ - - -/** - * \defgroup zrtp_types Types and Definitions - * \ingroup zrtp_api - * The data types used in libzrtp are defined in this section - * \{ - * - */ -/** - * \typedef typedef uint32_t zrtp_id_t; - * \brief libzrtp general identifier used to debug connections management. - * \ingroup zrtp_main_init - */ - -/** Length of "zrtp-hash-value", RFC 6189 sec 8. @sa zrtp_signaling_hash_get(); */ -#define ZRTP_SIGN_ZRTP_HASH_LENGTH (ZRTP_MESSAGE_HASH_SIZE*2) - -/** - * \brief Enumeration for ZRTP Licensing modes - * \ingroup zrtp_main_init - * - * A ZRTP endpoint that is Passive will never send a Commit message, which means that it cannot be - * the initiator in the ZRTP exchange. Since at least one of the two parties must be the initiator, - * two Passive endpoints cannot make a secure connection. However, a non-Passive ZRTP endpoint can - * send a Commit message, enabling it to act as the initiator in a ZRTP exchange. This allows it to - * make a secure connection to a Passive endpoint, or to another non-Passive endpoint. - * - * In addition, a Passive ZRTP endpoint declares that it is Passive by setting the passive flag in - * the Hello message, which means the other party will recognize it as Passive. This allows for a - * Passive mode and two forms of Active mode-- Active, or Unlimited. These three possible behaviors - * for a ZRTP endpoint are defined as: - * - \b Passive: Never send a Commit message, and thus can never be the initiator. - * - \b Active: Will send a Commit message, but only to non-Passive ZRTP partners. - * - \b Unlimited: Will send a Commit message to any ZRTP partner, Passive or non-Passive. - * - * This can be used to provide three classes of service, which can be licensed t different price - * points. Passive can be used in freeware for widest possible deployment, Active can be used in - * discount products that can only talk to non-freeware, and Unlimited can be used in full-price - * products that will benefit from the network effect of widely deployed Passive freeware. - */ -typedef enum zrtp_license_mode_t -{ - /** @brief Never send a Commit message, and thus can never be the initiator. */ - ZRTP_LICENSE_MODE_PASSIVE = 0, - /** @brief Will initiate ZRTP exchange, but only to non-Passive ZRTP partners. */ - ZRTP_LICENSE_MODE_ACTIVE, - /** @brief Will send a Commit message to any ZRTP partner, Passive or non-Passive. */ - ZRTP_LICENSE_MODE_UNLIMITED -} zrtp_license_mode_t; - -/** - * @brief Enumeration to define Signaling initiator/responder roles. - * - * Used by libzrtp to optimize some internal processes and protocol handshake. - * - * @sas zrtp_stream_start(). - */ -typedef enum zrtp_signaling_role_t -{ - /** @brief Unknown Signaling role, should be used when the app can't determine the role. */ - ZRTP_SIGNALING_ROLE_UNKNOWN = 0, - /** @brief Signaling Initiator. */ - ZRTP_SIGNALING_ROLE_INITIATOR, - /** @brief Signaling Responder. */ - ZRTP_SIGNALING_ROLE_RESPONDER, - ZRTP_SIGNALING_ROLE_COUNT -} zrtp_signaling_role_t; - - -/** @brief 12-byte ZID for unique ZRTP endpoint identification. */ -typedef unsigned char zrtp_zid_t[12]; - -/** \brief 16-byte ID for ZRTP endpoint's software identification. */ -typedef char zrtp_client_id_t[16]; - -/** - * @brief ZRTP global configuration options - * @ingroup zrtp_main_init - * @warning Use \ref zrtp_config_defaults() before start configuring this structure. - */ -typedef struct zrtp_config_t -{ - /** @brief Symbolic client identifier */ - zrtp_client_id_t client_id; - - /** @brief libzrtp license mode defined protocol behavior */ - zrtp_license_mode_t lic_mode; - - /** @brief Set this flag to 1 if you product is MiTM box */ - uint8_t is_mitm; - - /** @brief Set of interfaces required to operate with libzrtp */ - zrtp_callback_t cb; - - /** @brief Path to zrtp cache file (set if you use built-in realization) */ - zrtp_string256_t def_cache_path; - - /** - * @brief Flush the cache automatically - * Set to 1 if you want libzrtp to flush the cache to the persistent storage - * right after it is modified. If cache_auto_store is 0, libzrtp will flush - * the cache on going down only and the app is responsible for storing the - * cache in unexpected situations. Enabled by default. - * - * @sa zrtp_def_cache_store() - */ - unsigned cache_auto_store; -} zrtp_config_t; - -/** - * \brief zrtp stream information structure - * \ingroup zrtp_main_management - * - * libzrtp, since v0.80 takes data encapsulating approach and hides all private data inside - * zrtp_stream_t structure. Developers shouldn't access them directly. \ref zrtp_stream_get() should - * be used instead to fill zrtp_stream_info_t structure. zrtp_stream_info_t contains all needed - * information in safe and easy to use form. - */ -struct zrtp_stream_info_t -{ - /** \brief Stream unique identifier for debug purposes */ - zrtp_id_t id; - - /** \brief Pointer to the parent zrtp session */ - zrtp_session_t* session; - - /** \brief Stream mode. Defines libzrtp behavior related to specified contexts. */ - zrtp_stream_mode_t mode; - - /** \brief Defines ZRTP Trusted mitm mode for the current session. */ - zrtp_mitm_mode_t mitm_mode; - - /** \brief Reflects current state of ZRTP protocol */ - zrtp_state_t state; - - /** - * \brief Last protocol error code - * - * Available for reading in ERROR state on zrtp_security_event_t#ZRTP_EVENT_PROTOCOL_ERROR. - */ - zrtp_protocol_error_t last_error; - - /** - * \brief Remote passive flag - * - * This flag shows when remote side is "passive" (has license mode PASSIVE) available in CLEAR - * state and later. - */ - uint8_t peer_passive; - - /** - * \brief Allowclear flag. - * - * Current value of "allowclear" option exchanged during ZRTP negotiation. Available in SECURE - * state. - */ - uint8_t res_allowclear; - - /** - * \brief Peer disclose bit flag - * - * Indicates the ability of the remote side to disclose its session key. Specifies that the - * remote side allows call monitoring. If this flag is set, the end user must be informed. It - * can be read in the SECURE state. - */ - uint8_t peer_disclose; - - /** - * \brief Defines that remote party is ZRTP MiTM endpoint - * - * Enabled by (Asterisk PBX, UMLab SIP Firewall or etc.) Available for reading in CLEAR state - * ande later. - */ - uint8_t peer_mitm; -}; - -/** - * \brief zrtp session information structure - * \ingroup zrtp_main_management - * libzrtp, since v0.80 takes data incapsulating approach and hides all private date inside - * zrtp_session_t structure. Developers shouldn't access them directly. \ref zrtp_session_get() - * should be used instead to fill zrtp_session_info_t structure. zrtp_session_info_t contains all - * needed information in safe and easy to use form. - */ -struct zrtp_session_info_t -{ - /** \brief Session unique identifier for debug purposes */ - zrtp_id_t id; - - /** - * \brief Local ZID - * - The unique 12-characters string that identifies the local ZRTP endpoint.This ID allows remote - * peers to recognize this ZRTP endpoint. - */ - zrtp_string16_t zid; - - /** - * \brief Remote ZID - * - * Extracted from the Hello packet of the very first ZRTP stream. Uniquely identifies the remote - * ZRTP peer. - */ - zrtp_string16_t peer_zid; - - /** \brief Character name identified remote ZRTP endpoint.*/ - zrtp_string16_t peer_clientid; - - /** \brief ZRTP Protocol version supported by the remote endpoint. */ - zrtp_string16_t peer_version; - - /** - * \brief Indicates that SAS related data is available for reading. - * \note - * As SAS is computed in SECURE state only, it may contain unknown values in other states. Check - * sas_is_ready before displaying SAS to the user. - */ - uint8_t sas_is_ready; - - /** \brief First Short Authentication String */ - zrtp_string16_t sas1; - - /** - * \brief Second Short Authentication string. - * \note - * Second SAS is available for \c base256 authentication only (\c sas_is_base256 is set). In - * other case, \c sas1 contains \c base32 value and \c sas2 is empty. - */ - zrtp_string16_t sas2; - - /** \brief Binary SAS digest (ZRTP_SAS_DIGEST_LENGTH bytes) */ - zrtp_string32_t sasbin; - - /** - * \brief Bit-map to summarize shared secrets "Cached" flags. - * - * 1 at appropriate bit means that the secrets was found in the cache and restored successfully. - * Value equal to 0 indicates that secret for the remote endpoint was not found in the cache - * and was generated randomly. - * Use ZRTP_BIT_RS1, ZRTP_BIT_RS2, ZRTP_BIT_AUX and ZRTP_BIT_PBX bit-masks to get "cached" value - * for the appropriate secret. - */ - uint32_t cached_flags; - - /** - * \brief Bit-map to summarize shared secrets "Matched" flags. - * - * 1 at appropriate bit means that the secret, locally computed by your ZRTP endpoint is equal - * to the secret, received from the remote endpoint. Secrets may not match if one of the - * endpoints doesn't use cache of the shared secrets, if the cache was deleted or in case of - * an attack. - * Use ZRTP_BIT_RS1, ZRTP_BIT_RS2, ZRTP_BIT_AUX and ZRTP_BIT_PBX bit-masks to get "cached" value - * for the appropriate secret. - */ - uint32_t matches_flags; - - /** - * \brief Bit-map to summarize shared secrets "Wrong" flags. - * - * 1 at appropriate bit means that the secret was restored from the cache, but doesn't match - * to the remote endpoint's secret. Such situation may happen if the remote endpoint lost cache - * or in case of attach. - * Use ZRTP_BIT_RS1, ZRTP_BIT_RS2, ZRTP_BIT_AUX and ZRTP_BIT_PBX bit-masks to get "cached" value - * for the appropriate secret. - */ - uint32_t wrongs_flags; - - /** - * \brief SAS Verification flag. - * - * The SAS Verified flag (V) is set based on the user indicating that SAS comparison has been - * successfully performed. Each party sends the SAS Verified flag from the previous session in - * the Confirm message of the current session. - * \sa - * - ZRTP RFC section. "7.1. SAS Verified Flag" for more information about Verification Flag. - * - zrtp_verified_set() - */ - uint32_t sas_is_verified; - - /** \brief Indicates base256 SAS encoding */ - uint8_t sas_is_base256; - - /** - * \brief actual lifetime of the secrets - * - * This variable contains the interval for retaining secrets within an established session. In - * accordance with ZRTP RFC this value is calculated as the minimal of local and remote TTLs - * after confirmation. Value is given in seconds and can be read in the SECURE state. - */ - uint32_t secrets_ttl; - - /** \brief Hash crypto component name used in ZRTP calculations. */ - zrtp_string32_t hash_name; - - /** \brief Cipher crypto component name used in ZRTP encryption. */ - zrtp_string32_t cipher_name; - - /** \brief SRTP Authentication crypto component name used in ZRTP exchange. */ - zrtp_string32_t auth_name; - - /** \brief SAS scheme crypto component name used in ZRTP exchange. */ - zrtp_string32_t sas_name; - - /** \brief Publik Key Exchange name used in ZRTP exchange. */ - zrtp_string32_t pk_name; -}; - -/* \} */ - - -/*======================================================================*/ -/* libzrtp Public API: Streams management */ -/*======================================================================*/ - - -#if defined(__cplusplus) -extern "C" -{ -#endif - -/** - * \defgroup zrtp_main_init Initalization and Configuration - * \ingroup zrtp_api - * \{ - */ - -/** - * \brief Initializes libzrtp global config - * - * zrtp_config_defaults() prepares all fields of zrtp_config_t for further usage in zrtp_init(). - * This function allocates all necessary resources and initialize zrtp_config_t#cb with default - * implementations. - * - * \param config - libzrtp config for initialization. - * \warning this function must be used before start operating with the config. - */ -void zrtp_config_defaults(zrtp_config_t* config); - -/** - * \brief Initializing libzrtp - * - * This function initializes the library and all its components. zrtp_init() initialize global data - * for all sessions and streams. Fields of the global zrtp context are initialized automatically and - * shouldn't be modified. For correct memory management, global context should be released by - * calling zrtp_down(). - * - * \param config - libzrtp inital parameters - * \param zrtp - out parameter, pointer to allocated zrtp global context structure; - * \warning this function \b must be called before any operation with libzrtp. - * \return - * - zrtp_status_ok in successfully initialized or one of zrtp status errors in other case. - * \sa zrtp_down() -*/ -zrtp_status_t zrtp_init(zrtp_config_t* config, zrtp_global_t** zrtp); - -/*! - * \brief Shutting down the library - * - * Frees all allocated structures and resources. This function \b must be called at the end of use - * to stop libzrtp correctly. zrtp_down() doesn't stop in-progress ZRTP streams. To avoid mistakes, - * close all sessions before library deinitialization. - * - * \param zrtp - global ZRTP context previously allocated by zrtp_init(); - * \return - * - zrtp_status_ok if successfully shut down; - * - zrtp_status_fail if an error occurred. - * \sa zrtp_init() - */ -zrtp_status_t zrtp_down(zrtp_global_t* zrtp); - -/* \} */ - -/** - * \defgroup zrtp_main_management ZRTP Connections - * \ingroup zrtp_api - * \{ - */ - -/** - * \brief ZRTP Session Initialization. - * - * This function allocates and initializes the internal session context data. The given context is - * associated with the specified ZRTP identifier. Only after initialization does the session contain - * ZRTP_MAX_STREAMS_PER_SESSION streams ready to be used. - * - * After successfully initialization, configuration will be done according to the relevant profile - * \c profile. Profile will be applyed to every stream allocated within this session. Before using - * the profile, call zrtp_profile_check() function to make sure that the profile you are applying - * is correct. - * - * \warning Don't call zrtp_session_init() in parallel with other operations on this session. - * \param zrtp - global libzrtp context; - * \param profile - the session configuration profile. If value of this parameter is NULL, default - * profile will be used. NULL profile usage is equivalent to calling zrtp_profile_defaults(). - * \param zid - ZRTP peer identificator. - * \param role - identifies if the endpoint was the signaling initiator of the call. Used to - * provide Passive Mode options to the developer. If your application doesn't control signaling - * or you don't want to support Passive Mode features - set it to ZRTP_SIGNALING_ROLE_UNKNOWN. - * \param session - allocated session structure. - * \return - * - zrtp_status_ok if initialization is successful; - * - zrtp_status_fail if an error occurs. - * \sa zrtp_session_down() - */ -zrtp_status_t zrtp_session_init( zrtp_global_t* zrtp, - zrtp_profile_t* profile, - zrtp_zid_t zid, - zrtp_signaling_role_t role, - zrtp_session_t **session); -/** - * \brief ZRTP Session context deinitialization - * - * This function releases all resources allocated for internal context operations by zrtp_init(). - * - * \warning Don't call zrtp_session_init() in parallel with other operations on this session. - * \param session - session for deinitialization. - * \sa zrtp_session_init() - */ -void zrtp_session_down(zrtp_session_t *session); - - -/** - * \brief Obtain information about ZRTP session - * - * Function initialize and fills all fields of zrtp_session_info_t structure according to - * the current state of ZRTP session. - * - * \param session - zrtp session which parameters should be extracted; - * \param info - out structure to be initialized. - * \return - * - zrtp_status_ok in case of success. - * - zrtp_status_fail if an error occurs. - */ -zrtp_status_t zrtp_session_get(zrtp_session_t *session, zrtp_session_info_t *info); - -/** - * \brief Allow user to associate some data with current zrtp session. - * \param session - zrtp session to attach data to. - * \param udata - pointer to the user-data context. - * \sa zrtp_session_get_userdata() - */ -void zrtp_session_set_userdata(zrtp_session_t *session, void* udata); - -/** - * \brief Return user data associated with the zrtp session - * \param session - zrtp session to extract user data. - * \return - * - pointer to the user-data context previously set by zrtp_session_set_userdata(). - * - NULL if the user data unavailable. - * \sa zrtp_session_set_userdata() - */ -void* zrtp_session_get_userdata(zrtp_session_t *session); - -/** - * \brief Attaching a new stream to the session - * - * This function call initializes a ZRTP stream and prepares it for use within the specified - * session. The maximum number of streams for one session is defined by the - * ZRTP_MAX_STREAMS_PER_SESSION variable. All newly created streams are equivalent and have - * ZRTP_STREAM_MODE_CLEAR mode and ZRTP_ACTIVE state. Only after attaching a stream, ZRTP protocol - * can be initiated. - * - * \param session - the ZRTP session within which a new stream is to be - * \param stream - out parameter, attached stream will be stored there - * \return - * - zrtp_status_ok if stream was attached successfully - * - one of zrtp_status_t errors in case of failure - * \sa zrtp_stream_start() zrtp_stream_stop() - */ -zrtp_status_t zrtp_stream_attach(zrtp_session_t *session, zrtp_stream_t** stream); - -/** - * \brief Starting a ZRTP stream - * - * ZRTP stream setup is initiated by calling this function. Exchange of command packets begins - * immediately according to protocol. If the option "autosecure" is on, calling this function is the - * only requirement for setting up the ZRTP connection within a stream. If "autosecure" mode is not - * available, calling this function activates only connection within a ZRTP stream. A connection can - * be established manually later by calling zrtp_stream_secure(). - * - * Setup of the stream/connection takes a certain interval of time. This function just initiates - * this process. The system of callbacks informs the user about the progress of libzrtp protocol. - * - * \param stream - ZRTP stream to be started. - * \param ssrc - ssrc which will be used in ZRTP protocol messages. It should match with ssrc of - * appropriate RTP stream which will be encrypted by this ZRTP stream. - * \return - * - zrtp_status_ok in case of success; - * - one of zrtp_status_t errors in case of failure - * \sa - * - \ref XXX_GUIDE_CB \ref XXX_GUIDE_MANAGEMENT - * - zrtp_stream_stop() zrtp_stream_secure() zrtp_stream_clear() - */ -zrtp_status_t zrtp_stream_start(zrtp_stream_t* stream, - uint32_t ssrc); - -/** - * \brief ZRTP protocol stopping - * - * This function stops all protocol operations for the specified stream, releases resources - * allocated on the zrtp_stream_start() and prepares the stream structure for the next use. - * - * This function will stop the protocol at any stage: all delayed tasks are canceled, and the - * protocol packet exchange and encryption is stopped. After this function call it is necessary to - * stop processing traffic using the zrtp_process_xxx() function. - * - * \param stream - the stream being shutdown. - * \return - * - zrtp_status_ok in case of success; - * - one of zrtp_status_t errors in case of failure - * \sa - * - \ref XXX_GUIDE_CB \ref XXX_GUIDE_MANAGEMENT - * - zrtp_stream_start() zrtp_stream_secure() zrtp_stream_clear() - */ -zrtp_status_t zrtp_stream_stop(zrtp_stream_t* stream); - -/*! - * \brief Initiating an interruption of the secure connection - * - * This function initiates the shutting down of the ZRTP connection within a stream. In other words, - * after successfully switching to secure mode (\ref XXX SECURE state, fig. 1.5), calling this - * function begins the exchange of packets switching back to insecure (CLEAR) mode. - * - * This function can only be implemented from the SECURE state. Attempt to call this function from - * any other state will end in failure. The client application is informed about protocol - * progress through a system of callbacks. - * - * \param stream - ZRTP stream . - * \return - * - zrtp_status_ok - if shutting down the connection is started successfully. - * - zrtp_status_fail - if shutting down the connection is initiated from an incorrect state. - * \sa - * - \ref XXX_GUIDE_CB \ref XXX_GUIDE_MANAGEMENT - * - zrtp_stream_start() zrtp_stream_secure() zrtp_stream_clear() - */ -zrtp_status_t zrtp_stream_clear(zrtp_stream_t *stream); - -/** - * \brief Initiating a secure connection setup - * - * The function initiates a ZRTP connection setup within a stream. In other words, after the - * protocol has started and Discovery phase have been successfully accomplished, calling this - * function will begin the exchange of packets for switching to SECURE mode. - * - * This function can be successfully performed only from the CLEAR state (\ref XXX Figure 1.6). - * Attempting to call this function from any other state will result in failure. The client - * application is informed about protocol progress through a system of callbacks. - * - * \param stream - ZRTP stream to be secured. - * \return - * - zrtp_status_ok - if switching to secure mode started successfully. - * - zrtp_status_fail - if switching to secure mode is initiated from a state other than CLEAR. - * \sa - * - \ref XXX_GUIDE_CB \ref XXX_GUIDE_MANAGEMENT. - * - zrtp_stream_start() zrtp_stream_clear(). - */ -zrtp_status_t zrtp_stream_secure(zrtp_stream_t *stream); - -/** - * \brief Obtain information about zrtp stream - * - * Function initialize and fills all fields of zrtp_stream_info_t structure accordint to - * current state of zrtp stream. - * - * \param stream - zrtp stream which parameters should be extracted - * \param info - out structure to be initialized - * \return - * - zrtp_status_ok in case of success. - * - zrtp_status_fail if an error occurs. - */ -zrtp_status_t zrtp_stream_get(zrtp_stream_t *stream, zrtp_stream_info_t *info); - -/** - * @brief Allow user to associate some data with zrtp stream. - * @param stream - zrtp stream to attach data to. - * @param udata - pointer to the user-data context. - * @sa zrtp_stream_get_userdata() - */ -void zrtp_stream_set_userdata(zrtp_stream_t *stream, void* udata); - -/** - * \brief Return user data associated with the zrtp stream - * \return - * - pointer to the user-data context previously set by zrtp_stream_set_userdata() - * - NULL if user data unavailable; - * \sa zrtp_stream_set_userdata() - */ -void* zrtp_stream_get_userdata(const zrtp_stream_t *stream); - -/* \} */ - -/*======================================================================*/ -/* libzrtp Public API: Encryption */ -/*======================================================================*/ - -/** - * \defgroup zrtp_main_proto Traffic Processing - * \ingroup zrtp_api - * \{ - */ - -/** - * \brief Processing outgoing RTP packets - * - * This is the main function for processing outgoing RTP packets. As soon as the protocol is - * started, each outgoing RTP packet (not encrypted) has to go through this function. - * - * It performs different actions depending on the connection state and packet type: - * - In setup ZRTP connection mode, it encrypts outgoing RTP packets. The packet is encrypted right - * in the transferred buffer; - * - Protects codec and data privacy by deleting certain packets from the stream. In this case the - * body and the length of the packet remain unchanged. - * - * \param stream - ZRTP stream to process RTP packet; - * \param packet - buffer storing the RTP packet for encryption. After processing, the encrypted - * packet is stored in the same buffer. - * \param length - the length of the buffered packet. After processing, the length of encrypted - * packet is stored here. - * \warning During encryption, the data length increases in comparison to the source data. Because - * the function uses the same buffer both for incoming and resulting values, the length of the - * buffer must be larger than size of source packet. - * \return - * - zrtp_status_ok if encryption is successful. The packet should be sent to the recipient. - * - zrtp_status_fail if there was an error during encryption. The packet should be rejected. - * - zrtp_status_drop if there was interference in the VoIP client codec protection mechanism. The - * packet should be rejected. - * \sa zrtp_process_srtp() zrtp_process_rtcp() zrtp_process_srtcp() - */ -zrtp_status_t zrtp_process_rtp( zrtp_stream_t *stream, - char* packet, - unsigned int* length); - -/** - * \brief Processing incoming RTP packets - * - * This is the main function for incoming RTP packets processing. It is an analogue of - * zrtp_process_rtp() but for an incoming stream. After the protocol is started, each (encrypted) - * incoming RTP packet has to go through this function. - * - * It performs different actions depending on the connection state and packet type: - * - during setup/interruption of ZRTP connection, processes incoming protocol packets. The body - * and length of the packet remain unchanged; - * - in setup ZRTP connection mode, decrypts incoming RTP packet. The packet is decrypted right in - * the transferred buffer; - * - protects codec and data privacy by deleting certain packets from the stream. In this case the - * body and the length of the packet remain unchanged. - * - * \param stream - ZRTP stream for processing - * \param packet - buffer storing the packet for decrypting. After processing, the decrypted packet - * is stored in the same buffer; - * \param length - the length of the buffered packet. After processing, the length of decrypted - * packet is stored here; - * \return - * - zrtp_status_ok if decrypting is successful. Such a packet should be sent to the recipient; - * - zrtp_status_fail if an error occurred during decrypting or command packet processing. The - * packet should be rejected; - * - zrtp_status_drop if the command packet processing is successful or if there was interference - * in the VoIP client codec protection mechanism. The packet should be rejected in either case; - * \sa zrtp_process_rtp() zrtp_process_rtcp() zrtp_process_srtcp() - */ -zrtp_status_t zrtp_process_srtp( zrtp_stream_t *stream, - char* packet, - unsigned int* length); - -/*! - * \brief Processing outgoing RTCP packets - * - * This is the main function for processing outgoing RTCP packets. The function behavior is similar - * to that of zrtp_process_rtp(): - * - In SECURE mode, encrypts outgoing RTCP packets. The packet is encrypted right in the - * transferred buffer. The length of encrypted packet is returned in the \c length variable; - * - protects codec and data privacy by deleting certain packets from the stream. In this case the - * body and the length of the packet remain unchanged. - * - * \param stream - ZRTP session for processing; - * \param packet - buffer storing RTCP packet; - * \param length - length of the buffered packet. - * \return - * - zrtp_status_ok if encryption is successful. The packet should be sent to the recipient. - * - zrtp_status_fail if there was an error during encryption. The packet should be rejected. - * - zrtp_status_drop if there was interference in the VoIP client codec protection mechanism. The - * packet should be rejected. - * \sa zrtp_process_srtp() zrtp_process_rtp() zrtp_process_srtcp() - */ -zrtp_status_t zrtp_process_rtcp( zrtp_stream_t *stream, - char* packet, - unsigned int* length); - -/** - * \brief Processing incoming RTCP packets - * - * This is the main function for processing incoming RTCP packets. The function behavior is similar - * to that of zrtp_process_srtp(): - * - In SECURE mode, decrypts incoming RTCP packets. The packet is decrypted right in the - * transferred buffer. The length of the encrypted packet is returned in the \c length variable; - * - In transition states, drops all incoming RTCP traffic. In this case the body and the length of - * the packet remain unchanged. - * - * \param stream - ZRTP stream for processing; - * \param packet - buffer storing the RTCP packet; - * \param length - length of the buffered packet. - * \return - * - zrtp_status_ok if decrypting is successful. Such a packet should be sent to the recipient; - * - zrtp_status_drop if the command packet processing is successful or if there was interference - * in the VoIP client codec protection mechanism. The packet should be rejected in either case; - * - zrtp_status_fail if there was an error during encryption. The packet should be rejected. - * \sa zrtp_process_srtp() zrtp_process_rtp() zrtp_process_rtcp() - */ -zrtp_status_t zrtp_process_srtcp( zrtp_stream_t *stream, - char* packet, - unsigned int* length); - -/* \} */ - -/** - * \defgroup zrtp_main_utils Utilities - * \ingroup zrtp_api - * \{ - */ - -/** - * \brief Specifies the hash of the peer Hello message for verification. - * - * In accordance with the ZRTP RFC sec. 9, this protocol can prevent DOS attacks by verification of - * the Hello message hash sent through the signaling protocol. - * - * This function allows the user to specify the Hello hash for verification. If after the - * discovering phase the Hello hashes don't match, libzrtp raises the - * zrtp_event_t#ZRTP_EVENT_WRONG_SIGNALING_HASH event. This function should only be called before - * starting the protocol from the ZRTP_STATE_ACTIVE state. - * - * \param stream - stream for operating with; - * \param hash_buff - signaling hash buffer. Function accepts string, not a binary value!; - * \param hash_buff_length - signaling hash length in bytes, must be ZRTP_SIGN_ZRTP_HASH_LENGTH bytes; - * \return: - * - zrtp_status_ok if the operation finished successfully - * - one of the errors otherwise - * \sa - * - ZRTP RFC. sec 8; - * - zrtp_signaling_hash_get() - */ -zrtp_status_t zrtp_signaling_hash_set( zrtp_stream_t* stream, - const char *hash_buff, - uint32_t hash_buff_length); - -/** - * \brief Returns the hash of the Hello message to be transferred in signaling. - * - * To prevent DOS attacks, the hash of the Hello message may be sent through signaling. - * zrtp_signaling_hash_get() may be called after attaching the stream to receive the value of this - * hash. - * - * \param stream - stream for operating with - * \param hash_buff - buffer for storing signaling hash. Function returns already parsed hex string. - * String is null-terminated. Buffer must be at least ZRTP_SIGN_ZRTP_HASH_LENGTH bytes length. - * \param hash_buff_length - buffer length in bytes, non less than ZRTP_SIGN_ZRTP_HASH_LENGTH bytes. - * \return: - * - zrtp_status_ok if the operation finished successfully - * - one of the errors otherwise - * \sa - * - ZRTP RFC. sec 8; - * - zrtp_signaling_hash_set() - */ -zrtp_status_t zrtp_signaling_hash_get(zrtp_stream_t* stream, - char* hash_buff, - uint32_t hash_buff_length); - -/** - * \brief Changing the value of the secret's verification flag - * - * This function is used to change (set, unset) the secret's verification flag. zrtp_verified_set() - * changes the relevant internal data and stores a flag in the cache. - * \note - * Special synchronization mechanisms are provided to protect the cache from race conditions. Don't - * change the verified flag directly in the cache - use this function. - * - * \param zrtp - zrtp global data; - * \param zid1 - ZID of the first party; - * \param zid2 - ZID of the second party; - * \param verified - Boolean value of the verified flag. - * \return - * - zrtp_status_ok - if successful; - * - one of zrtp_status_t errors if fails. - */ -zrtp_status_t zrtp_verified_set( zrtp_global_t *zrtp, - zrtp_string16_t *zid1, - zrtp_string16_t *zid2, - uint8_t verified); - -/** - * \brief Verifying the ZRTP profile - * - * zrtp_profile_check() checks the correctness of the values in the profile. The following checks - * are performed: - * - the number of components in each group does not exceed ZRTP_MAX_COMP_COUNT; - * - the components declared are supported by the library kernel. - * - presence of the set of obligatory components defined by ZRTP RFC. - * - * \param profile - ZRTP profile for validation; - * \param zrtp - global ZRTP context. - * \return - * - zrtp_status_ok - if profile passed all available tests; - * - one of ZRTP errors - if there are mistakes in the profile. See debug logging for additional - * information. - */ -zrtp_status_t zrtp_profile_check(const zrtp_profile_t* profile, zrtp_global_t* zrtp); - -/** - * \brief Configure the default ZRTP profile - * - * These options are used: - * \code - * "active" is enabled; - * "allowclear" is disabled by default and enabled for Zfone only; - * "autosecure" is enabled; - * "disclose_bit" is disabled; - * cache_ttl = ZRTP_CACHE_DEFAULT_TTL defined by ZRTP RFC; - * - * [sas_schemes] = ZRTP_SAS_BASE256, ZRTP_SAS_BASE32; - * [cipher_types] = ZRTP_CIPHER_AES128; - * [pk_schemes] = ZRTP_PKTYPE_DH3072; - * [auth_tag_lens] = ZRTP_ATL_HS32; - * [hash_schemes] = ZRTP_HASH_SHA256; - * \endcode - * - * \param profile - ZRTP stream profile for filling; - * \param zrtp - libzrtp global context. - */ -void zrtp_profile_defaults(zrtp_profile_t* profile, zrtp_global_t* zrtp); - -/** - * \brief Search for a component in the profile by ID - * - * The utility function returning the position of an element of the specified type in the profile. - * Used by libZRTP kernel and for external use. - * - * \param profile - ZRTP profile; - * \param type - sought component type; - * \param id - sought component ID. - * \return - * - component position - if component was found; - * -1 - if the component with the specified ID can't be found in profile. - */ -int zrtp_profile_find(const zrtp_profile_t* profile, zrtp_crypto_comp_t type, uint8_t id); - -/* \} */ - -/** - * \defgroup zrtp_main_rng Random Number Generation - * \ingroup zrtp_api - * \{ - * The generation of cryptographic key material is a highly sensitive process. To do this, you need - * high entropy random numbers that an attacker cannot predict. This section \ref rng gives basic - * knowliges andbot the RNG and it's implementation in libzrtp. - * \warning - * \ref rng \c MUST be read by every developer using libzrtp. - */ - -/** - * \brief Entropy accumulation routine - * - * The random number generation scheme is described in detail in chapter \ref XXX. This function - * gets \c length bytes of entropy from \c buffer and hashes it into the special storage. This - * function should be called periodically from the user's space to increase entropy quality. - * \warning - * RNG is a very important and sensitive component of the crypto-system. Please, pay attention to - * \ref rng. - * \param zrtp - libzrtp global context; - * \param buffer - pointer to the buffer with entropy for accumulating; - * \param length - entropy size in bytes. - * \return: number of hashed bytes. - */ -int zrtp_entropy_add(zrtp_global_t* zrtp, const unsigned char *buffer, uint32_t length); - -/** - * \brief Random string generation - * - * zrtp_randstr() generates \c length bytes of "random" data. We say "random" because the - * "randomness" of the generated sequence depends on the quality of the entropy passed to - * zrtp_entropy_add(). If the user provides "good" entropy, zrtp_randstr() generates sufficiently - * "random" data. - * - * \param zrtp - libzrtp global context; - * \param buffer - buffer into which random data will be generated; - * \param length - length of required sequence in bytes. - * \return - * - length of generated sequence in bytes or -1 in case of error - * \sa \ref rng - */ -int zrtp_randstr(zrtp_global_t* zrtp, unsigned char *buffer, uint32_t length); - -int zrtp_randstr2(unsigned char *buffer, uint32_t length); - -/* \} */ - -#if defined(__cplusplus) -} -#endif - -#endif /* __ZRTP_H__ */ diff --git a/libs/libzrtp/include/zrtp_base.h b/libs/libzrtp/include/zrtp_base.h deleted file mode 100644 index 2b03352d5b..0000000000 --- a/libs/libzrtp/include/zrtp_base.h +++ /dev/null @@ -1,208 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - -#ifndef __ZRTP_BASE_H__ -#define __ZRTP_BASE_H__ - -#include "zrtp_config.h" - -typedef double uint64_t_; - -typedef uint8_t zrtp_uchar4_t[4]; -typedef uint8_t zrtp_uchar8_t[8]; -typedef uint8_t zrtp_uchar12_t[12]; -typedef uint8_t zrtp_uchar16_t[16]; -typedef uint8_t zrtp_uchar32_t[32]; -typedef uint8_t zrtp_uchar64_t[64]; -typedef uint8_t zrtp_uchar128_t[128]; -typedef uint8_t zrtp_uchar256_t[256]; -typedef uint8_t zrtp_uchar1024_t[1024]; - -typedef uint32_t zrtp_id_t; - -typedef struct zrtp_profile_t zrtp_profile_t; -typedef struct zrtp_stream_t zrtp_stream_t; -typedef struct zrtp_session_t zrtp_session_t; -typedef struct zrtp_global_t zrtp_global_t; - -typedef struct zrtp_protocol_t zrtp_protocol_t; -typedef struct zrtp_srtp_ctx_t zrtp_srtp_ctx_t; -typedef struct zrtp_shared_secret_t zrtp_shared_secret_t; -typedef struct zrtp_retry_task_t zrtp_retry_task_t; - -typedef struct zrtp_hash_t zrtp_hash_t; -typedef struct zrtp_cipher_t zrtp_cipher_t; -typedef struct zrtp_auth_tag_length_t zrtp_auth_tag_length_t; -typedef struct zrtp_pk_scheme_t zrtp_pk_scheme_t; -typedef struct zrtp_sas_scheme_t zrtp_sas_scheme_t; -typedef struct zrtp_sig_scheme_t zrtp_sig_scheme_t; - -typedef struct zrtp_mutex_t zrtp_mutex_t; -typedef struct zrtp_sem_t zrtp_sem_t; - -typedef struct zrtp_stream_info_t zrtp_stream_info_t; -typedef struct zrtp_session_info_t zrtp_session_info_t; - -#include "sha2.h" -#define MD_CTX sha512_ctx -#define MD_Update(a,b,c) sha512_hash((const unsigned char *)(b),c,a) - - -/** - * \brief Function computing minimum value - * - * This macro returns the lesser of two values. If the numbers are equal, either of them is returned. - * - * \param left - first value for comparison; - * \param right - second value for comparison. - * \return - * - lesser of compared numbers. - */ -#define ZRTP_MIN(left, right) ((left < right) ? left : right) - - -/*! - * \brief zrtp_htonXX, zrtp_ntohXX - convert values between host and network - * byte order - * - * To avoid ambiguities and difficulties with compilation on various platforms, - * we designed our own swap functions. Byte order detection is based on zrtp_system.h. - * - * On the i80x86 the host byte order is little-endian (least significant byte - * first), whereas the network byte order, as used on the Internet, is - * big-endian (most significant byte first). - */ - -uint16_t zrtp_swap16(uint16_t x); -uint32_t zrtp_swap32(uint32_t x); -uint64_t zrtp_swap64(uint64_t x); - -#if ZRTP_BYTE_ORDER == ZBO_BIG_ENDIAN -/*! Converts 16 bit unsigned integer to network byte order */ -#define zrtp_hton16(x) (x) -/*! Converts 32 bit unsigned integer to network byte order */ -#define zrtp_hton32(x) (x) -/*! Converts 64 bit unsigned integer to network byte order */ -#define zrtp_hton64(x) (x) - -/*! Converts 16 bit unsigned integer to host byte order */ -#define zrtp_ntoh16(x) (x) -/*! Converts 32 bit unsigned integer to host byte order */ -#define zrtp_ntoh32(x) (x) -/*! Converts 64 bit unsigned integer to host byte order */ -#define zrtp_ntoh64(x) (x) -#else /* ZBO_BIG_ENDIAN */ -/*! Converts 16 bit unsigned integer to network byte order */ -#define zrtp_hton16(x) (zrtp_swap16(x)) -/*! Converts 32 bit unsigned integer to network byte order */ -#define zrtp_hton32(x) (zrtp_swap32(x)) -/*! Converts 64 bit unsigned integer to network byte order */ -#define zrtp_hton64(x) (zrtp_swap64(x)) - -/*! Converts 16 bit unsigned integer to host byte order */ -#define zrtp_ntoh16(x) (zrtp_swap16(x)) -/*! Converts 32 bit unsigned integer to host byte order */ -#define zrtp_ntoh32(x) (zrtp_swap32(x)) -/*! Converts 64 bit unsigned integer to host byte order */ -#define zrtp_ntoh64(x) (zrtp_swap64(x)) -#endif - - -/* - * 128 and 256-bit structures used in Ciphers and SRTP module - */ -typedef union - { - uint8_t v8[16]; - uint16_t v16[8]; - uint32_t v32[4]; - uint64_t v64[2]; - } zrtp_v128_t; - -typedef union - { - uint8_t v8[32]; - uint16_t v16[16]; - uint32_t v32[8]; - uint64_t v64[4]; - } zrtp_v256_t; - -/* - * The following macros define the data manipulation functions. - * - * If DATATYPES_USE_MACROS is defined, then these macros are used directly (and - * function-call overhead is avoided). Otherwise, the macros are used through - * the functions defined in datatypes.c (and the compiler provides better - * warnings). - */ - -#define _zrtp_v128_xor(z, x, y) \ -( \ -(z)->v32[0] = (x)->v32[0] ^ (y)->v32[0], \ -(z)->v32[1] = (x)->v32[1] ^ (y)->v32[1], \ -(z)->v32[2] = (x)->v32[2] ^ (y)->v32[2], \ -(z)->v32[3] = (x)->v32[3] ^ (y)->v32[3] \ -) - -#define _zrtp_v128_get_bit(x, bit) \ -( \ -( (((x)->v32[(bit) >> 5]) >> ((bit) & 31)) & 1) \ -) - -#define zrtp_bitmap_get_bit(x, bit) \ -( \ -( (((x)[(bit) >> 3]) >> ((bit) & 7) ) & 1) \ -) - -#define zrtp_bitmap_set_bit(x, bit) \ -( \ -( (((x)[(bit) >> 3])) |= ((uint8_t)1 << ((bit) & 7)) ) \ -) - -#define zrtp_bitmap_clear_bit(x, bit) \ -( \ -( (((x)[(bit) >> 3])) &= ~((uint8_t)1 << ((bit) & 7)) ) \ -) - -void zrtp_bitmap_left_shift(uint8_t *x, int width_bytes, int index); - -void zrtp_v128_xor(zrtp_v128_t *z, zrtp_v128_t *x, zrtp_v128_t *y); - - - -//WIN64 { -#if (ZRTP_PLATFORM == ZP_WIN32_KERNEL) - -#ifdef WIN64 // For 64-bit apps - -unsigned __int64 __rdtsc(void); -#pragma intrinsic(__rdtsc) -#define _RDTSC __rdtsc - -#else // For 32-bit apps - -#define _RDTSC_STACK(ts) \ -__asm rdtsc \ -__asm mov DWORD PTR [ts], eax \ -__asm mov DWORD PTR [ts+4], edx - -__inline unsigned __int64 _inl_rdtsc32() { - unsigned __int64 t; - _RDTSC_STACK(t); - return t; -} -#define _RDTSC _inl_rdtsc32 - -#endif - -#endif -//WIN64 } - - -#endif /*__ZRTP_BASE_H__*/ diff --git a/libs/libzrtp/include/zrtp_config.h b/libs/libzrtp/include/zrtp_config.h deleted file mode 100644 index dbfad31f7d..0000000000 --- a/libs/libzrtp/include/zrtp_config.h +++ /dev/null @@ -1,271 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - -#ifndef __ZRTP_CONFIG_H__ -#define __ZRTP_CONFIG_H__ - -#include "zrtp_config_user.h" - -/* - * ZRTP PLATFORM DETECTION - * If platworm is not specified manually in zrtp_config_user.h - try to detect it aytomatically - */ -#if !defined(ZRTP_PLATFORM) -# if defined(ANDROID_NDK) -# define ZRTP_PLATFORM ZP_ANDROID -# elif defined(__FreeBSD__) -# define ZRTP_PLATFORM ZP_BSD -# elif defined(linux) || defined(__linux__) || defined(__linux) -# include -# define ZRTP_PLATFORM ZP_LINUX -# elif defined(__MACOSX__) || defined (__APPLE__) || defined (__MACH__) -# define ZRTP_PLATFORM ZP_DARWIN -# elif defined(_WIN32_WCE) || defined(UNDER_CE) -# include -# define ZRTP_PLATFORM ZP_WINCE -# elif defined(__SYMBIAN32__) -# define ZRTP_PLATFORM ZP_SYMBIAN -# elif defined(_WIN32) || defined(__WIN32__) || defined(_WIN64) || defined(WIN32) || defined(__TOS_WIN__) -# if defined(__BUILDMACHINE__) && (__BUILDMACHINE__ == WinDDK) -# define ZRTP_PLATFORM ZP_WIN32_KERNEL -# elif defined(_WIN64) -# define ZRTP_PLATFORM ZP_WIN32 -# else -# define ZRTP_PLATFORM ZP_WIN32 -# endif -# endif -#endif - -#if ZRTP_PLATFORM == ZP_ANDROID -# include "zrtp_config_android.h" -#elif (ZRTP_PLATFORM == ZP_LINUX) || (ZRTP_PLATFORM == ZP_DARWIN) || (ZRTP_PLATFORM == ZP_BSD) || defined(ZRTP_AUTOMAKE) -# include "zrtp_config_unix.h" -#elif (ZRTP_PLATFORM == ZP_WIN32) || (ZRTP_PLATFORM == ZP_WIN32_KERNEL) || (ZRTP_PLATFORM == ZP_WINCE) -# include "zrtp_config_win.h" -#elif (ZRTP_PLATFORM == ZP_SYMBIAN) -# include "zrtp_config_symbian.h" -#endif - -#if !defined(ZRTP_PLATFORM) -# error "Libzrtp can't detect software platform: use manual setup in zrtp_config_user.h" -#endif - -#if ZRTP_HAVE_LINUX_VERSION_H == 1 -#include -#endif -#if ZRTP_HAVE_ASM_TYPES_H == 1 -#include -#endif - -/* - * ZRTP BYTEORDER DETECTION - * If the byte order is not specified manually in zrtp_config_user.h - try to detect it automatically - */ -#if !defined(ZRTP_BYTE_ORDER) - -#if defined(_i386_) || defined(i_386_) || defined(_X86_) || defined(x86) || defined(__i386__) || \ - defined(__i386) || defined(_M_IX86) || defined(__I86__) -/* - * Generic i386 processor family, little-endian - */ -#define ZRTP_BYTE_ORDER ZBO_LITTLE_ENDIAN - -#elif defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(_AMD64_) -/* - * AMD 64bit processor, little endian - */ -#define ZRTP_BYTE_ORDER ZBO_LITTLE_ENDIAN - -#elif defined( __sparc__) || defined(__sparc) -/* - * Sun Sparc, big endian - */ -#define ZRTP_BYTE_ORDER ZBO_BIG_ENDIAN - -#elif defined(__AARCH64EB__) -/* - * aarch64, big endian - */ -#define ZRTP_BYTE_ORDER ZBO_BIG_ENDIAN - -#elif defined(ARM) || defined(_ARM_) || defined(ARMV4) || defined(__arm__) || defined(__AARCH64EL__) -/* - * ARM, default to little endian - */ -#define ZRTP_BYTE_ORDER ZBO_LITTLE_ENDIAN - -#elif defined(__powerpc) || defined(__powerpc__) || defined(__POWERPC__) || defined(__ppc__) || \ - defined(_M_PPC) || defined(_ARCH_PPC) -/* - * PowerPC, big endian - */ -#define ZRTP_BYTE_ORDER ZBO_BIG_ENDIAN - -#elif defined(__MIPSEB__) -/* - * mips, big endian - */ -#define ZRTP_BYTE_ORDER ZBO_BIG_ENDIAN - -#elif defined(__MIPSEL__) -/* - * mips, little endian - */ -#define ZRTP_BYTE_ORDER ZBO_LITTLE_ENDIAN - -#elif defined(__e2k__) -/* - * Elbrus, little endian - */ -#define ZRTP_BYTE_ORDER ZBO_LITTLE_ENDIAN - -#endif /* Automatic byte order detection */ - -#endif - -#if !defined(ZRTP_BYTE_ORDER) -# error "Libzrtp can't detect byte order: use manual setup in zrtp_config_user.h" -#endif - - -/* - * Define Unaligned structure for target platform - */ -#if (ZRTP_PLATFORM == ZP_WINCE) -# define ZRTP_UNALIGNED(type) UNALIGNED type -#else -# define ZRTP_UNALIGNED(type) type -#endif - - -/* - * Define basic literal types for libzrtp - * We use this definitions in SRTP, AES and Hash implementation - */ -#if (ZRTP_PLATFORM != ZP_WIN32_KERNEL) -# if ZRTP_HAVE_STDLIB_H == 1 -# include -# endif -# if ZRTP_HAVE_STDINT_H == 1 -# include -# endif -# if ZRTP_HAVE_INTTYPES_H == 1 -# include -# endif -# if ZRTP_HAVE_SYS_TYPES_H == 1 -# include -# endif -# if ZRTP_HAVE_SYS_INT_TYPES_H == 1 -# include -# endif -# if ZRTP_HAVE_MACHINE_TYPES_H == 1 -# include -# endif -#endif - -#if (ZRTP_PLATFORM == ZP_WINCE) || (ZRTP_PLATFORM == ZP_SYMBIAN) || (ZRTP_PLATFORM == ZP_ANDROID) -# define ALIGNMENT_32BIT_REQUIRED -#endif - -#ifdef ZRTP_HAVE_UINT64_T -# if ZRTP_HAVE_UINT64_T == 0 -# if defined(WIN32) || defined(WIN64) -# if defined(_MSC_VER) && (_MSC_VER < 1310) - typedef __int64 uint64_t; -# else - typedef unsigned long long uint64_t; -# endif -# else -# if SIZEOF_UNSIGNED_LONG == 8 - typedef unsigned long uint64_t; -# elif SIZEOF_UNSIGNED_LONG_LONG == 8 - typedef unsigned long long uint64_t; -# else -# define ZRTP_NO_64BIT_MATH 1 -# endif -# endif /* WIN32 */ -# endif -#endif - -#ifdef ZRTP_HAVE_INT64_T -# if ZRTP_HAVE_INT64_T == 0 -# if defined(WIN32) || defined(WIN64) -# if defined(_MSC_VER) && (_MSC_VER < 1310) - typedef __int64 int64_t; -# else - typedef long long int64_t; -# endif -# else -# if SIZEOF_UNSIGNED_LONG == 8 - typedef long int64_t; -# elif SIZEOF_UNSIGNED_LONG_LONG == 8 - typedef long long int64_t; -# else -# define ZRTP_NO_64BIT_MATH 1 -# endif -# endif /* WIN32 */ -# endif -#endif - -#define SIZEOF_UNSIGNED_LONG_LONG 8 - -#if defined(WIN32) || defined(WIN64) -# if defined(_MSC_VER) && (_MSC_VER < 1310) -# define li_64(h) 0x##h##ui64 -# else -# define li_64(h) 0x##h##ull -# endif -#else -# if SIZEOF_UNSIGNED_LONG == 8 -# define li_64(h) 0x##h##ul -# elif SIZEOF_UNSIGNED_LONG_LONG == 8 -# define li_64(h) 0x##h##ull -# else -# define ZRTP_NO_64BIT_MATH 1 -# endif -#endif /* WIN32 */ - - -#ifdef ZRTP_HAVE_UINT8_T -# if ZRTP_HAVE_UINT8_T == 0 - typedef unsigned char uint8_t; -# endif -#endif - -#ifdef ZRTP_HAVE_UINT16_T -# if ZRTP_HAVE_UINT16_T == 0 - typedef unsigned short int uint16_t; -# endif -#endif - -#ifdef ZRTP_HAVE_UINT32_T -# if ZRTP_HAVE_UINT32_T == 0 - typedef unsigned int uint32_t; -# endif -#endif - -#ifdef ZRTP_HAVE_INT8_T -# if ZRTP_HAVE_INT8_T == 0 - typedef char int8_t; -# endif -#endif - -#ifdef ZRTP_HAVE_INT16_T -# if ZRTP_HAVE_INT16_T == 0 - typedef short int int16_t; -# endif -#endif - -#ifdef ZRTP_HAVE_INT32_T -# if ZRTP_HAVE_INT32_T == 0 - typedef int int32_t; -# endif -#endif - -#endif /*__ZRTP_CONFIG_H__ */ diff --git a/libs/libzrtp/include/zrtp_config_android.h b/libs/libzrtp/include/zrtp_config_android.h deleted file mode 100644 index 06d379939e..0000000000 --- a/libs/libzrtp/include/zrtp_config_android.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - -#ifndef ZRTP_SYMB_CONFIG_H__ -#define ZRTP_SYMB_CONFIG_H__ - -#ifndef ZRTP_HAVE_STDIO_H -# define ZRTP_HAVE_STDIO_H 1 -#endif - -#ifndef ZRTP_HAVE_STDARG_H -# define ZRTP_HAVE_STDARG_H 1 -#endif - - -#ifndef NO_ASSERT_H -# define NO_ASSERT_H 1 -#endif - -#ifndef NO_STDLIB_H -# define NO_STDLIB_H 0 -#endif -//#define ZRTP_HAVE_INTTYPES_H 1 -#ifndef ZRTP_HAVE_UNISTD_H -# define ZRTP_HAVE_UNISTD_H 1 -#endif - -#ifndef ZRTP_HAVE_PTHREAD_H -# define ZRTP_HAVE_PTHREAD_H 1 -#endif - -#ifndef ZRTP_HAVE_SEMAPHORE_H -#define ZRTP_HAVE_SEMAPHORE_H 1 -#endif - -#ifndef ZRTP_HAVE_ERRNO_H -#define ZRTP_HAVE_ERRNO_H 1 -#endif - -#ifndef ZRTP_HAVE_FCNTL_H -#define ZRTP_HAVE_FCNTL_H 1 -#endif - -#ifndef ZRTP_HAVE_SYS_TIME_H -# define ZRTP_HAVE_SYS_TIME_H 1 -#endif - - -#ifndef ZRTP_HAVE_SYS_TYPES_H -# define ZRTP_HAVE_SYS_TYPES_H 1 -#endif - - -#ifndef ZRTP_HAVE_INTTYPES_H -# define ZRTP_HAVE_INTTYPES_H 1 -#endif - -#ifndef ZRTP_HAVE_STDINT_H -# define ZRTP_HAVE_STDINT_H 1 -#endif - -#ifndef ZRTP_HAVE_LINUX_VERSION_H -# define ZRTP_HAVE_LINUX_VERSION_H 0 -#endif - - -// (ZRTP_PLATFORM == ZP_ANDROID) - - -#define ZRTP_HAVE_INT64_T 1 -#define ZRTP_HAVE_INT32_T 1 -#define ZRTP_HAVE_INT16_T 1 -#define ZRTP_HAVE_INT8_T 1 - -#define ZRTP_HAVE_UINT64_T 1 -#define ZRTP_HAVE_UINT32_T 1 -#define ZRTP_HAVE_UINT16_T 1 -#define ZRTP_HAVE_UINT8_T 1 - -#define ZRTP_BYTE_ORDER ZBO_LITTLE_ENDIAN - -#define SIZEOF_UNSIGNED_LONG 4 -#define SIZEOF_UNSIGNED_LONG_LONG 8 - -#define ZRTP_INLINE inline - -#define ZRTP_USE_BUILTIN_CACHE 1 -#define ZRTP_USE_BUILTIN_SCEHDULER 1 -#undef ZRTP_USE_STACK_MINIM -#define ZRTP_USE_STACK_MINIM 1 -#define ALIGNMENT_32BIT_REQUIRED - -#endif /* ZRTP_WIN_CONFIG_H__ */ diff --git a/libs/libzrtp/include/zrtp_config_symbian.h b/libs/libzrtp/include/zrtp_config_symbian.h deleted file mode 100644 index 1cda65dbb2..0000000000 --- a/libs/libzrtp/include/zrtp_config_symbian.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - -#ifndef ZRTP_SYMB_CONFIG_H__ -#define ZRTP_SYMB_CONFIG_H__ - - -/* - * Used to map system integer types to zrtp integer definitions. - * Define to 1 if you have the header file. - */ -#undef ZRTP_HAVE_INTTYPES_H - -/* - * This header is needed for operations with binary file in deefault realization - * of the secrets' cache. Can be eliminated if default cache isn't used. - * Define to 1 if you have the header file. - */ -#ifndef ZRTP_HAVE_STDIO_H -# define ZRTP_HAVE_STDIO_H 1 -#endif - -#ifndef ZRTP_HAVE_STDARG_H -# define ZRTP_HAVE_STDARG_H 1 -#endif - -/* - * Used by bnlib, but we don't need this on Symbian platform. - */ -#ifndef NO_ASSERT_H -# define NO_ASSERT_H 1 -#endif - -/* - * Used by bnlib. We have stdlib in Symbian platform - set it to 1. - */ -#ifndef NO_STDLIB_H -# define NO_STDLIB_H 0 -#endif - -#ifndef ZRTP_HAVE_SYS_TIME_H -# define ZRTP_HAVE_SYS_TIME_H 1 -#endif - - -#define ZRTP_HAVE_INT64_T 0 -#define ZRTP_HAVE_INT32_T 0 -#define ZRTP_HAVE_INT16_T 0 -#define ZRTP_HAVE_INT8_T 0 - -#define ZRTP_HAVE_UINT64_T 0 -#define ZRTP_HAVE_UINT32_T 0 -#define ZRTP_HAVE_UINT16_T 0 -#define ZRTP_HAVE_UINT8_T 0 - -#define ZRTP_BYTE_ORDER ZBO_BIG_ENDIAN - -#define SIZEOF_UNSIGNED_LONG 4 -#define SIZEOF_UNSIGNED_LONG_LONG 8 - -#define ZRTP_INLINE static __inline - -#endif /* ZRTP_WIN_CONFIG_H__ */ diff --git a/libs/libzrtp/include/zrtp_config_user.h b/libs/libzrtp/include/zrtp_config_user.h deleted file mode 100644 index 2989878d08..0000000000 --- a/libs/libzrtp/include/zrtp_config_user.h +++ /dev/null @@ -1,187 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - -/** - * @file zrtp_config_user.h - * @brief libzrtp user configuration routine - */ - -#ifndef __ZRTP_CONFIG_USER_H__ -#define __ZRTP_CONFIG_USER_H__ - -/** - * \defgroup zrtp_config Build Configuration - * \{ - * - * As libzrtp based on few OS dependent components, target platform and byte-order must be defined - * on compilation level. libzrtp provides automatic platform and byte-order detection. Developer - * needs to define these parameters manually in very specific cases only. - * - * libzrtp originaly supports folowwing platforms: - * - 32/64-bit Windows platform; - * - Windows kernel mode; - * - Apple Mac OS X and iPhone; - * - Linux and *nix platforms; - * - Symbian OS. - * - * In order to specify platform manually, developer should define ZRTP_PLATFORM value. If - * ZRTP_PLATFORM is not defined - libzrtp will try to detect it automatically (see zrtp_config.h). - * - * In order to specify platform byte-order manually, developer should define ZRTP_BYTE_ORDER value. - * If ZRTP_BYTE_ORDER is not defined - libzrtp will try to detect it automatically. - */ - -/** \brief Constant to define ZRTP Windows 32-bit platform */ -#define ZP_WIN32 100 -/** \brief Constant to define ZRTP Windows 64-bit platform */ -#define ZP_WIN64 106 -/** \brief Constant to define ZRTP Windows Kernel mode */ -#define ZP_WIN32_KERNEL 101 -/** \brief Constant to define ZRTP Windows CE platform */ -#define ZP_WINCE 102 -/** \brief Constant to define Linux and *nux platforms */ -#define ZP_LINUX 103 -/** \brief Constant to define Mac OS X Platform */ -#define ZP_DARWIN 104 -/** \brief Constant to define Symbian OS */ -#define ZP_SYMBIAN 105 -/** \brief Constant to define ZRTP BSD platform */ -#define ZP_BSD 107 -/** \brief Constant to define ZRTP Android platform */ -#define ZP_ANDROID 108 - -/** \brief Define Platform manually there */ -//#undefine ZRTP_PLATFORM - - -/** \brief Constant to define Big Endian Platform */ -#define ZBO_BIG_ENDIAN 0x4321 -/** \brief Constant to define Little Endian Platform */ -#define ZBO_LITTLE_ENDIAN 0x1234 - -/** \brief Define Platform Byte Order manually there */ -//#define ZRTP_BYTE_ORDER - -/** \brief Defines the max length in bytes of a binary SAS digest */ -#ifndef ZRTP_SAS_DIGEST_LENGTH -#define ZRTP_SAS_DIGEST_LENGTH 32 -#endif - -/** \brief Defines maximum number of ZRTP streams within one session */ -#ifndef ZRTP_MAX_STREAMS_PER_SESSION -#define ZRTP_MAX_STREAMS_PER_SESSION 2 -#endif - -/** - * \brief Allows to build libzrtp against external srtp encryption library - * - * The latest version of libzrtp, starting with 0.3.9, supplies a built-in mechanism for SRTP - * encryption. However, if for some reason during development it is neccesary to use an external - * library, this flag must be set. - */ -#ifndef ZRTP_USE_EXTERN_SRTP -#define ZRTP_USE_EXTERN_SRTP 0 -#endif - -/** - * \brief Build libzrtp with minimum stack usage - * - * Set to 1 you build libzrtp in environment with strong limitation of stack size (Mobile platforms - * or in kernel mode). When this flag is set, some static data allocation will be changed to - * dynamic. The size of these data doesn't matter in "regular" PC applications, but on mobile - * platforms and in kernel mode, where the stack size is critical, libzrtp must work with optimized - * data. - */ -#ifndef ZRTP_USE_STACK_MINIM -#define ZRTP_USE_STACK_MINIM 0 -#endif - -#ifndef ZRTP_USE_BUILTIN -#define ZRTP_USE_BUILTIN 1 -#endif - -#ifndef ZRTP_USE_BUILTIN_SCEHDULER -#define ZRTP_USE_BUILTIN_SCEHDULER 1 -#endif - -#ifndef ZRTP_USE_BUILTIN_CACHE -# if defined(_WIN32) || defined(__WIN32__) || defined(_WIN64) || defined(WIN32) || defined(__TOS_WIN__) -# if defined(__BUILDMACHINE__) && (__BUILDMACHINE__ == WinDDK) -# define ZRTP_USE_BUILTIN_CACHE 1 -# else -# define ZRTP_USE_BUILTIN_CACHE 0 -# endif -# else -# define ZRTP_USE_BUILTIN_CACHE 1 -# endif -#endif - -#ifndef ZRTP_DEBUG_WITH_PJSIP -#define ZRTP_DEBUG_WITH_PJSIP 0 -#endif - -/** - * \brief Set to 1 if you build libzrtp against libzrtp-s. - * - * CSD-mode was implemented to support new ZRTP/S protocol designed by KHAMSA SA, Via Giacometti 1, - * CH-6900, Lugano - info@khamsa.ch. and Phil Zimmermann. ZRTP/S allows to make secure ZRTP calls - * over CSD channels. This option affect enterprise version of the library only. - */ -#ifndef ZRTP_BUILD_FOR_CSD -#define ZRTP_BUILD_FOR_CSD 0 -#endif - -/** - * \brief Maximum number of Preshared exchanges allowed since last retain secret update - * - * Preshared key exchange mode has lot of weaknesses comparing to DH. And one of them - lack of key - * continuity. Preshared mode is not recommended unless there is a strong necessity in using it - * (slow CPU device, low-latency channel). - * - * To minimize risk of using Preshared exchanges, libzrtp automatically limits number for preshared - * connection available for the same instance of RS value. In other words, libzrtp forces DH exchange - * every \c ZRTP_PRESHARED_MAX_ALLOWED calls. - */ -#define ZRTP_PRESHARED_MAX_ALLOWED 20 - -/** - * \brief Defines libzrtp log-level - * - * Defines maximum log level for libzrtp: log-level 3 contains debug messages, 2 - warnings and - * software errors, 1 - security issues. If you set this option to 0 - libzrtp will not debug - * output and will not even make a log function calls. - */ -#ifndef ZRTP_LOG_MAX_LEVEL -#define ZRTP_LOG_MAX_LEVEL 3 -#endif - -/** - * \brief Enables SRTP debug output - * - * \warning! ZRTP crypto debug logs may include security sensitive information and cause security - * weakness in the system. Enable SRTP debug logging only when it necessary. - */ -#ifndef ZRTP_DEBUG_SRTP_KEYS -#define ZRTP_DEBUG_SRTP_KEYS 0 -#endif - -/** - * \brief Enables ZRTP Crypto debug logging. - * - * \warning! ZRTP crypto debug logs may include security sensitive information and cause security - * weakness in the system. Enable ZRTP Protocol debug logging only when it necessary. - */ -#ifndef ZRTP_DEBUG_ZRTP_KEYS -#define ZRTP_DEBUG_ZRTP_KEYS 0 -#endif - - -/* \} */ - -#endif /*__ZRTP_CONFIG_USER_H__*/ diff --git a/libs/libzrtp/include/zrtp_config_win.h b/libs/libzrtp/include/zrtp_config_win.h deleted file mode 100644 index 15135a50bd..0000000000 --- a/libs/libzrtp/include/zrtp_config_win.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - -#ifndef ZRTP_WIN_CONFIG_H__ -#define ZRTP_WIN_CONFIG_H__ - -#define _CRT_SECURE_NO_WARNINGS 1 -#pragma warning(disable: 4068) - -#if !(defined(__BUILDMACHINE__) && __BUILDMACHINE__ == WinDDK) -#include -#endif - -/* - * Used to map system integer types to zrtp integer definitions. - * Define to 1 if you have the header file. - */ -#undef ZRTP_HAVE_INTTYPES_H - -#define ZRTP_HAVE_STRING_H 1 - -/* - * This header is needed for operations with binary file in deefault realization - * of the secrets' cache. Can be eliminated if default cache isn't used. - * Define to 1 if you have the header file. - */ -#ifndef ZRTP_HAVE_STDIO_H -# define ZRTP_HAVE_STDIO_H 1 -#endif - -#ifndef ZRTP_HAVE_STDARG_H -# define ZRTP_HAVE_STDARG_H 1 -#endif - -/* - * Used by bnlib, but we don't need this on Windows platform. - */ -#ifndef NO_ASSERT_H - #define NO_ASSERT_H 1 -#endif - -/* - * Used by bnlib. We have stdlib in any Windows platform - set it to 1. - */ -#ifndef NO_STDLIB_H - #define NO_STDLIB_H 0 -#endif - - -#define ZRTP_HAVE_INT64_T 0 -#define ZRTP_HAVE_INT32_T 0 -#define ZRTP_HAVE_INT16_T 0 -#define ZRTP_HAVE_INT8_T 0 - -#define ZRTP_HAVE_UINT64_T 0 -#define ZRTP_HAVE_UINT32_T 0 -#define ZRTP_HAVE_UINT16_T 0 -#define ZRTP_HAVE_UINT8_T 0 - -#define SIZEOF_UNSIGNED_LONG 4 -#define SIZEOF_UNSIGNED_LONG_LONG 8 - -#define ZRTP_INLINE static __inline - -#define ZRTP_VERSION "0.90" - - -#endif /* ZRTP_WIN_CONFIG_H__ */ diff --git a/libs/libzrtp/include/zrtp_crypto.h b/libs/libzrtp/include/zrtp_crypto.h deleted file mode 100644 index bb191bdedd..0000000000 --- a/libs/libzrtp/include/zrtp_crypto.h +++ /dev/null @@ -1,656 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - -#ifndef __ZRTP_CRYPTO_H__ -#define __ZRTP_CRYPTO_H__ - -#include "bn.h" -#include "zrtp_types.h" -#include "zrtp_error.h" -#include "zrtp_engine.h" -#include "zrtp_config_user.h" -#include "zrtp_ec.h" - - - -/*! - * \defgroup crypto Library crypto-components - * \ingroup zrtp_dev - * - * This section describes functions and data types for managing crypto-components. - * All these functions and structures are used by the libZRTP kernel for the - * built-in crypt-components management. The developer has the option of - * implementing and integrating her own components into the library. This is not - * a full manual on creating crypto-components. Its purpose is only to elucidate - * the library functionality. - * - * The concept behind crypto components is similar to that of classes in object - * oriented programming. The components are defined as structures and - * manipulated by functions. Component attributes are stored in 'contexts', and - * are defined during initialization. Resources allocated at initialization are - * freed with the 'free' function. - * - * Components are divided into 5 functional groups (component types): - * - ciphers; - * - hash/hmac components; - * - public key exchange schemes; - * - components defined SRTP authentication scheme; - * - SAS calculation schemes. - * Within a group, components are distinguished by integer identifiers and by - * their defined functionality. So to fully identify a component, you need to - * know its type and its identifier. (For example an AES cipher with a 128 bit - * key is defined as: ZRTP_CC_CIPHER, zrtp_cipher_id_t::ZRTP_CIPHER_AES128). - * The high number of components means that every component must have a minimal - * set of attributes and functions: type identifier, and function initialization - * and deinitialization. The base type of all components is zrtp_comp_t. Every - * new component MUST start with definitions of this structure strictly in the - * given order. - * \warning - * Every crypto-component included in libZRTP was developed and tested by - * professionals. Its presence is functionally based. Using only the built-in - * components gives you 100% crypto-strength and the guarantee of the fully - * tested code. Never use your own components without strong reasons. If you - * have noticed the absence of any important component in the library, contact - * the developers. Reasonable offers will be considered for implementation in - * the following versions. - * \{ - */ - - -/*============================================================================*/ -/* Types of libZRTP crypto-components definitions */ -/*============================================================================*/ - -/*! - * \brief Enumeration for crypto-components types definition - */ -typedef enum zrtp_crypto_comp_t -{ - ZRTP_CC_HASH = 1, /*!< hash calculation schemes */ - ZRTP_CC_SAS = 2, /*!< short autentification scheme components */ - ZRTP_CC_CIPHER = 3, /*!< ciphers */ - ZRTP_CC_PKT = 4, /*!< public key exchange scheme */ - ZRTP_CC_ATL = 5, -}zrtp_crypto_comp_t; - - -/*! - * This ID with code 0 is used as an error signal by all crypto-components - * groups to indicate a wrongly defined component identifier. - */ -#define ZRTP_COMP_UNKN 0 - -/*! Defines types of hash functions */ -typedef enum zrtp_hash_id_t -{ - ZRTP_HASH_SHA256 = 1, - ZRTP_HASH_SHA384 = 2 -} zrtp_hash_id_t; - -/*! Defines types of ciphers */ -typedef enum zrtp_cipher_id_t -{ - ZRTP_CIPHER_AES128 = 1, - ZRTP_CIPHER_AES256 = 2 -} zrtp_cipher_id_t; - -/*! Defines SRTP authentication schemes */ -typedef enum zrtp_atl_id_t -{ - ZRTP_ATL_HS32 = 1, - ZRTP_ATL_HS80 = 2 -} zrtp_atl_id_t; - -/*! Defines public key exchange schemes */ -/* WARNING! don't change order of the PK components definitions! */ -typedef enum zrtp_pktype_id_t -{ - ZRTP_PKTYPE_PRESH = 1, - ZRTP_PKTYPE_MULT = 2, - ZRTP_PKTYPE_DH2048 = 3, - ZRTP_PKTYPE_EC256P = 4, - ZRTP_PKTYPE_DH3072 = 5, - ZRTP_PKTYPE_EC384P = 6, - ZRTP_PKTYPE_EC521P = 7, - ZRTP_PKTYPE_DH4096 = 8 -} zrtp_pktype_id_t; - -/*! Defines modes of short authentication scheme calculation */ -typedef enum zrtp_sas_id -{ - ZRTP_SAS_BASE32 = 1, - ZRTP_SAS_BASE256 = 2 -} zrtp_sas_id_t; - - -/*! - * \brief Global structure for all crypto-component types. - * \warning All developed components must have these 4 fields at the beginning. - */ -typedef struct zrtp_comp_t -{ - zrtp_uchar4_t type; /*!< 4-character symbolic name defined by ZRTP Draft */ - uint8_t id; /*!< Integer component identifier */ - zrtp_global_t* zrtp;/*!< ZRTP global context */ - - /*! - * \brief Component initiation function. - * This function body is for holding component initialization code. libzrtp - * calls the function before using a component, at its registration. If the - * component does not require additional actions for initialization, the - * value of this field can be NULL. - * \param self - self-pointer for fast access to structure data. - * \return - * - zrtp_status_ok - if initialized successfully; - * - one of \ref zrtp_status_t errors - if initialization failed. - */ - zrtp_status_t (*init)(void* self); - - /*! - * \brief Component deinitializtion function. - * This function body is for holding component deinitialization code and - * all code for releasing allocated resources. libzrtp calls the function - * at the end of component use, at context deinitialization. If the component - * does not require additional actions for deinitialization, the value of - * this field can be NULL. - * \param self - pointer to component structure for deinitialization. - * \return - * - zrtp_status_ok - if deinitialized successfully; - * - one of \ref zrtp_status_t errors - if deinitialization failed. - */ - zrtp_status_t (*free)(void* self); -} zrtp_comp_t; - - -/*! - * \brief Structure for defining the hash-value computing scheme - * The ZRTP context field zrtp_stream#_hash is initialized by the given type - * value and used for all hash calculations within the ZRTP sessions. Having - * implemented a structure of this type, it is possible to integrate new hash - * calculation schemes into libzrtp. - */ -struct zrtp_hash_t -{ - zrtp_comp_t base; - - /*! - * \brief Begin hash computation with update support. - * The following set of functions ( zrtp_hash#hash_begin, zrtp_hash#hash_update, - * zrtp_hash#hash_end) implements a standard hash calculation scheme with - * accumulation. The functions perform the required actions to start - * calculations and to allocate hash-contexts for preserving intermediate - * results and other required information. The allocated context will be - * passed-to by the subsequent calls zrtp_hash#hash_update and zrtp_hash#hash_end. - * \param self - self-pointer for fast access to structure data - * \return - * - pointer to allocated hash-context if successful; - * - NULL if error. - */ - void* (*hash_begin)(zrtp_hash_t *self); - - /*! - * \brief Process more input data for hash calculation - * This function is called in the hash-building chain to obtain additional - * data that it then processes and recalculates intermediate values. - * \param self - self-pointer for fast access to structure data; - * \param ctx - hash-context for current hash-value calculation; - * \param msg - additional source data for processing; - * \param length - length of additional data in bytes. - * \return - * - zrtp_status_ok - if successfully processed; - * - one of \ref zrtp_status_t errors - if error. - */ - zrtp_status_t (*hash_update)( zrtp_hash_t *self, - void *ctx, - const int8_t*msg, - uint32_t length ); - - /*! - * \brief Completes the computation of the current hash-value - * This function completes the computation of the hash-value with accumul. - * After completion, the hash-context previously allocated by the call to - * zrtp_hash#hash_begin, must be destroyed. The size of the calculated - * value must be kept in the parameter digest field zrtp_string#length. - * \param self - self-pointer for fast access to structure data; - * \param ctx - hash-context for current hash-value calculation; - * \param digest - buffer for storing result. - * \return - * - zrtp_status_ok - if computing finished successfully; - * - one of \ref zrtp_status_t errors - if error. - */ - zrtp_status_t (*hash_end)( zrtp_hash_t *self, - void *ctx, - zrtp_stringn_t *digest ); - - /*! - * \brief Calculate hash-value for current message - * This function implicitly calls the previous 3 functions. The only - * difference is that initial data for hash value construction is gathered - * in a single buffer and is passed to the function in the \c msg argument. - * The calculated value size must be stored in the digest zrtp_string#length - * parameter - * \param self - self-pointer for fast access to structure data; - * \param msg - source data buffer for hash computing; - * \param digest - buffer for storing result. - * \return - * - zrtp_status_ok - if computing finished successfully; - * - one of \ref zrtp_status_t errors - if error. - */ - zrtp_status_t (*hash)( zrtp_hash_t *self, - const zrtp_stringn_t *msg, - zrtp_stringn_t *digest ); - - /*! \brief Analogue of zrtp_hash::hash for C-string */ - zrtp_status_t (*hash_c)( zrtp_hash_t *self, - const char* msg, - uint32_t msg_len, - zrtp_stringn_t *digest ); - - /*! - * \brief HASH self-test. - * This function implements hmac self-tests using pre-defined test vectors. - * \param self - self-pointer for fast access to structure data; - * \return - * - zrtp_status_ok - if tests have been passed successfully; - * - one of \ref zrtp_status_t errors - if one or more tests have - * failed. - */ - zrtp_status_t (*hash_self_test)(zrtp_hash_t *self); - - - /*! - * \brief Begin HMAC computation with update support. - * The zrtp_hash#hmac_begin, zrtp_hash#hmac_update and zrtp_hash#hmac_end - * functions implement the HMAC calculation scheme with accumulation. The - * function performs all actions required before beginning the calculation - * and allocates a hash-context to store intermediate values. The allocated - * hash-context will be passed to successive hash_update and hash_end calls - * \param self - self-pointer for fast access to structure data; - * \param key - secret key for hmac-value protection. - * \return - * - pointer to allocated hmac-context if successful; - * - NULL - if error. - */ - void* (*hmac_begin)(zrtp_hash_t *self, const zrtp_stringn_t *key); - - /*! \brief Analogue of zrtp_hash::hmac_begin for C-string */ - void* (*hmac_begin_c)(zrtp_hash_t *self, const char *key, uint32_t length); - - /*! - * \brief Process more input data for HMAC calculation - * This function is called to transfer additional data to the HMAC hash- - * calculation. Processes new data and recalculates intermediate values. - * \param self - self-pointer for fast access to structure data; - * \param ctx - hmac-context for current hmac-value calculation; - * \param msg - additional source data for processing; - * \param length - additional data length in bytes. - * \return - * - zrtp_status_ok - if successfully processed; - * - one of \ref zrtp_status_t errors - if error. - */ - zrtp_status_t (*hmac_update)( zrtp_hash_t *self, - void *ctx, - const char *msg, - uint32_t length ); - - /*! - * \brief Complete current HMAC-value computation - * This function completes the hmac calculation. After the final iteration - * \a the hash_context allocated by zrtp_hash#hmac_begin is destroyed. The - * argument \c len holds the HMAC size. If the buffer contains more than \c - * length characters then only the first \c length are copied to \c digest. - * The calculated value size is stored in the digest parameter length. - * \param self - self-pointer for fast access to structure data; - * \param ctx - hmac-context for current hmac-value calculation; - * \param digest - buffer for storing result; - * \param len - required hmac-value size. - * \return - * - zrtp_status_ok - if computing finished successfully; - * - one of \ref zrtp_status_t errors - if error. - */ - zrtp_status_t (*hmac_end)( zrtp_hash_t *self, - void *ctx, - zrtp_stringn_t *digest, - uint32_t len); - - /*! - * \brief Calculate hmac-value for current message - * The function implicitly calls the previous 3 functions - * (zrtp_hash#hmac_begin, zrtp_hash#hmac_update and zrtp_hash#hmac_end). The - * difference is that the initial data for hash value construction is - * gathered in a single buffer and is passed to the function in the \a msg - * argument. The calculated value size must be stored in the \a digest - * zrtp_string#length parameter - * \param self - self-pointer for fast access to structure data; - * \param key - key for protecting hmac; - * \param msg - source data buffer for hash computing; - * \param digest - buffer for storing result. - * \return - * - zrtp_status_ok - if computing finished successfully; - * - one of \ref zrtp_status_t errors - if error. - */ - zrtp_status_t (*hmac)( zrtp_hash_t *self, - const zrtp_stringn_t *key, - const zrtp_stringn_t *msg, - zrtp_stringn_t *digest ); - - /*! \brief Analogue of zrtp_hash::hmac for C-string */ - zrtp_status_t (*hmac_c)( zrtp_hash_t *self, - const char *key, - const uint32_t key_len, - const char *msg, - const uint32_t msg_len, - zrtp_stringn_t *digest ); - - /*! - * \brief Truncated Hmac-calculation version - * This function acts just like the previous \a hmac except it returns the - * first \a length bytes of the calculated value in the digest. - * \param self - self-pointer for fast access to structure data; - * \param key - key for hmac protection; - * \param msg - source data buffer for hash computing; - * \param digest - buffer for storing result; - * \param len - required hmac-value size. - * \return - * - zrtp_status_ok - if computed successfully; - * - one of \ref zrtp_status_t errors - if error. - */ - zrtp_status_t (*hmac_truncated)( zrtp_hash_t *self, - const zrtp_stringn_t *key, - const zrtp_stringn_t *msg, - uint32_t len, - zrtp_stringn_t *digest ); - - /*! \brief Analogue of zrtp_hash::hmac_truncated for C-string */ - zrtp_status_t (*hmac_truncated_c)( zrtp_hash_t *self, - const char *key, - const uint32_t key_len, - const char *msg, - const uint32_t msg_len, - uint32_t necessary_len, - zrtp_stringn_t *digest ); - - /*! - * \brief HMAC self-test. - * This function implements the hmac self-tests using pre-defined test vectors. - * \param self - self-pointer for fast access to structure data; . - * \return - * - zrtp_status_ok - if tests have passed successfully; - * - one of \ref zrtp_status_t errors - if one or more tests have failed. - */ - zrtp_status_t (*hmac_self_test)( zrtp_hash_t *self); - - uint32_t digest_length; - uint32_t block_length; - mlist_t mlist; -}; - - -/*! - * \brief Structure for defining the SRTP authentication scheme - * The ZRTP context field zrtp_stream#_authtaglength is initialized by the - * given type value and used for SRTP encryption configuration. - */ -struct zrtp_auth_tag_length_t -{ - zrtp_comp_t base; - uint32_t tag_length; - mlist_t mlist; -}; - - -/** - * @brief Structure for describing the public key scheme - * The ZRTP context field zrtp_stream#_pubkeyscheme is initialized by the given - * type value and used by libzrtp in public key exchange. - */ -struct zrtp_pk_scheme_t -{ - zrtp_comp_t base; - - /** Generate Diffie-Hellman secret value and Calculate public value */ - zrtp_status_t (*initialize)( zrtp_pk_scheme_t *self, - zrtp_dh_crypto_context_t *dh_cc ); - - /** Calculate Diffie-Hellman result (ZRTP Internet Draft) */ - zrtp_status_t (*compute)( zrtp_pk_scheme_t *self, - zrtp_dh_crypto_context_t *dh_cc, - struct BigNum *dhresult, - struct BigNum *pv); - - /** Validate Diffie-Hellman public value */ - zrtp_status_t (*validate)(zrtp_pk_scheme_t *self, struct BigNum *pv); - - /** Diffie-Hellman self-test routine. */ - zrtp_status_t (*self_test)(zrtp_pk_scheme_t *self); - - /** Diffie-Hellman secret value size in bytes */ - uint32_t sv_length; - - /** Diffie-Hellman public value size in bytes */ - uint32_t pv_length; - - mlist_t mlist; -}; - - -/*! - * \brief Structure for defining SAS generation scheme - * The type of the ZRTP context's field zrtp_stream#_sasscheme. It is used - * to generate short authentication strings. LibZRTP functionality can be augmented - * with a new SAS scheme by supplying your own instance of zrtp_sas_scheme. - */ -struct zrtp_sas_scheme_t -{ - zrtp_comp_t base; - - /*! - * \brief Generate short authentication strings - * This function computes SAS values according to the specified scheme. It - * can use base32 or base256 algorithms. It stores the generated SAS values - * as a zrtp_sas_values_t structure (string and binary representation). - * \param self - self-pointer for fast access to structure data; - * \param session - ZRTP session context for additional data; - * \param hash - hmac component to be used for SAS calculation; - * \param is_transferred - if this flag is equal to 1 new SAS value should - * not be computed. It is already in sas->bin buffer and rendering only - * is required. - * \return - * - zrtp_status_ok - if generation successful; - * - one of zrtp_status_t errors - if generation failed. - */ - zrtp_status_t (*compute)( zrtp_sas_scheme_t *self, - zrtp_stream_t *stream, - zrtp_hash_t *hash, - uint8_t is_transferred ); - - mlist_t mlist; -}; - - -#include "aes.h" - -/*! Defines block cipher modes. */ -typedef enum zrtp_cipher_mode_values_t -{ - ZRTP_CIPHER_MODE_CTR = 1, - ZRTP_CIPHER_MODE_CFB = 2 -} zrtp_cipher_mode_values_t; - -typedef struct zrtp_cipher_mode_t -{ - uint8_t mode; -} zrtp_cipher_mode_t; - - -/* \brief Structure for cipher definition */ -struct zrtp_cipher_t -{ - zrtp_comp_t base; - - /*! - * \brief Start cipher. - * This function performs all actions necessary to allocate the cipher context - * for holding intermediate results and other required information. The allocated - * context should be related to the given key. It will be passed to the - * zrtp_cipher#set_iv, zrtp_cipher#encrypt and zrtp_cipher#decrypt functions. - * \param self - self-pointer for fast access to structure data; - * \param key - cipher key; - * \param extra_data - additional data necessary for cipher initialization; - * \param mode - cipher mode (one of \ref zrtp_cipher_mode_values_t values). - * \return - * - pointer to allocated cipher context; - * - NULL if error. - */ - void* (*start)( zrtp_cipher_t *self, - void *key, - void *extra_data, uint8_t mode ); - - /*! - * \brief Set Initialization Vector. - * Function resets the previous state of the cipher context and sets the new IV. - * \param self - self-pointer for fast access to structure data; - * \param cipher_ctx - cipher context for current key value; - * \param iv - new initialization vector value. - * \return - * - zrtp_status_ok - if vector has been set successfully; - * - one of \ref zrtp_status_t errors - if operation failed. - */ - zrtp_status_t (*set_iv)( zrtp_cipher_t *self, - void *cipher_ctx, - zrtp_v128_t *iv ); - - /*! - * \brief Encrypt data. - * Implements the encryption engine. - * \param self - self-pointer for fast access to structure data; - * \param cipher_ctx - cipher context for current key value; - * \param buf - buffer with data for encryption. If successful this - * buffer contains the resulting encrypted text; - * \param len - length of plain/encrypted data. - * \return - * - zrtp_status_ok - if data has been encrypted successfully; - * - one of \ref zrtp_status_t errors - if encryption failed. - */ - zrtp_status_t (*encrypt)( zrtp_cipher_t *self, - void *cipher_ctx, - unsigned char *buf, - int len ); - - /*! - * \brief Decrypt data. - * Implements the decryption engine. - * \param self - self-pointer for fast access to structure data; - * \param cipher_ctx - cipher context for current key value; - * \param buf - buffer with data for decryption. If successful this buffer - * contains the resulting plain text; - * \param len - length of encrypted/plain data. - * \return - * - zrtp_status_ok - if data has been decrypted successfully; - * - one of \ref zrtp_status_t errors - if decryption failed. - */ - zrtp_status_t (*decrypt)( zrtp_cipher_t *self, - void *cipher_ctx, - unsigned char *buf, - int len ); - - /*! - * \brief Cipher self-test. - * Implements cipher self-tests using pre-defined test vectors. - * \param self - self-pointer for fast access to structure data; - * \param mode - cipher mode (one of \ref zrtp_cipher_mode_values_t values). - * \return - * - zrtp_status_ok - if tests have passed successfully; - * - one of \ref zrtp_status_t errors - if one or more tests have failed. - */ - zrtp_status_t (*self_test)(zrtp_cipher_t *self, uint8_t mode); - - /*! - * \brief Destroy cipher context. - * Deallocs the cipher context previously allocated by a call to zrtp_cipher#start. - * \param self - self-pointer for fast access to structure data; - * \param cipher_ctx - cipher context for current key value. - * \return - * - zrtp_status_ok - if the context has been deallocated - * successfully; - * - one of \ref zrtp_status_t errors - if deallocation failed. - */ - zrtp_status_t (*stop)(zrtp_cipher_t *self, void* cipher_ctx); - - mlist_t mlist; -}; - -#if defined(__cplusplus) -extern "C" -{ -#endif - - -/*============================================================================*/ -/* Crypto-components management Private part */ -/*============================================================================*/ - - -/*! - * \brief Destroy components buffer - * This function clears the list of components of the specified type, destroys - * all components and releases all allocated resources. It is used on libzrtp - * down. zrtp_comp_done calls zrtp_comp_t#free() if it isn't NULL. - * \param zrtp - the ZRTP global context where components are stored; - * \param type - specifies the component pool type for destroying. - * \return - * - zrtp_status_ok - if clearing successful; - * - zrtp_status_fail - if error. - */ -zrtp_status_t zrtp_comp_done(zrtp_crypto_comp_t type, zrtp_global_t* zrtp); - -/*! - * \brief Registering a new crypto-component - * Correctness of values in the necessary structure is the developer's - * responsibility. zrtp_comp_register calls zrtp_comp_t#init() if it isn't NULL. - * \param type - type of registred component; - * \param comp - registered crypto-component; - * \param zrtp - the ZRTP global context where components are stored. - * \return - * - zrtp_status_ok if registration successful; - * - zrtp_status_fail if error (conflicts with other components). - */ -zrtp_status_t zrtp_comp_register( zrtp_crypto_comp_t type, - void *comp, - zrtp_global_t* zrtp); - -/*! - * \brief Search component by ID - * \param type - type of sought component; - * \param zrtp - the ZRTP global context where components are stored; - * \param id - integer identifier of the necessary element. - * \return - * - the found structure if successful; - * - NULL if the element with the specified ID can't be found or - * other error. - */ -void* zrtp_comp_find( zrtp_crypto_comp_t type, - uint8_t id, - zrtp_global_t* zrtp); - - -/*! Converts a component's integer ID to a symbolic ZRTP name */ -char* zrtp_comp_id2type(zrtp_crypto_comp_t type, uint8_t id); - -/*! Converts a component's ZRTP symbolic name to an integer ID */ -uint8_t zrtp_comp_type2id(zrtp_crypto_comp_t type, char* name); - - -/*! \} */ - -#if defined(__cplusplus) -} -#endif - -#endif /*__ZRTP_CRYPTO_H__ */ diff --git a/libs/libzrtp/include/zrtp_ec.h b/libs/libzrtp/include/zrtp_ec.h deleted file mode 100644 index 75497979a5..0000000000 --- a/libs/libzrtp/include/zrtp_ec.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - */ - -#ifndef __ZRTP_CRYPTO_EC_H__ -#define __ZRTP_CRYPTO_EC_H__ - -#include "bn.h" - -#include "zrtp_config.h" -#include "zrtp_types.h" -#include "zrtp_error.h" - -#define ZRTP_MAXECBITS 521 -#define ZRTP_MAXECWORDS ((ZRTP_MAXECBITS+7)/8) - -typedef struct zrtp_ec_params -{ - unsigned ec_bits; /* # EC bits: 256, 384, 521 */ - uint8_t P_data[ZRTP_MAXECWORDS]; /* curve field prime */ - uint8_t n_data[ZRTP_MAXECWORDS]; /* curve order (# points) */ - uint8_t b_data[ZRTP_MAXECWORDS]; /* curve param, y^3 = x^2 -3x + b */ - uint8_t Gx_data[ZRTP_MAXECWORDS]; /* curve point, x coordinate */ - uint8_t Gy_data[ZRTP_MAXECWORDS]; /* curve point, y coordinate */ -} zrtp_ec_params_t; - -#if defined(__cplusplus) -extern "C" -{ -#endif - -/*============================================================================*/ -/* Elliptic Curve library */ -/*============================================================================*/ - -int zrtp_ecAdd ( struct BigNum *rsltx, - struct BigNum *rslty, - struct BigNum *p1x, - struct BigNum *p1y, - struct BigNum *p2x, - struct BigNum *p2y, - struct BigNum *mod); - -int zrtp_ecMul ( struct BigNum *rsltx, - struct BigNum *rslty, - struct BigNum *mult, - struct BigNum *basex, - struct BigNum *basey, - struct BigNum *mod); - -zrtp_status_t zrtp_ec_random_point( zrtp_global_t *zrtp, - struct BigNum *P, - struct BigNum *n, - struct BigNum *Gx, - struct BigNum *Gy, - struct BigNum *pkx, - struct BigNum *pky, - struct BigNum *sv, - uint8_t *test_sv_data, - size_t test_sv_data_len); - -extern zrtp_status_t zrtp_ec_init_params(struct zrtp_ec_params *params, uint32_t bits ); - - -/* Useful bignum utility functions not defined in bignum library */ -int bnAddMod_ (struct BigNum *rslt, struct BigNum *n1, struct BigNum *mod); -int bnAddQMod_ (struct BigNum *rslt, unsigned n1, struct BigNum *mod); -int bnSubMod_ (struct BigNum *rslt, struct BigNum *n1, struct BigNum *mod); -int bnSubQMod_ (struct BigNum *rslt, unsigned n1, struct BigNum *mod); -int bnMulMod_ (struct BigNum *rslt, struct BigNum *n1, struct BigNum *n2, struct BigNum *mod); -int bnMulQMod_ (struct BigNum *rslt, struct BigNum *n1, unsigned n2, struct BigNum *mod); -int bnSquareMod_ (struct BigNum *rslt, struct BigNum *n1, struct BigNum *mod); - -#if defined(__cplusplus) -} -#endif - -#endif /* __ZRTP_CRYPTO_EC_H__ */ diff --git a/libs/libzrtp/include/zrtp_engine.h b/libs/libzrtp/include/zrtp_engine.h deleted file mode 100644 index a2c7e05de5..0000000000 --- a/libs/libzrtp/include/zrtp_engine.h +++ /dev/null @@ -1,387 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - - -#ifndef __ZRTP_ENGINE_H__ -#define __ZRTP_ENGINE_H__ - -#include "zrtp_config.h" -#include "zrtp_types.h" -#include "zrtp_crypto.h" - - -#if defined(__cplusplus) -extern "C" -{ -#endif - -/** - * @defgroup engine_dev ZRTP Engine related types and functions - * @ingroup zrtp_dev - * \{ - */ - -#define ZRTP_IS_STREAM_DH(stream) \ -(stream->mode == ZRTP_STREAM_MODE_DH) - -#define ZRTP_IS_STREAM_FAST(stream) \ -(stream->mode != ZRTP_STREAM_MODE_DH) - -#define ZRTP_IS_STREAM_MULT(stream) \ -(stream->mode == ZRTP_STREAM_MODE_MULT) - -#define ZRTP_IS_STREAM_PRESH(stream) \ -(stream->mode == ZRTP_STREAM_MODE_PRESHARED) - - -/** - * @brief Test Passive Rule N1 - * A passive endpoint never sends a Commit message. Semi-active endpoint does - * not send a commit to a passive endpoint. - * Return 1 if the tast have been passed successfully and 0 in other case. - */ -#define ZRTP_PASSIVE1_TEST(stream) \ -( (ZRTP_LICENSE_MODE_UNLIMITED == stream->zrtp->lic_mode) || \ - ((ZRTP_LICENSE_MODE_ACTIVE == stream->zrtp->lic_mode) && (!stream->messages.peer_hello.pasive)) ) - -/** - * @brief Test Passive Rule N2 - * A passive phone, if acting as a SIP initiator (meaning it initiated the call), - * rejects all commit packets from everyone. - * Return 1 if the tast have been passed successfully and 0 in other case - */ -#define ZRTP_PASSIVE2_TEST(stream) \ -( !((ZRTP_LICENSE_MODE_PASSIVE == stream->zrtp->lic_mode) && \ - (stream->session->signaling_role == ZRTP_SIGNALING_ROLE_INITIATOR)) ) - -/** - * @brief Test Passive Rule N3 - * A passive phone rejects all commit messages from a PBX. - * Return 1 if the tast have been passed successfully and 0 in other case - */ -#define ZRTP_PASSIVE3_TEST(stream) \ -( !(!stream->zrtp->is_mitm && stream->peer_mitm_flag && \ - (ZRTP_LICENSE_MODE_PASSIVE == stream->zrtp->lic_mode)) ) - - -/*===========================================================================*/ -/* PROTOCOL Logic */ -/*===========================================================================*/ - -/** - * @brief Allocate ZRTP protocol structure - * Allocates and initializes all necessary data according to the protocol mode. - * Initializes required DH crypto context info and generates secret IDs. - * @param stream - stream context in which protocol should be allocated; - * @param is_initiator - defines protocol type (1 - initiator, 0 - responder). - * @exception SOFTWARE exceptions. - */ -zrtp_status_t _zrtp_protocol_init( zrtp_stream_t *stream, - uint8_t is_initiator, - zrtp_protocol_t **proto); - -/** - * @brief Release protocol structure - * Stops all replay tasks, clears all crypto sources and SRTP engine, and - * releases memory. The protocol should be destroyed on: stream closing, or - * switching to CLEAR or ERROR states. - */ -void _zrtp_protocol_destroy(zrtp_protocol_t *proto); - -/** - * @brief Encrypts RTP/RTCP media - * After switching to Secure, the protocol structure is able to encrypt - * media using the SRTP crypto-engine. - * @param self - self-pointer to protocol instance; - * @param packet - media packet for encryption; - * @param is_rtp - defines type of media for encryption; value equal to 1 - * means RTP packet, 0 - RTCP. - * @return - * - zrtp_status_ok - if successfully encrypted; - * - one of zrtp_status_t errors otherwise. - */ -zrtp_status_t _zrtp_protocol_encrypt( zrtp_protocol_t *proto, - zrtp_rtp_info_t *packet, - uint8_t is_rtp); - -/** - * @brief Decrypts RTP/RTCP media - * After switching to Secure, the protocol structure is able to decrypt - * media using the SRTP crypto-engine. - * @param self - self-pointer to protocol instance; - * @param packet - media packet for decryption; - * @param is_rtp - defines type of media for decryption; value equal to 1 - * means RTP packet, 0 - RTCP. - * @return - * - zrtp_status_ok - if successfully decrypted; - * - one of zrtp_status_t errors otherwise. - */ -zrtp_status_t _zrtp_protocol_decrypt( zrtp_protocol_t *self, - zrtp_rtp_info_t *packet, - uint8_t is_rtp); - - -/*===========================================================================*/ -/* CRTPTO Utilities */ -/*===========================================================================*/ - -/** - * ZRTP KDF function. - * KDF(KI, Label, Context, L) = HMAC(KI, i | Label | 0x00 | Context | L). See - * Section "4.5.1. The ZRTP Key Derivation Function" in ZRTP RFC for more info. - * @param stream - used to obtain negotiated HMAC function and other parameters; - * @param ki- secret key derivation key that is unknown to the wiretapper - * (for example, s0); - * @param label - string of nonzero octets that identifies the purpose for the - * derived keying material; - * @param context - includes ZIDi, ZIDr, and some optional nonce material; - * @param length - needed digest length. (The output of the KDF is truncated to - * the leftmost length bits); - * @param digest - destination buffer. - */ -zrtp_status_t _zrtp_kdf( zrtp_stream_t* stream, - zrtp_stringn_t* ki, - zrtp_stringn_t* label, - zrtp_stringn_t* context, - uint32_t length, - zrtp_stringn_t* digest); - -/*! - * \brief Allocate shared secret structure - * This function allocates memory for a zrtp_shared_secret_t and initializes - * the secret value using a zrtp_fill_shared_secret() function call. Used in - * protocol allocating. - * \param session - ZRTP session for access to global data. - * \return - * - allocated secrets - on success; - * - NULL - if allocation fails. - */ -zrtp_shared_secret_t *_zrtp_alloc_shared_secret(zrtp_session_t* session); - -/*! - * \brief Restores secrets from the cache - * Uploads retained secrets from the cache and initializes secret flags. If - * the secret has expired (is_expired flag is set), its value will be randomly - * regenerated. _zrtp_prepare_secrets() is called after the discovery phase on - * the setting up the very first stream. After secrets are uploaded the - * zrtp_secrets_t#_is_ready flag is enabled to prevent secrets from reinitialization - * on setting up the next stream. - * \param session - ZRTP session in which secrets should be restored. - * - zrtp_status_ok - if secrets were restored successfully; - * - one of zrtp_status_t errors in case of failure. - */ -zrtp_status_t _zrtp_prepare_secrets(zrtp_session_t* session); - -/** - * @brief Validate confirm chmac message. - * In case of chmac failure it switches to Initiating Error state and generate - * ZRTP_EVENT_WRONG_MESSAGE_HMAC security event. - * @return - * -1 - in case of error and 0 - on success. - */ -int _zrtp_validate_message_hmac(zrtp_stream_t *stream, zrtp_msg_hdr_t* msg2check, char* hmackey); - -/** - * @brief Computes preshared key using available secrets. - * hash(len(rs1) | rs1 | len(auxsecret) | auxsecret | len(pbxsecret) | pbxsecret) - * Result key stored in key variable, if key_id not NULL - hmac - * of the preshared_key will be stored. - * return - * - zrtp_status_ok on success and one of libzrtp errors in case of failure - */ -zrtp_status_t _zrtp_compute_preshared_key( zrtp_session_t *session, - zrtp_stringn_t* rs1, - zrtp_stringn_t* auxs, - zrtp_stringn_t* pbxs, - zrtp_stringn_t* key, - zrtp_stringn_t* key_id); - -/** @brief Perform Key generation according to ZRTp RFC sec. 5.6 */ -zrtp_status_t _zrtp_set_public_value(zrtp_stream_t *stream, int is_initiator); - - -/*===========================================================================*/ -/* PROTOCOL Utilites */ -/*===========================================================================*/ - -/*! - * \brief Check availability to start stream (DH or Preshared) - * The ZRTP specification says that only one DH stream can be run at a time between - * two ZRTP endpoints. So _zrtp_can_start_stream(DH) looks over all sessions - * between two ZIDs and if any other stream is running it denies the start of - * another DH stream in parallel. Although the ZRTP standard says that Preshared - * or Multistream stream can't be run in parallel with DH streams between two - * ZRTP endpoints. So _zrtp_can_start_stream(PRESH) looks over all sessions between - * two ZIDs and if any other DH stream is running it denies the start of - * Preshared/Multistream stream in parallel. All operations with sessions and - * streams are protected by mutexes. Call this function every time before starting - * "initiating secure" process. For internal use only. - * \sa "break the tie schemes" internal document. - * \param stream - ZRTP stream which going to be started; - * \param conc - in this variable _zrtp_can_start_stream() returns pointer to the - * concurrent DH stream if it's in progress. It's used in "breaking the tie" - * scheme. - * \param mode - stream mode. - * \return - * - 1 if stream can be started; - * - 0 - if stream can't be started and should wait for concurrent stream - * establishment. - */ -int _zrtp_can_start_stream( zrtp_stream_t* stream, - zrtp_stream_t** conc, - zrtp_stream_mode_t mode); - -/** Return ZRTP Stream mode which should be used for current stream. */ -zrtp_stream_mode_t _zrtp_define_stream_mode(zrtp_stream_t* stream); - -/*! - * \brief Chooses the best crypto component of the given type - * Selects the crypto component according to the local initiator's profile and - * the remote responder's Hello. - * \param profile - local profile; - * \param peer_hello - Hello packet, received from the remote peer; - * \param type - type of the crypto component to be chosen. - * \return: - * - identifier of the chosen component (according to type); - * - ZRTP_COMP_UNKN in case of error. - */ -uint8_t _zrtp_choose_best_comp( zrtp_profile_t* profile, - zrtp_packet_Hello_t* peer_hello, - zrtp_crypto_comp_t type); - -/*! - * \brief Computes replay timeouts - * This function computes messages replays schedule. There are some recommended - * values by ZRTP specification, but in some network environments values may be - * sligh different - */ -uint32_t _zrtp_get_timeout(uint32_t curr_timeout, zrtp_msg_type_t msg); - - -/*! - * \brief Terminates retransmission task - * This function is a wrapper around zrtp_cancele_send_packet_later() which - * unsets the zrtp_retry_task_t#_is_enabled flag to prevent the scheduler from - * re-adding tasks after their termination. - */ -void _zrtp_cancel_send_packet_later( zrtp_stream_t* stream, - zrtp_msg_type_t type); - -/*! - * \brief state switcher - * This function changes stream state to \c state, makes a backup of the previous - * state at zrtp_stream_t#_prev_state and prints debug information. - * \warning Don't change the stream state directly. Use this function. - * \param stream - ZRTP stream to be changed; - * \param state - new state. - */ -void _zrtp_change_state( zrtp_stream_t* stream, zrtp_state_t state); - - -/*===========================================================================*/ -/* Shared STATE-MACHINE Routine */ -/*===========================================================================*/ - -// TODO: clean this up -zrtp_status_t _zrtp_machine_enter_pendingsecure(zrtp_stream_t* stream, zrtp_rtp_info_t* commit); -zrtp_status_t _zrtp_machine_enter_initiatingsecure(zrtp_stream_t* stream); -zrtp_status_t _zrtp_machine_enter_secure(zrtp_stream_t* stream); -zrtp_status_t _zrtp_machine_enter_pendingclear(zrtp_stream_t* stream); -zrtp_status_t _zrtp_machine_enter_initiatingerror( zrtp_stream_t *stream, - zrtp_protocol_error_t code, - uint8_t notif); - -zrtp_status_t _zrtp_machine_create_confirm(zrtp_stream_t *stream, zrtp_packet_Confirm_t* confirm); -zrtp_status_t _zrtp_machine_process_confirm(zrtp_stream_t *stream, zrtp_packet_Confirm_t *confirm); -zrtp_status_t _zrtp_machine_process_goclear(zrtp_stream_t* stream, zrtp_rtp_info_t* packet); - -zrtp_status_t _zrtp_machine_start_initiating_secure(zrtp_stream_t *stream); -zrtp_statemachine_type_t _zrtp_machine_preparse_commit(zrtp_stream_t *stream, zrtp_rtp_info_t* packet); - - -/*===========================================================================*/ -/* PARSERS */ -/*===========================================================================*/ - -/*! - * \brief Prepare RTP/ZRTP media packet for the further processing. - * This function defines the packet type, parses SSRC and makes the sequence - * number implicit. If it is a ZRTP message, packet length correctness and CRC - * are checked as well. - * \param stream - ZRTP stream associated with this packet; - * \param packet - packet for preparing; - * \param length - packet length; - * \param info - resulting packet structure; - * \param is_input - 1 - assumes incoming and 0 - outgoing packet direction. - */ -zrtp_status_t _zrtp_packet_preparse( zrtp_stream_t* stream, - char* packet, - uint32_t *length, - zrtp_rtp_info_t* info, - uint8_t is_input); - -/*! - * \brief Fills ZRTP message header and computes messages HMAC - * _zrtp_packet_fill_msg_hdr() prepares a ZRTP message header for sending. It calculates - * the total message length in 4-byte words and fills the message type block. - * \param stream - stream within in the operation will be performed - * \param type - ZRTP message type; - * \param body_length - message body length (without header); - * \param hdr - message ZRTP header - * \return - * - zrtp_status_ok - if success; - * - zrtp_status_bad_param - if message \c type is unknown. - */ -zrtp_status_t _zrtp_packet_fill_msg_hdr( zrtp_stream_t *stream, - zrtp_msg_type_t type, - uint16_t body_length, - zrtp_msg_hdr_t *hdr); - -/** - * @brief Sends ZRTP message onto the network - * _zrtp_packet_send_message constructs a ZRTP header and prepares packet for sending, - * computes CRC and injects the packet into the network using the interface - * function zrtp_send_rtp(). - * @param ctx - ZRTP stream context; - * @param type - packet type to construct primitive ZRTP messages; - * @param message - ZRTP message for sending. - * @return - * - 0 - if sent successfully; - * - -1 - if error. - */ -int _zrtp_packet_send_message( zrtp_stream_t *stream, - zrtp_msg_type_t type, - const void *message); - -/** @brief Returns ZRTP message type by symbolic name in header. */ -zrtp_msg_type_t _zrtp_packet_get_type(ZRTP_UNALIGNED(zrtp_rtp_hdr_t)*hdr, uint32_t length); - -/** - * @brief Insert CRC32 to ZRTP packets - * This function computes the 32 bit ZRTP packet checksum according to RFC 3309. - * As specified at ZRTP RFC, CRC32 is appended to the end of the extension for every ZRTP packet. - * @param packet - zrtp packet wrapper structure. - */ -void _zrtp_packet_insert_crc(char* packet, uint32_t length); - -/** - * @brief Validate ZRTP packet CRC - * @return - * - 0 if correct CRC; - * - -1 if CRC validation failed. - */ -int8_t _zrtp_packet_validate_crc(const char* packet, uint32_t length); - -/* \} */ - -#if defined(__cplusplus) -} -#endif - -#endif /* __ZRTP_ENGINE_H__ */ diff --git a/libs/libzrtp/include/zrtp_error.h b/libs/libzrtp/include/zrtp_error.h deleted file mode 100644 index a50b68ba9f..0000000000 --- a/libs/libzrtp/include/zrtp_error.h +++ /dev/null @@ -1,136 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - - -/** - * \file zrtp_error.h - * \brief libzrtp errors definitions - */ - -#ifndef __ZRTP_ERROR_H__ -#define __ZRTP_ERROR_H__ - -#include "zrtp_config.h" - -/** - * \defgroup zrtp_errors Libzrtp Error Definitions - * - * In this section the ZRTP protocol error codes and the library internal errors are defined. - * - * When ZRTP Protocl error detected, zrtp_callback_event_t#on_zrtp_security_event is called and - * zrtp_session_info_t#last_error contains error code. - * \{ - */ - -/** - * \brief Define protocol error codes according to ZRTP RFC sec. 5.9 - */ -typedef enum zrtp_protocol_error_t -{ - zrtp_error_unknown = 0, - zrtp_error_timeout = 1, - - zrtp_error_invalid_packet = 0x10, /** Malformed packet (CRC OK, but wrong structure) */ - zrtp_error_software = 0x20, /** Critical software error */ - zrtp_error_version = 0x30, /** Unsupported ZRTP version */ - zrtp_error_hello_mistmatch = 0x40, /** Hello components mismatch */ - - zrtp_error_hash_unsp = 0x51, /** Hash type not supported */ - zrtp_error_cipher_unsp = 0x52, /** Cipher type not supported */ - zrtp_error_pktype_unsp = 0x53, /** Public key exchange not supported */ - zrtp_error_auth_unsp = 0x54, /** SRTP auth. tag not supported */ - zrtp_error_sas_unsp = 0x55, /** SAS scheme not supported */ - zrtp_error_no_secret = 0x56, /** No shared secret available, Preshared mode required */ - - zrtp_error_possible_mitm1 = 0x61, /** DH Error: bad pvi or pvr ( == 1, 0, or p-1) */ - zrtp_error_possible_mitm2 = 0x62, /** DH Error: hvi != hashed data */ - zrtp_error_possible_mitm3 = 0x63, /** Received relayed SAS from untrusted MiTM */ - - zrtp_error_auth_decrypt = 0x70, /** Auth. Error: Bad Confirm pkt HMAC */ - zrtp_error_nonse_reuse = 0x80, /** Nonce reuse */ - zrtp_error_equal_zid = 0x90, /** Equal ZIDs in Hello */ - zrtp_error_service_unavail = 0xA0, /** Service unavailable */ - zrtp_error_goclear_unsp = 0x100,/** GoClear packet received, but not allowed */ - - zrtp_error_wrong_zid = 0x202, /** ZID received in new Hello doesn't equal to ZID from the previous stream */ - zrtp_error_wrong_meshmac = 0x203, /** Message HMAC doesn't match with pre-received one */ - zrtp_error_count -} zrtp_protocol_error_t; - -/** - * \brief libzrtp functions statuses. - * - * Note that the value of zrtp_status_ok is equal to zero. This can simplify error checking - * somewhat. - */ -typedef enum zrtp_status_t -{ - zrtp_status_ok = 0, /** OK status */ - zrtp_status_fail = 1, /** General, unspecified failure */ - zrtp_status_bad_param = 2, /** Wrong, unsupported parameter */ - zrtp_status_alloc_fail = 3, /** Fail allocate memory */ - zrtp_status_auth_fail = 4, /** SRTP authentication failure */ - zrtp_status_cipher_fail = 5, /** Cipher failure on RTP encrypt/decrypt */ - zrtp_status_algo_fail = 6, /** General Crypto Algorithm failure */ - zrtp_status_key_expired = 7, /** SRTP can't use key any longer */ - zrtp_status_buffer_size = 8, /** Input buffer too small */ - zrtp_status_drop = 9, /** Packet process DROP status */ - zrtp_status_open_fail = 10, /** Failed to open file/device */ - zrtp_status_read_fail = 11, /** Unable to read data from the file/stream */ - zrtp_status_write_fail = 12, /** Unable to write to the file/stream */ - zrtp_status_old_pkt = 13, /** SRTP packet is out of sliding window */ - zrtp_status_rp_fail = 14, /** RTP replay protection failed */ - zrtp_status_zrp_fail = 15, /** ZRTP replay protection failed */ - zrtp_status_crc_fail = 16, /** ZRTP packet CRC is wrong */ - zrtp_status_rng_fail = 17, /** Can't generate random value */ - zrtp_status_wrong_state = 18, /** Illegal operation in current state */ - zrtp_status_attack = 19, /** Attack detected */ - zrtp_status_notavailable = 20, /** Function is not available in current configuration */ - zrtp_status_count = 21 -} zrtp_status_t; - -/** \} */ - -/** \manonly */ - -#define ZRTP_MIM2_WARNING_STR \ - "Possible Man-In-The-Middle-Attack! Switching to state Error\n"\ - "because a packet arrived that was ZRTP_DHPART2, but contained\n"\ - "a g^y that didn't match the previous ZRTP_COMMIT.\n" - -#define ZRTP_MITM1_WARNING_STR "DH validating failed. (pvi is 1 or p-1), aborted\n" - -#define ZRTP_VERIFIED_INIT_WARNING_STR \ - "Falling back to cleartext because a packet arrived that was\n"\ - "ZRTP_CONFIRM1, but which couldn't be verified - the sender must have a different\n"\ - "shared secret than we have.\n" - -#define ZRTP_VERIFIED_RESP_WARNING_STR \ - "Falling back to cleartext because a packet arrived that was ZRTP_CONFIRM2,\n"\ - " but which couldn't be verified - the sender must have a different shared secret than we have.\n" - -#define ZRTP_EQUAL_ZID_WARNING_STR \ - "Received a ZRTP_HELLO packet with the same ZRTP ID that we have.\n"\ - " This is likely due to a bug in the software. Ignoring the ZRTP_HELLO\n"\ - " packet, therefore this call cannot be encrypted.\n" - -#define ZRTP_UNSUPPORTED_COMP_WARNING_STR \ - " Received ZRTP_HELLO packet with an algorithms field which had a\n"\ - " list of hashes that didn't include any of our supported hashes. Ignoring\n"\ - " the ZRTP_HELLO packet, therefore this call cannot be encrypted.\n" - -#define ZRTP_NOT_UNIQUE_NONCE_WARNING_STR \ - " Received COMMIT with hash value already used in another stream within this ZRTP session\n" - -#define ZRTP_RELAYED_SAS_FROM_NONMITM_STR \ -" Received SAS Relaying message from endpoint which haven't introduced as MiTM.\n" - -/** \endmanonly */ - -#endif /* __ZRTP_ERROR_H__ */ diff --git a/libs/libzrtp/include/zrtp_iface.h b/libs/libzrtp/include/zrtp_iface.h deleted file mode 100644 index e8de27fb3b..0000000000 --- a/libs/libzrtp/include/zrtp_iface.h +++ /dev/null @@ -1,692 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - - - -/** - * \file zrtp_iface.h - * \brief libzrtp product-dependent functions - */ - -#ifndef __ZRTP_IFACE_H__ -#define __ZRTP_IFACE_H__ - -#include "zrtp_config.h" -#include "zrtp_base.h" -#include "zrtp_string.h" -#include "zrtp_error.h" -#include "zrtp_iface_system.h" - - -#if defined(__cplusplus) -extern "C" -{ -#endif - -/*======================================================================*/ -/* libzrtp interface: Cache */ -/*======================================================================*/ - -/*! - * \defgroup zrtp_iface_cache ZRTP Cache - * \ingroup zrtp_iface - * - * The secret cache implementation should have a two-layer structure: each pair of ZIDs should have - * a relevant pair of secrets (current and previous). In addition to the value of the secret, the - * cache should contain: verification flag, last usage time-stamp and cache TTL value. - * - * The simplest secret cache scheme implementation is: - * \code - * [local_ZID][remote_ZID][curr_cache][prev_cache][verified][used at][cache ttl] - * \endcode - * \warning - * Libzrtp doen't provide synchronization for cache read/write operation. Cache is not thread safe - * by default. Implementor must take care of synchronization inside his implementation. - * - * For more information see corresponding section \ref XXX. Samples can be found at \ref XXX - * (\c zrtp_iface_builtin.h, \c zrtp_iface_cache.c) - * \{ - */ - -/** - * @brief Data types and functions related to shared secrets. - */ -typedef struct zrtp_callback_cache_t -{ - /** - * \brief Cache initialization. - * - * libzrtp calls this function before start using cache routine at zrtp_init(). - * - * \param zrtp - libzrtp global context; - * \sa zrtp_callback_cache_t#on_down() - */ - zrtp_status_t (*on_init)(zrtp_global_t* zrtp); - - /** - * \brief Cache deinitialization. - * - * libzrtp calls this function when zrtp cache is no longer needed at zrtp_down(). - * \sa zrtp_callback_cache_t#on_init() - */ - void (*on_down)(); - - /** - * \brief Add/Update cache value - * - * Interface function for entering the retained secret to the cache. This function should - * guarantee permanent storage in the cache. The implementation algorithm is the following: - * - if the entry associated with a given pair of ZIDs does not exist, the value should be - * stored in cache. - * - if the entry already exists, the current secret value becomes stored as the previous one. - * The new value becomes stored as the current one. Besides rss->value a timestamp - * (rss->lastused_at) and cache TTL(rss->ttl) should be updated. - * - * \param one_zid - ZID of one side; - * \param another_zid - ZID of the other side; - * \param rss - a structure storing the value of the secret that needs to be saved. - * \return - * - zrtp_status_ok if operation is successful; - * - some error code from \ref zrtp_status_t in case of error. - * \sa zrtp_callback_cache_t#on_get - */ - zrtp_status_t (*on_put)( const zrtp_stringn_t* one_zid, - const zrtp_stringn_t* another_zid, - zrtp_shared_secret_t *rss); - - /** - * \brief Return secret cache associated with specified pair of ZIDs. - * - * This function should return the secret associated with the specified pair of ZIDs. In - * addition to the secret value, TTL (rss->ttl) and cache timestamp (rss->lastused_at) value - * should be also returned. - * - * \param one_zid - one side's ZID; - * \param another_zid - the other side's ZID; - * \param prev_requested - if this parameter value is 1, the function should return the previous - * secret's value. If this parameter value is 0, the function should return the current - * secret's value; - * \param rss - structure that needs to be filled in. - * \return - * - zrtp_status_ok - if operation is successful; - * - zrtp_status_fail - if the secret cannot be found; - * - some error code from zrtp_status_t if an error occurred. - * \sa zrtp_callback_cache_t#on_put - */ - zrtp_status_t (*on_get)( const zrtp_stringn_t* one_zid, - const zrtp_stringn_t* another_zid, - zrtp_shared_secret_t *rss, - int prev_requested); - - /** - * \brief Set/clear cache verification flag - * - * This function should set the secret verification flag associated with a pair of ZIDs. - * \warning - * For internal use only. To change the verification flag from the user space use the - * zrtp_verified_set() function. - * - * \param one_zid - first ZID for cache identification; - * \param another_zid - second ZID for cache identification; - * \param verified - verification flag (value can be 0 or 1). - * \return - * - zrtp_status_ok if flag is successfully modified; - * - zrtp_status_fail if the secret cannot be found; - * - some other error code from \ref zrtp_status_t if another error occurred. - */ - zrtp_status_t (*on_set_verified)( const zrtp_stringn_t* one_zid, - const zrtp_stringn_t* another_zid, - uint32_t verified); - - /** - * \brief Return cache verification flag - * - * This function return the secret verification flag associated with a pair of ZIDs. - * - * \param one_zid - first ZID for cache identification; - * \param another_zid - second ZID for cache identification; - * \param verified - verification flag to be filled in - * \return - * - zrtp_status_ok if flag is successfully returned; - * - zrtp_status_fail if the secret cannot be found; - * - some other error code from \ref zrtp_status_t if another error occurred. - */ - zrtp_status_t (*on_get_verified)( const zrtp_stringn_t* one_zid, - const zrtp_stringn_t* another_zid, - uint32_t* verified); - - /** - * \brief Should set Secure Since cache aparemeter to current date and time - * - * This function is optional and may be ommited. - * - * \param one_zid - first ZID for cache identification; - * \param another_zid - second ZID for cache identification; - * \return - * - zrtp_status_ok if the oprtation finished sucessfully. - * - some other error code from \ref zrtp_status_t if another error occurred. - */ - zrtp_status_t (*on_reset_since)( const zrtp_stringn_t* one_zid, - const zrtp_stringn_t* another_zid); - - /** - * \brief Add/Update cache value for MiTM endpoint - * - * This function is analogy to zrtp_callback_cache_t#on_put but for MiTM endpoint. - * \todo Add more detail description - * \sa zrtp_callback_cache_t#on_put zrtp_callback_cache_t#on_get_mitm - */ - zrtp_status_t (*on_put_mitm)( const zrtp_stringn_t* one_zid, - const zrtp_stringn_t* another_zid, - zrtp_shared_secret_t *rss); - - /** - * \brief Return secret cache for MiTM endpoint - * - * This function is analogy to zrtp_callback_cache_t#on_get but for MiTM endpoint. - * \todo Add more detail description - * \sa zrtp_callback_cache_t#on_get zrtp_callback_cache_t#on_put_mitm - */ - zrtp_status_t (*on_get_mitm)( const zrtp_stringn_t* one_zid, - const zrtp_stringn_t* another_zid, - zrtp_shared_secret_t *rss); - - /** - * \brief Return Preshared calls counter - * - * This function should return the preshared calls counter associated with a pair of ZIDs. - * - * \param one_zid - first ZID for cache identification; - * \param another_zid - second ZID for cache identification; - * \param counter - preshared calls counter to be filled in - * \return - * - zrtp_status_ok if counter is successfully returned; - * - zrtp_status_fail if the secret cannot be found; - * - some other error code from \ref zrtp_status_t if another error occurred. - */ - zrtp_status_t (*on_presh_counter_get)( const zrtp_stringn_t* one_zid, - const zrtp_stringn_t* another_zid, - uint32_t* counter); - - /** - * \brief Increase/reset Preshared streams counter made between two endpoints (ZIDs) - * - * This function should set the preshared calls counter associated with a pair of ZIDs. - * Function is optional and should be implemented if your prodict uses Preshared keys exchange. - * - * \param one_zid - first ZID for; - * \param another_zid - second ZID; - * \param counter - Preshared calls counter. - * \return - * - zrtp_status_ok if the counter is successfully modified; - * - zrtp_status_fail if the secret cannot be found; - * - some other error code from \ref zrtp_status_t if another error occurred. - */ - zrtp_status_t (*on_presh_counter_set)( const zrtp_stringn_t* one_zid, - const zrtp_stringn_t* another_zid, - uint32_t counter); -} zrtp_callback_cache_t; - - -/** \} */ - -/*======================================================================*/ -/* libzrtp interface: Scheduler */ -/*======================================================================*/ - -/** - * \defgroup zrtp_iface_scheduler ZRTP Delay Calls - * \ingroup zrtp_iface - * - * Algorithm used in the scheduled call module is described in detail in section \ref XXX of the - * developer's guide documentation. Technical details of this function's implementation follows. - * - * For more information see corresponding section \ref XXX. Samples can be found at \ref XXX - * (\c zrtp_iface_builtin.h, \c zrtp_iface_scheduler.c) - * \{ - */ - -/** \brief ZRTP Delays Calls signature. */ -typedef void (*zrtp_call_callback_t)(zrtp_stream_t*, zrtp_retry_task_t*); - -/** - * @brief Delay Call wrapper - */ -struct zrtp_retry_task_t -{ - /** \brief Task action callback */ - zrtp_call_callback_t callback; - - /** \brief Timeout before call in milliseconds */ - zrtp_time_t timeout; - - /** - * \brief User data pointer. - * - * Pointer to the user data. This pointer can be used for fast access to some additional data - * attached to this task by the user application. - */ - void* usr_data; - - - // TODO: hide these elements - /** - * \brief Task activity flag. - * - * Libzrtp unsets this flag on task canceling. It prevents the scheduler engine from re-adding - * an already canceled task. Callback handlers skip passive tasks. - * \note - * For internal use only. Don't' modify this field in implementation. - */ - uint8_t _is_enabled; - - /** - * \brief Number of task retries. - * - * Every handler that attempts the task increases it by one. When the limit is reached the - * scheduler should stop retries and performs a specified action - generally raises an error. - * \note - * For internal use only. Don't' modify this field in implementation. - */ - uint32_t _retrys; - - /** - * \brief Task Busy flag. - * - * Built-in cache implementation uses this flag to protect task from being removed during the - * callback. - * - * Default cache implementation "locks" this flag before call zrtp_retry_task#callback - * and "unlocks" when the call is performed. zrtp_callback_scheduler_t#on_wait_call_later exits - * when there are no callbacks in progress - no tasks with \c _is_busy enabled. - */ - uint8_t _is_busy; -}; - -/** - * @brief Delay Calls callbacks - */ -typedef struct zrtp_callback_scheduler_t -{ - /** - * \brief Delay Calls initialization. - * - * libzrtp calls this function before start using scheduler routine at zrtp_init(). - * - * \param zrtp - libzrtp global context; - * \sa zrtp_callback_scheduler_t#on_down() - */ - zrtp_status_t (*on_init)(zrtp_global_t* zrtp); - - /** - * \brief Delay Calls deinitialization. - * - * libzrtp calls this function when zrtp scheduler is no longer needed at zrtp_down(). - * \sa zrtp_callback_scheduler_t#on_init() - */ - void (*on_down)(); - - /** - * \brief Interface for performing delay call - * - * This function should add delay call request (\c task) to the processing queue. When the - * zrtp_retry_task_t#timeout is expired, scheduler should call zrtp_retry_task_t#callback and - * remove tasks from the processing queue. - * - * \param stream - stream context for processing the callback function; - * \param task - task structure that should be processed. - * \sa zrtp_callback_scheduler_t#on_cancel_call_later - */ - void (*on_call_later)(zrtp_stream_t *stream, zrtp_retry_task_t* task); - - /** - * \brief Interface for canceling a delay calls - * - * This function cancels delay call if it still in the processing queue. The algorithm is the - * following: - * - If there is a specified task for a specified stream, this task should be deleted. - * - If the \c task parameter is equal to NULL - ALL tasks for the specified stream must be - * terminated and removed from the queue. - * - * \param ctx - stream context for the operation; - * \param task - delayed call wrapper structure. - * \sa zrtp_callback_scheduler_t#on_call_later - */ - void (*on_cancel_call_later)(zrtp_stream_t* ctx, zrtp_retry_task_t* task); - - /** - * \brief Interface for waiting for scheduling tasks is finished - * - * This function is called by libzrtp when the state-mamchine is in a position to destroy ZRTP - * session and all incapsulated streams. Allocated for the stream memory may be cleared and - * released. If after this operation, scheduler perform time-out call it will bring system to - * crash. - * - * The scheduler implementation must guarantee that any delay call for the \c stream will not be - * performed after on_wait_call_later(). - * - * \param stream - stream context for the operation; - * \sa zrtp_callback_scheduler_t#on_call_later. - */ - void (*on_wait_call_later)(zrtp_stream_t* stream); -} zrtp_callback_scheduler_t; - -/** \} */ - -/*======================================================================*/ -/* libzrtp interface: Protocol */ -/*======================================================================*/ - -/** - * \defgroup zrtp_iface_proto ZRTP Protocol Feedback - * \ingroup zrtp_iface - * - * This section defines ZRTP protcol events. Detail description of ZRTP state-machine is defined in - * \ref XXX. - * \{ - */ - -/** - * \brief ZRTP Protocol events - * - * For additional information see \ref XXX - */ -typedef enum zrtp_protocol_event_t -{ - /** \brief Just a stub for error detection. */ - ZRTP_EVENT_UNSUPPORTED = 0, - - /** \brief Switching to CLEAR state */ - ZRTP_EVENT_IS_CLEAR, - - /** \brief Switching to INITIATING_SECURE state */ - ZRTP_EVENT_IS_INITIATINGSECURE, - - /** \brief Switching to PENDING_SECURE state */ - ZRTP_EVENT_IS_PENDINGSECURE, - - /** \brief Switching to PENDING_CLEAR state */ - ZRTP_EVENT_IS_PENDINGCLEAR, - - /** - * \brief Switching to NO_ZRTP state. - * - * Hello packet undelivered - no ZRTP endpoint and other end - */ - ZRTP_EVENT_NO_ZRTP, - - /** - * \brief First N Hello packet undelivered - probably, no ZRTP endpoint and other end - * - * Libzrtp raises this event after few Hello have been send without receiving response from the - * remote endpoint. User application may use this event to stop Securing ritual if connection - * lag is important. - * - * Developer should take into account that delays in Hello receiving may be conditioned by - * interruptions in media channel - * - * \warning Don't handle this event unless necessary - */ - ZRTP_EVENT_NO_ZRTP_QUICK, - - /** - * \brief MiTM Enrollment with MiTM endpoint - * - * Informs the Client-side endpoint of receiving a registration invitation from the MiTM. - * Libzrtp raises this event after switching to the Secure state (ZRTP_EVENT_IS_SECURE). The - * user may accept the invitation using a zrtp_register_with_trusted_mitm() call. - */ - ZRTP_EVENT_IS_CLIENT_ENROLLMENT, - - /** - * \brief New user has registered to the MitM - * - * Informs MitM of the registration of a new user. Libzrtp raises this event when a user calls - * the special registration number and has switched to the secure state. - */ - ZRTP_EVENT_NEW_USER_ENROLLED, - - /** - * \brief New user has already registered with the MiTM - * - * Notifies the MiTM of an attempt to register from a user that is already registered. In this - * case a new MiTM secret will not be generated and the user may be informed by voice prompt. - * Libzrtp raises this event from the SECURE state. - */ - ZRTP_EVENT_USER_ALREADY_ENROLLED, - - /** - * \brief User has cancelled registration - * - * Libzrtp may raise this event during regular calls when it discovers that the user has removed - * its MiTM secret. This event informs the MiTM that the SAS can no longer be transferred to - * this user. - */ - ZRTP_EVENT_USER_UNENROLLED, - - /** - * \brief SAS value and/or rendering scheme was updated - * - * LibZRTP raises this event when the SAS value is transferred from the trusted MiTM. The value - * is rendered automatically according to the rendering scheme specified by the trusted MiTM. - * (it may be different than that of the previous one). - * - * On receiving this event, the Client application should replace the old SAS with the new one - * and ask the user to verify it. This event is called from the Secure state only. - */ - ZRTP_EVENT_LOCAL_SAS_UPDATED, - - /** - * \brief SAS transfer was accepted by the remote side - * - * Libzrtp raises this event to inform the Server-side about accepting the change of SAS value - * and/or rendering scheme by the remote client. This event is called from the Secure state - * only. - */ - ZRTP_EVENT_REMOTE_SAS_UPDATED, - - /** - * \brief Swishing to SECURE state - * - * Duplicates zrtp_callback_event_t#on_zrtp_secure for more thin adjustments. - */ - ZRTP_EVENT_IS_SECURE, - - /** - * \brief Swishing to SECURE state is finished. - * - * Equal to ZRTP_EVENT_IS_SECURE but called when the Securing process is completely finished: - * new RS secret is generate, cache flags updated and etc. Can be used in extended application - * for more thin adjustments. - */ - ZRTP_EVENT_IS_SECURE_DONE, - - /** - * \brief Indicates DRM restriction. Stream can't go Secure. - * - * Libzrtp generate this event if DRM rules don't allow to switch to Secure mode: - * - A passive endpoint never sends a Commit message. Semi-active endpoint does not send a - * Commit to a passive endpoint - * - A passive phone, if acting as a SIP initiator r ejects all commit packets from everyone. - * - A passive phone rejects all commit messages from a PBX. - */ - ZRTP_EVENT_IS_PASSIVE_RESTRICTION, - - ZRTP_EVENT_COUNT - -} zrtp_protocol_event_t; - -/** - * \brief ZRTP Protocol Errors and Warnings - * - * For additional information see \ref XXX - */ -typedef enum zrtp_security_event_t -{ - /** - * \brief Switching to ERROR state - * - * The exact error code can be found at zrtp_stream_info_t#last_error. Use zrtp_log_error2str() - * to get error description in text mode. - */ - ZRTP_EVENT_PROTOCOL_ERROR = ZRTP_EVENT_COUNT, - - /** - * \brief Hello Hash is different from that received in signaling. - * - * In accordance with sec. 8.1 of the ZRTP RFC, libzrtp provides the ability to prevent DOS - * attacks. libzrtp can detect an attack in which the hash of the remote Hello was received - * through signaling and added to the ZRTP context (zrtp_signaling_hash_set()). - * - * When the hash of the incoming Hello doesn't match the hash from signaling, the - * ZRTP_EVENT_WRONG_SIGNALING_HASH event is raised and the connection MAY be terminated - * manually. - */ - ZRTP_EVENT_WRONG_SIGNALING_HASH, - - /** - * \brief Hmac of the received packet is different from the hmac value earlier received. - * - * If the Hello hash is sent through protected signaling, libzrtp provides the ability to - * prevent protocol packets from modification and even eliminates comparing the SAS. To do this, - * libzrtp compares the message Hmac with the Hmac received in the previous message. - * - * If the Hmacs don't match, the ZRTP_EVENT_WRONG_MESSAGE_HMAC event is raised and the - * connection MAY be terminated manually. - */ - ZRTP_EVENT_WRONG_MESSAGE_HMAC, - - /** - * \brief Retain secret was found in the cache but it doesn't match with the remote one - * - * The library rises this event when non-expired secret have been found in the cache but - * value of the secret doesn't match with the remote side secret. Such situation may happen - * in case of MiTM attack or when remote side lost it's cache. - * - * Recommended behavior: the application should notify user about the situation and ask him to - * verify the SAS. If SAS is different - it indicates the attack. - */ - ZRTP_EVENT_MITM_WARNING -} zrtp_security_event_t; - -/** - * \brief Callbacks definitions - * - * This section lists callback functions informing the user about the protocol status. These - * callbacks must be defined in the user application. - */ -typedef struct zrtp_callback_event_t -{ - /** - * \brief ZRTP Protocol events notification. - * - * Informs about switching between the protocol states and other events. Provides more flexible - * control over the protocol then on_zrtp_secure and on_zrtp_not_secure. - * - * \param event - type of event; - * \param stream - ZRTP stream context. - */ - void (*on_zrtp_protocol_event)(zrtp_stream_t *stream, zrtp_protocol_event_t event); - - /** - * \brief ZRTP Security events notification - * - * Informs about ZRTP security events: MiTM attacks, cache desynchronization and - * others. - * \warning MUST be handled in the target application to provide high security level. - * - * \param event - type of event; - * \param stream - ZRTP stream context. - */ - void (*on_zrtp_security_event)(zrtp_stream_t *stream, zrtp_security_event_t event); - - /** - * \brief Indicates switching to SECURE state. - * - * Pair of events: \c on_zrtp_secure and \c on_zrtp_not_secure represent simplified event - * handling mechanism comparing to \c on_zrtp_protocol_event. libzrtp calls this event when the - * call is SECURE and media is encrypted. - * - * SAS Verification is required on this event. - * - * \param stream - ZRTP stream context. - */ - void (*on_zrtp_secure)(zrtp_stream_t *stream); - - /** - * \brief Indicates switching to NOT SECURE state. - * - * This event duplicates some protocol and security events to simplify libzrtp usage. It may be - * used in applications which don't require detail information about ZRTP protocol. - * - * If Error appeared - the exact error code can be found at zrtp_stream_info_t#last_error. Use - * zrtp_log_error2str() to get error description in text mode. - * - * \param stream - ZRTP stream context. - */ - void (*on_zrtp_not_secure)(zrtp_stream_t *stream); -} zrtp_callback_event_t; - -/** \} */ - -/*======================================================================*/ -/* libzrtp interface: Misc */ -/*======================================================================*/ - -/** - * \defgroup zrtp_iface_misc Miscellaneous functions - * \ingroup zrtp_iface - * \{ - */ - -/** - * \brief Miscellaneous Functions - */ -typedef struct zrtp_callback_misc_t -{ - /** - * \brief RTP packet sending function - * - * This function pushes an outgoing ZRTP packet to the network. Correct building of IP and UPD - * headers is the developer's responsibility. - * - * \param stream - ZRTP stream context; - * \param packet - buffer storing the ZRTP packet to send; - * \param length - size of the ZRTP packet. - * \return - * - number of bytes sent if successful; - * - -1 if error occurred. - */ - int (*on_send_packet)(const zrtp_stream_t* stream, char* packet, unsigned int length); -} zrtp_callback_misc_t; - -/** \} */ - -/** - * \brief ZRTP feedback interface and application dependent routine - * \ingroup zrtp_iface - */ -typedef struct zrtp_callback_t -{ - /** \brief ZRTP Protocol Feedback */ - zrtp_callback_event_t event_cb; - /** \brief ZRTP Delay Calls routine */ - zrtp_callback_scheduler_t sched_cb; - /** \brief ZRTP Cache */ - zrtp_callback_cache_t cache_cb; - /** \brief Miscellaneous functions */ - zrtp_callback_misc_t misc_cb; -} zrtp_callback_t; - - -#if defined(__cplusplus) -} -#endif - -#endif /*__ZRTP_IFACE_H__*/ diff --git a/libs/libzrtp/include/zrtp_iface_cache.h b/libs/libzrtp/include/zrtp_iface_cache.h deleted file mode 100644 index 0bdde3cf92..0000000000 --- a/libs/libzrtp/include/zrtp_iface_cache.h +++ /dev/null @@ -1,169 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - -#ifndef __ZRTP_IFACE_CACHE_H__ -#define __ZRTP_IFACE_CACHE_H__ - -#include "zrtp_config.h" -#include "zrtp_base.h" -#include "zrtp_string.h" -#include "zrtp_error.h" -#include "zrtp_iface.h" - -#if defined(__cplusplus) -extern "C" -{ -#endif - -#if defined(ZRTP_USE_BUILTIN_CACHE) && (ZRTP_USE_BUILTIN_CACHE == 1) - -#define ZRTP_DEF_CACHE_VERSION_STR "libZRTP cache version=" -#define ZRTP_DEF_CACHE_VERSION_VAL "1.0" - -/** - * @brief Cache element identifier type - * Elements of this type link cache data with a pair of ZIDs. - * (constructed as: [ZID1][ZID2], where ZID1 - ZID with greater binary value) - * This type is used to identify cache elements in the built-in implementation. - */ -typedef uint8_t zrtp_cache_id_t[24]; - -#define ZRTP_MITMCACHE_ELEM_LENGTH ( sizeof(zrtp_cache_id_t) + sizeof(zrtp_string64_t) ) -#define ZRTP_CACHE_ELEM_LENGTH ( sizeof(zrtp_cache_elem_t) - sizeof(mlist_t) - (sizeof(uint32_t)*2) ) -#define ZFONE_CACHE_NAME_LENGTH 256 - -/** - * @brief Secret cache element structure - * This structure is used to store cache data in the built-in implementation - * of the caching system. - */ -typedef struct zrtp_cache_elem -{ - zrtp_cache_id_t id; /** Cache element identifier */ - zrtp_string64_t curr_cache; /** Current cache value */ - zrtp_string64_t prev_cache; /** Prev cache value */ - uint32_t verified; /** Verified flag for the cache value */ - uint32_t lastused_at; /** Last usage time-stamp in seconds */ - uint32_t ttl; /** Cache TTL since lastused_at in seconds */ - uint32_t secure_since; /** Secure since date in seconds. Utility field. Don't required by libzrtp. */ - char name[ZFONE_CACHE_NAME_LENGTH]; /** name of the user associated with this cache entry */ - uint32_t name_length; /** cache name lengths */ - uint32_t presh_counter; /** number of Preshared streams made since last DH exchange */ - uint32_t _index; /** cache element index in the cache file */ - uint32_t _is_dirty; /** dirty flag means the entry has unsaved changes */ - mlist_t _mlist; -} zrtp_cache_elem_t; - -#endif /* ZRTP_USE_BUILTIN_CACHE */ - -zrtp_status_t zrtp_def_cache_init(zrtp_global_t* zrtp); - -void zrtp_def_cache_down(); - -zrtp_status_t zrtp_def_cache_set_verified( const zrtp_stringn_t* one_zid, - const zrtp_stringn_t* another_zid, - uint32_t verified); - -zrtp_status_t zrtp_def_cache_get_verified( const zrtp_stringn_t* one_zid, - const zrtp_stringn_t* another_zid, - uint32_t* verified); - - -zrtp_status_t zrtp_def_cache_put( const zrtp_stringn_t* one_zid, - const zrtp_stringn_t* another_zid, - zrtp_shared_secret_t *rss); - -zrtp_status_t zrtp_def_cache_put_mitm( const zrtp_stringn_t* one_zid, - const zrtp_stringn_t* another_zid, - zrtp_shared_secret_t *rss); - -zrtp_status_t zrtp_def_cache_get( const zrtp_stringn_t* one_zid, - const zrtp_stringn_t* another_zid, - zrtp_shared_secret_t *rss, - int prev_requested); - -zrtp_status_t zrtp_def_cache_get_mitm( const zrtp_stringn_t* one_zid, - const zrtp_stringn_t* another_zid, - zrtp_shared_secret_t *rss); - -zrtp_status_t zrtp_def_cache_set_presh_counter( const zrtp_stringn_t* one_zid, - const zrtp_stringn_t* another_zid, - uint32_t counter); - -zrtp_status_t zrtp_def_cache_get_presh_counter( const zrtp_stringn_t* one_zid, - const zrtp_stringn_t* another_zid, - uint32_t* counter); - -#if defined(ZRTP_USE_BUILTIN_CACHE) && (ZRTP_USE_BUILTIN_CACHE == 1) -/** - * @brief Cache iterator - * zrtp_def_cache_foreach() calls this function for every cache entry. - * @param elem - cache element; - * @param is_mitm - is 1 when callback was called for MiTM for each. - * @param del - callback may return 1 to this to remove cache entry from the list. - * @param data - pointer to some user data from zrtp_def_cache_foreach(); - * @return - * - 0 - if element was requested for reading only and wasn't changed; - * - 1 - if element was modified and cache should be updated. - */ -typedef int (*zrtp_cache_callback_t)(zrtp_cache_elem_t* elem, int is_mitm, void* data, int* del); - -/** - * @brief Iterate over all cache entries. - * Can be used for searching and modifying cache entries. Protected by mutex. - * Can be called in parallel with other cache operations when protocol is - * running. - * @param global - libzrtp global context; - * @param is_mitm - if value of this flag is 1 - fore_each will be applied for MiTM secrets; - * @param callback - function to be called for every cache entry; - * @param data - this pointer will be passed to every \c callback call. - */ -void zrtp_def_cache_foreach( zrtp_global_t *global, - int is_mitm, - zrtp_cache_callback_t callback, - void *data); - -#endif /* ZRTP_USE_BUILTIN_CACHE */ - -/** - * @brief Store shared secrets cache to the persistent storage - * May be used in server solutions for periodically flushing the cache to prevent data loss. - * - * @return - * - zrtp_status_ok - if operation completed successfully; - * - zrtp_status_wrong_state - if a call is performed from a routine which - * doesn't use the default cache. - */ -zrtp_status_t zrtp_def_cache_store(zrtp_global_t *global); - -zrtp_status_t zrtp_def_cache_reset_since( const zrtp_stringn_t* one_zid, - const zrtp_stringn_t* another_zid); - -zrtp_status_t zrtp_def_cache_get_since( const zrtp_stringn_t* one_zid, - const zrtp_stringn_t* another_zid, - uint32_t* since); - -zrtp_status_t zrtp_def_cache_get_name( const zrtp_stringn_t* one_zid, - const zrtp_stringn_t* another_zid, - zrtp_stringn_t* name); - -zrtp_status_t zrtp_def_cache_put_name( const zrtp_stringn_t* one_zid, - const zrtp_stringn_t* another_zid, - const zrtp_stringn_t* name); - -#if defined(ZRTP_USE_BUILTIN_CACHE) && (ZRTP_USE_BUILTIN_CACHE == 1) -zrtp_cache_elem_t* zrtp_def_cache_get2(const zrtp_cache_id_t id, int is_mitm); -#endif /* ZRTP_USE_BUILTIN_CACHE */ - -#if defined(__cplusplus) -} -#endif - -#endif /*__ZRTP_IFACE_CACHE_H__*/ - diff --git a/libs/libzrtp/include/zrtp_iface_scheduler.h b/libs/libzrtp/include/zrtp_iface_scheduler.h deleted file mode 100644 index 2fe27c447a..0000000000 --- a/libs/libzrtp/include/zrtp_iface_scheduler.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - - -#ifndef __ZRTP_IFACE_SCHEDULER_H__ -#define __ZRTP_IFACE_SCHEDULER_H__ - -#include "zrtp_config.h" -#include "zrtp_base.h" -#include "zrtp_string.h" -#include "zrtp_error.h" -#include "zrtp_iface.h" - -#if defined(ZRTP_USE_BUILTIN_SCEHDULER) && (ZRTP_USE_BUILTIN_SCEHDULER == 1) - -#if defined(__cplusplus) -extern "C" -{ -#endif - - -/** - * In order to use default secheduler libzrtp one should define tow extra interfaces: - * sleep and threads riutine. - */ - -/** - * \brief Suspend thread execution for an interval measured in miliseconds - * \param msec - number of miliseconds - * \return: 0 if successful and -1 in case of errors. - */ - -#if ZRTP_PLATFORM != ZP_WIN32_KERNEL - -#if (ZRTP_PLATFORM == ZP_WIN32) || (ZRTP_PLATFORM == ZP_WINCE) -#include - typedef LPTHREAD_START_ROUTINE zrtp_thread_routine_t; -#elif (ZRTP_PLATFORM == ZP_LINUX) || (ZRTP_PLATFORM == ZP_DARWIN) || (ZRTP_PLATFORM == ZP_BSD) || (ZRTP_PLATFORM == ZP_ANDROID) - typedef void *(*zrtp_thread_routine_t)(void*); -#elif (ZRTP_PLATFORM == ZP_SYMBIAN) - typedef int(*zrtp_thread_routine_t)(void*); -#endif - -/** - * \brief Function is used to create a new thread, within a process. - * - * Thread should be created with default attributes. Upon its creation, the thread executes - * \c start_routine, with \c arg as its sole argument. - * \param start_routine - thread start routine. - * \param arg - start routine arguments. - * \return 0 if successful and -1 in case of errors. - */ - - -extern int zrtp_thread_create(zrtp_thread_routine_t start_routine, void *arg); -extern int zrtp_sleep(unsigned int msec); - -#endif - -void zrtp_def_scheduler_down(); - -zrtp_status_t zrtp_def_scheduler_init(zrtp_global_t* zrtp); - -void zrtp_def_scheduler_call_later(zrtp_stream_t *ctx, zrtp_retry_task_t* ztask); - -void zrtp_def_scheduler_cancel_call_later(zrtp_stream_t* ctx, zrtp_retry_task_t* ztask); - -void zrtp_def_scheduler_wait_call_later(zrtp_stream_t* ctx); - - -zrtp_status_t zrtp_sem_init(zrtp_sem_t** sem, uint32_t value, uint32_t limit); -zrtp_status_t zrtp_sem_destroy(zrtp_sem_t* sem); -zrtp_status_t zrtp_sem_wait(zrtp_sem_t* sem); -zrtp_status_t zrtp_sem_trtwait(zrtp_sem_t* sem); -zrtp_status_t zrtp_sem_post(zrtp_sem_t* sem); - -#if defined(__cplusplus) -} -#endif - -#endif /* ZRTP_USE_BUILTIN_SCEHDULER */ - -#endif /*__ZRTP_IFACE_SCHEDULER_H__*/ diff --git a/libs/libzrtp/include/zrtp_iface_system.h b/libs/libzrtp/include/zrtp_iface_system.h deleted file mode 100644 index 6a69bd5b8b..0000000000 --- a/libs/libzrtp/include/zrtp_iface_system.h +++ /dev/null @@ -1,183 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - - -/** - * \file zrtp_iface_system.h - * \brief libzrtp platform-dependent routine - */ - -#ifndef __ZRTP_IFACE_SYSTEM_H__ -#define __ZRTP_IFACE_SYSTEM_H__ - -#include "zrtp_config.h" -#include "zrtp_types.h" - -#if defined(__cplusplus) -extern "C" -{ -#endif - - -/*============================================================================*/ -/* System wide functions */ -/*============================================================================*/ - -/** - * \defgroup zrtp_iface Library Interfaces Overview - * - * This section describes the requirements for the implementation of each interface function. - * Descriptions are divided into groups by function - */ - -/** - * \defgroup zrtp_iface_base Basic platform-dependent routine - * \ingroup zrtp_iface - * \{ - */ - -/** - * \brief Time in miliseconds - * - * libzrtp uses a unix-like time calculation scheme: time since 1/1/1970. - */ -typedef uint64_t zrtp_time_t; - - -/** - * \brief Allocates memory of a defined size - * - * Allocates \c size bytes and returns a pointer to the allocated memory Allocated memory is not - * cleared. - * - * \param size - number of bytes for allocation - * \return - * - pointer to the allocated memory if successful. - * - NULL if the memory allocation failed. - */ -extern void* zrtp_sys_alloc(unsigned int size); - -/** - * \brief release memory - * - * Release the memory space pointed to by \c obj, which was returned by a previous zrtp_sys_alloc() - * call. If \c obj is NULL, no operation is performed. - * - * \param obj - pointer to the released memory - */ -extern void zrtp_sys_free(void* obj); - -/** - * \brief Memory copying function. - * - * This function copies \c length bytes from memory area \c src to memory area \c dest. The memory - * areas should not overlap. - * - * \param dest - pointer to the destination buffer - * \param src - pointer to the source buffer; - * \param length - number of bytes to be copied. - * \return - * - pointer to the destination buffer (dest) - */ -extern void* zrtp_memcpy(void* dest, const void* src, unsigned int length); - -/** - * \brief Write a byte to a byte string - * - * The zrtp_memset() function writes \c n bytes of value \c c (converted to an unsigned char) to the - * string \c s. - * \return - * - first argument - */ -extern void *zrtp_memset(void *s, int c, unsigned int n); - -/** - * \brief Returns current date and time - * - * This function should return current unix-like date and time: number of microseconds since - * 1.1.1970. - */ -extern zrtp_time_t zrtp_time_now(); - -/** \} */ - -/*============================================================================*/ -/* Mutex related interfaces */ -/*============================================================================*/ - -/** - * \defgroup zrtp_iface_mutex Synchronization related functions - * \ingroup zrtp_iface - * \{ - */ - -/** - * \brief Initializing the mutex structure - * - * This function allocates and initializes the mutex referenced by \c mutex with default attributes. - * Upon successful initialization, the state of the mutex becomes initialized and unlocked. This - * function should create a NON RECURSIVE mutex. (Attempting to relock the mutex causes deadlock) - * - * \param mutex - out parameter, mutex structure for allocation and initialization - * \return: - * - zrtp_status_ok if initialization successful; - * - zrtp_status_fail if an error occurred. - * \sa zrtp_mutex_destroy() - */ -extern zrtp_status_t zrtp_mutex_init(zrtp_mutex_t** mutex); - -/** - * \brief Deinitializing the mutex structure - * - * This function destroys the mutex object previously allocated by zrtp_mutex_init(). - * - * \param mutex - mutex structure for deinitialization. - * \return: - * - zrtp_status_ok if deinitialization successful; - * - zrtp_status_fail if an error occurred. - * \sa zrtp_mutex_init() - */ - extern zrtp_status_t zrtp_mutex_destroy(zrtp_mutex_t* mutex); - -/** - * \brief Mutex locking - * - * This function locks the mutex object referenced by \c mutex. If the mutex is already locked, the - * thread that called it is blocked until the mutex becomes available. This operation returns the - * mutex object referenced by the mutex in the locked state with the calling thread as its owner. - * - * \param mutex - mutex for locking; - * \return: - * - zrtp_status_ok if successful; - * - zrtp_status_fail if an error occurred. - */ -extern zrtp_status_t zrtp_mutex_lock(zrtp_mutex_t* mutex); - -/** - * \brief Mutex releasing - * - * This function releases the mutex object referenced by mutex. The way a mutex is released depends - * on the mutex's type attribute. If there are threads blocked on the mutex object referenced by - * mutex when zrtp_mutex_unlock() is called and the mutex becomes available, the scheduling policy - * determines which thread acquires the mutex. - * - * \param mutex - mutex to release - * \return: - * - zrtp_status_ok if successful; - * - zrtp_status_fail if an error occurred. - */ -extern zrtp_status_t zrtp_mutex_unlock(zrtp_mutex_t* mutex); - -/*! \} */ - -#if defined(__cplusplus) -} -#endif - -#endif /* __ZRTP_IFACE_SYSTEM_H__ */ diff --git a/libs/libzrtp/include/zrtp_legal.h b/libs/libzrtp/include/zrtp_legal.h deleted file mode 100644 index 03c94729fd..0000000000 --- a/libs/libzrtp/include/zrtp_legal.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - -#ifndef __ZRTP_LEGAL_H__ -#define __ZRTP_LEGAL_H__ - - -/* - * We want the copyright string accessable to the unix strings command in - * the linked binary, and don't want the linker to remove it if it's not - * referenced, thus the volatile qualifier. - * - * ANSI C standard, section 3.5.3: "An object that has volatile-qualified - * type may be modified in ways unknown to the implementation or have - * other unknown side effects." - */ -extern volatile const char zrtpCopyright[]; - -#endif /*__ZRTP_LEGAL_H__ */ diff --git a/libs/libzrtp/include/zrtp_list.h b/libs/libzrtp/include/zrtp_list.h deleted file mode 100644 index e6ee0988c8..0000000000 --- a/libs/libzrtp/include/zrtp_list.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - - -#ifndef __ZRTP_LIST_H__ -#define __ZRTP_LIST_H__ - -#include "zrtp_config.h" - -typedef struct mlist mlist_t; -struct mlist -{ - mlist_t *next; - mlist_t *prev; -}; - -#if defined(__cplusplus) -extern "C" -{ -#endif - -/* - * \warning - * We cast pointer to integer. There is bad thing for 64 bit platforms but - * calculated offset couldn't be bigger then 2x32 and it will be casted - * to integer correctly. - */ -#define mlist_list_offset(type, list_name) ((size_t)&(((type*)0)->list_name)) - -#define mlist_get_struct(type, list_name, list_ptr) \ - ((type*)(((char*)(list_ptr)) - mlist_list_offset(type,list_name))) - -#define mlist_for_each(pos, head) \ - for (pos = (head)->next; pos != (head); pos = pos->next) - -#define mlist_for_each_safe(pos, n, head) \ - for (pos = (head)->next, n = pos->next; pos != (head); \ - pos = n, n = pos->next) - -void init_mlist(mlist_t* head); - -void mlist_add(mlist_t* head, mlist_t* node); -void mlist_add_tail(mlist_t *head, mlist_t *node); - -void mlist_insert(mlist_t *prev, mlist_t *node); - -void mlist_del(mlist_t *node); -void mlist_del_tail(mlist_t *node); - -mlist_t* mlist_get(mlist_t *head); -mlist_t* mlist_get_tail(mlist_t *head); - -int mlist_isempty(mlist_t *head); - -#if defined(__cplusplus) -} -#endif - - -#endif /*__ZRTP_LIST_H__ */ diff --git a/libs/libzrtp/include/zrtp_log.h b/libs/libzrtp/include/zrtp_log.h deleted file mode 100644 index ca2213eca4..0000000000 --- a/libs/libzrtp/include/zrtp_log.h +++ /dev/null @@ -1,169 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - -#ifndef __ZRTP_LOG_H__ -#define __ZRTP_LOG_H__ - -#include "zrtp_config.h" -#include "zrtp_types.h" -#include "zrtp_base.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define ZRTP_LOG_SENDER_MAX_LEN 12 -#define ZRTP_LOG_BUFFER_SIZE 512 - - -/*! - * \defgroup iface_log Functions for debug and information logging - * \ingroup interfaces - * \{ - */ - -/** - * @brief Write log message. - * This is the main macro used to write text to the logging backend. - * @param level The logging verbosity level. Lower number indicates higher - * importance, with level zero indicates fatal error. Only - * numeral argument is permitted (e.g. not variable). - * @param arg Enclosed 'printf' like arguments, with the first - * argument is the sender, the second argument is format - * string and the following arguments are variable number of - * arguments suitable for the format string. - * - * Sample: - * @code - * ZRTP_LOG(2, (__UNITE__, "Some log message with id %d", id)); - * @endcode - */ - -#define ZRTP_LOG(level,arg) do { \ -zrtp_log_wrapper_##level(arg); \ -} while (0) - -#define ZRTP_LOGC(level,arg) do { \ -zrtp_log_wrapperc_##level(arg); \ -} while (0) - - -/** - * @brief Signature for function to be registered to the logging subsystem to - * write the actual log message to some output device. - * - * @param level Log level. - * @param data Log message, which will be NULL terminated. - * @param len Message length. (prefix + text) - * @param offset Log message prefix length - */ -typedef void zrtp_log_engine(int level, char *data, int len, int offset); - - -#if ZRTP_LOG_MAX_LEVEL >= 1 - -/** - * @brief Changes default log writer function. - * This function may be used to implement log writer in a way native for target - * OS or product. By default libzrtp uses console output. - * @param engine - log writer. - */ -void zrtp_log_set_log_engine(zrtp_log_engine *engine); - -/** - * @brief Changes Log-Level in run-time mode - * Libzrtp uses 3 log levels: - * - 1 - system related errors; - * - 2 - security, ZRTP protocol related errors and warnings; - * - 3 - debug logging. - * By default, libzrtp uses debug logging - level 3. - * @param level - log level. - */ -void zrtp_log_set_level(uint32_t level); - -/* \} */ - -#else /* If logger is enabled */ - -# define zrtp_log_set_log_engine(engine) -# define zrtp_log_set_level(level) - -#endif /* If logger is enabled */ - - -#if ZRTP_LOG_MAX_LEVEL >= 1 -# define zrtp_log_wrapper_1(arg) zrtp_log_1 arg - void zrtp_log_1(const char *src, const char *format, ...); -# define zrtp_log_wrapperc_1(arg) zrtp_logc_1 arg - void zrtp_logc_1(const char *format, ...); -#else -# define zrtp_log_wrapper_1(arg) -# define zrtp_log_wrapperc_1(arg) -#endif - -#if ZRTP_LOG_MAX_LEVEL >= 2 -# define zrtp_log_wrapper_2(arg) zrtp_log_2 arg - void zrtp_log_2(const char *src, const char *format, ...); -# define zrtp_log_wrapperc_2(arg) zrtp_logc_2 arg - void zrtp_logc_2(const char *format, ...); -#else -#define zrtp_log_wrapper_2(arg) -#define zrtp_log_wrapperc_2(arg) -#endif - -#if ZRTP_LOG_MAX_LEVEL >= 3 -# define zrtp_log_wrapper_3(arg) zrtp_log_3 arg - void zrtp_log_3(const char *src, const char *format, ...); -# define zrtp_log_wrapperc_3(arg) zrtp_logc_3 arg - void zrtp_logc_3(const char *format, ...); - -#else -# define zrtp_log_wrapper_3(arg) -# define zrtp_log_wrapperc_3(arg) -#endif - -const char* zrtp_log_error2str(zrtp_protocol_error_t error); -const char* zrtp_log_status2str(zrtp_status_t error); - -/** Returns symbolical name of ZRTP protocol state for the current stream. */ -const char* zrtp_log_state2str(zrtp_state_t state); - -/** Returns symbolical name of ZXRTP protocol packet by it's code. */ -const char* zrtp_log_pkt2str(zrtp_msg_type_t type); - -/** Returns symbolical name of the PK Exchange mode for the current stream. */ -const char* zrtp_log_mode2str(zrtp_stream_mode_t mode); - -/** Returns symbolical name of the protocol and security events. */ -const char* zrtp_log_event2str(uint8_t event); - -/** - * Returns character name of the Signaling role. - * - * @param role One of zrtp_signaling_role_t values. - * @return character name of the \c role. - */ -const char* zrtp_log_sign_role2str(unsigned role); - - -/** Print out ZRTP environment configuration setting to log level 3. */ -void zrtp_print_env_settings(); - -/** Print out ZRTP stream info strxucture. (use ZRTP log-level 3). */ -void zrtp_log_print_streaminfo(zrtp_stream_info_t* info); - -/** Print out ZRTP session info structure. (use ZRTP log-level 3). */ -void zrtp_log_print_sessioninfo(zrtp_session_info_t* info); - -#ifdef __cplusplus -} -#endif - - -#endif /* __ZRTP_LOG_H__ */ diff --git a/libs/libzrtp/include/zrtp_pbx.h b/libs/libzrtp/include/zrtp_pbx.h deleted file mode 100644 index 485ec74670..0000000000 --- a/libs/libzrtp/include/zrtp_pbx.h +++ /dev/null @@ -1,152 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - - -/** - * \file zrtp_pbx.h - * \brief Defines basic Functions to work with MiTM endpoints - */ - -#ifndef __ZRTP_PBX_H__ -#define __ZRTP_PBX_H__ - -#include "zrtp_config.h" -#include "zrtp_types.h" - -#if defined(__cplusplus) -extern "C" -{ -#endif - -/** - * \defgroup zrtp_api_mitm PBX related functions and data types - * \ingroup zrtp_api - * - * In this section the basic functions for using the library in MiTM mode - * environment. Asterisk PBX, for example. - * \{ - */ - -/** - * \brief Start ZRTP enrollment ritual on Server side - * - * This is the equivalent of zrtp_stream_start() but for MiTM endpoints. By calling - * zrtp_stream_registration_start() libzrtp prepares to engage in the enrollment ritual: send - * special flag in Confirm packet and prepare for generating the MiTM secret. - * \return - * - zrtp_status_ok - if operation started successfully; - * - one of zrtp_status_t errorrs in other case. - * \sa zrtp_callback_event_t#on_zrtp_protocol_event - * \sa zrtp_event_t (PBX related definitions) - */ -zrtp_status_t zrtp_stream_registration_start(zrtp_stream_t* stream, uint32_t ssrc); - -/** - * \brief Continue ZRTP enrollment ritual (from CLEAR state) on Server side. - * - * This is equivalent to zrtp_stream_secure() but with enrollment ritual. Use this function instead - * of zrtp_stream_registration_start() in case when "autosecure" option is disabled for some reason. - * \return - * - zrtp_status_ok - if operation started successfully; - * - one of zrtp_status_t errorrs in other case. - */ -zrtp_status_t zrtp_stream_registration_secure(zrtp_stream_t* stream); - -/** - * \brief Confirms enrollment ritual on Client side - * - * Invocation of this function by event zrtp_protocol_event_t#ZRTP_EVENT_IS_CLIENT_ENROLLMENT - * confirms enrollment process; libzrtp generates special secret which will be used to "Sign" all - * further calls with the trusted MiTM. - * \return - * - zrtp_status_ok - in case when enrollment was completed successfully; - * - zrtp_status_fail - in case of error: wrong protocol state or system error. - */ -zrtp_status_t zrtp_register_with_trusted_mitm(zrtp_stream_t* stream); - -/** - * \brief Automatically handle ZRTP call in PBX environment - * - * This function may be called to handle ZRTP call between two ZRTP endpoints through PBX. As - * described in ID sec 8.3., there are several problems with ZRTP in PBX environment. - * zrtp_resolve_mitm_call() implements several steps to resolve such problems: - * - detect enrolled and non enrolled endpoint. If both sides are enrolled - one side for the SAS - * transfer will be chousen automatically; - * - start SAS transfer with the enrolled endpoint; - * - update flags and SAS rendering scheme if necessary. - * In other words: After switching to SECURE state, this is the one function which ZRTP MiTM - * endpoint should call to handle ZRTP call correctly. If you want to have more flexability in MiTM - * mode - resolve ambiguity manually using functions listed below. - * \param stream1 - one party of ZRTP call (must be in secure state already); - * \param stream2 - other party of ZRTP call (must be in secure state already). - * \return - * - zrtp_status_ok - if operation started successfully; - * - one of zrtp_status_t errors in other case. - * \ref XXX_DRAFT, XXX_GUIDE - */ -zrtp_status_t zrtp_resolve_mitm_call(zrtp_stream_t* stream1, zrtp_stream_t* stream2); - -/** - * @brief Links two lags of Trusted ZRTP MiTM call together. - * - * This function allows libzrtp2 to optimize protocol behavior of one leg depending on the state and - * parameters of the other lag. MitM boxes should use this API whenever possible. - * - * @param stream1 - one leg of the trusted MiTM call; - * @param stream2 - another leg of the trusted MiTM call. - * - * @return zrtp_status_ok in case of success. - */ -zrtp_status_t zrtp_link_mitm_calls(zrtp_stream_t* stream1, zrtp_stream_t* stream2); - -/** - * \brief Updates remote-side SAS value and rendering scheme - * - * zrtp_update_remote_sas() initiates process of "SAS transferring" between trusted MiTM and user. - * It allows to change as SAS rendering scheme as a SAS value and related flags as well. It the MiTM - * needs to update just one of the parameters - the other one should be set to NULL. libzrtp informs - * about status of the SAS updating through zrtp_protocol_event_t::ZRTP_EVENT_REMOTE_SAS_UPDATED. - * Call this function in SECURE state only. - * \param stream - zrtp endpoint stream to update; - * \param transf_sas_scheme - chosen SAS rendering scheme; - * \param transf_sas_value - relaying SAS value (full sas hash); - * \param transf_ac_flag - relaying "allowclear" flag; - * \param transf_d_flag - relaying "disclose" flag. - * \return - * - zrtp_status_ok - if operation started successfully; - * - one of zrtp_status_t errors in other case. - */ -zrtp_status_t zrtp_update_remote_options( zrtp_stream_t* stream, - zrtp_sas_id_t transf_sas_scheme, - zrtp_string32_t* transf_sas_value, - uint8_t transf_ac_flag, - uint8_t transf_d_flag ); - -/** - * \brief Check if user at the end of the stream \c stream is enrolled - * \param stream - stream for examining. - * \return: 1 if user is enrolled and 0 in other case - */ -uint8_t zrtp_is_user_enrolled(zrtp_stream_t* stream); - -/** - * \brief Choose single enrolled stream from two enrolled - * - * This function may be used to resolve ambiguity with call transferring between two enrolled users. - * \return stream which shuld be used for SAS transferring - */ -zrtp_stream_t* zrtp_choose_one_enrolled(zrtp_stream_t* stream1, zrtp_stream_t* stream2); - -/* \} */ - -#if defined(__cplusplus) -} -#endif - -#endif diff --git a/libs/libzrtp/include/zrtp_protocol.h b/libs/libzrtp/include/zrtp_protocol.h deleted file mode 100644 index 104d6d9be0..0000000000 --- a/libs/libzrtp/include/zrtp_protocol.h +++ /dev/null @@ -1,495 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - -#ifndef __ZRTP_PROTOCOL_H__ -#define __ZRTP_PROTOCOL_H__ - -#include "zrtp_config.h" -#include "zrtp_types.h" -#include "zrtp_error.h" - -#if defined(_MSC_VER) -#pragma warning(disable:4214) -#endif - -/*! - * \defgroup dev_protocol Protocol related data types and definitions - * \ingroup zrtp_dev - * \{ - */ - -/*! ZRTP Protocol version, retransmitted in HELLO packets */ -#define ZRTP_PROTOCOL_VERSION "1.10" -#define ZRTP_PROTOCOL_VERSION_VALUE 110 - -#define ZRTP_ZFONE_PROTOCOL_VERSION "0.10" -#define ZRTP_ZFONE_PROTOCOL_VERSION_VALUE 10 - -/* - * Protocol constants and definitions. All these values are defined by the ZRTP - * specification "ZRTP Internet Draft". - * Don't change them! - */ -#define ZRTP_S384 "S384" -#define ZRTP_S256 "S256" -#define ZRTP_S160 "S160" -#define ZRTP_AES1 "AES1" -#define ZRTP_AES3 "AES3" -#define ZRTP_HS32 "HS32" -#define ZRTP_HS80 "HS80" -#define ZRTP_DH2K "DH2k" -#define ZRTP_DH3K "DH3k" -#define ZRTP_EC256P "EC25" -#define ZRTP_EC384P "EC38" -#define ZRTP_EC521P "EC52" -#define ZRTP_MULT "Mult" -#define ZRTP_PRESHARED "Prsh" -#define ZRTP_B32 "B32 " -#define ZRTP_B256 "B256" - -#define ZRTP_ROLE_INITIATOR "Initiator" -#define ZRTP_ROLE_RESPONDER "Responder" -#define ZRTP_INITIATOR_HMAKKEY_STR "Initiator HMAC key" -#define ZRTP_RESPONDER_HMAKKEY_STR "Responder HMAC key" -#define ZRTP_GOCLEAR_STR "GoClear" -#define ZRTP_INITIATOR_KEY_STR "Initiator SRTP master key" -#define ZRTP_INITIATOR_SALT_STR "Initiator SRTP master salt" -#define ZRTP_RESPONDER_KEY_STR "Responder SRTP master key" -#define ZRTP_RESPONDER_SALT_STR "Responder SRTP master salt" -#define ZRTP_SKEY_STR "ZRTP Session Key" -#define ZRTP_SAS_STR "SAS" -#define ZRTP_RS_STR "retained secret" -#define ZRTP_INITIATOR_ZRTPKEY_STR "Initiator ZRTP key" -#define ZRTP_RESPONDER_ZRTPKEY_STR "Responder ZRTP key" -#define ZRTP_CLEAR_HMAC_STR "GoClear" -#define ZRTP_KDF_STR "ZRTP-HMAC-KDF" -#define ZRTP_SESS_STR "ZRTP Session Key" -#define ZRTP_MULTI_STR "ZRTP MSK" -#define ZRTP_PRESH_STR "ZRTP PSK" -#define ZRTP_TRUSTMITMKEY_STR "Trusted MiTM key" -#define ZRTP_COMMIT_HV_KEY_STR "Prsh" - -#define ZRTP_CACHE_DEFAULT_TTL (30*24*60*60) - -/** ZRTP Message magic Cookie */ -#define ZRTP_PACKETS_MAGIC 0x5a525450L -/** Defines ZRTP extension type for RTP protocol */ -#define ZRTP_MESSAGE_MAGIC 0x505a - - -/** - * @brief Retransmission timer T1 in milliseconds - * T1 is used for the retransmission of Hello messages. The HELLO timeout is - * doubled each time a resend occurs. The gain (max timeout value) is limited - * by @ref ZRTP_T1_CAPPING. After reaching \c ZRTP_T1_CAPPING, the state machine - * keeps resending HELLO packets until the resend count is less than \ref - * ZRTP_T1_MAX_COUNT - * @sa ZRTP_T1_MAX_COUNT ZRTP_T1_CAPPING - */ - -#define ZRTP_T1 50 - -/*! - * \brief Max resends count value for T1 timer - * This is the threshold value for HELLO replays. See \ref ZRTP_T1 ZRTP_T1 for - * details. If the resend count exceeds the value of ZRTP_T1_MAX_COUNT then - * the state machine calls _zrtp_machine_enter_initiatingerror() with error code \ref - * zrtp_protocol_error_t#zrtp_error_timeout and ZRTP session establishment is - * failed. - */ -#define ZRTP_T1_MAX_COUNT 20 - -/*! - * \brief Max resends count value for T1 timer for cases when local side have - * received remote Hello. Libzrtp uses this extended number of retries when there - * is an evidence, that remote side supports ZRTP protocol (remote Hello received). - * This approach allows to eliminate problem when ZRTP state-machine switches to - * NO_ZRTP state while remote side is computing his initial DH value. (especially - * important for slow devices) - */ -#define ZRTP_T1_MAX_COUNT_EXT 60 - -/*! Hello retries counter for ZRTP_EVENT_NO_ZRTP_QUICK event */ -#define ZRTP_NO_ZRTP_FAST_COUNT 5 - -/*! - * \brief Max T1 timeout - * ZRTP_T1_MAX_COUNT is the threshold for the growth of the timeout value of - * HELLO resends. See \ref ZRTP_T1 for details. - */ -#define ZRTP_T1_CAPPING 200 - -/*! - * \brief ZRTP stream initiation period in milliseconds - * If for some reason the initiation of a secure ZRTP stream can't be performed - * at a given time (there are no retained secrets for the session, or the - * concurrent stream is being processed in "DH" mode) the next attempt will be - * done in ZRTP_PROCESS_T1 milliseconds. If at the end of ZRTP_PROCESS_T1_MAX_COUNT - * attempts the necessary conditions haven't been reached, the task is canceled. - * The mechanism of delayed execution is the same as the mechanism of delayed - * packet sending. \sa ZRTP_PROCESS_T1_MAX_COUNT - */ -#define ZRTP_PROCESS_T1 50 - -/*! - * \brief Max recall count value - * This is the threshold value for ZRTP stream initiation tries. See \ref - * ZRTP_PROCESS_T1 for details. -*/ -#define ZRTP_PROCESS_T1_MAX_COUNT 20000 - -/*! - * \brief Retransmission timer T2 in milliseconds - * T2 is used for the retransmission of all ZRTP messages except HELLO. The - * timeout value is doubled after every retransmission. The gain (max timeout's - * value) is limited by \ref ZRTP_T2_CAPPING. \ref ZRTP_T2_MAX_COUNT is the limit - * for packets resent as for \ref ZRTP_T1. - */ -#define ZRTP_T2 150 - -/*! - * \brief Max retransmissions for non-HELLO packets - * ZRTP_T2_MAX_COUNT limits number of resends for the non-HELLO/GOCLEAR packets. - * When exceeded, call_is_on_error() is called and the error code is set to - * \ref zrtp_protocol_error_t#zrtp_error_timeout - */ -#define ZRTP_T2_MAX_COUNT 10 - - -/*! - * \brief Max timeout value for protocol packets (except HELLO and GOCLEAR) - * The resend timeout value grows until it reaches ZRTP_T2_CAPPING. After that - * the state machine keeps resending until the resend count hits the limit of - * \ref ZRTP_T2_MAX_COUNT - */ -#define ZRTP_T2_CAPPING 1200 - -/*! - * \brief Retransmission timer for GoClear resending in milliseconds. - * To prevent pinholes from closing or NAT bindings from expiring, the GoClear - * message should be resent every N seconds while waiting for confirmation from - * the user. GoClear replays are endless. - */ -#define ZRTP_T3 300 - -/*! - * \brief Set of timeouts for Error packet replays. - * The meaning of these fields are the same as in the T1 group but for - * Error/ErrorAck packets. The values of these options are not strongly - * defined by the draft. We use empirical values. - */ -#define ZRTP_ET 150 -#define ZRTP_ETI_MAX_COUNT 10 -#define ZRTP_ETR_MAX_COUNT 3 - -/* ZRTP Retries schedule for slow CSD channel */ -#define ZRTP_CSD_T4PROC 2000 - -#define ZRTP_CSD_T1 400 + ZRTP_CSD_T4PROC -#define ZRTP_CSD_T2 900 + ZRTP_CSD_T4PROC -#define ZRTP_CSD_T3 900 + ZRTP_CSD_T4PROC -#define ZRTP_CSD_T4 200 + ZRTP_CSD_T4PROC -#define ZRTP_CSD_ET 200 + ZRTP_CSD_T4PROC - - -/*! Defines the max component number which can be used in a HELLO agreement */ -#define ZRTP_MAX_COMP_COUNT 7 - - -/* - * Some definitions of protocol structure sizes. To simplify sizeof() constructions - */ -#define ZRTP_VERSION_SIZE 4 -#define ZRTP_ZID_SIZE 12 -#define ZRTP_CLIENTID_SIZE 16 -#define ZRTP_COMP_TYPE_SIZE 4 -#define ZRTP_RS_SIZE 32 -#define ZRTP_RSID_SIZE 8 -#define ZRTP_PACKET_TYPE_SIZE 8 -#define RTP_V2_HDR_SIZE 12 -#define RTP_HDR_SIZE RTP_V2_HDR_SIZE -#define RTCP_HDR_SIZE 8 -#define ZRTP_HV_SIZE 32 -#define ZRTP_HV_NONCE_SIZE 16 -#define ZRTP_HV_KEY_SIZE 8 -#define ZRTP_HMAC_SIZE 8 -#define ZRTP_CFBIV_SIZE 16 -#define ZRTP_MITM_SAS_SIZE 4 -#define ZRTP_MESSAGE_HASH_SIZE 32 -#define ZRTP_HASH_SIZE 32 - -/* Without header and HMAC: + + + + */ -#define ZRTP_HELLO_STATIC_SIZE (ZRTP_VERSION_SIZE + ZRTP_CLIENTID_SIZE + 32 + ZRTP_ZID_SIZE + 4) - -/* Without header and HMAC: + */ -#define ZRTP_DH_STATIC_SIZE (32 + 4*8) - -/* Without header and HMAC: + + */ -#define ZRTP_COMMIT_STATIC_SIZE (32 + ZRTP_ZID_SIZE + 4*5) - -/* + + + CRC32 */ -#define ZRTP_MIN_PACKET_LENGTH (RTP_HDR_SIZE + 4 + 8 + 4) - - -#if ( ZRTP_PLATFORM != ZP_SYMBIAN ) - #pragma pack(push,1) -#endif - - - -/** Base ZRTP messages header */ -typedef struct zrtp_msg_hdr -{ - /** ZRTP magic cookie */ - uint16_t magic; - - /** ZRTP message length in 4-byte words */ - uint16_t length; - - /** ZRTP message type */ - zrtp_uchar8_t type; -} zrtp_msg_hdr_t; - -/*! - * \brief ZRTP HELLO packet data - * Contains fields needed to construct/store a ZRTP HELLO packet - */ -typedef struct zrtp_packet_Hello -{ - zrtp_msg_hdr_t hdr; - /** ZRTP protocol version */ - zrtp_uchar4_t version; - - /** ZRTP client ID */ - zrtp_uchar16_t cliend_id; - - /*!< Hash to prevent DOS attacks */ - zrtp_uchar32_t hash; - - /** Endpoint unique ID */ - zrtp_uchar12_t zid; -#if ZRTP_BYTE_ORDER == ZBO_LITTLE_ENDIAN - uint8_t padding2:4; - - /** Passive flag */ - uint8_t pasive:1; - - /** M flag */ - uint8_t mitmflag:1; - - /** Signature support flag */ - uint8_t sigflag:1; - - uint8_t uflag:1; - - /** Hash scheme count */ - uint8_t hc:4; - uint8_t padding3:4; - - /** Cipher count */ - uint8_t ac:4; - - /** Hash scheme count */ - uint8_t cc:4; - - /** SAS scheme count */ - uint8_t sc:4; - - /** PK Type count */ - uint8_t kc:4; -#elif ZRTP_BYTE_ORDER == ZBO_BIG_ENDIAN - uint8_t uflag:1; - uint8_t sigflag:1; - uint8_t mitmflag:1; - uint8_t pasive:1; - uint8_t padding2:4; - uint8_t padding3:4; - uint8_t hc:4; - uint8_t cc:4; - uint8_t ac:4; - uint8_t kc:4; - uint8_t sc:4; -#endif - - zrtp_uchar4_t comp[ZRTP_MAX_COMP_COUNT*5]; - zrtp_uchar8_t hmac; -} zrtp_packet_Hello_t; - - -/** - * @brief ZRTP COMMIT packet data - * Contains information to build/store a ZRTP commit packet. - */ -typedef struct zrtp_packet_Commit -{ - zrtp_msg_hdr_t hdr; - - /** Hash to prevent DOS attacks */ - zrtp_uchar32_t hash; - - /** ZRTP endpoint unique ID */ - zrtp_uchar12_t zid; - - /** hash calculations schemes selected by ZRTP endpoint */ - zrtp_uchar4_t hash_type; - - /** cipher types selected by ZRTP endpoint */ - zrtp_uchar4_t cipher_type; - - /** SRTP auth tag lengths selected by ZRTP endpoint */ - zrtp_uchar4_t auth_tag_length; - - /** session key exchange schemes selected by endpoints */ - zrtp_uchar4_t public_key_type; - - /** SAS calculation schemes selected by endpoint*/ - zrtp_uchar4_t sas_type; - /** hvi. See "ZRTP Internet Draft" */ - zrtp_uchar32_t hv; - zrtp_uchar8_t hmac; -} zrtp_packet_Commit_t; - - -/** - * @brief ZRTP DH1/2 packets data - * Contains fields needed to constructing/storing ZRTP DH1/2 packet. - */ -typedef struct zrtp_packet_DHPart -{ - zrtp_msg_hdr_t hdr; - - /** Hash to prevent DOS attacks */ - zrtp_uchar32_t hash; - - /** hash of retained shared secret 1 */ - zrtp_uchar8_t rs1ID; - - /** hash of retained shared secret 2 */ - zrtp_uchar8_t rs2ID; - - /** hash of user-defined secret */ - zrtp_uchar8_t auxsID; - - /** hash of PBX secret */ - zrtp_uchar8_t pbxsID; - - /** pvi/pvr or nonce field depends on stream mode */ - zrtp_uchar1024_t pv; - zrtp_uchar8_t hmac; -} zrtp_packet_DHPart_t; - - -/** - * @brief ZRTP Confirm1/Confirm2 packets data - */ -typedef struct zrtp_packet_Confirm -{ - zrtp_msg_hdr_t hdr; - - /** HMAC of preceding parameters */ - zrtp_uchar8_t hmac; - - /** The CFB Initialization Vector is a 128 bit random nonce */ - zrtp_uchar16_t iv; - - /** Hash to prevent DOS attacks */ - zrtp_uchar32_t hash; - - /** Unused (Set to zero and ignored) */ - uint8_t pad[2]; - - /** Length of optional signature field */ - uint8_t sig_length; - - /** boolean flags for allowclear, SAS verified and disclose */ - uint8_t flags; - - /** how long (seconds) to cache shared secret */ - uint32_t expired_interval; -} zrtp_packet_Confirm_t; - - -/** - * @brief ZRTP Confirm1/Confirm2 packets data - */ -typedef struct zrtp_packet_SASRelay -{ - zrtp_msg_hdr_t hdr; - - /** HMAC of preceding parameters */ - zrtp_uchar8_t hmac; - - /** The CFB Initialization Vector is a 128 bit random nonce */ - zrtp_uchar16_t iv; - - /** Unused (Set to zero and ignored) */ - uint8_t pad[2]; - - /** Length of optionas signature field */ - uint8_t sig_length; - - /** boolean flags for allowclear, SAS verified and disclose */ - uint8_t flags; - - /** Rendering scheme of relayed sasvalue (for trusted MitMs) */ - zrtp_uchar4_t sas_scheme; - - /** Trusted MITM relayed sashash */ - uint8_t sashash[32]; -} zrtp_packet_SASRelay_t; - - -/** - * @brief GoClear packet structure according to ZRTP specification - */ -typedef struct zrtp_packet_GoClear -{ - zrtp_msg_hdr_t hdr; - - /** Clear HMAC to protect SRTP session from accidental termination */ - zrtp_uchar8_t clear_hmac; -} zrtp_packet_GoClear_t; - - -/** - * @brief Error packet structure in accordance with ZRTP specification - */ -typedef struct zrtp_packet_Error -{ - zrtp_msg_hdr_t hdr; - - /** ZRTP error code defined by draft and \ref zrtp_protocol_error_t */ - uint32_t code; -} zrtp_packet_Error_t; - -/** ZFone Ping Message. Similar to ZRTP protocol packet format */ -typedef struct -{ - zrtp_msg_hdr_t hdr; - zrtp_uchar4_t version; /** Zfone discovery protocol version */ - zrtp_uchar8_t endpointhash; /** Zfone endpoint unique identifier */ -} zrtp_packet_zfoneping_t; - -/** ZFone Ping MessageAck. Similar to ZRTP protocol packet format */ -typedef struct -{ - zrtp_msg_hdr_t hdr; - zrtp_uchar4_t version; /** Zfone discovery protocol version */ - zrtp_uchar8_t endpointhash; /** Zfone endpoint unique identifier */ - zrtp_uchar8_t peerendpointhash; /** EndpointHash copied from Ping message */ - uint32_t peerssrc; -} zrtp_packet_zfonepingack_t; - -/*! \} */ - -#if ( ZRTP_PLATFORM != ZP_SYMBIAN ) - #pragma pack(pop) -#endif - -#endif /*__ZRTP_PROTOCOL_H__*/ diff --git a/libs/libzrtp/include/zrtp_srtp.h b/libs/libzrtp/include/zrtp_srtp.h deleted file mode 100644 index 8a5489364a..0000000000 --- a/libs/libzrtp/include/zrtp_srtp.h +++ /dev/null @@ -1,252 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Vitaly Rozhkov - */ - -#ifndef __ZRTP_SRTP_H__ -#define __ZRTP_SRTP_H__ - -#include "zrtp_config.h" -#include "zrtp_error.h" -#include "zrtp_types.h" -#include "zrtp_crypto.h" - - -/* in host order, so outside the #if */ -#define ZRTP_RTCP_E_BIT 0x80000000 -/* for byte-access */ -#define ZRTP_RTCP_E_BYTE_BIT 0x80 -#define ZRTP_RTCP_INDEX_MASK 0x7fffffff - - -/*! - * \defgroup srtp SRTP encryption interface - * \ingroup zrtp_dev - * \{ - */ - -/* Special types and definitions for the embedded implementation */ -#if (!defined(ZRTP_USE_EXTERN_SRTP) || (ZRTP_USE_EXTERN_SRTP == 0)) -#include "zrtp_srtp_builtin.h" - -/*! - * \brief Structure describing an SRTP session. - * An instance of this structure is created by calling zrtp_srtp_create() - * and destroyed by calling zrtp_srtp_destroy(). It is used for - * protecting and unprotecting included streams. - */ -struct zrtp_srtp_ctx_t -{ - zrtp_srtp_stream_ctx_t *outgoing_srtp; /*!< pointer to outgoing SRTP stream context */ - zrtp_srtp_stream_ctx_t *incoming_srtp; /*!< pointer to incoming SRTP stream context */ -}; - -/*! - * \brief Global context of an internal SRTP implementation. - * It is created by calling zrtp_srtp_init() and destroyed by calling zrtp_srtp_down(). - * This context is used for holding replay protection mechanism data. - */ -typedef struct -{ - zrtp_rp_ctx_t *rp_ctx; /*!< pointer to replay protection context. */ -} zrtp_srtp_global_t; - -#else -typedef void zrtp_srtp_global_t; -#endif /* BUILDIN SRTP */ - -/*! Defines types of SRTP hmac functions */ -typedef enum zrtp_srtp_hash_id_t -{ - /*! - * @warning SHA1 hash algorithm is for internal use only! It used for srtp authentication and does - * not used in ZRTP protocol itself. Don't use it in \ref zrtp_profile_t#hash_schemes configuration. - */ - ZRTP_SRTP_HASH_HMAC_SHA1 = 10 -} zrtp_srtp_hash_id_t; - - -/*! - * \brief Structure describing SRTP/SRTCP stream parameters. - */ -typedef struct -{ - /*!< Cipher used to encrypt packets */ - zrtp_cipher_t *cipher; - /*! - * \brief Cipher key length in bytes (not including salt length). - * Used for cipher key derivation on stream initialization - * by calling \ref zrtp_srtp_create(). - */ - uint32_t cipher_key_len; - - /*!< Hash used for packets authentication */ - zrtp_hash_t *hash; - - /*! - * \brief Key length in bytes for HMAC generation. - * Used for auth key derivation on stream initialization by calling \ref - * zrtp_srtp_create() and for filling the key buffer with zeros on - * stream deinitialization by calling \ref zrtp_srtp_destroy(). - */ - uint32_t auth_key_len; - - /*!< Structure describing SRTP authentication scheme */ - zrtp_auth_tag_length_t *auth_tag_len; -} zrtp_srtp_policy_t; - - -/*! - * \brief Structure describing SRTP stream parameters. - * Variables of this type should be mapped into the SRTP stream context when - * a new stream is created. - */ -typedef struct -{ - zrtp_srtp_policy_t rtp_policy; /*!< crypto policy for RTP stream */ - zrtp_srtp_policy_t rtcp_policy; /*!< crypto policy for RTCP stream */ - - zrtp_cipher_t *dk_cipher; /*!< cipher for the key derivation mechanism */ - - /*!< Master key for key derivation. (holds the key value only, without the salt) */ - zrtp_string64_t key; - /*!< Master salt for key derivation. (salt should be 14 bytes length) */ - zrtp_string64_t salt; - - uint16_t ssrc; -} zrtp_srtp_profile_t; - - -/*! - * \brief Initialize SRTP engine and allocate global SRTP context. - * Contains global data for all sessions and streams. For correct memory - * management, the global SRTP context should be released by calling \ref - * zrtp_srtp_destroy(). A pointer to the allocated SRTP global should be saved - * at zrtp->srtp_global. - * \warning this function \b must be called before any operation with the SRTP - * engine. - * \param zrtp - pointer to libzrtp global context - * \return - * - zrtp_status_ok if success - * - zrtp_status_fail if error. - */ -zrtp_status_t zrtp_srtp_init(zrtp_global_t *zrtp); - -/*! - * \brief Free all allocated resources that were allocated by initialization - * This function \b must be called at the end of SRTP engine use. - * A pointer to deallocated SRTP global context (zrtp->srtp_global) - * should be cleared ( set to NULL). - * \param zrtp - pointer to libzrtp global context; - * \return - * - zrtp_status_ok - if SRTP engine has been deinitialized successfully; - * - one of \ref zrtp_status_t errors - if deinitialization failed. - */ -zrtp_status_t zrtp_srtp_down( zrtp_global_t *zrtp); - -/*! - * \brief Creates SRTP context based on given incoming and outgoing profiles. - * \param srtp_global - pointer to SRTP engine global context; - * \param inc_profile - profile for incoming stream configuration; - * \param out_profile - profile for outgoing stream configuration. - * \return - * - pointer to allocated and initialized SRTP session; - * - NULL if error. - */ -zrtp_srtp_ctx_t * zrtp_srtp_create( zrtp_srtp_global_t *srtp_global, - zrtp_srtp_profile_t *inc_profile, - zrtp_srtp_profile_t *out_profile ); - -/*! - * \brief Destroys SRTP context that was allocated by \ref zrtp_srtp_create() - * \param srtp_global - pointer to SRTP engine global context; - * \param srtp_ctx - pointer to SRTP context. - * \return - * - zrtp_status_ok - if SRTP context has been destroyed successfully; - * - one of \ref zrtp_status_t errors if error. - */ -zrtp_status_t zrtp_srtp_destroy( zrtp_srtp_global_t *srtp_global, - zrtp_srtp_ctx_t * srtp_ctx ); - - -/*! - * \brief Function applies SRTP protection to the RTP packet. - * If zrtp_status_ok is returned, then packet points to the resulting SRTP - * packet; otherwise, no assumptions should be made about the value of either - * data elements. - * \note This function assumes that it can write the authentication tag - * directly into the packet buffer, right after the the RTP payload. 32-bit - * boundary alignment of the packet is assumed as well. - * \param srtp_global - global SRTP context; - * \param srtp_ctx - SRTP context to use in processing the packet; - * \param packet - pointer to the packet to be protected. - * \return - * - zrtp_status_ok - if packet has been protected successfully; - * - one of \ref zrtp_status_t errors - if protection failed. - */ -zrtp_status_t zrtp_srtp_protect( zrtp_srtp_global_t *srtp_global, - zrtp_srtp_ctx_t *srtp_ctx, - zrtp_rtp_info_t *packet ); - -/*! - * \brief Decrypts SRTP packet. - * If zrtp_status_ok is returned, then packet points to the resulting plain RTP - * packet; otherwise, no assumptions should be made about the value of either - * data elements. - * \warning This function assumes that the SRTP packet is aligned on - * a 32-bit boundary. - * \param srtp_global - global SRTP context; - * \param srtp_ctx - SRTP context to use in processing the packet; - * \param packet - pointer to the packet to be unprotected. - * \return - * - zrtp_status_ok - if packet has been unprotected successfully - * - one of \ref zrtp_status_t errors - if decryption failed - */ -zrtp_status_t zrtp_srtp_unprotect( zrtp_srtp_global_t *srtp_global, - zrtp_srtp_ctx_t *srtp_ctx, - zrtp_rtp_info_t *packet ); - -/*! - * \brief Function applies SRTCP protection to the RTCP packet. - * If zrtp_status_ok is returned, then packet points to the result in SRTCP - * packet; otherwise, no assumptions should be made about the value of either - * data elements. - * \note This function assumes that it can write the authentication tag - * directly into the packet buffer, right after the the RTP payload. 32-bit - * boundary alignment of the packet is also assumed. - * \param srtp_global - global SRTP context; - * \param srtp_ctx - SRTP context to use in processing the packet; - * \param packet - pointer to the packet to be protected. - * \return - * - zrtp_status_ok - if packet has been protected successfully; - * - one of \ref zrtp_status_t errors - if protection failed. - */ -zrtp_status_t zrtp_srtp_protect_rtcp( zrtp_srtp_global_t *srtp_global, - zrtp_srtp_ctx_t *srtp_ctx, - zrtp_rtp_info_t *packet ); - -/*! - * \brief Decrypts SRTCP packet. - * If zrtp_status_ok is returned, then packet points to the resulting RTCP - * packet; otherwise, no assumptions should be made about the value of either - * data elements. - * \warning This function assumes that the SRTP packet is aligned on - * a 32-bit boundary. - * \param srtp_global - global SRTP context; - * \param srtp_ctx - SRTP context to use in processing the packet; - * \param packet - pointer to the packet to be unprotected. - * \return - * - zrtp_status_ok - if packet has been unprotected successfully; - * - one of \ref zrtp_status_t errors - if decryption failed. -*/ -zrtp_status_t zrtp_srtp_unprotect_rtcp( zrtp_srtp_global_t *srtp_global, - zrtp_srtp_ctx_t *srtp_ctx, - zrtp_rtp_info_t *packet ); - -/* \} */ - -#endif /*__ZRTP_SRTP_H__ */ diff --git a/libs/libzrtp/include/zrtp_srtp_builtin.h b/libs/libzrtp/include/zrtp_srtp_builtin.h deleted file mode 100644 index 0e92d4af88..0000000000 --- a/libs/libzrtp/include/zrtp_srtp_builtin.h +++ /dev/null @@ -1,149 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - * Vitaly Rozhkov - */ - -#ifndef __ZRTP_SRTP_BUILTIN_H__ -#define __ZRTP_SRTP_BUILTIN_H__ - -#include "zrtp_config.h" -#include "zrtp_error.h" -#include "zrtp_types.h" -#include "zrtp_crypto.h" - -/*! - * \defgroup dev_srtp Built in SRTP realization - * \ingroup zrtp_dev - * \{ - */ - -/*! - * \brief Sliding window width in bits. - * This window is used by the replay protection mechanism. As stated in the - * RFC3711, '3.3.2., the replay protection sliding window width MUST be at least - * 64, but MAY be set to a higher value. - */ -#if (ZRTP_PLATFORM == ZP_SYMBIAN) -# define ZRTP_SRTP_WINDOW_WIDTH 16 -#else -# define ZRTP_SRTP_WINDOW_WIDTH 128 -#endif - -#if ZRTP_SRTP_WINDOW_WIDTH % 8 -/*! - * \brief Sliding window width in bytes if padding is needed. - * This is used for allocating a window as a uint8_t array. - */ -#define ZRTP_SRTP_WINDOW_WIDTH_BYTES ZRTP_SRTP_WINDOW_WIDTH/8+1 -#else -/*! - * \brief Sliding window width in bytes if padding isn't needed. - * This is used for allocating a window as a uint8_t array. - */ -#define ZRTP_SRTP_WINDOW_WIDTH_BYTES ZRTP_SRTP_WINDOW_WIDTH/8 -#endif - -#define RP_INCOMING_DIRECTION 1 -#define RP_OUTGOING_DIRECTION 2 - - -/*! \brief Structure describing replay protection engine data */ -typedef struct -{ - uint32_t seq; /*!< sequence number of packet on the top of sliding window */ - uint8_t window[ZRTP_SRTP_WINDOW_WIDTH_BYTES]; /*!< sliding window buffer */ -} zrtp_srtp_rp_t; - - -/*! \brief Structure describing cipher wrapper */ -typedef struct -{ - /*!< cipher that will be used for packet encryption */ - zrtp_cipher_t *cipher; - - /*!< pointer to cipher's context */ - void *ctx; -} zrtp_srtp_cipher_t; - - -/*! \brief Structure describing authentication wrapper */ -typedef struct -{ - zrtp_hash_t *hash; /*!< hash component for authentication tag generation */ - uint8_t *key; /*!< key buffer for HMAC generation */ - uint32_t key_len; /*!< key length in bytes. Used for zeroes filling of buffer with key */ - zrtp_auth_tag_length_t *tag_len; /*!< SRTP authentication scheme component */ -} zrtp_srtp_auth_t; - - -/*! \brief Structure for SRTP stream context description. */ -typedef struct -{ - /*!< wrapper for cipher component and holding its auxiliary data. Used for RTP encryption */ - zrtp_srtp_cipher_t rtp_cipher; - /*!< wrapper for hash component and holding its auxiliary data. Used for RTP authentication */ - zrtp_srtp_auth_t rtp_auth; - - /*!< wrapper for cipher component and holding its auxiliary data. Used for RTCP encryption */ - zrtp_srtp_cipher_t rtcp_cipher; - /*!< wrapper for hash component and holding its auxiliary data. Used for RTCP authentication */ - zrtp_srtp_auth_t rtcp_auth; -} zrtp_srtp_stream_ctx_t; - - -/*! - * \brief Enumeration of labels used in key derivation for various purposes. - * See RFC3711, "4.3. Key Derivation" for more details - */ -typedef enum -{ - label_rtp_encryption = 0x00, /*!< for RTP cipher's key derivation */ - label_rtp_msg_auth = 0x01, /*!< for RTP packets authentication mechanism's key derivation */ - label_rtp_salt = 0x02, /*!< for RTP cipher's salt derivation */ - - label_rtcp_encryption = 0x03, /*!< used for RTCP cipher's key derivation */ - label_rtcp_msg_auth = 0x04, /*!< for RTCP packets authentication mechanism key derivation */ - label_rtcp_salt = 0x05 /*!< for RTCP cipher's salt derivation */ -} zrtp_srtp_prf_label; - -typedef zrtp_srtp_cipher_t zrtp_dk_ctx; - - -/*! - * \brief Structure describing a protection node. - * Each node keeps data for protecting RTP and RTCP packets against replays - * within streams with a given SSRC. There are two replay protection nodes for - * each SSRC value in the two lists. One is used for incoming packets and - * the other for outgoing packets. -*/ -typedef struct -{ - zrtp_srtp_rp_t rtp_rp; /*!< RTP replay protection data */ - zrtp_srtp_rp_t rtcp_rp; /*!< RTCP replay protection data */ - uint32_t ssrc; /*!< RTP media SSRC for nodes searching in the linked list */ - zrtp_srtp_ctx_t *srtp_ctx; /*!< SRTP context related with current node*/ - mlist_t mlist; -} zrtp_rp_node_t; - - -/*! -* \brief Structure describing replay protection context. -* This structure holds two linked list's heads and two mutexes for -* synchronization access to appropriate lists. -*/ -typedef struct -{ - zrtp_rp_node_t inc_head; /*!< head of replay protection nodes list for incoming packets */ - zrtp_mutex_t* inc_sync; /*!< mutex for incoming list access synchronization */ - zrtp_rp_node_t out_head; /*!< head of replay protection nodes list for outgoing packets */ - zrtp_mutex_t* out_sync; /*!< mutex for outgoing list access synchronization */ -} zrtp_rp_ctx_t; - -/* \} */ - -#endif /* __ZRTP_SRTP_BUILTIN_H__ */ diff --git a/libs/libzrtp/include/zrtp_string.h b/libs/libzrtp/include/zrtp_string.h deleted file mode 100644 index a132130cfe..0000000000 --- a/libs/libzrtp/include/zrtp_string.h +++ /dev/null @@ -1,283 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - -#ifndef __ZRTP_STRING_H__ -#define __ZRTP_STRING_H__ - -#include "zrtp_config.h" - -/** - * \file zrtp_strings.h - * \brief libzrtp safe strings - */ - -/*============================================================================*/ -/* Libzrtp Strings */ -/*============================================================================*/ - -#define ZRTP_STRING8 12 -#define ZRTP_STRING16 20 -#define ZRTP_STRING32 36 -#define ZRTP_STRING64 68 -#define ZRTP_STRING128 132 -#define ZRTP_STRING256 260 -#define ZRTP_STRING1024 1028 - - -#if ( ZRTP_PLATFORM != ZP_SYMBIAN ) -#pragma pack(push, 1) -#endif - -typedef struct zrtp_stringn -{ - uint16_t length; - uint16_t max_length; - char buffer[0]; -} zrtp_stringn_t; - -typedef struct zrtp_string8 -{ - uint16_t length; - uint16_t max_length; - char buffer[ZRTP_STRING8]; -} zrtp_string8_t; - - -typedef struct zrtp_string16 -{ - uint16_t length; - uint16_t max_length; - char buffer[ZRTP_STRING16]; -} zrtp_string16_t; - -typedef struct zrtp_string32 -{ - uint16_t length; - uint16_t max_length; - char buffer[ZRTP_STRING32]; -} zrtp_string32_t; - -typedef struct zrtp_string64 -{ - uint16_t length; - uint16_t max_length; - char buffer[ZRTP_STRING64]; -} zrtp_string64_t; - -typedef struct zrtp_string128 -{ - uint16_t length; - uint16_t max_length; - char buffer[ZRTP_STRING128]; -} zrtp_string128_t; - -typedef struct zrtp_string256 -{ - uint16_t length; - uint16_t max_length; - char buffer[ZRTP_STRING256]; -} zrtp_string256_t; - -typedef struct zrtp_string1024 -{ - uint16_t length; - uint16_t max_length; - char buffer[ZRTP_STRING1024]; -} zrtp_string1024_t; - -#if ( ZRTP_PLATFORM != ZP_SYMBIAN ) -#pragma pack(pop) -#endif - - -/** - * \defgroup zrtp_strings Libzrtp Safe Strings - * - * Using standard C-like strings is potentially dangerous in any program. All standard functions for - * working with c-strings rely on zero-termination, since c-strings don't contain a representation - * of their length. This can cause many mistakes. Moreover, it is impossible to use these strings - * for storing binary data. - * - * To solve these problems libzrtp uses zstrings instead of normal c-strings. A zstring is just a - * wrapped c-string that stores its own length. Use the following data types, macros and utility - * functions for working with zstrings in your applications. - * - * zstrings are easy to use, and at the same time light-weight and flexible. - * We use two groups of zstring types: - * \li zrtp_stringn_t - base type for all operations with zstrings; - * \li zrtp_stringXX_t group - storage types. - * - * One can use any zrtp_stringXX_t type (big enough to store necessary data) esired and operate with - * it using global zstring functions. To cast zrtp_stringXX_t to zrtp_stringn_t, the \ref ZSTR_GV - * and \ref ZSTR_GVP macros can be used. - * - * The main principle of running zstrings is storing its current data size. So to avoid mistakes and - * mess it is advised to use preestablished initialization macros. The description of each follows. - * \{ - */ - - -/** - * \brief Casts zrtp_stringXX_t to a pointer to zrtp_stringn_t. - * - * This macro prevents static casts caused by using zstring functions. Prevents mistakes and makes - * zstrings safer to use. - * \sa ZSTR_GVP - */ -#define ZSTR_GV(pstr) \ -(zrtp_stringn_t*)((char*)pstr.buffer - sizeof(pstr.max_length) - sizeof(pstr.length)) - -/** - * \brief Casts zrtp_stringXX_t* to a pointer to zrtp_stringn_t. - * - * This macro prevents static casts from using zstring functions. - * \sa ZSTR_GV - */ -#define ZSTR_GVP(pstr) \ -(zrtp_stringn_t*)((char*)pstr->buffer - sizeof(pstr->max_length) - sizeof(pstr->length)) - -/** - * \brief Macro for empty zstring initialization - * \warning Use this macro on every zrtp_string structure allocation. - * usage: \code zrtp_string_t zstr = ZSTR_INIT_EMPTY(zstr); \endcode - */ -#define ZSTR_INIT_EMPTY(a) { 0, sizeof(a.buffer) - 1, { 0 }} - -/** - * \brief Macro for zstring initialization from a constant C-string - * usage: \code zrtp_string_t zstr = ZSTR_INIT_WITH_CONST_CSTRING("zstring use example"); \endcode - */ -#define ZSTR_INIT_WITH_CONST_CSTRING(s) {sizeof(s) - 1, 0, s} - -/** - * \brief Macro for zstring clearing - * - * Use this macro for initializing already created zstrings - * usage: \code ZSTR_SET_EMPTY(zstr); \endcode - */ -#define ZSTR_SET_EMPTY(a)\ -{ a.length = 0; a.max_length = sizeof(a.buffer) - 1; a.buffer[0] = 0; } - - -#if defined(__cplusplus) -extern "C" -{ -#endif - -/** - * \brief compare two zstrings - * - * Function compares the two strings left and right. - * \param left - one string for comparing; - * \param right - the other string for comparing. - * \return - * - -1 if left string less than right; - * - 0 if left string is equal to right; - * - 1 if left string greater than right. - */ -int zrtp_zstrcmp(const zrtp_stringn_t *left, const zrtp_stringn_t *right); - -/** - * \brief Copy a zstring - * - * The zrtp_zstrcpy function copies the string pointed by src to the structure pointed to by dst. - * \param src source string; - * \param dst destination string. - */ -void zrtp_zstrcpy(zrtp_stringn_t *dst, const zrtp_stringn_t *src); - -/** - * \brief Copy first N bytes of zstring - * - * The zrtp_zstrncpy function copies the first N bytes from the string pointed to by src to the - * structure pointed by dst. - * \param src - source string; - * \param dst - destination string; - * \param size - nuber of bytes to copy. - */ -void zrtp_zstrncpy(zrtp_stringn_t *dst, const zrtp_stringn_t *src, uint16_t size); - -/** - * @brief Copy a c-string into a z-string - * \param dst - destination zsyring - * \param src - source c-string to be copied. - */ -void zrtp_zstrcpyc(zrtp_stringn_t *dst, const char *src); - - -/** - * \brief Copy first N bytes of a c-string into a z-string - * \param dst - destination zsyring - * \param src - source c-string to be copied. - * \param size - number of bytes to be copied from \c src to \c dst - */ -void zrtp_zstrncpyc(zrtp_stringn_t *dst, const char *src, uint16_t size); - -/** - * \brief Concatenate two strings - * - * The zrtp_zstrcat function appends the src string to the dst string. If dst string doesn't have - * enough space it will be truncated. - * \param src source string; - * \param dst destination string. - */ -void zrtp_zstrcat(zrtp_stringn_t *dst, const zrtp_stringn_t *src); - -/** - * \brief Clear a zstring - * \param zstr - string for clearing; - */ -void zrtp_wipe_zstring(zrtp_stringn_t *zstr); - -/** - * \brief Compare two binary strings - * - * This function is used to prevent errors caused by other, non byte-to-byte comparison - * implementations. The secret sorting function is sensitive to such things. - * - * \param s1 - first string for comparison - * \param s2 - second string for comparison - * \param n - number of bytes to be compared - * \return - an integer less than, equal to, or greater than zero, if the first n bytes of s1 - * is found, respectively, to be less than, to match, or to be greater than the first n bytes of s2. - */ -int zrtp_memcmp(const void* s1, const void* s2, uint32_t n); - -/** - * \brief Converts binary data to the hex string representation - * - * \param bin - pointer to the binary buffer for converting; - * \param bin_size - binary data size; - * \param buff - destination buffer; - * \param buff_size - destination buffer size. - * \return - * - pointer to the buff with converted data; - * - "Buffer too small" in case of error. - */ -const char* hex2str(const char* bin, int bin_size, char* buff, int buff_size); - -/** - * \brief Converts hex string to the binary representation - * - * \param buff - source buffer for converting; - * \param buff_size - source buffer size; - * \param bin - pointer to the destination binary buffer; - * \param bin_size - binary data size; - * \return - * - pointer to the buff with converted data, or NULL in case of error. - */ -char *str2hex(const char* buff, int buff_size, char* bin, int bin_size); - -#if defined(__cplusplus) -} -#endif - -/** \} */ - -#endif /* __ZRTP_STRING_H__ */ diff --git a/libs/libzrtp/include/zrtp_types.h b/libs/libzrtp/include/zrtp_types.h deleted file mode 100644 index b1282cc3e6..0000000000 --- a/libs/libzrtp/include/zrtp_types.h +++ /dev/null @@ -1,987 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - - -#ifndef __ZRTP_TYPES_H__ -#define __ZRTP_TYPES_H__ - -#include "zrtp_config.h" -#include "bn.h" -#include "zrtp_base.h" -#include "zrtp_iface.h" -#include "zrtp_list.h" -#include "zrtp_legal.h" -#include "zrtp_string.h" -#include "zrtp_protocol.h" - - -/** - * \brief Defines ZRTP state-machine states - * \ingroup zrtp_types - * - * The conditions for switching from one state to another, and libzrtp behavior in every state is - * described in detail in \ref XXX and depicted in diagram XXX and XXX. - * - * The current stream state is stored in the zrtp_stream_info_t#state variable and available for - * reading at any time. - */ -typedef enum zrtp_state_t -{ - ZRTP_STATE_NONE = 0, - ZRTP_STATE_ACTIVE, /** Just right stream attaching, before protocol start */ - ZRTP_STATE_START, /** Protocol initiated, Discovery haven't started yet */ - ZRTP_STATE_WAIT_HELLOACK, /** Hello sending, waiting for HelloAck */ - ZRTP_STATE_WAIT_HELLO, /** HelloAck received, Waiting for peer Hello */ - ZRTP_STATE_CLEAR, /** CLEAR state */ - ZRTP_STATE_START_INITIATINGSECURE, /** Starting Initiator state-machine */ - ZRTP_STATE_INITIATINGSECURE, /** Commit retries, waiting for DH1 */ - ZRTP_STATE_WAIT_CONFIRM1, /** DH2 retries, waiting for Confirm1 */ - ZRTP_STATE_WAIT_CONFIRMACK, /** Confirm2 retries, waiting for ConfirmAck */ - ZRTP_STATE_PENDINGSECURE, /** Responder state-machine, waiting for DH2 */ - ZRTP_STATE_WAIT_CONFIRM2, /** Waiting for Confirm2 to finalize ZRTP exchange */ - ZRTP_STATE_SECURE, /** SECURE state, call is encrypted */ - ZRTP_STATE_SASRELAYING, /** SAS transferring to the remote peer (for MiTM only) */ - ZRTP_STATE_INITIATINGCLEAR, /** Switching to CLEAR initated by the local endpoint */ - ZRTP_STATE_PENDINGCLEAR, /** CLEAR request have been received */ - ZRTP_STATE_INITIATINGERROR, /** Protocol ERROR detected on local side */ - ZRTP_STATE_PENDINGERROR, /** Protocol ERROR received from the remote peer */ - ZRTP_STATE_ERROR, /** Protocol ERROR state. Check zrtp_stream_info#last_error*/ -#if (defined(ZRTP_BUILD_FOR_CSD) && (ZRTP_BUILD_FOR_CSD == 1)) - ZRTP_STATE_DRIVEN_INITIATOR, - ZRTP_STATE_DRIVEN_RESPONDER, - ZRTP_STATE_DRIVEN_PENDING, -#endif - ZRTP_STATE_NO_ZRTP, /** Discovery phase failed. Remote peer doesn't support ZRTP */ - ZRTP_STATE_COUNT -} zrtp_state_t; - -/** - * \brief Enumeration for ZRTP stream mode definition - * \ingroup zrtp_types - */ -typedef enum zrtp_stream_mode_t -{ - ZRTP_STREAM_MODE_UNKN = 0, /** Unused stream - unknown mode */ - ZRTP_STREAM_MODE_CLEAR = 1, /** Just after stream attaching - mode is undefined */ - ZRTP_STREAM_MODE_DH = 2, /** FULL DH ZRTP stream mode */ - ZRTP_STREAM_MODE_PRESHARED = 3, /** Preshared ZRTP stream mode */ - ZRTP_STREAM_MODE_MULT = 4, /** Multistream ZRTP stream mode */ - ZRTP_STREAM_MODE_COUNT = 5 -} zrtp_stream_mode_t; - -/** - * \brief ZRTP session profile - * \ingroup zrtp_types - * \ingroup zrtp_main_init - * - * ZRTP Sessions are configured with a profile scheme. Each profile is defined by a structure of the - * given type. zrtp_profile_t contains a set of preferences for crypto components and other - * protocol parameters. - * - * The Crypto component choosing mechanism is as follows: both sides communicated their supported - * components during the "discovery phase". After that the initiator chooses the optimal - * intersection of components. - * - * For components identification the numerical values of the following types are used: - * zrtp_hash_id_t, zrtp_cipher_id_t, zrtp_atl_id_t, and zrtp_sas_id_t. The profile field responsible - * for components of a particular type setting is an integer-valued array where component - * identifiers should be placed in order of priority. 0-element is of the first priority. The list - * should end with ZRTP_COMP_UNKN=0. - * - * The values in the profile may be filled either by libzrtp zrtp_profile_defaults() or by the user - * manually. - * - * The profile is applied to the stream context on allocation by zrtp_session_init(). - * - * \sa XXX - */ -struct zrtp_profile_t -{ - /** - * \brief Allowclear mode flag - * - * This option means that the ZRTP peer allows SRTP termination. If allowclear is disabled, the - * ZRTP peer must stay in protected mode until the moment the ZRTP stream is shut down. When not - * in "allowclear" mode, libzrtp will reject all incoming GoClear packages and will not generate - * its own. - * - * Setting the value equal to 1 turns "allowclear" on, and 0 turns "allowclear" off. If - * "allowclear" is disabled zrtp_stream_clear() returns zrtp_status_fail. - */ - uint8_t allowclear; - - /** - * \brief ZRTP "autosecure" mode flag - * - * In "autosecure" mode, a protected connection will be initiated automatically just after - * stream start-up. If the option "autosecure" is switched off, then a secure connection can be - *initialized only by calling zrtp_stream_secure(). - */ - uint8_t autosecure; - - /** - * \brief Disclose bit. - * - * This field MUST be set by user application if it's going to disclose stream keys. - */ - uint8_t disclose_bit; - - /** - * \brief Enabled Discovery Optimization - * - * ZRTP protocol specification allows to speed-up the discovery process by sending Commit - * instead of HelloAck. This is the default behavior for most of ZRTP endpoints. It allows to - * eliminate one unnecessary exchange. - * - * At other hand, this optimization may cose some problems on slow devices: using this option, - * the endpoint starts to compute DH value right after receiving remote Hello. It may take - * seginificent amount of time on slow device (of is the device is busy on other calculations). - * As all libzrtp messages are processed in single thread, while local endpoint computing DH - * it be unable to response on remote Hello-s and remote side may switch to NO_ZRTP state. - * - * Not use this option is you running libzrtp on slow device or your software supports HQ video - * conferences. Enabled by default. - */ - uint8_t discovery_optimization; - - /** - * \brief Cache time-to-live - * - * The time interval libzrtp should retain secrets. This parameter sets the secret's time to - * live in seconds. This option is global for all connections processed by the library. It is - * used together with zrtp_session_info_t#cache_ttl. - * - * ZRTP_CACHE_DEFAULT_TTL value is used by default. - */ - uint32_t cache_ttl; - - /** \brief SAS calculation scheme preferences */ - uint8_t sas_schemes[ZRTP_MAX_COMP_COUNT+1]; - - /** \brief Cipher type preferences */ - uint8_t cipher_types[ZRTP_MAX_COMP_COUNT+1]; - - /** \brief Public key exchange scheme preferences */ - uint8_t pk_schemes[ZRTP_MAX_COMP_COUNT+1]; - - /** \brief Auth tag length preferences */ - uint8_t auth_tag_lens[ZRTP_MAX_COMP_COUNT+1]; - - /** - * \brief Hash calculation scheme preferences - * \note ZRTP_HASH_SHA256 is only one hash algorithm supported by current version of libzrtp. - */ - uint8_t hash_schemes[ZRTP_MAX_COMP_COUNT+1]; -}; - -/** - * \brief Shared secret structure - * \ingroup zrtp_iface_cache - * - * This structure stores ZRTP shared secret values used in the protocol. - */ -struct zrtp_shared_secret_t -{ - /** \brief ZRTP secret value */ - zrtp_string64_t value; - - /** - * \brief last usage time-stamp in seconds. - * - * Library updates this value on generation of the new value based on previous one. - */ - uint32_t lastused_at; - - /** - * \brief TTL value in seconds. - * - * Available for reading after the Hello exchange. Updated on switching to Secure state. - */ - uint32_t ttl; - - /** - * \brief Loaded secret flag. - * - * When the flag is set (= 1), the secret has been loaded from the cache. Otherwise the secret - * has been generated. - * \warning For internal use only. Don't modify this flag in the application. - */ - uint8_t _cachedflag; -}; - -/** - * \brief Lists MitM roles on PBX call transferring - * - * Enumeration type for the ZRTP modes based on the role of the MitM. - */ -typedef enum zrtp_mitm_mode_t -{ - /** MitM is not supported or not activated. */ - ZRTP_MITM_MODE_UNKN = 0, - - /** - * \brief Client-side mode called to the PBX in ZRTP trusted MiTM mode. - * - * Libzrtp activates this state on receiving an Hello, indicating that remote side is trusted - * MiTM. - */ - ZRTP_MITM_MODE_CLIENT, - - /** - * \brief Server-side mode to transfer SAS to the registrant. - * - * Libzrtp switches to this state on starting zrtp_update_remote_options(). - */ - ZRTP_MITM_MODE_RECONFIRM_SERVER, - /** - * \brief Client-side mode accepted SAS transfer from the trusted MiTM. - * - * Libzrtp activates this state on receiving an SASRELAY from a trusted MiTM endpoint. - */ - ZRTP_MITM_MODE_RECONFIRM_CLIENT, - /** - * \brief Server-side mode to accept the user's registration requests. - * - * Libzrtp switches to this state on starting a registration stream by - * zrtp_stream_registration_start() or zrtp_stream_registration_secure(). - */ - ZRTP_MITM_MODE_REG_SERVER, - /** - * \brief User-side mode to confirm the registration ritual. - * - * The library enables this state when a remote party invites it to the registration ritual - * by a special flag in the Confirm packet. - */ - ZRTP_MITM_MODE_REG_CLIENT -} zrtp_mitm_mode_t; - - -/** \manonly */ - - -/*======================================================================*/ -/* Internal ZRTP libzrtp datatypes */ -/*======================================================================*/ - -/** - * @defgroup types_dev libzrtp types for developers - * The data types used in inside libzrte. This section is for libzrtp developers - * @ingroup zrtp_dev - * \{ - */ - - -/** - * @brief Enumeration for ZRTP protocol packets type definition - * @warning! Don't change order of these definition without synchronizing with - * print* functions (see zrtp_log.h) - */ -typedef enum -{ - ZRTP_UNPARSED = -1, /** Unparsed packet */ - ZRTP_NONE = 0, /** Not ZRTP packet */ - ZRTP_HELLO = 1, /** ZRTP protocol HELLO packet */ - ZRTP_HELLOACK = 2, /** ZRTP protocol HELLOACK packet */ - ZRTP_COMMIT = 3, /** ZRTP protocol COMMIT packet */ - ZRTP_DHPART1 = 4, /** ZRTP protocol DHPART1 packet */ - ZRTP_DHPART2 = 5, /** ZRTP protocol DHPART2 packet */ - ZRTP_CONFIRM1 = 6, /** ZRTP protocol CONFIRM1 packet */ - ZRTP_CONFIRM2 = 7, /** ZRTP protocol CONFIRM2 packet */ - ZRTP_CONFIRM2ACK = 8, /** ZRTP protocol CONFIRM2ACK packet */ - ZRTP_GOCLEAR = 9, /** ZRTP protocol GOCLEAR packet */ - ZRTP_GOCLEARACK = 10, /** ZRTP protocol GOCLEARACK packet */ - ZRTP_ERROR = 11, /** ZRTP protocol ERROR packet */ - ZRTP_ERRORACK = 12, /** ZRTP protocol ERRORACK packet */ - ZRTP_PROCESS = 13, /** This is not a packet type but type of task for scheduler */ - ZRTP_SASRELAY = 14, /** ZRTP protocol SASRELAY packet */ - ZRTP_RELAYACK = 15, /** ZRTP protocol RELAYACK packet */ - ZRTP_ZFONEPING = 16, /** Zfone3 Ping packet */ - ZRTP_ZFONEPINGACK = 17, /** Zfone3 PingAck packet */ - ZRTP_MSG_TYPE_COUNT = 18 -} zrtp_msg_type_t; - - -/** - * @brief enumeration for protocol state-machine roles - * Protocol role fully defines it's behavior. ZRTP peer chooses a role according - * to specification. For details see internal developers documentation - */ -typedef enum zrtp_statemachine_type_t -{ - ZRTP_STATEMACHINE_NONE = 0, /** Unknown type. Used as error value */ - ZRTP_STATEMACHINE_INITIATOR = 1, /** Defines initiator's protocol logic */ - ZRTP_STATEMACHINE_RESPONDER = 2 /** Defines responder's protocol logic */ -} zrtp_statemachine_type_t; - -#define ZRTP_BIT_RS1 0x02 -#define ZRTP_BIT_RS2 0x04 -#define ZRTP_BIT_AUX 0x10 -#define ZRTP_BIT_PBX 0x20 - -/** - * @brief Library global context - * Compilers and linkers on some operating systems don't support the declaration - * of global variables in c files. Storing a context allows us to solve this - * problem in a way that unifies component use. The context is created by calling - * zrtp_init(), and is destroyed with zrtp_down(). It contains data necessary - * for crypto-component algorithms, including hash schemes, cipher types, SAS - * schemes etc. Context data can be divided into three groups: - * - ID of client ZRTP peer; - * - RNG related fields (hash context for entropy computing); - * - DH scheme related fields(internal data used for DH exchange); - * - headers of the lists of every crypto-component type used for component - * management. - * All of this data, except for "RNG related fields", is for internal use only - * and set automatically. All that is needed is to link every created session - * to global context. - * @sa zrtp_init() zrtp_down() zrtp_session_init() - */ -struct zrtp_global_t -{ - uint32_t lic_mode; /** ZRTP license mode. */ - zrtp_string16_t client_id; /** Local ZRTP client ID. */ - uint8_t is_mitm; /** Flags defines that the local endpoint acts as ZRTP MiTM. */ - MD_CTX rand_ctx; /** Hash context for entropy accumulation for the RNG unit. */ - uint8_t rand_initialized; /** RNG unit initialization flag. */ - zrtp_string256_t def_cache_path; /** Full path to ZRTP cache file. */ - unsigned cache_auto_store; /** Set when user wants libzrtp to flush the cache once it changed */ - zrtp_mutex_t* rng_protector; /** This object is used to protect the shared RNG hash zrtp#rand_ctx */ - struct BigNum one; /** This section provides static data for DH3K and DH4K components */ - struct BigNum G; - struct BigNum P_2048; - struct BigNum P_2048_1; - struct BigNum P_3072; - struct BigNum P_3072_1; - uint8_t P_2048_data[256]; - uint8_t P_3072_data[384]; - mlist_t hash_head; /** Head of hash components list */ - mlist_t cipher_head; /** Head of ciphers list */ - mlist_t atl_head; /** Head of ATL components list */ - mlist_t pktype_head; /** Head of public key exchange schemes list */ - mlist_t sas_head; /** SAS schemes list */ - void* srtp_global; /** Storage for some SRTP global data */ - mlist_t sessions_head; /** Head of ZRTP sessions list */ - uint32_t sessions_count; /** Global sessions count used to create ZRTP session IDs. For debug purposes mostly. */ - uint32_t streams_count; /** Global streams count used to create ZRTP session IDs. For debug purposes mostly. */ - zrtp_mutex_t* sessions_protector; /** This object is used to synchronize sessions list operations */ - zrtp_callback_t cb; /** Set of feedback callbacks used by libzrtp to interact with the user-space.*/ -}; - - -/** - * @brief RTP packet structure used in libzrtp - * Used for conveniently working with RTP/ZRTP packets. A binary RTP/ZRTP - * packet is converted into a zrtp_rtp_info_t structure before processing by - * _zrtp_packet_preparse() - */ -typedef struct zrtp_rtp_info_t -{ - /** Packet length in bytes */ - uint32_t *length; - - /** Pointer to the RTP/ZRTP packet body */ - char *packet; - - /** Pointer to ZRTP Message part (skip ZRTP transport header part) */ - void *message; - - /** ZRTP packet type (ZRTP_NONE in case of non command packet) */ - zrtp_msg_type_t type; - - /** Straightened RTP/ZRTP sequence number in host mode */ - uint32_t seq; - - /** RTP SSRC/ZRTP in network mode */ - uint32_t ssrc; -} zrtp_rtp_info_t; - - -/** - * @brief Retained secrets container - * Contains the session's shared secret values and related flags restored from - * the cache. Every subsequent stream within a session uses these values - * through @ref zrtp_proto_secret_t pointers. By definition, different ZRTP - * streams can't change secret values. Secret flags are protected against race - * conditions by the mutex \c _protector. For internal use only. - */ -typedef struct zrtp_secrets_t -{ - /** First retained secret RS1. */ - zrtp_shared_secret_t *rs1; - - /** Second retained secret RS1. */ - zrtp_shared_secret_t *rs2; - - /** User-defined secret. */ - zrtp_shared_secret_t *auxs; - - /** PBX Secret for trusted MiTMs. */ - zrtp_shared_secret_t *pbxs; - - /** Bit-map to summarize shared secrets "Cached" flags. */ - uint32_t cached; - uint32_t cached_curr; - - /** Bit-map to summarize shared secrets "Matches" flags. */ - uint32_t matches; - uint32_t matches_curr; - - /** Bit-map to summarize shared secrets "Wrongs" flags. */ - uint32_t wrongs; - uint32_t wrongs_curr; - - /** This flag equals one if the secrets have been uploaded from the cache. */ - uint8_t is_ready; -} zrtp_secrets_t; - - -/** - * @brief Protocol shared secret - * Wrapper around the session shared secrets \ref zrtp_shared_secret. Used - * for ID storing and secret sorting according to ZRTP ID sec. 5.4.4. - */ -typedef struct zrtp_proto_secret_t -{ - /** Local-side secret ID */ - zrtp_string8_t id; - - /** Remote-side secret ID */ - zrtp_string8_t peer_id; - - /** Pointer to the binary value and set of related flags */ - zrtp_shared_secret_t *secret; -} zrtp_proto_secret_t; - - -/** - * @brief ZRTP messages cache - * This structure contains ZRTP messages prepared for sending or received from - * the other side. This scheme allows speed-ups the resending of packets and - * computing message hashes, and makes resending thread-safe. Besides packets, - * tasks retries are stored as well. - */ -typedef struct zrtp_stream_mescache_t -{ - zrtp_packet_Hello_t peer_hello; - zrtp_packet_Hello_t hello; - zrtp_packet_GoClear_t goclear; - zrtp_packet_Commit_t peer_commit; - zrtp_packet_Commit_t commit; - zrtp_packet_DHPart_t peer_dhpart; - zrtp_packet_DHPart_t dhpart; - zrtp_packet_Confirm_t confirm; - zrtp_string32_t h0; - zrtp_packet_Confirm_t peer_confirm; - zrtp_packet_Error_t error; - zrtp_packet_SASRelay_t sasrelay; - - zrtp_retry_task_t hello_task; - zrtp_retry_task_t goclear_task; - zrtp_retry_task_t dh_task; - zrtp_retry_task_t commit_task; - zrtp_retry_task_t dhpart_task; - zrtp_retry_task_t confirm_task; - zrtp_retry_task_t error_task; - zrtp_retry_task_t errorack_task; - zrtp_retry_task_t sasrelay_task; - - /*! - * Hash pre-image of the remote party Hello retrieved from Signaling. When - * user calls zrtp_signaling_hash_set() libzrtp stores hash value in this - * variable and checks all incoming Hello-s to prevent DOS attacks. - */ - zrtp_string64_t signaling_hash; -} zrtp_stream_mescache_t; - - -/** - * @brief Crypto context for Diffie-Hellman calculations - * Used only by DH streams to store Diffie-Hellman calculations. Allocated on - * protocol initialization and released on switching to SECURE mode. - */ -typedef struct zrtp_dh_crypto_context_t -{ - /** DH secret value */ - struct BigNum sv; - - /** DH public value */ - struct BigNum pv; - - /** DH public value recalculated for remote side */ - struct BigNum peer_pv; - - /** DH shared secret. DHSS = hash(DHResult) */ - zrtp_string64_t dhss; - - unsigned int initialized_with; -} zrtp_dh_crypto_context_t; - - -/*! - * \brief Crypto context for ECDSA calculations - * Used to store ECDSA keys and calculations. Allocated on - * protocol initialization and released on switching to SECURE mode. - */ -typedef struct zrtp_dsa_crypto_context_t -{ - struct BigNum sv; /*!< DSA secret value */ - struct BigNum pv; /*!< DSA public value */ - struct BigNum peer_pv;/*!< DSA public value for some remote side */ -} zrtp_dsa_crypto_context_t; - - -/** - * @brief Protocol crypto context - * Used as temporary storage for ZRTP crypto data during protocol running. - * Unlike \ref zrtp_stream_crypto_t this context is needed only during key - * negotiation and destroyed on switching to SECURE state. - */ -typedef struct zrtp_proto_crypto_t -{ - /** ZRTP */ - zrtp_string128_t kdf_context; - - /** ZRTP stream key */ - zrtp_string64_t s0; - - /** Local hvi value for the hash commitment: hvi or nonce for Multistream. */ - zrtp_string64_t hv; - - /** Remove hvi value for the hash commitment: hvi or nonce for Multistream. */ - zrtp_string64_t peer_hv; - - /** Total messages hash. See ZRTP ID 5.4.4/5.5.4 */ - zrtp_string64_t mes_hash; - - /** RS1 */ - zrtp_proto_secret_t rs1; - - /** RS2 */ - zrtp_proto_secret_t rs2; - - /** User-Defined secret */ - zrtp_proto_secret_t auxs; - - /** PBX secret */ - zrtp_proto_secret_t pbxs; -} zrtp_proto_crypto_t; - -/*! - * \brief ZRTP protocol structure - * Protocol structure is responsible for ZRTP protocol logic (CLEAR-SECURE - * switching) and RTP media encrypting/decrypting. The protocol is created - * right after the discovery phase and destroyed on stream closing. - */ -struct zrtp_protocol_t -{ - /** Protocol mode: responder or initiator. */ - zrtp_statemachine_type_t type; - - /** Context for storing protocol crypto data. */ - zrtp_proto_crypto_t* cc; - - /** SRTP crypto engine */ - zrtp_srtp_ctx_t* _srtp; - - /** Back-pointer to ZRTP stream context. */ - zrtp_stream_t *context; -}; - -/** - * @brief Stream-persistent crypto options. - * Unlike \ref zrtp_proto_crypto_t these data are kept after switching to Secure - * state or stopping the protocol; used to sign/verify Confirm and GoClear packets. - */ -typedef struct zrtp_stream_crypto_t -{ - /** Local side hmackey value. */ - zrtp_string64_t hmackey; - - /** Remote side hmackey value. */ - zrtp_string64_t peer_hmackey; - - /** Local side ZRTP key for Confirms protection. */ - zrtp_string64_t zrtp_key; - - /** Remote side ZRTP key for Confirms verification. */ - zrtp_string64_t peer_zrtp_key; -} zrtp_stream_crypto_t; - - -/** - * @brief stream media context. Contains all RTP media-related information. - */ -typedef struct zrtp_media_context_t -{ - /** The highest ZRTP message sequence number received. */ - uint32_t high_in_zrtp_seq; - - /** The last ZRTP message sequence number sent. */ - uint32_t high_out_zrtp_seq; - - /** The highest RTP media sequence number received; used by SRTP. */ - uint32_t high_in_media_seq; - - /** The highest RTP media sequence number sent; used by SRTP. */ - uint32_t high_out_media_seq; - - /** SSRC of the RTP media stream associated with the current ZRTP stream. */ - uint32_t ssrc; -} zrtp_media_context_t; - -/*! - * \brief ZRTP stream context - * \warning Fields with prefix "_" are for internal use only. - */ -struct zrtp_stream_t -{ - /*! Stream unique identifier for debug purposes */ - zrtp_id_t id; - - /*! - * \brief Stream mode - * This field defines libzrtp behavior related to specified contexts. See - * "ZRTP Internet Draft" - * and \ref usage for additional information about stream types and their - * processing logic. - */ - zrtp_stream_mode_t mode; - - /*! - * \brief Defines ZRTP role in trusted MitM scheme. - * The value of this mode determines the behavior of the ZRTP machine - * according to it's role in the MitM scheme. Initially the mode is - * ZRTP_MITM_MODE_UNKN and then changes on protocol running. - */ - zrtp_mitm_mode_t mitm_mode; - - /*! - * \brief Previous ZRTP protocol states - * Used in analysis to determine the reason for a switch from one state to - * another. Enabled by _zrtp_change_state(. - */ - zrtp_state_t prev_state; - - /** 1 means that peer Hello have been raceived within current ZRTP session */ - uint8_t is_hello_received; - - /*!< Reflects current state of ZRTP protocol */ - zrtp_state_t state; - - /** - * @brief Persistent stream crypto options. - * Stores persistent crypto data needed after Confirmation. This data can be - * cleared only when the stream is destroyed. - */ - zrtp_stream_crypto_t cc; - - /** DH crypto context used in PK calculations */ - zrtp_dh_crypto_context_t dh_cc; - - /*! - * \brief Pointer to the ZRTP protocol implementation - * The protocol structure stores all crypto data during the securing - * procedure. After switching to SECURE state the protocol clears all - * crypto sources and performs traffic encryption/decryption. - */ - zrtp_protocol_t *protocol; - - /*!< Holder for RTP/ZRTP media stream options. */ - zrtp_media_context_t media_ctx; - - /*!< ZRTP messages and task retries cache */ - zrtp_stream_mescache_t messages; - - /*! - * Current value of "allowclear" option exchanged during ZRTP negotiation. - * Available for reading in SECURE state. - */ - uint8_t allowclear; - - /*! - * This flag shows when remote side is "passive" (has license mode PASSIVE) - * Available for reading in CLEAR state. - */ - uint8_t peer_passive; - - /*! - * \brief actual lifetime of stream secrets - * This variable contains the interval for retaining secrets within an - * established stream. In accordance with "ZRTP Internet Draft" - * this value is calculated as the minimal of local and remote TTLs after - * confirmation. Value is given in seconds and can be read in the SECURE - * state. It may be used in displaying session parameters. - */ - uint32_t cache_ttl; - - /*! - * \brief Peer disclose bit Indicates the ability of the remote side to - * disclose its session key. Specifies that the remote side allows call - * monitoring. If this flag is set, the end user must be informed. It can - * be read in the SECURE state. - */ - uint8_t peer_disclose_bit; - - /*! - * \brief Last protocol error code - * If there is a mistake in running the protocol, zrtp_event_callback() - * will be called and the required error code will be set to this field. - * An error code is the numeric representation of ZRTP errors defined in - * the draft. All error codes are defined by \ref zrtp_protocol_error_t. - */ - zrtp_protocol_error_t last_error; - - /** - * Duplicates MiTM flag from peer Hello message - */ - uint8_t peer_mitm_flag; - - /** - * Duplicates U flag from peer Hello message - */ - uint8_t peer_super_flag; - - /*! - * \brief Pointer to the concurrent DH stream - * If Commit messages are sent by both ZRTP endpoints at the same time, but - * are received in different media streams, "tie-breaking" rules apply - the - * Commit message with the lowest hvi value is discarded and the other side - * becomes the initiator. The media stream in which the Commit was sent will - * proceed through the ZRTP exchange while the media stream with the discarded - * Commit must wait for the completion of the other ZRTP exchange. A pointer - * to that "waiting" stream is stored in \c _concurrent. When the running - * stream is switched to "Initiating Secure" the concurrent stream is resumed. - */ - zrtp_stream_t *concurrent; - - /** Back-pointer to the ZRTP global data */ - zrtp_global_t *zrtp; - - /** Pointer to parent session context. Used for back capability */ - zrtp_session_t *session; - - /*!< Public key exchange component used within current stream */ - zrtp_pk_scheme_t *pubkeyscheme; - - /*! - * Pointer to the user data. This pointer can be used for fast access to - * some additional data attached to this ZRTP stream by the user application - */ - void *usr_data; - - /*! - * Pointer to the peer stream during a trusted MiTM call. - * @sa zrtp_link_mitm_calls() - */ - zrtp_stream_t *linked_mitm; - - /*! - * \brief Stream data protector - * A mutex is used to avoid race conditions during asynchronous calls - * (zrtp_stream_secure(), zrtp_stream_clear() etc.) in parallel to the main - * processing loop zrtp_process_rtp/srtp(). - */ - zrtp_mutex_t* stream_protector; -}; - - -/*! - * \brief ZRTP session context - * Describes the state of the ZRTP session. Stores data necessary and sufficient - * for processing ZRTP sessions. Encapsulates ZRTP streams and all crypto-data. - */ -struct zrtp_session_t -{ - /*! Session unique identifier for debug purposes */ - zrtp_id_t id; - - /*! - * \brief Local-side ZID - * The unique 12-characters string that identifies the local ZRTP endpoint. - * It must be generated by the user application on installation and used - * permanently for every ZRTP session. This ID allows remote peers to - * recognize this ZRTP endpoint. - */ - zrtp_string16_t zid; - - /*! - * \brief Remote-side ZID - * Extracted from the Hello packet of the very first ZRTP stream. Uniquely - * identifies the remote ZRTP peer. Used in combination with the local zid - * to restore secrets and other data from the previous call. Available for - * reading after the discovering phase. - */ - zrtp_string16_t peer_zid; - - /*!< ZRTP profile, defined crypto options and behavior for every stream within current session */ - zrtp_profile_t profile; - - /* - * Signaling Role which protocol was started with, one of zrtp_signaling_role_t values. - */ - unsigned signaling_role; - - /*! - * \brief Set of retained secrets and flags for the current ZRTP session. - * libzrtp uploads secrets and flags from the cache on the very first - * stream within every ZRTP session. - */ - zrtp_secrets_t secrets; - - /*!< ZRTP session key used to extend ZRTP session without additional DH exchange */ - zrtp_string64_t zrtpsess; - - /** First SAS base32/256 string */ - zrtp_string16_t sas1; - - /** Second SAS 256 string */ - zrtp_string16_t sas2; - - /** Binary SAS digest (ZRTP_SAS_DIGEST_LENGTH bytes) */ - zrtp_string32_t sasbin; - - /*!< Back-pointer to the ZRTP global data */ - zrtp_global_t *zrtp; - - /*!< Back-pointer to user data associated with this session context. */ - void *usr_data; - - /** Hash component used within current session */ - zrtp_hash_t *hash; - - /** Cipher component used within current session */ - zrtp_cipher_t *blockcipher; - - /** SRTP authentication component used within current session */ - zrtp_auth_tag_length_t *authtaglength; - - /** SAS scheme component used within current session */ - zrtp_sas_scheme_t *sasscheme; - - /** List of ZRTP streams attached to the session. */ - zrtp_stream_t streams[ZRTP_MAX_STREAMS_PER_SESSION]; - - /** This object is used to synchronize all stream list operations */ - zrtp_mutex_t* streams_protector; - - /** Prevents race conditions if streams start simultaneously. */ - zrtp_mutex_t* init_protector; - - /** - * This flag indicates that possible MiTM attach was detected during the protocol exchange. - */ - uint8_t mitm_alert_detected; - - mlist_t _mlist; -}; - -/*! \} */ - - -/*===========================================================================*/ -/* Data types and definitions for SRTP */ -/*===========================================================================*/ - -#if ZRTP_BYTE_ORDER == ZBO_LITTLE_ENDIAN - -/** - * RTP header structure - * @ingroup dev_srtp - */ -typedef struct -{ - uint16_t cc:4; /** CSRC count */ - uint16_t x:1; /** header extension flag */ - uint16_t p:1; /** padding flag */ - uint16_t version:2; /** protocol version */ - uint16_t pt:7; /** payload type */ - uint16_t m:1; /** marker bit */ - uint16_t seq; /** sequence number */ - uint32_t ts; /** timestamp */ - uint32_t ssrc; /** synchronization source */ -} zrtp_rtp_hdr_t; - -/** - * RTCP header structure - * @ingroup dev_srtp - */ -typedef struct -{ - unsigned char rc:5; /** reception report count */ - unsigned char p:1; /** padding flag */ - unsigned char version:2; /** protocol version */ - unsigned char pt:8; /** payload type */ - uint16_t len; /** length */ - uint32_t ssrc; /** synchronization source */ -} zrtp_rtcp_hdr_t; - -typedef struct -{ - unsigned int index:31; /** srtcp packet index in network order! */ - unsigned int e:1; /** encrypted? 1=yes */ - /** optional mikey/etc go here */ - /** and then the variable-length auth tag */ -} zrtp_rtcp_trailer_t; - -#else - -/** - * RTP header structure - * @ingroup dev_srtp - */ -typedef struct -{ - uint16_t version:2; /** protocol version */ - uint16_t p:1; /** padding flag */ - uint16_t x:1; /** header extension flag */ - uint16_t cc:4; /** CSRC count */ - uint16_t m:1; /** marker bit */ - uint16_t pt:7; /** payload type */ - uint16_t seq; /** sequence number */ - uint32_t ts; /** timestamp */ - uint32_t ssrc; /** synchronization source */ -} zrtp_rtp_hdr_t; - -/** - * RTCP header structure - * @ingroup dev_srtp - */ -typedef struct -{ - unsigned char version:2; /** protocol version */ - unsigned char p:1; /** padding flag */ - unsigned char rc:5; /** reception report count */ - unsigned char pt:8; /** payload type */ - uint16_t len; /** length */ - uint32_t ssrc; /** synchronization source */ -} zrtp_rtcp_hdr_t; - -typedef struct -{ - unsigned int e:1; /** encrypted? 1=yes */ - unsigned int index:31; /** srtcp packet index */ -} zrtp_rtcp_trailer_t; - -#endif - -/** - * RTP header extension structure - * @ingroup dev_srtp - */ -typedef struct -{ - uint16_t profile_specific; /** profile-specific info */ - uint16_t length; /** number of 32-bit words in extension */ -} zrtp_rtp_hdr_xtnd_t; - - -/** \endmanonly */ - -#endif /* __ZRTP_TYPES_H__ */ diff --git a/libs/libzrtp/include/zrtp_version.h b/libs/libzrtp/include/zrtp_version.h deleted file mode 100644 index fc0a349442..0000000000 --- a/libs/libzrtp/include/zrtp_version.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - -#ifndef __ZRTP_VERSION_H__ -#define __ZRTP_VERSION_H__ - -#define LIBZRTP_VERSION_MAJOR 1 - -#define LIBZRTP_VERSION_MINOR 20 -#define LIBZRTP_VERSION_BUILD 616 -#define LIBZRTP_VERSION_STR "v1.20 616" - -#endif /*__ZRTP_VERSION_H__*/ diff --git a/libs/libzrtp/projects/android/jni/Android.mk b/libs/libzrtp/projects/android/jni/Android.mk deleted file mode 100644 index cb3837b6bf..0000000000 --- a/libs/libzrtp/projects/android/jni/Android.mk +++ /dev/null @@ -1,72 +0,0 @@ -LOCAL_PATH := $(call my-dir)/../../.. - -include $(CLEAR_VARS) - -LOCAL_MODULE := libzrtp -MY_SRC_PATH := src - -MY_SRC_FILES := $(MY_SRC_PATH)/zrtp.c \ - $(MY_SRC_PATH)/zrtp_crc.c \ - $(MY_SRC_PATH)/zrtp_crypto_aes.c \ - $(MY_SRC_PATH)/zrtp_crypto_atl.c \ - $(MY_SRC_PATH)/zrtp_crypto_hash.c \ - $(MY_SRC_PATH)/zrtp_crypto_pk.c \ - $(MY_SRC_PATH)/zrtp_crypto_sas.c \ - $(MY_SRC_PATH)/zrtp_datatypes.c \ - $(MY_SRC_PATH)/zrtp_engine.c \ - $(MY_SRC_PATH)/zrtp_engine_driven.c \ - $(MY_SRC_PATH)/zrtp_iface_cache.c \ - $(MY_SRC_PATH)/zrtp_iface_scheduler.c \ - $(MY_SRC_PATH)/zrtp_iface_sys.c \ - $(MY_SRC_PATH)/zrtp_initiator.c \ - $(MY_SRC_PATH)/zrtp_legal.c \ - $(MY_SRC_PATH)/zrtp_list.c \ - $(MY_SRC_PATH)/zrtp_log.c \ - $(MY_SRC_PATH)/zrtp_pbx.c \ - $(MY_SRC_PATH)/zrtp_protocol.c \ - $(MY_SRC_PATH)/zrtp_responder.c \ - $(MY_SRC_PATH)/zrtp_rng.c \ - $(MY_SRC_PATH)/zrtp_srtp_builtin.c \ - $(MY_SRC_PATH)/zrtp_srtp_dm.c \ - $(MY_SRC_PATH)/zrtp_string.c \ - $(MY_SRC_PATH)/zrtp_utils.c \ - $(MY_SRC_PATH)/zrtp_utils_proto.c - -MY_SRC_FILES += third_party/bgaes/aes_modes.c \ - third_party/bgaes/sha2.c \ - third_party/bgaes/sha1.c \ - third_party/bgaes/aestab.c \ - third_party/bgaes/aeskey.c \ - third_party/bgaes/aescrypt.c - -MY_SRC_FILES += third_party/bnlib/bn.c \ - third_party/bnlib/bn32.c \ - third_party/bnlib/bninit32.c \ - third_party/bnlib/lbn32.c \ - third_party/bnlib/lbnmem.c \ - third_party/bnlib/legal.c - -LOCAL_SRC_FILES := $(MY_SRC_FILES) - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/include -LOCAL_C_INCLUDES += $(LOCAL_PATH)/third_party/bnlib -LOCAL_C_INCLUDES += $(LOCAL_PATH)/third_party/bgaes - -LOCAL_ARM_MODE := arm -LOCAL_CFLAGS := -DANDROID_NDK=5 - -#include $(BUILD_STATIC_LIBRARY) -include $(BUILD_SHARED_LIBRARY) - -# -# Dummy shared library to build libzrtp.a -# - -# include $(CLEAR_VARS) -# -# LOCAL_MODULE := libzrtp-dummy -# LOCAL_STATIC_LIBRARIES := libzrtp -# -# include $(BUILD_SHARED_LIBRARY) diff --git a/libs/libzrtp/projects/symbian/DelayRuner.cpp b/libs/libzrtp/projects/symbian/DelayRuner.cpp deleted file mode 100644 index e0297d63ff..0000000000 --- a/libs/libzrtp/projects/symbian/DelayRuner.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - ============================================================================ - Name : CDelayRuner.cpp - Author : R. Drutsky - Version : 1.0 - Copyright : Copyright (c) 2010 Soft Industry - Description : CCDelayRuner implementation - ============================================================================ - */ - -#include "DelayRuner.h" -#include "zrtp_iface_system.h" - -void zrtp_internal_delete_task_from_list(zrtp_stream_t* ctx, zrtp_retry_task_t* ztask); - -CDelayRuner::CDelayRuner() : - CActive(EPriorityLow) // Standard priority - { - } - -CDelayRuner* CDelayRuner::NewLC() - { - CDelayRuner* self = new (ELeave) CDelayRuner(); - CleanupStack::PushL(self); - self->ConstructL(); - return self; - } - -CDelayRuner* CDelayRuner::NewL() - { - CDelayRuner* self = CDelayRuner::NewLC(); - CleanupStack::Pop(); // self; - return self; - } - -void CDelayRuner::ConstructL() - { - User::LeaveIfError(iTimer.CreateLocal()); // Initialize timer - CActiveScheduler::Add(this); // Add to scheduler - } - -CDelayRuner::~CDelayRuner() - { - Cancel(); // Cancel any request, if outstanding - iTimer.Close(); // Destroy the RTimer object - // Delete instance variables if any - } - -void CDelayRuner::DoCancel() - { - iTimer.Cancel(); - } - -void CDelayRuner::StartL(zrtp_stream_t *ctx, zrtp_retry_task_t* ztask) - { - Cancel(); // Cancel any request, just to be sure - //iState = EUninitialized; - iCtx = ctx; - iZTask = ztask; - iTimer.After(iStatus, ztask->timeout * 1000); // Set for later - SetActive(); // Tell scheduler a request is active - } - -void CDelayRuner::RunL() - { - if (iStatus == KErrNone) - { - // Do something useful - iZTask->_is_busy = 1 ; // may be we don't need this - (iZTask->callback)(iCtx,iZTask); - iZTask->_is_busy = 0 ; // may be we don't need this - } - zrtp_internal_delete_task_from_list(iCtx,iZTask); - } - -TInt CDelayRuner::RunError(TInt aError) - { - return aError; - } diff --git a/libs/libzrtp/projects/symbian/DelayRuner.h b/libs/libzrtp/projects/symbian/DelayRuner.h deleted file mode 100644 index ae19f3a4e6..0000000000 --- a/libs/libzrtp/projects/symbian/DelayRuner.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - ============================================================================ - Name : CDelayRuner.h - Author : R. Drutsky - Version : 1.0 - Copyright : Copyright (c) 2010 Soft Industry - Description : CDelayRuner declaration - ============================================================================ - */ - -#ifndef DELAYRUNER_H -#define DELAYRUNER_H - -#include // For CActive, link against: euser.lib -#include // For RTimer, link against: euser.lib - -#include -class CDelayRuner : public CActive - { -public: - // Cancel and destroy - ~CDelayRuner(); - - // Two-phased constructor. - static CDelayRuner* NewL(); - - // Two-phased constructor. - static CDelayRuner* NewLC(); - -public: - // New functions - // Function for making the initial request - void StartL(zrtp_stream_t *ctx, zrtp_retry_task_t* ztask); - -private: - // C++ constructor - CDelayRuner(); - - // Second-phase constructor - void ConstructL(); - -private: - // From CActive - // Handle completion - void RunL(); - - // How to cancel me - void DoCancel(); - - // Override to handle leaves from RunL(). Default implementation causes - // the active scheduler to panic. - TInt RunError(TInt aError); - -private: - enum TCDelayRunerState - { - EUninitialized, // Uninitialized - EInitialized, // Initalized - EError - // Error condition - }; - -private: - TInt iState; // State of the active object - RTimer iTimer; // Provides async timing service - - zrtp_stream_t *iCtx; - zrtp_retry_task_t * iZTask; - - }; - -#endif // CDELAYRUNER_H diff --git a/libs/libzrtp/projects/symbian/bld.bat b/libs/libzrtp/projects/symbian/bld.bat deleted file mode 100755 index 0bbff637c6..0000000000 --- a/libs/libzrtp/projects/symbian/bld.bat +++ /dev/null @@ -1 +0,0 @@ -bldmake bldfiles \ No newline at end of file diff --git a/libs/libzrtp/projects/symbian/bld.inf b/libs/libzrtp/projects/symbian/bld.inf deleted file mode 100644 index f477ab57f7..0000000000 --- a/libs/libzrtp/projects/symbian/bld.inf +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2006-2007 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * - * Nikolay Popok mailto: - * - */ - -PRJ_MMPFILES -libzrtp.mmp - -PRJ_PLATFORMS -WINSCW GCCE WINC diff --git a/libs/libzrtp/projects/symbian/bldgcce.bat b/libs/libzrtp/projects/symbian/bldgcce.bat deleted file mode 100755 index cf1e17b541..0000000000 --- a/libs/libzrtp/projects/symbian/bldgcce.bat +++ /dev/null @@ -1,2 +0,0 @@ -abld build gcce urel -pause \ No newline at end of file diff --git a/libs/libzrtp/projects/symbian/libzrtp.mmp b/libs/libzrtp/projects/symbian/libzrtp.mmp deleted file mode 100644 index ba6a7a1001..0000000000 --- a/libs/libzrtp/projects/symbian/libzrtp.mmp +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - */ - -TARGET libzrtp.lib -TARGETTYPE lib -UID 0x0FFFFFF0 - -VENDORID 0 - -//OPTION GCC +Wno-ctor-dtor-privacy -MACRO ZRTP_USE_STACK_MINIM - -USERINCLUDE . - -SOURCEPATH . -SOURCE DelayRuner.cpp -SOURCE zrtp_iface_symb.cpp - -SOURCEPATH ..\..\third_party\bnlib -SOURCE bn.c -SOURCE bn32.c -SOURCE bninit32.c -SOURCE lbn32.c -SOURCE lbnmem.c -SOURCE legal.c - -SOURCEPATH ..\..\src -SOURCE zrtp_crc.c -SOURCE zrtp_crypto_aes.c -SOURCE zrtp_crypto_atl.c -SOURCE zrtp_crypto_hash.c -SOURCE zrtp_crypto_pk.c -SOURCE zrtp_crypto_sas.c -SOURCE zrtp_datatypes.c -SOURCE zrtp_engine.c -SOURCE zrtp_iface_cache.c -SOURCE zrtp_iface_scheduler.c -SOURCE zrtp_iface_sys.c -SOURCE zrtp_initiator.c -SOURCE zrtp_list.c -SOURCE zrtp_log.c -SOURCE zrtp_pbx.c -SOURCE zrtp_protocol.c -SOURCE zrtp_responder.c -SOURCE zrtp_rng.c -SOURCE zrtp_srtp_builtin.c -SOURCE zrtp_string.c -SOURCE zrtp_utils.c -SOURCE zrtp_utils_proto.c -SOURCE zrtp.c - -SOURCEPATH ..\..\third_party\bgaes -SOURCE aes_modes.c -SOURCE aescrypt.c -SOURCE aeskey.c -SOURCE aestab.c -SOURCE sha1.c -SOURCE sha2.c - -SYSTEMINCLUDE ..\..\. -SYSTEMINCLUDE ..\..\include -SYSTEMINCLUDE ..\..\third_party\bnlib -SYSTEMINCLUDE ..\..\third_party\bgaes - -SYSTEMINCLUDE \epoc32\include -SYSTEMINCLUDE \epoc32\include\libc - -LIBRARY euser.lib - -SOURCEPATH ..\..\src -SOURCE zrtp_crypto_ec.c zrtp_crypto_ecdh.c zrtp_crypto_ecdsa.c zrtp_engine_driven.c zrtp_legal.c zrtp_srtp_dm.c diff --git a/libs/libzrtp/projects/symbian/zrtp_iface_symb.cpp b/libs/libzrtp/projects/symbian/zrtp_iface_symb.cpp deleted file mode 100644 index bfbe93770b..0000000000 --- a/libs/libzrtp/projects/symbian/zrtp_iface_symb.cpp +++ /dev/null @@ -1,336 +0,0 @@ -/* - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - */ - -#include -#include -#include - -#include - -#include -#include -#include - -#include - -extern "C" -{ -/** - * @brief Get kernel-generated random number - * @bug seems not work - * @return 32 random bits - */ -uint32_t zrtp_symbian_kernel_random(); - -/** - * @brief Pseudo random number: sum of pid's shifted and xored by number of precceses - * @return - */ -uint32_t zrtp_sum_of_pid_and_number_of_poccesses(); - -/** - * @brief Number of milisecond past from particular date and time - * @return - */ -uint64_t zrtp_get_system_time_crazy(); - -/** - * @brief Current procces PID - * @return PID - */ -unsigned int zrtp_get_pid(); - -/** - * @brief Availible memory - * @return memory availible on heap - */ -uint32_t zrtp_get_availible_heap(); - -} - - - -//----------------------------------------------------------------------------- -zrtp_status_t zrtp_mutex_init(zrtp_mutex_t **mutex) { - RMutex *rmutex = new RMutex(); - //rmutex->CreateLocal(); was before - rmutex->CreateGlobal(KNullDesC); - *mutex = (zrtp_mutex_t*) rmutex; - return zrtp_status_ok; -} - -zrtp_status_t zrtp_mutex_lock(zrtp_mutex_t* mutex) { - RMutex *rmutex = (RMutex *) mutex; - rmutex->Wait(); - return zrtp_status_ok; -} - -zrtp_status_t zrtp_mutex_unlock(zrtp_mutex_t* mutex) { - RMutex *rmutex = (RMutex *) mutex; - rmutex->Signal(); - return zrtp_status_ok; -} - -zrtp_status_t zrtp_mutex_destroy(zrtp_mutex_t* mutex) { - RMutex *rmutex = (RMutex *) mutex; - if (rmutex) { - rmutex->Close(); - delete rmutex; - } - return zrtp_status_ok; -} - -//----------------------------------------------------------------------------- -zrtp_status_t zrtp_sem_init(zrtp_sem_t** sem, uint32_t value, uint32_t limit) { - RSemaphore *rsem = new RSemaphore(); - //rsem->CreateLocal(value); - rsem->CreateGlobal(KNullDesC,value); - *sem = (zrtp_sem_t*) rsem; - return zrtp_status_ok; -} - -zrtp_status_t zrtp_sem_destroy(zrtp_sem_t* sem) { - RSemaphore *rsem = (RSemaphore *) sem; - if (rsem) { - rsem->Close(); - delete rsem; - } - return zrtp_status_ok; -} - -zrtp_status_t zrtp_sem_wait(zrtp_sem_t* sem) { - RSemaphore *rsem = (RSemaphore *) sem; - rsem->Wait(); - return zrtp_status_ok; -} - -zrtp_status_t zrtp_sem_trtwait(zrtp_sem_t* sem) { - RSemaphore *rsem = (RSemaphore *) sem; - rsem->Wait(1000); - return zrtp_status_ok; -} - -zrtp_status_t zrtp_sem_post(zrtp_sem_t* sem) { - RSemaphore *rsem = (RSemaphore *) sem; - rsem->Signal(); - return zrtp_status_ok; -} - -//----------------------------------------------------------------------------- -int zrtp_sleep(unsigned int msec) { - TTimeIntervalMicroSeconds32 i(msec *1000); - User::After(i); - return 0; -} - -int zrtp_thread_create(zrtp_thread_routine_t start_routine, void *arg) { - RThread h; - TBuf<64> thName=_L("zrtp_thread"); - - h.Create(thName, start_routine, KDefaultStackSize*2, NULL, arg) ; - h.Resume(); - h.Close(); - - return NULL; -} -//----------------------------------------------------------------------------- -// For Scheduler -#if (defined(ZRTP_USE_BUILTIN_SCEHDULER) && (ZRTP_USE_BUILTIN_SCEHDULER ==1)) - -#include "DelayRuner.h" -#include "zrtp_error.h" -mlist_t tasks_head_s; -static uint8_t inited = 0 ; -static uint8_t is_running = 0; - -typedef struct { - zrtp_stream_t *ctx; /** ZRTP stream context associated with the task */ - zrtp_retry_task_t *ztask; /** ZRTP stream associated with the task */ - mlist_t _mlist; - CDelayRuner* ao; // Active object -} zrtp_sched_task_s_t; - -zrtp_status_t zrtp_def_scheduler_init(zrtp_global_t* zrtp) -{ - zrtp_status_t status = zrtp_status_ok; - ZRTP_LOG(3,("symbian","Init start")); - if (inited) { - return zrtp_status_ok; - } - - do { - init_mlist(&tasks_head_s); - is_running = 1; - inited = 1; - } while (0); - - ZRTP_LOG(3,("symbian","Init end")); - return status; -} - -void zrtp_def_scheduler_down() -{ - ZRTP_LOG(3,("symbian","Down start")); - mlist_t *node = 0, *tmp = 0; - - if (!inited) { - return; - } - - /* Stop main thread */ - is_running = 0; -// zrtp_sem_post(count); - - /* Then destroy tasks queue and realease all other resources */ - //zrtp_mutex_lock(protector); - - mlist_for_each_safe(node, tmp, &tasks_head_s) { - zrtp_sched_task_s_t* task = mlist_get_struct(zrtp_sched_task_s_t, _mlist, node); - if (task->ao!=NULL) - { - delete task->ao; - } - zrtp_sys_free(task); - } - init_mlist(&tasks_head_s); - -// zrtp_mutex_unlock(protector); - -// zrtp_mutex_destroy(protector); -// zrtp_sem_destroy(count); - - ZRTP_LOG(3,("symbian","Down end")); - inited = 0; -} - - -void zrtp_def_scheduler_call_later(zrtp_stream_t *ctx, zrtp_retry_task_t* ztask) -{ -// ZRTP_LOG(3,("symbian","CallLater start")); - //mlist_t *node=0, *tmp=0; - mlist_t* last = &tasks_head_s; - - //zrtp_mutex_lock(protector); - - if (!ztask->_is_enabled) { - //zrtp_mutex_unlock(protector); - return; - } - - do { - zrtp_sched_task_s_t* new_task = (zrtp_sched_task_s_t*)zrtp_sys_alloc(sizeof(zrtp_sched_task_s_t)); - if (!new_task) { - break; - } - - new_task->ctx = ctx; - new_task->ztask = ztask; - new_task->ao = CDelayRuner::NewL(); - - mlist_insert(last, &new_task->_mlist); - - new_task->ao->StartL(ctx,ztask); - //zrtp_sem_post(count); - } while (0); - - //ZRTP_LOG(3,("symbian","CallLater end")); - //zrtp_mutex_unlock(protector); -} - -void zrtp_def_scheduler_cancel_call_later(zrtp_stream_t* ctx, zrtp_retry_task_t* ztask) -{ - mlist_t *node=0, *tmp=0; - ZRTP_LOG(3,("symbian","CancelcallLater start")); -// zrtp_mutex_lock(protector); - - mlist_for_each_safe(node, tmp, &tasks_head_s) { - zrtp_sched_task_s_t* task = mlist_get_struct(zrtp_sched_task_s_t, _mlist, node); - if ((task->ctx == ctx) && ((task->ztask == ztask) || !ztask)) { - task->ao->Cancel(); - delete task->ao; // Cancel and delete task - mlist_del(&task->_mlist); - zrtp_sys_free(task); - //zrtp_sem_trtwait(count); - if (ztask) { - break; - } - } - } - ZRTP_LOG(3,("symbian","CancelCallLater done")); -// zrtp_mutex_unlock(protector); -} - -void zrtp_internal_delete_task_from_list(zrtp_stream_t* ctx, zrtp_retry_task_t* ztask) - { - mlist_t *node=0, *tmp=0; - ZRTP_LOG(3,("symbian","DelTask begin")); - mlist_for_each_safe(node, tmp, &tasks_head_s) - { - zrtp_sched_task_s_t* task = mlist_get_struct(zrtp_sched_task_s_t, _mlist, node); - if ((task->ctx == ctx) && ((task->ztask == ztask) || !ztask)) - { - delete task->ao; // Cancel and delete task - mlist_del(&task->_mlist); - zrtp_sys_free(task); - ZRTP_LOG(3,("symbian","DelTask Del")); - //zrtp_sem_trtwait(count); - if (ztask) - { - break; - } - } - } - ZRTP_LOG(3,("symbian","DelTask end")); - } - -void zrtp_def_scheduler_wait_call_later(zrtp_stream_t* ctx) -{ -} -#endif // ZRTP_USE_BUILTIN_SCEHDULER -//----------------------------------------------------------------------------- - -unsigned int zrtp_get_pid() - { - return getpid(); - } - -uint64_t zrtp_get_system_time_crazy() - { - TTime time; - - return time.MicroSecondsFrom(TTime(TDateTime (491,EAugust,7,3,37,17,347))).Int64(); - } - -uint32_t zrtp_sum_of_pid_and_number_of_poccesses() - { - TFindProcess fp; - RProcess procces; - TFullName proccesName; - uint_32t idsum=1; - uint_32t proccesCount=0; - fp.Find(KNullDesC); - while (fp.Next(proccesName)==KErrNone) - { - if (procces.Open(proccesName,EOwnerProcess)==KErrNone) - { - idsum+=procces.Id(); - proccesCount++; - procces.Close(); - } - } - idsum = (idsum << 3) xor proccesCount; - return idsum; - } - -uint32_t zrtp_get_availible_heap() - { - return User::Heap().MaxLength(); - } - -uint32_t zrtp_symbian_kernel_random() - { - return Math::Random(); - } diff --git a/libs/libzrtp/projects/win/libzrtp.2010.vcxproj.filters b/libs/libzrtp/projects/win/libzrtp.2010.vcxproj.filters deleted file mode 100644 index 7e1165d4b3..0000000000 --- a/libs/libzrtp/projects/win/libzrtp.2010.vcxproj.filters +++ /dev/null @@ -1,262 +0,0 @@ - - - - - {c0e76076-0032-445d-8c07-32b6c762622b} - - - {a03c0d83-0032-4848-9704-22cdce5ab144} - - - {dbe8a34e-0032-495e-8df7-e82218921e60} - - - {96d1a5c9-0032-4230-a764-a0ed11f434a7} - - - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - bnlib - - - bnlib - - - bnlib - - - bnlib - - - bnlib - - - bnlib - - - bnlib - - - bnlib - - - bgaes - - - bgaes - - - bgaes - - - bgaes - - - bgaes - - - bgaes - - - bgaes - - - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - bnlib - - - bnlib - - - bnlib - - - bnlib - - - bnlib - - - bnlib - - - bnlib - - - bgaes - - - bgaes - - - bgaes - - - bgaes - - - bgaes - - - bgaes - - - src - - - src - - - - - - - \ No newline at end of file diff --git a/libs/libzrtp/projects/win/libzrtp.2017.vcxproj b/libs/libzrtp/projects/win/libzrtp.2017.vcxproj deleted file mode 100644 index 3e5362e219..0000000000 --- a/libs/libzrtp/projects/win/libzrtp.2017.vcxproj +++ /dev/null @@ -1,258 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {C13CC324-0032-4492-9A30-310A6BD64FF5} - libzrtp.x32 - Win32Proj - libzrtp - - - - StaticLibrary - Unicode - $(DefaultPlatformToolset) - - - StaticLibrary - Unicode - $(DefaultPlatformToolset) - - - StaticLibrary - Unicode - $(DefaultPlatformToolset) - - - StaticLibrary - Unicode - $(DefaultPlatformToolset) - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - AllRules.ruleset - AllRules.ruleset - - - - - AllRules.ruleset - AllRules.ruleset - - - - - - - - Disabled - ../../include;../../third_party/bnlib;../../third_party/bgaes;../../test/include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_LIB;HAVE_CONFIG_H=1;ZRTP_ENABLE_EC=0;ZRTP_USE_BUILTIN_CACHE=1;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Default - - - Level3 - ProgramDatabase - CompileAsC - 4267;%(DisableSpecificWarnings) - - - - if not exist "$(ProjectDir)..\..\third_party\bnlib\bnconfig.h" copy "$(ProjectDir)..\..\third_party\bnlib\bnconfig.win" "$(ProjectDir)..\..\third_party\bnlib\bnconfig.h" - - - - - Disabled - ../../include;../../third_party/bnlib;../../third_party/bgaes;../../test/include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_LIB;HAVE_CONFIG_H=1;ZRTP_ENABLE_EC=0;ZRTP_USE_BUILTIN_CACHE=1;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebugDLL - Default - - - Level3 - ProgramDatabase - CompileAsC - 4267;%(DisableSpecificWarnings) - - - - if not exist "$(ProjectDir)..\..\third_party\bnlib\bnconfig.h" copy "$(ProjectDir)..\..\third_party\bnlib\bnconfig.win" "$(ProjectDir)..\..\third_party\bnlib\bnconfig.h" - - - - - ../../include;../../third_party/bnlib;../../third_party/bgaes;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_LIB;HAVE_CONFIG_H=1;ZRTP_ENABLE_EC=0;ZRTP_USE_BUILTIN_CACHE=1;%(PreprocessorDefinitions) - - - MultiThreadedDLL - Default - false - - - Level3 - ProgramDatabase - CompileAsC - 4267;%(DisableSpecificWarnings) - - - - if not exist "$(ProjectDir)..\..\third_party\bnlib\bnconfig.h" copy "$(ProjectDir)..\..\third_party\bnlib\bnconfig.win" "$(ProjectDir)..\..\third_party\bnlib\bnconfig.h" - - - - - ../../include;../../third_party/bnlib;../../third_party/bgaes;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_LIB;HAVE_CONFIG_H=1;ZRTP_ENABLE_EC=0;ZRTP_USE_BUILTIN_CACHE=1;%(PreprocessorDefinitions) - - - MultiThreadedDLL - Default - false - - - Level3 - ProgramDatabase - CompileAsC - 4267;%(DisableSpecificWarnings) - - - - if not exist "$(ProjectDir)..\..\third_party\bnlib\bnconfig.h" copy "$(ProjectDir)..\..\third_party\bnlib\bnconfig.win" "$(ProjectDir)..\..\third_party\bnlib\bnconfig.h" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/libs/libzrtp/projects/win/libzrtp.sln b/libs/libzrtp/projects/win/libzrtp.sln deleted file mode 100644 index b94a523c24..0000000000 --- a/libs/libzrtp/projects/win/libzrtp.sln +++ /dev/null @@ -1,28 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libzrtp_test", "libzrtp_test.vcproj", "{BA35741B-8C8E-4A39-9CA1-0CE032D6E4ED}" - ProjectSection(ProjectDependencies) = postProject - {C13CC324-E0CA-4492-9A30-310A6BD64FF5} = {C13CC324-E0CA-4492-9A30-310A6BD64FF5} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libzrtp", "libzrtp.vcproj", "{C13CC324-E0CA-4492-9A30-310A6BD64FF5}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {BA35741B-8C8E-4A39-9CA1-0CE032D6E4ED}.Debug|Win32.ActiveCfg = Debug|Win32 - {BA35741B-8C8E-4A39-9CA1-0CE032D6E4ED}.Debug|Win32.Build.0 = Debug|Win32 - {BA35741B-8C8E-4A39-9CA1-0CE032D6E4ED}.Release|Win32.ActiveCfg = Release|Win32 - {BA35741B-8C8E-4A39-9CA1-0CE032D6E4ED}.Release|Win32.Build.0 = Release|Win32 - {C13CC324-E0CA-4492-9A30-310A6BD64FF5}.Debug|Win32.ActiveCfg = Debug|Win32 - {C13CC324-E0CA-4492-9A30-310A6BD64FF5}.Debug|Win32.Build.0 = Debug|Win32 - {C13CC324-E0CA-4492-9A30-310A6BD64FF5}.Release|Win32.ActiveCfg = Release|Win32 - {C13CC324-E0CA-4492-9A30-310A6BD64FF5}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/libs/libzrtp/projects/win/libzrtp.vcproj b/libs/libzrtp/projects/win/libzrtp.vcproj deleted file mode 100644 index 485bd2f02d..0000000000 --- a/libs/libzrtp/projects/win/libzrtp.vcproj +++ /dev/null @@ -1,499 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/libzrtp/projects/win/libzrtp.x32.vcxproj b/libs/libzrtp/projects/win/libzrtp.x32.vcxproj deleted file mode 100644 index d67c404c97..0000000000 --- a/libs/libzrtp/projects/win/libzrtp.x32.vcxproj +++ /dev/null @@ -1,180 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {C13CC324-0032-4492-9A30-310A6BD64FF5} - libzrtp.x32 - Win32Proj - - - - StaticLibrary - MultiByte - - - StaticLibrary - MultiByte - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Configuration).x32\ - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Configuration).x32\ - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - ../../include;../../third_party/bnlib;../../third_party/bgaes;../../test/include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_LIB;HAVE_CONFIG_H=1;ZRTP_ENABLE_EC=1;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - Default - - - Level3 - ProgramDatabase - CompileAsC - - - $(OutDir)libzrtp.x32.lib - - - - - ../../include;../../third_party/bnlib;../../third_party/bgaes;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_LIB;HAVE_CONFIG_H=1;ZRTP_ENABLE_EC=1;%(PreprocessorDefinitions) - - - MultiThreaded - Default - false - - - Level3 - ProgramDatabase - CompileAsC - - - $(OutDir)libzrtp.x32.lib - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/libs/libzrtp/projects/win/libzrtp.x32.vcxproj.filters b/libs/libzrtp/projects/win/libzrtp.x32.vcxproj.filters deleted file mode 100644 index 451b5531f3..0000000000 --- a/libs/libzrtp/projects/win/libzrtp.x32.vcxproj.filters +++ /dev/null @@ -1,262 +0,0 @@ - - - - - {c0e76076-0032-445d-8c07-32b6c762622b} - - - {a03c0d83-0032-4848-9704-22cdce5ab144} - - - {dbe8a34e-0032-495e-8df7-e82218921e60} - - - {96d1a5c9-0032-4230-a764-a0ed11f434a7} - - - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - bnlib - - - bnlib - - - bnlib - - - bnlib - - - bnlib - - - bnlib - - - bnlib - - - bnlib - - - bgaes - - - bgaes - - - bgaes - - - bgaes - - - bgaes - - - bgaes - - - bgaes - - - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - bnlib - - - bnlib - - - bnlib - - - bnlib - - - bnlib - - - bnlib - - - bnlib - - - bgaes - - - bgaes - - - bgaes - - - bgaes - - - bgaes - - - bgaes - - - - - - - \ No newline at end of file diff --git a/libs/libzrtp/projects/win/libzrtp.x64.vcxproj b/libs/libzrtp/projects/win/libzrtp.x64.vcxproj deleted file mode 100644 index 056158ec4f..0000000000 --- a/libs/libzrtp/projects/win/libzrtp.x64.vcxproj +++ /dev/null @@ -1,179 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - {C13CC324-0064-4492-9A30-310A6BD64FF5} - libzrtp.x64 - Win32Proj - - - - StaticLibrary - MultiByte - - - StaticLibrary - MultiByte - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Configuration).x64\ - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Configuration).x64\ - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - ../../include;../../third_party/bnlib;../../third_party/bgaes;../../test/include;%(AdditionalIncludeDirectories) - _WIN64;_DEBUG;_LIB;HAVE_CONFIG_H=1;ZRTP_ENABLE_EC=1;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - Default - - - Level3 - ProgramDatabase - CompileAsC - - - $(OutDir)libzrtp.x64.lib - - - - - ../../include;../../third_party/bnlib;../../third_party/bgaes;%(AdditionalIncludeDirectories) - _WIN64;NDEBUG;_LIB;HAVE_CONFIG_H=1;ZRTP_ENABLE_EC=1;%(PreprocessorDefinitions) - - - MultiThreaded - Default - false - - - Level3 - ProgramDatabase - CompileAsC - - - $(OutDir)libzrtp.x64.lib - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/libs/libzrtp/projects/win/libzrtp.x64.vcxproj.filters b/libs/libzrtp/projects/win/libzrtp.x64.vcxproj.filters deleted file mode 100644 index 533b86f682..0000000000 --- a/libs/libzrtp/projects/win/libzrtp.x64.vcxproj.filters +++ /dev/null @@ -1,262 +0,0 @@ - - - - - {c0e76076-0064-445d-8c07-32b6c762622b} - - - {a03c0d83-0064-4848-9704-22cdce5ab144} - - - {dbe8a34e-0064-495e-8df7-e82218921e60} - - - {96d1a5c9-0064-4230-a764-a0ed11f434a7} - - - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - bnlib - - - bnlib - - - bnlib - - - bnlib - - - bnlib - - - bnlib - - - bnlib - - - bnlib - - - bgaes - - - bgaes - - - bgaes - - - bgaes - - - bgaes - - - bgaes - - - bgaes - - - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - bnlib - - - bnlib - - - bnlib - - - bnlib - - - bnlib - - - bnlib - - - bnlib - - - bgaes - - - bgaes - - - bgaes - - - bgaes - - - bgaes - - - bgaes - - - - - - - \ No newline at end of file diff --git a/libs/libzrtp/projects/win/libzrtp_not_ec.vcproj b/libs/libzrtp/projects/win/libzrtp_not_ec.vcproj deleted file mode 100644 index 63f6c1ca56..0000000000 --- a/libs/libzrtp/projects/win/libzrtp_not_ec.vcproj +++ /dev/null @@ -1,483 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/libzrtp/projects/win/libzrtp_test.vcproj b/libs/libzrtp/projects/win/libzrtp_test.vcproj deleted file mode 100644 index 99ce3f1675..0000000000 --- a/libs/libzrtp/projects/win/libzrtp_test.vcproj +++ /dev/null @@ -1,211 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/libzrtp/projects/win_ce/libzrtp_test_wince.vcproj b/libs/libzrtp/projects/win_ce/libzrtp_test_wince.vcproj deleted file mode 100644 index 4dfc6574c0..0000000000 --- a/libs/libzrtp/projects/win_ce/libzrtp_test_wince.vcproj +++ /dev/null @@ -1,500 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/libzrtp/projects/win_ce/libzrtp_wince.sln b/libs/libzrtp/projects/win_ce/libzrtp_wince.sln deleted file mode 100644 index a732637635..0000000000 --- a/libs/libzrtp/projects/win_ce/libzrtp_wince.sln +++ /dev/null @@ -1,40 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libzrtp", "libzrtp_wince.vcproj", "{53F84E3B-9903-4046-897B-33FEFFED527A}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libzrtp_test", "libzrtp_test_wince.vcproj", "{5C082222-FD44-4295-8055-915936F086BE}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Pocket PC 2003 (ARMV4) = Debug|Pocket PC 2003 (ARMV4) - Debug|Smartphone 2003 (ARMV4) = Debug|Smartphone 2003 (ARMV4) - Release|Pocket PC 2003 (ARMV4) = Release|Pocket PC 2003 (ARMV4) - Release|Smartphone 2003 (ARMV4) = Release|Smartphone 2003 (ARMV4) - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {53F84E3B-9903-4046-897B-33FEFFED527A}.Debug|Pocket PC 2003 (ARMV4).ActiveCfg = Debug|Pocket PC 2003 (ARMV4) - {53F84E3B-9903-4046-897B-33FEFFED527A}.Debug|Smartphone 2003 (ARMV4).ActiveCfg = Debug|Smartphone 2003 (ARMV4) - {53F84E3B-9903-4046-897B-33FEFFED527A}.Release|Pocket PC 2003 (ARMV4).ActiveCfg = Release|Pocket PC 2003 (ARMV4) - {53F84E3B-9903-4046-897B-33FEFFED527A}.Release|Pocket PC 2003 (ARMV4).Build.0 = Release|Pocket PC 2003 (ARMV4) - {53F84E3B-9903-4046-897B-33FEFFED527A}.Release|Pocket PC 2003 (ARMV4).Deploy.0 = Release|Pocket PC 2003 (ARMV4) - {53F84E3B-9903-4046-897B-33FEFFED527A}.Release|Smartphone 2003 (ARMV4).ActiveCfg = Release|Smartphone 2003 (ARMV4) - {53F84E3B-9903-4046-897B-33FEFFED527A}.Release|Smartphone 2003 (ARMV4).Build.0 = Release|Smartphone 2003 (ARMV4) - {53F84E3B-9903-4046-897B-33FEFFED527A}.Release|Smartphone 2003 (ARMV4).Deploy.0 = Release|Smartphone 2003 (ARMV4) - {5C082222-FD44-4295-8055-915936F086BE}.Debug|Pocket PC 2003 (ARMV4).ActiveCfg = Debug|Pocket PC 2003 (ARMV4) - {5C082222-FD44-4295-8055-915936F086BE}.Debug|Pocket PC 2003 (ARMV4).Build.0 = Debug|Pocket PC 2003 (ARMV4) - {5C082222-FD44-4295-8055-915936F086BE}.Debug|Pocket PC 2003 (ARMV4).Deploy.0 = Debug|Pocket PC 2003 (ARMV4) - {5C082222-FD44-4295-8055-915936F086BE}.Debug|Smartphone 2003 (ARMV4).ActiveCfg = Debug|Smartphone 2003 (ARMV4) - {5C082222-FD44-4295-8055-915936F086BE}.Debug|Smartphone 2003 (ARMV4).Build.0 = Debug|Smartphone 2003 (ARMV4) - {5C082222-FD44-4295-8055-915936F086BE}.Debug|Smartphone 2003 (ARMV4).Deploy.0 = Debug|Smartphone 2003 (ARMV4) - {5C082222-FD44-4295-8055-915936F086BE}.Release|Pocket PC 2003 (ARMV4).ActiveCfg = Release|Pocket PC 2003 (ARMV4) - {5C082222-FD44-4295-8055-915936F086BE}.Release|Pocket PC 2003 (ARMV4).Build.0 = Release|Pocket PC 2003 (ARMV4) - {5C082222-FD44-4295-8055-915936F086BE}.Release|Pocket PC 2003 (ARMV4).Deploy.0 = Release|Pocket PC 2003 (ARMV4) - {5C082222-FD44-4295-8055-915936F086BE}.Release|Smartphone 2003 (ARMV4).ActiveCfg = Release|Smartphone 2003 (ARMV4) - {5C082222-FD44-4295-8055-915936F086BE}.Release|Smartphone 2003 (ARMV4).Build.0 = Release|Smartphone 2003 (ARMV4) - {5C082222-FD44-4295-8055-915936F086BE}.Release|Smartphone 2003 (ARMV4).Deploy.0 = Release|Smartphone 2003 (ARMV4) - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/libs/libzrtp/projects/win_ce/libzrtp_wince.vcproj b/libs/libzrtp/projects/win_ce/libzrtp_wince.vcproj deleted file mode 100644 index cbe4fb4389..0000000000 --- a/libs/libzrtp/projects/win_ce/libzrtp_wince.vcproj +++ /dev/null @@ -1,761 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/libzrtp/projects/win_ce/libzrtp_wince_not_ec.vcproj b/libs/libzrtp/projects/win_ce/libzrtp_wince_not_ec.vcproj deleted file mode 100644 index d16b5559d6..0000000000 --- a/libs/libzrtp/projects/win_ce/libzrtp_wince_not_ec.vcproj +++ /dev/null @@ -1,741 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/libzrtp/projects/win_kernel/MAKEFILE.WIN32 b/libs/libzrtp/projects/win_kernel/MAKEFILE.WIN32 deleted file mode 100644 index 2b15ded64a..0000000000 --- a/libs/libzrtp/projects/win_kernel/MAKEFILE.WIN32 +++ /dev/null @@ -1,132 +0,0 @@ -# -# Copyright (c) 2006 Philip R. Zimmermann. All rights reserved. -# Contact: http://philzimmermann.com -# For licensing and other legal details, see the file zrtp_legal.c. -# -# Andrew Rozinko - -# -# THIS MAKEFILE WORKS WITH MICROSOFT NMAKE ONLY -# - -# change this to point to your DDK - -DDK = ..\..\..\..\winddk\3790 -OS = wxp -BASENAME = libzrtp - -#RELEASE = 1 - -CC = cl -ASM = ml -LIB = lib - -all: $(BASENAME).lib - -# bnlib (the BigNumber engine) - -bnlib = \ - ../../third_party/bnlib/bn.obj \ - ../../third_party/bnlib/bn32.obj \ - ../../third_party/bnlib/bninit32.obj \ - ../../third_party/bnlib/lbn32.obj \ - ../../third_party/bnlib/lbnmem.obj \ - ../../third_party/bnlib/legal.obj - -protocol = \ - ../../src/zrtp.obj \ - ../../src/zrtp_crc.obj \ - ../../src/zrtp_crypto_aes.obj \ - ../../src/zrtp_crypto_atl.obj \ - ../../src/zrtp_crypto_hash.obj \ - ../../src/zrtp_crypto_pk.obj \ - ../../src/zrtp_crypto_sas.obj \ - ../../src/zrtp_datatypes.obj \ - ../../src/zrtp_engine.obj \ - ../../src/enterprise/zrtp_engine_driven.obj \ - ../../src/enterprise/zrtp_crypto_ec.obj \ - ../../src/enterprise/zrtp_crypto_ecdh.obj \ - ../../src/zrtp_iface_sys.obj \ - ../../src/zrtp_initiator.obj \ - ../../src/zrtp_legal.obj \ - ../../src/zrtp_list.obj \ - ../../src/zrtp_log.obj \ - ../../src/zrtp_pbx.obj \ - ../../src/zrtp_protocol.obj \ - ../../src/zrtp_responder.obj \ - ../../src/zrtp_rng.obj \ - ../../src/zrtp_srtp_builtin.obj \ - ../../src/zrtp_string.obj \ - ../../src/zrtp_utils.obj \ - ../../src/zrtp_utils_proto.obj - -bgaes = \ - ../../third_party/bgaes/aes_modes.obj \ - ../../third_party/bgaes/aescrypt.obj \ - ../../third_party/bgaes/aeskey.obj \ - ../../third_party/bgaes/aestab.obj \ - ../../third_party/bgaes/sha1.obj \ - ../../third_party/bgaes/sha2.obj - -OBJECTS = $(bnlib) $(protocol) $(bgaes) - -!IFNDEF RELEASE - -# Debug - -OUT_DIR = debug_ec.km - -DEFINES_D = -D_X86_=1 -Di386=1 -DSTD_CALL -DCONDITION_HANDLING=1 \ --DNT_UP=1 -DNT_INST=0 -DWIN32=100 -D_NT1X_=100 \ --DWINNT=1 -D_WIN32_WINNT=0x0500 -DWIN32_LEAN_AND_MEAN=1 -DDBG=1 -D_DEBUG -DDEBUG -DDEVL=1 \ --DFPO=0 -D_DLL=1 -D_IDWBUILD -DRDRDBG -DSRVDBG -DDBG_MESSAGES=1 \ --D_UNICODE -DLITTLE_ENDIAN -DZRTP_USE_ENTERPRISE=1 - -CFLAGS_D = $(DEFINES_D) -Zel -Zp8 -Gy -cbstring -Gz -QIfdiv- -QIf -Gi- -Gm- -GX- \ --GR- -GF -FI$(DDK)\inc\$(OS)\warning.h -Z7 -Od -Oi -Oy- -W3 - -!ELSE - -# Release - -OUT_DIR = release_ec.km - -DEFINES_D = -D_X86_=1 -Di386=1 -DSTD_CALL -DCONDITION_HANDLING=1 \ --DNT_UP=1 -DNO_DISK_ACCESS -DNT_INST=0 -DWIN32=100 -D_NT1X_=100 \ --DWINNT=1 -D_WIN32_WINNT=0x0500 -DWIN32_LEAN_AND_MEAN=1 -DDEVL=1 \ --DFPO=1 -DNDEBUG -D_DLL=1 -D_IDWBUILD -D_UNICODE \ --DLITTLE_ENDIAN -DZRTP_USE_ENTERPRISE=1 - -CFLAGS_D = $(DEFINES_D) -Zel -Zp8 -Gy -cbstring -Gz -QIfdiv- -QIf -Gi- -Gm- -GX- \ --GR- -GF -Oxs -Oy -FI$(DDK)\inc\$(OS)\warning.h -W3 -FAcs -Z7 - -!ENDIF - -ASM = ml -AFLAGS = /c /Cx /coff /Zi -AINCLUDE = -I. -I$(DDK)\inc - -CFLAGS = $(CFLAGS_D) -nologo -DHAVE_CONFIG_H=1 -DNT_DRIVER -D__BUILDMACHINE__=WinDDK \ - -I$(DDK)\inc\$(OS) -I$(DDK)\inc\ddk\$(OS) -I$(DDK)\inc\ddk\wdm\$(OS) \ - -I. -Ibnlib -Iinclude \ - -I$(DDK)\inc\crt -I..\..\third_party\bnlib\config -I..\..\third_party\bnlib \ - -I..\..\third_party\bgaes -I..\..\test\include -I..\..\include -I..\..\include\enterprise - -.c.obj : - @$(CC) -c $(CFLAGS) $< /Fo$(OUT_DIR)/$( - -# -# THIS MAKEFILE WORKS WITH MICROSOFT NMAKE ONLY -# - -# change this to point to your DDK - -DDK = ..\..\..\..\winddk2003 -OS = wnet -BASENAME = libzrtp -BINPATH = $(DDK)\bin\win64\x86\amd64 - -#RELEASE = 1 - -CC = $(BINPATH)\cl -ASM = $(BINPATH)\ml -LIB = $(BINPATH)\lib - -all: $(BASENAME).lib - -# bnlib (the BigNumber engine) - -bnlib = \ - ../../third_party/bnlib/bn.obj \ - ../../third_party/bnlib/bn32.obj \ - ../../third_party/bnlib/bninit32.obj \ - ../../third_party/bnlib/lbn32.obj \ - ../../third_party/bnlib/lbnmem.obj \ - ../../third_party/bnlib/legal.obj - -protocol = \ - ../../src/zrtp.obj \ - ../../src/zrtp_crc.obj \ - ../../src/zrtp_crypto_aes.obj \ - ../../src/zrtp_crypto_atl.obj \ - ../../src/zrtp_crypto_hash.obj \ - ../../src/zrtp_crypto_pk.obj \ - ../../src/zrtp_crypto_sas.obj \ - ../../src/zrtp_datatypes.obj \ - ../../src/zrtp_engine.obj \ - ../../src/enterprise/zrtp_engine_driven.obj \ - ../../src/enterprise/zrtp_crypto_ec.obj \ - ../../src/enterprise/zrtp_crypto_ecdh.obj \ - ../../src/zrtp_iface_sys.obj \ - ../../src/zrtp_initiator.obj \ - ../../src/zrtp_legal.obj \ - ../../src/zrtp_list.obj \ - ../../src/zrtp_log.obj \ - ../../src/zrtp_pbx.obj \ - ../../src/zrtp_protocol.obj \ - ../../src/zrtp_responder.obj \ - ../../src/zrtp_rng.obj \ - ../../src/zrtp_srtp_builtin.obj \ - ../../src/zrtp_string.obj \ - ../../src/zrtp_utils.obj \ - ../../src/zrtp_utils_proto.obj - -bgaes = \ - ../../third_party/bgaes/aes_modes.obj \ - ../../third_party/bgaes/aescrypt.obj \ - ../../third_party/bgaes/aeskey.obj \ - ../../third_party/bgaes/aestab.obj \ - ../../third_party/bgaes/sha1.obj \ - ../../third_party/bgaes/sha2.obj - -OBJECTS = $(bnlib) $(protocol) $(bgaes) - -!IFNDEF RELEASE - -# Debug - -OUT_DIR = debug64_ec.km - -DEFINES_D = -DWIN64=1 -D_WIN64=1 -D_AMD64_=1 -D_M_AMD64 -D_WINDOWS \ --DSTD_CALL -DCONDITION_HANDLING=1 \ --DNT_UP=1 -DNT_INST=0 -D_NT1X_=100 \ --DWINNT=1 -D_WIN32_WINNT=0x0500 -DWIN32_LEAN_AND_MEAN=1 -DDBG=1 -D_DEBUG -DDEBUG -DDEVL=1 \ --DFPO=0 -D_DLL=1 -D_IDWBUILD -DRDRDBG -DSRVDBG -DDBG_MESSAGES=1 \ --D_UNICODE -DLITTLE_ENDIAN -DZRTP_USE_ENTERPRISE=1 - -CFLAGS_D = $(DEFINES_D) -Zp8 -Gy -cbstring -Gz -Gm- -EHs-c- \ --GR- -GF -FI$(DDK)\inc\$(OS)\warning.h -Z7 -Od -Oi -Oy- -W3 - -!ELSE - -# Release - -OUT_DIR = release64_ec.km - -DEFINES_D = -DWIN64=1 -D_WIN64=1 -D_AMD64_=1 -D_M_AMD64 -D_WINDOWS \ --DSTD_CALL -DCONDITION_HANDLING=1 \ --DNT_UP=1 -DNO_DISK_ACCESS -DNT_INST=0 -DWIN32=100 -D_NT1X_=100 \ --DWINNT=1 -D_WIN32_WINNT=0x0500 -DWIN32_LEAN_AND_MEAN=1 -DDEVL=1 \ --DFPO=1 -DNDEBUG -D_DLL=1 -D_IDWBUILD -D_UNICODE \ --DLITTLE_ENDIAN -DZRTP_USE_ENTERPRISE=1 - -CFLAGS_D = $(DEFINES_D) -Zel -Zp8 -Gy -cbstring -Gz -QIfdiv- -QIf -Gi- -Gm- -GX- \ --GR- -GF -Oxs -Oy -FI$(DDK)\inc\$(OS)\warning.h -W3 -FAcs -Z7 - -!ENDIF - -ASM = ml -AFLAGS = /c /Cx /coff /Zi -AINCLUDE = -I. -I$(DDK)\inc - -CFLAGS = $(CFLAGS_D) -nologo -DHAVE_CONFIG_H=1 -DNT_DRIVER -D__BUILDMACHINE__=WinDDK \ - -I$(DDK)\inc\$(OS) -I$(DDK)\inc\ddk\$(OS) -I$(DDK)\inc\ddk\wdm\$(OS) \ - -I$(DDK)\inc\crt -I..\..\third_party\bnlib\config -I..\..\third_party\bnlib \ - -I..\..\third_party\bgaes -I..\..\test\include -I..\..\include -I..\..\include\enterprise - -.c.obj : - @$(CC) -c $(CFLAGS) $< /Fo$(OUT_DIR)/$( - -# -# THIS MAKEFILE WORKS WITH MICROSOFT NMAKE ONLY -# - -# change this to point to your DDK - -DDK = ..\..\..\..\winddk\3790 -OS = wxp -BASENAME = libzrtp - -#RELEASE = 1 - -CC = cl -ASM = ml -LIB = lib - -all: $(BASENAME).lib - -# bnlib (the BigNumber engine) - -bnlib = \ - ../../third_party/bnlib/bn.obj \ - ../../third_party/bnlib/bn32.obj \ - ../../third_party/bnlib/bninit32.obj \ - ../../third_party/bnlib/lbn32.obj \ - ../../third_party/bnlib/lbnmem.obj \ - ../../third_party/bnlib/legal.obj - -protocol = \ - ../../src/zrtp.obj \ - ../../src/zrtp_crc.obj \ - ../../src/zrtp_crypto_aes.obj \ - ../../src/zrtp_crypto_atl.obj \ - ../../src/zrtp_crypto_hash.obj \ - ../../src/zrtp_crypto_pk.obj \ - ../../src/zrtp_crypto_sas.obj \ - ../../src/zrtp_datatypes.obj \ - ../../src/zrtp_engine.obj \ - ../../src/zrtp_iface_sys.obj \ - ../../src/zrtp_initiator.obj \ - ../../src/zrtp_legal.obj \ - ../../src/zrtp_list.obj \ - ../../src/zrtp_log.obj \ - ../../src/zrtp_pbx.obj \ - ../../src/zrtp_protocol.obj \ - ../../src/zrtp_responder.obj \ - ../../src/zrtp_rng.obj \ - ../../src/zrtp_srtp_builtin.obj \ - ../../src/zrtp_string.obj \ - ../../src/zrtp_utils.obj \ - ../../src/zrtp_utils_proto.obj - -bgaes = \ - ../../third_party/bgaes/aes_modes.obj \ - ../../third_party/bgaes/aescrypt.obj \ - ../../third_party/bgaes/aeskey.obj \ - ../../third_party/bgaes/aestab.obj \ - ../../third_party/bgaes/sha1.obj \ - ../../third_party/bgaes/sha2.obj - -OBJECTS = $(bnlib) $(protocol) $(bgaes) - -!IFNDEF RELEASE - -# Debug - -OUT_DIR = debug.km - -DEFINES_D = -D_X86_=1 -Di386=1 -DSTD_CALL -DCONDITION_HANDLING=1 \ --DNT_UP=1 -DNT_INST=0 -DWIN32=100 -D_NT1X_=100 \ --DWINNT=1 -D_WIN32_WINNT=0x0500 -DWIN32_LEAN_AND_MEAN=1 -DDBG=1 -D_DEBUG -DDEBUG -DDEVL=1 \ --DFPO=0 -D_DLL=1 -D_IDWBUILD -DRDRDBG -DSRVDBG -DDBG_MESSAGES=1 \ --D_UNICODE -DLITTLE_ENDIAN -DZRTP_USE_ENTERPRISE=0 - -CFLAGS_D = $(DEFINES_D) -Zel -Zp8 -Gy -cbstring -Gz -QIfdiv- -QIf -Gi- -Gm- -GX- \ --GR- -GF -FI$(DDK)\inc\$(OS)\warning.h -Z7 -Od -Oi -Oy- -W3 - -!ELSE - -# Release - -OUT_DIR = release.km - -DEFINES_D = -D_X86_=1 -Di386=1 -DSTD_CALL -DCONDITION_HANDLING=1 \ --DNT_UP=1 -DNO_DISK_ACCESS -DNT_INST=0 -DWIN32=100 -D_NT1X_=100 \ --DWINNT=1 -D_WIN32_WINNT=0x0500 -DWIN32_LEAN_AND_MEAN=1 -DDEVL=1 \ --DFPO=1 -DNDEBUG -D_DLL=1 -D_IDWBUILD -D_UNICODE \ --DLITTLE_ENDIAN -DZRTP_USE_ENTERPRISE=0 - -CFLAGS_D = $(DEFINES_D) -Zel -Zp8 -Gy -cbstring -Gz -QIfdiv- -QIf -Gi- -Gm- -GX- \ --GR- -GF -Oxs -Oy -FI$(DDK)\inc\$(OS)\warning.h -W3 -FAcs -Z7 - -!ENDIF - -ASM = ml -AFLAGS = /c /Cx /coff /Zi -AINCLUDE = -I. -I$(DDK)\inc - -CFLAGS = $(CFLAGS_D) -nologo -DHAVE_CONFIG_H=1 -DNT_DRIVER -D__BUILDMACHINE__=WinDDK \ - -I$(DDK)\inc\$(OS) -I$(DDK)\inc\ddk\$(OS) -I$(DDK)\inc\ddk\wdm\$(OS) \ - -I. -Ibnlib -Iinclude \ - -I$(DDK)\inc\crt -I..\..\third_party\bnlib\config -I..\..\third_party\bnlib \ - -I..\..\third_party\bgaes -I..\..\test\include -I..\..\include -I..\..\include\enterprise - -.c.obj : - @$(CC) -c $(CFLAGS) $< /Fo$(OUT_DIR)/$( - -# -# THIS MAKEFILE WORKS WITH MICROSOFT NMAKE ONLY -# - -# change this to point to your DDK - -DDK = ..\..\..\..\winddk2003 -OS = wnet -BASENAME = libzrtp -BINPATH = $(DDK)\bin\win64\x86\amd64 - -#RELEASE = 1 - -CC = $(BINPATH)\cl -ASM = $(BINPATH)\ml -LIB = $(BINPATH)\lib - -all: $(BASENAME).lib - -# bnlib (the BigNumber engine) - -bnlib = \ - ../../third_party/bnlib/bn.obj \ - ../../third_party/bnlib/bn32.obj \ - ../../third_party/bnlib/bninit32.obj \ - ../../third_party/bnlib/lbn32.obj \ - ../../third_party/bnlib/lbnmem.obj \ - ../../third_party/bnlib/legal.obj - -protocol = \ - ../../src/zrtp.obj \ - ../../src/zrtp_crc.obj \ - ../../src/zrtp_crypto_aes.obj \ - ../../src/zrtp_crypto_atl.obj \ - ../../src/zrtp_crypto_hash.obj \ - ../../src/zrtp_crypto_pk.obj \ - ../../src/zrtp_crypto_sas.obj \ - ../../src/zrtp_datatypes.obj \ - ../../src/zrtp_engine.obj \ - ../../src/zrtp_iface_sys.obj \ - ../../src/zrtp_initiator.obj \ - ../../src/zrtp_legal.obj \ - ../../src/zrtp_list.obj \ - ../../src/zrtp_log.obj \ - ../../src/zrtp_pbx.obj \ - ../../src/zrtp_protocol.obj \ - ../../src/zrtp_responder.obj \ - ../../src/zrtp_rng.obj \ - ../../src/zrtp_srtp_builtin.obj \ - ../../src/zrtp_string.obj \ - ../../src/zrtp_utils.obj \ - ../../src/zrtp_utils_proto.obj - -bgaes = \ - ../../third_party/bgaes/aes_modes.obj \ - ../../third_party/bgaes/aescrypt.obj \ - ../../third_party/bgaes/aeskey.obj \ - ../../third_party/bgaes/aestab.obj \ - ../../third_party/bgaes/sha1.obj \ - ../../third_party/bgaes/sha2.obj - -OBJECTS = $(bnlib) $(protocol) $(bgaes) - -!IFNDEF RELEASE - -# Debug - -OUT_DIR = debug64.km - -DEFINES_D = -DWIN64=1 -D_WIN64=1 -D_AMD64_=1 -D_M_AMD64 -D_WINDOWS \ --DSTD_CALL -DCONDITION_HANDLING=1 \ --DNT_UP=1 -DNT_INST=0 -D_NT1X_=100 \ --DWINNT=1 -D_WIN32_WINNT=0x0500 -DWIN32_LEAN_AND_MEAN=1 -DDBG=1 -D_DEBUG -DDEBUG -DDEVL=1 \ --DFPO=0 -D_DLL=1 -D_IDWBUILD -DRDRDBG -DSRVDBG -DDBG_MESSAGES=1 \ --D_UNICODE -DLITTLE_ENDIAN -DZRTP_USE_ENTERPRISE=0 - -CFLAGS_D = $(DEFINES_D) -Zp8 -Gy -cbstring -Gz -Gm- -EHs-c- \ --GR- -GF -FI$(DDK)\inc\$(OS)\warning.h -Z7 -Od -Oi -Oy- -W3 - -!ELSE - -# Release - -OUT_DIR = release64.km - -DEFINES_D = -DWIN64=1 -D_WIN64=1 -D_AMD64_=1 -D_M_AMD64 -D_WINDOWS \ --DSTD_CALL -DCONDITION_HANDLING=1 \ --DNT_UP=1 -DNO_DISK_ACCESS -DNT_INST=0 -DWIN32=100 -D_NT1X_=100 \ --DWINNT=1 -D_WIN32_WINNT=0x0500 -DWIN32_LEAN_AND_MEAN=1 -DDEVL=1 \ --DFPO=1 -DNDEBUG -D_DLL=1 -D_IDWBUILD -D_UNICODE \ --DLITTLE_ENDIAN -DZRTP_USE_ENTERPRISE=0 - -CFLAGS_D = $(DEFINES_D) -Zel -Zp8 -Gy -cbstring -Gz -QIfdiv- -QIf -Gi- -Gm- -GX- \ --GR- -GF -Oxs -Oy -FI$(DDK)\inc\$(OS)\warning.h -W3 -FAcs -Z7 - -!ENDIF - -ASM = ml -AFLAGS = /c /Cx /coff /Zi -AINCLUDE = -I. -I$(DDK)\inc - -CFLAGS = $(CFLAGS_D) -nologo -DHAVE_CONFIG_H=1 -DNT_DRIVER -D__BUILDMACHINE__=WinDDK \ - -I$(DDK)\inc\$(OS) -I$(DDK)\inc\ddk\$(OS) -I$(DDK)\inc\ddk\wdm\$(OS) \ - -I$(DDK)\inc\crt -I..\..\third_party\bnlib\config -I..\..\third_party\bnlib \ - -I..\..\third_party\bgaes -I..\..\test\include -I..\..\include -I..\..\include\enterprise - -.c.obj : - @$(CC) -c $(CFLAGS) $< /Fo$(OUT_DIR)/$( - - - - diff --git a/libs/libzrtp/projects/xcode/libzrtp_test.xcodeproj/project.pbxproj b/libs/libzrtp/projects/xcode/libzrtp_test.xcodeproj/project.pbxproj deleted file mode 100644 index c70f0fc50e..0000000000 --- a/libs/libzrtp/projects/xcode/libzrtp_test.xcodeproj/project.pbxproj +++ /dev/null @@ -1,295 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - 8D6EECFF0F01458D00529121 /* zrtp_test_core.c in Sources */ = {isa = PBXBuildFile; fileRef = 8D6EECF70F01458D00529121 /* zrtp_test_core.c */; }; - 8D6EED000F01458D00529121 /* zrtp_test_crypto.c in Sources */ = {isa = PBXBuildFile; fileRef = 8D6EECF80F01458D00529121 /* zrtp_test_crypto.c */; }; - 8D6EED010F01458D00529121 /* zrtp_test_queue.c in Sources */ = {isa = PBXBuildFile; fileRef = 8D6EECF90F01458D00529121 /* zrtp_test_queue.c */; }; - 8D6EED020F01458D00529121 /* zrtp_test_ui.c in Sources */ = {isa = PBXBuildFile; fileRef = 8D6EECFA0F01458D00529121 /* zrtp_test_ui.c */; }; - 8D6EED110F0145BF00529121 /* libzrtp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8D6EED0F0F0145AA00529121 /* libzrtp.a */; }; -/* End PBXBuildFile section */ - -/* Begin PBXContainerItemProxy section */ - 8D6EED0E0F0145AA00529121 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 8D6EED030F0145AA00529121 /* libzrtp.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 8996E0300EC9CA8C007D7FD5; - remoteInfo = libzrtp_ec; - }; - 8D6EED490F01487C00529121 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 8D6EED030F0145AA00529121 /* libzrtp.xcodeproj */; - proxyType = 1; - remoteGlobalIDString = 8996DFD70EC9CA8C007D7FD5; - remoteInfo = libzrtp_ec; - }; -/* End PBXContainerItemProxy section */ - -/* Begin PBXFileReference section */ - 8D6EEC500F013D2A00529121 /* libzrtp_test_ec */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = libzrtp_test_ec; sourceTree = BUILT_PRODUCTS_DIR; }; - 8D6EECF50F01450800529121 /* zrtp_test_core.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = zrtp_test_core.h; path = ../../test/pc/zrtp_test_core.h; sourceTree = SOURCE_ROOT; }; - 8D6EECF60F01450800529121 /* zrtp_test_queue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = zrtp_test_queue.h; path = ../../test/pc/zrtp_test_queue.h; sourceTree = SOURCE_ROOT; }; - 8D6EECF70F01458D00529121 /* zrtp_test_core.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = zrtp_test_core.c; path = ../../test/pc/zrtp_test_core.c; sourceTree = SOURCE_ROOT; }; - 8D6EECF80F01458D00529121 /* zrtp_test_crypto.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = zrtp_test_crypto.c; path = ../../test/pc/zrtp_test_crypto.c; sourceTree = SOURCE_ROOT; }; - 8D6EECF90F01458D00529121 /* zrtp_test_queue.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = zrtp_test_queue.c; path = ../../test/pc/zrtp_test_queue.c; sourceTree = SOURCE_ROOT; }; - 8D6EECFA0F01458D00529121 /* zrtp_test_ui.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = zrtp_test_ui.c; path = ../../test/pc/zrtp_test_ui.c; sourceTree = SOURCE_ROOT; }; - 8D6EED030F0145AA00529121 /* libzrtp.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = libzrtp.xcodeproj; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 8D6EEC4E0F013D2A00529121 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 8D6EED110F0145BF00529121 /* libzrtp.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 08FB7794FE84155DC02AAC07 /* libzrtp_test */ = { - isa = PBXGroup; - children = ( - 8D6EED030F0145AA00529121 /* libzrtp.xcodeproj */, - 08FB7795FE84155DC02AAC07 /* Source */, - 1AB674ADFE9D54B511CA2CBB /* Products */, - ); - name = libzrtp_test; - sourceTree = ""; - }; - 08FB7795FE84155DC02AAC07 /* Source */ = { - isa = PBXGroup; - children = ( - 8DFEC0890F0125D3004540A4 /* include */, - 8DFEC08A0F0125DE004540A4 /* src */, - ); - name = Source; - sourceTree = ""; - }; - 1AB674ADFE9D54B511CA2CBB /* Products */ = { - isa = PBXGroup; - children = ( - 8D6EEC500F013D2A00529121 /* libzrtp_test_ec */, - ); - name = Products; - sourceTree = ""; - }; - 8D6EED040F0145AA00529121 /* Products */ = { - isa = PBXGroup; - children = ( - 8D6EED0F0F0145AA00529121 /* libzrtp.a */, - ); - name = Products; - sourceTree = ""; - }; - 8DFEC0890F0125D3004540A4 /* include */ = { - isa = PBXGroup; - children = ( - 8D6EECF50F01450800529121 /* zrtp_test_core.h */, - 8D6EECF60F01450800529121 /* zrtp_test_queue.h */, - ); - name = include; - sourceTree = ""; - }; - 8DFEC08A0F0125DE004540A4 /* src */ = { - isa = PBXGroup; - children = ( - 8D6EECF70F01458D00529121 /* zrtp_test_core.c */, - 8D6EECF80F01458D00529121 /* zrtp_test_crypto.c */, - 8D6EECF90F01458D00529121 /* zrtp_test_queue.c */, - 8D6EECFA0F01458D00529121 /* zrtp_test_ui.c */, - ); - name = src; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 8D6EEC4F0F013D2A00529121 /* libzrtp_test_ec */ = { - isa = PBXNativeTarget; - buildConfigurationList = 8D6EEC5D0F013D3E00529121 /* Build configuration list for PBXNativeTarget "libzrtp_test_ec" */; - buildPhases = ( - 8D6EEC4D0F013D2A00529121 /* Sources */, - 8D6EEC4E0F013D2A00529121 /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - 8D6EED4A0F01487C00529121 /* PBXTargetDependency */, - ); - name = libzrtp_test_ec; - productName = libzrtp_test_ec; - productReference = 8D6EEC500F013D2A00529121 /* libzrtp_test_ec */; - productType = "com.apple.product-type.tool"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 08FB7793FE84155DC02AAC07 /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0410; - }; - buildConfigurationList = 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "libzrtp_test" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 1; - knownRegions = ( - en, - ); - mainGroup = 08FB7794FE84155DC02AAC07 /* libzrtp_test */; - projectDirPath = ""; - projectReferences = ( - { - ProductGroup = 8D6EED040F0145AA00529121 /* Products */; - ProjectRef = 8D6EED030F0145AA00529121 /* libzrtp.xcodeproj */; - }, - ); - projectRoot = ""; - targets = ( - 8D6EEC4F0F013D2A00529121 /* libzrtp_test_ec */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXReferenceProxy section */ - 8D6EED0F0F0145AA00529121 /* libzrtp.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libzrtp.a; - remoteRef = 8D6EED0E0F0145AA00529121 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; -/* End PBXReferenceProxy section */ - -/* Begin PBXSourcesBuildPhase section */ - 8D6EEC4D0F013D2A00529121 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 8D6EECFF0F01458D00529121 /* zrtp_test_core.c in Sources */, - 8D6EED000F01458D00529121 /* zrtp_test_crypto.c in Sources */, - 8D6EED010F01458D00529121 /* zrtp_test_queue.c in Sources */, - 8D6EED020F01458D00529121 /* zrtp_test_ui.c in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXTargetDependency section */ - 8D6EED4A0F01487C00529121 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - name = libzrtp_ec; - targetProxy = 8D6EED490F01487C00529121 /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - -/* Begin XCBuildConfiguration section */ - 1DEB928A08733DD80010E9CD /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_BIT)"; - GCC_C_LANGUAGE_STANDARD = c99; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = macosx; - }; - name = Debug; - }; - 1DEB928B08733DD80010E9CD /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_BIT)"; - GCC_C_LANGUAGE_STANDARD = c99; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - SDKROOT = macosx; - }; - name = Release; - }; - 8D6EEC520F013D2B00529121 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_MODEL_TUNING = G5; - GCC_OPTIMIZATION_LEVEL = 0; - HEADER_SEARCH_PATHS = ( - ../../third_party/bnlib, - ../../third_party/bgaes, - ../../projects/gnu/config, - ../../include/enterprise, - ../../include, - ); - INSTALL_PATH = /usr/local/bin; - LIBRARY_SEARCH_PATHS = ( - ../../third_party/bnlib, - "\"$(SRCROOT)/../../../third_party/bnlib\"", - ); - OTHER_CFLAGS = ""; - PRODUCT_NAME = libzrtp_test_ec; - SYMROOT = build_test; - }; - name = Debug; - }; - 8D6EEC530F013D2B00529121 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_MODEL_TUNING = G5; - HEADER_SEARCH_PATHS = ( - ../../third_party/bnlib, - ../../third_party/bgaes, - ../../projects/gnu/config, - ../../include/enterprise, - ../../include, - ); - INSTALL_PATH = /usr/local/bin; - LIBRARY_SEARCH_PATHS = ( - ../../include/third_party/bnlib, - "\"$(SRCROOT)/../../../third_party/bnlib\"", - ); - OTHER_CFLAGS = "-DZRTP_USE_ENTERPRISE=1"; - PRODUCT_NAME = libzrtp_test_ec; - SYMROOT = build_test; - ZERO_LINK = NO; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "libzrtp_test" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 1DEB928A08733DD80010E9CD /* Debug */, - 1DEB928B08733DD80010E9CD /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 8D6EEC5D0F013D3E00529121 /* Build configuration list for PBXNativeTarget "libzrtp_test_ec" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 8D6EEC520F013D2B00529121 /* Debug */, - 8D6EEC530F013D2B00529121 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 08FB7793FE84155DC02AAC07 /* Project object */; -} diff --git a/libs/libzrtp/projects/xcode/libzrtp_test.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/libs/libzrtp/projects/xcode/libzrtp_test.xcodeproj/project.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 3d74d82b5b..0000000000 --- a/libs/libzrtp/projects/xcode/libzrtp_test.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/libs/libzrtp/src/zrtp.c b/libs/libzrtp/src/zrtp.c deleted file mode 100644 index a0ff8de91e..0000000000 --- a/libs/libzrtp/src/zrtp.c +++ /dev/null @@ -1,1208 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - -#include "zrtp.h" - -#define _ZTU_ "zrtp main" - -/*----------------------------------------------------------------------------*/ -extern zrtp_status_t zrtp_init_rng(zrtp_global_t* zrtp); -extern void zrtp_down_rng(zrtp_global_t* zrtp); - -extern zrtp_status_t zrtp_defaults_sas(zrtp_global_t* global_ctx); -extern zrtp_status_t zrtp_defaults_pkt(zrtp_global_t* global_ctx); -extern zrtp_status_t zrtp_defaults_atl(zrtp_global_t* global_ctx); -extern zrtp_status_t zrtp_defaults_aes_cipher(zrtp_global_t* global_ctx); -extern zrtp_status_t zrtp_defaults_hash(zrtp_global_t* global_ctx); -extern zrtp_status_t zrtp_prepare_pkt(); -extern zrtp_status_t zrtp_done_pkt(); - - -void zrtp_config_defaults(zrtp_config_t* config) -{ - zrtp_memset(config, 0, sizeof(zrtp_config_t)); - - zrtp_memcpy(config->client_id, "ZRTP def. peer", 15); - config->lic_mode = ZRTP_LICENSE_MODE_PASSIVE; - - ZSTR_SET_EMPTY(config->def_cache_path); - zrtp_zstrncpyc(ZSTR_GV(config->def_cache_path), "./zrtp_def_cache_path.dat", 25); - - config->cache_auto_store = 1; /* cache auto flushing should be enabled by default */ - -#if (defined(ZRTP_USE_BUILTIN_CACHE) && (ZRTP_USE_BUILTIN_CACHE == 1)) - config->cb.cache_cb.on_init = zrtp_def_cache_init; - config->cb.cache_cb.on_down = zrtp_def_cache_down; - config->cb.cache_cb.on_put = zrtp_def_cache_put; - config->cb.cache_cb.on_put_mitm = zrtp_def_cache_put_mitm; - config->cb.cache_cb.on_get = zrtp_def_cache_get; - config->cb.cache_cb.on_get_mitm = zrtp_def_cache_get_mitm; - config->cb.cache_cb.on_set_verified = zrtp_def_cache_set_verified; - config->cb.cache_cb.on_get_verified = zrtp_def_cache_get_verified; - config->cb.cache_cb.on_reset_since = zrtp_def_cache_reset_since; - config->cb.cache_cb.on_presh_counter_set = zrtp_def_cache_set_presh_counter; - config->cb.cache_cb.on_presh_counter_get = zrtp_def_cache_get_presh_counter; -#endif - -#if (defined(ZRTP_USE_BUILTIN_SCEHDULER) && (ZRTP_USE_BUILTIN_SCEHDULER == 1)) - config->cb.sched_cb.on_init = zrtp_def_scheduler_init; - config->cb.sched_cb.on_down = zrtp_def_scheduler_down; - config->cb.sched_cb.on_call_later = zrtp_def_scheduler_call_later; - config->cb.sched_cb.on_cancel_call_later = zrtp_def_scheduler_cancel_call_later; - config->cb.sched_cb.on_wait_call_later = zrtp_def_scheduler_wait_call_later; -#endif -} - -zrtp_status_t zrtp_init(zrtp_config_t* config, zrtp_global_t** zrtp) -{ - zrtp_global_t* new_zrtp; - zrtp_status_t s = zrtp_status_ok; - - ZRTP_LOG(3, (_ZTU_,"INITIALIZING LIBZRTP...\n")); - - /* Print out configuration setting */ - zrtp_print_env_settings(config); - - new_zrtp = zrtp_sys_alloc(sizeof(zrtp_global_t)); - if (!new_zrtp) { - return zrtp_status_alloc_fail; - } - zrtp_memset(new_zrtp, 0, sizeof(zrtp_global_t)); - - /* - * Apply configuration according to the config - */ - new_zrtp->lic_mode = config->lic_mode; - new_zrtp->is_mitm = config->is_mitm; - ZSTR_SET_EMPTY(new_zrtp->def_cache_path); - zrtp_zstrcpy(ZSTR_GV(new_zrtp->def_cache_path), ZSTR_GV(config->def_cache_path)); - zrtp_memcpy(&new_zrtp->cb, &config->cb, sizeof(zrtp_callback_t)); - new_zrtp->cache_auto_store = config->cache_auto_store; - - ZSTR_SET_EMPTY(new_zrtp->client_id); - zrtp_memset(new_zrtp->client_id.buffer, ' ', sizeof(zrtp_client_id_t)); - zrtp_zstrncpyc( ZSTR_GV(new_zrtp->client_id), - (const char*)config->client_id, - sizeof(zrtp_client_id_t)); - - /* - * General Initialization - */ - init_mlist(&new_zrtp->sessions_head); - - zrtp_mutex_init(&new_zrtp->sessions_protector); - - init_mlist(&new_zrtp->hash_head); - init_mlist(&new_zrtp->cipher_head); - init_mlist(&new_zrtp->atl_head); - init_mlist(&new_zrtp->pktype_head); - init_mlist(&new_zrtp->sas_head); - - /* Init RNG context */ - s = zrtp_init_rng(new_zrtp); - if (zrtp_status_ok != s) { - ZRTP_LOG(1, (_ZTU_,"ERROR! zrtp_init_rng() failed:%s.\n", zrtp_log_status2str(s))); - return zrtp_status_rng_fail; - } - - /* Initialize SRTP engine */ - s = zrtp_srtp_init(new_zrtp); - if (zrtp_status_ok != s) { - ZRTP_LOG(1, (_ZTU_,"ERROR! zrtp_srtp_init() failed:<%s>\n", zrtp_log_status2str(s))); - return zrtp_status_fail; - } - - if (new_zrtp->cb.cache_cb.on_init) { - s = new_zrtp->cb.cache_cb.on_init(new_zrtp); - if (zrtp_status_ok != s) { - ZRTP_LOG(1, (_ZTU_,"ERROR! cache on_init() callback failed <%s>\n", zrtp_log_status2str(s))); - zrtp_srtp_down(new_zrtp); - return zrtp_status_fail; - } - } - - if (new_zrtp->cb.sched_cb.on_init) { - s = new_zrtp->cb.sched_cb.on_init(new_zrtp); - if (zrtp_status_ok != s) { - ZRTP_LOG(1, (_ZTU_,"ERROR! scheduler on_init() callback failed <%s>\n", zrtp_log_status2str(s))); - zrtp_srtp_down(new_zrtp); - return zrtp_status_fail; - } - } - - /* Load default crypto-components */ - zrtp_prepare_pkt(new_zrtp); - zrtp_defaults_sas(new_zrtp); - zrtp_defaults_pkt(new_zrtp); - zrtp_defaults_atl(new_zrtp); - zrtp_defaults_aes_cipher(new_zrtp); - zrtp_defaults_hash(new_zrtp); - - *zrtp = new_zrtp; - - ZRTP_LOG(3, (_ZTU_,"INITIALIZING LIBZRTP - DONE\n")); - return s; -} - - -/*----------------------------------------------------------------------------*/ -zrtp_status_t zrtp_down(zrtp_global_t* zrtp) -{ - ZRTP_LOG(3, (_ZTU_,"DESTROYING LIBZRTP...\n")); - - if (!zrtp) { - return zrtp_status_bad_param; - } - - zrtp_comp_done(ZRTP_CC_HASH, zrtp); - zrtp_comp_done(ZRTP_CC_SAS, zrtp); - zrtp_comp_done(ZRTP_CC_CIPHER, zrtp); - zrtp_comp_done(ZRTP_CC_PKT, zrtp); - zrtp_comp_done(ZRTP_CC_ATL, zrtp); - zrtp_done_pkt(zrtp); - - zrtp_mutex_destroy(zrtp->sessions_protector); - - zrtp_srtp_down(zrtp); - - if (zrtp->cb.cache_cb.on_down) { - zrtp->cb.cache_cb.on_down(); - } - if (zrtp->cb.sched_cb.on_down) { - zrtp->cb.sched_cb.on_down(); - } - - zrtp_down_rng(zrtp); - - zrtp_sys_free(zrtp); - - ZRTP_LOG(3, (_ZTU_,"DESTROYING LIBZRTP - DONE\n")); - - return zrtp_status_ok; -} - -/*----------------------------------------------------------------------------*/ -zrtp_status_t zrtp_session_init( zrtp_global_t* zrtp, - zrtp_profile_t* profile, - zrtp_zid_t zid, - zrtp_signaling_role_t role, - zrtp_session_t **session) -{ - uint32_t i = 0; - zrtp_status_t s = zrtp_status_fail; - zrtp_session_t* new_session = NULL; - - if (!zrtp) { - return zrtp_status_bad_param; - } - - new_session = zrtp_sys_alloc(sizeof(zrtp_session_t)); - if (!new_session) { - return zrtp_status_alloc_fail; - } - - zrtp_memset(new_session, 0, sizeof(zrtp_session_t)); - new_session->id = zrtp->sessions_count++; - - { - zrtp_uchar32_t buff; - ZRTP_LOG(3, (_ZTU_,"START SESSION INITIALIZATION. sID=%u.\n", new_session->id)); - ZRTP_LOG(3, (_ZTU_,"ZID=%s.\n", hex2str((const char*)zid, sizeof(zrtp_uchar12_t), (char*)buff, sizeof(buff)) )); - } - - do { - /* - * Apply profile for the stream context: set flags and prepare Hello packet. - * If profile structure isn't provided, generate default. - */ - if (!profile) { - ZRTP_LOG(1, (_ZTU_,"Profile in NULL - loading default one.\n")); - zrtp_profile_defaults(&new_session->profile, zrtp); - } else { - ZRTP_LOG(1, (_ZTU_,"Loading User's profile:\n")); - if (zrtp_status_ok != zrtp_profile_check(profile, zrtp)) { - ZRTP_LOG(1, (_ZTU_,"ERROR! Can't apply wrong profile to the session sID=%u.\n", new_session->id)); - break; - } - - /* Adjust user's settings: force SHA-384 hash for ECDH-384P */ - if (zrtp_profile_find(profile, ZRTP_CC_PKT, ZRTP_PKTYPE_EC384P) > 0) { - ZRTP_LOG(3, (_ZTU_,"User wants ECDH384 - auto-adjust profile to use SHA-384.\n")); - profile->hash_schemes[0] = ZRTP_HASH_SHA384; - profile->hash_schemes[1] = ZRTP_HASH_SHA256; - profile->hash_schemes[2] = 0; - } - - zrtp_memcpy(&new_session->profile, profile, sizeof(zrtp_profile_t)); - - { - int i; - ZRTP_LOG(3, (_ZTU_," allowclear: %s\n", profile->allowclear?"ON":"OFF")); - ZRTP_LOG(3, (_ZTU_," autosecure: %s\n", profile->autosecure?"ON":"OFF")); - ZRTP_LOG(3, (_ZTU_," disclose_bit: %s\n", profile->disclose_bit?"ON":"OFF")); - ZRTP_LOG(3, (_ZTU_," signal. role: %s\n", zrtp_log_sign_role2str(role))); - ZRTP_LOG(3, (_ZTU_," TTL: %u\n", profile->cache_ttl)); - - ZRTP_LOG(3, (_ZTU_," SAS schemes: ")); - i=0; - while (profile->sas_schemes[i]) { - ZRTP_LOGC(3, ("%.4s ", zrtp_comp_id2type(ZRTP_CC_SAS, profile->sas_schemes[i++]))); - } - ZRTP_LOGC(3, ("\n")); ZRTP_LOG(1, (_ZTU_," Ciphers: ")); - i=0; - while (profile->cipher_types[i]) { - ZRTP_LOGC(3, ("%.4s ", zrtp_comp_id2type(ZRTP_CC_CIPHER, profile->cipher_types[i++]))); - } - ZRTP_LOGC(3, ("\n")); ZRTP_LOG(1, (_ZTU_," PK schemes: ")); - i=0; - while (profile->pk_schemes[i]) { - ZRTP_LOGC(3, ("%.4s ", zrtp_comp_id2type(ZRTP_CC_PKT, profile->pk_schemes[i++]))); - } - ZRTP_LOGC(3, ("\n")); ZRTP_LOG(1, (_ZTU_," ATL: ")); - i=0; - while (profile->auth_tag_lens[i]) { - ZRTP_LOGC(3, ("%.4s ", zrtp_comp_id2type(ZRTP_CC_ATL, profile->auth_tag_lens[i++]))); - } - ZRTP_LOGC(3, ("\n")); ZRTP_LOG(1, (_ZTU_," Hashes: ")); - i=0; - while (profile->hash_schemes[i]) { - ZRTP_LOGC(3, ("%.4s ", zrtp_comp_id2type(ZRTP_CC_HASH, profile->hash_schemes[i++]))); - } - ZRTP_LOGC(3, ("\n")); - } - } - - /* Set ZIDs */ - ZSTR_SET_EMPTY(new_session->zid); - ZSTR_SET_EMPTY(new_session->peer_zid); - zrtp_zstrncpyc(ZSTR_GV(new_session->zid), (const char*)zid, sizeof(zrtp_zid_t)); - - new_session->zrtp = zrtp; - new_session->signaling_role = role; - new_session->mitm_alert_detected = 0; - - /* - * Allocate memory for holding secrets and initialize with random values. - * Actual values will be written from the cache at the beginning of the protocol. - */ - new_session->secrets.rs1 = _zrtp_alloc_shared_secret(new_session); - new_session->secrets.rs2 = _zrtp_alloc_shared_secret(new_session); - new_session->secrets.auxs = _zrtp_alloc_shared_secret(new_session); - new_session->secrets.pbxs = _zrtp_alloc_shared_secret(new_session); - - if ( !new_session->secrets.rs1 || !new_session->secrets.rs2 || - !new_session->secrets.auxs || !new_session->secrets.pbxs) { - ZRTP_LOG(1, (_ZTU_,"ERROR! Can't allocate shared secrets sID=%u\n.", new_session->id)); - s = zrtp_status_alloc_fail; - break; - } - - /* Initialize SAS values */ - ZSTR_SET_EMPTY(new_session->sas1); - ZSTR_SET_EMPTY(new_session->sas2); - ZSTR_SET_EMPTY(new_session->sasbin); - ZSTR_SET_EMPTY(new_session->zrtpsess); - - /* Clear all stream structures */ - for (i=0; istreams[i].state = ZRTP_STATE_NONE; - new_session->streams[i].prev_state = ZRTP_STATE_NONE; - new_session->streams[i].mode = ZRTP_STREAM_MODE_UNKN; - } - - /* Initialize synchronization objects */ - s = zrtp_mutex_init(&new_session->streams_protector); - if (zrtp_status_ok != s) { - ZRTP_LOG(1, (_ZTU_,"ERROR! can't initialize Stream protector. sID=%u.\n", new_session->id)); - break; - } - s = zrtp_mutex_init(&new_session->init_protector); - if (zrtp_status_ok != s) { - ZRTP_LOG(1, (_ZTU_,"ERROR! can't initialize Init protector. sID=%u.\n", new_session->id)); - break; - } - - s = zrtp_status_ok; - } while (0); - - if (zrtp_status_ok != s) { - zrtp_sys_free(new_session); - return s; - } - - /* Add new session to the global list */ - zrtp_mutex_lock(zrtp->sessions_protector); - mlist_add(&zrtp->sessions_head, &new_session->_mlist); - zrtp_mutex_unlock(zrtp->sessions_protector); - - *session = new_session; - - ZRTP_LOG(3, (_ZTU_,"Session initialization - DONE. sID=%u.\n\n", new_session->id)); - - return zrtp_status_ok; -} - -/*----------------------------------------------------------------------------*/ -void zrtp_session_down(zrtp_session_t *session) -{ - int i =0; - - if (!session) { - return; - } - - /* Stop ZRTP engine and clear all crypto sources for every stream in the session. */ - zrtp_mutex_lock(session->streams_protector); - for(i=0; istreams[i]; - zrtp_stream_stop(the_stream); - } - zrtp_mutex_unlock(session->streams_protector); - - /* Release memory allocated on initialization */ - if (session->secrets.rs1) { - zrtp_sys_free(session->secrets.rs1); - } - if (session->secrets.rs2) { - zrtp_sys_free(session->secrets.rs2); - } - if (session->secrets.auxs) { - zrtp_sys_free(session->secrets.auxs); - } - if (session->secrets.pbxs) { - zrtp_sys_free(session->secrets.pbxs); - } - - /* We don't need the session key anymore - clear it */ - zrtp_wipe_zstring(ZSTR_GV(session->zrtpsess)); - - /* Removing session from the global list */ - zrtp_mutex_lock(session->zrtp->sessions_protector); - mlist_del(&session->_mlist); - zrtp_mutex_unlock(session->zrtp->sessions_protector); - - zrtp_mutex_destroy(session->streams_protector); - zrtp_mutex_destroy(session->init_protector); - - zrtp_sys_free(session); -} - -/*----------------------------------------------------------------------------*/ -zrtp_status_t zrtp_stream_attach(zrtp_session_t *session, zrtp_stream_t** stream) -{ - uint32_t i = 0; - zrtp_status_t s = zrtp_status_fail; - zrtp_stream_t* new_stream = NULL; - - ZRTP_LOG(3, (_ZTU_,"ATTACH NEW STREAM to sID=%d:\n", session->id)); - - /* - * Initialize first unused stream. If there are no available streams return error. - */ - zrtp_mutex_lock(session->streams_protector); - for (i=0; istreams[i].state) { - new_stream = &session->streams[i]; - zrtp_memset(new_stream, 0, sizeof(zrtp_stream_t)); - break; - } - } - zrtp_mutex_unlock(session->streams_protector); - - if (!new_stream) { - ZRTP_LOG(1, (_ZTU_,"\tWARNING! Can't attach one more stream. Limit is reached." - " Use #ZRTP_MAX_STREAMS_PER_SESSION. sID=%u\n", session->id)); - return zrtp_status_alloc_fail; - } - - /* - * Initialize the private data stream with default initial values - */ - zrtp_mutex_init(&new_stream->stream_protector); - _zrtp_change_state(new_stream, ZRTP_STATE_ACTIVE); - new_stream->mode = ZRTP_STREAM_MODE_CLEAR; - new_stream->id = session->zrtp->streams_count++; - new_stream->session = session; - new_stream->zrtp = session->zrtp; - new_stream->mitm_mode = ZRTP_MITM_MODE_UNKN; - new_stream->is_hello_received = 0; - - ZSTR_SET_EMPTY(new_stream->cc.hmackey); - ZSTR_SET_EMPTY(new_stream->cc.peer_hmackey); - ZSTR_SET_EMPTY(new_stream->cc.zrtp_key); - ZSTR_SET_EMPTY(new_stream->cc.peer_zrtp_key); - - new_stream->dh_cc.initialized_with = ZRTP_COMP_UNKN; - bnBegin(&new_stream->dh_cc.peer_pv); - ZSTR_SET_EMPTY(new_stream->dh_cc.dhss); - - ZRTP_LOG(3, (_ZTU_,"\tEmpty slot was found - initializing new stream with ID=%u.\n", new_stream->id)); - - do { - zrtp_string32_t hash_buff = ZSTR_INIT_EMPTY(hash_buff); - zrtp_hash_t *hash = zrtp_comp_find(ZRTP_CC_HASH, ZRTP_HASH_SHA256, new_stream->zrtp); - s = zrtp_status_algo_fail; - - if (sizeof(uint16_t) != zrtp_randstr( new_stream->zrtp, - (uint8_t*)&new_stream->media_ctx.high_out_zrtp_seq, - sizeof(uint16_t))) { - break; - } - - /* - * Compute and store message hashes to prevent DoS attacks. - * Generate H0 as a random nonce and compute H1, H2 and H3 - * using the leftmost 128 bits from every hash. - * Then insert these directly into the message structures. - */ - - zrtp_memset(&new_stream->messages, 0, sizeof(new_stream->messages)); - ZSTR_SET_EMPTY(new_stream->messages.h0); - ZSTR_SET_EMPTY(new_stream->messages.signaling_hash); - - /* Generate Random nonce, compute H1 and store in the DH packet */ - new_stream->messages.h0.length = (uint16_t)zrtp_randstr( new_stream->zrtp, - (unsigned char*)new_stream->messages.h0.buffer, - ZRTP_MESSAGE_HASH_SIZE); - if (ZRTP_MESSAGE_HASH_SIZE != new_stream->messages.h0.length) { - break; - } - - s = hash->hash(hash, ZSTR_GV(new_stream->messages.h0), ZSTR_GV(hash_buff)); - if (zrtp_status_ok != s) { - break; - } - zrtp_memcpy(new_stream->messages.dhpart.hash, hash_buff.buffer, ZRTP_MESSAGE_HASH_SIZE); - - /* Compute H2 for the Commit */ - s = hash->hash_c(hash, (char*)new_stream->messages.dhpart.hash, ZRTP_MESSAGE_HASH_SIZE, ZSTR_GV(hash_buff)); - if (zrtp_status_ok != s) { - break; - } - zrtp_memcpy(new_stream->messages.commit.hash, hash_buff.buffer, ZRTP_MESSAGE_HASH_SIZE); - - /* Compute H3 for the Hello message */ - s = hash->hash_c(hash, (char*)new_stream->messages.commit.hash, ZRTP_MESSAGE_HASH_SIZE, ZSTR_GV(hash_buff)); - if (zrtp_status_ok != s) { - break; - } - zrtp_memcpy(new_stream->messages.hello.hash, hash_buff.buffer, ZRTP_MESSAGE_HASH_SIZE); - - s = zrtp_status_ok; - } while (0); - - if (zrtp_status_ok != s) { - ZRTP_LOG(1, (_ZTU_,"\tERROR! Fail to compute messages hashes <%s>.\n", zrtp_log_status2str(s))); - return s; - } - - /* - * Preparing HELLO based on user's profile - */ - ZRTP_LOG(3, (_ZTU_,"\tPreparing ZRTP Hello according to the Session profile.\n")); - { - zrtp_packet_Hello_t* hello = &new_stream->messages.hello; - uint8_t i = 0; - int8_t* comp_ptr = NULL; - - /* Set Protocol Version and ClientID */ - zrtp_memcpy(hello->version, ZRTP_PROTOCOL_VERSION, ZRTP_VERSION_SIZE); - zrtp_memcpy(hello->cliend_id, session->zrtp->client_id.buffer, session->zrtp->client_id.length); - - /* Set flags. */ - hello->pasive = (ZRTP_LICENSE_MODE_PASSIVE == session->zrtp->lic_mode) ? 1 : 0; - hello->uflag = (ZRTP_LICENSE_MODE_UNLIMITED == session->zrtp->lic_mode) ? 1 : 0; - hello->mitmflag = session->zrtp->is_mitm; - hello->sigflag = 0; - - zrtp_memcpy(hello->zid, session->zid.buffer, session->zid.length); - - comp_ptr = (int8_t*)hello->comp; - i = 0; - while ( session->profile.hash_schemes[i]) { - zrtp_memcpy( comp_ptr, - zrtp_comp_id2type(ZRTP_CC_HASH, session->profile.hash_schemes[i++]), - ZRTP_COMP_TYPE_SIZE ); - comp_ptr += ZRTP_COMP_TYPE_SIZE; - } - hello->hc = i; - - i = 0; - while (session->profile.cipher_types[i]) { - zrtp_memcpy( comp_ptr, - zrtp_comp_id2type(ZRTP_CC_CIPHER, session->profile.cipher_types[i++]), - ZRTP_COMP_TYPE_SIZE ); - comp_ptr += ZRTP_COMP_TYPE_SIZE; - } - hello->cc = i; - - i = 0; - while (session->profile.auth_tag_lens[i] ) { - zrtp_memcpy( comp_ptr, - zrtp_comp_id2type(ZRTP_CC_ATL, session->profile.auth_tag_lens[i++]), - ZRTP_COMP_TYPE_SIZE ); - comp_ptr += ZRTP_COMP_TYPE_SIZE; - } - hello->ac = i; - - i = 0; - while (session->profile.pk_schemes[i] ) { - zrtp_memcpy( comp_ptr, - zrtp_comp_id2type(ZRTP_CC_PKT, session->profile.pk_schemes[i++]), - ZRTP_COMP_TYPE_SIZE ); - comp_ptr += ZRTP_COMP_TYPE_SIZE; - } - hello->kc = i; - - i = 0; - while (session->profile.sas_schemes[i]) { - zrtp_memcpy( comp_ptr, - zrtp_comp_id2type(ZRTP_CC_SAS, session->profile.sas_schemes[i++]), - ZRTP_COMP_TYPE_SIZE ); - comp_ptr += ZRTP_COMP_TYPE_SIZE; - } - hello->sc = i; - - /* - * Hmac will appear at the end of the message, after the dynamic portion. - * i is the length of the dynamic part. - */ - i = (hello->hc + hello->cc + hello->ac + hello->kc + hello->sc) * ZRTP_COMP_TYPE_SIZE; - _zrtp_packet_fill_msg_hdr( new_stream, - ZRTP_HELLO, - ZRTP_HELLO_STATIC_SIZE + i + ZRTP_HMAC_SIZE, - &hello->hdr); - } - - *stream = new_stream; - - ZRTP_LOG(3, (_ZTU_,"ATTACH NEW STREAM - DONE.\n")); - return zrtp_status_ok; -} - -/*---------------------------------------------------------------------------*/ -zrtp_status_t zrtp_signaling_hash_get( zrtp_stream_t* stream, - char *hash_buff, - uint32_t hash_buff_length) -{ - zrtp_string32_t hash_str = ZSTR_INIT_EMPTY(hash_str); - zrtp_hash_t *hash = NULL; - - if (!stream || !hash_buff) { - return zrtp_status_bad_param; - } - - if (ZRTP_SIGN_ZRTP_HASH_LENGTH > hash_buff_length) { - return zrtp_status_buffer_size; - } - - if (stream->state < ZRTP_STATE_ACTIVE) { - return zrtp_status_wrong_state; - } - - hash = zrtp_comp_find(ZRTP_CC_HASH, ZRTP_HASH_SHA256, stream->zrtp); - hash->hash_c( hash, - (const char*)&stream->messages.hello.hdr, - zrtp_ntoh16(stream->messages.hello.hdr.length) * 4, - ZSTR_GV(hash_str) ); - - hex2str(hash_str.buffer, ZRTP_MESSAGE_HASH_SIZE, hash_buff, hash_buff_length); - - return zrtp_status_ok; -} - -zrtp_status_t zrtp_signaling_hash_set( zrtp_stream_t* ctx, - const char *hash_buff, - uint32_t hash_buff_length) -{ - if (!ctx || !hash_buff) { - return zrtp_status_bad_param; - } - - if (ZRTP_SIGN_ZRTP_HASH_LENGTH > hash_buff_length) { - return zrtp_status_buffer_size; - } - - if (ctx->state != ZRTP_STATE_ACTIVE) { - return zrtp_status_wrong_state; - } - - str2hex(hash_buff, - ZRTP_SIGN_ZRTP_HASH_LENGTH, - ctx->messages.signaling_hash.buffer, - ctx->messages.signaling_hash.max_length); - ctx->messages.signaling_hash.length = ZRTP_MESSAGE_HASH_SIZE; - - ZRTP_LOG(3, (_ZTU_,"SIGNALLING HAS was ADDED for the comparison. ID=%u\n", ctx->id)); - ZRTP_LOG(3, (_ZTU_,"Hash=%.*s.\n", ZRTP_SIGN_ZRTP_HASH_LENGTH, hash_buff)); - - return zrtp_status_ok; -} - - -/*----------------------------------------------------------------------------*/ -static const char* zrtp_pkt2str[] = { - "Preshared", - "Multistream", - "DH-2048", - "ECDH-256", - "DH-3072", - "ECDH-384", - "ECDH-521", - "DH-4096" -}; - -static const char* zrtp_hash2str[] = { - "SHA-256", - "SHA1", - "SHA-384" -}; - -static const char* zrtp_cipher2str[] = { - "AES-128", - "AES-256" -}; - -static const char* zrtp_atl2str[] = { - "HMAC-SHA1 32 bit", - "HMAC-SHA1 80 bit" -}; - -static const char* zrtp_sas2str[] = { - "Base-32", - "Base-256" -}; - -zrtp_status_t zrtp_session_get(zrtp_session_t *session, zrtp_session_info_t *info) -{ - int i=0; - if (!session || !info) { - return zrtp_status_bad_param; - } - - zrtp_memset(info, 0, sizeof(zrtp_session_info_t)); - - ZSTR_SET_EMPTY(info->peer_clientid); - ZSTR_SET_EMPTY(info->peer_version); - ZSTR_SET_EMPTY(info->zid); - ZSTR_SET_EMPTY(info->peer_zid); - ZSTR_SET_EMPTY(info->sas1); - ZSTR_SET_EMPTY(info->sasbin); - ZSTR_SET_EMPTY(info->sas2); - ZSTR_SET_EMPTY(info->auth_name); - ZSTR_SET_EMPTY(info->cipher_name); - ZSTR_SET_EMPTY(info->hash_name); - ZSTR_SET_EMPTY(info->sas_name); - ZSTR_SET_EMPTY(info->pk_name); - - info->id = session->id; - zrtp_zstrcpy(ZSTR_GV(info->zid), ZSTR_GV(session->zid)); - zrtp_zstrcpy(ZSTR_GV(info->peer_zid), ZSTR_GV(session->peer_zid)); - - for (i=0; istreams[i]; - if ((full_stream->state > ZRTP_STATE_ACTIVE) && !ZRTP_IS_STREAM_FAST(full_stream)) - { - zrtp_zstrcpyc(ZSTR_GV(info->pk_name), zrtp_pkt2str[full_stream->pubkeyscheme->base.id-1]); - - zrtp_zstrncpyc( ZSTR_GV(info->peer_clientid), - (const char*)full_stream->messages.peer_hello.cliend_id, 16); - zrtp_zstrncpyc( ZSTR_GV(info->peer_version), - (const char*)full_stream->messages.peer_hello.version, 4); - - info->secrets_ttl = full_stream->cache_ttl; - } - } - - info->sas_is_ready = (session->zrtpsess.length > 0) ? 1 : 0; - if (info->sas_is_ready) { - zrtp_zstrcpy(ZSTR_GV(info->sas1), ZSTR_GV(session->sas1)); - zrtp_zstrcpy(ZSTR_GV(info->sas2), ZSTR_GV(session->sas2)); - zrtp_zstrcpy(ZSTR_GV(info->sasbin), ZSTR_GV(session->sasbin)); - info->sas_is_base256 = (ZRTP_SAS_BASE256 == session->sasscheme->base.id); - - info->sas_is_verified = 0; - if (session->zrtp->cb.cache_cb.on_get_verified) { - session->zrtp->cb.cache_cb.on_get_verified( ZSTR_GV(session->zid), - ZSTR_GV(session->peer_zid), - &info->sas_is_verified); - } - - zrtp_zstrcpyc(ZSTR_GV(info->hash_name), zrtp_hash2str[session->hash->base.id-1]); - zrtp_zstrcpyc(ZSTR_GV(info->cipher_name), zrtp_cipher2str[session->blockcipher->base.id-1]); - zrtp_zstrcpyc(ZSTR_GV(info->auth_name), zrtp_atl2str[session->authtaglength->base.id-1]); - zrtp_zstrcpyc(ZSTR_GV(info->sas_name), zrtp_sas2str[session->sasscheme->base.id-1]); - - info->cached_flags = session->secrets.cached_curr; - info->matches_flags= session->secrets.matches_curr; - info->wrongs_flags = session->secrets.wrongs_curr; - } - - return zrtp_status_ok; -} - -zrtp_status_t zrtp_stream_get(zrtp_stream_t *stream, zrtp_stream_info_t *info) -{ - if (!stream || !info) { - return zrtp_status_bad_param; - } - - zrtp_memset(info, 0, sizeof(zrtp_stream_info_t)); - - info->id = stream->id; - info->state = stream->state; - info->mode = stream->mode; - info->mitm_mode = stream->mitm_mode; - - if (stream->state > ZRTP_STATE_ACTIVE) { - info->last_error = stream->last_error; - info->peer_passive = stream->peer_passive; - info->res_allowclear= stream->allowclear; - info->peer_disclose = stream->peer_disclose_bit; - info->peer_mitm = stream->peer_mitm_flag; - } - - return zrtp_status_ok; -} - -void zrtp_session_set_userdata(zrtp_session_t *session, void* udata) { - session->usr_data = udata; -} -void* zrtp_session_get_userdata(zrtp_session_t *session) { - return session->usr_data; -} - -void zrtp_stream_set_userdata(zrtp_stream_t *stream, void* udata) { - stream->usr_data = udata; -} -void* zrtp_stream_get_userdata(const zrtp_stream_t *stream) { - return stream->usr_data; -} - -/*----------------------------------------------------------------------------*/ -void zrtp_profile_defaults(zrtp_profile_t* profile, zrtp_global_t* zrtp) -{ - zrtp_memset(profile, 0, sizeof(zrtp_profile_t)); - - profile->autosecure = 1; - profile->allowclear = 0; - profile->discovery_optimization = 1; - profile->cache_ttl = ZRTP_CACHE_DEFAULT_TTL; - - profile->sas_schemes[0] = ZRTP_SAS_BASE256; - profile->sas_schemes[1] = ZRTP_SAS_BASE32; - profile->cipher_types[0] = ZRTP_CIPHER_AES256; - profile->cipher_types[1] = ZRTP_CIPHER_AES128; - profile->auth_tag_lens[0] = ZRTP_ATL_HS32; - profile->auth_tag_lens[1] = ZRTP_ATL_HS80; - profile->hash_schemes[0] = ZRTP_HASH_SHA256; - - if (zrtp && (ZRTP_LICENSE_MODE_PASSIVE == zrtp->lic_mode)) { - profile->pk_schemes[0] = ZRTP_PKTYPE_DH2048; - profile->pk_schemes[1] = ZRTP_PKTYPE_EC256P; - profile->pk_schemes[2] = ZRTP_PKTYPE_DH3072; - } else { - profile->pk_schemes[0] = ZRTP_PKTYPE_EC256P; - profile->pk_schemes[1] = ZRTP_PKTYPE_DH3072; - profile->pk_schemes[2] = ZRTP_PKTYPE_DH2048; - } - profile->pk_schemes[3] = ZRTP_PKTYPE_MULT; -} - -/*----------------------------------------------------------------------------*/ -zrtp_status_t zrtp_profile_check(const zrtp_profile_t* profile, zrtp_global_t* zrtp) -{ - uint8_t i = 0; - - if (!profile || !zrtp) { - return zrtp_status_bad_param; - } - - /* - * Fail if the required base components are not present in the profile. - */ - if (0 > zrtp_profile_find(profile, ZRTP_CC_HASH, ZRTP_HASH_SHA256)) { - ZRTP_LOG(1, (_ZTU_,"WARNING! can't find 'SHA256 ' in profile.\n")); - return zrtp_status_fail; - } - - if (0 > zrtp_profile_find(profile, ZRTP_CC_SAS, ZRTP_SAS_BASE32)) { - ZRTP_LOG(1, (_ZTU_,"WARNING! can't find 'base32' in profile.\n")); - return zrtp_status_fail; - } - - if (0 > zrtp_profile_find(profile, ZRTP_CC_CIPHER, ZRTP_CIPHER_AES128)) { - ZRTP_LOG(1, (_ZTU_,"WARNING! can't find 'AES1287 ' in profile.\n")); - return zrtp_status_fail; - } - - if (0 > zrtp_profile_find(profile, ZRTP_CC_PKT, ZRTP_PKTYPE_DH3072)) { - ZRTP_LOG(1, (_ZTU_,"WARNING! can't find 'DH3K' in profile.\n")); - return zrtp_status_fail; - } - - if (0 > zrtp_profile_find(profile, ZRTP_CC_PKT, ZRTP_PKTYPE_MULT)) { - ZRTP_LOG(1, (_ZTU_,"WARNING! can't find 'Mult' in profile.\n")); - return zrtp_status_fail; - } - - if (0 > zrtp_profile_find(profile, ZRTP_CC_ATL, ZRTP_ATL_HS32)) { - ZRTP_LOG(1, (_ZTU_,"WARNING! can't find '32 ' in profile.\n")); - return zrtp_status_fail; - } - - if (0 > zrtp_profile_find(profile, ZRTP_CC_ATL, ZRTP_ATL_HS80)) { - ZRTP_LOG(1, (_ZTU_,"WARNING! can't find '80 ' in profile.\n")); - return zrtp_status_fail; - } - - /* - * Check that each component in the profile is in the global set of components. - */ - i = 0; - while (profile->sas_schemes[i]) { - if (!zrtp_comp_find(ZRTP_CC_SAS, profile->sas_schemes[i++], zrtp)) { - return zrtp_status_fail; - } - } - - i = 0; - while (profile->cipher_types[i]) { - if (!zrtp_comp_find( ZRTP_CC_CIPHER, profile->cipher_types[i++], zrtp)) { - return zrtp_status_fail; - } - } - - i = 0; - while (profile->pk_schemes[i]) { - if (!zrtp_comp_find(ZRTP_CC_PKT, profile->pk_schemes[i++], zrtp)) { - return zrtp_status_fail; - } - } - - i = 0; - while (profile->auth_tag_lens[i]) { - if (!zrtp_comp_find(ZRTP_CC_ATL, profile->auth_tag_lens[i++], zrtp)) { - return zrtp_status_fail; - } - } - - i = 0; - while (profile->hash_schemes[i]) { - if (!zrtp_comp_find(ZRTP_CC_HASH, profile->hash_schemes[i++], zrtp)) { - return zrtp_status_fail; - } - } - - /* Can't use Preshared with No cahce */ - if (NULL == zrtp->cb.cache_cb.on_get) { - i = 0; - while (profile->pk_schemes[i]) { - if (ZRTP_PKTYPE_PRESH == profile->pk_schemes[i++]) { - ZRTP_LOG(1, (_ZTU_,"WARNING! can't use Preshared PK with no cache.\n")); - return zrtp_status_fail; - } - } - } - - return zrtp_status_ok; -} - - -/*----------------------------------------------------------------------------*/ -int zrtp_profile_find(const zrtp_profile_t* profile, zrtp_crypto_comp_t type, uint8_t id) - -{ - uint8_t* prof_elem = NULL; - unsigned int i = 0; - - if (!profile || !id) { - return -1; - } - - switch (type) - { - case ZRTP_CC_HASH: - prof_elem = (uint8_t*)profile->hash_schemes; - break; - case ZRTP_CC_SAS: - prof_elem = (uint8_t*)profile->sas_schemes; - break; - case ZRTP_CC_CIPHER: - prof_elem = (uint8_t*)profile->cipher_types; - break; - case ZRTP_CC_PKT: - prof_elem = (uint8_t*)profile->pk_schemes; - break; - case ZRTP_CC_ATL: - prof_elem = (uint8_t*)profile->auth_tag_lens; - break; - default: - return -1; - } - - - i = 0; - while ( prof_elem[i] ) { - if (id == prof_elem[i++]) return i; - } - - return -1; -} - - -/*============================================================================*/ -/* ZRTP components management part */ -/*============================================================================*/ - - -/*----------------------------------------------------------------------------*/ -#define DESTROY_COMP(mac_node, mac_tmp, mac_type, mac_head, mac_comp)\ -{ \ - mac_node = mac_tmp = NULL;\ - mac_comp = NULL;\ - mlist_for_each_safe(mac_node, mac_tmp, mac_head) \ - {\ - mac_comp = (zrtp_comp_t*) mlist_get_struct(mac_type, mlist, mac_node); \ - if (mac_comp->free)\ - mac_comp->free((mac_type*)mac_comp);\ - mlist_del(mac_node);\ - zrtp_sys_free(mac_comp);\ - } \ -}break - -zrtp_status_t zrtp_comp_done(zrtp_crypto_comp_t type, zrtp_global_t* zrtp) -{ - mlist_t* node = NULL; - mlist_t* tmp = NULL; - zrtp_comp_t* comp = NULL; - - switch (type) - { - case ZRTP_CC_HASH: - DESTROY_COMP(node, tmp, zrtp_hash_t, &zrtp->hash_head, comp); - case ZRTP_CC_SAS: - DESTROY_COMP(node, tmp, zrtp_sas_scheme_t, &zrtp->sas_head, comp); - case ZRTP_CC_CIPHER: - DESTROY_COMP(node, tmp, zrtp_cipher_t, &zrtp->cipher_head, comp); - case ZRTP_CC_PKT: - DESTROY_COMP(node, tmp, zrtp_pk_scheme_t, &zrtp->pktype_head, comp); - case ZRTP_CC_ATL: - DESTROY_COMP(node, tmp, zrtp_auth_tag_length_t, &zrtp->atl_head, comp); - default: - break; - } - - return zrtp_status_ok; -} - -/*----------------------------------------------------------------------------*/ -#define ZRTP_COMP_INIT(mac_type, mac_head, mac_elem)\ -{\ - mac_type* mac_e = (mac_type*)mac_elem; \ - mlist_add_tail(mac_head, &mac_e->mlist);\ - if (mac_e->base.init)\ - mac_e->base.init((mac_type*)mac_e);\ -} break;\ - -zrtp_status_t zrtp_comp_register( zrtp_crypto_comp_t type, - void *comp, - zrtp_global_t* zrtp ) -{ - switch (type) - { - case ZRTP_CC_HASH: - ZRTP_COMP_INIT(zrtp_hash_t, &zrtp->hash_head, comp); - case ZRTP_CC_SAS: - ZRTP_COMP_INIT(zrtp_sas_scheme_t, &zrtp->sas_head, comp); - case ZRTP_CC_CIPHER: - ZRTP_COMP_INIT(zrtp_cipher_t, &zrtp->cipher_head, comp); - case ZRTP_CC_ATL: - ZRTP_COMP_INIT(zrtp_auth_tag_length_t, &zrtp->atl_head, comp); - case ZRTP_CC_PKT: - ZRTP_COMP_INIT(zrtp_pk_scheme_t, &zrtp->pktype_head, comp); - default: - break; - } - - return zrtp_status_ok; -} - -/*----------------------------------------------------------------------------*/ -#define ZRTP_COMP_FIND(mac_head, mac_id, mac_type, res)\ -{\ - mlist_t* mac_node = NULL;\ - mlist_for_each(mac_node, mac_head)\ - {\ - zrtp_comp_t* mac_e = (zrtp_comp_t*) mlist_get_struct(mac_type, mlist, mac_node);\ - if ( mac_id == mac_e->id )\ - {\ - res = (mac_type*)mac_e;\ - break;\ - }\ - }\ -} break; - -void* zrtp_comp_find(zrtp_crypto_comp_t type, uint8_t id, zrtp_global_t* zrtp) -{ - void* res = NULL; - - switch (type) - { - case ZRTP_CC_HASH: - ZRTP_COMP_FIND(&zrtp->hash_head, id, zrtp_hash_t, res); - case ZRTP_CC_SAS: - ZRTP_COMP_FIND(&zrtp->sas_head, id, zrtp_sas_scheme_t, res); - case ZRTP_CC_CIPHER: - ZRTP_COMP_FIND(&zrtp->cipher_head, id, zrtp_cipher_t, res); - case ZRTP_CC_PKT: - ZRTP_COMP_FIND(&zrtp->pktype_head, id, zrtp_pk_scheme_t, res); - case ZRTP_CC_ATL: - ZRTP_COMP_FIND(&zrtp->atl_head, id, zrtp_auth_tag_length_t, res); - default: - break; - } - - return res ; -} - -/*----------------------------------------------------------------------------*/ -char* zrtp_comp_id2type(zrtp_crypto_comp_t type, uint8_t id) -{ - if (ZRTP_COMP_UNKN == id) - return "Unkn"; - - switch (type) - { - case ZRTP_CC_HASH: - switch (id) - { - case ZRTP_HASH_SHA256: return ZRTP_S256; - case ZRTP_HASH_SHA384: return ZRTP_S384; - default: return "Unkn"; - } - break; - - case ZRTP_CC_SAS: - switch (id) - { - case ZRTP_SAS_BASE32: return ZRTP_B32; - case ZRTP_SAS_BASE256: return ZRTP_B256; - default: return "Unkn"; - } - break; - - case ZRTP_CC_CIPHER: - switch (id) - { - case ZRTP_CIPHER_AES128: return ZRTP_AES1; - case ZRTP_CIPHER_AES256: return ZRTP_AES3; - default: return "Unkn"; - } - break; - - case ZRTP_CC_PKT: - switch (id) - { - case ZRTP_PKTYPE_PRESH: return ZRTP_PRESHARED; - case ZRTP_PKTYPE_MULT: return ZRTP_MULT; - case ZRTP_PKTYPE_DH2048: return ZRTP_DH2K; - case ZRTP_PKTYPE_DH3072: return ZRTP_DH3K; - case ZRTP_PKTYPE_EC256P: return ZRTP_EC256P; - case ZRTP_PKTYPE_EC384P: return ZRTP_EC384P; - case ZRTP_PKTYPE_EC521P: return ZRTP_EC521P; - default: return "Unkn"; - } - break; - - case ZRTP_CC_ATL: - switch (id) - { - case ZRTP_ATL_HS32: return ZRTP_HS32; - case ZRTP_ATL_HS80: return ZRTP_HS80; - default: return "Unkn"; - } - break; - - default: - return "Unkn"; - } -} - -/*----------------------------------------------------------------------------*/ -uint8_t zrtp_comp_type2id(zrtp_crypto_comp_t type, char* name) -{ - switch (type) - { - case ZRTP_CC_HASH: - if (!zrtp_memcmp(ZRTP_S256, name, ZRTP_COMP_TYPE_SIZE)) { - return ZRTP_HASH_SHA256; - } - if (!zrtp_memcmp(ZRTP_S384, name, ZRTP_COMP_TYPE_SIZE)) { - return ZRTP_HASH_SHA384; - } - break; - - case ZRTP_CC_SAS: - if (!zrtp_memcmp(ZRTP_B32, name, ZRTP_COMP_TYPE_SIZE)) { - return ZRTP_SAS_BASE32; - } - if (!zrtp_memcmp(ZRTP_B256, name, ZRTP_COMP_TYPE_SIZE)) { - return ZRTP_SAS_BASE256; - } - break; - - case ZRTP_CC_CIPHER: - if (!zrtp_memcmp(ZRTP_AES1, name, ZRTP_COMP_TYPE_SIZE)) { - return ZRTP_CIPHER_AES128; - } - if (!zrtp_memcmp(ZRTP_AES3, name, ZRTP_COMP_TYPE_SIZE)) { - return ZRTP_CIPHER_AES256; - } - break; - - case ZRTP_CC_PKT: - if (!zrtp_memcmp(ZRTP_PRESHARED, name, ZRTP_COMP_TYPE_SIZE)) { - return ZRTP_PKTYPE_PRESH; - } - if (!zrtp_memcmp(ZRTP_MULT, name, ZRTP_COMP_TYPE_SIZE)) { - return ZRTP_PKTYPE_MULT; - } - if (!zrtp_memcmp(ZRTP_DH3K, name, ZRTP_COMP_TYPE_SIZE)) { - return ZRTP_PKTYPE_DH3072; - } - if (!zrtp_memcmp(ZRTP_DH2K, name, ZRTP_COMP_TYPE_SIZE)) { - return ZRTP_PKTYPE_DH2048; - } - if (!zrtp_memcmp(ZRTP_EC256P, name, ZRTP_COMP_TYPE_SIZE)) { - return ZRTP_PKTYPE_EC256P; - } - if (!zrtp_memcmp(ZRTP_EC384P, name, ZRTP_COMP_TYPE_SIZE)) { - return ZRTP_PKTYPE_EC384P; - } - if (!zrtp_memcmp(ZRTP_EC521P, name, ZRTP_COMP_TYPE_SIZE)) { - return ZRTP_PKTYPE_EC521P; - } - break; - - case ZRTP_CC_ATL: - if ( !zrtp_memcmp(ZRTP_HS32, name, ZRTP_COMP_TYPE_SIZE)) { - return ZRTP_ATL_HS32; - } - if (!zrtp_memcmp(ZRTP_HS80, name, ZRTP_COMP_TYPE_SIZE)) { - return ZRTP_ATL_HS80; - } - break; - - default: - return 0; - } - - return 0; -} diff --git a/libs/libzrtp/src/zrtp_crc.c b/libs/libzrtp/src/zrtp_crc.c deleted file mode 100644 index 847b4e3f3f..0000000000 --- a/libs/libzrtp/src/zrtp_crc.c +++ /dev/null @@ -1,146 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - -#include "zrtp.h" - -#define ZRTP_CRC32C_POLY 0x1EDC6F41 -#define ZRTP_CRC32C(crc_c,c,d) (c=(c>>8)^crc_c[(c^(d))&0xFF]) - -/*----------------------------------------------------------------------------*/ -uint32_t zrtp_generate_crc(const uint8_t* buff, uint32_t length) -{ - uint32_t i=0; - uint32_t crc32 = ~0L; - uint32_t result; - uint8_t byte0,byte1,byte2,byte3; - - static const uint32_t crc_c[256] = - { - 0x00000000L, 0xF26B8303L, 0xE13B70F7L, 0x1350F3F4L, - 0xC79A971FL, 0x35F1141CL, 0x26A1E7E8L, 0xD4CA64EBL, - 0x8AD958CFL, 0x78B2DBCCL, 0x6BE22838L, 0x9989AB3BL, - 0x4D43CFD0L, 0xBF284CD3L, 0xAC78BF27L, 0x5E133C24L, - 0x105EC76FL, 0xE235446CL, 0xF165B798L, 0x030E349BL, - 0xD7C45070L, 0x25AFD373L, 0x36FF2087L, 0xC494A384L, - 0x9A879FA0L, 0x68EC1CA3L, 0x7BBCEF57L, 0x89D76C54L, - 0x5D1D08BFL, 0xAF768BBCL, 0xBC267848L, 0x4E4DFB4BL, - 0x20BD8EDEL, 0xD2D60DDDL, 0xC186FE29L, 0x33ED7D2AL, - 0xE72719C1L, 0x154C9AC2L, 0x061C6936L, 0xF477EA35L, - 0xAA64D611L, 0x580F5512L, 0x4B5FA6E6L, 0xB93425E5L, - 0x6DFE410EL, 0x9F95C20DL, 0x8CC531F9L, 0x7EAEB2FAL, - 0x30E349B1L, 0xC288CAB2L, 0xD1D83946L, 0x23B3BA45L, - 0xF779DEAEL, 0x05125DADL, 0x1642AE59L, 0xE4292D5AL, - 0xBA3A117EL, 0x4851927DL, 0x5B016189L, 0xA96AE28AL, - 0x7DA08661L, 0x8FCB0562L, 0x9C9BF696L, 0x6EF07595L, - 0x417B1DBCL, 0xB3109EBFL, 0xA0406D4BL, 0x522BEE48L, - 0x86E18AA3L, 0x748A09A0L, 0x67DAFA54L, 0x95B17957L, - 0xCBA24573L, 0x39C9C670L, 0x2A993584L, 0xD8F2B687L, - 0x0C38D26CL, 0xFE53516FL, 0xED03A29BL, 0x1F682198L, - 0x5125DAD3L, 0xA34E59D0L, 0xB01EAA24L, 0x42752927L, - 0x96BF4DCCL, 0x64D4CECFL, 0x77843D3BL, 0x85EFBE38L, - 0xDBFC821CL, 0x2997011FL, 0x3AC7F2EBL, 0xC8AC71E8L, - 0x1C661503L, 0xEE0D9600L, 0xFD5D65F4L, 0x0F36E6F7L, - 0x61C69362L, 0x93AD1061L, 0x80FDE395L, 0x72966096L, - 0xA65C047DL, 0x5437877EL, 0x4767748AL, 0xB50CF789L, - 0xEB1FCBADL, 0x197448AEL, 0x0A24BB5AL, 0xF84F3859L, - 0x2C855CB2L, 0xDEEEDFB1L, 0xCDBE2C45L, 0x3FD5AF46L, - 0x7198540DL, 0x83F3D70EL, 0x90A324FAL, 0x62C8A7F9L, - 0xB602C312L, 0x44694011L, 0x5739B3E5L, 0xA55230E6L, - 0xFB410CC2L, 0x092A8FC1L, 0x1A7A7C35L, 0xE811FF36L, - 0x3CDB9BDDL, 0xCEB018DEL, 0xDDE0EB2AL, 0x2F8B6829L, - 0x82F63B78L, 0x709DB87BL, 0x63CD4B8FL, 0x91A6C88CL, - 0x456CAC67L, 0xB7072F64L, 0xA457DC90L, 0x563C5F93L, - 0x082F63B7L, 0xFA44E0B4L, 0xE9141340L, 0x1B7F9043L, - 0xCFB5F4A8L, 0x3DDE77ABL, 0x2E8E845FL, 0xDCE5075CL, - 0x92A8FC17L, 0x60C37F14L, 0x73938CE0L, 0x81F80FE3L, - 0x55326B08L, 0xA759E80BL, 0xB4091BFFL, 0x466298FCL, - 0x1871A4D8L, 0xEA1A27DBL, 0xF94AD42FL, 0x0B21572CL, - 0xDFEB33C7L, 0x2D80B0C4L, 0x3ED04330L, 0xCCBBC033L, - 0xA24BB5A6L, 0x502036A5L, 0x4370C551L, 0xB11B4652L, - 0x65D122B9L, 0x97BAA1BAL, 0x84EA524EL, 0x7681D14DL, - 0x2892ED69L, 0xDAF96E6AL, 0xC9A99D9EL, 0x3BC21E9DL, - 0xEF087A76L, 0x1D63F975L, 0x0E330A81L, 0xFC588982L, - 0xB21572C9L, 0x407EF1CAL, 0x532E023EL, 0xA145813DL, - 0x758FE5D6L, 0x87E466D5L, 0x94B49521L, 0x66DF1622L, - 0x38CC2A06L, 0xCAA7A905L, 0xD9F75AF1L, 0x2B9CD9F2L, - 0xFF56BD19L, 0x0D3D3E1AL, 0x1E6DCDEEL, 0xEC064EEDL, - 0xC38D26C4L, 0x31E6A5C7L, 0x22B65633L, 0xD0DDD530L, - 0x0417B1DBL, 0xF67C32D8L, 0xE52CC12CL, 0x1747422FL, - 0x49547E0BL, 0xBB3FFD08L, 0xA86F0EFCL, 0x5A048DFFL, - 0x8ECEE914L, 0x7CA56A17L, 0x6FF599E3L, 0x9D9E1AE0L, - 0xD3D3E1ABL, 0x21B862A8L, 0x32E8915CL, 0xC083125FL, - 0x144976B4L, 0xE622F5B7L, 0xF5720643L, 0x07198540L, - 0x590AB964L, 0xAB613A67L, 0xB831C993L, 0x4A5A4A90L, - 0x9E902E7BL, 0x6CFBAD78L, 0x7FAB5E8CL, 0x8DC0DD8FL, - 0xE330A81AL, 0x115B2B19L, 0x020BD8EDL, 0xF0605BEEL, - 0x24AA3F05L, 0xD6C1BC06L, 0xC5914FF2L, 0x37FACCF1L, - 0x69E9F0D5L, 0x9B8273D6L, 0x88D28022L, 0x7AB90321L, - 0xAE7367CAL, 0x5C18E4C9L, 0x4F48173DL, 0xBD23943EL, - 0xF36E6F75L, 0x0105EC76L, 0x12551F82L, 0xE03E9C81L, - 0x34F4F86AL, 0xC69F7B69L, 0xD5CF889DL, 0x27A40B9EL, - 0x79B737BAL, 0x8BDCB4B9L, 0x988C474DL, 0x6AE7C44EL, - 0xBE2DA0A5L, 0x4C4623A6L, 0x5F16D052L, 0xAD7D5351L, - }; - - for (i=0; i>8) & 0xff; - byte2 = (result>>16) & 0xff; - byte3 = (result>>24) & 0xff; - - crc32 = ((byte0 << 24) | (byte1 << 16) | (byte2 << 8) | byte3); - return ( crc32 ); -} - - -/*----------------------------------------------------------------------------*/ -void _zrtp_packet_insert_crc(char* packet, uint32_t length) -{ - uint32_t crc32; - uint32_t* packet_crc = (uint32_t*) (packet + length - 4); /* Last 4 bytes contain CRC */ - - *packet_crc = 0L; - crc32 = zrtp_generate_crc((const uint8_t*)packet, length-4); - *packet_crc = zrtp_hton32(crc32); -} - - -/*----------------------------------------------------------------------------*/ -int8_t _zrtp_packet_validate_crc(const char* packet, uint32_t length) -{ - ZRTP_UNALIGNED(uint32_t)*packet_crc = 0; - uint32_t original_crc32 = 0L; - uint32_t crc32 = 0L; - - packet_crc = (uint32_t*) (packet + length - 4); /* Last 4 bytes contain CRC */ - original_crc32 = zrtp_ntoh32(*packet_crc); - *packet_crc = 0L; - crc32 = zrtp_generate_crc((const uint8_t*)packet, length-4); - *packet_crc = zrtp_hton32(original_crc32); - - return !(original_crc32 == crc32); -} diff --git a/libs/libzrtp/src/zrtp_crypto_aes.c b/libs/libzrtp/src/zrtp_crypto_aes.c deleted file mode 100644 index f6058fd90e..0000000000 --- a/libs/libzrtp/src/zrtp_crypto_aes.c +++ /dev/null @@ -1,833 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - * Vitaly Rozhkov - */ - -#include "zrtp.h" - -#define _ZTU_ "zrtp cipher" - -typedef struct zrtp_aes_cfb_ctx { - uint8_t mode; - aes_encrypt_ctx aes_ctx[1]; - zrtp_v128_t iv; -} zrtp_aes_cfb_ctx_t; - -typedef struct zrtp_aes_ctr_ctx { - uint8_t mode; - aes_encrypt_ctx aes_ctx[1]; - zrtp_v128_t salt; - zrtp_v128_t counter; -}zrtp_aes_ctr_ctx_t; - - -/*===========================================================================*/ -/* Global AES functions */ -/*===========================================================================*/ - -/*---------------------------------------------------------------------------*/ -zrtp_status_t zrtp_aes_cfb_stop(zrtp_cipher_t *self, void *cipher_ctx) { - zrtp_memset(cipher_ctx, 0, sizeof(zrtp_aes_cfb_ctx_t)); - zrtp_sys_free(cipher_ctx); - return zrtp_status_ok; -} - -zrtp_status_t zrtp_aes_ctr_stop(zrtp_cipher_t *self, void *cipher_ctx) { - zrtp_memset(cipher_ctx, 0, sizeof(zrtp_aes_ctr_ctx_t)); - zrtp_sys_free(cipher_ctx); - return zrtp_status_ok; -} - -zrtp_status_t zrtp_aes_stop(zrtp_cipher_t *self, void *cipher_ctx) -{ - zrtp_status_t res; - zrtp_cipher_mode_t *mode = (zrtp_cipher_mode_t*)cipher_ctx; - switch (mode->mode) { - case ZRTP_CIPHER_MODE_CTR: - res = zrtp_aes_ctr_stop(self, cipher_ctx); - break; - case ZRTP_CIPHER_MODE_CFB: - res = zrtp_aes_cfb_stop(self, cipher_ctx); - break; - default: - res = zrtp_status_bad_param; - break; - } - return res; -} - -/*---------------------------------------------------------------------------*/ -zrtp_status_t zrtp_aes_cfb_set_iv(zrtp_cipher_t *self, void* cipher_ctx, zrtp_v128_t *iv) -{ - zrtp_aes_cfb_ctx_t* ctx = (zrtp_aes_cfb_ctx_t*)cipher_ctx; - zrtp_memcpy(&ctx->iv, iv, sizeof(zrtp_v128_t)); - - /* clear previous context except the first byte (key length) */ - zrtp_bg_aes_mode_reset(ctx->aes_ctx); - return zrtp_status_ok; -} - -zrtp_status_t zrtp_aes_ctr_set_iv(zrtp_cipher_t *self, void *cipher_ctx, zrtp_v128_t *iv ) -{ - zrtp_aes_ctr_ctx_t* ctx = (zrtp_aes_ctr_ctx_t*)cipher_ctx; - zrtp_v128_xor(&ctx->counter, &ctx->salt, iv); - - /* clear previous context except the first byte (key length) */ - zrtp_bg_aes_mode_reset(ctx->aes_ctx); - return zrtp_status_ok; -} - -zrtp_status_t zrtp_aes_set_iv(zrtp_cipher_t *self, void *cipher_ctx, zrtp_v128_t *iv ) -{ - zrtp_status_t res; - zrtp_cipher_mode_t *mode = (zrtp_cipher_mode_t*)cipher_ctx; - - switch (mode->mode) { - case ZRTP_CIPHER_MODE_CTR: - res = zrtp_aes_ctr_set_iv(self, cipher_ctx, iv); - break; - case ZRTP_CIPHER_MODE_CFB: - res = zrtp_aes_cfb_set_iv(self, cipher_ctx, iv); - break; - default: - res = zrtp_status_bad_param; - break; - } - return res; -} - -/*---------------------------------------------------------------------------*/ -zrtp_status_t zrtp_aes_cfb_encrypt( zrtp_cipher_t *self, - void* cipher_ctx, - unsigned char *buf, - int len) { - zrtp_aes_cfb_ctx_t* ctx = (zrtp_aes_cfb_ctx_t*)cipher_ctx; - AES_RETURN res = zrtp_bg_aes_cfb_encrypt(buf, buf, len, ctx->iv.v8, ctx->aes_ctx); - - return (EXIT_SUCCESS == res) ? zrtp_status_ok : zrtp_status_cipher_fail; -} - -void zrtp_aes_ctr_inc(unsigned char *counter) { - if(!(++counter[15])) { - ++counter[14]; - } -} - -zrtp_status_t zrtp_aes_ctr_encrypt( zrtp_cipher_t *self, - void *cipher_ctx, - unsigned char *buf, - int len ) { - zrtp_aes_ctr_ctx_t* ctx = (zrtp_aes_ctr_ctx_t*)cipher_ctx; - AES_RETURN res = zrtp_bg_aes_ctr_crypt(buf, buf, len, ctx->counter.v8, zrtp_aes_ctr_inc, ctx->aes_ctx); - - return (EXIT_SUCCESS == res) ? zrtp_status_ok : zrtp_status_cipher_fail; -} - -zrtp_status_t zrtp_aes_encrypt( zrtp_cipher_t *self, - void *cipher_ctx, - unsigned char *buf, - int len) -{ - zrtp_status_t res; - zrtp_cipher_mode_t* mode = (zrtp_cipher_mode_t*)cipher_ctx; - switch (mode->mode) { - case ZRTP_CIPHER_MODE_CTR: - res = zrtp_aes_ctr_encrypt(self, cipher_ctx, buf, len); - break; - case ZRTP_CIPHER_MODE_CFB: - res = zrtp_aes_cfb_encrypt(self, cipher_ctx, buf, len); - break; - default: - res = zrtp_status_bad_param; - break; - } - return res; -} - -/*---------------------------------------------------------------------------*/ -zrtp_status_t zrtp_aes_cfb_decrypt( zrtp_cipher_t *self, - void* cipher_ctx, - unsigned char *buf, - int len) { - zrtp_aes_cfb_ctx_t* ctx = (zrtp_aes_cfb_ctx_t*)cipher_ctx; - AES_RETURN res = zrtp_bg_aes_cfb_decrypt(buf, buf, len, ctx->iv.v8, ctx->aes_ctx); - - return (EXIT_SUCCESS == res) ? zrtp_status_ok : zrtp_status_cipher_fail; -} - -zrtp_status_t zrtp_aes_ctr_decrypt( zrtp_cipher_t *self, - void *cipher_ctx, - unsigned char *buf, - int len) { - zrtp_aes_ctr_ctx_t* ctx = (zrtp_aes_ctr_ctx_t*)cipher_ctx; - - AES_RETURN res = zrtp_bg_aes_ctr_crypt(buf, buf, len, ctx->counter.v8, zrtp_aes_ctr_inc, ctx->aes_ctx); - return (EXIT_SUCCESS == res) ? zrtp_status_ok : zrtp_status_cipher_fail; -} - -zrtp_status_t zrtp_aes_decrypt( zrtp_cipher_t *self, - void *cipher_ctx, - unsigned char *buf, - int len) -{ - zrtp_status_t res; - zrtp_cipher_mode_t *mode = (zrtp_cipher_mode_t*)cipher_ctx; - - switch(mode->mode){ - case ZRTP_CIPHER_MODE_CTR: - res = zrtp_aes_ctr_decrypt(self, cipher_ctx, buf, len); - break; - case ZRTP_CIPHER_MODE_CFB: - res = zrtp_aes_cfb_decrypt(self, cipher_ctx, buf, len); - break; - default: - res = zrtp_status_bad_param; - break; - } - return res; -} - - -/*===========================================================================*/ -/* AES 128 implementation */ -/*===========================================================================*/ - -/*---------------------------------------------------------------------------*/ -void *zrtp_aes_cfb128_start(zrtp_cipher_t *self, void *key, void *extra_data) -{ - zrtp_aes_cfb_ctx_t *cipher_ctx = zrtp_sys_alloc(sizeof(zrtp_aes_cfb_ctx_t)); - if(NULL == cipher_ctx) { - return NULL; - } - cipher_ctx->mode = ZRTP_CIPHER_MODE_CFB; - zrtp_bg_aes_encrypt_key128(((zrtp_v128_t*)key)->v8, cipher_ctx->aes_ctx); - - return cipher_ctx; -} - - -void *zrtp_aes_ctr128_start( zrtp_cipher_t *self, void *key, void *extra_data) -{ - zrtp_aes_ctr_ctx_t *cipher_ctx = zrtp_sys_alloc(sizeof(zrtp_aes_ctr_ctx_t)); - if(NULL == cipher_ctx) { - return NULL; - } - - cipher_ctx->mode = ZRTP_CIPHER_MODE_CTR; - zrtp_memcpy(&cipher_ctx->salt, extra_data, sizeof(zrtp_v128_t)-2); - cipher_ctx->salt.v8[14] = cipher_ctx->salt.v8[15] =0; - - zrtp_memset(&cipher_ctx->counter, 0, sizeof(zrtp_v128_t)); - zrtp_bg_aes_encrypt_key128(((zrtp_v128_t*)key)->v8, cipher_ctx->aes_ctx); - - return cipher_ctx; -} - -void *zrtp_aes128_start( zrtp_cipher_t *self, void *key, void *extra_data, uint8_t mode) -{ - void *ctx; - switch (mode) { - case ZRTP_CIPHER_MODE_CTR: - ctx = zrtp_aes_ctr128_start(self, key, extra_data); - break; - case ZRTP_CIPHER_MODE_CFB: - ctx = zrtp_aes_cfb128_start(self, key, extra_data); - break; - default: - ctx = NULL; - break; - }; - return ctx; -} - -/*---------------------------------------------------------------------------*/ -/* Global CFB Test-Vectors */ -static uint8_t aes_cfb_test_key[32] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f -}; - -static uint8_t aes_cfb_test_iv[16] = { - 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, - 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff -}; - -static uint8_t aes_cfb_test_buf1a[50] = { - 0x69, 0xc4, 0xe0, 0xd8, 0x6a, 0x7b, 0x04, 0x30, - 0xd8, 0xcd, 0xb7, 0x80, 0x70, 0xb4, 0xc5, 0x5a -}; - -static uint8_t aes_cfb_test_buf1b[50]; -//static uint8_t aes_cfb_test_buf1c[50]; - -static uint8_t aes_cfb_test_buf2a[50] = { - 0x8e, 0xa2, 0xb7, 0xca, 0x51, 0x67, 0x45, 0xbf, - 0xea, 0xfc, 0x49, 0x90, 0x4b, 0x49, 0x60, 0x89 -}; - -static uint8_t aes_cfb_test_buf2b[50]; - -static uint8_t aes_cfb_test_key3[32]; -static uint8_t aes_cfb_test_iv3[16]; -static uint8_t aes_cfb_test_buf3a[50]; - -static uint8_t aes_cfb_test_buf3b[50] = { - 0x66, 0xe9, 0x4b, 0xd4, 0xef, 0x8a, 0x2c, 0x3b, - 0x88, 0x4c, 0xfa, 0x59, 0xca, 0x34, 0x2b, 0x2e, - 0xf7, 0x95, 0xbd, 0x4a, 0x52, 0xe2, 0x9e, 0xd7, - 0x13, 0xd3, 0x13, 0xfa, 0x20, 0xe9, 0x8d, 0xbc, - 0xa1, 0x0c, 0xf6, 0x6d, 0x0f, 0xdd, 0xf3, 0x40, - 0x53, 0x70, 0xb4, 0xbf, 0x8d, 0xf5, 0xbf, 0xb3, - 0x47, 0xc7 -}; - -uint8_t aes_cfb_test_buf3c[50] = { - 0xdc, 0x95, 0xc0, 0x78, 0xa2, 0x40, 0x89, 0x89, - 0xad, 0x48, 0xa2, 0x14, 0x92, 0x84, 0x20, 0x87, - 0x08, 0xc3, 0x74, 0x84, 0x8c, 0x22, 0x82, 0x33, - 0xc2, 0xb3, 0x4f, 0x33, 0x2b, 0xd2, 0xe9, 0xd3, - 0x8b, 0x70, 0xc5, 0x15, 0xa6, 0x66, 0x3d, 0x38, - 0xcd, 0xb8, 0xe6, 0x53, 0x2b, 0x26, 0x64, 0x91, - 0x5d, 0x0d -}; - -/* Global CTR Test-Vectors */ -uint8_t aes_ctr_test_nonce[16] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - -/* 258-bit AES CTR Test-Vectors */ -uint8_t aes_ctr_test_key256[48] = { - 0x00, 0x01, 0x02, 0x03, 0x05, 0x06, 0x07, 0x08, - 0x0A, 0x0B, 0x0C, 0x0D, 0x0F, 0x10, 0x11, 0x12, - 0x14, 0x15, 0x16, 0x17, 0x19, 0x1A, 0x1B, 0x1C, - 0x1E, 0x1F, 0x20, 0x21, 0x23, 0x24, 0x25, 0x26, - 0x83, 0x4E, 0xAD, 0xFC, 0xCA, 0xC7, 0xE1, 0xB3, - 0x06, 0x64, 0xB1, 0xAB, 0xA4, 0x48, 0x15, 0xAB -}; - -uint8_t aes_ctr_test_plaintext256[16] = { - 0x83, 0x4E, 0xAD, 0xFC, 0xCA, 0xC7, 0xE1, 0xB3, - 0x06, 0x64, 0xB1, 0xAB, 0xA4, 0x48, 0x15, 0xAB -}; - -uint8_t aes_ctr_test_ciphertext256[16] = { - 0x5d, 0x8e, 0xfd, 0xe6, 0x69, 0x62, 0xbf, 0x49, - 0xda, 0xe2, 0xea, 0xcf, 0x0b, 0x69, 0xe4, 0xf6 -}; - -/* 128-bit AES CFB Test-Vectors */ -uint8_t aes_ctr_test_key128[32] = { -0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, -0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c, -0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, -0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0x00, 0x00 -}; - -uint8_t aes_ctr_test_plaintext128[32] = { -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - -uint8_t aes_ctr_test_ciphertext128[32] = { -0xe0, 0x3e, 0xad, 0x09, 0x35, 0xc9, 0x5e, 0x80, -0xe1, 0x66, 0xb1, 0x6d, 0xd9, 0x2b, 0x4e, 0xb4, -0xd2, 0x35, 0x13, 0x16, 0x2b, 0x02, 0xd0, 0xf7, -0x2a, 0x43, 0xa2, 0xfe, 0x4a, 0x5f, 0x97, 0xab -}; - - -zrtp_status_t zrtp_aes_cfb128_self_test(zrtp_cipher_t *self) -{ - - zrtp_status_t err = zrtp_status_fail; - int i = 0; - zrtp_v128_t tmp_iv; - zrtp_aes_cfb_ctx_t *ctx = (zrtp_aes_cfb_ctx_t*)self->start( self, - aes_cfb_test_key, - NULL, - ZRTP_CIPHER_MODE_CFB); - if(NULL == ctx) { - return zrtp_status_fail; - } - - ZRTP_LOG(3, (_ZTU_,"128 bit AES CFB\n")); - ZRTP_LOG(3, (_ZTU_,"1st test...\n")); - - zrtp_memcpy(aes_cfb_test_buf1b, aes_cfb_test_buf1a, sizeof(aes_cfb_test_buf1a)); - zrtp_memcpy(&tmp_iv, aes_cfb_test_iv, sizeof(aes_cfb_test_iv)); - self->set_iv(self, ctx, &tmp_iv); - - ZRTP_LOG(3, (_ZTU_,"\tencryption... ")); - - err = self->encrypt(self, ctx, aes_cfb_test_buf1b, sizeof(aes_cfb_test_buf1b)); - if (zrtp_status_ok != err) { - ZRTP_LOGC(1, ("ERROR! 128-bit AES CFB encrypt returns error %d\n", err)); - self->stop(self, ctx); - return err; - } - - for (i=0; i<16; i++) { - if (aes_cfb_test_buf1b[i] != 0x00) { - ZRTP_LOGC(1, ("ERROR! 128-bit AES CFB failed on encrypt test")); - self->stop(self, ctx); - return zrtp_status_fail; - } - } - ZRTP_LOGC(3, ("OK\n")); - - ZRTP_LOG(3, (_ZTU_,"\tdecryption... ")); - - zrtp_memcpy(&tmp_iv, aes_cfb_test_iv, sizeof(aes_cfb_test_iv)); - - self->set_iv(self, ctx, &tmp_iv); - err = self->decrypt(self, ctx, aes_cfb_test_buf1b, sizeof(aes_cfb_test_buf1b)); - if (zrtp_status_ok != err) { - ZRTP_LOGC(3, ("ERROR! 128-bit AES CFB decrypt returns error %d\n", err)); - self->stop(self, ctx); - return err; - } - - for (i=0; istop(self, ctx); - return zrtp_status_fail; - } - } - self->stop(self, ctx); - ZRTP_LOGC(3, ("OK\n")); - - ZRTP_LOG(3, (_ZTU_, "2nd test...\n")); - - ctx = self->start(self, aes_cfb_test_key3, NULL, ZRTP_CIPHER_MODE_CFB); - if (NULL == ctx) { - return zrtp_status_fail; - } - - ZRTP_LOG(3, (_ZTU_, "\tencryption... ")); - - zrtp_memcpy(&tmp_iv, aes_cfb_test_iv3, sizeof(tmp_iv)); - self->set_iv(self, ctx, &tmp_iv); - - err = self->encrypt(self, ctx, aes_cfb_test_buf3a, sizeof(aes_cfb_test_buf3a)); - if (zrtp_status_ok != err) { - ZRTP_LOGC(1, ("ERROR! 128-bit AES CFB encrypt returns error %d\n", err)); - self->stop(self, ctx); - return err; - } - - for (i=0; istop(self, ctx); - return zrtp_status_fail; - } - } - ZRTP_LOGC(3, ("OK\n")); - - ZRTP_LOG(3, (_ZTU_, "\tdecryption... ")); - zrtp_memcpy(&tmp_iv, aes_cfb_test_iv3, sizeof(tmp_iv)); - self->set_iv(self, ctx, &tmp_iv); - - err = self->decrypt(self, ctx, aes_cfb_test_buf3b, sizeof(aes_cfb_test_buf3b)); - if (zrtp_status_ok != err) { - ZRTP_LOGC(1, ("ERROR! 128-bit AES CFB decrypt returns error %d\n", err)); - self->stop(self, ctx); - return err; - } - - for (i=0; istop(self, ctx); - return zrtp_status_fail; - } - } - ZRTP_LOGC(3, ("OK\n")); - - self->stop(self, ctx); - return zrtp_status_ok; -} - -zrtp_status_t zrtp_aes_ctr128_self_test(zrtp_cipher_t *self) -{ - uint8_t tmp_buf[32]; - zrtp_status_t err = zrtp_status_fail; - int i; - - zrtp_aes_ctr_ctx_t *ctx = (zrtp_aes_ctr_ctx_t*)self->start( self, - aes_ctr_test_key128, - aes_ctr_test_key128+16, - ZRTP_CIPHER_MODE_CTR); - - if (NULL == ctx) { - return zrtp_status_fail; - } - - ZRTP_LOG(3, (_ZTU_,"128 bit AES CTR\n")); - ZRTP_LOG(3, (_ZTU_, "1st test...\n")); - - ZRTP_LOG(3, (_ZTU_, "\tencryption... ")); - - self->set_iv(self, ctx, (zrtp_v128_t*)aes_ctr_test_nonce); - - zrtp_memcpy(tmp_buf, aes_ctr_test_plaintext128, sizeof(tmp_buf)); - err = self->encrypt(self, ctx, tmp_buf, sizeof(tmp_buf)); - if (zrtp_status_ok != err) { - ZRTP_LOGC(1, ("ERROR! 128-bit encrypt returns error %d\n", err)); - self->stop(self, ctx); - return zrtp_status_fail; - } - - for (i=0; istop(self, ctx); - return err; - } - } - ZRTP_LOGC(3, ("OK\n")); - - ZRTP_LOG(3, (_ZTU_, "\tdecryption...")); - - self->set_iv(self, ctx, (zrtp_v128_t*)aes_ctr_test_nonce); - - err = self->decrypt(self, ctx, tmp_buf, sizeof(tmp_buf)); - if (zrtp_status_ok != err) { - ZRTP_LOGC(1, ("ERROR! 128-bit AES CTR decrypt returns error %d\n", err)); - self->stop(self, ctx); - return err; - } - - for (i=0; istop(self, ctx); - return zrtp_status_fail; - } - } - self->stop(self, ctx); - ZRTP_LOGC(3, ("OK\n")); - - return zrtp_status_ok; -} - -zrtp_status_t zrtp_aes128_self_test(zrtp_cipher_t *self, uint8_t mode) -{ - zrtp_status_t res; - switch(mode){ - case ZRTP_CIPHER_MODE_CTR: - res = zrtp_aes_ctr128_self_test(self); - break; - case ZRTP_CIPHER_MODE_CFB: - res = zrtp_aes_cfb128_self_test(self); - break; - default: - res = zrtp_status_bad_param; - break; - } - return res; -} - -/*===========================================================================*/ -/* AES 256 implementation */ -/*===========================================================================*/ - -/*---------------------------------------------------------------------------*/ -void *zrtp_aes_cfb256_start(zrtp_cipher_t *self, void *key, void *extra_data) -{ - zrtp_aes_cfb_ctx_t *cipher_ctx = zrtp_sys_alloc(sizeof(zrtp_aes_cfb_ctx_t)); - if(NULL == cipher_ctx) { - return NULL; - } - - cipher_ctx->mode = ZRTP_CIPHER_MODE_CFB; - zrtp_bg_aes_encrypt_key256(((zrtp_v256_t*)key)->v8, cipher_ctx->aes_ctx); - return cipher_ctx; -} - -void *zrtp_aes_ctr256_start(zrtp_cipher_t *self, void *key, void *extra_data) -{ - zrtp_aes_ctr_ctx_t *cipher_ctx = zrtp_sys_alloc(sizeof(zrtp_aes_ctr_ctx_t)); - if(NULL == cipher_ctx) { - return NULL; - } - - cipher_ctx->mode = ZRTP_CIPHER_MODE_CTR; - zrtp_memcpy(&cipher_ctx->salt, extra_data, sizeof(zrtp_v128_t)-2); - cipher_ctx->salt.v8[14] = cipher_ctx->salt.v8[15] =0; - - zrtp_memset(&cipher_ctx->counter, 0, sizeof(zrtp_v128_t)); - - zrtp_bg_aes_encrypt_key256(((zrtp_v256_t*)key)->v8, cipher_ctx->aes_ctx); - - return cipher_ctx; -} - -void *zrtp_aes256_start(zrtp_cipher_t *self, void *key, void *extra_data, uint8_t mode) -{ - void *ctx = NULL; - switch (mode) { - case ZRTP_CIPHER_MODE_CTR: - ctx = zrtp_aes_ctr256_start(self, key, extra_data); - break; - case ZRTP_CIPHER_MODE_CFB: - ctx = zrtp_aes_cfb256_start(self, key, extra_data); - break; - default: - ctx = NULL; - break; - } - return ctx; -} - -/*---------------------------------------------------------------------------*/ -zrtp_status_t zrtp_aes_cfb256_self_test(zrtp_cipher_t *self) -{ - zrtp_status_t err; - int i; - zrtp_v128_t tmp_iv; - - zrtp_aes_cfb_ctx_t *ctx = (zrtp_aes_cfb_ctx_t*)self->start( self, - aes_cfb_test_key, - NULL, - ZRTP_CIPHER_MODE_CFB); - if (NULL == ctx) { - return zrtp_status_fail; - } - - ZRTP_LOG(3, (_ZTU_,"256 bit AES CFB\n")); - ZRTP_LOG(3, (_ZTU_, "1st test...\n")); - - zrtp_memcpy(aes_cfb_test_buf2b, aes_cfb_test_buf2a, sizeof(aes_cfb_test_buf2a)); - zrtp_memcpy(&tmp_iv, aes_cfb_test_iv, sizeof(tmp_iv)); - - ZRTP_LOG(3, (_ZTU_, "\tencryption... ")); - - self->set_iv(self, ctx, &tmp_iv); - err = self->encrypt(self, ctx, aes_cfb_test_buf2b, sizeof(aes_cfb_test_buf2b)); - if (zrtp_status_ok != err) { - ZRTP_LOGC(1, ("ERROR! 256-bit AES CFB encrypt returns error %d\n", err)); - self->stop(self, ctx); - return err; - } - - for (i=0; i<16; i++) { - if (aes_cfb_test_buf2b[i] != 0x00) { - ZRTP_LOGC(1, ("ERROR! 256-bit AES CFB failed on encrypt test\n")); - self->stop(self, ctx); - return zrtp_status_fail; - } - } - ZRTP_LOGC(3, ("OK\n")); - - ZRTP_LOG(3, (_ZTU_, "\tdecryption... ")); - - zrtp_memcpy(&tmp_iv, aes_cfb_test_iv, sizeof(tmp_iv)); - self->set_iv(self, ctx, &tmp_iv); - - err = self->decrypt(self, ctx, aes_cfb_test_buf2b, sizeof(aes_cfb_test_buf2b)); - if (zrtp_status_ok != err) { - ZRTP_LOGC(1, ("ERROR! 256-bit AES CFB decrypt returns error %d\n", err)); - self->stop(self, ctx); - return err; - } - for (i=0; istop(self, ctx); - return zrtp_status_fail; - } - } - self->stop(self, ctx); - ZRTP_LOGC(3, ("OK\n")); - - ZRTP_LOG(3, (_ZTU_, "2nd test...\n")); - - ctx = self->start(self, aes_cfb_test_key3, NULL, ZRTP_CIPHER_MODE_CFB); - if(NULL == ctx){ - return zrtp_status_fail; - } - - ZRTP_LOG(3, (_ZTU_, "\tencryption...")); - - zrtp_memset (aes_cfb_test_buf3a, 0, sizeof(aes_cfb_test_buf3a)); - zrtp_memcpy(&tmp_iv, aes_cfb_test_iv3, sizeof(tmp_iv)); - - self->set_iv(self, ctx, &tmp_iv); - err = self->encrypt(self, ctx, aes_cfb_test_buf3a, sizeof(aes_cfb_test_buf3a)); - if (zrtp_status_ok != err) { - ZRTP_LOGC(1, ("ERROR! 256-bit AES CFB encrypt returns error %d\n", err)); - self->stop(self, ctx); - return err; - } - - for (i=0; istop(self, ctx); - return zrtp_status_fail; - } - } - ZRTP_LOGC(3, ("OK\n")); - - ZRTP_LOG(3, (_ZTU_, "\tdecryption...")); - - zrtp_memcpy(&tmp_iv, aes_cfb_test_iv3, sizeof(tmp_iv)); - self->set_iv(self, ctx, &tmp_iv); - - err = self->decrypt(self, ctx, aes_cfb_test_buf3c, sizeof(aes_cfb_test_buf3c)); - if (zrtp_status_ok != err) { - ZRTP_LOGC(1, ("ERROR! 256-bit AES CFB decrypt returns error %d\n", err)); - self->stop(self, ctx); - return err; - } - - for (i=0; istop(self, ctx); - return zrtp_status_fail; - } - } - self->stop(self, ctx); - ZRTP_LOGC(3, ("OK\n")); - - return zrtp_status_ok; -} - -zrtp_status_t zrtp_aes_ctr256_self_test(zrtp_cipher_t *self) -{ - uint8_t tmp_buf[32]; - zrtp_status_t err = zrtp_status_fail; - int i; - - zrtp_aes_ctr_ctx_t *ctx = (zrtp_aes_ctr_ctx_t*)self->start( self, - aes_ctr_test_key256, - aes_ctr_test_key256+32, - ZRTP_CIPHER_MODE_CTR); - if (NULL == ctx) { - return zrtp_status_fail; - } - - ZRTP_LOG(3, (_ZTU_,"256 bit AES CTR\n")); - ZRTP_LOG(3, (_ZTU_, "1st test...\n")); - - ZRTP_LOG(3, (_ZTU_, "\tencryption... ")); - - self->set_iv(self, ctx, (zrtp_v128_t*)aes_ctr_test_nonce); - - zrtp_memcpy(tmp_buf, aes_ctr_test_plaintext256, sizeof(aes_ctr_test_plaintext256)); - err = self->encrypt(self, ctx, tmp_buf, sizeof(aes_ctr_test_plaintext256)); - if (zrtp_status_ok != err) { - ZRTP_LOGC(1, ("ERROR! 256-bit encrypt returns error %d\n", err)); - self->stop(self, ctx); - return zrtp_status_fail; - } - - for (i=0; istop(self, ctx); - return err; - } - } - - ZRTP_LOGC(3, ("OK\n")); - - ZRTP_LOG(3, (_ZTU_, "\tdecryption...")); - - self->set_iv(self, ctx, (zrtp_v128_t*)aes_ctr_test_nonce); - - err = self->decrypt(self, ctx, tmp_buf, sizeof(tmp_buf)); - if (zrtp_status_ok != err) { - ZRTP_LOGC(1, ("ERROR! 256-bit AES CTR decrypt returns error %d\n", err)); - self->stop(self, ctx); - return err; - } - - for (i=0; istop(self, ctx); - return zrtp_status_fail; - } - } - self->stop(self, ctx); - ZRTP_LOGC(3, ("OK\n")); - - return zrtp_status_ok; -} - -zrtp_status_t zrtp_aes256_self_test(zrtp_cipher_t *self, uint8_t mode) -{ - zrtp_status_t res; - switch (mode) { - case ZRTP_CIPHER_MODE_CTR: - res = zrtp_aes_ctr256_self_test(self); - break; - case ZRTP_CIPHER_MODE_CFB: - res = zrtp_aes_cfb256_self_test(self); - break; - default: - res = zrtp_status_bad_param; - break; - } - return res; -} - - -/*---------------------------------------------------------------------------*/ -zrtp_status_t zrtp_defaults_aes_cipher(zrtp_global_t* global_ctx) -{ - zrtp_cipher_t* cipher_aes128 = zrtp_sys_alloc(sizeof(zrtp_cipher_t)); - zrtp_cipher_t* cipher_aes256 = zrtp_sys_alloc(sizeof(zrtp_cipher_t)); - if (!cipher_aes128 || !cipher_aes256) { - if (cipher_aes128) { - zrtp_sys_free(cipher_aes128); - } - if (cipher_aes256) { - zrtp_sys_free(cipher_aes256); - } - return zrtp_status_alloc_fail; - } - - zrtp_memset(cipher_aes128, 0, sizeof(zrtp_cipher_t)); - zrtp_memset(cipher_aes256, 0, sizeof(zrtp_cipher_t)); - - zrtp_memcpy(cipher_aes128->base.type, ZRTP_AES1, ZRTP_COMP_TYPE_SIZE); - cipher_aes128->base.id = ZRTP_CIPHER_AES128; - cipher_aes128->base.zrtp = global_ctx; - cipher_aes128->start = zrtp_aes128_start; - cipher_aes128->set_iv = zrtp_aes_set_iv; - cipher_aes128->encrypt = zrtp_aes_encrypt; - cipher_aes128->decrypt = zrtp_aes_decrypt; - cipher_aes128->self_test = zrtp_aes128_self_test; - cipher_aes128->stop = zrtp_aes_stop; - - zrtp_memcpy(cipher_aes256->base.type, ZRTP_AES3, ZRTP_COMP_TYPE_SIZE); - cipher_aes256->base.id = ZRTP_CIPHER_AES256; - cipher_aes256->base.zrtp = global_ctx; - cipher_aes256->start = zrtp_aes256_start; - cipher_aes256->set_iv = zrtp_aes_set_iv; - cipher_aes256->encrypt = zrtp_aes_encrypt; - cipher_aes256->decrypt = zrtp_aes_decrypt; - cipher_aes256->self_test = zrtp_aes256_self_test; - cipher_aes256->stop = zrtp_aes_stop; - - zrtp_comp_register(ZRTP_CC_CIPHER, cipher_aes128, global_ctx); - zrtp_comp_register(ZRTP_CC_CIPHER, cipher_aes256, global_ctx); - - return zrtp_status_ok; -} diff --git a/libs/libzrtp/src/zrtp_crypto_atl.c b/libs/libzrtp/src/zrtp_crypto_atl.c deleted file mode 100644 index 790a11006f..0000000000 --- a/libs/libzrtp/src/zrtp_crypto_atl.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - -#include "zrtp.h" - - -/*============================================================================*/ -/* SRTP Auth Tag Length support */ -/*============================================================================*/ - -zrtp_status_t zrtp_defaults_atl(zrtp_global_t* global_ctx) -{ - zrtp_auth_tag_length_t* atl32 = zrtp_sys_alloc(sizeof(zrtp_auth_tag_length_t)); - zrtp_auth_tag_length_t* atl80 = zrtp_sys_alloc(sizeof(zrtp_auth_tag_length_t)); - - if (!atl32 || !atl80) { - if(atl32) zrtp_sys_free(atl32); - if(atl80) zrtp_sys_free(atl80); - return zrtp_status_alloc_fail; - } - - zrtp_memset(atl32, 0, sizeof(zrtp_auth_tag_length_t)); - zrtp_memcpy(atl32->base.type, ZRTP_HS32, ZRTP_COMP_TYPE_SIZE); - atl32->base.id = ZRTP_ATL_HS32; - atl32->base.zrtp = global_ctx; - atl32->tag_length = 4; - - zrtp_memset(atl80, 0, sizeof(zrtp_auth_tag_length_t)); - zrtp_memcpy(atl80->base.type, ZRTP_HS80, ZRTP_COMP_TYPE_SIZE); - atl80->base.id = ZRTP_ATL_HS80; - atl80->base.zrtp = global_ctx; - atl80->tag_length = 10; - - zrtp_comp_register(ZRTP_CC_ATL, atl32, global_ctx); - zrtp_comp_register(ZRTP_CC_ATL, atl80, global_ctx); - - return zrtp_status_ok; -} diff --git a/libs/libzrtp/src/zrtp_crypto_ec.c b/libs/libzrtp/src/zrtp_crypto_ec.c deleted file mode 100644 index 6a7fd2907d..0000000000 --- a/libs/libzrtp/src/zrtp_crypto_ec.c +++ /dev/null @@ -1,461 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - */ - -#include "zrtp.h" - -/* Size of extra random data to approximate a uniform distribution mod n */ -#define UNIFORMBYTES 8 - - -/*============================================================================*/ -/* Bignum Shorthand Functions */ -/*============================================================================*/ - -int bnAddMod_ (struct BigNum *rslt, struct BigNum *n1, struct BigNum *mod) -{ - bnAdd (rslt, n1); - if (bnCmp (rslt, mod) >= 0) { - bnSub (rslt, mod); - } - return 0; -} - -int bnAddQMod_ (struct BigNum *rslt, unsigned n1, struct BigNum *mod) -{ - bnAddQ (rslt, n1); - if (bnCmp (rslt, mod) >= 0) { - bnSub (rslt, mod); - } - return 0; -} - -int bnSubMod_ (struct BigNum *rslt, struct BigNum *n1, struct BigNum *mod) -{ - if (bnCmp (rslt, n1) < 0) { - bnAdd (rslt, mod); - } - bnSub (rslt, n1); - return 0; -} - -int bnSubQMod_ (struct BigNum *rslt, unsigned n1, struct BigNum *mod) -{ - if (bnCmpQ (rslt, n1) < 0) { - bnAdd (rslt, mod); - } - bnSubQ (rslt, n1); - return 0; -} - -int bnMulMod_ (struct BigNum *rslt, struct BigNum *n1, struct BigNum *n2, struct BigNum *mod) -{ - bnMul (rslt, n1, n2); - bnMod (rslt, rslt, mod); - return 0; -} - -int bnMulQMod_ (struct BigNum *rslt, struct BigNum *n1, unsigned n2, struct BigNum *mod) -{ - bnMulQ (rslt, n1, n2); - bnMod (rslt, rslt, mod); - return 0; -} - -int bnSquareMod_ (struct BigNum *rslt, struct BigNum *n1, struct BigNum *mod) -{ - bnSquare (rslt, n1); - bnMod (rslt, rslt, mod); - return 0; -} - - -/*============================================================================*/ -/* Elliptic Curve arithmetic */ -/*============================================================================*/ - -/* Add two elliptic curve points. Any of them may be the same object. */ -int zrtp_ecAdd ( struct BigNum *rsltx, struct BigNum *rslty, - struct BigNum *p1x, struct BigNum *p1y, - struct BigNum *p2x, struct BigNum *p2y, struct BigNum *mod) -{ - struct BigNum trsltx, trslty; - struct BigNum t1, gam; - struct BigNum bnzero; - - bnBegin (&bnzero); - - /* Check for an operand being zero */ - if (bnCmp (p1x, &bnzero) == 0 && bnCmp (p1y, &bnzero) == 0) { - bnCopy (rsltx, p2x); bnCopy (rslty, p2y); - bnEnd (&bnzero); - return 0; - } - if (bnCmp (p2x, &bnzero) == 0 && bnCmp (p2y, &bnzero) == 0) { - bnCopy (rsltx, p1x); bnCopy (rslty, p1y); - bnEnd (&bnzero); - return 0; - } - - /* Check if p1 == -p2 and return 0 if so */ - if (bnCmp (p1x, p2x) == 0) { - struct BigNum tsum; - bnBegin (&tsum); - bnCopy (&tsum, p1x); - bnAddMod_ (&tsum, p2x, mod); - if (bnCmp (&tsum, &bnzero) == 0) { - bnSetQ (rsltx, 0); bnSetQ (rslty, 0); - bnEnd (&tsum); - bnEnd (&bnzero); - return 0; - } - bnEnd (&tsum); - } - - bnBegin (&t1); - bnBegin (&gam); - bnBegin (&trsltx); - bnBegin (&trslty); - - /* Check for doubling, different formula for gamma */ - if (bnCmp (p1x, p2x) == 0 && bnCmp (p1y, p2y) == 0) { - bnCopy (&t1, p1y); - bnAddMod_ (&t1, p1y, mod); - bnInv (&t1, &t1, mod); - bnSquareMod_ (&gam, p1x, mod); - bnMulQMod_ (&gam, &gam, 3, mod); - bnSubQMod_ (&gam, 3, mod); - bnMulMod_ (&gam, &gam, &t1, mod); - } else { - bnCopy (&t1, p2x); - bnSubMod_ (&t1, p1x, mod); - bnInv (&t1, &t1, mod); - bnCopy (&gam, p2y); - bnSubMod_ (&gam, p1y, mod); - bnMulMod_ (&gam, &gam, &t1, mod); - } - - bnSquareMod_ (&trsltx, &gam, mod); - bnSubMod_ (&trsltx, p1x, mod); - bnSubMod_ (&trsltx, p2x, mod); - - bnCopy (&trslty, p1x); - bnSubMod_ (&trslty, &trsltx, mod); - bnMulMod_ (&trslty, &trslty, &gam, mod); - bnSubMod_ (&trslty, p1y, mod); - - bnCopy (rsltx, &trsltx); - bnCopy (rslty, &trslty); - - bnEnd (&t1); - bnEnd (&gam); - bnEnd (&trsltx); - bnEnd (&trslty); - bnEnd (&bnzero); - - return 0; -} - -int zrtp_ecMul ( struct BigNum *rsltx, struct BigNum *rslty, struct BigNum *mult, - struct BigNum *basex, struct BigNum *basey, struct BigNum *mod) -{ - struct BigNum bnzero; - struct BigNum tbasex, tbasey; - struct BigNum trsltx, trslty; - struct BigNum tmult; - - bnBegin (&bnzero); - bnBegin (&tbasex); - bnBegin (&tbasey); - bnBegin (&trsltx); - bnBegin (&trslty); - bnBegin (&tmult); - - /* Initialize result to 0 before additions */ - bnSetQ (&trsltx, 0); - bnSetQ (&trslty, 0); - /* Make copies of base and multiplier */ - bnCopy (&tbasex, basex); - bnCopy (&tbasey, basey); - bnCopy (&tmult, mult); - while (bnCmp (&tmult, &bnzero) > 0) { - /* Test lsb of mult */ - unsigned lsw = bnLSWord (&tmult); - if (lsw & 1) { - /* Add base to result */ - zrtp_ecAdd (&trsltx, &trslty, &trsltx, &trslty, &tbasex, &tbasey, mod); - } - /* Double the base */ - zrtp_ecAdd (&tbasex, &tbasey, &tbasex, &tbasey, &tbasex, &tbasey, mod); - /* Shift multiplier right */ - bnRShift (&tmult, 1); - } - - bnCopy (rsltx, &trsltx); - bnCopy (rslty, &trslty); - - bnEnd (&bnzero); - bnEnd (&tbasex); - bnEnd (&tbasey); - bnEnd (&trsltx); - bnEnd (&trslty); - bnEnd (&tmult); - return 0; -} - - - -/*----------------------------------------------------------------------------*/ -/* Choose a random point on the elliptic curve. */ -/* Provision is made to use a given point from test vectors. */ -/* pkx and pky are the output point, sv is output discrete log */ -/* Input base is Gx, Gy; curve field modulus is P; curve order is n. */ -/*----------------------------------------------------------------------------*/ -zrtp_status_t zrtp_ec_random_point( zrtp_global_t *zrtp, - struct BigNum *P, - struct BigNum *n, - struct BigNum *Gx, - struct BigNum *Gy, - struct BigNum *pkx, - struct BigNum *pky, - struct BigNum *sv, - uint8_t *test_sv_data, - size_t test_sv_data_len) -{ - zrtp_status_t s = zrtp_status_fail; - unsigned char* buffer = zrtp_sys_alloc(sizeof(zrtp_uchar1024_t)); - - if (!buffer) { - return zrtp_status_alloc_fail; - } - zrtp_memset(buffer, 0, sizeof(zrtp_uchar1024_t)); - - do - { - if (test_sv_data_len != 0) { - /* Force certain secret value */ - if (bnBytes(P) != test_sv_data_len) { - break; - } - zrtp_memcpy(buffer+UNIFORMBYTES, test_sv_data, test_sv_data_len); - } else { - /* Choose random value, larger than needed so it will be uniform */ - if (bnBytes(P)+UNIFORMBYTES != (uint32_t)zrtp_randstr(zrtp, buffer, bnBytes(P)+UNIFORMBYTES)) { - break; /* if we can't generate random string - fail initialization */ - } - } - - bnInsertBigBytes(sv, (const unsigned char *)buffer, 0, bnBytes(P)+UNIFORMBYTES); - bnMod(sv, sv, n); - zrtp_ecMul(pkx, pky, sv, Gx, Gy, P); - - s = zrtp_status_ok; - } while (0); - - if (buffer) { - zrtp_sys_free(buffer); - } - - return s; -} - - -/*============================================================================*/ -/* Curve parameters */ -/*============================================================================*/ - -uint8_t P_256_data[] = -{ - 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF -}; - -uint8_t n_256_data[] = -{ - 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xBC, 0xE6, 0xFA, 0xAD, 0xA7, 0x17, 0x9E, 0x84, - 0xF3, 0xB9, 0xCA, 0xC2, 0xFC, 0x63, 0x25, 0x51 -}; - -uint8_t b_256_data[] = -{ - 0x5a, 0xc6, 0x35, 0xd8, 0xaa, 0x3a, 0x93, 0xe7, - 0xb3, 0xeb, 0xbd, 0x55, 0x76, 0x98, 0x86, 0xbc, - 0x65, 0x1d, 0x06, 0xb0, 0xcc, 0x53, 0xb0, 0xf6, - 0x3b, 0xce, 0x3c, 0x3e, 0x27, 0xd2, 0x60, 0x4b -}; - -uint8_t Gx_256_data[] = -{ - 0x6b, 0x17, 0xd1, 0xf2, 0xe1, 0x2c, 0x42, 0x47, - 0xf8, 0xbc, 0xe6, 0xe5, 0x63, 0xa4, 0x40, 0xf2, - 0x77, 0x03, 0x7d, 0x81, 0x2d, 0xeb, 0x33, 0xa0, - 0xf4, 0xa1, 0x39, 0x45, 0xd8, 0x98, 0xc2, 0x96 -}; - -uint8_t Gy_256_data[] = -{ - 0x4f, 0xe3, 0x42, 0xe2, 0xfe, 0x1a, 0x7f, 0x9b, - 0x8e, 0xe7, 0xeb, 0x4a, 0x7c, 0x0f, 0x9e, 0x16, - 0x2b, 0xce, 0x33, 0x57, 0x6b, 0x31, 0x5e, 0xce, - 0xcb, 0xb6, 0x40, 0x68, 0x37, 0xbf, 0x51, 0xf5 -}; - - - -uint8_t P_384_data[] = -{ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, - 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF -}; - -uint8_t n_384_data[] = -{ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xC7, 0x63, 0x4D, 0x81, 0xF4, 0x37, 0x2D, 0xDF, - 0x58, 0x1A, 0x0D, 0xB2, 0x48, 0xB0, 0xA7, 0x7A, - 0xEC, 0xEC, 0x19, 0x6A, 0xCC, 0xC5, 0x29, 0x73 -}; - -uint8_t b_384_data[] = -{ - 0xb3, 0x31, 0x2f, 0xa7, 0xe2, 0x3e, 0xe7, 0xe4, - 0x98, 0x8e, 0x05, 0x6b, 0xe3, 0xf8, 0x2d, 0x19, - 0x18, 0x1d, 0x9c, 0x6e, 0xfe, 0x81, 0x41, 0x12, - 0x03, 0x14, 0x08, 0x8f, 0x50, 0x13, 0x87, 0x5a, - 0xc6, 0x56, 0x39, 0x8d, 0x8a, 0x2e, 0xd1, 0x9d, - 0x2a, 0x85, 0xc8, 0xed, 0xd3, 0xec, 0x2a, 0xef -}; - -uint8_t Gx_384_data[] = -{ - 0xaa, 0x87, 0xca, 0x22, 0xbe, 0x8b, 0x05, 0x37, - 0x8e, 0xb1, 0xc7, 0x1e, 0xf3, 0x20, 0xad, 0x74, - 0x6e, 0x1d, 0x3b, 0x62, 0x8b, 0xa7, 0x9b, 0x98, - 0x59, 0xf7, 0x41, 0xe0, 0x82, 0x54, 0x2a, 0x38, - 0x55, 0x02, 0xf2, 0x5d, 0xbf, 0x55, 0x29, 0x6c, - 0x3a, 0x54, 0x5e, 0x38, 0x72, 0x76, 0x0a, 0xb7 -}; - -uint8_t Gy_384_data[] = -{ - 0x36, 0x17, 0xde, 0x4a, 0x96, 0x26, 0x2c, 0x6f, - 0x5d, 0x9e, 0x98, 0xbf, 0x92, 0x92, 0xdc, 0x29, - 0xf8, 0xf4, 0x1d, 0xbd, 0x28, 0x9a, 0x14, 0x7c, - 0xe9, 0xda, 0x31, 0x13, 0xb5, 0xf0, 0xb8, 0xc0, - 0x0a, 0x60, 0xb1, 0xce, 0x1d, 0x7e, 0x81, 0x9d, - 0x7a, 0x43, 0x1d, 0x7c, 0x90, 0xea, 0x0e, 0x5f -}; - - -uint8_t P_521_data[] = -{ - 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF -}; - -uint8_t n_521_data[] = -{ - 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFA, 0x51, 0x86, 0x87, 0x83, 0xBF, 0x2F, - 0x96, 0x6B, 0x7F, 0xCC, 0x01, 0x48, 0xF7, 0x09, - 0xA5, 0xD0, 0x3B, 0xB5, 0xC9, 0xB8, 0x89, 0x9C, - 0x47, 0xAE, 0xBB, 0x6F, 0xB7, 0x1E, 0x91, 0x38, - 0x64, 0x09 -}; - -uint8_t b_521_data[] = -{ - 0x00, 0x51, 0x95, 0x3e, 0xb9, 0x61, 0x8e, 0x1c, - 0x9a, 0x1f, 0x92, 0x9a, 0x21, 0xa0, 0xb6, 0x85, - 0x40, 0xee, 0xa2, 0xda, 0x72, 0x5b, 0x99, 0xb3, - 0x15, 0xf3, 0xb8, 0xb4, 0x89, 0x91, 0x8e, 0xf1, - 0x09, 0xe1, 0x56, 0x19, 0x39, 0x51, 0xec, 0x7e, - 0x93, 0x7b, 0x16, 0x52, 0xc0, 0xbd, 0x3b, 0xb1, - 0xbf, 0x07, 0x35, 0x73, 0xdf, 0x88, 0x3d, 0x2c, - 0x34, 0xf1, 0xef, 0x45, 0x1f, 0xd4, 0x6b, 0x50, - 0x3f, 0x00 -}; - -uint8_t Gx_521_data[] = -{ - 0x00, 0xc6, 0x85, 0x8e, 0x06, 0xb7, 0x04, 0x04, - 0xe9, 0xcd, 0x9e, 0x3e, 0xcb, 0x66, 0x23, 0x95, - 0xb4, 0x42, 0x9c, 0x64, 0x81, 0x39, 0x05, 0x3f, - 0xb5, 0x21, 0xf8, 0x28, 0xaf, 0x60, 0x6b, 0x4d, - 0x3d, 0xba, 0xa1, 0x4b, 0x5e, 0x77, 0xef, 0xe7, - 0x59, 0x28, 0xfe, 0x1d, 0xc1, 0x27, 0xa2, 0xff, - 0xa8, 0xde, 0x33, 0x48, 0xb3, 0xc1, 0x85, 0x6a, - 0x42, 0x9b, 0xf9, 0x7e, 0x7e, 0x31, 0xc2, 0xe5, - 0xbd, 0x66 -}; - -uint8_t Gy_521_data[] = -{ - 0x01, 0x18, 0x39, 0x29, 0x6a, 0x78, 0x9a, 0x3b, - 0xc0, 0x04, 0x5c, 0x8a, 0x5f, 0xb4, 0x2c, 0x7d, - 0x1b, 0xd9, 0x98, 0xf5, 0x44, 0x49, 0x57, 0x9b, - 0x44, 0x68, 0x17, 0xaf, 0xbd, 0x17, 0x27, 0x3e, - 0x66, 0x2c, 0x97, 0xee, 0x72, 0x99, 0x5e, 0xf4, - 0x26, 0x40, 0xc5, 0x50, 0xb9, 0x01, 0x3f, 0xad, - 0x07, 0x61, 0x35, 0x3c, 0x70, 0x86, 0xa2, 0x72, - 0xc2, 0x40, 0x88, 0xbe, 0x94, 0x76, 0x9f, 0xd1, - 0x66, 0x50 -}; - -/*----------------------------------------------------------------------------*/ -/* Initialize the curve parameters struct */ -zrtp_status_t zrtp_ec_init_params( struct zrtp_ec_params *params, uint32_t bits ) -{ - unsigned ec_bytes = (bits+7) / 8; - params->ec_bits = bits; - switch (bits) { - case 256: - zrtp_memcpy (params->P_data, P_256_data, ec_bytes); - zrtp_memcpy (params->n_data, n_256_data, ec_bytes); - zrtp_memcpy (params->b_data, b_256_data, ec_bytes); - zrtp_memcpy (params->Gx_data, Gx_256_data, ec_bytes); - zrtp_memcpy (params->Gy_data, Gy_256_data, ec_bytes); - break; - case 384: - zrtp_memcpy (params->P_data, P_384_data, ec_bytes); - zrtp_memcpy (params->n_data, n_384_data, ec_bytes); - zrtp_memcpy (params->b_data, b_384_data, ec_bytes); - zrtp_memcpy (params->Gx_data, Gx_384_data, ec_bytes); - zrtp_memcpy (params->Gy_data, Gy_384_data, ec_bytes); - break; - case 521: - zrtp_memcpy (params->P_data, P_521_data, ec_bytes); - zrtp_memcpy (params->n_data, n_521_data, ec_bytes); - zrtp_memcpy (params->b_data, b_521_data, ec_bytes); - zrtp_memcpy (params->Gx_data, Gx_521_data, ec_bytes); - zrtp_memcpy (params->Gy_data, Gy_521_data, ec_bytes); - break; - default: - return zrtp_status_bad_param; - } - - return zrtp_status_ok; -} diff --git a/libs/libzrtp/src/zrtp_crypto_ecdh.c b/libs/libzrtp/src/zrtp_crypto_ecdh.c deleted file mode 100644 index 7a47e6c474..0000000000 --- a/libs/libzrtp/src/zrtp_crypto_ecdh.c +++ /dev/null @@ -1,559 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - */ - -#include "zrtp.h" - - -#define _ZTU_ "zrtp ecdh" - -static unsigned get_pbits(zrtp_pk_scheme_t *self) -{ - switch (self->base.id) { - case ZRTP_PKTYPE_EC256P: - return 256; - break; - case ZRTP_PKTYPE_EC384P: - return 384; - break; - case ZRTP_PKTYPE_EC521P: - return 521; - break; - default: - return 0; - } -} - -/*============================================================================*/ -/* Shared Elliptic Curve functions */ -/* */ -/* The Elliptic Curve DH algorithm and key generation is from */ -/* NIST SP 800-56A. The curves used are from NSA Suite B, which */ -/* uses the same curves as ECDSA defined by FIPS 186-3, and are */ -/* also defined in RFC 4753, sections 3.1 through 3.3. */ -/* The validation procedures are from NIST SP 800-56A section 5.6.2.6, */ -/* method 3, ECC Partial Validation. */ -/*============================================================================*/ - - -/*----------------------------------------------------------------------------*/ -static zrtp_status_t zrtp_ecdh_init(void *s) { - return zrtp_status_ok; -} - -static zrtp_status_t zrtp_ecdh_free(void *s) { - return zrtp_status_ok; -} - - -/*----------------------------------------------------------------------------*/ -/* Return dh_cc->pv holding public value and dh_cc->sv holding secret value */ -/* The public value is an elliptic curve point encoded as the x part shifted */ -/* left Pbits bits and or'd with the y part. */ -/*----------------------------------------------------------------------------*/ -static zrtp_status_t zrtp_ecdh_initialize( zrtp_pk_scheme_t *self, - zrtp_dh_crypto_context_t *dh_cc) -{ - zrtp_status_t s = zrtp_status_fail; - struct BigNum P, Gx, Gy, n; - struct BigNum pkx, pky; - unsigned ec_bytes = 0; - unsigned pbits = 0; - struct zrtp_ec_params ec_params; - zrtp_time_t start_ts = zrtp_time_now(); - - if (!self || !dh_cc) { - return zrtp_status_bad_param; - } - - pbits = get_pbits(self); - if (!pbits) { - return zrtp_status_bad_param; - } - - zrtp_ec_init_params(&ec_params, pbits); - - ec_bytes = (ec_params.ec_bits+7) / 8; - - bnBegin(&P); - bnInsertBigBytes(&P, ec_params.P_data, 0, ec_bytes ); - bnBegin(&Gx); - bnInsertBigBytes(&Gx, ec_params.Gx_data, 0, ec_bytes ); - bnBegin(&Gy); - bnInsertBigBytes(&Gy, ec_params.Gy_data, 0, ec_bytes ); - bnBegin(&n); - bnInsertBigBytes(&n, ec_params.n_data, 0, ec_bytes ); - - bnBegin(&pkx); - bnBegin(&pky); - bnBegin(&dh_cc->sv); - s = zrtp_ec_random_point( self->base.zrtp, &P, &n, &Gx, &Gy, - &pkx, &pky, &dh_cc->sv, - NULL, 0); - - if (zrtp_status_ok == s) - { - bnBegin(&dh_cc->pv); - bnCopy (&dh_cc->pv, &pkx); - bnLShift (&dh_cc->pv, pbits); - bnAdd (&dh_cc->pv, &pky); - } - - bnEnd (&pkx); - bnEnd (&pky); - bnEnd (&P); - bnEnd (&Gx); - bnEnd (&Gy); - bnEnd (&n); - - ZRTP_LOG(1,(_ZTU_,"\tDH TEST: zrtp_ecdh_initialize() for %.4s was executed by %llums.\n", self->base.type, zrtp_time_now()-start_ts)); - return s; -} - - -/*----------------------------------------------------------------------------*/ -/* Compute the shared dhresult as the X coordinate of the EC point. */ -/*----------------------------------------------------------------------------*/ -static zrtp_status_t zrtp_ecdh_compute( zrtp_pk_scheme_t *self, - zrtp_dh_crypto_context_t *dh_cc, - struct BigNum *dhresult, - struct BigNum *pv) -{ - struct BigNum P; - struct BigNum pkx, pky, rsltx, rslty; - unsigned ec_bytes = 0; - unsigned pbits = 0; - struct zrtp_ec_params ec_params; - zrtp_time_t start_ts = zrtp_time_now(); - - if (!self || !dh_cc || !dhresult || !pv) { - return zrtp_status_bad_param; - } - - pbits = get_pbits(self); - if (!pbits) { - return zrtp_status_bad_param; - } - - zrtp_ec_init_params(&ec_params, pbits); - - ec_bytes = (ec_params.ec_bits+7) / 8; - - bnBegin(&P); - bnInsertBigBytes( &P, ec_params.P_data, 0, ec_bytes ); - - bnBegin (&pkx); - bnBegin (&pky); - bnBegin (&rsltx); - bnBegin (&rslty); - - bnSetQ (&pkx, 1); - bnLShift (&pkx, pbits); - bnMod (&pky, pv, &pkx); - bnCopy (&pkx, pv); - bnRShift (&pkx, pbits); - - zrtp_ecMul (&rsltx, &rslty, &dh_cc->sv, &pkx, &pky, &P); - bnCopy (dhresult, &rsltx); - - bnEnd (&pkx); - bnEnd (&pky); - bnEnd (&rsltx); - bnEnd (&rslty); - bnEnd (&P); - - ZRTP_LOG(1,(_ZTU_,"\tDH TEST: zrtp_ecdh_compute() for %.4s was executed by %llums.\n", self->base.type, zrtp_time_now()-start_ts)); - return zrtp_status_ok; -} - -/*----------------------------------------------------------------------------*/ -/* ECC Partial Validation per NIST SP800-56A section 5.6.2.6 */ -/*----------------------------------------------------------------------------*/ -static zrtp_status_t zrtp_ecdh_validate( zrtp_pk_scheme_t *self, - struct BigNum *pv) -{ - zrtp_status_t s = zrtp_status_fail; - struct BigNum P, b; - struct BigNum t1, t2; - struct BigNum pkx, pky, bnzero; - unsigned ec_bytes = 0; - unsigned pbits = 0; - struct zrtp_ec_params ec_params; - zrtp_time_t start_ts = zrtp_time_now(); - - if (!self || !pv) { - return zrtp_status_bad_param; - } - - pbits = get_pbits(self); - if (!pbits) { - return zrtp_status_bad_param; - } - - zrtp_ec_init_params(&ec_params, pbits); - - ec_bytes = (ec_params.ec_bits+7) / 8; - - bnBegin(&P); - bnInsertBigBytes( &P, ec_params.P_data, 0, ec_bytes ); - bnBegin(&b); - bnInsertBigBytes( &b, ec_params.b_data, 0, ec_bytes ); - - bnBegin (&t1); - bnBegin (&t2); - bnBegin (&pkx); - bnBegin (&pky); - bnBegin (&bnzero); - - bnSetQ (&pkx, 1); - bnLShift (&pkx, pbits); - bnMod (&pky, pv, &pkx); - bnCopy (&pkx, pv); - bnRShift (&pkx, pbits); - - do{ - /* Represent point at infinity by (0, 0), make sure it's not that */ - if (bnCmp (&pkx, &bnzero) == 0 && bnCmp (&pky, &bnzero) == 0) { - break; - } - /* Check coordinates within range */ - if (bnCmp (&pkx, &bnzero) < 0 || bnCmp (&pkx, &P) >= 0) { - break; - } - if (bnCmp (&pky, &bnzero) < 0 || bnCmp (&pky, &P) >= 0) { - break; - } - - /* Check that point satisfies EC equation y^2 = x^3 - 3x + b, mod P */ - bnSquareMod_ (&t1, &pky, &P); - bnSquareMod_ (&t2, &pkx, &P); - bnSubQMod_ (&t2, 3, &P); - bnMulMod_ (&t2, &t2, &pkx, &P); - bnAddMod_ (&t2, &b, &P); - if (bnCmp (&t1, &t2) != 0) { - break; - } - - s = zrtp_status_ok; - } while (0); - - bnEnd (&t1); - bnEnd (&t2); - bnEnd (&pkx); - bnEnd (&pky); - bnEnd (&bnzero); - bnEnd (&P); - bnEnd (&b); - - ZRTP_LOG(1,(_ZTU_,"\tDH TEST: zrtp_ecdh_validate() for %.4s was executed by %llums.\n", self->base.type, zrtp_time_now()-start_ts)); - return s; -} - - -/*============================================================================*/ -/* P-256, 384, 521 (FIPS 186-3) support. See RFC 4753 3.1, 3.2, 3.3 */ -/*============================================================================*/ - -static uint8_t sv256_data[] = { - 0x81, 0x42, 0x64, 0x14, 0x5F, 0x2F, 0x56, 0xF2, - 0xE9, 0x6A, 0x8E, 0x33, 0x7A, 0x12, 0x84, 0x99, - 0x3F, 0xAF, 0x43, 0x2A, 0x5A, 0xBC, 0xE5, 0x9E, - 0x86, 0x7B, 0x72, 0x91, 0xD5, 0x07, 0xA3, 0xAF -}; -static uint8_t pvx256_data[] = { - 0x2A, 0xF5, 0x02, 0xF3, 0xBE, 0x89, 0x52, 0xF2, - 0xC9, 0xB5, 0xA8, 0xD4, 0x16, 0x0D, 0x09, 0xE9, - 0x71, 0x65, 0xBE, 0x50, 0xBC, 0x42, 0xAE, 0x4A, - 0x5E, 0x8D, 0x3B, 0x4B, 0xA8, 0x3A, 0xEB, 0x15 -}; -static uint8_t pvy256_data[] = { - 0xEB, 0x0F, 0xAF, 0x4C, 0xA9, 0x86, 0xC4, 0xD3, - 0x86, 0x81, 0xA0, 0xF9, 0x87, 0x2D, 0x79, 0xD5, - 0x67, 0x95, 0xBD, 0x4B, 0xFF, 0x6E, 0x6D, 0xE3, - 0xC0, 0xF5, 0x01, 0x5E, 0xCE, 0x5E, 0xFD, 0x85 -}; - -static uint8_t sv384_data[] = { - 0xD2, 0x73, 0x35, 0xEA, 0x71, 0x66, 0x4A, 0xF2, - 0x44, 0xDD, 0x14, 0xE9, 0xFD, 0x12, 0x60, 0x71, - 0x5D, 0xFD, 0x8A, 0x79, 0x65, 0x57, 0x1C, 0x48, - 0xD7, 0x09, 0xEE, 0x7A, 0x79, 0x62, 0xA1, 0x56, - 0xD7, 0x06, 0xA9, 0x0C, 0xBC, 0xB5, 0xDF, 0x29, - 0x86, 0xF0, 0x5F, 0xEA, 0xDB, 0x93, 0x76, 0xF1 -}; -static uint8_t pvx384_data[] = { - 0x79, 0x31, 0x48, 0xF1, 0x78, 0x76, 0x34, 0xD5, - 0xDA, 0x4C, 0x6D, 0x90, 0x74, 0x41, 0x7D, 0x05, - 0xE0, 0x57, 0xAB, 0x62, 0xF8, 0x20, 0x54, 0xD1, - 0x0E, 0xE6, 0xB0, 0x40, 0x3D, 0x62, 0x79, 0x54, - 0x7E, 0x6A, 0x8E, 0xA9, 0xD1, 0xFD, 0x77, 0x42, - 0x7D, 0x01, 0x6F, 0xE2, 0x7A, 0x8B, 0x8C, 0x66 -}; -static uint8_t pvy384_data[] = { - 0xC6, 0xC4, 0x12, 0x94, 0x33, 0x1D, 0x23, 0xE6, - 0xF4, 0x80, 0xF4, 0xFB, 0x4C, 0xD4, 0x05, 0x04, - 0xC9, 0x47, 0x39, 0x2E, 0x94, 0xF4, 0xC3, 0xF0, - 0x6B, 0x8F, 0x39, 0x8B, 0xB2, 0x9E, 0x42, 0x36, - 0x8F, 0x7A, 0x68, 0x59, 0x23, 0xDE, 0x3B, 0x67, - 0xBA, 0xCE, 0xD2, 0x14, 0xA1, 0xA1, 0xD1, 0x28 -}; - -static uint8_t sv521_data[] = { - 0x01, 0x13, 0xF8, 0x2D, 0xA8, 0x25, 0x73, 0x5E, - 0x3D, 0x97, 0x27, 0x66, 0x83, 0xB2, 0xB7, 0x42, - 0x77, 0xBA, 0xD2, 0x73, 0x35, 0xEA, 0x71, 0x66, - 0x4A, 0xF2, 0x43, 0x0C, 0xC4, 0xF3, 0x34, 0x59, - 0xB9, 0x66, 0x9E, 0xE7, 0x8B, 0x3F, 0xFB, 0x9B, - 0x86, 0x83, 0x01, 0x5D, 0x34, 0x4D, 0xCB, 0xFE, - 0xF6, 0xFB, 0x9A, 0xF4, 0xC6, 0xC4, 0x70, 0xBE, - 0x25, 0x45, 0x16, 0xCD, 0x3C, 0x1A, 0x1F, 0xB4, - 0x73, 0x62 -}; -static uint8_t pvx521_data[] = { - 0x01, 0xEB, 0xB3, 0x4D, 0xD7, 0x57, 0x21, 0xAB, - 0xF8, 0xAD, 0xC9, 0xDB, 0xED, 0x17, 0x88, 0x9C, - 0xBB, 0x97, 0x65, 0xD9, 0x0A, 0x7C, 0x60, 0xF2, - 0xCE, 0xF0, 0x07, 0xBB, 0x0F, 0x2B, 0x26, 0xE1, - 0x48, 0x81, 0xFD, 0x44, 0x42, 0xE6, 0x89, 0xD6, - 0x1C, 0xB2, 0xDD, 0x04, 0x6E, 0xE3, 0x0E, 0x3F, - 0xFD, 0x20, 0xF9, 0xA4, 0x5B, 0xBD, 0xF6, 0x41, - 0x3D, 0x58, 0x3A, 0x2D, 0xBF, 0x59, 0x92, 0x4F, - 0xD3, 0x5C -}; -static uint8_t pvy521_data[] = { - 0x00, 0xF6, 0xB6, 0x32, 0xD1, 0x94, 0xC0, 0x38, - 0x8E, 0x22, 0xD8, 0x43, 0x7E, 0x55, 0x8C, 0x55, - 0x2A, 0xE1, 0x95, 0xAD, 0xFD, 0x15, 0x3F, 0x92, - 0xD7, 0x49, 0x08, 0x35, 0x1B, 0x2F, 0x8C, 0x4E, - 0xDA, 0x94, 0xED, 0xB0, 0x91, 0x6D, 0x1B, 0x53, - 0xC0, 0x20, 0xB5, 0xEE, 0xCA, 0xED, 0x1A, 0x5F, - 0xC3, 0x8A, 0x23, 0x3E, 0x48, 0x30, 0x58, 0x7B, - 0xB2, 0xEE, 0x34, 0x89, 0xB3, 0xB4, 0x2A, 0x5A, - 0x86, 0xA4 -}; - -zrtp_status_t zrtp_ecdh_selftest(zrtp_pk_scheme_t *self) -{ - zrtp_status_t s = zrtp_status_fail; - struct BigNum P, Gx, Gy, n, sv; - struct BigNum pkx, pky; - unsigned ec_bytes = 0; - unsigned pbits = 0; - struct zrtp_ec_params ec_params; - - zrtp_time_t start_ts = 0; - - uint8_t *sv_data = NULL; - size_t sv_data_len = 0; - uint8_t *pvx_data = NULL; - size_t pvx_data_len = 0; - uint8_t *pvy_data = NULL; - size_t pvy_data_len = 0; - - if (!self) { - return zrtp_status_bad_param; - } - - ZRTP_LOG(3, (_ZTU_, "PKS %.4s testing... ", self->base.type)); - - switch (self->base.id) { - case ZRTP_PKTYPE_EC256P: - sv_data = sv256_data; - sv_data_len = sizeof(sv256_data); - pvx_data = pvx256_data; - pvx_data_len = sizeof(pvx256_data); - pvy_data = pvy256_data; - pvy_data_len = sizeof(pvy256_data); - break; - case ZRTP_PKTYPE_EC384P: - sv_data = sv384_data; - sv_data_len = sizeof(sv384_data); - pvx_data = pvx384_data; - pvx_data_len = sizeof(pvx384_data); - pvy_data = pvy384_data; - pvy_data_len = sizeof(pvy384_data); - break; - case ZRTP_PKTYPE_EC521P: - sv_data = sv521_data; - sv_data_len = sizeof(sv521_data); - pvx_data = pvx521_data; - pvx_data_len = sizeof(pvx521_data); - pvy_data = pvy521_data; - pvy_data_len = sizeof(pvy521_data); - break; - default: - return 0; - } - - pbits = get_pbits(self); - if (!pbits) { - return zrtp_status_bad_param; - } - - zrtp_ec_init_params(&ec_params, pbits); - - ec_bytes = (ec_params.ec_bits+7) / 8; - - bnBegin(&P); - bnInsertBigBytes(&P, ec_params.P_data, 0, ec_bytes ); - bnBegin(&Gx); - bnInsertBigBytes(&Gx, ec_params.Gx_data, 0, ec_bytes ); - bnBegin(&Gy); - bnInsertBigBytes(&Gy, ec_params.Gy_data, 0, ec_bytes ); - bnBegin(&n); - bnInsertBigBytes(&n, ec_params.n_data, 0, ec_bytes ); - - bnBegin(&pkx); - bnBegin(&pky); - bnBegin(&sv); - s = zrtp_ec_random_point( self->base.zrtp, &P, &n, &Gx, &Gy, - &pkx, &pky, &sv, - sv_data, sv_data_len); - if (zrtp_status_ok == s) - { - struct BigNum pkx1, pky1; - - bnBegin(&pkx1); bnBegin(&pky1); - bnInsertBigBytes(&pkx1, pvx_data, 0, pvx_data_len); - bnInsertBigBytes(&pky1, pvy_data, 0, pvy_data_len); - s = (bnCmp (&pkx1, &pkx) == 0 && bnCmp (&pky1, &pky) == 0) ? zrtp_status_ok : zrtp_status_fail; - bnEnd(&pkx1); - bnEnd(&pky1); - } - - bnEnd (&pkx); - bnEnd (&pky); - bnEnd (&P); - bnEnd (&Gx); - bnEnd (&Gy); - bnEnd (&n); - bnEnd (&sv); - - if (zrtp_status_ok == s) { - zrtp_status_t s = zrtp_status_ok; - zrtp_dh_crypto_context_t alice_cc; - zrtp_dh_crypto_context_t bob_cc; - struct BigNum alice_k; - struct BigNum bob_k; - - start_ts = zrtp_time_now(); - - bnBegin(&alice_k); - bnBegin(&bob_k); - - do { - /* Both sides initalise DH schemes and compute secret and public values. */ - s = self->initialize(self, &alice_cc); - if (zrtp_status_ok != s) { - break; - } - s = self->initialize(self, &bob_cc); - if (zrtp_status_ok != s) { - break; - } - - /* Both sides validate public values. (to provide exact performance estimation) */ - s = self->validate(self, &bob_cc.pv); - if (zrtp_status_ok != s) { - break; - } - s = self->validate(self, &alice_cc.pv); - if (zrtp_status_ok != s) { - break; - } - - /* Compute secret keys and compare them. */ - s = self->compute(self, &alice_cc, &alice_k, &bob_cc.pv); - if (zrtp_status_ok != s) { - break; - } - s= self->compute(self, &bob_cc, &bob_k, &alice_cc.pv); - if (zrtp_status_ok != s) { - break; - } - - s = (0 == bnCmp(&alice_k, &bob_k)) ? zrtp_status_ok : zrtp_status_algo_fail; - } while (0); - - bnEnd(&alice_k); - bnEnd(&bob_k); - } - ZRTP_LOGC(3, ("%s (%llu ms)\n", zrtp_log_status2str(s), (zrtp_time_now()-start_ts)/2)); - - return s; -} - - -/*============================================================================*/ -/* Public Key support */ -/*============================================================================*/ - -/*----------------------------------------------------------------------------*/ -zrtp_status_t zrtp_defaults_ec_pkt(zrtp_global_t* zrtp) -{ - zrtp_pk_scheme_t* ec256p = zrtp_sys_alloc(sizeof(zrtp_pk_scheme_t)); - zrtp_pk_scheme_t* ec384p = zrtp_sys_alloc(sizeof(zrtp_pk_scheme_t)); - zrtp_pk_scheme_t* ec521p = zrtp_sys_alloc(sizeof(zrtp_pk_scheme_t)); - - if (!ec256p || !ec384p || !ec521p) { - if(ec256p) { - zrtp_sys_free(ec256p); - } - if(ec384p) { - zrtp_sys_free(ec384p); - } - if(ec521p) { - zrtp_sys_free(ec521p); - } - return zrtp_status_alloc_fail; - } - - zrtp_memset(ec256p, 0, sizeof(zrtp_pk_scheme_t)); - zrtp_memcpy(ec256p->base.type, ZRTP_EC256P, ZRTP_COMP_TYPE_SIZE); - ec256p->base.id = ZRTP_PKTYPE_EC256P; - ec256p->base.zrtp = zrtp; - ec256p->sv_length = 256/8; - ec256p->pv_length = 2*256/8; - ec256p->base.init = zrtp_ecdh_init; - ec256p->base.free = zrtp_ecdh_free; - ec256p->initialize = zrtp_ecdh_initialize; - ec256p->compute = zrtp_ecdh_compute; - ec256p->validate = zrtp_ecdh_validate; - ec256p->self_test = zrtp_ecdh_selftest; - - zrtp_memset(ec384p, 0, sizeof(zrtp_pk_scheme_t)); - zrtp_memcpy(ec384p->base.type, ZRTP_EC384P, ZRTP_COMP_TYPE_SIZE); - ec384p->base.id = ZRTP_PKTYPE_EC384P; - ec384p->base.zrtp = zrtp; - ec384p->sv_length = 384/8; - ec384p->pv_length = 2*384/8; - ec384p->base.init = zrtp_ecdh_init; - ec384p->base.free = zrtp_ecdh_free; - ec384p->initialize = zrtp_ecdh_initialize; - ec384p->compute = zrtp_ecdh_compute; - ec384p->validate = zrtp_ecdh_validate; - ec384p->self_test = zrtp_ecdh_selftest; - - - zrtp_memset(ec521p, 0, sizeof(zrtp_pk_scheme_t)); - zrtp_memcpy(ec521p->base.type, ZRTP_EC521P, ZRTP_COMP_TYPE_SIZE); - ec521p->base.id = ZRTP_PKTYPE_EC521P; - ec521p->base.zrtp = zrtp; - ec521p->sv_length = 528/8; - ec521p->pv_length = 2*528/8; - ec521p->base.init = zrtp_ecdh_init; - ec521p->base.free = zrtp_ecdh_free; - ec521p->initialize = zrtp_ecdh_initialize; - ec521p->compute = zrtp_ecdh_compute; - ec521p->validate = zrtp_ecdh_validate; - ec521p->self_test = zrtp_ecdh_selftest; - - zrtp_comp_register(ZRTP_CC_PKT, ec256p, zrtp); - zrtp_comp_register(ZRTP_CC_PKT, ec384p, zrtp); - zrtp_comp_register(ZRTP_CC_PKT, ec521p, zrtp); - - return zrtp_status_ok; -} diff --git a/libs/libzrtp/src/zrtp_crypto_ecdsa.c b/libs/libzrtp/src/zrtp_crypto_ecdsa.c deleted file mode 100644 index fc86f12d2a..0000000000 --- a/libs/libzrtp/src/zrtp_crypto_ecdsa.c +++ /dev/null @@ -1,642 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - */ - -#include "zrtp.h" - -/* We don't have digital signatures ready yet. */ -#if 0 - -/* Size of extra random data to approximate a uniform distribution mod n */ -#define UNIFORMBYTES 8 - -/*============================================================================*/ -/* Shared Elliptic Curve functions */ -/* */ -/* The Elliptic Curve DSA algorithm, key generation, and curves are */ -/* from FIPS 186-3. The curves used are */ -/* also defined in RFC 4753, sections 3.1 through 3.3. */ -/*============================================================================*/ - -/*----------------------------------------------------------------------------*/ -/* Return dsa_cc->pv holding public value and dsa_cc->sv holding secret value */ -/* The public value is an elliptic curve point encoded as the x part shifted */ -/* left Pbits bits and or'd with the y part. */ -/*----------------------------------------------------------------------------*/ -static zrtp_status_t ECDSA_keygen( struct zrtp_sig_scheme *self, - zrtp_dsa_crypto_context_t *dsa_cc, - zrtp_ec_params_t *ec_params, -#ifdef ZRTP_TEST_VECTORS - uint8_t *sv_data, size_t sv_data_len, - uint8_t *pvx_data, size_t pvx_data_len, - uint8_t *pvy_data, size_t pvy_data_len, -#endif - unsigned Pbits ) -{ - zrtp_status_t s = zrtp_status_fail; - struct BigNum P, Gx, Gy, n; - struct BigNum pkx, pky; - unsigned ec_bytes; - - if (!ec_params) - return zrtp_status_bad_param; - - ec_bytes = (ec_params->ec_bits+7) / 8; - - do - { - if (!self || !dsa_cc) - { - s = zrtp_status_bad_param; - break; - } - - bnBegin(&P); - bnInsertBigBytes( &P, ec_params->P_data, 0, ec_bytes ); - bnBegin(&Gx); - bnInsertBigBytes( &Gx, ec_params->Gx_data, 0, ec_bytes ); - bnBegin(&Gy); - bnInsertBigBytes( &Gy, ec_params->Gy_data, 0, ec_bytes ); - bnBegin(&n); - bnInsertBigBytes( &n, ec_params->n_data, 0, ec_bytes ); - - bnBegin(&pkx); - bnBegin(&pky); - bnBegin(&dsa_cc->sv); - s = zrtp_ec_random_point( self->base.zrtp_global, &P, &n, &Gx, &Gy, -#ifdef ZRTP_TEST_VECTORS - sv_data, sv_data_len, - pvx_data, pvx_data_len, - pvy_data, pvy_data_len, -#endif - &pkx, &pky, &dsa_cc->sv ); - if ( s != zrtp_status_ok ) - break; - s = zrtp_status_fail; - - bnBegin(&dsa_cc->pv); - bnCopy (&dsa_cc->pv, &pkx); - bnLShift (&dsa_cc->pv, Pbits); - bnAdd (&dsa_cc->pv, &pky); - bnEnd (&pkx); - bnEnd (&pky); - bnEnd (&P); - bnEnd (&Gx); - bnEnd (&Gy); - bnEnd (&n); - - s = zrtp_status_ok; - } while (0); - - return s; -} - - -/*----------------------------------------------------------------------------*/ -/* Sign the specified hash value - must be size matching the curve */ -/*----------------------------------------------------------------------------*/ -static zrtp_status_t ECDSA_sign( struct zrtp_sig_scheme *self, - zrtp_dsa_crypto_context_t *dsa_cc, - zrtp_ec_params_t *ec_params, -#ifdef ZRTP_TEST_VECTORS - uint8_t *k_data, size_t k_data_len, - uint8_t *rx_data, size_t rx_data_len, - uint8_t *ry_data, size_t ry_data_len, - uint8_t *s_data, size_t s_data_len, -#endif - uint8_t *hash, uint32_t hash_len, - struct BigNum *dsasig ) -{ - zrtp_status_t s = zrtp_status_fail; - struct BigNum P, Gx, Gy, n; - struct BigNum h, s1, k, rx, ry, kinv, pkx, pky; - unsigned ec_bytes; - - if (!ec_params) - return zrtp_status_bad_param; - - ec_bytes = (ec_params->ec_bits+7) / 8; - - do - { - if (!self || !dsa_cc) - { - s = zrtp_status_bad_param; - break; - } - - bnBegin(&P); - bnInsertBigBytes( &P, ec_params->P_data, 0, ec_bytes ); - bnBegin(&Gx); - bnInsertBigBytes( &Gx, ec_params->Gx_data, 0, ec_bytes ); - bnBegin(&Gy); - bnInsertBigBytes( &Gy, ec_params->Gy_data, 0, ec_bytes ); - bnBegin(&n); - bnInsertBigBytes( &n, ec_params->n_data, 0, ec_bytes ); - - /* Hash to bignum */ - bnBegin(&h); - bnInsertBigBytes( &h, hash, 0, hash_len ); - bnMod (&h, &h, &P); - - /* Unpack signing key */ - bnBegin(&pkx); - bnBegin(&pky); - bnSetQ (&pkx, 1); - bnLShift (&pkx, ec_bytes*8); - bnMod (&pky, &dsa_cc->pv, &pkx); - bnCopy (&pkx, &dsa_cc->pv); - bnRShift (&pkx, ec_bytes*8); - - /* Choose signature secret k value */ - bnBegin(&rx); - bnBegin(&ry); - bnBegin(&k); - s = zrtp_ec_random_point( self->base.zrtp_global, &P, &n, &Gx, &Gy, -#ifdef ZRTP_TEST_VECTORS - k_data, k_data_len, - rx_data, rx_data_len, - ry_data, ry_data_len, -#endif - &rx, &ry, &k ); - if ( s != zrtp_status_ok ) - break; - s = zrtp_status_fail; - -#ifndef ZRTP_TEST_VECTORS - /* For further randomness we are going to add the secret key to k */ - bnAddMod_ (&k, &dsa_cc->sv, &n); - zrtp_ecAdd (&rx, &ry, &rx, &ry, &pkx, &pky, &P); -#endif - - /* Perform the signature */ - bnBegin (&s1); - bnMulMod_ (&s1, &rx, &dsa_cc->sv, &n); - bnAddMod_ (&s1, &h, &n); - bnBegin (&kinv); - bnInv (&kinv, &k, &n); - bnMulMod_ (&s1, &s1, &kinv, &n); - -#ifdef ZRTP_TEST_VECTORS - if (k_data_len != 0) - { - /* rx is checked in ec_random_point */ - struct BigNum s2; - int ok; - bnBegin(&s2); - bnInsertBigBytes(&s2, s_data, 0, s_data_len); - ok = (bnCmp (&s1, &s2) == 0); - bnEnd(&s2); - if (!ok) - break; - } -#endif - - /* Combine r, s into dsasig */ - bnBegin(dsasig); - bnCopy (dsasig, &rx); - bnLShift (dsasig, ec_bytes*8); - bnAdd (dsasig, &s1); - bnEnd (&rx); - bnEnd (&ry); - bnEnd (&k); - bnEnd (&kinv); - bnEnd (&s1); - bnEnd (&h); - bnEnd (&pkx); - bnEnd (&pky); - bnEnd (&P); - bnEnd (&Gx); - bnEnd (&Gy); - bnEnd (&n); - - s = zrtp_status_ok; - } while (0); - - return s; -} - - -/*----------------------------------------------------------------------------*/ -/* Verify a signature value - hash must be size matching the curve */ -/* Signing key should be in peer_pv entry of dsa_cc */ -/*----------------------------------------------------------------------------*/ -static zrtp_status_t ECDSA_verify( struct zrtp_sig_scheme *self, - zrtp_dsa_crypto_context_t *dsa_cc, - zrtp_ec_params_t *ec_params, - uint8_t *hash, uint32_t hash_len, - struct BigNum *dsasig ) -{ - zrtp_status_t s = zrtp_status_fail; - struct BigNum P, Gx, Gy, n; - struct BigNum rx, ry, pkx, pky, r, s1, sinv, u1, u2, u1x, u2x, u1y, u2y, h; - unsigned ec_bytes; - - if (!ec_params) - return zrtp_status_bad_param; - - ec_bytes = (ec_params->ec_bits+7) / 8; - - do - { - if (!self || !dsa_cc) - { - s = zrtp_status_bad_param; - break; - } - - bnBegin(&P); - bnInsertBigBytes( &P, ec_params->P_data, 0, ec_bytes ); - bnBegin(&Gx); - bnInsertBigBytes( &Gx, ec_params->Gx_data, 0, ec_bytes ); - bnBegin(&Gy); - bnInsertBigBytes( &Gy, ec_params->Gy_data, 0, ec_bytes ); - bnBegin(&n); - bnInsertBigBytes( &n, ec_params->n_data, 0, ec_bytes ); - - /* hash */ - bnBegin(&h); - bnInsertBigBytes( &h, hash, 0, hash_len ); - bnMod (&h, &h, &P); - - /* Unpack sig */ - bnBegin(&r); - bnBegin(&s1); - bnSetQ (&r, 1); - bnLShift (&r, ec_bytes*8); - bnMod (&s1, dsasig, &r); - bnCopy (&r, dsasig); - bnRShift (&r, ec_bytes*8); - - /* Unpack signing key */ - bnBegin(&pkx); - bnBegin(&pky); - bnSetQ (&pkx, 1); - bnLShift (&pkx, ec_bytes*8); - bnMod (&pky, &dsa_cc->peer_pv, &pkx); - bnCopy (&pkx, &dsa_cc->peer_pv); - bnRShift (&pkx, ec_bytes*8); - - /* Verify signature */ - bnBegin (&sinv); - bnInv (&sinv, &s1, &n); - bnBegin (&u1); - bnBegin (&u2); - bnMulMod_ (&u1, &sinv, &h, &n); - bnMulMod_ (&u2, &sinv, &r, &n); - - bnBegin (&u1x); - bnBegin (&u1y); - bnBegin (&u2x); - bnBegin (&u2y); - bnBegin (&rx); - bnBegin (&ry); - zrtp_ecMul (&u1x, &u1y, &u1, &Gx, &Gy, &P); - zrtp_ecMul (&u2x, &u2y, &u2, &pkx, &pky, &P); - zrtp_ecAdd (&rx, &ry, &u1x, &u1y, &u2x, &u2y, &P); - - if (bnCmp (&rx, &r) == 0) { - s = zrtp_status_ok; - } else { - s = zrtp_status_fail; - } - - /* Clean up */ - bnEnd (&rx); - bnEnd (&ry); - bnEnd (&r); - bnEnd (&s1); - bnEnd (&sinv); - bnEnd (&u1); - bnEnd (&u1x); - bnEnd (&u1y); - bnEnd (&u2); - bnEnd (&u2x); - bnEnd (&u2y); - bnEnd (&h); - bnEnd (&pkx); - bnEnd (&pky); - bnEnd (&P); - bnEnd (&Gx); - bnEnd (&Gy); - bnEnd (&n); - - } while (0); - - return s; -} - - - -/*----------------------------------------------------------------------------*/ -static zrtp_status_t EC_dummy(void *s) -{ - return zrtp_status_ok; -} - - -/*============================================================================*/ -/* P-256 (FIPS 186-3) support. See RFC 4753, section 3.1. */ -/*============================================================================*/ - -/* Test vectors from RFC4754 */ -#ifdef ZRTP_TEST_VECTORS -static uint8_t sv256_data[] = { - 0xDC, 0x51, 0xD3, 0x86, 0x6A, 0x15, 0xBA, 0xCD, - 0xE3, 0x3D, 0x96, 0xF9, 0x92, 0xFC, 0xA9, 0x9D, - 0xA7, 0xE6, 0xEF, 0x09, 0x34, 0xE7, 0x09, 0x75, - 0x59, 0xC2, 0x7F, 0x16, 0x14, 0xC8, 0x8A, 0x7F, -}; -static uint8_t pvx256_data[] = { - 0x24, 0x42, 0xA5, 0xCC, 0x0E, 0xCD, 0x01, 0x5F, - 0xA3, 0xCA, 0x31, 0xDC, 0x8E, 0x2B, 0xBC, 0x70, - 0xBF, 0x42, 0xD6, 0x0C, 0xBC, 0xA2, 0x00, 0x85, - 0xE0, 0x82, 0x2C, 0xB0, 0x42, 0x35, 0xE9, 0x70, -}; -static uint8_t pvy256_data[] = { - 0x6F, 0xC9, 0x8B, 0xD7, 0xE5, 0x02, 0x11, 0xA4, - 0xA2, 0x71, 0x02, 0xFA, 0x35, 0x49, 0xDF, 0x79, - 0xEB, 0xCB, 0x4B, 0xF2, 0x46, 0xB8, 0x09, 0x45, - 0xCD, 0xDF, 0xE7, 0xD5, 0x09, 0xBB, 0xFD, 0x7D, -}; - -static uint8_t k256_data[] = { - 0x9E, 0x56, 0xF5, 0x09, 0x19, 0x67, 0x84, 0xD9, - 0x63, 0xD1, 0xC0, 0xA4, 0x01, 0x51, 0x0E, 0xE7, - 0xAD, 0xA3, 0xDC, 0xC5, 0xDE, 0xE0, 0x4B, 0x15, - 0x4B, 0xF6, 0x1A, 0xF1, 0xD5, 0xA6, 0xDE, 0xCE, -}; -static uint8_t rx256_data[] = { - 0xCB, 0x28, 0xE0, 0x99, 0x9B, 0x9C, 0x77, 0x15, - 0xFD, 0x0A, 0x80, 0xD8, 0xE4, 0x7A, 0x77, 0x07, - 0x97, 0x16, 0xCB, 0xBF, 0x91, 0x7D, 0xD7, 0x2E, - 0x97, 0x56, 0x6E, 0xA1, 0xC0, 0x66, 0x95, 0x7C, -}; -static uint8_t ry256_data[] = { - 0x2B, 0x57, 0xC0, 0x23, 0x5F, 0xB7, 0x48, 0x97, - 0x68, 0xD0, 0x58, 0xFF, 0x49, 0x11, 0xC2, 0x0F, - 0xDB, 0xE7, 0x1E, 0x36, 0x99, 0xD9, 0x13, 0x39, - 0xAF, 0xBB, 0x90, 0x3E, 0xE1, 0x72, 0x55, 0xDC, -}; - -static uint8_t h256_data[] = { - 0xBA, 0x78, 0x16, 0xBF, 0x8F, 0x01, 0xCF, 0xEA, - 0x41, 0x41, 0x40, 0xDE, 0x5D, 0xAE, 0x22, 0x23, - 0xB0, 0x03, 0x61, 0xA3, 0x96, 0x17, 0x7A, 0x9C, - 0xB4, 0x10, 0xFF, 0x61, 0xF2, 0x00, 0x15, 0xAD, -}; -static uint8_t s256_data[] = { - 0x86, 0xFA, 0x3B, 0xB4, 0xE2, 0x6C, 0xAD, 0x5B, - 0xF9, 0x0B, 0x7F, 0x81, 0x89, 0x92, 0x56, 0xCE, - 0x75, 0x94, 0xBB, 0x1E, 0xA0, 0xC8, 0x92, 0x12, - 0x74, 0x8B, 0xFF, 0x3B, 0x3D, 0x5B, 0x03, 0x15, -}; - - -#endif - -/*----------------------------------------------------------------------------*/ -/* Return dsa_cc->pv holding public value and dsa_cc->sv holding secret value */ -/* The public value is an elliptic curve point encoded as the x part shifted */ -/* left 256 bits and or'd with the y part. */ -/*----------------------------------------------------------------------------*/ -static zrtp_status_t EC256P_keygen( struct zrtp_sig_scheme *self, - zrtp_dsa_crypto_context_t *dsa_cc ) -{ - struct zrtp_ec_params params; - zrtp_ec_init_params(¶ms, 256); - return ECDSA_keygen(self, dsa_cc, ¶ms, -#ifdef ZRTP_TEST_VECTORS - sv256_data, sizeof(sv256_data), - pvx256_data, sizeof(pvx256_data), - pvy256_data, sizeof(pvy256_data), -#endif - 256); -} - - -/*----------------------------------------------------------------------------*/ -/* Sign the specified hash value */ -/*----------------------------------------------------------------------------*/ -static zrtp_status_t EC256P_sign( struct zrtp_sig_scheme *self, - zrtp_dsa_crypto_context_t *dsa_cc, - uint8_t *hash, uint32_t hash_len, - struct BigNum *dsasig ) -{ - struct zrtp_ec_params params; - zrtp_ec_init_params(¶ms, 256); - return ECDSA_sign(self, dsa_cc, ¶ms, -#ifdef ZRTP_TEST_VECTORS - k256_data, sizeof(k256_data), - rx256_data, sizeof(rx256_data), - ry256_data, sizeof(ry256_data), - s256_data, sizeof(s256_data), - h256_data, sizeof(h256_data), -#else - hash, hash_len, -#endif - dsasig); -} - - -/*----------------------------------------------------------------------------*/ -/* Verify the signature on the hash value */ -/*----------------------------------------------------------------------------*/ -static zrtp_status_t EC256P_verify(struct zrtp_sig_scheme *self, - zrtp_dsa_crypto_context_t *dsa_cc, - uint8_t *hash, uint32_t hash_len, - struct BigNum *dsasig ) -{ - struct zrtp_ec_params params; - zrtp_ec_init_params(¶ms, 256); - return ECDSA_verify(self, dsa_cc, ¶ms, -#ifdef ZRTP_TEST_VECTORS - h256_data, sizeof(h256_data), -#else - hash, hash_len, -#endif - dsasig); -} - - - -/*============================================================================*/ -/* P-384 (FIPS 186-3) support. See RFC 4753, section 3.2. */ -/*============================================================================*/ - - - -/*----------------------------------------------------------------------------*/ -/* Return dsa_cc->pv holding public value and dsa_cc->sv holding secret value */ -/* The public value is an elliptic curve point encoded as the x part shifted */ -/* left 384 bits and or'd with the y part. */ -/*----------------------------------------------------------------------------*/ -static zrtp_status_t EC384P_keygen( struct zrtp_sig_scheme *self, - zrtp_dsa_crypto_context_t *dsa_cc ) -{ - struct zrtp_ec_params params; - zrtp_ec_init_params(¶ms, 384); - return ECDSA_keygen(self, dsa_cc, ¶ms, -#ifdef ZRTP_TEST_VECTORS - 0, 0, 0, 0, 0, 0, -#endif - 384); -} - - -/*----------------------------------------------------------------------------*/ -/* Sign the specified hash value */ -/*----------------------------------------------------------------------------*/ -static zrtp_status_t EC384P_sign( struct zrtp_sig_scheme *self, - zrtp_dsa_crypto_context_t *dsa_cc, - uint8_t *hash, uint32_t hash_len, - struct BigNum *dsasig ) -{ - struct zrtp_ec_params params; - zrtp_ec_init_params(¶ms, 384); - return ECDSA_sign(self, dsa_cc, ¶ms, -#ifdef ZRTP_TEST_VECTORS - 0, 0, 0, 0, 0, 0, 0, 0, -#endif - hash, hash_len, dsasig); -} - - -/*----------------------------------------------------------------------------*/ -/* Verify the signature on the hash value */ -/*----------------------------------------------------------------------------*/ -static zrtp_status_t EC384P_verify(struct zrtp_sig_scheme *self, - zrtp_dsa_crypto_context_t *dsa_cc, - uint8_t *hash, uint32_t hash_len, - struct BigNum *dsasig ) -{ - struct zrtp_ec_params params; - zrtp_ec_init_params(¶ms, 384); - return ECDSA_verify(self, dsa_cc, ¶ms, hash, hash_len, dsasig); -} - - - -/*============================================================================*/ -/* P-521 (FIPS 186-3) support. See RFC 4753, section 3.3. */ -/*============================================================================*/ - - -/*----------------------------------------------------------------------------*/ -/* Return dsa_cc->pv holding public value and dsa_cc->sv holding secret value */ -/* The public value is an elliptic curve point encoded as the x part shifted */ -/* left 528 bits (note, not 521) and or'd with the y part. */ -/*----------------------------------------------------------------------------*/ -static zrtp_status_t EC521P_keygen( struct zrtp_sig_scheme *self, - zrtp_dsa_crypto_context_t *dsa_cc ) -{ - struct zrtp_ec_params params; - zrtp_ec_init_params(¶ms, 521); - return ECDSA_keygen(self, dsa_cc, ¶ms, -#ifdef ZRTP_TEST_VECTORS - 0, 0, 0, 0, 0, 0, -#endif - 528); -} - - -/*----------------------------------------------------------------------------*/ -/* Sign the specified hash value */ -/*----------------------------------------------------------------------------*/ -static zrtp_status_t EC521P_sign( struct zrtp_sig_scheme *self, - zrtp_dsa_crypto_context_t *dsa_cc, - uint8_t *hash, uint32_t hash_len, - struct BigNum *dsasig ) -{ - struct zrtp_ec_params params; - zrtp_ec_init_params(¶ms, 521); - return ECDSA_sign(self, dsa_cc, ¶ms, -#ifdef ZRTP_TEST_VECTORS - 0, 0, 0, 0, 0, 0, 0, 0, -#endif - hash, hash_len, dsasig); -} - - -/*----------------------------------------------------------------------------*/ -/* Verify the signature on the hash value */ -/*----------------------------------------------------------------------------*/ -static zrtp_status_t EC521P_verify(struct zrtp_sig_scheme *self, - zrtp_dsa_crypto_context_t *dsa_cc, - uint8_t *hash, uint32_t hash_len, - struct BigNum *dsasig ) -{ - struct zrtp_ec_params params; - zrtp_ec_init_params(¶ms, 521); - return ECDSA_verify(self, dsa_cc, ¶ms, hash, hash_len, dsasig); -} - - - -/*============================================================================*/ -/* Public Key support */ -/*============================================================================*/ - - -/*----------------------------------------------------------------------------*/ -zrtp_status_t zrtp_defaults_sig(zrtp_global_ctx_t* zrtp_global) -{ - zrtp_sig_scheme_t* ec256p = zrtp_sys_alloc(sizeof(zrtp_sig_scheme_t)); - zrtp_sig_scheme_t* ec384p = zrtp_sys_alloc(sizeof(zrtp_sig_scheme_t)); - zrtp_sig_scheme_t* ec521p = zrtp_sys_alloc(sizeof(zrtp_sig_scheme_t)); - - if (!ec256p || !ec384p || !ec521p) - { - if(ec256p) zrtp_sys_free(ec256p); - if(ec384p) zrtp_sys_free(ec384p); - if(ec521p) zrtp_sys_free(ec521p); - return zrtp_status_alloc_fail; - } - - zrtp_memset(ec256p, 0, sizeof(zrtp_sig_scheme_t)); - zrtp_memcpy(ec256p->base.type, ZRTP_EC256P, ZRTP_COMP_TYPE_SIZE); - ec256p->base.id = ZRTP_SIGTYPE_EC256P; - ec256p->base.zrtp_global = zrtp_global; - ec256p->sv_length = 256/8; - ec256p->pv_length = 2*256/8; - ec256p->base.init = EC_dummy; - ec256p->base.free = EC_dummy; - ec256p->generate_key = EC256P_keygen; - ec256p->sign = EC256P_sign; - ec256p->verify = EC256P_verify; - - zrtp_memset(ec384p, 0, sizeof(zrtp_sig_scheme_t)); - zrtp_memcpy(ec384p->base.type, ZRTP_EC384P, ZRTP_COMP_TYPE_SIZE); - ec384p->base.id = ZRTP_SIGTYPE_EC384P; - ec384p->base.zrtp_global = zrtp_global; - ec384p->sv_length = 384/8; - ec384p->pv_length = 2*384/8; - ec384p->base.init = EC_dummy; - ec384p->base.free = EC_dummy; - ec384p->generate_key = EC384P_keygen; - ec384p->sign = EC384P_sign; - ec384p->verify = EC384P_verify; - - zrtp_memset(ec521p, 0, sizeof(zrtp_sig_scheme_t)); - zrtp_memcpy(ec521p->base.type, ZRTP_EC521P, ZRTP_COMP_TYPE_SIZE); - ec521p->base.id = ZRTP_SIGTYPE_EC521P; - ec521p->base.zrtp_global = zrtp_global; - ec521p->sv_length = 528/8; - ec521p->pv_length = 2*528/8; - ec521p->base.init = EC_dummy; - ec521p->base.free = EC_dummy; - ec521p->generate_key = EC521P_keygen; - ec521p->sign = EC521P_sign; - ec521p->verify = EC521P_verify; - - zrtp_register_comp(ZRTP_CC_SIG, ec256p, zrtp_global); - zrtp_register_comp(ZRTP_CC_SIG, ec384p, zrtp_global); - zrtp_register_comp(ZRTP_CC_SIG, ec521p, zrtp_global); - - return zrtp_status_ok; -} - -#endif /* don't have disgital signature ready for the moment*/ diff --git a/libs/libzrtp/src/zrtp_crypto_hash.c b/libs/libzrtp/src/zrtp_crypto_hash.c deleted file mode 100644 index 8154e8f970..0000000000 --- a/libs/libzrtp/src/zrtp_crypto_hash.c +++ /dev/null @@ -1,1638 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - * Vitaly Rozhkov - */ - -#include "sha2.h" -#include "sha1.h" - -#include "zrtp.h" - -#define _ZTU_ "zrtp hash" - - -/*============================================================================*/ -/* HASH function */ -/*============================================================================*/ - -/*----------------------------------------------------------------------------*/ -static zrtp_status_t zrtp_sha_c(zrtp_hash_t *self, const char* msg, uint32_t len, zrtp_stringn_t *dst) -{ - if (!self || !msg || !dst || !len) { - return zrtp_status_bad_param; - } - - switch (self->base.id) - { - case ZRTP_SRTP_HASH_HMAC_SHA1: { - sha1_ctx ctx; - if (dst->max_length < SHA1_DIGEST_SIZE) { - return zrtp_status_buffer_size; - } - sha1_begin(&ctx); - sha1_hash((const unsigned char*)msg, len, &ctx); - sha1_end((unsigned char*)dst->buffer, &ctx); - dst->length = SHA1_DIGEST_SIZE; - } break; - - case ZRTP_HASH_SHA256: { - sha256_ctx ctx; - if (dst->max_length < SHA256_DIGEST_SIZE) { - return zrtp_status_buffer_size; - } - sha256_begin(&ctx); - sha256_hash((const unsigned char*)msg, len, &ctx); - sha256_end((unsigned char*)dst->buffer, &ctx); - dst->length = SHA256_DIGEST_SIZE; - } break; - - case ZRTP_HASH_SHA384: { - sha384_ctx ctx; - if (dst->max_length < SHA384_DIGEST_SIZE) { - return zrtp_status_buffer_size; - } - sha384_begin(&ctx); - sha384_hash((const unsigned char*)msg, len, &ctx); - sha384_end((unsigned char*)dst->buffer, &ctx); - dst->length = SHA384_DIGEST_SIZE; - } break; - } - - return zrtp_status_ok; -} - -static zrtp_status_t zrtp_sha(zrtp_hash_t *self, const zrtp_stringn_t *msg, zrtp_stringn_t *dst) { - if (!self || !msg || !dst) { - return zrtp_status_bad_param; - } - return zrtp_sha_c(self, msg->buffer, msg->length, dst); -} - -/*----------------------------------------------------------------------------*/ -static void* zrtp_sha_begin(zrtp_hash_t *self) -{ - void *ctx = NULL; - - switch (self->base.id) { - case ZRTP_SRTP_HASH_HMAC_SHA1: - ctx = zrtp_sys_alloc(sizeof(sha1_ctx)); - if (ctx) { - sha1_begin(ctx); - } - break; - case ZRTP_HASH_SHA256: - ctx = zrtp_sys_alloc(sizeof(sha256_ctx)); - if (ctx) { - sha256_begin(ctx); - } - break; - case ZRTP_HASH_SHA384: - ctx = zrtp_sys_alloc(sizeof(sha384_ctx)); - if (ctx) { - sha384_begin(ctx); - } - break; - } - - return ctx; -} - -/*----------------------------------------------------------------------------*/ -static zrtp_status_t zrtp_sha_update( zrtp_hash_t *self, - void *ctx, - const int8_t *msg, - uint32_t length) -{ - if (!ctx || !msg || !length) { - return zrtp_status_bad_param; - } - - switch (self->base.id) { - case ZRTP_SRTP_HASH_HMAC_SHA1: - sha1_hash((const unsigned char*)msg, length, (sha1_ctx*)ctx); - break; - case ZRTP_HASH_SHA256: - sha256_hash((const unsigned char*)msg, length, (sha256_ctx*)ctx); - break; - case ZRTP_HASH_SHA384: - sha384_hash((const unsigned char*)msg, length, (sha384_ctx*)ctx); - break; - } - - return zrtp_status_ok; -} - -/*----------------------------------------------------------------------------*/ -static zrtp_status_t zrtp_sha_end( zrtp_hash_t *self, - void *ctx, - zrtp_stringn_t *digest) -{ - if (!ctx || !digest) { - return zrtp_status_bad_param; - } - - switch (self->base.id) { - case ZRTP_SRTP_HASH_HMAC_SHA1: - if (digest->max_length < SHA1_DIGEST_SIZE) { - return zrtp_status_buffer_size; - } - sha1_end((unsigned char*)digest->buffer,(sha1_ctx*)ctx); - digest->length = SHA1_DIGEST_SIZE; - break; - case ZRTP_HASH_SHA256: - if (digest->max_length < SHA256_DIGEST_SIZE) { - return zrtp_status_buffer_size; - } - sha256_end((unsigned char*)digest->buffer,(sha256_ctx*)ctx); - digest->length = SHA256_DIGEST_SIZE; - break; - case ZRTP_HASH_SHA384: - if (digest->max_length < SHA384_DIGEST_SIZE) { - return zrtp_status_buffer_size; - } - sha384_end((unsigned char*)digest->buffer,(sha384_ctx*)ctx); - digest->length = SHA384_DIGEST_SIZE; - break; - } - - zrtp_sys_free(ctx); - ctx = 0; - - return zrtp_status_ok; -} - - -/*============================================================================*/ -/* HMAC functions */ -/*============================================================================*/ - -typedef struct -{ - sha384_ctx context; - unsigned char k_ipad[128]; /* inner padding - key XORd with ipad */ - unsigned char k_opad[128]; /* outer padding - key XORd with opad */ -} hmac_sha384_context_t; - - -typedef struct -{ - sha256_ctx context; - unsigned char k_ipad[64]; - unsigned char k_opad[64]; -} hmac_sha256_context_t; - -typedef struct -{ - sha1_ctx context; - unsigned char k_ipad[64]; - unsigned char k_opad[64]; -} hmac_sha1_context_t; - - -/*----------------------------------------------------------------------------*/ -static void* zrtp_hmac_sha256_begin_c(zrtp_hash_t *self, const char *key, uint32_t length) -{ - const char *p_key; - uint32_t key_length; - char local_key[SHA256_BLOCK_SIZE]; - int i = 0; - hmac_sha256_context_t *ctx = zrtp_sys_alloc(sizeof(hmac_sha256_context_t)); - if (!ctx) { - return NULL; - } - zrtp_memset(ctx, 0, sizeof(hmac_sha256_context_t)); - - if (length > SHA256_BLOCK_SIZE) { - sha256_begin(&ctx->context); - sha256_hash((const unsigned char*)key, length, &ctx->context); - sha256_end((unsigned char*)local_key, &ctx->context); - - p_key = local_key; - key_length = SHA256_BLOCK_SIZE; - } else { - p_key = key; - key_length = length; - } - - /* - * the HMAC transform looks like: - * - * HASH(K XOR opad, HASH(K XOR ipad, text)) - * - * where K is an n byte key - * ipad is the byte 0x36 repeated 64 times - * opad is the byte 0x5c repeated 64 times - * and text is the data being protected - */ - - /* start out by storing key in pads */ - zrtp_memcpy(ctx->k_ipad, p_key, ZRTP_MIN(key_length, 64)); - zrtp_memcpy(ctx->k_opad, p_key, ZRTP_MIN(key_length, 64)); - - /* XOR key with ipad and opad values */ - for (i=0; i<64; i++) { - ctx->k_ipad[i] ^= (uint8_t)0x36; - ctx->k_opad[i] ^= (uint8_t)0x5c; - } - - /* perform inner hash */ - sha256_begin(&ctx->context); /* init context for 1st pass */ - sha256_hash(ctx->k_ipad, 64, &ctx->context); /* start with inner pad */ - - zrtp_memset(&local_key, 0, sizeof(local_key)); - return ctx; -} -static void* zrtp_hmac_sha384_begin_c(zrtp_hash_t *self, const char *key, uint32_t length) -{ - const char *p_key; - uint32_t key_length; - char local_key[SHA384_BLOCK_SIZE]; - int i = 0; - hmac_sha384_context_t *ctx = zrtp_sys_alloc(sizeof(hmac_sha384_context_t)); - if (!ctx) { - return NULL; - } - zrtp_memset(ctx, 0, sizeof(hmac_sha384_context_t)); - - if (length > SHA384_BLOCK_SIZE) { - sha384_begin(&ctx->context); - sha384_hash((const unsigned char*)key, length, &ctx->context); - sha384_end((unsigned char*)local_key, &ctx->context); - - p_key = local_key; - key_length = SHA384_BLOCK_SIZE; - } else { - p_key = key; - key_length = length; - } - - zrtp_memcpy(ctx->k_ipad, p_key, ZRTP_MIN(key_length, 128)); - zrtp_memcpy(ctx->k_opad, p_key, ZRTP_MIN(key_length, 128)); - - for (i=0; i<128; i++) { - ctx->k_ipad[i] ^= (uint8_t)0x36; - ctx->k_opad[i] ^= (uint8_t)0x5c; - } - - sha384_begin(&ctx->context); - sha384_hash(ctx->k_ipad, 128, &ctx->context); - - zrtp_memset(&local_key, 0, sizeof(local_key)); - return ctx; -} - -static void* zrtp_hmac_sha1_begin_c( zrtp_hash_t *self, - const char *key, - uint32_t length) -{ - const char *p_key; - uint32_t key_length; - char local_key[SHA1_BLOCK_SIZE]; - int i = 0; - hmac_sha1_context_t *ctx = zrtp_sys_alloc(sizeof(hmac_sha1_context_t)); - if (!ctx) { - return NULL; - } - zrtp_memset(ctx, 0, sizeof(hmac_sha1_context_t)); - - if (length > SHA1_BLOCK_SIZE) { - sha1_begin(&ctx->context); - sha1_hash((const unsigned char*)key, length, &ctx->context); - sha1_end((unsigned char*)local_key, &ctx->context); - - p_key = local_key; - key_length = SHA1_BLOCK_SIZE; - } else { - p_key = key; - key_length = length; - } - - zrtp_memcpy(ctx->k_ipad, p_key, ZRTP_MIN(key_length, 64)); - zrtp_memcpy(ctx->k_opad, p_key, ZRTP_MIN(key_length, 64)); - - for (i=0; i<64; i++) { - ctx->k_ipad[i] ^= (uint8_t)0x36; - ctx->k_opad[i] ^= (uint8_t)0x5c; - } - - sha1_begin(&ctx->context); - sha1_hash(ctx->k_ipad, 64, &ctx->context); - - zrtp_memset(&local_key, 0, sizeof(local_key)); - return ctx; -} - -static void* zrtp_hmac_begin(zrtp_hash_t *self, const zrtp_stringn_t *key) { - switch (self->base.id) - { - case ZRTP_SRTP_HASH_HMAC_SHA1: - return zrtp_hmac_sha1_begin_c(self, key->buffer, key->length); - case ZRTP_HASH_SHA256: - return zrtp_hmac_sha256_begin_c(self, key->buffer, key->length); - case ZRTP_HASH_SHA384: - return zrtp_hmac_sha384_begin_c(self, key->buffer, key->length); - default: - return NULL; - } -} - -/*----------------------------------------------------------------------------*/ -static zrtp_status_t zrtp_hmac_update(zrtp_hash_t *self, void *ctx, const char *msg, uint32_t length) -{ - if (!ctx || !msg) { - return zrtp_status_fail; - } - - if (0 != length) { - switch (self->base.id) { - case ZRTP_SRTP_HASH_HMAC_SHA1: - sha1_hash((const unsigned char*)msg, length, &((hmac_sha1_context_t*)ctx)->context); - break; - case ZRTP_HASH_SHA256: - sha256_hash((const unsigned char*)msg, length, &((hmac_sha256_context_t*)ctx)->context); - break; - case ZRTP_HASH_SHA384: - sha384_hash((const unsigned char*)msg, length, &((hmac_sha384_context_t*)ctx)->context); - break; - default: - return zrtp_status_bad_param; - } - } - - return zrtp_status_ok; -} - -/*----------------------------------------------------------------------------*/ -static zrtp_status_t zrtp_hmac_end( zrtp_hash_t *self, - void *ctx, - zrtp_stringn_t *digest, - uint32_t len) -{ - zrtp_string128_t dst = ZSTR_INIT_EMPTY(dst); - - if (!ctx || !digest) { - return zrtp_status_fail; - } - - switch (self->base.id) - { - case ZRTP_SRTP_HASH_HMAC_SHA1: - /* finish up 1st pass */ - sha1_end((unsigned char*)dst.buffer, &((hmac_sha1_context_t*)ctx)->context); - - /* perform outer hash and init context for 2nd pass */ - sha1_begin(&((hmac_sha1_context_t*)ctx)->context); - /* start with outer pad */ - sha1_hash(((hmac_sha1_context_t*)ctx)->k_opad, 64, &((hmac_sha1_context_t*)ctx)->context); - /* then results of 1st hash */ - sha1_hash((const unsigned char*)dst.buffer, SHA1_DIGEST_SIZE, &((hmac_sha1_context_t*)ctx)->context); - /* finish up 2nd pass */ - sha1_end((unsigned char*)dst.buffer, &((hmac_sha1_context_t*)ctx)->context); - - len = (0 == len) ? SHA1_DIGEST_SIZE : ZRTP_MIN(len, SHA1_DIGEST_SIZE); - break; - case ZRTP_HASH_SHA256: - sha256_end((unsigned char*)dst.buffer, &((hmac_sha256_context_t*)ctx)->context); - sha256_begin(&((hmac_sha256_context_t*)ctx)->context); - sha256_hash(((hmac_sha256_context_t*)ctx)->k_opad, 64, &((hmac_sha256_context_t*)ctx)->context); - sha256_hash((const unsigned char*)dst.buffer, SHA256_DIGEST_SIZE, &((hmac_sha256_context_t*)ctx)->context); - sha256_end((unsigned char*)dst.buffer, &((hmac_sha256_context_t*)ctx)->context); - - len = (0 == len) ? SHA256_DIGEST_SIZE : ZRTP_MIN(len, SHA256_DIGEST_SIZE); - break; - case ZRTP_HASH_SHA384: - sha384_end((unsigned char*)dst.buffer, &((hmac_sha384_context_t*)ctx)->context); - sha384_begin(&((hmac_sha384_context_t*)ctx)->context); - sha384_hash(((hmac_sha384_context_t*)ctx)->k_opad, 128, &((hmac_sha384_context_t*)ctx)->context); - sha384_hash((const unsigned char*)dst.buffer, SHA384_DIGEST_SIZE, &((hmac_sha384_context_t*)ctx)->context); - sha384_end((unsigned char*)dst.buffer, &((hmac_sha384_context_t*)ctx)->context); - - len = (0 == len) ? SHA384_DIGEST_SIZE : ZRTP_MIN(len, SHA384_DIGEST_SIZE); - break; - default: - return zrtp_status_bad_param; - } - - digest->length = ZRTP_MIN(len, digest->max_length); - zrtp_memcpy(digest->buffer, dst.buffer, digest->length); - - zrtp_sys_free(ctx); - - return zrtp_status_ok; -} - -/*----------------------------------------------------------------------------*/ -static zrtp_status_t zrtp_hmac_c( zrtp_hash_t *self, - const char *key, - const uint32_t key_len, - const char *msg, - const uint32_t msg_len, - zrtp_stringn_t *digest) -{ - unsigned char *p_key; - uint32_t l_key_len; - sha1_ctx context1; - sha256_ctx context2; - sha384_ctx context3; - unsigned char k_ipad[128]; /* inner padding - key XORd with ipad */ - unsigned char k_opad[128]; /* outer padding - key XORd with opad */ - unsigned i; - unsigned char local_key[SHA384_BLOCK_SIZE]; - uint32_t local_key_len = 0; - - - if (!self || !digest || !key || !msg) { - return zrtp_status_buffer_size; - } - - switch (self->base.id) { - case ZRTP_SRTP_HASH_HMAC_SHA1: - local_key_len = SHA1_BLOCK_SIZE; - break; - case ZRTP_HASH_SHA256: - local_key_len = SHA256_BLOCK_SIZE; - break; - case ZRTP_HASH_SHA384: - local_key_len = SHA384_BLOCK_SIZE; - break; - default: - return zrtp_status_bad_param; - } - - if (digest->max_length < local_key_len) { - return zrtp_status_buffer_size; - } - - if (key_len > local_key_len) { - switch (self->base.id) - { - case ZRTP_SRTP_HASH_HMAC_SHA1: - sha1_begin(&context1); - sha1_hash((const unsigned char*)key, key_len, &context1); - sha1_end(local_key, &context1); - break; - case ZRTP_HASH_SHA256: - sha256_begin(&context2); - sha256_hash((const unsigned char*)key, key_len, &context2); - sha256_end(local_key, &context2); - break; - case ZRTP_HASH_SHA384: - sha384_begin(&context3); - sha384_hash((const unsigned char*)key, key_len, &context3); - sha384_end(local_key, &context3); - break; - } - - p_key = local_key; - l_key_len = local_key_len; - } else { - p_key = (unsigned char*)key; - l_key_len = key_len; - } - - /* - * the HMAC transform looks like: - * - * HASH(K XOR opad, HASH(K XOR ipad, text)) - * - * where K is an n byte key - * ipad is the byte 0x36 repeated 64 times - * opad is the byte 0x5c repeated 64 times - * and text is the data being protected - */ - - /* start out by storing key in pads */ - zrtp_memset(k_ipad, 0, sizeof(k_ipad)); - zrtp_memset(k_opad, 0, sizeof(k_opad)); - zrtp_memcpy(k_ipad, p_key, ZRTP_MIN(l_key_len, local_key_len)); - zrtp_memcpy(k_opad, p_key, ZRTP_MIN(l_key_len, local_key_len)); - - /* XOR key with ipad and opad values */ - for (i=0; ibase.id) { - case ZRTP_SRTP_HASH_HMAC_SHA1: - /* perform inner hash */ - sha1_begin(&context1); /* init context for 1st pass */ - sha1_hash(k_ipad, local_key_len, &context1);/* start with inner pad */ - sha1_hash((const unsigned char*)msg, msg_len, &context1); /* then text of datagram */ - sha1_end((unsigned char*)digest->buffer, &context1); /* finish up 1st pass */ - - /* perform outer hash */ - sha1_begin(&context1); /* init context for 2nd pass */ - sha1_hash(k_opad, local_key_len, &context1);/* start with outer pad */ - sha1_hash((const unsigned char*)digest->buffer, SHA1_DIGEST_SIZE, &context1); /* then results of 1st hash */ - sha1_end((unsigned char*)digest->buffer, &context1); /* finish up 2nd pass */ - - digest->length = SHA1_DIGEST_SIZE; - break; - case ZRTP_HASH_SHA256: - sha256_begin(&context2); - sha256_hash(k_ipad, local_key_len, &context2); - sha256_hash((const unsigned char*)msg, msg_len, &context2); - sha256_end((unsigned char*)digest->buffer, &context2); - - sha256_begin(&context2); - sha256_hash(k_opad, local_key_len, &context2); - sha256_hash((const unsigned char*)digest->buffer, SHA256_DIGEST_SIZE, &context2); - sha256_end((unsigned char*)digest->buffer, &context2); - - digest->length = SHA256_DIGEST_SIZE; - break; - case ZRTP_HASH_SHA384: - sha384_begin(&context3); - sha384_hash(k_ipad, local_key_len, &context3); - sha384_hash((const unsigned char*)msg, msg_len, &context3); - sha384_end((unsigned char*)digest->buffer, &context3); - - sha384_begin(&context3); - sha384_hash(k_opad, local_key_len, &context3); - sha384_hash((const unsigned char*)digest->buffer, SHA384_DIGEST_SIZE, &context3); - sha384_end((unsigned char*)digest->buffer, &context3); - - digest->length = SHA384_DIGEST_SIZE; - break; - } - - return zrtp_status_ok; -} - -static zrtp_status_t zrtp_hmac( zrtp_hash_t *self, - const zrtp_stringn_t *key, - const zrtp_stringn_t *msg, - zrtp_stringn_t *digest) { - return zrtp_hmac_c(self, key->buffer, key->length, msg->buffer, msg->length, digest); -} - -/*----------------------------------------------------------------------------*/ -static zrtp_status_t zrtp_hmac_truncated_c( zrtp_hash_t *self, - const char *key, - const uint32_t key_len, - const char *msg, - const uint32_t msg_len, - uint32_t necessary_len, - zrtp_stringn_t *digest) -{ - uint32_t necessary_len_max = 0; - switch (self->base.id) { - case ZRTP_SRTP_HASH_HMAC_SHA1: - necessary_len_max = SHA1_DIGEST_SIZE; - break; - case ZRTP_HASH_SHA256: - necessary_len_max = SHA256_DIGEST_SIZE; - break; - case ZRTP_HASH_SHA384: - necessary_len_max = SHA384_DIGEST_SIZE; - break; - } - if (necessary_len > necessary_len_max) { - return zrtp_status_buffer_size; - } - - if (0 == necessary_len) { - zrtp_hmac_c(self, key, key_len, msg, msg_len, digest); - } else { - zrtp_string128_t dst = ZSTR_INIT_EMPTY(dst); - - zrtp_hmac_c(self, key, key_len, msg, msg_len, (zrtp_stringn_t *)&dst); - switch (self->base.id) { - case ZRTP_SRTP_HASH_HMAC_SHA1: - necessary_len = ZRTP_MIN(necessary_len, SHA1_DIGEST_SIZE); - break; - case ZRTP_HASH_SHA256: - necessary_len = ZRTP_MIN(necessary_len, SHA256_DIGEST_SIZE); - break; - case ZRTP_HASH_SHA384: - necessary_len = ZRTP_MIN(necessary_len, SHA384_DIGEST_SIZE); - break; - } - digest->length = ZRTP_MIN(necessary_len, digest->max_length); - zrtp_memcpy(digest->buffer, dst.buffer, digest->length); - } - - return zrtp_status_ok; -} - -static zrtp_status_t zrtp_hmac_truncated( zrtp_hash_t *self, - const zrtp_stringn_t *key, - const zrtp_stringn_t *msg, - uint32_t len, - zrtp_stringn_t *digest) { - return zrtp_hmac_truncated_c(self, key->buffer, key->length, msg->buffer, msg->length, len, digest); - -} - - -/*============================================================================*/ -/* SHA and SHMAC test cases */ -/*============================================================================*/ - - -/* - * SHA1 Test Vectors - */ - -static uint8_t sha1_msg_8[1] = { - 0xa8 -}; - -static uint8_t sha1_MD_8[20] = { - 0x99, 0xf2, 0xaa, 0x95, 0xe3, 0x6f, 0x95, 0xc2, - 0xac, 0xb0, 0xea, 0xf2, 0x39, 0x98, 0xf0, 0x30, - 0x63, 0x8f, 0x3f, 0x15 -}; - -static uint8_t sha1_msg_128[16] = { - 0xc5, 0xa2, 0x2d, 0xd6, 0xed, 0xa3, 0xfe, 0x2b, - 0xdc, 0x4d, 0xdb, 0x3c, 0xe6, 0xb3, 0x5f, 0xd1 -}; - -static uint8_t sha1_MD_128[20] = { - 0xfa, 0xc8, 0xab, 0x93, 0xc1, 0xae, 0x6c, 0x16, - 0xf0, 0x31, 0x18, 0x72, 0xb9, 0x84, 0xf7, 0x29, - 0xdc, 0x92, 0x8c, 0xcd -}; - -static uint8_t sha1_msg_512[64] = { - 0x7e, 0x3a, 0x4c, 0x32, 0x5c, 0xb9, 0xc5, 0x2b, - 0x88, 0x38, 0x7f, 0x93, 0xd0, 0x1a, 0xe8, 0x6d, - 0x42, 0x09, 0x8f, 0x5e, 0xfa, 0x7f, 0x94, 0x57, - 0x38, 0x8b, 0x5e, 0x74, 0xb6, 0xd2, 0x8b, 0x24, - 0x38, 0xd4, 0x2d, 0x8b, 0x64, 0x70, 0x33, 0x24, - 0xd4, 0xaa, 0x25, 0xab, 0x6a, 0xad, 0x15, 0x3a, - 0xe3, 0x0c, 0xd2, 0xb2, 0xaf, 0x4d, 0x5e, 0x5c, - 0x00, 0xa8, 0xa2, 0xd0, 0x22, 0x0c, 0x61, 0x16 -}; - -static uint8_t sha1_MD_512[20] = { - 0xa3, 0x05, 0x44, 0x27, 0xcd, 0xb1, 0x3f, 0x16, - 0x4a, 0x61, 0x0b, 0x34, 0x87, 0x02, 0x72, 0x4c, - 0x80, 0x8a, 0x0d, 0xcc -}; - -static uint8_t sha1_msg_2096[262] = { - 0x5f, 0xc2, 0xc3, 0xf6, 0xa7, 0xe7, 0x9d, 0xc9, - 0x4b, 0xe5, 0x26, 0xe5, 0x16, 0x6a, 0x23, 0x88, - 0x99, 0xd5, 0x49, 0x27, 0xce, 0x47, 0x00, 0x18, - 0xfb, 0xfd, 0x66, 0x8f, 0xd9, 0xdd, 0x97, 0xcb, - 0xf6, 0x4e, 0x2c, 0x91, 0x58, 0x4d, 0x01, 0xda, - 0x63, 0xbe, 0x3c, 0xc9, 0xfd, 0xff, 0x8a, 0xdf, - 0xef, 0xc3, 0xac, 0x72, 0x8e, 0x1e, 0x33, 0x5b, - 0x9c, 0xdc, 0x87, 0xf0, 0x69, 0x17, 0x2e, 0x32, - 0x3d, 0x09, 0x4b, 0x47, 0xfa, 0x1e, 0x65, 0x2a, - 0xfe, 0x4d, 0x6a, 0xa1, 0x47, 0xa9, 0xf4, 0x6f, - 0xda, 0x33, 0xca, 0xcb, 0x65, 0xf3, 0xaa, 0x12, - 0x23, 0x47, 0x46, 0xb9, 0x00, 0x7a, 0x8c, 0x85, - 0xfe, 0x98, 0x2a, 0xfe, 0xd7, 0x81, 0x52, 0x21, - 0xe4, 0x3d, 0xba, 0x55, 0x3d, 0x8f, 0xe8, 0xa0, - 0x22, 0xcd, 0xac, 0x1b, 0x99, 0xee, 0xee, 0xa3, - 0x59, 0xe5, 0xa9, 0xd2, 0xe7, 0x2e, 0x38, 0x2d, - 0xff, 0xa6, 0xd1, 0x9f, 0x35, 0x9f, 0x4f, 0x27, - 0xdc, 0x34, 0x34, 0xcd, 0x27, 0xda, 0xee, 0xda, - 0x8e, 0x38, 0x59, 0x48, 0x73, 0x39, 0x86, 0x78, - 0x06, 0x5f, 0xbb, 0x23, 0x66, 0x5a, 0xba, 0x93, - 0x09, 0xd9, 0x46, 0x13, 0x5d, 0xa0, 0xe4, 0xa4, - 0xaf, 0xda, 0xdf, 0xf1, 0x4d, 0xb1, 0x8e, 0x85, - 0xe7, 0x1d, 0xd9, 0x3c, 0x3b, 0xf9, 0xfa, 0xf7, - 0xf2, 0x5c, 0x81, 0x94, 0xc4, 0x26, 0x9b, 0x1e, - 0xe3, 0xd9, 0x93, 0x40, 0x97, 0xab, 0x99, 0x00, - 0x25, 0xd9, 0xc3, 0xaa, 0xf6, 0x3d, 0x51, 0x09, - 0xf5, 0x23, 0x35, 0xdd, 0x39, 0x59, 0xd3, 0x8a, - 0xe4, 0x85, 0x05, 0x0e, 0x4b, 0xbb, 0x62, 0x35, - 0x57, 0x4f, 0xc0, 0x10, 0x2b, 0xe8, 0xf7, 0xa3, - 0x06, 0xd6, 0xe8, 0xde, 0x6b, 0xa6, 0xbe, 0xcf, - 0x80, 0xf3, 0x74, 0x15, 0xb5, 0x7f, 0x98, 0x98, - 0xa5, 0x82, 0x4e, 0x77, 0x41, 0x41, 0x97, 0x42, - 0x2b, 0xe3, 0xd3, 0x6a, 0x60, 0x80 -}; - -static uint8_t sha1_MD_2096[20] = { - 0x04, 0x23, 0xdc, 0x76, 0xa8, 0x79, 0x11, 0x07, - 0xd1, 0x4e, 0x13, 0xf5, 0x26, 0x5b, 0x34, 0x3f, - 0x24, 0xcc, 0x0f, 0x19 -}; - - - -/* - * HMAC SHA1 Test Vectors from RFC 2202 - */ - -static uint8_t test_case1_hmac_sha1_key[20] = { - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b -}; -static uint8_t test_case1_hmac_sha1_data[8] = { - 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65 -}; -static uint8_t test_case1_hmac_sha1_result[20] = { - 0xb6, 0x17, 0x31, 0x86, 0x55, 0x05, 0x72, 0x64, - 0xe2, 0x8b, 0xc0, 0xb6, 0xfb, 0x37, 0x8c, 0x8e, - 0xf1, 0x46, 0xbe, 0x00 -}; - - -static uint8_t test_case2_hmac_sha1_key[4] = { - 0x4a, 0x65, 0x66, 0x65 -}; -static uint8_t test_case2_hmac_sha1_data[28] = { - 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20, - 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20, - 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68, - 0x69, 0x6e, 0x67, 0x3f -}; -static uint8_t test_case2_hmac_sha1_result[20] = { - 0xef, 0xfc, 0xdf, 0x6a, 0xe5, 0xeb, 0x2f, 0xa2, - 0xd2, 0x74, 0x16, 0xd5, 0xf1, 0x84, 0xdf, 0x9c, - 0x25, 0x9a, 0x7c, 0x79 -}; - - -static uint8_t test_case3_hmac_sha1_key[20] = { - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa -}; -static uint8_t test_case3_hmac_sha1_data[50] = { - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd -}; -static uint8_t test_case3_hmac_sha1_result[20] = { - 0x12, 0x5d, 0x73, 0x42, 0xb9, 0xac, 0x11, 0xcd, - 0x91, 0xa3, 0x9a, 0xf4, 0x8a, 0xa1, 0x7b, 0x4f, - 0x63, 0xf1, 0x75, 0xd3 -}; - - -static uint8_t test_case4_hmac_sha1_key[25] = { - 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, - 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, - 0x19 -}; -static uint8_t test_case4_hmac_sha1_data[50] = { - 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, - 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, - 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, - 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, - 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, - 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, - 0xcd, 0xcd -}; -static uint8_t test_case4_hmac_sha1_result[20] = { - 0x4c, 0x90, 0x07, 0xf4, 0x02, 0x62, 0x50, 0xc6, - 0xbc, 0x84, 0x14, 0xf9, 0xbf, 0x50, 0xc8, 0x6c, - 0x2d, 0x72, 0x35, 0xda -}; - - -static uint8_t test_case5_hmac_sha1_key[20] = { - 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, - 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, - 0x0c, 0x0c, 0x0c, 0x0c -}; -static uint8_t test_case5_hmac_sha1_data[20] = { - 0x54, 0x65, 0x73, 0x74, 0x20, 0x57, 0x69, 0x74, - 0x68, 0x20, 0x54, 0x72, 0x75, 0x6e, 0x63, 0x61, - 0x74, 0x69, 0x6f, 0x6e -}; -static uint8_t test_case5_hmac_sha1_result[20] = { - 0x4c, 0x1a, 0x03, 0x42, 0x4b, 0x55, 0xe0, 0x7f, - 0xe7, 0xf2, 0x7b, 0xe1, 0xd5, 0x8b, 0xb9, 0x32, - 0x4a, 0x9a, 0x5a, 0x04 -}; - - -static uint8_t test_case6_hmac_sha1_key[80] = { - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa -}; -static uint8_t test_case6_hmac_sha1_data[54] = { - 0x54, 0x65, 0x73, 0x74, 0x20, 0x55, 0x73, 0x69, - 0x6e, 0x67, 0x20, 0x4c, 0x61, 0x72, 0x67, 0x65, - 0x72, 0x20, 0x54, 0x68, 0x61, 0x6e, 0x20, 0x42, - 0x6c, 0x6f, 0x63, 0x6b, 0x2d, 0x53, 0x69, 0x7a, - 0x65, 0x20, 0x4b, 0x65, 0x79, 0x20, 0x2d, 0x20, - 0x48, 0x61, 0x73, 0x68, 0x20, 0x4b, 0x65, 0x79, - 0x20, 0x46, 0x69, 0x72, 0x73, 0x74 -}; -static uint8_t test_case6_hmac_sha1_result[20] = { - 0xaa, 0x4a, 0xe5, 0xe1, 0x52, 0x72, 0xd0, 0x0e, - 0x95, 0x70, 0x56, 0x37, 0xce, 0x8a, 0x3b, 0x55, - 0xed, 0x40, 0x21, 0x12 -}; - - -static uint8_t test_case7_hmac_sha1_key[80] = { - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa -}; -static uint8_t test_case7_hmac_sha1_data[73] = { - 0x54, 0x65, 0x73, 0x74, 0x20, 0x55, 0x73, 0x69, - 0x6e, 0x67, 0x20, 0x4c, 0x61, 0x72, 0x67, 0x65, - 0x72, 0x20, 0x54, 0x68, 0x61, 0x6e, 0x20, 0x42, - 0x6c, 0x6f, 0x63, 0x6b, 0x2d, 0x53, 0x69, 0x7a, - 0x65, 0x20, 0x4b, 0x65, 0x79, 0x20, 0x61, 0x6e, - 0x64, 0x20, 0x4c, 0x61, 0x72, 0x67, 0x65, 0x72, - 0x20, 0x54, 0x68, 0x61, 0x6e, 0x20, 0x4f, 0x6e, - 0x65, 0x20, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x2d, - 0x53, 0x69, 0x7a, 0x65, 0x20, 0x44, 0x61, 0x74, - 0x61 -}; -static uint8_t test_case7_hmac_sha1_result[20] = { - 0xe8, 0xe9, 0x9d, 0x0f, 0x45, 0x23, 0x7d, 0x78, - 0x6d, 0x6b, 0xba, 0xa7, 0x96, 0x5c, 0x78, 0x08, - 0xbb, 0xff, 0x1a, 0x91 -}; - - - -/* - * SHA256 Test Vectors - */ - -static uint8_t sha256_msg_8[1] = { - 0xbd -}; - -static uint8_t sha256_MD_8[32] = { - 0x68, 0x32, 0x57, 0x20, 0xaa, 0xbd, 0x7c, 0x82, - 0xf3, 0x0f, 0x55, 0x4b, 0x31, 0x3d, 0x05, 0x70, - 0xc9, 0x5a, 0xcc, 0xbb, 0x7d, 0xc4, 0xb5, 0xaa, - 0xe1, 0x12, 0x04, 0xc0, 0x8f, 0xfe, 0x73, 0x2b -}; - -static uint8_t sha256_msg_128[16] = { - 0xfd, 0xf4, 0x70, 0x09, 0x84, 0xee, 0x11, 0xb7, - 0x0a, 0xf1, 0x88, 0x0d, 0x0e, 0x0f, 0xef, 0xd4 -}; - -static uint8_t sha256_MD_128[32] = { - 0xb0, 0x1a, 0xe1, 0x6e, 0xed, 0x3b, 0x4a, 0x77, - 0x0f, 0x12, 0x7b, 0x98, 0x46, 0x9b, 0xa2, 0x6f, - 0xe3, 0xd8, 0xe9, 0xf5, 0x9d, 0x8a, 0x29, 0x83, - 0x21, 0x4a, 0xfe, 0x6c, 0xff, 0x0e, 0x6b, 0x6c -}; - - -static uint8_t sha256_msg_512[64] = { - 0x35, 0x92, 0xec, 0xfd, 0x1e, 0xac, 0x61, 0x8f, - 0xd3, 0x90, 0xe7, 0xa9, 0xc2, 0x4b, 0x65, 0x65, - 0x32, 0x50, 0x93, 0x67, 0xc2, 0x1a, 0x0e, 0xac, - 0x12, 0x12, 0xac, 0x83, 0xc0, 0xb2, 0x0c, 0xd8, - 0x96, 0xeb, 0x72, 0xb8, 0x01, 0xc4, 0xd2, 0x12, - 0xc5, 0x45, 0x2b, 0xbb, 0xf0, 0x93, 0x17, 0xb5, - 0x0c, 0x5c, 0x9f, 0xb1, 0x99, 0x75, 0x53, 0xd2, - 0xbb, 0xc2, 0x9b, 0xb4, 0x2f, 0x57, 0x48, 0xad -}; - -static uint8_t sha256_MD_512[32] = { - 0x10, 0x5a, 0x60, 0x86, 0x58, 0x30, 0xac, 0x3a, - 0x37, 0x1d, 0x38, 0x43, 0x32, 0x4d, 0x4b, 0xb5, - 0xfa, 0x8e, 0xc0, 0xe0, 0x2d, 0xda, 0xa3, 0x89, - 0xad, 0x8d, 0xa4, 0xf1, 0x02, 0x15, 0xc4, 0x54 -}; - -static uint8_t sha256_msg_2096[262] = { - 0xf6, 0xce, 0x82, 0x21, 0xbf, 0x64, 0x27, 0x3c, - 0x91, 0xc4, 0xcb, 0x41, 0xeb, 0xba, 0x1b, 0xfc, - 0xfa, 0x12, 0xc0, 0x43, 0xc7, 0x01, 0x31, 0x7e, - 0xb0, 0xc0, 0xcb, 0x66, 0x15, 0x7a, 0x23, 0x0c, - 0x53, 0x68, 0x9b, 0x1d, 0xf6, 0x3b, 0x33, 0x65, - 0x2a, 0xba, 0xa2, 0x93, 0x73, 0xac, 0xa6, 0x3c, - 0x9e, 0xf8, 0x98, 0x22, 0xf8, 0x0b, 0x43, 0xb5, - 0xbd, 0x7a, 0xf6, 0xda, 0xd3, 0xe8, 0xd8, 0xec, - 0xb8, 0x2b, 0x7c, 0x00, 0xba, 0xaa, 0xb5, 0x6e, - 0x66, 0x09, 0xac, 0x8d, 0x42, 0x09, 0x2f, 0xbd, - 0xbf, 0xa9, 0x4c, 0xab, 0x69, 0x92, 0x1f, 0xd0, - 0x61, 0xb1, 0xe8, 0x3b, 0x0d, 0x26, 0x60, 0x91, - 0x0e, 0x5d, 0x4e, 0x52, 0x72, 0x7a, 0x55, 0x5d, - 0x2b, 0xfb, 0x10, 0xb7, 0xc0, 0x98, 0x61, 0x88, - 0x43, 0x6e, 0x05, 0x66, 0x83, 0x5d, 0x6c, 0xd6, - 0x82, 0xaf, 0xc8, 0x10, 0x2a, 0xfa, 0x65, 0x03, - 0x3b, 0x47, 0x38, 0x99, 0x88, 0x73, 0xba, 0x3c, - 0x63, 0xd6, 0xf7, 0x99, 0x56, 0x23, 0xe1, 0xa4, - 0x14, 0x8f, 0xeb, 0xdc, 0xae, 0x36, 0xd3, 0xd0, - 0x0a, 0xba, 0xbf, 0xe2, 0x92, 0x2d, 0x8c, 0x4b, - 0x29, 0x31, 0x63, 0x5f, 0x63, 0x5d, 0x8d, 0x12, - 0xf5, 0xe3, 0x88, 0xbc, 0x6a, 0x70, 0x5a, 0x19, - 0x18, 0x54, 0x25, 0x94, 0x53, 0xe3, 0xfc, 0xc5, - 0xe0, 0x1b, 0xf5, 0x38, 0xac, 0x87, 0x7f, 0x70, - 0xbe, 0x62, 0xf6, 0x2b, 0x6b, 0x00, 0x75, 0xe8, - 0xc9, 0x6a, 0xec, 0xa7, 0x66, 0x49, 0x72, 0xf0, - 0x39, 0x05, 0xdc, 0x16, 0xd8, 0x2d, 0x8e, 0xbd, - 0xec, 0x1a, 0x91, 0x9a, 0xe2, 0xcf, 0xe6, 0x7a, - 0xe4, 0x24, 0x1a, 0x86, 0x08, 0x24, 0x1b, 0xc5, - 0xc7, 0xb3, 0x4a, 0xe2, 0xb0, 0x74, 0xd1, 0x30, - 0x5d, 0xe9, 0x37, 0xeb, 0xa7, 0xdc, 0x32, 0xc1, - 0x16, 0xfe, 0xbc, 0x90, 0x9b, 0xcf, 0x68, 0x72, - 0x82, 0xbd, 0xf7, 0xf7, 0xa2, 0x90 -}; - -static uint8_t sha256_MD_2096[32] = { - 0xef, 0xd3, 0x5c, 0x0d, 0x49, 0xe6, 0xa2, 0x2c, - 0x2b, 0x54, 0x59, 0x9a, 0xbb, 0x0d, 0xfa, 0x41, - 0x94, 0x35, 0xa5, 0xb7, 0x49, 0xef, 0x1c, 0x71, - 0x23, 0xd5, 0x9a, 0x2f, 0xb5, 0xdb, 0x8f, 0x75 -}; - - -/* - * HMAC SHA256 Test Vectors from RFC 4231 - */ - -static uint8_t test_case1_hmac_sha2_key[20] = { - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b -}; - -static uint8_t test_case1_hmac_sha2_data[8] = { - 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65 -}; -static uint8_t test_case1_hmac_sha256_result[32] = { - 0xb0, 0x34, 0x4c, 0x61, 0xd8, 0xdb, 0x38, 0x53, - 0x5c, 0xa8, 0xaf, 0xce, 0xaf, 0x0b, 0xf1, 0x2b, - 0x88, 0x1d, 0xc2, 0x00, 0xc9, 0x83, 0x3d, 0xa7, - 0x26, 0xe9, 0x37, 0x6c, 0x2e, 0x32, 0xcf, 0xf7 -}; -static uint8_t test_case1_hmac_sha384_result[48] = { - 0xaf, 0xd0, 0x39, 0x44, 0xd8, 0x48, 0x95, 0x62, - 0x6b, 0x08, 0x25, 0xf4, 0xab, 0x46, 0x90, 0x7f, - 0x15, 0xf9, 0xda, 0xdb, 0xe4, 0x10, 0x1e, 0xc6, - 0x82, 0xaa, 0x03, 0x4c, 0x7c, 0xeb, 0xc5, 0x9c, - 0xfa, 0xea, 0x9e, 0xa9, 0x07, 0x6e, 0xde, 0x7f, - 0x4a, 0xf1, 0x52, 0xe8, 0xb2, 0xfa, 0x9c, 0xb6 -}; - - -static uint8_t test_case2_hmac_sha2_key[4] = { - 0x4a, 0x65, 0x66, 0x65 -}; -static uint8_t test_case2_hmac_sha2_data[28] = { - 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20, - 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20, - 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68, - 0x69, 0x6e, 0x67, 0x3f -}; -static uint8_t test_case2_hmac_sha256_result[32] = { - 0x5b, 0xdc, 0xc1, 0x46, 0xbf, 0x60, 0x75, 0x4e, - 0x6a, 0x04, 0x24, 0x26, 0x08, 0x95, 0x75, 0xc7, - 0x5a, 0x00, 0x3f, 0x08, 0x9d, 0x27, 0x39, 0x83, - 0x9d, 0xec, 0x58, 0xb9, 0x64, 0xec, 0x38, 0x43 -}; -static uint8_t test_case2_hmac_sha384_result[48] = { - 0xaf, 0x45, 0xd2, 0xe3, 0x76, 0x48, 0x40, 0x31, - 0x61, 0x7f, 0x78, 0xd2, 0xb5, 0x8a, 0x6b, 0x1b, - 0x9c, 0x7e, 0xf4, 0x64, 0xf5, 0xa0, 0x1b, 0x47, - 0xe4, 0x2e, 0xc3, 0x73, 0x63, 0x22, 0x44, 0x5e, - 0x8e, 0x22, 0x40, 0xca, 0x5e, 0x69, 0xe2, 0xc7, - 0x8b, 0x32, 0x39, 0xec, 0xfa, 0xb2, 0x16, 0x49 -}; - - -static uint8_t test_case3_hmac_sha2_key[20] = { - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa -}; -static uint8_t test_case3_hmac_sha2_data[50] = { - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd -}; -static uint8_t test_case3_hmac_sha256_result[32] = { - 0x77, 0x3e, 0xa9, 0x1e, 0x36, 0x80, 0x0e, 0x46, - 0x85, 0x4d, 0xb8, 0xeb, 0xd0, 0x91, 0x81, 0xa7, - 0x29, 0x59, 0x09, 0x8b, 0x3e, 0xf8, 0xc1, 0x22, - 0xd9, 0x63, 0x55, 0x14, 0xce, 0xd5, 0x65, 0xfe -}; -static uint8_t test_case3_hmac_sha384_result[48] = { - 0x88, 0x06, 0x26, 0x08, 0xd3, 0xe6, 0xad, 0x8a, - 0x0a, 0xa2, 0xac, 0xe0, 0x14, 0xc8, 0xa8, 0x6f, - 0x0a, 0xa6, 0x35, 0xd9, 0x47, 0xac, 0x9f, 0xeb, - 0xe8, 0x3e, 0xf4, 0xe5, 0x59, 0x66, 0x14, 0x4b, - 0x2a, 0x5a, 0xb3, 0x9d, 0xc1, 0x38, 0x14, 0xb9, - 0x4e, 0x3a, 0xb6, 0xe1, 0x01, 0xa3, 0x4f, 0x27 -}; - - -static uint8_t test_case4_hmac_sha2_key[25] = { - 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, - 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, - 0x19 -}; -static uint8_t test_case4_hmac_sha2_data[50] = { - 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, - 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, - 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, - 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, - 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, - 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, - 0xcd, 0xcd -}; -static uint8_t test_case4_hmac_sha256_result[32] = { - 0x82, 0x55, 0x8a, 0x38, 0x9a, 0x44, 0x3c, 0x0e, - 0xa4, 0xcc, 0x81, 0x98, 0x99, 0xf2, 0x08, 0x3a, - 0x85, 0xf0, 0xfa, 0xa3, 0xe5, 0x78, 0xf8, 0x07, - 0x7a, 0x2e, 0x3f, 0xf4, 0x67, 0x29, 0x66, 0x5b -}; -static uint8_t test_case4_hmac_sha384_result[48] = { - 0x3e, 0x8a, 0x69, 0xb7, 0x78, 0x3c, 0x25, 0x85, - 0x19, 0x33, 0xab, 0x62, 0x90, 0xaf, 0x6c, 0xa7, - 0x7a, 0x99, 0x81, 0x48, 0x08, 0x50, 0x00, 0x9c, - 0xc5, 0x57, 0x7c, 0x6e, 0x1f, 0x57, 0x3b, 0x4e, - 0x68, 0x01, 0xdd, 0x23, 0xc4, 0xa7, 0xd6, 0x79, - 0xcc, 0xf8, 0xa3, 0x86, 0xc6, 0x74, 0xcf, 0xfb -}; - - -static uint8_t test_case5_hmac_sha2_key[20] = { - 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, - 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, - 0x0c, 0x0c, 0x0c, 0x0c -}; -static uint8_t test_case5_hmac_sha2_data[20] = { - 0x54, 0x65, 0x73, 0x74, 0x20, 0x57, 0x69, 0x74, - 0x68, 0x20, 0x54, 0x72, 0x75, 0x6e, 0x63, 0x61, - 0x74, 0x69, 0x6f, 0x6e -}; -static uint8_t test_case5_hmac_sha256_result[16] = { - 0xa3, 0xb6, 0x16, 0x74, 0x73, 0x10, 0x0e, 0xe0, - 0x6e, 0x0c, 0x79, 0x6c, 0x29, 0x55, 0x55, 0x2b -}; -static uint8_t test_case5_hmac_sha384_result[16] = { - 0x3a, 0xbf, 0x34, 0xc3, 0x50, 0x3b, 0x2a, 0x23, - 0xa4, 0x6e, 0xfc, 0x61, 0x9b, 0xae, 0xf8, 0x97 -}; - - -static uint8_t test_case6_hmac_sha2_key[131] = { - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa -}; -static uint8_t test_case6_hmac_sha2_data[54] = { - 0x54, 0x65, 0x73, 0x74, 0x20, 0x55, 0x73, 0x69, - 0x6e, 0x67, 0x20, 0x4c, 0x61, 0x72, 0x67, 0x65, - 0x72, 0x20, 0x54, 0x68, 0x61, 0x6e, 0x20, 0x42, - 0x6c, 0x6f, 0x63, 0x6b, 0x2d, 0x53, 0x69, 0x7a, - 0x65, 0x20, 0x4b, 0x65, 0x79, 0x20, 0x2d, 0x20, - 0x48, 0x61, 0x73, 0x68, 0x20, 0x4b, 0x65, 0x79, - 0x20, 0x46, 0x69, 0x72, 0x73, 0x74 -}; -static uint8_t test_case6_hmac_sha256_result[32] = { - 0x60, 0xe4, 0x31, 0x59, 0x1e, 0xe0, 0xb6, 0x7f, - 0x0d, 0x8a, 0x26, 0xaa, 0xcb, 0xf5, 0xb7, 0x7f, - 0x8e, 0x0b, 0xc6, 0x21, 0x37, 0x28, 0xc5, 0x14, - 0x05, 0x46, 0x04, 0x0f, 0x0e, 0xe3, 0x7f, 0x54 -}; -static uint8_t test_case6_hmac_sha384_result[48] = { - 0x4e, 0xce, 0x08, 0x44, 0x85, 0x81, 0x3e, 0x90, - 0x88, 0xd2, 0xc6, 0x3a, 0x04, 0x1b, 0xc5, 0xb4, - 0x4f, 0x9e, 0xf1, 0x01, 0x2a, 0x2b, 0x58, 0x8f, - 0x3c, 0xd1, 0x1f, 0x05, 0x03, 0x3a, 0xc4, 0xc6, - 0x0c, 0x2e, 0xf6, 0xab, 0x40, 0x30, 0xfe, 0x82, - 0x96, 0x24, 0x8d, 0xf1, 0x63, 0xf4, 0x49, 0x52 -}; - - -static uint8_t test_case7_hmac_sha2_key[131] = { - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa -}; - -static uint8_t test_case7_hmac_sha2_data[152] = { - 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, - 0x61, 0x20, 0x74, 0x65, 0x73, 0x74, 0x20, 0x75, - 0x73, 0x69, 0x6e, 0x67, 0x20, 0x61, 0x20, 0x6c, - 0x61, 0x72, 0x67, 0x65, 0x72, 0x20, 0x74, 0x68, - 0x61, 0x6e, 0x20, 0x62, 0x6c, 0x6f, 0x63, 0x6b, - 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x20, 0x6b, 0x65, - 0x79, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x61, 0x20, - 0x6c, 0x61, 0x72, 0x67, 0x65, 0x72, 0x20, 0x74, - 0x68, 0x61, 0x6e, 0x20, 0x62, 0x6c, 0x6f, 0x63, - 0x6b, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x20, 0x64, - 0x61, 0x74, 0x61, 0x2e, 0x20, 0x54, 0x68, 0x65, - 0x20, 0x6b, 0x65, 0x79, 0x20, 0x6e, 0x65, 0x65, - 0x64, 0x73, 0x20, 0x74, 0x6f, 0x20, 0x62, 0x65, - 0x20, 0x68, 0x61, 0x73, 0x68, 0x65, 0x64, 0x20, - 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x20, 0x62, - 0x65, 0x69, 0x6e, 0x67, 0x20, 0x75, 0x73, 0x65, - 0x64, 0x20, 0x62, 0x79, 0x20, 0x74, 0x68, 0x65, - 0x20, 0x48, 0x4d, 0x41, 0x43, 0x20, 0x61, 0x6c, - 0x67, 0x6f, 0x72, 0x69, 0x74, 0x68, 0x6d, 0x2e -}; -static uint8_t test_case7_hmac_sha256_result[32] = { - 0x9b, 0x09, 0xff, 0xa7, 0x1b, 0x94, 0x2f, 0xcb, - 0x27, 0x63, 0x5f, 0xbc, 0xd5, 0xb0, 0xe9, 0x44, - 0xbf, 0xdc, 0x63, 0x64, 0x4f, 0x07, 0x13, 0x93, - 0x8a, 0x7f, 0x51, 0x53, 0x5c, 0x3a, 0x35, 0xe2 -}; -static uint8_t test_case7_hmac_sha384_result[48] = { - 0x66, 0x17, 0x17, 0x8e, 0x94, 0x1f, 0x02, 0x0d, - 0x35, 0x1e, 0x2f, 0x25, 0x4e, 0x8f, 0xd3, 0x2c, - 0x60, 0x24, 0x20, 0xfe, 0xb0, 0xb8, 0xfb, 0x9a, - 0xdc, 0xce, 0xbb, 0x82, 0x46, 0x1e, 0x99, 0xc5, - 0xa6, 0x78, 0xcc, 0x31, 0xe7, 0x99, 0x17, 0x6d, - 0x38, 0x60, 0xe6, 0x11, 0x0c, 0x46, 0x52, 0x3e -}; - - -/*----------------------------------------------------------------------------*/ -zrtp_status_t zrtp_sha_test( zrtp_hash_t *self, - const uint8_t *test_vector, - int vector_length, - const uint8_t *test_result, - int test_length) -{ - zrtp_status_t res; - zrtp_string256_t hval = ZSTR_INIT_EMPTY(hval); - - res = self->hash_c(self, (const char*)test_vector, vector_length, (zrtp_stringn_t*)&hval); - if (zrtp_status_ok != res) { - return res; - } - - return (0 == zrtp_memcmp(hval.buffer, test_result, test_length)) ? zrtp_status_ok : zrtp_status_fail; -} - -/*----------------------------------------------------------------------------*/ -zrtp_status_t zrtp_hmac_test( zrtp_hash_t *self, - const uint8_t *key, - uint16_t key_length, - const uint8_t *test_vector, - uint16_t vector_length, - const uint8_t *test_result, - int test_length) -{ - zrtp_status_t res; - zrtp_string256_t hval = ZSTR_INIT_EMPTY(hval); - zrtp_string256_t zrtp_key = ZSTR_INIT_EMPTY(zrtp_key); - zrtp_string256_t zrtp_test_vector = ZSTR_INIT_EMPTY(zrtp_test_vector); - - zrtp_zstrncpyc(ZSTR_GV(zrtp_key), (const char*)key, key_length); - zrtp_zstrncpyc(ZSTR_GV(zrtp_test_vector), (const char*)test_vector, vector_length); - - res = self->hmac(self, ZSTR_GV(zrtp_key), ZSTR_GV(zrtp_test_vector), ZSTR_GV(hval)); - if (zrtp_status_ok != res) { - return res; - } - - return (0 == zrtp_memcmp(hval.buffer, test_result, test_length)) ? zrtp_status_ok : zrtp_status_fail; -} - -/*----------------------------------------------------------------------------*/ -zrtp_status_t zrtp_sha256_self_test(zrtp_hash_t *self) -{ - zrtp_status_t res; - ZRTP_LOG(3, (_ZTU_,"SHA256 Testing\n")); - - ZRTP_LOG(3, (_ZTU_, "\t8-bit test... ")); - res = zrtp_sha_test(self, sha256_msg_8, sizeof(sha256_msg_8), sha256_MD_8, sizeof(sha256_MD_8)); - ZRTP_LOGC(3, ("%s\n", zrtp_status_ok == res?"OK":"FALSE")); - - ZRTP_LOG(3, (_ZTU_, "\t128-bit test... ")); - res = zrtp_sha_test(self, sha256_msg_128, sizeof(sha256_msg_128), sha256_MD_128, sizeof(sha256_MD_128)); - ZRTP_LOGC(3, ("%s\n", zrtp_status_ok == res?"OK":"FALSE")); - - ZRTP_LOG(3, (_ZTU_, "\t512-bit test... ")); - res = zrtp_sha_test(self, sha256_msg_512, sizeof(sha256_msg_512), sha256_MD_512, sizeof(sha256_MD_512)); - ZRTP_LOGC(3, ("%s\n", zrtp_status_ok == res?"OK":"FALSE")); - - ZRTP_LOG(3, (_ZTU_, "\t2096-bit test... ")); - res = zrtp_sha_test(self, sha256_msg_2096, sizeof(sha256_msg_2096), sha256_MD_2096, sizeof(sha256_MD_2096)); - ZRTP_LOGC(3, ("%s\n", zrtp_status_ok == res?"OK":"FALSE")); - - return res; -} - -zrtp_status_t zrtp_sha384_self_test(zrtp_hash_t *self) -{ - return zrtp_status_ok; -} - -/*----------------------------------------------------------------------------*/ -zrtp_status_t zrtp_hmac_sha256_self_test(zrtp_hash_t *self) -{ - zrtp_status_t res; - ZRTP_LOG(3, (_ZTU_,"HMAC SHA256 Testing\n")); - - ZRTP_LOG(3, (_ZTU_, "\t1 case test... ")); - res = zrtp_hmac_test( self, - test_case1_hmac_sha2_key, - sizeof(test_case1_hmac_sha2_key), - test_case1_hmac_sha2_data, - sizeof(test_case1_hmac_sha2_data), - test_case1_hmac_sha256_result, - sizeof(test_case1_hmac_sha256_result)); - ZRTP_LOGC(3, ("%s\n", zrtp_status_ok == res?"OK":"FALSE")); - - ZRTP_LOG(3, (_ZTU_, "\t2 case test... ")); - res = zrtp_hmac_test( self, - test_case2_hmac_sha2_key, - sizeof(test_case2_hmac_sha2_key), - test_case2_hmac_sha2_data, - sizeof(test_case2_hmac_sha2_data), - test_case2_hmac_sha256_result, - sizeof(test_case2_hmac_sha256_result)); - ZRTP_LOGC(3, ("%s\n", zrtp_status_ok == res?"OK":"FALSE")); - - ZRTP_LOG(3, (_ZTU_, "\t3 case test... ")); - res = zrtp_hmac_test( self, - test_case3_hmac_sha2_key, - sizeof(test_case3_hmac_sha2_key), - test_case3_hmac_sha2_data, - sizeof(test_case3_hmac_sha2_data), - test_case3_hmac_sha256_result, - sizeof(test_case3_hmac_sha256_result)); - ZRTP_LOGC(3, ("%s\n", zrtp_status_ok == res?"OK":"FALSE")); - - ZRTP_LOG(3, (_ZTU_, "\t4 case test... ")); - res = zrtp_hmac_test(self, - test_case4_hmac_sha2_key, - sizeof(test_case4_hmac_sha2_key), - test_case4_hmac_sha2_data, - sizeof(test_case4_hmac_sha2_data), - test_case4_hmac_sha256_result, - sizeof(test_case4_hmac_sha256_result)); - ZRTP_LOGC(3, ("%s\n", zrtp_status_ok == res?"OK":"FALSE")); - - ZRTP_LOG(3, (_ZTU_, "\t5 case test...")); - res = zrtp_hmac_test(self, - test_case5_hmac_sha2_key, - sizeof(test_case5_hmac_sha2_key), - test_case5_hmac_sha2_data, - sizeof(test_case5_hmac_sha2_data), - test_case5_hmac_sha256_result, - sizeof(test_case5_hmac_sha256_result)); - ZRTP_LOGC(3, ("%s\n", zrtp_status_ok == res?"OK":"FALSE")); - - ZRTP_LOG(3, (_ZTU_, "\t6 case test... ")); - res = zrtp_hmac_test(self, - test_case6_hmac_sha2_key, - sizeof(test_case6_hmac_sha2_key), - test_case6_hmac_sha2_data, - sizeof(test_case6_hmac_sha2_data), - test_case6_hmac_sha256_result, - sizeof(test_case6_hmac_sha256_result)); - ZRTP_LOGC(3, ("%s\n", zrtp_status_ok == res?"OK":"FALSE")); - - ZRTP_LOG(3, (_ZTU_, "\t7 case test...")); - res = zrtp_hmac_test(self, - test_case7_hmac_sha2_key, - sizeof(test_case7_hmac_sha2_key), - test_case7_hmac_sha2_data, - sizeof(test_case7_hmac_sha2_data), - test_case7_hmac_sha256_result, - sizeof(test_case7_hmac_sha256_result)); - ZRTP_LOGC(3, ("%s\n", zrtp_status_ok == res?"OK":"FALSE")); - - return res; -} - -zrtp_status_t zrtp_hmac_sha384_self_test(zrtp_hash_t *self) -{ - zrtp_status_t res; - ZRTP_LOG(3, (_ZTU_,"HMAC SHA384 Testing\n")); - - ZRTP_LOG(3, (_ZTU_, "\t1 case test... ")); - res = zrtp_hmac_test( self, - test_case1_hmac_sha2_key, - sizeof(test_case1_hmac_sha2_key), - test_case1_hmac_sha2_data, - sizeof(test_case1_hmac_sha2_data), - test_case1_hmac_sha384_result, - sizeof(test_case1_hmac_sha384_result)); - ZRTP_LOGC(3, ("%s\n", zrtp_status_ok == res?"OK":"FALSE")); - - ZRTP_LOG(3, (_ZTU_, "\t2 case test... ")); - res = zrtp_hmac_test( self, - test_case2_hmac_sha2_key, - sizeof(test_case2_hmac_sha2_key), - test_case2_hmac_sha2_data, - sizeof(test_case2_hmac_sha2_data), - test_case2_hmac_sha384_result, - sizeof(test_case2_hmac_sha384_result)); - ZRTP_LOGC(3, ("%s\n", zrtp_status_ok == res?"OK":"FALSE")); - - ZRTP_LOG(3, (_ZTU_, "\t3 case test... ")); - res = zrtp_hmac_test( self, - test_case3_hmac_sha2_key, - sizeof(test_case3_hmac_sha2_key), - test_case3_hmac_sha2_data, - sizeof(test_case3_hmac_sha2_data), - test_case3_hmac_sha384_result, - sizeof(test_case3_hmac_sha384_result)); - ZRTP_LOGC(3, ("%s\n", zrtp_status_ok == res?"OK":"FALSE")); - - ZRTP_LOG(3, (_ZTU_, "\t4 case test... ")); - res = zrtp_hmac_test(self, - test_case4_hmac_sha2_key, - sizeof(test_case4_hmac_sha2_key), - test_case4_hmac_sha2_data, - sizeof(test_case4_hmac_sha2_data), - test_case4_hmac_sha384_result, - sizeof(test_case4_hmac_sha384_result)); - ZRTP_LOGC(3, ("%s\n", zrtp_status_ok == res?"OK":"FALSE")); - - ZRTP_LOG(3, (_ZTU_, "\t5 case test...")); - res = zrtp_hmac_test(self, - test_case5_hmac_sha2_key, - sizeof(test_case5_hmac_sha2_key), - test_case5_hmac_sha2_data, - sizeof(test_case5_hmac_sha2_data), - test_case5_hmac_sha384_result, - sizeof(test_case5_hmac_sha384_result)); - ZRTP_LOGC(3, ("%s\n", zrtp_status_ok == res?"OK":"FALSE")); - - ZRTP_LOG(3, (_ZTU_, "\t6 case test... ")); - res = zrtp_hmac_test(self, - test_case6_hmac_sha2_key, - sizeof(test_case6_hmac_sha2_key), - test_case6_hmac_sha2_data, - sizeof(test_case6_hmac_sha2_data), - test_case6_hmac_sha384_result, - sizeof(test_case6_hmac_sha384_result)); - ZRTP_LOGC(3, ("%s\n", zrtp_status_ok == res?"OK":"FALSE")); - - ZRTP_LOG(3, (_ZTU_, "\t7 case test...")); - res = zrtp_hmac_test(self, - test_case7_hmac_sha2_key, - sizeof(test_case7_hmac_sha2_key), - test_case7_hmac_sha2_data, - sizeof(test_case7_hmac_sha2_data), - test_case7_hmac_sha384_result, - sizeof(test_case7_hmac_sha384_result)); - ZRTP_LOGC(3, ("%s\n", zrtp_status_ok == res?"OK":"FALSE")); - - return res; -} - -/*----------------------------------------------------------------------------*/ -zrtp_status_t zrtp_sha1_self_test(zrtp_hash_t *self) -{ - zrtp_status_t res; - ZRTP_LOG(3, (_ZTU_,"SHA1 Testing\n")); - - ZRTP_LOG(3, (_ZTU_, "\t8-bit test... ")); - res = zrtp_sha_test(self, sha1_msg_8, sizeof(sha1_msg_8), sha1_MD_8, ZRTP_SRTP_HASH_HMAC_SHA1); - ZRTP_LOGC(3, ("%s\n", zrtp_status_ok == res?"OK":"FALSE")); - - ZRTP_LOG(3, (_ZTU_, "\t128-bit test... ")); - res = zrtp_sha_test(self, sha1_msg_128, sizeof(sha1_msg_128), sha1_MD_128, ZRTP_SRTP_HASH_HMAC_SHA1); - ZRTP_LOGC(3, ("%s\n", zrtp_status_ok == res?"OK":"FALSE")); - - ZRTP_LOG(3, (_ZTU_, "\t512-bit test... ")); - res = zrtp_sha_test(self, sha1_msg_512, sizeof(sha1_msg_512), sha1_MD_512, ZRTP_SRTP_HASH_HMAC_SHA1); - ZRTP_LOGC(3, ("%s\n", zrtp_status_ok == res?"OK":"FALSE")); - - ZRTP_LOG(3, (_ZTU_, "\t2096-bit test... ")); - res = zrtp_sha_test(self, sha1_msg_2096, sizeof(sha1_msg_2096), sha1_MD_2096, ZRTP_SRTP_HASH_HMAC_SHA1); - ZRTP_LOGC(3, ("%s\n", zrtp_status_ok == res?"OK":"FALSE")); - - return res; -} - -/*----------------------------------------------------------------------------*/ -zrtp_status_t zrtp_hmac_sha1_self_test(zrtp_hash_t *self) -{ - zrtp_status_t res; - ZRTP_LOG(3, (_ZTU_,"HMAC SHA1 Testing\n")); - - ZRTP_LOG(3, (_ZTU_, "\t1 case test... ")); - res = zrtp_hmac_test(self, - test_case1_hmac_sha1_key, - sizeof(test_case1_hmac_sha1_key), - test_case1_hmac_sha1_data, - sizeof(test_case1_hmac_sha1_data), - test_case1_hmac_sha1_result, - ZRTP_SRTP_HASH_HMAC_SHA1); - ZRTP_LOGC(3, ("%s\n", zrtp_status_ok == res?"OK":"FALSE")); - - ZRTP_LOG(3, (_ZTU_, "\t2 case test... ")); - res = zrtp_hmac_test(self, - test_case2_hmac_sha1_key, - sizeof(test_case2_hmac_sha1_key), - test_case2_hmac_sha1_data, - sizeof(test_case2_hmac_sha1_data), - test_case2_hmac_sha1_result, - ZRTP_SRTP_HASH_HMAC_SHA1); - ZRTP_LOGC(3, ("%s\n", zrtp_status_ok == res?"OK":"FALSE")); - - ZRTP_LOG(3, (_ZTU_, "\t3 case test... ")); - res = zrtp_hmac_test(self, - test_case3_hmac_sha1_key, - sizeof(test_case3_hmac_sha1_key), - test_case3_hmac_sha1_data, - sizeof(test_case3_hmac_sha1_data), - test_case3_hmac_sha1_result, - ZRTP_SRTP_HASH_HMAC_SHA1); - ZRTP_LOGC(3, ("%s\n", zrtp_status_ok == res?"OK":"FALSE")); - - ZRTP_LOG(3, (_ZTU_, "\t4 case test... ")); - res = zrtp_hmac_test(self, - test_case4_hmac_sha1_key, - sizeof(test_case4_hmac_sha1_key), - test_case4_hmac_sha1_data, - sizeof(test_case4_hmac_sha1_data), - test_case4_hmac_sha1_result, - ZRTP_SRTP_HASH_HMAC_SHA1); - ZRTP_LOGC(3, ("%s\n", zrtp_status_ok == res?"OK":"FALSE")); - - ZRTP_LOG(3, (_ZTU_, "\t5 case test... ")); - res = zrtp_hmac_test(self, - test_case5_hmac_sha1_key, - sizeof(test_case5_hmac_sha1_key), - test_case5_hmac_sha1_data, - sizeof(test_case5_hmac_sha1_data), - test_case5_hmac_sha1_result, - ZRTP_SRTP_HASH_HMAC_SHA1); - ZRTP_LOGC(3, ("%s\n", zrtp_status_ok == res?"OK":"FALSE")); - - ZRTP_LOG(3, (_ZTU_, "\t6 case test... ")); - res = zrtp_hmac_test(self, - test_case6_hmac_sha1_key, - sizeof(test_case6_hmac_sha1_key), - test_case6_hmac_sha1_data, - sizeof(test_case6_hmac_sha1_data), - test_case6_hmac_sha1_result, - ZRTP_SRTP_HASH_HMAC_SHA1); - ZRTP_LOGC(3, ("%s\n", zrtp_status_ok == res?"OK":"FALSE")); - - ZRTP_LOG(3, (_ZTU_, "\t7 case test... ")); - res = zrtp_hmac_test(self, - test_case7_hmac_sha1_key, - sizeof(test_case7_hmac_sha1_key), - test_case7_hmac_sha1_data, - sizeof(test_case7_hmac_sha1_data), - test_case7_hmac_sha1_result, - ZRTP_SRTP_HASH_HMAC_SHA1); - ZRTP_LOGC(3, ("%s\n", zrtp_status_ok == res?"OK":"FALSE")); - - return res; -} - -/*----------------------------------------------------------------------------*/ -zrtp_status_t zrtp_defaults_hash(zrtp_global_t* global_ctx) -{ - zrtp_hash_t* hash_sha384 = zrtp_sys_alloc(sizeof(zrtp_hash_t)); - zrtp_hash_t* hash_sha256 = zrtp_sys_alloc(sizeof(zrtp_hash_t)); - zrtp_hash_t* hash_sha1 = zrtp_sys_alloc(sizeof(zrtp_hash_t)); - if (!hash_sha256 || !hash_sha1 || !hash_sha384) { - if (hash_sha384) { - zrtp_sys_free(hash_sha384); - } - if (hash_sha256) { - zrtp_sys_free(hash_sha256); - } - if (hash_sha1) { - zrtp_sys_free(hash_sha1); - } - return zrtp_status_alloc_fail; - } - - zrtp_memset(hash_sha384, 0, sizeof(zrtp_hash_t)); - zrtp_memset(hash_sha256, 0, sizeof(zrtp_hash_t)); - zrtp_memset(hash_sha1, 0, sizeof(zrtp_hash_t)); - - zrtp_memcpy(hash_sha384->base.type, ZRTP_S384, ZRTP_COMP_TYPE_SIZE); - hash_sha384->base.id = ZRTP_HASH_SHA384; - hash_sha384->base.zrtp = global_ctx; - hash_sha384->block_length = SHA384_BLOCK_SIZE; - hash_sha384->digest_length = SHA384_DIGEST_SIZE; - - hash_sha384->hash_begin = zrtp_sha_begin; - hash_sha384->hash_update = zrtp_sha_update; - hash_sha384->hash_end = zrtp_sha_end; - hash_sha384->hash = zrtp_sha; - hash_sha384->hash_c = zrtp_sha_c; - hash_sha384->hash_self_test = zrtp_sha384_self_test; - - hash_sha384->hmac_begin_c = zrtp_hmac_sha384_begin_c; - hash_sha384->hmac_begin = zrtp_hmac_begin; - hash_sha384->hmac_update = zrtp_hmac_update; - hash_sha384->hmac_end = zrtp_hmac_end; - hash_sha384->hmac = zrtp_hmac; - hash_sha384->hmac_c = zrtp_hmac_c; - hash_sha384->hmac_truncated = zrtp_hmac_truncated; - hash_sha384->hmac_truncated_c = zrtp_hmac_truncated_c; - hash_sha384->hmac_self_test = zrtp_hmac_sha384_self_test; - - zrtp_memcpy(hash_sha256->base.type, ZRTP_S256, ZRTP_COMP_TYPE_SIZE); - hash_sha256->base.id = ZRTP_HASH_SHA256; - hash_sha256->base.zrtp = global_ctx; - hash_sha256->block_length = SHA256_BLOCK_SIZE; - hash_sha256->digest_length = SHA256_DIGEST_SIZE; - - hash_sha256->hash_begin = zrtp_sha_begin; - hash_sha256->hash_update = zrtp_sha_update; - hash_sha256->hash_end = zrtp_sha_end; - hash_sha256->hash = zrtp_sha; - hash_sha256->hash_c = zrtp_sha_c; - hash_sha256->hash_self_test = zrtp_sha256_self_test; - - hash_sha256->hmac_begin_c = zrtp_hmac_sha256_begin_c; - hash_sha256->hmac_begin = zrtp_hmac_begin; - hash_sha256->hmac_update = zrtp_hmac_update; - hash_sha256->hmac_end = zrtp_hmac_end; - hash_sha256->hmac = zrtp_hmac; - hash_sha256->hmac_c = zrtp_hmac_c; - hash_sha256->hmac_truncated = zrtp_hmac_truncated; - hash_sha256->hmac_truncated_c = zrtp_hmac_truncated_c; - hash_sha256->hmac_self_test = zrtp_hmac_sha256_self_test; - - - zrtp_memcpy(hash_sha1->base.type, ZRTP_S160, ZRTP_COMP_TYPE_SIZE); - hash_sha1->base.id = ZRTP_SRTP_HASH_HMAC_SHA1; - hash_sha1->base.zrtp = global_ctx; - hash_sha1->block_length = SHA1_BLOCK_SIZE; - hash_sha1->digest_length = SHA1_DIGEST_SIZE; - - hash_sha1->hash_begin = zrtp_sha_begin; - hash_sha1->hash_update = zrtp_sha_update; - hash_sha1->hash_end = zrtp_sha_end; - hash_sha1->hash = zrtp_sha; - hash_sha1->hash_c = zrtp_sha_c; - hash_sha1->hash_self_test = zrtp_sha1_self_test; - - hash_sha1->hmac_begin_c = zrtp_hmac_sha1_begin_c; - hash_sha1->hmac_begin = zrtp_hmac_begin; - hash_sha1->hmac_update = zrtp_hmac_update; - hash_sha1->hmac_end = zrtp_hmac_end; - hash_sha1->hmac = zrtp_hmac; - hash_sha1->hmac_c = zrtp_hmac_c; - hash_sha1->hmac_truncated = zrtp_hmac_truncated; - hash_sha1->hmac_truncated_c = zrtp_hmac_truncated_c; - hash_sha1->hmac_self_test = zrtp_hmac_sha1_self_test; - - zrtp_comp_register(ZRTP_CC_HASH, hash_sha384, global_ctx); - zrtp_comp_register(ZRTP_CC_HASH, hash_sha256, global_ctx); - zrtp_comp_register(ZRTP_CC_HASH, hash_sha1, global_ctx); - - return zrtp_status_ok; -} diff --git a/libs/libzrtp/src/zrtp_crypto_pk.c b/libs/libzrtp/src/zrtp_crypto_pk.c deleted file mode 100644 index 4130d6cbed..0000000000 --- a/libs/libzrtp/src/zrtp_crypto_pk.c +++ /dev/null @@ -1,351 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - -#include "zrtp.h" - -#define _ZTU_ "zrtp dh" - -/*============================================================================*/ -/* Global DH Functions */ -/*============================================================================*/ - -/*----------------------------------------------------------------------------*/ -static zrtp_status_t zrtp_dh_init(void *s) -{ - struct BigNum* p = NULL; - struct BigNum* p_1 = NULL; - uint8_t* p_data = NULL; - unsigned int p_data_length = 0; - zrtp_pk_scheme_t *self = (zrtp_pk_scheme_t *) s; - - switch (self->base.id) { - case ZRTP_PKTYPE_DH2048: - p = &self->base.zrtp->P_2048; - p_1 = &self->base.zrtp->P_2048_1; - p_data = self->base.zrtp->P_2048_data; - p_data_length = sizeof(self->base.zrtp->P_2048_data); - break; - case ZRTP_PKTYPE_DH3072: - p = &self->base.zrtp->P_3072; - p_1 = &self->base.zrtp->P_3072_1; - p_data = self->base.zrtp->P_3072_data; - p_data_length = sizeof(self->base.zrtp->P_3072_data); - break; - default: - return zrtp_status_bad_param; - } - - bnBegin(p); - bnInsertBigBytes(p, (const unsigned char *)p_data, 0, p_data_length); - - bnBegin(p_1); - bnCopy(p_1, p); - bnSub(p_1, &self->base.zrtp->one); - - return zrtp_status_ok; -} - -/*----------------------------------------------------------------------------*/ -static zrtp_status_t zrtp_dh_free(void *s) -{ - zrtp_pk_scheme_t *self = (zrtp_pk_scheme_t *) s; - switch (self->base.id) { - case ZRTP_PKTYPE_DH2048: - bnEnd(&self->base.zrtp->P_2048); - bnEnd(&self->base.zrtp->P_2048_1); - break; - case ZRTP_PKTYPE_DH3072: - bnEnd(&self->base.zrtp->P_3072); - bnEnd(&self->base.zrtp->P_3072_1); - break; - default: - return zrtp_status_bad_param; - } - - return zrtp_status_ok; -} - -/*----------------------------------------------------------------------------*/ -static struct BigNum* _zrtp_get_p(zrtp_pk_scheme_t *self) -{ - struct BigNum* p = NULL; - switch (self->base.id) { - case ZRTP_PKTYPE_DH2048: - p = &self->base.zrtp->P_2048; - break; - case ZRTP_PKTYPE_DH3072: - p = &self->base.zrtp->P_3072; - break; - default: - break; - } - - return p; -} - -static zrtp_status_t zrtp_dh_initialize( zrtp_pk_scheme_t *self, - zrtp_dh_crypto_context_t *dh_cc) -{ - unsigned char* buffer = zrtp_sys_alloc(sizeof(zrtp_uchar128_t)); - struct BigNum* p = _zrtp_get_p(self); - zrtp_time_t start_ts = zrtp_time_now(); - - ZRTP_LOG(1,(_ZTU_,"\tDH TEST: %.4s zrtp_dh_initialize() START. now=%llums.\n", self->base.type, start_ts)); - - if (!buffer) { - return zrtp_status_alloc_fail; - } - if (!p) { - zrtp_sys_free(buffer); - return zrtp_status_bad_param; - } - - if (64 != zrtp_randstr(self->base.zrtp, buffer, 64)) { - zrtp_sys_free(buffer); - return zrtp_status_rng_fail; - } - - bnBegin(&dh_cc->sv); - bnInsertBigBytes(&dh_cc->sv, (const unsigned char *)buffer, 0, self->sv_length); - bnBegin(&dh_cc->pv); - bnExpMod(&dh_cc->pv, &self->base.zrtp->G, &dh_cc->sv, p); - - zrtp_sys_free(buffer); - - ZRTP_LOG(1,(_ZTU_,"\tDH TEST: zrtp_dh_initialize() for %.4s was executed ts=%llums d=%llums.\n", self->base.type, zrtp_time_now(), zrtp_time_now()-start_ts)); - return zrtp_status_ok; -} - -/*----------------------------------------------------------------------------*/ -static zrtp_status_t zrtp_dh_compute( zrtp_pk_scheme_t *self, - zrtp_dh_crypto_context_t *dh_cc, - struct BigNum *dhresult, - struct BigNum *pv) -{ - struct BigNum* p = _zrtp_get_p(self); - zrtp_time_t start_ts = zrtp_time_now(); - if (!p) { - return zrtp_status_bad_param; - } - - ZRTP_LOG(1,(_ZTU_,"\tDH TEST: %.4s zrtp_dh_compute() START. now=%llums.\n", self->base.type, start_ts)); - - bnExpMod(dhresult, pv, &dh_cc->sv, p); - ZRTP_LOG(1,(_ZTU_,"\tDH TEST: zrtp_dh_compute() for %.4s was executed ts=%llums d=%llums.\n", self->base.type, zrtp_time_now(), zrtp_time_now()-start_ts)); - return zrtp_status_ok; -} - -/*----------------------------------------------------------------------------*/ -static zrtp_status_t zrtp_dh_validate(zrtp_pk_scheme_t *self, struct BigNum *pv) -{ - struct BigNum* p = _zrtp_get_p(self); - if (!p) { - return zrtp_status_bad_param; - } - - if (!pv || 0 == bnCmp(pv, &self->base.zrtp->one) || 0 == bnCmp(pv, p)) { - return zrtp_status_fail; - } else { - return zrtp_status_ok; - } -} - -/*----------------------------------------------------------------------------*/ -static zrtp_status_t zrtp_dh_self_test(zrtp_pk_scheme_t *self) -{ - zrtp_status_t s = zrtp_status_ok; - zrtp_dh_crypto_context_t alice_cc; - zrtp_dh_crypto_context_t bob_cc; - struct BigNum alice_k; - struct BigNum bob_k; - zrtp_time_t start_ts = zrtp_time_now(); - - ZRTP_LOG(3, (_ZTU_, "PKS %.4s testing... ", self->base.type)); - - bnBegin(&alice_k); - bnBegin(&bob_k); - - do { - /* Both sides initalise DH schemes and compute secret and public values. */ - s = self->initialize(self, &alice_cc); - if (zrtp_status_ok != s) { - break; - } - s = self->initialize(self, &bob_cc); - if (zrtp_status_ok != s) { - break; - } - - /* Both sides validate public values. (to provide exact performance estimation) */ - s = self->validate(self, &bob_cc.pv); - if (zrtp_status_ok != s) { - break; - } - s = self->validate(self, &alice_cc.pv); - if (zrtp_status_ok != s) { - break; - } - - /* Compute secret keys and compare them. */ - s = self->compute(self, &alice_cc, &alice_k, &bob_cc.pv); - if (zrtp_status_ok != s) { - break; - } - s= self->compute(self, &bob_cc, &bob_k, &alice_cc.pv); - if (zrtp_status_ok != s) { - break; - } - - s = (0 == bnCmp(&alice_k, &bob_k)) ? zrtp_status_ok : zrtp_status_algo_fail; - } while (0); - - bnEnd(&alice_k); - bnEnd(&bob_k); - - ZRTP_LOGC(3, ("%s (%llu ms)\n", zrtp_log_status2str(s), (zrtp_time_now()-start_ts)/2)); - - return s; -} - -/*----------------------------------------------------------------------------*/ -extern zrtp_status_t zrtp_defaults_ec_pkt(zrtp_global_t* zrtp); - -zrtp_status_t zrtp_defaults_pkt(zrtp_global_t* zrtp) -{ - zrtp_pk_scheme_t* presh = zrtp_sys_alloc(sizeof(zrtp_pk_scheme_t)); - zrtp_pk_scheme_t* dh2048 = zrtp_sys_alloc(sizeof(zrtp_pk_scheme_t)); - zrtp_pk_scheme_t* dh3072 = zrtp_sys_alloc(sizeof(zrtp_pk_scheme_t)); - zrtp_pk_scheme_t* multi = zrtp_sys_alloc(sizeof(zrtp_pk_scheme_t)); - - uint8_t P_2048_data[] = - { - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2, 0x21, 0x68, 0xC2, 0x34, - 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, - 0x02, 0x0B, 0xBE, 0xA6, 0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD, - 0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D, 0xF2, 0x5F, 0x14, 0x37, - 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45, 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, - 0xF4, 0x4C, 0x42, 0xE9, 0xA6, 0x37, 0xED, 0x6B, 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED, - 0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5, 0xAE, 0x9F, 0x24, 0x11, 0x7C, 0x4B, 0x1F, 0xE6, - 0x49, 0x28, 0x66, 0x51, 0xEC, 0xE4, 0x5B, 0x3D, 0xC2, 0x00, 0x7C, 0xB8, 0xA1, 0x63, 0xBF, 0x05, - 0x98, 0xDA, 0x48, 0x36, 0x1C, 0x55, 0xD3, 0x9A, 0x69, 0x16, 0x3F, 0xA8, 0xFD, 0x24, 0xCF, 0x5F, - 0x83, 0x65, 0x5D, 0x23, 0xDC, 0xA3, 0xAD, 0x96, 0x1C, 0x62, 0xF3, 0x56, 0x20, 0x85, 0x52, 0xBB, - 0x9E, 0xD5, 0x29, 0x07, 0x70, 0x96, 0x96, 0x6D, 0x67, 0x0C, 0x35, 0x4E, 0x4A, 0xBC, 0x98, 0x04, - 0xF1, 0x74, 0x6C, 0x08, 0xCA, 0x18, 0x21, 0x7C, 0x32, 0x90, 0x5E, 0x46, 0x2E, 0x36, 0xCE, 0x3B, - 0xE3, 0x9E, 0x77, 0x2C, 0x18, 0x0E, 0x86, 0x03, 0x9B, 0x27, 0x83, 0xA2, 0xEC, 0x07, 0xA2, 0x8F, - 0xB5, 0xC5, 0x5D, 0xF0, 0x6F, 0x4C, 0x52, 0xC9, 0xDE, 0x2B, 0xCB, 0xF6, 0x95, 0x58, 0x17, 0x18, - 0x39, 0x95, 0x49, 0x7C, 0xEA, 0x95, 0x6A, 0xE5, 0x15, 0xD2, 0x26, 0x18, 0x98, 0xFA, 0x05, 0x10, - 0x15, 0x72, 0x8E, 0x5A, 0x8A, 0xAC, 0xAA, 0x68, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF - }; - - uint8_t P_3072_data[] = - { - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2, 0x21, 0x68, 0xC2, 0x34, - 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, - 0x02, 0x0B, 0xBE, 0xA6, 0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD, - 0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D, 0xF2, 0x5F, 0x14, 0x37, - 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45, 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, - 0xF4, 0x4C, 0x42, 0xE9, 0xA6, 0x37, 0xED, 0x6B, 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED, - 0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5, 0xAE, 0x9F, 0x24, 0x11, 0x7C, 0x4B, 0x1F, 0xE6, - 0x49, 0x28, 0x66, 0x51, 0xEC, 0xE4, 0x5B, 0x3D, 0xC2, 0x00, 0x7C, 0xB8, 0xA1, 0x63, 0xBF, 0x05, - 0x98, 0xDA, 0x48, 0x36, 0x1C, 0x55, 0xD3, 0x9A, 0x69, 0x16, 0x3F, 0xA8, 0xFD, 0x24, 0xCF, 0x5F, - 0x83, 0x65, 0x5D, 0x23, 0xDC, 0xA3, 0xAD, 0x96, 0x1C, 0x62, 0xF3, 0x56, 0x20, 0x85, 0x52, 0xBB, - 0x9E, 0xD5, 0x29, 0x07, 0x70, 0x96, 0x96, 0x6D, 0x67, 0x0C, 0x35, 0x4E, 0x4A, 0xBC, 0x98, 0x04, - 0xF1, 0x74, 0x6C, 0x08, 0xCA, 0x18, 0x21, 0x7C, 0x32, 0x90, 0x5E, 0x46, 0x2E, 0x36, 0xCE, 0x3B, - 0xE3, 0x9E, 0x77, 0x2C, 0x18, 0x0E, 0x86, 0x03, 0x9B, 0x27, 0x83, 0xA2, 0xEC, 0x07, 0xA2, 0x8F, - 0xB5, 0xC5, 0x5D, 0xF0, 0x6F, 0x4C, 0x52, 0xC9, 0xDE, 0x2B, 0xCB, 0xF6, 0x95, 0x58, 0x17, 0x18, - 0x39, 0x95, 0x49, 0x7C, 0xEA, 0x95, 0x6A, 0xE5, 0x15, 0xD2, 0x26, 0x18, 0x98, 0xFA, 0x05, 0x10, - 0x15, 0x72, 0x8E, 0x5A, 0x8A, 0xAA, 0xC4, 0x2D, 0xAD, 0x33, 0x17, 0x0D, 0x04, 0x50, 0x7A, 0x33, - 0xA8, 0x55, 0x21, 0xAB, 0xDF, 0x1C, 0xBA, 0x64, 0xEC, 0xFB, 0x85, 0x04, 0x58, 0xDB, 0xEF, 0x0A, - 0x8A, 0xEA, 0x71, 0x57, 0x5D, 0x06, 0x0C, 0x7D, 0xB3, 0x97, 0x0F, 0x85, 0xA6, 0xE1, 0xE4, 0xC7, - 0xAB, 0xF5, 0xAE, 0x8C, 0xDB, 0x09, 0x33, 0xD7, 0x1E, 0x8C, 0x94, 0xE0, 0x4A, 0x25, 0x61, 0x9D, - 0xCE, 0xE3, 0xD2, 0x26, 0x1A, 0xD2, 0xEE, 0x6B, 0xF1, 0x2F, 0xFA, 0x06, 0xD9, 0x8A, 0x08, 0x64, - 0xD8, 0x76, 0x02, 0x73, 0x3E, 0xC8, 0x6A, 0x64, 0x52, 0x1F, 0x2B, 0x18, 0x17, 0x7B, 0x20, 0x0C, - 0xBB, 0xE1, 0x17, 0x57, 0x7A, 0x61, 0x5D, 0x6C, 0x77, 0x09, 0x88, 0xC0, 0xBA, 0xD9, 0x46, 0xE2, - 0x08, 0xE2, 0x4F, 0xA0, 0x74, 0xE5, 0xAB, 0x31, 0x43, 0xDB, 0x5B, 0xFC, 0xE0, 0xFD, 0x10, 0x8E, - 0x4B, 0x82, 0xD1, 0x20, 0xA9, 0x3A, 0xD2, 0xCA, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF - }; - - if (!dh2048 || !dh3072 || !presh || !multi) { - if (presh) { - zrtp_sys_free(presh); - } - if (dh2048) { - zrtp_sys_free(dh2048); - } - if (dh3072) { - zrtp_sys_free(dh3072); - } - if (multi) { - zrtp_sys_free(multi); - } - return zrtp_status_alloc_fail; - } - - zrtp_memset(dh3072, 0, sizeof(zrtp_pk_scheme_t)); - zrtp_memcpy(dh3072->base.type, ZRTP_DH3K, ZRTP_COMP_TYPE_SIZE); - dh3072->base.id = ZRTP_PKTYPE_DH3072; - dh3072->base.zrtp = zrtp; - dh3072->sv_length = 256/8; - dh3072->pv_length = 384; - dh3072->base.init = zrtp_dh_init; - dh3072->base.free = zrtp_dh_free; - dh3072->initialize = zrtp_dh_initialize; - dh3072->compute = zrtp_dh_compute; - dh3072->validate = zrtp_dh_validate; - dh3072->self_test = zrtp_dh_self_test; - zrtp_memcpy(zrtp->P_3072_data, P_3072_data, sizeof(P_3072_data)); - zrtp_comp_register(ZRTP_CC_PKT, dh3072, zrtp); - - zrtp_memset(dh2048, 0, sizeof(zrtp_pk_scheme_t)); - zrtp_memcpy(dh2048->base.type, ZRTP_DH2K, ZRTP_COMP_TYPE_SIZE); - dh2048->base.id = ZRTP_PKTYPE_DH2048; - dh2048->base.zrtp = zrtp; - dh2048->sv_length = 256/8; - dh2048->pv_length = 256; - dh2048->base.init = zrtp_dh_init; - dh2048->base.free = zrtp_dh_free; - dh2048->initialize = zrtp_dh_initialize; - dh2048->compute = zrtp_dh_compute; - dh2048->validate = zrtp_dh_validate; - dh2048->self_test = zrtp_dh_self_test; - zrtp_memcpy(zrtp->P_2048_data, P_2048_data, sizeof(P_2048_data)); - zrtp_comp_register(ZRTP_CC_PKT, dh2048, zrtp); - - zrtp_memset(multi, 0, sizeof(zrtp_pk_scheme_t)); - zrtp_memcpy(multi->base.type, ZRTP_MULT, ZRTP_COMP_TYPE_SIZE); - multi->base.id = ZRTP_PKTYPE_MULT; - zrtp_comp_register(ZRTP_CC_PKT, multi, zrtp); - - zrtp_memset(presh, 0, sizeof(zrtp_pk_scheme_t)); - zrtp_memcpy(presh->base.type, ZRTP_PRESHARED, ZRTP_COMP_TYPE_SIZE); - presh->base.id = ZRTP_PKTYPE_PRESH; - zrtp_comp_register(ZRTP_CC_PKT, presh, zrtp); - - return zrtp_defaults_ec_pkt(zrtp); -} - -/*----------------------------------------------------------------------------*/ -zrtp_status_t zrtp_prepare_pkt(zrtp_global_t* zrtp) -{ - bnInit(); - bnBegin(&zrtp->one); - bnSetQ(&zrtp->one, 1); - bnBegin(&zrtp->G); - bnSetQ(&zrtp->G, 2); - - return zrtp_status_ok; -} - -zrtp_status_t zrtp_done_pkt(zrtp_global_t* zrtp) -{ - bnEnd(&zrtp->one); - bnEnd(&zrtp->G); - - return zrtp_status_ok; -} diff --git a/libs/libzrtp/src/zrtp_crypto_sas.c b/libs/libzrtp/src/zrtp_crypto_sas.c deleted file mode 100644 index 93fc851dee..0000000000 --- a/libs/libzrtp/src/zrtp_crypto_sas.c +++ /dev/null @@ -1,745 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - -#include "zrtp.h" - -/* These 3-syllable words are no longer than 11 characters. */ -extern uint8_t hash_word_list_odd[256][12]; - -/* These 2-syllable words are no longer than 9 characters. */ -extern uint8_t hash_word_list_even[256][10]; - -/*----------------------------------------------------------------------------*/ -/* - * copyright 2002, 2003 Bryce "Zooko" Wilcox-O'Hearn - * mailto:zooko@zooko.com - * - * See the end of this file for the free software, open source license (BSD-style). - */ - -/** - * Copyright (c) 2002 Bryce "Zooko" Wilcox-O'Hearn - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software to deal in this software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of this software, and to permit - * persons to whom this software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of this software. - * - * THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THIS SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THIS SOFTWARE. - */ - -zrtp_status_t b2a(zrtp_stringn_t *os, zrtp_stringn_t *result) -{ - static const char chars[]="ybndrfg8ejkmcpqxot1uwisza345h769"; - - if (!os || !result) { - return zrtp_status_bad_param; - } else { - /* pointer into the os buffer, initially pointing to the "one-past-the-end" octet */ - const uint8_t* osp = (uint8_t*)os->buffer + os->length; - /* pointer into the result buffer, initially pointing to the "one-past-the-end" quintet */ - uint8_t* resp; - /* to hold up to 32 bits worth of the input */ - uint32_t x = 0; - - result->length = os->length*8; - result->length = (result->length % 5) ? ((result->length/5) + 1) : result->length/5; - - /* pointer into the result buffer, initially pointing to the "one-past-the-end" quintet */ - resp = (uint8_t*)result->buffer + result->length; - - /* Now this is a real live Duff's device. You gotta love it. */ - switch ((osp - (uint8_t*)os->buffer) % 5) { - case 0: - do { - x = *--osp; - *--resp = chars[x % 32]; /* The least sig 5 bits go into the final quintet. */ - x /= 32; /* ... now we have 3 bits worth in x... */ - case 4: - x |= ((uint32_t)(*--osp)) << 3; /* ... now we have 11 bits worth in x... */ - *--resp = chars[x % 32]; - x /= 32; /* ... now we have 6 bits worth in x... */ - *--resp = chars[x % 32]; - x /= 32; /* ... now we have 1 bits worth in x... */ - case 3: - /* The 8 bits from the 2-indexed octet. So now we have 9 bits worth in x... */ - x |= ((uint32_t)(*--osp)) << 1; - *--resp = chars[x % 32]; - x /= 32; /* ... now we have 4 bits worth in x... */ - case 2: - /* The 8 bits from the 1-indexed octet. So now we have 12 bits worth in x... */ - x |= ((uint32_t)(*--osp)) << 4; - *--resp = chars[x%32]; - x /= 32; /* ... now we have 7 bits worth in x... */ - *--resp = chars[x%32]; - x /= 32; /* ... now we have 2 bits worth in x... */ - case 1: - /* The 8 bits from the 0-indexed octet. So now we have 10 bits worth in x... */ - x |= ((uint32_t)(*--osp)) << 2; - *--resp = chars[x%32]; - x /= 32; /* ... now we have 5 bits worth in x... */ - *--resp = chars[x]; - } while (osp > (const uint8_t *)os->buffer); - } /* switch ((osp - os.buf) % 5) */ - - return zrtp_status_ok; - } -} - -/*----------------------------------------------------------------------------*/ -static zrtp_status_t SAS32_compute( zrtp_sas_scheme_t *self, - zrtp_stream_t *stream, - zrtp_hash_t *hash, - uint8_t is_transferred ) -{ - zrtp_session_t *session = stream->session; - static const zrtp_string16_t sas_label = ZSTR_INIT_WITH_CONST_CSTRING(ZRTP_SAS_STR); - - zrtp_string64_t sas_digest = ZSTR_INIT_EMPTY(sas_digest); - zrtp_string8_t vad = ZSTR_INIT_EMPTY(vad); - - ZSTR_SET_EMPTY(session->sas1); - ZSTR_SET_EMPTY(session->sas2); - - if (!is_transferred && !stream->protocol) { - return zrtp_status_bad_param; - } - - /* - * Generate SAS source as: - * sashash = KDF(ZRTPSess, "SAS", (ZIDi | ZIDr), 256) - */ - if (!is_transferred) { - _zrtp_kdf( stream, - ZSTR_GV(stream->protocol->cc->s0), - ZSTR_GV(sas_label), - ZSTR_GV(stream->protocol->cc->kdf_context), - ZRTP_HASH_SIZE, - ZSTR_GV(sas_digest)); - - - /* Binary sas value is the leftmost ZRTP_SAS_DIGEST_LENGTH bytes */ - zrtp_zstrncpy(ZSTR_GV(session->sasbin), ZSTR_GV(sas_digest), ZRTP_SAS_DIGEST_LENGTH); - } else { - zrtp_zstrcpy(ZSTR_GV(sas_digest), ZSTR_GV(session->sasbin)); - } - - /* Take the leftmost 20 bits from sas source and render bas32 value */ - sas_digest.length = 3; - sas_digest.buffer[2] &= 0xF0; - if (zrtp_status_ok == b2a(ZSTR_GV(sas_digest), ZSTR_GV(vad)) && vad.length >= 4) { - zrtp_zstrncpy(ZSTR_GV(session->sas1), ZSTR_GV(vad), 4); - return zrtp_status_ok; - } - - return zrtp_status_fail; -} - -/*----------------------------------------------------------------------------*/ -static zrtp_status_t SAS256_compute( zrtp_sas_scheme_t *self, - zrtp_stream_t *stream, - zrtp_hash_t *hash, - uint8_t is_transferred ) -{ - zrtp_session_t *session = stream->session; - ZSTR_SET_EMPTY(session->sas1); - ZSTR_SET_EMPTY(session->sas2); - - if (!is_transferred && !stream->protocol) { - return zrtp_status_bad_param; - } - - /* - * Generate SAS source as: - * sashash = KDF(ZRTPSess, "SAS", (ZIDi | ZIDr), 256) - */ - if (!is_transferred) - { - static const zrtp_string16_t sas_label = ZSTR_INIT_WITH_CONST_CSTRING(ZRTP_SAS_STR); - zrtp_string64_t sas_digest = ZSTR_INIT_EMPTY(sas_digest); - - _zrtp_kdf( stream, - ZSTR_GV(stream->protocol->cc->s0), - ZSTR_GV(sas_label), - ZSTR_GV(stream->protocol->cc->kdf_context), - ZRTP_HASH_SIZE, - ZSTR_GV(sas_digest)); - - /* Binary sas value is last ZRTP_SAS_DIGEST_LENGTH bytes */ - zrtp_zstrncpy(ZSTR_GV(session->sasbin), ZSTR_GV(sas_digest), ZRTP_SAS_DIGEST_LENGTH); - } - - zrtp_zstrcpyc(ZSTR_GV(session->sas1), (const char *)hash_word_list_even[(uint8_t)session->sasbin.buffer[0]]); - zrtp_zstrcpyc(ZSTR_GV(session->sas2), (const char *)hash_word_list_odd[(uint8_t)session->sasbin.buffer[1]]); - - return zrtp_status_ok; -} - -/*----------------------------------------------------------------------------*/ -zrtp_status_t zrtp_defaults_sas(zrtp_global_t* zrtp) -{ - zrtp_sas_scheme_t* base32 = zrtp_sys_alloc(sizeof(zrtp_sas_scheme_t)); - zrtp_sas_scheme_t* base256 = zrtp_sys_alloc(sizeof(zrtp_sas_scheme_t)); - - if (!base32 || !base256) { - if (base32) { - zrtp_sys_free(base32); - } - if (base256) { - zrtp_sys_free(base256); - } - return zrtp_status_alloc_fail; - } - - zrtp_memset(base32, 0, sizeof(zrtp_sas_scheme_t)); - zrtp_memcpy(base32->base.type, ZRTP_B32, ZRTP_COMP_TYPE_SIZE); - base32->base.id = ZRTP_SAS_BASE32; - base32->base.zrtp = zrtp; - base32->compute = SAS32_compute; - - zrtp_memset(base256, 0, sizeof(zrtp_sas_scheme_t)); - zrtp_memcpy(base256->base.type, ZRTP_B256, ZRTP_COMP_TYPE_SIZE); - base256->base.id = ZRTP_SAS_BASE256; - base256->base.zrtp = zrtp; - base256->compute = SAS256_compute; - - zrtp_comp_register(ZRTP_CC_SAS, base32, zrtp); - zrtp_comp_register(ZRTP_CC_SAS, base256, zrtp); - - return zrtp_status_ok; -} - - -uint8_t hash_word_list_odd[256][12] = { - "adroitness", - "adviser", - "aftermath", - "aggregate", - "alkali", - "almighty", - "amulet", - "amusement", - "antenna", - "applicant", - "Apollo", - "armistice", - "article", - "asteroid", - "Atlantic", - "atmosphere", - "autopsy", - "Babylon", - "backwater", - "barbecue", - "belowground", - "bifocals", - "bodyguard", - "bookseller", - "borderline", - "bottomless", - "Bradbury", - "bravado", - "Brazilian", - "breakaway", - "Burlington", - "businessman", - "butterfat", - "Camelot", - "candidate", - "cannonball", - "Capricorn", - "caravan", - "caretaker", - "celebrate", - "cellulose", - "certify", - "chambermaid", - "Cherokee", - "Chicago", - "clergyman", - "coherence", - "combustion", - "commando", - "company", - "component", - "concurrent", - "confidence", - "conformist", - "congregate", - "consensus", - "consulting", - "corporate", - "corrosion", - "councilman", - "crossover", - "crucifix", - "cumbersome", - "customer", - "Dakota", - "decadence", - "December", - "decimal", - "designing", - "detector", - "detergent", - "determine", - "dictator", - "dinosaur", - "direction", - "disable", - "disbelief", - "disruptive", - "distortion", - "document", - "embezzle", - "enchanting", - "enrollment", - "enterprise", - "equation", - "equipment", - "escapade", - "Eskimo", - "everyday", - "examine", - "existence", - "exodus", - "fascinate", - "filament", - "finicky", - "forever", - "fortitude", - "frequency", - "gadgetry", - "Galveston", - "getaway", - "glossary", - "gossamer", - "graduate", - "gravity", - "guitarist", - "hamburger", - "Hamilton", - "handiwork", - "hazardous", - "headwaters", - "hemisphere", - "hesitate", - "hideaway", - "holiness", - "hurricane", - "hydraulic", - "impartial", - "impetus", - "inception", - "indigo", - "inertia", - "infancy", - "inferno", - "informant", - "insincere", - "insurgent", - "integrate", - "intention", - "inventive", - "Istanbul", - "Jamaica", - "Jupiter", - "leprosy", - "letterhead", - "liberty", - "maritime", - "matchmaker", - "maverick", - "Medusa", - "megaton", - "microscope", - "microwave", - "midsummer", - "millionaire", - "miracle", - "misnomer", - "molasses", - "molecule", - "Montana", - "monument", - "mosquito", - "narrative", - "nebula", - "newsletter", - "Norwegian", - "October", - "Ohio", - "onlooker", - "opulent", - "Orlando", - "outfielder", - "Pacific", - "pandemic", - "Pandora", - "paperweight", - "paragon", - "paragraph", - "paramount", - "passenger", - "pedigree", - "Pegasus", - "penetrate", - "perceptive", - "performance", - "pharmacy", - "phonetic", - "photograph", - "pioneer", - "pocketful", - "politeness", - "positive", - "potato", - "processor", - "provincial", - "proximate", - "puberty", - "publisher", - "pyramid", - "quantity", - "racketeer", - "rebellion", - "recipe", - "recover", - "repellent", - "replica", - "reproduce", - "resistor", - "responsive", - "retraction", - "retrieval", - "retrospect", - "revenue", - "revival", - "revolver", - "sandalwood", - "sardonic", - "Saturday", - "savagery", - "scavenger", - "sensation", - "sociable", - "souvenir", - "specialist", - "speculate", - "stethoscope", - "stupendous", - "supportive", - "surrender", - "suspicious", - "sympathy", - "tambourine", - "telephone", - "therapist", - "tobacco", - "tolerance", - "tomorrow", - "torpedo", - "tradition", - "travesty", - "trombonist", - "truncated", - "typewriter", - "ultimate", - "undaunted", - "underfoot", - "unicorn", - "unify", - "universe", - "unravel", - "upcoming", - "vacancy", - "vagabond", - "vertigo", - "Virginia", - "visitor", - "vocalist", - "voyager", - "warranty", - "Waterloo", - "whimsical", - "Wichita", - "Wilmington", - "Wyoming", - "yesteryear", - "Yucatan" - }; - -uint8_t hash_word_list_even[256][10] = { - "aardvark", - "absurd", - "accrue", - "acme", - "adrift", - "adult", - "afflict", - "ahead", - "aimless", - "Algol", - "allow", - "alone", - "ammo", - "ancient", - "apple", - "artist", - "assume", - "Athens", - "atlas", - "Aztec", - "baboon", - "backfield", - "backward", - "banjo", - "beaming", - "bedlamp", - "beehive", - "beeswax", - "befriend", - "Belfast", - "berserk", - "billiard", - "bison", - "blackjack", - "blockade", - "blowtorch", - "bluebird", - "bombast", - "bookshelf", - "brackish", - "breadline", - "breakup", - "brickyard", - "briefcase", - "Burbank", - "button", - "buzzard", - "cement", - "chairlift", - "chatter", - "checkup", - "chisel", - "choking", - "chopper", - "Christmas", - "clamshell", - "classic", - "classroom", - "cleanup", - "clockwork", - "cobra", - "commence", - "concert", - "cowbell", - "crackdown", - "cranky", - "crowfoot", - "crucial", - "crumpled", - "crusade", - "cubic", - "dashboard", - "deadbolt", - "deckhand", - "dogsled", - "dragnet", - "drainage", - "dreadful", - "drifter", - "dropper", - "drumbeat", - "drunken", - "Dupont", - "dwelling", - "eating", - "edict", - "egghead", - "eightball", - "endorse", - "endow", - "enlist", - "erase", - "escape", - "exceed", - "eyeglass", - "eyetooth", - "facial", - "fallout", - "flagpole", - "flatfoot", - "flytrap", - "fracture", - "framework", - "freedom", - "frighten", - "gazelle", - "Geiger", - "glitter", - "glucose", - "goggles", - "goldfish", - "gremlin", - "guidance", - "hamlet", - "highchair", - "hockey", - "indoors", - "indulge", - "inverse", - "involve", - "island", - "jawbone", - "keyboard", - "kickoff", - "kiwi", - "klaxon", - "locale", - "lockup", - "merit", - "minnow", - "miser", - "Mohawk", - "mural", - "music", - "necklace", - "Neptune", - "newborn", - "nightbird", - "Oakland", - "obtuse", - "offload", - "optic", - "orca", - "payday", - "peachy", - "pheasant", - "physique", - "playhouse", - "Pluto", - "preclude", - "prefer", - "preshrunk", - "printer", - "prowler", - "pupil", - "puppy", - "python", - "quadrant", - "quiver", - "quota", - "ragtime", - "ratchet", - "rebirth", - "reform", - "regain", - "reindeer", - "rematch", - "repay", - "retouch", - "revenge", - "reward", - "rhythm", - "ribcage", - "ringbolt", - "robust", - "rocker", - "ruffled", - "sailboat", - "sawdust", - "scallion", - "scenic", - "scorecard", - "Scotland", - "seabird", - "select", - "sentence", - "shadow", - "shamrock", - "showgirl", - "skullcap", - "skydive", - "slingshot", - "slowdown", - "snapline", - "snapshot", - "snowcap", - "snowslide", - "solo", - "southward", - "soybean", - "spaniel", - "spearhead", - "spellbind", - "spheroid", - "spigot", - "spindle", - "spyglass", - "stagehand", - "stagnate", - "stairway", - "standard", - "stapler", - "steamship", - "sterling", - "stockman", - "stopwatch", - "stormy", - "sugar", - "surmount", - "suspense", - "sweatband", - "swelter", - "tactics", - "talon", - "tapeworm", - "tempest", - "tiger", - "tissue", - "tonic", - "topmost", - "tracker", - "transit", - "trauma", - "treadmill", - "Trojan", - "trouble", - "tumor", - "tunnel", - "tycoon", - "uncut", - "unearth", - "unwind", - "uproot", - "upset", - "upshot", - "vapor", - "village", - "virus", - "Vulcan", - "waffle", - "wallet", - "watchword", - "wayside", - "willow", - "woodlark", - "Zulu" - }; diff --git a/libs/libzrtp/src/zrtp_datatypes.c b/libs/libzrtp/src/zrtp_datatypes.c deleted file mode 100644 index 980fb88a88..0000000000 --- a/libs/libzrtp/src/zrtp_datatypes.c +++ /dev/null @@ -1,124 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - -#include "zrtp.h" - -/*---------------------------------------------------------------------------*/ -void zrtp_bitmap_right_shift(uint8_t *x, int width_bytes, int index) -{ - const int base_index = index >> 3; - const int bit_index = index & 7; - int i, from; - uint8_t b; - - if (index > width_bytes*8) { - for(i=0; i < width_bytes; i++) { - x[i] = 0; - } - return; - } - - if (bit_index == 0) { - /* copy each word from left side to right side */ - x[width_bytes-1] = x[width_bytes-1-base_index]; - for (i=width_bytes-1; i > base_index; i--) { - x[i-1] = x[i-1-base_index]; - } - } else { - /* set each word to the OR of the two bit-shifted words */ - for (i = width_bytes; i > base_index; i--) { - from = i-1 - base_index; - b = x[from] << bit_index; - if (from > 0) { - b |= x[from-1] >> (8-bit_index); - } - x[i-1] = b; - } - } - - /* now wrap up the final portion */ - for (i=0; i < base_index; i++) { - x[i] = 0; - } -} - -/*---------------------------------------------------------------------------*/ -void zrtp_bitmap_left_shift(uint8_t *x, int width_bytes, int index) -{ - int i; - const int base_index = index >> 3; - const int bit_index = index & 7; - - if (index > width_bytes*8) { - for(i=0; i < width_bytes; i++) { - x[i] = 0; - } - return; - } - - if (0 == bit_index) { - for (i=0; i < width_bytes - base_index; i++) { - x[i] = x[i+base_index]; - } - } else { - for (i=0; i < width_bytes - base_index - 1; i++) { - x[i] = (x[i+base_index] >> bit_index) ^ (x[i+base_index+1] << (8 - bit_index)); - } - - x[width_bytes - base_index-1] = x[width_bytes-1] >> bit_index; - } - - /* now wrap up the final portion */ - for (i = width_bytes - base_index; i < width_bytes; i++) { - x[i] = 0; - } -} - -void zrtp_v128_xor(zrtp_v128_t *z, zrtp_v128_t *x, zrtp_v128_t *y) -{ - _zrtp_v128_xor(z, x, y); -} - -/*---------------------------------------------------------------------------*/ -uint16_t zrtp_swap16(uint16_t x) { - return (x >> 8 | x << 8); -} - -uint32_t zrtp_swap32(uint32_t x) -{ - uint32_t res = (x >> 8 & 0x0000ff00) | (x << 8 & 0x00ff0000); - res |= (x >> 24 ) | (x << 24); - return res; -} - -#ifdef ZRTP_NO_64BIT_MATH -uint64_t zrtp_swap64(uint64_t x) -{ - uint8_t *p = &x; - uint8_t tmp; - int i; - - for(i=0; i<4; i++) { - tmp = p[i]; - p[i] = p[7-i]; - p[7-i] = tmp; - } - return x; -} -#else -uint64_t zrtp_swap64(uint64_t x) -{ - uint64_t res; - res = (x >> 8 & 0x00000000ff000000ll) | (x << 8 & 0x000000ff00000000ll); - res |= (x >> 24 & 0x0000000000ff0000ll) | (x << 24 & 0x0000ff0000000000ll); - res |= (x >> 40 & 0x000000000000ff00ll) | (x << 40 & 0x00ff000000000000ll); - res |= (x >> 56 & 0x00000000000000ffll) | (x << 56 & 0xff00000000000000ll); - return res; -} -#endif /* ZRTP_NO_64BIT_MATH */ diff --git a/libs/libzrtp/src/zrtp_engine.c b/libs/libzrtp/src/zrtp_engine.c deleted file mode 100644 index 1e2b4ac48d..0000000000 --- a/libs/libzrtp/src/zrtp_engine.c +++ /dev/null @@ -1,1480 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - -#include "zrtp.h" - -#define _ZTU_ "zrtp engine" - -/*! - * Data type for state-handlers: every state has a state handler - * function which is called by zrtp_process_srtp(). - */ -typedef zrtp_status_t state_handler_t( zrtp_stream_t* stream, zrtp_rtp_info_t* packet ); -extern state_handler_t* state_handler[ZRTP_STATE_COUNT]; - -extern zrtp_status_t _zrtp_machine_process_sasrelay(zrtp_stream_t *stream, zrtp_rtp_info_t *packet); - -static void _zrtp_machine_switch_to_error(zrtp_stream_t* stream); -static zrtp_status_t _zrtp_machine_enter_initiatingclear(zrtp_stream_t* stream); -static zrtp_status_t _zrtp_machine_enter_clear(zrtp_stream_t* stream); -static zrtp_status_t _zrtp_machine_enter_pendingerror(zrtp_stream_t *stream, zrtp_protocol_error_t code); - -zrtp_status_t _zrtp_machine_process_hello(zrtp_stream_t* stream, zrtp_rtp_info_t* packet); -zrtp_status_t _zrtp_machine_process_goclear(zrtp_stream_t* stream, zrtp_rtp_info_t* packet); - -static void _send_helloack(zrtp_stream_t* stream); -static void _send_goclearack(zrtp_stream_t* stream); - -zrtp_status_t _zrtp_machine_start_send_and_resend_hello(zrtp_stream_t* stream); -static zrtp_status_t _zrtp_machine_start_send_and_resend_goclear(zrtp_stream_t* stream); -static zrtp_status_t _zrtp_machine_start_send_and_resend_errorack(zrtp_stream_t* stream); -static zrtp_status_t _zrtp_machine_start_send_and_resend_error(zrtp_stream_t* stream); - -void _clear_stream_crypto(zrtp_stream_t* stream); - - -/*===========================================================================*/ -// MARK: ===> Main ZRTP interfaces -/*===========================================================================*/ - -/*----------------------------------------------------------------------------*/ -zrtp_status_t zrtp_process_rtcp(zrtp_stream_t *stream, char* packet, unsigned int* length) -{ - - /* - * In transition states, drop outgoing packets. In SECURE state, encrypt - outgoing packets. In all other states leave them unchanged. - */ - - if (stream) { - switch (stream->state) - { - case ZRTP_STATE_START_INITIATINGSECURE: - case ZRTP_STATE_INITIATINGSECURE: - case ZRTP_STATE_WAIT_CONFIRM1: - case ZRTP_STATE_WAIT_CONFIRMACK: - case ZRTP_STATE_PENDINGSECURE: - case ZRTP_STATE_WAIT_CONFIRM2: - case ZRTP_STATE_PENDINGCLEAR: - return zrtp_status_drop; - - case ZRTP_STATE_SASRELAYING: - case ZRTP_STATE_SECURE: - { - zrtp_rtp_info_t info; - - if (*length < RTCP_HDR_SIZE) { - return zrtp_status_fail; - } - - zrtp_memset(&info, 0, sizeof(info)); - info.packet = packet; - info.length = length; - info.seq = 0; /*sequence number will be generated in zrtp_srtp_protect_rtcp()*/ - info.ssrc = (uint32_t) *(packet+sizeof(uint32_t)); - - return _zrtp_protocol_encrypt(stream->protocol, &info, 0); - } - - default: - return zrtp_status_ok; - } - } - - return zrtp_status_ok; -} - -/*----------------------------------------------------------------------------*/ -zrtp_status_t zrtp_process_srtcp(zrtp_stream_t *stream, char* packet, unsigned int* length) -{ - - /* - * In transition states, drop incoming packets. In SECURE state, decrypt - * incoming packets. In all other states leave them unchanged. - */ - - if (stream) { - switch (stream->state) - { - case ZRTP_STATE_INITIATINGCLEAR: - case ZRTP_STATE_PENDINGCLEAR: - case ZRTP_STATE_INITIATINGSECURE: - case ZRTP_STATE_PENDINGSECURE: - return zrtp_status_drop; - - case ZRTP_STATE_SECURE: - case ZRTP_STATE_SASRELAYING: - { - zrtp_rtp_info_t info; - - if (*length < RTCP_HDR_SIZE) { - return zrtp_status_fail; - } - - zrtp_memset(&info, 0, sizeof(info)); - info.packet = packet; - info.length = length; - info.seq = 0; /*sequence number will be determined from packet in zrtp_srtp_unprotect_rtcp()*/ - info.ssrc = (uint32_t) *(packet+sizeof(uint32_t)); - - return _zrtp_protocol_decrypt(stream->protocol, &info, 0); - } - - default: - return zrtp_status_ok; - } - } - - return zrtp_status_ok; -} - -/*----------------------------------------------------------------------------*/ -zrtp_status_t zrtp_process_rtp(zrtp_stream_t *stream, char* packet, unsigned int* length) -{ - zrtp_rtp_info_t info; - - if (!stream || !packet || !length) { - return zrtp_status_bad_param; - } - - /* Skip packet processing within uninitiated stream */ - if ((stream->state < ZRTP_STATE_START) || (stream->state > ZRTP_STATE_NO_ZRTP)) { - return zrtp_status_ok; - } - - /* Prepare RTP packet: detect type and other options */ - if (zrtp_status_ok != _zrtp_packet_preparse(stream, packet, length, &info, 0)) { - return zrtp_status_fail; - } - - /* Drop packets in transition states and encrypt in SECURE state */ - switch (stream->state) - { - case ZRTP_STATE_START_INITIATINGSECURE: - case ZRTP_STATE_INITIATINGSECURE: - case ZRTP_STATE_WAIT_CONFIRM1: - case ZRTP_STATE_WAIT_CONFIRMACK: - case ZRTP_STATE_PENDINGSECURE: - case ZRTP_STATE_WAIT_CONFIRM2: - case ZRTP_STATE_PENDINGCLEAR: - if (ZRTP_NONE == info.type) { - /* Add dropped media to the entropy hash */ - ZRTP_LOG(1,(_ZTU_,"Add %d bytes of entropy to the RNG pool.\n", *length)); - zrtp_entropy_add(stream->zrtp, (unsigned char*)packet, *length); - - return zrtp_status_drop; - } - break; - - case ZRTP_STATE_SASRELAYING: - case ZRTP_STATE_SECURE: - if (ZRTP_NONE == info.type) { - return _zrtp_protocol_encrypt(stream->protocol, &info, 1); - } - break; - - default: - break; - } - - return zrtp_status_ok; -} - -/*----------------------------------------------------------------------------*/ -extern int _send_message(zrtp_stream_t* stream, zrtp_msg_type_t type, const void* message, uint32_t ssrc); -zrtp_status_t zrtp_process_srtp(zrtp_stream_t *stream, char* packet, unsigned int* length) -{ - zrtp_rtp_info_t info; - zrtp_status_t s = zrtp_status_ok; - - if (!stream || !packet || !length) { - return zrtp_status_bad_param; - } - - if (*length <= RTP_HDR_SIZE) { - return zrtp_status_bad_param; - } - - /* Preparse RTP packet: detect type and other options */ - s = _zrtp_packet_preparse(stream, packet, length, &info, 1); - if (zrtp_status_ok != s) { - return s; - } - - /*************************************************************************/ - /* For Zfone3 Compatibility */ - if (ZRTP_ZFONEPING == info.type) { - zrtp_packet_zfoneping_t* ping = (zrtp_packet_zfoneping_t*) info.message; - zrtp_packet_zfonepingack_t pingack; - - zrtp_memcpy(pingack.version, ZRTP_ZFONE_PROTOCOL_VERSION, 4); - zrtp_memcpy(pingack.endpointhash, stream->session->zid.buffer, sizeof(pingack.endpointhash)); - zrtp_memcpy(pingack.peerendpointhash, ping->endpointhash, sizeof(pingack.endpointhash)); - pingack.peerssrc = info.ssrc; - - _zrtp_packet_fill_msg_hdr( stream, - ZRTP_ZFONEPINGACK, - sizeof(zrtp_packet_zfonepingack_t) - sizeof(zrtp_msg_hdr_t), - &pingack.hdr); - - _zrtp_packet_send_message(stream, ZRTP_ZFONEPINGACK, &pingack); - return zrtp_status_drop; - } - /*************************************************************************/ - - /* Skip packet processing within non-started stream */ - if ((stream->state < ZRTP_STATE_START) || (stream->state > ZRTP_STATE_NO_ZRTP)) { - return (ZRTP_NONE == info.type) ? zrtp_status_ok : zrtp_status_drop; - } - - /* - * This mutex should protect stream data against asynchr. calls e.g.: - * zrtp_stream_secure(), zrtp_stream_clear() etc. Media packet handlers - * don't change any internal data, so this applies only to ZRTP messages. - */ - if (info.type != ZRTP_NONE) { - zrtp_mutex_lock(stream->stream_protector); - } - - /* Extra protection. We need protocol to handle ZRTP messages in following states. */ - switch (stream->state) - { - case ZRTP_STATE_INITIATINGSECURE: - case ZRTP_STATE_WAIT_CONFIRM1: - case ZRTP_STATE_WAIT_CONFIRMACK: - case ZRTP_STATE_PENDINGSECURE: - case ZRTP_STATE_WAIT_CONFIRM2: - case ZRTP_STATE_SECURE: - case ZRTP_STATE_SASRELAYING: - if (!stream->protocol) { - if (info.type != ZRTP_NONE) { - zrtp_mutex_unlock(stream->stream_protector); - } - return zrtp_status_fail; - } - default: - break; - } - - /* Handle Error packet from any state */ - if (ZRTP_ERROR == info.type && stream->state > ZRTP_STATE_START) - { - switch (stream->state) - { - case ZRTP_STATE_NONE: - case ZRTP_STATE_ACTIVE: - case ZRTP_STATE_SECURE: - case ZRTP_STATE_PENDINGERROR: - case ZRTP_STATE_INITIATINGERROR: - case ZRTP_STATE_NO_ZRTP: - break; - default: - { - zrtp_packet_Error_t* error = (zrtp_packet_Error_t*) info.message; - _zrtp_machine_enter_pendingerror(stream, zrtp_ntoh32(error->code)); - } break; - } - } - - /* Process packet by state-machine according to packet type and current protocol state */ - if (state_handler[stream->state]) { - s = state_handler[stream->state](stream, &info); - } - - /* Unlock stream mutex for a ZRTP message packet. See comments above. */ - if (info.type != ZRTP_NONE) { - s = zrtp_status_drop; - zrtp_mutex_unlock(stream->stream_protector); - } - - return s; -} - -/*----------------------------------------------------------------------------*/ -zrtp_status_t zrtp_stream_start(zrtp_stream_t* stream, uint32_t ssrc) -{ - zrtp_status_t s = zrtp_status_ok; - /* - * (ZRTP stream starts from START state and HELLO packets resending. - * Stream can be started from START, ERROR or NOZRTP states only.) - */ - ZRTP_LOG(3,(_ZTU_,"START STREAM ID=%u mode=%s state=%s.\n", - stream->id, zrtp_log_mode2str(stream->mode), zrtp_log_state2str(stream->state))); - - if ( (ZRTP_STATE_ACTIVE != stream->state) && - (ZRTP_STATE_ERROR != stream->state) && - (ZRTP_STATE_NO_ZRTP != stream->state)) { - ZRTP_LOG(1,(_ZTU_,"ERROR! Can't start Stream ID=%u from %s state.\n", - stream->id, zrtp_log_state2str(stream->state))); - s = zrtp_status_wrong_state; - } else { - stream->media_ctx.ssrc = zrtp_hton32(ssrc); - - _zrtp_change_state(stream, ZRTP_STATE_START); - _zrtp_machine_start_send_and_resend_hello(stream); - } - - return s; -} - -/*----------------------------------------------------------------------------*/ -zrtp_status_t zrtp_stream_stop(zrtp_stream_t* stream) -{ - zrtp_status_t s = zrtp_status_ok; - /* - * Stop all packet replays, deinitialize crypto data and prepare the stream - * for the next use. The stream can be terminated from any protocol state. - */ - ZRTP_LOG(3,(_ZTU_,"STOP STREAM ID=%u mode=%s state=%s.\n", - stream->id, zrtp_log_mode2str(stream->mode), zrtp_log_state2str(stream->state))); - - /* - * Unlink deleted stream for the peer MiTM stream if necessary. It may - * prevent some recae-conditions as we always test for NULL before - * accessing linked_mitm. - */ - if (stream->linked_mitm) { - stream->linked_mitm->linked_mitm = NULL; - } - - if (stream->state != ZRTP_STATE_NONE) { - /* - * This function can be called in parallel to the main processing loop - * - protect internal stream data. - */ - zrtp_mutex_lock(stream->stream_protector); - - _zrtp_cancel_send_packet_later(stream, ZRTP_NONE); - if (stream->zrtp->cb.sched_cb.on_wait_call_later) { - stream->zrtp->cb.sched_cb.on_wait_call_later(stream); - } - - _clear_stream_crypto(stream); - - zrtp_mutex_unlock(stream->stream_protector); - zrtp_mutex_destroy(stream->stream_protector); - - zrtp_memset(stream, 0, sizeof(zrtp_stream_t)); - - stream->mode = ZRTP_STREAM_MODE_UNKN; - - _zrtp_change_state(stream, ZRTP_STATE_NONE); - } else { - s = zrtp_status_wrong_state; - } - - return s; -} - -/*----------------------------------------------------------------------------*/ -zrtp_status_t zrtp_stream_clear(zrtp_stream_t *stream) -{ - /* - * This function can be called for two reasons: either our user is - * initiating the go-clear ritual or we accepting that ritual as - * initiated by the other end of the line. If our user initiates the - * go-clear process libzrtp switches to INITIATING_CLEAR and runs - * GoClear replays. The go-clear ritual can be started from SECURE state - * only. If the other end of the line is initiating and this function is - * being called to accept the go-clear procedure - protocol transites to - * CLEAR state imediately. One can accept go-clear from PENDING CLEAR - * state only. See state-macine diagram for more information. - */ - zrtp_status_t s = zrtp_status_fail; - - /* This function can be called in parallel to the main processing loop - protect stream data. */ - zrtp_mutex_lock(stream->stream_protector); - - ZRTP_LOG(3,(_ZTU_,"CLEAR STREAM ID=%u mode=%s state=%s.\n", - stream->id, zrtp_log_mode2str(stream->mode), zrtp_log_state2str(stream->state))); - - switch (stream->state) - { - case ZRTP_STATE_SECURE: - /* Clearing ritual can't be started if "allow clear" is disabled */ - if (stream->session->profile.allowclear) { - s = _zrtp_machine_enter_initiatingclear(stream); - } - break; - case ZRTP_STATE_PENDINGCLEAR: - s = _zrtp_machine_enter_clear(stream); - break; - default: - break; - } - - zrtp_mutex_unlock(stream->stream_protector); - - return s; -} - -/*----------------------------------------------------------------------------*/ -void _initiating_secure(zrtp_stream_t *stream, zrtp_retry_task_t* task) -{ - /* - * In accordance with the ZRTP standard, there can be multiple simultaneous - * DH streams, as well as preshared streams. - * - * Before entering the INITIATING_SECURE state, we check several conditions. - * For details see \doc\img\odg\zrtp_streams.odg and zrtp_statemach.odg) - */ - - /* The first call to this function is already protected by a mutex in zrtp_process_srtp() */ - uint8_t use_mutex = (task->_retrys > 0); - - if (!task->_is_enabled) { - return; - } - - if (use_mutex) { - zrtp_mutex_lock(stream->stream_protector); - } - - ZRTP_LOG(3,(_ZTU_,"\tInitiating Secure iteration... ID=%u.\n", stream->id)); - - /* Skip the last replay after switching to another state to avoid unwanted replays */ - if (stream->state <= ZRTP_STATE_START_INITIATINGSECURE) - { - stream->mode = _zrtp_define_stream_mode(stream); - ZRTP_LOG(3,(_ZTU_,"\tGot mode=%s. Check approval of starting.\n", zrtp_log_mode2str(stream->mode))); - if (!_zrtp_can_start_stream(stream, &stream->concurrent, stream->mode)) - { - if (task->_retrys > ZRTP_PROCESS_T1_MAX_COUNT) { - ZRTP_LOG(3,(_ZTU_,"\tInitiating Secure. Max retransmissions count reached" - "for stream ID=%u.\n", stream->id)); - - _zrtp_machine_enter_initiatingerror(stream, zrtp_error_timeout, 0); - } else { - ZRTP_LOG(3,(_ZTU_,"\tInitiating Secure. stream ID=%u is DH but one more DH" - " stream is in progress - waiting...\n", stream->id)); - - task->_retrys++; - if (stream->zrtp->cb.sched_cb.on_call_later) { - stream->zrtp->cb.sched_cb.on_call_later(stream, task); - } - } - } - else - { - ZRTP_LOG(3,(_ZTU_,"\tMode=%s Cccepted. Starting ZRTP Initiator Protocol.\n", zrtp_log_mode2str(stream->mode))); - _zrtp_cancel_send_packet_later(stream, ZRTP_PROCESS); - _zrtp_machine_enter_initiatingsecure(stream); - } - } - - if (use_mutex) { - zrtp_mutex_unlock(stream->stream_protector); - } -} - -zrtp_status_t _zrtp_machine_start_initiating_secure(zrtp_stream_t *stream) -{ - /* - * This function creates a task to do retries of the first packet in the - * "Going secure" procedure, and then _initiating_secure() will start - * protocol. - */ - zrtp_retry_task_t* task = &stream->messages.dh_task; - task->_is_enabled = 1; - task->_retrys = 0; - task->callback = _initiating_secure; - task->timeout = ZRTP_PROCESS_T1; - - /* - * Prevent race conditions on starting multiple streams. - */ - zrtp_mutex_lock(stream->session->init_protector); - - _zrtp_change_state(stream, ZRTP_STATE_START_INITIATINGSECURE); - _initiating_secure(stream, task); - - zrtp_mutex_unlock(stream->session->init_protector); - - return zrtp_status_ok; -} - - -zrtp_status_t zrtp_stream_secure(zrtp_stream_t *stream) -{ - /* - * Wrapper function for going into secure mode. It can be initiated in - * parallel to the main processing loop. The internal stream data has to - * be protected by mutex. - */ - - zrtp_status_t s = zrtp_status_fail; - - ZRTP_LOG(3,(_ZTU_,"SECURE STREAM ID=%u mode=%s state=%s.\n", - stream->id, zrtp_log_mode2str(stream->mode), zrtp_log_state2str(stream->state))); - - zrtp_mutex_lock(stream->stream_protector); - - /* Limit ZRTP Session initiation procedure according to the license */ - if ( (stream->state == ZRTP_STATE_CLEAR) && ZRTP_PASSIVE1_TEST(stream)) { - s = _zrtp_machine_start_initiating_secure(stream); - } else { - ZRTP_LOG(1,(_ZTU_,"\tWARNING! Can't Start Stream from %s state and with %d license mode. ID=%u\n", - zrtp_log_state2str(stream->state), stream->zrtp->lic_mode, stream->id)); - - if (!ZRTP_PASSIVE1_TEST(stream)) { - if (stream->zrtp->cb.event_cb.on_zrtp_protocol_event ) { - stream->zrtp->cb.event_cb.on_zrtp_protocol_event(stream, ZRTP_EVENT_IS_PASSIVE_RESTRICTION); - } - } - } - - zrtp_mutex_unlock(stream->stream_protector); - - return s; -} - - -/*===========================================================================*/ -/* State handlers */ -/*===========================================================================*/ - -/*---------------------------------------------------------------------------*/ -zrtp_status_t _zrtp_machine_process_while_in_start( zrtp_stream_t* stream, - zrtp_rtp_info_t* packet) -{ - zrtp_status_t s = zrtp_status_ok; - - switch (packet->type) - { - case ZRTP_HELLO: - s = _zrtp_machine_process_hello(stream, packet); - if (zrtp_status_ok != s) { - ZRTP_LOG(1,(_ZTU_,"\tERROR! _zrtp_machine_process_hello() failed with status=%d. ID=%u\n", s, stream->id)); - break; /* Just stay in START state. */ - } - - /* Now we have ZIDs for both sides and can upload secrets from the cache */ - s = _zrtp_prepare_secrets(stream->session); - if (zrtp_status_ok != s) { - ZRTP_LOG(1,(_ZTU_,"\tERROR! _zrtp_prepare_secrets() failed with status=%d. ID=%u\n", s, stream->id)); - break; /* Just stay in START state. */ - } - - _send_helloack(stream); - _zrtp_change_state(stream, ZRTP_STATE_WAIT_HELLOACK); - break; - - case ZRTP_HELLOACK: - _zrtp_cancel_send_packet_later(stream, ZRTP_HELLO); - _zrtp_change_state(stream, ZRTP_STATE_WAIT_HELLO); - break; - - default: - break; - } - - return s; -} - -/*---------------------------------------------------------------------------*/ -zrtp_status_t _zrtp_machine_process_while_in_wait4hello( zrtp_stream_t* stream, - zrtp_rtp_info_t* packet) -{ - zrtp_status_t s = zrtp_status_ok; - - switch (packet->type) - { - case ZRTP_HELLO: - s = _zrtp_machine_process_hello(stream, packet); - if (zrtp_status_ok != s) { - ZRTP_LOG(1,(_ZTU_,"\tERROR! _zrtp_machine_process_hello()2 failed with status=%d. ID=%u\n", s, stream->id)); - break; /* Just stay in the current state. */ - } - - /* Now we have ZIDs for both sides and can upload secrets from the cache */ - s = _zrtp_prepare_secrets(stream->session); - if (zrtp_status_ok != s) { - ZRTP_LOG(1,(_ZTU_,"\tERROR! _zrtp_prepare_secrets()2 failed with status=%d. ID=%u\n", s, stream->id)); - break; /* Just stay in the current state. */ - } - - /* Start initiating the secure state if "autosecure" is enabled */ - if ((stream->session->profile.autosecure) && ZRTP_PASSIVE1_TEST(stream)) { - if (!stream->session->profile.discovery_optimization) { - _send_helloack(stream); /* Response with HelloAck before start computing DH value */ - } - s = _zrtp_machine_start_initiating_secure(stream); - } else { - _send_helloack(stream); - - if (!ZRTP_PASSIVE1_TEST(stream)) { - if (stream->zrtp->cb.event_cb.on_zrtp_protocol_event) { - stream->zrtp->cb.event_cb.on_zrtp_protocol_event(stream, ZRTP_EVENT_IS_PASSIVE_RESTRICTION); - } - ZRTP_LOG(2,(_ZTU_,"\tINFO: Switching to Clear due to Active/Passive restrictions.\n")); - } - - s = _zrtp_machine_enter_clear(stream); - } - - break; - - default: - break; - } - - return s; -} - -/*---------------------------------------------------------------------------*/ -zrtp_status_t _zrtp_machine_process_while_in_wait4helloack( zrtp_stream_t* stream, - zrtp_rtp_info_t* packet) -{ - zrtp_status_t status = zrtp_status_ok; - - switch (packet->type) - { - case ZRTP_HELLO: - _send_helloack(stream); - break; - - case ZRTP_COMMIT: - { - /* Passive Initiator can't talk to anyone */ - if (ZRTP_PASSIVE2_TEST(stream)) - { - zrtp_statemachine_type_t role = _zrtp_machine_preparse_commit(stream, packet); - if (ZRTP_STATEMACHINE_RESPONDER == role) { - _zrtp_cancel_send_packet_later(stream, ZRTP_HELLO); - status = _zrtp_machine_enter_pendingsecure(stream, packet); - } else if (ZRTP_STATEMACHINE_INITIATOR == role) { - _zrtp_cancel_send_packet_later(stream, ZRTP_HELLO); - status = _zrtp_machine_start_initiating_secure(stream); - } else { - status = zrtp_status_fail; - } - } else { - ZRTP_LOG(2,(_ZTU_,"\tERROR: The endpoint is in passive mode and Signaling Initiator -" - " can't handle connections from anyone. ID=%u\n", stream->id)); - if (stream->zrtp->cb.event_cb.on_zrtp_protocol_event) { - stream->zrtp->cb.event_cb.on_zrtp_protocol_event(stream, ZRTP_EVENT_IS_PASSIVE_RESTRICTION); - } - _zrtp_machine_enter_initiatingerror(stream, zrtp_error_service_unavail, 1); - } - } break; - - case ZRTP_HELLOACK: - _zrtp_cancel_send_packet_later(stream, ZRTP_HELLO); - - /* Start initiating the secure state if "autosecure" is enabled */ - if ((stream->session->profile.autosecure) && ZRTP_PASSIVE1_TEST(stream)) { - status = _zrtp_machine_start_initiating_secure(stream); - } else { - if (!ZRTP_PASSIVE1_TEST(stream)) { - if (stream->zrtp->cb.event_cb.on_zrtp_protocol_event) { - stream->zrtp->cb.event_cb.on_zrtp_protocol_event(stream, ZRTP_EVENT_IS_PASSIVE_RESTRICTION); - } - ZRTP_LOG(2,(_ZTU_,"\tINFO: Switching to Clear due to Active/Passive restrictions.\n")); - } - status = _zrtp_machine_enter_clear(stream); - } - - break; - - default: - break; - } - - return status; -} - -/*---------------------------------------------------------------------------*/ -zrtp_status_t _zrtp_machine_process_while_in_clear( zrtp_stream_t* stream, - zrtp_rtp_info_t* packet) -{ - zrtp_status_t s = zrtp_status_ok; - - switch (packet->type) - { - case ZRTP_GOCLEAR: - _send_goclearack(stream); - break; - - case ZRTP_HELLO: - _send_helloack(stream); - break; - - case ZRTP_COMMIT: - { - zrtp_statemachine_type_t role = _zrtp_machine_preparse_commit(stream, packet); - if (ZRTP_STATEMACHINE_RESPONDER == role) { - s = _zrtp_machine_enter_pendingsecure(stream, packet); - } else if (ZRTP_STATEMACHINE_INITIATOR == role) { - s = _zrtp_machine_start_initiating_secure(stream); - } else { - s = zrtp_status_fail; - } - } break; - - default: - break; - } - - return s; -} - -/*---------------------------------------------------------------------------*/ -zrtp_status_t _zrtp_machine_process_while_in_initiatingclear( zrtp_stream_t* stream, - zrtp_rtp_info_t* packet) -{ - zrtp_status_t s = zrtp_status_ok; - - switch (packet->type) - { - case ZRTP_GOCLEARACK: - case ZRTP_COMMIT: - s = _zrtp_machine_enter_clear(stream); - break; - - case ZRTP_NONE: - s = zrtp_status_drop; - break; - - default: - break; - } - - return s; -} - -/*---------------------------------------------------------------------------*/ -zrtp_status_t _zrtp_machine_process_while_in_pendingclear( zrtp_stream_t* stream, - zrtp_rtp_info_t* packet) -{ - zrtp_status_t s = zrtp_status_ok; - - switch (packet->type) - { - case ZRTP_GOCLEAR: - _send_goclearack(stream); - break; - - case ZRTP_COMMIT: - { - zrtp_statemachine_type_t role = _zrtp_machine_preparse_commit(stream, packet); - if (ZRTP_STATEMACHINE_RESPONDER == role) { - s = _zrtp_machine_enter_pendingsecure(stream, packet); - } else if (ZRTP_STATEMACHINE_INITIATOR == role) { - s = _zrtp_machine_start_initiating_secure(stream); - } else { - s = zrtp_status_fail; - } - } break; - - default: - break; - } - - return s; -} - -/*---------------------------------------------------------------------------*/ -zrtp_status_t _zrtp_machine_process_while_in_start_initiatingsecure( zrtp_stream_t* stream, - zrtp_rtp_info_t* packet) -{ - zrtp_status_t s = zrtp_status_ok; - - switch (packet->type) - { - case ZRTP_HELLO: - _send_helloack(stream); - break; - - case ZRTP_COMMIT: - { - zrtp_statemachine_type_t role = _zrtp_machine_preparse_commit(stream, packet); - if (ZRTP_STATEMACHINE_RESPONDER == role) { - _zrtp_cancel_send_packet_later(stream, ZRTP_PROCESS); - s = _zrtp_machine_enter_pendingsecure(stream, packet); - } else { - s = zrtp_status_fail; - } - } break; - - default: - break; - } - - return s; -} - -/*---------------------------------------------------------------------------*/ -zrtp_status_t _zrtp_machine_process_while_in_secure( zrtp_stream_t* stream, - zrtp_rtp_info_t* packet) -{ - zrtp_status_t s = zrtp_status_ok; - - switch (packet->type) - { - case ZRTP_CONFIRM2: - _zrtp_packet_send_message(stream, ZRTP_CONFIRM2ACK, NULL); - break; - - case ZRTP_SASRELAY: - /* - * _zrtp_machine_process_sasrelay() updates SAS, sends events and does - * other things if SAS transferring is allowed - */ - s = _zrtp_machine_process_sasrelay(stream, packet); - if (zrtp_status_ok == s) { - _zrtp_packet_send_message(stream, ZRTP_RELAYACK, NULL); - } - break; - - case ZRTP_GOCLEAR: - s = _zrtp_machine_process_goclear(stream, packet); - if (zrtp_status_ok == s) { - s = _zrtp_machine_enter_pendingclear(stream); - _send_goclearack(stream); - } - break; - - case ZRTP_NONE: - s = _zrtp_protocol_decrypt(stream->protocol, packet, 1); - break; - - default: - break; - } - - return s; -} - -/*---------------------------------------------------------------------------*/ -zrtp_status_t _zrtp_machine_process_while_in_initiatingerror( zrtp_stream_t* stream, - zrtp_rtp_info_t* packet) -{ - switch (packet->type) - { - case ZRTP_ERROR: - _zrtp_machine_enter_pendingerror(stream, ((zrtp_packet_Error_t*) packet->message)->code ); - break; - - case ZRTP_ERRORACK: - _zrtp_machine_switch_to_error(stream); - break; - - default: - break; - } - - return zrtp_status_ok; -} - -/*---------------------------------------------------------------------------*/ -zrtp_status_t _zrtp_machine_process_while_in_nozrtp( zrtp_stream_t* stream, - zrtp_rtp_info_t* packet) -{ - zrtp_status_t s = zrtp_status_ok; - - switch (packet->type) - { - case ZRTP_HELLO: - s = _zrtp_machine_process_hello(stream, packet); - if (zrtp_status_ok != s) { - ZRTP_LOG(1,(_ZTU_,"\tERROR! _zrtp_machine_process_hello()3 failed with status=%d ID=%u.\n", s, stream->id)); - break; - } - - _zrtp_change_state(stream, ZRTP_STATE_START); - _zrtp_machine_start_send_and_resend_hello(stream); - break; - - case ZRTP_COMMIT: /* this logic should be similar to Commit handler in ZRTP_STATE_WAIT_HELLOACK state */ - { - /* Passive Initiator can't talk to anyone */ - if (ZRTP_PASSIVE2_TEST(stream)) - { - zrtp_statemachine_type_t role = _zrtp_machine_preparse_commit(stream, packet); - if (ZRTP_STATEMACHINE_RESPONDER == role) { - s = _zrtp_machine_enter_pendingsecure(stream, packet); - } else if (ZRTP_STATEMACHINE_INITIATOR == role) { - s = _zrtp_machine_start_initiating_secure(stream); - } else { - s = zrtp_status_fail; - } - } else { - ZRTP_LOG(2,(_ZTU_,"\tERROR: The endpoint is in passive mode and Signaling Initiator -" - " can't handle connections from anyone. ID=%u\n", stream->id)); - if (stream->zrtp->cb.event_cb.on_zrtp_protocol_event ) { - stream->zrtp->cb.event_cb.on_zrtp_protocol_event(stream, ZRTP_EVENT_IS_PASSIVE_RESTRICTION); - } - _zrtp_machine_enter_initiatingerror(stream, zrtp_error_service_unavail, 1); - } - } break; - - default: - break; - } - - return s; -} - - -/* Initiator logic */ -extern zrtp_status_t _zrtp_machine_process_while_in_initiatingsecure(zrtp_stream_t* stream, zrtp_rtp_info_t* packet); -extern zrtp_status_t _zrtp_machine_process_while_in_waitconfirmack(zrtp_stream_t* stream, zrtp_rtp_info_t* packet); -extern zrtp_status_t _zrtp_machine_process_while_in_waitconfirm1(zrtp_stream_t* stream, zrtp_rtp_info_t* packet); - -/* Responder logic */ -extern zrtp_status_t _zrtp_machine_process_while_in_pendingsecure(zrtp_stream_t* stream, zrtp_rtp_info_t* packet); -extern zrtp_status_t _zrtp_machine_process_while_in_waitconfirm2(zrtp_stream_t* stream, zrtp_rtp_info_t* packet); - -/* PBX transferring logic */ -extern zrtp_status_t _zrtp_machine_process_while_in_sasrelaying(zrtp_stream_t* stream, zrtp_rtp_info_t* packet); - -#if (defined(ZRTP_BUILD_FOR_CSD) && (ZRTP_BUILD_FOR_CSD == 1)) -/* Driven Discovery state-machine */ -extern zrtp_status_t _zrtp_machine_process_while_in_driven_initiator(zrtp_stream_t* stream, zrtp_rtp_info_t* packet); -extern zrtp_status_t _zrtp_machine_process_while_in_driven_responder(zrtp_stream_t* stream, zrtp_rtp_info_t* packet); -extern zrtp_status_t _zrtp_machine_process_while_in_driven_pending(zrtp_stream_t* stream, zrtp_rtp_info_t* packet); -#endif - -state_handler_t* state_handler[ZRTP_STATE_COUNT] = -{ - NULL, - NULL, - _zrtp_machine_process_while_in_start, - _zrtp_machine_process_while_in_wait4helloack, - _zrtp_machine_process_while_in_wait4hello, - _zrtp_machine_process_while_in_clear, - _zrtp_machine_process_while_in_start_initiatingsecure, - _zrtp_machine_process_while_in_initiatingsecure, - _zrtp_machine_process_while_in_waitconfirm1, - _zrtp_machine_process_while_in_waitconfirmack, - _zrtp_machine_process_while_in_pendingsecure, - _zrtp_machine_process_while_in_waitconfirm2, - _zrtp_machine_process_while_in_secure, - _zrtp_machine_process_while_in_sasrelaying, - _zrtp_machine_process_while_in_initiatingclear, - _zrtp_machine_process_while_in_pendingclear, - _zrtp_machine_process_while_in_initiatingerror, - NULL, - NULL, -#if (defined(ZRTP_BUILD_FOR_CSD) && (ZRTP_BUILD_FOR_CSD == 1)) - _zrtp_machine_process_while_in_driven_initiator, - _zrtp_machine_process_while_in_driven_responder, - _zrtp_machine_process_while_in_driven_pending, -#endif - _zrtp_machine_process_while_in_nozrtp -}; - - -/*===========================================================================*/ -/* State switchers */ -/*===========================================================================*/ - -static void _zrtp_machine_switch_to_error(zrtp_stream_t* stream) -{ - _zrtp_cancel_send_packet_later(stream, ZRTP_NONE); - _clear_stream_crypto(stream); - - _zrtp_change_state(stream, ZRTP_STATE_ERROR); - - if (stream->zrtp->cb.event_cb.on_zrtp_security_event) { - stream->zrtp->cb.event_cb.on_zrtp_security_event(stream, ZRTP_EVENT_PROTOCOL_ERROR); - } - if (stream->zrtp->cb.event_cb.on_zrtp_not_secure) { - stream->zrtp->cb.event_cb.on_zrtp_not_secure(stream); - } - stream->last_error = 0; -} - -/*---------------------------------------------------------------------------*/ -zrtp_status_t _zrtp_machine_enter_pendingclear(zrtp_stream_t* stream) -{ - _zrtp_cancel_send_packet_later(stream, ZRTP_NONE); - _zrtp_change_state(stream, ZRTP_STATE_PENDINGCLEAR); - - /* - * We have to destroy the ZRTP Session Key because user may not press "clear - * button", and the remote endpoint may subsequently initiate a new secure - * session. Other secret values will be destroyed in Clear state or - * rewritten with new. - */ - { - zrtp_string64_t new_zrtpsess = ZSTR_INIT_EMPTY(new_zrtpsess); - // TODO: hash - stream->session->hash->hash( stream->session->hash, - ZSTR_GV(stream->session->zrtpsess), - ZSTR_GV(new_zrtpsess)); - zrtp_zstrcpy(ZSTR_GV(stream->session->zrtpsess), ZSTR_GV(new_zrtpsess)); - } - - if (stream->zrtp->cb.event_cb.on_zrtp_protocol_event) { - stream->zrtp->cb.event_cb.on_zrtp_protocol_event(stream, ZRTP_EVENT_IS_PENDINGCLEAR); - } - - return zrtp_status_ok; -} - -/*---------------------------------------------------------------------------*/ -static zrtp_status_t _zrtp_machine_enter_initiatingclear(zrtp_stream_t* stream) -{ - - _zrtp_cancel_send_packet_later(stream, ZRTP_NONE); - _zrtp_change_state(stream, ZRTP_STATE_INITIATINGCLEAR); - - { - zrtp_string64_t new_zrtpsess = ZSTR_INIT_EMPTY(new_zrtpsess); - // TODO: hash - stream->session->hash->hash( stream->session->hash, - ZSTR_GV(stream->session->zrtpsess), - ZSTR_GV(new_zrtpsess)); - zrtp_zstrcpy(ZSTR_GV(stream->session->zrtpsess), ZSTR_GV(new_zrtpsess)); - } - - return _zrtp_machine_start_send_and_resend_goclear(stream); -} - -/*---------------------------------------------------------------------------*/ -static zrtp_status_t _zrtp_machine_enter_clear(zrtp_stream_t* stream) -{ - _zrtp_cancel_send_packet_later(stream, ZRTP_NONE); - _clear_stream_crypto(stream); - _zrtp_change_state(stream, ZRTP_STATE_CLEAR); - - if (stream->zrtp->cb.event_cb.on_zrtp_protocol_event) { - stream->zrtp->cb.event_cb.on_zrtp_protocol_event(stream, ZRTP_EVENT_IS_CLEAR); - } - - /* - * Now, let's check if the transition to CLEAR was caused by Active/Passive rules. - * If local endpoint is a MitM and peer MiTM linked stream is Unlimited, we - * could break the rules and send commit to Passive endpoint. - */ - if (stream->zrtp->is_mitm && stream->peer_passive) { - if (stream->linked_mitm && stream->linked_mitm->peer_super_flag) { - ZRTP_LOG(2,(_ZTU_,"INFO: Current stream ID=%u was switched to CLEAR-mode due to Active/Passive" - " restrictions, but we are running in MiTM mode and peer linked stream is" - " Super-active. Go Secure!\n", stream->id)); - - /* @note: don't use zrtp_secure_stream() wrapper as it checks for Active/Passive stuff. */ - _zrtp_machine_start_initiating_secure(stream); - } - } - - return zrtp_status_ok; -} - - -/*---------------------------------------------------------------------------*/ -zrtp_status_t _zrtp_machine_enter_initiatingerror( zrtp_stream_t *stream, - zrtp_protocol_error_t code, - uint8_t notif) -{ - if ( (ZRTP_STATE_ERROR != stream->state) && - (ZRTP_STATE_INITIATINGERROR != stream->state) && - (ZRTP_STATE_PENDINGERROR != stream->state) ) - { - stream->last_error = code; - - ZRTP_LOG(3,(_ZTU_,"\tEnter InitiatingError State with ERROR:<%s>, notification %s. ID=%u\n", - zrtp_log_error2str(stream->last_error), (notif?"Enabled":"Disabled"), stream->id)); - - /* If we can't deliver a ZRTP message, just switch to the ERROR state. */ - if (notif) { - _zrtp_cancel_send_packet_later(stream, ZRTP_NONE); - _zrtp_change_state(stream, ZRTP_STATE_INITIATINGERROR); - _zrtp_machine_start_send_and_resend_error(stream); - } else { - _zrtp_machine_switch_to_error(stream); - } - } - - return zrtp_status_ok; -} - -zrtp_status_t _zrtp_machine_enter_pendingerror(zrtp_stream_t *stream, zrtp_protocol_error_t code) -{ - ZRTP_LOG(3,(_ZTU_,"\tEnter PendingError State with ERROR:<%s>. ID=%u\n", - zrtp_log_error2str(stream->last_error), stream->id)); - - _zrtp_cancel_send_packet_later(stream, ZRTP_NONE); - _zrtp_change_state(stream, ZRTP_STATE_PENDINGERROR); - - stream->last_error = code; - _zrtp_machine_start_send_and_resend_errorack(stream); - return zrtp_status_ok; -} - - -/*===========================================================================*/ -/* Packet handlers */ -/*===========================================================================*/ - -zrtp_status_t _zrtp_machine_process_goclear(zrtp_stream_t* stream, zrtp_rtp_info_t* packet) -{ - zrtp_packet_GoClear_t *goclear = (zrtp_packet_GoClear_t*) packet->message; - zrtp_string128_t clear_hmac = ZSTR_INIT_EMPTY(clear_hmac); - static const zrtp_string16_t clear_hmac_str = ZSTR_INIT_WITH_CONST_CSTRING(ZRTP_CLEAR_HMAC_STR); - - if (!stream->allowclear) { - ZRTP_LOG(2, (_ZTU_,"\tWARNING! Allowclear is disabled but GoClear was received. ID=%u.\n", stream->id)); - _zrtp_machine_enter_initiatingerror(stream, zrtp_error_goclear_unsp, 1); - return zrtp_status_fail; - } - - stream->session->hash->hmac( stream->session->hash, - ZSTR_GV(stream->cc.peer_hmackey), - ZSTR_GV(clear_hmac_str), - ZSTR_GV(clear_hmac)); - clear_hmac.length = ZRTP_HMAC_SIZE; - - if (0 != zrtp_memcmp(clear_hmac.buffer, goclear->clear_hmac, ZRTP_HMAC_SIZE)) { - ZRTP_LOG(2, (_ZTU_,"\tWARNING! Wrong GoClear hmac. ID=%u.\n", stream->id)); - return zrtp_status_fail; /* EH: Just ignore malformed packets */ - } - - return zrtp_status_ok; -} - -/*---------------------------------------------------------------------------*/ -zrtp_status_t _zrtp_machine_process_hello(zrtp_stream_t* stream, zrtp_rtp_info_t* packet) -{ - zrtp_session_t* session = stream->session; - zrtp_packet_Hello_t* peer_hello = NULL; - uint32_t comp_block_len = 0; - uint8_t id = 0; - - /* Size of HELLO packet must be bigger then . */ - if (*(packet->length) < (ZRTP_MIN_PACKET_LENGTH + ZRTP_HELLO_STATIC_SIZE + ZRTP_HMAC_SIZE)) { - ZRTP_LOG(2,(_ZTU_,"\tWARNING! Wrong HELLO static size=%d must be=%d. ID=%u\n", *packet->length, - ZRTP_MIN_PACKET_LENGTH + ZRTP_HELLO_STATIC_SIZE + ZRTP_HMAC_SIZE, stream->id)); - - _zrtp_machine_enter_initiatingerror(stream, zrtp_error_invalid_packet, 1); - return zrtp_status_fail; - } - - peer_hello = (zrtp_packet_Hello_t*) packet->message; - - /* Now we can verify packet size according to size of its parts */ - comp_block_len = ( peer_hello->hc + peer_hello->cc + - peer_hello->ac + peer_hello->kc + - peer_hello->sc) * ZRTP_COMP_TYPE_SIZE; - - if (*packet->length < (ZRTP_MIN_PACKET_LENGTH + ZRTP_HELLO_STATIC_SIZE + comp_block_len + ZRTP_HMAC_SIZE)) - { - ZRTP_LOG(2,(_ZTU_,"\tWARNING! Wrong HELLO dynamic size=%d must be=%d. ID=%u\n", *packet->length, - comp_block_len+ ZRTP_MIN_PACKET_LENGTH + ZRTP_HELLO_STATIC_SIZE + ZRTP_HMAC_SIZE, stream->id)); - - _zrtp_machine_enter_initiatingerror(stream, zrtp_error_invalid_packet, 1); - return zrtp_status_fail; - } - - /* Every component quantity must be less than or equal to 7 */ - if ( (peer_hello->hc > ZRTP_MAX_COMP_COUNT) || (peer_hello->cc > ZRTP_MAX_COMP_COUNT) || - (peer_hello->ac > ZRTP_MAX_COMP_COUNT) || (peer_hello->kc > ZRTP_MAX_COMP_COUNT) || - (peer_hello->sc > ZRTP_MAX_COMP_COUNT) ) - { - ZRTP_LOG(2,(_ZTU_,"\tWARNING! Wrong HELLO packet data. Components count can't be greater" - " then 7. ID=%u\n", stream->id)); - - _zrtp_machine_enter_initiatingerror(stream, zrtp_error_invalid_packet, 1); - return zrtp_status_fail; - } - - /* Print out ZRTP Hello message for debug purposes */ - { - char print_buffer[ZRTP_MAX_COMP_COUNT*20]; - zrtp_memcpy(print_buffer, peer_hello->comp, comp_block_len); - print_buffer[comp_block_len] = 0; - ZRTP_LOG(3,(_ZTU_,"\tProcessing HELLO from %.16s V=%.4s, P=%d, M=%d.\n", - peer_hello->cliend_id, peer_hello->version, peer_hello->pasive, peer_hello->mitmflag)); - ZRTP_LOG(3,(_ZTU_,"\t\tac=%d cc=%d sc=%d kc=%d\n", - peer_hello->ac, peer_hello->cc, peer_hello->sc, peer_hello->kc)); - ZRTP_LOG(3,(_ZTU_,"\t\t%s\n", print_buffer)); - } - - /* - * Check protocol version. Try to resolve versions missmatch according to ZRTP Draft sec. 5.1 - */ - { - uint32_t peer_version = 0; - peer_version = (char)((*peer_hello->version) - '0') *10; /* only 3 first octets are significant */ - peer_version += (char)(*(peer_hello->version+2) - '0'); - - if ((ZRTP_PROTOCOL_VERSION_VALUE/10) == peer_version) { - ZRTP_LOG(3,(_ZTU_,"\tReceived HELLO had the same protocol V.\n")); - } - else if ((ZRTP_PROTOCOL_VERSION_VALUE/10) < peer_version) { - ZRTP_LOG(2,(_ZTU_,"\tWARNING! Received HELLO greater ZRTP V=%d - wait for other party" - " to resolve this issue. ID=%u.\n", peer_version, stream->id)); - } else { - ZRTP_LOG(2,(_ZTU_,"\tWARNING! Received a ZRTP_HELLO smaller ZRTP V=%d and we don't" - " support it - terminate session. ID=%u\n", peer_version, stream->id)); - - _zrtp_machine_enter_initiatingerror(stream, zrtp_error_version, 1); - return zrtp_status_fail; - } - } - - /* Close session if ZID duplication */ - if (!zrtp_memcmp(stream->messages.hello.zid, peer_hello->zid, sizeof(zrtp_zid_t))) { - ZRTP_LOG(2,(_ZTU_,ZRTP_EQUAL_ZID_WARNING_STR)); - _zrtp_machine_enter_initiatingerror(stream, zrtp_error_equal_zid, 1); - return zrtp_status_fail; - } - - /* All streams within a single session MUST have the same ZID */ - if (session->peer_zid.length > 0) { - if (0 != zrtp_memcmp(session->peer_zid.buffer, peer_hello->zid, sizeof(zrtp_zid_t))) { - ZRTP_LOG(2,(_ZTU_,"\tWARNING! Received HELLO which had a different ZID from that of the" - " previous stream within the same session. sID=%u ID=%u\n", session->id, stream->id)); - - _zrtp_machine_enter_initiatingerror(stream, zrtp_error_wrong_zid, 1); - return zrtp_status_fail; - } - } else { - zrtp_zstrncpyc(ZSTR_GV(session->peer_zid), (const char*) peer_hello->zid, sizeof(zrtp_zid_t)); - } - - /* - * Process Remote flags. - */ - if (peer_hello->pasive && peer_hello->uflag) { - ZRTP_LOG(2,(_ZTU_,"\tWARNING! Received HELLO which both P and U flags set.\n")); - return zrtp_status_fail; - } - - stream->peer_passive = peer_hello->pasive; - stream->peer_super_flag = peer_hello->uflag; - - stream->peer_mitm_flag = peer_hello->mitmflag; - if (stream->peer_mitm_flag) { - stream->mitm_mode = ZRTP_MITM_MODE_CLIENT; - } - - /* Current version doesn't support Digital Signatures. Ignore peer Hello with S flag enabled. */ - if (peer_hello->sigflag) { - ZRTP_LOG(2,(_ZTU_,"\tWARNING! Received a ZRTP_HELLO with S flag enabled. We don't support Digital Signatures - ignore message.\n")); - return zrtp_status_fail; - } - - /* Copy packet for future hashing */ - zrtp_memcpy(&stream->messages.peer_hello, peer_hello, zrtp_ntoh16(peer_hello->hdr.length)*4); - stream->is_hello_received = 1; - - /* - * Choose PK exchange scheme and PK mode. - * We do this right after receiving Hello to speedup DH calculations. - */ - stream->pubkeyscheme = zrtp_comp_find(ZRTP_CC_PKT, ZRTP_PKTYPE_DH3072, session->zrtp); - id = _zrtp_choose_best_comp(&session->profile, peer_hello, ZRTP_CC_PKT); - if (id != ZRTP_COMP_UNKN) { - stream->pubkeyscheme = zrtp_comp_find(ZRTP_CC_PKT, id, session->zrtp); - } - - ZRTP_LOG(3,(_ZTU_,"\tReceived HELLO Accepted\n")); - - return zrtp_status_ok; -} - - -/*===========================================================================*/ -/* Packet senders */ -/*===========================================================================*/ - -/*---------------------------------------------------------------------------*/ -static void _send_and_resend_hello(zrtp_stream_t* stream, zrtp_retry_task_t* task) -{ - if ((task->_retrys == ZRTP_NO_ZRTP_FAST_COUNT) && !stream->is_hello_received) { - ZRTP_LOG(2,(_ZTU_,"WARNING! HELLO have been resent %d times without a response." - " Raising ZRTP_EVENT_NO_ZRTP_QUICK event. ID=%u\n", task->_retrys, stream->id)); - - if (stream->zrtp->cb.event_cb.on_zrtp_protocol_event) { - stream->zrtp->cb.event_cb.on_zrtp_protocol_event(stream, ZRTP_EVENT_NO_ZRTP_QUICK); - } - } - - if (task->_retrys >= (uint32_t)((ZRTP_STATE_WAIT_HELLOACK==stream->state)?ZRTP_T1_MAX_COUNT_EXT:ZRTP_T1_MAX_COUNT)) { - ZRTP_LOG(2,(_ZTU_,"WARNING! HELLO Max retransmissions count reached (%d retries). ID=%u\n", task->_retrys, stream->id)); - - _zrtp_cancel_send_packet_later(stream, ZRTP_NONE); - _clear_stream_crypto(stream); - _zrtp_change_state(stream, ZRTP_STATE_NO_ZRTP); - - if (stream->zrtp->cb.event_cb.on_zrtp_protocol_event) { - stream->zrtp->cb.event_cb.on_zrtp_protocol_event(stream, ZRTP_EVENT_NO_ZRTP); - } - } else if (task->_is_enabled) { - zrtp_status_t s = _zrtp_packet_send_message(stream, ZRTP_HELLO, &stream->messages.hello); - task->timeout = _zrtp_get_timeout((uint32_t)task->timeout, ZRTP_HELLO); - if (zrtp_status_ok == s) { - task->_retrys++; - } - - - if (stream->zrtp->cb.sched_cb.on_call_later) { - stream->zrtp->cb.sched_cb.on_call_later(stream, task); - } - } -} - -zrtp_status_t _zrtp_machine_start_send_and_resend_hello(zrtp_stream_t* stream) -{ - zrtp_retry_task_t* task = &stream->messages.hello_task; - - task->_is_enabled = 1; - task->callback = _send_and_resend_hello; - task->_retrys = 0; - - _send_and_resend_hello(stream, task); - - return zrtp_status_ok; -} - -static void _send_helloack(zrtp_stream_t* stream) -{ - _zrtp_packet_send_message(stream, ZRTP_HELLOACK, NULL); -} - - -/*---------------------------------------------------------------------------*/ -static void _send_and_resend_goclear(zrtp_stream_t* stream, zrtp_retry_task_t* task) -{ - if (task->_is_enabled) { - if (task->_retrys > ZRTP_T2_MAX_COUNT) { - ZRTP_LOG(2,(_ZTU_,"\tWARNING!: GOCLEAR Nax retransmissions count reached. ID=%u\n", stream->id)); - _zrtp_machine_enter_clear(stream); - } else { - zrtp_packet_GoClear_t* goclear = (zrtp_packet_GoClear_t*) &stream->messages.goclear; - - _zrtp_packet_send_message(stream, ZRTP_GOCLEAR, goclear); - task->_retrys++; - if (stream->zrtp->cb.sched_cb.on_call_later) { - stream->zrtp->cb.sched_cb.on_call_later(stream, task); - } - } - } -} - -static zrtp_status_t _zrtp_machine_start_send_and_resend_goclear(zrtp_stream_t* stream) -{ - zrtp_retry_task_t* task = &stream->messages.goclear_task; - zrtp_string128_t clear_hmac = ZSTR_INIT_EMPTY(clear_hmac); - static const zrtp_string16_t clear_hmac_str = ZSTR_INIT_WITH_CONST_CSTRING(ZRTP_CLEAR_HMAC_STR); - - zrtp_memset(&stream->messages.goclear, 0, sizeof(zrtp_packet_GoClear_t)); - - /* Compute Clear HMAC as: HMAC(hmackey, "Clear hmac") */ - stream->session->hash->hmac( stream->session->hash, - ZSTR_GV(stream->cc.hmackey), - ZSTR_GV(clear_hmac_str), - ZSTR_GV(clear_hmac)); - clear_hmac.length = ZRTP_HMAC_SIZE; - - zrtp_memcpy(stream->messages.goclear.clear_hmac, clear_hmac.buffer, clear_hmac.length); - _zrtp_packet_fill_msg_hdr( stream, - ZRTP_GOCLEAR, - sizeof(zrtp_packet_GoClear_t) - sizeof(zrtp_msg_hdr_t), - &stream->messages.goclear.hdr); - - task->_is_enabled = 1; - task->callback = _send_and_resend_goclear; - task->timeout = ZRTP_T2; - task->_retrys = 0; - - _send_and_resend_goclear(stream, task); - - return zrtp_status_ok; -} - - -static void _send_goclearack(zrtp_stream_t* stream) -{ - _zrtp_packet_send_message(stream, ZRTP_GOCLEARACK, NULL); -} - -/*---------------------------------------------------------------------------*/ -static void _send_and_resend_error(zrtp_stream_t* stream, zrtp_retry_task_t* task) -{ - if (task->_retrys >= ZRTP_ETI_MAX_COUNT) { - ZRTP_LOG(2,(_ZTU_,"\tWARNING! ERROR Max retransmissions count reached. ID=%u\n", stream->id)); - _zrtp_machine_switch_to_error(stream); - } else if (task->_is_enabled) { - if (zrtp_status_ok == _zrtp_packet_send_message(stream, ZRTP_ERROR, &stream->messages.error)) { - task->_retrys++; - } - if (stream->zrtp->cb.sched_cb.on_call_later) { - stream->zrtp->cb.sched_cb.on_call_later(stream, task); - } - } -} - -static zrtp_status_t _zrtp_machine_start_send_and_resend_error(zrtp_stream_t* stream) -{ - zrtp_retry_task_t* task = &stream->messages.error_task; - - zrtp_memset(&stream->messages.error, 0, sizeof(zrtp_packet_Error_t)); - stream->messages.error.code = zrtp_hton32(stream->last_error); - - _zrtp_packet_fill_msg_hdr( stream, - ZRTP_ERROR, - sizeof(zrtp_packet_Error_t) - sizeof(zrtp_msg_hdr_t), - &stream->messages.error.hdr); - - task->_is_enabled = 1; - task->callback = _send_and_resend_error; - task->timeout = ZRTP_ET; - task->_retrys = 0; - - _send_and_resend_error(stream, task); - - return zrtp_status_ok; -} - -/*---------------------------------------------------------------------------*/ -static void _send_and_resend_errorack(zrtp_stream_t* stream, zrtp_retry_task_t* task) -{ - if (task->_retrys >= ZRTP_ETR_MAX_COUNT) { - ZRTP_LOG(2,(_ZTU_,"\tWARNING! ERRORACK Max retransmissions count reached. ID=%u\n", stream->id)); - _zrtp_machine_switch_to_error(stream); - } else if (task->_is_enabled) { - if (zrtp_status_ok == _zrtp_packet_send_message(stream, ZRTP_ERRORACK, NULL)) { - task->_retrys++; - } - if (stream->zrtp->cb.sched_cb.on_call_later) { - stream->zrtp->cb.sched_cb.on_call_later(stream, task); - } - } -} - -static zrtp_status_t _zrtp_machine_start_send_and_resend_errorack(zrtp_stream_t* stream) -{ - zrtp_retry_task_t* task = &stream->messages.errorack_task; - - task->_is_enabled = 1; - task->callback = _send_and_resend_errorack; - task->timeout = ZRTP_ET; - task->_retrys = 0; - - _send_and_resend_errorack(stream, task); - - return zrtp_status_ok; -} - - -void _clear_stream_crypto(zrtp_stream_t* stream) -{ - if (stream->protocol) { - _zrtp_protocol_destroy(stream->protocol); - stream->protocol = 0; - } - - zrtp_wipe_zstring(ZSTR_GV(stream->cc.hmackey)); - zrtp_wipe_zstring(ZSTR_GV(stream->cc.peer_hmackey)); - zrtp_wipe_zstring(ZSTR_GV(&stream->cc.zrtp_key)); - zrtp_wipe_zstring(ZSTR_GV(stream->cc.peer_zrtp_key)); -} diff --git a/libs/libzrtp/src/zrtp_engine_driven.c b/libs/libzrtp/src/zrtp_engine_driven.c deleted file mode 100644 index cccc06b08d..0000000000 --- a/libs/libzrtp/src/zrtp_engine_driven.c +++ /dev/null @@ -1,152 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - -#include "zrtp.h" - -#define _ZTU_ "zrtp dengine" - - -#if (defined(ZRTP_BUILD_FOR_CSD) && (ZRTP_BUILD_FOR_CSD == 1)) - -extern zrtp_status_t _zrtp_machine_process_hello(zrtp_stream_t* stream, zrtp_rtp_info_t* packet); -extern zrtp_status_t start_send_and_resend_hello(zrtp_stream_t* stream); -extern zrtp_status_t start_initiating_secure(zrtp_stream_t *stream); -extern zrtp_status_t _zrtp_machine_start_send_and_resend_hello(zrtp_stream_t* stream); - - -/*----------------------------------------------------------------------------*/ -void zrtp_driven_stream_start(zrtp_stream_t* stream, zrtp_statemachine_type_t role) -{ - - ZRTP_LOG(3,(_ZTU_,"START Driven %s Stream ID=%u mode=%s state=%s.", - (ZRTP_STATEMACHINE_INITIATOR == role)?"INITIATOR":"RESPONDER", - stream->id, zrtp_log_mode2str(stream->mode), zrtp_log_state2str(stream->state))); - - /* This function can be called in parallel to the main processing loop protect internal stream data. */ - zrtp_mutex_lock(stream->stream_protector); - - if ( (ZRTP_STATE_ACTIVE != stream->state) && - (ZRTP_STATE_ERROR != stream->state) && - (ZRTP_STATE_NO_ZRTP != stream->state)) - { - ZRTP_LOG(1,(_ZTU_,"ERROR! can't start stream ID=%u from state %d.", stream->id, stream->state)); - } - else - { - if (ZRTP_STATEMACHINE_INITIATOR == role) { - _zrtp_change_state(stream, ZRTP_STATE_DRIVEN_INITIATOR); - _zrtp_machine_start_send_and_resend_hello(stream); - } else if (ZRTP_STATEMACHINE_RESPONDER == role) { - _zrtp_change_state(stream, ZRTP_STATE_DRIVEN_RESPONDER); - } - } - - zrtp_mutex_unlock(stream->stream_protector); -} - -/*---------------------------------------------------------------------------*/ -zrtp_status_t _zrtp_machine_process_while_in_driven_initiator( zrtp_stream_t* stream, - zrtp_rtp_info_t* packet) -{ - zrtp_status_t s = zrtp_status_ok; - - switch (packet->type) - { - case ZRTP_HELLO: { - s = _zrtp_machine_process_hello(stream, packet); - if (zrtp_status_ok != s) { - ZRTP_LOG(1,(_ZTU_,"ERROR! _zrtp_machine_process_hello()4 failed with status=%d. ID=%u",s, stream->id)); - break; /* Just stay in DRIVEN_INITIATOR state. */ - } - - /* Now we have ZIDs for both sides and can upload secrets from the cache */ - s = _zrtp_prepare_secrets(stream->session); - if (zrtp_status_ok != s) { - ZRTP_LOG(1,(_ZTU_,"ERROR! _zrtp_prepare_secrets()3 failed with status=%d. ID=%u",s, stream->id)); - break; /* Just stay in START state. */ - } - - // TODO: handle autosecure and licensing modes there - _zrtp_cancel_send_packet_later(stream, ZRTP_HELLO); - stream->mode = _zrtp_define_stream_mode(stream); - s = _zrtp_machine_enter_initiatingsecure(stream); - } break; - - default: - break; - } - - return s; -} - -zrtp_status_t _zrtp_machine_process_while_in_driven_responder( zrtp_stream_t* stream, - zrtp_rtp_info_t* packet) -{ - zrtp_status_t s = zrtp_status_ok; - - switch (packet->type) - { - case ZRTP_HELLO: { - s = _zrtp_machine_process_hello(stream, packet); - if (zrtp_status_ok != s) { - ZRTP_LOG(1,(_ZTU_,"ERROR! _zrtp_machine_process_hello()5 failed with status=%d. ID=%u", s, stream->id)); - break; /* Just stay in DRIVEN_INITIATOR state. */ - } - - /* Now we have ZIDs for both sides and can upload secrets from the cache */ - s = _zrtp_prepare_secrets(stream->session); - if (zrtp_status_ok != s) { - ZRTP_LOG(1,(_ZTU_,"ERROR! _zrtp_prepare_secrets()4 failed with status=%d. ID=%u", s, stream->id)); - break; /* Just stay in START state. */ - } - - // TODO: handle autosecure and licensing modes there - s = _zrtp_packet_send_message(stream, ZRTP_HELLO, &stream->messages.hello); - if (zrtp_status_ok == s) { - _zrtp_change_state(stream, ZRTP_STATE_DRIVEN_PENDING); - } - } break; - - default: - break; - } - - return s; -} - -zrtp_status_t _zrtp_machine_process_while_in_driven_pending( zrtp_stream_t* stream, - zrtp_rtp_info_t* packet) -{ - zrtp_status_t s = zrtp_status_ok; - - switch (packet->type) - { - case ZRTP_HELLO: { - s = _zrtp_packet_send_message(stream, ZRTP_HELLO, &stream->messages.hello); - } break; - - case ZRTP_COMMIT: { - zrtp_statemachine_type_t role = _zrtp_machine_preparse_commit(stream, packet); - if (ZRTP_STATEMACHINE_RESPONDER == role) { - s = _zrtp_machine_enter_pendingsecure(stream, packet); - } else if (ZRTP_STATEMACHINE_INITIATOR == role) { - s = _zrtp_machine_start_initiating_secure(stream); - } else { - s = zrtp_status_fail; - } - } break; - - default: - break; - } - - return s; -} - -#endif /* ZRTP_BUILD_FOR_CSD */ diff --git a/libs/libzrtp/src/zrtp_iface_cache.c b/libs/libzrtp/src/zrtp_iface_cache.c deleted file mode 100644 index 27191f80f3..0000000000 --- a/libs/libzrtp/src/zrtp_iface_cache.c +++ /dev/null @@ -1,963 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2012 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - -#include "zrtp.h" - -#if defined(ZRTP_USE_BUILTIN_CACHE) && (ZRTP_USE_BUILTIN_CACHE == 1) - -#define _ZTU_ "zrtp cache" - - -/* Windows kernel have it's own realization in Windows registry*/ -#if (ZRTP_PLATFORM != ZP_WIN32_KERNEL) - -static mlist_t cache_head; -static uint32_t g_cache_elems_counter = 0; -static mlist_t mitmcache_head; -static uint32_t g_mitmcache_elems_counter = 0; -static uint8_t inited = 0; -static uint8_t g_needs_rewriting = 0; - -static zrtp_global_t* zrtp; -static zrtp_mutex_t* def_cache_protector = NULL; - - -/* Create cache ID like a pair of ZIDs. ZID with lowest value at the beginning */ -void zrtp_cache_create_id( const zrtp_stringn_t* first_ZID, - const zrtp_stringn_t* second_ZID, - zrtp_cache_id_t id); - -/* Searching for cache element by cache ID */ -static zrtp_cache_elem_t* get_elem(const zrtp_cache_id_t id, uint8_t is_mitm); - -/* Allows use cache on system with different byte-order */ -static void cache_make_cross( zrtp_cache_elem_t* from, - zrtp_cache_elem_t* to, - uint8_t is_upload); - -static zrtp_status_t zrtp_cache_user_init(); -static zrtp_status_t zrtp_cache_user_down(); - - -/*===========================================================================*/ -/* libZRTP interface implementation */ -/*===========================================================================*/ - -#define ZRTP_CACHE_CHECK_ZID(a,b) \ - if ( (a->length != b->length) || \ - (a->length != sizeof(zrtp_zid_t)) ) \ - { \ - return zrtp_status_bad_param; \ - } - -zrtp_status_t zrtp_def_cache_init(zrtp_global_t* a_zrtp) -{ - zrtp_status_t s = zrtp_status_ok; - - if (!inited) { - zrtp = a_zrtp; - s = zrtp_mutex_init(&def_cache_protector); - if (zrtp_status_ok != s) { - return s; - } - - init_mlist(&cache_head); - init_mlist(&mitmcache_head); - s = zrtp_cache_user_init(); - - inited = 1; - } - - return s; -} - -void zrtp_def_cache_down() -{ - if (inited) { - mlist_t *node = NULL, *tmp = NULL; - - /* If automatic cache flushing enabled we don't need to store it in a disk as it should be already in sync. */ - if (!zrtp->cache_auto_store) - zrtp_cache_user_down(); - - mlist_for_each_safe(node, tmp, &cache_head) { - zrtp_sys_free(mlist_get_struct(zrtp_cache_elem_t, _mlist, node)); - } - mlist_for_each_safe(node, tmp, &mitmcache_head) { - zrtp_sys_free(mlist_get_struct(zrtp_cache_elem_t, _mlist, node)); - } - - init_mlist(&cache_head); - init_mlist(&mitmcache_head); - - zrtp_mutex_destroy(def_cache_protector); - - inited = 0; - zrtp = NULL; - } -} - - -zrtp_status_t zrtp_def_cache_set_verified( const zrtp_stringn_t* one_ZID, - const zrtp_stringn_t* another_ZID, - uint32_t verified) -{ - zrtp_cache_id_t id; - zrtp_cache_elem_t* new_elem = NULL; - - ZRTP_CACHE_CHECK_ZID(one_ZID, another_ZID); - zrtp_cache_create_id(one_ZID, another_ZID, id); - - zrtp_mutex_lock(def_cache_protector); - new_elem = get_elem(id, 0); - if (new_elem) { - new_elem->verified = verified; - } - zrtp_mutex_unlock(def_cache_protector); - - if (zrtp->cache_auto_store) zrtp_def_cache_store(zrtp); - - return (new_elem) ? zrtp_status_ok : zrtp_status_fail; -} - -zrtp_status_t zrtp_def_cache_get_verified( const zrtp_stringn_t* one_ZID, - const zrtp_stringn_t* another_ZID, - uint32_t* verified) - -{ - zrtp_cache_id_t id; - zrtp_cache_elem_t* elem = NULL; - - ZRTP_CACHE_CHECK_ZID(one_ZID, another_ZID); - zrtp_cache_create_id(one_ZID, another_ZID, id); - - zrtp_mutex_lock(def_cache_protector); - elem = get_elem(id, 0); - if (elem) { - *verified = elem->verified; - } - zrtp_mutex_unlock(def_cache_protector); - - return (elem) ? zrtp_status_ok : zrtp_status_fail; -} - - -static zrtp_status_t cache_put( const zrtp_stringn_t* one_ZID, - const zrtp_stringn_t* another_ZID, - zrtp_shared_secret_t *rss, - uint8_t is_mitm ) -{ - zrtp_cache_elem_t* new_elem = 0; - zrtp_cache_id_t id; - - ZRTP_CACHE_CHECK_ZID(one_ZID, another_ZID); - zrtp_cache_create_id(one_ZID, another_ZID, id); - - { - char zid1str[24+1], zid2str[24+1]; - ZRTP_LOG(3,(_ZTU_,"\tcache_put() zid1=%s, zis2=%s MiTM=%s\n", - hex2str(one_ZID->buffer, one_ZID->length, zid1str, sizeof(zid1str)), - hex2str(another_ZID->buffer, another_ZID->length, zid2str, sizeof(zid2str)), - is_mitm?"YES":"NO")); - } - - zrtp_mutex_lock(def_cache_protector); - do { - new_elem = get_elem(id, is_mitm); - if (!new_elem) - { - /* If cache doesn't exist - create new one */ - if (!( new_elem = (zrtp_cache_elem_t*) zrtp_sys_alloc(sizeof(zrtp_cache_elem_t)) )) { - break; - } - - zrtp_memset(new_elem, 0, sizeof(zrtp_cache_elem_t)); - ZSTR_SET_EMPTY(new_elem->curr_cache); - ZSTR_SET_EMPTY(new_elem->prev_cache); - - new_elem->secure_since = (uint32_t)(zrtp_time_now()/1000); - - mlist_add_tail(is_mitm ? &mitmcache_head : &cache_head, &new_elem->_mlist); - zrtp_memcpy(new_elem->id, id, sizeof(zrtp_cache_id_t)); - - if (is_mitm) { - new_elem->_index = g_mitmcache_elems_counter++; - } else { - new_elem->_index = g_cache_elems_counter++; - } - - ZRTP_LOG(3,(_ZTU_,"\tcache_put() can't find element in the cache - create a new entry index=%u.\n", new_elem->_index)); - } - else { - ZRTP_LOG(3,(_ZTU_,"\tcache_put() Just update existing value.\n")); - } - - /* Save current cache value as previous one and new as a current */ - if (!is_mitm) { - if (new_elem->curr_cache.length > 0) { - zrtp_zstrcpy(ZSTR_GV(new_elem->prev_cache), ZSTR_GV(new_elem->curr_cache)); - } - } - - zrtp_zstrcpy(ZSTR_GV(new_elem->curr_cache), ZSTR_GV(rss->value)); - new_elem->lastused_at = rss->lastused_at; - if (!is_mitm) { - new_elem->ttl = rss->ttl; - } - - new_elem->_is_dirty = 1; - } while (0); - zrtp_mutex_unlock(def_cache_protector); - - if (zrtp->cache_auto_store) zrtp_def_cache_store(zrtp); - - return (new_elem) ? zrtp_status_ok : zrtp_status_fail; -} - -zrtp_status_t zrtp_def_cache_put( const zrtp_stringn_t* one_ZID, - const zrtp_stringn_t* another_ZID, - zrtp_shared_secret_t *rss) { - return cache_put(one_ZID, another_ZID, rss, 0); -} - -zrtp_status_t zrtp_def_cache_put_mitm( const zrtp_stringn_t* one_ZID, - const zrtp_stringn_t* another_ZID, - zrtp_shared_secret_t *rss) { - return cache_put(one_ZID, another_ZID, rss, 1); -} - - -static zrtp_status_t cache_get( const zrtp_stringn_t* one_ZID, - const zrtp_stringn_t* another_ZID, - zrtp_shared_secret_t *rss, - int prev_requested, - uint8_t is_mitm) -{ - zrtp_cache_elem_t* curr = 0; - zrtp_cache_id_t id; - zrtp_status_t s = zrtp_status_ok; - - { - char zid1str[24+1], zid2str[24+1]; - ZRTP_LOG(3,(_ZTU_,"\tache_get(): zid1=%s, zis2=%s MiTM=%s\n", - hex2str(one_ZID->buffer, one_ZID->length, zid1str, sizeof(zid1str)), - hex2str(another_ZID->buffer, another_ZID->length, zid2str, sizeof(zid2str)), - is_mitm?"YES":"NO")); - } - - ZRTP_CACHE_CHECK_ZID(one_ZID, another_ZID); - zrtp_cache_create_id(one_ZID, another_ZID, id); - - zrtp_mutex_lock(def_cache_protector); - do { - curr = get_elem(id, is_mitm); - if (!curr || (!curr->prev_cache.length && prev_requested)) { - s = zrtp_status_fail; - ZRTP_LOG(3,(_ZTU_,"\tache_get() - not found.\n")); - break; - } - - zrtp_zstrcpy( ZSTR_GV(rss->value), - prev_requested ? ZSTR_GV(curr->prev_cache) : ZSTR_GV(curr->curr_cache)); - - rss->lastused_at = curr->lastused_at; - if (!is_mitm) { - rss->ttl = curr->ttl; - } - } while (0); - zrtp_mutex_unlock(def_cache_protector); - - return s; -} - -zrtp_status_t zrtp_def_cache_get( const zrtp_stringn_t* one_ZID, - const zrtp_stringn_t* another_ZID, - zrtp_shared_secret_t *rss, - int prev_requested) -{ - return cache_get(one_ZID, another_ZID, rss, prev_requested, 0); -} - -zrtp_status_t zrtp_def_cache_get_mitm( const zrtp_stringn_t* one_ZID, - const zrtp_stringn_t* another_ZID, - zrtp_shared_secret_t *rss) -{ - return cache_get(one_ZID, another_ZID, rss, 0, 1); -} - -zrtp_status_t zrtp_def_cache_set_presh_counter( const zrtp_stringn_t* one_zid, - const zrtp_stringn_t* another_zid, - uint32_t counter) -{ - zrtp_cache_elem_t* new_elem = 0; - zrtp_cache_id_t id; - - ZRTP_CACHE_CHECK_ZID(one_zid, another_zid); - zrtp_cache_create_id(one_zid, another_zid, id); - - zrtp_mutex_lock(def_cache_protector); - new_elem = get_elem(id, 0); - if (new_elem) { - new_elem->presh_counter = counter; - - new_elem->_is_dirty = 1; - } - zrtp_mutex_unlock(def_cache_protector); - - if (zrtp->cache_auto_store) zrtp_def_cache_store(zrtp); - - return (new_elem) ? zrtp_status_ok : zrtp_status_fail; -} - -zrtp_status_t zrtp_def_cache_get_presh_counter( const zrtp_stringn_t* one_zid, - const zrtp_stringn_t* another_zid, - uint32_t* counter) -{ - zrtp_cache_elem_t* new_elem = 0; - zrtp_cache_id_t id; - - ZRTP_CACHE_CHECK_ZID(one_zid, another_zid); - zrtp_cache_create_id(one_zid, another_zid, id); - - zrtp_mutex_lock(def_cache_protector); - new_elem = get_elem(id, 0); - if (new_elem) { - *counter = new_elem->presh_counter; - } - zrtp_mutex_unlock(def_cache_protector); - - return (new_elem) ? zrtp_status_ok : zrtp_status_fail; -} - - void zrtp_cache_create_id( const zrtp_stringn_t* first_ZID, - const zrtp_stringn_t* second_ZID, - zrtp_cache_id_t id ) -{ - if (0 < zrtp_memcmp(first_ZID->buffer, second_ZID->buffer, sizeof(zrtp_zid_t))) { - const zrtp_stringn_t* tmp_ZID = first_ZID; - first_ZID = second_ZID; - second_ZID = tmp_ZID; - } - - zrtp_memcpy(id, first_ZID->buffer, sizeof(zrtp_zid_t)); - zrtp_memcpy((char*)id+sizeof(zrtp_zid_t), second_ZID->buffer, sizeof(zrtp_zid_t)); -} - -zrtp_cache_elem_t* zrtp_def_cache_get2(const zrtp_cache_id_t id, int is_mitm) -{ - return get_elem(id, is_mitm); -} - - -static zrtp_cache_elem_t* get_elem(const zrtp_cache_id_t id, uint8_t is_mitm) -{ - mlist_t* node = NULL; - mlist_t* head = is_mitm ? &mitmcache_head : &cache_head; - mlist_for_each(node, head) { - zrtp_cache_elem_t* elem = mlist_get_struct(zrtp_cache_elem_t, _mlist, node); - if (!zrtp_memcmp(elem->id, id, sizeof(zrtp_cache_id_t))) { - return elem; - } - } - - return NULL; -} - -static void cache_make_cross(zrtp_cache_elem_t* from, zrtp_cache_elem_t* to, uint8_t is_upload) -{ - if (!to) { - return; - } - - if (from) { - zrtp_memcpy(to, from, sizeof(zrtp_cache_elem_t)); - } - - if (is_upload) { - to->verified = zrtp_ntoh32(to->verified); - to->secure_since= zrtp_ntoh32(to->secure_since); - to->lastused_at = zrtp_ntoh32(to->lastused_at); - to->ttl = zrtp_ntoh32(to->ttl); - to->name_length = zrtp_ntoh32(to->name_length); - to->curr_cache.length = zrtp_ntoh16(to->curr_cache.length); - to->prev_cache.length = zrtp_ntoh16(to->prev_cache.length); - to->presh_counter = zrtp_ntoh32(to->presh_counter); - } else { - to->verified = zrtp_hton32(to->verified); - to->secure_since= zrtp_hton32(to->secure_since); - to->lastused_at = zrtp_hton32(to->lastused_at); - to->ttl = zrtp_hton32(to->ttl); - to->name_length = zrtp_hton32(to->name_length); - to->curr_cache.length = zrtp_hton16(to->curr_cache.length); - to->prev_cache.length = zrtp_hton16(to->prev_cache.length); - to->presh_counter = zrtp_hton32(to->presh_counter); - } -} - - -/*===========================================================================*/ -/* ZRTP cache realization as a simple binary file */ -/*===========================================================================*/ - - -#if ZRTP_HAVE_STDIO_H == 1 - #include -#endif - -#include - -/*---------------------------------------------------------------------------*/ -#define ZRTP_INT_CACHE_BREAK(s, status) \ -{ \ - if (!s) s = status; \ - break; \ -}\ - -zrtp_status_t zrtp_cache_user_init() -{ - FILE* cache_file = 0; - zrtp_cache_elem_t* new_elem = 0; - zrtp_status_t s = zrtp_status_ok; - uint32_t cache_elems_count = 0; - uint32_t mitmcache_elems_count = 0; - uint32_t i = 0; - unsigned is_unsupported = 0; - - ZRTP_LOG(3,(_ZTU_,"\tLoad ZRTP cache from <%s>...\n", zrtp->def_cache_path.buffer)); - - g_mitmcache_elems_counter = 0; - g_cache_elems_counter = 0; - g_needs_rewriting = 0; - - /* Try to open existing file. If ther is no cache file - start with empty cache */ -#if (ZRTP_PLATFORM == ZP_WIN32) - if (0 != fopen_s(&cache_file, zrtp->def_cache_path.buffer, "rb")) { - return zrtp_status_ok; - } -#else - if (0 == (cache_file = fopen(zrtp->def_cache_path.buffer, "rb"))) { - ZRTP_LOG(3,(_ZTU_,"\tCan't open file for reading.\n")); - return zrtp_status_ok; - } -#endif - /* - * Check for the cache file version number. Current version of libzrtp doesn't support - * backward compatibility in zrtp cache file structure, so we just remove the old cache file. - * - * Version field format: $ZRTP_DEF_CACHE_VERSION_STR$ZRTP_DEF_CACHE_VERSION_VAL - */ - do { - char version_buff[256]; - memset(version_buff, 0, sizeof(version_buff)); - - if (fread(version_buff, strlen(ZRTP_DEF_CACHE_VERSION_STR)+strlen(ZRTP_DEF_CACHE_VERSION_VAL), 1, cache_file) <= 0) { - ZRTP_LOG(3,(_ZTU_,"\tCache Error: Cache file is too small.\n")); - is_unsupported = 1; - break; - } - - if (0 != zrtp_memcmp(version_buff, ZRTP_DEF_CACHE_VERSION_STR, strlen(ZRTP_DEF_CACHE_VERSION_STR))) { - ZRTP_LOG(3,(_ZTU_,"\tCache Error: Can't find ZRTP Version tag in the cache file.\n")); - is_unsupported = 1; - break; - } - - ZRTP_LOG(3,(_ZTU_,"\tZRTP cache file has version=%s\n", version_buff+strlen(ZRTP_DEF_CACHE_VERSION_STR))); - - if (0 != zrtp_memcmp(version_buff+strlen(ZRTP_DEF_CACHE_VERSION_STR), ZRTP_DEF_CACHE_VERSION_VAL, strlen(ZRTP_DEF_CACHE_VERSION_VAL))) { - ZRTP_LOG(3,(_ZTU_,"\tCache Error: Unsupported ZRTP cache version.\n")); - is_unsupported = 1; - break; - } - } while (0); - - if (is_unsupported) { - ZRTP_LOG(3,(_ZTU_,"\tCache Error: Unsupported version of ZRTP cache file detected - white-out the cache.\n")); - fclose(cache_file); - return zrtp_status_ok; - } - - /* - * Load MitM caches: first 32 bits is a MiTM secrets counter. Read it and then - * upload appropriate number of MitM secrets. - */ - do { - cache_elems_count = 0; - if (fread(&mitmcache_elems_count, 4, 1, cache_file) <= 0) { - ZRTP_INT_CACHE_BREAK(s, zrtp_status_read_fail); - } - mitmcache_elems_count = zrtp_ntoh32(mitmcache_elems_count); - - ZRTP_LOG(3,(_ZTU_,"\tZRTP cache file contains %u MiTM secrets.\n", mitmcache_elems_count)); - - for (i=0; i_index = g_mitmcache_elems_counter++; - new_elem->_is_dirty = 0; - - mlist_add_tail(&mitmcache_head, &new_elem->_mlist); - } - - if (i != mitmcache_elems_count) - ZRTP_INT_CACHE_BREAK(s, zrtp_status_read_fail); - } while(0); - if (s != zrtp_status_ok) { - fclose(cache_file); - zrtp_def_cache_down(); - return s; - } - - ZRTP_LOG(3,(_ZTU_,"\tAll %u MiTM Cache entries have been uploaded.\n", g_mitmcache_elems_counter)); - - /* - * Load regular caches: first 32 bits is a secrets counter. Read it and then - * upload appropriate number of regular secrets. - */ - cache_elems_count = 0; - if (fread(&cache_elems_count, 4, 1, cache_file) <= 0) { - fclose(cache_file); - zrtp_def_cache_down(); - return zrtp_status_read_fail; - } - cache_elems_count = zrtp_ntoh32(cache_elems_count); - - ZRTP_LOG(3,(_ZTU_,"\tZRTP cache file contains %u RS secrets.\n", cache_elems_count)); - - for (i=0; i_index = g_cache_elems_counter++; - new_elem->_is_dirty = 0; - - mlist_add_tail(&cache_head, &new_elem->_mlist); - } - if (i != cache_elems_count) { - s = zrtp_status_read_fail; - } - - if (0 != fclose(cache_file)) { - zrtp_def_cache_down(); - return zrtp_status_fail; - } - - ZRTP_LOG(3,(_ZTU_,"\tAll of %u RS Cache entries have been uploaded.\n", g_cache_elems_counter)); - - return s; -} - - -#define ZRTP_DOWN_CACHE_RETURN(s, f) \ -{\ - if (zrtp_status_ok != s) { \ - ZRTP_LOG(3,(_ZTU_,"\tERROR! Unable to writing to ZRTP cache file.\n")); \ - } \ - if (f) { \ - fclose(f);\ - } \ - return s;\ -}; - -static zrtp_status_t flush_elem_(zrtp_cache_elem_t *elem, FILE *cache_file, unsigned is_mitm) { - zrtp_cache_elem_t tmp_elem; - uint32_t pos = 0; - - /* - * Let's calculate cache element position in the file - */ - -// @note: I'm going to remove unused comments when random-access cache get more stable. (vkrykun, Nov 27, 2011) -// printf("flush_elem_(): calculate Element offset for %s..\n", is_mitm?"MiTM":"RS"); - - /* Skip the header */ - pos += strlen(ZRTP_DEF_CACHE_VERSION_STR)+strlen(ZRTP_DEF_CACHE_VERSION_VAL); - - pos += sizeof(uint32_t); /* Skip MiTM secretes count. */ - -// printf("flush_elem_(): \t pos=%u (Header, MiTM Count).\n", pos); - - if (is_mitm) { - /* position within MiTM secrets block. */ - pos += (elem->_index * ZRTP_MITMCACHE_ELEM_LENGTH); -// printf("flush_elem_(): \t pos=%u (Header, MiTM Count + %u MiTM Secrets).\n", pos, elem->_index); - } else { - /* Skip MiTM Secrets block */ - pos += (g_mitmcache_elems_counter * ZRTP_MITMCACHE_ELEM_LENGTH); - - pos += sizeof(uint32_t); /* Skip RS elements count. */ - - pos += (elem->_index * ZRTP_CACHE_ELEM_LENGTH); /* Skip previous RS elements */ - -// printf("flush_elem_(): \t pos=%u (Header, MiTM Count + ALL %u Secrets, RS counter and %u prev. RS).\n", pos, g_mitmcache_elems_counter, elem->_index); - } - - fseek(cache_file, pos, SEEK_SET); - - /* Prepare element for storing, convert all fields to the network byte-order. */ - cache_make_cross(elem, &tmp_elem, 0); - -// printf("flush_elem_(): write to offset=%lu\n", ftell(cache_file)); - - /* Flush the element. */ - if (fwrite(&tmp_elem, (is_mitm ? ZRTP_MITMCACHE_ELEM_LENGTH : ZRTP_CACHE_ELEM_LENGTH), 1, cache_file) != 1) { -// printf("flush_elem_(): ERROR!!! write failed!\n"); - return zrtp_status_write_fail; - } else { - elem->_is_dirty = 0; - -// printf("flush_elem_(): OK! %lu bytes were written\n", (is_mitm ? ZRTP_MITMCACHE_ELEM_LENGTH : ZRTP_CACHE_ELEM_LENGTH)); - return zrtp_status_ok; - } -} - -zrtp_status_t zrtp_cache_user_down() -{ - FILE* cache_file = 0; - mlist_t *node = 0; - uint32_t count = 0, dirty_count=0; - uint32_t pos = 0; - - ZRTP_LOG(3,(_ZTU_,"\tStoring ZRTP cache to <%s>...\n", zrtp->def_cache_path.buffer)); - - /* Open/create file for writing */ -#if (ZRTP_PLATFORM == ZP_WIN32) - if (g_needs_rewriting || 0 != fopen_s(&cache_file, zrtp->def_cache_path.buffer, "r+")) { - if (0 != fopen_s(&cache_file, zrtp->def_cache_path.buffer, "w+")) { - ZRTP_LOG(2,(_ZTU_,"\tERROR! unable to open ZRTP cache file <%s>.\n", zrtp->def_cache_path.buffer)); - return zrtp_status_open_fail; - } - } -#else - if (g_needs_rewriting || !(cache_file = fopen(zrtp->def_cache_path.buffer, "r+"))) { - cache_file = fopen(zrtp->def_cache_path.buffer, "w+"); - if (!cache_file) { - ZRTP_LOG(2,(_ZTU_,"\tERROR! unable to open ZRTP cache file <%s>.\n", zrtp->def_cache_path.buffer)); - return zrtp_status_open_fail; - } - } -#endif - - fseek(cache_file, 0, SEEK_SET); - - /* Store version string first. Format: &ZRTP_DEF_CACHE_VERSION_STR&ZRTP_DEF_CACHE_VERSION_VAL */ - if (1 != fwrite(ZRTP_DEF_CACHE_VERSION_STR, strlen(ZRTP_DEF_CACHE_VERSION_STR), 1, cache_file)) { - ZRTP_LOG(2,(_ZTU_,"\tERROR! unable to write header to the cache file\n")); - ZRTP_DOWN_CACHE_RETURN(zrtp_status_write_fail, cache_file); - } - if (1 != fwrite(ZRTP_DEF_CACHE_VERSION_VAL, strlen(ZRTP_DEF_CACHE_VERSION_VAL), 1, cache_file)) { - ZRTP_LOG(2,(_ZTU_,"\tERROR! unable to write header to the cache file\n")); - ZRTP_DOWN_CACHE_RETURN(zrtp_status_write_fail, cache_file); - } - - /* - * Store PBX secrets first. Format: , - * - * NOTE!!! It's IMPORTANT to store PBX secrets before the Regular secrets!!! - */ - pos = ftell(cache_file); - - count = 0; dirty_count = 0; - fwrite(&count, sizeof(count), 1, cache_file); - - mlist_for_each(node, &mitmcache_head) { - zrtp_cache_elem_t* elem = mlist_get_struct(zrtp_cache_elem_t, _mlist, node); - /* Store dirty values only. */ - if (g_needs_rewriting || elem->_is_dirty) { -// printf("zrtp_cache_user_down: Store MiTM elem index=%u, not modified.\n", elem->_index); - dirty_count++; - if (zrtp_status_ok != flush_elem_(elem, cache_file, 1)) { - ZRTP_DOWN_CACHE_RETURN(zrtp_status_write_fail, cache_file); - } - } else { -// printf("zrtp_cache_user_down: Skip MiTM elem index=%u, not modified.\n", elem->_index); - } - } - - fseek(cache_file, pos, SEEK_SET); - - count = zrtp_hton32(g_mitmcache_elems_counter); - if (fwrite(&count, sizeof(count), 1, cache_file) != 1) { - ZRTP_DOWN_CACHE_RETURN(zrtp_status_write_fail, cache_file); - } - - if (dirty_count > 0) - ZRTP_LOG(3,(_ZTU_,"\t%u out of %u MiTM cache entries have been flushed successfully.\n", dirty_count, zrtp_ntoh32(count))); - - /* - * Store regular secrets. Format: , - */ - - /* Seek to the beginning of the Regular secrets block */ - pos = strlen(ZRTP_DEF_CACHE_VERSION_STR)+strlen(ZRTP_DEF_CACHE_VERSION_VAL); - pos += sizeof(uint32_t); /* Skip MiTM secrets count. */ - pos += (g_mitmcache_elems_counter * ZRTP_MITMCACHE_ELEM_LENGTH); /* Skip MiTM Secrets block */ - - fseek(cache_file, pos, SEEK_SET); - - count = 0; dirty_count=0; - fwrite(&count, sizeof(count), 1, cache_file); - - mlist_for_each(node, &cache_head) { - zrtp_cache_elem_t* elem = mlist_get_struct(zrtp_cache_elem_t, _mlist, node); - - /* Store dirty values only. */ - if (g_needs_rewriting || elem->_is_dirty) { -// printf("zrtp_cache_user_down: Store RS elem index=%u, not modified.\n", elem->_index); - dirty_count++; - if (zrtp_status_ok != flush_elem_(elem, cache_file, 0)) { - ZRTP_DOWN_CACHE_RETURN(zrtp_status_write_fail, cache_file); - } - } -// else { -// printf("zrtp_cache_user_down: Skip RS elem index=%u, not modified.\n", elem->_index); -// } - } - - fseek(cache_file, pos, SEEK_SET); - - count = zrtp_hton32(g_cache_elems_counter); - if (fwrite(&count, sizeof(count), 1, cache_file) != 1) { - ZRTP_DOWN_CACHE_RETURN(zrtp_status_write_fail, cache_file); - } - - if (dirty_count > 0) - ZRTP_LOG(3,(_ZTU_,"\t%u out of %u regular cache entries have been flushed successfully.\n", dirty_count, zrtp_ntoh32(count))); - - g_needs_rewriting = 0; - - ZRTP_DOWN_CACHE_RETURN(zrtp_status_ok, cache_file); -} - - -/*==========================================================================*/ -/* Utility functions. */ -/* These functions are example how cache can be used for internal needs */ -/*==========================================================================*/ - - -/*----------------------------------------------------------------------------*/ -static zrtp_status_t put_name( const zrtp_stringn_t* one_ZID, - const zrtp_stringn_t* another_ZID, - const zrtp_stringn_t* name, - uint8_t is_mitm) -{ - zrtp_cache_elem_t* new_elem = 0; - zrtp_cache_id_t id; - zrtp_status_t s = zrtp_status_ok; - - ZRTP_CACHE_CHECK_ZID(one_ZID, another_ZID); - zrtp_cache_create_id(one_ZID, another_ZID, id); - - zrtp_mutex_lock(def_cache_protector); - do { - new_elem = get_elem(id, is_mitm); - if (!new_elem) { - s = zrtp_status_fail; - break; - } - - /* Update regular cache name*/ - new_elem->name_length = ZRTP_MIN(name->length, ZFONE_CACHE_NAME_LENGTH-1); - zrtp_memset(new_elem->name, 0, sizeof(new_elem->name)); - zrtp_memcpy(new_elem->name, name->buffer, new_elem->name_length); - - new_elem->_is_dirty = 1; - } while (0); - zrtp_mutex_unlock(def_cache_protector); - - if (zrtp->cache_auto_store) zrtp_def_cache_store(zrtp); - - return s; -} - - -zrtp_status_t zrtp_def_cache_put_name( const zrtp_stringn_t* one_ZID, - const zrtp_stringn_t* another_ZID, - const zrtp_stringn_t* name) -{ - return put_name(one_ZID, another_ZID, name, 0); -} - - -/*----------------------------------------------------------------------------*/ -static zrtp_status_t get_name( const zrtp_stringn_t* one_ZID, - const zrtp_stringn_t* another_ZID, - zrtp_stringn_t* name, - uint8_t is_mitm) -{ - zrtp_cache_elem_t* new_elem = 0; - zrtp_cache_id_t id; - zrtp_status_t s = zrtp_status_fail; - - ZRTP_CACHE_CHECK_ZID(one_ZID, another_ZID); - zrtp_cache_create_id(one_ZID, another_ZID, id); - - zrtp_mutex_lock(def_cache_protector); - do { - new_elem = get_elem(id, is_mitm); - if (!new_elem) { - s = zrtp_status_fail; - break; - } - - name->length = new_elem->name_length; - zrtp_memcpy(name->buffer, new_elem->name, name->length); - s = zrtp_status_ok; - } while (0); - zrtp_mutex_unlock(def_cache_protector); - - return s; -} - -zrtp_status_t zrtp_def_cache_get_name( const zrtp_stringn_t* one_zid, - const zrtp_stringn_t* another_zid, - zrtp_stringn_t* name) -{ - return get_name(one_zid, another_zid, name, 0); -} - - -/*----------------------------------------------------------------------------*/ -zrtp_status_t zrtp_def_cache_get_since( const zrtp_stringn_t* one_ZID, - const zrtp_stringn_t* another_ZID, - uint32_t* since) -{ - zrtp_cache_elem_t* new_elem = 0; - zrtp_cache_id_t id; - - ZRTP_CACHE_CHECK_ZID(one_ZID, another_ZID); - zrtp_cache_create_id(one_ZID, another_ZID, id); - - zrtp_mutex_lock(def_cache_protector); - new_elem = get_elem(id, 0); - if (new_elem) { - *since = new_elem->secure_since; - } - zrtp_mutex_unlock(def_cache_protector); - - return (new_elem) ? zrtp_status_ok : zrtp_status_fail; -} - -zrtp_status_t zrtp_def_cache_reset_since( const zrtp_stringn_t* one_zid, - const zrtp_stringn_t* another_zid) -{ - zrtp_cache_elem_t* new_elem = 0; - zrtp_cache_id_t id; - - ZRTP_CACHE_CHECK_ZID(one_zid, another_zid); - zrtp_cache_create_id(one_zid, another_zid, id); - - zrtp_mutex_lock(def_cache_protector); - new_elem = get_elem(id, 0); - if (new_elem) { - new_elem->secure_since = (uint32_t)(zrtp_time_now()/1000); - - new_elem->_is_dirty = 1; - } - zrtp_mutex_unlock(def_cache_protector); - - if (zrtp->cache_auto_store) zrtp_def_cache_store(zrtp); - - return (new_elem) ? zrtp_status_ok : zrtp_status_fail; -} - - -/*----------------------------------------------------------------------------*/ -void zrtp_def_cache_foreach( zrtp_global_t *global, - int is_mitm, - zrtp_cache_callback_t callback, - void *data) -{ - int delete, result; - unsigned index_decrease = 0; - mlist_t* node = NULL, *tmp_node = NULL; - - zrtp_mutex_lock(def_cache_protector); - mlist_for_each_safe(node, tmp_node, (is_mitm ? &mitmcache_head : &cache_head)) - { - zrtp_cache_elem_t* elem = mlist_get_struct(zrtp_cache_elem_t, _mlist, node); - - /* - * We are about to delete cache element, in order to keep our - * random-access file working, we should re-arrange indexes of - * cache elements go after the deleting one. - */ - if (index_decrease >0) { - elem->_index -= index_decrease; - } - - delete = 0; - result = callback(elem, is_mitm, data, &delete); - if (delete) { - { - char idstr[24*2+1]; - ZRTP_LOG(3,(_ZTU_,"\trtp_def_cache_foreach() Delete element id=%s index=%u\n", - hex2str((const char*)elem->id, sizeof(elem->id), idstr, sizeof(idstr)), - elem->_index)); - } - - index_decrease++; - - mlist_del(&elem->_mlist); - - /* Decrement global cache counter. */ - if (is_mitm) - g_mitmcache_elems_counter--; - else - g_cache_elems_counter--; - - g_needs_rewriting = 1; - } - if (!result) { - break; - } - } - zrtp_mutex_unlock(def_cache_protector); - - return; -} - -/*----------------------------------------------------------------------------*/ -zrtp_status_t zrtp_def_cache_store(zrtp_global_t *zrtp) -{ - zrtp_mutex_lock(def_cache_protector); - zrtp_cache_user_down(); - zrtp_mutex_unlock(def_cache_protector); - - return zrtp_status_ok; -} - -#endif /* ZRTP_PLATFORM != ZP_WIN32_KERNEL */ - -#endif /* ZRTP_USE_BUILTIN_CACHE */ diff --git a/libs/libzrtp/src/zrtp_iface_scheduler.c b/libs/libzrtp/src/zrtp_iface_scheduler.c deleted file mode 100644 index fe4a2fd014..0000000000 --- a/libs/libzrtp/src/zrtp_iface_scheduler.c +++ /dev/null @@ -1,375 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - -#define _POSIX_C_SOURCE 199309L /* for struct timespec */ -#include "zrtp.h" - -#if (defined(ZRTP_USE_BUILTIN_SCEHDULER) && (ZRTP_USE_BUILTIN_SCEHDULER ==1)) -#if (ZRTP_PLATFORM!=ZP_SYMBIAN) - -#if defined (ZRTP_DEBUG_WITH_PJSIP) && (ZRTP_DEBUG_WITH_PJSIP == 1) -# include -#endif - -/* Windows kernel have it's own realization based on kernel timers */ -#if (ZRTP_PLATFORM != ZP_WIN32_KERNEL) - -#define ZRTP_SCHED_QUEUE_SIZE ZRTP_MAX_STREAMS_PER_SESSION * 1000 -#define ZRTP_SCHED_LOOP_QVANT 20 - -#define ZRTP_SCHED_SLEEP(count) zrtp_sleep(ZRTP_SCHED_LOOP_QVANT*count); - - -/** Schedulling tasks structure */ -typedef struct -{ - zrtp_stream_t *ctx; /** ZRTP stream context associated with the task */ - zrtp_retry_task_t *ztask; /** ZRTP stream associated with the task */ - uint64_t wake_at; /* Wake time in milliseconds */ - mlist_t _mlist; -} zrtp_sched_task_t; - -/** Initiation flag. Protection from reinitialization. (1 if initiated) */ -static uint8_t inited = 0; - -/** Sorted by wake time tasks list. First task to do at the begining */ -static mlist_t tasks_head; - -/** Tasks queue protector againts race conditions on add/remove tasks */ -static zrtp_mutex_t* protector = NULL; - -/** Main queue symaphore */ -static zrtp_sem_t* count = NULL; - -static uint8_t is_running = 0; -#if (ZRTP_PLATFORM == ZP_WIN32 || ZRTP_PLATFORM == ZP_WINCE) -HANDLE scheduler_thread = NULL; -#else -static uint8_t is_working = 0; -#endif - - -/*==========================================================================*/ -/* Platform Dependent Routine */ -/*==========================================================================*/ - -#if (ZRTP_PLATFORM == ZP_WIN32) || (ZRTP_PLATFORM == ZP_WINCE) -#include - -int zrtp_sleep(unsigned int msec) -{ - Sleep(msec); - return 0; -} - -int zrtp_thread_create(zrtp_thread_routine_t start_routine, void *arg) -{ - DWORD dwThreadId; - - scheduler_thread = CreateThread(NULL, 0, start_routine, 0, 0, &dwThreadId); - if (NULL == scheduler_thread) { - return -1; - } - - return 0; -} - -#elif (ZRTP_PLATFORM == ZP_LINUX) || (ZRTP_PLATFORM == ZP_DARWIN) || (ZRTP_PLATFORM == ZP_BSD) || (ZRTP_PLATFORM == ZP_ANDROID) -/* POSIX.1-2008 removes usleep, so use nanosleep instead when available */ -#if ZRTP_HAVE_NANOSLEEP -#include /* for nanosleep */ -#elif ZRTP_HAVE_UNISTD_H == 1 -#include -#else -#error "Used environment dosn't have - zrtp_scheduler can't be build." -#endif - -#if ZRTP_HAVE_PTHREAD_H == 1 -#include -#else -# error "Used environment dosn't have - zrtp_scheduler can't be build." -#endif - -int zrtp_sleep(unsigned int msec) -{ -#if ZRTP_HAVE_NANOSLEEP - struct timespec delay; - delay.tv_sec = msec / 1000; - delay.tv_nsec = (msec % 1000) * 1000000; - while (nanosleep(&delay, &delay)); -#else - usleep(msec*1000); -#endif - return 0; -} - -int zrtp_thread_create(zrtp_thread_routine_t start_routine, void *arg) -{ - pthread_t thread; - return pthread_create(&thread, NULL, start_routine, arg); -} -#endif - - -/*==========================================================================*/ -/* Scheduler Implementation */ -/*==========================================================================*/ -#if (ZRTP_PLATFORM == ZP_WIN32) || (ZRTP_PLATFORM == ZP_WIN64) || (ZRTP_PLATFORM == ZP_WINCE) -static DWORD WINAPI sched_loop(void* param) -#elif (ZRTP_PLATFORM == ZP_SYMBIAN) -static int sched_loop(void* param) -#else -static void* sched_loop(void* param) -#endif -{ -#if defined (ZRTP_DEBUG_WITH_PJSIP) && (ZRTP_DEBUG_WITH_PJSIP == 1) - /* - Register current thread if it was created by - external system call(not pj_sip call) - */ - pj_thread_desc desc; - pj_thread_t *sched_loop_thread; - - if (pj_thread_is_registered()==PJ_FALSE){ - pj_thread_register("zrtp_sched_loop_thread", desc, &sched_loop_thread); - } -#endif - -#if (ZRTP_PLATFORM != ZP_WIN32 && ZRTP_PLATFORM != ZP_WINCE) - is_working = 1; -#endif - while (is_running) - { - zrtp_sched_task_t* task = NULL; - zrtp_sched_task_t task2run; - int ready_2_run = 0; - mlist_t* node = 0; - - /* Wait for tasks in queue */ - zrtp_sem_wait(count); - - zrtp_mutex_lock(protector); - - node = mlist_get(&tasks_head); - if (!node) { - zrtp_mutex_unlock(protector); - continue; - } - - task = mlist_get_struct(zrtp_sched_task_t, _mlist, node); - if (task->wake_at <= zrtp_time_now()) - { - task2run.ctx = task->ctx; - task2run.ztask = task->ztask; - mlist_del(node); - zrtp_sys_free(task); - ready_2_run = 1; - } - - zrtp_mutex_unlock(protector); - - if (ready_2_run) { - task2run.ztask->_is_busy = 1; - task2run.ztask->callback(task2run.ctx, task2run.ztask); - task2run.ztask->_is_busy = 0; - } else { - zrtp_sem_post(count); - } - - ZRTP_SCHED_SLEEP(1); - } - -#if (ZRTP_PLATFORM != ZP_WIN32)&& (ZRTP_PLATFORM != ZP_WINCE) - is_working = 0; -#endif - -#if (ZRTP_PLATFORM != ZP_WIN32) && (ZRTP_PLATFORM != ZP_WIN64) && (ZRTP_PLATFORM != ZP_WINCE) - return NULL; -#else - return 0; -#endif -} - -/*---------------------------------------------------------------------------*/ -zrtp_status_t zrtp_def_scheduler_init(zrtp_global_t* zrtp) -{ - zrtp_status_t status = zrtp_status_ok; - - if (inited) { - return zrtp_status_ok; - } - - do { - init_mlist(&tasks_head); - - if (zrtp_status_ok != (status = zrtp_mutex_init(&protector))) { - break; - } - if (zrtp_status_ok != (status = zrtp_sem_init(&count, 0, ZRTP_SCHED_QUEUE_SIZE))) { - break; - } - - /* Starting processing loop */ - is_running = 1; - - if (0 != zrtp_thread_create(sched_loop, NULL)) { - zrtp_sem_destroy(count); - zrtp_mutex_destroy(protector); - - status = zrtp_status_fail; - break; - } - - inited = 1; - } while (0); - - return status; -} - -/*---------------------------------------------------------------------------*/ -void zrtp_def_scheduler_down() -{ - mlist_t *node = 0, *tmp = 0; - - if (!inited) { - return; - } - - /* Stop main thread */ - is_running = 0; - zrtp_sem_post(count); -#if (ZRTP_PLATFORM == ZP_WIN32) || (ZRTP_PLATFORM == ZP_WINCE) - if (NULL != scheduler_thread) - { - WaitForSingleObject(scheduler_thread, INFINITE); - CloseHandle(scheduler_thread); - scheduler_thread = NULL; - } -#else - while (is_working) { - ZRTP_SCHED_SLEEP(1); - } -#endif - - /* Then destroy tasks queue and realease all other resources */ - zrtp_mutex_lock(protector); - - mlist_for_each_safe(node, tmp, &tasks_head) { - zrtp_sched_task_t* task = mlist_get_struct(zrtp_sched_task_t, _mlist, node); - zrtp_sys_free(task); - } - init_mlist(&tasks_head); - - zrtp_mutex_unlock(protector); - - zrtp_mutex_destroy(protector); - zrtp_sem_destroy(count); - - inited = 0; -} - -/*---------------------------------------------------------------------------*/ -void zrtp_def_scheduler_call_later(zrtp_stream_t *ctx, zrtp_retry_task_t* ztask) -{ - mlist_t *node=0, *tmp=0; - mlist_t* last = &tasks_head; - - zrtp_mutex_lock(protector); - - if (!ztask->_is_enabled) { - zrtp_mutex_unlock(protector); - return; - } - - do { - zrtp_sched_task_t* new_task = zrtp_sys_alloc(sizeof(zrtp_sched_task_t)); - if (!new_task) { - break; - } - - new_task->ctx = ctx; - new_task->ztask = ztask; - new_task->wake_at = zrtp_time_now() + ztask->timeout; - - /* Try to find element with later wacked time than we have */ - mlist_for_each_safe(node, tmp, &tasks_head) { - zrtp_sched_task_t* tmp_task = mlist_get_struct(zrtp_sched_task_t, _mlist, node); - if (tmp_task->wake_at >= new_task->wake_at) { - last = node; - break; - } - } - - /* - * If packet wasn't inserted (empty queue or all elements are smaller) - * Put them to the end of the queue. - */ - mlist_insert(last, &new_task->_mlist); - - zrtp_sem_post(count); - } while (0); - - zrtp_mutex_unlock(protector); -} - -/*---------------------------------------------------------------------------*/ -void zrtp_def_scheduler_cancel_call_later(zrtp_stream_t* ctx, zrtp_retry_task_t* ztask) -{ - mlist_t *node=0, *tmp=0; - - zrtp_mutex_lock(protector); - - mlist_for_each_safe(node, tmp, &tasks_head) { - zrtp_sched_task_t* task = mlist_get_struct(zrtp_sched_task_t, _mlist, node); - if ((task->ctx == ctx) && ((task->ztask == ztask) || !ztask)) { - mlist_del(&task->_mlist); - zrtp_sys_free(task); - zrtp_sem_trtwait(count); - if (ztask) { - break; - } - } - } - - zrtp_mutex_unlock(protector); -} - -void zrtp_def_scheduler_wait_call_later(zrtp_stream_t* ctx) -{ - while (ctx->messages.hello_task._is_busy) { - ZRTP_SCHED_SLEEP(1); - } - while (ctx->messages.commit_task._is_busy) { - ZRTP_SCHED_SLEEP(1); - } - while (ctx->messages.dhpart_task._is_busy) { - ZRTP_SCHED_SLEEP(1); - } - while (ctx->messages.confirm_task._is_busy) { - ZRTP_SCHED_SLEEP(1); - } - while (ctx->messages.error_task._is_busy) { - ZRTP_SCHED_SLEEP(1); - } - while (ctx->messages.errorack_task._is_busy) { - ZRTP_SCHED_SLEEP(1); - } - while (ctx->messages.goclear_task._is_busy) { - ZRTP_SCHED_SLEEP(1); - } - while (ctx->messages.dh_task._is_busy) { - ZRTP_SCHED_SLEEP(1); - } -} - -#endif /* not for windows kernel */ - -#endif // ZRTP_PLATFORM==ZP_SYMBIAN - -#endif /*ZRTP_USE_BUILTIN_SCEHDULER*/ diff --git a/libs/libzrtp/src/zrtp_iface_sys.c b/libs/libzrtp/src/zrtp_iface_sys.c deleted file mode 100644 index f26b651a38..0000000000 --- a/libs/libzrtp/src/zrtp_iface_sys.c +++ /dev/null @@ -1,489 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - -#include "zrtp.h" - -#if (defined(ZRTP_USE_BUILTIN) && (ZRTP_USE_BUILTIN == 1)) - -/*============================================================================*/ -/* Default realization of Mutexes synchronization routine */ -/*============================================================================*/ - -/*---------------------------------------------------------------------------*/ -#if (ZRTP_PLATFORM == ZP_WIN32_KERNEL) -#include - -struct zrtp_mutex_t -{ - NDIS_SPIN_LOCK mutex; -}; - -zrtp_status_t zrtp_mutex_init(zrtp_mutex_t **mutex) -{ - zrtp_mutex_t* new_mutex = zrtp_sys_alloc(sizeof(zrtp_mutex_t)); - if (!new_mutex) - return zrtp_status_alloc_fail; - NdisAllocateSpinLock(&new_mutex->mutex); - *mutex = new_mutex; - return zrtp_status_ok; -} - -zrtp_status_t zrtp_mutex_destroy(zrtp_mutex_t* mutex) -{ - NdisFreeSpinLock(&mutex->mutex); - zrtp_sys_free(mutex); - return zrtp_status_ok; -} - -zrtp_status_t zrtp_mutex_lock(zrtp_mutex_t* mutex) -{ - NdisAcquireSpinLock(&mutex->mutex); - return zrtp_status_ok; -} - -zrtp_status_t zrtp_mutex_unlock(zrtp_mutex_t* mutex) -{ - NdisReleaseSpinLock(&mutex->mutex); - return zrtp_status_ok; -} - -/*---------------------------------------------------------------------------*/ -#elif (ZRTP_PLATFORM == ZP_WIN32) || (ZRTP_PLATFORM == ZP_WIN64) || (ZRTP_PLATFORM == ZP_WINCE) - -#include - -struct zrtp_mutex_t -{ - HANDLE mutex; -}; - -zrtp_status_t zrtp_mutex_init(zrtp_mutex_t** mutex) -{ - zrtp_mutex_t* new_mutex = zrtp_sys_alloc(sizeof(zrtp_mutex_t)); - if (!new_mutex) - return zrtp_status_alloc_fail; - new_mutex->mutex = CreateMutex(NULL, FALSE, NULL); - if (!new_mutex->mutex) { - zrtp_sys_free(new_mutex); - return zrtp_status_fail; - } - *mutex = new_mutex; - return zrtp_status_ok; -} - -zrtp_status_t zrtp_mutex_destroy(zrtp_mutex_t* mutex) -{ - zrtp_status_t s = (0 == CloseHandle(mutex->mutex)) ? zrtp_status_fail : zrtp_status_ok; - zrtp_sys_free(mutex); - return s; -} - -zrtp_status_t zrtp_mutex_lock(zrtp_mutex_t* mutex) -{ - return (WaitForSingleObject(mutex->mutex, INFINITE) == WAIT_FAILED) ? zrtp_status_fail : zrtp_status_ok; -} - -zrtp_status_t zrtp_mutex_unlock(zrtp_mutex_t* mutex) -{ - return (0 == ReleaseMutex(mutex->mutex)) ? zrtp_status_fail : zrtp_status_ok; -} - -/*---------------------------------------------------------------------------*/ -#elif (ZRTP_PLATFORM == ZP_LINUX) || (ZRTP_PLATFORM == ZP_DARWIN) || (ZRTP_PLATFORM == ZP_BSD) || (ZRTP_PLATFORM == ZP_ANDROID) - -#if defined ZRTP_HAVE_PTHREAD_H -# include -#endif - -struct zrtp_mutex_t -{ - pthread_mutex_t mutex; -}; - - -zrtp_status_t zrtp_mutex_init(zrtp_mutex_t** mutex) -{ - zrtp_mutex_t* new_mutex = zrtp_sys_alloc(sizeof(zrtp_mutex_t)); - if (new_mutex) { - zrtp_status_t s = pthread_mutex_init(&new_mutex->mutex, NULL) == 0 ? zrtp_status_ok : zrtp_status_fail; - if (s == zrtp_status_fail) - zrtp_sys_free(new_mutex); - else - *mutex = new_mutex; - return s; - } - return zrtp_status_alloc_fail; -} - -zrtp_status_t zrtp_mutex_destroy(zrtp_mutex_t* mutex) -{ - zrtp_status_t s = (pthread_mutex_destroy(&mutex->mutex) == 0) ? zrtp_status_ok : zrtp_status_fail; - zrtp_sys_free(mutex); - return s; -} - -zrtp_status_t zrtp_mutex_lock(zrtp_mutex_t* mutex) -{ - return (pthread_mutex_lock(&mutex->mutex) == 0) ? zrtp_status_ok : zrtp_status_fail; -} - -zrtp_status_t zrtp_mutex_unlock(zrtp_mutex_t* mutex) -{ - return (pthread_mutex_unlock(&mutex->mutex) == 0) ? zrtp_status_ok : zrtp_status_fail; -} - -#endif - - -/*============================================================================*/ -/* Default realization of Semaphores synchronization routine */ -/*============================================================================*/ - -#if (ZRTP_PLATFORM == ZP_WIN32_KERNEL) - -struct zrtp_sem_t -{ - KSEMAPHORE sem; -}; - -zrtp_status_t zrtp_sem_init(zrtp_sem_t** sem, uint32_t val, uint32_t limit) -{ - zrtp_sem_t *new_sem = zrtp_sys_alloc(sizeof(zrtp_sem_t)); - if (NULL == new_sem) { - return zrtp_status_alloc_fail; - } - - KeInitializeSemaphore(&new_sem->sem, val, limit); - *sem = new_sem; - return zrtp_status_ok; -} - -zrtp_status_t zrtp_sem_destroy(zrtp_sem_t* sem) -{ - return zrtp_status_ok; -} - -zrtp_status_t zrtp_sem_wait(zrtp_sem_t* sem) -{ - return KeWaitForSingleObject(&sem->sem, Executive, KernelMode, FALSE, NULL) == STATUS_SUCCESS ? - zrtp_status_ok : zrtp_status_fail; -} - -zrtp_status_t zrtp_sem_trtwait(zrtp_sem_t* sem) -{ - LARGE_INTEGER timeout; - timeout.QuadPart = 0; - - return KeWaitForSingleObject(&sem->sem, Executive, KernelMode, FALSE, &timeout) == STATUS_SUCCESS ? - zrtp_status_ok : zrtp_status_fail; -} - -zrtp_status_t zrtp_sem_post(zrtp_sem_t* sem) -{ - KeReleaseSemaphore(&sem->sem, IO_NO_INCREMENT, 1, FALSE); - return zrtp_status_ok; -} - - -#elif (ZRTP_PLATFORM == ZP_WIN32) || (ZRTP_PLATFORM == ZP_WIN64) || (ZRTP_PLATFORM == ZP_WINCE) - -struct zrtp_sem_t -{ - HANDLE sem; -}; - -zrtp_status_t zrtp_sem_init(zrtp_sem_t** sem, uint32_t val, uint32_t limit) -{ - zrtp_sem_t *new_sem = zrtp_sys_alloc(sizeof(zrtp_sem_t)); - if (NULL == new_sem) { - return zrtp_status_alloc_fail; - } - - new_sem->sem = CreateSemaphore(NULL, val, limit, NULL); - if (!new_sem->sem) { - zrtp_sys_free(new_sem); - return zrtp_status_fail; - } - *sem = new_sem; - return zrtp_status_ok; -} - -zrtp_status_t zrtp_sem_destroy(zrtp_sem_t* sem) -{ - zrtp_status_t s = (0 == CloseHandle(sem->sem)) ? zrtp_status_fail : zrtp_status_ok; - zrtp_sys_free(sem); - return s; -} - -zrtp_status_t zrtp_sem_wait(zrtp_sem_t* sem) -{ - return (WaitForSingleObject(sem->sem, INFINITE) == WAIT_FAILED) ? zrtp_status_fail : zrtp_status_ok; -} - -zrtp_status_t zrtp_sem_trtwait(zrtp_sem_t* sem) -{ - return (WaitForSingleObject(sem->sem, 0) == WAIT_OBJECT_0) ? zrtp_status_ok : zrtp_status_fail; -} - -zrtp_status_t zrtp_sem_post(zrtp_sem_t* sem) -{ - return (0 == ReleaseSemaphore(sem->sem, 1, NULL)) ? zrtp_status_fail : zrtp_status_ok; -} - -#elif (ZRTP_PLATFORM == ZP_LINUX) || (ZRTP_PLATFORM == ZP_DARWIN) || (ZRTP_PLATFORM == ZP_BSD) || (ZRTP_PLATFORM == ZP_ANDROID) - -#if defined ZRTP_HAVE_STDIO_H -# include -#endif -#if ZRTP_HAVE_SEMAPHORE_H -# include -#endif -#if ZRTP_HAVE_FCNTL_H -# include -#endif -#if ZRTP_HAVE_ERRNO_H -# include -#endif - - -#if (ZRTP_PLATFORM == ZP_DARWIN) - -struct zrtp_sem_t -{ - sem_t* sem; -}; - -zrtp_status_t zrtp_sem_init(zrtp_sem_t** sem, uint32_t value, uint32_t limit) -{ - zrtp_status_t s = zrtp_status_ok; - char name_buff[48]; - zrtp_time_t now = zrtp_time_now(); - - zrtp_sem_t *new_sem = (zrtp_sem_t*)zrtp_sys_alloc(sizeof(zrtp_sem_t)); - if (0 == new_sem) { - return zrtp_status_alloc_fail; - } - - /* - * This bogusness is to follow what appears to be the lowest common - * denominator in Posix semaphore naming: - * - start with '/' - * - be at most 15 chars - * - be unique and not match anything on the filesystem - * We suppose to generate unique name for every semaphore in the system. - */ - - sprintf(name_buff, "/libzrtp.%llxZ%llx", now/1000, now); - new_sem->sem = sem_open(name_buff, O_CREAT | O_EXCL, S_IRUSR|S_IWUSR, value); - if ((sem_t *)SEM_FAILED == new_sem->sem) { - if (errno == ENAMETOOLONG) { - name_buff[13] = '\0'; - } else if (errno == EEXIST) { - sprintf(name_buff, "/libzrtp.%llxZ%llx", now, now/1000); - } else { - s = zrtp_status_fail; - } - new_sem->sem = sem_open(name_buff, O_CREAT | O_EXCL, 0644, value); - } - - if (new_sem->sem == (sem_t *)SEM_FAILED) { - s = zrtp_status_fail; - zrtp_sys_free(new_sem); - } else { - sem_unlink(name_buff); - *sem = new_sem; - } - - return s; -} - -zrtp_status_t zrtp_sem_destroy(zrtp_sem_t* sem) -{ - zrtp_status_t s = sem_close(sem->sem); - zrtp_sys_free(sem); - if (0 != s) { - s = zrtp_status_fail; - } - - return s; -} - -zrtp_status_t zrtp_sem_wait(zrtp_sem_t* sem) -{ - return (sem_wait(sem->sem) == 0) ? zrtp_status_ok : zrtp_status_fail; -} - -zrtp_status_t zrtp_sem_trtwait(zrtp_sem_t* sem) -{ - return (sem_trywait(sem->sem) == 0) ? zrtp_status_ok : zrtp_status_fail; -} - -zrtp_status_t zrtp_sem_post(zrtp_sem_t* sem) -{ - return (sem_post(sem->sem) == 0) ? zrtp_status_ok : zrtp_status_fail; -} - -#else - -struct zrtp_sem_t -{ - sem_t sem; -}; - - -zrtp_status_t zrtp_sem_init(zrtp_sem_t** sem, uint32_t value, uint32_t limit) -{ - zrtp_sem_t *new_sem = (zrtp_sem_t*)zrtp_sys_alloc(sizeof(zrtp_sem_t)); - if (NULL == new_sem) { - return zrtp_status_alloc_fail; - } - - if (sem_init(&new_sem->sem, 0, value) != 0) { - zrtp_sys_free(new_sem); - return zrtp_status_fail; - } - - *sem = new_sem; - return zrtp_status_ok; -} - -zrtp_status_t zrtp_sem_destroy(zrtp_sem_t* sem) -{ - zrtp_status_t s = sem_destroy(&sem->sem) == 0 ? zrtp_status_ok : zrtp_status_fail; - zrtp_sys_free(sem); - return s; -} - -zrtp_status_t zrtp_sem_wait(zrtp_sem_t* sem) -{ - return (sem_wait(&sem->sem) == 0) ? zrtp_status_ok : zrtp_status_fail; -} - -zrtp_status_t zrtp_sem_trtwait(zrtp_sem_t* sem) -{ - return (sem_trywait(&sem->sem) == 0) ? zrtp_status_ok : zrtp_status_fail; -} - -zrtp_status_t zrtp_sem_post(zrtp_sem_t* sem) -{ - return (sem_post(&sem->sem) == 0) ? zrtp_status_ok : zrtp_status_fail; -} - - -#endif - - -#endif - - -/*============================================================================*/ -/* Default realization of general routine */ -/*============================================================================*/ - -#if defined ZRTP_HAVE_STRING_H -# include /* for memset() and memcpy() */ -#endif - -/*----------------------------------------------------------------------------*/ -#if (ZRTP_PLATFORM == ZP_WIN32_KERNEL) - -void* zrtp_sys_alloc(unsigned int size) -{ - void *VA; - return (NDIS_STATUS_SUCCESS != NdisAllocateMemoryWithTag(&VA, size, (ULONG)"zrtp")) ? NULL : VA; -} - -void zrtp_sys_free(void* obj) -{ - /* Length is 0 because memory was allocated with TAG */ - NdisFreeMemory(obj, 0, 0); -} - -void* zrtp_memcpy(void* dest, const void* src, unsigned int length) -{ - return memcpy(dest,src,length); -} - -void *zrtp_memset(void *s, int c, unsigned int n) -{ - return memset(s, c, n); -} - -zrtp_time_t zrtp_time_now() -{ - LARGE_INTEGER ft; - KeQuerySystemTime(&ft); - - ft.QuadPart -= 116444736000000000; - return (zrtp_time_t)(ft.QuadPart) / 10000; -} -#else - -/*---------------------------------------------------------------------------*/ -#if (ZRTP_PLATFORM == ZP_WIN32) || (ZRTP_PLATFORM == ZP_WIN64) || (ZRTP_PLATFORM == ZP_WINCE) - -zrtp_time_t zrtp_time_now() -{ - LONGLONG ft; - -#if ZRTP_PLATFORM != ZP_WINCE - GetSystemTimeAsFileTime((LPFILETIME)&ft); -#else - SYSTEMTIME SystemTime; - GetSystemTime(&SystemTime); - SystemTimeToFileTime(&SystemTime, (LPFILETIME)&ft); -#endif - - ft -= 116444736000000000; - return (zrtp_time_t)(ft) / 10000; -} - -/*---------------------------------------------------------------------------*/ -#elif (ZRTP_PLATFORM == ZP_LINUX) || (ZRTP_PLATFORM == ZP_DARWIN) || (ZRTP_PLATFORM == ZP_SYMBIAN) || (ZRTP_PLATFORM == ZP_BSD) || (ZRTP_PLATFORM == ZP_ANDROID) - -#if defined ZRTP_HAVE_SYS_TIME_H -# include -#endif - -zrtp_time_t zrtp_time_now() -{ - struct timeval tv; - if (0 == gettimeofday(&tv, 0)) { - return (zrtp_time_t)(tv.tv_sec)*1000 + (zrtp_time_t)(tv.tv_usec)/1000; - } - return 0; -} -#endif - - -void *zrtp_memset(void *s, int c, unsigned int n) -{ - memset(s, c, n); - return s; -} - -void* zrtp_memcpy(void* dest, const void* src, unsigned int length) -{ - memcpy(dest, src, (size_t)length); - return dest; -} - -void* zrtp_sys_alloc(unsigned int size) -{ - return malloc((size_t)size); -} - -void zrtp_sys_free(void* obj) -{ - free(obj); -} - -#endif /* default platform-dependent components realizations */ - -#endif /*ZRTP_USE_BUILTIN*/ diff --git a/libs/libzrtp/src/zrtp_initiator.c b/libs/libzrtp/src/zrtp_initiator.c deleted file mode 100644 index c23eb78512..0000000000 --- a/libs/libzrtp/src/zrtp_initiator.c +++ /dev/null @@ -1,557 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - -#include "zrtp.h" - -#define _ZTU_ "zrtp initiator" - -extern zrtp_status_t _zrtp_machine_start_initiating_secure(zrtp_stream_t *stream); - -/*! These functions set constructs and start ZRTP messages replays */ -static zrtp_status_t _zrtp_machine_start_send_and_resend_commit(zrtp_stream_t *stream); -static zrtp_status_t _zrtp_machine_start_send_and_resend_dhpart2(zrtp_stream_t *stream); -static zrtp_status_t _zrtp_machine_start_send_and_resend_confirm2(zrtp_stream_t *stream); - -/*! - * We need to know the contents of the DH2 packet before we send the Commit to - * compute the hash value. So, we construct DH packet but don't send it till - * WAITING_FOR_CONFIRM1 state. -*/ -static void _prepare_dhpart2(zrtp_stream_t *stream); - -/* - * Parses DH packet: check for MitM1 attack and makes a copy of the packet for - * later. \exception: Handles all exceptions -- informs user and switches to - * CLEAR.(MITM attacks) - */ -static zrtp_status_t _zrtp_machine_process_incoming_dhpart1( zrtp_stream_t *stream, - zrtp_rtp_info_t *packet); -/* - * Just a wrapper over the protocol::_zrtp_machine_process_confirm(). - * \exception: Handles all exceptions -- informs user and switches to - * CLEAR. (SOFTWARE) - */ -static zrtp_status_t _zrtp_machine_process_incoming_confirm1( zrtp_stream_t *stream, - zrtp_rtp_info_t *packet); - - -/*===========================================================================*/ -/* State handlers */ -/*===========================================================================*/ - -/*---------------------------------------------------------------------------*/ -zrtp_status_t _zrtp_machine_process_while_in_initiatingsecure( zrtp_stream_t* stream, - zrtp_rtp_info_t* packet) -{ - zrtp_status_t s = zrtp_status_ok; - - switch (packet->type) - { - case ZRTP_COMMIT: - if (ZRTP_STATEMACHINE_RESPONDER == _zrtp_machine_preparse_commit(stream, packet)) { - _zrtp_cancel_send_packet_later(stream, ZRTP_COMMIT); - s = _zrtp_machine_enter_pendingsecure(stream, packet); - } - break; - - case ZRTP_DHPART1: - if (ZRTP_IS_STREAM_DH(stream)) { - _zrtp_cancel_send_packet_later(stream, ZRTP_COMMIT); - - s = _zrtp_machine_process_incoming_dhpart1(stream, packet); - if (zrtp_status_ok != s) { - ZRTP_LOG(1,(_ZTU_,"\tERROR! _zrtp_machine_process_incoming_dhpart1() failed with status=%d ID=%u\n.", s, stream->id)); - break; - } - - _zrtp_machine_start_send_and_resend_dhpart2(stream); - - /* Perform Key generation according to draft 5.6 */ - s = _zrtp_set_public_value(stream, 1); - if (zrtp_status_ok != s) { - ZRTP_LOG(1,(_ZTU_,"\tERROR! set_public_value1() failed with status=%d ID=%u.\n", s, stream->id)); - _zrtp_machine_enter_initiatingerror(stream, zrtp_error_software, 1); - break; - } - - _zrtp_change_state(stream, ZRTP_STATE_WAIT_CONFIRM1); - } - break; - - case ZRTP_CONFIRM1: - if (ZRTP_IS_STREAM_FAST(stream)) { - s = _zrtp_set_public_value(stream, 1); - if (zrtp_status_ok != s) { - break; - } - - s = _zrtp_machine_process_incoming_confirm1(stream, packet); - if (zrtp_status_ok != s) { - ZRTP_LOG(1,(_ZTU_,"\tERROR! process_incoming_confirm1() failed with status=%d ID=%u.\n", s, stream->id)); - break; - } - - _zrtp_cancel_send_packet_later(stream, ZRTP_COMMIT); - _zrtp_change_state(stream, ZRTP_STATE_WAIT_CONFIRMACK); - s = _zrtp_machine_start_send_and_resend_confirm2(stream); - } - break; - - case ZRTP_NONE: - s = zrtp_status_drop; - break; - - default: - break; - } - - return s; -} - -/*---------------------------------------------------------------------------*/ -zrtp_status_t _zrtp_machine_process_while_in_waitconfirm1( zrtp_stream_t* stream, - zrtp_rtp_info_t* packet) -{ - zrtp_status_t s = zrtp_status_ok; - - switch (packet->type) - { - case ZRTP_CONFIRM1: - s = _zrtp_machine_process_incoming_confirm1(stream, packet); - if (zrtp_status_ok != s) { - ZRTP_LOG(1,(_ZTU_,"\tERROR! process_incoming_confirm1() failed with status=%d ID=%u.\n", s, stream->id)); - break; - } - - _zrtp_change_state(stream, ZRTP_STATE_WAIT_CONFIRMACK); - _zrtp_cancel_send_packet_later(stream, ZRTP_DHPART2); - s = _zrtp_machine_start_send_and_resend_confirm2(stream); - break; - - case ZRTP_NONE: - s = zrtp_status_drop; - break; - - default: - break; - } - - return s; -} - -/*---------------------------------------------------------------------------*/ -zrtp_status_t _zrtp_machine_process_while_in_waitconfirmack( zrtp_stream_t* stream, - zrtp_rtp_info_t* packet) -{ - zrtp_status_t s = zrtp_status_ok; - - switch (packet->type) - { - case ZRTP_NONE: - s = _zrtp_protocol_decrypt(stream->protocol, packet, 1); - if (s == zrtp_status_ok) { - /* - * High level functions triggers mutexes for protocol messages only. - * We have manually protect this transaction triggered by media packet, not protocol packet. - */ - zrtp_mutex_lock(stream->stream_protector); - - ZRTP_LOG(3,(_ZTU_, "Received FIRST VALID SRTP packet - switching to SECURE state. ID=%u\n", stream->id)); - _zrtp_cancel_send_packet_later(stream, ZRTP_CONFIRM2); - _zrtp_machine_enter_secure(stream); - - zrtp_mutex_unlock(stream->stream_protector); - } - break; - - case ZRTP_CONFIRM2ACK: - _zrtp_cancel_send_packet_later(stream, ZRTP_CONFIRM2); - s = _zrtp_machine_enter_secure(stream); - break; - - default: - break; - } - - return s; -} - - -/*===========================================================================*/ -/* State switchers */ -/*===========================================================================*/ - -/*---------------------------------------------------------------------------*/ -zrtp_status_t _zrtp_machine_enter_initiatingsecure(zrtp_stream_t* stream) -{ - zrtp_status_t s = zrtp_status_ok; - - ZRTP_LOG(3,(_ZTU_,"\tENTER STATE INITIATING SECURE for ID=%u mode=%s state=%s.\n", - stream->id, zrtp_log_mode2str(stream->mode), zrtp_log_state2str(stream->state))); - - if (!ZRTP_IS_STREAM_MULT(stream)) { - uint8_t id = ZRTP_COMP_UNKN; - zrtp_session_t *session = stream->session; - zrtp_packet_Hello_t *peer_hello = &stream->messages.peer_hello; - - /* - * ZRTP specification provides that default crypto components may be - * omitted from the Hello message, so we initialize components with - * default values. - */ - session->hash = zrtp_comp_find(ZRTP_CC_HASH, ZRTP_HASH_SHA256, session->zrtp); - session->blockcipher = zrtp_comp_find(ZRTP_CC_CIPHER, ZRTP_CIPHER_AES128, session->zrtp); - session->authtaglength = zrtp_comp_find(ZRTP_CC_ATL, ZRTP_ATL_HS32, session->zrtp); - session->sasscheme = zrtp_comp_find(ZRTP_CC_SAS, ZRTP_SAS_BASE32, session->zrtp); - - id = _zrtp_choose_best_comp(&session->profile, peer_hello, ZRTP_CC_HASH); - if (id != ZRTP_COMP_UNKN) { - session->hash = zrtp_comp_find(ZRTP_CC_HASH, id, session->zrtp); - } - id = _zrtp_choose_best_comp(&session->profile, peer_hello, ZRTP_CC_CIPHER); - if (id != ZRTP_COMP_UNKN) { - session->blockcipher = zrtp_comp_find(ZRTP_CC_CIPHER, id, session->zrtp); - } - id = _zrtp_choose_best_comp(&session->profile, peer_hello, ZRTP_CC_ATL); - if (id != ZRTP_COMP_UNKN) { - session->authtaglength = zrtp_comp_find(ZRTP_CC_ATL, id, session->zrtp); - } - id = _zrtp_choose_best_comp(&session->profile, peer_hello, ZRTP_CC_SAS); - if (id != ZRTP_COMP_UNKN) { - session->sasscheme = zrtp_comp_find(ZRTP_CC_SAS, id, session->zrtp); - } - - ZRTP_LOG(3,(_ZTU_,"\tInitiator selected following options:\n")); - ZRTP_LOG(3,(_ZTU_,"\t Hash: %.4s\n", session->hash->base.type)); - ZRTP_LOG(3,(_ZTU_,"\t Cipher: %.4s\n", session->blockcipher->base.type)); - ZRTP_LOG(3,(_ZTU_,"\t ATL: %.4s\n", session->authtaglength->base.type)); - ZRTP_LOG(3,(_ZTU_,"\tVAD scheme: %.4s\n", session->sasscheme->base.type)); - } - - do{ - /* Allocate resources for Initiator's state-machine */ - s = _zrtp_protocol_init(stream, 1, &stream->protocol); - if (zrtp_status_ok != s) { - break; /* Software error */ - } - - _zrtp_change_state(stream, ZRTP_STATE_INITIATINGSECURE); - - /* Prepare DHPart2 message to compute hvi. For DH and Preshared streams only*/ - if (ZRTP_IS_STREAM_DH(stream)) { - _prepare_dhpart2(stream); - } - - s = _zrtp_machine_start_send_and_resend_commit(stream); - if (zrtp_status_ok != s) { - break; /* EH: Software error */ - } - - if (stream->zrtp->cb.event_cb.on_zrtp_protocol_event) { - stream->zrtp->cb.event_cb.on_zrtp_protocol_event(stream, ZRTP_EVENT_IS_INITIATINGSECURE); - } - } while (0); - - if (zrtp_status_ok != s) { - if (stream->protocol) { - _zrtp_protocol_destroy(stream->protocol); - stream->protocol = NULL; - } - _zrtp_machine_enter_initiatingerror(stream, zrtp_error_software, 1); - } - - if (ZRTP_IS_STREAM_DH(stream)) { - /* - * If stream->concurrent is set this means that we stopped a concurrent - * DH stream to break a tie. This can happen when Commit messages are - * sent by both ZRTP endpoints at the same time, but are received in - * different media streams. Now current stream has finished DH setup and - * we can resume the other one. - */ - if (stream->concurrent) { - zrtp_stream_t* tctx = stream->concurrent; - stream->concurrent = NULL; - ZRTP_LOG(3,(_ZTU_,"\tRelease Concurrent Stream ID=%u. ID=%u\n", tctx->id, stream->id)); - _zrtp_machine_start_initiating_secure(tctx); - } - } - - - return s; -} - - -/*===========================================================================*/ -/* Packet handlers */ -/*===========================================================================*/ - -/*---------------------------------------------------------------------------*/ -static zrtp_status_t _zrtp_machine_process_incoming_dhpart1( zrtp_stream_t *stream, - zrtp_rtp_info_t *packet) -{ - zrtp_status_t s = zrtp_status_ok; - zrtp_packet_DHPart_t *dhpart1 = (zrtp_packet_DHPart_t*) packet->message; - - /* Validating DH (pvr is 1 or p-1) */ - bnInsertBigBytes(&stream->dh_cc.peer_pv, dhpart1->pv, 0, stream->pubkeyscheme->pv_length); - - s = stream->pubkeyscheme->validate(stream->pubkeyscheme, &stream->dh_cc.peer_pv); - if (zrtp_status_ok != s) { - ZRTP_LOG(2,(_ZTU_,"\tERROR! " ZRTP_MITM1_WARNING_STR " ID=%u\n", stream->id)); - _zrtp_machine_enter_initiatingerror(stream, zrtp_error_possible_mitm1, 1); - return s; - } - - /* Copy DH Part1 packet for further hashing */ - zrtp_memcpy(&stream->messages.peer_dhpart, dhpart1, zrtp_ntoh16(dhpart1->hdr.length)*4); - - return s; -} - -/*----------------------------------------------------------------------------*/ -static zrtp_status_t _zrtp_machine_process_incoming_confirm1( zrtp_stream_t *stream, - zrtp_rtp_info_t *packet) -{ - return _zrtp_machine_process_confirm(stream, (zrtp_packet_Confirm_t*) packet->message); -} - - -/*===========================================================================*/ -/* Packet senders */ -/*===========================================================================*/ - -static void _send_and_resend_commit(zrtp_stream_t *stream, zrtp_retry_task_t* task) -{ - if (task->_retrys >= ZRTP_T2_MAX_COUNT) { - ZRTP_LOG(2,(_ZTU_,"WARNING! COMMIT Max retransmissions count reached. ID=%u\n", stream->id)); - _zrtp_machine_enter_initiatingerror(stream, zrtp_error_timeout, 0); - } else if (task->_is_enabled) { - zrtp_status_t s = zrtp_status_fail; - zrtp_packet_Commit_t* commit = (zrtp_packet_Commit_t*) &stream->messages.commit; - - s = _zrtp_packet_send_message(stream, ZRTP_COMMIT, commit); - task->timeout = _zrtp_get_timeout((uint32_t)task->timeout, ZRTP_COMMIT); - if (s == zrtp_status_ok) { - task->_retrys++; - } - if (stream->zrtp->cb.sched_cb.on_call_later) { - stream->zrtp->cb.sched_cb.on_call_later(stream, task); - } - } -} - -/*---------------------------------------------------------------------------*/ -static zrtp_status_t _zrtp_machine_start_send_and_resend_commit(zrtp_stream_t *stream) -{ - zrtp_proto_crypto_t* cc = stream->protocol->cc; - zrtp_packet_Commit_t* commit = &stream->messages.commit; - zrtp_retry_task_t* task = &stream->messages.commit_task; - uint8_t hmac_offset = ZRTP_COMMIT_STATIC_SIZE; - zrtp_session_t *session = stream->session; - - zrtp_memcpy(commit->zid, stream->messages.hello.zid, sizeof(zrtp_zid_t)); - - zrtp_memcpy(commit->hash_type, session->hash->base.type, ZRTP_COMP_TYPE_SIZE); - zrtp_memcpy(commit->cipher_type, session->blockcipher->base.type, ZRTP_COMP_TYPE_SIZE); - zrtp_memcpy(commit->auth_tag_length, session->authtaglength->base.type, ZRTP_COMP_TYPE_SIZE ); - zrtp_memcpy(commit->public_key_type, stream->pubkeyscheme->base.type, ZRTP_COMP_TYPE_SIZE); - zrtp_memcpy(commit->sas_type, session->sasscheme->base.type, ZRTP_COMP_TYPE_SIZE); - - /* - * According to the last version of the internet draft 08b., hvi should be - * computed as: - * a) hvi=hash(initiator's DHPart2 message | responder's Hello message) for DH stream. - * b) For Multistream it just a 128 bit random nonce. - * c) For Preshared streams it keyID = HMAC(preshared_key, "Prsh") truncated to 64 bits - */ - switch (stream->mode) - { - case ZRTP_STREAM_MODE_DH: - { - void *hash_ctx = session->hash->hash_begin(session->hash); - if (!hash_ctx) { - return zrtp_status_alloc_fail; - } - - session->hash->hash_update( session->hash, - hash_ctx, - (const int8_t*)&stream->messages.dhpart, - zrtp_ntoh16(stream->messages.dhpart.hdr.length)*4); - session->hash->hash_update( session->hash, - hash_ctx, - (const int8_t*)&stream->messages.peer_hello, - zrtp_ntoh16(stream->messages.peer_hello.hdr.length)*4); - - session->hash->hash_end(session->hash, hash_ctx, ZSTR_GV(cc->hv)); - zrtp_memcpy(commit->hv, cc->hv.buffer, ZRTP_HV_SIZE); - hmac_offset += ZRTP_HV_SIZE; - } break; - - case ZRTP_STREAM_MODE_PRESHARED: - { - zrtp_string8_t key_id = ZSTR_INIT_EMPTY(key_id); - zrtp_status_t s = zrtp_status_ok; - - /* Generate random 4 word nonce */ - if (ZRTP_HV_NONCE_SIZE != zrtp_randstr(session->zrtp, (unsigned char*)cc->hv.buffer, ZRTP_HV_NONCE_SIZE)) { - return zrtp_status_rng_fail; - } - cc->hv.length = ZRTP_HV_NONCE_SIZE; - - /* - * Generate Preshared_key: - * hash(len(rs1) | rs1 | len(auxsecret) | auxsecret | len(pbxsecret) | pbxsecret) - */ - s = _zrtp_compute_preshared_key( session, - ZSTR_GV(session->secrets.rs1->value), - (session->secrets.auxs->_cachedflag) ? ZSTR_GV(session->secrets.auxs->value) : NULL, - (session->secrets.pbxs->_cachedflag) ? ZSTR_GV(session->secrets.pbxs->value) : NULL, - NULL, - ZSTR_GV(key_id)); - if (zrtp_status_ok != s) { - return s; - } - - /* Copy 4 word nonce and add 2 word keyID */ - zrtp_memcpy(commit->hv, cc->hv.buffer, ZRTP_HV_NONCE_SIZE); - hmac_offset += ZRTP_HV_NONCE_SIZE; - - zrtp_memcpy(commit->hv+ZRTP_HV_NONCE_SIZE, key_id.buffer, ZRTP_HV_KEY_SIZE); - hmac_offset += ZRTP_HV_KEY_SIZE; - } break; - - case ZRTP_STREAM_MODE_MULT: - { - if(ZRTP_HV_NONCE_SIZE != zrtp_randstr(session->zrtp, (unsigned char*)cc->hv.buffer, ZRTP_HV_NONCE_SIZE)) { - return zrtp_status_rng_fail; - } - - cc->hv.length = ZRTP_HV_NONCE_SIZE; - zrtp_memcpy(commit->hv, cc->hv.buffer, ZRTP_HV_NONCE_SIZE); - hmac_offset += ZRTP_HV_NONCE_SIZE; - }break; - default: break; - } - - _zrtp_packet_fill_msg_hdr(stream, ZRTP_COMMIT, hmac_offset + ZRTP_HMAC_SIZE, &commit->hdr); - - { - char buff[256]; - ZRTP_LOG(3,(_ZTU_,"\tStart Sending COMMIT ID=%u mode=%s state=%s:\n", - stream->id, zrtp_log_mode2str(stream->mode), zrtp_log_state2str(stream->state))); - ZRTP_LOG(3,(_ZTU_,"\t Hash: %.4s\n", commit->hash_type)); - ZRTP_LOG(3,(_ZTU_,"\t Cipher: %.4s\n", commit->cipher_type)); - ZRTP_LOG(3,(_ZTU_,"\t ATL: %.4s\n", commit->auth_tag_length)); - ZRTP_LOG(3,(_ZTU_,"\t PK scheme: %.4s\n", commit->public_key_type)); - ZRTP_LOG(3,(_ZTU_,"\tVAD scheme: %.4s\n", commit->sas_type)); - - ZRTP_LOG(3,(_ZTU_,"\t hv: %s\n", hex2str((const char*)commit->hv, ZRTP_HV_SIZE, (char*)buff, sizeof(buff)))); - } - - task->_is_enabled = 1; - task->callback = _send_and_resend_commit; - task->_retrys = 0; - _send_and_resend_commit(stream, task); - - return zrtp_status_ok; -} - -/*----------------------------------------------------------------------------*/ -static void _send_and_resend_dhpart2(zrtp_stream_t *stream, zrtp_retry_task_t* task) -{ - if (task->_retrys >= ZRTP_T2_MAX_COUNT) - { - ZRTP_LOG(1,(_ZTU_,"WARNING! DH2 Max retransmissions count reached. ID=%u\n", stream->id)); - _zrtp_machine_enter_initiatingerror(stream, zrtp_error_timeout, 0); - } else if (task->_is_enabled) { - zrtp_status_t s = _zrtp_packet_send_message(stream, ZRTP_DHPART2, &stream->messages.dhpart); - task->timeout = _zrtp_get_timeout((uint32_t)task->timeout, ZRTP_DHPART2); - if (zrtp_status_ok == s) { - task->_retrys++; - } - if (stream->zrtp->cb.sched_cb.on_call_later) { - stream->zrtp->cb.sched_cb.on_call_later(stream, task); - } - } -} - -static void _prepare_dhpart2(zrtp_stream_t *stream) -{ - zrtp_proto_crypto_t* cc = stream->protocol->cc; - zrtp_packet_DHPart_t *dh2 = &stream->messages.dhpart; - uint16_t dh_length = (uint16_t)stream->pubkeyscheme->pv_length; - - zrtp_memcpy(dh2->rs1ID, cc->rs1.id.buffer, ZRTP_RSID_SIZE); - zrtp_memcpy(dh2->rs2ID, cc->rs2.id.buffer, ZRTP_RSID_SIZE); - zrtp_memcpy(dh2->auxsID, cc->auxs.id.buffer, ZRTP_RSID_SIZE); - zrtp_memcpy(dh2->pbxsID, cc->pbxs.id.buffer, ZRTP_RSID_SIZE); - - bnExtractBigBytes(&stream->dh_cc.pv, dh2->pv, 0, dh_length); - - _zrtp_packet_fill_msg_hdr( stream, - ZRTP_DHPART2, - dh_length + ZRTP_DH_STATIC_SIZE + ZRTP_HMAC_SIZE, - &dh2->hdr ); -} - -static zrtp_status_t _zrtp_machine_start_send_and_resend_dhpart2(zrtp_stream_t *stream) -{ - zrtp_retry_task_t* task = &stream->messages.dhpart_task; - - task->_is_enabled = 1; - task->callback = _send_and_resend_dhpart2; - task->_retrys = 0; - _send_and_resend_dhpart2(stream, task); - - return zrtp_status_ok; -} - - -/*---------------------------------------------------------------------------*/ -static void _send_and_resend_confirm2(zrtp_stream_t *stream, zrtp_retry_task_t* task) -{ - if (task->_retrys >= ZRTP_T2_MAX_COUNT) { - ZRTP_LOG(1,(_ZTU_,"WARNING! CONFIRM2 Max retransmissions count reached. ID=%u\n", stream->id)); - _zrtp_machine_enter_initiatingerror(stream, zrtp_error_timeout, 0); - } else if (task->_is_enabled) { - zrtp_status_t s = zrtp_status_ok; - s = _zrtp_packet_send_message(stream, ZRTP_CONFIRM2, &stream->messages.confirm); - task->timeout = _zrtp_get_timeout((uint32_t)task->timeout, ZRTP_CONFIRM2); - if (zrtp_status_ok == s) { - task->_retrys++; - } - if (stream->zrtp->cb.sched_cb.on_call_later) { - stream->zrtp->cb.sched_cb.on_call_later(stream, task); - } - } -} - -static zrtp_status_t _zrtp_machine_start_send_and_resend_confirm2(zrtp_stream_t *stream) -{ - zrtp_retry_task_t* task = &stream->messages.confirm_task; - - zrtp_status_t s = _zrtp_machine_create_confirm(stream, &stream->messages.confirm); - if (zrtp_status_ok != s) { - return s; - } - - s = _zrtp_packet_fill_msg_hdr( stream, - ZRTP_CONFIRM2, - sizeof(zrtp_packet_Confirm_t) - sizeof(zrtp_msg_hdr_t), - &stream->messages.confirm.hdr); - - if (zrtp_status_ok == s) { - task->_is_enabled = 1; - task->callback = _send_and_resend_confirm2; - task->_retrys = 0; - _send_and_resend_confirm2(stream, task); - } - - return s; -} diff --git a/libs/libzrtp/src/zrtp_legal.c b/libs/libzrtp/src/zrtp_legal.c deleted file mode 100644 index f9b6ac6492..0000000000 --- a/libs/libzrtp/src/zrtp_legal.c +++ /dev/null @@ -1,742 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2012 Philip R. Zimmermann. All rights reserved. - * - * This software development kit (the "program", "library", or "SDK") - * is licensed under the terms of the GNU Affero General Public - * License (AGPL) as published by the Free Software Foundation, AGPL - * version 3 only, except as described below. - * - * If by private arrangement with Philip Zimmermann you've received - * this library under a different license, that license will supersede - * the terms set out in this document. - * - * You may not redistribute or use this library except according to - * the terms described in this document. Don't be confused by the - * AGPL. It is not the GPL, LGPL, Apache, MIT, BSD, Creative Commons, - * WTFPL, or any other license you might imagine. It is the AGPLv3, - * as included below. - * - * The AGPLv3 license places many complex restrictions on the usage - * and distribution of this library which might make it inconvenient - * to use in a commercial project or as part of a commercial service. - * You might be surprised by the extent of the requirements. Many - * people don't even consider the AGPL a free software license. So be - * sure to check the exact details of the license before you use this - * library for anything meaningful. For more information about the - * AGPLv3, visit: http://www.gnu.org/licenses/agpl-3.0.html - * - * To license this library under non-AGPLv3 terms, please contact: - * Philip Zimmermann (http://philzimmermann.com). - * - * As a special exception, you may combine this library with the code - * of FreeSWITCH or FreeSWITCH derivatives and modify, redistribute, - * and use the resulting source code and executable binaries - * (including modified versions of each) under the Mozilla Public - * License Version 1.1 (MPLv1.1). For more information about - * FreeSWITCH, visit: https://freeswitch.org/ - * - * As a restatement of the above, you may use, modify, and - * redistribute this library as if it were licensed under the MPLv1.1 - * if and only if it is combined with FreeSWITCH or a derivative work - * of the FreeSWITCH code. If it is not combined with anything, the - * terms of the AGPLv3 apply. If it is combined with any other - * program that is not FreeSWITCH or a derivative work of the - * FreeSWITCH code but not also combined with FreeSWITCH or a - * derivative work of the FreeSWITCH code in the same work, the terms - * of the AGPLv3 apply. - * - * I, Phil Zimmermann, would like to make the following non-binding - * request of any contributors to this library: please make your - * changes available for me to sublicense. I support myself in part - * on my ability to license software I've created to producers of - * proprietary software, and I'd like to include your contributions in - * the proprietary releases I make. You can allow me to do so either - * by placing your changes in the public domain (e.g. "I place these - * changes in the public domain") or by granting me certain rights to - * your changes (e.g. "I grant to Philip Zimmermann a non-exclusive, - * irrevocable, world-wide license to distribute, modify, use in any - * way, and sublicense under any terms my code and changes to - * libzrtp"). - * - * This file must be packaged together with the rest of the libZRTP - * SDK source code. That's why it's in a .c file. - * - * This software might be subject to export controls by the US - * Commerce Department's Bureau of Industry and Security. This - * software is provided "as is," with no warranty expressed or - * implied. - * - */ - -/* Force inclusion of this copyright string in the linked binary, - * accessible to the unix strings command. */ -#include "zrtp_legal.h" -volatile const char zrtpCopyright[] = - "\0libZRTP Copyright (c) 2006-2009 Philip R. Zimmermann."; - -/**************************************************************************** - - GNU AFFERO GENERAL PUBLIC LICENSE - Version 3, 19 November 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU Affero General Public License is a free, copyleft license for -software and other kinds of works, specifically designed to ensure -cooperation with the community in the case of network server software. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -our General Public Licenses are intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - Developers that use our General Public Licenses protect your rights -with two steps: (1) assert copyright on the software, and (2) offer -you this License which gives you legal permission to copy, distribute -and/or modify the software. - - A secondary benefit of defending all users' freedom is that -improvements made in alternate versions of the program, if they -receive widespread use, become available for other developers to -incorporate. Many developers of free software are heartened and -encouraged by the resulting cooperation. However, in the case of -software used on network servers, this result may fail to come about. -The GNU General Public License permits making a modified version and -letting the public access it on a server without ever releasing its -source code to the public. - - The GNU Affero General Public License is designed specifically to -ensure that, in such cases, the modified source code becomes available -to the community. It requires the operator of a network server to -provide the source code of the modified version running there to the -users of that server. Therefore, public use of a modified version, on -a publicly accessible server, gives the public access to the source -code of the modified version. - - An older license, called the Affero General Public License and -published by Affero, was designed to accomplish similar goals. This is -a different license, not a version of the Affero GPL, but Affero has -released a new version of the Affero GPL which permits relicensing under -this license. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU Affero General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Remote Network Interaction; Use with the GNU General Public License. - - Notwithstanding any other provision of this License, if you modify the -Program, your modified version must prominently offer all users -interacting with it remotely through a computer network (if your version -supports such interaction) an opportunity to receive the Corresponding -Source of your version by providing access to the Corresponding Source -from a network server at no charge, through some standard or customary -means of facilitating copying of software. This Corresponding Source -shall include the Corresponding Source for any work covered by version 3 -of the GNU General Public License that is incorporated pursuant to the -following paragraph. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the work with which it is combined will remain governed by version -3 of the GNU General Public License. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU Affero General Public License from time to time. Such new versions -will be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU Affero General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU Affero General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU Affero General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If your software can interact with users remotely through a computer -network, you should also make sure that it provides a way for users to -get its source. For example, if your program is a web application, its -interface could display a "Source" link that leads users to an archive -of the code. There are many ways you could offer source, and different -solutions will be better for different programs; see section 13 for the -specific requirements. - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU AGPL, see -. - -****************************************************************************/ diff --git a/libs/libzrtp/src/zrtp_list.c b/libs/libzrtp/src/zrtp_list.c deleted file mode 100644 index 5cea2fcfdd..0000000000 --- a/libs/libzrtp/src/zrtp_list.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - -#include "zrtp.h" - -/*----------------------------------------------------------------------------*/ -void init_mlist(mlist_t* head) { - head->next = head; - head->prev = head; -} - -/*----------------------------------------------------------------------------*/ -static void mlist_insert_node(mlist_t* node, mlist_t* prev, mlist_t* next) { - next->prev = node; - node->next = next; - node->prev = prev; - prev->next = node; -} - -void mlist_insert(mlist_t *prev, mlist_t *node) { - mlist_insert_node(node, prev->prev, prev); -} - -void mlist_add(mlist_t* head, mlist_t* node) { - mlist_insert_node(node, head, head->next); -} - -void mlist_add_tail(mlist_t *head, mlist_t *node) { - mlist_insert_node(node, head->prev, head); -} - -/*----------------------------------------------------------------------------*/ -static void mlist_remove(mlist_t* prev, mlist_t* next) { - next->prev = prev; - prev->next = next; -} - -void mlist_del(mlist_t *node) { - mlist_remove(node->prev, node->next); - node->next = node->prev = 0; -} - -void mlist_del_tail(mlist_t *node) { - mlist_remove(node->prev, node->next); - node->next = node->prev = 0; -} - -/*----------------------------------------------------------------------------*/ -mlist_t* mlist_get(mlist_t *head) { - return (head->next != head) ? head->next : 0; -} - -mlist_t* mlist_get_tail(mlist_t *head) { - return (head->prev != head) ? head->prev : 0; -} - -/*----------------------------------------------------------------------------*/ -int mlist_isempty(mlist_t *head) { - return (head->next == head); -} diff --git a/libs/libzrtp/src/zrtp_log.c b/libs/libzrtp/src/zrtp_log.c deleted file mode 100644 index b2576e5cf7..0000000000 --- a/libs/libzrtp/src/zrtp_log.c +++ /dev/null @@ -1,496 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - -#include "zrtp.h" - -#if (ZRTP_PLATFORM == ZP_WIN32_KERNEL) -#include -#include -#endif - -#if ZRTP_LOG_MAX_LEVEL >= 1 - -/*----------------------------------------------------------------------------*/ -#if defined ZRTP_HAVE_STDIO_H -# include -#endif -#if defined ZRTP_HAVE_STRING_H -# include -#endif -#if defined ZRTP_HAVE_STDARG_H -# include -#endif - -static const char* k_unknown = "UNKNOWN"; - -#if ZRTP_PLATFORM != ZP_WIN32_KERNEL -void zrtp_def_log_write(int level, char *buffer, int len, int offset) { - printf("%s", buffer); -} - -static zrtp_log_engine *log_writer = &zrtp_def_log_write; -#else -static zrtp_log_engine *log_writer = NULL; -#endif - -static uint32_t log_max_level = ZRTP_LOG_MAX_LEVEL; - - -/*----------------------------------------------------------------------------*/ -void zrtp_log_set_level(uint32_t level) { - log_max_level = level; -} - -void zrtp_log_set_log_engine(zrtp_log_engine *engine) { - log_writer = engine; -} - -/*----------------------------------------------------------------------------*/ -static void zrtp_log(uint8_t is_clean, const char *sender, uint32_t level, const char *format, va_list marker) -{ -#if (defined(ZRTP_USE_STACK_MINIM) && (ZRTP_USE_STACK_MINIM == 1)) - char *log_buffer = zrtp_sys_alloc(ZRTP_LOG_BUFFER_SIZE); -#else - char log_buffer[ZRTP_LOG_BUFFER_SIZE]; -#endif - char* sline = log_buffer; - uint32_t offset = 0; - int len = 0; - - if (!sline) { - return; - } - - if (!is_clean) { - /* Print sender with left aligment */ - uint32_t sender_len = strlen(sender); - *sline++ = ' '; - *sline++ = '['; - if (sender_len <= ZRTP_LOG_SENDER_MAX_LEN) { - while (sender_len < ZRTP_LOG_SENDER_MAX_LEN) { - *sline++ = ' ', ++sender_len; - } - while (*sender) { - *sline++ = *sender++; - } - } else { - int i = 0; - for (i=0; i= 1400) && (ZRTP_PLATFORM != ZP_WINCE) - len = _vsnprintf_s(sline, ZRTP_LOG_BUFFER_SIZE-offset-1, ZRTP_LOG_BUFFER_SIZE-offset-1, format, marker); -# else - len = _vsnprintf(sline, ZRTP_LOG_BUFFER_SIZE-offset, format, marker); -# endif -#elif (ZRTP_PLATFORM == ZP_WIN32_KERNEL) - RtlStringCchVPrintfA(sline, ZRTP_LOG_BUFFER_SIZE-offset, format, marker); -#elif (ZRTP_PLATFORM == ZP_LINUX) || (ZRTP_PLATFORM == ZP_DARWIN) || (ZRTP_PLATFORM == ZP_BSD) || (ZRTP_PLATFORM == ZP_ANDROID) - len = vsnprintf(sline, ZRTP_LOG_BUFFER_SIZE-offset, format, marker); -#elif (ZRTP_PLATFORM == ZP_SYMBIAN) - len = vsprintf(sline, format, marker); -#endif - - if ((len > 0) && log_writer) { - (*log_writer)(level, log_buffer, len+offset, offset); - } - -#if (defined(ZRTP_USE_STACK_MINIM) && (ZRTP_USE_STACK_MINIM == 1)) - zrtp_sys_free(log_buffer); -#endif -} - - -#if ZRTP_LOG_MAX_LEVEL >= 1 -void zrtp_log_1(const char *obj, const char *format, ...) -{ - va_list arg; - va_start(arg, format); - zrtp_log(0, obj, 1, format, arg); - va_end(arg); -} -void zrtp_logc_1(const char *format, ...) -{ - va_list arg; - va_start(arg, format); - zrtp_log(1, NULL, 1, format, arg); - va_end(arg); -} - -#endif - -#if ZRTP_LOG_MAX_LEVEL >= 2 -void zrtp_log_2(const char *obj, const char *format, ...) -{ - va_list arg; - va_start(arg, format); - zrtp_log(0, obj, 2, format, arg); - va_end(arg); -} -void zrtp_logc_2(const char *format, ...) -{ - va_list arg; - va_start(arg, format); - zrtp_log(1, NULL, 2, format, arg); - va_end(arg); -} - -#endif - -#if ZRTP_LOG_MAX_LEVEL >= 3 -void zrtp_log_3(const char *obj, const char *format, ...) -{ - va_list arg; - va_start(arg, format); - zrtp_log(0, obj, 3, format, arg); - va_end(arg); -} -void zrtp_logc_3(const char *format, ...) -{ - va_list arg; - va_start(arg, format); - zrtp_log(1, NULL, 3, format, arg); - va_end(arg); -} - -#endif - -#endif - -/*---------------------------------------------------------------------------*/ -struct _error_strings_t -{ - zrtp_protocol_error_t code; - char* descr; -}; - -static const struct _error_strings_t _error_strings[] = { - {zrtp_error_unknown, "Unknown"}, - {zrtp_error_timeout, "Protocol Packets Retries Timeout"}, - {zrtp_error_invalid_packet, "Malformed packet (CRC OK, but wrong structure)"}, - {zrtp_error_software, "Critical software error: no memory, can't call some system function, etc"}, - {zrtp_error_version, "Unsupported ZRTP version"}, - {zrtp_error_hello_mistmatch,"Hello components mismatch "}, - - {zrtp_error_hash_unsp, "Hash type not supported"}, - {zrtp_error_cipher_unsp, "Cipher type not supported"}, - {zrtp_error_pktype_unsp, "Public key exchange not supported"}, - {zrtp_error_auth_unsp, "SRTP auth. tag not supported"}, - {zrtp_error_sas_unsp, "SAS scheme not supported"}, - {zrtp_error_no_secret, "No shared secret available, DH mode required"}, - - {zrtp_error_possible_mitm1, "Attack DH Error: bad pvi or pvr ( == 1, 0, or p-1)"}, - {zrtp_error_possible_mitm2, "Attack DH Error: hvi != hashed data"}, - {zrtp_error_possible_mitm3, "Attack Received relayed SAS from untrusted MiTM"}, - - {zrtp_error_auth_decrypt, "Auth. Error: Bad Confirm pkt HMAC"}, - {zrtp_error_nonse_reuse, "Nonce reuse"}, - {zrtp_error_equal_zid, "Equal ZIDs in Hello"}, - {zrtp_error_service_unavail,"Service unavailable"}, - {zrtp_error_goclear_unsp, "GoClear packet received, but not allowed"}, - - {zrtp_error_wrong_zid, "ZID received in new Hello doesn't equal to ZID from the previous stream"}, - {zrtp_error_wrong_meshmac, "Message HMAC doesn't match with pre-received one"} -}; - -const char* zrtp_log_error2str(zrtp_protocol_error_t error) -{ - int i=0; - for(i=0; i<22; i++) { - if (error == _error_strings[i].code) { - return _error_strings[i].descr; - } - } - - return k_unknown; -} - -/*---------------------------------------------------------------------------*/ -static char* _status_strings[zrtp_status_count] = -{ - "OK status", - "General, unspecified failure", - "Wrong, unsupported parameter", - "Fail allocate memory", - "SRTP authentication failure", - "Cipher failure on RTP encrypt/decrypt", - "General Crypto Algorithm failure", - "SRTP can't use key any longer", - "Input buffer too small", - "Packet process DROP status", - "Failed to open file/device", - "Unable to read data from the file/stream", - "Unable to write to the file/stream", - "SRTP packet is out of sliding window", - "RTP replay protection failed", - "ZRTP replay protection failed", - "ZRTP packet CRC is wrong", - "Can't generate random value", - "Illegal operation in current state", - "Attack detected", - "Function is not available in current configuration" -}; - -const char* zrtp_log_status2str(zrtp_status_t error) -{ - if (zrtp_status_count > error) { - return _status_strings[error]; - } else { - return k_unknown; - } -} - -/*---------------------------------------------------------------------------*/ -static char* _state_names[ZRTP_STATE_COUNT] = -{ - "NONE", - "ACTIVE", - "START", - "W4HACK", - "W4HELLO", - "CLEAR", - "SINITSEC", - "INITSEC", - "WCONFIRM", - "W4CONFACK", - "PENDSEC", - "W4CONF2", - "SECURE", - "SASRELAY", - "INITCLEAR", - "PENDCLEAR", - "INITERROR", - "PENDERROR", - "ERROR", - #if (defined(ZRTP_BUILD_FOR_CSD) && (ZRTP_BUILD_FOR_CSD == 1)) - "DRIVINIT", - "DRIVRESP", - "DRIVPEND", - #endif - "NOZRTP" -}; - -const char* zrtp_log_state2str(zrtp_state_t state) -{ - if (state < ZRTP_STATE_COUNT) { - return _state_names[state]; - } else { - return k_unknown; - } -}; - -/*---------------------------------------------------------------------------*/ -static char* _stream_mode_name[ZRTP_STREAM_MODE_COUNT] = -{ - "UNKNOWN", - "CLEAR", - "DH", - "PRESHARED", - "MULTI" -}; - -const char* zrtp_log_mode2str(zrtp_stream_mode_t mode) -{ - if (mode < ZRTP_STREAM_MODE_COUNT) { - return _stream_mode_name[mode]; - } else { - return k_unknown; - } -}; - -/*---------------------------------------------------------------------------*/ -static char* _msg_type_names[ZRTP_MSG_TYPE_COUNT] = -{ - "NONE", - "HELLO", - "HELLOACK", - "COMMIT", - "DH1", - "DH2", - "CONFIRM1", - "CONFIRM2", - "CONFIRMACK", - "GOCLEAR", - "CLEARACKE", - "ERROR", - "ERRORACK", - "PROCESS", - "SASRELAY", - "RELAYACK", - "PING", - "PINGACK", -}; - -const char* zrtp_log_pkt2str(zrtp_msg_type_t type) -{ - if (type < ZRTP_MSG_TYPE_COUNT) { - return _msg_type_names[type]; - } else { - return k_unknown; - } -} - -/*---------------------------------------------------------------------------*/ -static char* _event_code_name[] = -{ - "ZRTP_EVENT_UNSUPPORTED", - "ZRTP_EVENT_IS_CLEAR", - "ZRTP_EVENT_IS_INITIATINGSECURE", - "ZRTP_EVENT_IS_PENDINGSECURE", - "ZRTP_EVENT_IS_PENDINGCLEAR", - "ZRTP_EVENT_NO_ZRTP", - "ZRTP_EVENT_NO_ZRTP_QUICK", - "ZRTP_EVENT_IS_CLIENT_ENROLLMENT", - "ZRTP_EVENT_NEW_USER_ENROLLED", - "ZRTP_EVENT_USER_ALREADY_ENROLLED", - "ZRTP_EVENT_USER_UNENROLLED", - "ZRTP_EVENT_LOCAL_SAS_UPDATED", - "ZRTP_EVENT_REMOTE_SAS_UPDATED", - "ZRTP_EVENT_IS_SECURE", - "ZRTP_EVENT_IS_SECURE_DONE", - "ZRTP_EVENT_IS_PASSIVE_RESTRICTION", - "ZRTP_EVENT_PROTOCOL_ERROR", - "ZRTP_EVENT_WRONG_SIGNALING_HASH", - "ZRTP_EVENT_WRONG_MESSAGE_HMAC", - "ZRTP_EVENT_MITM_WARNING" -}; - -const char* zrtp_log_event2str(uint8_t event) -{ - if (event <= ZRTP_EVENT_WRONG_MESSAGE_HMAC) { - return _event_code_name[event]; - } else { - return k_unknown; - } -} - -static char* _sign_role_name[] = -{ - "Unknown", - "Initiator", - "Responder" -}; - -const char* zrtp_log_sign_role2str(unsigned role) { - if (role < ZRTP_SIGNALING_ROLE_COUNT) { - return _sign_role_name[role]; - } else { - return k_unknown; - } -} - -/*---------------------------------------------------------------------------*/ -typedef struct _zrtp_aling_test -{ - uint_8t c1; - uint_8t c2; - uint_8t c3; -} _zrtp_aling_test; - -void zrtp_print_env_settings(zrtp_config_t* config) -{ -#if (ZRTP_PLATFORM == ZP_WIN32) - char* platform = "Windows 32bit"; -#elif (ZRTP_PLATFORM == ZP_WIN32_KERNEL) - char* platform = "Windows Kernel 32bit"; -#elif (ZRTP_PLATFORM == ZP_WINCE) - char* platform = "Windows CE"; -#elif (ZRTP_PLATFORM == ZP_DARWIN) - char* platform = "Darwin OS X"; -#elif (ZRTP_PLATFORM == ZP_BSD) - char* platform = "BSD"; -#elif (ZRTP_PLATFORM == ZP_LINUX) - char* platform = "Linux OS"; -#elif (ZRTP_PLATFORM == ZP_SYMBIAN) - char* platform = "Symbian OS"; -#elif (ZRTP_PLATFORM == ZP_ANDROID) - char* platform = "Android OS"; -#endif - - ZRTP_LOG(3,("zrtp","============================================================\n")); - ZRTP_LOG(3,("zrtp","ZRTP Configuration Settings\n")); - ZRTP_LOG(3,("zrtp","============================================================\n")); - ZRTP_LOG(3,("zrtp"," PLATFORM: %s\n", platform)); -#if (ZRTP_BYTE_ORDER == ZBO_BIG_ENDIAN) - ZRTP_LOG(3,("zrtp"," BYTE ORDER: BIG ENDIAN\n")); -#else - ZRTP_LOG(3,("zrtp"," BYTE ORDER: LITTLE ENDIAN\n")); -#endif - ZRTP_LOG(3,("zrtp"," ZRTP_SAS_DIGEST_LENGTH: %d\n", ZRTP_SAS_DIGEST_LENGTH)); - ZRTP_LOG(3,("zrtp"," ZRTP_MAX_STREAMS_PER_SESSION: %d\n", ZRTP_MAX_STREAMS_PER_SESSION)); - ZRTP_LOG(3,("zrtp"," ZRTP_USE_EXTERN_SRTP: %d\n", ZRTP_USE_EXTERN_SRTP)); - ZRTP_LOG(3,("zrtp"," ZRTP_USE_STACK_MINIM: %d\n", ZRTP_USE_STACK_MINIM)); - ZRTP_LOG(3,("zrtp"," ZRTP_BUILD_FOR_CSD: %d\n", ZRTP_BUILD_FOR_CSD)); - ZRTP_LOG(3,("zrtp"," ZRTP_USE_BUILTIN: %d\n", ZRTP_USE_BUILTIN)); - ZRTP_LOG(3,("zrtp"," ZRTP_USE_BUILTIN_SCEHDULER: %d\n", ZRTP_USE_BUILTIN_SCEHDULER)); - ZRTP_LOG(3,("zrtp"," ZRTP_USE_BUILTIN_CACHE: %d\n", ZRTP_USE_BUILTIN_CACHE)); - ZRTP_LOG(3,("zrtp"," ZRTP_LOG_MAX_LEVEL: %d\n", ZRTP_LOG_MAX_LEVEL)); - - ZRTP_LOG(3,("zrtp"," sizeo of unsigned int: %d\n", sizeof(unsigned int))); - ZRTP_LOG(3,("zrtp"," size of unsigned long long: %d\n", sizeof(unsigned long long))); - ZRTP_LOG(3,("zrtp"," sizeo of three chars: %d\n", sizeof(_zrtp_aling_test))); - ZRTP_LOG(3,("zrtp","\n")); - ZRTP_LOG(3,("zrtp","ZRTP Initialization Settings\n")); - ZRTP_LOG(3,("zrtp"," client ID: %s\n", config->client_id)); - ZRTP_LOG(3,("zrtp"," license: %d\n", config->lic_mode)); - ZRTP_LOG(3,("zrtp"," MiTM: %s\n", config->is_mitm?"ENABLED":"DIABLED")); - ZRTP_LOG(3,("zrtp"," cache path: %s\n", config->def_cache_path.length?config->def_cache_path.buffer:"")); -} - -/*---------------------------------------------------------------------------*/ -void zrtp_log_print_streaminfo(zrtp_stream_info_t* info) -{ - ZRTP_LOG(3,("zrtp"," ZRTP Stream ID=%u\n", info->id)); - ZRTP_LOG(3,("zrtp"," mode: %s\n", zrtp_log_mode2str(info->mode))); - ZRTP_LOG(3,("zrtp"," state: %s\n", zrtp_log_state2str(info->state))); - ZRTP_LOG(3,("zrtp"," error: %s\n", zrtp_log_error2str(info->last_error))); - - ZRTP_LOG(3,("zrtp"," peer passive: %s\n", info->peer_passive?"ON":"OFF")); - ZRTP_LOG(3,("zrtp"," peer disclose: %s\n", info->peer_disclose?"ON":"OFF")); - ZRTP_LOG(3,("zrtp"," peer mitm: %s\n", info->peer_mitm?"ON":"OFF")); - ZRTP_LOG(3,("zrtp"," res allowclear: %s\n", info->res_allowclear?"ON":"OFF")); -} - -void zrtp_log_print_sessioninfo(zrtp_session_info_t* info) -{ - char buffer[256]; - - ZRTP_LOG(3,("zrtp"," ZRTP Session sID=%u is ready=%s\n", info->id, info->sas_is_ready?"YES":"NO")); - ZRTP_LOG(3,("zrtp"," peer client: <%s> V=<%s>\n", info->peer_clientid.buffer, info->peer_version.buffer)); - hex2str(info->zid.buffer, info->zid.length, buffer, sizeof(buffer)); - ZRTP_LOG(3,("zrtp"," zid: %s\n", buffer)); - hex2str(info->peer_zid.buffer, info->peer_zid.length, buffer, sizeof(buffer)); - ZRTP_LOG(3,("zrtp"," peer zid: %s\n", buffer)); - hex2str(info->zid.buffer, info->zid.length, buffer, sizeof(buffer)); - - ZRTP_LOG(3,("zrtp"," is base256: %s\n", info->sas_is_base256?"YES":"NO")); - ZRTP_LOG(3,("zrtp"," SAS1: %s\n", info->sas1.buffer)); - ZRTP_LOG(3,("zrtp"," SAS2: %s\n", info->sas2.buffer)); - hex2str(info->sasbin.buffer, info->sasbin.length, buffer, sizeof(buffer)); - ZRTP_LOG(3,("zrtp"," bin SAS: %s\n", buffer)); - ZRTP_LOG(3,("zrtp"," TTL: %u\n", info->secrets_ttl)); - - ZRTP_LOG(3,("zrtp"," hash: %s\n", info->hash_name.buffer)); - ZRTP_LOG(3,("zrtp"," cipher: %s\n", info->cipher_name.buffer)); - ZRTP_LOG(3,("zrtp"," auth: %s\n", info->auth_name.buffer)); - ZRTP_LOG(3,("zrtp"," sas: %s\n", info->sas_name.buffer)); - ZRTP_LOG(3,("zrtp"," pks: %s\n", info->pk_name.buffer)); -} diff --git a/libs/libzrtp/src/zrtp_pbx.c b/libs/libzrtp/src/zrtp_pbx.c deleted file mode 100644 index dbc2aa7cbb..0000000000 --- a/libs/libzrtp/src/zrtp_pbx.c +++ /dev/null @@ -1,691 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - -#include "zrtp.h" - -#define _ZTU_ "zrtp mitm" - -extern zrtp_status_t _zrtp_machine_process_goclear(zrtp_stream_t* stream, zrtp_rtp_info_t* packet); - - -/*===========================================================================*/ -/* State-Machine related functions */ -/*===========================================================================*/ - -/*---------------------------------------------------------------------------*/ -static void _send_and_resend_sasrelay(zrtp_stream_t *stream, zrtp_retry_task_t* task) -{ - if (task->_retrys >= ZRTP_T2_MAX_COUNT) { - ZRTP_LOG(1,(_ZTU_,"WARNING! SASRELAY Max retransmissions count reached. ID=%u\n", stream->id)); - _zrtp_machine_enter_initiatingerror(stream, zrtp_error_timeout, 0); - } else if (task->_is_enabled) { - - zrtp_status_t s = _zrtp_packet_send_message(stream, ZRTP_SASRELAY, &stream->messages.sasrelay); - task->timeout = _zrtp_get_timeout((uint32_t)task->timeout, ZRTP_SASRELAY); - if (zrtp_status_ok == s) { - task->_retrys++; - } - if (stream->zrtp->cb.sched_cb.on_call_later) { - stream->zrtp->cb.sched_cb.on_call_later(stream, task); - } - } -} - -/*----------------------------------------------------------------------------*/ -static zrtp_status_t _create_sasrelay( zrtp_stream_t *stream, - zrtp_sas_id_t transf_sas_scheme, - zrtp_string32_t* transf_sas_value, - uint8_t transf_ac_flag, - uint8_t transf_d_flag, - zrtp_packet_SASRelay_t* sasrelay ) -{ - zrtp_session_t *session = stream->session; - zrtp_status_t s = zrtp_status_fail; - void* cipher_ctx = NULL; - - /* (padding + sig_len + flags) + SAS scheme and SASHash */ - const uint8_t encrypted_body_size = (2 + 1 + 1) + 4 + 32; - - zrtp_memset(sasrelay, 0, sizeof(zrtp_packet_SASRelay_t)); - - /* generate a random initialization vector for CFB cipher */ - if (ZRTP_CFBIV_SIZE != zrtp_randstr(session->zrtp, sasrelay->iv, ZRTP_CFBIV_SIZE)) { - return zrtp_status_rp_fail; - } - - sasrelay->flags |= (session->profile.disclose_bit || transf_d_flag) ? 0x01 : 0x00; - sasrelay->flags |= (session->profile.allowclear && transf_ac_flag) ? 0x02 : 0x00; - sasrelay->flags |= 0x04; - - zrtp_memcpy( sasrelay->sas_scheme, - zrtp_comp_id2type(ZRTP_CC_SAS, transf_sas_scheme), - ZRTP_COMP_TYPE_SIZE ); - if (transf_sas_value) - zrtp_memcpy(sasrelay->sashash, transf_sas_value->buffer, transf_sas_value->length); - - /* Then we need to encrypt Confirm before computing Hmac. Use AES CFB */ - do { - cipher_ctx = session->blockcipher->start( session->blockcipher, - (uint8_t*)stream->cc.zrtp_key.buffer, - NULL, - ZRTP_CIPHER_MODE_CFB ); - if (!cipher_ctx) { - break; - } - - s = session->blockcipher->set_iv( session->blockcipher, - cipher_ctx, - (zrtp_v128_t*)sasrelay->iv); - if (zrtp_status_ok != s) { - break; - } - - s = session->blockcipher->encrypt( session->blockcipher, - cipher_ctx, - (uint8_t*)sasrelay->pad, - encrypted_body_size ); - } while(0); - if (cipher_ctx) { - session->blockcipher->stop(session->blockcipher, cipher_ctx); - } - - - - if (zrtp_status_ok != s) { - ZRTP_LOG(1,(_ZTU_,"\tERROR! Failed to encrypt SASRELAY Message status=%d. ID=%u\n", s, stream->id)); - return s; - } - - /* Compute Hmac over encrypted part of Confirm */ - { - zrtp_string128_t hmac = ZSTR_INIT_EMPTY(hmac); - s = session->hash->hmac_c( session->hash, - stream->cc.hmackey.buffer, - stream->cc.hmackey.length, - (const char*)&sasrelay->pad, - encrypted_body_size, - ZSTR_GV(hmac) ); - if (zrtp_status_ok != s) { - ZRTP_LOG(1,(_ZTU_,"\tERROR! Failed to compute CONFIRM hmac status=%d. ID=%u\n", s, stream->id)); - return s; - } - zrtp_memcpy(sasrelay->hmac, hmac.buffer, ZRTP_HMAC_SIZE); - } - - return s; -} - -/*----------------------------------------------------------------------------*/ -zrtp_status_t _zrtp_machine_process_sasrelay(zrtp_stream_t *stream, zrtp_rtp_info_t *packet) -{ - zrtp_session_t *session = stream->session; - zrtp_packet_SASRelay_t *sasrelay = (zrtp_packet_SASRelay_t*) packet->message; - void* cipher_ctx = NULL; - zrtp_sas_id_t rendering_id = ZRTP_COMP_UNKN; - zrtp_status_t s = zrtp_status_fail; - zrtp_string128_t hmac = ZSTR_INIT_EMPTY(hmac); - char zerosashash[32]; - unsigned sas_scheme_did_change = 0; - unsigned sas_hash_did_change = 0; - - /* (padding + sig_len + flags) + SAS scheme and SAS hash */ - const uint8_t encrypted_body_size = (2 + 1 + 1) + 4 + 32; - - zrtp_memset(zerosashash, 0, sizeof(zerosashash)); - - /* Check if the remote endpoint is assigned to relay the SAS values */ - if (!stream->peer_mitm_flag) { - ZRTP_LOG(2,(_ZTU_, ZRTP_RELAYED_SAS_FROM_NONMITM_STR)); - return zrtp_status_fail; - } - - /* Check the HMAC */ - s = session->hash->hmac_c( session->hash, - stream->cc.peer_hmackey.buffer, - stream->cc.peer_hmackey.length, - (const char*)&sasrelay->pad, - encrypted_body_size, - ZSTR_GV(hmac) ); - if (zrtp_status_ok != s ) { - ZRTP_LOG(1,(_ZTU_,"\tERROR! Failed to compute CONFIRM hmac. status=%d ID=%u\n", s, stream->id)); - return zrtp_status_fail; - } - - if (0 != zrtp_memcmp(sasrelay->hmac, hmac.buffer, ZRTP_HMAC_SIZE)) { - ZRTP_LOG(2,(_ZTU_, ZRTP_VERIFIED_RESP_WARNING_STR)); - return zrtp_status_fail; - } - - ZRTP_LOG(3,(_ZTU_, "\tHMAC value for the SASRELAY is correct - decrypting...\n")); - - /* Then we need to decrypt Confirm body */ - do - { - cipher_ctx = session->blockcipher->start( session->blockcipher, - (uint8_t*)stream->cc.peer_zrtp_key.buffer, - NULL, - ZRTP_CIPHER_MODE_CFB ); - if (!cipher_ctx) { - break; - } - - s = session->blockcipher->set_iv(session->blockcipher, cipher_ctx, (zrtp_v128_t*)sasrelay->iv); - if (zrtp_status_ok != s) { - break; - } - - s = session->blockcipher->decrypt( session->blockcipher, - cipher_ctx, - (uint8_t*)sasrelay->pad, - encrypted_body_size); - } while(0); - if (cipher_ctx) { - session->blockcipher->stop(session->blockcipher, cipher_ctx); - } - - if (zrtp_status_ok != s) { - ZRTP_LOG(1,(_ZTU_,"\tERROR! Failed to decrypt Confirm. status=%d ID=%u\n", s, stream->id)); - return s; - } - - ZRTP_LOG(2,(_ZTU_,"\tSasRelay FLAGS old/new A=%d/%d, D=%d/%d.\n", - stream->allowclear, (uint8_t)(sasrelay->flags & 0x02), - stream->peer_disclose_bit, (uint8_t)(sasrelay->flags & 0x01))); - - /* Set evil bit if other-side disclosed session key */ - stream->peer_disclose_bit = (sasrelay->flags & 0x01); - - /* Enable ALLOWCLEAR option only if both sides support it */ - stream->allowclear = (sasrelay->flags & 0x02) && session->profile.allowclear; - - /* - * We don't handle verified flag in SASRelaying because it makes no - * sense in implementation of the ZRTP Internet Draft. - */ - - /* - * Only enrolled users can do SAS transferring. (Non-enrolled users can - * only change the SAS rendering scheme). - */ - - rendering_id = zrtp_comp_type2id(ZRTP_CC_SAS, (char*)sasrelay->sas_scheme); - if (-1 == zrtp_profile_find(&session->profile, ZRTP_CC_SAS, rendering_id)) { - ZRTP_LOG(1,(_ZTU_,"\tERROR! PBX Confirm packet with transferred SAS have unknown or" - " unsupported rendering scheme %.4s.ID=%u\n", sasrelay->sas_scheme, stream->id)); - - _zrtp_machine_enter_initiatingerror(stream, zrtp_error_invalid_packet, 1); - return zrtp_status_fail; - } - - /* Check is SAS rendering did change */ - if (rendering_id != session->sasscheme->base.id) { - session->sasscheme = zrtp_comp_find(ZRTP_CC_SAS, rendering_id, session->zrtp ); - - sas_scheme_did_change = 1; - ZRTP_LOG(3,(_ZTU_,"\tSasrelay: Rendering scheme was updated to %.4s.\n", session->sasscheme->base.type)); - } - - if (session->secrets.matches & ZRTP_BIT_PBX) { - if ( (((uint32_t) *sasrelay->sas_scheme) != (uint32_t)0x0L) && - (0 != zrtp_memcmp(sasrelay->sashash, zerosashash, sizeof(sasrelay->sashash))) ) - { - char buff[256]; - session->sasbin.length = ZRTP_MITM_SAS_SIZE; - /* First 32 bits if sashash includes sasvalue */ - zrtp_memcpy(session->sasbin.buffer, sasrelay->sashash, session->sasbin.length); - stream->mitm_mode = ZRTP_MITM_MODE_RECONFIRM_CLIENT; - - sas_hash_did_change = 1; - ZRTP_LOG(3,(_ZTU_,"\tSasRelay: SAS value was updated to bin=%s.\n", - hex2str(session->sasbin.buffer, session->sasbin.length, buff, sizeof(buff)))); - } - } else if (0 != zrtp_memcmp(sasrelay->sashash, zerosashash, sizeof(sasrelay->sashash))) { - ZRTP_LOG(1,(_ZTU_,"\tWARNING! SAS Value was received from NOT Trusted MiTM. ID=%u\n", stream->id)); - _zrtp_machine_enter_initiatingerror(stream, zrtp_error_possible_mitm3, 1); - return zrtp_status_fail; - } else { - ZRTP_LOG(1,(_ZTU_, "\rERROR! For SasRelay Other secret doesn't match. ID=%u\n", stream->id)); - } - - - /* Generate new SAS if hash or rendering scheme did change. - * Note: latest libzrtp may send "empty" SasRelay with the same SAS rendering - * scheme and empty Hello hash for consistency reasons, we should ignore - * such packets. - */ - if (sas_scheme_did_change || sas_hash_did_change) { - s = session->sasscheme->compute(session->sasscheme, stream, session->hash, 1); - if (zrtp_status_ok != s) { - _zrtp_machine_enter_initiatingerror(stream, zrtp_error_software, 1); - return s; - } - - ZRTP_LOG(3,(_ZTU_,"\tSasRelay: Updated SAS is <%s> <%s>.\n", session->sas1.buffer, session->sas2.buffer)); - - if (session->zrtp->cb.event_cb.on_zrtp_protocol_event) { - session->zrtp->cb.event_cb.on_zrtp_protocol_event(stream, ZRTP_EVENT_LOCAL_SAS_UPDATED); - } - } - - return zrtp_status_ok; -} - -/*---------------------------------------------------------------------------*/ -zrtp_status_t _zrtp_machine_process_while_in_sasrelaying( zrtp_stream_t* stream, - zrtp_rtp_info_t* packet) -{ - zrtp_status_t s = zrtp_status_ok; - - switch (packet->type) - { - case ZRTP_RELAYACK: - _zrtp_cancel_send_packet_later(stream, ZRTP_SASRELAY); - _zrtp_change_state(stream, ZRTP_STATE_SECURE); - if (stream->zrtp->cb.event_cb.on_zrtp_protocol_event) { - stream->zrtp->cb.event_cb.on_zrtp_protocol_event(stream, ZRTP_EVENT_REMOTE_SAS_UPDATED); - } - break; - - case ZRTP_GOCLEAR: - s = _zrtp_machine_process_goclear(stream, packet); - if (zrtp_status_ok == s) { - s = _zrtp_machine_enter_pendingclear(stream); - } - break; - - case ZRTP_NONE: - s = _zrtp_protocol_decrypt(stream->protocol, packet, 1); - break; - - default: - break; - } - - return s; -} - - -/*===========================================================================*/ -/* ZRTP API for PBX */ -/*===========================================================================*/ - -/*---------------------------------------------------------------------------*/ -zrtp_status_t zrtp_stream_registration_start(zrtp_stream_t* stream, uint32_t ssrc) -{ - if (!stream) { - return zrtp_status_bad_param; - } - - ZRTP_LOG(3,(_ZTU_,"START REGISTRATION STREAM ID=%u mode=%s state=%s.\n", - stream->id, zrtp_log_mode2str(stream->mode), zrtp_log_state2str(stream->state))); - - if (NULL == stream->zrtp->cb.cache_cb.on_get_mitm) { - ZRTP_LOG(2,(_ZTU_,"WARNING: Can't use MiTM Functions with no ZRTP Cache.\n")); - return zrtp_status_notavailable; - } - - stream->mitm_mode = ZRTP_MITM_MODE_REG_SERVER; - return zrtp_stream_start(stream, ssrc); -} - -zrtp_status_t zrtp_stream_registration_secure(zrtp_stream_t* stream) -{ - if (!stream) { - return zrtp_status_bad_param; - } - - ZRTP_LOG(3,(_ZTU_,"SECURE REGISTRATION STREAM ID=%u mode=%s state=%s.\n", - stream->id, zrtp_log_mode2str(stream->mode), zrtp_log_state2str(stream->state))); - - if (NULL == stream->zrtp->cb.cache_cb.on_get_mitm) { - ZRTP_LOG(2,(_ZTU_,"WARNING: Can't use MiTM Functions with no ZRTP Cache.\n")); - return zrtp_status_notavailable; - } - - stream->mitm_mode = ZRTP_MITM_MODE_REG_SERVER; - return zrtp_stream_secure(stream); -} - -/*---------------------------------------------------------------------------*/ -zrtp_status_t zrtp_register_with_trusted_mitm(zrtp_stream_t* stream) -{ - zrtp_session_t *session = stream->session; - zrtp_status_t s = zrtp_status_bad_param; - - if (!stream) { - return zrtp_status_bad_param; - } - - ZRTP_LOG(3,(_ZTU_,"MARKING this call as REGISTRATION ID=%u\n", stream->id)); - - if (NULL == stream->zrtp->cb.cache_cb.on_get_mitm) { - ZRTP_LOG(2,(_ZTU_,"WARNING: Can't use MiTM Functions with no ZRTP Cache.\n")); - return zrtp_status_notavailable; - } - - if (!stream->protocol) { - return zrtp_status_bad_param; - } - - /* Passive Client endpoint should NOT generate PBX Secret. */ - if ((stream->mitm_mode == ZRTP_MITM_MODE_REG_CLIENT) && - (ZRTP_LICENSE_MODE_PASSIVE == stream->zrtp->lic_mode)) { - ZRTP_LOG(2,(_ZTU_,"WARNING: Passive Client endpoint should NOT generate PBX Secret.\n")); - return zrtp_status_bad_param; - } - - /* - * Generate new MitM cache: - * pbxsecret = KDF(ZRTPSess, "Trusted MiTM key", (ZIDi | ZIDr), negotiated hash length) - */ - if ( (stream->state == ZRTP_STATE_SECURE) && - ((stream->mitm_mode == ZRTP_MITM_MODE_REG_CLIENT) || (stream->mitm_mode == ZRTP_MITM_MODE_REG_SERVER)) ) - { - zrtp_string32_t kdf_context = ZSTR_INIT_EMPTY(kdf_context); - static const zrtp_string32_t trusted_mitm_key_label = ZSTR_INIT_WITH_CONST_CSTRING(ZRTP_TRUSTMITMKEY_STR); - zrtp_string16_t *zidi, *zidr; - - if (stream->protocol->type == ZRTP_STATEMACHINE_INITIATOR) { - zidi = &session->zid; - zidr = &session->peer_zid; - } else { - zidi = &session->peer_zid; - zidr = &session->zid; - } - - zrtp_zstrcat(ZSTR_GV(kdf_context), ZSTR_GVP(zidi)); - zrtp_zstrcat(ZSTR_GV(kdf_context), ZSTR_GVP(zidr)); - - _zrtp_kdf( stream, - ZSTR_GV(session->zrtpsess), - ZSTR_GV(trusted_mitm_key_label), - ZSTR_GV(kdf_context), - ZRTP_HASH_SIZE, - ZSTR_GV(session->secrets.pbxs->value)); - - session->secrets.pbxs->_cachedflag = 1; - session->secrets.pbxs->lastused_at = (uint32_t)(zrtp_time_now()/1000); - session->secrets.cached |= ZRTP_BIT_PBX; - session->secrets.matches |= ZRTP_BIT_PBX; - - s = zrtp_status_ok; - if (session->zrtp->cb.cache_cb.on_put_mitm) { - s = session->zrtp->cb.cache_cb.on_put_mitm( ZSTR_GV(session->zid), - ZSTR_GV(session->peer_zid), - session->secrets.pbxs); - } - - ZRTP_LOG(3,(_ZTU_,"Makring this call as REGISTRATION - DONE\n")); - } - - return s; -} - -/*---------------------------------------------------------------------------*/ -zrtp_status_t zrtp_link_mitm_calls(zrtp_stream_t *stream1, zrtp_stream_t *stream2) -{ - if (!stream1 || !stream2) { - return zrtp_status_bad_param; - } - - ZRTP_LOG(3,(_ZTU_,"Link to MiTM call together stream1=%u stream2=%u.\n", stream1->id, stream2->id)); - - /* This APi is for MiTM endpoints only. */ - if (stream1->zrtp->is_mitm) { - return zrtp_status_bad_param; - } - - stream1->linked_mitm = stream2; - stream2->linked_mitm = stream1; - - { - zrtp_stream_t *passive = NULL; - zrtp_stream_t *unlimited = NULL; - - /* Check if we have at least one Unlimited endpoint. */ - if (stream1->peer_super_flag) - unlimited = stream1; - else if (stream2->peer_super_flag) - unlimited = stream2; - - /* Check if the peer stream is Passive */ - if (unlimited) { - passive = (stream1 == unlimited) ? stream2 : stream1; - if (!passive->peer_passive) - passive = NULL; - } - - /* Ok, we haver Unlimited and Passive at two ends, let's make an exception and switch Passive to Secure. */ - if (unlimited && passive) { - if (passive->state == ZRTP_STATE_CLEAR) { - ZRTP_LOG(2,(_ZTU_,"INFO: zrtp_link_mitm_calls() stream with id=%u is Unlimited and" - " Peer stream with id=%u is Passive in CLEAR state, switch the passive one to SECURE.\n")); - - /* @note: don't use zrtp_secure_stream() wrapper as it checks for Active/Passive stuff. */ - _zrtp_machine_start_initiating_secure(passive); - } - } - } - - return zrtp_status_ok; -} - -/*---------------------------------------------------------------------------*/ -zrtp_status_t zrtp_update_remote_options( zrtp_stream_t* stream, - zrtp_sas_id_t transf_sas_scheme, - zrtp_string32_t* transf_sas_value, - uint8_t transf_ac_flag, - uint8_t transf_d_flag ) -{ - zrtp_retry_task_t* task = &stream->messages.sasrelay_task; - zrtp_status_t s = zrtp_status_ok; - char buff[256]; - - if (!stream) { - return zrtp_status_bad_param; - } - - ZRTP_LOG(3,(_ZTU_,"UPDATE REMOTE SAS OPTIONS mode. ID=%u\n", stream->id)); - ZRTP_LOG(3,(_ZTU_,"transf_sas=%s scheme=%d.\n", transf_sas_value ? - hex2str((const char*)transf_sas_value->buffer, transf_sas_value->length, (char*)buff, sizeof(buff)) : "NULL", - transf_sas_scheme)); - - if (NULL == stream->zrtp->cb.cache_cb.on_get_mitm) { - ZRTP_LOG(2,(_ZTU_,"WARNING: Can't use MiTM Functions with no ZRTP Cache.\n")); - return zrtp_status_notavailable; - } - - /* The TRANSFERRING option is only available from the SECURE state. */ - if (stream->state != ZRTP_STATE_SECURE) { - return zrtp_status_bad_param; - } - - /* Don't transfer an SAS to a non-enrolled user */ - if (transf_sas_value && !(stream->session->secrets.matches & ZRTP_BIT_PBX)) { - return zrtp_status_bad_param; - } - - /* Don't allow to transfer the SAS if the library wasn't initialized as MiTM endpoint */ - if (!stream->zrtp->is_mitm) { - ZRTP_LOG(3,(_ZTU_,"\tERROR! The endpoint can't transfer SAS values to other endpoints" - " without introducing itself by M-flag in Hello. see zrtp_init().\n")); - return zrtp_status_wrong_state; - } - - s = _create_sasrelay( stream, - transf_sas_scheme, - transf_sas_value, - transf_ac_flag, - transf_d_flag, - &stream->messages.sasrelay); - if(zrtp_status_ok != s) { - return s; - } - - s = _zrtp_packet_fill_msg_hdr( stream, - ZRTP_SASRELAY, - sizeof(zrtp_packet_SASRelay_t) - sizeof(zrtp_msg_hdr_t), - &stream->messages.sasrelay.hdr); - if(zrtp_status_ok != s) { - return s; - } - - _zrtp_change_state(stream, ZRTP_STATE_SASRELAYING); - - task->_is_enabled = 1; - task->callback = _send_and_resend_sasrelay; - task->_retrys = 0; - _send_and_resend_sasrelay(stream, task); - - return s; -} - -/*---------------------------------------------------------------------------*/ -zrtp_status_t zrtp_resolve_mitm_call( zrtp_stream_t* stream1, - zrtp_stream_t* stream2) -{ - zrtp_stream_t* enrolled = NULL; - zrtp_stream_t* non_enrolled = NULL; - zrtp_sas_id_t mitm_sas_scheme = ZRTP_COMP_UNKN; - zrtp_status_t s = zrtp_status_ok; - - if (!stream1 || !stream2) { - return zrtp_status_bad_param; - } - - ZRTP_LOG(3,(_ZTU_,"RESOLVE MITM CALL s1=%u, s2=%u...\n", stream1->id, stream2->id)); - - if (NULL == stream1->zrtp->cb.cache_cb.on_get_mitm) { - ZRTP_LOG(2,(_ZTU_,"WARNING: Can't use MiTM Functions with no ZRTP Cache.\n")); - return zrtp_status_notavailable; - } - - /* - * Both sides must be in the Secure state and at least one should be - * enrolled. - */ - if ((stream1->state != ZRTP_STATE_SECURE) || (stream2->state != ZRTP_STATE_SECURE)) { - return zrtp_status_bad_param; - } - - /* Check the stream enrollment options and choose one for transferring the call. */ - if (zrtp_is_user_enrolled(stream1)) { - if (zrtp_is_user_enrolled(stream2)) { - ZRTP_LOG(3,(_ZTU_,"\tBoth streams are enrolled - choose one with bigger ZID.\n")); - enrolled = zrtp_choose_one_enrolled(stream1, stream2); - } else { - enrolled = stream1; - } - } else if (zrtp_is_user_enrolled(stream2)) { - enrolled = stream2; - } - - if (!enrolled) { - return zrtp_status_bad_param; - } - else { - non_enrolled = (stream1 == enrolled) ? stream2 : stream1; - } - - ZRTP_LOG(3,(_ZTU_,"\tAfter Resolving: S1 is %s and S2 is %s.\n", - (stream1 == enrolled) ? "ENROLLED" : "NON-ENROLLED", - (stream2 == enrolled) ? "ENROLLED" : "NON-ENROLLED")); - - /* - * Choose the best SAS rendering scheme supported by both peers. Find the - * stream that can change it. - */ - { - uint8_t i=0; - - zrtp_packet_Hello_t *enhello = &enrolled->messages.peer_hello; - char *encp = (char*)enhello->comp + (enhello->hc + - enhello->cc + - enhello->ac + - enhello->kc)* ZRTP_COMP_TYPE_SIZE; - - - for (i=0; isc; i++, encp+=ZRTP_COMP_TYPE_SIZE) - { - uint8_t j=0; - zrtp_packet_Hello_t *nonenhello = &non_enrolled->messages.peer_hello; - char *nonencp = (char*)nonenhello->comp + (nonenhello->hc + - nonenhello->cc + - nonenhello->ac + - nonenhello->kc)* ZRTP_COMP_TYPE_SIZE; - - for (j=0; jsc; j++, nonencp+=ZRTP_COMP_TYPE_SIZE) - { - if (0 == zrtp_memcmp(encp, nonencp, ZRTP_COMP_TYPE_SIZE)) { - mitm_sas_scheme = zrtp_comp_type2id(ZRTP_CC_SAS, encp); - ZRTP_LOG(3,(_ZTU_,"\tMITM SAS scheme=%.4s was choosen.\n", encp)); - break; - } - } - if (j != nonenhello->sc) { - break; - } - } - } - if (ZRTP_COMP_UNKN == mitm_sas_scheme) { - ZRTP_LOG(1,(_ZTU_,"\tERROR! Can't find matched SAS schemes on MiTM Resolving.\n" - " s1=%u s2=$u", stream1->id, stream2->id)); - return zrtp_status_algo_fail; - } - - s = zrtp_update_remote_options( enrolled, - mitm_sas_scheme, - &non_enrolled->session->sasbin, - non_enrolled->allowclear, - non_enrolled->peer_disclose_bit ); - if (zrtp_status_ok != s) { - return s; - } - - /* NOTE: new request from Philip Zimmermann - always send SASRelay to BOTH parties. */ - /* If non-enrolled party has SAS scheme different from chosen one - update */ - /*if (non_enrolled->session->sasscheme->base.id != mitm_sas_scheme) { */ - s = zrtp_update_remote_options( non_enrolled, - mitm_sas_scheme, - NULL, - enrolled->allowclear, - enrolled->peer_disclose_bit ); - if (zrtp_status_ok != s) { - return s; - } - /*}*/ - - return s; -} - -/*---------------------------------------------------------------------------*/ -uint8_t zrtp_is_user_enrolled(zrtp_stream_t* stream) -{ - if (!stream) { - return zrtp_status_bad_param; - } - - return ( (stream->session->secrets.cached & ZRTP_BIT_PBX) && - (stream->session->secrets.matches & ZRTP_BIT_PBX) ); -} - -zrtp_stream_t* zrtp_choose_one_enrolled(zrtp_stream_t* stream1, zrtp_stream_t* stream2) -{ - if (!stream1 || !stream2) { - return NULL; - } - - if (zrtp_memcmp( stream1->session->zid.buffer, - stream2->session->zid.buffer, - stream1->session->zid.length) > 0) { - return stream1; - } else { - return stream2; - } -} diff --git a/libs/libzrtp/src/zrtp_protocol.c b/libs/libzrtp/src/zrtp_protocol.c deleted file mode 100644 index 8a62e11aa0..0000000000 --- a/libs/libzrtp/src/zrtp_protocol.c +++ /dev/null @@ -1,1456 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - -#include "zrtp.h" - -#define _ZTU_ "zrtp protocol" - - -/*===========================================================================*/ -/* PROTOCOL Logic */ -/*===========================================================================*/ - -/*----------------------------------------------------------------------------*/ -static zrtp_status_t _attach_secret( zrtp_session_t *session, - zrtp_proto_secret_t* psec, - zrtp_shared_secret_t* sec, - uint8_t is_initiator) -{ - zrtp_uchar32_t buff; - static const zrtp_string16_t initiator = ZSTR_INIT_WITH_CONST_CSTRING(ZRTP_ROLE_INITIATOR); - static const zrtp_string16_t responder = ZSTR_INIT_WITH_CONST_CSTRING(ZRTP_ROLE_RESPONDER); - - const zrtp_string16_t* role = is_initiator ? &initiator : &responder; - const zrtp_string16_t* his_role = is_initiator ? &responder : &initiator; - - ZSTR_SET_EMPTY(psec->id); - ZSTR_SET_EMPTY(psec->peer_id); - psec->secret = sec; - - /* - * If secret's value is available (from the cache or from SIP) - use hmac; - * use zero-strings in other case. - */ - if (psec->secret) { - session->hash->hmac_truncated( session->hash, - ZSTR_GV(sec->value), - ZSTR_GVP(role), - ZRTP_RSID_SIZE, - ZSTR_GV(psec->id)); - - session->hash->hmac_truncated( session->hash, - ZSTR_GV(sec->value), - ZSTR_GVP(his_role), - ZRTP_RSID_SIZE, - ZSTR_GV(psec->peer_id)); - } else { - psec->id.length = ZRTP_RSID_SIZE; - zrtp_memset(psec->id.buffer, 0, psec->id.length); - - psec->peer_id.length = ZRTP_RSID_SIZE; - zrtp_memset(psec->peer_id.buffer, 0, psec->peer_id.length); - } - - ZRTP_LOG(3,(_ZTU_,"\tAttach RS id=%s.\n", - hex2str((const char*)psec->id.buffer, psec->id.length, (char*)buff, sizeof(buff)))); - ZRTP_LOG(3,(_ZTU_,"\tAttach RS peer_id=%s.\n", - hex2str((const char*)psec->peer_id.buffer, psec->peer_id.length, (char*)buff, sizeof(buff)))); - - return zrtp_status_ok; -} - -static zrtp_status_t _attach_auxs_secret(zrtp_stream_t *stream, - zrtp_proto_secret_t* psec, - zrtp_shared_secret_t* sec, - uint8_t is_initiator) -{ - zrtp_uchar32_t buff; - - zrtp_string32_t myH3; - ZSTR_SET_EMPTY(myH3); - zrtp_zstrncpyc(ZSTR_GV(myH3), stream->messages.hello.hash, sizeof(stream->messages.hello.hash)); - - zrtp_string32_t peerH3; - ZSTR_SET_EMPTY(peerH3); - zrtp_zstrncpyc(ZSTR_GV(peerH3), stream->messages.peer_hello.hash, sizeof(stream->messages.peer_hello.hash)); - - ZSTR_SET_EMPTY(psec->id); - ZSTR_SET_EMPTY(psec->peer_id); - psec->secret = sec; - - if (psec->secret) { - stream->session->hash->hmac_truncated(stream->session->hash, - ZSTR_GV(sec->value), - ZSTR_GV(myH3), - ZRTP_RSID_SIZE, - ZSTR_GV(psec->id)); - - stream->session->hash->hmac_truncated(stream->session->hash, - ZSTR_GV(sec->value), - ZSTR_GV(peerH3), - ZRTP_RSID_SIZE, - ZSTR_GV(psec->peer_id)); - } - else { - psec->id.length = ZRTP_RSID_SIZE; - zrtp_memset(psec->id.buffer, 0, psec->id.length); - - psec->peer_id.length = ZRTP_RSID_SIZE; - zrtp_memset(psec->peer_id.buffer, 0, psec->peer_id.length); - } - - ZRTP_LOG(3, (_ZTU_, "\tAttach RS/auxs id=%s.\n", - hex2str((const char*)psec->id.buffer, psec->id.length, (char*)buff, sizeof(buff)))); - ZRTP_LOG(3, (_ZTU_, "\tAttach RS/auxs peer_id=%s.\n", - hex2str((const char*)psec->peer_id.buffer, psec->peer_id.length, (char*)buff, sizeof(buff)))); - - return zrtp_status_ok; -} - -zrtp_status_t _zrtp_protocol_init(zrtp_stream_t *stream, uint8_t is_initiator, zrtp_protocol_t **protocol) -{ - zrtp_protocol_t *new_proto = NULL; - zrtp_status_t s = zrtp_status_ok; - - ZRTP_LOG(3,(_ZTU_,"\tInit %s Protocol ID=%u mode=%s...\n", - is_initiator ? "INITIATOR's" : "RESPONDER's", stream->id, zrtp_log_mode2str(stream->mode))); - - /* Destroy previous protocol structure (Responder or Preshared) */ - if (*protocol) { - _zrtp_protocol_destroy(*protocol); - *protocol = NULL; - } - - /* Allocate memory for all branching structures */ - do - { - new_proto = zrtp_sys_alloc(sizeof(zrtp_protocol_t)); - if (!new_proto) { - s = zrtp_status_alloc_fail; - break; - } - zrtp_memset(new_proto, 0, sizeof(zrtp_protocol_t)); - - new_proto->cc = zrtp_sys_alloc(sizeof(zrtp_proto_crypto_t)); - if (!new_proto->cc) { - s = zrtp_status_alloc_fail; - break; - } - zrtp_memset(new_proto->cc, 0, sizeof(zrtp_proto_crypto_t)); - - /* Create and Initialize DH crypto context (for DH streams only) */ - if (ZRTP_IS_STREAM_DH(stream)) { - if (stream->dh_cc.initialized_with != stream->pubkeyscheme->base.id) { - stream->pubkeyscheme->initialize(stream->pubkeyscheme, &stream->dh_cc); - stream->dh_cc.initialized_with = stream->pubkeyscheme->base.id; - } - } - - /* Initialize main structure at first: functions pointers and generate nonce */ - new_proto->type = is_initiator ? ZRTP_STATEMACHINE_INITIATOR : ZRTP_STATEMACHINE_RESPONDER; - new_proto->context = stream; - - /* Initialize protocol crypto context and prepare it for further usage */ - ZSTR_SET_EMPTY(new_proto->cc->kdf_context); - ZSTR_SET_EMPTY(new_proto->cc->s0); - ZSTR_SET_EMPTY(new_proto->cc->mes_hash); - ZSTR_SET_EMPTY(new_proto->cc->hv); - ZSTR_SET_EMPTY(new_proto->cc->peer_hv); - - if (ZRTP_IS_STREAM_DH(stream)) { - _attach_secret(stream->session, &new_proto->cc->rs1, stream->session->secrets.rs1, is_initiator); - _attach_secret(stream->session, &new_proto->cc->rs2, stream->session->secrets.rs2, is_initiator); - _attach_auxs_secret(stream, &new_proto->cc->auxs, stream->session->secrets.auxs, is_initiator); - _attach_secret(stream->session, &new_proto->cc->pbxs, stream->session->secrets.pbxs, is_initiator); - } - - s = zrtp_status_ok; - *protocol = new_proto; - } while (0); - - if (s != zrtp_status_ok) { - ZRTP_LOG(1,(_ZTU_,"\tERROR! _zrtp_protocol_attach() with code %s.\n", zrtp_log_status2str(s))); - if (new_proto && new_proto->cc) { - zrtp_sys_free(new_proto->cc); - } - if (new_proto) { - zrtp_sys_free(new_proto); - } - *protocol = NULL; - } - - return s; -} - -/*----------------------------------------------------------------------------*/ -static void clear_crypto_sources(zrtp_stream_t* stream) -{ - zrtp_protocol_t* proto = stream->protocol; - if (proto && proto->cc) { - zrtp_memset(proto->cc, 0, sizeof(zrtp_proto_crypto_t)); - zrtp_sys_free(proto->cc); - proto->cc = 0; - } -} - -void _zrtp_protocol_destroy(zrtp_protocol_t *proto) -{ - /* Clear protocol crypto values, destroy SRTP unit, clear and release memory. */ - if (proto) { - /* if protocol is being destroyed by exception, ->context may be NULL */ - if (proto->context) { - _zrtp_cancel_send_packet_later(proto->context, ZRTP_NONE); - if (proto->_srtp) { - zrtp_srtp_destroy(proto->context->zrtp->srtp_global, proto->_srtp); - } - } - - clear_crypto_sources(proto->context); - zrtp_memset(proto, 0, sizeof(zrtp_protocol_t)); - zrtp_sys_free(proto); - } -} - -/*----------------------------------------------------------------------------*/ -zrtp_status_t _zrtp_protocol_encrypt( zrtp_protocol_t *proto, - zrtp_rtp_info_t *packet, - uint8_t is_rtp) -{ - zrtp_status_t s = zrtp_status_ok; - - if (is_rtp) { - s = zrtp_srtp_protect(proto->context->zrtp->srtp_global, proto->_srtp, packet); - } else { - s = zrtp_srtp_protect_rtcp(proto->context->zrtp->srtp_global, proto->_srtp, packet); - } - - if (zrtp_status_ok != s) { - ZRTP_UNALIGNED(zrtp_rtp_hdr_t) *hdr = (zrtp_rtp_hdr_t*) packet->packet; - - ZRTP_LOG(2,(_ZTU_,"ERROR! Encrypt failed. ID=%u:%s s=%s (%s size=%d ssrc=%u seq=%d pt=%d)\n", - proto->context->id, - zrtp_log_mode2str(proto->context->mode), - zrtp_log_status2str(s), - is_rtp ? "RTP" : "RTCP", - *packet->length, - zrtp_ntoh32(hdr->ssrc), - zrtp_ntoh16(hdr->seq), - hdr->pt)); - } - - return s; -} - -/*----------------------------------------------------------------------------*/ -zrtp_status_t _zrtp_protocol_decrypt( zrtp_protocol_t *proto, - zrtp_rtp_info_t *packet, - uint8_t is_rtp) -{ - zrtp_status_t s = zrtp_status_ok; - - if (is_rtp) { - s = zrtp_srtp_unprotect(proto->context->zrtp->srtp_global, proto->_srtp, packet); - } else { - s = zrtp_srtp_unprotect_rtcp(proto->context->zrtp->srtp_global, proto->_srtp, packet); - } - - if (zrtp_status_ok != s) { - ZRTP_UNALIGNED(zrtp_rtp_hdr_t) *hdr = (zrtp_rtp_hdr_t*) packet->packet; - ZRTP_LOG(2,(_ZTU_,"ERROR! Decrypt failed. ID=%u:%s s=%s (%s size=%d ssrc=%u seq=%u/%u pt=%d)\n", - proto->context->id, - zrtp_log_mode2str(proto->context->mode), - zrtp_log_status2str(s), - is_rtp ? "RTP" : "RTCP", - *packet->length, - zrtp_ntoh32(hdr->ssrc), - zrtp_ntoh16(hdr->seq), - packet->seq, - hdr->pt)); - } - - return s; -} - - -/*===========================================================================*/ -/* CRYPTO Utilites */ -/*===========================================================================*/ - -/*---------------------------------------------------------------------------*/ -static zrtp_status_t _derive_s0(zrtp_stream_t* stream, int is_initiator) -{ - static const zrtp_string32_t zrtp_kdf_label = ZSTR_INIT_WITH_CONST_CSTRING(ZRTP_KDF_STR); - static const zrtp_string32_t zrtp_sess_label = ZSTR_INIT_WITH_CONST_CSTRING(ZRTP_SESS_STR); - static const zrtp_string32_t zrtp_multi_label = ZSTR_INIT_WITH_CONST_CSTRING(ZRTP_MULTI_STR); - static const zrtp_string32_t zrtp_presh_label = ZSTR_INIT_WITH_CONST_CSTRING(ZRTP_PRESH_STR); - - zrtp_session_t *session = stream->session; - zrtp_secrets_t* secrets = &session->secrets; - zrtp_proto_crypto_t* cc = stream->protocol->cc; - void* hash_ctx = NULL; - char print_buff[256]; - - switch (stream->mode) - { - /* - * S0 computing for FULL DH exchange - * S0 computing. s0 is the master shared secret used for all - * cryptographic operations. In particular, note the inclusion - * of "total_hash", a hash of all packets exchanged up to this - * point. This belatedly detects any tampering with earlier - * packets, e.g. bid-down attacks. - * - * s0 = hash( 1 | DHResult | "ZRTP-HMAC-KDF" | ZIDi | ZIDr | - * total_hash | len(s1) | s1 | len(s2) | s2 | len(s3) | s3 ) - * The constant 1 and all lengths are 32 bits big-endian values. - * The fields without length prefixes are fixed-witdh: - * - DHresult is fixed to the width of the DH prime. - * - The hash type string and ZIDs are fixed width. - * - total_hash is fixed by the hash negotiation. - * The constant 1 is per NIST SP 800-56A section 5.8.1, and is - * a counter which can be incremented to generate more than 256 - * bits of key material. - * ======================================================================== - */ - case ZRTP_STREAM_MODE_DH: - { - zrtp_proto_secret_t *C[3] = { 0, 0, 0}; - int i = 0; - uint32_t comp_length = 0; - zrtp_stringn_t *zidi = NULL, *zidr = NULL; - struct BigNum dhresult; -#if (defined(ZRTP_USE_STACK_MINIM) && (ZRTP_USE_STACK_MINIM == 1)) - zrtp_uchar1024_t* buffer = zrtp_sys_alloc( sizeof(zrtp_uchar1024_t) ); - if (!buffer) { - return zrtp_status_alloc_fail; - } -#else - zrtp_uchar1024_t holder; - zrtp_uchar1024_t* buffer = &holder; -#endif - - ZRTP_LOG(3,(_ZTU_,"\tDERIVE S0 from DH exchange and RS secrets...\n")); - ZRTP_LOG(3,(_ZTU_,"\t my rs1ID:%s\n", hex2str(cc->rs1.id.buffer, cc->rs1.id.length, print_buff, sizeof(print_buff)))); - ZRTP_LOG(3,(_ZTU_,"\t his rs1ID:%s\n", hex2str((const char*)stream->messages.peer_dhpart.rs1ID, ZRTP_RSID_SIZE, print_buff, sizeof(print_buff)))); - ZRTP_LOG(3,(_ZTU_,"\t his rs1ID comp:%s\n", hex2str(cc->rs1.peer_id.buffer, cc->rs1.peer_id.length, print_buff, sizeof(print_buff)))); - - ZRTP_LOG(3,(_ZTU_,"\t my rs2ID:%s\n", hex2str(cc->rs2.id.buffer, cc->rs2.id.length, print_buff, sizeof(print_buff)))); - ZRTP_LOG(3,(_ZTU_,"\t his rs2ID:%s\n", hex2str((const char*)stream->messages.peer_dhpart.rs2ID, ZRTP_RSID_SIZE, print_buff, sizeof(print_buff)))); - ZRTP_LOG(3,(_ZTU_,"\t his rs2ID comp:%s\n", hex2str(cc->rs2.peer_id.buffer, cc->rs2.peer_id.length, print_buff, sizeof(print_buff)))); - - ZRTP_LOG(3,(_ZTU_,"\t my pbxsID:%s\n", hex2str(cc->pbxs.id.buffer, cc->pbxs.id.length, print_buff, sizeof(print_buff)))); - ZRTP_LOG(3,(_ZTU_,"\t his pbxsID:%s\n", hex2str((const char*)stream->messages.peer_dhpart.pbxsID, ZRTP_RSID_SIZE, print_buff, sizeof(print_buff)))); - ZRTP_LOG(3,(_ZTU_,"\this pbxsID comp:%s\n", hex2str(cc->pbxs.peer_id.buffer, cc->pbxs.peer_id.length, print_buff, sizeof(print_buff)))); - - ZRTP_LOG(3, (_ZTU_, "\t my auxsID:%s\n", hex2str(cc->auxs.id.buffer, cc->auxs.id.length, print_buff, sizeof(print_buff)))); - ZRTP_LOG(3, (_ZTU_, "\t his auxsID:%s\n", hex2str((const char*)stream->messages.peer_dhpart.auxsID, ZRTP_RSID_SIZE, print_buff, sizeof(print_buff)))); - ZRTP_LOG(3, (_ZTU_, "\this auxsID comp:%s\n", hex2str(cc->auxs.peer_id.buffer, cc->auxs.peer_id.length, print_buff, sizeof(print_buff)))); - - hash_ctx = session->hash->hash_begin(session->hash); - if (0 == hash_ctx) { - ZRTP_LOG(1,(_ZTU_, "\tERROR! can't start hash calculation for S0 computing. ID=%u.\n", stream->id)); - return zrtp_status_fail; - } - - /* - * NIST requires a 32-bit big-endian integer counter to be included - * in the hash each time the hash is computed, which we have set to - * the fixed value of 1, because we only compute the hash once. - */ - comp_length = zrtp_hton32(1L); - session->hash->hash_update(session->hash, hash_ctx, (const int8_t*)&comp_length, 4); - - - switch (stream->pubkeyscheme->base.id) { - case ZRTP_PKTYPE_DH2048: - case ZRTP_PKTYPE_DH3072: - case ZRTP_PKTYPE_DH4096: - comp_length = stream->pubkeyscheme->pv_length; - ZRTP_LOG(3,(_ZTU_,"DH comp_length=%u\n", comp_length)); - break; - case ZRTP_PKTYPE_EC256P: - case ZRTP_PKTYPE_EC384P: - case ZRTP_PKTYPE_EC521P: - comp_length = stream->pubkeyscheme->pv_length/2; - ZRTP_LOG(3,(_ZTU_,"ECDH comp_length=%u\n", comp_length)); - break; - default: - break; - } - - bnBegin(&dhresult); - stream->pubkeyscheme->compute(stream->pubkeyscheme, - &stream->dh_cc, - &dhresult, - &stream->dh_cc.peer_pv); - - bnExtractBigBytes(&dhresult, (uint8_t *)buffer, 0, comp_length); - session->hash->hash_update(session->hash, hash_ctx, (const int8_t*)buffer, comp_length); - bnEnd(&dhresult); - -#if (defined(ZRTP_USE_STACK_MINIM) && (ZRTP_USE_STACK_MINIM == 1)) - zrtp_sys_free(buffer); -#endif - - /* Add "ZRTP-HMAC-KDF" to the S0 hash */ - session->hash->hash_update( session->hash, hash_ctx, - (const int8_t*)&zrtp_kdf_label.buffer, - zrtp_kdf_label.length); - - /* Then Initiator's and Responder's ZIDs */ - if (stream->protocol->type == ZRTP_STATEMACHINE_INITIATOR) { - zidi = ZSTR_GV(stream->session->zid); - zidr = ZSTR_GV(stream->session->peer_zid); - } else { - zidr = ZSTR_GV(stream->session->zid); - zidi = ZSTR_GV(stream->session->peer_zid); - } - - session->hash->hash_update(session->hash, hash_ctx, (const int8_t*)&zidi->buffer, zidi->length); - session->hash->hash_update(session->hash, hash_ctx, (const int8_t*)&zidr->buffer, zidr->length); - session->hash->hash_update(session->hash, hash_ctx, (const int8_t*)&cc->mes_hash.buffer, cc->mes_hash.length); - - /* If everything is OK - RS1 should much */ - if (!zrtp_memcmp(cc->rs1.peer_id.buffer, stream->messages.peer_dhpart.rs1ID, ZRTP_RSID_SIZE)) - { - C[0] = &cc->rs1; - secrets->matches |= ZRTP_BIT_RS1; - } - /* If we have lost our RS1 - remote party should use backup (RS2) instead */ - else if (!zrtp_memcmp(cc->rs1.peer_id.buffer, stream->messages.peer_dhpart.rs2ID, ZRTP_RSID_SIZE)) - { - C[0] = &cc->rs1; - secrets->matches |= ZRTP_BIT_RS1; - ZRTP_LOG(2,(_ZTU_,"\tINFO! We have lost our RS1 from previous broken exchange" - " - remote party will use RS2 backup. ID=%u\n", stream->id)); - } - /* If remote party lost it's secret - we will use backup */ - else if (!zrtp_memcmp(cc->rs2.peer_id.buffer, stream->messages.peer_dhpart.rs1ID, ZRTP_RSID_SIZE)) - { - C[0] = &cc->rs2; - cc->rs1 = cc->rs2; - secrets->matches |= ZRTP_BIT_RS1; - secrets->cached |= ZRTP_BIT_RS1; - ZRTP_LOG(2,(_ZTU_,"\tINFO! Remote party has lost it's RS1 - use RS2 backup. ID=%u\n", stream->id)); - } - else - { - secrets->matches &= ~ZRTP_BIT_RS1; - if (session->zrtp->cb.cache_cb.on_set_verified) { - session->zrtp->cb.cache_cb.on_set_verified( ZSTR_GV(session->zid), - ZSTR_GV(session->peer_zid), - 0); - } - - if (session->zrtp->cb.cache_cb.on_reset_since) { - session->zrtp->cb.cache_cb.on_reset_since(ZSTR_GV(session->zid), ZSTR_GV(session->peer_zid)); - } - - ZRTP_LOG(2,(_ZTU_,"\tINFO! Our RS1 doesn't equal to other-side's one %s. ID=%u\n", - cc->rs1.secret->_cachedflag ? " - drop verified!" : "", stream->id)); - } - - if (!zrtp_memcmp(cc->rs2.peer_id.buffer, stream->messages.peer_dhpart.rs2ID, ZRTP_RSID_SIZE)) { - secrets->matches |= ZRTP_BIT_RS2; - if (0 == C[0]) { - C[0] = &cc->rs2; - } - } - - - if (secrets->auxs && - (!zrtp_memcmp(stream->messages.peer_dhpart.auxsID, cc->auxs.peer_id.buffer, ZRTP_RSID_SIZE)) ) { - C[1] =&cc->auxs; - secrets->matches |= ZRTP_BIT_AUX; - } - - if ( secrets->pbxs && - (!zrtp_memcmp(stream->messages.peer_dhpart.pbxsID, cc->pbxs.peer_id.buffer, ZRTP_RSID_SIZE)) ) { - C[2] = &cc->pbxs; - secrets->matches |= ZRTP_BIT_PBX; - } - - /* Finally hashing matched shared secrets */ - for (i=0; i<3; i++) { - /* - * Some of the shared secrets s1 through s5 may have lengths of zero - * if they are null (not shared), and are each preceded by a 4-octet - * length field. For example, if s4 is null, len(s4) is 00 00 00 00, - * and s4 itself would be absent from the hash calculation, which - * means len(s5) would immediately follow len(s4). - */ - comp_length = C[i] ? zrtp_hton32(ZRTP_RS_SIZE) : 0; - session->hash->hash_update(session->hash, hash_ctx, (const int8_t*)&comp_length, 4); - if (C[i]) { - session->hash->hash_update( session->hash, - hash_ctx, - (const int8_t*)C[i]->secret->value.buffer, - C[i]->secret->value.length ); - ZRTP_LOG(3,(_ZTU_,"\tUse S%d in calculations.\n", i+1)); - } - } - - session->hash->hash_end(session->hash, hash_ctx, ZSTR_GV(cc->s0)); - } break; /* S0 for for DH and Preshared streams */ - - /* - * Compute all possible combinations of preshared_key: - * hash(len(rs1) | rs1 | len(auxsecret) | auxsecret | len(pbxsecret) | pbxsecret) - * Find matched preshared_key and derive S0 from it: - * s0 = KDF(preshared_key, "ZRTP Stream Key", KDF_Context, negotiated hash length) - * - * INFO: Take into account that RS1 and RS2 may be swapped. - * If no matched were found - generate DH commit. - * ======================================================================== - */ - case ZRTP_STREAM_MODE_PRESHARED: - { - zrtp_status_t s = zrtp_status_ok; - zrtp_string32_t presh_key = ZSTR_INIT_EMPTY(presh_key); - - ZRTP_LOG(3,(_ZTU_,"\tDERIVE S0 for PRESHARED from cached secret. ID=%u\n", stream->id)); - - /* Use the same hash as we used for Commitment */ - if (is_initiator) - { - s = _zrtp_compute_preshared_key( session, - ZSTR_GV(session->secrets.rs1->value), - (session->secrets.auxs->_cachedflag) ? ZSTR_GV(session->secrets.auxs->value) : NULL, - (session->secrets.pbxs->_cachedflag) ? ZSTR_GV(session->secrets.pbxs->value) : NULL, - ZSTR_GV(presh_key), - NULL); - if (zrtp_status_ok != s) { - return s; - } - - secrets->matches |= ZRTP_BIT_RS1; - if (session->secrets.auxs->_cachedflag) { - secrets->matches |= ZRTP_BIT_AUX; - } - if (session->secrets.pbxs->_cachedflag) { - secrets->matches |= ZRTP_BIT_PBX; - } - } - /* - * Let's find appropriate hv key for Responder: - * , , , . - */ - else - { - int res=-1; - char* peer_key_id = (char*)stream->messages.peer_commit.hv+ZRTP_HV_NONCE_SIZE; - zrtp_string8_t key_id = ZSTR_INIT_EMPTY(key_id); - - do { - /* RS1 MUST be available at this stage.*/ - s = _zrtp_compute_preshared_key( session, - ZSTR_GV(secrets->rs1->value), - NULL, - NULL, - ZSTR_GV(presh_key), - ZSTR_GV(key_id)); - if (zrtp_status_ok == s) { - res = zrtp_memcmp(peer_key_id, key_id.buffer, ZRTP_HV_KEY_SIZE); - if (0 == res) { - secrets->matches |= ZRTP_BIT_RS1; - break; - } - } - - if (session->secrets.pbxs->_cachedflag) - { - s = _zrtp_compute_preshared_key( session, - ZSTR_GV(secrets->rs1->value), - NULL, - ZSTR_GV(secrets->pbxs->value), - ZSTR_GV(presh_key), - ZSTR_GV(key_id)); - if (zrtp_status_ok == s) { - res = zrtp_memcmp(peer_key_id, key_id.buffer, ZRTP_HV_KEY_SIZE); - if (0 == res) { - secrets->matches |= ZRTP_BIT_PBX; - break; - } - } - } - - if (session->secrets.auxs->_cachedflag) - { - s = _zrtp_compute_preshared_key( session, - ZSTR_GV(secrets->rs1->value), - ZSTR_GV(secrets->auxs->value), - NULL, - ZSTR_GV(presh_key), - ZSTR_GV(key_id)); - if (zrtp_status_ok == s) { - res = zrtp_memcmp(peer_key_id, key_id.buffer, ZRTP_HV_KEY_SIZE); - if (0 == res) { - secrets->matches |= ZRTP_BIT_AUX; - break; - } - } - } - - if ((session->secrets.pbxs->_cachedflag) && (session->secrets.auxs->_cachedflag)) - { - s = _zrtp_compute_preshared_key( session, - ZSTR_GV(secrets->rs1->value), - ZSTR_GV(secrets->auxs->value), - ZSTR_GV(secrets->pbxs->value), - ZSTR_GV(presh_key), - ZSTR_GV(key_id)); - if (zrtp_status_ok == s) { - res = zrtp_memcmp(peer_key_id, key_id.buffer, ZRTP_HV_KEY_SIZE); - if (0 == res) { - secrets->matches |= ZRTP_BIT_AUX; - secrets->matches |= ZRTP_BIT_PBX; - break; - } - } - } - - } while (0); - - if (0 != res) { - ZRTP_LOG(3,(_ZTU_,"\tINFO! Matched Key wasn't found - initate DH exchange.\n")); - secrets->cached = 0; - secrets->rs1->_cachedflag = 0; - - _zrtp_machine_start_initiating_secure(stream); - return zrtp_status_ok; - } - } - - ZRTP_LOG(3,(_ZTU_,"\tUse RS1, %s, %s in calculations.\n", - (session->secrets.matches & ZRTP_BIT_AUX) ? "AUX" : "NULL", - (session->secrets.matches & ZRTP_BIT_PBX) ? "PBX" : "NULL")); - - _zrtp_kdf( stream, - ZSTR_GV(presh_key), - ZSTR_GV(zrtp_presh_label), - ZSTR_GV(stream->protocol->cc->kdf_context), - session->hash->digest_length, - ZSTR_GV(cc->s0)); - } break; - - - /* - * For FAST Multistream: - * s0n = KDF(ZRTPSess, "ZRTP Multistream Key", KDF_Context, negotiated hash length) - * ======================================================================== - */ - case ZRTP_STREAM_MODE_MULT: - { - ZRTP_LOG(3,(_ZTU_,"\tDERIVE S0 for MULTISTREAM from ZRTP Session key... ID=%u\n", stream->id)); - _zrtp_kdf( stream, - ZSTR_GV(session->zrtpsess), - ZSTR_GV(zrtp_multi_label), - ZSTR_GV(stream->protocol->cc->kdf_context), - session->hash->digest_length, - ZSTR_GV(cc->s0)); - } break; - - default: break; - } - - - /* - * Compute ZRTP session key for FULL streams only: - * ZRTPSess = KDF(s0, "ZRTP Session Key", KDF_Context, negotiated hash length) - */ - if (!ZRTP_IS_STREAM_MULT(stream)) { - if (session->zrtpsess.length == 0) { - _zrtp_kdf( stream, - ZSTR_GV(cc->s0), - ZSTR_GV(zrtp_sess_label), - ZSTR_GV(stream->protocol->cc->kdf_context), - session->hash->digest_length, - ZSTR_GV(session->zrtpsess)); - } - } - - return zrtp_status_ok; -} - - -/*----------------------------------------------------------------------------*/ -zrtp_status_t _zrtp_set_public_value( zrtp_stream_t *stream, - int is_initiator) -{ - /* - * This function performs the following actions according to ZRTP draft 5.6 - * a) Computes total hash; - * b) Calculates DHResult; - * c) Computes final stream key S0, based on DHSS and retained secrets; - * d) Computes HMAC Key and ZRTP key; - * e) Computes srtp keys and salts and creates srtp session. - */ - - zrtp_session_t *session = stream->session; - zrtp_proto_crypto_t* cc = stream->protocol->cc; - void* hash_ctx = NULL; - - static const zrtp_string32_t hmac_keyi_label = ZSTR_INIT_WITH_CONST_CSTRING(ZRTP_INITIATOR_HMAKKEY_STR); - static const zrtp_string32_t hmac_keyr_label = ZSTR_INIT_WITH_CONST_CSTRING(ZRTP_RESPONDER_HMAKKEY_STR); - - static const zrtp_string32_t srtp_mki_label = ZSTR_INIT_WITH_CONST_CSTRING(ZRTP_INITIATOR_KEY_STR); - static const zrtp_string32_t srtp_msi_label = ZSTR_INIT_WITH_CONST_CSTRING(ZRTP_INITIATOR_SALT_STR); - static const zrtp_string32_t srtp_mkr_label = ZSTR_INIT_WITH_CONST_CSTRING(ZRTP_RESPONDER_KEY_STR); - static const zrtp_string32_t srtp_msr_label = ZSTR_INIT_WITH_CONST_CSTRING(ZRTP_RESPONDER_SALT_STR); - - static const zrtp_string32_t zrtp_keyi_label = ZSTR_INIT_WITH_CONST_CSTRING(ZRTP_INITIATOR_ZRTPKEY_STR); - static const zrtp_string32_t zrtp_keyr_label = ZSTR_INIT_WITH_CONST_CSTRING(ZRTP_RESPONDER_ZRTPKEY_STR); - - uint32_t cipher_key_length = (ZRTP_CIPHER_AES128 == session->blockcipher->base.id) ? 16 : 32; - - const zrtp_string32_t *output_mk_label; - const zrtp_string32_t *output_ms_label; - const zrtp_string32_t *input_mk_label; - const zrtp_string32_t *input_ms_label; - const zrtp_string32_t *hmac_key_label; - const zrtp_string32_t *peer_hmac_key_label; - const zrtp_string32_t *zrtp_key_label; - const zrtp_string32_t *peer_zrtp_key_label; - - /* Define roles and prepare structures */ - if (is_initiator) { - output_mk_label = &srtp_mki_label; - output_ms_label = &srtp_msi_label; - input_mk_label = &srtp_mkr_label; - input_ms_label = &srtp_msr_label; - hmac_key_label = &hmac_keyi_label; - peer_hmac_key_label = &hmac_keyr_label; - zrtp_key_label = &zrtp_keyi_label; - peer_zrtp_key_label = &zrtp_keyr_label; - } else { - output_mk_label = &srtp_mkr_label; - output_ms_label = &srtp_msr_label; - input_mk_label = &srtp_mki_label; - input_ms_label = &srtp_msi_label; - hmac_key_label = &hmac_keyr_label; - peer_hmac_key_label = &hmac_keyi_label; - zrtp_key_label = &zrtp_keyr_label; - peer_zrtp_key_label = &zrtp_keyi_label; - } - - ZRTP_LOG(3, (_ZTU_,"---------------------------------------------------\n")); - ZRTP_LOG(3,(_ZTU_,"\tSWITCHING TO SRTP. ID=%u\n", zrtp_log_mode2str(stream->mode), stream->id)); - ZRTP_LOG(3,(_ZTU_,"\tI %s\n", is_initiator ? "Initiator" : "Responder")); - - /* - * Compute total messages hash: - * total_hash = hash(Hello of responder | Commit | DHPart1 | DHPart2) for DH streams - * total_hash = hash(Hello of responder | Commit ) for Fast modes. - */ - { - uint8_t* tok = NULL; - uint16_t tok_len = 0; - - hash_ctx = session->hash->hash_begin(session->hash); - if (0 == hash_ctx) { - return zrtp_status_fail; - } - - tok = is_initiator ? (uint8_t*)&stream->messages.peer_hello : (uint8_t*) &stream->messages.hello; - tok_len = is_initiator ? stream->messages.peer_hello.hdr.length : stream->messages.hello.hdr.length; - tok_len = zrtp_ntoh16(tok_len)*4; - session->hash->hash_update(session->hash, hash_ctx, (const int8_t*)tok, tok_len); - - tok = is_initiator ? (uint8_t*)&stream->messages.commit : (uint8_t*)&stream->messages.peer_commit; - tok_len = is_initiator ? stream->messages.commit.hdr.length : stream->messages.peer_commit.hdr.length; - tok_len = zrtp_ntoh16(tok_len)*4; - session->hash->hash_update(session->hash, hash_ctx, (const int8_t*)tok, tok_len); - - if (ZRTP_IS_STREAM_DH(stream)) - { - tok = (uint8_t*) (is_initiator ? &stream->messages.peer_dhpart : &stream->messages.dhpart); - tok_len = is_initiator ? stream->messages.peer_dhpart.hdr.length : stream->messages.dhpart.hdr.length; - tok_len = zrtp_ntoh16(tok_len)*4; - session->hash->hash_update(session->hash, hash_ctx, (const int8_t*)tok, tok_len); - - tok = (uint8_t*)(is_initiator ? &stream->messages.dhpart : &stream->messages.peer_dhpart); - tok_len = is_initiator ? stream->messages.dhpart.hdr.length : stream->messages.peer_dhpart.hdr.length; - tok_len = zrtp_ntoh16(tok_len)*4; - session->hash->hash_update(session->hash, hash_ctx, (const int8_t*)tok, tok_len); - } - - session->hash->hash_end(session->hash, hash_ctx, ZSTR_GV(cc->mes_hash)); - hash_ctx = NULL; - } /* total hash computing */ - - /* Total Hash is ready and we can create KDF_Context */ - zrtp_zstrcat(ZSTR_GV(cc->kdf_context), is_initiator ? ZSTR_GV(session->zid) : ZSTR_GV(session->peer_zid)); - zrtp_zstrcat(ZSTR_GV(cc->kdf_context), is_initiator ? ZSTR_GV(session->peer_zid) : ZSTR_GV(session->zid)); - zrtp_zstrcat(ZSTR_GV(cc->kdf_context), ZSTR_GV(cc->mes_hash)); - - /* Derive stream key S0 according to key exchange scheme */ - if (zrtp_status_ok != _derive_s0(stream, is_initiator)) { - return zrtp_status_fail; - } - - /* - * Compute HMAC keys. These values will be used after confirmation: - * hmackeyi = KDF(s0, "Initiator HMAC key", KDF_Context, negotiated hash length) - * hmackeyr = KDF(s0, "Responder HMAC key", KDF_Context, negotiated hash length) - */ - _zrtp_kdf( stream, - ZSTR_GV(cc->s0), - ZSTR_GVP(hmac_key_label), - ZSTR_GV(stream->protocol->cc->kdf_context), - session->hash->digest_length, - ZSTR_GV(stream->cc.hmackey)); - _zrtp_kdf( stream, - ZSTR_GV(cc->s0), - ZSTR_GVP(peer_hmac_key_label), - ZSTR_GV(stream->protocol->cc->kdf_context), - session->hash->digest_length, - ZSTR_GV(stream->cc.peer_hmackey)); - - /* - * Computing ZRTP keys for protection of the Confirm packet: - * zrtpkeyi = KDF(s0, "Initiator ZRTP key", KDF_Context, negotiated AES key length) - * zrtpkeyr = KDF(s0, "Responder ZRTP key", KDF_Context, negotiated AES key length) - */ - _zrtp_kdf( stream, - ZSTR_GV(cc->s0), - ZSTR_GVP(zrtp_key_label), - ZSTR_GV(stream->protocol->cc->kdf_context), - cipher_key_length, - ZSTR_GV(stream->cc.zrtp_key)); - _zrtp_kdf( stream, - ZSTR_GV(cc->s0), - ZSTR_GVP(peer_zrtp_key_label), - ZSTR_GV(stream->protocol->cc->kdf_context), - cipher_key_length, - ZSTR_GV(stream->cc.peer_zrtp_key)); -#if (defined(ZRTP_DEBUG_ZRTP_KEYS) && ZRTP_DEBUG_ZRTP_KEYS == 1) - { - char print_buff[256]; - ZRTP_LOG(3,(_ZTU_,"\t Messages hash:%s\n", hex2str(cc->mes_hash.buffer, cc->mes_hash.length, print_buff, sizeof(print_buff)))); - ZRTP_LOG(3,(_ZTU_,"\t S0:%s\n", hex2str(cc->s0.buffer, cc->s0.length, print_buff, sizeof(print_buff)))); - ZRTP_LOG(3,(_ZTU_,"\t ZRTP Sess:%s\n", hex2str(session->zrtpsess.buffer, session->zrtpsess.length, print_buff, sizeof(print_buff)))); - ZRTP_LOG(3,(_ZTU_,"\t hmackey:%s\n", hex2str(stream->cc.hmackey.buffer, stream->cc.hmackey.length, print_buff, sizeof(print_buff)))); - ZRTP_LOG(3,(_ZTU_,"\t peer_hmackeyr:%s\n", hex2str(stream->cc.peer_hmackey.buffer, stream->cc.peer_hmackey.length, print_buff, sizeof(print_buff)))); - ZRTP_LOG(3,(_ZTU_,"\t ZRTP key:%s\n", hex2str(stream->cc.zrtp_key.buffer, stream->cc.zrtp_key.length, print_buff, sizeof(print_buff)))); - ZRTP_LOG(3,(_ZTU_,"\t Peer ZRTP key:%s\n", hex2str(stream->cc.peer_zrtp_key.buffer, stream->cc.peer_zrtp_key.length, print_buff, sizeof(print_buff)))); - } -#endif - /* - * Preparing SRTP crypto engine: - * srtpkeyi = KDF(s0, "Initiator SRTP master key", KDF_Context, negotiated AES key length) - * srtpsalti = KDF(s0, "Initiator SRTP master salt", KDF_Context, 112) - * srtpkeyr = KDF(s0, "Responder SRTP master key", KDF_Context, negotiated AES key length) - * srtpsaltr = KDF(s0, "Responder SRTP master salt", KDF_Context, 112) - */ - { - zrtp_srtp_profile_t iprof; - zrtp_srtp_profile_t oprof; - - ZSTR_SET_EMPTY(iprof.salt); - ZSTR_SET_EMPTY(iprof.key); - - iprof.rtp_policy.cipher = session->blockcipher; - iprof.rtp_policy.auth_tag_len = session->authtaglength; - iprof.rtp_policy.hash = zrtp_comp_find(ZRTP_CC_HASH, ZRTP_SRTP_HASH_HMAC_SHA1, session->zrtp); - iprof.rtp_policy.auth_key_len = 20; - iprof.rtp_policy.cipher_key_len = cipher_key_length; - - zrtp_memcpy(&iprof.rtcp_policy, &iprof.rtp_policy, sizeof(iprof.rtcp_policy)); - iprof.dk_cipher = session->blockcipher; - - zrtp_memcpy(&oprof, &iprof, sizeof(iprof)); - - _zrtp_kdf( stream, - ZSTR_GV(cc->s0), - ZSTR_GVP(input_mk_label), - ZSTR_GV(stream->protocol->cc->kdf_context), - cipher_key_length, - ZSTR_GV(iprof.key)); - _zrtp_kdf( stream, - ZSTR_GV(cc->s0), - ZSTR_GVP(input_ms_label), - ZSTR_GV(stream->protocol->cc->kdf_context), - 14, - ZSTR_GV(iprof.salt)); - _zrtp_kdf( stream, - ZSTR_GV(cc->s0), - ZSTR_GVP(output_mk_label), - ZSTR_GV(stream->protocol->cc->kdf_context), - cipher_key_length, - ZSTR_GV(oprof.key)); - _zrtp_kdf( stream, - ZSTR_GV(cc->s0), - ZSTR_GVP(output_ms_label), - ZSTR_GV(stream->protocol->cc->kdf_context), - 14, - ZSTR_GV(oprof.salt)); - - stream->protocol->_srtp = zrtp_srtp_create(session->zrtp->srtp_global, &iprof, &oprof); - - /* Profiles and keys in them are not needed anymore - clear them */ - zrtp_memset(&iprof, 0, sizeof(iprof)); - zrtp_memset(&oprof, 0, sizeof(oprof)); - - if (!stream->protocol->_srtp) { - ZRTP_LOG(1,(_ZTU_,"\tERROR! Can't initialize SRTP engine. ID=%u\n", stream->id)); - return zrtp_status_fail; - } - } /* SRTP initialization */ - - return zrtp_status_ok; -} - -/*---------------------------------------------------------------------------*/ -zrtp_status_t _zrtp_machine_enter_secure(zrtp_stream_t* stream) -{ - /* - * When switching to SECURE all ZRTP crypto values were already computed by - * state-machine. Then we need to have logic to manage SAS value and shared - * secrets only. So: we compute SAS, refresh secrets flags and save the - * secrets to the cache after RS2 and RS1 swapping. We don't need any - * crypto sources any longer - destroy them. - */ - - zrtp_status_t s = zrtp_status_ok; - zrtp_proto_crypto_t* cc = stream->protocol->cc; - zrtp_session_t *session = stream->session; - zrtp_secrets_t *secrets = &stream->session->secrets; - uint8_t was_exp = 0; - uint64_t exp_date = 0; - - ZRTP_LOG(3,(_ZTU_,"\tEnter state SECURE (%s).\n", zrtp_log_mode2str(stream->mode))); - - _zrtp_cancel_send_packet_later(stream, ZRTP_NONE); - - /* - * Compute the SAS value if it isn't computed yet. If there are several - * streams running in parallel - stream with the biggest hvi should - * generate the SAS. - */ - if (!session->sas1.length) { - s = session->sasscheme->compute(session->sasscheme, stream, session->hash, 0); - if (zrtp_status_ok != s) { - _zrtp_machine_enter_initiatingerror(stream, zrtp_error_software, 1); - return s; - } - - - ZRTP_LOG(3,(_ZTU_,"\tThis is the very first stream in sID GENERATING SAS value.\n", session->id)); - ZRTP_LOG(3,(_ZTU_,"\tSAS computed: <%.16s> <%.16s>.\n", session->sas1.buffer, session->sas2.buffer)); - } - - /* - * Compute a new value for RS1 and store the prevoious one. - * Compute result secrets' flags. - */ - if (ZRTP_IS_STREAM_DH(stream)) - { - ZRTP_LOG(3,(_ZTU_,"\tCheck expiration interval: last_use=%u ttl=%u new_ttl=%u exp=%u now=%u\n", - secrets->rs1->lastused_at, - secrets->rs1->ttl, - stream->cache_ttl, - (secrets->rs1->lastused_at + secrets->rs1->ttl), - zrtp_time_now()/1000)); - - if (secrets->rs1->ttl != 0xFFFFFFFF) { - exp_date = secrets->rs1->lastused_at; - exp_date += secrets->rs1->ttl; - - if (ZRTP_IS_STREAM_DH(stream) && (exp_date < zrtp_time_now()/1000)) { - ZRTP_LOG(3,(_ZTU_,"\tUsing EXPIRED secrets: last_use=%u ttl=%u exp=%u now=%u\n", - secrets->rs1->lastused_at, - secrets->rs1->ttl, - (secrets->rs1->lastused_at + secrets->rs1->ttl), - zrtp_time_now()/1000)); - was_exp = 1; - } - } - - if (!was_exp) { - secrets->wrongs = secrets->matches ^ secrets->cached; - secrets->wrongs &= ~ZRTP_BIT_RS2; - secrets->wrongs &= ~ZRTP_BIT_PBX; - } - } - - /* - * We going to update RS1 and change appropriate secrets flags. Let's back-up current values. - * Back-upped values could be used in debug purposes and in the GUI to reflect current state of the call - */ - if (!ZRTP_IS_STREAM_MULT(stream)) { - secrets->cached_curr = secrets->cached; - secrets->matches_curr = secrets->matches; - secrets->wrongs_curr = secrets->wrongs; - } - - - ZRTP_LOG(3,(_ZTU_,"\tFlags C=%x M=%x W=%x ID=%u\n", - secrets->cached, secrets->matches, secrets->wrongs, stream->id)); - - _zrtp_change_state(stream, ZRTP_STATE_SECURE); - /* - * Alarm user if the following condition is TRUE for both RS1 and RS2: - * "secret is wrong if it has been restored from the cache but hasn't matched - * with the remote one". - */ - if (session->zrtp->cb.event_cb.on_zrtp_protocol_event) { - session->zrtp->cb.event_cb.on_zrtp_protocol_event(stream, ZRTP_EVENT_IS_SECURE); - } - if (session->zrtp->cb.event_cb.on_zrtp_secure) { - session->zrtp->cb.event_cb.on_zrtp_secure(stream); - } - - /* Alarm user if possible MiTM attack detected */ - if (secrets->wrongs) { - session->mitm_alert_detected = 1; - - if (session->zrtp->cb.event_cb.on_zrtp_security_event) { - session->zrtp->cb.event_cb.on_zrtp_security_event(stream, ZRTP_EVENT_MITM_WARNING); - } - } - - /* Check for unenrollemnt first */ - if ((secrets->cached & ZRTP_BIT_PBX) && !(secrets->matches & ZRTP_BIT_PBX)) { - ZRTP_LOG(2,(_ZTU_,"\tINFO! The user requires new un-enrolment - the nedpint may clear" - " the cache or perform other action. ID=%u\n", stream->id)); - - if (session->zrtp->cb.event_cb.on_zrtp_protocol_event) { - session->zrtp->cb.event_cb.on_zrtp_protocol_event(stream, ZRTP_EVENT_USER_UNENROLLED); - } - } - - /* - * Handle PBX registration, if required: If PBX already had a shared secret - * for the ZID it leaves the cache entry unmodified. Else, it computes a new - * one. If the PBX detects cache entry for the static shared secret, but the - * phone does not have a matching cache entry - the PBX generates a new one. - */ - if (ZRTP_MITM_MODE_REG_SERVER == stream->mitm_mode) - { - if (secrets->matches & ZRTP_BIT_PBX) { - ZRTP_LOG(2,(_ZTU_,"\tINFO! User have been already registered - skip enrollment ritual. ID=%u\n", stream->id)); - if (session->zrtp->cb.event_cb.on_zrtp_protocol_event) { - session->zrtp->cb.event_cb.on_zrtp_protocol_event(stream, ZRTP_EVENT_USER_ALREADY_ENROLLED); - } - } else { - ZRTP_LOG(2,(_ZTU_,"\tINFO! The user requires new enrolment - generate new MiTM secret. ID=%u\n", stream->id)); - zrtp_register_with_trusted_mitm(stream); - if (session->zrtp->cb.event_cb.on_zrtp_protocol_event) { - stream->zrtp->cb.event_cb.on_zrtp_protocol_event(stream, ZRTP_EVENT_NEW_USER_ENROLLED); - } - - } - } - else if (ZRTP_MITM_MODE_REG_CLIENT == stream->mitm_mode) - { - if (session->zrtp->cb.event_cb.on_zrtp_protocol_event) { - session->zrtp->cb.event_cb.on_zrtp_protocol_event(stream, ZRTP_EVENT_IS_CLIENT_ENROLLMENT); - } - } - - /* - * Compute new RS for FULL DH streams only. Don't update RS1 if cache TTL is 0 - */ - if (ZRTP_IS_STREAM_DH(stream)) - { - static const zrtp_string32_t rss_label = ZSTR_INIT_WITH_CONST_CSTRING(ZRTP_RS_STR); - - if (stream->cache_ttl > 0) { - /* Replace RS2 with RS1 */ - zrtp_sys_free(secrets->rs2); - secrets->rs2 = secrets->rs1; - - secrets->rs1 = _zrtp_alloc_shared_secret(session); - if (!secrets->rs1) { - _zrtp_machine_enter_initiatingerror(stream, zrtp_error_software, 1); - return zrtp_status_fail; - } - - /* - * Compute new RS1 based on previous one and S0: - * rs1 = KDF(s0, "retained secret", KDF_Context, negotiated hash length) - */ - _zrtp_kdf( stream, - ZSTR_GV(cc->s0), - ZSTR_GV(rss_label), - ZSTR_GV(cc->kdf_context), - ZRTP_HASH_SIZE, - ZSTR_GV(secrets->rs1->value)); - - /* - * Mark secrets as cached: RS1 have been just generated and cached; - * RS2 is cached if previous secret was cached as well. - */ - secrets->rs1->_cachedflag = 1; - secrets->cached |= ZRTP_BIT_RS1; - secrets->matches |= ZRTP_BIT_RS1; - if (secrets->rs2->_cachedflag) { - secrets->cached |= ZRTP_BIT_RS2; - } - - /* Let's update the TTL interval for the new secret */ - secrets->rs1->ttl = stream->cache_ttl; - secrets->rs1->lastused_at = (uint32_t)(zrtp_time_now()/1000); - - /* If possible MiTM attach detected - postpone storing the cache until after the user verify the SAS */ - if (!session->mitm_alert_detected) { - if (session->zrtp->cb.cache_cb.on_put) { - session->zrtp->cb.cache_cb.on_put( ZSTR_GV(session->zid), - ZSTR_GV(session->peer_zid), - secrets->rs1); - } - } - - { - uint32_t verifiedflag = 0; - char buff[128]; - if (session->zrtp->cb.cache_cb.on_get_verified) { - session->zrtp->cb.cache_cb.on_get_verified( ZSTR_GV(session->zid), - ZSTR_GV(session->peer_zid), - &verifiedflag); - } - - ZRTP_LOG(3,(_ZTU_,"\tNew secret was generated:\n")); - ZRTP_LOG(3,(_ZTU_,"\t\tRS1 value:<%s>\n", - hex2str(secrets->rs1->value.buffer, secrets->rs1->value.length, buff, sizeof(buff)))); - ZRTP_LOG(3,(_ZTU_,"\t\tTTL=%u, flags C=%x M=%x W=%x V=%d\n", - secrets->rs1->ttl, secrets->cached, secrets->matches, secrets->wrongs, verifiedflag)); - } - } /* for TTL > 0 only */ - else { - if (session->zrtp->cb.cache_cb.on_put) { - secrets->rs1->ttl = 0; - session->zrtp->cb.cache_cb.on_put( ZSTR_GV(session->zid), - ZSTR_GV(session->peer_zid), - secrets->rs1); - } - } - } /* For DH mode only */ - - - if (session->zrtp->cb.event_cb.on_zrtp_protocol_event) { - session->zrtp->cb.event_cb.on_zrtp_protocol_event(stream, ZRTP_EVENT_IS_SECURE_DONE); - } - - /* We have computed all subkeys from S0 and don't need it any longer. */ - zrtp_wipe_zstring(ZSTR_GV(cc->s0)); - - /* Clear DH crypto context */ - if (ZRTP_IS_STREAM_DH(stream)) { - bnEnd(&stream->dh_cc.peer_pv); - bnEnd(&stream->dh_cc.pv); - bnEnd(&stream->dh_cc.sv); - zrtp_wipe_zstring(ZSTR_GV(stream->dh_cc.dhss)); - } - - /* - * Now, let's check if the transition to CLEAR was caused by Active/Passive rules. - * If local endpoint is a MitM and peer MiTM linked stream is Unlimited, we - * could break the rules and send commit to Passive endpoint. - */ - if (stream->zrtp->is_mitm && stream->peer_super_flag) { - if (stream->linked_mitm && stream->linked_mitm->peer_passive) { - if (stream->linked_mitm->state == ZRTP_STATE_CLEAR) { - ZRTP_LOG(2,(_ZTU_,"INFO: Linked Peer stream id=%u suspended in CLEAR-state due to" - " Active/Passive restrictions, but we are running in MiTM mode and " - "current peer endpoint is Super-Active. Let's Go Secure for the linked stream.\n", stream->id)); - - /* @note: don't use zrtp_secure_stream() wrapper as it checks for Active/Passive stuff. */ - _zrtp_machine_start_initiating_secure(stream->linked_mitm); - } - } - } - - /* - * Increase calls counter for Preshared mode and reset it on DH - */ - if (session->zrtp->cb.cache_cb.on_presh_counter_get && session->zrtp->cb.cache_cb.on_presh_counter_set) { - uint32_t calls_counter = 0; - session->zrtp->cb.cache_cb.on_presh_counter_get( ZSTR_GV(session->zid), - ZSTR_GV(session->peer_zid), - &calls_counter); - if (ZRTP_IS_STREAM_DH(stream)) { - session->zrtp->cb.cache_cb.on_presh_counter_set( ZSTR_GV(session->zid), - ZSTR_GV(session->peer_zid), - 0); - } else if ZRTP_IS_STREAM_PRESH(stream) { - session->zrtp->cb.cache_cb.on_presh_counter_set( ZSTR_GV(session->zid), - ZSTR_GV(session->peer_zid), - ++calls_counter); - } - } - - clear_crypto_sources(stream); - - return zrtp_status_ok; -} - - -/*===========================================================================*/ -/* Shared functions */ -/*===========================================================================*/ - -/*----------------------------------------------------------------------------*/ -zrtp_status_t _zrtp_machine_create_confirm( zrtp_stream_t *stream, - zrtp_packet_Confirm_t* confirm) -{ - void* cipher_ctx = NULL; - zrtp_status_t s = zrtp_status_fail; - zrtp_session_t *session = stream->session; - uint32_t verifiedflag = 0; - - /* hash + (padding + sig_len + flags) + ttl */ - const uint8_t encrypted_body_size = ZRTP_MESSAGE_HASH_SIZE + (2 + 1 + 1) + 4; - - /* - * Create the Confirm packet according to draft 6.7 - * AES CFB vector at first, SIG length and flags octet and cache TTL at the end - * This version doesn't support signatures so sig_length=0 - */ - if (ZRTP_CFBIV_SIZE != zrtp_randstr(session->zrtp, confirm->iv, ZRTP_CFBIV_SIZE)) { - return zrtp_status_fail; - } - - zrtp_memcpy(confirm->hash, stream->messages.h0.buffer, ZRTP_MESSAGE_HASH_SIZE); - - if (session->zrtp->cb.cache_cb.on_get_verified) { - session->zrtp->cb.cache_cb.on_get_verified( ZSTR_GV(session->zid), - ZSTR_GV(session->peer_zid), - &verifiedflag); - } - - confirm->expired_interval = zrtp_hton32(session->profile.cache_ttl); - confirm->flags = 0; - confirm->flags |= session->profile.disclose_bit ? 0x01 : 0x00; - confirm->flags |= session->profile.allowclear ? 0x02 : 0x00; - confirm->flags |= verifiedflag ? 0x04 : 0x00; - confirm->flags |= (ZRTP_MITM_MODE_REG_SERVER == stream->mitm_mode) ? 0x08 : 0x00; - - /* Then we need to encrypt Confirm before Hmac computing. Use AES CFB */ - do - { - cipher_ctx = session->blockcipher->start( session->blockcipher, - (uint8_t*)stream->cc.zrtp_key.buffer, - NULL, - ZRTP_CIPHER_MODE_CFB); - if (!cipher_ctx) { - break; - } - - s = session->blockcipher->set_iv(session->blockcipher, cipher_ctx, (zrtp_v128_t*)confirm->iv); - if (zrtp_status_ok != s) { - break; - } - - s = session->blockcipher->encrypt( session->blockcipher, - cipher_ctx, - (uint8_t*)&confirm->hash, - encrypted_body_size ); - } while(0); - if (cipher_ctx) { - session->blockcipher->stop(session->blockcipher, cipher_ctx); - } - if (zrtp_status_ok != s) { - ZRTP_LOG(1,(_ZTU_,"ERROR! failed to encrypt Confirm. s=%d ID=%u\n", s, stream->id)); - return s; - } - - /* Compute Hmac over encrypted part of Confirm */ - { - zrtp_string128_t hmac = ZSTR_INIT_EMPTY(hmac); - s = session->hash->hmac_c( session->hash, - stream->cc.hmackey.buffer, - stream->cc.hmackey.length, - (const char*)&confirm->hash, - encrypted_body_size, - ZSTR_GV(hmac) ); - if (zrtp_status_ok != s) { - ZRTP_LOG(1,(_ZTU_,"ERROR! failed to compute Confirm hmac. s=%d ID=%u\n", s, stream->id)); - return s; - } - - zrtp_memcpy(confirm->hmac, hmac.buffer, ZRTP_HMAC_SIZE); - - { - char buff[512]; - ZRTP_LOG(3,(_ZTU_,"HMAC TRACE. COMPUTE.\n")); - ZRTP_LOG(3,(_ZTU_,"\tcipher text:%s. size=%u\n", - hex2str((const char*)&confirm->hash, encrypted_body_size, buff, sizeof(buff)), encrypted_body_size)); - ZRTP_LOG(3,(_ZTU_,"\t key:%s.\n", - hex2str(stream->cc.hmackey.buffer, stream->cc.hmackey.length, buff, sizeof(buff)))); - ZRTP_LOG(3,(_ZTU_,"\t comp hmac:%s.\n", - hex2str(hmac.buffer, hmac.length, buff, sizeof(buff)))); - ZRTP_LOG(3,(_ZTU_,"\t hmac:%s.\n", - hex2str((const char*)confirm->hmac, ZRTP_HMAC_SIZE, buff, sizeof(buff)))); - } - } - - return zrtp_status_ok; -} - -/*----------------------------------------------------------------------------*/ -zrtp_status_t _zrtp_machine_process_confirm( zrtp_stream_t *stream, - zrtp_packet_Confirm_t *confirm) -{ - /* Compute Hmac over encrypted part of Confirm and reject malformed packets */ - void* cipher_ctx = NULL; - zrtp_status_t s = zrtp_status_fail; - zrtp_session_t *session = stream->session; - zrtp_string128_t hmac = ZSTR_INIT_EMPTY(hmac); - - /* hash + (padding + sig_len + flags) + ttl */ - const uint8_t encrypted_body_size = ZRTP_MESSAGE_HASH_SIZE + (2 + 1 + 1) + 4; - s = session->hash->hmac_c( session->hash, - stream->cc.peer_hmackey.buffer, - stream->cc.peer_hmackey.length, - (const char*)&confirm->hash, - encrypted_body_size, - ZSTR_GV(hmac) ); - if (zrtp_status_ok != s) { - ZRTP_LOG(1,(_ZTU_,"\tERROR! failed to compute Incoming Confirm hmac. s=%d ID=%u\n", s, stream->id)); - return zrtp_status_fail; - } - - - // MARK: TRACE CONFIRM HMAC ERROR -#if 0 - { - char buff[512]; - ZRTP_LOG(3,(_ZTU_,"HMAC TRACE. VERIFY\n")); - ZRTP_LOG(3,(_ZTU_,"\tcipher text:%s. size=%u\n", - hex2str((const char*)&confirm->hash, encrypted_body_size, buff, sizeof(buff)), encrypted_body_size)); - ZRTP_LOG(3,(_ZTU_,"\t key:%s.\n", - hex2str(stream->cc.peer_hmackey.buffer, stream->cc.peer_hmackey.length, buff, sizeof(buff)))); - ZRTP_LOG(3,(_ZTU_,"\t comp hmac:%s.\n", - hex2str(hmac.buffer, hmac.length, buff, sizeof(buff)))); - ZRTP_LOG(3,(_ZTU_,"\t hmac:%s.\n", - hex2str((const char*)confirm->hmac, ZRTP_HMAC_SIZE, buff, sizeof(buff)))); - } -#endif - - - if (0 != zrtp_memcmp(confirm->hmac, hmac.buffer, ZRTP_HMAC_SIZE)) { - /* - * Weird. Perhaps a bug in our code or our peer's code. Or it could be an attacker - * who doesn't realize that Man-In-The-Middling the Diffie-Hellman key generation - * but allowing the correct rsIds to pass through accomplishes nothing more than - * forcing us to fallback to cleartext mode. If this attacker had gone ahead and deleted - * or replaced the rsIds, then he would have been able to stay in the middle (although - * he would of course still face the threat of a Voice Authentication Check). On the - * other hand if this attacker wanted to force us to fallback to cleartext mode, he could - * have done that more simply, for example by intercepting our ZRTP HELLO packet and - * replacing it with a normal non-ZRTP comfort noise packet. In any case, we'll do our - * "switch to cleartext fallback" behavior. - */ - - ZRTP_LOG(2,(_ZTU_,"\tWARNING!" ZRTP_VERIFIED_RESP_WARNING_STR "ID=%u\n", stream->id)); - - _zrtp_machine_enter_initiatingerror(stream, zrtp_error_auth_decrypt, 1); - return zrtp_status_fail; - } - - /* Then we need to decrypt Confirm body */ - do { - cipher_ctx = session->blockcipher->start( session->blockcipher, - (uint8_t*)stream->cc.peer_zrtp_key.buffer, - NULL, - ZRTP_CIPHER_MODE_CFB); - if (!cipher_ctx) { - break; - } - - s = session->blockcipher->set_iv( session->blockcipher, - cipher_ctx, - (zrtp_v128_t*)confirm->iv); - if (zrtp_status_ok != s) { - break; - } - - s = session->blockcipher->decrypt( session->blockcipher, - cipher_ctx, - (uint8_t*)&confirm->hash, - encrypted_body_size); - } while(0); - if (cipher_ctx) { - session->blockcipher->stop(session->blockcipher, cipher_ctx); - } - if (zrtp_status_ok != s) { - ZRTP_LOG(3,(_ZTU_,"\tERROR! failed to decrypt incoming Confirm. s=%d ID=%u\n", s, stream->id)); - return s; - } - - /* We have access to hash field and can check hmac of the previous message */ - { - zrtp_msg_hdr_t *hdr = NULL; - char *key=NULL; - zrtp_string32_t tmphash_str = ZSTR_INIT_EMPTY(tmphash_str); - zrtp_hash_t *hash = zrtp_comp_find( ZRTP_CC_HASH, ZRTP_HASH_SHA256, stream->zrtp); - - if (ZRTP_IS_STREAM_DH(stream)) { - hdr = &stream->messages.peer_dhpart.hdr; - key = (char*)confirm->hash; - } else { - hash->hash_c(hash, (char*)confirm->hash, ZRTP_MESSAGE_HASH_SIZE, ZSTR_GV(tmphash_str)); - - if (ZRTP_STATEMACHINE_INITIATOR == stream->protocol->type) { - hdr = &stream->messages.peer_hello.hdr; - hash->hash_c( hash, - tmphash_str.buffer, - ZRTP_MESSAGE_HASH_SIZE, - ZSTR_GV(tmphash_str) ); - } else { - hdr = &stream->messages.peer_commit.hdr; - } - key = tmphash_str.buffer; - } - - if (0 != _zrtp_validate_message_hmac(stream, hdr, key)) { - return zrtp_status_fail; - } - } - - /* Set evil bit if other-side shared session key */ - stream->peer_disclose_bit = (confirm->flags & 0x01); - - /* Enable ALLOWCLEAR option if only both sides support it */ - stream->allowclear = (confirm->flags & 0x02) && session->profile.allowclear; - - /* Drop RS1 VERIFIED flag if other side didn't verified key exchange */ - if (0 == (confirm->flags & 0x04)) { - ZRTP_LOG(2,(_ZTU_,"\tINFO: Other side Confirm V=0 - set verified to 0! ID=%u\n", stream->id)); - zrtp_verified_set(session->zrtp, &session->zid, &session->peer_zid, 0); - } - - /* Look for Enrollment replay flag */ - if (confirm->flags & 0x08) - { - ZRTP_LOG(2,(_ZTU_,"\tINFO: Confirm PBX Enrolled flag is set - it is a Registration call! ID=%u\n", stream->id)); - - if (stream->mitm_mode != ZRTP_MITM_MODE_CLIENT) { - ZRTP_LOG(2,(_ZTU_,"\tERROR: PBX enrollment flag was received in wrong MiTM mode %s." - " ID=%u\n", zrtp_log_mode2str(stream->mode), stream->id)); - _zrtp_machine_enter_initiatingerror(stream, zrtp_error_invalid_packet, 1); - return zrtp_status_fail; - } - - /* Passive endpoint should ignore PBX Enrollment. */ - if (ZRTP_LICENSE_MODE_PASSIVE != stream->zrtp->lic_mode) { - stream->mitm_mode = ZRTP_MITM_MODE_REG_CLIENT; - } else { - ZRTP_LOG(2,(_ZTU_,"\tINFO: Ignore PBX Enrollment flag as we are Passive ID=%u\n", stream->id)); - } - } - - stream->cache_ttl = ZRTP_MIN(session->profile.cache_ttl, zrtp_ntoh32(confirm->expired_interval)); - - /* Copy packet for future hashing */ - zrtp_memcpy(&stream->messages.peer_confirm, confirm, zrtp_ntoh16(confirm->hdr.length)*4); - - return zrtp_status_ok; -} diff --git a/libs/libzrtp/src/zrtp_responder.c b/libs/libzrtp/src/zrtp_responder.c deleted file mode 100644 index 73e25f7495..0000000000 --- a/libs/libzrtp/src/zrtp_responder.c +++ /dev/null @@ -1,612 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - -#include "zrtp.h" - -#define _ZTU_ "zrtp responder" - -extern zrtp_status_t _zrtp_machine_start_initiating_secure(zrtp_stream_t *stream); - -/* These functions construct packets for further replies. */ -static zrtp_status_t _prepare_dhpart1(zrtp_stream_t *stream); -static zrtp_status_t _prepare_confirm1(zrtp_stream_t *stream); - -/* Functions which are used to answer the Initiator's requests */ -static void _send_dhpart1(zrtp_stream_t *stream); -static void _send_confirm1(zrtp_stream_t *stream); - -/* - * Parses crypto-components list chosen by the initiator. doesn't perform any - * tests. Commit was fully checked by previous call of _zrtp_machine_preparse_commit(). - * \exception: Handles all exceptions -- informs user and switches to CLEAR. - * (zrtp_error_XXX_unsp and zrtp_error_software errors.) - */ -static zrtp_status_t _zrtp_machine_process_commit( zrtp_stream_t* stream, - zrtp_rtp_info_t* packet); - -/* - * Parses DH packet: check for MitM1, MitM2 attacks and makes a copy of it for further usage. - * \exception: (MITM attacks, SOFTWARE) Informs user and switches to CLEAR. - */ -static zrtp_status_t _zrtp_machine_process_dhpart2( zrtp_stream_t *stream, - zrtp_rtp_info_t *packet); - -/* - * Just a wrapper over the protocol::_zrtp_machine_process_confirm(). - * \exception: (AUTH attacks, SOFTWARE) Informs user and switches to CLEAR. - */ -static zrtp_status_t _zrtp_machine_process_confirm2( zrtp_stream_t *stream, - zrtp_rtp_info_t *packet); - - -/*===========================================================================*/ -/* State handlers */ -/*===========================================================================*/ - -/*---------------------------------------------------------------------------*/ -zrtp_status_t _zrtp_machine_process_while_in_pendingsecure( zrtp_stream_t* stream, - zrtp_rtp_info_t* packet) -{ - zrtp_status_t s = zrtp_status_ok; - - switch (packet->type) - { - case ZRTP_COMMIT: - _send_dhpart1(stream); - break; - - case ZRTP_DHPART2: - s = _zrtp_machine_process_dhpart2(stream, packet); - if (zrtp_status_ok != s) { - break; - } - - /* Perform Keys generation according to draft 5.6 */ - s = _zrtp_set_public_value(stream, 0); - if (zrtp_status_ok != s) { - _zrtp_machine_enter_initiatingerror(stream, zrtp_error_software, 1); - break; - } - - s = _prepare_confirm1(stream); - if (zrtp_status_ok != s) { - _zrtp_machine_enter_initiatingerror(stream, zrtp_error_software, 1); - break; - } - - _zrtp_change_state(stream, ZRTP_STATE_WAIT_CONFIRM2); - _send_confirm1(stream); - break; - - case ZRTP_NONE: - s = zrtp_status_drop; - break; - - default: - break; - } - - return s; -} - - -/*---------------------------------------------------------------------------*/ -zrtp_status_t _zrtp_machine_process_while_in_waitconfirm2( zrtp_stream_t* stream, - zrtp_rtp_info_t* packet) -{ - zrtp_status_t status = zrtp_status_ok; - - switch (packet->type) - { - case ZRTP_DHPART2: - if (ZRTP_IS_STREAM_DH(stream)) { - _send_confirm1(stream); - } - break; - - case ZRTP_COMMIT: - if (ZRTP_IS_STREAM_FAST(stream)) { - _send_confirm1(stream); - } - break; - - case ZRTP_CONFIRM2: - status = _zrtp_machine_process_confirm2(stream, packet); - if (zrtp_status_ok == status) { - _zrtp_packet_send_message(stream, ZRTP_CONFIRM2ACK, NULL); - status = _zrtp_machine_enter_secure(stream); - } - break; - - case ZRTP_NONE: - status = zrtp_status_drop; - break; - - default: - break; - } - - return status; -} - - -/*===========================================================================*/ -/* States switchers */ -/*===========================================================================*/ - -/*---------------------------------------------------------------------------*/ -zrtp_status_t _zrtp_machine_enter_pendingsecure( zrtp_stream_t* stream, - zrtp_rtp_info_t* packet) -{ - zrtp_status_t s = zrtp_status_ok; - - ZRTP_LOG(3,(_ZTU_,"\tENTER STATE PENDING SECURE for ID=%u mode=%s state=%s.\n", - stream->id, zrtp_log_mode2str(stream->mode), zrtp_log_state2str(stream->state))); - - do - { - if (!ZRTP_IS_STREAM_MULT(stream)) { - zrtp_packet_Commit_t *commit = (zrtp_packet_Commit_t*) packet->message; - - stream->session->hash = zrtp_comp_find( ZRTP_CC_HASH, - zrtp_comp_type2id(ZRTP_CC_HASH, (char*)commit->hash_type), - stream->zrtp); - stream->session->blockcipher = zrtp_comp_find( ZRTP_CC_CIPHER, - zrtp_comp_type2id(ZRTP_CC_CIPHER, (char*)commit->cipher_type), - stream->zrtp); - stream->session->authtaglength = zrtp_comp_find( ZRTP_CC_ATL, - zrtp_comp_type2id(ZRTP_CC_ATL, (char*)commit->auth_tag_length), - stream->zrtp); - stream->session->sasscheme = zrtp_comp_find( ZRTP_CC_SAS, - zrtp_comp_type2id(ZRTP_CC_SAS, (char*)commit->sas_type), - stream->zrtp); - - ZRTP_LOG(3,(_ZTU_,"\tRemote COMMIT specified following options:\n")); - ZRTP_LOG(3,(_ZTU_,"\t Hash: %.4s\n", commit->hash_type)); - ZRTP_LOG(3,(_ZTU_,"\t Cipher: %.4s\n", commit->cipher_type)); - ZRTP_LOG(3,(_ZTU_,"\t ATL: %.4s\n", commit->auth_tag_length)); - ZRTP_LOG(3,(_ZTU_,"\t PK scheme: %.4s\n", commit->public_key_type)); - ZRTP_LOG(3,(_ZTU_,"\tVAD scheme: %.4s\n", commit->sas_type)); - } - - if (ZRTP_IS_STREAM_DH(stream)) { - _zrtp_change_state(stream, ZRTP_STATE_PENDINGSECURE); - - /* - * If stream->concurrent is set this means that we stopped a concurrent - * DH stream to break a tie. This can happen when Commit messages are - * sent by both ZRTP endpoints at the same time, but are received in - * different media streams. Now current stream has finished DH setup and - * we can resume the other one. - */ - if (stream->concurrent) { - zrtp_stream_t* tctx = stream->concurrent; - stream->concurrent = NULL; - ZRTP_LOG(3,(_ZTU_,"\tRelease2 Concurrent stream=%u ID=%u\n", tctx->id, stream->id)); - _zrtp_machine_start_initiating_secure(tctx); - } - - s = _zrtp_protocol_init(stream, 0, &stream->protocol); - if (zrtp_status_ok != s) { - break; - } - - s = _zrtp_machine_process_commit(stream, packet); /* doesn't throw exception */ - if (zrtp_status_ok != s) { - break; /* Software error */ - } - - s = _prepare_dhpart1(stream); - if (zrtp_status_ok != s) { - break; /* EH: Always successful */ - } - - _zrtp_machine_process_while_in_pendingsecure(stream, packet); - - if (stream->zrtp->cb.event_cb.on_zrtp_protocol_event) { - stream->zrtp->cb.event_cb.on_zrtp_protocol_event(stream, ZRTP_EVENT_IS_PENDINGSECURE); - } - } - else - { - _zrtp_change_state(stream, ZRTP_STATE_WAIT_CONFIRM2); - - s = _zrtp_protocol_init(stream, 0, &stream->protocol); - if (zrtp_status_ok != s) { - break; - } - - s = _zrtp_machine_process_commit(stream, packet); /* doesn't throw exception */ - if (zrtp_status_ok != s) { - break; /* Software error */ - } - - s = _zrtp_set_public_value(stream, 0); - if (zrtp_status_ok != s) { - break; /* Software error */ - } - - s = _prepare_confirm1(stream); - if (zrtp_status_ok != s) { - break; /* Software error */ - } - - _send_confirm1(stream); - } - } while (0); - - if (zrtp_status_ok != s) { - if (stream->protocol) { - _zrtp_protocol_destroy(stream->protocol); - stream->protocol = NULL; - } - _zrtp_machine_enter_initiatingerror(stream, zrtp_error_software, 1); - } - - return s; -} - - -/*===========================================================================*/ -/* Packets handlers */ -/*===========================================================================*/ - -/*---------------------------------------------------------------------------*/ -static zrtp_status_t _check_commit(zrtp_stream_t *stream, zrtp_packet_Commit_t *commit) -{ - do { - /* check PUBLIC KEY TYPE */ - if (0 > zrtp_profile_find( &stream->session->profile, - ZRTP_CC_PKT, - zrtp_comp_type2id(ZRTP_CC_PKT, (char*)commit->public_key_type))) - { - /* Can't talk to them. ZRTP public key type not supported by current profile */ - ZRTP_LOG(2,(_ZTU_,"\tINFO: PKExch %.4s isn't supported by profile. ID=%u\n", - commit->public_key_type, stream->id)); - _zrtp_machine_enter_initiatingerror(stream, zrtp_error_pktype_unsp, 1); - break; - } - - /* check HASH scheme */ - if ( 0 > zrtp_profile_find( &stream->session->profile, - ZRTP_CC_HASH, - zrtp_comp_type2id(ZRTP_CC_HASH, (char*)commit->hash_type)) ) - { - /* Can't talk to them. ZRTP hash type not supported by current profile */ - ZRTP_LOG(2,(_ZTU_,"\tINFO: Hash %.4s isn't supported by profile. ID=%u\n", - commit->hash_type, stream->id)); - _zrtp_machine_enter_initiatingerror(stream, zrtp_error_hash_unsp, 1); - break; - } - - /* check CIPHER type */ - if ( 0 > zrtp_profile_find( &stream->session->profile, - ZRTP_CC_CIPHER, - zrtp_comp_type2id(ZRTP_CC_CIPHER, (char*)commit->cipher_type)) ) - { - /* Can't talk to them. ZRTP cipher type not supported by current profile */ - ZRTP_LOG(2,(_ZTU_,"\tINFO: Cipher %.4s isn't supported by profile. ID=%u\n", - commit->cipher_type, stream->id)); - _zrtp_machine_enter_initiatingerror(stream, zrtp_error_cipher_unsp, 1); - break; - } - - /* check AUTH TAG LENGTH */ - if ( 0 > zrtp_profile_find( &stream->session->profile, - ZRTP_CC_ATL, - zrtp_comp_type2id(ZRTP_CC_ATL, (char*)commit->auth_tag_length)) ) - { - /* Can't talk to them. ZRTP auth tag length not supported by current profile */ - ZRTP_LOG(2,(_ZTU_,"\tINFO: Authtag %.4s isn't supported by profile. ID=%u\n", - commit->auth_tag_length, stream->id)); - _zrtp_machine_enter_initiatingerror(stream, zrtp_error_auth_unsp, 1); - break; - } - - /* check SAS scheme */ - if ( 0 > zrtp_profile_find( &stream->session->profile, - ZRTP_CC_SAS, - zrtp_comp_type2id(ZRTP_CC_SAS, (char*)commit->sas_type)) ) - { - /* Can't talk to them. ZRTP SAS scheme not supported by current profile */ - ZRTP_LOG(2,(_ZTU_,"\tINFO: SAS %.4s isn't supported by profile. ID=%u\n", - commit->sas_type, stream->id)); - _zrtp_machine_enter_initiatingerror(stream, zrtp_error_sas_unsp, 1); - break; - } - - return zrtp_status_ok; - } while (0); - - return zrtp_status_fail; -} - -/*---------------------------------------------------------------------------*/ -zrtp_statemachine_type_t _zrtp_machine_preparse_commit( zrtp_stream_t *stream, - zrtp_rtp_info_t* packet) -{ - zrtp_packet_Commit_t *commit = (zrtp_packet_Commit_t*) packet->message; - zrtp_statemachine_type_t res = ZRTP_STATEMACHINE_RESPONDER; - - zrtp_pktype_id_t his_pkt = zrtp_comp_type2id(ZRTP_CC_PKT, (char*)commit->public_key_type); - zrtp_stream_mode_t his_mode = (his_pkt == ZRTP_PKTYPE_PRESH) ? ZRTP_STREAM_MODE_PRESHARED : (his_pkt == ZRTP_PKTYPE_MULT) ? ZRTP_STREAM_MODE_MULT : ZRTP_STREAM_MODE_DH; - - ZRTP_LOG(3,(_ZTU_,"\tPreparse incoming COMMIT. Remote peer wants %.4s:%d mode lic=%d peer M=%d.\n", - commit->public_key_type, his_mode, stream->zrtp->lic_mode, stream->peer_mitm_flag)); - - /* - * Checking crypto components chosen by other peer for stream establishment - */ - if (zrtp_status_ok != _check_commit(stream, commit)) { - return ZRTP_STATEMACHINE_NONE; - } - - /* - * Passive ZRTP endpoint can't talk to ZRTP MiTM endpoints. - */ - if (!ZRTP_PASSIVE3_TEST(stream)) { - ZRTP_LOG(2,(_ZTU_,"\tERROR: The endpoint is in passive mode and can't handle" - " connections with MiTM endpoints. ID=%u\n", stream->id)); - if (stream->zrtp->cb.event_cb.on_zrtp_protocol_event ) { - stream->zrtp->cb.event_cb.on_zrtp_protocol_event(stream, ZRTP_EVENT_IS_PASSIVE_RESTRICTION); - } - _zrtp_machine_enter_initiatingerror(stream, zrtp_error_service_unavail, 1); - return ZRTP_STATEMACHINE_NONE; - } - - /* - * Both sides are in "Initiating" state we need to break the tie: - * - if both sides wants to use the same scheme - side with lower vh switches to - * "Responder" state. - * - if both sides wants to use Preshared scheme and one of the sides are in MiTM mode it - * should switch to Responder state - * - if one side wants Preshared and onother one DH - DH should win. - * - rest of the combinations (DH - Multistream, Preshared - Multistream) are deperecated by the RFC - */ - if (ZRTP_STATE_INITIATINGSECURE == stream->state) - { - zrtp_pktype_id_t my_pkt = stream->pubkeyscheme->base.id; - zrtp_stream_mode_t my_mode = (my_pkt == ZRTP_PKTYPE_PRESH) ? ZRTP_STREAM_MODE_PRESHARED : (my_pkt == ZRTP_PKTYPE_MULT) ? ZRTP_STREAM_MODE_MULT : ZRTP_STREAM_MODE_DH; - - ZRTP_LOG(2,(_ZTU_,"\tBoth sides are in INITIATINGSECURE State - BREACK the TIE. ID=%u\n", stream->id)); - - if (his_mode == my_mode) { - if ( (his_mode == ZRTP_STREAM_MODE_PRESHARED) && (stream->peer_mitm_flag || stream->zrtp->is_mitm)) { - if (stream->peer_mitm_flag) { - ZRTP_LOG(3,(_ZTU_,"\tWe running in Gneral ZRTP Endpoint mode, but the" - " remote side is in MiTM - stay Initiating state.\n")); - res = ZRTP_STATEMACHINE_INITIATOR; - } - } else { - if (zrtp_memcmp( stream->protocol->cc->hv.buffer, - commit->hv, - (his_mode == ZRTP_STREAM_MODE_DH) ? ZRTP_HV_SIZE : ZRTP_HV_NONCE_SIZE) > 0) { - ZRTP_LOG(3,(_ZTU_,"\tWe have Commit with greater HV so stay Initiating state.\n")); - res = ZRTP_STATEMACHINE_INITIATOR; - } - } - } else { - if (my_mode == ZRTP_STREAM_MODE_DH) { - ZRTP_LOG(3,(_ZTU_,"\tOther peer sent Non DH Commit but we want DH - stay Initiating state.\n")); - res = ZRTP_STATEMACHINE_INITIATOR; - } - } - } - - if (res == ZRTP_STATEMACHINE_RESPONDER) - { - /* - * If other peer wants to switch "Preshared" we must be ready for this. Check - * for secrets availability and if we can't use "Preshared" we should force other - * peer to switch to "DH" mode. For this purpose we use our own Commit with DHxK - * in it. Such Commit should win competition in any case. - */ - if ((his_mode == ZRTP_STREAM_MODE_PRESHARED) && !stream->session->secrets.rs1->_cachedflag) { - ZRTP_LOG(3,(_ZTU_, "\tOther peer wants Preshared mode but we have no secrets.\n")); - res = ZRTP_STATEMACHINE_INITIATOR; - } - - /* - * If other peer wants to switch "Multistream" we must be ready for this. Check - * for ZRTPSess key availability. If we can't use "Multistream" we should force other - * peer to switch to "DH" mode. For this purpose we use our own Commit with DHxK - * in it. Such Commit should win competition in any case. - */ - if ((his_mode == ZRTP_STREAM_MODE_MULT) && !stream->session->zrtpsess.length) { - ZRTP_LOG(3,(_ZTU_,"\tOther peer wants Preshared mode but we have no secrets.\n")); - res = ZRTP_STATEMACHINE_INITIATOR; - } - - /* - * If other peer wants "Full DH" exchange but ZRTP Session key have been already - * computed - there is no sense in doing this. What is more, ZRTP Specification - * doesn't allow doing this. - */ - if ((his_mode == ZRTP_STREAM_MODE_DH) && (stream->session->zrtpsess.length > 0)) { - ZRTP_LOG(3,(_ZTU_,"\tOther peer wants DH mode but we have ZRTP session and ready for Multistream.\n")); - res = ZRTP_STATEMACHINE_NONE; - } - } - - /* - * If we decided to use Responder's state-machine - only one DH or Preshared stream - * can be run at the moment so check states. - */ - if ((res == ZRTP_STATEMACHINE_RESPONDER) && !_zrtp_can_start_stream(stream, &stream->concurrent, his_mode)) - { - ZRTP_LOG(3,(_ZTU_,"\tCan't handle COMMIT another DH with ID=%u is in progress.\n", stream->concurrent->id)); - - if ( (stream->concurrent->state <= ZRTP_STATE_INITIATINGSECURE) && - (zrtp_memcmp(stream->concurrent->protocol->cc->hv.buffer, commit->hv, ZRTP_HV_SIZE) < 0) ) - { - ZRTP_LOG(3,(_ZTU_,"\tPossible DEADLOCK Resolving. STOP CONCURRENT" - " Stream with ID=%u\n",stream->concurrent->id)); - _zrtp_cancel_send_packet_later(stream->concurrent, ZRTP_NONE); - } else { - res = ZRTP_STATEMACHINE_NONE; - } - } - - if (res == ZRTP_STATEMACHINE_RESPONDER) { - ZRTP_LOG(3,(_ZTU_,"\tChosen Responder State-Machine. Change Mode to %s," - " pkt to %.4s\n", zrtp_log_mode2str(his_mode), commit->public_key_type)); - stream->mode = his_mode; - stream->pubkeyscheme = zrtp_comp_find(ZRTP_CC_PKT, his_pkt, stream->zrtp); - } else { - ZRTP_LOG(3,(_ZTU_,"\tChosen Initiator State-Machine. Stay in current Mode\n")); - } - - return res; -} - -/*---------------------------------------------------------------------------*/ -zrtp_status_t _zrtp_machine_process_commit(zrtp_stream_t* stream, zrtp_rtp_info_t* packet) -{ - zrtp_packet_Commit_t *commit = (zrtp_packet_Commit_t*) packet->message; - - switch (stream->mode) - { - case ZRTP_STREAM_MODE_DH: - zrtp_zstrncpyc( ZSTR_GV(stream->protocol->cc->peer_hv), - (const char*)commit->hv, - ZRTP_HV_SIZE); - break; - case ZRTP_STREAM_MODE_PRESHARED: - zrtp_zstrncpyc( ZSTR_GV(stream->protocol->cc->peer_hv), - (const char*)commit->hv + ZRTP_HV_NONCE_SIZE, - ZRTP_HV_NONCE_SIZE); - case ZRTP_STREAM_MODE_MULT: - zrtp_zstrncpyc( ZSTR_GV(stream->protocol->cc->peer_hv), - (const char*)commit->hv, - ZRTP_HV_NONCE_SIZE); - break; - default: break; - } - - /* Copy Commit packet for further hashing */ - zrtp_memcpy(&stream->messages.peer_commit, commit, zrtp_ntoh16(commit->hdr.length)*4); - - return zrtp_status_ok; -} - - -/*----------------------------------------------------------------------------*/ -static zrtp_status_t _zrtp_machine_process_dhpart2( zrtp_stream_t *stream, - zrtp_rtp_info_t *packet) -{ - zrtp_status_t s = zrtp_status_ok; - zrtp_proto_crypto_t* cc = stream->protocol->cc; - zrtp_packet_DHPart_t *dhpart2 = (zrtp_packet_DHPart_t*) packet->message; - void *hash_ctx = NULL; - - /* - * Verify hash commitment. (Compare hvi calculated from DH with peer hvi from COMMIT) - * According to the last version of the internet draft 04a. Hvi should be - * computed as: hvi=hash(initiator's DHPart2 message | responder's Hello message) - */ - hash_ctx = stream->session->hash->hash_begin(stream->session->hash); - if (!hash_ctx) { - return zrtp_status_fail; - } - - stream->session->hash->hash_update( stream->session->hash, - hash_ctx, - (const int8_t*)dhpart2, - zrtp_ntoh16(dhpart2->hdr.length)*4); - stream->session->hash->hash_update( stream->session->hash, - hash_ctx, - (const int8_t*)&stream->messages.hello, - zrtp_ntoh16(stream->messages.hello.hdr.length)*4); - stream->session->hash->hash_end( stream->session->hash, - hash_ctx, - ZSTR_GV(cc->hv)); - - /* Truncate comuted hvi to 256 bit. The same length as transferred in Commit message.*/ - cc->hv.length = ZRTP_HASH_SIZE; - - if (0 != zrtp_zstrcmp(ZSTR_GV(cc->hv), ZSTR_GV(cc->peer_hv))) { - ZRTP_LOG(1,(_ZTU_,"\tERROR!" ZRTP_MIM2_WARNING_STR " ID=%u\n", stream->id)); - _zrtp_machine_enter_initiatingerror(stream, zrtp_error_possible_mitm2, 1); - return zrtp_status_fail; - } - - /* Validate DH exchange (pvi is 1 or p-1). For DH streams only */ - bnInsertBigBytes(&stream->dh_cc.peer_pv, dhpart2->pv, 0, stream->pubkeyscheme->pv_length); - - s = stream->pubkeyscheme->validate(stream->pubkeyscheme, &stream->dh_cc.peer_pv); - if (zrtp_status_ok != s) { - ZRTP_LOG(1,(_ZTU_,"\tERROR!" ZRTP_MITM1_WARNING_STR " ID=%u\n", stream->id)); - _zrtp_machine_enter_initiatingerror(stream, zrtp_error_possible_mitm1, 1); - return s; - } - - /* Copy DH Part2 packet for future hashing */ - zrtp_memcpy(&stream->messages.peer_dhpart, dhpart2, zrtp_ntoh16(dhpart2->hdr.length)*4); - - return s; -} - -/*----------------------------------------------------------------------------*/ -zrtp_status_t _zrtp_machine_process_confirm2( zrtp_stream_t *stream, - zrtp_rtp_info_t *packet) -{ - zrtp_packet_Confirm_t *confirm2 = (zrtp_packet_Confirm_t*) packet->message; - return _zrtp_machine_process_confirm(stream, confirm2); -} - - -/*===========================================================================*/ -/* Packets senders */ -/*===========================================================================*/ - -/*----------------------------------------------------------------------------*/ -static void _send_dhpart1(zrtp_stream_t *stream) -{ - _zrtp_packet_send_message(stream, ZRTP_DHPART1, &stream->messages.dhpart); -} - -static zrtp_status_t _prepare_dhpart1(zrtp_stream_t *stream) -{ - zrtp_proto_crypto_t* cc = stream->protocol->cc; - zrtp_packet_DHPart_t *dh1 = &stream->messages.dhpart; - uint16_t dh_length = (uint16_t)stream->pubkeyscheme->pv_length; - - zrtp_memcpy(dh1->rs1ID, cc->rs1.id.buffer, ZRTP_RSID_SIZE); - zrtp_memcpy(dh1->rs2ID, cc->rs2.id.buffer, ZRTP_RSID_SIZE); - zrtp_memcpy(dh1->auxsID, cc->auxs.id.buffer, ZRTP_RSID_SIZE); - zrtp_memcpy(dh1->pbxsID, cc->pbxs.id.buffer, ZRTP_RSID_SIZE); - - bnExtractBigBytes(&stream->dh_cc.pv, dh1->pv, 0, dh_length); - - _zrtp_packet_fill_msg_hdr( stream, - ZRTP_DHPART1, - dh_length + ZRTP_DH_STATIC_SIZE + ZRTP_HMAC_SIZE, - &dh1->hdr); - - return zrtp_status_ok; -} - -/*----------------------------------------------------------------------------*/ -static void _send_confirm1(zrtp_stream_t *stream) -{ - _zrtp_packet_send_message(stream, ZRTP_CONFIRM1, &stream->messages.confirm); -} - -static zrtp_status_t _prepare_confirm1(zrtp_stream_t *stream) -{ - zrtp_status_t s = _zrtp_machine_create_confirm(stream, &stream->messages.confirm); - if (zrtp_status_ok == s) { - s = _zrtp_packet_fill_msg_hdr( stream, - ZRTP_CONFIRM1, - sizeof(zrtp_packet_Confirm_t) - sizeof(zrtp_msg_hdr_t), - &stream->messages.confirm.hdr); - } - - return s; -} diff --git a/libs/libzrtp/src/zrtp_rng.c b/libs/libzrtp/src/zrtp_rng.c deleted file mode 100644 index c32fbe3a30..0000000000 --- a/libs/libzrtp/src/zrtp_rng.c +++ /dev/null @@ -1,351 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - */ - -#include "zrtp.h" - -#define _ZTU_ "zrtp rng" - -#define MD_DIGEST_LENGTH SHA512_DIGEST_SIZE -#define MD_CTX_init(a) -#define MD_Init(a) sha512_begin(a) -#define MD_Final(a,b) sha512_end(b,a) -#define MD_Cleanup(a) zrtp_memset(a,0,sizeof(*a)); - - -#if (ZRTP_PLATFORM == ZP_WIN32) || (ZRTP_PLATFORM == ZP_WIN64) || (ZRTP_PLATFORM == ZP_WINCE) - -#include - -HCRYPTPROV g_hCryptProv; - -zrtp_status_t NtLmInitializeRNG(VOID) -{ - BOOL fSuccess; - - if (g_hCryptProv != 0) { - return zrtp_status_ok; - } - - fSuccess = CryptAcquireContext( &g_hCryptProv, - NULL, - NULL, - PROV_RSA_FULL, - CRYPT_VERIFYCONTEXT); - - return (TRUE == fSuccess) ? zrtp_status_ok : zrtp_status_fail; -} - -void NtLmCleanupRNG(VOID) -{ - if (g_hCryptProv) { - CryptReleaseContext(g_hCryptProv, 0); - g_hCryptProv = 0; - } -} - -int zrtp_add_system_state(zrtp_global_t* zrtp, MD_CTX *ctx) -{ - uint8_t buffer[64]; - - if(!CryptGenRandom(g_hCryptProv, sizeof(buffer), buffer)) { - ZRTP_LOG(1,(_ZTU_,"\tERROR! Error during CryptGenRandom.\n")); - return 0; - } - - MD_Update(ctx, buffer, sizeof(buffer)); - ZeroMemory((PVOID)buffer, sizeof(buffer)); - - return sizeof(buffer); -} - -#elif (ZRTP_PLATFORM == ZP_WIN32_KERNEL) - -#include - -/*----------------------------------------------------------------------------*/ -int zrtp_add_system_state(zrtp_global_t* zrtp, MD_CTX *ctx) -{ - LARGE_INTEGER li1; - LARGE_INTEGER li2; - ULONG ul1; - ULONG ul2; - ULONGLONG ull; - PKTHREAD thread; - static int tsc_ok = 1; - /* - * WARNING! - * Of course it's not a real size of entropy added to the context. It's very - * difficult to compute the size of real random data and estimate its quality. - * This value means: size of maximum possible random data which this function can provide. - */ - static int entropy_length = sizeof(LARGE_INTEGER)*2 + sizeof(PKTHREAD) + - sizeof(ULONG)*2 + sizeof(LARGE_INTEGER)*2 + sizeof(ULONG)*2; - - li2 = KeQueryPerformanceCounter(&li1); - MD_Update(ctx, &li1, sizeof(LARGE_INTEGER)); - MD_Update(ctx, &li2, sizeof(LARGE_INTEGER)); - - ull = KeQueryInterruptTime(); - MD_Update(ctx, &ull, sizeof(ULONGLONG)); - - thread = KeGetCurrentThread(); - MD_Update(ctx, &thread, sizeof(PKTHREAD)); - ul2 = KeQueryRuntimeThread(thread, &ul1); - MD_Update(ctx, &ul1, sizeof(ULONG)); - MD_Update(ctx, &ul2, sizeof(ULONG)); - - KeQuerySystemTime(&li1); - MD_Update(ctx, &li1, sizeof(LARGE_INTEGER)); - - KeQueryTickCount(&li1); - MD_Update(ctx, &li1, sizeof(LARGE_INTEGER)); - - if (tsc_ok) { - __try { - ull = _RDTSC(); - MD_Update(ctx, &ull, sizeof(ULONGLONG)); - } __except(EXCEPTION_EXECUTE_HANDLER) { - tsc_ok = 0; - } - } - - return entropy_length; -} - -#elif ((ZRTP_PLATFORM == ZP_SYMBIAN)) -/* - * WARNING! - * This is just a stub to let you start with something little bit better then zero. - * We have no possibility to implement entropy collection in this abstract cross-platform - * application. This function MUST NOT be used as example in real applications. For more - * information read \ref RNG in developers guide - * - * To add real entropy - capture random data from microphone and camera. - */ -extern uint32_t zrtp_symbian_kernel_random(); -extern uint32_t zrtp_sum_of_pid_and_number_of_poccesses(); -extern uint64_t zrtp_get_system_time_crazy(); -extern unsigned int zrtp_get_pid(); -extern uint32_t zrtp_get_availible_heap(); - - -int zrtp_add_system_state(zrtp_global_t* zrtp, MD_CTX *ctx) { - uint64_t sysdate; - unsigned int pid; - uint32_t crazy_pid_sum; - - uint32_t heap_size; - - static int entropy_length = sizeof(sysdate) + sizeof(pid) - + sizeof(crazy_pid_sum) + sizeof(heap_size); - sysdate = zrtp_get_system_time_crazy(); - MD_Update(ctx,&sysdate,sizeof(sysdate)); - - pid = zrtp_get_pid(); - - MD_Update(ctx,&pid,sizeof(pid)); - - crazy_pid_sum = zrtp_sum_of_pid_and_number_of_poccesses(); - MD_Update(ctx,&crazy_pid_sum,sizeof(crazy_pid_sum)); - - heap_size = zrtp_get_availible_heap(); - MD_Update(ctx,&heap_size,sizeof(heap_size)); - - return entropy_length; -} - -#elif ( (ZRTP_PLATFORM == ZP_LINUX) || (ZRTP_PLATFORM == ZP_DARWIN) || (ZRTP_PLATFORM == ZP_BSD) || (ZRTP_PLATFORM == ZP_ANDROID) ) - -#if ZRTP_HAVE_STDIO_H == 1 -# include -#else -# error "Used environment dosn't have - zrtp_rng.c can't be build." -#endif - -/*----------------------------------------------------------------------------*/ -int zrtp_add_system_state(zrtp_global_t* zrtp, MD_CTX *ctx) -{ - uint8_t buffer[64]; - size_t bytes_read = 0; - static size_t length= sizeof(buffer); - FILE *fp = NULL; - - fp = fopen("/dev/urandom", "rb"); - if (!fp) { - ZRTP_LOG(1,(_ZTU_,"\tERROR! can't get access to /dev/urandom - trying /dev/random.\n")); - fp = fopen("/dev/random", "rb"); - } - - if (fp) { - int number_of_retries = 1024; - while ((bytes_read < length) && (number_of_retries-- > 0)) { - setbuf(fp, NULL); /* Otherwise fread() tries to read() 4096 bytes or other default value */ - bytes_read += fread(buffer+bytes_read, 1, length-bytes_read, fp); - } - - if (0 != fclose(fp)) { - ZRTP_LOG(1,(_ZTU_,"\tERROR! unable to cloas /dev/random\n")); - } - } else { - ZRTP_LOG(1,(_ZTU_,"\tERROR! RNG Can't open /dev/random\n")); - } - - if (bytes_read < length) { - ZRTP_LOG(1,(_ZTU_,"\tERROR! can't read random string! Current session have to be closed.\n")); - return -1; - } - - MD_Update(ctx, buffer, length); - zrtp_memset(buffer, 0, sizeof(buffer)); - - return bytes_read; -} - -#endif - -/*----------------------------------------------------------------------------*/ -zrtp_status_t zrtp_init_rng(zrtp_global_t* zrtp) -{ - if (!zrtp->rand_initialized) { - zrtp_mutex_init(&zrtp->rng_protector); - MD_Init(&zrtp->rand_ctx); -#if (ZRTP_PLATFORM == ZP_WIN32) || (ZRTP_PLATFORM == ZP_WIN64) || (ZRTP_PLATFORM == ZP_WINCE) - if (zrtp_status_ok != NtLmInitializeRNG()) { - ZRTP_LOG(1,(_ZTU_,"\tERROR! during CryptAcquireContext!\n")); - return zrtp_status_fail; - } -#endif - zrtp->rand_initialized = 1; - } - - return zrtp_status_ok; -} - -void zrtp_down_rng(zrtp_global_t* zrtp) -{ - if (zrtp->rand_initialized) { - zrtp_mutex_destroy(zrtp->rng_protector); -#if (ZRTP_PLATFORM == ZP_WIN32) || (ZRTP_PLATFORM == ZP_WIN64) || (ZRTP_PLATFORM == ZP_WINCE) - NtLmCleanupRNG(); -#endif - zrtp->rand_initialized = 0; - } -} - - -/* - * Call this to add entropy to the system from the given buffer, - * and also from the system state. It's OK to pass a null buffer - * with a length of zero, then we will just use the system entropy. - */ -/*----------------------------------------------------------------------------*/ -int zrtp_entropy_add(zrtp_global_t* zrtp, const unsigned char *buffer, uint32_t length) -{ - if (buffer && length) { - MD_Update(&zrtp->rand_ctx, buffer, length); - } - - return zrtp_add_system_state(zrtp, &zrtp->rand_ctx); -} - - -/* - * Random bits are produced as follows. - * First stir new entropy into the random state (zrtp->rand_ctx). - * Then make a copy of the random context and finalize it. - * Use the digest to seed an AES-256 context and, if space remains, to - * initialize a counter. - * Then encrypt the counter with the AES-256 context, incrementing it - * per block, until we have produced the desired quantity of data. - */ -/*----------------------------------------------------------------------------*/ -int zrtp_randstr(zrtp_global_t* zrtp, unsigned char *buffer, uint32_t length) -{ - //TODO: replace bg_aes_xxx() with our own block cipher component. - //TODO: Do the same with the hash functions. - - aes_encrypt_ctx aes_ctx; - MD_CTX rand_ctx2; - unsigned char md[MD_DIGEST_LENGTH]; - unsigned char ctr[AES_BLOCK_SIZE]; - unsigned char rdata[AES_BLOCK_SIZE]; - uint32_t generated = length; - - /* - * In few cases we need to gerate random value before initializing libzrtp engine. - * Following trick makes it possible. - */ - if (!zrtp->rand_initialized) { - if (zrtp_status_ok != zrtp_init_rng(zrtp)) { - return -1; - } - } - - zrtp_mutex_lock(zrtp->rng_protector); - - /* - * Add entropy from system state - * We will include whatever happens to be in the buffer, it can't hurt - */ - if ( 0 > zrtp_entropy_add(zrtp, buffer, length) ) { - zrtp_mutex_unlock(zrtp->rng_protector); - return -1; - } - - /* Copy the zrtp->rand_ctx and finalize it into the md buffer */ - rand_ctx2 = zrtp->rand_ctx; - MD_Final(&rand_ctx2, md); - - zrtp_mutex_unlock(zrtp->rng_protector); - - /* Key an AES context from this buffer */ - zrtp_bg_aes_encrypt_key256(md, &aes_ctx); - - /* Initialize counter, using excess from md if available */ - zrtp_memset (ctr, 0, sizeof(ctr)); - if (MD_DIGEST_LENGTH > (256/8)) { - uint32_t ctrbytes = MD_DIGEST_LENGTH - (256/8); - if (ctrbytes > AES_BLOCK_SIZE) - ctrbytes = AES_BLOCK_SIZE; - zrtp_memcpy(ctr + sizeof(ctr) - ctrbytes, md + (256/8), ctrbytes); - } - - /* Encrypt counter, copy to destination buffer, increment counter */ - while (length) - { - unsigned char *ctrptr; - uint32_t copied; - zrtp_bg_aes_encrypt(ctr, rdata, &aes_ctx); - copied = (sizeof(rdata) < length) ? sizeof(rdata) : length; - zrtp_memcpy (buffer, rdata, copied); - buffer += copied; - length -= copied; - - /* Increment counter */ - ctrptr = ctr + sizeof(ctr) - 1; - while (ctrptr >= ctr) { - if ((*ctrptr-- += 1) != 0) { - break; - } - } - } - - /* Done! Cleanup and exit */ - MD_Cleanup (&rand_ctx2); - MD_Cleanup (md); - MD_Cleanup (&aes_ctx); - MD_Cleanup (ctr); - MD_Cleanup (rdata); - - return generated; -} - -int zrtp_randstr2(unsigned char *buffer, uint32_t length) { - zrtp_global_t zrtp; - zrtp.rand_initialized = 0; - return zrtp_randstr(&zrtp, buffer, length); -} diff --git a/libs/libzrtp/src/zrtp_srtp_builtin.c b/libs/libzrtp/src/zrtp_srtp_builtin.c deleted file mode 100644 index 1d19e434bd..0000000000 --- a/libs/libzrtp/src/zrtp_srtp_builtin.c +++ /dev/null @@ -1,1469 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Vitaly Rozhkov - */ - -#include "zrtp.h" - -#define _ZTU_ "zrtp srtp" - -#if (!defined(ZRTP_USE_EXTERN_SRTP)) || (ZRTP_USE_EXTERN_SRTP == 0) - - -/* constants that are used for packet's parsing */ -#define octets_in_rtp_header 12 -#define uint32s_in_rtp_header 3 -#define octets_in_rtcp_header 8 -#define uint32s_in_rtcp_header 2 - - -/* - defines to make work with cipher component little bit easy -*/ -#define zrtp_cipher_init(self) \ - ( ((self)->cipher)->init(((self)->cipher)) ) - -#define zrtp_cipher_start(self, key, extra_data, mode) \ - ( ((self)->cipher)->start(((self)->cipher), (key), (extra_data), (mode)) ) - -#define zrtp_cipher_set_iv(self, iv) \ - ( ((self)->cipher)->set_iv( ((self)->cipher), ((self)->ctx), (iv)) ) - -#define zrtp_cipher_encrypt(self, buf, len) \ - ( ((self)->cipher)->encrypt( ((self)->cipher), ((self)->ctx), (buf), (len)) ) - -#define zrtp_cipher_decrypt(self, buf, len) \ - ( ((self)->cipher)->decrypt( ((self)->cipher), ((self)->ctx), (buf), (len)) ) - -#define zrtp_cipher_self_test(self) \ - ( ((self)->cipher)->self_test(((self)->cipher)) ) - -#define zrtp_cipher_stop(self) \ - ( ((self)->cipher)->stop(((self)->cipher), ((self)->ctx)) ) - -#define zrtp_cipher_free(self) \ - ( ((self)->cipher)->free(((self)->cipher)) ) - - - - -/*===========================================================================*/ -/* Replay protection serve functions set */ -/*===========================================================================*/ - - -/*! \brief Allocates and initializes replay protection context. Initialize - * mutexes and linked lists. - * \return - * - allocated replay protection context - * - NULL if error - */ -/*---------------------------------------------------------------------------*/ -zrtp_rp_ctx_t* rp_init() -{ - zrtp_rp_ctx_t *ctx = zrtp_sys_alloc(sizeof(zrtp_rp_ctx_t)); - if(NULL == ctx){ - return NULL; - } - - if(zrtp_status_ok != zrtp_mutex_init(&ctx->inc_sync)){ - zrtp_sys_free(ctx); - return NULL; - } - - if(zrtp_status_ok != zrtp_mutex_init(&ctx->out_sync)){ - zrtp_mutex_destroy(ctx->inc_sync); - zrtp_sys_free(ctx); - return NULL; - } - - init_mlist(&ctx->inc_head.mlist); - init_mlist(&ctx->out_head.mlist); - - return ctx; -} - - -/*! \brief Deinitializes and deallocates replay protection context. - * \param ctx - replay protection context - * \return - * - zrtp_status_ok - */ -/*---------------------------------------------------------------------------*/ -zrtp_status_t rp_destroy(zrtp_rp_ctx_t *ctx) -{ - mlist_t *pos, *n; - zrtp_rp_node_t *node = NULL; - - /*free all existing replay protection nodes in the incoming list*/ - zrtp_mutex_lock(ctx->inc_sync); - mlist_for_each_safe(pos, n, &ctx->inc_head.mlist){ - node = mlist_get_struct(zrtp_rp_node_t, mlist, pos); - mlist_del(&node->mlist); - zrtp_sys_free(node); - } - zrtp_mutex_unlock(ctx->inc_sync); - - zrtp_mutex_destroy(ctx->inc_sync); - - /*free all existing replay protection nodes in the outgoing list*/ - zrtp_mutex_lock(ctx->out_sync); - mlist_for_each_safe(pos, n, &ctx->out_head.mlist){ - node = mlist_get_struct(zrtp_rp_node_t, mlist, pos); - mlist_del(&node->mlist); - zrtp_sys_free(node); - } - zrtp_mutex_unlock(ctx->out_sync); - - zrtp_mutex_destroy(ctx->out_sync); - - zrtp_sys_free(ctx); - return zrtp_status_ok; -} - - -/*! \brief Finds replay protection node by given ssrc. Which linked list to search is - * determined by the direction param. - * \warning This function doesn't lock the linked list before search and is for internal usage. - * To find necessary replay protection node use get_rp_node() function. - * \param ctx - pointer to replay protection context - * \param direction - defines what list to search. It may have values: - * - RP_INCOMING_DIRECTION - * - RP_OUTGOING_DIRECTION - * \return - * - pointer to found replay protection node - * - NULL if node hasn't been found or if error - */ -/*---------------------------------------------------------------------------*/ -zrtp_rp_node_t *get_rp_node_non_lock( zrtp_rp_ctx_t *ctx, - uint8_t direction, - uint32_t ssrc) -{ - zrtp_rp_node_t *node = NULL; - mlist_t *pos; - mlist_t *head = NULL; - - switch(direction){ - case RP_INCOMING_DIRECTION: - head = &ctx->inc_head.mlist; - break; - case RP_OUTGOING_DIRECTION: - head = &ctx->out_head.mlist; - break; - default: - head = NULL; - break; - }; - - if(NULL != head){ - mlist_for_each(pos, head){ - node = mlist_get_struct(zrtp_rp_node_t, mlist, pos); - if(ssrc == node->ssrc){ - break; - }else{ - node = NULL; - } - } - } - - return node; -} - - -///*! \brief Finds replay protection node by given ssrc. Linked list to search is -// * determined by direction param. This function locks the linked list to -// * ensure exclusive access. -// * -// * \param ctx - pointer to replay protection context -// * \param direction - defines what list to search. It may have values: -// * - RP_INCOMING_DIRECTION -// * - RP_OUTGOING_DIRECTION -// * \param ssrc - value by which search will be made -// * \return -// * - pointer to found replay protection node -// * - NULL if node hasn't been found or if error -// */ -///*---------------------------------------------------------------------------*/ -//zrtp_rp_node_t *get_rp_node(zrtp_rp_ctx_t *ctx, uint8_t direction, uint32_t ssrc) -//{ -// zrtp_rp_node_t *node = NULL; -// zrtp_mutex_t *sync = NULL; -// -// switch(direction){ -// case RP_INCOMING_DIRECTION: -// sync = ctx->inc_sync; -// break; -// case RP_OUTGOING_DIRECTION: -// sync = ctx->out_sync; -// break; -// default: -// sync = NULL; -// break; -// }; -// -// if(NULL != sync){ -// zrtp_mutex_lock(sync); -// node = get_rp_node_non_lock(ctx, direction, ssrc); -// zrtp_mutex_unlock(sync); -// } -// -// return node; -//} - -/*! \brief Allocates new replay protection node for given direction and ssrc and adds it into - * appropriate linked list. - * \warning This function is for internal usage. Use add_rp_node() and add_rp_node_unique(). - * \param srtp_ctx - pointer to SRTP ctx related with created node. Used for removing node on SRTP session destruction. - * \param ctx - pointer to replay protection context - * \param direction - defines in which list newly created node will be inserted. It may have values: - * - RP_INCOMING_DIRECTION - * - RP_OUTGOING_DIRECTION - * \param ssrc - newly created replay protection node key value. - * \param is_unique - defines what should be returned when replay protection node - * with given direction and ssrc values already exists: - * - pointer to existing node if is_unique == 0 - * - NULL if is_unique == 1 - * \return - * - pointer to newly created replay protection node - * - pointer to existing replay protection node - * - NULL if is_unique == 1 and needed replay protection node already exists or if error - */ -/*---------------------------------------------------------------------------*/ -zrtp_rp_node_t *add_rp_node_ex( zrtp_srtp_ctx_t *srtp_ctx, - zrtp_rp_ctx_t *ctx, - uint8_t direction, - uint32_t ssrc, - uint8_t is_unique) -{ - zrtp_rp_node_t *node = NULL; - zrtp_mutex_t *sync = NULL; - mlist_t *head = NULL; - - switch(direction){ - case RP_INCOMING_DIRECTION: - sync = ctx->inc_sync; - head = &ctx->inc_head.mlist; - break; - case RP_OUTGOING_DIRECTION: - sync = ctx->out_sync; - head = &ctx->out_head.mlist; - break; - default: - sync = NULL; - head = NULL; - break; - }; - - if(NULL != sync && NULL != head){ - zrtp_mutex_lock(sync); - do{ - node = get_rp_node_non_lock(ctx, direction, ssrc); - - /*create new node if not found*/ - if(NULL == node){ - node = zrtp_sys_alloc(sizeof(zrtp_rp_node_t)); - if(NULL == node){ - break; - } - /*clean sliding window and on-top sequence number value*/ - zrtp_memset(node, 0, sizeof(zrtp_rp_node_t)); - node->ssrc = ssrc; - node->srtp_ctx = srtp_ctx; - mlist_add_tail(head, &node->mlist); -#if ZRTP_DEBUG_SRTP_KEYS - ZRTP_LOG(3,(_ZTU_,"\tadd %s rp node. ssrc[%u] srtp_ctx[0x%08x]", - direction==RP_INCOMING_DIRECTION?"incoming":"outgoing\n", - zrtp_ntoh32(node->ssrc), node->srtp_ctx)); -#endif - }else if(is_unique){ - // ???: why do we need unique mode at all? - node = NULL; - } - - }while(0); - zrtp_mutex_unlock(sync); - } - - return node; -} - -/*! \brief Allocates new replay protection node for given direction and ssrc and adds it into - * appropriate linked list. This function is based on add_rp_node_ex(). - * \param srtp_ctx - pointer to SRTP ctx related with created node. Used for removing node on SRTP session destruction. - * \param ctx - pointer to replay protection context - * \param direction - defines in which list newly created node will be inserted. It may have values: - * - RP_INCOMING_DIRECTION - * - RP_OUTGOING_DIRECTION - * \param ssrc - newly created replay protection node key value. - * \return - * - pointer to newly created replay protection node - * - pointer to existing replay protection node - * - NULL if error - */ -zrtp_rp_node_t *add_rp_node(zrtp_srtp_ctx_t *srtp_ctx, zrtp_rp_ctx_t *ctx, uint8_t direction, uint32_t ssrc){ - /*not-unique mode*/ - // ???: why do we need unique mode at all? - return add_rp_node_ex(srtp_ctx, ctx, direction, ssrc, 0); -} - -///*! \brief Allocates new replay protection node for given direction and ssrc and adds it into -// * appropriate linked list. This function is based on add_rp_node_ex(). -// * \param srtp_ctx - pointer to SRTP ctx related with created node. Used for removing node on SRTP session destruction. -// * \param ctx - pointer to replay protection context -// * \param direction - defines in which list newly created node will be inserted. It may have values: -// * - RP_INCOMING_DIRECTION -// * - RP_OUTGOING_DIRECTION -// * \param ssrc - newly created replay protection node key value. -// * \return -// * - pointer to newly created replay protection node -// * - NULL if error or if needed node already exists -// */ -//zrtp_rp_node_t *add_rp_node_unique(zrtp_srtp_ctx_t *srtp_ctx, zrtp_rp_ctx_t *ctx, uint8_t direction, uint32_t ssrc){ -// /*unique mode*/ -// return add_rp_node_ex(srtp_ctx, ctx, direction, ssrc, 1); -//} - -/*! \brief Removes replay protection node with given ssrc from linked list defined by direction value. - * \param ctx - pointer to replay protection context - * \param direction - defines from which list replay protection node will be removed. It may have values: - * - RP_INCOMING_DIRECTION - * - RP_OUTGOING_DIRECTION - * \param ssrc - key value of replay protection node to remove - * \return - * - zrtp_status_ok if replay protection node has been removed successfully - * - zrtp_status_fail if node hasn't been found - */ -/*---------------------------------------------------------------------------*/ -zrtp_status_t remove_rp_node(zrtp_rp_ctx_t *ctx, uint8_t direction, uint32_t ssrc){ - zrtp_rp_node_t *node = NULL; - zrtp_mutex_t *sync = NULL; - zrtp_status_t res = zrtp_status_fail; - - switch(direction){ - case RP_INCOMING_DIRECTION: - sync = ctx->inc_sync; - break; - case RP_OUTGOING_DIRECTION: - sync = ctx->out_sync; - break; - default: - sync = NULL; - break; - }; - - if(NULL != sync){ - zrtp_mutex_lock(sync); - node = get_rp_node_non_lock(ctx, direction, ssrc); - if(NULL != node){ - mlist_del(&node->mlist); - zrtp_sys_free(node); - res = zrtp_status_ok; - } - zrtp_mutex_unlock(sync); - } - - return res; -} - - -zrtp_status_t remove_rp_nodes_by_srtp_ctx(zrtp_srtp_ctx_t *srtp_ctx, zrtp_rp_ctx_t *ctx){ - zrtp_status_t res = zrtp_status_ok; - zrtp_rp_node_t *node = NULL; - mlist_t *pos, *n; - - if((NULL == srtp_ctx) || (NULL == ctx)){ - return zrtp_status_bad_param; - } - - /* Walk over incoming nodes list */ - zrtp_mutex_lock(ctx->inc_sync); - mlist_for_each_safe(pos, n, &ctx->inc_head.mlist){ - node = mlist_get_struct(zrtp_rp_node_t, mlist, pos); - if((NULL != node->srtp_ctx) && (node->srtp_ctx == srtp_ctx)){ -#if ZRTP_DEBUG_SRTP_KEYS - ZRTP_LOG(3,(_ZTU_,"\tremove incoming rp node. ssrc[%u] srtp_ctx[0x%08x]\n", - zrtp_ntoh32(node->ssrc), node->srtp_ctx)); -#endif - mlist_del(&node->mlist); - zrtp_sys_free(node); - } - } - zrtp_mutex_unlock(ctx->inc_sync); - - /* Walk over outgoing nodes list */ - zrtp_mutex_lock(ctx->out_sync); - mlist_for_each_safe(pos, n, &ctx->out_head.mlist){ - node = mlist_get_struct(zrtp_rp_node_t, mlist, pos); - if((NULL != node->srtp_ctx) && (node->srtp_ctx == srtp_ctx)){ -#if ZRTP_DEBUG_SRTP_KEYS - ZRTP_LOG(3,(_ZTU_,"\tremove outgoing rp node. ssrc[%u] srtp_ctx[0x%08x]\n", - zrtp_ntoh32(node->ssrc), node->srtp_ctx)); -#endif - mlist_del(&node->mlist); - zrtp_sys_free(node); - } - } - zrtp_mutex_unlock(ctx->out_sync); - - return res; -} - - -/*===========================================================================*/ -/* Replay protection mechanism functions set */ -/*===========================================================================*/ - - -/*! \brief This function is used for RTCP replay protection to generate next sequence number - * of outgoing RTCP packet. If the sequence number is too large it returns zrtp_status_key_expired. - * See RFC3711 for more details. - * \param srtp_rp - pointer to replay protection engine data - * \return - * - zrtp_status_key_expired if next sequence number is too large - * - zrtp_status_ok otherwise - */ -zrtp_status_t zrtp_srtp_rp_increment(zrtp_srtp_rp_t *srtp_rp){ - - if(srtp_rp->seq++ > 0x7fffffff){ - return zrtp_status_key_expired; - }else{ - return zrtp_status_ok; - } -} - -/*! \brief Returns current on-top sequence number. This function is used for RTCP - * replay protection. - * \param srtp_rp - pointer to replay protection engine data - * \return current on-top sequence number - */ -uint32_t zrtp_srtp_rp_get_value(zrtp_srtp_rp_t *srtp_rp){ - return srtp_rp->seq; -} - - -/*! \brief This function checks packet sequence number position relative to - * sliding window current position and makes the decision to accept or discard packet. - * \param srtp_rp - pointer to replay protection engine data - * \param packet - pointer to packet structure - * \return - * - zrtp_status_ok if packet must be accepted - * - zrtp_status_old_pkt if packet sequence number is lower than lowest sequence number - * which can be into the sliding window at the current time. In this case packet must be discarded. - * - zrtp_status_fail if packet must be discarded - */ -/*---------------------------------------------------------------------------*/ -zrtp_status_t zrtp_srtp_rp_check(zrtp_srtp_rp_t *srtp_rp, zrtp_rtp_info_t *packet) -{ - int32_t delta = packet->seq - srtp_rp->seq; - if(delta > 0){ - /*if delta is positive, it's good*/ - return zrtp_status_ok; - }else if(ZRTP_SRTP_WINDOW_WIDTH-1 + delta < 0){ - /*if delta is lower than the bitmask, it's bad*/ - return zrtp_status_old_pkt; - }else{ - if(1 == zrtp_bitmap_get_bit(srtp_rp->window, ZRTP_SRTP_WINDOW_WIDTH-1 + delta)){ - /*delta is within the window, so check the bitmask*/ - return zrtp_status_fail; - } - } - return zrtp_status_ok; -} - -/*! \brief This function updates the sliding window state by setting appropriate bit and - * shifting the sliding window if needed. - * \param srtp_rp - pointer to replay protection engine data - * \param packet - pointer to packet structure - * \return - * - zrtp_status_ok - */ -/*---------------------------------------------------------------------------*/ -zrtp_status_t zrtp_srtp_rp_add(zrtp_srtp_rp_t *srtp_rp, zrtp_rtp_info_t *packet) -{ - int32_t delta = packet->seq - srtp_rp->seq; - if(delta > 0){ - /* packet sequence nubmer is larger than current on-top sequence number. - shift the window, set top bit and update on-top sequence number value */ - srtp_rp->seq = packet->seq; - zrtp_bitmap_left_shift(srtp_rp->window, ZRTP_SRTP_WINDOW_WIDTH_BYTES, delta); - zrtp_bitmap_set_bit(srtp_rp->window, ZRTP_SRTP_WINDOW_WIDTH-1); - }else - - /* commented by book, 19.07.07: - we need not consider case when delta == 0 - if(0 == delta){ - zrtp_bitmap_set_bit(srtp_rp->window, ZRTP_SRTP_WINDOW_WIDTH-1); - }else*/ - - { - /* - packet sequence number is into the sliding window. - set appropriate bit - */ - zrtp_bitmap_set_bit(srtp_rp->window, ZRTP_SRTP_WINDOW_WIDTH-1 + delta); - } - - return zrtp_status_ok; -} - - -/*===========================================================================*/ -/* Key derivation mechanism functions set */ -/*===========================================================================*/ - - -/*! \brief This function allocates key derivation context and initializes it with - * given master key, master salt and cipher. - * \param cipher - pointer to cipher that is used for key derivation - * \param key - pointer to master key - * \param salt - pointer to master salt - * \return - * - allocated key derivation context - * - NULL if error - */ -/*---------------------------------------------------------------------------*/ -zrtp_dk_ctx *zrtp_dk_init( zrtp_cipher_t *cipher, - zrtp_stringn_t *key, - zrtp_stringn_t *salt) -{ - zrtp_dk_ctx *ctx = NULL; -#if ZRTP_DEBUG_SRTP_KEYS - ZRTP_LOG(3,(_ZTU_,"\tzrtp_dk_init():\n")); - ZRTP_LOG(3,(_ZTU_,"\tcipher ID[%i]\n", cipher->base.id)); -#endif - do{ - ctx = zrtp_sys_alloc(sizeof(zrtp_dk_ctx)); - if(NULL == ctx){ - break; - } - - ctx->ctx = cipher->start(cipher, key->buffer, salt->buffer, ZRTP_CIPHER_MODE_CTR); - if(NULL == ctx->ctx){ - zrtp_sys_free(ctx); - ctx = NULL; - break; - } - - ctx->cipher = cipher; - }while(0); - - return ctx; -} - -/*! \brief This function derives key for different purposes like SRTP encryption, - * SRTP message authentication, etc. See RFC3711, "4.3. Key Derivation" for more details. - * \warning This function may change length field value in the result_key variable when - * length is larger than max_length field value. - * \param ctx - pointer to key derivation context - * \param label - defines purpose of key to derive - * \param result_key - out parameter. It contains derived key on success. - * \return - * - actually derived key length - * - -1 if error - */ -/*---------------------------------------------------------------------------*/ -uint16_t zrtp_derive_key( zrtp_dk_ctx *ctx, - zrtp_srtp_prf_label label, - zrtp_stringn_t *result_key ) -{ - zrtp_v128_t nonce; - uint16_t length; -#if ZRTP_DEBUG_SRTP_KEYS - char buffer[256]; - ZRTP_LOG(3,(_ZTU_,"\tzrtp_derive_key():\n")); -#endif - - /* set eigth octet of nonce to