diff --git a/.gitignore b/.gitignore
index 1fc3016d3f..5da9566192 100644
--- a/.gitignore
+++ b/.gitignore
@@ -42,6 +42,12 @@ configure.lineno
config.log
config.status
core.*
+*.2010.log
+*.Build.CppClean.log
+*.tlog
+*.unsuccessfulbuild
+*.cache
+*.lastbuildstate
/w32/Library/lastversion
/w32/Library/tmpVersion.Bat
@@ -83,6 +89,7 @@ core.*
/build/config/missing
/build/freeswitch.pc
/build/getlib.sh
+/build/getg729.sh
/build/getsounds.sh
/build/Makefile
/build/Makefile.in
@@ -104,6 +111,7 @@ core.*
/libs/freetdm/testtones
/libs/fsg729-*-installer
/libs/g729/
+/libs/libcodec2/compile
/libs/libcodec2/config.guess
/libs/libcodec2/config.sub
/libs/libcodec2/configure
@@ -118,6 +126,7 @@ core.*
/libs/libcodec2/src/Makefile.in
/libs/libcodec2/unittest/Makefile
/libs/libcodec2/unittest/Makefile.in
+/libs/mpg123-1.13.2/
/scripts/fsxs
/scripts/gentls_cert
@@ -147,3 +156,17 @@ core.*
/src/mod/say/mod_say_th/Makefile
/src/mod/say/mod_say_zh/Makefile
+BuildLog.htm
+/w32/Console/Debug/
+/w32/Console/Release/
+/w32/Library/Debug/
+/w32/Library/Release/
+
+Freeswitch.2010.sdf
+
+/Win32/
+/x64/
+
+src/mod/codecs/mod_celt/*/*/mod_celt.log
+src/mod/endpoints/mod_skinny/*/*/mod_skinny_2010.log
+src/mod/formats/mod_shout/*/*/mod_shout.log
diff --git a/Freeswitch.2008.express.sln b/Freeswitch.2008.express.sln
index d9cb441e2f..43cbc02d0e 100644
--- a/Freeswitch.2008.express.sln
+++ b/Freeswitch.2008.express.sln
@@ -9,12 +9,14 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeSwitchConsole", "w32\Co
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeSwitchCoreLib", "w32\Library\FreeSwitchCore.2008.vcproj", "{202D7A4E-760D-4D0E-AFA1-D7459CED30FF}"
ProjectSection(ProjectDependencies) = postProject
+ {D331904D-A00A-4694-A5A3-FCFF64AB5DBE} = {D331904D-A00A-4694-A5A3-FCFF64AB5DBE}
{8D04B550-D240-4A44-8A18-35DA3F7038D9} = {8D04B550-D240-4A44-8A18-35DA3F7038D9}
{89385C74-5860-4174-9CAF-A39E7C48909C} = {89385C74-5860-4174-9CAF-A39E7C48909C}
{1CBB0077-18C5-455F-801C-0A0CE7B0BBF5} = {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}
{F057DA7F-79E5-4B00-845C-EF446EF055E3} = {F057DA7F-79E5-4B00-845C-EF446EF055E3}
{03207781-0D1C-4DB3-A71D-45C608F28DBD} = {03207781-0D1C-4DB3-A71D-45C608F28DBD}
{F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
+ {87EE9DA4-DE1E-4448-8324-183C98DCA588} = {87EE9DA4-DE1E-4448-8324-183C98DCA588}
{EEF031CB-FED8-451E-A471-91EC8D4F6750} = {EEF031CB-FED8-451E-A471-91EC8D4F6750}
{6EDFEFD5-3596-4FA9-8EBA-B331547B35A3} = {6EDFEFD5-3596-4FA9-8EBA-B331547B35A3}
EndProjectSection
@@ -230,12 +232,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_spidermonkey_teletone",
{204FA0DE-305D-4414-AE2E-F195A23F390D} = {204FA0DE-305D-4414-AE2E-F195A23F390D}
EndProjectSection
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libudns", "libs\win32\udns\libudns.2008.vcproj", "{4043FC6A-9A30-4577-8AD5-9B233C9575D8}"
-EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_enum", "src\mod\applications\mod_enum\mod_enum.2008.vcproj", "{71A967D5-0E99-4CEF-A587-98836EE6F2EF}"
ProjectSection(ProjectDependencies) = postProject
+ {23B4D303-79FC-49E0-89E2-2280E7E28940} = {23B4D303-79FC-49E0-89E2-2280E7E28940}
{202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8} = {4043FC6A-9A30-4577-8AD5-9B233C9575D8}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_spidermonkey_odbc", "src\mod\languages\mod_spidermonkey\mod_spidermonkey_odbc.2008.vcproj", "{0A6B5EA5-6E9B-4A51-931F-ED25AA87B4DF}"
@@ -664,6 +664,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_directory", "src\mod\ap
{202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
EndProjectSection
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ldns", "libs\win32\ldns\ldns-lib\ldns-lib.2008.vcproj", "{23B4D303-79FC-49E0-89E2-2280E7E28940}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
All|Win32 = All|Win32
@@ -1139,17 +1141,6 @@ Global
{8F992C49-6C51-412F-B2A3-34EAB708EB65}.Release|Win32.Build.0 = Release|Win32
{8F992C49-6C51-412F-B2A3-34EAB708EB65}.Release|x64.ActiveCfg = Release|x64
{8F992C49-6C51-412F-B2A3-34EAB708EB65}.Release|x64.Build.0 = Release|x64
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8}.All|Win32.ActiveCfg = Release|x64
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8}.All|x64.ActiveCfg = Release|x64
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8}.All|x64.Build.0 = Release|x64
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8}.Debug|Win32.ActiveCfg = Debug|Win32
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8}.Debug|Win32.Build.0 = Debug|Win32
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8}.Debug|x64.ActiveCfg = Debug|Win32
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8}.Debug|x64.Build.0 = Debug|Win32
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8}.Release|Win32.ActiveCfg = Release|Win32
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8}.Release|Win32.Build.0 = Release|Win32
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8}.Release|x64.ActiveCfg = Release|x64
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8}.Release|x64.Build.0 = Release|x64
{71A967D5-0E99-4CEF-A587-98836EE6F2EF}.All|Win32.ActiveCfg = Release|x64
{71A967D5-0E99-4CEF-A587-98836EE6F2EF}.All|x64.ActiveCfg = Release|x64
{71A967D5-0E99-4CEF-A587-98836EE6F2EF}.All|x64.Build.0 = Release|x64
@@ -2137,6 +2128,15 @@ Global
{42E721FD-43D6-4B04-A34B-42567199FFB8}.Debug|x64.ActiveCfg = Debug|Win32
{42E721FD-43D6-4B04-A34B-42567199FFB8}.Release|Win32.ActiveCfg = Release|Win32
{42E721FD-43D6-4B04-A34B-42567199FFB8}.Release|x64.ActiveCfg = Release|Win32
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.All|Win32.ActiveCfg = Release|Win32
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.All|Win32.Build.0 = Release|Win32
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.All|x64.ActiveCfg = Release|Win32
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.Debug|Win32.ActiveCfg = Debug|Win32
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.Debug|Win32.Build.0 = Debug|Win32
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.Debug|x64.ActiveCfg = Debug|Win32
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.Release|Win32.ActiveCfg = Release|Win32
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.Release|Win32.Build.0 = Release|Win32
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.Release|x64.ActiveCfg = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/Freeswitch.2008.sln b/Freeswitch.2008.sln
index e171ffe418..4061116d07 100644
--- a/Freeswitch.2008.sln
+++ b/Freeswitch.2008.sln
@@ -379,12 +379,14 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeSwitchConsole", "w32\Co
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeSwitchCoreLib", "w32\Library\FreeSwitchCore.2008.vcproj", "{202D7A4E-760D-4D0E-AFA1-D7459CED30FF}"
ProjectSection(ProjectDependencies) = postProject
+ {D331904D-A00A-4694-A5A3-FCFF64AB5DBE} = {D331904D-A00A-4694-A5A3-FCFF64AB5DBE}
{8D04B550-D240-4A44-8A18-35DA3F7038D9} = {8D04B550-D240-4A44-8A18-35DA3F7038D9}
{89385C74-5860-4174-9CAF-A39E7C48909C} = {89385C74-5860-4174-9CAF-A39E7C48909C}
{1CBB0077-18C5-455F-801C-0A0CE7B0BBF5} = {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}
{F057DA7F-79E5-4B00-845C-EF446EF055E3} = {F057DA7F-79E5-4B00-845C-EF446EF055E3}
{03207781-0D1C-4DB3-A71D-45C608F28DBD} = {03207781-0D1C-4DB3-A71D-45C608F28DBD}
{F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
+ {87EE9DA4-DE1E-4448-8324-183C98DCA588} = {87EE9DA4-DE1E-4448-8324-183C98DCA588}
{EEF031CB-FED8-451E-A471-91EC8D4F6750} = {EEF031CB-FED8-451E-A471-91EC8D4F6750}
{6EDFEFD5-3596-4FA9-8EBA-B331547B35A3} = {6EDFEFD5-3596-4FA9-8EBA-B331547B35A3}
EndProjectSection
@@ -602,12 +604,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_spidermonkey_teletone",
{204FA0DE-305D-4414-AE2E-F195A23F390D} = {204FA0DE-305D-4414-AE2E-F195A23F390D}
EndProjectSection
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libudns", "libs\win32\udns\libudns.2008.vcproj", "{4043FC6A-9A30-4577-8AD5-9B233C9575D8}"
-EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_enum", "src\mod\applications\mod_enum\mod_enum.2008.vcproj", "{71A967D5-0E99-4CEF-A587-98836EE6F2EF}"
ProjectSection(ProjectDependencies) = postProject
+ {23B4D303-79FC-49E0-89E2-2280E7E28940} = {23B4D303-79FC-49E0-89E2-2280E7E28940}
{202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8} = {4043FC6A-9A30-4577-8AD5-9B233C9575D8}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_spidermonkey_odbc", "src\mod\languages\mod_spidermonkey\mod_spidermonkey_odbc.2008.vcproj", "{0A6B5EA5-6E9B-4A51-931F-ED25AA87B4DF}"
@@ -983,11 +983,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "32khz music", "libs\win32\S
{1F0A8A77-E661-418F-BB92-82172AE43803} = {1F0A8A77-E661-418F-BB92-82172AE43803}
EndProjectSection
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_file_string", "src\mod\formats\mod_file_string\mod_file_string.2008.vcproj", "{70564D74-199A-4452-9C60-19ED5F242F0D}"
- ProjectSection(ProjectDependencies) = postProject
- {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
- EndProjectSection
-EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_nibblebill", "src\mod\applications\mod_nibblebill\mod_nibblebill.2008.vcproj", "{3C977801-FE88-48F2-83D3-FA2EBFF6688E}"
ProjectSection(ProjectDependencies) = postProject
{202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
@@ -1135,6 +1130,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openssl", "libs\win32\opens
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_directory", "src\mod\applications\mod_directory\mod_directory.2008.vcproj", "{42E721FD-43D6-4B04-A34B-42567199FFB8}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ldns", "libs\win32\ldns\ldns-lib\ldns-lib.2008.vcproj", "{23B4D303-79FC-49E0-89E2-2280E7E28940}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
All|Win32 = All|Win32
@@ -1604,17 +1601,6 @@ Global
{8F992C49-6C51-412F-B2A3-34EAB708EB65}.Release|Win32.ActiveCfg = Release|Win32
{8F992C49-6C51-412F-B2A3-34EAB708EB65}.Release|Win32.Build.0 = Release|Win32
{8F992C49-6C51-412F-B2A3-34EAB708EB65}.Release|x64.ActiveCfg = Release|x64
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8}.All|Win32.ActiveCfg = Release|x64
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8}.All|x64.ActiveCfg = Release|x64
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8}.All|x64.Build.0 = Release|x64
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8}.Debug|Win32.ActiveCfg = Debug|Win32
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8}.Debug|Win32.Build.0 = Debug|Win32
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8}.Debug|x64.ActiveCfg = Debug|x64
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8}.Debug|x64.Build.0 = Debug|x64
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8}.Release|Win32.ActiveCfg = Release|Win32
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8}.Release|Win32.Build.0 = Release|Win32
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8}.Release|x64.ActiveCfg = Release|x64
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8}.Release|x64.Build.0 = Release|x64
{71A967D5-0E99-4CEF-A587-98836EE6F2EF}.All|Win32.ActiveCfg = Release|x64
{71A967D5-0E99-4CEF-A587-98836EE6F2EF}.All|x64.ActiveCfg = Release|x64
{71A967D5-0E99-4CEF-A587-98836EE6F2EF}.All|x64.Build.0 = Release|x64
@@ -2501,17 +2487,6 @@ Global
{EED13FC7-4F81-4E6F-93DB-CDB7DF5CF959}.Debug|x64.ActiveCfg = Debug|x64
{EED13FC7-4F81-4E6F-93DB-CDB7DF5CF959}.Release|Win32.ActiveCfg = Release|Win32
{EED13FC7-4F81-4E6F-93DB-CDB7DF5CF959}.Release|x64.ActiveCfg = Release|x64
- {70564D74-199A-4452-9C60-19ED5F242F0D}.All|Win32.ActiveCfg = Release|x64
- {70564D74-199A-4452-9C60-19ED5F242F0D}.All|x64.ActiveCfg = Release|x64
- {70564D74-199A-4452-9C60-19ED5F242F0D}.All|x64.Build.0 = Release|x64
- {70564D74-199A-4452-9C60-19ED5F242F0D}.Debug|Win32.ActiveCfg = Debug|Win32
- {70564D74-199A-4452-9C60-19ED5F242F0D}.Debug|Win32.Build.0 = Debug|Win32
- {70564D74-199A-4452-9C60-19ED5F242F0D}.Debug|x64.ActiveCfg = Debug|x64
- {70564D74-199A-4452-9C60-19ED5F242F0D}.Debug|x64.Build.0 = Debug|x64
- {70564D74-199A-4452-9C60-19ED5F242F0D}.Release|Win32.ActiveCfg = Release|Win32
- {70564D74-199A-4452-9C60-19ED5F242F0D}.Release|Win32.Build.0 = Release|Win32
- {70564D74-199A-4452-9C60-19ED5F242F0D}.Release|x64.ActiveCfg = Release|x64
- {70564D74-199A-4452-9C60-19ED5F242F0D}.Release|x64.Build.0 = Release|x64
{3C977801-FE88-48F2-83D3-FA2EBFF6688E}.All|Win32.ActiveCfg = Release|x64
{3C977801-FE88-48F2-83D3-FA2EBFF6688E}.All|x64.ActiveCfg = Release|x64
{3C977801-FE88-48F2-83D3-FA2EBFF6688E}.All|x64.Build.0 = Release|x64
@@ -2856,6 +2831,17 @@ Global
{42E721FD-43D6-4B04-A34B-42567199FFB8}.Debug|x64.ActiveCfg = Debug|x64
{42E721FD-43D6-4B04-A34B-42567199FFB8}.Release|Win32.ActiveCfg = Release|Win32
{42E721FD-43D6-4B04-A34B-42567199FFB8}.Release|x64.ActiveCfg = Release|x64
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.All|Win32.ActiveCfg = Release|x64
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.All|x64.ActiveCfg = Release|x64
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.All|x64.Build.0 = Release|x64
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.Debug|Win32.ActiveCfg = Debug|Win32
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.Debug|Win32.Build.0 = Debug|Win32
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.Debug|x64.ActiveCfg = Debug|x64
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.Debug|x64.Build.0 = Debug|x64
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.Release|Win32.ActiveCfg = Release|Win32
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.Release|Win32.Build.0 = Release|Win32
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.Release|x64.ActiveCfg = Release|x64
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -2913,7 +2899,6 @@ Global
{2CA40887-1622-46A1-A7F9-17FD7E7E545B} = {A5A27244-AD24-46E5-B01B-840CD296C91D}
{6FF941AC-82C5-429F-AA4C-AD2FB9E5DA52} = {A5A27244-AD24-46E5-B01B-840CD296C91D}
{38FE0559-9910-43A8-9E45-3E5004C27692} = {A5A27244-AD24-46E5-B01B-840CD296C91D}
- {70564D74-199A-4452-9C60-19ED5F242F0D} = {A5A27244-AD24-46E5-B01B-840CD296C91D}
{1A1FF289-4FD6-4285-A422-D31DD67A4723} = {CBD81696-EFB4-4D2F-8451-1B8DAA86155A}
{EC3E5C7F-EE09-47E2-80FE-546363D14A98} = {B8F5B47B-8568-46EB-B320-64C17D2A98BC}
{1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F} = {0C808854-54D1-4230-BFF5-77B5FD905000}
@@ -2948,7 +2933,6 @@ Global
{204FA0DE-305D-4414-AE2E-F195A23F390D} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B}
{70A49BC2-7500-41D0-B75D-EDCC5BE987A0} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B}
{DF018947-0FFF-4EB3-BDEE-441DC81DA7A4} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B}
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B}
{0A18A071-125E-442F-AFF7-A3F68ABECF99} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B}
{D2396DD7-7D38-473A-ABB7-6F96D65AE1B9} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B}
{CEE544A9-0303-44C2-8ECE-EFA7D7BCBBBA} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B}
@@ -2977,6 +2961,7 @@ Global
{9778F1C0-09BC-4698-8EBC-BD982247209A} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B}
{56B91D01-9150-4BBF-AFA1-5B68AB991B76} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B}
{B376D494-D7DD-4B2A-99E2-52916D5A8CD8} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B}
+ {23B4D303-79FC-49E0-89E2-2280E7E28940} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B}
{8B3B4C4C-13C2-446C-BEB0-F412CC2CFB9A} = {C120A020-773F-4EA3-923F-B67AF28B750D}
{4F92B672-DADB-4047-8D6A-4BB3796733FD} = {C120A020-773F-4EA3-923F-B67AF28B750D}
{2DEE4895-1134-439C-B688-52203E57D878} = {C120A020-773F-4EA3-923F-B67AF28B750D}
diff --git a/Freeswitch.2010.express.sln b/Freeswitch.2010.express.sln
index e999721ba8..b0df7d9c35 100644
--- a/Freeswitch.2010.express.sln
+++ b/Freeswitch.2010.express.sln
@@ -54,6 +54,9 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libsqlite", "libs\win32\sqlite\sqlite.2010.vcxproj", "{6EDFEFD5-3596-4FA9-8EBA-B331547B35A3}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libpcre", "libs\win32\pcre\libpcre.2010.vcxproj", "{8D04B550-D240-4A44-8A18-35DA3F7038D9}"
+ ProjectSection(ProjectDependencies) = postProject
+ {1CED5987-A529-46DC-B30F-870D85FF9C94} = {1CED5987-A529-46DC-B30F-870D85FF9C94}
+ EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libapr", "libs\win32\apr\libapr.2010.vcxproj", "{F6C55D93-B927-4483-BB69-15AEF3DD2DFF}"
EndProject
@@ -85,8 +88,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_spidermonkey_core_db",
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_spidermonkey_teletone", "src\mod\languages\mod_spidermonkey\mod_spidermonkey_teletone.2010.vcxproj", "{8F992C49-6C51-412F-B2A3-34EAB708EB65}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libudns", "libs\win32\udns\libudns.2010.vcxproj", "{4043FC6A-9A30-4577-8AD5-9B233C9575D8}"
-EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_enum", "src\mod\applications\mod_enum\mod_enum.2010.vcxproj", "{71A967D5-0E99-4CEF-A587-98836EE6F2EF}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_spidermonkey_odbc", "src\mod\languages\mod_spidermonkey\mod_spidermonkey_odbc.2010.vcxproj", "{0A6B5EA5-6E9B-4A51-931F-ED25AA87B4DF}"
@@ -251,8 +252,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "16khz music", "libs\win32\S
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "32khz music", "libs\win32\Sound_Files\32khzmusic.2010.vcxproj", "{EED13FC7-4F81-4E6F-93DB-CDB7DF5CF959}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_file_string", "src\mod\formats\mod_file_string\mod_file_string.2010.vcxproj", "{70564D74-199A-4452-9C60-19ED5F242F0D}"
-EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_nibblebill", "src\mod\applications\mod_nibblebill\mod_nibblebill.2010.vcxproj", "{3C977801-FE88-48F2-83D3-FA2EBFF6688E}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_say_ru", "src\mod\say\mod_say_ru\mod_say_ru.2010.vcxproj", "{0382E8FD-CFDC-41C0-8B03-792C7C84FC31}"
@@ -317,6 +316,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openssl", "libs\win32\opens
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_directory", "src\mod\applications\mod_directory\mod_directory.2010.vcxproj", "{B889A18E-70A7-44B5-B2C9-47798D4F43B3}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ldns", "libs\win32\ldns\ldns-lib\ldns-lib.2010.vcxproj", "{23B4D303-79FC-49E0-89E2-2280E7E28940}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libpcre Generate pcre_chartables.c", "libs\win32\pcre\pcre_chartables.c.2010.vcxproj", "{1CED5987-A529-46DC-B30F-870D85FF9C94}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
All|Win32 = All|Win32
@@ -781,17 +784,6 @@ Global
{8F992C49-6C51-412F-B2A3-34EAB708EB65}.Release|Win32.Build.0 = Release|Win32
{8F992C49-6C51-412F-B2A3-34EAB708EB65}.Release|x64.ActiveCfg = Release|x64
{8F992C49-6C51-412F-B2A3-34EAB708EB65}.Release|x64.Build.0 = Release|x64
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8}.All|Win32.ActiveCfg = Release|x64
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8}.All|x64.ActiveCfg = Release|x64
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8}.All|x64.Build.0 = Release|x64
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8}.Debug|Win32.ActiveCfg = Debug|Win32
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8}.Debug|Win32.Build.0 = Debug|Win32
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8}.Debug|x64.ActiveCfg = Debug|x64
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8}.Debug|x64.Build.0 = Debug|x64
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8}.Release|Win32.ActiveCfg = Release|Win32
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8}.Release|Win32.Build.0 = Release|Win32
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8}.Release|x64.ActiveCfg = Release|x64
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8}.Release|x64.Build.0 = Release|x64
{71A967D5-0E99-4CEF-A587-98836EE6F2EF}.All|Win32.ActiveCfg = Release|x64
{71A967D5-0E99-4CEF-A587-98836EE6F2EF}.All|x64.ActiveCfg = Release|x64
{71A967D5-0E99-4CEF-A587-98836EE6F2EF}.All|x64.Build.0 = Release|x64
@@ -1645,17 +1637,6 @@ Global
{EED13FC7-4F81-4E6F-93DB-CDB7DF5CF959}.Debug|x64.ActiveCfg = Debug|Win32
{EED13FC7-4F81-4E6F-93DB-CDB7DF5CF959}.Release|Win32.ActiveCfg = Release|Win32
{EED13FC7-4F81-4E6F-93DB-CDB7DF5CF959}.Release|x64.ActiveCfg = Release|Win32
- {70564D74-199A-4452-9C60-19ED5F242F0D}.All|Win32.ActiveCfg = Release|x64
- {70564D74-199A-4452-9C60-19ED5F242F0D}.All|x64.ActiveCfg = Release|x64
- {70564D74-199A-4452-9C60-19ED5F242F0D}.All|x64.Build.0 = Release|x64
- {70564D74-199A-4452-9C60-19ED5F242F0D}.Debug|Win32.ActiveCfg = Debug|Win32
- {70564D74-199A-4452-9C60-19ED5F242F0D}.Debug|Win32.Build.0 = Debug|Win32
- {70564D74-199A-4452-9C60-19ED5F242F0D}.Debug|x64.ActiveCfg = Debug|x64
- {70564D74-199A-4452-9C60-19ED5F242F0D}.Debug|x64.Build.0 = Debug|x64
- {70564D74-199A-4452-9C60-19ED5F242F0D}.Release|Win32.ActiveCfg = Release|Win32
- {70564D74-199A-4452-9C60-19ED5F242F0D}.Release|Win32.Build.0 = Release|Win32
- {70564D74-199A-4452-9C60-19ED5F242F0D}.Release|x64.ActiveCfg = Release|x64
- {70564D74-199A-4452-9C60-19ED5F242F0D}.Release|x64.Build.0 = Release|x64
{3C977801-FE88-48F2-83D3-FA2EBFF6688E}.All|Win32.ActiveCfg = Release|x64
{3C977801-FE88-48F2-83D3-FA2EBFF6688E}.All|x64.ActiveCfg = Release|x64
{3C977801-FE88-48F2-83D3-FA2EBFF6688E}.All|x64.Build.0 = Release|x64
@@ -1990,6 +1971,24 @@ Global
{B889A18E-70A7-44B5-B2C9-47798D4F43B3}.Debug|x64.ActiveCfg = Debug|Win32
{B889A18E-70A7-44B5-B2C9-47798D4F43B3}.Release|Win32.ActiveCfg = Release|Win32
{B889A18E-70A7-44B5-B2C9-47798D4F43B3}.Release|x64.ActiveCfg = Release|Win32
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.All|Win32.ActiveCfg = Release|Win32
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.All|Win32.Build.0 = Release|Win32
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.All|x64.ActiveCfg = Release|Win32
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.Debug|Win32.ActiveCfg = Debug|Win32
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.Debug|Win32.Build.0 = Debug|Win32
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.Debug|x64.ActiveCfg = Debug|Win32
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.Release|Win32.ActiveCfg = Release|Win32
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.Release|Win32.Build.0 = Release|Win32
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.Release|x64.ActiveCfg = Release|Win32
+ {1CED5987-A529-46DC-B30F-870D85FF9C94}.All|Win32.ActiveCfg = Release|Win32
+ {1CED5987-A529-46DC-B30F-870D85FF9C94}.All|Win32.Build.0 = Release|Win32
+ {1CED5987-A529-46DC-B30F-870D85FF9C94}.All|x64.ActiveCfg = Release|Win32
+ {1CED5987-A529-46DC-B30F-870D85FF9C94}.Debug|Win32.ActiveCfg = Debug|Win32
+ {1CED5987-A529-46DC-B30F-870D85FF9C94}.Debug|Win32.Build.0 = Debug|Win32
+ {1CED5987-A529-46DC-B30F-870D85FF9C94}.Debug|x64.ActiveCfg = Debug|Win32
+ {1CED5987-A529-46DC-B30F-870D85FF9C94}.Release|Win32.ActiveCfg = Release|Win32
+ {1CED5987-A529-46DC-B30F-870D85FF9C94}.Release|Win32.Build.0 = Release|Win32
+ {1CED5987-A529-46DC-B30F-870D85FF9C94}.Release|x64.ActiveCfg = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/Freeswitch.2010.sln b/Freeswitch.2010.sln
index 464cb2e273..cfb4770b6f 100644
--- a/Freeswitch.2010.sln
+++ b/Freeswitch.2010.sln
@@ -631,8 +631,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "16khz music", "libs\win32\S
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "32khz music", "libs\win32\Sound_Files\32khzmusic.2010.vcxproj", "{EED13FC7-4F81-4E6F-93DB-CDB7DF5CF959}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_file_string", "src\mod\formats\mod_file_string\mod_file_string.2010.vcxproj", "{70564D74-199A-4452-9C60-19ED5F242F0D}"
-EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_nibblebill", "src\mod\applications\mod_nibblebill\mod_nibblebill.2010.vcxproj", "{3C977801-FE88-48F2-83D3-FA2EBFF6688E}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_say_ru", "src\mod\say\mod_say_ru\mod_say_ru.2010.vcxproj", "{0382E8FD-CFDC-41C0-8B03-792C7C84FC31}"
@@ -709,6 +707,10 @@ Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "Setup", "w32\Setup\Setup.wi
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_say_pt", "src\mod\say\mod_say_pt\mod_say_pt.2010.vcxproj", "{7C22BDFF-CC09-400C-8A09-660733980028}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ldns", "libs\win32\ldns\ldns-lib\ldns-lib.2010.vcxproj", "{23B4D303-79FC-49E0-89E2-2280E7E28940}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_callcenter", "src\mod\applications\mod_callcenter\mod_callcenter.2010.vcxproj", "{47886A6C-CCA6-4F9F-A7D4-F97D06FB2B1A}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
All|Win32 = All|Win32
@@ -1480,15 +1482,11 @@ Global
{4043FC6A-9A30-4577-8AD5-9B233C9575D8}.All|x64 Setup.Build.0 = Release|x64
{4043FC6A-9A30-4577-8AD5-9B233C9575D8}.All|x86 Setup.ActiveCfg = Release|x64
{4043FC6A-9A30-4577-8AD5-9B233C9575D8}.Debug|Win32.ActiveCfg = Debug|Win32
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8}.Debug|Win32.Build.0 = Debug|Win32
{4043FC6A-9A30-4577-8AD5-9B233C9575D8}.Debug|x64.ActiveCfg = Debug|x64
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8}.Debug|x64.Build.0 = Debug|x64
{4043FC6A-9A30-4577-8AD5-9B233C9575D8}.Debug|x64 Setup.ActiveCfg = Debug|x64
{4043FC6A-9A30-4577-8AD5-9B233C9575D8}.Debug|x86 Setup.ActiveCfg = Debug|Win32
{4043FC6A-9A30-4577-8AD5-9B233C9575D8}.Release|Win32.ActiveCfg = Release|Win32
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8}.Release|Win32.Build.0 = Release|Win32
{4043FC6A-9A30-4577-8AD5-9B233C9575D8}.Release|x64.ActiveCfg = Release|x64
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8}.Release|x64.Build.0 = Release|x64
{4043FC6A-9A30-4577-8AD5-9B233C9575D8}.Release|x64 Setup.ActiveCfg = Release|x64
{4043FC6A-9A30-4577-8AD5-9B233C9575D8}.Release|x86 Setup.ActiveCfg = Release|Win32
{71A967D5-0E99-4CEF-A587-98836EE6F2EF}.All|Win32.ActiveCfg = Release|x64
@@ -2973,24 +2971,6 @@ Global
{EED13FC7-4F81-4E6F-93DB-CDB7DF5CF959}.Release|x64.ActiveCfg = Release|x64
{EED13FC7-4F81-4E6F-93DB-CDB7DF5CF959}.Release|x64 Setup.ActiveCfg = Release|x64
{EED13FC7-4F81-4E6F-93DB-CDB7DF5CF959}.Release|x86 Setup.ActiveCfg = Release|Win32
- {70564D74-199A-4452-9C60-19ED5F242F0D}.All|Win32.ActiveCfg = Release|x64
- {70564D74-199A-4452-9C60-19ED5F242F0D}.All|x64.ActiveCfg = Release|x64
- {70564D74-199A-4452-9C60-19ED5F242F0D}.All|x64.Build.0 = Release|x64
- {70564D74-199A-4452-9C60-19ED5F242F0D}.All|x64 Setup.ActiveCfg = Release|x64
- {70564D74-199A-4452-9C60-19ED5F242F0D}.All|x64 Setup.Build.0 = Release|x64
- {70564D74-199A-4452-9C60-19ED5F242F0D}.All|x86 Setup.ActiveCfg = Release|x64
- {70564D74-199A-4452-9C60-19ED5F242F0D}.Debug|Win32.ActiveCfg = Debug|Win32
- {70564D74-199A-4452-9C60-19ED5F242F0D}.Debug|Win32.Build.0 = Debug|Win32
- {70564D74-199A-4452-9C60-19ED5F242F0D}.Debug|x64.ActiveCfg = Debug|x64
- {70564D74-199A-4452-9C60-19ED5F242F0D}.Debug|x64.Build.0 = Debug|x64
- {70564D74-199A-4452-9C60-19ED5F242F0D}.Debug|x64 Setup.ActiveCfg = Debug|x64
- {70564D74-199A-4452-9C60-19ED5F242F0D}.Debug|x86 Setup.ActiveCfg = Debug|Win32
- {70564D74-199A-4452-9C60-19ED5F242F0D}.Release|Win32.ActiveCfg = Release|Win32
- {70564D74-199A-4452-9C60-19ED5F242F0D}.Release|Win32.Build.0 = Release|Win32
- {70564D74-199A-4452-9C60-19ED5F242F0D}.Release|x64.ActiveCfg = Release|x64
- {70564D74-199A-4452-9C60-19ED5F242F0D}.Release|x64.Build.0 = Release|x64
- {70564D74-199A-4452-9C60-19ED5F242F0D}.Release|x64 Setup.ActiveCfg = Release|x64
- {70564D74-199A-4452-9C60-19ED5F242F0D}.Release|x86 Setup.ActiveCfg = Release|Win32
{3C977801-FE88-48F2-83D3-FA2EBFF6688E}.All|Win32.ActiveCfg = Release|x64
{3C977801-FE88-48F2-83D3-FA2EBFF6688E}.All|x64.ActiveCfg = Release|x64
{3C977801-FE88-48F2-83D3-FA2EBFF6688E}.All|x64.Build.0 = Release|x64
@@ -3638,6 +3618,36 @@ Global
{7C22BDFF-CC09-400C-8A09-660733980028}.Release|x64.Build.0 = Release|x64
{7C22BDFF-CC09-400C-8A09-660733980028}.Release|x64 Setup.ActiveCfg = Release|x64
{7C22BDFF-CC09-400C-8A09-660733980028}.Release|x86 Setup.ActiveCfg = Release|x64
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.All|Win32.ActiveCfg = Release|x64
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.All|x64.ActiveCfg = Release|x64
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.All|x64.Build.0 = Release|x64
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.All|x64 Setup.ActiveCfg = Release|x64
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.All|x86 Setup.ActiveCfg = Release|x64
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.Debug|Win32.ActiveCfg = Debug|Win32
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.Debug|Win32.Build.0 = Debug|Win32
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.Debug|x64.ActiveCfg = Debug|x64
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.Debug|x64.Build.0 = Debug|x64
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.Debug|x64 Setup.ActiveCfg = Debug|x64
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.Debug|x86 Setup.ActiveCfg = Debug|x64
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.Release|Win32.ActiveCfg = Release|Win32
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.Release|Win32.Build.0 = Release|Win32
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.Release|x64.ActiveCfg = Release|x64
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.Release|x64.Build.0 = Release|x64
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.Release|x64 Setup.ActiveCfg = Release|x64
+ {23B4D303-79FC-49E0-89E2-2280E7E28940}.Release|x86 Setup.ActiveCfg = Release|x64
+ {47886A6C-CCA6-4F9F-A7D4-F97D06FB2B1A}.All|Win32.ActiveCfg = Release|x64
+ {47886A6C-CCA6-4F9F-A7D4-F97D06FB2B1A}.All|x64.ActiveCfg = Release|x64
+ {47886A6C-CCA6-4F9F-A7D4-F97D06FB2B1A}.All|x64.Build.0 = Release|x64
+ {47886A6C-CCA6-4F9F-A7D4-F97D06FB2B1A}.All|x64 Setup.ActiveCfg = Release|x64
+ {47886A6C-CCA6-4F9F-A7D4-F97D06FB2B1A}.All|x86 Setup.ActiveCfg = Release|x64
+ {47886A6C-CCA6-4F9F-A7D4-F97D06FB2B1A}.Debug|Win32.ActiveCfg = Debug|Win32
+ {47886A6C-CCA6-4F9F-A7D4-F97D06FB2B1A}.Debug|x64.ActiveCfg = Debug|x64
+ {47886A6C-CCA6-4F9F-A7D4-F97D06FB2B1A}.Debug|x64 Setup.ActiveCfg = Debug|x64
+ {47886A6C-CCA6-4F9F-A7D4-F97D06FB2B1A}.Debug|x86 Setup.ActiveCfg = Debug|x64
+ {47886A6C-CCA6-4F9F-A7D4-F97D06FB2B1A}.Release|Win32.ActiveCfg = Release|Win32
+ {47886A6C-CCA6-4F9F-A7D4-F97D06FB2B1A}.Release|x64.ActiveCfg = Release|x64
+ {47886A6C-CCA6-4F9F-A7D4-F97D06FB2B1A}.Release|x64 Setup.ActiveCfg = Release|x64
+ {47886A6C-CCA6-4F9F-A7D4-F97D06FB2B1A}.Release|x86 Setup.ActiveCfg = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -3685,6 +3695,7 @@ Global
{2E250296-0C08-4342-9C8A-BCBDD0E7DF65} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78}
{B889A18E-70A7-44B5-B2C9-47798D4F43B3} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78}
{5C2B4D88-3BEA-4FE0-90DF-FA9836099D5F} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78}
+ {47886A6C-CCA6-4F9F-A7D4-F97D06FB2B1A} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78}
{07113B25-D3AF-4E04-BA77-4CD1171F022C} = {C5F182F9-754A-4EC5-B50F-76ED02BE13F4}
{A27CCA23-1541-4337-81A4-F0A6413078A0} = {C5F182F9-754A-4EC5-B50F-76ED02BE13F4}
{E7BC026C-7CC5-45A3-BC7C-3B88EEF01F24} = {C5F182F9-754A-4EC5-B50F-76ED02BE13F4}
@@ -3696,7 +3707,6 @@ Global
{2CA40887-1622-46A1-A7F9-17FD7E7E545B} = {A5A27244-AD24-46E5-B01B-840CD296C91D}
{6FF941AC-82C5-429F-AA4C-AD2FB9E5DA52} = {A5A27244-AD24-46E5-B01B-840CD296C91D}
{38FE0559-9910-43A8-9E45-3E5004C27692} = {A5A27244-AD24-46E5-B01B-840CD296C91D}
- {70564D74-199A-4452-9C60-19ED5F242F0D} = {A5A27244-AD24-46E5-B01B-840CD296C91D}
{CBD81696-EFB4-4D2F-8451-1B8DAA86155A} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B}
{62F27B1A-C919-4A70-8478-51F178F3B18F} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B}
{89385C74-5860-4174-9CAF-A39E7C48909C} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B}
@@ -3742,6 +3752,7 @@ Global
{56B91D01-9150-4BBF-AFA1-5B68AB991B76} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B}
{E4D29906-8B73-4F8A-B5F4-CA8BFA648F5A} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B}
{70A49BC2-7500-41D0-B75D-EDCC5BE987A0} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B}
+ {23B4D303-79FC-49E0-89E2-2280E7E28940} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B}
{EC3E5C7F-EE09-47E2-80FE-546363D14A98} = {B8F5B47B-8568-46EB-B320-64C17D2A98BC}
{1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F} = {0C808854-54D1-4230-BFF5-77B5FD905000}
{ACFFF684-4D19-4D48-AF12-88EA1D778BDF} = {0C808854-54D1-4230-BFF5-77B5FD905000}
diff --git a/Makefile.am b/Makefile.am
index 5b6b9896ac..95c53dd128 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -106,7 +106,10 @@ CORE_CFLAGS += -I$(switch_srcdir)/libs/spandsp/src -I$(switch_srcdir)/libs/tiff-
CORE_LIBS = libs/apr-util/libaprutil-1.la libs/apr/libapr-1.la
CORE_LIBS += libs/sqlite/libsqlite3.la libs/pcre/libpcre.la libs/speex/libspeex/libspeexdsp.la
+if ENABLE_SRTP
+CORE_CFLAGS += -DENABLE_SRTP
CORE_LIBS += libs/srtp/libsrtp.la
+endif
MOD_LINK = $(switch_srcdir)/libfreeswitch.la
CLEANFILES = src/include/switch_version.h src/include/switch_swigable_cpp.h
diff --git a/acinclude.m4 b/acinclude.m4
index 705b9458b5..aeba17b5c3 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -12,4 +12,5 @@ m4_include([build/config/sched_setaffinity.m4])
m4_include([libs/apr/build/apr_common.m4])
m4_include([libs/sofia-sip/m4/sac-pkg-config.m4])
m4_include([libs/sofia-sip/m4/sac-openssl.m4])
+m4_include([libs/iksemel/build/libgnutls.m4])
m4_include([build/config/libcurl.m4])
diff --git a/build/freeswitch.init.redhat b/build/freeswitch.init.redhat
index 6fe9c43c47..b9dc3d8db5 100644
--- a/build/freeswitch.init.redhat
+++ b/build/freeswitch.init.redhat
@@ -15,7 +15,7 @@
. /etc/init.d/functions
PROG_NAME=freeswitch
-PID_FILE=${PID_FILE-/opt/freeswitch/run/freeswitch.pid}
+PID_FILE=${PID_FILE-/var/run/freeswitch/freeswitch.pid}
FS_USER=${FS_USER-freeswitch}
FS_FILE=${FS_FILE-/opt/freeswitch/bin/freeswitch}
FS_HOME=${FS_HOME-/opt/freeswitch}
diff --git a/build/modmake.rules.in b/build/modmake.rules.in
index f1b30c8a18..51923ec3dd 100644
--- a/build/modmake.rules.in
+++ b/build/modmake.rules.in
@@ -27,6 +27,7 @@ INSTALL=@INSTALL@
GETLIB=@GETLIB@
LIBTOOL=@LIBTOOL@
AR=@AR@
+LIBGNUTLS_LIBS=@LIBGNUTLS_LIBS@
LTINSTALL=$(LIBTOOL) --quiet --mode=install $(INSTALL)
LTUNINSTALL=$(LIBTOOL) --mode=uninstall rm -f
CCLD = $(CC)
diff --git a/build/modules.conf.in b/build/modules.conf.in
index 63a0ab491e..1084461f0e 100644
--- a/build/modules.conf.in
+++ b/build/modules.conf.in
@@ -36,6 +36,8 @@ applications/mod_valet_parking
#applications/mod_snipe_hunt
#applications/mod_callcenter
#applications/mod_fsk
+#applications/mod_ladspa
+#applications/mod_mongo
codecs/mod_g723_1
codecs/mod_amr
#codecs/mod_amrwb
@@ -75,6 +77,7 @@ endpoints/mod_loopback
#asr_tts/mod_tts_commandline
#event_handlers/mod_event_multicast
event_handlers/mod_event_socket
+#event_handlers/mod_event_zmq
event_handlers/mod_cdr_csv
event_handlers/mod_cdr_sqlite
#event_handlers/mod_cdr_pg_csv
@@ -86,7 +89,6 @@ formats/mod_sndfile
#formats/mod_shout
formats/mod_local_stream
formats/mod_tone_stream
-formats/mod_file_string
#formats/mod_portaudio_stream
#formats/mod_shell_stream
#languages/mod_python
@@ -107,10 +109,12 @@ say/mod_say_en
#say/mod_say_it
#say/mod_say_nl
#say/mod_say_pt
-say/mod_say_ru
+#say/mod_say_ru
#say/mod_say_zh
#say/mod_say_hu
#say/mod_say_th
+#say/mod_say_he
+#timers/mod_timerfd
## Experimental Modules (don't cry if they're broken)
#../../contrib/mod/xml_int/mod_xml_odbc
diff --git a/build/sounds_version.txt b/build/sounds_version.txt
index 20cb29cbd7..55729b1f9f 100644
--- a/build/sounds_version.txt
+++ b/build/sounds_version.txt
@@ -1,3 +1,3 @@
-en-us-callie 1.0.14
+en-us-callie 1.0.16
ru-RU-elena 1.0.12
diff --git a/conf/README_IMPORTANT.txt b/conf/README_IMPORTANT.txt
new file mode 100644
index 0000000000..8d82b404f6
--- /dev/null
+++ b/conf/README_IMPORTANT.txt
@@ -0,0 +1,35 @@
+ -= PLEASE READ THIS BEFORE YOU PUT A FreeSWITCH BOX INTO PRODUCTION =-
+
+This configuration, generally known as the "default configuration" for FreeSWITCH, is *NOT* designed to be put into a production environment without some important modifications. Please keep in mind that the default configuration is designed to demonstrate what FreeSWITCH *can* do, not what it *should* do in your specific scenario.
+
+*** SECURING YOUR SERVER ***
+
+By default, FreeSWITCH starts up and does a NATPMP and UPnP request to your router. If your router supports either of these protocols then FreeSWITCH does two things:
+#1 - It gets the external IP address, which it uses for SIP communications
+#2 - It causes there to be a "pinhole" opened up in the router allowing inbound communications to your FreeSWITCH server
+
+Please re-read #2. Now, please re-read #2 again. If you do not want a pinhole coming through your router then DO NOT USE the "auto-nat" tools. The way to disable the auto-nat (that is, UPnP/NATPMP) checking is to start FreeSWITCH with the "-nonat" flag. Easy enough.
+
+If you are planning on putting a system into production then you had better pay attention to security in other areas as well. If you are behind a firewall then make sure your firewall is actually protecting you. If you have your server on a public-facing Internet connection then we recommend a few things:
+#1 - Consider using iptables (Linux/Unix)
+#2 - Consider using fail2ban (see http://wiki.freeswitch.org/wiki/Fail2ban)
+
+*** SECURING YOUR USERS ***
+
+By default, the static XML files have 20 "directory users" in conf/directory/10xx.xml, numbered 1000-1019. Also, the default dialplan has routing for calls to those same extension numbers. (NOTE: the directory and the dialplan are 100% separate concepts. Check out chapters 3-5 of the awesome FreeSWITCH book for details.)
+
+The default users all have *very* simple passwords for SIP credentials and voicemail. If you put those into a production system then you are either brave, ignorant, or stupid. Please don't be any of those three things! You have a few choices for handling your users:
+
+#1 - Delete the static XML files and use mod_xml_curl for dynamic users from a back-end database
+#2 - Manually edit the static XML user directory files and modify the passwords
+#3 - Run the handy randomize-passwords.pl script found in scripts/perl/ subdirectory under the main FreeSWITCH source directory
+
+*** GETTING HELP ***
+
+FreeSWITCH has a thriving on-line community - we welcome you to join us!
+IRC: #freeswitch on irc.freenode.net
+Mailing List: freeswitch-users on lists.freeswitch.org
+
+You can also get professional FreeSWITCH assistance by visiting http://www.freeswitchsolutions.com or sending an email to consulting@freeswitch.org.
+
+Happy FreeSWITCHing!
diff --git a/conf/autoload_configs/cepstral.conf.xml b/conf/autoload_configs/cepstral.conf.xml
new file mode 100644
index 0000000000..cf4aa92f41
--- /dev/null
+++ b/conf/autoload_configs/cepstral.conf.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/conf/autoload_configs/modules.conf.xml b/conf/autoload_configs/modules.conf.xml
index 0e485b24e3..96079cd227 100644
--- a/conf/autoload_configs/modules.conf.xml
+++ b/conf/autoload_configs/modules.conf.xml
@@ -22,6 +22,7 @@
+
@@ -64,6 +65,9 @@
+
+
+
@@ -89,9 +93,9 @@
-
+
@@ -109,7 +113,7 @@
-
+
diff --git a/conf/autoload_configs/mongo.conf.xml b/conf/autoload_configs/mongo.conf.xml
new file mode 100644
index 0000000000..a7fdecae8d
--- /dev/null
+++ b/conf/autoload_configs/mongo.conf.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/conf/autoload_configs/switch.conf.xml b/conf/autoload_configs/switch.conf.xml
index d2500a6463..b0f0c53fef 100644
--- a/conf/autoload_configs/switch.conf.xml
+++ b/conf/autoload_configs/switch.conf.xml
@@ -24,6 +24,17 @@
+
+
+
+
+
+
diff --git a/conf/autoload_configs/voicemail.conf.xml b/conf/autoload_configs/voicemail.conf.xml
index 06bd6f6dca..62e8bf9de0 100644
--- a/conf/autoload_configs/voicemail.conf.xml
+++ b/conf/autoload_configs/voicemail.conf.xml
@@ -33,7 +33,7 @@
- -->
+
diff --git a/conf/dialplan/default/00_ladspa.xml b/conf/dialplan/default/00_ladspa.xml
new file mode 100644
index 0000000000..a26b193ef5
--- /dev/null
+++ b/conf/dialplan/default/00_ladspa.xml
@@ -0,0 +1,77 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/conf/dialplan/default/01_Talking_Clock.xml b/conf/dialplan/default/01_Talking_Clock.xml
new file mode 100644
index 0000000000..205132a249
--- /dev/null
+++ b/conf/dialplan/default/01_Talking_Clock.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/conf/freeswitch.xml b/conf/freeswitch.xml
index 6914128e55..42eede31ee 100644
--- a/conf/freeswitch.xml
+++ b/conf/freeswitch.xml
@@ -52,13 +52,12 @@
-
-
-
-
-
-
-
-
+
+
diff --git a/conf/lang/de/de.xml b/conf/lang/de/de.xml
index 5239489f75..1b44c9a1dd 100644
--- a/conf/lang/de/de.xml
+++ b/conf/lang/de/de.xml
@@ -1,7 +1,11 @@
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/conf/lang/de/vm/sounds.xml b/conf/lang/de/vm/sounds.xml
new file mode 100644
index 0000000000..ad9dc2e136
--- /dev/null
+++ b/conf/lang/de/vm/sounds.xml
@@ -0,0 +1,407 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/conf/lang/en/en.xml b/conf/lang/en/en.xml
index 6bd5a7d5fb..1e23dc5d7b 100644
--- a/conf/lang/en/en.xml
+++ b/conf/lang/en/en.xml
@@ -1,8 +1,12 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/conf/lang/en/ivr/sounds.xml b/conf/lang/en/ivr/sounds.xml
new file mode 100644
index 0000000000..58db0a6c15
--- /dev/null
+++ b/conf/lang/en/ivr/sounds.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/conf/lang/fr/fr.xml b/conf/lang/fr/fr.xml
index 12bec06f20..eaf00f247e 100644
--- a/conf/lang/fr/fr.xml
+++ b/conf/lang/fr/fr.xml
@@ -1,8 +1,12 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/conf/lang/he/demo/demo-ivr.xml b/conf/lang/he/demo/demo-ivr.xml
new file mode 100644
index 0000000000..ec7d7bccd2
--- /dev/null
+++ b/conf/lang/he/demo/demo-ivr.xml
@@ -0,0 +1,148 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/conf/lang/he/demo/demo.xml b/conf/lang/he/demo/demo.xml
new file mode 100644
index 0000000000..e3e6f02142
--- /dev/null
+++ b/conf/lang/he/demo/demo.xml
@@ -0,0 +1,71 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/conf/lang/he/dir/sounds.xml b/conf/lang/he/dir/sounds.xml
new file mode 100644
index 0000000000..15ecec304a
--- /dev/null
+++ b/conf/lang/he/dir/sounds.xml
@@ -0,0 +1,121 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/conf/lang/he/he.xml b/conf/lang/he/he.xml
new file mode 100644
index 0000000000..fe7c5d8a01
--- /dev/null
+++ b/conf/lang/he/he.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/conf/lang/he/vm/sounds.xml b/conf/lang/he/vm/sounds.xml
new file mode 100644
index 0000000000..5a090411d7
--- /dev/null
+++ b/conf/lang/he/vm/sounds.xml
@@ -0,0 +1,404 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/conf/lang/ru/ru.xml b/conf/lang/ru/ru.xml
index 25d63b6110..686e840860 100644
--- a/conf/lang/ru/ru.xml
+++ b/conf/lang/ru/ru.xml
@@ -1,9 +1,13 @@
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/conf/sip_profiles/internal.xml b/conf/sip_profiles/internal.xml
index b78ea20070..b803bcea6d 100644
--- a/conf/sip_profiles/internal.xml
+++ b/conf/sip_profiles/internal.xml
@@ -47,8 +47,8 @@
Sometimes, in extremely rare edge cases, the Sofia SIP stack may stop
responding. These options allow you to enable and control a watchdog
on the Sofia SIP stack so that if it stops responding for the
- specified number of milliseconds, it will cause FreeSWITCH to shut
- down immediately. This is useful if you run in an HA environment and
+ specified number of milliseconds, it will cause FreeSWITCH to crash
+ immediately. This is useful if you run in an HA environment and
need to ensure automated recovery from such a condition. Note that if
your server is idle a lot, the watchdog may fire due to not receiving
any SIP messages. Thus, if you expect your system to be idle, you
@@ -57,6 +57,8 @@
globally for all profiles. So, if you run in an HA environment with a
master and slave, you should use the CLI to make sure the watchdog is
only enabled on the master.
+ If such crash occurs, FreeSWITCH will dump core if allowed. The
+ stacktrace will include function watchdog_triggered_abort().
-->
diff --git a/conf/vars.xml b/conf/vars.xml
index 94529aa9bc..f24cc5ccee 100644
--- a/conf/vars.xml
+++ b/conf/vars.xml
@@ -199,15 +199,32 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
diff --git a/docs/phrase/phrase_fr.xml b/docs/phrase/phrase_fr.xml
index ef3ee7bb6d..2d5f488152 100644
--- a/docs/phrase/phrase_fr.xml
+++ b/docs/phrase/phrase_fr.xml
@@ -219,14 +219,14 @@
-
+
-
-
+
+
diff --git a/docs/phrase/phrase_ru.xml b/docs/phrase/phrase_ru.xml
index e8423e7aaa..fb873dd9da 100644
--- a/docs/phrase/phrase_ru.xml
+++ b/docs/phrase/phrase_ru.xml
@@ -316,16 +316,20 @@
+
+
+
+
-
+
-
+
@@ -395,6 +399,7 @@
+
@@ -431,26 +436,39 @@
+
+
+
+
+
+
+
-
+
-
+
-
-
+
+
-
-
-
+
+
+
+ ^
+
+
+
+
+
@@ -460,7 +478,7 @@
-
+
@@ -471,6 +489,15 @@
+
+
+
+
+
+
+
+
+
@@ -479,11 +506,11 @@
-
-
-
-
-
+
+
+
+
+
@@ -508,7 +535,7 @@
-
+
@@ -545,7 +572,7 @@
-
+
@@ -554,17 +581,66 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
+
+
+
+
diff --git a/freeswitch-sounds-en-us-callie.spec b/freeswitch-sounds-en-us-callie.spec
index c4764570f5..dabf1e45de 100644
--- a/freeswitch-sounds-en-us-callie.spec
+++ b/freeswitch-sounds-en-us-callie.spec
@@ -2,7 +2,7 @@
# Copyright and license
##############################################################################
#
-# Spec file for package freeswitch-sounds-en-us-callie (version 1.0.12-8)
+# Spec file for package freeswitch-sounds-en-us-callie (version 1.0.16-8)
#
# Copyright (c) 2009 Patrick Laimbock
# Some fixes and additions (c) 2011 Michal Bielicki
@@ -20,7 +20,7 @@
# Set variables
##############################################################################
-%define version 1.0.14
+%define version 1.0.16
%define release 1
%define fsname freeswitch
@@ -299,6 +299,8 @@ cd %{_prefix}/sounds/en/us/callie
##############################################################################
%changelog
+* Sun May 22 2011 Michal Bielicki - 1.0.16-1
+- bump up version
* Tue Jan 18 2011 Michal Bielicki - 1.0.14-1
- bump up version
- include script into freeswitch core
diff --git a/freeswitch.spec b/freeswitch.spec
index 1000a89239..d13ae2686d 100644
--- a/freeswitch.spec
+++ b/freeswitch.spec
@@ -31,9 +31,11 @@
%define build_sng_isdn 0
%define build_sng_ss7 0
%define build_sng_tc 0
+%define build_py26_esl 0
%{?with_sang_tc:%define build_sng_tc 1 }
%{?with_sang_isdn:%define build_sng_isdn 1 }
%{?with_sang_ss7:%define build_sng_ss7 1 }
+%{?with_py26_esl:%define build_py26_esl 1 }
######################################################################################################################
#
@@ -61,12 +63,12 @@ Vendor: http://www.freeswitch.org/
# Source files and where to get them
#
######################################################################################################################
-Source0: http://files.freeswitch.org/%{name}-%{version}.tar.bz2
+Source0: http://files.freeswitch.org/%{name}-%{version}.tar.bz2
Source1: http://files.freeswitch.org/downloads/libs/celt-0.10.0.tar.gz
Source2: http://files.freeswitch.org/downloads/libs/flite-1.3.99-latest.tar.gz
Source3: http://files.freeswitch.org/downloads/libs/lame-3.97.tar.gz
Source4: http://files.freeswitch.org/downloads/libs/libshout-2.2.2.tar.gz
-Source5: http://files.freeswitch.org/downloads/libs/mpg123.tar.gz
+Source5: http://files.freeswitch.org/downloads/libs/mpg123-1.13.2.tar.gz
Source6: http://files.freeswitch.org/downloads/libs/openldap-2.4.11.tar.gz
Source7: http://files.freeswitch.org/downloads/libs/pocketsphinx-0.5.99-20091212.tar.gz
Source8: http://files.freeswitch.org/downloads/libs/soundtouch-1.3.1.tar.gz
@@ -121,6 +123,10 @@ BuildRequires: e2fsprogs-devel
BuildRequires: libtheora-devel
BuildRequires: libxml2-devel
BuildRequires: bison
+%if %{build_py26_esl}
+BuildRequires: python26-devel
+Requires: python26
+%endif
Requires: alsa-lib
Requires: libogg
Requires: libvorbis
@@ -271,25 +277,36 @@ English language phrases module and directory structure for say module and voice
%package lang-ru
Summary: Provides russian language dependand modules and speech config for the FreeSWITCH Open Source telephone platform.
-Group: System/LibrariesRequires: %{name} = %{version}-%{release}
+Group: System/Libraries
+Requires: %{name} = %{version}-%{release}
%description lang-ru
Russian language phrases module and directory structure for say module and voicemail
%package lang-fr
-Summary: Provides french language dependand modules and speech config for the FreeSWITCH Open Source telephone platform.
-Group: System/LibrariesRequires: %{name} = %{version}-%{release}
+Summary: Provides french language dependend modules and speech config for the FreeSWITCH Open Source telephone platform.
+Group: System/Libraries
+Requires: %{name} = %{version}-%{release}
%description lang-fr
French language phrases module and directory structure for say module and voicemail
%package lang-de
-Summary: Provides german language dependand modules and speech config for the FreeSWITCH Open Source telephone platform.
-Group: System/LibrariesRequires: %{name} = %{version}-%{release}
+Summary: Provides german language dependend modules and speech config for the FreeSWITCH Open Source telephone platform.
+Group: System/Libraries
+Requires: %{name} = %{version}-%{release}
%description lang-de
German language phrases module and directory structure for say module and voicemail
+%package lang-he
+Summary: Provides hebrew language dependend modules and speech config for the FreeSWITCH Open Source telephone platform.
+Group: System/Libraries
+Requires: %{name} = %{version}-%{release}
+
+%description lang-he
+Hebrew language phrases module and directory structure for say module and voicemail
+
%package freetdm
Summary: Provides a unified interface to hardware TDM cards and ss7 stacks for FreeSWITCH
@@ -467,7 +484,7 @@ EVENT_HANDLERS_MODULES="event_handlers/mod_cdr_csv event_handlers/mod_cdr_sqlite
# File and Audio Format Handlers
#
######################################################################################################################
-FORMATS_MODULES="formats/mod_file_string formats/mod_local_stream formats/mod_native_file formats/mod_portaudio_stream \
+FORMATS_MODULES="formats/mod_local_stream formats/mod_native_file formats/mod_portaudio_stream \
formats/mod_shout formats/mod_sndfile formats/mod_tone_stream"
######################################################################################################################
@@ -493,7 +510,7 @@ PASSTHRU_CODEC_MODULES="codecs/mod_amr codecs/mod_amrwb codecs/mod_g723_1 codecs
# Phrase engine language modules
#
######################################################################################################################
-SAY_MODULES="say/mod_say_de say/mod_say_en say/mod_say_fr say/mod_say_ru"
+SAY_MODULES="say/mod_say_de say/mod_say_en say/mod_say_fr say/mod_say_he say/mod_say_ru"
######################################################################################################################
#
# Timers
@@ -568,6 +585,7 @@ fi
cd libs/esl
%{__make} pymod
+
######################################################################################################################
#
# Install it and create some required dirs and links
@@ -585,6 +603,16 @@ cd libs/esl
#install the esl stuff
cd libs/esl
%{__make} DESTDIR=%{buildroot} pymod-install
+
+%if %{build_py26_esl}
+#install esl for python 26
+%{__make} clean
+sed -i s/python\ /python26\ /g python/Makefile
+%{__make} pymod
+%{__mkdir} -p %{buildroot}/usr/lib/python2.6/site-packages
+%{__make} DESTDIR=%{buildroot} pymod-install
+%endif
+
cd ../..
%ifos linux
@@ -724,6 +752,7 @@ fi
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/cdr_csv.conf.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/cdr_pg_csv.conf.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/cdr_sqlite.conf.xml
+%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/cepstral.conf.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/cidlookup.conf.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/conference.conf.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/console.conf.xml
@@ -747,6 +776,7 @@ fi
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/logfile.conf.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/memcache.conf.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/modules.conf.xml
+%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/mongo.conf.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/nibblebill.conf.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/opal.conf.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/osp.conf.xml
@@ -874,7 +904,6 @@ fi
%{prefix}/mod/mod_event_socket.so*
%{prefix}/mod/mod_expr.so*
%{prefix}/mod/mod_fifo.so*
-%{prefix}/mod/mod_file_string.so*
%{prefix}/mod/mod_flite.so*
%{prefix}/mod/mod_fsv.so*
%{prefix}/mod/mod_hash.so*
@@ -1037,10 +1066,13 @@ fi
%dir %attr(0750, freeswitch, daemon) %{prefix}/conf/lang/en
%dir %attr(0750, freeswitch, daemon) %{prefix}/conf/lang/en/demo
%dir %attr(0750, freeswitch, daemon) %{prefix}/conf/lang/en/vm
+%dir %attr(0750, freeswitch, daemon) %{prefix}/conf/lang/en/dir
+%dir %attr(0750, freeswitch, daemon) %{prefix}/conf/lang/en/ivr
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/lang/en/*.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/lang/en/demo/*.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/lang/en/vm/*.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/lang/en/dir/*.xml
+%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/lang/en/ivr/*.xml
%{prefix}/mod/mod_say_en.so*
%files lang-de
@@ -1058,6 +1090,7 @@ fi
%dir %attr(0750, freeswitch, daemon) %{prefix}/conf/lang/fr
%dir %attr(0750, freeswitch, daemon) %{prefix}/conf/lang/fr/demo
%dir %attr(0750, freeswitch, daemon) %{prefix}/conf/lang/fr/vm
+%dir %attr(0750, freeswitch, daemon) %{prefix}/conf/lang/fr/dir
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/lang/fr/*.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/lang/fr/demo/*.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/lang/fr/vm/*.xml
@@ -1069,18 +1102,35 @@ fi
%dir %attr(0750, freeswitch, daemon) %{prefix}/conf/lang/ru
%dir %attr(0750, freeswitch, daemon) %{prefix}/conf/lang/ru/demo
%dir %attr(0750, freeswitch, daemon) %{prefix}/conf/lang/ru/vm
+%dir %attr(0750, freeswitch, daemon) %{prefix}/conf/lang/ru/dir
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/lang/ru/*.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/lang/ru/demo/*.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/lang/ru/vm/*.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/lang/ru/dir/*.xml
%{prefix}/mod/mod_say_ru.so*
+%files lang-he
+%defattr(-, freeswitch, daemon)
+%dir %attr(0750, freeswitch, daemon) %{prefix}/conf/lang/he/
+%dir %attr(0750, freeswitch, daemon) %{prefix}/conf/lang/he/demo
+%dir %attr(0750, freeswitch, daemon) %{prefix}/conf/lang/he/vm
+%dir %attr(0750, freeswitch, daemon) %{prefix}/conf/lang/he/dir
+%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/lang/he/*.xml
+%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/lang/he/demo/*.xml
+%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/lang/he/vm/*.xml
+%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/lang/he/dir/*.xml
+%{prefix}/mod/mod_say_he.so*
+
######################################################################################################################
#
# Changelog
#
######################################################################################################################
%changelog
+* Fri Apr 01 2011 - michal.bielicki@seventhsignal.de
+- added hebrew language stuff
+* Wed Mar 30 2011 - michal.bielicki@seventhsignal.de
+- removed mod_file_string since it has been merged into dptools
* Wed Feb 16 2011 - michal.bielicki@seventhsignal.de
- added mod_skinny
- added sangoma libraries
diff --git a/libs/.gitignore b/libs/.gitignore
index b31646500e..b9aa87286c 100644
--- a/libs/.gitignore
+++ b/libs/.gitignore
@@ -263,6 +263,19 @@
/js/nsprpub/pr/tests/dll/Makefile
/js/src/jsautocfg.h
/js/src/perlconnect/Makefile.PL
+/ldns/Makefile
+/ldns/doc/ldns_manpages
+/ldns/include/
+/ldns/ldns/config.h
+/ldns/ldns/net.h
+/ldns/ldns/util.h
+/ldns/lib
+/ldns/libtool
+/ldns/linktest
+/ldns/linktest.dSYM/
+/ldns/packaging/ldns-config
+/ldns/packaging/libldns.pc
+/ldns-1.6.9/
/libdingaling/Makefile
/libdingaling/Makefile.in
/libdingaling/aclocal.m4
@@ -346,6 +359,7 @@
/libg722_1/tests/Makefile
/libg722_1/tests/Makefile.in
/libg722_1/tests/regression_tests.sh
+/libg722_1/g722_1.pc
/libsndfile/Cfg/compile
/libsndfile/Cfg/config.guess
/libsndfile/Cfg/config.sub
@@ -1104,3 +1118,28 @@
/tiff-3.8.2/a.out.dSYM/
/tiff-3.8.2/tiff-Makefile.tgz
/unimrcp/a.out.dSYM/
+/esl/fs_cli.dSYM/
+/esl/ivrd.dSYM/
+/esl/testclient.dSYM/
+/esl/testserver.dSYM/
+
+/openssl-1.0.0a/
+/esl/Debug/
+/esl/Release/
+/freetdm/msvc/Release/
+/freetdm/msvc/Debug/
+
+/spandsp/src/msvc/All/BuildLog make_at_dictionary.htm
+/spandsp/src/msvc/All/BuildLog make_modem_filter.htm
+
+BuildLog*.htm
+/win32/tmp*.bat
+
+/speex/win32/VS2008/libspeex/*/*/libspeex.log
+/speex/win32/VS2008/libspeexdsp/*/*/libspeexdsp.log
+/win32/celt/*/*/libcelt.log
+/win32/libg722_1/*/*/libg722_1.log
+/win32/libshout/*/*/libshout.log
+openssl_manifest.rc
+libeay32_manifest.rc
+ssleay32_manifest.rc
diff --git a/libs/esl/Makefile b/libs/esl/Makefile
index fbc870ac24..60bae27b5f 100644
--- a/libs/esl/Makefile
+++ b/libs/esl/Makefile
@@ -34,10 +34,10 @@ testclient: $(MYLIB) testclient.c
fs_cli: $(MYLIB) fs_cli.c
$(CC) $(CC_CFLAGS) $(CFLAGS) fs_cli.c -o fs_cli $(LDFLAGS) -L$(LIBEDIT_DIR)/src/.libs $(LIBS) -ledit
-%.o: %.c
+%.o: %.c $(HEADERS)
$(CC) $(CC_CFLAGS) $(CFLAGS) -c $< -o $@
-%.o: %.cpp
+%.o: %.cpp $(HEADERS)
$(CXX) $(CXX_CFLAGS) $(CXXFLAGS) -c $< -o $@
clean:
@@ -92,6 +92,9 @@ javamod: $(MYLIB)
managedmod: $(MYLIB)
$(MAKE) MYLIB="../$(MYLIB)" SOLINK="$(SOLINK)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" CXX_CFLAGS="$(CXX_CFLAGS)" -C managed
+perlmod-install: perlmod
+ $(MAKE) -C perl install
+
phpmod-install: phpmod
$(MAKE) -C php install
diff --git a/libs/esl/fs_cli.c b/libs/esl/fs_cli.c
index 2985bca2af..5135f222ac 100644
--- a/libs/esl/fs_cli.c
+++ b/libs/esl/fs_cli.c
@@ -571,7 +571,7 @@ COLORS[] = { ESL_SEQ_DEFAULT_COLOR, ESL_SEQ_FRED, ESL_SEQ_FRED,
ESL_SEQ_FRED, ESL_SEQ_FMAGEN, ESL_SEQ_FCYAN, ESL_SEQ_FGREEN, ESL_SEQ_FYELLOW };
static int usage(char *name){
- printf("Usage: %s [-H ] [-P ] [-p ] [-d ] [-x command] [profile]\n\n", name);
+ printf("Usage: %s [-H ] [-P ] [-p ] [-d ] [-x command] [-t ] [profile]\n\n", name);
printf(" -?,-h --help Usage Information\n");
printf(" -H, --host=hostname Host to connect\n");
printf(" -P, --port=port Port to connect (1 - 65535)\n");
@@ -583,7 +583,8 @@ static int usage(char *name){
printf(" -q, --quiet Disable logging\n");
printf(" -r, --retry Retry connection on failure\n");
printf(" -R, --reconnect Reconnect if disconnected\n");
- printf(" -d, --debug=level Debug Level (0 - 7)\n\n");
+ printf(" -d, --debug=level Debug Level (0 - 7)\n");
+ printf(" -t, --timeout Timeout for API commands (in miliseconds)\n\n");
return 1;
}
@@ -839,9 +840,9 @@ static const char *basic_gets(int *cnt)
}
Sleep(20);
}
+#endif
return command_buf;
-#endif
}
#endif
@@ -1032,6 +1033,7 @@ int main(int argc, char *argv[])
{"retry", 0, 0, 'r'},
{"interrupt", 0, 0, 'i'},
{"reconnect", 0, 0, 'R'},
+ {"timeout", 1, 0, 't'},
{0, 0, 0, 0}
};
@@ -1050,7 +1052,7 @@ int main(int argc, char *argv[])
char argv_command[1024] = "";
char argv_loglevel[128] = "";
int argv_quiet = 0;
- int loops = 2, reconnect = 0;
+ int loops = 2, reconnect = 0, timeout = 0;
strncpy(internal_profile.host, "127.0.0.1", sizeof(internal_profile.host));
strncpy(internal_profile.pass, "ClueCon", sizeof(internal_profile.pass));
@@ -1075,7 +1077,7 @@ int main(int argc, char *argv[])
for(;;) {
int option_index = 0;
- opt = getopt_long(argc, argv, "H:U:P:S:u:p:d:x:l:qrRhi?", options, &option_index);
+ opt = getopt_long(argc, argv, "H:U:P:S:u:p:d:x:l:t:qrRhi?", options, &option_index);
if (opt == -1) break;
switch (opt)
{
@@ -1128,6 +1130,9 @@ int main(int argc, char *argv[])
case 'R':
reconnect = 1;
break;
+ case 't':
+ timeout = atoi(optarg);
+ break;
case 'h':
case '?':
print_banner(stdout);
@@ -1284,7 +1289,17 @@ int main(int argc, char *argv[])
const char *err = NULL;
snprintf(cmd_str, sizeof(cmd_str), "api %s\n\n", argv_command);
- esl_send_recv(&handle, cmd_str);
+ if (timeout) {
+ esl_status_t status = esl_send_recv_timed(&handle, cmd_str, timeout);
+ if (status != ESL_SUCCESS) {
+ printf("Request timed out.\n");
+ esl_disconnect(&handle);
+ return -2;
+ }
+ } else {
+ esl_send_recv(&handle, cmd_str);
+ }
+
if (handle.last_sr_event) {
if (handle.last_sr_event->body) {
printf("%s\n", handle.last_sr_event->body);
diff --git a/libs/esl/lua/esl_lua.2010.sln b/libs/esl/lua/esl_lua.2010.sln
new file mode 100644
index 0000000000..5cdab36b1c
--- /dev/null
+++ b/libs/esl/lua/esl_lua.2010.sln
@@ -0,0 +1,26 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ESL", "esl_lua.2010.vcxproj", "{86B6AB99-A261-455A-9CD6-9142A5A1652E}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Debug|x64 = Debug|x64
+ Release|Win32 = Release|Win32
+ Release|x64 = Release|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {86B6AB99-A261-455A-9CD6-9142A5A1652E}.Debug|Win32.ActiveCfg = Debug|Win32
+ {86B6AB99-A261-455A-9CD6-9142A5A1652E}.Debug|Win32.Build.0 = Debug|Win32
+ {86B6AB99-A261-455A-9CD6-9142A5A1652E}.Debug|x64.ActiveCfg = Debug|x64
+ {86B6AB99-A261-455A-9CD6-9142A5A1652E}.Debug|x64.Build.0 = Debug|x64
+ {86B6AB99-A261-455A-9CD6-9142A5A1652E}.Release|Win32.ActiveCfg = Release|Win32
+ {86B6AB99-A261-455A-9CD6-9142A5A1652E}.Release|Win32.Build.0 = Release|Win32
+ {86B6AB99-A261-455A-9CD6-9142A5A1652E}.Release|x64.ActiveCfg = Release|x64
+ {86B6AB99-A261-455A-9CD6-9142A5A1652E}.Release|x64.Build.0 = Release|x64
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/libs/esl/lua/esl_lua.2010.vcxproj b/libs/esl/lua/esl_lua.2010.vcxproj
new file mode 100644
index 0000000000..99a355f95a
--- /dev/null
+++ b/libs/esl/lua/esl_lua.2010.vcxproj
@@ -0,0 +1,178 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ ESL
+ {86B6AB99-A261-455A-9CD6-9142A5A1652E}
+ esl_lua.2010
+ Win32Proj
+
+
+
+ DynamicLibrary
+
+
+ DynamicLibrary
+
+
+ DynamicLibrary
+
+
+ DynamicLibrary
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <_ProjectFileVersion>10.0.40219.1
+ $(Platform)\$(Configuration)\
+ $(Platform)\$(Configuration)\
+ true
+ $(Platform)\$(Configuration)\
+ $(Platform)\$(Configuration)\
+ true
+ $(Platform)\$(Configuration)\
+ $(Platform)\$(Configuration)\
+ true
+ $(Platform)\$(Configuration)\
+ $(Platform)\$(Configuration)\
+ true
+ AllRules.ruleset
+
+
+ AllRules.ruleset
+
+
+ AllRules.ruleset
+
+
+ AllRules.ruleset
+
+
+
+
+
+ Disabled
+ $(ProjectDir)..\..\..\src\mod\languages\mod_lua\lua\;$(ProjectDir)..\src\include;%(AdditionalIncludeDirectories)
+ ESL_DECLARE_STATIC;WIN32;%(PreprocessorDefinitions)
+ true
+ EnableFastChecks
+ MultiThreadedDebugDLL
+
+
+ Level3
+ EditAndContinue
+
+
+ esl.lib;lua51.lib;ws2_32.lib;%(AdditionalDependencies)
+ $(ProjectDir)..\..\..\$(Platform)\$(Configuration)\;$(ProjectDir)..\..\..\libs\esl\src\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)
+ true
+ Windows
+ MachineX86
+
+
+
+
+ $(ProjectDir)..\..\..\src\mod\languages\mod_lua\lua\;$(ProjectDir)..\src\include;%(AdditionalIncludeDirectories)
+ ESL_DECLARE_STATIC;WIN32;%(PreprocessorDefinitions)
+ MultiThreadedDLL
+
+
+ Level3
+ ProgramDatabase
+
+
+ esl.lib;lua51.lib;ws2_32.lib;%(AdditionalDependencies)
+ $(ProjectDir)..\..\..\$(Platform)\$(Configuration)\;$(ProjectDir)..\..\..\libs\esl\src\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)
+ true
+ Windows
+ true
+ true
+ MachineX86
+
+
+
+
+ X64
+
+
+ Disabled
+ $(ProjectDir)..\..\..\src\mod\languages\mod_lua\lua\;$(ProjectDir)..\src\include;%(AdditionalIncludeDirectories)
+ ESL_DECLARE_STATIC;WIN32;%(PreprocessorDefinitions)
+ true
+ EnableFastChecks
+ MultiThreadedDebugDLL
+
+
+ Level3
+ ProgramDatabase
+
+
+ esl.lib;lua51.lib;ws2_32.lib;%(AdditionalDependencies)
+ $(ProjectDir)..\..\..\$(Platform)\$(Configuration);$(ProjectDir)..\..\..\libs\esl\src\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)
+ true
+ Windows
+ MachineX64
+
+
+
+
+ X64
+
+
+ $(ProjectDir)..\..\..\src\mod\languages\mod_lua\lua\;$(ProjectDir)..\src\include;%(AdditionalIncludeDirectories)
+ ESL_DECLARE_STATIC;WIN32;%(PreprocessorDefinitions)
+ MultiThreadedDLL
+
+
+ Level3
+ ProgramDatabase
+
+
+ esl.lib;lua51.lib;ws2_32.lib;%(AdditionalDependencies)
+ $(ProjectDir)..\..\..\$(Platform)\$(Configuration);$(ProjectDir)..\..\..\libs\esl\src\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)
+ true
+ Windows
+ true
+ true
+ MachineX64
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/libs/esl/lua/esl_lua.2010.vcxproj.filters b/libs/esl/lua/esl_lua.2010.vcxproj.filters
new file mode 100644
index 0000000000..51644e4cdf
--- /dev/null
+++ b/libs/esl/lua/esl_lua.2010.vcxproj.filters
@@ -0,0 +1,25 @@
+
+
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hpp;hxx;hm;inl;inc;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+
+
+ Source Files
+
+
+ Source Files
+
+
+
\ No newline at end of file
diff --git a/libs/esl/perl/ESL/IVR.pm b/libs/esl/perl/ESL/IVR.pm
index f7919c1b94..5dc6088236 100644
--- a/libs/esl/perl/ESL/IVR.pm
+++ b/libs/esl/perl/ESL/IVR.pm
@@ -73,13 +73,13 @@ sub setVar($;) {
sub playAndGetDigits($;) {
my $self = shift;
- my ($min, $max, $tries, $to, $term, $file, $invalid_file, $var, $regex) = @_;
+ my ($min, $max, $tries, $to, $term, $file, $invalid_file, $var, $regex, $digit_timeout) = @_;
if (!$self->{_esl}->connected()) {
return undef;
}
- $self->execute("play_and_get_digits", "$min $max $tries $to $term $file $invalid_file $var $regex");
+ $self->execute("play_and_get_digits", "$min $max $tries $to $term $file $invalid_file $var $regex $digit_timeout");
return $self->getVar($var);
diff --git a/libs/esl/perl/Makefile b/libs/esl/perl/Makefile
index 058e0d3849..a76e9c5e6d 100644
--- a/libs/esl/perl/Makefile
+++ b/libs/esl/perl/Makefile
@@ -1,4 +1,5 @@
PERL=$(shell which perl)
+PERL_SITEDIR=$(shell perl -MConfig -e 'print $$Config{sitelibexp}')
PERL_LIBDIR=-L$(shell perl -MConfig -e 'print $$Config{archlib}')/CORE
PERL_LIBS=$(shell perl -MConfig -e 'print $$Config{libs}')
LOCAL_CFLAGS=-w -DMULTIPLICITY $(shell $(PERL) -MExtUtils::Embed -e ccopts) -DEMBED_PERL
@@ -30,3 +31,8 @@ swigclean:
reswig: swigclean esl_wrap.cpp perlxsi.c
+install: ESL.so
+ install -m 755 ESL.so $(PERL_SITEDIR)
+ install -m 755 ESL.pm $(PERL_SITEDIR)
+ install -d -m 755 ESL $(PERL_SITEDIR)/ESL
+ install -m 755 ESL/* $(PERL_SITEDIR)/ESL
\ No newline at end of file
diff --git a/libs/esl/perl/logger.pl b/libs/esl/perl/logger.pl
index 08213c033f..d26e8f9fbc 100644
--- a/libs/esl/perl/logger.pl
+++ b/libs/esl/perl/logger.pl
@@ -18,6 +18,7 @@ FreeSWITCH Logger Utility
USAGE:
-h --help This help
+-H --host Choose host
-p --port Choose port
-P -pass Choose password
-f --file Output file
@@ -42,12 +43,12 @@ sub parse(\$\$$) {
}
for($i = 0; $i < $argc; $i++) {
- if ($ARGV[$i] =~ /^\-help$|^\-\-help$/) {
+ if ($ARGV[$i] =~ /^\-h$|^\-\-help$/) {
print $USAGE;
exit;
}
- if (! (parse($i, $host, '^-h$|^--host$') ||
+ if (! (parse($i, $host, '^-H$|^--host$') ||
parse($i, $port, '^-p$|^--port$') ||
parse($i, $pass, '^-P$|^--pass$') ||
parse($i, $file, '^-f$|^--file$') ||
diff --git a/libs/esl/src/esl.c b/libs/esl/src/esl.c
index b0bc311ce0..675ecee460 100644
--- a/libs/esl/src/esl.c
+++ b/libs/esl/src/esl.c
@@ -31,6 +31,24 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
+/* Use select on windows and poll everywhere else.
+ Select is the devil. Especially if you are doing a lot of small socket connections.
+ If your FD number is bigger than 1024 you will silently create memory corruption.
+
+ If you have build errors on your platform because you don't have poll find a way to detect it and #define ESL_USE_SELECT and #undef ESL_USE_POLL
+ All of this will be upgraded to autoheadache eventually.
+*/
+
+/* TBD for win32 figure out how to tell if you have WSAPoll (vista or higher) and use it when available by #defining ESL_USE_WSAPOLL (see below) */
+
+#ifdef _MSC_VER
+#define FD_SETSIZE 8192
+#define ESL_USE_SELECT
+#else
+#define ESL_USE_POLL
+#endif
+
#include
#ifndef WIN32
#define closesocket(x) close(x)
@@ -42,6 +60,10 @@
#pragma warning (default:6386)
#endif
+#ifdef ESL_USE_POLL
+#include
+#endif
+
/* Written by Marc Espie, public domain */
#define ESL_CTYPE_NUM_CHARS 256
@@ -301,7 +323,7 @@ static void default_logger(const char *file, const char *func, int line, int lev
ret = esl_vasprintf(&data, fmt, ap);
if (ret != -1) {
- fprintf(stderr, "[%s] %s:%d %s() %s", LEVEL_NAMES[level], file, line, func, data);
+ fprintf(stderr, "[%s] %s:%d %s() %s", LEVEL_NAMES[level], fp, line, func, data);
free(data);
}
@@ -614,6 +636,143 @@ ESL_DECLARE(esl_status_t) esl_listen(const char *host, esl_port_t port, esl_list
}
+
+/* USE WSAPoll on vista or higher */
+#ifdef ESL_USE_WSAPOLL
+ESL_DECLARE(int) esl_wait_sock(esl_socket_t sock, uint32_t ms, esl_poll_t flags)
+{
+}
+#endif
+
+
+#ifdef ESL_USE_SELECT
+#ifdef WIN32
+#pragma warning( push )
+#pragma warning( disable : 6262 ) /* warning C6262: Function uses '98348' bytes of stack: exceeds /analyze:stacksize'16384'. Consider moving some data to heap */
+#endif
+ESL_DECLARE(int) esl_wait_sock(esl_socket_t sock, uint32_t ms, esl_poll_t flags)
+{
+ int s = 0, r = 0;
+ fd_set rfds;
+ fd_set wfds;
+ fd_set efds;
+ struct timeval tv;
+
+ FD_ZERO(&rfds);
+ FD_ZERO(&wfds);
+ FD_ZERO(&efds);
+
+ /* Wouldn't you rather know?? */
+ assert(sock <= FD_SETSIZE);
+
+
+ if ((flags & ESL_POLL_READ)) {
+
+#ifdef WIN32
+#pragma warning( push )
+#pragma warning( disable : 4127 )
+ FD_SET(sock, &rfds);
+#pragma warning( pop )
+#else
+ FD_SET(sock, &rfds);
+#endif
+ }
+
+ if ((flags & ESL_POLL_WRITE)) {
+
+#ifdef WIN32
+#pragma warning( push )
+#pragma warning( disable : 4127 )
+ FD_SET(sock, &wfds);
+#pragma warning( pop )
+#else
+ FD_SET(sock, &wfds);
+#endif
+ }
+
+ if ((flags & ESL_POLL_ERROR)) {
+
+#ifdef WIN32
+#pragma warning( push )
+#pragma warning( disable : 4127 )
+ FD_SET(sock, &efds);
+#pragma warning( pop )
+#else
+ FD_SET(sock, &efds);
+#endif
+ }
+
+ tv.tv_sec = ms / 1000;
+ tv.tv_usec = (ms % 1000) * ms;
+
+ s = select(sock + 1, (flags & ESL_POLL_READ) ? &rfds : NULL, (flags & ESL_POLL_WRITE) ? &wfds : NULL, (flags & ESL_POLL_ERROR) ? &efds : NULL, &tv);
+
+ if (s < 0) {
+ r = s;
+ } else if (s > 0) {
+ if ((flags & ESL_POLL_READ) && FD_ISSET(sock, &rfds)) {
+ r |= ESL_POLL_READ;
+ }
+
+ if ((flags & ESL_POLL_WRITE) && FD_ISSET(sock, &wfds)) {
+ r |= ESL_POLL_WRITE;
+ }
+
+ if ((flags & ESL_POLL_ERROR) && FD_ISSET(sock, &efds)) {
+ r |= ESL_POLL_ERROR;
+ }
+ }
+
+ return r;
+
+}
+#ifdef WIN32
+#pragma warning( pop )
+#endif
+#endif
+
+#ifdef ESL_USE_POLL
+ESL_DECLARE(int) esl_wait_sock(esl_socket_t sock, uint32_t ms, esl_poll_t flags)
+{
+ struct pollfd pfds[2] = { { 0 } };
+ int s = 0, r = 0;
+
+ pfds[0].fd = sock;
+
+ if ((flags & ESL_POLL_READ)) {
+ pfds[0].events |= POLLIN;
+ }
+
+ if ((flags & ESL_POLL_WRITE)) {
+ pfds[0].events |= POLLOUT;
+ }
+
+ if ((flags & ESL_POLL_ERROR)) {
+ pfds[0].events |= POLLERR;
+ }
+
+ s = poll(pfds, 1, ms);
+
+ if (s < 0) {
+ r = s;
+ } else if (s > 0) {
+ if ((pfds[0].revents & POLLIN)) {
+ r |= ESL_POLL_READ;
+ }
+ if ((pfds[0].revents & POLLOUT)) {
+ r |= ESL_POLL_WRITE;
+ }
+ if ((pfds[0].revents & POLLERR)) {
+ r |= ESL_POLL_ERROR;
+ }
+ }
+
+ return r;
+
+}
+#endif
+
+
ESL_DECLARE(esl_status_t) esl_connect_timeout(esl_handle_t *handle, const char *host, esl_port_t port, const char *user, const char *password, uint32_t timeout)
{
char sendbuf[256];
@@ -681,30 +840,17 @@ ESL_DECLARE(esl_status_t) esl_connect_timeout(esl_handle_t *handle, const char *
rval = connect(handle->sock, (struct sockaddr*)&handle->sockaddr, sizeof(handle->sockaddr));
if (timeout) {
- fd_set wfds;
- struct timeval tv;
int r;
- tv.tv_sec = timeout / 1000;
- tv.tv_usec = (timeout % 1000) * 1000;
- FD_ZERO(&wfds);
-#ifdef WIN32
-#pragma warning( push )
-#pragma warning( disable : 4127 )
- FD_SET(handle->sock, &wfds);
-#pragma warning( pop )
-#else
- FD_SET(handle->sock, &wfds);
-#endif
- r = select(handle->sock + 1, NULL, &wfds, NULL, &tv);
+ r = esl_wait_sock(handle->sock, timeout, ESL_POLL_WRITE);
if (r <= 0) {
snprintf(handle->err, sizeof(handle->err), "Connection timed out");
goto fail;
}
- if (!FD_ISSET(handle->sock, &wfds)) {
+ if (!(r & ESL_POLL_WRITE)) {
snprintf(handle->err, sizeof(handle->err), "Connection timed out");
goto fail;
}
@@ -823,9 +969,7 @@ ESL_DECLARE(esl_status_t) esl_disconnect(esl_handle_t *handle)
ESL_DECLARE(esl_status_t) esl_recv_event_timed(esl_handle_t *handle, uint32_t ms, int check_q, esl_event_t **save_event)
{
- fd_set rfds, efds;
- struct timeval tv = { 0 };
- int max, activity;
+ int activity;
esl_status_t status = ESL_SUCCESS;
if (!ms) {
@@ -845,55 +989,24 @@ ESL_DECLARE(esl_status_t) esl_recv_event_timed(esl_handle_t *handle, uint32_t ms
esl_mutex_unlock(handle->mutex);
}
- tv.tv_usec = ms * 1000;
-
- FD_ZERO(&rfds);
- FD_ZERO(&efds);
-
-#ifdef WIN32
-#pragma warning( push )
-#pragma warning( disable : 4127 )
- FD_SET(handle->sock, &rfds);
- FD_SET(handle->sock, &efds);
-#pragma warning( pop )
-#else
- FD_SET(handle->sock, &rfds);
- FD_SET(handle->sock, &efds);
-#endif
-
- max = handle->sock + 1;
+ activity = esl_wait_sock(handle->sock, ms, ESL_POLL_READ|ESL_POLL_ERROR);
- if ((activity = select(max, &rfds, NULL, &efds, &tv)) < 0) {
+ if (activity < 0) {
handle->connected = 0;
return ESL_FAIL;
}
- if (activity == 0 || !FD_ISSET(handle->sock, &rfds) || (esl_mutex_trylock(handle->mutex) != ESL_SUCCESS)) {
+ if (activity == 0 || !(activity & ESL_POLL_READ) || (esl_mutex_trylock(handle->mutex) != ESL_SUCCESS)) {
return ESL_BREAK;
}
- tv.tv_usec = 0;
+ activity = esl_wait_sock(handle->sock, ms, ESL_POLL_READ|ESL_POLL_ERROR);
- FD_ZERO(&rfds);
- FD_ZERO(&efds);
-
-#ifdef WIN32
-#pragma warning( push )
-#pragma warning( disable : 4127 )
- FD_SET(handle->sock, &rfds);
- FD_SET(handle->sock, &efds);
-#pragma warning( pop )
-#else
- FD_SET(handle->sock, &rfds);
- FD_SET(handle->sock, &efds);
-#endif
-
- activity = select(max, &rfds, NULL, &efds, &tv);
if (activity < 0) {
handle->connected = 0;
status = ESL_FAIL;
- } else if (activity > 0 && FD_ISSET(handle->sock, &rfds)) {
+ } else if (activity > 0 && (activity & ESL_POLL_READ)) {
if (esl_recv_event(handle, check_q, save_event)) {
status = ESL_FAIL;
}
@@ -912,6 +1025,51 @@ static esl_ssize_t handle_recv(esl_handle_t *handle, void *data, esl_size_t data
return recv(handle->sock, data, datalen, 0);
}
+static int add_array(esl_event_t *event, const char *var, const char *val)
+{
+ char *data;
+ char **array;
+ int idx;
+ int max = 0;
+ int len;
+ const char *p;
+ int i;
+
+ if (strlen(val) < 8) {
+ return -1;
+ }
+
+ p = val + 7;
+
+ while((p = strstr(p, "::"))) {
+ max++;
+ p += 2;
+ }
+
+ if (!max) {
+ return -2;
+ }
+
+ data = strdup(val + 7);
+
+ len = (sizeof(char *) * max) + 1;
+ array = malloc(len);
+ memset(array, 0, len);
+
+ idx = esl_separate_string_string(data, "::", array, max);
+
+ for(i = 0; i < max; i++) {
+ esl_event_add_header_string(event, ESL_STACK_PUSH, var, array[i]);
+ }
+
+ free(array);
+ free(data);
+
+ return 0;
+}
+
+
+
ESL_DECLARE(esl_status_t) esl_recv_event(esl_handle_t *handle, int check_q, esl_event_t **save_event)
{
char *c;
@@ -934,7 +1092,6 @@ ESL_DECLARE(esl_status_t) esl_recv_event(esl_handle_t *handle, int check_q, esl_
goto fail;
}
- esl_event_safe_destroy(&handle->last_event);
esl_event_safe_destroy(&handle->last_ievent);
if (check_q && handle->race_event) {
@@ -976,7 +1133,11 @@ ESL_DECLARE(esl_status_t) esl_recv_event(esl_handle_t *handle, int check_q, esl_
if (hname && hval) {
esl_url_decode(hval);
esl_log(ESL_LOG_DEBUG, "RECV HEADER [%s] = [%s]\n", hname, hval);
- esl_event_add_header_string(revent, ESL_STACK_BOTTOM, hname, hval);
+ if (!strncmp(hval, "ARRAY::", 7)) {
+ add_array(revent, hname, hval);
+ } else {
+ esl_event_add_header_string(revent, ESL_STACK_BOTTOM, hname, hval);
+ }
}
p = e;
@@ -1053,6 +1214,7 @@ ESL_DECLARE(esl_status_t) esl_recv_event(esl_handle_t *handle, int check_q, esl_
*save_event = revent;
revent = NULL;
} else {
+ esl_event_safe_destroy(&handle->last_event);
handle->last_event = revent;
}
@@ -1104,7 +1266,12 @@ ESL_DECLARE(esl_status_t) esl_recv_event(esl_handle_t *handle, int check_q, esl_
esl_event_del_header(handle->last_ievent, "event-name");
esl_name_event(hval, &handle->last_ievent->event_id);
}
- esl_event_add_header_string(handle->last_ievent, ESL_STACK_BOTTOM, hname, hval);
+
+ if (!strncmp(hval, "ARRAY::", 7)) {
+ add_array(handle->last_ievent, hname, hval);
+ } else {
+ esl_event_add_header_string(handle->last_ievent, ESL_STACK_BOTTOM, hname, hval);
+ }
}
beg = c + 1;
@@ -1258,5 +1425,23 @@ ESL_DECLARE(esl_status_t) esl_send_recv_timed(esl_handle_t *handle, const char *
}
+ESL_DECLARE(unsigned int) esl_separate_string_string(char *buf, const char *delim, char **array, unsigned int arraylen)
+{
+ unsigned int count = 0;
+ char *d;
+ size_t dlen = strlen(delim);
+ array[count++] = buf;
+
+ while (count < arraylen && array[count - 1]) {
+ if ((d = strstr(array[count - 1], delim))) {
+ *d = '\0';
+ d += dlen;
+ array[count++] = d;
+ } else
+ break;
+ }
+
+ return count;
+}
diff --git a/libs/esl/src/esl_event.c b/libs/esl/src/esl_event.c
index 9bd78a838d..614d1b6190 100644
--- a/libs/esl/src/esl_event.c
+++ b/libs/esl/src/esl_event.c
@@ -235,8 +235,7 @@ static unsigned int esl_ci_hashfunc_default(const char *char_key, esl_ssize_t *k
return hash;
}
-
-ESL_DECLARE(char *)esl_event_get_header(esl_event_t *event, const char *header_name)
+ESL_DECLARE(esl_event_header_t *) esl_event_get_header_ptr(esl_event_t *event, const char *header_name)
{
esl_event_header_t *hp;
esl_ssize_t hlen = -1;
@@ -244,18 +243,39 @@ ESL_DECLARE(char *)esl_event_get_header(esl_event_t *event, const char *header_n
esl_assert(event);
- if (!header_name) return NULL;
-
+ if (!header_name)
+ return NULL;
+
hash = esl_ci_hashfunc_default(header_name, &hlen);
-
+
for (hp = event->headers; hp; hp = hp->next) {
- if ((!hp->hash || hash == hp->hash) && !strcasecmp(hp->name, header_name) ) {
- return hp->value;
+ if ((!hp->hash || hash == hp->hash) && !strcasecmp(hp->name, header_name)) {
+ return hp;
}
}
return NULL;
}
+ESL_DECLARE(char *) esl_event_get_header_idx(esl_event_t *event, const char *header_name, int idx)
+{
+ esl_event_header_t *hp;
+
+ if ((hp = esl_event_get_header_ptr(event, header_name))) {
+ if (idx > -1) {
+ if (idx < hp->idx) {
+ return hp->array[idx];
+ } else {
+ return NULL;
+ }
+ }
+
+ return hp->value;
+
+ }
+
+ return NULL;
+}
+
ESL_DECLARE(char *)esl_event_get_body(esl_event_t *event)
{
return (event ? event->body : NULL);
@@ -264,7 +284,7 @@ ESL_DECLARE(char *)esl_event_get_body(esl_event_t *event)
ESL_DECLARE(esl_status_t) esl_event_del_header_val(esl_event_t *event, const char *header_name, const char *val)
{
esl_event_header_t *hp, *lp = NULL, *tp;
- esl_status_t status = ESL_FAIL;
+ esl_status_t status = ESL_FALSE;
int x = 0;
esl_ssize_t hlen = -1;
unsigned long hash = 0;
@@ -273,12 +293,12 @@ ESL_DECLARE(esl_status_t) esl_event_del_header_val(esl_event_t *event, const cha
while (tp) {
hp = tp;
tp = tp->next;
-
+
x++;
- esl_assert(x < 1000);
+ esl_assert(x < 1000000);
hash = esl_ci_hashfunc_default(header_name, &hlen);
- if (hp->name && (!hp->hash || hash == hp->hash) && !strcasecmp(header_name, hp->name) && (esl_strlen_zero(val) || !strcmp(hp->value, val))) {
+ if ((!hp->hash || hash == hp->hash) && !strcasecmp(header_name, hp->name) && (esl_strlen_zero(val) || !strcmp(hp->value, val))) {
if (lp) {
lp->next = hp->next;
} else {
@@ -288,10 +308,27 @@ ESL_DECLARE(esl_status_t) esl_event_del_header_val(esl_event_t *event, const cha
event->last_header = lp;
}
FREE(hp->name);
- FREE(hp->value);
- memset(hp, 0, sizeof(*hp));
- FREE(hp);
+ if (hp->idx) {
+ int i = 0;
+ hp->value = NULL;
+
+ for (i = 0; i < hp->idx; i++) {
+ FREE(hp->array[i]);
+ }
+ FREE(hp->array);
+ }
+
+ FREE(hp->value);
+
+ memset(hp, 0, sizeof(*hp));
+#ifdef ESL_EVENT_RECYCLE
+ if (esl_queue_trypush(EVENT_HEADER_RECYCLE_QUEUE, hp) != ESL_SUCCESS) {
+ FREE(hp);
+ }
+#else
+ FREE(hp);
+#endif
status = ESL_SUCCESS;
} else {
lp = hp;
@@ -303,36 +340,122 @@ ESL_DECLARE(esl_status_t) esl_event_del_header_val(esl_event_t *event, const cha
static esl_status_t esl_event_base_add_header(esl_event_t *event, esl_stack_t stack, const char *header_name, char *data)
{
- esl_event_header_t *header;
+ esl_event_header_t *header = NULL;
esl_ssize_t hlen = -1;
+ int exists = 0;
- header = ALLOC(sizeof(*header));
- esl_assert(header);
+ if ((stack & ESL_STACK_PUSH) || (stack & ESL_STACK_UNSHIFT) || esl_test_flag(event, ESL_EF_CONTAINS_ARRAYS)) {
- if ((event->flags & ESL_UNIQ_HEADERS)) {
- esl_event_del_header(event, header_name);
+ if ((header = esl_event_get_header_ptr(event, header_name))) {
+
+ if (!(stack & ESL_STACK_PUSH) && !(stack & ESL_STACK_UNSHIFT) && header->idx) {
+ stack |= ESL_STACK_PUSH;
+ }
+
+ if ((stack & ESL_STACK_PUSH) || (stack & ESL_STACK_UNSHIFT)) {
+ exists++;
+ stack &= ~(ESL_STACK_TOP | ESL_STACK_BOTTOM);
+ } else {
+ header = NULL;
+ }
+ }
}
- memset(header, 0, sizeof(*header));
+ if (!header) {
- header->name = DUP(header_name);
- header->value = data;
- header->hash = esl_ci_hashfunc_default(header->name, &hlen);
+#ifdef ESL_EVENT_RECYCLE
+ void *pop;
+ if (esl_queue_trypop(EVENT_HEADER_RECYCLE_QUEUE, &pop) == ESL_SUCCESS) {
+ header = (esl_event_header_t *) pop;
+ } else {
+#endif
+ header = ALLOC(sizeof(*header));
+ esl_assert(header);
+#ifdef ESL_EVENT_RECYCLE
+ }
+#endif
- if (stack == ESL_STACK_TOP) {
- header->next = event->headers;
- event->headers = header;
- if (!event->last_header) {
+
+ if (esl_test_flag(event, ESL_EF_UNIQ_HEADERS)) {
+ esl_event_del_header(event, header_name);
+ }
+
+ memset(header, 0, sizeof(*header));
+
+ header->name = DUP(header_name);
+ }
+
+ if ((stack & ESL_STACK_PUSH) || (stack & ESL_STACK_UNSHIFT)) {
+ char **m = NULL;
+ esl_size_t len = 0;
+ char *hv;
+ int i = 0, j = 0;
+
+ esl_set_flag(event, ESL_EF_CONTAINS_ARRAYS);
+
+ if (header->value && !header->idx) {
+ m = malloc(sizeof(char *));
+ esl_assert(m);
+ m[0] = header->value;
+ header->value = NULL;
+ header->array = m;
+ header->idx++;
+ m = NULL;
+ }
+
+ i = header->idx + 1;
+ m = realloc(header->array, sizeof(char *) * i);
+ esl_assert(m);
+
+ if ((stack & ESL_STACK_PUSH)) {
+ m[header->idx] = data;
+ } else if ((stack & ESL_STACK_UNSHIFT)) {
+ for (j = header->idx; j > 0; j--) {
+ m[j] = m[j-1];
+ }
+ m[0] = data;
+ }
+
+ header->idx++;
+ header->array = m;
+
+ for(j = 0; j < header->idx; j++) {
+ len += strlen(header->array[j]) + 2;
+ }
+
+ if (len) {
+ len += 8;
+ hv = realloc(header->value, len);
+ esl_assert(hv);
+ header->value = hv;
+ esl_snprintf(header->value, len, "ARRAY::");
+ for(j = 0; j < header->idx; j++) {
+ esl_snprintf(header->value + strlen(header->value), len - strlen(header->value), "%s%s", j == 0 ? "" : "::", header->array[j]);
+ }
+ }
+
+ } else {
+ header->value = data;
+ }
+
+ if (!exists) {
+ header->hash = esl_ci_hashfunc_default(header->name, &hlen);
+
+ if ((stack & ESL_STACK_TOP)) {
+ header->next = event->headers;
+ event->headers = header;
+ if (!event->last_header) {
+ event->last_header = header;
+ }
+ } else {
+ if (event->last_header) {
+ event->last_header->next = header;
+ } else {
+ event->headers = header;
+ header->next = NULL;
+ }
event->last_header = header;
}
- } else {
- if (event->last_header) {
- event->last_header->next = header;
- } else {
- event->headers = header;
- header->next = NULL;
- }
- event->last_header = header;
}
return ESL_SUCCESS;
@@ -386,48 +509,98 @@ ESL_DECLARE(esl_status_t) esl_event_add_body(esl_event_t *event, const char *fmt
}
}
+
ESL_DECLARE(void) esl_event_destroy(esl_event_t **event)
{
- esl_event_t *ep = *event, *this_event;
- esl_event_header_t *hp, *this_header;
+ esl_event_t *ep = *event;
+ esl_event_header_t *hp, *this;
- for (ep = *event ; ep ;) {
- this_event = ep;
- ep = ep->next;
-
- for (hp = this_event->headers; hp;) {
- this_header = hp;
+ if (ep) {
+ for (hp = ep->headers; hp;) {
+ this = hp;
hp = hp->next;
- FREE(this_header->name);
- FREE(this_header->value);
- memset(this_header, 0, sizeof(*this_header));
- FREE(this_header);
+ FREE(this->name);
+
+ if (this->idx) {
+ int i = 0;
+ this->value = NULL;
+ for (i = 0; i < this->idx; i++) {
+ FREE(this->array[i]);
+ }
+ FREE(this->array);
+ }
+
+ FREE(this->value);
+
+
+#ifdef ESL_EVENT_RECYCLE
+ if (esl_queue_trypush(EVENT_HEADER_RECYCLE_QUEUE, this) != ESL_SUCCESS) {
+ FREE(this);
+ }
+#else
+ FREE(this);
+#endif
+
+
}
- FREE(this_event->body);
- FREE(this_event->subclass_name);
- memset(this_event, 0, sizeof(*this_event));
- FREE(this_event);
+ FREE(ep->body);
+ FREE(ep->subclass_name);
+#ifdef ESL_EVENT_RECYCLE
+ if (esl_queue_trypush(EVENT_RECYCLE_QUEUE, ep) != ESL_SUCCESS) {
+ FREE(ep);
+ }
+#else
+ FREE(ep);
+#endif
+
}
*event = NULL;
}
+ESL_DECLARE(void) esl_event_merge(esl_event_t *event, esl_event_t *tomerge)
+{
+ esl_event_header_t *hp;
+
+ esl_assert(tomerge && event);
+ for (hp = tomerge->headers; hp; hp = hp->next) {
+ if (hp->idx) {
+ int i;
+
+ for(i = 0; i < hp->idx; i++) {
+ esl_event_add_header_string(event, ESL_STACK_PUSH, hp->name, hp->array[i]);
+ }
+ } else {
+ esl_event_add_header_string(event, ESL_STACK_BOTTOM, hp->name, hp->value);
+ }
+ }
+}
ESL_DECLARE(esl_status_t) esl_event_dup(esl_event_t **event, esl_event_t *todup)
{
esl_event_header_t *hp;
if (esl_event_create_subclass(event, ESL_EVENT_CLONE, todup->subclass_name) != ESL_SUCCESS) {
- return ESL_FAIL;
+ return ESL_GENERR;
}
(*event)->event_id = todup->event_id;
-
(*event)->event_user_data = todup->event_user_data;
(*event)->bind_user_data = todup->bind_user_data;
-
+ (*event)->flags = todup->flags;
for (hp = todup->headers; hp; hp = hp->next) {
- esl_event_add_header_string(*event, ESL_STACK_BOTTOM, hp->name, hp->value);
+ if (todup->subclass_name && !strcmp(hp->name, "Event-Subclass")) {
+ continue;
+ }
+
+ if (hp->idx) {
+ int i;
+ for (i = 0; i < hp->idx; i++) {
+ esl_event_add_header_string(*event, ESL_STACK_PUSH, hp->name, hp->array[i]);
+ }
+ } else {
+ esl_event_add_header_string(*event, ESL_STACK_BOTTOM, hp->name, hp->value);
+ }
}
if (todup->body) {
@@ -439,97 +612,26 @@ ESL_DECLARE(esl_status_t) esl_event_dup(esl_event_t **event, esl_event_t *todup)
return ESL_SUCCESS;
}
-ESL_DECLARE(esl_status_t) esl_event_create_json(esl_event_t **event, const char *json)
-{
- esl_event_t *new_event;
- cJSON *cj, *cjp;
-
-
- if (!(cj = cJSON_Parse(json))) {
- return ESL_FAIL;
- }
-
- if (esl_event_create(&new_event, ESL_EVENT_CLONE) != ESL_SUCCESS) {
- cJSON_Delete(cj);
- return ESL_FAIL;
- }
-
- for (cjp = cj->child; cjp; cjp = cjp->next) {
- char *name = cjp->string;
- char *value = cjp->valuestring;
-
- if (name && value) {
- if (!strcasecmp(name, "_body")) {
- esl_event_add_body(new_event, value);
- } else {
- if (!strcasecmp(name, "event-name")) {
- esl_event_del_header(new_event, "event-name");
- }
-
- esl_name_event(value, &new_event->event_id);
- esl_event_add_header_string(new_event, ESL_STACK_BOTTOM, name, value);
- }
-
- }
- }
-
- cJSON_Delete(cj);
- *event = new_event;
- return ESL_SUCCESS;
-}
-
-ESL_DECLARE(esl_status_t) esl_event_serialize_json(esl_event_t *event, char **str)
-{
- esl_event_header_t *hp;
- cJSON *cj;
-
- *str = NULL;
-
- cj = cJSON_CreateObject();
-
- for (hp = event->headers; hp; hp = hp->next) {
- cJSON_AddItemToObject(cj, hp->name, cJSON_CreateString(hp->value));
- }
- if (event->body) {
- int blen = (int) strlen(event->body);
- char tmp[25];
-
- esl_snprintf(tmp, sizeof(tmp), "%d", blen);
-
- cJSON_AddItemToObject(cj, "Content-Length", cJSON_CreateString(tmp));
- cJSON_AddItemToObject(cj, "_body", cJSON_CreateString(event->body));
- }
-
- *str = cJSON_Print(cj);
- cJSON_Delete(cj);
-
- return ESL_SUCCESS;
-}
ESL_DECLARE(esl_status_t) esl_event_serialize(esl_event_t *event, char **str, esl_bool_t encode)
{
- size_t len = 0;
+ esl_size_t len = 0;
esl_event_header_t *hp;
- size_t llen = 0, dlen = 0, blocksize = 512, encode_len = 1536, new_len = 0;
+ esl_size_t llen = 0, dlen = 0, blocksize = 512, encode_len = 1536, new_len = 0;
char *buf;
char *encode_buf = NULL; /* used for url encoding of variables to make sure unsafe things stay out of the serialized copy */
- int clen = 0;
-
- if (!event || !event->headers)
- return ESL_FAIL;
*str = NULL;
dlen = blocksize * 2;
if (!(buf = malloc(dlen))) {
- return ESL_FAIL;
+ abort();
}
/* go ahead and give ourselves some space to work with, should save a few reallocs */
if (!(encode_buf = malloc(encode_len))) {
- esl_safe_free(buf);
- return ESL_FAIL;
+ abort();
}
/* esl_log_printf(ESL_CHANNEL_LOG, ESL_LOG_INFO, "hit serialized!.\n"); */
@@ -542,38 +644,39 @@ ESL_DECLARE(esl_status_t) esl_event_serialize(esl_event_t *event, char **str, es
* destroying loop.
*/
- if (!strcasecmp(hp->name, "content-length")) {
- clen++;
+ if (hp->idx) {
+ int i;
+ new_len = 0;
+ for(i = 0; i < hp->idx; i++) {
+ new_len += (strlen(hp->array[i]) * 3) + 1;
+ }
+ } else {
+ new_len = (strlen(hp->value) * 3) + 1;
}
-
- new_len = (strlen(hp->value) * 3) + 1;
-
if (encode_len < new_len) {
char *tmp;
- /* esl_log_printf(ESL_CHANNEL_LOG, ESL_LOG_INFO, "Allocing %d was %d.\n", ((strlen(hp->value) * 3) + 1), encode_len); */
- /* we can use realloc for initial alloc as well, if encode_buf is zero it treats it as a malloc */
/* keep track of the size of our allocation */
encode_len = new_len;
if (!(tmp = realloc(encode_buf, encode_len))) {
- /* oh boy, ram's gone, give back what little we grabbed and bail */
- esl_safe_free(buf);
- esl_safe_free(encode_buf);
- return ESL_FAIL;
+ abort();
}
encode_buf = tmp;
}
/* handle any bad things in the string like newlines : etc that screw up the serialized format */
+
+
if (encode) {
esl_url_encode(hp->value, encode_buf, encode_len);
} else {
- esl_snprintf(encode_buf, encode_len, "%s", hp->value);
+ esl_snprintf(encode_buf, encode_len, "[%s]", hp->value);
}
+
llen = strlen(hp->name) + strlen(encode_buf) + 8;
if ((len + llen) > dlen) {
@@ -582,14 +685,11 @@ ESL_DECLARE(esl_status_t) esl_event_serialize(esl_event_t *event, char **str, es
if ((m = realloc(buf, dlen))) {
buf = m;
} else {
- /* we seem to be out of memory trying to resize the serialize string, give back what we already have and give up */
- esl_safe_free(buf);
- esl_safe_free(encode_buf);
- return ESL_FAIL;
+ abort();
}
}
- snprintf(buf + len, dlen - len, "%s: %s\n", hp->name, *encode_buf == '\0' ? "_undef_" : encode_buf);
+ esl_snprintf(buf + len, dlen - len, "%s: %s\n", hp->name, *encode_buf == '\0' ? "_undef_" : encode_buf);
len = strlen(buf);
}
@@ -612,29 +712,115 @@ ESL_DECLARE(esl_status_t) esl_event_serialize(esl_event_t *event, char **str, es
if ((m = realloc(buf, dlen))) {
buf = m;
} else {
- esl_safe_free(buf);
- return ESL_FAIL;
+ abort();
}
}
-
+
if (blen) {
- if (clen) {
- snprintf(buf + len, dlen - len, "\n%s", event->body);
- } else {
- snprintf(buf + len, dlen - len, "Content-Length: %d\n\n%s", (int)strlen(event->body), event->body);
-
- }
+ esl_snprintf(buf + len, dlen - len, "Content-Length: %d\n\n%s", blen, event->body);
+ } else {
+ esl_snprintf(buf + len, dlen - len, "\n");
}
} else {
- snprintf(buf + len, dlen - len, "\n");
+ esl_snprintf(buf + len, dlen - len, "\n");
}
-
*str = buf;
return ESL_SUCCESS;
}
+ESL_DECLARE(esl_status_t) esl_event_create_json(esl_event_t **event, const char *json)
+{
+ esl_event_t *new_event;
+ cJSON *cj, *cjp;
+
+
+ if (!(cj = cJSON_Parse(json))) {
+ return ESL_FALSE;
+ }
+
+ if (esl_event_create(&new_event, ESL_EVENT_CLONE) != ESL_SUCCESS) {
+ cJSON_Delete(cj);
+ return ESL_FALSE;
+ }
+
+ for (cjp = cj->child; cjp; cjp = cjp->next) {
+ char *name = cjp->string;
+ char *value = cjp->valuestring;
+
+ if (name && value) {
+ if (!strcasecmp(name, "_body")) {
+ esl_event_add_body(new_event, value, ESL_VA_NONE);
+ } else {
+ if (!strcasecmp(name, "event-name")) {
+ esl_event_del_header(new_event, "event-name");
+ esl_name_event(value, &new_event->event_id);
+ }
+
+ esl_event_add_header_string(new_event, ESL_STACK_BOTTOM, name, value);
+ }
+
+ } else if (name) {
+ if (cjp->type == cJSON_Array) {
+ int i, x = cJSON_GetArraySize(cjp);
+
+ for (i = 0; i < x; i++) {
+ cJSON *item = cJSON_GetArrayItem(cjp, i);
+
+ if (item && item->type == cJSON_String && item->valuestring) {
+ esl_event_add_header_string(new_event, ESL_STACK_PUSH, name, item->valuestring);
+ }
+ }
+ }
+ }
+ }
+
+ cJSON_Delete(cj);
+ *event = new_event;
+ return ESL_SUCCESS;
+}
+
+ESL_DECLARE(esl_status_t) esl_event_serialize_json(esl_event_t *event, char **str)
+{
+ esl_event_header_t *hp;
+ cJSON *cj;
+
+ *str = NULL;
+
+ cj = cJSON_CreateObject();
+
+ for (hp = event->headers; hp; hp = hp->next) {
+ if (hp->idx) {
+ cJSON *a = cJSON_CreateArray();
+ int i;
+
+ for(i = 0; i < hp->idx; i++) {
+ cJSON_AddItemToArray(a, cJSON_CreateString(hp->array[i]));
+ }
+
+ cJSON_AddItemToObject(cj, hp->name, a);
+
+ } else {
+ cJSON_AddItemToObject(cj, hp->name, cJSON_CreateString(hp->value));
+ }
+ }
+
+ if (event->body) {
+ int blen = (int) strlen(event->body);
+ char tmp[25];
+
+ esl_snprintf(tmp, sizeof(tmp), "%d", blen);
+
+ cJSON_AddItemToObject(cj, "Content-Length", cJSON_CreateString(tmp));
+ cJSON_AddItemToObject(cj, "_body", cJSON_CreateString(event->body));
+ }
+
+ *str = cJSON_Print(cj);
+ cJSON_Delete(cj);
+
+ return ESL_SUCCESS;
+}
/* For Emacs:
* Local Variables:
diff --git a/libs/esl/src/include/esl.h b/libs/esl/src/include/esl.h
index 99ab53ae95..095e814a0e 100644
--- a/libs/esl/src/include/esl.h
+++ b/libs/esl/src/include/esl.h
@@ -42,10 +42,16 @@ extern "C" {
#define esl_copy_string(_x, _y, _z) strncpy(_x, _y, _z - 1)
#define esl_set_string(_x, _y) esl_copy_string(_x, _y, sizeof(_x))
+#define ESL_VA_NONE "%s", ""
typedef struct esl_event_header esl_event_header_t;
typedef struct esl_event esl_event_t;
+typedef enum {
+ ESL_POLL_READ = (1 << 0),
+ ESL_POLL_WRITE = (1 << 1),
+ ESL_POLL_ERROR = (1 << 2)
+} esl_poll_t;
typedef enum {
ESL_EVENT_TYPE_PLAIN,
@@ -257,7 +263,8 @@ typedef enum {
ESL_SUCCESS,
ESL_FAIL,
ESL_BREAK,
- ESL_DISCONNECTED
+ ESL_DISCONNECTED,
+ ESL_GENERR
} esl_status_t;
#define BUF_CHUNK 65536 * 50
@@ -304,6 +311,10 @@ typedef struct {
int destroyed;
} esl_handle_t;
+#define esl_test_flag(obj, flag) ((obj)->flags & flag)
+#define esl_set_flag(obj, flag) (obj)->flags |= (flag)
+#define esl_clear_flag(obj, flag) (obj)->flags &= ~(flag)
+
/*! \brief Used internally for truth test */
typedef enum {
ESL_TRUE = 1,
@@ -446,6 +457,10 @@ ESL_DECLARE(esl_status_t) esl_filter(esl_handle_t *handle, const char *header, c
*/
ESL_DECLARE(esl_status_t) esl_events(esl_handle_t *handle, esl_event_type_t etype, const char *value);
+ESL_DECLARE(int) esl_wait_sock(esl_socket_t sock, uint32_t ms, esl_poll_t flags);
+
+ESL_DECLARE(unsigned int) esl_separate_string_string(char *buf, const char *delim, char **array, unsigned int arraylen);
+
#define esl_recv(_h) esl_recv_event(_h, 0, NULL)
#define esl_recv_timed(_h, _ms) esl_recv_event_timed(_h, _ms, 0, NULL)
diff --git a/libs/esl/src/include/esl_event.h b/libs/esl/src/include/esl_event.h
index 7e619f4764..10af7264b9 100644
--- a/libs/esl/src/include/esl_event.h
+++ b/libs/esl/src/include/esl_event.h
@@ -42,7 +42,9 @@ extern "C" {
typedef enum {
ESL_STACK_BOTTOM,
- ESL_STACK_TOP
+ ESL_STACK_TOP,
+ ESL_STACK_PUSH,
+ ESL_STACK_UNSHIFT
} esl_stack_t;
typedef enum {
@@ -141,6 +143,10 @@ typedef enum {
char *name;
/*! the header value */
char *value;
+ /*! array space */
+ char **array;
+ /*! array index */
+ int idx;
/*! hash of the header name */
unsigned long hash;
struct esl_event_header *next;
@@ -174,7 +180,8 @@ struct esl_event {
};
typedef enum {
- ESL_UNIQ_HEADERS = (1 << 0)
+ ESL_EF_UNIQ_HEADERS = (1 << 0),
+ ESL_EF_CONTAINS_ARRAYS = (1 << 1)
} esl_event_flag_t;
@@ -203,7 +210,11 @@ ESL_DECLARE(esl_status_t) esl_event_set_priority(esl_event_t *event, esl_priorit
\param header_name the name of the header to read
\return the value of the requested header
*/
-ESL_DECLARE(char *)esl_event_get_header(esl_event_t *event, const char *header_name);
+
+
+ESL_DECLARE(esl_event_header_t *) esl_event_get_header_ptr(esl_event_t *event, const char *header_name);
+ESL_DECLARE(char *) esl_event_get_header_idx(esl_event_t *event, const char *header_name, int idx);
+#define esl_event_get_header(_e, _h) esl_event_get_header_idx(_e, _h, -1)
/*!
\brief Retrieve the body value from an event
@@ -250,6 +261,7 @@ ESL_DECLARE(void) esl_event_destroy(esl_event_t **event);
\return ESL_SUCCESS if the event was duplicated
*/
ESL_DECLARE(esl_status_t) esl_event_dup(esl_event_t **event, esl_event_t *todup);
+ESL_DECLARE(void) esl_event_merge(esl_event_t *event, esl_event_t *tomerge);
/*!
\brief Render the name of an event id enumeration
diff --git a/libs/freetdm/.gitignore b/libs/freetdm/.gitignore
index 2b06b30218..ff2a46a071 100644
--- a/libs/freetdm/.gitignore
+++ b/libs/freetdm/.gitignore
@@ -29,3 +29,8 @@ testtones
!/sample/boost/Makefile
!/sample/dso/Makefile
+freetdm.2010.sdf
+/mod_freetdm/Win32/
+/msvc/Win32/
+/src/ftmod/*/Win32/
+/src/ftmod/*/x64/
diff --git a/libs/freetdm/conf/freetdm.conf b/libs/freetdm/conf/freetdm.conf
index 2f9643dedd..cd269b7736 100644
--- a/libs/freetdm/conf/freetdm.conf
+++ b/libs/freetdm/conf/freetdm.conf
@@ -20,6 +20,9 @@ cpu_reset_alarm_threshold => 70
; cpu_alarm_action => warn,reject
cpu_alarm_action => warn
+; Where to dump DTMF debug files (see per span debugdtmf=yes option)
+debugdtmf_directory=/full/path/to/dtmf/directory
+
; spans are defined with [span ]
; the span type can either be zt, wanpipe or pika
; the span name can be any unique string
diff --git a/libs/freetdm/conf/wanpipe.conf b/libs/freetdm/conf/wanpipe.conf
index ba609ac42e..3784eaf17a 100644
--- a/libs/freetdm/conf/wanpipe.conf
+++ b/libs/freetdm/conf/wanpipe.conf
@@ -1,4 +1,13 @@
[defaults]
+; User space interval at which data will be delivered
codec_ms => 20
+
+; wink and flash interval
wink_ms => 150
flash_ms => 750
+
+; size of the driver queue of elements of MTU size
+; typical case is 10 elements of 80 bytes each (10ms of ulaw/alaw)
+; don't mess with this if you don't know what you're doing
+; txqueue_size => 10
+; rxqueue_size => 10
diff --git a/libs/freetdm/configure.ac b/libs/freetdm/configure.ac
index 55185cb10d..493f0da3b0 100644
--- a/libs/freetdm/configure.ac
+++ b/libs/freetdm/configure.ac
@@ -294,6 +294,19 @@ if test "${HAVE_SNG_SS7}" = "yes"; then
fi
fi
+
+##
+# zlib (required for Sangoma SS7 Transparent IAM)
+#
+HAVE_ZLIB="no"
+AC_MSG_RESULT([${as_nl}<<>> zlib])
+AC_CHECK_LIB([z], [compress], [HAVE_ZLIB="yes"])
+AC_MSG_RESULT([checking whether zlib is installed... ${HAVE_ZLIB}])
+AM_CONDITIONAL([HAVE_ZLIB], [test "{HAVE_ZLIB]" = "yes"])
+if test "${HAVE_ZLIB}" = "yes"; then
+ CFLAGS="$CFLAGS -DHAVE_ZLIB"
+fi
+
##
# libisdn
#
diff --git a/libs/freetdm/docs/PRI-BRI-Debug.pdf b/libs/freetdm/docs/PRI-BRI-Debug.pdf
new file mode 100755
index 0000000000..53386b1b52
Binary files /dev/null and b/libs/freetdm/docs/PRI-BRI-Debug.pdf differ
diff --git a/libs/freetdm/docs/variables.txt b/libs/freetdm/docs/variables.txt
index 0beecd016c..cb518e14d8 100644
--- a/libs/freetdm/docs/variables.txt
+++ b/libs/freetdm/docs/variables.txt
@@ -10,6 +10,7 @@ example #1a - Making an outbound call:
To make an outbound call:
ftdm_usrmsg_t usrmsg;
+ memset(&usrmsg, 0, sizeof(usrmsg));
/* Attach variable to usrmsg */
ftdm_usrmsg_add_var(&usrmsg, "isdn.prog_ind.descr", "inband-info-available");
@@ -22,6 +23,7 @@ When using ftmod_sangoma_isdn, user want to specify progress indicator inside PR
ftdm_usrmsg_t usrmsg;
+ memset(&usrmsg, 0, sizeof(usrmsg));
/* Attach variable to usrmsg */
ftdm_usrmsg_add_var(&usrmsg, "isdn.prog_ind.descr", "inband-info-available");
@@ -40,6 +42,8 @@ When using ftmod_sangoma_isdn, user wants to transmit a custom Facility IE, insi
uint8_t *my_facility_ie = ftdm_calloc(1, 200); /*memory has to be allocated using ftdm_calloc !! */
unsigned my_facility_ie_len = 0;
+ memset(&usrmsg, 0, sizeof(usrmsg));
+
/* Fill my_facility_ie with custom data here */
my_facility_ie[my_facility_ie_len++] = 0x1C; /* Q.931 Facility IE ID */
my_facility_ie[my_facility_ie_len++] = 0x03; /* Length of facility IE */
@@ -49,7 +53,7 @@ When using ftmod_sangoma_isdn, user wants to transmit a custom Facility IE, insi
ftdm_usrmsg_set_raw_data(&usrmsg, my_facility_ie, my_facility_ie_len);
- ftdm_channel_call_indicate(ftdmchan, FTDM_CHANNEL_INDICATE_FACILITY, &usrmsg);
+ ftdm_channel_call_indicate_ex(ftdmchan, FTDM_CHANNEL_INDICATE_FACILITY, &usrmsg);
/* FreeTDM will automatically free my_facility_ie */
diff --git a/libs/freetdm/mkrelease.sh b/libs/freetdm/mkrelease.sh
index 58d176119d..b079158541 100755
--- a/libs/freetdm/mkrelease.sh
+++ b/libs/freetdm/mkrelease.sh
@@ -29,36 +29,116 @@ then
exit 1
fi
+arch=$(uname -m)
+
+# defs
+LIBSNG_ISDN_URL=ftp://ftp.sangoma.com/linux/libsng_isdn
+LIBSNG_ISDN_NAME=libsng_isdn-7-current
+LIBSNG_SS7_URL=ftp://ftp.sangoma.com/linux/libsng_ss7
+LIBSNG_SS7_NAME=libsng_ss7-3-current
+LIBSNG_ISDN_DIR="$LIBSNG_ISDN_NAME.$arch"
+LIBSNG_SS7_DIR="$LIBSNG_SS7_NAME.$arch"
+
+# download and decompress a tarball
+# $1 = prefix_url, such as ftp://ftp.sangoma.com/foo/bar
+# $2 = package name, such as libsng_isdn-7.0.0.x86_64
+function download() {
+ wget $1/$2.tgz
+ if [ $? = 0 ]
+ then
+ tardir=$(tar -tf $2.tgz | head -n1 | sed 's,\/,,g')
+ tar -xvzf $2.tgz || echo "FAILED to decompress $2.tgz"
+ if [ "$tardir" != "$2" ]
+ then
+ mv $tardir $2 || echo "FAILED to move $tardir to $2"
+ fi
+ echo "SUCCESSFULLY downloaded $2"
+ else
+ echo "FAILED to download $1/$2.tgz"
+ fi
+}
+
+# download and build libsng-ss7
+fullname="$LIBSNG_ISDN_NAME.$arch"
+if [ -d $fullname ]
+then
+ echo "skipping isdn download since $fullname directory already exists ... remove if you want this step to be performed"
+else
+ download $LIBSNG_ISDN_URL $fullname
+fi
+
+cd $LIBSNG_ISDN_DIR
+make DESTDIR=$INSTALLPREFIX install || echo "Failed to build libsng-isdn"
+cd ..
+
+# download and build libsng-ss7
+fullname="$LIBSNG_SS7_NAME.$arch"
+if [ -d $fullname ]
+then
+ echo "skipping ss7 download since $fullname directory already exists ... remove if you want this step to be performed"
+else
+ download $LIBSNG_SS7_URL $fullname
+fi
+
+cd $LIBSNG_SS7_DIR
+make DESTDIR=$INSTALLPREFIX install || echo "Failed to build libsng-ss7"
+cd ..
+
if [ ! -d $INSTALLPREFIX ]
then
mkdir -p $INSTALLPREFIX || exit 1
fi
-make clean
-make mod_freetdm-clean
-if [ $NODOCS = "NO" ]
+if [ ! -d $INSTALLPREFIX/bin-releases ]
then
- make dox || exit 1
+ mkdir -p $INSTALLPREFIX/bin-releases || exit 1
fi
+# attempt to compile freetdm
+echo "Build freetdm and mod_freetdm now..."
+make all mod_freetdm || exit 1
+echo "freetdm built OK"
+
major=$(echo "$VERSION" | cut -d. -f1)
minor=$(echo "$VERSION" | cut -d. -f2)
micro=$(echo "$VERSION" | cut -d. -f3)
release="freetdm-$VERSION"
-echo "Creating $release ($major.$minor.$micro) at $INSTALLPREFIX/$release (directory will be removed if exists already) ... press any key to continue"
-read
+# ABI compatibility check
+if [ -x /usr/local/bin/ftdm_abi_check.py ]; then
+ /usr/local/bin/ftdm_abi_check.py --release_path=$(pwd) --archive_path=$INSTALLPREFIX/bin-releases --version=$VERSION
-mkdir -p $INSTALLPREFIX/$release
+ if [ $? -ne 0 ]; then
+ echo "ABI compabitility test failed, not creating release. Either increment the major version number or fix the interface."
+ exit 1
+ fi
+else
+ echo -ne "\n\nWARNING: /usr/local/bin/ftdm_abi_check.py not found, skipping ABI compatibility test\n\n"
+fi
+
+if [ $NODOCS = "NO" ]
+then
+ make dox || exit 1
+fi
+
+echo "Creating $release ($major.$minor.$micro) at $INSTALLPREFIX/$release (directory will be removed if exists already) ... "
+
+mkdir -p $INSTALLPREFIX/$release $INSTALLPREFIX/bin-releases/$major/$release
+
+cp -r ./* $INSTALLPREFIX/bin-releases/$major/$release
+cp -r ./.libs $INSTALLPREFIX/bin-releases/$major/$release
+
+make clean
+make mod_freetdm-clean
cp -r ./* $INSTALLPREFIX/$release
-find $INSTALLPREFIX/ -name .libs -exec rm -rf {} \;
-find $INSTALLPREFIX/ -name .deps -exec rm -rf {} \;
-find $INSTALLPREFIX/ -name *.so -exec rm -rf {} \;
-find $INSTALLPREFIX/ -name *.lo -exec rm -rf {} \;
+# copy ABI compatibility reports to release
+if [ -d compat_reports ]; then
+ mv ./compat_reports $INSTALLPREFIX/$release
+fi
+rm -rf $INSTALLPREFIX/$release/{$LIBSNG_ISDN_DIR,$LIBSNG_SS7_DIR,*.tgz}
+rm -rf $INSTALLPREFIX/bin-releases/$major/$release/{$LIBSNG_ISDN_DIR,$LIBSNG_SS7_DIR,*.tgz}
tar -C $INSTALLPREFIX -czf $INSTALLPREFIX/$release.tar.gz $release/
-
-
diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c
index 0652a8e128..618f2501ff 100755
--- a/libs/freetdm/mod_freetdm/mod_freetdm.c
+++ b/libs/freetdm/mod_freetdm/mod_freetdm.c
@@ -87,7 +87,7 @@ static struct {
analog_option_t analog_options;
switch_hash_t *ss7_configs;
int sip_headers;
- uint8_t crash_on_assert;
+ int crash_on_assert;
} globals;
/* private data attached to each fs session */
@@ -130,6 +130,10 @@ struct span_config {
int limit_calls;
int limit_seconds;
limit_reset_event_t limit_reset_event;
+ /* digital codec and digital sampling rate are used to configure the codec
+ * when bearer capability is set to unrestricted digital */
+ const char *digital_codec;
+ int digital_sampling_rate;
chan_pvt_t pvts[FTDM_MAX_CHANNELS_SPAN];
};
@@ -294,13 +298,11 @@ static void cycle_foreground(ftdm_channel_t *ftdmchan, int flash, const char *bc
}
}
-
-
-
-static switch_status_t tech_init(private_t *tech_pvt, switch_core_session_t *session, ftdm_channel_t *ftdmchan)
+static switch_status_t tech_init(private_t *tech_pvt, switch_core_session_t *session, ftdm_channel_t *ftdmchan, ftdm_caller_data_t *caller_data)
{
const char *dname = NULL;
uint32_t interval = 0, srate = 8000;
+ uint32_t span_id;
ftdm_codec_t codec;
tech_pvt->ftdmchan = ftdmchan;
@@ -321,6 +323,16 @@ static switch_status_t tech_init(private_t *tech_pvt, switch_core_session_t *ses
return SWITCH_STATUS_GENERR;
}
+ span_id = ftdm_channel_get_span_id(ftdmchan);
+ if (caller_data->bearer_capability == FTDM_BEARER_CAP_UNRESTRICTED
+ && SPAN_CONFIG[span_id].digital_codec) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Initializing digital call with codec %s at %dhz.\n",
+ SPAN_CONFIG[span_id].digital_codec, SPAN_CONFIG[span_id].digital_sampling_rate);
+ dname = SPAN_CONFIG[span_id].digital_codec;
+ srate = SPAN_CONFIG[span_id].digital_sampling_rate;
+ goto init_codecs;
+ }
+
if (FTDM_SUCCESS != ftdm_channel_command(ftdmchan, FTDM_COMMAND_GET_CODEC, &codec)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to retrieve channel codec.\n");
return SWITCH_STATUS_GENERR;
@@ -349,6 +361,7 @@ static switch_status_t tech_init(private_t *tech_pvt, switch_core_session_t *ses
}
}
+init_codecs:
if (switch_core_codec_init(&tech_pvt->read_codec,
dname,
@@ -720,7 +733,6 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
ftdm_size_t len;
unsigned char data[SWITCH_RECOMMENDED_BUFFER_SIZE] = {0};
ftdm_wait_flag_t wflags = FTDM_WRITE;
- ftdm_status_t status;
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
@@ -755,7 +767,7 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
wflags = FTDM_WRITE;
- status = ftdm_channel_wait(tech_pvt->ftdmchan, &wflags, ftdm_channel_get_io_interval(tech_pvt->ftdmchan) * 10);
+ ftdm_channel_wait(tech_pvt->ftdmchan, &wflags, ftdm_channel_get_io_interval(tech_pvt->ftdmchan) * 10);
if (!(wflags & FTDM_WRITE)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Dropping frame! (write not ready)\n");
@@ -1094,7 +1106,7 @@ static ftdm_status_t on_channel_found(ftdm_channel_t *fchan, ftdm_caller_data_t
span_id = ftdm_channel_get_span_id(fchan);
chan_id = ftdm_channel_get_id(fchan);
- tech_init(hdata->tech_pvt, hdata->new_session, fchan);
+ tech_init(hdata->tech_pvt, hdata->new_session, fchan, caller_data);
snprintf(name, sizeof(name), "FreeTDM/%u:%u/%s", span_id, chan_id, caller_data->dnis.digits);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Connect outbound channel %s\n", name);
@@ -1264,6 +1276,12 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
caller_data.ani.plan = (uint8_t)atoi(sipvar);
}
+ /* Used by ftmod_sangoma_ss7 only */
+ sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-ANI-NADI");
+ if (sipvar) {
+ ftdm_usrmsg_add_var(&usrmsg, "ss7_clg_nadi", sipvar);
+ }
+
sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-ANI2");
if (sipvar) {
ftdm_set_string(caller_data.aniII, sipvar);
@@ -1284,29 +1302,91 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
caller_data.dnis.plan = (uint8_t)atoi(sipvar);
}
+ /* Used by ftmod_sangoma_ss7 only */
+ sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-DNIS-NADI");
+ if (sipvar) {
+ ftdm_usrmsg_add_var(&usrmsg, "ss7_clg_nadi", sipvar);
+ }
+
sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-RDNIS");
if (sipvar) {
ftdm_set_string(caller_data.rdnis.digits, sipvar);
- }
-
- sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-RDNIS-TON");
- if (sipvar) {
- caller_data.rdnis.type = (uint8_t)atoi(sipvar);
+ ftdm_usrmsg_add_var(&usrmsg, "ss7_rdnis_digits", sipvar);
}
sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-RDNIS-Plan");
if (sipvar) {
- caller_data.rdnis.plan = (uint8_t)atoi(sipvar);
+ ftdm_usrmsg_add_var(&usrmsg, "ss7_rdnis_plan", sipvar);
}
+ sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-RDNIS-NADI");
+ if (sipvar) {
+ ftdm_usrmsg_add_var(&usrmsg, "ss7_rdnis_nadi", sipvar);
+ }
+
+ sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-RDNIS-Screen");
+ if (sipvar) {
+ ftdm_usrmsg_add_var(&usrmsg, "ss7_rdnis_screen_ind", sipvar);
+ }
+
+ sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-RDNIS-Presentation");
+ if (sipvar) {
+ ftdm_usrmsg_add_var(&usrmsg, "ss7_rdnis_pres_ind", sipvar);
+ }
+
+ sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-GN");
+ if (sipvar) {
+ ftdm_usrmsg_add_var(&usrmsg, "ss7_gn_digits", sipvar);
+ }
+
+ sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-GN-NumQual");
+ if (sipvar) {
+ ftdm_usrmsg_add_var(&usrmsg, "ss7_gn_numqual", sipvar);
+ }
+
+ sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-GN-NADI");
+ if (sipvar) {
+ ftdm_usrmsg_add_var(&usrmsg, "ss7_gn_nadi", sipvar);
+ }
+
+ sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-GN-Screen");
+ if (sipvar) {
+ ftdm_usrmsg_add_var(&usrmsg, "ss7_gn_screen_ind", sipvar);
+ }
+
+ sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-GN-Presentation");
+ if (sipvar) {
+ ftdm_usrmsg_add_var(&usrmsg, "ss7_gn_pres_ind", sipvar);
+ }
+
+ sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-GN-Plan");
+ if (sipvar) {
+ ftdm_usrmsg_add_var(&usrmsg, "ss7_gn_npi", sipvar);
+ }
+
+ sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-GN-NumInComp");
+ if (sipvar) {
+ ftdm_usrmsg_add_var(&usrmsg, "ss7_gn_num_inc_ind", sipvar);
+ }
+
sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-Screen");
if (sipvar) {
- caller_data.screen = (uint8_t)atoi(sipvar);
+ ftdm_usrmsg_add_var(&usrmsg, "ss7_screen_ind", sipvar);
}
sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-Presentation");
if (sipvar) {
- caller_data.pres = (uint8_t)atoi(sipvar);
+ ftdm_usrmsg_add_var(&usrmsg, "ss7_pres_ind", sipvar);
+ }
+
+ sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-CPC");
+ if (sipvar) {
+ ftdm_set_calling_party_category(sipvar, (uint8_t *)&caller_data.cpc);
+ }
+
+ sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-IAM");
+ if (sipvar) {
+ ftdm_usrmsg_add_var(&usrmsg, "ss7_iam", sipvar);
}
}
@@ -1323,19 +1403,19 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
}
if ((var = channel_get_variable(session, var_event, "freetdm_bearer_layer1"))) {
- caller_data.bearer_layer1 = (uint8_t)atoi(var);
+ caller_data.bearer_layer1 = (uint8_t)atoi(var);
}
if ((var = channel_get_variable(session, var_event, "freetdm_screening_ind"))) {
- ftdm_set_screening_ind(var, &caller_data.screen);
+ ftdm_set_screening_ind(var, &caller_data.screen);
}
if ((var = channel_get_variable(session, var_event, "freetdm_presentation_ind"))) {
- ftdm_set_presentation_ind(var, &caller_data.pres);
+ ftdm_set_presentation_ind(var, &caller_data.pres);
}
if ((var = channel_get_variable(session, var_event, "freetdm_outbound_ton"))) {
- ftdm_set_ton(var, &caller_data.dnis.type);
+ ftdm_set_ton(var, &caller_data.dnis.type);
} else {
caller_data.dnis.type = outbound_profile->destination_number_ton;
}
@@ -1380,7 +1460,13 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
if (!strncasecmp(h->name, FREETDM_VAR_PREFIX, FREETDM_VAR_PREFIX_LEN)) {
char *v = h->name + FREETDM_VAR_PREFIX_LEN;
if (!zstr(v)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding outbound freetdm variable %s=%s to channel %d:%d\n", v, h->value, span_id, chan_id);
+ if (!strcasecmp(v, "ss7_iam")) {
+ /* Do not print the value of ss7_iam as it is very long */
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding outbound freetdm variable %s to channel %d:%d\n", v, span_id, chan_id);
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding outbound freetdm variable %s=%s to channel %d:%d\n", v, h->value, span_id, chan_id);
+ }
+
ftdm_usrmsg_add_var(&usrmsg, v, h->value);
}
}
@@ -1483,7 +1569,7 @@ ftdm_status_t ftdm_channel_from_event(ftdm_sigmsg_t *sigmsg, switch_core_session
tech_pvt = (private_t *) switch_core_session_alloc(session, sizeof(private_t));
assert(tech_pvt != NULL);
channel = switch_core_session_get_channel(session);
- if (tech_init(tech_pvt, session, sigmsg->channel) != SWITCH_STATUS_SUCCESS) {
+ if (tech_init(tech_pvt, session, sigmsg->channel, channel_caller_data) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Initilization Error!\n");
switch_core_session_destroy(&session);
return FTDM_FAIL;
@@ -1545,9 +1631,11 @@ ftdm_status_t ftdm_channel_from_event(ftdm_sigmsg_t *sigmsg, switch_core_session
switch_channel_set_variable_printf(channel, "freetdm_chan_number", "%d", chanid);
switch_channel_set_variable_printf(channel, "freetdm_bearer_capability", "%d", channel_caller_data->bearer_capability);
switch_channel_set_variable_printf(channel, "freetdm_bearer_layer1", "%d", channel_caller_data->bearer_layer1);
+ switch_channel_set_variable_printf(channel, "freetdm_calling_party_category", ftdm_calling_party_category2str(channel_caller_data->cpc));
switch_channel_set_variable_printf(channel, "screening_ind", ftdm_screening2str(channel_caller_data->screen));
switch_channel_set_variable_printf(channel, "presentation_ind", ftdm_presentation2str(channel_caller_data->pres));
+
if (globals.sip_headers) {
switch_channel_set_variable(channel, "sip_h_X-FreeTDM-SpanName", ftdm_channel_get_span_name(sigmsg->channel));
switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-SpanNumber", "%d", spanid);
@@ -1566,8 +1654,60 @@ ftdm_status_t ftdm_channel_from_event(ftdm_sigmsg_t *sigmsg, switch_core_session
switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-DNIS-Plan", "%d", channel_caller_data->dnis.plan);
switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-RDNIS", "%s", channel_caller_data->rdnis.digits);
- switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-RDNIS-TON", "%d", channel_caller_data->rdnis.type);
+ switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-RDNIS-NADI", "%d", channel_caller_data->rdnis.type);
switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-RDNIS-Plan", "%d", channel_caller_data->rdnis.plan);
+ switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-CPC", "%s", ftdm_calling_party_category2str(channel_caller_data->cpc));
+
+
+ var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_rdnis_screen_ind");
+ if (!ftdm_strlen_zero(var_value)) {
+ switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-RDNIS-Screen", "%d", var_value);
+ }
+
+ var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_rdnis_pres_ind");
+ if (!ftdm_strlen_zero(var_value)) {
+ switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-RDNIS-Presentation", "%d", channel_caller_data->rdnis.plan);
+ }
+
+ var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_gn_digits");
+ if (!ftdm_strlen_zero(var_value)) {
+ switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-GN", "%d", var_value);
+
+ var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_gn_numqual");
+ if (!ftdm_strlen_zero(var_value)) {
+ switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-GN-NumQual", "%d", var_value);
+ }
+
+ var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_gn_nadi");
+ if (!ftdm_strlen_zero(var_value)) {
+ switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-GN-NADI", "%d", var_value);
+ }
+
+ var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_gn_screen_ind");
+ if (!ftdm_strlen_zero(var_value)) {
+ switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-GN-Screen", "%d", var_value);
+ }
+
+ var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_gn_pres_ind");
+ if (!ftdm_strlen_zero(var_value)) {
+ switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-GN-Presentation", "%d", var_value);
+ }
+
+ var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_gn_npi");
+ if (!ftdm_strlen_zero(var_value)) {
+ switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-GN-Plan", "%d", var_value);
+ }
+
+ var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_gn_num_inc_ind");
+ if (!ftdm_strlen_zero(var_value)) {
+ switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-GN-NumInComp", "%d", var_value);
+ }
+ } /* End - var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_gn_digits"); */
+
+ var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_iam");
+ if (!ftdm_strlen_zero(var_value)) {
+ switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-IAM", "%s", var_value);
+ }
switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-Screen", "%d", channel_caller_data->screen);
switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-Presentation", "%d", channel_caller_data->pres);
@@ -1579,7 +1719,12 @@ ftdm_status_t ftdm_channel_from_event(ftdm_sigmsg_t *sigmsg, switch_core_session
ftdm_get_current_var(curr, &var_name, &var_value);
snprintf(name, sizeof(name), FREETDM_VAR_PREFIX "%s", var_name);
switch_channel_set_variable_printf(channel, name, "%s", var_value);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Call Variable: %s = %s\n", name, var_value);
+ if (!strcasecmp(var_name, "ss7_iam")) {
+ /* Do not print freetdm_ss7_iam as it is a very long variable */
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Call Variable: %s is present\n", name);
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Call Variable: %s = %s\n", name, var_value);
+ }
}
ftdm_iterator_free(iter);
@@ -2564,6 +2709,7 @@ static void parse_bri_pri_spans(switch_xml_t cfg, switch_xml_t spans)
/* some defaults first */
SPAN_CONFIG[span_id].limit_backend = "hash";
SPAN_CONFIG[span_id].limit_reset_event = FTDM_LIMIT_RESET_ON_TIMEOUT;
+ SPAN_CONFIG[span_id].digital_sampling_rate = 8000;
for (param = switch_xml_child(myspan, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr_soft(param, "name");
@@ -2578,6 +2724,21 @@ static void parse_bri_pri_spans(switch_xml_t cfg, switch_xml_t spans)
context = val;
} else if (!strcasecmp(var, "dialplan")) {
dialplan = val;
+ } else if (!strcasecmp(var, "unrestricted-digital-codec")) {
+ //switch_core_strdup(pool, val);
+ const switch_codec_implementation_t *codec = NULL;
+ int num_codecs;
+ num_codecs = switch_loadable_module_get_codecs_sorted(&codec, 1, &val, 1);
+ if (num_codecs != 1 || !codec) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ "Failed finding codec %s for unrestricted digital calls\n", val);
+ } else {
+ SPAN_CONFIG[span_id].digital_codec = switch_core_strdup(module_pool, codec->iananame);
+ SPAN_CONFIG[span_id].digital_sampling_rate = codec->samples_per_second;
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+ "Unrestricted digital codec is %s at %dhz for span %d\n",
+ SPAN_CONFIG[span_id].digital_codec, SPAN_CONFIG[span_id].digital_sampling_rate, span_id);
+ }
} else if (!strcasecmp(var, "call_limit_backend")) {
SPAN_CONFIG[span_id].limit_backend = val;
ftdm_log(FTDM_LOG_DEBUG, "Using limit backend %s for span %d\n", SPAN_CONFIG[span_id].limit_backend, span_id);
@@ -3499,6 +3660,12 @@ void dump_chan(ftdm_span_t *span, uint32_t chan_id, switch_stream_handle_t *stre
"physical_span_id: %u\n"
"physical_chan_id: %u\n"
"physical_status: %s\n"
+ "physical_status_red: %d\n"
+ "physical_status_yellow: %d\n"
+ "physical_status_rai: %d\n"
+ "physical_status_blue: %d\n"
+ "physical_status_ais: %d\n"
+ "physical_status_general: %d\n"
"signaling_status: %s\n"
"type: %s\n"
"state: %s\n"
@@ -3519,7 +3686,13 @@ void dump_chan(ftdm_span_t *span, uint32_t chan_id, switch_stream_handle_t *stre
phspan_id,
phchan_id,
alarmflag ? "alarmed" : "ok",
- ftdm_signaling_status2str(sigstatus),
+ (alarmflag & FTDM_ALARM_RED) ? 1 : 0,
+ (alarmflag & FTDM_ALARM_YELLOW) ? 1 : 0,
+ (alarmflag & FTDM_ALARM_RAI) ? 1 : 0,
+ (alarmflag & FTDM_ALARM_BLUE) ? 1 : 0,
+ (alarmflag & FTDM_ALARM_AIS) ? 1 : 0,
+ (alarmflag & FTDM_ALARM_GENERAL) ? 1 : 0,
+ ftdm_signaling_status2str(sigstatus),
chan_type,
state,
last_state,
@@ -3575,6 +3748,12 @@ void dump_chan_xml(ftdm_span_t *span, uint32_t chan_id, switch_stream_handle_t *
" %u\n"
" %u\n"
" %s\n"
+ " %d\n"
+ " %d\n"
+ " %d\n"
+ " %d\n"
+ " %d\n"
+ " %d\n"
" %s\n"
" %s\n"
" %s\n"
@@ -3595,7 +3774,13 @@ void dump_chan_xml(ftdm_span_t *span, uint32_t chan_id, switch_stream_handle_t *
phspan_id,
phchan_id,
alarmflag ? "alarmed" : "ok",
- ftdm_signaling_status2str(sigstatus),
+ (alarmflag & FTDM_ALARM_RED) ? 1 : 0,
+ (alarmflag & FTDM_ALARM_YELLOW) ? 1 : 0,
+ (alarmflag & FTDM_ALARM_RAI) ? 1 : 0,
+ (alarmflag & FTDM_ALARM_BLUE) ? 1 : 0,
+ (alarmflag & FTDM_ALARM_AIS) ? 1 : 0,
+ (alarmflag & FTDM_ALARM_GENERAL) ? 1 : 0,
+ ftdm_signaling_status2str(sigstatus),
chan_type,
state,
last_state,
@@ -3615,14 +3800,15 @@ void dump_chan_xml(ftdm_span_t *span, uint32_t chan_id, switch_stream_handle_t *
"--------------------------------------------------------------------------------\n" \
"ftdm list\n" \
"ftdm start|stop \n" \
-"ftdm restart \n" \
+"ftdm restart []\n" \
"ftdm dump []\n" \
"ftdm sigstatus get|set [] [] []\n" \
"ftdm trace []\n" \
"ftdm notrace []\n" \
"ftdm q931_pcap on|off [pcapfilename without suffix]\n" \
-"ftdm gains []\n" \
+"ftdm gains []\n" \
"ftdm dtmf on|off []\n" \
+"ftdm queuesize []\n" \
"--------------------------------------------------------------------------------\n"
SWITCH_STANDARD_API(ft_function)
{
@@ -3817,7 +4003,7 @@ SWITCH_STANDARD_API(ft_function)
"dial_regex: %s\n"
"fail_dial_regex: %s\n"
"hold_music: %s\n"
- "analog_options %s\n",
+ "analog_options: %s\n",
j,
ftdm_span_get_name(SPAN_CONFIG[j].span),
SPAN_CONFIG[j].type,
@@ -3843,7 +4029,7 @@ SWITCH_STANDARD_API(ft_function)
"dial_regex: %s\n"
"fail_dial_regex: %s\n"
"hold_music: %s\n"
- "analog_options %s\n",
+ "analog_options: %s\n",
j,
ftdm_span_get_name(SPAN_CONFIG[j].span),
SPAN_CONFIG[j].type,
@@ -4059,7 +4245,7 @@ SWITCH_STANDARD_API(ft_function)
ftdm_channel_t *chan;
ftdm_span_t *span = NULL;
if (argc < 4) {
- stream->write_function(stream, "-ERR Usage: ft gains []\n");
+ stream->write_function(stream, "-ERR Usage: ftdm gains []\n");
goto end;
}
ftdm_span_find_by_name(argv[3], &span);
@@ -4094,12 +4280,57 @@ SWITCH_STANDARD_API(ft_function)
}
}
stream->write_function(stream, "+OK gains set to Rx %f and Tx %f\n", rxgain, txgain);
- } else if (!strcasecmp(argv[0], "restart")) {
+ } else if (!strcasecmp(argv[0], "queuesize")) {
+ unsigned int i = 0;
+ uint32_t rxsize = 10;
+ uint32_t txsize = 10;
uint32_t chan_id = 0;
+ uint32_t ccount = 0;
ftdm_channel_t *chan;
ftdm_span_t *span = NULL;
- if (argc < 3) {
- stream->write_function(stream, "-ERR Usage: ftdm restart \n");
+ if (argc < 4) {
+ stream->write_function(stream, "-ERR Usage: ftdm queuesize []\n");
+ goto end;
+ }
+ ftdm_span_find_by_name(argv[3], &span);
+ if (!span) {
+ stream->write_function(stream, "-ERR invalid span\n");
+ goto end;
+ }
+ if (argc > 4) {
+ chan_id = atoi(argv[4]);
+ if (chan_id > ftdm_span_get_chan_count(span)) {
+ stream->write_function(stream, "-ERR invalid chan\n");
+ goto end;
+ }
+ }
+ i = sscanf(argv[1], "%u", &rxsize);
+ i += sscanf(argv[2], "%u", &txsize);
+ if (i != 2) {
+ stream->write_function(stream, "-ERR invalid queue sizes provided\n");
+ goto end;
+ }
+
+ if (chan_id) {
+ chan = ftdm_span_get_channel(span, chan_id);
+ ftdm_channel_command(chan, FTDM_COMMAND_SET_RX_QUEUE_SIZE, &rxsize);
+ ftdm_channel_command(chan, FTDM_COMMAND_SET_TX_QUEUE_SIZE, &txsize);
+ } else {
+ ccount = ftdm_span_get_chan_count(span);
+ for (i = 1; i < ccount; i++) {
+ chan = ftdm_span_get_channel(span, i);
+ ftdm_channel_command(chan, FTDM_COMMAND_SET_RX_QUEUE_SIZE, &rxsize);
+ ftdm_channel_command(chan, FTDM_COMMAND_SET_TX_QUEUE_SIZE, &txsize);
+ }
+ }
+ stream->write_function(stream, "+OK queue sizes set to Rx %d and Tx %d\n", rxsize, txsize);
+ } else if (!strcasecmp(argv[0], "restart")) {
+ uint32_t chan_id = 0;
+ uint32_t ccount = 0;
+ ftdm_channel_t *chan;
+ ftdm_span_t *span = NULL;
+ if (argc < 2) {
+ stream->write_function(stream, "-ERR Usage: ftdm restart []\n");
goto end;
}
ftdm_span_find_by_name(argv[1], &span);
@@ -4107,15 +4338,32 @@ SWITCH_STANDARD_API(ft_function)
stream->write_function(stream, "-ERR invalid span\n");
goto end;
}
-
- chan_id = atoi(argv[2]);
- chan = ftdm_span_get_channel(span, chan_id);
- if (!chan) {
- stream->write_function(stream, "-ERR Could not find chan\n");
- goto end;
+
+ if (argc > 2) {
+ chan_id = atoi(argv[2]);
+ if (chan_id > ftdm_span_get_chan_count(span)) {
+ stream->write_function(stream, "-ERR invalid chan\n");
+ goto end;
+ }
}
- stream->write_function(stream, "Resetting channel %s:%s\n", argv[2], argv[3]);
- ftdm_channel_reset(chan);
+ if (chan_id) {
+ chan = ftdm_span_get_channel(span, chan_id);
+ if (!chan) {
+ stream->write_function(stream, "-ERR Could not find chan\n");
+ goto end;
+ }
+ stream->write_function(stream, "Resetting channel %s:%s\n", argv[1], argv[2]);
+ ftdm_channel_reset(chan);
+ } else {
+ uint32_t i = 0;
+ ccount = ftdm_span_get_chan_count(span);
+ for (i = 1; i < ccount; i++) {
+ chan = ftdm_span_get_channel(span, i);
+ stream->write_function(stream, "Resetting channel %s:%d\n", argv[1], i);
+ ftdm_channel_reset(chan);
+ }
+ }
+
} else {
char *rply = ftdm_api_execute(cmd);
@@ -4235,7 +4483,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_freetdm_load)
SWITCH_ADD_API(commands_api_interface, "ftdm", "FreeTDM commands", ft_function, FT_SYNTAX);
switch_console_set_complete("add ftdm start");
switch_console_set_complete("add ftdm stop");
- switch_console_set_complete("add ftdm retart");
+ switch_console_set_complete("add ftdm restart");
switch_console_set_complete("add ftdm dump");
switch_console_set_complete("add ftdm sigstatus get");
switch_console_set_complete("add ftdm sigstatus set");
@@ -4243,6 +4491,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_freetdm_load)
switch_console_set_complete("add ftdm notrace");
switch_console_set_complete("add ftdm q931_pcap");
switch_console_set_complete("add ftdm gains");
+ switch_console_set_complete("add ftdm queuesize");
switch_console_set_complete("add ftdm dtmf on");
switch_console_set_complete("add ftdm dtmf off");
switch_console_set_complete("add ftdm core state");
diff --git a/libs/freetdm/src/ftdm_call_utils.c b/libs/freetdm/src/ftdm_call_utils.c
index 2b72f05b77..d23c95af4e 100644
--- a/libs/freetdm/src/ftdm_call_utils.c
+++ b/libs/freetdm/src/ftdm_call_utils.c
@@ -42,6 +42,74 @@
#include
+
+
+FT_DECLARE(char *) ftdm_url_encode(const char *url, char *buf, ftdm_size_t len)
+{
+ /* This implementation of url_encode is slightly different compared to the
+ * Freeswitch one. This is because this implementation accepts the full
+ * range of values (0x00 - 0xFF) compared to the Freeswitch implementation
+ * that does not accept 0x00 */
+
+ const char *p;
+ size_t x = 0,y = 0;
+ const char urlunsafe[] = "\r\n \"#%&+:;<=>?@[\\]^`{|}";
+ const char hex[] = "0123456789ABCDEF";
+
+ if (!buf) {
+ return 0;
+ }
+
+ if (!url) {
+ return 0;
+ }
+
+ len--;
+
+ for (p = url; y <= len; p++) {
+ if (*p < ' ' || *p > '~' || strchr(urlunsafe, *p)) {
+ buf[x++] = '%';
+ buf[x++] = hex[(*p >> 4) & 0x0f];
+ buf[x++] = hex[*p & 0x0f];
+ } else {
+ buf[x++] = *p;
+ }
+ y++;
+ }
+ buf[x] = '\0';
+ return buf;
+}
+
+
+FT_DECLARE(char *) ftdm_url_decode(char *s, ftdm_size_t *len)
+{
+ /* This implementation of url_decode is slightly different compared to the
+ * Freeswitch one. This is because this implementation accepts the full
+ * range of values (0x00 - 0xFF) compared to the Freeswitch implementation
+ * that does not accept 0x00 */
+
+ char *o;
+ unsigned int tmp;
+ ftdm_size_t mylen = 0;
+
+ if (ftdm_strlen_zero(s)) {
+ return s;
+ }
+
+ for (o = s; *s; s++, o++) {
+ if (*s == '%' && strlen(s) > 2 && sscanf(s + 1, "%2x", &tmp) == 1) {
+ *o = (char) tmp;
+ s += 2;
+ } else {
+ *o = *s;
+ }
+ mylen++;
+ }
+ *o = '\0';
+ *len = mylen;
+ return s;
+}
+
FT_DECLARE(ftdm_status_t) ftdm_set_npi(const char *string, uint8_t *target)
{
uint8_t val;
diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c
index 1951678d73..b57292c5b0 100644
--- a/libs/freetdm/src/ftdm_io.c
+++ b/libs/freetdm/src/ftdm_io.c
@@ -244,6 +244,7 @@ static struct {
ftdm_caller_data_t *call_ids[MAX_CALLIDS+1];
ftdm_mutex_t *call_id_mutex;
uint32_t last_call_id;
+ char dtmfdebug_directory[1024];
} globals;
enum ftdm_enum_cpu_alarm_action_flags
@@ -309,21 +310,6 @@ FTDM_STR2ENUM(ftdm_str2channel_indication, ftdm_channel_indication2str, ftdm_cha
static ftdm_status_t ftdm_group_add_channels(ftdm_span_t* span, int currindex, const char* name);
-static const char *cut_path(const char *in)
-{
- const char *p, *ret = in;
- char delims[] = "/\\";
- char *i;
-
- for (i = delims; *i; i++) {
- p = in;
- while ((p = strchr(p, *i)) != 0) {
- ret = ++p;
- }
- }
- return ret;
-}
-
static void null_logger(const char *file, const char *func, int line, int level, const char *fmt, ...)
{
if (file && func && line && level && fmt) {
@@ -349,7 +335,6 @@ static int ftdm_log_level = FTDM_LOG_LEVEL_DEBUG;
static void default_logger(const char *file, const char *func, int line, int level, const char *fmt, ...)
{
- const char *fp;
char data[1024];
va_list ap;
@@ -359,14 +344,11 @@ static void default_logger(const char *file, const char *func, int line, int lev
if (level > ftdm_log_level) {
return;
}
-
- fp = cut_path(file);
va_start(ap, fmt);
vsnprintf(data, sizeof(data), fmt, ap);
-
fprintf(stderr, "[%s] %s:%d %s() %s", FTDM_LEVEL_NAMES[level], file, line, func, data);
va_end(ap);
@@ -410,13 +392,13 @@ FT_DECLARE(void) ftdm_set_echocancel_call_begin(ftdm_channel_t *chan)
if (ftdm_channel_test_feature(chan, FTDM_CHANNEL_FEATURE_HWEC)) {
if (ftdm_channel_test_feature(chan, FTDM_CHANNEL_FEATURE_HWEC_DISABLED_ON_IDLE)) {
/* If the ec is disabled on idle, we need to enable it unless is a digital call */
- if (caller_data->bearer_capability != FTDM_BEARER_CAP_64K_UNRESTRICTED) {
+ if (caller_data->bearer_capability != FTDM_BEARER_CAP_UNRESTRICTED) {
ftdm_log_chan(chan, FTDM_LOG_DEBUG, "Enabling ec for call in channel state %s\n", ftdm_channel_state2str(chan->state));
ftdm_channel_command(chan, FTDM_COMMAND_ENABLE_ECHOCANCEL, NULL);
}
} else {
/* If the ec is enabled on idle, we do nothing unless is a digital call that needs it disabled */
- if (caller_data->bearer_capability == FTDM_BEARER_CAP_64K_UNRESTRICTED) {
+ if (caller_data->bearer_capability == FTDM_BEARER_CAP_UNRESTRICTED) {
ftdm_log_chan(chan, FTDM_LOG_DEBUG, "Disabling ec for digital call in channel state %s\n", ftdm_channel_state2str(chan->state));
ftdm_channel_command(chan, FTDM_COMMAND_DISABLE_ECHOCANCEL, NULL);
}
@@ -507,13 +489,16 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_set_caller_data(ftdm_channel_t *ftdmchan,
{
ftdm_status_t err = FTDM_SUCCESS;
if (!ftdmchan) {
- ftdm_log(FTDM_LOG_CRIT, "Error: trying to set caller data, but no ftdmchan!\n");
+ ftdm_log(FTDM_LOG_CRIT, "trying to set caller data, but no ftdmchan!\n");
return FTDM_FAIL;
}
if ((err = ftdm_set_caller_data(ftdmchan->span, caller_data)) != FTDM_SUCCESS) {
return err;
}
ftdmchan->caller_data = *caller_data;
+ if (ftdmchan->caller_data.bearer_capability == FTDM_BEARER_CAP_UNRESTRICTED) {
+ ftdm_set_flag(ftdmchan, FTDM_CHANNEL_DIGITAL_MEDIA);
+ }
return FTDM_SUCCESS;
}
@@ -2310,7 +2295,9 @@ FT_DECLARE(ftdm_status_t) _ftdm_channel_call_indicate(const char *file, const ch
ftdm_set_flag(ftdmchan, FTDM_CHANNEL_IND_ACK_PENDING);
}
- if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) {
+ if (indication != FTDM_CHANNEL_INDICATE_FACILITY &&
+ ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) {
+
ftdm_log_chan_ex(ftdmchan, file, func, line, FTDM_LOG_LEVEL_WARNING, "Cannot indicate %s in outgoing channel in state %s\n",
ftdm_channel_indication2str(indication), ftdm_channel_state2str(ftdmchan->state));
status = FTDM_EINVAL;
@@ -2525,20 +2512,7 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_set_sig_status(ftdm_channel_t *fchan, ftd
ftdm_channel_lock(fchan);
- if (ftdm_test_flag(fchan, FTDM_CHANNEL_IN_ALARM)) {
- ftdm_log_chan_msg(fchan, FTDM_LOG_WARNING, "You can not set the signaling status of an alarmed channel\n");
- res = FTDM_EINVAL;
- goto done;
- }
-
- if (sigstatus == FTDM_SIG_STATE_DOWN) {
- ftdm_log_chan_msg(fchan, FTDM_LOG_WARNING, "You can not set the signaling status to DOWN, valid states are UP or SUSPENDED\n");
- res = FTDM_EINVAL;
- goto done;
- }
-
res = fchan->span->set_channel_sig_status(fchan, sigstatus);
-done:
ftdm_channel_unlock(fchan);
@@ -2638,6 +2612,7 @@ static ftdm_status_t ftdm_channel_done(ftdm_channel_t *ftdmchan)
ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_MEDIA);
ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_ANSWERED);
ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_USER_HANGUP);
+ ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_DIGITAL_MEDIA);
ftdm_mutex_lock(ftdmchan->pre_buffer_mutex);
ftdm_buffer_destroy(&ftdmchan->pre_buffer);
ftdmchan->pre_buffer_size = 0;
@@ -3469,7 +3444,7 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_queue_dtmf(ftdm_channel_t *ftdmchan, cons
if (!ftdmchan->dtmfdbg.file) {
struct tm currtime;
time_t currsec;
- char dfile[512];
+ char dfile[1024];
currsec = time(NULL);
@@ -3480,10 +3455,18 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_queue_dtmf(ftdm_channel_t *ftdmchan, cons
localtime_r(&currsec, &currtime);
#endif
- snprintf(dfile, sizeof(dfile), "dtmf-s%dc%d-20%d-%d-%d-%d:%d:%d.%s",
- ftdmchan->span_id, ftdmchan->chan_id,
- currtime.tm_year-100, currtime.tm_mon+1, currtime.tm_mday,
- currtime.tm_hour, currtime.tm_min, currtime.tm_sec, ftdmchan->native_codec == FTDM_CODEC_ULAW ? "ulaw" : ftdmchan->native_codec == FTDM_CODEC_ALAW ? "alaw" : "sln");
+ if (ftdm_strlen_zero(globals.dtmfdebug_directory)) {
+ snprintf(dfile, sizeof(dfile), "dtmf-s%dc%d-20%d-%d-%d-%d:%d:%d.%s",
+ ftdmchan->span_id, ftdmchan->chan_id,
+ currtime.tm_year-100, currtime.tm_mon+1, currtime.tm_mday,
+ currtime.tm_hour, currtime.tm_min, currtime.tm_sec, ftdmchan->native_codec == FTDM_CODEC_ULAW ? "ulaw" : ftdmchan->native_codec == FTDM_CODEC_ALAW ? "alaw" : "sln");
+ } else {
+ snprintf(dfile, sizeof(dfile), "%s/dtmf-s%dc%d-20%d-%d-%d-%d:%d:%d.%s",
+ globals.dtmfdebug_directory,
+ ftdmchan->span_id, ftdmchan->chan_id,
+ currtime.tm_year-100, currtime.tm_mon+1, currtime.tm_mday,
+ currtime.tm_hour, currtime.tm_min, currtime.tm_sec, ftdmchan->native_codec == FTDM_CODEC_ULAW ? "ulaw" : ftdmchan->native_codec == FTDM_CODEC_ALAW ? "alaw" : "sln");
+ }
ftdmchan->dtmfdbg.file = fopen(dfile, "wb");
if (!ftdmchan->dtmfdbg.file) {
ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "failed to open debug dtmf file %s\n", dfile);
@@ -3565,6 +3548,16 @@ static FIO_WRITE_FUNCTION(ftdm_raw_write)
static FIO_READ_FUNCTION(ftdm_raw_read)
{
ftdm_status_t status = ftdmchan->fio->read(ftdmchan, data, datalen);
+
+ if (status == FTDM_SUCCESS && ftdm_test_flag(ftdmchan, FTDM_CHANNEL_USE_RX_GAIN)
+ && (ftdmchan->native_codec == FTDM_CODEC_ALAW || ftdmchan->native_codec == FTDM_CODEC_ULAW)) {
+ ftdm_size_t i = 0;
+ unsigned char *rdata = data;
+ for (i = 0; i < *datalen; i++) {
+ rdata[i] = ftdmchan->rxgain_table[rdata[i]];
+ }
+ }
+
if (status == FTDM_SUCCESS && ftdmchan->fds[FTDM_READ_TRACE_INDEX] > -1) {
ftdm_size_t dlen = *datalen;
if ((ftdm_size_t)write(ftdmchan->fds[FTDM_READ_TRACE_INDEX], data, (int)dlen) != dlen) {
@@ -3732,7 +3725,6 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_read(ftdm_channel_t *ftdmchan, void *data
ftdm_status_t status = FTDM_FAIL;
fio_codec_t codec_func = NULL;
ftdm_size_t max = *datalen;
- unsigned i = 0;
ftdm_assert_return(ftdmchan != NULL, FTDM_FAIL, "ftdmchan is null\n");
ftdm_assert_return(ftdmchan->fio != NULL, FTDM_FAIL, "No I/O module attached to ftdmchan\n");
@@ -3771,15 +3763,12 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_read(ftdm_channel_t *ftdmchan, void *data
goto done;
}
- if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_USE_RX_GAIN)
- && (ftdmchan->native_codec == FTDM_CODEC_ALAW || ftdmchan->native_codec == FTDM_CODEC_ULAW)) {
- unsigned char *rdata = data;
- for (i = 0; i < *datalen; i++) {
- rdata[i] = ftdmchan->rxgain_table[rdata[i]];
- }
- }
handle_tone_generation(ftdmchan);
+ if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_DIGITAL_MEDIA)) {
+ goto done;
+ }
+
if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_TRANSCODE) && ftdmchan->effective_codec != ftdmchan->native_codec) {
if (ftdmchan->native_codec == FTDM_CODEC_ULAW && ftdmchan->effective_codec == FTDM_CODEC_SLIN) {
codec_func = fio_ulaw2slin;
@@ -3934,7 +3923,7 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_read(ftdm_channel_t *ftdmchan, void *data
ftdm_mutex_unlock(ftdmchan->pre_buffer_mutex);
- memset(data, 255, *datalen);
+ memset(data, FTDM_SILENCE_VALUE(ftdmchan), *datalen);
if (ftdmchan->skip_read_frames > 0) {
ftdmchan->skip_read_frames--;
@@ -3946,7 +3935,7 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_read(ftdm_channel_t *ftdmchan, void *data
if (ftdm_buffer_inuse(ftdmchan->pre_buffer) >= ftdmchan->pre_buffer_size) {
ftdm_buffer_read(ftdmchan->pre_buffer, data, *datalen);
} else {
- memset(data, 255, *datalen);
+ memset(data, FTDM_SILENCE_VALUE(ftdmchan), *datalen);
}
}
ftdm_mutex_unlock(ftdmchan->pre_buffer_mutex);
@@ -3994,6 +3983,10 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_write(ftdm_channel_t *ftdmchan, void *dat
status = FTDM_FAIL;
goto done;
}
+
+ if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_DIGITAL_MEDIA)) {
+ goto do_write;
+ }
if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_TRANSCODE) && ftdmchan->effective_codec != ftdmchan->native_codec) {
if (ftdmchan->native_codec == FTDM_CODEC_ULAW && ftdmchan->effective_codec == FTDM_CODEC_SLIN) {
@@ -4025,6 +4018,8 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_write(ftdm_channel_t *ftdmchan, void *dat
}
}
+do_write:
+
if (ftdmchan->span->sig_write) {
status = ftdmchan->span->sig_write(ftdmchan, data, *datalen);
if (status == FTDM_BREAK) {
@@ -4697,6 +4692,9 @@ static ftdm_status_t load_config(void)
globals.cpu_monitor.alarm_action_flags |= FTDM_CPU_ALARM_ACTION_WARN;
}
}
+ } else if (!strncasecmp(var, "debugdtmf_directory", sizeof("debugdtmf_directory")-1)) {
+ ftdm_set_string(globals.dtmfdebug_directory, val);
+ ftdm_log(FTDM_LOG_DEBUG, "Debug DTMF directory set to '%s'\n", globals.dtmfdebug_directory);
} else if (!strncasecmp(var, "cpu_monitoring_interval", sizeof("cpu_monitoring_interval")-1)) {
if (atoi(val) > 0) {
globals.cpu_monitor.interval = atoi(val);
@@ -5371,10 +5369,12 @@ FT_DECLARE(ftdm_status_t) ftdm_span_send_signal(ftdm_span_t *span, ftdm_sigmsg_t
ftdm_set_flag(sigmsg->channel, FTDM_CHANNEL_CALL_STARTED);
ftdm_call_set_call_id(sigmsg->channel, &sigmsg->channel->caller_data);
/* when cleaning up the public API I added this because mod_freetdm.c on_fxs_signal was
- * doing it during SIGEVENT_START, but now that flags are private they can't, wonder if
- * is needed at all?
- * */
+ * doing it during SIGEVENT_START, but now that flags are private they can't, wonder if
+ * is needed at all? */
ftdm_clear_flag(sigmsg->channel, FTDM_CHANNEL_HOLD);
+ if (sigmsg->channel->caller_data.bearer_capability == FTDM_BEARER_CAP_UNRESTRICTED) {
+ ftdm_set_flag(sigmsg->channel, FTDM_CHANNEL_DIGITAL_MEDIA);
+ }
}
break;
@@ -6057,9 +6057,12 @@ FT_DECLARE(ftdm_status_t) ftdm_sigmsg_get_raw_data_detached(ftdm_sigmsg_t *sigms
if (!sigmsg || !sigmsg->raw.len) {
return FTDM_FAIL;
}
-
+
*data = sigmsg->raw.data;
- *datalen = sigmsg->raw.len;
+ *datalen = sigmsg->raw.len;
+
+ sigmsg->raw.data = NULL;
+ sigmsg->raw.len = 0;
return FTDM_SUCCESS;
}
diff --git a/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.c b/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.c
index 21008e6c96..7e230ecc34 100644
--- a/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.c
+++ b/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.c
@@ -426,7 +426,6 @@ static void *ftdm_analog_channel_run(ftdm_thread_t *me, void *obj)
uint32_t state_counter = 0, elapsed = 0, collecting = 0, interval = 0, last_digit = 0, indicate = 0, dial_timeout = analog_data->wait_dialtone_timeout;
uint32_t answer_on_polarity_counter = 0;
ftdm_sigmsg_t sig;
- ftdm_status_t status;
ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "ANALOG CHANNEL thread starting.\n");
@@ -916,7 +915,7 @@ static void *ftdm_analog_channel_run(ftdm_thread_t *me, void *obj)
}
if (codec_func) {
- status = codec_func(frame, sizeof(frame), &rlen);
+ codec_func(frame, sizeof(frame), &rlen);
} else {
snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "codec error!");
goto done;
diff --git a/libs/freetdm/src/ftmod/ftmod_analog_em/ftmod_analog_em.c b/libs/freetdm/src/ftmod/ftmod_analog_em/ftmod_analog_em.c
index 31c2421b9b..907a8cb034 100644
--- a/libs/freetdm/src/ftmod/ftmod_analog_em/ftmod_analog_em.c
+++ b/libs/freetdm/src/ftmod/ftmod_analog_em/ftmod_analog_em.c
@@ -221,7 +221,6 @@ static void *ftdm_analog_em_channel_run(ftdm_thread_t *me, void *obj)
ftdm_channel_t *closed_chan;
uint32_t state_counter = 0, elapsed = 0, collecting = 0, interval = 0, last_digit = 0, indicate = 0, dial_timeout = 30000;
ftdm_sigmsg_t sig;
- ftdm_status_t status;
ftdm_log(FTDM_LOG_DEBUG, "ANALOG EM CHANNEL thread starting.\n");
@@ -545,7 +544,7 @@ static void *ftdm_analog_em_channel_run(ftdm_thread_t *me, void *obj)
}
if (codec_func) {
- status = codec_func(frame, sizeof(frame), &rlen);
+ codec_func(frame, sizeof(frame), &rlen);
} else {
snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "codec error!");
goto done;
diff --git a/libs/freetdm/src/ftmod/ftmod_isdn/ftmod_isdn.c b/libs/freetdm/src/ftmod/ftmod_isdn/ftmod_isdn.c
index a7b84ea5d8..4abddf16e1 100644
--- a/libs/freetdm/src/ftmod/ftmod_isdn/ftmod_isdn.c
+++ b/libs/freetdm/src/ftmod/ftmod_isdn/ftmod_isdn.c
@@ -979,7 +979,6 @@ static L3INT ftdm_isdn_931_34(void *pvt, struct Q931_Call *call, Q931mes_Generic
{
Q931ie_CallingNum *callingnum = Q931GetIEPtr(gen->CallingNum, gen->buf);
Q931ie_CalledNum *callednum = Q931GetIEPtr(gen->CalledNum, gen->buf);
- uint32_t cplen = mlen;
int overlap_dial = 0;
int fail_cause = 0;
int fail = 1;
@@ -2128,7 +2127,7 @@ static int ftdm_isdn_q921_log(void *pvt, Q921LogLevel_t level, char *msg, L2INT
return 0;
}
-static L3INT ftdm_isdn_q931_log(void *pvt, Q931LogLevel_t level, char *msg, L3INT size)
+static L3INT ftdm_isdn_q931_log(void *pvt, Q931LogLevel_t level, const char *msg, L3INT size)
{
ftdm_span_t *span = (ftdm_span_t *) pvt;
diff --git a/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.c b/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.c
index e051477346..8093443986 100644
--- a/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.c
+++ b/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.c
@@ -562,14 +562,18 @@ static ftdm_status_t state_advance(ftdm_channel_t *chan)
sig.chan_id = ftdm_channel_get_id(chan);
sig.span_id = ftdm_channel_get_span_id(chan);
sig.channel = chan;
-
+
ftdm_channel_complete_state(chan);
switch (ftdm_channel_get_state(chan)) {
case FTDM_CHANNEL_STATE_DOWN:
{
ftdm_channel_t *chtmp = chan;
- chan->call_data = NULL;
+
+ if (call) {
+ pri_destroycall(isdn_data->spri.pri, call);
+ chan->call_data = NULL;
+ }
if (ftdm_channel_close(&chtmp) != FTDM_SUCCESS) {
ftdm_log(FTDM_LOG_WARNING, "-- Failed to close channel %d:%d\n",
@@ -776,8 +780,7 @@ static ftdm_status_t state_advance(ftdm_channel_t *chan)
pri_hangup(isdn_data->spri.pri, call, caller_data->hangup_cause);
// pri_destroycall(isdn_data->spri.pri, call);
-
- chan->call_data = NULL;
+// chan->call_data = NULL;
}
ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_HANGUP_COMPLETE);
}
@@ -785,10 +788,10 @@ static ftdm_status_t state_advance(ftdm_channel_t *chan)
case FTDM_CHANNEL_STATE_HANGUP_COMPLETE:
{
- if (call) {
- pri_destroycall(isdn_data->spri.pri, call);
- chan->call_data = NULL;
- }
+// if (call) {
+// pri_destroycall(isdn_data->spri.pri, call);
+// chan->call_data = NULL;
+// }
ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_DOWN);
}
break;
@@ -854,7 +857,6 @@ static int on_hangup(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_even
{
ftdm_span_t *span = spri->span;
ftdm_channel_t *chan = ftdm_span_get_channel(span, pevent->hangup.channel);
- q931_call *call = NULL;
if (!chan) {
ftdm_log(FTDM_LOG_CRIT, "-- Hangup on channel %d:%d %s but it's not in use?\n", ftdm_span_get_id(spri->span), pevent->hangup.channel);
@@ -863,27 +865,61 @@ static int on_hangup(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_even
ftdm_channel_lock(chan);
- if (ftdm_channel_get_state(chan) >= FTDM_CHANNEL_STATE_TERMINATING) {
- ftdm_log_chan(chan, FTDM_LOG_DEBUG, "Ignoring remote hangup in state %s\n", ftdm_channel_get_state_str(chan));
- goto done;
+ switch (event_type) {
+ case LPWRAP_PRI_EVENT_HANGUP_REQ: /* DISCONNECT */
+ if (ftdm_channel_get_state(chan) >= FTDM_CHANNEL_STATE_TERMINATING) {
+ ftdm_log_chan(chan, FTDM_LOG_DEBUG, "Ignoring remote hangup in state %s\n",
+ ftdm_channel_get_state_str(chan));
+ goto done;
+ }
+ ftdm_log(FTDM_LOG_DEBUG, "-- Hangup REQ on channel %d:%d\n",
+ ftdm_span_get_id(spri->span), pevent->hangup.channel);
+
+ pri_hangup(spri->pri, pevent->hangup.call, pevent->hangup.cause);
+
+ chan->caller_data.hangup_cause = pevent->hangup.cause;
+ ftdm_set_state(chan, FTDM_CHANNEL_STATE_TERMINATING);
+ break;
+
+ case LPWRAP_PRI_EVENT_HANGUP_ACK: /* */
+ ftdm_log(FTDM_LOG_DEBUG, "-- Hangup ACK on channel %d:%d\n",
+ ftdm_span_get_id(spri->span), pevent->hangup.channel);
+
+ pri_hangup(spri->pri, pevent->hangup.call, pevent->hangup.cause);
+
+ ftdm_set_state(chan, FTDM_CHANNEL_STATE_HANGUP_COMPLETE);
+ break;
+
+ case LPWRAP_PRI_EVENT_HANGUP: /* "RELEASE/RELEASE_COMPLETE/other" */
+ ftdm_log(FTDM_LOG_DEBUG, "-- Hangup on channel %d:%d\n",
+ ftdm_span_get_id(spri->span), pevent->hangup.channel);
+
+ switch (ftdm_channel_get_state(chan)) {
+ case FTDM_CHANNEL_STATE_DIALING:
+ case FTDM_CHANNEL_STATE_RINGING:
+ case FTDM_CHANNEL_STATE_PROGRESS:
+ case FTDM_CHANNEL_STATE_PROGRESS_MEDIA:
+ case FTDM_CHANNEL_STATE_PROCEED:
+ case FTDM_CHANNEL_STATE_UP:
+ chan->caller_data.hangup_cause = pevent->hangup.cause;
+ ftdm_set_state(chan, FTDM_CHANNEL_STATE_TERMINATING);
+ break;
+ case FTDM_CHANNEL_STATE_HANGUP:
+ chan->caller_data.hangup_cause = pevent->hangup.cause;
+ ftdm_set_state(chan, FTDM_CHANNEL_STATE_HANGUP_COMPLETE);
+ break;
+// case FTDM_CHANNEL_STATE_TERMINATING:
+// ftdm_set_state(chan, FTDM_CHANNEL_STATE_HANGUP);
+// break;
+// case FTDM_CHANNEL_STATE_HANGUP_COMPLETE:
+// ftdm_set_state(chan, FTDM_CHANNEL_STATE_DOWN);
+// break;
+ }
+ break;
+ default:
+ break;
}
- if (!chan->call_data) {
- ftdm_log_chan(chan, FTDM_LOG_DEBUG, "Ignoring remote hangup in state %s with no call data\n", ftdm_channel_get_state_str(chan));
- goto done;
- }
-
- call = (q931_call *)chan->call_data;
-
- ftdm_log(FTDM_LOG_DEBUG, "-- Hangup on channel %d:%d\n", ftdm_span_get_id(spri->span), pevent->hangup.channel);
-
- pri_release(spri->pri, call, 0);
- pri_destroycall(spri->pri, call);
-
- chan->caller_data.hangup_cause = pevent->hangup.cause;
- chan->call_data = NULL;
- ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_TERMINATING);
-
done:
ftdm_channel_unlock(chan);
return 0;
@@ -943,12 +979,12 @@ static int on_proceeding(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_
if (chan) {
/* Open channel if inband information is available */
- if ((pevent->proceeding.progressmask & PRI_PROG_INBAND_AVAILABLE) && !ftdm_test_flag(chan, FTDM_CHANNEL_OPEN)) {
- ftdm_log(FTDM_LOG_DEBUG, "-- In-band information available, opening B-Channel %d:%d\n",
+ if (pevent->proceeding.progressmask & PRI_PROG_INBAND_AVAILABLE) {
+ ftdm_log(FTDM_LOG_DEBUG, "-- In-band information available, B-Channel %d:%d\n",
ftdm_channel_get_span_id(chan),
ftdm_channel_get_id(chan));
- if (ftdm_channel_open_chan(chan) != FTDM_SUCCESS) {
+ if (!ftdm_test_flag(chan, FTDM_CHANNEL_OPEN) && (ftdm_channel_open_chan(chan) != FTDM_SUCCESS)) {
ftdm_caller_data_t *caller_data = ftdm_channel_get_caller_data(chan);
ftdm_log(FTDM_LOG_ERROR, "-- Error opening channel %d:%d\n",
@@ -985,12 +1021,12 @@ static int on_progress(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_ev
if (chan) {
/* Open channel if inband information is available */
- if ((pevent->proceeding.progressmask & PRI_PROG_INBAND_AVAILABLE) && !ftdm_test_flag(chan, FTDM_CHANNEL_OPEN)) {
- ftdm_log(FTDM_LOG_DEBUG, "-- In-band information available, opening B-Channel %d:%d\n",
+ if (pevent->proceeding.progressmask & PRI_PROG_INBAND_AVAILABLE) {
+ ftdm_log(FTDM_LOG_DEBUG, "-- In-band information available, B-Channel %d:%d\n",
ftdm_channel_get_span_id(chan),
ftdm_channel_get_id(chan));
- if (ftdm_channel_open_chan(chan) != FTDM_SUCCESS) {
+ if (!ftdm_test_flag(chan, FTDM_CHANNEL_OPEN) && (ftdm_channel_open_chan(chan) != FTDM_SUCCESS)) {
ftdm_caller_data_t *caller_data = ftdm_channel_get_caller_data(chan);
ftdm_log(FTDM_LOG_ERROR, "-- Error opening channel %d:%d\n",
@@ -1028,8 +1064,6 @@ static int on_ringing(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_eve
ftdm_channel_t *chan = ftdm_span_get_channel(span, pevent->ringing.channel);
if (chan) {
- ftdm_log(FTDM_LOG_DEBUG, "-- Ringing on channel %d:%d\n", ftdm_span_get_id(span), pevent->ringing.channel);
-
/* we may get on_ringing even when we're already in FTDM_CHANNEL_STATE_PROGRESS_MEDIA */
// if (ftdm_channel_get_state(chan) == FTDM_CHANNEL_STATE_PROGRESS_MEDIA) {
// /* dont try to move to STATE_PROGRESS to avoid annoying veto warning */
@@ -1037,12 +1071,12 @@ static int on_ringing(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_eve
// }
/* Open channel if inband information is available */
- if ((pevent->ringing.progressmask & PRI_PROG_INBAND_AVAILABLE) && !ftdm_test_flag(chan, FTDM_CHANNEL_OPEN)) {
- ftdm_log(FTDM_LOG_DEBUG, "-- In-band information available, opening B-Channel %d:%d\n",
+ if ((pevent->ringing.progressmask & PRI_PROG_INBAND_AVAILABLE)) {
+ ftdm_log(FTDM_LOG_DEBUG, "-- In-band information available, B-Channel %d:%d\n",
ftdm_channel_get_span_id(chan),
ftdm_channel_get_id(chan));
- if (ftdm_channel_open_chan(chan) != FTDM_SUCCESS) {
+ if (!ftdm_test_flag(chan, FTDM_CHANNEL_OPEN) && (ftdm_channel_open_chan(chan) != FTDM_SUCCESS)) {
ftdm_caller_data_t *caller_data = ftdm_channel_get_caller_data(chan);
ftdm_log(FTDM_LOG_ERROR, "-- Error opening channel %d:%d\n",
@@ -1053,9 +1087,13 @@ static int on_ringing(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_eve
ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_TERMINATING);
goto out;
}
+ ftdm_log(FTDM_LOG_DEBUG, "-- Ringing on channel %d:%d with media\n", ftdm_span_get_id(span), pevent->proceeding.channel);
+ ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA);
+ } else {
+// ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_PROGRESS);
+ ftdm_log(FTDM_LOG_DEBUG, "-- Ringing on channel %d:%d\n", ftdm_span_get_id(span), pevent->proceeding.channel);
+ ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_RINGING);
}
-// ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_PROGRESS);
- ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_RINGING);
} else {
ftdm_log(FTDM_LOG_DEBUG, "-- Ringing on channel %d:%d but it's not in the span?\n",
ftdm_span_get_id(span), pevent->ringing.channel);
@@ -1652,6 +1690,7 @@ static void *ftdm_libpri_run(ftdm_thread_t *me, void *obj)
LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_DCHAN_UP, on_dchan_up);
LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_DCHAN_DOWN, on_dchan_down);
LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_HANGUP_REQ, on_hangup);
+ LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_HANGUP_ACK, on_hangup);
LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_HANGUP, on_hangup);
LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_INFO_RECEIVED, on_info);
LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_RESTART, on_restart);
@@ -1926,6 +1965,10 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_libpri_configure_span)
assert(isdn_data != NULL);
memset(isdn_data, 0, sizeof(*isdn_data));
+ /* set some default values */
+ isdn_data->mode = PRI_CPE;
+ isdn_data->ton = PRI_UNKNOWN;
+
switch (ftdm_span_get_trunk_type(span)) {
case FTDM_TRUNK_BRI:
case FTDM_TRUNK_BRI_PTMP:
@@ -1936,12 +1979,14 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_libpri_configure_span)
#endif
case FTDM_TRUNK_E1:
ftdm_log(FTDM_LOG_NOTICE, "Setting default Layer 1 to ALAW since this is an E1/BRI/BRI PTMP trunk\n");
- isdn_data->layer1 = PRI_LAYER_1_ALAW;
+ isdn_data->layer1 = PRI_LAYER_1_ALAW;
+ isdn_data->dialect = PRI_SWITCH_EUROISDN_E1;
break;
case FTDM_TRUNK_T1:
case FTDM_TRUNK_J1:
ftdm_log(FTDM_LOG_NOTICE, "Setting default Layer 1 to ULAW since this is a T1/J1 trunk\n");
- isdn_data->layer1 = PRI_LAYER_1_ULAW;
+ isdn_data->layer1 = PRI_LAYER_1_ULAW;
+ isdn_data->dialect = PRI_SWITCH_LUCENT5E;
break;
default:
ftdm_log(FTDM_LOG_ERROR, "Invalid trunk type: '%s'\n", ftdm_span_get_trunk_type_str(span));
diff --git a/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c b/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c
index c47f97a50b..1c15f992a2 100755
--- a/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c
+++ b/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c
@@ -360,11 +360,15 @@ static void ft_r2_clean_call(ftdm_r2_call_t *call)
static void ft_r2_accept_call(ftdm_channel_t *ftdmchan)
{
openr2_chan_t *r2chan = R2CALL(ftdmchan)->r2chan;
- // FIXME: not always accept as no charge, let the user decide that
- // also we should check the return code from openr2_chan_accept_call and handle error condition
+ ftdm_r2_data_t *r2data = ftdmchan->span->signal_data;
+
+ // FIXME: we should check the return code from openr2_chan_accept_call and handle error condition
// hanging up the call with protocol error as the reason, this openr2 API will fail only when there something
// wrong at the I/O layer or the library itself
- openr2_chan_accept_call(r2chan, OR2_CALL_NO_CHARGE);
+ if (r2data->charge_calls)
+ openr2_chan_accept_call(r2chan, OR2_CALL_WITH_CHARGE);
+ else
+ openr2_chan_accept_call(r2chan, OR2_CALL_NO_CHARGE);
}
static void ft_r2_answer_call(ftdm_channel_t *ftdmchan)
@@ -520,6 +524,28 @@ static FIO_CHANNEL_SET_SIG_STATUS_FUNCTION(ftdm_r2_set_channel_sig_status)
openr2_chan_t *r2chan = R2CALL(ftdmchan)->r2chan;
openr2_cas_signal_t rxcas, txcas;
+ if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_IN_ALARM)) {
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG,
+ "Received request to change sig status of alarmed channel to %s", ftdm_signaling_status2str(status));
+
+ switch (status) {
+ case FTDM_SIG_STATE_SUSPENDED:
+ openr2_chan_set_blocked(r2chan);
+ /* Need to send sig status change to SUSPENDED once out of alarm */
+ R2CALL(ftdmchan)->localsuspend_on_alarm = 1;
+ break;
+ case FTDM_SIG_STATE_UP:
+ openr2_chan_set_blocked(r2chan);
+ /* DO NOT send sig status change to SUSPENDED once out of alarm */
+ R2CALL(ftdmchan)->localsuspend_on_alarm = 0;
+ break;
+ default:
+ ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Cannot set signaling status to unknown value '%d'\n", status);
+ return FTDM_FAIL;
+ }
+ return FTDM_SUCCESS;
+ }
+
/* get the current rx and tx cas bits */
openr2_chan_get_cas(r2chan, &rxcas, &txcas);
@@ -1675,6 +1701,8 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_r2_configure_span_signaling)
r2data->category = r2conf.category;
r2data->allow_collect_calls = r2conf.allow_collect_calls;
r2data->flags = 0;
+ r2data->charge_calls = r2conf.charge_calls;
+ r2data->forced_release = r2conf.forced_release;
spanpvt->r2context = r2data->r2context;
/* just the value must be freed by the hash */
@@ -1832,6 +1860,10 @@ static ftdm_status_t ftdm_r2_state_advance(ftdm_channel_t *ftdmchan)
{
if (!r2call->disconnect_rcvd) {
openr2_call_disconnect_cause_t disconnect_cause = ftdm_r2_ftdm_cause_to_openr2_cause(ftdmchan);
+ /* overwrite the hangup cause if this is an incoming call and forced_release is set */
+ if (openr2_chan_get_direction(r2chan) == OR2_DIR_BACKWARD && r2data->forced_release) {
+ disconnect_cause = OR2_CAUSE_FORCED_RELEASE;
+ }
ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Clearing call, cause = %s\n", openr2_proto_get_disconnect_string(disconnect_cause));
/* this will disconnect the call, but need to wait for the call end before moving to DOWN */
openr2_chan_disconnect_call(r2chan, disconnect_cause);
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.2008.vcproj b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.2008.vcproj
index 2e7fb82041..01395cb1db 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.2008.vcproj
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.2008.vcproj
@@ -118,7 +118,7 @@
- WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
true
EnableFastChecks
MultiThreadedDLL
@@ -157,7 +157,7 @@
- WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
EnableFastChecks
MultiThreadedDLL
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c
index d119ff4fd2..3cf4876070 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c
@@ -996,11 +996,15 @@ static ftdm_status_t ftdm_sangoma_isdn_start(ftdm_span_t *span)
ftdm_clear_flag(span, FTDM_SPAN_STOP_THREAD);
ftdm_clear_flag(span, FTDM_SPAN_IN_THREAD);
- if (signal_data->raw_trace_q921 == SNGISDN_OPT_TRUE) {
+ if (signal_data->trace_q921 == SNGISDN_OPT_TRUE ||
+ signal_data->raw_trace_q921 == SNGISDN_OPT_TRUE) {
+
sngisdn_activate_trace(span, SNGISDN_TRACE_Q921);
}
- if (signal_data->raw_trace_q931 == SNGISDN_OPT_TRUE) {
+ if (signal_data->trace_q931 == SNGISDN_OPT_TRUE ||
+ signal_data->raw_trace_q931 == SNGISDN_OPT_TRUE) {
+
sngisdn_activate_trace(span, SNGISDN_TRACE_Q931);
}
@@ -1195,9 +1199,17 @@ static FIO_SIG_UNLOAD_FUNCTION(ftdm_sangoma_isdn_unload)
return FTDM_SUCCESS;
}
+#define SANGOMA_ISDN_API_USAGE_TRACE "ftdm sangoma_isdn trace \n"
+#define SANGOMA_ISDN_API_USAGE_SHOW_L1_STATS "ftdm sangoma_isdn l1_stats \n"
+#define SANGOMA_ISDN_API_USAGE_SHOW_SPANS "ftdm sangoma_isdn show_spans []\n"
+
+#define SANGOMA_ISDN_API_USAGE "\t"SANGOMA_ISDN_API_USAGE_TRACE \
+ "\t"SANGOMA_ISDN_API_USAGE_SHOW_L1_STATS \
+ "\t"SANGOMA_ISDN_API_USAGE_SHOW_SPANS
+
static FIO_API_FUNCTION(ftdm_sangoma_isdn_api)
{
- ftdm_status_t status = FTDM_SUCCESS;
+ ftdm_status_t status = FTDM_EINVAL;
char *mycmd = NULL, *argv[10] = { 0 };
int argc = 0;
@@ -1219,7 +1231,7 @@ static FIO_API_FUNCTION(ftdm_sangoma_isdn_api)
ftdm_span_t *span;
if (argc < 3) {
- ftdm_log(FTDM_LOG_ERROR, "Usage: ftdm sangoma_isdn trace \n");
+ ftdm_log(FTDM_LOG_ERROR, "Usage: %s\n", SANGOMA_ISDN_API_USAGE_TRACE);
status = FTDM_FAIL;
goto done;
}
@@ -1228,34 +1240,40 @@ static FIO_API_FUNCTION(ftdm_sangoma_isdn_api)
status = ftdm_span_find_by_name(argv[2], &span);
if (FTDM_SUCCESS != status) {
stream->write_function(stream, "-ERR failed to find span by name %s\n", argv[2]);
+
+ status = FTDM_FAIL;
goto done;
}
if (!strcasecmp(trace_opt, "q921")) {
- sngisdn_activate_trace(span, SNGISDN_TRACE_Q921);
+ status = sngisdn_activate_trace(span, SNGISDN_TRACE_Q921);
} else if (!strcasecmp(trace_opt, "q931")) {
- sngisdn_activate_trace(span, SNGISDN_TRACE_Q931);
+ status = sngisdn_activate_trace(span, SNGISDN_TRACE_Q931);
} else if (!strcasecmp(trace_opt, "disable")) {
- sngisdn_activate_trace(span, SNGISDN_TRACE_DISABLE);
+ status = sngisdn_activate_trace(span, SNGISDN_TRACE_DISABLE);
} else {
stream->write_function(stream, "-ERR invalid trace option \n");
+ status = FTDM_FAIL;
}
+ goto done;
}
+
if (!strcasecmp(argv[0], "l1_stats")) {
ftdm_span_t *span;
if (argc < 2) {
- stream->write_function(stream, "Usage: ftdm sangoma_isdn l1_stats \n");
+ stream->write_function(stream, "Usage: %s\n", SANGOMA_ISDN_API_USAGE_SHOW_L1_STATS);
status = FTDM_FAIL;
goto done;
}
status = ftdm_span_find_by_name(argv[1], &span);
if (FTDM_SUCCESS != status) {
stream->write_function(stream, "-ERR failed to find span with name %s\n", argv[1]);
- /* Return SUCCESS because we do not want to print the general FTDM usage list */
- status = FTDM_SUCCESS;
+
+ status = FTDM_FAIL;
goto done;
}
- sngisdn_print_phy_stats(stream, span);
+ status = sngisdn_show_l1_stats(stream, span);
+ goto done;
}
if (!strcasecmp(argv[0], "show_spans")) {
@@ -1264,20 +1282,39 @@ static FIO_API_FUNCTION(ftdm_sangoma_isdn_api)
status = ftdm_span_find_by_name(argv[1], &span);
if (FTDM_SUCCESS != status) {
stream->write_function(stream, "-ERR failed to find span with name %s\n", argv[1]);
- /* Return SUCCESS because we do not want to print the general FTDM usage list */
- status = FTDM_SUCCESS;
+
+ stream->write_function(stream, "Usage: %s\n", SANGOMA_ISDN_API_USAGE_SHOW_SPANS);
+ status = FTDM_FAIL;
goto done;
}
- sngisdn_print_span(stream, span);
- status = FTDM_SUCCESS;
+ status = sngisdn_show_span(stream, span);
goto done;
}
- sngisdn_print_spans(stream);
+ status = sngisdn_show_spans(stream);
+ goto done;
}
+
if (!strcasecmp(argv[0], "check_ids")) {
- sngisdn_check_free_ids();
+ status = sngisdn_check_free_ids();
+ goto done;
}
done:
+ switch (status) {
+ case FTDM_SUCCESS:
+ stream->write_function(stream, "Command executed OK\n");
+ break;
+ case FTDM_EINVAL:
+ stream->write_function(stream, "Invalid arguments [%s]\n", mycmd);
+ stream->write_function(stream, "Usage:\n%s\n", SANGOMA_ISDN_API_USAGE);
+ break;
+ default:
+ /* FTDM_FAIL - Do nothing since we already printed the cause of the error */
+ break;
+ }
+
+ /* Return SUCCESS because we do not want to print the general FTDM usage list */
+ status = FTDM_SUCCESS;
+
ftdm_safe_free(mycmd);
return status;
}
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h
index 43d6ad555e..ac69fa8d66 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h
@@ -213,6 +213,8 @@ typedef struct sngisdn_span_data {
int8_t facility_timeout;
uint8_t num_local_numbers;
uint8_t ignore_cause_value;
+ uint8_t trace_q931; /* TODO: combine with trace_flags */
+ uint8_t trace_q921; /* TODO: combine with trace_flags */
uint8_t raw_trace_q931; /* TODO: combine with trace_flags */
uint8_t raw_trace_q921; /* TODO: combine with trace_flags */
uint8_t timer_t3;
@@ -290,6 +292,12 @@ typedef struct ftdm_sngisdn_data {
sngisdn_span_data_t *spans[MAX_L1_LINKS+1]; /* spans are indexed by link_id */
}ftdm_sngisdn_data_t;
+typedef struct ftdm2trillium
+{
+ uint8_t ftdm_val;
+ uint8_t trillium_val;
+}ftdm2trillium_t;
+
/* TODO implement these 2 functions */
#define ISDN_FUNC_TRACE_ENTER(a)
@@ -469,9 +477,9 @@ ftdm_status_t sngisdn_stack_start(ftdm_span_t *span);
ftdm_status_t sngisdn_stack_stop(ftdm_span_t *span);
ftdm_status_t sngisdn_wake_up_phy(ftdm_span_t *span);
-void sngisdn_print_phy_stats(ftdm_stream_handle_t *stream, ftdm_span_t *span);
-void sngisdn_print_spans(ftdm_stream_handle_t *stream);
-void sngisdn_print_span(ftdm_stream_handle_t *stream, ftdm_span_t *span);
+ftdm_status_t sngisdn_show_l1_stats(ftdm_stream_handle_t *stream, ftdm_span_t *span);
+ftdm_status_t sngisdn_show_spans(ftdm_stream_handle_t *stream);
+ftdm_status_t sngisdn_show_span(ftdm_stream_handle_t *stream, ftdm_span_t *span);
#endif /* __FTMOD_SNG_ISDN_H__ */
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c
index 9fe28190e1..49b07fff33 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c
@@ -333,7 +333,8 @@ ftdm_status_t ftmod_isdn_parse_cfg(ftdm_conf_parameter_t *ftdm_parameters, ftdm_
parse_yesno(var, val, &signal_data->setup_arb);
} else if (!strcasecmp(var, "facility")) {
parse_yesno(var, val, &signal_data->facility);
- } else if (!strcasecmp(var, "min_digits")) {
+ } else if (!strcasecmp(var, "min-digits") ||
+ !strcasecmp(var, "min_digits")) {
signal_data->min_digits = atoi(val);
} else if (!strcasecmp(var, "outbound-called-ton")) {
ftdm_set_ton(val, &span->default_caller_data.dnis.type);
@@ -347,11 +348,11 @@ ftdm_status_t ftmod_isdn_parse_cfg(ftdm_conf_parameter_t *ftdm_parameters, ftdm_
ftdm_set_ton(val, &span->default_caller_data.rdnis.type);
} else if (!strcasecmp(var, "outbound-rdnis-npi")) {
ftdm_set_npi(val, &span->default_caller_data.rdnis.plan);
- } else if (!strcasecmp(var, "outbound-bearer_cap") ||
- !strcasecmp(var, "outbound-bc-transfer-cap")) {
+ } else if (!strcasecmp(var, "outbound-bc-transfer-cap") ||
+ !strcasecmp(var, "outbound-bearer_cap")) {
ftdm_set_bearer_capability(val, (uint8_t*)&span->default_caller_data.bearer_capability);
- } else if (!strcasecmp(var, "outbound-bearer_layer1") ||
- !strcasecmp(var, "outbound-bc-user-layer1")) {
+ } else if (!strcasecmp(var, "outbound-bc-user-layer1") ||
+ !strcasecmp(var, "outbound-bearer_layer1")) {
ftdm_set_bearer_layer1(val, (uint8_t*)&span->default_caller_data.bearer_layer1);
} else if (!strcasecmp(var, "channel-restart-on-link-up")) {
parse_yesno(var, val, &signal_data->restart_opt);
@@ -368,6 +369,10 @@ ftdm_status_t ftmod_isdn_parse_cfg(ftdm_conf_parameter_t *ftdm_parameters, ftdm_
parse_yesno(var, val, &signal_data->facility_ie_decode);
} else if (!strcasecmp(var, "ignore-cause-value")) {
parse_yesno(var, val, &signal_data->ignore_cause_value);
+ } else if (!strcasecmp(var, "q931-trace")) {
+ parse_yesno(var, val, &signal_data->trace_q931);
+ } else if (!strcasecmp(var, "q921-trace")) {
+ parse_yesno(var, val, &signal_data->trace_q921);
} else if (!strcasecmp(var, "q931-raw-trace")) {
parse_yesno(var, val, &signal_data->raw_trace_q931);
} else if (!strcasecmp(var, "q921-raw-trace")) {
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c
index 1bd2753e81..88aa9131b6 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c
@@ -745,8 +745,16 @@ ftdm_status_t sngisdn_stack_cfg_q931_dlsap(ftdm_span_t *span)
/* TODO: Fill in these timers with proper values - eventually pass them */
cfg.t.cfg.s.inDLSAP.tmr.t301.enb = TRUE;
cfg.t.cfg.s.inDLSAP.tmr.t301.val = 180;
- cfg.t.cfg.s.inDLSAP.tmr.t302.enb = TRUE;
- cfg.t.cfg.s.inDLSAP.tmr.t302.val = 15;
+
+ /* It looks like ETSI is the only variant that supports Overlap */
+ if (signal_data->switchtype == SNGISDN_SWITCH_EUROISDN) {
+ cfg.t.cfg.s.inDLSAP.tmr.t302.enb = TRUE;
+ cfg.t.cfg.s.inDLSAP.tmr.t302.val = 15;
+ } else {
+ cfg.t.cfg.s.inDLSAP.tmr.t302.enb = FALSE;
+ cfg.t.cfg.s.inDLSAP.tmr.t302.val = 0;
+ }
+
cfg.t.cfg.s.inDLSAP.tmr.t303.enb = TRUE;
cfg.t.cfg.s.inDLSAP.tmr.t303.val = 4;
cfg.t.cfg.s.inDLSAP.tmr.t304.enb = TRUE;
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c
index a9d2d06c32..0789c433f9 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c
@@ -662,7 +662,7 @@ void sngisdn_process_rel_ind (sngisdn_event_data_t *sngisdn_event)
}
break;
case FTDM_CHANNEL_STATE_RESET:
- ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Processing SETUP but channel in RESET state, ignoring\n");
+ ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Processing RELEASE but channel in RESET state, ignoring\n");
break;
default:
ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Received RELEASE in an invalid state (%s)\n",
@@ -807,17 +807,10 @@ void sngisdn_process_fac_ind (sngisdn_event_data_t *sngisdn_event)
if (signal_data->facility_ie_decode == SNGISDN_OPT_FALSE) {
/* If Facility decoding is disabled, we do not care about current call state, just pass event up to user */
- ftdm_sigmsg_t sigev;
if (facEvnt->facElmt.facStr.pres) {
get_facility_ie_str(ftdmchan, &facEvnt->facElmt.facStr.val[2], facEvnt->facElmt.facStr.len-2);
+ sngisdn_send_signal(sngisdn_info, FTDM_SIGEVENT_FACILITY);
}
- memset(&sigev, 0, sizeof(sigev));
- sigev.chan_id = ftdmchan->chan_id;
- sigev.span_id = ftdmchan->span_id;
- sigev.channel = ftdmchan;
-
- sigev.event_id = FTDM_SIGEVENT_FACILITY;
- ftdm_span_send_signal(ftdmchan->span, &sigev);
ISDN_FUNC_TRACE_EXIT(__FUNCTION__);
return;
}
@@ -838,7 +831,7 @@ void sngisdn_process_fac_ind (sngisdn_event_data_t *sngisdn_event)
if (sng_isdn_retrieve_facility_caller_name(&facEvnt->facElmt.facStr.val[2], facEvnt->facElmt.facStr.len, retrieved_str) == 0) {
strcpy(ftdmchan->caller_data.cid_name, retrieved_str);
} else {
- ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "Failed to retrieve Caller Name from Facility IE\n");
+ ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Failed to retrieve Caller Name from Facility IE\n");
}
if (signal_data->facility_timeout) {
/* Cancel facility timeout */
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c
index b56c95b10d..674e642719 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c
@@ -60,7 +60,7 @@ void sngisdn_snd_setup(ftdm_channel_t *ftdmchan)
}
ftdm_log_chan(sngisdn_info->ftdmchan, FTDM_LOG_INFO, "Outgoing call: Called No:[%s] Calling No:[%s]\n", ftdmchan->caller_data.dnis.digits, ftdmchan->caller_data.cid_num.digits);
- set_chan_id_ie(ftdmchan, &conEvnt.chanId);
+ set_chan_id_ie(ftdmchan, &conEvnt.chanId);
set_bear_cap_ie(ftdmchan, &conEvnt.bearCap[0]);
set_called_num(ftdmchan, &conEvnt.cdPtyNmb);
set_calling_num(ftdmchan, &conEvnt.cgPtyNmb);
@@ -125,8 +125,11 @@ void sngisdn_snd_con_complete(ftdm_channel_t *ftdmchan)
}
memset(&cnStEvnt, 0, sizeof(cnStEvnt));
-
- set_chan_id_ie(ftdmchan, &cnStEvnt.chanId);
+
+ /* Indicate channel ID only in first response */
+ if (!ftdm_test_flag(sngisdn_info, FLAG_SENT_CHAN_ID)) {
+ set_chan_id_ie(ftdmchan, &cnStEvnt.chanId);
+ }
ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending CONNECT COMPL (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, signal_data->dchan_id, sngisdn_info->ces);
@@ -152,7 +155,10 @@ void sngisdn_snd_proceed(ftdm_channel_t *ftdmchan, ftdm_sngisdn_progind_t prog_i
memset(&cnStEvnt, 0, sizeof(cnStEvnt));
- set_chan_id_ie(ftdmchan, &cnStEvnt.chanId);
+ /* Indicate channel ID only in first response */
+ if (!ftdm_test_flag(sngisdn_info, FLAG_SENT_CHAN_ID)) {
+ set_chan_id_ie(ftdmchan, &cnStEvnt.chanId);
+ }
set_prog_ind_ie(ftdmchan, &cnStEvnt.progInd, prog_ind);
set_facility_ie(ftdmchan, &cnStEvnt.facilityStr);
@@ -238,7 +244,10 @@ void sngisdn_snd_connect(ftdm_channel_t *ftdmchan)
memset(&cnStEvnt, 0, sizeof(cnStEvnt));
- set_chan_id_ie(ftdmchan, &cnStEvnt.chanId);
+ /* Indicate channel ID only in first response */
+ if (!ftdm_test_flag(sngisdn_info, FLAG_SENT_CHAN_ID)) {
+ set_chan_id_ie(ftdmchan, &cnStEvnt.chanId);
+ }
set_prog_ind_ie(ftdmchan, &cnStEvnt.progInd, prog_ind);
set_facility_ie(ftdmchan, &cnStEvnt.facilityStr);
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c
index 791b65f0f6..67de893f5d 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c
@@ -677,20 +677,20 @@ void sngisdn_rcv_q921_ind(BdMngmt *status)
}
switch (status->t.usta.alarm.category) {
- case (LCM_CATEGORY_INTERFACE):
- ftdm_log(FTDM_LOG_INFO, "[SNGISDN Q921] %s: %s: %s(%d): %s(%d)\n",
- ftdmspan->name,
- DECODE_LCM_CATEGORY(status->t.usta.alarm.category),
- DECODE_LCM_EVENT(status->t.usta.alarm.event), status->t.usta.alarm.event,
- DECODE_LCM_CAUSE(status->t.usta.alarm.cause), status->t.usta.alarm.cause);
+ case (LCM_CATEGORY_PROTOCOL):
+ ftdm_log(FTDM_LOG_DEBUG, "[SNGISDN Q921] %s: %s: %s(%d): %s(%d)\n",
+ ftdmspan->name,
+ DECODE_LCM_CATEGORY(status->t.usta.alarm.category),
+ DECODE_LLD_EVENT(status->t.usta.alarm.event), status->t.usta.alarm.event,
+ DECODE_LLD_CAUSE(status->t.usta.alarm.cause), status->t.usta.alarm.cause);
break;
default:
ftdm_log(FTDM_LOG_INFO, "[SNGISDN Q921] %s: %s: %s(%d): %s(%d)\n",
- ftdmspan->name,
- DECODE_LCM_CATEGORY(status->t.usta.alarm.category),
- DECODE_LLD_EVENT(status->t.usta.alarm.event), status->t.usta.alarm.event,
- DECODE_LLD_CAUSE(status->t.usta.alarm.cause), status->t.usta.alarm.cause);
-
+ ftdmspan->name,
+ DECODE_LCM_CATEGORY(status->t.usta.alarm.category),
+ DECODE_LLD_EVENT(status->t.usta.alarm.event), status->t.usta.alarm.event,
+ DECODE_LLD_CAUSE(status->t.usta.alarm.cause), status->t.usta.alarm.cause);
+
switch (status->t.usta.alarm.event) {
case ENTR_CONG: /* Entering Congestion */
ftdm_log(FTDM_LOG_WARNING, "s%d: Entering Congestion\n", ftdmspan->span_id);
@@ -779,7 +779,6 @@ void sngisdn_rcv_cc_ind(CcMngmt *status)
void sngisdn_rcv_q931_trace(InMngmt *trc, Buffer *mBuf)
{
MsgLen mlen;
- MsgLen i;
int16_t j;
Buffer *tmp;
Data *cptr;
@@ -802,7 +801,6 @@ void sngisdn_rcv_q931_trace(InMngmt *trc, Buffer *mBuf)
tmp = mBuf->b_cont;
cptr = tmp->b_rptr;
data = *cptr++;
- i = 0;
for(j=0;jftdm_val == ftdm_val) {
+ return val->trillium_val;
+ }
+ }
+ return default_val;
+}
+
+static uint8_t get_ftdm_val(ftdm2trillium_t *vals, uint8_t trillium_val, uint8_t default_val)
+{
+ ftdm2trillium_t *val = vals;
+ while(val++) {
+ if (val->trillium_val == trillium_val) {
+ return val->ftdm_val;
+ }
+ }
+ return default_val;
+}
+
+
void clear_call_data(sngisdn_chan_data_t *sngisdn_info)
{
uint32_t cc_id = ((sngisdn_span_data_t*)sngisdn_info->ftdmchan->span->signal_data)->cc_id;
@@ -259,11 +303,11 @@ ftdm_status_t get_called_num(ftdm_channel_t *ftdmchan, CdPtyNmb *cdPtyNmb)
}
if (cdPtyNmb->nmbPlanId.pres == PRSNT_NODEF) {
- caller_data->dnis.plan = cdPtyNmb->nmbPlanId.val;
+ caller_data->dnis.plan = get_ftdm_val(npi_codes, cdPtyNmb->nmbPlanId.val, IN_NP_UNK);
}
if (cdPtyNmb->typeNmb0.pres == PRSNT_NODEF) {
- caller_data->dnis.type = cdPtyNmb->typeNmb0.val;
+ caller_data->dnis.type = get_ftdm_val(ton_codes, cdPtyNmb->typeNmb0.val, IN_TON_UNK);
}
if (cdPtyNmb->nmbDigits.pres == PRSNT_NODEF) {
@@ -283,11 +327,11 @@ ftdm_status_t get_redir_num(ftdm_channel_t *ftdmchan, RedirNmb *redirNmb)
}
if (redirNmb->nmbPlanId.pres == PRSNT_NODEF) {
- caller_data->rdnis.plan = redirNmb->nmbPlanId.val;
+ caller_data->rdnis.plan = get_ftdm_val(npi_codes, redirNmb->nmbPlanId.val, IN_NP_UNK);
}
if (redirNmb->typeNmb.pres == PRSNT_NODEF) {
- caller_data->rdnis.type = redirNmb->typeNmb.val;
+ caller_data->rdnis.type = get_ftdm_val(ton_codes, redirNmb->typeNmb.val, IN_TON_UNK);
}
if (redirNmb->nmbDigits.pres == PRSNT_NODEF) {
@@ -370,7 +414,7 @@ ftdm_status_t get_facility_ie_str(ftdm_channel_t *ftdmchan, uint8_t *data, uint8
my_data[1] = data_len;
memcpy(&my_data[2], data, data_len);
- sngisdn_add_raw_data((sngisdn_chan_data_t*)ftdmchan->call_data, data, data_len+2);
+ sngisdn_add_raw_data((sngisdn_chan_data_t*)ftdmchan->call_data, my_data, data_len+2);
ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Raw Facility IE copied available\n");
} else {
@@ -382,11 +426,13 @@ ftdm_status_t get_facility_ie_str(ftdm_channel_t *ftdmchan, uint8_t *data, uint8
ftdm_status_t get_prog_ind_ie(ftdm_channel_t *ftdmchan, ProgInd *progInd)
{
uint8_t val;
+
if (!progInd->eh.pres) {
return FTDM_FAIL;
}
if (progInd->progDesc.pres) {
+ /* TODO: use get_ftdm_val function and table here */
switch (progInd->progDesc.val) {
case IN_PD_NOTETEISDN:
val = SNGISDN_PROGIND_DESCR_NETE_ISDN;
@@ -464,19 +510,11 @@ ftdm_status_t set_calling_num(ftdm_channel_t *ftdmchan, CgPtyNmb *cgPtyNmb)
cgPtyNmb->presInd0.val = caller_data->pres;
cgPtyNmb->nmbPlanId.pres = PRSNT_NODEF;
- if (caller_data->cid_num.plan >= FTDM_NPI_INVALID) {
- cgPtyNmb->nmbPlanId.val = FTDM_NPI_UNKNOWN;
- } else {
- cgPtyNmb->nmbPlanId.val = caller_data->cid_num.plan;
- }
+ cgPtyNmb->nmbPlanId.val = get_trillium_val(npi_codes, caller_data->cid_num.plan, IN_NP_UNK);
cgPtyNmb->typeNmb1.pres = PRSNT_NODEF;
- if (caller_data->cid_num.type >= FTDM_TON_INVALID) {
- cgPtyNmb->typeNmb1.val = FTDM_TON_UNKNOWN;
- } else {
- cgPtyNmb->typeNmb1.val = caller_data->cid_num.type;
- }
+ cgPtyNmb->typeNmb1.val = get_trillium_val(ton_codes, caller_data->cid_num.type, IN_TON_UNK);
cgPtyNmb->nmbDigits.pres = PRSNT_NODEF;
cgPtyNmb->nmbDigits.len = len;
@@ -510,7 +548,7 @@ ftdm_status_t set_calling_num2(ftdm_channel_t *ftdmchan, CgPtyNmb *cgPtyNmb)
val = FTDM_SCREENING_INVALID;
string = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "isdn.cg_pty2.screening_ind");
- if ((string != NULL) && (*string)) {
+ if (!ftdm_strlen_zero(string)) {
val = ftdm_str2ftdm_screening(string);
}
@@ -527,7 +565,7 @@ ftdm_status_t set_calling_num2(ftdm_channel_t *ftdmchan, CgPtyNmb *cgPtyNmb)
val = FTDM_PRES_INVALID;
string = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "isdn.cg_pty2.presentation_ind");
- if ((string != NULL) && (*string)) {
+ if (!ftdm_strlen_zero(string)) {
val = ftdm_str2ftdm_presentation(string);
}
@@ -542,14 +580,14 @@ ftdm_status_t set_calling_num2(ftdm_channel_t *ftdmchan, CgPtyNmb *cgPtyNmb)
val = FTDM_NPI_INVALID;
string = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "isdn.cg_pty2.npi");
- if ((string != NULL) && (*string)) {
+ if (!ftdm_strlen_zero(string)) {
val = ftdm_str2ftdm_npi(string);
}
if (val == FTDM_NPI_INVALID) {
cgPtyNmb->nmbPlanId.val = caller_data->cid_num.plan;
} else {
- cgPtyNmb->nmbPlanId.val = val;
+ cgPtyNmb->nmbPlanId.val = get_trillium_val(npi_codes, val, IN_NP_UNK);
}
cgPtyNmb->typeNmb1.pres = PRSNT_NODEF;
@@ -557,14 +595,14 @@ ftdm_status_t set_calling_num2(ftdm_channel_t *ftdmchan, CgPtyNmb *cgPtyNmb)
/* Type of Number */
val = FTDM_TON_INVALID;
string = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "isdn.cg_pty2.ton");
- if ((string != NULL) && (*string)) {
+ if (!ftdm_strlen_zero(string)) {
val = ftdm_str2ftdm_ton(string);
}
if (val == FTDM_TON_INVALID) {
cgPtyNmb->typeNmb1.val = caller_data->cid_num.type;
} else {
- cgPtyNmb->typeNmb1.val = val;
+ cgPtyNmb->typeNmb1.val = get_trillium_val(ton_codes, val, IN_TON_UNK);
}
return FTDM_SUCCESS;
}
@@ -577,21 +615,14 @@ ftdm_status_t set_called_num(ftdm_channel_t *ftdmchan, CdPtyNmb *cdPtyNmb)
if (!len) {
return FTDM_SUCCESS;
}
- cdPtyNmb->eh.pres = PRSNT_NODEF;
-
- cdPtyNmb->nmbPlanId.pres = PRSNT_NODEF;
- if (caller_data->dnis.plan >= FTDM_NPI_INVALID) {
- cdPtyNmb->nmbPlanId.val = FTDM_NPI_UNKNOWN;
- } else {
- cdPtyNmb->nmbPlanId.val = caller_data->dnis.plan;
- }
- cdPtyNmb->typeNmb0.pres = PRSNT_NODEF;
- if (caller_data->dnis.type >= FTDM_TON_INVALID) {
- cdPtyNmb->typeNmb0.val = FTDM_TON_UNKNOWN;
- } else {
- cdPtyNmb->typeNmb0.val = caller_data->dnis.type;
- }
+ cdPtyNmb->eh.pres = PRSNT_NODEF;
+
+ cdPtyNmb->nmbPlanId.pres = PRSNT_NODEF;
+ cdPtyNmb->nmbPlanId.val = get_trillium_val(npi_codes, caller_data->dnis.plan, IN_NP_UNK);
+
+ cdPtyNmb->typeNmb0.pres = PRSNT_NODEF;
+ cdPtyNmb->typeNmb0.val = get_trillium_val(ton_codes, caller_data->dnis.type, IN_TON_UNK);
cdPtyNmb->nmbDigits.pres = PRSNT_NODEF;
cdPtyNmb->nmbDigits.len = len;
@@ -612,18 +643,10 @@ ftdm_status_t set_redir_num(ftdm_channel_t *ftdmchan, RedirNmb *redirNmb)
redirNmb->eh.pres = PRSNT_NODEF;
redirNmb->nmbPlanId.pres = PRSNT_NODEF;
- if (caller_data->rdnis.plan >= FTDM_NPI_INVALID) {
- redirNmb->nmbPlanId.val = FTDM_NPI_UNKNOWN;
- } else {
- redirNmb->nmbPlanId.val = caller_data->rdnis.plan;
- }
+ redirNmb->nmbPlanId.val = get_trillium_val(npi_codes, caller_data->rdnis.plan, IN_NP_UNK);
redirNmb->typeNmb.pres = PRSNT_NODEF;
- if (caller_data->rdnis.type >= FTDM_TON_INVALID) {
- redirNmb->typeNmb.val = FTDM_TON_UNKNOWN;
- } else {
- redirNmb->typeNmb.val = caller_data->rdnis.type;
- }
+ redirNmb->typeNmb.val = get_trillium_val(ton_codes, caller_data->rdnis.type, IN_TON_UNK);
redirNmb->nmbDigits.pres = PRSNT_NODEF;
redirNmb->nmbDigits.len = len;
@@ -743,7 +766,7 @@ ftdm_status_t set_prog_ind_ie(ftdm_channel_t *ftdmchan, ProgInd *progInd, ftdm_s
int loc = prog_ind.loc;
str = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "isdn.prog_ind.descr");
- if (str && *str) {
+ if (!ftdm_strlen_zero(str)) {
/* User wants to override progress indicator */
descr = ftdm_str2ftdm_sngisdn_progind_descr(str);
}
@@ -754,7 +777,7 @@ ftdm_status_t set_prog_ind_ie(ftdm_channel_t *ftdmchan, ProgInd *progInd, ftdm_s
}
str = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "isdn.prog_ind.loc");
- if (str && *str) {
+ if (!ftdm_strlen_zero(str)) {
loc = ftdm_str2ftdm_sngisdn_progind_loc(str);
}
if (loc == SNGISDN_PROGIND_LOC_INVALID) {
@@ -830,10 +853,6 @@ ftdm_status_t set_chan_id_ie(ftdm_channel_t *ftdmchan, ChanId *chanId)
return FTDM_SUCCESS;
}
- if (ftdm_test_flag(sngisdn_info, FLAG_SENT_CHAN_ID)) {
- /* Indicate channel ID only in first response */
- return FTDM_SUCCESS;
- }
ftdm_set_flag(sngisdn_info, FLAG_SENT_CHAN_ID);
chanId->eh.pres = PRSNT_NODEF;
@@ -1073,18 +1092,20 @@ void get_memory_info(void)
return;
}
+
uint8_t sngisdn_get_infoTranCap_from_user(ftdm_bearer_cap_t bearer_capability)
{
switch(bearer_capability) {
case FTDM_BEARER_CAP_SPEECH:
return IN_ITC_SPEECH;
- case FTDM_BEARER_CAP_64K_UNRESTRICTED:
+ case FTDM_BEARER_CAP_UNRESTRICTED:
return IN_ITC_UNRDIG;
case FTDM_BEARER_CAP_3_1KHZ_AUDIO:
return IN_ITC_A31KHZ;
case FTDM_BEARER_CAP_INVALID:
return IN_ITC_SPEECH;
- /* Do not put a default case here, so we can see compile warnings if we have unhandled cases */
+ default:
+ return IN_ITC_SPEECH;
}
return FTDM_BEARER_CAP_SPEECH;
}
@@ -1100,7 +1121,8 @@ uint8_t sngisdn_get_usrInfoLyr1Prot_from_user(ftdm_user_layer1_prot_t layer1_pro
return IN_UIL1_G711ALAW;
case FTDM_USER_LAYER1_PROT_INVALID:
return IN_UIL1_G711ULAW;
- /* Do not put a default case here, so we can see compile warnings if we have unhandled cases */
+ default:
+ return IN_UIL1_G711ULAW;
}
return IN_UIL1_G711ULAW;
}
@@ -1109,9 +1131,9 @@ ftdm_bearer_cap_t sngisdn_get_infoTranCap_from_stack(uint8_t bearer_capability)
{
switch(bearer_capability) {
case IN_ITC_SPEECH:
- return FTDM_BEARER_CAP_SPEECH;
+ return FTDM_BEARER_CAP_SPEECH;
case IN_ITC_UNRDIG:
- return FTDM_BEARER_CAP_64K_UNRESTRICTED;
+ return FTDM_BEARER_CAP_UNRESTRICTED;
case IN_ITC_A31KHZ:
return FTDM_BEARER_CAP_3_1KHZ_AUDIO;
default:
@@ -1135,7 +1157,7 @@ ftdm_user_layer1_prot_t sngisdn_get_usrInfoLyr1Prot_from_stack(uint8_t layer1_pr
return FTDM_USER_LAYER1_PROT_ULAW;
}
-void sngisdn_print_phy_stats(ftdm_stream_handle_t *stream, ftdm_span_t *span)
+ftdm_status_t sngisdn_show_l1_stats(ftdm_stream_handle_t *stream, ftdm_span_t *span)
{
L1Mngmt sts;
sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)span->signal_data;
@@ -1173,11 +1195,11 @@ void sngisdn_print_phy_stats(ftdm_stream_handle_t *stream, ftdm_span_t *span)
stream->write_function(stream, " TX Errors Details");
stream->write_function(stream, "\n---------------------------------------------------------------------\n");
stream->write_function(stream, "Aborted:\t%u\tFifo:\t\t%u\tCarrier:\t%u\n", sts.t.sts.tx_aborted_errors, sts.t.sts.tx_fifo_errors, sts.t.sts.tx_carrier_errors);
- return;
+ return FTDM_SUCCESS;
}
-void sngisdn_print_span(ftdm_stream_handle_t *stream, ftdm_span_t *span)
+ftdm_status_t sngisdn_show_span(ftdm_stream_handle_t *stream, ftdm_span_t *span)
{
ftdm_signaling_status_t sigstatus;
ftdm_alarm_flag_t alarmbits;
@@ -1192,18 +1214,18 @@ void sngisdn_print_span(ftdm_stream_handle_t *stream, ftdm_span_t *span)
stream->write_function(stream, "span:%s physical:%s signalling:%s\n",
span->name, alarmbits ? "ALARMED" : "OK",
ftdm_signaling_status2str(sigstatus));
- return;
+ return FTDM_SUCCESS;
}
-void sngisdn_print_spans(ftdm_stream_handle_t *stream)
+ftdm_status_t sngisdn_show_spans(ftdm_stream_handle_t *stream)
{
int i;
for(i=1;i<=MAX_L1_LINKS;i++) {
if (g_sngisdn_data.spans[i]) {
- sngisdn_print_span(stream, g_sngisdn_data.spans[i]->ftdm_span);
+ sngisdn_show_span(stream, g_sngisdn_data.spans[i]->ftdm_span);
}
}
- return;
+ return FTDM_SUCCESS;
}
ftdm_status_t sngisdn_add_var(sngisdn_chan_data_t *sngisdn_info, const char* var, const char* val)
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_trace.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_trace.c
index 8c8c8d5159..d455fc06d0 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_trace.c
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_trace.c
@@ -334,11 +334,12 @@ uint32_t sngisdn_decode_ie(char *str, uint32_t *str_len, uint8_t current_codeset
switch(ieId) {
case PROT_Q931_IE_BEARER_CAP:
{
- uint8_t codingStandard, infTransferCap, transferMode, infTransferRate, usrL1Prot;
+ uint8_t codingStandard, infTransferCap, infTransferRate, usrL1Prot;
+ /*uint8_t transferMode;*/
codingStandard = get_bits(OCTET(3),6,7);
infTransferCap = get_bits(OCTET(3),1,5);
- transferMode = get_bits(OCTET(4),6,7);
+ /*transferMode = get_bits(OCTET(4),6,7);*/
infTransferRate = get_bits(OCTET(4),1,5);
usrL1Prot = get_bits(OCTET(5),1,5);
@@ -404,8 +405,9 @@ uint32_t sngisdn_decode_ie(char *str, uint32_t *str_len, uint8_t current_codeset
uint8_t infoChannelSelection=0;
uint8_t prefExclusive=0;
uint8_t ifaceIdPresent=0;
- uint8_t ifaceIdentifier = 0; /* octet_3_1 */
- uint8_t chanType=0, numberMap=0, codingStandard=0;
+ /* uint8_t ifaceIdentifier = 0; */ /* octet_3_1 */
+ uint8_t chanType=0, numberMap=0;
+ /* uint8_t codingStandard=0; */
uint8_t channelNo = 0;
infoChannelSelection = get_bits(OCTET(3),1,2);
@@ -413,15 +415,15 @@ uint32_t sngisdn_decode_ie(char *str, uint32_t *str_len, uint8_t current_codeset
ifaceIdPresent = get_bits(OCTET(3),7,7);
if (ifaceIdPresent) {
- ifaceIdentifier= get_bits(OCTET(4),1,7);
+ /*ifaceIdentifier= get_bits(OCTET(4),1,7);*/
chanType = get_bits(OCTET(5),1,4);
numberMap = get_bits(OCTET(5),5,5);
- codingStandard = get_bits(OCTET(5),6,7);
+ /*codingStandard = get_bits(OCTET(5),6,7);*/
channelNo = get_bits(OCTET(6),1,7);
} else {
chanType = get_bits(OCTET(4),1,4);
numberMap = get_bits(OCTET(4),5,5);
- codingStandard = get_bits(OCTET(4),6,7);
+ /*codingStandard = get_bits(OCTET(4),6,7);*/
channelNo = get_bits(OCTET(5),1,7);
}
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c
index df0414a7f5..34d79837f0 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c
@@ -207,9 +207,10 @@ int ft_to_sngss7_cfg_all(void)
/* go through all the relays channels and configure it */
x = 1;
- while (g_ftdm_sngss7_data.cfg.relay[x].id != 0) {
+ while (x < (MAX_RELAY_CHANNELS)) {
/* check if this relay channel has been configured already */
- if (!(g_ftdm_sngss7_data.cfg.relay[x].flags & SNGSS7_CONFIGURED)) {
+ if ((g_ftdm_sngss7_data.cfg.relay[x].id != 0) &&
+ (!(g_ftdm_sngss7_data.cfg.relay[x].flags & SNGSS7_CONFIGURED))) {
/* send the specific configuration */
if (ftmod_ss7_relay_chan_config(x)) {
@@ -223,13 +224,13 @@ int ft_to_sngss7_cfg_all(void)
g_ftdm_sngss7_data.cfg.relay[x].flags |= SNGSS7_CONFIGURED;
} /* if !SNGSS7_CONFIGURED */
x++;
- } /* while (g_ftdm_sngss7_data.cfg.relay[x].id != 0) */
+ } /* while (x < (MAX_RELAY_CHANNELS)) */
x = 1;
- while (x < (MAX_MTP_LINKS + 1)) {
+ while (x < (MAX_MTP_LINKS)) {
/* check if this link has been configured already */
- if (!(g_ftdm_sngss7_data.cfg.mtp1Link[x].flags & SNGSS7_CONFIGURED) &&
- (g_ftdm_sngss7_data.cfg.mtp1Link[x].id != 0)) {
+ if ((g_ftdm_sngss7_data.cfg.mtp1Link[x].id != 0) &&
+ (!(g_ftdm_sngss7_data.cfg.mtp1Link[x].flags & SNGSS7_CONFIGURED))) {
/* configure mtp1 */
if (ftmod_ss7_mtp1_psap_config(x)) {
@@ -243,13 +244,13 @@ int ft_to_sngss7_cfg_all(void)
g_ftdm_sngss7_data.cfg.mtp1Link[x].flags |= SNGSS7_CONFIGURED;
}
x++;
- } /* while (g_ftdm_sngss7_data.cfg.mtp1Link[x].id != 0) */
+ } /* while (x < (MAX_MTP_LINKS+1)) */
x = 1;
- while (x < (MAX_MTP_LINKS + 1)) {
+ while (x < (MAX_MTP_LINKS)) {
/* check if this link has been configured already */
- if (!(g_ftdm_sngss7_data.cfg.mtp2Link[x].flags & SNGSS7_CONFIGURED) &&
- (g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0)) {
+ if ((g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) &&
+ (!(g_ftdm_sngss7_data.cfg.mtp2Link[x].flags & SNGSS7_CONFIGURED))) {
/* configure mtp2 */
if (ftmod_ss7_mtp2_dlsap_config(x)) {
@@ -263,13 +264,13 @@ int ft_to_sngss7_cfg_all(void)
g_ftdm_sngss7_data.cfg.mtp2Link[x].flags |= SNGSS7_CONFIGURED;
}
x++;
- } /* while (g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) */
+ } /* while (x < (MAX_MTP_LINKS+1)) */
x = 1;
- while (x < (MAX_MTP_LINKS + 1)) {
+ while (x < (MAX_MTP_LINKS)) {
/* check if this link has been configured already */
- if (!(g_ftdm_sngss7_data.cfg.mtp3Link[x].flags & SNGSS7_CONFIGURED) &&
- (g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0)) {
+ if ((g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) &&
+ (!(g_ftdm_sngss7_data.cfg.mtp3Link[x].flags & SNGSS7_CONFIGURED))) {
/* configure mtp3 */
if (ftmod_ss7_mtp3_dlsap_config(x)) {
@@ -284,12 +285,13 @@ int ft_to_sngss7_cfg_all(void)
}
x++;
- } /* while (g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) */
+ } /* while (x < (MAX_MTP_LINKS+1)) */
x = 1;
- while (g_ftdm_sngss7_data.cfg.nsap[x].id != 0) {
+ while (x < (MAX_NSAPS)) {
/* check if this link has been configured already */
- if (!(g_ftdm_sngss7_data.cfg.nsap[x].flags & SNGSS7_CONFIGURED)) {
+ if ((g_ftdm_sngss7_data.cfg.nsap[x].id != 0) &&
+ (!(g_ftdm_sngss7_data.cfg.nsap[x].flags & SNGSS7_CONFIGURED))) {
ret = ftmod_ss7_mtp3_nsap_config(x);
if (ret) {
@@ -312,12 +314,13 @@ int ft_to_sngss7_cfg_all(void)
} /* if !SNGSS7_CONFIGURED */
x++;
- } /* while (g_ftdm_sngss7_data.cfg.nsap[x].id != 0) */
+ } /* while (x < (MAX_NSAPS)) */
x = 1;
- while (g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) {
+ while (x < (MAX_MTP_LINKSETS+1)) {
/* check if this link has been configured already */
- if (!(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].flags & SNGSS7_CONFIGURED)) {
+ if ((g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) &&
+ (!(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].flags & SNGSS7_CONFIGURED))) {
if (ftmod_ss7_mtp3_linkset_config(x)) {
SS7_CRITICAL("MTP3 LINKSET %d configuration FAILED!\n", x);
@@ -331,12 +334,13 @@ int ft_to_sngss7_cfg_all(void)
} /* if !SNGSS7_CONFIGURED */
x++;
- } /* while (g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) */
+ } /* while (x < (MAX_MTP_LINKSETS+1)) */
x = 1;
- while ((g_ftdm_sngss7_data.cfg.mtpRoute[x].id != 0)) {
+ while (x < (MAX_MTP_ROUTES+1)) {
/* check if this link has been configured already */
- if (!(g_ftdm_sngss7_data.cfg.mtpRoute[x].flags & SNGSS7_CONFIGURED)) {
+ if ((g_ftdm_sngss7_data.cfg.mtpRoute[x].id != 0) &&
+ (!(g_ftdm_sngss7_data.cfg.mtpRoute[x].flags & SNGSS7_CONFIGURED))) {
if (ftmod_ss7_mtp3_route_config(x)) {
SS7_CRITICAL("MTP3 ROUTE %d configuration FAILED!\n", x);
@@ -350,12 +354,13 @@ int ft_to_sngss7_cfg_all(void)
} /* if !SNGSS7_CONFIGURED */
x++;
- } /* while (g_ftdm_sngss7_data.cfg.mtpRoute[x].id != 0) */
+ } /* while (x < (MAX_MTP_ROUTES+1)) */
x = 1;
- while (g_ftdm_sngss7_data.cfg.isap[x].id != 0) {
+ while (x < (MAX_ISAPS)) {
/* check if this link has been configured already */
- if (!(g_ftdm_sngss7_data.cfg.isap[x].flags & SNGSS7_CONFIGURED)) {
+ if ((g_ftdm_sngss7_data.cfg.isap[x].id != 0) &&
+ (!(g_ftdm_sngss7_data.cfg.isap[x].flags & SNGSS7_CONFIGURED))) {
if (ftmod_ss7_isup_isap_config(x)) {
SS7_CRITICAL("ISUP ISAP %d configuration FAILED!\n", x);
@@ -369,13 +374,14 @@ int ft_to_sngss7_cfg_all(void)
} /* if !SNGSS7_CONFIGURED */
x++;
- } /* while (g_ftdm_sngss7_data.cfg.isap[x].id != 0) */
+ } /* while (x < (MAX_ISAPS)) */
if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_ISUP)) {
x = 1;
- while (g_ftdm_sngss7_data.cfg.isupIntf[x].id != 0) {
+ while (x < (MAX_ISUP_INFS)) {
/* check if this link has been configured already */
- if (!(g_ftdm_sngss7_data.cfg.isupIntf[x].flags & SNGSS7_CONFIGURED)) {
+ if ((g_ftdm_sngss7_data.cfg.isupIntf[x].id != 0) &&
+ (!(g_ftdm_sngss7_data.cfg.isupIntf[x].flags & SNGSS7_CONFIGURED))) {
if (ftmod_ss7_isup_intf_config(x)) {
SS7_CRITICAL("ISUP INTF %d configuration FAILED!\n", x);
@@ -391,12 +397,14 @@ int ft_to_sngss7_cfg_all(void)
} /* if !SNGSS7_CONFIGURED */
x++;
- } /* while (g_ftdm_sngss7_data.cfg.isupIntf[x].id != 0) */
+ } /* while (x < (MAX_ISUP_INFS)) */
} /* if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_ISUP)) */
x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;
while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
- if ( g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) {
+ /* check if this link has been configured already */
+ if ((g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) &&
+ (!(g_ftdm_sngss7_data.cfg.isupCkt[x].flags & SNGSS7_CONFIGURED))) {
if (ftmod_ss7_isup_ckt_config(x)) {
SS7_CRITICAL("ISUP CKT %d configuration FAILED!\n", x);
@@ -405,10 +413,9 @@ int ft_to_sngss7_cfg_all(void)
SS7_INFO("ISUP CKT %d configuration DONE!\n", x);
}
- } /* if ( g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) */
-
- /* set the SNGSS7_CONFIGURED flag */
- g_ftdm_sngss7_data.cfg.isupCkt[x].flags |= SNGSS7_CONFIGURED;
+ /* set the SNGSS7_CONFIGURED flag */
+ g_ftdm_sngss7_data.cfg.isupCkt[x].flags |= SNGSS7_CONFIGURED;
+ } /* if !SNGSS7_CONFIGURED */
x++;
} /* while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) */
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c
index 2f56619863..1dd9717c9f 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c
@@ -724,6 +724,9 @@ static ftdm_status_t handle_print_usuage(ftdm_stream_handle_t *stream)
stream->write_function(stream, "ftdm ss7 lpo link X\n");
stream->write_function(stream, "ftdm ss7 lpr link X\n");
stream->write_function(stream, "\n");
+ stream->write_function(stream, "Ftmod_sangoma_ss7 Relay status:\n");
+ stream->write_function(stream, "ftdm ss7 show status relay X\n");
+ stream->write_function(stream, "\n");
return FTDM_SUCCESS;
}
@@ -967,12 +970,14 @@ static ftdm_status_t handle_show_inreset(ftdm_stream_handle_t *stream, int span,
/******************************************************************************/
static ftdm_status_t handle_show_flags(ftdm_stream_handle_t *stream, int span, int chan, int verbose)
{
- int x;
- int bit;
- sngss7_chan_data_t *ss7_info;
- ftdm_channel_t *ftdmchan;
- int lspan;
- int lchan;
+ sngss7_chan_data_t *ss7_info;
+ ftdm_channel_t *ftdmchan;
+ int x;
+ int bit;
+ int lspan;
+ int lchan;
+ const char *text;
+ int flag;
x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;
while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
@@ -1001,11 +1006,20 @@ static ftdm_status_t handle_show_flags(ftdm_stream_handle_t *stream, int span, i
ss7_info->circuit->cic);
for (bit = 0; bit < 33; bit++) {
- stream->write_function(stream, "|");
if (ss7_info->ckt_flags & ( 0x1 << bit)) {
- stream->write_function(stream, "%2d=1", bit);
- } else {
- stream->write_function(stream, "%2d=0", bit);
+ stream->write_function(stream, "|");
+ flag = bit;
+ text = ftmod_ss7_ckt_flag2str(flag);
+ stream->write_function(stream, "%s",text);
+ }
+ }
+
+ for (bit = 0; bit < 33; bit++) {
+ if (ss7_info->blk_flags & ( 0x1 << bit)) {
+ stream->write_function(stream, "|");
+ flag = bit;
+ text = ftmod_ss7_blk_flag2str(flag);
+ stream->write_function(stream, "%s",text);
}
}
@@ -1170,7 +1184,8 @@ static ftdm_status_t handle_show_status(ftdm_stream_handle_t *stream, int span,
ftdm_channel_state2str(ftdmchan->state));
if ((sngss7_test_ckt_blk_flag(ss7_info, FLAG_CKT_MN_BLOCK_TX)) ||
- (sngss7_test_ckt_blk_flag(ss7_info, FLAG_GRP_MN_BLOCK_TX))) {
+ (sngss7_test_ckt_blk_flag(ss7_info, FLAG_GRP_MN_BLOCK_TX)) ||
+ (sngss7_test_ckt_blk_flag(ss7_info, FLAG_CKT_LC_BLOCK_RX))) {
stream->write_function(stream, "l_mn=Y|");
}else {
stream->write_function(stream, "l_mn=N|");
@@ -1195,8 +1210,8 @@ static ftdm_status_t handle_show_status(ftdm_stream_handle_t *stream, int span,
stream->write_function(stream, "r_hw=N|");
}
- if (sngss7_test_ckt_flag(ss7_info, FLAG_RELAY_DOWN)) {
- stream->write_function(stream, "relay=Y");
+ if (sngss7_test_ckt_blk_flag(ss7_info, FLAG_RELAY_DOWN)) {
+ stream->write_function(stream, "relay=Y|");
}else {
stream->write_function(stream, "relay=N");
}
@@ -1354,7 +1369,7 @@ static ftdm_status_t handle_status_mtp3link(ftdm_stream_handle_t *stream, char *
/* find the link request by it's name */
x = 1;
- while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {
+ while(x < (MAX_MTP_LINKS+1)) {
if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) {
/* send the status request */
@@ -1380,7 +1395,7 @@ static ftdm_status_t handle_status_mtp3link(ftdm_stream_handle_t *stream, char *
/* move to the next link */
x++;
- } /* while (id != 0) */
+ } /* while (x < (MAX_MTP_LINKS+1)) */
stream->write_function(stream, "Failed to find link=\"%s\"\n", name);
@@ -1396,7 +1411,7 @@ static ftdm_status_t handle_status_mtp2link(ftdm_stream_handle_t *stream, char *
/* find the link request by it's name */
x = 1;
- while(g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) {
+ while(x < (MAX_MTP_LINKS+1)) {
if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp2Link[x].name, name)) {
/* send the status request */
@@ -1424,7 +1439,7 @@ static ftdm_status_t handle_status_mtp2link(ftdm_stream_handle_t *stream, char *
/* move to the next link */
x++;
- } /* while (id != 0) */
+ } /* while (x < (MAX_MTP_LINKS+1)) */
stream->write_function(stream, "Failed to find link=\"%s\"\n", name);
@@ -1440,7 +1455,7 @@ static ftdm_status_t handle_status_linkset(ftdm_stream_handle_t *stream, char *n
/* find the linkset request by it's name */
x = 1;
- while(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) {
+ while(x < (MAX_MTP_LINKSETS+1)) {
if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name, name)) {
/* send the status request */
@@ -1475,7 +1490,7 @@ static ftdm_status_t handle_set_inhibit(ftdm_stream_handle_t *stream, char *name
/* find the link request by it's name */
x = 1;
- while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {
+ while(x < (MAX_MTP_LINKS+1)) {
if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) {
/* send the inhibit request */
@@ -1492,7 +1507,7 @@ static ftdm_status_t handle_set_inhibit(ftdm_stream_handle_t *stream, char *name
/* move to the next linkset */
x++;
- } /* while (id != 0) */
+ } /* while (x < (MAX_MTP_LINKS+1)) */
stream->write_function(stream, "Failed to find link=\"%s\"\n", name);
@@ -1507,7 +1522,7 @@ static ftdm_status_t handle_set_uninhibit(ftdm_stream_handle_t *stream, char *na
/* find the link request by it's name */
x = 1;
- while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {
+ while(x < (MAX_MTP_LINKS+1)) {
if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) {
/* send the uninhibit request */
@@ -1524,7 +1539,7 @@ static ftdm_status_t handle_set_uninhibit(ftdm_stream_handle_t *stream, char *na
/* move to the next linkset */
x++;
- } /* while (id != 0) */
+ } /* while (x < (MAX_MTP_LINKS+1)) */
stream->write_function(stream, "Failed to find link=\"%s\"\n", name);
@@ -1879,7 +1894,7 @@ static ftdm_status_t handle_bind_link(ftdm_stream_handle_t *stream, char *name)
/* find the link request by it's name */
x = 1;
- while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {
+ while(x < (MAX_MTP_LINKS+1)) {
if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) {
/* send the uninhibit request */
@@ -1895,7 +1910,7 @@ static ftdm_status_t handle_bind_link(ftdm_stream_handle_t *stream, char *name)
/* move to the next link */
x++;
- } /* while (id != 0) */
+ } /* while (x < (MAX_MTP_LINKS+1)) */
stream->write_function(stream, "Could not find link=%s\n", name);
@@ -1910,7 +1925,7 @@ static ftdm_status_t handle_unbind_link(ftdm_stream_handle_t *stream, char *name
/* find the link request by it's name */
x = 1;
- while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {
+ while(x < (MAX_MTP_LINKS+1)) {
if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) {
/* send the uninhibit request */
@@ -1926,7 +1941,7 @@ static ftdm_status_t handle_unbind_link(ftdm_stream_handle_t *stream, char *name
/* move to the next link */
x++;
- } /* while (id != 0) */
+ } /* while (x < (MAX_MTP_LINKS+1)) */
stream->write_function(stream, "Could not find link=%s\n", name);
@@ -1941,7 +1956,7 @@ static ftdm_status_t handle_activate_link(ftdm_stream_handle_t *stream, char *na
/* find the link request by it's name */
x = 1;
- while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {
+ while(x < (MAX_MTP_LINKS+1)) {
if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) {
/* send the uninhibit request */
@@ -1957,7 +1972,7 @@ static ftdm_status_t handle_activate_link(ftdm_stream_handle_t *stream, char *na
/* move to the next link */
x++;
- } /* while (id != 0) */
+ } /* while (x < (MAX_MTP_LINKS+1)) */
stream->write_function(stream, "Could not find link=%s\n", name);
@@ -1972,7 +1987,7 @@ static ftdm_status_t handle_deactivate_link(ftdm_stream_handle_t *stream, char *
/* find the link request by it's name */
x = 1;
- while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {
+ while(x < (MAX_MTP_LINKS+1)) {
if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) {
/* send the deactivate request */
@@ -1988,7 +2003,7 @@ static ftdm_status_t handle_deactivate_link(ftdm_stream_handle_t *stream, char *
/* move to the next link */
x++;
- } /* while (id != 0) */
+ } /* while (x < (MAX_MTP_LINKS+1)) */
stream->write_function(stream, "Could not find link=%s\n", name);
@@ -2003,7 +2018,7 @@ static ftdm_status_t handle_activate_linkset(ftdm_stream_handle_t *stream, char
/* find the linkset request by it's name */
x = 1;
- while(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) {
+ while(x < (MAX_MTP_LINKSETS+1)) {
if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name, name)) {
/* send the activate request */
@@ -2034,7 +2049,7 @@ static ftdm_status_t handle_deactivate_linkset(ftdm_stream_handle_t *stream, cha
/* find the linkset request by it's name */
x = 1;
- while(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) {
+ while(x < (MAX_MTP_LINKSETS+1)) {
if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name, name)) {
/* send the deactivate request */
@@ -2066,7 +2081,7 @@ static ftdm_status_t handle_tx_lpo(ftdm_stream_handle_t *stream, char *name)
/* find the link request by it's name */
x = 1;
- while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {
+ while(x < (MAX_MTP_LINKS+1)) {
if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) {
/* send the uninhibit request */
@@ -2082,7 +2097,7 @@ static ftdm_status_t handle_tx_lpo(ftdm_stream_handle_t *stream, char *name)
/* move to the next link */
x++;
- } /* while (id != 0) */
+ } /* while (x < (MAX_MTP_LINKS+1)) */
stream->write_function(stream, "Could not find link=%s\n", name);
@@ -2097,7 +2112,7 @@ static ftdm_status_t handle_tx_lpr(ftdm_stream_handle_t *stream, char *name)
/* find the link request by it's name */
x = 1;
- while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {
+ while(x < (MAX_MTP_LINKS+1)) {
if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) {
/* send the uninhibit request */
@@ -2113,7 +2128,7 @@ static ftdm_status_t handle_tx_lpr(ftdm_stream_handle_t *stream, char *name)
/* move to the next link */
x++;
- } /* while (id != 0) */
+ } /* while (x < (MAX_MTP_LINKS+1)) */
stream->write_function(stream, "Could not find link=%s\n", name);
@@ -2132,7 +2147,7 @@ static ftdm_status_t handle_status_relay(ftdm_stream_handle_t *stream, char *nam
/* find the channel request by it's name */
x = 1;
- while(g_ftdm_sngss7_data.cfg.relay[x].id != 0) {
+ while(x < (MAX_RELAY_CHANNELS)) {
if (!strcasecmp(g_ftdm_sngss7_data.cfg.relay[x].name, name)) {
if (ftmod_ss7_relay_status(g_ftdm_sngss7_data.cfg.relay[x].id, &sta)) {
@@ -2156,7 +2171,7 @@ static ftdm_status_t handle_status_relay(ftdm_stream_handle_t *stream, char *nam
/* move to the next link */
x++;
- } /* g_ftdm_sngss7_data.cfg.relay[x].id */
+ } /* x < (MAX_RELAY_CHANNELS) */
success:
return FTDM_SUCCESS;
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cntrl.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cntrl.c
index c1b18e529a..b0a2163fdd 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cntrl.c
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cntrl.c
@@ -68,11 +68,15 @@ int ftmod_ss7_shutdown_isup(void);
int ftmod_ss7_shutdown_mtp3(void);
int ftmod_ss7_shutdown_mtp2(void);
int ftmod_ss7_shutdown_relay(void);
+int ftmod_ss7_disable_relay_channel(uint32_t chanId);
int ftmod_ss7_disable_grp_mtp3Link(uint32_t procId);
int ftmod_ss7_enable_grp_mtp3Link(uint32_t procId);
int ftmod_ss7_disable_grp_mtp2Link(uint32_t procId);
+
+int ftmod_ss7_block_isup_ckt(uint32_t cktId);
+int ftmod_ss7_unblock_isup_ckt(uint32_t cktId);
/******************************************************************************/
/* FUNCTIONS ******************************************************************/
@@ -81,9 +85,10 @@ int ft_to_sngss7_activate_all(void)
int x;
x = 1;
- while (g_ftdm_sngss7_data.cfg.isap[x].id != 0) {
+ while (x < (MAX_ISAPS)) {
/* check if this link has already been actived */
- if (!(g_ftdm_sngss7_data.cfg.isap[x].flags & SNGSS7_ACTIVE)) {
+ if ((g_ftdm_sngss7_data.cfg.isap[x].id != 0) &&
+ (!(g_ftdm_sngss7_data.cfg.isap[x].flags & SNGSS7_ACTIVE))) {
if (ftmod_ss7_enable_isap(x)) {
SS7_CRITICAL("ISAP %d Enable: NOT OK\n", x);
@@ -97,12 +102,13 @@ int ft_to_sngss7_activate_all(void)
} /* if !SNGSS7_ACTIVE */
x++;
- } /* while (g_ftdm_sngss7_data.cfg.isap[x].id != 0) */
+ } /* while (x < (MAX_ISAPS)) */
x = 1;
- while (g_ftdm_sngss7_data.cfg.nsap[x].id != 0) {
+ while (x < (MAX_NSAPS)) {
/* check if this link has already been actived */
- if (!(g_ftdm_sngss7_data.cfg.nsap[x].flags & SNGSS7_ACTIVE)) {
+ if ((g_ftdm_sngss7_data.cfg.nsap[x].id != 0) &&
+ (!(g_ftdm_sngss7_data.cfg.nsap[x].flags & SNGSS7_ACTIVE))) {
if (ftmod_ss7_enable_nsap(x)) {
SS7_CRITICAL("NSAP %d Enable: NOT OK\n", x);
@@ -116,13 +122,14 @@ int ft_to_sngss7_activate_all(void)
} /* if !SNGSS7_ACTIVE */
x++;
- } /* while (g_ftdm_sngss7_data.cfg.nsap[x].id != 0) */
+ } /* while (x < (MAX_NSAPS)) */
if (g_ftdm_sngss7_data.cfg.mtpRoute[1].id != 0) {
x = 1;
- while (g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) {
+ while (x < (MAX_MTP_LINKSETS+1)) {
/* check if this link has already been actived */
- if (!(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].flags & SNGSS7_ACTIVE)) {
+ if ((g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) &&
+ (!(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].flags & SNGSS7_ACTIVE))) {
if (ftmod_ss7_enable_mtpLinkSet(x)) {
SS7_CRITICAL("LinkSet \"%s\" Enable: NOT OK\n", g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name);
@@ -136,7 +143,7 @@ int ft_to_sngss7_activate_all(void)
} /* if !SNGSS7_ACTIVE */
x++;
- } /* while (g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) */
+ } /* while (x < (MAX_MTP_LINKSETS+1)) */
}
return 0;
@@ -712,6 +719,38 @@ int ftmod_ss7_shutdown_relay(void)
return (sng_cntrl_relay(&pst, &cntrl));
}
+/******************************************************************************/
+int ftmod_ss7_disable_relay_channel(uint32_t chanId)
+{
+ RyMngmt cntrl;
+ Pst pst;
+
+ /* initalize the post structure */
+ smPstInit(&pst);
+
+ /* insert the destination Entity */
+ pst.dstEnt = ENTRY;
+
+ /* initalize the control structure */
+ memset(&cntrl, 0x0, sizeof(RyMngmt));
+
+ /* initalize the control header */
+ smHdrInit(&cntrl.hdr);
+
+ cntrl.hdr.msgType = TCNTRL; /* this is a control request */
+ cntrl.hdr.entId.ent = ENTRY;
+ cntrl.hdr.entId.inst = S_INST;
+ cntrl.hdr.elmId.elmnt = STGEN;
+
+
+ cntrl.hdr.elmId.elmntInst1 = chanId;
+
+ cntrl.t.cntrl.action = ADISIMM; /* Deactivate */
+ cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */
+
+ return (sng_cntrl_relay(&pst, &cntrl));
+}
+
/******************************************************************************/
int ftmod_ss7_disable_grp_mtp3Link(uint32_t procId)
{
@@ -808,6 +847,69 @@ int ftmod_ss7_disable_grp_mtp2Link(uint32_t procId)
}
+/******************************************************************************/
+int ftmod_ss7_block_isup_ckt(uint32_t cktId)
+{
+ SiMngmt cntrl;
+ Pst pst;
+
+ /* initalize the post structure */
+ smPstInit(&pst);
+
+ /* insert the destination Entity */
+ pst.dstEnt = ENTSI;
+
+ /* initalize the control structure */
+ memset(&cntrl, 0x0, sizeof(SiMngmt));
+
+ /* initalize the control header */
+ smHdrInit(&cntrl.hdr);
+
+ cntrl.hdr.msgType = TCNTRL; /* this is a control request */
+ cntrl.hdr.entId.ent = ENTSI;
+ cntrl.hdr.entId.inst = S_INST;
+ cntrl.hdr.elmId.elmnt = STICIR;
+
+ cntrl.t.cntrl.s.siElmnt.elmntId.circuit = cktId;
+ cntrl.t.cntrl.s.siElmnt.elmntParam.cir.flag = LSI_CNTRL_CIR_FORCE;
+
+ cntrl.t.cntrl.action = ADISIMM; /* block via BLO */
+ cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */
+
+ return (sng_cntrl_isup(&pst, &cntrl));
+}
+
+/******************************************************************************/
+int ftmod_ss7_unblock_isup_ckt(uint32_t cktId)
+{
+ SiMngmt cntrl;
+ Pst pst;
+
+ /* initalize the post structure */
+ smPstInit(&pst);
+
+ /* insert the destination Entity */
+ pst.dstEnt = ENTSI;
+
+ /* initalize the control structure */
+ memset(&cntrl, 0x0, sizeof(SiMngmt));
+
+ /* initalize the control header */
+ smHdrInit(&cntrl.hdr);
+
+ cntrl.hdr.msgType = TCNTRL; /* this is a control request */
+ cntrl.hdr.entId.ent = ENTSI;
+ cntrl.hdr.entId.inst = S_INST;
+ cntrl.hdr.elmId.elmnt = STICIR;
+
+ cntrl.t.cntrl.s.siElmnt.elmntId.circuit = cktId;
+ cntrl.t.cntrl.s.siElmnt.elmntParam.cir.flag = LSI_CNTRL_CIR_FORCE;
+
+ cntrl.t.cntrl.action = AENA; /* unblock via UBL */
+ cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */
+
+ return (sng_cntrl_isup(&pst, &cntrl));
+}
/******************************************************************************/
/* For Emacs:
* Local Variables:
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c
index 331312fafb..0520e9d163 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c
@@ -33,12 +33,14 @@
/* INCLUDE ********************************************************************/
#include "ftmod_sangoma_ss7_main.h"
+
/******************************************************************************/
/* DEFINES ********************************************************************/
/******************************************************************************/
/* GLOBALS ********************************************************************/
+
/******************************************************************************/
/* PROTOTYPES *****************************************************************/
@@ -79,14 +81,14 @@ ftdm_status_t handle_olm_msg(uint32_t suInstId, uint32_t spInstId, uint32_t circ
/******************************************************************************/
/* FUNCTIONS ******************************************************************/
+
ftdm_status_t handle_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiConEvnt *siConEvnt)
{
- SS7_FUNC_TRACE_ENTER(__FUNCTION__);
-
sngss7_chan_data_t *sngss7_info = NULL;
ftdm_channel_t *ftdmchan = NULL;
char nadi[2];
-
+
+ SS7_FUNC_TRACE_ENTER(__FUNCTION__);
memset(nadi, '\0', sizeof(nadi));
/* get the ftdmchan and ss7_chan_data from the circuit */
@@ -185,17 +187,11 @@ ftdm_status_t handle_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circ
SS7_INFO_CHAN(ftdmchan,"No Called party (DNIS) information in IAM!%s\n", " ");
}
- /* fill in rdnis information*/
- if (siConEvnt->redirgNum.eh.pres) {
- if (siConEvnt->redirgNum.addrSig.pres) {
- /* fill in the rdnis digits */
- copy_tknStr_from_sngss7(siConEvnt->redirgNum.addrSig,
- ftdmchan->caller_data.rdnis.digits,
- siConEvnt->cgPtyNum.oddEven);
- }
- } else {
- SS7_DEBUG_CHAN(ftdmchan,"No RDNIS party information in IAM!%s\n", " ");
- }
+ copy_redirgNum_from_sngss7(ftdmchan, &siConEvnt->redirgNum);
+
+ copy_genNmb_from_sngss7(ftdmchan, &siConEvnt->genNmb);
+
+ copy_cgPtyCat_from_sngss7(ftdmchan, &siConEvnt->cgPtyCat);
/* fill in the TMR/bearer capability */
if (siConEvnt->txMedReq.eh.pres) {
@@ -214,6 +210,10 @@ ftdm_status_t handle_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circ
sprintf(nadi, "%d", siConEvnt->cdPtyNum.natAddrInd.val);
sngss7_add_var(sngss7_info, "ss7_cld_nadi", nadi);
+ if (sngss7_info->circuit->transparent_iam) {
+ sngss7_save_iam(ftdmchan, siConEvnt);
+ }
+
/* check if a COT test is requested */
if ((siConEvnt->natConInd.eh.pres) &&
(siConEvnt->natConInd.contChkInd.pres) &&
@@ -237,7 +237,6 @@ ftdm_status_t handle_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circ
siConEvnt->cgPtyNum.natAddrInd.val,
ftdmchan->caller_data.dnis.digits,
siConEvnt->cdPtyNum.natAddrInd.val);
-
} /* if (channel is usable */
break;
@@ -490,6 +489,47 @@ ftdm_status_t handle_con_sta(uint32_t suInstId, uint32_t spInstId, uint32_t circ
case (SUBDIRNUM):
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx SUB-DIR\n", sngss7_info->circuit->cic);
break;
+#ifdef SANGOMA_SPIROU
+ case (CHARGE_ACK):
+ SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx TXA\n", sngss7_info->circuit->cic);
+ break;
+ case (CHARGE_UNIT):
+ {
+ uint32_t charging_unit = 0;
+ uint32_t msg_num = 0;
+ char val[3];
+
+ SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx ITX\n", sngss7_info->circuit->cic);
+
+ memset(val, '\0', sizeof(val));
+
+ if (siCnStEvnt->chargUnitNum.eh.pres == PRSNT_NODEF &&
+ siCnStEvnt->chargUnitNum.chargUnitNum.pres == PRSNT_NODEF) {
+
+ charging_unit = siCnStEvnt->chargUnitNum.chargUnitNum.val;
+ }
+
+ if (siCnStEvnt->msgNum.eh.pres == PRSNT_NODEF &&
+ siCnStEvnt->msgNum.msgNum.pres == PRSNT_NODEF) {
+
+ msg_num = siCnStEvnt->msgNum.msgNum.val;
+ }
+
+ ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Charging Unit:%d Msg Num:%d\n", charging_unit, msg_num);
+
+ sprintf(val, "%d", charging_unit);
+ sngss7_add_var(sngss7_info, "ss7_itx_charge_unit", val);
+
+ sprintf(val, "%d", msg_num);
+ sngss7_add_var(sngss7_info, "ss7_itx_msg_num", val);
+
+ if (sngss7_info->circuit->itx_auto_reply) {
+ ftdm_log_chan_msg(ftdmchan, FTDM_LOG_INFO, "Auto-reply with TXA msg\n");
+ ft_to_sngss7_txa (ftdmchan);
+ }
+ }
+ break;
+#endif
/**************************************************************************/
default:
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx Unknown Msg\n", sngss7_info->circuit->cic);
@@ -532,7 +572,7 @@ ftdm_status_t handle_con_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circ
/* go to UP */
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_UP);
-
+
break;
/**************************************************************************/
case FTDM_CHANNEL_STATE_DIALING:
@@ -609,6 +649,7 @@ ftdm_channel_command(ftdmchan, FTDM_COMMAND_DISABLE_LOOP, NULL);
break;
/**************************************************************************/
case FTDM_CHANNEL_STATE_RING:
+ case FTDM_CHANNEL_STATE_RINGING:
case FTDM_CHANNEL_STATE_PROGRESS:
case FTDM_CHANNEL_STATE_PROGRESS_MEDIA:
case FTDM_CHANNEL_STATE_UP:
@@ -881,232 +922,187 @@ ftdm_status_t handle_resm_ind(uint32_t suInstId, uint32_t spInstId, uint32_t cir
/******************************************************************************/
ftdm_status_t handle_sta_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt)
{
- sngss7_chan_data_t *sngss7_info ;
- ftdm_channel_t *ftdmchan;
+ SS7_FUNC_TRACE_ENTER(__FUNCTION__);
- /* get the ftdmchan and ss7_chan_data from the circuit */
- if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
- SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
- SS7_FUNC_TRACE_EXIT(__FUNCTION__);
+ /* confirm that the circuit is active on our side otherwise move to the next circuit */
+ if (!sngss7_test_flag(&g_ftdm_sngss7_data.cfg.isupCkt[circuit], SNGSS7_ACTIVE)) {
+ SS7_ERROR("[CIC:%d]Rx %s but circuit is not active yet, skipping!\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
return FTDM_FAIL;
}
- SS7_FUNC_TRACE_ENTER(__FUNCTION__);
-
switch (evntType) {
/**************************************************************************/
case SIT_STA_REATTEMPT: /* reattempt indication */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx Reattempt indication\n", sngss7_info->circuit->cic);
handle_reattempt(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt);
break;
/**************************************************************************/
case SIT_STA_ERRORIND: /* error indication */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx Error indication\n", sngss7_info->circuit->cic);
SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType));
break;
/**************************************************************************/
case SIT_STA_CONTCHK: /* continuity check */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx CCR start\n", sngss7_info->circuit->cic);
handle_cot_start(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt);
break;
/**************************************************************************/
case SIT_STA_CONTREP: /* continuity report */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx COT report\n", sngss7_info->circuit->cic);
handle_cot(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt);
break;
/**************************************************************************/
case SIT_STA_STPCONTIN: /* stop continuity */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx CCR stop\n", sngss7_info->circuit->cic);
handle_cot_stop(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt);
break;
/**************************************************************************/
case SIT_STA_CGQRYRSP: /* circuit grp query response from far end forwarded to upper layer by ISUP */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx CQM\n", sngss7_info->circuit->cic);
SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType));
break;
/**************************************************************************/
case SIT_STA_CONFUSION: /* confusion */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx CFN\n", sngss7_info->circuit->cic);
SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType));
break;
/**************************************************************************/
case SIT_STA_LOOPBACKACK: /* loop-back acknowledge */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx LPA\n", sngss7_info->circuit->cic);
SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType));
break;
/**************************************************************************/
case SIT_STA_CIRRSRVREQ: /* circuit reservation request */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx Ckt Resveration req\n", sngss7_info->circuit->cic);
SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType));
break;
/**************************************************************************/
case SIT_STA_CIRRSRVACK: /* circuit reservation acknowledgement */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx Ckt Res ack\n", sngss7_info->circuit->cic);
SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType));
break;
/**************************************************************************/
case SIT_STA_CIRBLOREQ: /* circuit blocking request */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx BLO\n", sngss7_info->circuit->cic);
handle_blo_req(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt);
break;
/**************************************************************************/
case SIT_STA_CIRBLORSP: /* circuit blocking response */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx BLA\n", sngss7_info->circuit->cic);
handle_blo_rsp(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt);
break;
/**************************************************************************/
case SIT_STA_CIRUBLREQ: /* circuit unblocking request */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx UBL\n", sngss7_info->circuit->cic);
handle_ubl_req(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt);
break;
/**************************************************************************/
case SIT_STA_CIRUBLRSP: /* circuit unblocking response */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx UBA\n", sngss7_info->circuit->cic);
handle_ubl_rsp(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt);
break;
/**************************************************************************/
case SIT_STA_CIRRESREQ: /* circuit reset request - RSC */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx RSC\n", sngss7_info->circuit->cic);
handle_rsc_req(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt);
break;
/**************************************************************************/
case SIT_STA_CIRLOCRES: /* reset initiated locally by the software */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx Local RSC\n", sngss7_info->circuit->cic);
handle_local_rsc_req(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt);
break;
/**************************************************************************/
case SIT_STA_CIRRESRSP: /* circuit reset response */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx RSC-RLC\n", sngss7_info->circuit->cic);
handle_rsc_rsp(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt);
break;
/**************************************************************************/
case SIT_STA_CGBREQ: /* CGB request */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx CGB\n", sngss7_info->circuit->cic);
handle_cgb_req(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt);
break;
/**************************************************************************/
case SIT_STA_CGUREQ: /* CGU request */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx CGU\n", sngss7_info->circuit->cic);
handle_cgu_req(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt);
break;
/**************************************************************************/
case SIT_STA_CGQRYREQ: /* circuit group query request */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx CQM\n", sngss7_info->circuit->cic);
SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType));
break;
/**************************************************************************/
case SIT_STA_CGBRSP: /* mntc. oriented CGB response */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx mntc CGB\n", sngss7_info->circuit->cic);
/*handle_cgb_req(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt);*/
break;
/**************************************************************************/
case SIT_STA_CGURSP: /* mntc. oriented CGU response */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx mntc CGU\n", sngss7_info->circuit->cic);
/*SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType));*/
break;
/**************************************************************************/
case SIT_STA_GRSREQ: /* circuit group reset request */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx GRS\n", sngss7_info->circuit->cic);
handle_grs_req(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt);
break;
/**************************************************************************/
case SIT_STA_CIRUNEQPD: /* circuit unequipped indication */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx UCIC\n", sngss7_info->circuit->cic);
handle_ucic(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt);
break;
/**************************************************************************/
case SIT_STA_GRSRSP: /* circuit group reset response */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx GRA\n", sngss7_info->circuit->cic);
handle_grs_rsp(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt);
break;
/**************************************************************************/
case SIT_STA_PAUSEIND: /* pause indication */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx SUS\n", sngss7_info->circuit->cic);
handle_pause(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt);
break;
/**************************************************************************/
case SIT_STA_RESUMEIND: /* resume indication */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx RES\n", sngss7_info->circuit->cic);
handle_resume(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt);
break;
/**************************************************************************/
case SIT_STA_USRPARTA: /* user part available */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx UPA\n", sngss7_info->circuit->cic);
SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType));
break;
/**************************************************************************/
case SIT_STA_RMTUSRUNAV: /* remote user not available */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx Remote User not Available\n", sngss7_info->circuit->cic);
SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType));
break;
/**************************************************************************/
case SIT_STA_MTPCONG0: /* congestion indication level 0 */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx Congestion L0\n", sngss7_info->circuit->cic);
SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType));
break;
/**************************************************************************/
case SIT_STA_MTPCONG1: /* congestion indication level 1 */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx Congestion L1\n", sngss7_info->circuit->cic);
SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType));
break;
/**************************************************************************/
case SIT_STA_MTPCONG2: /* congestion indication level 2 */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx Congestion L2\n", sngss7_info->circuit->cic);
SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType));
break;
/**************************************************************************/
case SIT_STA_MTPCONG3: /* congestion indication level 3 */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx Congestion L3\n", sngss7_info->circuit->cic);
SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType));
break;
/**************************************************************************/
case SIT_STA_MTPSTPCONG: /* stop congestion indication level 0 */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx Stop Congestion\n", sngss7_info->circuit->cic);
SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType));
break;
/**************************************************************************/
case SIT_STA_CIRLOCALBLOIND: /* Mngmt local blocking */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx Local BLO\n", sngss7_info->circuit->cic);
handle_local_blk(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt);
break;
/**************************************************************************/
case SIT_STA_CIRLOCALUBLIND: /* Mngmt local unblocking */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx Local UBL\n", sngss7_info->circuit->cic);
handle_local_ubl(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt);
break;
/**************************************************************************/
case SIT_STA_OVERLOAD: /* Overload */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx Overload\n", sngss7_info->circuit->cic);
handle_olm_msg(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt);
break;
/**************************************************************************/
case SIT_STA_LMCGBREQ: /* when LM requests ckt grp blocking */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx LM CGB\n", sngss7_info->circuit->cic);
SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType));
break;
/**************************************************************************/
case SIT_STA_LMCGUREQ: /* when LM requests ckt grp unblocking */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx LM CGU\n", sngss7_info->circuit->cic);
SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType));
break;
/**************************************************************************/
case SIT_STA_LMGRSREQ: /* when LM requests ckt grp reset */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx LM RSC\n", sngss7_info->circuit->cic);
SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType));
break;
/**************************************************************************/
case SIT_STA_CGBINFOIND: /* circuit grp blking ind , no resp req */
- /*SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx CGB no resp req\n", sngss7_info->circuit->cic);*/
/* handle_cgb_req(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt);*/
break;
/**************************************************************************/
case SIT_STA_LMCQMINFOREQ: /* when LM requests ckt grp query */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx LM CQM\n", sngss7_info->circuit->cic);
// SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType));
break;
/**************************************************************************/
case SIT_STA_CIRLOCGRS: /* group reset initiated locally by the software */
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx Local GRS\n", sngss7_info->circuit->cic);
SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType));
break;
/**************************************************************************/
@@ -1128,11 +1124,25 @@ ftdm_status_t handle_reattempt(uint32_t suInstId, uint32_t spInstId, uint32_t ci
sngss7_chan_data_t *sngss7_info = NULL;
ftdm_channel_t *ftdmchan = NULL;
- /* get the ftdmchan and ss7_chan_data from the circuit */
- if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
- SS7_ERROR("Failed to extract channel data for ISUP circuit = %d!\n", circuit);
+ /* confirm that the circuit is voice channel */
+ if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
+ SS7_ERROR("[CIC:%d]Rx %s on non-voice CIC\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
+
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
return FTDM_FAIL;
+ } else {
+ /* get the ftdmchan and ss7_chan_data from the circuit */
+ if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
+ SS7_ERROR("Failed to extract channel data for ISUP circuit = %d!\n", circuit);
+ SS7_FUNC_TRACE_EXIT(__FUNCTION__);
+ return FTDM_FAIL;
+ }
+
+ SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Rx %s\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
}
/* lock the channel */
@@ -1189,6 +1199,13 @@ ftdm_status_t handle_pause(uint32_t suInstId, uint32_t spInstId, uint32_t circui
/* check that the infId matches and that this is not a siglink */
if ((g_ftdm_sngss7_data.cfg.isupCkt[i].infId == infId) &&
(g_ftdm_sngss7_data.cfg.isupCkt[i].type == VOICE)) {
+
+ /* confirm that the circuit is active on our side otherwise move to the next circuit */
+ if (!sngss7_test_flag(&g_ftdm_sngss7_data.cfg.isupCkt[i], SNGSS7_ACTIVE)) {
+ SS7_ERROR("[CIC:%d]Circuit is not active yet, skipping!\n",g_ftdm_sngss7_data.cfg.isupCkt[i].cic);
+ i++;
+ continue;
+ }
/* get the ftdmchan and ss7_chan_data from the circuit */
if (extract_chan_data(i, &sngss7_info, &ftdmchan)) {
@@ -1207,7 +1224,7 @@ ftdm_status_t handle_pause(uint32_t suInstId, uint32_t spInstId, uint32_t circui
sngss7_set_ckt_flag(sngss7_info, FLAG_INFID_PAUSED);
/* clear the resume flag on the channel */
- sngss7_set_ckt_flag(sngss7_info, FLAG_INFID_RESUME);
+ sngss7_clear_ckt_flag(sngss7_info, FLAG_INFID_RESUME);
}
/* unlock the channel again before we exit */
@@ -1248,6 +1265,13 @@ ftdm_status_t handle_resume(uint32_t suInstId, uint32_t spInstId, uint32_t circu
if ((g_ftdm_sngss7_data.cfg.isupCkt[i].infId == infId) &&
(g_ftdm_sngss7_data.cfg.isupCkt[i].type == VOICE)) {
+ /* confirm that the circuit is active on our side otherwise move to the next circuit */
+ if (!sngss7_test_flag(&g_ftdm_sngss7_data.cfg.isupCkt[i], SNGSS7_ACTIVE)) {
+ SS7_ERROR("[CIC:%d]Circuit is not active yet, skipping!\n",g_ftdm_sngss7_data.cfg.isupCkt[i].cic);
+ i++;
+ continue;
+ }
+
/* get the ftdmchan and ss7_chan_data from the circuit */
if (extract_chan_data(i, &sngss7_info, &ftdmchan)) {
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
@@ -1291,11 +1315,25 @@ ftdm_status_t handle_cot_start(uint32_t suInstId, uint32_t spInstId, uint32_t ci
sngss7_chan_data_t *sngss7_info = NULL;
ftdm_channel_t *ftdmchan = NULL;
- /* get the ftdmchan and ss7_chan_data from the circuit */
- if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
- SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
+ /* confirm that the circuit is voice channel */
+ if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
+ SS7_ERROR("[CIC:%d]Rx %s on non-voice CIC\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
+
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
return FTDM_FAIL;
+ } else {
+ /* get the ftdmchan and ss7_chan_data from the circuit */
+ if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
+ SS7_ERROR("Failed to extract channel data for ISUP circuit = %d!\n", circuit);
+ SS7_FUNC_TRACE_EXIT(__FUNCTION__);
+ return FTDM_FAIL;
+ }
+
+ SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Rx %s\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
}
/* lock the channel */
@@ -1332,11 +1370,25 @@ ftdm_status_t handle_cot_stop(uint32_t suInstId, uint32_t spInstId, uint32_t cir
sngss7_chan_data_t *sngss7_info = NULL;
ftdm_channel_t *ftdmchan = NULL;
- /* get the ftdmchan and ss7_chan_data from the circuit */
- if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
- SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
+ /* confirm that the circuit is voice channel */
+ if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
+ SS7_ERROR("[CIC:%d]Rx %s on non-voice CIC\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
+
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
return FTDM_FAIL;
+ } else {
+ /* get the ftdmchan and ss7_chan_data from the circuit */
+ if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
+ SS7_ERROR("Failed to extract channel data for ISUP circuit = %d!\n", circuit);
+ SS7_FUNC_TRACE_EXIT(__FUNCTION__);
+ return FTDM_FAIL;
+ }
+
+ SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Rx %s\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
}
/* lock the channel */
@@ -1363,11 +1415,25 @@ ftdm_status_t handle_cot(uint32_t suInstId, uint32_t spInstId, uint32_t circuit,
sngss7_chan_data_t *sngss7_info = NULL;
ftdm_channel_t *ftdmchan = NULL;
- /* get the ftdmchan and ss7_chan_data from the circuit */
- if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
- SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
+ /* confirm that the circuit is voice channel */
+ if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
+ SS7_ERROR("[CIC:%d]Rx %s on non-voice CIC\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
+
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
return FTDM_FAIL;
+ } else {
+ /* get the ftdmchan and ss7_chan_data from the circuit */
+ if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
+ SS7_ERROR("Failed to extract channel data for ISUP circuit = %d!\n", circuit);
+ SS7_FUNC_TRACE_EXIT(__FUNCTION__);
+ return FTDM_FAIL;
+ }
+
+ SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Rx %s\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
}
/* lock the channel */
@@ -1417,11 +1483,25 @@ ftdm_status_t handle_blo_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ
sngss7_chan_data_t *sngss7_info = NULL;
ftdm_channel_t *ftdmchan = NULL;
- /* get the ftdmchan and ss7_chan_data from the circuit */
- if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
- SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
+ /* confirm that the circuit is voice channel */
+ if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
+ SS7_ERROR("[CIC:%d]Rx %s on non-voice CIC\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
+
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
return FTDM_FAIL;
+ } else {
+ /* get the ftdmchan and ss7_chan_data from the circuit */
+ if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
+ SS7_ERROR("Failed to extract channel data for ISUP circuit = %d!\n", circuit);
+ SS7_FUNC_TRACE_EXIT(__FUNCTION__);
+ return FTDM_FAIL;
+ }
+
+ SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Rx %s\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
}
/* lock the channel */
@@ -1453,11 +1533,25 @@ ftdm_status_t handle_blo_rsp(uint32_t suInstId, uint32_t spInstId, uint32_t circ
sngss7_chan_data_t *sngss7_info = NULL;
ftdm_channel_t *ftdmchan = NULL;
- /* get the ftdmchan and ss7_chan_data from the circuit */
- if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
- SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
+ /* confirm that the circuit is voice channel */
+ if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
+ SS7_ERROR("[CIC:%d]Rx %s on non-voice CIC\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
+
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
return FTDM_FAIL;
+ } else {
+ /* get the ftdmchan and ss7_chan_data from the circuit */
+ if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
+ SS7_ERROR("Failed to extract channel data for ISUP circuit = %d!\n", circuit);
+ SS7_FUNC_TRACE_EXIT(__FUNCTION__);
+ return FTDM_FAIL;
+ }
+
+ SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Rx %s\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
}
/* lock the channel */
@@ -1480,11 +1574,25 @@ ftdm_status_t handle_ubl_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ
sngss7_chan_data_t *sngss7_info = NULL;
ftdm_channel_t *ftdmchan = NULL;
- /* get the ftdmchan and ss7_chan_data from the circuit */
- if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
- SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
+ /* confirm that the circuit is voice channel */
+ if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
+ SS7_ERROR("[CIC:%d]Rx %s on non-voice CIC\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
+
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
return FTDM_FAIL;
+ } else {
+ /* get the ftdmchan and ss7_chan_data from the circuit */
+ if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
+ SS7_ERROR("Failed to extract channel data for ISUP circuit = %d!\n", circuit);
+ SS7_FUNC_TRACE_EXIT(__FUNCTION__);
+ return FTDM_FAIL;
+ }
+
+ SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Rx %s\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
}
/* lock the channel */
@@ -1519,11 +1627,25 @@ ftdm_status_t handle_ubl_rsp(uint32_t suInstId, uint32_t spInstId, uint32_t circ
sngss7_chan_data_t *sngss7_info = NULL;
ftdm_channel_t *ftdmchan = NULL;
- /* get the ftdmchan and ss7_chan_data from the circuit */
- if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
- SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
+ /* confirm that the circuit is voice channel */
+ if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
+ SS7_ERROR("[CIC:%d]Rx %s on non-voice CIC\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
+
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
return FTDM_FAIL;
+ } else {
+ /* get the ftdmchan and ss7_chan_data from the circuit */
+ if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
+ SS7_ERROR("Failed to extract channel data for ISUP circuit = %d!\n", circuit);
+ SS7_FUNC_TRACE_EXIT(__FUNCTION__);
+ return FTDM_FAIL;
+ }
+
+ SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Rx %s\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
}
/* lock the channel */
@@ -1546,11 +1668,25 @@ ftdm_status_t handle_rsc_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ
sngss7_chan_data_t *sngss7_info = NULL;
ftdm_channel_t *ftdmchan = NULL;
- /* get the ftdmchan and ss7_chan_data from the circuit */
- if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
- SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
+ /* confirm that the circuit is voice channel */
+ if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
+ SS7_ERROR("[CIC:%d]Rx %s on non-voice CIC\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
+
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
return FTDM_FAIL;
+ } else {
+ /* get the ftdmchan and ss7_chan_data from the circuit */
+ if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
+ SS7_ERROR("Failed to extract channel data for ISUP circuit = %d!\n", circuit);
+ SS7_FUNC_TRACE_EXIT(__FUNCTION__);
+ return FTDM_FAIL;
+ }
+
+ SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Rx %s\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
}
/* lock the channel */
@@ -1591,13 +1727,26 @@ ftdm_status_t handle_local_rsc_req(uint32_t suInstId, uint32_t spInstId, uint32_
sngss7_chan_data_t *sngss7_info = NULL;
ftdm_channel_t *ftdmchan = NULL;
- /* get the ftdmchan and ss7_chan_data from the circuit */
- if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
- SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
+ /* confirm that the circuit is voice channel */
+ if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
+ SS7_ERROR("[CIC:%d]Rx %s on non-voice CIC\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
+
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
return FTDM_FAIL;
- }
+ } else {
+ /* get the ftdmchan and ss7_chan_data from the circuit */
+ if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
+ SS7_ERROR("Failed to extract channel data for ISUP circuit = %d!\n", circuit);
+ SS7_FUNC_TRACE_EXIT(__FUNCTION__);
+ return FTDM_FAIL;
+ }
+ SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Rx %s\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
+ }
/* lock the channel */
ftdm_mutex_lock(ftdmchan->mutex);
@@ -1636,11 +1785,25 @@ ftdm_status_t handle_rsc_rsp(uint32_t suInstId, uint32_t spInstId, uint32_t circ
sngss7_chan_data_t *sngss7_info = NULL;
ftdm_channel_t *ftdmchan = NULL;
- /* get the ftdmchan and ss7_chan_data from the circuit */
- if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
- SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
+ /* confirm that the circuit is voice channel */
+ if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
+ SS7_ERROR("[CIC:%d]Rx %s on non-voice CIC\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
+
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
return FTDM_FAIL;
+ } else {
+ /* get the ftdmchan and ss7_chan_data from the circuit */
+ if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
+ SS7_ERROR("Failed to extract channel data for ISUP circuit = %d!\n", circuit);
+ SS7_FUNC_TRACE_EXIT(__FUNCTION__);
+ return FTDM_FAIL;
+ }
+
+ SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Rx %s\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
}
/* lock the channel */
@@ -1713,10 +1876,25 @@ ftdm_status_t handle_grs_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ
int range;
- if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
- SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
+ /* confirm that the circuit is voice channel */
+ if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
+ SS7_ERROR("[CIC:%d]Rx %s on non-voice CIC\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
+
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
return FTDM_FAIL;
+ } else {
+ /* get the ftdmchan and ss7_chan_data from the circuit */
+ if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
+ SS7_ERROR("Failed to extract channel data for ISUP circuit = %d!\n", circuit);
+ SS7_FUNC_TRACE_EXIT(__FUNCTION__);
+ return FTDM_FAIL;
+ }
+
+ SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Rx %s\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
}
/* extract the range value from the event structure */
@@ -1749,10 +1927,25 @@ ftdm_status_t handle_grs_rsp(uint32_t suInstId, uint32_t spInstId, uint32_t circ
sngss7_span_data_t *sngss7_span = NULL;
int range;
- if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
- SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
+ /* confirm that the circuit is voice channel */
+ if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
+ SS7_ERROR("[CIC:%d]Rx %s on non-voice CIC\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
+
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
return FTDM_FAIL;
+ } else {
+ /* get the ftdmchan and ss7_chan_data from the circuit */
+ if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
+ SS7_ERROR("Failed to extract channel data for ISUP circuit = %d!\n", circuit);
+ SS7_FUNC_TRACE_EXIT(__FUNCTION__);
+ return FTDM_FAIL;
+ }
+
+ SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Rx %s\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
}
/* extract the range value from the event structure */
@@ -1791,11 +1984,25 @@ ftdm_status_t handle_local_blk(uint32_t suInstId, uint32_t spInstId, uint32_t ci
sngss7_chan_data_t *sngss7_info = NULL;
ftdm_channel_t *ftdmchan = NULL;
- /* get the ftdmchan and ss7_chan_data from the circuit */
- if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
- SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
+ /* confirm that the circuit is voice channel */
+ if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
+ SS7_ERROR("[CIC:%d]Rx %s on non-voice CIC\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
+
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
return FTDM_FAIL;
+ } else {
+ /* get the ftdmchan and ss7_chan_data from the circuit */
+ if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
+ SS7_ERROR("Failed to extract channel data for ISUP circuit = %d!\n", circuit);
+ SS7_FUNC_TRACE_EXIT(__FUNCTION__);
+ return FTDM_FAIL;
+ }
+
+ SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Rx %s\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
}
/* lock the channel */
@@ -1827,22 +2034,36 @@ ftdm_status_t handle_local_ubl(uint32_t suInstId, uint32_t spInstId, uint32_t ci
sngss7_chan_data_t *sngss7_info = NULL;
ftdm_channel_t *ftdmchan = NULL;
- /* get the ftdmchan and ss7_chan_data from the circuit */
- if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
- SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
+ /* confirm that the circuit is voice channel */
+ if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
+ SS7_ERROR("[CIC:%d]Rx %s on non-voice CIC\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
+
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
return FTDM_FAIL;
+ } else {
+ /* get the ftdmchan and ss7_chan_data from the circuit */
+ if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
+ SS7_ERROR("Failed to extract channel data for ISUP circuit = %d!\n", circuit);
+ SS7_FUNC_TRACE_EXIT(__FUNCTION__);
+ return FTDM_FAIL;
+ }
+
+ SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Rx %s\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
}
/* lock the channel */
ftdm_mutex_lock(ftdmchan->mutex);
- /* check if the circuit is already blocked or not */
- if (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_UNBLK_RX)) {
- SS7_WARN("Received local UBL on circuit that is already unblocked!\n");
+ /* check if the circuit is blocked or not */
+ if (!sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX)) {
+ SS7_WARN("Received local UBL on circuit that is not blocked!\n");
}
- /* throw the ckt block flag */
+ /* throw the ckt unblock flag */
sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_UNBLK_RX);
/* set the channel to suspended state */
@@ -1865,11 +2086,25 @@ ftdm_status_t handle_ucic(uint32_t suInstId, uint32_t spInstId, uint32_t circuit
ftdm_channel_t *ftdmchan = NULL;
- /* get the ftdmchan and ss7_chan_data from the circuit */
- if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
- SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
+ /* confirm that the circuit is voice channel */
+ if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
+ SS7_ERROR("[CIC:%d]Rx %s on non-voice CIC\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
+
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
return FTDM_FAIL;
+ } else {
+ /* get the ftdmchan and ss7_chan_data from the circuit */
+ if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
+ SS7_ERROR("Failed to extract channel data for ISUP circuit = %d!\n", circuit);
+ SS7_FUNC_TRACE_EXIT(__FUNCTION__);
+ return FTDM_FAIL;
+ }
+
+ SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Rx %s\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
}
/* check if we just sent a GRS request...*/
@@ -1914,13 +2149,26 @@ ftdm_status_t handle_cgb_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ
memset(&status[0], '\0', sizeof(status));
- /* get the ftdmchan and ss7_chan_data from the circuit */
- if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
- SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
+ /* confirm that the circuit is voice channel */
+ if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
+ SS7_ERROR("[CIC:%d]Rx %s on non-voice CIC\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
+
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
return FTDM_FAIL;
- }
+ } else {
+ /* get the ftdmchan and ss7_chan_data from the circuit */
+ if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
+ SS7_ERROR("Failed to extract channel data for ISUP circuit = %d!\n", circuit);
+ SS7_FUNC_TRACE_EXIT(__FUNCTION__);
+ return FTDM_FAIL;
+ }
+ SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Rx %s\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
+ }
/* grab the span info */
sngss7_span = ftdmchan->span->signal_data;
@@ -2049,11 +2297,25 @@ ftdm_status_t handle_cgu_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ
memset(&sigev, 0, sizeof (sigev));
memset(&status[0], '\0', sizeof(status));
- /* get the ftdmchan and ss7_chan_data from the circuit */
- if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
- SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
+ /* confirm that the circuit is voice channel */
+ if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
+ SS7_ERROR("[CIC:%d]Rx %s on non-voice CIC\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
+
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
return FTDM_FAIL;
+ } else {
+ /* get the ftdmchan and ss7_chan_data from the circuit */
+ if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
+ SS7_ERROR("Failed to extract channel data for ISUP circuit = %d!\n", circuit);
+ SS7_FUNC_TRACE_EXIT(__FUNCTION__);
+ return FTDM_FAIL;
+ }
+
+ SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Rx %s\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
}
/* grab the span info */
@@ -2167,11 +2429,25 @@ ftdm_status_t handle_olm_msg(uint32_t suInstId, uint32_t spInstId, uint32_t circ
sngss7_chan_data_t *sngss7_info = NULL;
ftdm_channel_t *ftdmchan = NULL;
- /* get the ftdmchan and ss7_chan_data from the circuit */
- if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
- SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
+ /* confirm that the circuit is voice channel */
+ if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
+ SS7_ERROR("[CIC:%d]Rx %s on non-voice CIC\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
+
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
return FTDM_FAIL;
+ } else {
+ /* get the ftdmchan and ss7_chan_data from the circuit */
+ if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
+ SS7_ERROR("Failed to extract channel data for ISUP circuit = %d!\n", circuit);
+ SS7_FUNC_TRACE_EXIT(__FUNCTION__);
+ return FTDM_FAIL;
+ }
+
+ SS7_INFO_CHAN(ftdmchan, "[CIC:%d]Rx %s\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
}
/* handle overload */
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_in.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_in.c
index 76984b907b..d3828fe0e3 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_in.c
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_in.c
@@ -66,6 +66,12 @@ void sngss7_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiCo
ftdm_channel_t *ftdmchan = NULL;
sngss7_event_data_t *sngss7_event = NULL;
+ if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
+ SS7_ERROR("Rx sig event on circuit that is not a voice CIC (%d)\n", circuit);
+ SS7_FUNC_TRACE_EXIT(__FUNCTION__);
+ return;
+ }
+
/* get the ftdmchan and ss7_chan_data from the circuit */
if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
@@ -104,6 +110,12 @@ void sngss7_con_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiCo
ftdm_channel_t *ftdmchan = NULL;
sngss7_event_data_t *sngss7_event = NULL;
+ if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
+ SS7_ERROR("Rx sig event on circuit that is not a voice CIC (%d)\n", circuit);
+ SS7_FUNC_TRACE_EXIT(__FUNCTION__);
+ return;
+ }
+
/* get the ftdmchan and ss7_chan_data from the circuit */
if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
@@ -142,6 +154,12 @@ void sngss7_con_sta(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiCn
ftdm_channel_t *ftdmchan = NULL;
sngss7_event_data_t *sngss7_event = NULL;
+ if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
+ SS7_ERROR("Rx sig event on circuit that is not a voice CIC (%d)\n", circuit);
+ SS7_FUNC_TRACE_EXIT(__FUNCTION__);
+ return;
+ }
+
/* get the ftdmchan and ss7_chan_data from the circuit */
if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
@@ -181,6 +199,12 @@ void sngss7_rel_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiRe
ftdm_channel_t *ftdmchan = NULL;
sngss7_event_data_t *sngss7_event = NULL;
+ if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
+ SS7_ERROR("Rx sig event on circuit that is not a voice CIC (%d)\n", circuit);
+ SS7_FUNC_TRACE_EXIT(__FUNCTION__);
+ return;
+ }
+
/* get the ftdmchan and ss7_chan_data from the circuit */
if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
@@ -219,6 +243,12 @@ void sngss7_rel_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiRe
ftdm_channel_t *ftdmchan = NULL;
sngss7_event_data_t *sngss7_event = NULL;
+ if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
+ SS7_ERROR("Rx sig event on circuit that is not a voice CIC (%d)\n", circuit);
+ SS7_FUNC_TRACE_EXIT(__FUNCTION__);
+ return;
+ }
+
/* get the ftdmchan and ss7_chan_data from the circuit */
if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
@@ -257,6 +287,12 @@ void sngss7_dat_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiIn
ftdm_channel_t *ftdmchan = NULL;
sngss7_event_data_t *sngss7_event = NULL;
+ if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
+ SS7_ERROR("Rx sig event on circuit that is not a voice CIC (%d)\n", circuit);
+ SS7_FUNC_TRACE_EXIT(__FUNCTION__);
+ return;
+ }
+
/* get the ftdmchan and ss7_chan_data from the circuit */
if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
@@ -295,6 +331,12 @@ void sngss7_fac_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint
ftdm_channel_t *ftdmchan = NULL;
sngss7_event_data_t *sngss7_event = NULL;
+ if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
+ SS7_ERROR("Rx sig event on circuit that is not a voice CIC (%d)\n", circuit);
+ SS7_FUNC_TRACE_EXIT(__FUNCTION__);
+ return;
+ }
+
/* get the ftdmchan and ss7_chan_data from the circuit */
if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
@@ -334,6 +376,12 @@ void sngss7_fac_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint
ftdm_channel_t *ftdmchan = NULL;
sngss7_event_data_t *sngss7_event = NULL;
+ if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
+ SS7_ERROR("Rx sig event on circuit that is not a voice CIC (%d)\n", circuit);
+ SS7_FUNC_TRACE_EXIT(__FUNCTION__);
+ return;
+ }
+
/* get the ftdmchan and ss7_chan_data from the circuit */
if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
@@ -373,6 +421,12 @@ void sngss7_umsg_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit)
ftdm_channel_t *ftdmchan = NULL;
sngss7_event_data_t *sngss7_event = NULL;
+ if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
+ SS7_ERROR("Rx sig event on circuit that is not a voice CIC (%d)\n", circuit);
+ SS7_FUNC_TRACE_EXIT(__FUNCTION__);
+ return;
+ }
+
/* get the ftdmchan and ss7_chan_data from the circuit */
if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
@@ -412,29 +466,26 @@ void sngss7_sta_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint
uint32_t intfId;
int x;
+
+
/* check if the eventType is a pause/resume */
switch (evntType) {
/**************************************************************************/
case (SIT_STA_PAUSEIND):
case (SIT_STA_RESUMEIND):
-
- /* the circuit for this type of event may not exist on the local system
- * so first check if the circuit is local
- */
- if ((circuit >= (g_ftdm_sngss7_data.cfg.procId * 1000)) &&
- (circuit < ((g_ftdm_sngss7_data.cfg.procId +1) * 1000))) {
-
- /* the circuit is on the local system, handle normally */
- goto sta_ind_local;
- }
-
- /* the circuit is not local, so find a local circuit with the same intfId
- * by finding the orginial circuit in our array first, finding the intfId
- * from there, then go through the local circuits to see if we find a
- * match and use that circuit instead
+ /* the circuit may or may not be on the local system so we have to find
+ * circuit with the same intfId. The circuit specified might also be
+ * a non-voice cic so we also need to find the first voice cic on this
+ * system with the same intfId.
*/
intfId = g_ftdm_sngss7_data.cfg.isupCkt[circuit].infId;
+ if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
+ SS7_DEBUG("Rx %s on circuit that is not a voice CIC (%d) finding a new circuit\n",
+ DECODE_LCC_EVENT(evntType),
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic);
+ }
+
x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;
while ((g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) &&
(g_ftdm_sngss7_data.cfg.isupCkt[x].id < ((g_ftdm_sngss7_data.cfg.procId +1) * 1000))) {
@@ -446,6 +497,14 @@ void sngss7_sta_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint
if (g_ftdm_sngss7_data.cfg.isupCkt[x].infId == intfId) {
/* we have a match, setup the pointers to the correct values */
circuit = x;
+
+ /* confirm that the circuit is active on our side otherwise move to the next circuit */
+ if (!sngss7_test_flag(&g_ftdm_sngss7_data.cfg.isupCkt[circuit], SNGSS7_ACTIVE)) {
+ SS7_DEBUG("[CIC:%d]Rx %s but circuit is not active yet, skipping!\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
+ DECODE_LCC_EVENT(evntType));
+ continue;
+ }
if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
@@ -472,7 +531,14 @@ move_along:
break;
/**************************************************************************/
default:
-sta_ind_local:
+ if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
+ SS7_ERROR("Rx %s on circuit that is not a voice CIC (%d)\n",
+ DECODE_LCC_EVENT(evntType),
+ g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic);
+ SS7_FUNC_TRACE_EXIT(__FUNCTION__);
+ return;
+ }
+
/* get the ftdmchan and ss7_chan_data from the circuit */
if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
@@ -520,6 +586,12 @@ void sngss7_susp_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiS
ftdm_channel_t *ftdmchan = NULL;
sngss7_event_data_t *sngss7_event = NULL;
+ if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
+ SS7_ERROR("Rx sig event on circuit that is not a voice CIC (%d)\n", circuit);
+ SS7_FUNC_TRACE_EXIT(__FUNCTION__);
+ return;
+ }
+
/* get the ftdmchan and ss7_chan_data from the circuit */
if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
@@ -561,6 +633,12 @@ void sngss7_resm_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiR
ftdm_channel_t *ftdmchan = NULL;
sngss7_event_data_t *sngss7_event = NULL;
+ if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
+ SS7_ERROR("Rx sig event on circuit that is not a voice CIC (%d)\n", circuit);
+ SS7_FUNC_TRACE_EXIT(__FUNCTION__);
+ return;
+ }
+
/* get the ftdmchan and ss7_chan_data from the circuit */
if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.c
index f4143fc864..4b5787c0cb 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.c
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.c
@@ -134,7 +134,7 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta)
/* find the name for the sap in question */
x = 1;
- while (g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) {
+ while (x < (MAX_MTP_LINKS+1)) {
if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) {
break;
}
@@ -149,24 +149,19 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta)
switch (sta->t.usta.alarm.cause) {
- /******************************************************************/
- case (LCM_CAUSE_UNKNOWN):
- ftdm_log(FTDM_LOG_ERROR,"[MTP2]%s %s\n",
- buf,
- DECODE_LSD_EVENT(sta->t.usta.alarm.event));
- break;
- /******************************************************************/
- case (LCM_CAUSE_MGMT_INITIATED):
- ftdm_log(FTDM_LOG_ERROR,"[MTP2]%s[MGMT] %s\n",
- buf,
- DECODE_LSD_EVENT(sta->t.usta.alarm.event));
- break;
- /******************************************************************/
- default:
- ftdm_log(FTDM_LOG_ERROR,"[MTP2]%s %s (***unknown cause***)\n",
- buf,
- DECODE_LSD_EVENT(sta->t.usta.alarm.event));
- break;
+ case (LCM_CAUSE_MGMT_INITIATED):
+ ftdm_log(FTDM_LOG_DEBUG,"[MTP2]%s[MGMT] cause:%s event:%s\n",
+ buf,
+ DECODE_LCM_CAUSE(sta->t.usta.alarm.cause),
+ DECODE_LSD_EVENT(sta->t.usta.alarm.event));
+ break;
+ case (LCM_CAUSE_UNKNOWN):
+ default:
+ ftdm_log(FTDM_LOG_DEBUG,"[MTP2]%s cause:%s event:%s\n",
+ buf,
+ DECODE_LCM_CAUSE(sta->t.usta.alarm.cause),
+ DECODE_LSD_EVENT(sta->t.usta.alarm.event));
+ break;
/******************************************************************/
} /* switch (sta->t.usta.alarm.cause) */
break;
@@ -175,7 +170,7 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta)
/* find the name for the sap in question */
x = 1;
- while (g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) {
+ while (x < (MAX_MTP_LINKS+1)) {
if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) {
break;
}
@@ -198,7 +193,7 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta)
/* find the name for the sap in question */
x = 1;
- while (g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) {
+ while (x < (MAX_MTP_LINKS+1)) {
if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) {
break;
}
@@ -211,7 +206,7 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta)
sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtp2Link[x].name);
}
- ftdm_log(FTDM_LOG_ERROR,"[MTP2]%s %s : %s\n",
+ ftdm_log(FTDM_LOG_DEBUG,"[MTP2]%s %s : %s\n",
buf,
DECODE_LSD_EVENT(sta->t.usta.alarm.event),
DECODE_DISC_REASON(sta->t.usta.evntParm[1]));
@@ -222,7 +217,7 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta)
/* find the name for the sap in question */
x = 1;
- while (g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) {
+ while (x < (MAX_MTP_LINKS+1)) {
if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) {
break;
}
@@ -248,7 +243,7 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta)
/* find the name for the sap in question */
x = 1;
- while (g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) {
+ while (x < (MAX_MTP_LINKS+1)) {
if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) {
break;
}
@@ -271,7 +266,7 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta)
/* find the name for the sap in question */
x = 1;
- while (g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) {
+ while (x < (MAX_MTP_LINKS+1)) {
if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) {
break;
}
@@ -366,7 +361,7 @@ void handle_sng_mtp3_alarm(Pst *pst, SnMngmt *sta)
/* find the name for the sap in question */
x = 1;
- while (g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {
+ while (x < (MAX_MTP_LINKS+1)) {
if (g_ftdm_sngss7_data.cfg.mtp3Link[x].id == sta->hdr.elmId.elmntInst1) {
break;
}
@@ -402,7 +397,7 @@ void handle_sng_mtp3_alarm(Pst *pst, SnMngmt *sta)
break;
/**********************************************************************/
default:
- ftdm_log(FTDM_LOG_ERROR,"[MTP3]%s %s(%d) : %s(%d)\n",
+ ftdm_log(FTDM_LOG_DEBUG,"[MTP3]%s %s(%d) : %s(%d)\n",
buf,
DECODE_LSN_EVENT(sta->t.usta.alarm.event),
sta->t.usta.alarm.event,
@@ -421,7 +416,7 @@ void handle_sng_mtp3_alarm(Pst *pst, SnMngmt *sta)
break;
/**************************************************************************/
case (STLNKSET):
- ftdm_log(FTDM_LOG_ERROR,"[MTP3][LNKSET:%d] %s : %s\n",
+ ftdm_log(FTDM_LOG_DEBUG,"[MTP3][LNKSET:%d] %s : %s\n",
sta->hdr.elmId.elmntInst1,
DECODE_LSN_EVENT(sta->t.usta.alarm.event),
DECODE_LSN_CAUSE(sta->t.usta.alarm.cause));
@@ -766,7 +761,18 @@ void handle_sng_relay_alarm(Pst *pst, RyMngmt *sta)
DECODE_LRY_REASON(sta->t.usta.s.ryErrUsta.reason));
/* process the event */
- handle_relay_disconnect_on_error(sta);
+ switch (sta->t.usta.s.ryErrUsta.reason) {
+ /**********************************************************************/
+ case (LRYRSNMGMTREQ):
+ /* do nothing since this is a shutdown */
+ break;
+ /**********************************************************************/
+ default:
+ /* handle the error */
+ handle_relay_disconnect_on_error(sta);
+ break;
+ /**********************************************************************/
+ } /* switch (sta->t.usta.s.ryErrUsta.reason) */
break;
/**************************************************************************/
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c
index 2f630fe462..53062b9d56 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c
@@ -42,6 +42,7 @@
static sng_isup_event_interface_t sng_event;
static ftdm_io_interface_t g_ftdm_sngss7_interface;
ftdm_sngss7_data_t g_ftdm_sngss7_data;
+
/******************************************************************************/
/* PROTOTYPES *****************************************************************/
@@ -109,7 +110,15 @@ ftdm_state_map_t sangoma_ss7_state_map = {
{FTDM_CHANNEL_STATE_RING, FTDM_END},
{FTDM_CHANNEL_STATE_SUSPENDED, FTDM_CHANNEL_STATE_RESTART,
FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP,
- FTDM_CHANNEL_STATE_PROGRESS, FTDM_END}
+ FTDM_CHANNEL_STATE_RINGING, FTDM_CHANNEL_STATE_PROGRESS, FTDM_END}
+ },
+ {
+ ZSD_INBOUND,
+ ZSM_UNACCEPTABLE,
+ {FTDM_CHANNEL_STATE_RINGING, FTDM_END},
+ {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP,
+ FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_PROGRESS_MEDIA,
+ FTDM_CHANNEL_STATE_UP, FTDM_END},
},
{
ZSD_INBOUND,
@@ -365,6 +374,9 @@ static void *ftdm_sangoma_ss7_run(ftdm_thread_t * me, void *obj)
/* check each channel on the span to see if there is an un-procressed SUS/RES flag */
check_for_res_sus_flag(ftdmspan);
+ /* check each channel on the span to see if it needs to be reconfigured */
+ check_for_reconfig_flag(ftdmspan);
+
/* Poll for events, e.g HW DTMF */
switch (ftdm_span_poll_event(ftdmspan, 0, NULL)) {
/**********************************************************************/
@@ -498,11 +510,6 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
SS7_DEBUG_CHAN(ftdmchan, "ftmod_sangoma_ss7 processing state %s\n", ftdm_channel_state2str (ftdmchan->state));
-#if 0
- /* clear the state change flag...since we might be setting a new state */
- ftdm_channel_complete_state(ftdmchan);
-#endif
-
/*check what state we are supposed to be in */
switch (ftdmchan->state) {
/**************************************************************************/
@@ -606,6 +613,8 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
break;
/**************************************************************************/
+ /* We handle RING indication the same way we would indicate PROGRESS */
+ case FTDM_CHANNEL_STATE_RINGING:
case FTDM_CHANNEL_STATE_PROGRESS:
if (ftdmchan->last_state == FTDM_CHANNEL_STATE_SUSPENDED) {
@@ -623,7 +632,10 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA);
} else {
/* inbound call so we need to send out ACM */
- ft_to_sngss7_acm(ftdmchan);
+ if (!sngss7_test_ckt_flag(sngss7_info, FLAG_SENT_ACM)) {
+ sngss7_set_ckt_flag(sngss7_info, FLAG_SENT_ACM);
+ ft_to_sngss7_acm(ftdmchan);
+ }
}
break;
@@ -874,6 +886,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
/* clear any call related flags */
sngss7_clear_ckt_flag (sngss7_info, FLAG_REMOTE_REL);
sngss7_clear_ckt_flag (sngss7_info, FLAG_LOCAL_REL);
+ sngss7_clear_ckt_flag (sngss7_info, FLAG_SENT_ACM);
if (ftdm_test_flag (ftdmchan, FTDM_CHANNEL_OPEN)) {
@@ -906,8 +919,8 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
case FTDM_CHANNEL_STATE_RESTART: /* CICs needs a Reset */
if (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK)) {
- if ((sngss7_test_ckt_blk_flag(sngss7_info, FLAG_RESET_RX)) ||
- (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_GRP_RESET_RX))) {
+ if ((sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_RX)) ||
+ (sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX))) {
SS7_DEBUG_CHAN(ftdmchan,"Incoming Reset request on CIC in UCIC block, removing UCIC block%s\n", "");
@@ -926,33 +939,27 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
}
}
- /* if we're not coming from HANGUP_COMPLETE we need to check for resets
- * we can also check if we are in a PAUSED state (no point in sending message
- */
- if ((ftdmchan->last_state != FTDM_CHANNEL_STATE_HANGUP_COMPLETE) &&
- (!sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_PAUSED))) {
- /* check if this is an outgoing RSC */
- if ((sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_TX)) &&
- !(sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_SENT))) {
+ /* check if this is an outgoing RSC */
+ if ((sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_TX)) &&
+ !(sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_SENT))) {
- /* send a reset request */
- ft_to_sngss7_rsc (ftdmchan);
- sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_SENT);
+ /* send a reset request */
+ ft_to_sngss7_rsc (ftdmchan);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_SENT);
- } /* if (sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_TX)) */
-
- /* check if this is the first channel of a GRS (this flag is thrown when requesting reset) */
- if ( (sngss7_test_ckt_flag (sngss7_info, FLAG_GRP_RESET_TX)) &&
- !(sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_SENT)) &&
- (sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_BASE))) {
+ } /* if (sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_TX)) */
- /* send out the grs */
- ft_to_sngss7_grs (ftdmchan);
- sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_RESET_SENT);
+ /* check if this is the first channel of a GRS (this flag is thrown when requesting reset) */
+ if ( (sngss7_test_ckt_flag (sngss7_info, FLAG_GRP_RESET_TX)) &&
+ !(sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_SENT)) &&
+ (sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_BASE))) {
- }/* if ( sngss7_test_ckt_flag ( sngss7_info, FLAG_GRP_RESET_TX ) ) */
- } /* if ( last_state != HANGUP && !PAUSED */
+ /* send out the grs */
+ ft_to_sngss7_grs (ftdmchan);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_RESET_SENT);
+
+ }/* if ( sngss7_test_ckt_flag ( sngss7_info, FLAG_GRP_RESET_TX ) ) */
/* if the sig_status is up...bring it down */
if (ftdm_test_flag (ftdmchan, FTDM_CHANNEL_SIG_UP)) {
@@ -1023,10 +1030,13 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
/**************************************************************************/
case FTDM_CHANNEL_STATE_SUSPENDED: /* circuit has been blocked */
- SS7_DEBUG_CHAN(ftdmchan,"Current flags: 0x%X\n", sngss7_info->ckt_flags);
+ SS7_DEBUG_CHAN(ftdmchan,"Current flags: ckt=0x%X, blk=0x%X\n",
+ sngss7_info->ckt_flags,
+ sngss7_info->blk_flags);
/**********************************************************************/
if (sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_RESUME)) {
+
SS7_DEBUG_CHAN(ftdmchan, "Processing RESUME%s\n", "");
/* clear the RESUME flag */
@@ -1041,30 +1051,28 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
(sngss7_test_ckt_flag (sngss7_info, FLAG_GRP_RESET_TX)) ||
(sngss7_test_ckt_flag (sngss7_info, FLAG_GRP_RESET_RX))) {
- /* go back to the reset state */
+ /* don't bring up the sig status but also move to reset */
goto suspend_goto_restart;
} else {
-
/* bring the sig status back up */
sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_UP);
}
-
- /* go back to the last state */
- goto suspend_goto_last;
} /* if (sngss7_test_flag(sngss7_info, FLAG_INFID_RESUME)) */
if (sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_PAUSED)) {
+
SS7_DEBUG_CHAN(ftdmchan, "Processing PAUSE%s\n", "");
- /* bring the sig status down */
- sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_DOWN);
-
- /* go back to the last state */
- goto suspend_goto_last;
+ if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_SIG_UP)) {
+ /* bring the sig status down */
+ sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_DOWN);
+ }
} /* if (sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_PAUSED)) { */
+
/**********************************************************************/
- if (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX) &&
+ if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_MN_BLOCK_RX) &&
!sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX_DN)) {
+
SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_MN_BLOCK_RX flag %s\n", "");
/* bring the sig status down */
@@ -1080,10 +1088,13 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
goto suspend_goto_last;
}
- if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_MN_UNBLK_RX) &&
- !sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_MN_UNBLK_RX_DN)){
+ if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_MN_UNBLK_RX)){
SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_MN_UNBLK_RX flag %s\n", "");
+ /* clear the block flags */
+ sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX);
+ sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX_DN);
+
/* clear the unblock flag */
sngss7_clear_ckt_blk_flag (sngss7_info, FLAG_CKT_MN_UNBLK_RX);
@@ -1093,9 +1104,6 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
/* send a uba */
ft_to_sngss7_uba (ftdmchan);
- /* throw the done flag */
- sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_UNBLK_RX_DN);
-
/* check the last state and return to it to allow the call to finish */
goto suspend_goto_last;
}
@@ -1103,6 +1111,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
/**********************************************************************/
if (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX) &&
!sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX_DN)) {
+
SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_MN_BLOCK_TX flag %s\n", "");
/* bring the sig status down */
@@ -1118,12 +1127,16 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
goto suspend_goto_last;
}
- if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_MN_UNBLK_TX) &&
- !sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_MN_UNBLK_TX_DN)){
+ if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_MN_UNBLK_TX)) {
+
SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_MN_UNBLK_TX flag %s\n", "");
+ /* clear the block flags */
+ sngss7_clear_ckt_blk_flag (sngss7_info, FLAG_CKT_MN_BLOCK_TX);
+ sngss7_clear_ckt_blk_flag (sngss7_info, FLAG_CKT_MN_BLOCK_TX_DN);
+
/* clear the unblock flag */
- sngss7_clear_ckt_blk_flag (sngss7_info, FLAG_CKT_MN_UNBLK_TX);
+ sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_UNBLK_TX);
/* bring the sig status up */
sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_UP);
@@ -1131,9 +1144,6 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
/* send a ubl */
ft_to_sngss7_ubl (ftdmchan);
- /* throw the done flag */
- sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_UNBLK_TX_DN);
-
/* check the last state and return to it to allow the call to finish */
goto suspend_goto_last;
}
@@ -1141,6 +1151,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
/**********************************************************************/
if (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX) &&
!sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX_DN)) {
+
SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_LC_BLOCK_RX flag %s\n", "");
/* send a BLA */
@@ -1153,18 +1164,20 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
goto suspend_goto_last;
}
- if (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_UNBLK_RX) &&
- !sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_UNBLK_RX_DN)) {
+ if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_LC_UNBLK_RX)) {
+
SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_LC_UNBLK_RX flag %s\n", "");
+
+ /* clear the block flags */
+ sngss7_clear_ckt_blk_flag (sngss7_info, FLAG_CKT_LC_BLOCK_RX);
+ sngss7_clear_ckt_blk_flag (sngss7_info, FLAG_CKT_LC_BLOCK_RX_DN);
/* clear the unblock flag */
- sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_UNBLK_RX);
+ sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_UNBLK_RX);
/* send a uba */
/*ft_to_sngss7_uba(ftdmchan);*/
- /* throw the done flag */
- sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_UNBLK_RX_DN);
/* check the last state and return to it to allow the call to finish */
goto suspend_goto_last;
@@ -1172,6 +1185,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
/**********************************************************************/
if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_UCIC_BLOCK) &&
!sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_UCIC_BLOCK_DN)) {
+
SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_UCIC_BLOCK flag %s\n", "");
/* bring the channel signaling status to down */
@@ -1192,12 +1206,12 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
goto suspend_goto_last;
}
- if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_UCIC_UNBLK) &&
- !sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_UCIC_UNBLK_DN)) {
- SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_UCIC_UNBLK flag %s\n", "");;
+ if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_UCIC_UNBLK)) {
+ SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_UCIC_UNBLK flag %s\n", "");
/* remove the UCIC block flag */
sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK);
+ sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK_DN);
/* remove the UCIC unblock flag */
sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_UCIC_UNBLK);
@@ -1205,13 +1219,12 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
/* throw the channel into reset to sync states */
sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_TX);
- /* throw the done flag */
- sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_UCIC_UNBLK_DN);
-
/* bring the channel into restart again */
goto suspend_goto_restart;
}
+ SS7_DEBUG_CHAN(ftdmchan,"No block flag processed!%s\n", "");
+
suspend_goto_last:
state_flag = 0;
ftdm_set_state(ftdmchan, ftdmchan->last_state);
@@ -1370,30 +1383,27 @@ static ftdm_status_t ftdm_sangoma_ss7_start(ftdm_span_t * span)
ftdm_clear_flag (span, FTDM_SPAN_STOP_THREAD);
ftdm_clear_flag (span, FTDM_SPAN_IN_THREAD);
- /* activate all the configured ss7 links */
- if (ft_to_sngss7_activate_all()) {
- SS7_CRITICAL ("Failed to activate LibSngSS7!\n");
- return FTDM_FAIL;
- }
-
- /*start the span monitor thread */
- if (ftdm_thread_create_detached (ftdm_sangoma_ss7_run, span) != FTDM_SUCCESS) {
- SS7_CRITICAL ("Failed to start Span Monitor Thread!\n");
- return FTDM_FAIL;
- }
-
- /* confirm the state of all isup interfaces*/
+ /* check the status of all isup interfaces */
check_status_of_all_isup_intf();
/* throw the channels in pause */
for (x = 1; x < (span->chan_count + 1); x++) {
/* extract the channel structure and sngss7 channel data */
ftdmchan = span->channels[x];
+
+ /* if there is no sig mod data move along */
if (ftdmchan->call_data == NULL) continue;
+
sngss7_info = ftdmchan->call_data;
sngss7_span = ftdmchan->span->signal_data;
sngss7_intf = &g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info->circuit->infId];
+ /* flag the circuit as active so we can receieve events on it */
+ sngss7_set_flag(sngss7_info->circuit, SNGSS7_ACTIVE);
+
+ /* if this is a non-voice channel, move along cause we're done with it */
+ if (sngss7_info->circuit->type != VOICE) continue;
+
/* lock the channel */
ftdm_mutex_lock(ftdmchan->mutex);
@@ -1428,6 +1438,18 @@ static ftdm_status_t ftdm_sangoma_ss7_start(ftdm_span_t * span)
ftdm_mutex_unlock(ftdmchan->mutex);
}
+ /* activate all the configured ss7 links */
+ if (ft_to_sngss7_activate_all()) {
+ SS7_CRITICAL ("Failed to activate LibSngSS7!\n");
+ return FTDM_FAIL;
+ }
+
+ /*start the span monitor thread */
+ if (ftdm_thread_create_detached (ftdm_sangoma_ss7_run, span) != FTDM_SUCCESS) {
+ SS7_CRITICAL ("Failed to start Span Monitor Thread!\n");
+ return FTDM_FAIL;
+ }
+
SS7_DEBUG ("Finished starting span %s:%u.\n", span->name, span->span_id);
return FTDM_SUCCESS;
@@ -1595,6 +1617,8 @@ static FIO_SIG_UNLOAD_FUNCTION(ftdm_sangoma_ss7_unload)
{
/*this function is called by the FT-core to unload the signaling module */
+ int x;
+
ftdm_log (FTDM_LOG_INFO, "Starting ftmod_sangoma_ss7 unload...\n");
if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_CC)) {
@@ -1622,6 +1646,26 @@ static FIO_SIG_UNLOAD_FUNCTION(ftdm_sangoma_ss7_unload)
}
if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_RY)) {
+ /* go through all the relays channels and configure it */
+ x = 1;
+ while (x < (MAX_RELAY_CHANNELS)) {
+ /* check if this relay channel has been configured already */
+ if ((g_ftdm_sngss7_data.cfg.relay[x].flags & SNGSS7_CONFIGURED)) {
+
+ /* send the specific configuration */
+ if (ftmod_ss7_disable_relay_channel(x)) {
+ SS7_CRITICAL("Relay Channel %d disable failed!\n", x);
+ return 1;
+ } else {
+ SS7_INFO("Relay Channel %d disable DONE!\n", x);
+ }
+
+ /* set the SNGSS7_CONFIGURED flag */
+ g_ftdm_sngss7_data.cfg.relay[x].flags &= !SNGSS7_CONFIGURED;
+ } /* if !SNGSS7_CONFIGURED */
+ x++;
+ } /* while (x < (MAX_RELAY_CHANNELS)) */
+
ftmod_ss7_shutdown_relay();
sng_isup_free_relay();
sngss7_clear_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_RY);
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h
index 4d09dfa7e3..f88202b1a8 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h
@@ -60,6 +60,13 @@
#define MAX_SIZEOF_SUBADDR_IE 24 /* as per Q931 4.5.9 */
+typedef struct ftdm2trillium
+{
+ uint8_t ftdm_val;
+ uint8_t trillium_val;
+}ftdm2trillium_t;
+
+
typedef enum {
SNGSS7_CON_IND_EVENT = 0,
SNGSS7_CON_CFM_EVENT,
@@ -316,9 +323,23 @@ typedef struct sng_isup_ckt {
uint32_t typeCntrl;
uint32_t ssf;
uint32_t switchType;
+
uint32_t clg_nadi;
uint32_t cld_nadi;
+ uint8_t rdnis_nadi;
+
+ /* Generic Number defaults */
+ uint8_t gn_nmbqual; /* Number Qualifier */
+ uint8_t gn_nadi; /* Nature of Address indicator */
+ uint8_t gn_screen_ind; /* Screening Indicator */
+ uint8_t gn_pres_ind; /* Presentation Indicator */
+ uint8_t gn_npi; /* Numbering Plan Indicator */
+ uint8_t gn_num_inc_ind; /* Number Incomplete Indicator */
+ /* END - Generic Number defaults */
+
uint32_t min_digits;
+ uint8_t itx_auto_reply;
+ uint8_t transparent_iam;
void *obj;
uint16_t t3;
uint16_t t12;
@@ -386,6 +407,7 @@ typedef struct sng_ss7_cfg {
uint32_t procId;
char license[MAX_PATH];
char signature[MAX_PATH];
+ uint32_t transparent_iam_max_size;
uint32_t flags;
sng_relay_t relay[MAX_RELAY_CHANNELS+1];
sng_mtp1_link_t mtp1Link[MAX_MTP_LINKS+1];
@@ -503,9 +525,33 @@ typedef enum {
FLAG_GLARE = (1 << 13),
FLAG_INFID_RESUME = (1 << 14),
FLAG_INFID_PAUSED = (1 << 15),
- FLAG_RELAY_DOWN = (1 << 30)
+ FLAG_SENT_ACM = (1 << 16),
+ FLAG_RELAY_DOWN = (1 << 30),
+ FLAG_CKT_RECONFIG = (1 << 31)
} sng_ckt_flag_t;
+#define CKT_FLAGS_STRING \
+ "RX_RSC", \
+ "TX_RSC", \
+ "TX_RSC_REQ_SENT", \
+ "TX_RSC_RSP_RECIEVED", \
+ "RX_GRS", \
+ "RX_GRS_DONE", \
+ "RX_GRS_CMPLT", \
+ "GRS_BASE", \
+ "TX_GRS", \
+ "TX_GRS_REQ_SENT", \
+ "TX_GRS_RSP_RECIEVED", \
+ "REMOTE_REL", \
+ "LOCAL_REL", \
+ "GLARE", \
+ "INF_RESUME", \
+ "INF_PAUSED", \
+ "TX_ACM_SENT" \
+ "RELAY_DOWN", \
+ "CKT_RECONFIG"
+FTDM_STR2ENUM_P(ftmod_ss7_ckt_state2flag, ftmod_ss7_ckt_flag2str, sng_ckt_flag_t)
+
/* ckt blocking flags */
typedef enum {
FLAG_CKT_UCIC_BLOCK = (1 << 0),
@@ -538,6 +584,41 @@ typedef enum {
FLAG_GRP_MN_UNBLK_TX_DN = (1 << 27)
} sng_ckt_block_flag_t;
+#define BLK_FLAGS_STRING \
+ "UCIC BLK", \
+ "UCIC BLK DN", \
+ "UCIC UNBLK", \
+ "UCIC UNBLK DN", \
+ "RX LC BLK", \
+ "RX LC BLK DN", \
+ "RX LC UNBLK", \
+ "RX LC UNBLK DN", \
+ "RX CKT BLK", \
+ "RX CKT BLK DN", \
+ "RX CKT UNBLK", \
+ "RX CKT UNBLK DN", \
+ "TX CKT BLK", \
+ "TX CKT BLK DN", \
+ "TX CKT UNBLK", \
+ "TX CKT UNBLK DN", \
+ "RX GRP MN BLK", \
+ "RX GRP MN BLK DN", \
+ "RX GRP MN UNBLK", \
+ "RX GRP MN UNBLK DN", \
+ "TX GRP MN BLK", \
+ "TX GRP MN BLK DN", \
+ "TX GRP MN UNBLK", \
+ "TX GRP MN UNBLK DN", \
+ "RX GRP HW BLK", \
+ "RX GRP HW BLK DN", \
+ "RX GRP HW UNBLK", \
+ "RX GRP HW UNBLK DN", \
+ "TX GRP HW BLK", \
+ "TX GRP HW BLK DN", \
+ "TX GRP HW UNBLK", \
+ "TX GRP HW UNBLK DN"
+FTDM_STR2ENUM_P(ftmod_ss7_blk_state2flag, ftmod_ss7_blk_flag2str, sng_ckt_block_flag_t)
+
/* valid for every cfg array except circuits */
typedef enum {
SNGSS7_CONFIGURED = (1 << 0),
@@ -626,12 +707,17 @@ int ftmod_ss7_shutdown_isup(void);
int ftmod_ss7_shutdown_mtp3(void);
int ftmod_ss7_shutdown_mtp2(void);
int ftmod_ss7_shutdown_relay(void);
+int ftmod_ss7_disable_relay_channel(uint32_t chanId);
int ftmod_ss7_disable_grp_mtp3Link(uint32_t procId);
int ftmod_ss7_enable_grp_mtp3Link(uint32_t procId);
int ftmod_ss7_disable_grp_mtp2Link(uint32_t procId);
+int ftmod_ss7_block_isup_ckt(uint32_t cktId);
+int ftmod_ss7_unblock_isup_ckt(uint32_t cktId);
+
+
/* in ftmod_sangoma_ss7_sta.c */
int ftmod_ss7_mtp1link_sta(uint32_t id, L1Mngmt *cfm);
int ftmod_ss7_mtp2link_sta(uint32_t id, SdMngmt *cfm);
@@ -661,6 +747,9 @@ void ft_to_sngss7_cgba(ftdm_channel_t * ftdmchan);
void ft_to_sngss7_cgua(ftdm_channel_t * ftdmchan);
void ft_to_sngss7_cgb(ftdm_channel_t * ftdmchan);
void ft_to_sngss7_cgu(ftdm_channel_t * ftdmchan);
+void ft_to_sngss7_itx (ftdm_channel_t * ftdmchan);
+void ft_to_sngss7_txa (ftdm_channel_t * ftdmchan);
+
/* in ftmod_sangoma_ss7_in.c */
void sngss7_sta_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
@@ -678,6 +767,10 @@ void sngss7_resm_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiR
void sngss7_susp_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiSuspEvnt *siSuspEvnt);
void sngss7_ssp_sta_cfm(uint32_t infId);
+ftdm_status_t sngss7_bufferzero_iam(SiConEvnt *siConEvnt);
+ftdm_status_t sngss7_retrieve_iam(ftdm_channel_t *ftdmchan, SiConEvnt *siConEvnt);
+ftdm_status_t sngss7_save_iam(ftdm_channel_t *ftdmchan, SiConEvnt *siConEvnt);
+
/* in ftmod_sangoma_ss7_handle.c */
ftdm_status_t handle_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiConEvnt *siConEvnt);
ftdm_status_t handle_con_sta(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiCnStEvnt *siCnStEvnt, uint8_t evntType);
@@ -718,12 +811,25 @@ int ftmod_ss7_parse_xml(ftdm_conf_parameter_t *ftdm_parameters, ftdm_span_t *spa
ftdm_status_t ftdm_sngss7_handle_cli_cmd(ftdm_stream_handle_t *stream, const char *data);
/* in ftmod_sangoma_ss7_support.c */
-uint8_t copy_cgPtyNum_from_sngss7(ftdm_caller_data_t *ftdm, SiCgPtyNum *cgPtyNum);
-uint8_t copy_cgPtyNum_to_sngss7(ftdm_caller_data_t *ftdm, SiCgPtyNum *cgPtyNum);
-uint8_t copy_cdPtyNum_from_sngss7(ftdm_caller_data_t *ftdm, SiCdPtyNum *cdPtyNum);
-uint8_t copy_cdPtyNum_to_sngss7(ftdm_caller_data_t *ftdm, SiCdPtyNum *cdPtyNum);
-uint8_t copy_tknStr_from_sngss7(TknStr str, char *ftdm, TknU8 oddEven);
-uint8_t append_tknStr_from_sngss7(TknStr str, char *ftdm, TknU8 oddEven);
+ftdm_status_t copy_cgPtyNum_from_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyNum *cgPtyNum);
+ftdm_status_t copy_cgPtyNum_to_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyNum *cgPtyNum);
+ftdm_status_t copy_cdPtyNum_from_sngss7(ftdm_channel_t *ftdmchan, SiCdPtyNum *cdPtyNum);
+ftdm_status_t copy_cdPtyNum_to_sngss7(ftdm_channel_t *ftdmchan, SiCdPtyNum *cdPtyNum);
+ftdm_status_t copy_redirgNum_to_sngss7(ftdm_channel_t *ftdmchan, SiRedirNum *redirgNum);
+ftdm_status_t copy_redirgNum_from_sngss7(ftdm_channel_t *ftdmchan, SiRedirNum *redirgNum);
+ftdm_status_t copy_genNmb_to_sngss7(ftdm_channel_t *ftdmchan, SiGenNum *genNmb);
+ftdm_status_t copy_genNmb_from_sngss7(ftdm_channel_t *ftdmchan, SiGenNum *genNmb);
+ftdm_status_t copy_cgPtyCat_to_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyCat *cgPtyCat);
+ftdm_status_t copy_cgPtyCat_from_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyCat *cgPtyCat);
+ftdm_status_t copy_accTrnspt_to_sngss7(ftdm_channel_t *ftdmchan, SiAccTrnspt *accTrnspt);
+ftdm_status_t copy_natConInd_to_sngss7(ftdm_channel_t *ftdmchan, SiNatConInd *natConInd);
+ftdm_status_t copy_fwdCallInd_to_sngss7(ftdm_channel_t *ftdmchan, SiFwdCallInd *fwdCallInd);
+ftdm_status_t copy_txMedReq_to_sngss7(ftdm_channel_t *ftdmchan, SiTxMedReq *txMedReq);
+ftdm_status_t copy_usrServInfoA_to_sngss7(ftdm_channel_t *ftdmchan, SiUsrServInfo *usrServInfoA);
+
+ftdm_status_t copy_tknStr_from_sngss7(TknStr str, char *ftdm, TknU8 oddEven);
+ftdm_status_t append_tknStr_from_sngss7(TknStr str, char *ftdm, TknU8 oddEven);
+ftdm_status_t copy_tknStr_to_sngss7(char* str, TknStr *tknStr, TknU8 *oddEven);
int check_for_state_change(ftdm_channel_t *ftdmchan);
int check_cics_in_range(sngss7_chan_data_t *sngss7_info);
@@ -756,6 +862,7 @@ int find_ssf_type_in_map(const char *ssfType);
int find_cic_cntrl_in_map(const char *cntrlType);
ftdm_status_t check_status_of_all_isup_intf(void);
+ftdm_status_t check_for_reconfig_flag(ftdm_span_t *ftdmspan);
void sngss7_send_signal(sngss7_chan_data_t *sngss7_info, ftdm_signal_event_t event_id);
void sngss7_set_sig_status(sngss7_chan_data_t *sngss7_info, ftdm_signaling_status_t status);
@@ -767,6 +874,13 @@ void handle_isup_t35(void *userdata);
/******************************************************************************/
/* MACROS *********************************************************************/
+#define SS7_STATE_CHANGE(ftdmchan, new_state) \
+if (ftdmchan->state == new_state) { \
+ ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_IDLE); \
+} else { \
+ ftdm_set_state(ftdmchan, new_state); \
+}
+
#define SS7_DEBUG(a,...) ftdm_log(FTDM_LOG_DEBUG,a , ##__VA_ARGS__ );
#define SS7_INFO(a,...) ftdm_log(FTDM_LOG_INFO,a , ##__VA_ARGS__ );
#define SS7_WARN(a,...) ftdm_log(FTDM_LOG_WARNING,a , ##__VA_ARGS__ );
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c
index 96446b4215..91b8900fef 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c
@@ -36,10 +36,8 @@
/******************************************************************************/
/* DEFINES ********************************************************************/
-/******************************************************************************/
/* GLOBALS ********************************************************************/
-/******************************************************************************/
/* PROTOTYPES *****************************************************************/
void ft_to_sngss7_iam(ftdm_channel_t * ftdmchan);
@@ -66,242 +64,74 @@ void ft_to_sngss7_cgu(ftdm_channel_t * ftdmchan);
void ft_to_sngss7_cgba(ftdm_channel_t * ftdmchan);
void ft_to_sngss7_cgua(ftdm_channel_t * ftdmchan);
-/******************************************************************************/
/* FUNCTIONS ******************************************************************/
void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan)
-{
- SS7_FUNC_TRACE_ENTER (__FUNCTION__);
-
- sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;;
- const char *clg_nadi = NULL;
- const char *cld_nadi = NULL;
- const char *clg_subAddr = NULL;
- const char *cld_subAddr = NULL;
- char subAddrIE[MAX_SIZEOF_SUBADDR_IE];
+{
SiConEvnt iam;
+ sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;;
+
+ SS7_FUNC_TRACE_ENTER (__FUNCTION__);
sngss7_info->suInstId = get_unique_id ();
sngss7_info->spInstId = 0;
sngss7_info->spId = 1;
memset (&iam, 0x0, sizeof (iam));
-
- /* copy down the nature of connection indicators */
- iam.natConInd.eh.pres = PRSNT_NODEF;
- iam.natConInd.satInd.pres = PRSNT_NODEF;
- iam.natConInd.satInd.val = 0; /* no satellite circuit */
- iam.natConInd.contChkInd.pres = PRSNT_NODEF;
- iam.natConInd.contChkInd.val = CONTCHK_NOTREQ;
- iam.natConInd.echoCntrlDevInd.pres = PRSNT_NODEF;
- iam.natConInd.echoCntrlDevInd.val = ECHOCDEV_INCL;
-
- /* copy down the forward call indicators */
- iam.fwdCallInd.eh.pres = PRSNT_NODEF;
- iam.fwdCallInd.natIntCallInd.pres = PRSNT_NODEF;
- iam.fwdCallInd.natIntCallInd.val = 0x00;
- iam.fwdCallInd.end2EndMethInd.pres = PRSNT_NODEF;
- iam.fwdCallInd.end2EndMethInd.val = E2EMTH_NOMETH;
- iam.fwdCallInd.intInd.pres = PRSNT_NODEF;
- iam.fwdCallInd.intInd.val = INTIND_NOINTW;
- iam.fwdCallInd.end2EndInfoInd.pres = PRSNT_NODEF;
- iam.fwdCallInd.end2EndInfoInd.val = E2EINF_NOINFO;
- iam.fwdCallInd.isdnUsrPrtInd.pres = PRSNT_NODEF;
- iam.fwdCallInd.isdnUsrPrtInd.val = ISUP_USED;
- iam.fwdCallInd.isdnUsrPrtPrfInd.pres = PRSNT_NODEF;
- iam.fwdCallInd.isdnUsrPrtPrfInd.val = PREF_PREFAW;
- iam.fwdCallInd.isdnAccInd.pres = PRSNT_NODEF;
- iam.fwdCallInd.isdnAccInd.val = ISDNACC_ISDN;
- iam.fwdCallInd.sccpMethInd.pres = PRSNT_NODEF;
- iam.fwdCallInd.sccpMethInd.val = SCCPMTH_NOIND;
-
- /* copy down the calling number information */
- iam.cgPtyCat.eh.pres = PRSNT_NODEF;
- iam.cgPtyCat.cgPtyCat.pres = PRSNT_NODEF;
- iam.cgPtyCat.cgPtyCat.val = CAT_ORD; /* ordinary suscriber */
-
- /* copy down the transmission medium requirements */
- iam.txMedReq.eh.pres = PRSNT_NODEF;
- iam.txMedReq.trMedReq.pres = PRSNT_NODEF;
- iam.txMedReq.trMedReq.val = ftdmchan->caller_data.bearer_capability;
- if ((g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].switchType == LSI_SW_ANS88) ||
- (g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].switchType == LSI_SW_ANS92) ||
- (g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].switchType == LSI_SW_ANS95)) {
-
- /* include only if we're running ANSI */
- iam.fwdCallInd.transCallNInd.pres = PRSNT_NODEF;
- iam.fwdCallInd.transCallNInd.val = 0x0;
-
- iam.usrServInfoA.eh.pres = PRSNT_NODEF;
-
- iam.usrServInfoA.infoTranCap.pres = PRSNT_NODEF;
- switch (ftdmchan->caller_data.bearer_capability) {
- /**********************************************************************/
- case (FTDM_BEARER_CAP_SPEECH):
- iam.usrServInfoA.infoTranCap.val = 0x0; /* speech as per ATIS-1000113.3.2005 */
- break;
- /**********************************************************************/
- case (FTDM_BEARER_CAP_64K_UNRESTRICTED):
- iam.usrServInfoA.infoTranCap.val = 0x8; /* unrestricted digital as per ATIS-1000113.3.2005 */
- break;
- /**********************************************************************/
- case (FTDM_BEARER_CAP_3_1KHZ_AUDIO):
- iam.usrServInfoA.infoTranCap.val = 0x10; /* 3.1kHz audio as per ATIS-1000113.3.2005 */
- break;
- /**********************************************************************/
- default:
- SS7_ERROR_CHAN(ftdmchan, "Unknown Bearer capability falling back to speech%s\n", " ");
- iam.usrServInfoA.infoTranCap.val = 0x0; /* speech as per ATIS-1000113.3.2005 */
- break;
- /**********************************************************************/
- } /* switch (ftdmchan->caller_data.bearer_capability) */
-
- iam.usrServInfoA.cdeStand.pres = PRSNT_NODEF;
- iam.usrServInfoA.cdeStand.val = 0x0; /* ITU-T standardized coding */
- iam.usrServInfoA.tranMode.pres = PRSNT_NODEF;
- iam.usrServInfoA.tranMode.val = 0x0; /* circuit mode */
- iam.usrServInfoA.infoTranRate0.pres = PRSNT_NODEF;
- iam.usrServInfoA.infoTranRate0.val = 0x10; /* 64kbps origination to destination */
- iam.usrServInfoA.infoTranRate1.pres = PRSNT_NODEF;
- iam.usrServInfoA.infoTranRate1.val = 0x10; /* 64kbps destination to origination */
- iam.usrServInfoA.chanStruct.pres = PRSNT_NODEF;
- iam.usrServInfoA.chanStruct.val = 0x1; /* 8kHz integrity */
- iam.usrServInfoA.config.pres = PRSNT_NODEF;
- iam.usrServInfoA.config.val = 0x0; /* point to point configuration */
- iam.usrServInfoA.establish.pres = PRSNT_NODEF;
- iam.usrServInfoA.establish.val = 0x0; /* on demand */
- iam.usrServInfoA.symmetry.pres = PRSNT_NODEF;
- iam.usrServInfoA.symmetry.val = 0x0; /* bi-directional symmetric */
- iam.usrServInfoA.usrInfLyr1Prot.pres = PRSNT_NODEF;
- iam.usrServInfoA.usrInfLyr1Prot.val = 0x2; /* G.711 ulaw */
- iam.usrServInfoA.rateMultiplier.pres = PRSNT_NODEF;
- iam.usrServInfoA.rateMultiplier.val = 0x1; /* 1x rate multipler */
- } /* if ANSI */
-
- /* copy down the called number information */
- copy_cdPtyNum_to_sngss7 (&ftdmchan->caller_data, &iam.cdPtyNum);
-
- /* copy down the calling number information */
-
- copy_cgPtyNum_to_sngss7 (&ftdmchan->caller_data, &iam.cgPtyNum);
-
- /* check if the user would like a custom NADI value for the calling Pty Num */
- clg_nadi = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_clg_nadi");
- if ((clg_nadi != NULL) && (*clg_nadi)) {
- SS7_DEBUG_CHAN(ftdmchan,"Found user supplied Calling NADI value \"%s\"\n", clg_nadi);
- iam.cgPtyNum.natAddrInd.val = atoi(clg_nadi);
+ if (sngss7_info->circuit->transparent_iam &&
+ sngss7_retrieve_iam(ftdmchan, &iam) == FTDM_SUCCESS) {
+ SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx IAM (Transparent)\n", sngss7_info->circuit->cic);
} else {
- iam.cgPtyNum.natAddrInd.val = g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].clg_nadi;
- SS7_DEBUG_CHAN(ftdmchan,"No user supplied NADI value found for CLG, using \"%d\"\n", iam.cgPtyNum.natAddrInd.val);
- }
+ /* Nature of Connection Indicators */
+ copy_natConInd_to_sngss7(ftdmchan, &iam.natConInd);
- cld_nadi = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_cld_nadi");
- if ((cld_nadi != NULL) && (*cld_nadi)) {
- SS7_DEBUG_CHAN(ftdmchan,"Found user supplied Called NADI value \"%s\"\n", cld_nadi);
- iam.cdPtyNum.natAddrInd.val = atoi(cld_nadi);
- } else {
- iam.cdPtyNum.natAddrInd.val = g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].cld_nadi;
- SS7_DEBUG_CHAN(ftdmchan,"No user supplied NADI value found for CLD, using \"%d\"\n", iam.cdPtyNum.natAddrInd.val);
- }
+ /* Forward Call Indicators */
+ copy_fwdCallInd_to_sngss7(ftdmchan, &iam.fwdCallInd);
- /* check if the user would like us to send a clg_sub-address */
- clg_subAddr = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_clg_subaddr");
- if ((clg_subAddr != NULL) && (*clg_subAddr)) {
- SS7_DEBUG_CHAN(ftdmchan,"Found user supplied Calling Sub-Address value \"%s\"\n", clg_subAddr);
+ /* Transmission medium requirements */
+ copy_txMedReq_to_sngss7(ftdmchan, &iam.txMedReq);
+
+ /* User Service Info A */
+ copy_usrServInfoA_to_sngss7(ftdmchan, &iam.usrServInfoA);
- /* clean out the subAddrIE */
- memset(subAddrIE, 0x0, sizeof(subAddrIE));
-
- /* check the first character in the sub-address to see what type of encoding to use */
- switch (clg_subAddr[0]) {
- case '0': /* NSAP */
- encode_subAddrIE_nsap(&clg_subAddr[1], subAddrIE, SNG_CALLING);
- break;
- case '1': /* national variant */
- encode_subAddrIE_nat(&clg_subAddr[1], subAddrIE, SNG_CALLING);
- break;
- default:
- SS7_ERROR_CHAN(ftdmchan,"Invalid Calling Sub-Address encoding requested: %c\n", clg_subAddr[0]);
- break;
- } /* switch (cld_subAddr[0]) */
-
-
- /* if subaddIE is still empty don't copy it in */
- if (subAddrIE[0] != '0') {
- /* check if the clg_subAddr has already been added */
- if (iam.accTrnspt.eh.pres == PRSNT_NODEF) {
- /* append the subAddrIE */
- memcpy(&iam.accTrnspt.infoElmts.val[iam.accTrnspt.infoElmts.len], subAddrIE, (subAddrIE[1] + 2));
- iam.accTrnspt.infoElmts.len = iam.accTrnspt.infoElmts.len +subAddrIE[1] + 2;
- } else {
- /* fill in from the beginning */
- iam.accTrnspt.eh.pres = PRSNT_NODEF;
- iam.accTrnspt.infoElmts.pres = PRSNT_NODEF;
- memcpy(iam.accTrnspt.infoElmts.val, subAddrIE, (subAddrIE[1] + 2));
- iam.accTrnspt.infoElmts.len = subAddrIE[1] + 2;
- } /* if (iam.accTrnspt.eh.pres */
- } /* if (subAddrIE[0] != '0') */
- }
-
- /* check if the user would like us to send a cld_sub-address */
- cld_subAddr = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_cld_subaddr");
- if ((cld_subAddr != NULL) && (*cld_subAddr)) {
- SS7_DEBUG_CHAN(ftdmchan,"Found user supplied Called Sub-Address value \"%s\"\n", cld_subAddr);
+ /* Called Number information */
+ copy_cdPtyNum_to_sngss7(ftdmchan, &iam.cdPtyNum);
- /* clean out the subAddrIE */
- memset(subAddrIE, 0x0, sizeof(subAddrIE));
+ /* Calling Number information */
+ copy_cgPtyNum_to_sngss7(ftdmchan, &iam.cgPtyNum);
- /* check the first character in the sub-address to see what type of encoding to use */
- switch (cld_subAddr[0]) {
- case '0': /* NSAP */
- encode_subAddrIE_nsap(&cld_subAddr[1], subAddrIE, SNG_CALLED);
- break;
- case '1': /* national variant */
- encode_subAddrIE_nat(&cld_subAddr[1], subAddrIE, SNG_CALLED);
- break;
- default:
- SS7_ERROR_CHAN(ftdmchan,"Invalid Called Sub-Address encoding requested: %c\n", cld_subAddr[0]);
- break;
- } /* switch (cld_subAddr[0]) */
+ /* Generic Number information */
+ copy_genNmb_to_sngss7(ftdmchan, &iam.genNmb);
- /* if subaddIE is still empty don't copy it in */
- if (subAddrIE[0] != '0') {
- /* check if the cld_subAddr has already been added */
- if (iam.accTrnspt.eh.pres == PRSNT_NODEF) {
- /* append the subAddrIE */
- memcpy(&iam.accTrnspt.infoElmts.val[iam.accTrnspt.infoElmts.len], subAddrIE, (subAddrIE[1] + 2));
- iam.accTrnspt.infoElmts.len = iam.accTrnspt.infoElmts.len +subAddrIE[1] + 2;
- } else {
- /* fill in from the beginning */
- iam.accTrnspt.eh.pres = PRSNT_NODEF;
- iam.accTrnspt.infoElmts.pres = PRSNT_NODEF;
- memcpy(iam.accTrnspt.infoElmts.val, subAddrIE, (subAddrIE[1] + 2));
- iam.accTrnspt.infoElmts.len = subAddrIE[1] + 2;
- } /* if (iam.accTrnspt.eh.pres */
- } /* if (subAddrIE[0] != '0') */
- } /* if ((cld_subAddr != NULL) && (*cld_subAddr)) */
+ /* Calling Party's Category */
+ copy_cgPtyCat_to_sngss7(ftdmchan, &iam.cgPtyCat);
+
+ /* Redirecting Number */
+ copy_redirgNum_to_sngss7(ftdmchan, &iam.redirgNum);
+
+ /* Access Transport */
+ copy_accTrnspt_to_sngss7(ftdmchan, &iam.accTrnspt);
+
+ SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx IAM clg = \"%s\" (NADI=%d), cld = \"%s\" (NADI=%d)\n",
+ sngss7_info->circuit->cic,
+ ftdmchan->caller_data.cid_num.digits,
+ iam.cgPtyNum.natAddrInd.val,
+ ftdmchan->caller_data.dnis.digits,
+ iam.cdPtyNum.natAddrInd.val);
+ }
sng_cc_con_request (sngss7_info->spId,
sngss7_info->suInstId,
sngss7_info->spInstId,
- sngss7_info->circuit->id,
- &iam,
+ sngss7_info->circuit->id,
+ &iam,
0);
- SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx IAM clg = \"%s\" (NADI=%d), cld = \"%s\" (NADI=%d)\n",
- sngss7_info->circuit->cic,
- ftdmchan->caller_data.cid_num.digits,
- iam.cgPtyNum.natAddrInd.val,
- ftdmchan->caller_data.dnis.digits,
- iam.cdPtyNum.natAddrInd.val);
-
-
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
return;
}
-/******************************************************************************/
void ft_to_sngss7_acm (ftdm_channel_t * ftdmchan)
{
SS7_FUNC_TRACE_ENTER (__FUNCTION__);
@@ -338,7 +168,7 @@ void ft_to_sngss7_acm (ftdm_channel_t * ftdmchan)
acm.bckCallInd.echoCtrlDevInd.val = 0x1;
break;
/**********************************************************************/
- case (FTDM_BEARER_CAP_64K_UNRESTRICTED):
+ case (FTDM_BEARER_CAP_UNRESTRICTED):
acm.bckCallInd.echoCtrlDevInd.val = 0x0;
break;
/**********************************************************************/
@@ -381,7 +211,6 @@ void ft_to_sngss7_acm (ftdm_channel_t * ftdmchan)
return;
}
-/******************************************************************************/
void ft_to_sngss7_anm (ftdm_channel_t * ftdmchan)
{
SS7_FUNC_TRACE_ENTER (__FUNCTION__);
@@ -891,6 +720,69 @@ void ft_to_sngss7_cgu(ftdm_channel_t * ftdmchan)
return;
}
+/* French SPIROU send Charge Unit */
+/* No one calls this function yet, but it has been implemented to complement TXA messages */
+void ft_to_sngss7_itx (ftdm_channel_t * ftdmchan)
+{
+#ifndef SANGOMA_SPIROU
+ SS7_FUNC_TRACE_ENTER (__FUNCTION__);
+ ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "ITX message not supported!, please update your libsng_ss7\n");
+#else
+ const char* var = NULL;
+ sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
+ SiCnStEvnt itx;
+
+ SS7_FUNC_TRACE_ENTER (__FUNCTION__);
+
+ memset (&itx, 0x0, sizeof (itx));
+
+ itx.msgNum.eh.pres = PRSNT_NODEF;
+ itx.msgNum.msgNum.pres = PRSNT_NODEF;
+ var = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_itx_msg_num");
+ if (!ftdm_strlen_zero(var)) {
+ itx.msgNum.msgNum.val = atoi(var);
+ } else {
+ itx.msgNum.msgNum.val = 0x1;
+ }
+
+ itx.chargUnitNum.eh.pres = PRSNT_NODEF;
+ itx.chargUnitNum.chargUnitNum.pres = PRSNT_NODEF;
+ var = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_itx_charge_unit");
+ if (!ftdm_strlen_zero(var)) {
+ itx.chargUnitNum.chargUnitNum.val = atoi(var);
+ } else {
+ itx.chargUnitNum.chargUnitNum.val = 0x1;
+ }
+
+ ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "ITX Charging Unit:%d Msg Num:%d\n", itx.chargUnitNum.chargUnitNum.val, itx.msgNum.msgNum.val);
+ sng_cc_con_status (1, sngss7_info->suInstId, sngss7_info->spInstId, sngss7_info->circuit->id, &itx, CHARGE_UNIT);
+
+ SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx ITX\n", sngss7_info->circuit->cic);
+#endif
+ SS7_FUNC_TRACE_EXIT (__FUNCTION__);
+ return;
+}
+
+/* French SPIROU send Charging Acknowledgement */
+void ft_to_sngss7_txa (ftdm_channel_t * ftdmchan)
+{
+#ifndef SANGOMA_SPIROU
+ SS7_FUNC_TRACE_ENTER (__FUNCTION__);
+ ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "TXA message not supported!, please update your libsng_ss7\n");
+#else
+ SiCnStEvnt txa;
+ sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
+ SS7_FUNC_TRACE_ENTER (__FUNCTION__);
+
+ memset (&txa, 0x0, sizeof(txa));
+
+ sng_cc_con_status(1, sngss7_info->suInstId, sngss7_info->spInstId, sngss7_info->circuit->id, &txa, CHARGE_ACK);
+
+ SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx TXA\n", sngss7_info->circuit->cic);
+#endif
+ SS7_FUNC_TRACE_EXIT (__FUNCTION__);
+ return;
+}
/******************************************************************************/
/* For Emacs:
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_relay.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_relay.c
index d003371ff2..1af538d727 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_relay.c
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_relay.c
@@ -45,10 +45,11 @@
ftdm_status_t handle_relay_connect(RyMngmt *sta);
ftdm_status_t handle_relay_disconnect(RyMngmt *sta);
-static ftdm_status_t enable_all_ckts_for_relay(void);
+/*static ftdm_status_t enable_all_ckts_for_relay(void);*/
static ftdm_status_t reconfig_all_ckts_for_relay(void);
static ftdm_status_t disable_all_ckts_for_relay(void);
static ftdm_status_t block_all_ckts_for_relay(uint32_t procId);
+static ftdm_status_t unblock_all_ckts_for_relay(uint32_t procId);
static ftdm_status_t disable_all_sigs_for_relay(uint32_t procId);
static ftdm_status_t disble_all_mtp2_sigs_for_relay(void);
/******************************************************************************/
@@ -61,12 +62,12 @@ ftdm_status_t handle_relay_connect(RyMngmt *sta)
/* test if this is the first time the channel comes up */
if (!sngss7_test_flag(sng_relay, SNGSS7_RELAY_INIT)) {
- SS7_DEBUG("Relay Channel %d initial connection UP\n", sng_relay->id);
+ SS7_INFO("Relay Channel %d initial connection UP\n", sng_relay->id);
/* mark the channel as being up */
sngss7_set_flag(sng_relay, SNGSS7_RELAY_INIT);
} else {
- SS7_DEBUG("Relay Channel %d connection UP\n", sng_relay->id);
+ SS7_INFO("Relay Channel %d connection UP\n", sng_relay->id);
/* react based on type of channel */
switch (sng_relay->type) {
@@ -75,18 +76,17 @@ ftdm_status_t handle_relay_connect(RyMngmt *sta)
/* reconfigure all ISUP ckts, since the main system would have lost all configs */
if (reconfig_all_ckts_for_relay()) {
SS7_ERROR("Failed to reconfigure ISUP Ckts!\n");
-
/* we're done....this is very bad! */
- } else {
- enable_all_ckts_for_relay();
}
-
break;
/******************************************************************/
case (LRY_CT_TCP_SERVER):
- /*unblock_all_ckts_for_relay(sta->t.usta.s.ryErrUsta.errPid);*/
+ /* bring the sig links on the client system back up */
ftmod_ss7_enable_grp_mtp3Link(sta->t.usta.s.ryUpUsta.id);
-
+
+ /* unbloock the ckts on the client system */
+ unblock_all_ckts_for_relay(sta->t.usta.s.ryUpUsta.id);
+
break;
/******************************************************************/
default:
@@ -104,16 +104,20 @@ ftdm_status_t handle_relay_disconnect_on_error(RyMngmt *sta)
/* check which procId is in error, if it is 1, disable the ckts */
if (sta->t.usta.s.ryErrUsta.errPid == 1 ) {
- disable_all_ckts_for_relay();
-
+ /* we've lost the server, bring down the mtp2 links */
disble_all_mtp2_sigs_for_relay();
+
+ /* we've lost the server, bring the sig status down on all ckts */
+ disable_all_ckts_for_relay();
}
/* check if the channel is a server, means we just lost a MGW */
if (g_ftdm_sngss7_data.cfg.relay[sta->t.usta.s.ryErrUsta.errPid].type == LRY_CT_TCP_SERVER) {
- block_all_ckts_for_relay(sta->t.usta.s.ryErrUsta.errPid);
-
+ /* we've lost the client, bring down all mtp3 links for this procId */
disable_all_sigs_for_relay(sta->t.usta.s.ryErrUsta.errPid);
+
+ /* we've lost the client, bring down all the ckts for this procId */
+ block_all_ckts_for_relay(sta->t.usta.s.ryErrUsta.errPid);
}
return FTDM_SUCCESS;
@@ -170,7 +174,7 @@ ftdm_status_t disable_all_ckts_for_relay(void)
return FTDM_SUCCESS;
}
-
+#if 0
/******************************************************************************/
ftdm_status_t enable_all_ckts_for_relay(void)
{
@@ -218,34 +222,33 @@ ftdm_status_t enable_all_ckts_for_relay(void)
return FTDM_SUCCESS;
}
-
+#endif
/******************************************************************************/
ftdm_status_t reconfig_all_ckts_for_relay(void)
{
-#if 1
int x;
- int ret;
+ sngss7_chan_data_t *sngss7_info = NULL;
+ /* go through all the circuits on our ProcId */
x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;
while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
+ /**************************************************************************/
if ( g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) {
-
- ret = ftmod_ss7_isup_ckt_config(x);
- if (ret) {
- SS7_CRITICAL("ISUP CKT %d configuration FAILED (%d)!\n", x, ret);
- return 1;
- } else {
- SS7_INFO("ISUP CKT %d configuration DONE!\n", x);
- }
+ /* grab the private data structure */
+ sngss7_info = g_ftdm_sngss7_data.cfg.isupCkt[x].obj;
+
+ /* mark the circuit for re-configuration */
+ sngss7_set_ckt_flag(sngss7_info, FLAG_CKT_RECONFIG);
- } /* if ( g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) */
+ /* clear the relay flag */
+ sngss7_clear_ckt_flag(sngss7_info, FLAG_RELAY_DOWN);
+ }
- /* set the SNGSS7_CONFIGURED flag */
- g_ftdm_sngss7_data.cfg.isupCkt[x].flags |= SNGSS7_CONFIGURED;
-
+ /* move to the next circuit */
x++;
+ /**************************************************************************/
} /* while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) */
-#endif
+
return FTDM_SUCCESS;
}
@@ -253,23 +256,26 @@ ftdm_status_t reconfig_all_ckts_for_relay(void)
ftdm_status_t block_all_ckts_for_relay(uint32_t procId)
{
int x;
-
- SS7_INFO("BLOcking all ckts on ProcID = %d\n", procId);
+ int ret;
/* we just lost connection to this procId, send out a block for all these circuits */
x = (procId * 1000) + 1;
while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
/**************************************************************************/
if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) {
- /* send out a BLO */
- sng_cc_sta_request (1,
- 0,
- 0,
- g_ftdm_sngss7_data.cfg.isupCkt[x].id,
- 0,
- SIT_STA_CIRBLOREQ,
- NULL);
+ /* send a block request via stack manager */
+ ret = ftmod_ss7_block_isup_ckt(g_ftdm_sngss7_data.cfg.isupCkt[x].id);
+ if (ret) {
+ SS7_INFO("Successfully BLOcked CIC:%d(ckt:%d) due to Relay failure\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[x].cic,
+ g_ftdm_sngss7_data.cfg.isupCkt[x].id);
+ } else {
+ SS7_ERROR("Failed to BLOck CIC:%d(ckt:%d) due to Relay failure\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[x].cic,
+ g_ftdm_sngss7_data.cfg.isupCkt[x].id);
+ }
+
} /* if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) */
/* move along */
@@ -304,6 +310,42 @@ ftdm_status_t disble_all_mtp2_sigs_for_relay(void)
}
+/******************************************************************************/
+static ftdm_status_t unblock_all_ckts_for_relay(uint32_t procId)
+{
+ int x;
+ int ret;
+
+ /* we just got connection to this procId, send out a unblock for all these circuits
+ * since we blocked them when we lost the connection
+ */
+ x = (procId * 1000) + 1;
+ while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
+ /**************************************************************************/
+ if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) {
+
+ /* send a block request via stack manager */
+ ret = ftmod_ss7_unblock_isup_ckt(g_ftdm_sngss7_data.cfg.isupCkt[x].id);
+ if (ret) {
+ SS7_INFO("Successfully unblocked CIC:%d(ckt:%d) due to Relay connection\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[x].cic,
+ g_ftdm_sngss7_data.cfg.isupCkt[x].id);
+ } else {
+ SS7_ERROR("Failed to unblock CIC:%d(ckt:%d) due to Relay connection\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[x].cic,
+ g_ftdm_sngss7_data.cfg.isupCkt[x].id);
+ }
+
+ } /* if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) */
+
+ /* move along */
+ x++;
+ /**************************************************************************/
+ } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) */
+
+ return FTDM_SUCCESS;
+}
+
/******************************************************************************/
/* For Emacs:
* Local Variables:
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c
index 9296dbc08a..e61153c8e7 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c
@@ -33,6 +33,9 @@
/* INCLUDE ********************************************************************/
#include "ftmod_sangoma_ss7_main.h"
+#ifdef HAVE_ZLIB
+#include
+#endif
/******************************************************************************/
/* DEFINES ********************************************************************/
@@ -43,13 +46,6 @@ uint32_t sngss7_id;
/******************************************************************************/
/* PROTOTYPES *****************************************************************/
-uint8_t copy_tknStr_from_sngss7(TknStr str, char *ftdm, TknU8 oddEven);
-uint8_t append_tknStr_from_sngss7(TknStr str, char *ftdm, TknU8 oddEven);
-uint8_t copy_cgPtyNum_from_sngss7(ftdm_caller_data_t *ftdm, SiCgPtyNum *cgPtyNum);
-uint8_t copy_cgPtyNum_to_sngss7(ftdm_caller_data_t *ftdm, SiCgPtyNum *cgPtyNum);
-uint8_t copy_cdPtyNum_from_sngss7(ftdm_caller_data_t *ftdm, SiCdPtyNum *cdPtyNum);
-uint8_t copy_cdPtyNum_to_sngss7(ftdm_caller_data_t *ftdm, SiCdPtyNum *cdPtyNum);
-
int check_for_state_change(ftdm_channel_t *ftdmchan);
int check_cics_in_range(sngss7_chan_data_t *sngss7_info);
int check_for_reset(sngss7_chan_data_t *sngss7_info);
@@ -83,6 +79,7 @@ int find_ssf_type_in_map(const char *ssfType);
int find_cic_cntrl_in_map(const char *cntrlType);
ftdm_status_t check_status_of_all_isup_intf(void);
+ftdm_status_t check_for_reconfig_flag(ftdm_span_t *ftdmspan);
void sngss7_send_signal(sngss7_chan_data_t *sngss7_info, ftdm_signal_event_t event_id);
void sngss7_set_sig_status(sngss7_chan_data_t *sngss7_info, ftdm_signaling_status_t status);
@@ -90,251 +87,604 @@ ftdm_status_t sngss7_add_var(sngss7_chan_data_t *ss7_info, const char* var, cons
ftdm_status_t sngss7_add_raw_data(sngss7_chan_data_t *sngss7_info, uint8_t* data, ftdm_size_t data_len);
/******************************************************************************/
-/* FUNCTIONS ******************************************************************/
-uint8_t copy_cgPtyNum_from_sngss7(ftdm_caller_data_t *ftdm, SiCgPtyNum *cgPtyNum)
-{
+FTDM_ENUM_NAMES(CKT_FLAGS_NAMES, CKT_FLAGS_STRING)
+FTDM_STR2ENUM(ftmod_ss7_ckt_state2flag, ftmod_ss7_ckt_flag2str, sng_ckt_flag_t, CKT_FLAGS_NAMES, 31)
- return 0;
+FTDM_ENUM_NAMES(BLK_FLAGS_NAMES, BLK_FLAGS_STRING)
+FTDM_STR2ENUM(ftmod_ss7_blk_state2flag, ftmod_ss7_blk_flag2str, sng_ckt_block_flag_t, BLK_FLAGS_NAMES, 31)
+
+/* FUNCTIONS ******************************************************************/
+static uint8_t get_trillium_val(ftdm2trillium_t *vals, uint8_t ftdm_val, uint8_t default_val);
+static uint8_t get_ftdm_val(ftdm2trillium_t *vals, uint8_t trillium_val, uint8_t default_val);
+
+
+
+/* Maps generic FreeTDM CPC codes to SS7 CPC codes */
+ftdm2trillium_t cpc_codes[] = {
+ {FTDM_CPC_UNKNOWN, CAT_UNKNOWN},
+ {FTDM_CPC_OPERATOR_FRENCH, CAT_OPLANGFR},
+ {FTDM_CPC_OPERATOR_ENGLISH, CAT_OPLANGENG},
+ {FTDM_CPC_OPERATOR_GERMAN, CAT_OPLANGGER},
+ {FTDM_CPC_OPERATOR_RUSSIAN, CAT_OPLANGRUS},
+ {FTDM_CPC_OPERATOR_SPANISH, CAT_OPLANGSP},
+ {FTDM_CPC_ORDINARY, CAT_ORD},
+ {FTDM_CPC_PRIORITY, CAT_PRIOR},
+ {FTDM_CPC_DATA, CAT_DATA},
+ {FTDM_CPC_TEST, CAT_TEST},
+ {FTDM_CPC_PAYPHONE, CAT_PAYPHONE},
+};
+
+ftdm2trillium_t bc_cap_codes[] = {
+ {FTDM_BEARER_CAP_SPEECH, ITC_SPEECH}, /* speech as per ATIS-1000113.3.2005 */
+ {FTDM_BEARER_CAP_UNRESTRICTED, ITC_UNRDIG}, /* unrestricted digital as per ATIS-1000113.3.2005 */
+ {FTDM_BEARER_CAP_RESTRICTED, ITC_UNRDIG}, /* Restricted Digital */
+ {FTDM_BEARER_CAP_3_1KHZ_AUDIO, ITC_A31KHZ}, /* 3.1kHz audio as per ATIS-1000113.3.2005 */
+ {FTDM_BEARER_CAP_7KHZ_AUDIO, ITC_A7KHZ}, /* 7Khz audio */
+ {FTDM_BEARER_CAP_15KHZ_AUDIO, ITC_A15KHZ}, /* 15Khz audio */
+ {FTDM_BEARER_CAP_VIDEO, ITC_VIDEO}, /* Video */
+};
+
+static uint8_t get_trillium_val(ftdm2trillium_t *vals, uint8_t ftdm_val, uint8_t default_val)
+{
+ ftdm2trillium_t *val = vals;
+ while(val++) {
+ if (val->ftdm_val == ftdm_val) {
+ return val->trillium_val;
+ }
+ }
+ return default_val;
}
-/******************************************************************************/
-uint8_t copy_cgPtyNum_to_sngss7(ftdm_caller_data_t *ftdm, SiCgPtyNum *cgPtyNum)
+static uint8_t get_ftdm_val(ftdm2trillium_t *vals, uint8_t trillium_val, uint8_t default_val)
{
- int k;
- int j;
- int flag;
- int odd;
- char tmp[2];
- uint8_t lower;
- uint8_t upper;
+ ftdm2trillium_t *val = vals;
+ while(val++) {
+ if (val->trillium_val == trillium_val) {
+ return val->ftdm_val;
+ }
+ }
+ return default_val;
+}
+
+ftdm_status_t copy_cgPtyNum_from_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyNum *cgPtyNum)
+{
+ return FTDM_SUCCESS;
+}
+
+ftdm_status_t copy_cgPtyNum_to_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyNum *cgPtyNum)
+{
+ const char *val;
+
+ ftdm_caller_data_t *caller_data = &ftdmchan->caller_data;
- /**************************************************************************/
cgPtyNum->eh.pres = PRSNT_NODEF;
- /**************************************************************************/
+
cgPtyNum->natAddrInd.pres = PRSNT_NODEF;
cgPtyNum->natAddrInd.val = 0x03;
- /**************************************************************************/
+
+
cgPtyNum->scrnInd.pres = PRSNT_NODEF;
- cgPtyNum->scrnInd.val = ftdm->screen;
- /**************************************************************************/
+ val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_screen_ind");
+ if (!ftdm_strlen_zero(val)) {
+ cgPtyNum->scrnInd.val = atoi(val);
+ } else {
+ cgPtyNum->scrnInd.val = caller_data->screen;
+ }
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Calling Party Number Screening Ind %d\n", cgPtyNum->scrnInd.val);
+
cgPtyNum->presRest.pres = PRSNT_NODEF;
- cgPtyNum->presRest.val = ftdm->pres;
- /**************************************************************************/
+ val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_pres_ind");
+ if (!ftdm_strlen_zero(val)) {
+ cgPtyNum->presRest.val = atoi(val);
+ } else {
+ cgPtyNum->presRest.val = caller_data->pres;
+ }
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Calling Party Number Presentation Ind %d\n", cgPtyNum->presRest.val);
+
cgPtyNum->numPlan.pres = PRSNT_NODEF;
cgPtyNum->numPlan.val = 0x01;
- /**************************************************************************/
+
cgPtyNum->niInd.pres = PRSNT_NODEF;
cgPtyNum->niInd.val = 0x00;
- /**************************************************************************/
- cgPtyNum->addrSig.pres = PRSNT_NODEF;
- /* atoi will search through memory starting from the pointer it is given until
- * it finds the \0...since tmp is on the stack it will start going through the
- * possibly causing corruption. Hard code a \0 to prevent this
- */
- tmp[1] = '\0';
- k = 0;
- j = 0;
- flag = 0;
- odd = 0;
- upper = 0x0;
- lower = 0x0;
-
- while (1) {
- /* grab a digit from the ftdm digits */
- tmp[0] = ftdm->cid_num.digits[k];
-
- /* check if the digit is a number and that is not null */
- while (!(isxdigit(tmp[0])) && (tmp[0] != '\0')) {
- SS7_INFO("Dropping invalid digit: %c\n", tmp[0]);
- /* move on to the next value */
- k++;
- tmp[0] = ftdm->cid_num.digits[k];
- } /* while(!(isdigit(tmp))) */
-
- /* check if tmp is null or a digit */
- if (tmp[0] != '\0') {
- /* push it into the lower nibble */
- lower = strtol(&tmp[0], (char **)NULL, 16);
- /* move to the next digit */
- k++;
- /* grab a digit from the ftdm digits */
- tmp[0] = ftdm->cid_num.digits[k];
-
- /* check if the digit is a number and that is not null */
- while (!(isxdigit(tmp[0])) && (tmp[0] != '\0')) {
- SS7_INFO("Dropping invalid digit: %c\n", tmp[0]);
- k++;
- tmp[0] = ftdm->cid_num.digits[k];
- } /* while(!(isdigit(tmp))) */
-
- /* check if tmp is null or a digit */
- if (tmp[0] != '\0') {
- /* push the digit into the upper nibble */
- upper = (strtol(&tmp[0], (char **)NULL, 16)) << 4;
- } else {
- /* there is no upper ... fill in 0 */
- upper = 0x0;
- /* throw the odd flag */
- odd = 1;
- /* throw the end flag */
- flag = 1;
- } /* if (tmp != '\0') */
- } else {
- /* keep the odd flag down */
- odd = 0;
- /* break right away since we don't need to write the digits */
- break;
- }
-
- /* push the digits into the trillium structure */
- cgPtyNum->addrSig.val[j] = upper | lower;
-
- /* increment the trillium pointer */
- j++;
-
- /* if the flag is up we're through all the digits */
- if (flag) break;
-
- /* move to the next digit */
- k++;
- } /* while(1) */
-
- cgPtyNum->addrSig.len = j;
-
- /**************************************************************************/
- cgPtyNum->oddEven.pres = PRSNT_NODEF;
- cgPtyNum->oddEven.val = odd;
- /**************************************************************************/
- return 0;
+ return copy_tknStr_to_sngss7(caller_data->cid_num.digits, &cgPtyNum->addrSig, &cgPtyNum->oddEven);
}
-/******************************************************************************/
-uint8_t copy_cdPtyNum_from_sngss7(ftdm_caller_data_t *ftdm, SiCdPtyNum *cdPtyNum)
+ftdm_status_t copy_cdPtyNum_from_sngss7(ftdm_channel_t *ftdmchan, SiCdPtyNum *cdPtyNum)
{
-
- return 0;
+ /* TODO: Implement me */
+ return FTDM_SUCCESS;
}
-/******************************************************************************/
-uint8_t copy_cdPtyNum_to_sngss7(ftdm_caller_data_t *ftdm, SiCdPtyNum *cdPtyNum)
-{
- int k;
- int j;
- int flag;
- int odd;
- char tmp[2];
- uint8_t lower;
- uint8_t upper;
- /**************************************************************************/
+ftdm_status_t copy_cdPtyNum_to_sngss7(ftdm_channel_t *ftdmchan, SiCdPtyNum *cdPtyNum)
+{
+ const char *cld_nadi = NULL;
+ ftdm_caller_data_t *caller_data = &ftdmchan->caller_data;
+ sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
+
cdPtyNum->eh.pres = PRSNT_NODEF;
- /**************************************************************************/
+
cdPtyNum->natAddrInd.pres = PRSNT_NODEF;
- cdPtyNum->natAddrInd.val = 0x03;
- /**************************************************************************/
+ cld_nadi = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_cld_nadi");
+ if (!ftdm_strlen_zero(cld_nadi)) {
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Called NADI value \"%s\"\n", cld_nadi);
+ cdPtyNum->natAddrInd.val = atoi(cld_nadi);
+ } else {
+ cdPtyNum->natAddrInd.val = g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].cld_nadi;
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "No user supplied NADI value found for CLD, using \"%d\"\n", cdPtyNum->natAddrInd.val);
+ }
+
cdPtyNum->numPlan.pres = PRSNT_NODEF;
cdPtyNum->numPlan.val = 0x01;
- /**************************************************************************/
+
cdPtyNum->innInd.pres = PRSNT_NODEF;
cdPtyNum->innInd.val = 0x01;
- /**************************************************************************/
- cdPtyNum->addrSig.pres = PRSNT_NODEF;
-
- /* atoi will search through memory starting from the pointer it is given until
- * it finds the \0...since tmp is on the stack it will start going through the
- * possibly causing corruption. Hard code a \0 to prevent this
- */ /* dnis */
- tmp[1] = '\0';
- k = 0;
- j = 0;
- flag = 0;
- odd = 0;
- upper = 0x0;
- lower = 0x0;
-
- while (1) {
- /* grab a digit from the ftdm digits */
- tmp[0] = ftdm->dnis.digits[k];
-
- /* check if the digit is a number and that is not null */
- while (!(isxdigit(tmp[0])) && (tmp[0] != '\0')) {
- SS7_INFO("Dropping invalid digit: %c\n", tmp[0]);
- /* move on to the next value */
- k++;
- tmp[0] = ftdm->dnis.digits[k];
- } /* while(!(isdigit(tmp))) */
-
- /* check if tmp is null or a digit */
- if (tmp[0] != '\0') {
- /* push it into the lower nibble */
- lower = strtol(&tmp[0], (char **)NULL, 16);
- /* move to the next digit */
- k++;
- /* grab a digit from the ftdm digits */
- tmp[0] = ftdm->dnis.digits[k];
-
- /* check if the digit is a number and that is not null */
- while (!(isxdigit(tmp[0])) && (tmp[0] != '\0')) {
- SS7_INFO("Dropping invalid digit: %c\n", tmp[0]);
- k++;
- tmp[0] = ftdm->dnis.digits[k];
- } /* while(!(isdigit(tmp))) */
-
- /* check if tmp is null or a digit */
- if (tmp[0] != '\0') {
- /* push the digit into the upper nibble */
- upper = (strtol(&tmp[0], (char **)NULL, 16)) << 4;
- } else {
- /* there is no upper ... fill in ST */
- upper = 0xF0;
- /* keep the odd flag down */
- odd = 0;
- /* throw the end flag */
- flag = 1;
- } /* if (tmp != '\0') */
- } else {
- /* throw the odd flag */
- odd = 1;
- /* need to add the ST */
- lower = 0xF;
- upper = 0x0;
- /* throw the flag */
- flag = 1;
- }
-
- /* push the digits into the trillium structure */
- cdPtyNum->addrSig.val[j] = upper | lower;
-
- /* increment the trillium pointer */
- j++;
-
- /* if the flag is up we're through all the digits */
- if (flag) break;
-
- /* move to the next digit */
- k++;
- } /* while(1) */
-
- cdPtyNum->addrSig.len = j;
-
- /**************************************************************************/
- cdPtyNum->oddEven.pres = PRSNT_NODEF;
-
- cdPtyNum->oddEven.val = odd;
-
- /**************************************************************************/
- return 0;
+
+ return copy_tknStr_to_sngss7(caller_data->dnis.digits, &cdPtyNum->addrSig, &cdPtyNum->oddEven);
}
-/******************************************************************************/
-uint8_t copy_tknStr_from_sngss7(TknStr str, char *ftdm, TknU8 oddEven)
+ftdm_status_t copy_genNmb_to_sngss7(ftdm_channel_t *ftdmchan, SiGenNum *genNmb)
+{
+ const char *val = NULL;
+ sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
+
+ val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_gn_digits");
+ if (!ftdm_strlen_zero(val)) {
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Generic Number qualifier \"%s\"\n", val);
+ if (copy_tknStr_to_sngss7((char*)val, &genNmb->addrSig, &genNmb->oddEven) != FTDM_SUCCESS) {
+ return FTDM_FAIL;
+ }
+ } else {
+ return FTDM_SUCCESS;
+ }
+
+ genNmb->eh.pres = PRSNT_NODEF;
+ genNmb->addrSig.pres = PRSNT_NODEF;
+
+ genNmb->nmbQual.pres = PRSNT_NODEF;
+ val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_gn_numqual");
+ if (!ftdm_strlen_zero(val)) {
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Generic Number \"%s\"\n", val);
+ genNmb->nmbQual.val = atoi(val);
+ } else {
+ genNmb->nmbQual.val = g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].gn_nmbqual;
+ ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "No user supplied Generic Number \n");
+ }
+ genNmb->natAddrInd.pres = PRSNT_NODEF;
+ val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_gn_nadi");
+ if (!ftdm_strlen_zero(val)) {
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Generic Number \"nature of address\" \"%s\"\n", val);
+ genNmb->natAddrInd.val = atoi(val);
+ } else {
+ genNmb->natAddrInd.val = g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].gn_nadi;
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "No user supplied Generic Number \"nature of address\" \"%d\"\n", genNmb->natAddrInd.val);
+ }
+ genNmb->scrnInd.pres = PRSNT_NODEF;
+ val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_gn_screen_ind");
+ if (!ftdm_strlen_zero(val)) {
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Generic Number \"screening indicator\" \"%s\"\n", val);
+ genNmb->scrnInd.val = atoi(val);
+ } else {
+ genNmb->natAddrInd.val = g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].gn_screen_ind;
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "No user supplied Generic Number \"screening indicator\" \"%d\"\n", genNmb->natAddrInd.val);
+ }
+ genNmb->presRest.pres = PRSNT_NODEF;
+ val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_gn_pres_ind");
+ if (!ftdm_strlen_zero(val)) {
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Generic Number \"presentation indicator\" \"%s\"\n", val);
+ genNmb->presRest.val = atoi(val);
+ } else {
+ genNmb->presRest.val = g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].gn_pres_ind;
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "No user supplied Generic Number \"presentation indicator\" \"%d\"\n", genNmb->presRest.val);
+ }
+ genNmb->numPlan.pres = PRSNT_NODEF;
+ val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_gn_npi");
+ if (!ftdm_strlen_zero(val)) {
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Generic Number \"numbering plan\" \"%s\"\n", val);
+ genNmb->numPlan.val = atoi(val);
+ } else {
+ genNmb->numPlan.val = g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].gn_npi;
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "No user supplied Generic Number \"numbering plan\" \"%d\"\n", genNmb->numPlan.val);
+ }
+ genNmb->niInd.pres = PRSNT_NODEF;
+ val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_gn_num_inc_ind");
+ if (!ftdm_strlen_zero(val)) {
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Generic Number \"number incomplete indicator\" \"%s\"\n", val);
+ genNmb->niInd.val = atoi(val);
+ } else {
+ genNmb->niInd.val = g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].gn_num_inc_ind;
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "No user supplied Generic Number \"number incomplete indicator\" \"%d\"\n", genNmb->niInd.val);
+ }
+ return FTDM_SUCCESS;
+}
+
+ftdm_status_t copy_genNmb_from_sngss7(ftdm_channel_t *ftdmchan, SiGenNum *genNmb)
+{
+ char val[64];
+ sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
+
+ memset(val, 0, sizeof(val));
+
+ if (genNmb->eh.pres != PRSNT_NODEF || genNmb->addrSig.pres != PRSNT_NODEF) {
+ ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "No Generic Number available\n");
+ return FTDM_SUCCESS;
+ }
+
+ copy_tknStr_from_sngss7(genNmb->addrSig, val, genNmb->oddEven);
+
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Generic Number:%s\n", val);
+ sngss7_add_var(sngss7_info, "ss7_gn_digits", val);
+
+ if (genNmb->nmbQual.pres == PRSNT_NODEF) {
+ snprintf(val, sizeof(val), "%d", genNmb->nmbQual.val);
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Generic Number \"number qualifier\" \n", val);
+ sngss7_add_var(sngss7_info, "ss7_gn_numqual", val);
+ }
+
+ if (genNmb->natAddrInd.pres == PRSNT_NODEF) {
+ snprintf(val, sizeof(val), "%d", genNmb->natAddrInd.val);
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Generic Number \"nature of address\" \"%s\"\n", val);
+ sngss7_add_var(sngss7_info, "ss7_gn_nadi", val);
+ }
+
+ if (genNmb->scrnInd.pres == PRSNT_NODEF) {
+ snprintf(val, sizeof(val), "%d", genNmb->scrnInd.val);
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Generic Number \"screening indicator\" \"%s\"\n", val);
+ sngss7_add_var(sngss7_info, "ss7_gn_screen_ind", val);
+ }
+
+ if (genNmb->presRest.pres == PRSNT_NODEF) {
+ snprintf(val, sizeof(val), "%d", genNmb->presRest.val);
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Generic Number \"presentation indicator\" \"%s\"\n", val);
+ sngss7_add_var(sngss7_info, "ss7_gn_pres_ind", val);
+ }
+
+ if (genNmb->numPlan.pres == PRSNT_NODEF) {
+ snprintf(val, sizeof(val), "%d", genNmb->numPlan.val);
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Generic Number \"numbering plan\" \"%s\"\n", val);
+ sngss7_add_var(sngss7_info, "ss7_gn_npi", val);
+ }
+
+ if (genNmb->niInd.pres == PRSNT_NODEF) {
+ snprintf(val, sizeof(val), "%d", genNmb->niInd.val);
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Generic Number \"number incomplete indicator\" \"%s\"\n", val);
+ sngss7_add_var(sngss7_info, "ss7_gn_num_inc_ind", val);
+ }
+
+ return FTDM_SUCCESS;
+}
+
+ftdm_status_t copy_redirgNum_to_sngss7(ftdm_channel_t *ftdmchan, SiRedirNum *redirgNum)
+{
+ const char* val = NULL;
+ sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
+ ftdm_caller_data_t *caller_data = &ftdmchan->caller_data;
+
+ val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_rdnis_digits");
+ if (!ftdm_strlen_zero(val)) {
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Redirection Number\"%s\"\n", val);
+ if (copy_tknStr_to_sngss7((char*)val, &redirgNum->addrSig, &redirgNum->oddEven) != FTDM_SUCCESS) {
+ return FTDM_FAIL;
+ }
+ } else if (!ftdm_strlen_zero(caller_data->rdnis.digits)) {
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Redirection Number\"%s\"\n", val);
+ if (copy_tknStr_to_sngss7(caller_data->rdnis.digits, &redirgNum->addrSig, &redirgNum->oddEven) != FTDM_SUCCESS) {
+ return FTDM_FAIL;
+ }
+ } else {
+ ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "No user supplied Redirection Number\n");
+ return FTDM_SUCCESS;
+ }
+
+ redirgNum->eh.pres = PRSNT_NODEF;
+
+ /* Nature of address indicator */
+ redirgNum->natAddr.pres = PRSNT_NODEF;
+
+ val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_rdnis_nadi");
+ if (!ftdm_strlen_zero(val)) {
+ redirgNum->natAddr.val = atoi(val);
+ } else {
+ redirgNum->natAddr.val = g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].rdnis_nadi;
+ }
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Redirecting Number NADI:%d\n", redirgNum->natAddr.val);
+
+ /* Screening indicator */
+ redirgNum->scrInd.pres = PRSNT_NODEF;
+ val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_rdnis_screen_ind");
+ if (!ftdm_strlen_zero(val)) {
+ redirgNum->scrInd.val = atoi(val);
+ } else {
+ redirgNum->scrInd.val = FTDM_SCREENING_VERIFIED_PASSED;
+ }
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Redirecting Number Screening Ind:%d\n", redirgNum->scrInd.val);
+
+ /* Address presentation restricted ind */
+ redirgNum->presRest.pres = PRSNT_NODEF;
+
+ val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_rdnis_pres_ind");
+ if (!ftdm_strlen_zero(val)) {
+ redirgNum->presRest.val = atoi(val);
+ } else {
+ redirgNum->presRest.val = FTDM_PRES_ALLOWED;
+ }
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Redirecting Number Address Presentation Restricted Ind:%d\n", redirgNum->presRest.val);
+
+ /* Numbering plan */
+ redirgNum->numPlan.pres = PRSNT_NODEF;
+
+ val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_rdnis_plan");
+ if (!ftdm_strlen_zero(val)) {
+ redirgNum->numPlan.val = atoi(val);
+ } else {
+ redirgNum->numPlan.val = caller_data->rdnis.plan;
+ }
+
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Redirecting Number Numbering plan:%d\n", redirgNum->numPlan.val);
+
+ return copy_tknStr_to_sngss7(caller_data->rdnis.digits, &redirgNum->addrSig, &redirgNum->oddEven);
+}
+
+ftdm_status_t copy_redirgNum_from_sngss7(ftdm_channel_t *ftdmchan, SiRedirNum *redirgNum)
+{
+ char val[20];
+ sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
+ ftdm_caller_data_t *caller_data = &ftdmchan->caller_data;
+
+ if (redirgNum->eh.pres != PRSNT_NODEF || redirgNum->addrSig.pres != PRSNT_NODEF) {
+ ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "No Redirecting Number available\n");
+ return FTDM_SUCCESS;
+ }
+
+ copy_tknStr_from_sngss7(redirgNum->addrSig, ftdmchan->caller_data.rdnis.digits, redirgNum->oddEven);
+
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Redirecting Number:%s\n", ftdmchan->caller_data.rdnis.digits);
+ snprintf(val, sizeof(val), "%s", ftdmchan->caller_data.rdnis.digits);
+ sngss7_add_var(sngss7_info, "ss7_rdnis_digits", val);
+
+
+ if (redirgNum->natAddr.pres == PRSNT_NODEF) {
+ snprintf(val, sizeof(val), "%d", redirgNum->natAddr.val);
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Redirecting Number NADI:%s\n", val);
+ sngss7_add_var(sngss7_info, "ss7_rdnis_nadi", val);
+ caller_data->rdnis.type = redirgNum->natAddr.val;
+ }
+
+ if (redirgNum->scrInd.pres == PRSNT_NODEF) {
+ snprintf(val, sizeof(val), "%d", redirgNum->scrInd.val);
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Redirecting Number Screening Ind:%s\n", val);
+ sngss7_add_var(sngss7_info, "ss7_rdnis_screen_ind", val);
+ }
+
+ if (redirgNum->presRest.pres == PRSNT_NODEF) {
+ snprintf(val, sizeof(val), "%d", redirgNum->presRest.val);
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Redirecting Number Presentation Ind:%s\n", val);
+ sngss7_add_var(sngss7_info, "ss7_rdnis_pres_ind", val);
+ }
+
+ if (redirgNum->numPlan.pres == PRSNT_NODEF) {
+ snprintf(val, sizeof(val), "%d", redirgNum->numPlan.val);
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Redirecting Number Numbering plan:%s\n", val);
+ sngss7_add_var(sngss7_info, "ss7_rdnis_plan", val);
+ caller_data->rdnis.plan = redirgNum->numPlan.val;
+ }
+
+ return FTDM_SUCCESS;
+}
+
+ftdm_status_t copy_cgPtyCat_to_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyCat *cgPtyCat)
+{
+ ftdm_caller_data_t *caller_data = &ftdmchan->caller_data;
+
+ cgPtyCat->eh.pres = PRSNT_NODEF;
+ cgPtyCat->cgPtyCat.pres = PRSNT_NODEF;
+
+ cgPtyCat->cgPtyCat.val = get_trillium_val(cpc_codes, caller_data->cpc, CAT_ORD);
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Calling Party Category:0x%x\n",cgPtyCat->cgPtyCat.val);
+ return FTDM_SUCCESS;
+}
+
+ftdm_status_t copy_cgPtyCat_from_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyCat *cgPtyCat)
+{
+ ftdm_caller_data_t *caller_data = &ftdmchan->caller_data;
+
+ if (cgPtyCat->eh.pres == PRSNT_NODEF &&
+ cgPtyCat->cgPtyCat.pres == PRSNT_NODEF) {
+
+ caller_data->cpc = get_ftdm_val(cpc_codes, cgPtyCat->cgPtyCat.val, FTDM_CPC_UNKNOWN);
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Calling Party Category:0x%x\n", cgPtyCat->cgPtyCat.val);
+ }
+ return FTDM_SUCCESS;
+}
+
+
+ftdm_status_t copy_accTrnspt_to_sngss7(ftdm_channel_t *ftdmchan, SiAccTrnspt *accTrnspt)
+{
+ const char *clg_subAddr = NULL;
+ const char *cld_subAddr = NULL;
+ char subAddrIE[MAX_SIZEOF_SUBADDR_IE];
+
+ /* check if the user would like us to send a clg_sub-address */
+ clg_subAddr = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_clg_subaddr");
+ if (!ftdm_strlen_zero(clg_subAddr)) {
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Calling Sub-Address value \"%s\"\n", clg_subAddr);
+
+ /* clean out the subAddrIE */
+ memset(subAddrIE, 0x0, sizeof(subAddrIE));
+
+ /* check the first character in the sub-address to see what type of encoding to use */
+ switch (clg_subAddr[0]) {
+ case '0': /* NSAP */
+ encode_subAddrIE_nsap(&clg_subAddr[1], subAddrIE, SNG_CALLING);
+ break;
+ case '1': /* national variant */
+ encode_subAddrIE_nat(&clg_subAddr[1], subAddrIE, SNG_CALLING);
+ break;
+ default:
+ ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Invalid Calling Sub-Address encoding requested: %c\n", clg_subAddr[0]);
+ break;
+ } /* switch (cld_subAddr[0]) */
+
+
+ /* if subaddIE is still empty don't copy it in */
+ if (subAddrIE[0] != '0') {
+ /* check if the clg_subAddr has already been added */
+ if (accTrnspt->eh.pres == PRSNT_NODEF) {
+ /* append the subAddrIE */
+ memcpy(&accTrnspt->infoElmts.val[accTrnspt->infoElmts.len], subAddrIE, (subAddrIE[1] + 2));
+ accTrnspt->infoElmts.len = accTrnspt->infoElmts.len +subAddrIE[1] + 2;
+ } else {
+ /* fill in from the beginning */
+ accTrnspt->eh.pres = PRSNT_NODEF;
+ accTrnspt->infoElmts.pres = PRSNT_NODEF;
+ memcpy(accTrnspt->infoElmts.val, subAddrIE, (subAddrIE[1] + 2));
+ accTrnspt->infoElmts.len = subAddrIE[1] + 2;
+ }
+ }
+ }
+
+ /* check if the user would like us to send a cld_sub-address */
+ cld_subAddr = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_cld_subaddr");
+ if ((cld_subAddr != NULL) && (*cld_subAddr)) {
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Called Sub-Address value \"%s\"\n", cld_subAddr);
+
+ /* clean out the subAddrIE */
+ memset(subAddrIE, 0x0, sizeof(subAddrIE));
+
+ /* check the first character in the sub-address to see what type of encoding to use */
+ switch (cld_subAddr[0]) {
+ case '0': /* NSAP */
+ encode_subAddrIE_nsap(&cld_subAddr[1], subAddrIE, SNG_CALLED);
+ break;
+ case '1': /* national variant */
+ encode_subAddrIE_nat(&cld_subAddr[1], subAddrIE, SNG_CALLED);
+ break;
+ default:
+ ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Invalid Called Sub-Address encoding requested: %c\n", cld_subAddr[0]);
+ break;
+ } /* switch (cld_subAddr[0]) */
+
+ /* if subaddIE is still empty don't copy it in */
+ if (subAddrIE[0] != '0') {
+ /* check if the cld_subAddr has already been added */
+ if (accTrnspt->eh.pres == PRSNT_NODEF) {
+ /* append the subAddrIE */
+ memcpy(&accTrnspt->infoElmts.val[accTrnspt->infoElmts.len], subAddrIE, (subAddrIE[1] + 2));
+ accTrnspt->infoElmts.len = accTrnspt->infoElmts.len +subAddrIE[1] + 2;
+ } else {
+ /* fill in from the beginning */
+ accTrnspt->eh.pres = PRSNT_NODEF;
+ accTrnspt->infoElmts.pres = PRSNT_NODEF;
+ memcpy(accTrnspt->infoElmts.val, subAddrIE, (subAddrIE[1] + 2));
+ accTrnspt->infoElmts.len = subAddrIE[1] + 2;
+ }
+ }
+ } /* if ((cld_subAddr != NULL) && (*cld_subAddr)) */
+ return FTDM_SUCCESS;
+}
+
+ftdm_status_t copy_natConInd_to_sngss7(ftdm_channel_t *ftdmchan, SiNatConInd *natConInd)
+{
+ /* copy down the nature of connection indicators */
+ natConInd->eh.pres = PRSNT_NODEF;
+ natConInd->satInd.pres = PRSNT_NODEF;
+ natConInd->satInd.val = 0; /* no satellite circuit */
+ natConInd->contChkInd.pres = PRSNT_NODEF;
+ natConInd->contChkInd.val = CONTCHK_NOTREQ;
+ natConInd->echoCntrlDevInd.pres = PRSNT_NODEF;
+ natConInd->echoCntrlDevInd.val = ECHOCDEV_INCL;
+ return FTDM_SUCCESS;
+}
+
+ftdm_status_t copy_fwdCallInd_to_sngss7(ftdm_channel_t *ftdmchan, SiFwdCallInd *fwdCallInd)
+{
+ sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
+
+ fwdCallInd->eh.pres = PRSNT_NODEF;
+ fwdCallInd->natIntCallInd.pres = PRSNT_NODEF;
+ fwdCallInd->natIntCallInd.val = 0x00;
+ fwdCallInd->end2EndMethInd.pres = PRSNT_NODEF;
+ fwdCallInd->end2EndMethInd.val = E2EMTH_NOMETH;
+ fwdCallInd->intInd.pres = PRSNT_NODEF;
+ fwdCallInd->intInd.val = INTIND_NOINTW;
+ fwdCallInd->end2EndInfoInd.pres = PRSNT_NODEF;
+ fwdCallInd->end2EndInfoInd.val = E2EINF_NOINFO;
+ fwdCallInd->isdnUsrPrtInd.pres = PRSNT_NODEF;
+ fwdCallInd->isdnUsrPrtInd.val = ISUP_USED;
+ fwdCallInd->isdnUsrPrtPrfInd.pres = PRSNT_NODEF;
+ fwdCallInd->isdnUsrPrtPrfInd.val = PREF_PREFAW;
+ fwdCallInd->isdnAccInd.pres = PRSNT_NODEF;
+ fwdCallInd->isdnAccInd.val = ISDNACC_ISDN;
+ fwdCallInd->sccpMethInd.pres = PRSNT_NODEF;
+ fwdCallInd->sccpMethInd.val = SCCPMTH_NOIND;
+
+ if ((g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].switchType == LSI_SW_ANS88) ||
+ (g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].switchType == LSI_SW_ANS92) ||
+ (g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].switchType == LSI_SW_ANS95)) {
+
+ /* include only if we're running ANSI */
+ fwdCallInd->transCallNInd.pres = PRSNT_NODEF;
+ fwdCallInd->transCallNInd.val = 0x0;
+ }
+ return FTDM_SUCCESS;
+}
+
+ftdm_status_t copy_txMedReq_to_sngss7(ftdm_channel_t *ftdmchan, SiTxMedReq *txMedReq)
+{
+ txMedReq->eh.pres = PRSNT_NODEF;
+ txMedReq->trMedReq.pres = PRSNT_NODEF;
+ txMedReq->trMedReq.val = ftdmchan->caller_data.bearer_capability;
+
+ return FTDM_SUCCESS;
+}
+
+ftdm_status_t copy_usrServInfoA_to_sngss7(ftdm_channel_t *ftdmchan, SiUsrServInfo *usrServInfoA)
+{
+ sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
+
+ if ((g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].switchType == LSI_SW_ANS88) ||
+ (g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].switchType == LSI_SW_ANS92) ||
+ (g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].switchType == LSI_SW_ANS95)) {
+
+ usrServInfoA->eh.pres = PRSNT_NODEF;
+
+ usrServInfoA->infoTranCap.pres = PRSNT_NODEF;
+
+ usrServInfoA->infoTranCap.val = get_trillium_val(bc_cap_codes, ftdmchan->caller_data.bearer_capability, ITC_SPEECH);
+
+ usrServInfoA->cdeStand.pres = PRSNT_NODEF;
+ usrServInfoA->cdeStand.val = 0x0; /* ITU-T standardized coding */
+ usrServInfoA->tranMode.pres = PRSNT_NODEF;
+ usrServInfoA->tranMode.val = 0x0; /* circuit mode */
+ usrServInfoA->infoTranRate0.pres = PRSNT_NODEF;
+ usrServInfoA->infoTranRate0.val = 0x10; /* 64kbps origination to destination */
+ usrServInfoA->infoTranRate1.pres = PRSNT_NODEF;
+ usrServInfoA->infoTranRate1.val = 0x10; /* 64kbps destination to origination */
+ usrServInfoA->chanStruct.pres = PRSNT_NODEF;
+ usrServInfoA->chanStruct.val = 0x1; /* 8kHz integrity */
+ usrServInfoA->config.pres = PRSNT_NODEF;
+ usrServInfoA->config.val = 0x0; /* point to point configuration */
+ usrServInfoA->establish.pres = PRSNT_NODEF;
+ usrServInfoA->establish.val = 0x0; /* on demand */
+ usrServInfoA->symmetry.pres = PRSNT_NODEF;
+ usrServInfoA->symmetry.val = 0x0; /* bi-directional symmetric */
+ usrServInfoA->usrInfLyr1Prot.pres = PRSNT_NODEF;
+ usrServInfoA->usrInfLyr1Prot.val = 0x2; /* G.711 ulaw */
+ usrServInfoA->rateMultiplier.pres = PRSNT_NODEF;
+ usrServInfoA->rateMultiplier.val = 0x1; /* 1x rate multipler */
+ } /* if ANSI */
+ return FTDM_SUCCESS;
+}
+
+
+
+ftdm_status_t copy_tknStr_from_sngss7(TknStr str, char *ftdm, TknU8 oddEven)
{
uint8_t i;
uint8_t j;
/* check if the token string is present */
-
if (str.pres == 1) {
j = 0;
@@ -355,14 +705,14 @@ uint8_t copy_tknStr_from_sngss7(TknStr str, char *ftdm, TknU8 oddEven)
} else {
SS7_ERROR("Asked to copy tknStr that is not present!\n");
- return 1;
+ return FTDM_FAIL;
}
- return 0;
+ return FTDM_SUCCESS;
}
/******************************************************************************/
-uint8_t append_tknStr_from_sngss7(TknStr str, char *ftdm, TknU8 oddEven)
+ftdm_status_t append_tknStr_from_sngss7(TknStr str, char *ftdm, TknU8 oddEven)
{
int i = 0;
int j = 0;
@@ -375,7 +725,7 @@ uint8_t append_tknStr_from_sngss7(TknStr str, char *ftdm, TknU8 oddEven)
/* confirm that we found an acceptable length */
if ( j > 25 ) {
SS7_ERROR("string length exceeds maxium value...aborting append!\n");
- return 1;
+ return FTDM_FAIL;
} /* if ( j > 25 ) */
/* copy in digits */
@@ -398,12 +748,107 @@ uint8_t append_tknStr_from_sngss7(TknStr str, char *ftdm, TknU8 oddEven)
} /* if ((oddEven.pres == 1) && (oddEven.val == 1)) */
} else {
SS7_ERROR("Asked to copy tknStr that is not present!\n");
- return 1;
+ return FTDM_FAIL;
} /* if (str.pres == 1) */
- return 0;
+ return FTDM_SUCCESS;
}
+
+ftdm_status_t copy_tknStr_to_sngss7(char* val, TknStr *tknStr, TknU8 *oddEven)
+{
+ char tmp[2];
+ int k = 0;
+ int j = 0;
+ uint8_t flag = 0;
+ uint8_t odd = 0;
+
+ uint8_t lower = 0x0;
+ uint8_t upper = 0x0;
+
+ tknStr->pres = PRSNT_NODEF;
+
+ /* atoi will search through memory starting from the pointer it is given until
+ * it finds the \0...since tmp is on the stack it will start going through the
+ * possibly causing corruption. Hard code a \0 to prevent this
+ */
+ tmp[1] = '\0';
+
+ while (1) {
+ /* grab a digit from the ftdm digits */
+ tmp[0] = val[k];
+
+ /* check if the digit is a number and that is not null */
+ while (!(isxdigit(tmp[0])) && (tmp[0] != '\0')) {
+ if (tmp[0] == '*') {
+ /* Could not find a spec that specifies this , but on customer system, * was transmitted as 0x0b */
+ SS7_DEBUG("Replacing * with 0x0b");
+ k++;
+ tmp[0] = 0x0b;
+ } else {
+ SS7_INFO("Dropping invalid digit: %c\n", tmp[0]);
+ /* move on to the next value */
+ k++;
+ tmp[0] = val[k];
+ }
+ } /* while(!(isdigit(tmp))) */
+
+ /* check if tmp is null or a digit */
+ if (tmp[0] != '\0') {
+ /* push it into the lower nibble */
+ lower = strtol(&tmp[0], (char **)NULL, 16);
+ /* move to the next digit */
+ k++;
+ /* grab a digit from the ftdm digits */
+ tmp[0] = val[k];
+
+ /* check if the digit is a number and that is not null */
+ while (!(isxdigit(tmp[0])) && (tmp[0] != '\0')) {
+ SS7_INFO("Dropping invalid digit: %c\n", tmp[0]);
+ k++;
+ tmp[0] = val[k];
+ } /* while(!(isdigit(tmp))) */
+
+ /* check if tmp is null or a digit */
+ if (tmp[0] != '\0') {
+ /* push the digit into the upper nibble */
+ upper = (strtol(&tmp[0], (char **)NULL, 16)) << 4;
+ } else {
+ /* there is no upper ... fill in 0 */
+ upper = 0x0;
+ /* throw the odd flag */
+ odd = 1;
+ /* throw the end flag */
+ flag = 1;
+ } /* if (tmp != '\0') */
+ } else {
+ /* keep the odd flag down */
+ odd = 0;
+ /* break right away since we don't need to write the digits */
+ break;
+ }
+
+ /* push the digits into the trillium structure */
+ tknStr->val[j] = upper | lower;
+
+ /* increment the trillium pointer */
+ j++;
+
+ /* if the flag is up we're through all the digits */
+ if (flag) break;
+
+ /* move to the next digit */
+ k++;
+ } /* while(1) */
+
+ tknStr->len = j;
+ oddEven->pres = PRSNT_NODEF;
+ oddEven->val = odd;
+ return FTDM_SUCCESS;
+}
+
+
+
/******************************************************************************/
int check_for_state_change(ftdm_channel_t *ftdmchan)
{
@@ -415,7 +860,7 @@ int check_for_state_change(ftdm_channel_t *ftdmchan)
if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_STATE_CHANGE)) {
/* the flag is still up...so we have a problem */
- SS7_DEBUG_CHAN(ftdmchan, "FTDM_CHANNEL_STATE_CHANGE flag set for over 500ms, channel state = %s\n",
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "FTDM_CHANNEL_STATE_CHANGE flag set for over 500ms, channel state = %s\n",
ftdm_channel_state2str (ftdmchan->state));
return 1;
@@ -466,8 +911,6 @@ int check_cics_in_range(sngss7_chan_data_t *sngss7_info)
/******************************************************************************/
ftdm_status_t extract_chan_data(uint32_t circuit, sngss7_chan_data_t **sngss7_info, ftdm_channel_t **ftdmchan)
{
- /*SS7_FUNC_TRACE_ENTER(__FUNCTION__);*/
-
if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].obj == NULL) {
SS7_ERROR("sngss7_info is Null for circuit #%d\n", circuit);
return FTDM_FAIL;
@@ -480,7 +923,6 @@ ftdm_status_t extract_chan_data(uint32_t circuit, sngss7_chan_data_t **sngss7_in
ftdm_assert_return((*sngss7_info)->ftdmchan, FTDM_FAIL, "received message on signalling link or non-configured cic\n");
*ftdmchan = (*sngss7_info)->ftdmchan;
- /*SS7_FUNC_TRACE_EXIT(__FUNCTION__);*/
return FTDM_SUCCESS;
}
@@ -531,8 +973,18 @@ ftdm_status_t check_if_rx_grs_started(ftdm_span_t *ftdmspan)
sngss7_span_data_t *sngss7_span = (sngss7_span_data_t *)ftdmspan->signal_data;
int i;
+
+ SS7_INFO("Rx GRS (%d:%d)\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[sngss7_span->rx_grs.circuit].cic,
+ (g_ftdm_sngss7_data.cfg.isupCkt[sngss7_span->rx_grs.circuit].cic + sngss7_span->rx_grs.range));
+
for ( i = sngss7_span->rx_grs.circuit; i < (sngss7_span->rx_grs.circuit + sngss7_span->rx_grs.range + 1); i++) {
+ /* confirm this is a voice channel, otherwise we do nothing */
+ if (g_ftdm_sngss7_data.cfg.isupCkt[i].type != VOICE) {
+ continue;
+ }
+
/* extract the channel in question */
if (extract_chan_data(i, &sngss7_info, &ftdmchan)) {
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", i);
@@ -553,10 +1005,6 @@ ftdm_status_t check_if_rx_grs_started(ftdm_span_t *ftdmspan)
ftdm_sangoma_ss7_process_state_change (ftdmchan);
}
- SS7_INFO_CHAN(ftdmchan, "Rx GRS (%d:%d)\n",
- g_ftdm_sngss7_data.cfg.isupCkt[sngss7_span->rx_grs.circuit].cic,
- (g_ftdm_sngss7_data.cfg.isupCkt[sngss7_span->rx_grs.circuit].cic + sngss7_span->rx_grs.range));
-
/* flag the channel as having received a reset */
sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX);
@@ -595,12 +1043,14 @@ ftdm_status_t check_if_rx_grs_processed(ftdm_span_t *ftdmspan)
int byte = 0;
int bit = 0;
-
- ftdm_log(FTDM_LOG_DEBUG, "Found Rx GRS on span %s...checking circuits\n", ftdmspan->name);
-
/* check all the circuits in the range to see if they are done resetting */
for ( i = sngss7_span->rx_grs.circuit; i < (sngss7_span->rx_grs.circuit + sngss7_span->rx_grs.range + 1); i++) {
+ /* confirm this is a voice channel, otherwise we do nothing */
+ if (g_ftdm_sngss7_data.cfg.isupCkt[i].type != VOICE) {
+ continue;
+ }
+
/* extract the channel in question */
if (extract_chan_data(i, &sngss7_info, &ftdmchan)) {
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", i);
@@ -630,6 +1080,11 @@ ftdm_status_t check_if_rx_grs_processed(ftdm_span_t *ftdmspan)
/* check all the circuits in the range to see if they are done resetting */
for ( i = sngss7_span->rx_grs.circuit; i < (sngss7_span->rx_grs.circuit + sngss7_span->rx_grs.range + 1); i++) {
+ /* confirm this is a voice channel, otherwise we do nothing */
+ if (g_ftdm_sngss7_data.cfg.isupCkt[i].type != VOICE) {
+ continue;
+ }
+
/* extract the channel in question */
if (extract_chan_data(i, &sngss7_info, &ftdmchan)) {
SS7_ERROR("Failed to extract channel data for circuit = %d!\n",i);
@@ -664,6 +1119,12 @@ ftdm_status_t check_if_rx_grs_processed(ftdm_span_t *ftdmspan)
GRS_UNLOCK_ALL:
for ( i = sngss7_span->rx_grs.circuit; i < (sngss7_span->rx_grs.circuit + sngss7_span->rx_grs.range + 1); i++) {
+
+ /* confirm this is a voice channel, otherwise we do nothing */
+ if (g_ftdm_sngss7_data.cfg.isupCkt[i].type != VOICE) {
+ continue;
+ }
+
/* extract the channel in question */
if (extract_chan_data(i, &sngss7_info, &ftdmchan)) {
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", i);
@@ -685,6 +1146,10 @@ ftdm_status_t check_if_rx_gra_started(ftdm_span_t *ftdmspan)
sngss7_span_data_t *sngss7_span = (sngss7_span_data_t *)ftdmspan->signal_data;
int i;
+ SS7_INFO("Rx GRA (%d:%d)\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[sngss7_span->rx_gra.circuit].cic,
+ (g_ftdm_sngss7_data.cfg.isupCkt[sngss7_span->rx_gra.circuit].cic + sngss7_span->rx_gra.range));
+
for (i = sngss7_span->rx_gra.circuit; i < (sngss7_span->rx_gra.circuit + sngss7_span->rx_gra.range + 1); i++) {
/* extract the channel in question */
@@ -707,9 +1172,7 @@ ftdm_status_t check_if_rx_gra_started(ftdm_span_t *ftdmspan)
ftdm_sangoma_ss7_process_state_change (ftdmchan);
}
- SS7_INFO_CHAN(ftdmchan, "Rx GRA (%d:%d)\n",
- g_ftdm_sngss7_data.cfg.isupCkt[sngss7_span->rx_gra.circuit].cic,
- (g_ftdm_sngss7_data.cfg.isupCkt[sngss7_span->rx_gra.circuit].cic + sngss7_span->rx_gra.range));
+
switch (ftdmchan->state) {
/**********************************************************************/
@@ -1088,10 +1551,17 @@ ftdm_status_t encode_subAddrIE_nat(const char *subAddr, char *subAddrIE, int typ
/* confirm it is a hex digit */
while ((!isxdigit(tmp[0])) && (tmp[0] != '\0')) {
- SS7_INFO("Dropping invalid digit: %c\n", tmp[0]);
- /* move to the next character in subAddr */
- x++;
- tmp[0] = subAddr[x];
+ if (tmp[0] == '*') {
+ /* Could not find a spec that specifies this, but on customer system, * was transmitted as 0x0b */
+ SS7_DEBUG("Replacing * with 0x0b");
+ x++;
+ tmp[0] = 0x0b;
+ } else {
+ SS7_INFO("Dropping invalid digit: %c\n", tmp[0]);
+ /* move to the next character in subAddr */
+ x++;
+ tmp[0] = subAddr[x];
+ }
}
/* check if tmp is null or a digit */
@@ -1291,7 +1761,7 @@ ftdm_status_t check_status_of_all_isup_intf(void)
/* go through all the isupIntfs and ask the stack to give their current state */
x = 1;
- for (x = 1; x < (MAX_ISUP_INFS + 1); x++) {
+ for (x = 1; x < (MAX_ISUP_INFS); x++) {
/**************************************************************************/
if (g_ftdm_sngss7_data.cfg.isupIntf[x].id == 0) continue;
@@ -1348,7 +1818,7 @@ ftdm_status_t check_status_of_all_isup_intf(void)
} /* switch (status) */
/**************************************************************************/
- } /* for (x = 1; x < MAX_ISUP_INFS + 1); i++) */
+ } /* for (x = 1; x < MAX_ISUP_INFS); i++) */
return FTDM_SUCCESS;
}
@@ -1436,7 +1906,7 @@ void sngss7_set_sig_status(sngss7_chan_data_t *sngss7_info, ftdm_signaling_statu
ftdm_sigmsg_t sig;
ftdm_channel_t *ftdmchan = sngss7_info->ftdmchan;
- SS7_DEBUG_CHAN(ftdmchan, "Signalling link status changed to %s\n",
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Signalling link status changed to %s\n",
ftdm_signaling_status2str(status));
memset(&sig, 0, sizeof(sig));
@@ -1448,12 +1918,511 @@ void sngss7_set_sig_status(sngss7_chan_data_t *sngss7_info, ftdm_signaling_statu
sig.ev_data.sigstatus.status = status;
if (ftdm_span_send_signal(ftdmchan->span, &sig) != FTDM_SUCCESS) {
- SS7_ERROR_CHAN(ftdmchan, "Failed to change channel status to %s\n",
+ ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Failed to change channel status to %s\n",
ftdm_signaling_status2str(status));
}
return;
}
+/******************************************************************************/
+ftdm_status_t check_for_reconfig_flag(ftdm_span_t *ftdmspan)
+{
+ ftdm_channel_t *ftdmchan = NULL;
+ sngss7_chan_data_t *sngss7_info = NULL;
+ sng_isup_inf_t *sngss7_intf = NULL;
+ uint8_t state;
+ uint8_t bits_ab = 0;
+ uint8_t bits_cd = 0;
+ uint8_t bits_ef = 0;
+ int x;
+ int ret;
+
+ for (x = 1; x < (ftdmspan->chan_count + 1); x++) {
+ /**************************************************************************/
+ /* extract the channel structure and sngss7 channel data */
+ ftdmchan = ftdmspan->channels[x];
+
+ /* if the call data is NULL move on */
+ if (ftdmchan->call_data == NULL) {
+ SS7_WARN_CHAN(ftdmchan, "Found ftdmchan with no sig module data!%s\n", " ");
+ continue;
+ }
+
+ /* grab the private data */
+ sngss7_info = ftdmchan->call_data;
+
+ /* check the reconfig flag */
+ if (sngss7_test_ckt_flag(sngss7_info, FLAG_CKT_RECONFIG)) {
+ /* confirm the state of all isup interfaces*/
+ check_status_of_all_isup_intf();
+
+ sngss7_intf = &g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info->circuit->infId];
+
+ /* check if the interface is paused or resumed */
+ if (sngss7_test_flag(sngss7_intf, SNGSS7_PAUSED)) {
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "ISUP intf %d is PAUSED\n", sngss7_intf->id);
+ /* throw the pause flag */
+ sngss7_clear_ckt_flag(sngss7_info, FLAG_INFID_RESUME);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_INFID_PAUSED);
+ } else {
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "ISUP intf %d is RESUMED\n", sngss7_intf->id);
+ /* throw the resume flag */
+ sngss7_clear_ckt_flag(sngss7_info, FLAG_INFID_PAUSED);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_INFID_RESUME);
+ }
+
+ /* query for the status of the ckt */
+ if (ftmod_ss7_isup_ckt_sta(sngss7_info->circuit->id, &state)) {
+ SS7_ERROR("Failed to read isup ckt = %d status\n", sngss7_info->circuit->id);
+ continue;
+ }
+
+ /* extract the bit sections */
+ bits_ab = (state & (SNG_BIT_A + SNG_BIT_B)) >> 0;
+ bits_cd = (state & (SNG_BIT_C + SNG_BIT_D)) >> 2;
+ bits_ef = (state & (SNG_BIT_E + SNG_BIT_F)) >> 4;
+
+ if (bits_cd == 0x0) {
+ /* check if circuit is UCIC or transient */
+ if (bits_ab == 0x3) {
+ /* bit a and bit b are set, unequipped */
+ ret = ftmod_ss7_isup_ckt_config(sngss7_info->circuit->id);
+ if (ret) {
+ SS7_CRITICAL("ISUP CKT %d re-configuration FAILED!\n",x);
+ } else {
+ SS7_INFO("ISUP CKT %d re-configuration DONE!\n", x);
+ }
+
+ /* reset the circuit to sync states */
+ ftdm_mutex_lock(ftdmchan->mutex);
+
+ /* flag the circuit as active */
+ sngss7_set_flag(sngss7_info->circuit, SNGSS7_ACTIVE);
+
+ /* throw the channel into reset */
+ sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_TX);
+
+ /* throw the channel to suspend */
+ ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
+
+ /* unlock the channel */
+ ftdm_mutex_unlock(ftdmchan->mutex);
+
+ } /* if (bits_ab == 0x3) */
+ } else {
+ /* check the maintenance block status in bits A and B */
+ switch (bits_ab) {
+ /**************************************************************************/
+ case (0):
+ /* no maintenace block...do nothing */
+ break;
+ /**************************************************************************/
+ case (1):
+ /* locally blocked */
+ sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX);
+
+ /* set the channel to suspended state */
+ SS7_STATE_CHANGE(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
+ break;
+ /**************************************************************************/
+ case (2):
+ /* remotely blocked */
+ sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX);
+
+ /* set the channel to suspended state */
+ SS7_STATE_CHANGE(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
+ break;
+ /**************************************************************************/
+ case (3):
+ /* both locally and remotely blocked */
+ sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX);
+ sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX);
+
+ /* set the channel to suspended state */
+ SS7_STATE_CHANGE(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
+ break;
+ /**************************************************************************/
+ default:
+ break;
+ /**************************************************************************/
+ } /* switch (bits_ab) */
+
+ /* check the hardware block status in bits e and f */
+ switch (bits_ef) {
+ /**************************************************************************/
+ case (0):
+ /* no maintenace block...do nothing */
+ break;
+ /**************************************************************************/
+ case (1):
+ /* locally blocked */
+ sngss7_set_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_TX);
+
+ /* set the channel to suspended state */
+ SS7_STATE_CHANGE(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
+ break;
+ /**************************************************************************/
+ case (2):
+ /* remotely blocked */
+ sngss7_set_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX);
+
+ /* set the channel to suspended state */
+ SS7_STATE_CHANGE(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
+ break;
+ /**************************************************************************/
+ case (3):
+ /* both locally and remotely blocked */
+ sngss7_set_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_TX);
+ sngss7_set_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX);
+
+ /* set the channel to suspended state */
+ SS7_STATE_CHANGE(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
+ break;
+ /**************************************************************************/
+ default:
+ break;
+ /**************************************************************************/
+ } /* switch (bits_ef) */
+ }
+
+ /* clear the re-config flag ... no matter what */
+ sngss7_clear_ckt_flag(sngss7_info, FLAG_CKT_RECONFIG);
+
+ } /* if ((sngss7_test_ckt_flag(sngss7_info, FLAG_CKT_RECONFIG)) */
+ } /* for (x = 1; x < (span->chan_count + 1); x++) */
+
+ return FTDM_SUCCESS;
+}
+
+ftdm_status_t sngss7_bufferzero_iam(SiConEvnt *siConEvnt)
+{
+ if (siConEvnt->natConInd.eh.pres != PRSNT_NODEF) memset(&siConEvnt->natConInd, 0, sizeof(siConEvnt->natConInd));
+ if (siConEvnt->fwdCallInd.eh.pres != PRSNT_NODEF) memset(&siConEvnt->fwdCallInd, 0, sizeof(siConEvnt->fwdCallInd));
+ if (siConEvnt->cgPtyCat.eh.pres != PRSNT_NODEF) memset(&siConEvnt->cgPtyCat, 0, sizeof(siConEvnt->cgPtyCat));
+ if (siConEvnt->txMedReq.eh.pres != PRSNT_NODEF) memset(&siConEvnt->txMedReq, 0, sizeof(siConEvnt->txMedReq));
+#if (SS7_ANS88 || SS7_ANS92 || SS7_ANS95 || SS7_BELL)
+ if (siConEvnt->usrServInfoA.eh.pres != PRSNT_NODEF) memset(&siConEvnt->usrServInfoA, 0, sizeof(siConEvnt->usrServInfoA));
+#endif
+ if (siConEvnt->cdPtyNum.eh.pres != PRSNT_NODEF) memset(&siConEvnt->cdPtyNum, 0, sizeof(siConEvnt->cdPtyNum));
+#if TNS_ANSI
+#if (SS7_ANS92 || SS7_ANS95 || SS7_BELL)
+ if (siConEvnt->tranNetSel1.eh.pres != PRSNT_NODEF) memset(&siConEvnt->tranNetSel1, 0, sizeof(siConEvnt->tranNetSel1));
+#endif
+#endif
+ if (siConEvnt->tranNetSel.eh.pres != PRSNT_NODEF) memset(&siConEvnt->tranNetSel, 0, sizeof(siConEvnt->tranNetSel));
+#if (SS7_ANS88 || SS7_ANS92 || SS7_ANS95 || SS7_BELL || SS7_CHINA)
+ if (siConEvnt->callRefA.eh.pres != PRSNT_NODEF) memset(&siConEvnt->callRefA, 0, sizeof(siConEvnt->callRefA));
+#endif
+ if (siConEvnt->callRef.eh.pres != PRSNT_NODEF) memset(&siConEvnt->callRef, 0, sizeof(siConEvnt->callRef));
+ if (siConEvnt->cgPtyNum.eh.pres != PRSNT_NODEF) memset(&siConEvnt->cgPtyNum, 0, sizeof(siConEvnt->cgPtyNum));
+#if SS7_BELL
+ if (siConEvnt->cgPtyNumB.eh.pres != PRSNT_NODEF) memset(&siConEvnt->cgPtyNumB, 0, sizeof(siConEvnt->cgPtyNumB));
+#endif
+ if (siConEvnt->opFwdCalInd.eh.pres != PRSNT_NODEF) memset(&siConEvnt->opFwdCalInd, 0, sizeof(siConEvnt->opFwdCalInd));
+#if (SS7_Q767 || SS7_RUSSIA || SS7_NTT)
+ if (siConEvnt->opFwdCalIndQ.eh.pres != PRSNT_NODEF) memset(&siConEvnt->opFwdCalIndQ, 0, sizeof(siConEvnt->opFwdCalIndQ));
+#endif
+#if SS7_Q767IT
+ if (siConEvnt->fwdVad.eh.pres != PRSNT_NODEF) memset(&siConEvnt->fwdVad, 0, sizeof(siConEvnt->fwdVad));
+#endif
+#if SS7_ANS88
+ if (siConEvnt->opFwdCalIndA.eh.pres != PRSNT_NODEF) memset(&siConEvnt->opFwdCalIndA, 0, sizeof(siConEvnt->opFwdCalIndA));
+#endif
+ if (siConEvnt->redirgNum.eh.pres != PRSNT_NODEF) memset(&siConEvnt->redirgNum, 0, sizeof(siConEvnt->redirgNum));
+ if (siConEvnt->redirInfo.eh.pres != PRSNT_NODEF) memset(&siConEvnt->redirInfo, 0, sizeof(siConEvnt->redirInfo));
+ if (siConEvnt->cugIntCode.eh.pres != PRSNT_NODEF) memset(&siConEvnt->cugIntCode, 0, sizeof(siConEvnt->cugIntCode));
+#if SS7_ANS88
+ if (siConEvnt->cugIntCodeA.eh.pres != PRSNT_NODEF) memset(&siConEvnt->cugIntCodeA, 0, sizeof(siConEvnt->cugIntCodeA));
+#endif
+#if (SS7_ANS88 || SS7_ANS92 || SS7_ANS95 || SS7_BELL || SS7_CHINA)
+ if (siConEvnt->connReqA.eh.pres != PRSNT_NODEF) memset(&siConEvnt->connReqA, 0, sizeof(siConEvnt->connReqA));
+#endif
+#if SS7_ANS88
+ if (siConEvnt->usr2UsrInfoA.eh.pres != PRSNT_NODEF) memset(&siConEvnt->usr2UsrInfoA, 0, sizeof(siConEvnt->usr2UsrInfoA));
+#endif
+ if (siConEvnt->connReq.eh.pres != PRSNT_NODEF) memset(&siConEvnt->connReq, 0, sizeof(siConEvnt->connReq));
+ if (siConEvnt->origCdNum.eh.pres != PRSNT_NODEF) memset(&siConEvnt->origCdNum, 0, sizeof(siConEvnt->origCdNum));
+ if (siConEvnt->usr2UsrInfo.eh.pres != PRSNT_NODEF) memset(&siConEvnt->usr2UsrInfo, 0, sizeof(siConEvnt->usr2UsrInfo));
+ if (siConEvnt->accTrnspt.eh.pres != PRSNT_NODEF) memset(&siConEvnt->accTrnspt, 0, sizeof(siConEvnt->accTrnspt));
+ if (siConEvnt->echoControl.eh.pres != PRSNT_NODEF) memset(&siConEvnt->echoControl, 0, sizeof(siConEvnt->echoControl));
+#if SS7_ANS88
+ if (siConEvnt->redirInfoA.eh.pres != PRSNT_NODEF) memset(&siConEvnt->redirInfoA, 0, sizeof(siConEvnt->redirInfoA));
+#endif
+#if (SS7_ANS88 || SS7_ANS92 || SS7_ANS95 || SS7_BELL)
+ if (siConEvnt->chargeNum.eh.pres != PRSNT_NODEF) memset(&siConEvnt->chargeNum, 0, sizeof(siConEvnt->chargeNum));
+ if (siConEvnt->origLineInf.eh.pres != PRSNT_NODEF) memset(&siConEvnt->origLineInf, 0, sizeof(siConEvnt->origLineInf));
+#endif
+ if (siConEvnt->usrServInfo.eh.pres != PRSNT_NODEF) memset(&siConEvnt->usrServInfo, 0, sizeof(siConEvnt->usrServInfo));
+ if (siConEvnt->usr2UsrInd.eh.pres != PRSNT_NODEF) memset(&siConEvnt->usr2UsrInd, 0, sizeof(siConEvnt->usr2UsrInd));
+ if (siConEvnt->propDly.eh.pres != PRSNT_NODEF) memset(&siConEvnt->propDly, 0, sizeof(siConEvnt->propDly));
+ if (siConEvnt->usrServInfo1.eh.pres != PRSNT_NODEF) memset(&siConEvnt->usrServInfo1, 0, sizeof(siConEvnt->usrServInfo1));
+ if (siConEvnt->netFac.eh.pres != PRSNT_NODEF) memset(&siConEvnt->netFac, 0, sizeof(siConEvnt->netFac));
+#ifdef SS7_CHINA
+ if (siConEvnt->orgPteCdeA.eh.pres != PRSNT_NODEF) memset(&siConEvnt->orgPteCdeA, 0, sizeof(siConEvnt->orgPteCdeA));
+#endif
+ if (siConEvnt->orgPteCde.eh.pres != PRSNT_NODEF) memset(&siConEvnt->orgPteCde, 0, sizeof(siConEvnt->orgPteCde));
+ if (siConEvnt->genDigits.eh.pres != PRSNT_NODEF) memset(&siConEvnt->genDigits, 0, sizeof(siConEvnt->genDigits));
+ if (siConEvnt->genDigitsR.eh.pres != PRSNT_NODEF) memset(&siConEvnt->genDigitsR, 0, sizeof(siConEvnt->genDigitsR));
+ if (siConEvnt->usrTSrvInfo.eh.pres != PRSNT_NODEF) memset(&siConEvnt->usrTSrvInfo, 0, sizeof(siConEvnt->usrTSrvInfo));
+ if (siConEvnt->remotOper.eh.pres != PRSNT_NODEF) memset(&siConEvnt->remotOper, 0, sizeof(siConEvnt->remotOper));
+ if (siConEvnt->parmCom.eh.pres != PRSNT_NODEF) memset(&siConEvnt->parmCom, 0, sizeof(siConEvnt->parmCom));
+#if (SS7_ANS92 || SS7_ANS95)
+ if (siConEvnt->servCode.eh.pres != PRSNT_NODEF) memset(&siConEvnt->servCode, 0, sizeof(siConEvnt->servCode));
+#endif
+#if SS7_ANS92
+ if (siConEvnt->serviceAct1.eh.pres != PRSNT_NODEF) memset(&siConEvnt->serviceAct1, 0, sizeof(siConEvnt->serviceAct1));
+#endif
+#if SS7_CHINA
+ if (siConEvnt->serviceAct2.eh.pres != PRSNT_NODEF) memset(&siConEvnt->serviceAct2, 0, sizeof(siConEvnt->serviceAct2));
+#endif
+ if (siConEvnt->serviceAct2.eh.pres != PRSNT_NODEF) memset(&siConEvnt->serviceAct2, 0, sizeof(siConEvnt->serviceAct2));
+ if (siConEvnt->serviceAct.eh.pres != PRSNT_NODEF) memset(&siConEvnt->serviceAct, 0, sizeof(siConEvnt->serviceAct));
+ if (siConEvnt->mlppPrec.eh.pres != PRSNT_NODEF) memset(&siConEvnt->mlppPrec, 0, sizeof(siConEvnt->mlppPrec));
+#if (defined(SIT_PARAMETER) || defined(TDS_ROLL_UPGRADE_SUPPORT))
+ if (siConEvnt->txMedUsPr.eh.pres != PRSNT_NODEF) memset(&siConEvnt->txMedUsPr, 0, sizeof(siConEvnt->txMedUsPr));
+#endif
+ if (siConEvnt->bckCallInd.eh.pres != PRSNT_NODEF) memset(&siConEvnt->bckCallInd, 0, sizeof(siConEvnt->bckCallInd));
+ if (siConEvnt->cgPtyNum1.eh.pres != PRSNT_NODEF) memset(&siConEvnt->cgPtyNum1, 0, sizeof(siConEvnt->cgPtyNum1));
+ if (siConEvnt->optBckCalInd.eh.pres != PRSNT_NODEF) memset(&siConEvnt->optBckCalInd, 0, sizeof(siConEvnt->optBckCalInd));
+#if (SS7_Q767 || SS7_RUSSIA || SS7_NTT)
+ if (siConEvnt->optBckCalIndQ.eh.pres != PRSNT_NODEF) memset(&siConEvnt->optBckCalIndQ, 0, sizeof(siConEvnt->optBckCalIndQ));
+#endif
+ if (siConEvnt->connNum.eh.pres != PRSNT_NODEF) memset(&siConEvnt->connNum, 0, sizeof(siConEvnt->connNum));
+#if (defined(SIT_PARAMETER) || defined(TDS_ROLL_UPGRADE_SUPPORT))
+ if (siConEvnt->connNum2.eh.pres != PRSNT_NODEF) memset(&siConEvnt->connNum2, 0, sizeof(siConEvnt->connNum2));
+#endif
+ if (siConEvnt->accDelInfo.eh.pres != PRSNT_NODEF) memset(&siConEvnt->accDelInfo, 0, sizeof(siConEvnt->accDelInfo));
+ if (siConEvnt->notifInd.eh.pres != PRSNT_NODEF) memset(&siConEvnt->notifInd, 0, sizeof(siConEvnt->notifInd));
+ if (siConEvnt->notifIndR2.eh.pres != PRSNT_NODEF) memset(&siConEvnt->notifIndR2, 0, sizeof(siConEvnt->notifIndR2));
+ if (siConEvnt->cllHstry.eh.pres != PRSNT_NODEF) memset(&siConEvnt->cllHstry, 0, sizeof(siConEvnt->cllHstry));
+ if (siConEvnt->genNmb.eh.pres != PRSNT_NODEF) memset(&siConEvnt->genNmb, 0, sizeof(siConEvnt->genNmb));
+ if (siConEvnt->genNmbR.eh.pres != PRSNT_NODEF) memset(&siConEvnt->genNmbR, 0, sizeof(siConEvnt->genNmbR));
+ if (siConEvnt->redirNum.eh.pres != PRSNT_NODEF) memset(&siConEvnt->redirNum, 0, sizeof(siConEvnt->redirNum));
+ if (siConEvnt->redirRstr.eh.pres != PRSNT_NODEF) memset(&siConEvnt->redirRstr, 0, sizeof(siConEvnt->redirRstr));
+
+#if SS7_Q767IT
+ if (siConEvnt->backVad.eh.pres != PRSNT_NODEF) memset(&siConEvnt->backVad, 0, sizeof(siConEvnt->backVad));
+#endif
+#if SS7_SINGTEL
+ if (siConEvnt->cgPtyNumS.eh.pres != PRSNT_NODEF) memset(&siConEvnt->cgPtyNumS, 0, sizeof(siConEvnt->cgPtyNumS));
+#endif
+#if (SS7_ANS92 || SS7_ANS95 || SS7_BELL)
+ if (siConEvnt->businessGrp.eh.pres != PRSNT_NODEF) memset(&siConEvnt->businessGrp, 0, sizeof(siConEvnt->businessGrp));
+ if (siConEvnt->infoInd.eh.pres != PRSNT_NODEF) memset(&siConEvnt->infoInd, 0, sizeof(siConEvnt->infoInd));
+ if (siConEvnt->carrierId.eh.pres != PRSNT_NODEF) memset(&siConEvnt->carrierId, 0, sizeof(siConEvnt->carrierId));
+ if (siConEvnt->carSelInf.eh.pres != PRSNT_NODEF) memset(&siConEvnt->carSelInf, 0, sizeof(siConEvnt->carSelInf));
+ if (siConEvnt->egress.eh.pres != PRSNT_NODEF) memset(&siConEvnt->egress, 0, sizeof(siConEvnt->egress));
+ if (siConEvnt->genAddr.eh.pres != PRSNT_NODEF) memset(&siConEvnt->genAddr, 0, sizeof(siConEvnt->genAddr));
+ if (siConEvnt->genAddrR.eh.pres != PRSNT_NODEF) memset(&siConEvnt->genAddrR, 0, sizeof(siConEvnt->genAddrR));
+ if (siConEvnt->infoReqInd.eh.pres != PRSNT_NODEF) memset(&siConEvnt->infoReqInd, 0, sizeof(siConEvnt->infoReqInd));
+ if (siConEvnt->jurisInf.eh.pres != PRSNT_NODEF) memset(&siConEvnt->jurisInf, 0, sizeof(siConEvnt->jurisInf));
+ if (siConEvnt->netTransport.eh.pres != PRSNT_NODEF) memset(&siConEvnt->netTransport, 0, sizeof(siConEvnt->netTransport));
+ if (siConEvnt->specProcReq.eh.pres != PRSNT_NODEF) memset(&siConEvnt->specProcReq, 0, sizeof(siConEvnt->specProcReq));
+ if (siConEvnt->transReq.eh.pres != PRSNT_NODEF) memset(&siConEvnt->transReq, 0, sizeof(siConEvnt->transReq));
+#endif
+#if (defined(SIT_PARAMETER) || defined(TDS_ROLL_UPGRADE_SUPPORT))
+#if (SS7_ANS92 || SS7_ANS95)
+ if (siConEvnt->notifInd1.eh.pres != PRSNT_NODEF) memset(&siConEvnt->notifInd1, 0, sizeof(siConEvnt->notifInd1));
+ if (siConEvnt->notifIndR1.eh.pres != PRSNT_NODEF) memset(&siConEvnt->notifIndR1, 0, sizeof(siConEvnt->notifIndR1));
+#endif /* SS7_ANS92 */
+#endif /* SIT_PARAMETER || TDS_ROLL_UPGRADE_SUPPORT */
+#if (SS7_BELL || SS7_ANS95)
+ if (siConEvnt->genName.eh.pres != PRSNT_NODEF) memset(&siConEvnt->genName, 0, sizeof(siConEvnt->genName));
+#endif
+#if (SS7_ITU97 || SS7_RUSS2000 || SS7_ITU2000 || SS7_ETSIV3 || \
+ SS7_BELL || SS7_ANS95 || SS7_INDIA || SS7_UK || SS7_NZL || SS7_KZ)
+ if (siConEvnt->hopCounter.eh.pres != PRSNT_NODEF) memset(&siConEvnt->hopCounter, 0, sizeof(siConEvnt->hopCounter));
+#endif
+#if (SS7_BELL || SS7_ITU2000 || SS7_KZ)
+ if (siConEvnt->redirCap.eh.pres != PRSNT_NODEF) memset(&siConEvnt->redirCap, 0, sizeof(siConEvnt->redirCap));
+ if (siConEvnt->redirCntr.eh.pres != PRSNT_NODEF) memset(&siConEvnt->redirCntr, 0, sizeof(siConEvnt->redirCntr));
+#endif
+#if (SS7_ETSI || SS7_FTZ)
+ if (siConEvnt->ccbsParam.eh.pres != PRSNT_NODEF) memset(&siConEvnt->ccbsParam, 0, sizeof(siConEvnt->ccbsParam));
+ if (siConEvnt->freePhParam.eh.pres != PRSNT_NODEF) memset(&siConEvnt->freePhParam, 0, sizeof(siConEvnt->freePhParam));
+#endif
+#ifdef SS7_FTZ
+ if (siConEvnt->naPaFF.eh.pres != PRSNT_NODEF) memset(&siConEvnt->naPaFF, 0, sizeof(siConEvnt->naPaFF));
+ if (siConEvnt->naPaFE.eh.pres != PRSNT_NODEF) memset(&siConEvnt->naPaFE, 0, sizeof(siConEvnt->naPaFE));
+ if (siConEvnt->naPaSSP.eh.pres != PRSNT_NODEF) memset(&siConEvnt->naPaSSP, 0, sizeof(siConEvnt->naPaSSP));
+ if (siConEvnt->naPaCdPNO.eh.pres != PRSNT_NODEF) memset(&siConEvnt->naPaCdPNO, 0, sizeof(siConEvnt->naPaCdPNO));
+ if (siConEvnt->naPaSPV.eh.pres != PRSNT_NODEF) memset(&siConEvnt->naPaSPV, 0, sizeof(siConEvnt->naPaSPV));
+ if (siConEvnt->naPaUKK.eh.pres != PRSNT_NODEF) memset(&siConEvnt->naPaUKK, 0, sizeof(siConEvnt->naPaUKK));
+#endif
+#if SS7_NTT
+ if (siConEvnt->msgAreaInfo.eh.pres != PRSNT_NODEF) memset(&siConEvnt->msgAreaInfo, 0, sizeof(siConEvnt->msgAreaInfo));
+ if (siConEvnt->subsNumber.eh.pres != PRSNT_NODEF) memset(&siConEvnt->subsNumber, 0, sizeof(siConEvnt->subsNumber));
+ if (siConEvnt->rpCllngNo.eh.pres != PRSNT_NODEF) memset(&siConEvnt->rpCllngNo, 0, sizeof(siConEvnt->rpCllngNo));
+ if (siConEvnt->supplUserType.eh.pres != PRSNT_NODEF) memset(&siConEvnt->supplUserType, 0, sizeof(siConEvnt->supplUserType));
+ if (siConEvnt->carrierInfoTrans.eh.pres != PRSNT_NODEF) memset(&siConEvnt->carrierInfoTrans, 0, sizeof(siConEvnt->carrierInfoTrans));
+ if (siConEvnt->nwFuncType.eh.pres != PRSNT_NODEF) memset(&siConEvnt->nwFuncType, 0, sizeof(siConEvnt->nwFuncType));
+#endif
+#if SS7_ANS95
+ if (siConEvnt->optrServicesInfo.eh.pres != PRSNT_NODEF) memset(&siConEvnt->optrServicesInfo, 0, sizeof(siConEvnt->optrServicesInfo));
+#endif
+#if (SS7_ANS95 || SS7_ITU97 || SS7_RUSS2000|| SS7_ITU2000 || SS7_NZL || SS7_KZ)
+ if (siConEvnt->cirAsgnMap.eh.pres != PRSNT_NODEF) memset(&siConEvnt->cirAsgnMap, 0, sizeof(siConEvnt->cirAsgnMap));
+#endif
+#if (SS7_ITU97 || SS7_RUSS2000 || SS7_ITU2000 || SS7_ETSIV3 || \
+ SS7_INDIA || SS7_UK || SS7_NZL || SS7_KZ)
+ if (siConEvnt->displayInfo.eh.pres != PRSNT_NODEF) memset(&siConEvnt->displayInfo, 0, sizeof(siConEvnt->displayInfo));
+ if (siConEvnt->confTrtInd.eh.pres != PRSNT_NODEF) memset(&siConEvnt->confTrtInd, 0, sizeof(siConEvnt->confTrtInd));
+ if (siConEvnt->netMgmtControls.eh.pres != PRSNT_NODEF) memset(&siConEvnt->netMgmtControls, 0, sizeof(siConEvnt->netMgmtControls));
+ if (siConEvnt->correlationId.eh.pres != PRSNT_NODEF) memset(&siConEvnt->correlationId, 0, sizeof(siConEvnt->correlationId));
+ if (siConEvnt->callDivTrtInd.eh.pres != PRSNT_NODEF) memset(&siConEvnt->callDivTrtInd, 0, sizeof(siConEvnt->callDivTrtInd));
+ if (siConEvnt->callInNmb.eh.pres != PRSNT_NODEF) memset(&siConEvnt->callInNmb, 0, sizeof(siConEvnt->callInNmb));
+ if (siConEvnt->callOfferTrtInd.eh.pres != PRSNT_NODEF) memset(&siConEvnt->callOfferTrtInd, 0, sizeof(siConEvnt->callOfferTrtInd));
+ if (siConEvnt->scfId.eh.pres != PRSNT_NODEF) memset(&siConEvnt->scfId, 0, sizeof(siConEvnt->scfId));
+ if (siConEvnt->uidCapInd.eh.pres != PRSNT_NODEF) memset(&siConEvnt->uidCapInd, 0, sizeof(siConEvnt->uidCapInd));
+ if (siConEvnt->collCallReq.eh.pres != PRSNT_NODEF) memset(&siConEvnt->collCallReq, 0, sizeof(siConEvnt->collCallReq));
+ if (siConEvnt->ccss.eh.pres != PRSNT_NODEF) memset(&siConEvnt->ccss, 0, sizeof(siConEvnt->ccss));
+#endif
+#if (SS7_ITU97 || SS7_RUSS2000 || SS7_ITU2000 || SS7_UK || SS7_NZL || SS7_KZ)
+ if (siConEvnt->backGVNS.eh.pres != PRSNT_NODEF) memset(&siConEvnt->backGVNS, 0, sizeof(siConEvnt->backGVNS));
+ if (siConEvnt->forwardGVNS.eh.pres != PRSNT_NODEF) memset(&siConEvnt->forwardGVNS, 0, sizeof(siConEvnt->forwardGVNS));
+#endif
+#if (SS7_ETSIV3 || SS7_ITU97 || SS7_RUSS2000 || SS7_ITU2000 || \
+ SS7_INDIA || SS7_UK || SS7_NZL || SS7_KZ)
+ if (siConEvnt->appTransParam.eh.pres != PRSNT_NODEF) memset(&siConEvnt->appTransParam, 0, sizeof(siConEvnt->appTransParam));
+#endif
+#if (SS7_ITU2000 || SS7_UK || SS7_NZL || SS7_KZ)
+ if (siConEvnt->htrInfo.eh.pres != PRSNT_NODEF) memset(&siConEvnt->htrInfo, 0, sizeof(siConEvnt->htrInfo));
+ if (siConEvnt->pivotCap.eh.pres != PRSNT_NODEF) memset(&siConEvnt->pivotCap, 0, sizeof(siConEvnt->pivotCap));
+ if (siConEvnt->cadDirNmb.eh.pres != PRSNT_NODEF) memset(&siConEvnt->cadDirNmb, 0, sizeof(siConEvnt->cadDirNmb));
+ if (siConEvnt->origCallInNum.eh.pres != PRSNT_NODEF) memset(&siConEvnt->origCallInNum, 0, sizeof(siConEvnt->origCallInNum));
+ if (siConEvnt->calgGeoLoc.eh.pres != PRSNT_NODEF) memset(&siConEvnt->calgGeoLoc, 0, sizeof(siConEvnt->calgGeoLoc));
+ if (siConEvnt->netRoutNum.eh.pres != PRSNT_NODEF) memset(&siConEvnt->netRoutNum, 0, sizeof(siConEvnt->netRoutNum));
+ if (siConEvnt->qonRelCap.eh.pres != PRSNT_NODEF) memset(&siConEvnt->qonRelCap, 0, sizeof(siConEvnt->qonRelCap));
+ if (siConEvnt->pivotCntr.eh.pres != PRSNT_NODEF) memset(&siConEvnt->pivotCntr, 0, sizeof(siConEvnt->pivotCntr));
+ if (siConEvnt->pivotRtgFwInfo.eh.pres != PRSNT_NODEF) memset(&siConEvnt->pivotRtgFwInfo, 0, sizeof(siConEvnt->pivotRtgFwInfo));
+ if (siConEvnt->pivotRtgBkInfo.eh.pres != PRSNT_NODEF) memset(&siConEvnt->pivotRtgBkInfo, 0, sizeof(siConEvnt->pivotRtgBkInfo));
+ if (siConEvnt->numPortFwdInfo.eh.pres != PRSNT_NODEF) memset(&siConEvnt->numPortFwdInfo, 0, sizeof(siConEvnt->numPortFwdInfo));
+#endif
+#ifdef SS7_UK
+ if (siConEvnt->natFwdCalInd.eh.pres != PRSNT_NODEF) memset(&siConEvnt->natFwdCalInd, 0, sizeof(siConEvnt->natFwdCalInd));
+ if (siConEvnt->presntNum.eh.pres != PRSNT_NODEF) memset(&siConEvnt->presntNum, 0, sizeof(siConEvnt->presntNum));
+ if (siConEvnt->lstDvrtLineId.eh.pres != PRSNT_NODEF) memset(&siConEvnt->lstDvrtLineId, 0, sizeof(siConEvnt->lstDvrtLineId));
+ if (siConEvnt->pcgLineId.eh.pres != PRSNT_NODEF) memset(&siConEvnt->pcgLineId, 0, sizeof(siConEvnt->pcgLineId));
+ if (siConEvnt->natFwdCalIndLnk.eh.pres != PRSNT_NODEF) memset(&siConEvnt->natFwdCalIndLnk, 0, sizeof(siConEvnt->natFwdCalIndLnk));
+ if (siConEvnt->cdBascSrvcMrk.eh.pres != PRSNT_NODEF) memset(&siConEvnt->cdBascSrvcMrk, 0, sizeof(siConEvnt->cdBascSrvcMrk));
+#endif /* SS7_UK */
+#if (defined(CGPN_CHK))
+ if (siConEvnt->causeDgnCgPnChk.eh.pres != PRSNT_NODEF) memset(&siConEvnt->causeDgnCgPnChk, 0, sizeof(siConEvnt->causeDgnCgPnChk));
+#endif
+ return FTDM_SUCCESS;
+}
+
+ftdm_status_t sngss7_save_iam(ftdm_channel_t *ftdmchan, SiConEvnt *siConEvnt)
+{
+#ifndef HAVE_ZLIB
+ ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "Cannot perform transparent IAM because zlib is missing\n");
+ return FTDM_FAIL;
+#else
+ unsigned ret_val = FTDM_FAIL;
+ char *compressed_iam = NULL;
+ char *url_encoded_iam = NULL;
+ uLongf len = sizeof(*siConEvnt);
+ sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
+
+ /* By default, Trillium does not memset their whole structure to zero for
+ * performance. But we want to memset all the IE's that are not present to
+ * optimize compressed size */
+ sngss7_bufferzero_iam(siConEvnt);
+
+ compressed_iam = ftdm_malloc(sizeof(*siConEvnt));
+ if (!compressed_iam) {
+ ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "Failed to allocate buffer for compressed_iam\n");
+ goto done;
+ }
+
+ /* Compress IAM structure to minimize buffer size */
+ ret_val = compress((Bytef *)compressed_iam, &len, (const Bytef *)siConEvnt, (uLong)sizeof(*siConEvnt));
+ if (ret_val != Z_OK) {
+ ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Failed to compress IAM (error:%d)\n", ret_val);
+ ret_val = FTDM_FAIL;
+ goto done;
+ }
+
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Compressed IAM size:%d\n", len);
+
+ /* Worst case: size will triple after url encode */
+ url_encoded_iam = ftdm_malloc(3*sizeof(*siConEvnt));
+ if (!url_encoded_iam) {
+ ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "Failed to allocated buffer for url_encoded_iam\n");
+ ret_val = FTDM_FAIL;
+ goto done;
+ }
+ memset(url_encoded_iam, 0, 2*sizeof(*siConEvnt));
+
+ /* URL encode buffer to that its safe to store it in a string */
+ ftdm_url_encode((const char*)compressed_iam, url_encoded_iam, len);
+
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "IAM variable length:%d\n", strlen(url_encoded_iam));
+
+ if (strlen(url_encoded_iam) > g_ftdm_sngss7_data.cfg.transparent_iam_max_size) {
+ ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "IAM variable length exceeds max size (len:%d max:%d) \n", strlen(url_encoded_iam), g_ftdm_sngss7_data.cfg.transparent_iam_max_size);
+ ret_val = FTDM_FAIL;
+ goto done;
+ }
+
+ sngss7_add_var(sngss7_info, "ss7_iam", url_encoded_iam);
+done:
+ ftdm_safe_free(compressed_iam);
+ ftdm_safe_free(url_encoded_iam);
+ return ret_val;
+#endif
+}
+
+ftdm_status_t sngss7_retrieve_iam(ftdm_channel_t *ftdmchan, SiConEvnt *siConEvnt)
+{
+#ifndef HAVE_ZLIB
+ ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "Cannot perform transparent IAM because zlib is missing\n");
+ return FTDM_FAIL;
+#else
+ uLongf len = 3*sizeof(*siConEvnt); /* worst case: URL encoded buffer is 3x length of buffer */
+ char *val = NULL;
+ unsigned ret_val = FTDM_FAIL;
+ void *uncompressed_buffer = NULL;
+ char *url_encoded_iam = NULL;
+ ftdm_size_t url_encoded_iam_len;
+
+ val = (char*)ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam");
+ if (ftdm_strlen_zero(val)) {
+ ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "No Transparent IAM info available\n");
+ return FTDM_FAIL;
+ }
+
+ url_encoded_iam = ftdm_strdup(val);
+
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "IAM variable length:%d\n", strlen(val));
+ ftdm_url_decode(url_encoded_iam, &url_encoded_iam_len);
+
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Compressed IAM size:%d\n", url_encoded_iam_len);
+
+ uncompressed_buffer = ftdm_malloc(sizeof(*siConEvnt));
+ ftdm_assert_return(uncompressed_buffer, FTDM_FAIL, "Failed to allocate buffer for uncompressed buffer\n");
+
+ ret_val = uncompress(uncompressed_buffer, &len, (const Bytef *)url_encoded_iam, (uLong)url_encoded_iam_len);
+ if (ret_val != Z_OK) {
+ ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Failed to uncompress IAM (error:%d)\n", ret_val);
+ goto done;
+ }
+
+ if (len != sizeof(*siConEvnt)) {
+ ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Incompatible IAM structure size (expected:%d size:%d)\n", sizeof(*siConEvnt), strlen(uncompressed_buffer));
+ goto done;
+ }
+
+ memcpy(siConEvnt, uncompressed_buffer, sizeof(*siConEvnt));
+ ret_val = FTDM_SUCCESS;
+
+done:
+ ftdm_safe_free(uncompressed_buffer);
+ ftdm_safe_free(url_encoded_iam);
+ return ret_val;
+#endif
+}
+
/******************************************************************************/
/* For Emacs:
* Local Variables:
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c
index 166fe5dc04..a891c50108 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c
@@ -122,7 +122,10 @@ typedef struct sng_ccSpan
uint32_t ssf;
uint32_t clg_nadi;
uint32_t cld_nadi;
+ uint32_t rdnis_nadi;
uint32_t min_digits;
+ uint8_t itx_auto_reply;
+ uint8_t transparent_iam;
uint32_t t3;
uint32_t t12;
uint32_t t13;
@@ -464,6 +467,9 @@ static int ftmod_ss7_parse_sng_gen(ftdm_conf_node_t *sng_gen)
SS7_DEBUG("Found license file = %s\n", g_ftdm_sngss7_data.cfg.license);
SS7_DEBUG("Found signature file = %s\n", g_ftdm_sngss7_data.cfg.signature);
/**********************************************************************/
+ } else if (!strcasecmp(parm->var, "transparent_iam_max_size")) {
+ g_ftdm_sngss7_data.cfg.transparent_iam_max_size = atoi(parm->val);
+ SS7_DEBUG("Found a transparent_iam max size = %d\n", g_ftdm_sngss7_data.cfg.transparent_iam_max_size);
} else {
/**********************************************************************/
SS7_ERROR("Found an invalid parameter \"%s\"!\n", parm->val);
@@ -1215,7 +1221,7 @@ static int ftmod_ss7_parse_mtp_linkset(ftdm_conf_node_t *mtp_linkset)
/* go through all the mtp3 links and fill in the apc */
i = 1;
- while (g_ftdm_sngss7_data.cfg.mtp3Link[i].id != 0) {
+ while (i < (MAX_MTP_LINKS)) {
if (g_ftdm_sngss7_data.cfg.mtp3Link[i].linkSetId == mtpLinkSet.id) {
g_ftdm_sngss7_data.cfg.mtp3Link[i].apc = mtpLinkSet.apc;
}
@@ -1757,7 +1763,7 @@ static int ftmod_ss7_parse_isup_interface(ftdm_conf_node_t *isup_interface)
/**************************************************************************/
/* go through all the links and check if they belong to this linkset*/
i = 1;
- while (g_ftdm_sngss7_data.cfg.mtp3Link[i].id != 0) {
+ while (i < (MAX_MTP_LINKS)) {
/* check if this link is in the linkset */
if (g_ftdm_sngss7_data.cfg.mtp3Link[i].linkSetId == lnkSet->lsId) {
/* fill in the spc */
@@ -1841,6 +1847,7 @@ static int ftmod_ss7_parse_cc_span(ftdm_conf_node_t *cc_span)
int num_parms = cc_span->n_parameters;
int flag_clg_nadi = 0;
int flag_cld_nadi = 0;
+ int flag_rdnis_nadi = 0;
int i;
int ret;
@@ -1890,29 +1897,16 @@ static int ftmod_ss7_parse_cc_span(ftdm_conf_node_t *cc_span)
sng_ccSpan.typeCntrl = sng_cic_cntrl_type_map[ret].tril_type;
SS7_DEBUG("Found an ccSpan typeCntrl = %s\n", sng_cic_cntrl_type_map[ret].sng_type);
}
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "ssf")) {
- /**********************************************************************/
- ret = find_ssf_type_in_map(parm->val);
- if (ret == -1) {
- SS7_ERROR("Found an invalid ccSpan ssf = %s\n", parm->var);
- return FTDM_FAIL;
- } else {
- sng_ccSpan.ssf = sng_ssf_type_map[ret].tril_type;
- SS7_DEBUG("Found an ccSpan ssf = %s\n", sng_ssf_type_map[ret].sng_type);
- }
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "switchType")) {
- /**********************************************************************/
- ret = find_switch_type_in_map(parm->val);
- if (ret == -1) {
- SS7_ERROR("Found an invalid ccSpan switchType = %s\n", parm->var);
- return FTDM_FAIL;
- } else {
- sng_ccSpan.switchType = sng_switch_type_map[ret].tril_isup_type;
- SS7_DEBUG("Found an ccSpan switchType = %s\n", sng_switch_type_map[ret].sng_type);
- }
- /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "itx_auto_reply")) {
+ sng_ccSpan.itx_auto_reply = ftdm_true(parm->val);
+ SS7_DEBUG("Found itx_auto_reply %d\n", sng_ccSpan.itx_auto_reply);
+ } else if (!strcasecmp(parm->var, "transparent_iam")) {
+#ifndef HAVE_ZLIB
+ SS7_CRIT("Cannot enable transparent IAM becauze zlib not installed\n");
+#else
+ sng_ccSpan.transparent_iam = ftdm_true(parm->val);
+ SS7_DEBUG("Found transparent_iam %d\n", sng_ccSpan.transparent_iam);
+#endif
} else if (!strcasecmp(parm->var, "cicbase")) {
/**********************************************************************/
sng_ccSpan.cicbase = atoi(parm->val);
@@ -1934,16 +1928,17 @@ static int ftmod_ss7_parse_cc_span(ftdm_conf_node_t *cc_span)
flag_clg_nadi = 1;
sng_ccSpan.clg_nadi = atoi(parm->val);
SS7_DEBUG("Found default CLG_NADI parm->value = %d\n", sng_ccSpan.clg_nadi);
- /**********************************************************************/
} else if (!strcasecmp(parm->var, "cld_nadi")) {
- /**********************************************************************/
/* throw the flag so that we know we got this optional parameter */
flag_cld_nadi = 1;
sng_ccSpan.cld_nadi = atoi(parm->val);
SS7_DEBUG("Found default CLD_NADI parm->value = %d\n", sng_ccSpan.cld_nadi);
- /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "rdnis_nadi")) {
+ /* throw the flag so that we know we got this optional parameter */
+ flag_rdnis_nadi = 1;
+ sng_ccSpan.rdnis_nadi = atoi(parm->val);
+ SS7_DEBUG("Found default RDNIS_NADI parm->value = %d\n", sng_ccSpan.rdnis_nadi);
} else if (!strcasecmp(parm->var, "obci_bita")) {
- /**********************************************************************/
if (*parm->val == '1') {
sngss7_set_options(&sng_ccSpan, SNGSS7_ACM_OBCI_BITA);
SS7_DEBUG("Found Optional Backwards Indicator: Bit A (early media) enable option\n");
@@ -2034,6 +2029,15 @@ static int ftmod_ss7_parse_cc_span(ftdm_conf_node_t *cc_span)
sng_ccSpan.clg_nadi = 0x03;
}
+ if (!flag_rdnis_nadi) {
+ /* default the nadi value to national */
+ sng_ccSpan.rdnis_nadi = 0x03;
+ }
+
+ /* pull up the SSF and Switchtype from the isup interface */
+ sng_ccSpan.ssf = g_ftdm_sngss7_data.cfg.isupIntf[sng_ccSpan.isupInf].ssf;
+ sng_ccSpan.switchType = g_ftdm_sngss7_data.cfg.isupIntf[sng_ccSpan.isupInf].switchType;
+
/* add this span to our global listing */
ftmod_ss7_fill_in_ccSpan(&sng_ccSpan);
@@ -2461,7 +2465,7 @@ static int ftmod_ss7_fill_in_self_route(int spc, int linkType, int switchType, i
{
int i = 1;
- while (g_ftdm_sngss7_data.cfg.mtpRoute[i].id != 0) {
+ while (i < (MAX_MTP_ROUTES)) {
if (g_ftdm_sngss7_data.cfg.mtpRoute[i].dpc == spc) {
/* we have a match so break out of this loop */
break;
@@ -2471,6 +2475,16 @@ static int ftmod_ss7_fill_in_self_route(int spc, int linkType, int switchType, i
}
if (g_ftdm_sngss7_data.cfg.mtpRoute[i].id == 0) {
+ /* this is a new route...find the first free spot */
+ i = 1;
+ while (i < (MAX_MTP_ROUTES)) {
+ if (g_ftdm_sngss7_data.cfg.mtpRoute[i].id == 0) {
+ /* we have a match so break out of this loop */
+ break;
+ }
+ /* move on to the next one */
+ i++;
+ }
g_ftdm_sngss7_data.cfg.mtpRoute[i].id = i;
SS7_DEBUG("found new mtp3 self route\n");
} else {
@@ -2668,7 +2682,7 @@ static int ftmod_ss7_fill_in_isup_interface(sng_isup_inf_t *sng_isup)
if (sng_isup->tpause != 0) {
g_ftdm_sngss7_data.cfg.isupIntf[i].tpause = sng_isup->tpause;
} else {
- g_ftdm_sngss7_data.cfg.isupIntf[i].tpause = 150;
+ g_ftdm_sngss7_data.cfg.isupIntf[i].tpause = 3000;
}
if (sng_isup->tstaenq != 0) {
g_ftdm_sngss7_data.cfg.isupIntf[i].tstaenq = sng_isup->tstaenq;
@@ -2904,14 +2918,17 @@ static int ftmod_ss7_fill_in_ccSpan(sng_ccSpan_t *ccSpan)
g_ftdm_sngss7_data.cfg.isupCkt[x].cic = 0;
}
- g_ftdm_sngss7_data.cfg.isupCkt[x].infId = ccSpan->isupInf;
- g_ftdm_sngss7_data.cfg.isupCkt[x].typeCntrl = ccSpan->typeCntrl;
- g_ftdm_sngss7_data.cfg.isupCkt[x].ssf = ccSpan->ssf;
- g_ftdm_sngss7_data.cfg.isupCkt[x].cld_nadi = ccSpan->cld_nadi;
- g_ftdm_sngss7_data.cfg.isupCkt[x].clg_nadi = ccSpan->clg_nadi;
- g_ftdm_sngss7_data.cfg.isupCkt[x].options = ccSpan->options;
- g_ftdm_sngss7_data.cfg.isupCkt[x].switchType = ccSpan->switchType;
- g_ftdm_sngss7_data.cfg.isupCkt[x].min_digits = ccSpan->min_digits;
+ g_ftdm_sngss7_data.cfg.isupCkt[x].infId = ccSpan->isupInf;
+ g_ftdm_sngss7_data.cfg.isupCkt[x].typeCntrl = ccSpan->typeCntrl;
+ g_ftdm_sngss7_data.cfg.isupCkt[x].ssf = ccSpan->ssf;
+ g_ftdm_sngss7_data.cfg.isupCkt[x].cld_nadi = ccSpan->cld_nadi;
+ g_ftdm_sngss7_data.cfg.isupCkt[x].clg_nadi = ccSpan->clg_nadi;
+ g_ftdm_sngss7_data.cfg.isupCkt[x].rdnis_nadi = ccSpan->rdnis_nadi;
+ g_ftdm_sngss7_data.cfg.isupCkt[x].options = ccSpan->options;
+ g_ftdm_sngss7_data.cfg.isupCkt[x].switchType = ccSpan->switchType;
+ g_ftdm_sngss7_data.cfg.isupCkt[x].min_digits = ccSpan->min_digits;
+ g_ftdm_sngss7_data.cfg.isupCkt[x].itx_auto_reply = ccSpan->itx_auto_reply;
+ g_ftdm_sngss7_data.cfg.isupCkt[x].transparent_iam = ccSpan->transparent_iam;
if (ccSpan->t3 == 0) {
g_ftdm_sngss7_data.cfg.isupCkt[x].t3 = 1200;
diff --git a/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c b/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c
index b648daadaf..2bf9f6bc2e 100644
--- a/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c
+++ b/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c
@@ -91,6 +91,8 @@ typedef enum {
*/
static struct {
uint32_t codec_ms;
+ uint32_t rxqueue_size;
+ uint32_t txqueue_size;
uint32_t wink_ms;
uint32_t flash_ms;
uint32_t ring_on_ms;
@@ -406,6 +408,20 @@ static FIO_CONFIGURE_FUNCTION(wanpipe_configure)
} else {
wp_globals.codec_ms = num;
}
+ } else if (!strcasecmp(var, "rxqueue_size")) {
+ num = atoi(val);
+ if (num < 1 || num > 1000) {
+ ftdm_log(FTDM_LOG_WARNING, "invalid rx queue size at line %d\n", lineno);
+ } else {
+ wp_globals.rxqueue_size = num;
+ }
+ } else if (!strcasecmp(var, "txqueue_size")) {
+ num = atoi(val);
+ if (num < 1 || num > 1000) {
+ ftdm_log(FTDM_LOG_WARNING, "invalid tx queue size at line %d\n", lineno);
+ } else {
+ wp_globals.txqueue_size = num;
+ }
} else if (!strcasecmp(var, "wink_ms")) {
num = atoi(val);
if (num < 50 || num > 3000) {
@@ -544,6 +560,13 @@ static FIO_OPEN_FUNCTION(wanpipe_open)
ftdm_channel_set_feature(ftdmchan, FTDM_CHANNEL_FEATURE_INTERVAL);
ftdmchan->effective_interval = ftdmchan->native_interval = wp_globals.codec_ms;
ftdmchan->packet_len = ftdmchan->native_interval * 8;
+
+ if (wp_globals.txqueue_size > 0) {
+ ftdm_channel_command(ftdmchan, FTDM_COMMAND_SET_TX_QUEUE_SIZE, &wp_globals.txqueue_size);
+ }
+ if (wp_globals.rxqueue_size > 0) {
+ ftdm_channel_command(ftdmchan, FTDM_COMMAND_SET_RX_QUEUE_SIZE, &wp_globals.rxqueue_size);
+ }
}
return FTDM_SUCCESS;
@@ -927,7 +950,6 @@ static void wanpipe_read_stats(ftdm_channel_t *ftdmchan, wp_tdm_api_rx_hdr_t *rx
static FIO_READ_FUNCTION(wanpipe_read)
{
int rx_len = 0;
- int myerrno = 0;
wp_tdm_api_rx_hdr_t hdrframe;
memset(&hdrframe, 0, sizeof(hdrframe));
@@ -941,7 +963,6 @@ static FIO_READ_FUNCTION(wanpipe_read)
}
if (rx_len < 0) {
- myerrno = errno;
snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "%s", strerror(errno));
ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Failed to read from sangoma device: %s (%d)\n", strerror(errno), rx_len);
return FTDM_FAIL;
@@ -1246,7 +1267,7 @@ static FIO_GET_ALARMS_FUNCTION(wanpipe_get_alarms)
ftdm_channel_command(ftdmchan, FTDM_COMMAND_GET_LINK_STATUS, &sangoma_status);
ftdmchan->alarm_flags = sangoma_status == FTDM_HW_LINK_DISCONNECTED ? FTDM_ALARM_RED : FTDM_ALARM_NONE;
ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Link status is %d\n", sangoma_status);
- }
+ }
}
if (alarms) {
@@ -1270,6 +1291,7 @@ static __inline__ ftdm_status_t wanpipe_channel_process_event(ftdm_channel_t *fc
switch(tdm_api->wp_tdm_cmd.event.wp_tdm_api_event_type) {
case WP_API_EVENT_LINK_STATUS:
{
+ if (FTDM_IS_DIGITAL_CHANNEL(fchan)) {
switch(tdm_api->wp_tdm_cmd.event.wp_tdm_api_event_link_status) {
case WP_TDMAPI_EVENT_LINK_STATUS_CONNECTED:
/* *event_id = FTDM_OOB_ALARM_CLEAR; */
@@ -1282,6 +1304,22 @@ static __inline__ ftdm_status_t wanpipe_channel_process_event(ftdm_channel_t *fc
};
/* The WP_API_EVENT_ALARM event should be used to clear alarms */
*event_id = FTDM_OOB_NOOP;
+ } else {
+ switch(tdm_api->wp_tdm_cmd.event.wp_tdm_api_event_link_status) {
+ case WP_TDMAPI_EVENT_LINK_STATUS_CONNECTED:
+ /* *event_id = FTDM_OOB_ALARM_CLEAR; */
+ ftdm_log_chan_msg(fchan, FTDM_LOG_DEBUG, "Using analog link connected event as alarm clear\n");
+ *event_id = FTDM_OOB_ALARM_CLEAR;
+ fchan->alarm_flags = FTDM_ALARM_NONE;
+ break;
+ default:
+ /* *event_id = FTDM_OOB_ALARM_TRAP; */
+ ftdm_log_chan_msg(fchan, FTDM_LOG_DEBUG, "Using analog link disconnected event as alarm trap\n");
+ *event_id = FTDM_OOB_ALARM_TRAP;
+ fchan->alarm_flags = FTDM_ALARM_RED;
+ break;
+ };
+ }
}
break;
@@ -1315,14 +1353,12 @@ static __inline__ ftdm_status_t wanpipe_channel_process_event(ftdm_channel_t *fc
status = FTDM_BREAK;
} else {
ftdm_status_t status;
- wanpipe_tdm_api_t onhook_tdm_api;
- memset(&onhook_tdm_api, 0, sizeof(onhook_tdm_api));
- status = sangoma_tdm_txsig_onhook(fchan->sockfd, &onhook_tdm_api);
+ status = sangoma_tdm_txsig_onhook(fchan->sockfd, tdm_api);
if (status) {
snprintf(fchan->last_error, sizeof(fchan->last_error), "ONHOOK Failed");
return FTDM_FAIL;
}
- *event_id = onhook_tdm_api.wp_tdm_cmd.event.wp_tdm_api_event_hook_state & WP_TDMAPI_EVENT_RXHOOK_OFF ? FTDM_OOB_ONHOOK : FTDM_OOB_NOOP;
+ *event_id = tdm_api->wp_tdm_cmd.event.wp_tdm_api_event_hook_state & WP_TDMAPI_EVENT_RXHOOK_OFF ? FTDM_OOB_ONHOOK : FTDM_OOB_NOOP;
}
}
break;
@@ -1575,6 +1611,9 @@ static FIO_IO_LOAD_FUNCTION(wanpipe_init)
wp_globals.flash_ms = 750;
wp_globals.ring_on_ms = 2000;
wp_globals.ring_off_ms = 4000;
+ /* 0 for queue size will leave driver defaults */
+ wp_globals.txqueue_size = 0;
+ wp_globals.rxqueue_size = 0;
wanpipe_interface.name = "wanpipe";
wanpipe_interface.configure_span = wanpipe_configure_span;
wanpipe_interface.configure = wanpipe_configure;
diff --git a/libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.c b/libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.c
index 1b55b739fc..9c01b41299 100644
--- a/libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.c
+++ b/libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.c
@@ -1064,6 +1064,20 @@ static __inline__ ftdm_status_t zt_channel_process_event(ftdm_channel_t *fchan,
fchan->rx_cas_bits = bits;
}
break;
+ case ZT_EVENT_BADFCS:
+ {
+ ftdm_log_chan_msg(fchan, FTDM_LOG_ERROR, "Bad frame checksum (ZT_EVENT_BADFCS)!\n");
+ /* What else could we do? */
+ *event_id = FTDM_OOB_NOOP;
+ }
+ break;
+ case ZT_EVENT_OVERRUN:
+ {
+ ftdm_log_chan_msg(fchan, FTDM_LOG_ERROR, "Driver overrun! (ZT_EVENT_OVERRUN)\n");
+ /* What else could we do? */
+ *event_id = FTDM_OOB_NOOP;
+ }
+ break;
case ZT_EVENT_NONE:
{
ftdm_log_chan_msg(fchan, FTDM_LOG_DEBUG, "No event\n");
diff --git a/libs/freetdm/src/include/freetdm.h b/libs/freetdm/src/include/freetdm.h
index 6556164aac..253f256ffa 100755
--- a/libs/freetdm/src/include/freetdm.h
+++ b/libs/freetdm/src/include/freetdm.h
@@ -241,12 +241,12 @@ FTDM_STR2ENUM_P(ftdm_str2ftdm_ton, ftdm_ton2str, ftdm_ton_t)
/*! Numbering Plan Identification (NPI) */
typedef enum {
FTDM_NPI_UNKNOWN = 0,
- FTDM_NPI_ISDN = 1,
- FTDM_NPI_DATA = 3,
- FTDM_NPI_TELEX = 4,
- FTDM_NPI_NATIONAL = 8,
- FTDM_NPI_PRIVATE = 9,
- FTDM_NPI_RESERVED = 10,
+ FTDM_NPI_ISDN,
+ FTDM_NPI_DATA,
+ FTDM_NPI_TELEX,
+ FTDM_NPI_NATIONAL,
+ FTDM_NPI_PRIVATE,
+ FTDM_NPI_RESERVED,
FTDM_NPI_INVALID
} ftdm_npi_t;
#define NPI_STRINGS "unknown", "ISDN", "data", "telex", "national", "private", "reserved", "invalid"
@@ -276,12 +276,16 @@ FTDM_STR2ENUM_P(ftdm_str2ftdm_screening, ftdm_screening2str, ftdm_screening_t)
/*! \brief bearer capability */
typedef enum {
- FTDM_BEARER_CAP_SPEECH = 0x00,
- FTDM_BEARER_CAP_64K_UNRESTRICTED = 0x02,
- FTDM_BEARER_CAP_3_1KHZ_AUDIO = 0x03,
+ FTDM_BEARER_CAP_SPEECH = 0x00, /* Speech */
+ FTDM_BEARER_CAP_UNRESTRICTED, /* Unrestricted Digital */
+ FTDM_BEARER_CAP_RESTRICTED, /* Restricted Digital */
+ FTDM_BEARER_CAP_3_1KHZ_AUDIO, /* 3.1 Khz Audio */
+ FTDM_BEARER_CAP_7KHZ_AUDIO, /* 7 Khz Audio or Unrestricted digital w tones */
+ FTDM_BEARER_CAP_15KHZ_AUDIO, /* 15 Khz Audio */
+ FTDM_BEARER_CAP_VIDEO, /* Video */
FTDM_BEARER_CAP_INVALID
} ftdm_bearer_cap_t;
-#define BEARER_CAP_STRINGS "speech", "unrestricted-digital-information", "3.1-Khz-audio", "invalid"
+#define BEARER_CAP_STRINGS "speech", "unrestricted-digital-information", "restricted-digital-information", "3.1-Khz-audio", "7-Khz-audio", "15-Khz-audio", "video", "invalid"
FTDM_STR2ENUM_P(ftdm_str2ftdm_bearer_cap, ftdm_bearer_cap2str, ftdm_bearer_cap_t)
/*! \brief user information layer 1 protocol */
@@ -291,13 +295,18 @@ typedef enum {
FTDM_USER_LAYER1_PROT_ALAW = 0x03,
FTDM_USER_LAYER1_PROT_INVALID
} ftdm_user_layer1_prot_t;
-#define USER_LAYER1_PROT_STRINGS "V.110", "u-law", "a-law", "Invalid"
+#define USER_LAYER1_PROT_STRINGS "V.110", "ulaw", "alaw", "Invalid"
FTDM_STR2ENUM_P(ftdm_str2ftdm_usr_layer1_prot, ftdm_user_layer1_prot2str, ftdm_user_layer1_prot_t)
/*! Calling Party Category */
typedef enum {
FTDM_CPC_UNKNOWN,
FTDM_CPC_OPERATOR,
+ FTDM_CPC_OPERATOR_FRENCH,
+ FTDM_CPC_OPERATOR_ENGLISH,
+ FTDM_CPC_OPERATOR_GERMAN,
+ FTDM_CPC_OPERATOR_RUSSIAN,
+ FTDM_CPC_OPERATOR_SPANISH,
FTDM_CPC_ORDINARY,
FTDM_CPC_PRIORITY,
FTDM_CPC_DATA,
@@ -305,12 +314,14 @@ typedef enum {
FTDM_CPC_PAYPHONE,
FTDM_CPC_INVALID
} ftdm_calling_party_category_t;
-#define CALLING_PARTY_CATEGORY_STRINGS "unknown", "operator", "ordinary", "priority", "data-call", "test-call", "payphone", "invalid"
+#define CALLING_PARTY_CATEGORY_STRINGS "unknown", "operator", "operator-french", "operator-english", "operator-german", "operator-russian", "operator-spanish", "ordinary", "priority", "data-call", "test-call", "payphone", "invalid"
FTDM_STR2ENUM_P(ftdm_str2ftdm_calling_party_category, ftdm_calling_party_category2str, ftdm_calling_party_category_t)
/*! \brief Digit limit used in DNIS/ANI */
#define FTDM_DIGITS_LIMIT 25
+#define FTDM_SILENCE_VALUE(fchan) (fchan)->native_codec == FTDM_CODEC_ULAW ? 255 : (fchan)->native_codec == FTDM_CODEC_ALAW ? 0xD5 : 0x00
+
/*! \brief Number abstraction */
typedef struct {
char digits[FTDM_DIGITS_LIMIT];
@@ -1463,11 +1474,6 @@ FT_DECLARE(ftdm_iterator_t *) ftdm_iterator_next(ftdm_iterator_t *iter);
*/
FT_DECLARE(ftdm_status_t) ftdm_iterator_free(ftdm_iterator_t *iter);
-/*! \brief Clears all the temporary data attached to this call
- * \note Clears caller_data->variables and caller_data->raw_data.
- * */
-FT_DECLARE(void) ftdm_call_clear_data(ftdm_caller_data_t *caller_data);
-
/*! \brief Get the span pointer associated to the channel */
FT_DECLARE(ftdm_span_t *) ftdm_channel_get_span(const ftdm_channel_t *ftdmchan);
diff --git a/libs/freetdm/src/include/ftdm_call_utils.h b/libs/freetdm/src/include/ftdm_call_utils.h
index 2418273343..975e73e729 100644
--- a/libs/freetdm/src/include/ftdm_call_utils.h
+++ b/libs/freetdm/src/include/ftdm_call_utils.h
@@ -131,5 +131,24 @@ FT_DECLARE(ftdm_status_t) ftdm_is_number(const char *number);
*/
FT_DECLARE(ftdm_status_t) ftdm_set_calling_party_category(const char *string, uint8_t *target);
+/*!
+ * \brief URL encode a buffer
+ *
+ * \param url buffer to convert
+ * \param buf target to save converted string to
+ * \param len size of buffer
+ *
+ * \retval pointer to converted string
+ */
+FT_DECLARE(char *) ftdm_url_encode(const char *url, char *buf, ftdm_size_t len);
+
+/*!
+ * \param s buffer to convert
+ * \param len size of buffer
+ *
+ * \retval pointer to converted string
+ */
+FT_DECLARE(char *) ftdm_url_decode(char *s, ftdm_size_t *len);
+
#endif /* __FTDM_CALL_UTILS_H__ */
diff --git a/libs/freetdm/src/include/private/ftdm_types.h b/libs/freetdm/src/include/private/ftdm_types.h
index b263b64a2d..e4d2b6900d 100755
--- a/libs/freetdm/src/include/private/ftdm_types.h
+++ b/libs/freetdm/src/include/private/ftdm_types.h
@@ -249,6 +249,8 @@ typedef enum {
#define FTDM_CHANNEL_IND_ACK_PENDING (1ULL << 34)
/*!< There is someone blocking in the channel waiting for state completion */
#define FTDM_CHANNEL_BLOCKING (1ULL << 35)
+/*!< Media is digital */
+#define FTDM_CHANNEL_DIGITAL_MEDIA (1ULL << 36)
#include "ftdm_state.h"
diff --git a/libs/freetdm/src/libteletone_generate.c b/libs/freetdm/src/libteletone_generate.c
index 7f37b7a258..c0d6a54349 100644
--- a/libs/freetdm/src/libteletone_generate.c
+++ b/libs/freetdm/src/libteletone_generate.c
@@ -273,7 +273,7 @@ TELETONE_API(int) teletone_mux_tones(teletone_generation_session_t *ts, teletone
TELETONE_API(int) teletone_run(teletone_generation_session_t *ts, const char *cmd)
{
char *data = NULL, *cur = NULL, *end = NULL;
- int var = 0, LOOPING = 0;
+ int LOOPING = 0;
if (!cmd) {
return -1;
@@ -287,7 +287,6 @@ TELETONE_API(int) teletone_run(teletone_generation_session_t *ts, const char *cm
cur = data;
while (*cur) {
- var = 0;
if (*cur == ' ' || *cur == '\r' || *cur == '\n') {
cur++;
continue;
@@ -298,7 +297,6 @@ TELETONE_API(int) teletone_run(teletone_generation_session_t *ts, const char *cm
}
if (*(cur + 1) == '=') {
- var = 1;
switch(*cur) {
case 'c':
ts->channels = atoi(cur + 2);
diff --git a/libs/ldns/Changelog b/libs/ldns/Changelog
new file mode 100644
index 0000000000..ffbcb3fe92
--- /dev/null
+++ b/libs/ldns/Changelog
@@ -0,0 +1,584 @@
+1.6.9 2011-03-16
+ * Fix creating NSEC(3) bitmaps: make array size 65536,
+ don't add doubles.
+ * Fix printout of escaped binary in TXT records.
+ * Parsing TXT records: don't skip starting whitespace that is quoted.
+ * bugfix #358: Check if memory was successfully allocated in
+ ldns_rdf2str().
+ * Added more memory allocation checks in host2str.c
+ * python wrapper for ldns_fetch_valid_domain_keys by Bedrich Kosata.
+ * fix to compile python wrapper with swig 2.0.2.
+ * Don't fallback to SHA-1 when creating NSEC3 hash with another
+ algorithm identifier, fail instead (no other algorithm identifiers
+ are assigned yet).
+
+1.6.8 2011-01-24
+ * Fix ldns zone, so that $TTL definition match RFC 2308.
+ * Fix lots of missing checks on allocation failures and parse of
+ NSEC with many types and max parse length in hosts_frm_fp routine
+ and off by one in read_anchor_file routine (thanks Dan Kaminsky and
+ Justin Ferguson).
+ * bugfix #335: Drill: Print both SHA-1 and SHA-256 corresponding DS
+ records.
+ * Print correct WHEN in query packet (is not always 1-1-1970)
+ * ldns-test-edns: new example tool that detects EDNS support.
+ * fix ldns_resolver_send without openssl.
+ * bugfix #342: patch for support for more CERT key types (RFC4398).
+ * bugfix #351: fix udp_send hang if UDP checksum error.
+ * fix set_bit (from NSEC3 sign) patch from Jan Komissar.
+
+1.6.7 2010-11-08
+ * EXPERIMENTAL ecdsa implementation, please do not enable on real
+ servers.
+ * GOST code enabled by default (RFC 5933).
+ * bugfix #326: ignore whitespace between directives and their values.
+ * Header comment to advertise ldns_axfr_complete to check for
+ successfully completed zone transfers.
+ * read resolv.conf skips interface labels, e.g. %eth0.
+ * Fix drill verify NSEC3 denials.
+ * Use closesocket() on windows.
+ * Add ldns_get_signing_algorithm_by_name that understand aliases,
+ names changed to RFC names and aliases for compatibility added.
+ * bugfix: don't print final dot if the domain is relative.
+ * bugfix: resolver search continue when packet rcode != NOERROR.
+ * bugfix: resolver push all domains in search directive to list.
+ * bugfix: resolver search by default includes the root domain.
+ * bugfix: tcp read could fail on single octet recv.
+ * bugfix: read of RR in unknown syntax with missing fields.
+ * added ldns_pkt_tsig_sign_next() and ldns_pkt_tsig_verify_next()
+ to sign and verify TSIG RRs on subsequent messages
+ (section 4.4, RFC 2845, thanks to Michael Sheldon).
+ * bugfix: signer sigs nsecs with zsks only.
+ * bugfix #333: fix ldns_dname_absolute for name ending with backslash.
+
+1.6.6 2010-08-09
+ * Fix ldns_rr_clone to copy question rrs properly.
+ * Fix ldns_sign_zone(_nsec3) to clone the soa for the new zone.
+ * Fix ldns_wire2dname size check from reading 1 byte beyond buffer end.
+ * Fix ldns_wire2dname from reading 1 byte beyond end for pointer.
+ * Fix crash using GOST for particular platform configurations.
+ * extern C declarations used in the header file.
+ * Removed debug fprintf from resolver.c.
+ * ldns-signzone checks if public key file is for the right zone.
+ * NETLDNS, .NET port of ldns functionality, by Alex Nicoll, in contrib.
+ * Fix handling of comments in resolv.conf parse.
+ * GOST code enabled if SSL recent, RFC 5933.
+ * bugfix #317: segfault util.c ldns_init_random() fixed.
+ * Fix ldns_tsig_mac_new: allocate enough memory for the hash, fix use of
+ b64_pton_calculate_size.
+ * Fix ldns_dname_cat: size calculation and handling of realloc().
+ * Fix ldns_rr_pop_rdf: fix handling of realloc().
+ * Fix ldns-signzone for single type key scheme: sign whole zone if there
+ are only KSKs.
+ * Fix ldns_resolver: also close socket if AXFR failed (if you don't,
+ it would block subsequent transfers (thanks Roland van Rijswijk).
+ * Fix drill: allow for a secure trace if you use DS records as trust
+ anchors (thanks Jan Komissar).
+
+1.6.5 2010-06-15
+ * Catch \X where X is a digit as an error.
+ * Fix segfault when ip6 ldns resolver only has ip4 servers.
+ * Fix NSEC record after DNSKEY at zone apex not properly signed.
+ * Fix syntax error if last label too long and no dot at end of domain.
+ * Fix parse of \# syntax with space for type LOC.
+ * Fix ldns_dname_absolute for escape sequences, fixes some parse errs.
+ * bugfix #297: linking ssl, bug due to patch submitted as #296.
+ * bugfix #299: added missing declarations to host2str.h
+ * ldns-compare-zones -s to not exclude SOA record from comparison.
+ * --disable-rpath fix
+ * fix ldns_pkt_empty(), reported by Alex Nicoll.
+ * fix ldns_resolver_new_frm_fp not ignore lines after a comment.
+ * python code for ldns_rr.new_question_frm_str()
+ * Fix ldns_dnssec_verify_denial: the signature selection routine.
+ * Type TALINK parsed (draft-ietf-dnsop-trust-history).
+ * bugfix #304: fixed dead loop in ldns_tcp_read_wire() and
+ ldns_tcp_read_wire_timeout().
+ * GOST support with correct algorithm numbers. The plan is to make it
+ enabled if openssl support is detected, but it is disabled by
+ default in this release because the RFC is not ready.
+ * Fixed comment in rbtree.h about being first member and data ptr.
+ * Fixed possibly leak in case of out of memory in ldns_native2rdf...
+ * ldns_dname_is_wildcard added.
+ * Fixed: signatures over wildcards had the wrong labelcount.
+ * Fixed ldns_verify() inconsistent return values.
+ * Fixed ldns_resolver to copy and free tsig name, data and algorithm.
+ * Fixed ldns_resolver to push search onto searchlist.
+ * A ldns resolver now defaults to a non-recursive resolver that handles
+ the TC bit.
+ * ldns_resolver_print() prints more details.
+ * Fixed ldns_rdf2buffer_str_time(), which did not print timestamps
+ on 64bit systems.
+ * Make ldns_resolver_nameservers_randomize() more random.
+ * bugfix #310: POSIX specifies NULL second argument of gettimeofday.
+ * fix compiler warnings from llvm clang compiler.
+ * bugfix #309: ldns_pkt_clone did not clone the tsig_rr.
+ * Fix gentoo ebuild for drill, 'no m4 directory'.
+ * bugfix #313: drill trace on an empty nonterminal continuation.
+
+1.6.4 2010-01-20
+ * Imported pyldns contribution by Zdenek Vasicek and Karel Slany.
+ Changed its configure and Makefile to fit into ldns.
+ Added its dname_* methods to the rdf_* class (as is the ldns API).
+ Changed swig destroy of ldns_buffer class to ldns_buffer_free.
+ Declared ldns_pkt_all and ldns_pkt_all_noquestion so swig sees them.
+ * Bugfix: parse PTR target of .tomhendrikx.nl with error not crash.
+ * Bugfix: handle escaped characters in TXT rdata.
+ * bug292: no longer crash on malformed domain names where a label is
+ on position 255, which was a buffer overflow by one.
+ * Fix ldns_get_rr_list_hosts_frm_fp_l (strncpy to strlcpy change),
+ which fixes resolv.conf reading badly terminated string buffers.
+ * Fix ldns_pkt_set_random_id to be more random, and a little faster,
+ it did not do value 0 statistically correctly.
+ * Fix ldns_rdf2native_sockaddr_storage to set sockaddr type to zeroes,
+ for portability.
+ * bug295: nsec3-hash routine no longer case sensitive.
+ * bug298: drill failed nsec3 denial of existence proof.
+
+1.6.3 2009-12-04
+ * Bugfix: allow for unknown resource records in zonefile with rdlen=0.
+ * Bugfix: also mark an RR as question if it comes from the wire
+ * Bugfix: NSEC3 bitmap contained NSEC
+ * Bugfix: Inherit class when creating signatures
+
+1.6.2 2009-11-12
+ * Fix Makefile patch from Havard Eidnes, better install.sh usage.
+ * Fix parse error on SOA serial of 2910532839.
+ Fix print of ';' and readback of '\;' in names, also for '\\'.
+ Fix parse of '\(' and '\)' in names. Also for file read. Also '\.'
+ * Fix signature creation when TTLs are different for RRs in RRset.
+ * bug273: fix so EDNS rdata is included in pkt to wire conversion.
+ * bug274: fix use of c++ keyword 'class' for RR class in the code.
+ * bug275: fix memory leak of packet edns rdata.
+ * Fix timeout procedure for TCP and AXFR on Solaris.
+ * Fix occasional NSEC bitmap bogus
+ * Fix rr comparing (was in reversed order since 1.6.0)
+ * bug278: fix parsing HINFO rdata (and other cases).
+ * Fix previous owner name: also pick up if owner name is @.
+ * RFC5702: enabled sha2 functions by default. This requires OpenSSL 0.9.8 or higher.
+ Reason for this default is the root to be signed with RSASHA256.
+ * Fix various LDNS RR parsing issues: IPSECKEY, WKS, NSAP, very long lines
+ * Fix: Make ldns_dname_is_subdomain case insensitive.
+ * Fix ldns-verify-zone so that address records at zone NS set are not considered glue
+ (Or glue records fall below delegation)
+ * Fix LOC RR altitude printing.
+ * Feature: Added period (e.g. '3m6d') support at explicit TTLs.
+ * Feature: DNSKEY rrset by default signed with minimal signatures
+ but -A option for ldns-signzone to sign it with all keys.
+ This makes the DNSKEY responses smaller for signed domains.
+
+1.6.1 2009-09-14
+ * --enable-gost : use the GOST algorithm (experimental).
+ * Added some missing options to drill manpage
+ * Some fixes to --without-ssl option
+ * Fixed quote parsing withing strings
+ * Bitmask fix in EDNS handling
+ * Fixed non-fqdn domain name completion for rdata field domain
+ names of length 1
+ * Fixed chain validation with SHA256 DS records
+
+1.6.0
+ Additions:
+ * Addition of an ldns-config script which gives cflags and libs
+ values, for use in configure scripts for applications that use
+ use ldns. Can be disabled with ./configure --disable-ldns-config
+ * Added direct sha1, sha256, and sha512 support in ldns.
+ With these functions, all NSEC3 functionality can still be
+ used, even if ldns is built without OpenSSL. Thanks to OpenBSD,
+ Steve Reid, and Aaron D. Gifford for the code.
+ * Added reading/writing support for the SPF Resource Record
+ * Base32 functions are now exported
+ Bugfixes:
+ * ldns_is_rrset did not go through the complete rrset, but
+ only compared the first two records. Thanks to Olafur
+ Gudmundsson for report and patch
+ * Fixed a small memory bug in ldns_rr_list_subtype_by_rdf(),
+ thanks to Marius Rieder for finding an patching this.
+ * --without-ssl should now work. Make sure that examples/ and
+ drill also get the --without-ssl flag on their configure, if
+ this is used.
+ * Some malloc() return value checks have been added
+ * NSEC3 creation has been improved wrt to empty nonterminals,
+ and opt-out.
+ * Fixed a bug in the parser when reading large NSEC3 salt
+ values.
+ * Made the allowed length for domain names on wire
+ and presentation format the same.
+ Example tools:
+ * ldns-key2ds can now also generate DS records for keys without
+ the SEP flag
+ * ldns-signzone now equalizes the TTL of the DNSKEY RRset (to
+ the first non-default DNSKEY TTL value it sees)
+
+1.5.1
+ Example tools:
+ * ldns-signzone was broken in 1.5.0 for multiple keys, this
+ has been repaired
+
+ Build system:
+ * Removed a small erroneous output warning in
+ examples/configure and drill/configure
+
+1.5.0
+ Bug fixes:
+ * fixed a possible memory overflow in the RR parser
+ * build flag fix for Sun Studio
+ * fixed a building race condition in the copying of header
+ files
+ * EDNS0 extended rcode; the correct assembled code number
+ is now printed (still in the EDNS0 field, though)
+ * ldns_pkt_rr no longer leaks memory (in fact, it no longer
+ copies anything all)
+
+ API addition:
+ * ldns_key now has support for 'external' data, in which
+ case the OpenSSL EVP structures are not used;
+ ldns_key_set_external_key() and ldns_key_external_key()
+ * added ldns_key_get_file_base_name() which creates a
+ 'default' filename base string for key storage, of the
+ form "K++"
+ * the ldns_dnssec_* family of structures now have deep_free()
+ functions, which also free the ldns_rr's contained in them
+ * there is now an ldns_match_wildcard() function, which checks
+ whether a domain name matches a wildcard name
+ * ldns_sign_public has been split up; this resulted in the
+ addition of ldns_create_empty_rrsig() and
+ ldns_sign_public_buffer()
+
+ Examples:
+ * ldns-signzone can now automatically add DNSKEY records when
+ using an OpenSSL engine, as it already did when using key
+ files
+ * added new example tool: ldns-nsec3-hash
+ * ldns-dpa can now filter on specific query name and types
+ * ldnsd has fixes for the zone name, a fix for the return
+ value of recvfrom(), and an memory initialization fix
+ (Thanks to Colm MacCárthaigh for the patch)
+ * Fixed memory leaks in ldnsd
+
+
+
+1.4.1
+ Bug fixes:
+ * fixed a build issue where ldns lib existence was done too early
+ * removed unnecessary check for pcap.h
+ * NSEC3 optout flag now correctly printed in string output
+ * inttypes.h moved to configured inclusion
+ * fixed NSEC3 type bitmaps for empty nonterminals and unsigned
+ delegations
+
+ API addition:
+ * for that last fix, we added a new function
+ ldns_dname_add_from() that can clone parts of a dname
+
+1.4.0
+ Bug fixes:
+ * sig chase return code fix (patch from Rafael Justo, bug id 189)
+ * rdata.c memory leaks on error and allocation checks fixed (patch
+ from Shane Kerr, bug id 188)
+ * zone.c memory leaks on error and allocation checks fixed (patch
+ from Shane Kerr, bug id 189)
+ * ldns-zplit output and error messages fixed (patch from Shane Kerr,
+ bug id 190)
+ * Fixed potential buffer overflow in ldns_str2rdf_dname
+ * Signing code no longer signs delegation NS rrsets
+ * Some minor configure/makefile updates
+ * Fixed a bug in the randomness initialization
+ * Fixed a bug in the reading of resolv.conf
+ * Fixed a bug concerning whitespace in zone data (with patch from Ondrej
+ Sury, bug 213)
+ * Fixed a small fallback problem in axfr client code
+
+ API CHANGES:
+ * added 2str convenience functions:
+ - ldns_rr_type2str
+ - ldns_rr_class2str
+ - ldns_rr_type2buffer_str
+ - ldns_rr_class2buffer_str
+ * buffer2str() is now called ldns_buffer2str
+ * base32 and base64 function names are now also prepended with ldns_
+ * ldns_rr_new_frm_str() now returns an error on missing RDATA fields.
+ Since you cannot read QUESTION section RRs with this anymore,
+ there is now a function called ldns_rr_new_question_frm_str()
+
+ LIBRARY FEATURES:
+ * DS RRs string representation now add bubblebabble in a comment
+ (patch from Jakob Schlyter)
+ * DLV RR type added
+ * TCP fallback system has been improved
+ * HMAC-SHA256 TSIG support has been added.
+ * TTLS are now correcly set in NSEC(3) records when signing zones
+
+ EXAMPLE TOOLS:
+ * New example: ldns-revoke to revoke DNSKEYs according to RFC5011
+ * ldns-testpkts has been fixed and updated
+ * ldns-signzone now has the option to not add the DNSKEY
+ * ldns-signzone now has an (full zone only) opt-out option for
+ NSEC3
+ * ldns-keygen can create HMAC-SHA1 and HMAC-SHA256 symmetric keys
+ * ldns-walk output has been fixed
+ * ldns-compare-zones has been fixed, and now has an option
+ to show all differences (-a)
+ * ldns-read-zone now has an option to print DNSSEC records only
+
+1.3
+ Base library:
+
+ * Added a new family of functions based around ldns_dnssec_zone,
+ which is a new structure that keeps a zone sorted through an
+ rbtree and links signatures and NSEC(3) records directly to their
+ RRset. These functions all start with ldns_dnssec_
+
+ * ldns_zone_sign and ldns_zone_sign_nsec3 are now deprecated, but
+ have been changed to internally use the new
+ ldns_dnssec_zone_sign(_nsec3)
+
+ * Moved some ldns_buffer functions inline, so a clean rebuild of
+ applications relying on those is needed (otherwise you'll get
+ linker errors)
+ * ldns_dname_label now returns one extra (zero)
+ byte, so it can be seen as an fqdn.
+ * NSEC3 type code update for signing algorithms.
+ * DSA key generation of DNSKEY RRs fixed (one byte too small).
+
+ * Added support for RSA/SHA256 and RSA/SHA512, as specified in
+ draft-ietf-dnsext-dnssec-rsasha256-04. The typecodes are not
+ final, and this feature is not enabled by default. It can be
+ enabled at compilation time with the flag --with-sha2
+
+ * Added 2wire_canonical family of functions that lowercase dnames
+ in rdata fields in resource records of the types in the list in
+ rfc3597
+
+ * Added base32 conversion functions.
+
+ * Fixed DSA RRSIG conversion when calling OpenSSL
+
+ Drill:
+
+ * Chase output is completely different, it shows, in ascii, the
+ relations in the trust hierarchy.
+
+ Examples:
+ * Added ldns-verify-zone, that can verify the internal DNSSEC records
+ of a signed BIND-style zone file
+
+ * ldns-keygen now takes an -a argument specifying the algorithm,
+ instead of -R or -D. -a list show a list of supported algorithms
+
+ * ldns-keygen now defaults to the exponent RSA_F4 instead of RSA_3
+ for RSA key generation
+
+ * ldns-signzone now has support for HSMs
+ * ldns-signzone uses the new ldns_dnssec_ structures and functions
+ which improves its speed, and output; RRSIGS are now placed
+ directly after their RRset, NSEC(3) records directly after the
+ name they handle
+
+ Contrib:
+ * new contrib/ dir with user contributions
+ * added compilation script for solaris (thanks to Jakob Schlyter)
+
+28 Nov 2007 1.2.2:
+ * Added support for HMAC-MD5 keys in generator
+ * Added a new example tool (written by Ondrej Sury): ldns-compare-zones
+ * ldns-keygen now checks key sizes for rfc conformancy
+ * ldns-signzone outputs SSL error if present
+ * Fixed manpages (thanks to Ondrej Sury)
+ * Fixed Makefile for -j
+ * Fixed a $ORIGIN error when reading zones
+ * Fixed another off-by-one error
+
+03 Oct 2007 1.2.1:
+ * Fixed an offset error in rr comparison
+ * Fixed ldns-read-zone exit code
+ * Added check for availability of SHA256 hashing algorithm
+ * Fixed ldns-key2ds -2 argument
+ * Fixed $ORIGIN bug in .key files
+ * Output algorithms as an integer instead of their mnemonic
+ * Fixed a memory leak in dnssec code when SHA256 is not available
+ * Updated fedora .spec file
+
+11 Apr 2007 1.2.0:
+ * canonicalization of rdata in DNSSEC functions now adheres to the
+ rr type list in rfc3597, not rfc4035, which will be updated
+ (see http://www.ops.ietf.org/lists/namedroppers/namedroppers.2007/msg00183.html)
+ * ldns-walk now support dnames with maximum label length
+ * ldnsd now takes an extra argument containing the address to listen on
+ * signing no longer signs every rrset with KSK's, but only the DNSKEY rrset
+ * ported to Solaris 10
+ * added ldns_send_buffer() function
+ * added ldns-testpkts fake packet server
+ * added ldns-notify to send NOTIFY packets
+ * ldns-dpa can now accurately calculate the number of matches per
+ second
+ * libtool is now used for compilation too (still gcc, but not directly)
+ * Bugfixes:
+ - TSIG signing buffer size
+ - resolv.conf reading (comments)
+ - dname comparison off by one error
+ - typo in keyfetchers output file name fixed (a . too much)
+ - fixed zone file parser when comments contain ( or )
+ - fixed LOC RR type
+ - fixed CERT RR type
+
+ Drill:
+ * drill prints error on failed axfr.
+ * drill now accepts mangled packets with -f
+ * old -c option (use tcp) changed to -t
+ * -c option to specify alternative resolv.conf file added
+ * feedback of signature chase improved
+ * chaser now stops at root when no trusted keys are found
+ instead of looping forever trying to find the DS for .
+ * Fixed bugs:
+ - wildcard on multiple labels signature verification
+ - error in -f packet writing for malformed packets
+ - made KSK check more resilient
+
+7 Jul 2006: 1.1.0: ldns-team
+ * Added tutorials and an introduction to the documentation
+ * Added include/ and lib/ dirs so that you can compile against ldns
+ without installing ldns on your system
+ * Makefile updates
+ * Starting usage of assert throughout the library to catch illegal calls
+ * Solaris 9 testing was carried out. Ldns now compiles on that
+ platform; some gnuism were identified and fixed.
+ * The ldns_zone structure was stress tested. The current setup
+ (ie. just a list of rrs) can scale to zone file in order of
+ megabytes. Sorting such zone is still difficult.
+ * Reading multiline b64 encoded rdata works.
+ * OpenSSL was made optional, configure --without-ssl.
+ Ofcourse all dnssec/tsig related functions are disabled
+ * Building of examples and drill now happens with the same
+ defines as the building of ldns itself.
+ * Preliminary sha-256 support was added. Currently is your
+ OpenSSL supports it, it is supported in the DS creation.
+ * ldns_resolver_search was implemented
+ * Fixed a lot of bugs
+
+ Drill:
+ * -r was killed in favor of -o which
+ allows for a header bits setting (and maybe more in the
+ future)
+ * DNSSEC is never automaticaly set, even when you query
+ for DNSKEY/RRSIG or DS.
+ * Implement a crude RTT check, it now distinguishes between
+ reachable and unreachable.
+ * A form of secure tracing was added
+ * Secure Chasing has been improved
+ * -x does a reverse lookup for the given IP address
+
+ Examples:
+ * ldns-dpa was added to the examples - this is the Dns Packet
+ Analyzer tool.
+ * ldnsd - as very, very simple nameserver impl.
+ * ldns-zsplit - split zones for parrallel signing
+ * ldns-zcat - cat split zones back together
+ * ldns-keyfetcher - Fetches DNSKEY records with a few (non-strong,
+ non-DNSSEC) anti-spoofing techniques.
+ * ldns-walk - 'Walks' a DNSSEC signed zone
+ * Added an all-static target to the makefile so you can use examples
+ without installing the library
+ * When building in the source tree or in a direct subdirectory of
+ the build dir, configure does not need --with-ldns=../ anymore
+
+ Code:
+ * All networking code was moved to net.c
+ * rdata.c: added asserts to the rdf set/get functions
+ * const keyword was added to pointer arguments that
+ aren't changed
+
+ API:
+ Changed:
+ * renamed ldns/dns.h to ldns/ldns.h
+ * ldns_rr_new_frm_str() is extented with an extra variable which
+ in common use may be NULL. This trickles through to:
+ o ldns_rr_new_frm_fp
+ o ldns_rr_new_frm_fp_l
+ Which also get an extra variable
+ Also the function has been changed to return a status message.
+ The compiled RR is returned in the first argument.
+ * ldns_zone_new_frm_fp_l() and ldns_zone_new_frm_fp() are
+ changed to return a status msg.
+ * ldns_key_new_frm_fp is changed to return ldns_status and
+ the actual key list in the first argument
+ * ldns_rdata_new_frm_fp[_l]() are changed to return a status.
+ the rdf is return in the first argument
+ * ldns_resolver_new_frm_fp: same treatment: return status and
+ the new resolver in the first argument
+ * ldns_pkt_query_new_frm_str(): same: return status and the
+ packet in the first arg
+ * tsig.h: internal used functions are now static:
+ ldns_digest_name and ldns_tsig_mac_new
+ * ldns_key_rr2ds has an extra argument to specify the hash to
+ use.
+ * ldns_pkt_rcode() is renamed to ldns_pkt_get_rcode, ldns_pkt_rcode
+ is now the rcode type, like ldns_pkt_opcode
+ New:
+ * ldns_resolver_searchlist_count: return the searchlist counter
+ * ldns_zone_sort: Sort a zone
+ * ldns_bgsend(): background send, returns a socket.
+ * ldns_pkt_empty(): check is a packet is empty
+ * ldns_rr_list_pop_rr_list(): pop multiple rr's from another rr_list
+ * ldns_rr_list_push_rr_list(): push multiple rr's to an rr_list
+ * ldns_rr_list_compare(): compare 2 ldns_rr_lists
+ * ldns_pkt_push_rr_list: rr_list equiv for rr
+ * ldns_pkt_safe_push_rr_list: rr_list equiv for rr
+ Removed:
+ * ldns_resolver_bgsend(): was not used in 1.0.0 and is not used now
+ * ldns_udp_server_connect(): was faulty and isn't really part of
+ the core ldns idea any how.
+ * ldns_rr_list_insert_rr(): obsoleted, because not used.
+ * char *_when was removed from the ldns_pkt structure
+
+18 Oct 2005: 1.0.0: ldns-team
+ * Commited a patch from HÃ¥kan Olsson
+ * Added UPDATE support (Jakob Schlyter and HÃ¥kan Olsson)
+ * License change: ldns is now BSD licensed
+ * ldns now depends on SSL
+ * Networking code cleanup, added (some) server udp/tcp support
+ * A zone type is introduced. Currently this is a list
+ of RRs, so it will not scale well.
+ * [beta] Zonefile parsing was added
+ * [tools] Drill was added to ldns - see drill/
+ * [tools] experimental signer was added
+ * [building] better check for ssl
+ * [building] major revision of build system
+ * [building] added rpm .spec in packaging/ (thanks to Paul Wouters)
+ * [building] A lot of cleanup in the build scripts (thanks to Jakob Schlyter
+ and Paul Wouters)
+
+28 Jul 2005: 0.70: ldns-team
+ * [func] ldns_pkt_get_section now returns copies from the rrlists
+ in the packet. This can be freed by the user program
+ * [code] added ldns_ prefixes to function from util.h
+ * [inst] removed documentation from default make install
+ * Usual fixes in documentation and code
+
+20 Jun 2005: 0.66: ldns-team
+ Rel. Focus: drill-pre2 uses some functions which are
+ not in 0.65
+ * dnssec_cd bit function was added
+ * Zone infrastructure was added
+ * Usual fixes in documentation and code
+
+13 Jun 2005: 0.65: ldns-team
+ * Repository is online at:
+ http://www.nlnetlabs.nl/ldns/svn/
+ * Apply reference copying throuhgout ldns, except in 2
+ places in the ldns_resolver structure (._domain and
+ ._nameservers)
+ * Usual array of bugfixes
+ * Documentation added
+ * keygen.c added as an example for DNSSEC programming
+
+23 May 2005: 0.60: ldns-team
+ * Removed config.h from the header installed files
+ (you're not supposed to include that in a libary)
+ * Further tweaking
+ - DNSSEC signing/verification works
+ - Assorted bug fixes and tweaks (memory management)
+
+May 2005: 0.50: ldns-team
+ * First usable release
+ * Basic DNS functionality works
+ * DNSSEC validation works
diff --git a/libs/ldns/LICENSE b/libs/ldns/LICENSE
new file mode 100644
index 0000000000..6d4c6be096
--- /dev/null
+++ b/libs/ldns/LICENSE
@@ -0,0 +1,26 @@
+Copyright (c) 2005,2006, NLnetLabs
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of NLnetLabs nor the names of its
+ contributors may be used to endorse or promote products derived from this
+ software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
diff --git a/libs/ldns/Makefile.in b/libs/ldns/Makefile.in
new file mode 100644
index 0000000000..6e0ce40641
--- /dev/null
+++ b/libs/ldns/Makefile.in
@@ -0,0 +1,368 @@
+# Standard installation pathnames
+# See the file LICENSE for the license
+SHELL = @SHELL@
+VERSION = @PACKAGE_VERSION@
+version_info = @LIBTOOL_VERSION_INFO@
+srcdir = @srcdir@
+basesrcdir = $(shell basename `pwd`)
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+bindir = @bindir@
+mandir = @mandir@
+datarootdir = @datarootdir@
+datadir = @datadir@
+libdir = @libdir@
+includedir = @includedir@
+doxygen = @doxygen@
+pywrapdir = ${srcdir}/contrib/python
+swig = @swig@
+python_site =@PYTHON_SITE_PKG@
+pyldns_inst =@PYLDNS@
+pyldns_uninst =@PYLDNS@
+ifeq "$(pyldns_inst)" "pyldns"
+ pyldns_inst=install-@PYLDNS@
+ pyldns_uninst=uninstall-@PYLDNS@
+else
+ pyldns_inst=
+ pyldns_uninst=
+endif
+glibtool = @libtool@
+libtool = ./libtool
+ifdef glibtool
+libtool = $(glibtool)
+endif
+
+CC = @CC@
+ifeq "$(srcdir)" "."
+ CPPFLAGS = $(strip -I. @CPPFLAGS@ @DEFS@)
+else
+ CPPFLAGS = $(strip -I. -I$(srcdir) @CPPFLAGS@ @DEFS@)
+endif
+CFLAGS = $(strip @CFLAGS@)
+LDFLAGS = @LDFLAGS@
+LIBS = @LIBS@
+LIBOBJS = @LIBOBJS@
+PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@
+PYTHON_LDFLAGS = @PYTHON_LDFLAGS@
+LIBSSL_CPPFLAGS = @LIBSSL_CPPFLAGS@
+LIBSSL_LDFLAGS = @LIBSSL_LDFLAGS@
+LIBSSL_LIBS = @LIBSSL_LIBS@
+RUNTIME_PATH = @RUNTIME_PATH@
+DATE = $(shell date +%Y%m%d)
+LIBTOOL = $(libtool) --tag=CC --quiet
+INSTALL_LDNS_CONFIG = @INSTALL_LDNS_CONFIG@
+
+LINT = splint
+LINTFLAGS=+quiet -weak -warnposix -unrecog -Din_addr_t=uint32_t -Du_int=unsigned -Du_char=uint8_t -preproc -Drlimit=rlimit64 -D__gnuc_va_list=va_list
+#-Dglob64=glob -Dglobfree64=globfree
+# compat with openssl linux edition.
+LINTFLAGS+="-DBN_ULONG=unsigned long" -Dkrb5_int32=int "-Dkrb5_ui_4=unsigned int" -DPQ_64BIT=uint64_t -DRC4_INT=unsigned -fixedformalarray -D"ENGINE=unsigned" -D"RSA=unsigned" -D"DSA=unsigned" -D"EVP_PKEY=unsigned" -D"EVP_MD=unsigned" -D"SSL=unsigned" -D"SSL_CTX=unsigned" -D"X509=unsigned" -D"RC4_KEY=unsigned" -D"EVP_MD_CTX=unsigned" -D"EC_KEY=unsigned" -D"EC_POINT=unsigned" -D"EC_GROUP=unsigned"
+# compat with NetBSD
+ifeq "$(shell uname)" "NetBSD"
+LINTFLAGS+="-D__RENAME(x)=" -D_NETINET_IN_H_
+endif
+# compat with OpenBSD
+LINTFLAGS+="-Dsigset_t=long"
+# FreeBSD8
+LINTFLAGS+="-D__uint16_t=uint16_t"
+
+INSTALL = $(srcdir)/install-sh
+
+LIBDNS_SOURCES = rdata.c util.c rr.c packet.c wire2host.c \
+ host2str.c buffer.c str2host.c tsig.c resolver.c \
+ net.c host2wire.c dname.c dnssec.c dnssec_verify.c \
+ keys.c higher.c rr_functions.c parse.c update.c \
+ error.c zone.c dnssec_zone.c dnssec_sign.c rbtree.c \
+ sha1.c sha2.c
+LIBDNS_HEADERS = $(srcdir)/ldns/error.h \
+ $(srcdir)/ldns/packet.h \
+ $(srcdir)/ldns/common.h \
+ $(srcdir)/ldns/rdata.h \
+ $(srcdir)/ldns/rr.h \
+ $(srcdir)/ldns/wire2host.h \
+ $(srcdir)/ldns/host2str.h \
+ $(srcdir)/ldns/host2wire.h \
+ $(srcdir)/ldns/str2host.h \
+ $(srcdir)/ldns/buffer.h \
+ $(srcdir)/ldns/resolver.h \
+ $(srcdir)/ldns/dname.h \
+ $(srcdir)/ldns/dnssec.h \
+ $(srcdir)/ldns/dnssec_verify.h \
+ $(srcdir)/ldns/dnssec_sign.h \
+ $(srcdir)/ldns/keys.h \
+ $(srcdir)/ldns/higher.h \
+ $(srcdir)/ldns/parse.h \
+ $(srcdir)/ldns/rr_functions.h \
+ $(srcdir)/ldns/ldns.h \
+ $(srcdir)/ldns/zone.h \
+ $(srcdir)/ldns/dnssec_zone.h \
+ $(srcdir)/ldns/update.h \
+ $(srcdir)/ldns/tsig.h \
+ $(srcdir)/ldns/rbtree.h \
+ $(srcdir)/ldns/sha1.h \
+ $(srcdir)/ldns/sha2.h
+LIBDNS_OBJECTS = $(LIBDNS_SOURCES:.c=.o) $(LIBOBJS)
+LIBDNS_LOBJECTS = $(LIBDNS_SOURCES:.c=.lo) $(LIBOBJS:.o=.lo)
+
+ALL_SOURCES = $(LIBDNS_SOURCES)
+
+COMPILE = $(CC) $(CPPFLAGS) $(CFLAGS)
+COMP_LIB = $(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(CFLAGS)
+LINK = $(CC) $(strip $(CFLAGS) $(LDFLAGS) $(LIBS))
+LINK_LIB = $(LIBTOOL) --mode=link $(CC) $(strip $(CFLAGS) $(LDFLAGS) $(LIBS) -version-number $(version_info) -no-undefined)
+
+%.o: $(srcdir)/%.c $(LIBDNS_HEADERS) ldns/net.h ldns/util.h ldns/config.h
+ $(COMP_LIB) $(LIBSSL_CPPFLAGS) -c $<
+
+.PHONY: clean realclean docclean manpages doc lint all lib pyldns test
+.PHONY: install uninstall install-doc uninstall-doc uninstall-pyldns
+.PHONY: install-h uninstall-h install-lib uninstall-lib install-pyldns
+
+all: copy-headers lib linktest manpages @PYLDNS@
+
+linktest: $(srcdir)/linktest.c $(LIBDNS_HEADERS) ldns/net.h ldns/util.h ldns/config.h libldns.la
+ $(LIBTOOL) --mode=link $(CC) $(srcdir)/linktest.c $(CPPFLAGS) $(LIBSSL_CPPFLAGS) $(CFLAGS) -lldns $(LIBS) -o linktest
+
+lib: libldns.la
+ if [ ! -d lib ] ; then ln -s .libs lib ; fi ;
+
+lib-export-all: libldns.la-export-all
+ if [ ! -d lib ] ; then ln -s .libs lib ; fi ;
+
+libldns.la: $(LIBDNS_OBJECTS)
+ $(LINK_LIB) $(LIBSSL_LDFLAGS) $(LIBSSL_LIBS) --export-symbols $(srcdir)/ldns_symbols.def -o libldns.la $(LIBDNS_LOBJECTS) -rpath $(libdir) $(RUNTIME_PATH)
+
+libldns.la-export-all: $(LIBDNS_OBJECTS)
+ $(LINK_LIB) -o libldns.la $(LIBDNS_LOBJECTS) -rpath $(libdir) $(RUNTIME_PATH)
+
+$(addprefix include/ldns/, $(notdir $(LIBDNS_HEADERS))): include/ldns/%.h: $(srcdir)/ldns/%.h
+ @if [ ! -d include ] ; then ($(INSTALL) -d include || echo "include exists") ; fi ;
+ @if [ ! -d include/ldns ] ; then (cd include; ln -s ../ldns ./ldns || echo "include/ldns exists") ; fi ;
+ $(INSTALL) -c -m 644 $< ./include/ldns/
+
+include/ldns/util.h include/ldns/net.h include/ldns/config.h: include/ldns/%.h: ./ldns/%.h
+ @if [ ! -d include ] ; then ($(INSTALL) -d include || echo "include exists") ; fi ;
+ @if [ ! -d include/ldns ] ; then (cd include; ln -s ../ldns ./ldns || echo "include/ldns exists") ; fi ;
+ $(INSTALL) -c -m 644 $< ./include/ldns/
+
+copy-headers: $(addprefix include/ldns/, $(notdir $(LIBDNS_HEADERS))) include/ldns/util.h include/ldns/net.h include/ldns/config.h
+
+mancheck:
+ sh -c 'find . -name \*.\[13\] -exec troff -z {} \;' 2>&1 | sed "s/^\.\///" | sed "s/\(:[0\-9]\+:\)/\1 warning:/g"
+
+doxygen: manpages
+ $(INSTALL) -d doc
+ifdef doxygen
+# if we are not in base we need to copy some html files too
+ if [ ! -e doc/header.html ] ; then \
+ $(INSTALL) -c -m 644 $(srcdir)/doc/header.html doc/ ; \
+ fi ;
+ $(doxygen) $(srcdir)/libdns.doxygen
+endif
+
+manpages: $(srcdir)/doc/function_manpages
+ $(INSTALL) -d doc
+ cat $(srcdir)/ldns/*.h | $(srcdir)/doc/doxyparse.pl -m $(srcdir)/doc/function_manpages 2>&1 | \
+ grep -v ^doxygen | grep -v ^cat > doc/ldns_manpages
+
+pyldns: _ldns.la
+
+$(pywrapdir)/ldns_wrapper.c: $(pywrapdir)/ldns.i $(wildcard $(pywrapdir)/*.i) $(LIBDNS_HEADERS) ldns/util.h ldns/config.h
+ $(swig) -python -o $@ $(CPPFLAGS) $(PYTHON_CPPFLAGS) $<
+
+ldns_wrapper.lo: $(pywrapdir)/ldns_wrapper.c $(LIBDNS_HEADERS) ldns/util.h ldns/config.h
+ $(COMP_LIB) -I./include/ldns $(PYTHON_CPPFLAGS) -c $< -o $@
+
+_ldns.la: ldns_wrapper.lo libldns.la
+ $(LIBTOOL) --tag=CC --mode=link $(CC) $(strip $(CFLAGS) $(PYTHON_CFLAGS) $(LDFLAGS) $(PYTHON_LDFLAGS) -module -version-number $(version_info) -no-undefined -o $@ $< -rpath $(python_site) -L. -L.libs -lldns $(LIBS))
+
+install: install-h install-lib install-config install-manpages $(pyldns_inst)
+
+uninstall: uninstall-manpages uninstall-h uninstall-lib $(pyldns_uninst)
+
+destclean: uninstall
+
+install-config:
+ if [ $(INSTALL_LDNS_CONFIG) = "yes" ] ; then \
+ $(INSTALL) -d $(DESTDIR)$(bindir); \
+ $(INSTALL) -c -m 755 packaging/ldns-config $(DESTDIR)$(bindir)/; \
+ fi
+
+install-manpages: manpages
+ ${INSTALL} -d $(DESTDIR)$(mandir)/man3
+ for f in doc/man/man3/*; do \
+ ${INSTALL} -c -m 444 $$f $(DESTDIR)$(mandir)/man3/; \
+ done
+
+uninstall-manpages:
+ for i in `cat doc/ldns_manpages`; do \
+ rm -f $(DESTDIR)$(mandir)/man3/$$i.3 ; done
+ rmdir -p $(DESTDIR)$(mandir)/man3 || echo "ok, dir already gone"
+
+install-h: lib
+ $(INSTALL) -m 755 -d $(DESTDIR)$(includedir)/ldns
+ for i in $(LIBDNS_HEADERS); do \
+ $(INSTALL) -c -m 644 $$i $(DESTDIR)$(includedir)/ldns/; done
+ $(INSTALL) -c -m 644 include/ldns/util.h $(DESTDIR)$(includedir)/ldns/
+ $(INSTALL) -c -m 644 include/ldns/net.h $(DESTDIR)$(includedir)/ldns/
+
+uninstall-h:
+ for i in $(LIBDNS_HEADERS); do \
+ rm -f $(DESTDIR)$(includedir)/$$i; done
+ [ ! -d $(DESTDIR)$(includedir)/ldns ] || rmdir -p $(DESTDI)$(includedir)/ldns || echo "ok, dir already gone"
+ exit 0
+
+install-lib: lib
+ $(INSTALL) -m 755 -d $(DESTDIR)$(libdir)
+ $(LIBTOOL) --mode=install cp libldns.la $(DESTDIR)$(libdir)
+ $(LIBTOOL) --mode=finish $(DESTDIR)$(libdir)
+
+uninstall-lib:
+ $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/libldns.la
+ rmdir -p $(DESTDIR)$(libdir) || echo "ok, dir already gone"
+
+install-pyldns: @PYLDNS@
+ $(INSTALL) -m 755 -d $(DESTDIR)$(python_site)/ldns
+ $(INSTALL) -c -m 644 $(pywrapdir)/ldns.py $(DESTDIR)$(python_site)/ldns.py
+ $(LIBTOOL) --mode=install cp _ldns.la $(DESTDIR)$(python_site)
+ $(LIBTOOL) --mode=finish $(DESTDIR)$(python_site)
+
+uninstall-pyldns:
+ rm -f $(DESTDIR)$(python_site)/ldns/*
+ rmdir -p $(DESTDIR)$(python_site)/ldns
+
+clean:
+ rm -f *.o *.d *.lo
+ rm -f *~
+ rm -rf autom4te.cache/
+ rm -f tags
+ rm -f *.key
+ rm -f *.ds
+ rm -f *.private
+ rm -rf include/
+ rm -rf lib
+ rm -rf .libs
+ rm -f linktest
+ rm -f $(pywrapdir)/ldns_wrapper.c $(pywrapdir)/ldns.py
+
+distclean: clean docclean libclean
+ rm -f ltmain.sh
+
+realclean: clean docclean libclean
+ rm -f config.status
+ rm -f config.log
+ rm -f Makefile
+ rm -f ldns/config.h.in
+ rm -f ldns/config.h
+ rm -f ldns/util.h
+ rm -f config.h.in
+ rm -f configure
+ rm -f config.sub
+ rm -f config.guess
+ rm -f ltmain.sh
+
+docclean:
+ rm -rf doc/html/
+ rm -rf doc/man/
+ rm -rf doc/latex/
+ rm -f doc/*.txt
+ rm -f doc/*.tex
+ rm -f doc/ldns_manpages
+
+libclean:
+ $(LIBTOOL) --mode clean rm -f libldns.la
+ $(LIBTOOL) --mode clean rm -f libldns.a
+ $(LIBTOOL) --mode clean rm -f libldns.so
+ $(LIBTOOL) --mode clean rm -f libldns.so.*
+ $(LIBTOOL) --mode clean rm -f _ldns.la
+ rm -rf ldns/net.h ldns/util.h ldns/config.h
+ rm -rf *.lo
+ rm -rf .libs
+ rm -rf libtool
+
+## No need for changes here
+
+lint:
+ for i in $(LIBDNS_SOURCES); do \
+ $(LINT) $(LINTFLAGS) -I. -I$(srcdir) $(srcdir)/$$i ; \
+ if [ $$? -ne 0 ] ; then exit 1 ; fi ; \
+ done
+
+tags: $(srcdir)/*.c ldns/*.[ch]
+ ctags -f $(srcdir)/tags $(srcdir)/*.[ch] ldns/*.[ch]
+
+b64_pton$U.o: $(srcdir)/compat/b64_pton.c
+ $(COMP_LIB) -c $(srcdir)/compat/b64_pton.c -o $@
+
+b64_ntop$U.o: $(srcdir)/compat/b64_ntop.c
+ $(COMP_LIB) -c $(srcdir)/compat/b64_ntop.c -o $@
+
+b32_pton$U.o: $(srcdir)/compat/b32_pton.c
+ $(COMP_LIB) -c $(srcdir)/compat/b32_pton.c -o $@
+
+b32_ntop$U.o: $(srcdir)/compat/b32_ntop.c
+ $(COMP_LIB) -c $(srcdir)/compat/b32_ntop.c -o $@
+
+malloc$U.o: $(srcdir)/compat/malloc.c
+ $(COMP_LIB) -c $(srcdir)/compat/malloc.c -o $@
+
+realloc$U.o: $(srcdir)/compat/realloc.c
+ $(COMP_LIB) -c $(srcdir)/compat/realloc.c -o $@
+
+timegm$U.o: $(srcdir)/compat/timegm.c
+ $(COMP_LIB) -c $(srcdir)/compat/timegm.c -o $@
+
+isblank$U.o: $(srcdir)/compat/isblank.c
+ $(COMP_LIB) -c $(srcdir)/compat/isblank.c -o $@
+
+isasciik$U.o: $(srcdir)/compat/isascii.c
+ $(COMP_LIB) -c $(srcdir)/compat/isascii.c -o $@
+
+strlcpy$U.o: $(srcdir)/compat/strlcpy.c
+ $(COMP_LIB) -c $(srcdir)/compat/strlcpy.c -o $@
+
+memmove$U.o: $(srcdir)/compat/memmove.c
+ $(COMP_LIB) -c $(srcdir)/compat/memmove.c -o $@
+
+inet_pton$U.o: $(srcdir)/compat/inet_pton.c
+ $(COMP_LIB) -c $(srcdir)/compat/inet_pton.c -o $@
+
+inet_aton$U.o: $(srcdir)/compat/inet_aton.c
+ $(COMP_LIB) -c $(srcdir)/compat/inet_aton.c -o $@
+
+inet_ntop$U.o: $(srcdir)/compat/inet_ntop.c
+ $(COMP_LIB) -c $(srcdir)/compat/inet_ntop.c -o $@
+
+snprintf$U.o: $(srcdir)/compat/snprintf.c
+ $(COMP_LIB) -c $(srcdir)/compat/snprintf.c -o $@
+
+fake-rfc2553$U.o: $(srcdir)/compat/fake-rfc2553.c
+ $(COMP_LIB) -c $(srcdir)/compat/fake-rfc2553.c -o $@
+
+gmtime_r$U.o: $(srcdir)/compat/gmtime_r.c
+ $(COMP_LIB) -c $(srcdir)/compat/gmtime_r.c -o $@
+
+ctime_r$U.o: $(srcdir)/compat/ctime_r.c
+ $(COMP_LIB) -c $(srcdir)/compat/ctime_r.c -o $@
+
+# Automatic dependencies.
+%.d: $(srcdir)/%.c
+ $(SHELL) -ec '$(CC) -MM $(CPPFLAGS) $< \
+ | sed '\''s!\(.*\)\.o[ :]*!$(dir $@)\1.o $@ : !g'\'' > $@; \
+ [ -s $@ ] || rm -f $@'
+
+allclean: test-clean clean
+
+test-clean:
+ tpkg -b test clean
+
+test:
+ if test -x "`which bash`"; then bash test/test_all.sh; else sh test/test_all.sh; fi
+
+#-include $(ALL_SOURCES:.c=.d)
+
+# Recreate symbols file, only needed when API changes
+# make clean first (and after this make clean; make again)
+symbols: lib-export-all
+ nm -g lib/libldns.so | cut -d " " -f 3 | grep ldns | sort > $(srcdir)/ldns_symbols.def
+
diff --git a/libs/ldns/README b/libs/ldns/README
new file mode 100644
index 0000000000..74e470a03d
--- /dev/null
+++ b/libs/ldns/README
@@ -0,0 +1,129 @@
+
+Contents:
+ REQUIREMENTS
+ INSTALLATION
+ libdns
+ examples
+ drill
+ INFORMATION FOR SPECIFIC OPERATING SYSTEMS
+ Mac OS X
+ Solaris
+ Your Support
+
+Project page:
+http://www.nlnetlabs.nl/ldns/
+On that page you can also subscribe to the ldns mailing list.
+
+* Development
+ldns is mainly developed on Linux and FreeBSD. It is regularly tested to
+compile on other systems like Solaris and Mac OS X.
+
+REQUIREMENTS
+- OpenSSL (Optional, but needed for features like DNSSEC)
+- libpcap (Optional, but needed for examples/ldns-dpa)
+- (GNU) libtool (in OSX, that's glibtool, not libtool)
+- GNU make
+
+INSTALLATION
+1. Unpack the tarball
+2. cd ldns-
+3. ./configure
+4. gmake (it needs gnu make to compile, on systems where GNU make is the
+ default you can just use 'make')
+5. sudo gmake install
+6. Optional. (cd examples; ./configure; gmake), make example programs included.
+7. Optional. (cd drill; ./configure; gmake; gmake install), to build drill.
+
+You can configure and compile it in a separate build directory.
+
+* Examples
+There are some examples and dns related tools in the examples/ directory.
+These can be built with:
+1. cd examples/
+2. ./configure [--with-ldns=]
+3. gmake
+
+* Drill
+Drill can be built with:
+1. cd drill/
+2. ./configure [--with-ldns=]
+3. gmake
+
+Note that you need to set LD_LIBRARY_PATH if you want to run the binaries
+and you have not installed the library to a system directory. You can use
+the make target all-static for the examples to run them if you don't want to
+install the library.
+
+
+* Building from subversion repository
+
+If you are building from the repository you will need to have (gnu)
+autotools like libtool and autoreconf installed. A list of all the commands
+needed to build everything can be found in README.svn. Note that the actual
+commands may be a little bit different on your machine. Most notable, you'll need to run libtoolize (or glibtoolize), if you skip this step, you'll get an error about missing config.sub.
+
+* Developers
+ldns is developed by the ldns team at NLnet Labs. This team currently
+consists of:
+ o Wouter Wijngaards
+ o Matthijs Mekking
+
+Former main developers:
+ o Jelte Jansen
+ o Miek Gieben
+
+* Credits
+We have received patches from the following people, thanks!
+ o Erik Rozendaal
+ o HÃ¥kan Olsson
+ o Jakob Schlyter
+ o Paul Wouters
+ o Simon Vallet
+ o Ondřej Surý
+
+
+IFORMATION FOR SPECIFIC OPERATING SYSTEMS
+
+MAC OS X
+
+For MACOSX 10.4 and later, it seems that you have to set the
+MACOSX_DEPLOYMENT_TARGET environment variable to 10.4 before running
+make. Apparently it defaults to 10.1.
+
+This appears to be a known problem in 10.2 to 10.4, see:
+http://developer.apple.com/qa/qa2001/qa1233.html
+for more information.
+
+
+SOLARIS
+
+In Solaris multi-architecture systems (that have both 32-bit and
+64-bit support), it can be a bit taxing to convince the system to
+compile in 64-bit mode. Jakob Schlyter has kindly contributed a build
+script that sets the right build and link options. You can find it in
+contrib/build-solaris.sh
+
+
+Your Support
+NLnet Labs offers all of its software products as open source, most are
+published under a BDS license. You can download them, not only from the
+NLnet Labs website but also through the various OS distributions for
+which NSD, ldns, and Unbound are packaged. We therefore have little idea
+who uses our software in production environments and have no direct ties
+with 'our customers'.
+
+Therefore, we ask you to contact us at users@NLnetLabs.nl and tell us
+whether you use one of our products in your production environment,
+what that environment looks like, and maybe even share some praise.
+We would like to refer to the fact that your organization is using our
+products. We will only do that if you explicitly allow us. In all other
+cases we will keep the information you share with us to ourselves.
+
+In addition to the moral support you can also support us
+financially. NLnet Labs is a recognized not-for-profit charity foundation
+that is chartered to develop open-source software and open-standards
+for the Internet. If you use our software to satisfaction please express
+that by giving us a donation. For small donations PayPal can be used. For
+larger and regular donations please contact us at users@NLnetLabs.nl. Also
+see http://www.nlnetlabs.nl/labs/contributors/.
+
diff --git a/libs/ldns/README.snapshots b/libs/ldns/README.snapshots
new file mode 100644
index 0000000000..891fcca1d6
--- /dev/null
+++ b/libs/ldns/README.snapshots
@@ -0,0 +1,8 @@
+ldns - snapshot releases
+
+Snapshot releases are not official released. They can be released to
+interested parties for development.
+
+Snapshots can be recognized from the date in the the tar file name.
+
+They should not be used for packaging in distributions.
diff --git a/libs/ldns/README.svn b/libs/ldns/README.svn
new file mode 100644
index 0000000000..10f7cb4163
--- /dev/null
+++ b/libs/ldns/README.svn
@@ -0,0 +1,26 @@
+
+# The ldns subversion repository can found at:
+# www.nlnetlabs.nl/ldns/svn/
+
+# small list of commands to build all on a linux system
+# libtoolize is needed for most other targets
+
+# on Solaris, and other systems that may not have
+# the default 'automake' and 'aclocal' script aliases,
+# the correct versions may need to be set. On those
+# systems, the 'autoreconf' line should be changed to:
+# AUTOMAKE=automake-1.10 ACLOCAL=aclocal-1.10 autoreconf
+# (and these systems probably need gmake instead of make)
+
+# older versions of libtoolize do not support --install
+# so you might need to remove that (with newer versions
+# it is needed)
+libtoolize -c --install
+autoreconf --install
+./configure
+make
+make doc # needs doxygen for the html pages
+(cd examples && autoreconf && ./configure && make)
+(cd drill && autoreconf && ./configure && make)
+(cd pcat && autoreconf && ./configure && make)
+(cd examples/nsd-test && autoreconf && ./configure && make)
diff --git a/libs/ldns/ac_pkg_swig.m4 b/libs/ldns/ac_pkg_swig.m4
new file mode 100644
index 0000000000..738f69d45e
--- /dev/null
+++ b/libs/ldns/ac_pkg_swig.m4
@@ -0,0 +1,122 @@
+# ===========================================================================
+# http://autoconf-archive.cryp.to/ac_pkg_swig.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AC_PROG_SWIG([major.minor.micro])
+#
+# DESCRIPTION
+#
+# This macro searches for a SWIG installation on your system. If found you
+# should call SWIG via $(SWIG). You can use the optional first argument to
+# check if the version of the available SWIG is greater than or equal to
+# the value of the argument. It should have the format: N[.N[.N]] (N is a
+# number between 0 and 999. Only the first N is mandatory.)
+#
+# If the version argument is given (e.g. 1.3.17), AC_PROG_SWIG checks that
+# the swig package is this version number or higher.
+#
+# In configure.in, use as:
+#
+# AC_PROG_SWIG(1.3.17)
+# SWIG_ENABLE_CXX
+# SWIG_MULTI_MODULE_SUPPORT
+# SWIG_PYTHON
+#
+# LAST MODIFICATION
+#
+# 2008-04-12
+#
+# COPYLEFT
+#
+# Copyright (c) 2008 Sebastian Huber
+# Copyright (c) 2008 Alan W. Irwin
+# Copyright (c) 2008 Rafael Laboissiere
+# Copyright (c) 2008 Andrew Collier
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see .
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Macro Archive. When you make and
+# distribute a modified version of the Autoconf Macro, you may extend this
+# special exception to the GPL to apply to your modified version as well.
+
+AC_DEFUN([AC_PROG_SWIG],[
+ AC_PATH_PROG([SWIG],[swig])
+ if test -z "$SWIG" ; then
+ AC_MSG_WARN([cannot find 'swig' program. You should look at http://www.swig.org])
+ SWIG='echo "Error: SWIG is not installed. You should look at http://www.swig.org" ; false'
+ elif test -n "$1" ; then
+ AC_MSG_CHECKING([for SWIG version])
+ [swig_version=`$SWIG -version 2>&1 | grep 'SWIG Version' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'`]
+ AC_MSG_RESULT([$swig_version])
+ if test -n "$swig_version" ; then
+ # Calculate the required version number components
+ [required=$1]
+ [required_major=`echo $required | sed 's/[^0-9].*//'`]
+ if test -z "$required_major" ; then
+ [required_major=0]
+ fi
+ [required=`echo $required | sed 's/[0-9]*[^0-9]//'`]
+ [required_minor=`echo $required | sed 's/[^0-9].*//'`]
+ if test -z "$required_minor" ; then
+ [required_minor=0]
+ fi
+ [required=`echo $required | sed 's/[0-9]*[^0-9]//'`]
+ [required_patch=`echo $required | sed 's/[^0-9].*//'`]
+ if test -z "$required_patch" ; then
+ [required_patch=0]
+ fi
+ # Calculate the available version number components
+ [available=$swig_version]
+ [available_major=`echo $available | sed 's/[^0-9].*//'`]
+ if test -z "$available_major" ; then
+ [available_major=0]
+ fi
+ [available=`echo $available | sed 's/[0-9]*[^0-9]//'`]
+ [available_minor=`echo $available | sed 's/[^0-9].*//'`]
+ if test -z "$available_minor" ; then
+ [available_minor=0]
+ fi
+ [available=`echo $available | sed 's/[0-9]*[^0-9]//'`]
+ [available_patch=`echo $available | sed 's/[^0-9].*//'`]
+ if test -z "$available_patch" ; then
+ [available_patch=0]
+ fi
+ if test $available_major -ne $required_major \
+ -o $available_minor -ne $required_minor \
+ -o $available_patch -lt $required_patch ; then
+ AC_MSG_WARN([SWIG version >= $1 is required. You have $swig_version. You should look at http://www.swig.org])
+ SWIG='echo "Error: SWIG version >= $1 is required. You have '"$swig_version"'. You should look at http://www.swig.org" ; false'
+ else
+ AC_MSG_NOTICE([SWIG executable is '$SWIG'])
+ SWIG_LIB=`$SWIG -swiglib`
+ AC_MSG_NOTICE([SWIG library directory is '$SWIG_LIB'])
+ fi
+ else
+ AC_MSG_WARN([cannot determine SWIG version])
+ SWIG='echo "Error: Cannot determine SWIG version. You should look at http://www.swig.org" ; false'
+ fi
+ fi
+ AC_SUBST([SWIG_LIB])
+])
diff --git a/libs/ldns/acx_nlnetlabs.m4 b/libs/ldns/acx_nlnetlabs.m4
new file mode 100644
index 0000000000..147af7f9ad
--- /dev/null
+++ b/libs/ldns/acx_nlnetlabs.m4
@@ -0,0 +1,1310 @@
+# acx_nlnetlabs.m4 - common macros for configure checks
+# Copyright 2009, Wouter Wijngaards, NLnet Labs.
+# BSD licensed.
+#
+# Version 11
+# 2010-08-16 Fix FLAG_OMITTED for AS_TR_CPP changes in autoconf-2.66.
+# 2010-07-02 Add check for ss_family (for minix).
+# 2010-04-26 Fix to use CPPFLAGS for CHECK_COMPILER_FLAGS.
+# 2010-03-01 Fix RPATH using CONFIG_COMMANDS to run at the very end.
+# 2010-02-18 WITH_SSL outputs the LIBSSL_LDFLAGS, LIBS, CPPFLAGS seperate, -ldl
+# 2010-02-01 added ACX_CHECK_MEMCMP_SIGNED, AHX_MEMCMP_BROKEN
+# 2010-01-20 added AHX_COONFIG_STRLCAT
+# 2009-07-14 U_CHAR detection improved for windows crosscompile.
+# added ACX_FUNC_MALLOC
+# fixup some #if to #ifdef
+# NONBLOCKING test for mingw crosscompile.
+# 2009-07-13 added ACX_WITH_SSL_OPTIONAL
+# 2009-07-03 fixup LDFLAGS for empty ssl dir.
+#
+# Automates some of the checking constructs. Aims at portability for POSIX.
+# Documentation for functions is below.
+#
+# the following macro's are provided in this file:
+# (see below for details on each macro).
+#
+# ACX_ESCAPE_BACKSLASH - escape backslashes in var for C-preproc.
+# ACX_RSRC_VERSION - create windows resource version number.
+# ACX_CHECK_COMPILER_FLAG - see if cc supports a flag.
+# ACX_CHECK_ERROR_FLAGS - see which flag is -werror (used below).
+# ACX_CHECK_COMPILER_FLAG_NEEDED - see if flags make the code compile cleanly.
+# ACX_DEPFLAG - find cc dependency flags.
+# ACX_DETERMINE_EXT_FLAGS_UNBOUND - find out which flags enable BSD and POSIX.
+# ACX_CHECK_FORMAT_ATTRIBUTE - find cc printf format syntax.
+# ACX_CHECK_UNUSED_ATTRIBUTE - find cc variable unused syntax.
+# ACX_LIBTOOL_C_ONLY - create libtool for C only, improved.
+# ACX_TYPE_U_CHAR - u_char type.
+# ACX_TYPE_RLIM_T - rlim_t type.
+# ACX_TYPE_SOCKLEN_T - socklen_t type.
+# ACX_TYPE_IN_ADDR_T - in_addr_t type.
+# ACX_TYPE_IN_PORT_T - in_port_t type.
+# ACX_ARG_RPATH - add --disable-rpath option.
+# ACX_WITH_SSL - add --with-ssl option, link -lcrypto.
+# ACX_WITH_SSL_OPTIONAL - add --with-ssl option, link -lcrypto,
+# where --without-ssl is also accepted
+# ACX_LIB_SSL - setup to link -lssl.
+# ACX_SYS_LARGEFILE - improved sys_largefile, fseeko, >2G files.
+# ACX_CHECK_GETADDRINFO_WITH_INCLUDES - find getaddrinfo, portably.
+# ACX_FUNC_DEPRECATED - see if func is deprecated.
+# ACX_CHECK_NONBLOCKING_BROKEN - see if nonblocking sockets really work.
+# ACX_MKDIR_ONE_ARG - determine mkdir(2) number of arguments.
+# ACX_FUNC_IOCTLSOCKET - find ioctlsocket, portably.
+# ACX_FUNC_MALLOC - check malloc, define replacement .
+# AHX_CONFIG_FORMAT_ATTRIBUTE - config.h text for format.
+# AHX_CONFIG_UNUSED_ATTRIBUTE - config.h text for unused.
+# AHX_CONFIG_FSEEKO - define fseeko, ftello fallback.
+# AHX_CONFIG_RAND_MAX - define RAND_MAX if needed.
+# AHX_CONFIG_MAXHOSTNAMELEN - define MAXHOSTNAMELEN if needed.
+# AHX_CONFIG_IPV6_MIN_MTU - define IPV6_MIN_MTU if needed.
+# AHX_CONFIG_SNPRINTF - snprintf compat prototype
+# AHX_CONFIG_INET_PTON - inet_pton compat prototype
+# AHX_CONFIG_INET_NTOP - inet_ntop compat prototype
+# AHX_CONFIG_INET_ATON - inet_aton compat prototype
+# AHX_CONFIG_MEMMOVE - memmove compat prototype
+# AHX_CONFIG_STRLCAT - strlcat compat prototype
+# AHX_CONFIG_STRLCPY - strlcpy compat prototype
+# AHX_CONFIG_GMTIME_R - gmtime_r compat prototype
+# AHX_CONFIG_W32_SLEEP - w32 compat for sleep
+# AHX_CONFIG_W32_USLEEP - w32 compat for usleep
+# AHX_CONFIG_W32_RANDOM - w32 compat for random
+# AHX_CONFIG_W32_SRANDOM - w32 compat for srandom
+# AHX_CONFIG_W32_FD_SET_T - w32 detection of FD_SET_T.
+# ACX_CFLAGS_STRIP - strip one flag from CFLAGS
+# ACX_STRIP_EXT_FLAGS - strip extension flags from CFLAGS
+# AHX_CONFIG_FLAG_OMITTED - define omitted flag
+# AHX_CONFIG_FLAG_EXT - define omitted extension flag
+# AHX_CONFIG_EXT_FLAGS - define the stripped extension flags
+# ACX_CHECK_MEMCMP_SIGNED - check if memcmp uses signed characters.
+# AHX_MEMCMP_BROKEN - replace memcmp func for CHECK_MEMCMP_SIGNED.
+# ACX_CHECK_SS_FAMILY - check for sockaddr_storage.ss_family
+#
+
+dnl Escape backslashes as \\, for C:\ paths, for the C preprocessor defines.
+dnl for example, ACX_ESCAPE_BACKSLASH($from_var, to_var)
+dnl $1: the text to change.
+dnl $2: the result.
+AC_DEFUN([ACX_ESCAPE_BACKSLASH], [$2="`echo $1 | sed -e 's/\\\\/\\\\\\\\/g'`"
+])
+
+dnl Calculate comma separated windows-resource numbers from package version.
+dnl Picks the first three(,0) or four numbers out of the name.
+dnl $1: variable for the result
+AC_DEFUN([ACX_RSRC_VERSION],
+[$1=[`echo $PACKAGE_VERSION | sed -e 's/^[^0-9]*\([0-9]\)[^0-9]*\([0-9]\)[^0-9]*\([0-9]\)[^0-9]*\([0-9]\).*$/\1,\2,\3,\4/' -e 's/^[^0-9]*\([0-9]\)[^0-9]*\([0-9]\)[^0-9]*\([0-9]\)[^0-9]*$/\1,\2,\3,0/' `]
+])
+
+dnl Routine to help check for compiler flags.
+dnl Checks if the compiler will accept the flag.
+dnl $1: the flag without a - in front, so g to check -g.
+dnl $2: executed if yes
+dnl $3: executed if no
+AC_DEFUN([ACX_CHECK_COMPILER_FLAG],
+[
+AC_REQUIRE([AC_PROG_CC])
+AC_MSG_CHECKING(whether $CC supports -$1)
+cache=`echo $1 | sed 'y%.=/+-%___p_%'`
+AC_CACHE_VAL(cv_prog_cc_flag_$cache,
+[
+echo 'void f(){}' >conftest.c
+if test -z "`$CC $CPPFLAGS $CFLAGS -$1 -c conftest.c 2>&1`"; then
+eval "cv_prog_cc_flag_$cache=yes"
+else
+eval "cv_prog_cc_flag_$cache=no"
+fi
+rm -f conftest conftest.o conftest.c
+])
+if eval "test \"`echo '$cv_prog_cc_flag_'$cache`\" = yes"; then
+AC_MSG_RESULT(yes)
+:
+$2
+else
+AC_MSG_RESULT(no)
+:
+$3
+fi
+])
+
+dnl setup flags for ACX_CHECK_COMPILER_FLAG_NEEDED
+dnl ERRFLAG: result, compiler flag to turn warnings into errors
+AC_DEFUN([ACX_CHECK_ERROR_FLAGS],
+[
+ACX_CHECK_COMPILER_FLAG(Werror, [ERRFLAG="-Werror"], [ERRFLAG="-errwarn"])
+ACX_CHECK_COMPILER_FLAG(Wall, [ERRFLAG="$ERRFLAG -Wall"],
+ [ERRFLAG="$ERRFLAG -errfmt"])
+])
+
+dnl Routine to help check for needed compiler flags.
+dnl $1: flags for CC
+dnl $2: the includes and code
+dnl $3: if the given code only compiles with the flag, execute argument 3
+dnl $4: if the given code compiles without the flag, execute argument 4
+dnl $5: with and without flag the compile fails, execute argument 5.
+AC_DEFUN([ACX_CHECK_COMPILER_FLAG_NEEDED],
+[
+AC_REQUIRE([AC_PROG_CC])
+AC_REQUIRE([ACX_CHECK_ERROR_FLAGS])
+AC_MSG_CHECKING(whether we need $1 as a flag for $CC)
+cache=AS_TR_SH($1)
+dnl cache=`echo $1 | sed 'y%.=/+- %___p__%'`
+AC_CACHE_VAL(cv_prog_cc_flag_needed_$cache,
+[
+echo '$2' > conftest.c
+echo 'void f(){}' >>conftest.c
+if test -z "`$CC $CPPFLAGS $CFLAGS $ERRFLAG -c conftest.c 2>&1`"; then
+eval "cv_prog_cc_flag_needed_$cache=no"
+else
+[
+if test -z "`$CC $CPPFLAGS $CFLAGS $1 $ERRFLAG -c conftest.c 2>&1`"; then
+eval "cv_prog_cc_flag_needed_$cache=yes"
+else
+eval "cv_prog_cc_flag_needed_$cache=fail"
+#echo 'Test with flag fails too!'
+#cat conftest.c
+#echo "$CC $CPPFLAGS $CFLAGS $1 $ERRFLAG -c conftest.c 2>&1"
+#echo `$CC $CPPFLAGS $CFLAGS $1 $ERRFLAG -c conftest.c 2>&1`
+#exit 1
+fi
+]
+fi
+rm -f conftest conftest.c conftest.o
+])
+if eval "test \"`echo '$cv_prog_cc_flag_needed_'$cache`\" = yes"; then
+AC_MSG_RESULT(yes)
+:
+$3
+else
+if eval "test \"`echo '$cv_prog_cc_flag_needed_'$cache`\" = no"; then
+AC_MSG_RESULT(no)
+#echo 'Test with flag is no!'
+#cat conftest.c
+#echo "$CC $CPPFLAGS $CFLAGS $1 $ERRFLAG -c conftest.c 2>&1"
+#echo `$CC $CPPFLAGS $CFLAGS $1 $ERRFLAG -c conftest.c 2>&1`
+#exit 1
+:
+$4
+else
+AC_MSG_RESULT(failed)
+:
+$5
+fi
+fi
+])
+
+dnl Check for CC dependency flag
+dnl DEPFLAG: set to flag that generates dependencies.
+AC_DEFUN([ACX_DEPFLAG],
+[
+AC_MSG_CHECKING([$CC dependency flag])
+echo 'void f(){}' >conftest.c
+if test "`$CC -MM conftest.c 2>&1`" = "conftest.o: conftest.c"; then
+ DEPFLAG="-MM"
+else
+ if test "`$CC -xM1 conftest.c 2>&1`" = "conftest.o: conftest.c"; then
+ DEPFLAG="-xM1"
+ else
+ DEPFLAG="-MM" # dunno do something
+ fi
+fi
+AC_MSG_RESULT($DEPFLAG)
+rm -f conftest.c
+AC_SUBST(DEPFLAG)
+])
+
+dnl Determine flags that gives POSIX and BSD functionality.
+dnl CFLAGS is modified for the result.
+AC_DEFUN([ACX_DETERMINE_EXT_FLAGS_UNBOUND],
+[
+ACX_CHECK_COMPILER_FLAG(std=c99, [C99FLAG="-std=c99"])
+ACX_CHECK_COMPILER_FLAG(xc99, [C99FLAG="-xc99"])
+
+AC_CHECK_HEADERS([getopt.h time.h],,, [AC_INCLUDES_DEFAULT])
+
+ACX_CHECK_COMPILER_FLAG_NEEDED($C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=1 -D_ALL_SOURCE,
+[
+#include "confdefs.h"
+#include
+#include
+#include
+#ifdef HAVE_TIME_H
+#include
+#endif
+#include
+#include
+#ifdef HAVE_GETOPT_H
+#include
+#endif
+
+int test() {
+ int a;
+ char **opts = NULL;
+ struct timeval tv;
+ char *t;
+ time_t time = 0;
+ char *buf = NULL;
+ const char* str = NULL;
+ struct msghdr msg;
+ msg.msg_control = 0;
+ t = ctime_r(&time, buf);
+ tv.tv_usec = 10;
+ srandom(32);
+ a = getopt(2, opts, "a");
+ a = isascii(32);
+ str = gai_strerror(0);
+ return a;
+}
+], [CFLAGS="$CFLAGS $C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=1 -D_ALL_SOURCE"])
+
+ACX_CHECK_COMPILER_FLAG_NEEDED($C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_ALL_SOURCE,
+[
+#include "confdefs.h"
+#include
+#include
+#include
+#ifdef HAVE_TIME_H
+#include
+#endif
+#include
+#include
+#ifdef HAVE_GETOPT_H
+#include
+#endif
+
+int test() {
+ int a;
+ char **opts = NULL;
+ struct timeval tv;
+ char *t;
+ time_t time = 0;
+ char *buf = NULL;
+ const char* str = NULL;
+ struct msghdr msg;
+ msg.msg_control = 0;
+ t = ctime_r(&time, buf);
+ tv.tv_usec = 10;
+ srandom(32);
+ a = getopt(2, opts, "a");
+ a = isascii(32);
+ str = gai_strerror(0);
+ return a;
+}
+], [CFLAGS="$CFLAGS $C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_ALL_SOURCE"])
+
+ACX_CHECK_COMPILER_FLAG_NEEDED($C99FLAG,
+[
+#include
+#include
+int test() {
+ int a = 0;
+ return a;
+}
+], [CFLAGS="$CFLAGS $C99FLAG"])
+
+ACX_CHECK_COMPILER_FLAG_NEEDED(-D_BSD_SOURCE,
+[
+#include
+
+int test() {
+ int a;
+ a = isascii(32);
+ return a;
+}
+], [CFLAGS="$CFLAGS -D_BSD_SOURCE"])
+
+ACX_CHECK_COMPILER_FLAG_NEEDED(-D_GNU_SOURCE,
+[
+#include
+
+int test() {
+ struct in6_pktinfo inf;
+ int a = (int)sizeof(inf);
+ return a;
+}
+], [CFLAGS="$CFLAGS -D_GNU_SOURCE"])
+
+# check again for GNU_SOURCE for setresgid. May fail if setresgid
+# is not available at all. -D_FRSRESGID is to make this check unique.
+# otherwise we would get the previous cached result.
+ACX_CHECK_COMPILER_FLAG_NEEDED(-D_GNU_SOURCE -D_FRSRESGID,
+[
+#include
+
+int test() {
+ int a = setresgid(0,0,0);
+ a = setresuid(0,0,0);
+ return a;
+}
+], [CFLAGS="$CFLAGS -D_GNU_SOURCE"])
+
+ACX_CHECK_COMPILER_FLAG_NEEDED(-D_POSIX_C_SOURCE=200112,
+[
+#include "confdefs.h"
+#ifdef HAVE_TIME_H
+#include
+#endif
+#include
+
+int test() {
+ int a = 0;
+ char *t;
+ time_t time = 0;
+ char *buf = NULL;
+ const char* str = NULL;
+ t = ctime_r(&time, buf);
+ str = gai_strerror(0);
+ return a;
+}
+], [CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=200112"])
+
+ACX_CHECK_COMPILER_FLAG_NEEDED(-D__EXTENSIONS__,
+[
+#include "confdefs.h"
+#include
+#include
+#include
+#ifdef HAVE_TIME_H
+#include
+#endif
+#include
+#ifdef HAVE_GETOPT_H
+#include
+#endif
+
+int test() {
+ int a;
+ char **opts = NULL;
+ struct timeval tv;
+ tv.tv_usec = 10;
+ srandom(32);
+ a = getopt(2, opts, "a");
+ a = isascii(32);
+ return a;
+}
+], [CFLAGS="$CFLAGS -D__EXTENSIONS__"])
+
+])dnl End of ACX_DETERMINE_EXT_FLAGS_UNBOUND
+
+dnl Check the printf-format attribute (if any)
+dnl result in HAVE_ATTR_FORMAT.
+dnl Make sure you also include the AHX_CONFIG_FORMAT_ATTRIBUTE.
+AC_DEFUN([ACX_CHECK_FORMAT_ATTRIBUTE],
+[AC_REQUIRE([AC_PROG_CC])
+AC_MSG_CHECKING(whether the C compiler (${CC-cc}) accepts the "format" attribute)
+AC_CACHE_VAL(ac_cv_c_format_attribute,
+[ac_cv_c_format_attribute=no
+AC_TRY_COMPILE(
+[#include
+void f (char *format, ...) __attribute__ ((format (printf, 1, 2)));
+void (*pf) (char *format, ...) __attribute__ ((format (printf, 1, 2)));
+], [
+ f ("%s", "str");
+],
+[ac_cv_c_format_attribute="yes"],
+[ac_cv_c_format_attribute="no"])
+])
+
+AC_MSG_RESULT($ac_cv_c_format_attribute)
+if test $ac_cv_c_format_attribute = yes; then
+ AC_DEFINE(HAVE_ATTR_FORMAT, 1, [Whether the C compiler accepts the "format" attribute])
+fi
+])dnl End of ACX_CHECK_FORMAT_ATTRIBUTE
+
+dnl Setup ATTR_FORMAT config.h parts.
+dnl make sure you call ACX_CHECK_FORMAT_ATTRIBUTE also.
+AC_DEFUN([AHX_CONFIG_FORMAT_ATTRIBUTE],
+[
+#ifdef HAVE_ATTR_FORMAT
+# define ATTR_FORMAT(archetype, string_index, first_to_check) \
+ __attribute__ ((format (archetype, string_index, first_to_check)))
+#else /* !HAVE_ATTR_FORMAT */
+# define ATTR_FORMAT(archetype, string_index, first_to_check) /* empty */
+#endif /* !HAVE_ATTR_FORMAT */
+])
+
+dnl Check how to mark function arguments as unused.
+dnl result in HAVE_ATTR_UNUSED.
+dnl Make sure you include AHX_CONFIG_UNUSED_ATTRIBUTE also.
+AC_DEFUN([ACX_CHECK_UNUSED_ATTRIBUTE],
+[AC_REQUIRE([AC_PROG_CC])
+AC_MSG_CHECKING(whether the C compiler (${CC-cc}) accepts the "unused" attribute)
+AC_CACHE_VAL(ac_cv_c_unused_attribute,
+[ac_cv_c_unused_attribute=no
+AC_TRY_COMPILE(
+[#include
+void f (char *u __attribute__((unused)));
+], [
+ f ("x");
+],
+[ac_cv_c_unused_attribute="yes"],
+[ac_cv_c_unused_attribute="no"])
+])
+
+dnl Setup ATTR_UNUSED config.h parts.
+dnl make sure you call ACX_CHECK_UNUSED_ATTRIBUTE also.
+AC_DEFUN([AHX_CONFIG_UNUSED_ATTRIBUTE],
+[
+#if defined(DOXYGEN)
+# define ATTR_UNUSED(x) x
+#elif defined(__cplusplus)
+# define ATTR_UNUSED(x)
+#elif defined(HAVE_ATTR_UNUSED)
+# define ATTR_UNUSED(x) x __attribute__((unused))
+#else /* !HAVE_ATTR_UNUSED */
+# define ATTR_UNUSED(x) x
+#endif /* !HAVE_ATTR_UNUSED */
+])
+
+AC_MSG_RESULT($ac_cv_c_unused_attribute)
+if test $ac_cv_c_unused_attribute = yes; then
+ AC_DEFINE(HAVE_ATTR_UNUSED, 1, [Whether the C compiler accepts the "unused" attribute])
+fi
+])dnl
+
+dnl Pre-fun for ACX_LIBTOOL_C_ONLY
+AC_DEFUN([ACX_LIBTOOL_C_PRE], [
+# skip these tests, we do not need them.
+AC_DEFUN([AC_PROG_F77], [:])
+AC_DEFUN([AC_PROG_FC], [:])
+AC_DEFUN([AC_PROG_CXX], [:])
+AC_DEFUN([AC_PROG_CXXCPP], [:])
+AC_DEFUN([AC_PROG_OBJC], [:])
+AC_DEFUN([AC_PROG_OBJCCPP], [:])
+AC_DEFUN([AC_LIBTOOL_CXX], [:])
+AC_DEFUN([AC_LIBTOOL_F77], [:])
+# always use ./libtool unless override from commandline (libtool=mylibtool)
+if test -z "$libtool"; then
+ libtool="./libtool"
+fi
+AC_SUBST(libtool)
+# avoid libtool max commandline length test on systems that fork slowly.
+AC_CANONICAL_HOST
+if echo "$host_os" | grep "sunos4" >/dev/null; then
+ lt_cv_sys_max_cmd_len=32750;
+fi
+AC_PATH_TOOL(AR, ar, [false])
+if test $AR = false; then
+ AC_MSG_ERROR([Cannot find 'ar', please extend PATH to include it])
+fi
+])
+
+dnl Perform libtool check, portably, only for C
+AC_DEFUN([ACX_LIBTOOL_C_ONLY], [
+dnl as a requirement so that is gets called before LIBTOOL
+dnl because libtools 'AC_REQUIRE' names are right after this one, before
+dnl this function contents.
+AC_REQUIRE([ACX_LIBTOOL_C_PRE])
+AC_PROG_LIBTOOL
+])
+
+dnl Detect if u_char type is defined, otherwise define it.
+AC_DEFUN([ACX_TYPE_U_CHAR],
+[AC_CHECK_TYPE([u_char], ,
+ [AC_DEFINE([u_char], [unsigned char], [Define to 'unsigned char if not defined])], [
+AC_INCLUDES_DEFAULT
+#ifdef HAVE_WINSOCK2_H
+# include
+#endif
+]) ])
+
+dnl Detect if rlim_t type is defined, otherwise define it.
+AC_DEFUN([ACX_TYPE_RLIM_T],
+[AC_CHECK_TYPE(rlim_t, ,
+ [AC_DEFINE([rlim_t], [unsigned long], [Define to 'int' if not defined])], [
+AC_INCLUDES_DEFAULT
+#ifdef HAVE_SYS_RESOURCE_H
+# include
+#endif
+]) ])
+
+dnl Detect if socklen_t type is defined, otherwise define it.
+AC_DEFUN([ACX_TYPE_SOCKLEN_T],
+[
+AC_CHECK_TYPE(socklen_t, ,
+ [AC_DEFINE([socklen_t], [int], [Define to 'int' if not defined])], [
+AC_INCLUDES_DEFAULT
+#ifdef HAVE_SYS_SOCKET_H
+# include
+#endif
+#ifdef HAVE_WS2TCPIP_H
+# include
+#endif
+]) ])
+
+dnl Detect if in_addr_t type is defined, otherwise define it.
+AC_DEFUN([ACX_TYPE_IN_ADDR_T],
+[ AC_CHECK_TYPE(in_addr_t, [], [AC_DEFINE([in_addr_t], [uint32_t], [in_addr_t])], [
+AC_INCLUDES_DEFAULT
+#ifdef HAVE_SYS_TYPES_H
+# include
+#endif
+#ifdef HAVE_NETINET_IN_H
+# include
+#endif
+]) ])
+
+dnl Detect if in_port_t type is defined, otherwise define it.
+AC_DEFUN([ACX_TYPE_IN_PORT_T],
+[ AC_CHECK_TYPE(in_port_t, [], [AC_DEFINE([in_port_t], [uint16_t], [in_port_t])], [
+AC_INCLUDES_DEFAULT
+#ifdef HAVE_SYS_TYPES_H
+# include
+#endif
+#ifdef HAVE_NETINET_IN_H
+# include
+#endif
+]) ])
+
+dnl Add option to disable the evil rpath. Check whether to use rpath or not.
+dnl Adds the --disable-rpath option. Uses trick to edit the ./libtool.
+AC_DEFUN([ACX_ARG_RPATH],
+[
+AC_ARG_ENABLE(rpath,
+ [ --disable-rpath disable hardcoded rpath (default=enabled)],
+ enable_rpath=$enableval, enable_rpath=yes)
+if test "x$enable_rpath" = xno; then
+ dnl AC_MSG_RESULT([Fixing libtool for -rpath problems.])
+ AC_CONFIG_COMMANDS([disable-rpath], [
+ sed < libtool > libtool-2 \
+ 's/^hardcode_libdir_flag_spec.*$'/'hardcode_libdir_flag_spec=" -D__LIBTOOL_RPATH_SED__ "/'
+ mv libtool-2 libtool
+ chmod 755 libtool
+ libtool="./libtool"
+ ])
+fi
+])
+
+dnl Add a -R to the RUNTIME_PATH. Only if rpath is enabled and it is
+dnl an absolute path.
+dnl $1: the pathname to add.
+AC_DEFUN([ACX_RUNTIME_PATH_ADD], [
+ if test "x$enable_rpath" = xyes; then
+ if echo "$1" | grep "^/" >/dev/null; then
+ RUNTIME_PATH="$RUNTIME_PATH -R$1"
+ fi
+ fi
+])
+
+dnl Common code for both ACX_WITH_SSL and ACX_WITH_SSL_OPTIONAL
+dnl Takes one argument; the withval checked in those 2 functions
+dnl sets up the environment for the given openssl path
+AC_DEFUN([ACX_SSL_CHECKS], [
+ withval=$1
+ if test x_$withval != x_no; then
+ AC_MSG_CHECKING(for SSL)
+ if test x_$withval = x_ -o x_$withval = x_yes; then
+ withval="/usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /opt/local /usr/sfw /usr"
+ fi
+ for dir in $withval; do
+ ssldir="$dir"
+ if test -f "$dir/include/openssl/ssl.h"; then
+ found_ssl="yes"
+ AC_DEFINE_UNQUOTED([HAVE_SSL], [], [Define if you have the SSL libraries installed.])
+ dnl assume /usr/include is already in the include-path.
+ if test "$ssldir" != "/usr"; then
+ CPPFLAGS="$CPPFLAGS -I$ssldir/include"
+ LIBSSL_CPPFLAGS="$LIBSSL_CPPFLAGS -I$ssldir/include"
+ fi
+ break;
+ fi
+ done
+ if test x_$found_ssl != x_yes; then
+ AC_MSG_ERROR(Cannot find the SSL libraries in $withval)
+ else
+ AC_MSG_RESULT(found in $ssldir)
+ HAVE_SSL=yes
+ dnl assume /usr is already in the lib and dynlib paths.
+ if test "$ssldir" != "/usr" -a "$ssldir" != ""; then
+ LDFLAGS="$LDFLAGS -L$ssldir/lib"
+ LIBSSL_LDFLAGS="$LIBSSL_LDFLAGS -L$ssldir/lib"
+ ACX_RUNTIME_PATH_ADD([$ssldir/lib])
+ fi
+
+ AC_MSG_CHECKING([for HMAC_CTX_init in -lcrypto])
+ LIBS="$LIBS -lcrypto"
+ LIBSSL_LIBS="$LIBSSL_LIBS -lcrypto"
+ AC_TRY_LINK(, [
+ int HMAC_CTX_init(void);
+ (void)HMAC_CTX_init();
+ ], [
+ AC_MSG_RESULT(yes)
+ AC_DEFINE([HAVE_HMAC_CTX_INIT], 1,
+ [If you have HMAC_CTX_init])
+ ], [
+ AC_MSG_RESULT(no)
+ # check if -lwsock32 or -lgdi32 are needed.
+ BAKLIBS="$LIBS"
+ BAKSSLLIBS="$LIBSSL_LIBS"
+ LIBS="$LIBS -lgdi32"
+ LIBSSL_LIBS="$LIBSSL_LIBS -lgdi32"
+ AC_MSG_CHECKING([if -lcrypto needs -lgdi32])
+ AC_TRY_LINK([], [
+ int HMAC_CTX_init(void);
+ (void)HMAC_CTX_init();
+ ],[
+ AC_DEFINE([HAVE_HMAC_CTX_INIT], 1,
+ [If you have HMAC_CTX_init])
+ AC_MSG_RESULT(yes)
+ ],[
+ AC_MSG_RESULT(no)
+ LIBS="$BAKLIBS"
+ LIBSSL_LIBS="$BAKSSLLIBS"
+ LIBS="$LIBS -ldl"
+ LIBSSL_LIBS="$LIBSSL_LIBS -ldl"
+ AC_MSG_CHECKING([if -lcrypto needs -ldl])
+ AC_TRY_LINK([], [
+ int HMAC_CTX_init(void);
+ (void)HMAC_CTX_init();
+ ],[
+ AC_DEFINE([HAVE_HMAC_CTX_INIT], 1,
+ [If you have HMAC_CTX_init])
+ AC_MSG_RESULT(yes)
+ ],[
+ AC_MSG_RESULT(no)
+ AC_MSG_ERROR([OpenSSL found in $ssldir, but version 0.9.7 or higher is required])
+ ])
+ ])
+ ])
+ fi
+ AC_SUBST(HAVE_SSL)
+ AC_SUBST(RUNTIME_PATH)
+ # openssl engine functionality needs dlopen().
+ BAKLIBS="$LIBS"
+ AC_SEARCH_LIBS([dlopen], [dl])
+ if test "$LIBS" != "$BAKLIBS"; then
+ LIBSSL_LIBS="$LIBSSL_LIBS -ldl"
+ fi
+ fi
+AC_CHECK_HEADERS([openssl/ssl.h],,, [AC_INCLUDES_DEFAULT])
+AC_CHECK_HEADERS([openssl/err.h],,, [AC_INCLUDES_DEFAULT])
+AC_CHECK_HEADERS([openssl/rand.h],,, [AC_INCLUDES_DEFAULT])
+])dnl End of ACX_SSL_CHECKS
+
+dnl Check for SSL, where SSL is mandatory
+dnl Adds --with-ssl option, searches for openssl and defines HAVE_SSL if found
+dnl Setup of CPPFLAGS, CFLAGS. Adds -lcrypto to LIBS.
+dnl Checks main header files of SSL.
+dnl
+AC_DEFUN([ACX_WITH_SSL],
+[
+AC_ARG_WITH(ssl, AC_HELP_STRING([--with-ssl=pathname],
+ [enable SSL (will check /usr/local/ssl
+ /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /opt/local /usr/sfw /usr)]),[
+ ],[
+ withval="yes"
+ ])
+ if test x_$withval = x_no; then
+ AC_MSG_ERROR([Need SSL library to do digital signature cryptography])
+ fi
+ ACX_SSL_CHECKS($withval)
+])dnl End of ACX_WITH_SSL
+
+dnl Check for SSL, where ssl is optional (--without-ssl is allowed)
+dnl Adds --with-ssl option, searches for openssl and defines HAVE_SSL if found
+dnl Setup of CPPFLAGS, CFLAGS. Adds -lcrypto to LIBS.
+dnl Checks main header files of SSL.
+dnl
+AC_DEFUN([ACX_WITH_SSL_OPTIONAL],
+[
+AC_ARG_WITH(ssl, AC_HELP_STRING([--with-ssl=pathname],
+ [enable SSL (will check /usr/local/ssl
+ /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /opt/local /usr/sfw /usr)]),[
+ ],[
+ withval="yes"
+ ])
+ ACX_SSL_CHECKS($withval)
+])dnl End of ACX_WITH_SSL_OPTIONAL
+
+dnl Setup to use -lssl
+dnl To use -lcrypto, use the ACX_WITH_SSL setup (before this one).
+AC_DEFUN([ACX_LIB_SSL],
+[
+# check if libssl needs libdl
+BAKLIBS="$LIBS"
+LIBS="-lssl $LIBS"
+AC_MSG_CHECKING([if libssl needs libdl])
+AC_TRY_LINK_FUNC([SSL_CTX_new], [
+ AC_MSG_RESULT([no])
+ LIBS="$BAKLIBS"
+] , [
+ AC_MSG_RESULT([yes])
+ LIBS="$BAKLIBS"
+ AC_SEARCH_LIBS([dlopen], [dl])
+]) ])dnl End of ACX_LIB_SSL
+
+dnl Setup to use very large files (>2Gb).
+dnl setups fseeko and its own
+AC_DEFUN([ACX_SYS_LARGEFILE],
+[
+AC_SYS_LARGEFILE
+dnl try to see if an additional _LARGEFILE_SOURCE 1 is needed to get fseeko
+ACX_CHECK_COMPILER_FLAG_NEEDED(-D_LARGEFILE_SOURCE=1,
+[
+#include
+int test() {
+ int a = fseeko(stdin, 0, 0);
+ return a;
+}
+], [CFLAGS="$CFLAGS -D_LARGEFILE_SOURCE=1"])
+])
+
+dnl Check getaddrinfo.
+dnl Works on linux, solaris, bsd and windows(links winsock).
+dnl defines HAVE_GETADDRINFO, USE_WINSOCK.
+AC_DEFUN([ACX_CHECK_GETADDRINFO_WITH_INCLUDES],
+[AC_REQUIRE([AC_PROG_CC])
+AC_MSG_CHECKING(for getaddrinfo)
+ac_cv_func_getaddrinfo=no
+AC_LINK_IFELSE(
+[
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+char* getaddrinfo();
+char* (*f) () = getaddrinfo;
+#ifdef __cplusplus
+}
+#endif
+int main() {
+ ;
+ return 0;
+}
+],
+dnl this case on linux, solaris, bsd
+[ac_cv_func_getaddrinfo="yes"],
+dnl no quick getaddrinfo, try mingw32 and winsock2 library.
+ORIGLIBS="$LIBS"
+LIBS="$LIBS -lws2_32"
+AC_LINK_IFELSE(
+AC_LANG_PROGRAM(
+[
+#ifdef HAVE_WS2TCPIP_H
+#include
+#endif
+],
+[
+ (void)getaddrinfo(NULL, NULL, NULL, NULL);
+]
+),
+[
+ac_cv_func_getaddrinfo="yes"
+dnl already: LIBS="$LIBS -lws2_32"
+AC_DEFINE(USE_WINSOCK, 1, [Whether the windows socket API is used])
+USE_WINSOCK="1"
+],
+[
+ac_cv_func_getaddrinfo="no"
+LIBS="$ORIGLIBS"
+])
+)
+
+AC_MSG_RESULT($ac_cv_func_getaddrinfo)
+if test $ac_cv_func_getaddrinfo = yes; then
+ AC_DEFINE(HAVE_GETADDRINFO, 1, [Whether getaddrinfo is available])
+fi
+])dnl Endof AC_CHECK_GETADDRINFO_WITH_INCLUDES
+
+dnl check if a function is deprecated. defines DEPRECATED_func in config.h.
+dnl $1: function name
+dnl $2: C-statement that calls the function.
+dnl $3: includes for the program.
+dnl $4: executes if yes
+dnl $5: executes if no
+AC_DEFUN([ACX_FUNC_DEPRECATED],
+[
+AC_REQUIRE([AC_PROG_CC])
+AC_MSG_CHECKING(if $1 is deprecated)
+cache=`echo $1 | sed 'y%.=/+-%___p_%'`
+AC_CACHE_VAL(cv_cc_deprecated_$cache,
+[
+echo '$3' >conftest.c
+echo 'void f(){ $2 }' >>conftest.c
+if test -z "`$CC -c conftest.c 2>&1 | grep deprecated`"; then
+eval "cv_cc_deprecated_$cache=no"
+else
+eval "cv_cc_deprecated_$cache=yes"
+fi
+rm -f conftest conftest.o conftest.c
+])
+if eval "test \"`echo '$cv_cc_deprecated_'$cache`\" = yes"; then
+AC_MSG_RESULT(yes)
+AC_DEFINE_UNQUOTED(AS_TR_CPP([DEPRECATED_$1]), 1, [Whether $1 is deprecated])
+:
+$4
+else
+AC_MSG_RESULT(no)
+:
+$5
+fi
+])dnl end of ACX_FUNC_DEPRECATED
+
+dnl check if select and nonblocking sockets actually work.
+dnl Needs fork(2) and select(2).
+dnl defines NONBLOCKING_IS_BROKEN, and if that is true multiple reads from
+dnl a nonblocking socket do not work, a new call to select is necessary.
+AC_DEFUN([ACX_CHECK_NONBLOCKING_BROKEN],
+[
+AC_MSG_CHECKING([if nonblocking sockets work])
+if echo $target | grep mingw32 >/dev/null; then
+ AC_MSG_RESULT([no (windows)])
+ AC_DEFINE([NONBLOCKING_IS_BROKEN], 1, [Define if the network stack does not fully support nonblocking io (causes lower performance).])
+else
+AC_RUN_IFELSE(AC_LANG_PROGRAM([
+#include
+#include
+#include
+#include
+#include
+#ifdef HAVE_SYS_TYPES_H
+#include
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include
+#endif
+#ifdef HAVE_NETINET_IN_H
+#include
+#endif
+#ifdef HAVE_ARPA_INET_H
+#include
+#endif
+#ifdef HAVE_UNISTD_H
+#include
+#endif
+#ifdef HAVE_TIME_H
+#include
+#endif
+],[[
+ int port;
+ int sfd, cfd;
+ int num = 10;
+ int i, p;
+ struct sockaddr_in a;
+ /* test if select and nonblocking reads work well together */
+ /* open port.
+ fork child to send 10 messages.
+ select to read.
+ then try to nonblocking read the 10 messages
+ then, nonblocking read must give EAGAIN
+ */
+
+ port = 12345 + (time(0)%32);
+ sfd = socket(PF_INET, SOCK_DGRAM, 0);
+ if(sfd == -1) {
+ perror("socket");
+ return 1;
+ }
+ memset(&a, 0, sizeof(a));
+ a.sin_family = AF_INET;
+ a.sin_port = htons(port);
+ a.sin_addr.s_addr = inet_addr("127.0.0.1");
+ if(bind(sfd, (struct sockaddr*)&a, sizeof(a)) < 0) {
+ perror("bind");
+ return 1;
+ }
+ if(fcntl(sfd, F_SETFL, O_NONBLOCK) == -1) {
+ perror("fcntl");
+ return 1;
+ }
+
+ cfd = socket(PF_INET, SOCK_DGRAM, 0);
+ if(cfd == -1) {
+ perror("client socket");
+ return 1;
+ }
+ a.sin_port = 0;
+ if(bind(cfd, (struct sockaddr*)&a, sizeof(a)) < 0) {
+ perror("client bind");
+ return 1;
+ }
+ a.sin_port = htons(port);
+
+ /* no handler, causes exit in 10 seconds */
+ alarm(10);
+
+ /* send and receive on the socket */
+ if((p=fork()) == 0) {
+ for(i=0; i
+#include
+#ifdef HAVE_WINSOCK2_H
+#include
+#endif
+#ifdef HAVE_SYS_STAT_H
+#include
+#endif
+], [
+ (void)mkdir("directory");
+],
+AC_MSG_RESULT(yes)
+AC_DEFINE(MKDIR_HAS_ONE_ARG, 1, [Define if mkdir has one argument.])
+,
+AC_MSG_RESULT(no)
+)
+])dnl end of ACX_MKDIR_ONE_ARG
+
+dnl Check for ioctlsocket function. works on mingw32 too.
+AC_DEFUN([ACX_FUNC_IOCTLSOCKET],
+[
+# check ioctlsocket
+AC_MSG_CHECKING(for ioctlsocket)
+AC_LINK_IFELSE(AC_LANG_PROGRAM([
+#ifdef HAVE_WINSOCK2_H
+#include
+#endif
+], [
+ (void)ioctlsocket(0, 0, NULL);
+]), [
+AC_MSG_RESULT(yes)
+AC_DEFINE(HAVE_IOCTLSOCKET, 1, [if the function 'ioctlsocket' is available])
+],[AC_MSG_RESULT(no)])
+])dnl end of ACX_FUNC_IOCTLSOCKET
+
+dnl detect malloc and provide malloc compat prototype.
+dnl $1: unique name for compat code
+AC_DEFUN([ACX_FUNC_MALLOC],
+[
+ AC_FUNC_MALLOC
+ if test "$ac_cv_func_malloc_0_nonnull" = no; then
+ AC_DEFINE_UNQUOTED([malloc], [rpl_malloc_$1], [Define if replacement function should be used.])
+ fi
+])
+
+dnl Define fallback for fseeko and ftello if needed.
+AC_DEFUN([AHX_CONFIG_FSEEKO],
+[
+#ifndef HAVE_FSEEKO
+#define fseeko fseek
+#define ftello ftell
+#endif /* HAVE_FSEEKO */
+])
+
+dnl Define RAND_MAX if not defined
+AC_DEFUN([AHX_CONFIG_RAND_MAX],
+[
+#ifndef RAND_MAX
+#define RAND_MAX 2147483647
+#endif
+])
+
+dnl Define MAXHOSTNAMELEN if not defined
+AC_DEFUN([AHX_CONFIG_MAXHOSTNAMELEN],
+[
+#ifndef MAXHOSTNAMELEN
+#define MAXHOSTNAMELEN 256
+#endif
+])
+
+dnl Define IPV6_MIN_MTU if not defined
+AC_DEFUN([AHX_CONFIG_IPV6_MIN_MTU],
+[
+#ifndef IPV6_MIN_MTU
+#define IPV6_MIN_MTU 1280
+#endif /* IPV6_MIN_MTU */
+])
+
+dnl provide snprintf, vsnprintf compat prototype
+dnl $1: unique name for compat code
+AC_DEFUN([AHX_CONFIG_SNPRINTF],
+[
+#ifndef HAVE_SNPRINTF
+#define snprintf snprintf_$1
+#define vsnprintf vsnprintf_$1
+#include
+int snprintf (char *str, size_t count, const char *fmt, ...);
+int vsnprintf (char *str, size_t count, const char *fmt, va_list arg);
+#endif /* HAVE_SNPRINTF */
+])
+
+dnl provide inet_pton compat prototype.
+dnl $1: unique name for compat code
+AC_DEFUN([AHX_CONFIG_INET_PTON],
+[
+#ifndef HAVE_INET_PTON
+#define inet_pton inet_pton_$1
+int inet_pton(int af, const char* src, void* dst);
+#endif /* HAVE_INET_PTON */
+])
+
+dnl provide inet_ntop compat prototype.
+dnl $1: unique name for compat code
+AC_DEFUN([AHX_CONFIG_INET_NTOP],
+[
+#ifndef HAVE_INET_NTOP
+#define inet_ntop inet_ntop_$1
+const char *inet_ntop(int af, const void *src, char *dst, size_t size);
+#endif
+])
+
+dnl provide inet_aton compat prototype.
+dnl $1: unique name for compat code
+AC_DEFUN([AHX_CONFIG_INET_ATON],
+[
+#ifndef HAVE_INET_ATON
+#define inet_aton inet_aton_$1
+int inet_aton(const char *cp, struct in_addr *addr);
+#endif
+])
+
+dnl provide memmove compat prototype.
+dnl $1: unique name for compat code
+AC_DEFUN([AHX_CONFIG_MEMMOVE],
+[
+#ifndef HAVE_MEMMOVE
+#define memmove memmove_$1
+void *memmove(void *dest, const void *src, size_t n);
+#endif
+])
+
+dnl provide strlcat compat prototype.
+dnl $1: unique name for compat code
+AC_DEFUN([AHX_CONFIG_STRLCAT],
+[
+#ifndef HAVE_STRLCAT
+#define strlcat strlcat_$1
+size_t strlcat(char *dst, const char *src, size_t siz);
+#endif
+])
+
+dnl provide strlcpy compat prototype.
+dnl $1: unique name for compat code
+AC_DEFUN([AHX_CONFIG_STRLCPY],
+[
+#ifndef HAVE_STRLCPY
+#define strlcpy strlcpy_$1
+size_t strlcpy(char *dst, const char *src, size_t siz);
+#endif
+])
+
+dnl provide gmtime_r compat prototype.
+dnl $1: unique name for compat code
+AC_DEFUN([AHX_CONFIG_GMTIME_R],
+[
+#ifndef HAVE_GMTIME_R
+#define gmtime_r gmtime_r_$1
+struct tm *gmtime_r(const time_t *timep, struct tm *result);
+#endif
+])
+
+dnl provide w32 compat definition for sleep
+AC_DEFUN([AHX_CONFIG_W32_SLEEP],
+[
+#ifndef HAVE_SLEEP
+#define sleep(x) Sleep((x)*1000) /* on win32 */
+#endif /* HAVE_SLEEP */
+])
+
+dnl provide w32 compat definition for usleep
+AC_DEFUN([AHX_CONFIG_W32_USLEEP],
+[
+#ifndef HAVE_USLEEP
+#define usleep(x) Sleep((x)/1000 + 1) /* on win32 */
+#endif /* HAVE_USLEEP */
+])
+
+dnl provide w32 compat definition for random
+AC_DEFUN([AHX_CONFIG_W32_RANDOM],
+[
+#ifndef HAVE_RANDOM
+#define random rand /* on win32, for tests only (bad random) */
+#endif /* HAVE_RANDOM */
+])
+
+dnl provide w32 compat definition for srandom
+AC_DEFUN([AHX_CONFIG_W32_SRANDOM],
+[
+#ifndef HAVE_SRANDOM
+#define srandom(x) srand(x) /* on win32, for tests only (bad random) */
+#endif /* HAVE_SRANDOM */
+])
+
+dnl provide w32 compat definition for FD_SET_T
+AC_DEFUN([AHX_CONFIG_W32_FD_SET_T],
+[
+/* detect if we need to cast to unsigned int for FD_SET to avoid warnings */
+#ifdef HAVE_WINSOCK2_H
+#define FD_SET_T (u_int)
+#else
+#define FD_SET_T
+#endif
+])
+
+dnl Remove an extension flag from CFLAGS, define replacement to be made.
+dnl Used by ACX_STRIP_EXT_FLAGS.
+dnl $1: the name of the flag, for example -D_GNU_SOURCE.
+AC_DEFUN([ACX_CFLAGS_STRIP],
+[
+ if echo $CFLAGS | grep " $1" >/dev/null 2>&1; then
+ CFLAGS="`echo $CFLAGS | sed -e 's/ $1//g'`"
+ AC_DEFINE(m4_bpatsubst(OMITTED_$1,[[-=]],_), 1, Put $1 define in config.h)
+ fi
+])
+
+dnl Remove EXT flags from the CFLAGS and set them to be defined in config.h
+dnl use with ACX_DETERMINE_EXT_FLAGS.
+AC_DEFUN([ACX_STRIP_EXT_FLAGS],
+[
+ AC_MSG_NOTICE([Stripping extension flags...])
+ ACX_CFLAGS_STRIP(-D_GNU_SOURCE)
+ ACX_CFLAGS_STRIP(-D_BSD_SOURCE)
+ ACX_CFLAGS_STRIP(-D__EXTENSIONS__)
+ ACX_CFLAGS_STRIP(-D_POSIX_C_SOURCE=200112)
+ ACX_CFLAGS_STRIP(-D_XOPEN_SOURCE=600)
+ ACX_CFLAGS_STRIP(-D_XOPEN_SOURCE_EXTENDED=1)
+ ACX_CFLAGS_STRIP(-D_ALL_SOURCE)
+ ACX_CFLAGS_STRIP(-D_LARGEFILE_SOURCE=1)
+]) dnl End of ACX_STRIP_EXT_FLAGS
+
+dnl define one omitted flag for config.h
+dnl $1: flag name. -D_GNU_SOURCE
+dnl $2: replacement define. _GNU_SOURCE
+dnl $3: define value, 1
+AC_DEFUN([AHX_CONFIG_FLAG_OMITTED],
+[#if defined($1) && !defined($2)
+#define $2 $3
+[#]endif ])
+
+dnl Wrapper for AHX_CONFIG_FLAG_OMITTED for -D style flags
+dnl $1: the -DNAME or -DNAME=value string.
+AC_DEFUN([AHX_CONFIG_FLAG_EXT],
+[AHX_CONFIG_FLAG_OMITTED(m4_bpatsubst(OMITTED_$1,[[-=]],_),m4_bpatsubst(m4_bpatsubst($1,-D,),=.*$,),m4_if(m4_bregexp($1,=),-1,1,m4_bpatsubst($1,^.*=,)))
+])
+
+dnl config.h part to define omitted cflags, use with ACX_STRIP_EXT_FLAGS.
+AC_DEFUN([AHX_CONFIG_EXT_FLAGS],
+[AHX_CONFIG_FLAG_EXT(-D_GNU_SOURCE)
+AHX_CONFIG_FLAG_EXT(-D_BSD_SOURCE)
+AHX_CONFIG_FLAG_EXT(-D__EXTENSIONS__)
+AHX_CONFIG_FLAG_EXT(-D_POSIX_C_SOURCE=200112)
+AHX_CONFIG_FLAG_EXT(-D_XOPEN_SOURCE=600)
+AHX_CONFIG_FLAG_EXT(-D_XOPEN_SOURCE_EXTENDED=1)
+AHX_CONFIG_FLAG_EXT(-D_ALL_SOURCE)
+AHX_CONFIG_FLAG_EXT(-D_LARGEFILE_SOURCE=1)
+])
+
+dnl check if memcmp is using signed characters and replace if so.
+AC_DEFUN([ACX_CHECK_MEMCMP_SIGNED],
+[AC_MSG_CHECKING([if memcmp compares unsigned])
+AC_RUN_IFELSE([AC_LANG_SOURCE([[
+#include
+#include
+#include
+int main(void)
+{
+ char a = 255, b = 0;
+ if(memcmp(&a, &b, 1) < 0)
+ return 1;
+ return 0;
+}
+]])], [AC_MSG_RESULT([yes]) ],
+[ AC_MSG_RESULT([no])
+ AC_DEFINE([MEMCMP_IS_BROKEN], [1], [Define if memcmp() does not compare unsigned bytes])
+ AC_LIBOBJ([memcmp])
+], [ AC_MSG_RESULT([cross-compile no])
+ AC_DEFINE([MEMCMP_IS_BROKEN], [1], [Define if memcmp() does not compare unsigned bytes])
+ AC_LIBOBJ([memcmp])
+]) ])
+
+dnl define memcmp to its replacement, pass unique id for program as arg
+AC_DEFUN([AHX_MEMCMP_BROKEN], [
+#ifdef MEMCMP_IS_BROKEN
+# ifdef memcmp
+# undef memcmp
+# endif
+#define memcmp memcmp_$1
+int memcmp(const void *x, const void *y, size_t n);
+#endif
+])
+
+dnl ACX_CHECK_SS_FAMILY - check for sockaddr_storage.ss_family
+AC_DEFUN([ACX_CHECK_SS_FAMILY],
+[AC_CHECK_MEMBER([struct sockaddr_storage.ss_family], [], [
+ AC_CHECK_MEMBER([struct sockaddr_storage.__ss_family], [
+ AC_DEFINE([ss_family], [__ss_family], [Fallback member name for socket family in struct sockaddr_storage])
+ ],, [AC_INCLUDES_DEFAULT
+#ifdef HAVE_NETINET_IN_H
+#include
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include
+#endif
+#ifdef HAVE_NETDB_H
+#include
+#endif
+#ifdef HAVE_ARPA_INET_H
+#include
+#endif
+ ])
+], [AC_INCLUDES_DEFAULT
+#ifdef HAVE_NETINET_IN_H
+#include
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include
+#endif
+#ifdef HAVE_NETDB_H
+#include
+#endif
+#ifdef HAVE_ARPA_INET_H
+#include
+#endif
+]) ])
+
+dnl End of file
diff --git a/libs/ldns/acx_python.m4 b/libs/ldns/acx_python.m4
new file mode 100644
index 0000000000..f4bf421f86
--- /dev/null
+++ b/libs/ldns/acx_python.m4
@@ -0,0 +1,200 @@
+AC_DEFUN([AC_PYTHON_DEVEL],[
+ #
+ # Allow the use of a (user set) custom python version
+ #
+ AC_ARG_VAR([PYTHON_VERSION],[The installed Python
+ version to use, for example '2.3'. This string
+ will be appended to the Python interpreter
+ canonical name.])
+
+ AC_PATH_PROG([PYTHON],[python[$PYTHON_VERSION]])
+ if test -z "$PYTHON"; then
+ AC_MSG_ERROR([Cannot find python$PYTHON_VERSION in your system path])
+ PYTHON_VERSION=""
+ fi
+
+ if test -z "$PYTHON_VERSION"; then
+ PYTHON_VERSION=`$PYTHON -c "import sys, string; \
+ print string.split(sys.version)[[0]]"`
+ fi
+
+ #
+ # Check for a version of Python >= 2.1.0
+ #
+ AC_MSG_CHECKING([for a version of Python >= '2.1.0'])
+ ac_supports_python_ver=`$PYTHON -c "import sys, string; \
+ ver = string.split(sys.version)[[0]]; \
+ print ver >= '2.1.0'"`
+ if test "$ac_supports_python_ver" != "True"; then
+ if test -z "$PYTHON_NOVERSIONCHECK"; then
+ AC_MSG_RESULT([no])
+ AC_MSG_FAILURE([
+This version of the AC@&t@_PYTHON_DEVEL macro
+doesn't work properly with versions of Python before
+2.1.0. You may need to re-run configure, setting the
+variables PYTHON_CPPFLAGS, PYTHON_LDFLAGS, PYTHON_SITE_PKG,
+PYTHON_EXTRA_LIBS and PYTHON_EXTRA_LDFLAGS by hand.
+Moreover, to disable this check, set PYTHON_NOVERSIONCHECK
+to something else than an empty string.
+])
+ else
+ AC_MSG_RESULT([skip at user request])
+ fi
+ else
+ AC_MSG_RESULT([yes])
+ fi
+
+ #
+ # if the macro parameter ``version'' is set, honour it
+ #
+ if test -n "$1"; then
+ AC_MSG_CHECKING([for a version of Python $1])
+ ac_supports_python_ver=`$PYTHON -c "import sys, string; \
+ ver = string.split(sys.version)[[0]]; \
+ print ver $1"`
+ if test "$ac_supports_python_ver" = "True"; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ AC_MSG_ERROR([this package requires Python $1.
+If you have it installed, but it isn't the default Python
+interpreter in your system path, please pass the PYTHON_VERSION
+variable to configure. See ``configure --help'' for reference.
+])
+ PYTHON_VERSION=""
+ fi
+ fi
+
+ #
+ # Check if you have distutils, else fail
+ #
+ AC_MSG_CHECKING([for the distutils Python package])
+ ac_distutils_result=`$PYTHON -c "import distutils" 2>&1`
+ if test -z "$ac_distutils_result"; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ AC_MSG_ERROR([cannot import Python module "distutils".
+Please check your Python installation. The error was:
+$ac_distutils_result])
+ PYTHON_VERSION=""
+ fi
+
+ #
+ # Check for Python include path
+ #
+ AC_MSG_CHECKING([for Python include path])
+ if test -z "$PYTHON_CPPFLAGS"; then
+ python_path=`$PYTHON -c "import distutils.sysconfig; \
+ print distutils.sysconfig.get_python_inc();"`
+ if test -n "${python_path}"; then
+ python_path="-I$python_path"
+ fi
+ PYTHON_CPPFLAGS=$python_path
+ fi
+ AC_MSG_RESULT([$PYTHON_CPPFLAGS])
+ AC_SUBST([PYTHON_CPPFLAGS])
+
+ #
+ # Check for Python library path
+ #
+ AC_MSG_CHECKING([for Python library path])
+ if test -z "$PYTHON_LDFLAGS"; then
+ # (makes two attempts to ensure we've got a version number
+ # from the interpreter)
+ py_version=`$PYTHON -c "from distutils.sysconfig import *; \
+ from string import join; \
+ print join(get_config_vars('VERSION'))"`
+ if test "$py_version" = "[None]"; then
+ if test -n "$PYTHON_VERSION"; then
+ py_version=$PYTHON_VERSION
+ else
+ py_version=`$PYTHON -c "import sys; \
+ print sys.version[[:3]]"`
+ fi
+ fi
+
+ PYTHON_LDFLAGS=`$PYTHON -c "from distutils.sysconfig import *; \
+ from string import join; \
+ print '-L' + get_python_lib(0,1), \
+ '-L' + os.path.dirname(get_python_lib(0,1)), \
+ '-lpython';"`$py_version
+ fi
+ AC_MSG_RESULT([$PYTHON_LDFLAGS])
+ AC_SUBST([PYTHON_LDFLAGS])
+
+ #
+ # Check for site packages
+ #
+ AC_MSG_CHECKING([for Python site-packages path])
+ if test -z "$PYTHON_SITE_PKG"; then
+ PYTHON_SITE_PKG=`$PYTHON -c "import distutils.sysconfig; \
+ print distutils.sysconfig.get_python_lib(0,0);"`
+ fi
+ AC_MSG_RESULT([$PYTHON_SITE_PKG])
+ AC_SUBST([PYTHON_SITE_PKG])
+
+ #
+ # libraries which must be linked in when embedding
+ #
+ AC_MSG_CHECKING(python extra libraries)
+ if test -z "$PYTHON_EXTRA_LIBS"; then
+ PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \
+ conf = distutils.sysconfig.get_config_var; \
+ print conf('LOCALMODLIBS'), conf('LIBS')"`
+ fi
+ AC_MSG_RESULT([$PYTHON_EXTRA_LIBS])
+ AC_SUBST(PYTHON_EXTRA_LIBS)
+
+ #
+ # linking flags needed when embedding
+ #
+ AC_MSG_CHECKING(python extra linking flags)
+ if test -z "$PYTHON_EXTRA_LDFLAGS"; then
+ PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "import distutils.sysconfig; \
+ conf = distutils.sysconfig.get_config_var; \
+ print conf('LINKFORSHARED')"`
+ fi
+ AC_MSG_RESULT([$PYTHON_EXTRA_LDFLAGS])
+ AC_SUBST(PYTHON_EXTRA_LDFLAGS)
+
+ #
+ # final check to see if everything compiles alright
+ #
+ AC_MSG_CHECKING([consistency of all components of python development environment])
+ AC_LANG_PUSH([C])
+ # save current global flags
+ LIBS="$ac_save_LIBS $PYTHON_LDFLAGS"
+ CPPFLAGS="$ac_save_CPPFLAGS $PYTHON_CPPFLAGS"
+ AC_TRY_LINK([
+ #include
+ ],[
+ Py_Initialize();
+ ],[pythonexists=yes],[pythonexists=no])
+
+ AC_MSG_RESULT([$pythonexists])
+
+ if test ! "$pythonexists" = "yes"; then
+ AC_MSG_ERROR([
+ Could not link test program to Python. Maybe the main Python library has been
+ installed in some non-standard library path. If so, pass it to configure,
+ via the LDFLAGS environment variable.
+ Example: ./configure LDFLAGS="-L/usr/non-standard-path/python/lib"
+ ============================================================================
+ ERROR!
+ You probably have to install the development version of the Python package
+ for your distribution. The exact name of this package varies among them.
+ ============================================================================
+ ])
+ PYTHON_VERSION=""
+ fi
+ AC_LANG_POP
+ # turn back to default flags
+ CPPFLAGS="$ac_save_CPPFLAGS"
+ LIBS="$ac_save_LIBS"
+
+ #
+ # all done!
+ #
+])
+
diff --git a/libs/ldns/buffer.c b/libs/ldns/buffer.c
new file mode 100644
index 0000000000..5a6b0ba74c
--- /dev/null
+++ b/libs/ldns/buffer.c
@@ -0,0 +1,176 @@
+/*
+ * buffer.c -- generic memory buffer .
+ *
+ * Copyright (c) 2001-2008, NLnet Labs. All rights reserved.
+ *
+ * See LICENSE for the license.
+ *
+ */
+
+#include
+
+#include
+#include
+
+ldns_buffer *
+ldns_buffer_new(size_t capacity)
+{
+ ldns_buffer *buffer = LDNS_MALLOC(ldns_buffer);
+
+ if (!buffer) {
+ return NULL;
+ }
+
+ buffer->_data = (uint8_t *) LDNS_XMALLOC(uint8_t, capacity);
+ if (!buffer->_data) {
+ LDNS_FREE(buffer);
+ return NULL;
+ }
+
+ buffer->_position = 0;
+ buffer->_limit = buffer->_capacity = capacity;
+ buffer->_fixed = 0;
+ buffer->_status = LDNS_STATUS_OK;
+
+ ldns_buffer_invariant(buffer);
+
+ return buffer;
+}
+
+void
+ldns_buffer_new_frm_data(ldns_buffer *buffer, void *data, size_t size)
+{
+ assert(data != NULL);
+
+ buffer->_position = 0;
+ buffer->_limit = buffer->_capacity = size;
+ buffer->_fixed = 0;
+ buffer->_data = LDNS_XMALLOC(uint8_t, size);
+ if(!buffer->_data) {
+ buffer->_status = LDNS_STATUS_MEM_ERR;
+ return;
+ }
+ memcpy(buffer->_data, data, size);
+ buffer->_status = LDNS_STATUS_OK;
+
+ ldns_buffer_invariant(buffer);
+}
+
+bool
+ldns_buffer_set_capacity(ldns_buffer *buffer, size_t capacity)
+{
+ void *data;
+
+ ldns_buffer_invariant(buffer);
+ assert(buffer->_position <= capacity);
+
+ data = (uint8_t *) LDNS_XREALLOC(buffer->_data, uint8_t, capacity);
+ if (!data) {
+ buffer->_status = LDNS_STATUS_MEM_ERR;
+ return false;
+ } else {
+ buffer->_data = data;
+ buffer->_limit = buffer->_capacity = capacity;
+ return true;
+ }
+}
+
+bool
+ldns_buffer_reserve(ldns_buffer *buffer, size_t amount)
+{
+ ldns_buffer_invariant(buffer);
+ assert(!buffer->_fixed);
+ if (buffer->_capacity < buffer->_position + amount) {
+ size_t new_capacity = buffer->_capacity * 3 / 2;
+
+ if (new_capacity < buffer->_position + amount) {
+ new_capacity = buffer->_position + amount;
+ }
+ if (!ldns_buffer_set_capacity(buffer, new_capacity)) {
+ buffer->_status = LDNS_STATUS_MEM_ERR;
+ return false;
+ }
+ }
+ buffer->_limit = buffer->_capacity;
+ return true;
+}
+
+int
+ldns_buffer_printf(ldns_buffer *buffer, const char *format, ...)
+{
+ va_list args;
+ int written = 0;
+ size_t remaining;
+
+ if (ldns_buffer_status_ok(buffer)) {
+ ldns_buffer_invariant(buffer);
+ assert(buffer->_limit == buffer->_capacity);
+
+ remaining = ldns_buffer_remaining(buffer);
+ va_start(args, format);
+ written = vsnprintf((char *) ldns_buffer_current(buffer), remaining,
+ format, args);
+ va_end(args);
+ if (written == -1) {
+ buffer->_status = LDNS_STATUS_INTERNAL_ERR;
+ return -1;
+ } else if ((size_t) written >= remaining) {
+ if (!ldns_buffer_reserve(buffer, (size_t) written + 1)) {
+ buffer->_status = LDNS_STATUS_MEM_ERR;
+ return -1;
+ }
+ va_start(args, format);
+ written = vsnprintf((char *) ldns_buffer_current(buffer),
+ ldns_buffer_remaining(buffer), format, args);
+ va_end(args);
+ if (written == -1) {
+ buffer->_status = LDNS_STATUS_INTERNAL_ERR;
+ return -1;
+ }
+ }
+ buffer->_position += written;
+ }
+ return written;
+}
+
+void
+ldns_buffer_free(ldns_buffer *buffer)
+{
+ if (!buffer) {
+ return;
+ }
+
+ LDNS_FREE(buffer->_data);
+
+ LDNS_FREE(buffer);
+}
+
+void *
+ldns_buffer_export(ldns_buffer *buffer)
+{
+ buffer->_fixed = 1;
+ return buffer->_data;
+}
+
+int
+ldns_bgetc(ldns_buffer *buffer)
+{
+ if (!ldns_buffer_available_at(buffer, buffer->_position, sizeof(uint8_t))) {
+ ldns_buffer_set_position(buffer, ldns_buffer_limit(buffer));
+ /* ldns_buffer_rewind(buffer);*/
+ return EOF;
+ }
+ return (int)ldns_buffer_read_u8(buffer);
+}
+
+void
+ldns_buffer_copy(ldns_buffer* result, ldns_buffer* from)
+{
+ size_t tocopy = ldns_buffer_limit(from);
+
+ if(tocopy > ldns_buffer_capacity(result))
+ tocopy = ldns_buffer_capacity(result);
+ ldns_buffer_clear(result);
+ ldns_buffer_write(result, ldns_buffer_begin(from), tocopy);
+ ldns_buffer_flip(result);
+}
diff --git a/libs/ldns/compat/b32_ntop.c b/libs/ldns/compat/b32_ntop.c
new file mode 100644
index 0000000000..f6fa95c58c
--- /dev/null
+++ b/libs/ldns/compat/b32_ntop.c
@@ -0,0 +1,335 @@
+/*
+ * Copyright (c) 1996, 1998 by Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+/*
+ * Portions Copyright (c) 1995 by International Business Machines, Inc.
+ *
+ * International Business Machines, Inc. (hereinafter called IBM) grants
+ * permission under its copyrights to use, copy, modify, and distribute this
+ * Software with or without fee, provided that the above copyright notice and
+ * all paragraphs of this notice appear in all copies, and that the name of IBM
+ * not be used in connection with the marketing of any product incorporating
+ * the Software or modifications thereof, without specific, written prior
+ * permission.
+ *
+ * To the extent it has a right to do so, IBM grants an immunity from suit
+ * under its patents, if any, for the use, sale or manufacture of products to
+ * the extent that such products are used for performing Domain Name System
+ * dynamic updates in TCP/IP networks by means of the Software. No immunity is
+ * granted for any product per se or for any other function of any product.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL,
+ * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN
+ * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+#include
+
+#include
+#ifndef _MSC_VER
+#include
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include
+#endif
+
+#ifdef HAVE_NETINET_IN_H
+#include
+#endif
+#ifdef HAVE_ARPA_INET_H
+#include
+#endif
+
+#include
+#include
+#include
+#include
+
+#include
+
+static const char Base32[] =
+ "abcdefghijklmnopqrstuvwxyz234567";
+/* "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";*/
+/* 00000000001111111111222222222233
+ 01234567890123456789012345678901*/
+static const char Base32_extended_hex[] =
+/* "0123456789ABCDEFGHIJKLMNOPQRSTUV";*/
+ "0123456789abcdefghijklmnopqrstuv";
+static const char Pad32 = '=';
+
+/* (From RFC3548 and draft-josefsson-rfc3548bis-00.txt)
+5. Base 32 Encoding
+
+ The Base 32 encoding is designed to represent arbitrary sequences of
+ octets in a form that needs to be case insensitive but need not be
+ humanly readable.
+
+ A 33-character subset of US-ASCII is used, enabling 5 bits to be
+ represented per printable character. (The extra 33rd character, "=",
+ is used to signify a special processing function.)
+
+ The encoding process represents 40-bit groups of input bits as output
+ strings of 8 encoded characters. Proceeding from left to right, a
+ 40-bit input group is formed by concatenating 5 8bit input groups.
+ These 40 bits are then treated as 8 concatenated 5-bit groups, each
+ of which is translated into a single digit in the base 32 alphabet.
+ When encoding a bit stream via the base 32 encoding, the bit stream
+ must be presumed to be ordered with the most-significant-bit first.
+ That is, the first bit in the stream will be the high-order bit in
+ the first 8bit byte, and the eighth bit will be the low-order bit in
+ the first 8bit byte, and so on.
+
+ Each 5-bit group is used as an index into an array of 32 printable
+ characters. The character referenced by the index is placed in the
+ output string. These characters, identified in Table 3, below, are
+ selected from US-ASCII digits and uppercase letters.
+
+ Table 3: The Base 32 Alphabet
+
+ Value Encoding Value Encoding Value Encoding Value Encoding
+ 0 A 9 J 18 S 27 3
+ 1 B 10 K 19 T 28 4
+ 2 C 11 L 20 U 29 5
+ 3 D 12 M 21 V 30 6
+ 4 E 13 N 22 W 31 7
+ 5 F 14 O 23 X
+ 6 G 15 P 24 Y (pad) =
+ 7 H 16 Q 25 Z
+ 8 I 17 R 26 2
+
+
+ Special processing is performed if fewer than 40 bits are available
+ at the end of the data being encoded. A full encoding quantum is
+ always completed at the end of a body. When fewer than 40 input bits
+ are available in an input group, zero bits are added (on the right)
+ to form an integral number of 5-bit groups. Padding at the end of
+ the data is performed using the "=" character. Since all base 32
+ input is an integral number of octets, only the following cases can
+ arise:
+
+ (1) the final quantum of encoding input is an integral multiple of 40
+ bits; here, the final unit of encoded output will be an integral
+ multiple of 8 characters with no "=" padding,
+
+ (2) the final quantum of encoding input is exactly 8 bits; here, the
+ final unit of encoded output will be two characters followed by six
+ "=" padding characters,
+
+ (3) the final quantum of encoding input is exactly 16 bits; here, the
+ final unit of encoded output will be four characters followed by four
+ "=" padding characters,
+
+ (4) the final quantum of encoding input is exactly 24 bits; here, the
+ final unit of encoded output will be five characters followed by
+ three "=" padding characters, or
+
+ (5) the final quantum of encoding input is exactly 32 bits; here, the
+ final unit of encoded output will be seven characters followed by one
+ "=" padding character.
+
+
+6. Base 32 Encoding with Extended Hex Alphabet
+
+ The following description of base 32 is due to [7]. This encoding
+ should not be regarded as the same as the "base32" encoding, and
+ should not be referred to as only "base32".
+
+ One property with this alphabet, that the base64 and base32 alphabet
+ lack, is that encoded data maintain its sort order when the encoded
+ data is compared bit-wise.
+
+ This encoding is identical to the previous one, except for the
+ alphabet. The new alphabet is found in table 4.
+
+ Table 4: The "Extended Hex" Base 32 Alphabet
+
+ Value Encoding Value Encoding Value Encoding Value Encoding
+ 0 0 9 9 18 I 27 R
+ 1 1 10 A 19 J 28 S
+ 2 2 11 B 20 K 29 T
+ 3 3 12 C 21 L 30 U
+ 4 4 13 D 22 M 31 V
+ 5 5 14 E 23 N
+ 6 6 15 F 24 O (pad) =
+ 7 7 16 G 25 P
+ 8 8 17 H 26 Q
+
+*/
+
+
+int
+ldns_b32_ntop_ar(uint8_t const *src, size_t srclength, char *target, size_t targsize, const char B32_ar[]) {
+ size_t datalength = 0;
+ uint8_t input[5];
+ uint8_t output[8];
+ size_t i;
+ memset(output, 0, 8);
+
+ while (4 < srclength) {
+ input[0] = *src++;
+ input[1] = *src++;
+ input[2] = *src++;
+ input[3] = *src++;
+ input[4] = *src++;
+ srclength -= 5;
+
+ output[0] = (input[0] & 0xf8) >> 3;
+ output[1] = ((input[0] & 0x07) << 2) + ((input[1] & 0xc0) >> 6);
+ output[2] = (input[1] & 0x3e) >> 1;
+ output[3] = ((input[1] & 0x01) << 4) + ((input[2] & 0xf0) >> 4);
+ output[4] = ((input[2] & 0x0f) << 1) + ((input[3] & 0x80) >> 7);
+ output[5] = (input[3] & 0x7c) >> 2;
+ output[6] = ((input[3] & 0x03) << 3) + ((input[4] & 0xe0) >> 5);
+ output[7] = (input[4] & 0x1f);
+
+ assert(output[0] < 32);
+ assert(output[1] < 32);
+ assert(output[2] < 32);
+ assert(output[3] < 32);
+ assert(output[4] < 32);
+ assert(output[5] < 32);
+ assert(output[6] < 32);
+ assert(output[7] < 32);
+
+ if (datalength + 8 > targsize) {
+ return (-1);
+ }
+ target[datalength++] = B32_ar[output[0]];
+ target[datalength++] = B32_ar[output[1]];
+ target[datalength++] = B32_ar[output[2]];
+ target[datalength++] = B32_ar[output[3]];
+ target[datalength++] = B32_ar[output[4]];
+ target[datalength++] = B32_ar[output[5]];
+ target[datalength++] = B32_ar[output[6]];
+ target[datalength++] = B32_ar[output[7]];
+ }
+
+ /* Now we worry about padding. */
+ if (0 != srclength) {
+ /* Get what's left. */
+ input[0] = input[1] = input[2] = input[3] = input[4] = (uint8_t) '\0';
+ for (i = 0; i < srclength; i++)
+ input[i] = *src++;
+
+ output[0] = (input[0] & 0xf8) >> 3;
+ assert(output[0] < 32);
+ if (srclength >= 1) {
+ output[1] = ((input[0] & 0x07) << 2) + ((input[1] & 0xc0) >> 6);
+ assert(output[1] < 32);
+ output[2] = (input[1] & 0x3e) >> 1;
+ assert(output[2] < 32);
+ }
+ if (srclength >= 2) {
+ output[3] = ((input[1] & 0x01) << 4) + ((input[2] & 0xf0) >> 4);
+ assert(output[3] < 32);
+ }
+ if (srclength >= 3) {
+ output[4] = ((input[2] & 0x0f) << 1) + ((input[3] & 0x80) >> 7);
+ assert(output[4] < 32);
+ output[5] = (input[3] & 0x7c) >> 2;
+ assert(output[5] < 32);
+ }
+ if (srclength >= 4) {
+ output[6] = ((input[3] & 0x03) << 3) + ((input[4] & 0xe0) >> 5);
+ assert(output[6] < 32);
+ }
+
+
+ if (datalength + 1 > targsize) {
+ return (-2);
+ }
+ target[datalength++] = B32_ar[output[0]];
+ if (srclength >= 1) {
+ if (datalength + 1 > targsize) { return (-2); }
+ target[datalength++] = B32_ar[output[1]];
+ if (srclength == 1 && output[2] == 0) {
+ if (datalength + 1 > targsize) { return (-2); }
+ target[datalength++] = Pad32;
+ } else {
+ if (datalength + 1 > targsize) { return (-2); }
+ target[datalength++] = B32_ar[output[2]];
+ }
+ } else {
+ if (datalength + 1 > targsize) { return (-2); }
+ target[datalength++] = Pad32;
+ if (datalength + 1 > targsize) { return (-2); }
+ target[datalength++] = Pad32;
+ }
+ if (srclength >= 2) {
+ if (datalength + 1 > targsize) { return (-2); }
+ target[datalength++] = B32_ar[output[3]];
+ } else {
+ if (datalength + 1 > targsize) { return (-2); }
+ target[datalength++] = Pad32;
+ }
+ if (srclength >= 3) {
+ if (datalength + 1 > targsize) { return (-2); }
+ target[datalength++] = B32_ar[output[4]];
+ if (srclength == 3 && output[5] == 0) {
+ if (datalength + 1 > targsize) { return (-2); }
+ target[datalength++] = Pad32;
+ } else {
+ if (datalength + 1 > targsize) { return (-2); }
+ target[datalength++] = B32_ar[output[5]];
+ }
+ } else {
+ if (datalength + 1 > targsize) { return (-2); }
+ target[datalength++] = Pad32;
+ if (datalength + 1 > targsize) { return (-2); }
+ target[datalength++] = Pad32;
+ }
+ if (srclength >= 4) {
+ if (datalength + 1 > targsize) { return (-2); }
+ target[datalength++] = B32_ar[output[6]];
+ } else {
+ if (datalength + 1 > targsize) { return (-2); }
+ target[datalength++] = Pad32;
+ }
+ if (datalength + 1 > targsize) { return (-2); }
+ target[datalength++] = Pad32;
+ }
+ if (datalength+1 > targsize) {
+ return (int) (datalength);
+ }
+ target[datalength] = '\0'; /* Returned value doesn't count \0. */
+ return (int) (datalength);
+}
+
+int
+ldns_b32_ntop(uint8_t const *src, size_t srclength, char *target, size_t targsize) {
+ return ldns_b32_ntop_ar(src, srclength, target, targsize, Base32);
+}
+
+/* deprecated, here for backwards compatibility */
+int
+b32_ntop(uint8_t const *src, size_t srclength, char *target, size_t targsize) {
+ return ldns_b32_ntop_ar(src, srclength, target, targsize, Base32);
+}
+
+int
+ldns_b32_ntop_extended_hex(uint8_t const *src, size_t srclength, char *target, size_t targsize) {
+ return ldns_b32_ntop_ar(src, srclength, target, targsize, Base32_extended_hex);
+}
+
+/* deprecated, here for backwards compatibility */
+int
+b32_ntop_extended_hex(uint8_t const *src, size_t srclength, char *target, size_t targsize) {
+ return ldns_b32_ntop_ar(src, srclength, target, targsize, Base32_extended_hex);
+}
+
diff --git a/libs/ldns/compat/b32_pton.c b/libs/ldns/compat/b32_pton.c
new file mode 100644
index 0000000000..766f5fa4b4
--- /dev/null
+++ b/libs/ldns/compat/b32_pton.c
@@ -0,0 +1,389 @@
+/*
+ * Copyright (c) 1996, 1998 by Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+/*
+ * Portions Copyright (c) 1995 by International Business Machines, Inc.
+ *
+ * International Business Machines, Inc. (hereinafter called IBM) grants
+ * permission under its copyrights to use, copy, modify, and distribute this
+ * Software with or without fee, provided that the above copyright notice and
+ * all paragraphs of this notice appear in all copies, and that the name of IBM
+ * not be used in connection with the marketing of any product incorporating
+ * the Software or modifications thereof, without specific, written prior
+ * permission.
+ *
+ * To the extent it has a right to do so, IBM grants an immunity from suit
+ * under its patents, if any, for the use, sale or manufacture of products to
+ * the extent that such products are used for performing Domain Name System
+ * dynamic updates in TCP/IP networks by means of the Software. No immunity is
+ * granted for any product per se or for any other function of any product.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL,
+ * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN
+ * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+#include
+
+#include
+#ifndef _MSC_VER
+#include
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include
+#endif
+
+#ifdef HAVE_NETINET_IN_H
+#include
+#endif
+#ifdef HAVE_ARPA_INET_H
+#include
+#endif
+
+#include
+#include
+#include
+#include
+
+/* "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";*/
+static const char Base32[] =
+ "abcdefghijklmnopqrstuvwxyz234567";
+/* "0123456789ABCDEFGHIJKLMNOPQRSTUV";*/
+static const char Base32_extended_hex[] =
+ "0123456789abcdefghijklmnopqrstuv";
+static const char Pad32 = '=';
+
+/* (From RFC1521 and draft-ietf-dnssec-secext-03.txt)
+5. Base 32 Encoding
+
+ The Base 32 encoding is designed to represent arbitrary sequences of
+ octets in a form that needs to be case insensitive but need not be
+ humanly readable.
+
+ A 33-character subset of US-ASCII is used, enabling 5 bits to be
+ represented per printable character. (The extra 33rd character, "=",
+ is used to signify a special processing function.)
+
+ The encoding process represents 40-bit groups of input bits as output
+ strings of 8 encoded characters. Proceeding from left to right, a
+ 40-bit input group is formed by concatenating 5 8bit input groups.
+ These 40 bits are then treated as 8 concatenated 5-bit groups, each
+ of which is translated into a single digit in the base 32 alphabet.
+ When encoding a bit stream via the base 32 encoding, the bit stream
+ must be presumed to be ordered with the most-significant-bit first.
+ That is, the first bit in the stream will be the high-order bit in
+ the first 8bit byte, and the eighth bit will be the low-order bit in
+ the first 8bit byte, and so on.
+
+ Each 5-bit group is used as an index into an array of 32 printable
+ characters. The character referenced by the index is placed in the
+ output string. These characters, identified in Table 3, below, are
+ selected from US-ASCII digits and uppercase letters.
+
+ Table 3: The Base 32 Alphabet
+
+ Value Encoding Value Encoding Value Encoding Value Encoding
+ 0 A 9 J 18 S 27 3
+ 1 B 10 K 19 T 28 4
+ 2 C 11 L 20 U 29 5
+ 3 D 12 M 21 V 30 6
+ 4 E 13 N 22 W 31 7
+ 5 F 14 O 23 X
+ 6 G 15 P 24 Y (pad) =
+ 7 H 16 Q 25 Z
+ 8 I 17 R 26 2
+
+
+ Special processing is performed if fewer than 40 bits are available
+ at the end of the data being encoded. A full encoding quantum is
+ always completed at the end of a body. When fewer than 40 input bits
+ are available in an input group, zero bits are added (on the right)
+ to form an integral number of 5-bit groups. Padding at the end of
+ the data is performed using the "=" character. Since all base 32
+ input is an integral number of octets, only the following cases can
+ arise:
+
+ (1) the final quantum of encoding input is an integral multiple of 40
+ bits; here, the final unit of encoded output will be an integral
+ multiple of 8 characters with no "=" padding,
+
+ (2) the final quantum of encoding input is exactly 8 bits; here, the
+ final unit of encoded output will be two characters followed by six
+ "=" padding characters,
+
+ (3) the final quantum of encoding input is exactly 16 bits; here, the
+ final unit of encoded output will be four characters followed by four
+ "=" padding characters,
+
+ (4) the final quantum of encoding input is exactly 24 bits; here, the
+ final unit of encoded output will be five characters followed by
+ three "=" padding characters, or
+
+ (5) the final quantum of encoding input is exactly 32 bits; here, the
+ final unit of encoded output will be seven characters followed by one
+ "=" padding character.
+
+
+6. Base 32 Encoding with Extended Hex Alphabet
+
+ The following description of base 32 is due to [7]. This encoding
+ should not be regarded as the same as the "base32" encoding, and
+ should not be referred to as only "base32".
+
+ One property with this alphabet, that the base32 and base32 alphabet
+ lack, is that encoded data maintain its sort order when the encoded
+ data is compared bit-wise.
+
+ This encoding is identical to the previous one, except for the
+ alphabet. The new alphabet is found in table 4.
+
+ Table 4: The "Extended Hex" Base 32 Alphabet
+
+ Value Encoding Value Encoding Value Encoding Value Encoding
+ 0 0 9 9 18 I 27 R
+ 1 1 10 A 19 J 28 S
+ 2 2 11 B 20 K 29 T
+ 3 3 12 C 21 L 30 U
+ 4 4 13 D 22 M 31 V
+ 5 5 14 E 23 N
+ 6 6 15 F 24 O (pad) =
+ 7 7 16 G 25 P
+ 8 8 17 H 26 Q
+
+
+
+
+*/
+/* skips all whitespace anywhere.
+ converts characters, four at a time, starting at (or after)
+ src from base - 32 numbers into three 8 bit bytes in the target area.
+ it returns the number of data bytes stored at the target, or -1 on error.
+ */
+
+int
+ldns_b32_pton_ar(char const *src, size_t hashed_owner_str_len, uint8_t *target, size_t targsize, const char B32_ar[])
+{
+ int tarindex, state, ch;
+ char *pos;
+ int i = 0;
+
+ state = 0;
+ tarindex = 0;
+
+ while ((ch = *src++) != '\0' && (i == 0 || i < (int) hashed_owner_str_len)) {
+ i++;
+ ch = tolower(ch);
+ if (isspace((unsigned char)ch)) /* Skip whitespace anywhere. */
+ continue;
+
+ if (ch == Pad32)
+ break;
+
+ pos = strchr(B32_ar, ch);
+ if (pos == 0) {
+ /* A non-base32 character. */
+ return (-ch);
+ }
+
+ switch (state) {
+ case 0:
+ if (target) {
+ if ((size_t)tarindex >= targsize) {
+ return (-2);
+ }
+ target[tarindex] = (pos - B32_ar) << 3;
+ }
+ state = 1;
+ break;
+ case 1:
+ if (target) {
+ if ((size_t)tarindex + 1 >= targsize) {
+ return (-3);
+ }
+ target[tarindex] |= (pos - B32_ar) >> 2;
+ target[tarindex+1] = ((pos - B32_ar) & 0x03)
+ << 6 ;
+ }
+ tarindex++;
+ state = 2;
+ break;
+ case 2:
+ if (target) {
+ if ((size_t)tarindex + 1 >= targsize) {
+ return (-4);
+ }
+ target[tarindex] |= (pos - B32_ar) << 1;
+ }
+ /*tarindex++;*/
+ state = 3;
+ break;
+ case 3:
+ if (target) {
+ if ((size_t)tarindex + 1 >= targsize) {
+ return (-5);
+ }
+ target[tarindex] |= (pos - B32_ar) >> 4;
+ target[tarindex+1] = ((pos - B32_ar) & 0x0f) << 4 ;
+ }
+ tarindex++;
+ state = 4;
+ break;
+ case 4:
+ if (target) {
+ if ((size_t)tarindex + 1 >= targsize) {
+ return (-6);
+ }
+ target[tarindex] |= (pos - B32_ar) >> 1;
+ target[tarindex+1] = ((pos - B32_ar) & 0x01)
+ << 7 ;
+ }
+ tarindex++;
+ state = 5;
+ break;
+ case 5:
+ if (target) {
+ if ((size_t)tarindex + 1 >= targsize) {
+ return (-7);
+ }
+ target[tarindex] |= (pos - B32_ar) << 2;
+ }
+ state = 6;
+ break;
+ case 6:
+ if (target) {
+ if ((size_t)tarindex + 1 >= targsize) {
+ return (-8);
+ }
+ target[tarindex] |= (pos - B32_ar) >> 3;
+ target[tarindex+1] = ((pos - B32_ar) & 0x07)
+ << 5 ;
+ }
+ tarindex++;
+ state = 7;
+ break;
+ case 7:
+ if (target) {
+ if ((size_t)tarindex + 1 >= targsize) {
+ return (-9);
+ }
+ target[tarindex] |= (pos - B32_ar);
+ }
+ tarindex++;
+ state = 0;
+ break;
+ default:
+ abort();
+ }
+ }
+
+ /*
+ * We are done decoding Base-32 chars. Let's see if we ended
+ * on a byte boundary, and/or with erroneous trailing characters.
+ */
+
+ if (ch == Pad32) { /* We got a pad char. */
+ ch = *src++; /* Skip it, get next. */
+ switch (state) {
+ case 0: /* Invalid = in first position */
+ case 1: /* Invalid = in second position */
+ return (-10);
+
+ case 2: /* Valid, means one byte of info */
+ case 3:
+ /* Skip any number of spaces. */
+ for ((void)NULL; ch != '\0'; ch = *src++)
+ if (!isspace((unsigned char)ch))
+ break;
+ /* Make sure there is another trailing = sign. */
+ if (ch != Pad32) {
+ return (-11);
+ }
+ ch = *src++; /* Skip the = */
+ /* Fall through to "single trailing =" case. */
+ /* FALLTHROUGH */
+
+ case 4: /* Valid, means two bytes of info */
+ case 5:
+ case 6:
+ /*
+ * We know this char is an =. Is there anything but
+ * whitespace after it?
+ */
+ for ((void)NULL; ch != '\0'; ch = *src++)
+ if (!(isspace((unsigned char)ch) || ch == '=')) {
+ return (-12);
+ }
+
+ case 7: /* Valid, means three bytes of info */
+ /*
+ * We know this char is an =. Is there anything but
+ * whitespace after it?
+ */
+ for ((void)NULL; ch != '\0'; ch = *src++)
+ if (!isspace((unsigned char)ch)) {
+ return (-13);
+ }
+
+ /*
+ * Now make sure for cases 2 and 3 that the "extra"
+ * bits that slopped past the last full byte were
+ * zeros. If we don't check them, they become a
+ * subliminal channel.
+ */
+ if (target && target[tarindex] != 0) {
+ return (-14);
+ }
+ }
+ } else {
+ /*
+ * We ended by seeing the end of the string. Make sure we
+ * have no partial bytes lying around.
+ */
+ if (state != 0)
+ return (-15);
+ }
+
+ return (tarindex);
+}
+
+int
+ldns_b32_pton(char const *src, size_t hashed_owner_str_len, uint8_t *target, size_t targsize)
+{
+ return ldns_b32_pton_ar(src, hashed_owner_str_len, target, targsize, Base32);
+}
+
+/* deprecated, here for backwards compatibility */
+int
+b32_pton(char const *src, size_t hashed_owner_str_len, uint8_t *target, size_t targsize)
+{
+ return ldns_b32_pton_ar(src, hashed_owner_str_len, target, targsize, Base32);
+}
+
+int
+ldns_b32_pton_extended_hex(char const *src, size_t hashed_owner_str_len, uint8_t *target, size_t targsize)
+{
+ return ldns_b32_pton_ar(src, hashed_owner_str_len, target, targsize, Base32_extended_hex);
+}
+
+/* deprecated, here for backwards compatibility */
+int
+b32_pton_extended_hex(char const *src, size_t hashed_owner_str_len, uint8_t *target, size_t targsize)
+{
+ return ldns_b32_pton_ar(src, hashed_owner_str_len, target, targsize, Base32_extended_hex);
+}
diff --git a/libs/ldns/compat/b64_ntop.c b/libs/ldns/compat/b64_ntop.c
new file mode 100644
index 0000000000..c9f605e901
--- /dev/null
+++ b/libs/ldns/compat/b64_ntop.c
@@ -0,0 +1,204 @@
+/*
+ * Copyright (c) 1996, 1998 by Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+/*
+ * Portions Copyright (c) 1995 by International Business Machines, Inc.
+ *
+ * International Business Machines, Inc. (hereinafter called IBM) grants
+ * permission under its copyrights to use, copy, modify, and distribute this
+ * Software with or without fee, provided that the above copyright notice and
+ * all paragraphs of this notice appear in all copies, and that the name of IBM
+ * not be used in connection with the marketing of any product incorporating
+ * the Software or modifications thereof, without specific, written prior
+ * permission.
+ *
+ * To the extent it has a right to do so, IBM grants an immunity from suit
+ * under its patents, if any, for the use, sale or manufacture of products to
+ * the extent that such products are used for performing Domain Name System
+ * dynamic updates in TCP/IP networks by means of the Software. No immunity is
+ * granted for any product per se or for any other function of any product.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL,
+ * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN
+ * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+#include
+
+#include
+#ifndef _MSC_VER
+#include
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include
+#endif
+
+#ifdef HAVE_NETINET_IN_H
+#include
+#endif
+#ifdef HAVE_ARPA_INET_H
+#include
+#endif
+
+#include
+#include
+#include
+#include
+
+#define Assert(Cond) if (!(Cond)) abort()
+
+static const char Base64[] =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+static const char Pad64 = '=';
+
+/* (From RFC1521 and draft-ietf-dnssec-secext-03.txt)
+ The following encoding technique is taken from RFC 1521 by Borenstein
+ and Freed. It is reproduced here in a slightly edited form for
+ convenience.
+
+ A 65-character subset of US-ASCII is used, enabling 6 bits to be
+ represented per printable character. (The extra 65th character, "=",
+ is used to signify a special processing function.)
+
+ The encoding process represents 24-bit groups of input bits as output
+ strings of 4 encoded characters. Proceeding from left to right, a
+ 24-bit input group is formed by concatenating 3 8-bit input groups.
+ These 24 bits are then treated as 4 concatenated 6-bit groups, each
+ of which is translated into a single digit in the base64 alphabet.
+
+ Each 6-bit group is used as an index into an array of 64 printable
+ characters. The character referenced by the index is placed in the
+ output string.
+
+ Table 1: The Base64 Alphabet
+
+ Value Encoding Value Encoding Value Encoding Value Encoding
+ 0 A 17 R 34 i 51 z
+ 1 B 18 S 35 j 52 0
+ 2 C 19 T 36 k 53 1
+ 3 D 20 U 37 l 54 2
+ 4 E 21 V 38 m 55 3
+ 5 F 22 W 39 n 56 4
+ 6 G 23 X 40 o 57 5
+ 7 H 24 Y 41 p 58 6
+ 8 I 25 Z 42 q 59 7
+ 9 J 26 a 43 r 60 8
+ 10 K 27 b 44 s 61 9
+ 11 L 28 c 45 t 62 +
+ 12 M 29 d 46 u 63 /
+ 13 N 30 e 47 v
+ 14 O 31 f 48 w (pad) =
+ 15 P 32 g 49 x
+ 16 Q 33 h 50 y
+
+ Special processing is performed if fewer than 24 bits are available
+ at the end of the data being encoded. A full encoding quantum is
+ always completed at the end of a quantity. When fewer than 24 input
+ bits are available in an input group, zero bits are added (on the
+ right) to form an integral number of 6-bit groups. Padding at the
+ end of the data is performed using the '=' character.
+
+ Since all base64 input is an integral number of octets, only the
+ -------------------------------------------------
+ following cases can arise:
+
+ (1) the final quantum of encoding input is an integral
+ multiple of 24 bits; here, the final unit of encoded
+ output will be an integral multiple of 4 characters
+ with no "=" padding,
+ (2) the final quantum of encoding input is exactly 8 bits;
+ here, the final unit of encoded output will be two
+ characters followed by two "=" padding characters, or
+ (3) the final quantum of encoding input is exactly 16 bits;
+ here, the final unit of encoded output will be three
+ characters followed by one "=" padding character.
+ */
+
+int
+ldns_b64_ntop(uint8_t const *src, size_t srclength, char *target, size_t targsize) {
+ size_t datalength = 0;
+ uint8_t input[3];
+ uint8_t output[4];
+ size_t i;
+
+ if (srclength == 0) {
+ if (targsize > 0) {
+ target[0] = '\0';
+ return 0;
+ } else {
+ return -1;
+ }
+ }
+
+ while (2 < srclength) {
+ input[0] = *src++;
+ input[1] = *src++;
+ input[2] = *src++;
+ srclength -= 3;
+
+ output[0] = input[0] >> 2;
+ output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
+ output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
+ output[3] = input[2] & 0x3f;
+ Assert(output[0] < 64);
+ Assert(output[1] < 64);
+ Assert(output[2] < 64);
+ Assert(output[3] < 64);
+
+ if (datalength + 4 > targsize) {
+ return (-1);
+ }
+ target[datalength++] = Base64[output[0]];
+ target[datalength++] = Base64[output[1]];
+ target[datalength++] = Base64[output[2]];
+ target[datalength++] = Base64[output[3]];
+ }
+
+ /* Now we worry about padding. */
+ if (0 != srclength) {
+ /* Get what's left. */
+ input[0] = input[1] = input[2] = (uint8_t) '\0';
+ for (i = 0; i < srclength; i++)
+ input[i] = *src++;
+
+ output[0] = input[0] >> 2;
+ output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
+ output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
+ Assert(output[0] < 64);
+ Assert(output[1] < 64);
+ Assert(output[2] < 64);
+
+ if (datalength + 4 > targsize) {
+ return (-2);
+ }
+ target[datalength++] = Base64[output[0]];
+ target[datalength++] = Base64[output[1]];
+ if (srclength == 1) {
+ target[datalength++] = Pad64;
+ } else {
+ target[datalength++] = Base64[output[2]];
+ }
+ target[datalength++] = Pad64;
+ }
+ if (datalength >= targsize) {
+ return (-3);
+ }
+ target[datalength] = '\0'; /* Returned value doesn't count \0. */
+ return (int) (datalength);
+}
diff --git a/libs/ldns/compat/b64_pton.c b/libs/ldns/compat/b64_pton.c
new file mode 100644
index 0000000000..98fdddb6d3
--- /dev/null
+++ b/libs/ldns/compat/b64_pton.c
@@ -0,0 +1,262 @@
+/*
+ * Copyright (c) 1996, 1998 by Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+/*
+ * Portions Copyright (c) 1995 by International Business Machines, Inc.
+ *
+ * International Business Machines, Inc. (hereinafter called IBM) grants
+ * permission under its copyrights to use, copy, modify, and distribute this
+ * Software with or without fee, provided that the above copyright notice and
+ * all paragraphs of this notice appear in all copies, and that the name of IBM
+ * not be used in connection with the marketing of any product incorporating
+ * the Software or modifications thereof, without specific, written prior
+ * permission.
+ *
+ * To the extent it has a right to do so, IBM grants an immunity from suit
+ * under its patents, if any, for the use, sale or manufacture of products to
+ * the extent that such products are used for performing Domain Name System
+ * dynamic updates in TCP/IP networks by means of the Software. No immunity is
+ * granted for any product per se or for any other function of any product.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL,
+ * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN
+ * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+#include
+
+#include
+#ifndef _MSC_VER
+#include
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include
+#endif
+
+#ifdef HAVE_NETINET_IN_H
+#include
+#endif
+#ifdef HAVE_ARPA_INET_H
+#include
+#endif
+
+#include
+#include
+#include
+#include
+
+#define Assert(Cond) if (!(Cond)) abort()
+
+static const char Base64[] =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+static const char Pad64 = '=';
+
+/* (From RFC1521 and draft-ietf-dnssec-secext-03.txt)
+ The following encoding technique is taken from RFC 1521 by Borenstein
+ and Freed. It is reproduced here in a slightly edited form for
+ convenience.
+
+ A 65-character subset of US-ASCII is used, enabling 6 bits to be
+ represented per printable character. (The extra 65th character, "=",
+ is used to signify a special processing function.)
+
+ The encoding process represents 24-bit groups of input bits as output
+ strings of 4 encoded characters. Proceeding from left to right, a
+ 24-bit input group is formed by concatenating 3 8-bit input groups.
+ These 24 bits are then treated as 4 concatenated 6-bit groups, each
+ of which is translated into a single digit in the base64 alphabet.
+
+ Each 6-bit group is used as an index into an array of 64 printable
+ characters. The character referenced by the index is placed in the
+ output string.
+
+ Table 1: The Base64 Alphabet
+
+ Value Encoding Value Encoding Value Encoding Value Encoding
+ 0 A 17 R 34 i 51 z
+ 1 B 18 S 35 j 52 0
+ 2 C 19 T 36 k 53 1
+ 3 D 20 U 37 l 54 2
+ 4 E 21 V 38 m 55 3
+ 5 F 22 W 39 n 56 4
+ 6 G 23 X 40 o 57 5
+ 7 H 24 Y 41 p 58 6
+ 8 I 25 Z 42 q 59 7
+ 9 J 26 a 43 r 60 8
+ 10 K 27 b 44 s 61 9
+ 11 L 28 c 45 t 62 +
+ 12 M 29 d 46 u 63 /
+ 13 N 30 e 47 v
+ 14 O 31 f 48 w (pad) =
+ 15 P 32 g 49 x
+ 16 Q 33 h 50 y
+
+ Special processing is performed if fewer than 24 bits are available
+ at the end of the data being encoded. A full encoding quantum is
+ always completed at the end of a quantity. When fewer than 24 input
+ bits are available in an input group, zero bits are added (on the
+ right) to form an integral number of 6-bit groups. Padding at the
+ end of the data is performed using the '=' character.
+
+ Since all base64 input is an integral number of octets, only the
+ -------------------------------------------------
+ following cases can arise:
+
+ (1) the final quantum of encoding input is an integral
+ multiple of 24 bits; here, the final unit of encoded
+ output will be an integral multiple of 4 characters
+ with no "=" padding,
+ (2) the final quantum of encoding input is exactly 8 bits;
+ here, the final unit of encoded output will be two
+ characters followed by two "=" padding characters, or
+ (3) the final quantum of encoding input is exactly 16 bits;
+ here, the final unit of encoded output will be three
+ characters followed by one "=" padding character.
+ */
+
+/* skips all whitespace anywhere.
+ converts characters, four at a time, starting at (or after)
+ src from base - 64 numbers into three 8 bit bytes in the target area.
+ it returns the number of data bytes stored at the target, or -1 on error.
+ */
+
+int
+ldns_b64_pton(char const *src, uint8_t *target, size_t targsize)
+{
+ int tarindex, state, ch;
+ char *pos;
+
+ state = 0;
+ tarindex = 0;
+
+ if (strlen(src) == 0) {
+ return 0;
+ }
+
+ while ((ch = *src++) != '\0') {
+ if (isspace((unsigned char)ch)) /* Skip whitespace anywhere. */
+ continue;
+
+ if (ch == Pad64)
+ break;
+
+ pos = strchr(Base64, ch);
+ if (pos == 0) {
+ /* A non-base64 character. */
+ return (-1);
+ }
+
+ switch (state) {
+ case 0:
+ if (target) {
+ if ((size_t)tarindex >= targsize)
+ return (-1);
+ target[tarindex] = (pos - Base64) << 2;
+ }
+ state = 1;
+ break;
+ case 1:
+ if (target) {
+ if ((size_t)tarindex + 1 >= targsize)
+ return (-1);
+ target[tarindex] |= (pos - Base64) >> 4;
+ target[tarindex+1] = ((pos - Base64) & 0x0f)
+ << 4 ;
+ }
+ tarindex++;
+ state = 2;
+ break;
+ case 2:
+ if (target) {
+ if ((size_t)tarindex + 1 >= targsize)
+ return (-1);
+ target[tarindex] |= (pos - Base64) >> 2;
+ target[tarindex+1] = ((pos - Base64) & 0x03)
+ << 6;
+ }
+ tarindex++;
+ state = 3;
+ break;
+ case 3:
+ if (target) {
+ if ((size_t)tarindex >= targsize)
+ return (-1);
+ target[tarindex] |= (pos - Base64);
+ }
+ tarindex++;
+ state = 0;
+ break;
+ default:
+ abort();
+ }
+ }
+
+ /*
+ * We are done decoding Base-64 chars. Let's see if we ended
+ * on a byte boundary, and/or with erroneous trailing characters.
+ */
+
+ if (ch == Pad64) { /* We got a pad char. */
+ ch = *src++; /* Skip it, get next. */
+ switch (state) {
+ case 0: /* Invalid = in first position */
+ case 1: /* Invalid = in second position */
+ return (-1);
+
+ case 2: /* Valid, means one byte of info */
+ /* Skip any number of spaces. */
+ for ((void)NULL; ch != '\0'; ch = *src++)
+ if (!isspace((unsigned char)ch))
+ break;
+ /* Make sure there is another trailing = sign. */
+ if (ch != Pad64)
+ return (-1);
+ ch = *src++; /* Skip the = */
+ /* Fall through to "single trailing =" case. */
+ /* FALLTHROUGH */
+
+ case 3: /* Valid, means two bytes of info */
+ /*
+ * We know this char is an =. Is there anything but
+ * whitespace after it?
+ */
+ for ((void)NULL; ch != '\0'; ch = *src++)
+ if (!isspace((unsigned char)ch))
+ return (-1);
+
+ /*
+ * Now make sure for cases 2 and 3 that the "extra"
+ * bits that slopped past the last full byte were
+ * zeros. If we don't check them, they become a
+ * subliminal channel.
+ */
+ if (target && target[tarindex] != 0)
+ return (-1);
+ }
+ } else {
+ /*
+ * We ended by seeing the end of the string. Make sure we
+ * have no partial bytes lying around.
+ */
+ if (state != 0)
+ return (-1);
+ }
+
+ return (tarindex);
+}
diff --git a/libs/ldns/compat/ctime_r.c b/libs/ldns/compat/ctime_r.c
new file mode 100644
index 0000000000..4ffd8b7e35
--- /dev/null
+++ b/libs/ldns/compat/ctime_r.c
@@ -0,0 +1,16 @@
+#ifdef HAVE_CONFIG_H
+#include
+#endif
+
+#ifdef HAVE_TIME_H
+#include
+#endif
+
+char *ctime_r(const time_t *timep, char *buf)
+{
+ /* no thread safety. */
+ char* result = ctime(timep);
+ if(buf && result)
+ strcpy(buf, result);
+ return result;
+}
diff --git a/libs/ldns/compat/fake-rfc2553.c b/libs/ldns/compat/fake-rfc2553.c
new file mode 100644
index 0000000000..28e8b4211f
--- /dev/null
+++ b/libs/ldns/compat/fake-rfc2553.c
@@ -0,0 +1,231 @@
+/* From openssh 4.3p2 filename openbsd-compat/fake-rfc2553.h */
+/*
+ * Copyright (C) 2000-2003 Damien Miller. All rights reserved.
+ * Copyright (C) 1999 WIDE Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Pseudo-implementation of RFC2553 name / address resolution functions
+ *
+ * But these functions are not implemented correctly. The minimum subset
+ * is implemented for ssh use only. For example, this routine assumes
+ * that ai_family is AF_INET. Don't use it for another purpose.
+ */
+
+#include
+#include
+#ifndef _MSC_VER
+#include
+#endif
+#include
+#include
+#include
+#include "compat/fake-rfc2553.h"
+
+#ifndef HAVE_GETNAMEINFO
+int getnameinfo(const struct sockaddr *sa, size_t ATTR_UNUSED(salen), char *host,
+ size_t hostlen, char *serv, size_t servlen, int flags)
+{
+ struct sockaddr_in *sin = (struct sockaddr_in *)sa;
+ struct hostent *hp;
+ char tmpserv[16];
+
+ if (serv != NULL) {
+ snprintf(tmpserv, sizeof(tmpserv), "%d", ntohs(sin->sin_port));
+ if (strlcpy(serv, tmpserv, servlen) >= servlen)
+ return (EAI_MEMORY);
+ }
+
+ if (host != NULL) {
+ if (flags & NI_NUMERICHOST) {
+ if (strlcpy(host, inet_ntoa(sin->sin_addr),
+ hostlen) >= hostlen)
+ return (EAI_MEMORY);
+ else
+ return (0);
+ } else {
+ hp = gethostbyaddr((char *)&sin->sin_addr,
+ sizeof(struct in_addr), AF_INET);
+ if (hp == NULL)
+ return (EAI_NODATA);
+
+ if (strlcpy(host, hp->h_name, hostlen) >= hostlen)
+ return (EAI_MEMORY);
+ else
+ return (0);
+ }
+ }
+ return (0);
+}
+#endif /* !HAVE_GETNAMEINFO */
+
+#ifndef HAVE_GAI_STRERROR
+#ifdef HAVE_CONST_GAI_STRERROR_PROTO
+const char *
+#else
+char *
+#endif
+gai_strerror(int err)
+{
+ switch (err) {
+ case EAI_NODATA:
+ return ("no address associated with name");
+ case EAI_MEMORY:
+ return ("memory allocation failure.");
+ case EAI_NONAME:
+ return ("nodename nor servname provided, or not known");
+ default:
+ return ("unknown/invalid error.");
+ }
+}
+#endif /* !HAVE_GAI_STRERROR */
+
+#ifndef HAVE_FREEADDRINFO
+void
+freeaddrinfo(struct addrinfo *ai)
+{
+ struct addrinfo *next;
+
+ for(; ai != NULL;) {
+ next = ai->ai_next;
+ free(ai);
+ ai = next;
+ }
+}
+#endif /* !HAVE_FREEADDRINFO */
+
+#ifndef HAVE_GETADDRINFO
+static struct
+addrinfo *malloc_ai(int port, u_long addr, const struct addrinfo *hints)
+{
+ struct addrinfo *ai;
+
+ ai = malloc(sizeof(*ai) + sizeof(struct sockaddr_in));
+ if (ai == NULL)
+ return (NULL);
+
+ memset(ai, '\0', sizeof(*ai) + sizeof(struct sockaddr_in));
+
+ ai->ai_addr = (struct sockaddr *)(ai + 1);
+ /* XXX -- ssh doesn't use sa_len */
+ ai->ai_addrlen = sizeof(struct sockaddr_in);
+ ai->ai_addr->sa_family = ai->ai_family = AF_INET;
+
+ ((struct sockaddr_in *)(ai)->ai_addr)->sin_port = port;
+ ((struct sockaddr_in *)(ai)->ai_addr)->sin_addr.s_addr = addr;
+
+ /* XXX: the following is not generally correct, but does what we want */
+ if (hints->ai_socktype)
+ ai->ai_socktype = hints->ai_socktype;
+ else
+ ai->ai_socktype = SOCK_STREAM;
+
+ if (hints->ai_protocol)
+ ai->ai_protocol = hints->ai_protocol;
+
+ return (ai);
+}
+
+int
+getaddrinfo(const char *hostname, const char *servname,
+ const struct addrinfo *hints, struct addrinfo **res)
+{
+ struct hostent *hp;
+ struct servent *sp;
+ struct in_addr in;
+ int i;
+ long int port;
+ u_long addr;
+
+ port = 0;
+ if (servname != NULL) {
+ char *cp;
+
+ port = strtol(servname, &cp, 10);
+ if (port > 0 && port <= 65535 && *cp == '\0')
+ port = htons(port);
+ else if ((sp = getservbyname(servname, NULL)) != NULL)
+ port = sp->s_port;
+ else
+ port = 0;
+ }
+
+ if (hints && hints->ai_flags & AI_PASSIVE) {
+ addr = htonl(0x00000000);
+ if (hostname && inet_aton(hostname, &in) != 0)
+ addr = in.s_addr;
+ *res = malloc_ai(port, addr, hints);
+ if (*res == NULL)
+ return (EAI_MEMORY);
+ return (0);
+ }
+
+ if (!hostname) {
+ *res = malloc_ai(port, htonl(0x7f000001), hints);
+ if (*res == NULL)
+ return (EAI_MEMORY);
+ return (0);
+ }
+
+ if (inet_aton(hostname, &in)) {
+ *res = malloc_ai(port, in.s_addr, hints);
+ if (*res == NULL)
+ return (EAI_MEMORY);
+ return (0);
+ }
+
+ /* Don't try DNS if AI_NUMERICHOST is set */
+ if (hints && hints->ai_flags & AI_NUMERICHOST)
+ return (EAI_NONAME);
+
+ hp = gethostbyname(hostname);
+ if (hp && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) {
+ struct addrinfo *cur, *prev;
+
+ cur = prev = *res = NULL;
+ for (i = 0; hp->h_addr_list[i]; i++) {
+ struct in_addr *in = (struct in_addr *)hp->h_addr_list[i];
+
+ cur = malloc_ai(port, in->s_addr, hints);
+ if (cur == NULL) {
+ if (*res != NULL)
+ freeaddrinfo(*res);
+ return (EAI_MEMORY);
+ }
+ if (prev)
+ prev->ai_next = cur;
+ else
+ *res = cur;
+
+ prev = cur;
+ }
+ return (0);
+ }
+
+ return (EAI_NODATA);
+}
+#endif /* !HAVE_GETADDRINFO */
diff --git a/libs/ldns/compat/fake-rfc2553.h b/libs/ldns/compat/fake-rfc2553.h
new file mode 100644
index 0000000000..2eab0c8bc4
--- /dev/null
+++ b/libs/ldns/compat/fake-rfc2553.h
@@ -0,0 +1,187 @@
+/* From openssh 4.3p2 filename openbsd-compat/fake-rfc2553.h */
+/*
+ * Copyright (C) 2000-2003 Damien Miller. All rights reserved.
+ * Copyright (C) 1999 WIDE Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Pseudo-implementation of RFC2553 name / address resolution functions
+ *
+ * But these functions are not implemented correctly. The minimum subset
+ * is implemented for ssh use only. For example, this routine assumes
+ * that ai_family is AF_INET. Don't use it for another purpose.
+ */
+
+#ifndef _FAKE_RFC2553_H
+#define _FAKE_RFC2553_H
+
+#include
+#ifdef _MSC_VER
+#include
+#else
+#include
+#include
+#endif
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * First, socket and INET6 related definitions
+ */
+#ifndef HAVE_STRUCT_SOCKADDR_STORAGE
+#ifndef _SS_MAXSIZE
+# define _SS_MAXSIZE 128 /* Implementation specific max size */
+# define _SS_PADSIZE (_SS_MAXSIZE - sizeof (struct sockaddr))
+struct sockaddr_storage {
+ struct sockaddr ss_sa;
+ char __ss_pad2[_SS_PADSIZE];
+};
+# define ss_family ss_sa.sa_family
+#endif /* _SS_MAXSIZE */
+#endif /* !HAVE_STRUCT_SOCKADDR_STORAGE */
+
+#ifndef IN6_IS_ADDR_LOOPBACK
+# define IN6_IS_ADDR_LOOPBACK(a) \
+ (((uint32_t *)(a))[0] == 0 && ((uint32_t *)(a))[1] == 0 && \
+ ((uint32_t *)(a))[2] == 0 && ((uint32_t *)(a))[3] == htonl(1))
+#endif /* !IN6_IS_ADDR_LOOPBACK */
+
+#ifndef HAVE_STRUCT_IN6_ADDR
+struct in6_addr {
+ uint8_t s6_addr[16];
+};
+#endif /* !HAVE_STRUCT_IN6_ADDR */
+
+#ifndef HAVE_STRUCT_SOCKADDR_IN6
+struct sockaddr_in6 {
+ unsigned short sin6_family;
+ uint16_t sin6_port;
+ uint32_t sin6_flowinfo;
+ struct in6_addr sin6_addr;
+};
+#endif /* !HAVE_STRUCT_SOCKADDR_IN6 */
+
+#ifndef AF_INET6
+/* Define it to something that should never appear */
+#define AF_INET6 AF_MAX
+#endif
+
+/*
+ * Next, RFC2553 name / address resolution API
+ */
+
+#ifndef NI_NUMERICHOST
+# define NI_NUMERICHOST (1)
+#endif
+#ifndef NI_NAMEREQD
+# define NI_NAMEREQD (1<<1)
+#endif
+#ifndef NI_NUMERICSERV
+# define NI_NUMERICSERV (1<<2)
+#endif
+
+#ifndef AI_PASSIVE
+# define AI_PASSIVE (1)
+#endif
+#ifndef AI_CANONNAME
+# define AI_CANONNAME (1<<1)
+#endif
+#ifndef AI_NUMERICHOST
+# define AI_NUMERICHOST (1<<2)
+#endif
+
+#ifndef NI_MAXSERV
+# define NI_MAXSERV 32
+#endif /* !NI_MAXSERV */
+#ifndef NI_MAXHOST
+# define NI_MAXHOST 1025
+#endif /* !NI_MAXHOST */
+
+#ifndef INT_MAX
+#define INT_MAX 0xffffffff
+#endif
+
+#ifndef EAI_NODATA
+# define EAI_NODATA (INT_MAX - 1)
+#endif
+#ifndef EAI_MEMORY
+# define EAI_MEMORY (INT_MAX - 2)
+#endif
+#ifndef EAI_NONAME
+# define EAI_NONAME (INT_MAX - 3)
+#endif
+#ifndef EAI_SYSTEM
+# define EAI_SYSTEM (INT_MAX - 4)
+#endif
+
+#ifndef HAVE_STRUCT_ADDRINFO
+struct addrinfo {
+ int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
+ int ai_family; /* PF_xxx */
+ int ai_socktype; /* SOCK_xxx */
+ int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
+ size_t ai_addrlen; /* length of ai_addr */
+ char *ai_canonname; /* canonical name for hostname */
+ struct sockaddr *ai_addr; /* binary address */
+ struct addrinfo *ai_next; /* next structure in linked list */
+};
+#endif /* !HAVE_STRUCT_ADDRINFO */
+
+#ifndef HAVE_GETADDRINFO
+#ifdef getaddrinfo
+# undef getaddrinfo
+#endif
+#define getaddrinfo(a,b,c,d) (ssh_getaddrinfo(a,b,c,d))
+int getaddrinfo(const char *, const char *,
+ const struct addrinfo *, struct addrinfo **);
+#endif /* !HAVE_GETADDRINFO */
+
+#if !defined(HAVE_GAI_STRERROR) && !defined(HAVE_CONST_GAI_STRERROR_PROTO)
+#define gai_strerror(a) (ssh_gai_strerror(a))
+char *gai_strerror(int);
+#endif /* !HAVE_GAI_STRERROR */
+
+#ifndef HAVE_FREEADDRINFO
+#define freeaddrinfo(a) (ssh_freeaddrinfo(a))
+void freeaddrinfo(struct addrinfo *);
+#endif /* !HAVE_FREEADDRINFO */
+
+#ifndef HAVE_GETNAMEINFO
+#define getnameinfo(a,b,c,d,e,f,g) (ssh_getnameinfo(a,b,c,d,e,f,g))
+int getnameinfo(const struct sockaddr *, size_t, char *, size_t,
+ char *, size_t, int);
+#endif /* !HAVE_GETNAMEINFO */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* !_FAKE_RFC2553_H */
+
diff --git a/libs/ldns/compat/gettimeofday.c b/libs/ldns/compat/gettimeofday.c
new file mode 100644
index 0000000000..3d1fb12810
--- /dev/null
+++ b/libs/ldns/compat/gettimeofday.c
@@ -0,0 +1,50 @@
+#include
+
+#ifndef HAVE_GETTIMEOFDAY
+
+#include < time.h >
+#include < windows.h>
+#include
+
+#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
+#define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
+#else
+#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
+#endif
+
+int gettimeofday(struct timeval *tv, struct timezone *tz)
+{
+ FILETIME ft;
+ unsigned __int64 tmpres = 0;
+ static int tzflag;
+
+ if (NULL != tv)
+ {
+ GetSystemTimeAsFileTime(&ft);
+
+ tmpres |= ft.dwHighDateTime;
+ tmpres <<= 32;
+ tmpres |= ft.dwLowDateTime;
+
+ /*converting file time to unix epoch*/
+ tmpres /= 10; /*convert into microseconds*/
+ tmpres -= DELTA_EPOCH_IN_MICROSECS;
+ tv->tv_sec = (long)(tmpres / 1000000UL);
+ tv->tv_usec = (long)(tmpres % 1000000UL);
+ }
+
+ if (NULL != tz)
+ {
+ if (!tzflag)
+ {
+ _tzset();
+ tzflag++;
+ }
+ tz->tz_minuteswest = _timezone / 60;
+ tz->tz_dsttime = _daylight;
+ }
+
+ return 0;
+}
+
+#endif
\ No newline at end of file
diff --git a/libs/ldns/compat/gettimeofday.h b/libs/ldns/compat/gettimeofday.h
new file mode 100644
index 0000000000..5a929fe082
--- /dev/null
+++ b/libs/ldns/compat/gettimeofday.h
@@ -0,0 +1,11 @@
+#ifndef HAVE_GETTIMEOFDAY
+
+struct timezone
+{
+ int tz_minuteswest; /* minutes W of Greenwich */
+ int tz_dsttime; /* type of dst correction */
+};
+
+int gettimeofday(struct timeval *tv, struct timezone *tz);
+
+#endif
\ No newline at end of file
diff --git a/libs/ldns/compat/gmtime_r.c b/libs/ldns/compat/gmtime_r.c
new file mode 100644
index 0000000000..7062e7dee3
--- /dev/null
+++ b/libs/ldns/compat/gmtime_r.c
@@ -0,0 +1,14 @@
+#ifdef HAVE_CONFIG_H
+#include
+#endif
+
+#ifdef HAVE_TIME_H
+#include
+#endif
+
+struct tm *gmtime_r(const time_t *timep, struct tm *result)
+{
+ /* no thread safety. */
+ *result = *gmtime(timep);
+ return result;
+}
diff --git a/libs/ldns/compat/inet_aton.c b/libs/ldns/compat/inet_aton.c
new file mode 100644
index 0000000000..86cd1125a5
--- /dev/null
+++ b/libs/ldns/compat/inet_aton.c
@@ -0,0 +1,184 @@
+/* From openssh4.3p2 compat/inet_aton.c */
+/*
+ * Copyright (c) 1983, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * -
+ * Portions Copyright (c) 1993 by Digital Equipment Corporation.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies, and that
+ * the name of Digital Equipment Corporation not be used in advertising or
+ * publicity pertaining to distribution of the document or software without
+ * specific, written prior permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
+ * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ * -
+ * --Copyright--
+ */
+
+/* OPENBSD ORIGINAL: lib/libc/net/inet_addr.c */
+
+#include
+
+#if !defined(HAVE_INET_ATON)
+
+#include
+#ifndef _MSC_VER
+#include
+#endif
+#ifdef HAVE_NETINET_IN_H
+#include
+#endif
+#ifdef HAVE_ARPA_INET_H
+#include
+#endif
+#include
+
+#if 0
+/*
+ * Ascii internet address interpretation routine.
+ * The value returned is in network order.
+ */
+in_addr_t
+inet_addr(const char *cp)
+{
+ struct in_addr val;
+
+ if (inet_aton(cp, &val))
+ return (val.s_addr);
+ return (INADDR_NONE);
+}
+#endif
+
+/*
+ * Check whether "cp" is a valid ascii representation
+ * of an Internet address and convert to a binary address.
+ * Returns 1 if the address is valid, 0 if not.
+ * This replaces inet_addr, the return value from which
+ * cannot distinguish between failure and a local broadcast address.
+ */
+int
+inet_aton(const char *cp, struct in_addr *addr)
+{
+ uint32_t val;
+ int base, n;
+ char c;
+ unsigned int parts[4];
+ unsigned int *pp = parts;
+
+ c = *cp;
+ for (;;) {
+ /*
+ * Collect number up to ``.''.
+ * Values are specified as for C:
+ * 0x=hex, 0=octal, isdigit=decimal.
+ */
+ if (!isdigit((int) c))
+ return (0);
+ val = 0; base = 10;
+ if (c == '0') {
+ c = *++cp;
+ if (c == 'x' || c == 'X')
+ base = 16, c = *++cp;
+ else
+ base = 8;
+ }
+ for (;;) {
+ if (isascii((int) c) && isdigit((int) c)) {
+ val = (val * base) + (c - '0');
+ c = *++cp;
+ } else if (base == 16 && isascii((int) c) && isxdigit((int) c)) {
+ val = (val << 4) |
+ (c + 10 - (islower((int) c) ? 'a' : 'A'));
+ c = *++cp;
+ } else
+ break;
+ }
+ if (c == '.') {
+ /*
+ * Internet format:
+ * a.b.c.d
+ * a.b.c (with c treated as 16 bits)
+ * a.b (with b treated as 24 bits)
+ */
+ if (pp >= parts + 3)
+ return (0);
+ *pp++ = val;
+ c = *++cp;
+ } else
+ break;
+ }
+ /*
+ * Check for trailing characters.
+ */
+ if (c != '\0' && (!isascii((int) c) || !isspace((int) c)))
+ return (0);
+ /*
+ * Concoct the address according to
+ * the number of parts specified.
+ */
+ n = pp - parts + 1;
+ switch (n) {
+
+ case 0:
+ return (0); /* initial nondigit */
+
+ case 1: /* a -- 32 bits */
+ break;
+
+ case 2: /* a.b -- 8.24 bits */
+ if ((val > 0xffffff) || (parts[0] > 0xff))
+ return (0);
+ val |= parts[0] << 24;
+ break;
+
+ case 3: /* a.b.c -- 8.8.16 bits */
+ if ((val > 0xffff) || (parts[0] > 0xff) || (parts[1] > 0xff))
+ return (0);
+ val |= (parts[0] << 24) | (parts[1] << 16);
+ break;
+
+ case 4: /* a.b.c.d -- 8.8.8.8 bits */
+ if ((val > 0xff) || (parts[0] > 0xff) || (parts[1] > 0xff) || (parts[2] > 0xff))
+ return (0);
+ val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
+ break;
+ }
+ if (addr)
+ addr->s_addr = htonl(val);
+ return (1);
+}
+
+#endif /* !defined(HAVE_INET_ATON) */
diff --git a/libs/ldns/compat/inet_ntop.c b/libs/ldns/compat/inet_ntop.c
new file mode 100644
index 0000000000..bb7b067ec3
--- /dev/null
+++ b/libs/ldns/compat/inet_ntop.c
@@ -0,0 +1,218 @@
+/* From openssh 4.3p2 compat/inet_ntop.c */
+/* Copyright (c) 1996 by Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+/* OPENBSD ORIGINAL: lib/libc/net/inet_ntop.c */
+
+#include
+
+#ifndef HAVE_INET_NTOP
+
+#ifndef _MSC_VER
+#include
+#endif
+#include
+#ifdef HAVE_SYS_SOCKET_H
+#include
+#endif
+#ifdef HAVE_NETINET_IN_H
+#include
+#endif
+#include
+#include
+#include
+
+#ifndef IN6ADDRSZ
+#define IN6ADDRSZ 16 /* IPv6 T_AAAA */
+#endif
+
+#ifndef INT16SZ
+#define INT16SZ 2 /* for systems without 16-bit ints */
+#endif
+
+/*
+ * WARNING: Don't even consider trying to compile this on a system where
+ * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
+ */
+
+static const char *inet_ntop4(const u_char *src, char *dst, size_t size);
+static const char *inet_ntop6(const u_char *src, char *dst, size_t size);
+
+/* char *
+ * inet_ntop(af, src, dst, size)
+ * convert a network format address to presentation format.
+ * return:
+ * pointer to presentation format address (`dst'), or NULL (see errno).
+ * author:
+ * Paul Vixie, 1996.
+ */
+const char *
+inet_ntop(int af, const void *src, char *dst, size_t size)
+{
+ switch (af) {
+ case AF_INET:
+ return (inet_ntop4(src, dst, size));
+ case AF_INET6:
+ return (inet_ntop6(src, dst, size));
+ default:
+#ifdef EAFNOSUPPORT
+ errno = EAFNOSUPPORT;
+#else
+ errno = ENOSYS;
+#endif
+ return (NULL);
+ }
+ /* NOTREACHED */
+}
+
+/* const char *
+ * inet_ntop4(src, dst, size)
+ * format an IPv4 address, more or less like inet_ntoa()
+ * return:
+ * `dst' (as a const)
+ * notes:
+ * (1) uses no statics
+ * (2) takes a u_char* not an in_addr as input
+ * author:
+ * Paul Vixie, 1996.
+ */
+static const char *
+inet_ntop4(const u_char *src, char *dst, size_t size)
+{
+ static const char fmt[] = "%u.%u.%u.%u";
+ char tmp[sizeof "255.255.255.255"];
+ int l;
+
+ l = snprintf(tmp, size, fmt, src[0], src[1], src[2], src[3]);
+ if (l <= 0 || l >= (int)size) {
+ errno = ENOSPC;
+ return (NULL);
+ }
+ strlcpy(dst, tmp, size);
+ return (dst);
+}
+
+/* const char *
+ * inet_ntop6(src, dst, size)
+ * convert IPv6 binary address into presentation (printable) format
+ * author:
+ * Paul Vixie, 1996.
+ */
+static const char *
+inet_ntop6(const u_char *src, char *dst, size_t size)
+{
+ /*
+ * Note that int32_t and int16_t need only be "at least" large enough
+ * to contain a value of the specified size. On some systems, like
+ * Crays, there is no such thing as an integer variable with 16 bits.
+ * Keep this in mind if you think this function should have been coded
+ * to use pointer overlays. All the world's not a VAX.
+ */
+ char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"];
+ char *tp, *ep;
+ struct { int base, len; } best, cur;
+ u_int words[IN6ADDRSZ / INT16SZ];
+ int i;
+ int advance;
+
+ /*
+ * Preprocess:
+ * Copy the input (bytewise) array into a wordwise array.
+ * Find the longest run of 0x00's in src[] for :: shorthanding.
+ */
+ memset(words, '\0', sizeof words);
+ for (i = 0; i < IN6ADDRSZ; i++)
+ words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));
+ best.base = -1;
+ cur.base = -1;
+ for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) {
+ if (words[i] == 0) {
+ if (cur.base == -1)
+ cur.base = i, cur.len = 1;
+ else
+ cur.len++;
+ } else {
+ if (cur.base != -1) {
+ if (best.base == -1 || cur.len > best.len)
+ best = cur;
+ cur.base = -1;
+ }
+ }
+ }
+ if (cur.base != -1) {
+ if (best.base == -1 || cur.len > best.len)
+ best = cur;
+ }
+ if (best.base != -1 && best.len < 2)
+ best.base = -1;
+
+ /*
+ * Format the result.
+ */
+ tp = tmp;
+ ep = tmp + sizeof(tmp);
+ for (i = 0; i < (IN6ADDRSZ / INT16SZ) && tp < ep; i++) {
+ /* Are we inside the best run of 0x00's? */
+ if (best.base != -1 && i >= best.base &&
+ i < (best.base + best.len)) {
+ if (i == best.base) {
+ if (tp + 1 >= ep)
+ return (NULL);
+ *tp++ = ':';
+ }
+ continue;
+ }
+ /* Are we following an initial run of 0x00s or any real hex? */
+ if (i != 0) {
+ if (tp + 1 >= ep)
+ return (NULL);
+ *tp++ = ':';
+ }
+ /* Is this address an encapsulated IPv4? */
+ if (i == 6 && best.base == 0 &&
+ (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) {
+ if (!inet_ntop4(src+12, tp, (size_t)(ep - tp)))
+ return (NULL);
+ tp += strlen(tp);
+ break;
+ }
+ advance = snprintf(tp, ep - tp, "%x", words[i]);
+ if (advance <= 0 || advance >= ep - tp)
+ return (NULL);
+ tp += advance;
+ }
+ /* Was it a trailing run of 0x00's? */
+ if (best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ)) {
+ if (tp + 1 >= ep)
+ return (NULL);
+ *tp++ = ':';
+ }
+ if (tp + 1 >= ep)
+ return (NULL);
+ *tp++ = '\0';
+
+ /*
+ * Check for overflow, copy, and we're done.
+ */
+ if ((size_t)(tp - tmp) > size) {
+ errno = ENOSPC;
+ return (NULL);
+ }
+ strlcpy(dst, tmp, size);
+ return (dst);
+}
+
+#endif /* !HAVE_INET_NTOP */
diff --git a/libs/ldns/compat/inet_pton.c b/libs/ldns/compat/inet_pton.c
new file mode 100644
index 0000000000..7a4f57614f
--- /dev/null
+++ b/libs/ldns/compat/inet_pton.c
@@ -0,0 +1,230 @@
+/* $KAME: inet_pton.c,v 1.5 2001/08/20 02:32:40 itojun Exp $ */
+
+/* Copyright (c) 1996 by Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+#include
+
+#include
+#include
+#include
+
+/*
+ * WARNING: Don't even consider trying to compile this on a system where
+ * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
+ */
+
+static int inet_pton4 (const char *src, uint8_t *dst);
+static int inet_pton6 (const char *src, uint8_t *dst);
+
+/*
+ *
+ * The definitions we might miss.
+ *
+ */
+#ifndef NS_INT16SZ
+#define NS_INT16SZ 2
+#endif
+
+#ifndef NS_IN6ADDRSZ
+#define NS_IN6ADDRSZ 16
+#endif
+
+#ifndef NS_INADDRSZ
+#define NS_INADDRSZ 4
+#endif
+
+/* int
+ * inet_pton(af, src, dst)
+ * convert from presentation format (which usually means ASCII printable)
+ * to network format (which is usually some kind of binary format).
+ * return:
+ * 1 if the address was valid for the specified address family
+ * 0 if the address wasn't valid (`dst' is untouched in this case)
+ * -1 if some other error occurred (`dst' is untouched in this case, too)
+ * author:
+ * Paul Vixie, 1996.
+ */
+int
+inet_pton(af, src, dst)
+ int af;
+ const char *src;
+ void *dst;
+{
+ switch (af) {
+ case AF_INET:
+ return (inet_pton4(src, dst));
+ case AF_INET6:
+ return (inet_pton6(src, dst));
+ default:
+#ifdef EAFNOSUPPORT
+ errno = EAFNOSUPPORT;
+#else
+ errno = ENOSYS;
+#endif
+ return (-1);
+ }
+ /* NOTREACHED */
+}
+
+/* int
+ * inet_pton4(src, dst)
+ * like inet_aton() but without all the hexadecimal and shorthand.
+ * return:
+ * 1 if `src' is a valid dotted quad, else 0.
+ * notice:
+ * does not touch `dst' unless it's returning 1.
+ * author:
+ * Paul Vixie, 1996.
+ */
+static int
+inet_pton4(src, dst)
+ const char *src;
+ uint8_t *dst;
+{
+ static const char digits[] = "0123456789";
+ int saw_digit, octets, ch;
+ uint8_t tmp[NS_INADDRSZ], *tp;
+
+ saw_digit = 0;
+ octets = 0;
+ *(tp = tmp) = 0;
+ while ((ch = *src++) != '\0') {
+ const char *pch;
+
+ if ((pch = strchr(digits, ch)) != NULL) {
+ uint32_t new = *tp * 10 + (pch - digits);
+
+ if (new > 255)
+ return (0);
+ *tp = new;
+ if (! saw_digit) {
+ if (++octets > 4)
+ return (0);
+ saw_digit = 1;
+ }
+ } else if (ch == '.' && saw_digit) {
+ if (octets == 4)
+ return (0);
+ *++tp = 0;
+ saw_digit = 0;
+ } else
+ return (0);
+ }
+ if (octets < 4)
+ return (0);
+
+ memcpy(dst, tmp, NS_INADDRSZ);
+ return (1);
+}
+
+/* int
+ * inet_pton6(src, dst)
+ * convert presentation level address to network order binary form.
+ * return:
+ * 1 if `src' is a valid [RFC1884 2.2] address, else 0.
+ * notice:
+ * (1) does not touch `dst' unless it's returning 1.
+ * (2) :: in a full address is silently ignored.
+ * credit:
+ * inspired by Mark Andrews.
+ * author:
+ * Paul Vixie, 1996.
+ */
+static int
+inet_pton6(src, dst)
+ const char *src;
+ uint8_t *dst;
+{
+ static const char xdigits_l[] = "0123456789abcdef",
+ xdigits_u[] = "0123456789ABCDEF";
+ uint8_t tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp;
+ const char *xdigits, *curtok;
+ int ch, saw_xdigit;
+ uint32_t val;
+
+ memset((tp = tmp), '\0', NS_IN6ADDRSZ);
+ endp = tp + NS_IN6ADDRSZ;
+ colonp = NULL;
+ /* Leading :: requires some special handling. */
+ if (*src == ':')
+ if (*++src != ':')
+ return (0);
+ curtok = src;
+ saw_xdigit = 0;
+ val = 0;
+ while ((ch = *src++) != '\0') {
+ const char *pch;
+
+ if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL)
+ pch = strchr((xdigits = xdigits_u), ch);
+ if (pch != NULL) {
+ val <<= 4;
+ val |= (pch - xdigits);
+ if (val > 0xffff)
+ return (0);
+ saw_xdigit = 1;
+ continue;
+ }
+ if (ch == ':') {
+ curtok = src;
+ if (!saw_xdigit) {
+ if (colonp)
+ return (0);
+ colonp = tp;
+ continue;
+ }
+ if (tp + NS_INT16SZ > endp)
+ return (0);
+ *tp++ = (uint8_t) (val >> 8) & 0xff;
+ *tp++ = (uint8_t) val & 0xff;
+ saw_xdigit = 0;
+ val = 0;
+ continue;
+ }
+ if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) &&
+ inet_pton4(curtok, tp) > 0) {
+ tp += NS_INADDRSZ;
+ saw_xdigit = 0;
+ break; /* '\0' was seen by inet_pton4(). */
+ }
+ return (0);
+ }
+ if (saw_xdigit) {
+ if (tp + NS_INT16SZ > endp)
+ return (0);
+ *tp++ = (uint8_t) (val >> 8) & 0xff;
+ *tp++ = (uint8_t) val & 0xff;
+ }
+ if (colonp != NULL) {
+ /*
+ * Since some memmove()'s erroneously fail to handle
+ * overlapping regions, we'll do the shift by hand.
+ */
+ const int n = tp - colonp;
+ int i;
+
+ for (i = 1; i <= n; i++) {
+ endp[- i] = colonp[n - i];
+ colonp[n - i] = 0;
+ }
+ tp = endp;
+ }
+ if (tp != endp)
+ return (0);
+ memcpy(dst, tmp, NS_IN6ADDRSZ);
+ return (1);
+}
diff --git a/libs/ldns/compat/isascii.c b/libs/ldns/compat/isascii.c
new file mode 100644
index 0000000000..8a4ab37431
--- /dev/null
+++ b/libs/ldns/compat/isascii.c
@@ -0,0 +1,15 @@
+/* Just a replacement, if the original isascii is not
+ present */
+
+#if HAVE_CONFIG_H
+#include
+#endif
+
+int isascii(int c);
+
+/* true if character is ascii. */
+int
+isascii(int c)
+{
+ return c >= 0 && c < 128;
+}
diff --git a/libs/ldns/compat/isblank.c b/libs/ldns/compat/isblank.c
new file mode 100644
index 0000000000..3b38154c5f
--- /dev/null
+++ b/libs/ldns/compat/isblank.c
@@ -0,0 +1,15 @@
+/* Just a replacement, if the original isblank is not
+ present */
+
+#if HAVE_CONFIG_H
+#include
+#endif
+
+int isblank(int c);
+
+/* true if character is a blank (space or tab). C99. */
+int
+isblank(int c)
+{
+ return (c == ' ') || (c == '\t');
+}
diff --git a/libs/ldns/compat/malloc.c b/libs/ldns/compat/malloc.c
new file mode 100644
index 0000000000..d51d4b0a92
--- /dev/null
+++ b/libs/ldns/compat/malloc.c
@@ -0,0 +1,24 @@
+/* Just a replacement, if the original malloc is not
+ GNU-compliant. See autoconf documentation. */
+
+#if HAVE_CONFIG_H
+#include
+#endif
+#undef malloc
+
+#include
+
+#ifndef _MSC_VER
+void *malloc ();
+#endif
+
+/* Allocate an N-byte block of memory from the heap.
+ If N is zero, allocate a 1-byte block. */
+
+void *
+rpl_malloc (size_t n)
+{
+ if (n == 0)
+ n = 1;
+ return malloc (n);
+}
diff --git a/libs/ldns/compat/memmove.c b/libs/ldns/compat/memmove.c
new file mode 100644
index 0000000000..8f3f54f5cc
--- /dev/null
+++ b/libs/ldns/compat/memmove.c
@@ -0,0 +1,45 @@
+/*
+ * memmove.c: memmove compat implementation.
+ *
+ * Copyright (c) 2001-2008, NLnet Labs. All rights reserved.
+ *
+ * See LICENSE for the license.
+*/
+
+#include
+#include
+
+#ifndef _MSC_VER
+void *memmove(void *dest, const void *src, size_t n);
+
+void *memmove(void *dest, const void *src, size_t n)
+{
+ uint8_t* from = (uint8_t*) src;
+ uint8_t* to = (uint8_t*) dest;
+
+ if (from == to || n == 0)
+ return dest;
+ if (to > from && to-from < (int)n) {
+ /* to overlaps with from */
+ /* */
+ /* */
+ /* copy in reverse, to avoid overwriting from */
+ int i;
+ for(i=n-1; i>=0; i--)
+ to[i] = from[i];
+ return dest;
+ }
+ if (from > to && from-to < (int)n) {
+ /* to overlaps with from */
+ /* */
+ /* */
+ /* copy forwards, to avoid overwriting from */
+ size_t i;
+ for(i=0; i