Compare commits

...

112 Commits

Author SHA1 Message Date
Andrey Volk d49d22ff06 [Core] DTMF: Avoid division by zero on low actual_samples_per_second 2019-12-20 00:14:17 +04:00
Andrey Volk 0c90ab01e5
Merge pull request #182 from signalwire/core_fixes
[Core] Fix hard coded dtmf durations based on 8k, fix short-circuit in write timestamp calc
2019-12-19 22:55:03 +04:00
Andrey Volk efc10bc190
Merge pull request #174 from signalwire/log_leaks_on_shutdown
[Core] Wait for all EVENT_DISPATCH_QUEUE_THREADS before killing the logging which leaks otherwise.
2019-12-17 21:07:07 +04:00
Andrey Volk 52949efc28 [Core] Wait for all EVENT_DISPATCH_QUEUE_THREADS before killing the logging which leaks otherwise. 2019-12-17 21:03:20 +04:00
Anthony Minessale 47c5c8f3e8 [Core] Fix short-circuit in write timestamp calc 2019-12-17 00:37:07 +04:00
Anthony Minessale 7ce50c8bd0 [Core] Fix hard coded dtmf durations based on 8k 2019-12-17 00:36:23 +04:00
Andrey Volk b93eea73ef
Merge pull request #166 from signalwire/fixfiletest
[Unit-tests] Fix switch_core_file test.
2019-12-05 23:55:04 +04:00
Andrey Volk bae7c3eae0 [Unit-tests] Fix switch_core_file test. 2019-12-05 23:44:33 +04:00
Dragos Oancea b124b607d7 [Core] Add PRE_CLOSED flag on file handle, add unit test. 2019-12-05 21:55:46 +04:00
Andrey Volk 5274dd1f9c
Merge pull request #164 from lazedo/kazoo-create_ei_cnode
[mod_kazoo] use globals hostname to create nodename in create_ei_cnode
2019-12-05 00:43:16 +04:00
Andrey Volk 329edd0133
Merge pull request #165 from signalwire/crashonload
[Core] Fix wrong sqldb initialization order causing crash on load.
2019-12-04 19:46:30 +04:00
Andrey Volk a124937f0c [Core] Fix wrong sqldb initialization order causing crash on load. 2019-12-04 19:32:46 +04:00
lazedo ac77de715b [mod_kazoo] use globals hostname to create nodename in create_ei_cnode 2019-12-04 05:58:08 +00:00
Andrey Volk 1435577eaf
Merge pull request #162 from lazedo/kazoo-hostname-2
[mod_kazoo] add kz_set_hostname declaration
2019-12-04 03:35:59 +04:00
lazedo 731b0eb8fd [mod_kazoo] add kz_set_hostname declaration 2019-12-03 23:24:47 +00:00
Andrey Volk 4de6afc9d6
Merge pull request #160 from lazedo/kazoo-hostname
[mod_kazoo] missing call to kz_set_hostname
2019-12-04 02:19:42 +04:00
lazedo 1afad3413b [mod_kazoo] missing call to kz_set_hostname 2019-12-03 21:45:15 +00:00
Andrey Volk b337e77258 [Unit-tests] Fix leaks in mod_test and in switch_core_codec, switch_vpx, switch_xml, switch_ivr_play_say tests. 2019-11-27 21:38:19 +04:00
Andrey Volk 4c434aef1f
[Unit-tests] Fix test framework by telling sqldb to manage handles so they don't leak and are destroyed on shutdown. 2019-11-26 22:54:17 +04:00
Andrey Volk 2865603ad2 [Unit-tests] Fix xml error not finding freeswitch.xml on FST_MINCORE_BEGIN 2019-11-26 01:54:43 +04:00
Ítalo Rossi 3de3ec3b1a [mod_callcenter] Adding SAF_SUPPORT_NOMEDIA to callcenter_track since we don't need media up for it. Also, a small fix to make it compile on OSX. 2019-11-26 01:33:12 +04:00
Andrey Volk 5836b9652b [Unit-tests] Fix test framework leaking on successful checks under setup or teardown mode. Failed checks in these modes are noted and then freed, but not when passed. 2019-11-26 01:05:03 +04:00
Andrey Volk ff65104c03
Merge pull request #134 from signalwire/drone
Add unit-tests automation to Drone CI
2019-11-25 23:54:14 +04:00
Andrey Volk 0bd676db32 Add unit-tests automation to Drone CI 2019-11-22 00:15:40 +04:00
Andrey Volk a4f0b2f2a0 [mod_test] Fix OSX build 2019-11-22 00:09:14 +04:00
Seven Du 724868fa08 [core] fix test case 2019-11-21 22:06:14 +04:00
Seven Du 254fda292a [core] fix shutdown crash when core running with MINIMAL flag 2019-11-21 22:05:43 +04:00
Andrey Volk 66aa064588
Merge pull request #91 from lazedo/event-channel-debug
[core] allow event-channel debugging & single delivery
2019-11-15 23:37:36 +04:00
Andrey Volk f8dc87bd18 [mod_event_socket] Fix "Listener session is null" problem - regression from previous commit to the mod. 2019-11-13 19:28:25 +04:00
Piotr Gregor b0f09fcff2 [mod_avmd] Unlock and close session if adding a media bug fails 2019-11-12 21:29:29 +04:00
Dragos Oancea a2b46bcf10 [core] Do not try to close a file handle if it's not SWITCH_FILE_OPEN, return SWITCH_STATUS_FALSE instead 2019-11-12 03:18:23 +04:00
Andrey Volk a288c3d969
Merge pull request #117 from lazedo/kazoo-ctx
[mod_kazoo] recurse context runtime vars
2019-11-12 01:25:14 +04:00
Dragos Oancea 60746cc07c [mod_tts_commandline, mod_sndfile] fix crash on file not found 2019-11-11 23:02:21 +04:00
Vallimamod Abdullah 7f63483138 [mod_event_socket] Add null pointer checks on listener session and socket 2019-11-11 22:58:18 +04:00
lazedo 3c6d47c293 [mod_kazoo] recurse context runtime vars 2019-11-11 18:09:26 +00:00
Areski Belaid 647ed310e5 [mod_callcenter] Unreserve callcenter events when config errors loading 2019-11-11 20:23:20 +04:00
Andrey Volk 7861ec937e
Merge pull request #64 from cdosoftei/amqp-reconnect
[mod_amqp] open logging and produced connections from within their threads
2019-11-11 20:11:59 +04:00
Andrey Volk 55afe220d3
Merge pull request #71 from cdosoftei/amqp-queue-properties
[mod_amqp] configurable commands queue properties
2019-11-11 20:11:30 +04:00
Andrey Volk 00cbf0ea37
Merge pull request #112 from lazedo/kazoo-cfw
[mod_kazoo] add kz-endpoint-runtime-context
2019-11-08 18:10:32 +04:00
lazedo 998e322f46 [mod_kazoo] add kz-endpoint-runtime-context 2019-11-07 22:42:28 +00:00
Andrey Volk aa2df4f3f8
Merge pull request #90 from lazedo/k-header
[mod_sofia] add K- to prefixes that create a sip_h_ variable
2019-10-31 20:50:05 +04:00
Andrey Volk 5705290f8d
Merge pull request #89 from lazedo/sofia-auth-query
[mod_sofia] add existing variables when locating user
2019-10-31 20:33:55 +04:00
Andrey Volk 2ace196aa6
Merge pull request #86 from lazedo/kazoo-updates
[mod_kazoo] several fixes & code cleanup
2019-10-31 20:30:39 +04:00
lazedo 506bcd280d [core] allow event-channel debugging & single delivery 2019-10-31 12:41:47 +00:00
lazedo b4373c6666 [mod_sofia] add K- to prefixes that create a sip_h_ variable
used by sip tracing tools and not to confuse with application (X-) or (P-)
2019-10-31 12:27:21 +00:00
lazedo f77484b96d [mod_sofia] add existing variables when locating user 2019-10-31 12:20:33 +00:00
lazedo 8d2174d707 [mod_kazoo] several fixes & code cleanup 2019-10-31 11:06:16 +00:00
Andrey Volk c76a8c5458 swigall 2019-10-30 17:25:47 +00:00
Chris Rienzo 1442186cee [core] Update switch_ivr_bridge_bleg to skip audio bridge during transfer 2019-10-30 21:08:03 +04:00
Seven Du 8aafff281b [Core] Make switch_ivr_orig_and_bridge function return status and a cause. 2019-10-30 21:07:54 +04:00
Dragos Oancea 45219aef6f [mod_sndfile] don't force channels and sample rate with .raw extension 2019-10-29 21:47:22 +04:00
Andrey Volk 31d6676706
Merge pull request #72 from andywolk/verto
[mod_verto] Ignore not just zero but negative frame size as well.
2019-10-25 02:10:27 +04:00
Andrey Volk 0e3d8c00ba
Merge pull request #73 from signalwire/osx-catalina-build
[build] fix libvpx osx build detection on newer compilers and osx versions so we use sse extensions on newer versions
2019-10-24 00:37:07 +04:00
Mike Jerris 07c6ad5e1a [build] fix libvpx osx build detection on newer compilers and osx versions so we use sse extensions on newer versions 2019-10-23 13:54:09 -06:00
Andrey Volk 311a20af63 [mod_verto] Ignore not just zero but negative frame size as well. 2019-10-23 23:03:18 +04:00
Andrey Volk 284d67738a
Merge pull request #70 from signalwire/osx-catalina-build
[build] OSX Catalina configure does not support --extra-cflags and fix broken compiler option test for -Wno-extended-offsetof that was used to fix older osx clang issue
2019-10-23 03:18:54 +04:00
cdosoftei 5244a64d4e
[mod_amqp] configurable commands queue properties 2019-10-22 15:22:00 -04:00
Mike Jerris 6a900a90a3 [build] OSX Catalina configure does not support --extra-cflags and fix broken compiler option test for -Wno-extended-offsetof that was used to fix older osx clang issue 2019-10-22 10:24:14 -06:00
cdosoftei 5f628c0090
[mod_amqp] open logging and produced connections from within their respective threads 2019-10-17 15:38:38 -04:00
Andrey Volk 7fdf8584e4
Merge pull request #61 from cdosoftei/amqp-heartbeat
[mod_amqp] Properly parse out heartbeat parameter
2019-10-15 20:44:53 +04:00
cdosoftei 7e91927278
[mod_amqp] Properly parse out heartbeat parameter 2019-10-15 12:37:47 -04:00
Pelle Mattsson 77cd699000 [Docs] Rename Docker README to README.md, so github recognizes that it as a Markdown file and update the git url in it 2019-10-13 21:46:36 +04:00
Ciprian 696814cb26 [Core] Disable msrp by default, only enable when listen-port or listen-ssl-port config params configured in msrp.conf 2019-10-13 21:27:58 +04:00
Andrey Volk cec8f3b1ca
Merge pull request #56 from lazedo/patch-1
[mod_kazoo] fix xml leak when event-filter is not available
2019-10-13 20:29:34 +04:00
lazedo 318e5d0d6d
[mod_kazoo] fix xml leak when event-filter is not available 2019-10-13 12:21:22 +01:00
Andrey Volk f6c10f8622
Merge pull request #28 from signalwire/fixup-stash-url
[build/docs] point all old stash references in docs and makefiles to new github repository
2019-10-13 01:38:02 +04:00
Andrey Volk 93691c60ce
Merge pull request #32 from cdosoftei/php7-esl
ESL adjustments for PHP 7+
2019-10-13 00:51:31 +04:00
Andrey Volk 8a80e3ad0c
Merge pull request #44 from micmac1/master-fs_cli_typo
[fs_cli] Fix typo, resolves garbled screen
2019-10-13 00:49:08 +04:00
Andrey Volk db64a08b02
Merge pull request #45 from micmac1/master-memleak-multicast
[mod_event_multicast] Fix memory leak
2019-10-13 00:45:59 +04:00
Andrey Volk c96479bfd6
Merge pull request #50 from bircoph/master
Add support for the Elbrus architecture
2019-10-13 00:41:51 +04:00
Sebastian Kemper 8919d581fe [fs_cli] Fix typo, resolves garbled screen
Related to FS-11309.

Commit bc3e1c9e7d introduced a typo that
results in EL_REFRESH never being used, even if available. This can
cause the screen to garble.

This fixes the typo.

Signed-off-by: Sebastian Kemper <sebastian_ml@gmx.net>
2019-10-12 21:46:09 +02:00
Sebastian Kemper fc41980f19 [mod_event_multicast] Fix memory leak
Taken from FS-11193:

In "event_handler()" function, when encrypting data using openssl 1.1.0,
the context ctx is allocated by "EVP_CIPHER_CTX_new()", then data is
encrypted, and at the end, EVP_CIPHER_CTX_cleanup is called. This
function resets the context (the function itself is deprecated, and has
been renamed to "EVP_CIPHER_CTX_reset) so that it can be used again. The
correct call would be to "EVP_CIPHER_CTX_free()", which frees the
memory. The code for openssl 1.0 is OK, since the "ctx" struct is kept
in stack.  The same thing happens during decryption. "ctx" is allocated,
but never freed.

Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>
Signed-off-by: Sebastian Kemper <sebastian_ml@gmx.net>
2019-10-12 21:43:14 +02:00
Andrey Volk ea2c31f0c8
Merge pull request #48 from crienzo/fix-grammar-in-mod_sofia
[mod_sofia] Fix some incorrect word contractions.
2019-10-10 20:34:21 +04:00
Chris Rienzo 9d4f480335 [mod_sofia] Fix some incorrect word contractions. 2019-10-10 09:41:53 -04:00
Andrew Savchenko c4ec06dc23
Add support for the Elbrus architecture
The Elbrus architecture (aka E2K, aka 2000) is LE.

Signed-off-by: Andrew Savchenko <bircoph@altlinux.org>
2019-10-10 16:21:31 +03:00
cdosoftei d60193c1ae
ESL adjustments for PHP 7+ 2019-10-02 14:05:58 -04:00
Andrey Volk 6f8d65c348
Merge pull request #30 from mitchcapper/bug_29_slack_join_link_broken_fix_pr
Updated slack community link to the current (working) join link as old one expired. Closes #29
2019-10-02 01:49:04 +04:00
Mitch Capper 1b04ffe535 Updated slack community link to the current (working) join link as old one expired. Closes #29 2019-10-01 14:25:31 -07:00
Mike Jerris dbec998873 [build/docs] point all old stash references in docs and makefiles to new github repository 2019-10-01 10:02:20 -06:00
Andrey Volk 34075172eb
Merge pull request #27 from andywolk/mod_av_crash
[mod_av] Fix crash on `av show codecs` and `av show formats`.
2019-10-01 19:37:12 +04:00
Andrey Volk 4a60911228
Merge pull request #26 from dvillaume/patch-1
[mod_say_fr] Fix "10" not playing in French.
2019-10-01 19:18:14 +04:00
David VILLAUME 9de281133a [mod_say_fr] Fix "10" not playing in French. 2019-10-01 17:07:29 +02:00
Andrey Volk 65c4ca072d [mod_av] Fix crash on `av show codecs` and `av show formats`. 2019-10-01 13:02:39 +04:00
Anthony Minessale 285cb60926
Merge pull request #20 from signalwire/readme4
Add initial README.md
2019-09-26 18:43:05 -05:00
Andrey Volk 1711450e98 Add initial README.md 2019-09-27 02:29:51 +04:00
Andrey Volk 15ad4c23e2 Merge pull request #1803 in FS/freeswitch from bugfix/FS-12025-freeswitch-crashes-on-reloadxml-when-spandsp-tone-detection-is-running to master
* commit 'd45e9df88349a26a18426fd98409845316d131fb':
  FS-12025: [mod_spandsp] FreeSWITCH crashes on reloadxml when spandsp tone detection is running.
2019-09-17 11:03:50 -05:00
Andrey Volk 5123b00426 Merge pull request #1746 in FS/freeswitch from ~SAFAROV/freeswitch2:FS-11917 to master
* commit '6704d3aabeacdfa9a652f700379b072b6166f5a0':
  FS-11917: [mod_event_socket] Added error logging if cannot parse IP address
2019-09-17 03:32:08 -05:00
Sergey Safarov 6704d3aabe
FS-11917: [mod_event_socket] Added error logging if cannot parse IP address 2019-09-17 07:40:45 +03:00
Andrey Volk 75cfacf4c2 Merge pull request #1813 in FS/freeswitch from bugfix/FS-12042-sofia-sip-fix-leaks-in-stun-and-a-typo-in-sresolv to master
* commit '583bf0441d8d6730d4570cad9cc6f93d3c955394':
  FS-12042: [sofia-sip] Fix typo in sresolv.
2019-09-09 13:27:39 -05:00
Andrey Volk 583bf0441d FS-12042: [sofia-sip] Fix typo in sresolv. 2019-09-09 22:12:10 +04:00
Andrey Volk 6f62194af7 Merge pull request #1812 in FS/freeswitch from bugfix/FS-12041-core-fix-memory-leak-on-msrp-shutdown to master
* commit '70831a7140343cd4bf9ae76337458a0644dde103':
  FS-12041: [Core] Fix memory leak on msrp shutdown
2019-09-06 18:37:04 -05:00
Andrey Volk 70831a7140 FS-12041: [Core] Fix memory leak on msrp shutdown 2019-09-07 03:10:20 +04:00
Andrey Volk fc925a273b Merge pull request #1809 in FS/freeswitch from sofia-leak to master
* commit '20a893fd0683de64353ee2c111aa9c61a867886d':
  FS-12038: [mod_sofia, core] Fix potential leak and race in chat_hash, add switch_core_hash_insert_auto_free().
2019-09-06 11:28:31 -05:00
Andrey Volk 20a893fd06 FS-12038: [mod_sofia, core] Fix potential leak and race in chat_hash, add switch_core_hash_insert_auto_free(). 2019-09-06 20:22:20 +04:00
Christopher Rienzo 8880c4f469 Merge pull request #1811 in FS/freeswitch from bugfix/FS-12040-mod_sofia-fix-potential-leak-if-realloc-fails to master
* commit '7ee53a6ec1753204d5f17e1f7d2b9429b8ab1342':
  FS-12040: [mod_sofia] Fix potential leak if realloc fails.
2019-09-06 09:37:37 -05:00
Andrey Volk 7ee53a6ec1 FS-12040: [mod_sofia] Fix potential leak if realloc fails. 2019-09-06 18:01:55 +04:00
Christopher Rienzo 468e2e06d1 Merge pull request #1810 in FS/freeswitch from bugfix/FS-12039-core-fix-memory-leak-on-ssl-shutdown to master
* commit 'f00d285b5eef6c697ba8bc3ecfde82fc7c2dba65':
  FS-12039: [Core] Fix memory leak on ssl shutdown.
2019-09-06 08:54:54 -05:00
Andrey Volk f00d285b5e FS-12039: [Core] Fix memory leak on ssl shutdown. 2019-09-06 17:50:16 +04:00
Andrey Volk d0c6b30c15 Merge pull request #1244 in FS/freeswitch from ~DRAGOS_OANCEA_NX/freeswitch-dragos-nx:fix/FS-10191/disable_video_floor_event_for_audio to master
* commit '4d4afbeb5d9a6aa2d8fced093aeba9b27c1e5623':
  FS-10191: don't send "video-floor-change" event for audio-only conference
2019-09-05 12:24:23 -05:00
Andrey Volk d45e9df883 FS-12025: [mod_spandsp] FreeSWITCH crashes on reloadxml when spandsp tone detection is running. 2019-08-30 02:20:18 +04:00
Dragos Oancea 4d4afbeb5d FS-10191: don't send "video-floor-change" event for audio-only conference 2019-08-28 17:54:24 +01:00
Andrey Volk eee07bd95f Merge pull request #1802 in FS/freeswitch from ~ITALOROSSI/freeswitch:feature/FS-12022 to master
* commit '759783532dc7c34b4f8ab27e63438a350bfbc256':
  FS-12022: [mod_event_socket] Add Job-Owner-UUID with session uuid when using bgapi inside outbound socket
2019-08-27 12:30:43 -05:00
Andrey Volk 1583740133 Merge pull request #1805 in FS/freeswitch from bugfix/FS-11995-err-mod_fifo.c-4398-odbc-is-not-available to master
* commit 'fd2f12cf94c4445843a299ef8b87ce2d15d77072':
  FS-11995: [mod_fifo, mod_directory] Fix database availability check.
2019-08-27 10:06:12 -05:00
Christopher Rienzo 6a6b8ac350 Merge pull request #1804 in FS/freeswitch from ~DRAGOS_OANCEA/freeswitch-dragos:FS-12026 to master
* commit 'aaacaa19deb6ef764acdfabefb625f3ddc4e2324':
  FS-12026 [mod_http_cache] fix multichannel file download and play
  FS-12026 [mod_httapi] fix multichannel file download and play
2019-08-27 08:27:05 -05:00
Dragos Oancea aaacaa19de FS-12026 [mod_http_cache] fix multichannel file download and play 2019-08-27 11:30:05 +00:00
Dragos Oancea 44199e91b5 FS-12026 [mod_httapi] fix multichannel file download and play 2019-08-27 11:28:51 +00:00
Andrey Volk e1c6786a50 Merge pull request #1793 in FS/freeswitch from ~INFOMIND/freeswitch:bugfix/FS-11993-fix-gcc-errors-when-building-on-rpi4-buster to master
* commit '7a4a988dcbc39c89b5cdfaacc514cfb1c4748197':
  FS-11993 [mod_http_cache][mod_smpp] fix gcc errors when building on rpi4 buster (strncpy to snprintf)
2019-08-26 17:09:12 -05:00
Andrey Volk fd2f12cf94 FS-11995: [mod_fifo, mod_directory] Fix database availability check. 2019-08-27 01:13:10 +04:00
David Grant 7a4a988dcb FS-11993 [mod_http_cache][mod_smpp] fix gcc errors when building on rpi4 buster (strncpy to snprintf)
FS-11993 [mod_http_cache][mod_smpp] fix gcc errors when building on rpi4 buster (strncpy to snprintf)
2019-08-24 22:48:59 -05:00
Ítalo Rossi 759783532d FS-12022: [mod_event_socket] Add Job-Owner-UUID with session uuid when using bgapi inside outbound socket 2019-08-22 16:35:34 -03:00
Mike Jerris 8c1697b9b2 FS-12021: [mod_signalwire] Remove ascii art on mod_signalwire token line 2019-08-22 10:40:55 -06:00
Andrey Volk b8e14cb9b5 version bump 2019-08-20 23:37:49 +04:00
114 changed files with 2879 additions and 2070 deletions

47
.drone.yml Normal file
View File

@ -0,0 +1,47 @@
---
kind: pipeline
name: unit-tests
steps:
- name: run-tests
image: signalwire/freeswitch-public-base
pull: true
commands:
- ./bootstrap.sh -j
- echo "applications/mod_test" >> modules.conf
- ./configure
- echo "#!/bin/bash\nmake -j`nproc --all` |& tee ./unit-tests-build-result.txt\nexitstatus=\${PIPESTATUS[0]}\necho \$exitstatus > ./build-status.txt\nmake install\n" > build.sh
- chmod +x build.sh
- ./build.sh
- cd tests/unit
- ./run-tests.sh
- mkdir logs && (mv log_run-tests_*.html logs || true)
- echo 0 > run-tests-status.txt
- ./collect-test-logs.sh && exit 0 || echo 'Some tests failed'
- echo 1 > run-tests-status.txt
- cd logs && ls -la
- name: notify
image: signalwire/unit-tests-notify
pull: true
environment:
GITHUB_CI_APP_PEM:
from_secret: github_ci_app_pem
SSH_KEY:
from_secret: ssh_key
SLACK_WEBHOOK_URL:
from_secret: slack_webhook_url
commands:
- /root/notify.sh
trigger:
branch:
- master
event:
- pull_request
- push
---
kind: signature
hmac: a34718dd1e2b9468a845962219ff05cac0c922ddf90d885af557a937a9e412e0
...

View File

@ -586,7 +586,7 @@ libs/libzrtp/libzrtp.a:
cd libs/libzrtp && $(MAKE)
libs/libvpx/Makefile: libs/libvpx/.update
cd libs/libvpx && CC="$(CC)" CXX="$(CXX)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" ./configure --enable-pic --disable-docs --disable-examples --disable-install-bins --disable-install-srcs --disable-unit-tests --size-limit=16384x16384 --extra-cflags="$(VISIBILITY_FLAG)"
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
libs/libvpx/libvpx.a: libs/libvpx/Makefile libs/libvpx/.update
@cd libs/libvpx && $(MAKE)
@ -684,7 +684,7 @@ is-scm:
echo ; echo ; \
echo "*****************************************************************************************************" ; \
echo "You cannot update a release tarball without a git tree. Please clone FreeSWITCH as so: " ; \
echo " git clone https://freeswitch.org/stash/scm/fs/freeswitch.git " ; \
echo " git clone https://github.com/signalwire/freeswitch.git " ; \
echo "*****************************************************************************************************" ; \
echo ; echo ; \
exit 1; \

63
README.md Normal file
View File

@ -0,0 +1,63 @@
# 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) [<b>Recommended</b>]
* [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!**

View File

@ -29,7 +29,7 @@ freeswitch.git/configure: freeswitch.git/bootstrap.sh
cd freeswitch.git && sh bootstrap.sh
freeswitch.git/bootstrap.sh: has-git
test -d freeswitch.git || git clone https://freeswitch.org/stash/scm/fs/freeswitch.git freeswitch.git
test -d freeswitch.git || git clone https://github.com/signalwire/freeswitch.git freeswitch.git
install: freeswitch
cd freeswitch.git && make install cd-sounds-install cd-moh-install

View File

@ -19,7 +19,7 @@ freeswitch.git/configure: freeswitch.git/bootstrap.sh
cd freeswitch.git && sh bootstrap.sh
freeswitch.git/bootstrap.sh: has-git
test -d freeswitch.git || git clone https://freeswitch.org/stash/scm/fs/freeswitch.git freeswitch.git
test -d freeswitch.git || git clone https://github.com/signalwire/freeswitch.git freeswitch.git
rpmforge:
(which rpm && rpm -i http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm) || true

View File

@ -24,7 +24,7 @@ freeswitch.git/configure: freeswitch.git/bootstrap.sh
cd freeswitch.git && AUTOCONF_VERSION=2.69 AUTOMAKE_VERSION=1.14 LIBTOOL=/usr/local/bin/libtoolize sh bootstrap.sh
freeswitch.git/bootstrap.sh: has-git
test -d freeswitch.git || git clone https://freeswitch.org/stash/scm/fs/freeswitch.git freeswitch.git
test -d freeswitch.git || git clone https://github.com/signalwire/freeswitch.git freeswitch.git
install:
cd freeswitch.git && AUTOCONF_VERSION=2.69 AUTOMAKE_VERSION=1.14 LIBTOOL=/usr/local/bin/libtoolize gmake install cd-sounds-install cd-moh-install

View File

@ -31,7 +31,7 @@ freeswitch.git/configure: freeswitch.git/bootstrap.sh
cd freeswitch.git && sh bootstrap.sh
freeswitch.git/bootstrap.sh: has-git
test -d freeswitch.git || git clone https://freeswitch.org/stash/scm/fs/freeswitch.git freeswitch.git
test -d freeswitch.git || git clone https://github.com/signalwire/freeswitch.git freeswitch.git
install: freeswitch
cd freeswitch.git && gmake install cd-sounds-install cd-moh-install

View File

@ -1 +1 @@
1.10.1-dev
1.10.2-dev

View File

@ -57,6 +57,10 @@
<param name="exchange-name" value="TAP.Commands"/>
<param name="binding_key" value="commandBindingKey"/>
<param name="reconnect_interval_ms" value="1000"/>
<param name="queue-passive" value="false"/>
<param name="queue-durable" value="false"/>
<param name="queue-exclusive" value="false"/>
<param name="queue-auto-delete" value="true"/>
</params>
</profile>
</commands>

View File

@ -1,8 +1,8 @@
<configuration name="msrp.conf" description="MSRP">
<settings>
<param name="listen-ip" value="$${local_ip_v4}"/>
<param name="listen-port" value="2855"/>
<param name="listen-ssl-port" value="2856"/>
<!-- <param name="listen-port" value="2855"/> -->
<!-- <param name="listen-ssl-port" value="2856"/> -->
<!-- <param name="message-buffer-size" value="50"/> -->
<!-- <param name="debug" value="true"/> -->
<!-- <param name="secure-cert" value="$${certs_dir}/wss.pem"/> -->

View File

@ -3,10 +3,10 @@
# Must change all of the below together
# For a release, set revision for that tagged release as well and uncomment
AC_INIT([freeswitch], [1.10.1-dev], bugs@freeswitch.org)
AC_INIT([freeswitch], [1.10.2-dev], bugs@freeswitch.org)
AC_SUBST(SWITCH_VERSION_MAJOR, [1])
AC_SUBST(SWITCH_VERSION_MINOR, [10])
AC_SUBST(SWITCH_VERSION_MICRO, [1-dev])
AC_SUBST(SWITCH_VERSION_MICRO, [2-dev])
AC_SUBST(SWITCH_VERSION_REVISION, [])
AC_SUBST(SWITCH_VERSION_REVISION_HUMAN, [])
@ -1052,14 +1052,17 @@ fi
CFLAGS="$saved_CFLAGS"
if test "x${ax_cv_c_compiler_vendor}" = "xclang" ; then
saved_CFLAGS="$CFLAGS"
# Next check added for Xcode 5 and systems with clang 5 llvm 3.3 or above, extended offset must be off
AC_CACHE_CHECK([whether compiler supports -Wextended-offsetof], [ac_cv_clang_extended_offsetof], [
CFLAGS="$CFLAGS -Wno-extended-offsetof"
AC_TRY_COMPILE([],[return 0;],[ac_cv_clang_extended_offsetof=yes],[ac_cv_clang_extended_offsetof=no])
])
AC_MSG_RESULT($ac_cv_clang_extended_offsetof)
if test x"$ac_cv_clang_extended_offsetof" = xyes; then
APR_ADDTO(CFLAGS, -Wno-extended-offsetof)
fi
CFLAGS="$saved_CFLAGS"
fi
# Tested and fixed lot of modules, but some are untested. Will be added back when the core team decide it ready
@ -1661,7 +1664,7 @@ if test "x$ac_cv_have_php" != "xno" -a "x$ac_cv_have_php_config" != "xno"; then
PHP=php
PHP_CONFIG=php-config
PHP_LDFLAGS="`$PHP_CONFIG --ldflags`"
PHP_LIBS="`$PHP_CONFIG --libs | sed -r 's/ ?-l(bz2|pcre|xml2|gssapi_krb5|krb5|k5crypto|com_err|history|z|readline|gmp|ssl|crypto)//g'`"
PHP_LIBS="`$PHP_CONFIG --libs | sed -r 's/ ?-l(bz2|pcre2-8|xml2|gssapi_krb5|krb5|k5crypto|com_err|history|z|readline|gmp|ssl|crypto|argon2|sodium)//g'`"
PHP_EXT_DIR="`$PHP_CONFIG --extension-dir`"
PHP_INC_DIR="`$PHP -r 'echo ini_get("include_path");' | cut -d: -f2`"
PHP_INI_DIR="`$PHP_CONFIG --configure-options | tr " " "\n" | grep -- --with-config-file-scan-dir | cut -f2 -d=`"

View File

@ -18,7 +18,7 @@ of a FreeSWITCH git repository. You can achieve this with:
aptitude update && aptitude install -y git
mkdir -p /usr/src/freeswitch
git clone https://freeswitch.org/stash/scm/fs/freeswitch.git /usr/src/freeswitch/src
git clone https://github.com/signalwire/freeswitch.git /usr/src/freeswitch/src
cd /usr/src/freeswitch/src
Ensuring you have a clean build directory

4
debian/bootstrap.sh vendored
View File

@ -338,8 +338,8 @@ Build-Depends:
$(debian_wrap "${mod_build_depends}")
Standards-Version: 3.9.3
Homepage: https://freeswitch.org/
Vcs-Git: https://freeswitch.org/stash/scm/fs/freeswitch.git
Vcs-Browser: https://freeswitch.org/stash/projects/FS/repos/freeswitch/browse
Vcs-Git: https://github.com/signalwire/freeswitch.git
Vcs-Browser: https://github.com/signalwire/freeswitch
EOF
}

View File

@ -31,7 +31,7 @@ The container exposes the following ports:
If you wish to help improve these please submit a pull request at:
https://freeswitch.org/jira
https://github.com/signalwire/freeswitch
Thanks,
/b

View File

@ -85,7 +85,7 @@ apt-get install freeswitch-conf-vanilla
```
2) clone freeswitch repo
```sh
git clone https://freeswitch.org/stash/projects/FS/repos/freeswitch/browse
git clone https://github.com/signalwire/freeswitch.git
```
3) execute ```make_min_archive.sh``` script
```sh
@ -100,4 +100,4 @@ docker build -t freeswitch_custom .
Read more
---------
[Dockerfile of official FreeSwitch container](https://freeswitch.org/stash/projects/FS/repos/freeswitch/browse/docker/release)
[Dockerfile of official FreeSwitch container](https://github.com/signalwire/freeswitch/tree/master/docker/release)

View File

@ -4,7 +4,7 @@ How to Contribute Patches to FreeSWITCH
Download the Source Code
------------------------
git clone https://freeswitch.org/stash/scm/fs/freeswitch.git
git clone https://github.com/signalwire/freeswitch.git
cd freeswitch
Ensure Git is Setup
@ -42,18 +42,18 @@ Create a Pull Request
# create an account in JIRA and create a new issue
# navigate to FreeSWITCH Stash
chromium https://freeswitch.org/stash
# navigate to FreeSWITCH github
chromium https://github.com/signalwire/freeswitch
# Using the same credentials as Jira, login to Stash; create a forked FS repository; read
# Using your github credentials, login to github; create a forked FS repository; read
# the details here:
chromium https://freeswitch.org/confluence/display/FREESWITCH/Pull+Requests
# add your repository as a remote (change to your username)
git remote add stash ssh://git@freeswitch.org:7999/~johndoe/freeswitch.git
git remote add fs git@github.com:signalwire/freeswitch.git
# push your changes to a branch
git push stash +HEAD:myfeature
git push fs +HEAD:myfeature
# create a pull request as described here:
chromium https://freeswitch.org/confluence/display/FREESWITCH/Pull+Requests

View File

@ -35,6 +35,6 @@
},
"repository": {
"type": "git",
"url": "https://freeswitch.org/stash/scm/fs/freeswitch.git"
"url": "https://github.com/signalwire/freeswitch.git"
}
}

View File

@ -674,7 +674,7 @@ static void redisplay(void)
esl_mutex_lock(MUTEX);
{
#ifdef HAVE_LIBEDIT
#ifdef XHAVE_DECL_EL_REFRESH
#ifdef HAVE_DECL_EL_REFRESH
#ifdef HAVE_EL_WSET
/* Current libedit versions don't implement EL_REFRESH in eln.c so
* use the wide version instead. */

View File

@ -2,7 +2,7 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 3.0.2
* Version 3.0.12
*
* 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

View File

@ -3,7 +3,7 @@ WRAP_GCC_WARNING_SILENCE=-Wno-unused-label -Wno-unused-function
all: ESL.so
esl_wrap.cpp:
swig3.0 -module ESL -php5 -c++ -DMULTIPLICITY -I../src/include -o esl_wrap.cpp ../ESL.i
swig3.0 -module ESL -php7 -c++ -DMULTIPLICITY -I../src/include -o esl_wrap.cpp ../ESL.i
sed -e 's/ char \*type_name;/ const char \*type_name;/' -i esl_wrap.cpp
esl_wrap.o: esl_wrap.cpp

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 3.0.2
* Version 3.0.12
*
* 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
@ -20,16 +20,6 @@ extern zend_module_entry ESL_module_entry;
# define PHP_ESL_API
#endif
#ifdef ZTS
#include "TSRM.h"
#endif
PHP_MINIT_FUNCTION(ESL);
PHP_MSHUTDOWN_FUNCTION(ESL);
PHP_RINIT_FUNCTION(ESL);
PHP_RSHUTDOWN_FUNCTION(ESL);
PHP_MINFO_FUNCTION(ESL);
ZEND_NAMED_FUNCTION(_wrap_ESLevent_event_set);
ZEND_NAMED_FUNCTION(_wrap_ESLevent_event_get);
ZEND_NAMED_FUNCTION(_wrap_ESLevent_serialized_string_set);
@ -69,4 +59,6 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_setAsyncExecute);
ZEND_NAMED_FUNCTION(_wrap_ESLconnection_setEventLock);
ZEND_NAMED_FUNCTION(_wrap_ESLconnection_disconnect);
ZEND_NAMED_FUNCTION(_wrap_eslSetLogLevel);
PHP_MINIT_FUNCTION(ESL);
#endif /* PHP_ESL_H */

View File

@ -757,6 +757,18 @@ process_common_toolchain() {
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
;;
x86_64*mingw32*)
tgt_os=win64
;;
@ -885,6 +897,18 @@ process_common_toolchain() {
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"
;;
*-iphonesimulator-*)
add_cflags "-miphoneos-version-min=${IOS_VERSION_MIN}"
add_ldflags "-miphoneos-version-min=${IOS_VERSION_MIN}"

View File

@ -35,8 +35,8 @@ ARM_TARGETS="arm64-darwin-gcc
armv7s-darwin-gcc"
SIM_TARGETS="x86-iphonesimulator-gcc
x86_64-iphonesimulator-gcc"
OSX_TARGETS="x86-darwin16-gcc
x86_64-darwin16-gcc"
OSX_TARGETS="x86-darwin18-gcc
x86_64-darwin18-gcc"
TARGETS="${ARM_TARGETS} ${SIM_TARGETS}"
# Configures for the target specified by $1, and invokes make with the dist
@ -271,7 +271,7 @@ cat << EOF
--help: Display this message and exit.
--enable-shared: Build a dynamic framework for use on iOS 8 or later.
--extra-configure-args <args>: Extra args to pass when configuring libvpx.
--macosx: Uses darwin16 targets instead of iphonesimulator targets for x86
--macosx: Uses darwin18 targets instead of iphonesimulator targets for x86
and x86_64. Allows linking to framework when builds target MacOSX
instead of iOS.
--preserve-build-output: Do not delete the build directory.

View File

@ -129,6 +129,8 @@ 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-iphonesimulator-gcc"
all_platforms="${all_platforms} x86-linux-gcc"
all_platforms="${all_platforms} x86-linux-icc"
@ -149,6 +151,9 @@ 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-iphonesimulator-gcc"
all_platforms="${all_platforms} x86_64-linux-gcc"
all_platforms="${all_platforms} x86_64-linux-icc"

View File

@ -119,6 +119,12 @@
*/
#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

View File

@ -1 +1 @@
Mon Aug 19 16:25:57 CDT 2019
Mon Sep 09 11:45:57 CDT 2019

View File

@ -904,7 +904,7 @@ sres_sip_log_answers(sres_sip_t *srs,
SU_DEBUG_5(("srs(%p): %s IN CNAME %s\n", (void *)srs, domain, cname));
}
#if SU_HAVE_IN6
else if (type == sres_type_cname) {
else if (type == sres_type_aaaa) {
sres_aaaa_record_t const *aaaa = sr->sr_aaaa;
su_inet_ntop(AF_INET6, &aaaa->aaaa_addr, addr, sizeof(addr));
SU_DEBUG_5(("srs(%p): %s IN AAAA %s\n", (void *)srs, domain, addr));

View File

@ -133,10 +133,10 @@ config_fs_repos() {
curl https://files.freeswitch.org/repo/deb/debian/freeswitch_archive_g0.pub | apt-key add -
if [ "$FS_REV" = "master" ]; then
echo "deb http://files.freeswitch.org/repo/deb/debian-unstable/ jessie main" >/etc/apt/sources.list.d/freeswitch.list
REPO="https://freeswitch.org/stash/scm/fs/freeswitch.git"
REPO="https://github.com/signalwire/freeswitch.git"
elif [ "$FS_REV" = "1.6" ]; then
echo "deb http://files.freeswitch.org/repo/deb/freeswitch-1.6/ jessie main" > /etc/apt/sources.list.d/freeswitch.list
REPO="-b v1.6 https://silik0n@freeswitch.org/stash/scm/fs/freeswitch.git"
REPO="-b v1.6 https://github.com/signalwire/freeswitch.git"
fi
apt-get update 2>&1 >/dev/null
}

View File

@ -12,7 +12,7 @@ apt-get update && apt-get install -y libtool libjpeg62-turbo-dev ntpdate libfree
cd /usr/src
git clone https://freeswitch.org/stash/scm/fs/freeswitch.git freeswitch.git
git clone https://github.com/signalwire/freeswitch.git freeswitch.git
cd freeswitch.git

View File

@ -1424,6 +1424,16 @@ SWITCH_DECLARE(switch_status_t) switch_core_hash_init_case(_Out_ switch_hash_t *
*/
SWITCH_DECLARE(switch_status_t) switch_core_hash_destroy(_Inout_ switch_hash_t **hash);
/*!
\brief Insert data into a hash and set flags so the value is automatically freed on delete
\param hash the hash to add data to
\param key the name of the key to add the data to
\param data the data to add
\return SWITCH_STATUS_SUCCESS if the data is added
\note the string key must be a constant or a dynamic string
*/
SWITCH_DECLARE(switch_status_t) switch_core_hash_insert_auto_free(switch_hash_t *hash, const char *key, const void *data);
/*!
\brief Insert data into a hash
\param hash the hash to add data to

View File

@ -1052,8 +1052,9 @@ SWITCH_DECLARE(int) switch_dial_handle_get_peers(switch_dial_handle_t *handle, i
SWITCH_DECLARE(int) switch_dial_handle_get_vars(switch_dial_handle_t *handle, int idx, switch_event_t **array, int max);
SWITCH_DECLARE(switch_event_t *) switch_dial_handle_get_global_vars(switch_dial_handle_t *handle);
SWITCH_DECLARE(switch_event_t *) switch_dial_leg_get_vars(switch_dial_leg_t *leg);
SWITCH_DECLARE(const char *) switch_dial_leg_get_var(switch_dial_leg_t *leg, const char *key);
SWITCH_DECLARE(int) switch_dial_handle_get_total(switch_dial_handle_t *handle);
SWITCH_DECLARE(void) switch_ivr_orig_and_bridge(switch_core_session_t *session, const char *data, switch_dial_handle_t *dh);
SWITCH_DECLARE(switch_status_t) switch_ivr_orig_and_bridge(switch_core_session_t *session, const char *data, switch_dial_handle_t *dh, switch_call_cause_t *cause);
SWITCH_DECLARE(switch_status_t) switch_ivr_play_and_collect_input(switch_core_session_t *session,
const char *prompt,

View File

@ -34,9 +34,6 @@
#include <switch.h>
#define MSRP_LISTEN_PORT 2855
#define MSRP_SSL_LISTEN_PORT 2856
enum {
MSRP_ST_WAIT_HEADER,
MSRP_ST_PARSE_HEADER,

View File

@ -387,7 +387,9 @@ typedef enum {
SCF_DIALPLAN_TIMESTAMPS = (1 << 24),
SCF_CPF_SOFT_PREFIX = (1 << 25),
SCF_CPF_SOFT_LOOKUP = (1 << 26),
SCF_EVENT_CHANNEL_ENABLE_HIERARCHY_DELIVERY = (1 << 27)
SCF_EVENT_CHANNEL_ENABLE_HIERARCHY_DELIVERY = (1 << 27),
SCF_EVENT_CHANNEL_HIERARCHY_DELIVERY_ONCE = (1 << 28),
SCF_EVENT_CHANNEL_LOG_UNDELIVERABLE_JSON = (1 << 29)
} switch_core_flag_enum_t;
typedef uint32_t switch_core_flag_t;
@ -1935,7 +1937,8 @@ typedef enum {
SWITCH_FILE_NOMUX = (1 << 17),
SWITCH_FILE_BREAK_ON_CHANGE = (1 << 18),
SWITCH_FILE_FLAG_VIDEO = (1 << 19),
SWITCH_FILE_FLAG_VIDEO_EOF = (1 << 20)
SWITCH_FILE_FLAG_VIDEO_EOF = (1 << 20),
SWITCH_FILE_PRE_CLOSED = (1 << 21)
} switch_file_flag_enum_t;
typedef uint32_t switch_file_flag_t;

View File

@ -3663,9 +3663,12 @@ with. If we fail a setup up, then we go directly to a teardown mode. */
fct_ts__add_test( \
fctkern_ptr__->ns.ts_curr, fctkern_ptr__->ns.curr_test \
); \
} else { \
fct_test__del(fctkern_ptr__->ns.curr_test); \
fctkern_ptr__->ns.curr_test = NULL; \
} \
} else { \
switch_assert("invalid condition for fct_req!"); \
switch_assert("invalid condition for fct_req!"); \
_fct_req((_CNDTN_)); \
}

View File

@ -113,7 +113,7 @@ static switch_status_t fst_init_core_and_modload(const char *confdir, const char
switch_core_set_globals();
if (!minimal) {
status = switch_core_init_and_modload(0, SWITCH_TRUE, &err);
status = switch_core_init_and_modload(SCF_USE_SQL, SWITCH_TRUE, &err);
switch_sleep(1 * 1000000);
switch_core_set_variable("sound_prefix", "." SWITCH_PATH_SEPARATOR);
if (status != SWITCH_STATUS_SUCCESS && err) {
@ -308,7 +308,7 @@ static switch_status_t fst_init_core_and_modload(const char *confdir, const char
/**
* Minimal FS core load
*/
#define FST_MINCORE_BEGIN() \
#define FST_MINCORE_BEGIN(confdir) \
FCT_BGN() \
{ \
int fst_core = 0; \
@ -317,7 +317,7 @@ static switch_status_t fst_init_core_and_modload(const char *confdir, const char
switch_memory_pool_t *fst_pool = NULL; \
int fst_timer_started = 0; \
fst_getenv_default("FST_SUPPRESS_UNUSED_STATIC_WARNING", NULL, SWITCH_FALSE); \
if (fst_init_core_and_modload(".", NULL, 1) == SWITCH_STATUS_SUCCESS) { /* minimal load */ \
if (fst_init_core_and_modload(confdir, NULL, 1) == SWITCH_STATUS_SUCCESS) { /* minimal load */ \
fst_core = 1; \
} else { \
fprintf(stderr, "Failed to load FS core\n"); \

View File

@ -1836,15 +1836,13 @@ static char get_media_type_char(enum AVMediaType type)
}
}
static const AVCodec *next_codec_for_id(enum AVCodecID id, const AVCodec *prev,
static const AVCodec *next_codec_for_id(enum AVCodecID id, const AVCodec *prev, void **index,
int encoder)
{
#if (LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58,10,100))
while ((prev = av_codec_next(prev))) {
#else
void *i;
while ((prev = av_codec_iterate(&i))) {
while ((prev = av_codec_iterate(index))) {
#endif
if (prev->id == id &&
(encoder ? av_codec_is_encoder(prev) : av_codec_is_decoder(prev)))
@ -1887,10 +1885,11 @@ static unsigned get_codecs_sorted(const AVCodecDescriptor ***rcodecs)
static void print_codecs_for_id(switch_stream_handle_t *stream, enum AVCodecID id, int encoder)
{
const AVCodec *codec = NULL;
void *index = 0;
stream->write_function(stream, " (%s: ", encoder ? "encoders" : "decoders");
while ((codec = next_codec_for_id(id, codec, encoder))) {
while ((codec = next_codec_for_id(id, codec, &index, encoder))) {
stream->write_function(stream, "%s ", codec->name);
}
@ -1916,6 +1915,7 @@ void show_codecs(switch_stream_handle_t *stream)
for (i = 0; i < nb_codecs; i++) {
const AVCodecDescriptor *desc = codecs[i];
const AVCodec *codec = NULL;
void *index = 0;
stream->write_function(stream, " ");
stream->write_function(stream, avcodec_find_decoder(desc->id) ? "D" : ".");
@ -1930,14 +1930,14 @@ void show_codecs(switch_stream_handle_t *stream)
/* print decoders/encoders when there's more than one or their
* names are different from codec name */
while ((codec = next_codec_for_id(desc->id, codec, 0))) {
while ((codec = next_codec_for_id(desc->id, codec, &index, 0))) {
if (strcmp(codec->name, desc->name)) {
print_codecs_for_id(stream ,desc->id, 0);
break;
}
}
codec = NULL;
while ((codec = next_codec_for_id(desc->id, codec, 1))) {
codec = NULL; index = 0;
while ((codec = next_codec_for_id(desc->id, codec, &index, 1))) {
if (strcmp(codec->name, desc->name)) {
print_codecs_for_id(stream, desc->id, 1);
break;

View File

@ -1029,7 +1029,7 @@ void show_formats(switch_stream_handle_t *stream) {
#if (LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58,9,100))
while ((ofmt = av_oformat_next(ofmt))) {
#else
void *i;
void *i = 0;
while ((ofmt = av_muxer_iterate(&i))) {
#endif
@ -1047,6 +1047,7 @@ void show_formats(switch_stream_handle_t *stream) {
#if (LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58,9,100))
while ((ifmt = av_iformat_next(ifmt))) {
#else
i = 0;
while ((ifmt = av_demuxer_iterate(&i))) {
#endif
is_dev = is_device(ifmt->priv_class);

View File

@ -1403,6 +1403,7 @@ SWITCH_STANDARD_APP(avmd_start_app) {
avmd_session_t *avmd_session = NULL;
switch_core_media_flag_t flags = 0;
const char *direction = "NO DIRECTION";
uint8_t report = 0;
if (session == NULL) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "BUGGG. FreeSWITCH session is NULL! Please report to developers\n");
@ -1446,6 +1447,8 @@ SWITCH_STANDARD_APP(avmd_start_app) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Failed to set dynamic parameteres for avmd session. Unknown error\n");
goto end;
}
report = avmd_session->settings.report_status;
status = init_avmd_session_data(avmd_session, session, avmd_globals.mutex);
if (status != SWITCH_STATUS_SUCCESS) {
@ -1508,7 +1511,10 @@ SWITCH_STANDARD_APP(avmd_start_app) {
status = switch_core_media_bug_add(session, "avmd", NULL, avmd_callback, avmd_session, 0, flags, &bug); /* Add a media bug that allows me to intercept the audio stream */
if (status != SWITCH_STATUS_SUCCESS) { /* If adding a media bug fails exit */
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Failed to add media bug!\n");
goto end_unlock;
switch_mutex_unlock(avmd_session->mutex);
avmd_session_close(avmd_session);
goto end;
}
switch_mutex_lock(avmd_globals.mutex);
@ -1526,7 +1532,7 @@ end_unlock:
end:
if (status != SWITCH_STATUS_SUCCESS) {
if (avmd_session == NULL || avmd_session->settings.report_status == 1) {
if (avmd_session == NULL || report) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Avmd on channel [%s] NOT started\n", switch_channel_get_name(channel));
}
}

View File

@ -4010,7 +4010,7 @@ SWITCH_STANDARD_API(cc_break_api_function)
const char *uuid = NULL;
switch_core_session_t *break_session = NULL;
switch_channel_t *channel = NULL;
switch_bool_t status = SWITCH_STATUS_SUCCESS;
switch_status_t status = SWITCH_STATUS_SUCCESS;
if (!zstr(cmd)) {
mydata = strdup(cmd);
@ -4208,12 +4208,19 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_callcenter_load)
switch_json_api_interface_t *json_api_interface;
switch_status_t status;
/* create/register custom event message type */
if (switch_event_reserve_subclass(CALLCENTER_EVENT) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", CALLCENTER_EVENT);
return SWITCH_STATUS_TERM;
}
/* Subscribe to presence request events */
if (switch_event_bind_removable(modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY,
cc_presence_event_handler, NULL, &globals.node) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to subscribe for presence events!\n");
return SWITCH_STATUS_GENERR;
}
memset(&globals, 0, sizeof(globals));
globals.pool = pool;
@ -4221,15 +4228,12 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_callcenter_load)
switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, globals.pool);
if ((status = load_config()) != SWITCH_STATUS_SUCCESS) {
switch_event_unbind(&globals.node);
switch_event_free_subclass(CALLCENTER_EVENT);
switch_core_hash_destroy(&globals.queue_hash);
return status;
}
if (switch_event_bind_removable(modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY,
cc_presence_event_handler, NULL, &globals.node) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to subscribe for presence events!\n");
return SWITCH_STATUS_GENERR;
}
switch_mutex_lock(globals.mutex);
globals.running = 1;
switch_mutex_unlock(globals.mutex);
@ -4242,7 +4246,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_callcenter_load)
}
SWITCH_ADD_APP(app_interface, "callcenter", "CallCenter", CC_DESC, callcenter_function, CC_USAGE, SAF_NONE);
SWITCH_ADD_APP(app_interface, "callcenter_track", "CallCenter Track Call", "Track external mod_callcenter calls to avoid place new calls", callcenter_track, CC_USAGE, SAF_NONE);
SWITCH_ADD_APP(app_interface, "callcenter_track", "CallCenter Track Call", "Track external mod_callcenter calls to avoid place new calls", callcenter_track, CC_USAGE, SAF_SUPPORT_NOMEDIA);
SWITCH_ADD_API(api_interface, "callcenter_config", "Config of callcenter", cc_config_api_function, CC_CONFIG_API_SYNTAX);
SWITCH_ADD_API(api_interface, "callcenter_break", "Stop watching an uuid and release agent", cc_break_api_function, "callcenter_break agent <uuid>");

View File

@ -1193,7 +1193,7 @@ void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, void *ob
member->last_score = member->score;
if (member->id == member->conference->floor_holder) {
if ((switch_channel_test_flag(channel, CF_VIDEO) || member->avatar_png_img) && (member->id == member->conference->floor_holder)) {
if (member->id != member->conference->video_floor_holder &&
(member->floor_packets > member->conference->video_floor_packets || member->energy_level == 0)) {
conference_video_set_floor_holder(member->conference, member, SWITCH_FALSE);

View File

@ -468,10 +468,10 @@ static switch_status_t load_config(switch_bool_t reload)
char *val = (char *) switch_xml_attr_soft(param, "value");
if (!strcasecmp(var, "odbc-dsn") && !zstr(val)) {
if (switch_database_available(val)) {
if (switch_database_available(val) == SWITCH_STATUS_SUCCESS) {
switch_set_string(globals.odbc_dsn, val);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "DATABASE IS NOT AVAILABLE!\n");
}
} else if (!strcasecmp(var, "dbname") && !zstr(val)) {
globals.dbname = switch_core_strdup(globals.pool, val);

View File

@ -4392,10 +4392,10 @@ static switch_status_t read_config_file(switch_xml_t *xml, switch_xml_t *cfg) {
if (!strcasecmp(var, "outbound-strategy") && !zstr(val)) {
globals.default_strategy = parse_strategy(val);
} else if (!strcasecmp(var, "odbc-dsn") && !zstr(val)) {
if (switch_database_available(val)) {
if (switch_database_available(val) == SWITCH_STATUS_SUCCESS) {
switch_set_string(globals.odbc_dsn, val);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "DATABASE IS NOT AVAILABLE!\n");
}
} else if (!strcasecmp(var, "dbname") && !zstr(val)) {
globals.dbname = switch_core_strdup(globals.pool, val);

View File

@ -3004,7 +3004,8 @@ static switch_status_t file_open(switch_file_handle_t *handle, const char *path,
handle->seekable = context->fh.seekable;
handle->speed = context->fh.speed;
handle->interval = context->fh.interval;
handle->channels = context->fh.real_channels;
handle->channels = context->fh.channels;
handle->cur_channels = context->fh.real_channels;
handle->flags |= SWITCH_FILE_NOMUX;
if (switch_test_flag((&context->fh), SWITCH_FILE_NATIVE)) {

View File

@ -273,7 +273,7 @@ static void parse_domain(const char *url, char *domain_buf, int domain_buf_len)
if (!*start) {
return;
}
strncpy(domain_buf, start, domain_buf_len);
snprintf(domain_buf, domain_buf_len, "%s", start);
end = strchr(domain_buf, '/');
if (end) {
*end = '\0';
@ -985,7 +985,7 @@ static char *cached_url_filename_create(url_cache_t *cache, const char *url, cha
/* filename is constructed from UUID and is stored in cache dir (first 2 characters of UUID) */
switch_uuid_get(&uuid);
switch_uuid_format(uuid_str, &uuid);
strncpy(uuid_dir, uuid_str, 2);
snprintf(uuid_dir, sizeof(uuid_dir), "%.2s", uuid_str);
dirname = switch_mprintf("%s%s%s", cache->location, SWITCH_PATH_SEPARATOR, uuid_dir);
/* create sub-directory if it doesn't exist */
@ -1754,6 +1754,7 @@ static switch_status_t http_cache_file_open(switch_file_handle_t *handle, const
handle->speed = context->fh.speed;
handle->interval = context->fh.interval;
handle->channels = context->fh.channels;
handle->cur_channels = context->fh.real_channels;
handle->flags |= SWITCH_FILE_NOMUX;
handle->pre_buffer_datalen = 0;

View File

@ -459,7 +459,7 @@ SWITCH_STANDARD_API(mod_signalwire_api_function)
" /____/_/\\__, /_/ /_/\\__,_/_/ |__/|__/_/_/ \\___/\n"
" /____/\n"
"\n /=====================================================================\\\n"
"| Connection Token: %s |\n"
" Connection Token: %s\n"
" \\=====================================================================/\n"
" Go to https://signalwire.com to set up your Connector now!\n", globals.adoption_token);
} else {

View File

@ -485,7 +485,7 @@ static void destroy_descriptor(void *ptr)
{
tone_descriptor_t *d = (tone_descriptor_t *) ptr;
super_tone_rx_free_descriptor(d->spandsp_tone_descriptor);
tone_descriptor_destroy(d);
}
switch_status_t load_configuration(switch_bool_t reload)

View File

@ -133,6 +133,7 @@ typedef struct tone_descriptor tone_descriptor_t;
switch_status_t tone_descriptor_create(tone_descriptor_t **descriptor, const char *name, switch_memory_pool_t *memory_pool);
void tone_descriptor_destroy(tone_descriptor_t *descriptor);
int tone_descriptor_add_tone(tone_descriptor_t *descriptor, const char *name);
switch_status_t tone_descriptor_add_tone_element(tone_descriptor_t *descriptor, int tone_id, int freq1, int freq2, int min, int max);

View File

@ -637,6 +637,20 @@ switch_status_t tone_descriptor_create(tone_descriptor_t **descriptor, const cha
return SWITCH_STATUS_SUCCESS;
}
/**
* Destroy the tone descriptor
*
* @param descriptor the descriptor to create
* @return void
*/
void tone_descriptor_destroy(tone_descriptor_t *descriptor)
{
if (descriptor->spandsp_tone_descriptor) {
super_tone_rx_free_descriptor(descriptor->spandsp_tone_descriptor);
descriptor->spandsp_tone_descriptor = NULL;
}
}
/**
* Add a tone to the tone descriptor
*
@ -711,6 +725,48 @@ static void tone_segment_callback(void *user_data, int f1, int f2, int duration)
}
}
/**
* Duplicate the tone descriptor
*
* @param descriptor the descriptor to use
* @param memory_pool the pool to use
* @return pointer to a copy of descriptor
*/
static tone_descriptor_t *tone_descriptor_dup(tone_descriptor_t *descriptor, switch_memory_pool_t *pool)
{
tone_descriptor_t *desc = NULL;
int t = 0, s = 0, tone_count = 0;
if (descriptor && pool) {
if (tone_descriptor_create(&desc, descriptor->name, pool) != SWITCH_STATUS_SUCCESS) {
return NULL;
}
tone_count = descriptor->idx + 1;
for (t = 0; t < tone_count; t++) {
int tone_id = tone_descriptor_add_tone(desc, descriptor->tone_keys[t]);
if (-1 != tone_id) {
int step = descriptor->spandsp_tone_descriptor->tone_segs[tone_id];
for (s = 0; s < step; s++) {
super_tone_rx_segment_t segment = descriptor->spandsp_tone_descriptor->tone_list[tone_id][s];
int f1 = (segment.f1 == -1 ? 0 : descriptor->spandsp_tone_descriptor->pitches[segment.f1][0]);
int f2 = (segment.f2 == -1 ? 0 : descriptor->spandsp_tone_descriptor->pitches[segment.f2][0]);
int min = segment.min_duration / 8;
int max = (segment.max_duration == 0x7FFFFFFF ? 0 : segment.max_duration / 8);
tone_descriptor_add_tone_element(desc, tone_id, f1, f2, min, max);
}
} else {
tone_descriptor_destroy(desc);
desc = NULL;
break;
}
}
}
return desc;
}
/**
* Allocate the tone detector
*
@ -723,11 +779,8 @@ static void tone_segment_callback(void *user_data, int f1, int f2, int duration)
static switch_status_t tone_detector_create(switch_core_session_t *session, tone_detector_t **detector, tone_descriptor_t *descriptor)
{
tone_detector_t *ldetector = switch_core_session_alloc(session, sizeof(tone_detector_t));
tone_descriptor_t *desc = switch_core_session_alloc(session, sizeof(tone_descriptor_t));
memcpy(desc, descriptor, sizeof(tone_descriptor_t));
ldetector->descriptor = desc;
ldetector->descriptor = tone_descriptor_dup(descriptor, switch_core_session_get_pool(session));
ldetector->debug = spandsp_globals.tonedebug;
ldetector->session = session;
*detector = ldetector;
@ -777,6 +830,10 @@ static void tone_detector_destroy(tone_detector_t *detector)
super_tone_rx_free(detector->spandsp_detector);
detector->spandsp_detector = NULL;
}
if (detector->descriptor) {
tone_descriptor_destroy(detector->descriptor);
detector->descriptor = NULL;
}
}
}

View File

@ -1,10 +1,14 @@
include $(top_srcdir)/build/modmake.rulesam
MODNAME=mod_test
noinst_LTLIBRARIES = libtestmod.la
libtestmod_la_SOURCES = mod_test.c
mod_LTLIBRARIES = mod_test.la
mod_test_la_SOURCES = mod_test.c
mod_test_la_CFLAGS = $(AM_CFLAGS)
mod_test_la_LIBADD = $(switch_builddir)/libfreeswitch.la
mod_test_la_LDFLAGS = -avoid-version -module -no-undefined -shared
mod_test_la_SOURCES =
mod_test_la_LIBADD = $(switch_builddir)/libfreeswitch.la $(SOFIALA) libtestmod.la
mod_test_la_LDFLAGS = -avoid-version -module -no-undefined -shared
SUBDIRS=. test

View File

@ -257,8 +257,6 @@ static switch_status_t test_asr_get_results(switch_asr_handle_t *ah, char **resu
{
test_asr_t *context = (test_asr_t *) ah->private_info;
switch_status_t status = SWITCH_STATUS_SUCCESS;
switch_stream_handle_t result = { 0 };
SWITCH_STANDARD_STREAM(result);
if (switch_test_flag(context, ASRFLAG_RETURNED_RESULT) || switch_test_flag(ah, SWITCH_ASR_FLAG_CLOSED)) {
return SWITCH_STATUS_FALSE;

View File

@ -1,5 +1,6 @@
include $(top_srcdir)/build/modmake.rulesam
noinst_PROGRAMS = test_asr
test_asr_CFLAGS = $(AM_CFLAGS) -I../
test_asr_LDFLAGS = $(AM_LDFLAGS) -avoid-version -no-undefined $(freeswitch_LDFLAGS) ../mod_test.la $(switch_builddir)/libfreeswitch.la $(CORE_LIBS) $(APR_LIBS)
test_asr_LDFLAGS = $(AM_LDFLAGS) -avoid-version -no-undefined $(freeswitch_LDFLAGS) $(switch_builddir)/libfreeswitch.la $(CORE_LIBS) $(APR_LIBS)
test_asr_LDADD = ../libtestmod.la
TESTS = $(noinst_PROGRAMS)

View File

@ -186,13 +186,17 @@ static switch_status_t tts_commandline_speech_read_tts(switch_speech_handle_t *s
assert(info != NULL);
if (switch_core_file_read(info->fh, data, &my_datalen) != SWITCH_STATUS_SUCCESS) {
switch_core_file_close(info->fh);
if (switch_test_flag(info->fh, SWITCH_FILE_OPEN)) {
switch_core_file_close(info->fh);
}
unlink(info->file);
return SWITCH_STATUS_FALSE;
}
*datalen = my_datalen * 2;
if (datalen == 0) {
switch_core_file_close(info->fh);
if (switch_test_flag(info->fh, SWITCH_FILE_OPEN)) {
switch_core_file_close(info->fh);
}
unlink(info->file);
return SWITCH_STATUS_BREAK;
} else {
@ -205,7 +209,7 @@ static void tts_commandline_speech_flush_tts(switch_speech_handle_t *sh)
tts_commandline_t *info = (tts_commandline_t *) sh->private_info;
assert(info != NULL);
if (info->fh != NULL && info->fh->file_interface != NULL) {
if (info->fh != NULL && info->fh->file_interface != NULL && switch_test_flag(info->fh, SWITCH_FILE_OPEN)) {
switch_core_file_close(info->fh);
}
if (switch_file_exists(info->file, NULL) == SWITCH_STATUS_SUCCESS) {

View File

@ -360,7 +360,6 @@ switch_status_t sofia_on_destroy(switch_core_session_t *session)
{
private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session);
switch_channel_t *channel = switch_core_session_get_channel(session);
char *uuid;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s SOFIA DESTROY\n", switch_channel_get_name(channel));
@ -376,13 +375,7 @@ switch_status_t sofia_on_destroy(switch_core_session_t *session)
}
if (!zstr(tech_pvt->call_id)) {
switch_mutex_lock(tech_pvt->profile->flag_mutex);
if ((uuid = switch_core_hash_find(tech_pvt->profile->chat_hash, tech_pvt->call_id))) {
free(uuid);
uuid = NULL;
switch_core_hash_delete(tech_pvt->profile->chat_hash, tech_pvt->call_id);
}
switch_mutex_unlock(tech_pvt->profile->flag_mutex);
switch_core_hash_delete_locked(tech_pvt->profile->chat_hash, tech_pvt->call_id, tech_pvt->profile->flag_mutex);
}
@ -461,7 +454,7 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session)
switch_channel_get_name(channel), switch_channel_cause2str(cause));
if (tech_pvt->hash_key && !sofia_test_pflag(tech_pvt->profile, PFLAG_DESTROY)) {
switch_core_hash_delete(tech_pvt->profile->chat_hash, tech_pvt->hash_key);
switch_core_hash_delete_locked(tech_pvt->profile->chat_hash, tech_pvt->hash_key, tech_pvt->profile->flag_mutex);
}
if (session && tech_pvt->profile->pres_type) {

View File

@ -821,8 +821,13 @@ void sofia_handle_sip_i_notify(switch_core_session_t *session, int status,
while ((call_info = call_info->ci_next) != NULL) {
char *tmp = sip_header_as_string(nua_handle_home(nh), (void *) call_info);
size_t tmp_len = strlen(tmp);
hold = realloc(hold, cur_len + tmp_len + 2);
switch_assert(hold);
char *tmp_hold = realloc(hold, cur_len + tmp_len + 2);
if (!tmp_hold) {
/* Avoid leak if realloc failed */
free(hold);
}
switch_assert(tmp_hold);
hold = tmp_hold;
strncpy(hold + cur_len, ",", 2);
strncpy(hold + cur_len + 1, tmp, tmp_len +1);
su_free(nua_handle_home(nh), tmp);
@ -2430,7 +2435,7 @@ void sofia_event_callback(nua_event_t event,
tech_pvt->nh = NULL;
sofia_set_flag(tech_pvt, TFLAG_BYE);
switch_mutex_lock(profile->flag_mutex);
switch_core_hash_insert(profile->chat_hash, tech_pvt->call_id, strdup(switch_core_session_get_uuid(session)));
switch_core_hash_insert_auto_free(profile->chat_hash, tech_pvt->call_id, strdup(switch_core_session_get_uuid(session)));
switch_mutex_unlock(profile->flag_mutex);
nua_handle_destroy(nh);
} else {
@ -2519,10 +2524,11 @@ void sofia_event_callback(nua_event_t event,
if (sip->sip_call_id && sip->sip_call_id->i_id) {
char *uuid;
char *uuid = NULL, *tmp;
switch_mutex_lock(profile->flag_mutex);
if ((uuid = (char *) switch_core_hash_find(profile->chat_hash, sip->sip_call_id->i_id))) {
if ((tmp = (char *) switch_core_hash_find(profile->chat_hash, sip->sip_call_id->i_id))) {
uuid = strdup(tmp);
switch_core_hash_delete(profile->chat_hash, sip->sip_call_id->i_id);
}
switch_mutex_unlock(profile->flag_mutex);
@ -10125,6 +10131,7 @@ switch_status_t sofia_locate_user(char* user, switch_core_session_t *session, si
for (un = sip->sip_unknown; un; un = un->un_next) {
switch_event_add_header_string(v_event, SWITCH_STACK_BOTTOM, un->un_name, un->un_value);
};
switch_channel_event_set_data(switch_core_session_get_channel(session), v_event);
}
result = switch_xml_locate_user_merged("id", username, domain, NULL, x_user, v_event);
@ -11321,7 +11328,7 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
switch_channel_set_variable(channel, "sip_geolocation_error", un->un_value);
} else if (!strcasecmp(un->un_name, "userLocation")) {
switch_channel_set_variable(channel, "sip_user_location", un->un_value);
} else if (!strncasecmp(un->un_name, "X-", 2) || !strncasecmp(un->un_name, "P-", 2) || !strcasecmp(un->un_name, "User-to-User") || !strncasecmp(un->un_name, "On", 2)) {
} else if (!strncasecmp(un->un_name, "X-", 2) || !strncasecmp(un->un_name, "P-", 2) || !strcasecmp(un->un_name, "User-to-User") || !strncasecmp(un->un_name, "On", 2) || !strncasecmp(un->un_name, "K-", 2)) {
if (!zstr(un->un_value)) {
char new_name[512] = "";
int reps = 0;

View File

@ -852,7 +852,7 @@ char *sofia_overcome_sip_uri_weakness(switch_core_session_t *session, const char
stripped = sofia_glue_get_url_from_contact(stripped, 0);
/* remove our params so we don't make any whiny moronic device piss it's pants and forget who it is for a half-hour */
/* remove our params so we don't make any whiny moronic device piss its pants and forget who it is for a half-hour */
if ((p = (char *) switch_stristr(";fs_", stripped))) {
*p = '\0';
}

View File

@ -5000,7 +5000,7 @@ void sofia_presence_handle_sip_i_message(int status,
abort();
}
if (sofia_test_pflag(profile, PFLAG_IN_DIALOG_CHAT) && (tech_pvt = (private_object_t *) switch_core_hash_find(profile->chat_hash, hash_key))) {
if (sofia_test_pflag(profile, PFLAG_IN_DIALOG_CHAT) && (tech_pvt = (private_object_t *) switch_core_hash_find_locked(profile->chat_hash, hash_key, profile->flag_mutex))) {
switch_core_session_queue_event(tech_pvt->session, &event);
} else {
switch_core_chat_send(proto, event);

View File

@ -2929,7 +2929,7 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile,
if (switch_xml_locate_user_merged("id", zstr(username) ? "nobody" : username, domain_name, ip, &user, params) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Can't find user [%s@%s] from %s\n"
"You must define a domain called '%s' in your directory and add a user with the id=\"%s\" attribute\n"
"and you must configure your device to use the proper domain in it's authentication credentials.\n", username, domain_name,
"and you must configure your device to use the proper domain in its authentication credentials.\n", username, domain_name,
ip, domain_name, username);
ret = AUTH_FORBIDDEN;
@ -2937,7 +2937,7 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile,
} else {
const char *type = switch_xml_attr(user, "type");
if (type && !strcasecmp(type, "pointer")) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cant register a pointer.\n");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Can't register a pointer.\n");
ret = AUTH_FORBIDDEN;
goto end;
}

View File

@ -33,7 +33,7 @@
#include <test/switch_test.h>
#include "../mod_sofia.c"
FST_MINCORE_BEGIN()
FST_MINCORE_BEGIN("./conf")
FST_SUITE_BEGIN(switch_hash)

View File

@ -1922,7 +1922,7 @@ static void client_run(jsock_t *jsock)
int rem = 0;
int dur = 0, j = 0;
if (!(size = atoi(p))) {
if ((size = atoi(p)) <= 0) {
continue;
}

View File

@ -134,6 +134,12 @@ typedef struct {
char *queue;
char *binding_key;
/* Queue properties */
switch_bool_t passive;
switch_bool_t durable;
switch_bool_t exclusive;
switch_bool_t auto_delete;
/* Note: The AMQP channel is not reentrant this MUTEX serializes sending events. */
mod_amqp_connection_t *conn_root;
mod_amqp_connection_t *conn_active;

View File

@ -121,6 +121,12 @@ switch_status_t mod_amqp_command_create(char *name, switch_xml_t cfg)
goto err;
}
/* Default queue properties, set to match formerly hardcoded values */
profile->passive = SWITCH_FALSE;
profile->durable = SWITCH_FALSE;
profile->exclusive = SWITCH_FALSE;
profile->auto_delete = SWITCH_TRUE;
if ((params = switch_xml_child(cfg, "params")) != NULL) {
for (param = switch_xml_child(params, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr_soft(param, "name");
@ -147,6 +153,14 @@ switch_status_t mod_amqp_command_create(char *name, switch_xml_t cfg)
queue = mod_amqp_expand_header(profile->pool, event, val);
} else if (!strncmp(var, "binding_key", 11)) {
binding_key = mod_amqp_expand_header(profile->pool, event, val);
} else if (!strncmp(var, "queue-passive", 13)) {
profile->passive = switch_true(val);
} else if (!strncmp(var, "queue-durable", 13)) {
profile->durable = switch_true(val);
} else if (!strncmp(var, "queue-exclusive", 15)) {
profile->exclusive = switch_true(val);
} else if (!strncmp(var, "queue-auto-delete", 17)) {
profile->auto_delete = switch_true(val);
}
}
}
@ -308,8 +322,10 @@ void * SWITCH_THREAD_FUNC mod_amqp_command_thread(switch_thread_t *thread, void
recv_queue = amqp_queue_declare(profile->conn_active->state, // state
1, // channel
profile->queue ? amqp_cstring_bytes(profile->queue) : amqp_empty_bytes, // queue name
0, 0, // passive, durable
0, 1, // exclusive, auto-delete
profile->passive,
profile->durable,
profile->exclusive,
profile->auto_delete,
amqp_empty_table); // args
if (mod_amqp_log_if_amqp_error(amqp_get_rpc_reply(profile->conn_active->state), "Declaring queue\n")) {

View File

@ -220,7 +220,7 @@ switch_status_t mod_amqp_connection_create(mod_amqp_connection_t **conn, switch_
if (interval && interval > 0) {
port = interval;
}
} else if (!strncmp(var, "heartbeat", 4)) {
} else if (!strncmp(var, "heartbeat", 9)) {
int interval = atoi(val);
if (interval && interval > 0) {
heartbeat = interval;

View File

@ -238,34 +238,7 @@ switch_status_t mod_amqp_logging_create(char *name, switch_xml_t cfg)
}
}
profile->conn_active = NULL;
if ( mod_amqp_connection_open(profile->conn_root, &(profile->conn_active), profile->name, profile->custom_attr) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Profile[%s] was unable to connect to any connection\n", profile->name);
goto err;
}
#if AMQP_VERSION_MAJOR == 0 && AMQP_VERSION_MINOR >= 6
amqp_exchange_declare(profile->conn_active->state, 1,
amqp_cstring_bytes(profile->exchange),
amqp_cstring_bytes(profile->exchange_type),
0, /* passive */
profile->exchange_durable,
profile->exchange_auto_delete,
0,
amqp_empty_table);
#else
amqp_exchange_declare(profile->conn_active->state, 1,
amqp_cstring_bytes(profile->exchange),
amqp_cstring_bytes(profile->exchange_type),
0, /* passive */
profile->exchange_durable,
amqp_empty_table);
#endif
if (mod_amqp_log_if_amqp_error(amqp_get_rpc_reply(profile->conn_active->state), "Declaring exchange")) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Profile[%s] failed to create exchange\n", profile->name);
goto err;
}
/* We are not going to open the logging queue connection on create, but instead wait for the running thread to open it */
/* Create a bounded FIFO queue for sending messages */
if (switch_queue_create(&(profile->send_queue), profile->send_queue_size, profile->pool) != SWITCH_STATUS_SUCCESS) {

View File

@ -325,33 +325,7 @@ switch_status_t mod_amqp_producer_create(char *name, switch_xml_t cfg)
}
}
profile->conn_active = NULL;
if ( mod_amqp_connection_open(profile->conn_root, &(profile->conn_active), profile->name, profile->custom_attr) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Profile[%s] was unable to connect to any connection\n", profile->name);
goto err;
}
#if AMQP_VERSION_MAJOR == 0 && AMQP_VERSION_MINOR >= 6
amqp_exchange_declare(profile->conn_active->state, 1,
amqp_cstring_bytes(profile->exchange),
amqp_cstring_bytes(profile->exchange_type),
0, /* passive */
profile->exchange_durable,
profile->exchange_auto_delete,
0,
amqp_empty_table);
#else
amqp_exchange_declare(profile->conn_active->state, 1,
amqp_cstring_bytes(profile->exchange),
amqp_cstring_bytes(profile->exchange_type),
0, /* passive */
profile->exchange_durable,
amqp_empty_table);
#endif
if (mod_amqp_log_if_amqp_error(amqp_get_rpc_reply(profile->conn_active->state), "Declaring exchange\n")) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Profile[%s] failed to create exchange\n", profile->name);
goto err;
}
/* We are not going to open the producer queue connection on create, but instead wait for the running thread to open it */
/* Create a bounded FIFO queue for sending messages */
if (switch_queue_create(&(profile->send_queue), profile->send_queue_size, profile->pool) != SWITCH_STATUS_SUCCESS) {

View File

@ -324,7 +324,7 @@ static void event_handler(switch_event_t *event)
&tmplen, (unsigned char *) MAGIC, (int) strlen((char *) MAGIC));
outlen += tmplen;
EVP_EncryptFinal(ctx, (unsigned char *) buf + SWITCH_UUID_FORMATTED_LENGTH + outlen, &tmplen);
EVP_CIPHER_CTX_cleanup(ctx);
EVP_CIPHER_CTX_free(ctx);
#else
EVP_CIPHER_CTX_init(&ctx);
EVP_EncryptInit(&ctx, EVP_bf_cbc(), NULL, NULL);
@ -577,7 +577,7 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_event_multicast_runtime)
EVP_DecryptInit(ctx, NULL, (unsigned char *) globals.psk, (unsigned char *) uuid_str);
EVP_DecryptUpdate(ctx, (unsigned char *) tmp, &outl, (unsigned char *) packet, (int) len);
EVP_DecryptFinal(ctx, (unsigned char *) tmp + outl, &tmplen);
EVP_CIPHER_CTX_cleanup(ctx);
EVP_CIPHER_CTX_free(ctx);
#else
EVP_CIPHER_CTX_init(&ctx);
EVP_DecryptInit(&ctx, EVP_bf_cbc(), NULL, NULL);

View File

@ -375,6 +375,9 @@ static void event_handler(switch_event_t *event)
if (!uuid || (l->session && strcmp(uuid, switch_core_session_get_uuid(l->session)))) {
send = 0;
}
if (!strcmp(switch_core_session_get_uuid(l->session), switch_event_get_header_nil(event, "Job-Owner-UUID"))) {
send = 1;
}
}
if (send) {
@ -1499,6 +1502,7 @@ struct api_command_struct {
listener_t *listener;
char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
int bg;
char bg_owner_uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
int ack;
int console_execute;
switch_memory_pool_t *pool;
@ -1557,6 +1561,7 @@ static void *SWITCH_THREAD_FUNC api_exec(switch_thread_t *thread, void *obj)
if (switch_event_create(&event, SWITCH_EVENT_BACKGROUND_JOB) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Job-UUID", acs->uuid_str);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Job-Owner-UUID", acs->bg_owner_uuid_str);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Job-Command", acs->api_cmd);
if (acs->arg) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Job-Command-Arg", acs->arg);
@ -2357,6 +2362,7 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even
switch_uuid_get(&uuid);
switch_uuid_format(acs->uuid_str, &uuid);
}
switch_copy_string(acs->bg_owner_uuid_str, switch_core_session_get_uuid(listener->session), sizeof(acs->bg_owner_uuid_str));
switch_snprintf(reply, reply_len, "~Reply-Text: +OK Job-UUID: %s\nJob-UUID: %s\n\n", acs->uuid_str, acs->uuid_str);
switch_thread_create(&thread, thd_attr, api_exec, acs, acs->pool);
sanity = 2000;
@ -2631,11 +2637,18 @@ static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj)
if ((session = listener->session)) {
if (switch_core_session_read_lock(session) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Unable to lock session!\n");
locked = 0;
goto done;
}
}
if (!listener->sock) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Listener socket is null!\n");
switch_clear_flag_locked(listener, LFLAG_RUNNING);
goto done;
}
switch_socket_opt_set(listener->sock, SWITCH_SO_TCP_NODELAY, TRUE);
switch_socket_opt_set(listener->sock, SWITCH_SO_NONBLOCK, TRUE);
@ -2928,8 +2941,10 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_event_socket_runtime)
while (!prefs.done) {
rv = switch_sockaddr_info_get(&sa, prefs.ip, SWITCH_UNSPEC, prefs.port, 0, pool);
if (rv)
if (rv) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot get information about IP address %s\n", prefs.ip);
goto fail;
}
rv = switch_socket_create(&listen_list.sock, switch_sockaddr_get_family(sa), SOCK_STREAM, SWITCH_PROTO_TCP, pool);
if (rv)
goto sock_fail;

View File

@ -516,8 +516,9 @@ SWITCH_STANDARD_API(exec_api_cmd)
return SWITCH_STATUS_SUCCESS;
}
void add_cli_api(switch_loadable_module_interface_t **module_interface, switch_api_interface_t *api_interface)
void add_cli_api(switch_loadable_module_interface_t **module_interface)
{
switch_api_interface_t *api_interface = NULL;
SWITCH_ADD_API(api_interface, "erlang", KAZOO_DESC, exec_api_cmd, KAZOO_SYNTAX);
switch_console_set_complete("add erlang status");
switch_console_set_complete("add erlang event_filter");

View File

@ -104,7 +104,8 @@ static void process_history_item(char* value, cJSON *json)
switch_safe_free(item);
}
SWITCH_STANDARD_API(kz_json_history) {
SWITCH_STANDARD_API(kz_json_history)
{
char *mycmd = NULL, *argv[MAX_HISTORY] = { 0 };
int n, argc = 0;
cJSON *json = cJSON_CreateObject();
@ -145,7 +146,8 @@ SWITCH_STANDARD_API(kz_json_history) {
return SWITCH_STATUS_SUCCESS;
}
SWITCH_STANDARD_API(kz_first_of) {
SWITCH_STANDARD_API(kz_first_of)
{
char delim = '|';
char *mycmd = NULL, *argv[MAX_FIRST_OF] = { 0 };
int n, argc = 0;
@ -498,7 +500,20 @@ done:
return status;
}
void add_kz_commands(switch_loadable_module_interface_t **module_interface, switch_api_interface_t *api_interface) {
SWITCH_STANDARD_API(kz_expand_api)
{
if (!zstr(cmd)) {
char * val = kz_expand(cmd);
stream->write_function(stream, "+OK %s", val);
switch_safe_free(val);
} else {
stream->write_function(stream, "ERR invalid input");
}
return SWITCH_STATUS_SUCCESS;
}
void add_kz_commands(switch_loadable_module_interface_t **module_interface) {
switch_api_interface_t *api_interface = NULL;
SWITCH_ADD_API(api_interface, "kz_uuid_setvar_multi", UUID_SET_DESC, uuid_setvar_multi_function, UUID_MULTISET_SYNTAX);
SWITCH_ADD_API(api_interface, "kz_uuid_setvar_multi_encoded", UUID_SET_DESC, uuid_setvar_multi_encoded_function, UUID_MULTISET_SYNTAX);
switch_console_set_complete("add kz_uuid_setvar_multi ::console::list_uuid");
@ -510,5 +525,6 @@ void add_kz_commands(switch_loadable_module_interface_t **module_interface, swit
SWITCH_ADD_API(api_interface, "kz_http_put", KZ_HTTP_PUT_DESC, kz_http_put, KZ_HTTP_PUT_SYNTAX);
SWITCH_ADD_API(api_interface, "first-of", KZ_FIRST_OF_DESC, kz_first_of, KZ_FIRST_OF_SYNTAX);
SWITCH_ADD_API(api_interface, "kz_json_history", KZ_FIRST_OF_DESC, kz_json_history, KZ_FIRST_OF_SYNTAX);
SWITCH_ADD_API(api_interface, "kz_expand", KZ_FIRST_OF_DESC, kz_expand_api, KZ_FIRST_OF_SYNTAX);
}

View File

@ -0,0 +1,9 @@
#ifndef KAZOO_DEFS_H_
#define KAZOO_DEFS_H_
#define INTERACTION_VARIABLE "Call-Interaction-ID"
#define UNIX_EPOCH_IN_GREGORIAN 62167219200
#define UNIX_EPOCH_IN_GREGORIAN_STR "62167219200"
#endif /* KAZOO_DEFS_H_ */

View File

@ -891,7 +891,8 @@ SWITCH_STANDARD_APP(kz_att_xfer_function)
}
}
void add_kz_dptools(switch_loadable_module_interface_t **module_interface, switch_application_interface_t *app_interface) {
void add_kz_dptools(switch_loadable_module_interface_t **module_interface) {
switch_application_interface_t *app_interface = NULL;
SWITCH_ADD_APP(app_interface, "kz_set", SET_SHORT_DESC, SET_LONG_DESC, set_function, SET_SYNTAX, SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC);
SWITCH_ADD_APP(app_interface, "kz_set_encoded", SET_SHORT_DESC, SET_LONG_DESC, set_encoded_function, SET_SYNTAX, SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC);
SWITCH_ADD_APP(app_interface, "kz_multiset", MULTISET_SHORT_DESC, MULTISET_LONG_DESC, multiset_function, MULTISET_SYNTAX, SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC);

View File

@ -10,6 +10,8 @@
#define VERSION "mod_kazoo v1.5.0-1 community"
#define KZ_MAX_SEPARATE_STRINGS 10
#define HOSTNAME_MAX 1024
#define NODENAME_MAX 1024
typedef enum {KAZOO_FETCH_PROFILE, KAZOO_EVENT_PROFILE} kazoo_profile_type;
@ -139,25 +141,7 @@ struct ei_xml_agent_s {
};
typedef enum {
KZ_TWEAK_INTERACTION_ID,
KZ_TWEAK_EXPORT_VARS,
KZ_TWEAK_SWITCH_URI,
KZ_TWEAK_REPLACES_CALL_ID,
KZ_TWEAK_LOOPBACK_VARS,
KZ_TWEAK_CALLER_ID,
KZ_TWEAK_TRANSFERS,
KZ_TWEAK_BRIDGE,
KZ_TWEAK_BRIDGE_REPLACES_ALEG,
KZ_TWEAK_BRIDGE_REPLACES_CALL_ID,
KZ_TWEAK_BRIDGE_VARIABLES,
KZ_TWEAK_RESTORE_CALLER_ID_ON_BLIND_XFER,
/* No new flags below this line */
KZ_TWEAK_MAX
} kz_tweak_t;
struct globals_s {
struct kz_globals_s {
switch_memory_pool_t *pool;
switch_atomic_t threads;
switch_socket_t *acceptor;
@ -180,6 +164,7 @@ struct globals_s {
int ei_compat_rel;
char *ip;
char *hostname;
struct hostent* hostname_ent;
char *ei_cookie;
char *ei_nodename;
uint32_t flags;
@ -209,8 +194,8 @@ struct globals_s {
};
typedef struct globals_s globals_t;
extern globals_t kazoo_globals;
typedef struct kz_globals_s kz_globals_t;
extern kz_globals_t kazoo_globals;
/* kazoo_event_stream.c */
ei_event_stream_t *find_event_stream(ei_event_stream_t *event_streams, const erlang_pid *from);
@ -253,7 +238,7 @@ void fetch_config();
switch_status_t kazoo_load_config();
void kazoo_destroy_config();
void kz_set_hostname();
#define _ei_x_encode_string(buf, string) { ei_x_encode_binary(buf, string, strlen(string)); }

View File

@ -95,6 +95,19 @@ static int read_cookie_from_file(char *filename) {
}
}
void kz_set_hostname()
{
if (kazoo_globals.hostname == NULL) {
char hostname[NODENAME_MAX];
memcpy(hostname, switch_core_get_hostname(), NODENAME_MAX);
kazoo_globals.hostname_ent = gethostbyname(hostname);
if(kazoo_globals.hostname_ent != NULL) {
kazoo_globals.hostname = switch_core_strdup(kazoo_globals.pool, kazoo_globals.hostname_ent->h_name);
} else {
kazoo_globals.hostname = switch_core_strdup(kazoo_globals.pool, hostname);
}
}
}
switch_status_t kazoo_ei_config(switch_xml_t cfg) {
switch_xml_t child, param;
@ -211,11 +224,18 @@ switch_status_t kazoo_ei_config(switch_xml_t cfg) {
}
if ((child = switch_xml_child(cfg, "tweaks"))) {
char *default_tweaks = (char *) switch_xml_attr_soft(param, "default");
if (default_tweaks) {
int i, v = switch_true(default_tweaks) ? 1 : 0;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set tweak default : %s\n", default_tweaks);
for (i = 0; i < KZ_TWEAK_MAX; i++) kazoo_globals.tweaks[i] = v;
}
for (param = switch_xml_child(child, "tweak"); param; param = param->next) {
kz_tweak_t tweak = KZ_TWEAK_MAX;
char *var = (char *) switch_xml_attr_soft(param, "name");
char *val = (char *) switch_xml_attr_soft(param, "value");
if(var && val && kz_name_tweak(var, &tweak) == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set tweak %s : %s\n", var, val);
if(switch_true(val)) {
kz_set_tweak(tweak);
} else {
@ -230,6 +250,7 @@ switch_status_t kazoo_ei_config(switch_xml_t cfg) {
char *var = (char *) switch_xml_attr_soft(param, "name");
char *val = (char *) switch_xml_attr_soft(param, "value");
if(var && val) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set core variable %s : %s\n", var, val);
switch_core_set_variable(var, val);
}
}

View File

@ -332,8 +332,6 @@ switch_socket_t *create_socket_with_port(switch_memory_pool_t *pool, switch_port
return NULL;
}
switch_getnameinfo(&kazoo_globals.hostname, sa, 0);
if (kazoo_globals.nat_map && switch_nat_get_type()) {
switch_nat_add_mapping(port, SWITCH_NAT_TCP, NULL, SWITCH_FALSE);
}
@ -347,10 +345,9 @@ switch_socket_t *create_socket(switch_memory_pool_t *pool) {
}
switch_status_t create_ei_cnode(const char *ip_addr, const char *name, struct ei_cnode_s *ei_cnode) {
char hostname[EI_MAXHOSTNAMELEN + 1] = "";
char hostname[EI_MAXHOSTNAMELEN + 1];
char nodename[MAXNODELEN + 1];
char cnodename[EI_MAXALIVELEN + 1];
//EI_MAX_COOKIE_SIZE+1
char *atsign;
/* copy the erlang interface nodename into something we can modify */
@ -358,17 +355,13 @@ switch_status_t create_ei_cnode(const char *ip_addr, const char *name, struct ei
if ((atsign = strchr(cnodename, '@'))) {
/* we got a qualified node name, don't guess the host/domain */
snprintf(nodename, MAXNODELEN + 1, "%s", kazoo_globals.ei_nodename);
snprintf(nodename, MAXNODELEN + 1, "%s", name);
/* truncate the alivename at the @ */
*atsign = '\0';
*atsign++ = '\0';
strncpy(hostname, atsign, EI_MAXHOSTNAMELEN);
} else {
if (zstr(kazoo_globals.hostname) || !strncasecmp(kazoo_globals.ip, "0.0.0.0", 7) || !strncasecmp(kazoo_globals.ip, "::", 2)) {
memcpy(hostname, switch_core_get_hostname(), EI_MAXHOSTNAMELEN);
} else {
memcpy(hostname, kazoo_globals.hostname, EI_MAXHOSTNAMELEN);
}
snprintf(nodename, MAXNODELEN + 1, "%s@%s", kazoo_globals.ei_nodename, hostname);
strncpy(hostname, kazoo_globals.hostname, EI_MAXHOSTNAMELEN);
snprintf(nodename, MAXNODELEN + 1, "%s@%s", name, hostname);
}
if (kazoo_globals.ei_shortname) {
@ -378,6 +371,8 @@ switch_status_t create_ei_cnode(const char *ip_addr, const char *name, struct ei
}
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "creating nodename: %s\n", nodename);
/* init the ec stuff */
if (ei_connect_xinit(ei_cnode, hostname, cnodename, nodename, (Erl_IpAddr) ip_addr, kazoo_globals.ei_cookie, 0) < 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to initialize the erlang interface connection structure\n");
@ -866,7 +861,8 @@ static void fetch_config_filters(switch_memory_pool_t *pool)
if (!(xml = switch_xml_open_cfg(cf, &cfg, params))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to open configuration file %s\n", cf);
} else if ((child = switch_xml_child(cfg, "event-filter"))) {
} else {
if ((child = switch_xml_child(cfg, "event-filter"))) {
switch_hash_t *filter;
switch_hash_t *old_filter;
@ -881,9 +877,10 @@ static void fetch_config_filters(switch_memory_pool_t *pool)
if (old_filter) {
switch_core_hash_destroy(&old_filter);
}
}
kazoo_globals.config_fetched = 1;
switch_xml_free(xml);
kazoo_globals.config_fetched = 1;
switch_xml_free(xml);
}
}

View File

@ -32,34 +32,75 @@
*/
#include "mod_kazoo.h"
#define INTERACTION_VARIABLE "Call-Interaction-ID"
static const char *x_bridge_variables[] = {
"Call-Control-Queue",
"Call-Control-PID",
"Call-Control-Node",
INTERACTION_VARIABLE,
"ecallmgr_Ecallmgr-Node",
"sip_h_k-cid",
"Switch-URI",
"Switch-URL",
NULL
};
static void kz_tweaks_variables_to_event(switch_core_session_t *session, switch_event_t *event)
{
int i;
switch_channel_t *channel = switch_core_session_get_channel(session);
for(i = 0; x_bridge_variables[i] != NULL; i++) {
const char *val = switch_channel_get_variable_dup(channel, x_bridge_variables[i], SWITCH_FALSE, -1);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, x_bridge_variables[i], val);
}
}
/* kazoo endpoint */
switch_endpoint_interface_t *kz_endpoint_interface;
static switch_call_cause_t kz_endpoint_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);
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);
switch_io_routines_t kz_endpoint_io_routines = {
/*.outgoing_channel */ kz_endpoint_outgoing_channel
};
static switch_call_cause_t kz_endpoint_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)
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)
{
switch_xml_t x_user = NULL, x_param, x_params;
switch_xml_t x_user = NULL, x_param, x_params, x_callfwd;
char *user = NULL, *domain = NULL, *dup_domain = NULL, *dialed_user = NULL;
const char *dest = NULL;
char *dest = NULL;
switch_call_cause_t cause = SWITCH_CAUSE_NONE;
unsigned int timelimit = SWITCH_DEFAULT_TIMEOUT;
switch_channel_t *new_channel = NULL;
switch_event_t *params = NULL, *var_event_orig = var_event;
char stupid[128] = "";
const char *skip = NULL, *var = NULL;
switch_core_session_t *a_session = NULL, *e_session = NULL;
cJSON * ctx = NULL;
const char *endpoint_dial = NULL;
const char *callforward_dial = NULL;
const char *failover_dial = NULL;
char *b_failover_dial = NULL;
const char *endpoint_separator = NULL;
const char *varval = NULL;
char *d_dest = NULL;
switch_channel_t *channel = NULL;
switch_originate_flag_t myflags = SOF_NONE;
char *cid_name_override = NULL;
char *cid_num_override = NULL;
switch_event_t *event = NULL;
switch_status_t status = SWITCH_STATUS_SUCCESS;
if (zstr(outbound_profile->destination_number)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "NO DESTINATION NUMBER\n");
goto done;
}
@ -84,6 +125,9 @@ static switch_call_cause_t kz_endpoint_outgoing_channel(switch_core_session_t *s
switch_assert(params);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "as_channel", "true");
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "action", "user_call");
if (session) {
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "Unique-ID", switch_core_session_get_uuid(session));
}
if (var_event) {
switch_event_merge(params, var_event);
@ -102,162 +146,308 @@ static switch_call_cause_t kz_endpoint_outgoing_channel(switch_core_session_t *s
goto done;
}
if (var_event) {
const char * str_ctx = switch_event_get_header(var_event, "kz-endpoint-runtime-context");
if ( str_ctx ) {
ctx = cJSON_Parse(str_ctx);
if (ctx) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "call context parsed => %s\n", str_ctx);
}
}
}
if ((x_params = switch_xml_child(x_user, "variables"))) {
for (x_param = switch_xml_child(x_params, "variable"); x_param; x_param = x_param->next) {
const char *pvar = switch_xml_attr_soft(x_param, "name");
const char *val = switch_xml_attr(x_param, "value");
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "adding variable to var_event => %s = %s\n", pvar, val);
if (!var_event) {
switch_event_create(&var_event, SWITCH_EVENT_GENERAL);
} else {
switch_event_del_header(var_event, pvar);
}
switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, pvar, val);
}
}
if ((x_params = switch_xml_child(x_user, "params"))) {
for (x_param = switch_xml_child(x_params, "param"); x_param; x_param = x_param->next) {
const char *pvar = switch_xml_attr_soft(x_param, "name");
const char *val = switch_xml_attr(x_param, "value");
if (!strcasecmp(pvar, "dial-string")) {
dest = val;
if (!strcasecmp(pvar, "endpoint-dial-string")) {
endpoint_dial = val;
} else if (!strcasecmp(pvar, "callforward-dial-string")) {
callforward_dial = val;
} else if (!strcasecmp(pvar, "endpoint-separator")) {
endpoint_separator = val;
} else if (!strncasecmp(pvar, "dial-var-", 9)) {
if (!var_event) {
switch_event_create(&var_event, SWITCH_EVENT_GENERAL);
} else {
switch_event_del_header(var_event, pvar + 9);
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG1, "adding variable to var_event => %s = %s\n", pvar + 9, val);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "adding dialog var to var_event => %s = %s\n", pvar + 9, val);
switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, pvar + 9, val);
}
}
}
x_callfwd = switch_xml_child(x_user, "call-forward");
if (x_callfwd) {
switch_bool_t call_fwd_is_substitute = SWITCH_FALSE,
call_fwd_is_failover = SWITCH_FALSE,
call_fwd_direct_calls_only = SWITCH_FALSE,
call_fwd_is_valid = SWITCH_TRUE;
for (x_param = switch_xml_child(x_callfwd, "variable"); x_param; x_param = x_param->next) {
const char *var = switch_xml_attr_soft(x_param, "name");
const char *val = switch_xml_attr(x_param, "value");
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "cfw %s => %s\n", var, val);
if (!strcasecmp(var, "Is-Substitute")) {
call_fwd_is_substitute = switch_true(val);
} else if (!strcasecmp(var, "Is-Failover")) {
call_fwd_is_failover = switch_true(val);
} else if (!strcasecmp(var, "Direct-Calls-Only")) {
call_fwd_direct_calls_only = switch_true(val);
}
}
if (call_fwd_direct_calls_only) {
call_fwd_is_valid = SWITCH_FALSE;
if (ctx ) {
cJSON *json_flags = cJSON_GetObjectItem(ctx, "Flags");
if (json_flags && json_flags->type == cJSON_Array) {
cJSON *item;
cJSON_ArrayForEach(item, json_flags) {
if (!strcmp(item->valuestring, "direct_call")) {
call_fwd_is_valid = SWITCH_TRUE;
break;
}
}
if (!call_fwd_is_valid) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "call fwd requires direct_call and it was not found\n");
}
}
}
}
if (!call_fwd_is_valid) {
dest = strdup(endpoint_dial);
} else if (call_fwd_is_failover) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "setting failover => %s\n", callforward_dial);
dest = strdup(endpoint_dial);
failover_dial = callforward_dial;
} else if (call_fwd_is_substitute) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "setting call fwd substitute => %s\n", callforward_dial);
dest = strdup(callforward_dial);
} else {
dest = switch_mprintf("%s%s%s", endpoint_dial ? endpoint_dial : "", (endpoint_dial ? endpoint_separator ? endpoint_separator : "," : ""), callforward_dial);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "setting call fwd append => %s => %s\n", callforward_dial, dest);
}
} else {
dest = strdup(endpoint_dial);
}
dialed_user = (char *)switch_xml_attr(x_user, "id");
if (var_event) {
switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "dialed_user", dialed_user);
switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "dialed_domain", domain);
if (!zstr(dest) && !strstr(dest, "presence_id=")) {
switch_event_add_header(var_event, SWITCH_STACK_BOTTOM, "presence_id", "%s@%s", dialed_user, domain);
}
}
if (!dest) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No dial-string available, please check your user directory.\n");
cause = SWITCH_CAUSE_MANDATORY_IE_MISSING;
} else {
const char *varval;
char *d_dest = NULL;
switch_channel_t *channel;
switch_originate_flag_t myflags = SOF_NONE;
char *cid_name_override = NULL;
char *cid_num_override = NULL;
goto done;
}
if (var_event) {
cid_name_override = switch_event_get_header(var_event, "origination_caller_id_name");
cid_num_override = switch_event_get_header(var_event, "origination_caller_id_number");
}
if (var_event) {
cid_name_override = switch_event_get_header(var_event, "origination_caller_id_name");
cid_num_override = switch_event_get_header(var_event, "origination_caller_id_number");
}
if (session) {
switch_event_t *event = NULL;
switch_event_create(&event, SWITCH_EVENT_GENERAL);
channel = switch_core_session_get_channel(session);
if ((varval = switch_channel_get_variable(channel, SWITCH_CALL_TIMEOUT_VARIABLE))
|| (var_event && (varval = switch_event_get_header(var_event, "leg_timeout")))) {
timelimit = atoi(varval);
}
switch_channel_event_set_data(channel, event);
if(var_event) {
switch_event_merge(event, var_event);
}
switch_channel_set_variable(channel, "dialed_user", dialed_user);
switch_channel_set_variable(channel, "dialed_domain", domain);
d_dest = switch_event_expand_headers(event, dest);
switch_event_destroy(&event);
} else {
switch_event_t *event = NULL;
if (var_event) {
switch_event_dup(&event, var_event);
switch_event_del_header(event, "dialed_user");
switch_event_del_header(event, "dialed_domain");
if ((varval = switch_event_get_header(var_event, SWITCH_CALL_TIMEOUT_VARIABLE)) ||
(varval = switch_event_get_header(var_event, "leg_timeout"))) {
timelimit = atoi(varval);
}
} else {
switch_event_create(&event, SWITCH_EVENT_REQUEST_PARAMS);
switch_assert(event);
}
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "dialed_user", dialed_user);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "dialed_domain", domain);
d_dest = switch_event_expand_headers(event, dest);
switch_event_destroy(&event);
}
if ((flags & SOF_NO_LIMITS)) {
myflags |= SOF_NO_LIMITS;
}
if ((flags & SOF_FORKED_DIAL)) {
myflags |= SOF_NOBLOCK;
}
switch_snprintf(stupid, sizeof(stupid), "kz/%s", dialed_user);
if (switch_stristr(stupid, d_dest)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Waddya Daft? You almost called '%s' in an infinate loop!\n",
stupid);
cause = SWITCH_CAUSE_INVALID_IE_CONTENTS;
} else if (switch_ivr_originate(session, new_session, &cause, d_dest, timelimit, NULL,
cid_name_override, cid_num_override, outbound_profile, var_event, myflags,
cancel_cause, NULL) == SWITCH_STATUS_SUCCESS) {
const char *context;
switch_caller_profile_t *cp;
if (var_event) {
switch_event_del_header(var_event, "origination_uuid");
}
new_channel = switch_core_session_get_channel(*new_session);
if ((context = switch_channel_get_variable(new_channel, "user_context"))) {
if ((cp = switch_channel_get_caller_profile(new_channel))) {
cp->context = switch_core_strdup(cp->pool, context);
}
}
if ((x_params = switch_xml_child(x_user, "variables"))) {
for (x_param = switch_xml_child(x_params, "variable"); x_param; x_param = x_param->next) {
const char *pvar = switch_xml_attr(x_param, "name");
const char *val = switch_xml_attr(x_param, "value");
switch_channel_set_variable(new_channel, pvar, val);
}
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_DEBUG1, "CHECKING CALLER-ID\n");
if ((x_params = switch_xml_child(x_user, "profile-variables"))) {
switch_caller_profile_t *cp = NULL;
const char* val = NULL;
for (x_param = switch_xml_child(x_params, "variable"); x_param; x_param = x_param->next) {
const char *pvar = switch_xml_attr(x_param, "name");
const char *val = switch_xml_attr(x_param, "value");
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_DEBUG1, "setting profile var %s = %s\n", pvar, val);
switch_channel_set_profile_var(new_channel, pvar, val);
}
cp = switch_channel_get_caller_profile(new_channel);
if((val=switch_caller_get_field_by_name(cp, "Endpoint-Caller-ID-Name"))) {
cp->callee_id_name = val;
cp->orig_caller_id_name = val;
}
if((val=switch_caller_get_field_by_name(cp, "Endpoint-Caller-ID-Number"))) {
cp->callee_id_number = val;
cp->orig_caller_id_number = val;
}
}
switch_core_session_rwunlock(*new_session);
}
if (d_dest != dest) {
switch_safe_free(d_dest);
if(session) {
a_session = session;
} else if(var_event) {
const char* uuid_e_session = switch_event_get_header(var_event, "ent_originate_aleg_uuid");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHECKING ORIGINATE-UUID : %s\n", uuid_e_session);
if (uuid_e_session && (e_session = switch_core_session_force_locate(uuid_e_session)) != NULL) {
a_session = e_session;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "FOUND ORIGINATE-UUID : %s\n", uuid_e_session);
}
}
if (a_session) {
switch_event_create(&event, SWITCH_EVENT_GENERAL);
channel = switch_core_session_get_channel(a_session);
if ((varval = switch_channel_get_variable(channel, SWITCH_CALL_TIMEOUT_VARIABLE))
|| (var_event && (varval = switch_event_get_header(var_event, "leg_timeout")))) {
timelimit = atoi(varval);
}
switch_channel_event_set_data(channel, event);
switch_channel_set_variable(channel, "dialed_user", dialed_user);
switch_channel_set_variable(channel, "dialed_domain", domain);
} else {
if (var_event) {
switch_event_dup(&event, var_event);
switch_event_del_header(event, "dialed_user");
switch_event_del_header(event, "dialed_domain");
if ((varval = switch_event_get_header(var_event, SWITCH_CALL_TIMEOUT_VARIABLE)) ||
(varval = switch_event_get_header(var_event, "leg_timeout"))) {
timelimit = atoi(varval);
}
} else {
switch_event_create(&event, SWITCH_EVENT_REQUEST_PARAMS);
switch_assert(event);
}
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "dialed_user", dialed_user);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "dialed_domain", domain);
}
if ((x_params = switch_xml_child(x_user, "profile-variables"))) {
for (x_param = switch_xml_child(x_params, "variable"); x_param; x_param = x_param->next) {
const char *pvar = switch_xml_attr_soft(x_param, "name");
const char *val = switch_xml_attr(x_param, "value");
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "adding profile variable to event => %s = %s\n", pvar, val);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, pvar, val);
}
}
if ((x_params = switch_xml_child(x_user, "variables"))) {
for (x_param = switch_xml_child(x_params, "variable"); x_param; x_param = x_param->next) {
const char *pvar = switch_xml_attr_soft(x_param, "name");
const char *val = switch_xml_attr(x_param, "value");
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "adding variable to event => %s = %s\n", pvar, val);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, pvar, val);
}
}
if ((x_params = switch_xml_child(x_user, "params"))) {
for (x_param = switch_xml_child(x_params, "param"); x_param; x_param = x_param->next) {
const char *pvar = switch_xml_attr_soft(x_param, "name");
const char *val = switch_xml_attr(x_param, "value");
if (!strncasecmp(pvar, "dial-var-", 9)) {
switch_event_del_header(event, pvar + 9);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "adding dialog var to event => %s = %s\n", pvar + 9, val);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, pvar + 9, val);
}
}
}
// add runtime vars to event for expand
if (ctx) {
kz_expand_json_to_event(ctx, event, "kz_ctx");
}
d_dest = kz_event_expand_headers(event, dest);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "dialing %s => %s\n", dest, d_dest);
if(failover_dial) {
b_failover_dial = kz_event_expand_headers(event, failover_dial);
}
if (var_event) {
kz_expand_headers(event, var_event);
}
switch_event_destroy(&event);
if ((flags & SOF_NO_LIMITS)) {
myflags |= SOF_NO_LIMITS;
}
if ((flags & SOF_FORKED_DIAL)) {
myflags |= SOF_NOBLOCK;
}
if ( a_session ) {
if(var_event) {
kz_tweaks_variables_to_event(a_session, var_event);
}
}
if(e_session) {
switch_core_session_rwunlock(e_session);
}
switch_snprintf(stupid, sizeof(stupid), "kz/%s", dialed_user);
if (switch_stristr(stupid, d_dest)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Waddya Daft? You almost called '%s' in an infinate loop!\n", stupid);
cause = SWITCH_CAUSE_INVALID_IE_CONTENTS;
goto done;
}
status = switch_ivr_originate(session, new_session, &cause, d_dest, timelimit, NULL,
cid_name_override, cid_num_override, outbound_profile, var_event, myflags,
cancel_cause, NULL);
if (status != SWITCH_STATUS_SUCCESS && b_failover_dial) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "trying failover => %s\n", failover_dial);
status = switch_ivr_originate(session, new_session, &cause, b_failover_dial, timelimit, NULL,
cid_name_override, cid_num_override, outbound_profile, var_event, myflags,
cancel_cause, NULL);
}
if (status == SWITCH_STATUS_SUCCESS) {
const char *context;
switch_caller_profile_t *cp;
if (var_event) {
switch_event_del_header(var_event, "origination_uuid");
}
new_channel = switch_core_session_get_channel(*new_session);
if ((context = switch_channel_get_variable(new_channel, "user_context"))) {
if ((cp = switch_channel_get_caller_profile(new_channel))) {
cp->context = switch_core_strdup(cp->pool, context);
}
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_DEBUG1, "CHECKING CALLER-ID\n");
if ((x_params = switch_xml_child(x_user, "profile-variables"))) {
switch_caller_profile_t *cp = NULL;
const char* val = NULL;
for (x_param = switch_xml_child(x_params, "variable"); x_param; x_param = x_param->next) {
const char *pvar = switch_xml_attr(x_param, "name");
const char *val = switch_xml_attr(x_param, "value");
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_DEBUG1, "setting profile var %s = %s\n", pvar, val);
switch_channel_set_profile_var(new_channel, pvar, val);
}
cp = switch_channel_get_caller_profile(new_channel);
if((val=switch_caller_get_field_by_name(cp, "Endpoint-Caller-ID-Name"))) {
cp->callee_id_name = val;
cp->orig_caller_id_name = val;
}
if((val=switch_caller_get_field_by_name(cp, "Endpoint-Caller-ID-Number"))) {
cp->callee_id_number = val;
cp->orig_caller_id_number = val;
}
}
switch_core_session_rwunlock(*new_session);
}
done:
if (d_dest && d_dest != dest) {
switch_safe_free(d_dest);
}
if(b_failover_dial && b_failover_dial != failover_dial) {
switch_safe_free(b_failover_dial);
}
switch_safe_free(dest);
if (ctx) {
cJSON_Delete(ctx);
}
if (x_user) {
switch_xml_free(x_user);
}
@ -272,7 +462,6 @@ static switch_call_cause_t kz_endpoint_outgoing_channel(switch_core_session_t *s
switch_safe_free(user);
switch_safe_free(dup_domain);
return cause;
}

View File

@ -232,7 +232,9 @@ cJSON * kazoo_event_add_field_to_json(cJSON *dst, switch_event_t *src, kazoo_fie
expanded = kz_event_expand_headers(src, field->value);
if(expanded != NULL && !zstr(expanded)) {
item = kazoo_event_add_json_value(dst, field, field->as ? field->as : field->name, expanded);
free(expanded);
if(expanded != field->value) {
free(expanded);
}
}
break;
@ -325,6 +327,21 @@ static switch_status_t kazoo_event_add_fields_to_json(kazoo_logging_ptr logging,
return SWITCH_STATUS_SUCCESS;
}
#define EVENT_TIMESTAMP_FIELD "Event-Date-Timestamp"
#define JSON_TIMESTAMP_FIELD "Event-Timestamp"
static switch_status_t kazoo_event_add_timestamp(switch_event_t* evt, cJSON* JObj)
{
switch_event_header_t *header;
cJSON *item = NULL;
if((header = switch_event_get_header_ptr(evt, EVENT_TIMESTAMP_FIELD)) != NULL) {
if ((item = kazoo_event_json_value(JSON_NUMBER, header->value)) != NULL) {
kazoo_cJSON_AddItemToObject(JObj, JSON_TIMESTAMP_FIELD, item);
return SWITCH_STATUS_SUCCESS;
}
}
return SWITCH_STATUS_NOTFOUND;
}
kazoo_message_ptr kazoo_message_create_event(switch_event_t* evt, kazoo_event_ptr event, kazoo_event_profile_ptr profile)
{
@ -366,6 +383,8 @@ kazoo_message_ptr kazoo_message_create_event(switch_event_t* evt, kazoo_event_pt
kazoo_event_init_json(profile->fields, event ? event->fields : NULL, evt, &JObj);
kazoo_event_add_timestamp(evt, JObj);
if(profile->fields)
kazoo_event_add_fields_to_json(&logging, JObj, evt, profile->fields->head);
@ -402,6 +421,8 @@ kazoo_message_ptr kazoo_message_create_fetch(switch_event_t* evt, kazoo_fetch_pr
kazoo_event_init_json(profile->fields, NULL, evt, &JObj);
kazoo_event_add_timestamp(evt, JObj);
if(profile->fields)
kazoo_event_add_fields_to_json(&logging, JObj, evt, profile->fields->head);

View File

@ -30,9 +30,6 @@
*/
#include "mod_kazoo.h"
#define INTERACTION_VARIABLE "Call-Interaction-ID"
#define BRIDGE_INTERCEPT_VARIABLE "Bridge-Intercepted"
static char *TWEAK_NAMES[] = {
"interaction-id",
"export-vars",
@ -69,7 +66,6 @@ static switch_status_t kz_tweaks_signal_bridge_on_hangup(switch_core_session_t *
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "tweak signal bridge on hangup: %s , %s\n", switch_core_session_get_uuid(session), peer_uuid);
if (switch_event_create(&my_event, SWITCH_EVENT_CHANNEL_UNBRIDGE) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header_string(my_event, SWITCH_STACK_BOTTOM, "Bridge-A-Unique-ID", switch_core_session_get_uuid(session));
switch_event_add_header_string(my_event, SWITCH_STACK_BOTTOM, "Bridge-B-Unique-ID", peer_uuid);
@ -106,7 +102,6 @@ static void kz_tweaks_handle_bridge_variables(switch_event_t *event)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "tweak bridge event handler: variables : %s , %s\n", a_leg, b_leg);
if (a_leg && (a_session = switch_core_session_force_locate(a_leg)) != NULL) {
switch_channel_t *a_channel = switch_core_session_get_channel(a_session);
if(switch_channel_get_variable_dup(a_channel, bridge_variables[0], SWITCH_FALSE, -1) == NULL) {
@ -137,56 +132,91 @@ static void kz_tweaks_handle_bridge_variables(switch_event_t *event)
}
static void kz_tweaks_handle_bridge_intercepted(switch_event_t *event)
static void kz_tweaks_handle_bridge_replaces_aleg(switch_event_t *event)
{
switch_event_t *my_event;
switch_core_session_t *a_session = NULL;
switch_core_session_t *b_session = NULL;
const char *uuid = switch_event_get_header(event, "Unique-ID");
const char *a_leg = switch_event_get_header(event, "Bridge-A-Unique-ID");
const char *b_leg = switch_event_get_header(event, "Bridge-B-Unique-ID");
const char *bridge_intercepted = NULL;
const char *replaced_call_id = switch_event_get_header(event, "variable_sip_replaces_call_id");
const char *a_leg_call_id = switch_event_get_header(event, "variable_sip_replaces_a-leg");
const char *peer_uuid = switch_event_get_header(event, "Unique-ID");
int processed = 0;
if (!kz_test_tweak(KZ_TWEAK_BRIDGE_REPLACES_ALEG)) return;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "tweak bridge event handler: intercepted : %s , %s, %s\n", uuid, a_leg, b_leg);
if(a_leg_call_id && replaced_call_id) {
const char *call_id = switch_event_get_header(event, "Bridge-B-Unique-ID");
switch_core_session_t *session = NULL;
if ((session = switch_core_session_locate(peer_uuid)) != NULL) {
switch_channel_t *channel = switch_core_session_get_channel(session);
processed = switch_true(switch_channel_get_variable_dup(channel, "Bridge-Event-Processed", SWITCH_FALSE, -1));
switch_channel_set_variable(channel, "Bridge-Event-Processed", "true");
switch_core_session_rwunlock(session);
}
if ((a_session = switch_core_session_locate(a_leg)) != NULL) {
switch_channel_t *a_channel = switch_core_session_get_channel(a_session);
bridge_intercepted = switch_channel_get_variable_dup(a_channel, BRIDGE_INTERCEPT_VARIABLE, SWITCH_TRUE, -1);
switch_channel_set_variable(a_channel, BRIDGE_INTERCEPT_VARIABLE, NULL);
if (bridge_intercepted && switch_true(bridge_intercepted)) {
switch_channel_set_variable(a_channel, "Bridge-B-Unique-ID", b_leg);
switch_channel_add_state_handler(a_channel, &kz_tweaks_signal_bridge_state_handlers);
if ((b_session = switch_core_session_locate(b_leg)) != NULL) {
switch_channel_t *b_channel = switch_core_session_get_channel(b_session);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "creating channel_bridge event A - %s , B - %s\n", switch_core_session_get_uuid(b_session), uuid);
if (switch_event_create(&my_event, SWITCH_EVENT_CHANNEL_BRIDGE) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header_string(my_event, SWITCH_STACK_BOTTOM, "Bridge-A-Unique-ID", switch_core_session_get_uuid(b_session));
switch_event_add_header_string(my_event, SWITCH_STACK_BOTTOM, "Bridge-B-Unique-ID", uuid);
switch_channel_event_set_data(b_channel, my_event);
switch_event_fire(&my_event);
if(processed) {
if(call_id) {
if((session = switch_core_session_locate(call_id)) != NULL) {
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_channel_set_variable(channel, "Bridge-Event-Processed", "true");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "creating channel_bridge event A - %s , B - %s\n", switch_core_session_get_uuid(session), peer_uuid);
if (switch_event_create(&my_event, SWITCH_EVENT_CHANNEL_BRIDGE) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header_string(my_event, SWITCH_STACK_BOTTOM, "Bridge-A-Unique-ID", switch_core_session_get_uuid(session));
switch_event_add_header_string(my_event, SWITCH_STACK_BOTTOM, "Bridge-B-Unique-ID", peer_uuid);
switch_channel_event_set_data(channel, my_event);
switch_event_fire(&my_event);
}
switch_channel_set_variable(channel, "Bridge-B-Unique-ID", peer_uuid);
switch_channel_add_state_handler(channel, &kz_tweaks_signal_bridge_state_handlers);
switch_core_session_rwunlock(session);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "invalid session : %s\n", call_id);
DUMP_EVENT(event);
}
switch_core_session_rwunlock(b_session);
}
}
switch_core_session_rwunlock(a_session);
}
switch_safe_strdup(bridge_intercepted);
}
static void kz_tweaks_handle_bridge_replaces_call_id(switch_event_t *event)
{
switch_event_t *my_event;
const char *replaced_call_id = switch_event_get_header(event, "variable_sip_replaces_call_id");
const char *a_leg_call_id = switch_event_get_header(event, "variable_sip_replaces_a-leg");
const char *peer_uuid = switch_event_get_header(event, "Unique-ID");
if (!kz_test_tweak(KZ_TWEAK_BRIDGE_REPLACES_CALL_ID)) return;
if(a_leg_call_id && replaced_call_id) {
switch_core_session_t *call_session = NULL;
const char *call_id = switch_event_get_header(event, "Bridge-B-Unique-ID");
if (call_id && (call_session = switch_core_session_force_locate(call_id)) != NULL) {
switch_channel_t *call_channel = switch_core_session_get_channel(call_session);
if (switch_event_create(&my_event, SWITCH_EVENT_CHANNEL_BRIDGE) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header_string(my_event, SWITCH_STACK_BOTTOM, "Bridge-A-Unique-ID", switch_core_session_get_uuid(call_session));
switch_event_add_header_string(my_event, SWITCH_STACK_BOTTOM, "Bridge-B-Unique-ID", peer_uuid);
switch_channel_event_set_data(call_channel, my_event);
switch_event_fire(&my_event);
}
switch_channel_set_variable(call_channel, "Bridge-B-Unique-ID", peer_uuid);
switch_channel_add_state_handler(call_channel, &kz_tweaks_signal_bridge_state_handlers);
switch_core_session_rwunlock(call_session);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "NOT FOUND : %s\n", call_id);
}
}
}
static void kz_tweaks_channel_bridge_event_handler(switch_event_t *event)
{
const char *uuid = switch_event_get_header(event, "Unique-ID");
if (!kz_test_tweak(KZ_TWEAK_BRIDGE)) return;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "tweak bridge event handler: %s\n", uuid);
kz_tweaks_handle_bridge_intercepted(event);
kz_tweaks_handle_bridge_replaces_call_id(event);
kz_tweaks_handle_bridge_replaces_aleg(event);
kz_tweaks_handle_bridge_variables(event);
}
@ -204,21 +234,12 @@ static void kz_tweaks_channel_replaced_event_handler(switch_event_t *event)
static void kz_tweaks_channel_intercepted_event_handler(switch_event_t *event)
{
switch_core_session_t *uuid_session = NULL;
const char *uuid = switch_event_get_header(event, "Unique-ID");
const char *peer_uuid = switch_event_get_header(event, "intercepted_by");
if (!kz_test_tweak(KZ_TWEAK_TRANSFERS)) return;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "tweak intercepted handler : %s was intercepted by %s\n", uuid, peer_uuid);
if ((uuid_session = switch_core_session_force_locate(peer_uuid)) != NULL) {
switch_channel_t *uuid_channel = switch_core_session_get_channel(uuid_session);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "marking %s for channel_bridge handling\n", peer_uuid);
switch_channel_set_variable(uuid_channel, BRIDGE_INTERCEPT_VARIABLE, "true");
switch_core_session_rwunlock(uuid_session);
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "INTERCEPTED : %s => %s\n", uuid, peer_uuid);
}
static void kz_tweaks_channel_transferor_event_handler(switch_event_t *event)
@ -423,30 +444,6 @@ static void kz_tweaks_handle_caller_id(switch_core_session_t *session)
}
}
/*
static switch_status_t kz_tweaks_handle_auth_token(switch_core_session_t *session)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_event_t *event;
const char *token = switch_channel_get_variable(channel, "sip_h_X-FS-Auth-Token");
if(token) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Authenticating user for nightmare xfer %s\n", token);
if (switch_ivr_set_user(session, token) == SWITCH_STATUS_SUCCESS) {
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_DATA) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(channel, event);
switch_event_fire(&event);
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Authenticated user from nightmare xfer %s\n", token);
} else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Error Authenticating user for nightmare xfer %s\n", token);
}
}
return SWITCH_STATUS_SUCCESS;
}
*/
static switch_status_t kz_tweaks_handle_nightmare_xfer_interaction_id(switch_core_session_t *session)
{
if (kz_test_tweak(KZ_TWEAK_INTERACTION_ID)) {
@ -525,16 +522,26 @@ static switch_status_t kz_tweaks_handle_switch_uri(switch_core_session_t *sessio
}
static char * kz_tweaks_new_interaction_id()
{
long int first = (switch_micro_time_now() / 1000000) + UNIX_EPOCH_IN_GREGORIAN;
char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
switch_uuid_t uuid;
switch_uuid_get(&uuid);
switch_uuid_format(uuid_str, &uuid);
uuid_str[8] = '\0';
return switch_mprintf("%ld-%s", first, uuid_str);
}
static void kz_tweaks_handle_interaction_id(switch_core_session_t *session)
{
const char *expr = "${expr(ceil((${Event-Date-Timestamp} / 1000000) + $${UNIX_EPOCH_IN_GREGORIAN}))}-${regex(${create_uuid()}|^([^-]*)|%1)}";
switch_channel_t *channel = switch_core_session_get_channel(session);
char * val = NULL;
switch_core_session_t *peer_session = NULL;
const char* peer_interaction_id = NULL;
if (kz_test_tweak(KZ_TWEAK_INTERACTION_ID)) {
val = kz_expand(expr);
val = kz_tweaks_new_interaction_id();
if (val) {
switch_channel_set_variable(channel, "Original-"INTERACTION_VARIABLE, val);
if(switch_core_session_get_partner(session, &peer_session) == SWITCH_STATUS_SUCCESS) {
@ -583,32 +590,6 @@ static switch_status_t kz_tweaks_register_handle_blind_xfer(switch_core_session_
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t kz_tweaks_set_export_vars(switch_core_session_t *session)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
const char *exports;
char *var, *new_exports, *new_exports_d = NULL;
if (kz_test_tweak(KZ_TWEAK_EXPORT_VARS)) {
exports = switch_channel_get_variable(channel, SWITCH_EXPORT_VARS_VARIABLE);
var = switch_core_session_strdup(session, "Switch-URI,Switch-URL");
if (exports) {
new_exports_d = switch_mprintf("%s,%s", exports, var);
new_exports = new_exports_d;
} else {
new_exports = var;
}
switch_channel_set_variable(channel, SWITCH_EXPORT_VARS_VARIABLE, new_exports);
switch_safe_free(new_exports_d);
}
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t kz_tweaks_on_init(switch_core_session_t *session)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
@ -618,12 +599,10 @@ static switch_status_t kz_tweaks_on_init(switch_core_session_t *session)
kz_tweaks_handle_interaction_id(session);
kz_tweaks_handle_switch_uri(session);
kz_tweaks_handle_caller_id(session);
// kz_tweaks_handle_auth_token(session);
kz_tweaks_handle_nightmare_xfer_interaction_id(session);
kz_tweaks_handle_replaces_call_id(session);
kz_tweaks_handle_loopback(session);
kz_tweaks_register_handle_blind_xfer(session);
kz_tweaks_set_export_vars(session);
return SWITCH_STATUS_SUCCESS;
}
@ -693,7 +672,7 @@ static void kz_tweaks_unbind_events()
void kz_tweaks_add_core_variables()
{
switch_core_set_variable("UNIX_EPOCH_IN_GREGORIAN", "62167219200");
switch_core_set_variable("UNIX_EPOCH_IN_GREGORIAN", UNIX_EPOCH_IN_GREGORIAN_STR);
}
void kz_tweaks_start()

View File

@ -0,0 +1,32 @@
#pragma once
#include <switch.h>
typedef enum {
KZ_TWEAK_INTERACTION_ID,
KZ_TWEAK_EXPORT_VARS,
KZ_TWEAK_SWITCH_URI,
KZ_TWEAK_REPLACES_CALL_ID,
KZ_TWEAK_LOOPBACK_VARS,
KZ_TWEAK_CALLER_ID,
KZ_TWEAK_TRANSFERS,
KZ_TWEAK_BRIDGE,
KZ_TWEAK_BRIDGE_REPLACES_ALEG,
KZ_TWEAK_BRIDGE_REPLACES_CALL_ID,
KZ_TWEAK_BRIDGE_VARIABLES,
KZ_TWEAK_RESTORE_CALLER_ID_ON_BLIND_XFER,
/* No new flags below this line */
KZ_TWEAK_MAX
} kz_tweak_t;
void kz_tweaks_start();
void kz_tweaks_stop();
SWITCH_DECLARE(const char *) kz_tweak_name(kz_tweak_t tweak);
SWITCH_DECLARE(switch_status_t) kz_name_tweak(const char *name, kz_tweak_t *type);
#define kz_test_tweak(flag) (kazoo_globals.tweaks[flag] ? 1 : 0)
#define kz_set_tweak(flag) kazoo_globals.tweaks[flag] = 1
#define kz_clear_tweak(flag) kazoo_globals.tweaks[flag] = 0

View File

@ -90,15 +90,11 @@ SWITCH_DECLARE(switch_status_t) kz_expand_api_execute(const char *cmd, const cha
switch_assert(stream->data != NULL);
switch_assert(stream->write_function != NULL);
if (strcasecmp(cmd, "console_complete")) {
cmd_used = switch_strip_whitespace(cmd);
arg_used = switch_strip_whitespace(arg);
} else {
cmd_used = (char *) cmd;
arg_used = (char *) arg;
}
cmd_used = switch_strip_whitespace(cmd);
arg_used = switch_strip_whitespace(arg);
if (cmd_used && (api = switch_loadable_module_get_api_interface(cmd_used)) != 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "executing [%s] => [%s]\n", cmd_used, arg_used);
if ((status = api->function(arg_used, session, stream)) != SWITCH_STATUS_SUCCESS) {
stream->write_function(stream, "COMMAND RETURNED ERROR!\n");
}
@ -148,6 +144,7 @@ SWITCH_DECLARE(char *) kz_event_expand_headers_check(switch_event_t *event, cons
nv = 0;
olen = strlen(in) + 1;
indup = strdup(in);
switch_assert(indup);
endof_indup = end_of_p(indup) + 1;
if ((data = malloc(olen))) {
@ -342,46 +339,37 @@ SWITCH_DECLARE(char *) kz_event_expand_headers_check(switch_event_t *event, cons
} else {
switch_stream_handle_t stream = { 0 };
char *expanded = NULL;
char *expanded_vname = NULL;
SWITCH_STANDARD_STREAM(stream);
if (stream.data) {
char *expanded_vname = NULL;
if ((expanded_vname = kz_event_expand_headers_check(event, (char *) vname, var_list, api_list, recur+1)) == vname) {
expanded_vname = NULL;
} else {
vname = expanded_vname;
}
if ((expanded = kz_event_expand_headers_check(event, vval, var_list, api_list, recur+1)) == vval) {
expanded = NULL;
} else {
vval = expanded;
}
if (!switch_core_test_flag(SCF_API_EXPANSION) || (api_list && !switch_event_check_permission_list(api_list, vname))) {
func_val = NULL;
sub_val = "<API execute Permission Denied>";
} else {
stream.param_event = event;
if (kz_expand_api_execute(vname, vval, NULL, &stream) == SWITCH_STATUS_SUCCESS) {
func_val = stream.data;
sub_val = func_val;
} else {
free(stream.data);
}
}
switch_safe_free(expanded);
switch_safe_free(expanded_vname);
if ((expanded_vname = kz_event_expand_headers_check(event, (char *) vname, var_list, api_list, recur+1)) == vname) {
expanded_vname = NULL;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
free(data);
free(indup);
return (char *) in;
vname = expanded_vname;
}
if ((expanded = kz_event_expand_headers_check(event, vval, var_list, api_list, recur+1)) == vval) {
expanded = NULL;
} else {
vval = expanded;
}
if (!switch_core_test_flag(SCF_API_EXPANSION) || (api_list && !switch_event_check_permission_list(api_list, vname))) {
func_val = NULL;
sub_val = "<API execute Permission Denied>";
} else {
stream.param_event = event;
if (kz_expand_api_execute(vname, vval, NULL, &stream) == SWITCH_STATUS_SUCCESS) {
func_val = stream.data;
sub_val = func_val;
} else {
free(stream.data);
}
}
switch_safe_free(expanded);
switch_safe_free(expanded_vname);
}
if ((nlen = sub_val ? strlen(sub_val) : 0)) {
if (len + nlen >= olen) {
@ -435,6 +423,21 @@ SWITCH_DECLARE(char *) kz_event_expand_headers(switch_event_t *event, const char
return kz_event_expand_headers_check(event, in, NULL, NULL, 0);
}
SWITCH_DECLARE(char *) kz_event_expand_headers_pool(switch_memory_pool_t *pool, switch_event_t *event, char *val)
{
char *expanded;
char *dup = NULL;
expanded = kz_event_expand_headers(event, val);
dup = switch_core_strdup(pool, expanded);
if (expanded != val) {
free(expanded);
}
return dup;
}
SWITCH_DECLARE(char *) kz_event_expand(const char *in)
{
switch_event_t *event = NULL;
@ -513,6 +516,32 @@ SWITCH_DECLARE(switch_status_t) kz_switch_event_add_variable_name_printf(switch_
return status;
}
SWITCH_DECLARE(switch_status_t) kz_expand_json_to_event(cJSON *json, switch_event_t *event, char * prefix)
{
char * fmt = switch_mprintf("%s%s%%s", prefix ? prefix : "", prefix ? "_" : "");
if (event) {
cJSON *item = NULL;
char *response = NULL;
cJSON_ArrayForEach(item, json) {
if (item->type == cJSON_String) {
response = strdup(item->valuestring);
} else if (item->type == cJSON_Object) {
char * fmt1 = switch_mprintf(fmt, item->string);
kz_expand_json_to_event(item, event, fmt1);
switch_safe_free(fmt1);
continue;
} else {
response = cJSON_PrintUnformatted(item);
}
kz_switch_event_add_variable_name_printf(event, SWITCH_STACK_BOTTOM, response, fmt, item->string);
switch_safe_free(response);
}
}
switch_safe_free(fmt);
return SWITCH_STATUS_SUCCESS;
}
SWITCH_DECLARE(switch_xml_t) kz_xml_child(switch_xml_t xml, const char *name)
{
xml = (xml) ? xml->child : NULL;
@ -565,6 +594,35 @@ void kz_event_decode(switch_event_t *event)
}
}
void kz_expand_headers(switch_event_t *resolver, switch_event_t *event) {
switch_event_t *clone = NULL;
switch_event_header_t *header = NULL;
switch_event_create_plain(&clone, event->event_id);
for(header = event->headers; header; header = header->next) {
char *expanded = kz_event_expand_headers(resolver, header->value);
if (expanded != header->value) {
switch_event_add_header_string(clone, SWITCH_STACK_BOTTOM, header->name, expanded);
switch_safe_free(expanded);
}
}
/* we don't want to force unique headers
* so we delete and then merge
*/
for(header = clone->headers; header; header = header->next) {
switch_event_del_header(event, header->name);
}
switch_event_merge(event, clone);
switch_event_destroy(&clone);
}
void kz_expand_headers_self(switch_event_t *event) {
kz_expand_headers(event, event);
}
char * kz_expand_vars(char *xml_str) {
return kz_expand_vars_pool(xml_str, NULL);
}

View File

@ -0,0 +1,53 @@
#pragma once
#include <switch.h>
#ifdef __cplusplus
#define KZ_BEGIN_EXTERN_C extern "C" {
#define KZ_END_EXTERN_C }
#else
#define KZ_BEGIN_EXTERN_C
#define KZ_END_EXTERN_C
#endif
KZ_BEGIN_EXTERN_C
void kz_check_set_profile_var(switch_channel_t *channel, char* var, char *val);
SWITCH_DECLARE(switch_status_t) kz_switch_core_merge_variables(switch_event_t *event);
SWITCH_DECLARE(switch_status_t) kz_switch_core_base_headers_for_expand(switch_event_t **event);
SWITCH_DECLARE(switch_status_t) kz_expand_api_execute(const char *cmd, const char *arg, switch_core_session_t *session, switch_stream_handle_t *stream);
SWITCH_DECLARE(char *) kz_event_expand_headers_check(switch_event_t *event, const char *in, switch_event_t *var_list, switch_event_t *api_list, uint32_t recur);
SWITCH_DECLARE(char *) kz_event_expand_headers(switch_event_t *event, const char *in);
SWITCH_DECLARE(char *) kz_event_expand_headers_pool(switch_memory_pool_t *pool, switch_event_t *event, char *val);
SWITCH_DECLARE(char *) kz_event_expand(const char *in);
SWITCH_DECLARE(char *) kz_expand(const char *in);
SWITCH_DECLARE(char *) kz_expand_pool(switch_memory_pool_t *pool, const char *in);
char* kz_switch_event_get_first_of(switch_event_t *event, const char *list[]);
SWITCH_DECLARE(switch_status_t) kz_switch_event_add_variable_name_printf(switch_event_t *event, switch_stack_t stack, const char *val, const char *fmt, ...);
SWITCH_DECLARE(switch_xml_t) kz_xml_child(switch_xml_t xml, const char *name);
void kz_xml_process(switch_xml_t cfg);
void kz_event_decode(switch_event_t *event);
char * kz_expand_vars(char *xml_str);
void kz_expand_headers(switch_event_t *resolver, switch_event_t *event);
void kz_expand_headers_self(switch_event_t *event);
char * kz_expand_vars_pool(char *xml_str, switch_memory_pool_t *pool);
switch_status_t kz_json_api(const char * command, cJSON *args, cJSON **res);
SWITCH_DECLARE(switch_status_t) kz_expand_json_to_event(cJSON *json, switch_event_t *event, char * prefix);
KZ_END_EXTERN_C

View File

@ -86,6 +86,6 @@ SWITCH_STANDARD_JSON_API(kz_node_info_json_function)
void add_kz_node(switch_loadable_module_interface_t **module_interface)
{
switch_json_api_interface_t *json_api_interface = NULL;
switch_json_api_interface_t *json_api_interface = NULL;
SWITCH_ADD_JSON_API(json_api_interface, "node.info", "JSON node API", kz_node_info_json_function, "");
}

View File

@ -32,23 +32,17 @@
*/
#include "mod_kazoo.h"
globals_t kazoo_globals = {0};
kz_globals_t kazoo_globals = {0};
SWITCH_MODULE_DEFINITION(mod_kazoo, mod_kazoo_load, mod_kazoo_shutdown, mod_kazoo_runtime);
SWITCH_MODULE_LOAD_FUNCTION(mod_kazoo_load) {
switch_api_interface_t *api_interface = NULL;
switch_application_interface_t *app_interface = NULL;
memset(&kazoo_globals, 0, sizeof(kazoo_globals));
kazoo_globals.pool = pool;
kazoo_globals.ei_nodes = NULL;
// ensure epmd is running
kz_set_hostname();
if(kazoo_load_config() != SWITCH_STATUS_SUCCESS) {
// TODO: what would we need to clean up here?
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Improper configuration!\n");
@ -66,13 +60,13 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_kazoo_load) {
bind_fetch_agents();
/* create an api for cli debug commands */
add_cli_api(module_interface, api_interface);
add_cli_api(module_interface);
/* add our modified commands */
add_kz_commands(module_interface, api_interface);
add_kz_commands(module_interface);
/* add our modified dptools */
add_kz_dptools(module_interface, app_interface);
add_kz_dptools(module_interface);
/* add our endpoints */
add_kz_endpoints(module_interface);

View File

@ -17,8 +17,11 @@
extern const char kz_default_config[];
extern const int kz_default_config_size;
#include "kazoo_defs.h"
#include "kazoo_tweaks.h"
#include "kazoo_ei.h"
#include "kazoo_message.h"
#include "kazoo_utils.h"
typedef enum {
LFLAG_RUNNING = (1 << 0)
@ -26,16 +29,17 @@ typedef enum {
/* kazoo_commands.c */
void add_kz_commands(switch_loadable_module_interface_t **module_interface, switch_api_interface_t *api_interface);
void add_kz_commands(switch_loadable_module_interface_t **module_interface);
/* kazoo_dptools.c */
void add_kz_dptools(switch_loadable_module_interface_t **module_interface, switch_application_interface_t *app_interface);
void add_kz_dptools(switch_loadable_module_interface_t **module_interface);
/* kazoo_api.c */
void add_cli_api(switch_loadable_module_interface_t **module_interface, switch_api_interface_t *api_interface);
void add_cli_api(switch_loadable_module_interface_t **module_interface);
void remove_cli_api();
/* kazoo_utils.c */
/*
SWITCH_DECLARE(switch_status_t) kz_switch_core_merge_variables(switch_event_t *event);
SWITCH_DECLARE(switch_status_t) kz_switch_core_base_headers_for_expand(switch_event_t **event);
void kz_check_set_profile_var(switch_channel_t *channel, char* var, char *val);
@ -49,6 +53,7 @@ SWITCH_DECLARE(char *) kz_event_expand_headers(switch_event_t *event, const char
SWITCH_DECLARE(char *) kz_expand(const char *in);
SWITCH_DECLARE(char *) kz_expand_pool(switch_memory_pool_t *pool, const char *in);
switch_status_t kz_json_api(const char * command, cJSON *args, cJSON **res);
*/
/* kazoo_endpoints.c */
void add_kz_endpoints(switch_loadable_module_interface_t **module_interface);

View File

@ -112,15 +112,15 @@ switch_status_t mod_smpp_gateway_authenticate(mod_smpp_gateway_t *gateway) {
strncpy( (char *)req_b->address_range, gateway->host, sizeof(req_b->address_range));
if ( gateway->system_id ) {
strncpy((char *)req_b->system_id, gateway->system_id, sizeof(req_b->system_id));
snprintf((char *)req_b->system_id, sizeof(req_b->system_id), "%s", gateway->system_id);
}
if ( gateway->password ) {
strncpy((char *)req_b->password, gateway->password, sizeof(req_b->password));
snprintf((char *)req_b->password, sizeof(req_b->password), "%s", gateway->password);
}
if ( gateway->system_type ) {
strncpy((char *)req_b->system_type, gateway->system_type, sizeof(req_b->system_type));
snprintf((char *)req_b->system_type, sizeof(req_b->system_type), "%s", gateway->system_type);
}
req_b->interface_version = SMPP_VERSION;

View File

@ -117,21 +117,19 @@ static switch_status_t sndfile_file_open(switch_file_handle_t *handle, const cha
context->sfinfo.format |= map->format;
}
if (!strcmp(ext, "r8") || !strcmp(ext, "raw")) {
if (!strcmp(ext, "raw")) {
context->sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_PCM_16;
} else if (!strcmp(ext, "r8")) {
context->sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_PCM_16;
context->sfinfo.channels = 1;
context->sfinfo.samplerate = 8000;
} else if (!strcmp(ext, "r16")) {
context->sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_PCM_16;
context->sfinfo.channels = 1;
context->sfinfo.samplerate = 16000;
} else if (!strcmp(ext, "r24")) {
context->sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_PCM_24;
context->sfinfo.channels = 1;
context->sfinfo.samplerate = 24000;
} else if (!strcmp(ext, "r32")) {
context->sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_PCM_32;
context->sfinfo.channels = 1;
context->sfinfo.samplerate = 32000;
} else if (!strcmp(ext, "gsm")) {
context->sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_GSM610;
@ -269,7 +267,9 @@ static switch_status_t sndfile_file_close(switch_file_handle_t *handle)
{
sndfile_context *context = handle->private_info;
sf_close(context->handle);
if (context) {
sf_close(context->handle);
}
return SWITCH_STATUS_SUCCESS;
}

View File

@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 3.0.10
* Version 3.0.12
*
* 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
@ -9923,7 +9923,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_device_node_t_xml_
}
SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_device_node_t__event_set___(void * jarg1, void * jarg2) {
SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_device_node_t_event__set___(void * jarg1, void * jarg2) {
device_uuid_node_s *arg1 = (device_uuid_node_s *) 0 ;
switch_event_t *arg2 = (switch_event_t *) 0 ;
@ -9933,7 +9933,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_device_node_t__event
}
SWIGEXPORT void * SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_device_node_t__event_get___(void * jarg1) {
SWIGEXPORT void * SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_device_node_t_event__get___(void * jarg1) {
void * jresult ;
device_uuid_node_s *arg1 = (device_uuid_node_s *) 0 ;
switch_event_t *result = 0 ;
@ -14573,6 +14573,22 @@ SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_core_hash_destroy___(
}
SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_core_hash_insert_auto_free___(void * jarg1, char * jarg2, void * jarg3) {
int jresult ;
switch_hash_t *arg1 = (switch_hash_t *) 0 ;
char *arg2 = (char *) 0 ;
void *arg3 = (void *) 0 ;
switch_status_t result;
arg1 = (switch_hash_t *)jarg1;
arg2 = (char *)jarg2;
arg3 = (void *)jarg3;
result = (switch_status_t)switch_core_hash_insert_auto_free(arg1,(char const *)arg2,(void const *)arg3);
jresult = (int)result;
return jresult;
}
SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_core_hash_insert_destructor___(void * jarg1, char * jarg2, void * jarg3, void * jarg4) {
int jresult ;
switch_hash_t *arg1 = (switch_hash_t *) 0 ;
@ -18603,6 +18619,16 @@ SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_core_session_start_te
}
SWIGEXPORT char * SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_core_get_event_channel_key_separator___() {
char * jresult ;
char *result = 0 ;
result = (char *)switch_core_get_event_channel_key_separator();
jresult = SWIG_csharp_string_callback((const char *)result);
return jresult;
}
SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_loadable_module_interface_module_name_set___(void * jarg1, char * jarg2) {
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
char *arg2 = (char *) 0 ;
@ -28639,7 +28665,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_file_handle_max_sampl
}
SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_file_handle__params_set___(void * jarg1, void * jarg2) {
SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_file_handle_params__set___(void * jarg1, void * jarg2) {
switch_file_handle *arg1 = (switch_file_handle *) 0 ;
switch_event_t *arg2 = (switch_event_t *) 0 ;
@ -28649,7 +28675,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_file_handle__params_
}
SWIGEXPORT void * SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_file_handle__params_get___(void * jarg1) {
SWIGEXPORT void * SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_file_handle_params__get___(void * jarg1) {
void * jresult ;
switch_file_handle *arg1 = (switch_file_handle *) 0 ;
switch_event_t *result = 0 ;
@ -43480,6 +43506,20 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_dial_leg_get_vars_
}
SWIGEXPORT char * SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_dial_leg_get_var___(void * jarg1, char * jarg2) {
char * jresult ;
switch_dial_leg_t *arg1 = (switch_dial_leg_t *) 0 ;
char *arg2 = (char *) 0 ;
char *result = 0 ;
arg1 = (switch_dial_leg_t *)jarg1;
arg2 = (char *)jarg2;
result = (char *)switch_dial_leg_get_var(arg1,(char const *)arg2);
jresult = SWIG_csharp_string_callback((const char *)result);
return jresult;
}
SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_dial_handle_get_total___(void * jarg1) {
int jresult ;
switch_dial_handle_t *arg1 = (switch_dial_handle_t *) 0 ;
@ -43492,15 +43532,21 @@ SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_dial_handle_get_total
}
SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_ivr_orig_and_bridge___(void * jarg1, char * jarg2, void * jarg3) {
SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_ivr_orig_and_bridge___(void * jarg1, char * jarg2, void * jarg3, void * jarg4) {
int jresult ;
switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
char *arg2 = (char *) 0 ;
switch_dial_handle_t *arg3 = (switch_dial_handle_t *) 0 ;
switch_call_cause_t *arg4 = (switch_call_cause_t *) 0 ;
switch_status_t result;
arg1 = (switch_core_session_t *)jarg1;
arg2 = (char *)jarg2;
arg3 = (switch_dial_handle_t *)jarg3;
switch_ivr_orig_and_bridge(arg1,(char const *)arg2,arg3);
arg4 = (switch_call_cause_t *)jarg4;
result = (switch_status_t)switch_ivr_orig_and_bridge(arg1,(char const *)arg2,arg3,arg4);
jresult = (int)result;
return jresult;
}

File diff suppressed because it is too large Load Diff

View File

@ -119,7 +119,7 @@ static switch_status_t play_group(switch_say_method_t method, switch_say_gender_
}
}
if (c || ((ftdNumber == 1 && (a || b || c)) && (a && (b || c)))) {
if (c || ((ftdNumber == 1 && (a || b || c)) && (a && (b || c))) || (a == 0 && b == 1 && c == 0) ) {
/*switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "a=%d b=[%d] c=%d\n",a, b,c);*/
int fVal = c;
if (ftdNumber == 1)

View File

@ -2369,6 +2369,20 @@ static void switch_load_core_config(const char *file)
} else {
switch_clear_flag((&runtime), SCF_EVENT_CHANNEL_ENABLE_HIERARCHY_DELIVERY);
}
} else if (!strcasecmp(var, "event-channel-hierarchy-deliver-once") && !zstr(val)) {
int v = switch_true(val);
if (v) {
switch_set_flag((&runtime), SCF_EVENT_CHANNEL_HIERARCHY_DELIVERY_ONCE);
} else {
switch_clear_flag((&runtime), SCF_EVENT_CHANNEL_HIERARCHY_DELIVERY_ONCE);
}
} else if (!strcasecmp(var, "event-channel-log-undeliverable-json") && !zstr(val)) {
int v = switch_true(val);
if (v) {
switch_set_flag((&runtime), SCF_EVENT_CHANNEL_LOG_UNDELIVERABLE_JSON);
} else {
switch_clear_flag((&runtime), SCF_EVENT_CHANNEL_LOG_UNDELIVERABLE_JSON);
}
}
}
}

View File

@ -91,6 +91,10 @@ SWITCH_DECLARE(void) switch_ssl_destroy_ssl_locks(void)
OPENSSL_free(ssl_mutexes);
ssl_count--;
}
if (ssl_pool) {
switch_core_destroy_memory_pool(&ssl_pool);
}
}
static const EVP_MD *get_evp_by_name(const char *name)

View File

@ -915,6 +915,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_pre_close(switch_file_handle_t
}
switch_clear_flag_locked(fh, SWITCH_FILE_OPEN);
switch_set_flag_locked(fh, SWITCH_FILE_PRE_CLOSED);
if (fh->file_interface->file_pre_close) {
status = fh->file_interface->file_pre_close(fh);
@ -929,8 +930,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_close(switch_file_handle_t *fh)
if (switch_test_flag(fh, SWITCH_FILE_OPEN)) {
status = switch_core_file_pre_close(fh);
} else if (!switch_test_flag(fh, SWITCH_FILE_PRE_CLOSED)) {
return SWITCH_STATUS_FALSE;
}
switch_clear_flag_locked(fh, SWITCH_FILE_PRE_CLOSED);
fh->file_interface->file_close(fh);
if (fh->params) {

View File

@ -55,6 +55,15 @@ SWITCH_DECLARE(switch_status_t) switch_core_hash_destroy(switch_hash_t **hash)
return SWITCH_STATUS_SUCCESS;
}
SWITCH_DECLARE(switch_status_t) switch_core_hash_insert_auto_free(switch_hash_t *hash, const char *key, const void *data)
{
int r = 0;
r = switch_hashtable_insert_destructor(hash, strdup(key), (void *)data, HASHTABLE_FLAG_FREE_KEY | HASHTABLE_FLAG_FREE_VALUE | HASHTABLE_DUP_CHECK, NULL);
return r ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
}
SWITCH_DECLARE(switch_status_t) switch_core_hash_insert_destructor(switch_hash_t *hash, const char *key, const void *data, hashtable_destructor_t destructor)
{
int r = 0;

View File

@ -1127,6 +1127,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf_string(switch_core
int i, argc;
char *argv[256];
int dur_total = 0;
int rate_mult = 8;
switch_codec_implementation_t write_impl = { 0 };
switch_assert(session != NULL);
@ -1156,13 +1159,19 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf_string(switch_core
switch_channel_pre_answer(session->channel);
}
switch_core_session_get_write_impl(session, &write_impl);
if (write_impl.actual_samples_per_second >= 1000) {
rate_mult = (write_impl.actual_samples_per_second / 1000);
}
for (i = 0; i < argc; i++) {
dtmf.duration = switch_core_default_dtmf_duration(0);
dur = switch_core_default_dtmf_duration(0) / 8;
dur = switch_core_default_dtmf_duration(0) / rate_mult;
if ((p = strchr(argv[i], '@'))) {
*p++ = '\0';
if ((dur = atoi(p)) > (int)switch_core_min_dtmf_duration(0) / 8) {
dtmf.duration = dur * 8;
if ((dur = atoi(p)) > (int)switch_core_min_dtmf_duration(0) / rate_mult) {
dtmf.duration = dur * rate_mult;
}
}
@ -1192,14 +1201,14 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf_string(switch_core
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s send dtmf\ndigit=%c ms=%u samples=%u\n",
switch_channel_get_name(session->channel), dtmf.digit, dur, dtmf.duration);
sent++;
dur_total += dtmf.duration + 2000; /* account for 250ms pause */
dur_total += dtmf.duration + (250 * rate_mult); /* account for 250ms pause */
}
}
}
if (dur_total) {
char tmp[32] = "";
switch_snprintf(tmp, sizeof(tmp), "%d", dur_total / 8);
switch_snprintf(tmp, sizeof(tmp), "%d", dur_total / rate_mult);
switch_channel_set_variable(session->channel, "last_dtmf_duration", tmp);
}

View File

@ -14069,7 +14069,9 @@ SWITCH_DECLARE(void) switch_core_media_init(void)
SWITCH_DECLARE(void) switch_core_media_deinit(void)
{
switch_core_destroy_memory_pool(&video_globals.pool);
if (video_globals.pool) {
switch_core_destroy_memory_pool(&video_globals.pool);
}
}
static int payload_number(const char *name)

View File

@ -3822,6 +3822,14 @@ switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_
skip:
if (sql_manager.manage) {
/* Initiate switch_sql_queue_manager */
switch_threadattr_create(&thd_attr, sql_manager.memory_pool);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
switch_threadattr_priority_set(thd_attr, SWITCH_PRI_REALTIME);
switch_core_sqldb_start_thread();
switch_thread_create(&sql_manager.db_thread, thd_attr, switch_core_sql_db_thread, NULL, sql_manager.memory_pool);
/* switch_sql_queue_manager initiated, now we can bind to core_event_handler */
#ifdef SWITCH_SQL_BIND_EVERY_EVENT
switch_event_bind("core_db", SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY, core_event_handler, NULL);
#else
@ -3851,13 +3859,6 @@ switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_
switch_event_bind("core_db", SWITCH_EVENT_NAT, SWITCH_EVENT_SUBCLASS_ANY, core_event_handler, NULL);
switch_event_bind("core_db", SWITCH_EVENT_CODEC, SWITCH_EVENT_SUBCLASS_ANY, core_event_handler, NULL);
#endif
switch_threadattr_create(&thd_attr, sql_manager.memory_pool);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
switch_threadattr_priority_set(thd_attr, SWITCH_PRI_REALTIME);
switch_core_sqldb_start_thread();
switch_thread_create(&sql_manager.db_thread, thd_attr, switch_core_sql_db_thread, NULL, sql_manager.memory_pool);
}
switch_cache_db_release_db_handle(&sql_manager.dbh);

View File

@ -571,9 +571,11 @@ SWITCH_DECLARE(switch_status_t) switch_event_shutdown(void)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Stopping dispatch threads\n");
for(x = 0; x < (uint32_t)DISPATCH_THREAD_COUNT; x++) {
switch_status_t st;
switch_thread_join(&st, EVENT_DISPATCH_QUEUE_THREADS[x]);
for(x = 0; x < (uint32_t)MAX_DISPATCH; x++) {
if (EVENT_DISPATCH_QUEUE_THREADS[x]) {
switch_status_t st;
switch_thread_join(&st, EVENT_DISPATCH_QUEUE_THREADS[x]);
}
}
}
@ -2934,17 +2936,21 @@ static void ecd_deliver(event_channel_data_t **ecdP)
const char *sep = switch_core_get_event_channel_key_separator();
char *x_argv[SWITCH_CHANNEL_DISPATCH_MAX_KEY_PARTS] = { 0 };
int x_argc = switch_separate_string_string(key, (char*) sep, x_argv, SWITCH_CHANNEL_DISPATCH_MAX_KEY_PARTS);
char buf[512];
int i;
char buf[1024];
int i, r;
for(i=x_argc - 1; i > 0; i--) {
int z;
memset(buf, 0, 512);
memset(buf, 0, 1024);
sprintf(buf, "%s", x_argv[0]);
for(z=1; z < i; z++) {
strcat(buf, sep);
strcat(buf, x_argv[z]);
}
t += _switch_event_channel_broadcast(buf, ecd->event_channel, ecd->json, ecd->key, ecd->id);
r = _switch_event_channel_broadcast(buf, ecd->event_channel, ecd->json, ecd->key, ecd->id);
t += r;
if (r && switch_core_test_flag(SCF_EVENT_CHANNEL_HIERARCHY_DELIVERY_ONCE)) {
break;
}
}
} else {
char *p = NULL;
@ -2958,7 +2964,13 @@ static void ecd_deliver(event_channel_data_t **ecdP)
t += _switch_event_channel_broadcast(SWITCH_EVENT_CHANNEL_GLOBAL, ecd->event_channel, ecd->json, ecd->key, ecd->id);
if(t == 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "no subscribers for %s , %s\n", ecd->event_channel, ecd->key);
if (switch_core_test_flag(SCF_EVENT_CHANNEL_LOG_UNDELIVERABLE_JSON)) {
char *json = cJSON_Print(ecd->json);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "no subscribers for %s , %s => %s\n", ecd->event_channel, ecd->key, json);
switch_safe_free(json);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "no subscribers for %s , %s\n", ecd->event_channel, ecd->key);
}
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "delivered to %u subscribers for %s\n", t, ecd->event_channel);
}

View File

@ -1099,7 +1099,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_bridge_bleg(switch_core_session_t *se
switch_channel_clear_flag(channel, CF_ARRANGED_BRIDGE);
return SWITCH_STATUS_FALSE;
} else {
audio_bridge_on_exchange_media(session);
switch_channel_t *channel = switch_core_session_get_channel(session);
if (!switch_channel_test_flag(channel, CF_TRANSFER)) {
audio_bridge_on_exchange_media(session);
}
}
return SWITCH_STATUS_SUCCESS;

View File

@ -4383,6 +4383,12 @@ SWITCH_DECLARE(switch_event_t *) switch_dial_leg_get_vars(switch_dial_leg_t *leg
return leg->leg_vars;
}
SWITCH_DECLARE(const char *) switch_dial_leg_get_var(switch_dial_leg_t *leg, const char *key)
{
switch_assert(leg);
return switch_event_get_header(leg->leg_vars, key);
}
static switch_status_t vars_serialize_json_obj(switch_event_t *event, cJSON **json)
{
@ -4559,32 +4565,31 @@ static switch_status_t o_bridge_on_dtmf(switch_core_session_t *session, void *in
return SWITCH_STATUS_SUCCESS;
}
SWITCH_DECLARE(void) switch_ivr_orig_and_bridge(switch_core_session_t *session, const char *data, switch_dial_handle_t *dh)
SWITCH_DECLARE(switch_status_t) switch_ivr_orig_and_bridge(switch_core_session_t *session, const char *data, switch_dial_handle_t *dh, switch_call_cause_t *cause)
{
switch_channel_t *caller_channel = switch_core_session_get_channel(session);
switch_core_session_t *peer_session = NULL;
switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
switch_status_t status = SWITCH_STATUS_FALSE;
int fail = 0;
if ((status = switch_ivr_originate(session,
&peer_session,
&cause, data, 0, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL, dh)) != SWITCH_STATUS_SUCCESS) {
cause, data, 0, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL, dh)) != SWITCH_STATUS_SUCCESS) {
fail = 1;
}
if (fail) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Originate Failed. Cause: %s\n", switch_channel_cause2str(cause));
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Originate Failed. Cause: %s\n", switch_channel_cause2str(*cause));
switch_channel_set_variable(caller_channel, "originate_failed_cause", switch_channel_cause2str(cause));
switch_channel_set_variable(caller_channel, "originate_failed_cause", switch_channel_cause2str(*cause));
switch_channel_handle_cause(caller_channel, cause);
switch_channel_handle_cause(caller_channel, *cause);
return;
return status;
} else {
switch_channel_t *peer_channel = switch_core_session_get_channel(peer_session);
if (switch_true(switch_channel_get_variable(caller_channel, SWITCH_BYPASS_MEDIA_AFTER_BRIDGE_VARIABLE)) ||
switch_true(switch_channel_get_variable(peer_channel, SWITCH_BYPASS_MEDIA_AFTER_BRIDGE_VARIABLE))) {
switch_channel_set_flag(caller_channel, CF_BYPASS_MEDIA_AFTER_BRIDGE);
@ -4620,6 +4625,8 @@ SWITCH_DECLARE(void) switch_ivr_orig_and_bridge(switch_core_session_t *session,
switch_core_session_rwunlock(peer_session);
}
}
return status;
}

View File

@ -36,8 +36,6 @@
#define MSRP_BUFF_SIZE (SWITCH_RTP_MAX_BUF_LEN - 32)
#define DEBUG_MSRP 0
#define MSRP_LISTEN_PORT 2855
#define MSRP_SSL_LISTEN_PORT 2856
struct msrp_socket_s {
switch_port_t port;
@ -108,6 +106,10 @@ static void msrp_deinit_ssl()
SSL_CTX_free(globals.ssl_ctx);
globals.ssl_ctx = NULL;
}
if (globals.ssl_client_ctx) {
SSL_CTX_free(globals.ssl_client_ctx);
globals.ssl_client_ctx = NULL;
}
}
static void msrp_init_ssl()
@ -293,35 +295,41 @@ SWITCH_DECLARE(switch_status_t) switch_msrp_init()
memset(&globals, 0, sizeof(globals));
set_global_ip("0.0.0.0");
globals.pool = pool;
globals.msock.port = (switch_port_t)MSRP_LISTEN_PORT;
globals.msock_ssl.port = (switch_port_t)MSRP_SSL_LISTEN_PORT;
globals.msock.port = (switch_port_t)0;
globals.msock_ssl.port = (switch_port_t)0;
globals.msock_ssl.secure = 1;
globals.message_buffer_size = 50;
globals.debug = DEBUG_MSRP;
load_config();
globals.running = 1;
if (globals.msock.port) {
globals.running = 1;
status = msock_init(globals.ip, globals.msock.port, &globals.msock.sock, pool);
status = msock_init(globals.ip, globals.msock.port, &globals.msock.sock, pool);
if (status == SWITCH_STATUS_SUCCESS) {
switch_threadattr_create(&thd_attr, pool);
// switch_threadattr_detach_set(thd_attr, 1);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
switch_thread_create(&thread, thd_attr, msrp_listener, &globals.msock, pool);
globals.msock.thread = thread;
if (status == SWITCH_STATUS_SUCCESS) {
switch_threadattr_create(&thd_attr, pool);
// switch_threadattr_detach_set(thd_attr, 1);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
switch_thread_create(&thread, thd_attr, msrp_listener, &globals.msock, pool);
globals.msock.thread = thread;
}
}
msrp_init_ssl();
status = msock_init(globals.ip, globals.msock_ssl.port, &globals.msock_ssl.sock, pool);
if (globals.msock_ssl.port) {
globals.running = 1;
if (status == SWITCH_STATUS_SUCCESS) {
switch_threadattr_create(&thd_attr, pool);
// switch_threadattr_detach_set(thd_attr, 1);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
switch_thread_create(&thread, thd_attr, msrp_listener, &globals.msock_ssl, pool);
globals.msock_ssl.thread = thread;
msrp_init_ssl();
status = msock_init(globals.ip, globals.msock_ssl.port, &globals.msock_ssl.sock, pool);
if (status == SWITCH_STATUS_SUCCESS) {
switch_threadattr_create(&thd_attr, pool);
// switch_threadattr_detach_set(thd_attr, 1);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
switch_thread_create(&thread, thd_attr, msrp_listener, &globals.msock_ssl, pool);
globals.msock_ssl.thread = thread;
}
}
return SWITCH_STATUS_SUCCESS;
@ -407,7 +415,7 @@ SWITCH_DECLARE(switch_status_t) switch_msrp_session_destroy(switch_msrp_session_
switch_status_t switch_msrp_session_push_msg(switch_msrp_session_t *ms, switch_msrp_msg_t *msg)
{
switch_mutex_lock(ms->mutex);
if (ms->last_msg == NULL) {
ms->last_msg = msg;
ms->msrp_msg = msg;

View File

@ -9039,7 +9039,6 @@ SWITCH_DECLARE(int) switch_rtp_write_frame(switch_rtp_t *rtp_session, switch_fra
data = frame->data;
len = frame->datalen;
ts = rtp_session->flags[SWITCH_RTP_FLAG_RAW_WRITE] ? (uint32_t) frame->timestamp : 0;
if (!ts) ts = rtp_session->last_write_ts + rtp_session->samples_per_interval;
}
/*

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